aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/Kconfig3
-rw-r--r--arch/alpha/include/asm/mman.h4
-rw-r--r--arch/alpha/include/asm/pci.h7
-rw-r--r--arch/alpha/kernel/pci.c86
-rw-r--r--arch/alpha/kernel/pci_impl.h3
-rw-r--r--arch/alpha/kernel/sys_marvel.c3
-rw-r--r--arch/alpha/kernel/sys_titan.c3
-rw-r--r--arch/arm/Kconfig45
-rw-r--r--arch/arm/Kconfig.debug164
-rw-r--r--arch/arm/Makefile3
-rw-r--r--arch/arm/boot/compressed/head.S2
-rw-r--r--arch/arm/boot/dts/am3517_mt_ventoux.dts27
-rw-r--r--arch/arm/boot/dts/at91sam9g20.dtsi131
-rw-r--r--arch/arm/boot/dts/at91sam9g25ek.dts49
-rw-r--r--arch/arm/boot/dts/at91sam9g45.dtsi151
-rw-r--r--arch/arm/boot/dts/at91sam9m10g45ek.dts118
-rw-r--r--arch/arm/boot/dts/at91sam9x5.dtsi264
-rw-r--r--arch/arm/boot/dts/at91sam9x5cm.dtsi74
-rw-r--r--arch/arm/boot/dts/db8500.dtsi275
-rw-r--r--arch/arm/boot/dts/exynos5250-smdk5250.dts26
-rw-r--r--arch/arm/boot/dts/exynos5250.dtsi413
-rw-r--r--arch/arm/boot/dts/highbank.dts8
-rw-r--r--arch/arm/boot/dts/imx27-phytec-phycore.dts76
-rw-r--r--arch/arm/boot/dts/imx27.dtsi217
-rw-r--r--arch/arm/boot/dts/imx51-babbage.dts91
-rw-r--r--arch/arm/boot/dts/imx6q-arm2.dts14
-rw-r--r--arch/arm/boot/dts/imx6q-sabrelite.dts34
-rw-r--r--arch/arm/boot/dts/imx6q.dtsi6
-rw-r--r--arch/arm/boot/dts/kirkwood-dreamplug.dts24
-rw-r--r--arch/arm/boot/dts/kirkwood.dtsi36
-rw-r--r--arch/arm/boot/dts/omap3-beagle.dts9
-rw-r--r--arch/arm/boot/dts/omap3-evm.dts20
-rw-r--r--arch/arm/boot/dts/omap3.dtsi35
-rw-r--r--arch/arm/boot/dts/omap4-panda.dts9
-rw-r--r--arch/arm/boot/dts/omap4-sdp.dts9
-rw-r--r--arch/arm/boot/dts/omap4.dtsi38
-rw-r--r--arch/arm/boot/dts/pxa168-aspenite.dts38
-rw-r--r--arch/arm/boot/dts/pxa168.dtsi98
-rw-r--r--arch/arm/boot/dts/snowball.dts139
-rw-r--r--arch/arm/boot/dts/spear600-evb.dts47
-rw-r--r--arch/arm/boot/dts/spear600.dtsi174
-rw-r--r--arch/arm/boot/dts/tegra-cardhu.dts34
-rw-r--r--arch/arm/boot/dts/tegra-harmony.dts45
-rw-r--r--arch/arm/boot/dts/tegra-paz00.dts57
-rw-r--r--arch/arm/boot/dts/tegra-seaboard.dts79
-rw-r--r--arch/arm/boot/dts/tegra-trimslice.dts12
-rw-r--r--arch/arm/boot/dts/tegra-ventana.dts42
-rw-r--r--arch/arm/boot/dts/tegra20.dtsi50
-rw-r--r--arch/arm/boot/dts/tegra30.dtsi61
-rw-r--r--arch/arm/boot/dts/usb_a9g20-dab-mmx.dtsi96
-rw-r--r--arch/arm/boot/dts/usb_a9g20.dts97
-rw-r--r--arch/arm/boot/dts/vexpress-v2m-rs1.dtsi201
-rw-r--r--arch/arm/boot/dts/vexpress-v2m.dtsi200
-rw-r--r--arch/arm/boot/dts/vexpress-v2p-ca15-tc1.dts157
-rw-r--r--arch/arm/boot/dts/vexpress-v2p-ca5s.dts162
-rw-r--r--arch/arm/boot/dts/vexpress-v2p-ca9.dts192
-rw-r--r--arch/arm/common/Kconfig3
-rw-r--r--arch/arm/common/Makefile1
-rw-r--r--arch/arm/common/it8152.c4
-rw-r--r--arch/arm/common/sa1111.c281
-rw-r--r--arch/arm/common/timer-sp.c17
-rw-r--r--arch/arm/configs/at91cap9_defconfig108
-rw-r--r--arch/arm/configs/at91sam9g20_defconfig3
-rw-r--r--arch/arm/configs/imx_v4_v5_defconfig19
-rw-r--r--arch/arm/configs/imx_v6_v7_defconfig39
-rw-r--r--arch/arm/configs/lpc32xx_defconfig145
-rw-r--r--arch/arm/configs/magician_defconfig2
-rw-r--r--arch/arm/configs/mini2440_defconfig2
-rw-r--r--arch/arm/configs/mxs_defconfig20
-rw-r--r--arch/arm/configs/s3c2410_defconfig57
-rw-r--r--arch/arm/configs/tct_hammer_defconfig2
-rw-r--r--arch/arm/configs/tegra_defconfig33
-rw-r--r--arch/arm/configs/u8500_defconfig1
-rw-r--r--arch/arm/include/asm/hardware/arm_timer.h5
-rw-r--r--arch/arm/include/asm/hardware/entry-macro-iomd.S8
-rw-r--r--arch/arm/include/asm/hardware/sa1111.h156
-rw-r--r--arch/arm/include/asm/hardware/timer-sp.h15
-rw-r--r--arch/arm/include/asm/localtimer.h37
-rw-r--r--arch/arm/include/asm/pci.h8
-rw-r--r--arch/arm/include/asm/pgtable-nommu.h1
-rw-r--r--arch/arm/include/asm/smp_twd.h25
-rw-r--r--arch/arm/include/asm/system_misc.h1
-rw-r--r--arch/arm/kernel/Makefile4
-rw-r--r--arch/arm/kernel/bios32.c75
-rw-r--r--arch/arm/kernel/entry-armv.S3
-rw-r--r--arch/arm/kernel/entry-common.S8
-rw-r--r--arch/arm/kernel/process.c30
-rw-r--r--arch/arm/kernel/smp.c22
-rw-r--r--arch/arm/kernel/smp_twd.c123
-rw-r--r--arch/arm/mach-at91/Kconfig33
-rw-r--r--arch/arm/mach-at91/Makefile5
-rw-r--r--arch/arm/mach-at91/Makefile.boot14
-rw-r--r--arch/arm/mach-at91/at91cap9.c398
-rw-r--r--arch/arm/mach-at91/at91cap9_devices.c1273
-rw-r--r--arch/arm/mach-at91/at91rm9200.c16
-rw-r--r--arch/arm/mach-at91/at91rm9200_devices.c14
-rw-r--r--arch/arm/mach-at91/at91rm9200_time.c37
-rw-r--r--arch/arm/mach-at91/at91sam9260.c25
-rw-r--r--arch/arm/mach-at91/at91sam9260_devices.c59
-rw-r--r--arch/arm/mach-at91/at91sam9261.c4
-rw-r--r--arch/arm/mach-at91/at91sam9261_devices.c31
-rw-r--r--arch/arm/mach-at91/at91sam9263.c5
-rw-r--r--arch/arm/mach-at91/at91sam9263_devices.c72
-rw-r--r--arch/arm/mach-at91/at91sam926x_time.c68
-rw-r--r--arch/arm/mach-at91/at91sam9_alt_reset.S12
-rw-r--r--arch/arm/mach-at91/at91sam9g45.c9
-rw-r--r--arch/arm/mach-at91/at91sam9g45_devices.c146
-rw-r--r--arch/arm/mach-at91/at91sam9g45_reset.S12
-rw-r--r--arch/arm/mach-at91/at91sam9rl.c4
-rw-r--r--arch/arm/mach-at91/at91sam9rl_devices.c31
-rw-r--r--arch/arm/mach-at91/at91sam9x5.c359
-rw-r--r--arch/arm/mach-at91/at91x40.c12
-rw-r--r--arch/arm/mach-at91/at91x40_time.c28
-rw-r--r--arch/arm/mach-at91/board-afeb-9260v1.c1
-rw-r--r--arch/arm/mach-at91/board-cam60.c1
-rw-r--r--arch/arm/mach-at91/board-cap9adk.c396
-rw-r--r--arch/arm/mach-at91/board-cpu9krea.c6
-rw-r--r--arch/arm/mach-at91/board-cpuat91.c1
-rw-r--r--arch/arm/mach-at91/board-dt.c76
-rw-r--r--arch/arm/mach-at91/board-eco920.c5
-rw-r--r--arch/arm/mach-at91/board-flexibity.c12
-rw-r--r--arch/arm/mach-at91/board-kb9202.c2
-rw-r--r--arch/arm/mach-at91/board-neocore926.c1
-rw-r--r--arch/arm/mach-at91/board-picotux200.c1
-rw-r--r--arch/arm/mach-at91/board-qil-a9260.c2
-rw-r--r--arch/arm/mach-at91/board-rm9200dk.c3
-rw-r--r--arch/arm/mach-at91/board-rm9200ek.c1
-rw-r--r--arch/arm/mach-at91/board-sam9-l9260.c1
-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.c2
-rw-r--r--arch/arm/mach-at91/board-sam9m10g45ek.c82
-rw-r--r--arch/arm/mach-at91/board-sam9rlek.c2
-rw-r--r--arch/arm/mach-at91/board-snapper9260.c11
-rw-r--r--arch/arm/mach-at91/board-stamp9g20.c1
-rw-r--r--arch/arm/mach-at91/board-usb-a926x.c2
-rw-r--r--arch/arm/mach-at91/board-yl-9200.c4
-rw-r--r--arch/arm/mach-at91/clock.c224
-rw-r--r--arch/arm/mach-at91/cpuidle.c11
-rw-r--r--arch/arm/mach-at91/generic.h19
-rw-r--r--arch/arm/mach-at91/gpio.c625
-rw-r--r--arch/arm/mach-at91/include/mach/at91_matrix.h23
-rw-r--r--arch/arm/mach-at91/include/mach/at91_pio.h25
-rw-r--r--arch/arm/mach-at91/include/mach/at91_pmc.h118
-rw-r--r--arch/arm/mach-at91/include/mach/at91_ramc.h32
-rw-r--r--arch/arm/mach-at91/include/mach/at91_shdwc.h4
-rw-r--r--arch/arm/mach-at91/include/mach/at91_st.h32
-rw-r--r--arch/arm/mach-at91/include/mach/at91cap9.h122
-rw-r--r--arch/arm/mach-at91/include/mach/at91cap9_matrix.h137
-rw-r--r--arch/arm/mach-at91/include/mach/at91rm9200.h10
-rw-r--r--arch/arm/mach-at91/include/mach/at91rm9200_mc.h58
-rw-r--r--arch/arm/mach-at91/include/mach/at91rm9200_sdramc.h63
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9260.h14
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9260_matrix.h36
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9261.h10
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9261_matrix.h18
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9263.h12
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9263_matrix.h74
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9_ddrsdr.h16
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9_sdramc.h6
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9g45.h12
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9g45_matrix.h84
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9rl.h7
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9rl_matrix.h42
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9x5.h74
-rw-r--r--arch/arm/mach-at91/include/mach/at91sam9x5_matrix.h53
-rw-r--r--arch/arm/mach-at91/include/mach/at91x40.h18
-rw-r--r--arch/arm/mach-at91/include/mach/board.h17
-rw-r--r--arch/arm/mach-at91/include/mach/cpu.h21
-rw-r--r--arch/arm/mach-at91/include/mach/entry-macro.S6
-rw-r--r--arch/arm/mach-at91/include/mach/gpio.h17
-rw-r--r--arch/arm/mach-at91/include/mach/hardware.h9
-rw-r--r--arch/arm/mach-at91/include/mach/io.h18
-rw-r--r--arch/arm/mach-at91/include/mach/system.h50
-rw-r--r--arch/arm/mach-at91/irq.c132
-rw-r--r--arch/arm/mach-at91/pm.c41
-rw-r--r--arch/arm/mach-at91/pm.h96
-rw-r--r--arch/arm/mach-at91/pm_slowclock.S275
-rw-r--r--arch/arm/mach-at91/setup.c184
-rw-r--r--arch/arm/mach-at91/soc.h5
-rw-r--r--arch/arm/mach-bcmring/core.c23
-rw-r--r--arch/arm/mach-bcmring/include/mach/entry-macro.S6
-rw-r--r--arch/arm/mach-bcmring/include/mach/system.h28
-rw-r--r--arch/arm/mach-clps711x/common.c16
-rw-r--r--arch/arm/mach-clps711x/include/mach/entry-macro.S6
-rw-r--r--arch/arm/mach-clps711x/include/mach/system.h35
-rw-r--r--arch/arm/mach-cns3xxx/include/mach/entry-macro.S15
-rw-r--r--arch/arm/mach-cns3xxx/include/mach/system.h25
-rw-r--r--arch/arm/mach-cns3xxx/pcie.c4
-rw-r--r--arch/arm/mach-davinci/board-dm355-evm.c3
-rw-r--r--arch/arm/mach-davinci/board-dm355-leopard.c3
-rw-r--r--arch/arm/mach-davinci/board-dm365-evm.c3
-rw-r--r--arch/arm/mach-davinci/board-dm644x-evm.c135
-rw-r--r--arch/arm/mach-davinci/board-dm646x-evm.c32
-rw-r--r--arch/arm/mach-davinci/board-neuros-osd2.c3
-rw-r--r--arch/arm/mach-davinci/board-sffsdr.c3
-rw-r--r--arch/arm/mach-davinci/cpufreq.c2
-rw-r--r--arch/arm/mach-davinci/da850.c2
-rw-r--r--arch/arm/mach-davinci/davinci.h102
-rw-r--r--arch/arm/mach-davinci/devices.c32
-rw-r--r--arch/arm/mach-davinci/dm355.c3
-rw-r--r--arch/arm/mach-davinci/dm365.c19
-rw-r--r--arch/arm/mach-davinci/dm644x.c193
-rw-r--r--arch/arm/mach-davinci/dm646x.c21
-rw-r--r--arch/arm/mach-davinci/dma.c6
-rw-r--r--arch/arm/mach-davinci/include/mach/dm355.h32
-rw-r--r--arch/arm/mach-davinci/include/mach/dm365.h53
-rw-r--r--arch/arm/mach-davinci/include/mach/dm644x.h47
-rw-r--r--arch/arm/mach-davinci/include/mach/dm646x.h42
-rw-r--r--arch/arm/mach-davinci/include/mach/edma.h5
-rw-r--r--arch/arm/mach-davinci/include/mach/entry-macro.S6
-rw-r--r--arch/arm/mach-davinci/include/mach/hardware.h2
-rw-r--r--arch/arm/mach-davinci/include/mach/system.h21
-rw-r--r--arch/arm/mach-dove/include/mach/entry-macro.S6
-rw-r--r--arch/arm/mach-dove/include/mach/system.h17
-rw-r--r--arch/arm/mach-dove/pcie.c4
-rw-r--r--arch/arm/mach-ebsa110/core.c38
-rw-r--r--arch/arm/mach-ebsa110/core.h41
-rw-r--r--arch/arm/mach-ebsa110/include/mach/entry-macro.S6
-rw-r--r--arch/arm/mach-ebsa110/include/mach/hardware.h39
-rw-r--r--arch/arm/mach-ebsa110/include/mach/system.h37
-rw-r--r--arch/arm/mach-ebsa110/io.c20
-rw-r--r--arch/arm/mach-ebsa110/leds.c2
-rw-r--r--arch/arm/mach-ep93xx/Makefile3
-rw-r--r--arch/arm/mach-ep93xx/adssphere.c1
-rw-r--r--arch/arm/mach-ep93xx/clock.c1
-rw-r--r--arch/arm/mach-ep93xx/core.c81
-rw-r--r--arch/arm/mach-ep93xx/crunch-bits.S (renamed from arch/arm/kernel/crunch-bits.S)0
-rw-r--r--arch/arm/mach-ep93xx/crunch.c (renamed from arch/arm/kernel/crunch.c)4
-rw-r--r--arch/arm/mach-ep93xx/dma.c2
-rw-r--r--arch/arm/mach-ep93xx/edb93xx.c1
-rw-r--r--arch/arm/mach-ep93xx/gesbc9312.c1
-rw-r--r--arch/arm/mach-ep93xx/include/mach/entry-macro.S17
-rw-r--r--arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h191
-rw-r--r--arch/arm/mach-ep93xx/include/mach/gpio-ep93xx.h10
-rw-r--r--arch/arm/mach-ep93xx/include/mach/hardware.h1
-rw-r--r--arch/arm/mach-ep93xx/include/mach/platform.h14
-rw-r--r--arch/arm/mach-ep93xx/include/mach/system.h7
-rw-r--r--arch/arm/mach-ep93xx/micro9.c1
-rw-r--r--arch/arm/mach-ep93xx/simone.c2
-rw-r--r--arch/arm/mach-ep93xx/snappercl15.c2
-rw-r--r--arch/arm/mach-ep93xx/soc.h213
-rw-r--r--arch/arm/mach-ep93xx/ts72xx.c1
-rw-r--r--arch/arm/mach-ep93xx/vision_ep9307.c2
-rw-r--r--arch/arm/mach-exynos/Kconfig42
-rw-r--r--arch/arm/mach-exynos/Makefile8
-rw-r--r--arch/arm/mach-exynos/clock-exynos4.c1581
-rw-r--r--arch/arm/mach-exynos/clock-exynos4.h30
-rw-r--r--arch/arm/mach-exynos/clock-exynos4210.c48
-rw-r--r--arch/arm/mach-exynos/clock-exynos4212.c32
-rw-r--r--arch/arm/mach-exynos/clock-exynos5.c1247
-rw-r--r--arch/arm/mach-exynos/clock.c1564
-rw-r--r--arch/arm/mach-exynos/common.c532
-rw-r--r--arch/arm/mach-exynos/common.h40
-rw-r--r--arch/arm/mach-exynos/cpuidle.c151
-rw-r--r--arch/arm/mach-exynos/dev-ahci.c4
-rw-r--r--arch/arm/mach-exynos/dev-audio.c4
-rw-r--r--arch/arm/mach-exynos/dev-uart.c78
-rw-r--r--arch/arm/mach-exynos/dma.c153
-rw-r--r--arch/arm/mach-exynos/include/mach/cpufreq.h2
-rw-r--r--arch/arm/mach-exynos/include/mach/debug-macro.S9
-rw-r--r--arch/arm/mach-exynos/include/mach/entry-macro.S16
-rw-r--r--arch/arm/mach-exynos/include/mach/exynos4-clock.h43
-rw-r--r--arch/arm/mach-exynos/include/mach/gpio.h239
-rw-r--r--arch/arm/mach-exynos/include/mach/irqs.h595
-rw-r--r--arch/arm/mach-exynos/include/mach/map.h55
-rw-r--r--arch/arm/mach-exynos/include/mach/pmu.h2
-rw-r--r--arch/arm/mach-exynos/include/mach/regs-clock.h478
-rw-r--r--arch/arm/mach-exynos/include/mach/regs-gpio.h20
-rw-r--r--arch/arm/mach-exynos/include/mach/regs-pmu.h1
-rw-r--r--arch/arm/mach-exynos/include/mach/system.h20
-rw-r--r--arch/arm/mach-exynos/include/mach/uncompress.h17
-rw-r--r--arch/arm/mach-exynos/mach-exynos4-dt.c8
-rw-r--r--arch/arm/mach-exynos/mach-exynos5-dt.c78
-rw-r--r--arch/arm/mach-exynos/mach-nuri.c84
-rw-r--r--arch/arm/mach-exynos/mach-origen.c39
-rw-r--r--arch/arm/mach-exynos/mach-smdkv310.c3
-rw-r--r--arch/arm/mach-exynos/mach-universal_c210.c84
-rw-r--r--arch/arm/mach-exynos/mct.c62
-rw-r--r--arch/arm/mach-exynos/platsmp.c9
-rw-r--r--arch/arm/mach-exynos/pm.c55
-rw-r--r--arch/arm/mach-exynos/pm_domains.c6
-rw-r--r--arch/arm/mach-exynos/setup-i2c0.c9
-rw-r--r--arch/arm/mach-footbridge/dc21285.c8
-rw-r--r--arch/arm/mach-footbridge/include/mach/entry-macro.S6
-rw-r--r--arch/arm/mach-footbridge/include/mach/system.h13
-rw-r--r--arch/arm/mach-gemini/Makefile2
-rw-r--r--arch/arm/mach-gemini/idle.c29
-rw-r--r--arch/arm/mach-gemini/include/mach/entry-macro.S6
-rw-r--r--arch/arm/mach-gemini/include/mach/system.h14
-rw-r--r--arch/arm/mach-gemini/irq.c4
-rw-r--r--arch/arm/mach-h720x/common.c18
-rw-r--r--arch/arm/mach-h720x/include/mach/entry-macro.S6
-rw-r--r--arch/arm/mach-h720x/include/mach/system.h27
-rw-r--r--arch/arm/mach-highbank/Makefile1
-rw-r--r--arch/arm/mach-highbank/highbank.c5
-rw-r--r--arch/arm/mach-highbank/include/mach/entry-macro.S5
-rw-r--r--arch/arm/mach-highbank/include/mach/memory.h1
-rw-r--r--arch/arm/mach-highbank/localtimer.c40
-rw-r--r--arch/arm/mach-imx/Kconfig14
-rw-r--r--arch/arm/mach-imx/Makefile6
-rw-r--r--arch/arm/mach-imx/Makefile.boot3
-rw-r--r--arch/arm/mach-imx/clock-imx27.c20
-rw-r--r--arch/arm/mach-imx/clock-imx31.c2
-rw-r--r--arch/arm/mach-imx/clock-imx35.c166
-rw-r--r--arch/arm/mach-imx/clock-imx6q.c74
-rw-r--r--arch/arm/mach-imx/cpu-imx5.c36
-rw-r--r--arch/arm/mach-imx/cpu_op-mx51.c1
-rw-r--r--arch/arm/mach-imx/crmregs-imx3.h (renamed from arch/arm/mach-imx/crmregs-imx31.h)16
-rw-r--r--arch/arm/mach-imx/devices-imx27.h2
-rw-r--r--arch/arm/mach-imx/imx27-dt.c89
-rw-r--r--arch/arm/mach-imx/imx51-dt.c1
-rw-r--r--arch/arm/mach-imx/imx53-dt.c1
-rw-r--r--arch/arm/mach-imx/lluart.c2
-rw-r--r--arch/arm/mach-imx/localtimer.c35
-rw-r--r--arch/arm/mach-imx/mach-armadillo5x0.c2
-rw-r--r--arch/arm/mach-imx/mach-imx27_visstrim_m10.c139
-rw-r--r--arch/arm/mach-imx/mach-imx6q.c3
-rw-r--r--arch/arm/mach-imx/mach-mx21ads.c16
-rw-r--r--arch/arm/mach-imx/mach-mx27_3ds.c108
-rw-r--r--arch/arm/mach-imx/mach-mx31ads.c35
-rw-r--r--arch/arm/mach-imx/mach-mx31moboard.c6
-rw-r--r--arch/arm/mach-imx/mach-mx35_3ds.c216
-rw-r--r--arch/arm/mach-imx/mach-pcm038.c2
-rw-r--r--arch/arm/mach-imx/mm-imx3.c65
-rw-r--r--arch/arm/mach-imx/mm-imx5.c38
-rw-r--r--arch/arm/mach-imx/pm-imx27.c3
-rw-r--r--arch/arm/mach-imx/pm-imx3.c37
-rw-r--r--arch/arm/mach-imx/pm-imx5.c4
-rw-r--r--arch/arm/mach-integrator/core.c70
-rw-r--r--arch/arm/mach-integrator/impd1.c9
-rw-r--r--arch/arm/mach-integrator/include/mach/entry-macro.S6
-rw-r--r--arch/arm/mach-integrator/include/mach/system.h33
-rw-r--r--arch/arm/mach-integrator/integrator_cp.c49
-rw-r--r--arch/arm/mach-integrator/pci_v3.c7
-rw-r--r--arch/arm/mach-iop13xx/include/mach/entry-macro.S3
-rw-r--r--arch/arm/mach-iop13xx/include/mach/system.h13
-rw-r--r--arch/arm/mach-iop13xx/pci.c4
-rw-r--r--arch/arm/mach-iop32x/include/mach/entry-macro.S3
-rw-r--r--arch/arm/mach-iop32x/include/mach/system.h13
-rw-r--r--arch/arm/mach-iop33x/include/mach/entry-macro.S3
-rw-r--r--arch/arm/mach-iop33x/include/mach/system.h13
-rw-r--r--arch/arm/mach-ixp2000/include/mach/entry-macro.S6
-rw-r--r--arch/arm/mach-ixp2000/include/mach/system.h14
-rw-r--r--arch/arm/mach-ixp2000/ixdp2400.c4
-rw-r--r--arch/arm/mach-ixp2000/ixdp2800.c4
-rw-r--r--arch/arm/mach-ixp2000/ixdp2x00.c4
-rw-r--r--arch/arm/mach-ixp2000/pci.c6
-rw-r--r--arch/arm/mach-ixp23xx/core.c3
-rw-r--r--arch/arm/mach-ixp23xx/include/mach/entry-macro.S6
-rw-r--r--arch/arm/mach-ixp23xx/include/mach/system.h16
-rw-r--r--arch/arm/mach-ixp23xx/pci.c6
-rw-r--r--arch/arm/mach-ixp4xx/common-pci.c4
-rw-r--r--arch/arm/mach-ixp4xx/common.c6
-rw-r--r--arch/arm/mach-ixp4xx/include/mach/entry-macro.S6
-rw-r--r--arch/arm/mach-ixp4xx/include/mach/system.h19
-rw-r--r--arch/arm/mach-kirkwood/Kconfig14
-rw-r--r--arch/arm/mach-kirkwood/Makefile2
-rw-r--r--arch/arm/mach-kirkwood/Makefile.boot2
-rw-r--r--arch/arm/mach-kirkwood/board-dreamplug.c152
-rw-r--r--arch/arm/mach-kirkwood/board-dt.c75
-rw-r--r--arch/arm/mach-kirkwood/common.c11
-rw-r--r--arch/arm/mach-kirkwood/common.h15
-rw-r--r--arch/arm/mach-kirkwood/include/mach/entry-macro.S6
-rw-r--r--arch/arm/mach-kirkwood/include/mach/system.h17
-rw-r--r--arch/arm/mach-kirkwood/pcie.c4
-rw-r--r--arch/arm/mach-ks8695/include/mach/entry-macro.S6
-rw-r--r--arch/arm/mach-ks8695/include/mach/system.h27
-rw-r--r--arch/arm/mach-ks8695/pci.c4
-rw-r--r--arch/arm/mach-lpc32xx/Kconfig25
-rw-r--r--arch/arm/mach-lpc32xx/clock.c183
-rw-r--r--arch/arm/mach-lpc32xx/common.c69
-rw-r--r--arch/arm/mach-lpc32xx/common.h6
-rw-r--r--arch/arm/mach-lpc32xx/include/mach/board.h (renamed from arch/arm/mach-lpc32xx/include/mach/system.h)13
-rw-r--r--arch/arm/mach-lpc32xx/include/mach/entry-macro.S6
-rw-r--r--arch/arm/mach-lpc32xx/include/mach/platform.h51
-rw-r--r--arch/arm/mach-lpc32xx/irq.c4
-rw-r--r--arch/arm/mach-lpc32xx/phy3250.c38
-rw-r--r--arch/arm/mach-lpc32xx/pm.c2
-rw-r--r--arch/arm/mach-lpc32xx/timer.c48
-rw-r--r--arch/arm/mach-mmp/Kconfig10
-rw-r--r--arch/arm/mach-mmp/Makefile1
-rw-r--r--arch/arm/mach-mmp/include/mach/entry-macro.S6
-rw-r--r--arch/arm/mach-mmp/include/mach/pxa910.h1
-rw-r--r--arch/arm/mach-mmp/include/mach/regs-apbc.h1
-rw-r--r--arch/arm/mach-mmp/include/mach/regs-rtc.h23
-rw-r--r--arch/arm/mach-mmp/include/mach/system.h16
-rw-r--r--arch/arm/mach-mmp/mmp-dt.c75
-rw-r--r--arch/arm/mach-mmp/mmp2.c1
-rw-r--r--arch/arm/mach-mmp/pxa168.c3
-rw-r--r--arch/arm/mach-mmp/pxa910.c28
-rw-r--r--arch/arm/mach-mmp/ttc_dkb.c1
-rw-r--r--arch/arm/mach-msm/idle.S36
-rw-r--r--arch/arm/mach-msm/idle.c49
-rw-r--r--arch/arm/mach-msm/include/mach/entry-macro.S6
-rw-r--r--arch/arm/mach-msm/include/mach/system.h1
-rw-r--r--arch/arm/mach-msm/timer.c79
-rw-r--r--arch/arm/mach-mv78xx0/include/mach/entry-macro.S6
-rw-r--r--arch/arm/mach-mv78xx0/include/mach/system.h17
-rw-r--r--arch/arm/mach-mv78xx0/pcie.c4
-rw-r--r--arch/arm/mach-mxs/Kconfig16
-rw-r--r--arch/arm/mach-mxs/Makefile1
-rw-r--r--arch/arm/mach-mxs/clock-mx23.c35
-rw-r--r--arch/arm/mach-mxs/clock-mx28.c58
-rw-r--r--arch/arm/mach-mxs/devices-mx23.h4
-rw-r--r--arch/arm/mach-mxs/devices-mx28.h4
-rw-r--r--arch/arm/mach-mxs/devices.c8
-rw-r--r--arch/arm/mach-mxs/devices/Kconfig3
-rw-r--r--arch/arm/mach-mxs/devices/Makefile1
-rw-r--r--arch/arm/mach-mxs/devices/amba-duart.c2
-rw-r--r--arch/arm/mach-mxs/devices/platform-gpmi-nand.c81
-rw-r--r--arch/arm/mach-mxs/devices/platform-mxs-mmc.c2
-rw-r--r--arch/arm/mach-mxs/include/mach/common.h2
-rw-r--r--arch/arm/mach-mxs/include/mach/devices-common.h10
-rw-r--r--arch/arm/mach-mxs/include/mach/digctl.h1
-rw-r--r--arch/arm/mach-mxs/include/mach/entry-macro.S6
-rw-r--r--arch/arm/mach-mxs/include/mach/mxs.h29
-rw-r--r--arch/arm/mach-mxs/include/mach/system.h25
-rw-r--r--arch/arm/mach-mxs/include/mach/uncompress.h13
-rw-r--r--arch/arm/mach-mxs/mach-apx4devkit.c260
-rw-r--r--arch/arm/mach-mxs/mach-m28evk.c7
-rw-r--r--arch/arm/mach-mxs/mach-mx28evk.c80
-rw-r--r--arch/arm/mach-mxs/pm.c3
-rw-r--r--arch/arm/mach-mxs/system.c16
-rw-r--r--arch/arm/mach-netx/fb.c13
-rw-r--r--arch/arm/mach-netx/include/mach/entry-macro.S26
-rw-r--r--arch/arm/mach-netx/include/mach/system.h28
-rw-r--r--arch/arm/mach-nomadik/board-nhk8815.c24
-rw-r--r--arch/arm/mach-nomadik/cpu-8815.c9
-rw-r--r--arch/arm/mach-nomadik/include/mach/entry-macro.S13
-rw-r--r--arch/arm/mach-nomadik/include/mach/setup.h19
-rw-r--r--arch/arm/mach-nomadik/include/mach/system.h32
-rw-r--r--arch/arm/mach-omap1/Kconfig4
-rw-r--r--arch/arm/mach-omap1/ams-delta-fiq-handler.S3
-rw-r--r--arch/arm/mach-omap1/ams-delta-fiq.c1
-rw-r--r--arch/arm/mach-omap1/board-ams-delta.c322
-rw-r--r--arch/arm/mach-omap1/board-fsample.c7
-rw-r--r--arch/arm/mach-omap1/board-h2.c6
-rw-r--r--arch/arm/mach-omap1/board-h3.c8
-rw-r--r--arch/arm/mach-omap1/board-htcherald.c5
-rw-r--r--arch/arm/mach-omap1/board-innovator.c7
-rw-r--r--arch/arm/mach-omap1/board-nokia770.c6
-rw-r--r--arch/arm/mach-omap1/board-osk.c7
-rw-r--r--arch/arm/mach-omap1/board-palmte.c4
-rw-r--r--arch/arm/mach-omap1/board-palmtt.c9
-rw-r--r--arch/arm/mach-omap1/board-palmz71.c9
-rw-r--r--arch/arm/mach-omap1/board-perseus2.c7
-rw-r--r--arch/arm/mach-omap1/board-sx1.c6
-rw-r--r--arch/arm/mach-omap1/board-voiceblue.c6
-rw-r--r--arch/arm/mach-omap1/clock.c5
-rw-r--r--arch/arm/mach-omap1/clock_data.c5
-rw-r--r--arch/arm/mach-omap1/common.h1
-rw-r--r--arch/arm/mach-omap1/devices.c8
-rw-r--r--arch/arm/mach-omap1/dma.c2
-rw-r--r--arch/arm/mach-omap1/flash.c4
-rw-r--r--arch/arm/mach-omap1/fpga.c5
-rw-r--r--arch/arm/mach-omap1/gpio15xx.c7
-rw-r--r--arch/arm/mach-omap1/gpio16xx.c47
-rw-r--r--arch/arm/mach-omap1/gpio7xx.c14
-rw-r--r--arch/arm/mach-omap1/id.c3
-rw-r--r--arch/arm/mach-omap1/include/mach/entry-macro.S8
-rw-r--r--arch/arm/mach-omap1/include/mach/hardware.h36
-rw-r--r--arch/arm/mach-omap1/include/mach/io.h43
-rw-r--r--arch/arm/mach-omap1/include/mach/memory.h3
-rw-r--r--arch/arm/mach-omap1/include/mach/system.h5
-rw-r--r--arch/arm/mach-omap1/io.c5
-rw-r--r--arch/arm/mach-omap1/iomap.h42
-rw-r--r--arch/arm/mach-omap1/irq.c4
-rw-r--r--arch/arm/mach-omap1/lcd_dma.c3
-rw-r--r--arch/arm/mach-omap1/mcbsp.c5
-rw-r--r--arch/arm/mach-omap1/pm.c23
-rw-r--r--arch/arm/mach-omap1/reset.c3
-rw-r--r--arch/arm/mach-omap1/sleep.S4
-rw-r--r--arch/arm/mach-omap1/sram.S4
-rw-r--r--arch/arm/mach-omap1/time.c3
-rw-r--r--arch/arm/mach-omap1/timer32k.c7
-rw-r--r--arch/arm/mach-omap2/Kconfig8
-rw-r--r--arch/arm/mach-omap2/Makefile13
-rw-r--r--arch/arm/mach-omap2/am35xx-emac.c117
-rw-r--r--arch/arm/mach-omap2/am35xx-emac.h15
-rw-r--r--arch/arm/mach-omap2/board-2430sdp.c2
-rw-r--r--arch/arm/mach-omap2/board-3430sdp.c5
-rw-r--r--arch/arm/mach-omap2/board-4430sdp.c22
-rw-r--r--arch/arm/mach-omap2/board-am3517evm.c119
-rw-r--r--arch/arm/mach-omap2/board-cm-t35.c6
-rw-r--r--arch/arm/mach-omap2/board-cm-t3517.c2
-rw-r--r--arch/arm/mach-omap2/board-devkit8000.c4
-rw-r--r--arch/arm/mach-omap2/board-flash.c2
-rw-r--r--arch/arm/mach-omap2/board-generic.c111
-rw-r--r--arch/arm/mach-omap2/board-igep0020.c6
-rw-r--r--arch/arm/mach-omap2/board-ldp.c3
-rw-r--r--arch/arm/mach-omap2/board-n8x0.c9
-rw-r--r--arch/arm/mach-omap2/board-omap3beagle.c10
-rw-r--r--arch/arm/mach-omap2/board-omap3evm.c7
-rw-r--r--arch/arm/mach-omap2/board-omap3logic.c4
-rw-r--r--arch/arm/mach-omap2/board-omap3pandora.c26
-rw-r--r--arch/arm/mach-omap2/board-omap3stalker.c15
-rw-r--r--arch/arm/mach-omap2/board-omap3touchbook.c17
-rw-r--r--arch/arm/mach-omap2/board-omap4panda.c27
-rw-r--r--arch/arm/mach-omap2/board-overo.c3
-rw-r--r--arch/arm/mach-omap2/board-rm680.c16
-rw-r--r--arch/arm/mach-omap2/board-rx51-peripherals.c30
-rw-r--r--arch/arm/mach-omap2/board-zoom-display.c5
-rw-r--r--arch/arm/mach-omap2/board-zoom-peripherals.c4
-rw-r--r--arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c1
-rw-r--r--arch/arm/mach-omap2/clkt_clksel.c1
-rw-r--r--arch/arm/mach-omap2/clkt_dpll.c1
-rw-r--r--arch/arm/mach-omap2/clock2420_data.c3
-rw-r--r--arch/arm/mach-omap2/clock2430.c2
-rw-r--r--arch/arm/mach-omap2/clock2430_data.c2
-rw-r--r--arch/arm/mach-omap2/clock2xxx.c1
-rw-r--r--arch/arm/mach-omap2/clock3xxx.c1
-rw-r--r--arch/arm/mach-omap2/clock3xxx_data.c3
-rw-r--r--arch/arm/mach-omap2/clock44xx_data.c3
-rw-r--r--arch/arm/mach-omap2/cm2xxx_3xxx.c4
-rw-r--r--arch/arm/mach-omap2/cm44xx.c2
-rw-r--r--arch/arm/mach-omap2/cminst44xx.c2
-rw-r--r--arch/arm/mach-omap2/common-board-devices.c9
-rw-r--r--arch/arm/mach-omap2/common.c5
-rw-r--r--arch/arm/mach-omap2/common.h19
-rw-r--r--arch/arm/mach-omap2/control.c4
-rw-r--r--arch/arm/mach-omap2/control.h6
-rw-r--r--arch/arm/mach-omap2/devices.c17
-rw-r--r--arch/arm/mach-omap2/display.c9
-rw-r--r--arch/arm/mach-omap2/dma.c2
-rw-r--r--arch/arm/mach-omap2/emu.c30
-rw-r--r--arch/arm/mach-omap2/gpio.c38
-rw-r--r--arch/arm/mach-omap2/gpmc-nand.c1
-rw-r--r--arch/arm/mach-omap2/gpmc-onenand.c1
-rw-r--r--arch/arm/mach-omap2/gpmc-smsc911x.c11
-rw-r--r--arch/arm/mach-omap2/gpmc.c2
-rw-r--r--arch/arm/mach-omap2/hsmmc.c123
-rw-r--r--arch/arm/mach-omap2/hsmmc.h12
-rw-r--r--arch/arm/mach-omap2/id.c188
-rw-r--r--arch/arm/mach-omap2/include/mach/entry-macro.S18
-rw-r--r--arch/arm/mach-omap2/include/mach/io.h46
-rw-r--r--arch/arm/mach-omap2/include/mach/system.h5
-rw-r--r--arch/arm/mach-omap2/io.c68
-rw-r--r--arch/arm/mach-omap2/iomap.h (renamed from arch/arm/plat-omap/include/plat/io.h)80
-rw-r--r--arch/arm/mach-omap2/irq.c65
-rw-r--r--arch/arm/mach-omap2/mcbsp.c2
-rw-r--r--arch/arm/mach-omap2/mux.c16
-rw-r--r--arch/arm/mach-omap2/mux.h2
-rw-r--r--arch/arm/mach-omap2/omap-hotplug.c2
-rw-r--r--arch/arm/mach-omap2/omap-mpuss-lowpower.c4
-rw-r--r--arch/arm/mach-omap2/omap-smp.c3
-rw-r--r--arch/arm/mach-omap2/omap-wakeupgen.c53
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_3xxx_data.c31
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_44xx_data.c20
-rw-r--r--arch/arm/mach-omap2/opp2420_data.c2
-rw-r--r--arch/arm/mach-omap2/opp2430_data.c2
-rw-r--r--arch/arm/mach-omap2/pm-debug.c6
-rw-r--r--arch/arm/mach-omap2/pm.c125
-rw-r--r--arch/arm/mach-omap2/pm.h3
-rw-r--r--arch/arm/mach-omap2/pm24xx.c104
-rw-r--r--arch/arm/mach-omap2/pm34xx.c94
-rw-r--r--arch/arm/mach-omap2/pm44xx.c65
-rw-r--r--arch/arm/mach-omap2/powerdomain-common.c1
-rw-r--r--arch/arm/mach-omap2/powerdomain2xxx_3xxx.c1
-rw-r--r--arch/arm/mach-omap2/powerdomain44xx.c1
-rw-r--r--arch/arm/mach-omap2/powerdomains3xxx_data.c1
-rw-r--r--arch/arm/mach-omap2/prcm_mpu44xx.c2
-rw-r--r--arch/arm/mach-omap2/prm44xx.c3
-rw-r--r--arch/arm/mach-omap2/prm_common.c1
-rw-r--r--arch/arm/mach-omap2/prminst44xx.c2
-rw-r--r--arch/arm/mach-omap2/sdram-nokia.c1
-rw-r--r--arch/arm/mach-omap2/sdrc2xxx.c6
-rw-r--r--arch/arm/mach-omap2/serial.c4
-rw-r--r--arch/arm/mach-omap2/sleep24xx.S1
-rw-r--r--arch/arm/mach-omap2/sleep34xx.S5
-rw-r--r--arch/arm/mach-omap2/smartreflex-class3.c1
-rw-r--r--arch/arm/mach-omap2/smartreflex.c229
-rw-r--r--arch/arm/mach-omap2/smartreflex.h10
-rw-r--r--arch/arm/mach-omap2/sr_device.c13
-rw-r--r--arch/arm/mach-omap2/sram242x.S4
-rw-r--r--arch/arm/mach-omap2/sram243x.S4
-rw-r--r--arch/arm/mach-omap2/sram34xx.S5
-rw-r--r--arch/arm/mach-omap2/timer-mpu.c39
-rw-r--r--arch/arm/mach-omap2/timer.c22
-rw-r--r--arch/arm/mach-omap2/vc.c1
-rw-r--r--arch/arm/mach-omap2/vp.c4
-rw-r--r--arch/arm/mach-orion5x/include/mach/entry-macro.S6
-rw-r--r--arch/arm/mach-orion5x/include/mach/system.h19
-rw-r--r--arch/arm/mach-orion5x/pci.c14
-rw-r--r--arch/arm/mach-picoxcell/include/mach/entry-macro.S16
-rw-r--r--arch/arm/mach-picoxcell/include/mach/system.h26
-rw-r--r--arch/arm/mach-pnx4008/include/mach/entry-macro.S6
-rw-r--r--arch/arm/mach-pnx4008/include/mach/system.h29
-rw-r--r--arch/arm/mach-prima2/include/mach/entry-macro.S7
-rw-r--r--arch/arm/mach-prima2/include/mach/system.h17
-rw-r--r--arch/arm/mach-pxa/devices.c28
-rw-r--r--arch/arm/mach-pxa/hx4700.c77
-rw-r--r--arch/arm/mach-pxa/include/mach/balloon3.h1
-rw-r--r--arch/arm/mach-pxa/include/mach/entry-macro.S15
-rw-r--r--arch/arm/mach-pxa/include/mach/mfp-pxa27x.h2
-rw-r--r--arch/arm/mach-pxa/include/mach/system.h15
-rw-r--r--arch/arm/mach-pxa/lubbock.c1
-rw-r--r--arch/arm/mach-pxa/magician.c33
-rw-r--r--arch/arm/mach-pxa/pxa3xx.c1
-rw-r--r--arch/arm/mach-pxa/pxa95x.c1
-rw-r--r--arch/arm/mach-realview/core.h20
-rw-r--r--arch/arm/mach-realview/include/mach/entry-macro.S16
-rw-r--r--arch/arm/mach-realview/include/mach/irqs-eb.h23
-rw-r--r--arch/arm/mach-realview/include/mach/irqs-pb1176.h2
-rw-r--r--arch/arm/mach-realview/include/mach/system.h33
-rw-r--r--arch/arm/mach-realview/realview_eb.c105
-rw-r--r--arch/arm/mach-realview/realview_pb1176.c78
-rw-r--r--arch/arm/mach-realview/realview_pb11mp.c99
-rw-r--r--arch/arm/mach-realview/realview_pba8.c78
-rw-r--r--arch/arm/mach-realview/realview_pbx.c98
-rw-r--r--arch/arm/mach-rpc/Makefile2
-rw-r--r--arch/arm/mach-rpc/ecard.c (renamed from arch/arm/kernel/ecard.c)134
-rw-r--r--arch/arm/mach-rpc/ecard.h (renamed from arch/arm/kernel/ecard.h)0
-rw-r--r--arch/arm/mach-rpc/fiq.S16
-rw-r--r--arch/arm/mach-rpc/include/mach/entry-macro.S4
-rw-r--r--arch/arm/mach-rpc/include/mach/irqs.h2
-rw-r--r--arch/arm/mach-rpc/include/mach/system.h13
-rw-r--r--arch/arm/mach-rpc/irq.c6
-rw-r--r--arch/arm/mach-rpc/riscpc.c45
-rw-r--r--arch/arm/mach-rpc/time.c (renamed from arch/arm/common/time-acorn.c)2
-rw-r--r--arch/arm/mach-s3c2410/Kconfig154
-rw-r--r--arch/arm/mach-s3c2410/Makefile26
-rw-r--r--arch/arm/mach-s3c2410/common.h17
-rw-r--r--arch/arm/mach-s3c2410/include/mach/spi.h38
-rw-r--r--arch/arm/mach-s3c2410/include/mach/system.h54
-rw-r--r--arch/arm/mach-s3c2410/usb-simtec.h16
-rw-r--r--arch/arm/mach-s3c2412/Kconfig85
-rw-r--r--arch/arm/mach-s3c2412/Makefile12
-rw-r--r--arch/arm/mach-s3c2416/Kconfig60
-rw-r--r--arch/arm/mach-s3c2416/Makefile22
-rw-r--r--arch/arm/mach-s3c2440/Kconfig165
-rw-r--r--arch/arm/mach-s3c2440/Makefile26
-rw-r--r--arch/arm/mach-s3c2440/common.h17
-rw-r--r--arch/arm/mach-s3c2443/Kconfig32
-rw-r--r--arch/arm/mach-s3c2443/Makefile20
-rw-r--r--arch/arm/mach-s3c24xx/Kconfig538
-rw-r--r--arch/arm/mach-s3c24xx/Makefile95
-rw-r--r--arch/arm/mach-s3c24xx/Makefile.boot (renamed from arch/arm/mach-s3c2410/Makefile.boot)0
-rw-r--r--arch/arm/mach-s3c24xx/bast-ide.c (renamed from arch/arm/mach-s3c2410/bast-ide.c)0
-rw-r--r--arch/arm/mach-s3c24xx/bast-irq.c (renamed from arch/arm/mach-s3c2410/bast-irq.c)0
-rw-r--r--arch/arm/mach-s3c24xx/clock-s3c2412.c (renamed from arch/arm/mach-s3c2412/clock.c)0
-rw-r--r--arch/arm/mach-s3c24xx/clock-s3c2416.c (renamed from arch/arm/mach-s3c2416/clock.c)7
-rw-r--r--arch/arm/mach-s3c24xx/clock-s3c2440.c (renamed from arch/arm/mach-s3c2440/clock.c)0
-rw-r--r--arch/arm/mach-s3c24xx/clock-s3c2443.c (renamed from arch/arm/mach-s3c2443/clock.c)7
-rw-r--r--arch/arm/mach-s3c24xx/clock-s3c244x.c (renamed from arch/arm/mach-s3c2440/s3c244x-clock.c)0
-rw-r--r--arch/arm/mach-s3c24xx/common-s3c2443.c (renamed from arch/arm/plat-s3c24xx/s3c2443-clock.c)90
-rw-r--r--arch/arm/mach-s3c24xx/common-smdk.c (renamed from arch/arm/plat-s3c24xx/common-smdk.c)0
-rw-r--r--arch/arm/mach-s3c24xx/dma-s3c2410.c (renamed from arch/arm/mach-s3c2410/dma.c)0
-rw-r--r--arch/arm/mach-s3c24xx/dma-s3c2412.c (renamed from arch/arm/mach-s3c2412/dma.c)0
-rw-r--r--arch/arm/mach-s3c24xx/dma-s3c2440.c (renamed from arch/arm/mach-s3c2440/dma.c)0
-rw-r--r--arch/arm/mach-s3c24xx/dma-s3c2443.c (renamed from arch/arm/mach-s3c2443/dma.c)30
-rw-r--r--arch/arm/mach-s3c24xx/h1940-bluetooth.c (renamed from arch/arm/mach-s3c2410/h1940-bluetooth.c)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/anubis-cpld.h (renamed from arch/arm/mach-s3c2410/include/mach/anubis-cpld.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/anubis-irq.h (renamed from arch/arm/mach-s3c2410/include/mach/anubis-irq.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/anubis-map.h (renamed from arch/arm/mach-s3c2410/include/mach/anubis-map.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/bast-cpld.h (renamed from arch/arm/mach-s3c2410/include/mach/bast-cpld.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/bast-irq.h (renamed from arch/arm/mach-s3c2410/include/mach/bast-irq.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/bast-map.h (renamed from arch/arm/mach-s3c2410/include/mach/bast-map.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/bast-pmu.h (renamed from arch/arm/mach-s3c2410/include/mach/bast-pmu.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/debug-macro.S (renamed from arch/arm/mach-s3c2410/include/mach/debug-macro.S)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/dma.h (renamed from arch/arm/mach-s3c2410/include/mach/dma.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/entry-macro.S (renamed from arch/arm/mach-s3c2410/include/mach/entry-macro.S)8
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/fb.h (renamed from arch/arm/mach-s3c2410/include/mach/fb.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/gpio-fns.h (renamed from arch/arm/mach-s3c2410/include/mach/gpio-fns.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/gpio-nrs.h (renamed from arch/arm/mach-s3c2410/include/mach/gpio-nrs.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/gpio-track.h (renamed from arch/arm/mach-s3c2410/include/mach/gpio-track.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/gpio.h (renamed from arch/arm/mach-s3c2410/include/mach/gpio.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/gta02.h (renamed from arch/arm/mach-s3c2440/include/mach/gta02.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/h1940-latch.h (renamed from arch/arm/mach-s3c2410/include/mach/h1940-latch.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/h1940.h (renamed from arch/arm/mach-s3c2410/include/mach/h1940.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/hardware.h (renamed from arch/arm/mach-s3c2410/include/mach/hardware.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/idle.h (renamed from arch/arm/mach-s3c2410/include/mach/idle.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/io.h (renamed from arch/arm/mach-s3c2410/include/mach/io.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/irqs.h (renamed from arch/arm/mach-s3c2410/include/mach/irqs.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/leds-gpio.h (renamed from arch/arm/mach-s3c2410/include/mach/leds-gpio.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/map.h (renamed from arch/arm/mach-s3c2410/include/mach/map.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/osiris-cpld.h (renamed from arch/arm/mach-s3c2410/include/mach/osiris-cpld.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/osiris-map.h (renamed from arch/arm/mach-s3c2410/include/mach/osiris-map.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/otom-map.h (renamed from arch/arm/mach-s3c2410/include/mach/otom-map.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/pm-core.h (renamed from arch/arm/mach-s3c2410/include/mach/pm-core.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/regs-clock.h (renamed from arch/arm/mach-s3c2410/include/mach/regs-clock.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/regs-dsc.h (renamed from arch/arm/mach-s3c2410/include/mach/regs-dsc.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/regs-gpio.h (renamed from arch/arm/mach-s3c2410/include/mach/regs-gpio.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/regs-gpioj.h (renamed from arch/arm/mach-s3c2410/include/mach/regs-gpioj.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/regs-irq.h (renamed from arch/arm/mach-s3c2410/include/mach/regs-irq.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/regs-lcd.h (renamed from arch/arm/mach-s3c2410/include/mach/regs-lcd.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/regs-mem.h (renamed from arch/arm/mach-s3c2410/include/mach/regs-mem.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/regs-power.h (renamed from arch/arm/mach-s3c2410/include/mach/regs-power.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/regs-s3c2412-mem.h (renamed from arch/arm/mach-s3c2410/include/mach/regs-s3c2412-mem.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/regs-s3c2412.h (renamed from arch/arm/mach-s3c2410/include/mach/regs-s3c2412.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/regs-s3c2416-mem.h (renamed from arch/arm/mach-s3c2410/include/mach/regs-s3c2416-mem.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/regs-s3c2416.h (renamed from arch/arm/mach-s3c2410/include/mach/regs-s3c2416.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/regs-s3c2443-clock.h (renamed from arch/arm/mach-s3c2410/include/mach/regs-s3c2443-clock.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/regs-sdi.h (renamed from arch/arm/mach-s3c2410/include/mach/regs-sdi.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/tick.h (renamed from arch/arm/mach-s3c2410/include/mach/tick.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/timex.h (renamed from arch/arm/mach-s3c2410/include/mach/timex.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/uncompress.h (renamed from arch/arm/mach-s3c2410/include/mach/uncompress.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/vr1000-cpld.h (renamed from arch/arm/mach-s3c2410/include/mach/vr1000-cpld.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/vr1000-irq.h (renamed from arch/arm/mach-s3c2410/include/mach/vr1000-irq.h)0
-rw-r--r--arch/arm/mach-s3c24xx/include/mach/vr1000-map.h (renamed from arch/arm/mach-s3c2410/include/mach/vr1000-map.h)0
-rw-r--r--arch/arm/mach-s3c24xx/irq-s3c2412.c (renamed from arch/arm/mach-s3c2412/irq.c)0
-rw-r--r--arch/arm/mach-s3c24xx/irq-s3c2416.c (renamed from arch/arm/mach-s3c2416/irq.c)0
-rw-r--r--arch/arm/mach-s3c24xx/irq-s3c2440.c (renamed from arch/arm/mach-s3c2440/irq.c)0
-rw-r--r--arch/arm/mach-s3c24xx/irq-s3c2443.c (renamed from arch/arm/mach-s3c2443/irq.c)0
-rw-r--r--arch/arm/mach-s3c24xx/irq-s3c244x.c (renamed from arch/arm/mach-s3c2440/s3c244x-irq.c)0
-rw-r--r--arch/arm/mach-s3c24xx/mach-amlm5900.c (renamed from arch/arm/mach-s3c2410/mach-amlm5900.c)0
-rw-r--r--arch/arm/mach-s3c24xx/mach-anubis.c (renamed from arch/arm/mach-s3c2440/mach-anubis.c)1
-rw-r--r--arch/arm/mach-s3c24xx/mach-at2440evb.c (renamed from arch/arm/mach-s3c2440/mach-at2440evb.c)0
-rw-r--r--arch/arm/mach-s3c24xx/mach-bast.c (renamed from arch/arm/mach-s3c2410/mach-bast.c)3
-rw-r--r--arch/arm/mach-s3c24xx/mach-gta02.c (renamed from arch/arm/mach-s3c2440/mach-gta02.c)6
-rw-r--r--arch/arm/mach-s3c24xx/mach-h1940.c (renamed from arch/arm/mach-s3c2410/mach-h1940.c)12
-rw-r--r--arch/arm/mach-s3c24xx/mach-jive.c (renamed from arch/arm/mach-s3c2412/mach-jive.c)0
-rw-r--r--arch/arm/mach-s3c24xx/mach-mini2440.c (renamed from arch/arm/mach-s3c2440/mach-mini2440.c)0
-rw-r--r--arch/arm/mach-s3c24xx/mach-n30.c (renamed from arch/arm/mach-s3c2410/mach-n30.c)0
-rw-r--r--arch/arm/mach-s3c24xx/mach-nexcoder.c (renamed from arch/arm/mach-s3c2440/mach-nexcoder.c)0
-rw-r--r--arch/arm/mach-s3c24xx/mach-osiris-dvs.c (renamed from arch/arm/mach-s3c2440/mach-osiris-dvs.c)0
-rw-r--r--arch/arm/mach-s3c24xx/mach-osiris.c (renamed from arch/arm/mach-s3c2440/mach-osiris.c)0
-rw-r--r--arch/arm/mach-s3c24xx/mach-otom.c (renamed from arch/arm/mach-s3c2410/mach-otom.c)0
-rw-r--r--arch/arm/mach-s3c24xx/mach-qt2410.c (renamed from arch/arm/mach-s3c2410/mach-qt2410.c)0
-rw-r--r--arch/arm/mach-s3c24xx/mach-rx1950.c (renamed from arch/arm/mach-s3c2440/mach-rx1950.c)12
-rw-r--r--arch/arm/mach-s3c24xx/mach-rx3715.c (renamed from arch/arm/mach-s3c2440/mach-rx3715.c)0
-rw-r--r--arch/arm/mach-s3c24xx/mach-smdk2410.c (renamed from arch/arm/mach-s3c2410/mach-smdk2410.c)0
-rw-r--r--arch/arm/mach-s3c24xx/mach-smdk2413.c (renamed from arch/arm/mach-s3c2412/mach-smdk2413.c)0
-rw-r--r--arch/arm/mach-s3c24xx/mach-smdk2416.c (renamed from arch/arm/mach-s3c2416/mach-smdk2416.c)8
-rw-r--r--arch/arm/mach-s3c24xx/mach-smdk2440.c (renamed from arch/arm/mach-s3c2440/mach-smdk2440.c)0
-rw-r--r--arch/arm/mach-s3c24xx/mach-smdk2443.c (renamed from arch/arm/mach-s3c2443/mach-smdk2443.c)0
-rw-r--r--arch/arm/mach-s3c24xx/mach-tct_hammer.c (renamed from arch/arm/mach-s3c2410/mach-tct_hammer.c)0
-rw-r--r--arch/arm/mach-s3c24xx/mach-vr1000.c (renamed from arch/arm/mach-s3c2410/mach-vr1000.c)3
-rw-r--r--arch/arm/mach-s3c24xx/mach-vstms.c (renamed from arch/arm/mach-s3c2412/mach-vstms.c)0
-rw-r--r--arch/arm/mach-s3c24xx/pm-h1940.S (renamed from arch/arm/mach-s3c2410/pm-h1940.S)0
-rw-r--r--arch/arm/mach-s3c24xx/pm-s3c2410.c (renamed from arch/arm/mach-s3c2410/pm.c)0
-rw-r--r--arch/arm/mach-s3c24xx/pm-s3c2412.c (renamed from arch/arm/mach-s3c2412/pm.c)0
-rw-r--r--arch/arm/mach-s3c24xx/pm-s3c2416.c (renamed from arch/arm/mach-s3c2416/pm.c)0
-rw-r--r--arch/arm/mach-s3c24xx/s3c2410.c (renamed from arch/arm/mach-s3c2410/s3c2410.c)0
-rw-r--r--arch/arm/mach-s3c24xx/s3c2412.c (renamed from arch/arm/mach-s3c2412/s3c2412.c)4
-rw-r--r--arch/arm/mach-s3c24xx/s3c2416.c (renamed from arch/arm/mach-s3c2416/s3c2416.c)5
-rw-r--r--arch/arm/mach-s3c24xx/s3c2440.c (renamed from arch/arm/mach-s3c2440/s3c2440.c)0
-rw-r--r--arch/arm/mach-s3c24xx/s3c2442.c (renamed from arch/arm/mach-s3c2440/s3c2442.c)0
-rw-r--r--arch/arm/mach-s3c24xx/s3c2443.c (renamed from arch/arm/mach-s3c2443/s3c2443.c)2
-rw-r--r--arch/arm/mach-s3c24xx/s3c244x.c (renamed from arch/arm/mach-s3c2440/s3c244x.c)0
-rw-r--r--arch/arm/mach-s3c24xx/setup-i2c.c (renamed from arch/arm/plat-s3c24xx/setup-i2c.c)0
-rw-r--r--arch/arm/mach-s3c24xx/setup-sdhci-gpio.c (renamed from arch/arm/mach-s3c2416/setup-sdhci-gpio.c)0
-rw-r--r--arch/arm/mach-s3c24xx/setup-ts.c (renamed from arch/arm/plat-s3c24xx/setup-ts.c)0
-rw-r--r--arch/arm/mach-s3c24xx/simtec-audio.c (renamed from arch/arm/plat-s3c24xx/simtec-audio.c)2
-rw-r--r--arch/arm/mach-s3c24xx/simtec-nor.c (renamed from arch/arm/mach-s3c2410/nor-simtec.c)2
-rw-r--r--arch/arm/mach-s3c24xx/simtec-pm.c (renamed from arch/arm/plat-s3c24xx/pm-simtec.c)0
-rw-r--r--arch/arm/mach-s3c24xx/simtec-usb.c (renamed from arch/arm/mach-s3c2410/usb-simtec.c)2
-rw-r--r--arch/arm/mach-s3c24xx/simtec.h (renamed from arch/arm/mach-s3c2410/nor-simtec.h)9
-rw-r--r--arch/arm/mach-s3c24xx/sleep-s3c2410.S (renamed from arch/arm/mach-s3c2410/sleep.S)0
-rw-r--r--arch/arm/mach-s3c24xx/sleep-s3c2412.S (renamed from arch/arm/mach-s3c2412/sleep.S)0
-rw-r--r--arch/arm/mach-s3c64xx/Kconfig9
-rw-r--r--arch/arm/mach-s3c64xx/Makefile2
-rw-r--r--arch/arm/mach-s3c64xx/clock.c121
-rw-r--r--arch/arm/mach-s3c64xx/common.h2
-rw-r--r--arch/arm/mach-s3c64xx/cpuidle.c91
-rw-r--r--arch/arm/mach-s3c64xx/include/mach/entry-macro.S19
-rw-r--r--arch/arm/mach-s3c64xx/include/mach/system.h19
-rw-r--r--arch/arm/mach-s3c64xx/irq-pm.c2
-rw-r--r--arch/arm/mach-s3c64xx/mach-crag6410-module.c45
-rw-r--r--arch/arm/mach-s3c64xx/mach-crag6410.c71
-rw-r--r--arch/arm/mach-s3c64xx/mach-smartq.c3
-rw-r--r--arch/arm/mach-s3c64xx/mach-smdk6410.c4
-rw-r--r--arch/arm/mach-s3c64xx/setup-usb-phy.c90
-rw-r--r--arch/arm/mach-s5p64x0/clock.c11
-rw-r--r--arch/arm/mach-s5p64x0/common.c15
-rw-r--r--arch/arm/mach-s5p64x0/dma.c30
-rw-r--r--arch/arm/mach-s5p64x0/include/mach/entry-macro.S17
-rw-r--r--arch/arm/mach-s5p64x0/include/mach/s5p64x0-clock.h7
-rw-r--r--arch/arm/mach-s5p64x0/include/mach/system.h21
-rw-r--r--arch/arm/mach-s5pc100/clock.c28
-rw-r--r--arch/arm/mach-s5pc100/common.c12
-rw-r--r--arch/arm/mach-s5pc100/dma.c46
-rw-r--r--arch/arm/mach-s5pc100/include/mach/entry-macro.S6
-rw-r--r--arch/arm/mach-s5pc100/include/mach/system.h19
-rw-r--r--arch/arm/mach-s5pv210/Kconfig15
-rw-r--r--arch/arm/mach-s5pv210/Makefile1
-rw-r--r--arch/arm/mach-s5pv210/clock.c5
-rw-r--r--arch/arm/mach-s5pv210/common.c12
-rw-r--r--arch/arm/mach-s5pv210/dma.c46
-rw-r--r--arch/arm/mach-s5pv210/include/mach/entry-macro.S17
-rw-r--r--arch/arm/mach-s5pv210/include/mach/map.h4
-rw-r--r--arch/arm/mach-s5pv210/include/mach/regs-sys.h4
-rw-r--r--arch/arm/mach-s5pv210/include/mach/system.h21
-rw-r--r--arch/arm/mach-s5pv210/mach-aquila.c1
-rw-r--r--arch/arm/mach-s5pv210/mach-goni.c2
-rw-r--r--arch/arm/mach-s5pv210/mach-smdkc110.c14
-rw-r--r--arch/arm/mach-s5pv210/mach-smdkv210.c17
-rw-r--r--arch/arm/mach-s5pv210/setup-usb-phy.c90
-rw-r--r--arch/arm/mach-sa1100/Makefile2
-rw-r--r--arch/arm/mach-sa1100/assabet.c194
-rw-r--r--arch/arm/mach-sa1100/badge4.c42
-rw-r--r--arch/arm/mach-sa1100/cerf.c17
-rw-r--r--arch/arm/mach-sa1100/clock.c82
-rw-r--r--arch/arm/mach-sa1100/collie.c55
-rw-r--r--arch/arm/mach-sa1100/dma.c347
-rw-r--r--arch/arm/mach-sa1100/generic.c159
-rw-r--r--arch/arm/mach-sa1100/generic.h7
-rw-r--r--arch/arm/mach-sa1100/h3100.c25
-rw-r--r--arch/arm/mach-sa1100/h3600.c34
-rw-r--r--arch/arm/mach-sa1100/h3xxx.c13
-rw-r--r--arch/arm/mach-sa1100/hackkit.c13
-rw-r--r--arch/arm/mach-sa1100/include/mach/SA-1100.h229
-rw-r--r--arch/arm/mach-sa1100/include/mach/assabet.h15
-rw-r--r--arch/arm/mach-sa1100/include/mach/cerf.h15
-rw-r--r--arch/arm/mach-sa1100/include/mach/dma.h117
-rw-r--r--arch/arm/mach-sa1100/include/mach/entry-macro.S6
-rw-r--r--arch/arm/mach-sa1100/include/mach/irqs.h27
-rw-r--r--arch/arm/mach-sa1100/include/mach/mcp.h2
-rw-r--r--arch/arm/mach-sa1100/include/mach/nanoengine.h12
-rw-r--r--arch/arm/mach-sa1100/include/mach/neponset.h52
-rw-r--r--arch/arm/mach-sa1100/include/mach/shannon.h14
-rw-r--r--arch/arm/mach-sa1100/include/mach/simpad.h6
-rw-r--r--arch/arm/mach-sa1100/include/mach/system.h9
-rw-r--r--arch/arm/mach-sa1100/irq.c8
-rw-r--r--arch/arm/mach-sa1100/jornada720.c46
-rw-r--r--arch/arm/mach-sa1100/lart.c82
-rw-r--r--arch/arm/mach-sa1100/nanoengine.c13
-rw-r--r--arch/arm/mach-sa1100/neponset.c549
-rw-r--r--arch/arm/mach-sa1100/pci-nanoengine.c16
-rw-r--r--arch/arm/mach-sa1100/pleb.c25
-rw-r--r--arch/arm/mach-sa1100/shannon.c27
-rw-r--r--arch/arm/mach-sa1100/simpad.c24
-rw-r--r--arch/arm/mach-sa1100/sleep.S37
-rw-r--r--arch/arm/mach-sa1100/ssp.c2
-rw-r--r--arch/arm/mach-sa1100/time.c1
-rw-r--r--arch/arm/mach-shark/core.c6
-rw-r--r--arch/arm/mach-shark/include/mach/entry-macro.S6
-rw-r--r--arch/arm/mach-shark/include/mach/system.h13
-rw-r--r--arch/arm/mach-shmobile/Makefile1
-rw-r--r--arch/arm/mach-shmobile/board-ag5evm.c39
-rw-r--r--arch/arm/mach-shmobile/board-ap4evb.c43
-rw-r--r--arch/arm/mach-shmobile/board-bonito.c44
-rw-r--r--arch/arm/mach-shmobile/board-g3evm.c38
-rw-r--r--arch/arm/mach-shmobile/board-g4evm.c38
-rw-r--r--arch/arm/mach-shmobile/board-kota2.c38
-rw-r--r--arch/arm/mach-shmobile/board-mackerel.c48
-rw-r--r--arch/arm/mach-shmobile/board-marzen.c62
-rw-r--r--arch/arm/mach-shmobile/clock-r8a7740.c8
-rw-r--r--arch/arm/mach-shmobile/clock-r8a7779.c4
-rw-r--r--arch/arm/mach-shmobile/clock-sh7367.c8
-rw-r--r--arch/arm/mach-shmobile/clock-sh7372.c10
-rw-r--r--arch/arm/mach-shmobile/clock-sh7377.c8
-rw-r--r--arch/arm/mach-shmobile/clock-sh73a0.c14
-rw-r--r--arch/arm/mach-shmobile/clock.c2
-rw-r--r--arch/arm/mach-shmobile/include/mach/common.h11
-rw-r--r--arch/arm/mach-shmobile/include/mach/entry-macro.S22
-rw-r--r--arch/arm/mach-shmobile/include/mach/system.h5
-rw-r--r--arch/arm/mach-shmobile/localtimer.c26
-rw-r--r--arch/arm/mach-shmobile/platsmp.c1
-rw-r--r--arch/arm/mach-shmobile/setup-r8a7740.c45
-rw-r--r--arch/arm/mach-shmobile/setup-r8a7779.c54
-rw-r--r--arch/arm/mach-shmobile/setup-sh7367.c32
-rw-r--r--arch/arm/mach-shmobile/setup-sh7372.c39
-rw-r--r--arch/arm/mach-shmobile/setup-sh7377.c32
-rw-r--r--arch/arm/mach-shmobile/setup-sh73a0.c32
-rw-r--r--arch/arm/mach-shmobile/smp-r8a7779.c8
-rw-r--r--arch/arm/mach-shmobile/smp-sh73a0.c8
-rw-r--r--arch/arm/mach-shmobile/timer.c16
-rw-r--r--arch/arm/mach-spear3xx/include/mach/entry-macro.S18
-rw-r--r--arch/arm/mach-spear3xx/include/mach/system.h19
-rw-r--r--arch/arm/mach-spear3xx/spear300.c14
-rw-r--r--arch/arm/mach-spear3xx/spear3xx.c27
-rw-r--r--arch/arm/mach-spear6xx/Kconfig7
-rw-r--r--arch/arm/mach-spear6xx/Makefile6
-rw-r--r--arch/arm/mach-spear6xx/clock.c14
-rw-r--r--arch/arm/mach-spear6xx/include/mach/entry-macro.S18
-rw-r--r--arch/arm/mach-spear6xx/include/mach/system.h19
-rw-r--r--arch/arm/mach-spear6xx/spear600.c25
-rw-r--r--arch/arm/mach-spear6xx/spear600_evb.c54
-rw-r--r--arch/arm/mach-spear6xx/spear6xx.c132
-rw-r--r--arch/arm/mach-tegra/Kconfig18
-rw-r--r--arch/arm/mach-tegra/Makefile10
-rw-r--r--arch/arm/mach-tegra/apbio.c145
-rw-r--r--arch/arm/mach-tegra/apbio.h (renamed from arch/arm/mach-tegra/include/mach/system.h)29
-rw-r--r--arch/arm/mach-tegra/board-dt-tegra20.c6
-rw-r--r--arch/arm/mach-tegra/board-dt-tegra30.c26
-rw-r--r--arch/arm/mach-tegra/board-harmony-pinmux.c6
-rw-r--r--arch/arm/mach-tegra/board-harmony-power.c18
-rw-r--r--arch/arm/mach-tegra/board-harmony.c2
-rw-r--r--arch/arm/mach-tegra/board-seaboard.c5
-rw-r--r--arch/arm/mach-tegra/clock.c22
-rw-r--r--arch/arm/mach-tegra/clock.h15
-rw-r--r--arch/arm/mach-tegra/common.c26
-rw-r--r--arch/arm/mach-tegra/cpuidle.c107
-rw-r--r--arch/arm/mach-tegra/dma.c128
-rw-r--r--arch/arm/mach-tegra/flowctrl.c62
-rw-r--r--arch/arm/mach-tegra/flowctrl.h42
-rw-r--r--arch/arm/mach-tegra/fuse.c113
-rw-r--r--arch/arm/mach-tegra/fuse.h38
-rw-r--r--arch/arm/mach-tegra/headsmp.S167
-rw-r--r--arch/arm/mach-tegra/include/mach/clk.h10
-rw-r--r--arch/arm/mach-tegra/include/mach/debug-macro.S88
-rw-r--r--arch/arm/mach-tegra/include/mach/entry-macro.S20
-rw-r--r--arch/arm/mach-tegra/include/mach/gpio-tegra.h2
-rw-r--r--arch/arm/mach-tegra/include/mach/iomap.h6
-rw-r--r--arch/arm/mach-tegra/include/mach/irammap.h35
-rw-r--r--arch/arm/mach-tegra/include/mach/irqs.h7
-rw-r--r--arch/arm/mach-tegra/include/mach/powergate.h15
-rw-r--r--arch/arm/mach-tegra/include/mach/smmu.h63
-rw-r--r--arch/arm/mach-tegra/include/mach/uncompress.h120
-rw-r--r--arch/arm/mach-tegra/irq.c20
-rw-r--r--arch/arm/mach-tegra/localtimer.c26
-rw-r--r--arch/arm/mach-tegra/pcie.c22
-rw-r--r--arch/arm/mach-tegra/platsmp.c137
-rw-r--r--arch/arm/mach-tegra/pmc.c76
-rw-r--r--arch/arm/mach-tegra/pmc.h (renamed from arch/arm/mach-highbank/include/mach/system.h)17
-rw-r--r--arch/arm/mach-tegra/powergate.c53
-rw-r--r--arch/arm/mach-tegra/reset.c84
-rw-r--r--arch/arm/mach-tegra/reset.h50
-rw-r--r--arch/arm/mach-tegra/sleep.S91
-rw-r--r--arch/arm/mach-tegra/tegra2_clocks.c32
-rw-r--r--arch/arm/mach-tegra/tegra2_emc.c224
-rw-r--r--arch/arm/mach-tegra/tegra2_emc.h11
-rw-r--r--arch/arm/mach-tegra/tegra30_clocks.c3099
-rw-r--r--arch/arm/mach-tegra/timer.c22
-rw-r--r--arch/arm/mach-tegra/usb_phy.c11
-rw-r--r--arch/arm/mach-u300/Makefile1
-rw-r--r--arch/arm/mach-u300/core.c113
-rw-r--r--arch/arm/mach-u300/include/mach/entry-macro.S16
-rw-r--r--arch/arm/mach-u300/include/mach/system.h14
-rw-r--r--arch/arm/mach-u300/mmc.c52
-rw-r--r--arch/arm/mach-u300/mmc.h18
-rw-r--r--arch/arm/mach-ux500/Kconfig51
-rw-r--r--arch/arm/mach-ux500/Makefile3
-rw-r--r--arch/arm/mach-ux500/Makefile.boot1
-rw-r--r--arch/arm/mach-ux500/board-mop500-pins.c1
-rw-r--r--arch/arm/mach-ux500/board-mop500-regulators.c28
-rw-r--r--arch/arm/mach-ux500/board-mop500-sdi.c52
-rw-r--r--arch/arm/mach-ux500/board-mop500-u8500uib.c1
-rw-r--r--arch/arm/mach-ux500/board-mop500.c173
-rw-r--r--arch/arm/mach-ux500/board-mop500.h10
-rw-r--r--arch/arm/mach-ux500/board-u5500-sdi.c4
-rw-r--r--arch/arm/mach-ux500/board-u5500.c27
-rw-r--r--arch/arm/mach-ux500/cache-l2x0.c7
-rw-r--r--arch/arm/mach-ux500/clock.c7
-rw-r--r--arch/arm/mach-ux500/clock.h1
-rw-r--r--arch/arm/mach-ux500/cpu-db5500.c36
-rw-r--r--arch/arm/mach-ux500/cpu-db8500.c44
-rw-r--r--arch/arm/mach-ux500/cpu.c90
-rw-r--r--arch/arm/mach-ux500/devices-common.c92
-rw-r--r--arch/arm/mach-ux500/devices-common.h83
-rw-r--r--arch/arm/mach-ux500/devices-db5500.h116
-rw-r--r--arch/arm/mach-ux500/devices-db8500.c6
-rw-r--r--arch/arm/mach-ux500/devices-db8500.h176
-rw-r--r--arch/arm/mach-ux500/dma-db5500.c3
-rw-r--r--arch/arm/mach-ux500/include/mach/db8500-regs.h3
-rw-r--r--arch/arm/mach-ux500/include/mach/entry-macro.S18
-rw-r--r--arch/arm/mach-ux500/include/mach/hardware.h2
-rw-r--r--arch/arm/mach-ux500/include/mach/irqs-board-mop500.h2
-rw-r--r--arch/arm/mach-ux500/include/mach/irqs.h2
-rw-r--r--arch/arm/mach-ux500/include/mach/setup.h11
-rw-r--r--arch/arm/mach-ux500/include/mach/system.h20
-rw-r--r--arch/arm/mach-ux500/include/mach/usb.h4
-rw-r--r--arch/arm/mach-ux500/localtimer.c29
-rw-r--r--arch/arm/mach-ux500/timer.c44
-rw-r--r--arch/arm/mach-ux500/usb.c7
-rw-r--r--arch/arm/mach-versatile/core.c70
-rw-r--r--arch/arm/mach-versatile/core.h20
-rw-r--r--arch/arm/mach-versatile/include/mach/entry-macro.S15
-rw-r--r--arch/arm/mach-versatile/include/mach/system.h33
-rw-r--r--arch/arm/mach-versatile/pci.c6
-rw-r--r--arch/arm/mach-versatile/versatile_pb.c18
-rw-r--r--arch/arm/mach-vexpress/Kconfig47
-rw-r--r--arch/arm/mach-vexpress/Makefile.boot6
-rw-r--r--arch/arm/mach-vexpress/core.h24
-rw-r--r--arch/arm/mach-vexpress/ct-ca9x4.c75
-rw-r--r--arch/arm/mach-vexpress/include/mach/ct-ca9x4.h5
-rw-r--r--arch/arm/mach-vexpress/include/mach/debug-macro.S30
-rw-r--r--arch/arm/mach-vexpress/include/mach/entry-macro.S5
-rw-r--r--arch/arm/mach-vexpress/include/mach/irqs.h2
-rw-r--r--arch/arm/mach-vexpress/include/mach/motherboard.h58
-rw-r--r--arch/arm/mach-vexpress/include/mach/system.h33
-rw-r--r--arch/arm/mach-vexpress/include/mach/uncompress.h22
-rw-r--r--arch/arm/mach-vexpress/platsmp.c160
-rw-r--r--arch/arm/mach-vexpress/v2m.c301
-rw-r--r--arch/arm/mach-vt8500/include/mach/entry-macro.S6
-rw-r--r--arch/arm/mach-vt8500/include/mach/system.h5
-rw-r--r--arch/arm/mach-w90x900/dev.c1
-rw-r--r--arch/arm/mach-w90x900/include/mach/entry-macro.S8
-rw-r--r--arch/arm/mach-w90x900/include/mach/system.h19
-rw-r--r--arch/arm/mach-zynq/include/mach/entry-macro.S27
-rw-r--r--arch/arm/mach-zynq/include/mach/system.h23
-rw-r--r--arch/arm/mm/iomap.c3
-rw-r--r--arch/arm/plat-iop/pci.c4
-rw-r--r--arch/arm/plat-mxc/avic.c2
-rw-r--r--arch/arm/plat-mxc/cpu.c24
-rw-r--r--arch/arm/plat-mxc/devices/platform-ahci-imx.c16
-rw-r--r--arch/arm/plat-mxc/devices/platform-mx2-camera.c18
-rw-r--r--arch/arm/plat-mxc/epit.c2
-rw-r--r--arch/arm/plat-mxc/include/mach/board-mx31ads.h33
-rw-r--r--arch/arm/plat-mxc/include/mach/common.h10
-rw-r--r--arch/arm/plat-mxc/include/mach/debug-macro.S2
-rw-r--r--arch/arm/plat-mxc/include/mach/devices-common.h2
-rw-r--r--arch/arm/plat-mxc/include/mach/dma.h3
-rw-r--r--arch/arm/plat-mxc/include/mach/entry-macro.S16
-rw-r--r--arch/arm/plat-mxc/include/mach/iomux-mx25.h42
-rw-r--r--arch/arm/plat-mxc/include/mach/system.h25
-rw-r--r--arch/arm/plat-mxc/pwm.c4
-rw-r--r--arch/arm/plat-mxc/system.c2
-rw-r--r--arch/arm/plat-mxc/time.c2
-rw-r--r--arch/arm/plat-nomadik/include/plat/mtu.h4
-rw-r--r--arch/arm/plat-nomadik/timer.c33
-rw-r--r--arch/arm/plat-omap/Kconfig3
-rw-r--r--arch/arm/plat-omap/clock.c1
-rw-r--r--arch/arm/plat-omap/counter_32k.c1
-rw-r--r--arch/arm/plat-omap/dma.c4
-rw-r--r--arch/arm/plat-omap/dmtimer.c21
-rw-r--r--arch/arm/plat-omap/include/plat/board-ams-delta.h49
-rw-r--r--arch/arm/plat-omap/include/plat/cpu.h9
-rw-r--r--arch/arm/plat-omap/include/plat/gpio.h51
-rw-r--r--arch/arm/plat-omap/include/plat/hardware.h6
-rw-r--r--arch/arm/plat-omap/include/plat/keypad.h2
-rw-r--r--arch/arm/plat-omap/include/plat/mcspi.h3
-rw-r--r--arch/arm/plat-omap/include/plat/omap_device.h9
-rw-r--r--arch/arm/plat-omap/include/plat/omap_hwmod.h2
-rw-r--r--arch/arm/plat-omap/include/plat/remoteproc.h57
-rw-r--r--arch/arm/plat-omap/include/plat/serial.h1
-rw-r--r--arch/arm/plat-omap/include/plat/sram.h1
-rw-r--r--arch/arm/plat-omap/include/plat/system.h15
-rw-r--r--arch/arm/plat-omap/include/plat/tc.h17
-rw-r--r--arch/arm/plat-omap/include/plat/uncompress.h1
-rw-r--r--arch/arm/plat-omap/include/plat/usb.h41
-rw-r--r--arch/arm/plat-omap/mailbox.c2
-rw-r--r--arch/arm/plat-omap/mux.c4
-rw-r--r--arch/arm/plat-omap/omap-pm-noop.c2
-rw-r--r--arch/arm/plat-omap/omap_device.c46
-rw-r--r--arch/arm/plat-omap/sram.c23
-rw-r--r--arch/arm/plat-omap/usb.c4
-rw-r--r--arch/arm/plat-orion/common.c7
-rw-r--r--arch/arm/plat-orion/include/plat/audio.h1
-rw-r--r--arch/arm/plat-s3c24xx/Kconfig57
-rw-r--r--arch/arm/plat-s3c24xx/Makefile19
-rw-r--r--arch/arm/plat-s3c24xx/cpu.c27
-rw-r--r--arch/arm/plat-s3c24xx/spi-bus0-gpe11_12_13.c36
-rw-r--r--arch/arm/plat-s3c24xx/spi-bus1-gpd8_9_10.c38
-rw-r--r--arch/arm/plat-s3c24xx/spi-bus1-gpg5_6_7.c36
-rw-r--r--arch/arm/plat-s5p/Kconfig18
-rw-r--r--arch/arm/plat-s5p/Makefile3
-rw-r--r--arch/arm/plat-s5p/clock.c36
-rw-r--r--arch/arm/plat-s5p/irq-eint.c2
-rw-r--r--arch/arm/plat-s5p/irq-gpioint.c2
-rw-r--r--arch/arm/plat-s5p/irq-pm.c25
-rw-r--r--arch/arm/plat-s5p/sleep.S44
-rw-r--r--arch/arm/plat-samsung/Kconfig4
-rw-r--r--arch/arm/plat-samsung/clock.c12
-rw-r--r--arch/arm/plat-samsung/dev-backlight.c4
-rw-r--r--arch/arm/plat-samsung/devs.c81
-rw-r--r--arch/arm/plat-samsung/dma-ops.c2
-rw-r--r--arch/arm/plat-samsung/include/plat/audio-simtec.h3
-rw-r--r--arch/arm/plat-samsung/include/plat/clock.h22
-rw-r--r--arch/arm/plat-samsung/include/plat/cpu.h10
-rw-r--r--arch/arm/plat-samsung/include/plat/devs.h4
-rw-r--r--arch/arm/plat-samsung/include/plat/dma-pl330.h16
-rw-r--r--arch/arm/plat-samsung/include/plat/regs-dma.h2
-rw-r--r--arch/arm/plat-samsung/include/plat/regs-rtc.h81
-rw-r--r--arch/arm/plat-samsung/include/plat/regs-usb-hsotg-phy.h7
-rw-r--r--arch/arm/plat-samsung/include/plat/rtc-core.h27
-rw-r--r--arch/arm/plat-samsung/include/plat/s3c2410.h2
-rw-r--r--arch/arm/plat-samsung/include/plat/s3c2443.h20
-rw-r--r--arch/arm/plat-samsung/include/plat/s5p-clock.h6
-rw-r--r--arch/arm/plat-samsung/include/plat/sdhci.h2
-rw-r--r--arch/arm/plat-samsung/include/plat/udc-hs.h5
-rw-r--r--arch/arm/plat-samsung/include/plat/uncompress.h2
-rw-r--r--arch/arm/plat-samsung/irq-vic-timer.c16
-rw-r--r--arch/arm/plat-samsung/platformdata.c2
-rw-r--r--arch/arm/plat-spear/include/plat/system.h26
-rw-r--r--arch/arm/plat-versatile/Makefile1
-rw-r--r--arch/arm/plat-versatile/localtimer.c27
-rw-r--r--arch/avr32/boards/atngw100/setup.c1
-rw-r--r--arch/avr32/boards/atstk1000/atstk1002.c1
-rw-r--r--arch/avr32/include/asm/io.h1
-rw-r--r--arch/avr32/mach-at32ap/at32ap700x.c2
-rw-r--r--arch/avr32/mach-at32ap/include/mach/board.h13
-rw-r--r--arch/avr32/mach-at32ap/include/mach/cpu.h3
-rw-r--r--arch/blackfin/Kconfig1
-rw-r--r--arch/blackfin/include/asm/irq.h4
-rw-r--r--arch/c6x/include/asm/pgtable.h3
-rw-r--r--arch/hexagon/kernel/signal.c12
-rw-r--r--arch/hexagon/kernel/vdso.c3
-rw-r--r--arch/ia64/include/asm/kvm.h4
-rw-r--r--arch/ia64/include/asm/kvm_host.h3
-rw-r--r--arch/ia64/include/asm/pci.h6
-rw-r--r--arch/ia64/kernel/acpi.c8
-rw-r--r--arch/ia64/kernel/machine_kexec.c2
-rw-r--r--arch/ia64/kernel/mca.c2
-rw-r--r--arch/ia64/kvm/kvm-ia64.c25
-rw-r--r--arch/ia64/pci/pci.c55
-rw-r--r--arch/ia64/sn/kernel/huberror.c2
-rw-r--r--arch/ia64/sn/kernel/io_common.c1
-rw-r--r--arch/ia64/sn/kernel/io_init.c16
-rw-r--r--arch/ia64/sn/kernel/irq.c2
-rw-r--r--arch/ia64/sn/kernel/sn2/sn_hwperf.c1
-rw-r--r--arch/ia64/sn/kernel/tiocx.c7
-rw-r--r--arch/ia64/sn/pci/pcibr/pcibr_provider.c1
-rw-r--r--arch/ia64/sn/pci/tioca_provider.c1
-rw-r--r--arch/ia64/sn/pci/tioce_provider.c1
-rw-r--r--arch/microblaze/Kconfig33
-rw-r--r--arch/microblaze/boot/Makefile2
-rw-r--r--arch/microblaze/include/asm/fixmap.h109
-rw-r--r--arch/microblaze/include/asm/highmem.h96
-rw-r--r--arch/microblaze/include/asm/mmu.h12
-rw-r--r--arch/microblaze/include/asm/page.h4
-rw-r--r--arch/microblaze/include/asm/pci-bridge.h1
-rw-r--r--arch/microblaze/include/asm/pci.h8
-rw-r--r--arch/microblaze/include/asm/pgtable.h5
-rw-r--r--arch/microblaze/include/asm/setup.h3
-rw-r--r--arch/microblaze/include/asm/uaccess.h2
-rw-r--r--arch/microblaze/kernel/cpu/cpuinfo.c2
-rw-r--r--arch/microblaze/kernel/early_printk.c16
-rw-r--r--arch/microblaze/kernel/head.S129
-rw-r--r--arch/microblaze/kernel/hw_exception_handler.S13
-rw-r--r--arch/microblaze/kernel/intc.c4
-rw-r--r--arch/microblaze/kernel/misc.S13
-rw-r--r--arch/microblaze/kernel/setup.c24
-rw-r--r--arch/microblaze/kernel/timer.c6
-rw-r--r--arch/microblaze/kernel/vmlinux.lds.S2
-rw-r--r--arch/microblaze/mm/Makefile1
-rw-r--r--arch/microblaze/mm/highmem.c88
-rw-r--r--arch/microblaze/mm/init.c224
-rw-r--r--arch/microblaze/mm/pgtable.c20
-rw-r--r--arch/microblaze/pci/pci-common.c117
-rw-r--r--arch/mips/fw/arc/cmdline.c1
-rw-r--r--arch/mips/fw/arc/identify.c1
-rw-r--r--arch/mips/include/asm/mman.h4
-rw-r--r--arch/mips/include/asm/pci.h9
-rw-r--r--arch/mips/kernel/vdso.c3
-rw-r--r--arch/mips/pci/fixup-cobalt.c61
-rw-r--r--arch/mips/pci/pci-bcm1480.c2
-rw-r--r--arch/mips/pci/pci-ip27.c2
-rw-r--r--arch/mips/pci/pci-lantiq.c3
-rw-r--r--arch/mips/pci/pci-sb1250.c2
-rw-r--r--arch/mips/pci/pci-xlr.c2
-rw-r--r--arch/mips/pci/pci.c86
-rw-r--r--arch/mn10300/Kconfig1
-rw-r--r--arch/mn10300/include/asm/pci.h16
-rw-r--r--arch/mn10300/include/asm/reset-regs.h4
-rw-r--r--arch/mn10300/unit-asb2305/pci.c62
-rw-r--r--arch/openrisc/Kconfig1
-rw-r--r--arch/openrisc/include/asm/page.h6
-rw-r--r--arch/openrisc/include/asm/pgtable.h1
-rw-r--r--arch/openrisc/include/asm/processor.h4
-rw-r--r--arch/openrisc/include/asm/ptrace.h6
-rw-r--r--arch/openrisc/include/asm/syscall.h7
-rw-r--r--arch/openrisc/include/asm/uaccess.h1
-rw-r--r--arch/openrisc/kernel/entry.S16
-rw-r--r--arch/openrisc/kernel/head.S17
-rw-r--r--arch/openrisc/kernel/ptrace.c4
-rw-r--r--arch/openrisc/kernel/setup.c18
-rw-r--r--arch/openrisc/kernel/signal.c47
-rw-r--r--arch/openrisc/kernel/time.c13
-rw-r--r--arch/openrisc/kernel/traps.c9
-rw-r--r--arch/openrisc/mm/init.c3
-rw-r--r--arch/parisc/include/asm/mman.h4
-rw-r--r--arch/parisc/include/asm/pci.h38
-rw-r--r--arch/parisc/kernel/pci.c52
-rw-r--r--arch/parisc/math-emu/fpudispatch.c1
-rw-r--r--arch/powerpc/boot/.gitignore1
-rw-r--r--arch/powerpc/include/asm/iommu.h1
-rw-r--r--arch/powerpc/include/asm/irq.h6
-rw-r--r--arch/powerpc/include/asm/kvm.h46
-rw-r--r--arch/powerpc/include/asm/kvm_book3s.h98
-rw-r--r--arch/powerpc/include/asm/kvm_book3s_32.h6
-rw-r--r--arch/powerpc/include/asm/kvm_book3s_64.h180
-rw-r--r--arch/powerpc/include/asm/kvm_e500.h52
-rw-r--r--arch/powerpc/include/asm/kvm_host.h90
-rw-r--r--arch/powerpc/include/asm/kvm_para.h41
-rw-r--r--arch/powerpc/include/asm/kvm_ppc.h25
-rw-r--r--arch/powerpc/include/asm/machdep.h4
-rw-r--r--arch/powerpc/include/asm/mmu-book3e.h6
-rw-r--r--arch/powerpc/include/asm/mmu-hash64.h14
-rw-r--r--arch/powerpc/include/asm/pci-bridge.h16
-rw-r--r--arch/powerpc/include/asm/pci.h9
-rw-r--r--arch/powerpc/include/asm/perf_event_server.h2
-rw-r--r--arch/powerpc/include/asm/ppc-opcode.h4
-rw-r--r--arch/powerpc/include/asm/ppc-pci.h2
-rw-r--r--arch/powerpc/include/asm/reg.h5
-rw-r--r--arch/powerpc/include/asm/rtas.h34
-rw-r--r--arch/powerpc/include/asm/smp.h1
-rw-r--r--arch/powerpc/include/asm/udbg.h1
-rw-r--r--arch/powerpc/include/asm/vio.h10
-rw-r--r--arch/powerpc/kernel/asm-offsets.c16
-rw-r--r--arch/powerpc/kernel/exceptions-64s.S8
-rw-r--r--arch/powerpc/kernel/irq.c8
-rw-r--r--arch/powerpc/kernel/kvm.c307
-rw-r--r--arch/powerpc/kernel/kvm_emul.S112
-rw-r--r--arch/powerpc/kernel/pci-common.c86
-rw-r--r--arch/powerpc/kernel/pci_32.c6
-rw-r--r--arch/powerpc/kernel/pci_64.c7
-rw-r--r--arch/powerpc/kernel/pci_of_scan.c12
-rw-r--r--arch/powerpc/kernel/pmc.c1
-rw-r--r--arch/powerpc/kernel/prom_init.c2
-rw-r--r--arch/powerpc/kernel/rtas.c34
-rw-r--r--arch/powerpc/kernel/rtas_pci.c10
-rw-r--r--arch/powerpc/kernel/setup_64.c2
-rw-r--r--arch/powerpc/kernel/udbg.c3
-rw-r--r--arch/powerpc/kernel/vdso.c14
-rw-r--r--arch/powerpc/kernel/vio.c12
-rw-r--r--arch/powerpc/kvm/Kconfig1
-rw-r--r--arch/powerpc/kvm/book3s.c57
-rw-r--r--arch/powerpc/kvm/book3s_32_mmu_host.c21
-rw-r--r--arch/powerpc/kvm/book3s_64_mmu_host.c66
-rw-r--r--arch/powerpc/kvm/book3s_64_mmu_hv.c919
-rw-r--r--arch/powerpc/kvm/book3s_emulate.c8
-rw-r--r--arch/powerpc/kvm/book3s_hv.c465
-rw-r--r--arch/powerpc/kvm/book3s_hv_builtin.c209
-rw-r--r--arch/powerpc/kvm/book3s_hv_rm_mmu.c835
-rw-r--r--arch/powerpc/kvm/book3s_hv_rmhandlers.S176
-rw-r--r--arch/powerpc/kvm/book3s_paired_singles.c9
-rw-r--r--arch/powerpc/kvm/book3s_pr.c178
-rw-r--r--arch/powerpc/kvm/booke.c150
-rw-r--r--arch/powerpc/kvm/booke.h4
-rw-r--r--arch/powerpc/kvm/booke_emulate.c23
-rw-r--r--arch/powerpc/kvm/booke_interrupts.S18
-rw-r--r--arch/powerpc/kvm/e500.c32
-rw-r--r--arch/powerpc/kvm/e500_emulate.c38
-rw-r--r--arch/powerpc/kvm/e500_tlb.c775
-rw-r--r--arch/powerpc/kvm/e500_tlb.h80
-rw-r--r--arch/powerpc/kvm/emulate.c61
-rw-r--r--arch/powerpc/kvm/powerpc.c148
-rw-r--r--arch/powerpc/kvm/trace.h62
-rw-r--r--arch/powerpc/mm/hugetlbpage.c5
-rw-r--r--arch/powerpc/perf/core-book3s.c46
-rw-r--r--arch/powerpc/perf/power4-pmu.c1
-rw-r--r--arch/powerpc/perf/ppc970-pmu.c1
-rw-r--r--arch/powerpc/platforms/cell/beat_htab.c2
-rw-r--r--arch/powerpc/platforms/maple/pci.c2
-rw-r--r--arch/powerpc/platforms/pasemi/pci.c3
-rw-r--r--arch/powerpc/platforms/powermac/pci.c3
-rw-r--r--arch/powerpc/platforms/powernv/pci-ioda.c5
-rw-r--r--arch/powerpc/platforms/powernv/pci.c5
-rw-r--r--arch/powerpc/platforms/pseries/eeh.c19
-rw-r--r--arch/powerpc/platforms/pseries/eeh_dev.c2
-rw-r--r--arch/powerpc/platforms/pseries/io_event_irq.c68
-rw-r--r--arch/powerpc/platforms/pseries/iommu.c29
-rw-r--r--arch/powerpc/platforms/pseries/pci_dlpar.c2
-rw-r--r--arch/powerpc/platforms/pseries/ras.c194
-rw-r--r--arch/powerpc/platforms/pseries/setup.c3
-rw-r--r--arch/powerpc/platforms/wsp/wsp_pci.c1
-rw-r--r--arch/powerpc/xmon/ppc-opc.c1
-rw-r--r--arch/powerpc/xmon/spu-opc.c1
-rw-r--r--arch/s390/Kconfig1
-rw-r--r--arch/s390/include/asm/cpu_mf.h95
-rw-r--r--arch/s390/include/asm/irq.h2
-rw-r--r--arch/s390/include/asm/kvm.h11
-rw-r--r--arch/s390/include/asm/kvm_host.h12
-rw-r--r--arch/s390/include/asm/perf_event.h12
-rw-r--r--arch/s390/kernel/Makefile1
-rw-r--r--arch/s390/kernel/irq.c23
-rw-r--r--arch/s390/kernel/perf_cpum_cf.c690
-rw-r--r--arch/s390/kernel/perf_event.c125
-rw-r--r--arch/s390/kernel/vdso.c10
-rw-r--r--arch/s390/kvm/Kconfig9
-rw-r--r--arch/s390/kvm/diag.c6
-rw-r--r--arch/s390/kvm/intercept.c24
-rw-r--r--arch/s390/kvm/interrupt.c3
-rw-r--r--arch/s390/kvm/kvm-s390.c221
-rw-r--r--arch/s390/kvm/kvm-s390.h18
-rw-r--r--arch/s390/kvm/priv.c27
-rw-r--r--arch/s390/kvm/sigp.c57
-rw-r--r--arch/s390/mm/mmap.c2
-rw-r--r--arch/s390/oprofile/hwsampler.c51
-rw-r--r--arch/sh/boards/mach-highlander/setup.c2
-rw-r--r--arch/sh/boards/mach-sdk7786/setup.c2
-rw-r--r--arch/sh/drivers/pci/pci.c75
-rw-r--r--arch/sh/include/asm/clock.h2
-rw-r--r--arch/sh/include/asm/pci.h6
-rw-r--r--arch/sh/kernel/cpu/sh2/clock-sh7619.c12
-rw-r--r--arch/sh/kernel/cpu/sh2a/clock-sh7201.c12
-rw-r--r--arch/sh/kernel/cpu/sh2a/clock-sh7203.c12
-rw-r--r--arch/sh/kernel/cpu/sh2a/clock-sh7206.c12
-rw-r--r--arch/sh/kernel/cpu/sh3/clock-sh3.c12
-rw-r--r--arch/sh/kernel/cpu/sh3/clock-sh7705.c12
-rw-r--r--arch/sh/kernel/cpu/sh3/clock-sh7706.c12
-rw-r--r--arch/sh/kernel/cpu/sh3/clock-sh7709.c12
-rw-r--r--arch/sh/kernel/cpu/sh3/clock-sh7710.c12
-rw-r--r--arch/sh/kernel/cpu/sh3/clock-sh7712.c10
-rw-r--r--arch/sh/kernel/cpu/sh4/clock-sh4-202.c6
-rw-r--r--arch/sh/kernel/cpu/sh4/clock-sh4.c12
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-sh7343.c4
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-sh7366.c4
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-sh7722.c4
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-sh7723.c4
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-sh7724.c6
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-sh7757.c2
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-sh7763.c14
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-sh7770.c12
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-sh7780.c14
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-sh7785.c2
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-sh7786.c2
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-shx3.c2
-rw-r--r--arch/sh/kernel/cpu/sh5/clock-sh5.c12
-rw-r--r--arch/sh/kernel/vsyscall/vsyscall.c3
-rw-r--r--arch/sparc/Kconfig1
-rw-r--r--arch/sparc/include/asm/irq_64.h1
-rw-r--r--arch/sparc/include/asm/pci_32.h8
-rw-r--r--arch/sparc/include/asm/pci_64.h8
-rw-r--r--arch/sparc/include/asm/vga.h1
-rw-r--r--arch/sparc/include/asm/vio.h9
-rw-r--r--arch/sparc/kernel/ds.c5
-rw-r--r--arch/sparc/kernel/leon_pci.c47
-rw-r--r--arch/sparc/kernel/pci.c106
-rw-r--r--arch/sparc/kernel/vio.c8
-rw-r--r--arch/tile/mm/elf.c8
-rw-r--r--arch/um/Kconfig.common1
-rw-r--r--arch/um/Makefile5
-rw-r--r--arch/um/defconfig655
-rw-r--r--arch/um/drivers/chan.h18
-rw-r--r--arch/um/drivers/chan_kern.c198
-rw-r--r--arch/um/drivers/chan_user.h2
-rw-r--r--arch/um/drivers/line.c258
-rw-r--r--arch/um/drivers/line.h29
-rw-r--r--arch/um/drivers/mconsole_kern.c2
-rw-r--r--arch/um/drivers/net_kern.c2
-rw-r--r--arch/um/drivers/port_kern.c4
-rw-r--r--arch/um/drivers/random.c2
-rw-r--r--arch/um/drivers/ssl.c41
-rw-r--r--arch/um/drivers/stdio_console.c46
-rw-r--r--arch/um/drivers/ubd.h (renamed from arch/um/drivers/ubd_user.h)0
-rw-r--r--arch/um/drivers/ubd_kern.c46
-rw-r--r--arch/um/drivers/ubd_user.c8
-rw-r--r--arch/um/drivers/xterm_kern.c2
-rw-r--r--arch/um/include/asm/Kbuild2
-rw-r--r--arch/um/include/asm/asm-offsets.h1
-rw-r--r--arch/um/include/asm/auxvec.h4
-rw-r--r--arch/um/include/asm/current.h13
-rw-r--r--arch/um/include/asm/delay.h18
-rw-r--r--arch/um/include/asm/io.h57
-rw-r--r--arch/um/include/asm/mutex.h9
-rw-r--r--arch/um/include/asm/param.h20
-rw-r--r--arch/um/include/asm/pci.h6
-rw-r--r--arch/um/include/asm/pgalloc.h3
-rw-r--r--arch/um/include/asm/pgtable.h2
-rw-r--r--arch/um/include/asm/ptrace-generic.h1
-rw-r--r--arch/um/include/shared/common-offsets.h2
-rw-r--r--arch/um/include/shared/kern_util.h2
-rw-r--r--arch/um/kernel/Makefile2
-rw-r--r--arch/um/kernel/process.c4
-rw-r--r--arch/um/kernel/sigio.c2
-rw-r--r--arch/um/kernel/signal.c26
-rw-r--r--arch/um/kernel/time.c2
-rw-r--r--arch/um/os-Linux/Makefile2
-rw-r--r--arch/um/os-Linux/user_syms.c2
-rw-r--r--arch/um/scripts/Makefile.rules7
-rw-r--r--arch/unicore32/include/asm/pci.h1
-rw-r--r--arch/unicore32/kernel/pci.c5
-rw-r--r--arch/unicore32/kernel/process.c2
-rw-r--r--arch/x86/Kconfig7
-rw-r--r--arch/x86/Makefile.um4
-rw-r--r--arch/x86/boot/Makefile6
-rw-r--r--arch/x86/include/asm/debugreg.h67
-rw-r--r--arch/x86/include/asm/kgdb.h10
-rw-r--r--arch/x86/include/asm/kvm.h4
-rw-r--r--arch/x86/include/asm/kvm_emulate.h3
-rw-r--r--arch/x86/include/asm/kvm_host.h63
-rw-r--r--arch/x86/include/asm/paravirt.h1
-rw-r--r--arch/x86/include/asm/perf_event.h1
-rw-r--r--arch/x86/include/asm/processor.h63
-rw-r--r--arch/x86/include/asm/tsc.h4
-rw-r--r--arch/x86/include/asm/x86_init.h6
-rw-r--r--arch/x86/kernel/cpu/common.c1
-rw-r--r--arch/x86/kernel/cpu/perf_event.c4
-rw-r--r--arch/x86/kernel/entry_32.S17
-rw-r--r--arch/x86/kernel/irqinit.c6
-rw-r--r--arch/x86/kernel/kgdb.c6
-rw-r--r--arch/x86/kernel/kvmclock.c15
-rw-r--r--arch/x86/kernel/paravirt.c1
-rw-r--r--arch/x86/kernel/pci-dma.c5
-rw-r--r--arch/x86/kernel/smpboot.c1
-rw-r--r--arch/x86/kernel/tsc.c4
-rw-r--r--arch/x86/kernel/x86_init.c5
-rw-r--r--arch/x86/kvm/cpuid.c2
-rw-r--r--arch/x86/kvm/cpuid.h8
-rw-r--r--arch/x86/kvm/emulate.c112
-rw-r--r--arch/x86/kvm/i8259.c1
-rw-r--r--arch/x86/kvm/lapic.c4
-rw-r--r--arch/x86/kvm/mmu.c85
-rw-r--r--arch/x86/kvm/mmu_audit.c4
-rw-r--r--arch/x86/kvm/pmu.c10
-rw-r--r--arch/x86/kvm/svm.c119
-rw-r--r--arch/x86/kvm/vmx.c53
-rw-r--r--arch/x86/kvm/x86.c403
-rw-r--r--arch/x86/mm/kmemcheck/selftest.c1
-rw-r--r--arch/x86/pci/acpi.c7
-rw-r--r--arch/x86/pci/fixup.c12
-rw-r--r--arch/x86/pci/i386.c85
-rw-r--r--arch/x86/pci/mrst.c40
-rw-r--r--arch/x86/platform/ce4100/falconfalls.dts7
-rw-r--r--arch/x86/platform/geode/Makefile1
-rw-r--r--arch/x86/platform/geode/geos.c128
-rw-r--r--arch/x86/power/cpu.c4
-rw-r--r--arch/x86/syscalls/syscall_32.tbl2
-rw-r--r--arch/x86/um/Kconfig4
-rw-r--r--arch/x86/um/asm/processor.h10
-rw-r--r--arch/x86/um/asm/processor_32.h10
-rw-r--r--arch/x86/um/asm/processor_64.h10
-rw-r--r--arch/x86/um/bugs_32.c4
-rw-r--r--arch/x86/um/mem_32.c8
-rw-r--r--arch/x86/um/vdso/vma.c3
-rw-r--r--arch/x86/vdso/vdso32-setup.c17
-rw-r--r--arch/x86/vdso/vma.c3
-rw-r--r--arch/x86/xen/setup.c2
-rw-r--r--arch/x86/xen/smp.c6
-rw-r--r--arch/xtensa/include/asm/mman.h4
-rw-r--r--arch/xtensa/kernel/pci.c17
1405 files changed, 36670 insertions, 19644 deletions
diff --git a/arch/Kconfig b/arch/Kconfig
index 5b448a74d0f..a6f14f622d1 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -120,6 +120,9 @@ config HAVE_KRETPROBES
120 120
121config HAVE_OPTPROBES 121config HAVE_OPTPROBES
122 bool 122 bool
123
124config HAVE_NMI_WATCHDOG
125 bool
123# 126#
124# An arch should select this if it provides all these things: 127# An arch should select this if it provides all these things:
125# 128#
diff --git a/arch/alpha/include/asm/mman.h b/arch/alpha/include/asm/mman.h
index 72db984f878..cbeb3616a28 100644
--- a/arch/alpha/include/asm/mman.h
+++ b/arch/alpha/include/asm/mman.h
@@ -56,6 +56,10 @@
56#define MADV_HUGEPAGE 14 /* Worth backing with hugepages */ 56#define MADV_HUGEPAGE 14 /* Worth backing with hugepages */
57#define MADV_NOHUGEPAGE 15 /* Not worth backing with hugepages */ 57#define MADV_NOHUGEPAGE 15 /* Not worth backing with hugepages */
58 58
59#define MADV_DONTDUMP 16 /* Explicity exclude from the core dump,
60 overrides the coredump filter bits */
61#define MADV_DODUMP 17 /* Clear the MADV_NODUMP flag */
62
59/* compatibility flags */ 63/* compatibility flags */
60#define MAP_FILE 0 64#define MAP_FILE 0
61 65
diff --git a/arch/alpha/include/asm/pci.h b/arch/alpha/include/asm/pci.h
index 28d0497fd3c..d01afb78919 100644
--- a/arch/alpha/include/asm/pci.h
+++ b/arch/alpha/include/asm/pci.h
@@ -7,6 +7,7 @@
7#include <linux/dma-mapping.h> 7#include <linux/dma-mapping.h>
8#include <asm/scatterlist.h> 8#include <asm/scatterlist.h>
9#include <asm/machvec.h> 9#include <asm/machvec.h>
10#include <asm-generic/pci-bridge.h>
10 11
11/* 12/*
12 * The following structure is used to manage multiple PCI busses. 13 * The following structure is used to manage multiple PCI busses.
@@ -99,12 +100,6 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
99 return channel ? 15 : 14; 100 return channel ? 15 : 14;
100} 101}
101 102
102extern void pcibios_resource_to_bus(struct pci_dev *, struct pci_bus_region *,
103 struct resource *);
104
105extern void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
106 struct pci_bus_region *region);
107
108#define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index 103#define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index
109 104
110static inline int pci_proc_domain(struct pci_bus *bus) 105static inline int pci_proc_domain(struct pci_bus *bus)
diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index 8c723c1b086..1a629636cc1 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -43,12 +43,10 @@ const char *const pci_mem_names[] = {
43 43
44const char pci_hae0_name[] = "HAE0"; 44const char pci_hae0_name[] = "HAE0";
45 45
46/* Indicate whether we respect the PCI setup left by console. */
47/* 46/*
48 * Make this long-lived so that we know when shutting down 47 * If PCI_PROBE_ONLY in pci_flags is set, we don't change any PCI resource
49 * whether we probed only or not. 48 * assignments.
50 */ 49 */
51int pci_probe_only;
52 50
53/* 51/*
54 * The PCI controller list. 52 * The PCI controller list.
@@ -215,7 +213,7 @@ pdev_save_srm_config(struct pci_dev *dev)
215 struct pdev_srm_saved_conf *tmp; 213 struct pdev_srm_saved_conf *tmp;
216 static int printed = 0; 214 static int printed = 0;
217 215
218 if (!alpha_using_srm || pci_probe_only) 216 if (!alpha_using_srm || pci_has_flag(PCI_PROBE_ONLY))
219 return; 217 return;
220 218
221 if (!printed) { 219 if (!printed) {
@@ -242,7 +240,7 @@ pci_restore_srm_config(void)
242 struct pdev_srm_saved_conf *tmp; 240 struct pdev_srm_saved_conf *tmp;
243 241
244 /* No need to restore if probed only. */ 242 /* No need to restore if probed only. */
245 if (pci_probe_only) 243 if (pci_has_flag(PCI_PROBE_ONLY))
246 return; 244 return;
247 245
248 /* Restore SRM config. */ 246 /* Restore SRM config. */
@@ -253,46 +251,17 @@ pci_restore_srm_config(void)
253#endif 251#endif
254 252
255void __devinit 253void __devinit
256pcibios_fixup_resource(struct resource *res, struct resource *root)
257{
258 res->start += root->start;
259 res->end += root->start;
260}
261
262void __devinit
263pcibios_fixup_device_resources(struct pci_dev *dev, struct pci_bus *bus)
264{
265 /* Update device resources. */
266 struct pci_controller *hose = (struct pci_controller *)bus->sysdata;
267 int i;
268
269 for (i = 0; i < PCI_NUM_RESOURCES; i++) {
270 if (!dev->resource[i].start)
271 continue;
272 if (dev->resource[i].flags & IORESOURCE_IO)
273 pcibios_fixup_resource(&dev->resource[i],
274 hose->io_space);
275 else if (dev->resource[i].flags & IORESOURCE_MEM)
276 pcibios_fixup_resource(&dev->resource[i],
277 hose->mem_space);
278 }
279}
280
281void __devinit
282pcibios_fixup_bus(struct pci_bus *bus) 254pcibios_fixup_bus(struct pci_bus *bus)
283{ 255{
284 struct pci_dev *dev = bus->self; 256 struct pci_dev *dev = bus->self;
285 257
286 if (pci_probe_only && dev && 258 if (pci_has_flag(PCI_PROBE_ONLY) && dev &&
287 (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) { 259 (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
288 pci_read_bridge_bases(bus); 260 pci_read_bridge_bases(bus);
289 pcibios_fixup_device_resources(dev, bus);
290 } 261 }
291 262
292 list_for_each_entry(dev, &bus->devices, bus_list) { 263 list_for_each_entry(dev, &bus->devices, bus_list) {
293 pdev_save_srm_config(dev); 264 pdev_save_srm_config(dev);
294 if ((dev->class >> 8) != PCI_CLASS_BRIDGE_PCI)
295 pcibios_fixup_device_resources(dev, bus);
296 } 265 }
297} 266}
298 267
@@ -302,42 +271,6 @@ pcibios_update_irq(struct pci_dev *dev, int irq)
302 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); 271 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
303} 272}
304 273
305void
306pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
307 struct resource *res)
308{
309 struct pci_controller *hose = (struct pci_controller *)dev->sysdata;
310 unsigned long offset = 0;
311
312 if (res->flags & IORESOURCE_IO)
313 offset = hose->io_space->start;
314 else if (res->flags & IORESOURCE_MEM)
315 offset = hose->mem_space->start;
316
317 region->start = res->start - offset;
318 region->end = res->end - offset;
319}
320
321void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
322 struct pci_bus_region *region)
323{
324 struct pci_controller *hose = (struct pci_controller *)dev->sysdata;
325 unsigned long offset = 0;
326
327 if (res->flags & IORESOURCE_IO)
328 offset = hose->io_space->start;
329 else if (res->flags & IORESOURCE_MEM)
330 offset = hose->mem_space->start;
331
332 res->start = region->start + offset;
333 res->end = region->end + offset;
334}
335
336#ifdef CONFIG_HOTPLUG
337EXPORT_SYMBOL(pcibios_resource_to_bus);
338EXPORT_SYMBOL(pcibios_bus_to_resource);
339#endif
340
341int 274int
342pcibios_enable_device(struct pci_dev *dev, int mask) 275pcibios_enable_device(struct pci_dev *dev, int mask)
343{ 276{
@@ -374,7 +307,8 @@ pcibios_claim_one_bus(struct pci_bus *b)
374 307
375 if (r->parent || !r->start || !r->flags) 308 if (r->parent || !r->start || !r->flags)
376 continue; 309 continue;
377 if (pci_probe_only || (r->flags & IORESOURCE_PCI_FIXED)) 310 if (pci_has_flag(PCI_PROBE_ONLY) ||
311 (r->flags & IORESOURCE_PCI_FIXED))
378 pci_claim_resource(dev, i); 312 pci_claim_resource(dev, i);
379 } 313 }
380 } 314 }
@@ -416,8 +350,10 @@ common_init_pci(void)
416 hose->mem_space->end = end; 350 hose->mem_space->end = end;
417 351
418 INIT_LIST_HEAD(&resources); 352 INIT_LIST_HEAD(&resources);
419 pci_add_resource(&resources, hose->io_space); 353 pci_add_resource_offset(&resources, hose->io_space,
420 pci_add_resource(&resources, hose->mem_space); 354 hose->io_space->start);
355 pci_add_resource_offset(&resources, hose->mem_space,
356 hose->mem_space->start);
421 357
422 bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops, 358 bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops,
423 hose, &resources); 359 hose, &resources);
diff --git a/arch/alpha/kernel/pci_impl.h b/arch/alpha/kernel/pci_impl.h
index 85457b2d451..2b0ac429f5e 100644
--- a/arch/alpha/kernel/pci_impl.h
+++ b/arch/alpha/kernel/pci_impl.h
@@ -173,9 +173,6 @@ extern void pci_restore_srm_config(void);
173extern struct pci_controller *hose_head, **hose_tail; 173extern struct pci_controller *hose_head, **hose_tail;
174extern struct pci_controller *pci_isa_hose; 174extern struct pci_controller *pci_isa_hose;
175 175
176/* Indicate that we trust the console to configure things properly. */
177extern int pci_probe_only;
178
179extern unsigned long alpha_agpgart_size; 176extern unsigned long alpha_agpgart_size;
180 177
181extern void common_init_pci(void); 178extern void common_init_pci(void);
diff --git a/arch/alpha/kernel/sys_marvel.c b/arch/alpha/kernel/sys_marvel.c
index e8b4f6f8cbb..14a4b6a7cf5 100644
--- a/arch/alpha/kernel/sys_marvel.c
+++ b/arch/alpha/kernel/sys_marvel.c
@@ -383,7 +383,8 @@ marvel_init_pci(void)
383 383
384 marvel_register_error_handlers(); 384 marvel_register_error_handlers();
385 385
386 pci_probe_only = 1; 386 /* Indicate that we trust the console to configure things properly */
387 pci_set_flags(PCI_PROBE_ONLY);
387 common_init_pci(); 388 common_init_pci();
388 locate_and_init_vga(NULL); 389 locate_and_init_vga(NULL);
389 390
diff --git a/arch/alpha/kernel/sys_titan.c b/arch/alpha/kernel/sys_titan.c
index 9de928c6ef9..2533db280d9 100644
--- a/arch/alpha/kernel/sys_titan.c
+++ b/arch/alpha/kernel/sys_titan.c
@@ -330,7 +330,8 @@ titan_init_pci(void)
330 */ 330 */
331 titan_late_init(); 331 titan_late_init();
332 332
333 pci_probe_only = 1; 333 /* Indicate that we trust the console to configure things properly */
334 pci_set_flags(PCI_PROBE_ONLY);
334 common_init_pci(); 335 common_init_pci();
335 SMC669_Init(0); 336 SMC669_Init(0);
336 locate_and_init_vga(NULL); 337 locate_and_init_vga(NULL);
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index dfb0312f4e7..5098564d587 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -186,6 +186,9 @@ config GENERIC_ISA_DMA
186config FIQ 186config FIQ
187 bool 187 bool
188 188
189config NEED_RET_TO_USER
190 bool
191
189config ARCH_MTD_XIP 192config ARCH_MTD_XIP
190 bool 193 bool
191 194
@@ -322,9 +325,10 @@ config ARCH_AT91
322 select ARCH_REQUIRE_GPIOLIB 325 select ARCH_REQUIRE_GPIOLIB
323 select HAVE_CLK 326 select HAVE_CLK
324 select CLKDEV_LOOKUP 327 select CLKDEV_LOOKUP
328 select IRQ_DOMAIN
325 help 329 help
326 This enables support for systems based on the Atmel AT91RM9200, 330 This enables support for systems based on the Atmel AT91RM9200,
327 AT91SAM9 and AT91CAP9 processors. 331 AT91SAM9 processors.
328 332
329config ARCH_BCMRING 333config ARCH_BCMRING
330 bool "Broadcom BCMRING" 334 bool "Broadcom BCMRING"
@@ -479,6 +483,7 @@ config ARCH_IOP13XX
479 select ARCH_SUPPORTS_MSI 483 select ARCH_SUPPORTS_MSI
480 select VMSPLIT_1G 484 select VMSPLIT_1G
481 select NEED_MACH_MEMORY_H 485 select NEED_MACH_MEMORY_H
486 select NEED_RET_TO_USER
482 help 487 help
483 Support for Intel's IOP13XX (XScale) family of processors. 488 Support for Intel's IOP13XX (XScale) family of processors.
484 489
@@ -486,6 +491,7 @@ config ARCH_IOP32X
486 bool "IOP32x-based" 491 bool "IOP32x-based"
487 depends on MMU 492 depends on MMU
488 select CPU_XSCALE 493 select CPU_XSCALE
494 select NEED_RET_TO_USER
489 select PLAT_IOP 495 select PLAT_IOP
490 select PCI 496 select PCI
491 select ARCH_REQUIRE_GPIOLIB 497 select ARCH_REQUIRE_GPIOLIB
@@ -497,6 +503,7 @@ config ARCH_IOP33X
497 bool "IOP33x-based" 503 bool "IOP33x-based"
498 depends on MMU 504 depends on MMU
499 select CPU_XSCALE 505 select CPU_XSCALE
506 select NEED_RET_TO_USER
500 select PLAT_IOP 507 select PLAT_IOP
501 select PCI 508 select PCI
502 select ARCH_REQUIRE_GPIOLIB 509 select ARCH_REQUIRE_GPIOLIB
@@ -731,7 +738,6 @@ config ARCH_RPC
731 bool "RiscPC" 738 bool "RiscPC"
732 select ARCH_ACORN 739 select ARCH_ACORN
733 select FIQ 740 select FIQ
734 select TIMER_ACORN
735 select ARCH_MAY_HAVE_PC_FDC 741 select ARCH_MAY_HAVE_PC_FDC
736 select HAVE_PATA_PLATFORM 742 select HAVE_PATA_PLATFORM
737 select ISA_DMA_API 743 select ISA_DMA_API
@@ -754,31 +760,31 @@ config ARCH_SA1100
754 select ARCH_HAS_CPUFREQ 760 select ARCH_HAS_CPUFREQ
755 select CPU_FREQ 761 select CPU_FREQ
756 select GENERIC_CLOCKEVENTS 762 select GENERIC_CLOCKEVENTS
757 select HAVE_CLK 763 select CLKDEV_LOOKUP
758 select HAVE_SCHED_CLOCK 764 select HAVE_SCHED_CLOCK
759 select TICK_ONESHOT 765 select TICK_ONESHOT
760 select ARCH_REQUIRE_GPIOLIB 766 select ARCH_REQUIRE_GPIOLIB
761 select HAVE_IDE 767 select HAVE_IDE
762 select NEED_MACH_MEMORY_H 768 select NEED_MACH_MEMORY_H
769 select SPARSE_IRQ
763 help 770 help
764 Support for StrongARM 11x0 based boards. 771 Support for StrongARM 11x0 based boards.
765 772
766config ARCH_S3C2410 773config ARCH_S3C24XX
767 bool "Samsung S3C2410, S3C2412, S3C2413, S3C2416, S3C2440, S3C2442, S3C2443, S3C2450" 774 bool "Samsung S3C24XX SoCs"
768 select GENERIC_GPIO 775 select GENERIC_GPIO
769 select ARCH_HAS_CPUFREQ 776 select ARCH_HAS_CPUFREQ
770 select HAVE_CLK 777 select HAVE_CLK
771 select CLKDEV_LOOKUP 778 select CLKDEV_LOOKUP
772 select ARCH_USES_GETTIMEOFFSET 779 select ARCH_USES_GETTIMEOFFSET
773 select HAVE_S3C2410_I2C if I2C 780 select HAVE_S3C2410_I2C if I2C
781 select HAVE_S3C_RTC if RTC_CLASS
782 select HAVE_S3C2410_WATCHDOG if WATCHDOG
774 help 783 help
775 Samsung S3C2410X CPU based systems, such as the Simtec Electronics 784 Samsung S3C2410, S3C2412, S3C2413, S3C2416, S3C2440, S3C2442, S3C2443
776 BAST (<http://www.simtec.co.uk/products/EB110ITX/>), the IPAQ 1940 or 785 and S3C2450 SoCs based systems, such as the Simtec Electronics BAST
777 the Samsung SMDK2410 development board (and derivatives). 786 (<http://www.simtec.co.uk/products/EB110ITX/>), the IPAQ 1940 or the
778 787 Samsung SMDK2410 development board (and derivatives).
779 Note, the S3C2416 and the S3C2450 are so close that they even share
780 the same SoC ID code. This means that there is no separate machine
781 directory (no arch/arm/mach-s3c2450) as the S3C2416 was first.
782 788
783config ARCH_S3C64XX 789config ARCH_S3C64XX
784 bool "Samsung S3C64XX" 790 bool "Samsung S3C64XX"
@@ -901,6 +907,7 @@ config ARCH_U300
901 907
902config ARCH_U8500 908config ARCH_U8500
903 bool "ST-Ericsson U8500 Series" 909 bool "ST-Ericsson U8500 Series"
910 depends on MMU
904 select CPU_V7 911 select CPU_V7
905 select ARM_AMBA 912 select ARM_AMBA
906 select GENERIC_CLOCKEVENTS 913 select GENERIC_CLOCKEVENTS
@@ -1066,12 +1073,10 @@ source "arch/arm/plat-s5p/Kconfig"
1066 1073
1067source "arch/arm/plat-spear/Kconfig" 1074source "arch/arm/plat-spear/Kconfig"
1068 1075
1069if ARCH_S3C2410 1076source "arch/arm/mach-s3c24xx/Kconfig"
1070source "arch/arm/mach-s3c2410/Kconfig" 1077if ARCH_S3C24XX
1071source "arch/arm/mach-s3c2412/Kconfig" 1078source "arch/arm/mach-s3c2412/Kconfig"
1072source "arch/arm/mach-s3c2416/Kconfig"
1073source "arch/arm/mach-s3c2440/Kconfig" 1079source "arch/arm/mach-s3c2440/Kconfig"
1074source "arch/arm/mach-s3c2443/Kconfig"
1075endif 1080endif
1076 1081
1077if ARCH_S3C64XX 1082if ARCH_S3C64XX
@@ -1127,6 +1132,7 @@ config PLAT_VERSATILE
1127config ARM_TIMER_SP804 1132config ARM_TIMER_SP804
1128 bool 1133 bool
1129 select CLKSRC_MMIO 1134 select CLKSRC_MMIO
1135 select HAVE_SCHED_CLOCK
1130 1136
1131source arch/arm/mm/Kconfig 1137source arch/arm/mm/Kconfig
1132 1138
@@ -1577,7 +1583,8 @@ config LOCAL_TIMERS
1577config ARCH_NR_GPIO 1583config ARCH_NR_GPIO
1578 int 1584 int
1579 default 1024 if ARCH_SHMOBILE || ARCH_TEGRA 1585 default 1024 if ARCH_SHMOBILE || ARCH_TEGRA
1580 default 350 if ARCH_U8500 1586 default 355 if ARCH_U8500
1587 default 264 if MACH_H4700
1581 default 0 1588 default 0
1582 help 1589 help
1583 Maximum number of GPIOs in the system. 1590 Maximum number of GPIOs in the system.
@@ -1588,7 +1595,7 @@ source kernel/Kconfig.preempt
1588 1595
1589config HZ 1596config HZ
1590 int 1597 int
1591 default 200 if ARCH_EBSA110 || ARCH_S3C2410 || ARCH_S5P64X0 || \ 1598 default 200 if ARCH_EBSA110 || ARCH_S3C24XX || ARCH_S5P64X0 || \
1592 ARCH_S5PV210 || ARCH_EXYNOS4 1599 ARCH_S5PV210 || ARCH_EXYNOS4
1593 default OMAP_32K_TIMER_HZ if ARCH_OMAP && OMAP_32K_TIMER 1600 default OMAP_32K_TIMER_HZ if ARCH_OMAP && OMAP_32K_TIMER
1594 default AT91_TIMER_HZ if ARCH_AT91 1601 default AT91_TIMER_HZ if ARCH_AT91
@@ -2114,7 +2121,7 @@ config CPU_FREQ_S3C
2114 2121
2115config CPU_FREQ_S3C24XX 2122config CPU_FREQ_S3C24XX
2116 bool "CPUfreq driver for Samsung S3C24XX series CPUs (EXPERIMENTAL)" 2123 bool "CPUfreq driver for Samsung S3C24XX series CPUs (EXPERIMENTAL)"
2117 depends on ARCH_S3C2410 && CPU_FREQ && EXPERIMENTAL 2124 depends on ARCH_S3C24XX && CPU_FREQ && EXPERIMENTAL
2118 select CPU_FREQ_S3C 2125 select CPU_FREQ_S3C
2119 help 2126 help
2120 This enables the CPUfreq driver for the Samsung S3C24XX family 2127 This enables the CPUfreq driver for the Samsung S3C24XX family
diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
index e0d236d7ff7..66ca8014ff3 100644
--- a/arch/arm/Kconfig.debug
+++ b/arch/arm/Kconfig.debug
@@ -81,47 +81,14 @@ choice
81 prompt "Kernel low-level debugging port" 81 prompt "Kernel low-level debugging port"
82 depends on DEBUG_LL 82 depends on DEBUG_LL
83 83
84 config DEBUG_LL_UART_NONE
85 bool "No low-level debugging UART"
86 help
87 Say Y here if your platform doesn't provide a UART option
88 below. This relies on your platform choosing the right UART
89 definition internally in order for low-level debugging to
90 work.
91
92 config DEBUG_ICEDCC
93 bool "Kernel low-level debugging via EmbeddedICE DCC channel"
94 help
95 Say Y here if you want the debug print routines to direct
96 their output to the EmbeddedICE macrocell's DCC channel using
97 co-processor 14. This is known to work on the ARM9 style ICE
98 channel and on the XScale with the PEEDI.
99
100 Note that the system will appear to hang during boot if there
101 is nothing connected to read from the DCC.
102
103 config AT91_DEBUG_LL_DBGU0 84 config AT91_DEBUG_LL_DBGU0
104 bool "Kernel low-level debugging on rm9200, 9260/9g20, 9261/9g10 and 9rl" 85 bool "Kernel low-level debugging on rm9200, 9260/9g20, 9261/9g10 and 9rl"
105 depends on HAVE_AT91_DBGU0 86 depends on HAVE_AT91_DBGU0
106 87
107 config AT91_DEBUG_LL_DBGU1 88 config AT91_DEBUG_LL_DBGU1
108 bool "Kernel low-level debugging on 9263, 9g45 and cap9" 89 bool "Kernel low-level debugging on 9263 and 9g45"
109 depends on HAVE_AT91_DBGU1 90 depends on HAVE_AT91_DBGU1
110 91
111 config DEBUG_FOOTBRIDGE_COM1
112 bool "Kernel low-level debugging messages via footbridge 8250 at PCI COM1"
113 depends on FOOTBRIDGE
114 help
115 Say Y here if you want the debug print routines to direct
116 their output to the 8250 at PCI COM1.
117
118 config DEBUG_DC21285_PORT
119 bool "Kernel low-level debugging messages via footbridge serial port"
120 depends on FOOTBRIDGE
121 help
122 Say Y here if you want the debug print routines to direct
123 their output to the serial port in the DC21285 (Footbridge).
124
125 config DEBUG_CLPS711X_UART1 92 config DEBUG_CLPS711X_UART1
126 bool "Kernel low-level debugging messages via UART1" 93 bool "Kernel low-level debugging messages via UART1"
127 depends on ARCH_CLPS711X 94 depends on ARCH_CLPS711X
@@ -136,6 +103,20 @@ choice
136 Say Y here if you want the debug print routines to direct 103 Say Y here if you want the debug print routines to direct
137 their output to the second serial port on these devices. 104 their output to the second serial port on these devices.
138 105
106 config DEBUG_DC21285_PORT
107 bool "Kernel low-level debugging messages via footbridge serial port"
108 depends on FOOTBRIDGE
109 help
110 Say Y here if you want the debug print routines to direct
111 their output to the serial port in the DC21285 (Footbridge).
112
113 config DEBUG_FOOTBRIDGE_COM1
114 bool "Kernel low-level debugging messages via footbridge 8250 at PCI COM1"
115 depends on FOOTBRIDGE
116 help
117 Say Y here if you want the debug print routines to direct
118 their output to the 8250 at PCI COM1.
119
139 config DEBUG_HIGHBANK_UART 120 config DEBUG_HIGHBANK_UART
140 bool "Kernel low-level debugging messages via Highbank UART" 121 bool "Kernel low-level debugging messages via Highbank UART"
141 depends on ARCH_HIGHBANK 122 depends on ARCH_HIGHBANK
@@ -199,45 +180,49 @@ choice
199 Say Y here if you want kernel low-level debugging support 180 Say Y here if you want kernel low-level debugging support
200 on i.MX50 or i.MX53. 181 on i.MX50 or i.MX53.
201 182
202 config DEBUG_IMX6Q_UART 183 config DEBUG_IMX6Q_UART4
203 bool "i.MX6Q Debug UART" 184 bool "i.MX6Q Debug UART4"
204 depends on SOC_IMX6Q 185 depends on SOC_IMX6Q
205 help 186 help
206 Say Y here if you want kernel low-level debugging support 187 Say Y here if you want kernel low-level debugging support
207 on i.MX6Q. 188 on i.MX6Q UART4.
208 189
209 config DEBUG_S3C_UART0 190 config DEBUG_MSM_UART1
210 depends on PLAT_SAMSUNG 191 bool "Kernel low-level debugging messages via MSM UART1"
211 bool "Use S3C UART 0 for low-level debug" 192 depends on ARCH_MSM7X00A || ARCH_MSM7X30 || ARCH_QSD8X50
212 help 193 help
213 Say Y here if you want the debug print routines to direct 194 Say Y here if you want the debug print routines to direct
214 their output to UART 0. The port must have been initialised 195 their output to the first serial port on MSM devices.
215 by the boot-loader before use.
216
217 The uncompressor code port configuration is now handled
218 by CONFIG_S3C_LOWLEVEL_UART_PORT.
219 196
220 config DEBUG_S3C_UART1 197 config DEBUG_MSM_UART2
221 depends on PLAT_SAMSUNG 198 bool "Kernel low-level debugging messages via MSM UART2"
222 bool "Use S3C UART 1 for low-level debug" 199 depends on ARCH_MSM7X00A || ARCH_MSM7X30 || ARCH_QSD8X50
223 help 200 help
224 Say Y here if you want the debug print routines to direct 201 Say Y here if you want the debug print routines to direct
225 their output to UART 1. The port must have been initialised 202 their output to the second serial port on MSM devices.
226 by the boot-loader before use.
227 203
228 The uncompressor code port configuration is now handled 204 config DEBUG_MSM_UART3
229 by CONFIG_S3C_LOWLEVEL_UART_PORT. 205 bool "Kernel low-level debugging messages via MSM UART3"
206 depends on ARCH_MSM7X00A || ARCH_MSM7X30 || ARCH_QSD8X50
207 help
208 Say Y here if you want the debug print routines to direct
209 their output to the third serial port on MSM devices.
230 210
231 config DEBUG_S3C_UART2 211 config DEBUG_MSM8660_UART
232 depends on PLAT_SAMSUNG 212 bool "Kernel low-level debugging messages via MSM 8660 UART"
233 bool "Use S3C UART 2 for low-level debug" 213 depends on ARCH_MSM8X60
214 select MSM_HAS_DEBUG_UART_HS
234 help 215 help
235 Say Y here if you want the debug print routines to direct 216 Say Y here if you want the debug print routines to direct
236 their output to UART 2. The port must have been initialised 217 their output to the serial port on MSM 8660 devices.
237 by the boot-loader before use.
238 218
239 The uncompressor code port configuration is now handled 219 config DEBUG_MSM8960_UART
240 by CONFIG_S3C_LOWLEVEL_UART_PORT. 220 bool "Kernel low-level debugging messages via MSM 8960 UART"
221 depends on ARCH_MSM8960
222 select MSM_HAS_DEBUG_UART_HS
223 help
224 Say Y here if you want the debug print routines to direct
225 their output to the serial port on MSM 8960 devices.
241 226
242 config DEBUG_REALVIEW_STD_PORT 227 config DEBUG_REALVIEW_STD_PORT
243 bool "RealView Default UART" 228 bool "RealView Default UART"
@@ -255,42 +240,57 @@ choice
255 their output to the standard serial port on the RealView 240 their output to the standard serial port on the RealView
256 PB1176 platform. 241 PB1176 platform.
257 242
258 config DEBUG_MSM_UART1 243 config DEBUG_S3C_UART0
259 bool "Kernel low-level debugging messages via MSM UART1" 244 depends on PLAT_SAMSUNG
260 depends on ARCH_MSM7X00A || ARCH_MSM7X30 || ARCH_QSD8X50 245 bool "Use S3C UART 0 for low-level debug"
261 help 246 help
262 Say Y here if you want the debug print routines to direct 247 Say Y here if you want the debug print routines to direct
263 their output to the first serial port on MSM devices. 248 their output to UART 0. The port must have been initialised
249 by the boot-loader before use.
264 250
265 config DEBUG_MSM_UART2 251 The uncompressor code port configuration is now handled
266 bool "Kernel low-level debugging messages via MSM UART2" 252 by CONFIG_S3C_LOWLEVEL_UART_PORT.
267 depends on ARCH_MSM7X00A || ARCH_MSM7X30 || ARCH_QSD8X50 253
254 config DEBUG_S3C_UART1
255 depends on PLAT_SAMSUNG
256 bool "Use S3C UART 1 for low-level debug"
268 help 257 help
269 Say Y here if you want the debug print routines to direct 258 Say Y here if you want the debug print routines to direct
270 their output to the second serial port on MSM devices. 259 their output to UART 1. The port must have been initialised
260 by the boot-loader before use.
271 261
272 config DEBUG_MSM_UART3 262 The uncompressor code port configuration is now handled
273 bool "Kernel low-level debugging messages via MSM UART3" 263 by CONFIG_S3C_LOWLEVEL_UART_PORT.
274 depends on ARCH_MSM7X00A || ARCH_MSM7X30 || ARCH_QSD8X50 264
265 config DEBUG_S3C_UART2
266 depends on PLAT_SAMSUNG
267 bool "Use S3C UART 2 for low-level debug"
275 help 268 help
276 Say Y here if you want the debug print routines to direct 269 Say Y here if you want the debug print routines to direct
277 their output to the third serial port on MSM devices. 270 their output to UART 2. The port must have been initialised
271 by the boot-loader before use.
278 272
279 config DEBUG_MSM8660_UART 273 The uncompressor code port configuration is now handled
280 bool "Kernel low-level debugging messages via MSM 8660 UART" 274 by CONFIG_S3C_LOWLEVEL_UART_PORT.
281 depends on ARCH_MSM8X60 275
282 select MSM_HAS_DEBUG_UART_HS 276 config DEBUG_LL_UART_NONE
277 bool "No low-level debugging UART"
283 help 278 help
284 Say Y here if you want the debug print routines to direct 279 Say Y here if your platform doesn't provide a UART option
285 their output to the serial port on MSM 8660 devices. 280 below. This relies on your platform choosing the right UART
281 definition internally in order for low-level debugging to
282 work.
286 283
287 config DEBUG_MSM8960_UART 284 config DEBUG_ICEDCC
288 bool "Kernel low-level debugging messages via MSM 8960 UART" 285 bool "Kernel low-level debugging via EmbeddedICE DCC channel"
289 depends on ARCH_MSM8960
290 select MSM_HAS_DEBUG_UART_HS
291 help 286 help
292 Say Y here if you want the debug print routines to direct 287 Say Y here if you want the debug print routines to direct
293 their output to the serial port on MSM 8960 devices. 288 their output to the EmbeddedICE macrocell's DCC channel using
289 co-processor 14. This is known to work on the ARM9 style ICE
290 channel and on the XScale with the PEEDI.
291
292 Note that the system will appear to hang during boot if there
293 is nothing connected to read from the DCC.
294 294
295endchoice 295endchoice
296 296
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 1683bfb9166..dcb088e868f 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -174,12 +174,13 @@ machine-$(CONFIG_ARCH_PRIMA2) := prima2
174machine-$(CONFIG_ARCH_PXA) := pxa 174machine-$(CONFIG_ARCH_PXA) := pxa
175machine-$(CONFIG_ARCH_REALVIEW) := realview 175machine-$(CONFIG_ARCH_REALVIEW) := realview
176machine-$(CONFIG_ARCH_RPC) := rpc 176machine-$(CONFIG_ARCH_RPC) := rpc
177machine-$(CONFIG_ARCH_S3C2410) := s3c2410 s3c2412 s3c2416 s3c2440 s3c2443 177machine-$(CONFIG_ARCH_S3C24XX) := s3c24xx s3c2412 s3c2440
178machine-$(CONFIG_ARCH_S3C64XX) := s3c64xx 178machine-$(CONFIG_ARCH_S3C64XX) := s3c64xx
179machine-$(CONFIG_ARCH_S5P64X0) := s5p64x0 179machine-$(CONFIG_ARCH_S5P64X0) := s5p64x0
180machine-$(CONFIG_ARCH_S5PC100) := s5pc100 180machine-$(CONFIG_ARCH_S5PC100) := s5pc100
181machine-$(CONFIG_ARCH_S5PV210) := s5pv210 181machine-$(CONFIG_ARCH_S5PV210) := s5pv210
182machine-$(CONFIG_ARCH_EXYNOS4) := exynos 182machine-$(CONFIG_ARCH_EXYNOS4) := exynos
183machine-$(CONFIG_ARCH_EXYNOS5) := exynos
183machine-$(CONFIG_ARCH_SA1100) := sa1100 184machine-$(CONFIG_ARCH_SA1100) := sa1100
184machine-$(CONFIG_ARCH_SHARK) := shark 185machine-$(CONFIG_ARCH_SHARK) := shark
185machine-$(CONFIG_ARCH_SHMOBILE) := shmobile 186machine-$(CONFIG_ARCH_SHMOBILE) := shmobile
diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index c5d60250d43..5f6045f1766 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -58,7 +58,7 @@
58 add \rb, \rb, #0x00010000 @ Ser1 58 add \rb, \rb, #0x00010000 @ Ser1
59#endif 59#endif
60 .endm 60 .endm
61#elif defined(CONFIG_ARCH_S3C2410) 61#elif defined(CONFIG_ARCH_S3C24XX)
62 .macro loadsp, rb, tmp 62 .macro loadsp, rb, tmp
63 mov \rb, #0x50000000 63 mov \rb, #0x50000000
64 add \rb, \rb, #0x4000 * CONFIG_S3C_LOWLEVEL_UART_PORT 64 add \rb, \rb, #0x4000 * CONFIG_S3C_LOWLEVEL_UART_PORT
diff --git a/arch/arm/boot/dts/am3517_mt_ventoux.dts b/arch/arm/boot/dts/am3517_mt_ventoux.dts
new file mode 100644
index 00000000000..5eb26d7d9b4
--- /dev/null
+++ b/arch/arm/boot/dts/am3517_mt_ventoux.dts
@@ -0,0 +1,27 @@
1/*
2 * Copyright (C) 2011 Ilya Yanok, EmCraft Systems
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 = "TeeJet Mt.Ventoux";
14 compatible = "teejet,mt_ventoux", "ti,omap3";
15
16 memory {
17 device_type = "memory";
18 reg = <0x80000000 0x10000000>; /* 256 MB */
19 };
20
21 /* AM35xx doesn't have IVA */
22 soc {
23 iva {
24 status = "disabled";
25 };
26 };
27};
diff --git a/arch/arm/boot/dts/at91sam9g20.dtsi b/arch/arm/boot/dts/at91sam9g20.dtsi
index 07603b8c950..92f36627e7f 100644
--- a/arch/arm/boot/dts/at91sam9g20.dtsi
+++ b/arch/arm/boot/dts/at91sam9g20.dtsi
@@ -23,6 +23,11 @@
23 serial4 = &usart3; 23 serial4 = &usart3;
24 serial5 = &usart4; 24 serial5 = &usart4;
25 serial6 = &usart5; 25 serial6 = &usart5;
26 gpio0 = &pioA;
27 gpio1 = &pioB;
28 gpio2 = &pioC;
29 tcb0 = &tcb0;
30 tcb1 = &tcb1;
26 }; 31 };
27 cpus { 32 cpus {
28 cpu@0 { 33 cpu@0 {
@@ -47,24 +52,89 @@
47 ranges; 52 ranges;
48 53
49 aic: interrupt-controller@fffff000 { 54 aic: interrupt-controller@fffff000 {
50 #interrupt-cells = <1>; 55 #interrupt-cells = <2>;
51 compatible = "atmel,at91rm9200-aic"; 56 compatible = "atmel,at91rm9200-aic";
52 interrupt-controller; 57 interrupt-controller;
53 interrupt-parent; 58 interrupt-parent;
54 reg = <0xfffff000 0x200>; 59 reg = <0xfffff000 0x200>;
55 }; 60 };
56 61
62 ramc0: ramc@ffffea00 {
63 compatible = "atmel,at91sam9260-sdramc";
64 reg = <0xffffea00 0x200>;
65 };
66
67 pmc: pmc@fffffc00 {
68 compatible = "atmel,at91rm9200-pmc";
69 reg = <0xfffffc00 0x100>;
70 };
71
72 rstc@fffffd00 {
73 compatible = "atmel,at91sam9260-rstc";
74 reg = <0xfffffd00 0x10>;
75 };
76
77 shdwc@fffffd10 {
78 compatible = "atmel,at91sam9260-shdwc";
79 reg = <0xfffffd10 0x10>;
80 };
81
82 pit: timer@fffffd30 {
83 compatible = "atmel,at91sam9260-pit";
84 reg = <0xfffffd30 0xf>;
85 interrupts = <1 4>;
86 };
87
88 tcb0: timer@fffa0000 {
89 compatible = "atmel,at91rm9200-tcb";
90 reg = <0xfffa0000 0x100>;
91 interrupts = <17 4 18 4 19 4>;
92 };
93
94 tcb1: timer@fffdc000 {
95 compatible = "atmel,at91rm9200-tcb";
96 reg = <0xfffdc000 0x100>;
97 interrupts = <26 4 27 4 28 4>;
98 };
99
100 pioA: gpio@fffff400 {
101 compatible = "atmel,at91rm9200-gpio";
102 reg = <0xfffff400 0x100>;
103 interrupts = <2 4>;
104 #gpio-cells = <2>;
105 gpio-controller;
106 interrupt-controller;
107 };
108
109 pioB: gpio@fffff600 {
110 compatible = "atmel,at91rm9200-gpio";
111 reg = <0xfffff600 0x100>;
112 interrupts = <3 4>;
113 #gpio-cells = <2>;
114 gpio-controller;
115 interrupt-controller;
116 };
117
118 pioC: gpio@fffff800 {
119 compatible = "atmel,at91rm9200-gpio";
120 reg = <0xfffff800 0x100>;
121 interrupts = <4 4>;
122 #gpio-cells = <2>;
123 gpio-controller;
124 interrupt-controller;
125 };
126
57 dbgu: serial@fffff200 { 127 dbgu: serial@fffff200 {
58 compatible = "atmel,at91sam9260-usart"; 128 compatible = "atmel,at91sam9260-usart";
59 reg = <0xfffff200 0x200>; 129 reg = <0xfffff200 0x200>;
60 interrupts = <1>; 130 interrupts = <1 4>;
61 status = "disabled"; 131 status = "disabled";
62 }; 132 };
63 133
64 usart0: serial@fffb0000 { 134 usart0: serial@fffb0000 {
65 compatible = "atmel,at91sam9260-usart"; 135 compatible = "atmel,at91sam9260-usart";
66 reg = <0xfffb0000 0x200>; 136 reg = <0xfffb0000 0x200>;
67 interrupts = <6>; 137 interrupts = <6 4>;
68 atmel,use-dma-rx; 138 atmel,use-dma-rx;
69 atmel,use-dma-tx; 139 atmel,use-dma-tx;
70 status = "disabled"; 140 status = "disabled";
@@ -73,7 +143,7 @@
73 usart1: serial@fffb4000 { 143 usart1: serial@fffb4000 {
74 compatible = "atmel,at91sam9260-usart"; 144 compatible = "atmel,at91sam9260-usart";
75 reg = <0xfffb4000 0x200>; 145 reg = <0xfffb4000 0x200>;
76 interrupts = <7>; 146 interrupts = <7 4>;
77 atmel,use-dma-rx; 147 atmel,use-dma-rx;
78 atmel,use-dma-tx; 148 atmel,use-dma-tx;
79 status = "disabled"; 149 status = "disabled";
@@ -82,7 +152,7 @@
82 usart2: serial@fffb8000 { 152 usart2: serial@fffb8000 {
83 compatible = "atmel,at91sam9260-usart"; 153 compatible = "atmel,at91sam9260-usart";
84 reg = <0xfffb8000 0x200>; 154 reg = <0xfffb8000 0x200>;
85 interrupts = <8>; 155 interrupts = <8 4>;
86 atmel,use-dma-rx; 156 atmel,use-dma-rx;
87 atmel,use-dma-tx; 157 atmel,use-dma-tx;
88 status = "disabled"; 158 status = "disabled";
@@ -91,7 +161,7 @@
91 usart3: serial@fffd0000 { 161 usart3: serial@fffd0000 {
92 compatible = "atmel,at91sam9260-usart"; 162 compatible = "atmel,at91sam9260-usart";
93 reg = <0xfffd0000 0x200>; 163 reg = <0xfffd0000 0x200>;
94 interrupts = <23>; 164 interrupts = <23 4>;
95 atmel,use-dma-rx; 165 atmel,use-dma-rx;
96 atmel,use-dma-tx; 166 atmel,use-dma-tx;
97 status = "disabled"; 167 status = "disabled";
@@ -100,7 +170,7 @@
100 usart4: serial@fffd4000 { 170 usart4: serial@fffd4000 {
101 compatible = "atmel,at91sam9260-usart"; 171 compatible = "atmel,at91sam9260-usart";
102 reg = <0xfffd4000 0x200>; 172 reg = <0xfffd4000 0x200>;
103 interrupts = <24>; 173 interrupts = <24 4>;
104 atmel,use-dma-rx; 174 atmel,use-dma-rx;
105 atmel,use-dma-tx; 175 atmel,use-dma-tx;
106 status = "disabled"; 176 status = "disabled";
@@ -109,7 +179,7 @@
109 usart5: serial@fffd8000 { 179 usart5: serial@fffd8000 {
110 compatible = "atmel,at91sam9260-usart"; 180 compatible = "atmel,at91sam9260-usart";
111 reg = <0xfffd8000 0x200>; 181 reg = <0xfffd8000 0x200>;
112 interrupts = <25>; 182 interrupts = <25 4>;
113 atmel,use-dma-rx; 183 atmel,use-dma-rx;
114 atmel,use-dma-tx; 184 atmel,use-dma-tx;
115 status = "disabled"; 185 status = "disabled";
@@ -118,9 +188,52 @@
118 macb0: ethernet@fffc4000 { 188 macb0: ethernet@fffc4000 {
119 compatible = "cdns,at32ap7000-macb", "cdns,macb"; 189 compatible = "cdns,at32ap7000-macb", "cdns,macb";
120 reg = <0xfffc4000 0x100>; 190 reg = <0xfffc4000 0x100>;
121 interrupts = <21>; 191 interrupts = <21 4>;
192 status = "disabled";
193 };
194
195 usb1: gadget@fffa4000 {
196 compatible = "atmel,at91rm9200-udc";
197 reg = <0xfffa4000 0x4000>;
198 interrupts = <10 4>;
122 status = "disabled"; 199 status = "disabled";
123 }; 200 };
124 }; 201 };
202
203 nand0: nand@40000000 {
204 compatible = "atmel,at91rm9200-nand";
205 #address-cells = <1>;
206 #size-cells = <1>;
207 reg = <0x40000000 0x10000000
208 0xffffe800 0x200
209 >;
210 atmel,nand-addr-offset = <21>;
211 atmel,nand-cmd-offset = <22>;
212 gpios = <&pioC 13 0
213 &pioC 14 0
214 0
215 >;
216 status = "disabled";
217 };
218
219 usb0: ohci@00500000 {
220 compatible = "atmel,at91rm9200-ohci", "usb-ohci";
221 reg = <0x00500000 0x100000>;
222 interrupts = <20 4>;
223 status = "disabled";
224 };
225 };
226
227 i2c@0 {
228 compatible = "i2c-gpio";
229 gpios = <&pioA 23 0 /* sda */
230 &pioA 24 0 /* scl */
231 >;
232 i2c-gpio,sda-open-drain;
233 i2c-gpio,scl-open-drain;
234 i2c-gpio,delay-us = <2>; /* ~100 kHz */
235 #address-cells = <1>;
236 #size-cells = <0>;
237 status = "disabled";
125 }; 238 };
126}; 239};
diff --git a/arch/arm/boot/dts/at91sam9g25ek.dts b/arch/arm/boot/dts/at91sam9g25ek.dts
new file mode 100644
index 00000000000..ac0dc0031dd
--- /dev/null
+++ b/arch/arm/boot/dts/at91sam9g25ek.dts
@@ -0,0 +1,49 @@
1/*
2 * at91sam9g25ek.dts - Device Tree file for AT91SAM9G25-EK board
3 *
4 * Copyright (C) 2012 Atmel,
5 * 2012 Nicolas Ferre <nicolas.ferre@atmel.com>
6 *
7 * Licensed under GPLv2 or later.
8 */
9/dts-v1/;
10/include/ "at91sam9x5.dtsi"
11/include/ "at91sam9x5cm.dtsi"
12
13/ {
14 model = "Atmel AT91SAM9G25-EK";
15 compatible = "atmel,at91sam9g25ek", "atmel,at91sam9x5ek", "atmel,at91sam9x5", "atmel,at91sam9";
16
17 chosen {
18 bootargs = "128M console=ttyS0,115200 root=/dev/mtdblock1 rw rootfstype=ubifs ubi.mtd=1 root=ubi0:rootfs";
19 };
20
21 ahb {
22 apb {
23 dbgu: serial@fffff200 {
24 status = "okay";
25 };
26
27 usart0: serial@f801c000 {
28 status = "okay";
29 };
30
31 macb0: ethernet@f802c000 {
32 phy-mode = "rmii";
33 status = "okay";
34 };
35 };
36
37 usb0: ohci@00600000 {
38 status = "okay";
39 num-ports = <2>;
40 atmel,vbus-gpio = <&pioD 19 0
41 &pioD 20 0
42 >;
43 };
44
45 usb1: ehci@00700000 {
46 status = "okay";
47 };
48 };
49};
diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi
index fffa005300a..3d0c32fb218 100644
--- a/arch/arm/boot/dts/at91sam9g45.dtsi
+++ b/arch/arm/boot/dts/at91sam9g45.dtsi
@@ -22,6 +22,13 @@
22 serial2 = &usart1; 22 serial2 = &usart1;
23 serial3 = &usart2; 23 serial3 = &usart2;
24 serial4 = &usart3; 24 serial4 = &usart3;
25 gpio0 = &pioA;
26 gpio1 = &pioB;
27 gpio2 = &pioC;
28 gpio3 = &pioD;
29 gpio4 = &pioE;
30 tcb0 = &tcb0;
31 tcb1 = &tcb1;
25 }; 32 };
26 cpus { 33 cpus {
27 cpu@0 { 34 cpu@0 {
@@ -46,30 +53,115 @@
46 ranges; 53 ranges;
47 54
48 aic: interrupt-controller@fffff000 { 55 aic: interrupt-controller@fffff000 {
49 #interrupt-cells = <1>; 56 #interrupt-cells = <2>;
50 compatible = "atmel,at91rm9200-aic"; 57 compatible = "atmel,at91rm9200-aic";
51 interrupt-controller; 58 interrupt-controller;
52 interrupt-parent; 59 interrupt-parent;
53 reg = <0xfffff000 0x200>; 60 reg = <0xfffff000 0x200>;
54 }; 61 };
55 62
63 ramc0: ramc@ffffe400 {
64 compatible = "atmel,at91sam9g45-ddramc";
65 reg = <0xffffe400 0x200
66 0xffffe600 0x200>;
67 };
68
69 pmc: pmc@fffffc00 {
70 compatible = "atmel,at91rm9200-pmc";
71 reg = <0xfffffc00 0x100>;
72 };
73
74 rstc@fffffd00 {
75 compatible = "atmel,at91sam9g45-rstc";
76 reg = <0xfffffd00 0x10>;
77 };
78
79 pit: timer@fffffd30 {
80 compatible = "atmel,at91sam9260-pit";
81 reg = <0xfffffd30 0xf>;
82 interrupts = <1 4>;
83 };
84
85
86 shdwc@fffffd10 {
87 compatible = "atmel,at91sam9rl-shdwc";
88 reg = <0xfffffd10 0x10>;
89 };
90
91 tcb0: timer@fff7c000 {
92 compatible = "atmel,at91rm9200-tcb";
93 reg = <0xfff7c000 0x100>;
94 interrupts = <18 4>;
95 };
96
97 tcb1: timer@fffd4000 {
98 compatible = "atmel,at91rm9200-tcb";
99 reg = <0xfffd4000 0x100>;
100 interrupts = <18 4>;
101 };
102
56 dma: dma-controller@ffffec00 { 103 dma: dma-controller@ffffec00 {
57 compatible = "atmel,at91sam9g45-dma"; 104 compatible = "atmel,at91sam9g45-dma";
58 reg = <0xffffec00 0x200>; 105 reg = <0xffffec00 0x200>;
59 interrupts = <21>; 106 interrupts = <21 4>;
107 };
108
109 pioA: gpio@fffff200 {
110 compatible = "atmel,at91rm9200-gpio";
111 reg = <0xfffff200 0x100>;
112 interrupts = <2 4>;
113 #gpio-cells = <2>;
114 gpio-controller;
115 interrupt-controller;
116 };
117
118 pioB: gpio@fffff400 {
119 compatible = "atmel,at91rm9200-gpio";
120 reg = <0xfffff400 0x100>;
121 interrupts = <3 4>;
122 #gpio-cells = <2>;
123 gpio-controller;
124 interrupt-controller;
125 };
126
127 pioC: gpio@fffff600 {
128 compatible = "atmel,at91rm9200-gpio";
129 reg = <0xfffff600 0x100>;
130 interrupts = <4 4>;
131 #gpio-cells = <2>;
132 gpio-controller;
133 interrupt-controller;
134 };
135
136 pioD: gpio@fffff800 {
137 compatible = "atmel,at91rm9200-gpio";
138 reg = <0xfffff800 0x100>;
139 interrupts = <5 4>;
140 #gpio-cells = <2>;
141 gpio-controller;
142 interrupt-controller;
143 };
144
145 pioE: gpio@fffffa00 {
146 compatible = "atmel,at91rm9200-gpio";
147 reg = <0xfffffa00 0x100>;
148 interrupts = <5 4>;
149 #gpio-cells = <2>;
150 gpio-controller;
151 interrupt-controller;
60 }; 152 };
61 153
62 dbgu: serial@ffffee00 { 154 dbgu: serial@ffffee00 {
63 compatible = "atmel,at91sam9260-usart"; 155 compatible = "atmel,at91sam9260-usart";
64 reg = <0xffffee00 0x200>; 156 reg = <0xffffee00 0x200>;
65 interrupts = <1>; 157 interrupts = <1 4>;
66 status = "disabled"; 158 status = "disabled";
67 }; 159 };
68 160
69 usart0: serial@fff8c000 { 161 usart0: serial@fff8c000 {
70 compatible = "atmel,at91sam9260-usart"; 162 compatible = "atmel,at91sam9260-usart";
71 reg = <0xfff8c000 0x200>; 163 reg = <0xfff8c000 0x200>;
72 interrupts = <7>; 164 interrupts = <7 4>;
73 atmel,use-dma-rx; 165 atmel,use-dma-rx;
74 atmel,use-dma-tx; 166 atmel,use-dma-tx;
75 status = "disabled"; 167 status = "disabled";
@@ -78,7 +170,7 @@
78 usart1: serial@fff90000 { 170 usart1: serial@fff90000 {
79 compatible = "atmel,at91sam9260-usart"; 171 compatible = "atmel,at91sam9260-usart";
80 reg = <0xfff90000 0x200>; 172 reg = <0xfff90000 0x200>;
81 interrupts = <8>; 173 interrupts = <8 4>;
82 atmel,use-dma-rx; 174 atmel,use-dma-rx;
83 atmel,use-dma-tx; 175 atmel,use-dma-tx;
84 status = "disabled"; 176 status = "disabled";
@@ -87,7 +179,7 @@
87 usart2: serial@fff94000 { 179 usart2: serial@fff94000 {
88 compatible = "atmel,at91sam9260-usart"; 180 compatible = "atmel,at91sam9260-usart";
89 reg = <0xfff94000 0x200>; 181 reg = <0xfff94000 0x200>;
90 interrupts = <9>; 182 interrupts = <9 4>;
91 atmel,use-dma-rx; 183 atmel,use-dma-rx;
92 atmel,use-dma-tx; 184 atmel,use-dma-tx;
93 status = "disabled"; 185 status = "disabled";
@@ -96,7 +188,7 @@
96 usart3: serial@fff98000 { 188 usart3: serial@fff98000 {
97 compatible = "atmel,at91sam9260-usart"; 189 compatible = "atmel,at91sam9260-usart";
98 reg = <0xfff98000 0x200>; 190 reg = <0xfff98000 0x200>;
99 interrupts = <10>; 191 interrupts = <10 4>;
100 atmel,use-dma-rx; 192 atmel,use-dma-rx;
101 atmel,use-dma-tx; 193 atmel,use-dma-tx;
102 status = "disabled"; 194 status = "disabled";
@@ -105,9 +197,52 @@
105 macb0: ethernet@fffbc000 { 197 macb0: ethernet@fffbc000 {
106 compatible = "cdns,at32ap7000-macb", "cdns,macb"; 198 compatible = "cdns,at32ap7000-macb", "cdns,macb";
107 reg = <0xfffbc000 0x100>; 199 reg = <0xfffbc000 0x100>;
108 interrupts = <25>; 200 interrupts = <25 4>;
109 status = "disabled"; 201 status = "disabled";
110 }; 202 };
111 }; 203 };
204
205 nand0: nand@40000000 {
206 compatible = "atmel,at91rm9200-nand";
207 #address-cells = <1>;
208 #size-cells = <1>;
209 reg = <0x40000000 0x10000000
210 0xffffe200 0x200
211 >;
212 atmel,nand-addr-offset = <21>;
213 atmel,nand-cmd-offset = <22>;
214 gpios = <&pioC 8 0
215 &pioC 14 0
216 0
217 >;
218 status = "disabled";
219 };
220
221 usb0: ohci@00700000 {
222 compatible = "atmel,at91rm9200-ohci", "usb-ohci";
223 reg = <0x00700000 0x100000>;
224 interrupts = <22 4>;
225 status = "disabled";
226 };
227
228 usb1: ehci@00800000 {
229 compatible = "atmel,at91sam9g45-ehci", "usb-ehci";
230 reg = <0x00800000 0x100000>;
231 interrupts = <22 4>;
232 status = "disabled";
233 };
234 };
235
236 i2c@0 {
237 compatible = "i2c-gpio";
238 gpios = <&pioA 20 0 /* sda */
239 &pioA 21 0 /* scl */
240 >;
241 i2c-gpio,sda-open-drain;
242 i2c-gpio,scl-open-drain;
243 i2c-gpio,delay-us = <5>; /* ~100 kHz */
244 #address-cells = <1>;
245 #size-cells = <0>;
246 status = "disabled";
112 }; 247 };
113}; 248};
diff --git a/arch/arm/boot/dts/at91sam9m10g45ek.dts b/arch/arm/boot/dts/at91sam9m10g45ek.dts
index a387e7704ce..c4c8ae4123d 100644
--- a/arch/arm/boot/dts/at91sam9m10g45ek.dts
+++ b/arch/arm/boot/dts/at91sam9m10g45ek.dts
@@ -14,13 +14,24 @@
14 compatible = "atmel,at91sam9m10g45ek", "atmel,at91sam9g45", "atmel,at91sam9"; 14 compatible = "atmel,at91sam9m10g45ek", "atmel,at91sam9g45", "atmel,at91sam9";
15 15
16 chosen { 16 chosen {
17 bootargs = "mem=64M console=ttyS0,115200 mtdparts=atmel_nand:4M(bootstrap/uboot/kernel)ro,60M(rootfs),-(data) root=/dev/mtdblock1 rw rootfstype=jffs2"; 17 bootargs = "mem=64M console=ttyS0,115200 root=/dev/mtdblock1 rw rootfstype=jffs2";
18 }; 18 };
19 19
20 memory@70000000 { 20 memory@70000000 {
21 reg = <0x70000000 0x4000000>; 21 reg = <0x70000000 0x4000000>;
22 }; 22 };
23 23
24 clocks {
25 #address-cells = <1>;
26 #size-cells = <1>;
27 ranges;
28
29 main_clock: clock@0 {
30 compatible = "atmel,osc", "fixed-clock";
31 clock-frequency = <12000000>;
32 };
33 };
34
24 ahb { 35 ahb {
25 apb { 36 apb {
26 dbgu: serial@ffffee00 { 37 dbgu: serial@ffffee00 {
@@ -36,5 +47,110 @@
36 status = "okay"; 47 status = "okay";
37 }; 48 };
38 }; 49 };
50
51 nand0: nand@40000000 {
52 nand-bus-width = <8>;
53 nand-ecc-mode = "soft";
54 nand-on-flash-bbt;
55 status = "okay";
56
57 boot@0 {
58 label = "bootstrap/uboot/kernel";
59 reg = <0x0 0x400000>;
60 };
61
62 rootfs@400000 {
63 label = "rootfs";
64 reg = <0x400000 0x3C00000>;
65 };
66
67 data@4000000 {
68 label = "data";
69 reg = <0x4000000 0xC000000>;
70 };
71 };
72
73 usb0: ohci@00700000 {
74 status = "okay";
75 num-ports = <2>;
76 atmel,vbus-gpio = <&pioD 1 0
77 &pioD 3 0>;
78 };
79
80 usb1: ehci@00800000 {
81 status = "okay";
82 };
83 };
84
85 leds {
86 compatible = "gpio-leds";
87
88 d8 {
89 label = "d8";
90 gpios = <&pioD 30 0>;
91 linux,default-trigger = "heartbeat";
92 };
93
94 d6 {
95 label = "d6";
96 gpios = <&pioD 0 1>;
97 linux,default-trigger = "nand-disk";
98 };
99
100 d7 {
101 label = "d7";
102 gpios = <&pioD 31 1>;
103 linux,default-trigger = "mmc0";
104 };
105 };
106
107 gpio_keys {
108 compatible = "gpio-keys";
109 #address-cells = <1>;
110 #size-cells = <0>;
111
112 left_click {
113 label = "left_click";
114 gpios = <&pioB 6 1>;
115 linux,code = <272>;
116 gpio-key,wakeup;
117 };
118
119 right_click {
120 label = "right_click";
121 gpios = <&pioB 7 1>;
122 linux,code = <273>;
123 gpio-key,wakeup;
124 };
125
126 left {
127 label = "Joystick Left";
128 gpios = <&pioB 14 1>;
129 linux,code = <105>;
130 };
131
132 right {
133 label = "Joystick Right";
134 gpios = <&pioB 15 1>;
135 linux,code = <106>;
136 };
137
138 up {
139 label = "Joystick Up";
140 gpios = <&pioB 16 1>;
141 linux,code = <103>;
142 };
143
144 down {
145 label = "Joystick Down";
146 gpios = <&pioB 17 1>;
147 linux,code = <108>;
148 };
149
150 enter {
151 label = "Joystick Press";
152 gpios = <&pioB 18 1>;
153 linux,code = <28>;
154 };
39 }; 155 };
40}; 156};
diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi
new file mode 100644
index 00000000000..c111001f254
--- /dev/null
+++ b/arch/arm/boot/dts/at91sam9x5.dtsi
@@ -0,0 +1,264 @@
1/*
2 * at91sam9x5.dtsi - Device Tree Include file for AT91SAM9x5 family SoC
3 * applies to AT91SAM9G15, AT91SAM9G25, AT91SAM9G35,
4 * AT91SAM9X25, AT91SAM9X35 SoC
5 *
6 * Copyright (C) 2012 Atmel,
7 * 2012 Nicolas Ferre <nicolas.ferre@atmel.com>
8 *
9 * Licensed under GPLv2 or later.
10 */
11
12/include/ "skeleton.dtsi"
13
14/ {
15 model = "Atmel AT91SAM9x5 family SoC";
16 compatible = "atmel,at91sam9x5";
17 interrupt-parent = <&aic>;
18
19 aliases {
20 serial0 = &dbgu;
21 serial1 = &usart0;
22 serial2 = &usart1;
23 serial3 = &usart2;
24 gpio0 = &pioA;
25 gpio1 = &pioB;
26 gpio2 = &pioC;
27 gpio3 = &pioD;
28 tcb0 = &tcb0;
29 tcb1 = &tcb1;
30 };
31 cpus {
32 cpu@0 {
33 compatible = "arm,arm926ejs";
34 };
35 };
36
37 memory@20000000 {
38 reg = <0x20000000 0x10000000>;
39 };
40
41 ahb {
42 compatible = "simple-bus";
43 #address-cells = <1>;
44 #size-cells = <1>;
45 ranges;
46
47 apb {
48 compatible = "simple-bus";
49 #address-cells = <1>;
50 #size-cells = <1>;
51 ranges;
52
53 aic: interrupt-controller@fffff000 {
54 #interrupt-cells = <2>;
55 compatible = "atmel,at91rm9200-aic";
56 interrupt-controller;
57 interrupt-parent;
58 reg = <0xfffff000 0x200>;
59 };
60
61 ramc0: ramc@ffffe800 {
62 compatible = "atmel,at91sam9g45-ddramc";
63 reg = <0xffffe800 0x200>;
64 };
65
66 pmc: pmc@fffffc00 {
67 compatible = "atmel,at91rm9200-pmc";
68 reg = <0xfffffc00 0x100>;
69 };
70
71 rstc@fffffe00 {
72 compatible = "atmel,at91sam9g45-rstc";
73 reg = <0xfffffe00 0x10>;
74 };
75
76 shdwc@fffffe10 {
77 compatible = "atmel,at91sam9x5-shdwc";
78 reg = <0xfffffe10 0x10>;
79 };
80
81 pit: timer@fffffe30 {
82 compatible = "atmel,at91sam9260-pit";
83 reg = <0xfffffe30 0xf>;
84 interrupts = <1 4>;
85 };
86
87 tcb0: timer@f8008000 {
88 compatible = "atmel,at91sam9x5-tcb";
89 reg = <0xf8008000 0x100>;
90 interrupts = <17 4>;
91 };
92
93 tcb1: timer@f800c000 {
94 compatible = "atmel,at91sam9x5-tcb";
95 reg = <0xf800c000 0x100>;
96 interrupts = <17 4>;
97 };
98
99 dma0: dma-controller@ffffec00 {
100 compatible = "atmel,at91sam9g45-dma";
101 reg = <0xffffec00 0x200>;
102 interrupts = <20 4>;
103 };
104
105 dma1: dma-controller@ffffee00 {
106 compatible = "atmel,at91sam9g45-dma";
107 reg = <0xffffee00 0x200>;
108 interrupts = <21 4>;
109 };
110
111 pioA: gpio@fffff400 {
112 compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio";
113 reg = <0xfffff400 0x100>;
114 interrupts = <2 4>;
115 #gpio-cells = <2>;
116 gpio-controller;
117 interrupt-controller;
118 };
119
120 pioB: gpio@fffff600 {
121 compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio";
122 reg = <0xfffff600 0x100>;
123 interrupts = <2 4>;
124 #gpio-cells = <2>;
125 gpio-controller;
126 interrupt-controller;
127 };
128
129 pioC: gpio@fffff800 {
130 compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio";
131 reg = <0xfffff800 0x100>;
132 interrupts = <3 4>;
133 #gpio-cells = <2>;
134 gpio-controller;
135 interrupt-controller;
136 };
137
138 pioD: gpio@fffffa00 {
139 compatible = "atmel,at91sam9x5-gpio", "atmel,at91rm9200-gpio";
140 reg = <0xfffffa00 0x100>;
141 interrupts = <3 4>;
142 #gpio-cells = <2>;
143 gpio-controller;
144 interrupt-controller;
145 };
146
147 dbgu: serial@fffff200 {
148 compatible = "atmel,at91sam9260-usart";
149 reg = <0xfffff200 0x200>;
150 interrupts = <1 4>;
151 status = "disabled";
152 };
153
154 usart0: serial@f801c000 {
155 compatible = "atmel,at91sam9260-usart";
156 reg = <0xf801c000 0x200>;
157 interrupts = <5 4>;
158 atmel,use-dma-rx;
159 atmel,use-dma-tx;
160 status = "disabled";
161 };
162
163 usart1: serial@f8020000 {
164 compatible = "atmel,at91sam9260-usart";
165 reg = <0xf8020000 0x200>;
166 interrupts = <6 4>;
167 atmel,use-dma-rx;
168 atmel,use-dma-tx;
169 status = "disabled";
170 };
171
172 usart2: serial@f8024000 {
173 compatible = "atmel,at91sam9260-usart";
174 reg = <0xf8024000 0x200>;
175 interrupts = <7 4>;
176 atmel,use-dma-rx;
177 atmel,use-dma-tx;
178 status = "disabled";
179 };
180
181 macb0: ethernet@f802c000 {
182 compatible = "cdns,at32ap7000-macb", "cdns,macb";
183 reg = <0xf802c000 0x100>;
184 interrupts = <24 4>;
185 status = "disabled";
186 };
187
188 macb1: ethernet@f8030000 {
189 compatible = "cdns,at32ap7000-macb", "cdns,macb";
190 reg = <0xf8030000 0x100>;
191 interrupts = <27 4>;
192 status = "disabled";
193 };
194 };
195
196 nand0: nand@40000000 {
197 compatible = "atmel,at91rm9200-nand";
198 #address-cells = <1>;
199 #size-cells = <1>;
200 reg = <0x40000000 0x10000000
201 >;
202 atmel,nand-addr-offset = <21>;
203 atmel,nand-cmd-offset = <22>;
204 gpios = <&pioC 8 0
205 &pioC 14 0
206 0
207 >;
208 status = "disabled";
209 };
210
211 usb0: ohci@00600000 {
212 compatible = "atmel,at91rm9200-ohci", "usb-ohci";
213 reg = <0x00600000 0x100000>;
214 interrupts = <22 4>;
215 status = "disabled";
216 };
217
218 usb1: ehci@00700000 {
219 compatible = "atmel,at91sam9g45-ehci", "usb-ehci";
220 reg = <0x00700000 0x100000>;
221 interrupts = <22 4>;
222 status = "disabled";
223 };
224 };
225
226 i2c@0 {
227 compatible = "i2c-gpio";
228 gpios = <&pioA 30 0 /* sda */
229 &pioA 31 0 /* scl */
230 >;
231 i2c-gpio,sda-open-drain;
232 i2c-gpio,scl-open-drain;
233 i2c-gpio,delay-us = <2>; /* ~100 kHz */
234 #address-cells = <1>;
235 #size-cells = <0>;
236 status = "disabled";
237 };
238
239 i2c@1 {
240 compatible = "i2c-gpio";
241 gpios = <&pioC 0 0 /* sda */
242 &pioC 1 0 /* scl */
243 >;
244 i2c-gpio,sda-open-drain;
245 i2c-gpio,scl-open-drain;
246 i2c-gpio,delay-us = <2>; /* ~100 kHz */
247 #address-cells = <1>;
248 #size-cells = <0>;
249 status = "disabled";
250 };
251
252 i2c@2 {
253 compatible = "i2c-gpio";
254 gpios = <&pioB 4 0 /* sda */
255 &pioB 5 0 /* scl */
256 >;
257 i2c-gpio,sda-open-drain;
258 i2c-gpio,scl-open-drain;
259 i2c-gpio,delay-us = <2>; /* ~100 kHz */
260 #address-cells = <1>;
261 #size-cells = <0>;
262 status = "disabled";
263 };
264};
diff --git a/arch/arm/boot/dts/at91sam9x5cm.dtsi b/arch/arm/boot/dts/at91sam9x5cm.dtsi
new file mode 100644
index 00000000000..67936f83c69
--- /dev/null
+++ b/arch/arm/boot/dts/at91sam9x5cm.dtsi
@@ -0,0 +1,74 @@
1/*
2 * at91sam9x5cm.dtsi - Device Tree Include file for AT91SAM9x5 CPU Module
3 *
4 * Copyright (C) 2012 Atmel,
5 * 2012 Nicolas Ferre <nicolas.ferre@atmel.com>
6 *
7 * Licensed under GPLv2 or later.
8 */
9
10/ {
11 memory@20000000 {
12 reg = <0x20000000 0x8000000>;
13 };
14
15 clocks {
16 #address-cells = <1>;
17 #size-cells = <1>;
18 ranges;
19
20 main_clock: clock@0 {
21 compatible = "atmel,osc", "fixed-clock";
22 clock-frequency = <12000000>;
23 };
24 };
25
26 ahb {
27 nand0: nand@40000000 {
28 nand-bus-width = <8>;
29 nand-ecc-mode = "soft";
30 nand-on-flash-bbt;
31 status = "okay";
32
33 at91bootstrap@0 {
34 label = "at91bootstrap";
35 reg = <0x0 0x40000>;
36 };
37
38 uboot@40000 {
39 label = "u-boot";
40 reg = <0x40000 0x80000>;
41 };
42
43 ubootenv@c0000 {
44 label = "U-Boot Env";
45 reg = <0xc0000 0x140000>;
46 };
47
48 kernel@200000 {
49 label = "kernel";
50 reg = <0x200000 0x600000>;
51 };
52
53 rootfs@800000 {
54 label = "rootfs";
55 reg = <0x800000 0x1f800000>;
56 };
57 };
58 };
59
60 leds {
61 compatible = "gpio-leds";
62
63 pb18 {
64 label = "pb18";
65 gpios = <&pioB 18 1>;
66 linux,default-trigger = "heartbeat";
67 };
68
69 pd21 {
70 label = "pd21";
71 gpios = <&pioD 21 0>;
72 };
73 };
74};
diff --git a/arch/arm/boot/dts/db8500.dtsi b/arch/arm/boot/dts/db8500.dtsi
new file mode 100644
index 00000000000..d73dce64566
--- /dev/null
+++ b/arch/arm/boot/dts/db8500.dtsi
@@ -0,0 +1,275 @@
1/*
2 * Copyright 2012 Linaro Ltd
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 soc-u9500 {
16 #address-cells = <1>;
17 #size-cells = <1>;
18 compatible = "stericsson,db8500";
19 interrupt-parent = <&intc>;
20 ranges;
21
22 intc: interrupt-controller@a0411000 {
23 compatible = "arm,cortex-a9-gic";
24 #interrupt-cells = <3>;
25 #address-cells = <1>;
26 interrupt-controller;
27 interrupt-parent;
28 reg = <0xa0411000 0x1000>,
29 <0xa0410100 0x100>;
30 };
31
32 L2: l2-cache {
33 compatible = "arm,pl310-cache";
34 reg = <0xa0412000 0x1000>;
35 interrupts = <0 13 4>;
36 cache-unified;
37 cache-level = <2>;
38 };
39
40 pmu {
41 compatible = "arm,cortex-a9-pmu";
42 interrupts = <0 7 0x4>;
43 };
44
45 timer@a0410600 {
46 compatible = "arm,cortex-a9-twd-timer";
47 reg = <0xa0410600 0x20>;
48 interrupts = <1 13 0x304>;
49 };
50
51 rtc@80154000 {
52 compatible = "stericsson,db8500-rtc";
53 reg = <0x80154000 0x1000>;
54 interrupts = <0 18 0x4>;
55 };
56
57 gpio0: gpio@8012e000 {
58 compatible = "stericsson,db8500-gpio",
59 "stmicroelectronics,nomadik-gpio";
60 reg = <0x8012e000 0x80>;
61 interrupts = <0 119 0x4>;
62 supports-sleepmode;
63 gpio-controller;
64 };
65
66 gpio1: gpio@8012e080 {
67 compatible = "stericsson,db8500-gpio",
68 "stmicroelectronics,nomadik-gpio";
69 reg = <0x8012e080 0x80>;
70 interrupts = <0 120 0x4>;
71 supports-sleepmode;
72 gpio-controller;
73 };
74
75 gpio2: gpio@8000e000 {
76 compatible = "stericsson,db8500-gpio",
77 "stmicroelectronics,nomadik-gpio";
78 reg = <0x8000e000 0x80>;
79 interrupts = <0 121 0x4>;
80 supports-sleepmode;
81 gpio-controller;
82 };
83
84 gpio3: gpio@8000e080 {
85 compatible = "stericsson,db8500-gpio",
86 "stmicroelectronics,nomadik-gpio";
87 reg = <0x8000e080 0x80>;
88 interrupts = <0 122 0x4>;
89 supports-sleepmode;
90 gpio-controller;
91 };
92
93 gpio4: gpio@8000e100 {
94 compatible = "stericsson,db8500-gpio",
95 "stmicroelectronics,nomadik-gpio";
96 reg = <0x8000e100 0x80>;
97 interrupts = <0 123 0x4>;
98 supports-sleepmode;
99 gpio-controller;
100 };
101
102 gpio5: gpio@8000e180 {
103 compatible = "stericsson,db8500-gpio",
104 "stmicroelectronics,nomadik-gpio";
105 reg = <0x8000e180 0x80>;
106 interrupts = <0 124 0x4>;
107 supports-sleepmode;
108 gpio-controller;
109 };
110
111 gpio6: gpio@8011e000 {
112 compatible = "stericsson,db8500-gpio",
113 "stmicroelectronics,nomadik-gpio";
114 reg = <0x8011e000 0x80>;
115 interrupts = <0 125 0x4>;
116 supports-sleepmode;
117 gpio-controller;
118 };
119
120 gpio7: gpio@8011e080 {
121 compatible = "stericsson,db8500-gpio",
122 "stmicroelectronics,nomadik-gpio";
123 reg = <0x8011e080 0x80>;
124 interrupts = <0 126 0x4>;
125 supports-sleepmode;
126 gpio-controller;
127 };
128
129 gpio8: gpio@a03fe000 {
130 compatible = "stericsson,db8500-gpio",
131 "stmicroelectronics,nomadik-gpio";
132 reg = <0xa03fe000 0x80>;
133 interrupts = <0 127 0x4>;
134 supports-sleepmode;
135 gpio-controller;
136 };
137
138 usb@a03e0000 {
139 compatible = "stericsson,db8500-musb",
140 "mentor,musb";
141 reg = <0xa03e0000 0x10000>;
142 interrupts = <0 23 0x4>;
143 };
144
145 dma-controller@801C0000 {
146 compatible = "stericsson,db8500-dma40",
147 "stericsson,dma40";
148 reg = <0x801C0000 0x1000 0x40010000 0x800>;
149 interrupts = <0 25 0x4>;
150 };
151
152 prcmu@80157000 {
153 compatible = "stericsson,db8500-prcmu";
154 reg = <0x80157000 0x1000>;
155 interrupts = <46 47>;
156 #address-cells = <1>;
157 #size-cells = <0>;
158
159 ab8500@5 {
160 compatible = "stericsson,ab8500";
161 reg = <5>; /* mailbox 5 is i2c */
162 interrupts = <0 40 0x4>;
163 };
164 };
165
166 i2c@80004000 {
167 compatible = "stericsson,db8500-i2c", "stmicroelectronics,nomadik-i2c";
168 reg = <0x80004000 0x1000>;
169 interrupts = <0 21 0x4>;
170 #address-cells = <1>;
171 #size-cells = <0>;
172 };
173
174 i2c@80122000 {
175 compatible = "stericsson,db8500-i2c", "stmicroelectronics,nomadik-i2c";
176 reg = <0x80122000 0x1000>;
177 interrupts = <0 22 0x4>;
178 #address-cells = <1>;
179 #size-cells = <0>;
180 };
181
182 i2c@80128000 {
183 compatible = "stericsson,db8500-i2c", "stmicroelectronics,nomadik-i2c";
184 reg = <0x80128000 0x1000>;
185 interrupts = <0 55 0x4>;
186 #address-cells = <1>;
187 #size-cells = <0>;
188 };
189
190 i2c@80110000 {
191 compatible = "stericsson,db8500-i2c", "stmicroelectronics,nomadik-i2c";
192 reg = <0x80110000 0x1000>;
193 interrupts = <0 12 0x4>;
194 #address-cells = <1>;
195 #size-cells = <0>;
196 };
197
198 i2c@8012a000 {
199 compatible = "stericsson,db8500-i2c", "stmicroelectronics,nomadik-i2c";
200 reg = <0x8012a000 0x1000>;
201 interrupts = <0 51 0x4>;
202 #address-cells = <1>;
203 #size-cells = <0>;
204 };
205
206 ssp@80002000 {
207 compatible = "arm,pl022", "arm,primecell";
208 reg = <80002000 0x1000>;
209 interrupts = <0 14 0x4>;
210 #address-cells = <1>;
211 #size-cells = <0>;
212 status = "disabled";
213
214 // Add one of these for each child device
215 cs-gpios = <&gpio0 31 &gpio4 14 &gpio4 16 &gpio6 22 &gpio7 0>;
216
217 };
218
219 uart@80120000 {
220 compatible = "arm,pl011", "arm,primecell";
221 reg = <0x80120000 0x1000>;
222 interrupts = <0 11 0x4>;
223 status = "disabled";
224 };
225 uart@80121000 {
226 compatible = "arm,pl011", "arm,primecell";
227 reg = <0x80121000 0x1000>;
228 interrupts = <0 19 0x4>;
229 status = "disabled";
230 };
231 uart@80007000 {
232 compatible = "arm,pl011", "arm,primecell";
233 reg = <0x80007000 0x1000>;
234 interrupts = <0 26 0x4>;
235 status = "disabled";
236 };
237
238 sdi@80126000 {
239 compatible = "arm,pl18x", "arm,primecell";
240 reg = <0x80126000 0x1000>;
241 interrupts = <0 60 0x4>;
242 status = "disabled";
243 };
244 sdi@80118000 {
245 compatible = "arm,pl18x", "arm,primecell";
246 reg = <0x80118000 0x1000>;
247 interrupts = <0 50 0x4>;
248 status = "disabled";
249 };
250 sdi@80005000 {
251 compatible = "arm,pl18x", "arm,primecell";
252 reg = <0x80005000 0x1000>;
253 interrupts = <0 41 0x4>;
254 status = "disabled";
255 };
256 sdi@80119000 {
257 compatible = "arm,pl18x", "arm,primecell";
258 reg = <0x80119000 0x1000>;
259 interrupts = <0 59 0x4>;
260 status = "disabled";
261 };
262 sdi@80114000 {
263 compatible = "arm,pl18x", "arm,primecell";
264 reg = <0x80114000 0x1000>;
265 interrupts = <0 99 0x4>;
266 status = "disabled";
267 };
268 sdi@80008000 {
269 compatible = "arm,pl18x", "arm,primecell";
270 reg = <0x80114000 0x1000>;
271 interrupts = <0 100 0x4>;
272 status = "disabled";
273 };
274 };
275};
diff --git a/arch/arm/boot/dts/exynos5250-smdk5250.dts b/arch/arm/boot/dts/exynos5250-smdk5250.dts
new file mode 100644
index 00000000000..399d17b231d
--- /dev/null
+++ b/arch/arm/boot/dts/exynos5250-smdk5250.dts
@@ -0,0 +1,26 @@
1/*
2 * SAMSUNG SMDK5250 board device tree source
3 *
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10*/
11
12/dts-v1/;
13/include/ "exynos5250.dtsi"
14
15/ {
16 model = "SAMSUNG SMDK5250 board based on EXYNOS5250";
17 compatible = "samsung,smdk5250", "samsung,exynos5250";
18
19 memory {
20 reg = <0x40000000 0x80000000>;
21 };
22
23 chosen {
24 bootargs = "root=/dev/ram0 rw ramdisk=8192 console=ttySAC1,115200";
25 };
26};
diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
new file mode 100644
index 00000000000..dfc43359943
--- /dev/null
+++ b/arch/arm/boot/dts/exynos5250.dtsi
@@ -0,0 +1,413 @@
1/*
2 * SAMSUNG EXYNOS5250 SoC device tree source
3 *
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com
6 *
7 * SAMSUNG EXYNOS5250 SoC device nodes are listed in this file.
8 * EXYNOS5250 based board files can include this file and provide
9 * values for board specfic bindings.
10 *
11 * Note: This file does not include device nodes for all the controllers in
12 * EXYNOS5250 SoC. As device tree coverage for EXYNOS5250 increases,
13 * additional nodes can be added to this file.
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/ "skeleton.dtsi"
21
22/ {
23 compatible = "samsung,exynos5250";
24 interrupt-parent = <&gic>;
25
26 gic:interrupt-controller@10490000 {
27 compatible = "arm,cortex-a9-gic";
28 #interrupt-cells = <3>;
29 interrupt-controller;
30 reg = <0x10490000 0x1000>, <0x10480000 0x100>;
31 };
32
33 watchdog {
34 compatible = "samsung,s3c2410-wdt";
35 reg = <0x101D0000 0x100>;
36 interrupts = <0 42 0>;
37 };
38
39 rtc {
40 compatible = "samsung,s3c6410-rtc";
41 reg = <0x101E0000 0x100>;
42 interrupts = <0 43 0>, <0 44 0>;
43 };
44
45 sdhci@12200000 {
46 compatible = "samsung,exynos4210-sdhci";
47 reg = <0x12200000 0x100>;
48 interrupts = <0 75 0>;
49 };
50
51 sdhci@12210000 {
52 compatible = "samsung,exynos4210-sdhci";
53 reg = <0x12210000 0x100>;
54 interrupts = <0 76 0>;
55 };
56
57 sdhci@12220000 {
58 compatible = "samsung,exynos4210-sdhci";
59 reg = <0x12220000 0x100>;
60 interrupts = <0 77 0>;
61 };
62
63 sdhci@12230000 {
64 compatible = "samsung,exynos4210-sdhci";
65 reg = <0x12230000 0x100>;
66 interrupts = <0 78 0>;
67 };
68
69 serial@12C00000 {
70 compatible = "samsung,exynos4210-uart";
71 reg = <0x12C00000 0x100>;
72 interrupts = <0 51 0>;
73 };
74
75 serial@12C10000 {
76 compatible = "samsung,exynos4210-uart";
77 reg = <0x12C10000 0x100>;
78 interrupts = <0 52 0>;
79 };
80
81 serial@12C20000 {
82 compatible = "samsung,exynos4210-uart";
83 reg = <0x12C20000 0x100>;
84 interrupts = <0 53 0>;
85 };
86
87 serial@12C30000 {
88 compatible = "samsung,exynos4210-uart";
89 reg = <0x12C30000 0x100>;
90 interrupts = <0 54 0>;
91 };
92
93 i2c@12C60000 {
94 compatible = "samsung,s3c2440-i2c";
95 reg = <0x12C60000 0x100>;
96 interrupts = <0 56 0>;
97 };
98
99 i2c@12C70000 {
100 compatible = "samsung,s3c2440-i2c";
101 reg = <0x12C70000 0x100>;
102 interrupts = <0 57 0>;
103 };
104
105 i2c@12C80000 {
106 compatible = "samsung,s3c2440-i2c";
107 reg = <0x12C80000 0x100>;
108 interrupts = <0 58 0>;
109 };
110
111 i2c@12C90000 {
112 compatible = "samsung,s3c2440-i2c";
113 reg = <0x12C90000 0x100>;
114 interrupts = <0 59 0>;
115 };
116
117 i2c@12CA0000 {
118 compatible = "samsung,s3c2440-i2c";
119 reg = <0x12CA0000 0x100>;
120 interrupts = <0 60 0>;
121 };
122
123 i2c@12CB0000 {
124 compatible = "samsung,s3c2440-i2c";
125 reg = <0x12CB0000 0x100>;
126 interrupts = <0 61 0>;
127 };
128
129 i2c@12CC0000 {
130 compatible = "samsung,s3c2440-i2c";
131 reg = <0x12CC0000 0x100>;
132 interrupts = <0 62 0>;
133 };
134
135 i2c@12CD0000 {
136 compatible = "samsung,s3c2440-i2c";
137 reg = <0x12CD0000 0x100>;
138 interrupts = <0 63 0>;
139 };
140
141 amba {
142 #address-cells = <1>;
143 #size-cells = <1>;
144 compatible = "arm,amba-bus";
145 interrupt-parent = <&gic>;
146 ranges;
147
148 pdma0: pdma@121A0000 {
149 compatible = "arm,pl330", "arm,primecell";
150 reg = <0x121A0000 0x1000>;
151 interrupts = <0 34 0>;
152 };
153
154 pdma1: pdma@121B0000 {
155 compatible = "arm,pl330", "arm,primecell";
156 reg = <0x121B0000 0x1000>;
157 interrupts = <0 35 0>;
158 };
159
160 mdma0: pdma@10800000 {
161 compatible = "arm,pl330", "arm,primecell";
162 reg = <0x10800000 0x1000>;
163 interrupts = <0 33 0>;
164 };
165
166 mdma1: pdma@11C10000 {
167 compatible = "arm,pl330", "arm,primecell";
168 reg = <0x11C10000 0x1000>;
169 interrupts = <0 124 0>;
170 };
171 };
172
173 gpio-controllers {
174 #address-cells = <1>;
175 #size-cells = <1>;
176 gpio-controller;
177 ranges;
178
179 gpa0: gpio-controller@11400000 {
180 compatible = "samsung,exynos4-gpio";
181 reg = <0x11400000 0x20>;
182 #gpio-cells = <4>;
183 };
184
185 gpa1: gpio-controller@11400020 {
186 compatible = "samsung,exynos4-gpio";
187 reg = <0x11400020 0x20>;
188 #gpio-cells = <4>;
189 };
190
191 gpa2: gpio-controller@11400040 {
192 compatible = "samsung,exynos4-gpio";
193 reg = <0x11400040 0x20>;
194 #gpio-cells = <4>;
195 };
196
197 gpb0: gpio-controller@11400060 {
198 compatible = "samsung,exynos4-gpio";
199 reg = <0x11400060 0x20>;
200 #gpio-cells = <4>;
201 };
202
203 gpb1: gpio-controller@11400080 {
204 compatible = "samsung,exynos4-gpio";
205 reg = <0x11400080 0x20>;
206 #gpio-cells = <4>;
207 };
208
209 gpb2: gpio-controller@114000A0 {
210 compatible = "samsung,exynos4-gpio";
211 reg = <0x114000A0 0x20>;
212 #gpio-cells = <4>;
213 };
214
215 gpb3: gpio-controller@114000C0 {
216 compatible = "samsung,exynos4-gpio";
217 reg = <0x114000C0 0x20>;
218 #gpio-cells = <4>;
219 };
220
221 gpc0: gpio-controller@114000E0 {
222 compatible = "samsung,exynos4-gpio";
223 reg = <0x114000E0 0x20>;
224 #gpio-cells = <4>;
225 };
226
227 gpc1: gpio-controller@11400100 {
228 compatible = "samsung,exynos4-gpio";
229 reg = <0x11400100 0x20>;
230 #gpio-cells = <4>;
231 };
232
233 gpc2: gpio-controller@11400120 {
234 compatible = "samsung,exynos4-gpio";
235 reg = <0x11400120 0x20>;
236 #gpio-cells = <4>;
237 };
238
239 gpc3: gpio-controller@11400140 {
240 compatible = "samsung,exynos4-gpio";
241 reg = <0x11400140 0x20>;
242 #gpio-cells = <4>;
243 };
244
245 gpd0: gpio-controller@11400160 {
246 compatible = "samsung,exynos4-gpio";
247 reg = <0x11400160 0x20>;
248 #gpio-cells = <4>;
249 };
250
251 gpd1: gpio-controller@11400180 {
252 compatible = "samsung,exynos4-gpio";
253 reg = <0x11400180 0x20>;
254 #gpio-cells = <4>;
255 };
256
257 gpy0: gpio-controller@114001A0 {
258 compatible = "samsung,exynos4-gpio";
259 reg = <0x114001A0 0x20>;
260 #gpio-cells = <4>;
261 };
262
263 gpy1: gpio-controller@114001C0 {
264 compatible = "samsung,exynos4-gpio";
265 reg = <0x114001C0 0x20>;
266 #gpio-cells = <4>;
267 };
268
269 gpy2: gpio-controller@114001E0 {
270 compatible = "samsung,exynos4-gpio";
271 reg = <0x114001E0 0x20>;
272 #gpio-cells = <4>;
273 };
274
275 gpy3: gpio-controller@11400200 {
276 compatible = "samsung,exynos4-gpio";
277 reg = <0x11400200 0x20>;
278 #gpio-cells = <4>;
279 };
280
281 gpy4: gpio-controller@11400220 {
282 compatible = "samsung,exynos4-gpio";
283 reg = <0x11400220 0x20>;
284 #gpio-cells = <4>;
285 };
286
287 gpy5: gpio-controller@11400240 {
288 compatible = "samsung,exynos4-gpio";
289 reg = <0x11400240 0x20>;
290 #gpio-cells = <4>;
291 };
292
293 gpy6: gpio-controller@11400260 {
294 compatible = "samsung,exynos4-gpio";
295 reg = <0x11400260 0x20>;
296 #gpio-cells = <4>;
297 };
298
299 gpx0: gpio-controller@11400C00 {
300 compatible = "samsung,exynos4-gpio";
301 reg = <0x11400C00 0x20>;
302 #gpio-cells = <4>;
303 };
304
305 gpx1: gpio-controller@11400C20 {
306 compatible = "samsung,exynos4-gpio";
307 reg = <0x11400C20 0x20>;
308 #gpio-cells = <4>;
309 };
310
311 gpx2: gpio-controller@11400C40 {
312 compatible = "samsung,exynos4-gpio";
313 reg = <0x11400C40 0x20>;
314 #gpio-cells = <4>;
315 };
316
317 gpx3: gpio-controller@11400C60 {
318 compatible = "samsung,exynos4-gpio";
319 reg = <0x11400C60 0x20>;
320 #gpio-cells = <4>;
321 };
322
323 gpe0: gpio-controller@13400000 {
324 compatible = "samsung,exynos4-gpio";
325 reg = <0x13400000 0x20>;
326 #gpio-cells = <4>;
327 };
328
329 gpe1: gpio-controller@13400020 {
330 compatible = "samsung,exynos4-gpio";
331 reg = <0x13400020 0x20>;
332 #gpio-cells = <4>;
333 };
334
335 gpf0: gpio-controller@13400040 {
336 compatible = "samsung,exynos4-gpio";
337 reg = <0x13400040 0x20>;
338 #gpio-cells = <4>;
339 };
340
341 gpf1: gpio-controller@13400060 {
342 compatible = "samsung,exynos4-gpio";
343 reg = <0x13400060 0x20>;
344 #gpio-cells = <4>;
345 };
346
347 gpg0: gpio-controller@13400080 {
348 compatible = "samsung,exynos4-gpio";
349 reg = <0x13400080 0x20>;
350 #gpio-cells = <4>;
351 };
352
353 gpg1: gpio-controller@134000A0 {
354 compatible = "samsung,exynos4-gpio";
355 reg = <0x134000A0 0x20>;
356 #gpio-cells = <4>;
357 };
358
359 gpg2: gpio-controller@134000C0 {
360 compatible = "samsung,exynos4-gpio";
361 reg = <0x134000C0 0x20>;
362 #gpio-cells = <4>;
363 };
364
365 gph0: gpio-controller@134000E0 {
366 compatible = "samsung,exynos4-gpio";
367 reg = <0x134000E0 0x20>;
368 #gpio-cells = <4>;
369 };
370
371 gph1: gpio-controller@13400100 {
372 compatible = "samsung,exynos4-gpio";
373 reg = <0x13400100 0x20>;
374 #gpio-cells = <4>;
375 };
376
377 gpv0: gpio-controller@10D10000 {
378 compatible = "samsung,exynos4-gpio";
379 reg = <0x10D10000 0x20>;
380 #gpio-cells = <4>;
381 };
382
383 gpv1: gpio-controller@10D10020 {
384 compatible = "samsung,exynos4-gpio";
385 reg = <0x10D10020 0x20>;
386 #gpio-cells = <4>;
387 };
388
389 gpv2: gpio-controller@10D10040 {
390 compatible = "samsung,exynos4-gpio";
391 reg = <0x10D10040 0x20>;
392 #gpio-cells = <4>;
393 };
394
395 gpv3: gpio-controller@10D10060 {
396 compatible = "samsung,exynos4-gpio";
397 reg = <0x10D10060 0x20>;
398 #gpio-cells = <4>;
399 };
400
401 gpv4: gpio-controller@10D10080 {
402 compatible = "samsung,exynos4-gpio";
403 reg = <0x10D10080 0x20>;
404 #gpio-cells = <4>;
405 };
406
407 gpz: gpio-controller@03860000 {
408 compatible = "samsung,exynos4-gpio";
409 reg = <0x03860000 0x20>;
410 #gpio-cells = <4>;
411 };
412 };
413};
diff --git a/arch/arm/boot/dts/highbank.dts b/arch/arm/boot/dts/highbank.dts
index 305635bd45c..37c0ff9c8b9 100644
--- a/arch/arm/boot/dts/highbank.dts
+++ b/arch/arm/boot/dts/highbank.dts
@@ -72,15 +72,15 @@
72 ranges; 72 ranges;
73 73
74 timer@fff10600 { 74 timer@fff10600 {
75 compatible = "arm,smp-twd"; 75 compatible = "arm,cortex-a9-twd-timer";
76 reg = <0xfff10600 0x20>; 76 reg = <0xfff10600 0x20>;
77 interrupts = <1 13 0xf04>; 77 interrupts = <1 13 0xf01>;
78 }; 78 };
79 79
80 watchdog@fff10620 { 80 watchdog@fff10620 {
81 compatible = "arm,cortex-a9-wdt"; 81 compatible = "arm,cortex-a9-twd-wdt";
82 reg = <0xfff10620 0x20>; 82 reg = <0xfff10620 0x20>;
83 interrupts = <1 14 0xf04>; 83 interrupts = <1 14 0xf01>;
84 }; 84 };
85 85
86 intc: interrupt-controller@fff11000 { 86 intc: interrupt-controller@fff11000 {
diff --git a/arch/arm/boot/dts/imx27-phytec-phycore.dts b/arch/arm/boot/dts/imx27-phytec-phycore.dts
new file mode 100644
index 00000000000..a51a08fc2af
--- /dev/null
+++ b/arch/arm/boot/dts/imx27-phytec-phycore.dts
@@ -0,0 +1,76 @@
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 = "Phytec pcm038";
17 compatible = "phytec,imx27-pcm038", "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 uart@1000a000 {
31 fsl,uart-has-rtscts;
32 status = "okay";
33 };
34
35 uart@1000b000 {
36 fsl,uart-has-rtscts;
37 status = "okay";
38 };
39
40 uart@1000c000 {
41 fsl,uart-has-rtscts;
42 status = "okay";
43 };
44
45 fec@1002b000 {
46 status = "okay";
47 };
48
49 i2c@1001d000 {
50 clock-frequency = <400000>;
51 status = "okay";
52 at24@4c {
53 compatible = "at,24c32";
54 pagesize = <32>;
55 reg = <0x52>;
56 };
57 pcf8563@51 {
58 compatible = "nxp,pcf8563";
59 reg = <0x51>;
60 };
61 lm75@4a {
62 compatible = "national,lm75";
63 reg = <0x4a>;
64 };
65 };
66 };
67 };
68
69 nor_flash@c0000000 {
70 compatible = "cfi-flash";
71 bank-width = <2>;
72 reg = <0xc0000000 0x02000000>;
73 #address-cells = <1>;
74 #size-cells = <1>;
75 };
76};
diff --git a/arch/arm/boot/dts/imx27.dtsi b/arch/arm/boot/dts/imx27.dtsi
new file mode 100644
index 00000000000..bc5e7d5ddd5
--- /dev/null
+++ b/arch/arm/boot/dts/imx27.dtsi
@@ -0,0 +1,217 @@
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/ "skeleton.dtsi"
13
14/ {
15 aliases {
16 serial0 = &uart1;
17 serial1 = &uart2;
18 serial2 = &uart3;
19 serial3 = &uart4;
20 serial4 = &uart5;
21 serial5 = &uart6;
22 };
23
24 avic: avic-interrupt-controller@e0000000 {
25 compatible = "fsl,imx27-avic", "fsl,avic";
26 interrupt-controller;
27 #interrupt-cells = <1>;
28 reg = <0x10040000 0x1000>;
29 };
30
31 clocks {
32 #address-cells = <1>;
33 #size-cells = <0>;
34
35 osc26m {
36 compatible = "fsl,imx-osc26m", "fixed-clock";
37 clock-frequency = <26000000>;
38 };
39 };
40
41 soc {
42 #address-cells = <1>;
43 #size-cells = <1>;
44 compatible = "simple-bus";
45 interrupt-parent = <&avic>;
46 ranges;
47
48 aipi@10000000 { /* AIPI1 */
49 compatible = "fsl,aipi-bus", "simple-bus";
50 #address-cells = <1>;
51 #size-cells = <1>;
52 reg = <0x10000000 0x10000000>;
53 ranges;
54
55 wdog@10002000 {
56 compatible = "fsl,imx27-wdt", "fsl,imx21-wdt";
57 reg = <0x10002000 0x4000>;
58 interrupts = <27>;
59 status = "disabled";
60 };
61
62 uart1: uart@1000a000 {
63 compatible = "fsl,imx27-uart", "fsl,imx21-uart";
64 reg = <0x1000a000 0x1000>;
65 interrupts = <20>;
66 status = "disabled";
67 };
68
69 uart2: uart@1000b000 {
70 compatible = "fsl,imx27-uart", "fsl,imx21-uart";
71 reg = <0x1000b000 0x1000>;
72 interrupts = <19>;
73 status = "disabled";
74 };
75
76 uart3: uart@1000c000 {
77 compatible = "fsl,imx27-uart", "fsl,imx21-uart";
78 reg = <0x1000c000 0x1000>;
79 interrupts = <18>;
80 status = "disabled";
81 };
82
83 uart4: uart@1000d000 {
84 compatible = "fsl,imx27-uart", "fsl,imx21-uart";
85 reg = <0x1000d000 0x1000>;
86 interrupts = <17>;
87 status = "disabled";
88 };
89
90 cspi1: cspi@1000e000 {
91 #address-cells = <1>;
92 #size-cells = <0>;
93 compatible = "fsl,imx27-cspi";
94 reg = <0x1000e000 0x1000>;
95 interrupts = <16>;
96 status = "disabled";
97 };
98
99 cspi2: cspi@1000f000 {
100 #address-cells = <1>;
101 #size-cells = <0>;
102 compatible = "fsl,imx27-cspi";
103 reg = <0x1000f000 0x1000>;
104 interrupts = <15>;
105 status = "disabled";
106 };
107
108 i2c1: i2c@10012000 {
109 #address-cells = <1>;
110 #size-cells = <0>;
111 compatible = "fsl,imx27-i2c", "fsl,imx1-i2c";
112 reg = <0x10012000 0x1000>;
113 interrupts = <12>;
114 status = "disabled";
115 };
116
117 gpio1: gpio@10015000 {
118 compatible = "fsl,imx27-gpio", "fsl,imx21-gpio";
119 reg = <0x10015000 0x100>;
120 interrupts = <8>;
121 gpio-controller;
122 #gpio-cells = <2>;
123 interrupt-controller;
124 #interrupt-cells = <1>;
125 };
126
127 gpio2: gpio@10015100 {
128 compatible = "fsl,imx27-gpio", "fsl,imx21-gpio";
129 reg = <0x10015100 0x100>;
130 interrupts = <8>;
131 gpio-controller;
132 #gpio-cells = <2>;
133 interrupt-controller;
134 #interrupt-cells = <1>;
135 };
136
137 gpio3: gpio@10015200 {
138 compatible = "fsl,imx27-gpio", "fsl,imx21-gpio";
139 reg = <0x10015200 0x100>;
140 interrupts = <8>;
141 gpio-controller;
142 #gpio-cells = <2>;
143 interrupt-controller;
144 #interrupt-cells = <1>;
145 };
146
147 gpio4: gpio@10015300 {
148 compatible = "fsl,imx27-gpio", "fsl,imx21-gpio";
149 reg = <0x10015300 0x100>;
150 interrupts = <8>;
151 gpio-controller;
152 #gpio-cells = <2>;
153 interrupt-controller;
154 #interrupt-cells = <1>;
155 };
156
157 gpio5: gpio@10015400 {
158 compatible = "fsl,imx27-gpio", "fsl,imx21-gpio";
159 reg = <0x10015400 0x100>;
160 interrupts = <8>;
161 gpio-controller;
162 #gpio-cells = <2>;
163 interrupt-controller;
164 #interrupt-cells = <1>;
165 };
166
167 gpio6: gpio@10015500 {
168 compatible = "fsl,imx27-gpio", "fsl,imx21-gpio";
169 reg = <0x10015500 0x100>;
170 interrupts = <8>;
171 gpio-controller;
172 #gpio-cells = <2>;
173 interrupt-controller;
174 #interrupt-cells = <1>;
175 };
176
177 cspi3: cspi@10017000 {
178 #address-cells = <1>;
179 #size-cells = <0>;
180 compatible = "fsl,imx27-cspi";
181 reg = <0x10017000 0x1000>;
182 interrupts = <6>;
183 status = "disabled";
184 };
185
186 uart5: uart@1001b000 {
187 compatible = "fsl,imx27-uart", "fsl,imx21-uart";
188 reg = <0x1001b000 0x1000>;
189 interrupts = <49>;
190 status = "disabled";
191 };
192
193 uart6: uart@1001c000 {
194 compatible = "fsl,imx27-uart", "fsl,imx21-uart";
195 reg = <0x1001c000 0x1000>;
196 interrupts = <48>;
197 status = "disabled";
198 };
199
200 i2c2: i2c@1001d000 {
201 #address-cells = <1>;
202 #size-cells = <0>;
203 compatible = "fsl,imx27-i2c", "fsl,imx1-i2c";
204 reg = <0x1001d000 0x1000>;
205 interrupts = <1>;
206 status = "disabled";
207 };
208
209 fec: fec@1002b000 {
210 compatible = "fsl,imx27-fec";
211 reg = <0x1002b000 0x4000>;
212 interrupts = <50>;
213 status = "disabled";
214 };
215 };
216 };
217};
diff --git a/arch/arm/boot/dts/imx51-babbage.dts b/arch/arm/boot/dts/imx51-babbage.dts
index 564cb8c19f1..9949e6060de 100644
--- a/arch/arm/boot/dts/imx51-babbage.dts
+++ b/arch/arm/boot/dts/imx51-babbage.dts
@@ -56,8 +56,95 @@
56 compatible = "fsl,mc13892"; 56 compatible = "fsl,mc13892";
57 spi-max-frequency = <6000000>; 57 spi-max-frequency = <6000000>;
58 reg = <0>; 58 reg = <0>;
59 mc13xxx-irq-gpios = <&gpio1 8 0>; 59 interrupt-parent = <&gpio1>;
60 fsl,mc13xxx-uses-regulator; 60 interrupts = <8>;
61
62 regulators {
63 sw1_reg: sw1 {
64 regulator-min-microvolt = <600000>;
65 regulator-max-microvolt = <1375000>;
66 regulator-boot-on;
67 regulator-always-on;
68 };
69
70 sw2_reg: sw2 {
71 regulator-min-microvolt = <900000>;
72 regulator-max-microvolt = <1850000>;
73 regulator-boot-on;
74 regulator-always-on;
75 };
76
77 sw3_reg: sw3 {
78 regulator-min-microvolt = <1100000>;
79 regulator-max-microvolt = <1850000>;
80 regulator-boot-on;
81 regulator-always-on;
82 };
83
84 sw4_reg: sw4 {
85 regulator-min-microvolt = <1100000>;
86 regulator-max-microvolt = <1850000>;
87 regulator-boot-on;
88 regulator-always-on;
89 };
90
91 vpll_reg: vpll {
92 regulator-min-microvolt = <1050000>;
93 regulator-max-microvolt = <1800000>;
94 regulator-boot-on;
95 regulator-always-on;
96 };
97
98 vdig_reg: vdig {
99 regulator-min-microvolt = <1650000>;
100 regulator-max-microvolt = <1650000>;
101 regulator-boot-on;
102 };
103
104 vsd_reg: vsd {
105 regulator-min-microvolt = <1800000>;
106 regulator-max-microvolt = <3150000>;
107 };
108
109 vusb2_reg: vusb2 {
110 regulator-min-microvolt = <2400000>;
111 regulator-max-microvolt = <2775000>;
112 regulator-boot-on;
113 regulator-always-on;
114 };
115
116 vvideo_reg: vvideo {
117 regulator-min-microvolt = <2775000>;
118 regulator-max-microvolt = <2775000>;
119 };
120
121 vaudio_reg: vaudio {
122 regulator-min-microvolt = <2300000>;
123 regulator-max-microvolt = <3000000>;
124 };
125
126 vcam_reg: vcam {
127 regulator-min-microvolt = <2500000>;
128 regulator-max-microvolt = <3000000>;
129 };
130
131 vgen1_reg: vgen1 {
132 regulator-min-microvolt = <1200000>;
133 regulator-max-microvolt = <1200000>;
134 };
135
136 vgen2_reg: vgen2 {
137 regulator-min-microvolt = <1200000>;
138 regulator-max-microvolt = <3150000>;
139 regulator-always-on;
140 };
141
142 vgen3_reg: vgen3 {
143 regulator-min-microvolt = <1800000>;
144 regulator-max-microvolt = <2900000>;
145 regulator-always-on;
146 };
147 };
61 }; 148 };
62 149
63 flash: at45db321d@1 { 150 flash: at45db321d@1 {
diff --git a/arch/arm/boot/dts/imx6q-arm2.dts b/arch/arm/boot/dts/imx6q-arm2.dts
index c3977e0478b..ce1c8238c89 100644
--- a/arch/arm/boot/dts/imx6q-arm2.dts
+++ b/arch/arm/boot/dts/imx6q-arm2.dts
@@ -36,11 +36,13 @@
36 usdhc@02198000 { /* uSDHC3 */ 36 usdhc@02198000 { /* uSDHC3 */
37 cd-gpios = <&gpio6 11 0>; 37 cd-gpios = <&gpio6 11 0>;
38 wp-gpios = <&gpio6 14 0>; 38 wp-gpios = <&gpio6 14 0>;
39 vmmc-supply = <&reg_3p3v>;
39 status = "okay"; 40 status = "okay";
40 }; 41 };
41 42
42 usdhc@0219c000 { /* uSDHC4 */ 43 usdhc@0219c000 { /* uSDHC4 */
43 fsl,card-wired; 44 fsl,card-wired;
45 vmmc-supply = <&reg_3p3v>;
44 status = "okay"; 46 status = "okay";
45 }; 47 };
46 48
@@ -50,6 +52,18 @@
50 }; 52 };
51 }; 53 };
52 54
55 regulators {
56 compatible = "simple-bus";
57
58 reg_3p3v: 3p3v {
59 compatible = "regulator-fixed";
60 regulator-name = "3P3V";
61 regulator-min-microvolt = <3300000>;
62 regulator-max-microvolt = <3300000>;
63 regulator-always-on;
64 };
65 };
66
53 leds { 67 leds {
54 compatible = "gpio-leds"; 68 compatible = "gpio-leds";
55 69
diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts b/arch/arm/boot/dts/imx6q-sabrelite.dts
index 08d920de728..4663a4e5a28 100644
--- a/arch/arm/boot/dts/imx6q-sabrelite.dts
+++ b/arch/arm/boot/dts/imx6q-sabrelite.dts
@@ -32,18 +32,52 @@
32 usdhc@02198000 { /* uSDHC3 */ 32 usdhc@02198000 { /* uSDHC3 */
33 cd-gpios = <&gpio7 0 0>; 33 cd-gpios = <&gpio7 0 0>;
34 wp-gpios = <&gpio7 1 0>; 34 wp-gpios = <&gpio7 1 0>;
35 vmmc-supply = <&reg_3p3v>;
35 status = "okay"; 36 status = "okay";
36 }; 37 };
37 38
38 usdhc@0219c000 { /* uSDHC4 */ 39 usdhc@0219c000 { /* uSDHC4 */
39 cd-gpios = <&gpio2 6 0>; 40 cd-gpios = <&gpio2 6 0>;
40 wp-gpios = <&gpio2 7 0>; 41 wp-gpios = <&gpio2 7 0>;
42 vmmc-supply = <&reg_3p3v>;
41 status = "okay"; 43 status = "okay";
42 }; 44 };
43 45
44 uart2: uart@021e8000 { 46 uart2: uart@021e8000 {
45 status = "okay"; 47 status = "okay";
46 }; 48 };
49
50 i2c@021a0000 { /* I2C1 */
51 status = "okay";
52 clock-frequency = <100000>;
53
54 codec: sgtl5000@0a {
55 compatible = "fsl,sgtl5000";
56 reg = <0x0a>;
57 VDDA-supply = <&reg_2p5v>;
58 VDDIO-supply = <&reg_3p3v>;
59 };
60 };
61 };
62 };
63
64 regulators {
65 compatible = "simple-bus";
66
67 reg_2p5v: 2p5v {
68 compatible = "regulator-fixed";
69 regulator-name = "2P5V";
70 regulator-min-microvolt = <2500000>;
71 regulator-max-microvolt = <2500000>;
72 regulator-always-on;
73 };
74
75 reg_3p3v: 3p3v {
76 compatible = "regulator-fixed";
77 regulator-name = "3P3V";
78 regulator-min-microvolt = <3300000>;
79 regulator-max-microvolt = <3300000>;
80 regulator-always-on;
47 }; 81 };
48 }; 82 };
49}; 83};
diff --git a/arch/arm/boot/dts/imx6q.dtsi b/arch/arm/boot/dts/imx6q.dtsi
index 263e8f3664b..4905f51a106 100644
--- a/arch/arm/boot/dts/imx6q.dtsi
+++ b/arch/arm/boot/dts/imx6q.dtsi
@@ -88,9 +88,9 @@
88 ranges; 88 ranges;
89 89
90 timer@00a00600 { 90 timer@00a00600 {
91 compatible = "arm,smp-twd"; 91 compatible = "arm,cortex-a9-twd-timer";
92 reg = <0x00a00600 0x100>; 92 reg = <0x00a00600 0x20>;
93 interrupts = <1 13 0xf4>; 93 interrupts = <1 13 0xf01>;
94 }; 94 };
95 95
96 L2: l2-cache@00a02000 { 96 L2: l2-cache@00a02000 {
diff --git a/arch/arm/boot/dts/kirkwood-dreamplug.dts b/arch/arm/boot/dts/kirkwood-dreamplug.dts
new file mode 100644
index 00000000000..a5376b84227
--- /dev/null
+++ b/arch/arm/boot/dts/kirkwood-dreamplug.dts
@@ -0,0 +1,24 @@
1/dts-v1/;
2
3/include/ "kirkwood.dtsi"
4
5/ {
6 model = "Globalscale Technologies Dreamplug";
7 compatible = "globalscale,dreamplug-003-ds2001", "globalscale,dreamplug", "mrvl,kirkwood-88f6281", "mrvl,kirkwood";
8
9 memory {
10 device_type = "memory";
11 reg = <0x00000000 0x20000000>;
12 };
13
14 chosen {
15 bootargs = "console=ttyS0,115200n8 earlyprintk";
16 };
17
18 ocp@f1000000 {
19 serial@12000 {
20 clock-frequency = <200000000>;
21 status = "ok";
22 };
23 };
24};
diff --git a/arch/arm/boot/dts/kirkwood.dtsi b/arch/arm/boot/dts/kirkwood.dtsi
new file mode 100644
index 00000000000..3474ef89094
--- /dev/null
+++ b/arch/arm/boot/dts/kirkwood.dtsi
@@ -0,0 +1,36 @@
1/include/ "skeleton.dtsi"
2
3/ {
4 compatible = "mrvl,kirkwood";
5
6 ocp@f1000000 {
7 compatible = "simple-bus";
8 ranges = <0 0xf1000000 0x1000000>;
9 #address-cells = <1>;
10 #size-cells = <1>;
11
12 serial@12000 {
13 compatible = "ns16550a";
14 reg = <0x12000 0x100>;
15 reg-shift = <2>;
16 interrupts = <33>;
17 /* set clock-frequency in board dts */
18 status = "disabled";
19 };
20
21 serial@12100 {
22 compatible = "ns16550a";
23 reg = <0x12100 0x100>;
24 reg-shift = <2>;
25 interrupts = <34>;
26 /* set clock-frequency in board dts */
27 status = "disabled";
28 };
29
30 rtc@10300 {
31 compatible = "mrvl,kirkwood-rtc", "mrvl,orion-rtc";
32 reg = <0x10300 0x20>;
33 interrupts = <53>;
34 };
35 };
36};
diff --git a/arch/arm/boot/dts/omap3-beagle.dts b/arch/arm/boot/dts/omap3-beagle.dts
index 9486be62bcd..9f72cd4cf30 100644
--- a/arch/arm/boot/dts/omap3-beagle.dts
+++ b/arch/arm/boot/dts/omap3-beagle.dts
@@ -13,15 +13,6 @@
13 model = "TI OMAP3 BeagleBoard"; 13 model = "TI OMAP3 BeagleBoard";
14 compatible = "ti,omap3-beagle", "ti,omap3"; 14 compatible = "ti,omap3-beagle", "ti,omap3";
15 15
16 /*
17 * Since the initial device tree board file does not create any
18 * devices (MMC, network...), the only way to boot is to provide a
19 * ramdisk.
20 */
21 chosen {
22 bootargs = "root=/dev/ram0 rw console=ttyO2,115200n8 initrd=0x81600000,20M ramdisk_size=20480 no_console_suspend debug earlyprintk";
23 };
24
25 memory { 16 memory {
26 device_type = "memory"; 17 device_type = "memory";
27 reg = <0x80000000 0x20000000>; /* 512 MB */ 18 reg = <0x80000000 0x20000000>; /* 512 MB */
diff --git a/arch/arm/boot/dts/omap3-evm.dts b/arch/arm/boot/dts/omap3-evm.dts
new file mode 100644
index 00000000000..2eee16ec59b
--- /dev/null
+++ b/arch/arm/boot/dts/omap3-evm.dts
@@ -0,0 +1,20 @@
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 OMAP3 EVM (OMAP3530, AM/DM37x)";
14 compatible = "ti,omap3-evm", "ti,omap3";
15
16 memory {
17 device_type = "memory";
18 reg = <0x80000000 0x10000000>; /* 256 MB */
19 };
20};
diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
index 216c3317461..c6121357c1e 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -61,34 +61,57 @@
61 ranges; 61 ranges;
62 ti,hwmods = "l3_main"; 62 ti,hwmods = "l3_main";
63 63
64 intc: interrupt-controller@1 { 64 intc: interrupt-controller@48200000 {
65 compatible = "ti,omap3-intc"; 65 compatible = "ti,omap2-intc";
66 interrupt-controller; 66 interrupt-controller;
67 #interrupt-cells = <1>; 67 #interrupt-cells = <1>;
68 ti,intc-size = <96>;
69 reg = <0x48200000 0x1000>;
68 }; 70 };
69 71
70 uart1: serial@0x4806a000 { 72 uart1: serial@4806a000 {
71 compatible = "ti,omap3-uart"; 73 compatible = "ti,omap3-uart";
72 ti,hwmods = "uart1"; 74 ti,hwmods = "uart1";
73 clock-frequency = <48000000>; 75 clock-frequency = <48000000>;
74 }; 76 };
75 77
76 uart2: serial@0x4806c000 { 78 uart2: serial@4806c000 {
77 compatible = "ti,omap3-uart"; 79 compatible = "ti,omap3-uart";
78 ti,hwmods = "uart2"; 80 ti,hwmods = "uart2";
79 clock-frequency = <48000000>; 81 clock-frequency = <48000000>;
80 }; 82 };
81 83
82 uart3: serial@0x49020000 { 84 uart3: serial@49020000 {
83 compatible = "ti,omap3-uart"; 85 compatible = "ti,omap3-uart";
84 ti,hwmods = "uart3"; 86 ti,hwmods = "uart3";
85 clock-frequency = <48000000>; 87 clock-frequency = <48000000>;
86 }; 88 };
87 89
88 uart4: serial@0x49042000 { 90 uart4: serial@49042000 {
89 compatible = "ti,omap3-uart"; 91 compatible = "ti,omap3-uart";
90 ti,hwmods = "uart4"; 92 ti,hwmods = "uart4";
91 clock-frequency = <48000000>; 93 clock-frequency = <48000000>;
92 }; 94 };
95
96 i2c1: i2c@48070000 {
97 compatible = "ti,omap3-i2c";
98 #address-cells = <1>;
99 #size-cells = <0>;
100 ti,hwmods = "i2c1";
101 };
102
103 i2c2: i2c@48072000 {
104 compatible = "ti,omap3-i2c";
105 #address-cells = <1>;
106 #size-cells = <0>;
107 ti,hwmods = "i2c2";
108 };
109
110 i2c3: i2c@48060000 {
111 compatible = "ti,omap3-i2c";
112 #address-cells = <1>;
113 #size-cells = <0>;
114 ti,hwmods = "i2c3";
115 };
93 }; 116 };
94}; 117};
diff --git a/arch/arm/boot/dts/omap4-panda.dts b/arch/arm/boot/dts/omap4-panda.dts
index c7026578ce7..9755ad5917f 100644
--- a/arch/arm/boot/dts/omap4-panda.dts
+++ b/arch/arm/boot/dts/omap4-panda.dts
@@ -13,15 +13,6 @@
13 model = "TI OMAP4 PandaBoard"; 13 model = "TI OMAP4 PandaBoard";
14 compatible = "ti,omap4-panda", "ti,omap4430", "ti,omap4"; 14 compatible = "ti,omap4-panda", "ti,omap4430", "ti,omap4";
15 15
16 /*
17 * Since the initial device tree board file does not create any
18 * devices (MMC, network...), the only way to boot is to provide a
19 * ramdisk.
20 */
21 chosen {
22 bootargs = "root=/dev/ram0 rw console=ttyO2,115200n8 initrd=0x81600000,20M ramdisk_size=20480 no_console_suspend debug";
23 };
24
25 memory { 16 memory {
26 device_type = "memory"; 17 device_type = "memory";
27 reg = <0x80000000 0x40000000>; /* 1 GB */ 18 reg = <0x80000000 0x40000000>; /* 1 GB */
diff --git a/arch/arm/boot/dts/omap4-sdp.dts b/arch/arm/boot/dts/omap4-sdp.dts
index 066e28c9032..63c6b2b2bf4 100644
--- a/arch/arm/boot/dts/omap4-sdp.dts
+++ b/arch/arm/boot/dts/omap4-sdp.dts
@@ -13,15 +13,6 @@
13 model = "TI OMAP4 SDP board"; 13 model = "TI OMAP4 SDP board";
14 compatible = "ti,omap4-sdp", "ti,omap4430", "ti,omap4"; 14 compatible = "ti,omap4-sdp", "ti,omap4430", "ti,omap4";
15 15
16 /*
17 * Since the initial device tree board file does not create any
18 * devices (MMC, network...), the only way to boot is to provide a
19 * ramdisk.
20 */
21 chosen {
22 bootargs = "root=/dev/ram0 rw console=ttyO2,115200n8 initrd=0x81600000,20M ramdisk_size=20480 no_console_suspend debug";
23 };
24
25 memory { 16 memory {
26 device_type = "memory"; 17 device_type = "memory";
27 reg = <0x80000000 0x40000000>; /* 1 GB */ 18 reg = <0x80000000 0x40000000>; /* 1 GB */
diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index e8fe75fac7c..3d35559e77b 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -99,33 +99,61 @@
99 gic: interrupt-controller@48241000 { 99 gic: interrupt-controller@48241000 {
100 compatible = "arm,cortex-a9-gic"; 100 compatible = "arm,cortex-a9-gic";
101 interrupt-controller; 101 interrupt-controller;
102 #interrupt-cells = <1>; 102 #interrupt-cells = <3>;
103 reg = <0x48241000 0x1000>, 103 reg = <0x48241000 0x1000>,
104 <0x48240100 0x0100>; 104 <0x48240100 0x0100>;
105 }; 105 };
106 106
107 uart1: serial@0x4806a000 { 107 uart1: serial@4806a000 {
108 compatible = "ti,omap4-uart"; 108 compatible = "ti,omap4-uart";
109 ti,hwmods = "uart1"; 109 ti,hwmods = "uart1";
110 clock-frequency = <48000000>; 110 clock-frequency = <48000000>;
111 }; 111 };
112 112
113 uart2: serial@0x4806c000 { 113 uart2: serial@4806c000 {
114 compatible = "ti,omap4-uart"; 114 compatible = "ti,omap4-uart";
115 ti,hwmods = "uart2"; 115 ti,hwmods = "uart2";
116 clock-frequency = <48000000>; 116 clock-frequency = <48000000>;
117 }; 117 };
118 118
119 uart3: serial@0x48020000 { 119 uart3: serial@48020000 {
120 compatible = "ti,omap4-uart"; 120 compatible = "ti,omap4-uart";
121 ti,hwmods = "uart3"; 121 ti,hwmods = "uart3";
122 clock-frequency = <48000000>; 122 clock-frequency = <48000000>;
123 }; 123 };
124 124
125 uart4: serial@0x4806e000 { 125 uart4: serial@4806e000 {
126 compatible = "ti,omap4-uart"; 126 compatible = "ti,omap4-uart";
127 ti,hwmods = "uart4"; 127 ti,hwmods = "uart4";
128 clock-frequency = <48000000>; 128 clock-frequency = <48000000>;
129 }; 129 };
130
131 i2c1: i2c@48070000 {
132 compatible = "ti,omap4-i2c";
133 #address-cells = <1>;
134 #size-cells = <0>;
135 ti,hwmods = "i2c1";
136 };
137
138 i2c2: i2c@48072000 {
139 compatible = "ti,omap4-i2c";
140 #address-cells = <1>;
141 #size-cells = <0>;
142 ti,hwmods = "i2c2";
143 };
144
145 i2c3: i2c@48060000 {
146 compatible = "ti,omap4-i2c";
147 #address-cells = <1>;
148 #size-cells = <0>;
149 ti,hwmods = "i2c3";
150 };
151
152 i2c4: i2c@48350000 {
153 compatible = "ti,omap4-i2c";
154 #address-cells = <1>;
155 #size-cells = <0>;
156 ti,hwmods = "i2c4";
157 };
130 }; 158 };
131}; 159};
diff --git a/arch/arm/boot/dts/pxa168-aspenite.dts b/arch/arm/boot/dts/pxa168-aspenite.dts
new file mode 100644
index 00000000000..e762facb3fa
--- /dev/null
+++ b/arch/arm/boot/dts/pxa168-aspenite.dts
@@ -0,0 +1,38 @@
1/*
2 * Copyright (C) 2012 Marvell Technology Group Ltd.
3 * Author: Haojian Zhuang <haojian.zhuang@marvell.com>
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 * publishhed by the Free Software Foundation.
8 */
9
10/dts-v1/;
11/include/ "pxa168.dtsi"
12
13/ {
14 model = "Marvell PXA168 Aspenite Development Board";
15 compatible = "mrvl,pxa168-aspenite", "mrvl,pxa168";
16
17 chosen {
18 bootargs = "console=ttyS0,115200 root=/dev/nfs nfsroot=192.168.1.100:/nfsroot/ ip=192.168.1.101:192.168.1.100::255.255.255.0::eth0:on";
19 };
20
21 memory {
22 reg = <0x00000000 0x04000000>;
23 };
24
25 soc {
26 apb@d4000000 {
27 uart1: uart@d4017000 {
28 status = "okay";
29 };
30 twsi1: i2c@d4011000 {
31 status = "okay";
32 };
33 rtc: rtc@d4010000 {
34 status = "okay";
35 };
36 };
37 };
38};
diff --git a/arch/arm/boot/dts/pxa168.dtsi b/arch/arm/boot/dts/pxa168.dtsi
new file mode 100644
index 00000000000..d32d5128f22
--- /dev/null
+++ b/arch/arm/boot/dts/pxa168.dtsi
@@ -0,0 +1,98 @@
1/*
2 * Copyright (C) 2012 Marvell Technology Group Ltd.
3 * Author: Haojian Zhuang <haojian.zhuang@marvell.com>
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 * publishhed by the Free Software Foundation.
8 */
9
10/include/ "skeleton.dtsi"
11
12/ {
13 aliases {
14 serial0 = &uart1;
15 serial1 = &uart2;
16 serial2 = &uart3;
17 i2c0 = &twsi1;
18 i2c1 = &twsi2;
19 };
20
21 intc: intc-interrupt-controller@d4282000 {
22 compatible = "mrvl,mmp-intc", "mrvl,intc";
23 interrupt-controller;
24 #interrupt-cells = <1>;
25 reg = <0xd4282000 0x1000>;
26 };
27
28 soc {
29 #address-cells = <1>;
30 #size-cells = <1>;
31 compatible = "simple-bus";
32 interrupt-parent = <&intc>;
33 ranges;
34
35 apb@d4000000 { /* APB */
36 compatible = "mrvl,apb-bus", "simple-bus";
37 #address-cells = <1>;
38 #size-cells = <1>;
39 reg = <0xd4000000 0x00200000>;
40 ranges;
41
42 uart1: uart@d4017000 {
43 compatible = "mrvl,mmp-uart", "mrvl,pxa-uart";
44 reg = <0xd4017000 0x1000>;
45 interrupts = <27>;
46 status = "disabled";
47 };
48
49 uart2: uart@d4018000 {
50 compatible = "mrvl,mmp-uart", "mrvl,pxa-uart";
51 reg = <0xd4018000 0x1000>;
52 interrupts = <28>;
53 status = "disabled";
54 };
55
56 uart3: uart@d4026000 {
57 compatible = "mrvl,mmp-uart", "mrvl,pxa-uart";
58 reg = <0xd4026000 0x1000>;
59 interrupts = <29>;
60 status = "disabled";
61 };
62
63 gpio: gpio@d4019000 {
64 compatible = "mrvl,mmp-gpio", "mrvl,pxa-gpio";
65 reg = <0xd4019000 0x1000>;
66 interrupts = <49>;
67 interrupt-names = "gpio_mux";
68 gpio-controller;
69 #gpio-cells = <1>;
70 interrupt-controller;
71 #interrupt-cells = <1>;
72 };
73
74 twsi1: i2c@d4011000 {
75 compatible = "mrvl,mmp-twsi", "mrvl,pxa-i2c";
76 reg = <0xd4011000 0x1000>;
77 interrupts = <7>;
78 mrvl,i2c-fast-mode;
79 status = "disabled";
80 };
81
82 twsi2: i2c@d4025000 {
83 compatible = "mrvl,mmp-twsi", "mrvl,pxa-i2c";
84 reg = <0xd4025000 0x1000>;
85 interrupts = <58>;
86 status = "disabled";
87 };
88
89 rtc: rtc@d4010000 {
90 compatible = "mrvl,mmp-rtc";
91 reg = <0xd4010000 0x1000>;
92 interrupts = <5 6>;
93 interrupt-names = "rtc 1Hz", "rtc alarm";
94 status = "disabled";
95 };
96 };
97 };
98};
diff --git a/arch/arm/boot/dts/snowball.dts b/arch/arm/boot/dts/snowball.dts
new file mode 100644
index 00000000000..359c6d67915
--- /dev/null
+++ b/arch/arm/boot/dts/snowball.dts
@@ -0,0 +1,139 @@
1/*
2 * Copyright 2011 ST-Ericsson AB
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/ "db8500.dtsi"
14
15/ {
16 model = "Calao Systems Snowball platform with device tree";
17 compatible = "calaosystems,snowball-a9500";
18
19 memory {
20 reg = <0x00000000 0x20000000>;
21 };
22
23 gpio_keys {
24 compatible = "gpio-keys";
25 #address-cells = <1>;
26 #size-cells = <0>;
27
28 button@1 {
29 debounce_interval = <50>;
30 wakeup = <1>;
31 linux,code = <2>;
32 label = "userpb";
33 gpios = <&gpio1 0>;
34 };
35 button@2 {
36 debounce_interval = <50>;
37 wakeup = <1>;
38 linux,code = <3>;
39 label = "userpb";
40 gpios = <&gpio4 23>;
41 };
42 button@3 {
43 debounce_interval = <50>;
44 wakeup = <1>;
45 linux,code = <4>;
46 label = "userpb";
47 gpios = <&gpio4 23>;
48 };
49 button@4 {
50 debounce_interval = <50>;
51 wakeup = <1>;
52 linux,code = <5>;
53 label = "userpb";
54 gpios = <&gpio5 1>;
55 };
56 button@5 {
57 debounce_interval = <50>;
58 wakeup = <1>;
59 linux,code = <6>;
60 label = "userpb";
61 gpios = <&gpio5 2>;
62 };
63 };
64
65 leds {
66 compatible = "gpio-leds";
67 used-led {
68 label = "user_led";
69 gpios = <&gpio4 14>;
70 };
71 };
72
73 soc-u9500 {
74
75 external-bus@50000000 {
76 compatible = "simple-bus";
77 reg = <0x50000000 0x10000000>;
78 #address-cells = <1>;
79 #size-cells = <1>;
80 ranges;
81
82 ethernet@50000000 {
83 compatible = "smsc,9111";
84 reg = <0x50000000 0x10000>;
85 interrupts = <12>;
86 interrupt-parent = <&gpio4>;
87 };
88 };
89
90 sdi@80126000 {
91 status = "enabled";
92 cd-gpios = <&gpio6 26>;
93 };
94
95 sdi@80114000 {
96 status = "enabled";
97 };
98
99 uart@80120000 {
100 status = "okay";
101 };
102
103 uart@80121000 {
104 status = "okay";
105 };
106
107 uart@80007000 {
108 status = "okay";
109 };
110
111 i2c@80004000 {
112 tc3589x@42 {
113 //compatible = "tc3589x";
114 reg = <0x42>;
115 interrupts = <25>;
116 interrupt-parent = <&gpio6>;
117 };
118 tps61052@33 {
119 //compatible = "tps61052";
120 reg = <0x33>;
121 };
122 };
123
124 i2c@80128000 {
125 lp5521@0x33 {
126 // compatible = "lp5521";
127 reg = <0x33>;
128 };
129 lp5521@0x34 {
130 // compatible = "lp5521";
131 reg = <0x34>;
132 };
133 bh1780@0x29 {
134 // compatible = "rohm,bh1780gli";
135 reg = <0x33>;
136 };
137 };
138 };
139};
diff --git a/arch/arm/boot/dts/spear600-evb.dts b/arch/arm/boot/dts/spear600-evb.dts
new file mode 100644
index 00000000000..636292e18c9
--- /dev/null
+++ b/arch/arm/boot/dts/spear600-evb.dts
@@ -0,0 +1,47 @@
1/*
2 * Copyright 2012 Stefan Roese <sr@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/ "spear600.dtsi"
14
15/ {
16 model = "ST SPEAr600 Evaluation Board";
17 compatible = "st,spear600-evb", "st,spear600";
18 #address-cells = <1>;
19 #size-cells = <1>;
20
21 memory {
22 device_type = "memory";
23 reg = <0 0x10000000>;
24 };
25
26 ahb {
27 gmac: ethernet@e0800000 {
28 phy-mode = "gmii";
29 status = "okay";
30 };
31
32 apb {
33 serial@d0000000 {
34 status = "okay";
35 };
36
37 serial@d0080000 {
38 status = "okay";
39 };
40
41 i2c@d0200000 {
42 clock-frequency = <400000>;
43 status = "okay";
44 };
45 };
46 };
47};
diff --git a/arch/arm/boot/dts/spear600.dtsi b/arch/arm/boot/dts/spear600.dtsi
new file mode 100644
index 00000000000..ebe0885a2b9
--- /dev/null
+++ b/arch/arm/boot/dts/spear600.dtsi
@@ -0,0 +1,174 @@
1/*
2 * Copyright 2012 Stefan Roese <sr@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/include/ "skeleton.dtsi"
13
14/ {
15 compatible = "st,spear600";
16
17 cpus {
18 cpu@0 {
19 compatible = "arm,arm926ejs";
20 };
21 };
22
23 memory {
24 device_type = "memory";
25 reg = <0 0x40000000>;
26 };
27
28 ahb {
29 #address-cells = <1>;
30 #size-cells = <1>;
31 compatible = "simple-bus";
32 ranges = <0xd0000000 0xd0000000 0x30000000>;
33
34 vic0: interrupt-controller@f1100000 {
35 compatible = "arm,pl190-vic";
36 interrupt-controller;
37 reg = <0xf1100000 0x1000>;
38 #interrupt-cells = <1>;
39 };
40
41 vic1: interrupt-controller@f1000000 {
42 compatible = "arm,pl190-vic";
43 interrupt-controller;
44 reg = <0xf1000000 0x1000>;
45 #interrupt-cells = <1>;
46 };
47
48 gmac: ethernet@e0800000 {
49 compatible = "st,spear600-gmac";
50 reg = <0xe0800000 0x8000>;
51 interrupt-parent = <&vic1>;
52 interrupts = <24 23>;
53 interrupt-names = "macirq", "eth_wake_irq";
54 status = "disabled";
55 };
56
57 fsmc: flash@d1800000 {
58 compatible = "st,spear600-fsmc-nand";
59 #address-cells = <1>;
60 #size-cells = <1>;
61 reg = <0xd1800000 0x1000 /* FSMC Register */
62 0xd2000000 0x4000>; /* NAND Base */
63 reg-names = "fsmc_regs", "nand_data";
64 st,ale-off = <0x20000>;
65 st,cle-off = <0x10000>;
66 status = "disabled";
67 };
68
69 smi: flash@fc000000 {
70 compatible = "st,spear600-smi";
71 #address-cells = <1>;
72 #size-cells = <1>;
73 reg = <0xfc000000 0x1000>;
74 interrupt-parent = <&vic1>;
75 interrupts = <12>;
76 status = "disabled";
77 };
78
79 ehci@e1800000 {
80 compatible = "st,spear600-ehci", "usb-ehci";
81 reg = <0xe1800000 0x1000>;
82 interrupt-parent = <&vic1>;
83 interrupts = <27>;
84 status = "disabled";
85 };
86
87 ehci@e2000000 {
88 compatible = "st,spear600-ehci", "usb-ehci";
89 reg = <0xe2000000 0x1000>;
90 interrupt-parent = <&vic1>;
91 interrupts = <29>;
92 status = "disabled";
93 };
94
95 ohci@e1900000 {
96 compatible = "st,spear600-ohci", "usb-ohci";
97 reg = <0xe1900000 0x1000>;
98 interrupt-parent = <&vic1>;
99 interrupts = <26>;
100 status = "disabled";
101 };
102
103 ohci@e2100000 {
104 compatible = "st,spear600-ohci", "usb-ohci";
105 reg = <0xe2100000 0x1000>;
106 interrupt-parent = <&vic1>;
107 interrupts = <28>;
108 status = "disabled";
109 };
110
111 apb {
112 #address-cells = <1>;
113 #size-cells = <1>;
114 compatible = "simple-bus";
115 ranges = <0xd0000000 0xd0000000 0x30000000>;
116
117 serial@d0000000 {
118 compatible = "arm,pl011", "arm,primecell";
119 reg = <0xd0000000 0x1000>;
120 interrupt-parent = <&vic0>;
121 interrupts = <24>;
122 status = "disabled";
123 };
124
125 serial@d0080000 {
126 compatible = "arm,pl011", "arm,primecell";
127 reg = <0xd0080000 0x1000>;
128 interrupt-parent = <&vic0>;
129 interrupts = <25>;
130 status = "disabled";
131 };
132
133 /* local/cpu GPIO */
134 gpio0: gpio@f0100000 {
135 #gpio-cells = <2>;
136 compatible = "arm,pl061", "arm,primecell";
137 gpio-controller;
138 reg = <0xf0100000 0x1000>;
139 interrupt-parent = <&vic0>;
140 interrupts = <18>;
141 };
142
143 /* basic GPIO */
144 gpio1: gpio@fc980000 {
145 #gpio-cells = <2>;
146 compatible = "arm,pl061", "arm,primecell";
147 gpio-controller;
148 reg = <0xfc980000 0x1000>;
149 interrupt-parent = <&vic1>;
150 interrupts = <19>;
151 };
152
153 /* appl GPIO */
154 gpio2: gpio@d8100000 {
155 #gpio-cells = <2>;
156 compatible = "arm,pl061", "arm,primecell";
157 gpio-controller;
158 reg = <0xd8100000 0x1000>;
159 interrupt-parent = <&vic1>;
160 interrupts = <4>;
161 };
162
163 i2c@d0200000 {
164 #address-cells = <1>;
165 #size-cells = <0>;
166 compatible = "snps,designware-i2c";
167 reg = <0xd0200000 0x1000>;
168 interrupt-parent = <&vic0>;
169 interrupts = <28>;
170 status = "disabled";
171 };
172 };
173 };
174};
diff --git a/arch/arm/boot/dts/tegra-cardhu.dts b/arch/arm/boot/dts/tegra-cardhu.dts
index 70c41fc897d..ac3fb755845 100644
--- a/arch/arm/boot/dts/tegra-cardhu.dts
+++ b/arch/arm/boot/dts/tegra-cardhu.dts
@@ -14,6 +14,22 @@
14 clock-frequency = < 408000000 >; 14 clock-frequency = < 408000000 >;
15 }; 15 };
16 16
17 serial@70006040 {
18 status = "disable";
19 };
20
21 serial@70006200 {
22 status = "disable";
23 };
24
25 serial@70006300 {
26 status = "disable";
27 };
28
29 serial@70006400 {
30 status = "disable";
31 };
32
17 i2c@7000c000 { 33 i2c@7000c000 {
18 clock-frequency = <100000>; 34 clock-frequency = <100000>;
19 }; 35 };
@@ -33,4 +49,22 @@
33 i2c@7000d000 { 49 i2c@7000d000 {
34 clock-frequency = <100000>; 50 clock-frequency = <100000>;
35 }; 51 };
52
53 sdhci@78000000 {
54 cd-gpios = <&gpio 69 0>; /* gpio PI5 */
55 wp-gpios = <&gpio 155 0>; /* gpio PT3 */
56 power-gpios = <&gpio 31 0>; /* gpio PD7 */
57 };
58
59 sdhci@78000200 {
60 status = "disable";
61 };
62
63 sdhci@78000400 {
64 status = "disable";
65 };
66
67 sdhci@78000400 {
68 support-8bit;
69 };
36}; 70};
diff --git a/arch/arm/boot/dts/tegra-harmony.dts b/arch/arm/boot/dts/tegra-harmony.dts
index 80afa1b70b8..6e8447dc020 100644
--- a/arch/arm/boot/dts/tegra-harmony.dts
+++ b/arch/arm/boot/dts/tegra-harmony.dts
@@ -10,19 +10,25 @@
10 reg = < 0x00000000 0x40000000 >; 10 reg = < 0x00000000 0x40000000 >;
11 }; 11 };
12 12
13 pmc@7000f400 {
14 nvidia,invert-interrupt;
15 };
16
13 i2c@7000c000 { 17 i2c@7000c000 {
14 clock-frequency = <400000>; 18 clock-frequency = <400000>;
15 19
16 codec: wm8903@1a { 20 wm8903: wm8903@1a {
17 compatible = "wlf,wm8903"; 21 compatible = "wlf,wm8903";
18 reg = <0x1a>; 22 reg = <0x1a>;
19 interrupts = < 347 >; 23 interrupt-parent = <&gpio>;
24 interrupts = < 187 0x04 >;
20 25
21 gpio-controller; 26 gpio-controller;
22 #gpio-cells = <2>; 27 #gpio-cells = <2>;
23 28
24 /* 0x8000 = Not configured */ 29 micdet-cfg = <0>;
25 gpio-cfg = < 0x8000 0x8000 0 0x8000 0x8000 >; 30 micdet-delay = <100>;
31 gpio-cfg = < 0xffffffff 0xffffffff 0 0xffffffff 0xffffffff >;
26 }; 32 };
27 }; 33 };
28 34
@@ -38,13 +44,32 @@
38 clock-frequency = <400000>; 44 clock-frequency = <400000>;
39 }; 45 };
40 46
41 sound { 47 i2s@70002a00 {
42 compatible = "nvidia,harmony-sound", "nvidia,tegra-wm8903"; 48 status = "disable";
49 };
43 50
44 spkr-en-gpios = <&codec 2 0>; 51 sound {
45 hp-det-gpios = <&gpio 178 0>; 52 compatible = "nvidia,tegra-audio-wm8903-harmony",
46 int-mic-en-gpios = <&gpio 184 0>; 53 "nvidia,tegra-audio-wm8903";
47 ext-mic-en-gpios = <&gpio 185 0>; 54 nvidia,model = "NVIDIA Tegra Harmony";
55
56 nvidia,audio-routing =
57 "Headphone Jack", "HPOUTR",
58 "Headphone Jack", "HPOUTL",
59 "Int Spk", "ROP",
60 "Int Spk", "RON",
61 "Int Spk", "LOP",
62 "Int Spk", "LON",
63 "Mic Jack", "MICBIAS",
64 "IN1L", "Mic Jack";
65
66 nvidia,i2s-controller = <&tegra_i2s1>;
67 nvidia,audio-codec = <&wm8903>;
68
69 nvidia,spkr-en-gpios = <&wm8903 2 0>;
70 nvidia,hp-det-gpios = <&gpio 178 0>; /* gpio PW2 */
71 nvidia,int-mic-en-gpios = <&gpio 184 0>; /*gpio PX0 */
72 nvidia,ext-mic-en-gpios = <&gpio 185 0>; /* gpio PX1 */
48 }; 73 };
49 74
50 serial@70006000 { 75 serial@70006000 {
diff --git a/arch/arm/boot/dts/tegra-paz00.dts b/arch/arm/boot/dts/tegra-paz00.dts
index 825d2957da0..6c02abb469d 100644
--- a/arch/arm/boot/dts/tegra-paz00.dts
+++ b/arch/arm/boot/dts/tegra-paz00.dts
@@ -12,6 +12,13 @@
12 12
13 i2c@7000c000 { 13 i2c@7000c000 {
14 clock-frequency = <400000>; 14 clock-frequency = <400000>;
15
16 alc5632: alc5632@1e {
17 compatible = "realtek,alc5632";
18 reg = <0x1e>;
19 gpio-controller;
20 #gpio-cells = <2>;
21 };
15 }; 22 };
16 23
17 i2c@7000c400 { 24 i2c@7000c400 {
@@ -35,6 +42,35 @@
35 42
36 i2c@7000d000 { 43 i2c@7000d000 {
37 clock-frequency = <400000>; 44 clock-frequency = <400000>;
45
46 adt7461@4c {
47 compatible = "adi,adt7461";
48 reg = <0x4c>;
49 };
50 };
51
52 i2s@70002a00 {
53 status = "disable";
54 };
55
56 sound {
57 compatible = "nvidia,tegra-audio-alc5632-paz00",
58 "nvidia,tegra-audio-alc5632";
59
60 nvidia,model = "Compal PAZ00";
61
62 nvidia,audio-routing =
63 "Int Spk", "SPKOUT",
64 "Int Spk", "SPKOUTN",
65 "Headset Mic", "MICBIAS1",
66 "MIC1", "Headset Mic",
67 "Headset Stereophone", "HPR",
68 "Headset Stereophone", "HPL",
69 "DMICDAT", "Digital Mic";
70
71 nvidia,audio-codec = <&alc5632>;
72 nvidia,i2s-controller = <&tegra_i2s1>;
73 nvidia,hp-det-gpios = <&gpio 178 0>; /* gpio PW2 */
38 }; 74 };
39 75
40 serial@70006000 { 76 serial@70006000 {
@@ -74,4 +110,25 @@
74 sdhci@c8000600 { 110 sdhci@c8000600 {
75 support-8bit; 111 support-8bit;
76 }; 112 };
113
114 gpio-keys {
115 compatible = "gpio-keys";
116
117 power {
118 label = "Power";
119 gpios = <&gpio 79 1>; /* gpio PJ7, active low */
120 linux,code = <116>; /* KEY_POWER */
121 gpio-key,wakeup;
122 };
123 };
124
125 gpio-leds {
126 compatible = "gpio-leds";
127
128 wifi {
129 label = "wifi-led";
130 gpios = <&gpio 24 0>;
131 linux,default-trigger = "rfkill0";
132 };
133 };
77}; 134};
diff --git a/arch/arm/boot/dts/tegra-seaboard.dts b/arch/arm/boot/dts/tegra-seaboard.dts
index b55a02e34ba..dbf1c5a171c 100644
--- a/arch/arm/boot/dts/tegra-seaboard.dts
+++ b/arch/arm/boot/dts/tegra-seaboard.dts
@@ -13,6 +13,20 @@
13 13
14 i2c@7000c000 { 14 i2c@7000c000 {
15 clock-frequency = <400000>; 15 clock-frequency = <400000>;
16
17 wm8903: wm8903@1a {
18 compatible = "wlf,wm8903";
19 reg = <0x1a>;
20 interrupt-parent = <&gpio>;
21 interrupts = < 187 0x04 >;
22
23 gpio-controller;
24 #gpio-cells = <2>;
25
26 micdet-cfg = <0>;
27 micdet-delay = <100>;
28 gpio-cfg = < 0xffffffff 0xffffffff 0 0xffffffff 0xffffffff >;
29 };
16 }; 30 };
17 31
18 i2c@7000c400 { 32 i2c@7000c400 {
@@ -32,6 +46,32 @@
32 }; 46 };
33 }; 47 };
34 48
49 i2s@70002a00 {
50 status = "disable";
51 };
52
53 sound {
54 compatible = "nvidia,tegra-audio-wm8903-seaboard",
55 "nvidia,tegra-audio-wm8903";
56 nvidia,model = "NVIDIA Tegra Seaboard";
57
58 nvidia,audio-routing =
59 "Headphone Jack", "HPOUTR",
60 "Headphone Jack", "HPOUTL",
61 "Int Spk", "ROP",
62 "Int Spk", "RON",
63 "Int Spk", "LOP",
64 "Int Spk", "LON",
65 "Mic Jack", "MICBIAS",
66 "IN1R", "Mic Jack";
67
68 nvidia,i2s-controller = <&tegra_i2s1>;
69 nvidia,audio-codec = <&wm8903>;
70
71 nvidia,spkr-en-gpios = <&wm8903 2 0>;
72 nvidia,hp-det-gpios = <&gpio 185 0>; /* gpio PX1 */
73 };
74
35 serial@70006000 { 75 serial@70006000 {
36 status = "disable"; 76 status = "disable";
37 }; 77 };
@@ -72,6 +112,7 @@
72 112
73 usb@c5000000 { 113 usb@c5000000 {
74 nvidia,vbus-gpio = <&gpio 24 0>; /* PD0 */ 114 nvidia,vbus-gpio = <&gpio 24 0>; /* PD0 */
115 dr_mode = "otg";
75 }; 116 };
76 117
77 gpio-keys { 118 gpio-keys {
@@ -93,4 +134,42 @@
93 gpio-key,wakeup; 134 gpio-key,wakeup;
94 }; 135 };
95 }; 136 };
137
138 emc@7000f400 {
139 emc-table@190000 {
140 reg = < 190000 >;
141 compatible = "nvidia,tegra20-emc-table";
142 clock-frequency = < 190000 >;
143 nvidia,emc-registers = < 0x0000000c 0x00000026
144 0x00000009 0x00000003 0x00000004 0x00000004
145 0x00000002 0x0000000c 0x00000003 0x00000003
146 0x00000002 0x00000001 0x00000004 0x00000005
147 0x00000004 0x00000009 0x0000000d 0x0000059f
148 0x00000000 0x00000003 0x00000003 0x00000003
149 0x00000003 0x00000001 0x0000000b 0x000000c8
150 0x00000003 0x00000007 0x00000004 0x0000000f
151 0x00000002 0x00000000 0x00000000 0x00000002
152 0x00000000 0x00000000 0x00000083 0xa06204ae
153 0x007dc010 0x00000000 0x00000000 0x00000000
154 0x00000000 0x00000000 0x00000000 0x00000000 >;
155 };
156
157 emc-table@380000 {
158 reg = < 380000 >;
159 compatible = "nvidia,tegra20-emc-table";
160 clock-frequency = < 380000 >;
161 nvidia,emc-registers = < 0x00000017 0x0000004b
162 0x00000012 0x00000006 0x00000004 0x00000005
163 0x00000003 0x0000000c 0x00000006 0x00000006
164 0x00000003 0x00000001 0x00000004 0x00000005
165 0x00000004 0x00000009 0x0000000d 0x00000b5f
166 0x00000000 0x00000003 0x00000003 0x00000006
167 0x00000006 0x00000001 0x00000011 0x000000c8
168 0x00000003 0x0000000e 0x00000007 0x0000000f
169 0x00000002 0x00000000 0x00000000 0x00000002
170 0x00000000 0x00000000 0x00000083 0xe044048b
171 0x007d8010 0x00000000 0x00000000 0x00000000
172 0x00000000 0x00000000 0x00000000 0x00000000 >;
173 };
174 };
96}; 175};
diff --git a/arch/arm/boot/dts/tegra-trimslice.dts b/arch/arm/boot/dts/tegra-trimslice.dts
index 3b3ee7db99f..252476867b5 100644
--- a/arch/arm/boot/dts/tegra-trimslice.dts
+++ b/arch/arm/boot/dts/tegra-trimslice.dts
@@ -26,6 +26,18 @@
26 status = "disable"; 26 status = "disable";
27 }; 27 };
28 28
29 i2s@70002800 {
30 status = "disable";
31 };
32
33 i2s@70002a00 {
34 status = "disable";
35 };
36
37 das@70000c00 {
38 status = "disable";
39 };
40
29 serial@70006000 { 41 serial@70006000 {
30 clock-frequency = < 216000000 >; 42 clock-frequency = < 216000000 >;
31 }; 43 };
diff --git a/arch/arm/boot/dts/tegra-ventana.dts b/arch/arm/boot/dts/tegra-ventana.dts
index c7d3b87f29d..2dcff8728e9 100644
--- a/arch/arm/boot/dts/tegra-ventana.dts
+++ b/arch/arm/boot/dts/tegra-ventana.dts
@@ -12,6 +12,20 @@
12 12
13 i2c@7000c000 { 13 i2c@7000c000 {
14 clock-frequency = <400000>; 14 clock-frequency = <400000>;
15
16 wm8903: wm8903@1a {
17 compatible = "wlf,wm8903";
18 reg = <0x1a>;
19 interrupt-parent = <&gpio>;
20 interrupts = < 187 0x04 >;
21
22 gpio-controller;
23 #gpio-cells = <2>;
24
25 micdet-cfg = <0>;
26 micdet-delay = <100>;
27 gpio-cfg = < 0xffffffff 0xffffffff 0 0xffffffff 0xffffffff >;
28 };
15 }; 29 };
16 30
17 i2c@7000c400 { 31 i2c@7000c400 {
@@ -26,6 +40,34 @@
26 clock-frequency = <400000>; 40 clock-frequency = <400000>;
27 }; 41 };
28 42
43 i2s@70002a00 {
44 status = "disable";
45 };
46
47 sound {
48 compatible = "nvidia,tegra-audio-wm8903-ventana",
49 "nvidia,tegra-audio-wm8903";
50 nvidia,model = "NVIDIA Tegra Ventana";
51
52 nvidia,audio-routing =
53 "Headphone Jack", "HPOUTR",
54 "Headphone Jack", "HPOUTL",
55 "Int Spk", "ROP",
56 "Int Spk", "RON",
57 "Int Spk", "LOP",
58 "Int Spk", "LON",
59 "Mic Jack", "MICBIAS",
60 "IN1L", "Mic Jack";
61
62 nvidia,i2s-controller = <&tegra_i2s1>;
63 nvidia,audio-codec = <&wm8903>;
64
65 nvidia,spkr-en-gpios = <&wm8903 2 0>;
66 nvidia,hp-det-gpios = <&gpio 178 0>; /* gpio PW2 */
67 nvidia,int-mic-en-gpios = <&gpio 184 0>; /*gpio PX0 */
68 nvidia,ext-mic-en-gpios = <&gpio 185 0>; /* gpio PX1 */
69 };
70
29 serial@70006000 { 71 serial@70006000 {
30 status = "disable"; 72 status = "disable";
31 }; 73 };
diff --git a/arch/arm/boot/dts/tegra20.dtsi b/arch/arm/boot/dts/tegra20.dtsi
index 3da7afd4532..108e894a892 100644
--- a/arch/arm/boot/dts/tegra20.dtsi
+++ b/arch/arm/boot/dts/tegra20.dtsi
@@ -4,6 +4,11 @@
4 compatible = "nvidia,tegra20"; 4 compatible = "nvidia,tegra20";
5 interrupt-parent = <&intc>; 5 interrupt-parent = <&intc>;
6 6
7 pmc@7000f400 {
8 compatible = "nvidia,tegra20-pmc";
9 reg = <0x7000e400 0x400>;
10 };
11
7 intc: interrupt-controller@50041000 { 12 intc: interrupt-controller@50041000 {
8 compatible = "arm,cortex-a9-gic"; 13 compatible = "arm,cortex-a9-gic";
9 interrupt-controller; 14 interrupt-controller;
@@ -12,6 +17,33 @@
12 < 0x50040100 0x0100 >; 17 < 0x50040100 0x0100 >;
13 }; 18 };
14 19
20 pmu {
21 compatible = "arm,cortex-a9-pmu";
22 interrupts = <0 56 0x04
23 0 57 0x04>;
24 };
25
26 apbdma: dma@6000a000 {
27 compatible = "nvidia,tegra20-apbdma";
28 reg = <0x6000a000 0x1200>;
29 interrupts = < 0 104 0x04
30 0 105 0x04
31 0 106 0x04
32 0 107 0x04
33 0 108 0x04
34 0 109 0x04
35 0 110 0x04
36 0 111 0x04
37 0 112 0x04
38 0 113 0x04
39 0 114 0x04
40 0 115 0x04
41 0 116 0x04
42 0 117 0x04
43 0 118 0x04
44 0 119 0x04 >;
45 };
46
15 i2c@7000c000 { 47 i2c@7000c000 {
16 #address-cells = <1>; 48 #address-cells = <1>;
17 #size-cells = <0>; 49 #size-cells = <0>;
@@ -44,18 +76,18 @@
44 interrupts = < 0 53 0x04 >; 76 interrupts = < 0 53 0x04 >;
45 }; 77 };
46 78
47 i2s@70002800 { 79 tegra_i2s1: i2s@70002800 {
48 compatible = "nvidia,tegra20-i2s"; 80 compatible = "nvidia,tegra20-i2s";
49 reg = <0x70002800 0x200>; 81 reg = <0x70002800 0x200>;
50 interrupts = < 0 13 0x04 >; 82 interrupts = < 0 13 0x04 >;
51 dma-channel = < 2 >; 83 nvidia,dma-request-selector = < &apbdma 2 >;
52 }; 84 };
53 85
54 i2s@70002a00 { 86 tegra_i2s2: i2s@70002a00 {
55 compatible = "nvidia,tegra20-i2s"; 87 compatible = "nvidia,tegra20-i2s";
56 reg = <0x70002a00 0x200>; 88 reg = <0x70002a00 0x200>;
57 interrupts = < 0 3 0x04 >; 89 interrupts = < 0 3 0x04 >;
58 dma-channel = < 1 >; 90 nvidia,dma-request-selector = < &apbdma 1 >;
59 }; 91 };
60 92
61 das@70000c00 { 93 das@70000c00 {
@@ -75,6 +107,8 @@
75 0 89 0x04 >; 107 0 89 0x04 >;
76 #gpio-cells = <2>; 108 #gpio-cells = <2>;
77 gpio-controller; 109 gpio-controller;
110 #interrupt-cells = <2>;
111 interrupt-controller;
78 }; 112 };
79 113
80 pinmux: pinmux@70000000 { 114 pinmux: pinmux@70000000 {
@@ -120,6 +154,13 @@
120 interrupts = < 0 91 0x04 >; 154 interrupts = < 0 91 0x04 >;
121 }; 155 };
122 156
157 emc@7000f400 {
158 #address-cells = <1>;
159 #size-cells = <0>;
160 compatible = "nvidia,tegra20-emc";
161 reg = <0x7000f400 0x200>;
162 };
163
123 sdhci@c8000000 { 164 sdhci@c8000000 {
124 compatible = "nvidia,tegra20-sdhci"; 165 compatible = "nvidia,tegra20-sdhci";
125 reg = <0xc8000000 0x200>; 166 reg = <0xc8000000 0x200>;
@@ -149,6 +190,7 @@
149 reg = <0xc5000000 0x4000>; 190 reg = <0xc5000000 0x4000>;
150 interrupts = < 0 20 0x04 >; 191 interrupts = < 0 20 0x04 >;
151 phy_type = "utmi"; 192 phy_type = "utmi";
193 nvidia,has-legacy-mode;
152 }; 194 };
153 195
154 usb@c5004000 { 196 usb@c5004000 {
diff --git a/arch/arm/boot/dts/tegra30.dtsi b/arch/arm/boot/dts/tegra30.dtsi
index ee7db9892e0..62a7b39f1c9 100644
--- a/arch/arm/boot/dts/tegra30.dtsi
+++ b/arch/arm/boot/dts/tegra30.dtsi
@@ -4,6 +4,11 @@
4 compatible = "nvidia,tegra30"; 4 compatible = "nvidia,tegra30";
5 interrupt-parent = <&intc>; 5 interrupt-parent = <&intc>;
6 6
7 pmc@7000f400 {
8 compatible = "nvidia,tegra20-pmc", "nvidia,tegra30-pmc";
9 reg = <0x7000e400 0x400>;
10 };
11
7 intc: interrupt-controller@50041000 { 12 intc: interrupt-controller@50041000 {
8 compatible = "arm,cortex-a9-gic"; 13 compatible = "arm,cortex-a9-gic";
9 interrupt-controller; 14 interrupt-controller;
@@ -12,6 +17,51 @@
12 < 0x50040100 0x0100 >; 17 < 0x50040100 0x0100 >;
13 }; 18 };
14 19
20 pmu {
21 compatible = "arm,cortex-a9-pmu";
22 interrupts = <0 144 0x04
23 0 145 0x04
24 0 146 0x04
25 0 147 0x04>;
26 };
27
28 apbdma: dma@6000a000 {
29 compatible = "nvidia,tegra30-apbdma", "nvidia,tegra20-apbdma";
30 reg = <0x6000a000 0x1400>;
31 interrupts = < 0 104 0x04
32 0 105 0x04
33 0 106 0x04
34 0 107 0x04
35 0 108 0x04
36 0 109 0x04
37 0 110 0x04
38 0 111 0x04
39 0 112 0x04
40 0 113 0x04
41 0 114 0x04
42 0 115 0x04
43 0 116 0x04
44 0 117 0x04
45 0 118 0x04
46 0 119 0x04
47 0 128 0x04
48 0 129 0x04
49 0 130 0x04
50 0 131 0x04
51 0 132 0x04
52 0 133 0x04
53 0 134 0x04
54 0 135 0x04
55 0 136 0x04
56 0 137 0x04
57 0 138 0x04
58 0 139 0x04
59 0 140 0x04
60 0 141 0x04
61 0 142 0x04
62 0 143 0x04 >;
63 };
64
15 i2c@7000c000 { 65 i2c@7000c000 {
16 #address-cells = <1>; 66 #address-cells = <1>;
17 #size-cells = <0>; 67 #size-cells = <0>;
@@ -55,9 +105,18 @@
55 gpio: gpio@6000d000 { 105 gpio: gpio@6000d000 {
56 compatible = "nvidia,tegra30-gpio", "nvidia,tegra20-gpio"; 106 compatible = "nvidia,tegra30-gpio", "nvidia,tegra20-gpio";
57 reg = < 0x6000d000 0x1000 >; 107 reg = < 0x6000d000 0x1000 >;
58 interrupts = < 0 32 0x04 0 33 0x04 0 34 0x04 0 35 0x04 0 55 0x04 0 87 0x04 0 89 0x04 >; 108 interrupts = < 0 32 0x04
109 0 33 0x04
110 0 34 0x04
111 0 35 0x04
112 0 55 0x04
113 0 87 0x04
114 0 89 0x04
115 0 125 0x04 >;
59 #gpio-cells = <2>; 116 #gpio-cells = <2>;
60 gpio-controller; 117 gpio-controller;
118 #interrupt-cells = <2>;
119 interrupt-controller;
61 }; 120 };
62 121
63 serial@70006000 { 122 serial@70006000 {
diff --git a/arch/arm/boot/dts/usb_a9g20-dab-mmx.dtsi b/arch/arm/boot/dts/usb_a9g20-dab-mmx.dtsi
new file mode 100644
index 00000000000..ad3eca17c43
--- /dev/null
+++ b/arch/arm/boot/dts/usb_a9g20-dab-mmx.dtsi
@@ -0,0 +1,96 @@
1/*
2 * calao-dab-mmx.dtsi - Device Tree Include file for Calao DAB-MMX Daughter Board
3 *
4 * Copyright (C) 2011 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
5 *
6 * Licensed under GPLv2.
7 */
8
9/ {
10 ahb {
11 apb {
12 usart1: serial@fffb4000 {
13 status = "okay";
14 };
15
16 usart3: serial@fffd0000 {
17 status = "okay";
18 };
19 };
20 };
21
22 i2c-gpio@0 {
23 status = "okay";
24 };
25
26 leds {
27 compatible = "gpio-leds";
28
29 user_led1 {
30 label = "user_led1";
31 gpios = <&pioB 20 1>;
32 };
33
34/*
35* led already used by mother board but active as high
36* user_led2 {
37* label = "user_led2";
38* gpios = <&pioB 21 1>;
39* };
40*/
41 user_led3 {
42 label = "user_led3";
43 gpios = <&pioB 22 1>;
44 };
45
46 user_led4 {
47 label = "user_led4";
48 gpios = <&pioB 23 1>;
49 };
50
51 red {
52 label = "red";
53 gpios = <&pioB 24 1>;
54 };
55
56 orange {
57 label = "orange";
58 gpios = <&pioB 30 1>;
59 };
60
61 green {
62 label = "green";
63 gpios = <&pioB 31 1>;
64 };
65 };
66
67 gpio_keys {
68 compatible = "gpio-keys";
69 #address-cells = <1>;
70 #size-cells = <0>;
71
72 user_pb1 {
73 label = "user_pb1";
74 gpios = <&pioB 25 1>;
75 linux,code = <0x100>;
76 };
77
78 user_pb2 {
79 label = "user_pb2";
80 gpios = <&pioB 13 1>;
81 linux,code = <0x101>;
82 };
83
84 user_pb3 {
85 label = "user_pb3";
86 gpios = <&pioA 26 1>;
87 linux,code = <0x102>;
88 };
89
90 user_pb4 {
91 label = "user_pb4";
92 gpios = <&pioC 9 1>;
93 linux,code = <0x103>;
94 };
95 };
96};
diff --git a/arch/arm/boot/dts/usb_a9g20.dts b/arch/arm/boot/dts/usb_a9g20.dts
index f04b535477f..3b3c4e0fa79 100644
--- a/arch/arm/boot/dts/usb_a9g20.dts
+++ b/arch/arm/boot/dts/usb_a9g20.dts
@@ -13,13 +13,24 @@
13 compatible = "calao,usb-a9g20", "atmel,at91sam9g20", "atmel,at91sam9"; 13 compatible = "calao,usb-a9g20", "atmel,at91sam9g20", "atmel,at91sam9";
14 14
15 chosen { 15 chosen {
16 bootargs = "mem=64M console=ttyS0,115200 mtdparts=atmel_nand:128k(at91bootstrap),256k(barebox)ro,128k(bareboxenv),128k(bareboxenv2),4M(kernel),120M(rootfs),-(data) root=/dev/mtdblock5 rw rootfstype=ubifs"; 16 bootargs = "mem=64M console=ttyS0,115200 root=/dev/mtdblock5 rw rootfstype=ubifs";
17 }; 17 };
18 18
19 memory@20000000 { 19 memory@20000000 {
20 reg = <0x20000000 0x4000000>; 20 reg = <0x20000000 0x4000000>;
21 }; 21 };
22 22
23 clocks {
24 #address-cells = <1>;
25 #size-cells = <1>;
26 ranges;
27
28 main_clock: clock@0 {
29 compatible = "atmel,osc", "fixed-clock";
30 clock-frequency = <12000000>;
31 };
32 };
33
23 ahb { 34 ahb {
24 apb { 35 apb {
25 dbgu: serial@fffff200 { 36 dbgu: serial@fffff200 {
@@ -30,6 +41,90 @@
30 phy-mode = "rmii"; 41 phy-mode = "rmii";
31 status = "okay"; 42 status = "okay";
32 }; 43 };
44
45 usb1: gadget@fffa4000 {
46 atmel,vbus-gpio = <&pioC 5 0>;
47 status = "okay";
48 };
49 };
50
51 nand0: nand@40000000 {
52 nand-bus-width = <8>;
53 nand-ecc-mode = "soft";
54 nand-on-flash-bbt;
55 status = "okay";
56
57 at91bootstrap@0 {
58 label = "at91bootstrap";
59 reg = <0x0 0x20000>;
60 };
61
62 barebox@20000 {
63 label = "barebox";
64 reg = <0x20000 0x40000>;
65 };
66
67 bareboxenv@60000 {
68 label = "bareboxenv";
69 reg = <0x60000 0x20000>;
70 };
71
72 bareboxenv2@80000 {
73 label = "bareboxenv2";
74 reg = <0x80000 0x20000>;
75 };
76
77 kernel@a0000 {
78 label = "kernel";
79 reg = <0xa0000 0x400000>;
80 };
81
82 rootfs@4a0000 {
83 label = "rootfs";
84 reg = <0x4a0000 0x7800000>;
85 };
86
87 data@7ca0000 {
88 label = "data";
89 reg = <0x7ca0000 0x8360000>;
90 };
91 };
92
93 usb0: ohci@00500000 {
94 num-ports = <2>;
95 status = "okay";
96 };
97 };
98
99 leds {
100 compatible = "gpio-leds";
101
102 user_led {
103 label = "user_led";
104 gpios = <&pioB 21 1>;
105 linux,default-trigger = "heartbeat";
106 };
107 };
108
109 gpio_keys {
110 compatible = "gpio-keys";
111 #address-cells = <1>;
112 #size-cells = <0>;
113
114 user_pb {
115 label = "user_pb";
116 gpios = <&pioB 10 1>;
117 linux,code = <28>;
118 gpio-key,wakeup;
119 };
120 };
121
122 i2c@0 {
123 status = "okay";
124
125 rv3029c2@56 {
126 compatible = "rv3029c2";
127 reg = <0x56>;
33 }; 128 };
34 }; 129 };
35}; 130};
diff --git a/arch/arm/boot/dts/vexpress-v2m-rs1.dtsi b/arch/arm/boot/dts/vexpress-v2m-rs1.dtsi
new file mode 100644
index 00000000000..16076e2d093
--- /dev/null
+++ b/arch/arm/boot/dts/vexpress-v2m-rs1.dtsi
@@ -0,0 +1,201 @@
1/*
2 * ARM Ltd. Versatile Express
3 *
4 * Motherboard Express uATX
5 * V2M-P1
6 *
7 * HBI-0190D
8 *
9 * RS1 memory map ("ARM Cortex-A Series memory map" in the board's
10 * Technical Reference Manual)
11 *
12 * WARNING! The hardware described in this file is independent from the
13 * original variant (vexpress-v2m.dtsi), but there is a strong
14 * correspondence between the two configurations.
15 *
16 * TAKE CARE WHEN MAINTAINING THIS FILE TO PROPAGATE ANY RELEVANT
17 * CHANGES TO vexpress-v2m.dtsi!
18 */
19
20/ {
21 aliases {
22 arm,v2m_timer = &v2m_timer01;
23 };
24
25 motherboard {
26 compatible = "simple-bus";
27 arm,v2m-memory-map = "rs1";
28 #address-cells = <2>; /* SMB chipselect number and offset */
29 #size-cells = <1>;
30 #interrupt-cells = <1>;
31
32 flash@0,00000000 {
33 compatible = "arm,vexpress-flash", "cfi-flash";
34 reg = <0 0x00000000 0x04000000>,
35 <4 0x00000000 0x04000000>;
36 bank-width = <4>;
37 };
38
39 psram@1,00000000 {
40 compatible = "arm,vexpress-psram", "mtd-ram";
41 reg = <1 0x00000000 0x02000000>;
42 bank-width = <4>;
43 };
44
45 vram@2,00000000 {
46 compatible = "arm,vexpress-vram";
47 reg = <2 0x00000000 0x00800000>;
48 };
49
50 ethernet@2,02000000 {
51 compatible = "smsc,lan9118", "smsc,lan9115";
52 reg = <2 0x02000000 0x10000>;
53 interrupts = <15>;
54 phy-mode = "mii";
55 reg-io-width = <4>;
56 smsc,irq-active-high;
57 smsc,irq-push-pull;
58 };
59
60 usb@2,03000000 {
61 compatible = "nxp,usb-isp1761";
62 reg = <2 0x03000000 0x20000>;
63 interrupts = <16>;
64 port1-otg;
65 };
66
67 iofpga@3,00000000 {
68 compatible = "arm,amba-bus", "simple-bus";
69 #address-cells = <1>;
70 #size-cells = <1>;
71 ranges = <0 3 0 0x200000>;
72
73 sysreg@010000 {
74 compatible = "arm,vexpress-sysreg";
75 reg = <0x010000 0x1000>;
76 };
77
78 sysctl@020000 {
79 compatible = "arm,sp810", "arm,primecell";
80 reg = <0x020000 0x1000>;
81 };
82
83 /* PCI-E I2C bus */
84 v2m_i2c_pcie: i2c@030000 {
85 compatible = "arm,versatile-i2c";
86 reg = <0x030000 0x1000>;
87
88 #address-cells = <1>;
89 #size-cells = <0>;
90
91 pcie-switch@60 {
92 compatible = "idt,89hpes32h8";
93 reg = <0x60>;
94 };
95 };
96
97 aaci@040000 {
98 compatible = "arm,pl041", "arm,primecell";
99 reg = <0x040000 0x1000>;
100 interrupts = <11>;
101 };
102
103 mmci@050000 {
104 compatible = "arm,pl180", "arm,primecell";
105 reg = <0x050000 0x1000>;
106 interrupts = <9 10>;
107 };
108
109 kmi@060000 {
110 compatible = "arm,pl050", "arm,primecell";
111 reg = <0x060000 0x1000>;
112 interrupts = <12>;
113 };
114
115 kmi@070000 {
116 compatible = "arm,pl050", "arm,primecell";
117 reg = <0x070000 0x1000>;
118 interrupts = <13>;
119 };
120
121 v2m_serial0: uart@090000 {
122 compatible = "arm,pl011", "arm,primecell";
123 reg = <0x090000 0x1000>;
124 interrupts = <5>;
125 };
126
127 v2m_serial1: uart@0a0000 {
128 compatible = "arm,pl011", "arm,primecell";
129 reg = <0x0a0000 0x1000>;
130 interrupts = <6>;
131 };
132
133 v2m_serial2: uart@0b0000 {
134 compatible = "arm,pl011", "arm,primecell";
135 reg = <0x0b0000 0x1000>;
136 interrupts = <7>;
137 };
138
139 v2m_serial3: uart@0c0000 {
140 compatible = "arm,pl011", "arm,primecell";
141 reg = <0x0c0000 0x1000>;
142 interrupts = <8>;
143 };
144
145 wdt@0f0000 {
146 compatible = "arm,sp805", "arm,primecell";
147 reg = <0x0f0000 0x1000>;
148 interrupts = <0>;
149 };
150
151 v2m_timer01: timer@110000 {
152 compatible = "arm,sp804", "arm,primecell";
153 reg = <0x110000 0x1000>;
154 interrupts = <2>;
155 };
156
157 v2m_timer23: timer@120000 {
158 compatible = "arm,sp804", "arm,primecell";
159 reg = <0x120000 0x1000>;
160 };
161
162 /* DVI I2C bus */
163 v2m_i2c_dvi: i2c@160000 {
164 compatible = "arm,versatile-i2c";
165 reg = <0x160000 0x1000>;
166
167 #address-cells = <1>;
168 #size-cells = <0>;
169
170 dvi-transmitter@39 {
171 compatible = "sil,sii9022-tpi", "sil,sii9022";
172 reg = <0x39>;
173 };
174
175 dvi-transmitter@60 {
176 compatible = "sil,sii9022-cpi", "sil,sii9022";
177 reg = <0x60>;
178 };
179 };
180
181 rtc@170000 {
182 compatible = "arm,pl031", "arm,primecell";
183 reg = <0x170000 0x1000>;
184 interrupts = <4>;
185 };
186
187 compact-flash@1a0000 {
188 compatible = "arm,vexpress-cf", "ata-generic";
189 reg = <0x1a0000 0x100
190 0x1a0100 0xf00>;
191 reg-shift = <2>;
192 };
193
194 clcd@1f0000 {
195 compatible = "arm,pl111", "arm,primecell";
196 reg = <0x1f0000 0x1000>;
197 interrupts = <14>;
198 };
199 };
200 };
201};
diff --git a/arch/arm/boot/dts/vexpress-v2m.dtsi b/arch/arm/boot/dts/vexpress-v2m.dtsi
new file mode 100644
index 00000000000..a6c9c7c82d5
--- /dev/null
+++ b/arch/arm/boot/dts/vexpress-v2m.dtsi
@@ -0,0 +1,200 @@
1/*
2 * ARM Ltd. Versatile Express
3 *
4 * Motherboard Express uATX
5 * V2M-P1
6 *
7 * HBI-0190D
8 *
9 * Original memory map ("Legacy memory map" in the board's
10 * Technical Reference Manual)
11 *
12 * WARNING! The hardware described in this file is independent from the
13 * RS1 variant (vexpress-v2m-rs1.dtsi), but there is a strong
14 * correspondence between the two configurations.
15 *
16 * TAKE CARE WHEN MAINTAINING THIS FILE TO PROPAGATE ANY RELEVANT
17 * CHANGES TO vexpress-v2m-rs1.dtsi!
18 */
19
20/ {
21 aliases {
22 arm,v2m_timer = &v2m_timer01;
23 };
24
25 motherboard {
26 compatible = "simple-bus";
27 #address-cells = <2>; /* SMB chipselect number and offset */
28 #size-cells = <1>;
29 #interrupt-cells = <1>;
30
31 flash@0,00000000 {
32 compatible = "arm,vexpress-flash", "cfi-flash";
33 reg = <0 0x00000000 0x04000000>,
34 <1 0x00000000 0x04000000>;
35 bank-width = <4>;
36 };
37
38 psram@2,00000000 {
39 compatible = "arm,vexpress-psram", "mtd-ram";
40 reg = <2 0x00000000 0x02000000>;
41 bank-width = <4>;
42 };
43
44 vram@3,00000000 {
45 compatible = "arm,vexpress-vram";
46 reg = <3 0x00000000 0x00800000>;
47 };
48
49 ethernet@3,02000000 {
50 compatible = "smsc,lan9118", "smsc,lan9115";
51 reg = <3 0x02000000 0x10000>;
52 interrupts = <15>;
53 phy-mode = "mii";
54 reg-io-width = <4>;
55 smsc,irq-active-high;
56 smsc,irq-push-pull;
57 };
58
59 usb@3,03000000 {
60 compatible = "nxp,usb-isp1761";
61 reg = <3 0x03000000 0x20000>;
62 interrupts = <16>;
63 port1-otg;
64 };
65
66 iofpga@7,00000000 {
67 compatible = "arm,amba-bus", "simple-bus";
68 #address-cells = <1>;
69 #size-cells = <1>;
70 ranges = <0 7 0 0x20000>;
71
72 sysreg@00000 {
73 compatible = "arm,vexpress-sysreg";
74 reg = <0x00000 0x1000>;
75 };
76
77 sysctl@01000 {
78 compatible = "arm,sp810", "arm,primecell";
79 reg = <0x01000 0x1000>;
80 };
81
82 /* PCI-E I2C bus */
83 v2m_i2c_pcie: i2c@02000 {
84 compatible = "arm,versatile-i2c";
85 reg = <0x02000 0x1000>;
86
87 #address-cells = <1>;
88 #size-cells = <0>;
89
90 pcie-switch@60 {
91 compatible = "idt,89hpes32h8";
92 reg = <0x60>;
93 };
94 };
95
96 aaci@04000 {
97 compatible = "arm,pl041", "arm,primecell";
98 reg = <0x04000 0x1000>;
99 interrupts = <11>;
100 };
101
102 mmci@05000 {
103 compatible = "arm,pl180", "arm,primecell";
104 reg = <0x05000 0x1000>;
105 interrupts = <9 10>;
106 };
107
108 kmi@06000 {
109 compatible = "arm,pl050", "arm,primecell";
110 reg = <0x06000 0x1000>;
111 interrupts = <12>;
112 };
113
114 kmi@07000 {
115 compatible = "arm,pl050", "arm,primecell";
116 reg = <0x07000 0x1000>;
117 interrupts = <13>;
118 };
119
120 v2m_serial0: uart@09000 {
121 compatible = "arm,pl011", "arm,primecell";
122 reg = <0x09000 0x1000>;
123 interrupts = <5>;
124 };
125
126 v2m_serial1: uart@0a000 {
127 compatible = "arm,pl011", "arm,primecell";
128 reg = <0x0a000 0x1000>;
129 interrupts = <6>;
130 };
131
132 v2m_serial2: uart@0b000 {
133 compatible = "arm,pl011", "arm,primecell";
134 reg = <0x0b000 0x1000>;
135 interrupts = <7>;
136 };
137
138 v2m_serial3: uart@0c000 {
139 compatible = "arm,pl011", "arm,primecell";
140 reg = <0x0c000 0x1000>;
141 interrupts = <8>;
142 };
143
144 wdt@0f000 {
145 compatible = "arm,sp805", "arm,primecell";
146 reg = <0x0f000 0x1000>;
147 interrupts = <0>;
148 };
149
150 v2m_timer01: timer@11000 {
151 compatible = "arm,sp804", "arm,primecell";
152 reg = <0x11000 0x1000>;
153 interrupts = <2>;
154 };
155
156 v2m_timer23: timer@12000 {
157 compatible = "arm,sp804", "arm,primecell";
158 reg = <0x12000 0x1000>;
159 };
160
161 /* DVI I2C bus */
162 v2m_i2c_dvi: i2c@16000 {
163 compatible = "arm,versatile-i2c";
164 reg = <0x16000 0x1000>;
165
166 #address-cells = <1>;
167 #size-cells = <0>;
168
169 dvi-transmitter@39 {
170 compatible = "sil,sii9022-tpi", "sil,sii9022";
171 reg = <0x39>;
172 };
173
174 dvi-transmitter@60 {
175 compatible = "sil,sii9022-cpi", "sil,sii9022";
176 reg = <0x60>;
177 };
178 };
179
180 rtc@17000 {
181 compatible = "arm,pl031", "arm,primecell";
182 reg = <0x17000 0x1000>;
183 interrupts = <4>;
184 };
185
186 compact-flash@1a000 {
187 compatible = "arm,vexpress-cf", "ata-generic";
188 reg = <0x1a000 0x100
189 0x1a100 0xf00>;
190 reg-shift = <2>;
191 };
192
193 clcd@1f000 {
194 compatible = "arm,pl111", "arm,primecell";
195 reg = <0x1f000 0x1000>;
196 interrupts = <14>;
197 };
198 };
199 };
200};
diff --git a/arch/arm/boot/dts/vexpress-v2p-ca15-tc1.dts b/arch/arm/boot/dts/vexpress-v2p-ca15-tc1.dts
new file mode 100644
index 00000000000..941b161ab78
--- /dev/null
+++ b/arch/arm/boot/dts/vexpress-v2p-ca15-tc1.dts
@@ -0,0 +1,157 @@
1/*
2 * ARM Ltd. Versatile Express
3 *
4 * CoreTile Express A15x2 (version with Test Chip 1)
5 * Cortex-A15 MPCore (V2P-CA15)
6 *
7 * HBI-0237A
8 */
9
10/dts-v1/;
11
12/ {
13 model = "V2P-CA15";
14 arm,hbi = <0x237>;
15 compatible = "arm,vexpress,v2p-ca15,tc1", "arm,vexpress,v2p-ca15", "arm,vexpress";
16 interrupt-parent = <&gic>;
17 #address-cells = <1>;
18 #size-cells = <1>;
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 cpu@0 {
36 device_type = "cpu";
37 compatible = "arm,cortex-a15";
38 reg = <0>;
39 };
40
41 cpu@1 {
42 device_type = "cpu";
43 compatible = "arm,cortex-a15";
44 reg = <1>;
45 };
46 };
47
48 memory@80000000 {
49 device_type = "memory";
50 reg = <0x80000000 0x40000000>;
51 };
52
53 hdlcd@2b000000 {
54 compatible = "arm,hdlcd";
55 reg = <0x2b000000 0x1000>;
56 interrupts = <0 85 4>;
57 };
58
59 memory-controller@2b0a0000 {
60 compatible = "arm,pl341", "arm,primecell";
61 reg = <0x2b0a0000 0x1000>;
62 };
63
64 wdt@2b060000 {
65 compatible = "arm,sp805", "arm,primecell";
66 reg = <0x2b060000 0x1000>;
67 interrupts = <98>;
68 };
69
70 gic: interrupt-controller@2c001000 {
71 compatible = "arm,cortex-a15-gic", "arm,cortex-a9-gic";
72 #interrupt-cells = <3>;
73 #address-cells = <0>;
74 interrupt-controller;
75 reg = <0x2c001000 0x1000>,
76 <0x2c002000 0x100>;
77 };
78
79 memory-controller@7ffd0000 {
80 compatible = "arm,pl354", "arm,primecell";
81 reg = <0x7ffd0000 0x1000>;
82 interrupts = <0 86 4>,
83 <0 87 4>;
84 };
85
86 dma@7ffb0000 {
87 compatible = "arm,pl330", "arm,primecell";
88 reg = <0x7ffb0000 0x1000>;
89 interrupts = <0 92 4>,
90 <0 88 4>,
91 <0 89 4>,
92 <0 90 4>,
93 <0 91 4>;
94 };
95
96 pmu {
97 compatible = "arm,cortex-a15-pmu", "arm,cortex-a9-pmu";
98 interrupts = <0 68 4>,
99 <0 69 4>;
100 };
101
102 motherboard {
103 ranges = <0 0 0x08000000 0x04000000>,
104 <1 0 0x14000000 0x04000000>,
105 <2 0 0x18000000 0x04000000>,
106 <3 0 0x1c000000 0x04000000>,
107 <4 0 0x0c000000 0x04000000>,
108 <5 0 0x10000000 0x04000000>;
109
110 interrupt-map-mask = <0 0 63>;
111 interrupt-map = <0 0 0 &gic 0 0 4>,
112 <0 0 1 &gic 0 1 4>,
113 <0 0 2 &gic 0 2 4>,
114 <0 0 3 &gic 0 3 4>,
115 <0 0 4 &gic 0 4 4>,
116 <0 0 5 &gic 0 5 4>,
117 <0 0 6 &gic 0 6 4>,
118 <0 0 7 &gic 0 7 4>,
119 <0 0 8 &gic 0 8 4>,
120 <0 0 9 &gic 0 9 4>,
121 <0 0 10 &gic 0 10 4>,
122 <0 0 11 &gic 0 11 4>,
123 <0 0 12 &gic 0 12 4>,
124 <0 0 13 &gic 0 13 4>,
125 <0 0 14 &gic 0 14 4>,
126 <0 0 15 &gic 0 15 4>,
127 <0 0 16 &gic 0 16 4>,
128 <0 0 17 &gic 0 17 4>,
129 <0 0 18 &gic 0 18 4>,
130 <0 0 19 &gic 0 19 4>,
131 <0 0 20 &gic 0 20 4>,
132 <0 0 21 &gic 0 21 4>,
133 <0 0 22 &gic 0 22 4>,
134 <0 0 23 &gic 0 23 4>,
135 <0 0 24 &gic 0 24 4>,
136 <0 0 25 &gic 0 25 4>,
137 <0 0 26 &gic 0 26 4>,
138 <0 0 27 &gic 0 27 4>,
139 <0 0 28 &gic 0 28 4>,
140 <0 0 29 &gic 0 29 4>,
141 <0 0 30 &gic 0 30 4>,
142 <0 0 31 &gic 0 31 4>,
143 <0 0 32 &gic 0 32 4>,
144 <0 0 33 &gic 0 33 4>,
145 <0 0 34 &gic 0 34 4>,
146 <0 0 35 &gic 0 35 4>,
147 <0 0 36 &gic 0 36 4>,
148 <0 0 37 &gic 0 37 4>,
149 <0 0 38 &gic 0 38 4>,
150 <0 0 39 &gic 0 39 4>,
151 <0 0 40 &gic 0 40 4>,
152 <0 0 41 &gic 0 41 4>,
153 <0 0 42 &gic 0 42 4>;
154 };
155};
156
157/include/ "vexpress-v2m-rs1.dtsi"
diff --git a/arch/arm/boot/dts/vexpress-v2p-ca5s.dts b/arch/arm/boot/dts/vexpress-v2p-ca5s.dts
new file mode 100644
index 00000000000..6905e66d474
--- /dev/null
+++ b/arch/arm/boot/dts/vexpress-v2p-ca5s.dts
@@ -0,0 +1,162 @@
1/*
2 * ARM Ltd. Versatile Express
3 *
4 * CoreTile Express A5x2
5 * Cortex-A5 MPCore (V2P-CA5s)
6 *
7 * HBI-0225B
8 */
9
10/dts-v1/;
11
12/ {
13 model = "V2P-CA5s";
14 arm,hbi = <0x225>;
15 compatible = "arm,vexpress,v2p-ca5s", "arm,vexpress";
16 interrupt-parent = <&gic>;
17 #address-cells = <1>;
18 #size-cells = <1>;
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 cpu@0 {
36 device_type = "cpu";
37 compatible = "arm,cortex-a5";
38 reg = <0>;
39 next-level-cache = <&L2>;
40 };
41
42 cpu@1 {
43 device_type = "cpu";
44 compatible = "arm,cortex-a5";
45 reg = <1>;
46 next-level-cache = <&L2>;
47 };
48 };
49
50 memory@80000000 {
51 device_type = "memory";
52 reg = <0x80000000 0x40000000>;
53 };
54
55 hdlcd@2a110000 {
56 compatible = "arm,hdlcd";
57 reg = <0x2a110000 0x1000>;
58 interrupts = <0 85 4>;
59 };
60
61 memory-controller@2a150000 {
62 compatible = "arm,pl341", "arm,primecell";
63 reg = <0x2a150000 0x1000>;
64 };
65
66 memory-controller@2a190000 {
67 compatible = "arm,pl354", "arm,primecell";
68 reg = <0x2a190000 0x1000>;
69 interrupts = <0 86 4>,
70 <0 87 4>;
71 };
72
73 scu@2c000000 {
74 compatible = "arm,cortex-a5-scu";
75 reg = <0x2c000000 0x58>;
76 };
77
78 timer@2c000600 {
79 compatible = "arm,cortex-a5-twd-timer";
80 reg = <0x2c000600 0x38>;
81 interrupts = <1 2 0x304>,
82 <1 3 0x304>;
83 };
84
85 gic: interrupt-controller@2c001000 {
86 compatible = "arm,corex-a5-gic", "arm,cortex-a9-gic";
87 #interrupt-cells = <3>;
88 #address-cells = <0>;
89 interrupt-controller;
90 reg = <0x2c001000 0x1000>,
91 <0x2c000100 0x100>;
92 };
93
94 L2: cache-controller@2c0f0000 {
95 compatible = "arm,pl310-cache";
96 reg = <0x2c0f0000 0x1000>;
97 interrupts = <0 84 4>;
98 cache-level = <2>;
99 };
100
101 pmu {
102 compatible = "arm,cortex-a5-pmu", "arm,cortex-a9-pmu";
103 interrupts = <0 68 4>,
104 <0 69 4>;
105 };
106
107 motherboard {
108 ranges = <0 0 0x08000000 0x04000000>,
109 <1 0 0x14000000 0x04000000>,
110 <2 0 0x18000000 0x04000000>,
111 <3 0 0x1c000000 0x04000000>,
112 <4 0 0x0c000000 0x04000000>,
113 <5 0 0x10000000 0x04000000>;
114
115 interrupt-map-mask = <0 0 63>;
116 interrupt-map = <0 0 0 &gic 0 0 4>,
117 <0 0 1 &gic 0 1 4>,
118 <0 0 2 &gic 0 2 4>,
119 <0 0 3 &gic 0 3 4>,
120 <0 0 4 &gic 0 4 4>,
121 <0 0 5 &gic 0 5 4>,
122 <0 0 6 &gic 0 6 4>,
123 <0 0 7 &gic 0 7 4>,
124 <0 0 8 &gic 0 8 4>,
125 <0 0 9 &gic 0 9 4>,
126 <0 0 10 &gic 0 10 4>,
127 <0 0 11 &gic 0 11 4>,
128 <0 0 12 &gic 0 12 4>,
129 <0 0 13 &gic 0 13 4>,
130 <0 0 14 &gic 0 14 4>,
131 <0 0 15 &gic 0 15 4>,
132 <0 0 16 &gic 0 16 4>,
133 <0 0 17 &gic 0 17 4>,
134 <0 0 18 &gic 0 18 4>,
135 <0 0 19 &gic 0 19 4>,
136 <0 0 20 &gic 0 20 4>,
137 <0 0 21 &gic 0 21 4>,
138 <0 0 22 &gic 0 22 4>,
139 <0 0 23 &gic 0 23 4>,
140 <0 0 24 &gic 0 24 4>,
141 <0 0 25 &gic 0 25 4>,
142 <0 0 26 &gic 0 26 4>,
143 <0 0 27 &gic 0 27 4>,
144 <0 0 28 &gic 0 28 4>,
145 <0 0 29 &gic 0 29 4>,
146 <0 0 30 &gic 0 30 4>,
147 <0 0 31 &gic 0 31 4>,
148 <0 0 32 &gic 0 32 4>,
149 <0 0 33 &gic 0 33 4>,
150 <0 0 34 &gic 0 34 4>,
151 <0 0 35 &gic 0 35 4>,
152 <0 0 36 &gic 0 36 4>,
153 <0 0 37 &gic 0 37 4>,
154 <0 0 38 &gic 0 38 4>,
155 <0 0 39 &gic 0 39 4>,
156 <0 0 40 &gic 0 40 4>,
157 <0 0 41 &gic 0 41 4>,
158 <0 0 42 &gic 0 42 4>;
159 };
160};
161
162/include/ "vexpress-v2m-rs1.dtsi"
diff --git a/arch/arm/boot/dts/vexpress-v2p-ca9.dts b/arch/arm/boot/dts/vexpress-v2p-ca9.dts
new file mode 100644
index 00000000000..da778693be5
--- /dev/null
+++ b/arch/arm/boot/dts/vexpress-v2p-ca9.dts
@@ -0,0 +1,192 @@
1/*
2 * ARM Ltd. Versatile Express
3 *
4 * CoreTile Express A9x4
5 * Cortex-A9 MPCore (V2P-CA9)
6 *
7 * HBI-0191B
8 */
9
10/dts-v1/;
11
12/ {
13 model = "V2P-CA9";
14 arm,hbi = <0x191>;
15 compatible = "arm,vexpress,v2p-ca9", "arm,vexpress";
16 interrupt-parent = <&gic>;
17 #address-cells = <1>;
18 #size-cells = <1>;
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 cpu@0 {
36 device_type = "cpu";
37 compatible = "arm,cortex-a9";
38 reg = <0>;
39 next-level-cache = <&L2>;
40 };
41
42 cpu@1 {
43 device_type = "cpu";
44 compatible = "arm,cortex-a9";
45 reg = <1>;
46 next-level-cache = <&L2>;
47 };
48
49 cpu@2 {
50 device_type = "cpu";
51 compatible = "arm,cortex-a9";
52 reg = <2>;
53 next-level-cache = <&L2>;
54 };
55
56 cpu@3 {
57 device_type = "cpu";
58 compatible = "arm,cortex-a9";
59 reg = <3>;
60 next-level-cache = <&L2>;
61 };
62 };
63
64 memory@60000000 {
65 device_type = "memory";
66 reg = <0x60000000 0x40000000>;
67 };
68
69 clcd@10020000 {
70 compatible = "arm,pl111", "arm,primecell";
71 reg = <0x10020000 0x1000>;
72 interrupts = <0 44 4>;
73 };
74
75 memory-controller@100e0000 {
76 compatible = "arm,pl341", "arm,primecell";
77 reg = <0x100e0000 0x1000>;
78 };
79
80 memory-controller@100e1000 {
81 compatible = "arm,pl354", "arm,primecell";
82 reg = <0x100e1000 0x1000>;
83 interrupts = <0 45 4>,
84 <0 46 4>;
85 };
86
87 timer@100e4000 {
88 compatible = "arm,sp804", "arm,primecell";
89 reg = <0x100e4000 0x1000>;
90 interrupts = <0 48 4>,
91 <0 49 4>;
92 };
93
94 watchdog@100e5000 {
95 compatible = "arm,sp805", "arm,primecell";
96 reg = <0x100e5000 0x1000>;
97 interrupts = <0 51 4>;
98 };
99
100 scu@1e000000 {
101 compatible = "arm,cortex-a9-scu";
102 reg = <0x1e000000 0x58>;
103 };
104
105 timer@1e000600 {
106 compatible = "arm,cortex-a9-twd-timer";
107 reg = <0x1e000600 0x20>;
108 interrupts = <1 2 0xf04>,
109 <1 3 0xf04>;
110 };
111
112 gic: interrupt-controller@1e001000 {
113 compatible = "arm,cortex-a9-gic";
114 #interrupt-cells = <3>;
115 #address-cells = <0>;
116 interrupt-controller;
117 reg = <0x1e001000 0x1000>,
118 <0x1e000100 0x100>;
119 };
120
121 L2: cache-controller@1e00a000 {
122 compatible = "arm,pl310-cache";
123 reg = <0x1e00a000 0x1000>;
124 interrupts = <0 43 4>;
125 cache-level = <2>;
126 arm,data-latency = <1 1 1>;
127 arm,tag-latency = <1 1 1>;
128 };
129
130 pmu {
131 compatible = "arm,cortex-a9-pmu";
132 interrupts = <0 60 4>,
133 <0 61 4>,
134 <0 62 4>,
135 <0 63 4>;
136 };
137
138 motherboard {
139 ranges = <0 0 0x40000000 0x04000000>,
140 <1 0 0x44000000 0x04000000>,
141 <2 0 0x48000000 0x04000000>,
142 <3 0 0x4c000000 0x04000000>,
143 <7 0 0x10000000 0x00020000>;
144
145 interrupt-map-mask = <0 0 63>;
146 interrupt-map = <0 0 0 &gic 0 0 4>,
147 <0 0 1 &gic 0 1 4>,
148 <0 0 2 &gic 0 2 4>,
149 <0 0 3 &gic 0 3 4>,
150 <0 0 4 &gic 0 4 4>,
151 <0 0 5 &gic 0 5 4>,
152 <0 0 6 &gic 0 6 4>,
153 <0 0 7 &gic 0 7 4>,
154 <0 0 8 &gic 0 8 4>,
155 <0 0 9 &gic 0 9 4>,
156 <0 0 10 &gic 0 10 4>,
157 <0 0 11 &gic 0 11 4>,
158 <0 0 12 &gic 0 12 4>,
159 <0 0 13 &gic 0 13 4>,
160 <0 0 14 &gic 0 14 4>,
161 <0 0 15 &gic 0 15 4>,
162 <0 0 16 &gic 0 16 4>,
163 <0 0 17 &gic 0 17 4>,
164 <0 0 18 &gic 0 18 4>,
165 <0 0 19 &gic 0 19 4>,
166 <0 0 20 &gic 0 20 4>,
167 <0 0 21 &gic 0 21 4>,
168 <0 0 22 &gic 0 22 4>,
169 <0 0 23 &gic 0 23 4>,
170 <0 0 24 &gic 0 24 4>,
171 <0 0 25 &gic 0 25 4>,
172 <0 0 26 &gic 0 26 4>,
173 <0 0 27 &gic 0 27 4>,
174 <0 0 28 &gic 0 28 4>,
175 <0 0 29 &gic 0 29 4>,
176 <0 0 30 &gic 0 30 4>,
177 <0 0 31 &gic 0 31 4>,
178 <0 0 32 &gic 0 32 4>,
179 <0 0 33 &gic 0 33 4>,
180 <0 0 34 &gic 0 34 4>,
181 <0 0 35 &gic 0 35 4>,
182 <0 0 36 &gic 0 36 4>,
183 <0 0 37 &gic 0 37 4>,
184 <0 0 38 &gic 0 38 4>,
185 <0 0 39 &gic 0 39 4>,
186 <0 0 40 &gic 0 40 4>,
187 <0 0 41 &gic 0 41 4>,
188 <0 0 42 &gic 0 42 4>;
189 };
190};
191
192/include/ "vexpress-v2m.dtsi"
diff --git a/arch/arm/common/Kconfig b/arch/arm/common/Kconfig
index 81a933eb090..3bb1d7589bd 100644
--- a/arch/arm/common/Kconfig
+++ b/arch/arm/common/Kconfig
@@ -35,9 +35,6 @@ config DMABOUNCE
35 bool 35 bool
36 select ZONE_DMA 36 select ZONE_DMA
37 37
38config TIMER_ACORN
39 bool
40
41config SHARP_LOCOMO 38config SHARP_LOCOMO
42 bool 39 bool
43 40
diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile
index 6ea9b6f3607..69feafe7286 100644
--- a/arch/arm/common/Makefile
+++ b/arch/arm/common/Makefile
@@ -9,7 +9,6 @@ obj-$(CONFIG_PL330) += pl330.o
9obj-$(CONFIG_SA1111) += sa1111.o 9obj-$(CONFIG_SA1111) += sa1111.o
10obj-$(CONFIG_PCI_HOST_VIA82C505) += via82c505.o 10obj-$(CONFIG_PCI_HOST_VIA82C505) += via82c505.o
11obj-$(CONFIG_DMABOUNCE) += dmabounce.o 11obj-$(CONFIG_DMABOUNCE) += dmabounce.o
12obj-$(CONFIG_TIMER_ACORN) += time-acorn.o
13obj-$(CONFIG_SHARP_LOCOMO) += locomo.o 12obj-$(CONFIG_SHARP_LOCOMO) += locomo.o
14obj-$(CONFIG_SHARP_PARAM) += sharpsl_param.o 13obj-$(CONFIG_SHARP_PARAM) += sharpsl_param.o
15obj-$(CONFIG_SHARP_SCOOP) += scoop.o 14obj-$(CONFIG_SHARP_SCOOP) += scoop.o
diff --git a/arch/arm/common/it8152.c b/arch/arm/common/it8152.c
index fb1f1cfce60..dcb13494ca0 100644
--- a/arch/arm/common/it8152.c
+++ b/arch/arm/common/it8152.c
@@ -299,8 +299,8 @@ int __init it8152_pci_setup(int nr, struct pci_sys_data *sys)
299 goto err1; 299 goto err1;
300 } 300 }
301 301
302 pci_add_resource(&sys->resources, &it8152_io); 302 pci_add_resource_offset(&sys->resources, &it8152_io, sys->io_offset);
303 pci_add_resource(&sys->resources, &it8152_mem); 303 pci_add_resource_offset(&sys->resources, &it8152_mem, sys->mem_offset);
304 304
305 if (platform_notify || platform_notify_remove) { 305 if (platform_notify || platform_notify_remove) {
306 printk(KERN_ERR "PCI: Can't use platform_notify\n"); 306 printk(KERN_ERR "PCI: Can't use platform_notify\n");
diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c
index 61691cdbdcf..9173d112ea0 100644
--- a/arch/arm/common/sa1111.c
+++ b/arch/arm/common/sa1111.c
@@ -16,6 +16,7 @@
16 */ 16 */
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/irq.h>
19#include <linux/kernel.h> 20#include <linux/kernel.h>
20#include <linux/delay.h> 21#include <linux/delay.h>
21#include <linux/errno.h> 22#include <linux/errno.h>
@@ -28,9 +29,8 @@
28#include <linux/io.h> 29#include <linux/io.h>
29 30
30#include <mach/hardware.h> 31#include <mach/hardware.h>
31#include <asm/mach-types.h>
32#include <asm/irq.h>
33#include <asm/mach/irq.h> 32#include <asm/mach/irq.h>
33#include <asm/mach-types.h>
34#include <asm/sizes.h> 34#include <asm/sizes.h>
35 35
36#include <asm/hardware/sa1111.h> 36#include <asm/hardware/sa1111.h>
@@ -86,8 +86,10 @@
86#define IRQ_S1_CD_VALID (52) 86#define IRQ_S1_CD_VALID (52)
87#define IRQ_S0_BVD1_STSCHG (53) 87#define IRQ_S0_BVD1_STSCHG (53)
88#define IRQ_S1_BVD1_STSCHG (54) 88#define IRQ_S1_BVD1_STSCHG (54)
89#define SA1111_IRQ_NR (55)
89 90
90extern void __init sa1110_mb_enable(void); 91extern void sa1110_mb_enable(void);
92extern void sa1110_mb_disable(void);
91 93
92/* 94/*
93 * We keep the following data for the overall SA1111. Note that the 95 * We keep the following data for the overall SA1111. Note that the
@@ -104,6 +106,7 @@ struct sa1111 {
104 int irq_base; /* base for cascaded on-chip IRQs */ 106 int irq_base; /* base for cascaded on-chip IRQs */
105 spinlock_t lock; 107 spinlock_t lock;
106 void __iomem *base; 108 void __iomem *base;
109 struct sa1111_platform_data *pdata;
107#ifdef CONFIG_PM 110#ifdef CONFIG_PM
108 void *saved_state; 111 void *saved_state;
109#endif 112#endif
@@ -118,6 +121,7 @@ static struct sa1111 *g_sa1111;
118struct sa1111_dev_info { 121struct sa1111_dev_info {
119 unsigned long offset; 122 unsigned long offset;
120 unsigned long skpcr_mask; 123 unsigned long skpcr_mask;
124 bool dma;
121 unsigned int devid; 125 unsigned int devid;
122 unsigned int irq[6]; 126 unsigned int irq[6];
123}; 127};
@@ -126,6 +130,7 @@ static struct sa1111_dev_info sa1111_devices[] = {
126 { 130 {
127 .offset = SA1111_USB, 131 .offset = SA1111_USB,
128 .skpcr_mask = SKPCR_UCLKEN, 132 .skpcr_mask = SKPCR_UCLKEN,
133 .dma = true,
129 .devid = SA1111_DEVID_USB, 134 .devid = SA1111_DEVID_USB,
130 .irq = { 135 .irq = {
131 IRQ_USBPWR, 136 IRQ_USBPWR,
@@ -139,6 +144,7 @@ static struct sa1111_dev_info sa1111_devices[] = {
139 { 144 {
140 .offset = 0x0600, 145 .offset = 0x0600,
141 .skpcr_mask = SKPCR_I2SCLKEN | SKPCR_L3CLKEN, 146 .skpcr_mask = SKPCR_I2SCLKEN | SKPCR_L3CLKEN,
147 .dma = true,
142 .devid = SA1111_DEVID_SAC, 148 .devid = SA1111_DEVID_SAC,
143 .irq = { 149 .irq = {
144 AUDXMTDMADONEA, 150 AUDXMTDMADONEA,
@@ -155,7 +161,7 @@ static struct sa1111_dev_info sa1111_devices[] = {
155 { 161 {
156 .offset = SA1111_KBD, 162 .offset = SA1111_KBD,
157 .skpcr_mask = SKPCR_PTCLKEN, 163 .skpcr_mask = SKPCR_PTCLKEN,
158 .devid = SA1111_DEVID_PS2, 164 .devid = SA1111_DEVID_PS2_KBD,
159 .irq = { 165 .irq = {
160 IRQ_TPRXINT, 166 IRQ_TPRXINT,
161 IRQ_TPTXINT 167 IRQ_TPTXINT
@@ -164,7 +170,7 @@ static struct sa1111_dev_info sa1111_devices[] = {
164 { 170 {
165 .offset = SA1111_MSE, 171 .offset = SA1111_MSE,
166 .skpcr_mask = SKPCR_PMCLKEN, 172 .skpcr_mask = SKPCR_PMCLKEN,
167 .devid = SA1111_DEVID_PS2, 173 .devid = SA1111_DEVID_PS2_MSE,
168 .irq = { 174 .irq = {
169 IRQ_MSRXINT, 175 IRQ_MSRXINT,
170 IRQ_MSTXINT 176 IRQ_MSTXINT
@@ -434,16 +440,28 @@ static struct irq_chip sa1111_high_chip = {
434 .irq_set_wake = sa1111_wake_highirq, 440 .irq_set_wake = sa1111_wake_highirq,
435}; 441};
436 442
437static void sa1111_setup_irq(struct sa1111 *sachip) 443static int sa1111_setup_irq(struct sa1111 *sachip, unsigned irq_base)
438{ 444{
439 void __iomem *irqbase = sachip->base + SA1111_INTC; 445 void __iomem *irqbase = sachip->base + SA1111_INTC;
440 unsigned int irq; 446 unsigned i, irq;
447 int ret;
441 448
442 /* 449 /*
443 * We're guaranteed that this region hasn't been taken. 450 * We're guaranteed that this region hasn't been taken.
444 */ 451 */
445 request_mem_region(sachip->phys + SA1111_INTC, 512, "irq"); 452 request_mem_region(sachip->phys + SA1111_INTC, 512, "irq");
446 453
454 ret = irq_alloc_descs(-1, irq_base, SA1111_IRQ_NR, -1);
455 if (ret <= 0) {
456 dev_err(sachip->dev, "unable to allocate %u irqs: %d\n",
457 SA1111_IRQ_NR, ret);
458 if (ret == 0)
459 ret = -EINVAL;
460 return ret;
461 }
462
463 sachip->irq_base = ret;
464
447 /* disable all IRQs */ 465 /* disable all IRQs */
448 sa1111_writel(0, irqbase + SA1111_INTEN0); 466 sa1111_writel(0, irqbase + SA1111_INTEN0);
449 sa1111_writel(0, irqbase + SA1111_INTEN1); 467 sa1111_writel(0, irqbase + SA1111_INTEN1);
@@ -463,14 +481,16 @@ static void sa1111_setup_irq(struct sa1111 *sachip)
463 sa1111_writel(~0, irqbase + SA1111_INTSTATCLR0); 481 sa1111_writel(~0, irqbase + SA1111_INTSTATCLR0);
464 sa1111_writel(~0, irqbase + SA1111_INTSTATCLR1); 482 sa1111_writel(~0, irqbase + SA1111_INTSTATCLR1);
465 483
466 for (irq = IRQ_GPAIN0; irq <= SSPROR; irq++) { 484 for (i = IRQ_GPAIN0; i <= SSPROR; i++) {
485 irq = sachip->irq_base + i;
467 irq_set_chip_and_handler(irq, &sa1111_low_chip, 486 irq_set_chip_and_handler(irq, &sa1111_low_chip,
468 handle_edge_irq); 487 handle_edge_irq);
469 irq_set_chip_data(irq, sachip); 488 irq_set_chip_data(irq, sachip);
470 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE); 489 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
471 } 490 }
472 491
473 for (irq = AUDXMTDMADONEA; irq <= IRQ_S1_BVD1_STSCHG; irq++) { 492 for (i = AUDXMTDMADONEA; i <= IRQ_S1_BVD1_STSCHG; i++) {
493 irq = sachip->irq_base + i;
474 irq_set_chip_and_handler(irq, &sa1111_high_chip, 494 irq_set_chip_and_handler(irq, &sa1111_high_chip,
475 handle_edge_irq); 495 handle_edge_irq);
476 irq_set_chip_data(irq, sachip); 496 irq_set_chip_data(irq, sachip);
@@ -483,6 +503,11 @@ static void sa1111_setup_irq(struct sa1111 *sachip)
483 irq_set_irq_type(sachip->irq, IRQ_TYPE_EDGE_RISING); 503 irq_set_irq_type(sachip->irq, IRQ_TYPE_EDGE_RISING);
484 irq_set_handler_data(sachip->irq, sachip); 504 irq_set_handler_data(sachip->irq, sachip);
485 irq_set_chained_handler(sachip->irq, sa1111_irq_handler); 505 irq_set_chained_handler(sachip->irq, sa1111_irq_handler);
506
507 dev_info(sachip->dev, "Providing IRQ%u-%u\n",
508 sachip->irq_base, sachip->irq_base + SA1111_IRQ_NR - 1);
509
510 return 0;
486} 511}
487 512
488/* 513/*
@@ -581,41 +606,10 @@ sa1111_configure_smc(struct sa1111 *sachip, int sdram, unsigned int drac,
581} 606}
582#endif 607#endif
583 608
584#ifdef CONFIG_DMABOUNCE
585/*
586 * According to the "Intel StrongARM SA-1111 Microprocessor Companion
587 * Chip Specification Update" (June 2000), erratum #7, there is a
588 * significant bug in the SA1111 SDRAM shared memory controller. If
589 * an access to a region of memory above 1MB relative to the bank base,
590 * it is important that address bit 10 _NOT_ be asserted. Depending
591 * on the configuration of the RAM, bit 10 may correspond to one
592 * of several different (processor-relative) address bits.
593 *
594 * This routine only identifies whether or not a given DMA address
595 * is susceptible to the bug.
596 *
597 * This should only get called for sa1111_device types due to the
598 * way we configure our device dma_masks.
599 */
600static int sa1111_needs_bounce(struct device *dev, dma_addr_t addr, size_t size)
601{
602 /*
603 * Section 4.6 of the "Intel StrongARM SA-1111 Development Module
604 * User's Guide" mentions that jumpers R51 and R52 control the
605 * target of SA-1111 DMA (either SDRAM bank 0 on Assabet, or
606 * SDRAM bank 1 on Neponset). The default configuration selects
607 * Assabet, so any address in bank 1 is necessarily invalid.
608 */
609 return (machine_is_assabet() || machine_is_pfs168()) &&
610 (addr >= 0xc8000000 || (addr + size) >= 0xc8000000);
611}
612#endif
613
614static void sa1111_dev_release(struct device *_dev) 609static void sa1111_dev_release(struct device *_dev)
615{ 610{
616 struct sa1111_dev *dev = SA1111_DEV(_dev); 611 struct sa1111_dev *dev = SA1111_DEV(_dev);
617 612
618 release_resource(&dev->res);
619 kfree(dev); 613 kfree(dev);
620} 614}
621 615
@@ -624,67 +618,58 @@ sa1111_init_one_child(struct sa1111 *sachip, struct resource *parent,
624 struct sa1111_dev_info *info) 618 struct sa1111_dev_info *info)
625{ 619{
626 struct sa1111_dev *dev; 620 struct sa1111_dev *dev;
621 unsigned i;
627 int ret; 622 int ret;
628 623
629 dev = kzalloc(sizeof(struct sa1111_dev), GFP_KERNEL); 624 dev = kzalloc(sizeof(struct sa1111_dev), GFP_KERNEL);
630 if (!dev) { 625 if (!dev) {
631 ret = -ENOMEM; 626 ret = -ENOMEM;
632 goto out; 627 goto err_alloc;
633 } 628 }
634 629
630 device_initialize(&dev->dev);
635 dev_set_name(&dev->dev, "%4.4lx", info->offset); 631 dev_set_name(&dev->dev, "%4.4lx", info->offset);
636 dev->devid = info->devid; 632 dev->devid = info->devid;
637 dev->dev.parent = sachip->dev; 633 dev->dev.parent = sachip->dev;
638 dev->dev.bus = &sa1111_bus_type; 634 dev->dev.bus = &sa1111_bus_type;
639 dev->dev.release = sa1111_dev_release; 635 dev->dev.release = sa1111_dev_release;
640 dev->dev.coherent_dma_mask = sachip->dev->coherent_dma_mask;
641 dev->res.start = sachip->phys + info->offset; 636 dev->res.start = sachip->phys + info->offset;
642 dev->res.end = dev->res.start + 511; 637 dev->res.end = dev->res.start + 511;
643 dev->res.name = dev_name(&dev->dev); 638 dev->res.name = dev_name(&dev->dev);
644 dev->res.flags = IORESOURCE_MEM; 639 dev->res.flags = IORESOURCE_MEM;
645 dev->mapbase = sachip->base + info->offset; 640 dev->mapbase = sachip->base + info->offset;
646 dev->skpcr_mask = info->skpcr_mask; 641 dev->skpcr_mask = info->skpcr_mask;
647 memmove(dev->irq, info->irq, sizeof(dev->irq));
648
649 ret = request_resource(parent, &dev->res);
650 if (ret) {
651 printk("SA1111: failed to allocate resource for %s\n",
652 dev->res.name);
653 dev_set_name(&dev->dev, NULL);
654 kfree(dev);
655 goto out;
656 }
657
658 642
659 ret = device_register(&dev->dev); 643 for (i = 0; i < ARRAY_SIZE(info->irq); i++)
660 if (ret) { 644 dev->irq[i] = sachip->irq_base + info->irq[i];
661 release_resource(&dev->res);
662 kfree(dev);
663 goto out;
664 }
665 645
666#ifdef CONFIG_DMABOUNCE
667 /* 646 /*
668 * If the parent device has a DMA mask associated with it, 647 * If the parent device has a DMA mask associated with it, and
669 * propagate it down to the children. 648 * this child supports DMA, propagate it down to the children.
670 */ 649 */
671 if (sachip->dev->dma_mask) { 650 if (info->dma && sachip->dev->dma_mask) {
672 dev->dma_mask = *sachip->dev->dma_mask; 651 dev->dma_mask = *sachip->dev->dma_mask;
673 dev->dev.dma_mask = &dev->dma_mask; 652 dev->dev.dma_mask = &dev->dma_mask;
653 dev->dev.coherent_dma_mask = sachip->dev->coherent_dma_mask;
654 }
674 655
675 if (dev->dma_mask != 0xffffffffUL) { 656 ret = request_resource(parent, &dev->res);
676 ret = dmabounce_register_dev(&dev->dev, 1024, 4096, 657 if (ret) {
677 sa1111_needs_bounce); 658 dev_err(sachip->dev, "failed to allocate resource for %s\n",
678 if (ret) { 659 dev->res.name);
679 dev_err(&dev->dev, "SA1111: Failed to register" 660 goto err_resource;
680 " with dmabounce\n");
681 device_unregister(&dev->dev);
682 }
683 }
684 } 661 }
685#endif
686 662
687out: 663 ret = device_add(&dev->dev);
664 if (ret)
665 goto err_add;
666 return 0;
667
668 err_add:
669 release_resource(&dev->res);
670 err_resource:
671 put_device(&dev->dev);
672 err_alloc:
688 return ret; 673 return ret;
689} 674}
690 675
@@ -698,16 +683,21 @@ out:
698 * Returns: 683 * Returns:
699 * %-ENODEV device not found. 684 * %-ENODEV device not found.
700 * %-EBUSY physical address already marked in-use. 685 * %-EBUSY physical address already marked in-use.
686 * %-EINVAL no platform data passed
701 * %0 successful. 687 * %0 successful.
702 */ 688 */
703static int __devinit 689static int __devinit
704__sa1111_probe(struct device *me, struct resource *mem, int irq) 690__sa1111_probe(struct device *me, struct resource *mem, int irq)
705{ 691{
692 struct sa1111_platform_data *pd = me->platform_data;
706 struct sa1111 *sachip; 693 struct sa1111 *sachip;
707 unsigned long id; 694 unsigned long id;
708 unsigned int has_devs; 695 unsigned int has_devs;
709 int i, ret = -ENODEV; 696 int i, ret = -ENODEV;
710 697
698 if (!pd)
699 return -EINVAL;
700
711 sachip = kzalloc(sizeof(struct sa1111), GFP_KERNEL); 701 sachip = kzalloc(sizeof(struct sa1111), GFP_KERNEL);
712 if (!sachip) 702 if (!sachip)
713 return -ENOMEM; 703 return -ENOMEM;
@@ -727,6 +717,7 @@ __sa1111_probe(struct device *me, struct resource *mem, int irq)
727 sachip->dev = me; 717 sachip->dev = me;
728 dev_set_drvdata(sachip->dev, sachip); 718 dev_set_drvdata(sachip->dev, sachip);
729 719
720 sachip->pdata = pd;
730 sachip->phys = mem->start; 721 sachip->phys = mem->start;
731 sachip->irq = irq; 722 sachip->irq = irq;
732 723
@@ -759,6 +750,16 @@ __sa1111_probe(struct device *me, struct resource *mem, int irq)
759 */ 750 */
760 sa1111_wake(sachip); 751 sa1111_wake(sachip);
761 752
753 /*
754 * The interrupt controller must be initialised before any
755 * other device to ensure that the interrupts are available.
756 */
757 if (sachip->irq != NO_IRQ) {
758 ret = sa1111_setup_irq(sachip, pd->irq_base);
759 if (ret)
760 goto err_unmap;
761 }
762
762#ifdef CONFIG_ARCH_SA1100 763#ifdef CONFIG_ARCH_SA1100
763 { 764 {
764 unsigned int val; 765 unsigned int val;
@@ -789,24 +790,14 @@ __sa1111_probe(struct device *me, struct resource *mem, int irq)
789 } 790 }
790#endif 791#endif
791 792
792 /*
793 * The interrupt controller must be initialised before any
794 * other device to ensure that the interrupts are available.
795 */
796 if (sachip->irq != NO_IRQ)
797 sa1111_setup_irq(sachip);
798
799 g_sa1111 = sachip; 793 g_sa1111 = sachip;
800 794
801 has_devs = ~0; 795 has_devs = ~0;
802 if (machine_is_assabet() || machine_is_jornada720() || 796 if (pd)
803 machine_is_badge4()) 797 has_devs &= ~pd->disable_devs;
804 has_devs &= ~(1 << 4);
805 else
806 has_devs &= ~(1 << 1);
807 798
808 for (i = 0; i < ARRAY_SIZE(sa1111_devices); i++) 799 for (i = 0; i < ARRAY_SIZE(sa1111_devices); i++)
809 if (has_devs & (1 << i)) 800 if (sa1111_devices[i].devid & has_devs)
810 sa1111_init_one_child(sachip, mem, &sa1111_devices[i]); 801 sa1111_init_one_child(sachip, mem, &sa1111_devices[i]);
811 802
812 return 0; 803 return 0;
@@ -824,7 +815,10 @@ __sa1111_probe(struct device *me, struct resource *mem, int irq)
824 815
825static int sa1111_remove_one(struct device *dev, void *data) 816static int sa1111_remove_one(struct device *dev, void *data)
826{ 817{
827 device_unregister(dev); 818 struct sa1111_dev *sadev = SA1111_DEV(dev);
819 device_del(&sadev->dev);
820 release_resource(&sadev->res);
821 put_device(&sadev->dev);
828 return 0; 822 return 0;
829} 823}
830 824
@@ -846,6 +840,7 @@ static void __sa1111_remove(struct sa1111 *sachip)
846 if (sachip->irq != NO_IRQ) { 840 if (sachip->irq != NO_IRQ) {
847 irq_set_chained_handler(sachip->irq, NULL); 841 irq_set_chained_handler(sachip->irq, NULL);
848 irq_set_handler_data(sachip->irq, NULL); 842 irq_set_handler_data(sachip->irq, NULL);
843 irq_free_descs(sachip->irq_base, SA1111_IRQ_NR);
849 844
850 release_mem_region(sachip->phys + SA1111_INTC, 512); 845 release_mem_region(sachip->phys + SA1111_INTC, 512);
851 } 846 }
@@ -904,6 +899,9 @@ static int sa1111_suspend(struct platform_device *dev, pm_message_t state)
904 save->skpwm0 = sa1111_readl(base + SA1111_SKPWM0); 899 save->skpwm0 = sa1111_readl(base + SA1111_SKPWM0);
905 save->skpwm1 = sa1111_readl(base + SA1111_SKPWM1); 900 save->skpwm1 = sa1111_readl(base + SA1111_SKPWM1);
906 901
902 sa1111_writel(0, sachip->base + SA1111_SKPWM0);
903 sa1111_writel(0, sachip->base + SA1111_SKPWM1);
904
907 base = sachip->base + SA1111_INTC; 905 base = sachip->base + SA1111_INTC;
908 save->intpol0 = sa1111_readl(base + SA1111_INTPOL0); 906 save->intpol0 = sa1111_readl(base + SA1111_INTPOL0);
909 save->intpol1 = sa1111_readl(base + SA1111_INTPOL1); 907 save->intpol1 = sa1111_readl(base + SA1111_INTPOL1);
@@ -919,13 +917,15 @@ static int sa1111_suspend(struct platform_device *dev, pm_message_t state)
919 */ 917 */
920 val = sa1111_readl(sachip->base + SA1111_SKCR); 918 val = sa1111_readl(sachip->base + SA1111_SKCR);
921 sa1111_writel(val | SKCR_SLEEP, sachip->base + SA1111_SKCR); 919 sa1111_writel(val | SKCR_SLEEP, sachip->base + SA1111_SKCR);
922 sa1111_writel(0, sachip->base + SA1111_SKPWM0);
923 sa1111_writel(0, sachip->base + SA1111_SKPWM1);
924 920
925 clk_disable(sachip->clk); 921 clk_disable(sachip->clk);
926 922
927 spin_unlock_irqrestore(&sachip->lock, flags); 923 spin_unlock_irqrestore(&sachip->lock, flags);
928 924
925#ifdef CONFIG_ARCH_SA1100
926 sa1110_mb_disable();
927#endif
928
929 return 0; 929 return 0;
930} 930}
931 931
@@ -966,6 +966,11 @@ static int sa1111_resume(struct platform_device *dev)
966 */ 966 */
967 sa1111_wake(sachip); 967 sa1111_wake(sachip);
968 968
969#ifdef CONFIG_ARCH_SA1100
970 /* Enable the memory bus request/grant signals */
971 sa1110_mb_enable();
972#endif
973
969 /* 974 /*
970 * Only lock for write ops. Also, sa1111_wake must be called with 975 * Only lock for write ops. Also, sa1111_wake must be called with
971 * released spinlock! 976 * released spinlock!
@@ -1053,6 +1058,7 @@ static struct platform_driver sa1111_device_driver = {
1053 .resume = sa1111_resume, 1058 .resume = sa1111_resume,
1054 .driver = { 1059 .driver = {
1055 .name = "sa1111", 1060 .name = "sa1111",
1061 .owner = THIS_MODULE,
1056 }, 1062 },
1057}; 1063};
1058 1064
@@ -1238,16 +1244,23 @@ EXPORT_SYMBOL(sa1111_set_sleep_io);
1238 * sa1111_enable_device - enable an on-chip SA1111 function block 1244 * sa1111_enable_device - enable an on-chip SA1111 function block
1239 * @sadev: SA1111 function block device to enable 1245 * @sadev: SA1111 function block device to enable
1240 */ 1246 */
1241void sa1111_enable_device(struct sa1111_dev *sadev) 1247int sa1111_enable_device(struct sa1111_dev *sadev)
1242{ 1248{
1243 struct sa1111 *sachip = sa1111_chip_driver(sadev); 1249 struct sa1111 *sachip = sa1111_chip_driver(sadev);
1244 unsigned long flags; 1250 unsigned long flags;
1245 unsigned int val; 1251 unsigned int val;
1252 int ret = 0;
1246 1253
1247 spin_lock_irqsave(&sachip->lock, flags); 1254 if (sachip->pdata && sachip->pdata->enable)
1248 val = sa1111_readl(sachip->base + SA1111_SKPCR); 1255 ret = sachip->pdata->enable(sachip->pdata->data, sadev->devid);
1249 sa1111_writel(val | sadev->skpcr_mask, sachip->base + SA1111_SKPCR); 1256
1250 spin_unlock_irqrestore(&sachip->lock, flags); 1257 if (ret == 0) {
1258 spin_lock_irqsave(&sachip->lock, flags);
1259 val = sa1111_readl(sachip->base + SA1111_SKPCR);
1260 sa1111_writel(val | sadev->skpcr_mask, sachip->base + SA1111_SKPCR);
1261 spin_unlock_irqrestore(&sachip->lock, flags);
1262 }
1263 return ret;
1251} 1264}
1252EXPORT_SYMBOL(sa1111_enable_device); 1265EXPORT_SYMBOL(sa1111_enable_device);
1253 1266
@@ -1265,6 +1278,9 @@ void sa1111_disable_device(struct sa1111_dev *sadev)
1265 val = sa1111_readl(sachip->base + SA1111_SKPCR); 1278 val = sa1111_readl(sachip->base + SA1111_SKPCR);
1266 sa1111_writel(val & ~sadev->skpcr_mask, sachip->base + SA1111_SKPCR); 1279 sa1111_writel(val & ~sadev->skpcr_mask, sachip->base + SA1111_SKPCR);
1267 spin_unlock_irqrestore(&sachip->lock, flags); 1280 spin_unlock_irqrestore(&sachip->lock, flags);
1281
1282 if (sachip->pdata && sachip->pdata->disable)
1283 sachip->pdata->disable(sachip->pdata->data, sadev->devid);
1268} 1284}
1269EXPORT_SYMBOL(sa1111_disable_device); 1285EXPORT_SYMBOL(sa1111_disable_device);
1270 1286
@@ -1279,7 +1295,7 @@ static int sa1111_match(struct device *_dev, struct device_driver *_drv)
1279 struct sa1111_dev *dev = SA1111_DEV(_dev); 1295 struct sa1111_dev *dev = SA1111_DEV(_dev);
1280 struct sa1111_driver *drv = SA1111_DRV(_drv); 1296 struct sa1111_driver *drv = SA1111_DRV(_drv);
1281 1297
1282 return dev->devid == drv->devid; 1298 return dev->devid & drv->devid;
1283} 1299}
1284 1300
1285static int sa1111_bus_suspend(struct device *dev, pm_message_t state) 1301static int sa1111_bus_suspend(struct device *dev, pm_message_t state)
@@ -1304,6 +1320,14 @@ static int sa1111_bus_resume(struct device *dev)
1304 return ret; 1320 return ret;
1305} 1321}
1306 1322
1323static void sa1111_bus_shutdown(struct device *dev)
1324{
1325 struct sa1111_driver *drv = SA1111_DRV(dev->driver);
1326
1327 if (drv && drv->shutdown)
1328 drv->shutdown(SA1111_DEV(dev));
1329}
1330
1307static int sa1111_bus_probe(struct device *dev) 1331static int sa1111_bus_probe(struct device *dev)
1308{ 1332{
1309 struct sa1111_dev *sadev = SA1111_DEV(dev); 1333 struct sa1111_dev *sadev = SA1111_DEV(dev);
@@ -1333,6 +1357,7 @@ struct bus_type sa1111_bus_type = {
1333 .remove = sa1111_bus_remove, 1357 .remove = sa1111_bus_remove,
1334 .suspend = sa1111_bus_suspend, 1358 .suspend = sa1111_bus_suspend,
1335 .resume = sa1111_bus_resume, 1359 .resume = sa1111_bus_resume,
1360 .shutdown = sa1111_bus_shutdown,
1336}; 1361};
1337EXPORT_SYMBOL(sa1111_bus_type); 1362EXPORT_SYMBOL(sa1111_bus_type);
1338 1363
@@ -1349,9 +1374,70 @@ void sa1111_driver_unregister(struct sa1111_driver *driver)
1349} 1374}
1350EXPORT_SYMBOL(sa1111_driver_unregister); 1375EXPORT_SYMBOL(sa1111_driver_unregister);
1351 1376
1377#ifdef CONFIG_DMABOUNCE
1378/*
1379 * According to the "Intel StrongARM SA-1111 Microprocessor Companion
1380 * Chip Specification Update" (June 2000), erratum #7, there is a
1381 * significant bug in the SA1111 SDRAM shared memory controller. If
1382 * an access to a region of memory above 1MB relative to the bank base,
1383 * it is important that address bit 10 _NOT_ be asserted. Depending
1384 * on the configuration of the RAM, bit 10 may correspond to one
1385 * of several different (processor-relative) address bits.
1386 *
1387 * This routine only identifies whether or not a given DMA address
1388 * is susceptible to the bug.
1389 *
1390 * This should only get called for sa1111_device types due to the
1391 * way we configure our device dma_masks.
1392 */
1393static int sa1111_needs_bounce(struct device *dev, dma_addr_t addr, size_t size)
1394{
1395 /*
1396 * Section 4.6 of the "Intel StrongARM SA-1111 Development Module
1397 * User's Guide" mentions that jumpers R51 and R52 control the
1398 * target of SA-1111 DMA (either SDRAM bank 0 on Assabet, or
1399 * SDRAM bank 1 on Neponset). The default configuration selects
1400 * Assabet, so any address in bank 1 is necessarily invalid.
1401 */
1402 return (machine_is_assabet() || machine_is_pfs168()) &&
1403 (addr >= 0xc8000000 || (addr + size) >= 0xc8000000);
1404}
1405
1406static int sa1111_notifier_call(struct notifier_block *n, unsigned long action,
1407 void *data)
1408{
1409 struct sa1111_dev *dev = SA1111_DEV(data);
1410
1411 switch (action) {
1412 case BUS_NOTIFY_ADD_DEVICE:
1413 if (dev->dev.dma_mask && dev->dma_mask < 0xffffffffUL) {
1414 int ret = dmabounce_register_dev(&dev->dev, 1024, 4096,
1415 sa1111_needs_bounce);
1416 if (ret)
1417 dev_err(&dev->dev, "failed to register with dmabounce: %d\n", ret);
1418 }
1419 break;
1420
1421 case BUS_NOTIFY_DEL_DEVICE:
1422 if (dev->dev.dma_mask && dev->dma_mask < 0xffffffffUL)
1423 dmabounce_unregister_dev(&dev->dev);
1424 break;
1425 }
1426 return NOTIFY_OK;
1427}
1428
1429static struct notifier_block sa1111_bus_notifier = {
1430 .notifier_call = sa1111_notifier_call,
1431};
1432#endif
1433
1352static int __init sa1111_init(void) 1434static int __init sa1111_init(void)
1353{ 1435{
1354 int ret = bus_register(&sa1111_bus_type); 1436 int ret = bus_register(&sa1111_bus_type);
1437#ifdef CONFIG_DMABOUNCE
1438 if (ret == 0)
1439 bus_register_notifier(&sa1111_bus_type, &sa1111_bus_notifier);
1440#endif
1355 if (ret == 0) 1441 if (ret == 0)
1356 platform_driver_register(&sa1111_device_driver); 1442 platform_driver_register(&sa1111_device_driver);
1357 return ret; 1443 return ret;
@@ -1360,6 +1446,9 @@ static int __init sa1111_init(void)
1360static void __exit sa1111_exit(void) 1446static void __exit sa1111_exit(void)
1361{ 1447{
1362 platform_driver_unregister(&sa1111_device_driver); 1448 platform_driver_unregister(&sa1111_device_driver);
1449#ifdef CONFIG_DMABOUNCE
1450 bus_unregister_notifier(&sa1111_bus_type, &sa1111_bus_notifier);
1451#endif
1363 bus_unregister(&sa1111_bus_type); 1452 bus_unregister(&sa1111_bus_type);
1364} 1453}
1365 1454
diff --git a/arch/arm/common/timer-sp.c b/arch/arm/common/timer-sp.c
index 8794a34eae6..df13a3ffff3 100644
--- a/arch/arm/common/timer-sp.c
+++ b/arch/arm/common/timer-sp.c
@@ -26,6 +26,7 @@
26#include <linux/irq.h> 26#include <linux/irq.h>
27#include <linux/io.h> 27#include <linux/io.h>
28 28
29#include <asm/sched_clock.h>
29#include <asm/hardware/arm_timer.h> 30#include <asm/hardware/arm_timer.h>
30 31
31static long __init sp804_get_clock_rate(const char *name) 32static long __init sp804_get_clock_rate(const char *name)
@@ -67,7 +68,16 @@ static long __init sp804_get_clock_rate(const char *name)
67 return rate; 68 return rate;
68} 69}
69 70
70void __init sp804_clocksource_init(void __iomem *base, const char *name) 71static void __iomem *sched_clock_base;
72
73static u32 sp804_read(void)
74{
75 return ~readl_relaxed(sched_clock_base + TIMER_VALUE);
76}
77
78void __init __sp804_clocksource_and_sched_clock_init(void __iomem *base,
79 const char *name,
80 int use_sched_clock)
71{ 81{
72 long rate = sp804_get_clock_rate(name); 82 long rate = sp804_get_clock_rate(name);
73 83
@@ -83,6 +93,11 @@ void __init sp804_clocksource_init(void __iomem *base, const char *name)
83 93
84 clocksource_mmio_init(base + TIMER_VALUE, name, 94 clocksource_mmio_init(base + TIMER_VALUE, name,
85 rate, 200, 32, clocksource_mmio_readl_down); 95 rate, 200, 32, clocksource_mmio_readl_down);
96
97 if (use_sched_clock) {
98 sched_clock_base = base;
99 setup_sched_clock(sp804_read, 32, rate);
100 }
86} 101}
87 102
88 103
diff --git a/arch/arm/configs/at91cap9_defconfig b/arch/arm/configs/at91cap9_defconfig
deleted file mode 100644
index 8826eb218e7..00000000000
--- a/arch/arm/configs/at91cap9_defconfig
+++ /dev/null
@@ -1,108 +0,0 @@
1CONFIG_EXPERIMENTAL=y
2# CONFIG_LOCALVERSION_AUTO is not set
3# CONFIG_SWAP is not set
4CONFIG_SYSVIPC=y
5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_BLK_DEV_INITRD=y
7CONFIG_SLAB=y
8CONFIG_MODULES=y
9CONFIG_MODULE_UNLOAD=y
10# CONFIG_BLK_DEV_BSG is not set
11# CONFIG_IOSCHED_DEADLINE is not set
12# CONFIG_IOSCHED_CFQ is not set
13CONFIG_ARCH_AT91=y
14CONFIG_ARCH_AT91CAP9=y
15CONFIG_MACH_AT91CAP9ADK=y
16CONFIG_MTD_AT91_DATAFLASH_CARD=y
17CONFIG_AT91_PROGRAMMABLE_CLOCKS=y
18# CONFIG_ARM_THUMB is not set
19CONFIG_AEABI=y
20CONFIG_LEDS=y
21CONFIG_LEDS_CPU=y
22CONFIG_ZBOOT_ROM_TEXT=0x0
23CONFIG_ZBOOT_ROM_BSS=0x0
24CONFIG_CMDLINE="console=ttyS0,115200 root=/dev/ram0 rw"
25CONFIG_FPE_NWFPE=y
26CONFIG_NET=y
27CONFIG_PACKET=y
28CONFIG_UNIX=y
29CONFIG_INET=y
30CONFIG_IP_PNP=y
31CONFIG_IP_PNP_BOOTP=y
32CONFIG_IP_PNP_RARP=y
33# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
34# CONFIG_INET_XFRM_MODE_TUNNEL is not set
35# CONFIG_INET_XFRM_MODE_BEET is not set
36# CONFIG_INET_LRO is not set
37# CONFIG_INET_DIAG is not set
38# CONFIG_IPV6 is not set
39CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
40CONFIG_MTD=y
41CONFIG_MTD_CMDLINE_PARTS=y
42CONFIG_MTD_CHAR=y
43CONFIG_MTD_BLOCK=y
44CONFIG_MTD_CFI=y
45CONFIG_MTD_JEDECPROBE=y
46CONFIG_MTD_CFI_AMDSTD=y
47CONFIG_MTD_PHYSMAP=y
48CONFIG_MTD_DATAFLASH=y
49CONFIG_MTD_NAND=y
50CONFIG_MTD_NAND_ATMEL=y
51CONFIG_BLK_DEV_LOOP=y
52CONFIG_BLK_DEV_RAM=y
53CONFIG_BLK_DEV_RAM_SIZE=8192
54CONFIG_SCSI=y
55CONFIG_BLK_DEV_SD=y
56CONFIG_SCSI_MULTI_LUN=y
57CONFIG_NETDEVICES=y
58CONFIG_MII=y
59CONFIG_MACB=y
60# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
61CONFIG_INPUT_EVDEV=y
62# CONFIG_INPUT_KEYBOARD is not set
63# CONFIG_INPUT_MOUSE is not set
64CONFIG_INPUT_TOUCHSCREEN=y
65CONFIG_TOUCHSCREEN_ADS7846=y
66# CONFIG_SERIO is not set
67CONFIG_SERIAL_ATMEL=y
68CONFIG_SERIAL_ATMEL_CONSOLE=y
69CONFIG_HW_RANDOM=y
70CONFIG_I2C=y
71CONFIG_I2C_CHARDEV=y
72CONFIG_SPI=y
73CONFIG_SPI_ATMEL=y
74# CONFIG_HWMON is not set
75CONFIG_WATCHDOG=y
76CONFIG_WATCHDOG_NOWAYOUT=y
77CONFIG_FB=y
78CONFIG_FB_ATMEL=y
79CONFIG_LOGO=y
80# CONFIG_LOGO_LINUX_MONO is not set
81# CONFIG_LOGO_LINUX_CLUT224 is not set
82# CONFIG_USB_HID is not set
83CONFIG_USB=y
84CONFIG_USB_DEVICEFS=y
85CONFIG_USB_MON=y
86CONFIG_USB_OHCI_HCD=y
87CONFIG_USB_STORAGE=y
88CONFIG_USB_GADGET=y
89CONFIG_USB_ETH=m
90CONFIG_USB_FILE_STORAGE=m
91CONFIG_MMC=y
92CONFIG_MMC_AT91=m
93CONFIG_RTC_CLASS=y
94CONFIG_RTC_DRV_AT91SAM9=y
95CONFIG_EXT2_FS=y
96CONFIG_VFAT_FS=y
97CONFIG_TMPFS=y
98CONFIG_JFFS2_FS=y
99CONFIG_CRAMFS=y
100CONFIG_NFS_FS=y
101CONFIG_ROOT_NFS=y
102CONFIG_NLS_CODEPAGE_437=y
103CONFIG_NLS_CODEPAGE_850=y
104CONFIG_NLS_ISO8859_1=y
105CONFIG_DEBUG_FS=y
106CONFIG_DEBUG_KERNEL=y
107CONFIG_DEBUG_INFO=y
108CONFIG_DEBUG_USER=y
diff --git a/arch/arm/configs/at91sam9g20_defconfig b/arch/arm/configs/at91sam9g20_defconfig
index 9123568d9a8..994d331b231 100644
--- a/arch/arm/configs/at91sam9g20_defconfig
+++ b/arch/arm/configs/at91sam9g20_defconfig
@@ -74,6 +74,8 @@ CONFIG_LEGACY_PTY_COUNT=16
74CONFIG_SERIAL_ATMEL=y 74CONFIG_SERIAL_ATMEL=y
75CONFIG_SERIAL_ATMEL_CONSOLE=y 75CONFIG_SERIAL_ATMEL_CONSOLE=y
76CONFIG_HW_RANDOM=y 76CONFIG_HW_RANDOM=y
77CONFIG_I2C=y
78CONFIG_I2C_GPIO=y
77CONFIG_SPI=y 79CONFIG_SPI=y
78CONFIG_SPI_ATMEL=y 80CONFIG_SPI_ATMEL=y
79CONFIG_SPI_SPIDEV=y 81CONFIG_SPI_SPIDEV=y
@@ -105,6 +107,7 @@ CONFIG_LEDS_TRIGGERS=y
105CONFIG_LEDS_TRIGGER_TIMER=y 107CONFIG_LEDS_TRIGGER_TIMER=y
106CONFIG_LEDS_TRIGGER_HEARTBEAT=y 108CONFIG_LEDS_TRIGGER_HEARTBEAT=y
107CONFIG_RTC_CLASS=y 109CONFIG_RTC_CLASS=y
110CONFIG_RTC_DRV_RV3029C2=y
108CONFIG_RTC_DRV_AT91SAM9=y 111CONFIG_RTC_DRV_AT91SAM9=y
109CONFIG_EXT2_FS=y 112CONFIG_EXT2_FS=y
110CONFIG_MSDOS_FS=y 113CONFIG_MSDOS_FS=y
diff --git a/arch/arm/configs/imx_v4_v5_defconfig b/arch/arm/configs/imx_v4_v5_defconfig
index a22e9307906..b5ac644e12a 100644
--- a/arch/arm/configs/imx_v4_v5_defconfig
+++ b/arch/arm/configs/imx_v4_v5_defconfig
@@ -45,6 +45,7 @@ CONFIG_FPE_NWFPE=y
45CONFIG_FPE_NWFPE_XP=y 45CONFIG_FPE_NWFPE_XP=y
46CONFIG_PM_DEBUG=y 46CONFIG_PM_DEBUG=y
47CONFIG_NET=y 47CONFIG_NET=y
48CONFIG_SMSC911X=y
48CONFIG_PACKET=y 49CONFIG_PACKET=y
49CONFIG_UNIX=y 50CONFIG_UNIX=y
50CONFIG_INET=y 51CONFIG_INET=y
@@ -68,6 +69,7 @@ CONFIG_MTD_CFI=y
68CONFIG_MTD_CFI_ADV_OPTIONS=y 69CONFIG_MTD_CFI_ADV_OPTIONS=y
69CONFIG_MTD_CFI_GEOMETRY=y 70CONFIG_MTD_CFI_GEOMETRY=y
70# CONFIG_MTD_MAP_BANK_WIDTH_1 is not set 71# CONFIG_MTD_MAP_BANK_WIDTH_1 is not set
72CONFIG_MTD_MAP_BANK_WIDTH_4=y
71# CONFIG_MTD_CFI_I2 is not set 73# CONFIG_MTD_CFI_I2 is not set
72CONFIG_MTD_CFI_INTELEXT=y 74CONFIG_MTD_CFI_INTELEXT=y
73CONFIG_MTD_PHYSMAP=y 75CONFIG_MTD_PHYSMAP=y
@@ -78,6 +80,8 @@ CONFIG_MISC_DEVICES=y
78CONFIG_EEPROM_AT24=y 80CONFIG_EEPROM_AT24=y
79CONFIG_EEPROM_AT25=y 81CONFIG_EEPROM_AT25=y
80CONFIG_NETDEVICES=y 82CONFIG_NETDEVICES=y
83CONFIG_CS89x0=y
84CONFIG_CS89x0_PLATFORM=y
81CONFIG_DM9000=y 85CONFIG_DM9000=y
82CONFIG_SMC91X=y 86CONFIG_SMC91X=y
83CONFIG_SMC911X=y 87CONFIG_SMC911X=y
@@ -115,6 +119,21 @@ CONFIG_FB_IMX=y
115CONFIG_BACKLIGHT_LCD_SUPPORT=y 119CONFIG_BACKLIGHT_LCD_SUPPORT=y
116CONFIG_LCD_CLASS_DEVICE=y 120CONFIG_LCD_CLASS_DEVICE=y
117CONFIG_BACKLIGHT_CLASS_DEVICE=y 121CONFIG_BACKLIGHT_CLASS_DEVICE=y
122CONFIG_LCD_L4F00242T03=y
123CONFIG_MEDIA_SUPPORT=y
124CONFIG_VIDEO_DEV=y
125CONFIG_VIDEO_V4L2_COMMON=y
126CONFIG_VIDEO_MEDIA=y
127CONFIG_VIDEO_V4L2=y
128CONFIG_VIDEOBUF_GEN=y
129CONFIG_VIDEOBUF_DMA_CONTIG=y
130CONFIG_VIDEOBUF2_CORE=y
131CONFIG_VIDEO_CAPTURE_DRIVERS=y
132CONFIG_V4L_PLATFORM_DRIVERS=y
133CONFIG_SOC_CAMERA=y
134CONFIG_SOC_CAMERA_OV2640=y
135CONFIG_VIDEO_MX2_HOSTSUPPORT=y
136CONFIG_VIDEO_MX2=y
118CONFIG_BACKLIGHT_PWM=y 137CONFIG_BACKLIGHT_PWM=y
119CONFIG_FRAMEBUFFER_CONSOLE=y 138CONFIG_FRAMEBUFFER_CONSOLE=y
120CONFIG_FONTS=y 139CONFIG_FONTS=y
diff --git a/arch/arm/configs/imx_v6_v7_defconfig b/arch/arm/configs/imx_v6_v7_defconfig
index 3a4fb2e5fc6..dc6f6411bbf 100644
--- a/arch/arm/configs/imx_v6_v7_defconfig
+++ b/arch/arm/configs/imx_v6_v7_defconfig
@@ -5,6 +5,7 @@ CONFIG_SYSVIPC=y
5CONFIG_LOG_BUF_SHIFT=18 5CONFIG_LOG_BUF_SHIFT=18
6CONFIG_CGROUPS=y 6CONFIG_CGROUPS=y
7CONFIG_RELAY=y 7CONFIG_RELAY=y
8CONFIG_BLK_DEV_INITRD=y
8CONFIG_EXPERT=y 9CONFIG_EXPERT=y
9# CONFIG_SLUB_DEBUG is not set 10# CONFIG_SLUB_DEBUG is not set
10# CONFIG_COMPAT_BRK is not set 11# CONFIG_COMPAT_BRK is not set
@@ -12,7 +13,6 @@ CONFIG_MODULES=y
12CONFIG_MODULE_UNLOAD=y 13CONFIG_MODULE_UNLOAD=y
13CONFIG_MODVERSIONS=y 14CONFIG_MODVERSIONS=y
14CONFIG_MODULE_SRCVERSION_ALL=y 15CONFIG_MODULE_SRCVERSION_ALL=y
15# CONFIG_LBDAF is not set
16# CONFIG_BLK_DEV_BSG is not set 16# CONFIG_BLK_DEV_BSG is not set
17CONFIG_ARCH_MXC=y 17CONFIG_ARCH_MXC=y
18CONFIG_MACH_MX31LILLY=y 18CONFIG_MACH_MX31LILLY=y
@@ -26,7 +26,6 @@ CONFIG_MACH_ARMADILLO5X0=y
26CONFIG_MACH_KZM_ARM11_01=y 26CONFIG_MACH_KZM_ARM11_01=y
27CONFIG_MACH_PCM043=y 27CONFIG_MACH_PCM043=y
28CONFIG_MACH_MX35_3DS=y 28CONFIG_MACH_MX35_3DS=y
29CONFIG_MACH_EUKREA_CPUIMX35=y
30CONFIG_MACH_VPR200=y 29CONFIG_MACH_VPR200=y
31CONFIG_MACH_IMX51_DT=y 30CONFIG_MACH_IMX51_DT=y
32CONFIG_MACH_MX51_3DS=y 31CONFIG_MACH_MX51_3DS=y
@@ -82,8 +81,9 @@ CONFIG_PATA_IMX=y
82CONFIG_NETDEVICES=y 81CONFIG_NETDEVICES=y
83# CONFIG_NET_VENDOR_BROADCOM is not set 82# CONFIG_NET_VENDOR_BROADCOM is not set
84# CONFIG_NET_VENDOR_CHELSIO is not set 83# CONFIG_NET_VENDOR_CHELSIO is not set
84CONFIG_CS89x0=y
85CONFIG_CS89x0_PLATFORM=y
85# CONFIG_NET_VENDOR_FARADAY is not set 86# CONFIG_NET_VENDOR_FARADAY is not set
86CONFIG_FEC=y
87# CONFIG_NET_VENDOR_INTEL is not set 87# CONFIG_NET_VENDOR_INTEL is not set
88# CONFIG_NET_VENDOR_MARVELL is not set 88# CONFIG_NET_VENDOR_MARVELL is not set
89# CONFIG_NET_VENDOR_MICREL is not set 89# CONFIG_NET_VENDOR_MICREL is not set
@@ -126,7 +126,40 @@ CONFIG_WATCHDOG=y
126CONFIG_IMX2_WDT=y 126CONFIG_IMX2_WDT=y
127CONFIG_MFD_MC13XXX=y 127CONFIG_MFD_MC13XXX=y
128CONFIG_REGULATOR=y 128CONFIG_REGULATOR=y
129CONFIG_REGULATOR_FIXED_VOLTAGE=y
130CONFIG_REGULATOR_MC13783=y
129CONFIG_REGULATOR_MC13892=y 131CONFIG_REGULATOR_MC13892=y
132CONFIG_MEDIA_SUPPORT=y
133CONFIG_VIDEO_V4L2=y
134CONFIG_VIDEO_DEV=y
135CONFIG_VIDEO_V4L2_COMMON=y
136CONFIG_VIDEOBUF_GEN=y
137CONFIG_VIDEOBUF2_CORE=y
138CONFIG_VIDEOBUF2_MEMOPS=y
139CONFIG_VIDEOBUF2_DMA_CONTIG=y
140CONFIG_VIDEO_CAPTURE_DRIVERS=y
141CONFIG_V4L_PLATFORM_DRIVERS=y
142CONFIG_SOC_CAMERA=y
143CONFIG_SOC_CAMERA_OV2640=y
144CONFIG_MX3_VIDEO=y
145CONFIG_VIDEO_MX3=y
146CONFIG_FB=y
147CONFIG_FB_MX3=y
148CONFIG_BACKLIGHT_LCD_SUPPORT=y
149CONFIG_LCD_CLASS_DEVICE=y
150CONFIG_LCD_L4F00242T03=y
151CONFIG_BACKLIGHT_CLASS_DEVICE=y
152CONFIG_BACKLIGHT_GENERIC=y
153CONFIG_DUMMY_CONSOLE=y
154CONFIG_FRAMEBUFFER_CONSOLE=y
155CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
156CONFIG_FONTS=y
157CONFIG_FONT_8x8=y
158CONFIG_FONT_8x16=y
159CONFIG_LOGO=y
160CONFIG_LOGO_LINUX_MONO=y
161CONFIG_LOGO_LINUX_VGA16=y
162CONFIG_LOGO_LINUX_CLUT224=y
130CONFIG_USB=y 163CONFIG_USB=y
131CONFIG_USB_EHCI_HCD=y 164CONFIG_USB_EHCI_HCD=y
132CONFIG_USB_EHCI_MXC=y 165CONFIG_USB_EHCI_MXC=y
diff --git a/arch/arm/configs/lpc32xx_defconfig b/arch/arm/configs/lpc32xx_defconfig
new file mode 100644
index 00000000000..fb2088171ca
--- /dev/null
+++ b/arch/arm/configs/lpc32xx_defconfig
@@ -0,0 +1,145 @@
1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y
3CONFIG_IKCONFIG=y
4CONFIG_IKCONFIG_PROC=y
5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_SYSFS_DEPRECATED=y
7CONFIG_SYSFS_DEPRECATED_V2=y
8CONFIG_BLK_DEV_INITRD=y
9CONFIG_CC_OPTIMIZE_FOR_SIZE=y
10CONFIG_SYSCTL_SYSCALL=y
11CONFIG_EMBEDDED=y
12CONFIG_SLAB=y
13CONFIG_MODULES=y
14CONFIG_MODULE_UNLOAD=y
15# CONFIG_BLK_DEV_BSG is not set
16CONFIG_PARTITION_ADVANCED=y
17CONFIG_ARCH_LPC32XX=y
18CONFIG_NO_HZ=y
19CONFIG_HIGH_RES_TIMERS=y
20CONFIG_PREEMPT=y
21CONFIG_AEABI=y
22CONFIG_ZBOOT_ROM_TEXT=0x0
23CONFIG_ZBOOT_ROM_BSS=0x0
24CONFIG_CMDLINE="console=ttyS0,115200n81 root=/dev/ram0"
25CONFIG_CPU_IDLE=y
26CONFIG_FPE_NWFPE=y
27CONFIG_VFP=y
28# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
29CONFIG_BINFMT_AOUT=y
30CONFIG_NET=y
31CONFIG_PACKET=y
32CONFIG_UNIX=y
33CONFIG_INET=y
34CONFIG_IP_MULTICAST=y
35CONFIG_IP_PNP=y
36CONFIG_IP_PNP_DHCP=y
37CONFIG_IP_PNP_BOOTP=y
38# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
39# CONFIG_INET_XFRM_MODE_TUNNEL is not set
40# CONFIG_INET_XFRM_MODE_BEET is not set
41# CONFIG_INET_LRO is not set
42# CONFIG_INET_DIAG is not set
43# CONFIG_IPV6 is not set
44# CONFIG_WIRELESS is not set
45CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
46# CONFIG_FW_LOADER is not set
47CONFIG_MTD=y
48CONFIG_MTD_CMDLINE_PARTS=y
49CONFIG_MTD_CHAR=y
50CONFIG_MTD_BLOCK=y
51CONFIG_MTD_NAND=y
52CONFIG_MTD_NAND_MUSEUM_IDS=y
53CONFIG_BLK_DEV_LOOP=y
54CONFIG_BLK_DEV_CRYPTOLOOP=y
55CONFIG_BLK_DEV_RAM=y
56CONFIG_BLK_DEV_RAM_COUNT=1
57CONFIG_BLK_DEV_RAM_SIZE=16384
58CONFIG_MISC_DEVICES=y
59CONFIG_EEPROM_AT25=y
60CONFIG_SCSI=y
61CONFIG_BLK_DEV_SD=y
62CONFIG_NETDEVICES=y
63CONFIG_MII=y
64CONFIG_PHYLIB=y
65CONFIG_SMSC_PHY=y
66# CONFIG_WLAN is not set
67# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
68CONFIG_INPUT_MOUSEDEV_SCREEN_X=240
69CONFIG_INPUT_MOUSEDEV_SCREEN_Y=320
70CONFIG_INPUT_EVDEV=y
71# CONFIG_INPUT_MOUSE is not set
72CONFIG_INPUT_TOUCHSCREEN=y
73CONFIG_TOUCHSCREEN_LPC32XX=y
74# CONFIG_LEGACY_PTYS is not set
75CONFIG_SERIAL_8250=y
76CONFIG_SERIAL_8250_CONSOLE=y
77# CONFIG_HW_RANDOM is not set
78CONFIG_I2C=y
79CONFIG_I2C_CHARDEV=y
80CONFIG_I2C_PNX=y
81CONFIG_SPI=y
82CONFIG_SPI_PL022=y
83CONFIG_GPIO_SYSFS=y
84# CONFIG_HWMON is not set
85CONFIG_WATCHDOG=y
86CONFIG_PNX4008_WATCHDOG=y
87CONFIG_FB=y
88CONFIG_FB_ARMCLCD=y
89CONFIG_FRAMEBUFFER_CONSOLE=y
90CONFIG_FRAMEBUFFER_CONSOLE_DETECT_PRIMARY=y
91CONFIG_LOGO=y
92# CONFIG_LOGO_LINUX_MONO is not set
93# CONFIG_LOGO_LINUX_VGA16 is not set
94CONFIG_SOUND=y
95CONFIG_SND=y
96CONFIG_SND_SEQUENCER=y
97CONFIG_SND_MIXER_OSS=y
98CONFIG_SND_PCM_OSS=y
99CONFIG_SND_SEQUENCER_OSS=y
100CONFIG_SND_DYNAMIC_MINORS=y
101# CONFIG_SND_VERBOSE_PROCFS is not set
102# CONFIG_SND_DRIVERS is not set
103# CONFIG_SND_ARM is not set
104# CONFIG_SND_SPI is not set
105CONFIG_SND_SOC=y
106# CONFIG_HID_SUPPORT is not set
107CONFIG_USB=y
108CONFIG_USB_STORAGE=y
109CONFIG_USB_LIBUSUAL=y
110CONFIG_MMC=y
111# CONFIG_MMC_BLOCK_BOUNCE is not set
112CONFIG_MMC_ARMMMCI=y
113CONFIG_NEW_LEDS=y
114CONFIG_LEDS_CLASS=y
115CONFIG_LEDS_GPIO=y
116CONFIG_LEDS_TRIGGERS=y
117CONFIG_LEDS_TRIGGER_HEARTBEAT=y
118CONFIG_RTC_CLASS=y
119CONFIG_RTC_INTF_DEV_UIE_EMUL=y
120CONFIG_RTC_DRV_LPC32XX=y
121CONFIG_EXT2_FS=y
122CONFIG_AUTOFS4_FS=y
123CONFIG_MSDOS_FS=y
124CONFIG_VFAT_FS=y
125CONFIG_TMPFS=y
126CONFIG_JFFS2_FS=y
127CONFIG_JFFS2_FS_WBUF_VERIFY=y
128CONFIG_CRAMFS=y
129CONFIG_NFS_FS=y
130CONFIG_NFS_V3=y
131CONFIG_ROOT_NFS=y
132CONFIG_NLS_CODEPAGE_437=y
133CONFIG_NLS_ASCII=y
134CONFIG_NLS_ISO8859_1=y
135CONFIG_NLS_UTF8=y
136# CONFIG_SCHED_DEBUG is not set
137# CONFIG_DEBUG_PREEMPT is not set
138CONFIG_DEBUG_INFO=y
139# CONFIG_FTRACE is not set
140# CONFIG_ARM_UNWIND is not set
141CONFIG_DEBUG_LL=y
142CONFIG_EARLY_PRINTK=y
143CONFIG_CRYPTO_ANSI_CPRNG=y
144# CONFIG_CRYPTO_HW is not set
145CONFIG_CRC_CCITT=y
diff --git a/arch/arm/configs/magician_defconfig b/arch/arm/configs/magician_defconfig
index 443675d317e..a691ef4c600 100644
--- a/arch/arm/configs/magician_defconfig
+++ b/arch/arm/configs/magician_defconfig
@@ -101,7 +101,7 @@ CONFIG_MFD_ASIC3=y
101CONFIG_HTC_EGPIO=y 101CONFIG_HTC_EGPIO=y
102CONFIG_HTC_PASIC3=y 102CONFIG_HTC_PASIC3=y
103CONFIG_REGULATOR=y 103CONFIG_REGULATOR=y
104CONFIG_REGULATOR_BQ24022=y 104CONFIG_REGULATOR_GPIO=y
105CONFIG_FB=y 105CONFIG_FB=y
106CONFIG_FB_PXA=y 106CONFIG_FB_PXA=y
107CONFIG_FB_PXA_OVERLAY=y 107CONFIG_FB_PXA_OVERLAY=y
diff --git a/arch/arm/configs/mini2440_defconfig b/arch/arm/configs/mini2440_defconfig
index 2472a958583..42da9183acc 100644
--- a/arch/arm/configs/mini2440_defconfig
+++ b/arch/arm/configs/mini2440_defconfig
@@ -13,7 +13,7 @@ CONFIG_MODULE_UNLOAD=y
13CONFIG_MODULE_FORCE_UNLOAD=y 13CONFIG_MODULE_FORCE_UNLOAD=y
14# CONFIG_BLK_DEV_BSG is not set 14# CONFIG_BLK_DEV_BSG is not set
15CONFIG_BLK_DEV_INTEGRITY=y 15CONFIG_BLK_DEV_INTEGRITY=y
16CONFIG_ARCH_S3C2410=y 16CONFIG_ARCH_S3C24XX=y
17CONFIG_S3C_ADC=y 17CONFIG_S3C_ADC=y
18CONFIG_S3C24XX_PWM=y 18CONFIG_S3C24XX_PWM=y
19CONFIG_MACH_MINI2440=y 19CONFIG_MACH_MINI2440=y
diff --git a/arch/arm/configs/mxs_defconfig b/arch/arm/configs/mxs_defconfig
index 6ee781bf6bf..1ebbf451c48 100644
--- a/arch/arm/configs/mxs_defconfig
+++ b/arch/arm/configs/mxs_defconfig
@@ -77,10 +77,10 @@ CONFIG_DEVPTS_MULTIPLE_INSTANCES=y
77CONFIG_SERIAL_AMBA_PL011=y 77CONFIG_SERIAL_AMBA_PL011=y
78CONFIG_SERIAL_AMBA_PL011_CONSOLE=y 78CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
79# CONFIG_HW_RANDOM is not set 79# CONFIG_HW_RANDOM is not set
80CONFIG_I2C=m 80CONFIG_I2C=y
81# CONFIG_I2C_COMPAT is not set 81# CONFIG_I2C_COMPAT is not set
82CONFIG_I2C_CHARDEV=m 82CONFIG_I2C_CHARDEV=y
83CONFIG_I2C_MXS=m 83CONFIG_I2C_MXS=y
84CONFIG_SPI=y 84CONFIG_SPI=y
85CONFIG_SPI_GPIO=m 85CONFIG_SPI_GPIO=m
86CONFIG_DEBUG_GPIO=y 86CONFIG_DEBUG_GPIO=y
@@ -90,6 +90,20 @@ CONFIG_GPIO_SYSFS=y
90CONFIG_DISPLAY_SUPPORT=m 90CONFIG_DISPLAY_SUPPORT=m
91# CONFIG_HID_SUPPORT is not set 91# CONFIG_HID_SUPPORT is not set
92# CONFIG_USB_SUPPORT is not set 92# CONFIG_USB_SUPPORT is not set
93CONFIG_SOUND=y
94CONFIG_SND=y
95CONFIG_SND_TIMER=y
96CONFIG_SND_PCM=y
97CONFIG_SND_JACK=y
98CONFIG_SND_DRIVERS=y
99CONFIG_SND_ARM=y
100CONFIG_SND_SOC=y
101CONFIG_SND_MXS_SOC=y
102CONFIG_SND_SOC_MXS_SGTL5000=y
103CONFIG_SND_SOC_I2C_AND_SPI=y
104CONFIG_SND_SOC_SGTL5000=y
105CONFIG_REGULATOR=y
106CONFIG_REGULATOR_FIXED_VOLTAGE=y
93CONFIG_MMC=y 107CONFIG_MMC=y
94CONFIG_MMC_MXS=y 108CONFIG_MMC_MXS=y
95CONFIG_RTC_CLASS=y 109CONFIG_RTC_CLASS=y
diff --git a/arch/arm/configs/s3c2410_defconfig b/arch/arm/configs/s3c2410_defconfig
index f9096c1b0a6..193448f3128 100644
--- a/arch/arm/configs/s3c2410_defconfig
+++ b/arch/arm/configs/s3c2410_defconfig
@@ -3,40 +3,47 @@ CONFIG_SYSVIPC=y
3CONFIG_IKCONFIG=m 3CONFIG_IKCONFIG=m
4CONFIG_IKCONFIG_PROC=y 4CONFIG_IKCONFIG_PROC=y
5CONFIG_LOG_BUF_SHIFT=16 5CONFIG_LOG_BUF_SHIFT=16
6CONFIG_SYSFS_DEPRECATED_V2=y
7CONFIG_BLK_DEV_INITRD=y 6CONFIG_BLK_DEV_INITRD=y
8CONFIG_SLAB=y 7CONFIG_SLAB=y
9CONFIG_MODULES=y 8CONFIG_MODULES=y
10CONFIG_MODULE_UNLOAD=y 9CONFIG_MODULE_UNLOAD=y
11# CONFIG_BLK_DEV_BSG is not set 10# CONFIG_BLK_DEV_BSG is not set
12CONFIG_ARCH_S3C2410=y 11CONFIG_PARTITION_ADVANCED=y
12CONFIG_BSD_DISKLABEL=y
13CONFIG_SOLARIS_X86_PARTITION=y
14CONFIG_ARCH_S3C24XX=y
13CONFIG_S3C_BOOT_ERROR_RESET=y 15CONFIG_S3C_BOOT_ERROR_RESET=y
14CONFIG_S3C_ADC=y 16CONFIG_S3C_ADC=y
15CONFIG_S3C24XX_PWM=y 17CONFIG_S3C24XX_PWM=y
16CONFIG_ARCH_SMDK2410=y 18CONFIG_CPU_S3C2412=y
19CONFIG_CPU_S3C2416=y
20CONFIG_CPU_S3C2440=y
21CONFIG_CPU_S3C2442=y
22CONFIG_CPU_S3C2443=y
23CONFIG_MACH_AML_M5900=y
24CONFIG_ARCH_BAST=y
17CONFIG_ARCH_H1940=y 25CONFIG_ARCH_H1940=y
18CONFIG_MACH_N30=y 26CONFIG_MACH_N30=y
19CONFIG_ARCH_BAST=y
20CONFIG_MACH_OTOM=y 27CONFIG_MACH_OTOM=y
21CONFIG_MACH_AML_M5900=y 28CONFIG_MACH_QT2410=y
29CONFIG_ARCH_SMDK2410=y
22CONFIG_MACH_TCT_HAMMER=y 30CONFIG_MACH_TCT_HAMMER=y
23CONFIG_MACH_VR1000=y 31CONFIG_MACH_VR1000=y
24CONFIG_MACH_QT2410=y
25CONFIG_MACH_JIVE=y 32CONFIG_MACH_JIVE=y
26CONFIG_MACH_SMDK2412=y 33CONFIG_MACH_SMDK2412=y
27CONFIG_MACH_VSTMS=y 34CONFIG_MACH_VSTMS=y
28CONFIG_MACH_SMDK2416=y 35CONFIG_MACH_SMDK2416=y
29CONFIG_MACH_ANUBIS=y 36CONFIG_MACH_ANUBIS=y
30CONFIG_MACH_NEO1973_GTA02=y 37CONFIG_MACH_AT2440EVB=y
38CONFIG_MACH_MINI2440=y
39CONFIG_MACH_NEXCODER_2440=y
31CONFIG_MACH_OSIRIS=y 40CONFIG_MACH_OSIRIS=y
32CONFIG_MACH_OSIRIS_DVS=m 41CONFIG_MACH_OSIRIS_DVS=m
33CONFIG_MACH_RX3715=y 42CONFIG_MACH_RX3715=y
34CONFIG_ARCH_S3C2440=y 43CONFIG_ARCH_S3C2440=y
35CONFIG_MACH_NEXCODER_2440=y 44CONFIG_MACH_NEO1973_GTA02=y
36CONFIG_SMDK2440_CPU2442=y
37CONFIG_MACH_AT2440EVB=y
38CONFIG_MACH_MINI2440=y
39CONFIG_MACH_RX1950=y 45CONFIG_MACH_RX1950=y
46CONFIG_SMDK2440_CPU2442=y
40CONFIG_MACH_SMDK2443=y 47CONFIG_MACH_SMDK2443=y
41# CONFIG_ARM_THUMB is not set 48# CONFIG_ARM_THUMB is not set
42CONFIG_ZBOOT_ROM_TEXT=0x0 49CONFIG_ZBOOT_ROM_TEXT=0x0
@@ -45,7 +52,6 @@ CONFIG_CMDLINE="root=/dev/hda1 ro init=/bin/bash console=ttySAC0"
45CONFIG_FPE_NWFPE=y 52CONFIG_FPE_NWFPE=y
46CONFIG_FPE_NWFPE_XP=y 53CONFIG_FPE_NWFPE_XP=y
47CONFIG_BINFMT_AOUT=y 54CONFIG_BINFMT_AOUT=y
48CONFIG_PM=y
49CONFIG_APM_EMULATION=m 55CONFIG_APM_EMULATION=m
50CONFIG_NET=y 56CONFIG_NET=y
51CONFIG_PACKET=y 57CONFIG_PACKET=y
@@ -58,7 +64,6 @@ CONFIG_IP_PNP=y
58CONFIG_IP_PNP_DHCP=y 64CONFIG_IP_PNP_DHCP=y
59CONFIG_IP_PNP_BOOTP=y 65CONFIG_IP_PNP_BOOTP=y
60CONFIG_NET_IPIP=m 66CONFIG_NET_IPIP=m
61CONFIG_NET_IPGRE=m
62CONFIG_INET_AH=m 67CONFIG_INET_AH=m
63CONFIG_INET_ESP=m 68CONFIG_INET_ESP=m
64CONFIG_INET_IPCOMP=m 69CONFIG_INET_IPCOMP=m
@@ -80,7 +85,6 @@ CONFIG_IPV6_MIP6=m
80CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION=m 85CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION=m
81CONFIG_IPV6_TUNNEL=m 86CONFIG_IPV6_TUNNEL=m
82CONFIG_NETFILTER=y 87CONFIG_NETFILTER=y
83CONFIG_NETFILTER_NETLINK_QUEUE=m
84CONFIG_NF_CONNTRACK=m 88CONFIG_NF_CONNTRACK=m
85CONFIG_NF_CONNTRACK_EVENTS=y 89CONFIG_NF_CONNTRACK_EVENTS=y
86CONFIG_NF_CT_PROTO_DCCP=m 90CONFIG_NF_CT_PROTO_DCCP=m
@@ -138,7 +142,6 @@ CONFIG_IP_VS=m
138CONFIG_NF_CONNTRACK_IPV4=m 142CONFIG_NF_CONNTRACK_IPV4=m
139CONFIG_IP_NF_QUEUE=m 143CONFIG_IP_NF_QUEUE=m
140CONFIG_IP_NF_IPTABLES=m 144CONFIG_IP_NF_IPTABLES=m
141CONFIG_IP_NF_MATCH_ADDRTYPE=m
142CONFIG_IP_NF_MATCH_AH=m 145CONFIG_IP_NF_MATCH_AH=m
143CONFIG_IP_NF_MATCH_ECN=m 146CONFIG_IP_NF_MATCH_ECN=m
144CONFIG_IP_NF_MATCH_TTL=m 147CONFIG_IP_NF_MATCH_TTL=m
@@ -150,7 +153,6 @@ CONFIG_NF_NAT=m
150CONFIG_IP_NF_TARGET_MASQUERADE=m 153CONFIG_IP_NF_TARGET_MASQUERADE=m
151CONFIG_IP_NF_TARGET_NETMAP=m 154CONFIG_IP_NF_TARGET_NETMAP=m
152CONFIG_IP_NF_TARGET_REDIRECT=m 155CONFIG_IP_NF_TARGET_REDIRECT=m
153CONFIG_NF_NAT_SNMP_BASIC=m
154CONFIG_IP_NF_MANGLE=m 156CONFIG_IP_NF_MANGLE=m
155CONFIG_IP_NF_TARGET_CLUSTERIP=m 157CONFIG_IP_NF_TARGET_CLUSTERIP=m
156CONFIG_IP_NF_TARGET_ECN=m 158CONFIG_IP_NF_TARGET_ECN=m
@@ -177,8 +179,6 @@ CONFIG_IP6_NF_TARGET_REJECT=m
177CONFIG_IP6_NF_MANGLE=m 179CONFIG_IP6_NF_MANGLE=m
178CONFIG_IP6_NF_RAW=m 180CONFIG_IP6_NF_RAW=m
179CONFIG_BT=m 181CONFIG_BT=m
180CONFIG_BT_L2CAP=m
181CONFIG_BT_SCO=m
182CONFIG_BT_RFCOMM=m 182CONFIG_BT_RFCOMM=m
183CONFIG_BT_RFCOMM_TTY=y 183CONFIG_BT_RFCOMM_TTY=y
184CONFIG_BT_BNEP=m 184CONFIG_BT_BNEP=m
@@ -199,7 +199,6 @@ CONFIG_MAC80211_MESH=y
199CONFIG_MAC80211_LEDS=y 199CONFIG_MAC80211_LEDS=y
200CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 200CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
201CONFIG_MTD=y 201CONFIG_MTD=y
202CONFIG_MTD_PARTITIONS=y
203CONFIG_MTD_REDBOOT_PARTS=y 202CONFIG_MTD_REDBOOT_PARTS=y
204CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED=y 203CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED=y
205CONFIG_MTD_CMDLINE_PARTS=y 204CONFIG_MTD_CMDLINE_PARTS=y
@@ -221,9 +220,6 @@ CONFIG_BLK_DEV_NBD=m
221CONFIG_BLK_DEV_UB=m 220CONFIG_BLK_DEV_UB=m
222CONFIG_BLK_DEV_RAM=y 221CONFIG_BLK_DEV_RAM=y
223CONFIG_ATA_OVER_ETH=m 222CONFIG_ATA_OVER_ETH=m
224CONFIG_EEPROM_AT25=m
225CONFIG_EEPROM_LEGACY=m
226CONFIG_EEPROM_93CX6=m
227CONFIG_IDE=y 223CONFIG_IDE=y
228CONFIG_BLK_DEV_IDECD=y 224CONFIG_BLK_DEV_IDECD=y
229CONFIG_BLK_DEV_IDETAPE=m 225CONFIG_BLK_DEV_IDETAPE=m
@@ -240,7 +236,6 @@ CONFIG_SCSI_MULTI_LUN=y
240CONFIG_SCSI_CONSTANTS=y 236CONFIG_SCSI_CONSTANTS=y
241CONFIG_SCSI_SCAN_ASYNC=y 237CONFIG_SCSI_SCAN_ASYNC=y
242CONFIG_NETDEVICES=y 238CONFIG_NETDEVICES=y
243CONFIG_NET_ETHERNET=y
244CONFIG_DM9000=y 239CONFIG_DM9000=y
245CONFIG_INPUT_EVDEV=y 240CONFIG_INPUT_EVDEV=y
246CONFIG_MOUSE_APPLETOUCH=m 241CONFIG_MOUSE_APPLETOUCH=m
@@ -274,7 +269,6 @@ CONFIG_JOYSTICK_XPAD_LEDS=y
274CONFIG_INPUT_TOUCHSCREEN=y 269CONFIG_INPUT_TOUCHSCREEN=y
275CONFIG_TOUCHSCREEN_USB_COMPOSITE=m 270CONFIG_TOUCHSCREEN_USB_COMPOSITE=m
276CONFIG_INPUT_MISC=y 271CONFIG_INPUT_MISC=y
277CONFIG_INPUT_ATI_REMOTE=m
278CONFIG_INPUT_ATI_REMOTE2=m 272CONFIG_INPUT_ATI_REMOTE2=m
279CONFIG_INPUT_KEYSPAN_REMOTE=m 273CONFIG_INPUT_KEYSPAN_REMOTE=m
280CONFIG_INPUT_POWERMATE=m 274CONFIG_INPUT_POWERMATE=m
@@ -300,7 +294,6 @@ CONFIG_I2C_SIMTEC=y
300CONFIG_SPI=y 294CONFIG_SPI=y
301CONFIG_SPI_GPIO=m 295CONFIG_SPI_GPIO=m
302CONFIG_SPI_S3C24XX=m 296CONFIG_SPI_S3C24XX=m
303CONFIG_SPI_S3C24XX_GPIO=m
304CONFIG_SPI_SPIDEV=m 297CONFIG_SPI_SPIDEV=m
305CONFIG_SPI_TLE62X0=m 298CONFIG_SPI_TLE62X0=m
306CONFIG_SENSORS_LM75=m 299CONFIG_SENSORS_LM75=m
@@ -315,7 +308,6 @@ CONFIG_FB_MODE_HELPERS=y
315CONFIG_FB_S3C2410=y 308CONFIG_FB_S3C2410=y
316CONFIG_FB_SM501=y 309CONFIG_FB_SM501=y
317CONFIG_BACKLIGHT_PWM=m 310CONFIG_BACKLIGHT_PWM=m
318# CONFIG_VGA_CONSOLE is not set
319CONFIG_FRAMEBUFFER_CONSOLE=y 311CONFIG_FRAMEBUFFER_CONSOLE=y
320CONFIG_SOUND=y 312CONFIG_SOUND=y
321CONFIG_SND=y 313CONFIG_SND=y
@@ -330,10 +322,6 @@ CONFIG_SND_VERBOSE_PRINTK=y
330CONFIG_SND_USB_AUDIO=m 322CONFIG_SND_USB_AUDIO=m
331CONFIG_SND_USB_CAIAQ=m 323CONFIG_SND_USB_CAIAQ=m
332CONFIG_SND_SOC=y 324CONFIG_SND_SOC=y
333CONFIG_SND_S3C24XX_SOC=y
334CONFIG_SND_S3C24XX_SOC_JIVE_WM8750=m
335CONFIG_SND_S3C24XX_SOC_SMDK2443_WM9710=m
336CONFIG_SND_S3C24XX_SOC_LN2440SBC_ALC650=m
337# CONFIG_USB_HID is not set 325# CONFIG_USB_HID is not set
338CONFIG_USB=y 326CONFIG_USB=y
339CONFIG_USB_DEVICEFS=y 327CONFIG_USB_DEVICEFS=y
@@ -387,9 +375,7 @@ CONFIG_MMC_TEST=m
387CONFIG_MMC_SDHCI=m 375CONFIG_MMC_SDHCI=m
388CONFIG_MMC_SPI=m 376CONFIG_MMC_SPI=m
389CONFIG_MMC_S3C=y 377CONFIG_MMC_S3C=y
390CONFIG_LEDS_CLASS=m
391CONFIG_LEDS_S3C24XX=m 378CONFIG_LEDS_S3C24XX=m
392CONFIG_LEDS_H1940=m
393CONFIG_LEDS_PCA9532=m 379CONFIG_LEDS_PCA9532=m
394CONFIG_LEDS_GPIO=m 380CONFIG_LEDS_GPIO=m
395CONFIG_LEDS_PCA955X=m 381CONFIG_LEDS_PCA955X=m
@@ -410,8 +396,6 @@ CONFIG_EXT3_FS=y
410CONFIG_EXT3_FS_POSIX_ACL=y 396CONFIG_EXT3_FS_POSIX_ACL=y
411CONFIG_EXT4_FS=m 397CONFIG_EXT4_FS=m
412CONFIG_EXT4_FS_POSIX_ACL=y 398CONFIG_EXT4_FS_POSIX_ACL=y
413CONFIG_INOTIFY=y
414CONFIG_AUTOFS_FS=m
415CONFIG_AUTOFS4_FS=m 399CONFIG_AUTOFS4_FS=m
416CONFIG_FUSE_FS=m 400CONFIG_FUSE_FS=m
417CONFIG_ISO9660_FS=y 401CONFIG_ISO9660_FS=y
@@ -436,9 +420,6 @@ CONFIG_NFSD=m
436CONFIG_NFSD_V3_ACL=y 420CONFIG_NFSD_V3_ACL=y
437CONFIG_NFSD_V4=y 421CONFIG_NFSD_V4=y
438CONFIG_CIFS=m 422CONFIG_CIFS=m
439CONFIG_PARTITION_ADVANCED=y
440CONFIG_BSD_DISKLABEL=y
441CONFIG_SOLARIS_X86_PARTITION=y
442CONFIG_NLS_CODEPAGE_437=y 423CONFIG_NLS_CODEPAGE_437=y
443CONFIG_NLS_CODEPAGE_737=m 424CONFIG_NLS_CODEPAGE_737=m
444CONFIG_NLS_CODEPAGE_775=m 425CONFIG_NLS_CODEPAGE_775=m
@@ -481,9 +462,7 @@ CONFIG_MAGIC_SYSRQ=y
481CONFIG_DEBUG_KERNEL=y 462CONFIG_DEBUG_KERNEL=y
482CONFIG_DEBUG_MUTEXES=y 463CONFIG_DEBUG_MUTEXES=y
483CONFIG_DEBUG_INFO=y 464CONFIG_DEBUG_INFO=y
484# CONFIG_RCU_CPU_STALL_DETECTOR is not set
485CONFIG_SYSCTL_SYSCALL_CHECK=y 465CONFIG_SYSCTL_SYSCALL_CHECK=y
486CONFIG_DEBUG_USER=y 466CONFIG_DEBUG_USER=y
487CONFIG_DEBUG_ERRORS=y
488CONFIG_DEBUG_LL=y 467CONFIG_DEBUG_LL=y
489# CONFIG_CRYPTO_ANSI_CPRNG is not set 468# CONFIG_CRYPTO_ANSI_CPRNG is not set
diff --git a/arch/arm/configs/tct_hammer_defconfig b/arch/arm/configs/tct_hammer_defconfig
index 95c0f0d63db..1d24f8458be 100644
--- a/arch/arm/configs/tct_hammer_defconfig
+++ b/arch/arm/configs/tct_hammer_defconfig
@@ -14,7 +14,7 @@ CONFIG_SLOB=y
14CONFIG_MODULES=y 14CONFIG_MODULES=y
15CONFIG_MODULE_UNLOAD=y 15CONFIG_MODULE_UNLOAD=y
16# CONFIG_BLK_DEV_BSG is not set 16# CONFIG_BLK_DEV_BSG is not set
17CONFIG_ARCH_S3C2410=y 17CONFIG_ARCH_S3C24XX=y
18CONFIG_MACH_TCT_HAMMER=y 18CONFIG_MACH_TCT_HAMMER=y
19CONFIG_ZBOOT_ROM_TEXT=0x0 19CONFIG_ZBOOT_ROM_TEXT=0x0
20CONFIG_ZBOOT_ROM_BSS=0x0 20CONFIG_ZBOOT_ROM_BSS=0x0
diff --git a/arch/arm/configs/tegra_defconfig b/arch/arm/configs/tegra_defconfig
index fd5d3041d71..351d6708c3a 100644
--- a/arch/arm/configs/tegra_defconfig
+++ b/arch/arm/configs/tegra_defconfig
@@ -11,11 +11,14 @@ CONFIG_RT_GROUP_SCHED=y
11CONFIG_BLK_DEV_INITRD=y 11CONFIG_BLK_DEV_INITRD=y
12# CONFIG_ELF_CORE is not set 12# CONFIG_ELF_CORE is not set
13CONFIG_EMBEDDED=y 13CONFIG_EMBEDDED=y
14CONFIG_PERF_EVENTS=y
14CONFIG_SLAB=y 15CONFIG_SLAB=y
15CONFIG_MODULES=y 16CONFIG_MODULES=y
16CONFIG_MODULE_UNLOAD=y 17CONFIG_MODULE_UNLOAD=y
17CONFIG_MODULE_FORCE_UNLOAD=y 18CONFIG_MODULE_FORCE_UNLOAD=y
18# CONFIG_BLK_DEV_BSG is not set 19# CONFIG_BLK_DEV_BSG is not set
20CONFIG_PARTITION_ADVANCED=y
21CONFIG_EFI_PARTITION=y
19# CONFIG_IOSCHED_DEADLINE is not set 22# CONFIG_IOSCHED_DEADLINE is not set
20# CONFIG_IOSCHED_CFQ is not set 23# CONFIG_IOSCHED_CFQ is not set
21CONFIG_ARCH_TEGRA=y 24CONFIG_ARCH_TEGRA=y
@@ -27,18 +30,20 @@ CONFIG_MACH_PAZ00=y
27CONFIG_MACH_TRIMSLICE=y 30CONFIG_MACH_TRIMSLICE=y
28CONFIG_MACH_WARIO=y 31CONFIG_MACH_WARIO=y
29CONFIG_MACH_VENTANA=y 32CONFIG_MACH_VENTANA=y
30CONFIG_TEGRA_DEBUG_UARTD=y 33CONFIG_TEGRA_EMC_SCALING_ENABLE=y
31CONFIG_ARM_ERRATA_742230=y
32CONFIG_NO_HZ=y 34CONFIG_NO_HZ=y
33CONFIG_HIGH_RES_TIMERS=y 35CONFIG_HIGH_RES_TIMERS=y
34CONFIG_SMP=y 36CONFIG_SMP=y
35CONFIG_NR_CPUS=2
36CONFIG_PREEMPT=y 37CONFIG_PREEMPT=y
37CONFIG_AEABI=y 38CONFIG_AEABI=y
38# CONFIG_OABI_COMPAT is not set 39# CONFIG_OABI_COMPAT is not set
39CONFIG_HIGHMEM=y 40CONFIG_HIGHMEM=y
40CONFIG_ZBOOT_ROM_TEXT=0x0 41CONFIG_ZBOOT_ROM_TEXT=0x0
41CONFIG_ZBOOT_ROM_BSS=0x0 42CONFIG_ZBOOT_ROM_BSS=0x0
43CONFIG_AUTO_ZRELADDR=y
44CONFIG_CPU_FREQ=y
45CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
46CONFIG_CPU_IDLE=y
42CONFIG_VFP=y 47CONFIG_VFP=y
43CONFIG_NET=y 48CONFIG_NET=y
44CONFIG_PACKET=y 49CONFIG_PACKET=y
@@ -68,7 +73,6 @@ CONFIG_IPV6_MULTIPLE_TABLES=y
68# CONFIG_FIRMWARE_IN_KERNEL is not set 73# CONFIG_FIRMWARE_IN_KERNEL is not set
69CONFIG_PROC_DEVICETREE=y 74CONFIG_PROC_DEVICETREE=y
70CONFIG_BLK_DEV_LOOP=y 75CONFIG_BLK_DEV_LOOP=y
71CONFIG_MISC_DEVICES=y
72CONFIG_AD525X_DPOT=y 76CONFIG_AD525X_DPOT=y
73CONFIG_AD525X_DPOT_I2C=y 77CONFIG_AD525X_DPOT_I2C=y
74CONFIG_ICS932S401=y 78CONFIG_ICS932S401=y
@@ -76,6 +80,7 @@ CONFIG_APDS9802ALS=y
76CONFIG_ISL29003=y 80CONFIG_ISL29003=y
77CONFIG_SCSI=y 81CONFIG_SCSI=y
78CONFIG_BLK_DEV_SD=y 82CONFIG_BLK_DEV_SD=y
83CONFIG_BLK_DEV_SR=y
79# CONFIG_SCSI_LOWLEVEL is not set 84# CONFIG_SCSI_LOWLEVEL is not set
80CONFIG_NETDEVICES=y 85CONFIG_NETDEVICES=y
81CONFIG_DUMMY=y 86CONFIG_DUMMY=y
@@ -85,8 +90,7 @@ CONFIG_USB_USBNET=y
85CONFIG_USB_NET_SMSC75XX=y 90CONFIG_USB_NET_SMSC75XX=y
86CONFIG_USB_NET_SMSC95XX=y 91CONFIG_USB_NET_SMSC95XX=y
87# CONFIG_WLAN is not set 92# CONFIG_WLAN is not set
88# CONFIG_INPUT is not set 93CONFIG_INPUT_EVDEV=y
89# CONFIG_SERIO is not set
90# CONFIG_VT is not set 94# CONFIG_VT is not set
91# CONFIG_LEGACY_PTYS is not set 95# CONFIG_LEGACY_PTYS is not set
92# CONFIG_DEVKMEM is not set 96# CONFIG_DEVKMEM is not set
@@ -96,13 +100,15 @@ CONFIG_SERIAL_OF_PLATFORM=y
96# CONFIG_HW_RANDOM is not set 100# CONFIG_HW_RANDOM is not set
97CONFIG_I2C=y 101CONFIG_I2C=y
98# CONFIG_I2C_COMPAT is not set 102# CONFIG_I2C_COMPAT is not set
99# CONFIG_I2C_HELPER_AUTO is not set
100CONFIG_I2C_TEGRA=y 103CONFIG_I2C_TEGRA=y
101CONFIG_SPI=y 104CONFIG_SPI=y
102CONFIG_SPI_TEGRA=y 105CONFIG_SPI_TEGRA=y
103CONFIG_SENSORS_LM90=y 106CONFIG_SENSORS_LM90=y
104CONFIG_MFD_TPS6586X=y 107CONFIG_MFD_TPS6586X=y
105CONFIG_REGULATOR=y 108CONFIG_REGULATOR=y
109CONFIG_REGULATOR_FIXED_VOLTAGE=y
110CONFIG_REGULATOR_VIRTUAL_CONSUMER=y
111CONFIG_REGULATOR_GPIO=y
106CONFIG_REGULATOR_TPS6586X=y 112CONFIG_REGULATOR_TPS6586X=y
107CONFIG_SOUND=y 113CONFIG_SOUND=y
108CONFIG_SND=y 114CONFIG_SND=y
@@ -116,11 +122,13 @@ CONFIG_SND_SOC=y
116CONFIG_SND_SOC_TEGRA=y 122CONFIG_SND_SOC_TEGRA=y
117CONFIG_SND_SOC_TEGRA_WM8903=y 123CONFIG_SND_SOC_TEGRA_WM8903=y
118CONFIG_SND_SOC_TEGRA_TRIMSLICE=y 124CONFIG_SND_SOC_TEGRA_TRIMSLICE=y
125CONFIG_SND_SOC_TEGRA_ALC5632=y
119CONFIG_USB=y 126CONFIG_USB=y
120CONFIG_USB_EHCI_HCD=y 127CONFIG_USB_EHCI_HCD=y
121CONFIG_USB_EHCI_TEGRA=y 128CONFIG_USB_EHCI_TEGRA=y
122CONFIG_USB_STORAGE=y 129CONFIG_USB_STORAGE=y
123CONFIG_MMC=y 130CONFIG_MMC=y
131CONFIG_MMC_BLOCK_MINORS=16
124CONFIG_MMC_SDHCI=y 132CONFIG_MMC_SDHCI=y
125CONFIG_MMC_SDHCI_PLTFM=y 133CONFIG_MMC_SDHCI_PLTFM=y
126CONFIG_MMC_SDHCI_TEGRA=y 134CONFIG_MMC_SDHCI_TEGRA=y
@@ -130,6 +138,11 @@ CONFIG_STAGING=y
130CONFIG_IIO=y 138CONFIG_IIO=y
131CONFIG_SENSORS_ISL29018=y 139CONFIG_SENSORS_ISL29018=y
132CONFIG_SENSORS_AK8975=y 140CONFIG_SENSORS_AK8975=y
141CONFIG_MFD_NVEC=y
142CONFIG_KEYBOARD_NVEC=y
143CONFIG_SERIO_NVEC_PS2=y
144CONFIG_TEGRA_IOMMU_GART=y
145CONFIG_TEGRA_IOMMU_SMMU=y
133CONFIG_EXT2_FS=y 146CONFIG_EXT2_FS=y
134CONFIG_EXT2_FS_XATTR=y 147CONFIG_EXT2_FS_XATTR=y
135CONFIG_EXT2_FS_POSIX_ACL=y 148CONFIG_EXT2_FS_POSIX_ACL=y
@@ -138,13 +151,12 @@ CONFIG_EXT3_FS=y
138# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set 151# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
139CONFIG_EXT3_FS_POSIX_ACL=y 152CONFIG_EXT3_FS_POSIX_ACL=y
140CONFIG_EXT3_FS_SECURITY=y 153CONFIG_EXT3_FS_SECURITY=y
154CONFIG_EXT4_FS=y
141# CONFIG_DNOTIFY is not set 155# CONFIG_DNOTIFY is not set
142CONFIG_VFAT_FS=y 156CONFIG_VFAT_FS=y
143CONFIG_TMPFS=y 157CONFIG_TMPFS=y
144CONFIG_NFS_FS=y 158CONFIG_NFS_FS=y
145CONFIG_ROOT_NFS=y 159CONFIG_ROOT_NFS=y
146CONFIG_PARTITION_ADVANCED=y
147CONFIG_EFI_PARTITION=y
148CONFIG_NLS_CODEPAGE_437=y 160CONFIG_NLS_CODEPAGE_437=y
149CONFIG_NLS_ISO8859_1=y 161CONFIG_NLS_ISO8859_1=y
150CONFIG_PRINTK_TIME=y 162CONFIG_PRINTK_TIME=y
@@ -162,9 +174,8 @@ CONFIG_DEBUG_SG=y
162CONFIG_DEBUG_LL=y 174CONFIG_DEBUG_LL=y
163CONFIG_EARLY_PRINTK=y 175CONFIG_EARLY_PRINTK=y
164CONFIG_CRYPTO_ECB=y 176CONFIG_CRYPTO_ECB=y
165CONFIG_CRYPTO_AES=y
166CONFIG_CRYPTO_ARC4=y 177CONFIG_CRYPTO_ARC4=y
167CONFIG_CRYPTO_TWOFISH=y 178CONFIG_CRYPTO_TWOFISH=y
168# CONFIG_CRYPTO_ANSI_CPRNG is not set 179# CONFIG_CRYPTO_ANSI_CPRNG is not set
180CONFIG_CRYPTO_DEV_TEGRA_AES=y
169CONFIG_CRC_CCITT=y 181CONFIG_CRC_CCITT=y
170CONFIG_CRC16=y
diff --git a/arch/arm/configs/u8500_defconfig b/arch/arm/configs/u8500_defconfig
index 2d7b6e7b727..889d73ac1ae 100644
--- a/arch/arm/configs/u8500_defconfig
+++ b/arch/arm/configs/u8500_defconfig
@@ -13,6 +13,7 @@ CONFIG_UX500_SOC_DB8500=y
13CONFIG_MACH_HREFV60=y 13CONFIG_MACH_HREFV60=y
14CONFIG_MACH_SNOWBALL=y 14CONFIG_MACH_SNOWBALL=y
15CONFIG_MACH_U5500=y 15CONFIG_MACH_U5500=y
16CONFIG_MACH_UX500_DT=y
16CONFIG_NO_HZ=y 17CONFIG_NO_HZ=y
17CONFIG_HIGH_RES_TIMERS=y 18CONFIG_HIGH_RES_TIMERS=y
18CONFIG_SMP=y 19CONFIG_SMP=y
diff --git a/arch/arm/include/asm/hardware/arm_timer.h b/arch/arm/include/asm/hardware/arm_timer.h
index c0f4e7bf22d..d6030ff599d 100644
--- a/arch/arm/include/asm/hardware/arm_timer.h
+++ b/arch/arm/include/asm/hardware/arm_timer.h
@@ -9,7 +9,12 @@
9 * 9 *
10 * Integrator AP has 16-bit timers, Integrator CP, Versatile and Realview 10 * Integrator AP has 16-bit timers, Integrator CP, Versatile and Realview
11 * can have 16-bit or 32-bit selectable via a bit in the control register. 11 * can have 16-bit or 32-bit selectable via a bit in the control register.
12 *
13 * Every SP804 contains two identical timers.
12 */ 14 */
15#define TIMER_1_BASE 0x00
16#define TIMER_2_BASE 0x20
17
13#define TIMER_LOAD 0x00 /* ACVR rw */ 18#define TIMER_LOAD 0x00 /* ACVR rw */
14#define TIMER_VALUE 0x04 /* ACVR ro */ 19#define TIMER_VALUE 0x04 /* ACVR ro */
15#define TIMER_CTRL 0x08 /* ACVR rw */ 20#define TIMER_CTRL 0x08 /* ACVR rw */
diff --git a/arch/arm/include/asm/hardware/entry-macro-iomd.S b/arch/arm/include/asm/hardware/entry-macro-iomd.S
index e0af4983723..8c215acd9b5 100644
--- a/arch/arm/include/asm/hardware/entry-macro-iomd.S
+++ b/arch/arm/include/asm/hardware/entry-macro-iomd.S
@@ -11,14 +11,6 @@
11/* IOC / IOMD based hardware */ 11/* IOC / IOMD based hardware */
12#include <asm/hardware/iomd.h> 12#include <asm/hardware/iomd.h>
13 13
14 .macro disable_fiq
15 mov r12, #ioc_base_high
16 .if ioc_base_low
17 orr r12, r12, #ioc_base_low
18 .endif
19 strb r12, [r12, #0x38] @ Disable FIQ register
20 .endm
21
22 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp 14 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
23 ldrb \irqstat, [\base, #IOMD_IRQREQB] @ get high priority first 15 ldrb \irqstat, [\base, #IOMD_IRQREQB] @ get high priority first
24 ldr \tmp, =irq_prio_h 16 ldr \tmp, =irq_prio_h
diff --git a/arch/arm/include/asm/hardware/sa1111.h b/arch/arm/include/asm/hardware/sa1111.h
index 92ed254c175..7c2bbc7f0be 100644
--- a/arch/arm/include/asm/hardware/sa1111.h
+++ b/arch/arm/include/asm/hardware/sa1111.h
@@ -132,34 +132,10 @@
132#define SKPCR_DCLKEN (1<<7) 132#define SKPCR_DCLKEN (1<<7)
133#define SKPCR_PWMCLKEN (1<<8) 133#define SKPCR_PWMCLKEN (1<<8)
134 134
135/* 135/* USB Host controller */
136 * USB Host controller
137 */
138#define SA1111_USB 0x0400 136#define SA1111_USB 0x0400
139 137
140/* 138/*
141 * Offsets from SA1111_USB_BASE
142 */
143#define SA1111_USB_STATUS 0x0118
144#define SA1111_USB_RESET 0x011c
145#define SA1111_USB_IRQTEST 0x0120
146
147#define USB_RESET_FORCEIFRESET (1 << 0)
148#define USB_RESET_FORCEHCRESET (1 << 1)
149#define USB_RESET_CLKGENRESET (1 << 2)
150#define USB_RESET_SIMSCALEDOWN (1 << 3)
151#define USB_RESET_USBINTTEST (1 << 4)
152#define USB_RESET_SLEEPSTBYEN (1 << 5)
153#define USB_RESET_PWRSENSELOW (1 << 6)
154#define USB_RESET_PWRCTRLLOW (1 << 7)
155
156#define USB_STATUS_IRQHCIRMTWKUP (1 << 7)
157#define USB_STATUS_IRQHCIBUFFACC (1 << 8)
158#define USB_STATUS_NIRQHCIM (1 << 9)
159#define USB_STATUS_NHCIMFCLR (1 << 10)
160#define USB_STATUS_USBPWRSENSE (1 << 11)
161
162/*
163 * Serial Audio Controller 139 * Serial Audio Controller
164 * 140 *
165 * Registers 141 * Registers
@@ -327,22 +303,6 @@
327 * PC_SSR GPIO Block C Sleep State 303 * PC_SSR GPIO Block C Sleep State
328 */ 304 */
329 305
330#define _PA_DDR _SA1111( 0x1000 )
331#define _PA_DRR _SA1111( 0x1004 )
332#define _PA_DWR _SA1111( 0x1004 )
333#define _PA_SDR _SA1111( 0x1008 )
334#define _PA_SSR _SA1111( 0x100c )
335#define _PB_DDR _SA1111( 0x1010 )
336#define _PB_DRR _SA1111( 0x1014 )
337#define _PB_DWR _SA1111( 0x1014 )
338#define _PB_SDR _SA1111( 0x1018 )
339#define _PB_SSR _SA1111( 0x101c )
340#define _PC_DDR _SA1111( 0x1020 )
341#define _PC_DRR _SA1111( 0x1024 )
342#define _PC_DWR _SA1111( 0x1024 )
343#define _PC_SDR _SA1111( 0x1028 )
344#define _PC_SSR _SA1111( 0x102c )
345
346#define SA1111_GPIO 0x1000 306#define SA1111_GPIO 0x1000
347 307
348#define SA1111_GPIO_PADDR (0x000) 308#define SA1111_GPIO_PADDR (0x000)
@@ -425,106 +385,30 @@
425#define SA1111_WAKEPOL0 0x0034 385#define SA1111_WAKEPOL0 0x0034
426#define SA1111_WAKEPOL1 0x0038 386#define SA1111_WAKEPOL1 0x0038
427 387
428/* 388/* PS/2 Trackpad and Mouse Interfaces */
429 * PS/2 Trackpad and Mouse Interfaces
430 *
431 * Registers
432 * PS2CR Control Register
433 * PS2STAT Status Register
434 * PS2DATA Transmit/Receive Data register
435 * PS2CLKDIV Clock Division Register
436 * PS2PRECNT Clock Precount Register
437 * PS2TEST1 Test register 1
438 * PS2TEST2 Test register 2
439 * PS2TEST3 Test register 3
440 * PS2TEST4 Test register 4
441 */
442
443#define SA1111_KBD 0x0a00 389#define SA1111_KBD 0x0a00
444#define SA1111_MSE 0x0c00 390#define SA1111_MSE 0x0c00
445 391
446/* 392/* PCMCIA Interface */
447 * These are offsets from the above bases. 393#define SA1111_PCMCIA 0x1600
448 */
449#define SA1111_PS2CR 0x0000
450#define SA1111_PS2STAT 0x0004
451#define SA1111_PS2DATA 0x0008
452#define SA1111_PS2CLKDIV 0x000c
453#define SA1111_PS2PRECNT 0x0010
454
455#define PS2CR_ENA 0x08
456#define PS2CR_FKD 0x02
457#define PS2CR_FKC 0x01
458
459#define PS2STAT_STP 0x0100
460#define PS2STAT_TXE 0x0080
461#define PS2STAT_TXB 0x0040
462#define PS2STAT_RXF 0x0020
463#define PS2STAT_RXB 0x0010
464#define PS2STAT_ENA 0x0008
465#define PS2STAT_RXP 0x0004
466#define PS2STAT_KBD 0x0002
467#define PS2STAT_KBC 0x0001
468 394
469/*
470 * PCMCIA Interface
471 *
472 * Registers
473 * PCSR Status Register
474 * PCCR Control Register
475 * PCSSR Sleep State Register
476 */
477
478#define SA1111_PCMCIA 0x1600
479
480/*
481 * These are offsets from the above base.
482 */
483#define SA1111_PCCR 0x0000
484#define SA1111_PCSSR 0x0004
485#define SA1111_PCSR 0x0008
486
487#define PCSR_S0_READY (1<<0)
488#define PCSR_S1_READY (1<<1)
489#define PCSR_S0_DETECT (1<<2)
490#define PCSR_S1_DETECT (1<<3)
491#define PCSR_S0_VS1 (1<<4)
492#define PCSR_S0_VS2 (1<<5)
493#define PCSR_S1_VS1 (1<<6)
494#define PCSR_S1_VS2 (1<<7)
495#define PCSR_S0_WP (1<<8)
496#define PCSR_S1_WP (1<<9)
497#define PCSR_S0_BVD1 (1<<10)
498#define PCSR_S0_BVD2 (1<<11)
499#define PCSR_S1_BVD1 (1<<12)
500#define PCSR_S1_BVD2 (1<<13)
501
502#define PCCR_S0_RST (1<<0)
503#define PCCR_S1_RST (1<<1)
504#define PCCR_S0_FLT (1<<2)
505#define PCCR_S1_FLT (1<<3)
506#define PCCR_S0_PWAITEN (1<<4)
507#define PCCR_S1_PWAITEN (1<<5)
508#define PCCR_S0_PSE (1<<6)
509#define PCCR_S1_PSE (1<<7)
510
511#define PCSSR_S0_SLEEP (1<<0)
512#define PCSSR_S1_SLEEP (1<<1)
513 395
514 396
515 397
516 398
517extern struct bus_type sa1111_bus_type; 399extern struct bus_type sa1111_bus_type;
518 400
519#define SA1111_DEVID_SBI 0 401#define SA1111_DEVID_SBI (1 << 0)
520#define SA1111_DEVID_SK 1 402#define SA1111_DEVID_SK (1 << 1)
521#define SA1111_DEVID_USB 2 403#define SA1111_DEVID_USB (1 << 2)
522#define SA1111_DEVID_SAC 3 404#define SA1111_DEVID_SAC (1 << 3)
523#define SA1111_DEVID_SSP 4 405#define SA1111_DEVID_SSP (1 << 4)
524#define SA1111_DEVID_PS2 5 406#define SA1111_DEVID_PS2 (3 << 5)
525#define SA1111_DEVID_GPIO 6 407#define SA1111_DEVID_PS2_KBD (1 << 5)
526#define SA1111_DEVID_INT 7 408#define SA1111_DEVID_PS2_MSE (1 << 6)
527#define SA1111_DEVID_PCMCIA 8 409#define SA1111_DEVID_GPIO (1 << 7)
410#define SA1111_DEVID_INT (1 << 8)
411#define SA1111_DEVID_PCMCIA (1 << 9)
528 412
529struct sa1111_dev { 413struct sa1111_dev {
530 struct device dev; 414 struct device dev;
@@ -548,6 +432,7 @@ struct sa1111_driver {
548 int (*remove)(struct sa1111_dev *); 432 int (*remove)(struct sa1111_dev *);
549 int (*suspend)(struct sa1111_dev *, pm_message_t); 433 int (*suspend)(struct sa1111_dev *, pm_message_t);
550 int (*resume)(struct sa1111_dev *); 434 int (*resume)(struct sa1111_dev *);
435 void (*shutdown)(struct sa1111_dev *);
551}; 436};
552 437
553#define SA1111_DRV(_d) container_of((_d), struct sa1111_driver, drv) 438#define SA1111_DRV(_d) container_of((_d), struct sa1111_driver, drv)
@@ -555,9 +440,10 @@ struct sa1111_driver {
555#define SA1111_DRIVER_NAME(_sadev) ((_sadev)->dev.driver->name) 440#define SA1111_DRIVER_NAME(_sadev) ((_sadev)->dev.driver->name)
556 441
557/* 442/*
558 * These frob the SKPCR register. 443 * These frob the SKPCR register, and call platform specific
444 * enable/disable functions.
559 */ 445 */
560void sa1111_enable_device(struct sa1111_dev *); 446int sa1111_enable_device(struct sa1111_dev *);
561void sa1111_disable_device(struct sa1111_dev *); 447void sa1111_disable_device(struct sa1111_dev *);
562 448
563unsigned int sa1111_pll_clock(struct sa1111_dev *); 449unsigned int sa1111_pll_clock(struct sa1111_dev *);
@@ -580,6 +466,10 @@ void sa1111_set_sleep_io(struct sa1111_dev *sadev, unsigned int bits, unsigned i
580 466
581struct sa1111_platform_data { 467struct sa1111_platform_data {
582 int irq_base; /* base for cascaded on-chip IRQs */ 468 int irq_base; /* base for cascaded on-chip IRQs */
469 unsigned disable_devs;
470 void *data;
471 int (*enable)(void *, unsigned);
472 void (*disable)(void *, unsigned);
583}; 473};
584 474
585#endif /* _ASM_ARCH_SA1111 */ 475#endif /* _ASM_ARCH_SA1111 */
diff --git a/arch/arm/include/asm/hardware/timer-sp.h b/arch/arm/include/asm/hardware/timer-sp.h
index 4384d81eee7..2dd9d3f83f2 100644
--- a/arch/arm/include/asm/hardware/timer-sp.h
+++ b/arch/arm/include/asm/hardware/timer-sp.h
@@ -1,2 +1,15 @@
1void sp804_clocksource_init(void __iomem *, const char *); 1void __sp804_clocksource_and_sched_clock_init(void __iomem *,
2 const char *, int);
3
4static inline void sp804_clocksource_init(void __iomem *base, const char *name)
5{
6 __sp804_clocksource_and_sched_clock_init(base, name, 0);
7}
8
9static inline void sp804_clocksource_and_sched_clock_init(void __iomem *base,
10 const char *name)
11{
12 __sp804_clocksource_and_sched_clock_init(base, name, 1);
13}
14
2void sp804_clockevents_init(void __iomem *, unsigned int, const char *); 15void sp804_clockevents_init(void __iomem *, unsigned int, const char *);
diff --git a/arch/arm/include/asm/localtimer.h b/arch/arm/include/asm/localtimer.h
index c6a18424888..f77ffc1eb0c 100644
--- a/arch/arm/include/asm/localtimer.h
+++ b/arch/arm/include/asm/localtimer.h
@@ -11,47 +11,24 @@
11#define __ASM_ARM_LOCALTIMER_H 11#define __ASM_ARM_LOCALTIMER_H
12 12
13#include <linux/errno.h> 13#include <linux/errno.h>
14#include <linux/interrupt.h>
15 14
16struct clock_event_device; 15struct clock_event_device;
17 16
18/* 17struct local_timer_ops {
19 * Setup a per-cpu timer, whether it be a local timer or dummy broadcast 18 int (*setup)(struct clock_event_device *);
20 */ 19 void (*stop)(struct clock_event_device *);
21void percpu_timer_setup(void); 20};
22 21
23#ifdef CONFIG_LOCAL_TIMERS 22#ifdef CONFIG_LOCAL_TIMERS
24
25#ifdef CONFIG_HAVE_ARM_TWD
26
27#include "smp_twd.h"
28
29#define local_timer_stop(c) twd_timer_stop((c))
30
31#else
32
33/*
34 * Stop the local timer
35 */
36void local_timer_stop(struct clock_event_device *);
37
38#endif
39
40/* 23/*
41 * Setup a local timer interrupt for a CPU. 24 * Register a local timer driver
42 */ 25 */
43int local_timer_setup(struct clock_event_device *); 26int local_timer_register(struct local_timer_ops *);
44
45#else 27#else
46 28static inline int local_timer_register(struct local_timer_ops *ops)
47static inline int local_timer_setup(struct clock_event_device *evt)
48{ 29{
49 return -ENXIO; 30 return -ENXIO;
50} 31}
51
52static inline void local_timer_stop(struct clock_event_device *evt)
53{
54}
55#endif 32#endif
56 33
57#endif 34#endif
diff --git a/arch/arm/include/asm/pci.h b/arch/arm/include/asm/pci.h
index da337ba57ff..a98a2e112fa 100644
--- a/arch/arm/include/asm/pci.h
+++ b/arch/arm/include/asm/pci.h
@@ -57,14 +57,6 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
57extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, 57extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
58 enum pci_mmap_state mmap_state, int write_combine); 58 enum pci_mmap_state mmap_state, int write_combine);
59 59
60extern void
61pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
62 struct resource *res);
63
64extern void
65pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
66 struct pci_bus_region *region);
67
68/* 60/*
69 * Dummy implementation; always return 0. 61 * Dummy implementation; always return 0.
70 */ 62 */
diff --git a/arch/arm/include/asm/pgtable-nommu.h b/arch/arm/include/asm/pgtable-nommu.h
index ffc0e85775b..7ec60d6075b 100644
--- a/arch/arm/include/asm/pgtable-nommu.h
+++ b/arch/arm/include/asm/pgtable-nommu.h
@@ -79,7 +79,6 @@ extern unsigned int kobjsize(const void *objp);
79 * No page table caches to initialise. 79 * No page table caches to initialise.
80 */ 80 */
81#define pgtable_cache_init() do { } while (0) 81#define pgtable_cache_init() do { } while (0)
82#define io_remap_page_range remap_page_range
83#define io_remap_pfn_range remap_pfn_range 82#define io_remap_pfn_range remap_pfn_range
84 83
85 84
diff --git a/arch/arm/include/asm/smp_twd.h b/arch/arm/include/asm/smp_twd.h
index ef9ffba97ad..0f01f4677bd 100644
--- a/arch/arm/include/asm/smp_twd.h
+++ b/arch/arm/include/asm/smp_twd.h
@@ -18,11 +18,28 @@
18#define TWD_TIMER_CONTROL_PERIODIC (1 << 1) 18#define TWD_TIMER_CONTROL_PERIODIC (1 << 1)
19#define TWD_TIMER_CONTROL_IT_ENABLE (1 << 2) 19#define TWD_TIMER_CONTROL_IT_ENABLE (1 << 2)
20 20
21struct clock_event_device; 21#include <linux/ioport.h>
22 22
23extern void __iomem *twd_base; 23struct twd_local_timer {
24 struct resource res[2];
25};
24 26
25void twd_timer_setup(struct clock_event_device *); 27#define DEFINE_TWD_LOCAL_TIMER(name,base,irq) \
26void twd_timer_stop(struct clock_event_device *); 28struct twd_local_timer name __initdata = { \
29 .res = { \
30 DEFINE_RES_MEM(base, 0x10), \
31 DEFINE_RES_IRQ(irq), \
32 }, \
33};
34
35int twd_local_timer_register(struct twd_local_timer *);
36
37#ifdef CONFIG_HAVE_ARM_TWD
38void twd_local_timer_of_register(void);
39#else
40static inline void twd_local_timer_of_register(void)
41{
42}
43#endif
27 44
28#endif 45#endif
diff --git a/arch/arm/include/asm/system_misc.h b/arch/arm/include/asm/system_misc.h
index 9e65b23be14..5a85f148b60 100644
--- a/arch/arm/include/asm/system_misc.h
+++ b/arch/arm/include/asm/system_misc.h
@@ -11,6 +11,7 @@ extern void cpu_init(void);
11 11
12void soft_restart(unsigned long); 12void soft_restart(unsigned long);
13extern void (*arm_pm_restart)(char str, const char *cmd); 13extern void (*arm_pm_restart)(char str, const char *cmd);
14extern void (*arm_pm_idle)(void);
14 15
15#define UDBG_UNDEFINED (1 << 0) 16#define UDBG_UNDEFINED (1 << 0)
16#define UDBG_SYSCALL (1 << 1) 17#define UDBG_SYSCALL (1 << 1)
diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
index 43b740d0e37..3a274878412 100644
--- a/arch/arm/kernel/Makefile
+++ b/arch/arm/kernel/Makefile
@@ -23,7 +23,6 @@ obj-$(CONFIG_LEDS) += leds.o
23obj-$(CONFIG_OC_ETM) += etm.o 23obj-$(CONFIG_OC_ETM) += etm.o
24 24
25obj-$(CONFIG_ISA_DMA_API) += dma.o 25obj-$(CONFIG_ISA_DMA_API) += dma.o
26obj-$(CONFIG_ARCH_ACORN) += ecard.o
27obj-$(CONFIG_FIQ) += fiq.o fiqasm.o 26obj-$(CONFIG_FIQ) += fiq.o fiqasm.o
28obj-$(CONFIG_MODULES) += armksyms.o module.o 27obj-$(CONFIG_MODULES) += armksyms.o module.o
29obj-$(CONFIG_ARTHUR) += arthur.o 28obj-$(CONFIG_ARTHUR) += arthur.o
@@ -62,9 +61,6 @@ obj-$(CONFIG_SWP_EMULATE) += swp_emulate.o
62CFLAGS_swp_emulate.o := -Wa,-march=armv7-a 61CFLAGS_swp_emulate.o := -Wa,-march=armv7-a
63obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o 62obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o
64 63
65obj-$(CONFIG_CRUNCH) += crunch.o crunch-bits.o
66AFLAGS_crunch-bits.o := -Wa,-mcpu=ep9312
67
68obj-$(CONFIG_CPU_XSCALE) += xscale-cp0.o 64obj-$(CONFIG_CPU_XSCALE) += xscale-cp0.o
69obj-$(CONFIG_CPU_XSC3) += xscale-cp0.o 65obj-$(CONFIG_CPU_XSC3) += xscale-cp0.o
70obj-$(CONFIG_CPU_MOHAWK) += xscale-cp0.o 66obj-$(CONFIG_CPU_MOHAWK) += xscale-cp0.o
diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
index f58ba358990..632df9a66f8 100644
--- a/arch/arm/kernel/bios32.c
+++ b/arch/arm/kernel/bios32.c
@@ -16,7 +16,6 @@
16#include <asm/mach/pci.h> 16#include <asm/mach/pci.h>
17 17
18static int debug_pci; 18static int debug_pci;
19static int use_firmware;
20 19
21/* 20/*
22 * We can't use pci_find_device() here since we are 21 * We can't use pci_find_device() here since we are
@@ -295,28 +294,6 @@ static inline int pdev_bad_for_parity(struct pci_dev *dev)
295} 294}
296 295
297/* 296/*
298 * Adjust the device resources from bus-centric to Linux-centric.
299 */
300static void __devinit
301pdev_fixup_device_resources(struct pci_sys_data *root, struct pci_dev *dev)
302{
303 resource_size_t offset;
304 int i;
305
306 for (i = 0; i < PCI_NUM_RESOURCES; i++) {
307 if (dev->resource[i].start == 0)
308 continue;
309 if (dev->resource[i].flags & IORESOURCE_MEM)
310 offset = root->mem_offset;
311 else
312 offset = root->io_offset;
313
314 dev->resource[i].start += offset;
315 dev->resource[i].end += offset;
316 }
317}
318
319/*
320 * pcibios_fixup_bus - Called after each bus is probed, 297 * pcibios_fixup_bus - Called after each bus is probed,
321 * but before its children are examined. 298 * but before its children are examined.
322 */ 299 */
@@ -333,8 +310,6 @@ void pcibios_fixup_bus(struct pci_bus *bus)
333 list_for_each_entry(dev, &bus->devices, bus_list) { 310 list_for_each_entry(dev, &bus->devices, bus_list) {
334 u16 status; 311 u16 status;
335 312
336 pdev_fixup_device_resources(root, dev);
337
338 pci_read_config_word(dev, PCI_STATUS, &status); 313 pci_read_config_word(dev, PCI_STATUS, &status);
339 314
340 /* 315 /*
@@ -400,43 +375,6 @@ EXPORT_SYMBOL(pcibios_fixup_bus);
400#endif 375#endif
401 376
402/* 377/*
403 * Convert from Linux-centric to bus-centric addresses for bridge devices.
404 */
405void
406pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
407 struct resource *res)
408{
409 struct pci_sys_data *root = dev->sysdata;
410 unsigned long offset = 0;
411
412 if (res->flags & IORESOURCE_IO)
413 offset = root->io_offset;
414 if (res->flags & IORESOURCE_MEM)
415 offset = root->mem_offset;
416
417 region->start = res->start - offset;
418 region->end = res->end - offset;
419}
420EXPORT_SYMBOL(pcibios_resource_to_bus);
421
422void __devinit
423pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
424 struct pci_bus_region *region)
425{
426 struct pci_sys_data *root = dev->sysdata;
427 unsigned long offset = 0;
428
429 if (res->flags & IORESOURCE_IO)
430 offset = root->io_offset;
431 if (res->flags & IORESOURCE_MEM)
432 offset = root->mem_offset;
433
434 res->start = region->start + offset;
435 res->end = region->end + offset;
436}
437EXPORT_SYMBOL(pcibios_bus_to_resource);
438
439/*
440 * Swizzle the device pin each time we cross a bridge. 378 * Swizzle the device pin each time we cross a bridge.
441 * This might update pin and returns the slot number. 379 * This might update pin and returns the slot number.
442 */ 380 */
@@ -497,10 +435,10 @@ static void __init pcibios_init_hw(struct hw_pci *hw)
497 435
498 if (ret > 0) { 436 if (ret > 0) {
499 if (list_empty(&sys->resources)) { 437 if (list_empty(&sys->resources)) {
500 pci_add_resource(&sys->resources, 438 pci_add_resource_offset(&sys->resources,
501 &ioport_resource); 439 &ioport_resource, sys->io_offset);
502 pci_add_resource(&sys->resources, 440 pci_add_resource_offset(&sys->resources,
503 &iomem_resource); 441 &iomem_resource, sys->mem_offset);
504 } 442 }
505 443
506 sys->bus = hw->scan(nr, sys); 444 sys->bus = hw->scan(nr, sys);
@@ -525,6 +463,7 @@ void __init pci_common_init(struct hw_pci *hw)
525 463
526 INIT_LIST_HEAD(&hw->buses); 464 INIT_LIST_HEAD(&hw->buses);
527 465
466 pci_add_flags(PCI_REASSIGN_ALL_RSRC);
528 if (hw->preinit) 467 if (hw->preinit)
529 hw->preinit(); 468 hw->preinit();
530 pcibios_init_hw(hw); 469 pcibios_init_hw(hw);
@@ -536,7 +475,7 @@ void __init pci_common_init(struct hw_pci *hw)
536 list_for_each_entry(sys, &hw->buses, node) { 475 list_for_each_entry(sys, &hw->buses, node) {
537 struct pci_bus *bus = sys->bus; 476 struct pci_bus *bus = sys->bus;
538 477
539 if (!use_firmware) { 478 if (!pci_has_flag(PCI_PROBE_ONLY)) {
540 /* 479 /*
541 * Size the bridge windows. 480 * Size the bridge windows.
542 */ 481 */
@@ -573,7 +512,7 @@ char * __init pcibios_setup(char *str)
573 debug_pci = 1; 512 debug_pci = 1;
574 return NULL; 513 return NULL;
575 } else if (!strcmp(str, "firmware")) { 514 } else if (!strcmp(str, "firmware")) {
576 use_firmware = 1; 515 pci_add_flags(PCI_PROBE_ONLY);
577 return NULL; 516 return NULL;
578 } 517 }
579 return str; 518 return str;
diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index 093a415902c..8ec5eed55e3 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -19,7 +19,9 @@
19#include <asm/glue-df.h> 19#include <asm/glue-df.h>
20#include <asm/glue-pf.h> 20#include <asm/glue-pf.h>
21#include <asm/vfpmacros.h> 21#include <asm/vfpmacros.h>
22#ifndef CONFIG_MULTI_IRQ_HANDLER
22#include <mach/entry-macro.S> 23#include <mach/entry-macro.S>
24#endif
23#include <asm/thread_notify.h> 25#include <asm/thread_notify.h>
24#include <asm/unwind.h> 26#include <asm/unwind.h>
25#include <asm/unistd.h> 27#include <asm/unistd.h>
@@ -1101,7 +1103,6 @@ __stubs_start:
1101 * get out of that mode without clobbering one register. 1103 * get out of that mode without clobbering one register.
1102 */ 1104 */
1103vector_fiq: 1105vector_fiq:
1104 disable_fiq
1105 subs pc, lr, #4 1106 subs pc, lr, #4
1106 1107
1107/*============================================================================= 1108/*=============================================================================
diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
index 9fd0ba90c1d..54ee265dd81 100644
--- a/arch/arm/kernel/entry-common.S
+++ b/arch/arm/kernel/entry-common.S
@@ -10,9 +10,15 @@
10 10
11#include <asm/unistd.h> 11#include <asm/unistd.h>
12#include <asm/ftrace.h> 12#include <asm/ftrace.h>
13#include <mach/entry-macro.S>
14#include <asm/unwind.h> 13#include <asm/unwind.h>
15 14
15#ifdef CONFIG_NEED_RET_TO_USER
16#include <mach/entry-macro.S>
17#else
18 .macro arch_ret_to_user, tmp1, tmp2
19 .endm
20#endif
21
16#include "entry-header.S" 22#include "entry-header.S"
17 23
18 24
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index 19917e89f13..7b9cddef6e5 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -60,8 +60,6 @@ extern void setup_mm_for_reboot(void);
60 60
61static volatile int hlt_counter; 61static volatile int hlt_counter;
62 62
63#include <mach/system.h>
64
65void disable_hlt(void) 63void disable_hlt(void)
66{ 64{
67 hlt_counter++; 65 hlt_counter++;
@@ -180,13 +178,17 @@ void cpu_idle_wait(void)
180EXPORT_SYMBOL_GPL(cpu_idle_wait); 178EXPORT_SYMBOL_GPL(cpu_idle_wait);
181 179
182/* 180/*
183 * This is our default idle handler. We need to disable 181 * This is our default idle handler.
184 * interrupts here to ensure we don't miss a wakeup call.
185 */ 182 */
183
184void (*arm_pm_idle)(void);
185
186static void default_idle(void) 186static void default_idle(void)
187{ 187{
188 if (!need_resched()) 188 if (arm_pm_idle)
189 arch_idle(); 189 arm_pm_idle();
190 else
191 cpu_do_idle();
190 local_irq_enable(); 192 local_irq_enable();
191} 193}
192 194
@@ -214,6 +216,10 @@ void cpu_idle(void)
214 cpu_die(); 216 cpu_die();
215#endif 217#endif
216 218
219 /*
220 * We need to disable interrupts here
221 * to ensure we don't miss a wakeup call.
222 */
217 local_irq_disable(); 223 local_irq_disable();
218#ifdef CONFIG_PL310_ERRATA_769419 224#ifdef CONFIG_PL310_ERRATA_769419
219 wmb(); 225 wmb();
@@ -221,19 +227,18 @@ void cpu_idle(void)
221 if (hlt_counter) { 227 if (hlt_counter) {
222 local_irq_enable(); 228 local_irq_enable();
223 cpu_relax(); 229 cpu_relax();
224 } else { 230 } else if (!need_resched()) {
225 stop_critical_timings(); 231 stop_critical_timings();
226 if (cpuidle_idle_call()) 232 if (cpuidle_idle_call())
227 pm_idle(); 233 pm_idle();
228 start_critical_timings(); 234 start_critical_timings();
229 /* 235 /*
230 * This will eventually be removed - pm_idle 236 * pm_idle functions must always
231 * functions should always return with IRQs 237 * return with IRQs enabled.
232 * enabled.
233 */ 238 */
234 WARN_ON(irqs_disabled()); 239 WARN_ON(irqs_disabled());
240 } else
235 local_irq_enable(); 241 local_irq_enable();
236 }
237 } 242 }
238 leds_event(led_idle_end); 243 leds_event(led_idle_end);
239 rcu_idle_exit(); 244 rcu_idle_exit();
@@ -532,8 +537,7 @@ int vectors_user_mapping(void)
532 struct mm_struct *mm = current->mm; 537 struct mm_struct *mm = current->mm;
533 return install_special_mapping(mm, 0xffff0000, PAGE_SIZE, 538 return install_special_mapping(mm, 0xffff0000, PAGE_SIZE,
534 VM_READ | VM_EXEC | 539 VM_READ | VM_EXEC |
535 VM_MAYREAD | VM_MAYEXEC | 540 VM_MAYREAD | VM_MAYEXEC | VM_RESERVED,
536 VM_ALWAYSDUMP | VM_RESERVED,
537 NULL); 541 NULL);
538} 542}
539 543
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index d616ed51e7a..8f8cce2c46c 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -246,6 +246,8 @@ static void __cpuinit smp_store_cpu_info(unsigned int cpuid)
246 store_cpu_topology(cpuid); 246 store_cpu_topology(cpuid);
247} 247}
248 248
249static void percpu_timer_setup(void);
250
249/* 251/*
250 * This is the secondary CPU boot entry. We're using this CPUs 252 * This is the secondary CPU boot entry. We're using this CPUs
251 * idle thread stack, but a set of temporary page tables. 253 * idle thread stack, but a set of temporary page tables.
@@ -452,7 +454,20 @@ static void __cpuinit broadcast_timer_setup(struct clock_event_device *evt)
452 clockevents_register_device(evt); 454 clockevents_register_device(evt);
453} 455}
454 456
455void __cpuinit percpu_timer_setup(void) 457static struct local_timer_ops *lt_ops;
458
459#ifdef CONFIG_LOCAL_TIMERS
460int local_timer_register(struct local_timer_ops *ops)
461{
462 if (lt_ops)
463 return -EBUSY;
464
465 lt_ops = ops;
466 return 0;
467}
468#endif
469
470static void __cpuinit percpu_timer_setup(void)
456{ 471{
457 unsigned int cpu = smp_processor_id(); 472 unsigned int cpu = smp_processor_id();
458 struct clock_event_device *evt = &per_cpu(percpu_clockevent, cpu); 473 struct clock_event_device *evt = &per_cpu(percpu_clockevent, cpu);
@@ -460,7 +475,7 @@ void __cpuinit percpu_timer_setup(void)
460 evt->cpumask = cpumask_of(cpu); 475 evt->cpumask = cpumask_of(cpu);
461 evt->broadcast = smp_timer_broadcast; 476 evt->broadcast = smp_timer_broadcast;
462 477
463 if (local_timer_setup(evt)) 478 if (!lt_ops || lt_ops->setup(evt))
464 broadcast_timer_setup(evt); 479 broadcast_timer_setup(evt);
465} 480}
466 481
@@ -475,7 +490,8 @@ static void percpu_timer_stop(void)
475 unsigned int cpu = smp_processor_id(); 490 unsigned int cpu = smp_processor_id();
476 struct clock_event_device *evt = &per_cpu(percpu_clockevent, cpu); 491 struct clock_event_device *evt = &per_cpu(percpu_clockevent, cpu);
477 492
478 local_timer_stop(evt); 493 if (lt_ops)
494 lt_ops->stop(evt);
479} 495}
480#endif 496#endif
481 497
diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c
index 7a79b24597b..fef42b21cec 100644
--- a/arch/arm/kernel/smp_twd.c
+++ b/arch/arm/kernel/smp_twd.c
@@ -18,20 +18,23 @@
18#include <linux/smp.h> 18#include <linux/smp.h>
19#include <linux/jiffies.h> 19#include <linux/jiffies.h>
20#include <linux/clockchips.h> 20#include <linux/clockchips.h>
21#include <linux/irq.h> 21#include <linux/interrupt.h>
22#include <linux/io.h> 22#include <linux/io.h>
23#include <linux/of_irq.h>
24#include <linux/of_address.h>
23 25
24#include <asm/smp_twd.h> 26#include <asm/smp_twd.h>
25#include <asm/localtimer.h> 27#include <asm/localtimer.h>
26#include <asm/hardware/gic.h> 28#include <asm/hardware/gic.h>
27 29
28/* set up by the platform code */ 30/* set up by the platform code */
29void __iomem *twd_base; 31static void __iomem *twd_base;
30 32
31static struct clk *twd_clk; 33static struct clk *twd_clk;
32static unsigned long twd_timer_rate; 34static unsigned long twd_timer_rate;
33 35
34static struct clock_event_device __percpu **twd_evt; 36static struct clock_event_device __percpu **twd_evt;
37static int twd_ppi;
35 38
36static void twd_set_mode(enum clock_event_mode mode, 39static void twd_set_mode(enum clock_event_mode mode,
37 struct clock_event_device *clk) 40 struct clock_event_device *clk)
@@ -77,7 +80,7 @@ static int twd_set_next_event(unsigned long evt,
77 * If a local timer interrupt has occurred, acknowledge and return 1. 80 * If a local timer interrupt has occurred, acknowledge and return 1.
78 * Otherwise, return 0. 81 * Otherwise, return 0.
79 */ 82 */
80int twd_timer_ack(void) 83static int twd_timer_ack(void)
81{ 84{
82 if (__raw_readl(twd_base + TWD_TIMER_INTSTAT)) { 85 if (__raw_readl(twd_base + TWD_TIMER_INTSTAT)) {
83 __raw_writel(1, twd_base + TWD_TIMER_INTSTAT); 86 __raw_writel(1, twd_base + TWD_TIMER_INTSTAT);
@@ -87,7 +90,7 @@ int twd_timer_ack(void)
87 return 0; 90 return 0;
88} 91}
89 92
90void twd_timer_stop(struct clock_event_device *clk) 93static void twd_timer_stop(struct clock_event_device *clk)
91{ 94{
92 twd_set_mode(CLOCK_EVT_MODE_UNUSED, clk); 95 twd_set_mode(CLOCK_EVT_MODE_UNUSED, clk);
93 disable_percpu_irq(clk->irq); 96 disable_percpu_irq(clk->irq);
@@ -222,28 +225,10 @@ static struct clk *twd_get_clock(void)
222/* 225/*
223 * Setup the local clock events for a CPU. 226 * Setup the local clock events for a CPU.
224 */ 227 */
225void __cpuinit twd_timer_setup(struct clock_event_device *clk) 228static int __cpuinit twd_timer_setup(struct clock_event_device *clk)
226{ 229{
227 struct clock_event_device **this_cpu_clk; 230 struct clock_event_device **this_cpu_clk;
228 231
229 if (!twd_evt) {
230 int err;
231
232 twd_evt = alloc_percpu(struct clock_event_device *);
233 if (!twd_evt) {
234 pr_err("twd: can't allocate memory\n");
235 return;
236 }
237
238 err = request_percpu_irq(clk->irq, twd_handler,
239 "twd", twd_evt);
240 if (err) {
241 pr_err("twd: can't register interrupt %d (%d)\n",
242 clk->irq, err);
243 return;
244 }
245 }
246
247 if (!twd_clk) 232 if (!twd_clk)
248 twd_clk = twd_get_clock(); 233 twd_clk = twd_get_clock();
249 234
@@ -260,6 +245,7 @@ void __cpuinit twd_timer_setup(struct clock_event_device *clk)
260 clk->rating = 350; 245 clk->rating = 350;
261 clk->set_mode = twd_set_mode; 246 clk->set_mode = twd_set_mode;
262 clk->set_next_event = twd_set_next_event; 247 clk->set_next_event = twd_set_next_event;
248 clk->irq = twd_ppi;
263 249
264 this_cpu_clk = __this_cpu_ptr(twd_evt); 250 this_cpu_clk = __this_cpu_ptr(twd_evt);
265 *this_cpu_clk = clk; 251 *this_cpu_clk = clk;
@@ -267,4 +253,95 @@ void __cpuinit twd_timer_setup(struct clock_event_device *clk)
267 clockevents_config_and_register(clk, twd_timer_rate, 253 clockevents_config_and_register(clk, twd_timer_rate,
268 0xf, 0xffffffff); 254 0xf, 0xffffffff);
269 enable_percpu_irq(clk->irq, 0); 255 enable_percpu_irq(clk->irq, 0);
256
257 return 0;
258}
259
260static struct local_timer_ops twd_lt_ops __cpuinitdata = {
261 .setup = twd_timer_setup,
262 .stop = twd_timer_stop,
263};
264
265static int __init twd_local_timer_common_register(void)
266{
267 int err;
268
269 twd_evt = alloc_percpu(struct clock_event_device *);
270 if (!twd_evt) {
271 err = -ENOMEM;
272 goto out_free;
273 }
274
275 err = request_percpu_irq(twd_ppi, twd_handler, "twd", twd_evt);
276 if (err) {
277 pr_err("twd: can't register interrupt %d (%d)\n", twd_ppi, err);
278 goto out_free;
279 }
280
281 err = local_timer_register(&twd_lt_ops);
282 if (err)
283 goto out_irq;
284
285 return 0;
286
287out_irq:
288 free_percpu_irq(twd_ppi, twd_evt);
289out_free:
290 iounmap(twd_base);
291 twd_base = NULL;
292 free_percpu(twd_evt);
293
294 return err;
270} 295}
296
297int __init twd_local_timer_register(struct twd_local_timer *tlt)
298{
299 if (twd_base || twd_evt)
300 return -EBUSY;
301
302 twd_ppi = tlt->res[1].start;
303
304 twd_base = ioremap(tlt->res[0].start, resource_size(&tlt->res[0]));
305 if (!twd_base)
306 return -ENOMEM;
307
308 return twd_local_timer_common_register();
309}
310
311#ifdef CONFIG_OF
312const static struct of_device_id twd_of_match[] __initconst = {
313 { .compatible = "arm,cortex-a9-twd-timer", },
314 { .compatible = "arm,cortex-a5-twd-timer", },
315 { .compatible = "arm,arm11mp-twd-timer", },
316 { },
317};
318
319void __init twd_local_timer_of_register(void)
320{
321 struct device_node *np;
322 int err;
323
324 np = of_find_matching_node(NULL, twd_of_match);
325 if (!np) {
326 err = -ENODEV;
327 goto out;
328 }
329
330 twd_ppi = irq_of_parse_and_map(np, 0);
331 if (!twd_ppi) {
332 err = -EINVAL;
333 goto out;
334 }
335
336 twd_base = of_iomap(np, 0);
337 if (!twd_base) {
338 err = -ENOMEM;
339 goto out;
340 }
341
342 err = twd_local_timer_common_register();
343
344out:
345 WARN(err, "twd_local_timer_of_register failed (%d)\n", err);
346}
347#endif
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 71feb00a1e9..45db05d8d94 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -20,9 +20,11 @@ config HAVE_AT91_USART5
20 20
21config AT91_SAM9_ALT_RESET 21config AT91_SAM9_ALT_RESET
22 bool 22 bool
23 default !ARCH_AT91X40
23 24
24config AT91_SAM9G45_RESET 25config AT91_SAM9G45_RESET
25 bool 26 bool
27 default !ARCH_AT91X40
26 28
27menu "Atmel AT91 System-on-Chip" 29menu "Atmel AT91 System-on-Chip"
28 30
@@ -45,7 +47,6 @@ config ARCH_AT91SAM9260
45 select HAVE_AT91_USART4 47 select HAVE_AT91_USART4
46 select HAVE_AT91_USART5 48 select HAVE_AT91_USART5
47 select HAVE_NET_MACB 49 select HAVE_NET_MACB
48 select AT91_SAM9_ALT_RESET
49 50
50config ARCH_AT91SAM9261 51config ARCH_AT91SAM9261
51 bool "AT91SAM9261" 52 bool "AT91SAM9261"
@@ -53,7 +54,6 @@ config ARCH_AT91SAM9261
53 select GENERIC_CLOCKEVENTS 54 select GENERIC_CLOCKEVENTS
54 select HAVE_FB_ATMEL 55 select HAVE_FB_ATMEL
55 select HAVE_AT91_DBGU0 56 select HAVE_AT91_DBGU0
56 select AT91_SAM9_ALT_RESET
57 57
58config ARCH_AT91SAM9G10 58config ARCH_AT91SAM9G10
59 bool "AT91SAM9G10" 59 bool "AT91SAM9G10"
@@ -61,7 +61,6 @@ config ARCH_AT91SAM9G10
61 select GENERIC_CLOCKEVENTS 61 select GENERIC_CLOCKEVENTS
62 select HAVE_AT91_DBGU0 62 select HAVE_AT91_DBGU0
63 select HAVE_FB_ATMEL 63 select HAVE_FB_ATMEL
64 select AT91_SAM9_ALT_RESET
65 64
66config ARCH_AT91SAM9263 65config ARCH_AT91SAM9263
67 bool "AT91SAM9263" 66 bool "AT91SAM9263"
@@ -70,7 +69,6 @@ config ARCH_AT91SAM9263
70 select HAVE_FB_ATMEL 69 select HAVE_FB_ATMEL
71 select HAVE_NET_MACB 70 select HAVE_NET_MACB
72 select HAVE_AT91_DBGU1 71 select HAVE_AT91_DBGU1
73 select AT91_SAM9_ALT_RESET
74 72
75config ARCH_AT91SAM9RL 73config ARCH_AT91SAM9RL
76 bool "AT91SAM9RL" 74 bool "AT91SAM9RL"
@@ -79,7 +77,6 @@ config ARCH_AT91SAM9RL
79 select HAVE_AT91_USART3 77 select HAVE_AT91_USART3
80 select HAVE_FB_ATMEL 78 select HAVE_FB_ATMEL
81 select HAVE_AT91_DBGU0 79 select HAVE_AT91_DBGU0
82 select AT91_SAM9_ALT_RESET
83 80
84config ARCH_AT91SAM9G20 81config ARCH_AT91SAM9G20
85 bool "AT91SAM9G20" 82 bool "AT91SAM9G20"
@@ -90,7 +87,6 @@ config ARCH_AT91SAM9G20
90 select HAVE_AT91_USART4 87 select HAVE_AT91_USART4
91 select HAVE_AT91_USART5 88 select HAVE_AT91_USART5
92 select HAVE_NET_MACB 89 select HAVE_NET_MACB
93 select AT91_SAM9_ALT_RESET
94 90
95config ARCH_AT91SAM9G45 91config ARCH_AT91SAM9G45
96 bool "AT91SAM9G45" 92 bool "AT91SAM9G45"
@@ -100,16 +96,14 @@ config ARCH_AT91SAM9G45
100 select HAVE_FB_ATMEL 96 select HAVE_FB_ATMEL
101 select HAVE_NET_MACB 97 select HAVE_NET_MACB
102 select HAVE_AT91_DBGU1 98 select HAVE_AT91_DBGU1
103 select AT91_SAM9G45_RESET
104 99
105config ARCH_AT91CAP9 100config ARCH_AT91SAM9X5
106 bool "AT91CAP9" 101 bool "AT91SAM9x5 family"
107 select CPU_ARM926T 102 select CPU_ARM926T
108 select GENERIC_CLOCKEVENTS 103 select GENERIC_CLOCKEVENTS
109 select HAVE_FB_ATMEL 104 select HAVE_FB_ATMEL
110 select HAVE_NET_MACB 105 select HAVE_NET_MACB
111 select HAVE_AT91_DBGU1 106 select HAVE_AT91_DBGU0
112 select AT91_SAM9G45_RESET
113 107
114config ARCH_AT91X40 108config ARCH_AT91X40
115 bool "AT91x40" 109 bool "AT91x40"
@@ -447,21 +441,6 @@ endif
447 441
448# ---------------------------------------------------------- 442# ----------------------------------------------------------
449 443
450if ARCH_AT91CAP9
451
452comment "AT91CAP9 Board Type"
453
454config MACH_AT91CAP9ADK
455 bool "Atmel AT91CAP9A-DK Evaluation Kit"
456 select HAVE_AT91_DATAFLASH_CARD
457 help
458 Select this if you are using Atmel's AT91CAP9A-DK Evaluation Kit.
459 <http://www.atmel.com/dyn/products/tools_card.asp?tool_id=4138>
460
461endif
462
463# ----------------------------------------------------------
464
465if ARCH_AT91X40 444if ARCH_AT91X40
466 445
467comment "AT91X40 Board Type" 446comment "AT91X40 Board Type"
@@ -544,7 +523,7 @@ config AT91_EARLY_DBGU0
544 depends on HAVE_AT91_DBGU0 523 depends on HAVE_AT91_DBGU0
545 524
546config AT91_EARLY_DBGU1 525config AT91_EARLY_DBGU1
547 bool "DBGU on 9263, 9g45 and cap9" 526 bool "DBGU on 9263 and 9g45"
548 depends on HAVE_AT91_DBGU1 527 depends on HAVE_AT91_DBGU1
549 528
550config AT91_EARLY_USART0 529config AT91_EARLY_USART0
diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index 705e1fbded3..8512e53bed9 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -20,7 +20,7 @@ obj-$(CONFIG_ARCH_AT91SAM9263) += at91sam9263.o at91sam926x_time.o at91sam9263_d
20obj-$(CONFIG_ARCH_AT91SAM9RL) += at91sam9rl.o at91sam926x_time.o at91sam9rl_devices.o sam9_smc.o 20obj-$(CONFIG_ARCH_AT91SAM9RL) += at91sam9rl.o at91sam926x_time.o at91sam9rl_devices.o sam9_smc.o
21obj-$(CONFIG_ARCH_AT91SAM9G20) += at91sam9260.o at91sam926x_time.o at91sam9260_devices.o sam9_smc.o 21obj-$(CONFIG_ARCH_AT91SAM9G20) += at91sam9260.o at91sam926x_time.o at91sam9260_devices.o sam9_smc.o
22obj-$(CONFIG_ARCH_AT91SAM9G45) += at91sam9g45.o at91sam926x_time.o at91sam9g45_devices.o sam9_smc.o 22obj-$(CONFIG_ARCH_AT91SAM9G45) += at91sam9g45.o at91sam926x_time.o at91sam9g45_devices.o sam9_smc.o
23obj-$(CONFIG_ARCH_AT91CAP9) += at91cap9.o at91sam926x_time.o at91cap9_devices.o sam9_smc.o 23obj-$(CONFIG_ARCH_AT91SAM9X5) += at91sam9x5.o at91sam926x_time.o sam9_smc.o
24obj-$(CONFIG_ARCH_AT91X40) += at91x40.o at91x40_time.o 24obj-$(CONFIG_ARCH_AT91X40) += at91x40.o at91x40_time.o
25 25
26# AT91RM9200 board-specific support 26# AT91RM9200 board-specific support
@@ -81,9 +81,6 @@ obj-$(CONFIG_MACH_AT91SAM9M10G45EK) += board-sam9m10g45ek.o
81# AT91SAM board with device-tree 81# AT91SAM board with device-tree
82obj-$(CONFIG_MACH_AT91SAM_DT) += board-dt.o 82obj-$(CONFIG_MACH_AT91SAM_DT) += board-dt.o
83 83
84# AT91CAP9 board-specific support
85obj-$(CONFIG_MACH_AT91CAP9ADK) += board-cap9adk.o
86
87# AT91X40 board-specific support 84# AT91X40 board-specific support
88obj-$(CONFIG_MACH_AT91EB01) += board-eb01.o 85obj-$(CONFIG_MACH_AT91EB01) += board-eb01.o
89 86
diff --git a/arch/arm/mach-at91/Makefile.boot b/arch/arm/mach-at91/Makefile.boot
index 8ddafadfdc7..0da66ca4a4f 100644
--- a/arch/arm/mach-at91/Makefile.boot
+++ b/arch/arm/mach-at91/Makefile.boot
@@ -3,11 +3,7 @@
3# PARAMS_PHYS must be within 4MB of ZRELADDR 3# PARAMS_PHYS must be within 4MB of ZRELADDR
4# INITRD_PHYS must be in RAM 4# INITRD_PHYS must be in RAM
5 5
6ifeq ($(CONFIG_ARCH_AT91CAP9),y) 6ifeq ($(CONFIG_ARCH_AT91SAM9G45),y)
7 zreladdr-y += 0x70008000
8params_phys-y := 0x70000100
9initrd_phys-y := 0x70410000
10else ifeq ($(CONFIG_ARCH_AT91SAM9G45),y)
11 zreladdr-y += 0x70008000 7 zreladdr-y += 0x70008000
12params_phys-y := 0x70000100 8params_phys-y := 0x70000100
13initrd_phys-y := 0x70410000 9initrd_phys-y := 0x70410000
@@ -17,4 +13,10 @@ params_phys-y := 0x20000100
17initrd_phys-y := 0x20410000 13initrd_phys-y := 0x20410000
18endif 14endif
19 15
20dtb-$(CONFIG_MACH_AT91SAM_DT) += at91sam9m10g45ek.dtb usb_a9g20.dtb 16# Keep dtb files sorted alphabetically for each SoC
17# sam9g20
18dtb-$(CONFIG_MACH_AT91SAM_DT) += usb_a9g20.dtb
19# sam9g45
20dtb-$(CONFIG_MACH_AT91SAM_DT) += at91sam9m10g45ek.dtb
21# sam9x5
22dtb-$(CONFIG_MACH_AT91SAM_DT) += at91sam9g25ek.dtb
diff --git a/arch/arm/mach-at91/at91cap9.c b/arch/arm/mach-at91/at91cap9.c
deleted file mode 100644
index fc460e96f1a..00000000000
--- a/arch/arm/mach-at91/at91cap9.c
+++ /dev/null
@@ -1,398 +0,0 @@
1/*
2 * arch/arm/mach-at91/at91cap9.c
3 *
4 * Copyright (C) 2007 Stelian Pop <stelian.pop@leadtechdesign.com>
5 * Copyright (C) 2007 Lead Tech Design <www.leadtechdesign.com>
6 * Copyright (C) 2007 Atmel Corporation.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 */
14
15#include <linux/module.h>
16
17#include <asm/irq.h>
18#include <asm/mach/arch.h>
19#include <asm/mach/map.h>
20#include <asm/system_info.h>
21#include <asm/system_misc.h>
22
23#include <mach/cpu.h>
24#include <mach/at91cap9.h>
25#include <mach/at91_pmc.h>
26
27#include "soc.h"
28#include "generic.h"
29#include "clock.h"
30#include "sam9_smc.h"
31
32/* --------------------------------------------------------------------
33 * Clocks
34 * -------------------------------------------------------------------- */
35
36/*
37 * The peripheral clocks.
38 */
39static struct clk pioABCD_clk = {
40 .name = "pioABCD_clk",
41 .pmc_mask = 1 << AT91CAP9_ID_PIOABCD,
42 .type = CLK_TYPE_PERIPHERAL,
43};
44static struct clk mpb0_clk = {
45 .name = "mpb0_clk",
46 .pmc_mask = 1 << AT91CAP9_ID_MPB0,
47 .type = CLK_TYPE_PERIPHERAL,
48};
49static struct clk mpb1_clk = {
50 .name = "mpb1_clk",
51 .pmc_mask = 1 << AT91CAP9_ID_MPB1,
52 .type = CLK_TYPE_PERIPHERAL,
53};
54static struct clk mpb2_clk = {
55 .name = "mpb2_clk",
56 .pmc_mask = 1 << AT91CAP9_ID_MPB2,
57 .type = CLK_TYPE_PERIPHERAL,
58};
59static struct clk mpb3_clk = {
60 .name = "mpb3_clk",
61 .pmc_mask = 1 << AT91CAP9_ID_MPB3,
62 .type = CLK_TYPE_PERIPHERAL,
63};
64static struct clk mpb4_clk = {
65 .name = "mpb4_clk",
66 .pmc_mask = 1 << AT91CAP9_ID_MPB4,
67 .type = CLK_TYPE_PERIPHERAL,
68};
69static struct clk usart0_clk = {
70 .name = "usart0_clk",
71 .pmc_mask = 1 << AT91CAP9_ID_US0,
72 .type = CLK_TYPE_PERIPHERAL,
73};
74static struct clk usart1_clk = {
75 .name = "usart1_clk",
76 .pmc_mask = 1 << AT91CAP9_ID_US1,
77 .type = CLK_TYPE_PERIPHERAL,
78};
79static struct clk usart2_clk = {
80 .name = "usart2_clk",
81 .pmc_mask = 1 << AT91CAP9_ID_US2,
82 .type = CLK_TYPE_PERIPHERAL,
83};
84static struct clk mmc0_clk = {
85 .name = "mci0_clk",
86 .pmc_mask = 1 << AT91CAP9_ID_MCI0,
87 .type = CLK_TYPE_PERIPHERAL,
88};
89static struct clk mmc1_clk = {
90 .name = "mci1_clk",
91 .pmc_mask = 1 << AT91CAP9_ID_MCI1,
92 .type = CLK_TYPE_PERIPHERAL,
93};
94static struct clk can_clk = {
95 .name = "can_clk",
96 .pmc_mask = 1 << AT91CAP9_ID_CAN,
97 .type = CLK_TYPE_PERIPHERAL,
98};
99static struct clk twi_clk = {
100 .name = "twi_clk",
101 .pmc_mask = 1 << AT91CAP9_ID_TWI,
102 .type = CLK_TYPE_PERIPHERAL,
103};
104static struct clk spi0_clk = {
105 .name = "spi0_clk",
106 .pmc_mask = 1 << AT91CAP9_ID_SPI0,
107 .type = CLK_TYPE_PERIPHERAL,
108};
109static struct clk spi1_clk = {
110 .name = "spi1_clk",
111 .pmc_mask = 1 << AT91CAP9_ID_SPI1,
112 .type = CLK_TYPE_PERIPHERAL,
113};
114static struct clk ssc0_clk = {
115 .name = "ssc0_clk",
116 .pmc_mask = 1 << AT91CAP9_ID_SSC0,
117 .type = CLK_TYPE_PERIPHERAL,
118};
119static struct clk ssc1_clk = {
120 .name = "ssc1_clk",
121 .pmc_mask = 1 << AT91CAP9_ID_SSC1,
122 .type = CLK_TYPE_PERIPHERAL,
123};
124static struct clk ac97_clk = {
125 .name = "ac97_clk",
126 .pmc_mask = 1 << AT91CAP9_ID_AC97C,
127 .type = CLK_TYPE_PERIPHERAL,
128};
129static struct clk tcb_clk = {
130 .name = "tcb_clk",
131 .pmc_mask = 1 << AT91CAP9_ID_TCB,
132 .type = CLK_TYPE_PERIPHERAL,
133};
134static struct clk pwm_clk = {
135 .name = "pwm_clk",
136 .pmc_mask = 1 << AT91CAP9_ID_PWMC,
137 .type = CLK_TYPE_PERIPHERAL,
138};
139static struct clk macb_clk = {
140 .name = "pclk",
141 .pmc_mask = 1 << AT91CAP9_ID_EMAC,
142 .type = CLK_TYPE_PERIPHERAL,
143};
144static struct clk aestdes_clk = {
145 .name = "aestdes_clk",
146 .pmc_mask = 1 << AT91CAP9_ID_AESTDES,
147 .type = CLK_TYPE_PERIPHERAL,
148};
149static struct clk adc_clk = {
150 .name = "adc_clk",
151 .pmc_mask = 1 << AT91CAP9_ID_ADC,
152 .type = CLK_TYPE_PERIPHERAL,
153};
154static struct clk isi_clk = {
155 .name = "isi_clk",
156 .pmc_mask = 1 << AT91CAP9_ID_ISI,
157 .type = CLK_TYPE_PERIPHERAL,
158};
159static struct clk lcdc_clk = {
160 .name = "lcdc_clk",
161 .pmc_mask = 1 << AT91CAP9_ID_LCDC,
162 .type = CLK_TYPE_PERIPHERAL,
163};
164static struct clk dma_clk = {
165 .name = "dma_clk",
166 .pmc_mask = 1 << AT91CAP9_ID_DMA,
167 .type = CLK_TYPE_PERIPHERAL,
168};
169static struct clk udphs_clk = {
170 .name = "udphs_clk",
171 .pmc_mask = 1 << AT91CAP9_ID_UDPHS,
172 .type = CLK_TYPE_PERIPHERAL,
173};
174static struct clk ohci_clk = {
175 .name = "ohci_clk",
176 .pmc_mask = 1 << AT91CAP9_ID_UHP,
177 .type = CLK_TYPE_PERIPHERAL,
178};
179
180static struct clk *periph_clocks[] __initdata = {
181 &pioABCD_clk,
182 &mpb0_clk,
183 &mpb1_clk,
184 &mpb2_clk,
185 &mpb3_clk,
186 &mpb4_clk,
187 &usart0_clk,
188 &usart1_clk,
189 &usart2_clk,
190 &mmc0_clk,
191 &mmc1_clk,
192 &can_clk,
193 &twi_clk,
194 &spi0_clk,
195 &spi1_clk,
196 &ssc0_clk,
197 &ssc1_clk,
198 &ac97_clk,
199 &tcb_clk,
200 &pwm_clk,
201 &macb_clk,
202 &aestdes_clk,
203 &adc_clk,
204 &isi_clk,
205 &lcdc_clk,
206 &dma_clk,
207 &udphs_clk,
208 &ohci_clk,
209 // irq0 .. irq1
210};
211
212static struct clk_lookup periph_clocks_lookups[] = {
213 /* One additional fake clock for macb_hclk */
214 CLKDEV_CON_ID("hclk", &macb_clk),
215 CLKDEV_CON_DEV_ID("hclk", "atmel_usba_udc", &utmi_clk),
216 CLKDEV_CON_DEV_ID("pclk", "atmel_usba_udc", &udphs_clk),
217 CLKDEV_CON_DEV_ID("mci_clk", "at91_mci.0", &mmc0_clk),
218 CLKDEV_CON_DEV_ID("mci_clk", "at91_mci.1", &mmc1_clk),
219 CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.0", &spi0_clk),
220 CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.1", &spi1_clk),
221 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tcb_clk),
222 CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk),
223 CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk),
224 /* fake hclk clock */
225 CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &ohci_clk),
226 CLKDEV_CON_ID("pioA", &pioABCD_clk),
227 CLKDEV_CON_ID("pioB", &pioABCD_clk),
228 CLKDEV_CON_ID("pioC", &pioABCD_clk),
229 CLKDEV_CON_ID("pioD", &pioABCD_clk),
230};
231
232static struct clk_lookup usart_clocks_lookups[] = {
233 CLKDEV_CON_DEV_ID("usart", "atmel_usart.0", &mck),
234 CLKDEV_CON_DEV_ID("usart", "atmel_usart.1", &usart0_clk),
235 CLKDEV_CON_DEV_ID("usart", "atmel_usart.2", &usart1_clk),
236 CLKDEV_CON_DEV_ID("usart", "atmel_usart.3", &usart2_clk),
237};
238
239/*
240 * The four programmable clocks.
241 * You must configure pin multiplexing to bring these signals out.
242 */
243static struct clk pck0 = {
244 .name = "pck0",
245 .pmc_mask = AT91_PMC_PCK0,
246 .type = CLK_TYPE_PROGRAMMABLE,
247 .id = 0,
248};
249static struct clk pck1 = {
250 .name = "pck1",
251 .pmc_mask = AT91_PMC_PCK1,
252 .type = CLK_TYPE_PROGRAMMABLE,
253 .id = 1,
254};
255static struct clk pck2 = {
256 .name = "pck2",
257 .pmc_mask = AT91_PMC_PCK2,
258 .type = CLK_TYPE_PROGRAMMABLE,
259 .id = 2,
260};
261static struct clk pck3 = {
262 .name = "pck3",
263 .pmc_mask = AT91_PMC_PCK3,
264 .type = CLK_TYPE_PROGRAMMABLE,
265 .id = 3,
266};
267
268static void __init at91cap9_register_clocks(void)
269{
270 int i;
271
272 for (i = 0; i < ARRAY_SIZE(periph_clocks); i++)
273 clk_register(periph_clocks[i]);
274
275 clkdev_add_table(periph_clocks_lookups,
276 ARRAY_SIZE(periph_clocks_lookups));
277 clkdev_add_table(usart_clocks_lookups,
278 ARRAY_SIZE(usart_clocks_lookups));
279
280 clk_register(&pck0);
281 clk_register(&pck1);
282 clk_register(&pck2);
283 clk_register(&pck3);
284}
285
286static struct clk_lookup console_clock_lookup;
287
288void __init at91cap9_set_console_clock(int id)
289{
290 if (id >= ARRAY_SIZE(usart_clocks_lookups))
291 return;
292
293 console_clock_lookup.con_id = "usart";
294 console_clock_lookup.clk = usart_clocks_lookups[id].clk;
295 clkdev_add(&console_clock_lookup);
296}
297
298/* --------------------------------------------------------------------
299 * GPIO
300 * -------------------------------------------------------------------- */
301
302static struct at91_gpio_bank at91cap9_gpio[] __initdata = {
303 {
304 .id = AT91CAP9_ID_PIOABCD,
305 .regbase = AT91CAP9_BASE_PIOA,
306 }, {
307 .id = AT91CAP9_ID_PIOABCD,
308 .regbase = AT91CAP9_BASE_PIOB,
309 }, {
310 .id = AT91CAP9_ID_PIOABCD,
311 .regbase = AT91CAP9_BASE_PIOC,
312 }, {
313 .id = AT91CAP9_ID_PIOABCD,
314 .regbase = AT91CAP9_BASE_PIOD,
315 }
316};
317
318/* --------------------------------------------------------------------
319 * AT91CAP9 processor initialization
320 * -------------------------------------------------------------------- */
321
322static void __init at91cap9_map_io(void)
323{
324 at91_init_sram(0, AT91CAP9_SRAM_BASE, AT91CAP9_SRAM_SIZE);
325}
326
327static void __init at91cap9_ioremap_registers(void)
328{
329 at91_ioremap_shdwc(AT91CAP9_BASE_SHDWC);
330 at91_ioremap_rstc(AT91CAP9_BASE_RSTC);
331 at91sam926x_ioremap_pit(AT91CAP9_BASE_PIT);
332 at91sam9_ioremap_smc(0, AT91CAP9_BASE_SMC);
333}
334
335static void __init at91cap9_initialize(void)
336{
337 arm_pm_restart = at91sam9g45_restart;
338 at91_extern_irq = (1 << AT91CAP9_ID_IRQ0) | (1 << AT91CAP9_ID_IRQ1);
339
340 /* Register GPIO subsystem */
341 at91_gpio_init(at91cap9_gpio, 4);
342
343 /* Remember the silicon revision */
344 if (cpu_is_at91cap9_revB())
345 system_rev = 0xB;
346 else if (cpu_is_at91cap9_revC())
347 system_rev = 0xC;
348}
349
350/* --------------------------------------------------------------------
351 * Interrupt initialization
352 * -------------------------------------------------------------------- */
353
354/*
355 * The default interrupt priority levels (0 = lowest, 7 = highest).
356 */
357static unsigned int at91cap9_default_irq_priority[NR_AIC_IRQS] __initdata = {
358 7, /* Advanced Interrupt Controller (FIQ) */
359 7, /* System Peripherals */
360 1, /* Parallel IO Controller A, B, C and D */
361 0, /* MP Block Peripheral 0 */
362 0, /* MP Block Peripheral 1 */
363 0, /* MP Block Peripheral 2 */
364 0, /* MP Block Peripheral 3 */
365 0, /* MP Block Peripheral 4 */
366 5, /* USART 0 */
367 5, /* USART 1 */
368 5, /* USART 2 */
369 0, /* Multimedia Card Interface 0 */
370 0, /* Multimedia Card Interface 1 */
371 3, /* CAN */
372 6, /* Two-Wire Interface */
373 5, /* Serial Peripheral Interface 0 */
374 5, /* Serial Peripheral Interface 1 */
375 4, /* Serial Synchronous Controller 0 */
376 4, /* Serial Synchronous Controller 1 */
377 5, /* AC97 Controller */
378 0, /* Timer Counter 0, 1 and 2 */
379 0, /* Pulse Width Modulation Controller */
380 3, /* Ethernet */
381 0, /* Advanced Encryption Standard, Triple DES*/
382 0, /* Analog-to-Digital Converter */
383 0, /* Image Sensor Interface */
384 3, /* LCD Controller */
385 0, /* DMA Controller */
386 2, /* USB Device Port */
387 2, /* USB Host port */
388 0, /* Advanced Interrupt Controller (IRQ0) */
389 0, /* Advanced Interrupt Controller (IRQ1) */
390};
391
392struct at91_init_soc __initdata at91cap9_soc = {
393 .map_io = at91cap9_map_io,
394 .default_irq_priority = at91cap9_default_irq_priority,
395 .ioremap_registers = at91cap9_ioremap_registers,
396 .register_clocks = at91cap9_register_clocks,
397 .init = at91cap9_initialize,
398};
diff --git a/arch/arm/mach-at91/at91cap9_devices.c b/arch/arm/mach-at91/at91cap9_devices.c
deleted file mode 100644
index d298fb7cb21..00000000000
--- a/arch/arm/mach-at91/at91cap9_devices.c
+++ /dev/null
@@ -1,1273 +0,0 @@
1/*
2 * arch/arm/mach-at91/at91cap9_devices.c
3 *
4 * Copyright (C) 2007 Stelian Pop <stelian.pop@leadtechdesign.com>
5 * Copyright (C) 2007 Lead Tech Design <www.leadtechdesign.com>
6 * Copyright (C) 2007 Atmel Corporation.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 */
14#include <asm/mach/arch.h>
15#include <asm/mach/map.h>
16#include <asm/mach/irq.h>
17
18#include <linux/dma-mapping.h>
19#include <linux/gpio.h>
20#include <linux/platform_device.h>
21#include <linux/i2c-gpio.h>
22
23#include <video/atmel_lcdc.h>
24
25#include <mach/board.h>
26#include <mach/cpu.h>
27#include <mach/at91cap9.h>
28#include <mach/at91cap9_matrix.h>
29#include <mach/at91sam9_smc.h>
30
31#include "generic.h"
32
33
34/* --------------------------------------------------------------------
35 * USB Host
36 * -------------------------------------------------------------------- */
37
38#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
39static u64 ohci_dmamask = DMA_BIT_MASK(32);
40static struct at91_usbh_data usbh_data;
41
42static struct resource usbh_resources[] = {
43 [0] = {
44 .start = AT91CAP9_UHP_BASE,
45 .end = AT91CAP9_UHP_BASE + SZ_1M - 1,
46 .flags = IORESOURCE_MEM,
47 },
48 [1] = {
49 .start = AT91CAP9_ID_UHP,
50 .end = AT91CAP9_ID_UHP,
51 .flags = IORESOURCE_IRQ,
52 },
53};
54
55static struct platform_device at91_usbh_device = {
56 .name = "at91_ohci",
57 .id = -1,
58 .dev = {
59 .dma_mask = &ohci_dmamask,
60 .coherent_dma_mask = DMA_BIT_MASK(32),
61 .platform_data = &usbh_data,
62 },
63 .resource = usbh_resources,
64 .num_resources = ARRAY_SIZE(usbh_resources),
65};
66
67void __init at91_add_device_usbh(struct at91_usbh_data *data)
68{
69 int i;
70
71 if (!data)
72 return;
73
74 if (cpu_is_at91cap9_revB())
75 irq_set_irq_type(AT91CAP9_ID_UHP, IRQ_TYPE_LEVEL_HIGH);
76
77 /* Enable VBus control for UHP ports */
78 for (i = 0; i < data->ports; i++) {
79 if (gpio_is_valid(data->vbus_pin[i]))
80 at91_set_gpio_output(data->vbus_pin[i], 0);
81 }
82
83 /* Enable overcurrent notification */
84 for (i = 0; i < data->ports; i++) {
85 if (data->overcurrent_pin[i])
86 at91_set_gpio_input(data->overcurrent_pin[i], 1);
87 }
88
89 usbh_data = *data;
90 platform_device_register(&at91_usbh_device);
91}
92#else
93void __init at91_add_device_usbh(struct at91_usbh_data *data) {}
94#endif
95
96
97/* --------------------------------------------------------------------
98 * USB HS Device (Gadget)
99 * -------------------------------------------------------------------- */
100
101#if defined(CONFIG_USB_ATMEL_USBA) || defined(CONFIG_USB_ATMEL_USBA_MODULE)
102
103static struct resource usba_udc_resources[] = {
104 [0] = {
105 .start = AT91CAP9_UDPHS_FIFO,
106 .end = AT91CAP9_UDPHS_FIFO + SZ_512K - 1,
107 .flags = IORESOURCE_MEM,
108 },
109 [1] = {
110 .start = AT91CAP9_BASE_UDPHS,
111 .end = AT91CAP9_BASE_UDPHS + SZ_1K - 1,
112 .flags = IORESOURCE_MEM,
113 },
114 [2] = {
115 .start = AT91CAP9_ID_UDPHS,
116 .end = AT91CAP9_ID_UDPHS,
117 .flags = IORESOURCE_IRQ,
118 },
119};
120
121#define EP(nam, idx, maxpkt, maxbk, dma, isoc) \
122 [idx] = { \
123 .name = nam, \
124 .index = idx, \
125 .fifo_size = maxpkt, \
126 .nr_banks = maxbk, \
127 .can_dma = dma, \
128 .can_isoc = isoc, \
129 }
130
131static struct usba_ep_data usba_udc_ep[] = {
132 EP("ep0", 0, 64, 1, 0, 0),
133 EP("ep1", 1, 1024, 3, 1, 1),
134 EP("ep2", 2, 1024, 3, 1, 1),
135 EP("ep3", 3, 1024, 2, 1, 1),
136 EP("ep4", 4, 1024, 2, 1, 1),
137 EP("ep5", 5, 1024, 2, 1, 0),
138 EP("ep6", 6, 1024, 2, 1, 0),
139 EP("ep7", 7, 1024, 2, 0, 0),
140};
141
142#undef EP
143
144/*
145 * pdata doesn't have room for any endpoints, so we need to
146 * append room for the ones we need right after it.
147 */
148static struct {
149 struct usba_platform_data pdata;
150 struct usba_ep_data ep[8];
151} usba_udc_data;
152
153static struct platform_device at91_usba_udc_device = {
154 .name = "atmel_usba_udc",
155 .id = -1,
156 .dev = {
157 .platform_data = &usba_udc_data.pdata,
158 },
159 .resource = usba_udc_resources,
160 .num_resources = ARRAY_SIZE(usba_udc_resources),
161};
162
163void __init at91_add_device_usba(struct usba_platform_data *data)
164{
165 if (cpu_is_at91cap9_revB()) {
166 irq_set_irq_type(AT91CAP9_ID_UDPHS, IRQ_TYPE_LEVEL_HIGH);
167 at91_sys_write(AT91_MATRIX_UDPHS, AT91_MATRIX_SELECT_UDPHS |
168 AT91_MATRIX_UDPHS_BYPASS_LOCK);
169 }
170 else
171 at91_sys_write(AT91_MATRIX_UDPHS, AT91_MATRIX_SELECT_UDPHS);
172
173 /*
174 * Invalid pins are 0 on AT91, but the usba driver is shared
175 * with AVR32, which use negative values instead. Once/if
176 * gpio_is_valid() is ported to AT91, revisit this code.
177 */
178 usba_udc_data.pdata.vbus_pin = -EINVAL;
179 usba_udc_data.pdata.num_ep = ARRAY_SIZE(usba_udc_ep);
180 memcpy(usba_udc_data.ep, usba_udc_ep, sizeof(usba_udc_ep));
181
182 if (data && gpio_is_valid(data->vbus_pin)) {
183 at91_set_gpio_input(data->vbus_pin, 0);
184 at91_set_deglitch(data->vbus_pin, 1);
185 usba_udc_data.pdata.vbus_pin = data->vbus_pin;
186 }
187
188 /* Pullup pin is handled internally by USB device peripheral */
189
190 platform_device_register(&at91_usba_udc_device);
191}
192#else
193void __init at91_add_device_usba(struct usba_platform_data *data) {}
194#endif
195
196
197/* --------------------------------------------------------------------
198 * Ethernet
199 * -------------------------------------------------------------------- */
200
201#if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE)
202static u64 eth_dmamask = DMA_BIT_MASK(32);
203static struct macb_platform_data eth_data;
204
205static struct resource eth_resources[] = {
206 [0] = {
207 .start = AT91CAP9_BASE_EMAC,
208 .end = AT91CAP9_BASE_EMAC + SZ_16K - 1,
209 .flags = IORESOURCE_MEM,
210 },
211 [1] = {
212 .start = AT91CAP9_ID_EMAC,
213 .end = AT91CAP9_ID_EMAC,
214 .flags = IORESOURCE_IRQ,
215 },
216};
217
218static struct platform_device at91cap9_eth_device = {
219 .name = "macb",
220 .id = -1,
221 .dev = {
222 .dma_mask = &eth_dmamask,
223 .coherent_dma_mask = DMA_BIT_MASK(32),
224 .platform_data = &eth_data,
225 },
226 .resource = eth_resources,
227 .num_resources = ARRAY_SIZE(eth_resources),
228};
229
230void __init at91_add_device_eth(struct macb_platform_data *data)
231{
232 if (!data)
233 return;
234
235 if (gpio_is_valid(data->phy_irq_pin)) {
236 at91_set_gpio_input(data->phy_irq_pin, 0);
237 at91_set_deglitch(data->phy_irq_pin, 1);
238 }
239
240 /* Pins used for MII and RMII */
241 at91_set_A_periph(AT91_PIN_PB21, 0); /* ETXCK_EREFCK */
242 at91_set_A_periph(AT91_PIN_PB22, 0); /* ERXDV */
243 at91_set_A_periph(AT91_PIN_PB25, 0); /* ERX0 */
244 at91_set_A_periph(AT91_PIN_PB26, 0); /* ERX1 */
245 at91_set_A_periph(AT91_PIN_PB27, 0); /* ERXER */
246 at91_set_A_periph(AT91_PIN_PB28, 0); /* ETXEN */
247 at91_set_A_periph(AT91_PIN_PB23, 0); /* ETX0 */
248 at91_set_A_periph(AT91_PIN_PB24, 0); /* ETX1 */
249 at91_set_A_periph(AT91_PIN_PB30, 0); /* EMDIO */
250 at91_set_A_periph(AT91_PIN_PB29, 0); /* EMDC */
251
252 if (!data->is_rmii) {
253 at91_set_B_periph(AT91_PIN_PC25, 0); /* ECRS */
254 at91_set_B_periph(AT91_PIN_PC26, 0); /* ECOL */
255 at91_set_B_periph(AT91_PIN_PC22, 0); /* ERX2 */
256 at91_set_B_periph(AT91_PIN_PC23, 0); /* ERX3 */
257 at91_set_B_periph(AT91_PIN_PC27, 0); /* ERXCK */
258 at91_set_B_periph(AT91_PIN_PC20, 0); /* ETX2 */
259 at91_set_B_periph(AT91_PIN_PC21, 0); /* ETX3 */
260 at91_set_B_periph(AT91_PIN_PC24, 0); /* ETXER */
261 }
262
263 eth_data = *data;
264 platform_device_register(&at91cap9_eth_device);
265}
266#else
267void __init at91_add_device_eth(struct macb_platform_data *data) {}
268#endif
269
270
271/* --------------------------------------------------------------------
272 * MMC / SD
273 * -------------------------------------------------------------------- */
274
275#if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE)
276static u64 mmc_dmamask = DMA_BIT_MASK(32);
277static struct at91_mmc_data mmc0_data, mmc1_data;
278
279static struct resource mmc0_resources[] = {
280 [0] = {
281 .start = AT91CAP9_BASE_MCI0,
282 .end = AT91CAP9_BASE_MCI0 + SZ_16K - 1,
283 .flags = IORESOURCE_MEM,
284 },
285 [1] = {
286 .start = AT91CAP9_ID_MCI0,
287 .end = AT91CAP9_ID_MCI0,
288 .flags = IORESOURCE_IRQ,
289 },
290};
291
292static struct platform_device at91cap9_mmc0_device = {
293 .name = "at91_mci",
294 .id = 0,
295 .dev = {
296 .dma_mask = &mmc_dmamask,
297 .coherent_dma_mask = DMA_BIT_MASK(32),
298 .platform_data = &mmc0_data,
299 },
300 .resource = mmc0_resources,
301 .num_resources = ARRAY_SIZE(mmc0_resources),
302};
303
304static struct resource mmc1_resources[] = {
305 [0] = {
306 .start = AT91CAP9_BASE_MCI1,
307 .end = AT91CAP9_BASE_MCI1 + SZ_16K - 1,
308 .flags = IORESOURCE_MEM,
309 },
310 [1] = {
311 .start = AT91CAP9_ID_MCI1,
312 .end = AT91CAP9_ID_MCI1,
313 .flags = IORESOURCE_IRQ,
314 },
315};
316
317static struct platform_device at91cap9_mmc1_device = {
318 .name = "at91_mci",
319 .id = 1,
320 .dev = {
321 .dma_mask = &mmc_dmamask,
322 .coherent_dma_mask = DMA_BIT_MASK(32),
323 .platform_data = &mmc1_data,
324 },
325 .resource = mmc1_resources,
326 .num_resources = ARRAY_SIZE(mmc1_resources),
327};
328
329void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data)
330{
331 if (!data)
332 return;
333
334 /* input/irq */
335 if (gpio_is_valid(data->det_pin)) {
336 at91_set_gpio_input(data->det_pin, 1);
337 at91_set_deglitch(data->det_pin, 1);
338 }
339 if (gpio_is_valid(data->wp_pin))
340 at91_set_gpio_input(data->wp_pin, 1);
341 if (gpio_is_valid(data->vcc_pin))
342 at91_set_gpio_output(data->vcc_pin, 0);
343
344 if (mmc_id == 0) { /* MCI0 */
345 /* CLK */
346 at91_set_A_periph(AT91_PIN_PA2, 0);
347
348 /* CMD */
349 at91_set_A_periph(AT91_PIN_PA1, 1);
350
351 /* DAT0, maybe DAT1..DAT3 */
352 at91_set_A_periph(AT91_PIN_PA0, 1);
353 if (data->wire4) {
354 at91_set_A_periph(AT91_PIN_PA3, 1);
355 at91_set_A_periph(AT91_PIN_PA4, 1);
356 at91_set_A_periph(AT91_PIN_PA5, 1);
357 }
358
359 mmc0_data = *data;
360 platform_device_register(&at91cap9_mmc0_device);
361 } else { /* MCI1 */
362 /* CLK */
363 at91_set_A_periph(AT91_PIN_PA16, 0);
364
365 /* CMD */
366 at91_set_A_periph(AT91_PIN_PA17, 1);
367
368 /* DAT0, maybe DAT1..DAT3 */
369 at91_set_A_periph(AT91_PIN_PA18, 1);
370 if (data->wire4) {
371 at91_set_A_periph(AT91_PIN_PA19, 1);
372 at91_set_A_periph(AT91_PIN_PA20, 1);
373 at91_set_A_periph(AT91_PIN_PA21, 1);
374 }
375
376 mmc1_data = *data;
377 platform_device_register(&at91cap9_mmc1_device);
378 }
379}
380#else
381void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {}
382#endif
383
384
385/* --------------------------------------------------------------------
386 * NAND / SmartMedia
387 * -------------------------------------------------------------------- */
388
389#if defined(CONFIG_MTD_NAND_ATMEL) || defined(CONFIG_MTD_NAND_ATMEL_MODULE)
390static struct atmel_nand_data nand_data;
391
392#define NAND_BASE AT91_CHIPSELECT_3
393
394static struct resource nand_resources[] = {
395 [0] = {
396 .start = NAND_BASE,
397 .end = NAND_BASE + SZ_256M - 1,
398 .flags = IORESOURCE_MEM,
399 },
400 [1] = {
401 .start = AT91CAP9_BASE_ECC,
402 .end = AT91CAP9_BASE_ECC + SZ_512 - 1,
403 .flags = IORESOURCE_MEM,
404 }
405};
406
407static struct platform_device at91cap9_nand_device = {
408 .name = "atmel_nand",
409 .id = -1,
410 .dev = {
411 .platform_data = &nand_data,
412 },
413 .resource = nand_resources,
414 .num_resources = ARRAY_SIZE(nand_resources),
415};
416
417void __init at91_add_device_nand(struct atmel_nand_data *data)
418{
419 unsigned long csa;
420
421 if (!data)
422 return;
423
424 csa = at91_sys_read(AT91_MATRIX_EBICSA);
425 at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_EBI_CS3A_SMC_SMARTMEDIA);
426
427 /* enable pin */
428 if (gpio_is_valid(data->enable_pin))
429 at91_set_gpio_output(data->enable_pin, 1);
430
431 /* ready/busy pin */
432 if (gpio_is_valid(data->rdy_pin))
433 at91_set_gpio_input(data->rdy_pin, 1);
434
435 /* card detect pin */
436 if (gpio_is_valid(data->det_pin))
437 at91_set_gpio_input(data->det_pin, 1);
438
439 nand_data = *data;
440 platform_device_register(&at91cap9_nand_device);
441}
442#else
443void __init at91_add_device_nand(struct atmel_nand_data *data) {}
444#endif
445
446
447/* --------------------------------------------------------------------
448 * TWI (i2c)
449 * -------------------------------------------------------------------- */
450
451/*
452 * Prefer the GPIO code since the TWI controller isn't robust
453 * (gets overruns and underruns under load) and can only issue
454 * repeated STARTs in one scenario (the driver doesn't yet handle them).
455 */
456#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
457
458static struct i2c_gpio_platform_data pdata = {
459 .sda_pin = AT91_PIN_PB4,
460 .sda_is_open_drain = 1,
461 .scl_pin = AT91_PIN_PB5,
462 .scl_is_open_drain = 1,
463 .udelay = 2, /* ~100 kHz */
464};
465
466static struct platform_device at91cap9_twi_device = {
467 .name = "i2c-gpio",
468 .id = -1,
469 .dev.platform_data = &pdata,
470};
471
472void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
473{
474 at91_set_GPIO_periph(AT91_PIN_PB4, 1); /* TWD (SDA) */
475 at91_set_multi_drive(AT91_PIN_PB4, 1);
476
477 at91_set_GPIO_periph(AT91_PIN_PB5, 1); /* TWCK (SCL) */
478 at91_set_multi_drive(AT91_PIN_PB5, 1);
479
480 i2c_register_board_info(0, devices, nr_devices);
481 platform_device_register(&at91cap9_twi_device);
482}
483
484#elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
485
486static struct resource twi_resources[] = {
487 [0] = {
488 .start = AT91CAP9_BASE_TWI,
489 .end = AT91CAP9_BASE_TWI + SZ_16K - 1,
490 .flags = IORESOURCE_MEM,
491 },
492 [1] = {
493 .start = AT91CAP9_ID_TWI,
494 .end = AT91CAP9_ID_TWI,
495 .flags = IORESOURCE_IRQ,
496 },
497};
498
499static struct platform_device at91cap9_twi_device = {
500 .name = "at91_i2c",
501 .id = -1,
502 .resource = twi_resources,
503 .num_resources = ARRAY_SIZE(twi_resources),
504};
505
506void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
507{
508 /* pins used for TWI interface */
509 at91_set_B_periph(AT91_PIN_PB4, 0); /* TWD */
510 at91_set_multi_drive(AT91_PIN_PB4, 1);
511
512 at91_set_B_periph(AT91_PIN_PB5, 0); /* TWCK */
513 at91_set_multi_drive(AT91_PIN_PB5, 1);
514
515 i2c_register_board_info(0, devices, nr_devices);
516 platform_device_register(&at91cap9_twi_device);
517}
518#else
519void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) {}
520#endif
521
522/* --------------------------------------------------------------------
523 * SPI
524 * -------------------------------------------------------------------- */
525
526#if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
527static u64 spi_dmamask = DMA_BIT_MASK(32);
528
529static struct resource spi0_resources[] = {
530 [0] = {
531 .start = AT91CAP9_BASE_SPI0,
532 .end = AT91CAP9_BASE_SPI0 + SZ_16K - 1,
533 .flags = IORESOURCE_MEM,
534 },
535 [1] = {
536 .start = AT91CAP9_ID_SPI0,
537 .end = AT91CAP9_ID_SPI0,
538 .flags = IORESOURCE_IRQ,
539 },
540};
541
542static struct platform_device at91cap9_spi0_device = {
543 .name = "atmel_spi",
544 .id = 0,
545 .dev = {
546 .dma_mask = &spi_dmamask,
547 .coherent_dma_mask = DMA_BIT_MASK(32),
548 },
549 .resource = spi0_resources,
550 .num_resources = ARRAY_SIZE(spi0_resources),
551};
552
553static const unsigned spi0_standard_cs[4] = { AT91_PIN_PA5, AT91_PIN_PA3, AT91_PIN_PD0, AT91_PIN_PD1 };
554
555static struct resource spi1_resources[] = {
556 [0] = {
557 .start = AT91CAP9_BASE_SPI1,
558 .end = AT91CAP9_BASE_SPI1 + SZ_16K - 1,
559 .flags = IORESOURCE_MEM,
560 },
561 [1] = {
562 .start = AT91CAP9_ID_SPI1,
563 .end = AT91CAP9_ID_SPI1,
564 .flags = IORESOURCE_IRQ,
565 },
566};
567
568static struct platform_device at91cap9_spi1_device = {
569 .name = "atmel_spi",
570 .id = 1,
571 .dev = {
572 .dma_mask = &spi_dmamask,
573 .coherent_dma_mask = DMA_BIT_MASK(32),
574 },
575 .resource = spi1_resources,
576 .num_resources = ARRAY_SIZE(spi1_resources),
577};
578
579static const unsigned spi1_standard_cs[4] = { AT91_PIN_PB15, AT91_PIN_PB16, AT91_PIN_PB17, AT91_PIN_PB18 };
580
581void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
582{
583 int i;
584 unsigned long cs_pin;
585 short enable_spi0 = 0;
586 short enable_spi1 = 0;
587
588 /* Choose SPI chip-selects */
589 for (i = 0; i < nr_devices; i++) {
590 if (devices[i].controller_data)
591 cs_pin = (unsigned long) devices[i].controller_data;
592 else if (devices[i].bus_num == 0)
593 cs_pin = spi0_standard_cs[devices[i].chip_select];
594 else
595 cs_pin = spi1_standard_cs[devices[i].chip_select];
596
597 if (devices[i].bus_num == 0)
598 enable_spi0 = 1;
599 else
600 enable_spi1 = 1;
601
602 /* enable chip-select pin */
603 at91_set_gpio_output(cs_pin, 1);
604
605 /* pass chip-select pin to driver */
606 devices[i].controller_data = (void *) cs_pin;
607 }
608
609 spi_register_board_info(devices, nr_devices);
610
611 /* Configure SPI bus(es) */
612 if (enable_spi0) {
613 at91_set_B_periph(AT91_PIN_PA0, 0); /* SPI0_MISO */
614 at91_set_B_periph(AT91_PIN_PA1, 0); /* SPI0_MOSI */
615 at91_set_B_periph(AT91_PIN_PA2, 0); /* SPI0_SPCK */
616
617 platform_device_register(&at91cap9_spi0_device);
618 }
619 if (enable_spi1) {
620 at91_set_A_periph(AT91_PIN_PB12, 0); /* SPI1_MISO */
621 at91_set_A_periph(AT91_PIN_PB13, 0); /* SPI1_MOSI */
622 at91_set_A_periph(AT91_PIN_PB14, 0); /* SPI1_SPCK */
623
624 platform_device_register(&at91cap9_spi1_device);
625 }
626}
627#else
628void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) {}
629#endif
630
631
632/* --------------------------------------------------------------------
633 * Timer/Counter block
634 * -------------------------------------------------------------------- */
635
636#ifdef CONFIG_ATMEL_TCLIB
637
638static struct resource tcb_resources[] = {
639 [0] = {
640 .start = AT91CAP9_BASE_TCB0,
641 .end = AT91CAP9_BASE_TCB0 + SZ_16K - 1,
642 .flags = IORESOURCE_MEM,
643 },
644 [1] = {
645 .start = AT91CAP9_ID_TCB,
646 .end = AT91CAP9_ID_TCB,
647 .flags = IORESOURCE_IRQ,
648 },
649};
650
651static struct platform_device at91cap9_tcb_device = {
652 .name = "atmel_tcb",
653 .id = 0,
654 .resource = tcb_resources,
655 .num_resources = ARRAY_SIZE(tcb_resources),
656};
657
658static void __init at91_add_device_tc(void)
659{
660 platform_device_register(&at91cap9_tcb_device);
661}
662#else
663static void __init at91_add_device_tc(void) { }
664#endif
665
666
667/* --------------------------------------------------------------------
668 * RTT
669 * -------------------------------------------------------------------- */
670
671static struct resource rtt_resources[] = {
672 {
673 .start = AT91CAP9_BASE_RTT,
674 .end = AT91CAP9_BASE_RTT + SZ_16 - 1,
675 .flags = IORESOURCE_MEM,
676 }
677};
678
679static struct platform_device at91cap9_rtt_device = {
680 .name = "at91_rtt",
681 .id = 0,
682 .resource = rtt_resources,
683 .num_resources = ARRAY_SIZE(rtt_resources),
684};
685
686static void __init at91_add_device_rtt(void)
687{
688 platform_device_register(&at91cap9_rtt_device);
689}
690
691
692/* --------------------------------------------------------------------
693 * Watchdog
694 * -------------------------------------------------------------------- */
695
696#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
697static struct resource wdt_resources[] = {
698 {
699 .start = AT91CAP9_BASE_WDT,
700 .end = AT91CAP9_BASE_WDT + SZ_16 - 1,
701 .flags = IORESOURCE_MEM,
702 }
703};
704
705static struct platform_device at91cap9_wdt_device = {
706 .name = "at91_wdt",
707 .id = -1,
708 .resource = wdt_resources,
709 .num_resources = ARRAY_SIZE(wdt_resources),
710};
711
712static void __init at91_add_device_watchdog(void)
713{
714 platform_device_register(&at91cap9_wdt_device);
715}
716#else
717static void __init at91_add_device_watchdog(void) {}
718#endif
719
720
721/* --------------------------------------------------------------------
722 * PWM
723 * --------------------------------------------------------------------*/
724
725#if defined(CONFIG_ATMEL_PWM)
726static u32 pwm_mask;
727
728static struct resource pwm_resources[] = {
729 [0] = {
730 .start = AT91CAP9_BASE_PWMC,
731 .end = AT91CAP9_BASE_PWMC + SZ_16K - 1,
732 .flags = IORESOURCE_MEM,
733 },
734 [1] = {
735 .start = AT91CAP9_ID_PWMC,
736 .end = AT91CAP9_ID_PWMC,
737 .flags = IORESOURCE_IRQ,
738 },
739};
740
741static struct platform_device at91cap9_pwm0_device = {
742 .name = "atmel_pwm",
743 .id = -1,
744 .dev = {
745 .platform_data = &pwm_mask,
746 },
747 .resource = pwm_resources,
748 .num_resources = ARRAY_SIZE(pwm_resources),
749};
750
751void __init at91_add_device_pwm(u32 mask)
752{
753 if (mask & (1 << AT91_PWM0))
754 at91_set_A_periph(AT91_PIN_PB19, 1); /* enable PWM0 */
755
756 if (mask & (1 << AT91_PWM1))
757 at91_set_B_periph(AT91_PIN_PB8, 1); /* enable PWM1 */
758
759 if (mask & (1 << AT91_PWM2))
760 at91_set_B_periph(AT91_PIN_PC29, 1); /* enable PWM2 */
761
762 if (mask & (1 << AT91_PWM3))
763 at91_set_B_periph(AT91_PIN_PA11, 1); /* enable PWM3 */
764
765 pwm_mask = mask;
766
767 platform_device_register(&at91cap9_pwm0_device);
768}
769#else
770void __init at91_add_device_pwm(u32 mask) {}
771#endif
772
773
774
775/* --------------------------------------------------------------------
776 * AC97
777 * -------------------------------------------------------------------- */
778
779#if defined(CONFIG_SND_ATMEL_AC97C) || defined(CONFIG_SND_ATMEL_AC97C_MODULE)
780static u64 ac97_dmamask = DMA_BIT_MASK(32);
781static struct ac97c_platform_data ac97_data;
782
783static struct resource ac97_resources[] = {
784 [0] = {
785 .start = AT91CAP9_BASE_AC97C,
786 .end = AT91CAP9_BASE_AC97C + SZ_16K - 1,
787 .flags = IORESOURCE_MEM,
788 },
789 [1] = {
790 .start = AT91CAP9_ID_AC97C,
791 .end = AT91CAP9_ID_AC97C,
792 .flags = IORESOURCE_IRQ,
793 },
794};
795
796static struct platform_device at91cap9_ac97_device = {
797 .name = "atmel_ac97c",
798 .id = 1,
799 .dev = {
800 .dma_mask = &ac97_dmamask,
801 .coherent_dma_mask = DMA_BIT_MASK(32),
802 .platform_data = &ac97_data,
803 },
804 .resource = ac97_resources,
805 .num_resources = ARRAY_SIZE(ac97_resources),
806};
807
808void __init at91_add_device_ac97(struct ac97c_platform_data *data)
809{
810 if (!data)
811 return;
812
813 at91_set_A_periph(AT91_PIN_PA6, 0); /* AC97FS */
814 at91_set_A_periph(AT91_PIN_PA7, 0); /* AC97CK */
815 at91_set_A_periph(AT91_PIN_PA8, 0); /* AC97TX */
816 at91_set_A_periph(AT91_PIN_PA9, 0); /* AC97RX */
817
818 /* reset */
819 if (gpio_is_valid(data->reset_pin))
820 at91_set_gpio_output(data->reset_pin, 0);
821
822 ac97_data = *data;
823 platform_device_register(&at91cap9_ac97_device);
824}
825#else
826void __init at91_add_device_ac97(struct ac97c_platform_data *data) {}
827#endif
828
829
830/* --------------------------------------------------------------------
831 * LCD Controller
832 * -------------------------------------------------------------------- */
833
834#if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
835static u64 lcdc_dmamask = DMA_BIT_MASK(32);
836static struct atmel_lcdfb_info lcdc_data;
837
838static struct resource lcdc_resources[] = {
839 [0] = {
840 .start = AT91CAP9_LCDC_BASE,
841 .end = AT91CAP9_LCDC_BASE + SZ_4K - 1,
842 .flags = IORESOURCE_MEM,
843 },
844 [1] = {
845 .start = AT91CAP9_ID_LCDC,
846 .end = AT91CAP9_ID_LCDC,
847 .flags = IORESOURCE_IRQ,
848 },
849};
850
851static struct platform_device at91_lcdc_device = {
852 .name = "atmel_lcdfb",
853 .id = 0,
854 .dev = {
855 .dma_mask = &lcdc_dmamask,
856 .coherent_dma_mask = DMA_BIT_MASK(32),
857 .platform_data = &lcdc_data,
858 },
859 .resource = lcdc_resources,
860 .num_resources = ARRAY_SIZE(lcdc_resources),
861};
862
863void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data)
864{
865 if (!data)
866 return;
867
868 if (cpu_is_at91cap9_revB())
869 irq_set_irq_type(AT91CAP9_ID_LCDC, IRQ_TYPE_LEVEL_HIGH);
870
871 at91_set_A_periph(AT91_PIN_PC1, 0); /* LCDHSYNC */
872 at91_set_A_periph(AT91_PIN_PC2, 0); /* LCDDOTCK */
873 at91_set_A_periph(AT91_PIN_PC3, 0); /* LCDDEN */
874 at91_set_B_periph(AT91_PIN_PB9, 0); /* LCDCC */
875 at91_set_A_periph(AT91_PIN_PC6, 0); /* LCDD2 */
876 at91_set_A_periph(AT91_PIN_PC7, 0); /* LCDD3 */
877 at91_set_A_periph(AT91_PIN_PC8, 0); /* LCDD4 */
878 at91_set_A_periph(AT91_PIN_PC9, 0); /* LCDD5 */
879 at91_set_A_periph(AT91_PIN_PC10, 0); /* LCDD6 */
880 at91_set_A_periph(AT91_PIN_PC11, 0); /* LCDD7 */
881 at91_set_A_periph(AT91_PIN_PC14, 0); /* LCDD10 */
882 at91_set_A_periph(AT91_PIN_PC15, 0); /* LCDD11 */
883 at91_set_A_periph(AT91_PIN_PC16, 0); /* LCDD12 */
884 at91_set_A_periph(AT91_PIN_PC17, 0); /* LCDD13 */
885 at91_set_A_periph(AT91_PIN_PC18, 0); /* LCDD14 */
886 at91_set_A_periph(AT91_PIN_PC19, 0); /* LCDD15 */
887 at91_set_A_periph(AT91_PIN_PC22, 0); /* LCDD18 */
888 at91_set_A_periph(AT91_PIN_PC23, 0); /* LCDD19 */
889 at91_set_A_periph(AT91_PIN_PC24, 0); /* LCDD20 */
890 at91_set_A_periph(AT91_PIN_PC25, 0); /* LCDD21 */
891 at91_set_A_periph(AT91_PIN_PC26, 0); /* LCDD22 */
892 at91_set_A_periph(AT91_PIN_PC27, 0); /* LCDD23 */
893
894 lcdc_data = *data;
895 platform_device_register(&at91_lcdc_device);
896}
897#else
898void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {}
899#endif
900
901
902/* --------------------------------------------------------------------
903 * SSC -- Synchronous Serial Controller
904 * -------------------------------------------------------------------- */
905
906#if defined(CONFIG_ATMEL_SSC) || defined(CONFIG_ATMEL_SSC_MODULE)
907static u64 ssc0_dmamask = DMA_BIT_MASK(32);
908
909static struct resource ssc0_resources[] = {
910 [0] = {
911 .start = AT91CAP9_BASE_SSC0,
912 .end = AT91CAP9_BASE_SSC0 + SZ_16K - 1,
913 .flags = IORESOURCE_MEM,
914 },
915 [1] = {
916 .start = AT91CAP9_ID_SSC0,
917 .end = AT91CAP9_ID_SSC0,
918 .flags = IORESOURCE_IRQ,
919 },
920};
921
922static struct platform_device at91cap9_ssc0_device = {
923 .name = "ssc",
924 .id = 0,
925 .dev = {
926 .dma_mask = &ssc0_dmamask,
927 .coherent_dma_mask = DMA_BIT_MASK(32),
928 },
929 .resource = ssc0_resources,
930 .num_resources = ARRAY_SIZE(ssc0_resources),
931};
932
933static inline void configure_ssc0_pins(unsigned pins)
934{
935 if (pins & ATMEL_SSC_TF)
936 at91_set_A_periph(AT91_PIN_PB0, 1);
937 if (pins & ATMEL_SSC_TK)
938 at91_set_A_periph(AT91_PIN_PB1, 1);
939 if (pins & ATMEL_SSC_TD)
940 at91_set_A_periph(AT91_PIN_PB2, 1);
941 if (pins & ATMEL_SSC_RD)
942 at91_set_A_periph(AT91_PIN_PB3, 1);
943 if (pins & ATMEL_SSC_RK)
944 at91_set_A_periph(AT91_PIN_PB4, 1);
945 if (pins & ATMEL_SSC_RF)
946 at91_set_A_periph(AT91_PIN_PB5, 1);
947}
948
949static u64 ssc1_dmamask = DMA_BIT_MASK(32);
950
951static struct resource ssc1_resources[] = {
952 [0] = {
953 .start = AT91CAP9_BASE_SSC1,
954 .end = AT91CAP9_BASE_SSC1 + SZ_16K - 1,
955 .flags = IORESOURCE_MEM,
956 },
957 [1] = {
958 .start = AT91CAP9_ID_SSC1,
959 .end = AT91CAP9_ID_SSC1,
960 .flags = IORESOURCE_IRQ,
961 },
962};
963
964static struct platform_device at91cap9_ssc1_device = {
965 .name = "ssc",
966 .id = 1,
967 .dev = {
968 .dma_mask = &ssc1_dmamask,
969 .coherent_dma_mask = DMA_BIT_MASK(32),
970 },
971 .resource = ssc1_resources,
972 .num_resources = ARRAY_SIZE(ssc1_resources),
973};
974
975static inline void configure_ssc1_pins(unsigned pins)
976{
977 if (pins & ATMEL_SSC_TF)
978 at91_set_A_periph(AT91_PIN_PB6, 1);
979 if (pins & ATMEL_SSC_TK)
980 at91_set_A_periph(AT91_PIN_PB7, 1);
981 if (pins & ATMEL_SSC_TD)
982 at91_set_A_periph(AT91_PIN_PB8, 1);
983 if (pins & ATMEL_SSC_RD)
984 at91_set_A_periph(AT91_PIN_PB9, 1);
985 if (pins & ATMEL_SSC_RK)
986 at91_set_A_periph(AT91_PIN_PB10, 1);
987 if (pins & ATMEL_SSC_RF)
988 at91_set_A_periph(AT91_PIN_PB11, 1);
989}
990
991/*
992 * SSC controllers are accessed through library code, instead of any
993 * kind of all-singing/all-dancing driver. For example one could be
994 * used by a particular I2S audio codec's driver, while another one
995 * on the same system might be used by a custom data capture driver.
996 */
997void __init at91_add_device_ssc(unsigned id, unsigned pins)
998{
999 struct platform_device *pdev;
1000
1001 /*
1002 * NOTE: caller is responsible for passing information matching
1003 * "pins" to whatever will be using each particular controller.
1004 */
1005 switch (id) {
1006 case AT91CAP9_ID_SSC0:
1007 pdev = &at91cap9_ssc0_device;
1008 configure_ssc0_pins(pins);
1009 break;
1010 case AT91CAP9_ID_SSC1:
1011 pdev = &at91cap9_ssc1_device;
1012 configure_ssc1_pins(pins);
1013 break;
1014 default:
1015 return;
1016 }
1017
1018 platform_device_register(pdev);
1019}
1020
1021#else
1022void __init at91_add_device_ssc(unsigned id, unsigned pins) {}
1023#endif
1024
1025
1026/* --------------------------------------------------------------------
1027 * UART
1028 * -------------------------------------------------------------------- */
1029
1030#if defined(CONFIG_SERIAL_ATMEL)
1031static struct resource dbgu_resources[] = {
1032 [0] = {
1033 .start = AT91CAP9_BASE_DBGU,
1034 .end = AT91CAP9_BASE_DBGU + SZ_512 - 1,
1035 .flags = IORESOURCE_MEM,
1036 },
1037 [1] = {
1038 .start = AT91_ID_SYS,
1039 .end = AT91_ID_SYS,
1040 .flags = IORESOURCE_IRQ,
1041 },
1042};
1043
1044static struct atmel_uart_data dbgu_data = {
1045 .use_dma_tx = 0,
1046 .use_dma_rx = 0, /* DBGU not capable of receive DMA */
1047};
1048
1049static u64 dbgu_dmamask = DMA_BIT_MASK(32);
1050
1051static struct platform_device at91cap9_dbgu_device = {
1052 .name = "atmel_usart",
1053 .id = 0,
1054 .dev = {
1055 .dma_mask = &dbgu_dmamask,
1056 .coherent_dma_mask = DMA_BIT_MASK(32),
1057 .platform_data = &dbgu_data,
1058 },
1059 .resource = dbgu_resources,
1060 .num_resources = ARRAY_SIZE(dbgu_resources),
1061};
1062
1063static inline void configure_dbgu_pins(void)
1064{
1065 at91_set_A_periph(AT91_PIN_PC30, 0); /* DRXD */
1066 at91_set_A_periph(AT91_PIN_PC31, 1); /* DTXD */
1067}
1068
1069static struct resource uart0_resources[] = {
1070 [0] = {
1071 .start = AT91CAP9_BASE_US0,
1072 .end = AT91CAP9_BASE_US0 + SZ_16K - 1,
1073 .flags = IORESOURCE_MEM,
1074 },
1075 [1] = {
1076 .start = AT91CAP9_ID_US0,
1077 .end = AT91CAP9_ID_US0,
1078 .flags = IORESOURCE_IRQ,
1079 },
1080};
1081
1082static struct atmel_uart_data uart0_data = {
1083 .use_dma_tx = 1,
1084 .use_dma_rx = 1,
1085};
1086
1087static u64 uart0_dmamask = DMA_BIT_MASK(32);
1088
1089static struct platform_device at91cap9_uart0_device = {
1090 .name = "atmel_usart",
1091 .id = 1,
1092 .dev = {
1093 .dma_mask = &uart0_dmamask,
1094 .coherent_dma_mask = DMA_BIT_MASK(32),
1095 .platform_data = &uart0_data,
1096 },
1097 .resource = uart0_resources,
1098 .num_resources = ARRAY_SIZE(uart0_resources),
1099};
1100
1101static inline void configure_usart0_pins(unsigned pins)
1102{
1103 at91_set_A_periph(AT91_PIN_PA22, 1); /* TXD0 */
1104 at91_set_A_periph(AT91_PIN_PA23, 0); /* RXD0 */
1105
1106 if (pins & ATMEL_UART_RTS)
1107 at91_set_A_periph(AT91_PIN_PA24, 0); /* RTS0 */
1108 if (pins & ATMEL_UART_CTS)
1109 at91_set_A_periph(AT91_PIN_PA25, 0); /* CTS0 */
1110}
1111
1112static struct resource uart1_resources[] = {
1113 [0] = {
1114 .start = AT91CAP9_BASE_US1,
1115 .end = AT91CAP9_BASE_US1 + SZ_16K - 1,
1116 .flags = IORESOURCE_MEM,
1117 },
1118 [1] = {
1119 .start = AT91CAP9_ID_US1,
1120 .end = AT91CAP9_ID_US1,
1121 .flags = IORESOURCE_IRQ,
1122 },
1123};
1124
1125static struct atmel_uart_data uart1_data = {
1126 .use_dma_tx = 1,
1127 .use_dma_rx = 1,
1128};
1129
1130static u64 uart1_dmamask = DMA_BIT_MASK(32);
1131
1132static struct platform_device at91cap9_uart1_device = {
1133 .name = "atmel_usart",
1134 .id = 2,
1135 .dev = {
1136 .dma_mask = &uart1_dmamask,
1137 .coherent_dma_mask = DMA_BIT_MASK(32),
1138 .platform_data = &uart1_data,
1139 },
1140 .resource = uart1_resources,
1141 .num_resources = ARRAY_SIZE(uart1_resources),
1142};
1143
1144static inline void configure_usart1_pins(unsigned pins)
1145{
1146 at91_set_A_periph(AT91_PIN_PD0, 1); /* TXD1 */
1147 at91_set_A_periph(AT91_PIN_PD1, 0); /* RXD1 */
1148
1149 if (pins & ATMEL_UART_RTS)
1150 at91_set_B_periph(AT91_PIN_PD7, 0); /* RTS1 */
1151 if (pins & ATMEL_UART_CTS)
1152 at91_set_B_periph(AT91_PIN_PD8, 0); /* CTS1 */
1153}
1154
1155static struct resource uart2_resources[] = {
1156 [0] = {
1157 .start = AT91CAP9_BASE_US2,
1158 .end = AT91CAP9_BASE_US2 + SZ_16K - 1,
1159 .flags = IORESOURCE_MEM,
1160 },
1161 [1] = {
1162 .start = AT91CAP9_ID_US2,
1163 .end = AT91CAP9_ID_US2,
1164 .flags = IORESOURCE_IRQ,
1165 },
1166};
1167
1168static struct atmel_uart_data uart2_data = {
1169 .use_dma_tx = 1,
1170 .use_dma_rx = 1,
1171};
1172
1173static u64 uart2_dmamask = DMA_BIT_MASK(32);
1174
1175static struct platform_device at91cap9_uart2_device = {
1176 .name = "atmel_usart",
1177 .id = 3,
1178 .dev = {
1179 .dma_mask = &uart2_dmamask,
1180 .coherent_dma_mask = DMA_BIT_MASK(32),
1181 .platform_data = &uart2_data,
1182 },
1183 .resource = uart2_resources,
1184 .num_resources = ARRAY_SIZE(uart2_resources),
1185};
1186
1187static inline void configure_usart2_pins(unsigned pins)
1188{
1189 at91_set_A_periph(AT91_PIN_PD2, 1); /* TXD2 */
1190 at91_set_A_periph(AT91_PIN_PD3, 0); /* RXD2 */
1191
1192 if (pins & ATMEL_UART_RTS)
1193 at91_set_B_periph(AT91_PIN_PD5, 0); /* RTS2 */
1194 if (pins & ATMEL_UART_CTS)
1195 at91_set_B_periph(AT91_PIN_PD6, 0); /* CTS2 */
1196}
1197
1198static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
1199struct platform_device *atmel_default_console_device; /* the serial console device */
1200
1201void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
1202{
1203 struct platform_device *pdev;
1204 struct atmel_uart_data *pdata;
1205
1206 switch (id) {
1207 case 0: /* DBGU */
1208 pdev = &at91cap9_dbgu_device;
1209 configure_dbgu_pins();
1210 break;
1211 case AT91CAP9_ID_US0:
1212 pdev = &at91cap9_uart0_device;
1213 configure_usart0_pins(pins);
1214 break;
1215 case AT91CAP9_ID_US1:
1216 pdev = &at91cap9_uart1_device;
1217 configure_usart1_pins(pins);
1218 break;
1219 case AT91CAP9_ID_US2:
1220 pdev = &at91cap9_uart2_device;
1221 configure_usart2_pins(pins);
1222 break;
1223 default:
1224 return;
1225 }
1226 pdata = pdev->dev.platform_data;
1227 pdata->num = portnr; /* update to mapped ID */
1228
1229 if (portnr < ATMEL_MAX_UART)
1230 at91_uarts[portnr] = pdev;
1231}
1232
1233void __init at91_set_serial_console(unsigned portnr)
1234{
1235 if (portnr < ATMEL_MAX_UART) {
1236 atmel_default_console_device = at91_uarts[portnr];
1237 at91cap9_set_console_clock(at91_uarts[portnr]->id);
1238 }
1239}
1240
1241void __init at91_add_device_serial(void)
1242{
1243 int i;
1244
1245 for (i = 0; i < ATMEL_MAX_UART; i++) {
1246 if (at91_uarts[i])
1247 platform_device_register(at91_uarts[i]);
1248 }
1249
1250 if (!atmel_default_console_device)
1251 printk(KERN_INFO "AT91: No default serial console defined.\n");
1252}
1253#else
1254void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
1255void __init at91_set_serial_console(unsigned portnr) {}
1256void __init at91_add_device_serial(void) {}
1257#endif
1258
1259
1260/* -------------------------------------------------------------------- */
1261/*
1262 * These devices are always present and don't need any board-specific
1263 * setup.
1264 */
1265static int __init at91_add_standard_devices(void)
1266{
1267 at91_add_device_rtt();
1268 at91_add_device_watchdog();
1269 at91_add_device_tc();
1270 return 0;
1271}
1272
1273arch_initcall(at91_add_standard_devices);
diff --git a/arch/arm/mach-at91/at91rm9200.c b/arch/arm/mach-at91/at91rm9200.c
index 413c027ab85..364c19357e6 100644
--- a/arch/arm/mach-at91/at91rm9200.c
+++ b/arch/arm/mach-at91/at91rm9200.c
@@ -290,13 +290,22 @@ static struct at91_gpio_bank at91rm9200_gpio[] __initdata = {
290 } 290 }
291}; 291};
292 292
293static void at91rm9200_idle(void)
294{
295 /*
296 * Disable the processor clock. The processor will be automatically
297 * re-enabled by an interrupt or by a reset.
298 */
299 at91_pmc_write(AT91_PMC_SCDR, AT91_PMC_PCK);
300}
301
293static void at91rm9200_restart(char mode, const char *cmd) 302static void at91rm9200_restart(char mode, const char *cmd)
294{ 303{
295 /* 304 /*
296 * Perform a hardware reset with the use of the Watchdog timer. 305 * Perform a hardware reset with the use of the Watchdog timer.
297 */ 306 */
298 at91_sys_write(AT91_ST_WDMR, AT91_ST_RSTEN | AT91_ST_EXTEN | 1); 307 at91_st_write(AT91_ST_WDMR, AT91_ST_RSTEN | AT91_ST_EXTEN | 1);
299 at91_sys_write(AT91_ST_CR, AT91_ST_WDRST); 308 at91_st_write(AT91_ST_CR, AT91_ST_WDRST);
300} 309}
301 310
302/* -------------------------------------------------------------------- 311/* --------------------------------------------------------------------
@@ -311,10 +320,13 @@ static void __init at91rm9200_map_io(void)
311 320
312static void __init at91rm9200_ioremap_registers(void) 321static void __init at91rm9200_ioremap_registers(void)
313{ 322{
323 at91rm9200_ioremap_st(AT91RM9200_BASE_ST);
324 at91_ioremap_ramc(0, AT91RM9200_BASE_MC, 256);
314} 325}
315 326
316static void __init at91rm9200_initialize(void) 327static void __init at91rm9200_initialize(void)
317{ 328{
329 arm_pm_idle = at91rm9200_idle;
318 arm_pm_restart = at91rm9200_restart; 330 arm_pm_restart = at91rm9200_restart;
319 at91_extern_irq = (1 << AT91RM9200_ID_IRQ0) | (1 << AT91RM9200_ID_IRQ1) 331 at91_extern_irq = (1 << AT91RM9200_ID_IRQ0) | (1 << AT91RM9200_ID_IRQ1)
320 | (1 << AT91RM9200_ID_IRQ2) | (1 << AT91RM9200_ID_IRQ3) 332 | (1 << AT91RM9200_ID_IRQ2) | (1 << AT91RM9200_ID_IRQ3)
diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c
index 97676bdae99..99ce5c955e3 100644
--- a/arch/arm/mach-at91/at91rm9200_devices.c
+++ b/arch/arm/mach-at91/at91rm9200_devices.c
@@ -21,6 +21,7 @@
21#include <mach/board.h> 21#include <mach/board.h>
22#include <mach/at91rm9200.h> 22#include <mach/at91rm9200.h>
23#include <mach/at91rm9200_mc.h> 23#include <mach/at91rm9200_mc.h>
24#include <mach/at91_ramc.h>
24 25
25#include "generic.h" 26#include "generic.h"
26 27
@@ -241,15 +242,15 @@ void __init at91_add_device_cf(struct at91_cf_data *data)
241 data->chipselect = 4; /* can only use EBI ChipSelect 4 */ 242 data->chipselect = 4; /* can only use EBI ChipSelect 4 */
242 243
243 /* CF takes over CS4, CS5, CS6 */ 244 /* CF takes over CS4, CS5, CS6 */
244 csa = at91_sys_read(AT91_EBI_CSA); 245 csa = at91_ramc_read(0, AT91_EBI_CSA);
245 at91_sys_write(AT91_EBI_CSA, csa | AT91_EBI_CS4A_SMC_COMPACTFLASH); 246 at91_ramc_write(0, AT91_EBI_CSA, csa | AT91_EBI_CS4A_SMC_COMPACTFLASH);
246 247
247 /* 248 /*
248 * Static memory controller timing adjustments. 249 * Static memory controller timing adjustments.
249 * REVISIT: these timings are in terms of MCK cycles, so 250 * REVISIT: these timings are in terms of MCK cycles, so
250 * when MCK changes (cpufreq etc) so must these values... 251 * when MCK changes (cpufreq etc) so must these values...
251 */ 252 */
252 at91_sys_write(AT91_SMC_CSR(4), 253 at91_ramc_write(0, AT91_SMC_CSR(4),
253 AT91_SMC_ACSS_STD 254 AT91_SMC_ACSS_STD
254 | AT91_SMC_DBW_16 255 | AT91_SMC_DBW_16
255 | AT91_SMC_BAT 256 | AT91_SMC_BAT
@@ -407,11 +408,11 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)
407 return; 408 return;
408 409
409 /* enable the address range of CS3 */ 410 /* enable the address range of CS3 */
410 csa = at91_sys_read(AT91_EBI_CSA); 411 csa = at91_ramc_read(0, AT91_EBI_CSA);
411 at91_sys_write(AT91_EBI_CSA, csa | AT91_EBI_CS3A_SMC_SMARTMEDIA); 412 at91_ramc_write(0, AT91_EBI_CSA, csa | AT91_EBI_CS3A_SMC_SMARTMEDIA);
412 413
413 /* set the bus interface characteristics */ 414 /* set the bus interface characteristics */
414 at91_sys_write(AT91_SMC_CSR(3), AT91_SMC_ACSS_STD | AT91_SMC_DBW_8 | AT91_SMC_WSEN 415 at91_ramc_write(0, AT91_SMC_CSR(3), AT91_SMC_ACSS_STD | AT91_SMC_DBW_8 | AT91_SMC_WSEN
415 | AT91_SMC_NWS_(5) 416 | AT91_SMC_NWS_(5)
416 | AT91_SMC_TDF_(1) 417 | AT91_SMC_TDF_(1)
417 | AT91_SMC_RWSETUP_(0) /* tDS Data Set up Time 30 - ns */ 418 | AT91_SMC_RWSETUP_(0) /* tDS Data Set up Time 30 - ns */
@@ -1114,7 +1115,6 @@ static inline void configure_usart3_pins(unsigned pins)
1114} 1115}
1115 1116
1116static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ 1117static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
1117struct platform_device *atmel_default_console_device; /* the serial console device */
1118 1118
1119void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) 1119void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
1120{ 1120{
diff --git a/arch/arm/mach-at91/at91rm9200_time.c b/arch/arm/mach-at91/at91rm9200_time.c
index a028cdf8f97..dd7f782b0b9 100644
--- a/arch/arm/mach-at91/at91rm9200_time.c
+++ b/arch/arm/mach-at91/at91rm9200_time.c
@@ -43,9 +43,9 @@ static inline unsigned long read_CRTR(void)
43{ 43{
44 unsigned long x1, x2; 44 unsigned long x1, x2;
45 45
46 x1 = at91_sys_read(AT91_ST_CRTR); 46 x1 = at91_st_read(AT91_ST_CRTR);
47 do { 47 do {
48 x2 = at91_sys_read(AT91_ST_CRTR); 48 x2 = at91_st_read(AT91_ST_CRTR);
49 if (x1 == x2) 49 if (x1 == x2)
50 break; 50 break;
51 x1 = x2; 51 x1 = x2;
@@ -58,7 +58,7 @@ static inline unsigned long read_CRTR(void)
58 */ 58 */
59static irqreturn_t at91rm9200_timer_interrupt(int irq, void *dev_id) 59static irqreturn_t at91rm9200_timer_interrupt(int irq, void *dev_id)
60{ 60{
61 u32 sr = at91_sys_read(AT91_ST_SR) & irqmask; 61 u32 sr = at91_st_read(AT91_ST_SR) & irqmask;
62 62
63 /* 63 /*
64 * irqs should be disabled here, but as the irq is shared they are only 64 * irqs should be disabled here, but as the irq is shared they are only
@@ -110,22 +110,22 @@ static void
110clkevt32k_mode(enum clock_event_mode mode, struct clock_event_device *dev) 110clkevt32k_mode(enum clock_event_mode mode, struct clock_event_device *dev)
111{ 111{
112 /* Disable and flush pending timer interrupts */ 112 /* Disable and flush pending timer interrupts */
113 at91_sys_write(AT91_ST_IDR, AT91_ST_PITS | AT91_ST_ALMS); 113 at91_st_write(AT91_ST_IDR, AT91_ST_PITS | AT91_ST_ALMS);
114 (void) at91_sys_read(AT91_ST_SR); 114 at91_st_read(AT91_ST_SR);
115 115
116 last_crtr = read_CRTR(); 116 last_crtr = read_CRTR();
117 switch (mode) { 117 switch (mode) {
118 case CLOCK_EVT_MODE_PERIODIC: 118 case CLOCK_EVT_MODE_PERIODIC:
119 /* PIT for periodic irqs; fixed rate of 1/HZ */ 119 /* PIT for periodic irqs; fixed rate of 1/HZ */
120 irqmask = AT91_ST_PITS; 120 irqmask = AT91_ST_PITS;
121 at91_sys_write(AT91_ST_PIMR, RM9200_TIMER_LATCH); 121 at91_st_write(AT91_ST_PIMR, RM9200_TIMER_LATCH);
122 break; 122 break;
123 case CLOCK_EVT_MODE_ONESHOT: 123 case CLOCK_EVT_MODE_ONESHOT:
124 /* ALM for oneshot irqs, set by next_event() 124 /* ALM for oneshot irqs, set by next_event()
125 * before 32 seconds have passed 125 * before 32 seconds have passed
126 */ 126 */
127 irqmask = AT91_ST_ALMS; 127 irqmask = AT91_ST_ALMS;
128 at91_sys_write(AT91_ST_RTAR, last_crtr); 128 at91_st_write(AT91_ST_RTAR, last_crtr);
129 break; 129 break;
130 case CLOCK_EVT_MODE_SHUTDOWN: 130 case CLOCK_EVT_MODE_SHUTDOWN:
131 case CLOCK_EVT_MODE_UNUSED: 131 case CLOCK_EVT_MODE_UNUSED:
@@ -133,7 +133,7 @@ clkevt32k_mode(enum clock_event_mode mode, struct clock_event_device *dev)
133 irqmask = 0; 133 irqmask = 0;
134 break; 134 break;
135 } 135 }
136 at91_sys_write(AT91_ST_IER, irqmask); 136 at91_st_write(AT91_ST_IER, irqmask);
137} 137}
138 138
139static int 139static int
@@ -156,12 +156,12 @@ clkevt32k_next_event(unsigned long delta, struct clock_event_device *dev)
156 alm = read_CRTR(); 156 alm = read_CRTR();
157 157
158 /* Cancel any pending alarm; flush any pending IRQ */ 158 /* Cancel any pending alarm; flush any pending IRQ */
159 at91_sys_write(AT91_ST_RTAR, alm); 159 at91_st_write(AT91_ST_RTAR, alm);
160 (void) at91_sys_read(AT91_ST_SR); 160 at91_st_read(AT91_ST_SR);
161 161
162 /* Schedule alarm by writing RTAR. */ 162 /* Schedule alarm by writing RTAR. */
163 alm += delta; 163 alm += delta;
164 at91_sys_write(AT91_ST_RTAR, alm); 164 at91_st_write(AT91_ST_RTAR, alm);
165 165
166 return status; 166 return status;
167} 167}
@@ -175,15 +175,24 @@ static struct clock_event_device clkevt = {
175 .set_mode = clkevt32k_mode, 175 .set_mode = clkevt32k_mode,
176}; 176};
177 177
178void __iomem *at91_st_base;
179
180void __init at91rm9200_ioremap_st(u32 addr)
181{
182 at91_st_base = ioremap(addr, 256);
183 if (!at91_st_base)
184 panic("Impossible to ioremap ST\n");
185}
186
178/* 187/*
179 * ST (system timer) module supports both clockevents and clocksource. 188 * ST (system timer) module supports both clockevents and clocksource.
180 */ 189 */
181void __init at91rm9200_timer_init(void) 190void __init at91rm9200_timer_init(void)
182{ 191{
183 /* Disable all timer interrupts, and clear any pending ones */ 192 /* Disable all timer interrupts, and clear any pending ones */
184 at91_sys_write(AT91_ST_IDR, 193 at91_st_write(AT91_ST_IDR,
185 AT91_ST_PITS | AT91_ST_WDOVF | AT91_ST_RTTINC | AT91_ST_ALMS); 194 AT91_ST_PITS | AT91_ST_WDOVF | AT91_ST_RTTINC | AT91_ST_ALMS);
186 (void) at91_sys_read(AT91_ST_SR); 195 at91_st_read(AT91_ST_SR);
187 196
188 /* Make IRQs happen for the system timer */ 197 /* Make IRQs happen for the system timer */
189 setup_irq(AT91_ID_SYS, &at91rm9200_timer_irq); 198 setup_irq(AT91_ID_SYS, &at91rm9200_timer_irq);
@@ -192,7 +201,7 @@ void __init at91rm9200_timer_init(void)
192 * directly for the clocksource and all clockevents, after adjusting 201 * directly for the clocksource and all clockevents, after adjusting
193 * its prescaler from the 1 Hz default. 202 * its prescaler from the 1 Hz default.
194 */ 203 */
195 at91_sys_write(AT91_ST_RTMR, 1); 204 at91_st_write(AT91_ST_RTMR, 1);
196 205
197 /* Setup timer clockevent, with minimum of two ticks (important!!) */ 206 /* Setup timer clockevent, with minimum of two ticks (important!!) */
198 clkevt.mult = div_sc(AT91_SLOW_CLOCK, NSEC_PER_SEC, clkevt.shift); 207 clkevt.mult = div_sc(AT91_SLOW_CLOCK, NSEC_PER_SEC, clkevt.shift);
diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c
index 79f571842c2..46f77423329 100644
--- a/arch/arm/mach-at91/at91sam9260.c
+++ b/arch/arm/mach-at91/at91sam9260.c
@@ -12,6 +12,7 @@
12 12
13#include <linux/module.h> 13#include <linux/module.h>
14 14
15#include <asm/proc-fns.h>
15#include <asm/irq.h> 16#include <asm/irq.h>
16#include <asm/mach/arch.h> 17#include <asm/mach/arch.h>
17#include <asm/mach/map.h> 18#include <asm/mach/map.h>
@@ -209,6 +210,14 @@ static struct clk_lookup periph_clocks_lookups[] = {
209 CLKDEV_CON_DEV_ID("usart", "fffd0000.serial", &usart3_clk), 210 CLKDEV_CON_DEV_ID("usart", "fffd0000.serial", &usart3_clk),
210 CLKDEV_CON_DEV_ID("usart", "fffd4000.serial", &usart4_clk), 211 CLKDEV_CON_DEV_ID("usart", "fffd4000.serial", &usart4_clk),
211 CLKDEV_CON_DEV_ID("usart", "fffd8000.serial", &usart5_clk), 212 CLKDEV_CON_DEV_ID("usart", "fffd8000.serial", &usart5_clk),
213 /* more tc lookup table for DT entries */
214 CLKDEV_CON_DEV_ID("t0_clk", "fffa0000.timer", &tc0_clk),
215 CLKDEV_CON_DEV_ID("t1_clk", "fffa0000.timer", &tc1_clk),
216 CLKDEV_CON_DEV_ID("t2_clk", "fffa0000.timer", &tc2_clk),
217 CLKDEV_CON_DEV_ID("t0_clk", "fffdc000.timer", &tc3_clk),
218 CLKDEV_CON_DEV_ID("t1_clk", "fffdc000.timer", &tc4_clk),
219 CLKDEV_CON_DEV_ID("t2_clk", "fffdc000.timer", &tc5_clk),
220 CLKDEV_CON_DEV_ID("hclk", "500000.ohci", &ohci_clk),
212 /* fake hclk clock */ 221 /* fake hclk clock */
213 CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &ohci_clk), 222 CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &ohci_clk),
214 CLKDEV_CON_ID("pioA", &pioA_clk), 223 CLKDEV_CON_ID("pioA", &pioA_clk),
@@ -310,27 +319,27 @@ static void __init at91sam9xe_map_io(void)
310 319
311static void __init at91sam9260_map_io(void) 320static void __init at91sam9260_map_io(void)
312{ 321{
313 if (cpu_is_at91sam9xe()) { 322 if (cpu_is_at91sam9xe())
314 at91sam9xe_map_io(); 323 at91sam9xe_map_io();
315 } else if (cpu_is_at91sam9g20()) { 324 else if (cpu_is_at91sam9g20())
316 at91_init_sram(0, AT91SAM9G20_SRAM0_BASE, AT91SAM9G20_SRAM0_SIZE); 325 at91_init_sram(0, AT91SAM9G20_SRAM_BASE, AT91SAM9G20_SRAM_SIZE);
317 at91_init_sram(1, AT91SAM9G20_SRAM1_BASE, AT91SAM9G20_SRAM1_SIZE); 326 else
318 } else { 327 at91_init_sram(0, AT91SAM9260_SRAM_BASE, AT91SAM9260_SRAM_SIZE);
319 at91_init_sram(0, AT91SAM9260_SRAM0_BASE, AT91SAM9260_SRAM0_SIZE);
320 at91_init_sram(1, AT91SAM9260_SRAM1_BASE, AT91SAM9260_SRAM1_SIZE);
321 }
322} 328}
323 329
324static void __init at91sam9260_ioremap_registers(void) 330static void __init at91sam9260_ioremap_registers(void)
325{ 331{
326 at91_ioremap_shdwc(AT91SAM9260_BASE_SHDWC); 332 at91_ioremap_shdwc(AT91SAM9260_BASE_SHDWC);
327 at91_ioremap_rstc(AT91SAM9260_BASE_RSTC); 333 at91_ioremap_rstc(AT91SAM9260_BASE_RSTC);
334 at91_ioremap_ramc(0, AT91SAM9260_BASE_SDRAMC, 512);
328 at91sam926x_ioremap_pit(AT91SAM9260_BASE_PIT); 335 at91sam926x_ioremap_pit(AT91SAM9260_BASE_PIT);
329 at91sam9_ioremap_smc(0, AT91SAM9260_BASE_SMC); 336 at91sam9_ioremap_smc(0, AT91SAM9260_BASE_SMC);
337 at91_ioremap_matrix(AT91SAM9260_BASE_MATRIX);
330} 338}
331 339
332static void __init at91sam9260_initialize(void) 340static void __init at91sam9260_initialize(void)
333{ 341{
342 arm_pm_idle = at91sam9_idle;
334 arm_pm_restart = at91sam9_alt_restart; 343 arm_pm_restart = at91sam9_alt_restart;
335 at91_extern_irq = (1 << AT91SAM9260_ID_IRQ0) | (1 << AT91SAM9260_ID_IRQ1) 344 at91_extern_irq = (1 << AT91SAM9260_ID_IRQ0) | (1 << AT91SAM9260_ID_IRQ1)
336 | (1 << AT91SAM9260_ID_IRQ2); 345 | (1 << AT91SAM9260_ID_IRQ2);
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
index 5a24f0b4554..7e5651ee9f8 100644
--- a/arch/arm/mach-at91/at91sam9260_devices.c
+++ b/arch/arm/mach-at91/at91sam9260_devices.c
@@ -21,6 +21,7 @@
21#include <mach/cpu.h> 21#include <mach/cpu.h>
22#include <mach/at91sam9260.h> 22#include <mach/at91sam9260.h>
23#include <mach/at91sam9260_matrix.h> 23#include <mach/at91sam9260_matrix.h>
24#include <mach/at91_matrix.h>
24#include <mach/at91sam9_smc.h> 25#include <mach/at91sam9_smc.h>
25 26
26#include "generic.h" 27#include "generic.h"
@@ -422,8 +423,8 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)
422 if (!data) 423 if (!data)
423 return; 424 return;
424 425
425 csa = at91_sys_read(AT91_MATRIX_EBICSA); 426 csa = at91_matrix_read(AT91_MATRIX_EBICSA);
426 at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA); 427 at91_matrix_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA);
427 428
428 /* enable pin */ 429 /* enable pin */
429 if (gpio_is_valid(data->enable_pin)) 430 if (gpio_is_valid(data->enable_pin))
@@ -641,7 +642,7 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
641static struct resource tcb0_resources[] = { 642static struct resource tcb0_resources[] = {
642 [0] = { 643 [0] = {
643 .start = AT91SAM9260_BASE_TCB0, 644 .start = AT91SAM9260_BASE_TCB0,
644 .end = AT91SAM9260_BASE_TCB0 + SZ_16K - 1, 645 .end = AT91SAM9260_BASE_TCB0 + SZ_256 - 1,
645 .flags = IORESOURCE_MEM, 646 .flags = IORESOURCE_MEM,
646 }, 647 },
647 [1] = { 648 [1] = {
@@ -671,7 +672,7 @@ static struct platform_device at91sam9260_tcb0_device = {
671static struct resource tcb1_resources[] = { 672static struct resource tcb1_resources[] = {
672 [0] = { 673 [0] = {
673 .start = AT91SAM9260_BASE_TCB1, 674 .start = AT91SAM9260_BASE_TCB1,
674 .end = AT91SAM9260_BASE_TCB1 + SZ_16K - 1, 675 .end = AT91SAM9260_BASE_TCB1 + SZ_256 - 1,
675 .flags = IORESOURCE_MEM, 676 .flags = IORESOURCE_MEM,
676 }, 677 },
677 [1] = { 678 [1] = {
@@ -698,8 +699,25 @@ static struct platform_device at91sam9260_tcb1_device = {
698 .num_resources = ARRAY_SIZE(tcb1_resources), 699 .num_resources = ARRAY_SIZE(tcb1_resources),
699}; 700};
700 701
702#if defined(CONFIG_OF)
703static struct of_device_id tcb_ids[] = {
704 { .compatible = "atmel,at91rm9200-tcb" },
705 { /*sentinel*/ }
706};
707#endif
708
701static void __init at91_add_device_tc(void) 709static void __init at91_add_device_tc(void)
702{ 710{
711#if defined(CONFIG_OF)
712 struct device_node *np;
713
714 np = of_find_matching_node(NULL, tcb_ids);
715 if (np) {
716 of_node_put(np);
717 return;
718 }
719#endif
720
703 platform_device_register(&at91sam9260_tcb0_device); 721 platform_device_register(&at91sam9260_tcb0_device);
704 platform_device_register(&at91sam9260_tcb1_device); 722 platform_device_register(&at91sam9260_tcb1_device);
705} 723}
@@ -717,18 +735,42 @@ static struct resource rtt_resources[] = {
717 .start = AT91SAM9260_BASE_RTT, 735 .start = AT91SAM9260_BASE_RTT,
718 .end = AT91SAM9260_BASE_RTT + SZ_16 - 1, 736 .end = AT91SAM9260_BASE_RTT + SZ_16 - 1,
719 .flags = IORESOURCE_MEM, 737 .flags = IORESOURCE_MEM,
720 } 738 }, {
739 .flags = IORESOURCE_MEM,
740 },
721}; 741};
722 742
723static struct platform_device at91sam9260_rtt_device = { 743static struct platform_device at91sam9260_rtt_device = {
724 .name = "at91_rtt", 744 .name = "at91_rtt",
725 .id = 0, 745 .id = 0,
726 .resource = rtt_resources, 746 .resource = rtt_resources,
727 .num_resources = ARRAY_SIZE(rtt_resources),
728}; 747};
729 748
749
750#if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9)
751static void __init at91_add_device_rtt_rtc(void)
752{
753 at91sam9260_rtt_device.name = "rtc-at91sam9";
754 /*
755 * The second resource is needed:
756 * GPBR will serve as the storage for RTC time offset
757 */
758 at91sam9260_rtt_device.num_resources = 2;
759 rtt_resources[1].start = AT91SAM9260_BASE_GPBR +
760 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;
761 rtt_resources[1].end = rtt_resources[1].start + 3;
762}
763#else
764static void __init at91_add_device_rtt_rtc(void)
765{
766 /* Only one resource is needed: RTT not used as RTC */
767 at91sam9260_rtt_device.num_resources = 1;
768}
769#endif
770
730static void __init at91_add_device_rtt(void) 771static void __init at91_add_device_rtt(void)
731{ 772{
773 at91_add_device_rtt_rtc();
732 platform_device_register(&at91sam9260_rtt_device); 774 platform_device_register(&at91sam9260_rtt_device);
733} 775}
734 776
@@ -1139,7 +1181,6 @@ static inline void configure_usart5_pins(void)
1139} 1181}
1140 1182
1141static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ 1183static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
1142struct platform_device *atmel_default_console_device; /* the serial console device */
1143 1184
1144void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) 1185void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
1145{ 1186{
@@ -1264,7 +1305,7 @@ void __init at91_add_device_cf(struct at91_cf_data *data)
1264 if (!data) 1305 if (!data)
1265 return; 1306 return;
1266 1307
1267 csa = at91_sys_read(AT91_MATRIX_EBICSA); 1308 csa = at91_matrix_read(AT91_MATRIX_EBICSA);
1268 1309
1269 switch (data->chipselect) { 1310 switch (data->chipselect) {
1270 case 4: 1311 case 4:
@@ -1287,7 +1328,7 @@ void __init at91_add_device_cf(struct at91_cf_data *data)
1287 return; 1328 return;
1288 } 1329 }
1289 1330
1290 at91_sys_write(AT91_MATRIX_EBICSA, csa); 1331 at91_matrix_write(AT91_MATRIX_EBICSA, csa);
1291 1332
1292 if (gpio_is_valid(data->rst_pin)) { 1333 if (gpio_is_valid(data->rst_pin)) {
1293 at91_set_multi_drive(data->rst_pin, 0); 1334 at91_set_multi_drive(data->rst_pin, 0);
diff --git a/arch/arm/mach-at91/at91sam9261.c b/arch/arm/mach-at91/at91sam9261.c
index 62818b956ae..7de81e6222f 100644
--- a/arch/arm/mach-at91/at91sam9261.c
+++ b/arch/arm/mach-at91/at91sam9261.c
@@ -12,6 +12,7 @@
12 12
13#include <linux/module.h> 13#include <linux/module.h>
14 14
15#include <asm/proc-fns.h>
15#include <asm/irq.h> 16#include <asm/irq.h>
16#include <asm/mach/arch.h> 17#include <asm/mach/arch.h>
17#include <asm/mach/map.h> 18#include <asm/mach/map.h>
@@ -283,12 +284,15 @@ static void __init at91sam9261_ioremap_registers(void)
283{ 284{
284 at91_ioremap_shdwc(AT91SAM9261_BASE_SHDWC); 285 at91_ioremap_shdwc(AT91SAM9261_BASE_SHDWC);
285 at91_ioremap_rstc(AT91SAM9261_BASE_RSTC); 286 at91_ioremap_rstc(AT91SAM9261_BASE_RSTC);
287 at91_ioremap_ramc(0, AT91SAM9261_BASE_SDRAMC, 512);
286 at91sam926x_ioremap_pit(AT91SAM9261_BASE_PIT); 288 at91sam926x_ioremap_pit(AT91SAM9261_BASE_PIT);
287 at91sam9_ioremap_smc(0, AT91SAM9261_BASE_SMC); 289 at91sam9_ioremap_smc(0, AT91SAM9261_BASE_SMC);
290 at91_ioremap_matrix(AT91SAM9261_BASE_MATRIX);
288} 291}
289 292
290static void __init at91sam9261_initialize(void) 293static void __init at91sam9261_initialize(void)
291{ 294{
295 arm_pm_idle = at91sam9_idle;
292 arm_pm_restart = at91sam9_alt_restart; 296 arm_pm_restart = at91sam9_alt_restart;
293 at91_extern_irq = (1 << AT91SAM9261_ID_IRQ0) | (1 << AT91SAM9261_ID_IRQ1) 297 at91_extern_irq = (1 << AT91SAM9261_ID_IRQ0) | (1 << AT91SAM9261_ID_IRQ1)
294 | (1 << AT91SAM9261_ID_IRQ2); 298 | (1 << AT91SAM9261_ID_IRQ2);
diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c
index 1e28bed8f42..096da87dc00 100644
--- a/arch/arm/mach-at91/at91sam9261_devices.c
+++ b/arch/arm/mach-at91/at91sam9261_devices.c
@@ -24,6 +24,7 @@
24#include <mach/board.h> 24#include <mach/board.h>
25#include <mach/at91sam9261.h> 25#include <mach/at91sam9261.h>
26#include <mach/at91sam9261_matrix.h> 26#include <mach/at91sam9261_matrix.h>
27#include <mach/at91_matrix.h>
27#include <mach/at91sam9_smc.h> 28#include <mach/at91sam9_smc.h>
28 29
29#include "generic.h" 30#include "generic.h"
@@ -236,8 +237,8 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)
236 if (!data) 237 if (!data)
237 return; 238 return;
238 239
239 csa = at91_sys_read(AT91_MATRIX_EBICSA); 240 csa = at91_matrix_read(AT91_MATRIX_EBICSA);
240 at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA); 241 at91_matrix_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA);
241 242
242 /* enable pin */ 243 /* enable pin */
243 if (gpio_is_valid(data->enable_pin)) 244 if (gpio_is_valid(data->enable_pin))
@@ -603,6 +604,8 @@ static struct resource rtt_resources[] = {
603 .start = AT91SAM9261_BASE_RTT, 604 .start = AT91SAM9261_BASE_RTT,
604 .end = AT91SAM9261_BASE_RTT + SZ_16 - 1, 605 .end = AT91SAM9261_BASE_RTT + SZ_16 - 1,
605 .flags = IORESOURCE_MEM, 606 .flags = IORESOURCE_MEM,
607 }, {
608 .flags = IORESOURCE_MEM,
606 } 609 }
607}; 610};
608 611
@@ -610,11 +613,32 @@ static struct platform_device at91sam9261_rtt_device = {
610 .name = "at91_rtt", 613 .name = "at91_rtt",
611 .id = 0, 614 .id = 0,
612 .resource = rtt_resources, 615 .resource = rtt_resources,
613 .num_resources = ARRAY_SIZE(rtt_resources),
614}; 616};
615 617
618#if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9)
619static void __init at91_add_device_rtt_rtc(void)
620{
621 at91sam9261_rtt_device.name = "rtc-at91sam9";
622 /*
623 * The second resource is needed:
624 * GPBR will serve as the storage for RTC time offset
625 */
626 at91sam9261_rtt_device.num_resources = 2;
627 rtt_resources[1].start = AT91SAM9261_BASE_GPBR +
628 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;
629 rtt_resources[1].end = rtt_resources[1].start + 3;
630}
631#else
632static void __init at91_add_device_rtt_rtc(void)
633{
634 /* Only one resource is needed: RTT not used as RTC */
635 at91sam9261_rtt_device.num_resources = 1;
636}
637#endif
638
616static void __init at91_add_device_rtt(void) 639static void __init at91_add_device_rtt(void)
617{ 640{
641 at91_add_device_rtt_rtc();
618 platform_device_register(&at91sam9261_rtt_device); 642 platform_device_register(&at91sam9261_rtt_device);
619} 643}
620 644
@@ -991,7 +1015,6 @@ static inline void configure_usart2_pins(unsigned pins)
991} 1015}
992 1016
993static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ 1017static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
994struct platform_device *atmel_default_console_device; /* the serial console device */
995 1018
996void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) 1019void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
997{ 1020{
diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c
index 722ee08e510..ef301be6657 100644
--- a/arch/arm/mach-at91/at91sam9263.c
+++ b/arch/arm/mach-at91/at91sam9263.c
@@ -12,6 +12,7 @@
12 12
13#include <linux/module.h> 13#include <linux/module.h>
14 14
15#include <asm/proc-fns.h>
15#include <asm/irq.h> 16#include <asm/irq.h>
16#include <asm/mach/arch.h> 17#include <asm/mach/arch.h>
17#include <asm/mach/map.h> 18#include <asm/mach/map.h>
@@ -303,13 +304,17 @@ static void __init at91sam9263_ioremap_registers(void)
303{ 304{
304 at91_ioremap_shdwc(AT91SAM9263_BASE_SHDWC); 305 at91_ioremap_shdwc(AT91SAM9263_BASE_SHDWC);
305 at91_ioremap_rstc(AT91SAM9263_BASE_RSTC); 306 at91_ioremap_rstc(AT91SAM9263_BASE_RSTC);
307 at91_ioremap_ramc(0, AT91SAM9263_BASE_SDRAMC0, 512);
308 at91_ioremap_ramc(1, AT91SAM9263_BASE_SDRAMC1, 512);
306 at91sam926x_ioremap_pit(AT91SAM9263_BASE_PIT); 309 at91sam926x_ioremap_pit(AT91SAM9263_BASE_PIT);
307 at91sam9_ioremap_smc(0, AT91SAM9263_BASE_SMC0); 310 at91sam9_ioremap_smc(0, AT91SAM9263_BASE_SMC0);
308 at91sam9_ioremap_smc(1, AT91SAM9263_BASE_SMC1); 311 at91sam9_ioremap_smc(1, AT91SAM9263_BASE_SMC1);
312 at91_ioremap_matrix(AT91SAM9263_BASE_MATRIX);
309} 313}
310 314
311static void __init at91sam9263_initialize(void) 315static void __init at91sam9263_initialize(void)
312{ 316{
317 arm_pm_idle = at91sam9_idle;
313 arm_pm_restart = at91sam9_alt_restart; 318 arm_pm_restart = at91sam9_alt_restart;
314 at91_extern_irq = (1 << AT91SAM9263_ID_IRQ0) | (1 << AT91SAM9263_ID_IRQ1); 319 at91_extern_irq = (1 << AT91SAM9263_ID_IRQ0) | (1 << AT91SAM9263_ID_IRQ1);
315 320
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
index 366a7765635..53688c46f95 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -23,6 +23,7 @@
23#include <mach/board.h> 23#include <mach/board.h>
24#include <mach/at91sam9263.h> 24#include <mach/at91sam9263.h>
25#include <mach/at91sam9263_matrix.h> 25#include <mach/at91sam9263_matrix.h>
26#include <mach/at91_matrix.h>
26#include <mach/at91sam9_smc.h> 27#include <mach/at91sam9_smc.h>
27 28
28#include "generic.h" 29#include "generic.h"
@@ -409,7 +410,7 @@ void __init at91_add_device_cf(struct at91_cf_data *data)
409 * we assume SMC timings are configured by board code, 410 * we assume SMC timings are configured by board code,
410 * except True IDE where timings are controlled by driver 411 * except True IDE where timings are controlled by driver
411 */ 412 */
412 ebi0_csa = at91_sys_read(AT91_MATRIX_EBI0CSA); 413 ebi0_csa = at91_matrix_read(AT91_MATRIX_EBI0CSA);
413 switch (data->chipselect) { 414 switch (data->chipselect) {
414 case 4: 415 case 4:
415 at91_set_A_periph(AT91_PIN_PD6, 0); /* EBI0_NCS4/CFCS0 */ 416 at91_set_A_periph(AT91_PIN_PD6, 0); /* EBI0_NCS4/CFCS0 */
@@ -428,7 +429,7 @@ void __init at91_add_device_cf(struct at91_cf_data *data)
428 data->chipselect); 429 data->chipselect);
429 return; 430 return;
430 } 431 }
431 at91_sys_write(AT91_MATRIX_EBI0CSA, ebi0_csa); 432 at91_matrix_write(AT91_MATRIX_EBI0CSA, ebi0_csa);
432 433
433 if (gpio_is_valid(data->det_pin)) { 434 if (gpio_is_valid(data->det_pin)) {
434 at91_set_gpio_input(data->det_pin, 1); 435 at91_set_gpio_input(data->det_pin, 1);
@@ -496,8 +497,8 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)
496 if (!data) 497 if (!data)
497 return; 498 return;
498 499
499 csa = at91_sys_read(AT91_MATRIX_EBI0CSA); 500 csa = at91_matrix_read(AT91_MATRIX_EBI0CSA);
500 at91_sys_write(AT91_MATRIX_EBI0CSA, csa | AT91_MATRIX_EBI0_CS3A_SMC_SMARTMEDIA); 501 at91_matrix_write(AT91_MATRIX_EBI0CSA, csa | AT91_MATRIX_EBI0_CS3A_SMC_SMARTMEDIA);
501 502
502 /* enable pin */ 503 /* enable pin */
503 if (gpio_is_valid(data->enable_pin)) 504 if (gpio_is_valid(data->enable_pin))
@@ -891,7 +892,8 @@ static struct platform_device at91sam9263_isi_device = {
891 .num_resources = ARRAY_SIZE(isi_resources), 892 .num_resources = ARRAY_SIZE(isi_resources),
892}; 893};
893 894
894void __init at91_add_device_isi(void) 895void __init at91_add_device_isi(struct isi_platform_data *data,
896 bool use_pck_as_mck)
895{ 897{
896 at91_set_A_periph(AT91_PIN_PE0, 0); /* ISI_D0 */ 898 at91_set_A_periph(AT91_PIN_PE0, 0); /* ISI_D0 */
897 at91_set_A_periph(AT91_PIN_PE1, 0); /* ISI_D1 */ 899 at91_set_A_periph(AT91_PIN_PE1, 0); /* ISI_D1 */
@@ -904,14 +906,20 @@ void __init at91_add_device_isi(void)
904 at91_set_A_periph(AT91_PIN_PE8, 0); /* ISI_PCK */ 906 at91_set_A_periph(AT91_PIN_PE8, 0); /* ISI_PCK */
905 at91_set_A_periph(AT91_PIN_PE9, 0); /* ISI_HSYNC */ 907 at91_set_A_periph(AT91_PIN_PE9, 0); /* ISI_HSYNC */
906 at91_set_A_periph(AT91_PIN_PE10, 0); /* ISI_VSYNC */ 908 at91_set_A_periph(AT91_PIN_PE10, 0); /* ISI_VSYNC */
907 at91_set_B_periph(AT91_PIN_PE11, 0); /* ISI_MCK (PCK3) */
908 at91_set_B_periph(AT91_PIN_PE12, 0); /* ISI_PD8 */ 909 at91_set_B_periph(AT91_PIN_PE12, 0); /* ISI_PD8 */
909 at91_set_B_periph(AT91_PIN_PE13, 0); /* ISI_PD9 */ 910 at91_set_B_periph(AT91_PIN_PE13, 0); /* ISI_PD9 */
910 at91_set_B_periph(AT91_PIN_PE14, 0); /* ISI_PD10 */ 911 at91_set_B_periph(AT91_PIN_PE14, 0); /* ISI_PD10 */
911 at91_set_B_periph(AT91_PIN_PE15, 0); /* ISI_PD11 */ 912 at91_set_B_periph(AT91_PIN_PE15, 0); /* ISI_PD11 */
913
914 if (use_pck_as_mck) {
915 at91_set_B_periph(AT91_PIN_PE11, 0); /* ISI_MCK (PCK3) */
916
917 /* TODO: register the PCK for ISI_MCK and set its parent */
918 }
912} 919}
913#else 920#else
914void __init at91_add_device_isi(void) {} 921void __init at91_add_device_isi(struct isi_platform_data *data,
922 bool use_pck_as_mck) {}
915#endif 923#endif
916 924
917 925
@@ -959,6 +967,8 @@ static struct resource rtt0_resources[] = {
959 .start = AT91SAM9263_BASE_RTT0, 967 .start = AT91SAM9263_BASE_RTT0,
960 .end = AT91SAM9263_BASE_RTT0 + SZ_16 - 1, 968 .end = AT91SAM9263_BASE_RTT0 + SZ_16 - 1,
961 .flags = IORESOURCE_MEM, 969 .flags = IORESOURCE_MEM,
970 }, {
971 .flags = IORESOURCE_MEM,
962 } 972 }
963}; 973};
964 974
@@ -966,7 +976,6 @@ static struct platform_device at91sam9263_rtt0_device = {
966 .name = "at91_rtt", 976 .name = "at91_rtt",
967 .id = 0, 977 .id = 0,
968 .resource = rtt0_resources, 978 .resource = rtt0_resources,
969 .num_resources = ARRAY_SIZE(rtt0_resources),
970}; 979};
971 980
972static struct resource rtt1_resources[] = { 981static struct resource rtt1_resources[] = {
@@ -974,6 +983,8 @@ static struct resource rtt1_resources[] = {
974 .start = AT91SAM9263_BASE_RTT1, 983 .start = AT91SAM9263_BASE_RTT1,
975 .end = AT91SAM9263_BASE_RTT1 + SZ_16 - 1, 984 .end = AT91SAM9263_BASE_RTT1 + SZ_16 - 1,
976 .flags = IORESOURCE_MEM, 985 .flags = IORESOURCE_MEM,
986 }, {
987 .flags = IORESOURCE_MEM,
977 } 988 }
978}; 989};
979 990
@@ -981,11 +992,53 @@ static struct platform_device at91sam9263_rtt1_device = {
981 .name = "at91_rtt", 992 .name = "at91_rtt",
982 .id = 1, 993 .id = 1,
983 .resource = rtt1_resources, 994 .resource = rtt1_resources,
984 .num_resources = ARRAY_SIZE(rtt1_resources),
985}; 995};
986 996
997#if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9)
998static void __init at91_add_device_rtt_rtc(void)
999{
1000 struct platform_device *pdev;
1001 struct resource *r;
1002
1003 switch (CONFIG_RTC_DRV_AT91SAM9_RTT) {
1004 case 0:
1005 /*
1006 * The second resource is needed only for the chosen RTT:
1007 * GPBR will serve as the storage for RTC time offset
1008 */
1009 at91sam9263_rtt0_device.num_resources = 2;
1010 at91sam9263_rtt1_device.num_resources = 1;
1011 pdev = &at91sam9263_rtt0_device;
1012 r = rtt0_resources;
1013 break;
1014 case 1:
1015 at91sam9263_rtt0_device.num_resources = 1;
1016 at91sam9263_rtt1_device.num_resources = 2;
1017 pdev = &at91sam9263_rtt1_device;
1018 r = rtt1_resources;
1019 break;
1020 default:
1021 pr_err("at91sam9263: only supports 2 RTT (%d)\n",
1022 CONFIG_RTC_DRV_AT91SAM9_RTT);
1023 return;
1024 }
1025
1026 pdev->name = "rtc-at91sam9";
1027 r[1].start = AT91SAM9263_BASE_GPBR + 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;
1028 r[1].end = r[1].start + 3;
1029}
1030#else
1031static void __init at91_add_device_rtt_rtc(void)
1032{
1033 /* Only one resource is needed: RTT not used as RTC */
1034 at91sam9263_rtt0_device.num_resources = 1;
1035 at91sam9263_rtt1_device.num_resources = 1;
1036}
1037#endif
1038
987static void __init at91_add_device_rtt(void) 1039static void __init at91_add_device_rtt(void)
988{ 1040{
1041 at91_add_device_rtt_rtc();
989 platform_device_register(&at91sam9263_rtt0_device); 1042 platform_device_register(&at91sam9263_rtt0_device);
990 platform_device_register(&at91sam9263_rtt1_device); 1043 platform_device_register(&at91sam9263_rtt1_device);
991} 1044}
@@ -1371,7 +1424,6 @@ static inline void configure_usart2_pins(unsigned pins)
1371} 1424}
1372 1425
1373static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ 1426static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
1374struct platform_device *atmel_default_console_device; /* the serial console device */
1375 1427
1376void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) 1428void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
1377{ 1429{
diff --git a/arch/arm/mach-at91/at91sam926x_time.c b/arch/arm/mach-at91/at91sam926x_time.c
index d89ead740a9..a94758b4273 100644
--- a/arch/arm/mach-at91/at91sam926x_time.c
+++ b/arch/arm/mach-at91/at91sam926x_time.c
@@ -14,6 +14,9 @@
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/clk.h> 15#include <linux/clk.h>
16#include <linux/clockchips.h> 16#include <linux/clockchips.h>
17#include <linux/of.h>
18#include <linux/of_address.h>
19#include <linux/of_irq.h>
17 20
18#include <asm/mach/time.h> 21#include <asm/mach/time.h>
19 22
@@ -133,7 +136,8 @@ static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id)
133static struct irqaction at91sam926x_pit_irq = { 136static struct irqaction at91sam926x_pit_irq = {
134 .name = "at91_tick", 137 .name = "at91_tick",
135 .flags = IRQF_SHARED | IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL, 138 .flags = IRQF_SHARED | IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
136 .handler = at91sam926x_pit_interrupt 139 .handler = at91sam926x_pit_interrupt,
140 .irq = AT91_ID_SYS,
137}; 141};
138 142
139static void at91sam926x_pit_reset(void) 143static void at91sam926x_pit_reset(void)
@@ -149,6 +153,51 @@ static void at91sam926x_pit_reset(void)
149 pit_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN); 153 pit_write(AT91_PIT_MR, (pit_cycle - 1) | AT91_PIT_PITEN);
150} 154}
151 155
156#ifdef CONFIG_OF
157static struct of_device_id pit_timer_ids[] = {
158 { .compatible = "atmel,at91sam9260-pit" },
159 { /* sentinel */ }
160};
161
162static int __init of_at91sam926x_pit_init(void)
163{
164 struct device_node *np;
165 int ret;
166
167 np = of_find_matching_node(NULL, pit_timer_ids);
168 if (!np)
169 goto err;
170
171 pit_base_addr = of_iomap(np, 0);
172 if (!pit_base_addr)
173 goto node_err;
174
175 /* Get the interrupts property */
176 ret = irq_of_parse_and_map(np, 0);
177 if (!ret) {
178 pr_crit("AT91: PIT: Unable to get IRQ from DT\n");
179 goto ioremap_err;
180 }
181 at91sam926x_pit_irq.irq = ret;
182
183 of_node_put(np);
184
185 return 0;
186
187ioremap_err:
188 iounmap(pit_base_addr);
189node_err:
190 of_node_put(np);
191err:
192 return -EINVAL;
193}
194#else
195static int __init of_at91sam926x_pit_init(void)
196{
197 return -EINVAL;
198}
199#endif
200
152/* 201/*
153 * Set up both clocksource and clockevent support. 202 * Set up both clocksource and clockevent support.
154 */ 203 */
@@ -156,6 +205,10 @@ static void __init at91sam926x_pit_init(void)
156{ 205{
157 unsigned long pit_rate; 206 unsigned long pit_rate;
158 unsigned bits; 207 unsigned bits;
208 int ret;
209
210 /* For device tree enabled device: initialize here */
211 of_at91sam926x_pit_init();
159 212
160 /* 213 /*
161 * Use our actual MCK to figure out how many MCK/16 ticks per 214 * Use our actual MCK to figure out how many MCK/16 ticks per
@@ -177,7 +230,9 @@ static void __init at91sam926x_pit_init(void)
177 clocksource_register_hz(&pit_clk, pit_rate); 230 clocksource_register_hz(&pit_clk, pit_rate);
178 231
179 /* Set up irq handler */ 232 /* Set up irq handler */
180 setup_irq(AT91_ID_SYS, &at91sam926x_pit_irq); 233 ret = setup_irq(at91sam926x_pit_irq.irq, &at91sam926x_pit_irq);
234 if (ret)
235 pr_crit("AT91: PIT: Unable to setup IRQ\n");
181 236
182 /* Set up and register clockevents */ 237 /* Set up and register clockevents */
183 pit_clkevt.mult = div_sc(pit_rate, NSEC_PER_SEC, pit_clkevt.shift); 238 pit_clkevt.mult = div_sc(pit_rate, NSEC_PER_SEC, pit_clkevt.shift);
@@ -193,6 +248,15 @@ static void at91sam926x_pit_suspend(void)
193 248
194void __init at91sam926x_ioremap_pit(u32 addr) 249void __init at91sam926x_ioremap_pit(u32 addr)
195{ 250{
251#if defined(CONFIG_OF)
252 struct device_node *np =
253 of_find_matching_node(NULL, pit_timer_ids);
254
255 if (np) {
256 of_node_put(np);
257 return;
258 }
259#endif
196 pit_base_addr = ioremap(addr, 16); 260 pit_base_addr = ioremap(addr, 16);
197 261
198 if (!pit_base_addr) 262 if (!pit_base_addr)
diff --git a/arch/arm/mach-at91/at91sam9_alt_reset.S b/arch/arm/mach-at91/at91sam9_alt_reset.S
index 518e4237717..7af2e108b8a 100644
--- a/arch/arm/mach-at91/at91sam9_alt_reset.S
+++ b/arch/arm/mach-at91/at91sam9_alt_reset.S
@@ -15,16 +15,17 @@
15 15
16#include <linux/linkage.h> 16#include <linux/linkage.h>
17#include <mach/hardware.h> 17#include <mach/hardware.h>
18#include <mach/at91sam9_sdramc.h> 18#include <mach/at91_ramc.h>
19#include <mach/at91_rstc.h> 19#include <mach/at91_rstc.h>
20 20
21 .arm 21 .arm
22 22
23 .globl at91sam9_alt_restart 23 .globl at91sam9_alt_restart
24 24
25at91sam9_alt_restart: ldr r0, .at91_va_base_sdramc @ preload constants 25at91sam9_alt_restart: ldr r0, =at91_ramc_base @ preload constants
26 ldr r1, =at91_rstc_base 26 ldr r0, [r0]
27 ldr r1, [r1] 27 ldr r4, =at91_rstc_base
28 ldr r1, [r4]
28 29
29 mov r2, #1 30 mov r2, #1
30 mov r3, #AT91_SDRAMC_LPCB_POWER_DOWN 31 mov r3, #AT91_SDRAMC_LPCB_POWER_DOWN
@@ -37,6 +38,3 @@ at91sam9_alt_restart: ldr r0, .at91_va_base_sdramc @ preload constants
37 str r4, [r1, #AT91_RSTC_CR] @ reset processor 38 str r4, [r1, #AT91_RSTC_CR] @ reset processor
38 39
39 b . 40 b .
40
41.at91_va_base_sdramc:
42 .word AT91_VA_BASE_SYS + AT91_SDRAMC0
diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c
index 47e8fdbed9c..d222f8333da 100644
--- a/arch/arm/mach-at91/at91sam9g45.c
+++ b/arch/arm/mach-at91/at91sam9g45.c
@@ -230,6 +230,11 @@ static struct clk_lookup periph_clocks_lookups[] = {
230 CLKDEV_CON_DEV_ID("usart", "fff90000.serial", &usart1_clk), 230 CLKDEV_CON_DEV_ID("usart", "fff90000.serial", &usart1_clk),
231 CLKDEV_CON_DEV_ID("usart", "fff94000.serial", &usart2_clk), 231 CLKDEV_CON_DEV_ID("usart", "fff94000.serial", &usart2_clk),
232 CLKDEV_CON_DEV_ID("usart", "fff98000.serial", &usart3_clk), 232 CLKDEV_CON_DEV_ID("usart", "fff98000.serial", &usart3_clk),
233 /* more tc lookup table for DT entries */
234 CLKDEV_CON_DEV_ID("t0_clk", "fff7c000.timer", &tcb0_clk),
235 CLKDEV_CON_DEV_ID("t0_clk", "fffd4000.timer", &tcb0_clk),
236 CLKDEV_CON_DEV_ID("hclk", "700000.ohci", &uhphs_clk),
237 CLKDEV_CON_DEV_ID("ehci_clk", "800000.ehci", &uhphs_clk),
233 /* fake hclk clock */ 238 /* fake hclk clock */
234 CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &uhphs_clk), 239 CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &uhphs_clk),
235 CLKDEV_CON_ID("pioA", &pioA_clk), 240 CLKDEV_CON_ID("pioA", &pioA_clk),
@@ -332,12 +337,16 @@ static void __init at91sam9g45_ioremap_registers(void)
332{ 337{
333 at91_ioremap_shdwc(AT91SAM9G45_BASE_SHDWC); 338 at91_ioremap_shdwc(AT91SAM9G45_BASE_SHDWC);
334 at91_ioremap_rstc(AT91SAM9G45_BASE_RSTC); 339 at91_ioremap_rstc(AT91SAM9G45_BASE_RSTC);
340 at91_ioremap_ramc(0, AT91SAM9G45_BASE_DDRSDRC1, 512);
341 at91_ioremap_ramc(1, AT91SAM9G45_BASE_DDRSDRC0, 512);
335 at91sam926x_ioremap_pit(AT91SAM9G45_BASE_PIT); 342 at91sam926x_ioremap_pit(AT91SAM9G45_BASE_PIT);
336 at91sam9_ioremap_smc(0, AT91SAM9G45_BASE_SMC); 343 at91sam9_ioremap_smc(0, AT91SAM9G45_BASE_SMC);
344 at91_ioremap_matrix(AT91SAM9G45_BASE_MATRIX);
337} 345}
338 346
339static void __init at91sam9g45_initialize(void) 347static void __init at91sam9g45_initialize(void)
340{ 348{
349 arm_pm_idle = at91sam9_idle;
341 arm_pm_restart = at91sam9g45_restart; 350 arm_pm_restart = at91sam9g45_restart;
342 at91_extern_irq = (1 << AT91SAM9G45_ID_IRQ0); 351 at91_extern_irq = (1 << AT91SAM9G45_ID_IRQ0);
343 352
diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c
index 96e2adcd5a8..4320b209678 100644
--- a/arch/arm/mach-at91/at91sam9g45_devices.c
+++ b/arch/arm/mach-at91/at91sam9g45_devices.c
@@ -14,6 +14,7 @@
14 14
15#include <linux/dma-mapping.h> 15#include <linux/dma-mapping.h>
16#include <linux/gpio.h> 16#include <linux/gpio.h>
17#include <linux/clk.h>
17#include <linux/platform_device.h> 18#include <linux/platform_device.h>
18#include <linux/i2c-gpio.h> 19#include <linux/i2c-gpio.h>
19#include <linux/atmel-mci.h> 20#include <linux/atmel-mci.h>
@@ -24,11 +25,15 @@
24#include <mach/board.h> 25#include <mach/board.h>
25#include <mach/at91sam9g45.h> 26#include <mach/at91sam9g45.h>
26#include <mach/at91sam9g45_matrix.h> 27#include <mach/at91sam9g45_matrix.h>
28#include <mach/at91_matrix.h>
27#include <mach/at91sam9_smc.h> 29#include <mach/at91sam9_smc.h>
28#include <mach/at_hdmac.h> 30#include <mach/at_hdmac.h>
29#include <mach/atmel-mci.h> 31#include <mach/atmel-mci.h>
30 32
33#include <media/atmel-isi.h>
34
31#include "generic.h" 35#include "generic.h"
36#include "clock.h"
32 37
33 38
34/* -------------------------------------------------------------------- 39/* --------------------------------------------------------------------
@@ -553,8 +558,8 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)
553 if (!data) 558 if (!data)
554 return; 559 return;
555 560
556 csa = at91_sys_read(AT91_MATRIX_EBICSA); 561 csa = at91_matrix_read(AT91_MATRIX_EBICSA);
557 at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_EBI_CS3A_SMC_SMARTMEDIA); 562 at91_matrix_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_EBI_CS3A_SMC_SMARTMEDIA);
558 563
559 /* enable pin */ 564 /* enable pin */
560 if (gpio_is_valid(data->enable_pin)) 565 if (gpio_is_valid(data->enable_pin))
@@ -870,6 +875,96 @@ void __init at91_add_device_ac97(struct ac97c_platform_data *data)
870void __init at91_add_device_ac97(struct ac97c_platform_data *data) {} 875void __init at91_add_device_ac97(struct ac97c_platform_data *data) {}
871#endif 876#endif
872 877
878/* --------------------------------------------------------------------
879 * Image Sensor Interface
880 * -------------------------------------------------------------------- */
881#if defined(CONFIG_VIDEO_ATMEL_ISI) || defined(CONFIG_VIDEO_ATMEL_ISI_MODULE)
882static u64 isi_dmamask = DMA_BIT_MASK(32);
883static struct isi_platform_data isi_data;
884
885struct resource isi_resources[] = {
886 [0] = {
887 .start = AT91SAM9G45_BASE_ISI,
888 .end = AT91SAM9G45_BASE_ISI + SZ_16K - 1,
889 .flags = IORESOURCE_MEM,
890 },
891 [1] = {
892 .start = AT91SAM9G45_ID_ISI,
893 .end = AT91SAM9G45_ID_ISI,
894 .flags = IORESOURCE_IRQ,
895 },
896};
897
898static struct platform_device at91sam9g45_isi_device = {
899 .name = "atmel_isi",
900 .id = 0,
901 .dev = {
902 .dma_mask = &isi_dmamask,
903 .coherent_dma_mask = DMA_BIT_MASK(32),
904 .platform_data = &isi_data,
905 },
906 .resource = isi_resources,
907 .num_resources = ARRAY_SIZE(isi_resources),
908};
909
910static struct clk_lookup isi_mck_lookups[] = {
911 CLKDEV_CON_DEV_ID("isi_mck", "atmel_isi.0", NULL),
912};
913
914void __init at91_add_device_isi(struct isi_platform_data *data,
915 bool use_pck_as_mck)
916{
917 struct clk *pck;
918 struct clk *parent;
919
920 if (!data)
921 return;
922 isi_data = *data;
923
924 at91_set_A_periph(AT91_PIN_PB20, 0); /* ISI_D0 */
925 at91_set_A_periph(AT91_PIN_PB21, 0); /* ISI_D1 */
926 at91_set_A_periph(AT91_PIN_PB22, 0); /* ISI_D2 */
927 at91_set_A_periph(AT91_PIN_PB23, 0); /* ISI_D3 */
928 at91_set_A_periph(AT91_PIN_PB24, 0); /* ISI_D4 */
929 at91_set_A_periph(AT91_PIN_PB25, 0); /* ISI_D5 */
930 at91_set_A_periph(AT91_PIN_PB26, 0); /* ISI_D6 */
931 at91_set_A_periph(AT91_PIN_PB27, 0); /* ISI_D7 */
932 at91_set_A_periph(AT91_PIN_PB28, 0); /* ISI_PCK */
933 at91_set_A_periph(AT91_PIN_PB30, 0); /* ISI_HSYNC */
934 at91_set_A_periph(AT91_PIN_PB29, 0); /* ISI_VSYNC */
935 at91_set_B_periph(AT91_PIN_PB8, 0); /* ISI_PD8 */
936 at91_set_B_periph(AT91_PIN_PB9, 0); /* ISI_PD9 */
937 at91_set_B_periph(AT91_PIN_PB10, 0); /* ISI_PD10 */
938 at91_set_B_periph(AT91_PIN_PB11, 0); /* ISI_PD11 */
939
940 platform_device_register(&at91sam9g45_isi_device);
941
942 if (use_pck_as_mck) {
943 at91_set_B_periph(AT91_PIN_PB31, 0); /* ISI_MCK (PCK1) */
944
945 pck = clk_get(NULL, "pck1");
946 parent = clk_get(NULL, "plla");
947
948 BUG_ON(IS_ERR(pck) || IS_ERR(parent));
949
950 if (clk_set_parent(pck, parent)) {
951 pr_err("Failed to set PCK's parent\n");
952 } else {
953 /* Register PCK as ISI_MCK */
954 isi_mck_lookups[0].clk = pck;
955 clkdev_add_table(isi_mck_lookups,
956 ARRAY_SIZE(isi_mck_lookups));
957 }
958
959 clk_put(pck);
960 clk_put(parent);
961 }
962}
963#else
964void __init at91_add_device_isi(struct isi_platform_data *data,
965 bool use_pck_as_mck) {}
966#endif
967
873 968
874/* -------------------------------------------------------------------- 969/* --------------------------------------------------------------------
875 * LCD Controller 970 * LCD Controller
@@ -957,7 +1052,7 @@ void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {}
957static struct resource tcb0_resources[] = { 1052static struct resource tcb0_resources[] = {
958 [0] = { 1053 [0] = {
959 .start = AT91SAM9G45_BASE_TCB0, 1054 .start = AT91SAM9G45_BASE_TCB0,
960 .end = AT91SAM9G45_BASE_TCB0 + SZ_16K - 1, 1055 .end = AT91SAM9G45_BASE_TCB0 + SZ_256 - 1,
961 .flags = IORESOURCE_MEM, 1056 .flags = IORESOURCE_MEM,
962 }, 1057 },
963 [1] = { 1058 [1] = {
@@ -978,7 +1073,7 @@ static struct platform_device at91sam9g45_tcb0_device = {
978static struct resource tcb1_resources[] = { 1073static struct resource tcb1_resources[] = {
979 [0] = { 1074 [0] = {
980 .start = AT91SAM9G45_BASE_TCB1, 1075 .start = AT91SAM9G45_BASE_TCB1,
981 .end = AT91SAM9G45_BASE_TCB1 + SZ_16K - 1, 1076 .end = AT91SAM9G45_BASE_TCB1 + SZ_256 - 1,
982 .flags = IORESOURCE_MEM, 1077 .flags = IORESOURCE_MEM,
983 }, 1078 },
984 [1] = { 1079 [1] = {
@@ -995,8 +1090,25 @@ static struct platform_device at91sam9g45_tcb1_device = {
995 .num_resources = ARRAY_SIZE(tcb1_resources), 1090 .num_resources = ARRAY_SIZE(tcb1_resources),
996}; 1091};
997 1092
1093#if defined(CONFIG_OF)
1094static struct of_device_id tcb_ids[] = {
1095 { .compatible = "atmel,at91rm9200-tcb" },
1096 { /*sentinel*/ }
1097};
1098#endif
1099
998static void __init at91_add_device_tc(void) 1100static void __init at91_add_device_tc(void)
999{ 1101{
1102#if defined(CONFIG_OF)
1103 struct device_node *np;
1104
1105 np = of_find_matching_node(NULL, tcb_ids);
1106 if (np) {
1107 of_node_put(np);
1108 return;
1109 }
1110#endif
1111
1000 platform_device_register(&at91sam9g45_tcb0_device); 1112 platform_device_register(&at91sam9g45_tcb0_device);
1001 platform_device_register(&at91sam9g45_tcb1_device); 1113 platform_device_register(&at91sam9g45_tcb1_device);
1002} 1114}
@@ -1099,6 +1211,8 @@ static struct resource rtt_resources[] = {
1099 .start = AT91SAM9G45_BASE_RTT, 1211 .start = AT91SAM9G45_BASE_RTT,
1100 .end = AT91SAM9G45_BASE_RTT + SZ_16 - 1, 1212 .end = AT91SAM9G45_BASE_RTT + SZ_16 - 1,
1101 .flags = IORESOURCE_MEM, 1213 .flags = IORESOURCE_MEM,
1214 }, {
1215 .flags = IORESOURCE_MEM,
1102 } 1216 }
1103}; 1217};
1104 1218
@@ -1106,11 +1220,32 @@ static struct platform_device at91sam9g45_rtt_device = {
1106 .name = "at91_rtt", 1220 .name = "at91_rtt",
1107 .id = 0, 1221 .id = 0,
1108 .resource = rtt_resources, 1222 .resource = rtt_resources,
1109 .num_resources = ARRAY_SIZE(rtt_resources),
1110}; 1223};
1111 1224
1225#if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9)
1226static void __init at91_add_device_rtt_rtc(void)
1227{
1228 at91sam9g45_rtt_device.name = "rtc-at91sam9";
1229 /*
1230 * The second resource is needed:
1231 * GPBR will serve as the storage for RTC time offset
1232 */
1233 at91sam9g45_rtt_device.num_resources = 2;
1234 rtt_resources[1].start = AT91SAM9G45_BASE_GPBR +
1235 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;
1236 rtt_resources[1].end = rtt_resources[1].start + 3;
1237}
1238#else
1239static void __init at91_add_device_rtt_rtc(void)
1240{
1241 /* Only one resource is needed: RTT not used as RTC */
1242 at91sam9g45_rtt_device.num_resources = 1;
1243}
1244#endif
1245
1112static void __init at91_add_device_rtt(void) 1246static void __init at91_add_device_rtt(void)
1113{ 1247{
1248 at91_add_device_rtt_rtc();
1114 platform_device_register(&at91sam9g45_rtt_device); 1249 platform_device_register(&at91sam9g45_rtt_device);
1115} 1250}
1116 1251
@@ -1565,7 +1700,6 @@ static inline void configure_usart3_pins(unsigned pins)
1565} 1700}
1566 1701
1567static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ 1702static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
1568struct platform_device *atmel_default_console_device; /* the serial console device */
1569 1703
1570void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) 1704void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
1571{ 1705{
diff --git a/arch/arm/mach-at91/at91sam9g45_reset.S b/arch/arm/mach-at91/at91sam9g45_reset.S
index 0468be10980..9d457182c86 100644
--- a/arch/arm/mach-at91/at91sam9g45_reset.S
+++ b/arch/arm/mach-at91/at91sam9g45_reset.S
@@ -12,7 +12,7 @@
12 12
13#include <linux/linkage.h> 13#include <linux/linkage.h>
14#include <mach/hardware.h> 14#include <mach/hardware.h>
15#include <mach/at91sam9_ddrsdr.h> 15#include <mach/at91_ramc.h>
16#include <mach/at91_rstc.h> 16#include <mach/at91_rstc.h>
17 17
18 .arm 18 .arm
@@ -20,9 +20,10 @@
20 .globl at91sam9g45_restart 20 .globl at91sam9g45_restart
21 21
22at91sam9g45_restart: 22at91sam9g45_restart:
23 ldr r0, .at91_va_base_sdramc0 @ preload constants 23 ldr r5, =at91_ramc_base @ preload constants
24 ldr r1, =at91_rstc_base 24 ldr r0, [r5]
25 ldr r1, [r1] 25 ldr r4, =at91_rstc_base
26 ldr r1, [r4]
26 27
27 mov r2, #1 28 mov r2, #1
28 mov r3, #AT91_DDRSDRC_LPCB_POWER_DOWN 29 mov r3, #AT91_DDRSDRC_LPCB_POWER_DOWN
@@ -35,6 +36,3 @@ at91sam9g45_restart:
35 str r4, [r1, #AT91_RSTC_CR] @ reset processor 36 str r4, [r1, #AT91_RSTC_CR] @ reset processor
36 37
37 b . 38 b .
38
39.at91_va_base_sdramc0:
40 .word AT91_VA_BASE_SYS + AT91_DDRSDRC0
diff --git a/arch/arm/mach-at91/at91sam9rl.c b/arch/arm/mach-at91/at91sam9rl.c
index 7ae499359d3..d9f2774f385 100644
--- a/arch/arm/mach-at91/at91sam9rl.c
+++ b/arch/arm/mach-at91/at91sam9rl.c
@@ -11,6 +11,7 @@
11 11
12#include <linux/module.h> 12#include <linux/module.h>
13 13
14#include <asm/proc-fns.h>
14#include <asm/irq.h> 15#include <asm/irq.h>
15#include <asm/mach/arch.h> 16#include <asm/mach/arch.h>
16#include <asm/mach/map.h> 17#include <asm/mach/map.h>
@@ -288,12 +289,15 @@ static void __init at91sam9rl_ioremap_registers(void)
288{ 289{
289 at91_ioremap_shdwc(AT91SAM9RL_BASE_SHDWC); 290 at91_ioremap_shdwc(AT91SAM9RL_BASE_SHDWC);
290 at91_ioremap_rstc(AT91SAM9RL_BASE_RSTC); 291 at91_ioremap_rstc(AT91SAM9RL_BASE_RSTC);
292 at91_ioremap_ramc(0, AT91SAM9RL_BASE_SDRAMC, 512);
291 at91sam926x_ioremap_pit(AT91SAM9RL_BASE_PIT); 293 at91sam926x_ioremap_pit(AT91SAM9RL_BASE_PIT);
292 at91sam9_ioremap_smc(0, AT91SAM9RL_BASE_SMC); 294 at91sam9_ioremap_smc(0, AT91SAM9RL_BASE_SMC);
295 at91_ioremap_matrix(AT91SAM9RL_BASE_MATRIX);
293} 296}
294 297
295static void __init at91sam9rl_initialize(void) 298static void __init at91sam9rl_initialize(void)
296{ 299{
300 arm_pm_idle = at91sam9_idle;
297 arm_pm_restart = at91sam9_alt_restart; 301 arm_pm_restart = at91sam9_alt_restart;
298 at91_extern_irq = (1 << AT91SAM9RL_ID_IRQ0); 302 at91_extern_irq = (1 << AT91SAM9RL_ID_IRQ0);
299 303
diff --git a/arch/arm/mach-at91/at91sam9rl_devices.c b/arch/arm/mach-at91/at91sam9rl_devices.c
index 9be71c11d0f..eda72e83037 100644
--- a/arch/arm/mach-at91/at91sam9rl_devices.c
+++ b/arch/arm/mach-at91/at91sam9rl_devices.c
@@ -20,6 +20,7 @@
20#include <mach/board.h> 20#include <mach/board.h>
21#include <mach/at91sam9rl.h> 21#include <mach/at91sam9rl.h>
22#include <mach/at91sam9rl_matrix.h> 22#include <mach/at91sam9rl_matrix.h>
23#include <mach/at91_matrix.h>
23#include <mach/at91sam9_smc.h> 24#include <mach/at91sam9_smc.h>
24#include <mach/at_hdmac.h> 25#include <mach/at_hdmac.h>
25 26
@@ -265,8 +266,8 @@ void __init at91_add_device_nand(struct atmel_nand_data *data)
265 if (!data) 266 if (!data)
266 return; 267 return;
267 268
268 csa = at91_sys_read(AT91_MATRIX_EBICSA); 269 csa = at91_matrix_read(AT91_MATRIX_EBICSA);
269 at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA); 270 at91_matrix_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA);
270 271
271 /* enable pin */ 272 /* enable pin */
272 if (gpio_is_valid(data->enable_pin)) 273 if (gpio_is_valid(data->enable_pin))
@@ -682,6 +683,8 @@ static struct resource rtt_resources[] = {
682 .start = AT91SAM9RL_BASE_RTT, 683 .start = AT91SAM9RL_BASE_RTT,
683 .end = AT91SAM9RL_BASE_RTT + SZ_16 - 1, 684 .end = AT91SAM9RL_BASE_RTT + SZ_16 - 1,
684 .flags = IORESOURCE_MEM, 685 .flags = IORESOURCE_MEM,
686 }, {
687 .flags = IORESOURCE_MEM,
685 } 688 }
686}; 689};
687 690
@@ -689,11 +692,32 @@ static struct platform_device at91sam9rl_rtt_device = {
689 .name = "at91_rtt", 692 .name = "at91_rtt",
690 .id = 0, 693 .id = 0,
691 .resource = rtt_resources, 694 .resource = rtt_resources,
692 .num_resources = ARRAY_SIZE(rtt_resources),
693}; 695};
694 696
697#if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9)
698static void __init at91_add_device_rtt_rtc(void)
699{
700 at91sam9rl_rtt_device.name = "rtc-at91sam9";
701 /*
702 * The second resource is needed:
703 * GPBR will serve as the storage for RTC time offset
704 */
705 at91sam9rl_rtt_device.num_resources = 2;
706 rtt_resources[1].start = AT91SAM9RL_BASE_GPBR +
707 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;
708 rtt_resources[1].end = rtt_resources[1].start + 3;
709}
710#else
711static void __init at91_add_device_rtt_rtc(void)
712{
713 /* Only one resource is needed: RTT not used as RTC */
714 at91sam9rl_rtt_device.num_resources = 1;
715}
716#endif
717
695static void __init at91_add_device_rtt(void) 718static void __init at91_add_device_rtt(void)
696{ 719{
720 at91_add_device_rtt_rtc();
697 platform_device_register(&at91sam9rl_rtt_device); 721 platform_device_register(&at91sam9rl_rtt_device);
698} 722}
699 723
@@ -1128,7 +1152,6 @@ static inline void configure_usart3_pins(unsigned pins)
1128} 1152}
1129 1153
1130static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ 1154static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
1131struct platform_device *atmel_default_console_device; /* the serial console device */
1132 1155
1133void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) 1156void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
1134{ 1157{
diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c
new file mode 100644
index 00000000000..b6831eeb7b7
--- /dev/null
+++ b/arch/arm/mach-at91/at91sam9x5.c
@@ -0,0 +1,359 @@
1/*
2 * Chip-specific setup code for the AT91SAM9x5 family
3 *
4 * Copyright (C) 2010-2012 Atmel Corporation.
5 *
6 * Licensed under GPLv2 or later.
7 */
8
9#include <linux/module.h>
10#include <linux/dma-mapping.h>
11
12#include <asm/irq.h>
13#include <asm/mach/arch.h>
14#include <asm/mach/map.h>
15#include <mach/at91sam9x5.h>
16#include <mach/at91_pmc.h>
17#include <mach/cpu.h>
18#include <mach/board.h>
19
20#include "soc.h"
21#include "generic.h"
22#include "clock.h"
23#include "sam9_smc.h"
24
25/* --------------------------------------------------------------------
26 * Clocks
27 * -------------------------------------------------------------------- */
28
29/*
30 * The peripheral clocks.
31 */
32static struct clk pioAB_clk = {
33 .name = "pioAB_clk",
34 .pmc_mask = 1 << AT91SAM9X5_ID_PIOAB,
35 .type = CLK_TYPE_PERIPHERAL,
36};
37static struct clk pioCD_clk = {
38 .name = "pioCD_clk",
39 .pmc_mask = 1 << AT91SAM9X5_ID_PIOCD,
40 .type = CLK_TYPE_PERIPHERAL,
41};
42static struct clk smd_clk = {
43 .name = "smd_clk",
44 .pmc_mask = 1 << AT91SAM9X5_ID_SMD,
45 .type = CLK_TYPE_PERIPHERAL,
46};
47static struct clk usart0_clk = {
48 .name = "usart0_clk",
49 .pmc_mask = 1 << AT91SAM9X5_ID_USART0,
50 .type = CLK_TYPE_PERIPHERAL,
51};
52static struct clk usart1_clk = {
53 .name = "usart1_clk",
54 .pmc_mask = 1 << AT91SAM9X5_ID_USART1,
55 .type = CLK_TYPE_PERIPHERAL,
56};
57static struct clk usart2_clk = {
58 .name = "usart2_clk",
59 .pmc_mask = 1 << AT91SAM9X5_ID_USART2,
60 .type = CLK_TYPE_PERIPHERAL,
61};
62/* USART3 clock - Only for sam9g25/sam9x25 */
63static struct clk usart3_clk = {
64 .name = "usart3_clk",
65 .pmc_mask = 1 << AT91SAM9X5_ID_USART3,
66 .type = CLK_TYPE_PERIPHERAL,
67};
68static struct clk twi0_clk = {
69 .name = "twi0_clk",
70 .pmc_mask = 1 << AT91SAM9X5_ID_TWI0,
71 .type = CLK_TYPE_PERIPHERAL,
72};
73static struct clk twi1_clk = {
74 .name = "twi1_clk",
75 .pmc_mask = 1 << AT91SAM9X5_ID_TWI1,
76 .type = CLK_TYPE_PERIPHERAL,
77};
78static struct clk twi2_clk = {
79 .name = "twi2_clk",
80 .pmc_mask = 1 << AT91SAM9X5_ID_TWI2,
81 .type = CLK_TYPE_PERIPHERAL,
82};
83static struct clk mmc0_clk = {
84 .name = "mci0_clk",
85 .pmc_mask = 1 << AT91SAM9X5_ID_MCI0,
86 .type = CLK_TYPE_PERIPHERAL,
87};
88static struct clk spi0_clk = {
89 .name = "spi0_clk",
90 .pmc_mask = 1 << AT91SAM9X5_ID_SPI0,
91 .type = CLK_TYPE_PERIPHERAL,
92};
93static struct clk spi1_clk = {
94 .name = "spi1_clk",
95 .pmc_mask = 1 << AT91SAM9X5_ID_SPI1,
96 .type = CLK_TYPE_PERIPHERAL,
97};
98static struct clk uart0_clk = {
99 .name = "uart0_clk",
100 .pmc_mask = 1 << AT91SAM9X5_ID_UART0,
101 .type = CLK_TYPE_PERIPHERAL,
102};
103static struct clk uart1_clk = {
104 .name = "uart1_clk",
105 .pmc_mask = 1 << AT91SAM9X5_ID_UART1,
106 .type = CLK_TYPE_PERIPHERAL,
107};
108static struct clk tcb0_clk = {
109 .name = "tcb0_clk",
110 .pmc_mask = 1 << AT91SAM9X5_ID_TCB,
111 .type = CLK_TYPE_PERIPHERAL,
112};
113static struct clk pwm_clk = {
114 .name = "pwm_clk",
115 .pmc_mask = 1 << AT91SAM9X5_ID_PWM,
116 .type = CLK_TYPE_PERIPHERAL,
117};
118static struct clk adc_clk = {
119 .name = "adc_clk",
120 .pmc_mask = 1 << AT91SAM9X5_ID_ADC,
121 .type = CLK_TYPE_PERIPHERAL,
122};
123static struct clk dma0_clk = {
124 .name = "dma0_clk",
125 .pmc_mask = 1 << AT91SAM9X5_ID_DMA0,
126 .type = CLK_TYPE_PERIPHERAL,
127};
128static struct clk dma1_clk = {
129 .name = "dma1_clk",
130 .pmc_mask = 1 << AT91SAM9X5_ID_DMA1,
131 .type = CLK_TYPE_PERIPHERAL,
132};
133static struct clk uhphs_clk = {
134 .name = "uhphs",
135 .pmc_mask = 1 << AT91SAM9X5_ID_UHPHS,
136 .type = CLK_TYPE_PERIPHERAL,
137};
138static struct clk udphs_clk = {
139 .name = "udphs_clk",
140 .pmc_mask = 1 << AT91SAM9X5_ID_UDPHS,
141 .type = CLK_TYPE_PERIPHERAL,
142};
143/* emac0 clock - Only for sam9g25/sam9x25/sam9g35/sam9x35 */
144static struct clk macb0_clk = {
145 .name = "pclk",
146 .pmc_mask = 1 << AT91SAM9X5_ID_EMAC0,
147 .type = CLK_TYPE_PERIPHERAL,
148};
149/* lcd clock - Only for sam9g15/sam9g35/sam9x35 */
150static struct clk lcdc_clk = {
151 .name = "lcdc_clk",
152 .pmc_mask = 1 << AT91SAM9X5_ID_LCDC,
153 .type = CLK_TYPE_PERIPHERAL,
154};
155/* isi clock - Only for sam9g25 */
156static struct clk isi_clk = {
157 .name = "isi_clk",
158 .pmc_mask = 1 << AT91SAM9X5_ID_ISI,
159 .type = CLK_TYPE_PERIPHERAL,
160};
161static struct clk mmc1_clk = {
162 .name = "mci1_clk",
163 .pmc_mask = 1 << AT91SAM9X5_ID_MCI1,
164 .type = CLK_TYPE_PERIPHERAL,
165};
166/* emac1 clock - Only for sam9x25 */
167static struct clk macb1_clk = {
168 .name = "pclk",
169 .pmc_mask = 1 << AT91SAM9X5_ID_EMAC1,
170 .type = CLK_TYPE_PERIPHERAL,
171};
172static struct clk ssc_clk = {
173 .name = "ssc_clk",
174 .pmc_mask = 1 << AT91SAM9X5_ID_SSC,
175 .type = CLK_TYPE_PERIPHERAL,
176};
177/* can0 clock - Only for sam9x35 */
178static struct clk can0_clk = {
179 .name = "can0_clk",
180 .pmc_mask = 1 << AT91SAM9X5_ID_CAN0,
181 .type = CLK_TYPE_PERIPHERAL,
182};
183/* can1 clock - Only for sam9x35 */
184static struct clk can1_clk = {
185 .name = "can1_clk",
186 .pmc_mask = 1 << AT91SAM9X5_ID_CAN1,
187 .type = CLK_TYPE_PERIPHERAL,
188};
189
190static struct clk *periph_clocks[] __initdata = {
191 &pioAB_clk,
192 &pioCD_clk,
193 &smd_clk,
194 &usart0_clk,
195 &usart1_clk,
196 &usart2_clk,
197 &twi0_clk,
198 &twi1_clk,
199 &twi2_clk,
200 &mmc0_clk,
201 &spi0_clk,
202 &spi1_clk,
203 &uart0_clk,
204 &uart1_clk,
205 &tcb0_clk,
206 &pwm_clk,
207 &adc_clk,
208 &dma0_clk,
209 &dma1_clk,
210 &uhphs_clk,
211 &udphs_clk,
212 &mmc1_clk,
213 &ssc_clk,
214 // irq0
215};
216
217static struct clk_lookup periph_clocks_lookups[] = {
218 /* lookup table for DT entries */
219 CLKDEV_CON_DEV_ID("usart", "fffff200.serial", &mck),
220 CLKDEV_CON_DEV_ID("usart", "f801c000.serial", &usart0_clk),
221 CLKDEV_CON_DEV_ID("usart", "f8020000.serial", &usart1_clk),
222 CLKDEV_CON_DEV_ID("usart", "f8024000.serial", &usart2_clk),
223 CLKDEV_CON_DEV_ID("usart", "f8028000.serial", &usart3_clk),
224 CLKDEV_CON_DEV_ID("t0_clk", "f8008000.timer", &tcb0_clk),
225 CLKDEV_CON_DEV_ID("t0_clk", "f800c000.timer", &tcb0_clk),
226 CLKDEV_CON_ID("pioA", &pioAB_clk),
227 CLKDEV_CON_ID("pioB", &pioAB_clk),
228 CLKDEV_CON_ID("pioC", &pioCD_clk),
229 CLKDEV_CON_ID("pioD", &pioCD_clk),
230 /* additional fake clock for macb_hclk */
231 CLKDEV_CON_DEV_ID("hclk", "f802c000.ethernet", &macb0_clk),
232 CLKDEV_CON_DEV_ID("hclk", "f8030000.ethernet", &macb1_clk),
233 CLKDEV_CON_DEV_ID("hclk", "600000.ohci", &uhphs_clk),
234 CLKDEV_CON_DEV_ID("ohci_clk", "600000.ohci", &uhphs_clk),
235 CLKDEV_CON_DEV_ID("ehci_clk", "700000.ehci", &uhphs_clk),
236};
237
238/*
239 * The two programmable clocks.
240 * You must configure pin multiplexing to bring these signals out.
241 */
242static struct clk pck0 = {
243 .name = "pck0",
244 .pmc_mask = AT91_PMC_PCK0,
245 .type = CLK_TYPE_PROGRAMMABLE,
246 .id = 0,
247};
248static struct clk pck1 = {
249 .name = "pck1",
250 .pmc_mask = AT91_PMC_PCK1,
251 .type = CLK_TYPE_PROGRAMMABLE,
252 .id = 1,
253};
254
255static void __init at91sam9x5_register_clocks(void)
256{
257 int i;
258
259 for (i = 0; i < ARRAY_SIZE(periph_clocks); i++)
260 clk_register(periph_clocks[i]);
261
262 clkdev_add_table(periph_clocks_lookups,
263 ARRAY_SIZE(periph_clocks_lookups));
264
265 if (cpu_is_at91sam9g25()
266 || cpu_is_at91sam9x25())
267 clk_register(&usart3_clk);
268
269 if (cpu_is_at91sam9g25()
270 || cpu_is_at91sam9x25()
271 || cpu_is_at91sam9g35()
272 || cpu_is_at91sam9x35())
273 clk_register(&macb0_clk);
274
275 if (cpu_is_at91sam9g15()
276 || cpu_is_at91sam9g35()
277 || cpu_is_at91sam9x35())
278 clk_register(&lcdc_clk);
279
280 if (cpu_is_at91sam9g25())
281 clk_register(&isi_clk);
282
283 if (cpu_is_at91sam9x25())
284 clk_register(&macb1_clk);
285
286 if (cpu_is_at91sam9x25()
287 || cpu_is_at91sam9x35()) {
288 clk_register(&can0_clk);
289 clk_register(&can1_clk);
290 }
291
292 clk_register(&pck0);
293 clk_register(&pck1);
294}
295
296/* --------------------------------------------------------------------
297 * AT91SAM9x5 processor initialization
298 * -------------------------------------------------------------------- */
299
300static void __init at91sam9x5_map_io(void)
301{
302 at91_init_sram(0, AT91SAM9X5_SRAM_BASE, AT91SAM9X5_SRAM_SIZE);
303}
304
305void __init at91sam9x5_initialize(void)
306{
307 at91_extern_irq = (1 << AT91SAM9X5_ID_IRQ0);
308
309 /* Register GPIO subsystem (using DT) */
310 at91_gpio_init(NULL, 0);
311}
312
313/* --------------------------------------------------------------------
314 * Interrupt initialization
315 * -------------------------------------------------------------------- */
316/*
317 * The default interrupt priority levels (0 = lowest, 7 = highest).
318 */
319static unsigned int at91sam9x5_default_irq_priority[NR_AIC_IRQS] __initdata = {
320 7, /* Advanced Interrupt Controller (FIQ) */
321 7, /* System Peripherals */
322 1, /* Parallel IO Controller A and B */
323 1, /* Parallel IO Controller C and D */
324 4, /* Soft Modem */
325 5, /* USART 0 */
326 5, /* USART 1 */
327 5, /* USART 2 */
328 5, /* USART 3 */
329 6, /* Two-Wire Interface 0 */
330 6, /* Two-Wire Interface 1 */
331 6, /* Two-Wire Interface 2 */
332 0, /* Multimedia Card Interface 0 */
333 5, /* Serial Peripheral Interface 0 */
334 5, /* Serial Peripheral Interface 1 */
335 5, /* UART 0 */
336 5, /* UART 1 */
337 0, /* Timer Counter 0, 1, 2, 3, 4 and 5 */
338 0, /* Pulse Width Modulation Controller */
339 0, /* ADC Controller */
340 0, /* DMA Controller 0 */
341 0, /* DMA Controller 1 */
342 2, /* USB Host High Speed port */
343 2, /* USB Device High speed port */
344 3, /* Ethernet MAC 0 */
345 3, /* LDC Controller or Image Sensor Interface */
346 0, /* Multimedia Card Interface 1 */
347 3, /* Ethernet MAC 1 */
348 4, /* Synchronous Serial Interface */
349 4, /* CAN Controller 0 */
350 4, /* CAN Controller 1 */
351 0, /* Advanced Interrupt Controller (IRQ0) */
352};
353
354struct at91_init_soc __initdata at91sam9x5_soc = {
355 .map_io = at91sam9x5_map_io,
356 .default_irq_priority = at91sam9x5_default_irq_priority,
357 .register_clocks = at91sam9x5_register_clocks,
358 .init = at91sam9x5_initialize,
359};
diff --git a/arch/arm/mach-at91/at91x40.c b/arch/arm/mach-at91/at91x40.c
index 56ba3bd035a..5400a1d6503 100644
--- a/arch/arm/mach-at91/at91x40.c
+++ b/arch/arm/mach-at91/at91x40.c
@@ -13,6 +13,7 @@
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 <asm/proc-fns.h>
16#include <asm/mach/arch.h> 17#include <asm/mach/arch.h>
17#include <mach/at91x40.h> 18#include <mach/at91x40.h>
18#include <mach/at91_st.h> 19#include <mach/at91_st.h>
@@ -37,8 +38,19 @@ unsigned long clk_get_rate(struct clk *clk)
37 return AT91X40_MASTER_CLOCK; 38 return AT91X40_MASTER_CLOCK;
38} 39}
39 40
41static void at91x40_idle(void)
42{
43 /*
44 * Disable the processor clock. The processor will be automatically
45 * re-enabled by an interrupt or by a reset.
46 */
47 __raw_writel(AT91_PS_CR_CPU, AT91_PS_CR);
48 cpu_do_idle();
49}
50
40void __init at91x40_initialize(unsigned long main_clock) 51void __init at91x40_initialize(unsigned long main_clock)
41{ 52{
53 arm_pm_idle = at91x40_idle;
42 at91_extern_irq = (1 << AT91X40_ID_IRQ0) | (1 << AT91X40_ID_IRQ1) 54 at91_extern_irq = (1 << AT91X40_ID_IRQ0) | (1 << AT91X40_ID_IRQ1)
43 | (1 << AT91X40_ID_IRQ2); 55 | (1 << AT91X40_ID_IRQ2);
44} 56}
diff --git a/arch/arm/mach-at91/at91x40_time.c b/arch/arm/mach-at91/at91x40_time.c
index dfff2895f4b..6ca680a1d5d 100644
--- a/arch/arm/mach-at91/at91x40_time.c
+++ b/arch/arm/mach-at91/at91x40_time.c
@@ -28,6 +28,12 @@
28#include <asm/mach/time.h> 28#include <asm/mach/time.h>
29#include <mach/at91_tc.h> 29#include <mach/at91_tc.h>
30 30
31#define at91_tc_read(field) \
32 __raw_readl(AT91_TC + field)
33
34#define at91_tc_write(field, value) \
35 __raw_writel(value, AT91_TC + field);
36
31/* 37/*
32 * 3 counter/timer units present. 38 * 3 counter/timer units present.
33 */ 39 */
@@ -37,12 +43,12 @@
37 43
38static unsigned long at91x40_gettimeoffset(void) 44static unsigned long at91x40_gettimeoffset(void)
39{ 45{
40 return (at91_sys_read(AT91_TC + AT91_TC_CLK1BASE + AT91_TC_CV) * 1000000 / (AT91X40_MASTER_CLOCK / 128)); 46 return (at91_tc_read(AT91_TC_CLK1BASE + AT91_TC_CV) * 1000000 / (AT91X40_MASTER_CLOCK / 128));
41} 47}
42 48
43static irqreturn_t at91x40_timer_interrupt(int irq, void *dev_id) 49static irqreturn_t at91x40_timer_interrupt(int irq, void *dev_id)
44{ 50{
45 at91_sys_read(AT91_TC + AT91_TC_CLK1BASE + AT91_TC_SR); 51 at91_tc_read(AT91_TC_CLK1BASE + AT91_TC_SR);
46 timer_tick(); 52 timer_tick();
47 return IRQ_HANDLED; 53 return IRQ_HANDLED;
48} 54}
@@ -57,20 +63,20 @@ void __init at91x40_timer_init(void)
57{ 63{
58 unsigned int v; 64 unsigned int v;
59 65
60 at91_sys_write(AT91_TC + AT91_TC_BCR, 0); 66 at91_tc_write(AT91_TC_BCR, 0);
61 v = at91_sys_read(AT91_TC + AT91_TC_BMR); 67 v = at91_tc_read(AT91_TC_BMR);
62 v = (v & ~AT91_TC_TC1XC1S) | AT91_TC_TC1XC1S_NONE; 68 v = (v & ~AT91_TC_TC1XC1S) | AT91_TC_TC1XC1S_NONE;
63 at91_sys_write(AT91_TC + AT91_TC_BMR, v); 69 at91_tc_write(AT91_TC_BMR, v);
64 70
65 at91_sys_write(AT91_TC + AT91_TC_CLK1BASE + AT91_TC_CCR, AT91_TC_CLKDIS); 71 at91_tc_write(AT91_TC_CLK1BASE + AT91_TC_CCR, AT91_TC_CLKDIS);
66 at91_sys_write(AT91_TC + AT91_TC_CLK1BASE + AT91_TC_CMR, (AT91_TC_TIMER_CLOCK4 | AT91_TC_CPCTRG)); 72 at91_tc_write(AT91_TC_CLK1BASE + AT91_TC_CMR, (AT91_TC_TIMER_CLOCK4 | AT91_TC_CPCTRG));
67 at91_sys_write(AT91_TC + AT91_TC_CLK1BASE + AT91_TC_IDR, 0xffffffff); 73 at91_tc_write(AT91_TC_CLK1BASE + AT91_TC_IDR, 0xffffffff);
68 at91_sys_write(AT91_TC + AT91_TC_CLK1BASE + AT91_TC_RC, (AT91X40_MASTER_CLOCK / 128) / HZ - 1); 74 at91_tc_write(AT91_TC_CLK1BASE + AT91_TC_RC, (AT91X40_MASTER_CLOCK / 128) / HZ - 1);
69 at91_sys_write(AT91_TC + AT91_TC_CLK1BASE + AT91_TC_IER, (1<<4)); 75 at91_tc_write(AT91_TC_CLK1BASE + AT91_TC_IER, (1<<4));
70 76
71 setup_irq(AT91X40_ID_TC1, &at91x40_timer_irq); 77 setup_irq(AT91X40_ID_TC1, &at91x40_timer_irq);
72 78
73 at91_sys_write(AT91_TC + AT91_TC_CLK1BASE + AT91_TC_CCR, (AT91_TC_SWTRG | AT91_TC_CLKEN)); 79 at91_tc_write(AT91_TC_CLK1BASE + AT91_TC_CCR, (AT91_TC_SWTRG | AT91_TC_CLKEN));
74} 80}
75 81
76struct sys_timer at91x40_timer = { 82struct sys_timer at91x40_timer = {
diff --git a/arch/arm/mach-at91/board-afeb-9260v1.c b/arch/arm/mach-at91/board-afeb-9260v1.c
index 3bb40694b02..161efbaa102 100644
--- a/arch/arm/mach-at91/board-afeb-9260v1.c
+++ b/arch/arm/mach-at91/board-afeb-9260v1.c
@@ -138,6 +138,7 @@ static struct atmel_nand_data __initdata afeb9260_nand_data = {
138 .rdy_pin = AT91_PIN_PC13, 138 .rdy_pin = AT91_PIN_PC13,
139 .enable_pin = AT91_PIN_PC14, 139 .enable_pin = AT91_PIN_PC14,
140 .bus_width_16 = 0, 140 .bus_width_16 = 0,
141 .ecc_mode = NAND_ECC_SOFT,
141 .parts = afeb9260_nand_partition, 142 .parts = afeb9260_nand_partition,
142 .num_parts = ARRAY_SIZE(afeb9260_nand_partition), 143 .num_parts = ARRAY_SIZE(afeb9260_nand_partition),
143 .det_pin = -EINVAL, 144 .det_pin = -EINVAL,
diff --git a/arch/arm/mach-at91/board-cam60.c b/arch/arm/mach-at91/board-cam60.c
index 8510e9e5498..c6d44ee0c77 100644
--- a/arch/arm/mach-at91/board-cam60.c
+++ b/arch/arm/mach-at91/board-cam60.c
@@ -140,6 +140,7 @@ static struct atmel_nand_data __initdata cam60_nand_data = {
140 .det_pin = -EINVAL, 140 .det_pin = -EINVAL,
141 .rdy_pin = AT91_PIN_PA9, 141 .rdy_pin = AT91_PIN_PA9,
142 .enable_pin = AT91_PIN_PA7, 142 .enable_pin = AT91_PIN_PA7,
143 .ecc_mode = NAND_ECC_SOFT,
143 .parts = cam60_nand_partition, 144 .parts = cam60_nand_partition,
144 .num_parts = ARRAY_SIZE(cam60_nand_partition), 145 .num_parts = ARRAY_SIZE(cam60_nand_partition),
145}; 146};
diff --git a/arch/arm/mach-at91/board-cap9adk.c b/arch/arm/mach-at91/board-cap9adk.c
deleted file mode 100644
index ac3de4f7c31..00000000000
--- a/arch/arm/mach-at91/board-cap9adk.c
+++ /dev/null
@@ -1,396 +0,0 @@
1/*
2 * linux/arch/arm/mach-at91/board-cap9adk.c
3 *
4 * Copyright (C) 2007 Stelian Pop <stelian.pop@leadtechdesign.com>
5 * Copyright (C) 2007 Lead Tech Design <www.leadtechdesign.com>
6 * Copyright (C) 2005 SAN People
7 * Copyright (C) 2007 Atmel Corporation.
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 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24#include <linux/types.h>
25#include <linux/gpio.h>
26#include <linux/init.h>
27#include <linux/mm.h>
28#include <linux/module.h>
29#include <linux/platform_device.h>
30#include <linux/spi/spi.h>
31#include <linux/spi/ads7846.h>
32#include <linux/fb.h>
33#include <linux/mtd/physmap.h>
34
35#include <video/atmel_lcdc.h>
36
37#include <mach/hardware.h>
38#include <asm/setup.h>
39#include <asm/mach-types.h>
40
41#include <asm/mach/arch.h>
42#include <asm/mach/map.h>
43
44#include <mach/board.h>
45#include <mach/at91cap9_matrix.h>
46#include <mach/at91sam9_smc.h>
47#include <mach/system_rev.h>
48
49#include "sam9_smc.h"
50#include "generic.h"
51
52
53static void __init cap9adk_init_early(void)
54{
55 /* Initialize processor: 12 MHz crystal */
56 at91_initialize(12000000);
57
58 /* Setup the LEDs: USER1 and USER2 LED for cpu/timer... */
59 at91_init_leds(AT91_PIN_PA10, AT91_PIN_PA11);
60 /* ... POWER LED always on */
61 at91_set_gpio_output(AT91_PIN_PC29, 1);
62
63 /* Setup the serial ports and console */
64 at91_register_uart(0, 0, 0); /* DBGU = ttyS0 */
65 at91_set_serial_console(0);
66}
67
68/*
69 * USB Host port
70 */
71static struct at91_usbh_data __initdata cap9adk_usbh_data = {
72 .ports = 2,
73 .vbus_pin = {-EINVAL, -EINVAL},
74 .overcurrent_pin= {-EINVAL, -EINVAL},
75};
76
77/*
78 * USB HS Device port
79 */
80static struct usba_platform_data __initdata cap9adk_usba_udc_data = {
81 .vbus_pin = AT91_PIN_PB31,
82};
83
84/*
85 * ADS7846 Touchscreen
86 */
87#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
88static int ads7843_pendown_state(void)
89{
90 return !at91_get_gpio_value(AT91_PIN_PC4); /* Touchscreen PENIRQ */
91}
92
93static struct ads7846_platform_data ads_info = {
94 .model = 7843,
95 .x_min = 150,
96 .x_max = 3830,
97 .y_min = 190,
98 .y_max = 3830,
99 .vref_delay_usecs = 100,
100 .x_plate_ohms = 450,
101 .y_plate_ohms = 250,
102 .pressure_max = 15000,
103 .debounce_max = 1,
104 .debounce_rep = 0,
105 .debounce_tol = (~0),
106 .get_pendown_state = ads7843_pendown_state,
107};
108
109static void __init cap9adk_add_device_ts(void)
110{
111 at91_set_gpio_input(AT91_PIN_PC4, 1); /* Touchscreen PENIRQ */
112 at91_set_gpio_input(AT91_PIN_PC5, 1); /* Touchscreen BUSY */
113}
114#else
115static void __init cap9adk_add_device_ts(void) {}
116#endif
117
118
119/*
120 * SPI devices.
121 */
122static struct spi_board_info cap9adk_spi_devices[] = {
123#if defined(CONFIG_MTD_AT91_DATAFLASH_CARD)
124 { /* DataFlash card */
125 .modalias = "mtd_dataflash",
126 .chip_select = 0,
127 .max_speed_hz = 15 * 1000 * 1000,
128 .bus_num = 0,
129 },
130#endif
131#if defined(CONFIG_TOUCHSCREEN_ADS7846) || defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
132 {
133 .modalias = "ads7846",
134 .chip_select = 3, /* can be 2 or 3, depending on J2 jumper */
135 .max_speed_hz = 125000 * 26, /* (max sample rate @ 3V) * (cmd + data + overhead) */
136 .bus_num = 0,
137 .platform_data = &ads_info,
138 .irq = AT91_PIN_PC4,
139 },
140#endif
141};
142
143
144/*
145 * MCI (SD/MMC)
146 */
147static struct at91_mmc_data __initdata cap9adk_mmc_data = {
148 .wire4 = 1,
149 .det_pin = -EINVAL,
150 .wp_pin = -EINVAL,
151 .vcc_pin = -EINVAL,
152};
153
154
155/*
156 * MACB Ethernet device
157 */
158static struct macb_platform_data __initdata cap9adk_macb_data = {
159 .phy_irq_pin = -EINVAL,
160 .is_rmii = 1,
161};
162
163
164/*
165 * NAND flash
166 */
167static struct mtd_partition __initdata cap9adk_nand_partitions[] = {
168 {
169 .name = "NAND partition",
170 .offset = 0,
171 .size = MTDPART_SIZ_FULL,
172 },
173};
174
175static struct atmel_nand_data __initdata cap9adk_nand_data = {
176 .ale = 21,
177 .cle = 22,
178 .det_pin = -EINVAL,
179 .rdy_pin = -EINVAL,
180 .enable_pin = AT91_PIN_PD15,
181 .parts = cap9adk_nand_partitions,
182 .num_parts = ARRAY_SIZE(cap9adk_nand_partitions),
183};
184
185static struct sam9_smc_config __initdata cap9adk_nand_smc_config = {
186 .ncs_read_setup = 1,
187 .nrd_setup = 2,
188 .ncs_write_setup = 1,
189 .nwe_setup = 2,
190
191 .ncs_read_pulse = 6,
192 .nrd_pulse = 4,
193 .ncs_write_pulse = 6,
194 .nwe_pulse = 4,
195
196 .read_cycle = 8,
197 .write_cycle = 8,
198
199 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE,
200 .tdf_cycles = 1,
201};
202
203static void __init cap9adk_add_device_nand(void)
204{
205 unsigned long csa;
206
207 csa = at91_sys_read(AT91_MATRIX_EBICSA);
208 at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_EBI_VDDIOMSEL_3_3V);
209
210 cap9adk_nand_data.bus_width_16 = board_have_nand_16bit();
211 /* setup bus-width (8 or 16) */
212 if (cap9adk_nand_data.bus_width_16)
213 cap9adk_nand_smc_config.mode |= AT91_SMC_DBW_16;
214 else
215 cap9adk_nand_smc_config.mode |= AT91_SMC_DBW_8;
216
217 /* configure chip-select 3 (NAND) */
218 sam9_smc_configure(0, 3, &cap9adk_nand_smc_config);
219
220 at91_add_device_nand(&cap9adk_nand_data);
221}
222
223
224/*
225 * NOR flash
226 */
227static struct mtd_partition cap9adk_nor_partitions[] = {
228 {
229 .name = "NOR partition",
230 .offset = 0,
231 .size = MTDPART_SIZ_FULL,
232 },
233};
234
235static struct physmap_flash_data cap9adk_nor_data = {
236 .width = 2,
237 .parts = cap9adk_nor_partitions,
238 .nr_parts = ARRAY_SIZE(cap9adk_nor_partitions),
239};
240
241#define NOR_BASE AT91_CHIPSELECT_0
242#define NOR_SIZE SZ_8M
243
244static struct resource nor_flash_resources[] = {
245 {
246 .start = NOR_BASE,
247 .end = NOR_BASE + NOR_SIZE - 1,
248 .flags = IORESOURCE_MEM,
249 }
250};
251
252static struct platform_device cap9adk_nor_flash = {
253 .name = "physmap-flash",
254 .id = 0,
255 .dev = {
256 .platform_data = &cap9adk_nor_data,
257 },
258 .resource = nor_flash_resources,
259 .num_resources = ARRAY_SIZE(nor_flash_resources),
260};
261
262static struct sam9_smc_config __initdata cap9adk_nor_smc_config = {
263 .ncs_read_setup = 2,
264 .nrd_setup = 4,
265 .ncs_write_setup = 2,
266 .nwe_setup = 4,
267
268 .ncs_read_pulse = 10,
269 .nrd_pulse = 8,
270 .ncs_write_pulse = 10,
271 .nwe_pulse = 8,
272
273 .read_cycle = 16,
274 .write_cycle = 16,
275
276 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_BAT_WRITE | AT91_SMC_DBW_16,
277 .tdf_cycles = 1,
278};
279
280static __init void cap9adk_add_device_nor(void)
281{
282 unsigned long csa;
283
284 csa = at91_sys_read(AT91_MATRIX_EBICSA);
285 at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_EBI_VDDIOMSEL_3_3V);
286
287 /* configure chip-select 0 (NOR) */
288 sam9_smc_configure(0, 0, &cap9adk_nor_smc_config);
289
290 platform_device_register(&cap9adk_nor_flash);
291}
292
293
294/*
295 * LCD Controller
296 */
297#if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
298static struct fb_videomode at91_tft_vga_modes[] = {
299 {
300 .name = "TX09D50VM1CCA @ 60",
301 .refresh = 60,
302 .xres = 240, .yres = 320,
303 .pixclock = KHZ2PICOS(4965),
304
305 .left_margin = 1, .right_margin = 33,
306 .upper_margin = 1, .lower_margin = 0,
307 .hsync_len = 5, .vsync_len = 1,
308
309 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
310 .vmode = FB_VMODE_NONINTERLACED,
311 },
312};
313
314static struct fb_monspecs at91fb_default_monspecs = {
315 .manufacturer = "HIT",
316 .monitor = "TX09D70VM1CCA",
317
318 .modedb = at91_tft_vga_modes,
319 .modedb_len = ARRAY_SIZE(at91_tft_vga_modes),
320 .hfmin = 15000,
321 .hfmax = 64000,
322 .vfmin = 50,
323 .vfmax = 150,
324};
325
326#define AT91CAP9_DEFAULT_LCDCON2 (ATMEL_LCDC_MEMOR_LITTLE \
327 | ATMEL_LCDC_DISTYPE_TFT \
328 | ATMEL_LCDC_CLKMOD_ALWAYSACTIVE)
329
330static void at91_lcdc_power_control(int on)
331{
332 if (on)
333 at91_set_gpio_value(AT91_PIN_PC0, 0); /* power up */
334 else
335 at91_set_gpio_value(AT91_PIN_PC0, 1); /* power down */
336}
337
338/* Driver datas */
339static struct atmel_lcdfb_info __initdata cap9adk_lcdc_data = {
340 .default_bpp = 16,
341 .default_dmacon = ATMEL_LCDC_DMAEN,
342 .default_lcdcon2 = AT91CAP9_DEFAULT_LCDCON2,
343 .default_monspecs = &at91fb_default_monspecs,
344 .atmel_lcdfb_power_control = at91_lcdc_power_control,
345 .guard_time = 1,
346};
347
348#else
349static struct atmel_lcdfb_info __initdata cap9adk_lcdc_data;
350#endif
351
352
353/*
354 * AC97
355 */
356static struct ac97c_platform_data cap9adk_ac97_data = {
357 .reset_pin = -EINVAL,
358};
359
360
361static void __init cap9adk_board_init(void)
362{
363 /* Serial */
364 at91_add_device_serial();
365 /* USB Host */
366 at91_add_device_usbh(&cap9adk_usbh_data);
367 /* USB HS */
368 at91_add_device_usba(&cap9adk_usba_udc_data);
369 /* SPI */
370 at91_add_device_spi(cap9adk_spi_devices, ARRAY_SIZE(cap9adk_spi_devices));
371 /* Touchscreen */
372 cap9adk_add_device_ts();
373 /* MMC */
374 at91_add_device_mmc(1, &cap9adk_mmc_data);
375 /* Ethernet */
376 at91_add_device_eth(&cap9adk_macb_data);
377 /* NAND */
378 cap9adk_add_device_nand();
379 /* NOR Flash */
380 cap9adk_add_device_nor();
381 /* I2C */
382 at91_add_device_i2c(NULL, 0);
383 /* LCD Controller */
384 at91_add_device_lcdc(&cap9adk_lcdc_data);
385 /* AC97 */
386 at91_add_device_ac97(&cap9adk_ac97_data);
387}
388
389MACHINE_START(AT91CAP9ADK, "Atmel AT91CAP9A-DK")
390 /* Maintainer: Stelian Pop <stelian.pop@leadtechdesign.com> */
391 .timer = &at91sam926x_timer,
392 .map_io = at91_map_io,
393 .init_early = cap9adk_init_early,
394 .init_irq = at91_init_irq_default,
395 .init_machine = cap9adk_board_init,
396MACHINE_END
diff --git a/arch/arm/mach-at91/board-cpu9krea.c b/arch/arm/mach-at91/board-cpu9krea.c
index 9ab3d1ea326..5f3680e7c88 100644
--- a/arch/arm/mach-at91/board-cpu9krea.c
+++ b/arch/arm/mach-at91/board-cpu9krea.c
@@ -43,6 +43,7 @@
43#include <mach/board.h> 43#include <mach/board.h>
44#include <mach/at91sam9_smc.h> 44#include <mach/at91sam9_smc.h>
45#include <mach/at91sam9260_matrix.h> 45#include <mach/at91sam9260_matrix.h>
46#include <mach/at91_matrix.h>
46 47
47#include "sam9_smc.h" 48#include "sam9_smc.h"
48#include "generic.h" 49#include "generic.h"
@@ -116,6 +117,7 @@ static struct atmel_nand_data __initdata cpu9krea_nand_data = {
116 .enable_pin = AT91_PIN_PC14, 117 .enable_pin = AT91_PIN_PC14,
117 .bus_width_16 = 0, 118 .bus_width_16 = 0,
118 .det_pin = -EINVAL, 119 .det_pin = -EINVAL,
120 .ecc_mode = NAND_ECC_SOFT,
119}; 121};
120 122
121#ifdef CONFIG_MACH_CPU9260 123#ifdef CONFIG_MACH_CPU9260
@@ -238,8 +240,8 @@ static __init void cpu9krea_add_device_nor(void)
238{ 240{
239 unsigned long csa; 241 unsigned long csa;
240 242
241 csa = at91_sys_read(AT91_MATRIX_EBICSA); 243 csa = at91_matrix_read(AT91_MATRIX_EBICSA);
242 at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_VDDIOMSEL_3_3V); 244 at91_matrix_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_VDDIOMSEL_3_3V);
243 245
244 /* configure chip-select 0 (NOR) */ 246 /* configure chip-select 0 (NOR) */
245 sam9_smc_configure(0, 0, &cpu9krea_nor_smc_config); 247 sam9_smc_configure(0, 0, &cpu9krea_nor_smc_config);
diff --git a/arch/arm/mach-at91/board-cpuat91.c b/arch/arm/mach-at91/board-cpuat91.c
index 368e1427ad9..e094cc81fe2 100644
--- a/arch/arm/mach-at91/board-cpuat91.c
+++ b/arch/arm/mach-at91/board-cpuat91.c
@@ -38,6 +38,7 @@
38 38
39#include <mach/board.h> 39#include <mach/board.h>
40#include <mach/at91rm9200_mc.h> 40#include <mach/at91rm9200_mc.h>
41#include <mach/at91_ramc.h>
41#include <mach/cpu.h> 42#include <mach/cpu.h>
42 43
43#include "generic.h" 44#include "generic.h"
diff --git a/arch/arm/mach-at91/board-dt.c b/arch/arm/mach-at91/board-dt.c
index bb6b434ec0c..c18d4d30780 100644
--- a/arch/arm/mach-at91/board-dt.c
+++ b/arch/arm/mach-at91/board-dt.c
@@ -15,14 +15,11 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/gpio.h> 17#include <linux/gpio.h>
18#include <linux/irqdomain.h> 18#include <linux/of.h>
19#include <linux/of_irq.h> 19#include <linux/of_irq.h>
20#include <linux/of_platform.h> 20#include <linux/of_platform.h>
21 21
22#include <mach/hardware.h>
23#include <mach/board.h> 22#include <mach/board.h>
24#include <mach/system_rev.h>
25#include <mach/at91sam9_smc.h>
26 23
27#include <asm/setup.h> 24#include <asm/setup.h>
28#include <asm/irq.h> 25#include <asm/irq.h>
@@ -30,85 +27,30 @@
30#include <asm/mach/map.h> 27#include <asm/mach/map.h>
31#include <asm/mach/irq.h> 28#include <asm/mach/irq.h>
32 29
33#include "sam9_smc.h"
34#include "generic.h" 30#include "generic.h"
35 31
36 32
37static void __init ek_init_early(void) 33static const struct of_device_id irq_of_match[] __initconst = {
38{
39 /* Initialize processor: 12.000 MHz crystal */
40 at91_initialize(12000000);
41
42 /* DGBU on ttyS0. (Rx & Tx only) */
43 at91_register_uart(0, 0, 0);
44
45 /* set serial console to ttyS0 (ie, DBGU) */
46 at91_set_serial_console(0);
47}
48
49/* det_pin is not connected */
50static struct atmel_nand_data __initdata ek_nand_data = {
51 .ale = 21,
52 .cle = 22,
53 .det_pin = -EINVAL,
54 .rdy_pin = AT91_PIN_PC8,
55 .enable_pin = AT91_PIN_PC14,
56};
57
58static struct sam9_smc_config __initdata ek_nand_smc_config = {
59 .ncs_read_setup = 0,
60 .nrd_setup = 2,
61 .ncs_write_setup = 0,
62 .nwe_setup = 2,
63
64 .ncs_read_pulse = 4,
65 .nrd_pulse = 4,
66 .ncs_write_pulse = 4,
67 .nwe_pulse = 4,
68
69 .read_cycle = 7,
70 .write_cycle = 7,
71 34
72 .mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE, 35 { .compatible = "atmel,at91rm9200-aic", .data = at91_aic_of_init },
73 .tdf_cycles = 3, 36 { .compatible = "atmel,at91rm9200-gpio", .data = at91_gpio_of_irq_setup },
74}; 37 { .compatible = "atmel,at91sam9x5-gpio", .data = at91_gpio_of_irq_setup },
75 38 { /*sentinel*/ }
76static void __init ek_add_device_nand(void)
77{
78 ek_nand_data.bus_width_16 = board_have_nand_16bit();
79 /* setup bus-width (8 or 16) */
80 if (ek_nand_data.bus_width_16)
81 ek_nand_smc_config.mode |= AT91_SMC_DBW_16;
82 else
83 ek_nand_smc_config.mode |= AT91_SMC_DBW_8;
84
85 /* configure chip-select 3 (NAND) */
86 sam9_smc_configure(0, 3, &ek_nand_smc_config);
87
88 at91_add_device_nand(&ek_nand_data);
89}
90
91static const struct of_device_id aic_of_match[] __initconst = {
92 { .compatible = "atmel,at91rm9200-aic", },
93 {},
94}; 39};
95 40
96static void __init at91_dt_init_irq(void) 41static void __init at91_dt_init_irq(void)
97{ 42{
98 irq_domain_generate_simple(aic_of_match, 0xfffff000, 0); 43 of_irq_init(irq_of_match);
99 at91_init_irq_default();
100} 44}
101 45
102static void __init at91_dt_device_init(void) 46static void __init at91_dt_device_init(void)
103{ 47{
104 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); 48 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
105
106 /* NAND */
107 ek_add_device_nand();
108} 49}
109 50
110static const char *at91_dt_board_compat[] __initdata = { 51static const char *at91_dt_board_compat[] __initdata = {
111 "atmel,at91sam9m10g45ek", 52 "atmel,at91sam9m10g45ek",
53 "atmel,at91sam9x5ek",
112 "calao,usb-a9g20", 54 "calao,usb-a9g20",
113 NULL 55 NULL
114}; 56};
@@ -117,7 +59,7 @@ DT_MACHINE_START(at91sam_dt, "Atmel AT91SAM (Device Tree)")
117 /* Maintainer: Atmel */ 59 /* Maintainer: Atmel */
118 .timer = &at91sam926x_timer, 60 .timer = &at91sam926x_timer,
119 .map_io = at91_map_io, 61 .map_io = at91_map_io,
120 .init_early = ek_init_early, 62 .init_early = at91_dt_initialize,
121 .init_irq = at91_dt_init_irq, 63 .init_irq = at91_dt_init_irq,
122 .init_machine = at91_dt_device_init, 64 .init_machine = at91_dt_device_init,
123 .dt_compat = at91_dt_board_compat, 65 .dt_compat = at91_dt_board_compat,
diff --git a/arch/arm/mach-at91/board-eco920.c b/arch/arm/mach-at91/board-eco920.c
index 07ef35b0ec2..f23aabef855 100644
--- a/arch/arm/mach-at91/board-eco920.c
+++ b/arch/arm/mach-at91/board-eco920.c
@@ -26,6 +26,7 @@
26 26
27#include <mach/board.h> 27#include <mach/board.h>
28#include <mach/at91rm9200_mc.h> 28#include <mach/at91rm9200_mc.h>
29#include <mach/at91_ramc.h>
29#include <mach/cpu.h> 30#include <mach/cpu.h>
30 31
31#include "generic.h" 32#include "generic.h"
@@ -110,7 +111,7 @@ static void __init eco920_board_init(void)
110 at91_add_device_mmc(0, &eco920_mmc_data); 111 at91_add_device_mmc(0, &eco920_mmc_data);
111 platform_device_register(&eco920_flash); 112 platform_device_register(&eco920_flash);
112 113
113 at91_sys_write(AT91_SMC_CSR(7), AT91_SMC_RWHOLD_(1) 114 at91_ramc_write(0, AT91_SMC_CSR(7), AT91_SMC_RWHOLD_(1)
114 | AT91_SMC_RWSETUP_(1) 115 | AT91_SMC_RWSETUP_(1)
115 | AT91_SMC_DBW_8 116 | AT91_SMC_DBW_8
116 | AT91_SMC_WSEN 117 | AT91_SMC_WSEN
@@ -122,7 +123,7 @@ static void __init eco920_board_init(void)
122 at91_set_deglitch(AT91_PIN_PA23, 1); 123 at91_set_deglitch(AT91_PIN_PA23, 1);
123 124
124/* Initialization of the Static Memory Controller for Chip Select 3 */ 125/* Initialization of the Static Memory Controller for Chip Select 3 */
125 at91_sys_write(AT91_SMC_CSR(3), 126 at91_ramc_write(0, AT91_SMC_CSR(3),
126 AT91_SMC_DBW_16 | /* 16 bit */ 127 AT91_SMC_DBW_16 | /* 16 bit */
127 AT91_SMC_WSEN | 128 AT91_SMC_WSEN |
128 AT91_SMC_NWS_(5) | /* wait states */ 129 AT91_SMC_NWS_(5) | /* wait states */
diff --git a/arch/arm/mach-at91/board-flexibity.c b/arch/arm/mach-at91/board-flexibity.c
index eec02cd57ce..1815152001f 100644
--- a/arch/arm/mach-at91/board-flexibity.c
+++ b/arch/arm/mach-at91/board-flexibity.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * linux/arch/arm/mach-at91/board-flexibity.c 2 * linux/arch/arm/mach-at91/board-flexibity.c
3 * 3 *
4 * Copyright (C) 2010 Flexibity 4 * Copyright (C) 2010-2011 Flexibity
5 * Copyright (C) 2005 SAN People 5 * Copyright (C) 2005 SAN People
6 * Copyright (C) 2006 Atmel 6 * Copyright (C) 2006 Atmel
7 * 7 *
@@ -62,6 +62,13 @@ static struct at91_udc_data __initdata flexibity_udc_data = {
62 .pullup_pin = -EINVAL, /* pull-up driven by UDC */ 62 .pullup_pin = -EINVAL, /* pull-up driven by UDC */
63}; 63};
64 64
65/* I2C devices */
66static struct i2c_board_info __initdata flexibity_i2c_devices[] = {
67 {
68 I2C_BOARD_INFO("ds1307", 0x68),
69 },
70};
71
65/* SPI devices */ 72/* SPI devices */
66static struct spi_board_info flexibity_spi_devices[] = { 73static struct spi_board_info flexibity_spi_devices[] = {
67 { /* DataFlash chip */ 74 { /* DataFlash chip */
@@ -141,6 +148,9 @@ static void __init flexibity_board_init(void)
141 at91_add_device_usbh(&flexibity_usbh_data); 148 at91_add_device_usbh(&flexibity_usbh_data);
142 /* USB Device */ 149 /* USB Device */
143 at91_add_device_udc(&flexibity_udc_data); 150 at91_add_device_udc(&flexibity_udc_data);
151 /* I2C */
152 at91_add_device_i2c(flexibity_i2c_devices,
153 ARRAY_SIZE(flexibity_i2c_devices));
144 /* SPI */ 154 /* SPI */
145 at91_add_device_spi(flexibity_spi_devices, 155 at91_add_device_spi(flexibity_spi_devices,
146 ARRAY_SIZE(flexibity_spi_devices)); 156 ARRAY_SIZE(flexibity_spi_devices));
diff --git a/arch/arm/mach-at91/board-kb9202.c b/arch/arm/mach-at91/board-kb9202.c
index d75a4a2ad9c..59b92aab9bc 100644
--- a/arch/arm/mach-at91/board-kb9202.c
+++ b/arch/arm/mach-at91/board-kb9202.c
@@ -38,6 +38,7 @@
38#include <mach/board.h> 38#include <mach/board.h>
39#include <mach/cpu.h> 39#include <mach/cpu.h>
40#include <mach/at91rm9200_mc.h> 40#include <mach/at91rm9200_mc.h>
41#include <mach/at91_ramc.h>
41 42
42#include "generic.h" 43#include "generic.h"
43 44
@@ -107,6 +108,7 @@ static struct atmel_nand_data __initdata kb9202_nand_data = {
107 .det_pin = -EINVAL, 108 .det_pin = -EINVAL,
108 .rdy_pin = AT91_PIN_PC29, 109 .rdy_pin = AT91_PIN_PC29,
109 .enable_pin = AT91_PIN_PC28, 110 .enable_pin = AT91_PIN_PC28,
111 .ecc_mode = NAND_ECC_SOFT,
110 .parts = kb9202_nand_partition, 112 .parts = kb9202_nand_partition,
111 .num_parts = ARRAY_SIZE(kb9202_nand_partition), 113 .num_parts = ARRAY_SIZE(kb9202_nand_partition),
112}; 114};
diff --git a/arch/arm/mach-at91/board-neocore926.c b/arch/arm/mach-at91/board-neocore926.c
index 3f8617c0e04..57d5f6a4726 100644
--- a/arch/arm/mach-at91/board-neocore926.c
+++ b/arch/arm/mach-at91/board-neocore926.c
@@ -190,6 +190,7 @@ static struct atmel_nand_data __initdata neocore926_nand_data = {
190 .rdy_pin = AT91_PIN_PB19, 190 .rdy_pin = AT91_PIN_PB19,
191 .rdy_pin_active_low = 1, 191 .rdy_pin_active_low = 1,
192 .enable_pin = AT91_PIN_PD15, 192 .enable_pin = AT91_PIN_PD15,
193 .ecc_mode = NAND_ECC_SOFT,
193 .parts = neocore926_nand_partition, 194 .parts = neocore926_nand_partition,
194 .num_parts = ARRAY_SIZE(neocore926_nand_partition), 195 .num_parts = ARRAY_SIZE(neocore926_nand_partition),
195 .det_pin = -EINVAL, 196 .det_pin = -EINVAL,
diff --git a/arch/arm/mach-at91/board-picotux200.c b/arch/arm/mach-at91/board-picotux200.c
index ab024fa11d5..59e35dd1486 100644
--- a/arch/arm/mach-at91/board-picotux200.c
+++ b/arch/arm/mach-at91/board-picotux200.c
@@ -39,6 +39,7 @@
39 39
40#include <mach/board.h> 40#include <mach/board.h>
41#include <mach/at91rm9200_mc.h> 41#include <mach/at91rm9200_mc.h>
42#include <mach/at91_ramc.h>
42 43
43#include "generic.h" 44#include "generic.h"
44 45
diff --git a/arch/arm/mach-at91/board-qil-a9260.c b/arch/arm/mach-at91/board-qil-a9260.c
index e029d220cb8..b6ed5ed7081 100644
--- a/arch/arm/mach-at91/board-qil-a9260.c
+++ b/arch/arm/mach-at91/board-qil-a9260.c
@@ -138,6 +138,8 @@ static struct atmel_nand_data __initdata ek_nand_data = {
138 .det_pin = -EINVAL, 138 .det_pin = -EINVAL,
139 .rdy_pin = AT91_PIN_PC13, 139 .rdy_pin = AT91_PIN_PC13,
140 .enable_pin = AT91_PIN_PC14, 140 .enable_pin = AT91_PIN_PC14,
141 .ecc_mode = NAND_ECC_SOFT,
142 .on_flash_bbt = 1,
141 .parts = ek_nand_partition, 143 .parts = ek_nand_partition,
142 .num_parts = ARRAY_SIZE(ek_nand_partition), 144 .num_parts = ARRAY_SIZE(ek_nand_partition),
143}; 145};
diff --git a/arch/arm/mach-at91/board-rm9200dk.c b/arch/arm/mach-at91/board-rm9200dk.c
index 782f37946af..01332aa538b 100644
--- a/arch/arm/mach-at91/board-rm9200dk.c
+++ b/arch/arm/mach-at91/board-rm9200dk.c
@@ -41,6 +41,7 @@
41#include <mach/hardware.h> 41#include <mach/hardware.h>
42#include <mach/board.h> 42#include <mach/board.h>
43#include <mach/at91rm9200_mc.h> 43#include <mach/at91rm9200_mc.h>
44#include <mach/at91_ramc.h>
44 45
45#include "generic.h" 46#include "generic.h"
46 47
@@ -149,6 +150,8 @@ static struct atmel_nand_data __initdata dk_nand_data = {
149 .det_pin = AT91_PIN_PB1, 150 .det_pin = AT91_PIN_PB1,
150 .rdy_pin = AT91_PIN_PC2, 151 .rdy_pin = AT91_PIN_PC2,
151 .enable_pin = -EINVAL, 152 .enable_pin = -EINVAL,
153 .ecc_mode = NAND_ECC_SOFT,
154 .on_flash_bbt = 1,
152 .parts = dk_nand_partition, 155 .parts = dk_nand_partition,
153 .num_parts = ARRAY_SIZE(dk_nand_partition), 156 .num_parts = ARRAY_SIZE(dk_nand_partition),
154}; 157};
diff --git a/arch/arm/mach-at91/board-rm9200ek.c b/arch/arm/mach-at91/board-rm9200ek.c
index ef7c12a9224..11cbaa8946f 100644
--- a/arch/arm/mach-at91/board-rm9200ek.c
+++ b/arch/arm/mach-at91/board-rm9200ek.c
@@ -41,6 +41,7 @@
41#include <mach/hardware.h> 41#include <mach/hardware.h>
42#include <mach/board.h> 42#include <mach/board.h>
43#include <mach/at91rm9200_mc.h> 43#include <mach/at91rm9200_mc.h>
44#include <mach/at91_ramc.h>
44 45
45#include "generic.h" 46#include "generic.h"
46 47
diff --git a/arch/arm/mach-at91/board-sam9-l9260.c b/arch/arm/mach-at91/board-sam9-l9260.c
index 84bce587735..e8b116b6cba 100644
--- a/arch/arm/mach-at91/board-sam9-l9260.c
+++ b/arch/arm/mach-at91/board-sam9-l9260.c
@@ -139,6 +139,7 @@ static struct atmel_nand_data __initdata ek_nand_data = {
139 .det_pin = -EINVAL, 139 .det_pin = -EINVAL,
140 .rdy_pin = AT91_PIN_PC13, 140 .rdy_pin = AT91_PIN_PC13,
141 .enable_pin = AT91_PIN_PC14, 141 .enable_pin = AT91_PIN_PC14,
142 .ecc_mode = NAND_ECC_SOFT,
142 .parts = ek_nand_partition, 143 .parts = ek_nand_partition,
143 .num_parts = ARRAY_SIZE(ek_nand_partition), 144 .num_parts = ARRAY_SIZE(ek_nand_partition),
144}; 145};
diff --git a/arch/arm/mach-at91/board-sam9260ek.c b/arch/arm/mach-at91/board-sam9260ek.c
index be8233bcabd..d5aec55b0eb 100644
--- a/arch/arm/mach-at91/board-sam9260ek.c
+++ b/arch/arm/mach-at91/board-sam9260ek.c
@@ -181,6 +181,8 @@ static struct atmel_nand_data __initdata ek_nand_data = {
181 .det_pin = -EINVAL, 181 .det_pin = -EINVAL,
182 .rdy_pin = AT91_PIN_PC13, 182 .rdy_pin = AT91_PIN_PC13,
183 .enable_pin = AT91_PIN_PC14, 183 .enable_pin = AT91_PIN_PC14,
184 .ecc_mode = NAND_ECC_SOFT,
185 .on_flash_bbt = 1,
184 .parts = ek_nand_partition, 186 .parts = ek_nand_partition,
185 .num_parts = ARRAY_SIZE(ek_nand_partition), 187 .num_parts = ARRAY_SIZE(ek_nand_partition),
186}; 188};
diff --git a/arch/arm/mach-at91/board-sam9261ek.c b/arch/arm/mach-at91/board-sam9261ek.c
index 40895072a1a..c3f99446286 100644
--- a/arch/arm/mach-at91/board-sam9261ek.c
+++ b/arch/arm/mach-at91/board-sam9261ek.c
@@ -187,6 +187,8 @@ static struct atmel_nand_data __initdata ek_nand_data = {
187 .det_pin = -EINVAL, 187 .det_pin = -EINVAL,
188 .rdy_pin = AT91_PIN_PC15, 188 .rdy_pin = AT91_PIN_PC15,
189 .enable_pin = AT91_PIN_PC14, 189 .enable_pin = AT91_PIN_PC14,
190 .ecc_mode = NAND_ECC_SOFT,
191 .on_flash_bbt = 1,
190 .parts = ek_nand_partition, 192 .parts = ek_nand_partition,
191 .num_parts = ARRAY_SIZE(ek_nand_partition), 193 .num_parts = ARRAY_SIZE(ek_nand_partition),
192}; 194};
diff --git a/arch/arm/mach-at91/board-sam9263ek.c b/arch/arm/mach-at91/board-sam9263ek.c
index 29f66052fe6..66f0ddf4b2a 100644
--- a/arch/arm/mach-at91/board-sam9263ek.c
+++ b/arch/arm/mach-at91/board-sam9263ek.c
@@ -187,6 +187,8 @@ static struct atmel_nand_data __initdata ek_nand_data = {
187 .det_pin = -EINVAL, 187 .det_pin = -EINVAL,
188 .rdy_pin = AT91_PIN_PA22, 188 .rdy_pin = AT91_PIN_PA22,
189 .enable_pin = AT91_PIN_PD15, 189 .enable_pin = AT91_PIN_PD15,
190 .ecc_mode = NAND_ECC_SOFT,
191 .on_flash_bbt = 1,
190 .parts = ek_nand_partition, 192 .parts = ek_nand_partition,
191 .num_parts = ARRAY_SIZE(ek_nand_partition), 193 .num_parts = ARRAY_SIZE(ek_nand_partition),
192}; 194};
diff --git a/arch/arm/mach-at91/board-sam9g20ek.c b/arch/arm/mach-at91/board-sam9g20ek.c
index 843d6286c6f..8923ec9f583 100644
--- a/arch/arm/mach-at91/board-sam9g20ek.c
+++ b/arch/arm/mach-at91/board-sam9g20ek.c
@@ -166,6 +166,8 @@ static struct atmel_nand_data __initdata ek_nand_data = {
166 .rdy_pin = AT91_PIN_PC13, 166 .rdy_pin = AT91_PIN_PC13,
167 .enable_pin = AT91_PIN_PC14, 167 .enable_pin = AT91_PIN_PC14,
168 .det_pin = -EINVAL, 168 .det_pin = -EINVAL,
169 .ecc_mode = NAND_ECC_SOFT,
170 .on_flash_bbt = 1,
169 .parts = ek_nand_partition, 171 .parts = ek_nand_partition,
170 .num_parts = ARRAY_SIZE(ek_nand_partition), 172 .num_parts = ARRAY_SIZE(ek_nand_partition),
171}; 173};
diff --git a/arch/arm/mach-at91/board-sam9m10g45ek.c b/arch/arm/mach-at91/board-sam9m10g45ek.c
index ea0d1b9c2b7..e1bea73e6b3 100644
--- a/arch/arm/mach-at91/board-sam9m10g45ek.c
+++ b/arch/arm/mach-at91/board-sam9m10g45ek.c
@@ -24,11 +24,13 @@
24#include <linux/gpio_keys.h> 24#include <linux/gpio_keys.h>
25#include <linux/input.h> 25#include <linux/input.h>
26#include <linux/leds.h> 26#include <linux/leds.h>
27#include <linux/clk.h>
28#include <linux/atmel-mci.h> 27#include <linux/atmel-mci.h>
28#include <linux/delay.h>
29 29
30#include <mach/hardware.h> 30#include <mach/hardware.h>
31#include <video/atmel_lcdc.h> 31#include <video/atmel_lcdc.h>
32#include <media/soc_camera.h>
33#include <media/atmel-isi.h>
32 34
33#include <asm/setup.h> 35#include <asm/setup.h>
34#include <asm/mach-types.h> 36#include <asm/mach-types.h>
@@ -146,6 +148,8 @@ static struct atmel_nand_data __initdata ek_nand_data = {
146 .rdy_pin = AT91_PIN_PC8, 148 .rdy_pin = AT91_PIN_PC8,
147 .enable_pin = AT91_PIN_PC14, 149 .enable_pin = AT91_PIN_PC14,
148 .det_pin = -EINVAL, 150 .det_pin = -EINVAL,
151 .ecc_mode = NAND_ECC_SOFT,
152 .on_flash_bbt = 1,
149 .parts = ek_nand_partition, 153 .parts = ek_nand_partition,
150 .num_parts = ARRAY_SIZE(ek_nand_partition), 154 .num_parts = ARRAY_SIZE(ek_nand_partition),
151}; 155};
@@ -185,6 +189,71 @@ static void __init ek_add_device_nand(void)
185 189
186 190
187/* 191/*
192 * ISI
193 */
194static struct isi_platform_data __initdata isi_data = {
195 .frate = ISI_CFG1_FRATE_CAPTURE_ALL,
196 /* to use codec and preview path simultaneously */
197 .full_mode = 1,
198 .data_width_flags = ISI_DATAWIDTH_8 | ISI_DATAWIDTH_10,
199 /* ISI_MCK is provided by programmable clock or external clock */
200 .mck_hz = 25000000,
201};
202
203
204/*
205 * soc-camera OV2640
206 */
207#if defined(CONFIG_SOC_CAMERA_OV2640) || \
208 defined(CONFIG_SOC_CAMERA_OV2640_MODULE)
209static unsigned long isi_camera_query_bus_param(struct soc_camera_link *link)
210{
211 /* ISI board for ek using default 8-bits connection */
212 return SOCAM_DATAWIDTH_8;
213}
214
215static int i2c_camera_power(struct device *dev, int on)
216{
217 /* enable or disable the camera */
218 pr_debug("%s: %s the camera\n", __func__, on ? "ENABLE" : "DISABLE");
219 at91_set_gpio_output(AT91_PIN_PD13, !on);
220
221 if (!on)
222 goto out;
223
224 /* If enabled, give a reset impulse */
225 at91_set_gpio_output(AT91_PIN_PD12, 0);
226 msleep(20);
227 at91_set_gpio_output(AT91_PIN_PD12, 1);
228 msleep(100);
229
230out:
231 return 0;
232}
233
234static struct i2c_board_info i2c_camera = {
235 I2C_BOARD_INFO("ov2640", 0x30),
236};
237
238static struct soc_camera_link iclink_ov2640 = {
239 .bus_id = 0,
240 .board_info = &i2c_camera,
241 .i2c_adapter_id = 0,
242 .power = i2c_camera_power,
243 .query_bus_param = isi_camera_query_bus_param,
244};
245
246static struct platform_device isi_ov2640 = {
247 .name = "soc-camera-pdrv",
248 .id = 0,
249 .dev = {
250 .platform_data = &iclink_ov2640,
251 },
252};
253#endif
254
255
256/*
188 * LCD Controller 257 * LCD Controller
189 */ 258 */
190#if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE) 259#if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
@@ -377,7 +446,12 @@ static struct gpio_led ek_pwm_led[] = {
377#endif 446#endif
378}; 447};
379 448
380 449static struct platform_device *devices[] __initdata = {
450#if defined(CONFIG_SOC_CAMERA_OV2640) || \
451 defined(CONFIG_SOC_CAMERA_OV2640_MODULE)
452 &isi_ov2640,
453#endif
454};
381 455
382static void __init ek_board_init(void) 456static void __init ek_board_init(void)
383{ 457{
@@ -399,6 +473,8 @@ static void __init ek_board_init(void)
399 ek_add_device_nand(); 473 ek_add_device_nand();
400 /* I2C */ 474 /* I2C */
401 at91_add_device_i2c(0, NULL, 0); 475 at91_add_device_i2c(0, NULL, 0);
476 /* ISI, using programmable clock as ISI_MCK */
477 at91_add_device_isi(&isi_data, true);
402 /* LCD Controller */ 478 /* LCD Controller */
403 at91_add_device_lcdc(&ek_lcdc_data); 479 at91_add_device_lcdc(&ek_lcdc_data);
404 /* Touch Screen */ 480 /* Touch Screen */
@@ -410,6 +486,8 @@ static void __init ek_board_init(void)
410 /* LEDs */ 486 /* LEDs */
411 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds)); 487 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
412 at91_pwm_leds(ek_pwm_led, ARRAY_SIZE(ek_pwm_led)); 488 at91_pwm_leds(ek_pwm_led, ARRAY_SIZE(ek_pwm_led));
489 /* Other platform devices */
490 platform_add_devices(devices, ARRAY_SIZE(devices));
413} 491}
414 492
415MACHINE_START(AT91SAM9M10G45EK, "Atmel AT91SAM9M10G45-EK") 493MACHINE_START(AT91SAM9M10G45EK, "Atmel AT91SAM9M10G45-EK")
diff --git a/arch/arm/mach-at91/board-sam9rlek.c b/arch/arm/mach-at91/board-sam9rlek.c
index c1366d0032b..b109ce2ba86 100644
--- a/arch/arm/mach-at91/board-sam9rlek.c
+++ b/arch/arm/mach-at91/board-sam9rlek.c
@@ -94,6 +94,8 @@ static struct atmel_nand_data __initdata ek_nand_data = {
94 .det_pin = -EINVAL, 94 .det_pin = -EINVAL,
95 .rdy_pin = AT91_PIN_PD17, 95 .rdy_pin = AT91_PIN_PD17,
96 .enable_pin = AT91_PIN_PB6, 96 .enable_pin = AT91_PIN_PB6,
97 .ecc_mode = NAND_ECC_SOFT,
98 .on_flash_bbt = 1,
97 .parts = ek_nand_partition, 99 .parts = ek_nand_partition,
98 .num_parts = ARRAY_SIZE(ek_nand_partition), 100 .num_parts = ARRAY_SIZE(ek_nand_partition),
99}; 101};
diff --git a/arch/arm/mach-at91/board-snapper9260.c b/arch/arm/mach-at91/board-snapper9260.c
index 4770db08e5a..ebc9d01ce74 100644
--- a/arch/arm/mach-at91/board-snapper9260.c
+++ b/arch/arm/mach-at91/board-snapper9260.c
@@ -110,6 +110,7 @@ static struct atmel_nand_data __initdata snapper9260_nand_data = {
110 .bus_width_16 = 0, 110 .bus_width_16 = 0,
111 .enable_pin = -EINVAL, 111 .enable_pin = -EINVAL,
112 .det_pin = -EINVAL, 112 .det_pin = -EINVAL,
113 .ecc_mode = NAND_ECC_SOFT,
113}; 114};
114 115
115static struct sam9_smc_config __initdata snapper9260_nand_smc_config = { 116static struct sam9_smc_config __initdata snapper9260_nand_smc_config = {
@@ -145,11 +146,11 @@ static struct i2c_board_info __initdata snapper9260_i2c_devices[] = {
145 /* Audio codec */ 146 /* Audio codec */
146 I2C_BOARD_INFO("tlv320aic23", 0x1a), 147 I2C_BOARD_INFO("tlv320aic23", 0x1a),
147 }, 148 },
148 { 149};
150
151static struct i2c_board_info __initdata snapper9260_i2c_isl1208 = {
149 /* RTC */ 152 /* RTC */
150 I2C_BOARD_INFO("isl1208", 0x6f), 153 I2C_BOARD_INFO("isl1208", 0x6f),
151 .irq = gpio_to_irq(AT91_PIN_PA31),
152 },
153}; 154};
154 155
155static void __init snapper9260_add_device_nand(void) 156static void __init snapper9260_add_device_nand(void)
@@ -163,6 +164,10 @@ static void __init snapper9260_board_init(void)
163{ 164{
164 at91_add_device_i2c(snapper9260_i2c_devices, 165 at91_add_device_i2c(snapper9260_i2c_devices,
165 ARRAY_SIZE(snapper9260_i2c_devices)); 166 ARRAY_SIZE(snapper9260_i2c_devices));
167
168 snapper9260_i2c_isl1208.irq = gpio_to_irq(AT91_PIN_PA31);
169 i2c_register_board_info(0, &snapper9260_i2c_isl1208, 1);
170
166 at91_add_device_serial(); 171 at91_add_device_serial();
167 at91_add_device_usbh(&snapper9260_usbh_data); 172 at91_add_device_usbh(&snapper9260_usbh_data);
168 at91_add_device_udc(&snapper9260_udc_data); 173 at91_add_device_udc(&snapper9260_udc_data);
diff --git a/arch/arm/mach-at91/board-stamp9g20.c b/arch/arm/mach-at91/board-stamp9g20.c
index 72eb3b4d9ab..7640049410a 100644
--- a/arch/arm/mach-at91/board-stamp9g20.c
+++ b/arch/arm/mach-at91/board-stamp9g20.c
@@ -86,6 +86,7 @@ static struct atmel_nand_data __initdata nand_data = {
86 .enable_pin = AT91_PIN_PC14, 86 .enable_pin = AT91_PIN_PC14,
87 .bus_width_16 = 0, 87 .bus_width_16 = 0,
88 .det_pin = -EINVAL, 88 .det_pin = -EINVAL,
89 .ecc_mode = NAND_ECC_SOFT,
89}; 90};
90 91
91static struct sam9_smc_config __initdata nand_smc_config = { 92static struct sam9_smc_config __initdata nand_smc_config = {
diff --git a/arch/arm/mach-at91/board-usb-a926x.c b/arch/arm/mach-at91/board-usb-a926x.c
index 26c36fc2d1e..b7483a3d098 100644
--- a/arch/arm/mach-at91/board-usb-a926x.c
+++ b/arch/arm/mach-at91/board-usb-a926x.c
@@ -198,6 +198,8 @@ static struct atmel_nand_data __initdata ek_nand_data = {
198 .det_pin = -EINVAL, 198 .det_pin = -EINVAL,
199 .rdy_pin = AT91_PIN_PA22, 199 .rdy_pin = AT91_PIN_PA22,
200 .enable_pin = AT91_PIN_PD15, 200 .enable_pin = AT91_PIN_PD15,
201 .ecc_mode = NAND_ECC_SOFT,
202 .on_flash_bbt = 1,
201 .parts = ek_nand_partition, 203 .parts = ek_nand_partition,
202 .num_parts = ARRAY_SIZE(ek_nand_partition), 204 .num_parts = ARRAY_SIZE(ek_nand_partition),
203}; 205};
diff --git a/arch/arm/mach-at91/board-yl-9200.c b/arch/arm/mach-at91/board-yl-9200.c
index bbd553e1cd9..38dd279d30b 100644
--- a/arch/arm/mach-at91/board-yl-9200.c
+++ b/arch/arm/mach-at91/board-yl-9200.c
@@ -45,6 +45,7 @@
45#include <mach/hardware.h> 45#include <mach/hardware.h>
46#include <mach/board.h> 46#include <mach/board.h>
47#include <mach/at91rm9200_mc.h> 47#include <mach/at91rm9200_mc.h>
48#include <mach/at91_ramc.h>
48#include <mach/cpu.h> 49#include <mach/cpu.h>
49 50
50#include "generic.h" 51#include "generic.h"
@@ -181,6 +182,7 @@ static struct atmel_nand_data __initdata yl9200_nand_data = {
181 .det_pin = -EINVAL, 182 .det_pin = -EINVAL,
182 .rdy_pin = AT91_PIN_PC14, /* R/!B (Sheet10) */ 183 .rdy_pin = AT91_PIN_PC14, /* R/!B (Sheet10) */
183 .enable_pin = AT91_PIN_PC15, /* !CE (Sheet10) */ 184 .enable_pin = AT91_PIN_PC15, /* !CE (Sheet10) */
185 .ecc_mode = NAND_ECC_SOFT,
184 .parts = yl9200_nand_partition, 186 .parts = yl9200_nand_partition,
185 .num_parts = ARRAY_SIZE(yl9200_nand_partition), 187 .num_parts = ARRAY_SIZE(yl9200_nand_partition),
186}; 188};
@@ -393,7 +395,7 @@ static void yl9200_init_video(void)
393 at91_set_A_periph(AT91_PIN_PC6, 0); 395 at91_set_A_periph(AT91_PIN_PC6, 0);
394 396
395 /* Initialization of the Static Memory Controller for Chip Select 2 */ 397 /* Initialization of the Static Memory Controller for Chip Select 2 */
396 at91_sys_write(AT91_SMC_CSR(2), AT91_SMC_DBW_16 /* 16 bit */ 398 at91_ramc_write(0, AT91_SMC_CSR(2), AT91_SMC_DBW_16 /* 16 bit */
397 | AT91_SMC_WSEN | AT91_SMC_NWS_(0x4) /* wait states */ 399 | AT91_SMC_WSEN | AT91_SMC_NWS_(0x4) /* wait states */
398 | AT91_SMC_TDF_(0x100) /* float time */ 400 | AT91_SMC_TDF_(0x100) /* float time */
399 ); 401 );
diff --git a/arch/arm/mach-at91/clock.c b/arch/arm/mach-at91/clock.c
index 61873f3aa92..a0f4d7424cd 100644
--- a/arch/arm/mach-at91/clock.c
+++ b/arch/arm/mach-at91/clock.c
@@ -23,14 +23,18 @@
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/clk.h> 24#include <linux/clk.h>
25#include <linux/io.h> 25#include <linux/io.h>
26#include <linux/of_address.h>
26 27
27#include <mach/hardware.h> 28#include <mach/hardware.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
32#include <asm/proc-fns.h>
33
31#include "clock.h" 34#include "clock.h"
32#include "generic.h" 35#include "generic.h"
33 36
37void __iomem *at91_pmc_base;
34 38
35/* 39/*
36 * There's a lot more which can be done with clocks, including cpufreq 40 * There's a lot more which can be done with clocks, including cpufreq
@@ -47,26 +51,38 @@
47/* 51/*
48 * Chips have some kind of clocks : group them by functionality 52 * Chips have some kind of clocks : group them by functionality
49 */ 53 */
50#define cpu_has_utmi() ( cpu_is_at91cap9() \ 54#define cpu_has_utmi() ( cpu_is_at91sam9rl() \
51 || cpu_is_at91sam9rl() \ 55 || cpu_is_at91sam9g45() \
52 || cpu_is_at91sam9g45()) 56 || cpu_is_at91sam9x5())
53 57
54#define cpu_has_800M_plla() ( cpu_is_at91sam9g20() \ 58#define cpu_has_800M_plla() ( cpu_is_at91sam9g20() \
55 || cpu_is_at91sam9g45()) 59 || cpu_is_at91sam9g45() \
60 || cpu_is_at91sam9x5())
56 61
57#define cpu_has_300M_plla() (cpu_is_at91sam9g10()) 62#define cpu_has_300M_plla() (cpu_is_at91sam9g10())
58 63
59#define cpu_has_pllb() (!(cpu_is_at91sam9rl() \ 64#define cpu_has_pllb() (!(cpu_is_at91sam9rl() \
60 || cpu_is_at91sam9g45())) 65 || cpu_is_at91sam9g45() \
66 || cpu_is_at91sam9x5()))
61 67
62#define cpu_has_upll() (cpu_is_at91sam9g45()) 68#define cpu_has_upll() (cpu_is_at91sam9g45() \
69 || cpu_is_at91sam9x5())
63 70
64/* USB host HS & FS */ 71/* USB host HS & FS */
65#define cpu_has_uhp() (!cpu_is_at91sam9rl()) 72#define cpu_has_uhp() (!cpu_is_at91sam9rl())
66 73
67/* USB device FS only */ 74/* USB device FS only */
68#define cpu_has_udpfs() (!(cpu_is_at91sam9rl() \ 75#define cpu_has_udpfs() (!(cpu_is_at91sam9rl() \
69 || cpu_is_at91sam9g45())) 76 || cpu_is_at91sam9g45() \
77 || cpu_is_at91sam9x5()))
78
79#define cpu_has_plladiv2() (cpu_is_at91sam9g45() \
80 || cpu_is_at91sam9x5())
81
82#define cpu_has_mdiv3() (cpu_is_at91sam9g45() \
83 || cpu_is_at91sam9x5())
84
85#define cpu_has_alt_prescaler() (cpu_is_at91sam9x5())
70 86
71static LIST_HEAD(clocks); 87static LIST_HEAD(clocks);
72static DEFINE_SPINLOCK(clk_lock); 88static DEFINE_SPINLOCK(clk_lock);
@@ -111,11 +127,11 @@ static void pllb_mode(struct clk *clk, int is_on)
111 value = 0; 127 value = 0;
112 128
113 // REVISIT: Add work-around for AT91RM9200 Errata #26 ? 129 // REVISIT: Add work-around for AT91RM9200 Errata #26 ?
114 at91_sys_write(AT91_CKGR_PLLBR, value); 130 at91_pmc_write(AT91_CKGR_PLLBR, value);
115 131
116 do { 132 do {
117 cpu_relax(); 133 cpu_relax();
118 } while ((at91_sys_read(AT91_PMC_SR) & AT91_PMC_LOCKB) != is_on); 134 } while ((at91_pmc_read(AT91_PMC_SR) & AT91_PMC_LOCKB) != is_on);
119} 135}
120 136
121static struct clk pllb = { 137static struct clk pllb = {
@@ -130,31 +146,24 @@ static struct clk pllb = {
130static void pmc_sys_mode(struct clk *clk, int is_on) 146static void pmc_sys_mode(struct clk *clk, int is_on)
131{ 147{
132 if (is_on) 148 if (is_on)
133 at91_sys_write(AT91_PMC_SCER, clk->pmc_mask); 149 at91_pmc_write(AT91_PMC_SCER, clk->pmc_mask);
134 else 150 else
135 at91_sys_write(AT91_PMC_SCDR, clk->pmc_mask); 151 at91_pmc_write(AT91_PMC_SCDR, clk->pmc_mask);
136} 152}
137 153
138static void pmc_uckr_mode(struct clk *clk, int is_on) 154static void pmc_uckr_mode(struct clk *clk, int is_on)
139{ 155{
140 unsigned int uckr = at91_sys_read(AT91_CKGR_UCKR); 156 unsigned int uckr = at91_pmc_read(AT91_CKGR_UCKR);
141
142 if (cpu_is_at91sam9g45()) {
143 if (is_on)
144 uckr |= AT91_PMC_BIASEN;
145 else
146 uckr &= ~AT91_PMC_BIASEN;
147 }
148 157
149 if (is_on) { 158 if (is_on) {
150 is_on = AT91_PMC_LOCKU; 159 is_on = AT91_PMC_LOCKU;
151 at91_sys_write(AT91_CKGR_UCKR, uckr | clk->pmc_mask); 160 at91_pmc_write(AT91_CKGR_UCKR, uckr | clk->pmc_mask);
152 } else 161 } else
153 at91_sys_write(AT91_CKGR_UCKR, uckr & ~(clk->pmc_mask)); 162 at91_pmc_write(AT91_CKGR_UCKR, uckr & ~(clk->pmc_mask));
154 163
155 do { 164 do {
156 cpu_relax(); 165 cpu_relax();
157 } while ((at91_sys_read(AT91_PMC_SR) & AT91_PMC_LOCKU) != is_on); 166 } while ((at91_pmc_read(AT91_PMC_SR) & AT91_PMC_LOCKU) != is_on);
158} 167}
159 168
160/* USB function clocks (PLLB must be 48 MHz) */ 169/* USB function clocks (PLLB must be 48 MHz) */
@@ -190,9 +199,9 @@ struct clk mck = {
190static void pmc_periph_mode(struct clk *clk, int is_on) 199static void pmc_periph_mode(struct clk *clk, int is_on)
191{ 200{
192 if (is_on) 201 if (is_on)
193 at91_sys_write(AT91_PMC_PCER, clk->pmc_mask); 202 at91_pmc_write(AT91_PMC_PCER, clk->pmc_mask);
194 else 203 else
195 at91_sys_write(AT91_PMC_PCDR, clk->pmc_mask); 204 at91_pmc_write(AT91_PMC_PCDR, clk->pmc_mask);
196} 205}
197 206
198static struct clk __init *at91_css_to_clk(unsigned long css) 207static struct clk __init *at91_css_to_clk(unsigned long css)
@@ -210,11 +219,24 @@ static struct clk __init *at91_css_to_clk(unsigned long css)
210 return &utmi_clk; 219 return &utmi_clk;
211 else if (cpu_has_pllb()) 220 else if (cpu_has_pllb())
212 return &pllb; 221 return &pllb;
222 break;
223 /* alternate PMC: can use master clock */
224 case AT91_PMC_CSS_MASTER:
225 return &mck;
213 } 226 }
214 227
215 return NULL; 228 return NULL;
216} 229}
217 230
231static int pmc_prescaler_divider(u32 reg)
232{
233 if (cpu_has_alt_prescaler()) {
234 return 1 << ((reg & AT91_PMC_ALT_PRES) >> PMC_ALT_PRES_OFFSET);
235 } else {
236 return 1 << ((reg & AT91_PMC_PRES) >> PMC_PRES_OFFSET);
237 }
238}
239
218static void __clk_enable(struct clk *clk) 240static void __clk_enable(struct clk *clk)
219{ 241{
220 if (clk->parent) 242 if (clk->parent)
@@ -316,12 +338,22 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
316{ 338{
317 unsigned long flags; 339 unsigned long flags;
318 unsigned prescale; 340 unsigned prescale;
341 unsigned long prescale_offset, css_mask;
319 unsigned long actual; 342 unsigned long actual;
320 343
321 if (!clk_is_programmable(clk)) 344 if (!clk_is_programmable(clk))
322 return -EINVAL; 345 return -EINVAL;
323 if (clk->users) 346 if (clk->users)
324 return -EBUSY; 347 return -EBUSY;
348
349 if (cpu_has_alt_prescaler()) {
350 prescale_offset = PMC_ALT_PRES_OFFSET;
351 css_mask = AT91_PMC_ALT_PCKR_CSS;
352 } else {
353 prescale_offset = PMC_PRES_OFFSET;
354 css_mask = AT91_PMC_CSS;
355 }
356
325 spin_lock_irqsave(&clk_lock, flags); 357 spin_lock_irqsave(&clk_lock, flags);
326 358
327 actual = clk->parent->rate_hz; 359 actual = clk->parent->rate_hz;
@@ -329,10 +361,10 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
329 if (actual && actual <= rate) { 361 if (actual && actual <= rate) {
330 u32 pckr; 362 u32 pckr;
331 363
332 pckr = at91_sys_read(AT91_PMC_PCKR(clk->id)); 364 pckr = at91_pmc_read(AT91_PMC_PCKR(clk->id));
333 pckr &= AT91_PMC_CSS; /* clock selection */ 365 pckr &= css_mask; /* keep clock selection */
334 pckr |= prescale << 2; 366 pckr |= prescale << prescale_offset;
335 at91_sys_write(AT91_PMC_PCKR(clk->id), pckr); 367 at91_pmc_write(AT91_PMC_PCKR(clk->id), pckr);
336 clk->rate_hz = actual; 368 clk->rate_hz = actual;
337 break; 369 break;
338 } 370 }
@@ -366,7 +398,7 @@ int clk_set_parent(struct clk *clk, struct clk *parent)
366 398
367 clk->rate_hz = parent->rate_hz; 399 clk->rate_hz = parent->rate_hz;
368 clk->parent = parent; 400 clk->parent = parent;
369 at91_sys_write(AT91_PMC_PCKR(clk->id), parent->id); 401 at91_pmc_write(AT91_PMC_PCKR(clk->id), parent->id);
370 402
371 spin_unlock_irqrestore(&clk_lock, flags); 403 spin_unlock_irqrestore(&clk_lock, flags);
372 return 0; 404 return 0;
@@ -378,11 +410,17 @@ static void __init init_programmable_clock(struct clk *clk)
378{ 410{
379 struct clk *parent; 411 struct clk *parent;
380 u32 pckr; 412 u32 pckr;
413 unsigned int css_mask;
414
415 if (cpu_has_alt_prescaler())
416 css_mask = AT91_PMC_ALT_PCKR_CSS;
417 else
418 css_mask = AT91_PMC_CSS;
381 419
382 pckr = at91_sys_read(AT91_PMC_PCKR(clk->id)); 420 pckr = at91_pmc_read(AT91_PMC_PCKR(clk->id));
383 parent = at91_css_to_clk(pckr & AT91_PMC_CSS); 421 parent = at91_css_to_clk(pckr & css_mask);
384 clk->parent = parent; 422 clk->parent = parent;
385 clk->rate_hz = parent->rate_hz / (1 << ((pckr & AT91_PMC_PRES) >> 2)); 423 clk->rate_hz = parent->rate_hz / pmc_prescaler_divider(pckr);
386} 424}
387 425
388#endif /* CONFIG_AT91_PROGRAMMABLE_CLOCKS */ 426#endif /* CONFIG_AT91_PROGRAMMABLE_CLOCKS */
@@ -396,19 +434,24 @@ static int at91_clk_show(struct seq_file *s, void *unused)
396 u32 scsr, pcsr, uckr = 0, sr; 434 u32 scsr, pcsr, uckr = 0, sr;
397 struct clk *clk; 435 struct clk *clk;
398 436
399 seq_printf(s, "SCSR = %8x\n", scsr = at91_sys_read(AT91_PMC_SCSR)); 437 scsr = at91_pmc_read(AT91_PMC_SCSR);
400 seq_printf(s, "PCSR = %8x\n", pcsr = at91_sys_read(AT91_PMC_PCSR)); 438 pcsr = at91_pmc_read(AT91_PMC_PCSR);
401 seq_printf(s, "MOR = %8x\n", at91_sys_read(AT91_CKGR_MOR)); 439 sr = at91_pmc_read(AT91_PMC_SR);
402 seq_printf(s, "MCFR = %8x\n", at91_sys_read(AT91_CKGR_MCFR)); 440 seq_printf(s, "SCSR = %8x\n", scsr);
403 seq_printf(s, "PLLA = %8x\n", at91_sys_read(AT91_CKGR_PLLAR)); 441 seq_printf(s, "PCSR = %8x\n", pcsr);
442 seq_printf(s, "MOR = %8x\n", at91_pmc_read(AT91_CKGR_MOR));
443 seq_printf(s, "MCFR = %8x\n", at91_pmc_read(AT91_CKGR_MCFR));
444 seq_printf(s, "PLLA = %8x\n", at91_pmc_read(AT91_CKGR_PLLAR));
404 if (cpu_has_pllb()) 445 if (cpu_has_pllb())
405 seq_printf(s, "PLLB = %8x\n", at91_sys_read(AT91_CKGR_PLLBR)); 446 seq_printf(s, "PLLB = %8x\n", at91_pmc_read(AT91_CKGR_PLLBR));
406 if (cpu_has_utmi()) 447 if (cpu_has_utmi()) {
407 seq_printf(s, "UCKR = %8x\n", uckr = at91_sys_read(AT91_CKGR_UCKR)); 448 uckr = at91_pmc_read(AT91_CKGR_UCKR);
408 seq_printf(s, "MCKR = %8x\n", at91_sys_read(AT91_PMC_MCKR)); 449 seq_printf(s, "UCKR = %8x\n", uckr);
450 }
451 seq_printf(s, "MCKR = %8x\n", at91_pmc_read(AT91_PMC_MCKR));
409 if (cpu_has_upll()) 452 if (cpu_has_upll())
410 seq_printf(s, "USB = %8x\n", at91_sys_read(AT91_PMC_USB)); 453 seq_printf(s, "USB = %8x\n", at91_pmc_read(AT91_PMC_USB));
411 seq_printf(s, "SR = %8x\n", sr = at91_sys_read(AT91_PMC_SR)); 454 seq_printf(s, "SR = %8x\n", sr);
412 455
413 seq_printf(s, "\n"); 456 seq_printf(s, "\n");
414 457
@@ -596,16 +639,14 @@ static void __init at91_pllb_usbfs_clock_init(unsigned long main_clock)
596 if (cpu_is_at91rm9200()) { 639 if (cpu_is_at91rm9200()) {
597 uhpck.pmc_mask = AT91RM9200_PMC_UHP; 640 uhpck.pmc_mask = AT91RM9200_PMC_UHP;
598 udpck.pmc_mask = AT91RM9200_PMC_UDP; 641 udpck.pmc_mask = AT91RM9200_PMC_UDP;
599 at91_sys_write(AT91_PMC_SCER, AT91RM9200_PMC_MCKUDP); 642 at91_pmc_write(AT91_PMC_SCER, AT91RM9200_PMC_MCKUDP);
600 } else if (cpu_is_at91sam9260() || cpu_is_at91sam9261() || 643 } else if (cpu_is_at91sam9260() || cpu_is_at91sam9261() ||
601 cpu_is_at91sam9263() || cpu_is_at91sam9g20() || 644 cpu_is_at91sam9263() || cpu_is_at91sam9g20() ||
602 cpu_is_at91sam9g10()) { 645 cpu_is_at91sam9g10()) {
603 uhpck.pmc_mask = AT91SAM926x_PMC_UHP; 646 uhpck.pmc_mask = AT91SAM926x_PMC_UHP;
604 udpck.pmc_mask = AT91SAM926x_PMC_UDP; 647 udpck.pmc_mask = AT91SAM926x_PMC_UDP;
605 } else if (cpu_is_at91cap9()) {
606 uhpck.pmc_mask = AT91CAP9_PMC_UHP;
607 } 648 }
608 at91_sys_write(AT91_CKGR_PLLBR, 0); 649 at91_pmc_write(AT91_CKGR_PLLBR, 0);
609 650
610 udpck.rate_hz = at91_usb_rate(&pllb, pllb.rate_hz, at91_pllb_usb_init); 651 udpck.rate_hz = at91_usb_rate(&pllb, pllb.rate_hz, at91_pllb_usb_init);
611 uhpck.rate_hz = at91_usb_rate(&pllb, pllb.rate_hz, at91_pllb_usb_init); 652 uhpck.rate_hz = at91_usb_rate(&pllb, pllb.rate_hz, at91_pllb_usb_init);
@@ -622,16 +663,16 @@ static void __init at91_upll_usbfs_clock_init(unsigned long main_clock)
622 /* Setup divider by 10 to reach 48 MHz */ 663 /* Setup divider by 10 to reach 48 MHz */
623 usbr |= ((10 - 1) << 8) & AT91_PMC_OHCIUSBDIV; 664 usbr |= ((10 - 1) << 8) & AT91_PMC_OHCIUSBDIV;
624 665
625 at91_sys_write(AT91_PMC_USB, usbr); 666 at91_pmc_write(AT91_PMC_USB, usbr);
626 667
627 /* Now set uhpck values */ 668 /* Now set uhpck values */
628 uhpck.parent = &utmi_clk; 669 uhpck.parent = &utmi_clk;
629 uhpck.pmc_mask = AT91SAM926x_PMC_UHP; 670 uhpck.pmc_mask = AT91SAM926x_PMC_UHP;
630 uhpck.rate_hz = utmi_clk.rate_hz; 671 uhpck.rate_hz = utmi_clk.rate_hz;
631 uhpck.rate_hz /= 1 + ((at91_sys_read(AT91_PMC_USB) & AT91_PMC_OHCIUSBDIV) >> 8); 672 uhpck.rate_hz /= 1 + ((at91_pmc_read(AT91_PMC_USB) & AT91_PMC_OHCIUSBDIV) >> 8);
632} 673}
633 674
634int __init at91_clock_init(unsigned long main_clock) 675static int __init at91_pmc_init(unsigned long main_clock)
635{ 676{
636 unsigned tmp, freq, mckr; 677 unsigned tmp, freq, mckr;
637 int i; 678 int i;
@@ -645,14 +686,14 @@ int __init at91_clock_init(unsigned long main_clock)
645 */ 686 */
646 if (!main_clock) { 687 if (!main_clock) {
647 do { 688 do {
648 tmp = at91_sys_read(AT91_CKGR_MCFR); 689 tmp = at91_pmc_read(AT91_CKGR_MCFR);
649 } while (!(tmp & AT91_PMC_MAINRDY)); 690 } while (!(tmp & AT91_PMC_MAINRDY));
650 main_clock = (tmp & AT91_PMC_MAINF) * (AT91_SLOW_CLOCK / 16); 691 main_clock = (tmp & AT91_PMC_MAINF) * (AT91_SLOW_CLOCK / 16);
651 } 692 }
652 main_clk.rate_hz = main_clock; 693 main_clk.rate_hz = main_clock;
653 694
654 /* report if PLLA is more than mildly overclocked */ 695 /* report if PLLA is more than mildly overclocked */
655 plla.rate_hz = at91_pll_rate(&plla, main_clock, at91_sys_read(AT91_CKGR_PLLAR)); 696 plla.rate_hz = at91_pll_rate(&plla, main_clock, at91_pmc_read(AT91_CKGR_PLLAR));
656 if (cpu_has_300M_plla()) { 697 if (cpu_has_300M_plla()) {
657 if (plla.rate_hz > 300000000) 698 if (plla.rate_hz > 300000000)
658 pll_overclock = true; 699 pll_overclock = true;
@@ -666,8 +707,8 @@ int __init at91_clock_init(unsigned long main_clock)
666 if (pll_overclock) 707 if (pll_overclock)
667 pr_info("Clocks: PLLA overclocked, %ld MHz\n", plla.rate_hz / 1000000); 708 pr_info("Clocks: PLLA overclocked, %ld MHz\n", plla.rate_hz / 1000000);
668 709
669 if (cpu_is_at91sam9g45()) { 710 if (cpu_has_plladiv2()) {
670 mckr = at91_sys_read(AT91_PMC_MCKR); 711 mckr = at91_pmc_read(AT91_PMC_MCKR);
671 plla.rate_hz /= (1 << ((mckr & AT91_PMC_PLLADIV2) >> 12)); /* plla divisor by 2 */ 712 plla.rate_hz /= (1 << ((mckr & AT91_PMC_PLLADIV2) >> 12)); /* plla divisor by 2 */
672 } 713 }
673 714
@@ -688,6 +729,10 @@ int __init at91_clock_init(unsigned long main_clock)
688 * (obtain the USB High Speed 480 MHz when input is 12 MHz) 729 * (obtain the USB High Speed 480 MHz when input is 12 MHz)
689 */ 730 */
690 utmi_clk.rate_hz = 40 * utmi_clk.parent->rate_hz; 731 utmi_clk.rate_hz = 40 * utmi_clk.parent->rate_hz;
732
733 /* UTMI bias and PLL are managed at the same time */
734 if (cpu_has_upll())
735 utmi_clk.pmc_mask |= AT91_PMC_BIASEN;
691 } 736 }
692 737
693 /* 738 /*
@@ -703,10 +748,10 @@ int __init at91_clock_init(unsigned long main_clock)
703 * MCK and CPU derive from one of those primary clocks. 748 * MCK and CPU derive from one of those primary clocks.
704 * For now, assume this parentage won't change. 749 * For now, assume this parentage won't change.
705 */ 750 */
706 mckr = at91_sys_read(AT91_PMC_MCKR); 751 mckr = at91_pmc_read(AT91_PMC_MCKR);
707 mck.parent = at91_css_to_clk(mckr & AT91_PMC_CSS); 752 mck.parent = at91_css_to_clk(mckr & AT91_PMC_CSS);
708 freq = mck.parent->rate_hz; 753 freq = mck.parent->rate_hz;
709 freq /= (1 << ((mckr & AT91_PMC_PRES) >> 2)); /* prescale */ 754 freq /= pmc_prescaler_divider(mckr); /* prescale */
710 if (cpu_is_at91rm9200()) { 755 if (cpu_is_at91rm9200()) {
711 mck.rate_hz = freq / (1 + ((mckr & AT91_PMC_MDIV) >> 8)); /* mdiv */ 756 mck.rate_hz = freq / (1 + ((mckr & AT91_PMC_MDIV) >> 8)); /* mdiv */
712 } else if (cpu_is_at91sam9g20()) { 757 } else if (cpu_is_at91sam9g20()) {
@@ -714,13 +759,19 @@ int __init at91_clock_init(unsigned long main_clock)
714 freq / ((mckr & AT91_PMC_MDIV) >> 7) : freq; /* mdiv ; (x >> 7) = ((x >> 8) * 2) */ 759 freq / ((mckr & AT91_PMC_MDIV) >> 7) : freq; /* mdiv ; (x >> 7) = ((x >> 8) * 2) */
715 if (mckr & AT91_PMC_PDIV) 760 if (mckr & AT91_PMC_PDIV)
716 freq /= 2; /* processor clock division */ 761 freq /= 2; /* processor clock division */
717 } else if (cpu_is_at91sam9g45()) { 762 } else if (cpu_has_mdiv3()) {
718 mck.rate_hz = (mckr & AT91_PMC_MDIV) == AT91SAM9_PMC_MDIV_3 ? 763 mck.rate_hz = (mckr & AT91_PMC_MDIV) == AT91SAM9_PMC_MDIV_3 ?
719 freq / 3 : freq / (1 << ((mckr & AT91_PMC_MDIV) >> 8)); /* mdiv */ 764 freq / 3 : freq / (1 << ((mckr & AT91_PMC_MDIV) >> 8)); /* mdiv */
720 } else { 765 } else {
721 mck.rate_hz = freq / (1 << ((mckr & AT91_PMC_MDIV) >> 8)); /* mdiv */ 766 mck.rate_hz = freq / (1 << ((mckr & AT91_PMC_MDIV) >> 8)); /* mdiv */
722 } 767 }
723 768
769 if (cpu_has_alt_prescaler()) {
770 /* Programmable clocks can use MCK */
771 mck.type |= CLK_TYPE_PRIMARY;
772 mck.id = 4;
773 }
774
724 /* Register the PMC's standard clocks */ 775 /* Register the PMC's standard clocks */
725 for (i = 0; i < ARRAY_SIZE(standard_pmc_clocks); i++) 776 for (i = 0; i < ARRAY_SIZE(standard_pmc_clocks); i++)
726 at91_clk_add(standard_pmc_clocks[i]); 777 at91_clk_add(standard_pmc_clocks[i]);
@@ -748,6 +799,55 @@ int __init at91_clock_init(unsigned long main_clock)
748 return 0; 799 return 0;
749} 800}
750 801
802#if defined(CONFIG_OF)
803static struct of_device_id pmc_ids[] = {
804 { .compatible = "atmel,at91rm9200-pmc" },
805 { /*sentinel*/ }
806};
807
808static struct of_device_id osc_ids[] = {
809 { .compatible = "atmel,osc" },
810 { /*sentinel*/ }
811};
812
813int __init at91_dt_clock_init(void)
814{
815 struct device_node *np;
816 u32 main_clock = 0;
817
818 np = of_find_matching_node(NULL, pmc_ids);
819 if (!np)
820 panic("unable to find compatible pmc node in dtb\n");
821
822 at91_pmc_base = of_iomap(np, 0);
823 if (!at91_pmc_base)
824 panic("unable to map pmc cpu registers\n");
825
826 of_node_put(np);
827
828 /* retrieve the freqency of fixed clocks from device tree */
829 np = of_find_matching_node(NULL, osc_ids);
830 if (np) {
831 u32 rate;
832 if (!of_property_read_u32(np, "clock-frequency", &rate))
833 main_clock = rate;
834 }
835
836 of_node_put(np);
837
838 return at91_pmc_init(main_clock);
839}
840#endif
841
842int __init at91_clock_init(unsigned long main_clock)
843{
844 at91_pmc_base = ioremap(AT91_PMC, 256);
845 if (!at91_pmc_base)
846 panic("Impossible to ioremap AT91_PMC 0x%x\n", AT91_PMC);
847
848 return at91_pmc_init(main_clock);
849}
850
751/* 851/*
752 * Several unused clocks may be active. Turn them off. 852 * Several unused clocks may be active. Turn them off.
753 */ 853 */
@@ -770,9 +870,15 @@ static int __init at91_clock_reset(void)
770 pr_debug("Clocks: disable unused %s\n", clk->name); 870 pr_debug("Clocks: disable unused %s\n", clk->name);
771 } 871 }
772 872
773 at91_sys_write(AT91_PMC_PCDR, pcdr); 873 at91_pmc_write(AT91_PMC_PCDR, pcdr);
774 at91_sys_write(AT91_PMC_SCDR, scdr); 874 at91_pmc_write(AT91_PMC_SCDR, scdr);
775 875
776 return 0; 876 return 0;
777} 877}
778late_initcall(at91_clock_reset); 878late_initcall(at91_clock_reset);
879
880void at91sam9_idle(void)
881{
882 at91_pmc_write(AT91_PMC_SCDR, AT91_PMC_PCK);
883 cpu_do_idle();
884}
diff --git a/arch/arm/mach-at91/cpuidle.c b/arch/arm/mach-at91/cpuidle.c
index a851e6c9842..555d956b3a5 100644
--- a/arch/arm/mach-at91/cpuidle.c
+++ b/arch/arm/mach-at91/cpuidle.c
@@ -39,20 +39,15 @@ static int at91_enter_idle(struct cpuidle_device *dev,
39{ 39{
40 struct timeval before, after; 40 struct timeval before, after;
41 int idle_time; 41 int idle_time;
42 u32 saved_lpr;
43 42
44 local_irq_disable(); 43 local_irq_disable();
45 do_gettimeofday(&before); 44 do_gettimeofday(&before);
46 if (index == 0) 45 if (index == 0)
47 /* Wait for interrupt state */ 46 /* Wait for interrupt state */
48 cpu_do_idle(); 47 cpu_do_idle();
49 else if (index == 1) { 48 else if (index == 1)
50 asm("b 1f; .align 5; 1:"); 49 at91_standby();
51 asm("mcr p15, 0, r0, c7, c10, 4"); /* drain write buffer */ 50
52 saved_lpr = sdram_selfrefresh_enable();
53 cpu_do_idle();
54 sdram_selfrefresh_disable(saved_lpr);
55 }
56 do_gettimeofday(&after); 51 do_gettimeofday(&after);
57 local_irq_enable(); 52 local_irq_enable();
58 idle_time = (after.tv_sec - before.tv_sec) * USEC_PER_SEC + 53 idle_time = (after.tv_sec - before.tv_sec) * USEC_PER_SEC +
diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h
index 594133451c0..dd9b346c451 100644
--- a/arch/arm/mach-at91/generic.h
+++ b/arch/arm/mach-at91/generic.h
@@ -9,6 +9,7 @@
9 */ 9 */
10 10
11#include <linux/clkdev.h> 11#include <linux/clkdev.h>
12#include <linux/of.h>
12 13
13 /* Map io */ 14 /* Map io */
14extern void __init at91_map_io(void); 15extern void __init at91_map_io(void);
@@ -19,15 +20,20 @@ extern void __init at91_init_sram(int bank, unsigned long base,
19extern void __init at91rm9200_set_type(int type); 20extern void __init at91rm9200_set_type(int type);
20extern void __init at91_initialize(unsigned long main_clock); 21extern void __init at91_initialize(unsigned long main_clock);
21extern void __init at91x40_initialize(unsigned long main_clock); 22extern void __init at91x40_initialize(unsigned long main_clock);
23extern void __init at91_dt_initialize(void);
22 24
23 /* Interrupts */ 25 /* Interrupts */
24extern void __init at91_init_irq_default(void); 26extern void __init at91_init_irq_default(void);
25extern void __init at91_init_interrupts(unsigned int priority[]); 27extern void __init at91_init_interrupts(unsigned int priority[]);
26extern void __init at91x40_init_interrupts(unsigned int priority[]); 28extern void __init at91x40_init_interrupts(unsigned int priority[]);
27extern 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,
31 struct device_node *parent);
32
28 33
29 /* Timer */ 34 /* Timer */
30struct sys_timer; 35struct sys_timer;
36extern void at91rm9200_ioremap_st(u32 addr);
31extern struct sys_timer at91rm9200_timer; 37extern struct sys_timer at91rm9200_timer;
32extern void at91sam926x_ioremap_pit(u32 addr); 38extern void at91sam926x_ioremap_pit(u32 addr);
33extern struct sys_timer at91sam926x_timer; 39extern struct sys_timer at91sam926x_timer;
@@ -45,9 +51,9 @@ extern void __init at91sam9261_set_console_clock(int id);
45extern void __init at91sam9263_set_console_clock(int id); 51extern void __init at91sam9263_set_console_clock(int id);
46extern void __init at91sam9rl_set_console_clock(int id); 52extern void __init at91sam9rl_set_console_clock(int id);
47extern void __init at91sam9g45_set_console_clock(int id); 53extern void __init at91sam9g45_set_console_clock(int id);
48extern void __init at91cap9_set_console_clock(int id);
49#ifdef CONFIG_AT91_PMC_UNIT 54#ifdef CONFIG_AT91_PMC_UNIT
50extern int __init at91_clock_init(unsigned long main_clock); 55extern int __init at91_clock_init(unsigned long main_clock);
56extern int __init at91_dt_clock_init(void);
51#else 57#else
52static int inline at91_clock_init(unsigned long main_clock) { return 0; } 58static int inline at91_clock_init(unsigned long main_clock) { return 0; }
53#endif 59#endif
@@ -57,6 +63,9 @@ struct device;
57extern void at91_irq_suspend(void); 63extern void at91_irq_suspend(void);
58extern void at91_irq_resume(void); 64extern void at91_irq_resume(void);
59 65
66/* idle */
67extern void at91sam9_idle(void);
68
60/* reset */ 69/* reset */
61extern void at91_ioremap_rstc(u32 base_addr); 70extern void at91_ioremap_rstc(u32 base_addr);
62extern void at91sam9_alt_restart(char, const char *); 71extern void at91sam9_alt_restart(char, const char *);
@@ -65,6 +74,12 @@ extern void at91sam9g45_restart(char, const char *);
65/* shutdown */ 74/* shutdown */
66extern void at91_ioremap_shdwc(u32 base_addr); 75extern void at91_ioremap_shdwc(u32 base_addr);
67 76
77/* Matrix */
78extern void at91_ioremap_matrix(u32 base_addr);
79
80/* Ram Controler */
81extern void at91_ioremap_ramc(int id, u32 addr, u32 size);
82
68 /* GPIO */ 83 /* GPIO */
69#define AT91RM9200_PQFP 3 /* AT91RM9200 PQFP package has 3 banks */ 84#define AT91RM9200_PQFP 3 /* AT91RM9200 PQFP package has 3 banks */
70#define AT91RM9200_BGA 4 /* AT91RM9200 BGA package has 4 banks */ 85#define AT91RM9200_BGA 4 /* AT91RM9200 BGA package has 4 banks */
@@ -75,5 +90,7 @@ struct at91_gpio_bank {
75}; 90};
76extern void __init at91_gpio_init(struct at91_gpio_bank *, int nr_banks); 91extern void __init at91_gpio_init(struct at91_gpio_bank *, int nr_banks);
77extern void __init at91_gpio_irq_setup(void); 92extern void __init at91_gpio_irq_setup(void);
93extern int __init at91_gpio_of_irq_setup(struct device_node *node,
94 struct device_node *parent);
78 95
79extern int at91_extern_irq; 96extern int at91_extern_irq;
diff --git a/arch/arm/mach-at91/gpio.c b/arch/arm/mach-at91/gpio.c
index 74d6783eeab..325837a264c 100644
--- a/arch/arm/mach-at91/gpio.c
+++ b/arch/arm/mach-at91/gpio.c
@@ -11,6 +11,7 @@
11 11
12#include <linux/clk.h> 12#include <linux/clk.h>
13#include <linux/errno.h> 13#include <linux/errno.h>
14#include <linux/device.h>
14#include <linux/gpio.h> 15#include <linux/gpio.h>
15#include <linux/interrupt.h> 16#include <linux/interrupt.h>
16#include <linux/irq.h> 17#include <linux/irq.h>
@@ -20,6 +21,10 @@
20#include <linux/list.h> 21#include <linux/list.h>
21#include <linux/module.h> 22#include <linux/module.h>
22#include <linux/io.h> 23#include <linux/io.h>
24#include <linux/irqdomain.h>
25#include <linux/of_address.h>
26#include <linux/of_irq.h>
27#include <linux/of_gpio.h>
23 28
24#include <mach/hardware.h> 29#include <mach/hardware.h>
25#include <mach/at91_pio.h> 30#include <mach/at91_pio.h>
@@ -29,9 +34,12 @@
29struct at91_gpio_chip { 34struct at91_gpio_chip {
30 struct gpio_chip chip; 35 struct gpio_chip chip;
31 struct at91_gpio_chip *next; /* Bank sharing same clock */ 36 struct at91_gpio_chip *next; /* Bank sharing same clock */
32 int id; /* ID of register bank */ 37 int pioc_hwirq; /* PIO bank interrupt identifier on AIC */
33 void __iomem *regbase; /* Base of register bank */ 38 int pioc_virq; /* PIO bank Linux virtual interrupt */
39 int pioc_idx; /* PIO bank index */
40 void __iomem *regbase; /* PIO bank virtual address */
34 struct clk *clock; /* associated clock */ 41 struct clk *clock; /* associated clock */
42 struct irq_domain *domain; /* associated irq domain */
35}; 43};
36 44
37#define to_at91_gpio_chip(c) container_of(c, struct at91_gpio_chip, chip) 45#define to_at91_gpio_chip(c) container_of(c, struct at91_gpio_chip, chip)
@@ -43,8 +51,9 @@ static int at91_gpiolib_direction_output(struct gpio_chip *chip,
43 unsigned offset, int val); 51 unsigned offset, int val);
44static int at91_gpiolib_direction_input(struct gpio_chip *chip, 52static int at91_gpiolib_direction_input(struct gpio_chip *chip,
45 unsigned offset); 53 unsigned offset);
54static int at91_gpiolib_to_irq(struct gpio_chip *chip, unsigned offset);
46 55
47#define AT91_GPIO_CHIP(name, base_gpio, nr_gpio) \ 56#define AT91_GPIO_CHIP(name, nr_gpio) \
48 { \ 57 { \
49 .chip = { \ 58 .chip = { \
50 .label = name, \ 59 .label = name, \
@@ -53,20 +62,28 @@ static int at91_gpiolib_direction_input(struct gpio_chip *chip,
53 .get = at91_gpiolib_get, \ 62 .get = at91_gpiolib_get, \
54 .set = at91_gpiolib_set, \ 63 .set = at91_gpiolib_set, \
55 .dbg_show = at91_gpiolib_dbg_show, \ 64 .dbg_show = at91_gpiolib_dbg_show, \
56 .base = base_gpio, \ 65 .to_irq = at91_gpiolib_to_irq, \
57 .ngpio = nr_gpio, \ 66 .ngpio = nr_gpio, \
58 }, \ 67 }, \
59 } 68 }
60 69
61static struct at91_gpio_chip gpio_chip[] = { 70static struct at91_gpio_chip gpio_chip[] = {
62 AT91_GPIO_CHIP("pioA", 0x00, 32), 71 AT91_GPIO_CHIP("pioA", 32),
63 AT91_GPIO_CHIP("pioB", 0x20, 32), 72 AT91_GPIO_CHIP("pioB", 32),
64 AT91_GPIO_CHIP("pioC", 0x40, 32), 73 AT91_GPIO_CHIP("pioC", 32),
65 AT91_GPIO_CHIP("pioD", 0x60, 32), 74 AT91_GPIO_CHIP("pioD", 32),
66 AT91_GPIO_CHIP("pioE", 0x80, 32), 75 AT91_GPIO_CHIP("pioE", 32),
67}; 76};
68 77
69static int gpio_banks; 78static int gpio_banks;
79static unsigned long at91_gpio_caps;
80
81/* All PIO controllers support PIO3 features */
82#define AT91_GPIO_CAP_PIO3 (1 << 0)
83
84#define has_pio3() (at91_gpio_caps & AT91_GPIO_CAP_PIO3)
85
86/*--------------------------------------------------------------------------*/
70 87
71static inline void __iomem *pin_to_controller(unsigned pin) 88static inline void __iomem *pin_to_controller(unsigned pin)
72{ 89{
@@ -83,6 +100,25 @@ static inline unsigned pin_to_mask(unsigned pin)
83} 100}
84 101
85 102
103static char peripheral_function(void __iomem *pio, unsigned mask)
104{
105 char ret = 'X';
106 u8 select;
107
108 if (pio) {
109 if (has_pio3()) {
110 select = !!(__raw_readl(pio + PIO_ABCDSR1) & mask);
111 select |= (!!(__raw_readl(pio + PIO_ABCDSR2) & mask) << 1);
112 ret = 'A' + select;
113 } else {
114 ret = __raw_readl(pio + PIO_ABSR) & mask ?
115 'B' : 'A';
116 }
117 }
118
119 return ret;
120}
121
86/*--------------------------------------------------------------------------*/ 122/*--------------------------------------------------------------------------*/
87 123
88/* Not all hardware capabilities are exposed through these calls; they 124/* Not all hardware capabilities are exposed through these calls; they
@@ -130,7 +166,14 @@ int __init_or_module at91_set_A_periph(unsigned pin, int use_pullup)
130 166
131 __raw_writel(mask, pio + PIO_IDR); 167 __raw_writel(mask, pio + PIO_IDR);
132 __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR)); 168 __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR));
133 __raw_writel(mask, pio + PIO_ASR); 169 if (has_pio3()) {
170 __raw_writel(__raw_readl(pio + PIO_ABCDSR1) & ~mask,
171 pio + PIO_ABCDSR1);
172 __raw_writel(__raw_readl(pio + PIO_ABCDSR2) & ~mask,
173 pio + PIO_ABCDSR2);
174 } else {
175 __raw_writel(mask, pio + PIO_ASR);
176 }
134 __raw_writel(mask, pio + PIO_PDR); 177 __raw_writel(mask, pio + PIO_PDR);
135 return 0; 178 return 0;
136} 179}
@@ -150,7 +193,14 @@ int __init_or_module at91_set_B_periph(unsigned pin, int use_pullup)
150 193
151 __raw_writel(mask, pio + PIO_IDR); 194 __raw_writel(mask, pio + PIO_IDR);
152 __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR)); 195 __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR));
153 __raw_writel(mask, pio + PIO_BSR); 196 if (has_pio3()) {
197 __raw_writel(__raw_readl(pio + PIO_ABCDSR1) | mask,
198 pio + PIO_ABCDSR1);
199 __raw_writel(__raw_readl(pio + PIO_ABCDSR2) & ~mask,
200 pio + PIO_ABCDSR2);
201 } else {
202 __raw_writel(mask, pio + PIO_BSR);
203 }
154 __raw_writel(mask, pio + PIO_PDR); 204 __raw_writel(mask, pio + PIO_PDR);
155 return 0; 205 return 0;
156} 206}
@@ -158,8 +208,50 @@ EXPORT_SYMBOL(at91_set_B_periph);
158 208
159 209
160/* 210/*
161 * mux the pin to the gpio controller (instead of "A" or "B" peripheral), and 211 * mux the pin to the "C" internal peripheral role.
162 * configure it for an input. 212 */
213int __init_or_module at91_set_C_periph(unsigned pin, int use_pullup)
214{
215 void __iomem *pio = pin_to_controller(pin);
216 unsigned mask = pin_to_mask(pin);
217
218 if (!pio || !has_pio3())
219 return -EINVAL;
220
221 __raw_writel(mask, pio + PIO_IDR);
222 __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR));
223 __raw_writel(__raw_readl(pio + PIO_ABCDSR1) & ~mask, pio + PIO_ABCDSR1);
224 __raw_writel(__raw_readl(pio + PIO_ABCDSR2) | mask, pio + PIO_ABCDSR2);
225 __raw_writel(mask, pio + PIO_PDR);
226 return 0;
227}
228EXPORT_SYMBOL(at91_set_C_periph);
229
230
231/*
232 * mux the pin to the "D" internal peripheral role.
233 */
234int __init_or_module at91_set_D_periph(unsigned pin, int use_pullup)
235{
236 void __iomem *pio = pin_to_controller(pin);
237 unsigned mask = pin_to_mask(pin);
238
239 if (!pio || !has_pio3())
240 return -EINVAL;
241
242 __raw_writel(mask, pio + PIO_IDR);
243 __raw_writel(mask, pio + (use_pullup ? PIO_PUER : PIO_PUDR));
244 __raw_writel(__raw_readl(pio + PIO_ABCDSR1) | mask, pio + PIO_ABCDSR1);
245 __raw_writel(__raw_readl(pio + PIO_ABCDSR2) | mask, pio + PIO_ABCDSR2);
246 __raw_writel(mask, pio + PIO_PDR);
247 return 0;
248}
249EXPORT_SYMBOL(at91_set_D_periph);
250
251
252/*
253 * mux the pin to the gpio controller (instead of "A", "B", "C"
254 * or "D" peripheral), and configure it for an input.
163 */ 255 */
164int __init_or_module at91_set_gpio_input(unsigned pin, int use_pullup) 256int __init_or_module at91_set_gpio_input(unsigned pin, int use_pullup)
165{ 257{
@@ -179,8 +271,8 @@ EXPORT_SYMBOL(at91_set_gpio_input);
179 271
180 272
181/* 273/*
182 * mux the pin to the gpio controller (instead of "A" or "B" peripheral), 274 * mux the pin to the gpio controller (instead of "A", "B", "C"
183 * and configure it for an output. 275 * or "D" peripheral), and configure it for an output.
184 */ 276 */
185int __init_or_module at91_set_gpio_output(unsigned pin, int value) 277int __init_or_module at91_set_gpio_output(unsigned pin, int value)
186{ 278{
@@ -210,12 +302,37 @@ int __init_or_module at91_set_deglitch(unsigned pin, int is_on)
210 302
211 if (!pio) 303 if (!pio)
212 return -EINVAL; 304 return -EINVAL;
305
306 if (has_pio3() && is_on)
307 __raw_writel(mask, pio + PIO_IFSCDR);
213 __raw_writel(mask, pio + (is_on ? PIO_IFER : PIO_IFDR)); 308 __raw_writel(mask, pio + (is_on ? PIO_IFER : PIO_IFDR));
214 return 0; 309 return 0;
215} 310}
216EXPORT_SYMBOL(at91_set_deglitch); 311EXPORT_SYMBOL(at91_set_deglitch);
217 312
218/* 313/*
314 * enable/disable the debounce filter;
315 */
316int __init_or_module at91_set_debounce(unsigned pin, int is_on, int div)
317{
318 void __iomem *pio = pin_to_controller(pin);
319 unsigned mask = pin_to_mask(pin);
320
321 if (!pio || !has_pio3())
322 return -EINVAL;
323
324 if (is_on) {
325 __raw_writel(mask, pio + PIO_IFSCER);
326 __raw_writel(div & PIO_SCDR_DIV, pio + PIO_SCDR);
327 __raw_writel(mask, pio + PIO_IFER);
328 } else {
329 __raw_writel(mask, pio + PIO_IFDR);
330 }
331 return 0;
332}
333EXPORT_SYMBOL(at91_set_debounce);
334
335/*
219 * enable/disable the multi-driver; This is only valid for output and 336 * enable/disable the multi-driver; This is only valid for output and
220 * allows the output pin to run as an open collector output. 337 * allows the output pin to run as an open collector output.
221 */ 338 */
@@ -233,6 +350,41 @@ int __init_or_module at91_set_multi_drive(unsigned pin, int is_on)
233EXPORT_SYMBOL(at91_set_multi_drive); 350EXPORT_SYMBOL(at91_set_multi_drive);
234 351
235/* 352/*
353 * enable/disable the pull-down.
354 * If pull-up already enabled while calling the function, we disable it.
355 */
356int __init_or_module at91_set_pulldown(unsigned pin, int is_on)
357{
358 void __iomem *pio = pin_to_controller(pin);
359 unsigned mask = pin_to_mask(pin);
360
361 if (!pio || !has_pio3())
362 return -EINVAL;
363
364 /* Disable pull-up anyway */
365 __raw_writel(mask, pio + PIO_PUDR);
366 __raw_writel(mask, pio + (is_on ? PIO_PPDER : PIO_PPDDR));
367 return 0;
368}
369EXPORT_SYMBOL(at91_set_pulldown);
370
371/*
372 * disable Schmitt trigger
373 */
374int __init_or_module at91_disable_schmitt_trig(unsigned pin)
375{
376 void __iomem *pio = pin_to_controller(pin);
377 unsigned mask = pin_to_mask(pin);
378
379 if (!pio || !has_pio3())
380 return -EINVAL;
381
382 __raw_writel(__raw_readl(pio + PIO_SCHMITT) | mask, pio + PIO_SCHMITT);
383 return 0;
384}
385EXPORT_SYMBOL(at91_disable_schmitt_trig);
386
387/*
236 * assuming the pin is muxed as a gpio output, set its value. 388 * assuming the pin is muxed as a gpio output, set its value.
237 */ 389 */
238int at91_set_gpio_value(unsigned pin, int value) 390int at91_set_gpio_value(unsigned pin, int value)
@@ -273,9 +425,9 @@ static u32 backups[MAX_GPIO_BANKS];
273 425
274static int gpio_irq_set_wake(struct irq_data *d, unsigned state) 426static int gpio_irq_set_wake(struct irq_data *d, unsigned state)
275{ 427{
276 unsigned pin = irq_to_gpio(d->irq); 428 struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d);
277 unsigned mask = pin_to_mask(pin); 429 unsigned mask = 1 << d->hwirq;
278 unsigned bank = pin / 32; 430 unsigned bank = at91_gpio->pioc_idx;
279 431
280 if (unlikely(bank >= MAX_GPIO_BANKS)) 432 if (unlikely(bank >= MAX_GPIO_BANKS))
281 return -EINVAL; 433 return -EINVAL;
@@ -285,7 +437,7 @@ static int gpio_irq_set_wake(struct irq_data *d, unsigned state)
285 else 437 else
286 wakeups[bank] &= ~mask; 438 wakeups[bank] &= ~mask;
287 439
288 irq_set_irq_wake(gpio_chip[bank].id, state); 440 irq_set_irq_wake(at91_gpio->pioc_virq, state);
289 441
290 return 0; 442 return 0;
291} 443}
@@ -301,9 +453,10 @@ void at91_gpio_suspend(void)
301 __raw_writel(backups[i], pio + PIO_IDR); 453 __raw_writel(backups[i], pio + PIO_IDR);
302 __raw_writel(wakeups[i], pio + PIO_IER); 454 __raw_writel(wakeups[i], pio + PIO_IER);
303 455
304 if (!wakeups[i]) 456 if (!wakeups[i]) {
457 clk_unprepare(gpio_chip[i].clock);
305 clk_disable(gpio_chip[i].clock); 458 clk_disable(gpio_chip[i].clock);
306 else { 459 } else {
307#ifdef CONFIG_PM_DEBUG 460#ifdef CONFIG_PM_DEBUG
308 printk(KERN_DEBUG "GPIO-%c may wake for %08x\n", 'A'+i, wakeups[i]); 461 printk(KERN_DEBUG "GPIO-%c may wake for %08x\n", 'A'+i, wakeups[i]);
309#endif 462#endif
@@ -318,8 +471,10 @@ void at91_gpio_resume(void)
318 for (i = 0; i < gpio_banks; i++) { 471 for (i = 0; i < gpio_banks; i++) {
319 void __iomem *pio = gpio_chip[i].regbase; 472 void __iomem *pio = gpio_chip[i].regbase;
320 473
321 if (!wakeups[i]) 474 if (!wakeups[i]) {
322 clk_enable(gpio_chip[i].clock); 475 if (clk_prepare(gpio_chip[i].clock) == 0)
476 clk_enable(gpio_chip[i].clock);
477 }
323 478
324 __raw_writel(wakeups[i], pio + PIO_IDR); 479 __raw_writel(wakeups[i], pio + PIO_IDR);
325 __raw_writel(backups[i], pio + PIO_IER); 480 __raw_writel(backups[i], pio + PIO_IER);
@@ -335,7 +490,10 @@ void at91_gpio_resume(void)
335 * To use any AT91_PIN_* as an externally triggered IRQ, first call 490 * To use any AT91_PIN_* as an externally triggered IRQ, first call
336 * at91_set_gpio_input() then maybe enable its glitch filter. 491 * at91_set_gpio_input() then maybe enable its glitch filter.
337 * Then just request_irq() with the pin ID; it works like any ARM IRQ 492 * Then just request_irq() with the pin ID; it works like any ARM IRQ
338 * handler, though it always triggers on rising and falling edges. 493 * handler.
494 * First implementation always triggers on rising and falling edges
495 * whereas the newer PIO3 can be additionally configured to trigger on
496 * level, edge with any polarity.
339 * 497 *
340 * Alternatively, certain pins may be used directly as IRQ0..IRQ6 after 498 * Alternatively, certain pins may be used directly as IRQ0..IRQ6 after
341 * configuring them with at91_set_a_periph() or at91_set_b_periph(). 499 * configuring them with at91_set_a_periph() or at91_set_b_periph().
@@ -344,9 +502,9 @@ void at91_gpio_resume(void)
344 502
345static void gpio_irq_mask(struct irq_data *d) 503static void gpio_irq_mask(struct irq_data *d)
346{ 504{
347 unsigned pin = irq_to_gpio(d->irq); 505 struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d);
348 void __iomem *pio = pin_to_controller(pin); 506 void __iomem *pio = at91_gpio->regbase;
349 unsigned mask = pin_to_mask(pin); 507 unsigned mask = 1 << d->hwirq;
350 508
351 if (pio) 509 if (pio)
352 __raw_writel(mask, pio + PIO_IDR); 510 __raw_writel(mask, pio + PIO_IDR);
@@ -354,9 +512,9 @@ static void gpio_irq_mask(struct irq_data *d)
354 512
355static void gpio_irq_unmask(struct irq_data *d) 513static void gpio_irq_unmask(struct irq_data *d)
356{ 514{
357 unsigned pin = irq_to_gpio(d->irq); 515 struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d);
358 void __iomem *pio = pin_to_controller(pin); 516 void __iomem *pio = at91_gpio->regbase;
359 unsigned mask = pin_to_mask(pin); 517 unsigned mask = 1 << d->hwirq;
360 518
361 if (pio) 519 if (pio)
362 __raw_writel(mask, pio + PIO_IER); 520 __raw_writel(mask, pio + PIO_IER);
@@ -373,23 +531,66 @@ static int gpio_irq_type(struct irq_data *d, unsigned type)
373 } 531 }
374} 532}
375 533
534/* Alternate irq type for PIO3 support */
535static int alt_gpio_irq_type(struct irq_data *d, unsigned type)
536{
537 struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d);
538 void __iomem *pio = at91_gpio->regbase;
539 unsigned mask = 1 << d->hwirq;
540
541 switch (type) {
542 case IRQ_TYPE_EDGE_RISING:
543 __raw_writel(mask, pio + PIO_ESR);
544 __raw_writel(mask, pio + PIO_REHLSR);
545 break;
546 case IRQ_TYPE_EDGE_FALLING:
547 __raw_writel(mask, pio + PIO_ESR);
548 __raw_writel(mask, pio + PIO_FELLSR);
549 break;
550 case IRQ_TYPE_LEVEL_LOW:
551 __raw_writel(mask, pio + PIO_LSR);
552 __raw_writel(mask, pio + PIO_FELLSR);
553 break;
554 case IRQ_TYPE_LEVEL_HIGH:
555 __raw_writel(mask, pio + PIO_LSR);
556 __raw_writel(mask, pio + PIO_REHLSR);
557 break;
558 case IRQ_TYPE_EDGE_BOTH:
559 /*
560 * disable additional interrupt modes:
561 * fall back to default behavior
562 */
563 __raw_writel(mask, pio + PIO_AIMDR);
564 return 0;
565 case IRQ_TYPE_NONE:
566 default:
567 pr_warn("AT91: No type for irq %d\n", gpio_to_irq(d->irq));
568 return -EINVAL;
569 }
570
571 /* enable additional interrupt modes */
572 __raw_writel(mask, pio + PIO_AIMER);
573
574 return 0;
575}
576
376static struct irq_chip gpio_irqchip = { 577static struct irq_chip gpio_irqchip = {
377 .name = "GPIO", 578 .name = "GPIO",
378 .irq_disable = gpio_irq_mask, 579 .irq_disable = gpio_irq_mask,
379 .irq_mask = gpio_irq_mask, 580 .irq_mask = gpio_irq_mask,
380 .irq_unmask = gpio_irq_unmask, 581 .irq_unmask = gpio_irq_unmask,
381 .irq_set_type = gpio_irq_type, 582 /* .irq_set_type is set dynamically */
382 .irq_set_wake = gpio_irq_set_wake, 583 .irq_set_wake = gpio_irq_set_wake,
383}; 584};
384 585
385static void gpio_irq_handler(unsigned irq, struct irq_desc *desc) 586static void gpio_irq_handler(unsigned irq, struct irq_desc *desc)
386{ 587{
387 unsigned irq_pin;
388 struct irq_data *idata = irq_desc_get_irq_data(desc); 588 struct irq_data *idata = irq_desc_get_irq_data(desc);
389 struct irq_chip *chip = irq_data_get_irq_chip(idata); 589 struct irq_chip *chip = irq_data_get_irq_chip(idata);
390 struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(idata); 590 struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(idata);
391 void __iomem *pio = at91_gpio->regbase; 591 void __iomem *pio = at91_gpio->regbase;
392 u32 isr; 592 unsigned long isr;
593 int n;
393 594
394 /* temporarily mask (level sensitive) parent IRQ */ 595 /* temporarily mask (level sensitive) parent IRQ */
395 chip->irq_ack(idata); 596 chip->irq_ack(idata);
@@ -407,13 +608,10 @@ static void gpio_irq_handler(unsigned irq, struct irq_desc *desc)
407 continue; 608 continue;
408 } 609 }
409 610
410 irq_pin = gpio_to_irq(at91_gpio->chip.base); 611 n = find_first_bit(&isr, BITS_PER_LONG);
411 612 while (n < BITS_PER_LONG) {
412 while (isr) { 613 generic_handle_irq(irq_find_mapping(at91_gpio->domain, n));
413 if (isr & 1) 614 n = find_next_bit(&isr, BITS_PER_LONG, n + 1);
414 generic_handle_irq(irq_pin);
415 irq_pin++;
416 isr >>= 1;
417 } 615 }
418 } 616 }
419 chip->irq_unmask(idata); 617 chip->irq_unmask(idata);
@@ -424,6 +622,33 @@ static void gpio_irq_handler(unsigned irq, struct irq_desc *desc)
424 622
425#ifdef CONFIG_DEBUG_FS 623#ifdef CONFIG_DEBUG_FS
426 624
625static void gpio_printf(struct seq_file *s, void __iomem *pio, unsigned mask)
626{
627 char *trigger = NULL;
628 char *polarity = NULL;
629
630 if (__raw_readl(pio + PIO_IMR) & mask) {
631 if (!has_pio3() || !(__raw_readl(pio + PIO_AIMMR) & mask )) {
632 trigger = "edge";
633 polarity = "both";
634 } else {
635 if (__raw_readl(pio + PIO_ELSR) & mask) {
636 trigger = "level";
637 polarity = __raw_readl(pio + PIO_FRLHSR) & mask ?
638 "high" : "low";
639 } else {
640 trigger = "edge";
641 polarity = __raw_readl(pio + PIO_FRLHSR) & mask ?
642 "rising" : "falling";
643 }
644 }
645 seq_printf(s, "IRQ:%s-%s\t", trigger, polarity);
646 } else {
647 seq_printf(s, "GPIO:%s\t\t",
648 __raw_readl(pio + PIO_PDSR) & mask ? "1" : "0");
649 }
650}
651
427static int at91_gpio_show(struct seq_file *s, void *unused) 652static int at91_gpio_show(struct seq_file *s, void *unused)
428{ 653{
429 int bank, j; 654 int bank, j;
@@ -431,7 +656,7 @@ static int at91_gpio_show(struct seq_file *s, void *unused)
431 /* print heading */ 656 /* print heading */
432 seq_printf(s, "Pin\t"); 657 seq_printf(s, "Pin\t");
433 for (bank = 0; bank < gpio_banks; bank++) { 658 for (bank = 0; bank < gpio_banks; bank++) {
434 seq_printf(s, "PIO%c\t", 'A' + bank); 659 seq_printf(s, "PIO%c\t\t", 'A' + bank);
435 }; 660 };
436 seq_printf(s, "\n\n"); 661 seq_printf(s, "\n\n");
437 662
@@ -445,11 +670,10 @@ static int at91_gpio_show(struct seq_file *s, void *unused)
445 unsigned mask = pin_to_mask(pin); 670 unsigned mask = pin_to_mask(pin);
446 671
447 if (__raw_readl(pio + PIO_PSR) & mask) 672 if (__raw_readl(pio + PIO_PSR) & mask)
448 seq_printf(s, "GPIO:%s", __raw_readl(pio + PIO_PDSR) & mask ? "1" : "0"); 673 gpio_printf(s, pio, mask);
449 else 674 else
450 seq_printf(s, "%s", __raw_readl(pio + PIO_ABSR) & mask ? "B" : "A"); 675 seq_printf(s, "%c\t\t",
451 676 peripheral_function(pio, mask));
452 seq_printf(s, "\t");
453 } 677 }
454 678
455 seq_printf(s, "\n"); 679 seq_printf(s, "\n");
@@ -488,46 +712,152 @@ postcore_initcall(at91_gpio_debugfs_init);
488 */ 712 */
489static struct lock_class_key gpio_lock_class; 713static struct lock_class_key gpio_lock_class;
490 714
715#if defined(CONFIG_OF)
716static int at91_gpio_irq_map(struct irq_domain *h, unsigned int virq,
717 irq_hw_number_t hw)
718{
719 struct at91_gpio_chip *at91_gpio = h->host_data;
720
721 irq_set_lockdep_class(virq, &gpio_lock_class);
722
723 /*
724 * Can use the "simple" and not "edge" handler since it's
725 * shorter, and the AIC handles interrupts sanely.
726 */
727 irq_set_chip_and_handler(virq, &gpio_irqchip,
728 handle_simple_irq);
729 set_irq_flags(virq, IRQF_VALID);
730 irq_set_chip_data(virq, at91_gpio);
731
732 return 0;
733}
734
735static struct irq_domain_ops at91_gpio_ops = {
736 .map = at91_gpio_irq_map,
737 .xlate = irq_domain_xlate_twocell,
738};
739
740int __init at91_gpio_of_irq_setup(struct device_node *node,
741 struct device_node *parent)
742{
743 struct at91_gpio_chip *prev = NULL;
744 int alias_idx = of_alias_get_id(node, "gpio");
745 struct at91_gpio_chip *at91_gpio = &gpio_chip[alias_idx];
746
747 /* Setup proper .irq_set_type function */
748 if (has_pio3())
749 gpio_irqchip.irq_set_type = alt_gpio_irq_type;
750 else
751 gpio_irqchip.irq_set_type = gpio_irq_type;
752
753 /* Disable irqs of this PIO controller */
754 __raw_writel(~0, at91_gpio->regbase + PIO_IDR);
755
756 /* Setup irq domain */
757 at91_gpio->domain = irq_domain_add_linear(node, at91_gpio->chip.ngpio,
758 &at91_gpio_ops, at91_gpio);
759 if (!at91_gpio->domain)
760 panic("at91_gpio.%d: couldn't allocate irq domain (DT).\n",
761 at91_gpio->pioc_idx);
762
763 /* Setup chained handler */
764 if (at91_gpio->pioc_idx)
765 prev = &gpio_chip[at91_gpio->pioc_idx - 1];
766
767 /* The toplevel handler handles one bank of GPIOs, except
768 * on some SoC it can handles up to three...
769 * We only set up the handler for the first of the list.
770 */
771 if (prev && prev->next == at91_gpio)
772 return 0;
773
774 at91_gpio->pioc_virq = irq_create_mapping(irq_find_host(parent),
775 at91_gpio->pioc_hwirq);
776 irq_set_chip_data(at91_gpio->pioc_virq, at91_gpio);
777 irq_set_chained_handler(at91_gpio->pioc_virq, gpio_irq_handler);
778
779 return 0;
780}
781#else
782int __init at91_gpio_of_irq_setup(struct device_node *node,
783 struct device_node *parent)
784{
785 return -EINVAL;
786}
787#endif
788
789/*
790 * irqdomain initialization: pile up irqdomains on top of AIC range
791 */
792static void __init at91_gpio_irqdomain(struct at91_gpio_chip *at91_gpio)
793{
794 int irq_base;
795
796 irq_base = irq_alloc_descs(-1, 0, at91_gpio->chip.ngpio, 0);
797 if (irq_base < 0)
798 panic("at91_gpio.%d: error %d: couldn't allocate IRQ numbers.\n",
799 at91_gpio->pioc_idx, irq_base);
800 at91_gpio->domain = irq_domain_add_legacy(NULL, at91_gpio->chip.ngpio,
801 irq_base, 0,
802 &irq_domain_simple_ops, NULL);
803 if (!at91_gpio->domain)
804 panic("at91_gpio.%d: couldn't allocate irq domain.\n",
805 at91_gpio->pioc_idx);
806}
807
491/* 808/*
492 * Called from the processor-specific init to enable GPIO interrupt support. 809 * Called from the processor-specific init to enable GPIO interrupt support.
493 */ 810 */
494void __init at91_gpio_irq_setup(void) 811void __init at91_gpio_irq_setup(void)
495{ 812{
496 unsigned pioc, irq = gpio_to_irq(0); 813 unsigned pioc;
814 int gpio_irqnbr = 0;
497 struct at91_gpio_chip *this, *prev; 815 struct at91_gpio_chip *this, *prev;
498 816
817 /* Setup proper .irq_set_type function */
818 if (has_pio3())
819 gpio_irqchip.irq_set_type = alt_gpio_irq_type;
820 else
821 gpio_irqchip.irq_set_type = gpio_irq_type;
822
499 for (pioc = 0, this = gpio_chip, prev = NULL; 823 for (pioc = 0, this = gpio_chip, prev = NULL;
500 pioc++ < gpio_banks; 824 pioc++ < gpio_banks;
501 prev = this, this++) { 825 prev = this, this++) {
502 unsigned id = this->id; 826 int offset;
503 unsigned i;
504 827
505 __raw_writel(~0, this->regbase + PIO_IDR); 828 __raw_writel(~0, this->regbase + PIO_IDR);
506 829
507 for (i = 0, irq = gpio_to_irq(this->chip.base); i < 32; 830 /* setup irq domain for this GPIO controller */
508 i++, irq++) { 831 at91_gpio_irqdomain(this);
509 irq_set_lockdep_class(irq, &gpio_lock_class); 832
833 for (offset = 0; offset < this->chip.ngpio; offset++) {
834 unsigned int virq = irq_find_mapping(this->domain, offset);
835 irq_set_lockdep_class(virq, &gpio_lock_class);
510 836
511 /* 837 /*
512 * Can use the "simple" and not "edge" handler since it's 838 * Can use the "simple" and not "edge" handler since it's
513 * shorter, and the AIC handles interrupts sanely. 839 * shorter, and the AIC handles interrupts sanely.
514 */ 840 */
515 irq_set_chip_and_handler(irq, &gpio_irqchip, 841 irq_set_chip_and_handler(virq, &gpio_irqchip,
516 handle_simple_irq); 842 handle_simple_irq);
517 set_irq_flags(irq, IRQF_VALID); 843 set_irq_flags(virq, IRQF_VALID);
844 irq_set_chip_data(virq, this);
845
846 gpio_irqnbr++;
518 } 847 }
519 848
520 /* The toplevel handler handles one bank of GPIOs, except 849 /* The toplevel handler handles one bank of GPIOs, except
521 * AT91SAM9263_ID_PIOCDE handles three... PIOC is first in 850 * on some SoC it can handles up to three...
522 * the list, so we only set up that handler. 851 * We only set up the handler for the first of the list.
523 */ 852 */
524 if (prev && prev->next == this) 853 if (prev && prev->next == this)
525 continue; 854 continue;
526 855
527 irq_set_chip_data(id, this); 856 this->pioc_virq = irq_create_mapping(NULL, this->pioc_hwirq);
528 irq_set_chained_handler(id, gpio_irq_handler); 857 irq_set_chip_data(this->pioc_virq, this);
858 irq_set_chained_handler(this->pioc_virq, gpio_irq_handler);
529 } 859 }
530 pr_info("AT91: %d gpio irqs in %d banks\n", irq - gpio_to_irq(0), gpio_banks); 860 pr_info("AT91: %d gpio irqs in %d banks\n", gpio_irqnbr, gpio_banks);
531} 861}
532 862
533/* gpiolib support */ 863/* gpiolib support */
@@ -593,48 +923,175 @@ static void at91_gpiolib_dbg_show(struct seq_file *s, struct gpio_chip *chip)
593 at91_get_gpio_value(pin) ? 923 at91_get_gpio_value(pin) ?
594 "set" : "clear"); 924 "set" : "clear");
595 else 925 else
596 seq_printf(s, "[periph %s]\n", 926 seq_printf(s, "[periph %c]\n",
597 __raw_readl(pio + PIO_ABSR) & 927 peripheral_function(pio, mask));
598 mask ? "B" : "A");
599 } 928 }
600 } 929 }
601} 930}
602 931
932static int at91_gpiolib_to_irq(struct gpio_chip *chip, unsigned offset)
933{
934 struct at91_gpio_chip *at91_gpio = to_at91_gpio_chip(chip);
935 int virq;
936
937 if (offset < chip->ngpio)
938 virq = irq_create_mapping(at91_gpio->domain, offset);
939 else
940 virq = -ENXIO;
941
942 dev_dbg(chip->dev, "%s: request IRQ for GPIO %d, return %d\n",
943 chip->label, offset + chip->base, virq);
944 return virq;
945}
946
947static int __init at91_gpio_setup_clk(int idx)
948{
949 struct at91_gpio_chip *at91_gpio = &gpio_chip[idx];
950
951 /* retreive PIO controller's clock */
952 at91_gpio->clock = clk_get_sys(NULL, at91_gpio->chip.label);
953 if (IS_ERR(at91_gpio->clock)) {
954 pr_err("at91_gpio.%d, failed to get clock, ignoring.\n", idx);
955 goto err;
956 }
957
958 if (clk_prepare(at91_gpio->clock))
959 goto clk_prep_err;
960
961 /* enable PIO controller's clock */
962 if (clk_enable(at91_gpio->clock)) {
963 pr_err("at91_gpio.%d, failed to enable clock, ignoring.\n", idx);
964 goto clk_err;
965 }
966
967 return 0;
968
969clk_err:
970 clk_unprepare(at91_gpio->clock);
971clk_prep_err:
972 clk_put(at91_gpio->clock);
973err:
974 return -EINVAL;
975}
976
977#ifdef CONFIG_OF_GPIO
978static void __init of_at91_gpio_init_one(struct device_node *np)
979{
980 int alias_idx;
981 struct at91_gpio_chip *at91_gpio;
982
983 if (!np)
984 return;
985
986 alias_idx = of_alias_get_id(np, "gpio");
987 if (alias_idx >= MAX_GPIO_BANKS) {
988 pr_err("at91_gpio, failed alias idx(%d) > MAX_GPIO_BANKS(%d), ignoring.\n",
989 alias_idx, MAX_GPIO_BANKS);
990 return;
991 }
992
993 at91_gpio = &gpio_chip[alias_idx];
994 at91_gpio->chip.base = alias_idx * at91_gpio->chip.ngpio;
995
996 at91_gpio->regbase = of_iomap(np, 0);
997 if (!at91_gpio->regbase) {
998 pr_err("at91_gpio.%d, failed to map registers, ignoring.\n",
999 alias_idx);
1000 return;
1001 }
1002
1003 /* Get the interrupts property */
1004 if (of_property_read_u32(np, "interrupts", &at91_gpio->pioc_hwirq)) {
1005 pr_err("at91_gpio.%d, failed to get interrupts property, ignoring.\n",
1006 alias_idx);
1007 goto ioremap_err;
1008 }
1009
1010 /* Get capabilities from compatibility property */
1011 if (of_device_is_compatible(np, "atmel,at91sam9x5-gpio"))
1012 at91_gpio_caps |= AT91_GPIO_CAP_PIO3;
1013
1014 /* Setup clock */
1015 if (at91_gpio_setup_clk(alias_idx))
1016 goto ioremap_err;
1017
1018 at91_gpio->chip.of_node = np;
1019 gpio_banks = max(gpio_banks, alias_idx + 1);
1020 at91_gpio->pioc_idx = alias_idx;
1021 return;
1022
1023ioremap_err:
1024 iounmap(at91_gpio->regbase);
1025}
1026
1027static int __init of_at91_gpio_init(void)
1028{
1029 struct device_node *np = NULL;
1030
1031 /*
1032 * This isn't ideal, but it gets things hooked up until this
1033 * driver is converted into a platform_device
1034 */
1035 for_each_compatible_node(np, NULL, "atmel,at91rm9200-gpio")
1036 of_at91_gpio_init_one(np);
1037
1038 return gpio_banks > 0 ? 0 : -EINVAL;
1039}
1040#else
1041static int __init of_at91_gpio_init(void)
1042{
1043 return -EINVAL;
1044}
1045#endif
1046
1047static void __init at91_gpio_init_one(int idx, u32 regbase, int pioc_hwirq)
1048{
1049 struct at91_gpio_chip *at91_gpio = &gpio_chip[idx];
1050
1051 at91_gpio->chip.base = idx * at91_gpio->chip.ngpio;
1052 at91_gpio->pioc_hwirq = pioc_hwirq;
1053 at91_gpio->pioc_idx = idx;
1054
1055 at91_gpio->regbase = ioremap(regbase, 512);
1056 if (!at91_gpio->regbase) {
1057 pr_err("at91_gpio.%d, failed to map registers, ignoring.\n", idx);
1058 return;
1059 }
1060
1061 if (at91_gpio_setup_clk(idx))
1062 goto ioremap_err;
1063
1064 gpio_banks = max(gpio_banks, idx + 1);
1065 return;
1066
1067ioremap_err:
1068 iounmap(at91_gpio->regbase);
1069}
1070
603/* 1071/*
604 * Called from the processor-specific init to enable GPIO pin support. 1072 * Called from the processor-specific init to enable GPIO pin support.
605 */ 1073 */
606void __init at91_gpio_init(struct at91_gpio_bank *data, int nr_banks) 1074void __init at91_gpio_init(struct at91_gpio_bank *data, int nr_banks)
607{ 1075{
608 unsigned i; 1076 unsigned i;
609 struct at91_gpio_chip *at91_gpio, *last = NULL; 1077 struct at91_gpio_chip *at91_gpio, *last = NULL;
610 1078
611 BUG_ON(nr_banks > MAX_GPIO_BANKS); 1079 BUG_ON(nr_banks > MAX_GPIO_BANKS);
612 1080
613 gpio_banks = nr_banks; 1081 if (of_at91_gpio_init() < 0) {
1082 /* No GPIO controller found in device tree */
1083 for (i = 0; i < nr_banks; i++)
1084 at91_gpio_init_one(i, data[i].regbase, data[i].id);
1085 }
614 1086
615 for (i = 0; i < nr_banks; i++) { 1087 for (i = 0; i < gpio_banks; i++) {
616 at91_gpio = &gpio_chip[i]; 1088 at91_gpio = &gpio_chip[i];
617 1089
618 at91_gpio->id = data[i].id; 1090 /*
619 at91_gpio->chip.base = i * 32; 1091 * GPIO controller are grouped on some SoC:
620 1092 * PIOC, PIOD and PIOE can share the same IRQ line
621 at91_gpio->regbase = ioremap(data[i].regbase, 512); 1093 */
622 if (!at91_gpio->regbase) { 1094 if (last && last->pioc_hwirq == at91_gpio->pioc_hwirq)
623 pr_err("at91_gpio.%d, failed to map registers, ignoring.\n", i);
624 continue;
625 }
626
627 at91_gpio->clock = clk_get_sys(NULL, at91_gpio->chip.label);
628 if (!at91_gpio->clock) {
629 pr_err("at91_gpio.%d, failed to get clock, ignoring.\n", i);
630 continue;
631 }
632
633 /* enable PIO controller's clock */
634 clk_enable(at91_gpio->clock);
635
636 /* AT91SAM9263_ID_PIOCDE groups PIOC, PIOD, PIOE */
637 if (last && last->id == at91_gpio->id)
638 last->next = at91_gpio; 1095 last->next = at91_gpio;
639 last = at91_gpio; 1096 last = at91_gpio;
640 1097
diff --git a/arch/arm/mach-at91/include/mach/at91_matrix.h b/arch/arm/mach-at91/include/mach/at91_matrix.h
new file mode 100644
index 00000000000..02fae9de746
--- /dev/null
+++ b/arch/arm/mach-at91/include/mach/at91_matrix.h
@@ -0,0 +1,23 @@
1/*
2 * Copyright (C) 2011 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
3 *
4 * Under GPLv2
5 */
6
7#ifndef __MACH_AT91_MATRIX_H__
8#define __MACH_AT91_MATRIX_H__
9
10#ifndef __ASSEMBLY__
11extern void __iomem *at91_matrix_base;
12
13#define at91_matrix_read(field) \
14 __raw_readl(at91_matrix_base + field)
15
16#define at91_matrix_write(field, value) \
17 __raw_writel(value, at91_matrix_base + field);
18
19#else
20.extern at91_matrix_base
21#endif
22
23#endif /* __MACH_AT91_MATRIX_H__ */
diff --git a/arch/arm/mach-at91/include/mach/at91_pio.h b/arch/arm/mach-at91/include/mach/at91_pio.h
index c6a31bf8a5c..732b11c37f1 100644
--- a/arch/arm/mach-at91/include/mach/at91_pio.h
+++ b/arch/arm/mach-at91/include/mach/at91_pio.h
@@ -40,10 +40,35 @@
40#define PIO_PUER 0x64 /* Pull-up Enable Register */ 40#define PIO_PUER 0x64 /* Pull-up Enable Register */
41#define PIO_PUSR 0x68 /* Pull-up Status Register */ 41#define PIO_PUSR 0x68 /* Pull-up Status Register */
42#define PIO_ASR 0x70 /* Peripheral A Select Register */ 42#define PIO_ASR 0x70 /* Peripheral A Select Register */
43#define PIO_ABCDSR1 0x70 /* Peripheral ABCD Select Register 1 [some sam9 only] */
43#define PIO_BSR 0x74 /* Peripheral B Select Register */ 44#define PIO_BSR 0x74 /* Peripheral B Select Register */
45#define PIO_ABCDSR2 0x74 /* Peripheral ABCD Select Register 2 [some sam9 only] */
44#define PIO_ABSR 0x78 /* AB Status Register */ 46#define PIO_ABSR 0x78 /* AB Status Register */
47#define PIO_IFSCDR 0x80 /* Input Filter Slow Clock Disable Register */
48#define PIO_IFSCER 0x84 /* Input Filter Slow Clock Enable Register */
49#define PIO_IFSCSR 0x88 /* Input Filter Slow Clock Status Register */
50#define PIO_SCDR 0x8c /* Slow Clock Divider Debouncing Register */
51#define PIO_SCDR_DIV (0x3fff << 0) /* Slow Clock Divider Mask */
52#define PIO_PPDDR 0x90 /* Pad Pull-down Disable Register */
53#define PIO_PPDER 0x94 /* Pad Pull-down Enable Register */
54#define PIO_PPDSR 0x98 /* Pad Pull-down Status Register */
45#define PIO_OWER 0xa0 /* Output Write Enable Register */ 55#define PIO_OWER 0xa0 /* Output Write Enable Register */
46#define PIO_OWDR 0xa4 /* Output Write Disable Register */ 56#define PIO_OWDR 0xa4 /* Output Write Disable Register */
47#define PIO_OWSR 0xa8 /* Output Write Status Register */ 57#define PIO_OWSR 0xa8 /* Output Write Status Register */
58#define PIO_AIMER 0xb0 /* Additional Interrupt Modes Enable Register */
59#define PIO_AIMDR 0xb4 /* Additional Interrupt Modes Disable Register */
60#define PIO_AIMMR 0xb8 /* Additional Interrupt Modes Mask Register */
61#define PIO_ESR 0xc0 /* Edge Select Register */
62#define PIO_LSR 0xc4 /* Level Select Register */
63#define PIO_ELSR 0xc8 /* Edge/Level Status Register */
64#define PIO_FELLSR 0xd0 /* Falling Edge/Low Level Select Register */
65#define PIO_REHLSR 0xd4 /* Rising Edge/ High Level Select Register */
66#define PIO_FRLHSR 0xd8 /* Fall/Rise - Low/High Status Register */
67#define PIO_SCHMITT 0x100 /* Schmitt Trigger Register */
68
69#define ABCDSR_PERIPH_A 0x0
70#define ABCDSR_PERIPH_B 0x1
71#define ABCDSR_PERIPH_C 0x2
72#define ABCDSR_PERIPH_D 0x3
48 73
49#endif 74#endif
diff --git a/arch/arm/mach-at91/include/mach/at91_pmc.h b/arch/arm/mach-at91/include/mach/at91_pmc.h
index e46f93e34aa..36604782a78 100644
--- a/arch/arm/mach-at91/include/mach/at91_pmc.h
+++ b/arch/arm/mach-at91/include/mach/at91_pmc.h
@@ -16,17 +16,27 @@
16#ifndef AT91_PMC_H 16#ifndef AT91_PMC_H
17#define AT91_PMC_H 17#define AT91_PMC_H
18 18
19#define AT91_PMC_SCER (AT91_PMC + 0x00) /* System Clock Enable Register */ 19#ifndef __ASSEMBLY__
20#define AT91_PMC_SCDR (AT91_PMC + 0x04) /* System Clock Disable Register */ 20extern void __iomem *at91_pmc_base;
21 21
22#define AT91_PMC_SCSR (AT91_PMC + 0x08) /* System Clock Status Register */ 22#define at91_pmc_read(field) \
23 __raw_readl(at91_pmc_base + field)
24
25#define at91_pmc_write(field, value) \
26 __raw_writel(value, at91_pmc_base + field)
27#else
28.extern at91_aic_base
29#endif
30
31#define AT91_PMC_SCER 0x00 /* System Clock Enable Register */
32#define AT91_PMC_SCDR 0x04 /* System Clock Disable Register */
33
34#define AT91_PMC_SCSR 0x08 /* System Clock Status Register */
23#define AT91_PMC_PCK (1 << 0) /* Processor Clock */ 35#define AT91_PMC_PCK (1 << 0) /* Processor Clock */
24#define AT91RM9200_PMC_UDP (1 << 1) /* USB Devcice Port Clock [AT91RM9200 only] */ 36#define AT91RM9200_PMC_UDP (1 << 1) /* USB Devcice Port Clock [AT91RM9200 only] */
25#define AT91RM9200_PMC_MCKUDP (1 << 2) /* USB Device Port Master Clock Automatic Disable on Suspend [AT91RM9200 only] */ 37#define AT91RM9200_PMC_MCKUDP (1 << 2) /* USB Device Port Master Clock Automatic Disable on Suspend [AT91RM9200 only] */
26#define AT91CAP9_PMC_DDR (1 << 2) /* DDR Clock [CAP9 revC & some SAM9 only] */
27#define AT91RM9200_PMC_UHP (1 << 4) /* USB Host Port Clock [AT91RM9200 only] */ 38#define AT91RM9200_PMC_UHP (1 << 4) /* USB Host Port Clock [AT91RM9200 only] */
28#define AT91SAM926x_PMC_UHP (1 << 6) /* USB Host Port Clock [AT91SAM926x only] */ 39#define AT91SAM926x_PMC_UHP (1 << 6) /* USB Host Port Clock [AT91SAM926x only] */
29#define AT91CAP9_PMC_UHP (1 << 6) /* USB Host Port Clock [AT91CAP9 only] */
30#define AT91SAM926x_PMC_UDP (1 << 7) /* USB Devcice Port Clock [AT91SAM926x only] */ 40#define AT91SAM926x_PMC_UDP (1 << 7) /* USB Devcice Port Clock [AT91SAM926x only] */
31#define AT91_PMC_PCK0 (1 << 8) /* Programmable Clock 0 */ 41#define AT91_PMC_PCK0 (1 << 8) /* Programmable Clock 0 */
32#define AT91_PMC_PCK1 (1 << 9) /* Programmable Clock 1 */ 42#define AT91_PMC_PCK1 (1 << 9) /* Programmable Clock 1 */
@@ -36,27 +46,31 @@
36#define AT91_PMC_HCK0 (1 << 16) /* AHB Clock (USB host) [AT91SAM9261 only] */ 46#define AT91_PMC_HCK0 (1 << 16) /* AHB Clock (USB host) [AT91SAM9261 only] */
37#define AT91_PMC_HCK1 (1 << 17) /* AHB Clock (LCD) [AT91SAM9261 only] */ 47#define AT91_PMC_HCK1 (1 << 17) /* AHB Clock (LCD) [AT91SAM9261 only] */
38 48
39#define AT91_PMC_PCER (AT91_PMC + 0x10) /* Peripheral Clock Enable Register */ 49#define AT91_PMC_PCER 0x10 /* Peripheral Clock Enable Register */
40#define AT91_PMC_PCDR (AT91_PMC + 0x14) /* Peripheral Clock Disable Register */ 50#define AT91_PMC_PCDR 0x14 /* Peripheral Clock Disable Register */
41#define AT91_PMC_PCSR (AT91_PMC + 0x18) /* Peripheral Clock Status Register */ 51#define AT91_PMC_PCSR 0x18 /* Peripheral Clock Status Register */
42 52
43#define AT91_CKGR_UCKR (AT91_PMC + 0x1C) /* UTMI Clock Register [some SAM9, CAP9] */ 53#define AT91_CKGR_UCKR 0x1C /* UTMI Clock Register [some SAM9] */
44#define AT91_PMC_UPLLEN (1 << 16) /* UTMI PLL Enable */ 54#define AT91_PMC_UPLLEN (1 << 16) /* UTMI PLL Enable */
45#define AT91_PMC_UPLLCOUNT (0xf << 20) /* UTMI PLL Start-up Time */ 55#define AT91_PMC_UPLLCOUNT (0xf << 20) /* UTMI PLL Start-up Time */
46#define AT91_PMC_BIASEN (1 << 24) /* UTMI BIAS Enable */ 56#define AT91_PMC_BIASEN (1 << 24) /* UTMI BIAS Enable */
47#define AT91_PMC_BIASCOUNT (0xf << 28) /* UTMI BIAS Start-up Time */ 57#define AT91_PMC_BIASCOUNT (0xf << 28) /* UTMI BIAS Start-up Time */
48 58
49#define AT91_CKGR_MOR (AT91_PMC + 0x20) /* Main Oscillator Register [not on SAM9RL] */ 59#define AT91_CKGR_MOR 0x20 /* Main Oscillator Register [not on SAM9RL] */
50#define AT91_PMC_MOSCEN (1 << 0) /* Main Oscillator Enable */ 60#define AT91_PMC_MOSCEN (1 << 0) /* Main Oscillator Enable */
51#define AT91_PMC_OSCBYPASS (1 << 1) /* Oscillator Bypass [SAM9x, CAP9] */ 61#define AT91_PMC_OSCBYPASS (1 << 1) /* Oscillator Bypass */
52#define AT91_PMC_OSCOUNT (0xff << 8) /* Main Oscillator Start-up Time */ 62#define AT91_PMC_MOSCRCEN (1 << 3) /* Main On-Chip RC Oscillator Enable [some SAM9] */
63#define AT91_PMC_OSCOUNT (0xff << 8) /* Main Oscillator Start-up Time */
64#define AT91_PMC_KEY (0x37 << 16) /* MOR Writing Key */
65#define AT91_PMC_MOSCSEL (1 << 24) /* Main Oscillator Selection [some SAM9] */
66#define AT91_PMC_CFDEN (1 << 25) /* Clock Failure Detector Enable [some SAM9] */
53 67
54#define AT91_CKGR_MCFR (AT91_PMC + 0x24) /* Main Clock Frequency Register */ 68#define AT91_CKGR_MCFR 0x24 /* Main Clock Frequency Register */
55#define AT91_PMC_MAINF (0xffff << 0) /* Main Clock Frequency */ 69#define AT91_PMC_MAINF (0xffff << 0) /* Main Clock Frequency */
56#define AT91_PMC_MAINRDY (1 << 16) /* Main Clock Ready */ 70#define AT91_PMC_MAINRDY (1 << 16) /* Main Clock Ready */
57 71
58#define AT91_CKGR_PLLAR (AT91_PMC + 0x28) /* PLL A Register */ 72#define AT91_CKGR_PLLAR 0x28 /* PLL A Register */
59#define AT91_CKGR_PLLBR (AT91_PMC + 0x2c) /* PLL B Register */ 73#define AT91_CKGR_PLLBR 0x2c /* PLL B Register */
60#define AT91_PMC_DIV (0xff << 0) /* Divider */ 74#define AT91_PMC_DIV (0xff << 0) /* Divider */
61#define AT91_PMC_PLLCOUNT (0x3f << 8) /* PLL Counter */ 75#define AT91_PMC_PLLCOUNT (0x3f << 8) /* PLL Counter */
62#define AT91_PMC_OUT (3 << 14) /* PLL Clock Frequency Range */ 76#define AT91_PMC_OUT (3 << 14) /* PLL Clock Frequency Range */
@@ -67,27 +81,37 @@
67#define AT91_PMC_USBDIV_4 (2 << 28) 81#define AT91_PMC_USBDIV_4 (2 << 28)
68#define AT91_PMC_USB96M (1 << 28) /* Divider by 2 Enable (PLLB only) */ 82#define AT91_PMC_USB96M (1 << 28) /* Divider by 2 Enable (PLLB only) */
69 83
70#define AT91_PMC_MCKR (AT91_PMC + 0x30) /* Master Clock Register */ 84#define AT91_PMC_MCKR 0x30 /* Master Clock Register */
71#define AT91_PMC_CSS (3 << 0) /* Master Clock Selection */ 85#define AT91_PMC_CSS (3 << 0) /* Master Clock Selection */
72#define AT91_PMC_CSS_SLOW (0 << 0) 86#define AT91_PMC_CSS_SLOW (0 << 0)
73#define AT91_PMC_CSS_MAIN (1 << 0) 87#define AT91_PMC_CSS_MAIN (1 << 0)
74#define AT91_PMC_CSS_PLLA (2 << 0) 88#define AT91_PMC_CSS_PLLA (2 << 0)
75#define AT91_PMC_CSS_PLLB (3 << 0) 89#define AT91_PMC_CSS_PLLB (3 << 0)
76#define AT91_PMC_CSS_UPLL (3 << 0) /* [some SAM9 only] */ 90#define AT91_PMC_CSS_UPLL (3 << 0) /* [some SAM9 only] */
77#define AT91_PMC_PRES (7 << 2) /* Master Clock Prescaler */ 91#define PMC_PRES_OFFSET 2
78#define AT91_PMC_PRES_1 (0 << 2) 92#define AT91_PMC_PRES (7 << PMC_PRES_OFFSET) /* Master Clock Prescaler */
79#define AT91_PMC_PRES_2 (1 << 2) 93#define AT91_PMC_PRES_1 (0 << PMC_PRES_OFFSET)
80#define AT91_PMC_PRES_4 (2 << 2) 94#define AT91_PMC_PRES_2 (1 << PMC_PRES_OFFSET)
81#define AT91_PMC_PRES_8 (3 << 2) 95#define AT91_PMC_PRES_4 (2 << PMC_PRES_OFFSET)
82#define AT91_PMC_PRES_16 (4 << 2) 96#define AT91_PMC_PRES_8 (3 << PMC_PRES_OFFSET)
83#define AT91_PMC_PRES_32 (5 << 2) 97#define AT91_PMC_PRES_16 (4 << PMC_PRES_OFFSET)
84#define AT91_PMC_PRES_64 (6 << 2) 98#define AT91_PMC_PRES_32 (5 << PMC_PRES_OFFSET)
99#define AT91_PMC_PRES_64 (6 << PMC_PRES_OFFSET)
100#define PMC_ALT_PRES_OFFSET 4
101#define AT91_PMC_ALT_PRES (7 << PMC_ALT_PRES_OFFSET) /* Master Clock Prescaler [alternate location] */
102#define AT91_PMC_ALT_PRES_1 (0 << PMC_ALT_PRES_OFFSET)
103#define AT91_PMC_ALT_PRES_2 (1 << PMC_ALT_PRES_OFFSET)
104#define AT91_PMC_ALT_PRES_4 (2 << PMC_ALT_PRES_OFFSET)
105#define AT91_PMC_ALT_PRES_8 (3 << PMC_ALT_PRES_OFFSET)
106#define AT91_PMC_ALT_PRES_16 (4 << PMC_ALT_PRES_OFFSET)
107#define AT91_PMC_ALT_PRES_32 (5 << PMC_ALT_PRES_OFFSET)
108#define AT91_PMC_ALT_PRES_64 (6 << PMC_ALT_PRES_OFFSET)
85#define AT91_PMC_MDIV (3 << 8) /* Master Clock Division */ 109#define AT91_PMC_MDIV (3 << 8) /* Master Clock Division */
86#define AT91RM9200_PMC_MDIV_1 (0 << 8) /* [AT91RM9200 only] */ 110#define AT91RM9200_PMC_MDIV_1 (0 << 8) /* [AT91RM9200 only] */
87#define AT91RM9200_PMC_MDIV_2 (1 << 8) 111#define AT91RM9200_PMC_MDIV_2 (1 << 8)
88#define AT91RM9200_PMC_MDIV_3 (2 << 8) 112#define AT91RM9200_PMC_MDIV_3 (2 << 8)
89#define AT91RM9200_PMC_MDIV_4 (3 << 8) 113#define AT91RM9200_PMC_MDIV_4 (3 << 8)
90#define AT91SAM9_PMC_MDIV_1 (0 << 8) /* [SAM9,CAP9 only] */ 114#define AT91SAM9_PMC_MDIV_1 (0 << 8) /* [SAM9 only] */
91#define AT91SAM9_PMC_MDIV_2 (1 << 8) 115#define AT91SAM9_PMC_MDIV_2 (1 << 8)
92#define AT91SAM9_PMC_MDIV_4 (2 << 8) 116#define AT91SAM9_PMC_MDIV_4 (2 << 8)
93#define AT91SAM9_PMC_MDIV_6 (3 << 8) /* [some SAM9 only] */ 117#define AT91SAM9_PMC_MDIV_6 (3 << 8) /* [some SAM9 only] */
@@ -99,35 +123,55 @@
99#define AT91_PMC_PLLADIV2_OFF (0 << 12) 123#define AT91_PMC_PLLADIV2_OFF (0 << 12)
100#define AT91_PMC_PLLADIV2_ON (1 << 12) 124#define AT91_PMC_PLLADIV2_ON (1 << 12)
101 125
102#define AT91_PMC_USB (AT91_PMC + 0x38) /* USB Clock Register [some SAM9 only] */ 126#define AT91_PMC_USB 0x38 /* USB Clock Register [some SAM9 only] */
103#define AT91_PMC_USBS (0x1 << 0) /* USB OHCI Input clock selection */ 127#define AT91_PMC_USBS (0x1 << 0) /* USB OHCI Input clock selection */
104#define AT91_PMC_USBS_PLLA (0 << 0) 128#define AT91_PMC_USBS_PLLA (0 << 0)
105#define AT91_PMC_USBS_UPLL (1 << 0) 129#define AT91_PMC_USBS_UPLL (1 << 0)
106#define AT91_PMC_OHCIUSBDIV (0xF << 8) /* Divider for USB OHCI Clock */ 130#define AT91_PMC_OHCIUSBDIV (0xF << 8) /* Divider for USB OHCI Clock */
107 131
108#define AT91_PMC_PCKR(n) (AT91_PMC + 0x40 + ((n) * 4)) /* Programmable Clock 0-N Registers */ 132#define AT91_PMC_SMD 0x3c /* Soft Modem Clock Register [some SAM9 only] */
133#define AT91_PMC_SMDS (0x1 << 0) /* SMD input clock selection */
134#define AT91_PMC_SMD_DIV (0x1f << 8) /* SMD input clock divider */
135#define AT91_PMC_SMDDIV(n) (((n) << 8) & AT91_PMC_SMD_DIV)
136
137#define AT91_PMC_PCKR(n) (0x40 + ((n) * 4)) /* Programmable Clock 0-N Registers */
138#define AT91_PMC_ALT_PCKR_CSS (0x7 << 0) /* Programmable Clock Source Selection [alternate length] */
139#define AT91_PMC_CSS_MASTER (4 << 0) /* [some SAM9 only] */
109#define AT91_PMC_CSSMCK (0x1 << 8) /* CSS or Master Clock Selection */ 140#define AT91_PMC_CSSMCK (0x1 << 8) /* CSS or Master Clock Selection */
110#define AT91_PMC_CSSMCK_CSS (0 << 8) 141#define AT91_PMC_CSSMCK_CSS (0 << 8)
111#define AT91_PMC_CSSMCK_MCK (1 << 8) 142#define AT91_PMC_CSSMCK_MCK (1 << 8)
112 143
113#define AT91_PMC_IER (AT91_PMC + 0x60) /* Interrupt Enable Register */ 144#define AT91_PMC_IER 0x60 /* Interrupt Enable Register */
114#define AT91_PMC_IDR (AT91_PMC + 0x64) /* Interrupt Disable Register */ 145#define AT91_PMC_IDR 0x64 /* Interrupt Disable Register */
115#define AT91_PMC_SR (AT91_PMC + 0x68) /* Status Register */ 146#define AT91_PMC_SR 0x68 /* Status Register */
116#define AT91_PMC_MOSCS (1 << 0) /* MOSCS Flag */ 147#define AT91_PMC_MOSCS (1 << 0) /* MOSCS Flag */
117#define AT91_PMC_LOCKA (1 << 1) /* PLLA Lock */ 148#define AT91_PMC_LOCKA (1 << 1) /* PLLA Lock */
118#define AT91_PMC_LOCKB (1 << 2) /* PLLB Lock */ 149#define AT91_PMC_LOCKB (1 << 2) /* PLLB Lock */
119#define AT91_PMC_MCKRDY (1 << 3) /* Master Clock */ 150#define AT91_PMC_MCKRDY (1 << 3) /* Master Clock */
120#define AT91_PMC_LOCKU (1 << 6) /* UPLL Lock [some SAM9, AT91CAP9 only] */ 151#define AT91_PMC_LOCKU (1 << 6) /* UPLL Lock [some SAM9] */
121#define AT91_PMC_OSCSEL (1 << 7) /* Slow Clock Oscillator [AT91CAP9 revC only] */
122#define AT91_PMC_PCK0RDY (1 << 8) /* Programmable Clock 0 */ 152#define AT91_PMC_PCK0RDY (1 << 8) /* Programmable Clock 0 */
123#define AT91_PMC_PCK1RDY (1 << 9) /* Programmable Clock 1 */ 153#define AT91_PMC_PCK1RDY (1 << 9) /* Programmable Clock 1 */
124#define AT91_PMC_PCK2RDY (1 << 10) /* Programmable Clock 2 */ 154#define AT91_PMC_PCK2RDY (1 << 10) /* Programmable Clock 2 */
125#define AT91_PMC_PCK3RDY (1 << 11) /* Programmable Clock 3 */ 155#define AT91_PMC_PCK3RDY (1 << 11) /* Programmable Clock 3 */
126#define AT91_PMC_IMR (AT91_PMC + 0x6c) /* Interrupt Mask Register */ 156#define AT91_PMC_MOSCSELS (1 << 16) /* Main Oscillator Selection [some SAM9] */
157#define AT91_PMC_MOSCRCS (1 << 17) /* Main On-Chip RC [some SAM9] */
158#define AT91_PMC_CFDEV (1 << 18) /* Clock Failure Detector Event [some SAM9] */
159#define AT91_PMC_IMR 0x6c /* Interrupt Mask Register */
160
161#define AT91_PMC_PROT 0xe4 /* Write Protect Mode Register [some SAM9] */
162#define AT91_PMC_WPEN (0x1 << 0) /* Write Protect Enable */
163#define AT91_PMC_WPKEY (0xffffff << 8) /* Write Protect Key */
164#define AT91_PMC_PROTKEY (0x504d43 << 8) /* Activation Code */
127 165
128#define AT91_PMC_PROT (AT91_PMC + 0xe4) /* Protect Register [AT91CAP9 revC only] */ 166#define AT91_PMC_WPSR 0xe8 /* Write Protect Status Register [some SAM9] */
129#define AT91_PMC_PROTKEY 0x504d4301 /* Activation Code */ 167#define AT91_PMC_WPVS (0x1 << 0) /* Write Protect Violation Status */
168#define AT91_PMC_WPVSRC (0xffff << 8) /* Write Protect Violation Source */
130 169
131#define AT91_PMC_VER (AT91_PMC + 0xfc) /* PMC Module Version [AT91CAP9 only] */ 170#define AT91_PMC_PCR 0x10c /* Peripheral Control Register [some SAM9] */
171#define AT91_PMC_PCR_PID (0x3f << 0) /* Peripheral ID */
172#define AT91_PMC_PCR_CMD (0x1 << 12) /* Command */
173#define AT91_PMC_PCR_DIV (0x3 << 16) /* Divisor Value */
174#define AT91_PMC_PCRDIV(n) (((n) << 16) & AT91_PMC_PCR_DIV)
175#define AT91_PMC_PCR_EN (0x1 << 28) /* Enable */
132 176
133#endif 177#endif
diff --git a/arch/arm/mach-at91/include/mach/at91_ramc.h b/arch/arm/mach-at91/include/mach/at91_ramc.h
new file mode 100644
index 00000000000..d8aeb278614
--- /dev/null
+++ b/arch/arm/mach-at91/include/mach/at91_ramc.h
@@ -0,0 +1,32 @@
1/*
2 * Header file for the Atmel RAM Controller
3 *
4 * Copyright (C) 2011 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
5 *
6 * Under GPLv2 only
7 */
8
9#ifndef __AT91_RAMC_H__
10#define __AT91_RAMC_H__
11
12#ifndef __ASSEMBLY__
13extern void __iomem *at91_ramc_base[];
14
15#define at91_ramc_read(id, field) \
16 __raw_readl(at91_ramc_base[id] + field)
17
18#define at91_ramc_write(id, field, value) \
19 __raw_writel(value, at91_ramc_base[id] + field)
20#else
21.extern at91_ramc_base
22#endif
23
24#define AT91_MEMCTRL_MC 0
25#define AT91_MEMCTRL_SDRAMC 1
26#define AT91_MEMCTRL_DDRSDR 2
27
28#include <mach/at91rm9200_sdramc.h>
29#include <mach/at91sam9_ddrsdr.h>
30#include <mach/at91sam9_sdramc.h>
31
32#endif /* __AT91_RAMC_H__ */
diff --git a/arch/arm/mach-at91/include/mach/at91_shdwc.h b/arch/arm/mach-at91/include/mach/at91_shdwc.h
index 1d4fe822c77..60478ea8bd4 100644
--- a/arch/arm/mach-at91/include/mach/at91_shdwc.h
+++ b/arch/arm/mach-at91/include/mach/at91_shdwc.h
@@ -36,9 +36,11 @@ extern void __iomem *at91_shdwc_base;
36#define AT91_SHDW_WKMODE0_HIGH 1 36#define AT91_SHDW_WKMODE0_HIGH 1
37#define AT91_SHDW_WKMODE0_LOW 2 37#define AT91_SHDW_WKMODE0_LOW 2
38#define AT91_SHDW_WKMODE0_ANYLEVEL 3 38#define AT91_SHDW_WKMODE0_ANYLEVEL 3
39#define AT91_SHDW_CPTWK0 (0xf << 4) /* Counter On Wake Up 0 */ 39#define AT91_SHDW_CPTWK0_MAX 0xf /* Maximum Counter On Wake Up 0 */
40#define AT91_SHDW_CPTWK0 (AT91_SHDW_CPTWK0_MAX << 4) /* Counter On Wake Up 0 */
40#define AT91_SHDW_CPTWK0_(x) ((x) << 4) 41#define AT91_SHDW_CPTWK0_(x) ((x) << 4)
41#define AT91_SHDW_RTTWKEN (1 << 16) /* Real Time Timer Wake-up Enable */ 42#define AT91_SHDW_RTTWKEN (1 << 16) /* Real Time Timer Wake-up Enable */
43#define AT91_SHDW_RTCWKEN (1 << 17) /* Real Time Clock Wake-up Enable */
42 44
43#define AT91_SHDW_SR 0x08 /* Shut Down Status Register */ 45#define AT91_SHDW_SR 0x08 /* Shut Down Status Register */
44#define AT91_SHDW_WAKEUP0 (1 << 0) /* Wake-up 0 Status */ 46#define AT91_SHDW_WAKEUP0 (1 << 0) /* Wake-up 0 Status */
diff --git a/arch/arm/mach-at91/include/mach/at91_st.h b/arch/arm/mach-at91/include/mach/at91_st.h
index 8847173e410..969aac27109 100644
--- a/arch/arm/mach-at91/include/mach/at91_st.h
+++ b/arch/arm/mach-at91/include/mach/at91_st.h
@@ -16,34 +16,46 @@
16#ifndef AT91_ST_H 16#ifndef AT91_ST_H
17#define AT91_ST_H 17#define AT91_ST_H
18 18
19#define AT91_ST_CR (AT91_ST + 0x00) /* Control Register */ 19#ifndef __ASSEMBLY__
20extern void __iomem *at91_st_base;
21
22#define at91_st_read(field) \
23 __raw_readl(at91_st_base + field)
24
25#define at91_st_write(field, value) \
26 __raw_writel(value, at91_st_base + field);
27#else
28.extern at91_st_base
29#endif
30
31#define AT91_ST_CR 0x00 /* Control Register */
20#define AT91_ST_WDRST (1 << 0) /* Watchdog Timer Restart */ 32#define AT91_ST_WDRST (1 << 0) /* Watchdog Timer Restart */
21 33
22#define AT91_ST_PIMR (AT91_ST + 0x04) /* Period Interval Mode Register */ 34#define AT91_ST_PIMR 0x04 /* Period Interval Mode Register */
23#define AT91_ST_PIV (0xffff << 0) /* Period Interval Value */ 35#define AT91_ST_PIV (0xffff << 0) /* Period Interval Value */
24 36
25#define AT91_ST_WDMR (AT91_ST + 0x08) /* Watchdog Mode Register */ 37#define AT91_ST_WDMR 0x08 /* Watchdog Mode Register */
26#define AT91_ST_WDV (0xffff << 0) /* Watchdog Counter Value */ 38#define AT91_ST_WDV (0xffff << 0) /* Watchdog Counter Value */
27#define AT91_ST_RSTEN (1 << 16) /* Reset Enable */ 39#define AT91_ST_RSTEN (1 << 16) /* Reset Enable */
28#define AT91_ST_EXTEN (1 << 17) /* External Signal Assertion Enable */ 40#define AT91_ST_EXTEN (1 << 17) /* External Signal Assertion Enable */
29 41
30#define AT91_ST_RTMR (AT91_ST + 0x0c) /* Real-time Mode Register */ 42#define AT91_ST_RTMR 0x0c /* Real-time Mode Register */
31#define AT91_ST_RTPRES (0xffff << 0) /* Real-time Prescalar Value */ 43#define AT91_ST_RTPRES (0xffff << 0) /* Real-time Prescalar Value */
32 44
33#define AT91_ST_SR (AT91_ST + 0x10) /* Status Register */ 45#define AT91_ST_SR 0x10 /* Status Register */
34#define AT91_ST_PITS (1 << 0) /* Period Interval Timer Status */ 46#define AT91_ST_PITS (1 << 0) /* Period Interval Timer Status */
35#define AT91_ST_WDOVF (1 << 1) /* Watchdog Overflow */ 47#define AT91_ST_WDOVF (1 << 1) /* Watchdog Overflow */
36#define AT91_ST_RTTINC (1 << 2) /* Real-time Timer Increment */ 48#define AT91_ST_RTTINC (1 << 2) /* Real-time Timer Increment */
37#define AT91_ST_ALMS (1 << 3) /* Alarm Status */ 49#define AT91_ST_ALMS (1 << 3) /* Alarm Status */
38 50
39#define AT91_ST_IER (AT91_ST + 0x14) /* Interrupt Enable Register */ 51#define AT91_ST_IER 0x14 /* Interrupt Enable Register */
40#define AT91_ST_IDR (AT91_ST + 0x18) /* Interrupt Disable Register */ 52#define AT91_ST_IDR 0x18 /* Interrupt Disable Register */
41#define AT91_ST_IMR (AT91_ST + 0x1c) /* Interrupt Mask Register */ 53#define AT91_ST_IMR 0x1c /* Interrupt Mask Register */
42 54
43#define AT91_ST_RTAR (AT91_ST + 0x20) /* Real-time Alarm Register */ 55#define AT91_ST_RTAR 0x20 /* Real-time Alarm Register */
44#define AT91_ST_ALMV (0xfffff << 0) /* Alarm Value */ 56#define AT91_ST_ALMV (0xfffff << 0) /* Alarm Value */
45 57
46#define AT91_ST_CRTR (AT91_ST + 0x24) /* Current Real-time Register */ 58#define AT91_ST_CRTR 0x24 /* Current Real-time Register */
47#define AT91_ST_CRTV (0xfffff << 0) /* Current Real-Time Value */ 59#define AT91_ST_CRTV (0xfffff << 0) /* Current Real-Time Value */
48 60
49#endif 61#endif
diff --git a/arch/arm/mach-at91/include/mach/at91cap9.h b/arch/arm/mach-at91/include/mach/at91cap9.h
deleted file mode 100644
index 61d952902f2..00000000000
--- a/arch/arm/mach-at91/include/mach/at91cap9.h
+++ /dev/null
@@ -1,122 +0,0 @@
1/*
2 * arch/arm/mach-at91/include/mach/at91cap9.h
3 *
4 * Copyright (C) 2007 Stelian Pop <stelian.pop@leadtechdesign.com>
5 * Copyright (C) 2007 Lead Tech Design <www.leadtechdesign.com>
6 * Copyright (C) 2007 Atmel Corporation.
7 *
8 * Common definitions.
9 * Based on AT91CAP9 datasheet revision B (Preliminary).
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 */
16
17#ifndef AT91CAP9_H
18#define AT91CAP9_H
19
20/*
21 * Peripheral identifiers/interrupts.
22 */
23#define AT91CAP9_ID_PIOABCD 2 /* Parallel IO Controller A, B, C and D */
24#define AT91CAP9_ID_MPB0 3 /* MP Block Peripheral 0 */
25#define AT91CAP9_ID_MPB1 4 /* MP Block Peripheral 1 */
26#define AT91CAP9_ID_MPB2 5 /* MP Block Peripheral 2 */
27#define AT91CAP9_ID_MPB3 6 /* MP Block Peripheral 3 */
28#define AT91CAP9_ID_MPB4 7 /* MP Block Peripheral 4 */
29#define AT91CAP9_ID_US0 8 /* USART 0 */
30#define AT91CAP9_ID_US1 9 /* USART 1 */
31#define AT91CAP9_ID_US2 10 /* USART 2 */
32#define AT91CAP9_ID_MCI0 11 /* Multimedia Card Interface 0 */
33#define AT91CAP9_ID_MCI1 12 /* Multimedia Card Interface 1 */
34#define AT91CAP9_ID_CAN 13 /* CAN */
35#define AT91CAP9_ID_TWI 14 /* Two-Wire Interface */
36#define AT91CAP9_ID_SPI0 15 /* Serial Peripheral Interface 0 */
37#define AT91CAP9_ID_SPI1 16 /* Serial Peripheral Interface 0 */
38#define AT91CAP9_ID_SSC0 17 /* Serial Synchronous Controller 0 */
39#define AT91CAP9_ID_SSC1 18 /* Serial Synchronous Controller 1 */
40#define AT91CAP9_ID_AC97C 19 /* AC97 Controller */
41#define AT91CAP9_ID_TCB 20 /* Timer Counter 0, 1 and 2 */
42#define AT91CAP9_ID_PWMC 21 /* Pulse Width Modulation Controller */
43#define AT91CAP9_ID_EMAC 22 /* Ethernet */
44#define AT91CAP9_ID_AESTDES 23 /* Advanced Encryption Standard, Triple DES */
45#define AT91CAP9_ID_ADC 24 /* Analog-to-Digital Converter */
46#define AT91CAP9_ID_ISI 25 /* Image Sensor Interface */
47#define AT91CAP9_ID_LCDC 26 /* LCD Controller */
48#define AT91CAP9_ID_DMA 27 /* DMA Controller */
49#define AT91CAP9_ID_UDPHS 28 /* USB High Speed Device Port */
50#define AT91CAP9_ID_UHP 29 /* USB Host Port */
51#define AT91CAP9_ID_IRQ0 30 /* Advanced Interrupt Controller (IRQ0) */
52#define AT91CAP9_ID_IRQ1 31 /* Advanced Interrupt Controller (IRQ1) */
53
54/*
55 * User Peripheral physical base addresses.
56 */
57#define AT91CAP9_BASE_UDPHS 0xfff78000
58#define AT91CAP9_BASE_TCB0 0xfff7c000
59#define AT91CAP9_BASE_TC0 0xfff7c000
60#define AT91CAP9_BASE_TC1 0xfff7c040
61#define AT91CAP9_BASE_TC2 0xfff7c080
62#define AT91CAP9_BASE_MCI0 0xfff80000
63#define AT91CAP9_BASE_MCI1 0xfff84000
64#define AT91CAP9_BASE_TWI 0xfff88000
65#define AT91CAP9_BASE_US0 0xfff8c000
66#define AT91CAP9_BASE_US1 0xfff90000
67#define AT91CAP9_BASE_US2 0xfff94000
68#define AT91CAP9_BASE_SSC0 0xfff98000
69#define AT91CAP9_BASE_SSC1 0xfff9c000
70#define AT91CAP9_BASE_AC97C 0xfffa0000
71#define AT91CAP9_BASE_SPI0 0xfffa4000
72#define AT91CAP9_BASE_SPI1 0xfffa8000
73#define AT91CAP9_BASE_CAN 0xfffac000
74#define AT91CAP9_BASE_PWMC 0xfffb8000
75#define AT91CAP9_BASE_EMAC 0xfffbc000
76#define AT91CAP9_BASE_ADC 0xfffc0000
77#define AT91CAP9_BASE_ISI 0xfffc4000
78
79/*
80 * System Peripherals (offset from AT91_BASE_SYS)
81 */
82#define AT91_BCRAMC (0xffffe400 - AT91_BASE_SYS)
83#define AT91_DDRSDRC0 (0xffffe600 - AT91_BASE_SYS)
84#define AT91_MATRIX (0xffffea00 - AT91_BASE_SYS)
85#define AT91_PMC (0xfffffc00 - AT91_BASE_SYS)
86#define AT91_GPBR (cpu_is_at91cap9_revB() ? \
87 (0xfffffd50 - AT91_BASE_SYS) : \
88 (0xfffffd60 - AT91_BASE_SYS))
89
90#define AT91CAP9_BASE_ECC 0xffffe200
91#define AT91CAP9_BASE_DMA 0xffffec00
92#define AT91CAP9_BASE_SMC 0xffffe800
93#define AT91CAP9_BASE_DBGU AT91_BASE_DBGU1
94#define AT91CAP9_BASE_PIOA 0xfffff200
95#define AT91CAP9_BASE_PIOB 0xfffff400
96#define AT91CAP9_BASE_PIOC 0xfffff600
97#define AT91CAP9_BASE_PIOD 0xfffff800
98#define AT91CAP9_BASE_RSTC 0xfffffd00
99#define AT91CAP9_BASE_SHDWC 0xfffffd10
100#define AT91CAP9_BASE_RTT 0xfffffd20
101#define AT91CAP9_BASE_PIT 0xfffffd30
102#define AT91CAP9_BASE_WDT 0xfffffd40
103
104#define AT91_USART0 AT91CAP9_BASE_US0
105#define AT91_USART1 AT91CAP9_BASE_US1
106#define AT91_USART2 AT91CAP9_BASE_US2
107
108
109/*
110 * Internal Memory.
111 */
112#define AT91CAP9_SRAM_BASE 0x00100000 /* Internal SRAM base address */
113#define AT91CAP9_SRAM_SIZE (32 * SZ_1K) /* Internal SRAM size (32Kb) */
114
115#define AT91CAP9_ROM_BASE 0x00400000 /* Internal ROM base address */
116#define AT91CAP9_ROM_SIZE (32 * SZ_1K) /* Internal ROM size (32Kb) */
117
118#define AT91CAP9_LCDC_BASE 0x00500000 /* LCD Controller */
119#define AT91CAP9_UDPHS_FIFO 0x00600000 /* USB High Speed Device Port */
120#define AT91CAP9_UHP_BASE 0x00700000 /* USB Host controller */
121
122#endif
diff --git a/arch/arm/mach-at91/include/mach/at91cap9_matrix.h b/arch/arm/mach-at91/include/mach/at91cap9_matrix.h
deleted file mode 100644
index 4b9d4aff4b4..00000000000
--- a/arch/arm/mach-at91/include/mach/at91cap9_matrix.h
+++ /dev/null
@@ -1,137 +0,0 @@
1/*
2 * arch/arm/mach-at91/include/mach/at91cap9_matrix.h
3 *
4 * Copyright (C) 2007 Stelian Pop <stelian.pop@leadtechdesign.com>
5 * Copyright (C) 2007 Lead Tech Design <www.leadtechdesign.com>
6 * Copyright (C) 2006 Atmel Corporation.
7 *
8 * Memory Controllers (MATRIX, EBI) - System peripherals registers.
9 * Based on AT91CAP9 datasheet revision B (Preliminary).
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 */
16
17#ifndef AT91CAP9_MATRIX_H
18#define AT91CAP9_MATRIX_H
19
20#define AT91_MATRIX_MCFG0 (AT91_MATRIX + 0x00) /* Master Configuration Register 0 */
21#define AT91_MATRIX_MCFG1 (AT91_MATRIX + 0x04) /* Master Configuration Register 1 */
22#define AT91_MATRIX_MCFG2 (AT91_MATRIX + 0x08) /* Master Configuration Register 2 */
23#define AT91_MATRIX_MCFG3 (AT91_MATRIX + 0x0C) /* Master Configuration Register 3 */
24#define AT91_MATRIX_MCFG4 (AT91_MATRIX + 0x10) /* Master Configuration Register 4 */
25#define AT91_MATRIX_MCFG5 (AT91_MATRIX + 0x14) /* Master Configuration Register 5 */
26#define AT91_MATRIX_MCFG6 (AT91_MATRIX + 0x18) /* Master Configuration Register 6 */
27#define AT91_MATRIX_MCFG7 (AT91_MATRIX + 0x1C) /* Master Configuration Register 7 */
28#define AT91_MATRIX_MCFG8 (AT91_MATRIX + 0x20) /* Master Configuration Register 8 */
29#define AT91_MATRIX_MCFG9 (AT91_MATRIX + 0x24) /* Master Configuration Register 9 */
30#define AT91_MATRIX_MCFG10 (AT91_MATRIX + 0x28) /* Master Configuration Register 10 */
31#define AT91_MATRIX_MCFG11 (AT91_MATRIX + 0x2C) /* Master Configuration Register 11 */
32#define AT91_MATRIX_ULBT (7 << 0) /* Undefined Length Burst Type */
33#define AT91_MATRIX_ULBT_INFINITE (0 << 0)
34#define AT91_MATRIX_ULBT_SINGLE (1 << 0)
35#define AT91_MATRIX_ULBT_FOUR (2 << 0)
36#define AT91_MATRIX_ULBT_EIGHT (3 << 0)
37#define AT91_MATRIX_ULBT_SIXTEEN (4 << 0)
38
39#define AT91_MATRIX_SCFG0 (AT91_MATRIX + 0x40) /* Slave Configuration Register 0 */
40#define AT91_MATRIX_SCFG1 (AT91_MATRIX + 0x44) /* Slave Configuration Register 1 */
41#define AT91_MATRIX_SCFG2 (AT91_MATRIX + 0x48) /* Slave Configuration Register 2 */
42#define AT91_MATRIX_SCFG3 (AT91_MATRIX + 0x4C) /* Slave Configuration Register 3 */
43#define AT91_MATRIX_SCFG4 (AT91_MATRIX + 0x50) /* Slave Configuration Register 4 */
44#define AT91_MATRIX_SCFG5 (AT91_MATRIX + 0x54) /* Slave Configuration Register 5 */
45#define AT91_MATRIX_SCFG6 (AT91_MATRIX + 0x58) /* Slave Configuration Register 6 */
46#define AT91_MATRIX_SCFG7 (AT91_MATRIX + 0x5C) /* Slave Configuration Register 7 */
47#define AT91_MATRIX_SCFG8 (AT91_MATRIX + 0x60) /* Slave Configuration Register 8 */
48#define AT91_MATRIX_SCFG9 (AT91_MATRIX + 0x64) /* Slave Configuration Register 9 */
49#define AT91_MATRIX_SLOT_CYCLE (0xff << 0) /* Maximum Number of Allowed Cycles for a Burst */
50#define AT91_MATRIX_DEFMSTR_TYPE (3 << 16) /* Default Master Type */
51#define AT91_MATRIX_DEFMSTR_TYPE_NONE (0 << 16)
52#define AT91_MATRIX_DEFMSTR_TYPE_LAST (1 << 16)
53#define AT91_MATRIX_DEFMSTR_TYPE_FIXED (2 << 16)
54#define AT91_MATRIX_FIXED_DEFMSTR (0xf << 18) /* Fixed Index of Default Master */
55#define AT91_MATRIX_ARBT (3 << 24) /* Arbitration Type */
56#define AT91_MATRIX_ARBT_ROUND_ROBIN (0 << 24)
57#define AT91_MATRIX_ARBT_FIXED_PRIORITY (1 << 24)
58
59#define AT91_MATRIX_PRAS0 (AT91_MATRIX + 0x80) /* Priority Register A for Slave 0 */
60#define AT91_MATRIX_PRBS0 (AT91_MATRIX + 0x84) /* Priority Register B for Slave 0 */
61#define AT91_MATRIX_PRAS1 (AT91_MATRIX + 0x88) /* Priority Register A for Slave 1 */
62#define AT91_MATRIX_PRBS1 (AT91_MATRIX + 0x8C) /* Priority Register B for Slave 1 */
63#define AT91_MATRIX_PRAS2 (AT91_MATRIX + 0x90) /* Priority Register A for Slave 2 */
64#define AT91_MATRIX_PRBS2 (AT91_MATRIX + 0x94) /* Priority Register B for Slave 2 */
65#define AT91_MATRIX_PRAS3 (AT91_MATRIX + 0x98) /* Priority Register A for Slave 3 */
66#define AT91_MATRIX_PRBS3 (AT91_MATRIX + 0x9C) /* Priority Register B for Slave 3 */
67#define AT91_MATRIX_PRAS4 (AT91_MATRIX + 0xA0) /* Priority Register A for Slave 4 */
68#define AT91_MATRIX_PRBS4 (AT91_MATRIX + 0xA4) /* Priority Register B for Slave 4 */
69#define AT91_MATRIX_PRAS5 (AT91_MATRIX + 0xA8) /* Priority Register A for Slave 5 */
70#define AT91_MATRIX_PRBS5 (AT91_MATRIX + 0xAC) /* Priority Register B for Slave 5 */
71#define AT91_MATRIX_PRAS6 (AT91_MATRIX + 0xB0) /* Priority Register A for Slave 6 */
72#define AT91_MATRIX_PRBS6 (AT91_MATRIX + 0xB4) /* Priority Register B for Slave 6 */
73#define AT91_MATRIX_PRAS7 (AT91_MATRIX + 0xB8) /* Priority Register A for Slave 7 */
74#define AT91_MATRIX_PRBS7 (AT91_MATRIX + 0xBC) /* Priority Register B for Slave 7 */
75#define AT91_MATRIX_PRAS8 (AT91_MATRIX + 0xC0) /* Priority Register A for Slave 8 */
76#define AT91_MATRIX_PRBS8 (AT91_MATRIX + 0xC4) /* Priority Register B for Slave 8 */
77#define AT91_MATRIX_PRAS9 (AT91_MATRIX + 0xC8) /* Priority Register A for Slave 9 */
78#define AT91_MATRIX_PRBS9 (AT91_MATRIX + 0xCC) /* Priority Register B for Slave 9 */
79#define AT91_MATRIX_M0PR (3 << 0) /* Master 0 Priority */
80#define AT91_MATRIX_M1PR (3 << 4) /* Master 1 Priority */
81#define AT91_MATRIX_M2PR (3 << 8) /* Master 2 Priority */
82#define AT91_MATRIX_M3PR (3 << 12) /* Master 3 Priority */
83#define AT91_MATRIX_M4PR (3 << 16) /* Master 4 Priority */
84#define AT91_MATRIX_M5PR (3 << 20) /* Master 5 Priority */
85#define AT91_MATRIX_M6PR (3 << 24) /* Master 6 Priority */
86#define AT91_MATRIX_M7PR (3 << 28) /* Master 7 Priority */
87#define AT91_MATRIX_M8PR (3 << 0) /* Master 8 Priority (in Register B) */
88#define AT91_MATRIX_M9PR (3 << 4) /* Master 9 Priority (in Register B) */
89#define AT91_MATRIX_M10PR (3 << 8) /* Master 10 Priority (in Register B) */
90#define AT91_MATRIX_M11PR (3 << 12) /* Master 11 Priority (in Register B) */
91
92#define AT91_MATRIX_MRCR (AT91_MATRIX + 0x100) /* Master Remap Control Register */
93#define AT91_MATRIX_RCB0 (1 << 0) /* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */
94#define AT91_MATRIX_RCB1 (1 << 1) /* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */
95#define AT91_MATRIX_RCB2 (1 << 2)
96#define AT91_MATRIX_RCB3 (1 << 3)
97#define AT91_MATRIX_RCB4 (1 << 4)
98#define AT91_MATRIX_RCB5 (1 << 5)
99#define AT91_MATRIX_RCB6 (1 << 6)
100#define AT91_MATRIX_RCB7 (1 << 7)
101#define AT91_MATRIX_RCB8 (1 << 8)
102#define AT91_MATRIX_RCB9 (1 << 9)
103#define AT91_MATRIX_RCB10 (1 << 10)
104#define AT91_MATRIX_RCB11 (1 << 11)
105
106#define AT91_MPBS0_SFR (AT91_MATRIX + 0x114) /* MPBlock Slave 0 Special Function Register */
107#define AT91_MPBS1_SFR (AT91_MATRIX + 0x11C) /* MPBlock Slave 1 Special Function Register */
108
109#define AT91_MATRIX_UDPHS (AT91_MATRIX + 0x118) /* USBHS Special Function Register [AT91CAP9 only] */
110#define AT91_MATRIX_SELECT_UDPHS (0 << 31) /* select High Speed UDP */
111#define AT91_MATRIX_SELECT_UDP (1 << 31) /* select standard UDP */
112#define AT91_MATRIX_UDPHS_BYPASS_LOCK (1 << 30) /* bypass lock bit */
113
114#define AT91_MATRIX_EBICSA (AT91_MATRIX + 0x120) /* EBI Chip Select Assignment Register */
115#define AT91_MATRIX_EBI_CS1A (1 << 1) /* Chip Select 1 Assignment */
116#define AT91_MATRIX_EBI_CS1A_SMC (0 << 1)
117#define AT91_MATRIX_EBI_CS1A_BCRAMC (1 << 1)
118#define AT91_MATRIX_EBI_CS3A (1 << 3) /* Chip Select 3 Assignment */
119#define AT91_MATRIX_EBI_CS3A_SMC (0 << 3)
120#define AT91_MATRIX_EBI_CS3A_SMC_SMARTMEDIA (1 << 3)
121#define AT91_MATRIX_EBI_CS4A (1 << 4) /* Chip Select 4 Assignment */
122#define AT91_MATRIX_EBI_CS4A_SMC (0 << 4)
123#define AT91_MATRIX_EBI_CS4A_SMC_CF1 (1 << 4)
124#define AT91_MATRIX_EBI_CS5A (1 << 5) /* Chip Select 5 Assignment */
125#define AT91_MATRIX_EBI_CS5A_SMC (0 << 5)
126#define AT91_MATRIX_EBI_CS5A_SMC_CF2 (1 << 5)
127#define AT91_MATRIX_EBI_DBPUC (1 << 8) /* Data Bus Pull-up Configuration */
128#define AT91_MATRIX_EBI_DQSPDC (1 << 9) /* Data Qualifier Strobe Pull-Down Configuration */
129#define AT91_MATRIX_EBI_VDDIOMSEL (1 << 16) /* Memory voltage selection */
130#define AT91_MATRIX_EBI_VDDIOMSEL_1_8V (0 << 16)
131#define AT91_MATRIX_EBI_VDDIOMSEL_3_3V (1 << 16)
132
133#define AT91_MPBS2_SFR (AT91_MATRIX + 0x12C) /* MPBlock Slave 2 Special Function Register */
134#define AT91_MPBS3_SFR (AT91_MATRIX + 0x130) /* MPBlock Slave 3 Special Function Register */
135#define AT91_APB_SFR (AT91_MATRIX + 0x134) /* APB Bridge Special Function Register */
136
137#endif
diff --git a/arch/arm/mach-at91/include/mach/at91rm9200.h b/arch/arm/mach-at91/include/mach/at91rm9200.h
index bacb5114181..603e6aac2a4 100644
--- a/arch/arm/mach-at91/include/mach/at91rm9200.h
+++ b/arch/arm/mach-at91/include/mach/at91rm9200.h
@@ -77,26 +77,22 @@
77 77
78 78
79/* 79/*
80 * System Peripherals (offset from AT91_BASE_SYS) 80 * System Peripherals
81 */ 81 */
82#define AT91_PMC (0xfffffc00 - AT91_BASE_SYS) /* Power Management Controller */
83#define AT91_ST (0xfffffd00 - AT91_BASE_SYS) /* System Timer */
84#define AT91_MC (0xffffff00 - AT91_BASE_SYS) /* Memory Controllers */
85
86#define AT91RM9200_BASE_DBGU AT91_BASE_DBGU0 /* Debug Unit */ 82#define AT91RM9200_BASE_DBGU AT91_BASE_DBGU0 /* Debug Unit */
87#define AT91RM9200_BASE_PIOA 0xfffff400 /* PIO Controller A */ 83#define AT91RM9200_BASE_PIOA 0xfffff400 /* PIO Controller A */
88#define AT91RM9200_BASE_PIOB 0xfffff600 /* PIO Controller B */ 84#define AT91RM9200_BASE_PIOB 0xfffff600 /* PIO Controller B */
89#define AT91RM9200_BASE_PIOC 0xfffff800 /* PIO Controller C */ 85#define AT91RM9200_BASE_PIOC 0xfffff800 /* PIO Controller C */
90#define AT91RM9200_BASE_PIOD 0xfffffa00 /* PIO Controller D */ 86#define AT91RM9200_BASE_PIOD 0xfffffa00 /* PIO Controller D */
87#define AT91RM9200_BASE_ST 0xfffffd00 /* System Timer */
91#define AT91RM9200_BASE_RTC 0xfffffe00 /* Real-Time Clock */ 88#define AT91RM9200_BASE_RTC 0xfffffe00 /* Real-Time Clock */
89#define AT91RM9200_BASE_MC 0xffffff00 /* Memory Controllers */
92 90
93#define AT91_USART0 AT91RM9200_BASE_US0 91#define AT91_USART0 AT91RM9200_BASE_US0
94#define AT91_USART1 AT91RM9200_BASE_US1 92#define AT91_USART1 AT91RM9200_BASE_US1
95#define AT91_USART2 AT91RM9200_BASE_US2 93#define AT91_USART2 AT91RM9200_BASE_US2
96#define AT91_USART3 AT91RM9200_BASE_US3 94#define AT91_USART3 AT91RM9200_BASE_US3
97 95
98#define AT91_MATRIX 0 /* not supported */
99
100/* 96/*
101 * Internal Memory. 97 * Internal Memory.
102 */ 98 */
diff --git a/arch/arm/mach-at91/include/mach/at91rm9200_mc.h b/arch/arm/mach-at91/include/mach/at91rm9200_mc.h
index d34e4ed8934..aeaadfb452a 100644
--- a/arch/arm/mach-at91/include/mach/at91rm9200_mc.h
+++ b/arch/arm/mach-at91/include/mach/at91rm9200_mc.h
@@ -17,10 +17,10 @@
17#define AT91RM9200_MC_H 17#define AT91RM9200_MC_H
18 18
19/* Memory Controller */ 19/* Memory Controller */
20#define AT91_MC_RCR (AT91_MC + 0x00) /* MC Remap Control Register */ 20#define AT91_MC_RCR 0x00 /* MC Remap Control Register */
21#define AT91_MC_RCB (1 << 0) /* Remap Command Bit */ 21#define AT91_MC_RCB (1 << 0) /* Remap Command Bit */
22 22
23#define AT91_MC_ASR (AT91_MC + 0x04) /* MC Abort Status Register */ 23#define AT91_MC_ASR 0x04 /* MC Abort Status Register */
24#define AT91_MC_UNADD (1 << 0) /* Undefined Address Abort Status */ 24#define AT91_MC_UNADD (1 << 0) /* Undefined Address Abort Status */
25#define AT91_MC_MISADD (1 << 1) /* Misaligned Address Abort Status */ 25#define AT91_MC_MISADD (1 << 1) /* Misaligned Address Abort Status */
26#define AT91_MC_ABTSZ (3 << 8) /* Abort Size Status */ 26#define AT91_MC_ABTSZ (3 << 8) /* Abort Size Status */
@@ -40,16 +40,16 @@
40#define AT91_MC_SVMST2 (1 << 26) /* Saved UHP Abort Source */ 40#define AT91_MC_SVMST2 (1 << 26) /* Saved UHP Abort Source */
41#define AT91_MC_SVMST3 (1 << 27) /* Saved EMAC Abort Source */ 41#define AT91_MC_SVMST3 (1 << 27) /* Saved EMAC Abort Source */
42 42
43#define AT91_MC_AASR (AT91_MC + 0x08) /* MC Abort Address Status Register */ 43#define AT91_MC_AASR 0x08 /* MC Abort Address Status Register */
44 44
45#define AT91_MC_MPR (AT91_MC + 0x0c) /* MC Master Priority Register */ 45#define AT91_MC_MPR 0x0c /* MC Master Priority Register */
46#define AT91_MPR_MSTP0 (7 << 0) /* ARM920T Priority */ 46#define AT91_MPR_MSTP0 (7 << 0) /* ARM920T Priority */
47#define AT91_MPR_MSTP1 (7 << 4) /* PDC Priority */ 47#define AT91_MPR_MSTP1 (7 << 4) /* PDC Priority */
48#define AT91_MPR_MSTP2 (7 << 8) /* UHP Priority */ 48#define AT91_MPR_MSTP2 (7 << 8) /* UHP Priority */
49#define AT91_MPR_MSTP3 (7 << 12) /* EMAC Priority */ 49#define AT91_MPR_MSTP3 (7 << 12) /* EMAC Priority */
50 50
51/* External Bus Interface (EBI) registers */ 51/* External Bus Interface (EBI) registers */
52#define AT91_EBI_CSA (AT91_MC + 0x60) /* Chip Select Assignment Register */ 52#define AT91_EBI_CSA 0x60 /* Chip Select Assignment Register */
53#define AT91_EBI_CS0A (1 << 0) /* Chip Select 0 Assignment */ 53#define AT91_EBI_CS0A (1 << 0) /* Chip Select 0 Assignment */
54#define AT91_EBI_CS0A_SMC (0 << 0) 54#define AT91_EBI_CS0A_SMC (0 << 0)
55#define AT91_EBI_CS0A_BFC (1 << 0) 55#define AT91_EBI_CS0A_BFC (1 << 0)
@@ -66,7 +66,7 @@
66#define AT91_EBI_DBPUC (1 << 0) /* Data Bus Pull-Up Configuration */ 66#define AT91_EBI_DBPUC (1 << 0) /* Data Bus Pull-Up Configuration */
67 67
68/* Static Memory Controller (SMC) registers */ 68/* Static Memory Controller (SMC) registers */
69#define AT91_SMC_CSR(n) (AT91_MC + 0x70 + ((n) * 4))/* SMC Chip Select Register */ 69#define AT91_SMC_CSR(n) (0x70 + ((n) * 4)) /* SMC Chip Select Register */
70#define AT91_SMC_NWS (0x7f << 0) /* Number of Wait States */ 70#define AT91_SMC_NWS (0x7f << 0) /* Number of Wait States */
71#define AT91_SMC_NWS_(x) ((x) << 0) 71#define AT91_SMC_NWS_(x) ((x) << 0)
72#define AT91_SMC_WSEN (1 << 7) /* Wait State Enable */ 72#define AT91_SMC_WSEN (1 << 7) /* Wait State Enable */
@@ -87,52 +87,8 @@
87#define AT91_SMC_RWHOLD (7 << 28) /* Read & Write Signal Hold Time */ 87#define AT91_SMC_RWHOLD (7 << 28) /* Read & Write Signal Hold Time */
88#define AT91_SMC_RWHOLD_(x) ((x) << 28) 88#define AT91_SMC_RWHOLD_(x) ((x) << 28)
89 89
90/* SDRAM Controller registers */
91#define AT91_SDRAMC_MR (AT91_MC + 0x90) /* Mode Register */
92#define AT91_SDRAMC_MODE (0xf << 0) /* Command Mode */
93#define AT91_SDRAMC_MODE_NORMAL (0 << 0)
94#define AT91_SDRAMC_MODE_NOP (1 << 0)
95#define AT91_SDRAMC_MODE_PRECHARGE (2 << 0)
96#define AT91_SDRAMC_MODE_LMR (3 << 0)
97#define AT91_SDRAMC_MODE_REFRESH (4 << 0)
98#define AT91_SDRAMC_DBW (1 << 4) /* Data Bus Width */
99#define AT91_SDRAMC_DBW_32 (0 << 4)
100#define AT91_SDRAMC_DBW_16 (1 << 4)
101
102#define AT91_SDRAMC_TR (AT91_MC + 0x94) /* Refresh Timer Register */
103#define AT91_SDRAMC_COUNT (0xfff << 0) /* Refresh Timer Count */
104
105#define AT91_SDRAMC_CR (AT91_MC + 0x98) /* Configuration Register */
106#define AT91_SDRAMC_NC (3 << 0) /* Number of Column Bits */
107#define AT91_SDRAMC_NC_8 (0 << 0)
108#define AT91_SDRAMC_NC_9 (1 << 0)
109#define AT91_SDRAMC_NC_10 (2 << 0)
110#define AT91_SDRAMC_NC_11 (3 << 0)
111#define AT91_SDRAMC_NR (3 << 2) /* Number of Row Bits */
112#define AT91_SDRAMC_NR_11 (0 << 2)
113#define AT91_SDRAMC_NR_12 (1 << 2)
114#define AT91_SDRAMC_NR_13 (2 << 2)
115#define AT91_SDRAMC_NB (1 << 4) /* Number of Banks */
116#define AT91_SDRAMC_NB_2 (0 << 4)
117#define AT91_SDRAMC_NB_4 (1 << 4)
118#define AT91_SDRAMC_CAS (3 << 5) /* CAS Latency */
119#define AT91_SDRAMC_CAS_2 (2 << 5)
120#define AT91_SDRAMC_TWR (0xf << 7) /* Write Recovery Delay */
121#define AT91_SDRAMC_TRC (0xf << 11) /* Row Cycle Delay */
122#define AT91_SDRAMC_TRP (0xf << 15) /* Row Precharge Delay */
123#define AT91_SDRAMC_TRCD (0xf << 19) /* Row to Column Delay */
124#define AT91_SDRAMC_TRAS (0xf << 23) /* Active to Precharge Delay */
125#define AT91_SDRAMC_TXSR (0xf << 27) /* Exit Self Refresh to Active Delay */
126
127#define AT91_SDRAMC_SRR (AT91_MC + 0x9c) /* Self Refresh Register */
128#define AT91_SDRAMC_LPR (AT91_MC + 0xa0) /* Low Power Register */
129#define AT91_SDRAMC_IER (AT91_MC + 0xa4) /* Interrupt Enable Register */
130#define AT91_SDRAMC_IDR (AT91_MC + 0xa8) /* Interrupt Disable Register */
131#define AT91_SDRAMC_IMR (AT91_MC + 0xac) /* Interrupt Mask Register */
132#define AT91_SDRAMC_ISR (AT91_MC + 0xb0) /* Interrupt Status Register */
133
134/* Burst Flash Controller register */ 90/* Burst Flash Controller register */
135#define AT91_BFC_MR (AT91_MC + 0xc0) /* Mode Register */ 91#define AT91_BFC_MR 0xc0 /* Mode Register */
136#define AT91_BFC_BFCOM (3 << 0) /* Burst Flash Controller Operating Mode */ 92#define AT91_BFC_BFCOM (3 << 0) /* Burst Flash Controller Operating Mode */
137#define AT91_BFC_BFCOM_DISABLED (0 << 0) 93#define AT91_BFC_BFCOM_DISABLED (0 << 0)
138#define AT91_BFC_BFCOM_ASYNC (1 << 0) 94#define AT91_BFC_BFCOM_ASYNC (1 << 0)
diff --git a/arch/arm/mach-at91/include/mach/at91rm9200_sdramc.h b/arch/arm/mach-at91/include/mach/at91rm9200_sdramc.h
new file mode 100644
index 00000000000..aa047f458f1
--- /dev/null
+++ b/arch/arm/mach-at91/include/mach/at91rm9200_sdramc.h
@@ -0,0 +1,63 @@
1/*
2 * arch/arm/mach-at91/include/mach/at91rm9200_sdramc.h
3 *
4 * Copyright (C) 2005 Ivan Kokshaysky
5 * Copyright (C) SAN People
6 *
7 * Memory Controllers (SDRAMC only) - System peripherals 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 AT91RM9200_SDRAMC_H
17#define AT91RM9200_SDRAMC_H
18
19/* SDRAM Controller registers */
20#define AT91RM9200_SDRAMC_MR 0x90 /* Mode Register */
21#define AT91RM9200_SDRAMC_MODE (0xf << 0) /* Command Mode */
22#define AT91RM9200_SDRAMC_MODE_NORMAL (0 << 0)
23#define AT91RM9200_SDRAMC_MODE_NOP (1 << 0)
24#define AT91RM9200_SDRAMC_MODE_PRECHARGE (2 << 0)
25#define AT91RM9200_SDRAMC_MODE_LMR (3 << 0)
26#define AT91RM9200_SDRAMC_MODE_REFRESH (4 << 0)
27#define AT91RM9200_SDRAMC_DBW (1 << 4) /* Data Bus Width */
28#define AT91RM9200_SDRAMC_DBW_32 (0 << 4)
29#define AT91RM9200_SDRAMC_DBW_16 (1 << 4)
30
31#define AT91RM9200_SDRAMC_TR 0x94 /* Refresh Timer Register */
32#define AT91RM9200_SDRAMC_COUNT (0xfff << 0) /* Refresh Timer Count */
33
34#define AT91RM9200_SDRAMC_CR 0x98 /* Configuration Register */
35#define AT91RM9200_SDRAMC_NC (3 << 0) /* Number of Column Bits */
36#define AT91RM9200_SDRAMC_NC_8 (0 << 0)
37#define AT91RM9200_SDRAMC_NC_9 (1 << 0)
38#define AT91RM9200_SDRAMC_NC_10 (2 << 0)
39#define AT91RM9200_SDRAMC_NC_11 (3 << 0)
40#define AT91RM9200_SDRAMC_NR (3 << 2) /* Number of Row Bits */
41#define AT91RM9200_SDRAMC_NR_11 (0 << 2)
42#define AT91RM9200_SDRAMC_NR_12 (1 << 2)
43#define AT91RM9200_SDRAMC_NR_13 (2 << 2)
44#define AT91RM9200_SDRAMC_NB (1 << 4) /* Number of Banks */
45#define AT91RM9200_SDRAMC_NB_2 (0 << 4)
46#define AT91RM9200_SDRAMC_NB_4 (1 << 4)
47#define AT91RM9200_SDRAMC_CAS (3 << 5) /* CAS Latency */
48#define AT91RM9200_SDRAMC_CAS_2 (2 << 5)
49#define AT91RM9200_SDRAMC_TWR (0xf << 7) /* Write Recovery Delay */
50#define AT91RM9200_SDRAMC_TRC (0xf << 11) /* Row Cycle Delay */
51#define AT91RM9200_SDRAMC_TRP (0xf << 15) /* Row Precharge Delay */
52#define AT91RM9200_SDRAMC_TRCD (0xf << 19) /* Row to Column Delay */
53#define AT91RM9200_SDRAMC_TRAS (0xf << 23) /* Active to Precharge Delay */
54#define AT91RM9200_SDRAMC_TXSR (0xf << 27) /* Exit Self Refresh to Active Delay */
55
56#define AT91RM9200_SDRAMC_SRR 0x9c /* Self Refresh Register */
57#define AT91RM9200_SDRAMC_LPR 0xa0 /* Low Power Register */
58#define AT91RM9200_SDRAMC_IER 0xa4 /* Interrupt Enable Register */
59#define AT91RM9200_SDRAMC_IDR 0xa8 /* Interrupt Disable Register */
60#define AT91RM9200_SDRAMC_IMR 0xac /* Interrupt Mask Register */
61#define AT91RM9200_SDRAMC_ISR 0xb0 /* Interrupt Status Register */
62
63#endif
diff --git a/arch/arm/mach-at91/include/mach/at91sam9260.h b/arch/arm/mach-at91/include/mach/at91sam9260.h
index fa5ca278ade..08ae9afd00f 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9260.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9260.h
@@ -78,15 +78,12 @@
78#define AT91SAM9260_BASE_ADC 0xfffe0000 78#define AT91SAM9260_BASE_ADC 0xfffe0000
79 79
80/* 80/*
81 * System Peripherals (offset from AT91_BASE_SYS) 81 * System Peripherals
82 */ 82 */
83#define AT91_SDRAMC0 (0xffffea00 - AT91_BASE_SYS)
84#define AT91_MATRIX (0xffffee00 - AT91_BASE_SYS)
85#define AT91_PMC (0xfffffc00 - AT91_BASE_SYS)
86#define AT91_GPBR (0xfffffd50 - AT91_BASE_SYS)
87
88#define AT91SAM9260_BASE_ECC 0xffffe800 83#define AT91SAM9260_BASE_ECC 0xffffe800
84#define AT91SAM9260_BASE_SDRAMC 0xffffea00
89#define AT91SAM9260_BASE_SMC 0xffffec00 85#define AT91SAM9260_BASE_SMC 0xffffec00
86#define AT91SAM9260_BASE_MATRIX 0xffffee00
90#define AT91SAM9260_BASE_DBGU AT91_BASE_DBGU0 87#define AT91SAM9260_BASE_DBGU AT91_BASE_DBGU0
91#define AT91SAM9260_BASE_PIOA 0xfffff400 88#define AT91SAM9260_BASE_PIOA 0xfffff400
92#define AT91SAM9260_BASE_PIOB 0xfffff600 89#define AT91SAM9260_BASE_PIOB 0xfffff600
@@ -96,6 +93,7 @@
96#define AT91SAM9260_BASE_RTT 0xfffffd20 93#define AT91SAM9260_BASE_RTT 0xfffffd20
97#define AT91SAM9260_BASE_PIT 0xfffffd30 94#define AT91SAM9260_BASE_PIT 0xfffffd30
98#define AT91SAM9260_BASE_WDT 0xfffffd40 95#define AT91SAM9260_BASE_WDT 0xfffffd40
96#define AT91SAM9260_BASE_GPBR 0xfffffd50
99 97
100#define AT91_USART0 AT91SAM9260_BASE_US0 98#define AT91_USART0 AT91SAM9260_BASE_US0
101#define AT91_USART1 AT91SAM9260_BASE_US1 99#define AT91_USART1 AT91SAM9260_BASE_US1
@@ -115,6 +113,8 @@
115#define AT91SAM9260_SRAM0_SIZE SZ_4K /* Internal SRAM 0 size (4Kb) */ 113#define AT91SAM9260_SRAM0_SIZE SZ_4K /* Internal SRAM 0 size (4Kb) */
116#define AT91SAM9260_SRAM1_BASE 0x00300000 /* Internal SRAM 1 base address */ 114#define AT91SAM9260_SRAM1_BASE 0x00300000 /* Internal SRAM 1 base address */
117#define AT91SAM9260_SRAM1_SIZE SZ_4K /* Internal SRAM 1 size (4Kb) */ 115#define AT91SAM9260_SRAM1_SIZE SZ_4K /* Internal SRAM 1 size (4Kb) */
116#define AT91SAM9260_SRAM_BASE 0x002FF000 /* Internal SRAM base address */
117#define AT91SAM9260_SRAM_SIZE SZ_8K /* Internal SRAM size (8Kb) */
118 118
119#define AT91SAM9260_UHP_BASE 0x00500000 /* USB Host controller */ 119#define AT91SAM9260_UHP_BASE 0x00500000 /* USB Host controller */
120 120
@@ -128,6 +128,8 @@
128#define AT91SAM9G20_SRAM0_SIZE SZ_16K /* Internal SRAM 0 size (16Kb) */ 128#define AT91SAM9G20_SRAM0_SIZE SZ_16K /* Internal SRAM 0 size (16Kb) */
129#define AT91SAM9G20_SRAM1_BASE 0x00300000 /* Internal SRAM 1 base address */ 129#define AT91SAM9G20_SRAM1_BASE 0x00300000 /* Internal SRAM 1 base address */
130#define AT91SAM9G20_SRAM1_SIZE SZ_16K /* Internal SRAM 1 size (16Kb) */ 130#define AT91SAM9G20_SRAM1_SIZE SZ_16K /* Internal SRAM 1 size (16Kb) */
131#define AT91SAM9G20_SRAM_BASE 0x002FC000 /* Internal SRAM base address */
132#define AT91SAM9G20_SRAM_SIZE SZ_32K /* Internal SRAM size (32Kb) */
131 133
132#define AT91SAM9G20_UHP_BASE 0x00500000 /* USB Host controller */ 134#define AT91SAM9G20_UHP_BASE 0x00500000 /* USB Host controller */
133 135
diff --git a/arch/arm/mach-at91/include/mach/at91sam9260_matrix.h b/arch/arm/mach-at91/include/mach/at91sam9260_matrix.h
index 020f02ed921..f459df42062 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9260_matrix.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9260_matrix.h
@@ -15,12 +15,12 @@
15#ifndef AT91SAM9260_MATRIX_H 15#ifndef AT91SAM9260_MATRIX_H
16#define AT91SAM9260_MATRIX_H 16#define AT91SAM9260_MATRIX_H
17 17
18#define AT91_MATRIX_MCFG0 (AT91_MATRIX + 0x00) /* Master Configuration Register 0 */ 18#define AT91_MATRIX_MCFG0 0x00 /* Master Configuration Register 0 */
19#define AT91_MATRIX_MCFG1 (AT91_MATRIX + 0x04) /* Master Configuration Register 1 */ 19#define AT91_MATRIX_MCFG1 0x04 /* Master Configuration Register 1 */
20#define AT91_MATRIX_MCFG2 (AT91_MATRIX + 0x08) /* Master Configuration Register 2 */ 20#define AT91_MATRIX_MCFG2 0x08 /* Master Configuration Register 2 */
21#define AT91_MATRIX_MCFG3 (AT91_MATRIX + 0x0C) /* Master Configuration Register 3 */ 21#define AT91_MATRIX_MCFG3 0x0C /* Master Configuration Register 3 */
22#define AT91_MATRIX_MCFG4 (AT91_MATRIX + 0x10) /* Master Configuration Register 4 */ 22#define AT91_MATRIX_MCFG4 0x10 /* Master Configuration Register 4 */
23#define AT91_MATRIX_MCFG5 (AT91_MATRIX + 0x14) /* Master Configuration Register 5 */ 23#define AT91_MATRIX_MCFG5 0x14 /* Master Configuration Register 5 */
24#define AT91_MATRIX_ULBT (7 << 0) /* Undefined Length Burst Type */ 24#define AT91_MATRIX_ULBT (7 << 0) /* Undefined Length Burst Type */
25#define AT91_MATRIX_ULBT_INFINITE (0 << 0) 25#define AT91_MATRIX_ULBT_INFINITE (0 << 0)
26#define AT91_MATRIX_ULBT_SINGLE (1 << 0) 26#define AT91_MATRIX_ULBT_SINGLE (1 << 0)
@@ -28,11 +28,11 @@
28#define AT91_MATRIX_ULBT_EIGHT (3 << 0) 28#define AT91_MATRIX_ULBT_EIGHT (3 << 0)
29#define AT91_MATRIX_ULBT_SIXTEEN (4 << 0) 29#define AT91_MATRIX_ULBT_SIXTEEN (4 << 0)
30 30
31#define AT91_MATRIX_SCFG0 (AT91_MATRIX + 0x40) /* Slave Configuration Register 0 */ 31#define AT91_MATRIX_SCFG0 0x40 /* Slave Configuration Register 0 */
32#define AT91_MATRIX_SCFG1 (AT91_MATRIX + 0x44) /* Slave Configuration Register 1 */ 32#define AT91_MATRIX_SCFG1 0x44 /* Slave Configuration Register 1 */
33#define AT91_MATRIX_SCFG2 (AT91_MATRIX + 0x48) /* Slave Configuration Register 2 */ 33#define AT91_MATRIX_SCFG2 0x48 /* Slave Configuration Register 2 */
34#define AT91_MATRIX_SCFG3 (AT91_MATRIX + 0x4C) /* Slave Configuration Register 3 */ 34#define AT91_MATRIX_SCFG3 0x4C /* Slave Configuration Register 3 */
35#define AT91_MATRIX_SCFG4 (AT91_MATRIX + 0x50) /* Slave Configuration Register 4 */ 35#define AT91_MATRIX_SCFG4 0x50 /* Slave Configuration Register 4 */
36#define AT91_MATRIX_SLOT_CYCLE (0xff << 0) /* Maximum Number of Allowed Cycles for a Burst */ 36#define AT91_MATRIX_SLOT_CYCLE (0xff << 0) /* Maximum Number of Allowed Cycles for a Burst */
37#define AT91_MATRIX_DEFMSTR_TYPE (3 << 16) /* Default Master Type */ 37#define AT91_MATRIX_DEFMSTR_TYPE (3 << 16) /* Default Master Type */
38#define AT91_MATRIX_DEFMSTR_TYPE_NONE (0 << 16) 38#define AT91_MATRIX_DEFMSTR_TYPE_NONE (0 << 16)
@@ -43,11 +43,11 @@
43#define AT91_MATRIX_ARBT_ROUND_ROBIN (0 << 24) 43#define AT91_MATRIX_ARBT_ROUND_ROBIN (0 << 24)
44#define AT91_MATRIX_ARBT_FIXED_PRIORITY (1 << 24) 44#define AT91_MATRIX_ARBT_FIXED_PRIORITY (1 << 24)
45 45
46#define AT91_MATRIX_PRAS0 (AT91_MATRIX + 0x80) /* Priority Register A for Slave 0 */ 46#define AT91_MATRIX_PRAS0 0x80 /* Priority Register A for Slave 0 */
47#define AT91_MATRIX_PRAS1 (AT91_MATRIX + 0x88) /* Priority Register A for Slave 1 */ 47#define AT91_MATRIX_PRAS1 0x88 /* Priority Register A for Slave 1 */
48#define AT91_MATRIX_PRAS2 (AT91_MATRIX + 0x90) /* Priority Register A for Slave 2 */ 48#define AT91_MATRIX_PRAS2 0x90 /* Priority Register A for Slave 2 */
49#define AT91_MATRIX_PRAS3 (AT91_MATRIX + 0x98) /* Priority Register A for Slave 3 */ 49#define AT91_MATRIX_PRAS3 0x98 /* Priority Register A for Slave 3 */
50#define AT91_MATRIX_PRAS4 (AT91_MATRIX + 0xA0) /* Priority Register A for Slave 4 */ 50#define AT91_MATRIX_PRAS4 0xA0 /* Priority Register A for Slave 4 */
51#define AT91_MATRIX_M0PR (3 << 0) /* Master 0 Priority */ 51#define AT91_MATRIX_M0PR (3 << 0) /* Master 0 Priority */
52#define AT91_MATRIX_M1PR (3 << 4) /* Master 1 Priority */ 52#define AT91_MATRIX_M1PR (3 << 4) /* Master 1 Priority */
53#define AT91_MATRIX_M2PR (3 << 8) /* Master 2 Priority */ 53#define AT91_MATRIX_M2PR (3 << 8) /* Master 2 Priority */
@@ -55,11 +55,11 @@
55#define AT91_MATRIX_M4PR (3 << 16) /* Master 4 Priority */ 55#define AT91_MATRIX_M4PR (3 << 16) /* Master 4 Priority */
56#define AT91_MATRIX_M5PR (3 << 20) /* Master 5 Priority */ 56#define AT91_MATRIX_M5PR (3 << 20) /* Master 5 Priority */
57 57
58#define AT91_MATRIX_MRCR (AT91_MATRIX + 0x100) /* Master Remap Control Register */ 58#define AT91_MATRIX_MRCR 0x100 /* Master Remap Control Register */
59#define AT91_MATRIX_RCB0 (1 << 0) /* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */ 59#define AT91_MATRIX_RCB0 (1 << 0) /* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */
60#define AT91_MATRIX_RCB1 (1 << 1) /* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */ 60#define AT91_MATRIX_RCB1 (1 << 1) /* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */
61 61
62#define AT91_MATRIX_EBICSA (AT91_MATRIX + 0x11C) /* EBI Chip Select Assignment Register */ 62#define AT91_MATRIX_EBICSA 0x11C /* EBI Chip Select Assignment Register */
63#define AT91_MATRIX_CS1A (1 << 1) /* Chip Select 1 Assignment */ 63#define AT91_MATRIX_CS1A (1 << 1) /* Chip Select 1 Assignment */
64#define AT91_MATRIX_CS1A_SMC (0 << 1) 64#define AT91_MATRIX_CS1A_SMC (0 << 1)
65#define AT91_MATRIX_CS1A_SDRAMC (1 << 1) 65#define AT91_MATRIX_CS1A_SDRAMC (1 << 1)
diff --git a/arch/arm/mach-at91/include/mach/at91sam9261.h b/arch/arm/mach-at91/include/mach/at91sam9261.h
index 7cde2d36570..44fbdc12ee6 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9261.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9261.h
@@ -63,14 +63,11 @@
63 63
64 64
65/* 65/*
66 * System Peripherals (offset from AT91_BASE_SYS) 66 * System Peripherals
67 */ 67 */
68#define AT91_SDRAMC0 (0xffffea00 - AT91_BASE_SYS)
69#define AT91_MATRIX (0xffffee00 - AT91_BASE_SYS)
70#define AT91_PMC (0xfffffc00 - AT91_BASE_SYS)
71#define AT91_GPBR (0xfffffd50 - AT91_BASE_SYS)
72
73#define AT91SAM9261_BASE_SMC 0xffffec00 68#define AT91SAM9261_BASE_SMC 0xffffec00
69#define AT91SAM9261_BASE_MATRIX 0xffffee00
70#define AT91SAM9261_BASE_SDRAMC 0xffffea00
74#define AT91SAM9261_BASE_DBGU AT91_BASE_DBGU0 71#define AT91SAM9261_BASE_DBGU AT91_BASE_DBGU0
75#define AT91SAM9261_BASE_PIOA 0xfffff400 72#define AT91SAM9261_BASE_PIOA 0xfffff400
76#define AT91SAM9261_BASE_PIOB 0xfffff600 73#define AT91SAM9261_BASE_PIOB 0xfffff600
@@ -80,6 +77,7 @@
80#define AT91SAM9261_BASE_RTT 0xfffffd20 77#define AT91SAM9261_BASE_RTT 0xfffffd20
81#define AT91SAM9261_BASE_PIT 0xfffffd30 78#define AT91SAM9261_BASE_PIT 0xfffffd30
82#define AT91SAM9261_BASE_WDT 0xfffffd40 79#define AT91SAM9261_BASE_WDT 0xfffffd40
80#define AT91SAM9261_BASE_GPBR 0xfffffd50
83 81
84#define AT91_USART0 AT91SAM9261_BASE_US0 82#define AT91_USART0 AT91SAM9261_BASE_US0
85#define AT91_USART1 AT91SAM9261_BASE_US1 83#define AT91_USART1 AT91SAM9261_BASE_US1
diff --git a/arch/arm/mach-at91/include/mach/at91sam9261_matrix.h b/arch/arm/mach-at91/include/mach/at91sam9261_matrix.h
index 69c6501915d..a50cdf8b8ca 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9261_matrix.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9261_matrix.h
@@ -15,15 +15,15 @@
15#ifndef AT91SAM9261_MATRIX_H 15#ifndef AT91SAM9261_MATRIX_H
16#define AT91SAM9261_MATRIX_H 16#define AT91SAM9261_MATRIX_H
17 17
18#define AT91_MATRIX_MCFG (AT91_MATRIX + 0x00) /* Master Configuration Register */ 18#define AT91_MATRIX_MCFG 0x00 /* Master Configuration Register */
19#define AT91_MATRIX_RCB0 (1 << 0) /* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */ 19#define AT91_MATRIX_RCB0 (1 << 0) /* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */
20#define AT91_MATRIX_RCB1 (1 << 1) /* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */ 20#define AT91_MATRIX_RCB1 (1 << 1) /* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */
21 21
22#define AT91_MATRIX_SCFG0 (AT91_MATRIX + 0x04) /* Slave Configuration Register 0 */ 22#define AT91_MATRIX_SCFG0 0x04 /* Slave Configuration Register 0 */
23#define AT91_MATRIX_SCFG1 (AT91_MATRIX + 0x08) /* Slave Configuration Register 1 */ 23#define AT91_MATRIX_SCFG1 0x08 /* Slave Configuration Register 1 */
24#define AT91_MATRIX_SCFG2 (AT91_MATRIX + 0x0C) /* Slave Configuration Register 2 */ 24#define AT91_MATRIX_SCFG2 0x0C /* Slave Configuration Register 2 */
25#define AT91_MATRIX_SCFG3 (AT91_MATRIX + 0x10) /* Slave Configuration Register 3 */ 25#define AT91_MATRIX_SCFG3 0x10 /* Slave Configuration Register 3 */
26#define AT91_MATRIX_SCFG4 (AT91_MATRIX + 0x14) /* Slave Configuration Register 4 */ 26#define AT91_MATRIX_SCFG4 0x14 /* Slave Configuration Register 4 */
27#define AT91_MATRIX_SLOT_CYCLE (0xff << 0) /* Maximum Number of Allowed Cycles for a Burst */ 27#define AT91_MATRIX_SLOT_CYCLE (0xff << 0) /* Maximum Number of Allowed Cycles for a Burst */
28#define AT91_MATRIX_DEFMSTR_TYPE (3 << 16) /* Default Master Type */ 28#define AT91_MATRIX_DEFMSTR_TYPE (3 << 16) /* Default Master Type */
29#define AT91_MATRIX_DEFMSTR_TYPE_NONE (0 << 16) 29#define AT91_MATRIX_DEFMSTR_TYPE_NONE (0 << 16)
@@ -31,7 +31,7 @@
31#define AT91_MATRIX_DEFMSTR_TYPE_FIXED (2 << 16) 31#define AT91_MATRIX_DEFMSTR_TYPE_FIXED (2 << 16)
32#define AT91_MATRIX_FIXED_DEFMSTR (7 << 18) /* Fixed Index of Default Master */ 32#define AT91_MATRIX_FIXED_DEFMSTR (7 << 18) /* Fixed Index of Default Master */
33 33
34#define AT91_MATRIX_TCR (AT91_MATRIX + 0x24) /* TCM Configuration Register */ 34#define AT91_MATRIX_TCR 0x24 /* TCM Configuration Register */
35#define AT91_MATRIX_ITCM_SIZE (0xf << 0) /* Size of ITCM enabled memory block */ 35#define AT91_MATRIX_ITCM_SIZE (0xf << 0) /* Size of ITCM enabled memory block */
36#define AT91_MATRIX_ITCM_0 (0 << 0) 36#define AT91_MATRIX_ITCM_0 (0 << 0)
37#define AT91_MATRIX_ITCM_16 (5 << 0) 37#define AT91_MATRIX_ITCM_16 (5 << 0)
@@ -43,7 +43,7 @@
43#define AT91_MATRIX_DTCM_32 (6 << 4) 43#define AT91_MATRIX_DTCM_32 (6 << 4)
44#define AT91_MATRIX_DTCM_64 (7 << 4) 44#define AT91_MATRIX_DTCM_64 (7 << 4)
45 45
46#define AT91_MATRIX_EBICSA (AT91_MATRIX + 0x30) /* EBI Chip Select Assignment Register */ 46#define AT91_MATRIX_EBICSA 0x30 /* EBI Chip Select Assignment Register */
47#define AT91_MATRIX_CS1A (1 << 1) /* Chip Select 1 Assignment */ 47#define AT91_MATRIX_CS1A (1 << 1) /* Chip Select 1 Assignment */
48#define AT91_MATRIX_CS1A_SMC (0 << 1) 48#define AT91_MATRIX_CS1A_SMC (0 << 1)
49#define AT91_MATRIX_CS1A_SDRAMC (1 << 1) 49#define AT91_MATRIX_CS1A_SDRAMC (1 << 1)
@@ -58,7 +58,7 @@
58#define AT91_MATRIX_CS5A_SMC_CF2 (1 << 5) 58#define AT91_MATRIX_CS5A_SMC_CF2 (1 << 5)
59#define AT91_MATRIX_DBPUC (1 << 8) /* Data Bus Pull-up Configuration */ 59#define AT91_MATRIX_DBPUC (1 << 8) /* Data Bus Pull-up Configuration */
60 60
61#define AT91_MATRIX_USBPUCR (AT91_MATRIX + 0x34) /* USB Pad Pull-Up Control Register */ 61#define AT91_MATRIX_USBPUCR 0x34 /* USB Pad Pull-Up Control Register */
62#define AT91_MATRIX_USBPUCR_PUON (1 << 30) /* USB Device PAD Pull-up Enable */ 62#define AT91_MATRIX_USBPUCR_PUON (1 << 30) /* USB Device PAD Pull-up Enable */
63 63
64#endif 64#endif
diff --git a/arch/arm/mach-at91/include/mach/at91sam9263.h b/arch/arm/mach-at91/include/mach/at91sam9263.h
index 5949abda962..d96cbb2e03c 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9263.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9263.h
@@ -72,18 +72,15 @@
72#define AT91SAM9263_BASE_2DGE 0xfffc8000 72#define AT91SAM9263_BASE_2DGE 0xfffc8000
73 73
74/* 74/*
75 * System Peripherals (offset from AT91_BASE_SYS) 75 * System Peripherals
76 */ 76 */
77#define AT91_SDRAMC0 (0xffffe200 - AT91_BASE_SYS)
78#define AT91_SDRAMC1 (0xffffe800 - AT91_BASE_SYS)
79#define AT91_MATRIX (0xffffec00 - AT91_BASE_SYS)
80#define AT91_PMC (0xfffffc00 - AT91_BASE_SYS)
81#define AT91_GPBR (0xfffffd60 - AT91_BASE_SYS)
82
83#define AT91SAM9263_BASE_ECC0 0xffffe000 77#define AT91SAM9263_BASE_ECC0 0xffffe000
78#define AT91SAM9263_BASE_SDRAMC0 0xffffe200
84#define AT91SAM9263_BASE_SMC0 0xffffe400 79#define AT91SAM9263_BASE_SMC0 0xffffe400
85#define AT91SAM9263_BASE_ECC1 0xffffe600 80#define AT91SAM9263_BASE_ECC1 0xffffe600
81#define AT91SAM9263_BASE_SDRAMC1 0xffffe800
86#define AT91SAM9263_BASE_SMC1 0xffffea00 82#define AT91SAM9263_BASE_SMC1 0xffffea00
83#define AT91SAM9263_BASE_MATRIX 0xffffec00
87#define AT91SAM9263_BASE_DBGU AT91_BASE_DBGU1 84#define AT91SAM9263_BASE_DBGU AT91_BASE_DBGU1
88#define AT91SAM9263_BASE_PIOA 0xfffff200 85#define AT91SAM9263_BASE_PIOA 0xfffff200
89#define AT91SAM9263_BASE_PIOB 0xfffff400 86#define AT91SAM9263_BASE_PIOB 0xfffff400
@@ -96,6 +93,7 @@
96#define AT91SAM9263_BASE_PIT 0xfffffd30 93#define AT91SAM9263_BASE_PIT 0xfffffd30
97#define AT91SAM9263_BASE_WDT 0xfffffd40 94#define AT91SAM9263_BASE_WDT 0xfffffd40
98#define AT91SAM9263_BASE_RTT1 0xfffffd50 95#define AT91SAM9263_BASE_RTT1 0xfffffd50
96#define AT91SAM9263_BASE_GPBR 0xfffffd60
99 97
100#define AT91_USART0 AT91SAM9263_BASE_US0 98#define AT91_USART0 AT91SAM9263_BASE_US0
101#define AT91_USART1 AT91SAM9263_BASE_US1 99#define AT91_USART1 AT91SAM9263_BASE_US1
diff --git a/arch/arm/mach-at91/include/mach/at91sam9263_matrix.h b/arch/arm/mach-at91/include/mach/at91sam9263_matrix.h
index 9b3efd3eb2f..ebb5fdb565e 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9263_matrix.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9263_matrix.h
@@ -15,15 +15,15 @@
15#ifndef AT91SAM9263_MATRIX_H 15#ifndef AT91SAM9263_MATRIX_H
16#define AT91SAM9263_MATRIX_H 16#define AT91SAM9263_MATRIX_H
17 17
18#define AT91_MATRIX_MCFG0 (AT91_MATRIX + 0x00) /* Master Configuration Register 0 */ 18#define AT91_MATRIX_MCFG0 0x00 /* Master Configuration Register 0 */
19#define AT91_MATRIX_MCFG1 (AT91_MATRIX + 0x04) /* Master Configuration Register 1 */ 19#define AT91_MATRIX_MCFG1 0x04 /* Master Configuration Register 1 */
20#define AT91_MATRIX_MCFG2 (AT91_MATRIX + 0x08) /* Master Configuration Register 2 */ 20#define AT91_MATRIX_MCFG2 0x08 /* Master Configuration Register 2 */
21#define AT91_MATRIX_MCFG3 (AT91_MATRIX + 0x0C) /* Master Configuration Register 3 */ 21#define AT91_MATRIX_MCFG3 0x0C /* Master Configuration Register 3 */
22#define AT91_MATRIX_MCFG4 (AT91_MATRIX + 0x10) /* Master Configuration Register 4 */ 22#define AT91_MATRIX_MCFG4 0x10 /* Master Configuration Register 4 */
23#define AT91_MATRIX_MCFG5 (AT91_MATRIX + 0x14) /* Master Configuration Register 5 */ 23#define AT91_MATRIX_MCFG5 0x14 /* Master Configuration Register 5 */
24#define AT91_MATRIX_MCFG6 (AT91_MATRIX + 0x18) /* Master Configuration Register 6 */ 24#define AT91_MATRIX_MCFG6 0x18 /* Master Configuration Register 6 */
25#define AT91_MATRIX_MCFG7 (AT91_MATRIX + 0x1C) /* Master Configuration Register 7 */ 25#define AT91_MATRIX_MCFG7 0x1C /* Master Configuration Register 7 */
26#define AT91_MATRIX_MCFG8 (AT91_MATRIX + 0x20) /* Master Configuration Register 8 */ 26#define AT91_MATRIX_MCFG8 0x20 /* Master Configuration Register 8 */
27#define AT91_MATRIX_ULBT (7 << 0) /* Undefined Length Burst Type */ 27#define AT91_MATRIX_ULBT (7 << 0) /* Undefined Length Burst Type */
28#define AT91_MATRIX_ULBT_INFINITE (0 << 0) 28#define AT91_MATRIX_ULBT_INFINITE (0 << 0)
29#define AT91_MATRIX_ULBT_SINGLE (1 << 0) 29#define AT91_MATRIX_ULBT_SINGLE (1 << 0)
@@ -31,14 +31,14 @@
31#define AT91_MATRIX_ULBT_EIGHT (3 << 0) 31#define AT91_MATRIX_ULBT_EIGHT (3 << 0)
32#define AT91_MATRIX_ULBT_SIXTEEN (4 << 0) 32#define AT91_MATRIX_ULBT_SIXTEEN (4 << 0)
33 33
34#define AT91_MATRIX_SCFG0 (AT91_MATRIX + 0x40) /* Slave Configuration Register 0 */ 34#define AT91_MATRIX_SCFG0 0x40 /* Slave Configuration Register 0 */
35#define AT91_MATRIX_SCFG1 (AT91_MATRIX + 0x44) /* Slave Configuration Register 1 */ 35#define AT91_MATRIX_SCFG1 0x44 /* Slave Configuration Register 1 */
36#define AT91_MATRIX_SCFG2 (AT91_MATRIX + 0x48) /* Slave Configuration Register 2 */ 36#define AT91_MATRIX_SCFG2 0x48 /* Slave Configuration Register 2 */
37#define AT91_MATRIX_SCFG3 (AT91_MATRIX + 0x4C) /* Slave Configuration Register 3 */ 37#define AT91_MATRIX_SCFG3 0x4C /* Slave Configuration Register 3 */
38#define AT91_MATRIX_SCFG4 (AT91_MATRIX + 0x50) /* Slave Configuration Register 4 */ 38#define AT91_MATRIX_SCFG4 0x50 /* Slave Configuration Register 4 */
39#define AT91_MATRIX_SCFG5 (AT91_MATRIX + 0x54) /* Slave Configuration Register 5 */ 39#define AT91_MATRIX_SCFG5 0x54 /* Slave Configuration Register 5 */
40#define AT91_MATRIX_SCFG6 (AT91_MATRIX + 0x58) /* Slave Configuration Register 6 */ 40#define AT91_MATRIX_SCFG6 0x58 /* Slave Configuration Register 6 */
41#define AT91_MATRIX_SCFG7 (AT91_MATRIX + 0x5C) /* Slave Configuration Register 7 */ 41#define AT91_MATRIX_SCFG7 0x5C /* Slave Configuration Register 7 */
42#define AT91_MATRIX_SLOT_CYCLE (0xff << 0) /* Maximum Number of Allowed Cycles for a Burst */ 42#define AT91_MATRIX_SLOT_CYCLE (0xff << 0) /* Maximum Number of Allowed Cycles for a Burst */
43#define AT91_MATRIX_DEFMSTR_TYPE (3 << 16) /* Default Master Type */ 43#define AT91_MATRIX_DEFMSTR_TYPE (3 << 16) /* Default Master Type */
44#define AT91_MATRIX_DEFMSTR_TYPE_NONE (0 << 16) 44#define AT91_MATRIX_DEFMSTR_TYPE_NONE (0 << 16)
@@ -49,22 +49,22 @@
49#define AT91_MATRIX_ARBT_ROUND_ROBIN (0 << 24) 49#define AT91_MATRIX_ARBT_ROUND_ROBIN (0 << 24)
50#define AT91_MATRIX_ARBT_FIXED_PRIORITY (1 << 24) 50#define AT91_MATRIX_ARBT_FIXED_PRIORITY (1 << 24)
51 51
52#define AT91_MATRIX_PRAS0 (AT91_MATRIX + 0x80) /* Priority Register A for Slave 0 */ 52#define AT91_MATRIX_PRAS0 0x80 /* Priority Register A for Slave 0 */
53#define AT91_MATRIX_PRBS0 (AT91_MATRIX + 0x84) /* Priority Register B for Slave 0 */ 53#define AT91_MATRIX_PRBS0 0x84 /* Priority Register B for Slave 0 */
54#define AT91_MATRIX_PRAS1 (AT91_MATRIX + 0x88) /* Priority Register A for Slave 1 */ 54#define AT91_MATRIX_PRAS1 0x88 /* Priority Register A for Slave 1 */
55#define AT91_MATRIX_PRBS1 (AT91_MATRIX + 0x8C) /* Priority Register B for Slave 1 */ 55#define AT91_MATRIX_PRBS1 0x8C /* Priority Register B for Slave 1 */
56#define AT91_MATRIX_PRAS2 (AT91_MATRIX + 0x90) /* Priority Register A for Slave 2 */ 56#define AT91_MATRIX_PRAS2 0x90 /* Priority Register A for Slave 2 */
57#define AT91_MATRIX_PRBS2 (AT91_MATRIX + 0x94) /* Priority Register B for Slave 2 */ 57#define AT91_MATRIX_PRBS2 0x94 /* Priority Register B for Slave 2 */
58#define AT91_MATRIX_PRAS3 (AT91_MATRIX + 0x98) /* Priority Register A for Slave 3 */ 58#define AT91_MATRIX_PRAS3 0x98 /* Priority Register A for Slave 3 */
59#define AT91_MATRIX_PRBS3 (AT91_MATRIX + 0x9C) /* Priority Register B for Slave 3 */ 59#define AT91_MATRIX_PRBS3 0x9C /* Priority Register B for Slave 3 */
60#define AT91_MATRIX_PRAS4 (AT91_MATRIX + 0xA0) /* Priority Register A for Slave 4 */ 60#define AT91_MATRIX_PRAS4 0xA0 /* Priority Register A for Slave 4 */
61#define AT91_MATRIX_PRBS4 (AT91_MATRIX + 0xA4) /* Priority Register B for Slave 4 */ 61#define AT91_MATRIX_PRBS4 0xA4 /* Priority Register B for Slave 4 */
62#define AT91_MATRIX_PRAS5 (AT91_MATRIX + 0xA8) /* Priority Register A for Slave 5 */ 62#define AT91_MATRIX_PRAS5 0xA8 /* Priority Register A for Slave 5 */
63#define AT91_MATRIX_PRBS5 (AT91_MATRIX + 0xAC) /* Priority Register B for Slave 5 */ 63#define AT91_MATRIX_PRBS5 0xAC /* Priority Register B for Slave 5 */
64#define AT91_MATRIX_PRAS6 (AT91_MATRIX + 0xB0) /* Priority Register A for Slave 6 */ 64#define AT91_MATRIX_PRAS6 0xB0 /* Priority Register A for Slave 6 */
65#define AT91_MATRIX_PRBS6 (AT91_MATRIX + 0xB4) /* Priority Register B for Slave 6 */ 65#define AT91_MATRIX_PRBS6 0xB4 /* Priority Register B for Slave 6 */
66#define AT91_MATRIX_PRAS7 (AT91_MATRIX + 0xB8) /* Priority Register A for Slave 7 */ 66#define AT91_MATRIX_PRAS7 0xB8 /* Priority Register A for Slave 7 */
67#define AT91_MATRIX_PRBS7 (AT91_MATRIX + 0xBC) /* Priority Register B for Slave 7 */ 67#define AT91_MATRIX_PRBS7 0xBC /* Priority Register B for Slave 7 */
68#define AT91_MATRIX_M0PR (3 << 0) /* Master 0 Priority */ 68#define AT91_MATRIX_M0PR (3 << 0) /* Master 0 Priority */
69#define AT91_MATRIX_M1PR (3 << 4) /* Master 1 Priority */ 69#define AT91_MATRIX_M1PR (3 << 4) /* Master 1 Priority */
70#define AT91_MATRIX_M2PR (3 << 8) /* Master 2 Priority */ 70#define AT91_MATRIX_M2PR (3 << 8) /* Master 2 Priority */
@@ -75,7 +75,7 @@
75#define AT91_MATRIX_M7PR (3 << 28) /* Master 7 Priority */ 75#define AT91_MATRIX_M7PR (3 << 28) /* Master 7 Priority */
76#define AT91_MATRIX_M8PR (3 << 0) /* Master 8 Priority (in Register B) */ 76#define AT91_MATRIX_M8PR (3 << 0) /* Master 8 Priority (in Register B) */
77 77
78#define AT91_MATRIX_MRCR (AT91_MATRIX + 0x100) /* Master Remap Control Register */ 78#define AT91_MATRIX_MRCR 0x100 /* Master Remap Control Register */
79#define AT91_MATRIX_RCB0 (1 << 0) /* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */ 79#define AT91_MATRIX_RCB0 (1 << 0) /* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */
80#define AT91_MATRIX_RCB1 (1 << 1) /* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */ 80#define AT91_MATRIX_RCB1 (1 << 1) /* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */
81#define AT91_MATRIX_RCB2 (1 << 2) 81#define AT91_MATRIX_RCB2 (1 << 2)
@@ -86,7 +86,7 @@
86#define AT91_MATRIX_RCB7 (1 << 7) 86#define AT91_MATRIX_RCB7 (1 << 7)
87#define AT91_MATRIX_RCB8 (1 << 8) 87#define AT91_MATRIX_RCB8 (1 << 8)
88 88
89#define AT91_MATRIX_TCMR (AT91_MATRIX + 0x114) /* TCM Configuration Register */ 89#define AT91_MATRIX_TCMR 0x114 /* TCM Configuration Register */
90#define AT91_MATRIX_ITCM_SIZE (0xf << 0) /* Size of ITCM enabled memory block */ 90#define AT91_MATRIX_ITCM_SIZE (0xf << 0) /* Size of ITCM enabled memory block */
91#define AT91_MATRIX_ITCM_0 (0 << 0) 91#define AT91_MATRIX_ITCM_0 (0 << 0)
92#define AT91_MATRIX_ITCM_16 (5 << 0) 92#define AT91_MATRIX_ITCM_16 (5 << 0)
@@ -96,7 +96,7 @@
96#define AT91_MATRIX_DTCM_16 (5 << 4) 96#define AT91_MATRIX_DTCM_16 (5 << 4)
97#define AT91_MATRIX_DTCM_32 (6 << 4) 97#define AT91_MATRIX_DTCM_32 (6 << 4)
98 98
99#define AT91_MATRIX_EBI0CSA (AT91_MATRIX + 0x120) /* EBI0 Chip Select Assignment Register */ 99#define AT91_MATRIX_EBI0CSA 0x120 /* EBI0 Chip Select Assignment Register */
100#define AT91_MATRIX_EBI0_CS1A (1 << 1) /* Chip Select 1 Assignment */ 100#define AT91_MATRIX_EBI0_CS1A (1 << 1) /* Chip Select 1 Assignment */
101#define AT91_MATRIX_EBI0_CS1A_SMC (0 << 1) 101#define AT91_MATRIX_EBI0_CS1A_SMC (0 << 1)
102#define AT91_MATRIX_EBI0_CS1A_SDRAMC (1 << 1) 102#define AT91_MATRIX_EBI0_CS1A_SDRAMC (1 << 1)
@@ -114,7 +114,7 @@
114#define AT91_MATRIX_EBI0_VDDIOMSEL_1_8V (0 << 16) 114#define AT91_MATRIX_EBI0_VDDIOMSEL_1_8V (0 << 16)
115#define AT91_MATRIX_EBI0_VDDIOMSEL_3_3V (1 << 16) 115#define AT91_MATRIX_EBI0_VDDIOMSEL_3_3V (1 << 16)
116 116
117#define AT91_MATRIX_EBI1CSA (AT91_MATRIX + 0x124) /* EBI1 Chip Select Assignment Register */ 117#define AT91_MATRIX_EBI1CSA 0x124 /* EBI1 Chip Select Assignment Register */
118#define AT91_MATRIX_EBI1_CS1A (1 << 1) /* Chip Select 1 Assignment */ 118#define AT91_MATRIX_EBI1_CS1A (1 << 1) /* Chip Select 1 Assignment */
119#define AT91_MATRIX_EBI1_CS1A_SMC (0 << 1) 119#define AT91_MATRIX_EBI1_CS1A_SMC (0 << 1)
120#define AT91_MATRIX_EBI1_CS1A_SDRAMC (1 << 1) 120#define AT91_MATRIX_EBI1_CS1A_SDRAMC (1 << 1)
diff --git a/arch/arm/mach-at91/include/mach/at91sam9_ddrsdr.h b/arch/arm/mach-at91/include/mach/at91sam9_ddrsdr.h
index e2f8da8ce5b..0210797abf2 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9_ddrsdr.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9_ddrsdr.h
@@ -59,7 +59,6 @@
59#define AT91_DDRSDRC_TRP (0xf << 16) /* Row precharge delay */ 59#define AT91_DDRSDRC_TRP (0xf << 16) /* Row precharge delay */
60#define AT91_DDRSDRC_TRRD (0xf << 20) /* Active BankA to BankB */ 60#define AT91_DDRSDRC_TRRD (0xf << 20) /* Active BankA to BankB */
61#define AT91_DDRSDRC_TWTR (0x7 << 24) /* Internal Write to Read delay */ 61#define AT91_DDRSDRC_TWTR (0x7 << 24) /* Internal Write to Read delay */
62#define AT91CAP9_DDRSDRC_TWTR (1 << 24) /* Internal Write to Read delay */
63#define AT91_DDRSDRC_RED_WRRD (0x1 << 27) /* Reduce Write to Read Delay [SAM9 Only] */ 62#define AT91_DDRSDRC_RED_WRRD (0x1 << 27) /* Reduce Write to Read Delay [SAM9 Only] */
64#define AT91_DDRSDRC_TMRD (0xf << 28) /* Load mode to active/refresh delay */ 63#define AT91_DDRSDRC_TMRD (0xf << 28) /* Load mode to active/refresh delay */
65 64
@@ -76,7 +75,6 @@
76#define AT91_DDRSDRC_TRTP (0x7 << 12) /* Read to Precharge delay */ 75#define AT91_DDRSDRC_TRTP (0x7 << 12) /* Read to Precharge delay */
77 76
78#define AT91_DDRSDRC_LPR 0x1C /* Low Power Register */ 77#define AT91_DDRSDRC_LPR 0x1C /* Low Power Register */
79#define AT91CAP9_DDRSDRC_LPR 0x18 /* Low Power Register */
80#define AT91_DDRSDRC_LPCB (3 << 0) /* Low-power Configurations */ 78#define AT91_DDRSDRC_LPCB (3 << 0) /* Low-power Configurations */
81#define AT91_DDRSDRC_LPCB_DISABLE 0 79#define AT91_DDRSDRC_LPCB_DISABLE 0
82#define AT91_DDRSDRC_LPCB_SELF_REFRESH 1 80#define AT91_DDRSDRC_LPCB_SELF_REFRESH 1
@@ -94,11 +92,9 @@
94#define AT91_DDRSDRC_UPD_MR (3 << 20) /* Update load mode register and extended mode register */ 92#define AT91_DDRSDRC_UPD_MR (3 << 20) /* Update load mode register and extended mode register */
95 93
96#define AT91_DDRSDRC_MDR 0x20 /* Memory Device Register */ 94#define AT91_DDRSDRC_MDR 0x20 /* Memory Device Register */
97#define AT91CAP9_DDRSDRC_MDR 0x1C /* Memory Device Register */
98#define AT91_DDRSDRC_MD (3 << 0) /* Memory Device Type */ 95#define AT91_DDRSDRC_MD (3 << 0) /* Memory Device Type */
99#define AT91_DDRSDRC_MD_SDR 0 96#define AT91_DDRSDRC_MD_SDR 0
100#define AT91_DDRSDRC_MD_LOW_POWER_SDR 1 97#define AT91_DDRSDRC_MD_LOW_POWER_SDR 1
101#define AT91CAP9_DDRSDRC_MD_DDR 2
102#define AT91_DDRSDRC_MD_LOW_POWER_DDR 3 98#define AT91_DDRSDRC_MD_LOW_POWER_DDR 3
103#define AT91_DDRSDRC_MD_DDR2 6 /* [SAM9 Only] */ 99#define AT91_DDRSDRC_MD_DDR2 6 /* [SAM9 Only] */
104#define AT91_DDRSDRC_DBW (1 << 4) /* Data Bus Width */ 100#define AT91_DDRSDRC_DBW (1 << 4) /* Data Bus Width */
@@ -106,16 +102,10 @@
106#define AT91_DDRSDRC_DBW_16BITS (1 << 4) 102#define AT91_DDRSDRC_DBW_16BITS (1 << 4)
107 103
108#define AT91_DDRSDRC_DLL 0x24 /* DLL Information Register */ 104#define AT91_DDRSDRC_DLL 0x24 /* DLL Information Register */
109#define AT91CAP9_DDRSDRC_DLL 0x20 /* DLL Information Register */
110#define AT91_DDRSDRC_MDINC (1 << 0) /* Master Delay increment */ 105#define AT91_DDRSDRC_MDINC (1 << 0) /* Master Delay increment */
111#define AT91_DDRSDRC_MDDEC (1 << 1) /* Master Delay decrement */ 106#define AT91_DDRSDRC_MDDEC (1 << 1) /* Master Delay decrement */
112#define AT91_DDRSDRC_MDOVF (1 << 2) /* Master Delay Overflow */ 107#define AT91_DDRSDRC_MDOVF (1 << 2) /* Master Delay Overflow */
113#define AT91CAP9_DDRSDRC_SDCOVF (1 << 3) /* Slave Delay Correction Overflow */
114#define AT91CAP9_DDRSDRC_SDCUDF (1 << 4) /* Slave Delay Correction Underflow */
115#define AT91CAP9_DDRSDRC_SDERF (1 << 5) /* Slave Delay Correction error */
116#define AT91_DDRSDRC_MDVAL (0xff << 8) /* Master Delay value */ 108#define AT91_DDRSDRC_MDVAL (0xff << 8) /* Master Delay value */
117#define AT91CAP9_DDRSDRC_SDVAL (0xff << 16) /* Slave Delay value */
118#define AT91CAP9_DDRSDRC_SDCVAL (0xff << 24) /* Slave Delay Correction value */
119 109
120#define AT91_DDRSDRC_HS 0x2C /* High Speed Register [SAM9 Only] */ 110#define AT91_DDRSDRC_HS 0x2C /* High Speed Register [SAM9 Only] */
121#define AT91_DDRSDRC_DIS_ATCP_RD (1 << 2) /* Anticip read access is disabled */ 111#define AT91_DDRSDRC_DIS_ATCP_RD (1 << 2) /* Anticip read access is disabled */
@@ -131,10 +121,4 @@
131#define AT91_DDRSDRC_WPVS (1 << 0) /* Write protect violation status */ 121#define AT91_DDRSDRC_WPVS (1 << 0) /* Write protect violation status */
132#define AT91_DDRSDRC_WPVSRC (0xffff << 8) /* Write protect violation source */ 122#define AT91_DDRSDRC_WPVSRC (0xffff << 8) /* Write protect violation source */
133 123
134/* Register access macros */
135#define at91_ramc_read(num, reg) \
136 at91_sys_read(AT91_DDRSDRC##num + reg)
137#define at91_ramc_write(num, reg, value) \
138 at91_sys_write(AT91_DDRSDRC##num + reg, value)
139
140#endif 124#endif
diff --git a/arch/arm/mach-at91/include/mach/at91sam9_sdramc.h b/arch/arm/mach-at91/include/mach/at91sam9_sdramc.h
index 100f5a59292..3d085a9a745 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9_sdramc.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9_sdramc.h
@@ -82,10 +82,4 @@
82#define AT91_SDRAMC_MD_SDRAM 0 82#define AT91_SDRAMC_MD_SDRAM 0
83#define AT91_SDRAMC_MD_LOW_POWER_SDRAM 1 83#define AT91_SDRAMC_MD_LOW_POWER_SDRAM 1
84 84
85/* Register access macros */
86#define at91_ramc_read(num, reg) \
87 at91_sys_read(AT91_SDRAMC##num + reg)
88#define at91_ramc_write(num, reg, value) \
89 at91_sys_write(AT91_SDRAMC##num + reg, value)
90
91#endif 85#endif
diff --git a/arch/arm/mach-at91/include/mach/at91sam9g45.h b/arch/arm/mach-at91/include/mach/at91sam9g45.h
index dd9c95ea086..d052abcff85 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9g45.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9g45.h
@@ -84,17 +84,14 @@
84#define AT91SAM9G45_BASE_TC5 0xfffd4080 84#define AT91SAM9G45_BASE_TC5 0xfffd4080
85 85
86/* 86/*
87 * System Peripherals (offset from AT91_BASE_SYS) 87 * System Peripherals
88 */ 88 */
89#define AT91_DDRSDRC1 (0xffffe400 - AT91_BASE_SYS)
90#define AT91_DDRSDRC0 (0xffffe600 - AT91_BASE_SYS)
91#define AT91_MATRIX (0xffffea00 - AT91_BASE_SYS)
92#define AT91_PMC (0xfffffc00 - AT91_BASE_SYS)
93#define AT91_GPBR (0xfffffd60 - AT91_BASE_SYS)
94
95#define AT91SAM9G45_BASE_ECC 0xffffe200 89#define AT91SAM9G45_BASE_ECC 0xffffe200
90#define AT91SAM9G45_BASE_DDRSDRC1 0xffffe400
91#define AT91SAM9G45_BASE_DDRSDRC0 0xffffe600
96#define AT91SAM9G45_BASE_DMA 0xffffec00 92#define AT91SAM9G45_BASE_DMA 0xffffec00
97#define AT91SAM9G45_BASE_SMC 0xffffe800 93#define AT91SAM9G45_BASE_SMC 0xffffe800
94#define AT91SAM9G45_BASE_MATRIX 0xffffea00
98#define AT91SAM9G45_BASE_DBGU AT91_BASE_DBGU1 95#define AT91SAM9G45_BASE_DBGU AT91_BASE_DBGU1
99#define AT91SAM9G45_BASE_PIOA 0xfffff200 96#define AT91SAM9G45_BASE_PIOA 0xfffff200
100#define AT91SAM9G45_BASE_PIOB 0xfffff400 97#define AT91SAM9G45_BASE_PIOB 0xfffff400
@@ -107,6 +104,7 @@
107#define AT91SAM9G45_BASE_PIT 0xfffffd30 104#define AT91SAM9G45_BASE_PIT 0xfffffd30
108#define AT91SAM9G45_BASE_WDT 0xfffffd40 105#define AT91SAM9G45_BASE_WDT 0xfffffd40
109#define AT91SAM9G45_BASE_RTC 0xfffffdb0 106#define AT91SAM9G45_BASE_RTC 0xfffffdb0
107#define AT91SAM9G45_BASE_GPBR 0xfffffd60
110 108
111#define AT91_USART0 AT91SAM9G45_BASE_US0 109#define AT91_USART0 AT91SAM9G45_BASE_US0
112#define AT91_USART1 AT91SAM9G45_BASE_US1 110#define AT91_USART1 AT91SAM9G45_BASE_US1
diff --git a/arch/arm/mach-at91/include/mach/at91sam9g45_matrix.h b/arch/arm/mach-at91/include/mach/at91sam9g45_matrix.h
index c972d60e0ae..b76e2ed2fbc 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9g45_matrix.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9g45_matrix.h
@@ -15,18 +15,18 @@
15#ifndef AT91SAM9G45_MATRIX_H 15#ifndef AT91SAM9G45_MATRIX_H
16#define AT91SAM9G45_MATRIX_H 16#define AT91SAM9G45_MATRIX_H
17 17
18#define AT91_MATRIX_MCFG0 (AT91_MATRIX + 0x00) /* Master Configuration Register 0 */ 18#define AT91_MATRIX_MCFG0 0x00 /* Master Configuration Register 0 */
19#define AT91_MATRIX_MCFG1 (AT91_MATRIX + 0x04) /* Master Configuration Register 1 */ 19#define AT91_MATRIX_MCFG1 0x04 /* Master Configuration Register 1 */
20#define AT91_MATRIX_MCFG2 (AT91_MATRIX + 0x08) /* Master Configuration Register 2 */ 20#define AT91_MATRIX_MCFG2 0x08 /* Master Configuration Register 2 */
21#define AT91_MATRIX_MCFG3 (AT91_MATRIX + 0x0C) /* Master Configuration Register 3 */ 21#define AT91_MATRIX_MCFG3 0x0C /* Master Configuration Register 3 */
22#define AT91_MATRIX_MCFG4 (AT91_MATRIX + 0x10) /* Master Configuration Register 4 */ 22#define AT91_MATRIX_MCFG4 0x10 /* Master Configuration Register 4 */
23#define AT91_MATRIX_MCFG5 (AT91_MATRIX + 0x14) /* Master Configuration Register 5 */ 23#define AT91_MATRIX_MCFG5 0x14 /* Master Configuration Register 5 */
24#define AT91_MATRIX_MCFG6 (AT91_MATRIX + 0x18) /* Master Configuration Register 6 */ 24#define AT91_MATRIX_MCFG6 0x18 /* Master Configuration Register 6 */
25#define AT91_MATRIX_MCFG7 (AT91_MATRIX + 0x1C) /* Master Configuration Register 7 */ 25#define AT91_MATRIX_MCFG7 0x1C /* Master Configuration Register 7 */
26#define AT91_MATRIX_MCFG8 (AT91_MATRIX + 0x20) /* Master Configuration Register 8 */ 26#define AT91_MATRIX_MCFG8 0x20 /* Master Configuration Register 8 */
27#define AT91_MATRIX_MCFG9 (AT91_MATRIX + 0x24) /* Master Configuration Register 9 */ 27#define AT91_MATRIX_MCFG9 0x24 /* Master Configuration Register 9 */
28#define AT91_MATRIX_MCFG10 (AT91_MATRIX + 0x28) /* Master Configuration Register 10 */ 28#define AT91_MATRIX_MCFG10 0x28 /* Master Configuration Register 10 */
29#define AT91_MATRIX_MCFG11 (AT91_MATRIX + 0x2C) /* Master Configuration Register 11 */ 29#define AT91_MATRIX_MCFG11 0x2C /* Master Configuration Register 11 */
30#define AT91_MATRIX_ULBT (7 << 0) /* Undefined Length Burst Type */ 30#define AT91_MATRIX_ULBT (7 << 0) /* Undefined Length Burst Type */
31#define AT91_MATRIX_ULBT_INFINITE (0 << 0) 31#define AT91_MATRIX_ULBT_INFINITE (0 << 0)
32#define AT91_MATRIX_ULBT_SINGLE (1 << 0) 32#define AT91_MATRIX_ULBT_SINGLE (1 << 0)
@@ -37,14 +37,14 @@
37#define AT91_MATRIX_ULBT_SIXTYFOUR (6 << 0) 37#define AT91_MATRIX_ULBT_SIXTYFOUR (6 << 0)
38#define AT91_MATRIX_ULBT_128 (7 << 0) 38#define AT91_MATRIX_ULBT_128 (7 << 0)
39 39
40#define AT91_MATRIX_SCFG0 (AT91_MATRIX + 0x40) /* Slave Configuration Register 0 */ 40#define AT91_MATRIX_SCFG0 0x40 /* Slave Configuration Register 0 */
41#define AT91_MATRIX_SCFG1 (AT91_MATRIX + 0x44) /* Slave Configuration Register 1 */ 41#define AT91_MATRIX_SCFG1 0x44 /* Slave Configuration Register 1 */
42#define AT91_MATRIX_SCFG2 (AT91_MATRIX + 0x48) /* Slave Configuration Register 2 */ 42#define AT91_MATRIX_SCFG2 0x48 /* Slave Configuration Register 2 */
43#define AT91_MATRIX_SCFG3 (AT91_MATRIX + 0x4C) /* Slave Configuration Register 3 */ 43#define AT91_MATRIX_SCFG3 0x4C /* Slave Configuration Register 3 */
44#define AT91_MATRIX_SCFG4 (AT91_MATRIX + 0x50) /* Slave Configuration Register 4 */ 44#define AT91_MATRIX_SCFG4 0x50 /* Slave Configuration Register 4 */
45#define AT91_MATRIX_SCFG5 (AT91_MATRIX + 0x54) /* Slave Configuration Register 5 */ 45#define AT91_MATRIX_SCFG5 0x54 /* Slave Configuration Register 5 */
46#define AT91_MATRIX_SCFG6 (AT91_MATRIX + 0x58) /* Slave Configuration Register 6 */ 46#define AT91_MATRIX_SCFG6 0x58 /* Slave Configuration Register 6 */
47#define AT91_MATRIX_SCFG7 (AT91_MATRIX + 0x5C) /* Slave Configuration Register 7 */ 47#define AT91_MATRIX_SCFG7 0x5C /* Slave Configuration Register 7 */
48#define AT91_MATRIX_SLOT_CYCLE (0x1ff << 0) /* Maximum Number of Allowed Cycles for a Burst */ 48#define AT91_MATRIX_SLOT_CYCLE (0x1ff << 0) /* Maximum Number of Allowed Cycles for a Burst */
49#define AT91_MATRIX_DEFMSTR_TYPE (3 << 16) /* Default Master Type */ 49#define AT91_MATRIX_DEFMSTR_TYPE (3 << 16) /* Default Master Type */
50#define AT91_MATRIX_DEFMSTR_TYPE_NONE (0 << 16) 50#define AT91_MATRIX_DEFMSTR_TYPE_NONE (0 << 16)
@@ -52,22 +52,22 @@
52#define AT91_MATRIX_DEFMSTR_TYPE_FIXED (2 << 16) 52#define AT91_MATRIX_DEFMSTR_TYPE_FIXED (2 << 16)
53#define AT91_MATRIX_FIXED_DEFMSTR (0xf << 18) /* Fixed Index of Default Master */ 53#define AT91_MATRIX_FIXED_DEFMSTR (0xf << 18) /* Fixed Index of Default Master */
54 54
55#define AT91_MATRIX_PRAS0 (AT91_MATRIX + 0x80) /* Priority Register A for Slave 0 */ 55#define AT91_MATRIX_PRAS0 0x80 /* Priority Register A for Slave 0 */
56#define AT91_MATRIX_PRBS0 (AT91_MATRIX + 0x84) /* Priority Register B for Slave 0 */ 56#define AT91_MATRIX_PRBS0 0x84 /* Priority Register B for Slave 0 */
57#define AT91_MATRIX_PRAS1 (AT91_MATRIX + 0x88) /* Priority Register A for Slave 1 */ 57#define AT91_MATRIX_PRAS1 0x88 /* Priority Register A for Slave 1 */
58#define AT91_MATRIX_PRBS1 (AT91_MATRIX + 0x8C) /* Priority Register B for Slave 1 */ 58#define AT91_MATRIX_PRBS1 0x8C /* Priority Register B for Slave 1 */
59#define AT91_MATRIX_PRAS2 (AT91_MATRIX + 0x90) /* Priority Register A for Slave 2 */ 59#define AT91_MATRIX_PRAS2 0x90 /* Priority Register A for Slave 2 */
60#define AT91_MATRIX_PRBS2 (AT91_MATRIX + 0x94) /* Priority Register B for Slave 2 */ 60#define AT91_MATRIX_PRBS2 0x94 /* Priority Register B for Slave 2 */
61#define AT91_MATRIX_PRAS3 (AT91_MATRIX + 0x98) /* Priority Register A for Slave 3 */ 61#define AT91_MATRIX_PRAS3 0x98 /* Priority Register A for Slave 3 */
62#define AT91_MATRIX_PRBS3 (AT91_MATRIX + 0x9C) /* Priority Register B for Slave 3 */ 62#define AT91_MATRIX_PRBS3 0x9C /* Priority Register B for Slave 3 */
63#define AT91_MATRIX_PRAS4 (AT91_MATRIX + 0xA0) /* Priority Register A for Slave 4 */ 63#define AT91_MATRIX_PRAS4 0xA0 /* Priority Register A for Slave 4 */
64#define AT91_MATRIX_PRBS4 (AT91_MATRIX + 0xA4) /* Priority Register B for Slave 4 */ 64#define AT91_MATRIX_PRBS4 0xA4 /* Priority Register B for Slave 4 */
65#define AT91_MATRIX_PRAS5 (AT91_MATRIX + 0xA8) /* Priority Register A for Slave 5 */ 65#define AT91_MATRIX_PRAS5 0xA8 /* Priority Register A for Slave 5 */
66#define AT91_MATRIX_PRBS5 (AT91_MATRIX + 0xAC) /* Priority Register B for Slave 5 */ 66#define AT91_MATRIX_PRBS5 0xAC /* Priority Register B for Slave 5 */
67#define AT91_MATRIX_PRAS6 (AT91_MATRIX + 0xB0) /* Priority Register A for Slave 6 */ 67#define AT91_MATRIX_PRAS6 0xB0 /* Priority Register A for Slave 6 */
68#define AT91_MATRIX_PRBS6 (AT91_MATRIX + 0xB4) /* Priority Register B for Slave 6 */ 68#define AT91_MATRIX_PRBS6 0xB4 /* Priority Register B for Slave 6 */
69#define AT91_MATRIX_PRAS7 (AT91_MATRIX + 0xB8) /* Priority Register A for Slave 7 */ 69#define AT91_MATRIX_PRAS7 0xB8 /* Priority Register A for Slave 7 */
70#define AT91_MATRIX_PRBS7 (AT91_MATRIX + 0xBC) /* Priority Register B for Slave 7 */ 70#define AT91_MATRIX_PRBS7 0xBC /* Priority Register B for Slave 7 */
71#define AT91_MATRIX_M0PR (3 << 0) /* Master 0 Priority */ 71#define AT91_MATRIX_M0PR (3 << 0) /* Master 0 Priority */
72#define AT91_MATRIX_M1PR (3 << 4) /* Master 1 Priority */ 72#define AT91_MATRIX_M1PR (3 << 4) /* Master 1 Priority */
73#define AT91_MATRIX_M2PR (3 << 8) /* Master 2 Priority */ 73#define AT91_MATRIX_M2PR (3 << 8) /* Master 2 Priority */
@@ -81,7 +81,7 @@
81#define AT91_MATRIX_M10PR (3 << 8) /* Master 10 Priority (in Register B) */ 81#define AT91_MATRIX_M10PR (3 << 8) /* Master 10 Priority (in Register B) */
82#define AT91_MATRIX_M11PR (3 << 12) /* Master 11 Priority (in Register B) */ 82#define AT91_MATRIX_M11PR (3 << 12) /* Master 11 Priority (in Register B) */
83 83
84#define AT91_MATRIX_MRCR (AT91_MATRIX + 0x100) /* Master Remap Control Register */ 84#define AT91_MATRIX_MRCR 0x100 /* Master Remap Control Register */
85#define AT91_MATRIX_RCB0 (1 << 0) /* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */ 85#define AT91_MATRIX_RCB0 (1 << 0) /* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */
86#define AT91_MATRIX_RCB1 (1 << 1) /* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */ 86#define AT91_MATRIX_RCB1 (1 << 1) /* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */
87#define AT91_MATRIX_RCB2 (1 << 2) 87#define AT91_MATRIX_RCB2 (1 << 2)
@@ -95,7 +95,7 @@
95#define AT91_MATRIX_RCB10 (1 << 10) 95#define AT91_MATRIX_RCB10 (1 << 10)
96#define AT91_MATRIX_RCB11 (1 << 11) 96#define AT91_MATRIX_RCB11 (1 << 11)
97 97
98#define AT91_MATRIX_TCMR (AT91_MATRIX + 0x110) /* TCM Configuration Register */ 98#define AT91_MATRIX_TCMR 0x110 /* TCM Configuration Register */
99#define AT91_MATRIX_ITCM_SIZE (0xf << 0) /* Size of ITCM enabled memory block */ 99#define AT91_MATRIX_ITCM_SIZE (0xf << 0) /* Size of ITCM enabled memory block */
100#define AT91_MATRIX_ITCM_0 (0 << 0) 100#define AT91_MATRIX_ITCM_0 (0 << 0)
101#define AT91_MATRIX_ITCM_32 (6 << 0) 101#define AT91_MATRIX_ITCM_32 (6 << 0)
@@ -107,12 +107,12 @@
107#define AT91_MATRIX_TCM_NO_WS (0x0 << 11) 107#define AT91_MATRIX_TCM_NO_WS (0x0 << 11)
108#define AT91_MATRIX_TCM_ONE_WS (0x1 << 11) 108#define AT91_MATRIX_TCM_ONE_WS (0x1 << 11)
109 109
110#define AT91_MATRIX_VIDEO (AT91_MATRIX + 0x118) /* Video Mode Configuration Register */ 110#define AT91_MATRIX_VIDEO 0x118 /* Video Mode Configuration Register */
111#define AT91C_VDEC_SEL (0x1 << 0) /* Video Mode Selection */ 111#define AT91C_VDEC_SEL (0x1 << 0) /* Video Mode Selection */
112#define AT91C_VDEC_SEL_OFF (0 << 0) 112#define AT91C_VDEC_SEL_OFF (0 << 0)
113#define AT91C_VDEC_SEL_ON (1 << 0) 113#define AT91C_VDEC_SEL_ON (1 << 0)
114 114
115#define AT91_MATRIX_EBICSA (AT91_MATRIX + 0x128) /* EBI Chip Select Assignment Register */ 115#define AT91_MATRIX_EBICSA 0x128 /* EBI Chip Select Assignment Register */
116#define AT91_MATRIX_EBI_CS1A (1 << 1) /* Chip Select 1 Assignment */ 116#define AT91_MATRIX_EBI_CS1A (1 << 1) /* Chip Select 1 Assignment */
117#define AT91_MATRIX_EBI_CS1A_SMC (0 << 1) 117#define AT91_MATRIX_EBI_CS1A_SMC (0 << 1)
118#define AT91_MATRIX_EBI_CS1A_SDRAMC (1 << 1) 118#define AT91_MATRIX_EBI_CS1A_SDRAMC (1 << 1)
@@ -138,13 +138,13 @@
138#define AT91_MATRIX_EBI_DDR_IOSR_REDUCED (0 << 18) 138#define AT91_MATRIX_EBI_DDR_IOSR_REDUCED (0 << 18)
139#define AT91_MATRIX_EBI_DDR_IOSR_NORMAL (1 << 18) 139#define AT91_MATRIX_EBI_DDR_IOSR_NORMAL (1 << 18)
140 140
141#define AT91_MATRIX_WPMR (AT91_MATRIX + 0x1E4) /* Write Protect Mode Register */ 141#define AT91_MATRIX_WPMR 0x1E4 /* Write Protect Mode Register */
142#define AT91_MATRIX_WPMR_WPEN (1 << 0) /* Write Protect ENable */ 142#define AT91_MATRIX_WPMR_WPEN (1 << 0) /* Write Protect ENable */
143#define AT91_MATRIX_WPMR_WP_WPDIS (0 << 0) 143#define AT91_MATRIX_WPMR_WP_WPDIS (0 << 0)
144#define AT91_MATRIX_WPMR_WP_WPEN (1 << 0) 144#define AT91_MATRIX_WPMR_WP_WPEN (1 << 0)
145#define AT91_MATRIX_WPMR_WPKEY (0xFFFFFF << 8) /* Write Protect KEY */ 145#define AT91_MATRIX_WPMR_WPKEY (0xFFFFFF << 8) /* Write Protect KEY */
146 146
147#define AT91_MATRIX_WPSR (AT91_MATRIX + 0x1E8) /* Write Protect Status Register */ 147#define AT91_MATRIX_WPSR 0x1E8 /* Write Protect Status Register */
148#define AT91_MATRIX_WPSR_WPVS (1 << 0) /* Write Protect Violation Status */ 148#define AT91_MATRIX_WPSR_WPVS (1 << 0) /* Write Protect Violation Status */
149#define AT91_MATRIX_WPSR_NO_WPV (0 << 0) 149#define AT91_MATRIX_WPSR_NO_WPV (0 << 0)
150#define AT91_MATRIX_WPSR_WPV (1 << 0) 150#define AT91_MATRIX_WPSR_WPV (1 << 0)
diff --git a/arch/arm/mach-at91/include/mach/at91sam9rl.h b/arch/arm/mach-at91/include/mach/at91sam9rl.h
index d7bead7118d..e0073eb1014 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9rl.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9rl.h
@@ -69,15 +69,13 @@
69/* 69/*
70 * System Peripherals (offset from AT91_BASE_SYS) 70 * System Peripherals (offset from AT91_BASE_SYS)
71 */ 71 */
72#define AT91_SDRAMC0 (0xffffea00 - AT91_BASE_SYS)
73#define AT91_MATRIX (0xffffee00 - AT91_BASE_SYS)
74#define AT91_PMC (0xfffffc00 - AT91_BASE_SYS)
75#define AT91_SCKCR (0xfffffd50 - AT91_BASE_SYS) 72#define AT91_SCKCR (0xfffffd50 - AT91_BASE_SYS)
76#define AT91_GPBR (0xfffffd60 - AT91_BASE_SYS)
77 73
78#define AT91SAM9RL_BASE_DMA 0xffffe600 74#define AT91SAM9RL_BASE_DMA 0xffffe600
79#define AT91SAM9RL_BASE_ECC 0xffffe800 75#define AT91SAM9RL_BASE_ECC 0xffffe800
76#define AT91SAM9RL_BASE_SDRAMC 0xffffea00
80#define AT91SAM9RL_BASE_SMC 0xffffec00 77#define AT91SAM9RL_BASE_SMC 0xffffec00
78#define AT91SAM9RL_BASE_MATRIX 0xffffee00
81#define AT91SAM9RL_BASE_DBGU AT91_BASE_DBGU0 79#define AT91SAM9RL_BASE_DBGU AT91_BASE_DBGU0
82#define AT91SAM9RL_BASE_PIOA 0xfffff400 80#define AT91SAM9RL_BASE_PIOA 0xfffff400
83#define AT91SAM9RL_BASE_PIOB 0xfffff600 81#define AT91SAM9RL_BASE_PIOB 0xfffff600
@@ -88,6 +86,7 @@
88#define AT91SAM9RL_BASE_RTT 0xfffffd20 86#define AT91SAM9RL_BASE_RTT 0xfffffd20
89#define AT91SAM9RL_BASE_PIT 0xfffffd30 87#define AT91SAM9RL_BASE_PIT 0xfffffd30
90#define AT91SAM9RL_BASE_WDT 0xfffffd40 88#define AT91SAM9RL_BASE_WDT 0xfffffd40
89#define AT91SAM9RL_BASE_GPBR 0xfffffd60
91#define AT91SAM9RL_BASE_RTC 0xfffffe00 90#define AT91SAM9RL_BASE_RTC 0xfffffe00
92 91
93#define AT91_USART0 AT91SAM9RL_BASE_US0 92#define AT91_USART0 AT91SAM9RL_BASE_US0
diff --git a/arch/arm/mach-at91/include/mach/at91sam9rl_matrix.h b/arch/arm/mach-at91/include/mach/at91sam9rl_matrix.h
index 5f9149071fe..6d160adadaf 100644
--- a/arch/arm/mach-at91/include/mach/at91sam9rl_matrix.h
+++ b/arch/arm/mach-at91/include/mach/at91sam9rl_matrix.h
@@ -14,12 +14,12 @@
14#ifndef AT91SAM9RL_MATRIX_H 14#ifndef AT91SAM9RL_MATRIX_H
15#define AT91SAM9RL_MATRIX_H 15#define AT91SAM9RL_MATRIX_H
16 16
17#define AT91_MATRIX_MCFG0 (AT91_MATRIX + 0x00) /* Master Configuration Register 0 */ 17#define AT91_MATRIX_MCFG0 0x00 /* Master Configuration Register 0 */
18#define AT91_MATRIX_MCFG1 (AT91_MATRIX + 0x04) /* Master Configuration Register 1 */ 18#define AT91_MATRIX_MCFG1 0x04 /* Master Configuration Register 1 */
19#define AT91_MATRIX_MCFG2 (AT91_MATRIX + 0x08) /* Master Configuration Register 2 */ 19#define AT91_MATRIX_MCFG2 0x08 /* Master Configuration Register 2 */
20#define AT91_MATRIX_MCFG3 (AT91_MATRIX + 0x0C) /* Master Configuration Register 3 */ 20#define AT91_MATRIX_MCFG3 0x0C /* Master Configuration Register 3 */
21#define AT91_MATRIX_MCFG4 (AT91_MATRIX + 0x10) /* Master Configuration Register 4 */ 21#define AT91_MATRIX_MCFG4 0x10 /* Master Configuration Register 4 */
22#define AT91_MATRIX_MCFG5 (AT91_MATRIX + 0x14) /* Master Configuration Register 5 */ 22#define AT91_MATRIX_MCFG5 0x14 /* Master Configuration Register 5 */
23#define AT91_MATRIX_ULBT (7 << 0) /* Undefined Length Burst Type */ 23#define AT91_MATRIX_ULBT (7 << 0) /* Undefined Length Burst Type */
24#define AT91_MATRIX_ULBT_INFINITE (0 << 0) 24#define AT91_MATRIX_ULBT_INFINITE (0 << 0)
25#define AT91_MATRIX_ULBT_SINGLE (1 << 0) 25#define AT91_MATRIX_ULBT_SINGLE (1 << 0)
@@ -27,12 +27,12 @@
27#define AT91_MATRIX_ULBT_EIGHT (3 << 0) 27#define AT91_MATRIX_ULBT_EIGHT (3 << 0)
28#define AT91_MATRIX_ULBT_SIXTEEN (4 << 0) 28#define AT91_MATRIX_ULBT_SIXTEEN (4 << 0)
29 29
30#define AT91_MATRIX_SCFG0 (AT91_MATRIX + 0x40) /* Slave Configuration Register 0 */ 30#define AT91_MATRIX_SCFG0 0x40 /* Slave Configuration Register 0 */
31#define AT91_MATRIX_SCFG1 (AT91_MATRIX + 0x44) /* Slave Configuration Register 1 */ 31#define AT91_MATRIX_SCFG1 0x44 /* Slave Configuration Register 1 */
32#define AT91_MATRIX_SCFG2 (AT91_MATRIX + 0x48) /* Slave Configuration Register 2 */ 32#define AT91_MATRIX_SCFG2 0x48 /* Slave Configuration Register 2 */
33#define AT91_MATRIX_SCFG3 (AT91_MATRIX + 0x4C) /* Slave Configuration Register 3 */ 33#define AT91_MATRIX_SCFG3 0x4C /* Slave Configuration Register 3 */
34#define AT91_MATRIX_SCFG4 (AT91_MATRIX + 0x50) /* Slave Configuration Register 4 */ 34#define AT91_MATRIX_SCFG4 0x50 /* Slave Configuration Register 4 */
35#define AT91_MATRIX_SCFG5 (AT91_MATRIX + 0x54) /* Slave Configuration Register 5 */ 35#define AT91_MATRIX_SCFG5 0x54 /* Slave Configuration Register 5 */
36#define AT91_MATRIX_SLOT_CYCLE (0xff << 0) /* Maximum Number of Allowed Cycles for a Burst */ 36#define AT91_MATRIX_SLOT_CYCLE (0xff << 0) /* Maximum Number of Allowed Cycles for a Burst */
37#define AT91_MATRIX_DEFMSTR_TYPE (3 << 16) /* Default Master Type */ 37#define AT91_MATRIX_DEFMSTR_TYPE (3 << 16) /* Default Master Type */
38#define AT91_MATRIX_DEFMSTR_TYPE_NONE (0 << 16) 38#define AT91_MATRIX_DEFMSTR_TYPE_NONE (0 << 16)
@@ -43,12 +43,12 @@
43#define AT91_MATRIX_ARBT_ROUND_ROBIN (0 << 24) 43#define AT91_MATRIX_ARBT_ROUND_ROBIN (0 << 24)
44#define AT91_MATRIX_ARBT_FIXED_PRIORITY (1 << 24) 44#define AT91_MATRIX_ARBT_FIXED_PRIORITY (1 << 24)
45 45
46#define AT91_MATRIX_PRAS0 (AT91_MATRIX + 0x80) /* Priority Register A for Slave 0 */ 46#define AT91_MATRIX_PRAS0 0x80 /* Priority Register A for Slave 0 */
47#define AT91_MATRIX_PRAS1 (AT91_MATRIX + 0x88) /* Priority Register A for Slave 1 */ 47#define AT91_MATRIX_PRAS1 0x88 /* Priority Register A for Slave 1 */
48#define AT91_MATRIX_PRAS2 (AT91_MATRIX + 0x90) /* Priority Register A for Slave 2 */ 48#define AT91_MATRIX_PRAS2 0x90 /* Priority Register A for Slave 2 */
49#define AT91_MATRIX_PRAS3 (AT91_MATRIX + 0x98) /* Priority Register A for Slave 3 */ 49#define AT91_MATRIX_PRAS3 0x98 /* Priority Register A for Slave 3 */
50#define AT91_MATRIX_PRAS4 (AT91_MATRIX + 0xA0) /* Priority Register A for Slave 4 */ 50#define AT91_MATRIX_PRAS4 0xA0 /* Priority Register A for Slave 4 */
51#define AT91_MATRIX_PRAS5 (AT91_MATRIX + 0xA8) /* Priority Register A for Slave 5 */ 51#define AT91_MATRIX_PRAS5 0xA8 /* Priority Register A for Slave 5 */
52#define AT91_MATRIX_M0PR (3 << 0) /* Master 0 Priority */ 52#define AT91_MATRIX_M0PR (3 << 0) /* Master 0 Priority */
53#define AT91_MATRIX_M1PR (3 << 4) /* Master 1 Priority */ 53#define AT91_MATRIX_M1PR (3 << 4) /* Master 1 Priority */
54#define AT91_MATRIX_M2PR (3 << 8) /* Master 2 Priority */ 54#define AT91_MATRIX_M2PR (3 << 8) /* Master 2 Priority */
@@ -56,7 +56,7 @@
56#define AT91_MATRIX_M4PR (3 << 16) /* Master 4 Priority */ 56#define AT91_MATRIX_M4PR (3 << 16) /* Master 4 Priority */
57#define AT91_MATRIX_M5PR (3 << 20) /* Master 5 Priority */ 57#define AT91_MATRIX_M5PR (3 << 20) /* Master 5 Priority */
58 58
59#define AT91_MATRIX_MRCR (AT91_MATRIX + 0x100) /* Master Remap Control Register */ 59#define AT91_MATRIX_MRCR 0x100 /* Master Remap Control Register */
60#define AT91_MATRIX_RCB0 (1 << 0) /* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */ 60#define AT91_MATRIX_RCB0 (1 << 0) /* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */
61#define AT91_MATRIX_RCB1 (1 << 1) /* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */ 61#define AT91_MATRIX_RCB1 (1 << 1) /* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */
62#define AT91_MATRIX_RCB2 (1 << 2) 62#define AT91_MATRIX_RCB2 (1 << 2)
@@ -64,7 +64,7 @@
64#define AT91_MATRIX_RCB4 (1 << 4) 64#define AT91_MATRIX_RCB4 (1 << 4)
65#define AT91_MATRIX_RCB5 (1 << 5) 65#define AT91_MATRIX_RCB5 (1 << 5)
66 66
67#define AT91_MATRIX_TCMR (AT91_MATRIX + 0x114) /* TCM Configuration Register */ 67#define AT91_MATRIX_TCMR 0x114 /* TCM Configuration Register */
68#define AT91_MATRIX_ITCM_SIZE (0xf << 0) /* Size of ITCM enabled memory block */ 68#define AT91_MATRIX_ITCM_SIZE (0xf << 0) /* Size of ITCM enabled memory block */
69#define AT91_MATRIX_ITCM_0 (0 << 0) 69#define AT91_MATRIX_ITCM_0 (0 << 0)
70#define AT91_MATRIX_ITCM_16 (5 << 0) 70#define AT91_MATRIX_ITCM_16 (5 << 0)
@@ -74,7 +74,7 @@
74#define AT91_MATRIX_DTCM_16 (5 << 4) 74#define AT91_MATRIX_DTCM_16 (5 << 4)
75#define AT91_MATRIX_DTCM_32 (6 << 4) 75#define AT91_MATRIX_DTCM_32 (6 << 4)
76 76
77#define AT91_MATRIX_EBICSA (AT91_MATRIX + 0x120) /* EBI0 Chip Select Assignment Register */ 77#define AT91_MATRIX_EBICSA 0x120 /* EBI0 Chip Select Assignment Register */
78#define AT91_MATRIX_CS1A (1 << 1) /* Chip Select 1 Assignment */ 78#define AT91_MATRIX_CS1A (1 << 1) /* Chip Select 1 Assignment */
79#define AT91_MATRIX_CS1A_SMC (0 << 1) 79#define AT91_MATRIX_CS1A_SMC (0 << 1)
80#define AT91_MATRIX_CS1A_SDRAMC (1 << 1) 80#define AT91_MATRIX_CS1A_SDRAMC (1 << 1)
diff --git a/arch/arm/mach-at91/include/mach/at91sam9x5.h b/arch/arm/mach-at91/include/mach/at91sam9x5.h
new file mode 100644
index 00000000000..88e43d534cd
--- /dev/null
+++ b/arch/arm/mach-at91/include/mach/at91sam9x5.h
@@ -0,0 +1,74 @@
1/*
2 * Chip-specific header file for the AT91SAM9x5 family
3 *
4 * Copyright (C) 2009-2012 Atmel Corporation.
5 *
6 * Common definitions.
7 * Based on AT91SAM9x5 datasheet.
8 *
9 * Licensed under GPLv2 or later.
10 */
11
12#ifndef AT91SAM9X5_H
13#define AT91SAM9X5_H
14
15/*
16 * Peripheral identifiers/interrupts.
17 */
18#define AT91SAM9X5_ID_PIOAB 2 /* Parallel I/O Controller A and B */
19#define AT91SAM9X5_ID_PIOCD 3 /* Parallel I/O Controller C and D */
20#define AT91SAM9X5_ID_SMD 4 /* SMD Soft Modem (SMD) */
21#define AT91SAM9X5_ID_USART0 5 /* USART 0 */
22#define AT91SAM9X5_ID_USART1 6 /* USART 1 */
23#define AT91SAM9X5_ID_USART2 7 /* USART 2 */
24#define AT91SAM9X5_ID_USART3 8 /* USART 3 */
25#define AT91SAM9X5_ID_TWI0 9 /* Two-Wire Interface 0 */
26#define AT91SAM9X5_ID_TWI1 10 /* Two-Wire Interface 1 */
27#define AT91SAM9X5_ID_TWI2 11 /* Two-Wire Interface 2 */
28#define AT91SAM9X5_ID_MCI0 12 /* High Speed Multimedia Card Interface 0 */
29#define AT91SAM9X5_ID_SPI0 13 /* Serial Peripheral Interface 0 */
30#define AT91SAM9X5_ID_SPI1 14 /* Serial Peripheral Interface 1 */
31#define AT91SAM9X5_ID_UART0 15 /* UART 0 */
32#define AT91SAM9X5_ID_UART1 16 /* UART 1 */
33#define AT91SAM9X5_ID_TCB 17 /* Timer Counter 0, 1, 2, 3, 4 and 5 */
34#define AT91SAM9X5_ID_PWM 18 /* Pulse Width Modulation Controller */
35#define AT91SAM9X5_ID_ADC 19 /* ADC Controller */
36#define AT91SAM9X5_ID_DMA0 20 /* DMA Controller 0 */
37#define AT91SAM9X5_ID_DMA1 21 /* DMA Controller 1 */
38#define AT91SAM9X5_ID_UHPHS 22 /* USB Host High Speed */
39#define AT91SAM9X5_ID_UDPHS 23 /* USB Device High Speed */
40#define AT91SAM9X5_ID_EMAC0 24 /* Ethernet MAC0 */
41#define AT91SAM9X5_ID_LCDC 25 /* LCD Controller */
42#define AT91SAM9X5_ID_ISI 25 /* Image Sensor Interface */
43#define AT91SAM9X5_ID_MCI1 26 /* High Speed Multimedia Card Interface 1 */
44#define AT91SAM9X5_ID_EMAC1 27 /* Ethernet MAC1 */
45#define AT91SAM9X5_ID_SSC 28 /* Synchronous Serial Controller */
46#define AT91SAM9X5_ID_CAN0 29 /* CAN Controller 0 */
47#define AT91SAM9X5_ID_CAN1 30 /* CAN Controller 1 */
48#define AT91SAM9X5_ID_IRQ0 31 /* Advanced Interrupt Controller */
49
50/*
51 * User Peripheral physical base addresses.
52 */
53#define AT91SAM9X5_BASE_USART0 0xf801c000
54#define AT91SAM9X5_BASE_USART1 0xf8020000
55#define AT91SAM9X5_BASE_USART2 0xf8024000
56
57/*
58 * Base addresses for early serial code (uncompress.h)
59 */
60#define AT91_DBGU AT91_BASE_DBGU0
61#define AT91_USART0 AT91SAM9X5_BASE_USART0
62#define AT91_USART1 AT91SAM9X5_BASE_USART1
63#define AT91_USART2 AT91SAM9X5_BASE_USART2
64
65/*
66 * Internal Memory.
67 */
68#define AT91SAM9X5_SRAM_BASE 0x00300000 /* Internal SRAM base address */
69#define AT91SAM9X5_SRAM_SIZE SZ_32K /* Internal SRAM size (32Kb) */
70
71#define AT91SAM9X5_ROM_BASE 0x00400000 /* Internal ROM base address */
72#define AT91SAM9X5_ROM_SIZE SZ_64K /* Internal ROM size (64Kb) */
73
74#endif
diff --git a/arch/arm/mach-at91/include/mach/at91sam9x5_matrix.h b/arch/arm/mach-at91/include/mach/at91sam9x5_matrix.h
new file mode 100644
index 00000000000..a606d396647
--- /dev/null
+++ b/arch/arm/mach-at91/include/mach/at91sam9x5_matrix.h
@@ -0,0 +1,53 @@
1/*
2 * Matrix-centric header file for the AT91SAM9x5 family
3 *
4 * Copyright (C) 2009-2012 Atmel Corporation.
5 *
6 * Only EBI related registers.
7 * Write Protect register definitions may be useful.
8 *
9 * Licensed under GPLv2 or later.
10 */
11
12#ifndef AT91SAM9X5_MATRIX_H
13#define AT91SAM9X5_MATRIX_H
14
15#define AT91_MATRIX_EBICSA (AT91_MATRIX + 0x120) /* EBI Chip Select Assignment Register */
16#define AT91_MATRIX_EBI_CS1A (1 << 1) /* Chip Select 1 Assignment */
17#define AT91_MATRIX_EBI_CS1A_SMC (0 << 1)
18#define AT91_MATRIX_EBI_CS1A_SDRAMC (1 << 1)
19#define AT91_MATRIX_EBI_CS3A (1 << 3) /* Chip Select 3 Assignment */
20#define AT91_MATRIX_EBI_CS3A_SMC (0 << 3)
21#define AT91_MATRIX_EBI_CS3A_SMC_NANDFLASH (1 << 3)
22#define AT91_MATRIX_EBI_DBPUC (1 << 8) /* Data Bus Pull-up Configuration */
23#define AT91_MATRIX_EBI_DBPU_ON (0 << 8)
24#define AT91_MATRIX_EBI_DBPU_OFF (1 << 8)
25#define AT91_MATRIX_EBI_VDDIOMSEL (1 << 16) /* Memory voltage selection */
26#define AT91_MATRIX_EBI_VDDIOMSEL_1_8V (0 << 16)
27#define AT91_MATRIX_EBI_VDDIOMSEL_3_3V (1 << 16)
28#define AT91_MATRIX_EBI_EBI_IOSR (1 << 17) /* EBI I/O slew rate selection */
29#define AT91_MATRIX_EBI_EBI_IOSR_REDUCED (0 << 17)
30#define AT91_MATRIX_EBI_EBI_IOSR_NORMAL (1 << 17)
31#define AT91_MATRIX_EBI_DDR_IOSR (1 << 18) /* DDR2 dedicated port I/O slew rate selection */
32#define AT91_MATRIX_EBI_DDR_IOSR_REDUCED (0 << 18)
33#define AT91_MATRIX_EBI_DDR_IOSR_NORMAL (1 << 18)
34#define AT91_MATRIX_NFD0_SELECT (1 << 24) /* NAND Flash Data Bus Selection */
35#define AT91_MATRIX_NFD0_ON_D0 (0 << 24)
36#define AT91_MATRIX_NFD0_ON_D16 (1 << 24)
37#define AT91_MATRIX_DDR_MP_EN (1 << 25) /* DDR Multi-port Enable */
38#define AT91_MATRIX_MP_OFF (0 << 25)
39#define AT91_MATRIX_MP_ON (1 << 25)
40
41#define AT91_MATRIX_WPMR (AT91_MATRIX + 0x1E4) /* Write Protect Mode Register */
42#define AT91_MATRIX_WPMR_WPEN (1 << 0) /* Write Protect ENable */
43#define AT91_MATRIX_WPMR_WP_WPDIS (0 << 0)
44#define AT91_MATRIX_WPMR_WP_WPEN (1 << 0)
45#define AT91_MATRIX_WPMR_WPKEY (0xFFFFFF << 8) /* Write Protect KEY */
46
47#define AT91_MATRIX_WPSR (AT91_MATRIX + 0x1E8) /* Write Protect Status Register */
48#define AT91_MATRIX_WPSR_WPVS (1 << 0) /* Write Protect Violation Status */
49#define AT91_MATRIX_WPSR_NO_WPV (0 << 0)
50#define AT91_MATRIX_WPSR_WPV (1 << 0)
51#define AT91_MATRIX_WPSR_WPVSRC (0xFFFF << 8) /* Write Protect Violation Source */
52
53#endif
diff --git a/arch/arm/mach-at91/include/mach/at91x40.h b/arch/arm/mach-at91/include/mach/at91x40.h
index a57829f4fd1..90680217064 100644
--- a/arch/arm/mach-at91/include/mach/at91x40.h
+++ b/arch/arm/mach-at91/include/mach/at91x40.h
@@ -28,18 +28,18 @@
28#define AT91X40_ID_IRQ2 18 /* External IRQ 2 */ 28#define AT91X40_ID_IRQ2 18 /* External IRQ 2 */
29 29
30/* 30/*
31 * System Peripherals (offset from AT91_BASE_SYS) 31 * System Peripherals
32 */ 32 */
33#define AT91_BASE_SYS 0xffc00000 33#define AT91_BASE_SYS 0xffc00000
34 34
35#define AT91_EBI (0xffe00000 - AT91_BASE_SYS) /* External Bus Interface */ 35#define AT91_EBI 0xffe00000 /* External Bus Interface */
36#define AT91_SF (0xfff00000 - AT91_BASE_SYS) /* Special Function */ 36#define AT91_SF 0xfff00000 /* Special Function */
37#define AT91_USART1 (0xfffcc000 - AT91_BASE_SYS) /* USART 1 */ 37#define AT91_USART1 0xfffcc000 /* USART 1 */
38#define AT91_USART0 (0xfffd0000 - AT91_BASE_SYS) /* USART 0 */ 38#define AT91_USART0 0xfffd0000 /* USART 0 */
39#define AT91_TC (0xfffe0000 - AT91_BASE_SYS) /* Timer Counter */ 39#define AT91_TC 0xfffe0000 /* Timer Counter */
40#define AT91_PIOA (0xffff0000 - AT91_BASE_SYS) /* PIO Controller A */ 40#define AT91_PIOA 0xffff0000 /* PIO Controller A */
41#define AT91_PS (0xffff4000 - AT91_BASE_SYS) /* Power Save */ 41#define AT91_PS 0xffff4000 /* Power Save */
42#define AT91_WD (0xffff8000 - AT91_BASE_SYS) /* Watchdog Timer */ 42#define AT91_WD 0xffff8000 /* Watchdog Timer */
43 43
44/* 44/*
45 * The AT91x40 series doesn't have a debug unit like the other AT91 parts. 45 * The AT91x40 series doesn't have a debug unit like the other AT91 parts.
diff --git a/arch/arm/mach-at91/include/mach/board.h b/arch/arm/mach-at91/include/mach/board.h
index 3b33f07b1e1..544a5d5ce41 100644
--- a/arch/arm/mach-at91/include/mach/board.h
+++ b/arch/arm/mach-at91/include/mach/board.h
@@ -41,6 +41,7 @@
41#include <sound/atmel-ac97c.h> 41#include <sound/atmel-ac97c.h>
42#include <linux/serial.h> 42#include <linux/serial.h>
43#include <linux/platform_data/macb.h> 43#include <linux/platform_data/macb.h>
44#include <linux/platform_data/atmel.h>
44 45
45 /* USB Device */ 46 /* USB Device */
46struct at91_udc_data { 47struct at91_udc_data {
@@ -98,18 +99,6 @@ extern void __init at91_add_device_usbh(struct at91_usbh_data *data);
98extern void __init at91_add_device_usbh_ohci(struct at91_usbh_data *data); 99extern void __init at91_add_device_usbh_ohci(struct at91_usbh_data *data);
99extern void __init at91_add_device_usbh_ehci(struct at91_usbh_data *data); 100extern void __init at91_add_device_usbh_ehci(struct at91_usbh_data *data);
100 101
101 /* NAND / SmartMedia */
102struct atmel_nand_data {
103 int enable_pin; /* chip enable */
104 int det_pin; /* card detect */
105 int rdy_pin; /* ready/busy */
106 u8 rdy_pin_active_low; /* rdy_pin value is inverted */
107 u8 ale; /* address line number connected to ALE */
108 u8 cle; /* address line number connected to CLE */
109 u8 bus_width_16; /* buswidth is 16 bit */
110 struct mtd_partition *parts;
111 unsigned int num_parts;
112};
113extern void __init at91_add_device_nand(struct atmel_nand_data *data); 102extern void __init at91_add_device_nand(struct atmel_nand_data *data);
114 103
115 /* I2C*/ 104 /* I2C*/
@@ -179,7 +168,9 @@ extern void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data);
179extern void __init at91_add_device_ac97(struct ac97c_platform_data *data); 168extern void __init at91_add_device_ac97(struct ac97c_platform_data *data);
180 169
181 /* ISI */ 170 /* ISI */
182extern void __init at91_add_device_isi(void); 171struct isi_platform_data;
172extern void __init at91_add_device_isi(struct isi_platform_data *data,
173 bool use_pck_as_mck);
183 174
184 /* Touchscreen Controller */ 175 /* Touchscreen Controller */
185struct at91_tsadcc_data { 176struct at91_tsadcc_data {
diff --git a/arch/arm/mach-at91/include/mach/cpu.h b/arch/arm/mach-at91/include/mach/cpu.h
index f6ce936dba2..0118c333855 100644
--- a/arch/arm/mach-at91/include/mach/cpu.h
+++ b/arch/arm/mach-at91/include/mach/cpu.h
@@ -25,7 +25,6 @@
25#define ARCH_ID_AT91SAM9G45MRL 0x819b05a2 /* aka 9G45-ES2 & non ES lots */ 25#define ARCH_ID_AT91SAM9G45MRL 0x819b05a2 /* aka 9G45-ES2 & non ES lots */
26#define ARCH_ID_AT91SAM9G45ES 0x819b05a1 /* 9G45-ES (Engineering Sample) */ 26#define ARCH_ID_AT91SAM9G45ES 0x819b05a1 /* 9G45-ES (Engineering Sample) */
27#define ARCH_ID_AT91SAM9X5 0x819a05a0 27#define ARCH_ID_AT91SAM9X5 0x819a05a0
28#define ARCH_ID_AT91CAP9 0x039A03A0
29 28
30#define ARCH_ID_AT91SAM9XE128 0x329973a0 29#define ARCH_ID_AT91SAM9XE128 0x329973a0
31#define ARCH_ID_AT91SAM9XE256 0x329a93a0 30#define ARCH_ID_AT91SAM9XE256 0x329a93a0
@@ -51,10 +50,6 @@
51#define ARCH_FAMILY_AT91SAM9 0x01900000 50#define ARCH_FAMILY_AT91SAM9 0x01900000
52#define ARCH_FAMILY_AT91SAM9XE 0x02900000 51#define ARCH_FAMILY_AT91SAM9XE 0x02900000
53 52
54/* PMC revision */
55#define ARCH_REVISION_CAP9_B 0x399
56#define ARCH_REVISION_CAP9_C 0x601
57
58/* RM9200 type */ 53/* RM9200 type */
59#define ARCH_REVISON_9200_BGA (0 << 0) 54#define ARCH_REVISON_9200_BGA (0 << 0)
60#define ARCH_REVISON_9200_PQFP (1 << 0) 55#define ARCH_REVISON_9200_PQFP (1 << 0)
@@ -63,9 +58,6 @@ enum at91_soc_type {
63 /* 920T */ 58 /* 920T */
64 AT91_SOC_RM9200, 59 AT91_SOC_RM9200,
65 60
66 /* CAP */
67 AT91_SOC_CAP9,
68
69 /* SAM92xx */ 61 /* SAM92xx */
70 AT91_SOC_SAM9260, AT91_SOC_SAM9261, AT91_SOC_SAM9263, 62 AT91_SOC_SAM9260, AT91_SOC_SAM9261, AT91_SOC_SAM9263,
71 63
@@ -86,9 +78,6 @@ enum at91_soc_subtype {
86 /* RM9200 */ 78 /* RM9200 */
87 AT91_SOC_RM9200_BGA, AT91_SOC_RM9200_PQFP, 79 AT91_SOC_RM9200_BGA, AT91_SOC_RM9200_PQFP,
88 80
89 /* CAP9 */
90 AT91_SOC_CAP9_REV_B, AT91_SOC_CAP9_REV_C,
91
92 /* SAM9260 */ 81 /* SAM9260 */
93 AT91_SOC_SAM9XE, 82 AT91_SOC_SAM9XE,
94 83
@@ -195,16 +184,6 @@ static inline int at91_soc_is_detected(void)
195#define cpu_is_at91sam9x25() (0) 184#define cpu_is_at91sam9x25() (0)
196#endif 185#endif
197 186
198#ifdef CONFIG_ARCH_AT91CAP9
199#define cpu_is_at91cap9() (at91_soc_initdata.type == AT91_SOC_CAP9)
200#define cpu_is_at91cap9_revB() (at91_soc_initdata.subtype == AT91_SOC_CAP9_REV_B)
201#define cpu_is_at91cap9_revC() (at91_soc_initdata.subtype == AT91_SOC_CAP9_REV_C)
202#else
203#define cpu_is_at91cap9() (0)
204#define cpu_is_at91cap9_revB() (0)
205#define cpu_is_at91cap9_revC() (0)
206#endif
207
208/* 187/*
209 * Since this is ARM, we will never run on any AVR32 CPU. But these 188 * Since this is ARM, we will never run on any AVR32 CPU. But these
210 * definitions may reduce clutter in common drivers. 189 * definitions may reduce clutter in common drivers.
diff --git a/arch/arm/mach-at91/include/mach/entry-macro.S b/arch/arm/mach-at91/include/mach/entry-macro.S
index 423eea0ed74..903bf205a33 100644
--- a/arch/arm/mach-at91/include/mach/entry-macro.S
+++ b/arch/arm/mach-at91/include/mach/entry-macro.S
@@ -13,17 +13,11 @@
13#include <mach/hardware.h> 13#include <mach/hardware.h>
14#include <mach/at91_aic.h> 14#include <mach/at91_aic.h>
15 15
16 .macro disable_fiq
17 .endm
18
19 .macro get_irqnr_preamble, base, tmp 16 .macro get_irqnr_preamble, base, tmp
20 ldr \base, =at91_aic_base @ base virtual address of AIC peripheral 17 ldr \base, =at91_aic_base @ base virtual address of AIC peripheral
21 ldr \base, [\base] 18 ldr \base, [\base]
22 .endm 19 .endm
23 20
24 .macro arch_ret_to_user, tmp1, tmp2
25 .endm
26
27 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp 21 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
28 ldr \irqnr, [\base, #AT91_AIC_IVR] @ read IRQ vector register: de-asserts nIRQ to processor (and clears interrupt) 22 ldr \irqnr, [\base, #AT91_AIC_IVR] @ read IRQ vector register: de-asserts nIRQ to processor (and clears interrupt)
29 ldr \irqstat, [\base, #AT91_AIC_ISR] @ read interrupt source number 23 ldr \irqstat, [\base, #AT91_AIC_ISR] @ read interrupt source number
diff --git a/arch/arm/mach-at91/include/mach/gpio.h b/arch/arm/mach-at91/include/mach/gpio.h
index e3fd225121c..eed465ab0dd 100644
--- a/arch/arm/mach-at91/include/mach/gpio.h
+++ b/arch/arm/mach-at91/include/mach/gpio.h
@@ -191,10 +191,15 @@
191extern int __init_or_module at91_set_GPIO_periph(unsigned pin, int use_pullup); 191extern int __init_or_module at91_set_GPIO_periph(unsigned pin, int use_pullup);
192extern int __init_or_module at91_set_A_periph(unsigned pin, int use_pullup); 192extern int __init_or_module at91_set_A_periph(unsigned pin, int use_pullup);
193extern int __init_or_module at91_set_B_periph(unsigned pin, int use_pullup); 193extern int __init_or_module at91_set_B_periph(unsigned pin, int use_pullup);
194extern int __init_or_module at91_set_C_periph(unsigned pin, int use_pullup);
195extern int __init_or_module at91_set_D_periph(unsigned pin, int use_pullup);
194extern int __init_or_module at91_set_gpio_input(unsigned pin, int use_pullup); 196extern int __init_or_module at91_set_gpio_input(unsigned pin, int use_pullup);
195extern int __init_or_module at91_set_gpio_output(unsigned pin, int value); 197extern int __init_or_module at91_set_gpio_output(unsigned pin, int value);
196extern int __init_or_module at91_set_deglitch(unsigned pin, int is_on); 198extern int __init_or_module at91_set_deglitch(unsigned pin, int is_on);
199extern int __init_or_module at91_set_debounce(unsigned pin, int is_on, int div);
197extern int __init_or_module at91_set_multi_drive(unsigned pin, int is_on); 200extern int __init_or_module at91_set_multi_drive(unsigned pin, int is_on);
201extern int __init_or_module at91_set_pulldown(unsigned pin, int is_on);
202extern int __init_or_module at91_disable_schmitt_trig(unsigned pin);
198 203
199/* callable at any time */ 204/* callable at any time */
200extern int at91_set_gpio_value(unsigned pin, int value); 205extern int at91_set_gpio_value(unsigned pin, int value);
@@ -204,18 +209,6 @@ extern int at91_get_gpio_value(unsigned pin);
204extern void at91_gpio_suspend(void); 209extern void at91_gpio_suspend(void);
205extern void at91_gpio_resume(void); 210extern void at91_gpio_resume(void);
206 211
207/*-------------------------------------------------------------------------*/
208
209/* wrappers for "new style" GPIO calls. the old AT91-specific ones should
210 * eventually be removed (along with this errno.h inclusion), and the
211 * gpio request/free calls should probably be implemented.
212 */
213
214#include <asm/errno.h>
215
216#define gpio_to_irq(gpio) (gpio + NR_AIC_IRQS)
217#define irq_to_gpio(irq) (irq - NR_AIC_IRQS)
218
219#endif /* __ASSEMBLY__ */ 212#endif /* __ASSEMBLY__ */
220 213
221#endif 214#endif
diff --git a/arch/arm/mach-at91/include/mach/hardware.h b/arch/arm/mach-at91/include/mach/hardware.h
index 2d0e4e99856..e9e29a6c386 100644
--- a/arch/arm/mach-at91/include/mach/hardware.h
+++ b/arch/arm/mach-at91/include/mach/hardware.h
@@ -19,7 +19,7 @@
19/* DBGU base */ 19/* DBGU base */
20/* rm9200, 9260/9g20, 9261/9g10, 9rl */ 20/* rm9200, 9260/9g20, 9261/9g10, 9rl */
21#define AT91_BASE_DBGU0 0xfffff200 21#define AT91_BASE_DBGU0 0xfffff200
22/* 9263, 9g45, cap9 */ 22/* 9263, 9g45 */
23#define AT91_BASE_DBGU1 0xffffee00 23#define AT91_BASE_DBGU1 0xffffee00
24 24
25#if defined(CONFIG_ARCH_AT91RM9200) 25#if defined(CONFIG_ARCH_AT91RM9200)
@@ -34,8 +34,8 @@
34#include <mach/at91sam9rl.h> 34#include <mach/at91sam9rl.h>
35#elif defined(CONFIG_ARCH_AT91SAM9G45) 35#elif defined(CONFIG_ARCH_AT91SAM9G45)
36#include <mach/at91sam9g45.h> 36#include <mach/at91sam9g45.h>
37#elif defined(CONFIG_ARCH_AT91CAP9) 37#elif defined(CONFIG_ARCH_AT91SAM9X5)
38#include <mach/at91cap9.h> 38#include <mach/at91sam9x5.h>
39#elif defined(CONFIG_ARCH_AT91X40) 39#elif defined(CONFIG_ARCH_AT91X40)
40#include <mach/at91x40.h> 40#include <mach/at91x40.h>
41#else 41#else
@@ -59,9 +59,10 @@
59 59
60/* 60/*
61 * On all at91 have the Advanced Interrupt Controller starts at address 61 * On all at91 have the Advanced Interrupt Controller starts at address
62 * 0xfffff000 62 * 0xfffff000 and the Power Management Controller starts at 0xfffffc00
63 */ 63 */
64#define AT91_AIC 0xfffff000 64#define AT91_AIC 0xfffff000
65#define AT91_PMC 0xfffffc00
65 66
66/* 67/*
67 * Peripheral identifiers/interrupts. 68 * Peripheral identifiers/interrupts.
diff --git a/arch/arm/mach-at91/include/mach/io.h b/arch/arm/mach-at91/include/mach/io.h
index 4ca09ef7ca2..4003001eca3 100644
--- a/arch/arm/mach-at91/include/mach/io.h
+++ b/arch/arm/mach-at91/include/mach/io.h
@@ -28,22 +28,4 @@
28#define __io(a) __typesafe_io(a) 28#define __io(a) __typesafe_io(a)
29#define __mem_pci(a) (a) 29#define __mem_pci(a) (a)
30 30
31#ifndef __ASSEMBLY__
32
33static inline unsigned int at91_sys_read(unsigned int reg_offset)
34{
35 void __iomem *addr = (void __iomem *)AT91_VA_BASE_SYS;
36
37 return __raw_readl(addr + reg_offset);
38}
39
40static inline void at91_sys_write(unsigned int reg_offset, unsigned long value)
41{
42 void __iomem *addr = (void __iomem *)AT91_VA_BASE_SYS;
43
44 __raw_writel(value, addr + reg_offset);
45}
46
47#endif
48
49#endif 31#endif
diff --git a/arch/arm/mach-at91/include/mach/system.h b/arch/arm/mach-at91/include/mach/system.h
deleted file mode 100644
index cbd64f3bcec..00000000000
--- a/arch/arm/mach-at91/include/mach/system.h
+++ /dev/null
@@ -1,50 +0,0 @@
1/*
2 * arch/arm/mach-at91/include/mach/system.h
3 *
4 * Copyright (C) 2003 SAN People
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#ifndef __ASM_ARCH_SYSTEM_H
22#define __ASM_ARCH_SYSTEM_H
23
24#include <mach/hardware.h>
25#include <mach/at91_st.h>
26#include <mach/at91_dbgu.h>
27#include <mach/at91_pmc.h>
28
29static inline void arch_idle(void)
30{
31 /*
32 * Disable the processor clock. The processor will be automatically
33 * re-enabled by an interrupt or by a reset.
34 */
35#ifdef AT91_PS
36 at91_sys_write(AT91_PS_CR, AT91_PS_CR_CPU);
37#else
38 at91_sys_write(AT91_PMC_SCDR, AT91_PMC_PCK);
39#endif
40#ifndef CONFIG_CPU_ARM920T
41 /*
42 * Set the processor (CP15) into 'Wait for Interrupt' mode.
43 * Post-RM9200 processors need this in conjunction with the above
44 * to save power when idle.
45 */
46 cpu_do_idle();
47#endif
48}
49
50#endif
diff --git a/arch/arm/mach-at91/irq.c b/arch/arm/mach-at91/irq.c
index be6b639ecd7..cfcfcbe3626 100644
--- a/arch/arm/mach-at91/irq.c
+++ b/arch/arm/mach-at91/irq.c
@@ -24,6 +24,12 @@
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/mm.h> 25#include <linux/mm.h>
26#include <linux/types.h> 26#include <linux/types.h>
27#include <linux/irq.h>
28#include <linux/of.h>
29#include <linux/of_address.h>
30#include <linux/of_irq.h>
31#include <linux/irqdomain.h>
32#include <linux/err.h>
27 33
28#include <mach/hardware.h> 34#include <mach/hardware.h>
29#include <asm/irq.h> 35#include <asm/irq.h>
@@ -34,22 +40,24 @@
34#include <asm/mach/map.h> 40#include <asm/mach/map.h>
35 41
36void __iomem *at91_aic_base; 42void __iomem *at91_aic_base;
43static struct irq_domain *at91_aic_domain;
44static struct device_node *at91_aic_np;
37 45
38static void at91_aic_mask_irq(struct irq_data *d) 46static void at91_aic_mask_irq(struct irq_data *d)
39{ 47{
40 /* Disable interrupt on AIC */ 48 /* Disable interrupt on AIC */
41 at91_aic_write(AT91_AIC_IDCR, 1 << d->irq); 49 at91_aic_write(AT91_AIC_IDCR, 1 << d->hwirq);
42} 50}
43 51
44static void at91_aic_unmask_irq(struct irq_data *d) 52static void at91_aic_unmask_irq(struct irq_data *d)
45{ 53{
46 /* Enable interrupt on AIC */ 54 /* Enable interrupt on AIC */
47 at91_aic_write(AT91_AIC_IECR, 1 << d->irq); 55 at91_aic_write(AT91_AIC_IECR, 1 << d->hwirq);
48} 56}
49 57
50unsigned int at91_extern_irq; 58unsigned int at91_extern_irq;
51 59
52#define is_extern_irq(irq) ((1 << (irq)) & at91_extern_irq) 60#define is_extern_irq(hwirq) ((1 << (hwirq)) & at91_extern_irq)
53 61
54static int at91_aic_set_type(struct irq_data *d, unsigned type) 62static int at91_aic_set_type(struct irq_data *d, unsigned type)
55{ 63{
@@ -63,13 +71,13 @@ static int at91_aic_set_type(struct irq_data *d, unsigned type)
63 srctype = AT91_AIC_SRCTYPE_RISING; 71 srctype = AT91_AIC_SRCTYPE_RISING;
64 break; 72 break;
65 case IRQ_TYPE_LEVEL_LOW: 73 case IRQ_TYPE_LEVEL_LOW:
66 if ((d->irq == AT91_ID_FIQ) || is_extern_irq(d->irq)) /* only supported on external interrupts */ 74 if ((d->hwirq == AT91_ID_FIQ) || is_extern_irq(d->hwirq)) /* only supported on external interrupts */
67 srctype = AT91_AIC_SRCTYPE_LOW; 75 srctype = AT91_AIC_SRCTYPE_LOW;
68 else 76 else
69 return -EINVAL; 77 return -EINVAL;
70 break; 78 break;
71 case IRQ_TYPE_EDGE_FALLING: 79 case IRQ_TYPE_EDGE_FALLING:
72 if ((d->irq == AT91_ID_FIQ) || is_extern_irq(d->irq)) /* only supported on external interrupts */ 80 if ((d->hwirq == AT91_ID_FIQ) || is_extern_irq(d->hwirq)) /* only supported on external interrupts */
73 srctype = AT91_AIC_SRCTYPE_FALLING; 81 srctype = AT91_AIC_SRCTYPE_FALLING;
74 else 82 else
75 return -EINVAL; 83 return -EINVAL;
@@ -78,8 +86,8 @@ static int at91_aic_set_type(struct irq_data *d, unsigned type)
78 return -EINVAL; 86 return -EINVAL;
79 } 87 }
80 88
81 smr = at91_aic_read(AT91_AIC_SMR(d->irq)) & ~AT91_AIC_SRCTYPE; 89 smr = at91_aic_read(AT91_AIC_SMR(d->hwirq)) & ~AT91_AIC_SRCTYPE;
82 at91_aic_write(AT91_AIC_SMR(d->irq), smr | srctype); 90 at91_aic_write(AT91_AIC_SMR(d->hwirq), smr | srctype);
83 return 0; 91 return 0;
84} 92}
85 93
@@ -90,13 +98,13 @@ static u32 backups;
90 98
91static int at91_aic_set_wake(struct irq_data *d, unsigned value) 99static int at91_aic_set_wake(struct irq_data *d, unsigned value)
92{ 100{
93 if (unlikely(d->irq >= 32)) 101 if (unlikely(d->hwirq >= NR_AIC_IRQS))
94 return -EINVAL; 102 return -EINVAL;
95 103
96 if (value) 104 if (value)
97 wakeups |= (1 << d->irq); 105 wakeups |= (1 << d->hwirq);
98 else 106 else
99 wakeups &= ~(1 << d->irq); 107 wakeups &= ~(1 << d->hwirq);
100 108
101 return 0; 109 return 0;
102} 110}
@@ -127,46 +135,112 @@ static struct irq_chip at91_aic_chip = {
127 .irq_set_wake = at91_aic_set_wake, 135 .irq_set_wake = at91_aic_set_wake,
128}; 136};
129 137
138static void __init at91_aic_hw_init(unsigned int spu_vector)
139{
140 int i;
141
142 /*
143 * Perform 8 End Of Interrupt Command to make sure AIC
144 * will not Lock out nIRQ
145 */
146 for (i = 0; i < 8; i++)
147 at91_aic_write(AT91_AIC_EOICR, 0);
148
149 /*
150 * Spurious Interrupt ID in Spurious Vector Register.
151 * When there is no current interrupt, the IRQ Vector Register
152 * reads the value stored in AIC_SPU
153 */
154 at91_aic_write(AT91_AIC_SPU, spu_vector);
155
156 /* No debugging in AIC: Debug (Protect) Control Register */
157 at91_aic_write(AT91_AIC_DCR, 0);
158
159 /* Disable and clear all interrupts initially */
160 at91_aic_write(AT91_AIC_IDCR, 0xFFFFFFFF);
161 at91_aic_write(AT91_AIC_ICCR, 0xFFFFFFFF);
162}
163
164#if defined(CONFIG_OF)
165static int at91_aic_irq_map(struct irq_domain *h, unsigned int virq,
166 irq_hw_number_t hw)
167{
168 /* Put virq number in Source Vector Register */
169 at91_aic_write(AT91_AIC_SVR(hw), virq);
170
171 /* Active Low interrupt, without priority */
172 at91_aic_write(AT91_AIC_SMR(hw), AT91_AIC_SRCTYPE_LOW);
173
174 irq_set_chip_and_handler(virq, &at91_aic_chip, handle_level_irq);
175 set_irq_flags(virq, IRQF_VALID | IRQF_PROBE);
176
177 return 0;
178}
179
180static struct irq_domain_ops at91_aic_irq_ops = {
181 .map = at91_aic_irq_map,
182 .xlate = irq_domain_xlate_twocell,
183};
184
185int __init at91_aic_of_init(struct device_node *node,
186 struct device_node *parent)
187{
188 at91_aic_base = of_iomap(node, 0);
189 at91_aic_np = node;
190
191 at91_aic_domain = irq_domain_add_linear(at91_aic_np, NR_AIC_IRQS,
192 &at91_aic_irq_ops, NULL);
193 if (!at91_aic_domain)
194 panic("Unable to add AIC irq domain (DT)\n");
195
196 irq_set_default_host(at91_aic_domain);
197
198 at91_aic_hw_init(NR_AIC_IRQS);
199
200 return 0;
201}
202#endif
203
130/* 204/*
131 * Initialize the AIC interrupt controller. 205 * Initialize the AIC interrupt controller.
132 */ 206 */
133void __init at91_aic_init(unsigned int priority[NR_AIC_IRQS]) 207void __init at91_aic_init(unsigned int priority[NR_AIC_IRQS])
134{ 208{
135 unsigned int i; 209 unsigned int i;
210 int irq_base;
136 211
137 at91_aic_base = ioremap(AT91_AIC, 512); 212 at91_aic_base = ioremap(AT91_AIC, 512);
138
139 if (!at91_aic_base) 213 if (!at91_aic_base)
140 panic("Impossible to ioremap AT91_AIC\n"); 214 panic("Unable to ioremap AIC registers\n");
215
216 /* Add irq domain for AIC */
217 irq_base = irq_alloc_descs(-1, 0, NR_AIC_IRQS, 0);
218 if (irq_base < 0) {
219 WARN(1, "Cannot allocate irq_descs, assuming pre-allocated\n");
220 irq_base = 0;
221 }
222 at91_aic_domain = irq_domain_add_legacy(at91_aic_np, NR_AIC_IRQS,
223 irq_base, 0,
224 &irq_domain_simple_ops, NULL);
225
226 if (!at91_aic_domain)
227 panic("Unable to add AIC irq domain\n");
228
229 irq_set_default_host(at91_aic_domain);
141 230
142 /* 231 /*
143 * The IVR is used by macro get_irqnr_and_base to read and verify. 232 * The IVR is used by macro get_irqnr_and_base to read and verify.
144 * The irq number is NR_AIC_IRQS when a spurious interrupt has occurred. 233 * The irq number is NR_AIC_IRQS when a spurious interrupt has occurred.
145 */ 234 */
146 for (i = 0; i < NR_AIC_IRQS; i++) { 235 for (i = 0; i < NR_AIC_IRQS; i++) {
147 /* Put irq number in Source Vector Register: */ 236 /* Put hardware irq number in Source Vector Register: */
148 at91_aic_write(AT91_AIC_SVR(i), i); 237 at91_aic_write(AT91_AIC_SVR(i), i);
149 /* Active Low interrupt, with the specified priority */ 238 /* Active Low interrupt, with the specified priority */
150 at91_aic_write(AT91_AIC_SMR(i), AT91_AIC_SRCTYPE_LOW | priority[i]); 239 at91_aic_write(AT91_AIC_SMR(i), AT91_AIC_SRCTYPE_LOW | priority[i]);
151 240
152 irq_set_chip_and_handler(i, &at91_aic_chip, handle_level_irq); 241 irq_set_chip_and_handler(i, &at91_aic_chip, handle_level_irq);
153 set_irq_flags(i, IRQF_VALID | IRQF_PROBE); 242 set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
154
155 /* Perform 8 End Of Interrupt Command to make sure AIC will not Lock out nIRQ */
156 if (i < 8)
157 at91_aic_write(AT91_AIC_EOICR, 0);
158 } 243 }
159 244
160 /* 245 at91_aic_hw_init(NR_AIC_IRQS);
161 * Spurious Interrupt ID in Spurious Vector Register is NR_AIC_IRQS
162 * When there is no current interrupt, the IRQ Vector Register reads the value stored in AIC_SPU
163 */
164 at91_aic_write(AT91_AIC_SPU, NR_AIC_IRQS);
165
166 /* No debugging in AIC: Debug (Protect) Control Register */
167 at91_aic_write(AT91_AIC_DCR, 0);
168
169 /* Disable and clear all interrupts initially */
170 at91_aic_write(AT91_AIC_IDCR, 0xFFFFFFFF);
171 at91_aic_write(AT91_AIC_ICCR, 0xFFFFFFFF);
172} 246}
diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c
index 1606379ac28..f630250c6b8 100644
--- a/arch/arm/mach-at91/pm.c
+++ b/arch/arm/mach-at91/pm.c
@@ -136,7 +136,7 @@ static int at91_pm_verify_clocks(void)
136 unsigned long scsr; 136 unsigned long scsr;
137 int i; 137 int i;
138 138
139 scsr = at91_sys_read(AT91_PMC_SCSR); 139 scsr = at91_pmc_read(AT91_PMC_SCSR);
140 140
141 /* USB must not be using PLLB */ 141 /* USB must not be using PLLB */
142 if (cpu_is_at91rm9200()) { 142 if (cpu_is_at91rm9200()) {
@@ -150,11 +150,6 @@ static int at91_pm_verify_clocks(void)
150 pr_err("AT91: PM - Suspend-to-RAM with USB still active\n"); 150 pr_err("AT91: PM - Suspend-to-RAM with USB still active\n");
151 return 0; 151 return 0;
152 } 152 }
153 } else if (cpu_is_at91cap9()) {
154 if ((scsr & AT91CAP9_PMC_UHP) != 0) {
155 pr_err("AT91: PM - Suspend-to-RAM with USB still active\n");
156 return 0;
157 }
158 } 153 }
159 154
160#ifdef CONFIG_AT91_PROGRAMMABLE_CLOCKS 155#ifdef CONFIG_AT91_PROGRAMMABLE_CLOCKS
@@ -165,7 +160,7 @@ static int at91_pm_verify_clocks(void)
165 if ((scsr & (AT91_PMC_PCK0 << i)) == 0) 160 if ((scsr & (AT91_PMC_PCK0 << i)) == 0)
166 continue; 161 continue;
167 162
168 css = at91_sys_read(AT91_PMC_PCKR(i)) & AT91_PMC_CSS; 163 css = at91_pmc_read(AT91_PMC_PCKR(i)) & AT91_PMC_CSS;
169 if (css != AT91_PMC_CSS_SLOW) { 164 if (css != AT91_PMC_CSS_SLOW) {
170 pr_err("AT91: PM - Suspend-to-RAM with PCK%d src %d\n", i, css); 165 pr_err("AT91: PM - Suspend-to-RAM with PCK%d src %d\n", i, css);
171 return 0; 166 return 0;
@@ -193,23 +188,23 @@ int at91_suspend_entering_slow_clock(void)
193EXPORT_SYMBOL(at91_suspend_entering_slow_clock); 188EXPORT_SYMBOL(at91_suspend_entering_slow_clock);
194 189
195 190
196static void (*slow_clock)(void); 191static void (*slow_clock)(void __iomem *pmc, void __iomem *ramc0,
192 void __iomem *ramc1, int memctrl);
197 193
198#ifdef CONFIG_AT91_SLOW_CLOCK 194#ifdef CONFIG_AT91_SLOW_CLOCK
199extern void at91_slow_clock(void); 195extern void at91_slow_clock(void __iomem *pmc, void __iomem *ramc0,
196 void __iomem *ramc1, int memctrl);
200extern u32 at91_slow_clock_sz; 197extern u32 at91_slow_clock_sz;
201#endif 198#endif
202 199
203
204static int at91_pm_enter(suspend_state_t state) 200static int at91_pm_enter(suspend_state_t state)
205{ 201{
206 u32 saved_lpr;
207 at91_gpio_suspend(); 202 at91_gpio_suspend();
208 at91_irq_suspend(); 203 at91_irq_suspend();
209 204
210 pr_debug("AT91: PM - wake mask %08x, pm state %d\n", 205 pr_debug("AT91: PM - wake mask %08x, pm state %d\n",
211 /* remember all the always-wake irqs */ 206 /* remember all the always-wake irqs */
212 (at91_sys_read(AT91_PMC_PCSR) 207 (at91_pmc_read(AT91_PMC_PCSR)
213 | (1 << AT91_ID_FIQ) 208 | (1 << AT91_ID_FIQ)
214 | (1 << AT91_ID_SYS) 209 | (1 << AT91_ID_SYS)
215 | (at91_extern_irq)) 210 | (at91_extern_irq))
@@ -234,11 +229,18 @@ static int at91_pm_enter(suspend_state_t state)
234 * turning off the main oscillator; reverse on wakeup. 229 * turning off the main oscillator; reverse on wakeup.
235 */ 230 */
236 if (slow_clock) { 231 if (slow_clock) {
232 int memctrl = AT91_MEMCTRL_SDRAMC;
233
234 if (cpu_is_at91rm9200())
235 memctrl = AT91_MEMCTRL_MC;
236 else if (cpu_is_at91sam9g45())
237 memctrl = AT91_MEMCTRL_DDRSDR;
237#ifdef CONFIG_AT91_SLOW_CLOCK 238#ifdef CONFIG_AT91_SLOW_CLOCK
238 /* copy slow_clock handler to SRAM, and call it */ 239 /* copy slow_clock handler to SRAM, and call it */
239 memcpy(slow_clock, at91_slow_clock, at91_slow_clock_sz); 240 memcpy(slow_clock, at91_slow_clock, at91_slow_clock_sz);
240#endif 241#endif
241 slow_clock(); 242 slow_clock(at91_pmc_base, at91_ramc_base[0],
243 at91_ramc_base[1], memctrl);
242 break; 244 break;
243 } else { 245 } else {
244 pr_info("AT91: PM - no slow clock mode enabled ...\n"); 246 pr_info("AT91: PM - no slow clock mode enabled ...\n");
@@ -259,16 +261,7 @@ static int at91_pm_enter(suspend_state_t state)
259 * For ARM 926 based chips, this requirement is weaker 261 * For ARM 926 based chips, this requirement is weaker
260 * as at91sam9 can access a RAM in self-refresh mode. 262 * as at91sam9 can access a RAM in self-refresh mode.
261 */ 263 */
262 asm volatile ( "mov r0, #0\n\t" 264 at91_standby();
263 "b 1f\n\t"
264 ".align 5\n\t"
265 "1: mcr p15, 0, r0, c7, c10, 4\n\t"
266 : /* no output */
267 : /* no input */
268 : "r0");
269 saved_lpr = sdram_selfrefresh_enable();
270 wait_for_interrupt_enable();
271 sdram_selfrefresh_disable(saved_lpr);
272 break; 265 break;
273 266
274 case PM_SUSPEND_ON: 267 case PM_SUSPEND_ON:
@@ -316,7 +309,7 @@ static int __init at91_pm_init(void)
316 309
317#ifdef CONFIG_ARCH_AT91RM9200 310#ifdef CONFIG_ARCH_AT91RM9200
318 /* AT91RM9200 SDRAM low-power mode cannot be used with self-refresh. */ 311 /* AT91RM9200 SDRAM low-power mode cannot be used with self-refresh. */
319 at91_sys_write(AT91_SDRAMC_LPR, 0); 312 at91_ramc_write(0, AT91RM9200_SDRAMC_LPR, 0);
320#endif 313#endif
321 314
322 suspend_set_ops(&at91_pm_ops); 315 suspend_set_ops(&at91_pm_ops);
diff --git a/arch/arm/mach-at91/pm.h b/arch/arm/mach-at91/pm.h
index 7eb40d24242..89f56f3a802 100644
--- a/arch/arm/mach-at91/pm.h
+++ b/arch/arm/mach-at91/pm.h
@@ -1,5 +1,19 @@
1/*
2 * AT91 Power Management
3 *
4 * Copyright (C) 2005 David Brownell
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#ifndef __ARCH_ARM_MACH_AT91_PM
12#define __ARCH_ARM_MACH_AT91_PM
13
14#include <mach/at91_ramc.h>
1#ifdef CONFIG_ARCH_AT91RM9200 15#ifdef CONFIG_ARCH_AT91RM9200
2#include <mach/at91rm9200_mc.h> 16#include <mach/at91rm9200_sdramc.h>
3 17
4/* 18/*
5 * The AT91RM9200 goes into self-refresh mode with this command, and will 19 * The AT91RM9200 goes into self-refresh mode with this command, and will
@@ -11,51 +25,37 @@
11 * still in self-refresh is "not recommended", but seems to work. 25 * still in self-refresh is "not recommended", but seems to work.
12 */ 26 */
13 27
14static inline u32 sdram_selfrefresh_enable(void) 28static inline void at91rm9200_standby(void)
15{ 29{
16 u32 saved_lpr = at91_sys_read(AT91_SDRAMC_LPR); 30 u32 lpr = at91_ramc_read(0, AT91RM9200_SDRAMC_LPR);
17 31
18 at91_sys_write(AT91_SDRAMC_LPR, 0); 32 asm volatile(
19 at91_sys_write(AT91_SDRAMC_SRR, 1); 33 "b 1f\n\t"
20 return saved_lpr; 34 ".align 5\n\t"
35 "1: mcr p15, 0, %0, c7, c10, 4\n\t"
36 " str %0, [%1, %2]\n\t"
37 " str %3, [%1, %4]\n\t"
38 " mcr p15, 0, %0, c7, c0, 4\n\t"
39 " str %5, [%1, %2]"
40 :
41 : "r" (0), "r" (AT91_BASE_SYS), "r" (AT91RM9200_SDRAMC_LPR),
42 "r" (1), "r" (AT91RM9200_SDRAMC_SRR),
43 "r" (lpr));
21} 44}
22 45
23#define sdram_selfrefresh_disable(saved_lpr) at91_sys_write(AT91_SDRAMC_LPR, saved_lpr) 46#define at91_standby at91rm9200_standby
24#define wait_for_interrupt_enable() asm volatile ("mcr p15, 0, %0, c7, c0, 4" \
25 : : "r" (0))
26
27#elif defined(CONFIG_ARCH_AT91CAP9)
28#include <mach/at91sam9_ddrsdr.h>
29
30
31static inline u32 sdram_selfrefresh_enable(void)
32{
33 u32 saved_lpr, lpr;
34
35 saved_lpr = at91_ramc_read(0, AT91CAP9_DDRSDRC_LPR);
36
37 lpr = saved_lpr & ~AT91_DDRSDRC_LPCB;
38 at91_ramc_write(0, AT91CAP9_DDRSDRC_LPR, lpr | AT91_DDRSDRC_LPCB_SELF_REFRESH);
39 return saved_lpr;
40}
41
42#define sdram_selfrefresh_disable(saved_lpr) at91_ramc_write(0, AT91CAP9_DDRSDRC_LPR, saved_lpr)
43#define wait_for_interrupt_enable() cpu_do_idle()
44 47
45#elif defined(CONFIG_ARCH_AT91SAM9G45) 48#elif defined(CONFIG_ARCH_AT91SAM9G45)
46#include <mach/at91sam9_ddrsdr.h>
47 49
48/* We manage both DDRAM/SDRAM controllers, we need more than one value to 50/* We manage both DDRAM/SDRAM controllers, we need more than one value to
49 * remember. 51 * remember.
50 */ 52 */
51static u32 saved_lpr1; 53static inline void at91sam9g45_standby(void)
52
53static inline u32 sdram_selfrefresh_enable(void)
54{ 54{
55 /* Those tow values allow us to delay self-refresh activation 55 /* Those two values allow us to delay self-refresh activation
56 * to the maximum. */ 56 * to the maximum. */
57 u32 lpr0, lpr1; 57 u32 lpr0, lpr1;
58 u32 saved_lpr0; 58 u32 saved_lpr0, saved_lpr1;
59 59
60 saved_lpr1 = at91_ramc_read(1, AT91_DDRSDRC_LPR); 60 saved_lpr1 = at91_ramc_read(1, AT91_DDRSDRC_LPR);
61 lpr1 = saved_lpr1 & ~AT91_DDRSDRC_LPCB; 61 lpr1 = saved_lpr1 & ~AT91_DDRSDRC_LPCB;
@@ -69,18 +69,15 @@ static inline u32 sdram_selfrefresh_enable(void)
69 at91_ramc_write(0, AT91_DDRSDRC_LPR, lpr0); 69 at91_ramc_write(0, AT91_DDRSDRC_LPR, lpr0);
70 at91_ramc_write(1, AT91_DDRSDRC_LPR, lpr1); 70 at91_ramc_write(1, AT91_DDRSDRC_LPR, lpr1);
71 71
72 return saved_lpr0; 72 cpu_do_idle();
73
74 at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr0);
75 at91_ramc_write(1, AT91_DDRSDRC_LPR, saved_lpr1);
73} 76}
74 77
75#define sdram_selfrefresh_disable(saved_lpr0) \ 78#define at91_standby at91sam9g45_standby
76 do { \
77 at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr0); \
78 at91_ramc_write(1, AT91_DDRSDRC_LPR, saved_lpr1); \
79 } while (0)
80#define wait_for_interrupt_enable() cpu_do_idle()
81 79
82#else 80#else
83#include <mach/at91sam9_sdramc.h>
84 81
85#ifdef CONFIG_ARCH_AT91SAM9263 82#ifdef CONFIG_ARCH_AT91SAM9263
86/* 83/*
@@ -90,18 +87,23 @@ static inline u32 sdram_selfrefresh_enable(void)
90#warning Assuming EB1 SDRAM controller is *NOT* used 87#warning Assuming EB1 SDRAM controller is *NOT* used
91#endif 88#endif
92 89
93static inline u32 sdram_selfrefresh_enable(void) 90static inline void at91sam9_standby(void)
94{ 91{
95 u32 saved_lpr, lpr; 92 u32 saved_lpr, lpr;
96 93
97 saved_lpr = at91_ramc_read(0, AT91_SDRAMC_LPR); 94 saved_lpr = at91_ramc_read(0, AT91_SDRAMC_LPR);
98 95
99 lpr = saved_lpr & ~AT91_SDRAMC_LPCB; 96 lpr = saved_lpr & ~AT91_SDRAMC_LPCB;
100 at91_ramc_write(0, AT91_SDRAMC_LPR, lpr | AT91_SDRAMC_LPCB_SELF_REFRESH); 97 at91_ramc_write(0, AT91_SDRAMC_LPR, lpr |
101 return saved_lpr; 98 AT91_SDRAMC_LPCB_SELF_REFRESH);
99
100 cpu_do_idle();
101
102 at91_ramc_write(0, AT91_SDRAMC_LPR, saved_lpr);
102} 103}
103 104
104#define sdram_selfrefresh_disable(saved_lpr) at91_ramc_write(0, AT91_SDRAMC_LPR, saved_lpr) 105#define at91_standby at91sam9_standby
105#define wait_for_interrupt_enable() cpu_do_idle() 106
107#endif
106 108
107#endif 109#endif
diff --git a/arch/arm/mach-at91/pm_slowclock.S b/arch/arm/mach-at91/pm_slowclock.S
index 92dfb846139..db5452123f1 100644
--- a/arch/arm/mach-at91/pm_slowclock.S
+++ b/arch/arm/mach-at91/pm_slowclock.S
@@ -15,15 +15,7 @@
15#include <linux/linkage.h> 15#include <linux/linkage.h>
16#include <mach/hardware.h> 16#include <mach/hardware.h>
17#include <mach/at91_pmc.h> 17#include <mach/at91_pmc.h>
18 18#include <mach/at91_ramc.h>
19#if defined(CONFIG_ARCH_AT91RM9200)
20#include <mach/at91rm9200_mc.h>
21#elif defined(CONFIG_ARCH_AT91CAP9) \
22 || defined(CONFIG_ARCH_AT91SAM9G45)
23#include <mach/at91sam9_ddrsdr.h>
24#else
25#include <mach/at91sam9_sdramc.h>
26#endif
27 19
28 20
29#ifdef CONFIG_ARCH_AT91SAM9263 21#ifdef CONFIG_ARCH_AT91SAM9263
@@ -47,17 +39,23 @@
47#define PLLALOCK_TIMEOUT 1000 39#define PLLALOCK_TIMEOUT 1000
48#define PLLBLOCK_TIMEOUT 1000 40#define PLLBLOCK_TIMEOUT 1000
49 41
42pmc .req r0
43sdramc .req r1
44ramc1 .req r2
45memctrl .req r3
46tmp1 .req r4
47tmp2 .req r5
50 48
51/* 49/*
52 * Wait until master clock is ready (after switching master clock source) 50 * Wait until master clock is ready (after switching master clock source)
53 */ 51 */
54 .macro wait_mckrdy 52 .macro wait_mckrdy
55 mov r4, #MCKRDY_TIMEOUT 53 mov tmp2, #MCKRDY_TIMEOUT
561: sub r4, r4, #1 541: sub tmp2, tmp2, #1
57 cmp r4, #0 55 cmp tmp2, #0
58 beq 2f 56 beq 2f
59 ldr r3, [r1, #(AT91_PMC_SR - AT91_PMC)] 57 ldr tmp1, [pmc, #AT91_PMC_SR]
60 tst r3, #AT91_PMC_MCKRDY 58 tst tmp1, #AT91_PMC_MCKRDY
61 beq 1b 59 beq 1b
622: 602:
63 .endm 61 .endm
@@ -66,12 +64,12 @@
66 * Wait until master oscillator has stabilized. 64 * Wait until master oscillator has stabilized.
67 */ 65 */
68 .macro wait_moscrdy 66 .macro wait_moscrdy
69 mov r4, #MOSCRDY_TIMEOUT 67 mov tmp2, #MOSCRDY_TIMEOUT
701: sub r4, r4, #1 681: sub tmp2, tmp2, #1
71 cmp r4, #0 69 cmp tmp2, #0
72 beq 2f 70 beq 2f
73 ldr r3, [r1, #(AT91_PMC_SR - AT91_PMC)] 71 ldr tmp1, [pmc, #AT91_PMC_SR]
74 tst r3, #AT91_PMC_MOSCS 72 tst tmp1, #AT91_PMC_MOSCS
75 beq 1b 73 beq 1b
762: 742:
77 .endm 75 .endm
@@ -80,12 +78,12 @@
80 * Wait until PLLA has locked. 78 * Wait until PLLA has locked.
81 */ 79 */
82 .macro wait_pllalock 80 .macro wait_pllalock
83 mov r4, #PLLALOCK_TIMEOUT 81 mov tmp2, #PLLALOCK_TIMEOUT
841: sub r4, r4, #1 821: sub tmp2, tmp2, #1
85 cmp r4, #0 83 cmp tmp2, #0
86 beq 2f 84 beq 2f
87 ldr r3, [r1, #(AT91_PMC_SR - AT91_PMC)] 85 ldr tmp1, [pmc, #AT91_PMC_SR]
88 tst r3, #AT91_PMC_LOCKA 86 tst tmp1, #AT91_PMC_LOCKA
89 beq 1b 87 beq 1b
902: 882:
91 .endm 89 .endm
@@ -94,80 +92,98 @@
94 * Wait until PLLB has locked. 92 * Wait until PLLB has locked.
95 */ 93 */
96 .macro wait_pllblock 94 .macro wait_pllblock
97 mov r4, #PLLBLOCK_TIMEOUT 95 mov tmp2, #PLLBLOCK_TIMEOUT
981: sub r4, r4, #1 961: sub tmp2, tmp2, #1
99 cmp r4, #0 97 cmp tmp2, #0
100 beq 2f 98 beq 2f
101 ldr r3, [r1, #(AT91_PMC_SR - AT91_PMC)] 99 ldr tmp1, [pmc, #AT91_PMC_SR]
102 tst r3, #AT91_PMC_LOCKB 100 tst tmp1, #AT91_PMC_LOCKB
103 beq 1b 101 beq 1b
1042: 1022:
105 .endm 103 .endm
106 104
107 .text 105 .text
108 106
107/* void at91_slow_clock(void __iomem *pmc, void __iomem *sdramc,
108 * void __iomem *ramc1, int memctrl)
109 */
109ENTRY(at91_slow_clock) 110ENTRY(at91_slow_clock)
110 /* Save registers on stack */ 111 /* Save registers on stack */
111 stmfd sp!, {r0 - r12, lr} 112 stmfd sp!, {r4 - r12, lr}
112 113
113 /* 114 /*
114 * Register usage: 115 * Register usage:
115 * R1 = Base address of AT91_PMC 116 * R0 = Base address of AT91_PMC
116 * R2 = Base address of RAM Controller (SDRAM, DDRSDR, or AT91_SYS) 117 * R1 = Base address of RAM Controller (SDRAM, DDRSDR, or AT91_SYS)
117 * R3 = temporary register 118 * R2 = Base address of second RAM Controller or 0 if not present
119 * R3 = Memory controller
118 * R4 = temporary register 120 * R4 = temporary register
119 * R5 = Base address of second RAM Controller or 0 if not present 121 * R5 = temporary register
120 */ 122 */
121 ldr r1, .at91_va_base_pmc
122 ldr r2, .at91_va_base_sdramc
123 ldr r5, .at91_va_base_ramc1
124 123
125 /* Drain write buffer */ 124 /* Drain write buffer */
126 mov r0, #0 125 mov tmp1, #0
127 mcr p15, 0, r0, c7, c10, 4 126 mcr p15, 0, tmp1, c7, c10, 4
127
128 cmp memctrl, #AT91_MEMCTRL_MC
129 bne ddr_sr_enable
128 130
129#ifdef CONFIG_ARCH_AT91RM9200 131 /*
132 * at91rm9200 Memory controller
133 */
130 /* Put SDRAM in self-refresh mode */ 134 /* Put SDRAM in self-refresh mode */
131 mov r3, #1 135 mov tmp1, #1
132 str r3, [r2, #AT91_SDRAMC_SRR] 136 str tmp1, [sdramc, #AT91RM9200_SDRAMC_SRR]
133#elif defined(CONFIG_ARCH_AT91CAP9) \ 137 b sdr_sr_done
134 || defined(CONFIG_ARCH_AT91SAM9G45) 138
139 /*
140 * DDRSDR Memory controller
141 */
142ddr_sr_enable:
143 cmp memctrl, #AT91_MEMCTRL_DDRSDR
144 bne sdr_sr_enable
135 145
136 /* prepare for DDRAM self-refresh mode */ 146 /* prepare for DDRAM self-refresh mode */
137 ldr r3, [r2, #AT91_DDRSDRC_LPR] 147 ldr tmp1, [sdramc, #AT91_DDRSDRC_LPR]
138 str r3, .saved_sam9_lpr 148 str tmp1, .saved_sam9_lpr
139 bic r3, #AT91_DDRSDRC_LPCB 149 bic tmp1, #AT91_DDRSDRC_LPCB
140 orr r3, #AT91_DDRSDRC_LPCB_SELF_REFRESH 150 orr tmp1, #AT91_DDRSDRC_LPCB_SELF_REFRESH
141 151
142 /* figure out if we use the second ram controller */ 152 /* figure out if we use the second ram controller */
143 cmp r5, #0 153 cmp ramc1, #0
144 ldrne r4, [r5, #AT91_DDRSDRC_LPR] 154 ldrne tmp2, [ramc1, #AT91_DDRSDRC_LPR]
145 strne r4, .saved_sam9_lpr1 155 strne tmp2, .saved_sam9_lpr1
146 bicne r4, #AT91_DDRSDRC_LPCB 156 bicne tmp2, #AT91_DDRSDRC_LPCB
147 orrne r4, #AT91_DDRSDRC_LPCB_SELF_REFRESH 157 orrne tmp2, #AT91_DDRSDRC_LPCB_SELF_REFRESH
148 158
149 /* Enable DDRAM self-refresh mode */ 159 /* Enable DDRAM self-refresh mode */
150 str r3, [r2, #AT91_DDRSDRC_LPR] 160 str tmp1, [sdramc, #AT91_DDRSDRC_LPR]
151 strne r4, [r5, #AT91_DDRSDRC_LPR] 161 strne tmp2, [ramc1, #AT91_DDRSDRC_LPR]
152#else 162
163 b sdr_sr_done
164
165 /*
166 * SDRAMC Memory controller
167 */
168sdr_sr_enable:
153 /* Enable SDRAM self-refresh mode */ 169 /* Enable SDRAM self-refresh mode */
154 ldr r3, [r2, #AT91_SDRAMC_LPR] 170 ldr tmp1, [sdramc, #AT91_SDRAMC_LPR]
155 str r3, .saved_sam9_lpr 171 str tmp1, .saved_sam9_lpr
156 172
157 bic r3, #AT91_SDRAMC_LPCB 173 bic tmp1, #AT91_SDRAMC_LPCB
158 orr r3, #AT91_SDRAMC_LPCB_SELF_REFRESH 174 orr tmp1, #AT91_SDRAMC_LPCB_SELF_REFRESH
159 str r3, [r2, #AT91_SDRAMC_LPR] 175 str tmp1, [sdramc, #AT91_SDRAMC_LPR]
160#endif
161 176
177sdr_sr_done:
162 /* Save Master clock setting */ 178 /* Save Master clock setting */
163 ldr r3, [r1, #(AT91_PMC_MCKR - AT91_PMC)] 179 ldr tmp1, [pmc, #AT91_PMC_MCKR]
164 str r3, .saved_mckr 180 str tmp1, .saved_mckr
165 181
166 /* 182 /*
167 * Set the Master clock source to slow clock 183 * Set the Master clock source to slow clock
168 */ 184 */
169 bic r3, r3, #AT91_PMC_CSS 185 bic tmp1, tmp1, #AT91_PMC_CSS
170 str r3, [r1, #(AT91_PMC_MCKR - AT91_PMC)] 186 str tmp1, [pmc, #AT91_PMC_MCKR]
171 187
172 wait_mckrdy 188 wait_mckrdy
173 189
@@ -177,61 +193,61 @@ ENTRY(at91_slow_clock)
177 * 193 *
178 * See AT91RM9200 errata #27 and #28 for details. 194 * See AT91RM9200 errata #27 and #28 for details.
179 */ 195 */
180 mov r3, #0 196 mov tmp1, #0
181 str r3, [r1, #(AT91_PMC_MCKR - AT91_PMC)] 197 str tmp1, [pmc, #AT91_PMC_MCKR]
182 198
183 wait_mckrdy 199 wait_mckrdy
184#endif 200#endif
185 201
186 /* Save PLLA setting and disable it */ 202 /* Save PLLA setting and disable it */
187 ldr r3, [r1, #(AT91_CKGR_PLLAR - AT91_PMC)] 203 ldr tmp1, [pmc, #AT91_CKGR_PLLAR]
188 str r3, .saved_pllar 204 str tmp1, .saved_pllar
189 205
190 mov r3, #AT91_PMC_PLLCOUNT 206 mov tmp1, #AT91_PMC_PLLCOUNT
191 orr r3, r3, #(1 << 29) /* bit 29 always set */ 207 orr tmp1, tmp1, #(1 << 29) /* bit 29 always set */
192 str r3, [r1, #(AT91_CKGR_PLLAR - AT91_PMC)] 208 str tmp1, [pmc, #AT91_CKGR_PLLAR]
193 209
194 /* Save PLLB setting and disable it */ 210 /* Save PLLB setting and disable it */
195 ldr r3, [r1, #(AT91_CKGR_PLLBR - AT91_PMC)] 211 ldr tmp1, [pmc, #AT91_CKGR_PLLBR]
196 str r3, .saved_pllbr 212 str tmp1, .saved_pllbr
197 213
198 mov r3, #AT91_PMC_PLLCOUNT 214 mov tmp1, #AT91_PMC_PLLCOUNT
199 str r3, [r1, #(AT91_CKGR_PLLBR - AT91_PMC)] 215 str tmp1, [pmc, #AT91_CKGR_PLLBR]
200 216
201 /* Turn off the main oscillator */ 217 /* Turn off the main oscillator */
202 ldr r3, [r1, #(AT91_CKGR_MOR - AT91_PMC)] 218 ldr tmp1, [pmc, #AT91_CKGR_MOR]
203 bic r3, r3, #AT91_PMC_MOSCEN 219 bic tmp1, tmp1, #AT91_PMC_MOSCEN
204 str r3, [r1, #(AT91_CKGR_MOR - AT91_PMC)] 220 str tmp1, [pmc, #AT91_CKGR_MOR]
205 221
206 /* Wait for interrupt */ 222 /* Wait for interrupt */
207 mcr p15, 0, r0, c7, c0, 4 223 mcr p15, 0, tmp1, c7, c0, 4
208 224
209 /* Turn on the main oscillator */ 225 /* Turn on the main oscillator */
210 ldr r3, [r1, #(AT91_CKGR_MOR - AT91_PMC)] 226 ldr tmp1, [pmc, #AT91_CKGR_MOR]
211 orr r3, r3, #AT91_PMC_MOSCEN 227 orr tmp1, tmp1, #AT91_PMC_MOSCEN
212 str r3, [r1, #(AT91_CKGR_MOR - AT91_PMC)] 228 str tmp1, [pmc, #AT91_CKGR_MOR]
213 229
214 wait_moscrdy 230 wait_moscrdy
215 231
216 /* Restore PLLB setting */ 232 /* Restore PLLB setting */
217 ldr r3, .saved_pllbr 233 ldr tmp1, .saved_pllbr
218 str r3, [r1, #(AT91_CKGR_PLLBR - AT91_PMC)] 234 str tmp1, [pmc, #AT91_CKGR_PLLBR]
219 235
220 tst r3, #(AT91_PMC_MUL & 0xff0000) 236 tst tmp1, #(AT91_PMC_MUL & 0xff0000)
221 bne 1f 237 bne 1f
222 tst r3, #(AT91_PMC_MUL & ~0xff0000) 238 tst tmp1, #(AT91_PMC_MUL & ~0xff0000)
223 beq 2f 239 beq 2f
2241: 2401:
225 wait_pllblock 241 wait_pllblock
2262: 2422:
227 243
228 /* Restore PLLA setting */ 244 /* Restore PLLA setting */
229 ldr r3, .saved_pllar 245 ldr tmp1, .saved_pllar
230 str r3, [r1, #(AT91_CKGR_PLLAR - AT91_PMC)] 246 str tmp1, [pmc, #AT91_CKGR_PLLAR]
231 247
232 tst r3, #(AT91_PMC_MUL & 0xff0000) 248 tst tmp1, #(AT91_PMC_MUL & 0xff0000)
233 bne 3f 249 bne 3f
234 tst r3, #(AT91_PMC_MUL & ~0xff0000) 250 tst tmp1, #(AT91_PMC_MUL & ~0xff0000)
235 beq 4f 251 beq 4f
2363: 2523:
237 wait_pllalock 253 wait_pllalock
@@ -244,11 +260,11 @@ ENTRY(at91_slow_clock)
244 * 260 *
245 * See AT91RM9200 errata #27 and #28 for details. 261 * See AT91RM9200 errata #27 and #28 for details.
246 */ 262 */
247 ldr r3, .saved_mckr 263 ldr tmp1, .saved_mckr
248 tst r3, #AT91_PMC_PRES 264 tst tmp1, #AT91_PMC_PRES
249 beq 2f 265 beq 2f
250 and r3, r3, #AT91_PMC_PRES 266 and tmp1, tmp1, #AT91_PMC_PRES
251 str r3, [r1, #(AT91_PMC_MCKR - AT91_PMC)] 267 str tmp1, [pmc, #AT91_PMC_MCKR]
252 268
253 wait_mckrdy 269 wait_mckrdy
254#endif 270#endif
@@ -256,32 +272,45 @@ ENTRY(at91_slow_clock)
256 /* 272 /*
257 * Restore master clock setting 273 * Restore master clock setting
258 */ 274 */
2592: ldr r3, .saved_mckr 2752: ldr tmp1, .saved_mckr
260 str r3, [r1, #(AT91_PMC_MCKR - AT91_PMC)] 276 str tmp1, [pmc, #AT91_PMC_MCKR]
261 277
262 wait_mckrdy 278 wait_mckrdy
263 279
264#ifdef CONFIG_ARCH_AT91RM9200 280 /*
265 /* Do nothing - self-refresh is automatically disabled. */ 281 * at91rm9200 Memory controller
266#elif defined(CONFIG_ARCH_AT91CAP9) \ 282 * Do nothing - self-refresh is automatically disabled.
267 || defined(CONFIG_ARCH_AT91SAM9G45) 283 */
284 cmp memctrl, #AT91_MEMCTRL_MC
285 beq ram_restored
286
287 /*
288 * DDRSDR Memory controller
289 */
290 cmp memctrl, #AT91_MEMCTRL_DDRSDR
291 bne sdr_en_restore
268 /* Restore LPR on AT91 with DDRAM */ 292 /* Restore LPR on AT91 with DDRAM */
269 ldr r3, .saved_sam9_lpr 293 ldr tmp1, .saved_sam9_lpr
270 str r3, [r2, #AT91_DDRSDRC_LPR] 294 str tmp1, [sdramc, #AT91_DDRSDRC_LPR]
271 295
272 /* if we use the second ram controller */ 296 /* if we use the second ram controller */
273 cmp r5, #0 297 cmp ramc1, #0
274 ldrne r4, .saved_sam9_lpr1 298 ldrne tmp2, .saved_sam9_lpr1
275 strne r4, [r5, #AT91_DDRSDRC_LPR] 299 strne tmp2, [ramc1, #AT91_DDRSDRC_LPR]
300
301 b ram_restored
276 302
277#else 303 /*
304 * SDRAMC Memory controller
305 */
306sdr_en_restore:
278 /* Restore LPR on AT91 with SDRAM */ 307 /* Restore LPR on AT91 with SDRAM */
279 ldr r3, .saved_sam9_lpr 308 ldr tmp1, .saved_sam9_lpr
280 str r3, [r2, #AT91_SDRAMC_LPR] 309 str tmp1, [sdramc, #AT91_SDRAMC_LPR]
281#endif
282 310
311ram_restored:
283 /* Restore registers, and return */ 312 /* Restore registers, and return */
284 ldmfd sp!, {r0 - r12, pc} 313 ldmfd sp!, {r4 - r12, pc}
285 314
286 315
287.saved_mckr: 316.saved_mckr:
@@ -299,27 +328,5 @@ ENTRY(at91_slow_clock)
299.saved_sam9_lpr1: 328.saved_sam9_lpr1:
300 .word 0 329 .word 0
301 330
302.at91_va_base_pmc:
303 .word AT91_VA_BASE_SYS + AT91_PMC
304
305#ifdef CONFIG_ARCH_AT91RM9200
306.at91_va_base_sdramc:
307 .word AT91_VA_BASE_SYS
308#elif defined(CONFIG_ARCH_AT91CAP9) \
309 || defined(CONFIG_ARCH_AT91SAM9G45)
310.at91_va_base_sdramc:
311 .word AT91_VA_BASE_SYS + AT91_DDRSDRC0
312#else
313.at91_va_base_sdramc:
314 .word AT91_VA_BASE_SYS + AT91_SDRAMC0
315#endif
316
317.at91_va_base_ramc1:
318#if defined(CONFIG_ARCH_AT91SAM9G45)
319 .word AT91_VA_BASE_SYS + AT91_DDRSDRC1
320#else
321 .word 0
322#endif
323
324ENTRY(at91_slow_clock_sz) 331ENTRY(at91_slow_clock_sz)
325 .word .-at91_slow_clock 332 .word .-at91_slow_clock
diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c
index 69d3fc4c46f..1083739e306 100644
--- a/arch/arm/mach-at91/setup.c
+++ b/arch/arm/mach-at91/setup.c
@@ -9,6 +9,7 @@
9#include <linux/io.h> 9#include <linux/io.h>
10#include <linux/mm.h> 10#include <linux/mm.h>
11#include <linux/pm.h> 11#include <linux/pm.h>
12#include <linux/of_address.h>
12 13
13#include <asm/mach/map.h> 14#include <asm/mach/map.h>
14 15
@@ -51,6 +52,19 @@ void __init at91_init_interrupts(unsigned int *priority)
51 at91_gpio_irq_setup(); 52 at91_gpio_irq_setup();
52} 53}
53 54
55void __iomem *at91_ramc_base[2];
56
57void __init at91_ioremap_ramc(int id, u32 addr, u32 size)
58{
59 if (id < 0 || id > 1) {
60 pr_emerg("Wrong RAM controller id (%d), cannot continue\n", id);
61 BUG();
62 }
63 at91_ramc_base[id] = ioremap(addr, size);
64 if (!at91_ramc_base[id])
65 panic("Impossible to ioremap ramc.%d 0x%x\n", id, addr);
66}
67
54static struct map_desc sram_desc[2] __initdata; 68static struct map_desc sram_desc[2] __initdata;
55 69
56void __init at91_init_sram(int bank, unsigned long base, unsigned int length) 70void __init at91_init_sram(int bank, unsigned long base, unsigned int length)
@@ -86,20 +100,6 @@ static void __init soc_detect(u32 dbgu_base)
86 socid = cidr & ~AT91_CIDR_VERSION; 100 socid = cidr & ~AT91_CIDR_VERSION;
87 101
88 switch (socid) { 102 switch (socid) {
89 case ARCH_ID_AT91CAP9: {
90#ifdef CONFIG_AT91_PMC_UNIT
91 u32 pmc_ver = at91_sys_read(AT91_PMC_VER);
92
93 if (pmc_ver == ARCH_REVISION_CAP9_B)
94 at91_soc_initdata.subtype = AT91_SOC_CAP9_REV_B;
95 else if (pmc_ver == ARCH_REVISION_CAP9_C)
96 at91_soc_initdata.subtype = AT91_SOC_CAP9_REV_C;
97#endif
98 at91_soc_initdata.type = AT91_SOC_CAP9;
99 at91_boot_soc = at91cap9_soc;
100 break;
101 }
102
103 case ARCH_ID_AT91RM9200: 103 case ARCH_ID_AT91RM9200:
104 at91_soc_initdata.type = AT91_SOC_RM9200; 104 at91_soc_initdata.type = AT91_SOC_RM9200;
105 at91_boot_soc = at91rm9200_soc; 105 at91_boot_soc = at91rm9200_soc;
@@ -200,7 +200,6 @@ static void __init soc_detect(u32 dbgu_base)
200 200
201static const char *soc_name[] = { 201static const char *soc_name[] = {
202 [AT91_SOC_RM9200] = "at91rm9200", 202 [AT91_SOC_RM9200] = "at91rm9200",
203 [AT91_SOC_CAP9] = "at91cap9",
204 [AT91_SOC_SAM9260] = "at91sam9260", 203 [AT91_SOC_SAM9260] = "at91sam9260",
205 [AT91_SOC_SAM9261] = "at91sam9261", 204 [AT91_SOC_SAM9261] = "at91sam9261",
206 [AT91_SOC_SAM9263] = "at91sam9263", 205 [AT91_SOC_SAM9263] = "at91sam9263",
@@ -221,8 +220,6 @@ EXPORT_SYMBOL(at91_get_soc_type);
221static const char *soc_subtype_name[] = { 220static const char *soc_subtype_name[] = {
222 [AT91_SOC_RM9200_BGA] = "at91rm9200 BGA", 221 [AT91_SOC_RM9200_BGA] = "at91rm9200 BGA",
223 [AT91_SOC_RM9200_PQFP] = "at91rm9200 PQFP", 222 [AT91_SOC_RM9200_PQFP] = "at91rm9200 PQFP",
224 [AT91_SOC_CAP9_REV_B] = "at91cap9 revB",
225 [AT91_SOC_CAP9_REV_C] = "at91cap9 revC",
226 [AT91_SOC_SAM9XE] = "at91sam9xe", 223 [AT91_SOC_SAM9XE] = "at91sam9xe",
227 [AT91_SOC_SAM9G45ES] = "at91sam9g45es", 224 [AT91_SOC_SAM9G45ES] = "at91sam9g45es",
228 [AT91_SOC_SAM9M10] = "at91sam9m10", 225 [AT91_SOC_SAM9M10] = "at91sam9m10",
@@ -293,6 +290,159 @@ void __init at91_ioremap_rstc(u32 base_addr)
293 panic("Impossible to ioremap at91_rstc_base\n"); 290 panic("Impossible to ioremap at91_rstc_base\n");
294} 291}
295 292
293void __iomem *at91_matrix_base;
294
295void __init at91_ioremap_matrix(u32 base_addr)
296{
297 at91_matrix_base = ioremap(base_addr, 512);
298 if (!at91_matrix_base)
299 panic("Impossible to ioremap at91_matrix_base\n");
300}
301
302#if defined(CONFIG_OF)
303static struct of_device_id rstc_ids[] = {
304 { .compatible = "atmel,at91sam9260-rstc", .data = at91sam9_alt_restart },
305 { .compatible = "atmel,at91sam9g45-rstc", .data = at91sam9g45_restart },
306 { /*sentinel*/ }
307};
308
309static void at91_dt_rstc(void)
310{
311 struct device_node *np;
312 const struct of_device_id *of_id;
313
314 np = of_find_matching_node(NULL, rstc_ids);
315 if (!np)
316 panic("unable to find compatible rstc node in dtb\n");
317
318 at91_rstc_base = of_iomap(np, 0);
319 if (!at91_rstc_base)
320 panic("unable to map rstc cpu registers\n");
321
322 of_id = of_match_node(rstc_ids, np);
323 if (!of_id)
324 panic("AT91: rtsc no restart function availlable\n");
325
326 arm_pm_restart = of_id->data;
327
328 of_node_put(np);
329}
330
331static struct of_device_id ramc_ids[] = {
332 { .compatible = "atmel,at91sam9260-sdramc" },
333 { .compatible = "atmel,at91sam9g45-ddramc" },
334 { /*sentinel*/ }
335};
336
337static void at91_dt_ramc(void)
338{
339 struct device_node *np;
340
341 np = of_find_matching_node(NULL, ramc_ids);
342 if (!np)
343 panic("unable to find compatible ram conroller node in dtb\n");
344
345 at91_ramc_base[0] = of_iomap(np, 0);
346 if (!at91_ramc_base[0])
347 panic("unable to map ramc[0] cpu registers\n");
348 /* the controller may have 2 banks */
349 at91_ramc_base[1] = of_iomap(np, 1);
350
351 of_node_put(np);
352}
353
354static struct of_device_id shdwc_ids[] = {
355 { .compatible = "atmel,at91sam9260-shdwc", },
356 { .compatible = "atmel,at91sam9rl-shdwc", },
357 { .compatible = "atmel,at91sam9x5-shdwc", },
358 { /*sentinel*/ }
359};
360
361static const char *shdwc_wakeup_modes[] = {
362 [AT91_SHDW_WKMODE0_NONE] = "none",
363 [AT91_SHDW_WKMODE0_HIGH] = "high",
364 [AT91_SHDW_WKMODE0_LOW] = "low",
365 [AT91_SHDW_WKMODE0_ANYLEVEL] = "any",
366};
367
368const int at91_dtget_shdwc_wakeup_mode(struct device_node *np)
369{
370 const char *pm;
371 int err, i;
372
373 err = of_property_read_string(np, "atmel,wakeup-mode", &pm);
374 if (err < 0)
375 return AT91_SHDW_WKMODE0_ANYLEVEL;
376
377 for (i = 0; i < ARRAY_SIZE(shdwc_wakeup_modes); i++)
378 if (!strcasecmp(pm, shdwc_wakeup_modes[i]))
379 return i;
380
381 return -ENODEV;
382}
383
384static void at91_dt_shdwc(void)
385{
386 struct device_node *np;
387 int wakeup_mode;
388 u32 reg;
389 u32 mode = 0;
390
391 np = of_find_matching_node(NULL, shdwc_ids);
392 if (!np) {
393 pr_debug("AT91: unable to find compatible shutdown (shdwc) conroller node in dtb\n");
394 return;
395 }
396
397 at91_shdwc_base = of_iomap(np, 0);
398 if (!at91_shdwc_base)
399 panic("AT91: unable to map shdwc cpu registers\n");
400
401 wakeup_mode = at91_dtget_shdwc_wakeup_mode(np);
402 if (wakeup_mode < 0) {
403 pr_warn("AT91: shdwc unknown wakeup mode\n");
404 goto end;
405 }
406
407 if (!of_property_read_u32(np, "atmel,wakeup-counter", &reg)) {
408 if (reg > AT91_SHDW_CPTWK0_MAX) {
409 pr_warn("AT91: shdwc wakeup conter 0x%x > 0x%x reduce it to 0x%x\n",
410 reg, AT91_SHDW_CPTWK0_MAX, AT91_SHDW_CPTWK0_MAX);
411 reg = AT91_SHDW_CPTWK0_MAX;
412 }
413 mode |= AT91_SHDW_CPTWK0_(reg);
414 }
415
416 if (of_property_read_bool(np, "atmel,wakeup-rtc-timer"))
417 mode |= AT91_SHDW_RTCWKEN;
418
419 if (of_property_read_bool(np, "atmel,wakeup-rtt-timer"))
420 mode |= AT91_SHDW_RTTWKEN;
421
422 at91_shdwc_write(AT91_SHDW_MR, wakeup_mode | mode);
423
424end:
425 pm_power_off = at91sam9_poweroff;
426
427 of_node_put(np);
428}
429
430void __init at91_dt_initialize(void)
431{
432 at91_dt_rstc();
433 at91_dt_ramc();
434 at91_dt_shdwc();
435
436 /* Init clock subsystem */
437 at91_dt_clock_init();
438
439 /* Register the processor-specific clocks */
440 at91_boot_soc.register_clocks();
441
442 at91_boot_soc.init();
443}
444#endif
445
296void __init at91_initialize(unsigned long main_clock) 446void __init at91_initialize(unsigned long main_clock)
297{ 447{
298 at91_boot_soc.ioremap_registers(); 448 at91_boot_soc.ioremap_registers();
diff --git a/arch/arm/mach-at91/soc.h b/arch/arm/mach-at91/soc.h
index 4588ae6f7ac..5db4aa45404 100644
--- a/arch/arm/mach-at91/soc.h
+++ b/arch/arm/mach-at91/soc.h
@@ -13,7 +13,6 @@ struct at91_init_soc {
13}; 13};
14 14
15extern struct at91_init_soc at91_boot_soc; 15extern struct at91_init_soc at91_boot_soc;
16extern struct at91_init_soc at91cap9_soc;
17extern struct at91_init_soc at91rm9200_soc; 16extern struct at91_init_soc at91rm9200_soc;
18extern struct at91_init_soc at91sam9260_soc; 17extern struct at91_init_soc at91sam9260_soc;
19extern struct at91_init_soc at91sam9261_soc; 18extern struct at91_init_soc at91sam9261_soc;
@@ -27,10 +26,6 @@ static inline int at91_soc_is_enabled(void)
27 return at91_boot_soc.init != NULL; 26 return at91_boot_soc.init != NULL;
28} 27}
29 28
30#if !defined(CONFIG_ARCH_AT91CAP9)
31#define at91cap9_soc at91_boot_soc
32#endif
33
34#if !defined(CONFIG_ARCH_AT91RM9200) 29#if !defined(CONFIG_ARCH_AT91RM9200)
35#define at91rm9200_soc at91_boot_soc 30#define at91rm9200_soc at91_boot_soc
36#endif 31#endif
diff --git a/arch/arm/mach-bcmring/core.c b/arch/arm/mach-bcmring/core.c
index 6b67b7e8426..22e4e0a28ad 100644
--- a/arch/arm/mach-bcmring/core.c
+++ b/arch/arm/mach-bcmring/core.c
@@ -52,27 +52,8 @@
52#include <mach/csp/chipcHw_inline.h> 52#include <mach/csp/chipcHw_inline.h>
53#include <mach/csp/tmrHw_reg.h> 53#include <mach/csp/tmrHw_reg.h>
54 54
55#define AMBA_DEVICE(name, initname, base, plat, size) \ 55static AMBA_APB_DEVICE(uartA, "uarta", MM_ADDR_IO_UARTA, { IRQ_UARTA }, NULL);
56static struct amba_device name##_device = { \ 56static AMBA_APB_DEVICE(uartB, "uartb", MM_ADDR_IO_UARTB, { IRQ_UARTB }, NULL);
57 .dev = { \
58 .coherent_dma_mask = ~0, \
59 .init_name = initname, \
60 .platform_data = plat \
61 }, \
62 .res = { \
63 .start = MM_ADDR_IO_##base, \
64 .end = MM_ADDR_IO_##base + (size) - 1, \
65 .flags = IORESOURCE_MEM \
66 }, \
67 .dma_mask = ~0, \
68 .irq = { \
69 IRQ_##base \
70 } \
71}
72
73
74AMBA_DEVICE(uartA, "uarta", UARTA, NULL, SZ_4K);
75AMBA_DEVICE(uartB, "uartb", UARTB, NULL, SZ_4K);
76 57
77static struct clk pll1_clk = { 58static struct clk pll1_clk = {
78 .name = "PLL1", 59 .name = "PLL1",
diff --git a/arch/arm/mach-bcmring/include/mach/entry-macro.S b/arch/arm/mach-bcmring/include/mach/entry-macro.S
index 94c950d783b..2f316f0e6e6 100644
--- a/arch/arm/mach-bcmring/include/mach/entry-macro.S
+++ b/arch/arm/mach-bcmring/include/mach/entry-macro.S
@@ -21,9 +21,6 @@
21#include <mach/hardware.h> 21#include <mach/hardware.h>
22#include <mach/csp/mm_io.h> 22#include <mach/csp/mm_io.h>
23 23
24 .macro disable_fiq
25 .endm
26
27 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp 24 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
28 ldr \base, =(MM_IO_BASE_INTC0) 25 ldr \base, =(MM_IO_BASE_INTC0)
29 ldr \irqstat, [\base, #0] @ get status 26 ldr \irqstat, [\base, #0] @ get status
@@ -77,6 +74,3 @@
77 74
78 .macro get_irqnr_preamble, base, tmp 75 .macro get_irqnr_preamble, base, tmp
79 .endm 76 .endm
80
81 .macro arch_ret_to_user, tmp1, tmp2
82 .endm
diff --git a/arch/arm/mach-bcmring/include/mach/system.h b/arch/arm/mach-bcmring/include/mach/system.h
deleted file mode 100644
index cb78250db64..00000000000
--- a/arch/arm/mach-bcmring/include/mach/system.h
+++ /dev/null
@@ -1,28 +0,0 @@
1/*
2 *
3 * Copyright (C) 1999 ARM Limited
4 * Copyright (C) 2000 Deep Blue Solutions Ltd
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#ifndef __ASM_ARCH_SYSTEM_H
21#define __ASM_ARCH_SYSTEM_H
22
23static inline void arch_idle(void)
24{
25 cpu_do_idle();
26}
27
28#endif
diff --git a/arch/arm/mach-clps711x/common.c b/arch/arm/mach-clps711x/common.c
index ac84f925c79..3c5b5bbf24e 100644
--- a/arch/arm/mach-clps711x/common.c
+++ b/arch/arm/mach-clps711x/common.c
@@ -226,3 +226,19 @@ void clps711x_restart(char mode, const char *cmd)
226{ 226{
227 soft_restart(0); 227 soft_restart(0);
228} 228}
229
230static void clps711x_idle(void)
231{
232 clps_writel(1, HALT);
233 __asm__ __volatile__(
234 "mov r0, r0\n\
235 mov r0, r0");
236}
237
238static int __init clps711x_idle_init(void)
239{
240 arm_pm_idle = clps711x_idle;
241 return 0;
242}
243
244arch_initcall(clps711x_idle_init);
diff --git a/arch/arm/mach-clps711x/include/mach/entry-macro.S b/arch/arm/mach-clps711x/include/mach/entry-macro.S
index 90fa2f70489..125af59d7a2 100644
--- a/arch/arm/mach-clps711x/include/mach/entry-macro.S
+++ b/arch/arm/mach-clps711x/include/mach/entry-macro.S
@@ -10,15 +10,9 @@
10#include <mach/hardware.h> 10#include <mach/hardware.h>
11#include <asm/hardware/clps7111.h> 11#include <asm/hardware/clps7111.h>
12 12
13 .macro disable_fiq
14 .endm
15
16 .macro get_irqnr_preamble, base, tmp 13 .macro get_irqnr_preamble, base, tmp
17 .endm 14 .endm
18 15
19 .macro arch_ret_to_user, tmp1, tmp2
20 .endm
21
22#if (INTSR2 - INTSR1) != (INTMR2 - INTMR1) 16#if (INTSR2 - INTSR1) != (INTMR2 - INTMR1)
23#error INTSR stride != INTMR stride 17#error INTSR stride != INTMR stride
24#endif 18#endif
diff --git a/arch/arm/mach-clps711x/include/mach/system.h b/arch/arm/mach-clps711x/include/mach/system.h
deleted file mode 100644
index 23d6ef8c84d..00000000000
--- a/arch/arm/mach-clps711x/include/mach/system.h
+++ /dev/null
@@ -1,35 +0,0 @@
1/*
2 * arch/arm/mach-clps711x/include/mach/system.h
3 *
4 * Copyright (C) 2000 Deep Blue Solutions Ltd
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#ifndef __ASM_ARCH_SYSTEM_H
21#define __ASM_ARCH_SYSTEM_H
22
23#include <linux/io.h>
24#include <mach/hardware.h>
25#include <asm/hardware/clps7111.h>
26
27static inline void arch_idle(void)
28{
29 clps_writel(1, HALT);
30 __asm__ __volatile__(
31 "mov r0, r0\n\
32 mov r0, r0");
33}
34
35#endif
diff --git a/arch/arm/mach-cns3xxx/include/mach/entry-macro.S b/arch/arm/mach-cns3xxx/include/mach/entry-macro.S
deleted file mode 100644
index 01c57df5f71..00000000000
--- a/arch/arm/mach-cns3xxx/include/mach/entry-macro.S
+++ /dev/null
@@ -1,15 +0,0 @@
1/*
2 * Low-level IRQ helper macros for Cavium Networks platforms
3 *
4 * Copyright 2008 Cavium Networks
5 *
6 * This file 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 .macro disable_fiq
12 .endm
13
14 .macro arch_ret_to_user, tmp1, tmp2
15 .endm
diff --git a/arch/arm/mach-cns3xxx/include/mach/system.h b/arch/arm/mach-cns3xxx/include/mach/system.h
deleted file mode 100644
index 9e56b7dc133..00000000000
--- a/arch/arm/mach-cns3xxx/include/mach/system.h
+++ /dev/null
@@ -1,25 +0,0 @@
1/*
2 * Copyright 2000 Deep Blue Solutions Ltd
3 * Copyright 2003 ARM Limited
4 * Copyright 2008 Cavium Networks
5 *
6 * This file 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 __MACH_SYSTEM_H
12#define __MACH_SYSTEM_H
13
14#include <asm/proc-fns.h>
15
16static inline void arch_idle(void)
17{
18 /*
19 * This should do all the clock switching
20 * and wait for interrupt tricks
21 */
22 cpu_do_idle();
23}
24
25#endif
diff --git a/arch/arm/mach-cns3xxx/pcie.c b/arch/arm/mach-cns3xxx/pcie.c
index e159d69967c..79d001f831e 100644
--- a/arch/arm/mach-cns3xxx/pcie.c
+++ b/arch/arm/mach-cns3xxx/pcie.c
@@ -155,8 +155,8 @@ static int cns3xxx_pci_setup(int nr, struct pci_sys_data *sys)
155 BUG_ON(request_resource(&iomem_resource, res_io) || 155 BUG_ON(request_resource(&iomem_resource, res_io) ||
156 request_resource(&iomem_resource, res_mem)); 156 request_resource(&iomem_resource, res_mem));
157 157
158 pci_add_resource(&sys->resources, res_io); 158 pci_add_resource_offset(&sys->resources, res_io, sys->io_offset);
159 pci_add_resource(&sys->resources, res_mem); 159 pci_add_resource_offset(&sys->resources, res_mem, sys->mem_offset);
160 160
161 return 1; 161 return 1;
162} 162}
diff --git a/arch/arm/mach-davinci/board-dm355-evm.c b/arch/arm/mach-davinci/board-dm355-evm.c
index 275341f159f..82ed753fb36 100644
--- a/arch/arm/mach-davinci/board-dm355-evm.c
+++ b/arch/arm/mach-davinci/board-dm355-evm.c
@@ -26,13 +26,14 @@
26#include <asm/mach-types.h> 26#include <asm/mach-types.h>
27#include <asm/mach/arch.h> 27#include <asm/mach/arch.h>
28 28
29#include <mach/dm355.h>
30#include <mach/i2c.h> 29#include <mach/i2c.h>
31#include <mach/serial.h> 30#include <mach/serial.h>
32#include <mach/nand.h> 31#include <mach/nand.h>
33#include <mach/mmc.h> 32#include <mach/mmc.h>
34#include <mach/usb.h> 33#include <mach/usb.h>
35 34
35#include "davinci.h"
36
36/* NOTE: this is geared for the standard config, with a socketed 37/* NOTE: this is geared for the standard config, with a socketed
37 * 2 GByte Micron NAND (MT29F16G08FAA) using 128KB sectors. If you 38 * 2 GByte Micron NAND (MT29F16G08FAA) using 128KB sectors. If you
38 * swap chips, maybe with a different block size, partitioning may 39 * swap chips, maybe with a different block size, partitioning may
diff --git a/arch/arm/mach-davinci/board-dm355-leopard.c b/arch/arm/mach-davinci/board-dm355-leopard.c
index e99db28181a..d74a8b3445f 100644
--- a/arch/arm/mach-davinci/board-dm355-leopard.c
+++ b/arch/arm/mach-davinci/board-dm355-leopard.c
@@ -23,13 +23,14 @@
23#include <asm/mach-types.h> 23#include <asm/mach-types.h>
24#include <asm/mach/arch.h> 24#include <asm/mach/arch.h>
25 25
26#include <mach/dm355.h>
27#include <mach/i2c.h> 26#include <mach/i2c.h>
28#include <mach/serial.h> 27#include <mach/serial.h>
29#include <mach/nand.h> 28#include <mach/nand.h>
30#include <mach/mmc.h> 29#include <mach/mmc.h>
31#include <mach/usb.h> 30#include <mach/usb.h>
32 31
32#include "davinci.h"
33
33/* NOTE: this is geared for the standard config, with a socketed 34/* NOTE: this is geared for the standard config, with a socketed
34 * 2 GByte Micron NAND (MT29F16G08FAA) using 128KB sectors. If you 35 * 2 GByte Micron NAND (MT29F16G08FAA) using 128KB sectors. If you
35 * swap chips, maybe with a different block size, partitioning may 36 * swap chips, maybe with a different block size, partitioning may
diff --git a/arch/arm/mach-davinci/board-dm365-evm.c b/arch/arm/mach-davinci/board-dm365-evm.c
index 849311d3cb7..5bce2b83bb4 100644
--- a/arch/arm/mach-davinci/board-dm365-evm.c
+++ b/arch/arm/mach-davinci/board-dm365-evm.c
@@ -32,7 +32,6 @@
32#include <asm/mach/arch.h> 32#include <asm/mach/arch.h>
33 33
34#include <mach/mux.h> 34#include <mach/mux.h>
35#include <mach/dm365.h>
36#include <mach/common.h> 35#include <mach/common.h>
37#include <mach/i2c.h> 36#include <mach/i2c.h>
38#include <mach/serial.h> 37#include <mach/serial.h>
@@ -42,6 +41,8 @@
42 41
43#include <media/tvp514x.h> 42#include <media/tvp514x.h>
44 43
44#include "davinci.h"
45
45static inline int have_imager(void) 46static inline int have_imager(void)
46{ 47{
47 /* REVISIT when it's supported, trigger via Kconfig */ 48 /* REVISIT when it's supported, trigger via Kconfig */
diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c
index 1247ecdcf75..3683306e024 100644
--- a/arch/arm/mach-davinci/board-dm644x-evm.c
+++ b/arch/arm/mach-davinci/board-dm644x-evm.c
@@ -30,7 +30,6 @@
30#include <asm/mach-types.h> 30#include <asm/mach-types.h>
31#include <asm/mach/arch.h> 31#include <asm/mach/arch.h>
32 32
33#include <mach/dm644x.h>
34#include <mach/common.h> 33#include <mach/common.h>
35#include <mach/i2c.h> 34#include <mach/i2c.h>
36#include <mach/serial.h> 35#include <mach/serial.h>
@@ -40,6 +39,8 @@
40#include <mach/usb.h> 39#include <mach/usb.h>
41#include <mach/aemif.h> 40#include <mach/aemif.h>
42 41
42#include "davinci.h"
43
43#define DM644X_EVM_PHY_ID "davinci_mdio-0:01" 44#define DM644X_EVM_PHY_ID "davinci_mdio-0:01"
44#define LXT971_PHY_ID (0x001378e2) 45#define LXT971_PHY_ID (0x001378e2)
45#define LXT971_PHY_MASK (0xfffffff0) 46#define LXT971_PHY_MASK (0xfffffff0)
@@ -189,7 +190,7 @@ static struct platform_device davinci_fb_device = {
189 .num_resources = 0, 190 .num_resources = 0,
190}; 191};
191 192
192static struct tvp514x_platform_data tvp5146_pdata = { 193static struct tvp514x_platform_data dm644xevm_tvp5146_pdata = {
193 .clk_polarity = 0, 194 .clk_polarity = 0,
194 .hs_polarity = 1, 195 .hs_polarity = 1,
195 .vs_polarity = 1 196 .vs_polarity = 1
@@ -197,7 +198,7 @@ static struct tvp514x_platform_data tvp5146_pdata = {
197 198
198#define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL) 199#define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
199/* Inputs available at the TVP5146 */ 200/* Inputs available at the TVP5146 */
200static struct v4l2_input tvp5146_inputs[] = { 201static struct v4l2_input dm644xevm_tvp5146_inputs[] = {
201 { 202 {
202 .index = 0, 203 .index = 0,
203 .name = "Composite", 204 .name = "Composite",
@@ -217,7 +218,7 @@ static struct v4l2_input tvp5146_inputs[] = {
217 * ouput that goes to vpfe. There is a one to one correspondence 218 * ouput that goes to vpfe. There is a one to one correspondence
218 * with tvp5146_inputs 219 * with tvp5146_inputs
219 */ 220 */
220static struct vpfe_route tvp5146_routes[] = { 221static struct vpfe_route dm644xevm_tvp5146_routes[] = {
221 { 222 {
222 .input = INPUT_CVBS_VI2B, 223 .input = INPUT_CVBS_VI2B,
223 .output = OUTPUT_10BIT_422_EMBEDDED_SYNC, 224 .output = OUTPUT_10BIT_422_EMBEDDED_SYNC,
@@ -228,13 +229,13 @@ static struct vpfe_route tvp5146_routes[] = {
228 }, 229 },
229}; 230};
230 231
231static struct vpfe_subdev_info vpfe_sub_devs[] = { 232static struct vpfe_subdev_info dm644xevm_vpfe_sub_devs[] = {
232 { 233 {
233 .name = "tvp5146", 234 .name = "tvp5146",
234 .grp_id = 0, 235 .grp_id = 0,
235 .num_inputs = ARRAY_SIZE(tvp5146_inputs), 236 .num_inputs = ARRAY_SIZE(dm644xevm_tvp5146_inputs),
236 .inputs = tvp5146_inputs, 237 .inputs = dm644xevm_tvp5146_inputs,
237 .routes = tvp5146_routes, 238 .routes = dm644xevm_tvp5146_routes,
238 .can_route = 1, 239 .can_route = 1,
239 .ccdc_if_params = { 240 .ccdc_if_params = {
240 .if_type = VPFE_BT656, 241 .if_type = VPFE_BT656,
@@ -243,15 +244,15 @@ static struct vpfe_subdev_info vpfe_sub_devs[] = {
243 }, 244 },
244 .board_info = { 245 .board_info = {
245 I2C_BOARD_INFO("tvp5146", 0x5d), 246 I2C_BOARD_INFO("tvp5146", 0x5d),
246 .platform_data = &tvp5146_pdata, 247 .platform_data = &dm644xevm_tvp5146_pdata,
247 }, 248 },
248 }, 249 },
249}; 250};
250 251
251static struct vpfe_config vpfe_cfg = { 252static struct vpfe_config dm644xevm_capture_cfg = {
252 .num_subdevs = ARRAY_SIZE(vpfe_sub_devs), 253 .num_subdevs = ARRAY_SIZE(dm644xevm_vpfe_sub_devs),
253 .i2c_adapter_id = 1, 254 .i2c_adapter_id = 1,
254 .sub_devs = vpfe_sub_devs, 255 .sub_devs = dm644xevm_vpfe_sub_devs,
255 .card_name = "DM6446 EVM", 256 .card_name = "DM6446 EVM",
256 .ccdc = "DM6446 CCDC", 257 .ccdc = "DM6446 CCDC",
257}; 258};
@@ -612,6 +613,113 @@ static void __init evm_init_i2c(void)
612 i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info)); 613 i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info));
613} 614}
614 615
616#define VENC_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL)
617
618/* venc standard timings */
619static struct vpbe_enc_mode_info dm644xevm_enc_std_timing[] = {
620 {
621 .name = "ntsc",
622 .timings_type = VPBE_ENC_STD,
623 .timings = {V4L2_STD_525_60},
624 .interlaced = 1,
625 .xres = 720,
626 .yres = 480,
627 .aspect = {11, 10},
628 .fps = {30000, 1001},
629 .left_margin = 0x79,
630 .upper_margin = 0x10,
631 },
632 {
633 .name = "pal",
634 .timings_type = VPBE_ENC_STD,
635 .timings = {V4L2_STD_625_50},
636 .interlaced = 1,
637 .xres = 720,
638 .yres = 576,
639 .aspect = {54, 59},
640 .fps = {25, 1},
641 .left_margin = 0x7e,
642 .upper_margin = 0x16,
643 },
644};
645
646/* venc dv preset timings */
647static struct vpbe_enc_mode_info dm644xevm_enc_preset_timing[] = {
648 {
649 .name = "480p59_94",
650 .timings_type = VPBE_ENC_DV_PRESET,
651 .timings = {V4L2_DV_480P59_94},
652 .interlaced = 0,
653 .xres = 720,
654 .yres = 480,
655 .aspect = {1, 1},
656 .fps = {5994, 100},
657 .left_margin = 0x80,
658 .upper_margin = 0x20,
659 },
660 {
661 .name = "576p50",
662 .timings_type = VPBE_ENC_DV_PRESET,
663 .timings = {V4L2_DV_576P50},
664 .interlaced = 0,
665 .xres = 720,
666 .yres = 576,
667 .aspect = {1, 1},
668 .fps = {50, 1},
669 .left_margin = 0x7e,
670 .upper_margin = 0x30,
671 },
672};
673
674/*
675 * The outputs available from VPBE + encoders. Keep the order same
676 * as that of encoders. First those from venc followed by that from
677 * encoders. Index in the output refers to index on a particular encoder.
678 * Driver uses this index to pass it to encoder when it supports more
679 * than one output. Userspace applications use index of the array to
680 * set an output.
681 */
682static struct vpbe_output dm644xevm_vpbe_outputs[] = {
683 {
684 .output = {
685 .index = 0,
686 .name = "Composite",
687 .type = V4L2_OUTPUT_TYPE_ANALOG,
688 .std = VENC_STD_ALL,
689 .capabilities = V4L2_OUT_CAP_STD,
690 },
691 .subdev_name = VPBE_VENC_SUBDEV_NAME,
692 .default_mode = "ntsc",
693 .num_modes = ARRAY_SIZE(dm644xevm_enc_std_timing),
694 .modes = dm644xevm_enc_std_timing,
695 },
696 {
697 .output = {
698 .index = 1,
699 .name = "Component",
700 .type = V4L2_OUTPUT_TYPE_ANALOG,
701 .capabilities = V4L2_OUT_CAP_PRESETS,
702 },
703 .subdev_name = VPBE_VENC_SUBDEV_NAME,
704 .default_mode = "480p59_94",
705 .num_modes = ARRAY_SIZE(dm644xevm_enc_preset_timing),
706 .modes = dm644xevm_enc_preset_timing,
707 },
708};
709
710static struct vpbe_config dm644xevm_display_cfg = {
711 .module_name = "dm644x-vpbe-display",
712 .i2c_adapter_id = 1,
713 .osd = {
714 .module_name = VPBE_OSD_SUBDEV_NAME,
715 },
716 .venc = {
717 .module_name = VPBE_VENC_SUBDEV_NAME,
718 },
719 .num_outputs = ARRAY_SIZE(dm644xevm_vpbe_outputs),
720 .outputs = dm644xevm_vpbe_outputs,
721};
722
615static struct platform_device *davinci_evm_devices[] __initdata = { 723static struct platform_device *davinci_evm_devices[] __initdata = {
616 &davinci_fb_device, 724 &davinci_fb_device,
617 &rtc_dev, 725 &rtc_dev,
@@ -624,8 +732,6 @@ static struct davinci_uart_config uart_config __initdata = {
624static void __init 732static void __init
625davinci_evm_map_io(void) 733davinci_evm_map_io(void)
626{ 734{
627 /* setup input configuration for VPFE input devices */
628 dm644x_set_vpfe_config(&vpfe_cfg);
629 dm644x_init(); 735 dm644x_init();
630} 736}
631 737
@@ -697,6 +803,7 @@ static __init void davinci_evm_init(void)
697 evm_init_i2c(); 803 evm_init_i2c();
698 804
699 davinci_setup_mmc(0, &dm6446evm_mmc_config); 805 davinci_setup_mmc(0, &dm6446evm_mmc_config);
806 dm644x_init_video(&dm644xevm_capture_cfg, &dm644xevm_display_cfg);
700 807
701 davinci_serial_init(&uart_config); 808 davinci_serial_init(&uart_config);
702 dm644x_init_asp(&dm644x_evm_snd_data); 809 dm644x_init_asp(&dm644x_evm_snd_data);
diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c b/arch/arm/mach-davinci/board-dm646x-evm.c
index 872ac69fa04..d72ab948d63 100644
--- a/arch/arm/mach-davinci/board-dm646x-evm.c
+++ b/arch/arm/mach-davinci/board-dm646x-evm.c
@@ -36,7 +36,6 @@
36#include <asm/mach-types.h> 36#include <asm/mach-types.h>
37#include <asm/mach/arch.h> 37#include <asm/mach/arch.h>
38 38
39#include <mach/dm646x.h>
40#include <mach/common.h> 39#include <mach/common.h>
41#include <mach/serial.h> 40#include <mach/serial.h>
42#include <mach/i2c.h> 41#include <mach/i2c.h>
@@ -45,6 +44,7 @@
45#include <mach/cdce949.h> 44#include <mach/cdce949.h>
46#include <mach/aemif.h> 45#include <mach/aemif.h>
47 46
47#include "davinci.h"
48#include "clock.h" 48#include "clock.h"
49 49
50#define NAND_BLOCK_SIZE SZ_128K 50#define NAND_BLOCK_SIZE SZ_128K
@@ -410,8 +410,6 @@ static struct davinci_i2c_platform_data i2c_pdata = {
410 .bus_delay = 0 /* usec */, 410 .bus_delay = 0 /* usec */,
411}; 411};
412 412
413#define VIDCLKCTL_OFFSET (DAVINCI_SYSTEM_MODULE_BASE + 0x38)
414#define VSCLKDIS_OFFSET (DAVINCI_SYSTEM_MODULE_BASE + 0x6c)
415#define VCH2CLK_MASK (BIT_MASK(10) | BIT_MASK(9) | BIT_MASK(8)) 413#define VCH2CLK_MASK (BIT_MASK(10) | BIT_MASK(9) | BIT_MASK(8))
416#define VCH2CLK_SYSCLK8 (BIT(9)) 414#define VCH2CLK_SYSCLK8 (BIT(9))
417#define VCH2CLK_AUXCLK (BIT(9) | BIT(8)) 415#define VCH2CLK_AUXCLK (BIT(9) | BIT(8))
@@ -429,8 +427,6 @@ static struct davinci_i2c_platform_data i2c_pdata = {
429#define TVP5147_CH0 "tvp514x-0" 427#define TVP5147_CH0 "tvp514x-0"
430#define TVP5147_CH1 "tvp514x-1" 428#define TVP5147_CH1 "tvp514x-1"
431 429
432static void __iomem *vpif_vidclkctl_reg;
433static void __iomem *vpif_vsclkdis_reg;
434/* spin lock for updating above registers */ 430/* spin lock for updating above registers */
435static spinlock_t vpif_reg_lock; 431static spinlock_t vpif_reg_lock;
436 432
@@ -441,14 +437,14 @@ static int set_vpif_clock(int mux_mode, int hd)
441 int val = 0; 437 int val = 0;
442 int err = 0; 438 int err = 0;
443 439
444 if (!vpif_vidclkctl_reg || !vpif_vsclkdis_reg || !cpld_client) 440 if (!cpld_client)
445 return -ENXIO; 441 return -ENXIO;
446 442
447 /* disable the clock */ 443 /* disable the clock */
448 spin_lock_irqsave(&vpif_reg_lock, flags); 444 spin_lock_irqsave(&vpif_reg_lock, flags);
449 value = __raw_readl(vpif_vsclkdis_reg); 445 value = __raw_readl(DAVINCI_SYSMOD_VIRT(SYSMOD_VSCLKDIS));
450 value |= (VIDCH3CLK | VIDCH2CLK); 446 value |= (VIDCH3CLK | VIDCH2CLK);
451 __raw_writel(value, vpif_vsclkdis_reg); 447 __raw_writel(value, DAVINCI_SYSMOD_VIRT(SYSMOD_VSCLKDIS));
452 spin_unlock_irqrestore(&vpif_reg_lock, flags); 448 spin_unlock_irqrestore(&vpif_reg_lock, flags);
453 449
454 val = i2c_smbus_read_byte(cpld_client); 450 val = i2c_smbus_read_byte(cpld_client);
@@ -464,7 +460,7 @@ static int set_vpif_clock(int mux_mode, int hd)
464 if (err) 460 if (err)
465 return err; 461 return err;
466 462
467 value = __raw_readl(vpif_vidclkctl_reg); 463 value = __raw_readl(DAVINCI_SYSMOD_VIRT(SYSMOD_VIDCLKCTL));
468 value &= ~(VCH2CLK_MASK); 464 value &= ~(VCH2CLK_MASK);
469 value &= ~(VCH3CLK_MASK); 465 value &= ~(VCH3CLK_MASK);
470 466
@@ -473,13 +469,13 @@ static int set_vpif_clock(int mux_mode, int hd)
473 else 469 else
474 value |= (VCH2CLK_AUXCLK | VCH3CLK_AUXCLK); 470 value |= (VCH2CLK_AUXCLK | VCH3CLK_AUXCLK);
475 471
476 __raw_writel(value, vpif_vidclkctl_reg); 472 __raw_writel(value, DAVINCI_SYSMOD_VIRT(SYSMOD_VIDCLKCTL));
477 473
478 spin_lock_irqsave(&vpif_reg_lock, flags); 474 spin_lock_irqsave(&vpif_reg_lock, flags);
479 value = __raw_readl(vpif_vsclkdis_reg); 475 value = __raw_readl(DAVINCI_SYSMOD_VIRT(SYSMOD_VSCLKDIS));
480 /* enable the clock */ 476 /* enable the clock */
481 value &= ~(VIDCH3CLK | VIDCH2CLK); 477 value &= ~(VIDCH3CLK | VIDCH2CLK);
482 __raw_writel(value, vpif_vsclkdis_reg); 478 __raw_writel(value, DAVINCI_SYSMOD_VIRT(SYSMOD_VSCLKDIS));
483 spin_unlock_irqrestore(&vpif_reg_lock, flags); 479 spin_unlock_irqrestore(&vpif_reg_lock, flags);
484 480
485 return 0; 481 return 0;
@@ -564,7 +560,7 @@ static int setup_vpif_input_channel_mode(int mux_mode)
564 int val; 560 int val;
565 u32 value; 561 u32 value;
566 562
567 if (!vpif_vidclkctl_reg || !cpld_client) 563 if (!cpld_client)
568 return -ENXIO; 564 return -ENXIO;
569 565
570 val = i2c_smbus_read_byte(cpld_client); 566 val = i2c_smbus_read_byte(cpld_client);
@@ -572,7 +568,7 @@ static int setup_vpif_input_channel_mode(int mux_mode)
572 return val; 568 return val;
573 569
574 spin_lock_irqsave(&vpif_reg_lock, flags); 570 spin_lock_irqsave(&vpif_reg_lock, flags);
575 value = __raw_readl(vpif_vidclkctl_reg); 571 value = __raw_readl(DAVINCI_SYSMOD_VIRT(SYSMOD_VIDCLKCTL));
576 if (mux_mode) { 572 if (mux_mode) {
577 val &= VPIF_INPUT_TWO_CHANNEL; 573 val &= VPIF_INPUT_TWO_CHANNEL;
578 value |= VIDCH1CLK; 574 value |= VIDCH1CLK;
@@ -580,7 +576,7 @@ static int setup_vpif_input_channel_mode(int mux_mode)
580 val |= VPIF_INPUT_ONE_CHANNEL; 576 val |= VPIF_INPUT_ONE_CHANNEL;
581 value &= ~VIDCH1CLK; 577 value &= ~VIDCH1CLK;
582 } 578 }
583 __raw_writel(value, vpif_vidclkctl_reg); 579 __raw_writel(value, DAVINCI_SYSMOD_VIRT(SYSMOD_VIDCLKCTL));
584 spin_unlock_irqrestore(&vpif_reg_lock, flags); 580 spin_unlock_irqrestore(&vpif_reg_lock, flags);
585 581
586 err = i2c_smbus_write_byte(cpld_client, val); 582 err = i2c_smbus_write_byte(cpld_client, val);
@@ -674,12 +670,6 @@ static struct vpif_capture_config dm646x_vpif_capture_cfg = {
674 670
675static void __init evm_init_video(void) 671static void __init evm_init_video(void)
676{ 672{
677 vpif_vidclkctl_reg = ioremap(VIDCLKCTL_OFFSET, 4);
678 vpif_vsclkdis_reg = ioremap(VSCLKDIS_OFFSET, 4);
679 if (!vpif_vidclkctl_reg || !vpif_vsclkdis_reg) {
680 pr_err("Can't map VPIF VIDCLKCTL or VSCLKDIS registers\n");
681 return;
682 }
683 spin_lock_init(&vpif_reg_lock); 673 spin_lock_init(&vpif_reg_lock);
684 674
685 dm646x_setup_vpif(&dm646x_vpif_display_config, 675 dm646x_setup_vpif(&dm646x_vpif_display_config,
diff --git a/arch/arm/mach-davinci/board-neuros-osd2.c b/arch/arm/mach-davinci/board-neuros-osd2.c
index 8d34f513d41..a772bb45570 100644
--- a/arch/arm/mach-davinci/board-neuros-osd2.c
+++ b/arch/arm/mach-davinci/board-neuros-osd2.c
@@ -30,7 +30,6 @@
30#include <asm/mach-types.h> 30#include <asm/mach-types.h>
31#include <asm/mach/arch.h> 31#include <asm/mach/arch.h>
32 32
33#include <mach/dm644x.h>
34#include <mach/common.h> 33#include <mach/common.h>
35#include <mach/i2c.h> 34#include <mach/i2c.h>
36#include <mach/serial.h> 35#include <mach/serial.h>
@@ -39,6 +38,8 @@
39#include <mach/mmc.h> 38#include <mach/mmc.h>
40#include <mach/usb.h> 39#include <mach/usb.h>
41 40
41#include "davinci.h"
42
42#define NEUROS_OSD2_PHY_ID "davinci_mdio-0:01" 43#define NEUROS_OSD2_PHY_ID "davinci_mdio-0:01"
43#define LXT971_PHY_ID 0x001378e2 44#define LXT971_PHY_ID 0x001378e2
44#define LXT971_PHY_MASK 0xfffffff0 45#define LXT971_PHY_MASK 0xfffffff0
diff --git a/arch/arm/mach-davinci/board-sffsdr.c b/arch/arm/mach-davinci/board-sffsdr.c
index 31da3c5b2ba..76e67509610 100644
--- a/arch/arm/mach-davinci/board-sffsdr.c
+++ b/arch/arm/mach-davinci/board-sffsdr.c
@@ -35,13 +35,14 @@
35#include <asm/mach/arch.h> 35#include <asm/mach/arch.h>
36#include <asm/mach/flash.h> 36#include <asm/mach/flash.h>
37 37
38#include <mach/dm644x.h>
39#include <mach/common.h> 38#include <mach/common.h>
40#include <mach/i2c.h> 39#include <mach/i2c.h>
41#include <mach/serial.h> 40#include <mach/serial.h>
42#include <mach/mux.h> 41#include <mach/mux.h>
43#include <mach/usb.h> 42#include <mach/usb.h>
44 43
44#include "davinci.h"
45
45#define SFFSDR_PHY_ID "davinci_mdio-0:01" 46#define SFFSDR_PHY_ID "davinci_mdio-0:01"
46static struct mtd_partition davinci_sffsdr_nandflash_partition[] = { 47static struct mtd_partition davinci_sffsdr_nandflash_partition[] = {
47 /* U-Boot Environment: Block 0 48 /* U-Boot Environment: Block 0
diff --git a/arch/arm/mach-davinci/cpufreq.c b/arch/arm/mach-davinci/cpufreq.c
index 5bba7070f27..031048fec9f 100644
--- a/arch/arm/mach-davinci/cpufreq.c
+++ b/arch/arm/mach-davinci/cpufreq.c
@@ -95,7 +95,7 @@ static int davinci_target(struct cpufreq_policy *policy,
95 if (freqs.old == freqs.new) 95 if (freqs.old == freqs.new)
96 return ret; 96 return ret;
97 97
98 dev_dbg(&cpufreq.dev, "transition: %u --> %u\n", freqs.old, freqs.new); 98 dev_dbg(cpufreq.dev, "transition: %u --> %u\n", freqs.old, freqs.new);
99 99
100 ret = cpufreq_frequency_table_target(policy, pdata->freq_table, 100 ret = cpufreq_frequency_table_target(policy, pdata->freq_table,
101 freqs.new, relation, &idx); 101 freqs.new, relation, &idx);
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
index 992c4c41018..b44dc844e15 100644
--- a/arch/arm/mach-davinci/da850.c
+++ b/arch/arm/mach-davinci/da850.c
@@ -1026,7 +1026,7 @@ static int da850_round_armrate(struct clk *clk, unsigned long rate)
1026} 1026}
1027#endif 1027#endif
1028 1028
1029int da850_register_pm(struct platform_device *pdev) 1029int __init da850_register_pm(struct platform_device *pdev)
1030{ 1030{
1031 int ret; 1031 int ret;
1032 struct davinci_pm_config *pdata = pdev->dev.platform_data; 1032 struct davinci_pm_config *pdata = pdev->dev.platform_data;
diff --git a/arch/arm/mach-davinci/davinci.h b/arch/arm/mach-davinci/davinci.h
new file mode 100644
index 00000000000..3e519dad5bb
--- /dev/null
+++ b/arch/arm/mach-davinci/davinci.h
@@ -0,0 +1,102 @@
1/*
2 * This file contains the processor specific definitions
3 * of the TI DM644x, DM355, DM365, and DM646x.
4 *
5 * Copyright (C) 2011 Texas Instruments Incorporated
6 * Copyright (c) 2007 Deep Root Systems, LLC
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation version 2.
11 *
12 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
13 * kind, whether express or implied; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 */
17#ifndef __DAVINCI_H
18#define __DAVINCI_H
19
20#include <linux/clk.h>
21#include <linux/videodev2.h>
22#include <linux/davinci_emac.h>
23#include <linux/platform_device.h>
24#include <linux/spi/spi.h>
25
26#include <mach/asp.h>
27#include <mach/keyscan.h>
28#include <mach/hardware.h>
29
30#include <media/davinci/vpfe_capture.h>
31#include <media/davinci/vpif_types.h>
32#include <media/davinci/vpss.h>
33#include <media/davinci/vpbe_types.h>
34#include <media/davinci/vpbe_venc.h>
35#include <media/davinci/vpbe.h>
36#include <media/davinci/vpbe_osd.h>
37
38#define DAVINCI_SYSTEM_MODULE_BASE 0x01c40000
39#define SYSMOD_VIDCLKCTL 0x38
40#define SYSMOD_VPSS_CLKCTL 0x44
41#define SYSMOD_VDD3P3VPWDN 0x48
42#define SYSMOD_VSCLKDIS 0x6c
43#define SYSMOD_PUPDCTL1 0x7c
44
45extern void __iomem *davinci_sysmod_base;
46#define DAVINCI_SYSMOD_VIRT(x) (davinci_sysmod_base + (x))
47void davinci_map_sysmod(void);
48
49/* DM355 base addresses */
50#define DM355_ASYNC_EMIF_CONTROL_BASE 0x01e10000
51#define DM355_ASYNC_EMIF_DATA_CE0_BASE 0x02000000
52
53#define ASP1_TX_EVT_EN 1
54#define ASP1_RX_EVT_EN 2
55
56/* DM365 base addresses */
57#define DM365_ASYNC_EMIF_CONTROL_BASE 0x01d10000
58#define DM365_ASYNC_EMIF_DATA_CE0_BASE 0x02000000
59#define DM365_ASYNC_EMIF_DATA_CE1_BASE 0x04000000
60
61/* DM644x base addresses */
62#define DM644X_ASYNC_EMIF_CONTROL_BASE 0x01e00000
63#define DM644X_ASYNC_EMIF_DATA_CE0_BASE 0x02000000
64#define DM644X_ASYNC_EMIF_DATA_CE1_BASE 0x04000000
65#define DM644X_ASYNC_EMIF_DATA_CE2_BASE 0x06000000
66#define DM644X_ASYNC_EMIF_DATA_CE3_BASE 0x08000000
67
68/* DM646x base addresses */
69#define DM646X_ASYNC_EMIF_CONTROL_BASE 0x20008000
70#define DM646X_ASYNC_EMIF_CS2_SPACE_BASE 0x42000000
71
72/* DM355 function declarations */
73void __init dm355_init(void);
74void dm355_init_spi0(unsigned chipselect_mask,
75 struct spi_board_info *info, unsigned len);
76void __init dm355_init_asp1(u32 evt_enable, struct snd_platform_data *pdata);
77void dm355_set_vpfe_config(struct vpfe_config *cfg);
78
79/* DM365 function declarations */
80void __init dm365_init(void);
81void __init dm365_init_asp(struct snd_platform_data *pdata);
82void __init dm365_init_vc(struct snd_platform_data *pdata);
83void __init dm365_init_ks(struct davinci_ks_platform_data *pdata);
84void __init dm365_init_rtc(void);
85void dm365_init_spi0(unsigned chipselect_mask,
86 struct spi_board_info *info, unsigned len);
87void dm365_set_vpfe_config(struct vpfe_config *cfg);
88
89/* DM644x function declarations */
90void __init dm644x_init(void);
91void __init dm644x_init_asp(struct snd_platform_data *pdata);
92int __init dm644x_init_video(struct vpfe_config *, struct vpbe_config *);
93
94/* DM646x function declarations */
95void __init dm646x_init(void);
96void __init dm646x_init_mcasp0(struct snd_platform_data *pdata);
97void __init dm646x_init_mcasp1(struct snd_platform_data *pdata);
98int __init dm646x_init_edma(struct edma_rsv_info *rsv);
99void dm646x_video_init(void);
100void dm646x_setup_vpif(struct vpif_display_config *,
101 struct vpif_capture_config *);
102#endif /*__DAVINCI_H */
diff --git a/arch/arm/mach-davinci/devices.c b/arch/arm/mach-davinci/devices.c
index 50c0156b426..d2f9666284a 100644
--- a/arch/arm/mach-davinci/devices.c
+++ b/arch/arm/mach-davinci/devices.c
@@ -23,6 +23,7 @@
23#include <mach/mmc.h> 23#include <mach/mmc.h>
24#include <mach/time.h> 24#include <mach/time.h>
25 25
26#include "davinci.h"
26#include "clock.h" 27#include "clock.h"
27 28
28#define DAVINCI_I2C_BASE 0x01C21000 29#define DAVINCI_I2C_BASE 0x01C21000
@@ -33,8 +34,19 @@
33#define DM365_MMCSD0_BASE 0x01D11000 34#define DM365_MMCSD0_BASE 0x01D11000
34#define DM365_MMCSD1_BASE 0x01D00000 35#define DM365_MMCSD1_BASE 0x01D00000
35 36
36/* System control register offsets */ 37void __iomem *davinci_sysmod_base;
37#define DM64XX_VDD3P3V_PWDN 0x48 38
39void davinci_map_sysmod(void)
40{
41 davinci_sysmod_base = ioremap_nocache(DAVINCI_SYSTEM_MODULE_BASE,
42 0x800);
43 /*
44 * Throw a bug since a lot of board initialization code depends
45 * on system module availability. ioremap() failing this early
46 * need careful looking into anyway.
47 */
48 BUG_ON(!davinci_sysmod_base);
49}
38 50
39static struct resource i2c_resources[] = { 51static struct resource i2c_resources[] = {
40 { 52 {
@@ -212,12 +224,12 @@ void __init davinci_setup_mmc(int module, struct davinci_mmc_config *config)
212 davinci_cfg_reg(DM355_SD1_DATA2); 224 davinci_cfg_reg(DM355_SD1_DATA2);
213 davinci_cfg_reg(DM355_SD1_DATA3); 225 davinci_cfg_reg(DM355_SD1_DATA3);
214 } else if (cpu_is_davinci_dm365()) { 226 } else if (cpu_is_davinci_dm365()) {
215 void __iomem *pupdctl1 =
216 IO_ADDRESS(DAVINCI_SYSTEM_MODULE_BASE + 0x7c);
217
218 /* Configure pull down control */ 227 /* Configure pull down control */
219 __raw_writel((__raw_readl(pupdctl1) & ~0xfc0), 228 unsigned v;
220 pupdctl1); 229
230 v = __raw_readl(DAVINCI_SYSMOD_VIRT(SYSMOD_PUPDCTL1));
231 __raw_writel(v & ~0xfc0,
232 DAVINCI_SYSMOD_VIRT(SYSMOD_PUPDCTL1));
221 233
222 mmcsd1_resources[0].start = DM365_MMCSD1_BASE; 234 mmcsd1_resources[0].start = DM365_MMCSD1_BASE;
223 mmcsd1_resources[0].end = DM365_MMCSD1_BASE + 235 mmcsd1_resources[0].end = DM365_MMCSD1_BASE +
@@ -246,11 +258,9 @@ void __init davinci_setup_mmc(int module, struct davinci_mmc_config *config)
246 mmcsd0_resources[2].start = IRQ_DM365_SDIOINT0; 258 mmcsd0_resources[2].start = IRQ_DM365_SDIOINT0;
247 } else if (cpu_is_davinci_dm644x()) { 259 } else if (cpu_is_davinci_dm644x()) {
248 /* REVISIT: should this be in board-init code? */ 260 /* REVISIT: should this be in board-init code? */
249 void __iomem *base =
250 IO_ADDRESS(DAVINCI_SYSTEM_MODULE_BASE);
251
252 /* Power-on 3.3V IO cells */ 261 /* Power-on 3.3V IO cells */
253 __raw_writel(0, base + DM64XX_VDD3P3V_PWDN); 262 __raw_writel(0,
263 DAVINCI_SYSMOD_VIRT(SYSMOD_VDD3P3VPWDN));
254 /*Set up the pull regiter for MMC */ 264 /*Set up the pull regiter for MMC */
255 davinci_cfg_reg(DM644X_MSTK); 265 davinci_cfg_reg(DM644X_MSTK);
256 } 266 }
diff --git a/arch/arm/mach-davinci/dm355.c b/arch/arm/mach-davinci/dm355.c
index 19667cfc5de..fd3d09aa6cd 100644
--- a/arch/arm/mach-davinci/dm355.c
+++ b/arch/arm/mach-davinci/dm355.c
@@ -18,7 +18,6 @@
18 18
19#include <asm/mach/map.h> 19#include <asm/mach/map.h>
20 20
21#include <mach/dm355.h>
22#include <mach/cputype.h> 21#include <mach/cputype.h>
23#include <mach/edma.h> 22#include <mach/edma.h>
24#include <mach/psc.h> 23#include <mach/psc.h>
@@ -31,6 +30,7 @@
31#include <mach/spi.h> 30#include <mach/spi.h>
32#include <mach/gpio-davinci.h> 31#include <mach/gpio-davinci.h>
33 32
33#include "davinci.h"
34#include "clock.h" 34#include "clock.h"
35#include "mux.h" 35#include "mux.h"
36 36
@@ -871,6 +871,7 @@ void __init dm355_init_asp1(u32 evt_enable, struct snd_platform_data *pdata)
871void __init dm355_init(void) 871void __init dm355_init(void)
872{ 872{
873 davinci_common_init(&davinci_soc_info_dm355); 873 davinci_common_init(&davinci_soc_info_dm355);
874 davinci_map_sysmod();
874} 875}
875 876
876static int __init dm355_init_devices(void) 877static int __init dm355_init_devices(void)
diff --git a/arch/arm/mach-davinci/dm365.c b/arch/arm/mach-davinci/dm365.c
index f15b435cc65..1a2e953082b 100644
--- a/arch/arm/mach-davinci/dm365.c
+++ b/arch/arm/mach-davinci/dm365.c
@@ -21,7 +21,6 @@
21 21
22#include <asm/mach/map.h> 22#include <asm/mach/map.h>
23 23
24#include <mach/dm365.h>
25#include <mach/cputype.h> 24#include <mach/cputype.h>
26#include <mach/edma.h> 25#include <mach/edma.h>
27#include <mach/psc.h> 26#include <mach/psc.h>
@@ -35,11 +34,28 @@
35#include <mach/spi.h> 34#include <mach/spi.h>
36#include <mach/gpio-davinci.h> 35#include <mach/gpio-davinci.h>
37 36
37#include "davinci.h"
38#include "clock.h" 38#include "clock.h"
39#include "mux.h" 39#include "mux.h"
40 40
41#define DM365_REF_FREQ 24000000 /* 24 MHz on the DM365 EVM */ 41#define DM365_REF_FREQ 24000000 /* 24 MHz on the DM365 EVM */
42 42
43/* Base of key scan register bank */
44#define DM365_KEYSCAN_BASE 0x01c69400
45
46#define DM365_RTC_BASE 0x01c69000
47
48#define DAVINCI_DM365_VC_BASE 0x01d0c000
49#define DAVINCI_DMA_VC_TX 2
50#define DAVINCI_DMA_VC_RX 3
51
52#define DM365_EMAC_BASE 0x01d07000
53#define DM365_EMAC_MDIO_BASE (DM365_EMAC_BASE + 0x4000)
54#define DM365_EMAC_CNTRL_OFFSET 0x0000
55#define DM365_EMAC_CNTRL_MOD_OFFSET 0x3000
56#define DM365_EMAC_CNTRL_RAM_OFFSET 0x1000
57#define DM365_EMAC_CNTRL_RAM_SIZE 0x2000
58
43static struct pll_data pll1_data = { 59static struct pll_data pll1_data = {
44 .num = 1, 60 .num = 1,
45 .phys_base = DAVINCI_PLL1_BASE, 61 .phys_base = DAVINCI_PLL1_BASE,
@@ -1122,6 +1138,7 @@ void __init dm365_init_rtc(void)
1122void __init dm365_init(void) 1138void __init dm365_init(void)
1123{ 1139{
1124 davinci_common_init(&davinci_soc_info_dm365); 1140 davinci_common_init(&davinci_soc_info_dm365);
1141 davinci_map_sysmod();
1125} 1142}
1126 1143
1127static struct resource dm365_vpss_resources[] = { 1144static struct resource dm365_vpss_resources[] = {
diff --git a/arch/arm/mach-davinci/dm644x.c b/arch/arm/mach-davinci/dm644x.c
index 43a48ee1917..c8b866657fc 100644
--- a/arch/arm/mach-davinci/dm644x.c
+++ b/arch/arm/mach-davinci/dm644x.c
@@ -15,7 +15,6 @@
15 15
16#include <asm/mach/map.h> 16#include <asm/mach/map.h>
17 17
18#include <mach/dm644x.h>
19#include <mach/cputype.h> 18#include <mach/cputype.h>
20#include <mach/edma.h> 19#include <mach/edma.h>
21#include <mach/irqs.h> 20#include <mach/irqs.h>
@@ -27,6 +26,7 @@
27#include <mach/asp.h> 26#include <mach/asp.h>
28#include <mach/gpio-davinci.h> 27#include <mach/gpio-davinci.h>
29 28
29#include "davinci.h"
30#include "clock.h" 30#include "clock.h"
31#include "mux.h" 31#include "mux.h"
32 32
@@ -35,6 +35,13 @@
35 */ 35 */
36#define DM644X_REF_FREQ 27000000 36#define DM644X_REF_FREQ 27000000
37 37
38#define DM644X_EMAC_BASE 0x01c80000
39#define DM644X_EMAC_MDIO_BASE (DM644X_EMAC_BASE + 0x4000)
40#define DM644X_EMAC_CNTRL_OFFSET 0x0000
41#define DM644X_EMAC_CNTRL_MOD_OFFSET 0x1000
42#define DM644X_EMAC_CNTRL_RAM_OFFSET 0x2000
43#define DM644X_EMAC_CNTRL_RAM_SIZE 0x2000
44
38static struct pll_data pll1_data = { 45static struct pll_data pll1_data = {
39 .num = 1, 46 .num = 1,
40 .phys_base = DAVINCI_PLL1_BASE, 47 .phys_base = DAVINCI_PLL1_BASE,
@@ -587,13 +594,15 @@ static struct platform_device dm644x_asp_device = {
587 .resource = dm644x_asp_resources, 594 .resource = dm644x_asp_resources,
588}; 595};
589 596
597#define DM644X_VPSS_BASE 0x01c73400
598
590static struct resource dm644x_vpss_resources[] = { 599static struct resource dm644x_vpss_resources[] = {
591 { 600 {
592 /* VPSS Base address */ 601 /* VPSS Base address */
593 .name = "vpss", 602 .name = "vpss",
594 .start = 0x01c73400, 603 .start = DM644X_VPSS_BASE,
595 .end = 0x01c73400 + 0xff, 604 .end = DM644X_VPSS_BASE + 0xff,
596 .flags = IORESOURCE_MEM, 605 .flags = IORESOURCE_MEM,
597 }, 606 },
598}; 607};
599 608
@@ -605,7 +614,7 @@ static struct platform_device dm644x_vpss_device = {
605 .resource = dm644x_vpss_resources, 614 .resource = dm644x_vpss_resources,
606}; 615};
607 616
608static struct resource vpfe_resources[] = { 617static struct resource dm644x_vpfe_resources[] = {
609 { 618 {
610 .start = IRQ_VDINT0, 619 .start = IRQ_VDINT0,
611 .end = IRQ_VDINT0, 620 .end = IRQ_VDINT0,
@@ -618,7 +627,7 @@ static struct resource vpfe_resources[] = {
618 }, 627 },
619}; 628};
620 629
621static u64 vpfe_capture_dma_mask = DMA_BIT_MASK(32); 630static u64 dm644x_video_dma_mask = DMA_BIT_MASK(32);
622static struct resource dm644x_ccdc_resource[] = { 631static struct resource dm644x_ccdc_resource[] = {
623 /* CCDC Base address */ 632 /* CCDC Base address */
624 { 633 {
@@ -634,27 +643,149 @@ static struct platform_device dm644x_ccdc_dev = {
634 .num_resources = ARRAY_SIZE(dm644x_ccdc_resource), 643 .num_resources = ARRAY_SIZE(dm644x_ccdc_resource),
635 .resource = dm644x_ccdc_resource, 644 .resource = dm644x_ccdc_resource,
636 .dev = { 645 .dev = {
637 .dma_mask = &vpfe_capture_dma_mask, 646 .dma_mask = &dm644x_video_dma_mask,
638 .coherent_dma_mask = DMA_BIT_MASK(32), 647 .coherent_dma_mask = DMA_BIT_MASK(32),
639 }, 648 },
640}; 649};
641 650
642static struct platform_device vpfe_capture_dev = { 651static struct platform_device dm644x_vpfe_dev = {
643 .name = CAPTURE_DRV_NAME, 652 .name = CAPTURE_DRV_NAME,
644 .id = -1, 653 .id = -1,
645 .num_resources = ARRAY_SIZE(vpfe_resources), 654 .num_resources = ARRAY_SIZE(dm644x_vpfe_resources),
646 .resource = vpfe_resources, 655 .resource = dm644x_vpfe_resources,
647 .dev = { 656 .dev = {
648 .dma_mask = &vpfe_capture_dma_mask, 657 .dma_mask = &dm644x_video_dma_mask,
658 .coherent_dma_mask = DMA_BIT_MASK(32),
659 },
660};
661
662#define DM644X_OSD_BASE 0x01c72600
663
664static struct resource dm644x_osd_resources[] = {
665 {
666 .start = DM644X_OSD_BASE,
667 .end = DM644X_OSD_BASE + 0x1ff,
668 .flags = IORESOURCE_MEM,
669 },
670};
671
672static struct osd_platform_data dm644x_osd_data = {
673 .vpbe_type = VPBE_VERSION_1,
674};
675
676static struct platform_device dm644x_osd_dev = {
677 .name = VPBE_OSD_SUBDEV_NAME,
678 .id = -1,
679 .num_resources = ARRAY_SIZE(dm644x_osd_resources),
680 .resource = dm644x_osd_resources,
681 .dev = {
682 .dma_mask = &dm644x_video_dma_mask,
649 .coherent_dma_mask = DMA_BIT_MASK(32), 683 .coherent_dma_mask = DMA_BIT_MASK(32),
684 .platform_data = &dm644x_osd_data,
650 }, 685 },
651}; 686};
652 687
653void dm644x_set_vpfe_config(struct vpfe_config *cfg) 688#define DM644X_VENC_BASE 0x01c72400
689
690static struct resource dm644x_venc_resources[] = {
691 {
692 .start = DM644X_VENC_BASE,
693 .end = DM644X_VENC_BASE + 0x17f,
694 .flags = IORESOURCE_MEM,
695 },
696};
697
698#define DM644X_VPSS_MUXSEL_PLL2_MODE BIT(0)
699#define DM644X_VPSS_MUXSEL_VPBECLK_MODE BIT(1)
700#define DM644X_VPSS_VENCLKEN BIT(3)
701#define DM644X_VPSS_DACCLKEN BIT(4)
702
703static int dm644x_venc_setup_clock(enum vpbe_enc_timings_type type,
704 unsigned int mode)
654{ 705{
655 vpfe_capture_dev.dev.platform_data = cfg; 706 int ret = 0;
707 u32 v = DM644X_VPSS_VENCLKEN;
708
709 switch (type) {
710 case VPBE_ENC_STD:
711 v |= DM644X_VPSS_DACCLKEN;
712 writel(v, DAVINCI_SYSMOD_VIRT(SYSMOD_VPSS_CLKCTL));
713 break;
714 case VPBE_ENC_DV_PRESET:
715 switch (mode) {
716 case V4L2_DV_480P59_94:
717 case V4L2_DV_576P50:
718 v |= DM644X_VPSS_MUXSEL_PLL2_MODE |
719 DM644X_VPSS_DACCLKEN;
720 writel(v, DAVINCI_SYSMOD_VIRT(SYSMOD_VPSS_CLKCTL));
721 break;
722 case V4L2_DV_720P60:
723 case V4L2_DV_1080I60:
724 case V4L2_DV_1080P30:
725 /*
726 * For HD, use external clock source since
727 * HD requires higher clock rate
728 */
729 v |= DM644X_VPSS_MUXSEL_VPBECLK_MODE;
730 writel(v, DAVINCI_SYSMOD_VIRT(SYSMOD_VPSS_CLKCTL));
731 break;
732 default:
733 ret = -EINVAL;
734 break;
735 }
736 break;
737 default:
738 ret = -EINVAL;
739 }
740
741 return ret;
656} 742}
657 743
744static struct resource dm644x_v4l2_disp_resources[] = {
745 {
746 .start = IRQ_VENCINT,
747 .end = IRQ_VENCINT,
748 .flags = IORESOURCE_IRQ,
749 },
750};
751
752static struct platform_device dm644x_vpbe_display = {
753 .name = "vpbe-v4l2",
754 .id = -1,
755 .num_resources = ARRAY_SIZE(dm644x_v4l2_disp_resources),
756 .resource = dm644x_v4l2_disp_resources,
757 .dev = {
758 .dma_mask = &dm644x_video_dma_mask,
759 .coherent_dma_mask = DMA_BIT_MASK(32),
760 },
761};
762
763static struct venc_platform_data dm644x_venc_pdata = {
764 .venc_type = VPBE_VERSION_1,
765 .setup_clock = dm644x_venc_setup_clock,
766};
767
768static struct platform_device dm644x_venc_dev = {
769 .name = VPBE_VENC_SUBDEV_NAME,
770 .id = -1,
771 .num_resources = ARRAY_SIZE(dm644x_venc_resources),
772 .resource = dm644x_venc_resources,
773 .dev = {
774 .dma_mask = &dm644x_video_dma_mask,
775 .coherent_dma_mask = DMA_BIT_MASK(32),
776 .platform_data = &dm644x_venc_pdata,
777 },
778};
779
780static struct platform_device dm644x_vpbe_dev = {
781 .name = "vpbe_controller",
782 .id = -1,
783 .dev = {
784 .dma_mask = &dm644x_video_dma_mask,
785 .coherent_dma_mask = DMA_BIT_MASK(32),
786 },
787};
788
658/*----------------------------------------------------------------------*/ 789/*----------------------------------------------------------------------*/
659 790
660static struct map_desc dm644x_io_desc[] = { 791static struct map_desc dm644x_io_desc[] = {
@@ -779,6 +910,35 @@ void __init dm644x_init_asp(struct snd_platform_data *pdata)
779void __init dm644x_init(void) 910void __init dm644x_init(void)
780{ 911{
781 davinci_common_init(&davinci_soc_info_dm644x); 912 davinci_common_init(&davinci_soc_info_dm644x);
913 davinci_map_sysmod();
914}
915
916int __init dm644x_init_video(struct vpfe_config *vpfe_cfg,
917 struct vpbe_config *vpbe_cfg)
918{
919 if (vpfe_cfg || vpbe_cfg)
920 platform_device_register(&dm644x_vpss_device);
921
922 if (vpfe_cfg) {
923 dm644x_vpfe_dev.dev.platform_data = vpfe_cfg;
924 platform_device_register(&dm644x_ccdc_dev);
925 platform_device_register(&dm644x_vpfe_dev);
926 /* Add ccdc clock aliases */
927 clk_add_alias("master", dm644x_ccdc_dev.name,
928 "vpss_master", NULL);
929 clk_add_alias("slave", dm644x_ccdc_dev.name,
930 "vpss_slave", NULL);
931 }
932
933 if (vpbe_cfg) {
934 dm644x_vpbe_dev.dev.platform_data = vpbe_cfg;
935 platform_device_register(&dm644x_osd_dev);
936 platform_device_register(&dm644x_venc_dev);
937 platform_device_register(&dm644x_vpbe_dev);
938 platform_device_register(&dm644x_vpbe_display);
939 }
940
941 return 0;
782} 942}
783 943
784static int __init dm644x_init_devices(void) 944static int __init dm644x_init_devices(void)
@@ -786,9 +946,6 @@ static int __init dm644x_init_devices(void)
786 if (!cpu_is_davinci_dm644x()) 946 if (!cpu_is_davinci_dm644x())
787 return 0; 947 return 0;
788 948
789 /* Add ccdc clock aliases */
790 clk_add_alias("master", dm644x_ccdc_dev.name, "vpss_master", NULL);
791 clk_add_alias("slave", dm644x_ccdc_dev.name, "vpss_slave", NULL);
792 platform_device_register(&dm644x_edma_device); 949 platform_device_register(&dm644x_edma_device);
793 950
794 platform_device_register(&dm644x_mdio_device); 951 platform_device_register(&dm644x_mdio_device);
@@ -796,10 +953,6 @@ static int __init dm644x_init_devices(void)
796 clk_add_alias(NULL, dev_name(&dm644x_mdio_device.dev), 953 clk_add_alias(NULL, dev_name(&dm644x_mdio_device.dev),
797 NULL, &dm644x_emac_device.dev); 954 NULL, &dm644x_emac_device.dev);
798 955
799 platform_device_register(&dm644x_vpss_device);
800 platform_device_register(&dm644x_ccdc_dev);
801 platform_device_register(&vpfe_capture_dev);
802
803 return 0; 956 return 0;
804} 957}
805postcore_initcall(dm644x_init_devices); 958postcore_initcall(dm644x_init_devices);
diff --git a/arch/arm/mach-davinci/dm646x.c b/arch/arm/mach-davinci/dm646x.c
index 00f774394b1..9eb87c1d1ed 100644
--- a/arch/arm/mach-davinci/dm646x.c
+++ b/arch/arm/mach-davinci/dm646x.c
@@ -16,7 +16,6 @@
16 16
17#include <asm/mach/map.h> 17#include <asm/mach/map.h>
18 18
19#include <mach/dm646x.h>
20#include <mach/cputype.h> 19#include <mach/cputype.h>
21#include <mach/edma.h> 20#include <mach/edma.h>
22#include <mach/irqs.h> 21#include <mach/irqs.h>
@@ -28,12 +27,11 @@
28#include <mach/asp.h> 27#include <mach/asp.h>
29#include <mach/gpio-davinci.h> 28#include <mach/gpio-davinci.h>
30 29
30#include "davinci.h"
31#include "clock.h" 31#include "clock.h"
32#include "mux.h" 32#include "mux.h"
33 33
34#define DAVINCI_VPIF_BASE (0x01C12000) 34#define DAVINCI_VPIF_BASE (0x01C12000)
35#define VDD3P3V_PWDN_OFFSET (0x48)
36#define VSCLKDIS_OFFSET (0x6C)
37 35
38#define VDD3P3V_VID_MASK (BIT_MASK(3) | BIT_MASK(2) | BIT_MASK(1) |\ 36#define VDD3P3V_VID_MASK (BIT_MASK(3) | BIT_MASK(2) | BIT_MASK(1) |\
39 BIT_MASK(0)) 37 BIT_MASK(0))
@@ -46,6 +44,13 @@
46#define DM646X_REF_FREQ 27000000 44#define DM646X_REF_FREQ 27000000
47#define DM646X_AUX_FREQ 24000000 45#define DM646X_AUX_FREQ 24000000
48 46
47#define DM646X_EMAC_BASE 0x01c80000
48#define DM646X_EMAC_MDIO_BASE (DM646X_EMAC_BASE + 0x4000)
49#define DM646X_EMAC_CNTRL_OFFSET 0x0000
50#define DM646X_EMAC_CNTRL_MOD_OFFSET 0x1000
51#define DM646X_EMAC_CNTRL_RAM_OFFSET 0x2000
52#define DM646X_EMAC_CNTRL_RAM_SIZE 0x2000
53
49static struct pll_data pll1_data = { 54static struct pll_data pll1_data = {
50 .num = 1, 55 .num = 1,
51 .phys_base = DAVINCI_PLL1_BASE, 56 .phys_base = DAVINCI_PLL1_BASE,
@@ -873,15 +878,14 @@ void dm646x_setup_vpif(struct vpif_display_config *display_config,
873 struct vpif_capture_config *capture_config) 878 struct vpif_capture_config *capture_config)
874{ 879{
875 unsigned int value; 880 unsigned int value;
876 void __iomem *base = IO_ADDRESS(DAVINCI_SYSTEM_MODULE_BASE);
877 881
878 value = __raw_readl(base + VSCLKDIS_OFFSET); 882 value = __raw_readl(DAVINCI_SYSMOD_VIRT(SYSMOD_VSCLKDIS));
879 value &= ~VSCLKDIS_MASK; 883 value &= ~VSCLKDIS_MASK;
880 __raw_writel(value, base + VSCLKDIS_OFFSET); 884 __raw_writel(value, DAVINCI_SYSMOD_VIRT(SYSMOD_VSCLKDIS));
881 885
882 value = __raw_readl(base + VDD3P3V_PWDN_OFFSET); 886 value = __raw_readl(DAVINCI_SYSMOD_VIRT(SYSMOD_VDD3P3VPWDN));
883 value &= ~VDD3P3V_VID_MASK; 887 value &= ~VDD3P3V_VID_MASK;
884 __raw_writel(value, base + VDD3P3V_PWDN_OFFSET); 888 __raw_writel(value, DAVINCI_SYSMOD_VIRT(SYSMOD_VDD3P3VPWDN));
885 889
886 davinci_cfg_reg(DM646X_STSOMUX_DISABLE); 890 davinci_cfg_reg(DM646X_STSOMUX_DISABLE);
887 davinci_cfg_reg(DM646X_STSIMUX_DISABLE); 891 davinci_cfg_reg(DM646X_STSIMUX_DISABLE);
@@ -905,6 +909,7 @@ int __init dm646x_init_edma(struct edma_rsv_info *rsv)
905void __init dm646x_init(void) 909void __init dm646x_init(void)
906{ 910{
907 davinci_common_init(&davinci_soc_info_dm646x); 911 davinci_common_init(&davinci_soc_info_dm646x);
912 davinci_map_sysmod();
908} 913}
909 914
910static int __init dm646x_init_devices(void) 915static int __init dm646x_init_devices(void)
diff --git a/arch/arm/mach-davinci/dma.c b/arch/arm/mach-davinci/dma.c
index da90103a313..fd33919c95d 100644
--- a/arch/arm/mach-davinci/dma.c
+++ b/arch/arm/mach-davinci/dma.c
@@ -1508,12 +1508,8 @@ static int __init edma_probe(struct platform_device *pdev)
1508 goto fail; 1508 goto fail;
1509 } 1509 }
1510 1510
1511 /* Everything lives on transfer controller 1 until otherwise
1512 * specified. This way, long transfers on the low priority queue
1513 * started by the codec engine will not cause audio defects.
1514 */
1515 for (i = 0; i < edma_cc[j]->num_channels; i++) 1511 for (i = 0; i < edma_cc[j]->num_channels; i++)
1516 map_dmach_queue(j, i, EVENTQ_1); 1512 map_dmach_queue(j, i, info[j]->default_queue);
1517 1513
1518 queue_tc_mapping = info[j]->queue_tc_mapping; 1514 queue_tc_mapping = info[j]->queue_tc_mapping;
1519 queue_priority_mapping = info[j]->queue_priority_mapping; 1515 queue_priority_mapping = info[j]->queue_priority_mapping;
diff --git a/arch/arm/mach-davinci/include/mach/dm355.h b/arch/arm/mach-davinci/include/mach/dm355.h
deleted file mode 100644
index 36dff4a0ce3..00000000000
--- a/arch/arm/mach-davinci/include/mach/dm355.h
+++ /dev/null
@@ -1,32 +0,0 @@
1/*
2 * Chip specific defines for DM355 SoC
3 *
4 * Author: Kevin Hilman, Deep Root Systems, LLC
5 *
6 * 2007 (c) Deep Root Systems, LLC. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 */
11#ifndef __ASM_ARCH_DM355_H
12#define __ASM_ARCH_DM355_H
13
14#include <mach/hardware.h>
15#include <mach/asp.h>
16#include <media/davinci/vpfe_capture.h>
17
18#define DM355_ASYNC_EMIF_CONTROL_BASE 0x01E10000
19#define DM355_ASYNC_EMIF_DATA_CE0_BASE 0x02000000
20
21#define ASP1_TX_EVT_EN 1
22#define ASP1_RX_EVT_EN 2
23
24struct spi_board_info;
25
26void __init dm355_init(void);
27void dm355_init_spi0(unsigned chipselect_mask,
28 struct spi_board_info *info, unsigned len);
29void __init dm355_init_asp1(u32 evt_enable, struct snd_platform_data *pdata);
30void dm355_set_vpfe_config(struct vpfe_config *cfg);
31
32#endif /* __ASM_ARCH_DM355_H */
diff --git a/arch/arm/mach-davinci/include/mach/dm365.h b/arch/arm/mach-davinci/include/mach/dm365.h
index 2563bf4e93a..b9bf3d6a442 100644
--- a/arch/arm/mach-davinci/include/mach/dm365.h
+++ b/arch/arm/mach-davinci/include/mach/dm365.h
@@ -1,52 +1 @@
1/* /* empty, remove once unused */
2 * Copyright (C) 2009 Texas Instruments Incorporated
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 as
6 * published by the Free Software Foundation version 2.
7 *
8 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 * kind, whether express or implied; without even the implied warranty
10 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13#ifndef __ASM_ARCH_DM365_H
14#define __ASM_ARCH_DM665_H
15
16#include <linux/platform_device.h>
17#include <linux/davinci_emac.h>
18#include <mach/hardware.h>
19#include <mach/asp.h>
20#include <mach/keyscan.h>
21#include <media/davinci/vpfe_capture.h>
22
23#define DM365_EMAC_BASE (0x01D07000)
24#define DM365_EMAC_MDIO_BASE (DM365_EMAC_BASE + 0x4000)
25#define DM365_EMAC_CNTRL_OFFSET (0x0000)
26#define DM365_EMAC_CNTRL_MOD_OFFSET (0x3000)
27#define DM365_EMAC_CNTRL_RAM_OFFSET (0x1000)
28#define DM365_EMAC_CNTRL_RAM_SIZE (0x2000)
29
30/* Base of key scan register bank */
31#define DM365_KEYSCAN_BASE (0x01C69400)
32
33#define DM365_RTC_BASE (0x01C69000)
34
35#define DAVINCI_DM365_VC_BASE (0x01D0C000)
36#define DAVINCI_DMA_VC_TX 2
37#define DAVINCI_DMA_VC_RX 3
38
39#define DM365_ASYNC_EMIF_CONTROL_BASE 0x01D10000
40#define DM365_ASYNC_EMIF_DATA_CE0_BASE 0x02000000
41#define DM365_ASYNC_EMIF_DATA_CE1_BASE 0x04000000
42
43void __init dm365_init(void);
44void __init dm365_init_asp(struct snd_platform_data *pdata);
45void __init dm365_init_vc(struct snd_platform_data *pdata);
46void __init dm365_init_ks(struct davinci_ks_platform_data *pdata);
47void __init dm365_init_rtc(void);
48void dm365_init_spi0(unsigned chipselect_mask,
49 struct spi_board_info *info, unsigned len);
50
51void dm365_set_vpfe_config(struct vpfe_config *cfg);
52#endif /* __ASM_ARCH_DM365_H */
diff --git a/arch/arm/mach-davinci/include/mach/dm644x.h b/arch/arm/mach-davinci/include/mach/dm644x.h
deleted file mode 100644
index 5a1b26d4e68..00000000000
--- a/arch/arm/mach-davinci/include/mach/dm644x.h
+++ /dev/null
@@ -1,47 +0,0 @@
1/*
2 * This file contains the processor specific definitions
3 * of the TI DM644x.
4 *
5 * Copyright (C) 2008 Texas Instruments.
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 USA
20 *
21 */
22#ifndef __ASM_ARCH_DM644X_H
23#define __ASM_ARCH_DM644X_H
24
25#include <linux/davinci_emac.h>
26#include <mach/hardware.h>
27#include <mach/asp.h>
28#include <media/davinci/vpfe_capture.h>
29
30#define DM644X_EMAC_BASE (0x01C80000)
31#define DM644X_EMAC_MDIO_BASE (DM644X_EMAC_BASE + 0x4000)
32#define DM644X_EMAC_CNTRL_OFFSET (0x0000)
33#define DM644X_EMAC_CNTRL_MOD_OFFSET (0x1000)
34#define DM644X_EMAC_CNTRL_RAM_OFFSET (0x2000)
35#define DM644X_EMAC_CNTRL_RAM_SIZE (0x2000)
36
37#define DM644X_ASYNC_EMIF_CONTROL_BASE 0x01E00000
38#define DM644X_ASYNC_EMIF_DATA_CE0_BASE 0x02000000
39#define DM644X_ASYNC_EMIF_DATA_CE1_BASE 0x04000000
40#define DM644X_ASYNC_EMIF_DATA_CE2_BASE 0x06000000
41#define DM644X_ASYNC_EMIF_DATA_CE3_BASE 0x08000000
42
43void __init dm644x_init(void);
44void __init dm644x_init_asp(struct snd_platform_data *pdata);
45void dm644x_set_vpfe_config(struct vpfe_config *cfg);
46
47#endif /* __ASM_ARCH_DM644X_H */
diff --git a/arch/arm/mach-davinci/include/mach/dm646x.h b/arch/arm/mach-davinci/include/mach/dm646x.h
index a8ee6c9f0bb..b9bf3d6a442 100644
--- a/arch/arm/mach-davinci/include/mach/dm646x.h
+++ b/arch/arm/mach-davinci/include/mach/dm646x.h
@@ -1,41 +1 @@
1/* /* empty, remove once unused */
2 * Chip specific defines for DM646x SoC
3 *
4 * Author: Kevin Hilman, Deep Root Systems, LLC
5 *
6 * 2007 (c) Deep Root Systems, LLC. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 */
11#ifndef __ASM_ARCH_DM646X_H
12#define __ASM_ARCH_DM646X_H
13
14#include <mach/hardware.h>
15#include <mach/asp.h>
16#include <linux/i2c.h>
17#include <linux/videodev2.h>
18#include <linux/davinci_emac.h>
19#include <media/davinci/vpif_types.h>
20
21#define DM646X_EMAC_BASE (0x01C80000)
22#define DM646X_EMAC_MDIO_BASE (DM646X_EMAC_BASE + 0x4000)
23#define DM646X_EMAC_CNTRL_OFFSET (0x0000)
24#define DM646X_EMAC_CNTRL_MOD_OFFSET (0x1000)
25#define DM646X_EMAC_CNTRL_RAM_OFFSET (0x2000)
26#define DM646X_EMAC_CNTRL_RAM_SIZE (0x2000)
27
28#define DM646X_ASYNC_EMIF_CONTROL_BASE 0x20008000
29#define DM646X_ASYNC_EMIF_CS2_SPACE_BASE 0x42000000
30
31void __init dm646x_init(void);
32void __init dm646x_init_mcasp0(struct snd_platform_data *pdata);
33void __init dm646x_init_mcasp1(struct snd_platform_data *pdata);
34int __init dm646x_init_edma(struct edma_rsv_info *rsv);
35
36void dm646x_video_init(void);
37
38void dm646x_setup_vpif(struct vpif_display_config *,
39 struct vpif_capture_config *);
40
41#endif /* __ASM_ARCH_DM646X_H */
diff --git a/arch/arm/mach-davinci/include/mach/edma.h b/arch/arm/mach-davinci/include/mach/edma.h
index 20c77f29bf0..7e84c906cef 100644
--- a/arch/arm/mach-davinci/include/mach/edma.h
+++ b/arch/arm/mach-davinci/include/mach/edma.h
@@ -250,6 +250,11 @@ struct edma_soc_info {
250 unsigned n_slot; 250 unsigned n_slot;
251 unsigned n_tc; 251 unsigned n_tc;
252 unsigned n_cc; 252 unsigned n_cc;
253 /*
254 * Default queue is expected to be a low-priority queue.
255 * This way, long transfers on the default queue started
256 * by the codec engine will not cause audio defects.
257 */
253 enum dma_event_q default_queue; 258 enum dma_event_q default_queue;
254 259
255 /* Resource reservation for other cores */ 260 /* Resource reservation for other cores */
diff --git a/arch/arm/mach-davinci/include/mach/entry-macro.S b/arch/arm/mach-davinci/include/mach/entry-macro.S
index e14c0dc0e12..c1661d2feca 100644
--- a/arch/arm/mach-davinci/include/mach/entry-macro.S
+++ b/arch/arm/mach-davinci/include/mach/entry-macro.S
@@ -11,17 +11,11 @@
11#include <mach/io.h> 11#include <mach/io.h>
12#include <mach/irqs.h> 12#include <mach/irqs.h>
13 13
14 .macro disable_fiq
15 .endm
16
17 .macro get_irqnr_preamble, base, tmp 14 .macro get_irqnr_preamble, base, tmp
18 ldr \base, =davinci_intc_base 15 ldr \base, =davinci_intc_base
19 ldr \base, [\base] 16 ldr \base, [\base]
20 .endm 17 .endm
21 18
22 .macro arch_ret_to_user, tmp1, tmp2
23 .endm
24
25 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp 19 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
26#if defined(CONFIG_AINTC) && defined(CONFIG_CP_INTC) 20#if defined(CONFIG_AINTC) && defined(CONFIG_CP_INTC)
27 ldr \tmp, =davinci_intc_type 21 ldr \tmp, =davinci_intc_type
diff --git a/arch/arm/mach-davinci/include/mach/hardware.h b/arch/arm/mach-davinci/include/mach/hardware.h
index 414e0b93e74..0209b1fc22a 100644
--- a/arch/arm/mach-davinci/include/mach/hardware.h
+++ b/arch/arm/mach-davinci/include/mach/hardware.h
@@ -19,8 +19,6 @@
19 * and the chip/board init code should then explicitly include 19 * and the chip/board init code should then explicitly include
20 * <chipname>.h 20 * <chipname>.h
21 */ 21 */
22#define DAVINCI_SYSTEM_MODULE_BASE 0x01C40000
23
24/* 22/*
25 * I/O mapping 23 * I/O mapping
26 */ 24 */
diff --git a/arch/arm/mach-davinci/include/mach/system.h b/arch/arm/mach-davinci/include/mach/system.h
deleted file mode 100644
index fcb7a015aba..00000000000
--- a/arch/arm/mach-davinci/include/mach/system.h
+++ /dev/null
@@ -1,21 +0,0 @@
1/*
2 * DaVinci system defines
3 *
4 * Author: Kevin Hilman, MontaVista Software, Inc. <source@mvista.com>
5 *
6 * 2007 (c) MontaVista Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 */
11#ifndef __ASM_ARCH_SYSTEM_H
12#define __ASM_ARCH_SYSTEM_H
13
14#include <mach/common.h>
15
16static inline void arch_idle(void)
17{
18 cpu_do_idle();
19}
20
21#endif /* __ASM_ARCH_SYSTEM_H */
diff --git a/arch/arm/mach-dove/include/mach/entry-macro.S b/arch/arm/mach-dove/include/mach/entry-macro.S
index e84c78c2a8b..72d622baaad 100644
--- a/arch/arm/mach-dove/include/mach/entry-macro.S
+++ b/arch/arm/mach-dove/include/mach/entry-macro.S
@@ -10,12 +10,6 @@
10 10
11#include <mach/bridge-regs.h> 11#include <mach/bridge-regs.h>
12 12
13 .macro disable_fiq
14 .endm
15
16 .macro arch_ret_to_user, tmp1, tmp2
17 .endm
18
19 .macro get_irqnr_preamble, base, tmp 13 .macro get_irqnr_preamble, base, tmp
20 ldr \base, =IRQ_VIRT_BASE 14 ldr \base, =IRQ_VIRT_BASE
21 .endm 15 .endm
diff --git a/arch/arm/mach-dove/include/mach/system.h b/arch/arm/mach-dove/include/mach/system.h
deleted file mode 100644
index 3027954f616..00000000000
--- a/arch/arm/mach-dove/include/mach/system.h
+++ /dev/null
@@ -1,17 +0,0 @@
1/*
2 * arch/arm/mach-dove/include/mach/system.h
3 *
4 * This file is licensed under the terms of the GNU General Public
5 * License version 2. This program is licensed "as is" without any
6 * warranty of any kind, whether express or implied.
7 */
8
9#ifndef __ASM_ARCH_SYSTEM_H
10#define __ASM_ARCH_SYSTEM_H
11
12static inline void arch_idle(void)
13{
14 cpu_do_idle();
15}
16
17#endif
diff --git a/arch/arm/mach-dove/pcie.c b/arch/arm/mach-dove/pcie.c
index 52e96d397ba..48a032005ea 100644
--- a/arch/arm/mach-dove/pcie.c
+++ b/arch/arm/mach-dove/pcie.c
@@ -69,7 +69,7 @@ static int __init dove_pcie_setup(int nr, struct pci_sys_data *sys)
69 pp->res[0].flags = IORESOURCE_IO; 69 pp->res[0].flags = IORESOURCE_IO;
70 if (request_resource(&ioport_resource, &pp->res[0])) 70 if (request_resource(&ioport_resource, &pp->res[0]))
71 panic("Request PCIe IO resource failed\n"); 71 panic("Request PCIe IO resource failed\n");
72 pci_add_resource(&sys->resources, &pp->res[0]); 72 pci_add_resource_offset(&sys->resources, &pp->res[0], sys->io_offset);
73 73
74 /* 74 /*
75 * IORESOURCE_MEM 75 * IORESOURCE_MEM
@@ -88,7 +88,7 @@ static int __init dove_pcie_setup(int nr, struct pci_sys_data *sys)
88 pp->res[1].flags = IORESOURCE_MEM; 88 pp->res[1].flags = IORESOURCE_MEM;
89 if (request_resource(&iomem_resource, &pp->res[1])) 89 if (request_resource(&iomem_resource, &pp->res[1]))
90 panic("Request PCIe Memory resource failed\n"); 90 panic("Request PCIe Memory resource failed\n");
91 pci_add_resource(&sys->resources, &pp->res[1]); 91 pci_add_resource_offset(&sys->resources, &pp->res[1], sys->mem_offset);
92 92
93 return 1; 93 return 1;
94} 94}
diff --git a/arch/arm/mach-ebsa110/core.c b/arch/arm/mach-ebsa110/core.c
index 0c40e59af73..8c9f56a3e8e 100644
--- a/arch/arm/mach-ebsa110/core.c
+++ b/arch/arm/mach-ebsa110/core.c
@@ -30,10 +30,7 @@
30 30
31#include <asm/mach/time.h> 31#include <asm/mach/time.h>
32 32
33#define IRQ_MASK 0xfe000000 /* read */ 33#include "core.h"
34#define IRQ_MSET 0xfe000000 /* write */
35#define IRQ_STAT 0xff000000 /* read */
36#define IRQ_MCLR 0xff000000 /* write */
37 34
38static void ebsa110_mask_irq(struct irq_data *d) 35static void ebsa110_mask_irq(struct irq_data *d)
39{ 36{
@@ -79,22 +76,22 @@ static struct map_desc ebsa110_io_desc[] __initdata = {
79 { /* IRQ_STAT/IRQ_MCLR */ 76 { /* IRQ_STAT/IRQ_MCLR */
80 .virtual = IRQ_STAT, 77 .virtual = IRQ_STAT,
81 .pfn = __phys_to_pfn(TRICK4_PHYS), 78 .pfn = __phys_to_pfn(TRICK4_PHYS),
82 .length = PGDIR_SIZE, 79 .length = TRICK4_SIZE,
83 .type = MT_DEVICE 80 .type = MT_DEVICE
84 }, { /* IRQ_MASK/IRQ_MSET */ 81 }, { /* IRQ_MASK/IRQ_MSET */
85 .virtual = IRQ_MASK, 82 .virtual = IRQ_MASK,
86 .pfn = __phys_to_pfn(TRICK3_PHYS), 83 .pfn = __phys_to_pfn(TRICK3_PHYS),
87 .length = PGDIR_SIZE, 84 .length = TRICK3_SIZE,
88 .type = MT_DEVICE 85 .type = MT_DEVICE
89 }, { /* SOFT_BASE */ 86 }, { /* SOFT_BASE */
90 .virtual = SOFT_BASE, 87 .virtual = SOFT_BASE,
91 .pfn = __phys_to_pfn(TRICK1_PHYS), 88 .pfn = __phys_to_pfn(TRICK1_PHYS),
92 .length = PGDIR_SIZE, 89 .length = TRICK1_SIZE,
93 .type = MT_DEVICE 90 .type = MT_DEVICE
94 }, { /* PIT_BASE */ 91 }, { /* PIT_BASE */
95 .virtual = PIT_BASE, 92 .virtual = PIT_BASE,
96 .pfn = __phys_to_pfn(TRICK0_PHYS), 93 .pfn = __phys_to_pfn(TRICK0_PHYS),
97 .length = PGDIR_SIZE, 94 .length = TRICK0_SIZE,
98 .type = MT_DEVICE 95 .type = MT_DEVICE
99 }, 96 },
100 97
@@ -271,8 +268,33 @@ static struct platform_device *ebsa110_devices[] = {
271 &am79c961_device, 268 &am79c961_device,
272}; 269};
273 270
271/*
272 * EBSA110 idling methodology:
273 *
274 * We can not execute the "wait for interrupt" instruction since that
275 * will stop our MCLK signal (which provides the clock for the glue
276 * logic, and therefore the timer interrupt).
277 *
278 * Instead, we spin, polling the IRQ_STAT register for the occurrence
279 * of any interrupt with core clock down to the memory clock.
280 */
281static void ebsa110_idle(void)
282{
283 const char *irq_stat = (char *)0xff000000;
284
285 /* disable clock switching */
286 asm volatile ("mcr p15, 0, ip, c15, c2, 2" : : : "cc");
287
288 /* wait for an interrupt to occur */
289 while (!*irq_stat);
290
291 /* enable clock switching */
292 asm volatile ("mcr p15, 0, ip, c15, c1, 2" : : : "cc");
293}
294
274static int __init ebsa110_init(void) 295static int __init ebsa110_init(void)
275{ 296{
297 arm_pm_idle = ebsa110_idle;
276 return platform_add_devices(ebsa110_devices, ARRAY_SIZE(ebsa110_devices)); 298 return platform_add_devices(ebsa110_devices, ARRAY_SIZE(ebsa110_devices));
277} 299}
278 300
diff --git a/arch/arm/mach-ebsa110/core.h b/arch/arm/mach-ebsa110/core.h
new file mode 100644
index 00000000000..c93c9e43012
--- /dev/null
+++ b/arch/arm/mach-ebsa110/core.h
@@ -0,0 +1,41 @@
1/*
2 * Copyright (C) 1996-2000 Russell King.
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 file contains the core hardware definitions of the EBSA-110.
9 */
10#ifndef CORE_H
11#define CORE_H
12
13/* Physical addresses/sizes */
14#define ISAMEM_PHYS 0xe0000000
15#define ISAMEM_SIZE 0x10000000
16
17#define ISAIO_PHYS 0xf0000000
18#define ISAIO_SIZE PGDIR_SIZE
19
20#define TRICK0_PHYS 0xf2000000
21#define TRICK0_SIZE PGDIR_SIZE
22#define TRICK1_PHYS 0xf2400000
23#define TRICK1_SIZE PGDIR_SIZE
24#define TRICK2_PHYS 0xf2800000
25#define TRICK3_PHYS 0xf2c00000
26#define TRICK3_SIZE PGDIR_SIZE
27#define TRICK4_PHYS 0xf3000000
28#define TRICK4_SIZE PGDIR_SIZE
29#define TRICK5_PHYS 0xf3400000
30#define TRICK6_PHYS 0xf3800000
31#define TRICK7_PHYS 0xf3c00000
32
33/* Virtual addresses */
34#define PIT_BASE 0xfc000000 /* trick 0 */
35#define SOFT_BASE 0xfd000000 /* trick 1 */
36#define IRQ_MASK 0xfe000000 /* trick 3 - read */
37#define IRQ_MSET 0xfe000000 /* trick 3 - write */
38#define IRQ_STAT 0xff000000 /* trick 4 - read */
39#define IRQ_MCLR 0xff000000 /* trick 4 - write */
40
41#endif
diff --git a/arch/arm/mach-ebsa110/include/mach/entry-macro.S b/arch/arm/mach-ebsa110/include/mach/entry-macro.S
index cc3e5992f6b..14b110de78a 100644
--- a/arch/arm/mach-ebsa110/include/mach/entry-macro.S
+++ b/arch/arm/mach-ebsa110/include/mach/entry-macro.S
@@ -12,16 +12,10 @@
12 12
13#define IRQ_STAT 0xff000000 /* read */ 13#define IRQ_STAT 0xff000000 /* read */
14 14
15 .macro disable_fiq
16 .endm
17
18 .macro get_irqnr_preamble, base, tmp 15 .macro get_irqnr_preamble, base, tmp
19 mov \base, #IRQ_STAT 16 mov \base, #IRQ_STAT
20 .endm 17 .endm
21 18
22 .macro arch_ret_to_user, tmp1, tmp2
23 .endm
24
25 .macro get_irqnr_and_base, irqnr, stat, base, tmp 19 .macro get_irqnr_and_base, irqnr, stat, base, tmp
26 ldrb \stat, [\base] @ get interrupts 20 ldrb \stat, [\base] @ get interrupts
27 mov \irqnr, #0 21 mov \irqnr, #0
diff --git a/arch/arm/mach-ebsa110/include/mach/hardware.h b/arch/arm/mach-ebsa110/include/mach/hardware.h
index 4b2fb774390..f4e5407bd00 100644
--- a/arch/arm/mach-ebsa110/include/mach/hardware.h
+++ b/arch/arm/mach-ebsa110/include/mach/hardware.h
@@ -12,48 +12,9 @@
12#ifndef __ASM_ARCH_HARDWARE_H 12#ifndef __ASM_ARCH_HARDWARE_H
13#define __ASM_ARCH_HARDWARE_H 13#define __ASM_ARCH_HARDWARE_H
14 14
15/*
16 * The EBSA110 has a weird "ISA IO" region:
17 *
18 * Region 0 (addr = 0xf0000000 + io << 2)
19 * --------------------------------------------------------
20 * Physical region IO region
21 * f0000fe0 - f0000ffc 3f8 - 3ff ttyS0
22 * f0000e60 - f0000e64 398 - 399
23 * f0000de0 - f0000dfc 378 - 37f lp0
24 * f0000be0 - f0000bfc 2f8 - 2ff ttyS1
25 *
26 * Region 1 (addr = 0xf0000000 + (io & ~1) << 1 + (io & 1))
27 * --------------------------------------------------------
28 * Physical region IO region
29 * f00014f1 a79 pnp write data
30 * f00007c0 - f00007c1 3e0 - 3e1 pcmcia
31 * f00004f1 279 pnp address
32 * f0000440 - f000046c 220 - 236 eth0
33 * f0000405 203 pnp read data
34 */
35
36#define ISAMEM_PHYS 0xe0000000
37#define ISAMEM_SIZE 0x10000000
38
39#define ISAIO_PHYS 0xf0000000
40#define ISAIO_SIZE PGDIR_SIZE
41
42#define TRICK0_PHYS 0xf2000000
43#define TRICK1_PHYS 0xf2400000
44#define TRICK2_PHYS 0xf2800000
45#define TRICK3_PHYS 0xf2c00000
46#define TRICK4_PHYS 0xf3000000
47#define TRICK5_PHYS 0xf3400000
48#define TRICK6_PHYS 0xf3800000
49#define TRICK7_PHYS 0xf3c00000
50
51#define ISAMEM_BASE 0xe0000000 15#define ISAMEM_BASE 0xe0000000
52#define ISAIO_BASE 0xf0000000 16#define ISAIO_BASE 0xf0000000
53 17
54#define PIT_BASE 0xfc000000
55#define SOFT_BASE 0xfd000000
56
57/* 18/*
58 * RAM definitions 19 * RAM definitions
59 */ 20 */
diff --git a/arch/arm/mach-ebsa110/include/mach/system.h b/arch/arm/mach-ebsa110/include/mach/system.h
deleted file mode 100644
index 2e4af65edb6..00000000000
--- a/arch/arm/mach-ebsa110/include/mach/system.h
+++ /dev/null
@@ -1,37 +0,0 @@
1/*
2 * arch/arm/mach-ebsa110/include/mach/system.h
3 *
4 * Copyright (C) 1996-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#ifndef __ASM_ARCH_SYSTEM_H
11#define __ASM_ARCH_SYSTEM_H
12
13/*
14 * EBSA110 idling methodology:
15 *
16 * We can not execute the "wait for interrupt" instruction since that
17 * will stop our MCLK signal (which provides the clock for the glue
18 * logic, and therefore the timer interrupt).
19 *
20 * Instead, we spin, polling the IRQ_STAT register for the occurrence
21 * of any interrupt with core clock down to the memory clock.
22 */
23static inline void arch_idle(void)
24{
25 const char *irq_stat = (char *)0xff000000;
26
27 /* disable clock switching */
28 asm volatile ("mcr p15, 0, ip, c15, c2, 2" : : : "cc");
29
30 /* wait for an interrupt to occur */
31 while (!*irq_stat);
32
33 /* enable clock switching */
34 asm volatile ("mcr p15, 0, ip, c15, c1, 2" : : : "cc");
35}
36
37#endif
diff --git a/arch/arm/mach-ebsa110/io.c b/arch/arm/mach-ebsa110/io.c
index c52e3047a7e..756cc377a73 100644
--- a/arch/arm/mach-ebsa110/io.c
+++ b/arch/arm/mach-ebsa110/io.c
@@ -177,6 +177,26 @@ void writesl(void __iomem *addr, const void *data, int len)
177} 177}
178EXPORT_SYMBOL(writesl); 178EXPORT_SYMBOL(writesl);
179 179
180/*
181 * The EBSA110 has a weird "ISA IO" region:
182 *
183 * Region 0 (addr = 0xf0000000 + io << 2)
184 * --------------------------------------------------------
185 * Physical region IO region
186 * f0000fe0 - f0000ffc 3f8 - 3ff ttyS0
187 * f0000e60 - f0000e64 398 - 399
188 * f0000de0 - f0000dfc 378 - 37f lp0
189 * f0000be0 - f0000bfc 2f8 - 2ff ttyS1
190 *
191 * Region 1 (addr = 0xf0000000 + (io & ~1) << 1 + (io & 1))
192 * --------------------------------------------------------
193 * Physical region IO region
194 * f00014f1 a79 pnp write data
195 * f00007c0 - f00007c1 3e0 - 3e1 pcmcia
196 * f00004f1 279 pnp address
197 * f0000440 - f000046c 220 - 236 eth0
198 * f0000405 203 pnp read data
199 */
180#define SUPERIO_PORT(p) \ 200#define SUPERIO_PORT(p) \
181 (((p) >> 3) == (0x3f8 >> 3) || \ 201 (((p) >> 3) == (0x3f8 >> 3) || \
182 ((p) >> 3) == (0x2f8 >> 3) || \ 202 ((p) >> 3) == (0x2f8 >> 3) || \
diff --git a/arch/arm/mach-ebsa110/leds.c b/arch/arm/mach-ebsa110/leds.c
index 101a3204438..99e14e36250 100644
--- a/arch/arm/mach-ebsa110/leds.c
+++ b/arch/arm/mach-ebsa110/leds.c
@@ -19,6 +19,8 @@
19#include <asm/leds.h> 19#include <asm/leds.h>
20#include <asm/mach-types.h> 20#include <asm/mach-types.h>
21 21
22#include "core.h"
23
22static spinlock_t leds_lock; 24static spinlock_t leds_lock;
23 25
24static void ebsa110_leds_event(led_event_t ledevt) 26static void ebsa110_leds_event(led_event_t ledevt)
diff --git a/arch/arm/mach-ep93xx/Makefile b/arch/arm/mach-ep93xx/Makefile
index 574209d9e24..0dc51f9462d 100644
--- a/arch/arm/mach-ep93xx/Makefile
+++ b/arch/arm/mach-ep93xx/Makefile
@@ -8,6 +8,9 @@ obj- :=
8 8
9obj-$(CONFIG_EP93XX_DMA) += dma.o 9obj-$(CONFIG_EP93XX_DMA) += dma.o
10 10
11obj-$(CONFIG_CRUNCH) += crunch.o crunch-bits.o
12AFLAGS_crunch-bits.o := -Wa,-mcpu=ep9312
13
11obj-$(CONFIG_MACH_ADSSPHERE) += adssphere.o 14obj-$(CONFIG_MACH_ADSSPHERE) += adssphere.o
12obj-$(CONFIG_MACH_EDB93XX) += edb93xx.o 15obj-$(CONFIG_MACH_EDB93XX) += edb93xx.o
13obj-$(CONFIG_MACH_GESBC9312) += gesbc9312.o 16obj-$(CONFIG_MACH_GESBC9312) += gesbc9312.o
diff --git a/arch/arm/mach-ep93xx/adssphere.c b/arch/arm/mach-ep93xx/adssphere.c
index 681e939407d..2d45947a303 100644
--- a/arch/arm/mach-ep93xx/adssphere.c
+++ b/arch/arm/mach-ep93xx/adssphere.c
@@ -20,6 +20,7 @@
20#include <asm/mach-types.h> 20#include <asm/mach-types.h>
21#include <asm/mach/arch.h> 21#include <asm/mach/arch.h>
22 22
23#include "soc.h"
23 24
24static struct ep93xx_eth_data __initdata adssphere_eth_data = { 25static struct ep93xx_eth_data __initdata adssphere_eth_data = {
25 .phy_id = 1, 26 .phy_id = 1,
diff --git a/arch/arm/mach-ep93xx/clock.c b/arch/arm/mach-ep93xx/clock.c
index ca4de710509..c95dbce2468 100644
--- a/arch/arm/mach-ep93xx/clock.c
+++ b/arch/arm/mach-ep93xx/clock.c
@@ -25,6 +25,7 @@
25 25
26#include <asm/div64.h> 26#include <asm/div64.h>
27 27
28#include "soc.h"
28 29
29struct clk { 30struct clk {
30 struct clk *parent; 31 struct clk *parent;
diff --git a/arch/arm/mach-ep93xx/core.c b/arch/arm/mach-ep93xx/core.c
index b5c1dae8327..8d258958871 100644
--- a/arch/arm/mach-ep93xx/core.c
+++ b/arch/arm/mach-ep93xx/core.c
@@ -46,6 +46,7 @@
46 46
47#include <asm/hardware/vic.h> 47#include <asm/hardware/vic.h>
48 48
49#include "soc.h"
49 50
50/************************************************************************* 51/*************************************************************************
51 * Static I/O mappings that are needed for all EP93xx platforms 52 * Static I/O mappings that are needed for all EP93xx platforms
@@ -204,7 +205,6 @@ void ep93xx_syscon_swlocked_write(unsigned int val, void __iomem *reg)
204 205
205 spin_unlock_irqrestore(&syscon_swlock, flags); 206 spin_unlock_irqrestore(&syscon_swlock, flags);
206} 207}
207EXPORT_SYMBOL(ep93xx_syscon_swlocked_write);
208 208
209void ep93xx_devcfg_set_clear(unsigned int set_bits, unsigned int clear_bits) 209void ep93xx_devcfg_set_clear(unsigned int set_bits, unsigned int clear_bits)
210{ 210{
@@ -221,7 +221,6 @@ void ep93xx_devcfg_set_clear(unsigned int set_bits, unsigned int clear_bits)
221 221
222 spin_unlock_irqrestore(&syscon_swlock, flags); 222 spin_unlock_irqrestore(&syscon_swlock, flags);
223} 223}
224EXPORT_SYMBOL(ep93xx_devcfg_set_clear);
225 224
226/** 225/**
227 * ep93xx_chip_revision() - returns the EP93xx chip revision 226 * ep93xx_chip_revision() - returns the EP93xx chip revision
@@ -279,48 +278,14 @@ static struct amba_pl010_data ep93xx_uart_data = {
279 .set_mctrl = ep93xx_uart_set_mctrl, 278 .set_mctrl = ep93xx_uart_set_mctrl,
280}; 279};
281 280
282static struct amba_device uart1_device = { 281static AMBA_APB_DEVICE(uart1, "apb:uart1", 0x00041010, EP93XX_UART1_PHYS_BASE,
283 .dev = { 282 { IRQ_EP93XX_UART1 }, &ep93xx_uart_data);
284 .init_name = "apb:uart1",
285 .platform_data = &ep93xx_uart_data,
286 },
287 .res = {
288 .start = EP93XX_UART1_PHYS_BASE,
289 .end = EP93XX_UART1_PHYS_BASE + 0x0fff,
290 .flags = IORESOURCE_MEM,
291 },
292 .irq = { IRQ_EP93XX_UART1, NO_IRQ },
293 .periphid = 0x00041010,
294};
295
296static struct amba_device uart2_device = {
297 .dev = {
298 .init_name = "apb:uart2",
299 .platform_data = &ep93xx_uart_data,
300 },
301 .res = {
302 .start = EP93XX_UART2_PHYS_BASE,
303 .end = EP93XX_UART2_PHYS_BASE + 0x0fff,
304 .flags = IORESOURCE_MEM,
305 },
306 .irq = { IRQ_EP93XX_UART2, NO_IRQ },
307 .periphid = 0x00041010,
308};
309 283
310static struct amba_device uart3_device = { 284static AMBA_APB_DEVICE(uart2, "apb:uart2", 0x00041010, EP93XX_UART2_PHYS_BASE,
311 .dev = { 285 { IRQ_EP93XX_UART2 }, &ep93xx_uart_data);
312 .init_name = "apb:uart3",
313 .platform_data = &ep93xx_uart_data,
314 },
315 .res = {
316 .start = EP93XX_UART3_PHYS_BASE,
317 .end = EP93XX_UART3_PHYS_BASE + 0x0fff,
318 .flags = IORESOURCE_MEM,
319 },
320 .irq = { IRQ_EP93XX_UART3, NO_IRQ },
321 .periphid = 0x00041010,
322};
323 286
287static AMBA_APB_DEVICE(uart3, "apb:uart3", 0x00041010, EP93XX_UART3_PHYS_BASE,
288 { IRQ_EP93XX_UART3 }, &ep93xx_uart_data);
324 289
325static struct resource ep93xx_rtc_resource[] = { 290static struct resource ep93xx_rtc_resource[] = {
326 { 291 {
@@ -682,9 +647,19 @@ static struct platform_device ep93xx_fb_device = {
682 .resource = ep93xx_fb_resource, 647 .resource = ep93xx_fb_resource,
683}; 648};
684 649
650/* The backlight use a single register in the framebuffer's register space */
651#define EP93XX_RASTER_REG_BRIGHTNESS 0x20
652
653static struct resource ep93xx_bl_resources[] = {
654 DEFINE_RES_MEM(EP93XX_RASTER_PHYS_BASE +
655 EP93XX_RASTER_REG_BRIGHTNESS, 0x04),
656};
657
685static struct platform_device ep93xx_bl_device = { 658static struct platform_device ep93xx_bl_device = {
686 .name = "ep93xx-bl", 659 .name = "ep93xx-bl",
687 .id = -1, 660 .id = -1,
661 .num_resources = ARRAY_SIZE(ep93xx_bl_resources),
662 .resource = ep93xx_bl_resources,
688}; 663};
689 664
690/** 665/**
@@ -879,11 +854,32 @@ void __init ep93xx_register_ac97(void)
879 platform_device_register(&ep93xx_pcm_device); 854 platform_device_register(&ep93xx_pcm_device);
880} 855}
881 856
857/*************************************************************************
858 * EP93xx Watchdog
859 *************************************************************************/
860static struct resource ep93xx_wdt_resources[] = {
861 DEFINE_RES_MEM(EP93XX_WATCHDOG_PHYS_BASE, 0x08),
862};
863
864static struct platform_device ep93xx_wdt_device = {
865 .name = "ep93xx-wdt",
866 .id = -1,
867 .num_resources = ARRAY_SIZE(ep93xx_wdt_resources),
868 .resource = ep93xx_wdt_resources,
869};
870
882void __init ep93xx_init_devices(void) 871void __init ep93xx_init_devices(void)
883{ 872{
884 /* Disallow access to MaverickCrunch initially */ 873 /* Disallow access to MaverickCrunch initially */
885 ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_CPENA); 874 ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_CPENA);
886 875
876 /* Default all ports to GPIO */
877 ep93xx_devcfg_set_bits(EP93XX_SYSCON_DEVCFG_KEYS |
878 EP93XX_SYSCON_DEVCFG_GONK |
879 EP93XX_SYSCON_DEVCFG_EONIDE |
880 EP93XX_SYSCON_DEVCFG_GONIDE |
881 EP93XX_SYSCON_DEVCFG_HONIDE);
882
887 /* Get the GPIO working early, other devices need it */ 883 /* Get the GPIO working early, other devices need it */
888 platform_device_register(&ep93xx_gpio_device); 884 platform_device_register(&ep93xx_gpio_device);
889 885
@@ -894,6 +890,7 @@ void __init ep93xx_init_devices(void)
894 platform_device_register(&ep93xx_rtc_device); 890 platform_device_register(&ep93xx_rtc_device);
895 platform_device_register(&ep93xx_ohci_device); 891 platform_device_register(&ep93xx_ohci_device);
896 platform_device_register(&ep93xx_leds); 892 platform_device_register(&ep93xx_leds);
893 platform_device_register(&ep93xx_wdt_device);
897} 894}
898 895
899void ep93xx_restart(char mode, const char *cmd) 896void ep93xx_restart(char mode, const char *cmd)
diff --git a/arch/arm/kernel/crunch-bits.S b/arch/arm/mach-ep93xx/crunch-bits.S
index 0ec9bb48fab..0ec9bb48fab 100644
--- a/arch/arm/kernel/crunch-bits.S
+++ b/arch/arm/mach-ep93xx/crunch-bits.S
diff --git a/arch/arm/kernel/crunch.c b/arch/arm/mach-ep93xx/crunch.c
index 25ef223ba7f..74753e2df60 100644
--- a/arch/arm/kernel/crunch.c
+++ b/arch/arm/mach-ep93xx/crunch.c
@@ -16,9 +16,11 @@
16#include <linux/sched.h> 16#include <linux/sched.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/io.h> 18#include <linux/io.h>
19#include <mach/ep93xx-regs.h> 19
20#include <asm/thread_notify.h> 20#include <asm/thread_notify.h>
21 21
22#include "soc.h"
23
22struct crunch_state *crunch_owner; 24struct crunch_state *crunch_owner;
23 25
24void crunch_task_release(struct thread_info *thread) 26void crunch_task_release(struct thread_info *thread)
diff --git a/arch/arm/mach-ep93xx/dma.c b/arch/arm/mach-ep93xx/dma.c
index 5a257088125..16976d7bdc8 100644
--- a/arch/arm/mach-ep93xx/dma.c
+++ b/arch/arm/mach-ep93xx/dma.c
@@ -28,6 +28,8 @@
28#include <mach/dma.h> 28#include <mach/dma.h>
29#include <mach/hardware.h> 29#include <mach/hardware.h>
30 30
31#include "soc.h"
32
31#define DMA_CHANNEL(_name, _base, _irq) \ 33#define DMA_CHANNEL(_name, _base, _irq) \
32 { .name = (_name), .base = (_base), .irq = (_irq) } 34 { .name = (_name), .base = (_base), .irq = (_irq) }
33 35
diff --git a/arch/arm/mach-ep93xx/edb93xx.c b/arch/arm/mach-ep93xx/edb93xx.c
index d115653edca..da9047d726f 100644
--- a/arch/arm/mach-ep93xx/edb93xx.c
+++ b/arch/arm/mach-ep93xx/edb93xx.c
@@ -43,6 +43,7 @@
43#include <asm/mach-types.h> 43#include <asm/mach-types.h>
44#include <asm/mach/arch.h> 44#include <asm/mach/arch.h>
45 45
46#include "soc.h"
46 47
47static void __init edb93xx_register_flash(void) 48static void __init edb93xx_register_flash(void)
48{ 49{
diff --git a/arch/arm/mach-ep93xx/gesbc9312.c b/arch/arm/mach-ep93xx/gesbc9312.c
index af46970dc58..fcdffbe49dc 100644
--- a/arch/arm/mach-ep93xx/gesbc9312.c
+++ b/arch/arm/mach-ep93xx/gesbc9312.c
@@ -20,6 +20,7 @@
20#include <asm/mach-types.h> 20#include <asm/mach-types.h>
21#include <asm/mach/arch.h> 21#include <asm/mach/arch.h>
22 22
23#include "soc.h"
23 24
24static struct ep93xx_eth_data __initdata gesbc9312_eth_data = { 25static struct ep93xx_eth_data __initdata gesbc9312_eth_data = {
25 .phy_id = 1, 26 .phy_id = 1,
diff --git a/arch/arm/mach-ep93xx/include/mach/entry-macro.S b/arch/arm/mach-ep93xx/include/mach/entry-macro.S
deleted file mode 100644
index 9be6edcf904..00000000000
--- a/arch/arm/mach-ep93xx/include/mach/entry-macro.S
+++ /dev/null
@@ -1,17 +0,0 @@
1/*
2 * arch/arm/mach-ep93xx/include/mach/entry-macro.S
3 * IRQ demultiplexing for EP93xx
4 *
5 * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
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 (at
10 * your option) any later version.
11 */
12
13 .macro disable_fiq
14 .endm
15
16 .macro arch_ret_to_user, tmp1, tmp2
17 .endm
diff --git a/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h b/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h
index c4a7b84ef06..c64d7424660 100644
--- a/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h
+++ b/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h
@@ -6,40 +6,6 @@
6#define __ASM_ARCH_EP93XX_REGS_H 6#define __ASM_ARCH_EP93XX_REGS_H
7 7
8/* 8/*
9 * EP93xx Physical Memory Map:
10 *
11 * The ASDO pin is sampled at system reset to select a synchronous or
12 * asynchronous boot configuration. When ASDO is "1" (i.e. pulled-up)
13 * the synchronous boot mode is selected. When ASDO is "0" (i.e
14 * pulled-down) the asynchronous boot mode is selected.
15 *
16 * In synchronous boot mode nSDCE3 is decoded starting at physical address
17 * 0x00000000 and nCS0 is decoded starting at 0xf0000000. For asynchronous
18 * boot mode they are swapped with nCS0 decoded at 0x00000000 ann nSDCE3
19 * decoded at 0xf0000000.
20 *
21 * There is known errata for the EP93xx dealing with External Memory
22 * Configurations. Please refer to "AN273: EP93xx Silicon Rev E Design
23 * Guidelines" for more information. This document can be found at:
24 *
25 * http://www.cirrus.com/en/pubs/appNote/AN273REV4.pdf
26 */
27
28#define EP93XX_CS0_PHYS_BASE_ASYNC 0x00000000 /* ASDO Pin = 0 */
29#define EP93XX_SDCE3_PHYS_BASE_SYNC 0x00000000 /* ASDO Pin = 1 */
30#define EP93XX_CS1_PHYS_BASE 0x10000000
31#define EP93XX_CS2_PHYS_BASE 0x20000000
32#define EP93XX_CS3_PHYS_BASE 0x30000000
33#define EP93XX_PCMCIA_PHYS_BASE 0x40000000
34#define EP93XX_CS6_PHYS_BASE 0x60000000
35#define EP93XX_CS7_PHYS_BASE 0x70000000
36#define EP93XX_SDCE0_PHYS_BASE 0xc0000000
37#define EP93XX_SDCE1_PHYS_BASE 0xd0000000
38#define EP93XX_SDCE2_PHYS_BASE 0xe0000000
39#define EP93XX_SDCE3_PHYS_BASE_ASYNC 0xf0000000 /* ASDO Pin = 0 */
40#define EP93XX_CS0_PHYS_BASE_SYNC 0xf0000000 /* ASDO Pin = 1 */
41
42/*
43 * EP93xx linux memory map: 9 * EP93xx linux memory map:
44 * 10 *
45 * virt phys size 11 * virt phys size
@@ -62,58 +28,7 @@
62#define EP93XX_APB_PHYS(x) (EP93XX_APB_PHYS_BASE + (x)) 28#define EP93XX_APB_PHYS(x) (EP93XX_APB_PHYS_BASE + (x))
63#define EP93XX_APB_IOMEM(x) IOMEM(EP93XX_APB_VIRT_BASE + (x)) 29#define EP93XX_APB_IOMEM(x) IOMEM(EP93XX_APB_VIRT_BASE + (x))
64 30
65 31/* APB UARTs */
66/* AHB peripherals */
67#define EP93XX_DMA_BASE EP93XX_AHB_IOMEM(0x00000000)
68
69#define EP93XX_ETHERNET_PHYS_BASE EP93XX_AHB_PHYS(0x00010000)
70#define EP93XX_ETHERNET_BASE EP93XX_AHB_IOMEM(0x00010000)
71
72#define EP93XX_USB_PHYS_BASE EP93XX_AHB_PHYS(0x00020000)
73#define EP93XX_USB_BASE EP93XX_AHB_IOMEM(0x00020000)
74
75#define EP93XX_RASTER_PHYS_BASE EP93XX_AHB_PHYS(0x00030000)
76#define EP93XX_RASTER_BASE EP93XX_AHB_IOMEM(0x00030000)
77
78#define EP93XX_GRAPHICS_ACCEL_BASE EP93XX_AHB_IOMEM(0x00040000)
79
80#define EP93XX_SDRAM_CONTROLLER_BASE EP93XX_AHB_IOMEM(0x00060000)
81
82#define EP93XX_PCMCIA_CONTROLLER_BASE EP93XX_AHB_IOMEM(0x00080000)
83
84#define EP93XX_BOOT_ROM_BASE EP93XX_AHB_IOMEM(0x00090000)
85
86#define EP93XX_IDE_BASE EP93XX_AHB_IOMEM(0x000a0000)
87
88#define EP93XX_VIC1_BASE EP93XX_AHB_IOMEM(0x000b0000)
89
90#define EP93XX_VIC2_BASE EP93XX_AHB_IOMEM(0x000c0000)
91
92
93/* APB peripherals */
94#define EP93XX_TIMER_BASE EP93XX_APB_IOMEM(0x00010000)
95
96#define EP93XX_I2S_PHYS_BASE EP93XX_APB_PHYS(0x00020000)
97#define EP93XX_I2S_BASE EP93XX_APB_IOMEM(0x00020000)
98
99#define EP93XX_SECURITY_BASE EP93XX_APB_IOMEM(0x00030000)
100
101#define EP93XX_GPIO_PHYS_BASE EP93XX_APB_PHYS(0x00040000)
102#define EP93XX_GPIO_BASE EP93XX_APB_IOMEM(0x00040000)
103#define EP93XX_GPIO_REG(x) (EP93XX_GPIO_BASE + (x))
104#define EP93XX_GPIO_F_INT_STATUS EP93XX_GPIO_REG(0x5c)
105#define EP93XX_GPIO_A_INT_STATUS EP93XX_GPIO_REG(0xa0)
106#define EP93XX_GPIO_B_INT_STATUS EP93XX_GPIO_REG(0xbc)
107#define EP93XX_GPIO_EEDRIVE EP93XX_GPIO_REG(0xc8)
108
109#define EP93XX_AAC_PHYS_BASE EP93XX_APB_PHYS(0x00080000)
110#define EP93XX_AAC_BASE EP93XX_APB_IOMEM(0x00080000)
111
112#define EP93XX_SPI_PHYS_BASE EP93XX_APB_PHYS(0x000a0000)
113#define EP93XX_SPI_BASE EP93XX_APB_IOMEM(0x000a0000)
114
115#define EP93XX_IRDA_BASE EP93XX_APB_IOMEM(0x000b0000)
116
117#define EP93XX_UART1_PHYS_BASE EP93XX_APB_PHYS(0x000c0000) 32#define EP93XX_UART1_PHYS_BASE EP93XX_APB_PHYS(0x000c0000)
118#define EP93XX_UART1_BASE EP93XX_APB_IOMEM(0x000c0000) 33#define EP93XX_UART1_BASE EP93XX_APB_IOMEM(0x000c0000)
119 34
@@ -123,108 +38,4 @@
123#define EP93XX_UART3_PHYS_BASE EP93XX_APB_PHYS(0x000e0000) 38#define EP93XX_UART3_PHYS_BASE EP93XX_APB_PHYS(0x000e0000)
124#define EP93XX_UART3_BASE EP93XX_APB_IOMEM(0x000e0000) 39#define EP93XX_UART3_BASE EP93XX_APB_IOMEM(0x000e0000)
125 40
126#define EP93XX_KEY_MATRIX_PHYS_BASE EP93XX_APB_PHYS(0x000f0000)
127#define EP93XX_KEY_MATRIX_BASE EP93XX_APB_IOMEM(0x000f0000)
128
129#define EP93XX_ADC_BASE EP93XX_APB_IOMEM(0x00100000)
130#define EP93XX_TOUCHSCREEN_BASE EP93XX_APB_IOMEM(0x00100000)
131
132#define EP93XX_PWM_PHYS_BASE EP93XX_APB_PHYS(0x00110000)
133#define EP93XX_PWM_BASE EP93XX_APB_IOMEM(0x00110000)
134
135#define EP93XX_RTC_PHYS_BASE EP93XX_APB_PHYS(0x00120000)
136#define EP93XX_RTC_BASE EP93XX_APB_IOMEM(0x00120000)
137
138#define EP93XX_SYSCON_BASE EP93XX_APB_IOMEM(0x00130000)
139#define EP93XX_SYSCON_REG(x) (EP93XX_SYSCON_BASE + (x))
140#define EP93XX_SYSCON_POWER_STATE EP93XX_SYSCON_REG(0x00)
141#define EP93XX_SYSCON_PWRCNT EP93XX_SYSCON_REG(0x04)
142#define EP93XX_SYSCON_PWRCNT_FIR_EN (1<<31)
143#define EP93XX_SYSCON_PWRCNT_UARTBAUD (1<<29)
144#define EP93XX_SYSCON_PWRCNT_USH_EN (1<<28)
145#define EP93XX_SYSCON_PWRCNT_DMA_M2M1 (1<<27)
146#define EP93XX_SYSCON_PWRCNT_DMA_M2M0 (1<<26)
147#define EP93XX_SYSCON_PWRCNT_DMA_M2P8 (1<<25)
148#define EP93XX_SYSCON_PWRCNT_DMA_M2P9 (1<<24)
149#define EP93XX_SYSCON_PWRCNT_DMA_M2P6 (1<<23)
150#define EP93XX_SYSCON_PWRCNT_DMA_M2P7 (1<<22)
151#define EP93XX_SYSCON_PWRCNT_DMA_M2P4 (1<<21)
152#define EP93XX_SYSCON_PWRCNT_DMA_M2P5 (1<<20)
153#define EP93XX_SYSCON_PWRCNT_DMA_M2P2 (1<<19)
154#define EP93XX_SYSCON_PWRCNT_DMA_M2P3 (1<<18)
155#define EP93XX_SYSCON_PWRCNT_DMA_M2P0 (1<<17)
156#define EP93XX_SYSCON_PWRCNT_DMA_M2P1 (1<<16)
157#define EP93XX_SYSCON_HALT EP93XX_SYSCON_REG(0x08)
158#define EP93XX_SYSCON_STANDBY EP93XX_SYSCON_REG(0x0c)
159#define EP93XX_SYSCON_CLKSET1 EP93XX_SYSCON_REG(0x20)
160#define EP93XX_SYSCON_CLKSET1_NBYP1 (1<<23)
161#define EP93XX_SYSCON_CLKSET2 EP93XX_SYSCON_REG(0x24)
162#define EP93XX_SYSCON_CLKSET2_NBYP2 (1<<19)
163#define EP93XX_SYSCON_CLKSET2_PLL2_EN (1<<18)
164#define EP93XX_SYSCON_DEVCFG EP93XX_SYSCON_REG(0x80)
165#define EP93XX_SYSCON_DEVCFG_SWRST (1<<31)
166#define EP93XX_SYSCON_DEVCFG_D1ONG (1<<30)
167#define EP93XX_SYSCON_DEVCFG_D0ONG (1<<29)
168#define EP93XX_SYSCON_DEVCFG_IONU2 (1<<28)
169#define EP93XX_SYSCON_DEVCFG_GONK (1<<27)
170#define EP93XX_SYSCON_DEVCFG_TONG (1<<26)
171#define EP93XX_SYSCON_DEVCFG_MONG (1<<25)
172#define EP93XX_SYSCON_DEVCFG_U3EN (1<<24)
173#define EP93XX_SYSCON_DEVCFG_CPENA (1<<23)
174#define EP93XX_SYSCON_DEVCFG_A2ONG (1<<22)
175#define EP93XX_SYSCON_DEVCFG_A1ONG (1<<21)
176#define EP93XX_SYSCON_DEVCFG_U2EN (1<<20)
177#define EP93XX_SYSCON_DEVCFG_EXVC (1<<19)
178#define EP93XX_SYSCON_DEVCFG_U1EN (1<<18)
179#define EP93XX_SYSCON_DEVCFG_TIN (1<<17)
180#define EP93XX_SYSCON_DEVCFG_HC3IN (1<<15)
181#define EP93XX_SYSCON_DEVCFG_HC3EN (1<<14)
182#define EP93XX_SYSCON_DEVCFG_HC1IN (1<<13)
183#define EP93XX_SYSCON_DEVCFG_HC1EN (1<<12)
184#define EP93XX_SYSCON_DEVCFG_HONIDE (1<<11)
185#define EP93XX_SYSCON_DEVCFG_GONIDE (1<<10)
186#define EP93XX_SYSCON_DEVCFG_PONG (1<<9)
187#define EP93XX_SYSCON_DEVCFG_EONIDE (1<<8)
188#define EP93XX_SYSCON_DEVCFG_I2SONSSP (1<<7)
189#define EP93XX_SYSCON_DEVCFG_I2SONAC97 (1<<6)
190#define EP93XX_SYSCON_DEVCFG_RASONP3 (1<<4)
191#define EP93XX_SYSCON_DEVCFG_RAS (1<<3)
192#define EP93XX_SYSCON_DEVCFG_ADCPD (1<<2)
193#define EP93XX_SYSCON_DEVCFG_KEYS (1<<1)
194#define EP93XX_SYSCON_DEVCFG_SHENA (1<<0)
195#define EP93XX_SYSCON_VIDCLKDIV EP93XX_SYSCON_REG(0x84)
196#define EP93XX_SYSCON_CLKDIV_ENABLE (1<<15)
197#define EP93XX_SYSCON_CLKDIV_ESEL (1<<14)
198#define EP93XX_SYSCON_CLKDIV_PSEL (1<<13)
199#define EP93XX_SYSCON_CLKDIV_PDIV_SHIFT 8
200#define EP93XX_SYSCON_I2SCLKDIV EP93XX_SYSCON_REG(0x8c)
201#define EP93XX_SYSCON_I2SCLKDIV_SENA (1<<31)
202#define EP93XX_SYSCON_I2SCLKDIV_ORIDE (1<<29)
203#define EP93XX_SYSCON_I2SCLKDIV_SPOL (1<<19)
204#define EP93XX_I2SCLKDIV_SDIV (1 << 16)
205#define EP93XX_I2SCLKDIV_LRDIV32 (0 << 17)
206#define EP93XX_I2SCLKDIV_LRDIV64 (1 << 17)
207#define EP93XX_I2SCLKDIV_LRDIV128 (2 << 17)
208#define EP93XX_I2SCLKDIV_LRDIV_MASK (3 << 17)
209#define EP93XX_SYSCON_KEYTCHCLKDIV EP93XX_SYSCON_REG(0x90)
210#define EP93XX_SYSCON_KEYTCHCLKDIV_TSEN (1<<31)
211#define EP93XX_SYSCON_KEYTCHCLKDIV_ADIV (1<<16)
212#define EP93XX_SYSCON_KEYTCHCLKDIV_KEN (1<<15)
213#define EP93XX_SYSCON_KEYTCHCLKDIV_KDIV (1<<0)
214#define EP93XX_SYSCON_SYSCFG EP93XX_SYSCON_REG(0x9c)
215#define EP93XX_SYSCON_SYSCFG_REV_MASK (0xf0000000)
216#define EP93XX_SYSCON_SYSCFG_REV_SHIFT (28)
217#define EP93XX_SYSCON_SYSCFG_SBOOT (1<<8)
218#define EP93XX_SYSCON_SYSCFG_LCSN7 (1<<7)
219#define EP93XX_SYSCON_SYSCFG_LCSN6 (1<<6)
220#define EP93XX_SYSCON_SYSCFG_LASDO (1<<5)
221#define EP93XX_SYSCON_SYSCFG_LEEDA (1<<4)
222#define EP93XX_SYSCON_SYSCFG_LEECLK (1<<3)
223#define EP93XX_SYSCON_SYSCFG_LCSN2 (1<<1)
224#define EP93XX_SYSCON_SYSCFG_LCSN1 (1<<0)
225#define EP93XX_SYSCON_SWLOCK EP93XX_SYSCON_REG(0xc0)
226
227#define EP93XX_WATCHDOG_BASE EP93XX_APB_IOMEM(0x00140000)
228
229
230#endif 41#endif
diff --git a/arch/arm/mach-ep93xx/include/mach/gpio-ep93xx.h b/arch/arm/mach-ep93xx/include/mach/gpio-ep93xx.h
index 8aff2ea3587..6d7c571a519 100644
--- a/arch/arm/mach-ep93xx/include/mach/gpio-ep93xx.h
+++ b/arch/arm/mach-ep93xx/include/mach/gpio-ep93xx.h
@@ -3,6 +3,16 @@
3#ifndef __GPIO_EP93XX_H 3#ifndef __GPIO_EP93XX_H
4#define __GPIO_EP93XX_H 4#define __GPIO_EP93XX_H
5 5
6#include <mach/ep93xx-regs.h>
7
8#define EP93XX_GPIO_PHYS_BASE EP93XX_APB_PHYS(0x00040000)
9#define EP93XX_GPIO_BASE EP93XX_APB_IOMEM(0x00040000)
10#define EP93XX_GPIO_REG(x) (EP93XX_GPIO_BASE + (x))
11#define EP93XX_GPIO_F_INT_STATUS EP93XX_GPIO_REG(0x5c)
12#define EP93XX_GPIO_A_INT_STATUS EP93XX_GPIO_REG(0xa0)
13#define EP93XX_GPIO_B_INT_STATUS EP93XX_GPIO_REG(0xbc)
14#define EP93XX_GPIO_EEDRIVE EP93XX_GPIO_REG(0xc8)
15
6/* GPIO port A. */ 16/* GPIO port A. */
7#define EP93XX_GPIO_LINE_A(x) ((x) + 0) 17#define EP93XX_GPIO_LINE_A(x) ((x) + 0)
8#define EP93XX_GPIO_LINE_EGPIO0 EP93XX_GPIO_LINE_A(0) 18#define EP93XX_GPIO_LINE_EGPIO0 EP93XX_GPIO_LINE_A(0)
diff --git a/arch/arm/mach-ep93xx/include/mach/hardware.h b/arch/arm/mach-ep93xx/include/mach/hardware.h
index 4df842897ea..efcd47815a9 100644
--- a/arch/arm/mach-ep93xx/include/mach/hardware.h
+++ b/arch/arm/mach-ep93xx/include/mach/hardware.h
@@ -5,7 +5,6 @@
5#ifndef __ASM_ARCH_HARDWARE_H 5#ifndef __ASM_ARCH_HARDWARE_H
6#define __ASM_ARCH_HARDWARE_H 6#define __ASM_ARCH_HARDWARE_H
7 7
8#include <mach/ep93xx-regs.h>
9#include <mach/platform.h> 8#include <mach/platform.h>
10 9
11/* 10/*
diff --git a/arch/arm/mach-ep93xx/include/mach/platform.h b/arch/arm/mach-ep93xx/include/mach/platform.h
index ad63d4be693..602bd87fd0a 100644
--- a/arch/arm/mach-ep93xx/include/mach/platform.h
+++ b/arch/arm/mach-ep93xx/include/mach/platform.h
@@ -21,20 +21,6 @@ struct ep93xx_eth_data
21void ep93xx_map_io(void); 21void ep93xx_map_io(void);
22void ep93xx_init_irq(void); 22void ep93xx_init_irq(void);
23 23
24/* EP93xx System Controller software locked register write */
25void ep93xx_syscon_swlocked_write(unsigned int val, void __iomem *reg);
26void ep93xx_devcfg_set_clear(unsigned int set_bits, unsigned int clear_bits);
27
28static inline void ep93xx_devcfg_set_bits(unsigned int bits)
29{
30 ep93xx_devcfg_set_clear(bits, 0x00);
31}
32
33static inline void ep93xx_devcfg_clear_bits(unsigned int bits)
34{
35 ep93xx_devcfg_set_clear(0x00, bits);
36}
37
38#define EP93XX_CHIP_REV_D0 3 24#define EP93XX_CHIP_REV_D0 3
39#define EP93XX_CHIP_REV_D1 4 25#define EP93XX_CHIP_REV_D1 4
40#define EP93XX_CHIP_REV_E0 5 26#define EP93XX_CHIP_REV_E0 5
diff --git a/arch/arm/mach-ep93xx/include/mach/system.h b/arch/arm/mach-ep93xx/include/mach/system.h
deleted file mode 100644
index b5bec7cb9b5..00000000000
--- a/arch/arm/mach-ep93xx/include/mach/system.h
+++ /dev/null
@@ -1,7 +0,0 @@
1/*
2 * arch/arm/mach-ep93xx/include/mach/system.h
3 */
4static inline void arch_idle(void)
5{
6 cpu_do_idle();
7}
diff --git a/arch/arm/mach-ep93xx/micro9.c b/arch/arm/mach-ep93xx/micro9.c
index 7b98084f0c9..dc431c5f04c 100644
--- a/arch/arm/mach-ep93xx/micro9.c
+++ b/arch/arm/mach-ep93xx/micro9.c
@@ -22,6 +22,7 @@
22#include <asm/mach-types.h> 22#include <asm/mach-types.h>
23#include <asm/mach/arch.h> 23#include <asm/mach/arch.h>
24 24
25#include "soc.h"
25 26
26/************************************************************************* 27/*************************************************************************
27 * Micro9 NOR Flash 28 * Micro9 NOR Flash
diff --git a/arch/arm/mach-ep93xx/simone.c b/arch/arm/mach-ep93xx/simone.c
index f4e553eca21..f40c2987e54 100644
--- a/arch/arm/mach-ep93xx/simone.c
+++ b/arch/arm/mach-ep93xx/simone.c
@@ -29,6 +29,8 @@
29#include <asm/mach-types.h> 29#include <asm/mach-types.h>
30#include <asm/mach/arch.h> 30#include <asm/mach/arch.h>
31 31
32#include "soc.h"
33
32static struct ep93xx_eth_data __initdata simone_eth_data = { 34static struct ep93xx_eth_data __initdata simone_eth_data = {
33 .phy_id = 1, 35 .phy_id = 1,
34}; 36};
diff --git a/arch/arm/mach-ep93xx/snappercl15.c b/arch/arm/mach-ep93xx/snappercl15.c
index fd846331ddf..0c00852ef16 100644
--- a/arch/arm/mach-ep93xx/snappercl15.c
+++ b/arch/arm/mach-ep93xx/snappercl15.c
@@ -35,6 +35,8 @@
35#include <asm/mach-types.h> 35#include <asm/mach-types.h>
36#include <asm/mach/arch.h> 36#include <asm/mach/arch.h>
37 37
38#include "soc.h"
39
38#define SNAPPERCL15_NAND_BASE (EP93XX_CS7_PHYS_BASE + SZ_16M) 40#define SNAPPERCL15_NAND_BASE (EP93XX_CS7_PHYS_BASE + SZ_16M)
39 41
40#define SNAPPERCL15_NAND_WPN (1 << 8) /* Write protect (active low) */ 42#define SNAPPERCL15_NAND_WPN (1 << 8) /* Write protect (active low) */
diff --git a/arch/arm/mach-ep93xx/soc.h b/arch/arm/mach-ep93xx/soc.h
new file mode 100644
index 00000000000..979fba72292
--- /dev/null
+++ b/arch/arm/mach-ep93xx/soc.h
@@ -0,0 +1,213 @@
1/*
2 * arch/arm/mach-ep93xx/soc.h
3 *
4 * Copyright (C) 2012 Open Kernel Labs <www.ok-labs.com>
5 * Copyright (C) 2012 Ryan Mallon <rmallon@gmail.com>
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 (at
10 * your option) any later version.
11 */
12
13#ifndef _EP93XX_SOC_H
14#define _EP93XX_SOC_H
15
16#include <mach/ep93xx-regs.h>
17
18/*
19 * EP93xx Physical Memory Map:
20 *
21 * The ASDO pin is sampled at system reset to select a synchronous or
22 * asynchronous boot configuration. When ASDO is "1" (i.e. pulled-up)
23 * the synchronous boot mode is selected. When ASDO is "0" (i.e
24 * pulled-down) the asynchronous boot mode is selected.
25 *
26 * In synchronous boot mode nSDCE3 is decoded starting at physical address
27 * 0x00000000 and nCS0 is decoded starting at 0xf0000000. For asynchronous
28 * boot mode they are swapped with nCS0 decoded at 0x00000000 ann nSDCE3
29 * decoded at 0xf0000000.
30 *
31 * There is known errata for the EP93xx dealing with External Memory
32 * Configurations. Please refer to "AN273: EP93xx Silicon Rev E Design
33 * Guidelines" for more information. This document can be found at:
34 *
35 * http://www.cirrus.com/en/pubs/appNote/AN273REV4.pdf
36 */
37
38#define EP93XX_CS0_PHYS_BASE_ASYNC 0x00000000 /* ASDO Pin = 0 */
39#define EP93XX_SDCE3_PHYS_BASE_SYNC 0x00000000 /* ASDO Pin = 1 */
40#define EP93XX_CS1_PHYS_BASE 0x10000000
41#define EP93XX_CS2_PHYS_BASE 0x20000000
42#define EP93XX_CS3_PHYS_BASE 0x30000000
43#define EP93XX_PCMCIA_PHYS_BASE 0x40000000
44#define EP93XX_CS6_PHYS_BASE 0x60000000
45#define EP93XX_CS7_PHYS_BASE 0x70000000
46#define EP93XX_SDCE0_PHYS_BASE 0xc0000000
47#define EP93XX_SDCE1_PHYS_BASE 0xd0000000
48#define EP93XX_SDCE2_PHYS_BASE 0xe0000000
49#define EP93XX_SDCE3_PHYS_BASE_ASYNC 0xf0000000 /* ASDO Pin = 0 */
50#define EP93XX_CS0_PHYS_BASE_SYNC 0xf0000000 /* ASDO Pin = 1 */
51
52/* AHB peripherals */
53#define EP93XX_DMA_BASE EP93XX_AHB_IOMEM(0x00000000)
54
55#define EP93XX_ETHERNET_PHYS_BASE EP93XX_AHB_PHYS(0x00010000)
56#define EP93XX_ETHERNET_BASE EP93XX_AHB_IOMEM(0x00010000)
57
58#define EP93XX_USB_PHYS_BASE EP93XX_AHB_PHYS(0x00020000)
59#define EP93XX_USB_BASE EP93XX_AHB_IOMEM(0x00020000)
60
61#define EP93XX_RASTER_PHYS_BASE EP93XX_AHB_PHYS(0x00030000)
62#define EP93XX_RASTER_BASE EP93XX_AHB_IOMEM(0x00030000)
63
64#define EP93XX_GRAPHICS_ACCEL_BASE EP93XX_AHB_IOMEM(0x00040000)
65
66#define EP93XX_SDRAM_CONTROLLER_BASE EP93XX_AHB_IOMEM(0x00060000)
67
68#define EP93XX_PCMCIA_CONTROLLER_BASE EP93XX_AHB_IOMEM(0x00080000)
69
70#define EP93XX_BOOT_ROM_BASE EP93XX_AHB_IOMEM(0x00090000)
71
72#define EP93XX_IDE_BASE EP93XX_AHB_IOMEM(0x000a0000)
73
74#define EP93XX_VIC1_BASE EP93XX_AHB_IOMEM(0x000b0000)
75
76#define EP93XX_VIC2_BASE EP93XX_AHB_IOMEM(0x000c0000)
77
78/* APB peripherals */
79#define EP93XX_TIMER_BASE EP93XX_APB_IOMEM(0x00010000)
80
81#define EP93XX_I2S_PHYS_BASE EP93XX_APB_PHYS(0x00020000)
82#define EP93XX_I2S_BASE EP93XX_APB_IOMEM(0x00020000)
83
84#define EP93XX_SECURITY_BASE EP93XX_APB_IOMEM(0x00030000)
85
86#define EP93XX_AAC_PHYS_BASE EP93XX_APB_PHYS(0x00080000)
87#define EP93XX_AAC_BASE EP93XX_APB_IOMEM(0x00080000)
88
89#define EP93XX_SPI_PHYS_BASE EP93XX_APB_PHYS(0x000a0000)
90#define EP93XX_SPI_BASE EP93XX_APB_IOMEM(0x000a0000)
91
92#define EP93XX_IRDA_BASE EP93XX_APB_IOMEM(0x000b0000)
93
94#define EP93XX_KEY_MATRIX_PHYS_BASE EP93XX_APB_PHYS(0x000f0000)
95#define EP93XX_KEY_MATRIX_BASE EP93XX_APB_IOMEM(0x000f0000)
96
97#define EP93XX_ADC_BASE EP93XX_APB_IOMEM(0x00100000)
98#define EP93XX_TOUCHSCREEN_BASE EP93XX_APB_IOMEM(0x00100000)
99
100#define EP93XX_PWM_PHYS_BASE EP93XX_APB_PHYS(0x00110000)
101#define EP93XX_PWM_BASE EP93XX_APB_IOMEM(0x00110000)
102
103#define EP93XX_RTC_PHYS_BASE EP93XX_APB_PHYS(0x00120000)
104#define EP93XX_RTC_BASE EP93XX_APB_IOMEM(0x00120000)
105
106#define EP93XX_WATCHDOG_PHYS_BASE EP93XX_APB_PHYS(0x00140000)
107#define EP93XX_WATCHDOG_BASE EP93XX_APB_IOMEM(0x00140000)
108
109/* System controller */
110#define EP93XX_SYSCON_BASE EP93XX_APB_IOMEM(0x00130000)
111#define EP93XX_SYSCON_REG(x) (EP93XX_SYSCON_BASE + (x))
112#define EP93XX_SYSCON_POWER_STATE EP93XX_SYSCON_REG(0x00)
113#define EP93XX_SYSCON_PWRCNT EP93XX_SYSCON_REG(0x04)
114#define EP93XX_SYSCON_PWRCNT_FIR_EN (1<<31)
115#define EP93XX_SYSCON_PWRCNT_UARTBAUD (1<<29)
116#define EP93XX_SYSCON_PWRCNT_USH_EN (1<<28)
117#define EP93XX_SYSCON_PWRCNT_DMA_M2M1 (1<<27)
118#define EP93XX_SYSCON_PWRCNT_DMA_M2M0 (1<<26)
119#define EP93XX_SYSCON_PWRCNT_DMA_M2P8 (1<<25)
120#define EP93XX_SYSCON_PWRCNT_DMA_M2P9 (1<<24)
121#define EP93XX_SYSCON_PWRCNT_DMA_M2P6 (1<<23)
122#define EP93XX_SYSCON_PWRCNT_DMA_M2P7 (1<<22)
123#define EP93XX_SYSCON_PWRCNT_DMA_M2P4 (1<<21)
124#define EP93XX_SYSCON_PWRCNT_DMA_M2P5 (1<<20)
125#define EP93XX_SYSCON_PWRCNT_DMA_M2P2 (1<<19)
126#define EP93XX_SYSCON_PWRCNT_DMA_M2P3 (1<<18)
127#define EP93XX_SYSCON_PWRCNT_DMA_M2P0 (1<<17)
128#define EP93XX_SYSCON_PWRCNT_DMA_M2P1 (1<<16)
129#define EP93XX_SYSCON_HALT EP93XX_SYSCON_REG(0x08)
130#define EP93XX_SYSCON_STANDBY EP93XX_SYSCON_REG(0x0c)
131#define EP93XX_SYSCON_CLKSET1 EP93XX_SYSCON_REG(0x20)
132#define EP93XX_SYSCON_CLKSET1_NBYP1 (1<<23)
133#define EP93XX_SYSCON_CLKSET2 EP93XX_SYSCON_REG(0x24)
134#define EP93XX_SYSCON_CLKSET2_NBYP2 (1<<19)
135#define EP93XX_SYSCON_CLKSET2_PLL2_EN (1<<18)
136#define EP93XX_SYSCON_DEVCFG EP93XX_SYSCON_REG(0x80)
137#define EP93XX_SYSCON_DEVCFG_SWRST (1<<31)
138#define EP93XX_SYSCON_DEVCFG_D1ONG (1<<30)
139#define EP93XX_SYSCON_DEVCFG_D0ONG (1<<29)
140#define EP93XX_SYSCON_DEVCFG_IONU2 (1<<28)
141#define EP93XX_SYSCON_DEVCFG_GONK (1<<27)
142#define EP93XX_SYSCON_DEVCFG_TONG (1<<26)
143#define EP93XX_SYSCON_DEVCFG_MONG (1<<25)
144#define EP93XX_SYSCON_DEVCFG_U3EN (1<<24)
145#define EP93XX_SYSCON_DEVCFG_CPENA (1<<23)
146#define EP93XX_SYSCON_DEVCFG_A2ONG (1<<22)
147#define EP93XX_SYSCON_DEVCFG_A1ONG (1<<21)
148#define EP93XX_SYSCON_DEVCFG_U2EN (1<<20)
149#define EP93XX_SYSCON_DEVCFG_EXVC (1<<19)
150#define EP93XX_SYSCON_DEVCFG_U1EN (1<<18)
151#define EP93XX_SYSCON_DEVCFG_TIN (1<<17)
152#define EP93XX_SYSCON_DEVCFG_HC3IN (1<<15)
153#define EP93XX_SYSCON_DEVCFG_HC3EN (1<<14)
154#define EP93XX_SYSCON_DEVCFG_HC1IN (1<<13)
155#define EP93XX_SYSCON_DEVCFG_HC1EN (1<<12)
156#define EP93XX_SYSCON_DEVCFG_HONIDE (1<<11)
157#define EP93XX_SYSCON_DEVCFG_GONIDE (1<<10)
158#define EP93XX_SYSCON_DEVCFG_PONG (1<<9)
159#define EP93XX_SYSCON_DEVCFG_EONIDE (1<<8)
160#define EP93XX_SYSCON_DEVCFG_I2SONSSP (1<<7)
161#define EP93XX_SYSCON_DEVCFG_I2SONAC97 (1<<6)
162#define EP93XX_SYSCON_DEVCFG_RASONP3 (1<<4)
163#define EP93XX_SYSCON_DEVCFG_RAS (1<<3)
164#define EP93XX_SYSCON_DEVCFG_ADCPD (1<<2)
165#define EP93XX_SYSCON_DEVCFG_KEYS (1<<1)
166#define EP93XX_SYSCON_DEVCFG_SHENA (1<<0)
167#define EP93XX_SYSCON_VIDCLKDIV EP93XX_SYSCON_REG(0x84)
168#define EP93XX_SYSCON_CLKDIV_ENABLE (1<<15)
169#define EP93XX_SYSCON_CLKDIV_ESEL (1<<14)
170#define EP93XX_SYSCON_CLKDIV_PSEL (1<<13)
171#define EP93XX_SYSCON_CLKDIV_PDIV_SHIFT 8
172#define EP93XX_SYSCON_I2SCLKDIV EP93XX_SYSCON_REG(0x8c)
173#define EP93XX_SYSCON_I2SCLKDIV_SENA (1<<31)
174#define EP93XX_SYSCON_I2SCLKDIV_ORIDE (1<<29)
175#define EP93XX_SYSCON_I2SCLKDIV_SPOL (1<<19)
176#define EP93XX_I2SCLKDIV_SDIV (1 << 16)
177#define EP93XX_I2SCLKDIV_LRDIV32 (0 << 17)
178#define EP93XX_I2SCLKDIV_LRDIV64 (1 << 17)
179#define EP93XX_I2SCLKDIV_LRDIV128 (2 << 17)
180#define EP93XX_I2SCLKDIV_LRDIV_MASK (3 << 17)
181#define EP93XX_SYSCON_KEYTCHCLKDIV EP93XX_SYSCON_REG(0x90)
182#define EP93XX_SYSCON_KEYTCHCLKDIV_TSEN (1<<31)
183#define EP93XX_SYSCON_KEYTCHCLKDIV_ADIV (1<<16)
184#define EP93XX_SYSCON_KEYTCHCLKDIV_KEN (1<<15)
185#define EP93XX_SYSCON_KEYTCHCLKDIV_KDIV (1<<0)
186#define EP93XX_SYSCON_SYSCFG EP93XX_SYSCON_REG(0x9c)
187#define EP93XX_SYSCON_SYSCFG_REV_MASK (0xf0000000)
188#define EP93XX_SYSCON_SYSCFG_REV_SHIFT (28)
189#define EP93XX_SYSCON_SYSCFG_SBOOT (1<<8)
190#define EP93XX_SYSCON_SYSCFG_LCSN7 (1<<7)
191#define EP93XX_SYSCON_SYSCFG_LCSN6 (1<<6)
192#define EP93XX_SYSCON_SYSCFG_LASDO (1<<5)
193#define EP93XX_SYSCON_SYSCFG_LEEDA (1<<4)
194#define EP93XX_SYSCON_SYSCFG_LEECLK (1<<3)
195#define EP93XX_SYSCON_SYSCFG_LCSN2 (1<<1)
196#define EP93XX_SYSCON_SYSCFG_LCSN1 (1<<0)
197#define EP93XX_SYSCON_SWLOCK EP93XX_SYSCON_REG(0xc0)
198
199/* EP93xx System Controller software locked register write */
200void ep93xx_syscon_swlocked_write(unsigned int val, void __iomem *reg);
201void ep93xx_devcfg_set_clear(unsigned int set_bits, unsigned int clear_bits);
202
203static inline void ep93xx_devcfg_set_bits(unsigned int bits)
204{
205 ep93xx_devcfg_set_clear(bits, 0x00);
206}
207
208static inline void ep93xx_devcfg_clear_bits(unsigned int bits)
209{
210 ep93xx_devcfg_set_clear(0x00, bits);
211}
212
213#endif /* _EP93XX_SOC_H */
diff --git a/arch/arm/mach-ep93xx/ts72xx.c b/arch/arm/mach-ep93xx/ts72xx.c
index 79f8ecf07a1..5ea790942e9 100644
--- a/arch/arm/mach-ep93xx/ts72xx.c
+++ b/arch/arm/mach-ep93xx/ts72xx.c
@@ -28,6 +28,7 @@
28#include <asm/mach/map.h> 28#include <asm/mach/map.h>
29#include <asm/mach/arch.h> 29#include <asm/mach/arch.h>
30 30
31#include "soc.h"
31 32
32static struct map_desc ts72xx_io_desc[] __initdata = { 33static struct map_desc ts72xx_io_desc[] __initdata = {
33 { 34 {
diff --git a/arch/arm/mach-ep93xx/vision_ep9307.c b/arch/arm/mach-ep93xx/vision_ep9307.c
index d67d0b4feb6..ba156eb225e 100644
--- a/arch/arm/mach-ep93xx/vision_ep9307.c
+++ b/arch/arm/mach-ep93xx/vision_ep9307.c
@@ -39,6 +39,8 @@
39#include <asm/mach/map.h> 39#include <asm/mach/map.h>
40#include <asm/mach/arch.h> 40#include <asm/mach/arch.h>
41 41
42#include "soc.h"
43
42/************************************************************************* 44/*************************************************************************
43 * Static I/O mappings for the FPGA 45 * Static I/O mappings for the FPGA
44 *************************************************************************/ 46 *************************************************************************/
diff --git a/arch/arm/mach-exynos/Kconfig b/arch/arm/mach-exynos/Kconfig
index dfad6538b27..0491ceef1cd 100644
--- a/arch/arm/mach-exynos/Kconfig
+++ b/arch/arm/mach-exynos/Kconfig
@@ -11,18 +11,19 @@ if ARCH_EXYNOS
11 11
12menu "SAMSUNG EXYNOS SoCs Support" 12menu "SAMSUNG EXYNOS SoCs Support"
13 13
14choice
15 prompt "EXYNOS System Type"
16 default ARCH_EXYNOS4
17
18config ARCH_EXYNOS4 14config ARCH_EXYNOS4
19 bool "SAMSUNG EXYNOS4" 15 bool "SAMSUNG EXYNOS4"
16 default y
20 select HAVE_SMP 17 select HAVE_SMP
21 select MIGHT_HAVE_CACHE_L2X0 18 select MIGHT_HAVE_CACHE_L2X0
22 help 19 help
23 Samsung EXYNOS4 SoCs based systems 20 Samsung EXYNOS4 SoCs based systems
24 21
25endchoice 22config ARCH_EXYNOS5
23 bool "SAMSUNG EXYNOS5"
24 select HAVE_SMP
25 help
26 Samsung EXYNOS5 (Cortex-A15) SoC based systems
26 27
27comment "EXYNOS SoCs" 28comment "EXYNOS SoCs"
28 29
@@ -42,6 +43,7 @@ config SOC_EXYNOS4212
42 bool "SAMSUNG EXYNOS4212" 43 bool "SAMSUNG EXYNOS4212"
43 default y 44 default y
44 depends on ARCH_EXYNOS4 45 depends on ARCH_EXYNOS4
46 select SAMSUNG_DMADEV
45 select S5P_PM if PM 47 select S5P_PM if PM
46 select S5P_SLEEP if PM 48 select S5P_SLEEP if PM
47 help 49 help
@@ -51,9 +53,17 @@ config SOC_EXYNOS4412
51 bool "SAMSUNG EXYNOS4412" 53 bool "SAMSUNG EXYNOS4412"
52 default y 54 default y
53 depends on ARCH_EXYNOS4 55 depends on ARCH_EXYNOS4
56 select SAMSUNG_DMADEV
54 help 57 help
55 Enable EXYNOS4412 SoC support 58 Enable EXYNOS4412 SoC support
56 59
60config SOC_EXYNOS5250
61 bool "SAMSUNG EXYNOS5250"
62 default y
63 depends on ARCH_EXYNOS5
64 help
65 Enable EXYNOS5250 SoC support
66
57config EXYNOS4_MCT 67config EXYNOS4_MCT
58 bool 68 bool
59 default y 69 default y
@@ -179,7 +189,9 @@ config MACH_SMDKV310
179 select S5P_DEV_FIMC1 189 select S5P_DEV_FIMC1
180 select S5P_DEV_FIMC2 190 select S5P_DEV_FIMC2
181 select S5P_DEV_FIMC3 191 select S5P_DEV_FIMC3
192 select S5P_DEV_G2D
182 select S5P_DEV_I2C_HDMIPHY 193 select S5P_DEV_I2C_HDMIPHY
194 select S5P_DEV_JPEG
183 select S5P_DEV_MFC 195 select S5P_DEV_MFC
184 select S5P_DEV_TV 196 select S5P_DEV_TV
185 select S5P_DEV_USB_EHCI 197 select S5P_DEV_USB_EHCI
@@ -225,7 +237,9 @@ config MACH_UNIVERSAL_C210
225 select S5P_DEV_FIMC1 237 select S5P_DEV_FIMC1
226 select S5P_DEV_FIMC2 238 select S5P_DEV_FIMC2
227 select S5P_DEV_FIMC3 239 select S5P_DEV_FIMC3
240 select S5P_DEV_G2D
228 select S5P_DEV_CSIS0 241 select S5P_DEV_CSIS0
242 select S5P_DEV_JPEG
229 select S5P_DEV_FIMD0 243 select S5P_DEV_FIMD0
230 select S3C_DEV_HSMMC 244 select S3C_DEV_HSMMC
231 select S3C_DEV_HSMMC2 245 select S3C_DEV_HSMMC2
@@ -262,11 +276,14 @@ config MACH_NURI
262 select S3C_DEV_I2C1 276 select S3C_DEV_I2C1
263 select S3C_DEV_I2C3 277 select S3C_DEV_I2C3
264 select S3C_DEV_I2C5 278 select S3C_DEV_I2C5
279 select S3C_DEV_I2C6
265 select S5P_DEV_CSIS0 280 select S5P_DEV_CSIS0
281 select S5P_DEV_JPEG
266 select S5P_DEV_FIMC0 282 select S5P_DEV_FIMC0
267 select S5P_DEV_FIMC1 283 select S5P_DEV_FIMC1
268 select S5P_DEV_FIMC2 284 select S5P_DEV_FIMC2
269 select S5P_DEV_FIMC3 285 select S5P_DEV_FIMC3
286 select S5P_DEV_G2D
270 select S5P_DEV_MFC 287 select S5P_DEV_MFC
271 select S5P_DEV_USB_EHCI 288 select S5P_DEV_USB_EHCI
272 select S5P_SETUP_MIPIPHY 289 select S5P_SETUP_MIPIPHY
@@ -276,6 +293,7 @@ config MACH_NURI
276 select EXYNOS4_SETUP_I2C1 293 select EXYNOS4_SETUP_I2C1
277 select EXYNOS4_SETUP_I2C3 294 select EXYNOS4_SETUP_I2C3
278 select EXYNOS4_SETUP_I2C5 295 select EXYNOS4_SETUP_I2C5
296 select EXYNOS4_SETUP_I2C6
279 select EXYNOS4_SETUP_SDHCI 297 select EXYNOS4_SETUP_SDHCI
280 select EXYNOS4_SETUP_USB_PHY 298 select EXYNOS4_SETUP_USB_PHY
281 select S5P_SETUP_MIPIPHY 299 select S5P_SETUP_MIPIPHY
@@ -296,7 +314,9 @@ config MACH_ORIGEN
296 select S5P_DEV_FIMC2 314 select S5P_DEV_FIMC2
297 select S5P_DEV_FIMC3 315 select S5P_DEV_FIMC3
298 select S5P_DEV_FIMD0 316 select S5P_DEV_FIMD0
317 select S5P_DEV_G2D
299 select S5P_DEV_I2C_HDMIPHY 318 select S5P_DEV_I2C_HDMIPHY
319 select S5P_DEV_JPEG
300 select S5P_DEV_MFC 320 select S5P_DEV_MFC
301 select S5P_DEV_TV 321 select S5P_DEV_TV
302 select S5P_DEV_USB_EHCI 322 select S5P_DEV_USB_EHCI
@@ -325,6 +345,7 @@ config MACH_SMDK4212
325 select SAMSUNG_DEV_BACKLIGHT 345 select SAMSUNG_DEV_BACKLIGHT
326 select SAMSUNG_DEV_KEYPAD 346 select SAMSUNG_DEV_KEYPAD
327 select SAMSUNG_DEV_PWM 347 select SAMSUNG_DEV_PWM
348 select EXYNOS4_DEV_DMA
328 select EXYNOS4_SETUP_I2C1 349 select EXYNOS4_SETUP_I2C1
329 select EXYNOS4_SETUP_I2C3 350 select EXYNOS4_SETUP_I2C3
330 select EXYNOS4_SETUP_I2C7 351 select EXYNOS4_SETUP_I2C7
@@ -343,7 +364,7 @@ config MACH_SMDK4412
343 Machine support for Samsung SMDK4412 364 Machine support for Samsung SMDK4412
344endif 365endif
345 366
346comment "Flattened Device Tree based board for Exynos4 based SoC" 367comment "Flattened Device Tree based board for EXYNOS SoCs"
347 368
348config MACH_EXYNOS4_DT 369config MACH_EXYNOS4_DT
349 bool "Samsung Exynos4 Machine using device tree" 370 bool "Samsung Exynos4 Machine using device tree"
@@ -357,6 +378,15 @@ config MACH_EXYNOS4_DT
357 Note: This is under development and not all peripherals can be supported 378 Note: This is under development and not all peripherals can be supported
358 with this machine file. 379 with this machine file.
359 380
381config MACH_EXYNOS5_DT
382 bool "SAMSUNG EXYNOS5 Machine using device tree"
383 select SOC_EXYNOS5250
384 select USE_OF
385 select ARM_AMBA
386 help
387 Machine support for Samsung Exynos4 machine with device tree enabled.
388 Select this if a fdt blob is available for the EXYNOS4 SoC based board.
389
360if ARCH_EXYNOS4 390if ARCH_EXYNOS4
361 391
362comment "Configuration for HSMMC 8-bit bus width" 392comment "Configuration for HSMMC 8-bit bus width"
diff --git a/arch/arm/mach-exynos/Makefile b/arch/arm/mach-exynos/Makefile
index d9191f9a7af..8631840d1b5 100644
--- a/arch/arm/mach-exynos/Makefile
+++ b/arch/arm/mach-exynos/Makefile
@@ -12,7 +12,9 @@ obj- :=
12 12
13# Core 13# Core
14 14
15obj-$(CONFIG_ARCH_EXYNOS4) += common.o clock.o 15obj-$(CONFIG_ARCH_EXYNOS) += common.o
16obj-$(CONFIG_ARCH_EXYNOS4) += clock-exynos4.o
17obj-$(CONFIG_ARCH_EXYNOS5) += clock-exynos5.o
16obj-$(CONFIG_CPU_EXYNOS4210) += clock-exynos4210.o 18obj-$(CONFIG_CPU_EXYNOS4210) += clock-exynos4210.o
17obj-$(CONFIG_SOC_EXYNOS4212) += clock-exynos4212.o 19obj-$(CONFIG_SOC_EXYNOS4212) += clock-exynos4212.o
18 20
@@ -41,9 +43,11 @@ obj-$(CONFIG_MACH_SMDK4212) += mach-smdk4x12.o
41obj-$(CONFIG_MACH_SMDK4412) += mach-smdk4x12.o 43obj-$(CONFIG_MACH_SMDK4412) += mach-smdk4x12.o
42 44
43obj-$(CONFIG_MACH_EXYNOS4_DT) += mach-exynos4-dt.o 45obj-$(CONFIG_MACH_EXYNOS4_DT) += mach-exynos4-dt.o
46obj-$(CONFIG_MACH_EXYNOS5_DT) += mach-exynos5-dt.o
44 47
45# device support 48# device support
46 49
50obj-y += dev-uart.o
47obj-$(CONFIG_ARCH_EXYNOS4) += dev-audio.o 51obj-$(CONFIG_ARCH_EXYNOS4) += dev-audio.o
48obj-$(CONFIG_EXYNOS4_DEV_AHCI) += dev-ahci.o 52obj-$(CONFIG_EXYNOS4_DEV_AHCI) += dev-ahci.o
49obj-$(CONFIG_EXYNOS4_DEV_SYSMMU) += dev-sysmmu.o 53obj-$(CONFIG_EXYNOS4_DEV_SYSMMU) += dev-sysmmu.o
@@ -51,7 +55,7 @@ obj-$(CONFIG_EXYNOS4_DEV_DWMCI) += dev-dwmci.o
51obj-$(CONFIG_EXYNOS4_DEV_DMA) += dma.o 55obj-$(CONFIG_EXYNOS4_DEV_DMA) += dma.o
52obj-$(CONFIG_EXYNOS4_DEV_USB_OHCI) += dev-ohci.o 56obj-$(CONFIG_EXYNOS4_DEV_USB_OHCI) += dev-ohci.o
53 57
54obj-$(CONFIG_ARCH_EXYNOS4) += setup-i2c0.o 58obj-$(CONFIG_ARCH_EXYNOS) += setup-i2c0.o
55obj-$(CONFIG_EXYNOS4_SETUP_FIMC) += setup-fimc.o 59obj-$(CONFIG_EXYNOS4_SETUP_FIMC) += setup-fimc.o
56obj-$(CONFIG_EXYNOS4_SETUP_FIMD0) += setup-fimd0.o 60obj-$(CONFIG_EXYNOS4_SETUP_FIMD0) += setup-fimd0.o
57obj-$(CONFIG_EXYNOS4_SETUP_I2C1) += setup-i2c1.o 61obj-$(CONFIG_EXYNOS4_SETUP_I2C1) += setup-i2c1.o
diff --git a/arch/arm/mach-exynos/clock-exynos4.c b/arch/arm/mach-exynos/clock-exynos4.c
new file mode 100644
index 00000000000..df54c2a9222
--- /dev/null
+++ b/arch/arm/mach-exynos/clock-exynos4.c
@@ -0,0 +1,1581 @@
1/*
2 * Copyright (c) 2010-2012 Samsung Electronics Co., Ltd.
3 * http://www.samsung.com
4 *
5 * EXYNOS4 - Clock support
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10*/
11
12#include <linux/kernel.h>
13#include <linux/err.h>
14#include <linux/io.h>
15#include <linux/syscore_ops.h>
16
17#include <plat/cpu-freq.h>
18#include <plat/clock.h>
19#include <plat/cpu.h>
20#include <plat/pll.h>
21#include <plat/s5p-clock.h>
22#include <plat/clock-clksrc.h>
23#include <plat/pm.h>
24
25#include <mach/map.h>
26#include <mach/regs-clock.h>
27#include <mach/sysmmu.h>
28
29#include "common.h"
30#include "clock-exynos4.h"
31
32#ifdef CONFIG_PM_SLEEP
33static struct sleep_save exynos4_clock_save[] = {
34 SAVE_ITEM(EXYNOS4_CLKDIV_LEFTBUS),
35 SAVE_ITEM(EXYNOS4_CLKGATE_IP_LEFTBUS),
36 SAVE_ITEM(EXYNOS4_CLKDIV_RIGHTBUS),
37 SAVE_ITEM(EXYNOS4_CLKGATE_IP_RIGHTBUS),
38 SAVE_ITEM(EXYNOS4_CLKSRC_TOP0),
39 SAVE_ITEM(EXYNOS4_CLKSRC_TOP1),
40 SAVE_ITEM(EXYNOS4_CLKSRC_CAM),
41 SAVE_ITEM(EXYNOS4_CLKSRC_TV),
42 SAVE_ITEM(EXYNOS4_CLKSRC_MFC),
43 SAVE_ITEM(EXYNOS4_CLKSRC_G3D),
44 SAVE_ITEM(EXYNOS4_CLKSRC_LCD0),
45 SAVE_ITEM(EXYNOS4_CLKSRC_MAUDIO),
46 SAVE_ITEM(EXYNOS4_CLKSRC_FSYS),
47 SAVE_ITEM(EXYNOS4_CLKSRC_PERIL0),
48 SAVE_ITEM(EXYNOS4_CLKSRC_PERIL1),
49 SAVE_ITEM(EXYNOS4_CLKDIV_CAM),
50 SAVE_ITEM(EXYNOS4_CLKDIV_TV),
51 SAVE_ITEM(EXYNOS4_CLKDIV_MFC),
52 SAVE_ITEM(EXYNOS4_CLKDIV_G3D),
53 SAVE_ITEM(EXYNOS4_CLKDIV_LCD0),
54 SAVE_ITEM(EXYNOS4_CLKDIV_MAUDIO),
55 SAVE_ITEM(EXYNOS4_CLKDIV_FSYS0),
56 SAVE_ITEM(EXYNOS4_CLKDIV_FSYS1),
57 SAVE_ITEM(EXYNOS4_CLKDIV_FSYS2),
58 SAVE_ITEM(EXYNOS4_CLKDIV_FSYS3),
59 SAVE_ITEM(EXYNOS4_CLKDIV_PERIL0),
60 SAVE_ITEM(EXYNOS4_CLKDIV_PERIL1),
61 SAVE_ITEM(EXYNOS4_CLKDIV_PERIL2),
62 SAVE_ITEM(EXYNOS4_CLKDIV_PERIL3),
63 SAVE_ITEM(EXYNOS4_CLKDIV_PERIL4),
64 SAVE_ITEM(EXYNOS4_CLKDIV_PERIL5),
65 SAVE_ITEM(EXYNOS4_CLKDIV_TOP),
66 SAVE_ITEM(EXYNOS4_CLKSRC_MASK_TOP),
67 SAVE_ITEM(EXYNOS4_CLKSRC_MASK_CAM),
68 SAVE_ITEM(EXYNOS4_CLKSRC_MASK_TV),
69 SAVE_ITEM(EXYNOS4_CLKSRC_MASK_LCD0),
70 SAVE_ITEM(EXYNOS4_CLKSRC_MASK_MAUDIO),
71 SAVE_ITEM(EXYNOS4_CLKSRC_MASK_FSYS),
72 SAVE_ITEM(EXYNOS4_CLKSRC_MASK_PERIL0),
73 SAVE_ITEM(EXYNOS4_CLKSRC_MASK_PERIL1),
74 SAVE_ITEM(EXYNOS4_CLKDIV2_RATIO),
75 SAVE_ITEM(EXYNOS4_CLKGATE_SCLKCAM),
76 SAVE_ITEM(EXYNOS4_CLKGATE_IP_CAM),
77 SAVE_ITEM(EXYNOS4_CLKGATE_IP_TV),
78 SAVE_ITEM(EXYNOS4_CLKGATE_IP_MFC),
79 SAVE_ITEM(EXYNOS4_CLKGATE_IP_G3D),
80 SAVE_ITEM(EXYNOS4_CLKGATE_IP_LCD0),
81 SAVE_ITEM(EXYNOS4_CLKGATE_IP_FSYS),
82 SAVE_ITEM(EXYNOS4_CLKGATE_IP_GPS),
83 SAVE_ITEM(EXYNOS4_CLKGATE_IP_PERIL),
84 SAVE_ITEM(EXYNOS4_CLKGATE_BLOCK),
85 SAVE_ITEM(EXYNOS4_CLKSRC_MASK_DMC),
86 SAVE_ITEM(EXYNOS4_CLKSRC_DMC),
87 SAVE_ITEM(EXYNOS4_CLKDIV_DMC0),
88 SAVE_ITEM(EXYNOS4_CLKDIV_DMC1),
89 SAVE_ITEM(EXYNOS4_CLKGATE_IP_DMC),
90 SAVE_ITEM(EXYNOS4_CLKSRC_CPU),
91 SAVE_ITEM(EXYNOS4_CLKDIV_CPU),
92 SAVE_ITEM(EXYNOS4_CLKDIV_CPU + 0x4),
93 SAVE_ITEM(EXYNOS4_CLKGATE_SCLKCPU),
94 SAVE_ITEM(EXYNOS4_CLKGATE_IP_CPU),
95};
96#endif
97
98static struct clk exynos4_clk_sclk_hdmi27m = {
99 .name = "sclk_hdmi27m",
100 .rate = 27000000,
101};
102
103static struct clk exynos4_clk_sclk_hdmiphy = {
104 .name = "sclk_hdmiphy",
105};
106
107static struct clk exynos4_clk_sclk_usbphy0 = {
108 .name = "sclk_usbphy0",
109 .rate = 27000000,
110};
111
112static struct clk exynos4_clk_sclk_usbphy1 = {
113 .name = "sclk_usbphy1",
114};
115
116static struct clk dummy_apb_pclk = {
117 .name = "apb_pclk",
118 .id = -1,
119};
120
121static int exynos4_clksrc_mask_top_ctrl(struct clk *clk, int enable)
122{
123 return s5p_gatectrl(EXYNOS4_CLKSRC_MASK_TOP, clk, enable);
124}
125
126static int exynos4_clksrc_mask_cam_ctrl(struct clk *clk, int enable)
127{
128 return s5p_gatectrl(EXYNOS4_CLKSRC_MASK_CAM, clk, enable);
129}
130
131static int exynos4_clksrc_mask_lcd0_ctrl(struct clk *clk, int enable)
132{
133 return s5p_gatectrl(EXYNOS4_CLKSRC_MASK_LCD0, clk, enable);
134}
135
136int exynos4_clksrc_mask_fsys_ctrl(struct clk *clk, int enable)
137{
138 return s5p_gatectrl(EXYNOS4_CLKSRC_MASK_FSYS, clk, enable);
139}
140
141static int exynos4_clksrc_mask_peril0_ctrl(struct clk *clk, int enable)
142{
143 return s5p_gatectrl(EXYNOS4_CLKSRC_MASK_PERIL0, clk, enable);
144}
145
146static int exynos4_clksrc_mask_peril1_ctrl(struct clk *clk, int enable)
147{
148 return s5p_gatectrl(EXYNOS4_CLKSRC_MASK_PERIL1, clk, enable);
149}
150
151static int exynos4_clk_ip_mfc_ctrl(struct clk *clk, int enable)
152{
153 return s5p_gatectrl(EXYNOS4_CLKGATE_IP_MFC, clk, enable);
154}
155
156static int exynos4_clksrc_mask_tv_ctrl(struct clk *clk, int enable)
157{
158 return s5p_gatectrl(EXYNOS4_CLKSRC_MASK_TV, clk, enable);
159}
160
161static int exynos4_clk_ip_cam_ctrl(struct clk *clk, int enable)
162{
163 return s5p_gatectrl(EXYNOS4_CLKGATE_IP_CAM, clk, enable);
164}
165
166static int exynos4_clk_ip_tv_ctrl(struct clk *clk, int enable)
167{
168 return s5p_gatectrl(EXYNOS4_CLKGATE_IP_TV, clk, enable);
169}
170
171static int exynos4_clk_ip_image_ctrl(struct clk *clk, int enable)
172{
173 return s5p_gatectrl(EXYNOS4_CLKGATE_IP_IMAGE, clk, enable);
174}
175
176static int exynos4_clk_ip_lcd0_ctrl(struct clk *clk, int enable)
177{
178 return s5p_gatectrl(EXYNOS4_CLKGATE_IP_LCD0, clk, enable);
179}
180
181int exynos4_clk_ip_lcd1_ctrl(struct clk *clk, int enable)
182{
183 return s5p_gatectrl(EXYNOS4210_CLKGATE_IP_LCD1, clk, enable);
184}
185
186int exynos4_clk_ip_fsys_ctrl(struct clk *clk, int enable)
187{
188 return s5p_gatectrl(EXYNOS4_CLKGATE_IP_FSYS, clk, enable);
189}
190
191static int exynos4_clk_ip_peril_ctrl(struct clk *clk, int enable)
192{
193 return s5p_gatectrl(EXYNOS4_CLKGATE_IP_PERIL, clk, enable);
194}
195
196static int exynos4_clk_ip_perir_ctrl(struct clk *clk, int enable)
197{
198 return s5p_gatectrl(EXYNOS4_CLKGATE_IP_PERIR, clk, enable);
199}
200
201static int exynos4_clk_hdmiphy_ctrl(struct clk *clk, int enable)
202{
203 return s5p_gatectrl(S5P_HDMI_PHY_CONTROL, clk, enable);
204}
205
206static int exynos4_clk_dac_ctrl(struct clk *clk, int enable)
207{
208 return s5p_gatectrl(S5P_DAC_PHY_CONTROL, clk, enable);
209}
210
211/* Core list of CMU_CPU side */
212
213static struct clksrc_clk exynos4_clk_mout_apll = {
214 .clk = {
215 .name = "mout_apll",
216 },
217 .sources = &clk_src_apll,
218 .reg_src = { .reg = EXYNOS4_CLKSRC_CPU, .shift = 0, .size = 1 },
219};
220
221static struct clksrc_clk exynos4_clk_sclk_apll = {
222 .clk = {
223 .name = "sclk_apll",
224 .parent = &exynos4_clk_mout_apll.clk,
225 },
226 .reg_div = { .reg = EXYNOS4_CLKDIV_CPU, .shift = 24, .size = 3 },
227};
228
229static struct clksrc_clk exynos4_clk_mout_epll = {
230 .clk = {
231 .name = "mout_epll",
232 },
233 .sources = &clk_src_epll,
234 .reg_src = { .reg = EXYNOS4_CLKSRC_TOP0, .shift = 4, .size = 1 },
235};
236
237struct clksrc_clk exynos4_clk_mout_mpll = {
238 .clk = {
239 .name = "mout_mpll",
240 },
241 .sources = &clk_src_mpll,
242
243 /* reg_src will be added in each SoCs' clock */
244};
245
246static struct clk *exynos4_clkset_moutcore_list[] = {
247 [0] = &exynos4_clk_mout_apll.clk,
248 [1] = &exynos4_clk_mout_mpll.clk,
249};
250
251static struct clksrc_sources exynos4_clkset_moutcore = {
252 .sources = exynos4_clkset_moutcore_list,
253 .nr_sources = ARRAY_SIZE(exynos4_clkset_moutcore_list),
254};
255
256static struct clksrc_clk exynos4_clk_moutcore = {
257 .clk = {
258 .name = "moutcore",
259 },
260 .sources = &exynos4_clkset_moutcore,
261 .reg_src = { .reg = EXYNOS4_CLKSRC_CPU, .shift = 16, .size = 1 },
262};
263
264static struct clksrc_clk exynos4_clk_coreclk = {
265 .clk = {
266 .name = "core_clk",
267 .parent = &exynos4_clk_moutcore.clk,
268 },
269 .reg_div = { .reg = EXYNOS4_CLKDIV_CPU, .shift = 0, .size = 3 },
270};
271
272static struct clksrc_clk exynos4_clk_armclk = {
273 .clk = {
274 .name = "armclk",
275 .parent = &exynos4_clk_coreclk.clk,
276 },
277};
278
279static struct clksrc_clk exynos4_clk_aclk_corem0 = {
280 .clk = {
281 .name = "aclk_corem0",
282 .parent = &exynos4_clk_coreclk.clk,
283 },
284 .reg_div = { .reg = EXYNOS4_CLKDIV_CPU, .shift = 4, .size = 3 },
285};
286
287static struct clksrc_clk exynos4_clk_aclk_cores = {
288 .clk = {
289 .name = "aclk_cores",
290 .parent = &exynos4_clk_coreclk.clk,
291 },
292 .reg_div = { .reg = EXYNOS4_CLKDIV_CPU, .shift = 4, .size = 3 },
293};
294
295static struct clksrc_clk exynos4_clk_aclk_corem1 = {
296 .clk = {
297 .name = "aclk_corem1",
298 .parent = &exynos4_clk_coreclk.clk,
299 },
300 .reg_div = { .reg = EXYNOS4_CLKDIV_CPU, .shift = 8, .size = 3 },
301};
302
303static struct clksrc_clk exynos4_clk_periphclk = {
304 .clk = {
305 .name = "periphclk",
306 .parent = &exynos4_clk_coreclk.clk,
307 },
308 .reg_div = { .reg = EXYNOS4_CLKDIV_CPU, .shift = 12, .size = 3 },
309};
310
311/* Core list of CMU_CORE side */
312
313static struct clk *exynos4_clkset_corebus_list[] = {
314 [0] = &exynos4_clk_mout_mpll.clk,
315 [1] = &exynos4_clk_sclk_apll.clk,
316};
317
318struct clksrc_sources exynos4_clkset_mout_corebus = {
319 .sources = exynos4_clkset_corebus_list,
320 .nr_sources = ARRAY_SIZE(exynos4_clkset_corebus_list),
321};
322
323static struct clksrc_clk exynos4_clk_mout_corebus = {
324 .clk = {
325 .name = "mout_corebus",
326 },
327 .sources = &exynos4_clkset_mout_corebus,
328 .reg_src = { .reg = EXYNOS4_CLKSRC_DMC, .shift = 4, .size = 1 },
329};
330
331static struct clksrc_clk exynos4_clk_sclk_dmc = {
332 .clk = {
333 .name = "sclk_dmc",
334 .parent = &exynos4_clk_mout_corebus.clk,
335 },
336 .reg_div = { .reg = EXYNOS4_CLKDIV_DMC0, .shift = 12, .size = 3 },
337};
338
339static struct clksrc_clk exynos4_clk_aclk_cored = {
340 .clk = {
341 .name = "aclk_cored",
342 .parent = &exynos4_clk_sclk_dmc.clk,
343 },
344 .reg_div = { .reg = EXYNOS4_CLKDIV_DMC0, .shift = 16, .size = 3 },
345};
346
347static struct clksrc_clk exynos4_clk_aclk_corep = {
348 .clk = {
349 .name = "aclk_corep",
350 .parent = &exynos4_clk_aclk_cored.clk,
351 },
352 .reg_div = { .reg = EXYNOS4_CLKDIV_DMC0, .shift = 20, .size = 3 },
353};
354
355static struct clksrc_clk exynos4_clk_aclk_acp = {
356 .clk = {
357 .name = "aclk_acp",
358 .parent = &exynos4_clk_mout_corebus.clk,
359 },
360 .reg_div = { .reg = EXYNOS4_CLKDIV_DMC0, .shift = 0, .size = 3 },
361};
362
363static struct clksrc_clk exynos4_clk_pclk_acp = {
364 .clk = {
365 .name = "pclk_acp",
366 .parent = &exynos4_clk_aclk_acp.clk,
367 },
368 .reg_div = { .reg = EXYNOS4_CLKDIV_DMC0, .shift = 4, .size = 3 },
369};
370
371/* Core list of CMU_TOP side */
372
373struct clk *exynos4_clkset_aclk_top_list[] = {
374 [0] = &exynos4_clk_mout_mpll.clk,
375 [1] = &exynos4_clk_sclk_apll.clk,
376};
377
378static struct clksrc_sources exynos4_clkset_aclk = {
379 .sources = exynos4_clkset_aclk_top_list,
380 .nr_sources = ARRAY_SIZE(exynos4_clkset_aclk_top_list),
381};
382
383static struct clksrc_clk exynos4_clk_aclk_200 = {
384 .clk = {
385 .name = "aclk_200",
386 },
387 .sources = &exynos4_clkset_aclk,
388 .reg_src = { .reg = EXYNOS4_CLKSRC_TOP0, .shift = 12, .size = 1 },
389 .reg_div = { .reg = EXYNOS4_CLKDIV_TOP, .shift = 0, .size = 3 },
390};
391
392static struct clksrc_clk exynos4_clk_aclk_100 = {
393 .clk = {
394 .name = "aclk_100",
395 },
396 .sources = &exynos4_clkset_aclk,
397 .reg_src = { .reg = EXYNOS4_CLKSRC_TOP0, .shift = 16, .size = 1 },
398 .reg_div = { .reg = EXYNOS4_CLKDIV_TOP, .shift = 4, .size = 4 },
399};
400
401static struct clksrc_clk exynos4_clk_aclk_160 = {
402 .clk = {
403 .name = "aclk_160",
404 },
405 .sources = &exynos4_clkset_aclk,
406 .reg_src = { .reg = EXYNOS4_CLKSRC_TOP0, .shift = 20, .size = 1 },
407 .reg_div = { .reg = EXYNOS4_CLKDIV_TOP, .shift = 8, .size = 3 },
408};
409
410struct clksrc_clk exynos4_clk_aclk_133 = {
411 .clk = {
412 .name = "aclk_133",
413 },
414 .sources = &exynos4_clkset_aclk,
415 .reg_src = { .reg = EXYNOS4_CLKSRC_TOP0, .shift = 24, .size = 1 },
416 .reg_div = { .reg = EXYNOS4_CLKDIV_TOP, .shift = 12, .size = 3 },
417};
418
419static struct clk *exynos4_clkset_vpllsrc_list[] = {
420 [0] = &clk_fin_vpll,
421 [1] = &exynos4_clk_sclk_hdmi27m,
422};
423
424static struct clksrc_sources exynos4_clkset_vpllsrc = {
425 .sources = exynos4_clkset_vpllsrc_list,
426 .nr_sources = ARRAY_SIZE(exynos4_clkset_vpllsrc_list),
427};
428
429static struct clksrc_clk exynos4_clk_vpllsrc = {
430 .clk = {
431 .name = "vpll_src",
432 .enable = exynos4_clksrc_mask_top_ctrl,
433 .ctrlbit = (1 << 0),
434 },
435 .sources = &exynos4_clkset_vpllsrc,
436 .reg_src = { .reg = EXYNOS4_CLKSRC_TOP1, .shift = 0, .size = 1 },
437};
438
439static struct clk *exynos4_clkset_sclk_vpll_list[] = {
440 [0] = &exynos4_clk_vpllsrc.clk,
441 [1] = &clk_fout_vpll,
442};
443
444static struct clksrc_sources exynos4_clkset_sclk_vpll = {
445 .sources = exynos4_clkset_sclk_vpll_list,
446 .nr_sources = ARRAY_SIZE(exynos4_clkset_sclk_vpll_list),
447};
448
449static struct clksrc_clk exynos4_clk_sclk_vpll = {
450 .clk = {
451 .name = "sclk_vpll",
452 },
453 .sources = &exynos4_clkset_sclk_vpll,
454 .reg_src = { .reg = EXYNOS4_CLKSRC_TOP0, .shift = 8, .size = 1 },
455};
456
457static struct clk exynos4_init_clocks_off[] = {
458 {
459 .name = "timers",
460 .parent = &exynos4_clk_aclk_100.clk,
461 .enable = exynos4_clk_ip_peril_ctrl,
462 .ctrlbit = (1<<24),
463 }, {
464 .name = "csis",
465 .devname = "s5p-mipi-csis.0",
466 .enable = exynos4_clk_ip_cam_ctrl,
467 .ctrlbit = (1 << 4),
468 }, {
469 .name = "csis",
470 .devname = "s5p-mipi-csis.1",
471 .enable = exynos4_clk_ip_cam_ctrl,
472 .ctrlbit = (1 << 5),
473 }, {
474 .name = "jpeg",
475 .id = 0,
476 .enable = exynos4_clk_ip_cam_ctrl,
477 .ctrlbit = (1 << 6),
478 }, {
479 .name = "fimc",
480 .devname = "exynos4-fimc.0",
481 .enable = exynos4_clk_ip_cam_ctrl,
482 .ctrlbit = (1 << 0),
483 }, {
484 .name = "fimc",
485 .devname = "exynos4-fimc.1",
486 .enable = exynos4_clk_ip_cam_ctrl,
487 .ctrlbit = (1 << 1),
488 }, {
489 .name = "fimc",
490 .devname = "exynos4-fimc.2",
491 .enable = exynos4_clk_ip_cam_ctrl,
492 .ctrlbit = (1 << 2),
493 }, {
494 .name = "fimc",
495 .devname = "exynos4-fimc.3",
496 .enable = exynos4_clk_ip_cam_ctrl,
497 .ctrlbit = (1 << 3),
498 }, {
499 .name = "hsmmc",
500 .devname = "s3c-sdhci.0",
501 .parent = &exynos4_clk_aclk_133.clk,
502 .enable = exynos4_clk_ip_fsys_ctrl,
503 .ctrlbit = (1 << 5),
504 }, {
505 .name = "hsmmc",
506 .devname = "s3c-sdhci.1",
507 .parent = &exynos4_clk_aclk_133.clk,
508 .enable = exynos4_clk_ip_fsys_ctrl,
509 .ctrlbit = (1 << 6),
510 }, {
511 .name = "hsmmc",
512 .devname = "s3c-sdhci.2",
513 .parent = &exynos4_clk_aclk_133.clk,
514 .enable = exynos4_clk_ip_fsys_ctrl,
515 .ctrlbit = (1 << 7),
516 }, {
517 .name = "hsmmc",
518 .devname = "s3c-sdhci.3",
519 .parent = &exynos4_clk_aclk_133.clk,
520 .enable = exynos4_clk_ip_fsys_ctrl,
521 .ctrlbit = (1 << 8),
522 }, {
523 .name = "dwmmc",
524 .parent = &exynos4_clk_aclk_133.clk,
525 .enable = exynos4_clk_ip_fsys_ctrl,
526 .ctrlbit = (1 << 9),
527 }, {
528 .name = "dac",
529 .devname = "s5p-sdo",
530 .enable = exynos4_clk_ip_tv_ctrl,
531 .ctrlbit = (1 << 2),
532 }, {
533 .name = "mixer",
534 .devname = "s5p-mixer",
535 .enable = exynos4_clk_ip_tv_ctrl,
536 .ctrlbit = (1 << 1),
537 }, {
538 .name = "vp",
539 .devname = "s5p-mixer",
540 .enable = exynos4_clk_ip_tv_ctrl,
541 .ctrlbit = (1 << 0),
542 }, {
543 .name = "hdmi",
544 .devname = "exynos4-hdmi",
545 .enable = exynos4_clk_ip_tv_ctrl,
546 .ctrlbit = (1 << 3),
547 }, {
548 .name = "hdmiphy",
549 .devname = "exynos4-hdmi",
550 .enable = exynos4_clk_hdmiphy_ctrl,
551 .ctrlbit = (1 << 0),
552 }, {
553 .name = "dacphy",
554 .devname = "s5p-sdo",
555 .enable = exynos4_clk_dac_ctrl,
556 .ctrlbit = (1 << 0),
557 }, {
558 .name = "adc",
559 .enable = exynos4_clk_ip_peril_ctrl,
560 .ctrlbit = (1 << 15),
561 }, {
562 .name = "keypad",
563 .enable = exynos4_clk_ip_perir_ctrl,
564 .ctrlbit = (1 << 16),
565 }, {
566 .name = "rtc",
567 .enable = exynos4_clk_ip_perir_ctrl,
568 .ctrlbit = (1 << 15),
569 }, {
570 .name = "watchdog",
571 .parent = &exynos4_clk_aclk_100.clk,
572 .enable = exynos4_clk_ip_perir_ctrl,
573 .ctrlbit = (1 << 14),
574 }, {
575 .name = "usbhost",
576 .enable = exynos4_clk_ip_fsys_ctrl ,
577 .ctrlbit = (1 << 12),
578 }, {
579 .name = "otg",
580 .enable = exynos4_clk_ip_fsys_ctrl,
581 .ctrlbit = (1 << 13),
582 }, {
583 .name = "spi",
584 .devname = "s3c64xx-spi.0",
585 .enable = exynos4_clk_ip_peril_ctrl,
586 .ctrlbit = (1 << 16),
587 }, {
588 .name = "spi",
589 .devname = "s3c64xx-spi.1",
590 .enable = exynos4_clk_ip_peril_ctrl,
591 .ctrlbit = (1 << 17),
592 }, {
593 .name = "spi",
594 .devname = "s3c64xx-spi.2",
595 .enable = exynos4_clk_ip_peril_ctrl,
596 .ctrlbit = (1 << 18),
597 }, {
598 .name = "iis",
599 .devname = "samsung-i2s.0",
600 .enable = exynos4_clk_ip_peril_ctrl,
601 .ctrlbit = (1 << 19),
602 }, {
603 .name = "iis",
604 .devname = "samsung-i2s.1",
605 .enable = exynos4_clk_ip_peril_ctrl,
606 .ctrlbit = (1 << 20),
607 }, {
608 .name = "iis",
609 .devname = "samsung-i2s.2",
610 .enable = exynos4_clk_ip_peril_ctrl,
611 .ctrlbit = (1 << 21),
612 }, {
613 .name = "ac97",
614 .devname = "samsung-ac97",
615 .enable = exynos4_clk_ip_peril_ctrl,
616 .ctrlbit = (1 << 27),
617 }, {
618 .name = "fimg2d",
619 .enable = exynos4_clk_ip_image_ctrl,
620 .ctrlbit = (1 << 0),
621 }, {
622 .name = "mfc",
623 .devname = "s5p-mfc",
624 .enable = exynos4_clk_ip_mfc_ctrl,
625 .ctrlbit = (1 << 0),
626 }, {
627 .name = "i2c",
628 .devname = "s3c2440-i2c.0",
629 .parent = &exynos4_clk_aclk_100.clk,
630 .enable = exynos4_clk_ip_peril_ctrl,
631 .ctrlbit = (1 << 6),
632 }, {
633 .name = "i2c",
634 .devname = "s3c2440-i2c.1",
635 .parent = &exynos4_clk_aclk_100.clk,
636 .enable = exynos4_clk_ip_peril_ctrl,
637 .ctrlbit = (1 << 7),
638 }, {
639 .name = "i2c",
640 .devname = "s3c2440-i2c.2",
641 .parent = &exynos4_clk_aclk_100.clk,
642 .enable = exynos4_clk_ip_peril_ctrl,
643 .ctrlbit = (1 << 8),
644 }, {
645 .name = "i2c",
646 .devname = "s3c2440-i2c.3",
647 .parent = &exynos4_clk_aclk_100.clk,
648 .enable = exynos4_clk_ip_peril_ctrl,
649 .ctrlbit = (1 << 9),
650 }, {
651 .name = "i2c",
652 .devname = "s3c2440-i2c.4",
653 .parent = &exynos4_clk_aclk_100.clk,
654 .enable = exynos4_clk_ip_peril_ctrl,
655 .ctrlbit = (1 << 10),
656 }, {
657 .name = "i2c",
658 .devname = "s3c2440-i2c.5",
659 .parent = &exynos4_clk_aclk_100.clk,
660 .enable = exynos4_clk_ip_peril_ctrl,
661 .ctrlbit = (1 << 11),
662 }, {
663 .name = "i2c",
664 .devname = "s3c2440-i2c.6",
665 .parent = &exynos4_clk_aclk_100.clk,
666 .enable = exynos4_clk_ip_peril_ctrl,
667 .ctrlbit = (1 << 12),
668 }, {
669 .name = "i2c",
670 .devname = "s3c2440-i2c.7",
671 .parent = &exynos4_clk_aclk_100.clk,
672 .enable = exynos4_clk_ip_peril_ctrl,
673 .ctrlbit = (1 << 13),
674 }, {
675 .name = "i2c",
676 .devname = "s3c2440-hdmiphy-i2c",
677 .parent = &exynos4_clk_aclk_100.clk,
678 .enable = exynos4_clk_ip_peril_ctrl,
679 .ctrlbit = (1 << 14),
680 }, {
681 .name = "SYSMMU_MDMA",
682 .enable = exynos4_clk_ip_image_ctrl,
683 .ctrlbit = (1 << 5),
684 }, {
685 .name = "SYSMMU_FIMC0",
686 .enable = exynos4_clk_ip_cam_ctrl,
687 .ctrlbit = (1 << 7),
688 }, {
689 .name = "SYSMMU_FIMC1",
690 .enable = exynos4_clk_ip_cam_ctrl,
691 .ctrlbit = (1 << 8),
692 }, {
693 .name = "SYSMMU_FIMC2",
694 .enable = exynos4_clk_ip_cam_ctrl,
695 .ctrlbit = (1 << 9),
696 }, {
697 .name = "SYSMMU_FIMC3",
698 .enable = exynos4_clk_ip_cam_ctrl,
699 .ctrlbit = (1 << 10),
700 }, {
701 .name = "SYSMMU_JPEG",
702 .enable = exynos4_clk_ip_cam_ctrl,
703 .ctrlbit = (1 << 11),
704 }, {
705 .name = "SYSMMU_FIMD0",
706 .enable = exynos4_clk_ip_lcd0_ctrl,
707 .ctrlbit = (1 << 4),
708 }, {
709 .name = "SYSMMU_FIMD1",
710 .enable = exynos4_clk_ip_lcd1_ctrl,
711 .ctrlbit = (1 << 4),
712 }, {
713 .name = "SYSMMU_PCIe",
714 .enable = exynos4_clk_ip_fsys_ctrl,
715 .ctrlbit = (1 << 18),
716 }, {
717 .name = "SYSMMU_G2D",
718 .enable = exynos4_clk_ip_image_ctrl,
719 .ctrlbit = (1 << 3),
720 }, {
721 .name = "SYSMMU_ROTATOR",
722 .enable = exynos4_clk_ip_image_ctrl,
723 .ctrlbit = (1 << 4),
724 }, {
725 .name = "SYSMMU_TV",
726 .enable = exynos4_clk_ip_tv_ctrl,
727 .ctrlbit = (1 << 4),
728 }, {
729 .name = "SYSMMU_MFC_L",
730 .enable = exynos4_clk_ip_mfc_ctrl,
731 .ctrlbit = (1 << 1),
732 }, {
733 .name = "SYSMMU_MFC_R",
734 .enable = exynos4_clk_ip_mfc_ctrl,
735 .ctrlbit = (1 << 2),
736 }
737};
738
739static struct clk exynos4_init_clocks_on[] = {
740 {
741 .name = "uart",
742 .devname = "s5pv210-uart.0",
743 .enable = exynos4_clk_ip_peril_ctrl,
744 .ctrlbit = (1 << 0),
745 }, {
746 .name = "uart",
747 .devname = "s5pv210-uart.1",
748 .enable = exynos4_clk_ip_peril_ctrl,
749 .ctrlbit = (1 << 1),
750 }, {
751 .name = "uart",
752 .devname = "s5pv210-uart.2",
753 .enable = exynos4_clk_ip_peril_ctrl,
754 .ctrlbit = (1 << 2),
755 }, {
756 .name = "uart",
757 .devname = "s5pv210-uart.3",
758 .enable = exynos4_clk_ip_peril_ctrl,
759 .ctrlbit = (1 << 3),
760 }, {
761 .name = "uart",
762 .devname = "s5pv210-uart.4",
763 .enable = exynos4_clk_ip_peril_ctrl,
764 .ctrlbit = (1 << 4),
765 }, {
766 .name = "uart",
767 .devname = "s5pv210-uart.5",
768 .enable = exynos4_clk_ip_peril_ctrl,
769 .ctrlbit = (1 << 5),
770 }
771};
772
773static struct clk exynos4_clk_pdma0 = {
774 .name = "dma",
775 .devname = "dma-pl330.0",
776 .enable = exynos4_clk_ip_fsys_ctrl,
777 .ctrlbit = (1 << 0),
778};
779
780static struct clk exynos4_clk_pdma1 = {
781 .name = "dma",
782 .devname = "dma-pl330.1",
783 .enable = exynos4_clk_ip_fsys_ctrl,
784 .ctrlbit = (1 << 1),
785};
786
787static struct clk exynos4_clk_mdma1 = {
788 .name = "dma",
789 .devname = "dma-pl330.2",
790 .enable = exynos4_clk_ip_image_ctrl,
791 .ctrlbit = ((1 << 8) | (1 << 5) | (1 << 2)),
792};
793
794static struct clk exynos4_clk_fimd0 = {
795 .name = "fimd",
796 .devname = "exynos4-fb.0",
797 .enable = exynos4_clk_ip_lcd0_ctrl,
798 .ctrlbit = (1 << 0),
799};
800
801struct clk *exynos4_clkset_group_list[] = {
802 [0] = &clk_ext_xtal_mux,
803 [1] = &clk_xusbxti,
804 [2] = &exynos4_clk_sclk_hdmi27m,
805 [3] = &exynos4_clk_sclk_usbphy0,
806 [4] = &exynos4_clk_sclk_usbphy1,
807 [5] = &exynos4_clk_sclk_hdmiphy,
808 [6] = &exynos4_clk_mout_mpll.clk,
809 [7] = &exynos4_clk_mout_epll.clk,
810 [8] = &exynos4_clk_sclk_vpll.clk,
811};
812
813struct clksrc_sources exynos4_clkset_group = {
814 .sources = exynos4_clkset_group_list,
815 .nr_sources = ARRAY_SIZE(exynos4_clkset_group_list),
816};
817
818static struct clk *exynos4_clkset_mout_g2d0_list[] = {
819 [0] = &exynos4_clk_mout_mpll.clk,
820 [1] = &exynos4_clk_sclk_apll.clk,
821};
822
823static struct clksrc_sources exynos4_clkset_mout_g2d0 = {
824 .sources = exynos4_clkset_mout_g2d0_list,
825 .nr_sources = ARRAY_SIZE(exynos4_clkset_mout_g2d0_list),
826};
827
828static struct clksrc_clk exynos4_clk_mout_g2d0 = {
829 .clk = {
830 .name = "mout_g2d0",
831 },
832 .sources = &exynos4_clkset_mout_g2d0,
833 .reg_src = { .reg = EXYNOS4_CLKSRC_IMAGE, .shift = 0, .size = 1 },
834};
835
836static struct clk *exynos4_clkset_mout_g2d1_list[] = {
837 [0] = &exynos4_clk_mout_epll.clk,
838 [1] = &exynos4_clk_sclk_vpll.clk,
839};
840
841static struct clksrc_sources exynos4_clkset_mout_g2d1 = {
842 .sources = exynos4_clkset_mout_g2d1_list,
843 .nr_sources = ARRAY_SIZE(exynos4_clkset_mout_g2d1_list),
844};
845
846static struct clksrc_clk exynos4_clk_mout_g2d1 = {
847 .clk = {
848 .name = "mout_g2d1",
849 },
850 .sources = &exynos4_clkset_mout_g2d1,
851 .reg_src = { .reg = EXYNOS4_CLKSRC_IMAGE, .shift = 4, .size = 1 },
852};
853
854static struct clk *exynos4_clkset_mout_g2d_list[] = {
855 [0] = &exynos4_clk_mout_g2d0.clk,
856 [1] = &exynos4_clk_mout_g2d1.clk,
857};
858
859static struct clksrc_sources exynos4_clkset_mout_g2d = {
860 .sources = exynos4_clkset_mout_g2d_list,
861 .nr_sources = ARRAY_SIZE(exynos4_clkset_mout_g2d_list),
862};
863
864static struct clk *exynos4_clkset_mout_mfc0_list[] = {
865 [0] = &exynos4_clk_mout_mpll.clk,
866 [1] = &exynos4_clk_sclk_apll.clk,
867};
868
869static struct clksrc_sources exynos4_clkset_mout_mfc0 = {
870 .sources = exynos4_clkset_mout_mfc0_list,
871 .nr_sources = ARRAY_SIZE(exynos4_clkset_mout_mfc0_list),
872};
873
874static struct clksrc_clk exynos4_clk_mout_mfc0 = {
875 .clk = {
876 .name = "mout_mfc0",
877 },
878 .sources = &exynos4_clkset_mout_mfc0,
879 .reg_src = { .reg = EXYNOS4_CLKSRC_MFC, .shift = 0, .size = 1 },
880};
881
882static struct clk *exynos4_clkset_mout_mfc1_list[] = {
883 [0] = &exynos4_clk_mout_epll.clk,
884 [1] = &exynos4_clk_sclk_vpll.clk,
885};
886
887static struct clksrc_sources exynos4_clkset_mout_mfc1 = {
888 .sources = exynos4_clkset_mout_mfc1_list,
889 .nr_sources = ARRAY_SIZE(exynos4_clkset_mout_mfc1_list),
890};
891
892static struct clksrc_clk exynos4_clk_mout_mfc1 = {
893 .clk = {
894 .name = "mout_mfc1",
895 },
896 .sources = &exynos4_clkset_mout_mfc1,
897 .reg_src = { .reg = EXYNOS4_CLKSRC_MFC, .shift = 4, .size = 1 },
898};
899
900static struct clk *exynos4_clkset_mout_mfc_list[] = {
901 [0] = &exynos4_clk_mout_mfc0.clk,
902 [1] = &exynos4_clk_mout_mfc1.clk,
903};
904
905static struct clksrc_sources exynos4_clkset_mout_mfc = {
906 .sources = exynos4_clkset_mout_mfc_list,
907 .nr_sources = ARRAY_SIZE(exynos4_clkset_mout_mfc_list),
908};
909
910static struct clk *exynos4_clkset_sclk_dac_list[] = {
911 [0] = &exynos4_clk_sclk_vpll.clk,
912 [1] = &exynos4_clk_sclk_hdmiphy,
913};
914
915static struct clksrc_sources exynos4_clkset_sclk_dac = {
916 .sources = exynos4_clkset_sclk_dac_list,
917 .nr_sources = ARRAY_SIZE(exynos4_clkset_sclk_dac_list),
918};
919
920static struct clksrc_clk exynos4_clk_sclk_dac = {
921 .clk = {
922 .name = "sclk_dac",
923 .enable = exynos4_clksrc_mask_tv_ctrl,
924 .ctrlbit = (1 << 8),
925 },
926 .sources = &exynos4_clkset_sclk_dac,
927 .reg_src = { .reg = EXYNOS4_CLKSRC_TV, .shift = 8, .size = 1 },
928};
929
930static struct clksrc_clk exynos4_clk_sclk_pixel = {
931 .clk = {
932 .name = "sclk_pixel",
933 .parent = &exynos4_clk_sclk_vpll.clk,
934 },
935 .reg_div = { .reg = EXYNOS4_CLKDIV_TV, .shift = 0, .size = 4 },
936};
937
938static struct clk *exynos4_clkset_sclk_hdmi_list[] = {
939 [0] = &exynos4_clk_sclk_pixel.clk,
940 [1] = &exynos4_clk_sclk_hdmiphy,
941};
942
943static struct clksrc_sources exynos4_clkset_sclk_hdmi = {
944 .sources = exynos4_clkset_sclk_hdmi_list,
945 .nr_sources = ARRAY_SIZE(exynos4_clkset_sclk_hdmi_list),
946};
947
948static struct clksrc_clk exynos4_clk_sclk_hdmi = {
949 .clk = {
950 .name = "sclk_hdmi",
951 .enable = exynos4_clksrc_mask_tv_ctrl,
952 .ctrlbit = (1 << 0),
953 },
954 .sources = &exynos4_clkset_sclk_hdmi,
955 .reg_src = { .reg = EXYNOS4_CLKSRC_TV, .shift = 0, .size = 1 },
956};
957
958static struct clk *exynos4_clkset_sclk_mixer_list[] = {
959 [0] = &exynos4_clk_sclk_dac.clk,
960 [1] = &exynos4_clk_sclk_hdmi.clk,
961};
962
963static struct clksrc_sources exynos4_clkset_sclk_mixer = {
964 .sources = exynos4_clkset_sclk_mixer_list,
965 .nr_sources = ARRAY_SIZE(exynos4_clkset_sclk_mixer_list),
966};
967
968static struct clksrc_clk exynos4_clk_sclk_mixer = {
969 .clk = {
970 .name = "sclk_mixer",
971 .enable = exynos4_clksrc_mask_tv_ctrl,
972 .ctrlbit = (1 << 4),
973 },
974 .sources = &exynos4_clkset_sclk_mixer,
975 .reg_src = { .reg = EXYNOS4_CLKSRC_TV, .shift = 4, .size = 1 },
976};
977
978static struct clksrc_clk *exynos4_sclk_tv[] = {
979 &exynos4_clk_sclk_dac,
980 &exynos4_clk_sclk_pixel,
981 &exynos4_clk_sclk_hdmi,
982 &exynos4_clk_sclk_mixer,
983};
984
985static struct clksrc_clk exynos4_clk_dout_mmc0 = {
986 .clk = {
987 .name = "dout_mmc0",
988 },
989 .sources = &exynos4_clkset_group,
990 .reg_src = { .reg = EXYNOS4_CLKSRC_FSYS, .shift = 0, .size = 4 },
991 .reg_div = { .reg = EXYNOS4_CLKDIV_FSYS1, .shift = 0, .size = 4 },
992};
993
994static struct clksrc_clk exynos4_clk_dout_mmc1 = {
995 .clk = {
996 .name = "dout_mmc1",
997 },
998 .sources = &exynos4_clkset_group,
999 .reg_src = { .reg = EXYNOS4_CLKSRC_FSYS, .shift = 4, .size = 4 },
1000 .reg_div = { .reg = EXYNOS4_CLKDIV_FSYS1, .shift = 16, .size = 4 },
1001};
1002
1003static struct clksrc_clk exynos4_clk_dout_mmc2 = {
1004 .clk = {
1005 .name = "dout_mmc2",
1006 },
1007 .sources = &exynos4_clkset_group,
1008 .reg_src = { .reg = EXYNOS4_CLKSRC_FSYS, .shift = 8, .size = 4 },
1009 .reg_div = { .reg = EXYNOS4_CLKDIV_FSYS2, .shift = 0, .size = 4 },
1010};
1011
1012static struct clksrc_clk exynos4_clk_dout_mmc3 = {
1013 .clk = {
1014 .name = "dout_mmc3",
1015 },
1016 .sources = &exynos4_clkset_group,
1017 .reg_src = { .reg = EXYNOS4_CLKSRC_FSYS, .shift = 12, .size = 4 },
1018 .reg_div = { .reg = EXYNOS4_CLKDIV_FSYS2, .shift = 16, .size = 4 },
1019};
1020
1021static struct clksrc_clk exynos4_clk_dout_mmc4 = {
1022 .clk = {
1023 .name = "dout_mmc4",
1024 },
1025 .sources = &exynos4_clkset_group,
1026 .reg_src = { .reg = EXYNOS4_CLKSRC_FSYS, .shift = 16, .size = 4 },
1027 .reg_div = { .reg = EXYNOS4_CLKDIV_FSYS3, .shift = 0, .size = 4 },
1028};
1029
1030static struct clksrc_clk exynos4_clksrcs[] = {
1031 {
1032 .clk = {
1033 .name = "sclk_pwm",
1034 .enable = exynos4_clksrc_mask_peril0_ctrl,
1035 .ctrlbit = (1 << 24),
1036 },
1037 .sources = &exynos4_clkset_group,
1038 .reg_src = { .reg = EXYNOS4_CLKSRC_PERIL0, .shift = 24, .size = 4 },
1039 .reg_div = { .reg = EXYNOS4_CLKDIV_PERIL3, .shift = 0, .size = 4 },
1040 }, {
1041 .clk = {
1042 .name = "sclk_csis",
1043 .devname = "s5p-mipi-csis.0",
1044 .enable = exynos4_clksrc_mask_cam_ctrl,
1045 .ctrlbit = (1 << 24),
1046 },
1047 .sources = &exynos4_clkset_group,
1048 .reg_src = { .reg = EXYNOS4_CLKSRC_CAM, .shift = 24, .size = 4 },
1049 .reg_div = { .reg = EXYNOS4_CLKDIV_CAM, .shift = 24, .size = 4 },
1050 }, {
1051 .clk = {
1052 .name = "sclk_csis",
1053 .devname = "s5p-mipi-csis.1",
1054 .enable = exynos4_clksrc_mask_cam_ctrl,
1055 .ctrlbit = (1 << 28),
1056 },
1057 .sources = &exynos4_clkset_group,
1058 .reg_src = { .reg = EXYNOS4_CLKSRC_CAM, .shift = 28, .size = 4 },
1059 .reg_div = { .reg = EXYNOS4_CLKDIV_CAM, .shift = 28, .size = 4 },
1060 }, {
1061 .clk = {
1062 .name = "sclk_cam0",
1063 .enable = exynos4_clksrc_mask_cam_ctrl,
1064 .ctrlbit = (1 << 16),
1065 },
1066 .sources = &exynos4_clkset_group,
1067 .reg_src = { .reg = EXYNOS4_CLKSRC_CAM, .shift = 16, .size = 4 },
1068 .reg_div = { .reg = EXYNOS4_CLKDIV_CAM, .shift = 16, .size = 4 },
1069 }, {
1070 .clk = {
1071 .name = "sclk_cam1",
1072 .enable = exynos4_clksrc_mask_cam_ctrl,
1073 .ctrlbit = (1 << 20),
1074 },
1075 .sources = &exynos4_clkset_group,
1076 .reg_src = { .reg = EXYNOS4_CLKSRC_CAM, .shift = 20, .size = 4 },
1077 .reg_div = { .reg = EXYNOS4_CLKDIV_CAM, .shift = 20, .size = 4 },
1078 }, {
1079 .clk = {
1080 .name = "sclk_fimc",
1081 .devname = "exynos4-fimc.0",
1082 .enable = exynos4_clksrc_mask_cam_ctrl,
1083 .ctrlbit = (1 << 0),
1084 },
1085 .sources = &exynos4_clkset_group,
1086 .reg_src = { .reg = EXYNOS4_CLKSRC_CAM, .shift = 0, .size = 4 },
1087 .reg_div = { .reg = EXYNOS4_CLKDIV_CAM, .shift = 0, .size = 4 },
1088 }, {
1089 .clk = {
1090 .name = "sclk_fimc",
1091 .devname = "exynos4-fimc.1",
1092 .enable = exynos4_clksrc_mask_cam_ctrl,
1093 .ctrlbit = (1 << 4),
1094 },
1095 .sources = &exynos4_clkset_group,
1096 .reg_src = { .reg = EXYNOS4_CLKSRC_CAM, .shift = 4, .size = 4 },
1097 .reg_div = { .reg = EXYNOS4_CLKDIV_CAM, .shift = 4, .size = 4 },
1098 }, {
1099 .clk = {
1100 .name = "sclk_fimc",
1101 .devname = "exynos4-fimc.2",
1102 .enable = exynos4_clksrc_mask_cam_ctrl,
1103 .ctrlbit = (1 << 8),
1104 },
1105 .sources = &exynos4_clkset_group,
1106 .reg_src = { .reg = EXYNOS4_CLKSRC_CAM, .shift = 8, .size = 4 },
1107 .reg_div = { .reg = EXYNOS4_CLKDIV_CAM, .shift = 8, .size = 4 },
1108 }, {
1109 .clk = {
1110 .name = "sclk_fimc",
1111 .devname = "exynos4-fimc.3",
1112 .enable = exynos4_clksrc_mask_cam_ctrl,
1113 .ctrlbit = (1 << 12),
1114 },
1115 .sources = &exynos4_clkset_group,
1116 .reg_src = { .reg = EXYNOS4_CLKSRC_CAM, .shift = 12, .size = 4 },
1117 .reg_div = { .reg = EXYNOS4_CLKDIV_CAM, .shift = 12, .size = 4 },
1118 }, {
1119 .clk = {
1120 .name = "sclk_fimd",
1121 .devname = "exynos4-fb.0",
1122 .enable = exynos4_clksrc_mask_lcd0_ctrl,
1123 .ctrlbit = (1 << 0),
1124 },
1125 .sources = &exynos4_clkset_group,
1126 .reg_src = { .reg = EXYNOS4_CLKSRC_LCD0, .shift = 0, .size = 4 },
1127 .reg_div = { .reg = EXYNOS4_CLKDIV_LCD0, .shift = 0, .size = 4 },
1128 }, {
1129 .clk = {
1130 .name = "sclk_fimg2d",
1131 },
1132 .sources = &exynos4_clkset_mout_g2d,
1133 .reg_src = { .reg = EXYNOS4_CLKSRC_IMAGE, .shift = 8, .size = 1 },
1134 .reg_div = { .reg = EXYNOS4_CLKDIV_IMAGE, .shift = 0, .size = 4 },
1135 }, {
1136 .clk = {
1137 .name = "sclk_mfc",
1138 .devname = "s5p-mfc",
1139 },
1140 .sources = &exynos4_clkset_mout_mfc,
1141 .reg_src = { .reg = EXYNOS4_CLKSRC_MFC, .shift = 8, .size = 1 },
1142 .reg_div = { .reg = EXYNOS4_CLKDIV_MFC, .shift = 0, .size = 4 },
1143 }, {
1144 .clk = {
1145 .name = "sclk_dwmmc",
1146 .parent = &exynos4_clk_dout_mmc4.clk,
1147 .enable = exynos4_clksrc_mask_fsys_ctrl,
1148 .ctrlbit = (1 << 16),
1149 },
1150 .reg_div = { .reg = EXYNOS4_CLKDIV_FSYS3, .shift = 8, .size = 8 },
1151 }
1152};
1153
1154static struct clksrc_clk exynos4_clk_sclk_uart0 = {
1155 .clk = {
1156 .name = "uclk1",
1157 .devname = "exynos4210-uart.0",
1158 .enable = exynos4_clksrc_mask_peril0_ctrl,
1159 .ctrlbit = (1 << 0),
1160 },
1161 .sources = &exynos4_clkset_group,
1162 .reg_src = { .reg = EXYNOS4_CLKSRC_PERIL0, .shift = 0, .size = 4 },
1163 .reg_div = { .reg = EXYNOS4_CLKDIV_PERIL0, .shift = 0, .size = 4 },
1164};
1165
1166static struct clksrc_clk exynos4_clk_sclk_uart1 = {
1167 .clk = {
1168 .name = "uclk1",
1169 .devname = "exynos4210-uart.1",
1170 .enable = exynos4_clksrc_mask_peril0_ctrl,
1171 .ctrlbit = (1 << 4),
1172 },
1173 .sources = &exynos4_clkset_group,
1174 .reg_src = { .reg = EXYNOS4_CLKSRC_PERIL0, .shift = 4, .size = 4 },
1175 .reg_div = { .reg = EXYNOS4_CLKDIV_PERIL0, .shift = 4, .size = 4 },
1176};
1177
1178static struct clksrc_clk exynos4_clk_sclk_uart2 = {
1179 .clk = {
1180 .name = "uclk1",
1181 .devname = "exynos4210-uart.2",
1182 .enable = exynos4_clksrc_mask_peril0_ctrl,
1183 .ctrlbit = (1 << 8),
1184 },
1185 .sources = &exynos4_clkset_group,
1186 .reg_src = { .reg = EXYNOS4_CLKSRC_PERIL0, .shift = 8, .size = 4 },
1187 .reg_div = { .reg = EXYNOS4_CLKDIV_PERIL0, .shift = 8, .size = 4 },
1188};
1189
1190static struct clksrc_clk exynos4_clk_sclk_uart3 = {
1191 .clk = {
1192 .name = "uclk1",
1193 .devname = "exynos4210-uart.3",
1194 .enable = exynos4_clksrc_mask_peril0_ctrl,
1195 .ctrlbit = (1 << 12),
1196 },
1197 .sources = &exynos4_clkset_group,
1198 .reg_src = { .reg = EXYNOS4_CLKSRC_PERIL0, .shift = 12, .size = 4 },
1199 .reg_div = { .reg = EXYNOS4_CLKDIV_PERIL0, .shift = 12, .size = 4 },
1200};
1201
1202static struct clksrc_clk exynos4_clk_sclk_mmc0 = {
1203 .clk = {
1204 .name = "sclk_mmc",
1205 .devname = "s3c-sdhci.0",
1206 .parent = &exynos4_clk_dout_mmc0.clk,
1207 .enable = exynos4_clksrc_mask_fsys_ctrl,
1208 .ctrlbit = (1 << 0),
1209 },
1210 .reg_div = { .reg = EXYNOS4_CLKDIV_FSYS1, .shift = 8, .size = 8 },
1211};
1212
1213static struct clksrc_clk exynos4_clk_sclk_mmc1 = {
1214 .clk = {
1215 .name = "sclk_mmc",
1216 .devname = "s3c-sdhci.1",
1217 .parent = &exynos4_clk_dout_mmc1.clk,
1218 .enable = exynos4_clksrc_mask_fsys_ctrl,
1219 .ctrlbit = (1 << 4),
1220 },
1221 .reg_div = { .reg = EXYNOS4_CLKDIV_FSYS1, .shift = 24, .size = 8 },
1222};
1223
1224static struct clksrc_clk exynos4_clk_sclk_mmc2 = {
1225 .clk = {
1226 .name = "sclk_mmc",
1227 .devname = "s3c-sdhci.2",
1228 .parent = &exynos4_clk_dout_mmc2.clk,
1229 .enable = exynos4_clksrc_mask_fsys_ctrl,
1230 .ctrlbit = (1 << 8),
1231 },
1232 .reg_div = { .reg = EXYNOS4_CLKDIV_FSYS2, .shift = 8, .size = 8 },
1233};
1234
1235static struct clksrc_clk exynos4_clk_sclk_mmc3 = {
1236 .clk = {
1237 .name = "sclk_mmc",
1238 .devname = "s3c-sdhci.3",
1239 .parent = &exynos4_clk_dout_mmc3.clk,
1240 .enable = exynos4_clksrc_mask_fsys_ctrl,
1241 .ctrlbit = (1 << 12),
1242 },
1243 .reg_div = { .reg = EXYNOS4_CLKDIV_FSYS2, .shift = 24, .size = 8 },
1244};
1245
1246static struct clksrc_clk exynos4_clk_sclk_spi0 = {
1247 .clk = {
1248 .name = "sclk_spi",
1249 .devname = "s3c64xx-spi.0",
1250 .enable = exynos4_clksrc_mask_peril1_ctrl,
1251 .ctrlbit = (1 << 16),
1252 },
1253 .sources = &exynos4_clkset_group,
1254 .reg_src = { .reg = EXYNOS4_CLKSRC_PERIL1, .shift = 16, .size = 4 },
1255 .reg_div = { .reg = EXYNOS4_CLKDIV_PERIL1, .shift = 0, .size = 4 },
1256};
1257
1258static struct clksrc_clk exynos4_clk_sclk_spi1 = {
1259 .clk = {
1260 .name = "sclk_spi",
1261 .devname = "s3c64xx-spi.1",
1262 .enable = exynos4_clksrc_mask_peril1_ctrl,
1263 .ctrlbit = (1 << 20),
1264 },
1265 .sources = &exynos4_clkset_group,
1266 .reg_src = { .reg = EXYNOS4_CLKSRC_PERIL1, .shift = 20, .size = 4 },
1267 .reg_div = { .reg = EXYNOS4_CLKDIV_PERIL1, .shift = 16, .size = 4 },
1268};
1269
1270static struct clksrc_clk exynos4_clk_sclk_spi2 = {
1271 .clk = {
1272 .name = "sclk_spi",
1273 .devname = "s3c64xx-spi.2",
1274 .enable = exynos4_clksrc_mask_peril1_ctrl,
1275 .ctrlbit = (1 << 24),
1276 },
1277 .sources = &exynos4_clkset_group,
1278 .reg_src = { .reg = EXYNOS4_CLKSRC_PERIL1, .shift = 24, .size = 4 },
1279 .reg_div = { .reg = EXYNOS4_CLKDIV_PERIL2, .shift = 0, .size = 4 },
1280};
1281
1282/* Clock initialization code */
1283static struct clksrc_clk *exynos4_sysclks[] = {
1284 &exynos4_clk_mout_apll,
1285 &exynos4_clk_sclk_apll,
1286 &exynos4_clk_mout_epll,
1287 &exynos4_clk_mout_mpll,
1288 &exynos4_clk_moutcore,
1289 &exynos4_clk_coreclk,
1290 &exynos4_clk_armclk,
1291 &exynos4_clk_aclk_corem0,
1292 &exynos4_clk_aclk_cores,
1293 &exynos4_clk_aclk_corem1,
1294 &exynos4_clk_periphclk,
1295 &exynos4_clk_mout_corebus,
1296 &exynos4_clk_sclk_dmc,
1297 &exynos4_clk_aclk_cored,
1298 &exynos4_clk_aclk_corep,
1299 &exynos4_clk_aclk_acp,
1300 &exynos4_clk_pclk_acp,
1301 &exynos4_clk_vpllsrc,
1302 &exynos4_clk_sclk_vpll,
1303 &exynos4_clk_aclk_200,
1304 &exynos4_clk_aclk_100,
1305 &exynos4_clk_aclk_160,
1306 &exynos4_clk_aclk_133,
1307 &exynos4_clk_dout_mmc0,
1308 &exynos4_clk_dout_mmc1,
1309 &exynos4_clk_dout_mmc2,
1310 &exynos4_clk_dout_mmc3,
1311 &exynos4_clk_dout_mmc4,
1312 &exynos4_clk_mout_mfc0,
1313 &exynos4_clk_mout_mfc1,
1314};
1315
1316static struct clk *exynos4_clk_cdev[] = {
1317 &exynos4_clk_pdma0,
1318 &exynos4_clk_pdma1,
1319 &exynos4_clk_mdma1,
1320 &exynos4_clk_fimd0,
1321};
1322
1323static struct clksrc_clk *exynos4_clksrc_cdev[] = {
1324 &exynos4_clk_sclk_uart0,
1325 &exynos4_clk_sclk_uart1,
1326 &exynos4_clk_sclk_uart2,
1327 &exynos4_clk_sclk_uart3,
1328 &exynos4_clk_sclk_mmc0,
1329 &exynos4_clk_sclk_mmc1,
1330 &exynos4_clk_sclk_mmc2,
1331 &exynos4_clk_sclk_mmc3,
1332 &exynos4_clk_sclk_spi0,
1333 &exynos4_clk_sclk_spi1,
1334 &exynos4_clk_sclk_spi2,
1335
1336};
1337
1338static struct clk_lookup exynos4_clk_lookup[] = {
1339 CLKDEV_INIT("exynos4210-uart.0", "clk_uart_baud0", &exynos4_clk_sclk_uart0.clk),
1340 CLKDEV_INIT("exynos4210-uart.1", "clk_uart_baud0", &exynos4_clk_sclk_uart1.clk),
1341 CLKDEV_INIT("exynos4210-uart.2", "clk_uart_baud0", &exynos4_clk_sclk_uart2.clk),
1342 CLKDEV_INIT("exynos4210-uart.3", "clk_uart_baud0", &exynos4_clk_sclk_uart3.clk),
1343 CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.2", &exynos4_clk_sclk_mmc0.clk),
1344 CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.2", &exynos4_clk_sclk_mmc1.clk),
1345 CLKDEV_INIT("s3c-sdhci.2", "mmc_busclk.2", &exynos4_clk_sclk_mmc2.clk),
1346 CLKDEV_INIT("s3c-sdhci.3", "mmc_busclk.2", &exynos4_clk_sclk_mmc3.clk),
1347 CLKDEV_INIT("exynos4-fb.0", "lcd", &exynos4_clk_fimd0),
1348 CLKDEV_INIT("dma-pl330.0", "apb_pclk", &exynos4_clk_pdma0),
1349 CLKDEV_INIT("dma-pl330.1", "apb_pclk", &exynos4_clk_pdma1),
1350 CLKDEV_INIT("dma-pl330.2", "apb_pclk", &exynos4_clk_mdma1),
1351 CLKDEV_INIT("s3c64xx-spi.0", "spi_busclk0", &exynos4_clk_sclk_spi0.clk),
1352 CLKDEV_INIT("s3c64xx-spi.1", "spi_busclk0", &exynos4_clk_sclk_spi1.clk),
1353 CLKDEV_INIT("s3c64xx-spi.2", "spi_busclk0", &exynos4_clk_sclk_spi2.clk),
1354};
1355
1356static int xtal_rate;
1357
1358static unsigned long exynos4_fout_apll_get_rate(struct clk *clk)
1359{
1360 if (soc_is_exynos4210())
1361 return s5p_get_pll45xx(xtal_rate, __raw_readl(EXYNOS4_APLL_CON0),
1362 pll_4508);
1363 else if (soc_is_exynos4212() || soc_is_exynos4412())
1364 return s5p_get_pll35xx(xtal_rate, __raw_readl(EXYNOS4_APLL_CON0));
1365 else
1366 return 0;
1367}
1368
1369static struct clk_ops exynos4_fout_apll_ops = {
1370 .get_rate = exynos4_fout_apll_get_rate,
1371};
1372
1373static u32 exynos4_vpll_div[][8] = {
1374 { 54000000, 3, 53, 3, 1024, 0, 17, 0 },
1375 { 108000000, 3, 53, 2, 1024, 0, 17, 0 },
1376};
1377
1378static unsigned long exynos4_vpll_get_rate(struct clk *clk)
1379{
1380 return clk->rate;
1381}
1382
1383static int exynos4_vpll_set_rate(struct clk *clk, unsigned long rate)
1384{
1385 unsigned int vpll_con0, vpll_con1 = 0;
1386 unsigned int i;
1387
1388 /* Return if nothing changed */
1389 if (clk->rate == rate)
1390 return 0;
1391
1392 vpll_con0 = __raw_readl(EXYNOS4_VPLL_CON0);
1393 vpll_con0 &= ~(0x1 << 27 | \
1394 PLL90XX_MDIV_MASK << PLL46XX_MDIV_SHIFT | \
1395 PLL90XX_PDIV_MASK << PLL46XX_PDIV_SHIFT | \
1396 PLL90XX_SDIV_MASK << PLL46XX_SDIV_SHIFT);
1397
1398 vpll_con1 = __raw_readl(EXYNOS4_VPLL_CON1);
1399 vpll_con1 &= ~(PLL46XX_MRR_MASK << PLL46XX_MRR_SHIFT | \
1400 PLL46XX_MFR_MASK << PLL46XX_MFR_SHIFT | \
1401 PLL4650C_KDIV_MASK << PLL46XX_KDIV_SHIFT);
1402
1403 for (i = 0; i < ARRAY_SIZE(exynos4_vpll_div); i++) {
1404 if (exynos4_vpll_div[i][0] == rate) {
1405 vpll_con0 |= exynos4_vpll_div[i][1] << PLL46XX_PDIV_SHIFT;
1406 vpll_con0 |= exynos4_vpll_div[i][2] << PLL46XX_MDIV_SHIFT;
1407 vpll_con0 |= exynos4_vpll_div[i][3] << PLL46XX_SDIV_SHIFT;
1408 vpll_con1 |= exynos4_vpll_div[i][4] << PLL46XX_KDIV_SHIFT;
1409 vpll_con1 |= exynos4_vpll_div[i][5] << PLL46XX_MFR_SHIFT;
1410 vpll_con1 |= exynos4_vpll_div[i][6] << PLL46XX_MRR_SHIFT;
1411 vpll_con0 |= exynos4_vpll_div[i][7] << 27;
1412 break;
1413 }
1414 }
1415
1416 if (i == ARRAY_SIZE(exynos4_vpll_div)) {
1417 printk(KERN_ERR "%s: Invalid Clock VPLL Frequency\n",
1418 __func__);
1419 return -EINVAL;
1420 }
1421
1422 __raw_writel(vpll_con0, EXYNOS4_VPLL_CON0);
1423 __raw_writel(vpll_con1, EXYNOS4_VPLL_CON1);
1424
1425 /* Wait for VPLL lock */
1426 while (!(__raw_readl(EXYNOS4_VPLL_CON0) & (1 << PLL46XX_LOCKED_SHIFT)))
1427 continue;
1428
1429 clk->rate = rate;
1430 return 0;
1431}
1432
1433static struct clk_ops exynos4_vpll_ops = {
1434 .get_rate = exynos4_vpll_get_rate,
1435 .set_rate = exynos4_vpll_set_rate,
1436};
1437
1438void __init_or_cpufreq exynos4_setup_clocks(void)
1439{
1440 struct clk *xtal_clk;
1441 unsigned long apll = 0;
1442 unsigned long mpll = 0;
1443 unsigned long epll = 0;
1444 unsigned long vpll = 0;
1445 unsigned long vpllsrc;
1446 unsigned long xtal;
1447 unsigned long armclk;
1448 unsigned long sclk_dmc;
1449 unsigned long aclk_200;
1450 unsigned long aclk_100;
1451 unsigned long aclk_160;
1452 unsigned long aclk_133;
1453 unsigned int ptr;
1454
1455 printk(KERN_DEBUG "%s: registering clocks\n", __func__);
1456
1457 xtal_clk = clk_get(NULL, "xtal");
1458 BUG_ON(IS_ERR(xtal_clk));
1459
1460 xtal = clk_get_rate(xtal_clk);
1461
1462 xtal_rate = xtal;
1463
1464 clk_put(xtal_clk);
1465
1466 printk(KERN_DEBUG "%s: xtal is %ld\n", __func__, xtal);
1467
1468 if (soc_is_exynos4210()) {
1469 apll = s5p_get_pll45xx(xtal, __raw_readl(EXYNOS4_APLL_CON0),
1470 pll_4508);
1471 mpll = s5p_get_pll45xx(xtal, __raw_readl(EXYNOS4_MPLL_CON0),
1472 pll_4508);
1473 epll = s5p_get_pll46xx(xtal, __raw_readl(EXYNOS4_EPLL_CON0),
1474 __raw_readl(EXYNOS4_EPLL_CON1), pll_4600);
1475
1476 vpllsrc = clk_get_rate(&exynos4_clk_vpllsrc.clk);
1477 vpll = s5p_get_pll46xx(vpllsrc, __raw_readl(EXYNOS4_VPLL_CON0),
1478 __raw_readl(EXYNOS4_VPLL_CON1), pll_4650c);
1479 } else if (soc_is_exynos4212() || soc_is_exynos4412()) {
1480 apll = s5p_get_pll35xx(xtal, __raw_readl(EXYNOS4_APLL_CON0));
1481 mpll = s5p_get_pll35xx(xtal, __raw_readl(EXYNOS4_MPLL_CON0));
1482 epll = s5p_get_pll36xx(xtal, __raw_readl(EXYNOS4_EPLL_CON0),
1483 __raw_readl(EXYNOS4_EPLL_CON1));
1484
1485 vpllsrc = clk_get_rate(&exynos4_clk_vpllsrc.clk);
1486 vpll = s5p_get_pll36xx(vpllsrc, __raw_readl(EXYNOS4_VPLL_CON0),
1487 __raw_readl(EXYNOS4_VPLL_CON1));
1488 } else {
1489 /* nothing */
1490 }
1491
1492 clk_fout_apll.ops = &exynos4_fout_apll_ops;
1493 clk_fout_mpll.rate = mpll;
1494 clk_fout_epll.rate = epll;
1495 clk_fout_vpll.ops = &exynos4_vpll_ops;
1496 clk_fout_vpll.rate = vpll;
1497
1498 printk(KERN_INFO "EXYNOS4: PLL settings, A=%ld, M=%ld, E=%ld V=%ld",
1499 apll, mpll, epll, vpll);
1500
1501 armclk = clk_get_rate(&exynos4_clk_armclk.clk);
1502 sclk_dmc = clk_get_rate(&exynos4_clk_sclk_dmc.clk);
1503
1504 aclk_200 = clk_get_rate(&exynos4_clk_aclk_200.clk);
1505 aclk_100 = clk_get_rate(&exynos4_clk_aclk_100.clk);
1506 aclk_160 = clk_get_rate(&exynos4_clk_aclk_160.clk);
1507 aclk_133 = clk_get_rate(&exynos4_clk_aclk_133.clk);
1508
1509 printk(KERN_INFO "EXYNOS4: ARMCLK=%ld, DMC=%ld, ACLK200=%ld\n"
1510 "ACLK100=%ld, ACLK160=%ld, ACLK133=%ld\n",
1511 armclk, sclk_dmc, aclk_200,
1512 aclk_100, aclk_160, aclk_133);
1513
1514 clk_f.rate = armclk;
1515 clk_h.rate = sclk_dmc;
1516 clk_p.rate = aclk_100;
1517
1518 for (ptr = 0; ptr < ARRAY_SIZE(exynos4_clksrcs); ptr++)
1519 s3c_set_clksrc(&exynos4_clksrcs[ptr], true);
1520}
1521
1522static struct clk *exynos4_clks[] __initdata = {
1523 &exynos4_clk_sclk_hdmi27m,
1524 &exynos4_clk_sclk_hdmiphy,
1525 &exynos4_clk_sclk_usbphy0,
1526 &exynos4_clk_sclk_usbphy1,
1527};
1528
1529#ifdef CONFIG_PM_SLEEP
1530static int exynos4_clock_suspend(void)
1531{
1532 s3c_pm_do_save(exynos4_clock_save, ARRAY_SIZE(exynos4_clock_save));
1533 return 0;
1534}
1535
1536static void exynos4_clock_resume(void)
1537{
1538 s3c_pm_do_restore_core(exynos4_clock_save, ARRAY_SIZE(exynos4_clock_save));
1539}
1540
1541#else
1542#define exynos4_clock_suspend NULL
1543#define exynos4_clock_resume NULL
1544#endif
1545
1546static struct syscore_ops exynos4_clock_syscore_ops = {
1547 .suspend = exynos4_clock_suspend,
1548 .resume = exynos4_clock_resume,
1549};
1550
1551void __init exynos4_register_clocks(void)
1552{
1553 int ptr;
1554
1555 s3c24xx_register_clocks(exynos4_clks, ARRAY_SIZE(exynos4_clks));
1556
1557 for (ptr = 0; ptr < ARRAY_SIZE(exynos4_sysclks); ptr++)
1558 s3c_register_clksrc(exynos4_sysclks[ptr], 1);
1559
1560 for (ptr = 0; ptr < ARRAY_SIZE(exynos4_sclk_tv); ptr++)
1561 s3c_register_clksrc(exynos4_sclk_tv[ptr], 1);
1562
1563 for (ptr = 0; ptr < ARRAY_SIZE(exynos4_clksrc_cdev); ptr++)
1564 s3c_register_clksrc(exynos4_clksrc_cdev[ptr], 1);
1565
1566 s3c_register_clksrc(exynos4_clksrcs, ARRAY_SIZE(exynos4_clksrcs));
1567 s3c_register_clocks(exynos4_init_clocks_on, ARRAY_SIZE(exynos4_init_clocks_on));
1568
1569 s3c24xx_register_clocks(exynos4_clk_cdev, ARRAY_SIZE(exynos4_clk_cdev));
1570 for (ptr = 0; ptr < ARRAY_SIZE(exynos4_clk_cdev); ptr++)
1571 s3c_disable_clocks(exynos4_clk_cdev[ptr], 1);
1572
1573 s3c_register_clocks(exynos4_init_clocks_off, ARRAY_SIZE(exynos4_init_clocks_off));
1574 s3c_disable_clocks(exynos4_init_clocks_off, ARRAY_SIZE(exynos4_init_clocks_off));
1575 clkdev_add_table(exynos4_clk_lookup, ARRAY_SIZE(exynos4_clk_lookup));
1576
1577 register_syscore_ops(&exynos4_clock_syscore_ops);
1578 s3c24xx_register_clock(&dummy_apb_pclk);
1579
1580 s3c_pwmclk_init();
1581}
diff --git a/arch/arm/mach-exynos/clock-exynos4.h b/arch/arm/mach-exynos/clock-exynos4.h
new file mode 100644
index 00000000000..cb71c29c14d
--- /dev/null
+++ b/arch/arm/mach-exynos/clock-exynos4.h
@@ -0,0 +1,30 @@
1/*
2 * Copyright (c) 2011-2012 Samsung Electronics Co., Ltd.
3 * http://www.samsung.com
4 *
5 * Header file for exynos4 clock support
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10*/
11
12#ifndef __ASM_ARCH_CLOCK_H
13#define __ASM_ARCH_CLOCK_H __FILE__
14
15#include <linux/clk.h>
16
17extern struct clksrc_clk exynos4_clk_aclk_133;
18extern struct clksrc_clk exynos4_clk_mout_mpll;
19
20extern struct clksrc_sources exynos4_clkset_mout_corebus;
21extern struct clksrc_sources exynos4_clkset_group;
22
23extern struct clk *exynos4_clkset_aclk_top_list[];
24extern struct clk *exynos4_clkset_group_list[];
25
26extern int exynos4_clksrc_mask_fsys_ctrl(struct clk *clk, int enable);
27extern int exynos4_clk_ip_fsys_ctrl(struct clk *clk, int enable);
28extern int exynos4_clk_ip_lcd1_ctrl(struct clk *clk, int enable);
29
30#endif /* __ASM_ARCH_CLOCK_H */
diff --git a/arch/arm/mach-exynos/clock-exynos4210.c b/arch/arm/mach-exynos/clock-exynos4210.c
index 13312ccb2d9..3b131e4b6ef 100644
--- a/arch/arm/mach-exynos/clock-exynos4210.c
+++ b/arch/arm/mach-exynos/clock-exynos4210.c
@@ -1,7 +1,5 @@
1/* 1/*
2 * linux/arch/arm/mach-exynos4/clock-exynos4210.c 2 * Copyright (c) 2011-2012 Samsung Electronics Co., Ltd.
3 *
4 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com 3 * http://www.samsung.com
6 * 4 *
7 * EXYNOS4210 - Clock support 5 * EXYNOS4210 - Clock support
@@ -28,20 +26,20 @@
28#include <mach/hardware.h> 26#include <mach/hardware.h>
29#include <mach/map.h> 27#include <mach/map.h>
30#include <mach/regs-clock.h> 28#include <mach/regs-clock.h>
31#include <mach/exynos4-clock.h>
32 29
33#include "common.h" 30#include "common.h"
31#include "clock-exynos4.h"
34 32
35#ifdef CONFIG_PM_SLEEP 33#ifdef CONFIG_PM_SLEEP
36static struct sleep_save exynos4210_clock_save[] = { 34static struct sleep_save exynos4210_clock_save[] = {
37 SAVE_ITEM(S5P_CLKSRC_IMAGE), 35 SAVE_ITEM(EXYNOS4_CLKSRC_IMAGE),
38 SAVE_ITEM(S5P_CLKSRC_LCD1), 36 SAVE_ITEM(EXYNOS4_CLKDIV_IMAGE),
39 SAVE_ITEM(S5P_CLKDIV_IMAGE), 37 SAVE_ITEM(EXYNOS4210_CLKSRC_LCD1),
40 SAVE_ITEM(S5P_CLKDIV_LCD1), 38 SAVE_ITEM(EXYNOS4210_CLKDIV_LCD1),
41 SAVE_ITEM(S5P_CLKSRC_MASK_LCD1), 39 SAVE_ITEM(EXYNOS4210_CLKSRC_MASK_LCD1),
42 SAVE_ITEM(S5P_CLKGATE_IP_IMAGE_4210), 40 SAVE_ITEM(EXYNOS4210_CLKGATE_IP_IMAGE),
43 SAVE_ITEM(S5P_CLKGATE_IP_LCD1), 41 SAVE_ITEM(EXYNOS4210_CLKGATE_IP_LCD1),
44 SAVE_ITEM(S5P_CLKGATE_IP_PERIR_4210), 42 SAVE_ITEM(EXYNOS4210_CLKGATE_IP_PERIR),
45}; 43};
46#endif 44#endif
47 45
@@ -51,7 +49,7 @@ static struct clksrc_clk *sysclks[] = {
51 49
52static int exynos4_clksrc_mask_lcd1_ctrl(struct clk *clk, int enable) 50static int exynos4_clksrc_mask_lcd1_ctrl(struct clk *clk, int enable)
53{ 51{
54 return s5p_gatectrl(S5P_CLKSRC_MASK_LCD1, clk, enable); 52 return s5p_gatectrl(EXYNOS4210_CLKSRC_MASK_LCD1, clk, enable);
55} 53}
56 54
57static struct clksrc_clk clksrcs[] = { 55static struct clksrc_clk clksrcs[] = {
@@ -62,9 +60,9 @@ static struct clksrc_clk clksrcs[] = {
62 .enable = exynos4_clksrc_mask_fsys_ctrl, 60 .enable = exynos4_clksrc_mask_fsys_ctrl,
63 .ctrlbit = (1 << 24), 61 .ctrlbit = (1 << 24),
64 }, 62 },
65 .sources = &clkset_mout_corebus, 63 .sources = &exynos4_clkset_mout_corebus,
66 .reg_src = { .reg = S5P_CLKSRC_FSYS, .shift = 24, .size = 1 }, 64 .reg_src = { .reg = EXYNOS4_CLKSRC_FSYS, .shift = 24, .size = 1 },
67 .reg_div = { .reg = S5P_CLKDIV_FSYS0, .shift = 20, .size = 4 }, 65 .reg_div = { .reg = EXYNOS4_CLKDIV_FSYS0, .shift = 20, .size = 4 },
68 }, { 66 }, {
69 .clk = { 67 .clk = {
70 .name = "sclk_fimd", 68 .name = "sclk_fimd",
@@ -72,9 +70,9 @@ static struct clksrc_clk clksrcs[] = {
72 .enable = exynos4_clksrc_mask_lcd1_ctrl, 70 .enable = exynos4_clksrc_mask_lcd1_ctrl,
73 .ctrlbit = (1 << 0), 71 .ctrlbit = (1 << 0),
74 }, 72 },
75 .sources = &clkset_group, 73 .sources = &exynos4_clkset_group,
76 .reg_src = { .reg = S5P_CLKSRC_LCD1, .shift = 0, .size = 4 }, 74 .reg_src = { .reg = EXYNOS4210_CLKSRC_LCD1, .shift = 0, .size = 4 },
77 .reg_div = { .reg = S5P_CLKDIV_LCD1, .shift = 0, .size = 4 }, 75 .reg_div = { .reg = EXYNOS4210_CLKDIV_LCD1, .shift = 0, .size = 4 },
78 }, 76 },
79}; 77};
80 78
@@ -82,13 +80,13 @@ static struct clk init_clocks_off[] = {
82 { 80 {
83 .name = "sataphy", 81 .name = "sataphy",
84 .id = -1, 82 .id = -1,
85 .parent = &clk_aclk_133.clk, 83 .parent = &exynos4_clk_aclk_133.clk,
86 .enable = exynos4_clk_ip_fsys_ctrl, 84 .enable = exynos4_clk_ip_fsys_ctrl,
87 .ctrlbit = (1 << 3), 85 .ctrlbit = (1 << 3),
88 }, { 86 }, {
89 .name = "sata", 87 .name = "sata",
90 .id = -1, 88 .id = -1,
91 .parent = &clk_aclk_133.clk, 89 .parent = &exynos4_clk_aclk_133.clk,
92 .enable = exynos4_clk_ip_fsys_ctrl, 90 .enable = exynos4_clk_ip_fsys_ctrl,
93 .ctrlbit = (1 << 10), 91 .ctrlbit = (1 << 10),
94 }, { 92 }, {
@@ -117,7 +115,7 @@ static void exynos4210_clock_resume(void)
117#define exynos4210_clock_resume NULL 115#define exynos4210_clock_resume NULL
118#endif 116#endif
119 117
120struct syscore_ops exynos4210_clock_syscore_ops = { 118static struct syscore_ops exynos4210_clock_syscore_ops = {
121 .suspend = exynos4210_clock_suspend, 119 .suspend = exynos4210_clock_suspend,
122 .resume = exynos4210_clock_resume, 120 .resume = exynos4210_clock_resume,
123}; 121};
@@ -126,9 +124,9 @@ void __init exynos4210_register_clocks(void)
126{ 124{
127 int ptr; 125 int ptr;
128 126
129 clk_mout_mpll.reg_src.reg = S5P_CLKSRC_CPU; 127 exynos4_clk_mout_mpll.reg_src.reg = EXYNOS4_CLKSRC_CPU;
130 clk_mout_mpll.reg_src.shift = 8; 128 exynos4_clk_mout_mpll.reg_src.shift = 8;
131 clk_mout_mpll.reg_src.size = 1; 129 exynos4_clk_mout_mpll.reg_src.size = 1;
132 130
133 for (ptr = 0; ptr < ARRAY_SIZE(sysclks); ptr++) 131 for (ptr = 0; ptr < ARRAY_SIZE(sysclks); ptr++)
134 s3c_register_clksrc(sysclks[ptr], 1); 132 s3c_register_clksrc(sysclks[ptr], 1);
diff --git a/arch/arm/mach-exynos/clock-exynos4212.c b/arch/arm/mach-exynos/clock-exynos4212.c
index 48af28566fa..3ecc01e06f7 100644
--- a/arch/arm/mach-exynos/clock-exynos4212.c
+++ b/arch/arm/mach-exynos/clock-exynos4212.c
@@ -1,7 +1,5 @@
1/* 1/*
2 * linux/arch/arm/mach-exynos4/clock-exynos4212.c 2 * Copyright (c) 2011-2012 Samsung Electronics Co., Ltd.
3 *
4 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com 3 * http://www.samsung.com
6 * 4 *
7 * EXYNOS4212 - Clock support 5 * EXYNOS4212 - Clock support
@@ -28,22 +26,22 @@
28#include <mach/hardware.h> 26#include <mach/hardware.h>
29#include <mach/map.h> 27#include <mach/map.h>
30#include <mach/regs-clock.h> 28#include <mach/regs-clock.h>
31#include <mach/exynos4-clock.h>
32 29
33#include "common.h" 30#include "common.h"
31#include "clock-exynos4.h"
34 32
35#ifdef CONFIG_PM_SLEEP 33#ifdef CONFIG_PM_SLEEP
36static struct sleep_save exynos4212_clock_save[] = { 34static struct sleep_save exynos4212_clock_save[] = {
37 SAVE_ITEM(S5P_CLKSRC_IMAGE), 35 SAVE_ITEM(EXYNOS4_CLKSRC_IMAGE),
38 SAVE_ITEM(S5P_CLKDIV_IMAGE), 36 SAVE_ITEM(EXYNOS4_CLKDIV_IMAGE),
39 SAVE_ITEM(S5P_CLKGATE_IP_IMAGE_4212), 37 SAVE_ITEM(EXYNOS4212_CLKGATE_IP_IMAGE),
40 SAVE_ITEM(S5P_CLKGATE_IP_PERIR_4212), 38 SAVE_ITEM(EXYNOS4212_CLKGATE_IP_PERIR),
41}; 39};
42#endif 40#endif
43 41
44static struct clk *clk_src_mpll_user_list[] = { 42static struct clk *clk_src_mpll_user_list[] = {
45 [0] = &clk_fin_mpll, 43 [0] = &clk_fin_mpll,
46 [1] = &clk_mout_mpll.clk, 44 [1] = &exynos4_clk_mout_mpll.clk,
47}; 45};
48 46
49static struct clksrc_sources clk_src_mpll_user = { 47static struct clksrc_sources clk_src_mpll_user = {
@@ -56,7 +54,7 @@ static struct clksrc_clk clk_mout_mpll_user = {
56 .name = "mout_mpll_user", 54 .name = "mout_mpll_user",
57 }, 55 },
58 .sources = &clk_src_mpll_user, 56 .sources = &clk_src_mpll_user,
59 .reg_src = { .reg = S5P_CLKSRC_CPU, .shift = 24, .size = 1 }, 57 .reg_src = { .reg = EXYNOS4_CLKSRC_CPU, .shift = 24, .size = 1 },
60}; 58};
61 59
62static struct clksrc_clk *sysclks[] = { 60static struct clksrc_clk *sysclks[] = {
@@ -89,7 +87,7 @@ static void exynos4212_clock_resume(void)
89#define exynos4212_clock_resume NULL 87#define exynos4212_clock_resume NULL
90#endif 88#endif
91 89
92struct syscore_ops exynos4212_clock_syscore_ops = { 90static struct syscore_ops exynos4212_clock_syscore_ops = {
93 .suspend = exynos4212_clock_suspend, 91 .suspend = exynos4212_clock_suspend,
94 .resume = exynos4212_clock_resume, 92 .resume = exynos4212_clock_resume,
95}; 93};
@@ -99,15 +97,15 @@ void __init exynos4212_register_clocks(void)
99 int ptr; 97 int ptr;
100 98
101 /* usbphy1 is removed */ 99 /* usbphy1 is removed */
102 clkset_group_list[4] = NULL; 100 exynos4_clkset_group_list[4] = NULL;
103 101
104 /* mout_mpll_user is used */ 102 /* mout_mpll_user is used */
105 clkset_group_list[6] = &clk_mout_mpll_user.clk; 103 exynos4_clkset_group_list[6] = &clk_mout_mpll_user.clk;
106 clkset_aclk_top_list[0] = &clk_mout_mpll_user.clk; 104 exynos4_clkset_aclk_top_list[0] = &clk_mout_mpll_user.clk;
107 105
108 clk_mout_mpll.reg_src.reg = S5P_CLKSRC_DMC; 106 exynos4_clk_mout_mpll.reg_src.reg = EXYNOS4_CLKSRC_DMC;
109 clk_mout_mpll.reg_src.shift = 12; 107 exynos4_clk_mout_mpll.reg_src.shift = 12;
110 clk_mout_mpll.reg_src.size = 1; 108 exynos4_clk_mout_mpll.reg_src.size = 1;
111 109
112 for (ptr = 0; ptr < ARRAY_SIZE(sysclks); ptr++) 110 for (ptr = 0; ptr < ARRAY_SIZE(sysclks); ptr++)
113 s3c_register_clksrc(sysclks[ptr], 1); 111 s3c_register_clksrc(sysclks[ptr], 1);
diff --git a/arch/arm/mach-exynos/clock-exynos5.c b/arch/arm/mach-exynos/clock-exynos5.c
new file mode 100644
index 00000000000..d013982d0f8
--- /dev/null
+++ b/arch/arm/mach-exynos/clock-exynos5.c
@@ -0,0 +1,1247 @@
1/*
2 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 * http://www.samsung.com
4 *
5 * Clock support for EXYNOS5 SoCs
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10*/
11
12#include <linux/kernel.h>
13#include <linux/err.h>
14#include <linux/io.h>
15#include <linux/syscore_ops.h>
16
17#include <plat/cpu-freq.h>
18#include <plat/clock.h>
19#include <plat/cpu.h>
20#include <plat/pll.h>
21#include <plat/s5p-clock.h>
22#include <plat/clock-clksrc.h>
23#include <plat/pm.h>
24
25#include <mach/map.h>
26#include <mach/regs-clock.h>
27#include <mach/sysmmu.h>
28
29#include "common.h"
30
31#ifdef CONFIG_PM_SLEEP
32static struct sleep_save exynos5_clock_save[] = {
33 /* will be implemented */
34};
35#endif
36
37static struct clk exynos5_clk_sclk_dptxphy = {
38 .name = "sclk_dptx",
39};
40
41static struct clk exynos5_clk_sclk_hdmi24m = {
42 .name = "sclk_hdmi24m",
43 .rate = 24000000,
44};
45
46static struct clk exynos5_clk_sclk_hdmi27m = {
47 .name = "sclk_hdmi27m",
48 .rate = 27000000,
49};
50
51static struct clk exynos5_clk_sclk_hdmiphy = {
52 .name = "sclk_hdmiphy",
53};
54
55static struct clk exynos5_clk_sclk_usbphy = {
56 .name = "sclk_usbphy",
57 .rate = 48000000,
58};
59
60static int exynos5_clksrc_mask_top_ctrl(struct clk *clk, int enable)
61{
62 return s5p_gatectrl(EXYNOS5_CLKSRC_MASK_TOP, clk, enable);
63}
64
65static int exynos5_clksrc_mask_disp1_0_ctrl(struct clk *clk, int enable)
66{
67 return s5p_gatectrl(EXYNOS5_CLKSRC_MASK_DISP1_0, clk, enable);
68}
69
70static int exynos5_clksrc_mask_fsys_ctrl(struct clk *clk, int enable)
71{
72 return s5p_gatectrl(EXYNOS5_CLKSRC_MASK_FSYS, clk, enable);
73}
74
75static int exynos5_clksrc_mask_gscl_ctrl(struct clk *clk, int enable)
76{
77 return s5p_gatectrl(EXYNOS5_CLKSRC_MASK_GSCL, clk, enable);
78}
79
80static int exynos5_clksrc_mask_peric0_ctrl(struct clk *clk, int enable)
81{
82 return s5p_gatectrl(EXYNOS5_CLKSRC_MASK_PERIC0, clk, enable);
83}
84
85static int exynos5_clk_ip_core_ctrl(struct clk *clk, int enable)
86{
87 return s5p_gatectrl(EXYNOS5_CLKGATE_IP_CORE, clk, enable);
88}
89
90static int exynos5_clk_ip_disp1_ctrl(struct clk *clk, int enable)
91{
92 return s5p_gatectrl(EXYNOS5_CLKGATE_IP_DISP1, clk, enable);
93}
94
95static int exynos5_clk_ip_fsys_ctrl(struct clk *clk, int enable)
96{
97 return s5p_gatectrl(EXYNOS5_CLKGATE_IP_FSYS, clk, enable);
98}
99
100static int exynos5_clk_block_ctrl(struct clk *clk, int enable)
101{
102 return s5p_gatectrl(EXYNOS5_CLKGATE_BLOCK, clk, enable);
103}
104
105static int exynos5_clk_ip_gen_ctrl(struct clk *clk, int enable)
106{
107 return s5p_gatectrl(EXYNOS5_CLKGATE_IP_GEN, clk, enable);
108}
109
110static int exynos5_clk_ip_gps_ctrl(struct clk *clk, int enable)
111{
112 return s5p_gatectrl(EXYNOS5_CLKGATE_IP_GPS, clk, enable);
113}
114
115static int exynos5_clk_ip_mfc_ctrl(struct clk *clk, int enable)
116{
117 return s5p_gatectrl(EXYNOS5_CLKGATE_IP_MFC, clk, enable);
118}
119
120static int exynos5_clk_ip_peric_ctrl(struct clk *clk, int enable)
121{
122 return s5p_gatectrl(EXYNOS5_CLKGATE_IP_PERIC, clk, enable);
123}
124
125static int exynos5_clk_ip_peris_ctrl(struct clk *clk, int enable)
126{
127 return s5p_gatectrl(EXYNOS5_CLKGATE_IP_PERIS, clk, enable);
128}
129
130/* Core list of CMU_CPU side */
131
132static struct clksrc_clk exynos5_clk_mout_apll = {
133 .clk = {
134 .name = "mout_apll",
135 },
136 .sources = &clk_src_apll,
137 .reg_src = { .reg = EXYNOS5_CLKSRC_CPU, .shift = 0, .size = 1 },
138};
139
140static struct clksrc_clk exynos5_clk_sclk_apll = {
141 .clk = {
142 .name = "sclk_apll",
143 .parent = &exynos5_clk_mout_apll.clk,
144 },
145 .reg_div = { .reg = EXYNOS5_CLKDIV_CPU0, .shift = 24, .size = 3 },
146};
147
148static struct clksrc_clk exynos5_clk_mout_bpll = {
149 .clk = {
150 .name = "mout_bpll",
151 },
152 .sources = &clk_src_bpll,
153 .reg_src = { .reg = EXYNOS5_CLKSRC_CDREX, .shift = 0, .size = 1 },
154};
155
156static struct clk *exynos5_clk_src_bpll_user_list[] = {
157 [0] = &clk_fin_mpll,
158 [1] = &exynos5_clk_mout_bpll.clk,
159};
160
161static struct clksrc_sources exynos5_clk_src_bpll_user = {
162 .sources = exynos5_clk_src_bpll_user_list,
163 .nr_sources = ARRAY_SIZE(exynos5_clk_src_bpll_user_list),
164};
165
166static struct clksrc_clk exynos5_clk_mout_bpll_user = {
167 .clk = {
168 .name = "mout_bpll_user",
169 },
170 .sources = &exynos5_clk_src_bpll_user,
171 .reg_src = { .reg = EXYNOS5_CLKSRC_TOP2, .shift = 24, .size = 1 },
172};
173
174static struct clksrc_clk exynos5_clk_mout_cpll = {
175 .clk = {
176 .name = "mout_cpll",
177 },
178 .sources = &clk_src_cpll,
179 .reg_src = { .reg = EXYNOS5_CLKSRC_TOP2, .shift = 8, .size = 1 },
180};
181
182static struct clksrc_clk exynos5_clk_mout_epll = {
183 .clk = {
184 .name = "mout_epll",
185 },
186 .sources = &clk_src_epll,
187 .reg_src = { .reg = EXYNOS5_CLKSRC_TOP2, .shift = 12, .size = 1 },
188};
189
190struct clksrc_clk exynos5_clk_mout_mpll = {
191 .clk = {
192 .name = "mout_mpll",
193 },
194 .sources = &clk_src_mpll,
195 .reg_src = { .reg = EXYNOS5_CLKSRC_CORE1, .shift = 8, .size = 1 },
196};
197
198static struct clk *exynos_clkset_vpllsrc_list[] = {
199 [0] = &clk_fin_vpll,
200 [1] = &exynos5_clk_sclk_hdmi27m,
201};
202
203static struct clksrc_sources exynos5_clkset_vpllsrc = {
204 .sources = exynos_clkset_vpllsrc_list,
205 .nr_sources = ARRAY_SIZE(exynos_clkset_vpllsrc_list),
206};
207
208static struct clksrc_clk exynos5_clk_vpllsrc = {
209 .clk = {
210 .name = "vpll_src",
211 .enable = exynos5_clksrc_mask_top_ctrl,
212 .ctrlbit = (1 << 0),
213 },
214 .sources = &exynos5_clkset_vpllsrc,
215 .reg_src = { .reg = EXYNOS5_CLKSRC_TOP2, .shift = 0, .size = 1 },
216};
217
218static struct clk *exynos5_clkset_sclk_vpll_list[] = {
219 [0] = &exynos5_clk_vpllsrc.clk,
220 [1] = &clk_fout_vpll,
221};
222
223static struct clksrc_sources exynos5_clkset_sclk_vpll = {
224 .sources = exynos5_clkset_sclk_vpll_list,
225 .nr_sources = ARRAY_SIZE(exynos5_clkset_sclk_vpll_list),
226};
227
228static struct clksrc_clk exynos5_clk_sclk_vpll = {
229 .clk = {
230 .name = "sclk_vpll",
231 },
232 .sources = &exynos5_clkset_sclk_vpll,
233 .reg_src = { .reg = EXYNOS5_CLKSRC_TOP2, .shift = 16, .size = 1 },
234};
235
236static struct clksrc_clk exynos5_clk_sclk_pixel = {
237 .clk = {
238 .name = "sclk_pixel",
239 .parent = &exynos5_clk_sclk_vpll.clk,
240 },
241 .reg_div = { .reg = EXYNOS5_CLKDIV_DISP1_0, .shift = 28, .size = 4 },
242};
243
244static struct clk *exynos5_clkset_sclk_hdmi_list[] = {
245 [0] = &exynos5_clk_sclk_pixel.clk,
246 [1] = &exynos5_clk_sclk_hdmiphy,
247};
248
249static struct clksrc_sources exynos5_clkset_sclk_hdmi = {
250 .sources = exynos5_clkset_sclk_hdmi_list,
251 .nr_sources = ARRAY_SIZE(exynos5_clkset_sclk_hdmi_list),
252};
253
254static struct clksrc_clk exynos5_clk_sclk_hdmi = {
255 .clk = {
256 .name = "sclk_hdmi",
257 .enable = exynos5_clksrc_mask_disp1_0_ctrl,
258 .ctrlbit = (1 << 20),
259 },
260 .sources = &exynos5_clkset_sclk_hdmi,
261 .reg_src = { .reg = EXYNOS5_CLKSRC_DISP1_0, .shift = 20, .size = 1 },
262};
263
264static struct clksrc_clk *exynos5_sclk_tv[] = {
265 &exynos5_clk_sclk_pixel,
266 &exynos5_clk_sclk_hdmi,
267};
268
269static struct clk *exynos5_clk_src_mpll_user_list[] = {
270 [0] = &clk_fin_mpll,
271 [1] = &exynos5_clk_mout_mpll.clk,
272};
273
274static struct clksrc_sources exynos5_clk_src_mpll_user = {
275 .sources = exynos5_clk_src_mpll_user_list,
276 .nr_sources = ARRAY_SIZE(exynos5_clk_src_mpll_user_list),
277};
278
279static struct clksrc_clk exynos5_clk_mout_mpll_user = {
280 .clk = {
281 .name = "mout_mpll_user",
282 },
283 .sources = &exynos5_clk_src_mpll_user,
284 .reg_src = { .reg = EXYNOS5_CLKSRC_TOP2, .shift = 20, .size = 1 },
285};
286
287static struct clk *exynos5_clkset_mout_cpu_list[] = {
288 [0] = &exynos5_clk_mout_apll.clk,
289 [1] = &exynos5_clk_mout_mpll.clk,
290};
291
292static struct clksrc_sources exynos5_clkset_mout_cpu = {
293 .sources = exynos5_clkset_mout_cpu_list,
294 .nr_sources = ARRAY_SIZE(exynos5_clkset_mout_cpu_list),
295};
296
297static struct clksrc_clk exynos5_clk_mout_cpu = {
298 .clk = {
299 .name = "mout_cpu",
300 },
301 .sources = &exynos5_clkset_mout_cpu,
302 .reg_src = { .reg = EXYNOS5_CLKSRC_CPU, .shift = 16, .size = 1 },
303};
304
305static struct clksrc_clk exynos5_clk_dout_armclk = {
306 .clk = {
307 .name = "dout_armclk",
308 .parent = &exynos5_clk_mout_cpu.clk,
309 },
310 .reg_div = { .reg = EXYNOS5_CLKDIV_CPU0, .shift = 0, .size = 3 },
311};
312
313static struct clksrc_clk exynos5_clk_dout_arm2clk = {
314 .clk = {
315 .name = "dout_arm2clk",
316 .parent = &exynos5_clk_dout_armclk.clk,
317 },
318 .reg_div = { .reg = EXYNOS5_CLKDIV_CPU0, .shift = 28, .size = 3 },
319};
320
321static struct clk exynos5_clk_armclk = {
322 .name = "armclk",
323 .parent = &exynos5_clk_dout_arm2clk.clk,
324};
325
326/* Core list of CMU_CDREX side */
327
328static struct clk *exynos5_clkset_cdrex_list[] = {
329 [0] = &exynos5_clk_mout_mpll.clk,
330 [1] = &exynos5_clk_mout_bpll.clk,
331};
332
333static struct clksrc_sources exynos5_clkset_cdrex = {
334 .sources = exynos5_clkset_cdrex_list,
335 .nr_sources = ARRAY_SIZE(exynos5_clkset_cdrex_list),
336};
337
338static struct clksrc_clk exynos5_clk_cdrex = {
339 .clk = {
340 .name = "clk_cdrex",
341 },
342 .sources = &exynos5_clkset_cdrex,
343 .reg_src = { .reg = EXYNOS5_CLKSRC_CDREX, .shift = 4, .size = 1 },
344 .reg_div = { .reg = EXYNOS5_CLKDIV_CDREX, .shift = 16, .size = 3 },
345};
346
347static struct clksrc_clk exynos5_clk_aclk_acp = {
348 .clk = {
349 .name = "aclk_acp",
350 .parent = &exynos5_clk_mout_mpll.clk,
351 },
352 .reg_div = { .reg = EXYNOS5_CLKDIV_ACP, .shift = 0, .size = 3 },
353};
354
355static struct clksrc_clk exynos5_clk_pclk_acp = {
356 .clk = {
357 .name = "pclk_acp",
358 .parent = &exynos5_clk_aclk_acp.clk,
359 },
360 .reg_div = { .reg = EXYNOS5_CLKDIV_ACP, .shift = 4, .size = 3 },
361};
362
363/* Core list of CMU_TOP side */
364
365struct clk *exynos5_clkset_aclk_top_list[] = {
366 [0] = &exynos5_clk_mout_mpll_user.clk,
367 [1] = &exynos5_clk_mout_bpll_user.clk,
368};
369
370struct clksrc_sources exynos5_clkset_aclk = {
371 .sources = exynos5_clkset_aclk_top_list,
372 .nr_sources = ARRAY_SIZE(exynos5_clkset_aclk_top_list),
373};
374
375static struct clksrc_clk exynos5_clk_aclk_400 = {
376 .clk = {
377 .name = "aclk_400",
378 },
379 .sources = &exynos5_clkset_aclk,
380 .reg_src = { .reg = EXYNOS5_CLKSRC_TOP0, .shift = 20, .size = 1 },
381 .reg_div = { .reg = EXYNOS5_CLKDIV_TOP0, .shift = 24, .size = 3 },
382};
383
384struct clk *exynos5_clkset_aclk_333_166_list[] = {
385 [0] = &exynos5_clk_mout_cpll.clk,
386 [1] = &exynos5_clk_mout_mpll_user.clk,
387};
388
389struct clksrc_sources exynos5_clkset_aclk_333_166 = {
390 .sources = exynos5_clkset_aclk_333_166_list,
391 .nr_sources = ARRAY_SIZE(exynos5_clkset_aclk_333_166_list),
392};
393
394static struct clksrc_clk exynos5_clk_aclk_333 = {
395 .clk = {
396 .name = "aclk_333",
397 },
398 .sources = &exynos5_clkset_aclk_333_166,
399 .reg_src = { .reg = EXYNOS5_CLKSRC_TOP0, .shift = 16, .size = 1 },
400 .reg_div = { .reg = EXYNOS5_CLKDIV_TOP0, .shift = 20, .size = 3 },
401};
402
403static struct clksrc_clk exynos5_clk_aclk_166 = {
404 .clk = {
405 .name = "aclk_166",
406 },
407 .sources = &exynos5_clkset_aclk_333_166,
408 .reg_src = { .reg = EXYNOS5_CLKSRC_TOP0, .shift = 8, .size = 1 },
409 .reg_div = { .reg = EXYNOS5_CLKDIV_TOP0, .shift = 8, .size = 3 },
410};
411
412static struct clksrc_clk exynos5_clk_aclk_266 = {
413 .clk = {
414 .name = "aclk_266",
415 .parent = &exynos5_clk_mout_mpll_user.clk,
416 },
417 .reg_div = { .reg = EXYNOS5_CLKDIV_TOP0, .shift = 16, .size = 3 },
418};
419
420static struct clksrc_clk exynos5_clk_aclk_200 = {
421 .clk = {
422 .name = "aclk_200",
423 },
424 .sources = &exynos5_clkset_aclk,
425 .reg_src = { .reg = EXYNOS5_CLKSRC_TOP0, .shift = 12, .size = 1 },
426 .reg_div = { .reg = EXYNOS5_CLKDIV_TOP0, .shift = 12, .size = 3 },
427};
428
429static struct clksrc_clk exynos5_clk_aclk_66_pre = {
430 .clk = {
431 .name = "aclk_66_pre",
432 .parent = &exynos5_clk_mout_mpll_user.clk,
433 },
434 .reg_div = { .reg = EXYNOS5_CLKDIV_TOP1, .shift = 24, .size = 3 },
435};
436
437static struct clksrc_clk exynos5_clk_aclk_66 = {
438 .clk = {
439 .name = "aclk_66",
440 .parent = &exynos5_clk_aclk_66_pre.clk,
441 },
442 .reg_div = { .reg = EXYNOS5_CLKDIV_TOP0, .shift = 0, .size = 3 },
443};
444
445static struct clk exynos5_init_clocks_off[] = {
446 {
447 .name = "timers",
448 .parent = &exynos5_clk_aclk_66.clk,
449 .enable = exynos5_clk_ip_peric_ctrl,
450 .ctrlbit = (1 << 24),
451 }, {
452 .name = "rtc",
453 .parent = &exynos5_clk_aclk_66.clk,
454 .enable = exynos5_clk_ip_peris_ctrl,
455 .ctrlbit = (1 << 20),
456 }, {
457 .name = "hsmmc",
458 .devname = "s3c-sdhci.0",
459 .parent = &exynos5_clk_aclk_200.clk,
460 .enable = exynos5_clk_ip_fsys_ctrl,
461 .ctrlbit = (1 << 12),
462 }, {
463 .name = "hsmmc",
464 .devname = "s3c-sdhci.1",
465 .parent = &exynos5_clk_aclk_200.clk,
466 .enable = exynos5_clk_ip_fsys_ctrl,
467 .ctrlbit = (1 << 13),
468 }, {
469 .name = "hsmmc",
470 .devname = "s3c-sdhci.2",
471 .parent = &exynos5_clk_aclk_200.clk,
472 .enable = exynos5_clk_ip_fsys_ctrl,
473 .ctrlbit = (1 << 14),
474 }, {
475 .name = "hsmmc",
476 .devname = "s3c-sdhci.3",
477 .parent = &exynos5_clk_aclk_200.clk,
478 .enable = exynos5_clk_ip_fsys_ctrl,
479 .ctrlbit = (1 << 15),
480 }, {
481 .name = "dwmci",
482 .parent = &exynos5_clk_aclk_200.clk,
483 .enable = exynos5_clk_ip_fsys_ctrl,
484 .ctrlbit = (1 << 16),
485 }, {
486 .name = "sata",
487 .devname = "ahci",
488 .enable = exynos5_clk_ip_fsys_ctrl,
489 .ctrlbit = (1 << 6),
490 }, {
491 .name = "sata_phy",
492 .enable = exynos5_clk_ip_fsys_ctrl,
493 .ctrlbit = (1 << 24),
494 }, {
495 .name = "sata_phy_i2c",
496 .enable = exynos5_clk_ip_fsys_ctrl,
497 .ctrlbit = (1 << 25),
498 }, {
499 .name = "mfc",
500 .devname = "s5p-mfc",
501 .enable = exynos5_clk_ip_mfc_ctrl,
502 .ctrlbit = (1 << 0),
503 }, {
504 .name = "hdmi",
505 .devname = "exynos4-hdmi",
506 .enable = exynos5_clk_ip_disp1_ctrl,
507 .ctrlbit = (1 << 6),
508 }, {
509 .name = "mixer",
510 .devname = "s5p-mixer",
511 .enable = exynos5_clk_ip_disp1_ctrl,
512 .ctrlbit = (1 << 5),
513 }, {
514 .name = "jpeg",
515 .enable = exynos5_clk_ip_gen_ctrl,
516 .ctrlbit = (1 << 2),
517 }, {
518 .name = "dsim0",
519 .enable = exynos5_clk_ip_disp1_ctrl,
520 .ctrlbit = (1 << 3),
521 }, {
522 .name = "iis",
523 .devname = "samsung-i2s.1",
524 .enable = exynos5_clk_ip_peric_ctrl,
525 .ctrlbit = (1 << 20),
526 }, {
527 .name = "iis",
528 .devname = "samsung-i2s.2",
529 .enable = exynos5_clk_ip_peric_ctrl,
530 .ctrlbit = (1 << 21),
531 }, {
532 .name = "pcm",
533 .devname = "samsung-pcm.1",
534 .enable = exynos5_clk_ip_peric_ctrl,
535 .ctrlbit = (1 << 22),
536 }, {
537 .name = "pcm",
538 .devname = "samsung-pcm.2",
539 .enable = exynos5_clk_ip_peric_ctrl,
540 .ctrlbit = (1 << 23),
541 }, {
542 .name = "spdif",
543 .devname = "samsung-spdif",
544 .enable = exynos5_clk_ip_peric_ctrl,
545 .ctrlbit = (1 << 26),
546 }, {
547 .name = "ac97",
548 .devname = "samsung-ac97",
549 .enable = exynos5_clk_ip_peric_ctrl,
550 .ctrlbit = (1 << 27),
551 }, {
552 .name = "usbhost",
553 .enable = exynos5_clk_ip_fsys_ctrl ,
554 .ctrlbit = (1 << 18),
555 }, {
556 .name = "usbotg",
557 .enable = exynos5_clk_ip_fsys_ctrl,
558 .ctrlbit = (1 << 7),
559 }, {
560 .name = "gps",
561 .enable = exynos5_clk_ip_gps_ctrl,
562 .ctrlbit = ((1 << 3) | (1 << 2) | (1 << 0)),
563 }, {
564 .name = "nfcon",
565 .enable = exynos5_clk_ip_fsys_ctrl,
566 .ctrlbit = (1 << 22),
567 }, {
568 .name = "iop",
569 .enable = exynos5_clk_ip_fsys_ctrl,
570 .ctrlbit = ((1 << 30) | (1 << 26) | (1 << 23)),
571 }, {
572 .name = "core_iop",
573 .enable = exynos5_clk_ip_core_ctrl,
574 .ctrlbit = ((1 << 21) | (1 << 3)),
575 }, {
576 .name = "mcu_iop",
577 .enable = exynos5_clk_ip_fsys_ctrl,
578 .ctrlbit = (1 << 0),
579 }, {
580 .name = "i2c",
581 .devname = "s3c2440-i2c.0",
582 .parent = &exynos5_clk_aclk_66.clk,
583 .enable = exynos5_clk_ip_peric_ctrl,
584 .ctrlbit = (1 << 6),
585 }, {
586 .name = "i2c",
587 .devname = "s3c2440-i2c.1",
588 .parent = &exynos5_clk_aclk_66.clk,
589 .enable = exynos5_clk_ip_peric_ctrl,
590 .ctrlbit = (1 << 7),
591 }, {
592 .name = "i2c",
593 .devname = "s3c2440-i2c.2",
594 .parent = &exynos5_clk_aclk_66.clk,
595 .enable = exynos5_clk_ip_peric_ctrl,
596 .ctrlbit = (1 << 8),
597 }, {
598 .name = "i2c",
599 .devname = "s3c2440-i2c.3",
600 .parent = &exynos5_clk_aclk_66.clk,
601 .enable = exynos5_clk_ip_peric_ctrl,
602 .ctrlbit = (1 << 9),
603 }, {
604 .name = "i2c",
605 .devname = "s3c2440-i2c.4",
606 .parent = &exynos5_clk_aclk_66.clk,
607 .enable = exynos5_clk_ip_peric_ctrl,
608 .ctrlbit = (1 << 10),
609 }, {
610 .name = "i2c",
611 .devname = "s3c2440-i2c.5",
612 .parent = &exynos5_clk_aclk_66.clk,
613 .enable = exynos5_clk_ip_peric_ctrl,
614 .ctrlbit = (1 << 11),
615 }, {
616 .name = "i2c",
617 .devname = "s3c2440-i2c.6",
618 .parent = &exynos5_clk_aclk_66.clk,
619 .enable = exynos5_clk_ip_peric_ctrl,
620 .ctrlbit = (1 << 12),
621 }, {
622 .name = "i2c",
623 .devname = "s3c2440-i2c.7",
624 .parent = &exynos5_clk_aclk_66.clk,
625 .enable = exynos5_clk_ip_peric_ctrl,
626 .ctrlbit = (1 << 13),
627 }, {
628 .name = "i2c",
629 .devname = "s3c2440-hdmiphy-i2c",
630 .parent = &exynos5_clk_aclk_66.clk,
631 .enable = exynos5_clk_ip_peric_ctrl,
632 .ctrlbit = (1 << 14),
633 }
634};
635
636static struct clk exynos5_init_clocks_on[] = {
637 {
638 .name = "uart",
639 .devname = "s5pv210-uart.0",
640 .enable = exynos5_clk_ip_peric_ctrl,
641 .ctrlbit = (1 << 0),
642 }, {
643 .name = "uart",
644 .devname = "s5pv210-uart.1",
645 .enable = exynos5_clk_ip_peric_ctrl,
646 .ctrlbit = (1 << 1),
647 }, {
648 .name = "uart",
649 .devname = "s5pv210-uart.2",
650 .enable = exynos5_clk_ip_peric_ctrl,
651 .ctrlbit = (1 << 2),
652 }, {
653 .name = "uart",
654 .devname = "s5pv210-uart.3",
655 .enable = exynos5_clk_ip_peric_ctrl,
656 .ctrlbit = (1 << 3),
657 }, {
658 .name = "uart",
659 .devname = "s5pv210-uart.4",
660 .enable = exynos5_clk_ip_peric_ctrl,
661 .ctrlbit = (1 << 4),
662 }, {
663 .name = "uart",
664 .devname = "s5pv210-uart.5",
665 .enable = exynos5_clk_ip_peric_ctrl,
666 .ctrlbit = (1 << 5),
667 }
668};
669
670static struct clk exynos5_clk_pdma0 = {
671 .name = "dma",
672 .devname = "dma-pl330.0",
673 .enable = exynos5_clk_ip_fsys_ctrl,
674 .ctrlbit = (1 << 1),
675};
676
677static struct clk exynos5_clk_pdma1 = {
678 .name = "dma",
679 .devname = "dma-pl330.1",
680 .enable = exynos5_clk_ip_fsys_ctrl,
681 .ctrlbit = (1 << 1),
682};
683
684static struct clk exynos5_clk_mdma1 = {
685 .name = "dma",
686 .devname = "dma-pl330.2",
687 .enable = exynos5_clk_ip_gen_ctrl,
688 .ctrlbit = (1 << 4),
689};
690
691struct clk *exynos5_clkset_group_list[] = {
692 [0] = &clk_ext_xtal_mux,
693 [1] = NULL,
694 [2] = &exynos5_clk_sclk_hdmi24m,
695 [3] = &exynos5_clk_sclk_dptxphy,
696 [4] = &exynos5_clk_sclk_usbphy,
697 [5] = &exynos5_clk_sclk_hdmiphy,
698 [6] = &exynos5_clk_mout_mpll_user.clk,
699 [7] = &exynos5_clk_mout_epll.clk,
700 [8] = &exynos5_clk_sclk_vpll.clk,
701 [9] = &exynos5_clk_mout_cpll.clk,
702};
703
704struct clksrc_sources exynos5_clkset_group = {
705 .sources = exynos5_clkset_group_list,
706 .nr_sources = ARRAY_SIZE(exynos5_clkset_group_list),
707};
708
709/* Possible clock sources for aclk_266_gscl_sub Mux */
710static struct clk *clk_src_gscl_266_list[] = {
711 [0] = &clk_ext_xtal_mux,
712 [1] = &exynos5_clk_aclk_266.clk,
713};
714
715static struct clksrc_sources clk_src_gscl_266 = {
716 .sources = clk_src_gscl_266_list,
717 .nr_sources = ARRAY_SIZE(clk_src_gscl_266_list),
718};
719
720static struct clksrc_clk exynos5_clk_dout_mmc0 = {
721 .clk = {
722 .name = "dout_mmc0",
723 },
724 .sources = &exynos5_clkset_group,
725 .reg_src = { .reg = EXYNOS5_CLKSRC_FSYS, .shift = 0, .size = 4 },
726 .reg_div = { .reg = EXYNOS5_CLKDIV_FSYS1, .shift = 0, .size = 4 },
727};
728
729static struct clksrc_clk exynos5_clk_dout_mmc1 = {
730 .clk = {
731 .name = "dout_mmc1",
732 },
733 .sources = &exynos5_clkset_group,
734 .reg_src = { .reg = EXYNOS5_CLKSRC_FSYS, .shift = 4, .size = 4 },
735 .reg_div = { .reg = EXYNOS5_CLKDIV_FSYS1, .shift = 16, .size = 4 },
736};
737
738static struct clksrc_clk exynos5_clk_dout_mmc2 = {
739 .clk = {
740 .name = "dout_mmc2",
741 },
742 .sources = &exynos5_clkset_group,
743 .reg_src = { .reg = EXYNOS5_CLKSRC_FSYS, .shift = 8, .size = 4 },
744 .reg_div = { .reg = EXYNOS5_CLKDIV_FSYS2, .shift = 0, .size = 4 },
745};
746
747static struct clksrc_clk exynos5_clk_dout_mmc3 = {
748 .clk = {
749 .name = "dout_mmc3",
750 },
751 .sources = &exynos5_clkset_group,
752 .reg_src = { .reg = EXYNOS5_CLKSRC_FSYS, .shift = 12, .size = 4 },
753 .reg_div = { .reg = EXYNOS5_CLKDIV_FSYS2, .shift = 16, .size = 4 },
754};
755
756static struct clksrc_clk exynos5_clk_dout_mmc4 = {
757 .clk = {
758 .name = "dout_mmc4",
759 },
760 .sources = &exynos5_clkset_group,
761 .reg_src = { .reg = EXYNOS5_CLKSRC_FSYS, .shift = 16, .size = 4 },
762 .reg_div = { .reg = EXYNOS5_CLKDIV_FSYS3, .shift = 0, .size = 4 },
763};
764
765static struct clksrc_clk exynos5_clk_sclk_uart0 = {
766 .clk = {
767 .name = "uclk1",
768 .devname = "exynos4210-uart.0",
769 .enable = exynos5_clksrc_mask_peric0_ctrl,
770 .ctrlbit = (1 << 0),
771 },
772 .sources = &exynos5_clkset_group,
773 .reg_src = { .reg = EXYNOS5_CLKSRC_PERIC0, .shift = 0, .size = 4 },
774 .reg_div = { .reg = EXYNOS5_CLKDIV_PERIC0, .shift = 0, .size = 4 },
775};
776
777static struct clksrc_clk exynos5_clk_sclk_uart1 = {
778 .clk = {
779 .name = "uclk1",
780 .devname = "exynos4210-uart.1",
781 .enable = exynos5_clksrc_mask_peric0_ctrl,
782 .ctrlbit = (1 << 4),
783 },
784 .sources = &exynos5_clkset_group,
785 .reg_src = { .reg = EXYNOS5_CLKSRC_PERIC0, .shift = 4, .size = 4 },
786 .reg_div = { .reg = EXYNOS5_CLKDIV_PERIC0, .shift = 4, .size = 4 },
787};
788
789static struct clksrc_clk exynos5_clk_sclk_uart2 = {
790 .clk = {
791 .name = "uclk1",
792 .devname = "exynos4210-uart.2",
793 .enable = exynos5_clksrc_mask_peric0_ctrl,
794 .ctrlbit = (1 << 8),
795 },
796 .sources = &exynos5_clkset_group,
797 .reg_src = { .reg = EXYNOS5_CLKSRC_PERIC0, .shift = 8, .size = 4 },
798 .reg_div = { .reg = EXYNOS5_CLKDIV_PERIC0, .shift = 8, .size = 4 },
799};
800
801static struct clksrc_clk exynos5_clk_sclk_uart3 = {
802 .clk = {
803 .name = "uclk1",
804 .devname = "exynos4210-uart.3",
805 .enable = exynos5_clksrc_mask_peric0_ctrl,
806 .ctrlbit = (1 << 12),
807 },
808 .sources = &exynos5_clkset_group,
809 .reg_src = { .reg = EXYNOS5_CLKSRC_PERIC0, .shift = 12, .size = 4 },
810 .reg_div = { .reg = EXYNOS5_CLKDIV_PERIC0, .shift = 12, .size = 4 },
811};
812
813static struct clksrc_clk exynos5_clk_sclk_mmc0 = {
814 .clk = {
815 .name = "sclk_mmc",
816 .devname = "s3c-sdhci.0",
817 .parent = &exynos5_clk_dout_mmc0.clk,
818 .enable = exynos5_clksrc_mask_fsys_ctrl,
819 .ctrlbit = (1 << 0),
820 },
821 .reg_div = { .reg = EXYNOS5_CLKDIV_FSYS1, .shift = 8, .size = 8 },
822};
823
824static struct clksrc_clk exynos5_clk_sclk_mmc1 = {
825 .clk = {
826 .name = "sclk_mmc",
827 .devname = "s3c-sdhci.1",
828 .parent = &exynos5_clk_dout_mmc1.clk,
829 .enable = exynos5_clksrc_mask_fsys_ctrl,
830 .ctrlbit = (1 << 4),
831 },
832 .reg_div = { .reg = EXYNOS5_CLKDIV_FSYS1, .shift = 24, .size = 8 },
833};
834
835static struct clksrc_clk exynos5_clk_sclk_mmc2 = {
836 .clk = {
837 .name = "sclk_mmc",
838 .devname = "s3c-sdhci.2",
839 .parent = &exynos5_clk_dout_mmc2.clk,
840 .enable = exynos5_clksrc_mask_fsys_ctrl,
841 .ctrlbit = (1 << 8),
842 },
843 .reg_div = { .reg = EXYNOS5_CLKDIV_FSYS2, .shift = 8, .size = 8 },
844};
845
846static struct clksrc_clk exynos5_clk_sclk_mmc3 = {
847 .clk = {
848 .name = "sclk_mmc",
849 .devname = "s3c-sdhci.3",
850 .parent = &exynos5_clk_dout_mmc3.clk,
851 .enable = exynos5_clksrc_mask_fsys_ctrl,
852 .ctrlbit = (1 << 12),
853 },
854 .reg_div = { .reg = EXYNOS5_CLKDIV_FSYS2, .shift = 24, .size = 8 },
855};
856
857static struct clksrc_clk exynos5_clksrcs[] = {
858 {
859 .clk = {
860 .name = "sclk_dwmci",
861 .parent = &exynos5_clk_dout_mmc4.clk,
862 .enable = exynos5_clksrc_mask_fsys_ctrl,
863 .ctrlbit = (1 << 16),
864 },
865 .reg_div = { .reg = EXYNOS5_CLKDIV_FSYS3, .shift = 8, .size = 8 },
866 }, {
867 .clk = {
868 .name = "sclk_fimd",
869 .devname = "s3cfb.1",
870 .enable = exynos5_clksrc_mask_disp1_0_ctrl,
871 .ctrlbit = (1 << 0),
872 },
873 .sources = &exynos5_clkset_group,
874 .reg_src = { .reg = EXYNOS5_CLKSRC_DISP1_0, .shift = 0, .size = 4 },
875 .reg_div = { .reg = EXYNOS5_CLKDIV_DISP1_0, .shift = 0, .size = 4 },
876 }, {
877 .clk = {
878 .name = "aclk_266_gscl",
879 },
880 .sources = &clk_src_gscl_266,
881 .reg_src = { .reg = EXYNOS5_CLKSRC_TOP3, .shift = 8, .size = 1 },
882 }, {
883 .clk = {
884 .name = "sclk_g3d",
885 .devname = "mali-t604.0",
886 .enable = exynos5_clk_block_ctrl,
887 .ctrlbit = (1 << 1),
888 },
889 .sources = &exynos5_clkset_aclk,
890 .reg_src = { .reg = EXYNOS5_CLKSRC_TOP0, .shift = 20, .size = 1 },
891 .reg_div = { .reg = EXYNOS5_CLKDIV_TOP0, .shift = 24, .size = 3 },
892 }, {
893 .clk = {
894 .name = "sclk_gscl_wrap",
895 .devname = "s5p-mipi-csis.0",
896 .enable = exynos5_clksrc_mask_gscl_ctrl,
897 .ctrlbit = (1 << 24),
898 },
899 .sources = &exynos5_clkset_group,
900 .reg_src = { .reg = EXYNOS5_CLKSRC_GSCL, .shift = 24, .size = 4 },
901 .reg_div = { .reg = EXYNOS5_CLKDIV_GSCL, .shift = 24, .size = 4 },
902 }, {
903 .clk = {
904 .name = "sclk_gscl_wrap",
905 .devname = "s5p-mipi-csis.1",
906 .enable = exynos5_clksrc_mask_gscl_ctrl,
907 .ctrlbit = (1 << 28),
908 },
909 .sources = &exynos5_clkset_group,
910 .reg_src = { .reg = EXYNOS5_CLKSRC_GSCL, .shift = 28, .size = 4 },
911 .reg_div = { .reg = EXYNOS5_CLKDIV_GSCL, .shift = 28, .size = 4 },
912 }, {
913 .clk = {
914 .name = "sclk_cam0",
915 .enable = exynos5_clksrc_mask_gscl_ctrl,
916 .ctrlbit = (1 << 16),
917 },
918 .sources = &exynos5_clkset_group,
919 .reg_src = { .reg = EXYNOS5_CLKSRC_GSCL, .shift = 16, .size = 4 },
920 .reg_div = { .reg = EXYNOS5_CLKDIV_GSCL, .shift = 16, .size = 4 },
921 }, {
922 .clk = {
923 .name = "sclk_cam1",
924 .enable = exynos5_clksrc_mask_gscl_ctrl,
925 .ctrlbit = (1 << 20),
926 },
927 .sources = &exynos5_clkset_group,
928 .reg_src = { .reg = EXYNOS5_CLKSRC_GSCL, .shift = 20, .size = 4 },
929 .reg_div = { .reg = EXYNOS5_CLKDIV_GSCL, .shift = 20, .size = 4 },
930 }, {
931 .clk = {
932 .name = "sclk_jpeg",
933 .parent = &exynos5_clk_mout_cpll.clk,
934 },
935 .reg_div = { .reg = EXYNOS5_CLKDIV_GEN, .shift = 4, .size = 3 },
936 },
937};
938
939/* Clock initialization code */
940static struct clksrc_clk *exynos5_sysclks[] = {
941 &exynos5_clk_mout_apll,
942 &exynos5_clk_sclk_apll,
943 &exynos5_clk_mout_bpll,
944 &exynos5_clk_mout_bpll_user,
945 &exynos5_clk_mout_cpll,
946 &exynos5_clk_mout_epll,
947 &exynos5_clk_mout_mpll,
948 &exynos5_clk_mout_mpll_user,
949 &exynos5_clk_vpllsrc,
950 &exynos5_clk_sclk_vpll,
951 &exynos5_clk_mout_cpu,
952 &exynos5_clk_dout_armclk,
953 &exynos5_clk_dout_arm2clk,
954 &exynos5_clk_cdrex,
955 &exynos5_clk_aclk_400,
956 &exynos5_clk_aclk_333,
957 &exynos5_clk_aclk_266,
958 &exynos5_clk_aclk_200,
959 &exynos5_clk_aclk_166,
960 &exynos5_clk_aclk_66_pre,
961 &exynos5_clk_aclk_66,
962 &exynos5_clk_dout_mmc0,
963 &exynos5_clk_dout_mmc1,
964 &exynos5_clk_dout_mmc2,
965 &exynos5_clk_dout_mmc3,
966 &exynos5_clk_dout_mmc4,
967 &exynos5_clk_aclk_acp,
968 &exynos5_clk_pclk_acp,
969};
970
971static struct clk *exynos5_clk_cdev[] = {
972 &exynos5_clk_pdma0,
973 &exynos5_clk_pdma1,
974 &exynos5_clk_mdma1,
975};
976
977static struct clksrc_clk *exynos5_clksrc_cdev[] = {
978 &exynos5_clk_sclk_uart0,
979 &exynos5_clk_sclk_uart1,
980 &exynos5_clk_sclk_uart2,
981 &exynos5_clk_sclk_uart3,
982 &exynos5_clk_sclk_mmc0,
983 &exynos5_clk_sclk_mmc1,
984 &exynos5_clk_sclk_mmc2,
985 &exynos5_clk_sclk_mmc3,
986};
987
988static struct clk_lookup exynos5_clk_lookup[] = {
989 CLKDEV_INIT("exynos4210-uart.0", "clk_uart_baud0", &exynos5_clk_sclk_uart0.clk),
990 CLKDEV_INIT("exynos4210-uart.1", "clk_uart_baud0", &exynos5_clk_sclk_uart1.clk),
991 CLKDEV_INIT("exynos4210-uart.2", "clk_uart_baud0", &exynos5_clk_sclk_uart2.clk),
992 CLKDEV_INIT("exynos4210-uart.3", "clk_uart_baud0", &exynos5_clk_sclk_uart3.clk),
993 CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.2", &exynos5_clk_sclk_mmc0.clk),
994 CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.2", &exynos5_clk_sclk_mmc1.clk),
995 CLKDEV_INIT("s3c-sdhci.2", "mmc_busclk.2", &exynos5_clk_sclk_mmc2.clk),
996 CLKDEV_INIT("s3c-sdhci.3", "mmc_busclk.2", &exynos5_clk_sclk_mmc3.clk),
997 CLKDEV_INIT("dma-pl330.0", "apb_pclk", &exynos5_clk_pdma0),
998 CLKDEV_INIT("dma-pl330.1", "apb_pclk", &exynos5_clk_pdma1),
999 CLKDEV_INIT("dma-pl330.2", "apb_pclk", &exynos5_clk_mdma1),
1000};
1001
1002static unsigned long exynos5_epll_get_rate(struct clk *clk)
1003{
1004 return clk->rate;
1005}
1006
1007static struct clk *exynos5_clks[] __initdata = {
1008 &exynos5_clk_sclk_hdmi27m,
1009 &exynos5_clk_sclk_hdmiphy,
1010 &clk_fout_bpll,
1011 &clk_fout_cpll,
1012 &exynos5_clk_armclk,
1013};
1014
1015static u32 epll_div[][6] = {
1016 { 192000000, 0, 48, 3, 1, 0 },
1017 { 180000000, 0, 45, 3, 1, 0 },
1018 { 73728000, 1, 73, 3, 3, 47710 },
1019 { 67737600, 1, 90, 4, 3, 20762 },
1020 { 49152000, 0, 49, 3, 3, 9961 },
1021 { 45158400, 0, 45, 3, 3, 10381 },
1022 { 180633600, 0, 45, 3, 1, 10381 },
1023};
1024
1025static int exynos5_epll_set_rate(struct clk *clk, unsigned long rate)
1026{
1027 unsigned int epll_con, epll_con_k;
1028 unsigned int i;
1029 unsigned int tmp;
1030 unsigned int epll_rate;
1031 unsigned int locktime;
1032 unsigned int lockcnt;
1033
1034 /* Return if nothing changed */
1035 if (clk->rate == rate)
1036 return 0;
1037
1038 if (clk->parent)
1039 epll_rate = clk_get_rate(clk->parent);
1040 else
1041 epll_rate = clk_ext_xtal_mux.rate;
1042
1043 if (epll_rate != 24000000) {
1044 pr_err("Invalid Clock : recommended clock is 24MHz.\n");
1045 return -EINVAL;
1046 }
1047
1048 epll_con = __raw_readl(EXYNOS5_EPLL_CON0);
1049 epll_con &= ~(0x1 << 27 | \
1050 PLL46XX_MDIV_MASK << PLL46XX_MDIV_SHIFT | \
1051 PLL46XX_PDIV_MASK << PLL46XX_PDIV_SHIFT | \
1052 PLL46XX_SDIV_MASK << PLL46XX_SDIV_SHIFT);
1053
1054 for (i = 0; i < ARRAY_SIZE(epll_div); i++) {
1055 if (epll_div[i][0] == rate) {
1056 epll_con_k = epll_div[i][5] << 0;
1057 epll_con |= epll_div[i][1] << 27;
1058 epll_con |= epll_div[i][2] << PLL46XX_MDIV_SHIFT;
1059 epll_con |= epll_div[i][3] << PLL46XX_PDIV_SHIFT;
1060 epll_con |= epll_div[i][4] << PLL46XX_SDIV_SHIFT;
1061 break;
1062 }
1063 }
1064
1065 if (i == ARRAY_SIZE(epll_div)) {
1066 printk(KERN_ERR "%s: Invalid Clock EPLL Frequency\n",
1067 __func__);
1068 return -EINVAL;
1069 }
1070
1071 epll_rate /= 1000000;
1072
1073 /* 3000 max_cycls : specification data */
1074 locktime = 3000 / epll_rate * epll_div[i][3];
1075 lockcnt = locktime * 10000 / (10000 / epll_rate);
1076
1077 __raw_writel(lockcnt, EXYNOS5_EPLL_LOCK);
1078
1079 __raw_writel(epll_con, EXYNOS5_EPLL_CON0);
1080 __raw_writel(epll_con_k, EXYNOS5_EPLL_CON1);
1081
1082 do {
1083 tmp = __raw_readl(EXYNOS5_EPLL_CON0);
1084 } while (!(tmp & 0x1 << EXYNOS5_EPLLCON0_LOCKED_SHIFT));
1085
1086 clk->rate = rate;
1087
1088 return 0;
1089}
1090
1091static struct clk_ops exynos5_epll_ops = {
1092 .get_rate = exynos5_epll_get_rate,
1093 .set_rate = exynos5_epll_set_rate,
1094};
1095
1096static int xtal_rate;
1097
1098static unsigned long exynos5_fout_apll_get_rate(struct clk *clk)
1099{
1100 return s5p_get_pll35xx(xtal_rate, __raw_readl(EXYNOS5_APLL_CON0));
1101}
1102
1103static struct clk_ops exynos5_fout_apll_ops = {
1104 .get_rate = exynos5_fout_apll_get_rate,
1105};
1106
1107#ifdef CONFIG_PM
1108static int exynos5_clock_suspend(void)
1109{
1110 s3c_pm_do_save(exynos5_clock_save, ARRAY_SIZE(exynos5_clock_save));
1111
1112 return 0;
1113}
1114
1115static void exynos5_clock_resume(void)
1116{
1117 s3c_pm_do_restore_core(exynos5_clock_save, ARRAY_SIZE(exynos5_clock_save));
1118}
1119#else
1120#define exynos5_clock_suspend NULL
1121#define exynos5_clock_resume NULL
1122#endif
1123
1124struct syscore_ops exynos5_clock_syscore_ops = {
1125 .suspend = exynos5_clock_suspend,
1126 .resume = exynos5_clock_resume,
1127};
1128
1129void __init_or_cpufreq exynos5_setup_clocks(void)
1130{
1131 struct clk *xtal_clk;
1132 unsigned long apll;
1133 unsigned long bpll;
1134 unsigned long cpll;
1135 unsigned long mpll;
1136 unsigned long epll;
1137 unsigned long vpll;
1138 unsigned long vpllsrc;
1139 unsigned long xtal;
1140 unsigned long armclk;
1141 unsigned long mout_cdrex;
1142 unsigned long aclk_400;
1143 unsigned long aclk_333;
1144 unsigned long aclk_266;
1145 unsigned long aclk_200;
1146 unsigned long aclk_166;
1147 unsigned long aclk_66;
1148 unsigned int ptr;
1149
1150 printk(KERN_DEBUG "%s: registering clocks\n", __func__);
1151
1152 xtal_clk = clk_get(NULL, "xtal");
1153 BUG_ON(IS_ERR(xtal_clk));
1154
1155 xtal = clk_get_rate(xtal_clk);
1156
1157 xtal_rate = xtal;
1158
1159 clk_put(xtal_clk);
1160
1161 printk(KERN_DEBUG "%s: xtal is %ld\n", __func__, xtal);
1162
1163 apll = s5p_get_pll35xx(xtal, __raw_readl(EXYNOS5_APLL_CON0));
1164 bpll = s5p_get_pll35xx(xtal, __raw_readl(EXYNOS5_BPLL_CON0));
1165 cpll = s5p_get_pll35xx(xtal, __raw_readl(EXYNOS5_CPLL_CON0));
1166 mpll = s5p_get_pll35xx(xtal, __raw_readl(EXYNOS5_MPLL_CON0));
1167 epll = s5p_get_pll36xx(xtal, __raw_readl(EXYNOS5_EPLL_CON0),
1168 __raw_readl(EXYNOS5_EPLL_CON1));
1169
1170 vpllsrc = clk_get_rate(&exynos5_clk_vpllsrc.clk);
1171 vpll = s5p_get_pll36xx(vpllsrc, __raw_readl(EXYNOS5_VPLL_CON0),
1172 __raw_readl(EXYNOS5_VPLL_CON1));
1173
1174 clk_fout_apll.ops = &exynos5_fout_apll_ops;
1175 clk_fout_bpll.rate = bpll;
1176 clk_fout_cpll.rate = cpll;
1177 clk_fout_mpll.rate = mpll;
1178 clk_fout_epll.rate = epll;
1179 clk_fout_vpll.rate = vpll;
1180
1181 printk(KERN_INFO "EXYNOS5: PLL settings, A=%ld, B=%ld, C=%ld\n"
1182 "M=%ld, E=%ld V=%ld",
1183 apll, bpll, cpll, mpll, epll, vpll);
1184
1185 armclk = clk_get_rate(&exynos5_clk_armclk);
1186 mout_cdrex = clk_get_rate(&exynos5_clk_cdrex.clk);
1187
1188 aclk_400 = clk_get_rate(&exynos5_clk_aclk_400.clk);
1189 aclk_333 = clk_get_rate(&exynos5_clk_aclk_333.clk);
1190 aclk_266 = clk_get_rate(&exynos5_clk_aclk_266.clk);
1191 aclk_200 = clk_get_rate(&exynos5_clk_aclk_200.clk);
1192 aclk_166 = clk_get_rate(&exynos5_clk_aclk_166.clk);
1193 aclk_66 = clk_get_rate(&exynos5_clk_aclk_66.clk);
1194
1195 printk(KERN_INFO "EXYNOS5: ARMCLK=%ld, CDREX=%ld, ACLK400=%ld\n"
1196 "ACLK333=%ld, ACLK266=%ld, ACLK200=%ld\n"
1197 "ACLK166=%ld, ACLK66=%ld\n",
1198 armclk, mout_cdrex, aclk_400,
1199 aclk_333, aclk_266, aclk_200,
1200 aclk_166, aclk_66);
1201
1202
1203 clk_fout_epll.ops = &exynos5_epll_ops;
1204
1205 if (clk_set_parent(&exynos5_clk_mout_epll.clk, &clk_fout_epll))
1206 printk(KERN_ERR "Unable to set parent %s of clock %s.\n",
1207 clk_fout_epll.name, exynos5_clk_mout_epll.clk.name);
1208
1209 clk_set_rate(&exynos5_clk_sclk_apll.clk, 100000000);
1210 clk_set_rate(&exynos5_clk_aclk_266.clk, 300000000);
1211
1212 clk_set_rate(&exynos5_clk_aclk_acp.clk, 267000000);
1213 clk_set_rate(&exynos5_clk_pclk_acp.clk, 134000000);
1214
1215 for (ptr = 0; ptr < ARRAY_SIZE(exynos5_clksrcs); ptr++)
1216 s3c_set_clksrc(&exynos5_clksrcs[ptr], true);
1217}
1218
1219void __init exynos5_register_clocks(void)
1220{
1221 int ptr;
1222
1223 s3c24xx_register_clocks(exynos5_clks, ARRAY_SIZE(exynos5_clks));
1224
1225 for (ptr = 0; ptr < ARRAY_SIZE(exynos5_sysclks); ptr++)
1226 s3c_register_clksrc(exynos5_sysclks[ptr], 1);
1227
1228 for (ptr = 0; ptr < ARRAY_SIZE(exynos5_sclk_tv); ptr++)
1229 s3c_register_clksrc(exynos5_sclk_tv[ptr], 1);
1230
1231 for (ptr = 0; ptr < ARRAY_SIZE(exynos5_clksrc_cdev); ptr++)
1232 s3c_register_clksrc(exynos5_clksrc_cdev[ptr], 1);
1233
1234 s3c_register_clksrc(exynos5_clksrcs, ARRAY_SIZE(exynos5_clksrcs));
1235 s3c_register_clocks(exynos5_init_clocks_on, ARRAY_SIZE(exynos5_init_clocks_on));
1236
1237 s3c24xx_register_clocks(exynos5_clk_cdev, ARRAY_SIZE(exynos5_clk_cdev));
1238 for (ptr = 0; ptr < ARRAY_SIZE(exynos5_clk_cdev); ptr++)
1239 s3c_disable_clocks(exynos5_clk_cdev[ptr], 1);
1240
1241 s3c_register_clocks(exynos5_init_clocks_off, ARRAY_SIZE(exynos5_init_clocks_off));
1242 s3c_disable_clocks(exynos5_init_clocks_off, ARRAY_SIZE(exynos5_init_clocks_off));
1243 clkdev_add_table(exynos5_clk_lookup, ARRAY_SIZE(exynos5_clk_lookup));
1244
1245 register_syscore_ops(&exynos5_clock_syscore_ops);
1246 s3c_pwmclk_init();
1247}
diff --git a/arch/arm/mach-exynos/clock.c b/arch/arm/mach-exynos/clock.c
deleted file mode 100644
index 187287aa57a..00000000000
--- a/arch/arm/mach-exynos/clock.c
+++ /dev/null
@@ -1,1564 +0,0 @@
1/* linux/arch/arm/mach-exynos4/clock.c
2 *
3 * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * EXYNOS4 - Clock support
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13#include <linux/kernel.h>
14#include <linux/err.h>
15#include <linux/io.h>
16#include <linux/syscore_ops.h>
17
18#include <plat/cpu-freq.h>
19#include <plat/clock.h>
20#include <plat/cpu.h>
21#include <plat/pll.h>
22#include <plat/s5p-clock.h>
23#include <plat/clock-clksrc.h>
24#include <plat/pm.h>
25
26#include <mach/map.h>
27#include <mach/regs-clock.h>
28#include <mach/sysmmu.h>
29#include <mach/exynos4-clock.h>
30
31#include "common.h"
32
33#ifdef CONFIG_PM_SLEEP
34static struct sleep_save exynos4_clock_save[] = {
35 SAVE_ITEM(S5P_CLKDIV_LEFTBUS),
36 SAVE_ITEM(S5P_CLKGATE_IP_LEFTBUS),
37 SAVE_ITEM(S5P_CLKDIV_RIGHTBUS),
38 SAVE_ITEM(S5P_CLKGATE_IP_RIGHTBUS),
39 SAVE_ITEM(S5P_CLKSRC_TOP0),
40 SAVE_ITEM(S5P_CLKSRC_TOP1),
41 SAVE_ITEM(S5P_CLKSRC_CAM),
42 SAVE_ITEM(S5P_CLKSRC_TV),
43 SAVE_ITEM(S5P_CLKSRC_MFC),
44 SAVE_ITEM(S5P_CLKSRC_G3D),
45 SAVE_ITEM(S5P_CLKSRC_LCD0),
46 SAVE_ITEM(S5P_CLKSRC_MAUDIO),
47 SAVE_ITEM(S5P_CLKSRC_FSYS),
48 SAVE_ITEM(S5P_CLKSRC_PERIL0),
49 SAVE_ITEM(S5P_CLKSRC_PERIL1),
50 SAVE_ITEM(S5P_CLKDIV_CAM),
51 SAVE_ITEM(S5P_CLKDIV_TV),
52 SAVE_ITEM(S5P_CLKDIV_MFC),
53 SAVE_ITEM(S5P_CLKDIV_G3D),
54 SAVE_ITEM(S5P_CLKDIV_LCD0),
55 SAVE_ITEM(S5P_CLKDIV_MAUDIO),
56 SAVE_ITEM(S5P_CLKDIV_FSYS0),
57 SAVE_ITEM(S5P_CLKDIV_FSYS1),
58 SAVE_ITEM(S5P_CLKDIV_FSYS2),
59 SAVE_ITEM(S5P_CLKDIV_FSYS3),
60 SAVE_ITEM(S5P_CLKDIV_PERIL0),
61 SAVE_ITEM(S5P_CLKDIV_PERIL1),
62 SAVE_ITEM(S5P_CLKDIV_PERIL2),
63 SAVE_ITEM(S5P_CLKDIV_PERIL3),
64 SAVE_ITEM(S5P_CLKDIV_PERIL4),
65 SAVE_ITEM(S5P_CLKDIV_PERIL5),
66 SAVE_ITEM(S5P_CLKDIV_TOP),
67 SAVE_ITEM(S5P_CLKSRC_MASK_TOP),
68 SAVE_ITEM(S5P_CLKSRC_MASK_CAM),
69 SAVE_ITEM(S5P_CLKSRC_MASK_TV),
70 SAVE_ITEM(S5P_CLKSRC_MASK_LCD0),
71 SAVE_ITEM(S5P_CLKSRC_MASK_MAUDIO),
72 SAVE_ITEM(S5P_CLKSRC_MASK_FSYS),
73 SAVE_ITEM(S5P_CLKSRC_MASK_PERIL0),
74 SAVE_ITEM(S5P_CLKSRC_MASK_PERIL1),
75 SAVE_ITEM(S5P_CLKDIV2_RATIO),
76 SAVE_ITEM(S5P_CLKGATE_SCLKCAM),
77 SAVE_ITEM(S5P_CLKGATE_IP_CAM),
78 SAVE_ITEM(S5P_CLKGATE_IP_TV),
79 SAVE_ITEM(S5P_CLKGATE_IP_MFC),
80 SAVE_ITEM(S5P_CLKGATE_IP_G3D),
81 SAVE_ITEM(S5P_CLKGATE_IP_LCD0),
82 SAVE_ITEM(S5P_CLKGATE_IP_FSYS),
83 SAVE_ITEM(S5P_CLKGATE_IP_GPS),
84 SAVE_ITEM(S5P_CLKGATE_IP_PERIL),
85 SAVE_ITEM(S5P_CLKGATE_BLOCK),
86 SAVE_ITEM(S5P_CLKSRC_MASK_DMC),
87 SAVE_ITEM(S5P_CLKSRC_DMC),
88 SAVE_ITEM(S5P_CLKDIV_DMC0),
89 SAVE_ITEM(S5P_CLKDIV_DMC1),
90 SAVE_ITEM(S5P_CLKGATE_IP_DMC),
91 SAVE_ITEM(S5P_CLKSRC_CPU),
92 SAVE_ITEM(S5P_CLKDIV_CPU),
93 SAVE_ITEM(S5P_CLKDIV_CPU + 0x4),
94 SAVE_ITEM(S5P_CLKGATE_SCLKCPU),
95 SAVE_ITEM(S5P_CLKGATE_IP_CPU),
96};
97#endif
98
99struct clk clk_sclk_hdmi27m = {
100 .name = "sclk_hdmi27m",
101 .rate = 27000000,
102};
103
104struct clk clk_sclk_hdmiphy = {
105 .name = "sclk_hdmiphy",
106};
107
108struct clk clk_sclk_usbphy0 = {
109 .name = "sclk_usbphy0",
110 .rate = 27000000,
111};
112
113struct clk clk_sclk_usbphy1 = {
114 .name = "sclk_usbphy1",
115};
116
117static struct clk dummy_apb_pclk = {
118 .name = "apb_pclk",
119 .id = -1,
120};
121
122static int exynos4_clksrc_mask_top_ctrl(struct clk *clk, int enable)
123{
124 return s5p_gatectrl(S5P_CLKSRC_MASK_TOP, clk, enable);
125}
126
127static int exynos4_clksrc_mask_cam_ctrl(struct clk *clk, int enable)
128{
129 return s5p_gatectrl(S5P_CLKSRC_MASK_CAM, clk, enable);
130}
131
132static int exynos4_clksrc_mask_lcd0_ctrl(struct clk *clk, int enable)
133{
134 return s5p_gatectrl(S5P_CLKSRC_MASK_LCD0, clk, enable);
135}
136
137int exynos4_clksrc_mask_fsys_ctrl(struct clk *clk, int enable)
138{
139 return s5p_gatectrl(S5P_CLKSRC_MASK_FSYS, clk, enable);
140}
141
142static int exynos4_clksrc_mask_peril0_ctrl(struct clk *clk, int enable)
143{
144 return s5p_gatectrl(S5P_CLKSRC_MASK_PERIL0, clk, enable);
145}
146
147static int exynos4_clksrc_mask_peril1_ctrl(struct clk *clk, int enable)
148{
149 return s5p_gatectrl(S5P_CLKSRC_MASK_PERIL1, clk, enable);
150}
151
152static int exynos4_clk_ip_mfc_ctrl(struct clk *clk, int enable)
153{
154 return s5p_gatectrl(S5P_CLKGATE_IP_MFC, clk, enable);
155}
156
157static int exynos4_clksrc_mask_tv_ctrl(struct clk *clk, int enable)
158{
159 return s5p_gatectrl(S5P_CLKSRC_MASK_TV, clk, enable);
160}
161
162static int exynos4_clk_ip_cam_ctrl(struct clk *clk, int enable)
163{
164 return s5p_gatectrl(S5P_CLKGATE_IP_CAM, clk, enable);
165}
166
167static int exynos4_clk_ip_tv_ctrl(struct clk *clk, int enable)
168{
169 return s5p_gatectrl(S5P_CLKGATE_IP_TV, clk, enable);
170}
171
172static int exynos4_clk_ip_image_ctrl(struct clk *clk, int enable)
173{
174 return s5p_gatectrl(S5P_CLKGATE_IP_IMAGE, clk, enable);
175}
176
177static int exynos4_clk_ip_lcd0_ctrl(struct clk *clk, int enable)
178{
179 return s5p_gatectrl(S5P_CLKGATE_IP_LCD0, clk, enable);
180}
181
182int exynos4_clk_ip_lcd1_ctrl(struct clk *clk, int enable)
183{
184 return s5p_gatectrl(S5P_CLKGATE_IP_LCD1, clk, enable);
185}
186
187int exynos4_clk_ip_fsys_ctrl(struct clk *clk, int enable)
188{
189 return s5p_gatectrl(S5P_CLKGATE_IP_FSYS, clk, enable);
190}
191
192static int exynos4_clk_ip_peril_ctrl(struct clk *clk, int enable)
193{
194 return s5p_gatectrl(S5P_CLKGATE_IP_PERIL, clk, enable);
195}
196
197static int exynos4_clk_ip_perir_ctrl(struct clk *clk, int enable)
198{
199 return s5p_gatectrl(S5P_CLKGATE_IP_PERIR, clk, enable);
200}
201
202static int exynos4_clk_hdmiphy_ctrl(struct clk *clk, int enable)
203{
204 return s5p_gatectrl(S5P_HDMI_PHY_CONTROL, clk, enable);
205}
206
207static int exynos4_clk_dac_ctrl(struct clk *clk, int enable)
208{
209 return s5p_gatectrl(S5P_DAC_PHY_CONTROL, clk, enable);
210}
211
212/* Core list of CMU_CPU side */
213
214static struct clksrc_clk clk_mout_apll = {
215 .clk = {
216 .name = "mout_apll",
217 },
218 .sources = &clk_src_apll,
219 .reg_src = { .reg = S5P_CLKSRC_CPU, .shift = 0, .size = 1 },
220};
221
222struct clksrc_clk clk_sclk_apll = {
223 .clk = {
224 .name = "sclk_apll",
225 .parent = &clk_mout_apll.clk,
226 },
227 .reg_div = { .reg = S5P_CLKDIV_CPU, .shift = 24, .size = 3 },
228};
229
230struct clksrc_clk clk_mout_epll = {
231 .clk = {
232 .name = "mout_epll",
233 },
234 .sources = &clk_src_epll,
235 .reg_src = { .reg = S5P_CLKSRC_TOP0, .shift = 4, .size = 1 },
236};
237
238struct clksrc_clk clk_mout_mpll = {
239 .clk = {
240 .name = "mout_mpll",
241 },
242 .sources = &clk_src_mpll,
243
244 /* reg_src will be added in each SoCs' clock */
245};
246
247static struct clk *clkset_moutcore_list[] = {
248 [0] = &clk_mout_apll.clk,
249 [1] = &clk_mout_mpll.clk,
250};
251
252static struct clksrc_sources clkset_moutcore = {
253 .sources = clkset_moutcore_list,
254 .nr_sources = ARRAY_SIZE(clkset_moutcore_list),
255};
256
257static struct clksrc_clk clk_moutcore = {
258 .clk = {
259 .name = "moutcore",
260 },
261 .sources = &clkset_moutcore,
262 .reg_src = { .reg = S5P_CLKSRC_CPU, .shift = 16, .size = 1 },
263};
264
265static struct clksrc_clk clk_coreclk = {
266 .clk = {
267 .name = "core_clk",
268 .parent = &clk_moutcore.clk,
269 },
270 .reg_div = { .reg = S5P_CLKDIV_CPU, .shift = 0, .size = 3 },
271};
272
273static struct clksrc_clk clk_armclk = {
274 .clk = {
275 .name = "armclk",
276 .parent = &clk_coreclk.clk,
277 },
278};
279
280static struct clksrc_clk clk_aclk_corem0 = {
281 .clk = {
282 .name = "aclk_corem0",
283 .parent = &clk_coreclk.clk,
284 },
285 .reg_div = { .reg = S5P_CLKDIV_CPU, .shift = 4, .size = 3 },
286};
287
288static struct clksrc_clk clk_aclk_cores = {
289 .clk = {
290 .name = "aclk_cores",
291 .parent = &clk_coreclk.clk,
292 },
293 .reg_div = { .reg = S5P_CLKDIV_CPU, .shift = 4, .size = 3 },
294};
295
296static struct clksrc_clk clk_aclk_corem1 = {
297 .clk = {
298 .name = "aclk_corem1",
299 .parent = &clk_coreclk.clk,
300 },
301 .reg_div = { .reg = S5P_CLKDIV_CPU, .shift = 8, .size = 3 },
302};
303
304static struct clksrc_clk clk_periphclk = {
305 .clk = {
306 .name = "periphclk",
307 .parent = &clk_coreclk.clk,
308 },
309 .reg_div = { .reg = S5P_CLKDIV_CPU, .shift = 12, .size = 3 },
310};
311
312/* Core list of CMU_CORE side */
313
314struct clk *clkset_corebus_list[] = {
315 [0] = &clk_mout_mpll.clk,
316 [1] = &clk_sclk_apll.clk,
317};
318
319struct clksrc_sources clkset_mout_corebus = {
320 .sources = clkset_corebus_list,
321 .nr_sources = ARRAY_SIZE(clkset_corebus_list),
322};
323
324static struct clksrc_clk clk_mout_corebus = {
325 .clk = {
326 .name = "mout_corebus",
327 },
328 .sources = &clkset_mout_corebus,
329 .reg_src = { .reg = S5P_CLKSRC_DMC, .shift = 4, .size = 1 },
330};
331
332static struct clksrc_clk clk_sclk_dmc = {
333 .clk = {
334 .name = "sclk_dmc",
335 .parent = &clk_mout_corebus.clk,
336 },
337 .reg_div = { .reg = S5P_CLKDIV_DMC0, .shift = 12, .size = 3 },
338};
339
340static struct clksrc_clk clk_aclk_cored = {
341 .clk = {
342 .name = "aclk_cored",
343 .parent = &clk_sclk_dmc.clk,
344 },
345 .reg_div = { .reg = S5P_CLKDIV_DMC0, .shift = 16, .size = 3 },
346};
347
348static struct clksrc_clk clk_aclk_corep = {
349 .clk = {
350 .name = "aclk_corep",
351 .parent = &clk_aclk_cored.clk,
352 },
353 .reg_div = { .reg = S5P_CLKDIV_DMC0, .shift = 20, .size = 3 },
354};
355
356static struct clksrc_clk clk_aclk_acp = {
357 .clk = {
358 .name = "aclk_acp",
359 .parent = &clk_mout_corebus.clk,
360 },
361 .reg_div = { .reg = S5P_CLKDIV_DMC0, .shift = 0, .size = 3 },
362};
363
364static struct clksrc_clk clk_pclk_acp = {
365 .clk = {
366 .name = "pclk_acp",
367 .parent = &clk_aclk_acp.clk,
368 },
369 .reg_div = { .reg = S5P_CLKDIV_DMC0, .shift = 4, .size = 3 },
370};
371
372/* Core list of CMU_TOP side */
373
374struct clk *clkset_aclk_top_list[] = {
375 [0] = &clk_mout_mpll.clk,
376 [1] = &clk_sclk_apll.clk,
377};
378
379struct clksrc_sources clkset_aclk = {
380 .sources = clkset_aclk_top_list,
381 .nr_sources = ARRAY_SIZE(clkset_aclk_top_list),
382};
383
384static struct clksrc_clk clk_aclk_200 = {
385 .clk = {
386 .name = "aclk_200",
387 },
388 .sources = &clkset_aclk,
389 .reg_src = { .reg = S5P_CLKSRC_TOP0, .shift = 12, .size = 1 },
390 .reg_div = { .reg = S5P_CLKDIV_TOP, .shift = 0, .size = 3 },
391};
392
393static struct clksrc_clk clk_aclk_100 = {
394 .clk = {
395 .name = "aclk_100",
396 },
397 .sources = &clkset_aclk,
398 .reg_src = { .reg = S5P_CLKSRC_TOP0, .shift = 16, .size = 1 },
399 .reg_div = { .reg = S5P_CLKDIV_TOP, .shift = 4, .size = 4 },
400};
401
402static struct clksrc_clk clk_aclk_160 = {
403 .clk = {
404 .name = "aclk_160",
405 },
406 .sources = &clkset_aclk,
407 .reg_src = { .reg = S5P_CLKSRC_TOP0, .shift = 20, .size = 1 },
408 .reg_div = { .reg = S5P_CLKDIV_TOP, .shift = 8, .size = 3 },
409};
410
411struct clksrc_clk clk_aclk_133 = {
412 .clk = {
413 .name = "aclk_133",
414 },
415 .sources = &clkset_aclk,
416 .reg_src = { .reg = S5P_CLKSRC_TOP0, .shift = 24, .size = 1 },
417 .reg_div = { .reg = S5P_CLKDIV_TOP, .shift = 12, .size = 3 },
418};
419
420static struct clk *clkset_vpllsrc_list[] = {
421 [0] = &clk_fin_vpll,
422 [1] = &clk_sclk_hdmi27m,
423};
424
425static struct clksrc_sources clkset_vpllsrc = {
426 .sources = clkset_vpllsrc_list,
427 .nr_sources = ARRAY_SIZE(clkset_vpllsrc_list),
428};
429
430static struct clksrc_clk clk_vpllsrc = {
431 .clk = {
432 .name = "vpll_src",
433 .enable = exynos4_clksrc_mask_top_ctrl,
434 .ctrlbit = (1 << 0),
435 },
436 .sources = &clkset_vpllsrc,
437 .reg_src = { .reg = S5P_CLKSRC_TOP1, .shift = 0, .size = 1 },
438};
439
440static struct clk *clkset_sclk_vpll_list[] = {
441 [0] = &clk_vpllsrc.clk,
442 [1] = &clk_fout_vpll,
443};
444
445static struct clksrc_sources clkset_sclk_vpll = {
446 .sources = clkset_sclk_vpll_list,
447 .nr_sources = ARRAY_SIZE(clkset_sclk_vpll_list),
448};
449
450struct clksrc_clk clk_sclk_vpll = {
451 .clk = {
452 .name = "sclk_vpll",
453 },
454 .sources = &clkset_sclk_vpll,
455 .reg_src = { .reg = S5P_CLKSRC_TOP0, .shift = 8, .size = 1 },
456};
457
458static struct clk init_clocks_off[] = {
459 {
460 .name = "timers",
461 .parent = &clk_aclk_100.clk,
462 .enable = exynos4_clk_ip_peril_ctrl,
463 .ctrlbit = (1<<24),
464 }, {
465 .name = "csis",
466 .devname = "s5p-mipi-csis.0",
467 .enable = exynos4_clk_ip_cam_ctrl,
468 .ctrlbit = (1 << 4),
469 }, {
470 .name = "csis",
471 .devname = "s5p-mipi-csis.1",
472 .enable = exynos4_clk_ip_cam_ctrl,
473 .ctrlbit = (1 << 5),
474 }, {
475 .name = "fimc",
476 .devname = "exynos4-fimc.0",
477 .enable = exynos4_clk_ip_cam_ctrl,
478 .ctrlbit = (1 << 0),
479 }, {
480 .name = "fimc",
481 .devname = "exynos4-fimc.1",
482 .enable = exynos4_clk_ip_cam_ctrl,
483 .ctrlbit = (1 << 1),
484 }, {
485 .name = "fimc",
486 .devname = "exynos4-fimc.2",
487 .enable = exynos4_clk_ip_cam_ctrl,
488 .ctrlbit = (1 << 2),
489 }, {
490 .name = "fimc",
491 .devname = "exynos4-fimc.3",
492 .enable = exynos4_clk_ip_cam_ctrl,
493 .ctrlbit = (1 << 3),
494 }, {
495 .name = "fimd",
496 .devname = "exynos4-fb.0",
497 .enable = exynos4_clk_ip_lcd0_ctrl,
498 .ctrlbit = (1 << 0),
499 }, {
500 .name = "hsmmc",
501 .devname = "s3c-sdhci.0",
502 .parent = &clk_aclk_133.clk,
503 .enable = exynos4_clk_ip_fsys_ctrl,
504 .ctrlbit = (1 << 5),
505 }, {
506 .name = "hsmmc",
507 .devname = "s3c-sdhci.1",
508 .parent = &clk_aclk_133.clk,
509 .enable = exynos4_clk_ip_fsys_ctrl,
510 .ctrlbit = (1 << 6),
511 }, {
512 .name = "hsmmc",
513 .devname = "s3c-sdhci.2",
514 .parent = &clk_aclk_133.clk,
515 .enable = exynos4_clk_ip_fsys_ctrl,
516 .ctrlbit = (1 << 7),
517 }, {
518 .name = "hsmmc",
519 .devname = "s3c-sdhci.3",
520 .parent = &clk_aclk_133.clk,
521 .enable = exynos4_clk_ip_fsys_ctrl,
522 .ctrlbit = (1 << 8),
523 }, {
524 .name = "dwmmc",
525 .parent = &clk_aclk_133.clk,
526 .enable = exynos4_clk_ip_fsys_ctrl,
527 .ctrlbit = (1 << 9),
528 }, {
529 .name = "dac",
530 .devname = "s5p-sdo",
531 .enable = exynos4_clk_ip_tv_ctrl,
532 .ctrlbit = (1 << 2),
533 }, {
534 .name = "mixer",
535 .devname = "s5p-mixer",
536 .enable = exynos4_clk_ip_tv_ctrl,
537 .ctrlbit = (1 << 1),
538 }, {
539 .name = "vp",
540 .devname = "s5p-mixer",
541 .enable = exynos4_clk_ip_tv_ctrl,
542 .ctrlbit = (1 << 0),
543 }, {
544 .name = "hdmi",
545 .devname = "exynos4-hdmi",
546 .enable = exynos4_clk_ip_tv_ctrl,
547 .ctrlbit = (1 << 3),
548 }, {
549 .name = "hdmiphy",
550 .devname = "exynos4-hdmi",
551 .enable = exynos4_clk_hdmiphy_ctrl,
552 .ctrlbit = (1 << 0),
553 }, {
554 .name = "dacphy",
555 .devname = "s5p-sdo",
556 .enable = exynos4_clk_dac_ctrl,
557 .ctrlbit = (1 << 0),
558 }, {
559 .name = "adc",
560 .enable = exynos4_clk_ip_peril_ctrl,
561 .ctrlbit = (1 << 15),
562 }, {
563 .name = "keypad",
564 .enable = exynos4_clk_ip_perir_ctrl,
565 .ctrlbit = (1 << 16),
566 }, {
567 .name = "rtc",
568 .enable = exynos4_clk_ip_perir_ctrl,
569 .ctrlbit = (1 << 15),
570 }, {
571 .name = "watchdog",
572 .parent = &clk_aclk_100.clk,
573 .enable = exynos4_clk_ip_perir_ctrl,
574 .ctrlbit = (1 << 14),
575 }, {
576 .name = "usbhost",
577 .enable = exynos4_clk_ip_fsys_ctrl ,
578 .ctrlbit = (1 << 12),
579 }, {
580 .name = "otg",
581 .enable = exynos4_clk_ip_fsys_ctrl,
582 .ctrlbit = (1 << 13),
583 }, {
584 .name = "spi",
585 .devname = "s3c64xx-spi.0",
586 .enable = exynos4_clk_ip_peril_ctrl,
587 .ctrlbit = (1 << 16),
588 }, {
589 .name = "spi",
590 .devname = "s3c64xx-spi.1",
591 .enable = exynos4_clk_ip_peril_ctrl,
592 .ctrlbit = (1 << 17),
593 }, {
594 .name = "spi",
595 .devname = "s3c64xx-spi.2",
596 .enable = exynos4_clk_ip_peril_ctrl,
597 .ctrlbit = (1 << 18),
598 }, {
599 .name = "iis",
600 .devname = "samsung-i2s.0",
601 .enable = exynos4_clk_ip_peril_ctrl,
602 .ctrlbit = (1 << 19),
603 }, {
604 .name = "iis",
605 .devname = "samsung-i2s.1",
606 .enable = exynos4_clk_ip_peril_ctrl,
607 .ctrlbit = (1 << 20),
608 }, {
609 .name = "iis",
610 .devname = "samsung-i2s.2",
611 .enable = exynos4_clk_ip_peril_ctrl,
612 .ctrlbit = (1 << 21),
613 }, {
614 .name = "ac97",
615 .devname = "samsung-ac97",
616 .enable = exynos4_clk_ip_peril_ctrl,
617 .ctrlbit = (1 << 27),
618 }, {
619 .name = "fimg2d",
620 .enable = exynos4_clk_ip_image_ctrl,
621 .ctrlbit = (1 << 0),
622 }, {
623 .name = "mfc",
624 .devname = "s5p-mfc",
625 .enable = exynos4_clk_ip_mfc_ctrl,
626 .ctrlbit = (1 << 0),
627 }, {
628 .name = "i2c",
629 .devname = "s3c2440-i2c.0",
630 .parent = &clk_aclk_100.clk,
631 .enable = exynos4_clk_ip_peril_ctrl,
632 .ctrlbit = (1 << 6),
633 }, {
634 .name = "i2c",
635 .devname = "s3c2440-i2c.1",
636 .parent = &clk_aclk_100.clk,
637 .enable = exynos4_clk_ip_peril_ctrl,
638 .ctrlbit = (1 << 7),
639 }, {
640 .name = "i2c",
641 .devname = "s3c2440-i2c.2",
642 .parent = &clk_aclk_100.clk,
643 .enable = exynos4_clk_ip_peril_ctrl,
644 .ctrlbit = (1 << 8),
645 }, {
646 .name = "i2c",
647 .devname = "s3c2440-i2c.3",
648 .parent = &clk_aclk_100.clk,
649 .enable = exynos4_clk_ip_peril_ctrl,
650 .ctrlbit = (1 << 9),
651 }, {
652 .name = "i2c",
653 .devname = "s3c2440-i2c.4",
654 .parent = &clk_aclk_100.clk,
655 .enable = exynos4_clk_ip_peril_ctrl,
656 .ctrlbit = (1 << 10),
657 }, {
658 .name = "i2c",
659 .devname = "s3c2440-i2c.5",
660 .parent = &clk_aclk_100.clk,
661 .enable = exynos4_clk_ip_peril_ctrl,
662 .ctrlbit = (1 << 11),
663 }, {
664 .name = "i2c",
665 .devname = "s3c2440-i2c.6",
666 .parent = &clk_aclk_100.clk,
667 .enable = exynos4_clk_ip_peril_ctrl,
668 .ctrlbit = (1 << 12),
669 }, {
670 .name = "i2c",
671 .devname = "s3c2440-i2c.7",
672 .parent = &clk_aclk_100.clk,
673 .enable = exynos4_clk_ip_peril_ctrl,
674 .ctrlbit = (1 << 13),
675 }, {
676 .name = "i2c",
677 .devname = "s3c2440-hdmiphy-i2c",
678 .parent = &clk_aclk_100.clk,
679 .enable = exynos4_clk_ip_peril_ctrl,
680 .ctrlbit = (1 << 14),
681 }, {
682 .name = "SYSMMU_MDMA",
683 .enable = exynos4_clk_ip_image_ctrl,
684 .ctrlbit = (1 << 5),
685 }, {
686 .name = "SYSMMU_FIMC0",
687 .enable = exynos4_clk_ip_cam_ctrl,
688 .ctrlbit = (1 << 7),
689 }, {
690 .name = "SYSMMU_FIMC1",
691 .enable = exynos4_clk_ip_cam_ctrl,
692 .ctrlbit = (1 << 8),
693 }, {
694 .name = "SYSMMU_FIMC2",
695 .enable = exynos4_clk_ip_cam_ctrl,
696 .ctrlbit = (1 << 9),
697 }, {
698 .name = "SYSMMU_FIMC3",
699 .enable = exynos4_clk_ip_cam_ctrl,
700 .ctrlbit = (1 << 10),
701 }, {
702 .name = "SYSMMU_JPEG",
703 .enable = exynos4_clk_ip_cam_ctrl,
704 .ctrlbit = (1 << 11),
705 }, {
706 .name = "SYSMMU_FIMD0",
707 .enable = exynos4_clk_ip_lcd0_ctrl,
708 .ctrlbit = (1 << 4),
709 }, {
710 .name = "SYSMMU_FIMD1",
711 .enable = exynos4_clk_ip_lcd1_ctrl,
712 .ctrlbit = (1 << 4),
713 }, {
714 .name = "SYSMMU_PCIe",
715 .enable = exynos4_clk_ip_fsys_ctrl,
716 .ctrlbit = (1 << 18),
717 }, {
718 .name = "SYSMMU_G2D",
719 .enable = exynos4_clk_ip_image_ctrl,
720 .ctrlbit = (1 << 3),
721 }, {
722 .name = "SYSMMU_ROTATOR",
723 .enable = exynos4_clk_ip_image_ctrl,
724 .ctrlbit = (1 << 4),
725 }, {
726 .name = "SYSMMU_TV",
727 .enable = exynos4_clk_ip_tv_ctrl,
728 .ctrlbit = (1 << 4),
729 }, {
730 .name = "SYSMMU_MFC_L",
731 .enable = exynos4_clk_ip_mfc_ctrl,
732 .ctrlbit = (1 << 1),
733 }, {
734 .name = "SYSMMU_MFC_R",
735 .enable = exynos4_clk_ip_mfc_ctrl,
736 .ctrlbit = (1 << 2),
737 }
738};
739
740static struct clk init_clocks[] = {
741 {
742 .name = "uart",
743 .devname = "s5pv210-uart.0",
744 .enable = exynos4_clk_ip_peril_ctrl,
745 .ctrlbit = (1 << 0),
746 }, {
747 .name = "uart",
748 .devname = "s5pv210-uart.1",
749 .enable = exynos4_clk_ip_peril_ctrl,
750 .ctrlbit = (1 << 1),
751 }, {
752 .name = "uart",
753 .devname = "s5pv210-uart.2",
754 .enable = exynos4_clk_ip_peril_ctrl,
755 .ctrlbit = (1 << 2),
756 }, {
757 .name = "uart",
758 .devname = "s5pv210-uart.3",
759 .enable = exynos4_clk_ip_peril_ctrl,
760 .ctrlbit = (1 << 3),
761 }, {
762 .name = "uart",
763 .devname = "s5pv210-uart.4",
764 .enable = exynos4_clk_ip_peril_ctrl,
765 .ctrlbit = (1 << 4),
766 }, {
767 .name = "uart",
768 .devname = "s5pv210-uart.5",
769 .enable = exynos4_clk_ip_peril_ctrl,
770 .ctrlbit = (1 << 5),
771 }
772};
773
774static struct clk clk_pdma0 = {
775 .name = "dma",
776 .devname = "dma-pl330.0",
777 .enable = exynos4_clk_ip_fsys_ctrl,
778 .ctrlbit = (1 << 0),
779};
780
781static struct clk clk_pdma1 = {
782 .name = "dma",
783 .devname = "dma-pl330.1",
784 .enable = exynos4_clk_ip_fsys_ctrl,
785 .ctrlbit = (1 << 1),
786};
787
788struct clk *clkset_group_list[] = {
789 [0] = &clk_ext_xtal_mux,
790 [1] = &clk_xusbxti,
791 [2] = &clk_sclk_hdmi27m,
792 [3] = &clk_sclk_usbphy0,
793 [4] = &clk_sclk_usbphy1,
794 [5] = &clk_sclk_hdmiphy,
795 [6] = &clk_mout_mpll.clk,
796 [7] = &clk_mout_epll.clk,
797 [8] = &clk_sclk_vpll.clk,
798};
799
800struct clksrc_sources clkset_group = {
801 .sources = clkset_group_list,
802 .nr_sources = ARRAY_SIZE(clkset_group_list),
803};
804
805static struct clk *clkset_mout_g2d0_list[] = {
806 [0] = &clk_mout_mpll.clk,
807 [1] = &clk_sclk_apll.clk,
808};
809
810static struct clksrc_sources clkset_mout_g2d0 = {
811 .sources = clkset_mout_g2d0_list,
812 .nr_sources = ARRAY_SIZE(clkset_mout_g2d0_list),
813};
814
815static struct clksrc_clk clk_mout_g2d0 = {
816 .clk = {
817 .name = "mout_g2d0",
818 },
819 .sources = &clkset_mout_g2d0,
820 .reg_src = { .reg = S5P_CLKSRC_IMAGE, .shift = 0, .size = 1 },
821};
822
823static struct clk *clkset_mout_g2d1_list[] = {
824 [0] = &clk_mout_epll.clk,
825 [1] = &clk_sclk_vpll.clk,
826};
827
828static struct clksrc_sources clkset_mout_g2d1 = {
829 .sources = clkset_mout_g2d1_list,
830 .nr_sources = ARRAY_SIZE(clkset_mout_g2d1_list),
831};
832
833static struct clksrc_clk clk_mout_g2d1 = {
834 .clk = {
835 .name = "mout_g2d1",
836 },
837 .sources = &clkset_mout_g2d1,
838 .reg_src = { .reg = S5P_CLKSRC_IMAGE, .shift = 4, .size = 1 },
839};
840
841static struct clk *clkset_mout_g2d_list[] = {
842 [0] = &clk_mout_g2d0.clk,
843 [1] = &clk_mout_g2d1.clk,
844};
845
846static struct clksrc_sources clkset_mout_g2d = {
847 .sources = clkset_mout_g2d_list,
848 .nr_sources = ARRAY_SIZE(clkset_mout_g2d_list),
849};
850
851static struct clk *clkset_mout_mfc0_list[] = {
852 [0] = &clk_mout_mpll.clk,
853 [1] = &clk_sclk_apll.clk,
854};
855
856static struct clksrc_sources clkset_mout_mfc0 = {
857 .sources = clkset_mout_mfc0_list,
858 .nr_sources = ARRAY_SIZE(clkset_mout_mfc0_list),
859};
860
861static struct clksrc_clk clk_mout_mfc0 = {
862 .clk = {
863 .name = "mout_mfc0",
864 },
865 .sources = &clkset_mout_mfc0,
866 .reg_src = { .reg = S5P_CLKSRC_MFC, .shift = 0, .size = 1 },
867};
868
869static struct clk *clkset_mout_mfc1_list[] = {
870 [0] = &clk_mout_epll.clk,
871 [1] = &clk_sclk_vpll.clk,
872};
873
874static struct clksrc_sources clkset_mout_mfc1 = {
875 .sources = clkset_mout_mfc1_list,
876 .nr_sources = ARRAY_SIZE(clkset_mout_mfc1_list),
877};
878
879static struct clksrc_clk clk_mout_mfc1 = {
880 .clk = {
881 .name = "mout_mfc1",
882 },
883 .sources = &clkset_mout_mfc1,
884 .reg_src = { .reg = S5P_CLKSRC_MFC, .shift = 4, .size = 1 },
885};
886
887static struct clk *clkset_mout_mfc_list[] = {
888 [0] = &clk_mout_mfc0.clk,
889 [1] = &clk_mout_mfc1.clk,
890};
891
892static struct clksrc_sources clkset_mout_mfc = {
893 .sources = clkset_mout_mfc_list,
894 .nr_sources = ARRAY_SIZE(clkset_mout_mfc_list),
895};
896
897static struct clk *clkset_sclk_dac_list[] = {
898 [0] = &clk_sclk_vpll.clk,
899 [1] = &clk_sclk_hdmiphy,
900};
901
902static struct clksrc_sources clkset_sclk_dac = {
903 .sources = clkset_sclk_dac_list,
904 .nr_sources = ARRAY_SIZE(clkset_sclk_dac_list),
905};
906
907static struct clksrc_clk clk_sclk_dac = {
908 .clk = {
909 .name = "sclk_dac",
910 .enable = exynos4_clksrc_mask_tv_ctrl,
911 .ctrlbit = (1 << 8),
912 },
913 .sources = &clkset_sclk_dac,
914 .reg_src = { .reg = S5P_CLKSRC_TV, .shift = 8, .size = 1 },
915};
916
917static struct clksrc_clk clk_sclk_pixel = {
918 .clk = {
919 .name = "sclk_pixel",
920 .parent = &clk_sclk_vpll.clk,
921 },
922 .reg_div = { .reg = S5P_CLKDIV_TV, .shift = 0, .size = 4 },
923};
924
925static struct clk *clkset_sclk_hdmi_list[] = {
926 [0] = &clk_sclk_pixel.clk,
927 [1] = &clk_sclk_hdmiphy,
928};
929
930static struct clksrc_sources clkset_sclk_hdmi = {
931 .sources = clkset_sclk_hdmi_list,
932 .nr_sources = ARRAY_SIZE(clkset_sclk_hdmi_list),
933};
934
935static struct clksrc_clk clk_sclk_hdmi = {
936 .clk = {
937 .name = "sclk_hdmi",
938 .enable = exynos4_clksrc_mask_tv_ctrl,
939 .ctrlbit = (1 << 0),
940 },
941 .sources = &clkset_sclk_hdmi,
942 .reg_src = { .reg = S5P_CLKSRC_TV, .shift = 0, .size = 1 },
943};
944
945static struct clk *clkset_sclk_mixer_list[] = {
946 [0] = &clk_sclk_dac.clk,
947 [1] = &clk_sclk_hdmi.clk,
948};
949
950static struct clksrc_sources clkset_sclk_mixer = {
951 .sources = clkset_sclk_mixer_list,
952 .nr_sources = ARRAY_SIZE(clkset_sclk_mixer_list),
953};
954
955static struct clksrc_clk clk_sclk_mixer = {
956 .clk = {
957 .name = "sclk_mixer",
958 .enable = exynos4_clksrc_mask_tv_ctrl,
959 .ctrlbit = (1 << 4),
960 },
961 .sources = &clkset_sclk_mixer,
962 .reg_src = { .reg = S5P_CLKSRC_TV, .shift = 4, .size = 1 },
963};
964
965static struct clksrc_clk *sclk_tv[] = {
966 &clk_sclk_dac,
967 &clk_sclk_pixel,
968 &clk_sclk_hdmi,
969 &clk_sclk_mixer,
970};
971
972static struct clksrc_clk clk_dout_mmc0 = {
973 .clk = {
974 .name = "dout_mmc0",
975 },
976 .sources = &clkset_group,
977 .reg_src = { .reg = S5P_CLKSRC_FSYS, .shift = 0, .size = 4 },
978 .reg_div = { .reg = S5P_CLKDIV_FSYS1, .shift = 0, .size = 4 },
979};
980
981static struct clksrc_clk clk_dout_mmc1 = {
982 .clk = {
983 .name = "dout_mmc1",
984 },
985 .sources = &clkset_group,
986 .reg_src = { .reg = S5P_CLKSRC_FSYS, .shift = 4, .size = 4 },
987 .reg_div = { .reg = S5P_CLKDIV_FSYS1, .shift = 16, .size = 4 },
988};
989
990static struct clksrc_clk clk_dout_mmc2 = {
991 .clk = {
992 .name = "dout_mmc2",
993 },
994 .sources = &clkset_group,
995 .reg_src = { .reg = S5P_CLKSRC_FSYS, .shift = 8, .size = 4 },
996 .reg_div = { .reg = S5P_CLKDIV_FSYS2, .shift = 0, .size = 4 },
997};
998
999static struct clksrc_clk clk_dout_mmc3 = {
1000 .clk = {
1001 .name = "dout_mmc3",
1002 },
1003 .sources = &clkset_group,
1004 .reg_src = { .reg = S5P_CLKSRC_FSYS, .shift = 12, .size = 4 },
1005 .reg_div = { .reg = S5P_CLKDIV_FSYS2, .shift = 16, .size = 4 },
1006};
1007
1008static struct clksrc_clk clk_dout_mmc4 = {
1009 .clk = {
1010 .name = "dout_mmc4",
1011 },
1012 .sources = &clkset_group,
1013 .reg_src = { .reg = S5P_CLKSRC_FSYS, .shift = 16, .size = 4 },
1014 .reg_div = { .reg = S5P_CLKDIV_FSYS3, .shift = 0, .size = 4 },
1015};
1016
1017static struct clksrc_clk clksrcs[] = {
1018 {
1019 .clk = {
1020 .name = "sclk_pwm",
1021 .enable = exynos4_clksrc_mask_peril0_ctrl,
1022 .ctrlbit = (1 << 24),
1023 },
1024 .sources = &clkset_group,
1025 .reg_src = { .reg = S5P_CLKSRC_PERIL0, .shift = 24, .size = 4 },
1026 .reg_div = { .reg = S5P_CLKDIV_PERIL3, .shift = 0, .size = 4 },
1027 }, {
1028 .clk = {
1029 .name = "sclk_csis",
1030 .devname = "s5p-mipi-csis.0",
1031 .enable = exynos4_clksrc_mask_cam_ctrl,
1032 .ctrlbit = (1 << 24),
1033 },
1034 .sources = &clkset_group,
1035 .reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 24, .size = 4 },
1036 .reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 24, .size = 4 },
1037 }, {
1038 .clk = {
1039 .name = "sclk_csis",
1040 .devname = "s5p-mipi-csis.1",
1041 .enable = exynos4_clksrc_mask_cam_ctrl,
1042 .ctrlbit = (1 << 28),
1043 },
1044 .sources = &clkset_group,
1045 .reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 28, .size = 4 },
1046 .reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 28, .size = 4 },
1047 }, {
1048 .clk = {
1049 .name = "sclk_cam0",
1050 .enable = exynos4_clksrc_mask_cam_ctrl,
1051 .ctrlbit = (1 << 16),
1052 },
1053 .sources = &clkset_group,
1054 .reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 16, .size = 4 },
1055 .reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 16, .size = 4 },
1056 }, {
1057 .clk = {
1058 .name = "sclk_cam1",
1059 .enable = exynos4_clksrc_mask_cam_ctrl,
1060 .ctrlbit = (1 << 20),
1061 },
1062 .sources = &clkset_group,
1063 .reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 20, .size = 4 },
1064 .reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 20, .size = 4 },
1065 }, {
1066 .clk = {
1067 .name = "sclk_fimc",
1068 .devname = "exynos4-fimc.0",
1069 .enable = exynos4_clksrc_mask_cam_ctrl,
1070 .ctrlbit = (1 << 0),
1071 },
1072 .sources = &clkset_group,
1073 .reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 0, .size = 4 },
1074 .reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 0, .size = 4 },
1075 }, {
1076 .clk = {
1077 .name = "sclk_fimc",
1078 .devname = "exynos4-fimc.1",
1079 .enable = exynos4_clksrc_mask_cam_ctrl,
1080 .ctrlbit = (1 << 4),
1081 },
1082 .sources = &clkset_group,
1083 .reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 4, .size = 4 },
1084 .reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 4, .size = 4 },
1085 }, {
1086 .clk = {
1087 .name = "sclk_fimc",
1088 .devname = "exynos4-fimc.2",
1089 .enable = exynos4_clksrc_mask_cam_ctrl,
1090 .ctrlbit = (1 << 8),
1091 },
1092 .sources = &clkset_group,
1093 .reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 8, .size = 4 },
1094 .reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 8, .size = 4 },
1095 }, {
1096 .clk = {
1097 .name = "sclk_fimc",
1098 .devname = "exynos4-fimc.3",
1099 .enable = exynos4_clksrc_mask_cam_ctrl,
1100 .ctrlbit = (1 << 12),
1101 },
1102 .sources = &clkset_group,
1103 .reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 12, .size = 4 },
1104 .reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 12, .size = 4 },
1105 }, {
1106 .clk = {
1107 .name = "sclk_fimd",
1108 .devname = "exynos4-fb.0",
1109 .enable = exynos4_clksrc_mask_lcd0_ctrl,
1110 .ctrlbit = (1 << 0),
1111 },
1112 .sources = &clkset_group,
1113 .reg_src = { .reg = S5P_CLKSRC_LCD0, .shift = 0, .size = 4 },
1114 .reg_div = { .reg = S5P_CLKDIV_LCD0, .shift = 0, .size = 4 },
1115 }, {
1116 .clk = {
1117 .name = "sclk_fimg2d",
1118 },
1119 .sources = &clkset_mout_g2d,
1120 .reg_src = { .reg = S5P_CLKSRC_IMAGE, .shift = 8, .size = 1 },
1121 .reg_div = { .reg = S5P_CLKDIV_IMAGE, .shift = 0, .size = 4 },
1122 }, {
1123 .clk = {
1124 .name = "sclk_mfc",
1125 .devname = "s5p-mfc",
1126 },
1127 .sources = &clkset_mout_mfc,
1128 .reg_src = { .reg = S5P_CLKSRC_MFC, .shift = 8, .size = 1 },
1129 .reg_div = { .reg = S5P_CLKDIV_MFC, .shift = 0, .size = 4 },
1130 }, {
1131 .clk = {
1132 .name = "sclk_dwmmc",
1133 .parent = &clk_dout_mmc4.clk,
1134 .enable = exynos4_clksrc_mask_fsys_ctrl,
1135 .ctrlbit = (1 << 16),
1136 },
1137 .reg_div = { .reg = S5P_CLKDIV_FSYS3, .shift = 8, .size = 8 },
1138 }
1139};
1140
1141static struct clksrc_clk clk_sclk_uart0 = {
1142 .clk = {
1143 .name = "uclk1",
1144 .devname = "exynos4210-uart.0",
1145 .enable = exynos4_clksrc_mask_peril0_ctrl,
1146 .ctrlbit = (1 << 0),
1147 },
1148 .sources = &clkset_group,
1149 .reg_src = { .reg = S5P_CLKSRC_PERIL0, .shift = 0, .size = 4 },
1150 .reg_div = { .reg = S5P_CLKDIV_PERIL0, .shift = 0, .size = 4 },
1151};
1152
1153static struct clksrc_clk clk_sclk_uart1 = {
1154 .clk = {
1155 .name = "uclk1",
1156 .devname = "exynos4210-uart.1",
1157 .enable = exynos4_clksrc_mask_peril0_ctrl,
1158 .ctrlbit = (1 << 4),
1159 },
1160 .sources = &clkset_group,
1161 .reg_src = { .reg = S5P_CLKSRC_PERIL0, .shift = 4, .size = 4 },
1162 .reg_div = { .reg = S5P_CLKDIV_PERIL0, .shift = 4, .size = 4 },
1163};
1164
1165static struct clksrc_clk clk_sclk_uart2 = {
1166 .clk = {
1167 .name = "uclk1",
1168 .devname = "exynos4210-uart.2",
1169 .enable = exynos4_clksrc_mask_peril0_ctrl,
1170 .ctrlbit = (1 << 8),
1171 },
1172 .sources = &clkset_group,
1173 .reg_src = { .reg = S5P_CLKSRC_PERIL0, .shift = 8, .size = 4 },
1174 .reg_div = { .reg = S5P_CLKDIV_PERIL0, .shift = 8, .size = 4 },
1175};
1176
1177static struct clksrc_clk clk_sclk_uart3 = {
1178 .clk = {
1179 .name = "uclk1",
1180 .devname = "exynos4210-uart.3",
1181 .enable = exynos4_clksrc_mask_peril0_ctrl,
1182 .ctrlbit = (1 << 12),
1183 },
1184 .sources = &clkset_group,
1185 .reg_src = { .reg = S5P_CLKSRC_PERIL0, .shift = 12, .size = 4 },
1186 .reg_div = { .reg = S5P_CLKDIV_PERIL0, .shift = 12, .size = 4 },
1187};
1188
1189static struct clksrc_clk clk_sclk_mmc0 = {
1190 .clk = {
1191 .name = "sclk_mmc",
1192 .devname = "s3c-sdhci.0",
1193 .parent = &clk_dout_mmc0.clk,
1194 .enable = exynos4_clksrc_mask_fsys_ctrl,
1195 .ctrlbit = (1 << 0),
1196 },
1197 .reg_div = { .reg = S5P_CLKDIV_FSYS1, .shift = 8, .size = 8 },
1198};
1199
1200static struct clksrc_clk clk_sclk_mmc1 = {
1201 .clk = {
1202 .name = "sclk_mmc",
1203 .devname = "s3c-sdhci.1",
1204 .parent = &clk_dout_mmc1.clk,
1205 .enable = exynos4_clksrc_mask_fsys_ctrl,
1206 .ctrlbit = (1 << 4),
1207 },
1208 .reg_div = { .reg = S5P_CLKDIV_FSYS1, .shift = 24, .size = 8 },
1209};
1210
1211static struct clksrc_clk clk_sclk_mmc2 = {
1212 .clk = {
1213 .name = "sclk_mmc",
1214 .devname = "s3c-sdhci.2",
1215 .parent = &clk_dout_mmc2.clk,
1216 .enable = exynos4_clksrc_mask_fsys_ctrl,
1217 .ctrlbit = (1 << 8),
1218 },
1219 .reg_div = { .reg = S5P_CLKDIV_FSYS2, .shift = 8, .size = 8 },
1220};
1221
1222static struct clksrc_clk clk_sclk_mmc3 = {
1223 .clk = {
1224 .name = "sclk_mmc",
1225 .devname = "s3c-sdhci.3",
1226 .parent = &clk_dout_mmc3.clk,
1227 .enable = exynos4_clksrc_mask_fsys_ctrl,
1228 .ctrlbit = (1 << 12),
1229 },
1230 .reg_div = { .reg = S5P_CLKDIV_FSYS2, .shift = 24, .size = 8 },
1231};
1232
1233static struct clksrc_clk clk_sclk_spi0 = {
1234 .clk = {
1235 .name = "sclk_spi",
1236 .devname = "s3c64xx-spi.0",
1237 .enable = exynos4_clksrc_mask_peril1_ctrl,
1238 .ctrlbit = (1 << 16),
1239 },
1240 .sources = &clkset_group,
1241 .reg_src = { .reg = S5P_CLKSRC_PERIL1, .shift = 16, .size = 4 },
1242 .reg_div = { .reg = S5P_CLKDIV_PERIL1, .shift = 0, .size = 4 },
1243};
1244
1245static struct clksrc_clk clk_sclk_spi1 = {
1246 .clk = {
1247 .name = "sclk_spi",
1248 .devname = "s3c64xx-spi.1",
1249 .enable = exynos4_clksrc_mask_peril1_ctrl,
1250 .ctrlbit = (1 << 20),
1251 },
1252 .sources = &clkset_group,
1253 .reg_src = { .reg = S5P_CLKSRC_PERIL1, .shift = 20, .size = 4 },
1254 .reg_div = { .reg = S5P_CLKDIV_PERIL1, .shift = 16, .size = 4 },
1255};
1256
1257static struct clksrc_clk clk_sclk_spi2 = {
1258 .clk = {
1259 .name = "sclk_spi",
1260 .devname = "s3c64xx-spi.2",
1261 .enable = exynos4_clksrc_mask_peril1_ctrl,
1262 .ctrlbit = (1 << 24),
1263 },
1264 .sources = &clkset_group,
1265 .reg_src = { .reg = S5P_CLKSRC_PERIL1, .shift = 24, .size = 4 },
1266 .reg_div = { .reg = S5P_CLKDIV_PERIL2, .shift = 0, .size = 4 },
1267};
1268
1269/* Clock initialization code */
1270static struct clksrc_clk *sysclks[] = {
1271 &clk_mout_apll,
1272 &clk_sclk_apll,
1273 &clk_mout_epll,
1274 &clk_mout_mpll,
1275 &clk_moutcore,
1276 &clk_coreclk,
1277 &clk_armclk,
1278 &clk_aclk_corem0,
1279 &clk_aclk_cores,
1280 &clk_aclk_corem1,
1281 &clk_periphclk,
1282 &clk_mout_corebus,
1283 &clk_sclk_dmc,
1284 &clk_aclk_cored,
1285 &clk_aclk_corep,
1286 &clk_aclk_acp,
1287 &clk_pclk_acp,
1288 &clk_vpllsrc,
1289 &clk_sclk_vpll,
1290 &clk_aclk_200,
1291 &clk_aclk_100,
1292 &clk_aclk_160,
1293 &clk_aclk_133,
1294 &clk_dout_mmc0,
1295 &clk_dout_mmc1,
1296 &clk_dout_mmc2,
1297 &clk_dout_mmc3,
1298 &clk_dout_mmc4,
1299 &clk_mout_mfc0,
1300 &clk_mout_mfc1,
1301};
1302
1303static struct clk *clk_cdev[] = {
1304 &clk_pdma0,
1305 &clk_pdma1,
1306};
1307
1308static struct clksrc_clk *clksrc_cdev[] = {
1309 &clk_sclk_uart0,
1310 &clk_sclk_uart1,
1311 &clk_sclk_uart2,
1312 &clk_sclk_uart3,
1313 &clk_sclk_mmc0,
1314 &clk_sclk_mmc1,
1315 &clk_sclk_mmc2,
1316 &clk_sclk_mmc3,
1317 &clk_sclk_spi0,
1318 &clk_sclk_spi1,
1319 &clk_sclk_spi2,
1320
1321};
1322
1323static struct clk_lookup exynos4_clk_lookup[] = {
1324 CLKDEV_INIT("exynos4210-uart.0", "clk_uart_baud0", &clk_sclk_uart0.clk),
1325 CLKDEV_INIT("exynos4210-uart.1", "clk_uart_baud0", &clk_sclk_uart1.clk),
1326 CLKDEV_INIT("exynos4210-uart.2", "clk_uart_baud0", &clk_sclk_uart2.clk),
1327 CLKDEV_INIT("exynos4210-uart.3", "clk_uart_baud0", &clk_sclk_uart3.clk),
1328 CLKDEV_INIT("s3c-sdhci.0", "mmc_busclk.2", &clk_sclk_mmc0.clk),
1329 CLKDEV_INIT("s3c-sdhci.1", "mmc_busclk.2", &clk_sclk_mmc1.clk),
1330 CLKDEV_INIT("s3c-sdhci.2", "mmc_busclk.2", &clk_sclk_mmc2.clk),
1331 CLKDEV_INIT("s3c-sdhci.3", "mmc_busclk.2", &clk_sclk_mmc3.clk),
1332 CLKDEV_INIT("dma-pl330.0", "apb_pclk", &clk_pdma0),
1333 CLKDEV_INIT("dma-pl330.1", "apb_pclk", &clk_pdma1),
1334 CLKDEV_INIT("s3c64xx-spi.0", "spi_busclk0", &clk_sclk_spi0.clk),
1335 CLKDEV_INIT("s3c64xx-spi.1", "spi_busclk0", &clk_sclk_spi1.clk),
1336 CLKDEV_INIT("s3c64xx-spi.2", "spi_busclk0", &clk_sclk_spi2.clk),
1337};
1338
1339static int xtal_rate;
1340
1341static unsigned long exynos4_fout_apll_get_rate(struct clk *clk)
1342{
1343 if (soc_is_exynos4210())
1344 return s5p_get_pll45xx(xtal_rate, __raw_readl(S5P_APLL_CON0),
1345 pll_4508);
1346 else if (soc_is_exynos4212() || soc_is_exynos4412())
1347 return s5p_get_pll35xx(xtal_rate, __raw_readl(S5P_APLL_CON0));
1348 else
1349 return 0;
1350}
1351
1352static struct clk_ops exynos4_fout_apll_ops = {
1353 .get_rate = exynos4_fout_apll_get_rate,
1354};
1355
1356static u32 vpll_div[][8] = {
1357 { 54000000, 3, 53, 3, 1024, 0, 17, 0 },
1358 { 108000000, 3, 53, 2, 1024, 0, 17, 0 },
1359};
1360
1361static unsigned long exynos4_vpll_get_rate(struct clk *clk)
1362{
1363 return clk->rate;
1364}
1365
1366static int exynos4_vpll_set_rate(struct clk *clk, unsigned long rate)
1367{
1368 unsigned int vpll_con0, vpll_con1 = 0;
1369 unsigned int i;
1370
1371 /* Return if nothing changed */
1372 if (clk->rate == rate)
1373 return 0;
1374
1375 vpll_con0 = __raw_readl(S5P_VPLL_CON0);
1376 vpll_con0 &= ~(0x1 << 27 | \
1377 PLL90XX_MDIV_MASK << PLL46XX_MDIV_SHIFT | \
1378 PLL90XX_PDIV_MASK << PLL46XX_PDIV_SHIFT | \
1379 PLL90XX_SDIV_MASK << PLL46XX_SDIV_SHIFT);
1380
1381 vpll_con1 = __raw_readl(S5P_VPLL_CON1);
1382 vpll_con1 &= ~(PLL46XX_MRR_MASK << PLL46XX_MRR_SHIFT | \
1383 PLL46XX_MFR_MASK << PLL46XX_MFR_SHIFT | \
1384 PLL4650C_KDIV_MASK << PLL46XX_KDIV_SHIFT);
1385
1386 for (i = 0; i < ARRAY_SIZE(vpll_div); i++) {
1387 if (vpll_div[i][0] == rate) {
1388 vpll_con0 |= vpll_div[i][1] << PLL46XX_PDIV_SHIFT;
1389 vpll_con0 |= vpll_div[i][2] << PLL46XX_MDIV_SHIFT;
1390 vpll_con0 |= vpll_div[i][3] << PLL46XX_SDIV_SHIFT;
1391 vpll_con1 |= vpll_div[i][4] << PLL46XX_KDIV_SHIFT;
1392 vpll_con1 |= vpll_div[i][5] << PLL46XX_MFR_SHIFT;
1393 vpll_con1 |= vpll_div[i][6] << PLL46XX_MRR_SHIFT;
1394 vpll_con0 |= vpll_div[i][7] << 27;
1395 break;
1396 }
1397 }
1398
1399 if (i == ARRAY_SIZE(vpll_div)) {
1400 printk(KERN_ERR "%s: Invalid Clock VPLL Frequency\n",
1401 __func__);
1402 return -EINVAL;
1403 }
1404
1405 __raw_writel(vpll_con0, S5P_VPLL_CON0);
1406 __raw_writel(vpll_con1, S5P_VPLL_CON1);
1407
1408 /* Wait for VPLL lock */
1409 while (!(__raw_readl(S5P_VPLL_CON0) & (1 << PLL46XX_LOCKED_SHIFT)))
1410 continue;
1411
1412 clk->rate = rate;
1413 return 0;
1414}
1415
1416static struct clk_ops exynos4_vpll_ops = {
1417 .get_rate = exynos4_vpll_get_rate,
1418 .set_rate = exynos4_vpll_set_rate,
1419};
1420
1421void __init_or_cpufreq exynos4_setup_clocks(void)
1422{
1423 struct clk *xtal_clk;
1424 unsigned long apll = 0;
1425 unsigned long mpll = 0;
1426 unsigned long epll = 0;
1427 unsigned long vpll = 0;
1428 unsigned long vpllsrc;
1429 unsigned long xtal;
1430 unsigned long armclk;
1431 unsigned long sclk_dmc;
1432 unsigned long aclk_200;
1433 unsigned long aclk_100;
1434 unsigned long aclk_160;
1435 unsigned long aclk_133;
1436 unsigned int ptr;
1437
1438 printk(KERN_DEBUG "%s: registering clocks\n", __func__);
1439
1440 xtal_clk = clk_get(NULL, "xtal");
1441 BUG_ON(IS_ERR(xtal_clk));
1442
1443 xtal = clk_get_rate(xtal_clk);
1444
1445 xtal_rate = xtal;
1446
1447 clk_put(xtal_clk);
1448
1449 printk(KERN_DEBUG "%s: xtal is %ld\n", __func__, xtal);
1450
1451 if (soc_is_exynos4210()) {
1452 apll = s5p_get_pll45xx(xtal, __raw_readl(S5P_APLL_CON0),
1453 pll_4508);
1454 mpll = s5p_get_pll45xx(xtal, __raw_readl(S5P_MPLL_CON0),
1455 pll_4508);
1456 epll = s5p_get_pll46xx(xtal, __raw_readl(S5P_EPLL_CON0),
1457 __raw_readl(S5P_EPLL_CON1), pll_4600);
1458
1459 vpllsrc = clk_get_rate(&clk_vpllsrc.clk);
1460 vpll = s5p_get_pll46xx(vpllsrc, __raw_readl(S5P_VPLL_CON0),
1461 __raw_readl(S5P_VPLL_CON1), pll_4650c);
1462 } else if (soc_is_exynos4212() || soc_is_exynos4412()) {
1463 apll = s5p_get_pll35xx(xtal, __raw_readl(S5P_APLL_CON0));
1464 mpll = s5p_get_pll35xx(xtal, __raw_readl(S5P_MPLL_CON0));
1465 epll = s5p_get_pll36xx(xtal, __raw_readl(S5P_EPLL_CON0),
1466 __raw_readl(S5P_EPLL_CON1));
1467
1468 vpllsrc = clk_get_rate(&clk_vpllsrc.clk);
1469 vpll = s5p_get_pll36xx(vpllsrc, __raw_readl(S5P_VPLL_CON0),
1470 __raw_readl(S5P_VPLL_CON1));
1471 } else {
1472 /* nothing */
1473 }
1474
1475 clk_fout_apll.ops = &exynos4_fout_apll_ops;
1476 clk_fout_mpll.rate = mpll;
1477 clk_fout_epll.rate = epll;
1478 clk_fout_vpll.ops = &exynos4_vpll_ops;
1479 clk_fout_vpll.rate = vpll;
1480
1481 printk(KERN_INFO "EXYNOS4: PLL settings, A=%ld, M=%ld, E=%ld V=%ld",
1482 apll, mpll, epll, vpll);
1483
1484 armclk = clk_get_rate(&clk_armclk.clk);
1485 sclk_dmc = clk_get_rate(&clk_sclk_dmc.clk);
1486
1487 aclk_200 = clk_get_rate(&clk_aclk_200.clk);
1488 aclk_100 = clk_get_rate(&clk_aclk_100.clk);
1489 aclk_160 = clk_get_rate(&clk_aclk_160.clk);
1490 aclk_133 = clk_get_rate(&clk_aclk_133.clk);
1491
1492 printk(KERN_INFO "EXYNOS4: ARMCLK=%ld, DMC=%ld, ACLK200=%ld\n"
1493 "ACLK100=%ld, ACLK160=%ld, ACLK133=%ld\n",
1494 armclk, sclk_dmc, aclk_200,
1495 aclk_100, aclk_160, aclk_133);
1496
1497 clk_f.rate = armclk;
1498 clk_h.rate = sclk_dmc;
1499 clk_p.rate = aclk_100;
1500
1501 for (ptr = 0; ptr < ARRAY_SIZE(clksrcs); ptr++)
1502 s3c_set_clksrc(&clksrcs[ptr], true);
1503}
1504
1505static struct clk *clks[] __initdata = {
1506 &clk_sclk_hdmi27m,
1507 &clk_sclk_hdmiphy,
1508 &clk_sclk_usbphy0,
1509 &clk_sclk_usbphy1,
1510};
1511
1512#ifdef CONFIG_PM_SLEEP
1513static int exynos4_clock_suspend(void)
1514{
1515 s3c_pm_do_save(exynos4_clock_save, ARRAY_SIZE(exynos4_clock_save));
1516 return 0;
1517}
1518
1519static void exynos4_clock_resume(void)
1520{
1521 s3c_pm_do_restore_core(exynos4_clock_save, ARRAY_SIZE(exynos4_clock_save));
1522}
1523
1524#else
1525#define exynos4_clock_suspend NULL
1526#define exynos4_clock_resume NULL
1527#endif
1528
1529struct syscore_ops exynos4_clock_syscore_ops = {
1530 .suspend = exynos4_clock_suspend,
1531 .resume = exynos4_clock_resume,
1532};
1533
1534void __init exynos4_register_clocks(void)
1535{
1536 int ptr;
1537
1538 s3c24xx_register_clocks(clks, ARRAY_SIZE(clks));
1539
1540 for (ptr = 0; ptr < ARRAY_SIZE(sysclks); ptr++)
1541 s3c_register_clksrc(sysclks[ptr], 1);
1542
1543 for (ptr = 0; ptr < ARRAY_SIZE(sclk_tv); ptr++)
1544 s3c_register_clksrc(sclk_tv[ptr], 1);
1545
1546 for (ptr = 0; ptr < ARRAY_SIZE(clksrc_cdev); ptr++)
1547 s3c_register_clksrc(clksrc_cdev[ptr], 1);
1548
1549 s3c_register_clksrc(clksrcs, ARRAY_SIZE(clksrcs));
1550 s3c_register_clocks(init_clocks, ARRAY_SIZE(init_clocks));
1551
1552 s3c24xx_register_clocks(clk_cdev, ARRAY_SIZE(clk_cdev));
1553 for (ptr = 0; ptr < ARRAY_SIZE(clk_cdev); ptr++)
1554 s3c_disable_clocks(clk_cdev[ptr], 1);
1555
1556 s3c_register_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off));
1557 s3c_disable_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off));
1558 clkdev_add_table(exynos4_clk_lookup, ARRAY_SIZE(exynos4_clk_lookup));
1559
1560 register_syscore_ops(&exynos4_clock_syscore_ops);
1561 s3c24xx_register_clock(&dummy_apb_pclk);
1562
1563 s3c_pwmclk_init();
1564}
diff --git a/arch/arm/mach-exynos/common.c b/arch/arm/mach-exynos/common.c
index 6de298c5d2d..e6cc50e94a5 100644
--- a/arch/arm/mach-exynos/common.c
+++ b/arch/arm/mach-exynos/common.c
@@ -26,10 +26,12 @@
26#include <asm/hardware/gic.h> 26#include <asm/hardware/gic.h>
27#include <asm/mach/map.h> 27#include <asm/mach/map.h>
28#include <asm/mach/irq.h> 28#include <asm/mach/irq.h>
29#include <asm/cacheflush.h>
29 30
30#include <mach/regs-irq.h> 31#include <mach/regs-irq.h>
31#include <mach/regs-pmu.h> 32#include <mach/regs-pmu.h>
32#include <mach/regs-gpio.h> 33#include <mach/regs-gpio.h>
34#include <mach/pmu.h>
33 35
34#include <plat/cpu.h> 36#include <plat/cpu.h>
35#include <plat/clock.h> 37#include <plat/clock.h>
@@ -45,10 +47,20 @@
45#include <plat/regs-serial.h> 47#include <plat/regs-serial.h>
46 48
47#include "common.h" 49#include "common.h"
50#define L2_AUX_VAL 0x7C470001
51#define L2_AUX_MASK 0xC200ffff
48 52
49static const char name_exynos4210[] = "EXYNOS4210"; 53static const char name_exynos4210[] = "EXYNOS4210";
50static const char name_exynos4212[] = "EXYNOS4212"; 54static const char name_exynos4212[] = "EXYNOS4212";
51static const char name_exynos4412[] = "EXYNOS4412"; 55static const char name_exynos4412[] = "EXYNOS4412";
56static const char name_exynos5250[] = "EXYNOS5250";
57
58static void exynos4_map_io(void);
59static void exynos5_map_io(void);
60static void exynos4_init_clocks(int xtal);
61static void exynos5_init_clocks(int xtal);
62static void exynos_init_uarts(struct s3c2410_uartcfg *cfg, int no);
63static int exynos_init(void);
52 64
53static struct cpu_table cpu_ids[] __initdata = { 65static struct cpu_table cpu_ids[] __initdata = {
54 { 66 {
@@ -56,7 +68,7 @@ static struct cpu_table cpu_ids[] __initdata = {
56 .idmask = EXYNOS4_CPU_MASK, 68 .idmask = EXYNOS4_CPU_MASK,
57 .map_io = exynos4_map_io, 69 .map_io = exynos4_map_io,
58 .init_clocks = exynos4_init_clocks, 70 .init_clocks = exynos4_init_clocks,
59 .init_uarts = exynos4_init_uarts, 71 .init_uarts = exynos_init_uarts,
60 .init = exynos_init, 72 .init = exynos_init,
61 .name = name_exynos4210, 73 .name = name_exynos4210,
62 }, { 74 }, {
@@ -64,7 +76,7 @@ static struct cpu_table cpu_ids[] __initdata = {
64 .idmask = EXYNOS4_CPU_MASK, 76 .idmask = EXYNOS4_CPU_MASK,
65 .map_io = exynos4_map_io, 77 .map_io = exynos4_map_io,
66 .init_clocks = exynos4_init_clocks, 78 .init_clocks = exynos4_init_clocks,
67 .init_uarts = exynos4_init_uarts, 79 .init_uarts = exynos_init_uarts,
68 .init = exynos_init, 80 .init = exynos_init,
69 .name = name_exynos4212, 81 .name = name_exynos4212,
70 }, { 82 }, {
@@ -72,9 +84,17 @@ static struct cpu_table cpu_ids[] __initdata = {
72 .idmask = EXYNOS4_CPU_MASK, 84 .idmask = EXYNOS4_CPU_MASK,
73 .map_io = exynos4_map_io, 85 .map_io = exynos4_map_io,
74 .init_clocks = exynos4_init_clocks, 86 .init_clocks = exynos4_init_clocks,
75 .init_uarts = exynos4_init_uarts, 87 .init_uarts = exynos_init_uarts,
76 .init = exynos_init, 88 .init = exynos_init,
77 .name = name_exynos4412, 89 .name = name_exynos4412,
90 }, {
91 .idcode = EXYNOS5250_SOC_ID,
92 .idmask = EXYNOS5_SOC_MASK,
93 .map_io = exynos5_map_io,
94 .init_clocks = exynos5_init_clocks,
95 .init_uarts = exynos_init_uarts,
96 .init = exynos_init,
97 .name = name_exynos5250,
78 }, 98 },
79}; 99};
80 100
@@ -83,10 +103,14 @@ static struct cpu_table cpu_ids[] __initdata = {
83static struct map_desc exynos_iodesc[] __initdata = { 103static struct map_desc exynos_iodesc[] __initdata = {
84 { 104 {
85 .virtual = (unsigned long)S5P_VA_CHIPID, 105 .virtual = (unsigned long)S5P_VA_CHIPID,
86 .pfn = __phys_to_pfn(EXYNOS4_PA_CHIPID), 106 .pfn = __phys_to_pfn(EXYNOS_PA_CHIPID),
87 .length = SZ_4K, 107 .length = SZ_4K,
88 .type = MT_DEVICE, 108 .type = MT_DEVICE,
89 }, { 109 },
110};
111
112static struct map_desc exynos4_iodesc[] __initdata = {
113 {
90 .virtual = (unsigned long)S3C_VA_SYS, 114 .virtual = (unsigned long)S3C_VA_SYS,
91 .pfn = __phys_to_pfn(EXYNOS4_PA_SYSCON), 115 .pfn = __phys_to_pfn(EXYNOS4_PA_SYSCON),
92 .length = SZ_64K, 116 .length = SZ_64K,
@@ -136,11 +160,7 @@ static struct map_desc exynos_iodesc[] __initdata = {
136 .pfn = __phys_to_pfn(EXYNOS4_PA_UART), 160 .pfn = __phys_to_pfn(EXYNOS4_PA_UART),
137 .length = SZ_512K, 161 .length = SZ_512K,
138 .type = MT_DEVICE, 162 .type = MT_DEVICE,
139 }, 163 }, {
140};
141
142static struct map_desc exynos4_iodesc[] __initdata = {
143 {
144 .virtual = (unsigned long)S5P_VA_CMU, 164 .virtual = (unsigned long)S5P_VA_CMU,
145 .pfn = __phys_to_pfn(EXYNOS4_PA_CMU), 165 .pfn = __phys_to_pfn(EXYNOS4_PA_CMU),
146 .length = SZ_128K, 166 .length = SZ_128K,
@@ -156,24 +176,14 @@ static struct map_desc exynos4_iodesc[] __initdata = {
156 .length = SZ_4K, 176 .length = SZ_4K,
157 .type = MT_DEVICE, 177 .type = MT_DEVICE,
158 }, { 178 }, {
159 .virtual = (unsigned long)S5P_VA_GPIO1,
160 .pfn = __phys_to_pfn(EXYNOS4_PA_GPIO1),
161 .length = SZ_4K,
162 .type = MT_DEVICE,
163 }, {
164 .virtual = (unsigned long)S5P_VA_GPIO2,
165 .pfn = __phys_to_pfn(EXYNOS4_PA_GPIO2),
166 .length = SZ_4K,
167 .type = MT_DEVICE,
168 }, {
169 .virtual = (unsigned long)S5P_VA_GPIO3,
170 .pfn = __phys_to_pfn(EXYNOS4_PA_GPIO3),
171 .length = SZ_256,
172 .type = MT_DEVICE,
173 }, {
174 .virtual = (unsigned long)S5P_VA_DMC0, 179 .virtual = (unsigned long)S5P_VA_DMC0,
175 .pfn = __phys_to_pfn(EXYNOS4_PA_DMC0), 180 .pfn = __phys_to_pfn(EXYNOS4_PA_DMC0),
176 .length = SZ_4K, 181 .length = SZ_64K,
182 .type = MT_DEVICE,
183 }, {
184 .virtual = (unsigned long)S5P_VA_DMC1,
185 .pfn = __phys_to_pfn(EXYNOS4_PA_DMC1),
186 .length = SZ_64K,
177 .type = MT_DEVICE, 187 .type = MT_DEVICE,
178 }, { 188 }, {
179 .virtual = (unsigned long)S3C_VA_USB_HSPHY, 189 .virtual = (unsigned long)S3C_VA_USB_HSPHY,
@@ -201,19 +211,80 @@ static struct map_desc exynos4_iodesc1[] __initdata = {
201 }, 211 },
202}; 212};
203 213
204static void exynos_idle(void) 214static struct map_desc exynos5_iodesc[] __initdata = {
205{ 215 {
206 if (!need_resched()) 216 .virtual = (unsigned long)S3C_VA_SYS,
207 cpu_do_idle(); 217 .pfn = __phys_to_pfn(EXYNOS5_PA_SYSCON),
208 218 .length = SZ_64K,
209 local_irq_enable(); 219 .type = MT_DEVICE,
210} 220 }, {
221 .virtual = (unsigned long)S3C_VA_TIMER,
222 .pfn = __phys_to_pfn(EXYNOS5_PA_TIMER),
223 .length = SZ_16K,
224 .type = MT_DEVICE,
225 }, {
226 .virtual = (unsigned long)S3C_VA_WATCHDOG,
227 .pfn = __phys_to_pfn(EXYNOS5_PA_WATCHDOG),
228 .length = SZ_4K,
229 .type = MT_DEVICE,
230 }, {
231 .virtual = (unsigned long)S5P_VA_SROMC,
232 .pfn = __phys_to_pfn(EXYNOS5_PA_SROMC),
233 .length = SZ_4K,
234 .type = MT_DEVICE,
235 }, {
236 .virtual = (unsigned long)S5P_VA_SYSTIMER,
237 .pfn = __phys_to_pfn(EXYNOS5_PA_SYSTIMER),
238 .length = SZ_4K,
239 .type = MT_DEVICE,
240 }, {
241 .virtual = (unsigned long)S5P_VA_SYSRAM,
242 .pfn = __phys_to_pfn(EXYNOS5_PA_SYSRAM),
243 .length = SZ_4K,
244 .type = MT_DEVICE,
245 }, {
246 .virtual = (unsigned long)S5P_VA_CMU,
247 .pfn = __phys_to_pfn(EXYNOS5_PA_CMU),
248 .length = 144 * SZ_1K,
249 .type = MT_DEVICE,
250 }, {
251 .virtual = (unsigned long)S5P_VA_PMU,
252 .pfn = __phys_to_pfn(EXYNOS5_PA_PMU),
253 .length = SZ_64K,
254 .type = MT_DEVICE,
255 }, {
256 .virtual = (unsigned long)S5P_VA_COMBINER_BASE,
257 .pfn = __phys_to_pfn(EXYNOS5_PA_COMBINER),
258 .length = SZ_4K,
259 .type = MT_DEVICE,
260 }, {
261 .virtual = (unsigned long)S3C_VA_UART,
262 .pfn = __phys_to_pfn(EXYNOS5_PA_UART),
263 .length = SZ_512K,
264 .type = MT_DEVICE,
265 }, {
266 .virtual = (unsigned long)S5P_VA_GIC_CPU,
267 .pfn = __phys_to_pfn(EXYNOS5_PA_GIC_CPU),
268 .length = SZ_64K,
269 .type = MT_DEVICE,
270 }, {
271 .virtual = (unsigned long)S5P_VA_GIC_DIST,
272 .pfn = __phys_to_pfn(EXYNOS5_PA_GIC_DIST),
273 .length = SZ_64K,
274 .type = MT_DEVICE,
275 },
276};
211 277
212void exynos4_restart(char mode, const char *cmd) 278void exynos4_restart(char mode, const char *cmd)
213{ 279{
214 __raw_writel(0x1, S5P_SWRESET); 280 __raw_writel(0x1, S5P_SWRESET);
215} 281}
216 282
283void exynos5_restart(char mode, const char *cmd)
284{
285 __raw_writel(0x1, EXYNOS_SWRESET);
286}
287
217/* 288/*
218 * exynos_map_io 289 * exynos_map_io
219 * 290 *
@@ -233,7 +304,7 @@ void __init exynos_init_io(struct map_desc *mach_desc, int size)
233 s3c_init_cpu(samsung_cpu_id, cpu_ids, ARRAY_SIZE(cpu_ids)); 304 s3c_init_cpu(samsung_cpu_id, cpu_ids, ARRAY_SIZE(cpu_ids));
234} 305}
235 306
236void __init exynos4_map_io(void) 307static void __init exynos4_map_io(void)
237{ 308{
238 iotable_init(exynos4_iodesc, ARRAY_SIZE(exynos4_iodesc)); 309 iotable_init(exynos4_iodesc, ARRAY_SIZE(exynos4_iodesc));
239 310
@@ -264,7 +335,22 @@ void __init exynos4_map_io(void)
264 s5p_hdmi_setname("exynos4-hdmi"); 335 s5p_hdmi_setname("exynos4-hdmi");
265} 336}
266 337
267void __init exynos4_init_clocks(int xtal) 338static void __init exynos5_map_io(void)
339{
340 iotable_init(exynos5_iodesc, ARRAY_SIZE(exynos5_iodesc));
341
342 s3c_device_i2c0.resource[0].start = EXYNOS5_PA_IIC(0);
343 s3c_device_i2c0.resource[0].end = EXYNOS5_PA_IIC(0) + SZ_4K - 1;
344 s3c_device_i2c0.resource[1].start = EXYNOS5_IRQ_IIC;
345 s3c_device_i2c0.resource[1].end = EXYNOS5_IRQ_IIC;
346
347 /* The I2C bus controllers are directly compatible with s3c2440 */
348 s3c_i2c0_setname("s3c2440-i2c");
349 s3c_i2c1_setname("s3c2440-i2c");
350 s3c_i2c2_setname("s3c2440-i2c");
351}
352
353static void __init exynos4_init_clocks(int xtal)
268{ 354{
269 printk(KERN_DEBUG "%s: initializing clocks\n", __func__); 355 printk(KERN_DEBUG "%s: initializing clocks\n", __func__);
270 356
@@ -280,6 +366,17 @@ void __init exynos4_init_clocks(int xtal)
280 exynos4_setup_clocks(); 366 exynos4_setup_clocks();
281} 367}
282 368
369static void __init exynos5_init_clocks(int xtal)
370{
371 printk(KERN_DEBUG "%s: initializing clocks\n", __func__);
372
373 s3c24xx_register_baseclocks(xtal);
374 s5p_register_clocks(xtal);
375
376 exynos5_register_clocks();
377 exynos5_setup_clocks();
378}
379
283#define COMBINER_ENABLE_SET 0x0 380#define COMBINER_ENABLE_SET 0x0
284#define COMBINER_ENABLE_CLEAR 0x4 381#define COMBINER_ENABLE_CLEAR 0x4
285#define COMBINER_INT_STATUS 0xC 382#define COMBINER_INT_STATUS 0xC
@@ -353,7 +450,14 @@ static struct irq_chip combiner_chip = {
353 450
354static void __init combiner_cascade_irq(unsigned int combiner_nr, unsigned int irq) 451static void __init combiner_cascade_irq(unsigned int combiner_nr, unsigned int irq)
355{ 452{
356 if (combiner_nr >= MAX_COMBINER_NR) 453 unsigned int max_nr;
454
455 if (soc_is_exynos5250())
456 max_nr = EXYNOS5_MAX_COMBINER_NR;
457 else
458 max_nr = EXYNOS4_MAX_COMBINER_NR;
459
460 if (combiner_nr >= max_nr)
357 BUG(); 461 BUG();
358 if (irq_set_handler_data(irq, &combiner_data[combiner_nr]) != 0) 462 if (irq_set_handler_data(irq, &combiner_data[combiner_nr]) != 0)
359 BUG(); 463 BUG();
@@ -364,8 +468,14 @@ static void __init combiner_init(unsigned int combiner_nr, void __iomem *base,
364 unsigned int irq_start) 468 unsigned int irq_start)
365{ 469{
366 unsigned int i; 470 unsigned int i;
471 unsigned int max_nr;
367 472
368 if (combiner_nr >= MAX_COMBINER_NR) 473 if (soc_is_exynos5250())
474 max_nr = EXYNOS5_MAX_COMBINER_NR;
475 else
476 max_nr = EXYNOS4_MAX_COMBINER_NR;
477
478 if (combiner_nr >= max_nr)
369 BUG(); 479 BUG();
370 480
371 combiner_data[combiner_nr].base = base; 481 combiner_data[combiner_nr].base = base;
@@ -408,7 +518,7 @@ void __init exynos4_init_irq(void)
408 of_irq_init(exynos4_dt_irq_match); 518 of_irq_init(exynos4_dt_irq_match);
409#endif 519#endif
410 520
411 for (irq = 0; irq < MAX_COMBINER_NR; irq++) { 521 for (irq = 0; irq < EXYNOS4_MAX_COMBINER_NR; irq++) {
412 522
413 combiner_init(irq, (void __iomem *)S5P_VA_COMBINER(irq), 523 combiner_init(irq, (void __iomem *)S5P_VA_COMBINER(irq),
414 COMBINER_IRQ(irq, 0)); 524 COMBINER_IRQ(irq, 0));
@@ -423,60 +533,144 @@ void __init exynos4_init_irq(void)
423 s5p_init_irq(NULL, 0); 533 s5p_init_irq(NULL, 0);
424} 534}
425 535
536void __init exynos5_init_irq(void)
537{
538 int irq;
539
540 gic_init(0, IRQ_PPI(0), S5P_VA_GIC_DIST, S5P_VA_GIC_CPU);
541
542 for (irq = 0; irq < EXYNOS5_MAX_COMBINER_NR; irq++) {
543 combiner_init(irq, (void __iomem *)S5P_VA_COMBINER(irq),
544 COMBINER_IRQ(irq, 0));
545 combiner_cascade_irq(irq, IRQ_SPI(irq));
546 }
547
548 /*
549 * The parameters of s5p_init_irq() are for VIC init.
550 * Theses parameters should be NULL and 0 because EXYNOS4
551 * uses GIC instead of VIC.
552 */
553 s5p_init_irq(NULL, 0);
554}
555
426struct bus_type exynos4_subsys = { 556struct bus_type exynos4_subsys = {
427 .name = "exynos4-core", 557 .name = "exynos4-core",
428 .dev_name = "exynos4-core", 558 .dev_name = "exynos4-core",
429}; 559};
430 560
561struct bus_type exynos5_subsys = {
562 .name = "exynos5-core",
563 .dev_name = "exynos5-core",
564};
565
431static struct device exynos4_dev = { 566static struct device exynos4_dev = {
432 .bus = &exynos4_subsys, 567 .bus = &exynos4_subsys,
433}; 568};
434 569
435static int __init exynos4_core_init(void) 570static struct device exynos5_dev = {
571 .bus = &exynos5_subsys,
572};
573
574static int __init exynos_core_init(void)
436{ 575{
437 return subsys_system_register(&exynos4_subsys, NULL); 576 if (soc_is_exynos5250())
577 return subsys_system_register(&exynos5_subsys, NULL);
578 else
579 return subsys_system_register(&exynos4_subsys, NULL);
438} 580}
439core_initcall(exynos4_core_init); 581core_initcall(exynos_core_init);
440 582
441#ifdef CONFIG_CACHE_L2X0 583#ifdef CONFIG_CACHE_L2X0
442static int __init exynos4_l2x0_cache_init(void) 584static int __init exynos4_l2x0_cache_init(void)
443{ 585{
444 /* TAG, Data Latency Control: 2cycle */ 586 if (soc_is_exynos5250())
445 __raw_writel(0x110, S5P_VA_L2CC + L2X0_TAG_LATENCY_CTRL); 587 return 0;
588
589 int ret;
590 ret = l2x0_of_init(L2_AUX_VAL, L2_AUX_MASK);
591 if (!ret) {
592 l2x0_regs_phys = virt_to_phys(&l2x0_saved_regs);
593 clean_dcache_area(&l2x0_regs_phys, sizeof(unsigned long));
594 return 0;
595 }
446 596
447 if (soc_is_exynos4210()) 597 if (!(__raw_readl(S5P_VA_L2CC + L2X0_CTRL) & 0x1)) {
448 __raw_writel(0x110, S5P_VA_L2CC + L2X0_DATA_LATENCY_CTRL); 598 l2x0_saved_regs.phy_base = EXYNOS4_PA_L2CC;
449 else if (soc_is_exynos4212() || soc_is_exynos4412()) 599 /* TAG, Data Latency Control: 2 cycles */
450 __raw_writel(0x120, S5P_VA_L2CC + L2X0_DATA_LATENCY_CTRL); 600 l2x0_saved_regs.tag_latency = 0x110;
601
602 if (soc_is_exynos4212() || soc_is_exynos4412())
603 l2x0_saved_regs.data_latency = 0x120;
604 else
605 l2x0_saved_regs.data_latency = 0x110;
451 606
452 /* L2X0 Prefetch Control */ 607 l2x0_saved_regs.prefetch_ctrl = 0x30000007;
453 __raw_writel(0x30000007, S5P_VA_L2CC + L2X0_PREFETCH_CTRL); 608 l2x0_saved_regs.pwr_ctrl =
609 (L2X0_DYNAMIC_CLK_GATING_EN | L2X0_STNDBY_MODE_EN);
454 610
455 /* L2X0 Power Control */ 611 l2x0_regs_phys = virt_to_phys(&l2x0_saved_regs);
456 __raw_writel(L2X0_DYNAMIC_CLK_GATING_EN | L2X0_STNDBY_MODE_EN,
457 S5P_VA_L2CC + L2X0_POWER_CTRL);
458 612
459 l2x0_init(S5P_VA_L2CC, 0x7C470001, 0xC200ffff); 613 __raw_writel(l2x0_saved_regs.tag_latency,
614 S5P_VA_L2CC + L2X0_TAG_LATENCY_CTRL);
615 __raw_writel(l2x0_saved_regs.data_latency,
616 S5P_VA_L2CC + L2X0_DATA_LATENCY_CTRL);
460 617
618 /* L2X0 Prefetch Control */
619 __raw_writel(l2x0_saved_regs.prefetch_ctrl,
620 S5P_VA_L2CC + L2X0_PREFETCH_CTRL);
621
622 /* L2X0 Power Control */
623 __raw_writel(l2x0_saved_regs.pwr_ctrl,
624 S5P_VA_L2CC + L2X0_POWER_CTRL);
625
626 clean_dcache_area(&l2x0_regs_phys, sizeof(unsigned long));
627 clean_dcache_area(&l2x0_saved_regs, sizeof(struct l2x0_regs));
628 }
629
630 l2x0_init(S5P_VA_L2CC, L2_AUX_VAL, L2_AUX_MASK);
461 return 0; 631 return 0;
462} 632}
463
464early_initcall(exynos4_l2x0_cache_init); 633early_initcall(exynos4_l2x0_cache_init);
465#endif 634#endif
466 635
467int __init exynos_init(void) 636static int __init exynos5_l2_cache_init(void)
468{ 637{
469 printk(KERN_INFO "EXYNOS: Initializing architecture\n"); 638 unsigned int val;
639
640 if (!soc_is_exynos5250())
641 return 0;
642
643 asm volatile("mrc p15, 0, %0, c1, c0, 0\n"
644 "bic %0, %0, #(1 << 2)\n" /* cache disable */
645 "mcr p15, 0, %0, c1, c0, 0\n"
646 "mrc p15, 1, %0, c9, c0, 2\n"
647 : "=r"(val));
648
649 val |= (1 << 9) | (1 << 5) | (2 << 6) | (2 << 0);
650
651 asm volatile("mcr p15, 1, %0, c9, c0, 2\n" : : "r"(val));
652 asm volatile("mrc p15, 0, %0, c1, c0, 0\n"
653 "orr %0, %0, #(1 << 2)\n" /* cache enable */
654 "mcr p15, 0, %0, c1, c0, 0\n"
655 : : "r"(val));
656
657 return 0;
658}
659early_initcall(exynos5_l2_cache_init);
470 660
471 /* set idle function */ 661static int __init exynos_init(void)
472 pm_idle = exynos_idle; 662{
663 printk(KERN_INFO "EXYNOS: Initializing architecture\n");
473 664
474 return device_register(&exynos4_dev); 665 if (soc_is_exynos5250())
666 return device_register(&exynos5_dev);
667 else
668 return device_register(&exynos4_dev);
475} 669}
476 670
477/* uart registration process */ 671/* uart registration process */
478 672
479void __init exynos4_init_uarts(struct s3c2410_uartcfg *cfg, int no) 673static void __init exynos_init_uarts(struct s3c2410_uartcfg *cfg, int no)
480{ 674{
481 struct s3c2410_uartcfg *tcfg = cfg; 675 struct s3c2410_uartcfg *tcfg = cfg;
482 u32 ucnt; 676 u32 ucnt;
@@ -484,69 +678,138 @@ void __init exynos4_init_uarts(struct s3c2410_uartcfg *cfg, int no)
484 for (ucnt = 0; ucnt < no; ucnt++, tcfg++) 678 for (ucnt = 0; ucnt < no; ucnt++, tcfg++)
485 tcfg->has_fracval = 1; 679 tcfg->has_fracval = 1;
486 680
487 s3c24xx_init_uartdevs("exynos4210-uart", s5p_uart_resources, cfg, no); 681 if (soc_is_exynos5250())
682 s3c24xx_init_uartdevs("exynos4210-uart", exynos5_uart_resources, cfg, no);
683 else
684 s3c24xx_init_uartdevs("exynos4210-uart", exynos4_uart_resources, cfg, no);
488} 685}
489 686
687static void __iomem *exynos_eint_base;
688
490static DEFINE_SPINLOCK(eint_lock); 689static DEFINE_SPINLOCK(eint_lock);
491 690
492static unsigned int eint0_15_data[16]; 691static unsigned int eint0_15_data[16];
493 692
494static unsigned int exynos4_get_irq_nr(unsigned int number) 693static inline int exynos4_irq_to_gpio(unsigned int irq)
495{ 694{
496 u32 ret = 0; 695 if (irq < IRQ_EINT(0))
696 return -EINVAL;
497 697
498 switch (number) { 698 irq -= IRQ_EINT(0);
499 case 0 ... 3: 699 if (irq < 8)
500 ret = (number + IRQ_EINT0); 700 return EXYNOS4_GPX0(irq);
501 break; 701
502 case 4 ... 7: 702 irq -= 8;
503 ret = (number + (IRQ_EINT4 - 4)); 703 if (irq < 8)
504 break; 704 return EXYNOS4_GPX1(irq);
505 case 8 ... 15: 705
506 ret = (number + (IRQ_EINT8 - 8)); 706 irq -= 8;
507 break; 707 if (irq < 8)
508 default: 708 return EXYNOS4_GPX2(irq);
509 printk(KERN_ERR "number available : %d\n", number);
510 }
511 709
512 return ret; 710 irq -= 8;
711 if (irq < 8)
712 return EXYNOS4_GPX3(irq);
713
714 return -EINVAL;
513} 715}
514 716
515static inline void exynos4_irq_eint_mask(struct irq_data *data) 717static inline int exynos5_irq_to_gpio(unsigned int irq)
718{
719 if (irq < IRQ_EINT(0))
720 return -EINVAL;
721
722 irq -= IRQ_EINT(0);
723 if (irq < 8)
724 return EXYNOS5_GPX0(irq);
725
726 irq -= 8;
727 if (irq < 8)
728 return EXYNOS5_GPX1(irq);
729
730 irq -= 8;
731 if (irq < 8)
732 return EXYNOS5_GPX2(irq);
733
734 irq -= 8;
735 if (irq < 8)
736 return EXYNOS5_GPX3(irq);
737
738 return -EINVAL;
739}
740
741static unsigned int exynos4_eint0_15_src_int[16] = {
742 EXYNOS4_IRQ_EINT0,
743 EXYNOS4_IRQ_EINT1,
744 EXYNOS4_IRQ_EINT2,
745 EXYNOS4_IRQ_EINT3,
746 EXYNOS4_IRQ_EINT4,
747 EXYNOS4_IRQ_EINT5,
748 EXYNOS4_IRQ_EINT6,
749 EXYNOS4_IRQ_EINT7,
750 EXYNOS4_IRQ_EINT8,
751 EXYNOS4_IRQ_EINT9,
752 EXYNOS4_IRQ_EINT10,
753 EXYNOS4_IRQ_EINT11,
754 EXYNOS4_IRQ_EINT12,
755 EXYNOS4_IRQ_EINT13,
756 EXYNOS4_IRQ_EINT14,
757 EXYNOS4_IRQ_EINT15,
758};
759
760static unsigned int exynos5_eint0_15_src_int[16] = {
761 EXYNOS5_IRQ_EINT0,
762 EXYNOS5_IRQ_EINT1,
763 EXYNOS5_IRQ_EINT2,
764 EXYNOS5_IRQ_EINT3,
765 EXYNOS5_IRQ_EINT4,
766 EXYNOS5_IRQ_EINT5,
767 EXYNOS5_IRQ_EINT6,
768 EXYNOS5_IRQ_EINT7,
769 EXYNOS5_IRQ_EINT8,
770 EXYNOS5_IRQ_EINT9,
771 EXYNOS5_IRQ_EINT10,
772 EXYNOS5_IRQ_EINT11,
773 EXYNOS5_IRQ_EINT12,
774 EXYNOS5_IRQ_EINT13,
775 EXYNOS5_IRQ_EINT14,
776 EXYNOS5_IRQ_EINT15,
777};
778static inline void exynos_irq_eint_mask(struct irq_data *data)
516{ 779{
517 u32 mask; 780 u32 mask;
518 781
519 spin_lock(&eint_lock); 782 spin_lock(&eint_lock);
520 mask = __raw_readl(S5P_EINT_MASK(EINT_REG_NR(data->irq))); 783 mask = __raw_readl(EINT_MASK(exynos_eint_base, data->irq));
521 mask |= eint_irq_to_bit(data->irq); 784 mask |= EINT_OFFSET_BIT(data->irq);
522 __raw_writel(mask, S5P_EINT_MASK(EINT_REG_NR(data->irq))); 785 __raw_writel(mask, EINT_MASK(exynos_eint_base, data->irq));
523 spin_unlock(&eint_lock); 786 spin_unlock(&eint_lock);
524} 787}
525 788
526static void exynos4_irq_eint_unmask(struct irq_data *data) 789static void exynos_irq_eint_unmask(struct irq_data *data)
527{ 790{
528 u32 mask; 791 u32 mask;
529 792
530 spin_lock(&eint_lock); 793 spin_lock(&eint_lock);
531 mask = __raw_readl(S5P_EINT_MASK(EINT_REG_NR(data->irq))); 794 mask = __raw_readl(EINT_MASK(exynos_eint_base, data->irq));
532 mask &= ~(eint_irq_to_bit(data->irq)); 795 mask &= ~(EINT_OFFSET_BIT(data->irq));
533 __raw_writel(mask, S5P_EINT_MASK(EINT_REG_NR(data->irq))); 796 __raw_writel(mask, EINT_MASK(exynos_eint_base, data->irq));
534 spin_unlock(&eint_lock); 797 spin_unlock(&eint_lock);
535} 798}
536 799
537static inline void exynos4_irq_eint_ack(struct irq_data *data) 800static inline void exynos_irq_eint_ack(struct irq_data *data)
538{ 801{
539 __raw_writel(eint_irq_to_bit(data->irq), 802 __raw_writel(EINT_OFFSET_BIT(data->irq),
540 S5P_EINT_PEND(EINT_REG_NR(data->irq))); 803 EINT_PEND(exynos_eint_base, data->irq));
541} 804}
542 805
543static void exynos4_irq_eint_maskack(struct irq_data *data) 806static void exynos_irq_eint_maskack(struct irq_data *data)
544{ 807{
545 exynos4_irq_eint_mask(data); 808 exynos_irq_eint_mask(data);
546 exynos4_irq_eint_ack(data); 809 exynos_irq_eint_ack(data);
547} 810}
548 811
549static int exynos4_irq_eint_set_type(struct irq_data *data, unsigned int type) 812static int exynos_irq_eint_set_type(struct irq_data *data, unsigned int type)
550{ 813{
551 int offs = EINT_OFFSET(data->irq); 814 int offs = EINT_OFFSET(data->irq);
552 int shift; 815 int shift;
@@ -583,39 +846,27 @@ static int exynos4_irq_eint_set_type(struct irq_data *data, unsigned int type)
583 mask = 0x7 << shift; 846 mask = 0x7 << shift;
584 847
585 spin_lock(&eint_lock); 848 spin_lock(&eint_lock);
586 ctrl = __raw_readl(S5P_EINT_CON(EINT_REG_NR(data->irq))); 849 ctrl = __raw_readl(EINT_CON(exynos_eint_base, data->irq));
587 ctrl &= ~mask; 850 ctrl &= ~mask;
588 ctrl |= newvalue << shift; 851 ctrl |= newvalue << shift;
589 __raw_writel(ctrl, S5P_EINT_CON(EINT_REG_NR(data->irq))); 852 __raw_writel(ctrl, EINT_CON(exynos_eint_base, data->irq));
590 spin_unlock(&eint_lock); 853 spin_unlock(&eint_lock);
591 854
592 switch (offs) { 855 if (soc_is_exynos5250())
593 case 0 ... 7: 856 s3c_gpio_cfgpin(exynos5_irq_to_gpio(data->irq), S3C_GPIO_SFN(0xf));
594 s3c_gpio_cfgpin(EINT_GPIO_0(offs & 0x7), EINT_MODE); 857 else
595 break; 858 s3c_gpio_cfgpin(exynos4_irq_to_gpio(data->irq), S3C_GPIO_SFN(0xf));
596 case 8 ... 15:
597 s3c_gpio_cfgpin(EINT_GPIO_1(offs & 0x7), EINT_MODE);
598 break;
599 case 16 ... 23:
600 s3c_gpio_cfgpin(EINT_GPIO_2(offs & 0x7), EINT_MODE);
601 break;
602 case 24 ... 31:
603 s3c_gpio_cfgpin(EINT_GPIO_3(offs & 0x7), EINT_MODE);
604 break;
605 default:
606 printk(KERN_ERR "No such irq number %d", offs);
607 }
608 859
609 return 0; 860 return 0;
610} 861}
611 862
612static struct irq_chip exynos4_irq_eint = { 863static struct irq_chip exynos_irq_eint = {
613 .name = "exynos4-eint", 864 .name = "exynos-eint",
614 .irq_mask = exynos4_irq_eint_mask, 865 .irq_mask = exynos_irq_eint_mask,
615 .irq_unmask = exynos4_irq_eint_unmask, 866 .irq_unmask = exynos_irq_eint_unmask,
616 .irq_mask_ack = exynos4_irq_eint_maskack, 867 .irq_mask_ack = exynos_irq_eint_maskack,
617 .irq_ack = exynos4_irq_eint_ack, 868 .irq_ack = exynos_irq_eint_ack,
618 .irq_set_type = exynos4_irq_eint_set_type, 869 .irq_set_type = exynos_irq_eint_set_type,
619#ifdef CONFIG_PM 870#ifdef CONFIG_PM
620 .irq_set_wake = s3c_irqext_wake, 871 .irq_set_wake = s3c_irqext_wake,
621#endif 872#endif
@@ -630,12 +881,12 @@ static struct irq_chip exynos4_irq_eint = {
630 * 881 *
631 * Each EINT pend/mask registers handle eight of them. 882 * Each EINT pend/mask registers handle eight of them.
632 */ 883 */
633static inline void exynos4_irq_demux_eint(unsigned int start) 884static inline void exynos_irq_demux_eint(unsigned int start)
634{ 885{
635 unsigned int irq; 886 unsigned int irq;
636 887
637 u32 status = __raw_readl(S5P_EINT_PEND(EINT_REG_NR(start))); 888 u32 status = __raw_readl(EINT_PEND(exynos_eint_base, start));
638 u32 mask = __raw_readl(S5P_EINT_MASK(EINT_REG_NR(start))); 889 u32 mask = __raw_readl(EINT_MASK(exynos_eint_base, start));
639 890
640 status &= ~mask; 891 status &= ~mask;
641 status &= 0xff; 892 status &= 0xff;
@@ -647,16 +898,16 @@ static inline void exynos4_irq_demux_eint(unsigned int start)
647 } 898 }
648} 899}
649 900
650static void exynos4_irq_demux_eint16_31(unsigned int irq, struct irq_desc *desc) 901static void exynos_irq_demux_eint16_31(unsigned int irq, struct irq_desc *desc)
651{ 902{
652 struct irq_chip *chip = irq_get_chip(irq); 903 struct irq_chip *chip = irq_get_chip(irq);
653 chained_irq_enter(chip, desc); 904 chained_irq_enter(chip, desc);
654 exynos4_irq_demux_eint(IRQ_EINT(16)); 905 exynos_irq_demux_eint(IRQ_EINT(16));
655 exynos4_irq_demux_eint(IRQ_EINT(24)); 906 exynos_irq_demux_eint(IRQ_EINT(24));
656 chained_irq_exit(chip, desc); 907 chained_irq_exit(chip, desc);
657} 908}
658 909
659static void exynos4_irq_eint0_15(unsigned int irq, struct irq_desc *desc) 910static void exynos_irq_eint0_15(unsigned int irq, struct irq_desc *desc)
660{ 911{
661 u32 *irq_data = irq_get_handler_data(irq); 912 u32 *irq_data = irq_get_handler_data(irq);
662 struct irq_chip *chip = irq_get_chip(irq); 913 struct irq_chip *chip = irq_get_chip(irq);
@@ -673,27 +924,44 @@ static void exynos4_irq_eint0_15(unsigned int irq, struct irq_desc *desc)
673 chained_irq_exit(chip, desc); 924 chained_irq_exit(chip, desc);
674} 925}
675 926
676int __init exynos4_init_irq_eint(void) 927static int __init exynos_init_irq_eint(void)
677{ 928{
678 int irq; 929 int irq;
679 930
931 if (soc_is_exynos5250())
932 exynos_eint_base = ioremap(EXYNOS5_PA_GPIO1, SZ_4K);
933 else
934 exynos_eint_base = ioremap(EXYNOS4_PA_GPIO2, SZ_4K);
935
936 if (exynos_eint_base == NULL) {
937 pr_err("unable to ioremap for EINT base address\n");
938 return -ENOMEM;
939 }
940
680 for (irq = 0 ; irq <= 31 ; irq++) { 941 for (irq = 0 ; irq <= 31 ; irq++) {
681 irq_set_chip_and_handler(IRQ_EINT(irq), &exynos4_irq_eint, 942 irq_set_chip_and_handler(IRQ_EINT(irq), &exynos_irq_eint,
682 handle_level_irq); 943 handle_level_irq);
683 set_irq_flags(IRQ_EINT(irq), IRQF_VALID); 944 set_irq_flags(IRQ_EINT(irq), IRQF_VALID);
684 } 945 }
685 946
686 irq_set_chained_handler(IRQ_EINT16_31, exynos4_irq_demux_eint16_31); 947 irq_set_chained_handler(EXYNOS_IRQ_EINT16_31, exynos_irq_demux_eint16_31);
687 948
688 for (irq = 0 ; irq <= 15 ; irq++) { 949 for (irq = 0 ; irq <= 15 ; irq++) {
689 eint0_15_data[irq] = IRQ_EINT(irq); 950 eint0_15_data[irq] = IRQ_EINT(irq);
690 951
691 irq_set_handler_data(exynos4_get_irq_nr(irq), 952 if (soc_is_exynos5250()) {
692 &eint0_15_data[irq]); 953 irq_set_handler_data(exynos5_eint0_15_src_int[irq],
693 irq_set_chained_handler(exynos4_get_irq_nr(irq), 954 &eint0_15_data[irq]);
694 exynos4_irq_eint0_15); 955 irq_set_chained_handler(exynos5_eint0_15_src_int[irq],
956 exynos_irq_eint0_15);
957 } else {
958 irq_set_handler_data(exynos4_eint0_15_src_int[irq],
959 &eint0_15_data[irq]);
960 irq_set_chained_handler(exynos4_eint0_15_src_int[irq],
961 exynos_irq_eint0_15);
962 }
695 } 963 }
696 964
697 return 0; 965 return 0;
698} 966}
699arch_initcall(exynos4_init_irq_eint); 967arch_initcall(exynos_init_irq_eint);
diff --git a/arch/arm/mach-exynos/common.h b/arch/arm/mach-exynos/common.h
index 1ac49de0f39..677b5467df1 100644
--- a/arch/arm/mach-exynos/common.h
+++ b/arch/arm/mach-exynos/common.h
@@ -12,30 +12,44 @@
12#ifndef __ARCH_ARM_MACH_EXYNOS_COMMON_H 12#ifndef __ARCH_ARM_MACH_EXYNOS_COMMON_H
13#define __ARCH_ARM_MACH_EXYNOS_COMMON_H 13#define __ARCH_ARM_MACH_EXYNOS_COMMON_H
14 14
15extern struct sys_timer exynos4_timer;
16
15void exynos_init_io(struct map_desc *mach_desc, int size); 17void exynos_init_io(struct map_desc *mach_desc, int size);
16void exynos4_init_irq(void); 18void exynos4_init_irq(void);
19void exynos5_init_irq(void);
20void exynos4_restart(char mode, const char *cmd);
21void exynos5_restart(char mode, const char *cmd);
17 22
23#ifdef CONFIG_ARCH_EXYNOS4
18void exynos4_register_clocks(void); 24void exynos4_register_clocks(void);
19void exynos4_setup_clocks(void); 25void exynos4_setup_clocks(void);
20 26
21void exynos4210_register_clocks(void); 27#else
22void exynos4212_register_clocks(void); 28#define exynos4_register_clocks()
29#define exynos4_setup_clocks()
30#endif
23 31
24void exynos4_restart(char mode, const char *cmd); 32#ifdef CONFIG_ARCH_EXYNOS5
33void exynos5_register_clocks(void);
34void exynos5_setup_clocks(void);
25 35
26extern struct sys_timer exynos4_timer; 36#else
37#define exynos5_register_clocks()
38#define exynos5_setup_clocks()
39#endif
40
41#ifdef CONFIG_CPU_EXYNOS4210
42void exynos4210_register_clocks(void);
27 43
28#ifdef CONFIG_ARCH_EXYNOS 44#else
29extern int exynos_init(void); 45#define exynos4210_register_clocks()
30extern void exynos4_map_io(void); 46#endif
31extern void exynos4_init_clocks(int xtal); 47
32extern void exynos4_init_uarts(struct s3c2410_uartcfg *cfg, int no); 48#ifdef CONFIG_SOC_EXYNOS4212
49void exynos4212_register_clocks(void);
33 50
34#else 51#else
35#define exynos4_init_clocks NULL 52#define exynos4212_register_clocks()
36#define exynos4_init_uarts NULL
37#define exynos4_map_io NULL
38#define exynos_init NULL
39#endif 53#endif
40 54
41#endif /* __ARCH_ARM_MACH_EXYNOS_COMMON_H */ 55#endif /* __ARCH_ARM_MACH_EXYNOS_COMMON_H */
diff --git a/arch/arm/mach-exynos/cpuidle.c b/arch/arm/mach-exynos/cpuidle.c
index 4ebb382c597..33ab4e7558a 100644
--- a/arch/arm/mach-exynos/cpuidle.c
+++ b/arch/arm/mach-exynos/cpuidle.c
@@ -11,25 +11,53 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/cpuidle.h> 13#include <linux/cpuidle.h>
14#include <linux/cpu_pm.h>
14#include <linux/io.h> 15#include <linux/io.h>
15#include <linux/export.h> 16#include <linux/export.h>
16#include <linux/time.h> 17#include <linux/time.h>
17 18
18#include <asm/proc-fns.h> 19#include <asm/proc-fns.h>
20#include <asm/smp_scu.h>
21#include <asm/suspend.h>
22#include <asm/unified.h>
23#include <mach/regs-pmu.h>
24#include <mach/pmu.h>
25
26#include <plat/cpu.h>
27
28#define REG_DIRECTGO_ADDR (samsung_rev() == EXYNOS4210_REV_1_1 ? \
29 S5P_INFORM7 : (samsung_rev() == EXYNOS4210_REV_1_0 ? \
30 (S5P_VA_SYSRAM + 0x24) : S5P_INFORM0))
31#define REG_DIRECTGO_FLAG (samsung_rev() == EXYNOS4210_REV_1_1 ? \
32 S5P_INFORM6 : (samsung_rev() == EXYNOS4210_REV_1_0 ? \
33 (S5P_VA_SYSRAM + 0x20) : S5P_INFORM1))
34
35#define S5P_CHECK_AFTR 0xFCBA0D10
19 36
20static int exynos4_enter_idle(struct cpuidle_device *dev, 37static int exynos4_enter_idle(struct cpuidle_device *dev,
21 struct cpuidle_driver *drv, 38 struct cpuidle_driver *drv,
22 int index); 39 int index);
40static int exynos4_enter_lowpower(struct cpuidle_device *dev,
41 struct cpuidle_driver *drv,
42 int index);
23 43
24static struct cpuidle_state exynos4_cpuidle_set[] = { 44static struct cpuidle_state exynos4_cpuidle_set[] __initdata = {
25 [0] = { 45 [0] = {
26 .enter = exynos4_enter_idle, 46 .enter = exynos4_enter_idle,
27 .exit_latency = 1, 47 .exit_latency = 1,
28 .target_residency = 100000, 48 .target_residency = 100000,
29 .flags = CPUIDLE_FLAG_TIME_VALID, 49 .flags = CPUIDLE_FLAG_TIME_VALID,
30 .name = "IDLE", 50 .name = "C0",
31 .desc = "ARM clock gating(WFI)", 51 .desc = "ARM clock gating(WFI)",
32 }, 52 },
53 [1] = {
54 .enter = exynos4_enter_lowpower,
55 .exit_latency = 300,
56 .target_residency = 100000,
57 .flags = CPUIDLE_FLAG_TIME_VALID,
58 .name = "C1",
59 .desc = "ARM power down",
60 },
33}; 61};
34 62
35static DEFINE_PER_CPU(struct cpuidle_device, exynos4_cpuidle_device); 63static DEFINE_PER_CPU(struct cpuidle_device, exynos4_cpuidle_device);
@@ -39,9 +67,102 @@ static struct cpuidle_driver exynos4_idle_driver = {
39 .owner = THIS_MODULE, 67 .owner = THIS_MODULE,
40}; 68};
41 69
70/* Ext-GIC nIRQ/nFIQ is the only wakeup source in AFTR */
71static void exynos4_set_wakeupmask(void)
72{
73 __raw_writel(0x0000ff3e, S5P_WAKEUP_MASK);
74}
75
76static unsigned int g_pwr_ctrl, g_diag_reg;
77
78static void save_cpu_arch_register(void)
79{
80 /*read power control register*/
81 asm("mrc p15, 0, %0, c15, c0, 0" : "=r"(g_pwr_ctrl) : : "cc");
82 /*read diagnostic register*/
83 asm("mrc p15, 0, %0, c15, c0, 1" : "=r"(g_diag_reg) : : "cc");
84 return;
85}
86
87static void restore_cpu_arch_register(void)
88{
89 /*write power control register*/
90 asm("mcr p15, 0, %0, c15, c0, 0" : : "r"(g_pwr_ctrl) : "cc");
91 /*write diagnostic register*/
92 asm("mcr p15, 0, %0, c15, c0, 1" : : "r"(g_diag_reg) : "cc");
93 return;
94}
95
96static int idle_finisher(unsigned long flags)
97{
98 cpu_do_idle();
99 return 1;
100}
101
102static int exynos4_enter_core0_aftr(struct cpuidle_device *dev,
103 struct cpuidle_driver *drv,
104 int index)
105{
106 struct timeval before, after;
107 int idle_time;
108 unsigned long tmp;
109
110 local_irq_disable();
111 do_gettimeofday(&before);
112
113 exynos4_set_wakeupmask();
114
115 /* Set value of power down register for aftr mode */
116 exynos4_sys_powerdown_conf(SYS_AFTR);
117
118 __raw_writel(virt_to_phys(s3c_cpu_resume), REG_DIRECTGO_ADDR);
119 __raw_writel(S5P_CHECK_AFTR, REG_DIRECTGO_FLAG);
120
121 save_cpu_arch_register();
122
123 /* Setting Central Sequence Register for power down mode */
124 tmp = __raw_readl(S5P_CENTRAL_SEQ_CONFIGURATION);
125 tmp &= ~S5P_CENTRAL_LOWPWR_CFG;
126 __raw_writel(tmp, S5P_CENTRAL_SEQ_CONFIGURATION);
127
128 cpu_pm_enter();
129 cpu_suspend(0, idle_finisher);
130
131#ifdef CONFIG_SMP
132 scu_enable(S5P_VA_SCU);
133#endif
134 cpu_pm_exit();
135
136 restore_cpu_arch_register();
137
138 /*
139 * If PMU failed while entering sleep mode, WFI will be
140 * ignored by PMU and then exiting cpu_do_idle().
141 * S5P_CENTRAL_LOWPWR_CFG bit will not be set automatically
142 * in this situation.
143 */
144 tmp = __raw_readl(S5P_CENTRAL_SEQ_CONFIGURATION);
145 if (!(tmp & S5P_CENTRAL_LOWPWR_CFG)) {
146 tmp |= S5P_CENTRAL_LOWPWR_CFG;
147 __raw_writel(tmp, S5P_CENTRAL_SEQ_CONFIGURATION);
148 }
149
150 /* Clear wakeup state register */
151 __raw_writel(0x0, S5P_WAKEUP_STAT);
152
153 do_gettimeofday(&after);
154
155 local_irq_enable();
156 idle_time = (after.tv_sec - before.tv_sec) * USEC_PER_SEC +
157 (after.tv_usec - before.tv_usec);
158
159 dev->last_residency = idle_time;
160 return index;
161}
162
42static int exynos4_enter_idle(struct cpuidle_device *dev, 163static int exynos4_enter_idle(struct cpuidle_device *dev,
43 struct cpuidle_driver *drv, 164 struct cpuidle_driver *drv,
44 int index) 165 int index)
45{ 166{
46 struct timeval before, after; 167 struct timeval before, after;
47 int idle_time; 168 int idle_time;
@@ -60,6 +181,22 @@ static int exynos4_enter_idle(struct cpuidle_device *dev,
60 return index; 181 return index;
61} 182}
62 183
184static int exynos4_enter_lowpower(struct cpuidle_device *dev,
185 struct cpuidle_driver *drv,
186 int index)
187{
188 int new_index = index;
189
190 /* This mode only can be entered when other core's are offline */
191 if (num_online_cpus() > 1)
192 new_index = drv->safe_state_index;
193
194 if (new_index == 0)
195 return exynos4_enter_idle(dev, drv, new_index);
196 else
197 return exynos4_enter_core0_aftr(dev, drv, new_index);
198}
199
63static int __init exynos4_init_cpuidle(void) 200static int __init exynos4_init_cpuidle(void)
64{ 201{
65 int i, max_cpuidle_state, cpu_id; 202 int i, max_cpuidle_state, cpu_id;
@@ -74,19 +211,25 @@ static int __init exynos4_init_cpuidle(void)
74 memcpy(&drv->states[i], &exynos4_cpuidle_set[i], 211 memcpy(&drv->states[i], &exynos4_cpuidle_set[i],
75 sizeof(struct cpuidle_state)); 212 sizeof(struct cpuidle_state));
76 } 213 }
214 drv->safe_state_index = 0;
77 cpuidle_register_driver(&exynos4_idle_driver); 215 cpuidle_register_driver(&exynos4_idle_driver);
78 216
79 for_each_cpu(cpu_id, cpu_online_mask) { 217 for_each_cpu(cpu_id, cpu_online_mask) {
80 device = &per_cpu(exynos4_cpuidle_device, cpu_id); 218 device = &per_cpu(exynos4_cpuidle_device, cpu_id);
81 device->cpu = cpu_id; 219 device->cpu = cpu_id;
82 220
83 device->state_count = drv->state_count; 221 if (cpu_id == 0)
222 device->state_count = (sizeof(exynos4_cpuidle_set) /
223 sizeof(struct cpuidle_state));
224 else
225 device->state_count = 1; /* Support IDLE only */
84 226
85 if (cpuidle_register_device(device)) { 227 if (cpuidle_register_device(device)) {
86 printk(KERN_ERR "CPUidle register device failed\n,"); 228 printk(KERN_ERR "CPUidle register device failed\n,");
87 return -EIO; 229 return -EIO;
88 } 230 }
89 } 231 }
232
90 return 0; 233 return 0;
91} 234}
92device_initcall(exynos4_init_cpuidle); 235device_initcall(exynos4_init_cpuidle);
diff --git a/arch/arm/mach-exynos/dev-ahci.c b/arch/arm/mach-exynos/dev-ahci.c
index f57a3de8e1d..50ce5b0adcf 100644
--- a/arch/arm/mach-exynos/dev-ahci.c
+++ b/arch/arm/mach-exynos/dev-ahci.c
@@ -242,8 +242,8 @@ static struct resource exynos4_ahci_resource[] = {
242 .flags = IORESOURCE_MEM, 242 .flags = IORESOURCE_MEM,
243 }, 243 },
244 [1] = { 244 [1] = {
245 .start = IRQ_SATA, 245 .start = EXYNOS4_IRQ_SATA,
246 .end = IRQ_SATA, 246 .end = EXYNOS4_IRQ_SATA,
247 .flags = IORESOURCE_IRQ, 247 .flags = IORESOURCE_IRQ,
248 }, 248 },
249}; 249};
diff --git a/arch/arm/mach-exynos/dev-audio.c b/arch/arm/mach-exynos/dev-audio.c
index 5a9f9c2e53b..7199e1ae79b 100644
--- a/arch/arm/mach-exynos/dev-audio.c
+++ b/arch/arm/mach-exynos/dev-audio.c
@@ -304,8 +304,8 @@ static struct resource exynos4_ac97_resource[] = {
304 .flags = IORESOURCE_DMA, 304 .flags = IORESOURCE_DMA,
305 }, 305 },
306 [4] = { 306 [4] = {
307 .start = IRQ_AC97, 307 .start = EXYNOS4_IRQ_AC97,
308 .end = IRQ_AC97, 308 .end = EXYNOS4_IRQ_AC97,
309 .flags = IORESOURCE_IRQ, 309 .flags = IORESOURCE_IRQ,
310 }, 310 },
311}; 311};
diff --git a/arch/arm/mach-exynos/dev-uart.c b/arch/arm/mach-exynos/dev-uart.c
new file mode 100644
index 00000000000..2e85c022fd1
--- /dev/null
+++ b/arch/arm/mach-exynos/dev-uart.c
@@ -0,0 +1,78 @@
1/*
2 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 * http://www.samsung.com
4 *
5 * Base EXYNOS UART resource and device definitions
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/kernel.h>
13#include <linux/types.h>
14#include <linux/interrupt.h>
15#include <linux/list.h>
16#include <linux/ioport.h>
17#include <linux/platform_device.h>
18
19#include <asm/mach/arch.h>
20#include <asm/mach/irq.h>
21#include <mach/hardware.h>
22#include <mach/map.h>
23
24#include <plat/devs.h>
25
26#define EXYNOS_UART_RESOURCE(_series, _nr) \
27static struct resource exynos##_series##_uart##_nr##_resource[] = { \
28 [0] = DEFINE_RES_MEM(EXYNOS##_series##_PA_UART##_nr, EXYNOS##_series##_SZ_UART), \
29 [1] = DEFINE_RES_IRQ(EXYNOS##_series##_IRQ_UART##_nr), \
30};
31
32EXYNOS_UART_RESOURCE(4, 0)
33EXYNOS_UART_RESOURCE(4, 1)
34EXYNOS_UART_RESOURCE(4, 2)
35EXYNOS_UART_RESOURCE(4, 3)
36
37struct s3c24xx_uart_resources exynos4_uart_resources[] __initdata = {
38 [0] = {
39 .resources = exynos4_uart0_resource,
40 .nr_resources = ARRAY_SIZE(exynos4_uart0_resource),
41 },
42 [1] = {
43 .resources = exynos4_uart1_resource,
44 .nr_resources = ARRAY_SIZE(exynos4_uart1_resource),
45 },
46 [2] = {
47 .resources = exynos4_uart2_resource,
48 .nr_resources = ARRAY_SIZE(exynos4_uart2_resource),
49 },
50 [3] = {
51 .resources = exynos4_uart3_resource,
52 .nr_resources = ARRAY_SIZE(exynos4_uart3_resource),
53 },
54};
55
56EXYNOS_UART_RESOURCE(5, 0)
57EXYNOS_UART_RESOURCE(5, 1)
58EXYNOS_UART_RESOURCE(5, 2)
59EXYNOS_UART_RESOURCE(5, 3)
60
61struct s3c24xx_uart_resources exynos5_uart_resources[] __initdata = {
62 [0] = {
63 .resources = exynos5_uart0_resource,
64 .nr_resources = ARRAY_SIZE(exynos5_uart0_resource),
65 },
66 [1] = {
67 .resources = exynos5_uart1_resource,
68 .nr_resources = ARRAY_SIZE(exynos5_uart0_resource),
69 },
70 [2] = {
71 .resources = exynos5_uart2_resource,
72 .nr_resources = ARRAY_SIZE(exynos5_uart2_resource),
73 },
74 [3] = {
75 .resources = exynos5_uart3_resource,
76 .nr_resources = ARRAY_SIZE(exynos5_uart3_resource),
77 },
78};
diff --git a/arch/arm/mach-exynos/dma.c b/arch/arm/mach-exynos/dma.c
index b10fcd270f0..3983abee426 100644
--- a/arch/arm/mach-exynos/dma.c
+++ b/arch/arm/mach-exynos/dma.c
@@ -29,6 +29,7 @@
29#include <asm/irq.h> 29#include <asm/irq.h>
30#include <plat/devs.h> 30#include <plat/devs.h>
31#include <plat/irqs.h> 31#include <plat/irqs.h>
32#include <plat/cpu.h>
32 33
33#include <mach/map.h> 34#include <mach/map.h>
34#include <mach/irqs.h> 35#include <mach/irqs.h>
@@ -36,7 +37,7 @@
36 37
37static u64 dma_dmamask = DMA_BIT_MASK(32); 38static u64 dma_dmamask = DMA_BIT_MASK(32);
38 39
39u8 pdma0_peri[] = { 40static u8 exynos4210_pdma0_peri[] = {
40 DMACH_PCM0_RX, 41 DMACH_PCM0_RX,
41 DMACH_PCM0_TX, 42 DMACH_PCM0_TX,
42 DMACH_PCM2_RX, 43 DMACH_PCM2_RX,
@@ -69,28 +70,47 @@ u8 pdma0_peri[] = {
69 DMACH_AC97_PCMOUT, 70 DMACH_AC97_PCMOUT,
70}; 71};
71 72
72struct dma_pl330_platdata exynos4_pdma0_pdata = { 73static u8 exynos4212_pdma0_peri[] = {
73 .nr_valid_peri = ARRAY_SIZE(pdma0_peri), 74 DMACH_PCM0_RX,
74 .peri_id = pdma0_peri, 75 DMACH_PCM0_TX,
76 DMACH_PCM2_RX,
77 DMACH_PCM2_TX,
78 DMACH_MIPI_HSI0,
79 DMACH_MIPI_HSI1,
80 DMACH_SPI0_RX,
81 DMACH_SPI0_TX,
82 DMACH_SPI2_RX,
83 DMACH_SPI2_TX,
84 DMACH_I2S0S_TX,
85 DMACH_I2S0_RX,
86 DMACH_I2S0_TX,
87 DMACH_I2S2_RX,
88 DMACH_I2S2_TX,
89 DMACH_UART0_RX,
90 DMACH_UART0_TX,
91 DMACH_UART2_RX,
92 DMACH_UART2_TX,
93 DMACH_UART4_RX,
94 DMACH_UART4_TX,
95 DMACH_SLIMBUS0_RX,
96 DMACH_SLIMBUS0_TX,
97 DMACH_SLIMBUS2_RX,
98 DMACH_SLIMBUS2_TX,
99 DMACH_SLIMBUS4_RX,
100 DMACH_SLIMBUS4_TX,
101 DMACH_AC97_MICIN,
102 DMACH_AC97_PCMIN,
103 DMACH_AC97_PCMOUT,
104 DMACH_MIPI_HSI4,
105 DMACH_MIPI_HSI5,
75}; 106};
76 107
77struct amba_device exynos4_device_pdma0 = { 108struct dma_pl330_platdata exynos4_pdma0_pdata;
78 .dev = { 109
79 .init_name = "dma-pl330.0", 110static AMBA_AHB_DEVICE(exynos4_pdma0, "dma-pl330.0", 0x00041330,
80 .dma_mask = &dma_dmamask, 111 EXYNOS4_PA_PDMA0, {EXYNOS4_IRQ_PDMA0}, &exynos4_pdma0_pdata);
81 .coherent_dma_mask = DMA_BIT_MASK(32),
82 .platform_data = &exynos4_pdma0_pdata,
83 },
84 .res = {
85 .start = EXYNOS4_PA_PDMA0,
86 .end = EXYNOS4_PA_PDMA0 + SZ_4K,
87 .flags = IORESOURCE_MEM,
88 },
89 .irq = {IRQ_PDMA0, NO_IRQ},
90 .periphid = 0x00041330,
91};
92 112
93u8 pdma1_peri[] = { 113static u8 exynos4210_pdma1_peri[] = {
94 DMACH_PCM0_RX, 114 DMACH_PCM0_RX,
95 DMACH_PCM0_TX, 115 DMACH_PCM0_TX,
96 DMACH_PCM1_RX, 116 DMACH_PCM1_RX,
@@ -118,39 +138,94 @@ u8 pdma1_peri[] = {
118 DMACH_SLIMBUS5_TX, 138 DMACH_SLIMBUS5_TX,
119}; 139};
120 140
121struct dma_pl330_platdata exynos4_pdma1_pdata = { 141static u8 exynos4212_pdma1_peri[] = {
122 .nr_valid_peri = ARRAY_SIZE(pdma1_peri), 142 DMACH_PCM0_RX,
123 .peri_id = pdma1_peri, 143 DMACH_PCM0_TX,
144 DMACH_PCM1_RX,
145 DMACH_PCM1_TX,
146 DMACH_MIPI_HSI2,
147 DMACH_MIPI_HSI3,
148 DMACH_SPI1_RX,
149 DMACH_SPI1_TX,
150 DMACH_I2S0S_TX,
151 DMACH_I2S0_RX,
152 DMACH_I2S0_TX,
153 DMACH_I2S1_RX,
154 DMACH_I2S1_TX,
155 DMACH_UART0_RX,
156 DMACH_UART0_TX,
157 DMACH_UART1_RX,
158 DMACH_UART1_TX,
159 DMACH_UART3_RX,
160 DMACH_UART3_TX,
161 DMACH_SLIMBUS1_RX,
162 DMACH_SLIMBUS1_TX,
163 DMACH_SLIMBUS3_RX,
164 DMACH_SLIMBUS3_TX,
165 DMACH_SLIMBUS5_RX,
166 DMACH_SLIMBUS5_TX,
167 DMACH_SLIMBUS0AUX_RX,
168 DMACH_SLIMBUS0AUX_TX,
169 DMACH_SPDIF,
170 DMACH_MIPI_HSI6,
171 DMACH_MIPI_HSI7,
124}; 172};
125 173
126struct amba_device exynos4_device_pdma1 = { 174static struct dma_pl330_platdata exynos4_pdma1_pdata;
127 .dev = { 175
128 .init_name = "dma-pl330.1", 176static AMBA_AHB_DEVICE(exynos4_pdma1, "dma-pl330.1", 0x00041330,
129 .dma_mask = &dma_dmamask, 177 EXYNOS4_PA_PDMA1, {EXYNOS4_IRQ_PDMA1}, &exynos4_pdma1_pdata);
130 .coherent_dma_mask = DMA_BIT_MASK(32), 178
131 .platform_data = &exynos4_pdma1_pdata, 179static u8 mdma_peri[] = {
132 }, 180 DMACH_MTOM_0,
133 .res = { 181 DMACH_MTOM_1,
134 .start = EXYNOS4_PA_PDMA1, 182 DMACH_MTOM_2,
135 .end = EXYNOS4_PA_PDMA1 + SZ_4K, 183 DMACH_MTOM_3,
136 .flags = IORESOURCE_MEM, 184 DMACH_MTOM_4,
137 }, 185 DMACH_MTOM_5,
138 .irq = {IRQ_PDMA1, NO_IRQ}, 186 DMACH_MTOM_6,
139 .periphid = 0x00041330, 187 DMACH_MTOM_7,
188};
189
190static struct dma_pl330_platdata exynos4_mdma1_pdata = {
191 .nr_valid_peri = ARRAY_SIZE(mdma_peri),
192 .peri_id = mdma_peri,
140}; 193};
141 194
195static AMBA_AHB_DEVICE(exynos4_mdma1, "dma-pl330.2", 0x00041330,
196 EXYNOS4_PA_MDMA1, {EXYNOS4_IRQ_MDMA1}, &exynos4_mdma1_pdata);
197
142static int __init exynos4_dma_init(void) 198static int __init exynos4_dma_init(void)
143{ 199{
144 if (of_have_populated_dt()) 200 if (of_have_populated_dt())
145 return 0; 201 return 0;
146 202
203 if (soc_is_exynos4210()) {
204 exynos4_pdma0_pdata.nr_valid_peri =
205 ARRAY_SIZE(exynos4210_pdma0_peri);
206 exynos4_pdma0_pdata.peri_id = exynos4210_pdma0_peri;
207 exynos4_pdma1_pdata.nr_valid_peri =
208 ARRAY_SIZE(exynos4210_pdma1_peri);
209 exynos4_pdma1_pdata.peri_id = exynos4210_pdma1_peri;
210 } else if (soc_is_exynos4212() || soc_is_exynos4412()) {
211 exynos4_pdma0_pdata.nr_valid_peri =
212 ARRAY_SIZE(exynos4212_pdma0_peri);
213 exynos4_pdma0_pdata.peri_id = exynos4212_pdma0_peri;
214 exynos4_pdma1_pdata.nr_valid_peri =
215 ARRAY_SIZE(exynos4212_pdma1_peri);
216 exynos4_pdma1_pdata.peri_id = exynos4212_pdma1_peri;
217 }
218
147 dma_cap_set(DMA_SLAVE, exynos4_pdma0_pdata.cap_mask); 219 dma_cap_set(DMA_SLAVE, exynos4_pdma0_pdata.cap_mask);
148 dma_cap_set(DMA_CYCLIC, exynos4_pdma0_pdata.cap_mask); 220 dma_cap_set(DMA_CYCLIC, exynos4_pdma0_pdata.cap_mask);
149 amba_device_register(&exynos4_device_pdma0, &iomem_resource); 221 amba_device_register(&exynos4_pdma0_device, &iomem_resource);
150 222
151 dma_cap_set(DMA_SLAVE, exynos4_pdma1_pdata.cap_mask); 223 dma_cap_set(DMA_SLAVE, exynos4_pdma1_pdata.cap_mask);
152 dma_cap_set(DMA_CYCLIC, exynos4_pdma1_pdata.cap_mask); 224 dma_cap_set(DMA_CYCLIC, exynos4_pdma1_pdata.cap_mask);
153 amba_device_register(&exynos4_device_pdma1, &iomem_resource); 225 amba_device_register(&exynos4_pdma1_device, &iomem_resource);
226
227 dma_cap_set(DMA_MEMCPY, exynos4_mdma1_pdata.cap_mask);
228 amba_device_register(&exynos4_mdma1_device, &iomem_resource);
154 229
155 return 0; 230 return 0;
156} 231}
diff --git a/arch/arm/mach-exynos/include/mach/cpufreq.h b/arch/arm/mach-exynos/include/mach/cpufreq.h
index 3df27f2d503..7517c3f417a 100644
--- a/arch/arm/mach-exynos/include/mach/cpufreq.h
+++ b/arch/arm/mach-exynos/include/mach/cpufreq.h
@@ -32,3 +32,5 @@ struct exynos_dvfs_info {
32}; 32};
33 33
34extern int exynos4210_cpufreq_init(struct exynos_dvfs_info *); 34extern int exynos4210_cpufreq_init(struct exynos_dvfs_info *);
35extern int exynos4x12_cpufreq_init(struct exynos_dvfs_info *);
36extern int exynos5250_cpufreq_init(struct exynos_dvfs_info *);
diff --git a/arch/arm/mach-exynos/include/mach/debug-macro.S b/arch/arm/mach-exynos/include/mach/debug-macro.S
index 6cacf16a67a..6c857ff0b5d 100644
--- a/arch/arm/mach-exynos/include/mach/debug-macro.S
+++ b/arch/arm/mach-exynos/include/mach/debug-macro.S
@@ -21,8 +21,13 @@
21 */ 21 */
22 22
23 .macro addruart, rp, rv, tmp 23 .macro addruart, rp, rv, tmp
24 ldr \rp, = S3C_PA_UART 24 mov \rp, #0x10000000
25 ldr \rv, = S3C_VA_UART 25 ldr \rp, [\rp, #0x0]
26 and \rp, \rp, #0xf00000
27 teq \rp, #0x500000 @@ EXYNOS5
28 ldreq \rp, =EXYNOS5_PA_UART
29 movne \rp, #EXYNOS4_PA_UART @@ EXYNOS4
30 ldr \rv, =S3C_VA_UART
26#if CONFIG_DEBUG_S3C_UART != 0 31#if CONFIG_DEBUG_S3C_UART != 0
27 add \rp, \rp, #(0x10000 * CONFIG_DEBUG_S3C_UART) 32 add \rp, \rp, #(0x10000 * CONFIG_DEBUG_S3C_UART)
28 add \rv, \rv, #(0x10000 * CONFIG_DEBUG_S3C_UART) 33 add \rv, \rv, #(0x10000 * CONFIG_DEBUG_S3C_UART)
diff --git a/arch/arm/mach-exynos/include/mach/entry-macro.S b/arch/arm/mach-exynos/include/mach/entry-macro.S
deleted file mode 100644
index 3ba4f547534..00000000000
--- a/arch/arm/mach-exynos/include/mach/entry-macro.S
+++ /dev/null
@@ -1,16 +0,0 @@
1/* arch/arm/mach-exynos4/include/mach/entry-macro.S
2 *
3 * Cloned from arch/arm/mach-realview/include/mach/entry-macro.S
4 *
5 * Low-level IRQ helper macros for EXYNOS4 platforms
6 *
7 * This file is licensed under the terms of the GNU General Public
8 * License version 2. This program is licensed "as is" without any
9 * warranty of any kind, whether express or implied.
10*/
11
12 .macro disable_fiq
13 .endm
14
15 .macro arch_ret_to_user, tmp1, tmp2
16 .endm
diff --git a/arch/arm/mach-exynos/include/mach/exynos4-clock.h b/arch/arm/mach-exynos/include/mach/exynos4-clock.h
deleted file mode 100644
index a07fcbf5525..00000000000
--- a/arch/arm/mach-exynos/include/mach/exynos4-clock.h
+++ /dev/null
@@ -1,43 +0,0 @@
1/*
2 * linux/arch/arm/mach-exynos4/include/mach/exynos4-clock.h
3 *
4 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com
6 *
7 * Header file for exynos4 clock support
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_CLOCK_H
15#define __ASM_ARCH_CLOCK_H __FILE__
16
17#include <linux/clk.h>
18
19extern struct clk clk_sclk_hdmi27m;
20extern struct clk clk_sclk_usbphy0;
21extern struct clk clk_sclk_usbphy1;
22extern struct clk clk_sclk_hdmiphy;
23
24extern struct clksrc_clk clk_sclk_apll;
25extern struct clksrc_clk clk_mout_mpll;
26extern struct clksrc_clk clk_aclk_133;
27extern struct clksrc_clk clk_mout_epll;
28extern struct clksrc_clk clk_sclk_vpll;
29
30extern struct clk *clkset_corebus_list[];
31extern struct clksrc_sources clkset_mout_corebus;
32
33extern struct clk *clkset_aclk_top_list[];
34extern struct clksrc_sources clkset_aclk;
35
36extern struct clk *clkset_group_list[];
37extern struct clksrc_sources clkset_group;
38
39extern int exynos4_clksrc_mask_fsys_ctrl(struct clk *clk, int enable);
40extern int exynos4_clk_ip_fsys_ctrl(struct clk *clk, int enable);
41extern int exynos4_clk_ip_lcd1_ctrl(struct clk *clk, int enable);
42
43#endif /* __ASM_ARCH_CLOCK_H */
diff --git a/arch/arm/mach-exynos/include/mach/gpio.h b/arch/arm/mach-exynos/include/mach/gpio.h
index 80523ca9bb4..d7498afe036 100644
--- a/arch/arm/mach-exynos/include/mach/gpio.h
+++ b/arch/arm/mach-exynos/include/mach/gpio.h
@@ -1,9 +1,8 @@
1/* linux/arch/arm/mach-exynos4/include/mach/gpio.h 1/*
2 * 2 * Copyright (c) 2010-2012 Samsung Electronics Co., Ltd.
3 * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com 3 * http://www.samsung.com
5 * 4 *
6 * EXYNOS4 - GPIO lib support 5 * EXYNOS - GPIO lib support
7 * 6 *
8 * 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
9 * 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
@@ -13,9 +12,13 @@
13#ifndef __ASM_ARCH_GPIO_H 12#ifndef __ASM_ARCH_GPIO_H
14#define __ASM_ARCH_GPIO_H __FILE__ 13#define __ASM_ARCH_GPIO_H __FILE__
15 14
16/* Practically, GPIO banks up to GPZ are the configurable gpio banks */ 15/* Macro for EXYNOS GPIO numbering */
16
17#define EXYNOS_GPIO_NEXT(__gpio) \
18 ((__gpio##_START) + (__gpio##_NR) + CONFIG_S3C_GPIO_SPACE + 1)
19
20/* EXYNOS4 GPIO bank sizes */
17 21
18/* GPIO bank sizes */
19#define EXYNOS4_GPIO_A0_NR (8) 22#define EXYNOS4_GPIO_A0_NR (8)
20#define EXYNOS4_GPIO_A1_NR (6) 23#define EXYNOS4_GPIO_A1_NR (6)
21#define EXYNOS4_GPIO_B_NR (8) 24#define EXYNOS4_GPIO_B_NR (8)
@@ -54,52 +57,50 @@
54#define EXYNOS4_GPIO_Y6_NR (8) 57#define EXYNOS4_GPIO_Y6_NR (8)
55#define EXYNOS4_GPIO_Z_NR (7) 58#define EXYNOS4_GPIO_Z_NR (7)
56 59
57/* GPIO bank numbers */ 60/* EXYNOS4 GPIO bank numbers */
58
59#define EXYNOS4_GPIO_NEXT(__gpio) \
60 ((__gpio##_START) + (__gpio##_NR) + CONFIG_S3C_GPIO_SPACE + 1)
61 61
62enum s5p_gpio_number { 62enum exynos4_gpio_number {
63 EXYNOS4_GPIO_A0_START = 0, 63 EXYNOS4_GPIO_A0_START = 0,
64 EXYNOS4_GPIO_A1_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_A0), 64 EXYNOS4_GPIO_A1_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_A0),
65 EXYNOS4_GPIO_B_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_A1), 65 EXYNOS4_GPIO_B_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_A1),
66 EXYNOS4_GPIO_C0_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_B), 66 EXYNOS4_GPIO_C0_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_B),
67 EXYNOS4_GPIO_C1_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_C0), 67 EXYNOS4_GPIO_C1_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_C0),
68 EXYNOS4_GPIO_D0_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_C1), 68 EXYNOS4_GPIO_D0_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_C1),
69 EXYNOS4_GPIO_D1_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_D0), 69 EXYNOS4_GPIO_D1_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_D0),
70 EXYNOS4_GPIO_E0_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_D1), 70 EXYNOS4_GPIO_E0_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_D1),
71 EXYNOS4_GPIO_E1_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_E0), 71 EXYNOS4_GPIO_E1_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_E0),
72 EXYNOS4_GPIO_E2_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_E1), 72 EXYNOS4_GPIO_E2_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_E1),
73 EXYNOS4_GPIO_E3_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_E2), 73 EXYNOS4_GPIO_E3_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_E2),
74 EXYNOS4_GPIO_E4_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_E3), 74 EXYNOS4_GPIO_E4_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_E3),
75 EXYNOS4_GPIO_F0_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_E4), 75 EXYNOS4_GPIO_F0_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_E4),
76 EXYNOS4_GPIO_F1_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_F0), 76 EXYNOS4_GPIO_F1_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_F0),
77 EXYNOS4_GPIO_F2_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_F1), 77 EXYNOS4_GPIO_F2_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_F1),
78 EXYNOS4_GPIO_F3_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_F2), 78 EXYNOS4_GPIO_F3_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_F2),
79 EXYNOS4_GPIO_J0_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_F3), 79 EXYNOS4_GPIO_J0_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_F3),
80 EXYNOS4_GPIO_J1_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_J0), 80 EXYNOS4_GPIO_J1_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_J0),
81 EXYNOS4_GPIO_K0_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_J1), 81 EXYNOS4_GPIO_K0_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_J1),
82 EXYNOS4_GPIO_K1_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_K0), 82 EXYNOS4_GPIO_K1_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_K0),
83 EXYNOS4_GPIO_K2_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_K1), 83 EXYNOS4_GPIO_K2_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_K1),
84 EXYNOS4_GPIO_K3_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_K2), 84 EXYNOS4_GPIO_K3_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_K2),
85 EXYNOS4_GPIO_L0_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_K3), 85 EXYNOS4_GPIO_L0_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_K3),
86 EXYNOS4_GPIO_L1_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_L0), 86 EXYNOS4_GPIO_L1_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_L0),
87 EXYNOS4_GPIO_L2_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_L1), 87 EXYNOS4_GPIO_L2_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_L1),
88 EXYNOS4_GPIO_X0_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_L2), 88 EXYNOS4_GPIO_X0_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_L2),
89 EXYNOS4_GPIO_X1_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_X0), 89 EXYNOS4_GPIO_X1_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_X0),
90 EXYNOS4_GPIO_X2_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_X1), 90 EXYNOS4_GPIO_X2_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_X1),
91 EXYNOS4_GPIO_X3_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_X2), 91 EXYNOS4_GPIO_X3_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_X2),
92 EXYNOS4_GPIO_Y0_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_X3), 92 EXYNOS4_GPIO_Y0_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_X3),
93 EXYNOS4_GPIO_Y1_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_Y0), 93 EXYNOS4_GPIO_Y1_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_Y0),
94 EXYNOS4_GPIO_Y2_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_Y1), 94 EXYNOS4_GPIO_Y2_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_Y1),
95 EXYNOS4_GPIO_Y3_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_Y2), 95 EXYNOS4_GPIO_Y3_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_Y2),
96 EXYNOS4_GPIO_Y4_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_Y3), 96 EXYNOS4_GPIO_Y4_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_Y3),
97 EXYNOS4_GPIO_Y5_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_Y4), 97 EXYNOS4_GPIO_Y5_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_Y4),
98 EXYNOS4_GPIO_Y6_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_Y5), 98 EXYNOS4_GPIO_Y6_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_Y5),
99 EXYNOS4_GPIO_Z_START = EXYNOS4_GPIO_NEXT(EXYNOS4_GPIO_Y6), 99 EXYNOS4_GPIO_Z_START = EXYNOS_GPIO_NEXT(EXYNOS4_GPIO_Y6),
100}; 100};
101 101
102/* EXYNOS4 GPIO number definitions */ 102/* EXYNOS4 GPIO number definitions */
103
103#define EXYNOS4_GPA0(_nr) (EXYNOS4_GPIO_A0_START + (_nr)) 104#define EXYNOS4_GPA0(_nr) (EXYNOS4_GPIO_A0_START + (_nr))
104#define EXYNOS4_GPA1(_nr) (EXYNOS4_GPIO_A1_START + (_nr)) 105#define EXYNOS4_GPA1(_nr) (EXYNOS4_GPIO_A1_START + (_nr))
105#define EXYNOS4_GPB(_nr) (EXYNOS4_GPIO_B_START + (_nr)) 106#define EXYNOS4_GPB(_nr) (EXYNOS4_GPIO_B_START + (_nr))
@@ -139,11 +140,147 @@ enum s5p_gpio_number {
139#define EXYNOS4_GPZ(_nr) (EXYNOS4_GPIO_Z_START + (_nr)) 140#define EXYNOS4_GPZ(_nr) (EXYNOS4_GPIO_Z_START + (_nr))
140 141
141/* the end of the EXYNOS4 specific gpios */ 142/* the end of the EXYNOS4 specific gpios */
143
142#define EXYNOS4_GPIO_END (EXYNOS4_GPZ(EXYNOS4_GPIO_Z_NR) + 1) 144#define EXYNOS4_GPIO_END (EXYNOS4_GPZ(EXYNOS4_GPIO_Z_NR) + 1)
143#define S3C_GPIO_END EXYNOS4_GPIO_END
144 145
145/* define the number of gpios we need to the one after the GPZ() range */ 146/* EXYNOS5 GPIO bank sizes */
146#define ARCH_NR_GPIOS (EXYNOS4_GPZ(EXYNOS4_GPIO_Z_NR) + \ 147
147 CONFIG_SAMSUNG_GPIO_EXTRA + 1) 148#define EXYNOS5_GPIO_A0_NR (8)
149#define EXYNOS5_GPIO_A1_NR (6)
150#define EXYNOS5_GPIO_A2_NR (8)
151#define EXYNOS5_GPIO_B0_NR (5)
152#define EXYNOS5_GPIO_B1_NR (5)
153#define EXYNOS5_GPIO_B2_NR (4)
154#define EXYNOS5_GPIO_B3_NR (4)
155#define EXYNOS5_GPIO_C0_NR (7)
156#define EXYNOS5_GPIO_C1_NR (7)
157#define EXYNOS5_GPIO_C2_NR (7)
158#define EXYNOS5_GPIO_C3_NR (7)
159#define EXYNOS5_GPIO_D0_NR (8)
160#define EXYNOS5_GPIO_D1_NR (8)
161#define EXYNOS5_GPIO_Y0_NR (6)
162#define EXYNOS5_GPIO_Y1_NR (4)
163#define EXYNOS5_GPIO_Y2_NR (6)
164#define EXYNOS5_GPIO_Y3_NR (8)
165#define EXYNOS5_GPIO_Y4_NR (8)
166#define EXYNOS5_GPIO_Y5_NR (8)
167#define EXYNOS5_GPIO_Y6_NR (8)
168#define EXYNOS5_GPIO_X0_NR (8)
169#define EXYNOS5_GPIO_X1_NR (8)
170#define EXYNOS5_GPIO_X2_NR (8)
171#define EXYNOS5_GPIO_X3_NR (8)
172#define EXYNOS5_GPIO_E0_NR (8)
173#define EXYNOS5_GPIO_E1_NR (2)
174#define EXYNOS5_GPIO_F0_NR (4)
175#define EXYNOS5_GPIO_F1_NR (4)
176#define EXYNOS5_GPIO_G0_NR (8)
177#define EXYNOS5_GPIO_G1_NR (8)
178#define EXYNOS5_GPIO_G2_NR (2)
179#define EXYNOS5_GPIO_H0_NR (4)
180#define EXYNOS5_GPIO_H1_NR (8)
181#define EXYNOS5_GPIO_V0_NR (8)
182#define EXYNOS5_GPIO_V1_NR (8)
183#define EXYNOS5_GPIO_V2_NR (8)
184#define EXYNOS5_GPIO_V3_NR (8)
185#define EXYNOS5_GPIO_V4_NR (2)
186#define EXYNOS5_GPIO_Z_NR (7)
187
188/* EXYNOS5 GPIO bank numbers */
189
190enum exynos5_gpio_number {
191 EXYNOS5_GPIO_A0_START = 0,
192 EXYNOS5_GPIO_A1_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_A0),
193 EXYNOS5_GPIO_A2_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_A1),
194 EXYNOS5_GPIO_B0_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_A2),
195 EXYNOS5_GPIO_B1_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_B0),
196 EXYNOS5_GPIO_B2_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_B1),
197 EXYNOS5_GPIO_B3_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_B2),
198 EXYNOS5_GPIO_C0_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_B3),
199 EXYNOS5_GPIO_C1_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_C0),
200 EXYNOS5_GPIO_C2_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_C1),
201 EXYNOS5_GPIO_C3_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_C2),
202 EXYNOS5_GPIO_D0_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_C3),
203 EXYNOS5_GPIO_D1_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_D0),
204 EXYNOS5_GPIO_Y0_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_D1),
205 EXYNOS5_GPIO_Y1_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_Y0),
206 EXYNOS5_GPIO_Y2_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_Y1),
207 EXYNOS5_GPIO_Y3_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_Y2),
208 EXYNOS5_GPIO_Y4_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_Y3),
209 EXYNOS5_GPIO_Y5_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_Y4),
210 EXYNOS5_GPIO_Y6_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_Y5),
211 EXYNOS5_GPIO_X0_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_Y6),
212 EXYNOS5_GPIO_X1_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_X0),
213 EXYNOS5_GPIO_X2_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_X1),
214 EXYNOS5_GPIO_X3_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_X2),
215 EXYNOS5_GPIO_E0_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_X3),
216 EXYNOS5_GPIO_E1_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_E0),
217 EXYNOS5_GPIO_F0_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_E1),
218 EXYNOS5_GPIO_F1_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_F0),
219 EXYNOS5_GPIO_G0_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_F1),
220 EXYNOS5_GPIO_G1_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_G0),
221 EXYNOS5_GPIO_G2_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_G1),
222 EXYNOS5_GPIO_H0_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_G2),
223 EXYNOS5_GPIO_H1_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_H0),
224 EXYNOS5_GPIO_V0_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_H1),
225 EXYNOS5_GPIO_V1_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_V0),
226 EXYNOS5_GPIO_V2_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_V1),
227 EXYNOS5_GPIO_V3_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_V2),
228 EXYNOS5_GPIO_V4_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_V3),
229 EXYNOS5_GPIO_Z_START = EXYNOS_GPIO_NEXT(EXYNOS5_GPIO_V4),
230};
231
232/* EXYNOS5 GPIO number definitions */
233
234#define EXYNOS5_GPA0(_nr) (EXYNOS5_GPIO_A0_START + (_nr))
235#define EXYNOS5_GPA1(_nr) (EXYNOS5_GPIO_A1_START + (_nr))
236#define EXYNOS5_GPA2(_nr) (EXYNOS5_GPIO_A2_START + (_nr))
237#define EXYNOS5_GPB0(_nr) (EXYNOS5_GPIO_B0_START + (_nr))
238#define EXYNOS5_GPB1(_nr) (EXYNOS5_GPIO_B1_START + (_nr))
239#define EXYNOS5_GPB2(_nr) (EXYNOS5_GPIO_B2_START + (_nr))
240#define EXYNOS5_GPB3(_nr) (EXYNOS5_GPIO_B3_START + (_nr))
241#define EXYNOS5_GPC0(_nr) (EXYNOS5_GPIO_C0_START + (_nr))
242#define EXYNOS5_GPC1(_nr) (EXYNOS5_GPIO_C1_START + (_nr))
243#define EXYNOS5_GPC2(_nr) (EXYNOS5_GPIO_C2_START + (_nr))
244#define EXYNOS5_GPC3(_nr) (EXYNOS5_GPIO_C3_START + (_nr))
245#define EXYNOS5_GPD0(_nr) (EXYNOS5_GPIO_D0_START + (_nr))
246#define EXYNOS5_GPD1(_nr) (EXYNOS5_GPIO_D1_START + (_nr))
247#define EXYNOS5_GPY0(_nr) (EXYNOS5_GPIO_Y0_START + (_nr))
248#define EXYNOS5_GPY1(_nr) (EXYNOS5_GPIO_Y1_START + (_nr))
249#define EXYNOS5_GPY2(_nr) (EXYNOS5_GPIO_Y2_START + (_nr))
250#define EXYNOS5_GPY3(_nr) (EXYNOS5_GPIO_Y3_START + (_nr))
251#define EXYNOS5_GPY4(_nr) (EXYNOS5_GPIO_Y4_START + (_nr))
252#define EXYNOS5_GPY5(_nr) (EXYNOS5_GPIO_Y5_START + (_nr))
253#define EXYNOS5_GPY6(_nr) (EXYNOS5_GPIO_Y6_START + (_nr))
254#define EXYNOS5_GPX0(_nr) (EXYNOS5_GPIO_X0_START + (_nr))
255#define EXYNOS5_GPX1(_nr) (EXYNOS5_GPIO_X1_START + (_nr))
256#define EXYNOS5_GPX2(_nr) (EXYNOS5_GPIO_X2_START + (_nr))
257#define EXYNOS5_GPX3(_nr) (EXYNOS5_GPIO_X3_START + (_nr))
258#define EXYNOS5_GPE0(_nr) (EXYNOS5_GPIO_E0_START + (_nr))
259#define EXYNOS5_GPE1(_nr) (EXYNOS5_GPIO_E1_START + (_nr))
260#define EXYNOS5_GPF0(_nr) (EXYNOS5_GPIO_F0_START + (_nr))
261#define EXYNOS5_GPF1(_nr) (EXYNOS5_GPIO_F1_START + (_nr))
262#define EXYNOS5_GPG0(_nr) (EXYNOS5_GPIO_G0_START + (_nr))
263#define EXYNOS5_GPG1(_nr) (EXYNOS5_GPIO_G1_START + (_nr))
264#define EXYNOS5_GPG2(_nr) (EXYNOS5_GPIO_G2_START + (_nr))
265#define EXYNOS5_GPH0(_nr) (EXYNOS5_GPIO_H0_START + (_nr))
266#define EXYNOS5_GPH1(_nr) (EXYNOS5_GPIO_H1_START + (_nr))
267#define EXYNOS5_GPV0(_nr) (EXYNOS5_GPIO_V0_START + (_nr))
268#define EXYNOS5_GPV1(_nr) (EXYNOS5_GPIO_V1_START + (_nr))
269#define EXYNOS5_GPV2(_nr) (EXYNOS5_GPIO_V2_START + (_nr))
270#define EXYNOS5_GPV3(_nr) (EXYNOS5_GPIO_V3_START + (_nr))
271#define EXYNOS5_GPV4(_nr) (EXYNOS5_GPIO_V4_START + (_nr))
272#define EXYNOS5_GPZ(_nr) (EXYNOS5_GPIO_Z_START + (_nr))
273
274/* the end of the EXYNOS5 specific gpios */
275
276#define EXYNOS5_GPIO_END (EXYNOS5_GPZ(EXYNOS5_GPIO_Z_NR) + 1)
277
278/* actually, EXYNOS5_GPIO_END is bigger than EXYNOS4 */
279
280#define S3C_GPIO_END (EXYNOS5_GPIO_END)
281
282/* define the number of gpios */
283
284#define ARCH_NR_GPIOS (CONFIG_SAMSUNG_GPIO_EXTRA + S3C_GPIO_END)
148 285
149#endif /* __ASM_ARCH_GPIO_H */ 286#endif /* __ASM_ARCH_GPIO_H */
diff --git a/arch/arm/mach-exynos/include/mach/irqs.h b/arch/arm/mach-exynos/include/mach/irqs.h
index f77bce04789..9bee8535d9e 100644
--- a/arch/arm/mach-exynos/include/mach/irqs.h
+++ b/arch/arm/mach-exynos/include/mach/irqs.h
@@ -1,9 +1,8 @@
1/* linux/arch/arm/mach-exynos4/include/mach/irqs.h 1/*
2 * 2 * Copyright (c) 2010-2012 Samsung Electronics Co., Ltd.
3 * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com 3 * http://www.samsung.com
5 * 4 *
6 * EXYNOS4 - IRQ definitions 5 * EXYNOS - IRQ definitions
7 * 6 *
8 * 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
9 * 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
@@ -17,158 +16,450 @@
17 16
18/* PPI: Private Peripheral Interrupt */ 17/* PPI: Private Peripheral Interrupt */
19 18
20#define IRQ_PPI(x) (x+16) 19#define IRQ_PPI(x) (x + 16)
21
22#define IRQ_MCT_LOCALTIMER IRQ_PPI(12)
23 20
24/* SPI: Shared Peripheral Interrupt */ 21/* SPI: Shared Peripheral Interrupt */
25 22
26#define IRQ_SPI(x) (x+32) 23#define IRQ_SPI(x) (x + 32)
27 24
28#define IRQ_EINT0 IRQ_SPI(16) 25/* COMBINER */
29#define IRQ_EINT1 IRQ_SPI(17) 26
30#define IRQ_EINT2 IRQ_SPI(18) 27#define MAX_IRQ_IN_COMBINER 8
31#define IRQ_EINT3 IRQ_SPI(19) 28#define COMBINER_GROUP(x) ((x) * MAX_IRQ_IN_COMBINER + IRQ_SPI(128))
32#define IRQ_EINT4 IRQ_SPI(20) 29#define COMBINER_IRQ(x, y) (COMBINER_GROUP(x) + y)
33#define IRQ_EINT5 IRQ_SPI(21) 30
34#define IRQ_EINT6 IRQ_SPI(22) 31/* For EXYNOS4 and EXYNOS5 */
35#define IRQ_EINT7 IRQ_SPI(23) 32
36#define IRQ_EINT8 IRQ_SPI(24) 33#define EXYNOS_IRQ_MCT_LOCALTIMER IRQ_PPI(12)
37#define IRQ_EINT9 IRQ_SPI(25) 34
38#define IRQ_EINT10 IRQ_SPI(26) 35#define EXYNOS_IRQ_EINT16_31 IRQ_SPI(32)
39#define IRQ_EINT11 IRQ_SPI(27) 36
40#define IRQ_EINT12 IRQ_SPI(28) 37/* For EXYNOS4 SoCs */
41#define IRQ_EINT13 IRQ_SPI(29) 38
42#define IRQ_EINT14 IRQ_SPI(30) 39#define EXYNOS4_IRQ_EINT0 IRQ_SPI(16)
43#define IRQ_EINT15 IRQ_SPI(31) 40#define EXYNOS4_IRQ_EINT1 IRQ_SPI(17)
44#define IRQ_EINT16_31 IRQ_SPI(32) 41#define EXYNOS4_IRQ_EINT2 IRQ_SPI(18)
45 42#define EXYNOS4_IRQ_EINT3 IRQ_SPI(19)
46#define IRQ_PDMA0 IRQ_SPI(35) 43#define EXYNOS4_IRQ_EINT4 IRQ_SPI(20)
47#define IRQ_PDMA1 IRQ_SPI(36) 44#define EXYNOS4_IRQ_EINT5 IRQ_SPI(21)
48#define IRQ_TIMER0_VIC IRQ_SPI(37) 45#define EXYNOS4_IRQ_EINT6 IRQ_SPI(22)
49#define IRQ_TIMER1_VIC IRQ_SPI(38) 46#define EXYNOS4_IRQ_EINT7 IRQ_SPI(23)
50#define IRQ_TIMER2_VIC IRQ_SPI(39) 47#define EXYNOS4_IRQ_EINT8 IRQ_SPI(24)
51#define IRQ_TIMER3_VIC IRQ_SPI(40) 48#define EXYNOS4_IRQ_EINT9 IRQ_SPI(25)
52#define IRQ_TIMER4_VIC IRQ_SPI(41) 49#define EXYNOS4_IRQ_EINT10 IRQ_SPI(26)
53#define IRQ_MCT_L0 IRQ_SPI(42) 50#define EXYNOS4_IRQ_EINT11 IRQ_SPI(27)
54#define IRQ_WDT IRQ_SPI(43) 51#define EXYNOS4_IRQ_EINT12 IRQ_SPI(28)
55#define IRQ_RTC_ALARM IRQ_SPI(44) 52#define EXYNOS4_IRQ_EINT13 IRQ_SPI(29)
56#define IRQ_RTC_TIC IRQ_SPI(45) 53#define EXYNOS4_IRQ_EINT14 IRQ_SPI(30)
57#define IRQ_GPIO_XB IRQ_SPI(46) 54#define EXYNOS4_IRQ_EINT15 IRQ_SPI(31)
58#define IRQ_GPIO_XA IRQ_SPI(47) 55
59#define IRQ_MCT_L1 IRQ_SPI(48) 56#define EXYNOS4_IRQ_MDMA0 IRQ_SPI(33)
60 57#define EXYNOS4_IRQ_MDMA1 IRQ_SPI(34)
61#define IRQ_UART0 IRQ_SPI(52) 58#define EXYNOS4_IRQ_PDMA0 IRQ_SPI(35)
62#define IRQ_UART1 IRQ_SPI(53) 59#define EXYNOS4_IRQ_PDMA1 IRQ_SPI(36)
63#define IRQ_UART2 IRQ_SPI(54) 60#define EXYNOS4_IRQ_TIMER0_VIC IRQ_SPI(37)
64#define IRQ_UART3 IRQ_SPI(55) 61#define EXYNOS4_IRQ_TIMER1_VIC IRQ_SPI(38)
65#define IRQ_UART4 IRQ_SPI(56) 62#define EXYNOS4_IRQ_TIMER2_VIC IRQ_SPI(39)
66#define IRQ_MCT_G0 IRQ_SPI(57) 63#define EXYNOS4_IRQ_TIMER3_VIC IRQ_SPI(40)
67#define IRQ_IIC IRQ_SPI(58) 64#define EXYNOS4_IRQ_TIMER4_VIC IRQ_SPI(41)
68#define IRQ_IIC1 IRQ_SPI(59) 65#define EXYNOS4_IRQ_MCT_L0 IRQ_SPI(42)
69#define IRQ_IIC2 IRQ_SPI(60) 66#define EXYNOS4_IRQ_WDT IRQ_SPI(43)
70#define IRQ_IIC3 IRQ_SPI(61) 67#define EXYNOS4_IRQ_RTC_ALARM IRQ_SPI(44)
71#define IRQ_IIC4 IRQ_SPI(62) 68#define EXYNOS4_IRQ_RTC_TIC IRQ_SPI(45)
72#define IRQ_IIC5 IRQ_SPI(63) 69#define EXYNOS4_IRQ_GPIO_XB IRQ_SPI(46)
73#define IRQ_IIC6 IRQ_SPI(64) 70#define EXYNOS4_IRQ_GPIO_XA IRQ_SPI(47)
74#define IRQ_IIC7 IRQ_SPI(65) 71#define EXYNOS4_IRQ_MCT_L1 IRQ_SPI(48)
75#define IRQ_SPI0 IRQ_SPI(66) 72
76#define IRQ_SPI1 IRQ_SPI(67) 73#define EXYNOS4_IRQ_UART0 IRQ_SPI(52)
77#define IRQ_SPI2 IRQ_SPI(68) 74#define EXYNOS4_IRQ_UART1 IRQ_SPI(53)
78 75#define EXYNOS4_IRQ_UART2 IRQ_SPI(54)
79#define IRQ_USB_HOST IRQ_SPI(70) 76#define EXYNOS4_IRQ_UART3 IRQ_SPI(55)
80#define IRQ_USB_HSOTG IRQ_SPI(71) 77#define EXYNOS4_IRQ_UART4 IRQ_SPI(56)
81#define IRQ_MODEM_IF IRQ_SPI(72) 78#define EXYNOS4_IRQ_MCT_G0 IRQ_SPI(57)
82#define IRQ_HSMMC0 IRQ_SPI(73) 79#define EXYNOS4_IRQ_IIC IRQ_SPI(58)
83#define IRQ_HSMMC1 IRQ_SPI(74) 80#define EXYNOS4_IRQ_IIC1 IRQ_SPI(59)
84#define IRQ_HSMMC2 IRQ_SPI(75) 81#define EXYNOS4_IRQ_IIC2 IRQ_SPI(60)
85#define IRQ_HSMMC3 IRQ_SPI(76) 82#define EXYNOS4_IRQ_IIC3 IRQ_SPI(61)
86#define IRQ_DWMCI IRQ_SPI(77) 83#define EXYNOS4_IRQ_IIC4 IRQ_SPI(62)
87 84#define EXYNOS4_IRQ_IIC5 IRQ_SPI(63)
88#define IRQ_MIPI_CSIS0 IRQ_SPI(78) 85#define EXYNOS4_IRQ_IIC6 IRQ_SPI(64)
89#define IRQ_MIPI_CSIS1 IRQ_SPI(80) 86#define EXYNOS4_IRQ_IIC7 IRQ_SPI(65)
90 87#define EXYNOS4_IRQ_SPI0 IRQ_SPI(66)
91#define IRQ_ONENAND_AUDI IRQ_SPI(82) 88#define EXYNOS4_IRQ_SPI1 IRQ_SPI(67)
92#define IRQ_ROTATOR IRQ_SPI(83) 89#define EXYNOS4_IRQ_SPI2 IRQ_SPI(68)
93#define IRQ_FIMC0 IRQ_SPI(84) 90
94#define IRQ_FIMC1 IRQ_SPI(85) 91#define EXYNOS4_IRQ_USB_HOST IRQ_SPI(70)
95#define IRQ_FIMC2 IRQ_SPI(86) 92#define EXYNOS4_IRQ_USB_HSOTG IRQ_SPI(71)
96#define IRQ_FIMC3 IRQ_SPI(87) 93#define EXYNOS4_IRQ_MODEM_IF IRQ_SPI(72)
97#define IRQ_JPEG IRQ_SPI(88) 94#define EXYNOS4_IRQ_HSMMC0 IRQ_SPI(73)
98#define IRQ_2D IRQ_SPI(89) 95#define EXYNOS4_IRQ_HSMMC1 IRQ_SPI(74)
99#define IRQ_PCIE IRQ_SPI(90) 96#define EXYNOS4_IRQ_HSMMC2 IRQ_SPI(75)
100 97#define EXYNOS4_IRQ_HSMMC3 IRQ_SPI(76)
101#define IRQ_MIXER IRQ_SPI(91) 98#define EXYNOS4_IRQ_DWMCI IRQ_SPI(77)
102#define IRQ_HDMI IRQ_SPI(92) 99
103#define IRQ_IIC_HDMIPHY IRQ_SPI(93) 100#define EXYNOS4_IRQ_MIPI_CSIS0 IRQ_SPI(78)
104#define IRQ_MFC IRQ_SPI(94) 101#define EXYNOS4_IRQ_MIPI_CSIS1 IRQ_SPI(80)
105#define IRQ_SDO IRQ_SPI(95) 102
106 103#define EXYNOS4_IRQ_ONENAND_AUDI IRQ_SPI(82)
107#define IRQ_AUDIO_SS IRQ_SPI(96) 104#define EXYNOS4_IRQ_ROTATOR IRQ_SPI(83)
108#define IRQ_I2S0 IRQ_SPI(97) 105#define EXYNOS4_IRQ_FIMC0 IRQ_SPI(84)
109#define IRQ_I2S1 IRQ_SPI(98) 106#define EXYNOS4_IRQ_FIMC1 IRQ_SPI(85)
110#define IRQ_I2S2 IRQ_SPI(99) 107#define EXYNOS4_IRQ_FIMC2 IRQ_SPI(86)
111#define IRQ_AC97 IRQ_SPI(100) 108#define EXYNOS4_IRQ_FIMC3 IRQ_SPI(87)
112 109#define EXYNOS4_IRQ_JPEG IRQ_SPI(88)
113#define IRQ_SPDIF IRQ_SPI(104) 110#define EXYNOS4_IRQ_2D IRQ_SPI(89)
114#define IRQ_ADC0 IRQ_SPI(105) 111#define EXYNOS4_IRQ_PCIE IRQ_SPI(90)
115#define IRQ_PEN0 IRQ_SPI(106) 112
116#define IRQ_ADC1 IRQ_SPI(107) 113#define EXYNOS4_IRQ_MIXER IRQ_SPI(91)
117#define IRQ_PEN1 IRQ_SPI(108) 114#define EXYNOS4_IRQ_HDMI IRQ_SPI(92)
118#define IRQ_KEYPAD IRQ_SPI(109) 115#define EXYNOS4_IRQ_IIC_HDMIPHY IRQ_SPI(93)
119#define IRQ_PMU IRQ_SPI(110) 116#define EXYNOS4_IRQ_MFC IRQ_SPI(94)
120#define IRQ_GPS IRQ_SPI(111) 117#define EXYNOS4_IRQ_SDO IRQ_SPI(95)
121#define IRQ_INTFEEDCTRL_SSS IRQ_SPI(112) 118
122#define IRQ_SLIMBUS IRQ_SPI(113) 119#define EXYNOS4_IRQ_AUDIO_SS IRQ_SPI(96)
123 120#define EXYNOS4_IRQ_I2S0 IRQ_SPI(97)
124#define IRQ_TSI IRQ_SPI(115) 121#define EXYNOS4_IRQ_I2S1 IRQ_SPI(98)
125#define IRQ_SATA IRQ_SPI(116) 122#define EXYNOS4_IRQ_I2S2 IRQ_SPI(99)
126 123#define EXYNOS4_IRQ_AC97 IRQ_SPI(100)
127#define MAX_IRQ_IN_COMBINER 8 124
128#define COMBINER_GROUP(x) ((x) * MAX_IRQ_IN_COMBINER + IRQ_SPI(128)) 125#define EXYNOS4_IRQ_SPDIF IRQ_SPI(104)
129#define COMBINER_IRQ(x, y) (COMBINER_GROUP(x) + y) 126#define EXYNOS4_IRQ_ADC0 IRQ_SPI(105)
130 127#define EXYNOS4_IRQ_PEN0 IRQ_SPI(106)
131#define IRQ_SYSMMU_MDMA0_0 COMBINER_IRQ(4, 0) 128#define EXYNOS4_IRQ_ADC1 IRQ_SPI(107)
132#define IRQ_SYSMMU_SSS_0 COMBINER_IRQ(4, 1) 129#define EXYNOS4_IRQ_PEN1 IRQ_SPI(108)
133#define IRQ_SYSMMU_FIMC0_0 COMBINER_IRQ(4, 2) 130#define EXYNOS4_IRQ_KEYPAD IRQ_SPI(109)
134#define IRQ_SYSMMU_FIMC1_0 COMBINER_IRQ(4, 3) 131#define EXYNOS4_IRQ_PMU IRQ_SPI(110)
135#define IRQ_SYSMMU_FIMC2_0 COMBINER_IRQ(4, 4) 132#define EXYNOS4_IRQ_GPS IRQ_SPI(111)
136#define IRQ_SYSMMU_FIMC3_0 COMBINER_IRQ(4, 5) 133#define EXYNOS4_IRQ_INTFEEDCTRL_SSS IRQ_SPI(112)
137#define IRQ_SYSMMU_JPEG_0 COMBINER_IRQ(4, 6) 134#define EXYNOS4_IRQ_SLIMBUS IRQ_SPI(113)
138#define IRQ_SYSMMU_2D_0 COMBINER_IRQ(4, 7) 135
139 136#define EXYNOS4_IRQ_TSI IRQ_SPI(115)
140#define IRQ_SYSMMU_ROTATOR_0 COMBINER_IRQ(5, 0) 137#define EXYNOS4_IRQ_SATA IRQ_SPI(116)
141#define IRQ_SYSMMU_MDMA1_0 COMBINER_IRQ(5, 1) 138
142#define IRQ_SYSMMU_LCD0_M0_0 COMBINER_IRQ(5, 2) 139#define EXYNOS4_IRQ_SYSMMU_MDMA0_0 COMBINER_IRQ(4, 0)
143#define IRQ_SYSMMU_LCD1_M1_0 COMBINER_IRQ(5, 3) 140#define EXYNOS4_IRQ_SYSMMU_SSS_0 COMBINER_IRQ(4, 1)
144#define IRQ_SYSMMU_TV_M0_0 COMBINER_IRQ(5, 4) 141#define EXYNOS4_IRQ_SYSMMU_FIMC0_0 COMBINER_IRQ(4, 2)
145#define IRQ_SYSMMU_MFC_M0_0 COMBINER_IRQ(5, 5) 142#define EXYNOS4_IRQ_SYSMMU_FIMC1_0 COMBINER_IRQ(4, 3)
146#define IRQ_SYSMMU_MFC_M1_0 COMBINER_IRQ(5, 6) 143#define EXYNOS4_IRQ_SYSMMU_FIMC2_0 COMBINER_IRQ(4, 4)
147#define IRQ_SYSMMU_PCIE_0 COMBINER_IRQ(5, 7) 144#define EXYNOS4_IRQ_SYSMMU_FIMC3_0 COMBINER_IRQ(4, 5)
148 145#define EXYNOS4_IRQ_SYSMMU_JPEG_0 COMBINER_IRQ(4, 6)
149#define IRQ_FIMD0_FIFO COMBINER_IRQ(11, 0) 146#define EXYNOS4_IRQ_SYSMMU_2D_0 COMBINER_IRQ(4, 7)
150#define IRQ_FIMD0_VSYNC COMBINER_IRQ(11, 1) 147
151#define IRQ_FIMD0_SYSTEM COMBINER_IRQ(11, 2) 148#define EXYNOS4_IRQ_SYSMMU_ROTATOR_0 COMBINER_IRQ(5, 0)
152 149#define EXYNOS4_IRQ_SYSMMU_MDMA1_0 COMBINER_IRQ(5, 1)
153#define MAX_COMBINER_NR 16 150#define EXYNOS4_IRQ_SYSMMU_LCD0_M0_0 COMBINER_IRQ(5, 2)
154 151#define EXYNOS4_IRQ_SYSMMU_LCD1_M1_0 COMBINER_IRQ(5, 3)
155#define IRQ_ADC IRQ_ADC0 152#define EXYNOS4_IRQ_SYSMMU_TV_M0_0 COMBINER_IRQ(5, 4)
156#define IRQ_TC IRQ_PEN0 153#define EXYNOS4_IRQ_SYSMMU_MFC_M0_0 COMBINER_IRQ(5, 5)
157 154#define EXYNOS4_IRQ_SYSMMU_MFC_M1_0 COMBINER_IRQ(5, 6)
158#define S5P_IRQ_EINT_BASE COMBINER_IRQ(MAX_COMBINER_NR, 0) 155#define EXYNOS4_IRQ_SYSMMU_PCIE_0 COMBINER_IRQ(5, 7)
159 156
160#define S5P_EINT_BASE1 (S5P_IRQ_EINT_BASE + 0) 157#define EXYNOS4_IRQ_FIMD0_FIFO COMBINER_IRQ(11, 0)
161#define S5P_EINT_BASE2 (S5P_IRQ_EINT_BASE + 16) 158#define EXYNOS4_IRQ_FIMD0_VSYNC COMBINER_IRQ(11, 1)
162 159#define EXYNOS4_IRQ_FIMD0_SYSTEM COMBINER_IRQ(11, 2)
163/* optional GPIO interrupts */ 160
164#define S5P_GPIOINT_BASE (S5P_IRQ_EINT_BASE + 32) 161#define EXYNOS4_MAX_COMBINER_NR 16
165#define IRQ_GPIO1_NR_GROUPS 16 162
166#define IRQ_GPIO2_NR_GROUPS 9 163#define EXYNOS4_IRQ_GPIO1_NR_GROUPS 16
167#define IRQ_GPIO_END (S5P_GPIOINT_BASE + S5P_GPIOINT_COUNT) 164#define EXYNOS4_IRQ_GPIO2_NR_GROUPS 9
168 165
169#define IRQ_TIMER_BASE (IRQ_GPIO_END + 64) 166/*
167 * For Compatibility:
168 * the default is for EXYNOS4, and
169 * for exynos5, should be re-mapped at function
170 */
171
172#define IRQ_TIMER0_VIC EXYNOS4_IRQ_TIMER0_VIC
173#define IRQ_TIMER1_VIC EXYNOS4_IRQ_TIMER1_VIC
174#define IRQ_TIMER2_VIC EXYNOS4_IRQ_TIMER2_VIC
175#define IRQ_TIMER3_VIC EXYNOS4_IRQ_TIMER3_VIC
176#define IRQ_TIMER4_VIC EXYNOS4_IRQ_TIMER4_VIC
177
178#define IRQ_WDT EXYNOS4_IRQ_WDT
179#define IRQ_RTC_ALARM EXYNOS4_IRQ_RTC_ALARM
180#define IRQ_RTC_TIC EXYNOS4_IRQ_RTC_TIC
181#define IRQ_GPIO_XB EXYNOS4_IRQ_GPIO_XB
182#define IRQ_GPIO_XA EXYNOS4_IRQ_GPIO_XA
183
184#define IRQ_IIC EXYNOS4_IRQ_IIC
185#define IRQ_IIC1 EXYNOS4_IRQ_IIC1
186#define IRQ_IIC3 EXYNOS4_IRQ_IIC3
187#define IRQ_IIC5 EXYNOS4_IRQ_IIC5
188#define IRQ_IIC6 EXYNOS4_IRQ_IIC6
189#define IRQ_IIC7 EXYNOS4_IRQ_IIC7
190
191#define IRQ_USB_HOST EXYNOS4_IRQ_USB_HOST
192
193#define IRQ_HSMMC0 EXYNOS4_IRQ_HSMMC0
194#define IRQ_HSMMC1 EXYNOS4_IRQ_HSMMC1
195#define IRQ_HSMMC2 EXYNOS4_IRQ_HSMMC2
196#define IRQ_HSMMC3 EXYNOS4_IRQ_HSMMC3
197
198#define IRQ_MIPI_CSIS0 EXYNOS4_IRQ_MIPI_CSIS0
199
200#define IRQ_ONENAND_AUDI EXYNOS4_IRQ_ONENAND_AUDI
201
202#define IRQ_FIMC0 EXYNOS4_IRQ_FIMC0
203#define IRQ_FIMC1 EXYNOS4_IRQ_FIMC1
204#define IRQ_FIMC2 EXYNOS4_IRQ_FIMC2
205#define IRQ_FIMC3 EXYNOS4_IRQ_FIMC3
206#define IRQ_JPEG EXYNOS4_IRQ_JPEG
207#define IRQ_2D EXYNOS4_IRQ_2D
208
209#define IRQ_MIXER EXYNOS4_IRQ_MIXER
210#define IRQ_HDMI EXYNOS4_IRQ_HDMI
211#define IRQ_IIC_HDMIPHY EXYNOS4_IRQ_IIC_HDMIPHY
212#define IRQ_MFC EXYNOS4_IRQ_MFC
213#define IRQ_SDO EXYNOS4_IRQ_SDO
214
215#define IRQ_ADC EXYNOS4_IRQ_ADC0
216#define IRQ_TC EXYNOS4_IRQ_PEN0
217
218#define IRQ_KEYPAD EXYNOS4_IRQ_KEYPAD
219#define IRQ_PMU EXYNOS4_IRQ_PMU
220
221#define IRQ_SYSMMU_MDMA0_0 EXYNOS4_IRQ_SYSMMU_MDMA0_0
222#define IRQ_SYSMMU_SSS_0 EXYNOS4_IRQ_SYSMMU_SSS_0
223#define IRQ_SYSMMU_FIMC0_0 EXYNOS4_IRQ_SYSMMU_FIMC0_0
224#define IRQ_SYSMMU_FIMC1_0 EXYNOS4_IRQ_SYSMMU_FIMC1_0
225#define IRQ_SYSMMU_FIMC2_0 EXYNOS4_IRQ_SYSMMU_FIMC2_0
226#define IRQ_SYSMMU_FIMC3_0 EXYNOS4_IRQ_SYSMMU_FIMC3_0
227#define IRQ_SYSMMU_JPEG_0 EXYNOS4_IRQ_SYSMMU_JPEG_0
228#define IRQ_SYSMMU_2D_0 EXYNOS4_IRQ_SYSMMU_2D_0
229
230#define IRQ_SYSMMU_ROTATOR_0 EXYNOS4_IRQ_SYSMMU_ROTATOR_0
231#define IRQ_SYSMMU_MDMA1_0 EXYNOS4_IRQ_SYSMMU_MDMA1_0
232#define IRQ_SYSMMU_LCD0_M0_0 EXYNOS4_IRQ_SYSMMU_LCD0_M0_0
233#define IRQ_SYSMMU_LCD1_M1_0 EXYNOS4_IRQ_SYSMMU_LCD1_M1_0
234#define IRQ_SYSMMU_TV_M0_0 EXYNOS4_IRQ_SYSMMU_TV_M0_0
235#define IRQ_SYSMMU_MFC_M0_0 EXYNOS4_IRQ_SYSMMU_MFC_M0_0
236#define IRQ_SYSMMU_MFC_M1_0 EXYNOS4_IRQ_SYSMMU_MFC_M1_0
237#define IRQ_SYSMMU_PCIE_0 EXYNOS4_IRQ_SYSMMU_PCIE_0
238
239#define IRQ_FIMD0_FIFO EXYNOS4_IRQ_FIMD0_FIFO
240#define IRQ_FIMD0_VSYNC EXYNOS4_IRQ_FIMD0_VSYNC
241#define IRQ_FIMD0_SYSTEM EXYNOS4_IRQ_FIMD0_SYSTEM
242
243#define IRQ_GPIO1_NR_GROUPS EXYNOS4_IRQ_GPIO1_NR_GROUPS
244#define IRQ_GPIO2_NR_GROUPS EXYNOS4_IRQ_GPIO2_NR_GROUPS
245
246/* For EXYNOS5 SoCs */
247
248#define EXYNOS5_IRQ_MDMA0 IRQ_SPI(33)
249#define EXYNOS5_IRQ_PDMA0 IRQ_SPI(34)
250#define EXYNOS5_IRQ_PDMA1 IRQ_SPI(35)
251#define EXYNOS5_IRQ_TIMER0_VIC IRQ_SPI(36)
252#define EXYNOS5_IRQ_TIMER1_VIC IRQ_SPI(37)
253#define EXYNOS5_IRQ_TIMER2_VIC IRQ_SPI(38)
254#define EXYNOS5_IRQ_TIMER3_VIC IRQ_SPI(39)
255#define EXYNOS5_IRQ_TIMER4_VIC IRQ_SPI(40)
256#define EXYNOS5_IRQ_RTIC IRQ_SPI(41)
257#define EXYNOS5_IRQ_WDT IRQ_SPI(42)
258#define EXYNOS5_IRQ_RTC_ALARM IRQ_SPI(43)
259#define EXYNOS5_IRQ_RTC_TIC IRQ_SPI(44)
260#define EXYNOS5_IRQ_GPIO_XB IRQ_SPI(45)
261#define EXYNOS5_IRQ_GPIO_XA IRQ_SPI(46)
262#define EXYNOS5_IRQ_GPIO IRQ_SPI(47)
263#define EXYNOS5_IRQ_IEM_IEC IRQ_SPI(48)
264#define EXYNOS5_IRQ_IEM_APC IRQ_SPI(49)
265#define EXYNOS5_IRQ_GPIO_C2C IRQ_SPI(50)
266#define EXYNOS5_IRQ_UART0 IRQ_SPI(51)
267#define EXYNOS5_IRQ_UART1 IRQ_SPI(52)
268#define EXYNOS5_IRQ_UART2 IRQ_SPI(53)
269#define EXYNOS5_IRQ_UART3 IRQ_SPI(54)
270#define EXYNOS5_IRQ_UART4 IRQ_SPI(55)
271#define EXYNOS5_IRQ_IIC IRQ_SPI(56)
272#define EXYNOS5_IRQ_IIC1 IRQ_SPI(57)
273#define EXYNOS5_IRQ_IIC2 IRQ_SPI(58)
274#define EXYNOS5_IRQ_IIC3 IRQ_SPI(59)
275#define EXYNOS5_IRQ_IIC4 IRQ_SPI(60)
276#define EXYNOS5_IRQ_IIC5 IRQ_SPI(61)
277#define EXYNOS5_IRQ_IIC6 IRQ_SPI(62)
278#define EXYNOS5_IRQ_IIC7 IRQ_SPI(63)
279#define EXYNOS5_IRQ_IIC_HDMIPHY IRQ_SPI(64)
280#define EXYNOS5_IRQ_TMU IRQ_SPI(65)
281#define EXYNOS5_IRQ_FIQ_0 IRQ_SPI(66)
282#define EXYNOS5_IRQ_FIQ_1 IRQ_SPI(67)
283#define EXYNOS5_IRQ_SPI0 IRQ_SPI(68)
284#define EXYNOS5_IRQ_SPI1 IRQ_SPI(69)
285#define EXYNOS5_IRQ_SPI2 IRQ_SPI(70)
286#define EXYNOS5_IRQ_USB_HOST IRQ_SPI(71)
287#define EXYNOS5_IRQ_USB3_DRD IRQ_SPI(72)
288#define EXYNOS5_IRQ_MIPI_HSI IRQ_SPI(73)
289#define EXYNOS5_IRQ_USB_HSOTG IRQ_SPI(74)
290#define EXYNOS5_IRQ_HSMMC0 IRQ_SPI(75)
291#define EXYNOS5_IRQ_HSMMC1 IRQ_SPI(76)
292#define EXYNOS5_IRQ_HSMMC2 IRQ_SPI(77)
293#define EXYNOS5_IRQ_HSMMC3 IRQ_SPI(78)
294#define EXYNOS5_IRQ_MIPICSI0 IRQ_SPI(79)
295#define EXYNOS5_IRQ_MIPICSI1 IRQ_SPI(80)
296#define EXYNOS5_IRQ_EFNFCON_DMA_ABORT IRQ_SPI(81)
297#define EXYNOS5_IRQ_MIPIDSI0 IRQ_SPI(82)
298#define EXYNOS5_IRQ_ROTATOR IRQ_SPI(84)
299#define EXYNOS5_IRQ_GSC0 IRQ_SPI(85)
300#define EXYNOS5_IRQ_GSC1 IRQ_SPI(86)
301#define EXYNOS5_IRQ_GSC2 IRQ_SPI(87)
302#define EXYNOS5_IRQ_GSC3 IRQ_SPI(88)
303#define EXYNOS5_IRQ_JPEG IRQ_SPI(89)
304#define EXYNOS5_IRQ_EFNFCON_DMA IRQ_SPI(90)
305#define EXYNOS5_IRQ_2D IRQ_SPI(91)
306#define EXYNOS5_IRQ_SFMC0 IRQ_SPI(92)
307#define EXYNOS5_IRQ_SFMC1 IRQ_SPI(93)
308#define EXYNOS5_IRQ_MIXER IRQ_SPI(94)
309#define EXYNOS5_IRQ_HDMI IRQ_SPI(95)
310#define EXYNOS5_IRQ_MFC IRQ_SPI(96)
311#define EXYNOS5_IRQ_AUDIO_SS IRQ_SPI(97)
312#define EXYNOS5_IRQ_I2S0 IRQ_SPI(98)
313#define EXYNOS5_IRQ_I2S1 IRQ_SPI(99)
314#define EXYNOS5_IRQ_I2S2 IRQ_SPI(100)
315#define EXYNOS5_IRQ_AC97 IRQ_SPI(101)
316#define EXYNOS5_IRQ_PCM0 IRQ_SPI(102)
317#define EXYNOS5_IRQ_PCM1 IRQ_SPI(103)
318#define EXYNOS5_IRQ_PCM2 IRQ_SPI(104)
319#define EXYNOS5_IRQ_SPDIF IRQ_SPI(105)
320#define EXYNOS5_IRQ_ADC0 IRQ_SPI(106)
321
322#define EXYNOS5_IRQ_SATA_PHY IRQ_SPI(108)
323#define EXYNOS5_IRQ_SATA_PMEMREQ IRQ_SPI(109)
324#define EXYNOS5_IRQ_CAM_C IRQ_SPI(110)
325#define EXYNOS5_IRQ_EAGLE_PMU IRQ_SPI(111)
326#define EXYNOS5_IRQ_INTFEEDCTRL_SSS IRQ_SPI(112)
327#define EXYNOS5_IRQ_DP1_INTP1 IRQ_SPI(113)
328#define EXYNOS5_IRQ_CEC IRQ_SPI(114)
329#define EXYNOS5_IRQ_SATA IRQ_SPI(115)
330#define EXYNOS5_IRQ_NFCON IRQ_SPI(116)
331
332#define EXYNOS5_IRQ_MMC44 IRQ_SPI(123)
333#define EXYNOS5_IRQ_MDMA1 IRQ_SPI(124)
334#define EXYNOS5_IRQ_FIMC_LITE0 IRQ_SPI(125)
335#define EXYNOS5_IRQ_FIMC_LITE1 IRQ_SPI(126)
336#define EXYNOS5_IRQ_RP_TIMER IRQ_SPI(127)
337
338#define EXYNOS5_IRQ_PMU COMBINER_IRQ(1, 2)
339#define EXYNOS5_IRQ_PMU_CPU1 COMBINER_IRQ(1, 6)
340
341#define EXYNOS5_IRQ_SYSMMU_GSC0_0 COMBINER_IRQ(2, 0)
342#define EXYNOS5_IRQ_SYSMMU_GSC0_1 COMBINER_IRQ(2, 1)
343#define EXYNOS5_IRQ_SYSMMU_GSC1_0 COMBINER_IRQ(2, 2)
344#define EXYNOS5_IRQ_SYSMMU_GSC1_1 COMBINER_IRQ(2, 3)
345#define EXYNOS5_IRQ_SYSMMU_GSC2_0 COMBINER_IRQ(2, 4)
346#define EXYNOS5_IRQ_SYSMMU_GSC2_1 COMBINER_IRQ(2, 5)
347#define EXYNOS5_IRQ_SYSMMU_GSC3_0 COMBINER_IRQ(2, 6)
348#define EXYNOS5_IRQ_SYSMMU_GSC3_1 COMBINER_IRQ(2, 7)
349
350#define EXYNOS5_IRQ_SYSMMU_FIMD1_0 COMBINER_IRQ(3, 2)
351#define EXYNOS5_IRQ_SYSMMU_FIMD1_1 COMBINER_IRQ(3, 3)
352#define EXYNOS5_IRQ_SYSMMU_LITE0_0 COMBINER_IRQ(3, 4)
353#define EXYNOS5_IRQ_SYSMMU_LITE0_1 COMBINER_IRQ(3, 5)
354#define EXYNOS5_IRQ_SYSMMU_SCALERPISP_0 COMBINER_IRQ(3, 6)
355#define EXYNOS5_IRQ_SYSMMU_SCALERPISP_1 COMBINER_IRQ(3, 7)
356
357#define EXYNOS5_IRQ_SYSMMU_ROTATOR_0 COMBINER_IRQ(4, 0)
358#define EXYNOS5_IRQ_SYSMMU_ROTATOR_1 COMBINER_IRQ(4, 1)
359#define EXYNOS5_IRQ_SYSMMU_JPEG_0 COMBINER_IRQ(4, 2)
360#define EXYNOS5_IRQ_SYSMMU_JPEG_1 COMBINER_IRQ(4, 3)
361
362#define EXYNOS5_IRQ_SYSMMU_FD_0 COMBINER_IRQ(5, 0)
363#define EXYNOS5_IRQ_SYSMMU_FD_1 COMBINER_IRQ(5, 1)
364#define EXYNOS5_IRQ_SYSMMU_SCALERCISP_0 COMBINER_IRQ(5, 2)
365#define EXYNOS5_IRQ_SYSMMU_SCALERCISP_1 COMBINER_IRQ(5, 3)
366#define EXYNOS5_IRQ_SYSMMU_MCUISP_0 COMBINER_IRQ(5, 4)
367#define EXYNOS5_IRQ_SYSMMU_MCUISP_1 COMBINER_IRQ(5, 5)
368#define EXYNOS5_IRQ_SYSMMU_3DNR_0 COMBINER_IRQ(5, 6)
369#define EXYNOS5_IRQ_SYSMMU_3DNR_1 COMBINER_IRQ(5, 7)
370
371#define EXYNOS5_IRQ_SYSMMU_ARM_0 COMBINER_IRQ(6, 0)
372#define EXYNOS5_IRQ_SYSMMU_ARM_1 COMBINER_IRQ(6, 1)
373#define EXYNOS5_IRQ_SYSMMU_MFC_L_0 COMBINER_IRQ(6, 2)
374#define EXYNOS5_IRQ_SYSMMU_MFC_L_1 COMBINER_IRQ(6, 3)
375#define EXYNOS5_IRQ_SYSMMU_RTIC_0 COMBINER_IRQ(6, 4)
376#define EXYNOS5_IRQ_SYSMMU_RTIC_1 COMBINER_IRQ(6, 5)
377#define EXYNOS5_IRQ_SYSMMU_SSS_0 COMBINER_IRQ(6, 6)
378#define EXYNOS5_IRQ_SYSMMU_SSS_1 COMBINER_IRQ(6, 7)
379
380#define EXYNOS5_IRQ_SYSMMU_MDMA0_0 COMBINER_IRQ(7, 0)
381#define EXYNOS5_IRQ_SYSMMU_MDMA0_1 COMBINER_IRQ(7, 1)
382#define EXYNOS5_IRQ_SYSMMU_MDMA1_0 COMBINER_IRQ(7, 2)
383#define EXYNOS5_IRQ_SYSMMU_MDMA1_1 COMBINER_IRQ(7, 3)
384#define EXYNOS5_IRQ_SYSMMU_TV_0 COMBINER_IRQ(7, 4)
385#define EXYNOS5_IRQ_SYSMMU_TV_1 COMBINER_IRQ(7, 5)
386#define EXYNOS5_IRQ_SYSMMU_GPSX_0 COMBINER_IRQ(7, 6)
387#define EXYNOS5_IRQ_SYSMMU_GPSX_1 COMBINER_IRQ(7, 7)
388
389#define EXYNOS5_IRQ_SYSMMU_MFC_R_0 COMBINER_IRQ(8, 5)
390#define EXYNOS5_IRQ_SYSMMU_MFC_R_1 COMBINER_IRQ(8, 6)
391
392#define EXYNOS5_IRQ_SYSMMU_DIS1_0 COMBINER_IRQ(9, 4)
393#define EXYNOS5_IRQ_SYSMMU_DIS1_1 COMBINER_IRQ(9, 5)
394
395#define EXYNOS5_IRQ_DP COMBINER_IRQ(10, 3)
396#define EXYNOS5_IRQ_SYSMMU_DIS0_0 COMBINER_IRQ(10, 4)
397#define EXYNOS5_IRQ_SYSMMU_DIS0_1 COMBINER_IRQ(10, 5)
398#define EXYNOS5_IRQ_SYSMMU_ISP_0 COMBINER_IRQ(10, 6)
399#define EXYNOS5_IRQ_SYSMMU_ISP_1 COMBINER_IRQ(10, 7)
400
401#define EXYNOS5_IRQ_SYSMMU_ODC_0 COMBINER_IRQ(11, 0)
402#define EXYNOS5_IRQ_SYSMMU_ODC_1 COMBINER_IRQ(11, 1)
403#define EXYNOS5_IRQ_SYSMMU_DRC_0 COMBINER_IRQ(11, 6)
404#define EXYNOS5_IRQ_SYSMMU_DRC_1 COMBINER_IRQ(11, 7)
405
406#define EXYNOS5_IRQ_FIMD1_FIFO COMBINER_IRQ(18, 4)
407#define EXYNOS5_IRQ_FIMD1_VSYNC COMBINER_IRQ(18, 5)
408#define EXYNOS5_IRQ_FIMD1_SYSTEM COMBINER_IRQ(18, 6)
409
410#define EXYNOS5_IRQ_EINT0 COMBINER_IRQ(23, 0)
411#define EXYNOS5_IRQ_MCT_L0 COMBINER_IRQ(23, 1)
412#define EXYNOS5_IRQ_MCT_L1 COMBINER_IRQ(23, 2)
413#define EXYNOS5_IRQ_MCT_G0 COMBINER_IRQ(23, 3)
414#define EXYNOS5_IRQ_MCT_G1 COMBINER_IRQ(23, 4)
415#define EXYNOS5_IRQ_MCT_G2 COMBINER_IRQ(23, 5)
416#define EXYNOS5_IRQ_MCT_G3 COMBINER_IRQ(23, 6)
417
418#define EXYNOS5_IRQ_EINT1 COMBINER_IRQ(24, 0)
419#define EXYNOS5_IRQ_SYSMMU_LITE1_0 COMBINER_IRQ(24, 1)
420#define EXYNOS5_IRQ_SYSMMU_LITE1_1 COMBINER_IRQ(24, 2)
421#define EXYNOS5_IRQ_SYSMMU_2D_0 COMBINER_IRQ(24, 5)
422#define EXYNOS5_IRQ_SYSMMU_2D_1 COMBINER_IRQ(24, 6)
423
424#define EXYNOS5_IRQ_EINT2 COMBINER_IRQ(25, 0)
425#define EXYNOS5_IRQ_EINT3 COMBINER_IRQ(25, 1)
426
427#define EXYNOS5_IRQ_EINT4 COMBINER_IRQ(26, 0)
428#define EXYNOS5_IRQ_EINT5 COMBINER_IRQ(26, 1)
429
430#define EXYNOS5_IRQ_EINT6 COMBINER_IRQ(27, 0)
431#define EXYNOS5_IRQ_EINT7 COMBINER_IRQ(27, 1)
432
433#define EXYNOS5_IRQ_EINT8 COMBINER_IRQ(28, 0)
434#define EXYNOS5_IRQ_EINT9 COMBINER_IRQ(28, 1)
435
436#define EXYNOS5_IRQ_EINT10 COMBINER_IRQ(29, 0)
437#define EXYNOS5_IRQ_EINT11 COMBINER_IRQ(29, 1)
438
439#define EXYNOS5_IRQ_EINT12 COMBINER_IRQ(30, 0)
440#define EXYNOS5_IRQ_EINT13 COMBINER_IRQ(30, 1)
441
442#define EXYNOS5_IRQ_EINT14 COMBINER_IRQ(31, 0)
443#define EXYNOS5_IRQ_EINT15 COMBINER_IRQ(31, 1)
444
445#define EXYNOS5_MAX_COMBINER_NR 32
446
447#define EXYNOS5_IRQ_GPIO1_NR_GROUPS 13
448#define EXYNOS5_IRQ_GPIO2_NR_GROUPS 9
449#define EXYNOS5_IRQ_GPIO3_NR_GROUPS 5
450#define EXYNOS5_IRQ_GPIO4_NR_GROUPS 1
451
452#define MAX_COMBINER_NR (EXYNOS4_MAX_COMBINER_NR > EXYNOS5_MAX_COMBINER_NR ? \
453 EXYNOS4_MAX_COMBINER_NR : EXYNOS5_MAX_COMBINER_NR)
454
455#define S5P_EINT_BASE1 COMBINER_IRQ(MAX_COMBINER_NR, 0)
456#define S5P_EINT_BASE2 (S5P_EINT_BASE1 + 16)
457#define S5P_GPIOINT_BASE (S5P_EINT_BASE1 + 32)
458#define IRQ_GPIO_END (S5P_GPIOINT_BASE + S5P_GPIOINT_COUNT)
459#define IRQ_TIMER_BASE (IRQ_GPIO_END + 64)
170 460
171/* Set the default NR_IRQS */ 461/* Set the default NR_IRQS */
172#define NR_IRQS (IRQ_TIMER_BASE + IRQ_TIMER_COUNT) 462
463#define NR_IRQS (IRQ_TIMER_BASE + IRQ_TIMER_COUNT)
173 464
174#endif /* __ASM_ARCH_IRQS_H */ 465#endif /* __ASM_ARCH_IRQS_H */
diff --git a/arch/arm/mach-exynos/include/mach/map.h b/arch/arm/mach-exynos/include/mach/map.h
index c754a22a2bb..024d38ff171 100644
--- a/arch/arm/mach-exynos/include/mach/map.h
+++ b/arch/arm/mach-exynos/include/mach/map.h
@@ -25,12 +25,17 @@
25 25
26#define EXYNOS4_PA_SYSRAM0 0x02025000 26#define EXYNOS4_PA_SYSRAM0 0x02025000
27#define EXYNOS4_PA_SYSRAM1 0x02020000 27#define EXYNOS4_PA_SYSRAM1 0x02020000
28#define EXYNOS5_PA_SYSRAM 0x02020000
28 29
29#define EXYNOS4_PA_FIMC0 0x11800000 30#define EXYNOS4_PA_FIMC0 0x11800000
30#define EXYNOS4_PA_FIMC1 0x11810000 31#define EXYNOS4_PA_FIMC1 0x11810000
31#define EXYNOS4_PA_FIMC2 0x11820000 32#define EXYNOS4_PA_FIMC2 0x11820000
32#define EXYNOS4_PA_FIMC3 0x11830000 33#define EXYNOS4_PA_FIMC3 0x11830000
33 34
35#define EXYNOS4_PA_JPEG 0x11840000
36
37#define EXYNOS4_PA_G2D 0x12800000
38
34#define EXYNOS4_PA_I2S0 0x03830000 39#define EXYNOS4_PA_I2S0 0x03830000
35#define EXYNOS4_PA_I2S1 0xE3100000 40#define EXYNOS4_PA_I2S1 0xE3100000
36#define EXYNOS4_PA_I2S2 0xE2A00000 41#define EXYNOS4_PA_I2S2 0xE2A00000
@@ -44,30 +49,44 @@
44#define EXYNOS4_PA_ONENAND 0x0C000000 49#define EXYNOS4_PA_ONENAND 0x0C000000
45#define EXYNOS4_PA_ONENAND_DMA 0x0C600000 50#define EXYNOS4_PA_ONENAND_DMA 0x0C600000
46 51
47#define EXYNOS4_PA_CHIPID 0x10000000 52#define EXYNOS_PA_CHIPID 0x10000000
48 53
49#define EXYNOS4_PA_SYSCON 0x10010000 54#define EXYNOS4_PA_SYSCON 0x10010000
55#define EXYNOS5_PA_SYSCON 0x10050100
56
50#define EXYNOS4_PA_PMU 0x10020000 57#define EXYNOS4_PA_PMU 0x10020000
58#define EXYNOS5_PA_PMU 0x10040000
59
51#define EXYNOS4_PA_CMU 0x10030000 60#define EXYNOS4_PA_CMU 0x10030000
61#define EXYNOS5_PA_CMU 0x10010000
52 62
53#define EXYNOS4_PA_SYSTIMER 0x10050000 63#define EXYNOS4_PA_SYSTIMER 0x10050000
64#define EXYNOS5_PA_SYSTIMER 0x101C0000
65
54#define EXYNOS4_PA_WATCHDOG 0x10060000 66#define EXYNOS4_PA_WATCHDOG 0x10060000
67#define EXYNOS5_PA_WATCHDOG 0x101D0000
68
55#define EXYNOS4_PA_RTC 0x10070000 69#define EXYNOS4_PA_RTC 0x10070000
56 70
57#define EXYNOS4_PA_KEYPAD 0x100A0000 71#define EXYNOS4_PA_KEYPAD 0x100A0000
58 72
59#define EXYNOS4_PA_DMC0 0x10400000 73#define EXYNOS4_PA_DMC0 0x10400000
74#define EXYNOS4_PA_DMC1 0x10410000
60 75
61#define EXYNOS4_PA_COMBINER 0x10440000 76#define EXYNOS4_PA_COMBINER 0x10440000
77#define EXYNOS5_PA_COMBINER 0x10440000
62 78
63#define EXYNOS4_PA_GIC_CPU 0x10480000 79#define EXYNOS4_PA_GIC_CPU 0x10480000
64#define EXYNOS4_PA_GIC_DIST 0x10490000 80#define EXYNOS4_PA_GIC_DIST 0x10490000
81#define EXYNOS5_PA_GIC_CPU 0x10480000
82#define EXYNOS5_PA_GIC_DIST 0x10490000
65 83
66#define EXYNOS4_PA_COREPERI 0x10500000 84#define EXYNOS4_PA_COREPERI 0x10500000
67#define EXYNOS4_PA_TWD 0x10500600 85#define EXYNOS4_PA_TWD 0x10500600
68#define EXYNOS4_PA_L2CC 0x10502000 86#define EXYNOS4_PA_L2CC 0x10502000
69 87
70#define EXYNOS4_PA_MDMA 0x10810000 88#define EXYNOS4_PA_MDMA0 0x10810000
89#define EXYNOS4_PA_MDMA1 0x12840000
71#define EXYNOS4_PA_PDMA0 0x12680000 90#define EXYNOS4_PA_PDMA0 0x12680000
72#define EXYNOS4_PA_PDMA1 0x12690000 91#define EXYNOS4_PA_PDMA1 0x12690000
73 92
@@ -91,10 +110,13 @@
91#define EXYNOS4_PA_SPI1 0x13930000 110#define EXYNOS4_PA_SPI1 0x13930000
92#define EXYNOS4_PA_SPI2 0x13940000 111#define EXYNOS4_PA_SPI2 0x13940000
93 112
94
95#define EXYNOS4_PA_GPIO1 0x11400000 113#define EXYNOS4_PA_GPIO1 0x11400000
96#define EXYNOS4_PA_GPIO2 0x11000000 114#define EXYNOS4_PA_GPIO2 0x11000000
97#define EXYNOS4_PA_GPIO3 0x03860000 115#define EXYNOS4_PA_GPIO3 0x03860000
116#define EXYNOS5_PA_GPIO1 0x11400000
117#define EXYNOS5_PA_GPIO2 0x13400000
118#define EXYNOS5_PA_GPIO3 0x10D10000
119#define EXYNOS5_PA_GPIO4 0x03860000
98 120
99#define EXYNOS4_PA_MIPI_CSIS0 0x11880000 121#define EXYNOS4_PA_MIPI_CSIS0 0x11880000
100#define EXYNOS4_PA_MIPI_CSIS1 0x11890000 122#define EXYNOS4_PA_MIPI_CSIS1 0x11890000
@@ -109,6 +131,7 @@
109#define EXYNOS4_PA_SATAPHY_CTRL 0x126B0000 131#define EXYNOS4_PA_SATAPHY_CTRL 0x126B0000
110 132
111#define EXYNOS4_PA_SROMC 0x12570000 133#define EXYNOS4_PA_SROMC 0x12570000
134#define EXYNOS5_PA_SROMC 0x12250000
112 135
113#define EXYNOS4_PA_EHCI 0x12580000 136#define EXYNOS4_PA_EHCI 0x12580000
114#define EXYNOS4_PA_OHCI 0x12590000 137#define EXYNOS4_PA_OHCI 0x12590000
@@ -116,6 +139,7 @@
116#define EXYNOS4_PA_MFC 0x13400000 139#define EXYNOS4_PA_MFC 0x13400000
117 140
118#define EXYNOS4_PA_UART 0x13800000 141#define EXYNOS4_PA_UART 0x13800000
142#define EXYNOS5_PA_UART 0x12C00000
119 143
120#define EXYNOS4_PA_VP 0x12C00000 144#define EXYNOS4_PA_VP 0x12C00000
121#define EXYNOS4_PA_MIXER 0x12C10000 145#define EXYNOS4_PA_MIXER 0x12C10000
@@ -124,6 +148,7 @@
124#define EXYNOS4_PA_IIC_HDMIPHY 0x138E0000 148#define EXYNOS4_PA_IIC_HDMIPHY 0x138E0000
125 149
126#define EXYNOS4_PA_IIC(x) (0x13860000 + ((x) * 0x10000)) 150#define EXYNOS4_PA_IIC(x) (0x13860000 + ((x) * 0x10000))
151#define EXYNOS5_PA_IIC(x) (0x12C60000 + ((x) * 0x10000))
127 152
128#define EXYNOS4_PA_ADC 0x13910000 153#define EXYNOS4_PA_ADC 0x13910000
129#define EXYNOS4_PA_ADC1 0x13911000 154#define EXYNOS4_PA_ADC1 0x13911000
@@ -133,8 +158,10 @@
133#define EXYNOS4_PA_SPDIF 0x139B0000 158#define EXYNOS4_PA_SPDIF 0x139B0000
134 159
135#define EXYNOS4_PA_TIMER 0x139D0000 160#define EXYNOS4_PA_TIMER 0x139D0000
161#define EXYNOS5_PA_TIMER 0x12DD0000
136 162
137#define EXYNOS4_PA_SDRAM 0x40000000 163#define EXYNOS4_PA_SDRAM 0x40000000
164#define EXYNOS5_PA_SDRAM 0x40000000
138 165
139/* Compatibiltiy Defines */ 166/* Compatibiltiy Defines */
140 167
@@ -152,7 +179,6 @@
152#define S3C_PA_IIC7 EXYNOS4_PA_IIC(7) 179#define S3C_PA_IIC7 EXYNOS4_PA_IIC(7)
153#define S3C_PA_RTC EXYNOS4_PA_RTC 180#define S3C_PA_RTC EXYNOS4_PA_RTC
154#define S3C_PA_WDT EXYNOS4_PA_WATCHDOG 181#define S3C_PA_WDT EXYNOS4_PA_WATCHDOG
155#define S3C_PA_UART EXYNOS4_PA_UART
156#define S3C_PA_SPI0 EXYNOS4_PA_SPI0 182#define S3C_PA_SPI0 EXYNOS4_PA_SPI0
157#define S3C_PA_SPI1 EXYNOS4_PA_SPI1 183#define S3C_PA_SPI1 EXYNOS4_PA_SPI1
158#define S3C_PA_SPI2 EXYNOS4_PA_SPI2 184#define S3C_PA_SPI2 EXYNOS4_PA_SPI2
@@ -162,6 +188,8 @@
162#define S5P_PA_FIMC1 EXYNOS4_PA_FIMC1 188#define S5P_PA_FIMC1 EXYNOS4_PA_FIMC1
163#define S5P_PA_FIMC2 EXYNOS4_PA_FIMC2 189#define S5P_PA_FIMC2 EXYNOS4_PA_FIMC2
164#define S5P_PA_FIMC3 EXYNOS4_PA_FIMC3 190#define S5P_PA_FIMC3 EXYNOS4_PA_FIMC3
191#define S5P_PA_JPEG EXYNOS4_PA_JPEG
192#define S5P_PA_G2D EXYNOS4_PA_G2D
165#define S5P_PA_FIMD0 EXYNOS4_PA_FIMD0 193#define S5P_PA_FIMD0 EXYNOS4_PA_FIMD0
166#define S5P_PA_HDMI EXYNOS4_PA_HDMI 194#define S5P_PA_HDMI EXYNOS4_PA_HDMI
167#define S5P_PA_IIC_HDMIPHY EXYNOS4_PA_IIC_HDMIPHY 195#define S5P_PA_IIC_HDMIPHY EXYNOS4_PA_IIC_HDMIPHY
@@ -181,15 +209,18 @@
181 209
182/* Compatibility UART */ 210/* Compatibility UART */
183 211
184#define S3C_VA_UARTx(x) (S3C_VA_UART + ((x) * S3C_UART_OFFSET)) 212#define EXYNOS4_PA_UART0 0x13800000
213#define EXYNOS4_PA_UART1 0x13810000
214#define EXYNOS4_PA_UART2 0x13820000
215#define EXYNOS4_PA_UART3 0x13830000
216#define EXYNOS4_SZ_UART SZ_256
185 217
186#define S5P_PA_UART(x) (EXYNOS4_PA_UART + ((x) * S3C_UART_OFFSET)) 218#define EXYNOS5_PA_UART0 0x12C00000
187#define S5P_PA_UART0 S5P_PA_UART(0) 219#define EXYNOS5_PA_UART1 0x12C10000
188#define S5P_PA_UART1 S5P_PA_UART(1) 220#define EXYNOS5_PA_UART2 0x12C20000
189#define S5P_PA_UART2 S5P_PA_UART(2) 221#define EXYNOS5_PA_UART3 0x12C30000
190#define S5P_PA_UART3 S5P_PA_UART(3) 222#define EXYNOS5_SZ_UART SZ_256
191#define S5P_PA_UART4 S5P_PA_UART(4)
192 223
193#define S5P_SZ_UART SZ_256 224#define S3C_VA_UARTx(x) (S3C_VA_UART + ((x) * S3C_UART_OFFSET))
194 225
195#endif /* __ASM_ARCH_MAP_H */ 226#endif /* __ASM_ARCH_MAP_H */
diff --git a/arch/arm/mach-exynos/include/mach/pmu.h b/arch/arm/mach-exynos/include/mach/pmu.h
index 632dd563013..e76b7faba66 100644
--- a/arch/arm/mach-exynos/include/mach/pmu.h
+++ b/arch/arm/mach-exynos/include/mach/pmu.h
@@ -22,11 +22,13 @@ enum sys_powerdown {
22 NUM_SYS_POWERDOWN, 22 NUM_SYS_POWERDOWN,
23}; 23};
24 24
25extern unsigned long l2x0_regs_phys;
25struct exynos4_pmu_conf { 26struct exynos4_pmu_conf {
26 void __iomem *reg; 27 void __iomem *reg;
27 unsigned int val[NUM_SYS_POWERDOWN]; 28 unsigned int val[NUM_SYS_POWERDOWN];
28}; 29};
29 30
30extern void exynos4_sys_powerdown_conf(enum sys_powerdown mode); 31extern void exynos4_sys_powerdown_conf(enum sys_powerdown mode);
32extern void s3c_cpu_resume(void);
31 33
32#endif /* __ASM_ARCH_PMU_H */ 34#endif /* __ASM_ARCH_PMU_H */
diff --git a/arch/arm/mach-exynos/include/mach/regs-clock.h b/arch/arm/mach-exynos/include/mach/regs-clock.h
index 6c37ebe9482..e141c1fd68d 100644
--- a/arch/arm/mach-exynos/include/mach/regs-clock.h
+++ b/arch/arm/mach-exynos/include/mach/regs-clock.h
@@ -16,195 +16,309 @@
16#include <plat/cpu.h> 16#include <plat/cpu.h>
17#include <mach/map.h> 17#include <mach/map.h>
18 18
19#define S5P_CLKREG(x) (S5P_VA_CMU + (x)) 19#define EXYNOS_CLKREG(x) (S5P_VA_CMU + (x))
20 20
21#define S5P_CLKDIV_LEFTBUS S5P_CLKREG(0x04500) 21#define EXYNOS4_CLKDIV_LEFTBUS EXYNOS_CLKREG(0x04500)
22#define S5P_CLKDIV_STAT_LEFTBUS S5P_CLKREG(0x04600) 22#define EXYNOS4_CLKDIV_STAT_LEFTBUS EXYNOS_CLKREG(0x04600)
23#define S5P_CLKGATE_IP_LEFTBUS S5P_CLKREG(0x04800) 23#define EXYNOS4_CLKGATE_IP_LEFTBUS EXYNOS_CLKREG(0x04800)
24 24
25#define S5P_CLKDIV_RIGHTBUS S5P_CLKREG(0x08500) 25#define EXYNOS4_CLKDIV_RIGHTBUS EXYNOS_CLKREG(0x08500)
26#define S5P_CLKDIV_STAT_RIGHTBUS S5P_CLKREG(0x08600) 26#define EXYNOS4_CLKDIV_STAT_RIGHTBUS EXYNOS_CLKREG(0x08600)
27#define S5P_CLKGATE_IP_RIGHTBUS S5P_CLKREG(0x08800) 27#define EXYNOS4_CLKGATE_IP_RIGHTBUS EXYNOS_CLKREG(0x08800)
28 28
29#define S5P_EPLL_LOCK S5P_CLKREG(0x0C010) 29#define EXYNOS4_EPLL_LOCK EXYNOS_CLKREG(0x0C010)
30#define S5P_VPLL_LOCK S5P_CLKREG(0x0C020) 30#define EXYNOS4_VPLL_LOCK EXYNOS_CLKREG(0x0C020)
31 31
32#define S5P_EPLL_CON0 S5P_CLKREG(0x0C110) 32#define EXYNOS4_EPLL_CON0 EXYNOS_CLKREG(0x0C110)
33#define S5P_EPLL_CON1 S5P_CLKREG(0x0C114) 33#define EXYNOS4_EPLL_CON1 EXYNOS_CLKREG(0x0C114)
34#define S5P_VPLL_CON0 S5P_CLKREG(0x0C120) 34#define EXYNOS4_VPLL_CON0 EXYNOS_CLKREG(0x0C120)
35#define S5P_VPLL_CON1 S5P_CLKREG(0x0C124) 35#define EXYNOS4_VPLL_CON1 EXYNOS_CLKREG(0x0C124)
36 36
37#define S5P_CLKSRC_TOP0 S5P_CLKREG(0x0C210) 37#define EXYNOS4_CLKSRC_TOP0 EXYNOS_CLKREG(0x0C210)
38#define S5P_CLKSRC_TOP1 S5P_CLKREG(0x0C214) 38#define EXYNOS4_CLKSRC_TOP1 EXYNOS_CLKREG(0x0C214)
39#define S5P_CLKSRC_CAM S5P_CLKREG(0x0C220) 39#define EXYNOS4_CLKSRC_CAM EXYNOS_CLKREG(0x0C220)
40#define S5P_CLKSRC_TV S5P_CLKREG(0x0C224) 40#define EXYNOS4_CLKSRC_TV EXYNOS_CLKREG(0x0C224)
41#define S5P_CLKSRC_MFC S5P_CLKREG(0x0C228) 41#define EXYNOS4_CLKSRC_MFC EXYNOS_CLKREG(0x0C228)
42#define S5P_CLKSRC_G3D S5P_CLKREG(0x0C22C) 42#define EXYNOS4_CLKSRC_G3D EXYNOS_CLKREG(0x0C22C)
43#define S5P_CLKSRC_IMAGE S5P_CLKREG(0x0C230) 43#define EXYNOS4_CLKSRC_IMAGE EXYNOS_CLKREG(0x0C230)
44#define S5P_CLKSRC_LCD0 S5P_CLKREG(0x0C234) 44#define EXYNOS4_CLKSRC_LCD0 EXYNOS_CLKREG(0x0C234)
45#define S5P_CLKSRC_MAUDIO S5P_CLKREG(0x0C23C) 45#define EXYNOS4_CLKSRC_MAUDIO EXYNOS_CLKREG(0x0C23C)
46#define S5P_CLKSRC_FSYS S5P_CLKREG(0x0C240) 46#define EXYNOS4_CLKSRC_FSYS EXYNOS_CLKREG(0x0C240)
47#define S5P_CLKSRC_PERIL0 S5P_CLKREG(0x0C250) 47#define EXYNOS4_CLKSRC_PERIL0 EXYNOS_CLKREG(0x0C250)
48#define S5P_CLKSRC_PERIL1 S5P_CLKREG(0x0C254) 48#define EXYNOS4_CLKSRC_PERIL1 EXYNOS_CLKREG(0x0C254)
49 49
50#define S5P_CLKSRC_MASK_TOP S5P_CLKREG(0x0C310) 50#define EXYNOS4_CLKSRC_MASK_TOP EXYNOS_CLKREG(0x0C310)
51#define S5P_CLKSRC_MASK_CAM S5P_CLKREG(0x0C320) 51#define EXYNOS4_CLKSRC_MASK_CAM EXYNOS_CLKREG(0x0C320)
52#define S5P_CLKSRC_MASK_TV S5P_CLKREG(0x0C324) 52#define EXYNOS4_CLKSRC_MASK_TV EXYNOS_CLKREG(0x0C324)
53#define S5P_CLKSRC_MASK_LCD0 S5P_CLKREG(0x0C334) 53#define EXYNOS4_CLKSRC_MASK_LCD0 EXYNOS_CLKREG(0x0C334)
54#define S5P_CLKSRC_MASK_MAUDIO S5P_CLKREG(0x0C33C) 54#define EXYNOS4_CLKSRC_MASK_MAUDIO EXYNOS_CLKREG(0x0C33C)
55#define S5P_CLKSRC_MASK_FSYS S5P_CLKREG(0x0C340) 55#define EXYNOS4_CLKSRC_MASK_FSYS EXYNOS_CLKREG(0x0C340)
56#define S5P_CLKSRC_MASK_PERIL0 S5P_CLKREG(0x0C350) 56#define EXYNOS4_CLKSRC_MASK_PERIL0 EXYNOS_CLKREG(0x0C350)
57#define S5P_CLKSRC_MASK_PERIL1 S5P_CLKREG(0x0C354) 57#define EXYNOS4_CLKSRC_MASK_PERIL1 EXYNOS_CLKREG(0x0C354)
58 58
59#define S5P_CLKDIV_TOP S5P_CLKREG(0x0C510) 59#define EXYNOS4_CLKDIV_TOP EXYNOS_CLKREG(0x0C510)
60#define S5P_CLKDIV_CAM S5P_CLKREG(0x0C520) 60#define EXYNOS4_CLKDIV_CAM EXYNOS_CLKREG(0x0C520)
61#define S5P_CLKDIV_TV S5P_CLKREG(0x0C524) 61#define EXYNOS4_CLKDIV_TV EXYNOS_CLKREG(0x0C524)
62#define S5P_CLKDIV_MFC S5P_CLKREG(0x0C528) 62#define EXYNOS4_CLKDIV_MFC EXYNOS_CLKREG(0x0C528)
63#define S5P_CLKDIV_G3D S5P_CLKREG(0x0C52C) 63#define EXYNOS4_CLKDIV_G3D EXYNOS_CLKREG(0x0C52C)
64#define S5P_CLKDIV_IMAGE S5P_CLKREG(0x0C530) 64#define EXYNOS4_CLKDIV_IMAGE EXYNOS_CLKREG(0x0C530)
65#define S5P_CLKDIV_LCD0 S5P_CLKREG(0x0C534) 65#define EXYNOS4_CLKDIV_LCD0 EXYNOS_CLKREG(0x0C534)
66#define S5P_CLKDIV_MAUDIO S5P_CLKREG(0x0C53C) 66#define EXYNOS4_CLKDIV_MAUDIO EXYNOS_CLKREG(0x0C53C)
67#define S5P_CLKDIV_FSYS0 S5P_CLKREG(0x0C540) 67#define EXYNOS4_CLKDIV_FSYS0 EXYNOS_CLKREG(0x0C540)
68#define S5P_CLKDIV_FSYS1 S5P_CLKREG(0x0C544) 68#define EXYNOS4_CLKDIV_FSYS1 EXYNOS_CLKREG(0x0C544)
69#define S5P_CLKDIV_FSYS2 S5P_CLKREG(0x0C548) 69#define EXYNOS4_CLKDIV_FSYS2 EXYNOS_CLKREG(0x0C548)
70#define S5P_CLKDIV_FSYS3 S5P_CLKREG(0x0C54C) 70#define EXYNOS4_CLKDIV_FSYS3 EXYNOS_CLKREG(0x0C54C)
71#define S5P_CLKDIV_PERIL0 S5P_CLKREG(0x0C550) 71#define EXYNOS4_CLKDIV_PERIL0 EXYNOS_CLKREG(0x0C550)
72#define S5P_CLKDIV_PERIL1 S5P_CLKREG(0x0C554) 72#define EXYNOS4_CLKDIV_PERIL1 EXYNOS_CLKREG(0x0C554)
73#define S5P_CLKDIV_PERIL2 S5P_CLKREG(0x0C558) 73#define EXYNOS4_CLKDIV_PERIL2 EXYNOS_CLKREG(0x0C558)
74#define S5P_CLKDIV_PERIL3 S5P_CLKREG(0x0C55C) 74#define EXYNOS4_CLKDIV_PERIL3 EXYNOS_CLKREG(0x0C55C)
75#define S5P_CLKDIV_PERIL4 S5P_CLKREG(0x0C560) 75#define EXYNOS4_CLKDIV_PERIL4 EXYNOS_CLKREG(0x0C560)
76#define S5P_CLKDIV_PERIL5 S5P_CLKREG(0x0C564) 76#define EXYNOS4_CLKDIV_PERIL5 EXYNOS_CLKREG(0x0C564)
77#define S5P_CLKDIV2_RATIO S5P_CLKREG(0x0C580) 77#define EXYNOS4_CLKDIV2_RATIO EXYNOS_CLKREG(0x0C580)
78 78
79#define S5P_CLKDIV_STAT_TOP S5P_CLKREG(0x0C610) 79#define EXYNOS4_CLKDIV_STAT_TOP EXYNOS_CLKREG(0x0C610)
80 80#define EXYNOS4_CLKDIV_STAT_MFC EXYNOS_CLKREG(0x0C628)
81#define S5P_CLKGATE_SCLKCAM S5P_CLKREG(0x0C820) 81
82#define S5P_CLKGATE_IP_CAM S5P_CLKREG(0x0C920) 82#define EXYNOS4_CLKGATE_SCLKCAM EXYNOS_CLKREG(0x0C820)
83#define S5P_CLKGATE_IP_TV S5P_CLKREG(0x0C924) 83#define EXYNOS4_CLKGATE_IP_CAM EXYNOS_CLKREG(0x0C920)
84#define S5P_CLKGATE_IP_MFC S5P_CLKREG(0x0C928) 84#define EXYNOS4_CLKGATE_IP_TV EXYNOS_CLKREG(0x0C924)
85#define S5P_CLKGATE_IP_G3D S5P_CLKREG(0x0C92C) 85#define EXYNOS4_CLKGATE_IP_MFC EXYNOS_CLKREG(0x0C928)
86#define S5P_CLKGATE_IP_IMAGE (soc_is_exynos4210() ? \ 86#define EXYNOS4_CLKGATE_IP_G3D EXYNOS_CLKREG(0x0C92C)
87 S5P_CLKREG(0x0C930) : \ 87#define EXYNOS4_CLKGATE_IP_IMAGE (soc_is_exynos4210() ? \
88 S5P_CLKREG(0x04930)) 88 EXYNOS_CLKREG(0x0C930) : \
89#define S5P_CLKGATE_IP_IMAGE_4210 S5P_CLKREG(0x0C930) 89 EXYNOS_CLKREG(0x04930))
90#define S5P_CLKGATE_IP_IMAGE_4212 S5P_CLKREG(0x04930) 90#define EXYNOS4210_CLKGATE_IP_IMAGE EXYNOS_CLKREG(0x0C930)
91#define S5P_CLKGATE_IP_LCD0 S5P_CLKREG(0x0C934) 91#define EXYNOS4212_CLKGATE_IP_IMAGE EXYNOS_CLKREG(0x04930)
92#define S5P_CLKGATE_IP_FSYS S5P_CLKREG(0x0C940) 92#define EXYNOS4_CLKGATE_IP_LCD0 EXYNOS_CLKREG(0x0C934)
93#define S5P_CLKGATE_IP_GPS S5P_CLKREG(0x0C94C) 93#define EXYNOS4_CLKGATE_IP_FSYS EXYNOS_CLKREG(0x0C940)
94#define S5P_CLKGATE_IP_PERIL S5P_CLKREG(0x0C950) 94#define EXYNOS4_CLKGATE_IP_GPS EXYNOS_CLKREG(0x0C94C)
95#define S5P_CLKGATE_IP_PERIR (soc_is_exynos4210() ? \ 95#define EXYNOS4_CLKGATE_IP_PERIL EXYNOS_CLKREG(0x0C950)
96 S5P_CLKREG(0x0C960) : \ 96#define EXYNOS4_CLKGATE_IP_PERIR (soc_is_exynos4210() ? \
97 S5P_CLKREG(0x08960)) 97 EXYNOS_CLKREG(0x0C960) : \
98#define S5P_CLKGATE_IP_PERIR_4210 S5P_CLKREG(0x0C960) 98 EXYNOS_CLKREG(0x08960))
99#define S5P_CLKGATE_IP_PERIR_4212 S5P_CLKREG(0x08960) 99#define EXYNOS4210_CLKGATE_IP_PERIR EXYNOS_CLKREG(0x0C960)
100#define S5P_CLKGATE_BLOCK S5P_CLKREG(0x0C970) 100#define EXYNOS4212_CLKGATE_IP_PERIR EXYNOS_CLKREG(0x08960)
101 101#define EXYNOS4_CLKGATE_BLOCK EXYNOS_CLKREG(0x0C970)
102#define S5P_CLKSRC_MASK_DMC S5P_CLKREG(0x10300) 102
103#define S5P_CLKSRC_DMC S5P_CLKREG(0x10200) 103#define EXYNOS4_CLKSRC_MASK_DMC EXYNOS_CLKREG(0x10300)
104#define S5P_CLKDIV_DMC0 S5P_CLKREG(0x10500) 104#define EXYNOS4_CLKSRC_DMC EXYNOS_CLKREG(0x10200)
105#define S5P_CLKDIV_DMC1 S5P_CLKREG(0x10504) 105#define EXYNOS4_CLKDIV_DMC0 EXYNOS_CLKREG(0x10500)
106#define S5P_CLKDIV_STAT_DMC0 S5P_CLKREG(0x10600) 106#define EXYNOS4_CLKDIV_DMC1 EXYNOS_CLKREG(0x10504)
107#define S5P_CLKGATE_IP_DMC S5P_CLKREG(0x10900) 107#define EXYNOS4_CLKDIV_STAT_DMC0 EXYNOS_CLKREG(0x10600)
108 108#define EXYNOS4_CLKDIV_STAT_DMC1 EXYNOS_CLKREG(0x10604)
109#define S5P_APLL_LOCK S5P_CLKREG(0x14000) 109#define EXYNOS4_CLKGATE_IP_DMC EXYNOS_CLKREG(0x10900)
110#define S5P_MPLL_LOCK (soc_is_exynos4210() ? \ 110
111 S5P_CLKREG(0x14004) : \ 111#define EXYNOS4_DMC_PAUSE_CTRL EXYNOS_CLKREG(0x11094)
112 S5P_CLKREG(0x10008)) 112#define EXYNOS4_DMC_PAUSE_ENABLE (1 << 0)
113#define S5P_APLL_CON0 S5P_CLKREG(0x14100) 113
114#define S5P_APLL_CON1 S5P_CLKREG(0x14104) 114#define EXYNOS4_APLL_LOCK EXYNOS_CLKREG(0x14000)
115#define S5P_MPLL_CON0 (soc_is_exynos4210() ? \ 115#define EXYNOS4_MPLL_LOCK (soc_is_exynos4210() ? \
116 S5P_CLKREG(0x14108) : \ 116 EXYNOS_CLKREG(0x14004) : \
117 S5P_CLKREG(0x10108)) 117 EXYNOS_CLKREG(0x10008))
118#define S5P_MPLL_CON1 (soc_is_exynos4210() ? \ 118#define EXYNOS4_APLL_CON0 EXYNOS_CLKREG(0x14100)
119 S5P_CLKREG(0x1410C) : \ 119#define EXYNOS4_APLL_CON1 EXYNOS_CLKREG(0x14104)
120 S5P_CLKREG(0x1010C)) 120#define EXYNOS4_MPLL_CON0 (soc_is_exynos4210() ? \
121 121 EXYNOS_CLKREG(0x14108) : \
122#define S5P_CLKSRC_CPU S5P_CLKREG(0x14200) 122 EXYNOS_CLKREG(0x10108))
123#define S5P_CLKMUX_STATCPU S5P_CLKREG(0x14400) 123#define EXYNOS4_MPLL_CON1 (soc_is_exynos4210() ? \
124 124 EXYNOS_CLKREG(0x1410C) : \
125#define S5P_CLKDIV_CPU S5P_CLKREG(0x14500) 125 EXYNOS_CLKREG(0x1010C))
126#define S5P_CLKDIV_CPU1 S5P_CLKREG(0x14504) 126
127#define S5P_CLKDIV_STATCPU S5P_CLKREG(0x14600) 127#define EXYNOS4_CLKSRC_CPU EXYNOS_CLKREG(0x14200)
128#define S5P_CLKDIV_STATCPU1 S5P_CLKREG(0x14604) 128#define EXYNOS4_CLKMUX_STATCPU EXYNOS_CLKREG(0x14400)
129 129
130#define S5P_CLKGATE_SCLKCPU S5P_CLKREG(0x14800) 130#define EXYNOS4_CLKDIV_CPU EXYNOS_CLKREG(0x14500)
131#define S5P_CLKGATE_IP_CPU S5P_CLKREG(0x14900) 131#define EXYNOS4_CLKDIV_CPU1 EXYNOS_CLKREG(0x14504)
132 132#define EXYNOS4_CLKDIV_STATCPU EXYNOS_CLKREG(0x14600)
133#define S5P_APLL_LOCKTIME (0x1C20) /* 300us */ 133#define EXYNOS4_CLKDIV_STATCPU1 EXYNOS_CLKREG(0x14604)
134 134
135#define S5P_APLLCON0_ENABLE_SHIFT (31) 135#define EXYNOS4_CLKGATE_SCLKCPU EXYNOS_CLKREG(0x14800)
136#define S5P_APLLCON0_LOCKED_SHIFT (29) 136#define EXYNOS4_CLKGATE_IP_CPU EXYNOS_CLKREG(0x14900)
137#define S5P_APLL_VAL_1000 ((250 << 16) | (6 << 8) | 1) 137
138#define S5P_APLL_VAL_800 ((200 << 16) | (6 << 8) | 1) 138#define EXYNOS4_APLL_LOCKTIME (0x1C20) /* 300us */
139 139
140#define S5P_EPLLCON0_ENABLE_SHIFT (31) 140#define EXYNOS4_APLLCON0_ENABLE_SHIFT (31)
141#define S5P_EPLLCON0_LOCKED_SHIFT (29) 141#define EXYNOS4_APLLCON0_LOCKED_SHIFT (29)
142 142#define EXYNOS4_APLL_VAL_1000 ((250 << 16) | (6 << 8) | 1)
143#define S5P_VPLLCON0_ENABLE_SHIFT (31) 143#define EXYNOS4_APLL_VAL_800 ((200 << 16) | (6 << 8) | 1)
144#define S5P_VPLLCON0_LOCKED_SHIFT (29) 144
145 145#define EXYNOS4_EPLLCON0_ENABLE_SHIFT (31)
146#define S5P_CLKSRC_CPU_MUXCORE_SHIFT (16) 146#define EXYNOS4_EPLLCON0_LOCKED_SHIFT (29)
147#define S5P_CLKMUX_STATCPU_MUXCORE_MASK (0x7 << S5P_CLKSRC_CPU_MUXCORE_SHIFT) 147
148 148#define EXYNOS4_VPLLCON0_ENABLE_SHIFT (31)
149#define S5P_CLKDIV_CPU0_CORE_SHIFT (0) 149#define EXYNOS4_VPLLCON0_LOCKED_SHIFT (29)
150#define S5P_CLKDIV_CPU0_CORE_MASK (0x7 << S5P_CLKDIV_CPU0_CORE_SHIFT) 150
151#define S5P_CLKDIV_CPU0_COREM0_SHIFT (4) 151#define EXYNOS4_CLKSRC_CPU_MUXCORE_SHIFT (16)
152#define S5P_CLKDIV_CPU0_COREM0_MASK (0x7 << S5P_CLKDIV_CPU0_COREM0_SHIFT) 152#define EXYNOS4_CLKMUX_STATCPU_MUXCORE_MASK (0x7 << EXYNOS4_CLKSRC_CPU_MUXCORE_SHIFT)
153#define S5P_CLKDIV_CPU0_COREM1_SHIFT (8) 153
154#define S5P_CLKDIV_CPU0_COREM1_MASK (0x7 << S5P_CLKDIV_CPU0_COREM1_SHIFT) 154#define EXYNOS4_CLKDIV_CPU0_CORE_SHIFT (0)
155#define S5P_CLKDIV_CPU0_PERIPH_SHIFT (12) 155#define EXYNOS4_CLKDIV_CPU0_CORE_MASK (0x7 << EXYNOS4_CLKDIV_CPU0_CORE_SHIFT)
156#define S5P_CLKDIV_CPU0_PERIPH_MASK (0x7 << S5P_CLKDIV_CPU0_PERIPH_SHIFT) 156#define EXYNOS4_CLKDIV_CPU0_COREM0_SHIFT (4)
157#define S5P_CLKDIV_CPU0_ATB_SHIFT (16) 157#define EXYNOS4_CLKDIV_CPU0_COREM0_MASK (0x7 << EXYNOS4_CLKDIV_CPU0_COREM0_SHIFT)
158#define S5P_CLKDIV_CPU0_ATB_MASK (0x7 << S5P_CLKDIV_CPU0_ATB_SHIFT) 158#define EXYNOS4_CLKDIV_CPU0_COREM1_SHIFT (8)
159#define S5P_CLKDIV_CPU0_PCLKDBG_SHIFT (20) 159#define EXYNOS4_CLKDIV_CPU0_COREM1_MASK (0x7 << EXYNOS4_CLKDIV_CPU0_COREM1_SHIFT)
160#define S5P_CLKDIV_CPU0_PCLKDBG_MASK (0x7 << S5P_CLKDIV_CPU0_PCLKDBG_SHIFT) 160#define EXYNOS4_CLKDIV_CPU0_PERIPH_SHIFT (12)
161#define S5P_CLKDIV_CPU0_APLL_SHIFT (24) 161#define EXYNOS4_CLKDIV_CPU0_PERIPH_MASK (0x7 << EXYNOS4_CLKDIV_CPU0_PERIPH_SHIFT)
162#define S5P_CLKDIV_CPU0_APLL_MASK (0x7 << S5P_CLKDIV_CPU0_APLL_SHIFT) 162#define EXYNOS4_CLKDIV_CPU0_ATB_SHIFT (16)
163 163#define EXYNOS4_CLKDIV_CPU0_ATB_MASK (0x7 << EXYNOS4_CLKDIV_CPU0_ATB_SHIFT)
164#define S5P_CLKDIV_DMC0_ACP_SHIFT (0) 164#define EXYNOS4_CLKDIV_CPU0_PCLKDBG_SHIFT (20)
165#define S5P_CLKDIV_DMC0_ACP_MASK (0x7 << S5P_CLKDIV_DMC0_ACP_SHIFT) 165#define EXYNOS4_CLKDIV_CPU0_PCLKDBG_MASK (0x7 << EXYNOS4_CLKDIV_CPU0_PCLKDBG_SHIFT)
166#define S5P_CLKDIV_DMC0_ACPPCLK_SHIFT (4) 166#define EXYNOS4_CLKDIV_CPU0_APLL_SHIFT (24)
167#define S5P_CLKDIV_DMC0_ACPPCLK_MASK (0x7 << S5P_CLKDIV_DMC0_ACPPCLK_SHIFT) 167#define EXYNOS4_CLKDIV_CPU0_APLL_MASK (0x7 << EXYNOS4_CLKDIV_CPU0_APLL_SHIFT)
168#define S5P_CLKDIV_DMC0_DPHY_SHIFT (8) 168#define EXYNOS4_CLKDIV_CPU0_CORE2_SHIFT 28
169#define S5P_CLKDIV_DMC0_DPHY_MASK (0x7 << S5P_CLKDIV_DMC0_DPHY_SHIFT) 169#define EXYNOS4_CLKDIV_CPU0_CORE2_MASK (0x7 << EXYNOS4_CLKDIV_CPU0_CORE2_SHIFT)
170#define S5P_CLKDIV_DMC0_DMC_SHIFT (12) 170
171#define S5P_CLKDIV_DMC0_DMC_MASK (0x7 << S5P_CLKDIV_DMC0_DMC_SHIFT) 171#define EXYNOS4_CLKDIV_CPU1_COPY_SHIFT 0
172#define S5P_CLKDIV_DMC0_DMCD_SHIFT (16) 172#define EXYNOS4_CLKDIV_CPU1_COPY_MASK (0x7 << EXYNOS4_CLKDIV_CPU1_COPY_SHIFT)
173#define S5P_CLKDIV_DMC0_DMCD_MASK (0x7 << S5P_CLKDIV_DMC0_DMCD_SHIFT) 173#define EXYNOS4_CLKDIV_CPU1_HPM_SHIFT 4
174#define S5P_CLKDIV_DMC0_DMCP_SHIFT (20) 174#define EXYNOS4_CLKDIV_CPU1_HPM_MASK (0x7 << EXYNOS4_CLKDIV_CPU1_HPM_SHIFT)
175#define S5P_CLKDIV_DMC0_DMCP_MASK (0x7 << S5P_CLKDIV_DMC0_DMCP_SHIFT) 175#define EXYNOS4_CLKDIV_CPU1_CORES_SHIFT 8
176#define S5P_CLKDIV_DMC0_COPY2_SHIFT (24) 176#define EXYNOS4_CLKDIV_CPU1_CORES_MASK (0x7 << EXYNOS4_CLKDIV_CPU1_CORES_SHIFT)
177#define S5P_CLKDIV_DMC0_COPY2_MASK (0x7 << S5P_CLKDIV_DMC0_COPY2_SHIFT) 177
178#define S5P_CLKDIV_DMC0_CORETI_SHIFT (28) 178#define EXYNOS4_CLKDIV_DMC0_ACP_SHIFT (0)
179#define S5P_CLKDIV_DMC0_CORETI_MASK (0x7 << S5P_CLKDIV_DMC0_CORETI_SHIFT) 179#define EXYNOS4_CLKDIV_DMC0_ACP_MASK (0x7 << EXYNOS4_CLKDIV_DMC0_ACP_SHIFT)
180 180#define EXYNOS4_CLKDIV_DMC0_ACPPCLK_SHIFT (4)
181#define S5P_CLKDIV_TOP_ACLK200_SHIFT (0) 181#define EXYNOS4_CLKDIV_DMC0_ACPPCLK_MASK (0x7 << EXYNOS4_CLKDIV_DMC0_ACPPCLK_SHIFT)
182#define S5P_CLKDIV_TOP_ACLK200_MASK (0x7 << S5P_CLKDIV_TOP_ACLK200_SHIFT) 182#define EXYNOS4_CLKDIV_DMC0_DPHY_SHIFT (8)
183#define S5P_CLKDIV_TOP_ACLK100_SHIFT (4) 183#define EXYNOS4_CLKDIV_DMC0_DPHY_MASK (0x7 << EXYNOS4_CLKDIV_DMC0_DPHY_SHIFT)
184#define S5P_CLKDIV_TOP_ACLK100_MASK (0xf << S5P_CLKDIV_TOP_ACLK100_SHIFT) 184#define EXYNOS4_CLKDIV_DMC0_DMC_SHIFT (12)
185#define S5P_CLKDIV_TOP_ACLK160_SHIFT (8) 185#define EXYNOS4_CLKDIV_DMC0_DMC_MASK (0x7 << EXYNOS4_CLKDIV_DMC0_DMC_SHIFT)
186#define S5P_CLKDIV_TOP_ACLK160_MASK (0x7 << S5P_CLKDIV_TOP_ACLK160_SHIFT) 186#define EXYNOS4_CLKDIV_DMC0_DMCD_SHIFT (16)
187#define S5P_CLKDIV_TOP_ACLK133_SHIFT (12) 187#define EXYNOS4_CLKDIV_DMC0_DMCD_MASK (0x7 << EXYNOS4_CLKDIV_DMC0_DMCD_SHIFT)
188#define S5P_CLKDIV_TOP_ACLK133_MASK (0x7 << S5P_CLKDIV_TOP_ACLK133_SHIFT) 188#define EXYNOS4_CLKDIV_DMC0_DMCP_SHIFT (20)
189#define S5P_CLKDIV_TOP_ONENAND_SHIFT (16) 189#define EXYNOS4_CLKDIV_DMC0_DMCP_MASK (0x7 << EXYNOS4_CLKDIV_DMC0_DMCP_SHIFT)
190#define S5P_CLKDIV_TOP_ONENAND_MASK (0x7 << S5P_CLKDIV_TOP_ONENAND_SHIFT) 190#define EXYNOS4_CLKDIV_DMC0_COPY2_SHIFT (24)
191 191#define EXYNOS4_CLKDIV_DMC0_COPY2_MASK (0x7 << EXYNOS4_CLKDIV_DMC0_COPY2_SHIFT)
192#define S5P_CLKDIV_BUS_GDLR_SHIFT (0) 192#define EXYNOS4_CLKDIV_DMC0_CORETI_SHIFT (28)
193#define S5P_CLKDIV_BUS_GDLR_MASK (0x7 << S5P_CLKDIV_BUS_GDLR_SHIFT) 193#define EXYNOS4_CLKDIV_DMC0_CORETI_MASK (0x7 << EXYNOS4_CLKDIV_DMC0_CORETI_SHIFT)
194#define S5P_CLKDIV_BUS_GPLR_SHIFT (4) 194
195#define S5P_CLKDIV_BUS_GPLR_MASK (0x7 << S5P_CLKDIV_BUS_GPLR_SHIFT) 195#define EXYNOS4_CLKDIV_DMC1_G2D_ACP_SHIFT (0)
196#define EXYNOS4_CLKDIV_DMC1_G2D_ACP_MASK (0xf << EXYNOS4_CLKDIV_DMC1_G2D_ACP_SHIFT)
197#define EXYNOS4_CLKDIV_DMC1_C2C_SHIFT (4)
198#define EXYNOS4_CLKDIV_DMC1_C2C_MASK (0x7 << EXYNOS4_CLKDIV_DMC1_C2C_SHIFT)
199#define EXYNOS4_CLKDIV_DMC1_PWI_SHIFT (8)
200#define EXYNOS4_CLKDIV_DMC1_PWI_MASK (0xf << EXYNOS4_CLKDIV_DMC1_PWI_SHIFT)
201#define EXYNOS4_CLKDIV_DMC1_C2CACLK_SHIFT (12)
202#define EXYNOS4_CLKDIV_DMC1_C2CACLK_MASK (0x7 << EXYNOS4_CLKDIV_DMC1_C2CACLK_SHIFT)
203#define EXYNOS4_CLKDIV_DMC1_DVSEM_SHIFT (16)
204#define EXYNOS4_CLKDIV_DMC1_DVSEM_MASK (0x7f << EXYNOS4_CLKDIV_DMC1_DVSEM_SHIFT)
205#define EXYNOS4_CLKDIV_DMC1_DPM_SHIFT (24)
206#define EXYNOS4_CLKDIV_DMC1_DPM_MASK (0x7f << EXYNOS4_CLKDIV_DMC1_DPM_SHIFT)
207
208#define EXYNOS4_CLKDIV_MFC_SHIFT (0)
209#define EXYNOS4_CLKDIV_MFC_MASK (0x7 << EXYNOS4_CLKDIV_MFC_SHIFT)
210
211#define EXYNOS4_CLKDIV_TOP_ACLK200_SHIFT (0)
212#define EXYNOS4_CLKDIV_TOP_ACLK200_MASK (0x7 << EXYNOS4_CLKDIV_TOP_ACLK200_SHIFT)
213#define EXYNOS4_CLKDIV_TOP_ACLK100_SHIFT (4)
214#define EXYNOS4_CLKDIV_TOP_ACLK100_MASK (0xF << EXYNOS4_CLKDIV_TOP_ACLK100_SHIFT)
215#define EXYNOS4_CLKDIV_TOP_ACLK160_SHIFT (8)
216#define EXYNOS4_CLKDIV_TOP_ACLK160_MASK (0x7 << EXYNOS4_CLKDIV_TOP_ACLK160_SHIFT)
217#define EXYNOS4_CLKDIV_TOP_ACLK133_SHIFT (12)
218#define EXYNOS4_CLKDIV_TOP_ACLK133_MASK (0x7 << EXYNOS4_CLKDIV_TOP_ACLK133_SHIFT)
219#define EXYNOS4_CLKDIV_TOP_ONENAND_SHIFT (16)
220#define EXYNOS4_CLKDIV_TOP_ONENAND_MASK (0x7 << EXYNOS4_CLKDIV_TOP_ONENAND_SHIFT)
221#define EXYNOS4_CLKDIV_TOP_ACLK266_GPS_SHIFT (20)
222#define EXYNOS4_CLKDIV_TOP_ACLK266_GPS_MASK (0x7 << EXYNOS4_CLKDIV_TOP_ACLK266_GPS_SHIFT)
223#define EXYNOS4_CLKDIV_TOP_ACLK400_MCUISP_SHIFT (24)
224#define EXYNOS4_CLKDIV_TOP_ACLK400_MCUISP_MASK (0x7 << EXYNOS4_CLKDIV_TOP_ACLK400_MCUISP_SHIFT)
225
226#define EXYNOS4_CLKDIV_BUS_GDLR_SHIFT (0)
227#define EXYNOS4_CLKDIV_BUS_GDLR_MASK (0x7 << EXYNOS4_CLKDIV_BUS_GDLR_SHIFT)
228#define EXYNOS4_CLKDIV_BUS_GPLR_SHIFT (4)
229#define EXYNOS4_CLKDIV_BUS_GPLR_MASK (0x7 << EXYNOS4_CLKDIV_BUS_GPLR_SHIFT)
230
231#define EXYNOS4_CLKDIV_CAM_FIMC0_SHIFT (0)
232#define EXYNOS4_CLKDIV_CAM_FIMC0_MASK (0xf << EXYNOS4_CLKDIV_CAM_FIMC0_SHIFT)
233#define EXYNOS4_CLKDIV_CAM_FIMC1_SHIFT (4)
234#define EXYNOS4_CLKDIV_CAM_FIMC1_MASK (0xf << EXYNOS4_CLKDIV_CAM_FIMC1_SHIFT)
235#define EXYNOS4_CLKDIV_CAM_FIMC2_SHIFT (8)
236#define EXYNOS4_CLKDIV_CAM_FIMC2_MASK (0xf << EXYNOS4_CLKDIV_CAM_FIMC2_SHIFT)
237#define EXYNOS4_CLKDIV_CAM_FIMC3_SHIFT (12)
238#define EXYNOS4_CLKDIV_CAM_FIMC3_MASK (0xf << EXYNOS4_CLKDIV_CAM_FIMC3_SHIFT)
196 239
197/* Only for EXYNOS4210 */ 240/* Only for EXYNOS4210 */
198 241
199#define S5P_CLKSRC_LCD1 S5P_CLKREG(0x0C238) 242#define EXYNOS4210_CLKSRC_LCD1 EXYNOS_CLKREG(0x0C238)
200#define S5P_CLKSRC_MASK_LCD1 S5P_CLKREG(0x0C338) 243#define EXYNOS4210_CLKSRC_MASK_LCD1 EXYNOS_CLKREG(0x0C338)
201#define S5P_CLKDIV_LCD1 S5P_CLKREG(0x0C538) 244#define EXYNOS4210_CLKDIV_LCD1 EXYNOS_CLKREG(0x0C538)
202#define S5P_CLKGATE_IP_LCD1 S5P_CLKREG(0x0C938) 245#define EXYNOS4210_CLKGATE_IP_LCD1 EXYNOS_CLKREG(0x0C938)
246
247/* Only for EXYNOS4212 */
248
249#define EXYNOS4_CLKDIV_CAM1 EXYNOS_CLKREG(0x0C568)
250
251#define EXYNOS4_CLKDIV_STAT_CAM1 EXYNOS_CLKREG(0x0C668)
252
253#define EXYNOS4_CLKDIV_CAM1_JPEG_SHIFT (0)
254#define EXYNOS4_CLKDIV_CAM1_JPEG_MASK (0xf << EXYNOS4_CLKDIV_CAM1_JPEG_SHIFT)
255
256/* For EXYNOS5250 */
257
258#define EXYNOS5_APLL_CON0 EXYNOS_CLKREG(0x00100)
259#define EXYNOS5_CLKSRC_CPU EXYNOS_CLKREG(0x00200)
260#define EXYNOS5_CLKDIV_CPU0 EXYNOS_CLKREG(0x00500)
261#define EXYNOS5_MPLL_CON0 EXYNOS_CLKREG(0x04100)
262#define EXYNOS5_CLKSRC_CORE1 EXYNOS_CLKREG(0x04204)
263
264#define EXYNOS5_CLKGATE_IP_CORE EXYNOS_CLKREG(0x04900)
265
266#define EXYNOS5_CLKDIV_ACP EXYNOS_CLKREG(0x08500)
267
268#define EXYNOS5_CLKSRC_TOP2 EXYNOS_CLKREG(0x10218)
269#define EXYNOS5_EPLL_CON0 EXYNOS_CLKREG(0x10130)
270#define EXYNOS5_EPLL_CON1 EXYNOS_CLKREG(0x10134)
271#define EXYNOS5_VPLL_CON0 EXYNOS_CLKREG(0x10140)
272#define EXYNOS5_VPLL_CON1 EXYNOS_CLKREG(0x10144)
273#define EXYNOS5_CPLL_CON0 EXYNOS_CLKREG(0x10120)
274
275#define EXYNOS5_CLKSRC_TOP0 EXYNOS_CLKREG(0x10210)
276#define EXYNOS5_CLKSRC_TOP3 EXYNOS_CLKREG(0x1021C)
277#define EXYNOS5_CLKSRC_GSCL EXYNOS_CLKREG(0x10220)
278#define EXYNOS5_CLKSRC_DISP1_0 EXYNOS_CLKREG(0x1022C)
279#define EXYNOS5_CLKSRC_FSYS EXYNOS_CLKREG(0x10244)
280#define EXYNOS5_CLKSRC_PERIC0 EXYNOS_CLKREG(0x10250)
281
282#define EXYNOS5_CLKSRC_MASK_TOP EXYNOS_CLKREG(0x10310)
283#define EXYNOS5_CLKSRC_MASK_GSCL EXYNOS_CLKREG(0x10320)
284#define EXYNOS5_CLKSRC_MASK_DISP1_0 EXYNOS_CLKREG(0x1032C)
285#define EXYNOS5_CLKSRC_MASK_FSYS EXYNOS_CLKREG(0x10340)
286#define EXYNOS5_CLKSRC_MASK_PERIC0 EXYNOS_CLKREG(0x10350)
287
288#define EXYNOS5_CLKDIV_TOP0 EXYNOS_CLKREG(0x10510)
289#define EXYNOS5_CLKDIV_TOP1 EXYNOS_CLKREG(0x10514)
290#define EXYNOS5_CLKDIV_GSCL EXYNOS_CLKREG(0x10520)
291#define EXYNOS5_CLKDIV_DISP1_0 EXYNOS_CLKREG(0x1052C)
292#define EXYNOS5_CLKDIV_GEN EXYNOS_CLKREG(0x1053C)
293#define EXYNOS5_CLKDIV_FSYS0 EXYNOS_CLKREG(0x10548)
294#define EXYNOS5_CLKDIV_FSYS1 EXYNOS_CLKREG(0x1054C)
295#define EXYNOS5_CLKDIV_FSYS2 EXYNOS_CLKREG(0x10550)
296#define EXYNOS5_CLKDIV_FSYS3 EXYNOS_CLKREG(0x10554)
297#define EXYNOS5_CLKDIV_PERIC0 EXYNOS_CLKREG(0x10558)
298
299#define EXYNOS5_CLKGATE_IP_ACP EXYNOS_CLKREG(0x08800)
300#define EXYNOS5_CLKGATE_IP_GSCL EXYNOS_CLKREG(0x10920)
301#define EXYNOS5_CLKGATE_IP_DISP1 EXYNOS_CLKREG(0x10928)
302#define EXYNOS5_CLKGATE_IP_MFC EXYNOS_CLKREG(0x1092C)
303#define EXYNOS5_CLKGATE_IP_GEN EXYNOS_CLKREG(0x10934)
304#define EXYNOS5_CLKGATE_IP_FSYS EXYNOS_CLKREG(0x10944)
305#define EXYNOS5_CLKGATE_IP_GPS EXYNOS_CLKREG(0x1094C)
306#define EXYNOS5_CLKGATE_IP_PERIC EXYNOS_CLKREG(0x10950)
307#define EXYNOS5_CLKGATE_IP_PERIS EXYNOS_CLKREG(0x10960)
308#define EXYNOS5_CLKGATE_BLOCK EXYNOS_CLKREG(0x10980)
309
310#define EXYNOS5_BPLL_CON0 EXYNOS_CLKREG(0x20110)
311#define EXYNOS5_CLKSRC_CDREX EXYNOS_CLKREG(0x20200)
312#define EXYNOS5_CLKDIV_CDREX EXYNOS_CLKREG(0x20500)
313
314#define EXYNOS5_EPLL_LOCK EXYNOS_CLKREG(0x10030)
315
316#define EXYNOS5_EPLLCON0_LOCKED_SHIFT (29)
203 317
204/* Compatibility defines and inclusion */ 318/* Compatibility defines and inclusion */
205 319
206#include <mach/regs-pmu.h> 320#include <mach/regs-pmu.h>
207 321
208#define S5P_EPLL_CON S5P_EPLL_CON0 322#define S5P_EPLL_CON EXYNOS4_EPLL_CON0
209 323
210#endif /* __ASM_ARCH_REGS_CLOCK_H */ 324#endif /* __ASM_ARCH_REGS_CLOCK_H */
diff --git a/arch/arm/mach-exynos/include/mach/regs-gpio.h b/arch/arm/mach-exynos/include/mach/regs-gpio.h
index 1401b21663a..e4b5b60dcb8 100644
--- a/arch/arm/mach-exynos/include/mach/regs-gpio.h
+++ b/arch/arm/mach-exynos/include/mach/regs-gpio.h
@@ -16,6 +16,15 @@
16#include <mach/map.h> 16#include <mach/map.h>
17#include <mach/irqs.h> 17#include <mach/irqs.h>
18 18
19#define EINT_REG_NR(x) (EINT_OFFSET(x) >> 3)
20#define EINT_CON(b, x) (b + 0xE00 + (EINT_REG_NR(x) * 4))
21#define EINT_FLTCON(b, x) (b + 0xE80 + (EINT_REG_NR(x) * 4))
22#define EINT_MASK(b, x) (b + 0xF00 + (EINT_REG_NR(x) * 4))
23#define EINT_PEND(b, x) (b + 0xF40 + (EINT_REG_NR(x) * 4))
24
25#define EINT_OFFSET_BIT(x) (1 << (EINT_OFFSET(x) & 0x7))
26
27/* compatibility for plat-s5p/irq-pm.c */
19#define EXYNOS4_EINT40CON (S5P_VA_GPIO2 + 0xE00) 28#define EXYNOS4_EINT40CON (S5P_VA_GPIO2 + 0xE00)
20#define S5P_EINT_CON(x) (EXYNOS4_EINT40CON + ((x) * 0x4)) 29#define S5P_EINT_CON(x) (EXYNOS4_EINT40CON + ((x) * 0x4))
21 30
@@ -28,15 +37,4 @@
28#define EXYNOS4_EINT40PEND (S5P_VA_GPIO2 + 0xF40) 37#define EXYNOS4_EINT40PEND (S5P_VA_GPIO2 + 0xF40)
29#define S5P_EINT_PEND(x) (EXYNOS4_EINT40PEND + ((x) * 0x4)) 38#define S5P_EINT_PEND(x) (EXYNOS4_EINT40PEND + ((x) * 0x4))
30 39
31#define EINT_REG_NR(x) (EINT_OFFSET(x) >> 3)
32
33#define eint_irq_to_bit(irq) (1 << (EINT_OFFSET(irq) & 0x7))
34
35#define EINT_MODE S3C_GPIO_SFN(0xf)
36
37#define EINT_GPIO_0(x) EXYNOS4_GPX0(x)
38#define EINT_GPIO_1(x) EXYNOS4_GPX1(x)
39#define EINT_GPIO_2(x) EXYNOS4_GPX2(x)
40#define EINT_GPIO_3(x) EXYNOS4_GPX3(x)
41
42#endif /* __ASM_ARCH_REGS_GPIO_H */ 40#endif /* __ASM_ARCH_REGS_GPIO_H */
diff --git a/arch/arm/mach-exynos/include/mach/regs-pmu.h b/arch/arm/mach-exynos/include/mach/regs-pmu.h
index 4fff8e938fe..4c53f38b5a9 100644
--- a/arch/arm/mach-exynos/include/mach/regs-pmu.h
+++ b/arch/arm/mach-exynos/include/mach/regs-pmu.h
@@ -31,6 +31,7 @@
31#define S5P_USE_STANDBYWFE_ISP_ARM (1 << 26) 31#define S5P_USE_STANDBYWFE_ISP_ARM (1 << 26)
32 32
33#define S5P_SWRESET S5P_PMUREG(0x0400) 33#define S5P_SWRESET S5P_PMUREG(0x0400)
34#define EXYNOS_SWRESET S5P_PMUREG(0x0400)
34 35
35#define S5P_WAKEUP_STAT S5P_PMUREG(0x0600) 36#define S5P_WAKEUP_STAT S5P_PMUREG(0x0600)
36#define S5P_EINT_WAKEUP_MASK S5P_PMUREG(0x0604) 37#define S5P_EINT_WAKEUP_MASK S5P_PMUREG(0x0604)
diff --git a/arch/arm/mach-exynos/include/mach/system.h b/arch/arm/mach-exynos/include/mach/system.h
deleted file mode 100644
index 0063a6de3dc..00000000000
--- a/arch/arm/mach-exynos/include/mach/system.h
+++ /dev/null
@@ -1,20 +0,0 @@
1/* linux/arch/arm/mach-exynos4/include/mach/system.h
2 *
3 * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * EXYNOS4 - system support header
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13#ifndef __ASM_ARCH_SYSTEM_H
14#define __ASM_ARCH_SYSTEM_H __FILE__
15
16static void arch_idle(void)
17{
18 /* nothing here yet */
19}
20#endif /* __ASM_ARCH_SYSTEM_H */
diff --git a/arch/arm/mach-exynos/include/mach/uncompress.h b/arch/arm/mach-exynos/include/mach/uncompress.h
index 21d97bcd9ac..493f4f365dd 100644
--- a/arch/arm/mach-exynos/include/mach/uncompress.h
+++ b/arch/arm/mach-exynos/include/mach/uncompress.h
@@ -1,9 +1,8 @@
1/* linux/arch/arm/mach-exynos4/include/mach/uncompress.h 1/*
2 * 2 * Copyright (c) 2010-2012 Samsung Electronics Co., Ltd.
3 * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com 3 * http://www.samsung.com
5 * 4 *
6 * EXYNOS4 - uncompress code 5 * EXYNOS - uncompress code
7 * 6 *
8 * 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
9 * 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
@@ -13,12 +12,20 @@
13#ifndef __ASM_ARCH_UNCOMPRESS_H 12#ifndef __ASM_ARCH_UNCOMPRESS_H
14#define __ASM_ARCH_UNCOMPRESS_H __FILE__ 13#define __ASM_ARCH_UNCOMPRESS_H __FILE__
15 14
15#include <asm/mach-types.h>
16
16#include <mach/map.h> 17#include <mach/map.h>
18
19volatile u8 *uart_base;
20
17#include <plat/uncompress.h> 21#include <plat/uncompress.h>
18 22
19static void arch_detect_cpu(void) 23static void arch_detect_cpu(void)
20{ 24{
21 /* we do not need to do any cpu detection here at the moment. */ 25 if (machine_is_smdk5250())
26 uart_base = (volatile u8 *)EXYNOS5_PA_UART + (S3C_UART_OFFSET * CONFIG_S3C_LOWLEVEL_UART_PORT);
27 else
28 uart_base = (volatile u8 *)EXYNOS4_PA_UART + (S3C_UART_OFFSET * CONFIG_S3C_LOWLEVEL_UART_PORT);
22 29
23 /* 30 /*
24 * For preventing FIFO overrun or infinite loop of UART console, 31 * For preventing FIFO overrun or infinite loop of UART console,
diff --git a/arch/arm/mach-exynos/mach-exynos4-dt.c b/arch/arm/mach-exynos/mach-exynos4-dt.c
index e6b02fdf1b0..8245f1c761d 100644
--- a/arch/arm/mach-exynos/mach-exynos4-dt.c
+++ b/arch/arm/mach-exynos/mach-exynos4-dt.c
@@ -37,13 +37,13 @@
37 * data from the device tree. 37 * data from the device tree.
38 */ 38 */
39static const struct of_dev_auxdata exynos4210_auxdata_lookup[] __initconst = { 39static const struct of_dev_auxdata exynos4210_auxdata_lookup[] __initconst = {
40 OF_DEV_AUXDATA("samsung,exynos4210-uart", S5P_PA_UART0, 40 OF_DEV_AUXDATA("samsung,exynos4210-uart", EXYNOS4_PA_UART0,
41 "exynos4210-uart.0", NULL), 41 "exynos4210-uart.0", NULL),
42 OF_DEV_AUXDATA("samsung,exynos4210-uart", S5P_PA_UART1, 42 OF_DEV_AUXDATA("samsung,exynos4210-uart", EXYNOS4_PA_UART1,
43 "exynos4210-uart.1", NULL), 43 "exynos4210-uart.1", NULL),
44 OF_DEV_AUXDATA("samsung,exynos4210-uart", S5P_PA_UART2, 44 OF_DEV_AUXDATA("samsung,exynos4210-uart", EXYNOS4_PA_UART2,
45 "exynos4210-uart.2", NULL), 45 "exynos4210-uart.2", NULL),
46 OF_DEV_AUXDATA("samsung,exynos4210-uart", S5P_PA_UART3, 46 OF_DEV_AUXDATA("samsung,exynos4210-uart", EXYNOS4_PA_UART3,
47 "exynos4210-uart.3", NULL), 47 "exynos4210-uart.3", NULL),
48 OF_DEV_AUXDATA("samsung,exynos4210-sdhci", EXYNOS4_PA_HSMMC(0), 48 OF_DEV_AUXDATA("samsung,exynos4210-sdhci", EXYNOS4_PA_HSMMC(0),
49 "exynos4-sdhci.0", NULL), 49 "exynos4-sdhci.0", NULL),
diff --git a/arch/arm/mach-exynos/mach-exynos5-dt.c b/arch/arm/mach-exynos/mach-exynos5-dt.c
new file mode 100644
index 00000000000..0d26f50081a
--- /dev/null
+++ b/arch/arm/mach-exynos/mach-exynos5-dt.c
@@ -0,0 +1,78 @@
1/*
2 * SAMSUNG EXYNOS5250 Flattened Device Tree enabled machine
3 *
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10*/
11
12#include <linux/of_platform.h>
13#include <linux/serial_core.h>
14
15#include <asm/mach/arch.h>
16#include <asm/hardware/gic.h>
17#include <mach/map.h>
18
19#include <plat/cpu.h>
20#include <plat/regs-serial.h>
21
22#include "common.h"
23
24/*
25 * The following lookup table is used to override device names when devices
26 * are registered from device tree. This is temporarily added to enable
27 * device tree support addition for the EXYNOS5 architecture.
28 *
29 * For drivers that require platform data to be provided from the machine
30 * file, a platform data pointer can also be supplied along with the
31 * devices names. Usually, the platform data elements that cannot be parsed
32 * from the device tree by the drivers (example: function pointers) are
33 * supplied. But it should be noted that this is a temporary mechanism and
34 * at some point, the drivers should be capable of parsing all the platform
35 * data from the device tree.
36 */
37static const struct of_dev_auxdata exynos5250_auxdata_lookup[] __initconst = {
38 OF_DEV_AUXDATA("samsung,exynos4210-uart", EXYNOS5_PA_UART0,
39 "exynos4210-uart.0", NULL),
40 OF_DEV_AUXDATA("samsung,exynos4210-uart", EXYNOS5_PA_UART1,
41 "exynos4210-uart.1", NULL),
42 OF_DEV_AUXDATA("samsung,exynos4210-uart", EXYNOS5_PA_UART2,
43 "exynos4210-uart.2", NULL),
44 OF_DEV_AUXDATA("samsung,exynos4210-uart", EXYNOS5_PA_UART3,
45 "exynos4210-uart.3", NULL),
46 OF_DEV_AUXDATA("arm,pl330", EXYNOS5_PA_PDMA0, "dma-pl330.0", NULL),
47 OF_DEV_AUXDATA("arm,pl330", EXYNOS5_PA_PDMA1, "dma-pl330.1", NULL),
48 OF_DEV_AUXDATA("arm,pl330", EXYNOS5_PA_PDMA1, "dma-pl330.2", NULL),
49 {},
50};
51
52static void __init exynos5250_dt_map_io(void)
53{
54 exynos_init_io(NULL, 0);
55 s3c24xx_init_clocks(24000000);
56}
57
58static void __init exynos5250_dt_machine_init(void)
59{
60 of_platform_populate(NULL, of_default_bus_match_table,
61 exynos5250_auxdata_lookup, NULL);
62}
63
64static char const *exynos5250_dt_compat[] __initdata = {
65 "samsung,exynos5250",
66 NULL
67};
68
69DT_MACHINE_START(EXYNOS5_DT, "SAMSUNG EXYNOS5 (Flattened Device Tree)")
70 /* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */
71 .init_irq = exynos5_init_irq,
72 .map_io = exynos5250_dt_map_io,
73 .handle_irq = gic_handle_irq,
74 .init_machine = exynos5250_dt_machine_init,
75 .timer = &exynos4_timer,
76 .dt_compat = exynos5250_dt_compat,
77 .restart = exynos5_restart,
78MACHINE_END
diff --git a/arch/arm/mach-exynos/mach-nuri.c b/arch/arm/mach-exynos/mach-nuri.c
index aa37179d776..82ea6fccfb3 100644
--- a/arch/arm/mach-exynos/mach-nuri.c
+++ b/arch/arm/mach-exynos/mach-nuri.c
@@ -28,6 +28,7 @@
28 28
29#include <video/platform_lcd.h> 29#include <video/platform_lcd.h>
30#include <media/m5mols.h> 30#include <media/m5mols.h>
31#include <media/s5k6aa.h>
31#include <media/s5p_fimc.h> 32#include <media/s5p_fimc.h>
32#include <media/v4l2-mediabus.h> 33#include <media/v4l2-mediabus.h>
33 34
@@ -75,6 +76,7 @@ enum fixed_regulator_id {
75 FIXED_REG_ID_MAX8903, 76 FIXED_REG_ID_MAX8903,
76 FIXED_REG_ID_CAM_A28V, 77 FIXED_REG_ID_CAM_A28V,
77 FIXED_REG_ID_CAM_12V, 78 FIXED_REG_ID_CAM_12V,
79 FIXED_REG_ID_CAM_VT_15V,
78}; 80};
79 81
80static struct s3c2410_uartcfg nuri_uartcfgs[] __initdata = { 82static struct s3c2410_uartcfg nuri_uartcfgs[] __initdata = {
@@ -115,7 +117,7 @@ static struct s3c_sdhci_platdata nuri_hsmmc0_data __initdata = {
115}; 117};
116 118
117static struct regulator_consumer_supply emmc_supplies[] = { 119static struct regulator_consumer_supply emmc_supplies[] = {
118 REGULATOR_SUPPLY("vmmc", "s3c-sdhci.0"), 120 REGULATOR_SUPPLY("vmmc", "exynos4-sdhci.0"),
119 REGULATOR_SUPPLY("vmmc", "dw_mmc"), 121 REGULATOR_SUPPLY("vmmc", "dw_mmc"),
120}; 122};
121 123
@@ -399,6 +401,9 @@ static struct regulator_consumer_supply __initdata max8997_ldo4_[] = {
399static struct regulator_consumer_supply __initdata max8997_ldo5_[] = { 401static struct regulator_consumer_supply __initdata max8997_ldo5_[] = {
400 REGULATOR_SUPPLY("vhsic", "modemctl"), /* MODEM */ 402 REGULATOR_SUPPLY("vhsic", "modemctl"), /* MODEM */
401}; 403};
404static struct regulator_consumer_supply nuri_max8997_ldo6_consumer[] = {
405 REGULATOR_SUPPLY("vdd_reg", "6-003c"), /* S5K6AA camera */
406};
402static struct regulator_consumer_supply __initdata max8997_ldo7_[] = { 407static struct regulator_consumer_supply __initdata max8997_ldo7_[] = {
403 REGULATOR_SUPPLY("dig_18", "0-001f"), /* HCD803 */ 408 REGULATOR_SUPPLY("dig_18", "0-001f"), /* HCD803 */
404}; 409};
@@ -413,7 +418,7 @@ static struct regulator_consumer_supply __initdata max8997_ldo12_[] = {
413 REGULATOR_SUPPLY("vddio", "6-003c"), /* HDC802 */ 418 REGULATOR_SUPPLY("vddio", "6-003c"), /* HDC802 */
414}; 419};
415static struct regulator_consumer_supply __initdata max8997_ldo13_[] = { 420static struct regulator_consumer_supply __initdata max8997_ldo13_[] = {
416 REGULATOR_SUPPLY("vmmc", "s3c-sdhci.2"), /* TFLASH */ 421 REGULATOR_SUPPLY("vmmc", "exynos4-sdhci.2"), /* TFLASH */
417}; 422};
418static struct regulator_consumer_supply __initdata max8997_ldo14_[] = { 423static struct regulator_consumer_supply __initdata max8997_ldo14_[] = {
419 REGULATOR_SUPPLY("inmotor", "max8997-haptic"), 424 REGULATOR_SUPPLY("inmotor", "max8997-haptic"),
@@ -431,7 +436,7 @@ static struct regulator_consumer_supply __initdata max8997_buck1_[] = {
431 REGULATOR_SUPPLY("vdd_arm", NULL), /* CPUFREQ */ 436 REGULATOR_SUPPLY("vdd_arm", NULL), /* CPUFREQ */
432}; 437};
433static struct regulator_consumer_supply __initdata max8997_buck2_[] = { 438static struct regulator_consumer_supply __initdata max8997_buck2_[] = {
434 REGULATOR_SUPPLY("vdd_int", NULL), /* CPUFREQ */ 439 REGULATOR_SUPPLY("vdd_int", "exynos4210-busfreq.0"), /* CPUFREQ */
435}; 440};
436static struct regulator_consumer_supply __initdata max8997_buck3_[] = { 441static struct regulator_consumer_supply __initdata max8997_buck3_[] = {
437 REGULATOR_SUPPLY("vdd", "mali_dev.0"), /* G3D of Exynos 4 */ 442 REGULATOR_SUPPLY("vdd", "mali_dev.0"), /* G3D of Exynos 4 */
@@ -546,6 +551,8 @@ static struct regulator_init_data __initdata max8997_ldo6_data = {
546 .enabled = 1, 551 .enabled = 1,
547 }, 552 },
548 }, 553 },
554 .num_consumer_supplies = ARRAY_SIZE(nuri_max8997_ldo6_consumer),
555 .consumer_supplies = nuri_max8997_ldo6_consumer,
549}; 556};
550 557
551static struct regulator_init_data __initdata max8997_ldo7_data = { 558static struct regulator_init_data __initdata max8997_ldo7_data = {
@@ -742,7 +749,7 @@ static struct regulator_init_data __initdata max8997_buck2_data = {
742 .constraints = { 749 .constraints = {
743 .name = "VINT_1.1V_C210", 750 .name = "VINT_1.1V_C210",
744 .min_uV = 900000, 751 .min_uV = 900000,
745 .max_uV = 1100000, 752 .max_uV = 1200000,
746 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE, 753 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
747 .always_on = 1, 754 .always_on = 1,
748 .state_mem = { 755 .state_mem = {
@@ -957,7 +964,6 @@ static struct max8997_platform_data __initdata nuri_max8997_pdata = {
957 .regulators = nuri_max8997_regulators, 964 .regulators = nuri_max8997_regulators,
958 965
959 .buck125_gpios = { EXYNOS4_GPX0(5), EXYNOS4_GPX0(6), EXYNOS4_GPL0(0) }, 966 .buck125_gpios = { EXYNOS4_GPX0(5), EXYNOS4_GPX0(6), EXYNOS4_GPL0(0) },
960 .buck2_gpiodvs = true,
961 967
962 .buck1_voltage[0] = 1350000, /* 1.35V */ 968 .buck1_voltage[0] = 1350000, /* 1.35V */
963 .buck1_voltage[1] = 1300000, /* 1.3V */ 969 .buck1_voltage[1] = 1300000, /* 1.3V */
@@ -1116,7 +1122,30 @@ static void __init nuri_ehci_init(void)
1116} 1122}
1117 1123
1118/* CAMERA */ 1124/* CAMERA */
1125static struct regulator_consumer_supply cam_vt_cam15_supply =
1126 REGULATOR_SUPPLY("vdd_core", "6-003c");
1127
1128static struct regulator_init_data cam_vt_cam15_reg_init_data = {
1129 .constraints = { .valid_ops_mask = REGULATOR_CHANGE_STATUS },
1130 .num_consumer_supplies = 1,
1131 .consumer_supplies = &cam_vt_cam15_supply,
1132};
1133
1134static struct fixed_voltage_config cam_vt_cam15_fixed_voltage_cfg = {
1135 .supply_name = "VT_CAM_1.5V",
1136 .microvolts = 1500000,
1137 .gpio = EXYNOS4_GPE2(2), /* VT_CAM_1.5V_EN */
1138 .enable_high = 1,
1139 .init_data = &cam_vt_cam15_reg_init_data,
1140};
1141
1142static struct platform_device cam_vt_cam15_fixed_rdev = {
1143 .name = "reg-fixed-voltage", .id = FIXED_REG_ID_CAM_VT_15V,
1144 .dev = { .platform_data = &cam_vt_cam15_fixed_voltage_cfg },
1145};
1146
1119static struct regulator_consumer_supply cam_vdda_supply[] = { 1147static struct regulator_consumer_supply cam_vdda_supply[] = {
1148 REGULATOR_SUPPLY("vdda", "6-003c"),
1120 REGULATOR_SUPPLY("a_sensor", "0-001f"), 1149 REGULATOR_SUPPLY("a_sensor", "0-001f"),
1121}; 1150};
1122 1151
@@ -1173,6 +1202,21 @@ static struct s5p_platform_mipi_csis mipi_csis_platdata = {
1173 1202
1174#define GPIO_CAM_MEGA_RST EXYNOS4_GPY3(7) /* ISP_RESET */ 1203#define GPIO_CAM_MEGA_RST EXYNOS4_GPY3(7) /* ISP_RESET */
1175#define GPIO_CAM_8M_ISP_INT EXYNOS4_GPL2(5) 1204#define GPIO_CAM_8M_ISP_INT EXYNOS4_GPL2(5)
1205#define GPIO_CAM_VT_NSTBY EXYNOS4_GPL2(0)
1206#define GPIO_CAM_VT_NRST EXYNOS4_GPL2(1)
1207
1208static struct s5k6aa_platform_data s5k6aa_pldata = {
1209 .mclk_frequency = 24000000UL,
1210 .gpio_reset = { GPIO_CAM_VT_NRST, 0 },
1211 .gpio_stby = { GPIO_CAM_VT_NSTBY, 0 },
1212 .bus_type = V4L2_MBUS_PARALLEL,
1213 .horiz_flip = 1,
1214};
1215
1216static struct i2c_board_info s5k6aa_board_info = {
1217 I2C_BOARD_INFO("S5K6AA", 0x3c),
1218 .platform_data = &s5k6aa_pldata,
1219};
1176 1220
1177static struct m5mols_platform_data m5mols_platdata = { 1221static struct m5mols_platform_data m5mols_platdata = {
1178 .gpio_reset = GPIO_CAM_MEGA_RST, 1222 .gpio_reset = GPIO_CAM_MEGA_RST,
@@ -1185,6 +1229,13 @@ static struct i2c_board_info m5mols_board_info = {
1185 1229
1186static struct s5p_fimc_isp_info nuri_camera_sensors[] = { 1230static struct s5p_fimc_isp_info nuri_camera_sensors[] = {
1187 { 1231 {
1232 .flags = V4L2_MBUS_PCLK_SAMPLE_RISING |
1233 V4L2_MBUS_VSYNC_ACTIVE_LOW,
1234 .bus_type = FIMC_ITU_601,
1235 .board_info = &s5k6aa_board_info,
1236 .clk_frequency = 24000000UL,
1237 .i2c_bus_num = 6,
1238 }, {
1188 .flags = V4L2_MBUS_PCLK_SAMPLE_FALLING | 1239 .flags = V4L2_MBUS_PCLK_SAMPLE_FALLING |
1189 V4L2_MBUS_VSYNC_ACTIVE_LOW, 1240 V4L2_MBUS_VSYNC_ACTIVE_LOW,
1190 .bus_type = FIMC_MIPI_CSI2, 1241 .bus_type = FIMC_MIPI_CSI2,
@@ -1200,11 +1251,13 @@ static struct s5p_platform_fimc fimc_md_platdata = {
1200}; 1251};
1201 1252
1202static struct gpio nuri_camera_gpios[] = { 1253static struct gpio nuri_camera_gpios[] = {
1254 { GPIO_CAM_VT_NSTBY, GPIOF_OUT_INIT_LOW, "CAM_VGA_NSTBY" },
1255 { GPIO_CAM_VT_NRST, GPIOF_OUT_INIT_LOW, "CAM_VGA_NRST" },
1203 { GPIO_CAM_8M_ISP_INT, GPIOF_IN, "8M_ISP_INT" }, 1256 { GPIO_CAM_8M_ISP_INT, GPIOF_IN, "8M_ISP_INT" },
1204 { GPIO_CAM_MEGA_RST, GPIOF_OUT_INIT_LOW, "CAM_8M_NRST" }, 1257 { GPIO_CAM_MEGA_RST, GPIOF_OUT_INIT_LOW, "CAM_8M_NRST" },
1205}; 1258};
1206 1259
1207static void nuri_camera_init(void) 1260static void __init nuri_camera_init(void)
1208{ 1261{
1209 s3c_set_platdata(&mipi_csis_platdata, sizeof(mipi_csis_platdata), 1262 s3c_set_platdata(&mipi_csis_platdata, sizeof(mipi_csis_platdata),
1210 &s5p_device_mipi_csis0); 1263 &s5p_device_mipi_csis0);
@@ -1224,6 +1277,8 @@ static void nuri_camera_init(void)
1224 pr_err("%s: Failed to configure 8M_ISP_INT GPIO\n", __func__); 1277 pr_err("%s: Failed to configure 8M_ISP_INT GPIO\n", __func__);
1225 1278
1226 /* Free GPIOs controlled directly by the sensor drivers. */ 1279 /* Free GPIOs controlled directly by the sensor drivers. */
1280 gpio_free(GPIO_CAM_VT_NRST);
1281 gpio_free(GPIO_CAM_VT_NSTBY);
1227 gpio_free(GPIO_CAM_MEGA_RST); 1282 gpio_free(GPIO_CAM_MEGA_RST);
1228 1283
1229 if (exynos4_fimc_setup_gpio(S5P_CAMPORT_A)) { 1284 if (exynos4_fimc_setup_gpio(S5P_CAMPORT_A)) {
@@ -1234,15 +1289,27 @@ static void nuri_camera_init(void)
1234 s5p_gpio_set_drvstr(EXYNOS4_GPJ1(3), S5P_GPIO_DRVSTR_LV4); 1289 s5p_gpio_set_drvstr(EXYNOS4_GPJ1(3), S5P_GPIO_DRVSTR_LV4);
1235} 1290}
1236 1291
1292static struct s3c2410_platform_i2c nuri_i2c6_platdata __initdata = {
1293 .frequency = 400000U,
1294 .sda_delay = 200,
1295 .bus_num = 6,
1296};
1297
1237static struct s3c2410_platform_i2c nuri_i2c0_platdata __initdata = { 1298static struct s3c2410_platform_i2c nuri_i2c0_platdata __initdata = {
1238 .frequency = 400000U, 1299 .frequency = 400000U,
1239 .sda_delay = 200, 1300 .sda_delay = 200,
1240}; 1301};
1241 1302
1303/* DEVFREQ controlling memory/bus */
1304static struct platform_device exynos4_bus_devfreq = {
1305 .name = "exynos4210-busfreq",
1306};
1307
1242static struct platform_device *nuri_devices[] __initdata = { 1308static struct platform_device *nuri_devices[] __initdata = {
1243 /* Samsung Platform Devices */ 1309 /* Samsung Platform Devices */
1244 &s3c_device_i2c5, /* PMIC should initialize first */ 1310 &s3c_device_i2c5, /* PMIC should initialize first */
1245 &s3c_device_i2c0, 1311 &s3c_device_i2c0,
1312 &s3c_device_i2c6,
1246 &emmc_fixed_voltage, 1313 &emmc_fixed_voltage,
1247 &s5p_device_mipi_csis0, 1314 &s5p_device_mipi_csis0,
1248 &s5p_device_fimc0, 1315 &s5p_device_fimc0,
@@ -1259,6 +1326,8 @@ static struct platform_device *nuri_devices[] __initdata = {
1259 &s3c_device_i2c3, 1326 &s3c_device_i2c3,
1260 &i2c9_gpio, 1327 &i2c9_gpio,
1261 &s3c_device_adc, 1328 &s3c_device_adc,
1329 &s5p_device_g2d,
1330 &s5p_device_jpeg,
1262 &s3c_device_rtc, 1331 &s3c_device_rtc,
1263 &s5p_device_mfc, 1332 &s5p_device_mfc,
1264 &s5p_device_mfc_l, 1333 &s5p_device_mfc_l,
@@ -1271,8 +1340,10 @@ static struct platform_device *nuri_devices[] __initdata = {
1271 &nuri_backlight_device, 1340 &nuri_backlight_device,
1272 &max8903_fixed_reg_dev, 1341 &max8903_fixed_reg_dev,
1273 &nuri_max8903_device, 1342 &nuri_max8903_device,
1343 &cam_vt_cam15_fixed_rdev,
1274 &cam_vdda_fixed_rdev, 1344 &cam_vdda_fixed_rdev,
1275 &cam_8m_12v_fixed_rdev, 1345 &cam_8m_12v_fixed_rdev,
1346 &exynos4_bus_devfreq,
1276}; 1347};
1277 1348
1278static void __init nuri_map_io(void) 1349static void __init nuri_map_io(void)
@@ -1302,6 +1373,7 @@ static void __init nuri_machine_init(void)
1302 i2c_register_board_info(5, i2c5_devs, ARRAY_SIZE(i2c5_devs)); 1373 i2c_register_board_info(5, i2c5_devs, ARRAY_SIZE(i2c5_devs));
1303 i2c9_devs[I2C9_MAX17042].irq = gpio_to_irq(EXYNOS4_GPX2(3)); 1374 i2c9_devs[I2C9_MAX17042].irq = gpio_to_irq(EXYNOS4_GPX2(3));
1304 i2c_register_board_info(9, i2c9_devs, ARRAY_SIZE(i2c9_devs)); 1375 i2c_register_board_info(9, i2c9_devs, ARRAY_SIZE(i2c9_devs));
1376 s3c_i2c6_set_platdata(&nuri_i2c6_platdata);
1305 1377
1306 s5p_fimd0_set_platdata(&nuri_fb_pdata); 1378 s5p_fimd0_set_platdata(&nuri_fb_pdata);
1307 1379
diff --git a/arch/arm/mach-exynos/mach-origen.c b/arch/arm/mach-exynos/mach-origen.c
index fa5c4a59b0a..878d4c99142 100644
--- a/arch/arm/mach-exynos/mach-origen.c
+++ b/arch/arm/mach-exynos/mach-origen.c
@@ -20,6 +20,7 @@
20#include <linux/regulator/machine.h> 20#include <linux/regulator/machine.h>
21#include <linux/mfd/max8997.h> 21#include <linux/mfd/max8997.h>
22#include <linux/lcd.h> 22#include <linux/lcd.h>
23#include <linux/rfkill-gpio.h>
23 24
24#include <asm/mach/arch.h> 25#include <asm/mach/arch.h>
25#include <asm/hardware/gic.h> 26#include <asm/hardware/gic.h>
@@ -235,6 +236,7 @@ static struct regulator_init_data __initdata max8997_ldo9_data = {
235 .min_uV = 2800000, 236 .min_uV = 2800000,
236 .max_uV = 2800000, 237 .max_uV = 2800000,
237 .apply_uV = 1, 238 .apply_uV = 1,
239 .always_on = 1,
238 .valid_ops_mask = REGULATOR_CHANGE_STATUS, 240 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
239 .state_mem = { 241 .state_mem = {
240 .disabled = 1, 242 .disabled = 1,
@@ -278,6 +280,7 @@ static struct regulator_init_data __initdata max8997_ldo14_data = {
278 .min_uV = 1800000, 280 .min_uV = 1800000,
279 .max_uV = 1800000, 281 .max_uV = 1800000,
280 .apply_uV = 1, 282 .apply_uV = 1,
283 .always_on = 1,
281 .valid_ops_mask = REGULATOR_CHANGE_STATUS, 284 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
282 .state_mem = { 285 .state_mem = {
283 .disabled = 1, 286 .disabled = 1,
@@ -293,6 +296,7 @@ static struct regulator_init_data __initdata max8997_ldo17_data = {
293 .min_uV = 3300000, 296 .min_uV = 3300000,
294 .max_uV = 3300000, 297 .max_uV = 3300000,
295 .apply_uV = 1, 298 .apply_uV = 1,
299 .always_on = 1,
296 .valid_ops_mask = REGULATOR_CHANGE_STATUS, 300 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
297 .state_mem = { 301 .state_mem = {
298 .disabled = 1, 302 .disabled = 1,
@@ -412,7 +416,7 @@ static struct max8997_regulator_data __initdata origen_max8997_regulators[] = {
412 { MAX8997_BUCK7, &max8997_buck7_data }, 416 { MAX8997_BUCK7, &max8997_buck7_data },
413}; 417};
414 418
415struct max8997_platform_data __initdata origen_max8997_pdata = { 419static struct max8997_platform_data __initdata origen_max8997_pdata = {
416 .num_regulators = ARRAY_SIZE(origen_max8997_regulators), 420 .num_regulators = ARRAY_SIZE(origen_max8997_regulators),
417 .regulators = origen_max8997_regulators, 421 .regulators = origen_max8997_regulators,
418 422
@@ -602,6 +606,23 @@ static struct s3c_fb_platdata origen_lcd_pdata __initdata = {
602 .setup_gpio = exynos4_fimd0_gpio_setup_24bpp, 606 .setup_gpio = exynos4_fimd0_gpio_setup_24bpp,
603}; 607};
604 608
609/* Bluetooth rfkill gpio platform data */
610struct rfkill_gpio_platform_data origen_bt_pdata = {
611 .reset_gpio = EXYNOS4_GPX2(2),
612 .shutdown_gpio = -1,
613 .type = RFKILL_TYPE_BLUETOOTH,
614 .name = "origen-bt",
615};
616
617/* Bluetooth Platform device */
618static struct platform_device origen_device_bluetooth = {
619 .name = "rfkill_gpio",
620 .id = -1,
621 .dev = {
622 .platform_data = &origen_bt_pdata,
623 },
624};
625
605static struct platform_device *origen_devices[] __initdata = { 626static struct platform_device *origen_devices[] __initdata = {
606 &s3c_device_hsmmc2, 627 &s3c_device_hsmmc2,
607 &s3c_device_hsmmc0, 628 &s3c_device_hsmmc0,
@@ -613,9 +634,12 @@ static struct platform_device *origen_devices[] __initdata = {
613 &s5p_device_fimc1, 634 &s5p_device_fimc1,
614 &s5p_device_fimc2, 635 &s5p_device_fimc2,
615 &s5p_device_fimc3, 636 &s5p_device_fimc3,
637 &s5p_device_fimc_md,
616 &s5p_device_fimd0, 638 &s5p_device_fimd0,
639 &s5p_device_g2d,
617 &s5p_device_hdmi, 640 &s5p_device_hdmi,
618 &s5p_device_i2c_hdmiphy, 641 &s5p_device_i2c_hdmiphy,
642 &s5p_device_jpeg,
619 &s5p_device_mfc, 643 &s5p_device_mfc,
620 &s5p_device_mfc_l, 644 &s5p_device_mfc_l,
621 &s5p_device_mfc_r, 645 &s5p_device_mfc_r,
@@ -623,6 +647,7 @@ static struct platform_device *origen_devices[] __initdata = {
623 &exynos4_device_ohci, 647 &exynos4_device_ohci,
624 &origen_device_gpiokeys, 648 &origen_device_gpiokeys,
625 &origen_lcd_hv070wsa, 649 &origen_lcd_hv070wsa,
650 &origen_device_bluetooth,
626}; 651};
627 652
628/* LCD Backlight data */ 653/* LCD Backlight data */
@@ -636,6 +661,16 @@ static struct platform_pwm_backlight_data origen_bl_data = {
636 .pwm_period_ns = 1000, 661 .pwm_period_ns = 1000,
637}; 662};
638 663
664static void __init origen_bt_setup(void)
665{
666 gpio_request(EXYNOS4_GPA0(0), "GPIO BT_UART");
667 /* 4 UART Pins configuration */
668 s3c_gpio_cfgrange_nopull(EXYNOS4_GPA0(0), 4, S3C_GPIO_SFN(2));
669 /* Setup BT Reset, this gpio will be requesed by rfkill-gpio */
670 s3c_gpio_cfgpin(EXYNOS4_GPX2(2), S3C_GPIO_OUTPUT);
671 s3c_gpio_setpull(EXYNOS4_GPX2(2), S3C_GPIO_PULL_NONE);
672}
673
639static void s5p_tv_setup(void) 674static void s5p_tv_setup(void)
640{ 675{
641 /* Direct HPD to HDMI chip */ 676 /* Direct HPD to HDMI chip */
@@ -689,6 +724,8 @@ static void __init origen_machine_init(void)
689 platform_add_devices(origen_devices, ARRAY_SIZE(origen_devices)); 724 platform_add_devices(origen_devices, ARRAY_SIZE(origen_devices));
690 725
691 samsung_bl_set(&origen_bl_gpio_info, &origen_bl_data); 726 samsung_bl_set(&origen_bl_gpio_info, &origen_bl_data);
727
728 origen_bt_setup();
692} 729}
693 730
694MACHINE_START(ORIGEN, "ORIGEN") 731MACHINE_START(ORIGEN, "ORIGEN")
diff --git a/arch/arm/mach-exynos/mach-smdkv310.c b/arch/arm/mach-exynos/mach-smdkv310.c
index 5258b856367..83b91fa777c 100644
--- a/arch/arm/mach-exynos/mach-smdkv310.c
+++ b/arch/arm/mach-exynos/mach-smdkv310.c
@@ -270,6 +270,9 @@ static struct platform_device *smdkv310_devices[] __initdata = {
270 &s5p_device_fimc1, 270 &s5p_device_fimc1,
271 &s5p_device_fimc2, 271 &s5p_device_fimc2,
272 &s5p_device_fimc3, 272 &s5p_device_fimc3,
273 &s5p_device_fimc_md,
274 &s5p_device_g2d,
275 &s5p_device_jpeg,
273 &exynos4_device_ac97, 276 &exynos4_device_ac97,
274 &exynos4_device_i2s0, 277 &exynos4_device_i2s0,
275 &exynos4_device_ohci, 278 &exynos4_device_ohci,
diff --git a/arch/arm/mach-exynos/mach-universal_c210.c b/arch/arm/mach-exynos/mach-universal_c210.c
index b2d495b3109..28658da9f42 100644
--- a/arch/arm/mach-exynos/mach-universal_c210.c
+++ b/arch/arm/mach-exynos/mach-universal_c210.c
@@ -47,6 +47,7 @@
47#include <media/v4l2-mediabus.h> 47#include <media/v4l2-mediabus.h>
48#include <media/s5p_fimc.h> 48#include <media/s5p_fimc.h>
49#include <media/m5mols.h> 49#include <media/m5mols.h>
50#include <media/s5k6aa.h>
50 51
51#include "common.h" 52#include "common.h"
52 53
@@ -123,8 +124,10 @@ static struct regulator_consumer_supply lp3974_buck1_consumer =
123static struct regulator_consumer_supply lp3974_buck2_consumer = 124static struct regulator_consumer_supply lp3974_buck2_consumer =
124 REGULATOR_SUPPLY("vddg3d", NULL); 125 REGULATOR_SUPPLY("vddg3d", NULL);
125 126
126static struct regulator_consumer_supply lp3974_buck3_consumer = 127static struct regulator_consumer_supply lp3974_buck3_consumer[] = {
127 REGULATOR_SUPPLY("vdet", "s5p-sdo"); 128 REGULATOR_SUPPLY("vdet", "s5p-sdo"),
129 REGULATOR_SUPPLY("vdd_reg", "0-003c"),
130};
128 131
129static struct regulator_init_data lp3974_buck1_data = { 132static struct regulator_init_data lp3974_buck1_data = {
130 .constraints = { 133 .constraints = {
@@ -169,8 +172,8 @@ static struct regulator_init_data lp3974_buck3_data = {
169 .enabled = 1, 172 .enabled = 1,
170 }, 173 },
171 }, 174 },
172 .num_consumer_supplies = 1, 175 .num_consumer_supplies = ARRAY_SIZE(lp3974_buck3_consumer),
173 .consumer_supplies = &lp3974_buck3_consumer, 176 .consumer_supplies = lp3974_buck3_consumer,
174}; 177};
175 178
176static struct regulator_init_data lp3974_buck4_data = { 179static struct regulator_init_data lp3974_buck4_data = {
@@ -303,6 +306,9 @@ static struct regulator_init_data lp3974_ldo8_data = {
303 .consumer_supplies = lp3974_ldo8_consumer, 306 .consumer_supplies = lp3974_ldo8_consumer,
304}; 307};
305 308
309static struct regulator_consumer_supply lp3974_ldo9_consumer =
310 REGULATOR_SUPPLY("vddio", "0-003c");
311
306static struct regulator_init_data lp3974_ldo9_data = { 312static struct regulator_init_data lp3974_ldo9_data = {
307 .constraints = { 313 .constraints = {
308 .name = "VCC_2.8V", 314 .name = "VCC_2.8V",
@@ -314,6 +320,8 @@ static struct regulator_init_data lp3974_ldo9_data = {
314 .enabled = 1, 320 .enabled = 1,
315 }, 321 },
316 }, 322 },
323 .num_consumer_supplies = 1,
324 .consumer_supplies = &lp3974_ldo9_consumer,
317}; 325};
318 326
319static struct regulator_init_data lp3974_ldo10_data = { 327static struct regulator_init_data lp3974_ldo10_data = {
@@ -412,6 +420,7 @@ static struct regulator_init_data lp3974_ldo15_data = {
412}; 420};
413 421
414static struct regulator_consumer_supply lp3974_ldo16_consumer[] = { 422static struct regulator_consumer_supply lp3974_ldo16_consumer[] = {
423 REGULATOR_SUPPLY("vdda", "0-003c"),
415 REGULATOR_SUPPLY("a_sensor", "0-001f"), 424 REGULATOR_SUPPLY("a_sensor", "0-001f"),
416}; 425};
417 426
@@ -743,7 +752,7 @@ static struct s3c_sdhci_platdata universal_hsmmc0_data __initdata = {
743}; 752};
744 753
745static struct regulator_consumer_supply mmc0_supplies[] = { 754static struct regulator_consumer_supply mmc0_supplies[] = {
746 REGULATOR_SUPPLY("vmmc", "s3c-sdhci.0"), 755 REGULATOR_SUPPLY("vmmc", "exynos4-sdhci.0"),
747}; 756};
748 757
749static struct regulator_init_data mmc0_fixed_voltage_init_data = { 758static struct regulator_init_data mmc0_fixed_voltage_init_data = {
@@ -819,6 +828,8 @@ static struct s3c_fb_pd_win universal_fb_win0 = {
819 }, 828 },
820 .max_bpp = 32, 829 .max_bpp = 32,
821 .default_bpp = 16, 830 .default_bpp = 16,
831 .virtual_x = 480,
832 .virtual_y = 2 * 800,
822}; 833};
823 834
824static struct s3c_fb_platdata universal_lcd_pdata __initdata = { 835static struct s3c_fb_platdata universal_lcd_pdata __initdata = {
@@ -830,6 +841,28 @@ static struct s3c_fb_platdata universal_lcd_pdata __initdata = {
830 .setup_gpio = exynos4_fimd0_gpio_setup_24bpp, 841 .setup_gpio = exynos4_fimd0_gpio_setup_24bpp,
831}; 842};
832 843
844static struct regulator_consumer_supply cam_vt_dio_supply =
845 REGULATOR_SUPPLY("vdd_core", "0-003c");
846
847static struct regulator_init_data cam_vt_dio_reg_init_data = {
848 .constraints = { .valid_ops_mask = REGULATOR_CHANGE_STATUS },
849 .num_consumer_supplies = 1,
850 .consumer_supplies = &cam_vt_dio_supply,
851};
852
853static struct fixed_voltage_config cam_vt_dio_fixed_voltage_cfg = {
854 .supply_name = "CAM_VT_D_IO",
855 .microvolts = 2800000,
856 .gpio = EXYNOS4_GPE2(1), /* CAM_PWR_EN2 */
857 .enable_high = 1,
858 .init_data = &cam_vt_dio_reg_init_data,
859};
860
861static struct platform_device cam_vt_dio_fixed_reg_dev = {
862 .name = "reg-fixed-voltage", .id = FIXED_REG_ID_CAM_VT_DIO,
863 .dev = { .platform_data = &cam_vt_dio_fixed_voltage_cfg },
864};
865
833static struct regulator_consumer_supply cam_i_core_supply = 866static struct regulator_consumer_supply cam_i_core_supply =
834 REGULATOR_SUPPLY("core", "0-001f"); 867 REGULATOR_SUPPLY("core", "0-001f");
835 868
@@ -885,6 +918,28 @@ static struct s5p_platform_mipi_csis mipi_csis_platdata = {
885#define GPIO_CAM_LEVEL_EN(n) EXYNOS4_GPE4(n + 3) 918#define GPIO_CAM_LEVEL_EN(n) EXYNOS4_GPE4(n + 3)
886#define GPIO_CAM_8M_ISP_INT EXYNOS4_GPX1(5) /* XEINT_13 */ 919#define GPIO_CAM_8M_ISP_INT EXYNOS4_GPX1(5) /* XEINT_13 */
887#define GPIO_CAM_MEGA_nRST EXYNOS4_GPE2(5) 920#define GPIO_CAM_MEGA_nRST EXYNOS4_GPE2(5)
921#define GPIO_CAM_VGA_NRST EXYNOS4_GPE4(7)
922#define GPIO_CAM_VGA_NSTBY EXYNOS4_GPE4(6)
923
924static int s5k6aa_set_power(int on)
925{
926 gpio_set_value(GPIO_CAM_LEVEL_EN(2), !!on);
927 return 0;
928}
929
930static struct s5k6aa_platform_data s5k6aa_platdata = {
931 .mclk_frequency = 21600000UL,
932 .gpio_reset = { GPIO_CAM_VGA_NRST, 0 },
933 .gpio_stby = { GPIO_CAM_VGA_NSTBY, 0 },
934 .bus_type = V4L2_MBUS_PARALLEL,
935 .horiz_flip = 1,
936 .set_power = s5k6aa_set_power,
937};
938
939static struct i2c_board_info s5k6aa_board_info = {
940 I2C_BOARD_INFO("S5K6AA", 0x3C),
941 .platform_data = &s5k6aa_platdata,
942};
888 943
889static int m5mols_set_power(struct device *dev, int on) 944static int m5mols_set_power(struct device *dev, int on)
890{ 945{
@@ -909,6 +964,14 @@ static struct s5p_fimc_isp_info universal_camera_sensors[] = {
909 .mux_id = 0, 964 .mux_id = 0,
910 .flags = V4L2_MBUS_PCLK_SAMPLE_FALLING | 965 .flags = V4L2_MBUS_PCLK_SAMPLE_FALLING |
911 V4L2_MBUS_VSYNC_ACTIVE_LOW, 966 V4L2_MBUS_VSYNC_ACTIVE_LOW,
967 .bus_type = FIMC_ITU_601,
968 .board_info = &s5k6aa_board_info,
969 .i2c_bus_num = 0,
970 .clk_frequency = 24000000UL,
971 }, {
972 .mux_id = 0,
973 .flags = V4L2_MBUS_PCLK_SAMPLE_FALLING |
974 V4L2_MBUS_VSYNC_ACTIVE_LOW,
912 .bus_type = FIMC_MIPI_CSI2, 975 .bus_type = FIMC_MIPI_CSI2,
913 .board_info = &m5mols_board_info, 976 .board_info = &m5mols_board_info,
914 .i2c_bus_num = 0, 977 .i2c_bus_num = 0,
@@ -927,9 +990,11 @@ static struct gpio universal_camera_gpios[] = {
927 { GPIO_CAM_LEVEL_EN(2), GPIOF_OUT_INIT_LOW, "CAM_LVL_EN2" }, 990 { GPIO_CAM_LEVEL_EN(2), GPIOF_OUT_INIT_LOW, "CAM_LVL_EN2" },
928 { GPIO_CAM_8M_ISP_INT, GPIOF_IN, "8M_ISP_INT" }, 991 { GPIO_CAM_8M_ISP_INT, GPIOF_IN, "8M_ISP_INT" },
929 { GPIO_CAM_MEGA_nRST, GPIOF_OUT_INIT_LOW, "CAM_8M_NRST" }, 992 { GPIO_CAM_MEGA_nRST, GPIOF_OUT_INIT_LOW, "CAM_8M_NRST" },
993 { GPIO_CAM_VGA_NRST, GPIOF_OUT_INIT_LOW, "CAM_VGA_NRST" },
994 { GPIO_CAM_VGA_NSTBY, GPIOF_OUT_INIT_LOW, "CAM_VGA_NSTBY" },
930}; 995};
931 996
932static void universal_camera_init(void) 997static void __init universal_camera_init(void)
933{ 998{
934 s3c_set_platdata(&mipi_csis_platdata, sizeof(mipi_csis_platdata), 999 s3c_set_platdata(&mipi_csis_platdata, sizeof(mipi_csis_platdata),
935 &s5p_device_mipi_csis0); 1000 &s5p_device_mipi_csis0);
@@ -950,6 +1015,8 @@ static void universal_camera_init(void)
950 /* Free GPIOs controlled directly by the sensor drivers. */ 1015 /* Free GPIOs controlled directly by the sensor drivers. */
951 gpio_free(GPIO_CAM_MEGA_nRST); 1016 gpio_free(GPIO_CAM_MEGA_nRST);
952 gpio_free(GPIO_CAM_8M_ISP_INT); 1017 gpio_free(GPIO_CAM_8M_ISP_INT);
1018 gpio_free(GPIO_CAM_VGA_NRST);
1019 gpio_free(GPIO_CAM_VGA_NSTBY);
953 1020
954 if (exynos4_fimc_setup_gpio(S5P_CAMPORT_A)) 1021 if (exynos4_fimc_setup_gpio(S5P_CAMPORT_A))
955 pr_err("Camera port A setup failed\n"); 1022 pr_err("Camera port A setup failed\n");
@@ -962,6 +1029,7 @@ static struct platform_device *universal_devices[] __initdata = {
962 &s5p_device_fimc1, 1029 &s5p_device_fimc1,
963 &s5p_device_fimc2, 1030 &s5p_device_fimc2,
964 &s5p_device_fimc3, 1031 &s5p_device_fimc3,
1032 &s5p_device_g2d,
965 &mmc0_fixed_voltage, 1033 &mmc0_fixed_voltage,
966 &s3c_device_hsmmc0, 1034 &s3c_device_hsmmc0,
967 &s3c_device_hsmmc2, 1035 &s3c_device_hsmmc2,
@@ -980,9 +1048,11 @@ static struct platform_device *universal_devices[] __initdata = {
980 &universal_gpio_keys, 1048 &universal_gpio_keys,
981 &s5p_device_onenand, 1049 &s5p_device_onenand,
982 &s5p_device_fimd0, 1050 &s5p_device_fimd0,
1051 &s5p_device_jpeg,
983 &s5p_device_mfc, 1052 &s5p_device_mfc,
984 &s5p_device_mfc_l, 1053 &s5p_device_mfc_l,
985 &s5p_device_mfc_r, 1054 &s5p_device_mfc_r,
1055 &cam_vt_dio_fixed_reg_dev,
986 &cam_i_core_fixed_reg_dev, 1056 &cam_i_core_fixed_reg_dev,
987 &cam_s_if_fixed_reg_dev, 1057 &cam_s_if_fixed_reg_dev,
988 &s5p_device_fimc_md, 1058 &s5p_device_fimc_md,
@@ -995,7 +1065,7 @@ static void __init universal_map_io(void)
995 s3c24xx_init_uarts(universal_uartcfgs, ARRAY_SIZE(universal_uartcfgs)); 1065 s3c24xx_init_uarts(universal_uartcfgs, ARRAY_SIZE(universal_uartcfgs));
996} 1066}
997 1067
998void s5p_tv_setup(void) 1068static void s5p_tv_setup(void)
999{ 1069{
1000 /* direct HPD to HDMI chip */ 1070 /* direct HPD to HDMI chip */
1001 gpio_request_one(EXYNOS4_GPX3(7), GPIOF_IN, "hpd-plug"); 1071 gpio_request_one(EXYNOS4_GPX3(7), GPIOF_IN, "hpd-plug");
diff --git a/arch/arm/mach-exynos/mct.c b/arch/arm/mach-exynos/mct.c
index 85b5527d091..897d9a9cf22 100644
--- a/arch/arm/mach-exynos/mct.c
+++ b/arch/arm/mach-exynos/mct.c
@@ -21,6 +21,7 @@
21#include <linux/percpu.h> 21#include <linux/percpu.h>
22 22
23#include <asm/hardware/gic.h> 23#include <asm/hardware/gic.h>
24#include <asm/localtimer.h>
24 25
25#include <plat/cpu.h> 26#include <plat/cpu.h>
26 27
@@ -29,12 +30,13 @@
29#include <mach/regs-mct.h> 30#include <mach/regs-mct.h>
30#include <asm/mach/time.h> 31#include <asm/mach/time.h>
31 32
33#define TICK_BASE_CNT 1
34
32enum { 35enum {
33 MCT_INT_SPI, 36 MCT_INT_SPI,
34 MCT_INT_PPI 37 MCT_INT_PPI
35}; 38};
36 39
37static unsigned long clk_cnt_per_tick;
38static unsigned long clk_rate; 40static unsigned long clk_rate;
39static unsigned int mct_int_type; 41static unsigned int mct_int_type;
40 42
@@ -205,11 +207,14 @@ static int exynos4_comp_set_next_event(unsigned long cycles,
205static void exynos4_comp_set_mode(enum clock_event_mode mode, 207static void exynos4_comp_set_mode(enum clock_event_mode mode,
206 struct clock_event_device *evt) 208 struct clock_event_device *evt)
207{ 209{
210 unsigned long cycles_per_jiffy;
208 exynos4_mct_comp0_stop(); 211 exynos4_mct_comp0_stop();
209 212
210 switch (mode) { 213 switch (mode) {
211 case CLOCK_EVT_MODE_PERIODIC: 214 case CLOCK_EVT_MODE_PERIODIC:
212 exynos4_mct_comp0_start(mode, clk_cnt_per_tick); 215 cycles_per_jiffy =
216 (((unsigned long long) NSEC_PER_SEC / HZ * evt->mult) >> evt->shift);
217 exynos4_mct_comp0_start(mode, cycles_per_jiffy);
213 break; 218 break;
214 219
215 case CLOCK_EVT_MODE_ONESHOT: 220 case CLOCK_EVT_MODE_ONESHOT:
@@ -248,9 +253,7 @@ static struct irqaction mct_comp_event_irq = {
248 253
249static void exynos4_clockevent_init(void) 254static void exynos4_clockevent_init(void)
250{ 255{
251 clk_cnt_per_tick = clk_rate / 2 / HZ; 256 clockevents_calc_mult_shift(&mct_comp_device, clk_rate, 5);
252
253 clockevents_calc_mult_shift(&mct_comp_device, clk_rate / 2, 5);
254 mct_comp_device.max_delta_ns = 257 mct_comp_device.max_delta_ns =
255 clockevent_delta2ns(0xffffffff, &mct_comp_device); 258 clockevent_delta2ns(0xffffffff, &mct_comp_device);
256 mct_comp_device.min_delta_ns = 259 mct_comp_device.min_delta_ns =
@@ -258,7 +261,10 @@ static void exynos4_clockevent_init(void)
258 mct_comp_device.cpumask = cpumask_of(0); 261 mct_comp_device.cpumask = cpumask_of(0);
259 clockevents_register_device(&mct_comp_device); 262 clockevents_register_device(&mct_comp_device);
260 263
261 setup_irq(IRQ_MCT_G0, &mct_comp_event_irq); 264 if (soc_is_exynos5250())
265 setup_irq(EXYNOS5_IRQ_MCT_G0, &mct_comp_event_irq);
266 else
267 setup_irq(EXYNOS4_IRQ_MCT_G0, &mct_comp_event_irq);
262} 268}
263 269
264#ifdef CONFIG_LOCAL_TIMERS 270#ifdef CONFIG_LOCAL_TIMERS
@@ -314,12 +320,15 @@ static inline void exynos4_tick_set_mode(enum clock_event_mode mode,
314 struct clock_event_device *evt) 320 struct clock_event_device *evt)
315{ 321{
316 struct mct_clock_event_device *mevt = this_cpu_ptr(&percpu_mct_tick); 322 struct mct_clock_event_device *mevt = this_cpu_ptr(&percpu_mct_tick);
323 unsigned long cycles_per_jiffy;
317 324
318 exynos4_mct_tick_stop(mevt); 325 exynos4_mct_tick_stop(mevt);
319 326
320 switch (mode) { 327 switch (mode) {
321 case CLOCK_EVT_MODE_PERIODIC: 328 case CLOCK_EVT_MODE_PERIODIC:
322 exynos4_mct_tick_start(clk_cnt_per_tick, mevt); 329 cycles_per_jiffy =
330 (((unsigned long long) NSEC_PER_SEC / HZ * evt->mult) >> evt->shift);
331 exynos4_mct_tick_start(cycles_per_jiffy, mevt);
323 break; 332 break;
324 333
325 case CLOCK_EVT_MODE_ONESHOT: 334 case CLOCK_EVT_MODE_ONESHOT:
@@ -375,7 +384,7 @@ static struct irqaction mct_tick1_event_irq = {
375 .handler = exynos4_mct_tick_isr, 384 .handler = exynos4_mct_tick_isr,
376}; 385};
377 386
378static void exynos4_mct_tick_init(struct clock_event_device *evt) 387static int __cpuinit exynos4_local_timer_setup(struct clock_event_device *evt)
379{ 388{
380 struct mct_clock_event_device *mevt; 389 struct mct_clock_event_device *mevt;
381 unsigned int cpu = smp_processor_id(); 390 unsigned int cpu = smp_processor_id();
@@ -393,7 +402,7 @@ static void exynos4_mct_tick_init(struct clock_event_device *evt)
393 evt->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT; 402 evt->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT;
394 evt->rating = 450; 403 evt->rating = 450;
395 404
396 clockevents_calc_mult_shift(evt, clk_rate / 2, 5); 405 clockevents_calc_mult_shift(evt, clk_rate / (TICK_BASE_CNT + 1), 5);
397 evt->max_delta_ns = 406 evt->max_delta_ns =
398 clockevent_delta2ns(0x7fffffff, evt); 407 clockevent_delta2ns(0x7fffffff, evt);
399 evt->min_delta_ns = 408 evt->min_delta_ns =
@@ -401,33 +410,27 @@ static void exynos4_mct_tick_init(struct clock_event_device *evt)
401 410
402 clockevents_register_device(evt); 411 clockevents_register_device(evt);
403 412
404 exynos4_mct_write(0x1, mevt->base + MCT_L_TCNTB_OFFSET); 413 exynos4_mct_write(TICK_BASE_CNT, mevt->base + MCT_L_TCNTB_OFFSET);
405 414
406 if (mct_int_type == MCT_INT_SPI) { 415 if (mct_int_type == MCT_INT_SPI) {
407 if (cpu == 0) { 416 if (cpu == 0) {
408 mct_tick0_event_irq.dev_id = mevt; 417 mct_tick0_event_irq.dev_id = mevt;
409 evt->irq = IRQ_MCT_L0; 418 evt->irq = EXYNOS4_IRQ_MCT_L0;
410 setup_irq(IRQ_MCT_L0, &mct_tick0_event_irq); 419 setup_irq(EXYNOS4_IRQ_MCT_L0, &mct_tick0_event_irq);
411 } else { 420 } else {
412 mct_tick1_event_irq.dev_id = mevt; 421 mct_tick1_event_irq.dev_id = mevt;
413 evt->irq = IRQ_MCT_L1; 422 evt->irq = EXYNOS4_IRQ_MCT_L1;
414 setup_irq(IRQ_MCT_L1, &mct_tick1_event_irq); 423 setup_irq(EXYNOS4_IRQ_MCT_L1, &mct_tick1_event_irq);
415 irq_set_affinity(IRQ_MCT_L1, cpumask_of(1)); 424 irq_set_affinity(EXYNOS4_IRQ_MCT_L1, cpumask_of(1));
416 } 425 }
417 } else { 426 } else {
418 enable_percpu_irq(IRQ_MCT_LOCALTIMER, 0); 427 enable_percpu_irq(EXYNOS_IRQ_MCT_LOCALTIMER, 0);
419 } 428 }
420}
421
422/* Setup the local clock events for a CPU */
423int __cpuinit local_timer_setup(struct clock_event_device *evt)
424{
425 exynos4_mct_tick_init(evt);
426 429
427 return 0; 430 return 0;
428} 431}
429 432
430void local_timer_stop(struct clock_event_device *evt) 433static void exynos4_local_timer_stop(struct clock_event_device *evt)
431{ 434{
432 unsigned int cpu = smp_processor_id(); 435 unsigned int cpu = smp_processor_id();
433 evt->set_mode(CLOCK_EVT_MODE_UNUSED, evt); 436 evt->set_mode(CLOCK_EVT_MODE_UNUSED, evt);
@@ -437,8 +440,13 @@ void local_timer_stop(struct clock_event_device *evt)
437 else 440 else
438 remove_irq(evt->irq, &mct_tick1_event_irq); 441 remove_irq(evt->irq, &mct_tick1_event_irq);
439 else 442 else
440 disable_percpu_irq(IRQ_MCT_LOCALTIMER); 443 disable_percpu_irq(EXYNOS_IRQ_MCT_LOCALTIMER);
441} 444}
445
446static struct local_timer_ops exynos4_mct_tick_ops __cpuinitdata = {
447 .setup = exynos4_local_timer_setup,
448 .stop = exynos4_local_timer_stop,
449};
442#endif /* CONFIG_LOCAL_TIMERS */ 450#endif /* CONFIG_LOCAL_TIMERS */
443 451
444static void __init exynos4_timer_resources(void) 452static void __init exynos4_timer_resources(void)
@@ -452,12 +460,14 @@ static void __init exynos4_timer_resources(void)
452 if (mct_int_type == MCT_INT_PPI) { 460 if (mct_int_type == MCT_INT_PPI) {
453 int err; 461 int err;
454 462
455 err = request_percpu_irq(IRQ_MCT_LOCALTIMER, 463 err = request_percpu_irq(EXYNOS_IRQ_MCT_LOCALTIMER,
456 exynos4_mct_tick_isr, "MCT", 464 exynos4_mct_tick_isr, "MCT",
457 &percpu_mct_tick); 465 &percpu_mct_tick);
458 WARN(err, "MCT: can't request IRQ %d (%d)\n", 466 WARN(err, "MCT: can't request IRQ %d (%d)\n",
459 IRQ_MCT_LOCALTIMER, err); 467 EXYNOS_IRQ_MCT_LOCALTIMER, err);
460 } 468 }
469
470 local_timer_register(&exynos4_mct_tick_ops);
461#endif /* CONFIG_LOCAL_TIMERS */ 471#endif /* CONFIG_LOCAL_TIMERS */
462} 472}
463 473
diff --git a/arch/arm/mach-exynos/platsmp.c b/arch/arm/mach-exynos/platsmp.c
index 0f2035a1eb6..36c3984aaa4 100644
--- a/arch/arm/mach-exynos/platsmp.c
+++ b/arch/arm/mach-exynos/platsmp.c
@@ -166,7 +166,10 @@ void __init smp_init_cpus(void)
166 void __iomem *scu_base = scu_base_addr(); 166 void __iomem *scu_base = scu_base_addr();
167 unsigned int i, ncores; 167 unsigned int i, ncores;
168 168
169 ncores = scu_base ? scu_get_core_count(scu_base) : 1; 169 if (soc_is_exynos5250())
170 ncores = 2;
171 else
172 ncores = scu_base ? scu_get_core_count(scu_base) : 1;
170 173
171 /* sanity check */ 174 /* sanity check */
172 if (ncores > nr_cpu_ids) { 175 if (ncores > nr_cpu_ids) {
@@ -183,8 +186,8 @@ void __init smp_init_cpus(void)
183 186
184void __init platform_smp_prepare_cpus(unsigned int max_cpus) 187void __init platform_smp_prepare_cpus(unsigned int max_cpus)
185{ 188{
186 189 if (!soc_is_exynos5250())
187 scu_enable(scu_base_addr()); 190 scu_enable(scu_base_addr());
188 191
189 /* 192 /*
190 * Write the address of secondary startup into the 193 * Write the address of secondary startup into the
diff --git a/arch/arm/mach-exynos/pm.c b/arch/arm/mach-exynos/pm.c
index e1901305177..428cfeb5772 100644
--- a/arch/arm/mach-exynos/pm.c
+++ b/arch/arm/mach-exynos/pm.c
@@ -38,29 +38,29 @@
38#include <mach/pmu.h> 38#include <mach/pmu.h>
39 39
40static struct sleep_save exynos4_set_clksrc[] = { 40static struct sleep_save exynos4_set_clksrc[] = {
41 { .reg = S5P_CLKSRC_MASK_TOP , .val = 0x00000001, }, 41 { .reg = EXYNOS4_CLKSRC_MASK_TOP , .val = 0x00000001, },
42 { .reg = S5P_CLKSRC_MASK_CAM , .val = 0x11111111, }, 42 { .reg = EXYNOS4_CLKSRC_MASK_CAM , .val = 0x11111111, },
43 { .reg = S5P_CLKSRC_MASK_TV , .val = 0x00000111, }, 43 { .reg = EXYNOS4_CLKSRC_MASK_TV , .val = 0x00000111, },
44 { .reg = S5P_CLKSRC_MASK_LCD0 , .val = 0x00001111, }, 44 { .reg = EXYNOS4_CLKSRC_MASK_LCD0 , .val = 0x00001111, },
45 { .reg = S5P_CLKSRC_MASK_MAUDIO , .val = 0x00000001, }, 45 { .reg = EXYNOS4_CLKSRC_MASK_MAUDIO , .val = 0x00000001, },
46 { .reg = S5P_CLKSRC_MASK_FSYS , .val = 0x01011111, }, 46 { .reg = EXYNOS4_CLKSRC_MASK_FSYS , .val = 0x01011111, },
47 { .reg = S5P_CLKSRC_MASK_PERIL0 , .val = 0x01111111, }, 47 { .reg = EXYNOS4_CLKSRC_MASK_PERIL0 , .val = 0x01111111, },
48 { .reg = S5P_CLKSRC_MASK_PERIL1 , .val = 0x01110111, }, 48 { .reg = EXYNOS4_CLKSRC_MASK_PERIL1 , .val = 0x01110111, },
49 { .reg = S5P_CLKSRC_MASK_DMC , .val = 0x00010000, }, 49 { .reg = EXYNOS4_CLKSRC_MASK_DMC , .val = 0x00010000, },
50}; 50};
51 51
52static struct sleep_save exynos4210_set_clksrc[] = { 52static struct sleep_save exynos4210_set_clksrc[] = {
53 { .reg = S5P_CLKSRC_MASK_LCD1 , .val = 0x00001111, }, 53 { .reg = EXYNOS4210_CLKSRC_MASK_LCD1 , .val = 0x00001111, },
54}; 54};
55 55
56static struct sleep_save exynos4_epll_save[] = { 56static struct sleep_save exynos4_epll_save[] = {
57 SAVE_ITEM(S5P_EPLL_CON0), 57 SAVE_ITEM(EXYNOS4_EPLL_CON0),
58 SAVE_ITEM(S5P_EPLL_CON1), 58 SAVE_ITEM(EXYNOS4_EPLL_CON1),
59}; 59};
60 60
61static struct sleep_save exynos4_vpll_save[] = { 61static struct sleep_save exynos4_vpll_save[] = {
62 SAVE_ITEM(S5P_VPLL_CON0), 62 SAVE_ITEM(EXYNOS4_VPLL_CON0),
63 SAVE_ITEM(S5P_VPLL_CON1), 63 SAVE_ITEM(EXYNOS4_VPLL_CON1),
64}; 64};
65 65
66static struct sleep_save exynos4_core_save[] = { 66static struct sleep_save exynos4_core_save[] = {
@@ -155,13 +155,6 @@ static struct sleep_save exynos4_core_save[] = {
155 SAVE_ITEM(S5P_SROM_BC3), 155 SAVE_ITEM(S5P_SROM_BC3),
156}; 156};
157 157
158static struct sleep_save exynos4_l2cc_save[] = {
159 SAVE_ITEM(S5P_VA_L2CC + L2X0_TAG_LATENCY_CTRL),
160 SAVE_ITEM(S5P_VA_L2CC + L2X0_DATA_LATENCY_CTRL),
161 SAVE_ITEM(S5P_VA_L2CC + L2X0_PREFETCH_CTRL),
162 SAVE_ITEM(S5P_VA_L2CC + L2X0_POWER_CTRL),
163 SAVE_ITEM(S5P_VA_L2CC + L2X0_AUX_CTRL),
164};
165 158
166/* For Cortex-A9 Diagnostic and Power control register */ 159/* For Cortex-A9 Diagnostic and Power control register */
167static unsigned int save_arm_register[2]; 160static unsigned int save_arm_register[2];
@@ -182,7 +175,6 @@ static void exynos4_pm_prepare(void)
182 u32 tmp; 175 u32 tmp;
183 176
184 s3c_pm_do_save(exynos4_core_save, ARRAY_SIZE(exynos4_core_save)); 177 s3c_pm_do_save(exynos4_core_save, ARRAY_SIZE(exynos4_core_save));
185 s3c_pm_do_save(exynos4_l2cc_save, ARRAY_SIZE(exynos4_l2cc_save));
186 s3c_pm_do_save(exynos4_epll_save, ARRAY_SIZE(exynos4_epll_save)); 178 s3c_pm_do_save(exynos4_epll_save, ARRAY_SIZE(exynos4_epll_save));
187 s3c_pm_do_save(exynos4_vpll_save, ARRAY_SIZE(exynos4_vpll_save)); 179 s3c_pm_do_save(exynos4_vpll_save, ARRAY_SIZE(exynos4_vpll_save));
188 180
@@ -239,7 +231,7 @@ static void exynos4_restore_pll(void)
239 locktime = (3000 / pll_in_rate) * p_div; 231 locktime = (3000 / pll_in_rate) * p_div;
240 lockcnt = locktime * 10000 / (10000 / pll_in_rate); 232 lockcnt = locktime * 10000 / (10000 / pll_in_rate);
241 233
242 __raw_writel(lockcnt, S5P_EPLL_LOCK); 234 __raw_writel(lockcnt, EXYNOS4_EPLL_LOCK);
243 235
244 s3c_pm_do_restore_core(exynos4_epll_save, 236 s3c_pm_do_restore_core(exynos4_epll_save,
245 ARRAY_SIZE(exynos4_epll_save)); 237 ARRAY_SIZE(exynos4_epll_save));
@@ -257,7 +249,7 @@ static void exynos4_restore_pll(void)
257 locktime = 750; 249 locktime = 750;
258 lockcnt = locktime * 10000 / (10000 / pll_in_rate); 250 lockcnt = locktime * 10000 / (10000 / pll_in_rate);
259 251
260 __raw_writel(lockcnt, S5P_VPLL_LOCK); 252 __raw_writel(lockcnt, EXYNOS4_VPLL_LOCK);
261 253
262 s3c_pm_do_restore_core(exynos4_vpll_save, 254 s3c_pm_do_restore_core(exynos4_vpll_save,
263 ARRAY_SIZE(exynos4_vpll_save)); 255 ARRAY_SIZE(exynos4_vpll_save));
@@ -268,14 +260,14 @@ static void exynos4_restore_pll(void)
268 260
269 do { 261 do {
270 if (epll_wait) { 262 if (epll_wait) {
271 pll_con = __raw_readl(S5P_EPLL_CON0); 263 pll_con = __raw_readl(EXYNOS4_EPLL_CON0);
272 if (pll_con & (1 << S5P_EPLLCON0_LOCKED_SHIFT)) 264 if (pll_con & (1 << EXYNOS4_EPLLCON0_LOCKED_SHIFT))
273 epll_wait = 0; 265 epll_wait = 0;
274 } 266 }
275 267
276 if (vpll_wait) { 268 if (vpll_wait) {
277 pll_con = __raw_readl(S5P_VPLL_CON0); 269 pll_con = __raw_readl(EXYNOS4_VPLL_CON0);
278 if (pll_con & (1 << S5P_VPLLCON0_LOCKED_SHIFT)) 270 if (pll_con & (1 << EXYNOS4_VPLLCON0_LOCKED_SHIFT))
279 vpll_wait = 0; 271 vpll_wait = 0;
280 } 272 }
281 } while (epll_wait || vpll_wait); 273 } while (epll_wait || vpll_wait);
@@ -388,13 +380,6 @@ static void exynos4_pm_resume(void)
388 scu_enable(S5P_VA_SCU); 380 scu_enable(S5P_VA_SCU);
389#endif 381#endif
390 382
391#ifdef CONFIG_CACHE_L2X0
392 s3c_pm_do_restore_core(exynos4_l2cc_save, ARRAY_SIZE(exynos4_l2cc_save));
393 outer_inv_all();
394 /* enable L2X0*/
395 writel_relaxed(1, S5P_VA_L2CC + L2X0_CTRL);
396#endif
397
398early_wakeup: 383early_wakeup:
399 return; 384 return;
400} 385}
diff --git a/arch/arm/mach-exynos/pm_domains.c b/arch/arm/mach-exynos/pm_domains.c
index 0b04af2b13c..13b306808b4 100644
--- a/arch/arm/mach-exynos/pm_domains.c
+++ b/arch/arm/mach-exynos/pm_domains.c
@@ -183,6 +183,12 @@ static __init int exynos4_pm_init_power_domain(void)
183#ifdef CONFIG_S5P_DEV_CSIS1 183#ifdef CONFIG_S5P_DEV_CSIS1
184 exynos_pm_add_dev_to_genpd(&s5p_device_mipi_csis1, &exynos4_pd_cam); 184 exynos_pm_add_dev_to_genpd(&s5p_device_mipi_csis1, &exynos4_pd_cam);
185#endif 185#endif
186#ifdef CONFIG_S5P_DEV_G2D
187 exynos_pm_add_dev_to_genpd(&s5p_device_g2d, &exynos4_pd_lcd0);
188#endif
189#ifdef CONFIG_S5P_DEV_JPEG
190 exynos_pm_add_dev_to_genpd(&s5p_device_jpeg, &exynos4_pd_cam);
191#endif
186 return 0; 192 return 0;
187} 193}
188arch_initcall(exynos4_pm_init_power_domain); 194arch_initcall(exynos4_pm_init_power_domain);
diff --git a/arch/arm/mach-exynos/setup-i2c0.c b/arch/arm/mach-exynos/setup-i2c0.c
index d395bd17c38..b90d94c17f7 100644
--- a/arch/arm/mach-exynos/setup-i2c0.c
+++ b/arch/arm/mach-exynos/setup-i2c0.c
@@ -1,7 +1,5 @@
1/* 1/*
2 * linux/arch/arm/mach-exynos4/setup-i2c0.c 2 * Copyright (c) 2009-2012 Samsung Electronics Co., Ltd.
3 *
4 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com/ 3 * http://www.samsung.com/
6 * 4 *
7 * I2C0 GPIO configuration. 5 * I2C0 GPIO configuration.
@@ -18,9 +16,14 @@ struct platform_device; /* don't need the contents */
18#include <linux/gpio.h> 16#include <linux/gpio.h>
19#include <plat/iic.h> 17#include <plat/iic.h>
20#include <plat/gpio-cfg.h> 18#include <plat/gpio-cfg.h>
19#include <plat/cpu.h>
21 20
22void s3c_i2c0_cfg_gpio(struct platform_device *dev) 21void s3c_i2c0_cfg_gpio(struct platform_device *dev)
23{ 22{
23 if (soc_is_exynos5250())
24 /* will be implemented with gpio function */
25 return;
26
24 s3c_gpio_cfgall_range(EXYNOS4_GPD1(0), 2, 27 s3c_gpio_cfgall_range(EXYNOS4_GPD1(0), 2,
25 S3C_GPIO_SFN(2), S3C_GPIO_PULL_UP); 28 S3C_GPIO_SFN(2), S3C_GPIO_PULL_UP);
26} 29}
diff --git a/arch/arm/mach-footbridge/dc21285.c b/arch/arm/mach-footbridge/dc21285.c
index 94a7087a610..e17e11de4f5 100644
--- a/arch/arm/mach-footbridge/dc21285.c
+++ b/arch/arm/mach-footbridge/dc21285.c
@@ -274,11 +274,13 @@ int __init dc21285_setup(int nr, struct pci_sys_data *sys)
274 allocate_resource(&iomem_resource, &res[0], 0x40000000, 274 allocate_resource(&iomem_resource, &res[0], 0x40000000,
275 0x80000000, 0xffffffff, 0x40000000, NULL, NULL); 275 0x80000000, 0xffffffff, 0x40000000, NULL, NULL);
276 276
277 pci_add_resource(&sys->resources, &ioport_resource);
278 pci_add_resource(&sys->resources, &res[0]);
279 pci_add_resource(&sys->resources, &res[1]);
280 sys->mem_offset = DC21285_PCI_MEM; 277 sys->mem_offset = DC21285_PCI_MEM;
281 278
279 pci_add_resource_offset(&sys->resources,
280 &ioport_resource, sys->io_offset);
281 pci_add_resource_offset(&sys->resources, &res[0], sys->mem_offset);
282 pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset);
283
282 return 1; 284 return 1;
283} 285}
284 286
diff --git a/arch/arm/mach-footbridge/include/mach/entry-macro.S b/arch/arm/mach-footbridge/include/mach/entry-macro.S
index d3847be0c66..dabbd5c54a7 100644
--- a/arch/arm/mach-footbridge/include/mach/entry-macro.S
+++ b/arch/arm/mach-footbridge/include/mach/entry-macro.S
@@ -14,9 +14,6 @@
14 .equ dc21285_high, ARMCSR_BASE & 0xff000000 14 .equ dc21285_high, ARMCSR_BASE & 0xff000000
15 .equ dc21285_low, ARMCSR_BASE & 0x00ffffff 15 .equ dc21285_low, ARMCSR_BASE & 0x00ffffff
16 16
17 .macro disable_fiq
18 .endm
19
20 .macro get_irqnr_preamble, base, tmp 17 .macro get_irqnr_preamble, base, tmp
21 mov \base, #dc21285_high 18 mov \base, #dc21285_high
22 .if dc21285_low 19 .if dc21285_low
@@ -24,9 +21,6 @@
24 .endif 21 .endif
25 .endm 22 .endm
26 23
27 .macro arch_ret_to_user, tmp1, tmp2
28 .endm
29
30 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp 24 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
31 ldr \irqstat, [\base, #0x180] @ get interrupts 25 ldr \irqstat, [\base, #0x180] @ get interrupts
32 26
diff --git a/arch/arm/mach-footbridge/include/mach/system.h b/arch/arm/mach-footbridge/include/mach/system.h
deleted file mode 100644
index a174a5841bc..00000000000
--- a/arch/arm/mach-footbridge/include/mach/system.h
+++ /dev/null
@@ -1,13 +0,0 @@
1/*
2 * arch/arm/mach-footbridge/include/mach/system.h
3 *
4 * Copyright (C) 1996-1999 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 */
10static inline void arch_idle(void)
11{
12 cpu_do_idle();
13}
diff --git a/arch/arm/mach-gemini/Makefile b/arch/arm/mach-gemini/Makefile
index c5b24b95a76..7355c0bbcb5 100644
--- a/arch/arm/mach-gemini/Makefile
+++ b/arch/arm/mach-gemini/Makefile
@@ -4,7 +4,7 @@
4 4
5# Object file lists. 5# Object file lists.
6 6
7obj-y := irq.o mm.o time.o devices.o gpio.o 7obj-y := irq.o mm.o time.o devices.o gpio.o idle.o
8 8
9# Board-specific support 9# Board-specific support
10obj-$(CONFIG_MACH_NAS4220B) += board-nas4220b.o 10obj-$(CONFIG_MACH_NAS4220B) += board-nas4220b.o
diff --git a/arch/arm/mach-gemini/idle.c b/arch/arm/mach-gemini/idle.c
new file mode 100644
index 00000000000..92bbd6bb600
--- /dev/null
+++ b/arch/arm/mach-gemini/idle.c
@@ -0,0 +1,29 @@
1/*
2 * arch/arm/mach-gemini/idle.c
3 */
4
5#include <linux/init.h>
6#include <asm/system.h>
7#include <asm/proc-fns.h>
8
9static void gemini_idle(void)
10{
11 /*
12 * Because of broken hardware we have to enable interrupts or the CPU
13 * will never wakeup... Acctualy it is not very good to enable
14 * interrupts first since scheduler can miss a tick, but there is
15 * no other way around this. Platforms that needs it for power saving
16 * should call enable_hlt() in init code, since by default it is
17 * disabled.
18 */
19 local_irq_enable();
20 cpu_do_idle();
21}
22
23static int __init gemini_idle_init(void)
24{
25 arm_pm_idle = gemini_idle;
26 return 0;
27}
28
29arch_initcall(gemini_idle_init);
diff --git a/arch/arm/mach-gemini/include/mach/entry-macro.S b/arch/arm/mach-gemini/include/mach/entry-macro.S
index 1624f91a2b8..f044e430bfa 100644
--- a/arch/arm/mach-gemini/include/mach/entry-macro.S
+++ b/arch/arm/mach-gemini/include/mach/entry-macro.S
@@ -12,15 +12,9 @@
12 12
13#define IRQ_STATUS 0x14 13#define IRQ_STATUS 0x14
14 14
15 .macro disable_fiq
16 .endm
17
18 .macro get_irqnr_preamble, base, tmp 15 .macro get_irqnr_preamble, base, tmp
19 .endm 16 .endm
20 17
21 .macro arch_ret_to_user, tmp1, tmp2
22 .endm
23
24 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp 18 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
25 ldr \irqstat, =IO_ADDRESS(GEMINI_INTERRUPT_BASE + IRQ_STATUS) 19 ldr \irqstat, =IO_ADDRESS(GEMINI_INTERRUPT_BASE + IRQ_STATUS)
26 ldr \irqnr, [\irqstat] 20 ldr \irqnr, [\irqstat]
diff --git a/arch/arm/mach-gemini/include/mach/system.h b/arch/arm/mach-gemini/include/mach/system.h
index 4d9c1f87247..a33b5a1f8ab 100644
--- a/arch/arm/mach-gemini/include/mach/system.h
+++ b/arch/arm/mach-gemini/include/mach/system.h
@@ -14,20 +14,6 @@
14#include <mach/hardware.h> 14#include <mach/hardware.h>
15#include <mach/global_reg.h> 15#include <mach/global_reg.h>
16 16
17static inline void arch_idle(void)
18{
19 /*
20 * Because of broken hardware we have to enable interrupts or the CPU
21 * will never wakeup... Acctualy it is not very good to enable
22 * interrupts here since scheduler can miss a tick, but there is
23 * no other way around this. Platforms that needs it for power saving
24 * should call enable_hlt() in init code, since by default it is
25 * disabled.
26 */
27 local_irq_enable();
28 cpu_do_idle();
29}
30
31static inline void arch_reset(char mode, const char *cmd) 17static inline void arch_reset(char mode, const char *cmd)
32{ 18{
33 __raw_writel(RESET_GLOBAL | RESET_CPU1, 19 __raw_writel(RESET_GLOBAL | RESET_CPU1,
diff --git a/arch/arm/mach-gemini/irq.c b/arch/arm/mach-gemini/irq.c
index 9485a8fdf85..ca70e5fcc7a 100644
--- a/arch/arm/mach-gemini/irq.c
+++ b/arch/arm/mach-gemini/irq.c
@@ -73,8 +73,8 @@ void __init gemini_init_irq(void)
73 unsigned int i, mode = 0, level = 0; 73 unsigned int i, mode = 0, level = 0;
74 74
75 /* 75 /*
76 * Disable arch_idle() by default since it is buggy 76 * Disable the idle handler by default since it is buggy
77 * For more info see arch/arm/mach-gemini/include/mach/system.h 77 * For more info see arch/arm/mach-gemini/idle.c
78 */ 78 */
79 disable_hlt(); 79 disable_hlt();
80 80
diff --git a/arch/arm/mach-h720x/common.c b/arch/arm/mach-h720x/common.c
index f8a2f6bb548..e756d1ac00c 100644
--- a/arch/arm/mach-h720x/common.c
+++ b/arch/arm/mach-h720x/common.c
@@ -247,3 +247,21 @@ void h720x_restart(char mode, const char *cmd)
247{ 247{
248 CPU_REG (PMU_BASE, PMU_STAT) |= PMU_WARMRESET; 248 CPU_REG (PMU_BASE, PMU_STAT) |= PMU_WARMRESET;
249} 249}
250
251static void h720x__idle(void)
252{
253 CPU_REG (PMU_BASE, PMU_MODE) = PMU_MODE_IDLE;
254 nop();
255 nop();
256 CPU_REG (PMU_BASE, PMU_MODE) = PMU_MODE_RUN;
257 nop();
258 nop();
259}
260
261static int __init h720x_idle_init(void)
262{
263 arm_pm_idle = h720x__idle;
264 return 0;
265}
266
267arch_initcall(h720x_idle_init);
diff --git a/arch/arm/mach-h720x/include/mach/entry-macro.S b/arch/arm/mach-h720x/include/mach/entry-macro.S
index c3948e5ba4a..75267fad701 100644
--- a/arch/arm/mach-h720x/include/mach/entry-macro.S
+++ b/arch/arm/mach-h720x/include/mach/entry-macro.S
@@ -8,15 +8,9 @@
8 * warranty of any kind, whether express or implied. 8 * warranty of any kind, whether express or implied.
9 */ 9 */
10 10
11 .macro disable_fiq
12 .endm
13
14 .macro get_irqnr_preamble, base, tmp 11 .macro get_irqnr_preamble, base, tmp
15 .endm 12 .endm
16 13
17 .macro arch_ret_to_user, tmp1, tmp2
18 .endm
19
20 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp 14 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
21#if defined (CONFIG_CPU_H7201) || defined (CONFIG_CPU_H7202) 15#if defined (CONFIG_CPU_H7201) || defined (CONFIG_CPU_H7202)
22 @ we could use the id register on H7202, but this is not 16 @ we could use the id register on H7202, but this is not
diff --git a/arch/arm/mach-h720x/include/mach/system.h b/arch/arm/mach-h720x/include/mach/system.h
deleted file mode 100644
index 16ac46e239a..00000000000
--- a/arch/arm/mach-h720x/include/mach/system.h
+++ /dev/null
@@ -1,27 +0,0 @@
1/*
2 * arch/arm/mach-h720x/include/mach/system.h
3 *
4 * Copyright (C) 2001-2002 Jungjun Kim, Hynix Semiconductor 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 version 2 as
8 * published by the Free Software Foundation.
9 * arch/arm/mach-h720x/include/mach/system.h
10 *
11 */
12
13#ifndef __ASM_ARCH_SYSTEM_H
14#define __ASM_ARCH_SYSTEM_H
15#include <mach/hardware.h>
16
17static void arch_idle(void)
18{
19 CPU_REG (PMU_BASE, PMU_MODE) = PMU_MODE_IDLE;
20 nop();
21 nop();
22 CPU_REG (PMU_BASE, PMU_MODE) = PMU_MODE_RUN;
23 nop();
24 nop();
25}
26
27#endif
diff --git a/arch/arm/mach-highbank/Makefile b/arch/arm/mach-highbank/Makefile
index 986958a5a72..f8437dd238c 100644
--- a/arch/arm/mach-highbank/Makefile
+++ b/arch/arm/mach-highbank/Makefile
@@ -1,6 +1,5 @@
1obj-y := clock.o highbank.o system.o 1obj-y := clock.o highbank.o system.o
2obj-$(CONFIG_DEBUG_HIGHBANK_UART) += lluart.o 2obj-$(CONFIG_DEBUG_HIGHBANK_UART) += lluart.o
3obj-$(CONFIG_SMP) += platsmp.o 3obj-$(CONFIG_SMP) += platsmp.o
4obj-$(CONFIG_LOCAL_TIMERS) += localtimer.o
5obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o 4obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
6obj-$(CONFIG_PM_SLEEP) += pm.o 5obj-$(CONFIG_PM_SLEEP) += pm.o
diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c
index 8394d512a40..808b055289b 100644
--- a/arch/arm/mach-highbank/highbank.c
+++ b/arch/arm/mach-highbank/highbank.c
@@ -27,6 +27,7 @@
27#include <asm/cacheflush.h> 27#include <asm/cacheflush.h>
28#include <asm/smp_plat.h> 28#include <asm/smp_plat.h>
29#include <asm/smp_scu.h> 29#include <asm/smp_scu.h>
30#include <asm/smp_twd.h>
30#include <asm/hardware/arm_timer.h> 31#include <asm/hardware/arm_timer.h>
31#include <asm/hardware/timer-sp.h> 32#include <asm/hardware/timer-sp.h>
32#include <asm/hardware/gic.h> 33#include <asm/hardware/gic.h>
@@ -109,8 +110,10 @@ static void __init highbank_timer_init(void)
109 110
110 highbank_clocks_init(); 111 highbank_clocks_init();
111 112
112 sp804_clocksource_init(timer_base + 0x20, "timer1"); 113 sp804_clocksource_and_sched_clock_init(timer_base + 0x20, "timer1");
113 sp804_clockevents_init(timer_base, irq, "timer0"); 114 sp804_clockevents_init(timer_base, irq, "timer0");
115
116 twd_local_timer_of_register();
114} 117}
115 118
116static struct sys_timer highbank_timer = { 119static struct sys_timer highbank_timer = {
diff --git a/arch/arm/mach-highbank/include/mach/entry-macro.S b/arch/arm/mach-highbank/include/mach/entry-macro.S
deleted file mode 100644
index a14f9e62ca9..00000000000
--- a/arch/arm/mach-highbank/include/mach/entry-macro.S
+++ /dev/null
@@ -1,5 +0,0 @@
1 .macro disable_fiq
2 .endm
3
4 .macro arch_ret_to_user, tmp1, tmp2
5 .endm
diff --git a/arch/arm/mach-highbank/include/mach/memory.h b/arch/arm/mach-highbank/include/mach/memory.h
deleted file mode 100644
index 40a8c178f10..00000000000
--- a/arch/arm/mach-highbank/include/mach/memory.h
+++ /dev/null
@@ -1 +0,0 @@
1/* empty */
diff --git a/arch/arm/mach-highbank/localtimer.c b/arch/arm/mach-highbank/localtimer.c
deleted file mode 100644
index 5a00e7945fd..00000000000
--- a/arch/arm/mach-highbank/localtimer.c
+++ /dev/null
@@ -1,40 +0,0 @@
1/*
2 * Copyright 2010-2011 Calxeda, Inc.
3 * Based on localtimer.c, Copyright (C) 2002 ARM Ltd.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17#include <linux/init.h>
18#include <linux/clockchips.h>
19#include <linux/of.h>
20#include <linux/of_address.h>
21#include <linux/of_irq.h>
22
23#include <asm/smp_twd.h>
24
25/*
26 * Setup the local clock events for a CPU.
27 */
28int __cpuinit local_timer_setup(struct clock_event_device *evt)
29{
30 struct device_node *np;
31
32 np = of_find_compatible_node(NULL, NULL, "arm,smp-twd");
33 if (!twd_base) {
34 twd_base = of_iomap(np, 0);
35 WARN_ON(!twd_base);
36 }
37 evt->irq = irq_of_parse_and_map(np, 0);
38 twd_timer_setup(evt);
39 return 0;
40}
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index 3919fba52ac..52359f80c42 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -298,6 +298,7 @@ config MACH_MX27_3DS
298 select IMX_HAVE_PLATFORM_IMX_I2C 298 select IMX_HAVE_PLATFORM_IMX_I2C
299 select IMX_HAVE_PLATFORM_IMX_KEYPAD 299 select IMX_HAVE_PLATFORM_IMX_KEYPAD
300 select IMX_HAVE_PLATFORM_IMX_UART 300 select IMX_HAVE_PLATFORM_IMX_UART
301 select IMX_HAVE_PLATFORM_MX2_CAMERA
301 select IMX_HAVE_PLATFORM_MXC_EHCI 302 select IMX_HAVE_PLATFORM_MXC_EHCI
302 select IMX_HAVE_PLATFORM_MXC_MMC 303 select IMX_HAVE_PLATFORM_MXC_MMC
303 select IMX_HAVE_PLATFORM_SPI_IMX 304 select IMX_HAVE_PLATFORM_SPI_IMX
@@ -314,8 +315,10 @@ config MACH_IMX27_VISSTRIM_M10
314 select IMX_HAVE_PLATFORM_IMX_I2C 315 select IMX_HAVE_PLATFORM_IMX_I2C
315 select IMX_HAVE_PLATFORM_IMX_SSI 316 select IMX_HAVE_PLATFORM_IMX_SSI
316 select IMX_HAVE_PLATFORM_IMX_UART 317 select IMX_HAVE_PLATFORM_IMX_UART
317 select IMX_HAVE_PLATFORM_MXC_MMC 318 select IMX_HAVE_PLATFORM_MX2_CAMERA
318 select IMX_HAVE_PLATFORM_MXC_EHCI 319 select IMX_HAVE_PLATFORM_MXC_EHCI
320 select IMX_HAVE_PLATFORM_MXC_MMC
321 select LEDS_GPIO_REGISTER
319 help 322 help
320 Include support for Visstrim_m10 platform and its different variants. 323 Include support for Visstrim_m10 platform and its different variants.
321 This includes specific configurations for the board and its 324 This includes specific configurations for the board and its
@@ -370,6 +373,14 @@ config MACH_IMX27IPCAM
370 Include support for IMX27 IPCAM platform. This includes specific 373 Include support for IMX27 IPCAM platform. This includes specific
371 configurations for the board and its peripherals. 374 configurations for the board and its peripherals.
372 375
376config MACH_IMX27_DT
377 bool "Support i.MX27 platforms from device tree"
378 select SOC_IMX27
379 select USE_OF
380 help
381 Include support for Freescale i.MX27 based platforms
382 using the device tree for discovery
383
373endif 384endif
374 385
375if ARCH_IMX_V6_V7 386if ARCH_IMX_V6_V7
@@ -486,6 +497,7 @@ config MACH_MX31MOBOARD
486 bool "Support mx31moboard platforms (EPFL Mobots group)" 497 bool "Support mx31moboard platforms (EPFL Mobots group)"
487 select SOC_IMX31 498 select SOC_IMX31
488 select IMX_HAVE_PLATFORM_FSL_USB2_UDC 499 select IMX_HAVE_PLATFORM_FSL_USB2_UDC
500 select IMX_HAVE_PLATFORM_IMX2_WDT
489 select IMX_HAVE_PLATFORM_IMX_I2C 501 select IMX_HAVE_PLATFORM_IMX_I2C
490 select IMX_HAVE_PLATFORM_IMX_UART 502 select IMX_HAVE_PLATFORM_IMX_UART
491 select IMX_HAVE_PLATFORM_IPU_CORE 503 select IMX_HAVE_PLATFORM_IPU_CORE
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index 55db9c488f2..35fc450fa26 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -8,8 +8,8 @@ obj-$(CONFIG_SOC_IMX25) += clock-imx25.o mm-imx25.o ehci-imx25.o cpu-imx25.o
8obj-$(CONFIG_SOC_IMX27) += cpu-imx27.o pm-imx27.o 8obj-$(CONFIG_SOC_IMX27) += cpu-imx27.o pm-imx27.o
9obj-$(CONFIG_SOC_IMX27) += clock-imx27.o mm-imx27.o ehci-imx27.o 9obj-$(CONFIG_SOC_IMX27) += clock-imx27.o mm-imx27.o ehci-imx27.o
10 10
11obj-$(CONFIG_SOC_IMX31) += mm-imx3.o cpu-imx31.o clock-imx31.o iomux-imx31.o ehci-imx31.o 11obj-$(CONFIG_SOC_IMX31) += mm-imx3.o cpu-imx31.o clock-imx31.o iomux-imx31.o ehci-imx31.o pm-imx3.o
12obj-$(CONFIG_SOC_IMX35) += mm-imx3.o cpu-imx35.o clock-imx35.o ehci-imx35.o 12obj-$(CONFIG_SOC_IMX35) += mm-imx3.o cpu-imx35.o clock-imx35.o ehci-imx35.o pm-imx3.o
13 13
14obj-$(CONFIG_SOC_IMX5) += cpu-imx5.o mm-imx5.o clock-mx51-mx53.o ehci-imx5.o pm-imx5.o cpu_op-mx51.o 14obj-$(CONFIG_SOC_IMX5) += cpu-imx5.o mm-imx5.o clock-mx51-mx53.o ehci-imx5.o pm-imx5.o cpu_op-mx51.o
15 15
@@ -41,6 +41,7 @@ obj-$(CONFIG_MACH_EUKREA_MBIMX27_BASEBOARD) += eukrea_mbimx27-baseboard.o
41obj-$(CONFIG_MACH_PCA100) += mach-pca100.o 41obj-$(CONFIG_MACH_PCA100) += mach-pca100.o
42obj-$(CONFIG_MACH_MXT_TD60) += mach-mxt_td60.o 42obj-$(CONFIG_MACH_MXT_TD60) += mach-mxt_td60.o
43obj-$(CONFIG_MACH_IMX27IPCAM) += mach-imx27ipcam.o 43obj-$(CONFIG_MACH_IMX27IPCAM) += mach-imx27ipcam.o
44obj-$(CONFIG_MACH_IMX27_DT) += imx27-dt.o
44 45
45# i.MX31 based machines 46# i.MX31 based machines
46obj-$(CONFIG_MACH_MX31ADS) += mach-mx31ads.o 47obj-$(CONFIG_MACH_MX31ADS) += mach-mx31ads.o
@@ -71,7 +72,6 @@ obj-$(CONFIG_CPU_V7) += head-v7.o
71AFLAGS_head-v7.o :=-Wa,-march=armv7-a 72AFLAGS_head-v7.o :=-Wa,-march=armv7-a
72obj-$(CONFIG_SMP) += platsmp.o 73obj-$(CONFIG_SMP) += platsmp.o
73obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o 74obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
74obj-$(CONFIG_LOCAL_TIMERS) += localtimer.o
75obj-$(CONFIG_SOC_IMX6Q) += clock-imx6q.o mach-imx6q.o 75obj-$(CONFIG_SOC_IMX6Q) += clock-imx6q.o mach-imx6q.o
76 76
77ifeq ($(CONFIG_PM),y) 77ifeq ($(CONFIG_PM),y)
diff --git a/arch/arm/mach-imx/Makefile.boot b/arch/arm/mach-imx/Makefile.boot
index 6dfdbcc83af..3851d8a2787 100644
--- a/arch/arm/mach-imx/Makefile.boot
+++ b/arch/arm/mach-imx/Makefile.boot
@@ -38,5 +38,8 @@ zreladdr-$(CONFIG_SOC_IMX6Q) += 0x10008000
38params_phys-$(CONFIG_SOC_IMX6Q) := 0x10000100 38params_phys-$(CONFIG_SOC_IMX6Q) := 0x10000100
39initrd_phys-$(CONFIG_SOC_IMX6Q) := 0x10800000 39initrd_phys-$(CONFIG_SOC_IMX6Q) := 0x10800000
40 40
41dtb-$(CONFIG_MACH_IMX51_DT) += imx51-babbage.dtb
42dtb-$(CONFIG_MACH_IMX53_DT) += imx53-ard.dtb imx53-evk.dtb \
43 imx53-qsb.dtb imx53-smd.dtb
41dtb-$(CONFIG_SOC_IMX6Q) += imx6q-arm2.dtb \ 44dtb-$(CONFIG_SOC_IMX6Q) += imx6q-arm2.dtb \
42 imx6q-sabrelite.dtb 45 imx6q-sabrelite.dtb
diff --git a/arch/arm/mach-imx/clock-imx27.c b/arch/arm/mach-imx/clock-imx27.c
index 88fe00a146e..b9a95ed7555 100644
--- a/arch/arm/mach-imx/clock-imx27.c
+++ b/arch/arm/mach-imx/clock-imx27.c
@@ -22,6 +22,7 @@
22#include <linux/io.h> 22#include <linux/io.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/clkdev.h> 24#include <linux/clkdev.h>
25#include <linux/of.h>
25 26
26#include <asm/div64.h> 27#include <asm/div64.h>
27 28
@@ -661,7 +662,7 @@ static struct clk_lookup lookups[] = {
661 _REGISTER_CLOCK(NULL, "dma", dma_clk) 662 _REGISTER_CLOCK(NULL, "dma", dma_clk)
662 _REGISTER_CLOCK(NULL, "rtic", rtic_clk) 663 _REGISTER_CLOCK(NULL, "rtic", rtic_clk)
663 _REGISTER_CLOCK(NULL, "brom", brom_clk) 664 _REGISTER_CLOCK(NULL, "brom", brom_clk)
664 _REGISTER_CLOCK(NULL, "emma", emma_clk) 665 _REGISTER_CLOCK("m2m-emmaprp.0", NULL, emma_clk)
665 _REGISTER_CLOCK(NULL, "slcdc", slcdc_clk) 666 _REGISTER_CLOCK(NULL, "slcdc", slcdc_clk)
666 _REGISTER_CLOCK("imx27-fec.0", NULL, fec_clk) 667 _REGISTER_CLOCK("imx27-fec.0", NULL, fec_clk)
667 _REGISTER_CLOCK(NULL, "emi", emi_clk) 668 _REGISTER_CLOCK(NULL, "emi", emi_clk)
@@ -764,3 +765,20 @@ int __init mx27_clocks_init(unsigned long fref)
764 return 0; 765 return 0;
765} 766}
766 767
768#ifdef CONFIG_OF
769int __init mx27_clocks_init_dt(void)
770{
771 struct device_node *np;
772 u32 fref = 26000000; /* default */
773
774 for_each_compatible_node(np, NULL, "fixed-clock") {
775 if (!of_device_is_compatible(np, "fsl,imx-osc26m"))
776 continue;
777
778 if (!of_property_read_u32(np, "clock-frequency", &fref))
779 break;
780 }
781
782 return mx27_clocks_init(fref);
783}
784#endif
diff --git a/arch/arm/mach-imx/clock-imx31.c b/arch/arm/mach-imx/clock-imx31.c
index 988a28178d4..3a943cd4159 100644
--- a/arch/arm/mach-imx/clock-imx31.c
+++ b/arch/arm/mach-imx/clock-imx31.c
@@ -32,7 +32,7 @@
32#include <mach/mx31.h> 32#include <mach/mx31.h>
33#include <mach/common.h> 33#include <mach/common.h>
34 34
35#include "crmregs-imx31.h" 35#include "crmregs-imx3.h"
36 36
37#define PRE_DIV_MIN_FREQ 10000000 /* Minimum Frequency after Predivider */ 37#define PRE_DIV_MIN_FREQ 10000000 /* Minimum Frequency after Predivider */
38 38
diff --git a/arch/arm/mach-imx/clock-imx35.c b/arch/arm/mach-imx/clock-imx35.c
index ac8238caecb..1e279af656a 100644
--- a/arch/arm/mach-imx/clock-imx35.c
+++ b/arch/arm/mach-imx/clock-imx35.c
@@ -27,23 +27,7 @@
27#include <mach/hardware.h> 27#include <mach/hardware.h>
28#include <mach/common.h> 28#include <mach/common.h>
29 29
30#define CCM_BASE MX35_IO_ADDRESS(MX35_CCM_BASE_ADDR) 30#include "crmregs-imx3.h"
31
32#define CCM_CCMR 0x00
33#define CCM_PDR0 0x04
34#define CCM_PDR1 0x08
35#define CCM_PDR2 0x0C
36#define CCM_PDR3 0x10
37#define CCM_PDR4 0x14
38#define CCM_RCSR 0x18
39#define CCM_MPCTL 0x1C
40#define CCM_PPCTL 0x20
41#define CCM_ACMR 0x24
42#define CCM_COSR 0x28
43#define CCM_CGR0 0x2C
44#define CCM_CGR1 0x30
45#define CCM_CGR2 0x34
46#define CCM_CGR3 0x38
47 31
48#ifdef HAVE_SET_RATE_SUPPORT 32#ifdef HAVE_SET_RATE_SUPPORT
49static void calc_dividers(u32 div, u32 *pre, u32 *post, u32 maxpost) 33static void calc_dividers(u32 div, u32 *pre, u32 *post, u32 maxpost)
@@ -111,14 +95,14 @@ static void calc_dividers_3_3(u32 div, u32 *pre, u32 *post)
111 95
112static unsigned long get_rate_mpll(void) 96static unsigned long get_rate_mpll(void)
113{ 97{
114 ulong mpctl = __raw_readl(CCM_BASE + CCM_MPCTL); 98 ulong mpctl = __raw_readl(MX35_CCM_MPCTL);
115 99
116 return mxc_decode_pll(mpctl, 24000000); 100 return mxc_decode_pll(mpctl, 24000000);
117} 101}
118 102
119static unsigned long get_rate_ppll(void) 103static unsigned long get_rate_ppll(void)
120{ 104{
121 ulong ppctl = __raw_readl(CCM_BASE + CCM_PPCTL); 105 ulong ppctl = __raw_readl(MX35_CCM_PPCTL);
122 106
123 return mxc_decode_pll(ppctl, 24000000); 107 return mxc_decode_pll(ppctl, 24000000);
124} 108}
@@ -148,7 +132,7 @@ static struct arm_ahb_div clk_consumer[] = {
148 132
149static unsigned long get_rate_arm(void) 133static unsigned long get_rate_arm(void)
150{ 134{
151 unsigned long pdr0 = __raw_readl(CCM_BASE + CCM_PDR0); 135 unsigned long pdr0 = __raw_readl(MXC_CCM_PDR0);
152 struct arm_ahb_div *aad; 136 struct arm_ahb_div *aad;
153 unsigned long fref = get_rate_mpll(); 137 unsigned long fref = get_rate_mpll();
154 138
@@ -161,7 +145,7 @@ static unsigned long get_rate_arm(void)
161 145
162static unsigned long get_rate_ahb(struct clk *clk) 146static unsigned long get_rate_ahb(struct clk *clk)
163{ 147{
164 unsigned long pdr0 = __raw_readl(CCM_BASE + CCM_PDR0); 148 unsigned long pdr0 = __raw_readl(MXC_CCM_PDR0);
165 struct arm_ahb_div *aad; 149 struct arm_ahb_div *aad;
166 unsigned long fref = get_rate_arm(); 150 unsigned long fref = get_rate_arm();
167 151
@@ -177,8 +161,8 @@ static unsigned long get_rate_ipg(struct clk *clk)
177 161
178static unsigned long get_rate_uart(struct clk *clk) 162static unsigned long get_rate_uart(struct clk *clk)
179{ 163{
180 unsigned long pdr3 = __raw_readl(CCM_BASE + CCM_PDR3); 164 unsigned long pdr3 = __raw_readl(MX35_CCM_PDR3);
181 unsigned long pdr4 = __raw_readl(CCM_BASE + CCM_PDR4); 165 unsigned long pdr4 = __raw_readl(MX35_CCM_PDR4);
182 unsigned long div = ((pdr4 >> 10) & 0x3f) + 1; 166 unsigned long div = ((pdr4 >> 10) & 0x3f) + 1;
183 167
184 if (pdr3 & (1 << 14)) 168 if (pdr3 & (1 << 14))
@@ -189,7 +173,7 @@ static unsigned long get_rate_uart(struct clk *clk)
189 173
190static unsigned long get_rate_sdhc(struct clk *clk) 174static unsigned long get_rate_sdhc(struct clk *clk)
191{ 175{
192 unsigned long pdr3 = __raw_readl(CCM_BASE + CCM_PDR3); 176 unsigned long pdr3 = __raw_readl(MX35_CCM_PDR3);
193 unsigned long div, rate; 177 unsigned long div, rate;
194 178
195 if (pdr3 & (1 << 6)) 179 if (pdr3 & (1 << 6))
@@ -215,7 +199,7 @@ static unsigned long get_rate_sdhc(struct clk *clk)
215 199
216static unsigned long get_rate_mshc(struct clk *clk) 200static unsigned long get_rate_mshc(struct clk *clk)
217{ 201{
218 unsigned long pdr1 = __raw_readl(CCM_BASE + CCM_PDR1); 202 unsigned long pdr1 = __raw_readl(MXC_CCM_PDR1);
219 unsigned long div1, div2, rate; 203 unsigned long div1, div2, rate;
220 204
221 if (pdr1 & (1 << 7)) 205 if (pdr1 & (1 << 7))
@@ -231,7 +215,7 @@ static unsigned long get_rate_mshc(struct clk *clk)
231 215
232static unsigned long get_rate_ssi(struct clk *clk) 216static unsigned long get_rate_ssi(struct clk *clk)
233{ 217{
234 unsigned long pdr2 = __raw_readl(CCM_BASE + CCM_PDR2); 218 unsigned long pdr2 = __raw_readl(MX35_CCM_PDR2);
235 unsigned long div1, div2, rate; 219 unsigned long div1, div2, rate;
236 220
237 if (pdr2 & (1 << 6)) 221 if (pdr2 & (1 << 6))
@@ -256,7 +240,7 @@ static unsigned long get_rate_ssi(struct clk *clk)
256 240
257static unsigned long get_rate_csi(struct clk *clk) 241static unsigned long get_rate_csi(struct clk *clk)
258{ 242{
259 unsigned long pdr2 = __raw_readl(CCM_BASE + CCM_PDR2); 243 unsigned long pdr2 = __raw_readl(MX35_CCM_PDR2);
260 unsigned long rate; 244 unsigned long rate;
261 245
262 if (pdr2 & (1 << 7)) 246 if (pdr2 & (1 << 7))
@@ -269,7 +253,7 @@ static unsigned long get_rate_csi(struct clk *clk)
269 253
270static unsigned long get_rate_otg(struct clk *clk) 254static unsigned long get_rate_otg(struct clk *clk)
271{ 255{
272 unsigned long pdr4 = __raw_readl(CCM_BASE + CCM_PDR4); 256 unsigned long pdr4 = __raw_readl(MX35_CCM_PDR4);
273 unsigned long rate; 257 unsigned long rate;
274 258
275 if (pdr4 & (1 << 9)) 259 if (pdr4 & (1 << 9))
@@ -282,8 +266,8 @@ static unsigned long get_rate_otg(struct clk *clk)
282 266
283static unsigned long get_rate_ipg_per(struct clk *clk) 267static unsigned long get_rate_ipg_per(struct clk *clk)
284{ 268{
285 unsigned long pdr0 = __raw_readl(CCM_BASE + CCM_PDR0); 269 unsigned long pdr0 = __raw_readl(MXC_CCM_PDR0);
286 unsigned long pdr4 = __raw_readl(CCM_BASE + CCM_PDR4); 270 unsigned long pdr4 = __raw_readl(MX35_CCM_PDR4);
287 unsigned long div; 271 unsigned long div;
288 272
289 if (pdr0 & (1 << 26)) { 273 if (pdr0 & (1 << 26)) {
@@ -297,7 +281,7 @@ static unsigned long get_rate_ipg_per(struct clk *clk)
297 281
298static unsigned long get_rate_hsp(struct clk *clk) 282static unsigned long get_rate_hsp(struct clk *clk)
299{ 283{
300 unsigned long hsp_podf = (__raw_readl(CCM_BASE + CCM_PDR0) >> 20) & 0x03; 284 unsigned long hsp_podf = (__raw_readl(MXC_CCM_PDR0) >> 20) & 0x03;
301 unsigned long fref = get_rate_mpll(); 285 unsigned long fref = get_rate_mpll();
302 286
303 if (fref > 400 * 1000 * 1000) { 287 if (fref > 400 * 1000 * 1000) {
@@ -345,7 +329,7 @@ static void clk_cgr_disable(struct clk *clk)
345#define DEFINE_CLOCK(name, i, er, es, gr, sr) \ 329#define DEFINE_CLOCK(name, i, er, es, gr, sr) \
346 static struct clk name = { \ 330 static struct clk name = { \
347 .id = i, \ 331 .id = i, \
348 .enable_reg = CCM_BASE + er, \ 332 .enable_reg = er, \
349 .enable_shift = es, \ 333 .enable_shift = es, \
350 .get_rate = gr, \ 334 .get_rate = gr, \
351 .set_rate = sr, \ 335 .set_rate = sr, \
@@ -353,59 +337,59 @@ static void clk_cgr_disable(struct clk *clk)
353 .disable = clk_cgr_disable, \ 337 .disable = clk_cgr_disable, \
354 } 338 }
355 339
356DEFINE_CLOCK(asrc_clk, 0, CCM_CGR0, 0, NULL, NULL); 340DEFINE_CLOCK(asrc_clk, 0, MX35_CCM_CGR0, 0, NULL, NULL);
357DEFINE_CLOCK(pata_clk, 0, CCM_CGR0, 2, get_rate_ipg, NULL); 341DEFINE_CLOCK(pata_clk, 0, MX35_CCM_CGR0, 2, get_rate_ipg, NULL);
358/* DEFINE_CLOCK(audmux_clk, 0, CCM_CGR0, 4, NULL, NULL); */ 342/* DEFINE_CLOCK(audmux_clk, 0, MX35_CCM_CGR0, 4, NULL, NULL); */
359DEFINE_CLOCK(can1_clk, 0, CCM_CGR0, 6, get_rate_ipg, NULL); 343DEFINE_CLOCK(can1_clk, 0, MX35_CCM_CGR0, 6, get_rate_ipg, NULL);
360DEFINE_CLOCK(can2_clk, 1, CCM_CGR0, 8, get_rate_ipg, NULL); 344DEFINE_CLOCK(can2_clk, 1, MX35_CCM_CGR0, 8, get_rate_ipg, NULL);
361DEFINE_CLOCK(cspi1_clk, 0, CCM_CGR0, 10, get_rate_ipg, NULL); 345DEFINE_CLOCK(cspi1_clk, 0, MX35_CCM_CGR0, 10, get_rate_ipg, NULL);
362DEFINE_CLOCK(cspi2_clk, 1, CCM_CGR0, 12, get_rate_ipg, NULL); 346DEFINE_CLOCK(cspi2_clk, 1, MX35_CCM_CGR0, 12, get_rate_ipg, NULL);
363DEFINE_CLOCK(ect_clk, 0, CCM_CGR0, 14, get_rate_ipg, NULL); 347DEFINE_CLOCK(ect_clk, 0, MX35_CCM_CGR0, 14, get_rate_ipg, NULL);
364DEFINE_CLOCK(edio_clk, 0, CCM_CGR0, 16, NULL, NULL); 348DEFINE_CLOCK(edio_clk, 0, MX35_CCM_CGR0, 16, NULL, NULL);
365DEFINE_CLOCK(emi_clk, 0, CCM_CGR0, 18, get_rate_ipg, NULL); 349DEFINE_CLOCK(emi_clk, 0, MX35_CCM_CGR0, 18, get_rate_ipg, NULL);
366DEFINE_CLOCK(epit1_clk, 0, CCM_CGR0, 20, get_rate_ipg, NULL); 350DEFINE_CLOCK(epit1_clk, 0, MX35_CCM_CGR0, 20, get_rate_ipg, NULL);
367DEFINE_CLOCK(epit2_clk, 1, CCM_CGR0, 22, get_rate_ipg, NULL); 351DEFINE_CLOCK(epit2_clk, 1, MX35_CCM_CGR0, 22, get_rate_ipg, NULL);
368DEFINE_CLOCK(esai_clk, 0, CCM_CGR0, 24, NULL, NULL); 352DEFINE_CLOCK(esai_clk, 0, MX35_CCM_CGR0, 24, NULL, NULL);
369DEFINE_CLOCK(esdhc1_clk, 0, CCM_CGR0, 26, get_rate_sdhc, NULL); 353DEFINE_CLOCK(esdhc1_clk, 0, MX35_CCM_CGR0, 26, get_rate_sdhc, NULL);
370DEFINE_CLOCK(esdhc2_clk, 1, CCM_CGR0, 28, get_rate_sdhc, NULL); 354DEFINE_CLOCK(esdhc2_clk, 1, MX35_CCM_CGR0, 28, get_rate_sdhc, NULL);
371DEFINE_CLOCK(esdhc3_clk, 2, CCM_CGR0, 30, get_rate_sdhc, NULL); 355DEFINE_CLOCK(esdhc3_clk, 2, MX35_CCM_CGR0, 30, get_rate_sdhc, NULL);
372 356
373DEFINE_CLOCK(fec_clk, 0, CCM_CGR1, 0, get_rate_ipg, NULL); 357DEFINE_CLOCK(fec_clk, 0, MX35_CCM_CGR1, 0, get_rate_ipg, NULL);
374DEFINE_CLOCK(gpio1_clk, 0, CCM_CGR1, 2, NULL, NULL); 358DEFINE_CLOCK(gpio1_clk, 0, MX35_CCM_CGR1, 2, NULL, NULL);
375DEFINE_CLOCK(gpio2_clk, 1, CCM_CGR1, 4, NULL, NULL); 359DEFINE_CLOCK(gpio2_clk, 1, MX35_CCM_CGR1, 4, NULL, NULL);
376DEFINE_CLOCK(gpio3_clk, 2, CCM_CGR1, 6, NULL, NULL); 360DEFINE_CLOCK(gpio3_clk, 2, MX35_CCM_CGR1, 6, NULL, NULL);
377DEFINE_CLOCK(gpt_clk, 0, CCM_CGR1, 8, get_rate_ipg, NULL); 361DEFINE_CLOCK(gpt_clk, 0, MX35_CCM_CGR1, 8, get_rate_ipg, NULL);
378DEFINE_CLOCK(i2c1_clk, 0, CCM_CGR1, 10, get_rate_ipg_per, NULL); 362DEFINE_CLOCK(i2c1_clk, 0, MX35_CCM_CGR1, 10, get_rate_ipg_per, NULL);
379DEFINE_CLOCK(i2c2_clk, 1, CCM_CGR1, 12, get_rate_ipg_per, NULL); 363DEFINE_CLOCK(i2c2_clk, 1, MX35_CCM_CGR1, 12, get_rate_ipg_per, NULL);
380DEFINE_CLOCK(i2c3_clk, 2, CCM_CGR1, 14, get_rate_ipg_per, NULL); 364DEFINE_CLOCK(i2c3_clk, 2, MX35_CCM_CGR1, 14, get_rate_ipg_per, NULL);
381DEFINE_CLOCK(iomuxc_clk, 0, CCM_CGR1, 16, NULL, NULL); 365DEFINE_CLOCK(iomuxc_clk, 0, MX35_CCM_CGR1, 16, NULL, NULL);
382DEFINE_CLOCK(ipu_clk, 0, CCM_CGR1, 18, get_rate_hsp, NULL); 366DEFINE_CLOCK(ipu_clk, 0, MX35_CCM_CGR1, 18, get_rate_hsp, NULL);
383DEFINE_CLOCK(kpp_clk, 0, CCM_CGR1, 20, get_rate_ipg, NULL); 367DEFINE_CLOCK(kpp_clk, 0, MX35_CCM_CGR1, 20, get_rate_ipg, NULL);
384DEFINE_CLOCK(mlb_clk, 0, CCM_CGR1, 22, get_rate_ahb, NULL); 368DEFINE_CLOCK(mlb_clk, 0, MX35_CCM_CGR1, 22, get_rate_ahb, NULL);
385DEFINE_CLOCK(mshc_clk, 0, CCM_CGR1, 24, get_rate_mshc, NULL); 369DEFINE_CLOCK(mshc_clk, 0, MX35_CCM_CGR1, 24, get_rate_mshc, NULL);
386DEFINE_CLOCK(owire_clk, 0, CCM_CGR1, 26, get_rate_ipg_per, NULL); 370DEFINE_CLOCK(owire_clk, 0, MX35_CCM_CGR1, 26, get_rate_ipg_per, NULL);
387DEFINE_CLOCK(pwm_clk, 0, CCM_CGR1, 28, get_rate_ipg_per, NULL); 371DEFINE_CLOCK(pwm_clk, 0, MX35_CCM_CGR1, 28, get_rate_ipg_per, NULL);
388DEFINE_CLOCK(rngc_clk, 0, CCM_CGR1, 30, get_rate_ipg, NULL); 372DEFINE_CLOCK(rngc_clk, 0, MX35_CCM_CGR1, 30, get_rate_ipg, NULL);
389 373
390DEFINE_CLOCK(rtc_clk, 0, CCM_CGR2, 0, get_rate_ipg, NULL); 374DEFINE_CLOCK(rtc_clk, 0, MX35_CCM_CGR2, 0, get_rate_ipg, NULL);
391DEFINE_CLOCK(rtic_clk, 0, CCM_CGR2, 2, get_rate_ahb, NULL); 375DEFINE_CLOCK(rtic_clk, 0, MX35_CCM_CGR2, 2, get_rate_ahb, NULL);
392DEFINE_CLOCK(scc_clk, 0, CCM_CGR2, 4, get_rate_ipg, NULL); 376DEFINE_CLOCK(scc_clk, 0, MX35_CCM_CGR2, 4, get_rate_ipg, NULL);
393DEFINE_CLOCK(sdma_clk, 0, CCM_CGR2, 6, NULL, NULL); 377DEFINE_CLOCK(sdma_clk, 0, MX35_CCM_CGR2, 6, NULL, NULL);
394DEFINE_CLOCK(spba_clk, 0, CCM_CGR2, 8, get_rate_ipg, NULL); 378DEFINE_CLOCK(spba_clk, 0, MX35_CCM_CGR2, 8, get_rate_ipg, NULL);
395DEFINE_CLOCK(spdif_clk, 0, CCM_CGR2, 10, NULL, NULL); 379DEFINE_CLOCK(spdif_clk, 0, MX35_CCM_CGR2, 10, NULL, NULL);
396DEFINE_CLOCK(ssi1_clk, 0, CCM_CGR2, 12, get_rate_ssi, NULL); 380DEFINE_CLOCK(ssi1_clk, 0, MX35_CCM_CGR2, 12, get_rate_ssi, NULL);
397DEFINE_CLOCK(ssi2_clk, 1, CCM_CGR2, 14, get_rate_ssi, NULL); 381DEFINE_CLOCK(ssi2_clk, 1, MX35_CCM_CGR2, 14, get_rate_ssi, NULL);
398DEFINE_CLOCK(uart1_clk, 0, CCM_CGR2, 16, get_rate_uart, NULL); 382DEFINE_CLOCK(uart1_clk, 0, MX35_CCM_CGR2, 16, get_rate_uart, NULL);
399DEFINE_CLOCK(uart2_clk, 1, CCM_CGR2, 18, get_rate_uart, NULL); 383DEFINE_CLOCK(uart2_clk, 1, MX35_CCM_CGR2, 18, get_rate_uart, NULL);
400DEFINE_CLOCK(uart3_clk, 2, CCM_CGR2, 20, get_rate_uart, NULL); 384DEFINE_CLOCK(uart3_clk, 2, MX35_CCM_CGR2, 20, get_rate_uart, NULL);
401DEFINE_CLOCK(usbotg_clk, 0, CCM_CGR2, 22, get_rate_otg, NULL); 385DEFINE_CLOCK(usbotg_clk, 0, MX35_CCM_CGR2, 22, get_rate_otg, NULL);
402DEFINE_CLOCK(wdog_clk, 0, CCM_CGR2, 24, NULL, NULL); 386DEFINE_CLOCK(wdog_clk, 0, MX35_CCM_CGR2, 24, NULL, NULL);
403DEFINE_CLOCK(max_clk, 0, CCM_CGR2, 26, NULL, NULL); 387DEFINE_CLOCK(max_clk, 0, MX35_CCM_CGR2, 26, NULL, NULL);
404DEFINE_CLOCK(audmux_clk, 0, CCM_CGR2, 30, NULL, NULL); 388DEFINE_CLOCK(audmux_clk, 0, MX35_CCM_CGR2, 30, NULL, NULL);
405 389
406DEFINE_CLOCK(csi_clk, 0, CCM_CGR3, 0, get_rate_csi, NULL); 390DEFINE_CLOCK(csi_clk, 0, MX35_CCM_CGR3, 0, get_rate_csi, NULL);
407DEFINE_CLOCK(iim_clk, 0, CCM_CGR3, 2, NULL, NULL); 391DEFINE_CLOCK(iim_clk, 0, MX35_CCM_CGR3, 2, NULL, NULL);
408DEFINE_CLOCK(gpu2d_clk, 0, CCM_CGR3, 4, NULL, NULL); 392DEFINE_CLOCK(gpu2d_clk, 0, MX35_CCM_CGR3, 4, NULL, NULL);
409 393
410DEFINE_CLOCK(usbahb_clk, 0, 0, 0, get_rate_ahb, NULL); 394DEFINE_CLOCK(usbahb_clk, 0, 0, 0, get_rate_ahb, NULL);
411 395
@@ -422,7 +406,7 @@ static unsigned long get_rate_nfc(struct clk *clk)
422{ 406{
423 unsigned long div1; 407 unsigned long div1;
424 408
425 div1 = (__raw_readl(CCM_BASE + CCM_PDR4) >> 28) + 1; 409 div1 = (__raw_readl(MX35_CCM_PDR4) >> 28) + 1;
426 410
427 return get_rate_ahb(NULL) / div1; 411 return get_rate_ahb(NULL) / div1;
428} 412}
@@ -518,11 +502,11 @@ int __init mx35_clocks_init()
518 /* Turn off all clocks except the ones we need to survive, namely: 502 /* Turn off all clocks except the ones we need to survive, namely:
519 * EMI, GPIO1/2/3, GPT, IOMUX, MAX and eventually uart 503 * EMI, GPIO1/2/3, GPT, IOMUX, MAX and eventually uart
520 */ 504 */
521 __raw_writel((3 << 18), CCM_BASE + CCM_CGR0); 505 __raw_writel((3 << 18), MX35_CCM_CGR0);
522 __raw_writel((3 << 2) | (3 << 4) | (3 << 6) | (3 << 8) | (3 << 16), 506 __raw_writel((3 << 2) | (3 << 4) | (3 << 6) | (3 << 8) | (3 << 16),
523 CCM_BASE + CCM_CGR1); 507 MX35_CCM_CGR1);
524 __raw_writel(cgr2, CCM_BASE + CCM_CGR2); 508 __raw_writel(cgr2, MX35_CCM_CGR2);
525 __raw_writel(0, CCM_BASE + CCM_CGR3); 509 __raw_writel(0, MX35_CCM_CGR3);
526 510
527 clk_enable(&iim_clk); 511 clk_enable(&iim_clk);
528 imx_print_silicon_rev("i.MX35", mx35_revision()); 512 imx_print_silicon_rev("i.MX35", mx35_revision());
@@ -533,7 +517,7 @@ int __init mx35_clocks_init()
533 * extra clocks turned on, otherwise the MX35 boot ROM code will 517 * extra clocks turned on, otherwise the MX35 boot ROM code will
534 * hang after a watchdog reset. 518 * hang after a watchdog reset.
535 */ 519 */
536 if (!(__raw_readl(CCM_BASE + CCM_RCSR) & (3 << 10))) { 520 if (!(__raw_readl(MX35_CCM_RCSR) & (3 << 10))) {
537 /* Additionally turn on UART1, SCC, and IIM clocks */ 521 /* Additionally turn on UART1, SCC, and IIM clocks */
538 clk_enable(&iim_clk); 522 clk_enable(&iim_clk);
539 clk_enable(&uart1_clk); 523 clk_enable(&uart1_clk);
diff --git a/arch/arm/mach-imx/clock-imx6q.c b/arch/arm/mach-imx/clock-imx6q.c
index 2d88f8b9a45..111c328f542 100644
--- a/arch/arm/mach-imx/clock-imx6q.c
+++ b/arch/arm/mach-imx/clock-imx6q.c
@@ -329,6 +329,12 @@
329#define BM_CLPCR_MASK_SCU_IDLE (0x1 << 26) 329#define BM_CLPCR_MASK_SCU_IDLE (0x1 << 26)
330#define BM_CLPCR_MASK_L2CC_IDLE (0x1 << 27) 330#define BM_CLPCR_MASK_L2CC_IDLE (0x1 << 27)
331 331
332#define BP_CCOSR_CKO1_EN 7
333#define BP_CCOSR_CKO1_PODF 4
334#define BM_CCOSR_CKO1_PODF (0x7 << 4)
335#define BP_CCOSR_CKO1_SEL 0
336#define BM_CCOSR_CKO1_SEL (0xf << 0)
337
332#define FREQ_480M 480000000 338#define FREQ_480M 480000000
333#define FREQ_528M 528000000 339#define FREQ_528M 528000000
334#define FREQ_594M 594000000 340#define FREQ_594M 594000000
@@ -393,6 +399,7 @@ static struct clk ipu1_di1_clk;
393static struct clk ipu2_di0_clk; 399static struct clk ipu2_di0_clk;
394static struct clk ipu2_di1_clk; 400static struct clk ipu2_di1_clk;
395static struct clk enfc_clk; 401static struct clk enfc_clk;
402static struct clk cko1_clk;
396static struct clk dummy_clk = {}; 403static struct clk dummy_clk = {};
397 404
398static unsigned long external_high_reference; 405static unsigned long external_high_reference;
@@ -938,6 +945,24 @@ static void _clk_disable(struct clk *clk)
938 writel_relaxed(reg, clk->enable_reg); 945 writel_relaxed(reg, clk->enable_reg);
939} 946}
940 947
948static int _clk_enable_1b(struct clk *clk)
949{
950 u32 reg;
951 reg = readl_relaxed(clk->enable_reg);
952 reg |= 0x1 << clk->enable_shift;
953 writel_relaxed(reg, clk->enable_reg);
954
955 return 0;
956}
957
958static void _clk_disable_1b(struct clk *clk)
959{
960 u32 reg;
961 reg = readl_relaxed(clk->enable_reg);
962 reg &= ~(0x1 << clk->enable_shift);
963 writel_relaxed(reg, clk->enable_reg);
964}
965
941struct divider { 966struct divider {
942 struct clk *clk; 967 struct clk *clk;
943 void __iomem *reg; 968 void __iomem *reg;
@@ -983,6 +1008,7 @@ DEF_CLK_DIV1(ipu2_di0_pre_div, &ipu2_di0_pre_clk, CSCDR2, IPU2_DI0_PRE);
983DEF_CLK_DIV1(ipu2_di1_pre_div, &ipu2_di1_pre_clk, CSCDR2, IPU2_DI1_PRE); 1008DEF_CLK_DIV1(ipu2_di1_pre_div, &ipu2_di1_pre_clk, CSCDR2, IPU2_DI1_PRE);
984DEF_CLK_DIV1(ipu1_div, &ipu1_clk, CSCDR3, IPU1_HSP); 1009DEF_CLK_DIV1(ipu1_div, &ipu1_clk, CSCDR3, IPU1_HSP);
985DEF_CLK_DIV1(ipu2_div, &ipu2_clk, CSCDR3, IPU2_HSP); 1010DEF_CLK_DIV1(ipu2_div, &ipu2_clk, CSCDR3, IPU2_HSP);
1011DEF_CLK_DIV1(cko1_div, &cko1_clk, CCOSR, CKO1);
986 1012
987#define DEF_CLK_DIV2(d, c, r, b) \ 1013#define DEF_CLK_DIV2(d, c, r, b) \
988 static struct divider d = { \ 1014 static struct divider d = { \
@@ -1038,6 +1064,7 @@ static struct divider *dividers[] = {
1038 &enfc_div, 1064 &enfc_div,
1039 &spdif_div, 1065 &spdif_div,
1040 &asrc_serial_div, 1066 &asrc_serial_div,
1067 &cko1_div,
1041}; 1068};
1042 1069
1043static unsigned long ldb_di_clk_get_rate(struct clk *clk) 1070static unsigned long ldb_di_clk_get_rate(struct clk *clk)
@@ -1625,6 +1652,32 @@ DEF_IPU_DI_MUX(CSCDR2, 2, 1);
1625DEF_IPU_MUX(1); 1652DEF_IPU_MUX(1);
1626DEF_IPU_MUX(2); 1653DEF_IPU_MUX(2);
1627 1654
1655static struct multiplexer cko1_mux = {
1656 .clk = &cko1_clk,
1657 .reg = CCOSR,
1658 .bp = BP_CCOSR_CKO1_SEL,
1659 .bm = BM_CCOSR_CKO1_SEL,
1660 .parents = {
1661 &pll3_usb_otg,
1662 &pll2_bus,
1663 &pll1_sys,
1664 &pll5_video,
1665 &dummy_clk,
1666 &axi_clk,
1667 &enfc_clk,
1668 &ipu1_di0_clk,
1669 &ipu1_di1_clk,
1670 &ipu2_di0_clk,
1671 &ipu2_di1_clk,
1672 &ahb_clk,
1673 &ipg_clk,
1674 &ipg_perclk,
1675 &ckil_clk,
1676 &pll4_audio,
1677 NULL
1678 },
1679};
1680
1628static struct multiplexer *multiplexers[] = { 1681static struct multiplexer *multiplexers[] = {
1629 &axi_mux, 1682 &axi_mux,
1630 &periph_mux, 1683 &periph_mux,
@@ -1667,6 +1720,7 @@ static struct multiplexer *multiplexers[] = {
1667 &ipu2_di1_mux, 1720 &ipu2_di1_mux,
1668 &ipu1_mux, 1721 &ipu1_mux,
1669 &ipu2_mux, 1722 &ipu2_mux,
1723 &cko1_mux,
1670}; 1724};
1671 1725
1672static int _clk_set_parent(struct clk *clk, struct clk *parent) 1726static int _clk_set_parent(struct clk *clk, struct clk *parent)
@@ -1690,7 +1744,7 @@ static int _clk_set_parent(struct clk *clk, struct clk *parent)
1690 break; 1744 break;
1691 i++; 1745 i++;
1692 } 1746 }
1693 if (!m->parents[i]) 1747 if (!m->parents[i] || m->parents[i] == &dummy_clk)
1694 return -EINVAL; 1748 return -EINVAL;
1695 1749
1696 val = readl_relaxed(m->reg); 1750 val = readl_relaxed(m->reg);
@@ -1745,6 +1799,20 @@ DEF_NG_CLK(asrc_serial_clk, &pll3_usb_otg);
1745 .secondary = s, \ 1799 .secondary = s, \
1746 } 1800 }
1747 1801
1802#define DEF_CLK_1B(name, er, es, p, s) \
1803 static struct clk name = { \
1804 .enable_reg = er, \
1805 .enable_shift = es, \
1806 .enable = _clk_enable_1b, \
1807 .disable = _clk_disable_1b, \
1808 .get_rate = _clk_get_rate, \
1809 .set_rate = _clk_set_rate, \
1810 .round_rate = _clk_round_rate, \
1811 .set_parent = _clk_set_parent, \
1812 .parent = p, \
1813 .secondary = s, \
1814 }
1815
1748DEF_CLK(aips_tz1_clk, CCGR0, CG0, &ahb_clk, NULL); 1816DEF_CLK(aips_tz1_clk, CCGR0, CG0, &ahb_clk, NULL);
1749DEF_CLK(aips_tz2_clk, CCGR0, CG1, &ahb_clk, NULL); 1817DEF_CLK(aips_tz2_clk, CCGR0, CG1, &ahb_clk, NULL);
1750DEF_CLK(apbh_dma_clk, CCGR0, CG2, &ahb_clk, NULL); 1818DEF_CLK(apbh_dma_clk, CCGR0, CG2, &ahb_clk, NULL);
@@ -1811,6 +1879,7 @@ DEF_CLK(usdhc4_clk, CCGR6, CG4, &pll2_pfd_400m, NULL);
1811DEF_CLK(emi_slow_clk, CCGR6, CG5, &axi_clk, NULL); 1879DEF_CLK(emi_slow_clk, CCGR6, CG5, &axi_clk, NULL);
1812DEF_CLK(vdo_axi_clk, CCGR6, CG6, &axi_clk, NULL); 1880DEF_CLK(vdo_axi_clk, CCGR6, CG6, &axi_clk, NULL);
1813DEF_CLK(vpu_clk, CCGR6, CG7, &axi_clk, NULL); 1881DEF_CLK(vpu_clk, CCGR6, CG7, &axi_clk, NULL);
1882DEF_CLK_1B(cko1_clk, CCOSR, BP_CCOSR_CKO1_EN, &pll2_bus, NULL);
1814 1883
1815static int pcie_clk_enable(struct clk *clk) 1884static int pcie_clk_enable(struct clk *clk)
1816{ 1885{
@@ -1922,6 +1991,7 @@ static struct clk_lookup lookups[] = {
1922 _REGISTER_CLOCK(NULL, "gpmi_io_clk", gpmi_io_clk), 1991 _REGISTER_CLOCK(NULL, "gpmi_io_clk", gpmi_io_clk),
1923 _REGISTER_CLOCK(NULL, "usboh3_clk", usboh3_clk), 1992 _REGISTER_CLOCK(NULL, "usboh3_clk", usboh3_clk),
1924 _REGISTER_CLOCK(NULL, "sata_clk", sata_clk), 1993 _REGISTER_CLOCK(NULL, "sata_clk", sata_clk),
1994 _REGISTER_CLOCK(NULL, "cko1_clk", cko1_clk),
1925}; 1995};
1926 1996
1927int imx6q_set_lpm(enum mxc_cpu_pwr_mode mode) 1997int imx6q_set_lpm(enum mxc_cpu_pwr_mode mode)
@@ -2029,6 +2099,8 @@ int __init mx6q_clocks_init(void)
2029 clk_set_rate(&usdhc3_clk, 49500000); 2099 clk_set_rate(&usdhc3_clk, 49500000);
2030 clk_set_rate(&usdhc4_clk, 49500000); 2100 clk_set_rate(&usdhc4_clk, 49500000);
2031 2101
2102 clk_set_parent(&cko1_clk, &ahb_clk);
2103
2032 np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-gpt"); 2104 np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-gpt");
2033 base = of_iomap(np, 0); 2105 base = of_iomap(np, 0);
2034 WARN_ON(!base); 2106 WARN_ON(!base);
diff --git a/arch/arm/mach-imx/cpu-imx5.c b/arch/arm/mach-imx/cpu-imx5.c
index 5e2e7a84386..aa15c517d06 100644
--- a/arch/arm/mach-imx/cpu-imx5.c
+++ b/arch/arm/mach-imx/cpu-imx5.c
@@ -149,39 +149,3 @@ int mx50_revision(void)
149 return mx5_cpu_rev; 149 return mx5_cpu_rev;
150} 150}
151EXPORT_SYMBOL(mx50_revision); 151EXPORT_SYMBOL(mx50_revision);
152
153static int __init post_cpu_init(void)
154{
155 unsigned int reg;
156 void __iomem *base;
157
158 if (cpu_is_mx51() || cpu_is_mx53()) {
159 if (cpu_is_mx51())
160 base = MX51_IO_ADDRESS(MX51_AIPS1_BASE_ADDR);
161 else
162 base = MX53_IO_ADDRESS(MX53_AIPS1_BASE_ADDR);
163
164 __raw_writel(0x0, base + 0x40);
165 __raw_writel(0x0, base + 0x44);
166 __raw_writel(0x0, base + 0x48);
167 __raw_writel(0x0, base + 0x4C);
168 reg = __raw_readl(base + 0x50) & 0x00FFFFFF;
169 __raw_writel(reg, base + 0x50);
170
171 if (cpu_is_mx51())
172 base = MX51_IO_ADDRESS(MX51_AIPS2_BASE_ADDR);
173 else
174 base = MX53_IO_ADDRESS(MX53_AIPS2_BASE_ADDR);
175
176 __raw_writel(0x0, base + 0x40);
177 __raw_writel(0x0, base + 0x44);
178 __raw_writel(0x0, base + 0x48);
179 __raw_writel(0x0, base + 0x4C);
180 reg = __raw_readl(base + 0x50) & 0x00FFFFFF;
181 __raw_writel(reg, base + 0x50);
182 }
183
184 return 0;
185}
186
187postcore_initcall(post_cpu_init);
diff --git a/arch/arm/mach-imx/cpu_op-mx51.c b/arch/arm/mach-imx/cpu_op-mx51.c
index 9d34c3d4c02..7b92cd6da6d 100644
--- a/arch/arm/mach-imx/cpu_op-mx51.c
+++ b/arch/arm/mach-imx/cpu_op-mx51.c
@@ -11,6 +11,7 @@
11 * http://www.gnu.org/copyleft/gpl.html 11 * http://www.gnu.org/copyleft/gpl.html
12 */ 12 */
13 13
14#include <linux/bug.h>
14#include <linux/types.h> 15#include <linux/types.h>
15#include <mach/hardware.h> 16#include <mach/hardware.h>
16#include <linux/kernel.h> 17#include <linux/kernel.h>
diff --git a/arch/arm/mach-imx/crmregs-imx31.h b/arch/arm/mach-imx/crmregs-imx3.h
index 37a8a07beda..53141273df4 100644
--- a/arch/arm/mach-imx/crmregs-imx31.h
+++ b/arch/arm/mach-imx/crmregs-imx3.h
@@ -24,23 +24,36 @@
24#define CKIH_CLK_FREQ_27MHZ 27000000 24#define CKIH_CLK_FREQ_27MHZ 27000000
25#define CKIL_CLK_FREQ 32768 25#define CKIL_CLK_FREQ 32768
26 26
27#define MXC_CCM_BASE MX31_IO_ADDRESS(MX31_CCM_BASE_ADDR) 27#define MXC_CCM_BASE (cpu_is_mx31() ? \
28MX31_IO_ADDRESS(MX31_CCM_BASE_ADDR) : MX35_IO_ADDRESS(MX35_CCM_BASE_ADDR))
28 29
29/* Register addresses */ 30/* Register addresses */
30#define MXC_CCM_CCMR (MXC_CCM_BASE + 0x00) 31#define MXC_CCM_CCMR (MXC_CCM_BASE + 0x00)
31#define MXC_CCM_PDR0 (MXC_CCM_BASE + 0x04) 32#define MXC_CCM_PDR0 (MXC_CCM_BASE + 0x04)
32#define MXC_CCM_PDR1 (MXC_CCM_BASE + 0x08) 33#define MXC_CCM_PDR1 (MXC_CCM_BASE + 0x08)
34#define MX35_CCM_PDR2 (MXC_CCM_BASE + 0x0C)
33#define MXC_CCM_RCSR (MXC_CCM_BASE + 0x0C) 35#define MXC_CCM_RCSR (MXC_CCM_BASE + 0x0C)
36#define MX35_CCM_PDR3 (MXC_CCM_BASE + 0x10)
34#define MXC_CCM_MPCTL (MXC_CCM_BASE + 0x10) 37#define MXC_CCM_MPCTL (MXC_CCM_BASE + 0x10)
38#define MX35_CCM_PDR4 (MXC_CCM_BASE + 0x14)
35#define MXC_CCM_UPCTL (MXC_CCM_BASE + 0x14) 39#define MXC_CCM_UPCTL (MXC_CCM_BASE + 0x14)
40#define MX35_CCM_RCSR (MXC_CCM_BASE + 0x18)
36#define MXC_CCM_SRPCTL (MXC_CCM_BASE + 0x18) 41#define MXC_CCM_SRPCTL (MXC_CCM_BASE + 0x18)
42#define MX35_CCM_MPCTL (MXC_CCM_BASE + 0x1C)
37#define MXC_CCM_COSR (MXC_CCM_BASE + 0x1C) 43#define MXC_CCM_COSR (MXC_CCM_BASE + 0x1C)
44#define MX35_CCM_PPCTL (MXC_CCM_BASE + 0x20)
38#define MXC_CCM_CGR0 (MXC_CCM_BASE + 0x20) 45#define MXC_CCM_CGR0 (MXC_CCM_BASE + 0x20)
46#define MX35_CCM_ACMR (MXC_CCM_BASE + 0x24)
39#define MXC_CCM_CGR1 (MXC_CCM_BASE + 0x24) 47#define MXC_CCM_CGR1 (MXC_CCM_BASE + 0x24)
48#define MX35_CCM_COSR (MXC_CCM_BASE + 0x28)
40#define MXC_CCM_CGR2 (MXC_CCM_BASE + 0x28) 49#define MXC_CCM_CGR2 (MXC_CCM_BASE + 0x28)
50#define MX35_CCM_CGR0 (MXC_CCM_BASE + 0x2C)
41#define MXC_CCM_WIMR (MXC_CCM_BASE + 0x2C) 51#define MXC_CCM_WIMR (MXC_CCM_BASE + 0x2C)
52#define MX35_CCM_CGR1 (MXC_CCM_BASE + 0x30)
42#define MXC_CCM_LDC (MXC_CCM_BASE + 0x30) 53#define MXC_CCM_LDC (MXC_CCM_BASE + 0x30)
54#define MX35_CCM_CGR2 (MXC_CCM_BASE + 0x34)
43#define MXC_CCM_DCVR0 (MXC_CCM_BASE + 0x34) 55#define MXC_CCM_DCVR0 (MXC_CCM_BASE + 0x34)
56#define MX35_CCM_CGR3 (MXC_CCM_BASE + 0x38)
44#define MXC_CCM_DCVR1 (MXC_CCM_BASE + 0x38) 57#define MXC_CCM_DCVR1 (MXC_CCM_BASE + 0x38)
45#define MXC_CCM_DCVR2 (MXC_CCM_BASE + 0x3C) 58#define MXC_CCM_DCVR2 (MXC_CCM_BASE + 0x3C)
46#define MXC_CCM_DCVR3 (MXC_CCM_BASE + 0x40) 59#define MXC_CCM_DCVR3 (MXC_CCM_BASE + 0x40)
@@ -64,6 +77,7 @@
64#define MXC_CCM_CCMR_SSI2S_MASK (0x3 << 21) 77#define MXC_CCM_CCMR_SSI2S_MASK (0x3 << 21)
65#define MXC_CCM_CCMR_LPM_OFFSET 14 78#define MXC_CCM_CCMR_LPM_OFFSET 14
66#define MXC_CCM_CCMR_LPM_MASK (0x3 << 14) 79#define MXC_CCM_CCMR_LPM_MASK (0x3 << 14)
80#define MXC_CCM_CCMR_LPM_WAIT_MX35 (0x1 << 14)
67#define MXC_CCM_CCMR_FIRS_OFFSET 11 81#define MXC_CCM_CCMR_FIRS_OFFSET 11
68#define MXC_CCM_CCMR_FIRS_MASK (0x3 << 11) 82#define MXC_CCM_CCMR_FIRS_MASK (0x3 << 11)
69#define MXC_CCM_CCMR_UPE (1 << 9) 83#define MXC_CCM_CCMR_UPE (1 << 9)
diff --git a/arch/arm/mach-imx/devices-imx27.h b/arch/arm/mach-imx/devices-imx27.h
index 2f727d7c380..28537a5d904 100644
--- a/arch/arm/mach-imx/devices-imx27.h
+++ b/arch/arm/mach-imx/devices-imx27.h
@@ -50,6 +50,8 @@ 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) \
54 imx_add_mx2_emmaprp(&imx27_mx2_camera_data)
53 55
54extern const struct imx_mxc_ehci_data imx27_mxc_ehci_otg_data; 56extern const struct imx_mxc_ehci_data imx27_mxc_ehci_otg_data;
55#define imx27_add_mxc_ehci_otg(pdata) \ 57#define imx27_add_mxc_ehci_otg(pdata) \
diff --git a/arch/arm/mach-imx/imx27-dt.c b/arch/arm/mach-imx/imx27-dt.c
new file mode 100644
index 00000000000..861ceb8232d
--- /dev/null
+++ b/arch/arm/mach-imx/imx27-dt.c
@@ -0,0 +1,89 @@
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/irqdomain.h>
14#include <linux/of_irq.h>
15#include <linux/of_platform.h>
16#include <asm/mach/arch.h>
17#include <asm/mach/time.h>
18#include <mach/common.h>
19#include <mach/mx27.h>
20
21static const struct of_dev_auxdata imx27_auxdata_lookup[] __initconst = {
22 OF_DEV_AUXDATA("fsl,imx27-uart", MX27_UART1_BASE_ADDR, "imx21-uart.0", NULL),
23 OF_DEV_AUXDATA("fsl,imx27-uart", MX27_UART2_BASE_ADDR, "imx21-uart.1", NULL),
24 OF_DEV_AUXDATA("fsl,imx27-uart", MX27_UART3_BASE_ADDR, "imx21-uart.2", NULL),
25 OF_DEV_AUXDATA("fsl,imx27-fec", MX27_FEC_BASE_ADDR, "imx27-fec.0", NULL),
26 OF_DEV_AUXDATA("fsl,imx27-i2c", MX27_I2C1_BASE_ADDR, "imx-i2c.0", NULL),
27 OF_DEV_AUXDATA("fsl,imx27-i2c", MX27_I2C2_BASE_ADDR, "imx-i2c.1", NULL),
28 OF_DEV_AUXDATA("fsl,imx27-cspi", MX27_CSPI1_BASE_ADDR, "imx27-cspi.0", NULL),
29 OF_DEV_AUXDATA("fsl,imx27-cspi", MX27_CSPI2_BASE_ADDR, "imx27-cspi.1", NULL),
30 OF_DEV_AUXDATA("fsl,imx27-cspi", MX27_CSPI3_BASE_ADDR, "imx27-cspi.2", NULL),
31 OF_DEV_AUXDATA("fsl,imx27-wdt", MX27_WDOG_BASE_ADDR, "imx2-wdt.0", NULL),
32 { /* sentinel */ }
33};
34
35static int __init imx27_avic_add_irq_domain(struct device_node *np,
36 struct device_node *interrupt_parent)
37{
38 irq_domain_add_simple(np, 0);
39 return 0;
40}
41
42static int __init imx27_gpio_add_irq_domain(struct device_node *np,
43 struct device_node *interrupt_parent)
44{
45 static int gpio_irq_base = MXC_GPIO_IRQ_START + ARCH_NR_GPIOS;
46
47 irq_domain_add_simple(np, gpio_irq_base);
48
49 return 0;
50}
51
52static const struct of_device_id imx27_irq_match[] __initconst = {
53 { .compatible = "fsl,imx27-avic", .data = imx27_avic_add_irq_domain, },
54 { .compatible = "fsl,imx27-gpio", .data = imx27_gpio_add_irq_domain, },
55 { /* sentinel */ }
56};
57
58static void __init imx27_dt_init(void)
59{
60 of_irq_init(imx27_irq_match);
61
62 of_platform_populate(NULL, of_default_bus_match_table,
63 imx27_auxdata_lookup, NULL);
64}
65
66static void __init imx27_timer_init(void)
67{
68 mx27_clocks_init_dt();
69}
70
71static struct sys_timer imx27_timer = {
72 .init = imx27_timer_init,
73};
74
75static const char *imx27_dt_board_compat[] __initdata = {
76 "fsl,imx27",
77 NULL
78};
79
80DT_MACHINE_START(IMX27_DT, "Freescale i.MX27 (Device Tree Support)")
81 .map_io = mx27_map_io,
82 .init_early = imx27_init_early,
83 .init_irq = mx27_init_irq,
84 .handle_irq = imx27_handle_irq,
85 .timer = &imx27_timer,
86 .init_machine = imx27_dt_init,
87 .dt_compat = imx27_dt_board_compat,
88 .restart = mxc_restart,
89MACHINE_END
diff --git a/arch/arm/mach-imx/imx51-dt.c b/arch/arm/mach-imx/imx51-dt.c
index 1e03ef42faa..5cca573964f 100644
--- a/arch/arm/mach-imx/imx51-dt.c
+++ b/arch/arm/mach-imx/imx51-dt.c
@@ -104,6 +104,7 @@ static struct sys_timer imx51_timer = {
104 104
105static const char *imx51_dt_board_compat[] __initdata = { 105static const char *imx51_dt_board_compat[] __initdata = {
106 "fsl,imx51-babbage", 106 "fsl,imx51-babbage",
107 "fsl,imx51",
107 NULL 108 NULL
108}; 109};
109 110
diff --git a/arch/arm/mach-imx/imx53-dt.c b/arch/arm/mach-imx/imx53-dt.c
index fd5be0f20fb..4172279b390 100644
--- a/arch/arm/mach-imx/imx53-dt.c
+++ b/arch/arm/mach-imx/imx53-dt.c
@@ -114,6 +114,7 @@ static const char *imx53_dt_board_compat[] __initdata = {
114 "fsl,imx53-evk", 114 "fsl,imx53-evk",
115 "fsl,imx53-qsb", 115 "fsl,imx53-qsb",
116 "fsl,imx53-smd", 116 "fsl,imx53-smd",
117 "fsl,imx53",
117 NULL 118 NULL
118}; 119};
119 120
diff --git a/arch/arm/mach-imx/lluart.c b/arch/arm/mach-imx/lluart.c
index d4ab6f29a76..0213f8dcee8 100644
--- a/arch/arm/mach-imx/lluart.c
+++ b/arch/arm/mach-imx/lluart.c
@@ -17,7 +17,7 @@
17#include <mach/hardware.h> 17#include <mach/hardware.h>
18 18
19static struct map_desc imx_lluart_desc = { 19static struct map_desc imx_lluart_desc = {
20#ifdef CONFIG_DEBUG_IMX6Q_UART 20#ifdef CONFIG_DEBUG_IMX6Q_UART4
21 .virtual = MX6Q_IO_P2V(MX6Q_UART4_BASE_ADDR), 21 .virtual = MX6Q_IO_P2V(MX6Q_UART4_BASE_ADDR),
22 .pfn = __phys_to_pfn(MX6Q_UART4_BASE_ADDR), 22 .pfn = __phys_to_pfn(MX6Q_UART4_BASE_ADDR),
23 .length = MX6Q_UART4_SIZE, 23 .length = MX6Q_UART4_SIZE,
diff --git a/arch/arm/mach-imx/localtimer.c b/arch/arm/mach-imx/localtimer.c
deleted file mode 100644
index 3a163515d41..00000000000
--- a/arch/arm/mach-imx/localtimer.c
+++ /dev/null
@@ -1,35 +0,0 @@
1/*
2 * Copyright 2011 Freescale Semiconductor, Inc.
3 * Copyright 2011 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/init.h>
14#include <linux/clockchips.h>
15#include <linux/of_address.h>
16#include <linux/of_irq.h>
17#include <asm/smp_twd.h>
18
19/*
20 * Setup the local clock events for a CPU.
21 */
22int __cpuinit local_timer_setup(struct clock_event_device *evt)
23{
24 struct device_node *np;
25
26 np = of_find_compatible_node(NULL, NULL, "arm,smp-twd");
27 if (!twd_base) {
28 twd_base = of_iomap(np, 0);
29 WARN_ON(!twd_base);
30 }
31 evt->irq = irq_of_parse_and_map(np, 0);
32 twd_timer_setup(evt);
33
34 return 0;
35}
diff --git a/arch/arm/mach-imx/mach-armadillo5x0.c b/arch/arm/mach-imx/mach-armadillo5x0.c
index e4f426a0989..27bc27e6ea4 100644
--- a/arch/arm/mach-imx/mach-armadillo5x0.c
+++ b/arch/arm/mach-imx/mach-armadillo5x0.c
@@ -51,7 +51,7 @@
51#include <mach/ulpi.h> 51#include <mach/ulpi.h>
52 52
53#include "devices-imx31.h" 53#include "devices-imx31.h"
54#include "crmregs-imx31.h" 54#include "crmregs-imx3.h"
55 55
56static int armadillo5x0_pins[] = { 56static int armadillo5x0_pins[] = {
57 /* UART1 */ 57 /* UART1 */
diff --git a/arch/arm/mach-imx/mach-imx27_visstrim_m10.c b/arch/arm/mach-imx/mach-imx27_visstrim_m10.c
index 428459fbca4..f7b074f496f 100644
--- a/arch/arm/mach-imx/mach-imx27_visstrim_m10.c
+++ b/arch/arm/mach-imx/mach-imx27_visstrim_m10.c
@@ -30,6 +30,10 @@
30#include <linux/input.h> 30#include <linux/input.h>
31#include <linux/gpio.h> 31#include <linux/gpio.h>
32#include <linux/delay.h> 32#include <linux/delay.h>
33#include <linux/dma-mapping.h>
34#include <linux/leds.h>
35#include <linux/memblock.h>
36#include <media/soc_camera.h>
33#include <sound/tlv320aic32x4.h> 37#include <sound/tlv320aic32x4.h>
34#include <asm/mach-types.h> 38#include <asm/mach-types.h>
35#include <asm/mach/arch.h> 39#include <asm/mach/arch.h>
@@ -39,6 +43,8 @@
39 43
40#include "devices-imx27.h" 44#include "devices-imx27.h"
41 45
46#define TVP5150_RSTN (GPIO_PORTC + 18)
47#define TVP5150_PWDN (GPIO_PORTC + 19)
42#define OTG_PHY_CS_GPIO (GPIO_PORTF + 17) 48#define OTG_PHY_CS_GPIO (GPIO_PORTF + 17)
43#define SDHC1_IRQ IRQ_GPIOB(25) 49#define SDHC1_IRQ IRQ_GPIOB(25)
44 50
@@ -100,8 +106,99 @@ static const int visstrim_m10_pins[] __initconst = {
100 PE1_PF_USBOTG_STP, 106 PE1_PF_USBOTG_STP,
101 PB23_PF_USB_PWR, 107 PB23_PF_USB_PWR,
102 PB24_PF_USB_OC, 108 PB24_PF_USB_OC,
109 /* CSI */
110 PB10_PF_CSI_D0,
111 PB11_PF_CSI_D1,
112 PB12_PF_CSI_D2,
113 PB13_PF_CSI_D3,
114 PB14_PF_CSI_D4,
115 PB15_PF_CSI_MCLK,
116 PB16_PF_CSI_PIXCLK,
117 PB17_PF_CSI_D5,
118 PB18_PF_CSI_D6,
119 PB19_PF_CSI_D7,
120 PB20_PF_CSI_VSYNC,
121 PB21_PF_CSI_HSYNC,
103}; 122};
104 123
124/* Camera */
125static int visstrim_camera_power(struct device *dev, int on)
126{
127 gpio_set_value(TVP5150_PWDN, on);
128
129 return 0;
130};
131
132static int visstrim_camera_reset(struct device *dev)
133{
134 gpio_set_value(TVP5150_RSTN, 0);
135 ndelay(500);
136 gpio_set_value(TVP5150_RSTN, 1);
137
138 return 0;
139};
140
141static struct i2c_board_info visstrim_i2c_camera = {
142 I2C_BOARD_INFO("tvp5150", 0x5d),
143};
144
145static struct soc_camera_link iclink_tvp5150 = {
146 .bus_id = 0,
147 .board_info = &visstrim_i2c_camera,
148 .i2c_adapter_id = 0,
149 .power = visstrim_camera_power,
150 .reset = visstrim_camera_reset,
151};
152
153static struct mx2_camera_platform_data visstrim_camera = {
154 .flags = MX2_CAMERA_CCIR | MX2_CAMERA_CCIR_INTERLACE |
155 MX2_CAMERA_SWAP16 | MX2_CAMERA_PCLK_SAMPLE_RISING,
156 .clk = 100000,
157};
158
159static phys_addr_t mx2_camera_base __initdata;
160#define MX2_CAMERA_BUF_SIZE SZ_8M
161
162static void __init visstrim_camera_init(void)
163{
164 struct platform_device *pdev;
165 int dma;
166
167 /* Initialize tvp5150 gpios */
168 mxc_gpio_mode(TVP5150_RSTN | GPIO_GPIO | GPIO_OUT);
169 mxc_gpio_mode(TVP5150_PWDN | GPIO_GPIO | GPIO_OUT);
170 gpio_set_value(TVP5150_RSTN, 1);
171 gpio_set_value(TVP5150_PWDN, 0);
172 ndelay(1);
173
174 gpio_set_value(TVP5150_PWDN, 1);
175 ndelay(1);
176 gpio_set_value(TVP5150_RSTN, 0);
177 ndelay(500);
178 gpio_set_value(TVP5150_RSTN, 1);
179 ndelay(200000);
180
181 pdev = imx27_add_mx2_camera(&visstrim_camera);
182 if (IS_ERR(pdev))
183 return;
184
185 dma = dma_declare_coherent_memory(&pdev->dev,
186 mx2_camera_base, mx2_camera_base,
187 MX2_CAMERA_BUF_SIZE,
188 DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE);
189 if (!(dma & DMA_MEMORY_MAP))
190 return;
191}
192
193static void __init visstrim_reserve(void)
194{
195 /* reserve 4 MiB for mx2-camera */
196 mx2_camera_base = memblock_alloc(MX2_CAMERA_BUF_SIZE,
197 MX2_CAMERA_BUF_SIZE);
198 memblock_free(mx2_camera_base, MX2_CAMERA_BUF_SIZE);
199 memblock_remove(mx2_camera_base, MX2_CAMERA_BUF_SIZE);
200}
201
105/* GPIOs used as events for applications */ 202/* GPIOs used as events for applications */
106static struct gpio_keys_button visstrim_gpio_keys[] = { 203static struct gpio_keys_button visstrim_gpio_keys[] = {
107 { 204 {
@@ -136,6 +233,35 @@ static const struct gpio_keys_platform_data
136 .nbuttons = ARRAY_SIZE(visstrim_gpio_keys), 233 .nbuttons = ARRAY_SIZE(visstrim_gpio_keys),
137}; 234};
138 235
236/* led */
237static const struct gpio_led visstrim_m10_leds[] __initconst = {
238 {
239 .name = "visstrim:ld0",
240 .default_trigger = "nand-disk",
241 .gpio = (GPIO_PORTC + 29),
242 },
243 {
244 .name = "visstrim:ld1",
245 .default_trigger = "nand-disk",
246 .gpio = (GPIO_PORTC + 24),
247 },
248 {
249 .name = "visstrim:ld2",
250 .default_trigger = "nand-disk",
251 .gpio = (GPIO_PORTC + 28),
252 },
253 {
254 .name = "visstrim:ld3",
255 .default_trigger = "nand-disk",
256 .gpio = (GPIO_PORTC + 25),
257 },
258};
259
260static const struct gpio_led_platform_data visstrim_m10_led_data __initconst = {
261 .leds = visstrim_m10_leds,
262 .num_leds = ARRAY_SIZE(visstrim_m10_leds),
263};
264
139/* Visstrim_SM10 has a microSD slot connected to sdhc1 */ 265/* Visstrim_SM10 has a microSD slot connected to sdhc1 */
140static int visstrim_m10_sdhc1_init(struct device *dev, 266static int visstrim_m10_sdhc1_init(struct device *dev,
141 irq_handler_t detect_irq, void *data) 267 irq_handler_t detect_irq, void *data)
@@ -216,6 +342,9 @@ static struct i2c_board_info visstrim_m10_i2c_devices[] = {
216 { 342 {
217 I2C_BOARD_INFO("tlv320aic32x4", 0x18), 343 I2C_BOARD_INFO("tlv320aic32x4", 0x18),
218 .platform_data = &visstrim_m10_aic32x4_pdata, 344 .platform_data = &visstrim_m10_aic32x4_pdata,
345 },
346 {
347 I2C_BOARD_INFO("m41t00", 0x68),
219 } 348 }
220}; 349};
221 350
@@ -254,16 +383,21 @@ static void __init visstrim_m10_board_init(void)
254 imx27_add_imx_ssi(0, &visstrim_m10_ssi_pdata); 383 imx27_add_imx_ssi(0, &visstrim_m10_ssi_pdata);
255 imx27_add_imx_uart0(&uart_pdata); 384 imx27_add_imx_uart0(&uart_pdata);
256 385
257 i2c_register_board_info(0, visstrim_m10_i2c_devices,
258 ARRAY_SIZE(visstrim_m10_i2c_devices));
259 imx27_add_imx_i2c(0, &visstrim_m10_i2c_data); 386 imx27_add_imx_i2c(0, &visstrim_m10_i2c_data);
260 imx27_add_imx_i2c(1, &visstrim_m10_i2c_data); 387 imx27_add_imx_i2c(1, &visstrim_m10_i2c_data);
388 i2c_register_board_info(0, visstrim_m10_i2c_devices,
389 ARRAY_SIZE(visstrim_m10_i2c_devices));
390
261 imx27_add_mxc_mmc(0, &visstrim_m10_sdhc_pdata); 391 imx27_add_mxc_mmc(0, &visstrim_m10_sdhc_pdata);
262 imx27_add_mxc_ehci_otg(&visstrim_m10_usbotg_pdata); 392 imx27_add_mxc_ehci_otg(&visstrim_m10_usbotg_pdata);
263 imx27_add_fec(NULL); 393 imx27_add_fec(NULL);
264 imx_add_gpio_keys(&visstrim_gpio_keys_platform_data); 394 imx_add_gpio_keys(&visstrim_gpio_keys_platform_data);
265 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); 395 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
266 imx_add_platform_device("mx27vis", 0, NULL, 0, NULL, 0); 396 imx_add_platform_device("mx27vis", 0, NULL, 0, NULL, 0);
397 platform_device_register_resndata(NULL, "soc-camera-pdrv", 0, NULL, 0,
398 &iclink_tvp5150, sizeof(iclink_tvp5150));
399 gpio_led_register_device(0, &visstrim_m10_led_data);
400 visstrim_camera_init();
267} 401}
268 402
269static void __init visstrim_m10_timer_init(void) 403static void __init visstrim_m10_timer_init(void)
@@ -277,6 +411,7 @@ static struct sys_timer visstrim_m10_timer = {
277 411
278MACHINE_START(IMX27_VISSTRIM_M10, "Vista Silicon Visstrim_M10") 412MACHINE_START(IMX27_VISSTRIM_M10, "Vista Silicon Visstrim_M10")
279 .atag_offset = 0x100, 413 .atag_offset = 0x100,
414 .reserve = visstrim_reserve,
280 .map_io = mx27_map_io, 415 .map_io = mx27_map_io,
281 .init_early = imx27_init_early, 416 .init_early = imx27_init_early,
282 .init_irq = mx27_init_irq, 417 .init_irq = mx27_init_irq,
diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c
index e4bbd4f0294..da6c1d9af76 100644
--- a/arch/arm/mach-imx/mach-imx6q.c
+++ b/arch/arm/mach-imx/mach-imx6q.c
@@ -21,6 +21,7 @@
21#include <linux/of_platform.h> 21#include <linux/of_platform.h>
22#include <linux/phy.h> 22#include <linux/phy.h>
23#include <linux/micrel_phy.h> 23#include <linux/micrel_phy.h>
24#include <asm/smp_twd.h>
24#include <asm/hardware/cache-l2x0.h> 25#include <asm/hardware/cache-l2x0.h>
25#include <asm/hardware/gic.h> 26#include <asm/hardware/gic.h>
26#include <asm/mach/arch.h> 27#include <asm/mach/arch.h>
@@ -121,6 +122,7 @@ static void __init imx6q_init_irq(void)
121static void __init imx6q_timer_init(void) 122static void __init imx6q_timer_init(void)
122{ 123{
123 mx6q_clocks_init(); 124 mx6q_clocks_init();
125 twd_local_timer_of_register();
124} 126}
125 127
126static struct sys_timer imx6q_timer = { 128static struct sys_timer imx6q_timer = {
@@ -130,6 +132,7 @@ static struct sys_timer imx6q_timer = {
130static const char *imx6q_dt_compat[] __initdata = { 132static const char *imx6q_dt_compat[] __initdata = {
131 "fsl,imx6q-arm2", 133 "fsl,imx6q-arm2",
132 "fsl,imx6q-sabrelite", 134 "fsl,imx6q-sabrelite",
135 "fsl,imx6q",
133 NULL, 136 NULL,
134}; 137};
135 138
diff --git a/arch/arm/mach-imx/mach-mx21ads.c b/arch/arm/mach-imx/mach-mx21ads.c
index 8d9f95514b1..e432d4acee1 100644
--- a/arch/arm/mach-imx/mach-mx21ads.c
+++ b/arch/arm/mach-imx/mach-mx21ads.c
@@ -37,8 +37,8 @@
37#define MX21ADS_REG_ADDR(offset) (void __force __iomem *) \ 37#define MX21ADS_REG_ADDR(offset) (void __force __iomem *) \
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_IRQ IRQ_GPIOE(11) 41#define MX21ADS_CS8900A_IRQ IRQ_GPIOE(11)
41#define MX21ADS_CS8900A_IOBASE_REG MX21ADS_REG_ADDR(0x000000)
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,6 +159,18 @@ 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 = {
163 DEFINE_RES_MEM(MX21_CS1_BASE_ADDR, MX21ADS_CS8900A_MMIO_SIZE),
164 DEFINE_RES_IRQ(MX21ADS_CS8900A_IRQ),
165};
166
167static const struct platform_device_info mx21ads_cs8900_devinfo __initconst = {
168 .name = "cs89x0",
169 .id = 0,
170 .res = mx21ads_cs8900_resources,
171 .num_res = ARRAY_SIZE(mx21ads_cs8900_resources),
172};
173
162static const struct imxuart_platform_data uart_pdata_rts __initconst = { 174static const struct imxuart_platform_data uart_pdata_rts __initconst = {
163 .flags = IMXUART_HAVE_RTSCTS, 175 .flags = IMXUART_HAVE_RTSCTS,
164}; 176};
@@ -292,6 +304,8 @@ static void __init mx21ads_board_init(void)
292 imx21_add_mxc_nand(&mx21ads_nand_board_info); 304 imx21_add_mxc_nand(&mx21ads_nand_board_info);
293 305
294 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); 306 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
307 platform_device_register_full(
308 (struct platform_device_info *)&mx21ads_cs8900_devinfo);
295} 309}
296 310
297static void __init mx21ads_timer_init(void) 311static void __init mx21ads_timer_init(void)
diff --git a/arch/arm/mach-imx/mach-mx27_3ds.c b/arch/arm/mach-imx/mach-mx27_3ds.c
index 18f35816706..c6d385c5225 100644
--- a/arch/arm/mach-imx/mach-mx27_3ds.c
+++ b/arch/arm/mach-imx/mach-mx27_3ds.c
@@ -31,6 +31,8 @@
31#include <linux/regulator/machine.h> 31#include <linux/regulator/machine.h>
32#include <linux/spi/l4f00242t03.h> 32#include <linux/spi/l4f00242t03.h>
33 33
34#include <media/soc_camera.h>
35
34#include <asm/mach-types.h> 36#include <asm/mach-types.h>
35#include <asm/mach/arch.h> 37#include <asm/mach/arch.h>
36#include <asm/mach/time.h> 38#include <asm/mach/time.h>
@@ -52,6 +54,8 @@
52#define SD1_CD IMX_GPIO_NR(2, 26) 54#define SD1_CD IMX_GPIO_NR(2, 26)
53#define LCD_RESET IMX_GPIO_NR(1, 3) 55#define LCD_RESET IMX_GPIO_NR(1, 3)
54#define LCD_ENABLE IMX_GPIO_NR(1, 31) 56#define LCD_ENABLE IMX_GPIO_NR(1, 31)
57#define CSI_PWRDWN IMX_GPIO_NR(4, 19)
58#define CSI_RESET IMX_GPIO_NR(3, 6)
55 59
56static const int mx27pdk_pins[] __initconst = { 60static const int mx27pdk_pins[] __initconst = {
57 /* UART1 */ 61 /* UART1 */
@@ -141,6 +145,26 @@ static const int mx27pdk_pins[] __initconst = {
141 PA30_PF_CONTRAST, 145 PA30_PF_CONTRAST,
142 LCD_ENABLE | GPIO_GPIO | GPIO_OUT, 146 LCD_ENABLE | GPIO_GPIO | GPIO_OUT,
143 LCD_RESET | GPIO_GPIO | GPIO_OUT, 147 LCD_RESET | GPIO_GPIO | GPIO_OUT,
148 /* CSI */
149 PB10_PF_CSI_D0,
150 PB11_PF_CSI_D1,
151 PB12_PF_CSI_D2,
152 PB13_PF_CSI_D3,
153 PB14_PF_CSI_D4,
154 PB15_PF_CSI_MCLK,
155 PB16_PF_CSI_PIXCLK,
156 PB17_PF_CSI_D5,
157 PB18_PF_CSI_D6,
158 PB19_PF_CSI_D7,
159 PB20_PF_CSI_VSYNC,
160 PB21_PF_CSI_HSYNC,
161 CSI_PWRDWN | GPIO_GPIO | GPIO_OUT,
162 CSI_RESET | GPIO_GPIO | GPIO_OUT,
163};
164
165static struct gpio mx27_3ds_camera_gpios[] = {
166 { CSI_PWRDWN, GPIOF_OUT_INIT_HIGH, "camera-power" },
167 { CSI_RESET, GPIOF_OUT_INIT_HIGH, "camera-reset" },
144}; 168};
145 169
146static const struct imxuart_platform_data uart_pdata __initconst = { 170static const struct imxuart_platform_data uart_pdata __initconst = {
@@ -242,6 +266,7 @@ static struct regulator_init_data gpo_init = {
242 266
243static struct regulator_consumer_supply vmmc1_consumers[] = { 267static struct regulator_consumer_supply vmmc1_consumers[] = {
244 REGULATOR_SUPPLY("vcore", "spi0.0"), 268 REGULATOR_SUPPLY("vcore", "spi0.0"),
269 REGULATOR_SUPPLY("cmos_2v8", "soc-camera-pdrv.0"),
245}; 270};
246 271
247static struct regulator_init_data vmmc1_init = { 272static struct regulator_init_data vmmc1_init = {
@@ -270,6 +295,22 @@ static struct regulator_init_data vgen_init = {
270 .consumer_supplies = vgen_consumers, 295 .consumer_supplies = vgen_consumers,
271}; 296};
272 297
298static struct regulator_consumer_supply vvib_consumers[] = {
299 REGULATOR_SUPPLY("cmos_vcore", "soc-camera-pdrv.0"),
300};
301
302static struct regulator_init_data vvib_init = {
303 .constraints = {
304 .min_uV = 1300000,
305 .max_uV = 1300000,
306 .apply_uV = 1,
307 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
308 REGULATOR_CHANGE_STATUS,
309 },
310 .num_consumer_supplies = ARRAY_SIZE(vvib_consumers),
311 .consumer_supplies = vvib_consumers,
312};
313
273static struct mc13xxx_regulator_init_data mx27_3ds_regulators[] = { 314static struct mc13xxx_regulator_init_data mx27_3ds_regulators[] = {
274 { 315 {
275 .id = MC13783_REG_VMMC1, 316 .id = MC13783_REG_VMMC1,
@@ -283,6 +324,9 @@ static struct mc13xxx_regulator_init_data mx27_3ds_regulators[] = {
283 }, { 324 }, {
284 .id = MC13783_REG_GPO3, /* Turn on 3.3V */ 325 .id = MC13783_REG_GPO3, /* Turn on 3.3V */
285 .init_data = &gpo_init, 326 .init_data = &gpo_init,
327 }, {
328 .id = MC13783_REG_VVIB, /* Power OV2640 */
329 .init_data = &vvib_init,
286 }, 330 },
287}; 331};
288 332
@@ -311,6 +355,51 @@ static const struct spi_imx_master spi2_pdata __initconst = {
311 .num_chipselect = ARRAY_SIZE(spi2_chipselect), 355 .num_chipselect = ARRAY_SIZE(spi2_chipselect),
312}; 356};
313 357
358static int mx27_3ds_camera_power(struct device *dev, int on)
359{
360 /* enable or disable the camera */
361 pr_debug("%s: %s the camera\n", __func__, on ? "ENABLE" : "DISABLE");
362 gpio_set_value(CSI_PWRDWN, on ? 0 : 1);
363
364 if (!on)
365 goto out;
366
367 /* If enabled, give a reset impulse */
368 gpio_set_value(CSI_RESET, 0);
369 msleep(20);
370 gpio_set_value(CSI_RESET, 1);
371 msleep(100);
372
373out:
374 return 0;
375}
376
377static struct i2c_board_info mx27_3ds_i2c_camera = {
378 I2C_BOARD_INFO("ov2640", 0x30),
379};
380
381static struct regulator_bulk_data mx27_3ds_camera_regs[] = {
382 { .supply = "cmos_vcore" },
383 { .supply = "cmos_2v8" },
384};
385
386static struct soc_camera_link iclink_ov2640 = {
387 .bus_id = 0,
388 .board_info = &mx27_3ds_i2c_camera,
389 .i2c_adapter_id = 0,
390 .power = mx27_3ds_camera_power,
391 .regulators = mx27_3ds_camera_regs,
392 .num_regulators = ARRAY_SIZE(mx27_3ds_camera_regs),
393};
394
395static struct platform_device mx27_3ds_ov2640 = {
396 .name = "soc-camera-pdrv",
397 .id = 0,
398 .dev = {
399 .platform_data = &iclink_ov2640,
400 },
401};
402
314static struct imx_fb_videomode mx27_3ds_modes[] = { 403static struct imx_fb_videomode mx27_3ds_modes[] = {
315 { /* 480x640 @ 60 Hz */ 404 { /* 480x640 @ 60 Hz */
316 .mode = { 405 .mode = {
@@ -367,12 +456,21 @@ static struct spi_board_info mx27_3ds_spi_devs[] __initdata = {
367 }, 456 },
368}; 457};
369 458
459static struct platform_device *devices[] __initdata = {
460 &mx27_3ds_ov2640,
461};
462
463static const struct mx2_camera_platform_data mx27_3ds_cam_pdata __initconst = {
464 .clk = 26000000,
465};
466
370static const struct imxi2c_platform_data mx27_3ds_i2c0_data __initconst = { 467static const struct imxi2c_platform_data mx27_3ds_i2c0_data __initconst = {
371 .bitrate = 100000, 468 .bitrate = 100000,
372}; 469};
373 470
374static void __init mx27pdk_init(void) 471static void __init mx27pdk_init(void)
375{ 472{
473 int ret;
376 imx27_soc_init(); 474 imx27_soc_init();
377 475
378 mxc_gpio_setup_multiple_pins(mx27pdk_pins, ARRAY_SIZE(mx27pdk_pins), 476 mxc_gpio_setup_multiple_pins(mx27pdk_pins, ARRAY_SIZE(mx27pdk_pins),
@@ -404,7 +502,17 @@ static void __init mx27pdk_init(void)
404 if (mxc_expio_init(MX27_CS5_BASE_ADDR, EXPIO_PARENT_INT)) 502 if (mxc_expio_init(MX27_CS5_BASE_ADDR, EXPIO_PARENT_INT))
405 pr_warn("Init of the debugboard failed, all devices on the debugboard are unusable.\n"); 503 pr_warn("Init of the debugboard failed, all devices on the debugboard are unusable.\n");
406 imx27_add_imx_i2c(0, &mx27_3ds_i2c0_data); 504 imx27_add_imx_i2c(0, &mx27_3ds_i2c0_data);
505 platform_add_devices(devices, ARRAY_SIZE(devices));
407 imx27_add_imx_fb(&mx27_3ds_fb_data); 506 imx27_add_imx_fb(&mx27_3ds_fb_data);
507
508 ret = gpio_request_array(mx27_3ds_camera_gpios,
509 ARRAY_SIZE(mx27_3ds_camera_gpios));
510 if (ret) {
511 pr_err("Failed to request camera gpios");
512 iclink_ov2640.power = NULL;
513 }
514
515 imx27_add_mx2_camera(&mx27_3ds_cam_pdata);
408} 516}
409 517
410static void __init mx27pdk_timer_init(void) 518static void __init mx27pdk_timer_init(void)
diff --git a/arch/arm/mach-imx/mach-mx31ads.c b/arch/arm/mach-imx/mach-mx31ads.c
index 4917aab0e25..4518e544822 100644
--- a/arch/arm/mach-imx/mach-mx31ads.c
+++ b/arch/arm/mach-imx/mach-mx31ads.c
@@ -28,7 +28,6 @@
28#include <asm/memory.h> 28#include <asm/memory.h>
29#include <asm/mach/map.h> 29#include <asm/mach/map.h>
30#include <mach/common.h> 30#include <mach/common.h>
31#include <mach/board-mx31ads.h>
32#include <mach/iomux-mx3.h> 31#include <mach/iomux-mx3.h>
33 32
34#ifdef CONFIG_MACH_MX31ADS_WM1133_EV1 33#ifdef CONFIG_MACH_MX31ADS_WM1133_EV1
@@ -39,6 +38,9 @@
39 38
40#include "devices-imx31.h" 39#include "devices-imx31.h"
41 40
41/* Base address of PBC controller */
42#define PBC_BASE_ADDRESS MX31_CS4_BASE_ADDR_VIRT
43
42/* PBC Board interrupt status register */ 44/* PBC Board interrupt status register */
43#define PBC_INTSTATUS 0x000016 45#define PBC_INTSTATUS 0x000016
44 46
@@ -62,6 +64,7 @@
62#define PBC_INTMASK_CLEAR_REG (PBC_INTMASK_CLEAR + PBC_BASE_ADDRESS) 64#define PBC_INTMASK_CLEAR_REG (PBC_INTMASK_CLEAR + PBC_BASE_ADDRESS)
63#define EXPIO_PARENT_INT IOMUX_TO_IRQ(MX31_PIN_GPIO1_4) 65#define EXPIO_PARENT_INT IOMUX_TO_IRQ(MX31_PIN_GPIO1_4)
64 66
67#define MXC_EXP_IO_BASE MXC_BOARD_IRQ_START
65#define MXC_IRQ_TO_EXPIO(irq) ((irq) - MXC_EXP_IO_BASE) 68#define MXC_IRQ_TO_EXPIO(irq) ((irq) - MXC_EXP_IO_BASE)
66 69
67#define EXPIO_INT_XUART_INTA (MXC_EXP_IO_BASE + 10) 70#define EXPIO_INT_XUART_INTA (MXC_EXP_IO_BASE + 10)
@@ -69,6 +72,10 @@
69 72
70#define MXC_MAX_EXP_IO_LINES 16 73#define MXC_MAX_EXP_IO_LINES 16
71 74
75/* CS8900 */
76#define EXPIO_INT_ENET_INT (MXC_EXP_IO_BASE + 8)
77#define CS4_CS8900_MMIO_START 0x20000
78
72/* 79/*
73 * The serial port definition structure. 80 * The serial port definition structure.
74 */ 81 */
@@ -101,11 +108,29 @@ static struct platform_device serial_device = {
101 }, 108 },
102}; 109};
103 110
111static const struct resource mx31ads_cs8900_resources[] __initconst = {
112 DEFINE_RES_MEM(MX31_CS4_BASE_ADDR + CS4_CS8900_MMIO_START, SZ_64K),
113 DEFINE_RES_IRQ(EXPIO_INT_ENET_INT),
114};
115
116static const struct platform_device_info mx31ads_cs8900_devinfo __initconst = {
117 .name = "cs89x0",
118 .id = 0,
119 .res = mx31ads_cs8900_resources,
120 .num_res = ARRAY_SIZE(mx31ads_cs8900_resources),
121};
122
104static int __init mxc_init_extuart(void) 123static int __init mxc_init_extuart(void)
105{ 124{
106 return platform_device_register(&serial_device); 125 return platform_device_register(&serial_device);
107} 126}
108 127
128static void __init mxc_init_ext_ethernet(void)
129{
130 platform_device_register_full(
131 (struct platform_device_info *)&mx31ads_cs8900_devinfo);
132}
133
109static const struct imxuart_platform_data uart_pdata __initconst = { 134static const struct imxuart_platform_data uart_pdata __initconst = {
110 .flags = IMXUART_HAVE_RTSCTS, 135 .flags = IMXUART_HAVE_RTSCTS,
111}; 136};
@@ -492,12 +517,15 @@ static void __init mxc_init_audio(void)
492 mxc_iomux_setup_multiple_pins(ssi_pins, ARRAY_SIZE(ssi_pins), "ssi"); 517 mxc_iomux_setup_multiple_pins(ssi_pins, ARRAY_SIZE(ssi_pins), "ssi");
493} 518}
494 519
495/* static mappings */ 520/*
521 * Static mappings, starting from the CS4 start address up to the start address
522 * of the CS8900.
523 */
496static struct map_desc mx31ads_io_desc[] __initdata = { 524static struct map_desc mx31ads_io_desc[] __initdata = {
497 { 525 {
498 .virtual = MX31_CS4_BASE_ADDR_VIRT, 526 .virtual = MX31_CS4_BASE_ADDR_VIRT,
499 .pfn = __phys_to_pfn(MX31_CS4_BASE_ADDR), 527 .pfn = __phys_to_pfn(MX31_CS4_BASE_ADDR),
500 .length = MX31_CS4_SIZE / 2, 528 .length = CS4_CS8900_MMIO_START,
501 .type = MT_DEVICE 529 .type = MT_DEVICE
502 }, 530 },
503}; 531};
@@ -522,6 +550,7 @@ static void __init mx31ads_init(void)
522 mxc_init_imx_uart(); 550 mxc_init_imx_uart();
523 mxc_init_i2c(); 551 mxc_init_i2c();
524 mxc_init_audio(); 552 mxc_init_audio();
553 mxc_init_ext_ethernet();
525} 554}
526 555
527static void __init mx31ads_timer_init(void) 556static void __init mx31ads_timer_init(void)
diff --git a/arch/arm/mach-imx/mach-mx31moboard.c b/arch/arm/mach-imx/mach-mx31moboard.c
index f225262b5c3..f17a15f2831 100644
--- a/arch/arm/mach-imx/mach-mx31moboard.c
+++ b/arch/arm/mach-imx/mach-mx31moboard.c
@@ -507,7 +507,7 @@ static void mx31moboard_poweroff(void)
507 struct clk *clk = clk_get_sys("imx2-wdt.0", NULL); 507 struct clk *clk = clk_get_sys("imx2-wdt.0", NULL);
508 508
509 if (!IS_ERR(clk)) 509 if (!IS_ERR(clk))
510 clk_enable(clk); 510 clk_prepare_enable(clk);
511 511
512 mxc_iomux_mode(MX31_PIN_WATCHDOG_RST__WATCHDOG_RST); 512 mxc_iomux_mode(MX31_PIN_WATCHDOG_RST__WATCHDOG_RST);
513 513
@@ -530,6 +530,8 @@ static void __init mx31moboard_init(void)
530 platform_add_devices(devices, ARRAY_SIZE(devices)); 530 platform_add_devices(devices, ARRAY_SIZE(devices));
531 gpio_led_register_device(-1, &mx31moboard_led_pdata); 531 gpio_led_register_device(-1, &mx31moboard_led_pdata);
532 532
533 imx31_add_imx2_wdt(NULL);
534
533 imx31_add_imx_uart0(&uart0_pdata); 535 imx31_add_imx_uart0(&uart0_pdata);
534 imx31_add_imx_uart4(&uart4_pdata); 536 imx31_add_imx_uart4(&uart4_pdata);
535 537
@@ -590,7 +592,7 @@ static void __init mx31moboard_reserve(void)
590} 592}
591 593
592MACHINE_START(MX31MOBOARD, "EPFL Mobots mx31moboard") 594MACHINE_START(MX31MOBOARD, "EPFL Mobots mx31moboard")
593 /* Maintainer: Valentin Longchamp, EPFL Mobots group */ 595 /* Maintainer: Philippe Retornaz, EPFL Mobots group */
594 .atag_offset = 0x100, 596 .atag_offset = 0x100,
595 .reserve = mx31moboard_reserve, 597 .reserve = mx31moboard_reserve,
596 .map_io = mx31_map_io, 598 .map_io = mx31_map_io,
diff --git a/arch/arm/mach-imx/mach-mx35_3ds.c b/arch/arm/mach-imx/mach-mx35_3ds.c
index 0af6c9c5b3f..e14291d89e4 100644
--- a/arch/arm/mach-imx/mach-mx35_3ds.c
+++ b/arch/arm/mach-imx/mach-mx35_3ds.c
@@ -4,6 +4,11 @@
4 * 4 *
5 * Author: Fabio Estevam <fabio.estevam@freescale.com> 5 * Author: Fabio Estevam <fabio.estevam@freescale.com>
6 * 6 *
7 * Copyright (C) 2011 Meprolight, Ltd.
8 * Alex Gershgorin <alexg@meprolight.com>
9 *
10 * Modified from i.MX31 3-Stack Development System
11 *
7 * 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
8 * it under the terms of the GNU General Public License as published by 13 * 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 14 * the Free Software Foundation; either version 2 of the License, or
@@ -34,15 +39,102 @@
34#include <asm/mach/arch.h> 39#include <asm/mach/arch.h>
35#include <asm/mach/time.h> 40#include <asm/mach/time.h>
36#include <asm/mach/map.h> 41#include <asm/mach/map.h>
42#include <asm/memblock.h>
37 43
38#include <mach/hardware.h> 44#include <mach/hardware.h>
39#include <mach/common.h> 45#include <mach/common.h>
40#include <mach/iomux-mx35.h> 46#include <mach/iomux-mx35.h>
41#include <mach/irqs.h> 47#include <mach/irqs.h>
42#include <mach/3ds_debugboard.h> 48#include <mach/3ds_debugboard.h>
49#include <video/platform_lcd.h>
50
51#include <media/soc_camera.h>
43 52
44#include "devices-imx35.h" 53#include "devices-imx35.h"
45 54
55#define GPIO_MC9S08DZ60_GPS_ENABLE 0
56#define GPIO_MC9S08DZ60_HDD_ENABLE 4
57#define GPIO_MC9S08DZ60_WIFI_ENABLE 5
58#define GPIO_MC9S08DZ60_LCD_ENABLE 6
59#define GPIO_MC9S08DZ60_SPEAKER_ENABLE 8
60
61static const struct fb_videomode fb_modedb[] = {
62 {
63 /* 800x480 @ 55 Hz */
64 .name = "Ceramate-CLAA070VC01",
65 .refresh = 55,
66 .xres = 800,
67 .yres = 480,
68 .pixclock = 40000,
69 .left_margin = 40,
70 .right_margin = 40,
71 .upper_margin = 5,
72 .lower_margin = 5,
73 .hsync_len = 20,
74 .vsync_len = 10,
75 .sync = FB_SYNC_OE_ACT_HIGH,
76 .vmode = FB_VMODE_NONINTERLACED,
77 .flag = 0,
78 },
79};
80
81static const struct ipu_platform_data mx3_ipu_data __initconst = {
82 .irq_base = MXC_IPU_IRQ_START,
83};
84
85static struct mx3fb_platform_data mx3fb_pdata __initdata = {
86 .name = "Ceramate-CLAA070VC01",
87 .mode = fb_modedb,
88 .num_modes = ARRAY_SIZE(fb_modedb),
89};
90
91static struct i2c_board_info __initdata i2c_devices_3ds[] = {
92 {
93 I2C_BOARD_INFO("mc9s08dz60", 0x69),
94 },
95};
96
97static int lcd_power_gpio = -ENXIO;
98
99static int mc9s08dz60_gpiochip_match(struct gpio_chip *chip,
100 void *data)
101{
102 return !strcmp(chip->label, data);
103}
104
105static void mx35_3ds_lcd_set_power(
106 struct plat_lcd_data *pd, unsigned int power)
107{
108 struct gpio_chip *chip;
109
110 if (!gpio_is_valid(lcd_power_gpio)) {
111 chip = gpiochip_find(
112 "mc9s08dz60", mc9s08dz60_gpiochip_match);
113 if (chip) {
114 lcd_power_gpio =
115 chip->base + GPIO_MC9S08DZ60_LCD_ENABLE;
116 if (gpio_request(lcd_power_gpio, "lcd_power") < 0) {
117 pr_err("error: gpio already requested!\n");
118 lcd_power_gpio = -ENXIO;
119 }
120 } else {
121 pr_err("error: didn't find mc9s08dz60 gpio chip\n");
122 }
123 }
124
125 if (gpio_is_valid(lcd_power_gpio))
126 gpio_set_value_cansleep(lcd_power_gpio, power);
127}
128
129static struct plat_lcd_data mx35_3ds_lcd_data = {
130 .set_power = mx35_3ds_lcd_set_power,
131};
132
133static struct platform_device mx35_3ds_lcd = {
134 .name = "platform-lcd",
135 .dev.platform_data = &mx35_3ds_lcd_data,
136};
137
46#define EXPIO_PARENT_INT gpio_to_irq(IMX_GPIO_NR(1, 1)) 138#define EXPIO_PARENT_INT gpio_to_irq(IMX_GPIO_NR(1, 1))
47 139
48static const struct imxuart_platform_data uart_pdata __initconst = { 140static const struct imxuart_platform_data uart_pdata __initconst = {
@@ -120,6 +212,109 @@ static iomux_v3_cfg_t mx35pdk_pads[] = {
120 /* I2C1 */ 212 /* I2C1 */
121 MX35_PAD_I2C1_CLK__I2C1_SCL, 213 MX35_PAD_I2C1_CLK__I2C1_SCL,
122 MX35_PAD_I2C1_DAT__I2C1_SDA, 214 MX35_PAD_I2C1_DAT__I2C1_SDA,
215 /* Display */
216 MX35_PAD_LD0__IPU_DISPB_DAT_0,
217 MX35_PAD_LD1__IPU_DISPB_DAT_1,
218 MX35_PAD_LD2__IPU_DISPB_DAT_2,
219 MX35_PAD_LD3__IPU_DISPB_DAT_3,
220 MX35_PAD_LD4__IPU_DISPB_DAT_4,
221 MX35_PAD_LD5__IPU_DISPB_DAT_5,
222 MX35_PAD_LD6__IPU_DISPB_DAT_6,
223 MX35_PAD_LD7__IPU_DISPB_DAT_7,
224 MX35_PAD_LD8__IPU_DISPB_DAT_8,
225 MX35_PAD_LD9__IPU_DISPB_DAT_9,
226 MX35_PAD_LD10__IPU_DISPB_DAT_10,
227 MX35_PAD_LD11__IPU_DISPB_DAT_11,
228 MX35_PAD_LD12__IPU_DISPB_DAT_12,
229 MX35_PAD_LD13__IPU_DISPB_DAT_13,
230 MX35_PAD_LD14__IPU_DISPB_DAT_14,
231 MX35_PAD_LD15__IPU_DISPB_DAT_15,
232 MX35_PAD_LD16__IPU_DISPB_DAT_16,
233 MX35_PAD_LD17__IPU_DISPB_DAT_17,
234 MX35_PAD_D3_HSYNC__IPU_DISPB_D3_HSYNC,
235 MX35_PAD_D3_FPSHIFT__IPU_DISPB_D3_CLK,
236 MX35_PAD_D3_DRDY__IPU_DISPB_D3_DRDY,
237 MX35_PAD_CONTRAST__IPU_DISPB_CONTR,
238 MX35_PAD_D3_VSYNC__IPU_DISPB_D3_VSYNC,
239 MX35_PAD_D3_REV__IPU_DISPB_D3_REV,
240 MX35_PAD_D3_CLS__IPU_DISPB_D3_CLS,
241 /* CSI */
242 MX35_PAD_TX1__IPU_CSI_D_6,
243 MX35_PAD_TX0__IPU_CSI_D_7,
244 MX35_PAD_CSI_D8__IPU_CSI_D_8,
245 MX35_PAD_CSI_D9__IPU_CSI_D_9,
246 MX35_PAD_CSI_D10__IPU_CSI_D_10,
247 MX35_PAD_CSI_D11__IPU_CSI_D_11,
248 MX35_PAD_CSI_D12__IPU_CSI_D_12,
249 MX35_PAD_CSI_D13__IPU_CSI_D_13,
250 MX35_PAD_CSI_D14__IPU_CSI_D_14,
251 MX35_PAD_CSI_D15__IPU_CSI_D_15,
252 MX35_PAD_CSI_HSYNC__IPU_CSI_HSYNC,
253 MX35_PAD_CSI_MCLK__IPU_CSI_MCLK,
254 MX35_PAD_CSI_PIXCLK__IPU_CSI_PIXCLK,
255 MX35_PAD_CSI_VSYNC__IPU_CSI_VSYNC,
256};
257
258/*
259 * Camera support
260*/
261static phys_addr_t mx3_camera_base __initdata;
262#define MX35_3DS_CAMERA_BUF_SIZE SZ_8M
263
264static const struct mx3_camera_pdata mx35_3ds_camera_pdata __initconst = {
265 .flags = MX3_CAMERA_DATAWIDTH_8,
266 .mclk_10khz = 2000,
267};
268
269static int __init imx35_3ds_init_camera(void)
270{
271 int dma, ret = -ENOMEM;
272 struct platform_device *pdev =
273 imx35_alloc_mx3_camera(&mx35_3ds_camera_pdata);
274
275 if (IS_ERR(pdev))
276 return PTR_ERR(pdev);
277
278 if (!mx3_camera_base)
279 goto err;
280
281 dma = dma_declare_coherent_memory(&pdev->dev,
282 mx3_camera_base, mx3_camera_base,
283 MX35_3DS_CAMERA_BUF_SIZE,
284 DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE);
285
286 if (!(dma & DMA_MEMORY_MAP))
287 goto err;
288
289 ret = platform_device_add(pdev);
290 if (ret)
291err:
292 platform_device_put(pdev);
293
294 return ret;
295}
296
297static const struct ipu_platform_data mx35_3ds_ipu_data __initconst = {
298 .irq_base = MXC_IPU_IRQ_START,
299};
300
301static struct i2c_board_info mx35_3ds_i2c_camera = {
302 I2C_BOARD_INFO("ov2640", 0x30),
303};
304
305static struct soc_camera_link iclink_ov2640 = {
306 .bus_id = 0,
307 .board_info = &mx35_3ds_i2c_camera,
308 .i2c_adapter_id = 0,
309 .power = NULL,
310};
311
312static struct platform_device mx35_3ds_ov2640 = {
313 .name = "soc-camera-pdrv",
314 .id = 0,
315 .dev = {
316 .platform_data = &iclink_ov2640,
317 },
123}; 318};
124 319
125static int mx35_3ds_otg_init(struct platform_device *pdev) 320static int mx35_3ds_otg_init(struct platform_device *pdev)
@@ -179,6 +374,8 @@ static const struct imxi2c_platform_data mx35_3ds_i2c0_data __initconst = {
179 */ 374 */
180static void __init mx35_3ds_init(void) 375static void __init mx35_3ds_init(void)
181{ 376{
377 struct platform_device *imx35_fb_pdev;
378
182 imx35_soc_init(); 379 imx35_soc_init();
183 380
184 mxc_iomux_v3_setup_multiple_pads(mx35pdk_pads, ARRAY_SIZE(mx35pdk_pads)); 381 mxc_iomux_v3_setup_multiple_pads(mx35pdk_pads, ARRAY_SIZE(mx35pdk_pads));
@@ -204,6 +401,17 @@ static void __init mx35_3ds_init(void)
204 pr_warn("Init of the debugboard failed, all " 401 pr_warn("Init of the debugboard failed, all "
205 "devices on the debugboard are unusable.\n"); 402 "devices on the debugboard are unusable.\n");
206 imx35_add_imx_i2c0(&mx35_3ds_i2c0_data); 403 imx35_add_imx_i2c0(&mx35_3ds_i2c0_data);
404
405 i2c_register_board_info(
406 0, i2c_devices_3ds, ARRAY_SIZE(i2c_devices_3ds));
407
408 imx35_add_ipu_core(&mx35_3ds_ipu_data);
409 platform_device_register(&mx35_3ds_ov2640);
410 imx35_3ds_init_camera();
411
412 imx35_fb_pdev = imx35_add_mx3_sdc_fb(&mx3fb_pdata);
413 mx35_3ds_lcd.dev.parent = &imx35_fb_pdev->dev;
414 platform_device_register(&mx35_3ds_lcd);
207} 415}
208 416
209static void __init mx35pdk_timer_init(void) 417static void __init mx35pdk_timer_init(void)
@@ -215,6 +423,13 @@ struct sys_timer mx35pdk_timer = {
215 .init = mx35pdk_timer_init, 423 .init = mx35pdk_timer_init,
216}; 424};
217 425
426static void __init mx35_3ds_reserve(void)
427{
428 /* reserve MX35_3DS_CAMERA_BUF_SIZE bytes for mx3-camera */
429 mx3_camera_base = arm_memblock_steal(MX35_3DS_CAMERA_BUF_SIZE,
430 MX35_3DS_CAMERA_BUF_SIZE);
431}
432
218MACHINE_START(MX35_3DS, "Freescale MX35PDK") 433MACHINE_START(MX35_3DS, "Freescale MX35PDK")
219 /* Maintainer: Freescale Semiconductor, Inc */ 434 /* Maintainer: Freescale Semiconductor, Inc */
220 .atag_offset = 0x100, 435 .atag_offset = 0x100,
@@ -224,5 +439,6 @@ MACHINE_START(MX35_3DS, "Freescale MX35PDK")
224 .handle_irq = imx35_handle_irq, 439 .handle_irq = imx35_handle_irq,
225 .timer = &mx35pdk_timer, 440 .timer = &mx35pdk_timer,
226 .init_machine = mx35_3ds_init, 441 .init_machine = mx35_3ds_init,
442 .reserve = mx35_3ds_reserve,
227 .restart = mxc_restart, 443 .restart = mxc_restart,
228MACHINE_END 444MACHINE_END
diff --git a/arch/arm/mach-imx/mach-pcm038.c b/arch/arm/mach-imx/mach-pcm038.c
index 16f126da9f8..2f3debe2a11 100644
--- a/arch/arm/mach-imx/mach-pcm038.c
+++ b/arch/arm/mach-imx/mach-pcm038.c
@@ -233,7 +233,7 @@ static struct regulator_init_data sdhc1_data = {
233 233
234static struct regulator_consumer_supply cam_consumers[] = { 234static struct regulator_consumer_supply cam_consumers[] = {
235 { 235 {
236 .dev = NULL, 236 .dev_name = NULL,
237 .supply = "imx_cam_vcc", 237 .supply = "imx_cam_vcc",
238 }, 238 },
239}; 239};
diff --git a/arch/arm/mach-imx/mm-imx3.c b/arch/arm/mach-imx/mm-imx3.c
index 2530c151b7b..f8ca96c354f 100644
--- a/arch/arm/mach-imx/mm-imx3.c
+++ b/arch/arm/mach-imx/mm-imx3.c
@@ -34,31 +34,31 @@ static void imx3_idle(void)
34{ 34{
35 unsigned long reg = 0; 35 unsigned long reg = 0;
36 36
37 if (!need_resched()) 37 mx3_cpu_lp_set(MX3_WAIT);
38 __asm__ __volatile__( 38
39 /* disable I and D cache */ 39 __asm__ __volatile__(
40 "mrc p15, 0, %0, c1, c0, 0\n" 40 /* disable I and D cache */
41 "bic %0, %0, #0x00001000\n" 41 "mrc p15, 0, %0, c1, c0, 0\n"
42 "bic %0, %0, #0x00000004\n" 42 "bic %0, %0, #0x00001000\n"
43 "mcr p15, 0, %0, c1, c0, 0\n" 43 "bic %0, %0, #0x00000004\n"
44 /* invalidate I cache */ 44 "mcr p15, 0, %0, c1, c0, 0\n"
45 "mov %0, #0\n" 45 /* invalidate I cache */
46 "mcr p15, 0, %0, c7, c5, 0\n" 46 "mov %0, #0\n"
47 /* clear and invalidate D cache */ 47 "mcr p15, 0, %0, c7, c5, 0\n"
48 "mov %0, #0\n" 48 /* clear and invalidate D cache */
49 "mcr p15, 0, %0, c7, c14, 0\n" 49 "mov %0, #0\n"
50 /* WFI */ 50 "mcr p15, 0, %0, c7, c14, 0\n"
51 "mov %0, #0\n" 51 /* WFI */
52 "mcr p15, 0, %0, c7, c0, 4\n" 52 "mov %0, #0\n"
53 "nop\n" "nop\n" "nop\n" "nop\n" 53 "mcr p15, 0, %0, c7, c0, 4\n"
54 "nop\n" "nop\n" "nop\n" 54 "nop\n" "nop\n" "nop\n" "nop\n"
55 /* enable I and D cache */ 55 "nop\n" "nop\n" "nop\n"
56 "mrc p15, 0, %0, c1, c0, 0\n" 56 /* enable I and D cache */
57 "orr %0, %0, #0x00001000\n" 57 "mrc p15, 0, %0, c1, c0, 0\n"
58 "orr %0, %0, #0x00000004\n" 58 "orr %0, %0, #0x00001000\n"
59 "mcr p15, 0, %0, c1, c0, 0\n" 59 "orr %0, %0, #0x00000004\n"
60 : "=r" (reg)); 60 "mcr p15, 0, %0, c1, c0, 0\n"
61 local_irq_enable(); 61 : "=r" (reg));
62} 62}
63 63
64static void __iomem *imx3_ioremap(unsigned long phys_addr, size_t size, 64static void __iomem *imx3_ioremap(unsigned long phys_addr, size_t size,
@@ -78,7 +78,7 @@ static void __iomem *imx3_ioremap(unsigned long phys_addr, size_t size,
78 return __arm_ioremap(phys_addr, size, mtype); 78 return __arm_ioremap(phys_addr, size, mtype);
79} 79}
80 80
81void imx3_init_l2x0(void) 81void __init imx3_init_l2x0(void)
82{ 82{
83 void __iomem *l2x0_base; 83 void __iomem *l2x0_base;
84 void __iomem *clkctl_base; 84 void __iomem *clkctl_base;
@@ -134,8 +134,8 @@ void __init imx31_init_early(void)
134{ 134{
135 mxc_set_cpu_type(MXC_CPU_MX31); 135 mxc_set_cpu_type(MXC_CPU_MX31);
136 mxc_arch_reset_init(MX31_IO_ADDRESS(MX31_WDOG_BASE_ADDR)); 136 mxc_arch_reset_init(MX31_IO_ADDRESS(MX31_WDOG_BASE_ADDR));
137 pm_idle = imx3_idle;
138 imx_ioremap = imx3_ioremap; 137 imx_ioremap = imx3_ioremap;
138 arm_pm_idle = imx3_idle;
139} 139}
140 140
141void __init mx31_init_irq(void) 141void __init mx31_init_irq(void)
@@ -179,6 +179,10 @@ void __init imx31_soc_init(void)
179 } 179 }
180 180
181 imx_add_imx_sdma("imx31-sdma", MX31_SDMA_BASE_ADDR, MX31_INT_SDMA, &imx31_sdma_pdata); 181 imx_add_imx_sdma("imx31-sdma", MX31_SDMA_BASE_ADDR, MX31_INT_SDMA, &imx31_sdma_pdata);
182
183 imx_set_aips(MX31_IO_ADDRESS(MX31_AIPS1_BASE_ADDR));
184 imx_set_aips(MX31_IO_ADDRESS(MX31_AIPS2_BASE_ADDR));
185
182 platform_device_register_simple("imx31-audmux", 0, imx31_audmux_res, 186 platform_device_register_simple("imx31-audmux", 0, imx31_audmux_res,
183 ARRAY_SIZE(imx31_audmux_res)); 187 ARRAY_SIZE(imx31_audmux_res));
184} 188}
@@ -203,7 +207,7 @@ void __init imx35_init_early(void)
203 mxc_set_cpu_type(MXC_CPU_MX35); 207 mxc_set_cpu_type(MXC_CPU_MX35);
204 mxc_iomux_v3_init(MX35_IO_ADDRESS(MX35_IOMUXC_BASE_ADDR)); 208 mxc_iomux_v3_init(MX35_IO_ADDRESS(MX35_IOMUXC_BASE_ADDR));
205 mxc_arch_reset_init(MX35_IO_ADDRESS(MX35_WDOG_BASE_ADDR)); 209 mxc_arch_reset_init(MX35_IO_ADDRESS(MX35_WDOG_BASE_ADDR));
206 pm_idle = imx3_idle; 210 arm_pm_idle = imx3_idle;
207 imx_ioremap = imx3_ioremap; 211 imx_ioremap = imx3_ioremap;
208} 212}
209 213
@@ -269,6 +273,11 @@ void __init imx35_soc_init(void)
269 } 273 }
270 274
271 imx_add_imx_sdma("imx35-sdma", MX35_SDMA_BASE_ADDR, MX35_INT_SDMA, &imx35_sdma_pdata); 275 imx_add_imx_sdma("imx35-sdma", MX35_SDMA_BASE_ADDR, MX35_INT_SDMA, &imx35_sdma_pdata);
276
277 /* Setup AIPS registers */
278 imx_set_aips(MX35_IO_ADDRESS(MX35_AIPS1_BASE_ADDR));
279 imx_set_aips(MX35_IO_ADDRESS(MX35_AIPS2_BASE_ADDR));
280
272 /* i.mx35 has the i.mx31 type audmux */ 281 /* i.mx35 has the i.mx31 type audmux */
273 platform_device_register_simple("imx31-audmux", 0, imx35_audmux_res, 282 platform_device_register_simple("imx31-audmux", 0, imx35_audmux_res,
274 ARRAY_SIZE(imx35_audmux_res)); 283 ARRAY_SIZE(imx35_audmux_res));
diff --git a/arch/arm/mach-imx/mm-imx5.c b/arch/arm/mach-imx/mm-imx5.c
index 90d7880bb37..51af9fa5694 100644
--- a/arch/arm/mach-imx/mm-imx5.c
+++ b/arch/arm/mach-imx/mm-imx5.c
@@ -26,23 +26,17 @@ static struct clk *gpc_dvfs_clk;
26 26
27static void imx5_idle(void) 27static void imx5_idle(void)
28{ 28{
29 if (!need_resched()) { 29 /* gpc clock is needed for SRPG */
30 /* gpc clock is needed for SRPG */ 30 if (gpc_dvfs_clk == NULL) {
31 if (gpc_dvfs_clk == NULL) { 31 gpc_dvfs_clk = clk_get(NULL, "gpc_dvfs");
32 gpc_dvfs_clk = clk_get(NULL, "gpc_dvfs"); 32 if (IS_ERR(gpc_dvfs_clk))
33 if (IS_ERR(gpc_dvfs_clk)) 33 return;
34 goto err0;
35 }
36 clk_enable(gpc_dvfs_clk);
37 mx5_cpu_lp_set(WAIT_UNCLOCKED_POWER_OFF);
38 if (tzic_enable_wake())
39 goto err1;
40 cpu_do_idle();
41err1:
42 clk_disable(gpc_dvfs_clk);
43 } 34 }
44err0: 35 clk_enable(gpc_dvfs_clk);
45 local_irq_enable(); 36 mx5_cpu_lp_set(WAIT_UNCLOCKED_POWER_OFF);
37 if (tzic_enable_wake() != 0)
38 cpu_do_idle();
39 clk_disable(gpc_dvfs_clk);
46} 40}
47 41
48/* 42/*
@@ -108,7 +102,7 @@ void __init imx51_init_early(void)
108 mxc_set_cpu_type(MXC_CPU_MX51); 102 mxc_set_cpu_type(MXC_CPU_MX51);
109 mxc_iomux_v3_init(MX51_IO_ADDRESS(MX51_IOMUXC_BASE_ADDR)); 103 mxc_iomux_v3_init(MX51_IO_ADDRESS(MX51_IOMUXC_BASE_ADDR));
110 mxc_arch_reset_init(MX51_IO_ADDRESS(MX51_WDOG1_BASE_ADDR)); 104 mxc_arch_reset_init(MX51_IO_ADDRESS(MX51_WDOG1_BASE_ADDR));
111 pm_idle = imx5_idle; 105 arm_pm_idle = imx5_idle;
112} 106}
113 107
114void __init imx53_init_early(void) 108void __init imx53_init_early(void)
@@ -207,6 +201,11 @@ void __init imx51_soc_init(void)
207 201
208 /* i.mx51 has the i.mx35 type sdma */ 202 /* i.mx51 has the i.mx35 type sdma */
209 imx_add_imx_sdma("imx35-sdma", MX51_SDMA_BASE_ADDR, MX51_INT_SDMA, &imx51_sdma_pdata); 203 imx_add_imx_sdma("imx35-sdma", MX51_SDMA_BASE_ADDR, MX51_INT_SDMA, &imx51_sdma_pdata);
204
205 /* Setup AIPS registers */
206 imx_set_aips(MX51_IO_ADDRESS(MX51_AIPS1_BASE_ADDR));
207 imx_set_aips(MX51_IO_ADDRESS(MX51_AIPS2_BASE_ADDR));
208
210 /* i.mx51 has the i.mx31 type audmux */ 209 /* i.mx51 has the i.mx31 type audmux */
211 platform_device_register_simple("imx31-audmux", 0, imx51_audmux_res, 210 platform_device_register_simple("imx31-audmux", 0, imx51_audmux_res,
212 ARRAY_SIZE(imx51_audmux_res)); 211 ARRAY_SIZE(imx51_audmux_res));
@@ -225,6 +224,11 @@ void __init imx53_soc_init(void)
225 224
226 /* i.mx53 has the i.mx35 type sdma */ 225 /* i.mx53 has the i.mx35 type sdma */
227 imx_add_imx_sdma("imx35-sdma", MX53_SDMA_BASE_ADDR, MX53_INT_SDMA, &imx53_sdma_pdata); 226 imx_add_imx_sdma("imx35-sdma", MX53_SDMA_BASE_ADDR, MX53_INT_SDMA, &imx53_sdma_pdata);
227
228 /* Setup AIPS registers */
229 imx_set_aips(MX53_IO_ADDRESS(MX53_AIPS1_BASE_ADDR));
230 imx_set_aips(MX53_IO_ADDRESS(MX53_AIPS2_BASE_ADDR));
231
228 /* i.mx53 has the i.mx31 type audmux */ 232 /* i.mx53 has the i.mx31 type audmux */
229 platform_device_register_simple("imx31-audmux", 0, imx53_audmux_res, 233 platform_device_register_simple("imx31-audmux", 0, imx53_audmux_res,
230 ARRAY_SIZE(imx53_audmux_res)); 234 ARRAY_SIZE(imx53_audmux_res));
diff --git a/arch/arm/mach-imx/pm-imx27.c b/arch/arm/mach-imx/pm-imx27.c
index e455d2f855b..6fcffa7db97 100644
--- a/arch/arm/mach-imx/pm-imx27.c
+++ b/arch/arm/mach-imx/pm-imx27.c
@@ -10,7 +10,6 @@
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/suspend.h> 11#include <linux/suspend.h>
12#include <linux/io.h> 12#include <linux/io.h>
13#include <mach/system.h>
14#include <mach/hardware.h> 13#include <mach/hardware.h>
15 14
16static int mx27_suspend_enter(suspend_state_t state) 15static int mx27_suspend_enter(suspend_state_t state)
@@ -23,7 +22,7 @@ static int mx27_suspend_enter(suspend_state_t state)
23 cscr &= 0xFFFFFFFC; 22 cscr &= 0xFFFFFFFC;
24 __raw_writel(cscr, MX27_IO_ADDRESS(MX27_CCM_BASE_ADDR)); 23 __raw_writel(cscr, MX27_IO_ADDRESS(MX27_CCM_BASE_ADDR));
25 /* Executes WFI */ 24 /* Executes WFI */
26 arch_idle(); 25 cpu_do_idle();
27 break; 26 break;
28 27
29 default: 28 default:
diff --git a/arch/arm/mach-imx/pm-imx3.c b/arch/arm/mach-imx/pm-imx3.c
new file mode 100644
index 00000000000..b3752439632
--- /dev/null
+++ b/arch/arm/mach-imx/pm-imx3.c
@@ -0,0 +1,37 @@
1/*
2 * Copyright (C) 2012 Freescale Semiconductor, Inc. All Rights Reserved.
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#include <linux/io.h>
12#include <mach/common.h>
13#include <mach/hardware.h>
14#include <mach/devices-common.h>
15#include "crmregs-imx3.h"
16
17/*
18 * Set cpu low power mode before WFI instruction. This function is called
19 * mx3 because it can be used for mx31 and mx35.
20 * Currently only WAIT_MODE is supported.
21 */
22void mx3_cpu_lp_set(enum mx3_cpu_pwr_mode mode)
23{
24 int reg = __raw_readl(MXC_CCM_CCMR);
25 reg &= ~MXC_CCM_CCMR_LPM_MASK;
26
27 switch (mode) {
28 case MX3_WAIT:
29 if (cpu_is_mx35())
30 reg |= MXC_CCM_CCMR_LPM_WAIT_MX35;
31 __raw_writel(reg, MXC_CCM_CCMR);
32 break;
33 default:
34 pr_err("Unknown cpu power mode: %d\n", mode);
35 return;
36 }
37}
diff --git a/arch/arm/mach-imx/pm-imx5.c b/arch/arm/mach-imx/pm-imx5.c
index 6dc09344805..e26a9cb05ed 100644
--- a/arch/arm/mach-imx/pm-imx5.c
+++ b/arch/arm/mach-imx/pm-imx5.c
@@ -89,7 +89,7 @@ void mx5_cpu_lp_set(enum mxc_cpu_pwr_mode mode)
89 89
90static int mx5_suspend_prepare(void) 90static int mx5_suspend_prepare(void)
91{ 91{
92 return clk_enable(gpc_dvfs_clk); 92 return clk_prepare_enable(gpc_dvfs_clk);
93} 93}
94 94
95static int mx5_suspend_enter(suspend_state_t state) 95static int mx5_suspend_enter(suspend_state_t state)
@@ -119,7 +119,7 @@ static int mx5_suspend_enter(suspend_state_t state)
119 119
120static void mx5_suspend_finish(void) 120static void mx5_suspend_finish(void)
121{ 121{
122 clk_disable(gpc_dvfs_clk); 122 clk_disable_unprepare(gpc_dvfs_clk);
123} 123}
124 124
125static int mx5_pm_valid(suspend_state_t state) 125static int mx5_pm_valid(suspend_state_t state)
diff --git a/arch/arm/mach-integrator/core.c b/arch/arm/mach-integrator/core.c
index d2fd9f33e6f..1a65d77bd55 100644
--- a/arch/arm/mach-integrator/core.c
+++ b/arch/arm/mach-integrator/core.c
@@ -34,67 +34,23 @@
34 34
35static struct amba_pl010_data integrator_uart_data; 35static struct amba_pl010_data integrator_uart_data;
36 36
37static struct amba_device rtc_device = { 37#define INTEGRATOR_RTC_IRQ { IRQ_RTCINT }
38 .dev = { 38#define INTEGRATOR_UART0_IRQ { IRQ_UARTINT0 }
39 .init_name = "mb:15", 39#define INTEGRATOR_UART1_IRQ { IRQ_UARTINT1 }
40 }, 40#define KMI0_IRQ { IRQ_KMIINT0 }
41 .res = { 41#define KMI1_IRQ { IRQ_KMIINT1 }
42 .start = INTEGRATOR_RTC_BASE,
43 .end = INTEGRATOR_RTC_BASE + SZ_4K - 1,
44 .flags = IORESOURCE_MEM,
45 },
46 .irq = { IRQ_RTCINT, NO_IRQ },
47};
48 42
49static struct amba_device uart0_device = { 43static AMBA_APB_DEVICE(rtc, "mb:15", 0,
50 .dev = { 44 INTEGRATOR_RTC_BASE, INTEGRATOR_RTC_IRQ, NULL);
51 .init_name = "mb:16",
52 .platform_data = &integrator_uart_data,
53 },
54 .res = {
55 .start = INTEGRATOR_UART0_BASE,
56 .end = INTEGRATOR_UART0_BASE + SZ_4K - 1,
57 .flags = IORESOURCE_MEM,
58 },
59 .irq = { IRQ_UARTINT0, NO_IRQ },
60};
61 45
62static struct amba_device uart1_device = { 46static AMBA_APB_DEVICE(uart0, "mb:16", 0,
63 .dev = { 47 INTEGRATOR_UART0_BASE, INTEGRATOR_UART0_IRQ, &integrator_uart_data);
64 .init_name = "mb:17",
65 .platform_data = &integrator_uart_data,
66 },
67 .res = {
68 .start = INTEGRATOR_UART1_BASE,
69 .end = INTEGRATOR_UART1_BASE + SZ_4K - 1,
70 .flags = IORESOURCE_MEM,
71 },
72 .irq = { IRQ_UARTINT1, NO_IRQ },
73};
74 48
75static struct amba_device kmi0_device = { 49static AMBA_APB_DEVICE(uart1, "mb:17", 0,
76 .dev = { 50 INTEGRATOR_UART1_BASE, INTEGRATOR_UART1_IRQ, &integrator_uart_data);
77 .init_name = "mb:18",
78 },
79 .res = {
80 .start = KMI0_BASE,
81 .end = KMI0_BASE + SZ_4K - 1,
82 .flags = IORESOURCE_MEM,
83 },
84 .irq = { IRQ_KMIINT0, NO_IRQ },
85};
86 51
87static struct amba_device kmi1_device = { 52static AMBA_APB_DEVICE(kmi0, "mb:18", 0, KMI0_BASE, KMI0_IRQ, NULL);
88 .dev = { 53static AMBA_APB_DEVICE(kmi1, "mb:19", 0, KMI1_BASE, KMI1_IRQ, NULL);
89 .init_name = "mb:19",
90 },
91 .res = {
92 .start = KMI1_BASE,
93 .end = KMI1_BASE + SZ_4K - 1,
94 .flags = IORESOURCE_MEM,
95 },
96 .irq = { IRQ_KMIINT1, NO_IRQ },
97};
98 54
99static struct amba_device *amba_devs[] __initdata = { 55static struct amba_device *amba_devs[] __initdata = {
100 &rtc_device, 56 &rtc_device,
diff --git a/arch/arm/mach-integrator/impd1.c b/arch/arm/mach-integrator/impd1.c
index 8cbb75a96bd..3e538da6cb1 100644
--- a/arch/arm/mach-integrator/impd1.c
+++ b/arch/arm/mach-integrator/impd1.c
@@ -401,24 +401,21 @@ static int impd1_probe(struct lm_device *dev)
401 401
402 pc_base = dev->resource.start + idev->offset; 402 pc_base = dev->resource.start + idev->offset;
403 403
404 d = kzalloc(sizeof(struct amba_device), GFP_KERNEL); 404 d = amba_device_alloc(NULL, pc_base, SZ_4K);
405 if (!d) 405 if (!d)
406 continue; 406 continue;
407 407
408 dev_set_name(&d->dev, "lm%x:%5.5lx", dev->id, idev->offset >> 12); 408 dev_set_name(&d->dev, "lm%x:%5.5lx", dev->id, idev->offset >> 12);
409 d->dev.parent = &dev->dev; 409 d->dev.parent = &dev->dev;
410 d->res.start = dev->resource.start + idev->offset;
411 d->res.end = d->res.start + SZ_4K - 1;
412 d->res.flags = IORESOURCE_MEM;
413 d->irq[0] = dev->irq; 410 d->irq[0] = dev->irq;
414 d->irq[1] = dev->irq; 411 d->irq[1] = dev->irq;
415 d->periphid = idev->id; 412 d->periphid = idev->id;
416 d->dev.platform_data = idev->platform_data; 413 d->dev.platform_data = idev->platform_data;
417 414
418 ret = amba_device_register(d, &dev->resource); 415 ret = amba_device_add(d, &dev->resource);
419 if (ret) { 416 if (ret) {
420 dev_err(&d->dev, "unable to register device: %d\n", ret); 417 dev_err(&d->dev, "unable to register device: %d\n", ret);
421 kfree(d); 418 amba_device_put(d);
422 } 419 }
423 } 420 }
424 421
diff --git a/arch/arm/mach-integrator/include/mach/entry-macro.S b/arch/arm/mach-integrator/include/mach/entry-macro.S
index 3d029c9f3ef..5cc7b85ad9d 100644
--- a/arch/arm/mach-integrator/include/mach/entry-macro.S
+++ b/arch/arm/mach-integrator/include/mach/entry-macro.S
@@ -11,15 +11,9 @@
11#include <mach/platform.h> 11#include <mach/platform.h>
12#include <mach/irqs.h> 12#include <mach/irqs.h>
13 13
14 .macro disable_fiq
15 .endm
16
17 .macro get_irqnr_preamble, base, tmp 14 .macro get_irqnr_preamble, base, tmp
18 .endm 15 .endm
19 16
20 .macro arch_ret_to_user, tmp1, tmp2
21 .endm
22
23 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp 17 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
24/* FIXME: should not be using soo many LDRs here */ 18/* FIXME: should not be using soo many LDRs here */
25 ldr \base, =IO_ADDRESS(INTEGRATOR_IC_BASE) 19 ldr \base, =IO_ADDRESS(INTEGRATOR_IC_BASE)
diff --git a/arch/arm/mach-integrator/include/mach/system.h b/arch/arm/mach-integrator/include/mach/system.h
deleted file mode 100644
index 901514eba4a..00000000000
--- a/arch/arm/mach-integrator/include/mach/system.h
+++ /dev/null
@@ -1,33 +0,0 @@
1/*
2 * arch/arm/mach-integrator/include/mach/system.h
3 *
4 * Copyright (C) 1999 ARM Limited
5 * Copyright (C) 2000 Deep Blue Solutions Ltd
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 USA
20 */
21#ifndef __ASM_ARCH_SYSTEM_H
22#define __ASM_ARCH_SYSTEM_H
23
24static inline void arch_idle(void)
25{
26 /*
27 * This should do all the clock switching
28 * and wait for interrupt tricks
29 */
30 cpu_do_idle();
31}
32
33#endif
diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c
index a8b6aa6003f..be9ead4a3bc 100644
--- a/arch/arm/mach-integrator/integrator_cp.c
+++ b/arch/arm/mach-integrator/integrator_cp.c
@@ -347,32 +347,14 @@ static struct mmci_platform_data mmc_data = {
347 .gpio_cd = -1, 347 .gpio_cd = -1,
348}; 348};
349 349
350static struct amba_device mmc_device = { 350#define INTEGRATOR_CP_MMC_IRQS { IRQ_CP_MMCIINT0, IRQ_CP_MMCIINT1 }
351 .dev = { 351#define INTEGRATOR_CP_AACI_IRQS { IRQ_CP_AACIINT }
352 .init_name = "mb:1c",
353 .platform_data = &mmc_data,
354 },
355 .res = {
356 .start = INTEGRATOR_CP_MMC_BASE,
357 .end = INTEGRATOR_CP_MMC_BASE + SZ_4K - 1,
358 .flags = IORESOURCE_MEM,
359 },
360 .irq = { IRQ_CP_MMCIINT0, IRQ_CP_MMCIINT1 },
361 .periphid = 0,
362};
363 352
364static struct amba_device aaci_device = { 353static AMBA_APB_DEVICE(mmc, "mb:1c", 0, INTEGRATOR_CP_MMC_BASE,
365 .dev = { 354 INTEGRATOR_CP_MMC_IRQS, &mmc_data);
366 .init_name = "mb:1d", 355
367 }, 356static AMBA_APB_DEVICE(aaci, "mb:1d", 0, INTEGRATOR_CP_AACI_BASE,
368 .res = { 357 INTEGRATOR_CP_AACI_IRQS, NULL);
369 .start = INTEGRATOR_CP_AACI_BASE,
370 .end = INTEGRATOR_CP_AACI_BASE + SZ_4K - 1,
371 .flags = IORESOURCE_MEM,
372 },
373 .irq = { IRQ_CP_AACIINT, NO_IRQ },
374 .periphid = 0,
375};
376 358
377 359
378/* 360/*
@@ -425,21 +407,8 @@ static struct clcd_board clcd_data = {
425 .remove = versatile_clcd_remove_dma, 407 .remove = versatile_clcd_remove_dma,
426}; 408};
427 409
428static struct amba_device clcd_device = { 410static AMBA_AHB_DEVICE(clcd, "mb:c0", 0, INTCP_PA_CLCD_BASE,
429 .dev = { 411 { IRQ_CP_CLCDCINT }, &clcd_data);
430 .init_name = "mb:c0",
431 .coherent_dma_mask = ~0,
432 .platform_data = &clcd_data,
433 },
434 .res = {
435 .start = INTCP_PA_CLCD_BASE,
436 .end = INTCP_PA_CLCD_BASE + SZ_4K - 1,
437 .flags = IORESOURCE_MEM,
438 },
439 .dma_mask = ~0,
440 .irq = { IRQ_CP_CLCDCINT, NO_IRQ },
441 .periphid = 0,
442};
443 412
444static struct amba_device *amba_devs[] __initdata = { 413static struct amba_device *amba_devs[] __initdata = {
445 &mmc_device, 414 &mmc_device,
diff --git a/arch/arm/mach-integrator/pci_v3.c b/arch/arm/mach-integrator/pci_v3.c
index 9d47b4c6762..4be172c3cbe 100644
--- a/arch/arm/mach-integrator/pci_v3.c
+++ b/arch/arm/mach-integrator/pci_v3.c
@@ -377,9 +377,10 @@ static int __init pci_v3_setup_resources(struct pci_sys_data *sys)
377 * the mem resource for this bus 377 * the mem resource for this bus
378 * the prefetch mem resource for this bus 378 * the prefetch mem resource for this bus
379 */ 379 */
380 pci_add_resource(&sys->resources, &ioport_resource); 380 pci_add_resource_offset(&sys->resources,
381 pci_add_resource(&sys->resources, &non_mem); 381 &ioport_resource, sys->io_offset);
382 pci_add_resource(&sys->resources, &pre_mem); 382 pci_add_resource_offset(&sys->resources, &non_mem, sys->mem_offset);
383 pci_add_resource_offset(&sys->resources, &pre_mem, sys->mem_offset);
383 384
384 return 1; 385 return 1;
385} 386}
diff --git a/arch/arm/mach-iop13xx/include/mach/entry-macro.S b/arch/arm/mach-iop13xx/include/mach/entry-macro.S
index a624a7870c6..1a2d603488d 100644
--- a/arch/arm/mach-iop13xx/include/mach/entry-macro.S
+++ b/arch/arm/mach-iop13xx/include/mach/entry-macro.S
@@ -16,9 +16,6 @@
16 * Place - Suite 330, Boston, MA 02111-1307 USA. 16 * Place - Suite 330, Boston, MA 02111-1307 USA.
17 * 17 *
18 */ 18 */
19 .macro disable_fiq
20 .endm
21
22 .macro get_irqnr_preamble, base, tmp 19 .macro get_irqnr_preamble, base, tmp
23 mrc p15, 0, \tmp, c15, c1, 0 20 mrc p15, 0, \tmp, c15, c1, 0
24 orr \tmp, \tmp, #(1 << 6) 21 orr \tmp, \tmp, #(1 << 6)
diff --git a/arch/arm/mach-iop13xx/include/mach/system.h b/arch/arm/mach-iop13xx/include/mach/system.h
deleted file mode 100644
index 1f31ed3f8ae..00000000000
--- a/arch/arm/mach-iop13xx/include/mach/system.h
+++ /dev/null
@@ -1,13 +0,0 @@
1/*
2 * arch/arm/mach-iop13xx/include/mach/system.h
3 *
4 * Copyright (C) 2004 Intel Corp.
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 */
10static inline void arch_idle(void)
11{
12 cpu_do_idle();
13}
diff --git a/arch/arm/mach-iop13xx/pci.c b/arch/arm/mach-iop13xx/pci.c
index b8f5a873651..861cb12ef43 100644
--- a/arch/arm/mach-iop13xx/pci.c
+++ b/arch/arm/mach-iop13xx/pci.c
@@ -1084,8 +1084,8 @@ int iop13xx_pci_setup(int nr, struct pci_sys_data *sys)
1084 request_resource(&ioport_resource, &res[0]); 1084 request_resource(&ioport_resource, &res[0]);
1085 request_resource(&iomem_resource, &res[1]); 1085 request_resource(&iomem_resource, &res[1]);
1086 1086
1087 pci_add_resource(&sys->resources, &res[0]); 1087 pci_add_resource_offset(&sys->resources, &res[0], sys->io_offset);
1088 pci_add_resource(&sys->resources, &res[1]); 1088 pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset);
1089 1089
1090 return 1; 1090 return 1;
1091} 1091}
diff --git a/arch/arm/mach-iop32x/include/mach/entry-macro.S b/arch/arm/mach-iop32x/include/mach/entry-macro.S
index b02fb56bafc..ea13ae02d9b 100644
--- a/arch/arm/mach-iop32x/include/mach/entry-macro.S
+++ b/arch/arm/mach-iop32x/include/mach/entry-macro.S
@@ -9,9 +9,6 @@
9 */ 9 */
10#include <mach/iop32x.h> 10#include <mach/iop32x.h>
11 11
12 .macro disable_fiq
13 .endm
14
15 .macro get_irqnr_preamble, base, tmp 12 .macro get_irqnr_preamble, base, tmp
16 mrc p15, 0, \tmp, c15, c1, 0 13 mrc p15, 0, \tmp, c15, c1, 0
17 orr \tmp, \tmp, #(1 << 6) 14 orr \tmp, \tmp, #(1 << 6)
diff --git a/arch/arm/mach-iop32x/include/mach/system.h b/arch/arm/mach-iop32x/include/mach/system.h
deleted file mode 100644
index 4a88727bca9..00000000000
--- a/arch/arm/mach-iop32x/include/mach/system.h
+++ /dev/null
@@ -1,13 +0,0 @@
1/*
2 * arch/arm/mach-iop32x/include/mach/system.h
3 *
4 * Copyright (C) 2001 MontaVista Software, 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 version 2 as
8 * published by the Free Software Foundation.
9 */
10static inline void arch_idle(void)
11{
12 cpu_do_idle();
13}
diff --git a/arch/arm/mach-iop33x/include/mach/entry-macro.S b/arch/arm/mach-iop33x/include/mach/entry-macro.S
index 4e1f7282b35..0a398fe1fba 100644
--- a/arch/arm/mach-iop33x/include/mach/entry-macro.S
+++ b/arch/arm/mach-iop33x/include/mach/entry-macro.S
@@ -9,9 +9,6 @@
9 */ 9 */
10#include <mach/iop33x.h> 10#include <mach/iop33x.h>
11 11
12 .macro disable_fiq
13 .endm
14
15 .macro get_irqnr_preamble, base, tmp 12 .macro get_irqnr_preamble, base, tmp
16 mrc p15, 0, \tmp, c15, c1, 0 13 mrc p15, 0, \tmp, c15, c1, 0
17 orr \tmp, \tmp, #(1 << 6) 14 orr \tmp, \tmp, #(1 << 6)
diff --git a/arch/arm/mach-iop33x/include/mach/system.h b/arch/arm/mach-iop33x/include/mach/system.h
deleted file mode 100644
index 4f98e765397..00000000000
--- a/arch/arm/mach-iop33x/include/mach/system.h
+++ /dev/null
@@ -1,13 +0,0 @@
1/*
2 * arch/arm/mach-iop33x/include/mach/system.h
3 *
4 * Copyright (C) 2001 MontaVista Software, 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 version 2 as
8 * published by the Free Software Foundation.
9 */
10static inline void arch_idle(void)
11{
12 cpu_do_idle();
13}
diff --git a/arch/arm/mach-ixp2000/include/mach/entry-macro.S b/arch/arm/mach-ixp2000/include/mach/entry-macro.S
index 5850ffc8c75..c4444dff920 100644
--- a/arch/arm/mach-ixp2000/include/mach/entry-macro.S
+++ b/arch/arm/mach-ixp2000/include/mach/entry-macro.S
@@ -9,15 +9,9 @@
9 */ 9 */
10#include <mach/irqs.h> 10#include <mach/irqs.h>
11 11
12 .macro disable_fiq
13 .endm
14
15 .macro get_irqnr_preamble, base, tmp 12 .macro get_irqnr_preamble, base, tmp
16 .endm 13 .endm
17 14
18 .macro arch_ret_to_user, tmp1, tmp2
19 .endm
20
21 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp 15 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
22 16
23 mov \irqnr, #0x0 @clear out irqnr as default 17 mov \irqnr, #0x0 @clear out irqnr as default
diff --git a/arch/arm/mach-ixp2000/include/mach/system.h b/arch/arm/mach-ixp2000/include/mach/system.h
deleted file mode 100644
index a7fb08b2b8e..00000000000
--- a/arch/arm/mach-ixp2000/include/mach/system.h
+++ /dev/null
@@ -1,14 +0,0 @@
1/*
2 * arch/arm/mach-ixp2000/include/mach/system.h
3 *
4 * Copyright (C) 2002 Intel Corp.
5 * Copyricht (C) 2003-2005 MontaVista Software, Inc.
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 */
11static inline void arch_idle(void)
12{
13 cpu_do_idle();
14}
diff --git a/arch/arm/mach-ixp2000/ixdp2400.c b/arch/arm/mach-ixp2000/ixdp2400.c
index 558f5f81f02..915ad49e3b8 100644
--- a/arch/arm/mach-ixp2000/ixdp2400.c
+++ b/arch/arm/mach-ixp2000/ixdp2400.c
@@ -133,11 +133,11 @@ static void ixdp2400_pci_postinit(void)
133 133
134 if (ixdp2x00_master_npu()) { 134 if (ixdp2x00_master_npu()) {
135 dev = pci_get_bus_and_slot(1, IXDP2400_SLAVE_ENET_DEVFN); 135 dev = pci_get_bus_and_slot(1, IXDP2400_SLAVE_ENET_DEVFN);
136 pci_remove_bus_device(dev); 136 pci_stop_and_remove_bus_device(dev);
137 pci_dev_put(dev); 137 pci_dev_put(dev);
138 } else { 138 } else {
139 dev = pci_get_bus_and_slot(1, IXDP2400_MASTER_ENET_DEVFN); 139 dev = pci_get_bus_and_slot(1, IXDP2400_MASTER_ENET_DEVFN);
140 pci_remove_bus_device(dev); 140 pci_stop_and_remove_bus_device(dev);
141 pci_dev_put(dev); 141 pci_dev_put(dev);
142 142
143 ixdp2x00_slave_pci_postinit(); 143 ixdp2x00_slave_pci_postinit();
diff --git a/arch/arm/mach-ixp2000/ixdp2800.c b/arch/arm/mach-ixp2000/ixdp2800.c
index 33c6d5f3fda..a9f1819ea04 100644
--- a/arch/arm/mach-ixp2000/ixdp2800.c
+++ b/arch/arm/mach-ixp2000/ixdp2800.c
@@ -261,14 +261,14 @@ int __init ixdp2800_pci_init(void)
261 pci_common_init(&ixdp2800_pci); 261 pci_common_init(&ixdp2800_pci);
262 if (ixdp2x00_master_npu()) { 262 if (ixdp2x00_master_npu()) {
263 dev = pci_get_bus_and_slot(1, IXDP2800_SLAVE_ENET_DEVFN); 263 dev = pci_get_bus_and_slot(1, IXDP2800_SLAVE_ENET_DEVFN);
264 pci_remove_bus_device(dev); 264 pci_stop_and_remove_bus_device(dev);
265 pci_dev_put(dev); 265 pci_dev_put(dev);
266 266
267 ixdp2800_master_enable_slave(); 267 ixdp2800_master_enable_slave();
268 ixdp2800_master_wait_for_slave_bus_scan(); 268 ixdp2800_master_wait_for_slave_bus_scan();
269 } else { 269 } else {
270 dev = pci_get_bus_and_slot(1, IXDP2800_MASTER_ENET_DEVFN); 270 dev = pci_get_bus_and_slot(1, IXDP2800_MASTER_ENET_DEVFN);
271 pci_remove_bus_device(dev); 271 pci_stop_and_remove_bus_device(dev);
272 pci_dev_put(dev); 272 pci_dev_put(dev);
273 } 273 }
274 } 274 }
diff --git a/arch/arm/mach-ixp2000/ixdp2x00.c b/arch/arm/mach-ixp2000/ixdp2x00.c
index 910426a6ffd..421e38dc0fa 100644
--- a/arch/arm/mach-ixp2000/ixdp2x00.c
+++ b/arch/arm/mach-ixp2000/ixdp2x00.c
@@ -238,12 +238,12 @@ void ixdp2x00_slave_pci_postinit(void)
238 * Remove PMC device is there is one 238 * Remove PMC device is there is one
239 */ 239 */
240 if((dev = pci_get_bus_and_slot(1, IXDP2X00_PMC_DEVFN))) { 240 if((dev = pci_get_bus_and_slot(1, IXDP2X00_PMC_DEVFN))) {
241 pci_remove_bus_device(dev); 241 pci_stop_and_remove_bus_device(dev);
242 pci_dev_put(dev); 242 pci_dev_put(dev);
243 } 243 }
244 244
245 dev = pci_get_bus_and_slot(0, IXDP2X00_21555_DEVFN); 245 dev = pci_get_bus_and_slot(0, IXDP2X00_21555_DEVFN);
246 pci_remove_bus_device(dev); 246 pci_stop_and_remove_bus_device(dev);
247 pci_dev_put(dev); 247 pci_dev_put(dev);
248} 248}
249 249
diff --git a/arch/arm/mach-ixp2000/pci.c b/arch/arm/mach-ixp2000/pci.c
index 7e9a1f31a83..9c02de932fa 100644
--- a/arch/arm/mach-ixp2000/pci.c
+++ b/arch/arm/mach-ixp2000/pci.c
@@ -242,8 +242,10 @@ int ixp2000_pci_setup(int nr, struct pci_sys_data *sys)
242 if (nr >= 1) 242 if (nr >= 1)
243 return 0; 243 return 0;
244 244
245 pci_add_resource(&sys->resources, &ixp2000_pci_io_space); 245 pci_add_resource_offset(&sys->resources,
246 pci_add_resource(&sys->resources, &ixp2000_pci_mem_space); 246 &ixp2000_pci_io_space, sys->io_offset);
247 pci_add_resource_offset(&sys->resources,
248 &ixp2000_pci_mem_space, sys->mem_offset);
247 249
248 return 1; 250 return 1;
249} 251}
diff --git a/arch/arm/mach-ixp23xx/core.c b/arch/arm/mach-ixp23xx/core.c
index ccdec42af70..d2c2dc35cbd 100644
--- a/arch/arm/mach-ixp23xx/core.c
+++ b/arch/arm/mach-ixp23xx/core.c
@@ -440,6 +440,9 @@ static struct platform_device *ixp23xx_devices[] __initdata = {
440 440
441void __init ixp23xx_sys_init(void) 441void __init ixp23xx_sys_init(void)
442{ 442{
443 /* by default, the idle code is disabled */
444 disable_hlt();
445
443 *IXP23XX_EXP_UNIT_FUSE |= 0xf; 446 *IXP23XX_EXP_UNIT_FUSE |= 0xf;
444 platform_add_devices(ixp23xx_devices, ARRAY_SIZE(ixp23xx_devices)); 447 platform_add_devices(ixp23xx_devices, ARRAY_SIZE(ixp23xx_devices));
445} 448}
diff --git a/arch/arm/mach-ixp23xx/include/mach/entry-macro.S b/arch/arm/mach-ixp23xx/include/mach/entry-macro.S
index 3f5338a7bbd..3fd2cb984e4 100644
--- a/arch/arm/mach-ixp23xx/include/mach/entry-macro.S
+++ b/arch/arm/mach-ixp23xx/include/mach/entry-macro.S
@@ -2,15 +2,9 @@
2 * arch/arm/mach-ixp23xx/include/mach/entry-macro.S 2 * arch/arm/mach-ixp23xx/include/mach/entry-macro.S
3 */ 3 */
4 4
5 .macro disable_fiq
6 .endm
7
8 .macro get_irqnr_preamble, base, tmp 5 .macro get_irqnr_preamble, base, tmp
9 .endm 6 .endm
10 7
11 .macro arch_ret_to_user, tmp1, tmp2
12 .endm
13
14 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp 8 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
15 ldr \irqnr, =(IXP23XX_INTC_VIRT + IXP23XX_INTR_IRQ_ENC_ST_OFFSET) 9 ldr \irqnr, =(IXP23XX_INTC_VIRT + IXP23XX_INTR_IRQ_ENC_ST_OFFSET)
16 ldr \irqnr, [\irqnr] @ get interrupt number 10 ldr \irqnr, [\irqnr] @ get interrupt number
diff --git a/arch/arm/mach-ixp23xx/include/mach/system.h b/arch/arm/mach-ixp23xx/include/mach/system.h
deleted file mode 100644
index 277dda7334b..00000000000
--- a/arch/arm/mach-ixp23xx/include/mach/system.h
+++ /dev/null
@@ -1,16 +0,0 @@
1/*
2 * arch/arm/mach-ixp23xx/include/mach/system.h
3 *
4 * Copyright (C) 2003 Intel Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10static inline void arch_idle(void)
11{
12#if 0
13 if (!hlt_counter)
14 cpu_do_idle();
15#endif
16}
diff --git a/arch/arm/mach-ixp23xx/pci.c b/arch/arm/mach-ixp23xx/pci.c
index bdf2866a02a..911f5a58e00 100644
--- a/arch/arm/mach-ixp23xx/pci.c
+++ b/arch/arm/mach-ixp23xx/pci.c
@@ -280,8 +280,10 @@ int ixp23xx_pci_setup(int nr, struct pci_sys_data *sys)
280 if (nr >= 1) 280 if (nr >= 1)
281 return 0; 281 return 0;
282 282
283 pci_add_resource(&sys->resources, &ixp23xx_pci_io_space); 283 pci_add_resource_offset(&sys->resources,
284 pci_add_resource(&sys->resources, &ixp23xx_pci_mem_space); 284 &ixp23xx_pci_io_space, sys->io_offset);
285 pci_add_resource_offset(&sys->resources,
286 &ixp23xx_pci_mem_space, sys->mem_offset);
285 287
286 return 1; 288 return 1;
287} 289}
diff --git a/arch/arm/mach-ixp4xx/common-pci.c b/arch/arm/mach-ixp4xx/common-pci.c
index 0f445d3f0fa..d5719eb4259 100644
--- a/arch/arm/mach-ixp4xx/common-pci.c
+++ b/arch/arm/mach-ixp4xx/common-pci.c
@@ -471,8 +471,8 @@ int ixp4xx_setup(int nr, struct pci_sys_data *sys)
471 request_resource(&ioport_resource, &res[0]); 471 request_resource(&ioport_resource, &res[0]);
472 request_resource(&iomem_resource, &res[1]); 472 request_resource(&iomem_resource, &res[1]);
473 473
474 pci_add_resource(&sys->resources, &res[0]); 474 pci_add_resource_offset(&sys->resources, &res[0], sys->io_offset);
475 pci_add_resource(&sys->resources, &res[1]); 475 pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset);
476 476
477 platform_notify = ixp4xx_pci_platform_notify; 477 platform_notify = ixp4xx_pci_platform_notify;
478 platform_notify_remove = ixp4xx_pci_platform_notify_remove; 478 platform_notify_remove = ixp4xx_pci_platform_notify_remove;
diff --git a/arch/arm/mach-ixp4xx/common.c b/arch/arm/mach-ixp4xx/common.c
index 3841ab4146b..a6329a0a8ec 100644
--- a/arch/arm/mach-ixp4xx/common.c
+++ b/arch/arm/mach-ixp4xx/common.c
@@ -236,6 +236,12 @@ void __init ixp4xx_init_irq(void)
236{ 236{
237 int i = 0; 237 int i = 0;
238 238
239 /*
240 * ixp4xx does not implement the XScale PWRMODE register
241 * so it must not call cpu_do_idle().
242 */
243 disable_hlt();
244
239 /* Route all sources to IRQ instead of FIQ */ 245 /* Route all sources to IRQ instead of FIQ */
240 *IXP4XX_ICLR = 0x0; 246 *IXP4XX_ICLR = 0x0;
241 247
diff --git a/arch/arm/mach-ixp4xx/include/mach/entry-macro.S b/arch/arm/mach-ixp4xx/include/mach/entry-macro.S
index f2e14e94ed1..79adf83e2c3 100644
--- a/arch/arm/mach-ixp4xx/include/mach/entry-macro.S
+++ b/arch/arm/mach-ixp4xx/include/mach/entry-macro.S
@@ -9,15 +9,9 @@
9 */ 9 */
10#include <mach/hardware.h> 10#include <mach/hardware.h>
11 11
12 .macro disable_fiq
13 .endm
14
15 .macro get_irqnr_preamble, base, tmp 12 .macro get_irqnr_preamble, base, tmp
16 .endm 13 .endm
17 14
18 .macro arch_ret_to_user, tmp1, tmp2
19 .endm
20
21 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp 15 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
22 ldr \irqstat, =(IXP4XX_INTC_BASE_VIRT+IXP4XX_ICIP_OFFSET) 16 ldr \irqstat, =(IXP4XX_INTC_BASE_VIRT+IXP4XX_ICIP_OFFSET)
23 ldr \irqstat, [\irqstat] @ get interrupts 17 ldr \irqstat, [\irqstat] @ get interrupts
diff --git a/arch/arm/mach-ixp4xx/include/mach/system.h b/arch/arm/mach-ixp4xx/include/mach/system.h
deleted file mode 100644
index 140a9bef446..00000000000
--- a/arch/arm/mach-ixp4xx/include/mach/system.h
+++ /dev/null
@@ -1,19 +0,0 @@
1/*
2 * arch/arm/mach-ixp4xx/include/mach/system.h
3 *
4 * Copyright (C) 2002 Intel Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 */
11static inline void arch_idle(void)
12{
13 /* ixp4xx does not implement the XScale PWRMODE register,
14 * so it must not call cpu_do_idle() here.
15 */
16#if 0
17 cpu_do_idle();
18#endif
19}
diff --git a/arch/arm/mach-kirkwood/Kconfig b/arch/arm/mach-kirkwood/Kconfig
index 7fc603b4689..90ceab76192 100644
--- a/arch/arm/mach-kirkwood/Kconfig
+++ b/arch/arm/mach-kirkwood/Kconfig
@@ -44,6 +44,20 @@ config MACH_GURUPLUG
44 Say 'Y' here if you want your kernel to support the 44 Say 'Y' here if you want your kernel to support the
45 Marvell GuruPlug Reference Board. 45 Marvell GuruPlug Reference Board.
46 46
47config ARCH_KIRKWOOD_DT
48 bool "Marvell Kirkwood Flattened Device Tree"
49 select USE_OF
50 help
51 Say 'Y' here if you want your kernel to support the
52 Marvell Kirkwood using flattened device tree.
53
54config MACH_DREAMPLUG_DT
55 bool "Marvell DreamPlug (Flattened Device Tree)"
56 select ARCH_KIRKWOOD_DT
57 help
58 Say 'Y' here if you want your kernel to support the
59 Marvell DreamPlug (Flattened Device Tree).
60
47config MACH_TS219 61config MACH_TS219
48 bool "QNAP TS-110, TS-119, TS-119P+, TS-210, TS-219, TS-219P and TS-219P+ Turbo NAS" 62 bool "QNAP TS-110, TS-119, TS-119P+, TS-210, TS-219, TS-219P and TS-219P+ Turbo NAS"
49 help 63 help
diff --git a/arch/arm/mach-kirkwood/Makefile b/arch/arm/mach-kirkwood/Makefile
index 5dcaa81a2ec..e299a9576bf 100644
--- a/arch/arm/mach-kirkwood/Makefile
+++ b/arch/arm/mach-kirkwood/Makefile
@@ -20,3 +20,5 @@ obj-$(CONFIG_MACH_NET5BIG_V2) += netxbig_v2-setup.o lacie_v2-common.o
20obj-$(CONFIG_MACH_T5325) += t5325-setup.o 20obj-$(CONFIG_MACH_T5325) += t5325-setup.o
21 21
22obj-$(CONFIG_CPU_IDLE) += cpuidle.o 22obj-$(CONFIG_CPU_IDLE) += cpuidle.o
23obj-$(CONFIG_ARCH_KIRKWOOD_DT) += board-dt.o
24obj-$(CONFIG_MACH_DREAMPLUG_DT) += board-dreamplug.o
diff --git a/arch/arm/mach-kirkwood/Makefile.boot b/arch/arm/mach-kirkwood/Makefile.boot
index 760a0efe758..16f93852230 100644
--- a/arch/arm/mach-kirkwood/Makefile.boot
+++ b/arch/arm/mach-kirkwood/Makefile.boot
@@ -1,3 +1,5 @@
1 zreladdr-y += 0x00008000 1 zreladdr-y += 0x00008000
2params_phys-y := 0x00000100 2params_phys-y := 0x00000100
3initrd_phys-y := 0x00800000 3initrd_phys-y := 0x00800000
4
5dtb-$(CONFIG_MACH_DREAMPLUG_DT) += kirkwood-dreamplug.dtb
diff --git a/arch/arm/mach-kirkwood/board-dreamplug.c b/arch/arm/mach-kirkwood/board-dreamplug.c
new file mode 100644
index 00000000000..985453994dd
--- /dev/null
+++ b/arch/arm/mach-kirkwood/board-dreamplug.c
@@ -0,0 +1,152 @@
1/*
2 * Copyright 2012 (C), Jason Cooper <jason@lakedaemon.net>
3 *
4 * arch/arm/mach-kirkwood/board-dreamplug.c
5 *
6 * Marvell DreamPlug Reference 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
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/mv643xx_eth.h>
20#include <linux/of.h>
21#include <linux/of_address.h>
22#include <linux/of_fdt.h>
23#include <linux/of_irq.h>
24#include <linux/of_platform.h>
25#include <linux/gpio.h>
26#include <linux/leds.h>
27#include <linux/mtd/physmap.h>
28#include <linux/spi/flash.h>
29#include <linux/spi/spi.h>
30#include <linux/spi/orion_spi.h>
31#include <asm/mach-types.h>
32#include <asm/mach/arch.h>
33#include <asm/mach/map.h>
34#include <mach/kirkwood.h>
35#include <mach/bridge-regs.h>
36#include <plat/mvsdio.h>
37#include "common.h"
38#include "mpp.h"
39
40struct mtd_partition dreamplug_partitions[] = {
41 {
42 .name = "u-boot",
43 .size = SZ_512K,
44 .offset = 0,
45 },
46 {
47 .name = "u-boot env",
48 .size = SZ_64K,
49 .offset = SZ_512K + SZ_512K,
50 },
51 {
52 .name = "dtb",
53 .size = SZ_64K,
54 .offset = SZ_512K + SZ_512K + SZ_512K,
55 },
56};
57
58static const struct flash_platform_data dreamplug_spi_slave_data = {
59 .type = "mx25l1606e",
60 .name = "spi_flash",
61 .parts = dreamplug_partitions,
62 .nr_parts = ARRAY_SIZE(dreamplug_partitions),
63};
64
65static struct spi_board_info __initdata dreamplug_spi_slave_info[] = {
66 {
67 .modalias = "m25p80",
68 .platform_data = &dreamplug_spi_slave_data,
69 .irq = -1,
70 .max_speed_hz = 50000000,
71 .bus_num = 0,
72 .chip_select = 0,
73 },
74};
75
76static struct mv643xx_eth_platform_data dreamplug_ge00_data = {
77 .phy_addr = MV643XX_ETH_PHY_ADDR(0),
78};
79
80static struct mv643xx_eth_platform_data dreamplug_ge01_data = {
81 .phy_addr = MV643XX_ETH_PHY_ADDR(1),
82};
83
84static struct mv_sata_platform_data dreamplug_sata_data = {
85 .n_ports = 1,
86};
87
88static struct mvsdio_platform_data dreamplug_mvsdio_data = {
89 /* unfortunately the CD signal has not been connected */
90};
91
92static struct gpio_led dreamplug_led_pins[] = {
93 {
94 .name = "dreamplug:blue:bluetooth",
95 .gpio = 47,
96 .active_low = 1,
97 },
98 {
99 .name = "dreamplug:green:wifi",
100 .gpio = 48,
101 .active_low = 1,
102 },
103 {
104 .name = "dreamplug:green:wifi_ap",
105 .gpio = 49,
106 .active_low = 1,
107 },
108};
109
110static struct gpio_led_platform_data dreamplug_led_data = {
111 .leds = dreamplug_led_pins,
112 .num_leds = ARRAY_SIZE(dreamplug_led_pins),
113};
114
115static struct platform_device dreamplug_leds = {
116 .name = "leds-gpio",
117 .id = -1,
118 .dev = {
119 .platform_data = &dreamplug_led_data,
120 }
121};
122
123static unsigned int dreamplug_mpp_config[] __initdata = {
124 MPP0_SPI_SCn,
125 MPP1_SPI_MOSI,
126 MPP2_SPI_SCK,
127 MPP3_SPI_MISO,
128 MPP47_GPIO, /* Bluetooth LED */
129 MPP48_GPIO, /* Wifi LED */
130 MPP49_GPIO, /* Wifi AP LED */
131 0
132};
133
134void __init dreamplug_init(void)
135{
136 /*
137 * Basic setup. Needs to be called early.
138 */
139 kirkwood_mpp_conf(dreamplug_mpp_config);
140
141 spi_register_board_info(dreamplug_spi_slave_info,
142 ARRAY_SIZE(dreamplug_spi_slave_info));
143 kirkwood_spi_init();
144
145 kirkwood_ehci_init();
146 kirkwood_ge00_init(&dreamplug_ge00_data);
147 kirkwood_ge01_init(&dreamplug_ge01_data);
148 kirkwood_sata_init(&dreamplug_sata_data);
149 kirkwood_sdio_init(&dreamplug_mvsdio_data);
150
151 platform_device_register(&dreamplug_leds);
152}
diff --git a/arch/arm/mach-kirkwood/board-dt.c b/arch/arm/mach-kirkwood/board-dt.c
new file mode 100644
index 00000000000..1c672d9e665
--- /dev/null
+++ b/arch/arm/mach-kirkwood/board-dt.c
@@ -0,0 +1,75 @@
1/*
2 * Copyright 2012 (C), Jason Cooper <jason@lakedaemon.net>
3 *
4 * arch/arm/mach-kirkwood/board-dt.c
5 *
6 * Flattened Device Tree board initialization
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 <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/of.h>
16#include <linux/of_platform.h>
17#include <asm/mach/arch.h>
18#include <asm/mach/map.h>
19#include <mach/bridge-regs.h>
20#include "common.h"
21
22static struct of_device_id kirkwood_dt_match_table[] __initdata = {
23 { .compatible = "simple-bus", },
24 { }
25};
26
27static void __init kirkwood_dt_init(void)
28{
29 pr_info("Kirkwood: %s, TCLK=%d.\n", kirkwood_id(), kirkwood_tclk);
30
31 /*
32 * Disable propagation of mbus errors to the CPU local bus,
33 * as this causes mbus errors (which can occur for example
34 * for PCI aborts) to throw CPU aborts, which we're not set
35 * up to deal with.
36 */
37 writel(readl(CPU_CONFIG) & ~CPU_CONFIG_ERROR_PROP, CPU_CONFIG);
38
39 kirkwood_setup_cpu_mbus();
40
41#ifdef CONFIG_CACHE_FEROCEON_L2
42 kirkwood_l2_init();
43#endif
44
45 /* internal devices that every board has */
46 kirkwood_wdt_init();
47 kirkwood_xor0_init();
48 kirkwood_xor1_init();
49 kirkwood_crypto_init();
50
51#ifdef CONFIG_KEXEC
52 kexec_reinit = kirkwood_enable_pcie;
53#endif
54
55 if (of_machine_is_compatible("globalscale,dreamplug"))
56 dreamplug_init();
57
58 of_platform_populate(NULL, kirkwood_dt_match_table, NULL, NULL);
59}
60
61static const char *kirkwood_dt_board_compat[] = {
62 "globalscale,dreamplug",
63 NULL
64};
65
66DT_MACHINE_START(KIRKWOOD_DT, "Marvell Kirkwood (Flattened Device Tree)")
67 /* Maintainer: Jason Cooper <jason@lakedaemon.net> */
68 .map_io = kirkwood_map_io,
69 .init_early = kirkwood_init_early,
70 .init_irq = kirkwood_init_irq,
71 .timer = &kirkwood_timer,
72 .init_machine = kirkwood_dt_init,
73 .restart = kirkwood_restart,
74 .dt_compat = kirkwood_dt_board_compat,
75MACHINE_END
diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
index 77d4852e19f..a02cae881f2 100644
--- a/arch/arm/mach-kirkwood/common.c
+++ b/arch/arm/mach-kirkwood/common.c
@@ -279,7 +279,7 @@ void __init kirkwood_crypto_init(void)
279/***************************************************************************** 279/*****************************************************************************
280 * XOR0 280 * XOR0
281 ****************************************************************************/ 281 ****************************************************************************/
282static void __init kirkwood_xor0_init(void) 282void __init kirkwood_xor0_init(void)
283{ 283{
284 kirkwood_clk_ctrl |= CGC_XOR0; 284 kirkwood_clk_ctrl |= CGC_XOR0;
285 285
@@ -291,7 +291,7 @@ static void __init kirkwood_xor0_init(void)
291/***************************************************************************** 291/*****************************************************************************
292 * XOR1 292 * XOR1
293 ****************************************************************************/ 293 ****************************************************************************/
294static void __init kirkwood_xor1_init(void) 294void __init kirkwood_xor1_init(void)
295{ 295{
296 kirkwood_clk_ctrl |= CGC_XOR1; 296 kirkwood_clk_ctrl |= CGC_XOR1;
297 297
@@ -303,7 +303,7 @@ static void __init kirkwood_xor1_init(void)
303/***************************************************************************** 303/*****************************************************************************
304 * Watchdog 304 * Watchdog
305 ****************************************************************************/ 305 ****************************************************************************/
306static void __init kirkwood_wdt_init(void) 306void __init kirkwood_wdt_init(void)
307{ 307{
308 orion_wdt_init(kirkwood_tclk); 308 orion_wdt_init(kirkwood_tclk);
309} 309}
@@ -392,7 +392,7 @@ void __init kirkwood_audio_init(void)
392/* 392/*
393 * Identify device ID and revision. 393 * Identify device ID and revision.
394 */ 394 */
395static char * __init kirkwood_id(void) 395char * __init kirkwood_id(void)
396{ 396{
397 u32 dev, rev; 397 u32 dev, rev;
398 398
@@ -435,7 +435,7 @@ static char * __init kirkwood_id(void)
435 } 435 }
436} 436}
437 437
438static void __init kirkwood_l2_init(void) 438void __init kirkwood_l2_init(void)
439{ 439{
440#ifdef CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH 440#ifdef CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH
441 writel(readl(L2_CONFIG_REG) | L2_WRITETHROUGH, L2_CONFIG_REG); 441 writel(readl(L2_CONFIG_REG) | L2_WRITETHROUGH, L2_CONFIG_REG);
@@ -450,7 +450,6 @@ void __init kirkwood_init(void)
450{ 450{
451 printk(KERN_INFO "Kirkwood: %s, TCLK=%d.\n", 451 printk(KERN_INFO "Kirkwood: %s, TCLK=%d.\n",
452 kirkwood_id(), kirkwood_tclk); 452 kirkwood_id(), kirkwood_tclk);
453 kirkwood_i2s_data.tclk = kirkwood_tclk;
454 453
455 /* 454 /*
456 * Disable propagation of mbus errors to the CPU local bus, 455 * Disable propagation of mbus errors to the CPU local bus,
diff --git a/arch/arm/mach-kirkwood/common.h b/arch/arm/mach-kirkwood/common.h
index 9071a397136..fa8e7689c43 100644
--- a/arch/arm/mach-kirkwood/common.h
+++ b/arch/arm/mach-kirkwood/common.h
@@ -51,6 +51,21 @@ void kirkwood_nand_init_rnb(struct mtd_partition *parts, int nr_parts, int (*dev
51void kirkwood_audio_init(void); 51void kirkwood_audio_init(void);
52void kirkwood_restart(char, const char *); 52void kirkwood_restart(char, const char *);
53 53
54/* board init functions for boards not fully converted to fdt */
55#ifdef CONFIG_MACH_DREAMPLUG_DT
56void dreamplug_init(void);
57#else
58static inline void dreamplug_init(void) {};
59#endif
60
61/* early init functions not converted to fdt yet */
62char *kirkwood_id(void);
63void kirkwood_l2_init(void);
64void kirkwood_wdt_init(void);
65void kirkwood_xor0_init(void);
66void kirkwood_xor1_init(void);
67void kirkwood_crypto_init(void);
68
54extern int kirkwood_tclk; 69extern int kirkwood_tclk;
55extern struct sys_timer kirkwood_timer; 70extern struct sys_timer kirkwood_timer;
56 71
diff --git a/arch/arm/mach-kirkwood/include/mach/entry-macro.S b/arch/arm/mach-kirkwood/include/mach/entry-macro.S
index 8939d36f893..82db29f7af8 100644
--- a/arch/arm/mach-kirkwood/include/mach/entry-macro.S
+++ b/arch/arm/mach-kirkwood/include/mach/entry-macro.S
@@ -10,12 +10,6 @@
10 10
11#include <mach/bridge-regs.h> 11#include <mach/bridge-regs.h>
12 12
13 .macro disable_fiq
14 .endm
15
16 .macro arch_ret_to_user, tmp1, tmp2
17 .endm
18
19 .macro get_irqnr_preamble, base, tmp 13 .macro get_irqnr_preamble, base, tmp
20 ldr \base, =IRQ_VIRT_BASE 14 ldr \base, =IRQ_VIRT_BASE
21 .endm 15 .endm
diff --git a/arch/arm/mach-kirkwood/include/mach/system.h b/arch/arm/mach-kirkwood/include/mach/system.h
deleted file mode 100644
index 5fddde002b5..00000000000
--- a/arch/arm/mach-kirkwood/include/mach/system.h
+++ /dev/null
@@ -1,17 +0,0 @@
1/*
2 * arch/arm/mach-kirkwood/include/mach/system.h
3 *
4 * This file is licensed under the terms of the GNU General Public
5 * License version 2. This program is licensed "as is" without any
6 * warranty of any kind, whether express or implied.
7 */
8
9#ifndef __ASM_ARCH_SYSTEM_H
10#define __ASM_ARCH_SYSTEM_H
11
12static inline void arch_idle(void)
13{
14 cpu_do_idle();
15}
16
17#endif
diff --git a/arch/arm/mach-kirkwood/pcie.c b/arch/arm/mach-kirkwood/pcie.c
index a066a6d8d9d..f56a0118c1b 100644
--- a/arch/arm/mach-kirkwood/pcie.c
+++ b/arch/arm/mach-kirkwood/pcie.c
@@ -198,9 +198,9 @@ static int __init kirkwood_pcie_setup(int nr, struct pci_sys_data *sys)
198 if (request_resource(&iomem_resource, &pp->res[1])) 198 if (request_resource(&iomem_resource, &pp->res[1]))
199 panic("Request PCIe%d Memory resource failed\n", index); 199 panic("Request PCIe%d Memory resource failed\n", index);
200 200
201 pci_add_resource(&sys->resources, &pp->res[0]);
202 pci_add_resource(&sys->resources, &pp->res[1]);
203 sys->io_offset = 0; 201 sys->io_offset = 0;
202 pci_add_resource_offset(&sys->resources, &pp->res[0], sys->io_offset);
203 pci_add_resource_offset(&sys->resources, &pp->res[1], sys->mem_offset);
204 204
205 /* 205 /*
206 * Generic PCIe unit setup. 206 * Generic PCIe unit setup.
diff --git a/arch/arm/mach-ks8695/include/mach/entry-macro.S b/arch/arm/mach-ks8695/include/mach/entry-macro.S
index b4fe0c11c6c..8315b34f32f 100644
--- a/arch/arm/mach-ks8695/include/mach/entry-macro.S
+++ b/arch/arm/mach-ks8695/include/mach/entry-macro.S
@@ -14,16 +14,10 @@
14#include <mach/hardware.h> 14#include <mach/hardware.h>
15#include <mach/regs-irq.h> 15#include <mach/regs-irq.h>
16 16
17 .macro disable_fiq
18 .endm
19
20 .macro get_irqnr_preamble, base, tmp 17 .macro get_irqnr_preamble, base, tmp
21 ldr \base, =KS8695_IRQ_VA @ Base address of interrupt controller 18 ldr \base, =KS8695_IRQ_VA @ Base address of interrupt controller
22 .endm 19 .endm
23 20
24 .macro arch_ret_to_user, tmp1, tmp2
25 .endm
26
27 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp 21 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
28 ldr \irqstat, [\base, #KS8695_INTMS] @ Mask Status register 22 ldr \irqstat, [\base, #KS8695_INTMS] @ Mask Status register
29 23
diff --git a/arch/arm/mach-ks8695/include/mach/system.h b/arch/arm/mach-ks8695/include/mach/system.h
deleted file mode 100644
index 59fe992395b..00000000000
--- a/arch/arm/mach-ks8695/include/mach/system.h
+++ /dev/null
@@ -1,27 +0,0 @@
1/*
2 * arch/arm/mach-s3c2410/include/mach/system.h
3 *
4 * Copyright (C) 2006 Simtec Electronics
5 * Ben Dooks <ben@simtec.co.uk>
6 *
7 * KS8695 - System function defines and includes
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_SYSTEM_H
15#define __ASM_ARCH_SYSTEM_H
16
17static void arch_idle(void)
18{
19 /*
20 * This should do all the clock switching
21 * and wait for interrupt tricks,
22 */
23 cpu_do_idle();
24
25}
26
27#endif
diff --git a/arch/arm/mach-ks8695/pci.c b/arch/arm/mach-ks8695/pci.c
index b26f992071d..acc70143581 100644
--- a/arch/arm/mach-ks8695/pci.c
+++ b/arch/arm/mach-ks8695/pci.c
@@ -169,8 +169,8 @@ static int __init ks8695_pci_setup(int nr, struct pci_sys_data *sys)
169 request_resource(&iomem_resource, &pci_mem); 169 request_resource(&iomem_resource, &pci_mem);
170 request_resource(&ioport_resource, &pci_io); 170 request_resource(&ioport_resource, &pci_io);
171 171
172 pci_add_resource(&sys->resources, &pci_io); 172 pci_add_resource_offset(&sys->resources, &pci_io, sys->io_offset);
173 pci_add_resource(&sys->resources, &pci_mem); 173 pci_add_resource_offset(&sys->resources, &pci_mem, sys->mem_offset);
174 174
175 /* Assign and enable processor bridge */ 175 /* Assign and enable processor bridge */
176 ks8695_local_writeconfig(PCI_BASE_ADDRESS_0, KS8695_PCIMEM_PA); 176 ks8695_local_writeconfig(PCI_BASE_ADDRESS_0, KS8695_PCIMEM_PA);
diff --git a/arch/arm/mach-lpc32xx/Kconfig b/arch/arm/mach-lpc32xx/Kconfig
index fde66350869..75946ac89ee 100644
--- a/arch/arm/mach-lpc32xx/Kconfig
+++ b/arch/arm/mach-lpc32xx/Kconfig
@@ -29,5 +29,30 @@ config ARCH_LPC32XX_UART6_SELECT
29 29
30endmenu 30endmenu
31 31
32menu "LPC32XX chip components"
33
34config ARCH_LPC32XX_IRAM_FOR_NET
35 bool "Use IRAM for network buffers"
36 default y
37 help
38 Say Y here to use the LPC internal fast IRAM (i.e. 256KB SRAM) as
39 network buffer. If the total combined required buffer sizes is
40 larger than the size of IRAM, then SDRAM will be used instead.
41
42 This can be enabled safely if the IRAM is not intended for other
43 uses.
44
45config ARCH_LPC32XX_MII_SUPPORT
46 bool "Check to enable MII support or leave disabled for RMII support"
47 help
48 Say Y here to enable MII support, or N for RMII support. Regardless of
49 which support is selected, the ethernet interface driver needs to be
50 selected in the device driver networking section.
51
52 The PHY3250 reference board uses RMII, so users of this board should
53 say N.
54
55endmenu
56
32endif 57endif
33 58
diff --git a/arch/arm/mach-lpc32xx/clock.c b/arch/arm/mach-lpc32xx/clock.c
index 1e027514096..b7ef51119d3 100644
--- a/arch/arm/mach-lpc32xx/clock.c
+++ b/arch/arm/mach-lpc32xx/clock.c
@@ -82,10 +82,12 @@
82 * will also impact the individual peripheral rates. 82 * will also impact the individual peripheral rates.
83 */ 83 */
84 84
85#include <linux/export.h>
85#include <linux/kernel.h> 86#include <linux/kernel.h>
86#include <linux/list.h> 87#include <linux/list.h>
87#include <linux/errno.h> 88#include <linux/errno.h>
88#include <linux/device.h> 89#include <linux/device.h>
90#include <linux/delay.h>
89#include <linux/err.h> 91#include <linux/err.h>
90#include <linux/clk.h> 92#include <linux/clk.h>
91#include <linux/amba/bus.h> 93#include <linux/amba/bus.h>
@@ -97,9 +99,12 @@
97#include "clock.h" 99#include "clock.h"
98#include "common.h" 100#include "common.h"
99 101
102static DEFINE_SPINLOCK(global_clkregs_lock);
103
104static int usb_pll_enable, usb_pll_valid;
105
100static struct clk clk_armpll; 106static struct clk clk_armpll;
101static struct clk clk_usbpll; 107static struct clk clk_usbpll;
102static DEFINE_MUTEX(clkm_lock);
103 108
104/* 109/*
105 * Post divider values for PLLs based on selected register value 110 * Post divider values for PLLs based on selected register value
@@ -127,7 +132,7 @@ static struct clk osc_32KHz = {
127static int local_pll397_enable(struct clk *clk, int enable) 132static int local_pll397_enable(struct clk *clk, int enable)
128{ 133{
129 u32 reg; 134 u32 reg;
130 unsigned long timeout = 1 + msecs_to_jiffies(10); 135 unsigned long timeout = jiffies + msecs_to_jiffies(10);
131 136
132 reg = __raw_readl(LPC32XX_CLKPWR_PLL397_CTRL); 137 reg = __raw_readl(LPC32XX_CLKPWR_PLL397_CTRL);
133 138
@@ -142,7 +147,7 @@ static int local_pll397_enable(struct clk *clk, int enable)
142 /* Wait for PLL397 lock */ 147 /* Wait for PLL397 lock */
143 while (((__raw_readl(LPC32XX_CLKPWR_PLL397_CTRL) & 148 while (((__raw_readl(LPC32XX_CLKPWR_PLL397_CTRL) &
144 LPC32XX_CLKPWR_SYSCTRL_PLL397_STS) == 0) && 149 LPC32XX_CLKPWR_SYSCTRL_PLL397_STS) == 0) &&
145 (timeout > jiffies)) 150 time_before(jiffies, timeout))
146 cpu_relax(); 151 cpu_relax();
147 152
148 if ((__raw_readl(LPC32XX_CLKPWR_PLL397_CTRL) & 153 if ((__raw_readl(LPC32XX_CLKPWR_PLL397_CTRL) &
@@ -156,7 +161,7 @@ static int local_pll397_enable(struct clk *clk, int enable)
156static int local_oscmain_enable(struct clk *clk, int enable) 161static int local_oscmain_enable(struct clk *clk, int enable)
157{ 162{
158 u32 reg; 163 u32 reg;
159 unsigned long timeout = 1 + msecs_to_jiffies(10); 164 unsigned long timeout = jiffies + msecs_to_jiffies(10);
160 165
161 reg = __raw_readl(LPC32XX_CLKPWR_MAIN_OSC_CTRL); 166 reg = __raw_readl(LPC32XX_CLKPWR_MAIN_OSC_CTRL);
162 167
@@ -171,7 +176,7 @@ static int local_oscmain_enable(struct clk *clk, int enable)
171 /* Wait for main oscillator to start */ 176 /* Wait for main oscillator to start */
172 while (((__raw_readl(LPC32XX_CLKPWR_MAIN_OSC_CTRL) & 177 while (((__raw_readl(LPC32XX_CLKPWR_MAIN_OSC_CTRL) &
173 LPC32XX_CLKPWR_MOSC_DISABLE) != 0) && 178 LPC32XX_CLKPWR_MOSC_DISABLE) != 0) &&
174 (timeout > jiffies)) 179 time_before(jiffies, timeout))
175 cpu_relax(); 180 cpu_relax();
176 181
177 if ((__raw_readl(LPC32XX_CLKPWR_MAIN_OSC_CTRL) & 182 if ((__raw_readl(LPC32XX_CLKPWR_MAIN_OSC_CTRL) &
@@ -382,30 +387,62 @@ static u32 local_clk_usbpll_setup(struct clk_pll_setup *pHCLKPllSetup)
382static int local_usbpll_enable(struct clk *clk, int enable) 387static int local_usbpll_enable(struct clk *clk, int enable)
383{ 388{
384 u32 reg; 389 u32 reg;
385 int ret = -ENODEV; 390 int ret = 0;
386 unsigned long timeout = 1 + msecs_to_jiffies(10); 391 unsigned long timeout = jiffies + msecs_to_jiffies(20);
387 392
388 reg = __raw_readl(LPC32XX_CLKPWR_USB_CTRL); 393 reg = __raw_readl(LPC32XX_CLKPWR_USB_CTRL);
389 394
390 if (enable == 0) { 395 __raw_writel(reg & ~(LPC32XX_CLKPWR_USBCTRL_CLK_EN2 |
391 reg &= ~(LPC32XX_CLKPWR_USBCTRL_CLK_EN1 | 396 LPC32XX_CLKPWR_USBCTRL_PLL_PWRUP),
392 LPC32XX_CLKPWR_USBCTRL_CLK_EN2); 397 LPC32XX_CLKPWR_USB_CTRL);
393 __raw_writel(reg, LPC32XX_CLKPWR_USB_CTRL); 398 __raw_writel(reg & ~LPC32XX_CLKPWR_USBCTRL_CLK_EN1,
394 } else if (reg & LPC32XX_CLKPWR_USBCTRL_PLL_PWRUP) { 399 LPC32XX_CLKPWR_USB_CTRL);
400
401 if (enable && usb_pll_valid && usb_pll_enable) {
402 ret = -ENODEV;
403 /*
404 * If the PLL rate has been previously set, then the rate
405 * in the PLL register is valid and can be enabled here.
406 * Otherwise, it needs to be enabled as part of setrate.
407 */
408
409 /*
410 * Gate clock into PLL
411 */
395 reg |= LPC32XX_CLKPWR_USBCTRL_CLK_EN1; 412 reg |= LPC32XX_CLKPWR_USBCTRL_CLK_EN1;
396 __raw_writel(reg, LPC32XX_CLKPWR_USB_CTRL); 413 __raw_writel(reg, LPC32XX_CLKPWR_USB_CTRL);
397 414
398 /* Wait for PLL lock */ 415 /*
399 while ((timeout > jiffies) & (ret == -ENODEV)) { 416 * Enable PLL
417 */
418 reg |= LPC32XX_CLKPWR_USBCTRL_PLL_PWRUP;
419 __raw_writel(reg, LPC32XX_CLKPWR_USB_CTRL);
420
421 /*
422 * Wait for PLL to lock
423 */
424 while (time_before(jiffies, timeout) && (ret == -ENODEV)) {
400 reg = __raw_readl(LPC32XX_CLKPWR_USB_CTRL); 425 reg = __raw_readl(LPC32XX_CLKPWR_USB_CTRL);
401 if (reg & LPC32XX_CLKPWR_USBCTRL_PLL_STS) 426 if (reg & LPC32XX_CLKPWR_USBCTRL_PLL_STS)
402 ret = 0; 427 ret = 0;
428 else
429 udelay(10);
403 } 430 }
404 431
432 /*
433 * Gate clock from PLL if PLL is locked
434 */
405 if (ret == 0) { 435 if (ret == 0) {
406 reg |= LPC32XX_CLKPWR_USBCTRL_CLK_EN2; 436 __raw_writel(reg | LPC32XX_CLKPWR_USBCTRL_CLK_EN2,
407 __raw_writel(reg, LPC32XX_CLKPWR_USB_CTRL); 437 LPC32XX_CLKPWR_USB_CTRL);
438 } else {
439 __raw_writel(reg & ~(LPC32XX_CLKPWR_USBCTRL_CLK_EN1 |
440 LPC32XX_CLKPWR_USBCTRL_PLL_PWRUP),
441 LPC32XX_CLKPWR_USB_CTRL);
408 } 442 }
443 } else if ((enable == 0) && usb_pll_valid && usb_pll_enable) {
444 usb_pll_valid = 0;
445 usb_pll_enable = 0;
409 } 446 }
410 447
411 return ret; 448 return ret;
@@ -423,7 +460,7 @@ static unsigned long local_usbpll_round_rate(struct clk *clk,
423 */ 460 */
424 rate = rate * 1000; 461 rate = rate * 1000;
425 462
426 clkin = clk->parent->rate; 463 clkin = clk->get_rate(clk);
427 usbdiv = (__raw_readl(LPC32XX_CLKPWR_USBCLK_PDIV) & 464 usbdiv = (__raw_readl(LPC32XX_CLKPWR_USBCLK_PDIV) &
428 LPC32XX_CLKPWR_USBPDIV_PLL_MASK) + 1; 465 LPC32XX_CLKPWR_USBPDIV_PLL_MASK) + 1;
429 clkin = clkin / usbdiv; 466 clkin = clkin / usbdiv;
@@ -437,7 +474,8 @@ static unsigned long local_usbpll_round_rate(struct clk *clk,
437 474
438static int local_usbpll_set_rate(struct clk *clk, unsigned long rate) 475static int local_usbpll_set_rate(struct clk *clk, unsigned long rate)
439{ 476{
440 u32 clkin, reg, usbdiv; 477 int ret = -ENODEV;
478 u32 clkin, usbdiv;
441 struct clk_pll_setup pllsetup; 479 struct clk_pll_setup pllsetup;
442 480
443 /* 481 /*
@@ -446,7 +484,7 @@ static int local_usbpll_set_rate(struct clk *clk, unsigned long rate)
446 */ 484 */
447 rate = rate * 1000; 485 rate = rate * 1000;
448 486
449 clkin = clk->get_rate(clk); 487 clkin = clk->get_rate(clk->parent);
450 usbdiv = (__raw_readl(LPC32XX_CLKPWR_USBCLK_PDIV) & 488 usbdiv = (__raw_readl(LPC32XX_CLKPWR_USBCLK_PDIV) &
451 LPC32XX_CLKPWR_USBPDIV_PLL_MASK) + 1; 489 LPC32XX_CLKPWR_USBPDIV_PLL_MASK) + 1;
452 clkin = clkin / usbdiv; 490 clkin = clkin / usbdiv;
@@ -455,22 +493,25 @@ static int local_usbpll_set_rate(struct clk *clk, unsigned long rate)
455 if (local_clk_find_pll_cfg(clkin, rate, &pllsetup) == 0) 493 if (local_clk_find_pll_cfg(clkin, rate, &pllsetup) == 0)
456 return -EINVAL; 494 return -EINVAL;
457 495
496 /*
497 * Disable PLL clocks during PLL change
498 */
458 local_usbpll_enable(clk, 0); 499 local_usbpll_enable(clk, 0);
459 500 pllsetup.analog_on = 0;
460 reg = __raw_readl(LPC32XX_CLKPWR_USB_CTRL);
461 reg |= LPC32XX_CLKPWR_USBCTRL_CLK_EN1;
462 __raw_writel(reg, LPC32XX_CLKPWR_USB_CTRL);
463
464 pllsetup.analog_on = 1;
465 local_clk_usbpll_setup(&pllsetup); 501 local_clk_usbpll_setup(&pllsetup);
466 502
467 clk->rate = clk_check_pll_setup(clkin, &pllsetup); 503 /*
504 * Start USB PLL and check PLL status
505 */
506
507 usb_pll_valid = 1;
508 usb_pll_enable = 1;
468 509
469 reg = __raw_readl(LPC32XX_CLKPWR_USB_CTRL); 510 ret = local_usbpll_enable(clk, 1);
470 reg |= LPC32XX_CLKPWR_USBCTRL_CLK_EN2; 511 if (ret >= 0)
471 __raw_writel(reg, LPC32XX_CLKPWR_USB_CTRL); 512 clk->rate = clk_check_pll_setup(clkin, &pllsetup);
472 513
473 return 0; 514 return ret;
474} 515}
475 516
476static struct clk clk_usbpll = { 517static struct clk clk_usbpll = {
@@ -719,6 +760,41 @@ static struct clk clk_tsc = {
719 .get_rate = local_return_parent_rate, 760 .get_rate = local_return_parent_rate,
720}; 761};
721 762
763static int adc_onoff_enable(struct clk *clk, int enable)
764{
765 u32 tmp;
766 u32 divider;
767
768 /* Use PERIPH_CLOCK */
769 tmp = __raw_readl(LPC32XX_CLKPWR_ADC_CLK_CTRL_1);
770 tmp |= LPC32XX_CLKPWR_ADCCTRL1_PCLK_SEL;
771 /*
772 * Set clock divider so that we have equal to or less than
773 * 4.5MHz clock at ADC
774 */
775 divider = clk->get_rate(clk) / 4500000 + 1;
776 tmp |= divider;
777 __raw_writel(tmp, LPC32XX_CLKPWR_ADC_CLK_CTRL_1);
778
779 /* synchronize rate of this clock w/ actual HW setting */
780 clk->rate = clk->get_rate(clk->parent) / divider;
781
782 if (enable == 0)
783 __raw_writel(0, clk->enable_reg);
784 else
785 __raw_writel(clk->enable_mask, clk->enable_reg);
786
787 return 0;
788}
789
790static struct clk clk_adc = {
791 .parent = &clk_pclk,
792 .enable = adc_onoff_enable,
793 .enable_reg = LPC32XX_CLKPWR_ADC_CLK_CTRL,
794 .enable_mask = LPC32XX_CLKPWR_ADC32CLKCTRL_CLK_EN,
795 .get_rate = local_return_parent_rate,
796};
797
722static int mmc_onoff_enable(struct clk *clk, int enable) 798static int mmc_onoff_enable(struct clk *clk, int enable)
723{ 799{
724 u32 tmp; 800 u32 tmp;
@@ -891,20 +967,8 @@ static struct clk clk_lcd = {
891 .enable_mask = LPC32XX_CLKPWR_LCDCTRL_CLK_EN, 967 .enable_mask = LPC32XX_CLKPWR_LCDCTRL_CLK_EN,
892}; 968};
893 969
894static inline void clk_lock(void)
895{
896 mutex_lock(&clkm_lock);
897}
898
899static inline void clk_unlock(void)
900{
901 mutex_unlock(&clkm_lock);
902}
903
904static void local_clk_disable(struct clk *clk) 970static void local_clk_disable(struct clk *clk)
905{ 971{
906 WARN_ON(clk->usecount == 0);
907
908 /* Don't attempt to disable clock if it has no users */ 972 /* Don't attempt to disable clock if it has no users */
909 if (clk->usecount > 0) { 973 if (clk->usecount > 0) {
910 clk->usecount--; 974 clk->usecount--;
@@ -947,10 +1011,11 @@ static int local_clk_enable(struct clk *clk)
947int clk_enable(struct clk *clk) 1011int clk_enable(struct clk *clk)
948{ 1012{
949 int ret; 1013 int ret;
1014 unsigned long flags;
950 1015
951 clk_lock(); 1016 spin_lock_irqsave(&global_clkregs_lock, flags);
952 ret = local_clk_enable(clk); 1017 ret = local_clk_enable(clk);
953 clk_unlock(); 1018 spin_unlock_irqrestore(&global_clkregs_lock, flags);
954 1019
955 return ret; 1020 return ret;
956} 1021}
@@ -961,9 +1026,11 @@ EXPORT_SYMBOL(clk_enable);
961 */ 1026 */
962void clk_disable(struct clk *clk) 1027void clk_disable(struct clk *clk)
963{ 1028{
964 clk_lock(); 1029 unsigned long flags;
1030
1031 spin_lock_irqsave(&global_clkregs_lock, flags);
965 local_clk_disable(clk); 1032 local_clk_disable(clk);
966 clk_unlock(); 1033 spin_unlock_irqrestore(&global_clkregs_lock, flags);
967} 1034}
968EXPORT_SYMBOL(clk_disable); 1035EXPORT_SYMBOL(clk_disable);
969 1036
@@ -972,13 +1039,7 @@ EXPORT_SYMBOL(clk_disable);
972 */ 1039 */
973unsigned long clk_get_rate(struct clk *clk) 1040unsigned long clk_get_rate(struct clk *clk)
974{ 1041{
975 unsigned long rate; 1042 return clk->get_rate(clk);
976
977 clk_lock();
978 rate = clk->get_rate(clk);
979 clk_unlock();
980
981 return rate;
982} 1043}
983EXPORT_SYMBOL(clk_get_rate); 1044EXPORT_SYMBOL(clk_get_rate);
984 1045
@@ -994,11 +1055,8 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
994 * the actual rate set as part of the peripheral dividers 1055 * the actual rate set as part of the peripheral dividers
995 * instead of high level clock control 1056 * instead of high level clock control
996 */ 1057 */
997 if (clk->set_rate) { 1058 if (clk->set_rate)
998 clk_lock();
999 ret = clk->set_rate(clk, rate); 1059 ret = clk->set_rate(clk, rate);
1000 clk_unlock();
1001 }
1002 1060
1003 return ret; 1061 return ret;
1004} 1062}
@@ -1009,15 +1067,11 @@ EXPORT_SYMBOL(clk_set_rate);
1009 */ 1067 */
1010long clk_round_rate(struct clk *clk, unsigned long rate) 1068long clk_round_rate(struct clk *clk, unsigned long rate)
1011{ 1069{
1012 clk_lock();
1013
1014 if (clk->round_rate) 1070 if (clk->round_rate)
1015 rate = clk->round_rate(clk, rate); 1071 rate = clk->round_rate(clk, rate);
1016 else 1072 else
1017 rate = clk->get_rate(clk); 1073 rate = clk->get_rate(clk);
1018 1074
1019 clk_unlock();
1020
1021 return rate; 1075 return rate;
1022} 1076}
1023EXPORT_SYMBOL(clk_round_rate); 1077EXPORT_SYMBOL(clk_round_rate);
@@ -1075,10 +1129,11 @@ static struct clk_lookup lookups[] = {
1075 _REGISTER_CLOCK("dev:ssp1", NULL, clk_ssp1) 1129 _REGISTER_CLOCK("dev:ssp1", NULL, clk_ssp1)
1076 _REGISTER_CLOCK("lpc32xx_keys.0", NULL, clk_kscan) 1130 _REGISTER_CLOCK("lpc32xx_keys.0", NULL, clk_kscan)
1077 _REGISTER_CLOCK("lpc32xx-nand.0", "nand_ck", clk_nand) 1131 _REGISTER_CLOCK("lpc32xx-nand.0", "nand_ck", clk_nand)
1078 _REGISTER_CLOCK("tbd", "i2s0_ck", clk_i2s0) 1132 _REGISTER_CLOCK("lpc32xx-adc", NULL, clk_adc)
1079 _REGISTER_CLOCK("tbd", "i2s1_ck", clk_i2s1) 1133 _REGISTER_CLOCK(NULL, "i2s0_ck", clk_i2s0)
1134 _REGISTER_CLOCK(NULL, "i2s1_ck", clk_i2s1)
1080 _REGISTER_CLOCK("ts-lpc32xx", NULL, clk_tsc) 1135 _REGISTER_CLOCK("ts-lpc32xx", NULL, clk_tsc)
1081 _REGISTER_CLOCK("dev:mmc0", "MCLK", clk_mmc) 1136 _REGISTER_CLOCK("dev:mmc0", NULL, clk_mmc)
1082 _REGISTER_CLOCK("lpc-net.0", NULL, clk_net) 1137 _REGISTER_CLOCK("lpc-net.0", NULL, clk_net)
1083 _REGISTER_CLOCK("dev:clcd", NULL, clk_lcd) 1138 _REGISTER_CLOCK("dev:clcd", NULL, clk_lcd)
1084 _REGISTER_CLOCK("lpc32xx_udc", "ck_usbd", clk_usbd) 1139 _REGISTER_CLOCK("lpc32xx_udc", "ck_usbd", clk_usbd)
diff --git a/arch/arm/mach-lpc32xx/common.c b/arch/arm/mach-lpc32xx/common.c
index 369b152896c..bbbf063a74c 100644
--- a/arch/arm/mach-lpc32xx/common.c
+++ b/arch/arm/mach-lpc32xx/common.c
@@ -138,6 +138,75 @@ struct platform_device lpc32xx_rtc_device = {
138}; 138};
139 139
140/* 140/*
141 * ADC support
142 */
143static struct resource adc_resources[] = {
144 {
145 .start = LPC32XX_ADC_BASE,
146 .end = LPC32XX_ADC_BASE + SZ_4K - 1,
147 .flags = IORESOURCE_MEM,
148 }, {
149 .start = IRQ_LPC32XX_TS_IRQ,
150 .end = IRQ_LPC32XX_TS_IRQ,
151 .flags = IORESOURCE_IRQ,
152 },
153};
154
155struct platform_device lpc32xx_adc_device = {
156 .name = "lpc32xx-adc",
157 .id = -1,
158 .num_resources = ARRAY_SIZE(adc_resources),
159 .resource = adc_resources,
160};
161
162/*
163 * USB support
164 */
165/* The dmamask must be set for OHCI to work */
166static u64 ohci_dmamask = ~(u32) 0;
167static struct resource ohci_resources[] = {
168 {
169 .start = IO_ADDRESS(LPC32XX_USB_BASE),
170 .end = IO_ADDRESS(LPC32XX_USB_BASE + 0x100 - 1),
171 .flags = IORESOURCE_MEM,
172 }, {
173 .start = IRQ_LPC32XX_USB_HOST,
174 .flags = IORESOURCE_IRQ,
175 },
176};
177struct platform_device lpc32xx_ohci_device = {
178 .name = "usb-ohci",
179 .id = -1,
180 .dev = {
181 .dma_mask = &ohci_dmamask,
182 .coherent_dma_mask = 0xFFFFFFFF,
183 },
184 .num_resources = ARRAY_SIZE(ohci_resources),
185 .resource = ohci_resources,
186};
187
188/*
189 * Network Support
190 */
191static struct resource net_resources[] = {
192 [0] = DEFINE_RES_MEM(LPC32XX_ETHERNET_BASE, SZ_4K),
193 [1] = DEFINE_RES_MEM(LPC32XX_IRAM_BASE, SZ_128K),
194 [2] = DEFINE_RES_IRQ(IRQ_LPC32XX_ETHERNET),
195};
196
197static u64 lpc32xx_mac_dma_mask = 0xffffffffUL;
198struct platform_device lpc32xx_net_device = {
199 .name = "lpc-eth",
200 .id = 0,
201 .dev = {
202 .dma_mask = &lpc32xx_mac_dma_mask,
203 .coherent_dma_mask = 0xffffffffUL,
204 },
205 .num_resources = ARRAY_SIZE(net_resources),
206 .resource = net_resources,
207};
208
209/*
141 * Returns the unique ID for the device 210 * Returns the unique ID for the device
142 */ 211 */
143void lpc32xx_get_uid(u32 devid[4]) 212void lpc32xx_get_uid(u32 devid[4])
diff --git a/arch/arm/mach-lpc32xx/common.h b/arch/arm/mach-lpc32xx/common.h
index 4b4e700343c..68e45e8c948 100644
--- a/arch/arm/mach-lpc32xx/common.h
+++ b/arch/arm/mach-lpc32xx/common.h
@@ -19,6 +19,7 @@
19#ifndef __LPC32XX_COMMON_H 19#ifndef __LPC32XX_COMMON_H
20#define __LPC32XX_COMMON_H 20#define __LPC32XX_COMMON_H
21 21
22#include <mach/board.h>
22#include <linux/platform_device.h> 23#include <linux/platform_device.h>
23 24
24/* 25/*
@@ -29,7 +30,10 @@ extern struct platform_device lpc32xx_i2c0_device;
29extern struct platform_device lpc32xx_i2c1_device; 30extern struct platform_device lpc32xx_i2c1_device;
30extern struct platform_device lpc32xx_i2c2_device; 31extern struct platform_device lpc32xx_i2c2_device;
31extern struct platform_device lpc32xx_tsc_device; 32extern struct platform_device lpc32xx_tsc_device;
33extern struct platform_device lpc32xx_adc_device;
32extern struct platform_device lpc32xx_rtc_device; 34extern struct platform_device lpc32xx_rtc_device;
35extern struct platform_device lpc32xx_ohci_device;
36extern struct platform_device lpc32xx_net_device;
33 37
34/* 38/*
35 * Other arch specific structures and functions 39 * Other arch specific structures and functions
@@ -65,9 +69,7 @@ extern u32 clk_get_pclk_div(void);
65 */ 69 */
66extern void lpc32xx_get_uid(u32 devid[4]); 70extern void lpc32xx_get_uid(u32 devid[4]);
67 71
68extern void lpc32xx_watchdog_reset(void);
69extern u32 lpc32xx_return_iram_size(void); 72extern u32 lpc32xx_return_iram_size(void);
70
71/* 73/*
72 * Pointers used for sizing and copying suspend function data 74 * Pointers used for sizing and copying suspend function data
73 */ 75 */
diff --git a/arch/arm/mach-lpc32xx/include/mach/system.h b/arch/arm/mach-lpc32xx/include/mach/board.h
index bf176c99152..52531ca7bd1 100644
--- a/arch/arm/mach-lpc32xx/include/mach/system.h
+++ b/arch/arm/mach-lpc32xx/include/mach/board.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * arch/arm/mach-lpc32xx/include/mach/system.h 2 * arm/arch/mach-lpc32xx/include/mach/board.h
3 * 3 *
4 * Author: Kevin Wells <kevin.wells@nxp.com> 4 * Author: Kevin Wells <kevin.wells@nxp.com>
5 * 5 *
@@ -16,12 +16,9 @@
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 */ 17 */
18 18
19#ifndef __ASM_ARCH_SYSTEM_H 19#ifndef __ASM_ARCH_BOARD_H
20#define __ASM_ARCH_SYSTEM_H 20#define __ASM_ARCH_BOARD_H
21 21
22static void arch_idle(void) 22extern u32 lpc32xx_return_iram_size(void);
23{
24 cpu_do_idle();
25}
26 23
27#endif 24#endif /* __ASM_ARCH_BOARD_H */
diff --git a/arch/arm/mach-lpc32xx/include/mach/entry-macro.S b/arch/arm/mach-lpc32xx/include/mach/entry-macro.S
index b725f6c9397..24ca11b377c 100644
--- a/arch/arm/mach-lpc32xx/include/mach/entry-macro.S
+++ b/arch/arm/mach-lpc32xx/include/mach/entry-macro.S
@@ -21,16 +21,10 @@
21 21
22#define LPC32XX_INTC_MASKED_STATUS_OFS 0x8 22#define LPC32XX_INTC_MASKED_STATUS_OFS 0x8
23 23
24 .macro disable_fiq
25 .endm
26
27 .macro get_irqnr_preamble, base, tmp 24 .macro get_irqnr_preamble, base, tmp
28 ldr \base, =IO_ADDRESS(LPC32XX_MIC_BASE) 25 ldr \base, =IO_ADDRESS(LPC32XX_MIC_BASE)
29 .endm 26 .endm
30 27
31 .macro arch_ret_to_user, tmp1, tmp2
32 .endm
33
34/* 28/*
35 * Return IRQ number in irqnr. Also return processor Z flag status in CPSR 29 * Return IRQ number in irqnr. Also return processor Z flag status in CPSR
36 * as set if an interrupt is pending. 30 * as set if an interrupt is pending.
diff --git a/arch/arm/mach-lpc32xx/include/mach/platform.h b/arch/arm/mach-lpc32xx/include/mach/platform.h
index 14ea8d1aadb..c584f5bb164 100644
--- a/arch/arm/mach-lpc32xx/include/mach/platform.h
+++ b/arch/arm/mach-lpc32xx/include/mach/platform.h
@@ -591,42 +591,42 @@
591/* 591/*
592 * Timer/counter register offsets 592 * Timer/counter register offsets
593 */ 593 */
594#define LCP32XX_TIMER_IR(x) io_p2v((x) + 0x00) 594#define LPC32XX_TIMER_IR(x) io_p2v((x) + 0x00)
595#define LCP32XX_TIMER_TCR(x) io_p2v((x) + 0x04) 595#define LPC32XX_TIMER_TCR(x) io_p2v((x) + 0x04)
596#define LCP32XX_TIMER_TC(x) io_p2v((x) + 0x08) 596#define LPC32XX_TIMER_TC(x) io_p2v((x) + 0x08)
597#define LCP32XX_TIMER_PR(x) io_p2v((x) + 0x0C) 597#define LPC32XX_TIMER_PR(x) io_p2v((x) + 0x0C)
598#define LCP32XX_TIMER_PC(x) io_p2v((x) + 0x10) 598#define LPC32XX_TIMER_PC(x) io_p2v((x) + 0x10)
599#define LCP32XX_TIMER_MCR(x) io_p2v((x) + 0x14) 599#define LPC32XX_TIMER_MCR(x) io_p2v((x) + 0x14)
600#define LCP32XX_TIMER_MR0(x) io_p2v((x) + 0x18) 600#define LPC32XX_TIMER_MR0(x) io_p2v((x) + 0x18)
601#define LCP32XX_TIMER_MR1(x) io_p2v((x) + 0x1C) 601#define LPC32XX_TIMER_MR1(x) io_p2v((x) + 0x1C)
602#define LCP32XX_TIMER_MR2(x) io_p2v((x) + 0x20) 602#define LPC32XX_TIMER_MR2(x) io_p2v((x) + 0x20)
603#define LCP32XX_TIMER_MR3(x) io_p2v((x) + 0x24) 603#define LPC32XX_TIMER_MR3(x) io_p2v((x) + 0x24)
604#define LCP32XX_TIMER_CCR(x) io_p2v((x) + 0x28) 604#define LPC32XX_TIMER_CCR(x) io_p2v((x) + 0x28)
605#define LCP32XX_TIMER_CR0(x) io_p2v((x) + 0x2C) 605#define LPC32XX_TIMER_CR0(x) io_p2v((x) + 0x2C)
606#define LCP32XX_TIMER_CR1(x) io_p2v((x) + 0x30) 606#define LPC32XX_TIMER_CR1(x) io_p2v((x) + 0x30)
607#define LCP32XX_TIMER_CR2(x) io_p2v((x) + 0x34) 607#define LPC32XX_TIMER_CR2(x) io_p2v((x) + 0x34)
608#define LCP32XX_TIMER_CR3(x) io_p2v((x) + 0x38) 608#define LPC32XX_TIMER_CR3(x) io_p2v((x) + 0x38)
609#define LCP32XX_TIMER_EMR(x) io_p2v((x) + 0x3C) 609#define LPC32XX_TIMER_EMR(x) io_p2v((x) + 0x3C)
610#define LCP32XX_TIMER_CTCR(x) io_p2v((x) + 0x70) 610#define LPC32XX_TIMER_CTCR(x) io_p2v((x) + 0x70)
611 611
612/* 612/*
613 * ir register definitions 613 * ir register definitions
614 */ 614 */
615#define LCP32XX_TIMER_CNTR_MTCH_BIT(n) (1 << ((n) & 0x3)) 615#define LPC32XX_TIMER_CNTR_MTCH_BIT(n) (1 << ((n) & 0x3))
616#define LCP32XX_TIMER_CNTR_CAPT_BIT(n) (1 << (4 + ((n) & 0x3))) 616#define LPC32XX_TIMER_CNTR_CAPT_BIT(n) (1 << (4 + ((n) & 0x3)))
617 617
618/* 618/*
619 * tcr register definitions 619 * tcr register definitions
620 */ 620 */
621#define LCP32XX_TIMER_CNTR_TCR_EN 0x1 621#define LPC32XX_TIMER_CNTR_TCR_EN 0x1
622#define LCP32XX_TIMER_CNTR_TCR_RESET 0x2 622#define LPC32XX_TIMER_CNTR_TCR_RESET 0x2
623 623
624/* 624/*
625 * mcr register definitions 625 * mcr register definitions
626 */ 626 */
627#define LCP32XX_TIMER_CNTR_MCR_MTCH(n) (0x1 << ((n) * 3)) 627#define LPC32XX_TIMER_CNTR_MCR_MTCH(n) (0x1 << ((n) * 3))
628#define LCP32XX_TIMER_CNTR_MCR_RESET(n) (0x1 << (((n) * 3) + 1)) 628#define LPC32XX_TIMER_CNTR_MCR_RESET(n) (0x1 << (((n) * 3) + 1))
629#define LCP32XX_TIMER_CNTR_MCR_STOP(n) (0x1 << (((n) * 3) + 2)) 629#define LPC32XX_TIMER_CNTR_MCR_STOP(n) (0x1 << (((n) * 3) + 2))
630 630
631/* 631/*
632 * Standard UART register offsets 632 * Standard UART register offsets
@@ -690,5 +690,8 @@
690#define LPC32XX_GPIO_P1_MUX_SET _GPREG(0x130) 690#define LPC32XX_GPIO_P1_MUX_SET _GPREG(0x130)
691#define LPC32XX_GPIO_P1_MUX_CLR _GPREG(0x134) 691#define LPC32XX_GPIO_P1_MUX_CLR _GPREG(0x134)
692#define LPC32XX_GPIO_P1_MUX_STATE _GPREG(0x138) 692#define LPC32XX_GPIO_P1_MUX_STATE _GPREG(0x138)
693#define LPC32XX_GPIO_P2_MUX_SET _GPREG(0x028)
694#define LPC32XX_GPIO_P2_MUX_CLR _GPREG(0x02C)
695#define LPC32XX_GPIO_P2_MUX_STATE _GPREG(0x030)
693 696
694#endif 697#endif
diff --git a/arch/arm/mach-lpc32xx/irq.c b/arch/arm/mach-lpc32xx/irq.c
index c74de01ab5b..d080cb1123d 100644
--- a/arch/arm/mach-lpc32xx/irq.c
+++ b/arch/arm/mach-lpc32xx/irq.c
@@ -150,6 +150,10 @@ static const struct lpc32xx_event_info lpc32xx_events[NR_IRQS] = {
150 .event_group = &lpc32xx_event_int_regs, 150 .event_group = &lpc32xx_event_int_regs,
151 .mask = LPC32XX_CLKPWR_INTSRC_KEY_BIT, 151 .mask = LPC32XX_CLKPWR_INTSRC_KEY_BIT,
152 }, 152 },
153 [IRQ_LPC32XX_ETHERNET] = {
154 .event_group = &lpc32xx_event_int_regs,
155 .mask = LPC32XX_CLKPWR_INTSRC_MAC_BIT,
156 },
153 [IRQ_LPC32XX_USB_OTG_ATX] = { 157 [IRQ_LPC32XX_USB_OTG_ATX] = {
154 .event_group = &lpc32xx_event_int_regs, 158 .event_group = &lpc32xx_event_int_regs,
155 .mask = LPC32XX_CLKPWR_INTSRC_USBATXINT_BIT, 159 .mask = LPC32XX_CLKPWR_INTSRC_USBATXINT_BIT,
diff --git a/arch/arm/mach-lpc32xx/phy3250.c b/arch/arm/mach-lpc32xx/phy3250.c
index bfee5b45510..7f7401ec748 100644
--- a/arch/arm/mach-lpc32xx/phy3250.c
+++ b/arch/arm/mach-lpc32xx/phy3250.c
@@ -37,6 +37,7 @@
37 37
38#include <mach/hardware.h> 38#include <mach/hardware.h>
39#include <mach/platform.h> 39#include <mach/platform.h>
40#include <mach/board.h>
40#include <mach/gpio-lpc32xx.h> 41#include <mach/gpio-lpc32xx.h>
41#include "common.h" 42#include "common.h"
42 43
@@ -149,20 +150,8 @@ static struct clcd_board lpc32xx_clcd_data = {
149 .remove = lpc32xx_clcd_remove, 150 .remove = lpc32xx_clcd_remove,
150}; 151};
151 152
152static struct amba_device lpc32xx_clcd_device = { 153static AMBA_AHB_DEVICE(lpc32xx_clcd, "dev:clcd", 0,
153 .dev = { 154 LPC32XX_LCD_BASE, { IRQ_LPC32XX_LCD }, &lpc32xx_clcd_data);
154 .coherent_dma_mask = ~0,
155 .init_name = "dev:clcd",
156 .platform_data = &lpc32xx_clcd_data,
157 },
158 .res = {
159 .start = LPC32XX_LCD_BASE,
160 .end = (LPC32XX_LCD_BASE + SZ_4K - 1),
161 .flags = IORESOURCE_MEM,
162 },
163 .dma_mask = ~0,
164 .irq = {IRQ_LPC32XX_LCD, NO_IRQ},
165};
166 155
167/* 156/*
168 * AMBA SSP (SPI) 157 * AMBA SSP (SPI)
@@ -191,20 +180,8 @@ static struct pl022_ssp_controller lpc32xx_ssp0_data = {
191 .enable_dma = 0, 180 .enable_dma = 0,
192}; 181};
193 182
194static struct amba_device lpc32xx_ssp0_device = { 183static AMBA_APB_DEVICE(lpc32xx_ssp0, "dev:ssp0", 0,
195 .dev = { 184 LPC32XX_SSP0_BASE, { IRQ_LPC32XX_SSP0 }, &lpc32xx_ssp0_data);
196 .coherent_dma_mask = ~0,
197 .init_name = "dev:ssp0",
198 .platform_data = &lpc32xx_ssp0_data,
199 },
200 .res = {
201 .start = LPC32XX_SSP0_BASE,
202 .end = (LPC32XX_SSP0_BASE + SZ_4K - 1),
203 .flags = IORESOURCE_MEM,
204 },
205 .dma_mask = ~0,
206 .irq = {IRQ_LPC32XX_SSP0, NO_IRQ},
207};
208 185
209/* AT25 driver registration */ 186/* AT25 driver registration */
210static int __init phy3250_spi_board_register(void) 187static int __init phy3250_spi_board_register(void)
@@ -271,11 +248,16 @@ static struct platform_device lpc32xx_gpio_led_device = {
271}; 248};
272 249
273static struct platform_device *phy3250_devs[] __initdata = { 250static struct platform_device *phy3250_devs[] __initdata = {
251 &lpc32xx_rtc_device,
252 &lpc32xx_tsc_device,
274 &lpc32xx_i2c0_device, 253 &lpc32xx_i2c0_device,
275 &lpc32xx_i2c1_device, 254 &lpc32xx_i2c1_device,
276 &lpc32xx_i2c2_device, 255 &lpc32xx_i2c2_device,
277 &lpc32xx_watchdog_device, 256 &lpc32xx_watchdog_device,
278 &lpc32xx_gpio_led_device, 257 &lpc32xx_gpio_led_device,
258 &lpc32xx_adc_device,
259 &lpc32xx_ohci_device,
260 &lpc32xx_net_device,
279}; 261};
280 262
281static struct amba_device *amba_devs[] __initdata = { 263static struct amba_device *amba_devs[] __initdata = {
diff --git a/arch/arm/mach-lpc32xx/pm.c b/arch/arm/mach-lpc32xx/pm.c
index b9c80597b7b..207e81275ff 100644
--- a/arch/arm/mach-lpc32xx/pm.c
+++ b/arch/arm/mach-lpc32xx/pm.c
@@ -13,7 +13,7 @@
13/* 13/*
14 * LPC32XX CPU and system power management 14 * LPC32XX CPU and system power management
15 * 15 *
16 * The LCP32XX has three CPU modes for controlling system power: run, 16 * The LPC32XX has three CPU modes for controlling system power: run,
17 * direct-run, and halt modes. When switching between halt and run modes, 17 * direct-run, and halt modes. When switching between halt and run modes,
18 * the CPU transistions through direct-run mode. For Linux, direct-run 18 * the CPU transistions through direct-run mode. For Linux, direct-run
19 * mode is not used in normal operation. Halt mode is used when the 19 * mode is not used in normal operation. Halt mode is used when the
diff --git a/arch/arm/mach-lpc32xx/timer.c b/arch/arm/mach-lpc32xx/timer.c
index b42c909bbee..c40667c3316 100644
--- a/arch/arm/mach-lpc32xx/timer.c
+++ b/arch/arm/mach-lpc32xx/timer.c
@@ -34,11 +34,11 @@
34static int lpc32xx_clkevt_next_event(unsigned long delta, 34static int lpc32xx_clkevt_next_event(unsigned long delta,
35 struct clock_event_device *dev) 35 struct clock_event_device *dev)
36{ 36{
37 __raw_writel(LCP32XX_TIMER_CNTR_TCR_RESET, 37 __raw_writel(LPC32XX_TIMER_CNTR_TCR_RESET,
38 LCP32XX_TIMER_TCR(LPC32XX_TIMER0_BASE)); 38 LPC32XX_TIMER_TCR(LPC32XX_TIMER0_BASE));
39 __raw_writel(delta, LCP32XX_TIMER_PR(LPC32XX_TIMER0_BASE)); 39 __raw_writel(delta, LPC32XX_TIMER_PR(LPC32XX_TIMER0_BASE));
40 __raw_writel(LCP32XX_TIMER_CNTR_TCR_EN, 40 __raw_writel(LPC32XX_TIMER_CNTR_TCR_EN,
41 LCP32XX_TIMER_TCR(LPC32XX_TIMER0_BASE)); 41 LPC32XX_TIMER_TCR(LPC32XX_TIMER0_BASE));
42 42
43 return 0; 43 return 0;
44} 44}
@@ -58,7 +58,7 @@ static void lpc32xx_clkevt_mode(enum clock_event_mode mode,
58 * disable the timer to wait for the first call to 58 * disable the timer to wait for the first call to
59 * set_next_event(). 59 * set_next_event().
60 */ 60 */
61 __raw_writel(0, LCP32XX_TIMER_TCR(LPC32XX_TIMER0_BASE)); 61 __raw_writel(0, LPC32XX_TIMER_TCR(LPC32XX_TIMER0_BASE));
62 break; 62 break;
63 63
64 case CLOCK_EVT_MODE_UNUSED: 64 case CLOCK_EVT_MODE_UNUSED:
@@ -81,8 +81,8 @@ static irqreturn_t lpc32xx_timer_interrupt(int irq, void *dev_id)
81 struct clock_event_device *evt = &lpc32xx_clkevt; 81 struct clock_event_device *evt = &lpc32xx_clkevt;
82 82
83 /* Clear match */ 83 /* Clear match */
84 __raw_writel(LCP32XX_TIMER_CNTR_MTCH_BIT(0), 84 __raw_writel(LPC32XX_TIMER_CNTR_MTCH_BIT(0),
85 LCP32XX_TIMER_IR(LPC32XX_TIMER0_BASE)); 85 LPC32XX_TIMER_IR(LPC32XX_TIMER0_BASE));
86 86
87 evt->event_handler(evt); 87 evt->event_handler(evt);
88 88
@@ -128,14 +128,14 @@ static void __init lpc32xx_timer_init(void)
128 clkrate = clkrate / clk_get_pclk_div(); 128 clkrate = clkrate / clk_get_pclk_div();
129 129
130 /* Initial timer setup */ 130 /* Initial timer setup */
131 __raw_writel(0, LCP32XX_TIMER_TCR(LPC32XX_TIMER0_BASE)); 131 __raw_writel(0, LPC32XX_TIMER_TCR(LPC32XX_TIMER0_BASE));
132 __raw_writel(LCP32XX_TIMER_CNTR_MTCH_BIT(0), 132 __raw_writel(LPC32XX_TIMER_CNTR_MTCH_BIT(0),
133 LCP32XX_TIMER_IR(LPC32XX_TIMER0_BASE)); 133 LPC32XX_TIMER_IR(LPC32XX_TIMER0_BASE));
134 __raw_writel(1, LCP32XX_TIMER_MR0(LPC32XX_TIMER0_BASE)); 134 __raw_writel(1, LPC32XX_TIMER_MR0(LPC32XX_TIMER0_BASE));
135 __raw_writel(LCP32XX_TIMER_CNTR_MCR_MTCH(0) | 135 __raw_writel(LPC32XX_TIMER_CNTR_MCR_MTCH(0) |
136 LCP32XX_TIMER_CNTR_MCR_STOP(0) | 136 LPC32XX_TIMER_CNTR_MCR_STOP(0) |
137 LCP32XX_TIMER_CNTR_MCR_RESET(0), 137 LPC32XX_TIMER_CNTR_MCR_RESET(0),
138 LCP32XX_TIMER_MCR(LPC32XX_TIMER0_BASE)); 138 LPC32XX_TIMER_MCR(LPC32XX_TIMER0_BASE));
139 139
140 /* Setup tick interrupt */ 140 /* Setup tick interrupt */
141 setup_irq(IRQ_LPC32XX_TIMER0, &lpc32xx_timer_irq); 141 setup_irq(IRQ_LPC32XX_TIMER0, &lpc32xx_timer_irq);
@@ -151,14 +151,14 @@ static void __init lpc32xx_timer_init(void)
151 clockevents_register_device(&lpc32xx_clkevt); 151 clockevents_register_device(&lpc32xx_clkevt);
152 152
153 /* Use timer1 as clock source. */ 153 /* Use timer1 as clock source. */
154 __raw_writel(LCP32XX_TIMER_CNTR_TCR_RESET, 154 __raw_writel(LPC32XX_TIMER_CNTR_TCR_RESET,
155 LCP32XX_TIMER_TCR(LPC32XX_TIMER1_BASE)); 155 LPC32XX_TIMER_TCR(LPC32XX_TIMER1_BASE));
156 __raw_writel(0, LCP32XX_TIMER_PR(LPC32XX_TIMER1_BASE)); 156 __raw_writel(0, LPC32XX_TIMER_PR(LPC32XX_TIMER1_BASE));
157 __raw_writel(0, LCP32XX_TIMER_MCR(LPC32XX_TIMER1_BASE)); 157 __raw_writel(0, LPC32XX_TIMER_MCR(LPC32XX_TIMER1_BASE));
158 __raw_writel(LCP32XX_TIMER_CNTR_TCR_EN, 158 __raw_writel(LPC32XX_TIMER_CNTR_TCR_EN,
159 LCP32XX_TIMER_TCR(LPC32XX_TIMER1_BASE)); 159 LPC32XX_TIMER_TCR(LPC32XX_TIMER1_BASE));
160 160
161 clocksource_mmio_init(LCP32XX_TIMER_TC(LPC32XX_TIMER1_BASE), 161 clocksource_mmio_init(LPC32XX_TIMER_TC(LPC32XX_TIMER1_BASE),
162 "lpc32xx_clksrc", clkrate, 300, 32, clocksource_mmio_readl_up); 162 "lpc32xx_clksrc", clkrate, 300, 32, clocksource_mmio_readl_up);
163} 163}
164 164
diff --git a/arch/arm/mach-mmp/Kconfig b/arch/arm/mach-mmp/Kconfig
index 323d4c9e9f4..5a90b9a3ab6 100644
--- a/arch/arm/mach-mmp/Kconfig
+++ b/arch/arm/mach-mmp/Kconfig
@@ -2,6 +2,16 @@ if ARCH_MMP
2 2
3menu "Marvell PXA168/910/MMP2 Implmentations" 3menu "Marvell PXA168/910/MMP2 Implmentations"
4 4
5config MACH_MMP_DT
6 bool "Support MMP2 platforms from device tree"
7 select CPU_PXA168
8 select CPU_PXA910
9 select USE_OF
10 help
11 Include support for Marvell MMP2 based platforms using
12 the device tree. Needn't select any other machine while
13 MACH_MMP_DT is enabled.
14
5config MACH_ASPENITE 15config MACH_ASPENITE
6 bool "Marvell's PXA168 Aspenite Development Board" 16 bool "Marvell's PXA168 Aspenite Development Board"
7 select CPU_PXA168 17 select CPU_PXA168
diff --git a/arch/arm/mach-mmp/Makefile b/arch/arm/mach-mmp/Makefile
index ba254a71691..4fc0ff5dc96 100644
--- a/arch/arm/mach-mmp/Makefile
+++ b/arch/arm/mach-mmp/Makefile
@@ -18,5 +18,6 @@ obj-$(CONFIG_MACH_TTC_DKB) += ttc_dkb.o
18obj-$(CONFIG_MACH_BROWNSTONE) += brownstone.o 18obj-$(CONFIG_MACH_BROWNSTONE) += brownstone.o
19obj-$(CONFIG_MACH_FLINT) += flint.o 19obj-$(CONFIG_MACH_FLINT) += flint.o
20obj-$(CONFIG_MACH_MARVELL_JASPER) += jasper.o 20obj-$(CONFIG_MACH_MARVELL_JASPER) += jasper.o
21obj-$(CONFIG_MACH_MMP_DT) += mmp-dt.o
21obj-$(CONFIG_MACH_TETON_BGA) += teton_bga.o 22obj-$(CONFIG_MACH_TETON_BGA) += teton_bga.o
22obj-$(CONFIG_MACH_GPLUGD) += gplugd.o 23obj-$(CONFIG_MACH_GPLUGD) += gplugd.o
diff --git a/arch/arm/mach-mmp/include/mach/entry-macro.S b/arch/arm/mach-mmp/include/mach/entry-macro.S
index c42d9d4e892..9cff9e7a2b2 100644
--- a/arch/arm/mach-mmp/include/mach/entry-macro.S
+++ b/arch/arm/mach-mmp/include/mach/entry-macro.S
@@ -8,12 +8,6 @@
8 8
9#include <mach/regs-icu.h> 9#include <mach/regs-icu.h>
10 10
11 .macro disable_fiq
12 .endm
13
14 .macro arch_ret_to_user, tmp1, tmp2
15 .endm
16
17 .macro get_irqnr_preamble, base, tmp 11 .macro get_irqnr_preamble, base, tmp
18 mrc p15, 0, \tmp, c0, c0, 0 @ CPUID 12 mrc p15, 0, \tmp, c0, c0, 0 @ CPUID
19 and \tmp, \tmp, #0xff00 13 and \tmp, \tmp, #0xff00
diff --git a/arch/arm/mach-mmp/include/mach/pxa910.h b/arch/arm/mach-mmp/include/mach/pxa910.h
index 4de13abef7b..e2e1f1e5e12 100644
--- a/arch/arm/mach-mmp/include/mach/pxa910.h
+++ b/arch/arm/mach-mmp/include/mach/pxa910.h
@@ -22,6 +22,7 @@ extern struct pxa_device_desc pxa910_device_pwm4;
22extern struct pxa_device_desc pxa910_device_nand; 22extern struct pxa_device_desc pxa910_device_nand;
23 23
24extern struct platform_device pxa910_device_gpio; 24extern struct platform_device pxa910_device_gpio;
25extern struct platform_device pxa910_device_rtc;
25 26
26static inline int pxa910_add_uart(int id) 27static inline int pxa910_add_uart(int id)
27{ 28{
diff --git a/arch/arm/mach-mmp/include/mach/regs-apbc.h b/arch/arm/mach-mmp/include/mach/regs-apbc.h
index 1a96585336b..8a37fb00365 100644
--- a/arch/arm/mach-mmp/include/mach/regs-apbc.h
+++ b/arch/arm/mach-mmp/include/mach/regs-apbc.h
@@ -57,6 +57,7 @@
57#define APBC_PXA910_SSP1 APBC_REG(0x01c) 57#define APBC_PXA910_SSP1 APBC_REG(0x01c)
58#define APBC_PXA910_SSP2 APBC_REG(0x020) 58#define APBC_PXA910_SSP2 APBC_REG(0x020)
59#define APBC_PXA910_IPC APBC_REG(0x024) 59#define APBC_PXA910_IPC APBC_REG(0x024)
60#define APBC_PXA910_RTC APBC_REG(0x028)
60#define APBC_PXA910_TWSI0 APBC_REG(0x02c) 61#define APBC_PXA910_TWSI0 APBC_REG(0x02c)
61#define APBC_PXA910_KPC APBC_REG(0x030) 62#define APBC_PXA910_KPC APBC_REG(0x030)
62#define APBC_PXA910_TIMERS APBC_REG(0x034) 63#define APBC_PXA910_TIMERS APBC_REG(0x034)
diff --git a/arch/arm/mach-mmp/include/mach/regs-rtc.h b/arch/arm/mach-mmp/include/mach/regs-rtc.h
new file mode 100644
index 00000000000..5bff886a394
--- /dev/null
+++ b/arch/arm/mach-mmp/include/mach/regs-rtc.h
@@ -0,0 +1,23 @@
1#ifndef __ASM_MACH_REGS_RTC_H
2#define __ASM_MACH_REGS_RTC_H
3
4#include <mach/addr-map.h>
5
6#define RTC_VIRT_BASE (APB_VIRT_BASE + 0x10000)
7#define RTC_REG(x) (*((volatile u32 __iomem *)(RTC_VIRT_BASE + (x))))
8
9/*
10 * Real Time Clock
11 */
12
13#define RCNR RTC_REG(0x00) /* RTC Count Register */
14#define RTAR RTC_REG(0x04) /* RTC Alarm Register */
15#define RTSR RTC_REG(0x08) /* RTC Status Register */
16#define RTTR RTC_REG(0x0C) /* RTC Timer Trim Register */
17
18#define RTSR_HZE (1 << 3) /* HZ interrupt enable */
19#define RTSR_ALE (1 << 2) /* RTC alarm interrupt enable */
20#define RTSR_HZ (1 << 1) /* HZ rising-edge detected */
21#define RTSR_AL (1 << 0) /* RTC alarm detected */
22
23#endif /* __ASM_MACH_REGS_RTC_H */
diff --git a/arch/arm/mach-mmp/include/mach/system.h b/arch/arm/mach-mmp/include/mach/system.h
deleted file mode 100644
index 1d001eab81e..00000000000
--- a/arch/arm/mach-mmp/include/mach/system.h
+++ /dev/null
@@ -1,16 +0,0 @@
1/*
2 * linux/arch/arm/mach-mmp/include/mach/system.h
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#ifndef __ASM_MACH_SYSTEM_H
10#define __ASM_MACH_SYSTEM_H
11
12static inline void arch_idle(void)
13{
14 cpu_do_idle();
15}
16#endif /* __ASM_MACH_SYSTEM_H */
diff --git a/arch/arm/mach-mmp/mmp-dt.c b/arch/arm/mach-mmp/mmp-dt.c
new file mode 100644
index 00000000000..67075395e40
--- /dev/null
+++ b/arch/arm/mach-mmp/mmp-dt.c
@@ -0,0 +1,75 @@
1/*
2 * linux/arch/arm/mach-mmp/mmp-dt.c
3 *
4 * Copyright (C) 2012 Marvell Technology Group Ltd.
5 * Author: Haojian Zhuang <haojian.zhuang@marvell.com>
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 * publishhed by the Free Software Foundation.
10 */
11
12#include <linux/irq.h>
13#include <linux/irqdomain.h>
14#include <linux/of_irq.h>
15#include <linux/of_platform.h>
16#include <asm/mach/arch.h>
17#include <mach/irqs.h>
18
19#include "common.h"
20
21extern struct sys_timer pxa168_timer;
22extern void __init icu_init_irq(void);
23
24static const struct of_dev_auxdata mmp_auxdata_lookup[] __initconst = {
25 OF_DEV_AUXDATA("mrvl,mmp-uart", 0xd4017000, "pxa2xx-uart.0", NULL),
26 OF_DEV_AUXDATA("mrvl,mmp-uart", 0xd4018000, "pxa2xx-uart.1", NULL),
27 OF_DEV_AUXDATA("mrvl,mmp-uart", 0xd4026000, "pxa2xx-uart.2", NULL),
28 OF_DEV_AUXDATA("mrvl,mmp-twsi", 0xd4011000, "pxa2xx-i2c.0", NULL),
29 OF_DEV_AUXDATA("mrvl,mmp-twsi", 0xd4025000, "pxa2xx-i2c.1", NULL),
30 OF_DEV_AUXDATA("mrvl,mmp-gpio", 0xd4019000, "pxa-gpio", NULL),
31 OF_DEV_AUXDATA("mrvl,mmp-rtc", 0xd4010000, "sa1100-rtc", NULL),
32 {}
33};
34
35static int __init mmp_intc_add_irq_domain(struct device_node *np,
36 struct device_node *parent)
37{
38 irq_domain_add_simple(np, 0);
39 return 0;
40}
41
42static int __init mmp_gpio_add_irq_domain(struct device_node *np,
43 struct device_node *parent)
44{
45 irq_domain_add_simple(np, IRQ_GPIO_START);
46 return 0;
47}
48
49static const struct of_device_id mmp_irq_match[] __initconst = {
50 { .compatible = "mrvl,mmp-intc", .data = mmp_intc_add_irq_domain, },
51 { .compatible = "mrvl,mmp-gpio", .data = mmp_gpio_add_irq_domain, },
52 {}
53};
54
55static void __init mmp_dt_init(void)
56{
57
58 of_irq_init(mmp_irq_match);
59
60 of_platform_populate(NULL, of_default_bus_match_table,
61 mmp_auxdata_lookup, NULL);
62}
63
64static const char *pxa168_dt_board_compat[] __initdata = {
65 "mrvl,pxa168-aspenite",
66 NULL,
67};
68
69DT_MACHINE_START(PXA168_DT, "Marvell PXA168 (Device Tree Support)")
70 .map_io = mmp_map_io,
71 .init_irq = icu_init_irq,
72 .timer = &pxa168_timer,
73 .init_machine = mmp_dt_init,
74 .dt_compat = pxa168_dt_board_compat,
75MACHINE_END
diff --git a/arch/arm/mach-mmp/mmp2.c b/arch/arm/mach-mmp/mmp2.c
index 617c60a170a..c709a24a9d2 100644
--- a/arch/arm/mach-mmp/mmp2.c
+++ b/arch/arm/mach-mmp/mmp2.c
@@ -223,6 +223,7 @@ struct resource mmp2_resource_gpio[] = {
223 }, { 223 }, {
224 .start = IRQ_MMP2_GPIO, 224 .start = IRQ_MMP2_GPIO,
225 .end = IRQ_MMP2_GPIO, 225 .end = IRQ_MMP2_GPIO,
226 .name = "gpio_mux",
226 .flags = IORESOURCE_IRQ, 227 .flags = IORESOURCE_IRQ,
227 }, 228 },
228}; 229};
diff --git a/arch/arm/mach-mmp/pxa168.c b/arch/arm/mach-mmp/pxa168.c
index 520f39dc321..b24d2c32cba 100644
--- a/arch/arm/mach-mmp/pxa168.c
+++ b/arch/arm/mach-mmp/pxa168.c
@@ -65,6 +65,7 @@ static APBC_CLK(ssp4, PXA168_SSP4, 4, 0);
65static APBC_CLK(ssp5, PXA168_SSP5, 4, 0); 65static APBC_CLK(ssp5, PXA168_SSP5, 4, 0);
66static APBC_CLK(gpio, PXA168_GPIO, 0, 13000000); 66static APBC_CLK(gpio, PXA168_GPIO, 0, 13000000);
67static APBC_CLK(keypad, PXA168_KPC, 0, 32000); 67static APBC_CLK(keypad, PXA168_KPC, 0, 32000);
68static APBC_CLK(rtc, PXA168_RTC, 8, 32768);
68 69
69static APMU_CLK(nand, NAND, 0x19b, 156000000); 70static APMU_CLK(nand, NAND, 0x19b, 156000000);
70static APMU_CLK(lcd, LCD, 0x7f, 312000000); 71static APMU_CLK(lcd, LCD, 0x7f, 312000000);
@@ -93,6 +94,7 @@ static struct clk_lookup pxa168_clkregs[] = {
93 INIT_CLKREG(&clk_keypad, "pxa27x-keypad", NULL), 94 INIT_CLKREG(&clk_keypad, "pxa27x-keypad", NULL),
94 INIT_CLKREG(&clk_eth, "pxa168-eth", "MFUCLK"), 95 INIT_CLKREG(&clk_eth, "pxa168-eth", "MFUCLK"),
95 INIT_CLKREG(&clk_usb, "pxa168-ehci", "PXA168-USBCLK"), 96 INIT_CLKREG(&clk_usb, "pxa168-ehci", "PXA168-USBCLK"),
97 INIT_CLKREG(&clk_rtc, "sa1100-rtc", NULL),
96}; 98};
97 99
98static int __init pxa168_init(void) 100static int __init pxa168_init(void)
@@ -167,6 +169,7 @@ struct resource pxa168_resource_gpio[] = {
167 }, { 169 }, {
168 .start = IRQ_PXA168_GPIOX, 170 .start = IRQ_PXA168_GPIOX,
169 .end = IRQ_PXA168_GPIOX, 171 .end = IRQ_PXA168_GPIOX,
172 .name = "gpio_mux",
170 .flags = IORESOURCE_IRQ, 173 .flags = IORESOURCE_IRQ,
171 }, 174 },
172}; 175};
diff --git a/arch/arm/mach-mmp/pxa910.c b/arch/arm/mach-mmp/pxa910.c
index 3241a25784d..43f8bcc29b6 100644
--- a/arch/arm/mach-mmp/pxa910.c
+++ b/arch/arm/mach-mmp/pxa910.c
@@ -92,6 +92,7 @@ static APBC_CLK(pwm2, PXA910_PWM2, 1, 13000000);
92static APBC_CLK(pwm3, PXA910_PWM3, 1, 13000000); 92static APBC_CLK(pwm3, PXA910_PWM3, 1, 13000000);
93static APBC_CLK(pwm4, PXA910_PWM4, 1, 13000000); 93static APBC_CLK(pwm4, PXA910_PWM4, 1, 13000000);
94static APBC_CLK(gpio, PXA910_GPIO, 0, 13000000); 94static APBC_CLK(gpio, PXA910_GPIO, 0, 13000000);
95static APBC_CLK(rtc, PXA910_RTC, 8, 32768);
95 96
96static APMU_CLK(nand, NAND, 0x19b, 156000000); 97static APMU_CLK(nand, NAND, 0x19b, 156000000);
97static APMU_CLK(u2o, USB, 0x1b, 480000000); 98static APMU_CLK(u2o, USB, 0x1b, 480000000);
@@ -109,6 +110,7 @@ static struct clk_lookup pxa910_clkregs[] = {
109 INIT_CLKREG(&clk_nand, "pxa3xx-nand", NULL), 110 INIT_CLKREG(&clk_nand, "pxa3xx-nand", NULL),
110 INIT_CLKREG(&clk_gpio, "pxa-gpio", NULL), 111 INIT_CLKREG(&clk_gpio, "pxa-gpio", NULL),
111 INIT_CLKREG(&clk_u2o, "pxa-u2o", "U2OCLK"), 112 INIT_CLKREG(&clk_u2o, "pxa-u2o", "U2OCLK"),
113 INIT_CLKREG(&clk_rtc, "sa1100-rtc", NULL),
112}; 114};
113 115
114static int __init pxa910_init(void) 116static int __init pxa910_init(void)
@@ -173,6 +175,7 @@ struct resource pxa910_resource_gpio[] = {
173 }, { 175 }, {
174 .start = IRQ_PXA910_AP_GPIO, 176 .start = IRQ_PXA910_AP_GPIO,
175 .end = IRQ_PXA910_AP_GPIO, 177 .end = IRQ_PXA910_AP_GPIO,
178 .name = "gpio_mux",
176 .flags = IORESOURCE_IRQ, 179 .flags = IORESOURCE_IRQ,
177 }, 180 },
178}; 181};
@@ -183,3 +186,28 @@ struct platform_device pxa910_device_gpio = {
183 .num_resources = ARRAY_SIZE(pxa910_resource_gpio), 186 .num_resources = ARRAY_SIZE(pxa910_resource_gpio),
184 .resource = pxa910_resource_gpio, 187 .resource = pxa910_resource_gpio,
185}; 188};
189
190static struct resource pxa910_resource_rtc[] = {
191 {
192 .start = 0xd4010000,
193 .end = 0xd401003f,
194 .flags = IORESOURCE_MEM,
195 }, {
196 .start = IRQ_PXA910_RTC_INT,
197 .end = IRQ_PXA910_RTC_INT,
198 .name = "rtc 1Hz",
199 .flags = IORESOURCE_IRQ,
200 }, {
201 .start = IRQ_PXA910_RTC_ALARM,
202 .end = IRQ_PXA910_RTC_ALARM,
203 .name = "rtc alarm",
204 .flags = IORESOURCE_IRQ,
205 },
206};
207
208struct platform_device pxa910_device_rtc = {
209 .name = "sa1100-rtc",
210 .id = -1,
211 .num_resources = ARRAY_SIZE(pxa910_resource_rtc),
212 .resource = pxa910_resource_rtc,
213};
diff --git a/arch/arm/mach-mmp/ttc_dkb.c b/arch/arm/mach-mmp/ttc_dkb.c
index 5ac5d5832e4..e72c709da44 100644
--- a/arch/arm/mach-mmp/ttc_dkb.c
+++ b/arch/arm/mach-mmp/ttc_dkb.c
@@ -124,6 +124,7 @@ static struct platform_device ttc_dkb_device_onenand = {
124 124
125static struct platform_device *ttc_dkb_devices[] = { 125static struct platform_device *ttc_dkb_devices[] = {
126 &pxa910_device_gpio, 126 &pxa910_device_gpio,
127 &pxa910_device_rtc,
127 &ttc_dkb_device_onenand, 128 &ttc_dkb_device_onenand,
128}; 129};
129 130
diff --git a/arch/arm/mach-msm/idle.S b/arch/arm/mach-msm/idle.S
deleted file mode 100644
index 6a94f052713..00000000000
--- a/arch/arm/mach-msm/idle.S
+++ /dev/null
@@ -1,36 +0,0 @@
1/* arch/arm/mach-msm/include/mach/idle.S
2 *
3 * Idle processing for MSM7K - work around bugs with SWFI.
4 *
5 * Copyright (c) 2007 QUALCOMM Incorporated.
6 * Copyright (C) 2007 Google, Inc.
7 *
8 * This software is licensed under the terms of the GNU General Public
9 * License version 2, as published by the Free Software Foundation, and
10 * may be copied, distributed, and modified under those terms.
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 */
18
19#include <linux/linkage.h>
20#include <asm/assembler.h>
21
22ENTRY(arch_idle)
23#ifdef CONFIG_MSM7X00A_IDLE
24 mrc p15, 0, r1, c1, c0, 0 /* read current CR */
25 bic r0, r1, #(1 << 2) /* clear dcache bit */
26 bic r0, r0, #(1 << 12) /* clear icache bit */
27 mcr p15, 0, r0, c1, c0, 0 /* disable d/i cache */
28
29 mov r0, #0 /* prepare wfi value */
30 mcr p15, 0, r0, c7, c10, 0 /* flush the cache */
31 mcr p15, 0, r0, c7, c10, 4 /* memory barrier */
32 mcr p15, 0, r0, c7, c0, 4 /* wait for interrupt */
33
34 mcr p15, 0, r1, c1, c0, 0 /* restore d/i cache */
35#endif
36 mov pc, lr
diff --git a/arch/arm/mach-msm/idle.c b/arch/arm/mach-msm/idle.c
new file mode 100644
index 00000000000..0c9e13c6574
--- /dev/null
+++ b/arch/arm/mach-msm/idle.c
@@ -0,0 +1,49 @@
1/* arch/arm/mach-msm/idle.c
2 *
3 * Idle processing for MSM7K - work around bugs with SWFI.
4 *
5 * Copyright (c) 2007 QUALCOMM Incorporated.
6 * Copyright (C) 2007 Google, Inc.
7 *
8 * This software is licensed under the terms of the GNU General Public
9 * License version 2, as published by the Free Software Foundation, and
10 * may be copied, distributed, and modified under those terms.
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 */
18
19#include <linux/init.h>
20#include <asm/system.h>
21
22static void msm_idle(void)
23{
24#ifdef CONFIG_MSM7X00A_IDLE
25 asm volatile (
26
27 "mrc p15, 0, r1, c1, c0, 0 /* read current CR */ \n\t"
28 "bic r0, r1, #(1 << 2) /* clear dcache bit */ \n\t"
29 "bic r0, r0, #(1 << 12) /* clear icache bit */ \n\t"
30 "mcr p15, 0, r0, c1, c0, 0 /* disable d/i cache */ \n\t"
31
32 "mov r0, #0 /* prepare wfi value */ \n\t"
33 "mcr p15, 0, r0, c7, c10, 0 /* flush the cache */ \n\t"
34 "mcr p15, 0, r0, c7, c10, 4 /* memory barrier */ \n\t"
35 "mcr p15, 0, r0, c7, c0, 4 /* wait for interrupt */ \n\t"
36
37 "mcr p15, 0, r1, c1, c0, 0 /* restore d/i cache */ \n\t"
38
39 : : : "r0","r1" );
40#endif
41}
42
43static int __init msm_idle_init(void)
44{
45 arm_pm_idle = msm_idle;
46 return 0;
47}
48
49arch_initcall(msm_idle_init);
diff --git a/arch/arm/mach-msm/include/mach/entry-macro.S b/arch/arm/mach-msm/include/mach/entry-macro.S
index 41f7003ef34..f2ae9087f65 100644
--- a/arch/arm/mach-msm/include/mach/entry-macro.S
+++ b/arch/arm/mach-msm/include/mach/entry-macro.S
@@ -16,12 +16,6 @@
16 * 16 *
17 */ 17 */
18 18
19 .macro disable_fiq
20 .endm
21
22 .macro arch_ret_to_user, tmp1, tmp2
23 .endm
24
25#if !defined(CONFIG_ARM_GIC) 19#if !defined(CONFIG_ARM_GIC)
26#include <mach/msm_iomap.h> 20#include <mach/msm_iomap.h>
27 21
diff --git a/arch/arm/mach-msm/include/mach/system.h b/arch/arm/mach-msm/include/mach/system.h
index 311db2b35da..f5fb2ec87ff 100644
--- a/arch/arm/mach-msm/include/mach/system.h
+++ b/arch/arm/mach-msm/include/mach/system.h
@@ -12,7 +12,6 @@
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 */ 14 */
15void arch_idle(void);
16 15
17/* low level hardware reset hook -- for example, hitting the 16/* low level hardware reset hook -- for example, hitting the
18 * PSHOLD line on the PMIC to hard reset the system 17 * PSHOLD line on the PMIC to hard reset the system
diff --git a/arch/arm/mach-msm/timer.c b/arch/arm/mach-msm/timer.c
index 11d0d8f2656..75f4be40b3e 100644
--- a/arch/arm/mach-msm/timer.c
+++ b/arch/arm/mach-msm/timer.c
@@ -127,6 +127,45 @@ static struct clocksource msm_clocksource = {
127 .flags = CLOCK_SOURCE_IS_CONTINUOUS, 127 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
128}; 128};
129 129
130#ifdef CONFIG_LOCAL_TIMERS
131static int __cpuinit msm_local_timer_setup(struct clock_event_device *evt)
132{
133 /* Use existing clock_event for cpu 0 */
134 if (!smp_processor_id())
135 return 0;
136
137 writel_relaxed(0, event_base + TIMER_ENABLE);
138 writel_relaxed(0, event_base + TIMER_CLEAR);
139 writel_relaxed(~0, event_base + TIMER_MATCH_VAL);
140 evt->irq = msm_clockevent.irq;
141 evt->name = "local_timer";
142 evt->features = msm_clockevent.features;
143 evt->rating = msm_clockevent.rating;
144 evt->set_mode = msm_timer_set_mode;
145 evt->set_next_event = msm_timer_set_next_event;
146 evt->shift = msm_clockevent.shift;
147 evt->mult = div_sc(GPT_HZ, NSEC_PER_SEC, evt->shift);
148 evt->max_delta_ns = clockevent_delta2ns(0xf0000000, evt);
149 evt->min_delta_ns = clockevent_delta2ns(4, evt);
150
151 *__this_cpu_ptr(msm_evt.percpu_evt) = evt;
152 clockevents_register_device(evt);
153 enable_percpu_irq(evt->irq, 0);
154 return 0;
155}
156
157static void msm_local_timer_stop(struct clock_event_device *evt)
158{
159 evt->set_mode(CLOCK_EVT_MODE_UNUSED, evt);
160 disable_percpu_irq(evt->irq);
161}
162
163static struct local_timer_ops msm_local_timer_ops __cpuinitdata = {
164 .setup = msm_local_timer_setup,
165 .stop = msm_local_timer_stop,
166};
167#endif /* CONFIG_LOCAL_TIMERS */
168
130static void __init msm_timer_init(void) 169static void __init msm_timer_init(void)
131{ 170{
132 struct clock_event_device *ce = &msm_clockevent; 171 struct clock_event_device *ce = &msm_clockevent;
@@ -173,8 +212,12 @@ static void __init msm_timer_init(void)
173 *__this_cpu_ptr(msm_evt.percpu_evt) = ce; 212 *__this_cpu_ptr(msm_evt.percpu_evt) = ce;
174 res = request_percpu_irq(ce->irq, msm_timer_interrupt, 213 res = request_percpu_irq(ce->irq, msm_timer_interrupt,
175 ce->name, msm_evt.percpu_evt); 214 ce->name, msm_evt.percpu_evt);
176 if (!res) 215 if (!res) {
177 enable_percpu_irq(ce->irq, 0); 216 enable_percpu_irq(ce->irq, 0);
217#ifdef CONFIG_LOCAL_TIMERS
218 local_timer_register(&msm_local_timer_ops);
219#endif
220 }
178 } else { 221 } else {
179 msm_evt.evt = ce; 222 msm_evt.evt = ce;
180 res = request_irq(ce->irq, msm_timer_interrupt, 223 res = request_irq(ce->irq, msm_timer_interrupt,
@@ -191,40 +234,6 @@ err:
191 pr_err("clocksource_register failed\n"); 234 pr_err("clocksource_register failed\n");
192} 235}
193 236
194#ifdef CONFIG_LOCAL_TIMERS
195int __cpuinit local_timer_setup(struct clock_event_device *evt)
196{
197 /* Use existing clock_event for cpu 0 */
198 if (!smp_processor_id())
199 return 0;
200
201 writel_relaxed(0, event_base + TIMER_ENABLE);
202 writel_relaxed(0, event_base + TIMER_CLEAR);
203 writel_relaxed(~0, event_base + TIMER_MATCH_VAL);
204 evt->irq = msm_clockevent.irq;
205 evt->name = "local_timer";
206 evt->features = msm_clockevent.features;
207 evt->rating = msm_clockevent.rating;
208 evt->set_mode = msm_timer_set_mode;
209 evt->set_next_event = msm_timer_set_next_event;
210 evt->shift = msm_clockevent.shift;
211 evt->mult = div_sc(GPT_HZ, NSEC_PER_SEC, evt->shift);
212 evt->max_delta_ns = clockevent_delta2ns(0xf0000000, evt);
213 evt->min_delta_ns = clockevent_delta2ns(4, evt);
214
215 *__this_cpu_ptr(msm_evt.percpu_evt) = evt;
216 clockevents_register_device(evt);
217 enable_percpu_irq(evt->irq, 0);
218 return 0;
219}
220
221void local_timer_stop(struct clock_event_device *evt)
222{
223 evt->set_mode(CLOCK_EVT_MODE_UNUSED, evt);
224 disable_percpu_irq(evt->irq);
225}
226#endif /* CONFIG_LOCAL_TIMERS */
227
228struct sys_timer msm_timer = { 237struct sys_timer msm_timer = {
229 .init = msm_timer_init 238 .init = msm_timer_init
230}; 239};
diff --git a/arch/arm/mach-mv78xx0/include/mach/entry-macro.S b/arch/arm/mach-mv78xx0/include/mach/entry-macro.S
index 66ae2d29e77..6b1f088e059 100644
--- a/arch/arm/mach-mv78xx0/include/mach/entry-macro.S
+++ b/arch/arm/mach-mv78xx0/include/mach/entry-macro.S
@@ -10,12 +10,6 @@
10 10
11#include <mach/bridge-regs.h> 11#include <mach/bridge-regs.h>
12 12
13 .macro disable_fiq
14 .endm
15
16 .macro arch_ret_to_user, tmp1, tmp2
17 .endm
18
19 .macro get_irqnr_preamble, base, tmp 13 .macro get_irqnr_preamble, base, tmp
20 ldr \base, =IRQ_VIRT_BASE 14 ldr \base, =IRQ_VIRT_BASE
21 .endm 15 .endm
diff --git a/arch/arm/mach-mv78xx0/include/mach/system.h b/arch/arm/mach-mv78xx0/include/mach/system.h
deleted file mode 100644
index 8c3a5387cec..00000000000
--- a/arch/arm/mach-mv78xx0/include/mach/system.h
+++ /dev/null
@@ -1,17 +0,0 @@
1/*
2 * arch/arm/mach-mv78xx0/include/mach/system.h
3 *
4 * This file is licensed under the terms of the GNU General Public
5 * License version 2. This program is licensed "as is" without any
6 * warranty of any kind, whether express or implied.
7 */
8
9#ifndef __ASM_ARCH_SYSTEM_H
10#define __ASM_ARCH_SYSTEM_H
11
12static inline void arch_idle(void)
13{
14 cpu_do_idle();
15}
16
17#endif
diff --git a/arch/arm/mach-mv78xx0/pcie.c b/arch/arm/mach-mv78xx0/pcie.c
index 8459f6d7d8c..df3e38055a2 100644
--- a/arch/arm/mach-mv78xx0/pcie.c
+++ b/arch/arm/mach-mv78xx0/pcie.c
@@ -155,8 +155,8 @@ static int __init mv78xx0_pcie_setup(int nr, struct pci_sys_data *sys)
155 orion_pcie_set_local_bus_nr(pp->base, sys->busnr); 155 orion_pcie_set_local_bus_nr(pp->base, sys->busnr);
156 orion_pcie_setup(pp->base); 156 orion_pcie_setup(pp->base);
157 157
158 pci_add_resource(&sys->resources, &pp->res[0]); 158 pci_add_resource_offset(&sys->resources, &pp->res[0], sys->io_offset);
159 pci_add_resource(&sys->resources, &pp->res[1]); 159 pci_add_resource_offset(&sys->resources, &pp->res[1], sys->mem_offset);
160 160
161 return 1; 161 return 1;
162} 162}
diff --git a/arch/arm/mach-mxs/Kconfig b/arch/arm/mach-mxs/Kconfig
index cf00b3e3be8..c57f9964a71 100644
--- a/arch/arm/mach-mxs/Kconfig
+++ b/arch/arm/mach-mxs/Kconfig
@@ -83,6 +83,18 @@ config MODULE_M28
83 select MXS_HAVE_PLATFORM_MXSFB 83 select MXS_HAVE_PLATFORM_MXSFB
84 select MXS_OCOTP 84 select MXS_OCOTP
85 85
86config MODULE_APX4
87 bool
88 select SOC_IMX28
89 select LEDS_GPIO_REGISTER
90 select MXS_HAVE_AMBA_DUART
91 select MXS_HAVE_PLATFORM_AUART
92 select MXS_HAVE_PLATFORM_FEC
93 select MXS_HAVE_PLATFORM_MXS_I2C
94 select MXS_HAVE_PLATFORM_MXS_MMC
95 select MXS_HAVE_PLATFORM_MXS_SAIF
96 select MXS_OCOTP
97
86config MACH_TX28 98config MACH_TX28
87 bool "Ka-Ro TX28 module" 99 bool "Ka-Ro TX28 module"
88 select MODULE_TX28 100 select MODULE_TX28
@@ -91,4 +103,8 @@ config MACH_M28EVK
91 bool "Support DENX M28EVK Platform" 103 bool "Support DENX M28EVK Platform"
92 select MODULE_M28 104 select MODULE_M28
93 105
106config MACH_APX4DEVKIT
107 bool "Support Bluegiga APX4 Development Kit"
108 select MODULE_APX4
109
94endif 110endif
diff --git a/arch/arm/mach-mxs/Makefile b/arch/arm/mach-mxs/Makefile
index 8c93b24896b..908bf9a567f 100644
--- a/arch/arm/mach-mxs/Makefile
+++ b/arch/arm/mach-mxs/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_MACH_STMP378X_DEVB) += mach-stmp378x_devb.o
11obj-$(CONFIG_MACH_MX23EVK) += mach-mx23evk.o 11obj-$(CONFIG_MACH_MX23EVK) += mach-mx23evk.o
12obj-$(CONFIG_MACH_MX28EVK) += mach-mx28evk.o 12obj-$(CONFIG_MACH_MX28EVK) += mach-mx28evk.o
13obj-$(CONFIG_MACH_M28EVK) += mach-m28evk.o 13obj-$(CONFIG_MACH_M28EVK) += mach-m28evk.o
14obj-$(CONFIG_MACH_APX4DEVKIT) += mach-apx4devkit.o
14obj-$(CONFIG_MODULE_TX28) += module-tx28.o 15obj-$(CONFIG_MODULE_TX28) += module-tx28.o
15obj-$(CONFIG_MACH_TX28) += mach-tx28.o 16obj-$(CONFIG_MACH_TX28) += mach-tx28.o
16 17
diff --git a/arch/arm/mach-mxs/clock-mx23.c b/arch/arm/mach-mxs/clock-mx23.c
index e12e11231dc..e3ac52c3401 100644
--- a/arch/arm/mach-mxs/clock-mx23.c
+++ b/arch/arm/mach-mxs/clock-mx23.c
@@ -223,7 +223,6 @@ static int cpu_clk_set_rate(struct clk *clk, unsigned long rate)
223{ 223{
224 u32 reg, bm_busy, div_max, d, f, div, frac; 224 u32 reg, bm_busy, div_max, d, f, div, frac;
225 unsigned long diff, parent_rate, calc_rate; 225 unsigned long diff, parent_rate, calc_rate;
226 int i;
227 226
228 parent_rate = clk_get_rate(clk->parent); 227 parent_rate = clk_get_rate(clk->parent);
229 228
@@ -275,14 +274,7 @@ static int cpu_clk_set_rate(struct clk *clk, unsigned long rate)
275 reg |= div << BP_CLKCTRL_CPU_DIV_CPU; 274 reg |= div << BP_CLKCTRL_CPU_DIV_CPU;
276 __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_CPU); 275 __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_CPU);
277 276
278 for (i = 10000; i; i--) 277 mxs_clkctrl_timeout(HW_CLKCTRL_CPU, bm_busy);
279 if (!(__raw_readl(CLKCTRL_BASE_ADDR +
280 HW_CLKCTRL_CPU) & bm_busy))
281 break;
282 if (!i) {
283 pr_err("%s: divider writing timeout\n", __func__);
284 return -ETIMEDOUT;
285 }
286 278
287 return 0; 279 return 0;
288} 280}
@@ -292,7 +284,6 @@ static int name##_set_rate(struct clk *clk, unsigned long rate) \
292{ \ 284{ \
293 u32 reg, div_max, div; \ 285 u32 reg, div_max, div; \
294 unsigned long parent_rate; \ 286 unsigned long parent_rate; \
295 int i; \
296 \ 287 \
297 parent_rate = clk_get_rate(clk->parent); \ 288 parent_rate = clk_get_rate(clk->parent); \
298 div_max = BM_CLKCTRL_##dr##_DIV >> BP_CLKCTRL_##dr##_DIV; \ 289 div_max = BM_CLKCTRL_##dr##_DIV >> BP_CLKCTRL_##dr##_DIV; \
@@ -310,15 +301,7 @@ static int name##_set_rate(struct clk *clk, unsigned long rate) \
310 } \ 301 } \
311 __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_##dr); \ 302 __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_##dr); \
312 \ 303 \
313 for (i = 10000; i; i--) \ 304 mxs_clkctrl_timeout(HW_CLKCTRL_##dr, BM_CLKCTRL_##dr##_BUSY); \
314 if (!(__raw_readl(CLKCTRL_BASE_ADDR + \
315 HW_CLKCTRL_##dr) & BM_CLKCTRL_##dr##_BUSY)) \
316 break; \
317 if (!i) { \
318 pr_err("%s: divider writing timeout\n", __func__); \
319 return -ETIMEDOUT; \
320 } \
321 \
322 return 0; \ 305 return 0; \
323} 306}
324 307
@@ -456,12 +439,13 @@ static struct clk_lookup lookups[] = {
456 _REGISTER_CLOCK("mxs-pwm.3", NULL, pwm_clk) 439 _REGISTER_CLOCK("mxs-pwm.3", NULL, pwm_clk)
457 _REGISTER_CLOCK("mxs-pwm.4", NULL, pwm_clk) 440 _REGISTER_CLOCK("mxs-pwm.4", NULL, pwm_clk)
458 _REGISTER_CLOCK("imx23-fb", NULL, lcdif_clk) 441 _REGISTER_CLOCK("imx23-fb", NULL, lcdif_clk)
442 _REGISTER_CLOCK("imx23-gpmi-nand", NULL, gpmi_clk)
459}; 443};
460 444
461static int clk_misc_init(void) 445static int clk_misc_init(void)
462{ 446{
463 u32 reg; 447 u32 reg;
464 int i; 448 int ret;
465 449
466 /* Fix up parent per register setting */ 450 /* Fix up parent per register setting */
467 reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_CLKSEQ); 451 reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_CLKSEQ);
@@ -510,14 +494,7 @@ static int clk_misc_init(void)
510 reg |= 3 << BP_CLKCTRL_HBUS_DIV; 494 reg |= 3 << BP_CLKCTRL_HBUS_DIV;
511 __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_HBUS); 495 __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_HBUS);
512 496
513 for (i = 10000; i; i--) 497 ret = mxs_clkctrl_timeout(HW_CLKCTRL_HBUS, BM_CLKCTRL_HBUS_BUSY);
514 if (!(__raw_readl(CLKCTRL_BASE_ADDR +
515 HW_CLKCTRL_HBUS) & BM_CLKCTRL_HBUS_BUSY))
516 break;
517 if (!i) {
518 pr_err("%s: divider writing timeout\n", __func__);
519 return -ETIMEDOUT;
520 }
521 498
522 /* Gate off cpu clock in WFI for power saving */ 499 /* Gate off cpu clock in WFI for power saving */
523 __raw_writel(BM_CLKCTRL_CPU_INTERRUPT_WAIT, 500 __raw_writel(BM_CLKCTRL_CPU_INTERRUPT_WAIT,
@@ -532,7 +509,7 @@ static int clk_misc_init(void)
532 reg |= 30 << BP_CLKCTRL_FRAC_IOFRAC; 509 reg |= 30 << BP_CLKCTRL_FRAC_IOFRAC;
533 __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_FRAC); 510 __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_FRAC);
534 511
535 return 0; 512 return ret;
536} 513}
537 514
538int __init mx23_clocks_init(void) 515int __init mx23_clocks_init(void)
diff --git a/arch/arm/mach-mxs/clock-mx28.c b/arch/arm/mach-mxs/clock-mx28.c
index 5d68e415222..cea29c99e21 100644
--- a/arch/arm/mach-mxs/clock-mx28.c
+++ b/arch/arm/mach-mxs/clock-mx28.c
@@ -322,7 +322,6 @@ static int name##_set_rate(struct clk *clk, unsigned long rate) \
322{ \ 322{ \
323 u32 reg, bm_busy, div_max, d, f, div, frac; \ 323 u32 reg, bm_busy, div_max, d, f, div, frac; \
324 unsigned long diff, parent_rate, calc_rate; \ 324 unsigned long diff, parent_rate, calc_rate; \
325 int i; \
326 \ 325 \
327 div_max = BM_CLKCTRL_##dr##_DIV >> BP_CLKCTRL_##dr##_DIV; \ 326 div_max = BM_CLKCTRL_##dr##_DIV >> BP_CLKCTRL_##dr##_DIV; \
328 bm_busy = BM_CLKCTRL_##dr##_BUSY; \ 327 bm_busy = BM_CLKCTRL_##dr##_BUSY; \
@@ -396,16 +395,7 @@ static int name##_set_rate(struct clk *clk, unsigned long rate) \
396 } \ 395 } \
397 __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_##dr); \ 396 __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_##dr); \
398 \ 397 \
399 for (i = 10000; i; i--) \ 398 return mxs_clkctrl_timeout(HW_CLKCTRL_##dr, bm_busy); \
400 if (!(__raw_readl(CLKCTRL_BASE_ADDR + \
401 HW_CLKCTRL_##dr) & bm_busy)) \
402 break; \
403 if (!i) { \
404 pr_err("%s: divider writing timeout\n", __func__); \
405 return -ETIMEDOUT; \
406 } \
407 \
408 return 0; \
409} 399}
410 400
411_CLK_SET_RATE(cpu_clk, CPU, FRAC0, CPU) 401_CLK_SET_RATE(cpu_clk, CPU, FRAC0, CPU)
@@ -421,7 +411,6 @@ static int name##_set_rate(struct clk *clk, unsigned long rate) \
421{ \ 411{ \
422 u32 reg, div_max, div; \ 412 u32 reg, div_max, div; \
423 unsigned long parent_rate; \ 413 unsigned long parent_rate; \
424 int i; \
425 \ 414 \
426 parent_rate = clk_get_rate(clk->parent); \ 415 parent_rate = clk_get_rate(clk->parent); \
427 div_max = BM_CLKCTRL_##dr##_DIV >> BP_CLKCTRL_##dr##_DIV; \ 416 div_max = BM_CLKCTRL_##dr##_DIV >> BP_CLKCTRL_##dr##_DIV; \
@@ -439,16 +428,7 @@ static int name##_set_rate(struct clk *clk, unsigned long rate) \
439 } \ 428 } \
440 __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_##dr); \ 429 __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_##dr); \
441 \ 430 \
442 for (i = 10000; i; i--) \ 431 return mxs_clkctrl_timeout(HW_CLKCTRL_##dr, BM_CLKCTRL_##dr##_BUSY);\
443 if (!(__raw_readl(CLKCTRL_BASE_ADDR + \
444 HW_CLKCTRL_##dr) & BM_CLKCTRL_##dr##_BUSY)) \
445 break; \
446 if (!i) { \
447 pr_err("%s: divider writing timeout\n", __func__); \
448 return -ETIMEDOUT; \
449 } \
450 \
451 return 0; \
452} 432}
453 433
454_CLK_SET_RATE1(xbus_clk, XBUS) 434_CLK_SET_RATE1(xbus_clk, XBUS)
@@ -461,7 +441,6 @@ static int name##_set_rate(struct clk *clk, unsigned long rate) \
461 u32 reg; \ 441 u32 reg; \
462 u64 lrate; \ 442 u64 lrate; \
463 unsigned long parent_rate; \ 443 unsigned long parent_rate; \
464 int i; \
465 \ 444 \
466 parent_rate = clk_get_rate(clk->parent); \ 445 parent_rate = clk_get_rate(clk->parent); \
467 if (rate > parent_rate) \ 446 if (rate > parent_rate) \
@@ -477,18 +456,13 @@ static int name##_set_rate(struct clk *clk, unsigned long rate) \
477 reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##rs); \ 456 reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_##rs); \
478 reg &= ~BM_CLKCTRL_##rs##_DIV; \ 457 reg &= ~BM_CLKCTRL_##rs##_DIV; \
479 reg |= div << BP_CLKCTRL_##rs##_DIV; \ 458 reg |= div << BP_CLKCTRL_##rs##_DIV; \
480 __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_##rs); \ 459 if (reg & (1 << clk->enable_shift)) { \
481 \ 460 pr_err("%s: clock is gated\n", __func__); \
482 for (i = 10000; i; i--) \ 461 return -EINVAL; \
483 if (!(__raw_readl(CLKCTRL_BASE_ADDR + \
484 HW_CLKCTRL_##rs) & BM_CLKCTRL_##rs##_BUSY)) \
485 break; \
486 if (!i) { \
487 pr_err("%s: divider writing timeout\n", __func__); \
488 return -ETIMEDOUT; \
489 } \ 462 } \
463 __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_##rs); \
490 \ 464 \
491 return 0; \ 465 return mxs_clkctrl_timeout(HW_CLKCTRL_##rs, BM_CLKCTRL_##rs##_BUSY);\
492} 466}
493 467
494_CLK_SET_RATE_SAIF(saif0_clk, SAIF0) 468_CLK_SET_RATE_SAIF(saif0_clk, SAIF0)
@@ -643,6 +617,7 @@ static struct clk_lookup lookups[] = {
643 _REGISTER_CLOCK("duart", NULL, uart_clk) 617 _REGISTER_CLOCK("duart", NULL, uart_clk)
644 _REGISTER_CLOCK("imx28-fec.0", NULL, fec_clk) 618 _REGISTER_CLOCK("imx28-fec.0", NULL, fec_clk)
645 _REGISTER_CLOCK("imx28-fec.1", NULL, fec_clk) 619 _REGISTER_CLOCK("imx28-fec.1", NULL, fec_clk)
620 _REGISTER_CLOCK("imx28-gpmi-nand", NULL, gpmi_clk)
646 _REGISTER_CLOCK("mxs-auart.0", NULL, uart_clk) 621 _REGISTER_CLOCK("mxs-auart.0", NULL, uart_clk)
647 _REGISTER_CLOCK("mxs-auart.1", NULL, uart_clk) 622 _REGISTER_CLOCK("mxs-auart.1", NULL, uart_clk)
648 _REGISTER_CLOCK("mxs-auart.2", NULL, uart_clk) 623 _REGISTER_CLOCK("mxs-auart.2", NULL, uart_clk)
@@ -654,6 +629,8 @@ static struct clk_lookup lookups[] = {
654 _REGISTER_CLOCK("mxs-dma-apbx", NULL, xbus_clk) 629 _REGISTER_CLOCK("mxs-dma-apbx", NULL, xbus_clk)
655 _REGISTER_CLOCK("mxs-mmc.0", NULL, ssp0_clk) 630 _REGISTER_CLOCK("mxs-mmc.0", NULL, ssp0_clk)
656 _REGISTER_CLOCK("mxs-mmc.1", NULL, ssp1_clk) 631 _REGISTER_CLOCK("mxs-mmc.1", NULL, ssp1_clk)
632 _REGISTER_CLOCK("mxs-mmc.2", NULL, ssp2_clk)
633 _REGISTER_CLOCK("mxs-mmc.3", NULL, ssp3_clk)
657 _REGISTER_CLOCK("flexcan.0", NULL, can0_clk) 634 _REGISTER_CLOCK("flexcan.0", NULL, can0_clk)
658 _REGISTER_CLOCK("flexcan.1", NULL, can1_clk) 635 _REGISTER_CLOCK("flexcan.1", NULL, can1_clk)
659 _REGISTER_CLOCK(NULL, "usb0", usb0_clk) 636 _REGISTER_CLOCK(NULL, "usb0", usb0_clk)
@@ -676,7 +653,7 @@ static struct clk_lookup lookups[] = {
676static int clk_misc_init(void) 653static int clk_misc_init(void)
677{ 654{
678 u32 reg; 655 u32 reg;
679 int i; 656 int ret;
680 657
681 /* Fix up parent per register setting */ 658 /* Fix up parent per register setting */
682 reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_CLKSEQ); 659 reg = __raw_readl(CLKCTRL_BASE_ADDR + HW_CLKCTRL_CLKSEQ);
@@ -756,14 +733,7 @@ static int clk_misc_init(void)
756 reg |= 3 << BP_CLKCTRL_HBUS_DIV; 733 reg |= 3 << BP_CLKCTRL_HBUS_DIV;
757 __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_HBUS); 734 __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_HBUS);
758 735
759 for (i = 10000; i; i--) 736 ret = mxs_clkctrl_timeout(HW_CLKCTRL_HBUS, BM_CLKCTRL_HBUS_ASM_BUSY);
760 if (!(__raw_readl(CLKCTRL_BASE_ADDR +
761 HW_CLKCTRL_HBUS) & BM_CLKCTRL_HBUS_ASM_BUSY))
762 break;
763 if (!i) {
764 pr_err("%s: divider writing timeout\n", __func__);
765 return -ETIMEDOUT;
766 }
767 737
768 /* Gate off cpu clock in WFI for power saving */ 738 /* Gate off cpu clock in WFI for power saving */
769 __raw_writel(BM_CLKCTRL_CPU_INTERRUPT_WAIT, 739 __raw_writel(BM_CLKCTRL_CPU_INTERRUPT_WAIT,
@@ -790,7 +760,7 @@ static int clk_misc_init(void)
790 reg |= 30 << BP_CLKCTRL_FRAC0_IO0FRAC; 760 reg |= 30 << BP_CLKCTRL_FRAC0_IO0FRAC;
791 __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_FRAC0); 761 __raw_writel(reg, CLKCTRL_BASE_ADDR + HW_CLKCTRL_FRAC0);
792 762
793 return 0; 763 return ret;
794} 764}
795 765
796int __init mx28_clocks_init(void) 766int __init mx28_clocks_init(void)
@@ -803,6 +773,8 @@ int __init mx28_clocks_init(void)
803 */ 773 */
804 clk_set_parent(&ssp0_clk, &ref_io0_clk); 774 clk_set_parent(&ssp0_clk, &ref_io0_clk);
805 clk_set_parent(&ssp1_clk, &ref_io0_clk); 775 clk_set_parent(&ssp1_clk, &ref_io0_clk);
776 clk_set_parent(&ssp2_clk, &ref_io1_clk);
777 clk_set_parent(&ssp3_clk, &ref_io1_clk);
806 778
807 clk_prepare_enable(&cpu_clk); 779 clk_prepare_enable(&cpu_clk);
808 clk_prepare_enable(&hbus_clk); 780 clk_prepare_enable(&hbus_clk);
diff --git a/arch/arm/mach-mxs/devices-mx23.h b/arch/arm/mach-mxs/devices-mx23.h
index 3fa651d2c99..4d1329d5928 100644
--- a/arch/arm/mach-mxs/devices-mx23.h
+++ b/arch/arm/mach-mxs/devices-mx23.h
@@ -21,6 +21,10 @@ extern const struct mxs_auart_data mx23_auart_data[] __initconst;
21#define mx23_add_auart0() mx23_add_auart(0) 21#define mx23_add_auart0() mx23_add_auart(0)
22#define mx23_add_auart1() mx23_add_auart(1) 22#define mx23_add_auart1() mx23_add_auart(1)
23 23
24extern const struct mxs_gpmi_nand_data mx23_gpmi_nand_data __initconst;
25#define mx23_add_gpmi_nand(pdata) \
26 mxs_add_gpmi_nand(pdata, &mx23_gpmi_nand_data)
27
24extern const struct mxs_mxs_mmc_data mx23_mxs_mmc_data[] __initconst; 28extern const struct mxs_mxs_mmc_data mx23_mxs_mmc_data[] __initconst;
25#define mx23_add_mxs_mmc(id, pdata) \ 29#define mx23_add_mxs_mmc(id, pdata) \
26 mxs_add_mxs_mmc(&mx23_mxs_mmc_data[id], pdata) 30 mxs_add_mxs_mmc(&mx23_mxs_mmc_data[id], pdata)
diff --git a/arch/arm/mach-mxs/devices-mx28.h b/arch/arm/mach-mxs/devices-mx28.h
index 4f50094e293..9dbeae13084 100644
--- a/arch/arm/mach-mxs/devices-mx28.h
+++ b/arch/arm/mach-mxs/devices-mx28.h
@@ -34,6 +34,10 @@ extern const struct mxs_flexcan_data mx28_flexcan_data[] __initconst;
34#define mx28_add_flexcan0(pdata) mx28_add_flexcan(0, pdata) 34#define mx28_add_flexcan0(pdata) mx28_add_flexcan(0, pdata)
35#define mx28_add_flexcan1(pdata) mx28_add_flexcan(1, pdata) 35#define mx28_add_flexcan1(pdata) mx28_add_flexcan(1, pdata)
36 36
37extern const struct mxs_gpmi_nand_data mx28_gpmi_nand_data __initconst;
38#define mx28_add_gpmi_nand(pdata) \
39 mxs_add_gpmi_nand(pdata, &mx28_gpmi_nand_data)
40
37extern const struct mxs_mxs_i2c_data mx28_mxs_i2c_data[] __initconst; 41extern const struct mxs_mxs_i2c_data mx28_mxs_i2c_data[] __initconst;
38#define mx28_add_mxs_i2c(id) mxs_add_mxs_i2c(&mx28_mxs_i2c_data[id]) 42#define mx28_add_mxs_i2c(id) mxs_add_mxs_i2c(&mx28_mxs_i2c_data[id])
39 43
diff --git a/arch/arm/mach-mxs/devices.c b/arch/arm/mach-mxs/devices.c
index fe3e847930c..01faffec306 100644
--- a/arch/arm/mach-mxs/devices.c
+++ b/arch/arm/mach-mxs/devices.c
@@ -77,16 +77,18 @@ err:
77 77
78int __init mxs_add_amba_device(const struct amba_device *dev) 78int __init mxs_add_amba_device(const struct amba_device *dev)
79{ 79{
80 struct amba_device *adev = kmalloc(sizeof(*adev), GFP_KERNEL); 80 struct amba_device *adev = amba_device_alloc(dev->dev.init_name,
81 dev->res.start, resource_size(&dev->res));
81 82
82 if (!adev) { 83 if (!adev) {
83 pr_err("%s: failed to allocate memory", __func__); 84 pr_err("%s: failed to allocate memory", __func__);
84 return -ENOMEM; 85 return -ENOMEM;
85 } 86 }
86 87
87 *adev = *dev; 88 adev->irq[0] = dev->irq[0];
89 adev->irq[1] = dev->irq[1];
88 90
89 return amba_device_register(adev, &iomem_resource); 91 return amba_device_add(adev, &iomem_resource);
90} 92}
91 93
92struct device mxs_apbh_bus = { 94struct device mxs_apbh_bus = {
diff --git a/arch/arm/mach-mxs/devices/Kconfig b/arch/arm/mach-mxs/devices/Kconfig
index 18b6bf526a2..b8913df4cfa 100644
--- a/arch/arm/mach-mxs/devices/Kconfig
+++ b/arch/arm/mach-mxs/devices/Kconfig
@@ -12,6 +12,9 @@ config MXS_HAVE_PLATFORM_FLEXCAN
12 select HAVE_CAN_FLEXCAN if CAN 12 select HAVE_CAN_FLEXCAN if CAN
13 bool 13 bool
14 14
15config MXS_HAVE_PLATFORM_GPMI_NAND
16 bool
17
15config MXS_HAVE_PLATFORM_MXS_I2C 18config MXS_HAVE_PLATFORM_MXS_I2C
16 bool 19 bool
17 20
diff --git a/arch/arm/mach-mxs/devices/Makefile b/arch/arm/mach-mxs/devices/Makefile
index f52e3e53bae..c8f5c9541a3 100644
--- a/arch/arm/mach-mxs/devices/Makefile
+++ b/arch/arm/mach-mxs/devices/Makefile
@@ -3,6 +3,7 @@ obj-$(CONFIG_MXS_HAVE_PLATFORM_AUART) += platform-auart.o
3obj-y += platform-dma.o 3obj-y += platform-dma.o
4obj-$(CONFIG_MXS_HAVE_PLATFORM_FEC) += platform-fec.o 4obj-$(CONFIG_MXS_HAVE_PLATFORM_FEC) += platform-fec.o
5obj-$(CONFIG_MXS_HAVE_PLATFORM_FLEXCAN) += platform-flexcan.o 5obj-$(CONFIG_MXS_HAVE_PLATFORM_FLEXCAN) += platform-flexcan.o
6obj-$(CONFIG_MXS_HAVE_PLATFORM_GPMI_NAND) += platform-gpmi-nand.o
6obj-$(CONFIG_MXS_HAVE_PLATFORM_MXS_I2C) += platform-mxs-i2c.o 7obj-$(CONFIG_MXS_HAVE_PLATFORM_MXS_I2C) += platform-mxs-i2c.o
7obj-$(CONFIG_MXS_HAVE_PLATFORM_MXS_MMC) += platform-mxs-mmc.o 8obj-$(CONFIG_MXS_HAVE_PLATFORM_MXS_MMC) += platform-mxs-mmc.o
8obj-$(CONFIG_MXS_HAVE_PLATFORM_MXS_PWM) += platform-mxs-pwm.o 9obj-$(CONFIG_MXS_HAVE_PLATFORM_MXS_PWM) += platform-mxs-pwm.o
diff --git a/arch/arm/mach-mxs/devices/amba-duart.c b/arch/arm/mach-mxs/devices/amba-duart.c
index a559db09b49..a5479f76604 100644
--- a/arch/arm/mach-mxs/devices/amba-duart.c
+++ b/arch/arm/mach-mxs/devices/amba-duart.c
@@ -23,7 +23,7 @@ const struct amba_device name##_device __initconst = { \
23 .end = (soc ## _DUART_BASE_ADDR) + SZ_8K - 1, \ 23 .end = (soc ## _DUART_BASE_ADDR) + SZ_8K - 1, \
24 .flags = IORESOURCE_MEM, \ 24 .flags = IORESOURCE_MEM, \
25 }, \ 25 }, \
26 .irq = {soc ## _INT_DUART, NO_IRQ}, \ 26 .irq = {soc ## _INT_DUART}, \
27} 27}
28 28
29#ifdef CONFIG_SOC_IMX23 29#ifdef CONFIG_SOC_IMX23
diff --git a/arch/arm/mach-mxs/devices/platform-gpmi-nand.c b/arch/arm/mach-mxs/devices/platform-gpmi-nand.c
new file mode 100644
index 00000000000..3e22df5944a
--- /dev/null
+++ b/arch/arm/mach-mxs/devices/platform-gpmi-nand.c
@@ -0,0 +1,81 @@
1/*
2 * Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License 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 along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18#include <asm/sizes.h>
19#include <mach/mx23.h>
20#include <mach/mx28.h>
21#include <mach/devices-common.h>
22#include <linux/dma-mapping.h>
23
24#ifdef CONFIG_SOC_IMX23
25const struct mxs_gpmi_nand_data mx23_gpmi_nand_data __initconst = {
26 .devid = "imx23-gpmi-nand",
27 .res = {
28 /* GPMI */
29 DEFINE_RES_MEM_NAMED(MX23_GPMI_BASE_ADDR, SZ_8K,
30 GPMI_NAND_GPMI_REGS_ADDR_RES_NAME),
31 DEFINE_RES_IRQ_NAMED(MX23_INT_GPMI_ATTENTION,
32 GPMI_NAND_GPMI_INTERRUPT_RES_NAME),
33 /* BCH */
34 DEFINE_RES_MEM_NAMED(MX23_BCH_BASE_ADDR, SZ_8K,
35 GPMI_NAND_BCH_REGS_ADDR_RES_NAME),
36 DEFINE_RES_IRQ_NAMED(MX23_INT_BCH,
37 GPMI_NAND_BCH_INTERRUPT_RES_NAME),
38 /* DMA */
39 DEFINE_RES_NAMED(MX23_DMA_GPMI0,
40 MX23_DMA_GPMI3 - MX23_DMA_GPMI0 + 1,
41 GPMI_NAND_DMA_CHANNELS_RES_NAME,
42 IORESOURCE_DMA),
43 DEFINE_RES_IRQ_NAMED(MX23_INT_GPMI_DMA,
44 GPMI_NAND_DMA_INTERRUPT_RES_NAME),
45 },
46};
47#endif
48
49#ifdef CONFIG_SOC_IMX28
50const struct mxs_gpmi_nand_data mx28_gpmi_nand_data __initconst = {
51 .devid = "imx28-gpmi-nand",
52 .res = {
53 /* GPMI */
54 DEFINE_RES_MEM_NAMED(MX28_GPMI_BASE_ADDR, SZ_8K,
55 GPMI_NAND_GPMI_REGS_ADDR_RES_NAME),
56 DEFINE_RES_IRQ_NAMED(MX28_INT_GPMI,
57 GPMI_NAND_GPMI_INTERRUPT_RES_NAME),
58 /* BCH */
59 DEFINE_RES_MEM_NAMED(MX28_BCH_BASE_ADDR, SZ_8K,
60 GPMI_NAND_BCH_REGS_ADDR_RES_NAME),
61 DEFINE_RES_IRQ_NAMED(MX28_INT_BCH,
62 GPMI_NAND_BCH_INTERRUPT_RES_NAME),
63 /* DMA */
64 DEFINE_RES_NAMED(MX28_DMA_GPMI0,
65 MX28_DMA_GPMI7 - MX28_DMA_GPMI0 + 1,
66 GPMI_NAND_DMA_CHANNELS_RES_NAME,
67 IORESOURCE_DMA),
68 DEFINE_RES_IRQ_NAMED(MX28_INT_GPMI_DMA,
69 GPMI_NAND_DMA_INTERRUPT_RES_NAME),
70 },
71};
72#endif
73
74struct platform_device *__init
75mxs_add_gpmi_nand(const struct gpmi_nand_platform_data *pdata,
76 const struct mxs_gpmi_nand_data *data)
77{
78 return mxs_add_platform_device_dmamask(data->devid, -1,
79 data->res, GPMI_NAND_RES_SIZE,
80 pdata, sizeof(*pdata), DMA_BIT_MASK(32));
81}
diff --git a/arch/arm/mach-mxs/devices/platform-mxs-mmc.c b/arch/arm/mach-mxs/devices/platform-mxs-mmc.c
index 382dacbeca2..bef9d923f54 100644
--- a/arch/arm/mach-mxs/devices/platform-mxs-mmc.c
+++ b/arch/arm/mach-mxs/devices/platform-mxs-mmc.c
@@ -41,6 +41,8 @@ const struct mxs_mxs_mmc_data mx23_mxs_mmc_data[] __initconst = {
41const struct mxs_mxs_mmc_data mx28_mxs_mmc_data[] __initconst = { 41const struct mxs_mxs_mmc_data mx28_mxs_mmc_data[] __initconst = {
42 mxs_mxs_mmc_data_entry(MX28, 0, 0), 42 mxs_mxs_mmc_data_entry(MX28, 0, 0),
43 mxs_mxs_mmc_data_entry(MX28, 1, 1), 43 mxs_mxs_mmc_data_entry(MX28, 1, 1),
44 mxs_mxs_mmc_data_entry(MX28, 2, 2),
45 mxs_mxs_mmc_data_entry(MX28, 3, 3),
44}; 46};
45#endif 47#endif
46 48
diff --git a/arch/arm/mach-mxs/include/mach/common.h b/arch/arm/mach-mxs/include/mach/common.h
index e1237ab2586..c50c3ea28a9 100644
--- a/arch/arm/mach-mxs/include/mach/common.h
+++ b/arch/arm/mach-mxs/include/mach/common.h
@@ -31,4 +31,6 @@ extern void mx28_init_irq(void);
31 31
32extern void icoll_init_irq(void); 32extern void icoll_init_irq(void);
33 33
34extern int mxs_clkctrl_timeout(unsigned int reg_offset, unsigned int mask);
35
34#endif /* __MACH_MXS_COMMON_H__ */ 36#endif /* __MACH_MXS_COMMON_H__ */
diff --git a/arch/arm/mach-mxs/include/mach/devices-common.h b/arch/arm/mach-mxs/include/mach/devices-common.h
index dc369c1239f..f2e383955d8 100644
--- a/arch/arm/mach-mxs/include/mach/devices-common.h
+++ b/arch/arm/mach-mxs/include/mach/devices-common.h
@@ -66,6 +66,16 @@ struct platform_device *__init mxs_add_flexcan(
66 const struct mxs_flexcan_data *data, 66 const struct mxs_flexcan_data *data,
67 const struct flexcan_platform_data *pdata); 67 const struct flexcan_platform_data *pdata);
68 68
69/* gpmi-nand */
70#include <linux/mtd/gpmi-nand.h>
71struct mxs_gpmi_nand_data {
72 const char *devid;
73 const struct resource res[GPMI_NAND_RES_SIZE];
74};
75struct platform_device *__init
76mxs_add_gpmi_nand(const struct gpmi_nand_platform_data *pdata,
77 const struct mxs_gpmi_nand_data *data);
78
69/* i2c */ 79/* i2c */
70struct mxs_mxs_i2c_data { 80struct mxs_mxs_i2c_data {
71 int id; 81 int id;
diff --git a/arch/arm/mach-mxs/include/mach/digctl.h b/arch/arm/mach-mxs/include/mach/digctl.h
index 49a888c65d6..17964066303 100644
--- a/arch/arm/mach-mxs/include/mach/digctl.h
+++ b/arch/arm/mach-mxs/include/mach/digctl.h
@@ -18,4 +18,5 @@
18#define HW_DIGCTL_CTRL 0x0 18#define HW_DIGCTL_CTRL 0x0
19#define BP_DIGCTL_CTRL_SAIF_CLKMUX 10 19#define BP_DIGCTL_CTRL_SAIF_CLKMUX 10
20#define BM_DIGCTL_CTRL_SAIF_CLKMUX (0x3 << 10) 20#define BM_DIGCTL_CTRL_SAIF_CLKMUX (0x3 << 10)
21#define HW_DIGCTL_CHIPID 0x310
21#endif 22#endif
diff --git a/arch/arm/mach-mxs/include/mach/entry-macro.S b/arch/arm/mach-mxs/include/mach/entry-macro.S
index 9f0da12e657..0c14259705b 100644
--- a/arch/arm/mach-mxs/include/mach/entry-macro.S
+++ b/arch/arm/mach-mxs/include/mach/entry-macro.S
@@ -23,9 +23,6 @@
23#define MXS_ICOLL_VBASE MXS_IO_ADDRESS(MXS_ICOLL_BASE_ADDR) 23#define MXS_ICOLL_VBASE MXS_IO_ADDRESS(MXS_ICOLL_BASE_ADDR)
24#define HW_ICOLL_STAT_OFFSET 0x70 24#define HW_ICOLL_STAT_OFFSET 0x70
25 25
26 .macro disable_fiq
27 .endm
28
29 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp 26 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
30 ldr \irqnr, [\base, #HW_ICOLL_STAT_OFFSET] 27 ldr \irqnr, [\base, #HW_ICOLL_STAT_OFFSET]
31 cmp \irqnr, #0x7F 28 cmp \irqnr, #0x7F
@@ -36,6 +33,3 @@
36 .macro get_irqnr_preamble, base, tmp 33 .macro get_irqnr_preamble, base, tmp
37 ldr \base, =MXS_ICOLL_VBASE 34 ldr \base, =MXS_ICOLL_VBASE
38 .endm 35 .endm
39
40 .macro arch_ret_to_user, tmp1, tmp2
41 .endm
diff --git a/arch/arm/mach-mxs/include/mach/mxs.h b/arch/arm/mach-mxs/include/mach/mxs.h
index bde5f663474..7d4fb6d0afd 100644
--- a/arch/arm/mach-mxs/include/mach/mxs.h
+++ b/arch/arm/mach-mxs/include/mach/mxs.h
@@ -23,22 +23,10 @@
23#include <linux/io.h> 23#include <linux/io.h>
24#endif 24#endif
25#include <asm/mach-types.h> 25#include <asm/mach-types.h>
26#include <mach/digctl.h>
26#include <mach/hardware.h> 27#include <mach/hardware.h>
27 28
28/* 29/*
29 * MXS CPU types
30 */
31#define cpu_is_mx23() ( \
32 machine_is_mx23evk() || \
33 machine_is_stmp378x() || \
34 0)
35#define cpu_is_mx28() ( \
36 machine_is_mx28evk() || \
37 machine_is_m28evk() || \
38 machine_is_tx28() || \
39 0)
40
41/*
42 * IO addresses common to MXS-based 30 * IO addresses common to MXS-based
43 */ 31 */
44#define MXS_IO_BASE_ADDR 0x80000000 32#define MXS_IO_BASE_ADDR 0x80000000
@@ -109,6 +97,21 @@ static inline void __mxs_togl(u32 mask, void __iomem *reg)
109{ 97{
110 __raw_writel(mask, reg + MXS_TOG_ADDR); 98 __raw_writel(mask, reg + MXS_TOG_ADDR);
111} 99}
100
101/*
102 * MXS CPU types
103 */
104#define MXS_CHIPID (MXS_IO_ADDRESS(MXS_DIGCTL_BASE_ADDR) + HW_DIGCTL_CHIPID)
105
106static inline int cpu_is_mx23(void)
107{
108 return ((__raw_readl(MXS_CHIPID) >> 16) == 0x3780);
109}
110
111static inline int cpu_is_mx28(void)
112{
113 return ((__raw_readl(MXS_CHIPID) >> 16) == 0x2800);
114}
112#endif 115#endif
113 116
114#endif /* __MACH_MXS_H__ */ 117#endif /* __MACH_MXS_H__ */
diff --git a/arch/arm/mach-mxs/include/mach/system.h b/arch/arm/mach-mxs/include/mach/system.h
deleted file mode 100644
index e7ad1bb2942..00000000000
--- a/arch/arm/mach-mxs/include/mach/system.h
+++ /dev/null
@@ -1,25 +0,0 @@
1/*
2 * Copyright (C) 1999 ARM Limited
3 * Copyright (C) 2000 Deep Blue Solutions Ltd
4 * Copyright 2004-2008 Freescale Semiconductor, Inc. All Rights Reserved.
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
17#ifndef __MACH_MXS_SYSTEM_H__
18#define __MACH_MXS_SYSTEM_H__
19
20static inline void arch_idle(void)
21{
22 cpu_do_idle();
23}
24
25#endif /* __MACH_MXS_SYSTEM_H__ */
diff --git a/arch/arm/mach-mxs/include/mach/uncompress.h b/arch/arm/mach-mxs/include/mach/uncompress.h
index 67776746f14..ef281149544 100644
--- a/arch/arm/mach-mxs/include/mach/uncompress.h
+++ b/arch/arm/mach-mxs/include/mach/uncompress.h
@@ -18,8 +18,6 @@
18#ifndef __MACH_MXS_UNCOMPRESS_H__ 18#ifndef __MACH_MXS_UNCOMPRESS_H__
19#define __MACH_MXS_UNCOMPRESS_H__ 19#define __MACH_MXS_UNCOMPRESS_H__
20 20
21#include <asm/mach-types.h>
22
23unsigned long mxs_duart_base; 21unsigned long mxs_duart_base;
24 22
25#define MXS_DUART(x) (*(volatile unsigned long *)(mxs_duart_base + (x))) 23#define MXS_DUART(x) (*(volatile unsigned long *)(mxs_duart_base + (x)))
@@ -55,16 +53,17 @@ static inline void flush(void)
55 53
56#define MX23_DUART_BASE_ADDR 0x80070000 54#define MX23_DUART_BASE_ADDR 0x80070000
57#define MX28_DUART_BASE_ADDR 0x80074000 55#define MX28_DUART_BASE_ADDR 0x80074000
56#define MXS_DIGCTL_CHIPID 0x8001c310
58 57
59static inline void __arch_decomp_setup(unsigned long arch_id) 58static inline void __arch_decomp_setup(unsigned long arch_id)
60{ 59{
61 switch (arch_id) { 60 u16 chipid = (*(volatile unsigned long *) MXS_DIGCTL_CHIPID) >> 16;
62 case MACH_TYPE_MX23EVK: 61
62 switch (chipid) {
63 case 0x3780:
63 mxs_duart_base = MX23_DUART_BASE_ADDR; 64 mxs_duart_base = MX23_DUART_BASE_ADDR;
64 break; 65 break;
65 case MACH_TYPE_MX28EVK: 66 case 0x2800:
66 case MACH_TYPE_M28EVK:
67 case MACH_TYPE_TX28:
68 mxs_duart_base = MX28_DUART_BASE_ADDR; 67 mxs_duart_base = MX28_DUART_BASE_ADDR;
69 break; 68 break;
70 default: 69 default:
diff --git a/arch/arm/mach-mxs/mach-apx4devkit.c b/arch/arm/mach-mxs/mach-apx4devkit.c
new file mode 100644
index 00000000000..48a7fab571a
--- /dev/null
+++ b/arch/arm/mach-mxs/mach-apx4devkit.c
@@ -0,0 +1,260 @@
1/*
2 * Copyright (C) 2011-2012
3 * Lauri Hintsala, Bluegiga, <lauri.hintsala@bluegiga.com>
4 * Veli-Pekka Peltola, Bluegiga, <veli-pekka.peltola@bluegiga.com>
5 *
6 * based on: mach-mx28evk.c
7 * Copyright 2010 Freescale Semiconductor, Inc. All Rights Reserved.
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 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 */
19
20#include <linux/delay.h>
21#include <linux/platform_device.h>
22#include <linux/gpio.h>
23#include <linux/leds.h>
24#include <linux/clk.h>
25#include <linux/i2c.h>
26#include <linux/regulator/machine.h>
27#include <linux/regulator/fixed.h>
28#include <linux/micrel_phy.h>
29
30#include <asm/mach-types.h>
31#include <asm/mach/arch.h>
32#include <asm/mach/time.h>
33
34#include <mach/common.h>
35#include <mach/digctl.h>
36#include <mach/iomux-mx28.h>
37
38#include "devices-mx28.h"
39
40#define APX4DEVKIT_GPIO_USERLED MXS_GPIO_NR(3, 28)
41
42static const iomux_cfg_t apx4devkit_pads[] __initconst = {
43 /* duart */
44 MX28_PAD_PWM0__DUART_RX | MXS_PAD_CTRL,
45 MX28_PAD_PWM1__DUART_TX | MXS_PAD_CTRL,
46
47 /* auart0 */
48 MX28_PAD_AUART0_RX__AUART0_RX | MXS_PAD_CTRL,
49 MX28_PAD_AUART0_TX__AUART0_TX | MXS_PAD_CTRL,
50 MX28_PAD_AUART0_CTS__AUART0_CTS | MXS_PAD_CTRL,
51 MX28_PAD_AUART0_RTS__AUART0_RTS | MXS_PAD_CTRL,
52
53 /* auart1 */
54 MX28_PAD_AUART1_RX__AUART1_RX | MXS_PAD_CTRL,
55 MX28_PAD_AUART1_TX__AUART1_TX | MXS_PAD_CTRL,
56
57 /* auart2 */
58 MX28_PAD_SSP2_SCK__AUART2_RX | MXS_PAD_CTRL,
59 MX28_PAD_SSP2_MOSI__AUART2_TX | MXS_PAD_CTRL,
60
61 /* auart3 */
62 MX28_PAD_SSP2_MISO__AUART3_RX | MXS_PAD_CTRL,
63 MX28_PAD_SSP2_SS0__AUART3_TX | MXS_PAD_CTRL,
64
65#define MXS_PAD_FEC (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP)
66 /* fec0 */
67 MX28_PAD_ENET0_MDC__ENET0_MDC | MXS_PAD_FEC,
68 MX28_PAD_ENET0_MDIO__ENET0_MDIO | MXS_PAD_FEC,
69 MX28_PAD_ENET0_RX_EN__ENET0_RX_EN | MXS_PAD_FEC,
70 MX28_PAD_ENET0_RXD0__ENET0_RXD0 | MXS_PAD_FEC,
71 MX28_PAD_ENET0_RXD1__ENET0_RXD1 | MXS_PAD_FEC,
72 MX28_PAD_ENET0_TX_EN__ENET0_TX_EN | MXS_PAD_FEC,
73 MX28_PAD_ENET0_TXD0__ENET0_TXD0 | MXS_PAD_FEC,
74 MX28_PAD_ENET0_TXD1__ENET0_TXD1 | MXS_PAD_FEC,
75 MX28_PAD_ENET_CLK__CLKCTRL_ENET | MXS_PAD_FEC,
76
77 /* i2c */
78 MX28_PAD_I2C0_SCL__I2C0_SCL,
79 MX28_PAD_I2C0_SDA__I2C0_SDA,
80
81 /* mmc0 */
82 MX28_PAD_SSP0_DATA0__SSP0_D0 |
83 (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
84 MX28_PAD_SSP0_DATA1__SSP0_D1 |
85 (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
86 MX28_PAD_SSP0_DATA2__SSP0_D2 |
87 (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
88 MX28_PAD_SSP0_DATA3__SSP0_D3 |
89 (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
90 MX28_PAD_SSP0_DATA4__SSP0_D4 |
91 (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
92 MX28_PAD_SSP0_DATA5__SSP0_D5 |
93 (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
94 MX28_PAD_SSP0_DATA6__SSP0_D6 |
95 (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
96 MX28_PAD_SSP0_DATA7__SSP0_D7 |
97 (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
98 MX28_PAD_SSP0_CMD__SSP0_CMD |
99 (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
100 MX28_PAD_SSP0_DETECT__SSP0_CARD_DETECT |
101 (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_NOPULL),
102 MX28_PAD_SSP0_SCK__SSP0_SCK |
103 (MXS_PAD_12MA | MXS_PAD_3V3 | MXS_PAD_NOPULL),
104
105 /* led */
106 MX28_PAD_PWM3__GPIO_3_28 | MXS_PAD_CTRL,
107
108 /* saif0 & saif1 */
109 MX28_PAD_SAIF0_MCLK__SAIF0_MCLK |
110 (MXS_PAD_12MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
111 MX28_PAD_SAIF0_LRCLK__SAIF0_LRCLK |
112 (MXS_PAD_12MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
113 MX28_PAD_SAIF0_BITCLK__SAIF0_BITCLK |
114 (MXS_PAD_12MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
115 MX28_PAD_SAIF0_SDATA0__SAIF0_SDATA0 |
116 (MXS_PAD_12MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
117 MX28_PAD_SAIF1_SDATA0__SAIF1_SDATA0 |
118 (MXS_PAD_12MA | MXS_PAD_3V3 | MXS_PAD_PULLUP),
119};
120
121/* led */
122static const struct gpio_led apx4devkit_leds[] __initconst = {
123 {
124 .name = "user-led",
125 .default_trigger = "heartbeat",
126 .gpio = APX4DEVKIT_GPIO_USERLED,
127 },
128};
129
130static const struct gpio_led_platform_data apx4devkit_led_data __initconst = {
131 .leds = apx4devkit_leds,
132 .num_leds = ARRAY_SIZE(apx4devkit_leds),
133};
134
135static const struct fec_platform_data mx28_fec_pdata __initconst = {
136 .phy = PHY_INTERFACE_MODE_RMII,
137};
138
139static const struct mxs_mmc_platform_data apx4devkit_mmc_pdata __initconst = {
140 .wp_gpio = -EINVAL,
141 .flags = SLOTF_4_BIT_CAPABLE,
142};
143
144static const struct i2c_board_info apx4devkit_i2c_boardinfo[] __initconst = {
145 { I2C_BOARD_INFO("sgtl5000", 0x0a) }, /* ASoC */
146 { I2C_BOARD_INFO("pcf8563", 0x51) }, /* RTC */
147};
148
149#if defined(CONFIG_REGULATOR_FIXED_VOLTAGE) || \
150 defined(CONFIG_REGULATOR_FIXED_VOLTAGE_MODULE)
151static struct regulator_consumer_supply apx4devkit_audio_consumer_supplies[] = {
152 REGULATOR_SUPPLY("VDDA", "0-000a"),
153 REGULATOR_SUPPLY("VDDIO", "0-000a"),
154};
155
156static struct regulator_init_data apx4devkit_vdd_reg_init_data = {
157 .constraints = {
158 .name = "3V3",
159 .always_on = 1,
160 },
161 .consumer_supplies = apx4devkit_audio_consumer_supplies,
162 .num_consumer_supplies = ARRAY_SIZE(apx4devkit_audio_consumer_supplies),
163};
164
165static struct fixed_voltage_config apx4devkit_vdd_pdata = {
166 .supply_name = "board-3V3",
167 .microvolts = 3300000,
168 .gpio = -EINVAL,
169 .enabled_at_boot = 1,
170 .init_data = &apx4devkit_vdd_reg_init_data,
171};
172
173static struct platform_device apx4devkit_voltage_regulator = {
174 .name = "reg-fixed-voltage",
175 .id = -1,
176 .num_resources = 0,
177 .dev = {
178 .platform_data = &apx4devkit_vdd_pdata,
179 },
180};
181
182static void __init apx4devkit_add_regulators(void)
183{
184 platform_device_register(&apx4devkit_voltage_regulator);
185}
186#else
187static void __init apx4devkit_add_regulators(void) {}
188#endif
189
190static const struct mxs_saif_platform_data
191 apx4devkit_mxs_saif_pdata[] __initconst = {
192 /* working on EXTMSTR0 mode (saif0 master, saif1 slave) */
193 {
194 .master_mode = 1,
195 .master_id = 0,
196 }, {
197 .master_mode = 0,
198 .master_id = 0,
199 },
200};
201
202static int apx4devkit_phy_fixup(struct phy_device *phy)
203{
204 phy->dev_flags |= MICREL_PHY_50MHZ_CLK;
205 return 0;
206}
207
208static void __init apx4devkit_init(void)
209{
210 mxs_iomux_setup_multiple_pads(apx4devkit_pads,
211 ARRAY_SIZE(apx4devkit_pads));
212
213 mx28_add_duart();
214 mx28_add_auart0();
215 mx28_add_auart1();
216 mx28_add_auart2();
217 mx28_add_auart3();
218
219 /*
220 * Register fixup for the Micrel KS8031 PHY clock
221 * (shares same ID with KS8051)
222 */
223 phy_register_fixup_for_uid(PHY_ID_KS8051, MICREL_PHY_ID_MASK,
224 apx4devkit_phy_fixup);
225
226 mx28_add_fec(0, &mx28_fec_pdata);
227
228 mx28_add_mxs_mmc(0, &apx4devkit_mmc_pdata);
229
230 gpio_led_register_device(0, &apx4devkit_led_data);
231
232 mxs_saif_clkmux_select(MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0);
233 mx28_add_saif(0, &apx4devkit_mxs_saif_pdata[0]);
234 mx28_add_saif(1, &apx4devkit_mxs_saif_pdata[1]);
235
236 apx4devkit_add_regulators();
237
238 mx28_add_mxs_i2c(0);
239 i2c_register_board_info(0, apx4devkit_i2c_boardinfo,
240 ARRAY_SIZE(apx4devkit_i2c_boardinfo));
241
242 mxs_add_platform_device("mxs-sgtl5000", 0, NULL, 0, NULL, 0);
243}
244
245static void __init apx4devkit_timer_init(void)
246{
247 mx28_clocks_init();
248}
249
250static struct sys_timer apx4devkit_timer = {
251 .init = apx4devkit_timer_init,
252};
253
254MACHINE_START(APX4DEVKIT, "Bluegiga APX4 Development Kit")
255 .map_io = mx28_map_io,
256 .init_irq = mx28_init_irq,
257 .timer = &apx4devkit_timer,
258 .init_machine = apx4devkit_init,
259 .restart = mxs_restart,
260MACHINE_END
diff --git a/arch/arm/mach-mxs/mach-m28evk.c b/arch/arm/mach-mxs/mach-m28evk.c
index 2f2758230ed..06d79963611 100644
--- a/arch/arm/mach-mxs/mach-m28evk.c
+++ b/arch/arm/mach-mxs/mach-m28evk.c
@@ -247,18 +247,15 @@ static int __init m28evk_fec_get_mac(void)
247 u32 val; 247 u32 val;
248 const u32 *ocotp = mxs_get_ocotp(); 248 const u32 *ocotp = mxs_get_ocotp();
249 249
250 if (!ocotp) { 250 if (!ocotp)
251 pr_err("%s: timeout when reading fec mac from OCOTP\n",
252 __func__);
253 return -ETIMEDOUT; 251 return -ETIMEDOUT;
254 }
255 252
256 /* 253 /*
257 * OCOTP only stores the last 4 octets for each mac address, 254 * OCOTP only stores the last 4 octets for each mac address,
258 * so hard-code DENX OUI (C0:E5:4E) here. 255 * so hard-code DENX OUI (C0:E5:4E) here.
259 */ 256 */
260 for (i = 0; i < 2; i++) { 257 for (i = 0; i < 2; i++) {
261 val = ocotp[i * 4]; 258 val = ocotp[i];
262 mx28_fec_pdata[i].mac[0] = 0xC0; 259 mx28_fec_pdata[i].mac[0] = 0xC0;
263 mx28_fec_pdata[i].mac[1] = 0xE5; 260 mx28_fec_pdata[i].mac[1] = 0xE5;
264 mx28_fec_pdata[i].mac[2] = 0x4E; 261 mx28_fec_pdata[i].mac[2] = 0x4E;
diff --git a/arch/arm/mach-mxs/mach-mx28evk.c b/arch/arm/mach-mxs/mach-mx28evk.c
index fdb0a5664dd..e386c142f93 100644
--- a/arch/arm/mach-mxs/mach-mx28evk.c
+++ b/arch/arm/mach-mxs/mach-mx28evk.c
@@ -223,7 +223,6 @@ static const struct gpio_led_platform_data mx28evk_led_data __initconst = {
223/* fec */ 223/* fec */
224static void __init mx28evk_fec_reset(void) 224static void __init mx28evk_fec_reset(void)
225{ 225{
226 int ret;
227 struct clk *clk; 226 struct clk *clk;
228 227
229 /* Enable fec phy clock */ 228 /* Enable fec phy clock */
@@ -231,32 +230,7 @@ static void __init mx28evk_fec_reset(void)
231 if (!IS_ERR(clk)) 230 if (!IS_ERR(clk))
232 clk_prepare_enable(clk); 231 clk_prepare_enable(clk);
233 232
234 /* Power up fec phy */ 233 gpio_set_value(MX28EVK_FEC_PHY_RESET, 0);
235 ret = gpio_request(MX28EVK_FEC_PHY_POWER, "fec-phy-power");
236 if (ret) {
237 pr_err("Failed to request gpio fec-phy-%s: %d\n", "power", ret);
238 return;
239 }
240
241 ret = gpio_direction_output(MX28EVK_FEC_PHY_POWER, 0);
242 if (ret) {
243 pr_err("Failed to drive gpio fec-phy-%s: %d\n", "power", ret);
244 return;
245 }
246
247 /* Reset fec phy */
248 ret = gpio_request(MX28EVK_FEC_PHY_RESET, "fec-phy-reset");
249 if (ret) {
250 pr_err("Failed to request gpio fec-phy-%s: %d\n", "reset", ret);
251 return;
252 }
253
254 gpio_direction_output(MX28EVK_FEC_PHY_RESET, 0);
255 if (ret) {
256 pr_err("Failed to drive gpio fec-phy-%s: %d\n", "reset", ret);
257 return;
258 }
259
260 mdelay(1); 234 mdelay(1);
261 gpio_set_value(MX28EVK_FEC_PHY_RESET, 1); 235 gpio_set_value(MX28EVK_FEC_PHY_RESET, 1);
262} 236}
@@ -278,14 +252,14 @@ static int __init mx28evk_fec_get_mac(void)
278 const u32 *ocotp = mxs_get_ocotp(); 252 const u32 *ocotp = mxs_get_ocotp();
279 253
280 if (!ocotp) 254 if (!ocotp)
281 goto error; 255 return -ETIMEDOUT;
282 256
283 /* 257 /*
284 * OCOTP only stores the last 4 octets for each mac address, 258 * OCOTP only stores the last 4 octets for each mac address,
285 * so hard-code Freescale OUI (00:04:9f) here. 259 * so hard-code Freescale OUI (00:04:9f) here.
286 */ 260 */
287 for (i = 0; i < 2; i++) { 261 for (i = 0; i < 2; i++) {
288 val = ocotp[i * 4]; 262 val = ocotp[i];
289 mx28_fec_pdata[i].mac[0] = 0x00; 263 mx28_fec_pdata[i].mac[0] = 0x00;
290 mx28_fec_pdata[i].mac[1] = 0x04; 264 mx28_fec_pdata[i].mac[1] = 0x04;
291 mx28_fec_pdata[i].mac[2] = 0x9f; 265 mx28_fec_pdata[i].mac[2] = 0x9f;
@@ -295,10 +269,6 @@ static int __init mx28evk_fec_get_mac(void)
295 } 269 }
296 270
297 return 0; 271 return 0;
298
299error:
300 pr_err("%s: timeout when reading fec mac from OCOTP\n", __func__);
301 return -ETIMEDOUT;
302} 272}
303 273
304/* 274/*
@@ -417,9 +387,14 @@ static void __init mx28evk_add_regulators(void)
417static void __init mx28evk_add_regulators(void) {} 387static void __init mx28evk_add_regulators(void) {}
418#endif 388#endif
419 389
420static struct gpio mx28evk_lcd_gpios[] = { 390static const struct gpio mx28evk_gpios[] __initconst = {
421 { MX28EVK_LCD_ENABLE, GPIOF_OUT_INIT_HIGH, "lcd-enable" }, 391 { MX28EVK_LCD_ENABLE, GPIOF_OUT_INIT_HIGH, "lcd-enable" },
422 { MX28EVK_BL_ENABLE, GPIOF_OUT_INIT_HIGH, "bl-enable" }, 392 { MX28EVK_BL_ENABLE, GPIOF_OUT_INIT_HIGH, "bl-enable" },
393 { MX28EVK_FLEXCAN_SWITCH, GPIOF_DIR_OUT, "flexcan-switch" },
394 { MX28EVK_MMC0_SLOT_POWER, GPIOF_OUT_INIT_LOW, "mmc0-slot-power" },
395 { MX28EVK_MMC1_SLOT_POWER, GPIOF_OUT_INIT_LOW, "mmc1-slot-power" },
396 { MX28EVK_FEC_PHY_POWER, GPIOF_OUT_INIT_LOW, "fec-phy-power" },
397 { MX28EVK_FEC_PHY_RESET, GPIOF_DIR_OUT, "fec-phy-reset" },
423}; 398};
424 399
425static const struct mxs_saif_platform_data 400static const struct mxs_saif_platform_data
@@ -447,25 +422,18 @@ static void __init mx28evk_init(void)
447 if (mx28evk_fec_get_mac()) 422 if (mx28evk_fec_get_mac())
448 pr_warn("%s: failed on fec mac setup\n", __func__); 423 pr_warn("%s: failed on fec mac setup\n", __func__);
449 424
425 ret = gpio_request_array(mx28evk_gpios, ARRAY_SIZE(mx28evk_gpios));
426 if (ret)
427 pr_err("One or more GPIOs failed to be requested: %d\n", ret);
428
450 mx28evk_fec_reset(); 429 mx28evk_fec_reset();
451 mx28_add_fec(0, &mx28_fec_pdata[0]); 430 mx28_add_fec(0, &mx28_fec_pdata[0]);
452 mx28_add_fec(1, &mx28_fec_pdata[1]); 431 mx28_add_fec(1, &mx28_fec_pdata[1]);
453 432
454 ret = gpio_request_one(MX28EVK_FLEXCAN_SWITCH, GPIOF_DIR_OUT, 433 mx28_add_flexcan(0, &mx28evk_flexcan_pdata[0]);
455 "flexcan-switch"); 434 mx28_add_flexcan(1, &mx28evk_flexcan_pdata[1]);
456 if (ret) {
457 pr_err("failed to request gpio flexcan-switch: %d\n", ret);
458 } else {
459 mx28_add_flexcan(0, &mx28evk_flexcan_pdata[0]);
460 mx28_add_flexcan(1, &mx28evk_flexcan_pdata[1]);
461 }
462 435
463 ret = gpio_request_array(mx28evk_lcd_gpios, 436 mx28_add_mxsfb(&mx28evk_mxsfb_pdata);
464 ARRAY_SIZE(mx28evk_lcd_gpios));
465 if (ret)
466 pr_warn("failed to request gpio pins for lcd: %d\n", ret);
467 else
468 mx28_add_mxsfb(&mx28evk_mxsfb_pdata);
469 437
470 mxs_saif_clkmux_select(MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0); 438 mxs_saif_clkmux_select(MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0);
471 mx28_add_saif(0, &mx28evk_mxs_saif_pdata[0]); 439 mx28_add_saif(0, &mx28evk_mxs_saif_pdata[0]);
@@ -480,20 +448,8 @@ static void __init mx28evk_init(void)
480 mxs_add_platform_device("mxs-sgtl5000", 0, NULL, 0, 448 mxs_add_platform_device("mxs-sgtl5000", 0, NULL, 0,
481 NULL, 0); 449 NULL, 0);
482 450
483 /* power on mmc slot by writing 0 to the gpio */ 451 mx28_add_mxs_mmc(0, &mx28evk_mmc_pdata[0]);
484 ret = gpio_request_one(MX28EVK_MMC0_SLOT_POWER, GPIOF_OUT_INIT_LOW, 452 mx28_add_mxs_mmc(1, &mx28evk_mmc_pdata[1]);
485 "mmc0-slot-power");
486 if (ret)
487 pr_warn("failed to request gpio mmc0-slot-power: %d\n", ret);
488 else
489 mx28_add_mxs_mmc(0, &mx28evk_mmc_pdata[0]);
490
491 ret = gpio_request_one(MX28EVK_MMC1_SLOT_POWER, GPIOF_OUT_INIT_LOW,
492 "mmc1-slot-power");
493 if (ret)
494 pr_warn("failed to request gpio mmc1-slot-power: %d\n", ret);
495 else
496 mx28_add_mxs_mmc(1, &mx28evk_mmc_pdata[1]);
497 453
498 mx28_add_rtc_stmp3xxx(); 454 mx28_add_rtc_stmp3xxx();
499 455
diff --git a/arch/arm/mach-mxs/pm.c b/arch/arm/mach-mxs/pm.c
index fb042da29bd..a9b4bbcdafb 100644
--- a/arch/arm/mach-mxs/pm.c
+++ b/arch/arm/mach-mxs/pm.c
@@ -15,13 +15,12 @@
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/suspend.h> 16#include <linux/suspend.h>
17#include <linux/io.h> 17#include <linux/io.h>
18#include <mach/system.h>
19 18
20static int mxs_suspend_enter(suspend_state_t state) 19static int mxs_suspend_enter(suspend_state_t state)
21{ 20{
22 switch (state) { 21 switch (state) {
23 case PM_SUSPEND_MEM: 22 case PM_SUSPEND_MEM:
24 arch_idle(); 23 cpu_do_idle();
25 break; 24 break;
26 25
27 default: 26 default:
diff --git a/arch/arm/mach-mxs/system.c b/arch/arm/mach-mxs/system.c
index 30042e23bfa..80ac1fca8a0 100644
--- a/arch/arm/mach-mxs/system.c
+++ b/arch/arm/mach-mxs/system.c
@@ -37,6 +37,8 @@
37#define MXS_MODULE_CLKGATE (1 << 30) 37#define MXS_MODULE_CLKGATE (1 << 30)
38#define MXS_MODULE_SFTRST (1 << 31) 38#define MXS_MODULE_SFTRST (1 << 31)
39 39
40#define CLKCTRL_TIMEOUT 10 /* 10 ms */
41
40static void __iomem *mxs_clkctrl_reset_addr; 42static void __iomem *mxs_clkctrl_reset_addr;
41 43
42/* 44/*
@@ -137,3 +139,17 @@ error:
137 return -ETIMEDOUT; 139 return -ETIMEDOUT;
138} 140}
139EXPORT_SYMBOL(mxs_reset_block); 141EXPORT_SYMBOL(mxs_reset_block);
142
143int mxs_clkctrl_timeout(unsigned int reg_offset, unsigned int mask)
144{
145 unsigned long timeout = jiffies + msecs_to_jiffies(CLKCTRL_TIMEOUT);
146 while (readl_relaxed(MXS_IO_ADDRESS(MXS_CLKCTRL_BASE_ADDR)
147 + reg_offset) & mask) {
148 if (time_after(jiffies, timeout)) {
149 pr_err("Timeout at CLKCTRL + 0x%x\n", reg_offset);
150 return -ETIMEDOUT;
151 }
152 }
153
154 return 0;
155}
diff --git a/arch/arm/mach-netx/fb.c b/arch/arm/mach-netx/fb.c
index b9913234bbf..2cdf6ef69be 100644
--- a/arch/arm/mach-netx/fb.c
+++ b/arch/arm/mach-netx/fb.c
@@ -92,18 +92,7 @@ void clk_put(struct clk *clk)
92{ 92{
93} 93}
94 94
95static struct amba_device fb_device = { 95static AMBA_AHB_DEVICE(fb, "fb", 0, 0x00104000, { NETX_IRQ_LCD }, NULL);
96 .dev = {
97 .init_name = "fb",
98 .coherent_dma_mask = ~0,
99 },
100 .res = {
101 .start = 0x00104000,
102 .end = 0x00104fff,
103 .flags = IORESOURCE_MEM,
104 },
105 .irq = { NETX_IRQ_LCD, NO_IRQ },
106};
107 96
108int netx_fb_init(struct clcd_board *board, struct clcd_panel *panel) 97int netx_fb_init(struct clcd_board *board, struct clcd_panel *panel)
109{ 98{
diff --git a/arch/arm/mach-netx/include/mach/entry-macro.S b/arch/arm/mach-netx/include/mach/entry-macro.S
deleted file mode 100644
index 6e9f1cbe163..00000000000
--- a/arch/arm/mach-netx/include/mach/entry-macro.S
+++ /dev/null
@@ -1,26 +0,0 @@
1/*
2 * arch/arm/mach-netx/include/mach/entry-macro.S
3 *
4 * Low-level IRQ helper macros for Hilscher netX based platforms
5 *
6 * Copyright (C) 2005 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
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
10 * as published by the Free Software Foundation.
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 USA
20 */
21
22 .macro disable_fiq
23 .endm
24
25 .macro arch_ret_to_user, tmp1, tmp2
26 .endm
diff --git a/arch/arm/mach-netx/include/mach/system.h b/arch/arm/mach-netx/include/mach/system.h
deleted file mode 100644
index b38fa36d58c..00000000000
--- a/arch/arm/mach-netx/include/mach/system.h
+++ /dev/null
@@ -1,28 +0,0 @@
1/*
2 * arch/arm/mach-netx/include/mach/system.h
3 *
4 * Copyright (C) 2005 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
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
8 * as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * 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#ifndef __ASM_ARCH_SYSTEM_H
20#define __ASM_ARCH_SYSTEM_H
21
22static inline void arch_idle(void)
23{
24 cpu_do_idle();
25}
26
27#endif
28
diff --git a/arch/arm/mach-nomadik/board-nhk8815.c b/arch/arm/mach-nomadik/board-nhk8815.c
index 7c878bf0034..58cacafcf66 100644
--- a/arch/arm/mach-nomadik/board-nhk8815.c
+++ b/arch/arm/mach-nomadik/board-nhk8815.c
@@ -27,11 +27,11 @@
27#include <asm/mach/arch.h> 27#include <asm/mach/arch.h>
28#include <asm/mach/irq.h> 28#include <asm/mach/irq.h>
29#include <asm/mach/flash.h> 29#include <asm/mach/flash.h>
30#include <asm/mach/time.h>
30 31
31#include <plat/gpio-nomadik.h> 32#include <plat/gpio-nomadik.h>
32#include <plat/mtu.h> 33#include <plat/mtu.h>
33 34
34#include <mach/setup.h>
35#include <mach/nand.h> 35#include <mach/nand.h>
36#include <mach/fsmc.h> 36#include <mach/fsmc.h>
37 37
@@ -185,20 +185,11 @@ static void __init nhk8815_onenand_init(void)
185#endif 185#endif
186} 186}
187 187
188#define __MEM_4K_RESOURCE(x) \ 188static AMBA_APB_DEVICE(uart0, "uart0", 0, NOMADIK_UART0_BASE,
189 .res = {.start = (x), .end = (x) + SZ_4K - 1, .flags = IORESOURCE_MEM} 189 { IRQ_UART0 }, NULL);
190 190
191static struct amba_device uart0_device = { 191static AMBA_APB_DEVICE(uart1, "uart1", 0, NOMADIK_UART1_BASE,
192 .dev = { .init_name = "uart0" }, 192 { IRQ_UART1 }, NULL);
193 __MEM_4K_RESOURCE(NOMADIK_UART0_BASE),
194 .irq = {IRQ_UART0, NO_IRQ},
195};
196
197static struct amba_device uart1_device = {
198 .dev = { .init_name = "uart1" },
199 __MEM_4K_RESOURCE(NOMADIK_UART1_BASE),
200 .irq = {IRQ_UART1, NO_IRQ},
201};
202 193
203static struct amba_device *amba_devs[] __initdata = { 194static struct amba_device *amba_devs[] __initdata = {
204 &uart0_device, 195 &uart0_device,
@@ -255,10 +246,7 @@ static void __init nomadik_timer_init(void)
255 src_cr |= SRC_CR_INIT_VAL; 246 src_cr |= SRC_CR_INIT_VAL;
256 writel(src_cr, io_p2v(NOMADIK_SRC_BASE)); 247 writel(src_cr, io_p2v(NOMADIK_SRC_BASE));
257 248
258 /* Save global pointer to mtu, used by platform timer code */ 249 nmdk_timer_init(io_p2v(NOMADIK_MTU0_BASE));
259 mtu_base = io_p2v(NOMADIK_MTU0_BASE);
260
261 nmdk_timer_init();
262} 250}
263 251
264static struct sys_timer nomadik_timer = { 252static struct sys_timer nomadik_timer = {
diff --git a/arch/arm/mach-nomadik/cpu-8815.c b/arch/arm/mach-nomadik/cpu-8815.c
index 65df7b4fdd3..27f43a46985 100644
--- a/arch/arm/mach-nomadik/cpu-8815.c
+++ b/arch/arm/mach-nomadik/cpu-8815.c
@@ -97,12 +97,7 @@ static struct platform_device cpu8815_platform_gpio[] = {
97 GPIO_DEVICE(3), 97 GPIO_DEVICE(3),
98}; 98};
99 99
100static struct amba_device cpu8815_amba_rng = { 100static AMBA_APB_DEVICE(cpu8815_amba_rng, "rng", 0, NOMADIK_RNG_BASE, { }, NULL);
101 .dev = {
102 .init_name = "rng",
103 },
104 __MEM_4K_RESOURCE(NOMADIK_RNG_BASE),
105};
106 101
107static struct platform_device *platform_devs[] __initdata = { 102static struct platform_device *platform_devs[] __initdata = {
108 cpu8815_platform_gpio + 0, 103 cpu8815_platform_gpio + 0,
@@ -112,7 +107,7 @@ static struct platform_device *platform_devs[] __initdata = {
112}; 107};
113 108
114static struct amba_device *amba_devs[] __initdata = { 109static struct amba_device *amba_devs[] __initdata = {
115 &cpu8815_amba_rng 110 &cpu8815_amba_rng_device
116}; 111};
117 112
118static int __init cpu8815_init(void) 113static int __init cpu8815_init(void)
diff --git a/arch/arm/mach-nomadik/include/mach/entry-macro.S b/arch/arm/mach-nomadik/include/mach/entry-macro.S
deleted file mode 100644
index 98ea1c1fbba..00000000000
--- a/arch/arm/mach-nomadik/include/mach/entry-macro.S
+++ /dev/null
@@ -1,13 +0,0 @@
1/*
2 * Low-level IRQ helper macros for Nomadik platforms
3 *
4 * This file is licensed under the terms of the GNU General Public
5 * License version 2. This program is licensed "as is" without any
6 * warranty of any kind, whether express or implied.
7 */
8
9 .macro disable_fiq
10 .endm
11
12 .macro arch_ret_to_user, tmp1, tmp2
13 .endm
diff --git a/arch/arm/mach-nomadik/include/mach/setup.h b/arch/arm/mach-nomadik/include/mach/setup.h
deleted file mode 100644
index bcaeaf41c05..00000000000
--- a/arch/arm/mach-nomadik/include/mach/setup.h
+++ /dev/null
@@ -1,19 +0,0 @@
1
2/*
3 * These symbols are needed for board-specific files to call their
4 * own cpu-specific files
5 */
6
7#ifndef __ASM_ARCH_SETUP_H
8#define __ASM_ARCH_SETUP_H
9
10#include <asm/mach/time.h>
11#include <linux/init.h>
12
13#ifdef CONFIG_NOMADIK_8815
14
15extern void nmdk_timer_init(void);
16
17#endif /* NOMADIK_8815 */
18
19#endif /* __ASM_ARCH_SETUP_H */
diff --git a/arch/arm/mach-nomadik/include/mach/system.h b/arch/arm/mach-nomadik/include/mach/system.h
deleted file mode 100644
index 25e198b8976..00000000000
--- a/arch/arm/mach-nomadik/include/mach/system.h
+++ /dev/null
@@ -1,32 +0,0 @@
1/*
2 * mach-nomadik/include/mach/system.h
3 *
4 * Copyright (C) 2008 STMicroelectronics
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#ifndef __ASM_ARCH_SYSTEM_H
21#define __ASM_ARCH_SYSTEM_H
22
23static inline void arch_idle(void)
24{
25 /*
26 * This should do all the clock switching
27 * and wait for interrupt tricks
28 */
29 cpu_do_idle();
30}
31
32#endif
diff --git a/arch/arm/mach-omap1/Kconfig b/arch/arm/mach-omap1/Kconfig
index 922ab0dc2bc..dfab466ebd1 100644
--- a/arch/arm/mach-omap1/Kconfig
+++ b/arch/arm/mach-omap1/Kconfig
@@ -152,6 +152,10 @@ config MACH_AMS_DELTA
152 bool "Amstrad E3 (Delta)" 152 bool "Amstrad E3 (Delta)"
153 depends on ARCH_OMAP1 && ARCH_OMAP15XX 153 depends on ARCH_OMAP1 && ARCH_OMAP15XX
154 select FIQ 154 select FIQ
155 select GPIO_GENERIC_PLATFORM
156 select LEDS_GPIO_REGISTER
157 select REGULATOR
158 select REGULATOR_FIXED_VOLTAGE
155 help 159 help
156 Support for the Amstrad E3 (codename Delta) videophone. Say Y here 160 Support for the Amstrad E3 (codename Delta) videophone. Say Y here
157 if you have such a device. 161 if you have such a device.
diff --git a/arch/arm/mach-omap1/ams-delta-fiq-handler.S b/arch/arm/mach-omap1/ams-delta-fiq-handler.S
index c1c5fb6a5b4..399c4c49722 100644
--- a/arch/arm/mach-omap1/ams-delta-fiq-handler.S
+++ b/arch/arm/mach-omap1/ams-delta-fiq-handler.S
@@ -15,11 +15,12 @@
15 15
16#include <linux/linkage.h> 16#include <linux/linkage.h>
17 17
18#include <plat/io.h>
19#include <plat/board-ams-delta.h> 18#include <plat/board-ams-delta.h>
20 19
21#include <mach/ams-delta-fiq.h> 20#include <mach/ams-delta-fiq.h>
22 21
22#include "iomap.h"
23
23/* 24/*
24 * GPIO related definitions, copied from arch/arm/plat-omap/gpio.c. 25 * GPIO related definitions, copied from arch/arm/plat-omap/gpio.c.
25 * Unfortunately, those were not placed in a separate header file. 26 * Unfortunately, those were not placed in a separate header file.
diff --git a/arch/arm/mach-omap1/ams-delta-fiq.c b/arch/arm/mach-omap1/ams-delta-fiq.c
index 152b32c15e2..fcce7ff3763 100644
--- a/arch/arm/mach-omap1/ams-delta-fiq.c
+++ b/arch/arm/mach-omap1/ams-delta-fiq.c
@@ -22,6 +22,7 @@
22#include <plat/board-ams-delta.h> 22#include <plat/board-ams-delta.h>
23 23
24#include <asm/fiq.h> 24#include <asm/fiq.h>
25
25#include <mach/ams-delta-fiq.h> 26#include <mach/ams-delta-fiq.h>
26 27
27static struct fiq_handler fh = { 28static struct fiq_handler fh = {
diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index e0e8245f3c9..c1b681ef4cb 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -11,6 +11,7 @@
11 * it under the terms of the GNU General Public License version 2 as 11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation. 12 * published by the Free Software Foundation.
13 */ 13 */
14#include <linux/basic_mmio_gpio.h>
14#include <linux/gpio.h> 15#include <linux/gpio.h>
15#include <linux/kernel.h> 16#include <linux/kernel.h>
16#include <linux/init.h> 17#include <linux/init.h>
@@ -18,31 +19,33 @@
18#include <linux/interrupt.h> 19#include <linux/interrupt.h>
19#include <linux/leds.h> 20#include <linux/leds.h>
20#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/regulator/consumer.h>
23#include <linux/regulator/fixed.h>
24#include <linux/regulator/machine.h>
21#include <linux/serial_8250.h> 25#include <linux/serial_8250.h>
22#include <linux/export.h> 26#include <linux/export.h>
23#include <linux/omapfb.h> 27#include <linux/omapfb.h>
28#include <linux/io.h>
24 29
25#include <media/soc_camera.h> 30#include <media/soc_camera.h>
26 31
27#include <asm/serial.h> 32#include <asm/serial.h>
28#include <mach/hardware.h>
29#include <asm/mach-types.h> 33#include <asm/mach-types.h>
30#include <asm/mach/arch.h> 34#include <asm/mach/arch.h>
31#include <asm/mach/map.h> 35#include <asm/mach/map.h>
32 36
33#include <plat/io.h>
34#include <plat/board-ams-delta.h> 37#include <plat/board-ams-delta.h>
35#include <plat/keypad.h> 38#include <plat/keypad.h>
36#include <plat/mux.h> 39#include <plat/mux.h>
37#include <plat/usb.h> 40#include <plat/usb.h>
38#include <plat/board.h> 41#include <plat/board.h>
39#include "common.h"
40#include <mach/camera.h>
41 42
43#include <mach/hardware.h>
42#include <mach/ams-delta-fiq.h> 44#include <mach/ams-delta-fiq.h>
45#include <mach/camera.h>
43 46
44static u8 ams_delta_latch1_reg; 47#include "iomap.h"
45static u16 ams_delta_latch2_reg; 48#include "common.h"
46 49
47static const unsigned int ams_delta_keymap[] = { 50static const unsigned int ams_delta_keymap[] = {
48 KEY(0, 0, KEY_F1), /* Advert */ 51 KEY(0, 0, KEY_F1), /* Advert */
@@ -122,54 +125,188 @@ static const unsigned int ams_delta_keymap[] = {
122 KEY(7, 3, KEY_LEFTCTRL), /* Vol down */ 125 KEY(7, 3, KEY_LEFTCTRL), /* Vol down */
123}; 126};
124 127
125void ams_delta_latch1_write(u8 mask, u8 value) 128#define LATCH1_PHYS 0x01000000
126{ 129#define LATCH1_VIRT 0xEA000000
127 ams_delta_latch1_reg &= ~mask; 130#define MODEM_PHYS 0x04000000
128 ams_delta_latch1_reg |= value; 131#define MODEM_VIRT 0xEB000000
129 *(volatile __u8 *) AMS_DELTA_LATCH1_VIRT = ams_delta_latch1_reg; 132#define LATCH2_PHYS 0x08000000
130} 133#define LATCH2_VIRT 0xEC000000
131
132void ams_delta_latch2_write(u16 mask, u16 value)
133{
134 ams_delta_latch2_reg &= ~mask;
135 ams_delta_latch2_reg |= value;
136 *(volatile __u16 *) AMS_DELTA_LATCH2_VIRT = ams_delta_latch2_reg;
137}
138 134
139static struct map_desc ams_delta_io_desc[] __initdata = { 135static struct map_desc ams_delta_io_desc[] __initdata = {
140 /* AMS_DELTA_LATCH1 */ 136 /* AMS_DELTA_LATCH1 */
141 { 137 {
142 .virtual = AMS_DELTA_LATCH1_VIRT, 138 .virtual = LATCH1_VIRT,
143 .pfn = __phys_to_pfn(AMS_DELTA_LATCH1_PHYS), 139 .pfn = __phys_to_pfn(LATCH1_PHYS),
144 .length = 0x01000000, 140 .length = 0x01000000,
145 .type = MT_DEVICE 141 .type = MT_DEVICE
146 }, 142 },
147 /* AMS_DELTA_LATCH2 */ 143 /* AMS_DELTA_LATCH2 */
148 { 144 {
149 .virtual = AMS_DELTA_LATCH2_VIRT, 145 .virtual = LATCH2_VIRT,
150 .pfn = __phys_to_pfn(AMS_DELTA_LATCH2_PHYS), 146 .pfn = __phys_to_pfn(LATCH2_PHYS),
151 .length = 0x01000000, 147 .length = 0x01000000,
152 .type = MT_DEVICE 148 .type = MT_DEVICE
153 }, 149 },
154 /* AMS_DELTA_MODEM */ 150 /* AMS_DELTA_MODEM */
155 { 151 {
156 .virtual = AMS_DELTA_MODEM_VIRT, 152 .virtual = MODEM_VIRT,
157 .pfn = __phys_to_pfn(AMS_DELTA_MODEM_PHYS), 153 .pfn = __phys_to_pfn(MODEM_PHYS),
158 .length = 0x01000000, 154 .length = 0x01000000,
159 .type = MT_DEVICE 155 .type = MT_DEVICE
160 } 156 }
161}; 157};
162 158
163static struct omap_lcd_config ams_delta_lcd_config = { 159static struct omap_lcd_config ams_delta_lcd_config __initdata = {
164 .ctrl_name = "internal", 160 .ctrl_name = "internal",
165}; 161};
166 162
167static struct omap_usb_config ams_delta_usb_config __initdata = { 163static struct omap_usb_config ams_delta_usb_config = {
168 .register_host = 1, 164 .register_host = 1,
169 .hmc_mode = 16, 165 .hmc_mode = 16,
170 .pins[0] = 2, 166 .pins[0] = 2,
171}; 167};
172 168
169#define LATCH1_GPIO_BASE 232
170#define LATCH1_NGPIO 8
171
172static struct resource latch1_resources[] = {
173 [0] = {
174 .name = "dat",
175 .start = LATCH1_PHYS,
176 .end = LATCH1_PHYS + (LATCH1_NGPIO - 1) / 8,
177 .flags = IORESOURCE_MEM,
178 },
179};
180
181static struct bgpio_pdata latch1_pdata = {
182 .base = LATCH1_GPIO_BASE,
183 .ngpio = LATCH1_NGPIO,
184};
185
186static struct platform_device latch1_gpio_device = {
187 .name = "basic-mmio-gpio",
188 .id = 0,
189 .resource = latch1_resources,
190 .num_resources = ARRAY_SIZE(latch1_resources),
191 .dev = {
192 .platform_data = &latch1_pdata,
193 },
194};
195
196static struct resource latch2_resources[] = {
197 [0] = {
198 .name = "dat",
199 .start = LATCH2_PHYS,
200 .end = LATCH2_PHYS + (AMS_DELTA_LATCH2_NGPIO - 1) / 8,
201 .flags = IORESOURCE_MEM,
202 },
203};
204
205static struct bgpio_pdata latch2_pdata = {
206 .base = AMS_DELTA_LATCH2_GPIO_BASE,
207 .ngpio = AMS_DELTA_LATCH2_NGPIO,
208};
209
210static struct platform_device latch2_gpio_device = {
211 .name = "basic-mmio-gpio",
212 .id = 1,
213 .resource = latch2_resources,
214 .num_resources = ARRAY_SIZE(latch2_resources),
215 .dev = {
216 .platform_data = &latch2_pdata,
217 },
218};
219
220static const struct gpio latch_gpios[] __initconst = {
221 {
222 .gpio = LATCH1_GPIO_BASE + 6,
223 .flags = GPIOF_OUT_INIT_LOW,
224 .label = "dockit1",
225 },
226 {
227 .gpio = LATCH1_GPIO_BASE + 7,
228 .flags = GPIOF_OUT_INIT_LOW,
229 .label = "dockit2",
230 },
231 {
232 .gpio = AMS_DELTA_GPIO_PIN_SCARD_RSTIN,
233 .flags = GPIOF_OUT_INIT_LOW,
234 .label = "scard_rstin",
235 },
236 {
237 .gpio = AMS_DELTA_GPIO_PIN_SCARD_CMDVCC,
238 .flags = GPIOF_OUT_INIT_LOW,
239 .label = "scard_cmdvcc",
240 },
241 {
242 .gpio = AMS_DELTA_GPIO_PIN_MODEM_CODEC,
243 .flags = GPIOF_OUT_INIT_LOW,
244 .label = "modem_codec",
245 },
246 {
247 .gpio = AMS_DELTA_LATCH2_GPIO_BASE + 14,
248 .flags = GPIOF_OUT_INIT_LOW,
249 .label = "hookflash1",
250 },
251 {
252 .gpio = AMS_DELTA_LATCH2_GPIO_BASE + 15,
253 .flags = GPIOF_OUT_INIT_LOW,
254 .label = "hookflash2",
255 },
256};
257
258static struct regulator_consumer_supply modem_nreset_consumers[] = {
259 REGULATOR_SUPPLY("RESET#", "serial8250.1"),
260 REGULATOR_SUPPLY("POR", "cx20442-codec"),
261};
262
263static struct regulator_init_data modem_nreset_data = {
264 .constraints = {
265 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
266 .boot_on = 1,
267 },
268 .num_consumer_supplies = ARRAY_SIZE(modem_nreset_consumers),
269 .consumer_supplies = modem_nreset_consumers,
270};
271
272static struct fixed_voltage_config modem_nreset_config = {
273 .supply_name = "modem_nreset",
274 .microvolts = 3300000,
275 .gpio = AMS_DELTA_GPIO_PIN_MODEM_NRESET,
276 .startup_delay = 25000,
277 .enable_high = 1,
278 .enabled_at_boot = 1,
279 .init_data = &modem_nreset_data,
280};
281
282static struct platform_device modem_nreset_device = {
283 .name = "reg-fixed-voltage",
284 .id = -1,
285 .dev = {
286 .platform_data = &modem_nreset_config,
287 },
288};
289
290struct modem_private_data {
291 struct regulator *regulator;
292};
293
294static struct modem_private_data modem_priv;
295
296void ams_delta_latch_write(int base, int ngpio, u16 mask, u16 value)
297{
298 int bit = 0;
299 u16 bitpos = 1 << bit;
300
301 for (; bit < ngpio; bit++, bitpos = bitpos << 1) {
302 if (!(mask & bitpos))
303 continue;
304 else
305 gpio_set_value(base + bit, (value & bitpos) != 0);
306 }
307}
308EXPORT_SYMBOL(ams_delta_latch_write);
309
173static struct resource ams_delta_nand_resources[] = { 310static struct resource ams_delta_nand_resources[] = {
174 [0] = { 311 [0] = {
175 .start = OMAP1_MPUIO_BASE, 312 .start = OMAP1_MPUIO_BASE,
@@ -199,7 +336,7 @@ static const struct matrix_keymap_data ams_delta_keymap_data = {
199 .keymap_size = ARRAY_SIZE(ams_delta_keymap), 336 .keymap_size = ARRAY_SIZE(ams_delta_keymap),
200}; 337};
201 338
202static struct omap_kp_platform_data ams_delta_kp_data __initdata = { 339static struct omap_kp_platform_data ams_delta_kp_data = {
203 .rows = 8, 340 .rows = 8,
204 .cols = 8, 341 .cols = 8,
205 .keymap_data = &ams_delta_keymap_data, 342 .keymap_data = &ams_delta_keymap_data,
@@ -221,9 +358,45 @@ static struct platform_device ams_delta_lcd_device = {
221 .id = -1, 358 .id = -1,
222}; 359};
223 360
224static struct platform_device ams_delta_led_device = { 361static const struct gpio_led gpio_leds[] __initconst = {
225 .name = "ams-delta-led", 362 {
226 .id = -1 363 .name = "camera",
364 .gpio = LATCH1_GPIO_BASE + 0,
365 .default_state = LEDS_GPIO_DEFSTATE_OFF,
366#ifdef CONFIG_LEDS_TRIGGERS
367 .default_trigger = "ams_delta_camera",
368#endif
369 },
370 {
371 .name = "advert",
372 .gpio = LATCH1_GPIO_BASE + 1,
373 .default_state = LEDS_GPIO_DEFSTATE_OFF,
374 },
375 {
376 .name = "email",
377 .gpio = LATCH1_GPIO_BASE + 2,
378 .default_state = LEDS_GPIO_DEFSTATE_OFF,
379 },
380 {
381 .name = "handsfree",
382 .gpio = LATCH1_GPIO_BASE + 3,
383 .default_state = LEDS_GPIO_DEFSTATE_OFF,
384 },
385 {
386 .name = "voicemail",
387 .gpio = LATCH1_GPIO_BASE + 4,
388 .default_state = LEDS_GPIO_DEFSTATE_OFF,
389 },
390 {
391 .name = "voice",
392 .gpio = LATCH1_GPIO_BASE + 5,
393 .default_state = LEDS_GPIO_DEFSTATE_OFF,
394 },
395};
396
397static const struct gpio_led_platform_data leds_pdata __initconst = {
398 .leds = gpio_leds,
399 .num_leds = ARRAY_SIZE(gpio_leds),
227}; 400};
228 401
229static struct i2c_board_info ams_delta_camera_board_info[] = { 402static struct i2c_board_info ams_delta_camera_board_info[] = {
@@ -272,13 +445,17 @@ static struct omap1_cam_platform_data ams_delta_camera_platform_data = {
272}; 445};
273 446
274static struct platform_device *ams_delta_devices[] __initdata = { 447static struct platform_device *ams_delta_devices[] __initdata = {
275 &ams_delta_nand_device, 448 &latch1_gpio_device,
449 &latch2_gpio_device,
276 &ams_delta_kp_device, 450 &ams_delta_kp_device,
277 &ams_delta_lcd_device,
278 &ams_delta_led_device,
279 &ams_delta_camera_device, 451 &ams_delta_camera_device,
280}; 452};
281 453
454static struct platform_device *late_devices[] __initdata = {
455 &ams_delta_nand_device,
456 &ams_delta_lcd_device,
457};
458
282static void __init ams_delta_init(void) 459static void __init ams_delta_init(void)
283{ 460{
284 /* mux pins for uarts */ 461 /* mux pins for uarts */
@@ -302,15 +479,13 @@ static void __init ams_delta_init(void)
302 omap_serial_init(); 479 omap_serial_init();
303 omap_register_i2c_bus(1, 100, NULL, 0); 480 omap_register_i2c_bus(1, 100, NULL, 0);
304 481
305 /* Clear latch2 (NAND, LCD, modem enable) */
306 ams_delta_latch2_write(~0, 0);
307
308 omap1_usb_init(&ams_delta_usb_config); 482 omap1_usb_init(&ams_delta_usb_config);
309 omap1_set_camera_info(&ams_delta_camera_platform_data); 483 omap1_set_camera_info(&ams_delta_camera_platform_data);
310#ifdef CONFIG_LEDS_TRIGGERS 484#ifdef CONFIG_LEDS_TRIGGERS
311 led_trigger_register_simple("ams_delta_camera", 485 led_trigger_register_simple("ams_delta_camera",
312 &ams_delta_camera_led_trigger); 486 &ams_delta_camera_led_trigger);
313#endif 487#endif
488 gpio_led_register_device(-1, &leds_pdata);
314 platform_add_devices(ams_delta_devices, ARRAY_SIZE(ams_delta_devices)); 489 platform_add_devices(ams_delta_devices, ARRAY_SIZE(ams_delta_devices));
315 490
316 ams_delta_init_fiq(); 491 ams_delta_init_fiq();
@@ -320,16 +495,34 @@ static void __init ams_delta_init(void)
320 omapfb_set_lcd_config(&ams_delta_lcd_config); 495 omapfb_set_lcd_config(&ams_delta_lcd_config);
321} 496}
322 497
498static void modem_pm(struct uart_port *port, unsigned int state, unsigned old)
499{
500 struct modem_private_data *priv = port->private_data;
501
502 if (IS_ERR(priv->regulator))
503 return;
504
505 if (state == old)
506 return;
507
508 if (state == 0)
509 regulator_enable(priv->regulator);
510 else if (old == 0)
511 regulator_disable(priv->regulator);
512}
513
323static struct plat_serial8250_port ams_delta_modem_ports[] = { 514static struct plat_serial8250_port ams_delta_modem_ports[] = {
324 { 515 {
325 .membase = IOMEM(AMS_DELTA_MODEM_VIRT), 516 .membase = IOMEM(MODEM_VIRT),
326 .mapbase = AMS_DELTA_MODEM_PHYS, 517 .mapbase = MODEM_PHYS,
327 .irq = -EINVAL, /* changed later */ 518 .irq = -EINVAL, /* changed later */
328 .flags = UPF_BOOT_AUTOCONF, 519 .flags = UPF_BOOT_AUTOCONF,
329 .irqflags = IRQF_TRIGGER_RISING, 520 .irqflags = IRQF_TRIGGER_RISING,
330 .iotype = UPIO_MEM, 521 .iotype = UPIO_MEM,
331 .regshift = 1, 522 .regshift = 1,
332 .uartclk = BASE_BAUD * 16, 523 .uartclk = BASE_BAUD * 16,
524 .pm = modem_pm,
525 .private_data = &modem_priv,
333 }, 526 },
334 { }, 527 { },
335}; 528};
@@ -342,13 +535,27 @@ static struct platform_device ams_delta_modem_device = {
342 }, 535 },
343}; 536};
344 537
345static int __init ams_delta_modem_init(void) 538static int __init late_init(void)
346{ 539{
347 int err; 540 int err;
348 541
349 if (!machine_is_ams_delta()) 542 if (!machine_is_ams_delta())
350 return -ENODEV; 543 return -ENODEV;
351 544
545 err = gpio_request_array(latch_gpios, ARRAY_SIZE(latch_gpios));
546 if (err) {
547 pr_err("Couldn't take over latch1/latch2 GPIO pins\n");
548 return err;
549 }
550
551 platform_add_devices(late_devices, ARRAY_SIZE(late_devices));
552
553 err = platform_device_register(&modem_nreset_device);
554 if (err) {
555 pr_err("Couldn't register the modem regulator device\n");
556 return err;
557 }
558
352 omap_cfg_reg(M14_1510_GPIO2); 559 omap_cfg_reg(M14_1510_GPIO2);
353 ams_delta_modem_ports[0].irq = 560 ams_delta_modem_ports[0].irq =
354 gpio_to_irq(AMS_DELTA_GPIO_PIN_MODEM_IRQ); 561 gpio_to_irq(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
@@ -360,13 +567,35 @@ static int __init ams_delta_modem_init(void)
360 } 567 }
361 gpio_direction_input(AMS_DELTA_GPIO_PIN_MODEM_IRQ); 568 gpio_direction_input(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
362 569
363 ams_delta_latch2_write( 570 /* Initialize the modem_nreset regulator consumer before use */
364 AMS_DELTA_LATCH2_MODEM_NRESET | AMS_DELTA_LATCH2_MODEM_CODEC, 571 modem_priv.regulator = ERR_PTR(-ENODEV);
365 AMS_DELTA_LATCH2_MODEM_NRESET | AMS_DELTA_LATCH2_MODEM_CODEC); 572
573 ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_CODEC,
574 AMS_DELTA_LATCH2_MODEM_CODEC);
366 575
367 return platform_device_register(&ams_delta_modem_device); 576 err = platform_device_register(&ams_delta_modem_device);
577 if (err)
578 goto gpio_free;
579
580 /*
581 * Once the modem device is registered, the modem_nreset
582 * regulator can be requested on behalf of that device.
583 */
584 modem_priv.regulator = regulator_get(&ams_delta_modem_device.dev,
585 "RESET#");
586 if (IS_ERR(modem_priv.regulator)) {
587 err = PTR_ERR(modem_priv.regulator);
588 goto unregister;
589 }
590 return 0;
591
592unregister:
593 platform_device_unregister(&ams_delta_modem_device);
594gpio_free:
595 gpio_free(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
596 return err;
368} 597}
369arch_initcall(ams_delta_modem_init); 598late_initcall(late_init);
370 599
371static void __init ams_delta_map_io(void) 600static void __init ams_delta_map_io(void)
372{ 601{
@@ -385,6 +614,3 @@ MACHINE_START(AMS_DELTA, "Amstrad E3 (Delta)")
385 .timer = &omap1_timer, 614 .timer = &omap1_timer,
386 .restart = omap1_restart, 615 .restart = omap1_restart,
387MACHINE_END 616MACHINE_END
388
389EXPORT_SYMBOL(ams_delta_latch1_write);
390EXPORT_SYMBOL(ams_delta_latch2_write);
diff --git a/arch/arm/mach-omap1/board-fsample.c b/arch/arm/mach-omap1/board-fsample.c
index 7afaf3c5bdc..80bd43c7f4e 100644
--- a/arch/arm/mach-omap1/board-fsample.c
+++ b/arch/arm/mach-omap1/board-fsample.c
@@ -23,7 +23,6 @@
23#include <linux/smc91x.h> 23#include <linux/smc91x.h>
24#include <linux/omapfb.h> 24#include <linux/omapfb.h>
25 25
26#include <mach/hardware.h>
27#include <asm/mach-types.h> 26#include <asm/mach-types.h>
28#include <asm/mach/arch.h> 27#include <asm/mach/arch.h>
29#include <asm/mach/map.h> 28#include <asm/mach/map.h>
@@ -33,9 +32,13 @@
33#include <plat/flash.h> 32#include <plat/flash.h>
34#include <plat/fpga.h> 33#include <plat/fpga.h>
35#include <plat/keypad.h> 34#include <plat/keypad.h>
36#include "common.h"
37#include <plat/board.h> 35#include <plat/board.h>
38 36
37#include <mach/hardware.h>
38
39#include "iomap.h"
40#include "common.h"
41
39/* fsample is pretty close to p2-sample */ 42/* fsample is pretty close to p2-sample */
40 43
41#define fsample_cpld_read(reg) __raw_readb(reg) 44#define fsample_cpld_read(reg) __raw_readb(reg)
diff --git a/arch/arm/mach-omap1/board-h2.c b/arch/arm/mach-omap1/board-h2.c
index af2be8c12c0..c3068622fdc 100644
--- a/arch/arm/mach-omap1/board-h2.c
+++ b/arch/arm/mach-omap1/board-h2.c
@@ -32,8 +32,6 @@
32#include <linux/smc91x.h> 32#include <linux/smc91x.h>
33#include <linux/omapfb.h> 33#include <linux/omapfb.h>
34 34
35#include <mach/hardware.h>
36
37#include <asm/mach-types.h> 35#include <asm/mach-types.h>
38#include <asm/mach/arch.h> 36#include <asm/mach/arch.h>
39#include <asm/mach/map.h> 37#include <asm/mach/map.h>
@@ -44,9 +42,11 @@
44#include <plat/irda.h> 42#include <plat/irda.h>
45#include <plat/usb.h> 43#include <plat/usb.h>
46#include <plat/keypad.h> 44#include <plat/keypad.h>
47#include "common.h"
48#include <plat/flash.h> 45#include <plat/flash.h>
49 46
47#include <mach/hardware.h>
48
49#include "common.h"
50#include "board-h2.h" 50#include "board-h2.h"
51 51
52/* At OMAP1610 Innovator the Ethernet is directly connected to CS1 */ 52/* At OMAP1610 Innovator the Ethernet is directly connected to CS1 */
diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c
index 7cfd25b9073..64b8584f64c 100644
--- a/arch/arm/mach-omap1/board-h3.c
+++ b/arch/arm/mach-omap1/board-h3.c
@@ -34,21 +34,21 @@
34 34
35#include <asm/setup.h> 35#include <asm/setup.h>
36#include <asm/page.h> 36#include <asm/page.h>
37#include <mach/hardware.h>
38
39#include <asm/mach-types.h> 37#include <asm/mach-types.h>
40#include <asm/mach/arch.h> 38#include <asm/mach/arch.h>
41#include <asm/mach/map.h> 39#include <asm/mach/map.h>
42 40
43#include <mach/irqs.h>
44#include <plat/mux.h> 41#include <plat/mux.h>
45#include <plat/tc.h> 42#include <plat/tc.h>
46#include <plat/usb.h> 43#include <plat/usb.h>
47#include <plat/keypad.h> 44#include <plat/keypad.h>
48#include <plat/dma.h> 45#include <plat/dma.h>
49#include "common.h"
50#include <plat/flash.h> 46#include <plat/flash.h>
51 47
48#include <mach/hardware.h>
49#include <mach/irqs.h>
50
51#include "common.h"
52#include "board-h3.h" 52#include "board-h3.h"
53 53
54/* In OMAP1710 H3 the Ethernet is directly connected to CS1 */ 54/* In OMAP1710 H3 the Ethernet is directly connected to CS1 */
diff --git a/arch/arm/mach-omap1/board-htcherald.c b/arch/arm/mach-omap1/board-htcherald.c
index af2afcf24f7..827d83a96af 100644
--- a/arch/arm/mach-omap1/board-htcherald.c
+++ b/arch/arm/mach-omap1/board-htcherald.c
@@ -27,7 +27,7 @@
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/platform_device.h> 28#include <linux/platform_device.h>
29#include <linux/input.h> 29#include <linux/input.h>
30#include <linux/io.h> 30#include <linux/delay.h>
31#include <linux/gpio.h> 31#include <linux/gpio.h>
32#include <linux/gpio_keys.h> 32#include <linux/gpio_keys.h>
33#include <linux/i2c.h> 33#include <linux/i2c.h>
@@ -42,7 +42,6 @@
42#include <asm/mach/arch.h> 42#include <asm/mach/arch.h>
43 43
44#include <plat/omap7xx.h> 44#include <plat/omap7xx.h>
45#include "common.h"
46#include <plat/board.h> 45#include <plat/board.h>
47#include <plat/keypad.h> 46#include <plat/keypad.h>
48#include <plat/usb.h> 47#include <plat/usb.h>
@@ -50,7 +49,7 @@
50 49
51#include <mach/irqs.h> 50#include <mach/irqs.h>
52 51
53#include <linux/delay.h> 52#include "common.h"
54 53
55/* LCD register definition */ 54/* LCD register definition */
56#define OMAP_LCDC_CONTROL (0xfffec000 + 0x00) 55#define OMAP_LCDC_CONTROL (0xfffec000 + 0x00)
diff --git a/arch/arm/mach-omap1/board-innovator.c b/arch/arm/mach-omap1/board-innovator.c
index 1d5ab6606b9..61219182d16 100644
--- a/arch/arm/mach-omap1/board-innovator.c
+++ b/arch/arm/mach-omap1/board-innovator.c
@@ -27,7 +27,6 @@
27#include <linux/smc91x.h> 27#include <linux/smc91x.h>
28#include <linux/omapfb.h> 28#include <linux/omapfb.h>
29 29
30#include <mach/hardware.h>
31#include <asm/mach-types.h> 30#include <asm/mach-types.h>
32#include <asm/mach/arch.h> 31#include <asm/mach/arch.h>
33#include <asm/mach/map.h> 32#include <asm/mach/map.h>
@@ -38,9 +37,13 @@
38#include <plat/tc.h> 37#include <plat/tc.h>
39#include <plat/usb.h> 38#include <plat/usb.h>
40#include <plat/keypad.h> 39#include <plat/keypad.h>
41#include "common.h"
42#include <plat/mmc.h> 40#include <plat/mmc.h>
43 41
42#include <mach/hardware.h>
43
44#include "iomap.h"
45#include "common.h"
46
44/* At OMAP1610 Innovator the Ethernet is directly connected to CS1 */ 47/* At OMAP1610 Innovator the Ethernet is directly connected to CS1 */
45#define INNOVATOR1610_ETHR_START 0x04000300 48#define INNOVATOR1610_ETHR_START 0x04000300
46 49
diff --git a/arch/arm/mach-omap1/board-nokia770.c b/arch/arm/mach-omap1/board-nokia770.c
index 9b6332a31fb..fe95ec5f6f0 100644
--- a/arch/arm/mach-omap1/board-nokia770.c
+++ b/arch/arm/mach-omap1/board-nokia770.c
@@ -21,7 +21,6 @@
21#include <linux/workqueue.h> 21#include <linux/workqueue.h>
22#include <linux/delay.h> 22#include <linux/delay.h>
23 23
24#include <mach/hardware.h>
25#include <asm/mach-types.h> 24#include <asm/mach-types.h>
26#include <asm/mach/arch.h> 25#include <asm/mach/arch.h>
27#include <asm/mach/map.h> 26#include <asm/mach/map.h>
@@ -30,11 +29,14 @@
30#include <plat/usb.h> 29#include <plat/usb.h>
31#include <plat/board.h> 30#include <plat/board.h>
32#include <plat/keypad.h> 31#include <plat/keypad.h>
33#include "common.h"
34#include <plat/lcd_mipid.h> 32#include <plat/lcd_mipid.h>
35#include <plat/mmc.h> 33#include <plat/mmc.h>
36#include <plat/clock.h> 34#include <plat/clock.h>
37 35
36#include <mach/hardware.h>
37
38#include "common.h"
39
38#define ADS7846_PENDOWN_GPIO 15 40#define ADS7846_PENDOWN_GPIO 15
39 41
40static const unsigned int nokia770_keymap[] = { 42static const unsigned int nokia770_keymap[] = {
diff --git a/arch/arm/mach-omap1/board-osk.c b/arch/arm/mach-omap1/board-osk.c
index ef874655fbd..1fe347396f4 100644
--- a/arch/arm/mach-omap1/board-osk.c
+++ b/arch/arm/mach-omap1/board-osk.c
@@ -35,15 +35,11 @@
35#include <linux/leds.h> 35#include <linux/leds.h>
36#include <linux/smc91x.h> 36#include <linux/smc91x.h>
37#include <linux/omapfb.h> 37#include <linux/omapfb.h>
38
39#include <linux/mtd/mtd.h> 38#include <linux/mtd/mtd.h>
40#include <linux/mtd/partitions.h> 39#include <linux/mtd/partitions.h>
41#include <linux/mtd/physmap.h> 40#include <linux/mtd/physmap.h>
42
43#include <linux/i2c/tps65010.h> 41#include <linux/i2c/tps65010.h>
44 42
45#include <mach/hardware.h>
46
47#include <asm/mach-types.h> 43#include <asm/mach-types.h>
48#include <asm/mach/arch.h> 44#include <asm/mach/arch.h>
49#include <asm/mach/map.h> 45#include <asm/mach/map.h>
@@ -52,6 +48,9 @@
52#include <plat/usb.h> 48#include <plat/usb.h>
53#include <plat/mux.h> 49#include <plat/mux.h>
54#include <plat/tc.h> 50#include <plat/tc.h>
51
52#include <mach/hardware.h>
53
55#include "common.h" 54#include "common.h"
56 55
57/* At OMAP5912 OSK the Ethernet is directly connected to CS1 */ 56/* At OMAP5912 OSK the Ethernet is directly connected to CS1 */
diff --git a/arch/arm/mach-omap1/board-palmte.c b/arch/arm/mach-omap1/board-palmte.c
index 612342cb2a2..0863d8e2bdf 100644
--- a/arch/arm/mach-omap1/board-palmte.c
+++ b/arch/arm/mach-omap1/board-palmte.c
@@ -29,7 +29,6 @@
29#include <linux/apm-emulation.h> 29#include <linux/apm-emulation.h>
30#include <linux/omapfb.h> 30#include <linux/omapfb.h>
31 31
32#include <mach/hardware.h>
33#include <asm/mach-types.h> 32#include <asm/mach-types.h>
34#include <asm/mach/arch.h> 33#include <asm/mach/arch.h>
35#include <asm/mach/map.h> 34#include <asm/mach/map.h>
@@ -42,6 +41,9 @@
42#include <plat/board.h> 41#include <plat/board.h>
43#include <plat/irda.h> 42#include <plat/irda.h>
44#include <plat/keypad.h> 43#include <plat/keypad.h>
44
45#include <mach/hardware.h>
46
45#include "common.h" 47#include "common.h"
46 48
47#define PALMTE_USBDETECT_GPIO 0 49#define PALMTE_USBDETECT_GPIO 0
diff --git a/arch/arm/mach-omap1/board-palmtt.c b/arch/arm/mach-omap1/board-palmtt.c
index b63350bc88f..4ff699c509c 100644
--- a/arch/arm/mach-omap1/board-palmtt.c
+++ b/arch/arm/mach-omap1/board-palmtt.c
@@ -25,8 +25,9 @@
25#include <linux/mtd/physmap.h> 25#include <linux/mtd/physmap.h>
26#include <linux/leds.h> 26#include <linux/leds.h>
27#include <linux/omapfb.h> 27#include <linux/omapfb.h>
28#include <linux/spi/spi.h>
29#include <linux/spi/ads7846.h>
28 30
29#include <mach/hardware.h>
30#include <asm/mach-types.h> 31#include <asm/mach-types.h>
31#include <asm/mach/arch.h> 32#include <asm/mach/arch.h>
32#include <asm/mach/map.h> 33#include <asm/mach/map.h>
@@ -40,10 +41,10 @@
40#include <plat/board.h> 41#include <plat/board.h>
41#include <plat/irda.h> 42#include <plat/irda.h>
42#include <plat/keypad.h> 43#include <plat/keypad.h>
43#include "common.h"
44 44
45#include <linux/spi/spi.h> 45#include <mach/hardware.h>
46#include <linux/spi/ads7846.h> 46
47#include "common.h"
47 48
48#define PALMTT_USBDETECT_GPIO 0 49#define PALMTT_USBDETECT_GPIO 0
49#define PALMTT_CABLE_GPIO 1 50#define PALMTT_CABLE_GPIO 1
diff --git a/arch/arm/mach-omap1/board-palmz71.c b/arch/arm/mach-omap1/board-palmz71.c
index 9924c70af09..abcbbd339ae 100644
--- a/arch/arm/mach-omap1/board-palmz71.c
+++ b/arch/arm/mach-omap1/board-palmz71.c
@@ -28,8 +28,9 @@
28#include <linux/mtd/partitions.h> 28#include <linux/mtd/partitions.h>
29#include <linux/mtd/physmap.h> 29#include <linux/mtd/physmap.h>
30#include <linux/omapfb.h> 30#include <linux/omapfb.h>
31#include <linux/spi/spi.h>
32#include <linux/spi/ads7846.h>
31 33
32#include <mach/hardware.h>
33#include <asm/mach-types.h> 34#include <asm/mach-types.h>
34#include <asm/mach/arch.h> 35#include <asm/mach/arch.h>
35#include <asm/mach/map.h> 36#include <asm/mach/map.h>
@@ -42,10 +43,10 @@
42#include <plat/board.h> 43#include <plat/board.h>
43#include <plat/irda.h> 44#include <plat/irda.h>
44#include <plat/keypad.h> 45#include <plat/keypad.h>
45#include "common.h"
46 46
47#include <linux/spi/spi.h> 47#include <mach/hardware.h>
48#include <linux/spi/ads7846.h> 48
49#include "common.h"
49 50
50#define PALMZ71_USBDETECT_GPIO 0 51#define PALMZ71_USBDETECT_GPIO 0
51#define PALMZ71_PENIRQ_GPIO 6 52#define PALMZ71_PENIRQ_GPIO 6
diff --git a/arch/arm/mach-omap1/board-perseus2.c b/arch/arm/mach-omap1/board-perseus2.c
index 8e0153447c6..76d4ee05a81 100644
--- a/arch/arm/mach-omap1/board-perseus2.c
+++ b/arch/arm/mach-omap1/board-perseus2.c
@@ -23,7 +23,6 @@
23#include <linux/smc91x.h> 23#include <linux/smc91x.h>
24#include <linux/omapfb.h> 24#include <linux/omapfb.h>
25 25
26#include <mach/hardware.h>
27#include <asm/mach-types.h> 26#include <asm/mach-types.h>
28#include <asm/mach/arch.h> 27#include <asm/mach/arch.h>
29#include <asm/mach/map.h> 28#include <asm/mach/map.h>
@@ -33,9 +32,13 @@
33#include <plat/fpga.h> 32#include <plat/fpga.h>
34#include <plat/flash.h> 33#include <plat/flash.h>
35#include <plat/keypad.h> 34#include <plat/keypad.h>
36#include "common.h"
37#include <plat/board.h> 35#include <plat/board.h>
38 36
37#include <mach/hardware.h>
38
39#include "iomap.h"
40#include "common.h"
41
39static const unsigned int p2_keymap[] = { 42static const unsigned int p2_keymap[] = {
40 KEY(0, 0, KEY_UP), 43 KEY(0, 0, KEY_UP),
41 KEY(1, 0, KEY_RIGHT), 44 KEY(1, 0, KEY_RIGHT),
diff --git a/arch/arm/mach-omap1/board-sx1.c b/arch/arm/mach-omap1/board-sx1.c
index 0c76e12337d..f34cb74a9f4 100644
--- a/arch/arm/mach-omap1/board-sx1.c
+++ b/arch/arm/mach-omap1/board-sx1.c
@@ -29,7 +29,6 @@
29#include <linux/export.h> 29#include <linux/export.h>
30#include <linux/omapfb.h> 30#include <linux/omapfb.h>
31 31
32#include <mach/hardware.h>
33#include <asm/mach-types.h> 32#include <asm/mach-types.h>
34#include <asm/mach/arch.h> 33#include <asm/mach/arch.h>
35#include <asm/mach/map.h> 34#include <asm/mach/map.h>
@@ -41,10 +40,13 @@
41#include <plat/usb.h> 40#include <plat/usb.h>
42#include <plat/tc.h> 41#include <plat/tc.h>
43#include <plat/board.h> 42#include <plat/board.h>
44#include "common.h"
45#include <plat/keypad.h> 43#include <plat/keypad.h>
46#include <plat/board-sx1.h> 44#include <plat/board-sx1.h>
47 45
46#include <mach/hardware.h>
47
48#include "common.h"
49
48/* Write to I2C device */ 50/* Write to I2C device */
49int sx1_i2c_write_byte(u8 devaddr, u8 regoffset, u8 value) 51int sx1_i2c_write_byte(u8 devaddr, u8 regoffset, u8 value)
50{ 52{
diff --git a/arch/arm/mach-omap1/board-voiceblue.c b/arch/arm/mach-omap1/board-voiceblue.c
index f83a502dc93..659d0f75de2 100644
--- a/arch/arm/mach-omap1/board-voiceblue.c
+++ b/arch/arm/mach-omap1/board-voiceblue.c
@@ -27,18 +27,20 @@
27#include <linux/smc91x.h> 27#include <linux/smc91x.h>
28#include <linux/export.h> 28#include <linux/export.h>
29 29
30#include <mach/hardware.h>
31#include <asm/mach-types.h> 30#include <asm/mach-types.h>
32#include <asm/mach/arch.h> 31#include <asm/mach/arch.h>
33#include <asm/mach/map.h> 32#include <asm/mach/map.h>
34 33
35#include <plat/board-voiceblue.h> 34#include <plat/board-voiceblue.h>
36#include "common.h"
37#include <plat/flash.h> 35#include <plat/flash.h>
38#include <plat/mux.h> 36#include <plat/mux.h>
39#include <plat/tc.h> 37#include <plat/tc.h>
40#include <plat/usb.h> 38#include <plat/usb.h>
41 39
40#include <mach/hardware.h>
41
42#include "common.h"
43
42static struct plat_serial8250_port voiceblue_ports[] = { 44static struct plat_serial8250_port voiceblue_ports[] = {
43 { 45 {
44 .mapbase = (unsigned long)(OMAP_CS1_PHYS + 0x40000), 46 .mapbase = (unsigned long)(OMAP_CS1_PHYS + 0x40000),
diff --git a/arch/arm/mach-omap1/clock.c b/arch/arm/mach-omap1/clock.c
index 0c50df05d13..67382ddd8c8 100644
--- a/arch/arm/mach-omap1/clock.c
+++ b/arch/arm/mach-omap1/clock.c
@@ -15,8 +15,8 @@
15#include <linux/list.h> 15#include <linux/list.h>
16#include <linux/errno.h> 16#include <linux/errno.h>
17#include <linux/err.h> 17#include <linux/err.h>
18#include <linux/clk.h>
19#include <linux/io.h> 18#include <linux/io.h>
19#include <linux/clk.h>
20#include <linux/clkdev.h> 20#include <linux/clkdev.h>
21 21
22#include <asm/mach-types.h> 22#include <asm/mach-types.h>
@@ -27,6 +27,9 @@
27#include <plat/sram.h> 27#include <plat/sram.h>
28#include <plat/clkdev_omap.h> 28#include <plat/clkdev_omap.h>
29 29
30#include <mach/hardware.h>
31
32#include "iomap.h"
30#include "clock.h" 33#include "clock.h"
31#include "opp.h" 34#include "opp.h"
32 35
diff --git a/arch/arm/mach-omap1/clock_data.c b/arch/arm/mach-omap1/clock_data.c
index 94699a82a73..c6ce93f71d0 100644
--- a/arch/arm/mach-omap1/clock_data.c
+++ b/arch/arm/mach-omap1/clock_data.c
@@ -15,10 +15,10 @@
15 */ 15 */
16 16
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/io.h>
18#include <linux/clk.h> 19#include <linux/clk.h>
19#include <linux/cpufreq.h> 20#include <linux/cpufreq.h>
20#include <linux/delay.h> 21#include <linux/delay.h>
21#include <linux/io.h>
22 22
23#include <asm/mach-types.h> /* for machine_is_* */ 23#include <asm/mach-types.h> /* for machine_is_* */
24 24
@@ -28,6 +28,9 @@
28#include <plat/sram.h> /* for omap_sram_reprogram_clock() */ 28#include <plat/sram.h> /* for omap_sram_reprogram_clock() */
29#include <plat/usb.h> /* for OTG_BASE */ 29#include <plat/usb.h> /* for OTG_BASE */
30 30
31#include <mach/hardware.h>
32
33#include "iomap.h"
31#include "clock.h" 34#include "clock.h"
32 35
33/* Some ARM_IDLECT1 bit shifts - used in struct arm_idlect1_clk */ 36/* Some ARM_IDLECT1 bit shifts - used in struct arm_idlect1_clk */
diff --git a/arch/arm/mach-omap1/common.h b/arch/arm/mach-omap1/common.h
index a9a5146dd2d..af658ad338e 100644
--- a/arch/arm/mach-omap1/common.h
+++ b/arch/arm/mach-omap1/common.h
@@ -58,5 +58,6 @@ void omap1_restart(char, const char *);
58 58
59extern struct sys_timer omap1_timer; 59extern struct sys_timer omap1_timer;
60extern bool omap_32k_timer_init(void); 60extern bool omap_32k_timer_init(void);
61extern void __init omap_init_consistent_dma_size(void);
61 62
62#endif /* __ARCH_ARM_MACH_OMAP1_COMMON_H */ 63#endif /* __ARCH_ARM_MACH_OMAP1_COMMON_H */
diff --git a/arch/arm/mach-omap1/devices.c b/arch/arm/mach-omap1/devices.c
index 187b2fe132e..dcd8ddbec2b 100644
--- a/arch/arm/mach-omap1/devices.c
+++ b/arch/arm/mach-omap1/devices.c
@@ -15,20 +15,20 @@
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/io.h>
19#include <linux/spi/spi.h> 18#include <linux/spi/spi.h>
20 19
21#include <mach/camera.h>
22#include <mach/hardware.h>
23#include <asm/mach/map.h> 20#include <asm/mach/map.h>
24 21
25#include "common.h"
26#include <plat/tc.h> 22#include <plat/tc.h>
27#include <plat/board.h> 23#include <plat/board.h>
28#include <plat/mux.h> 24#include <plat/mux.h>
29#include <plat/mmc.h> 25#include <plat/mmc.h>
30#include <plat/omap7xx.h> 26#include <plat/omap7xx.h>
31 27
28#include <mach/camera.h>
29#include <mach/hardware.h>
30
31#include "common.h"
32#include "clock.h" 32#include "clock.h"
33 33
34/*-------------------------------------------------------------------------*/ 34/*-------------------------------------------------------------------------*/
diff --git a/arch/arm/mach-omap1/dma.c b/arch/arm/mach-omap1/dma.c
index f5a52204b89..3ef7d52316b 100644
--- a/arch/arm/mach-omap1/dma.c
+++ b/arch/arm/mach-omap1/dma.c
@@ -19,11 +19,11 @@
19 */ 19 */
20 20
21#include <linux/err.h> 21#include <linux/err.h>
22#include <linux/io.h>
23#include <linux/slab.h> 22#include <linux/slab.h>
24#include <linux/module.h> 23#include <linux/module.h>
25#include <linux/init.h> 24#include <linux/init.h>
26#include <linux/device.h> 25#include <linux/device.h>
26#include <linux/io.h>
27 27
28#include <plat/dma.h> 28#include <plat/dma.h>
29#include <plat/tc.h> 29#include <plat/tc.h>
diff --git a/arch/arm/mach-omap1/flash.c b/arch/arm/mach-omap1/flash.c
index 1749cb37dda..f9bf78d4fdf 100644
--- a/arch/arm/mach-omap1/flash.c
+++ b/arch/arm/mach-omap1/flash.c
@@ -6,13 +6,15 @@
6 * published by the Free Software Foundation. 6 * published by the Free Software Foundation.
7 */ 7 */
8 8
9#include <linux/io.h>
9#include <linux/mtd/mtd.h> 10#include <linux/mtd/mtd.h>
10#include <linux/mtd/map.h> 11#include <linux/mtd/map.h>
11 12
12#include <plat/io.h>
13#include <plat/tc.h> 13#include <plat/tc.h>
14#include <plat/flash.h> 14#include <plat/flash.h>
15 15
16#include <mach/hardware.h>
17
16void omap1_set_vpp(struct platform_device *pdev, int enable) 18void omap1_set_vpp(struct platform_device *pdev, int enable)
17{ 19{
18 static int count; 20 static int count;
diff --git a/arch/arm/mach-omap1/fpga.c b/arch/arm/mach-omap1/fpga.c
index 0a17a1a7e00..76c67b3f9f6 100644
--- a/arch/arm/mach-omap1/fpga.c
+++ b/arch/arm/mach-omap1/fpga.c
@@ -24,12 +24,15 @@
24#include <linux/errno.h> 24#include <linux/errno.h>
25#include <linux/io.h> 25#include <linux/io.h>
26 26
27#include <mach/hardware.h>
28#include <asm/irq.h> 27#include <asm/irq.h>
29#include <asm/mach/irq.h> 28#include <asm/mach/irq.h>
30 29
31#include <plat/fpga.h> 30#include <plat/fpga.h>
32 31
32#include <mach/hardware.h>
33
34#include "iomap.h"
35
33static void fpga_mask_irq(struct irq_data *d) 36static void fpga_mask_irq(struct irq_data *d)
34{ 37{
35 unsigned int irq = d->irq - OMAP_FPGA_IRQ_BASE; 38 unsigned int irq = d->irq - OMAP_FPGA_IRQ_BASE;
diff --git a/arch/arm/mach-omap1/gpio15xx.c b/arch/arm/mach-omap1/gpio15xx.c
index 399da4ce017..634903ef829 100644
--- a/arch/arm/mach-omap1/gpio15xx.c
+++ b/arch/arm/mach-omap1/gpio15xx.c
@@ -42,11 +42,12 @@ static struct omap_gpio_reg_offs omap15xx_mpuio_regs = {
42 .irqstatus = OMAP_MPUIO_GPIO_INT, 42 .irqstatus = OMAP_MPUIO_GPIO_INT,
43 .irqenable = OMAP_MPUIO_GPIO_MASKIT, 43 .irqenable = OMAP_MPUIO_GPIO_MASKIT,
44 .irqenable_inv = true, 44 .irqenable_inv = true,
45 .irqctrl = OMAP_MPUIO_GPIO_INT_EDGE,
45}; 46};
46 47
47static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = { 48static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = {
48 .virtual_irq_start = IH_MPUIO_BASE, 49 .virtual_irq_start = IH_MPUIO_BASE,
49 .bank_type = METHOD_MPUIO, 50 .is_mpuio = true,
50 .bank_width = 16, 51 .bank_width = 16,
51 .bank_stride = 1, 52 .bank_stride = 1,
52 .regs = &omap15xx_mpuio_regs, 53 .regs = &omap15xx_mpuio_regs,
@@ -83,11 +84,12 @@ static struct omap_gpio_reg_offs omap15xx_gpio_regs = {
83 .irqstatus = OMAP1510_GPIO_INT_STATUS, 84 .irqstatus = OMAP1510_GPIO_INT_STATUS,
84 .irqenable = OMAP1510_GPIO_INT_MASK, 85 .irqenable = OMAP1510_GPIO_INT_MASK,
85 .irqenable_inv = true, 86 .irqenable_inv = true,
87 .irqctrl = OMAP1510_GPIO_INT_CONTROL,
88 .pinctrl = OMAP1510_GPIO_PIN_CONTROL,
86}; 89};
87 90
88static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = { 91static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = {
89 .virtual_irq_start = IH_GPIO_BASE, 92 .virtual_irq_start = IH_GPIO_BASE,
90 .bank_type = METHOD_GPIO_1510,
91 .bank_width = 16, 93 .bank_width = 16,
92 .regs = &omap15xx_gpio_regs, 94 .regs = &omap15xx_gpio_regs,
93}; 95};
@@ -115,7 +117,6 @@ static int __init omap15xx_gpio_init(void)
115 platform_device_register(&omap15xx_mpu_gpio); 117 platform_device_register(&omap15xx_mpu_gpio);
116 platform_device_register(&omap15xx_gpio); 118 platform_device_register(&omap15xx_gpio);
117 119
118 gpio_bank_count = 2;
119 return 0; 120 return 0;
120} 121}
121postcore_initcall(omap15xx_gpio_init); 122postcore_initcall(omap15xx_gpio_init);
diff --git a/arch/arm/mach-omap1/gpio16xx.c b/arch/arm/mach-omap1/gpio16xx.c
index 0f399bd0e70..1fb3b9ad496 100644
--- a/arch/arm/mach-omap1/gpio16xx.c
+++ b/arch/arm/mach-omap1/gpio16xx.c
@@ -24,6 +24,9 @@
24#define OMAP1610_GPIO4_BASE 0xfffbbc00 24#define OMAP1610_GPIO4_BASE 0xfffbbc00
25#define OMAP1_MPUIO_VBASE OMAP1_MPUIO_BASE 25#define OMAP1_MPUIO_VBASE OMAP1_MPUIO_BASE
26 26
27/* smart idle, enable wakeup */
28#define SYSCONFIG_WORD 0x14
29
27/* mpu gpio */ 30/* mpu gpio */
28static struct __initdata resource omap16xx_mpu_gpio_resources[] = { 31static struct __initdata resource omap16xx_mpu_gpio_resources[] = {
29 { 32 {
@@ -45,11 +48,12 @@ static struct omap_gpio_reg_offs omap16xx_mpuio_regs = {
45 .irqstatus = OMAP_MPUIO_GPIO_INT, 48 .irqstatus = OMAP_MPUIO_GPIO_INT,
46 .irqenable = OMAP_MPUIO_GPIO_MASKIT, 49 .irqenable = OMAP_MPUIO_GPIO_MASKIT,
47 .irqenable_inv = true, 50 .irqenable_inv = true,
51 .irqctrl = OMAP_MPUIO_GPIO_INT_EDGE,
48}; 52};
49 53
50static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = { 54static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = {
51 .virtual_irq_start = IH_MPUIO_BASE, 55 .virtual_irq_start = IH_MPUIO_BASE,
52 .bank_type = METHOD_MPUIO, 56 .is_mpuio = true,
53 .bank_width = 16, 57 .bank_width = 16,
54 .bank_stride = 1, 58 .bank_stride = 1,
55 .regs = &omap16xx_mpuio_regs, 59 .regs = &omap16xx_mpuio_regs,
@@ -89,11 +93,13 @@ static struct omap_gpio_reg_offs omap16xx_gpio_regs = {
89 .irqenable = OMAP1610_GPIO_IRQENABLE1, 93 .irqenable = OMAP1610_GPIO_IRQENABLE1,
90 .set_irqenable = OMAP1610_GPIO_SET_IRQENABLE1, 94 .set_irqenable = OMAP1610_GPIO_SET_IRQENABLE1,
91 .clr_irqenable = OMAP1610_GPIO_CLEAR_IRQENABLE1, 95 .clr_irqenable = OMAP1610_GPIO_CLEAR_IRQENABLE1,
96 .wkup_en = OMAP1610_GPIO_WAKEUPENABLE,
97 .edgectrl1 = OMAP1610_GPIO_EDGE_CTRL1,
98 .edgectrl2 = OMAP1610_GPIO_EDGE_CTRL2,
92}; 99};
93 100
94static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = { 101static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = {
95 .virtual_irq_start = IH_GPIO_BASE, 102 .virtual_irq_start = IH_GPIO_BASE,
96 .bank_type = METHOD_GPIO_1610,
97 .bank_width = 16, 103 .bank_width = 16,
98 .regs = &omap16xx_gpio_regs, 104 .regs = &omap16xx_gpio_regs,
99}; 105};
@@ -123,7 +129,6 @@ static struct __initdata resource omap16xx_gpio2_resources[] = {
123 129
124static struct __initdata omap_gpio_platform_data omap16xx_gpio2_config = { 130static struct __initdata omap_gpio_platform_data omap16xx_gpio2_config = {
125 .virtual_irq_start = IH_GPIO_BASE + 16, 131 .virtual_irq_start = IH_GPIO_BASE + 16,
126 .bank_type = METHOD_GPIO_1610,
127 .bank_width = 16, 132 .bank_width = 16,
128 .regs = &omap16xx_gpio_regs, 133 .regs = &omap16xx_gpio_regs,
129}; 134};
@@ -153,7 +158,6 @@ static struct __initdata resource omap16xx_gpio3_resources[] = {
153 158
154static struct __initdata omap_gpio_platform_data omap16xx_gpio3_config = { 159static struct __initdata omap_gpio_platform_data omap16xx_gpio3_config = {
155 .virtual_irq_start = IH_GPIO_BASE + 32, 160 .virtual_irq_start = IH_GPIO_BASE + 32,
156 .bank_type = METHOD_GPIO_1610,
157 .bank_width = 16, 161 .bank_width = 16,
158 .regs = &omap16xx_gpio_regs, 162 .regs = &omap16xx_gpio_regs,
159}; 163};
@@ -183,7 +187,6 @@ static struct __initdata resource omap16xx_gpio4_resources[] = {
183 187
184static struct __initdata omap_gpio_platform_data omap16xx_gpio4_config = { 188static struct __initdata omap_gpio_platform_data omap16xx_gpio4_config = {
185 .virtual_irq_start = IH_GPIO_BASE + 48, 189 .virtual_irq_start = IH_GPIO_BASE + 48,
186 .bank_type = METHOD_GPIO_1610,
187 .bank_width = 16, 190 .bank_width = 16,
188 .regs = &omap16xx_gpio_regs, 191 .regs = &omap16xx_gpio_regs,
189}; 192};
@@ -214,14 +217,42 @@ static struct __initdata platform_device * omap16xx_gpio_dev[] = {
214static int __init omap16xx_gpio_init(void) 217static int __init omap16xx_gpio_init(void)
215{ 218{
216 int i; 219 int i;
220 void __iomem *base;
221 struct resource *res;
222 struct platform_device *pdev;
223 struct omap_gpio_platform_data *pdata;
217 224
218 if (!cpu_is_omap16xx()) 225 if (!cpu_is_omap16xx())
219 return -EINVAL; 226 return -EINVAL;
220 227
221 for (i = 0; i < ARRAY_SIZE(omap16xx_gpio_dev); i++) 228 /*
222 platform_device_register(omap16xx_gpio_dev[i]); 229 * Enable system clock for GPIO module.
230 * The CAM_CLK_CTRL *is* really the right place.
231 */
232 omap_writel(omap_readl(ULPD_CAM_CLK_CTRL) | 0x04,
233 ULPD_CAM_CLK_CTRL);
234
235 for (i = 0; i < ARRAY_SIZE(omap16xx_gpio_dev); i++) {
236 pdev = omap16xx_gpio_dev[i];
237 pdata = pdev->dev.platform_data;
238
239 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
240 if (unlikely(!res)) {
241 dev_err(&pdev->dev, "Invalid mem resource.\n");
242 return -ENODEV;
243 }
223 244
224 gpio_bank_count = ARRAY_SIZE(omap16xx_gpio_dev); 245 base = ioremap(res->start, resource_size(res));
246 if (unlikely(!base)) {
247 dev_err(&pdev->dev, "ioremap failed.\n");
248 return -ENOMEM;
249 }
250
251 __raw_writel(SYSCONFIG_WORD, base + OMAP1610_GPIO_SYSCONFIG);
252 iounmap(base);
253
254 platform_device_register(omap16xx_gpio_dev[i]);
255 }
225 256
226 return 0; 257 return 0;
227} 258}
diff --git a/arch/arm/mach-omap1/gpio7xx.c b/arch/arm/mach-omap1/gpio7xx.c
index 5ab63eab0ff..4771d6b68b9 100644
--- a/arch/arm/mach-omap1/gpio7xx.c
+++ b/arch/arm/mach-omap1/gpio7xx.c
@@ -47,12 +47,13 @@ static struct omap_gpio_reg_offs omap7xx_mpuio_regs = {
47 .irqstatus = OMAP_MPUIO_GPIO_INT / 2, 47 .irqstatus = OMAP_MPUIO_GPIO_INT / 2,
48 .irqenable = OMAP_MPUIO_GPIO_MASKIT / 2, 48 .irqenable = OMAP_MPUIO_GPIO_MASKIT / 2,
49 .irqenable_inv = true, 49 .irqenable_inv = true,
50 .irqctrl = OMAP_MPUIO_GPIO_INT_EDGE >> 1,
50}; 51};
51 52
52static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = { 53static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = {
53 .virtual_irq_start = IH_MPUIO_BASE, 54 .virtual_irq_start = IH_MPUIO_BASE,
54 .bank_type = METHOD_MPUIO, 55 .is_mpuio = true,
55 .bank_width = 32, 56 .bank_width = 16,
56 .bank_stride = 2, 57 .bank_stride = 2,
57 .regs = &omap7xx_mpuio_regs, 58 .regs = &omap7xx_mpuio_regs,
58}; 59};
@@ -88,11 +89,11 @@ static struct omap_gpio_reg_offs omap7xx_gpio_regs = {
88 .irqstatus = OMAP7XX_GPIO_INT_STATUS, 89 .irqstatus = OMAP7XX_GPIO_INT_STATUS,
89 .irqenable = OMAP7XX_GPIO_INT_MASK, 90 .irqenable = OMAP7XX_GPIO_INT_MASK,
90 .irqenable_inv = true, 91 .irqenable_inv = true,
92 .irqctrl = OMAP7XX_GPIO_INT_CONTROL,
91}; 93};
92 94
93static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = { 95static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = {
94 .virtual_irq_start = IH_GPIO_BASE, 96 .virtual_irq_start = IH_GPIO_BASE,
95 .bank_type = METHOD_GPIO_7XX,
96 .bank_width = 32, 97 .bank_width = 32,
97 .regs = &omap7xx_gpio_regs, 98 .regs = &omap7xx_gpio_regs,
98}; 99};
@@ -122,7 +123,6 @@ static struct __initdata resource omap7xx_gpio2_resources[] = {
122 123
123static struct __initdata omap_gpio_platform_data omap7xx_gpio2_config = { 124static struct __initdata omap_gpio_platform_data omap7xx_gpio2_config = {
124 .virtual_irq_start = IH_GPIO_BASE + 32, 125 .virtual_irq_start = IH_GPIO_BASE + 32,
125 .bank_type = METHOD_GPIO_7XX,
126 .bank_width = 32, 126 .bank_width = 32,
127 .regs = &omap7xx_gpio_regs, 127 .regs = &omap7xx_gpio_regs,
128}; 128};
@@ -152,7 +152,6 @@ static struct __initdata resource omap7xx_gpio3_resources[] = {
152 152
153static struct __initdata omap_gpio_platform_data omap7xx_gpio3_config = { 153static struct __initdata omap_gpio_platform_data omap7xx_gpio3_config = {
154 .virtual_irq_start = IH_GPIO_BASE + 64, 154 .virtual_irq_start = IH_GPIO_BASE + 64,
155 .bank_type = METHOD_GPIO_7XX,
156 .bank_width = 32, 155 .bank_width = 32,
157 .regs = &omap7xx_gpio_regs, 156 .regs = &omap7xx_gpio_regs,
158}; 157};
@@ -182,7 +181,6 @@ static struct __initdata resource omap7xx_gpio4_resources[] = {
182 181
183static struct __initdata omap_gpio_platform_data omap7xx_gpio4_config = { 182static struct __initdata omap_gpio_platform_data omap7xx_gpio4_config = {
184 .virtual_irq_start = IH_GPIO_BASE + 96, 183 .virtual_irq_start = IH_GPIO_BASE + 96,
185 .bank_type = METHOD_GPIO_7XX,
186 .bank_width = 32, 184 .bank_width = 32,
187 .regs = &omap7xx_gpio_regs, 185 .regs = &omap7xx_gpio_regs,
188}; 186};
@@ -212,7 +210,6 @@ static struct __initdata resource omap7xx_gpio5_resources[] = {
212 210
213static struct __initdata omap_gpio_platform_data omap7xx_gpio5_config = { 211static struct __initdata omap_gpio_platform_data omap7xx_gpio5_config = {
214 .virtual_irq_start = IH_GPIO_BASE + 128, 212 .virtual_irq_start = IH_GPIO_BASE + 128,
215 .bank_type = METHOD_GPIO_7XX,
216 .bank_width = 32, 213 .bank_width = 32,
217 .regs = &omap7xx_gpio_regs, 214 .regs = &omap7xx_gpio_regs,
218}; 215};
@@ -242,7 +239,6 @@ static struct __initdata resource omap7xx_gpio6_resources[] = {
242 239
243static struct __initdata omap_gpio_platform_data omap7xx_gpio6_config = { 240static struct __initdata omap_gpio_platform_data omap7xx_gpio6_config = {
244 .virtual_irq_start = IH_GPIO_BASE + 160, 241 .virtual_irq_start = IH_GPIO_BASE + 160,
245 .bank_type = METHOD_GPIO_7XX,
246 .bank_width = 32, 242 .bank_width = 32,
247 .regs = &omap7xx_gpio_regs, 243 .regs = &omap7xx_gpio_regs,
248}; 244};
@@ -282,8 +278,6 @@ static int __init omap7xx_gpio_init(void)
282 for (i = 0; i < ARRAY_SIZE(omap7xx_gpio_dev); i++) 278 for (i = 0; i < ARRAY_SIZE(omap7xx_gpio_dev); i++)
283 platform_device_register(omap7xx_gpio_dev[i]); 279 platform_device_register(omap7xx_gpio_dev[i]);
284 280
285 gpio_bank_count = ARRAY_SIZE(omap7xx_gpio_dev);
286
287 return 0; 281 return 0;
288} 282}
289postcore_initcall(omap7xx_gpio_init); 283postcore_initcall(omap7xx_gpio_init);
diff --git a/arch/arm/mach-omap1/id.c b/arch/arm/mach-omap1/id.c
index b3f3363cd45..2b28e1da14b 100644
--- a/arch/arm/mach-omap1/id.c
+++ b/arch/arm/mach-omap1/id.c
@@ -16,8 +16,11 @@
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/io.h> 17#include <linux/io.h>
18#include <asm/system_info.h> 18#include <asm/system_info.h>
19
19#include <plat/cpu.h> 20#include <plat/cpu.h>
20 21
22#include <mach/hardware.h>
23
21#define OMAP_DIE_ID_0 0xfffe1800 24#define OMAP_DIE_ID_0 0xfffe1800
22#define OMAP_DIE_ID_1 0xfffe1804 25#define OMAP_DIE_ID_1 0xfffe1804
23#define OMAP_PRODUCTION_ID_0 0xfffe2000 26#define OMAP_PRODUCTION_ID_0 0xfffe2000
diff --git a/arch/arm/mach-omap1/include/mach/entry-macro.S b/arch/arm/mach-omap1/include/mach/entry-macro.S
index bfb4fb1d738..fa0f32a686a 100644
--- a/arch/arm/mach-omap1/include/mach/entry-macro.S
+++ b/arch/arm/mach-omap1/include/mach/entry-macro.S
@@ -9,20 +9,16 @@
9 * License version 2. This program is licensed "as is" without any 9 * License version 2. This program is licensed "as is" without any
10 * warranty of any kind, whether express or implied. 10 * warranty of any kind, whether express or implied.
11 */ 11 */
12
12#include <mach/hardware.h> 13#include <mach/hardware.h>
13#include <mach/io.h> 14#include <mach/io.h>
14#include <mach/irqs.h> 15#include <mach/irqs.h>
15#include <asm/hardware/gic.h>
16 16
17 .macro disable_fiq 17#include "../../iomap.h"
18 .endm
19 18
20 .macro get_irqnr_preamble, base, tmp 19 .macro get_irqnr_preamble, base, tmp
21 .endm 20 .endm
22 21
23 .macro arch_ret_to_user, tmp1, tmp2
24 .endm
25
26 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp 22 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
27 ldr \base, =OMAP1_IO_ADDRESS(OMAP_IH1_BASE) 23 ldr \base, =OMAP1_IO_ADDRESS(OMAP_IH1_BASE)
28 ldr \irqnr, [\base, #IRQ_ITR_REG_OFFSET] 24 ldr \irqnr, [\base, #IRQ_ITR_REG_OFFSET]
diff --git a/arch/arm/mach-omap1/include/mach/hardware.h b/arch/arm/mach-omap1/include/mach/hardware.h
index a3f6287b200..01e35fa106b 100644
--- a/arch/arm/mach-omap1/include/mach/hardware.h
+++ b/arch/arm/mach-omap1/include/mach/hardware.h
@@ -2,4 +2,40 @@
2 * arch/arm/mach-omap1/include/mach/hardware.h 2 * arch/arm/mach-omap1/include/mach/hardware.h
3 */ 3 */
4 4
5#ifndef __MACH_HARDWARE_H
6#define __MACH_HARDWARE_H
7
8#ifndef __ASSEMBLER__
9/*
10 * NOTE: Please use ioremap + __raw_read/write where possible instead of these
11 */
12extern u8 omap_readb(u32 pa);
13extern u16 omap_readw(u32 pa);
14extern u32 omap_readl(u32 pa);
15extern void omap_writeb(u8 v, u32 pa);
16extern void omap_writew(u16 v, u32 pa);
17extern void omap_writel(u32 v, u32 pa);
18
19#include <plat/tc.h>
20
21/* Almost all documentation for chip and board memory maps assumes
22 * BM is clear. Most devel boards have a switch to control booting
23 * from NOR flash (using external chipselect 3) rather than mask ROM,
24 * which uses BM to interchange the physical CS0 and CS3 addresses.
25 */
26static inline u32 omap_cs0m_phys(void)
27{
28 return (omap_readl(EMIFS_CONFIG) & OMAP_EMIFS_CONFIG_BM)
29 ? OMAP_CS3_PHYS : 0;
30}
31
32static inline u32 omap_cs3_phys(void)
33{
34 return (omap_readl(EMIFS_CONFIG) & OMAP_EMIFS_CONFIG_BM)
35 ? 0 : OMAP_CS3_PHYS;
36}
37
38#endif
39#endif
40
5#include <plat/hardware.h> 41#include <plat/hardware.h>
diff --git a/arch/arm/mach-omap1/include/mach/io.h b/arch/arm/mach-omap1/include/mach/io.h
index 57bdf74a3e6..37b12e1fd02 100644
--- a/arch/arm/mach-omap1/include/mach/io.h
+++ b/arch/arm/mach-omap1/include/mach/io.h
@@ -1,5 +1,46 @@
1/* 1/*
2 * arch/arm/mach-omap1/include/mach/io.h 2 * arch/arm/mach-omap1/include/mach/io.h
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 * 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 * Modifications:
30 * 06-12-1997 RMK Created.
31 * 07-04-1999 RMK Major cleanup
3 */ 32 */
4 33
5#include <plat/io.h> 34#ifndef __ASM_ARM_ARCH_IO_H
35#define __ASM_ARM_ARCH_IO_H
36
37#define IO_SPACE_LIMIT 0xffffffff
38
39/*
40 * We don't actually have real ISA nor PCI buses, but there is so many
41 * drivers out there that might just work if we fake them...
42 */
43#define __io(a) __typesafe_io(a)
44#define __mem_pci(a) (a)
45
46#endif
diff --git a/arch/arm/mach-omap1/include/mach/memory.h b/arch/arm/mach-omap1/include/mach/memory.h
index c6337645ba8..901082def9b 100644
--- a/arch/arm/mach-omap1/include/mach/memory.h
+++ b/arch/arm/mach-omap1/include/mach/memory.h
@@ -18,7 +18,8 @@
18 * Note that the is_lbus_device() test is not very efficient on 1510 18 * Note that the is_lbus_device() test is not very efficient on 1510
19 * because of the strncmp(). 19 * because of the strncmp().
20 */ 20 */
21#ifdef CONFIG_ARCH_OMAP15XX 21#if defined(CONFIG_ARCH_OMAP15XX) && !defined(__ASSEMBLER__)
22#include <plat/cpu.h>
22 23
23/* 24/*
24 * OMAP-1510 Local Bus address offset 25 * OMAP-1510 Local Bus address offset
diff --git a/arch/arm/mach-omap1/include/mach/system.h b/arch/arm/mach-omap1/include/mach/system.h
deleted file mode 100644
index a6c1b3a16df..00000000000
--- a/arch/arm/mach-omap1/include/mach/system.h
+++ /dev/null
@@ -1,5 +0,0 @@
1/*
2 * arch/arm/mach-omap1/include/mach/system.h
3 */
4
5#include <plat/system.h>
diff --git a/arch/arm/mach-omap1/io.c b/arch/arm/mach-omap1/io.c
index 8e55b6fb347..d969a7203d1 100644
--- a/arch/arm/mach-omap1/io.c
+++ b/arch/arm/mach-omap1/io.c
@@ -15,9 +15,12 @@
15 15
16#include <asm/tlb.h> 16#include <asm/tlb.h>
17#include <asm/mach/map.h> 17#include <asm/mach/map.h>
18
18#include <plat/mux.h> 19#include <plat/mux.h>
19#include <plat/tc.h> 20#include <plat/tc.h>
20 21
22#include "iomap.h"
23#include "common.h"
21#include "clock.h" 24#include "clock.h"
22 25
23extern void omap_check_revision(void); 26extern void omap_check_revision(void);
@@ -118,7 +121,7 @@ void __init omap16xx_map_io(void)
118/* 121/*
119 * Common low-level hardware init for omap1. 122 * Common low-level hardware init for omap1.
120 */ 123 */
121void omap1_init_early(void) 124void __init omap1_init_early(void)
122{ 125{
123 omap_check_revision(); 126 omap_check_revision();
124 127
diff --git a/arch/arm/mach-omap1/iomap.h b/arch/arm/mach-omap1/iomap.h
new file mode 100644
index 00000000000..d68175761c3
--- /dev/null
+++ b/arch/arm/mach-omap1/iomap.h
@@ -0,0 +1,42 @@
1/*
2 * IO mappings for OMAP1
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 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
10 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
12 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
13 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
14 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
15 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
16 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
17 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
18 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 675 Mass Ave, Cambridge, MA 02139, USA.
23 */
24
25#ifdef __ASSEMBLER__
26#define IOMEM(x) (x)
27#else
28#define IOMEM(x) ((void __force __iomem *)(x))
29#endif
30
31#define OMAP1_IO_OFFSET 0x01000000 /* Virtual IO = 0xfefb0000 */
32#define OMAP1_IO_ADDRESS(pa) IOMEM((pa) - OMAP1_IO_OFFSET)
33
34/*
35 * ----------------------------------------------------------------------------
36 * Omap1 specific IO mapping
37 * ----------------------------------------------------------------------------
38 */
39
40#define OMAP1_IO_PHYS 0xFFFB0000
41#define OMAP1_IO_SIZE 0x40000
42#define OMAP1_IO_VIRT (OMAP1_IO_PHYS - OMAP1_IO_OFFSET)
diff --git a/arch/arm/mach-omap1/irq.c b/arch/arm/mach-omap1/irq.c
index e5b104b7fce..4448114fab7 100644
--- a/arch/arm/mach-omap1/irq.c
+++ b/arch/arm/mach-omap1/irq.c
@@ -42,11 +42,13 @@
42#include <linux/interrupt.h> 42#include <linux/interrupt.h>
43#include <linux/io.h> 43#include <linux/io.h>
44 44
45#include <mach/hardware.h>
46#include <asm/irq.h> 45#include <asm/irq.h>
47#include <asm/mach/irq.h> 46#include <asm/mach/irq.h>
47
48#include <plat/cpu.h> 48#include <plat/cpu.h>
49 49
50#include <mach/hardware.h>
51
50#define IRQ_BANK(irq) ((irq) >> 5) 52#define IRQ_BANK(irq) ((irq) >> 5)
51#define IRQ_BIT(irq) ((irq) & 0x1f) 53#define IRQ_BIT(irq) ((irq) & 0x1f)
52 54
diff --git a/arch/arm/mach-omap1/lcd_dma.c b/arch/arm/mach-omap1/lcd_dma.c
index 4c5ce7d829c..86ace9aaa66 100644
--- a/arch/arm/mach-omap1/lcd_dma.c
+++ b/arch/arm/mach-omap1/lcd_dma.c
@@ -27,9 +27,10 @@
27#include <linux/interrupt.h> 27#include <linux/interrupt.h>
28#include <linux/io.h> 28#include <linux/io.h>
29 29
30#include <plat/dma.h>
31
30#include <mach/hardware.h> 32#include <mach/hardware.h>
31#include <mach/lcdc.h> 33#include <mach/lcdc.h>
32#include <plat/dma.h>
33 34
34int omap_lcd_dma_running(void) 35int omap_lcd_dma_running(void)
35{ 36{
diff --git a/arch/arm/mach-omap1/mcbsp.c b/arch/arm/mach-omap1/mcbsp.c
index 3e8410a9999..adf00975b9b 100644
--- a/arch/arm/mach-omap1/mcbsp.c
+++ b/arch/arm/mach-omap1/mcbsp.c
@@ -19,12 +19,15 @@
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
21 21
22#include <mach/irqs.h>
23#include <plat/dma.h> 22#include <plat/dma.h>
24#include <plat/mux.h> 23#include <plat/mux.h>
25#include <plat/cpu.h> 24#include <plat/cpu.h>
26#include <plat/mcbsp.h> 25#include <plat/mcbsp.h>
27 26
27#include <mach/irqs.h>
28
29#include "iomap.h"
30
28#define DPS_RSTCT2_PER_EN (1 << 0) 31#define DPS_RSTCT2_PER_EN (1 << 0)
29#define DSP_RSTCT2_WD_PER_EN (1 << 1) 32#define DSP_RSTCT2_WD_PER_EN (1 << 1)
30 33
diff --git a/arch/arm/mach-omap1/pm.c b/arch/arm/mach-omap1/pm.c
index 89ea20ca0cc..306beaca14c 100644
--- a/arch/arm/mach-omap1/pm.c
+++ b/arch/arm/mach-omap1/pm.c
@@ -42,14 +42,13 @@
42#include <linux/sysfs.h> 42#include <linux/sysfs.h>
43#include <linux/module.h> 43#include <linux/module.h>
44#include <linux/io.h> 44#include <linux/io.h>
45#include <linux/atomic.h>
45 46
46#include <asm/irq.h> 47#include <asm/irq.h>
47#include <linux/atomic.h>
48#include <asm/mach/time.h> 48#include <asm/mach/time.h>
49#include <asm/mach/irq.h> 49#include <asm/mach/irq.h>
50 50
51#include <plat/cpu.h> 51#include <plat/cpu.h>
52#include <mach/irqs.h>
53#include <plat/clock.h> 52#include <plat/clock.h>
54#include <plat/sram.h> 53#include <plat/sram.h>
55#include <plat/tc.h> 54#include <plat/tc.h>
@@ -57,6 +56,9 @@
57#include <plat/dma.h> 56#include <plat/dma.h>
58#include <plat/dmtimer.h> 57#include <plat/dmtimer.h>
59 58
59#include <mach/irqs.h>
60
61#include "iomap.h"
60#include "pm.h" 62#include "pm.h"
61 63
62static unsigned int arm_sleep_save[ARM_SLEEP_SAVE_SIZE]; 64static unsigned int arm_sleep_save[ARM_SLEEP_SAVE_SIZE];
@@ -108,13 +110,7 @@ void omap1_pm_idle(void)
108 __u32 use_idlect1 = arm_idlect1_mask; 110 __u32 use_idlect1 = arm_idlect1_mask;
109 int do_sleep = 0; 111 int do_sleep = 0;
110 112
111 local_irq_disable();
112 local_fiq_disable(); 113 local_fiq_disable();
113 if (need_resched()) {
114 local_fiq_enable();
115 local_irq_enable();
116 return;
117 }
118 114
119#if defined(CONFIG_OMAP_MPU_TIMER) && !defined(CONFIG_OMAP_DM_TIMER) 115#if defined(CONFIG_OMAP_MPU_TIMER) && !defined(CONFIG_OMAP_DM_TIMER)
120#warning Enable 32kHz OS timer in order to allow sleep states in idle 116#warning Enable 32kHz OS timer in order to allow sleep states in idle
@@ -157,14 +153,12 @@ void omap1_pm_idle(void)
157 omap_writel(saved_idlect1, ARM_IDLECT1); 153 omap_writel(saved_idlect1, ARM_IDLECT1);
158 154
159 local_fiq_enable(); 155 local_fiq_enable();
160 local_irq_enable();
161 return; 156 return;
162 } 157 }
163 omap_sram_suspend(omap_readl(ARM_IDLECT1), 158 omap_sram_suspend(omap_readl(ARM_IDLECT1),
164 omap_readl(ARM_IDLECT2)); 159 omap_readl(ARM_IDLECT2));
165 160
166 local_fiq_enable(); 161 local_fiq_enable();
167 local_irq_enable();
168} 162}
169 163
170/* 164/*
@@ -583,8 +577,6 @@ static void omap_pm_init_proc(void)
583 577
584#endif /* DEBUG && CONFIG_PROC_FS */ 578#endif /* DEBUG && CONFIG_PROC_FS */
585 579
586static void (*saved_idle)(void) = NULL;
587
588/* 580/*
589 * omap_pm_prepare - Do preliminary suspend work. 581 * omap_pm_prepare - Do preliminary suspend work.
590 * 582 *
@@ -592,8 +584,7 @@ static void (*saved_idle)(void) = NULL;
592static int omap_pm_prepare(void) 584static int omap_pm_prepare(void)
593{ 585{
594 /* We cannot sleep in idle until we have resumed */ 586 /* We cannot sleep in idle until we have resumed */
595 saved_idle = pm_idle; 587 disable_hlt();
596 pm_idle = NULL;
597 588
598 return 0; 589 return 0;
599} 590}
@@ -630,7 +621,7 @@ static int omap_pm_enter(suspend_state_t state)
630 621
631static void omap_pm_finish(void) 622static void omap_pm_finish(void)
632{ 623{
633 pm_idle = saved_idle; 624 enable_hlt();
634} 625}
635 626
636 627
@@ -687,7 +678,7 @@ static int __init omap_pm_init(void)
687 return -ENODEV; 678 return -ENODEV;
688 } 679 }
689 680
690 pm_idle = omap1_pm_idle; 681 arm_pm_idle = omap1_pm_idle;
691 682
692 if (cpu_is_omap7xx()) 683 if (cpu_is_omap7xx())
693 setup_irq(INT_7XX_WAKE_UP_REQ, &omap_wakeup_irq); 684 setup_irq(INT_7XX_WAKE_UP_REQ, &omap_wakeup_irq);
diff --git a/arch/arm/mach-omap1/reset.c b/arch/arm/mach-omap1/reset.c
index 91d199b6497..f255b153b86 100644
--- a/arch/arm/mach-omap1/reset.c
+++ b/arch/arm/mach-omap1/reset.c
@@ -4,9 +4,10 @@
4#include <linux/kernel.h> 4#include <linux/kernel.h>
5#include <linux/io.h> 5#include <linux/io.h>
6 6
7#include <mach/hardware.h>
8#include <plat/prcm.h> 7#include <plat/prcm.h>
9 8
9#include <mach/hardware.h>
10
10void omap1_restart(char mode, const char *cmd) 11void omap1_restart(char mode, const char *cmd)
11{ 12{
12 /* 13 /*
diff --git a/arch/arm/mach-omap1/sleep.S b/arch/arm/mach-omap1/sleep.S
index c875bdc902c..0779db150da 100644
--- a/arch/arm/mach-omap1/sleep.S
+++ b/arch/arm/mach-omap1/sleep.S
@@ -33,8 +33,12 @@
33 */ 33 */
34 34
35#include <linux/linkage.h> 35#include <linux/linkage.h>
36
36#include <asm/assembler.h> 37#include <asm/assembler.h>
38
37#include <mach/io.h> 39#include <mach/io.h>
40
41#include "iomap.h"
38#include "pm.h" 42#include "pm.h"
39 43
40 .text 44 .text
diff --git a/arch/arm/mach-omap1/sram.S b/arch/arm/mach-omap1/sram.S
index 692587d07ea..2ce0b9ab20e 100644
--- a/arch/arm/mach-omap1/sram.S
+++ b/arch/arm/mach-omap1/sram.S
@@ -9,10 +9,14 @@
9 */ 9 */
10 10
11#include <linux/linkage.h> 11#include <linux/linkage.h>
12
12#include <asm/assembler.h> 13#include <asm/assembler.h>
14
13#include <mach/io.h> 15#include <mach/io.h>
14#include <mach/hardware.h> 16#include <mach/hardware.h>
15 17
18#include "iomap.h"
19
16 .text 20 .text
17 21
18/* 22/*
diff --git a/arch/arm/mach-omap1/time.c b/arch/arm/mach-omap1/time.c
index 7595e0ac225..4d8dd9a1b04 100644
--- a/arch/arm/mach-omap1/time.c
+++ b/arch/arm/mach-omap1/time.c
@@ -44,14 +44,15 @@
44#include <linux/clockchips.h> 44#include <linux/clockchips.h>
45#include <linux/io.h> 45#include <linux/io.h>
46 46
47#include <mach/hardware.h>
48#include <asm/leds.h> 47#include <asm/leds.h>
49#include <asm/irq.h> 48#include <asm/irq.h>
50#include <asm/sched_clock.h> 49#include <asm/sched_clock.h>
51 50
51#include <mach/hardware.h>
52#include <asm/mach/irq.h> 52#include <asm/mach/irq.h>
53#include <asm/mach/time.h> 53#include <asm/mach/time.h>
54 54
55#include "iomap.h"
55#include "common.h" 56#include "common.h"
56 57
57#ifdef CONFIG_OMAP_MPU_TIMER 58#ifdef CONFIG_OMAP_MPU_TIMER
diff --git a/arch/arm/mach-omap1/timer32k.c b/arch/arm/mach-omap1/timer32k.c
index 10bcd1364cd..325b9a0aa4a 100644
--- a/arch/arm/mach-omap1/timer32k.c
+++ b/arch/arm/mach-omap1/timer32k.c
@@ -46,14 +46,17 @@
46#include <linux/clockchips.h> 46#include <linux/clockchips.h>
47#include <linux/io.h> 47#include <linux/io.h>
48 48
49#include <mach/hardware.h>
50#include <asm/leds.h> 49#include <asm/leds.h>
51#include <asm/irq.h> 50#include <asm/irq.h>
52#include <asm/mach/irq.h> 51#include <asm/mach/irq.h>
53#include <asm/mach/time.h> 52#include <asm/mach/time.h>
54#include "common.h" 53
55#include <plat/dmtimer.h> 54#include <plat/dmtimer.h>
56 55
56#include <mach/hardware.h>
57
58#include "common.h"
59
57/* 60/*
58 * --------------------------------------------------------------------------- 61 * ---------------------------------------------------------------------------
59 * 32KHz OS timer 62 * 32KHz OS timer
diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
index e20c8ab80b0..8141b76283a 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -32,7 +32,7 @@ config ARCH_OMAP3
32 depends on ARCH_OMAP2PLUS 32 depends on ARCH_OMAP2PLUS
33 default y 33 default y
34 select CPU_V7 34 select CPU_V7
35 select USB_ARCH_HAS_EHCI 35 select USB_ARCH_HAS_EHCI if USB_SUPPORT
36 select ARCH_HAS_OPP 36 select ARCH_HAS_OPP
37 select PM_OPP if PM 37 select PM_OPP if PM
38 select ARM_CPU_SUSPEND if PM 38 select ARM_CPU_SUSPEND if PM
@@ -52,7 +52,7 @@ config ARCH_OMAP4
52 select ARM_ERRATA_720789 52 select ARM_ERRATA_720789
53 select ARCH_HAS_OPP 53 select ARCH_HAS_OPP
54 select PM_OPP if PM 54 select PM_OPP if PM
55 select USB_ARCH_HAS_EHCI 55 select USB_ARCH_HAS_EHCI if USB_SUPPORT
56 select ARM_CPU_SUSPEND if PM 56 select ARM_CPU_SUSPEND if PM
57 57
58comment "OMAP Core Type" 58comment "OMAP Core Type"
@@ -117,7 +117,6 @@ comment "OMAP Board Type"
117config MACH_OMAP_GENERIC 117config MACH_OMAP_GENERIC
118 bool "Generic OMAP2+ board" 118 bool "Generic OMAP2+ board"
119 depends on ARCH_OMAP2PLUS 119 depends on ARCH_OMAP2PLUS
120 select USE_OF
121 default y 120 default y
122 help 121 help
123 Support for generic TI OMAP2+ boards using Flattened Device Tree. 122 Support for generic TI OMAP2+ boards using Flattened Device Tree.
@@ -245,10 +244,11 @@ config MACH_NOKIA_N8X0
245 select MACH_NOKIA_N810_WIMAX 244 select MACH_NOKIA_N810_WIMAX
246 245
247config MACH_NOKIA_RM680 246config MACH_NOKIA_RM680
248 bool "Nokia RM-680 board" 247 bool "Nokia RM-680/696 board"
249 depends on ARCH_OMAP3 248 depends on ARCH_OMAP3
250 default y 249 default y
251 select OMAP_PACKAGE_CBB 250 select OMAP_PACKAGE_CBB
251 select MACH_NOKIA_RM696
252 252
253config MACH_NOKIA_RX51 253config MACH_NOKIA_RX51
254 bool "Nokia RX-51 board" 254 bool "Nokia RX-51 board"
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 06326a6e460..49f92bc1c31 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -4,7 +4,7 @@
4 4
5# Common support 5# Common support
6obj-y := id.o io.o control.o mux.o devices.o serial.o gpmc.o timer.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 7 common.o gpio.o dma.o wd_timer.o display.o i2c.o
8 8
9omap-2-3-common = irq.o sdrc.o 9omap-2-3-common = irq.o sdrc.o
10hwmod-common = omap_hwmod.o \ 10hwmod-common = omap_hwmod.o \
@@ -25,7 +25,6 @@ obj-$(CONFIG_TWL4030_CORE) += omap_twl.o
25 25
26# SMP support ONLY available for OMAP4 26# SMP support ONLY available for OMAP4
27obj-$(CONFIG_SMP) += omap-smp.o omap-headsmp.o 27obj-$(CONFIG_SMP) += omap-smp.o omap-headsmp.o
28obj-$(CONFIG_LOCAL_TIMERS) += timer-mpu.o
29obj-$(CONFIG_HOTPLUG_CPU) += omap-hotplug.o 28obj-$(CONFIG_HOTPLUG_CPU) += omap-hotplug.o
30obj-$(CONFIG_ARCH_OMAP4) += omap4-common.o omap-wakeupgen.o \ 29obj-$(CONFIG_ARCH_OMAP4) += omap4-common.o omap-wakeupgen.o \
31 sleep44xx.o 30 sleep44xx.o
@@ -184,9 +183,6 @@ obj-$(CONFIG_OMAP_IOMMU) += iommu2.o
184iommu-$(CONFIG_OMAP_IOMMU) := omap-iommu.o 183iommu-$(CONFIG_OMAP_IOMMU) := omap-iommu.o
185obj-y += $(iommu-m) $(iommu-y) 184obj-y += $(iommu-m) $(iommu-y)
186 185
187i2c-omap-$(CONFIG_I2C_OMAP) := i2c.o
188obj-y += $(i2c-omap-m) $(i2c-omap-y)
189
190ifneq ($(CONFIG_TIDSPBRIDGE),) 186ifneq ($(CONFIG_TIDSPBRIDGE),)
191obj-y += dsp.o 187obj-y += dsp.o
192endif 188endif
@@ -270,6 +266,11 @@ obj-y += $(smc91x-m) $(smc91x-y)
270 266
271smsc911x-$(CONFIG_SMSC911X) := gpmc-smsc911x.o 267smsc911x-$(CONFIG_SMSC911X) := gpmc-smsc911x.o
272obj-y += $(smsc911x-m) $(smsc911x-y) 268obj-y += $(smsc911x-m) $(smsc911x-y)
273obj-$(CONFIG_ARCH_OMAP4) += hwspinlock.o 269ifneq ($(CONFIG_HWSPINLOCK_OMAP),)
270obj-y += hwspinlock.o
271endif
272
273emac-$(CONFIG_TI_DAVINCI_EMAC) := am35xx-emac.o
274obj-y += $(emac-m) $(emac-y)
274 275
275obj-y += common-board-devices.o twl-common.o 276obj-y += common-board-devices.o twl-common.o
diff --git a/arch/arm/mach-omap2/am35xx-emac.c b/arch/arm/mach-omap2/am35xx-emac.c
new file mode 100644
index 00000000000..1f97e747520
--- /dev/null
+++ b/arch/arm/mach-omap2/am35xx-emac.c
@@ -0,0 +1,117 @@
1/*
2 * Copyright (C) 2011 Ilya Yanok, Emcraft Systems
3 *
4 * Based on mach-omap2/board-am3517evm.c
5 * Copyright (C) 2009 Texas Instruments Incorporated
6 * Author: Ranjith Lohithakshan <ranjithl@ti.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
13 * whether express or implied; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 */
17
18#include <linux/clk.h>
19#include <linux/davinci_emac.h>
20#include <linux/platform_device.h>
21#include <plat/irqs.h>
22#include <mach/am35xx.h>
23
24#include "control.h"
25
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
40static void am35xx_enable_emac_int(void)
41{
42 u32 regval;
43
44 regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
45 regval = (regval | AM35XX_CPGMAC_C0_RX_PULSE_CLR |
46 AM35XX_CPGMAC_C0_TX_PULSE_CLR |
47 AM35XX_CPGMAC_C0_MISC_PULSE_CLR |
48 AM35XX_CPGMAC_C0_RX_THRESH_CLR);
49 omap_ctrl_writel(regval, AM35XX_CONTROL_LVL_INTR_CLEAR);
50 regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
51}
52
53static void am35xx_disable_emac_int(void)
54{
55 u32 regval;
56
57 regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
58 regval = (regval | AM35XX_CPGMAC_C0_RX_PULSE_CLR |
59 AM35XX_CPGMAC_C0_TX_PULSE_CLR);
60 omap_ctrl_writel(regval, AM35XX_CONTROL_LVL_INTR_CLEAR);
61 regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
62}
63
64static struct emac_platform_data am35xx_emac_pdata = {
65 .ctrl_reg_offset = AM35XX_EMAC_CNTRL_OFFSET,
66 .ctrl_mod_reg_offset = AM35XX_EMAC_CNTRL_MOD_OFFSET,
67 .ctrl_ram_offset = AM35XX_EMAC_CNTRL_RAM_OFFSET,
68 .ctrl_ram_size = AM35XX_EMAC_CNTRL_RAM_SIZE,
69 .hw_ram_addr = AM35XX_EMAC_HW_RAM_ADDR,
70 .version = EMAC_VERSION_2,
71 .interrupt_enable = am35xx_enable_emac_int,
72 .interrupt_disable = am35xx_disable_emac_int,
73};
74
75static struct resource am35xx_emac_resources[] = {
76 DEFINE_RES_MEM(AM35XX_IPSS_EMAC_BASE, 0x30000),
77 DEFINE_RES_IRQ(INT_35XX_EMAC_C0_RXTHRESH_IRQ),
78 DEFINE_RES_IRQ(INT_35XX_EMAC_C0_RX_PULSE_IRQ),
79 DEFINE_RES_IRQ(INT_35XX_EMAC_C0_TX_PULSE_IRQ),
80 DEFINE_RES_IRQ(INT_35XX_EMAC_C0_MISC_PULSE_IRQ),
81};
82
83static struct platform_device am35xx_emac_device = {
84 .name = "davinci_emac",
85 .id = -1,
86 .num_resources = ARRAY_SIZE(am35xx_emac_resources),
87 .resource = am35xx_emac_resources,
88 .dev = {
89 .platform_data = &am35xx_emac_pdata,
90 },
91};
92
93void __init am35xx_emac_init(unsigned long mdio_bus_freq, u8 rmii_en)
94{
95 unsigned int regval;
96 int err;
97
98 am35xx_emac_pdata.rmii_en = rmii_en;
99 am35xx_emac_mdio_pdata.bus_freq = mdio_bus_freq;
100 err = platform_device_register(&am35xx_emac_device);
101 if (err) {
102 pr_err("AM35x: failed registering EMAC device: %d\n", err);
103 return;
104 }
105
106 err = platform_device_register(&am35xx_emac_mdio_device);
107 if (err) {
108 pr_err("AM35x: failed registering EMAC MDIO device: %d\n", err);
109 platform_device_unregister(&am35xx_emac_device);
110 return;
111 }
112
113 regval = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
114 regval = regval & (~(AM35XX_CPGMACSS_SW_RST));
115 omap_ctrl_writel(regval, AM35XX_CONTROL_IP_SW_RESET);
116 regval = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
117}
diff --git a/arch/arm/mach-omap2/am35xx-emac.h b/arch/arm/mach-omap2/am35xx-emac.h
new file mode 100644
index 00000000000..15c6f9ce59a
--- /dev/null
+++ b/arch/arm/mach-omap2/am35xx-emac.h
@@ -0,0 +1,15 @@
1/*
2 * Copyright (C) 2011 Ilya Yanok, Emcraft Systems
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#define AM35XX_DEFAULT_MDIO_FREQUENCY 1000000
10
11#if defined(CONFIG_TI_DAVINCI_EMAC) || defined(CONFIG_TI_DAVINCI_EMAC_MODULE)
12void am35xx_emac_init(unsigned long mdio_bus_freq, u8 rmii_en);
13#else
14static inline void am35xx_emac_init(unsigned long mdio_bus_freq, u8 rmii_en) {}
15#endif
diff --git a/arch/arm/mach-omap2/board-2430sdp.c b/arch/arm/mach-omap2/board-2430sdp.c
index 7370983f809..c8bda62900d 100644
--- a/arch/arm/mach-omap2/board-2430sdp.c
+++ b/arch/arm/mach-omap2/board-2430sdp.c
@@ -279,7 +279,7 @@ static void __init omap_2430sdp_init(void)
279 platform_add_devices(sdp2430_devices, ARRAY_SIZE(sdp2430_devices)); 279 platform_add_devices(sdp2430_devices, ARRAY_SIZE(sdp2430_devices));
280 omap_serial_init(); 280 omap_serial_init();
281 omap_sdrc_init(NULL, NULL); 281 omap_sdrc_init(NULL, NULL);
282 omap2_hsmmc_init(mmc); 282 omap_hsmmc_init(mmc);
283 omap2_usbfs_init(&sdp2430_usb_config); 283 omap2_usbfs_init(&sdp2430_usb_config);
284 284
285 omap_mux_init_signal("usb0hs_stp", OMAP_PULL_ENA | OMAP_PULL_UP); 285 omap_mux_init_signal("usb0hs_stp", OMAP_PULL_ENA | OMAP_PULL_UP);
diff --git a/arch/arm/mach-omap2/board-3430sdp.c b/arch/arm/mach-omap2/board-3430sdp.c
index 383717ba63b..da75f239873 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -232,11 +232,13 @@ static struct omap2_hsmmc_info mmc[] = {
232 */ 232 */
233 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA, 233 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
234 .gpio_wp = 4, 234 .gpio_wp = 4,
235 .deferred = true,
235 }, 236 },
236 { 237 {
237 .mmc = 2, 238 .mmc = 2,
238 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA, 239 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
239 .gpio_wp = 7, 240 .gpio_wp = 7,
241 .deferred = true,
240 }, 242 },
241 {} /* Terminator */ 243 {} /* Terminator */
242}; 244};
@@ -249,7 +251,7 @@ static int sdp3430_twl_gpio_setup(struct device *dev,
249 */ 251 */
250 mmc[0].gpio_cd = gpio + 0; 252 mmc[0].gpio_cd = gpio + 0;
251 mmc[1].gpio_cd = gpio + 1; 253 mmc[1].gpio_cd = gpio + 1;
252 omap2_hsmmc_init(mmc); 254 omap_hsmmc_late_init(mmc);
253 255
254 /* gpio + 7 is "sub_lcd_en_bkl" (output/PWM1) */ 256 /* gpio + 7 is "sub_lcd_en_bkl" (output/PWM1) */
255 gpio_request_one(gpio + 7, GPIOF_OUT_INIT_LOW, "sub_lcd_en_bkl"); 257 gpio_request_one(gpio + 7, GPIOF_OUT_INIT_LOW, "sub_lcd_en_bkl");
@@ -606,6 +608,7 @@ static void __init omap_3430sdp_init(void)
606 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB); 608 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
607 omap_board_config = sdp3430_config; 609 omap_board_config = sdp3430_config;
608 omap_board_config_size = ARRAY_SIZE(sdp3430_config); 610 omap_board_config_size = ARRAY_SIZE(sdp3430_config);
611 omap_hsmmc_init(mmc);
609 omap3430_i2c_init(); 612 omap3430_i2c_init();
610 omap_display_init(&sdp3430_dss_data); 613 omap_display_init(&sdp3430_dss_data);
611 if (omap_rev() > OMAP3430_REV_ES1_0) 614 if (omap_rev() > OMAP3430_REV_ES1_0)
diff --git a/arch/arm/mach-omap2/board-4430sdp.c b/arch/arm/mach-omap2/board-4430sdp.c
index 44cf1893829..37dcb1bc025 100644
--- a/arch/arm/mach-omap2/board-4430sdp.c
+++ b/arch/arm/mach-omap2/board-4430sdp.c
@@ -324,7 +324,10 @@ static struct spi_board_info sdp4430_spi_board_info[] __initdata = {
324 .bus_num = 1, 324 .bus_num = 1,
325 .chip_select = 0, 325 .chip_select = 0,
326 .max_speed_hz = 24000000, 326 .max_speed_hz = 24000000,
327 .irq = ETH_KS8851_IRQ, 327 /*
328 * .irq is set to gpio_to_irq(ETH_KS8851_IRQ)
329 * in omap_4430sdp_init
330 */
328 }, 331 },
329}; 332};
330 333
@@ -487,21 +490,22 @@ static struct platform_device omap_vwlan_device = {
487 490
488static int omap4_twl6030_hsmmc_late_init(struct device *dev) 491static int omap4_twl6030_hsmmc_late_init(struct device *dev)
489{ 492{
490 int ret = 0; 493 int irq = 0;
491 struct platform_device *pdev = container_of(dev, 494 struct platform_device *pdev = container_of(dev,
492 struct platform_device, dev); 495 struct platform_device, dev);
493 struct omap_mmc_platform_data *pdata = dev->platform_data; 496 struct omap_mmc_platform_data *pdata = dev->platform_data;
494 497
495 /* Setting MMC1 Card detect Irq */ 498 /* Setting MMC1 Card detect Irq */
496 if (pdev->id == 0) { 499 if (pdev->id == 0) {
497 ret = twl6030_mmc_card_detect_config(); 500 irq = twl6030_mmc_card_detect_config();
498 if (ret) 501 if (irq < 0) {
499 pr_err("Failed configuring MMC1 card detect\n"); 502 pr_err("Failed configuring MMC1 card detect\n");
500 pdata->slots[0].card_detect_irq = TWL6030_IRQ_BASE + 503 return irq;
501 MMCDETECT_INTR_OFFSET; 504 }
505 pdata->slots[0].card_detect_irq = irq;
502 pdata->slots[0].card_detect = twl6030_mmc_card_detect; 506 pdata->slots[0].card_detect = twl6030_mmc_card_detect;
503 } 507 }
504 return ret; 508 return 0;
505} 509}
506 510
507static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev) 511static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev)
@@ -521,9 +525,9 @@ static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
521{ 525{
522 struct omap2_hsmmc_info *c; 526 struct omap2_hsmmc_info *c;
523 527
524 omap2_hsmmc_init(controllers); 528 omap_hsmmc_init(controllers);
525 for (c = controllers; c->mmc; c++) 529 for (c = controllers; c->mmc; c++)
526 omap4_twl6030_hsmmc_set_late_init(c->dev); 530 omap4_twl6030_hsmmc_set_late_init(&c->pdev->dev);
527 531
528 return 0; 532 return 0;
529} 533}
diff --git a/arch/arm/mach-omap2/board-am3517evm.c b/arch/arm/mach-omap2/board-am3517evm.c
index 4b1cfe32e6b..3645285a3e2 100644
--- a/arch/arm/mach-omap2/board-am3517evm.c
+++ b/arch/arm/mach-omap2/board-am3517evm.c
@@ -39,124 +39,11 @@
39#include <video/omap-panel-generic-dpi.h> 39#include <video/omap-panel-generic-dpi.h>
40#include <video/omap-panel-dvi.h> 40#include <video/omap-panel-dvi.h>
41 41
42#include "am35xx-emac.h"
42#include "mux.h" 43#include "mux.h"
43#include "control.h" 44#include "control.h"
44#include "hsmmc.h" 45#include "hsmmc.h"
45 46
46#define AM35XX_EVM_MDIO_FREQUENCY (1000000)
47
48static struct mdio_platform_data am3517_evm_mdio_pdata = {
49 .bus_freq = AM35XX_EVM_MDIO_FREQUENCY,
50};
51
52static struct resource am3517_mdio_resources[] = {
53 {
54 .start = AM35XX_IPSS_EMAC_BASE + AM35XX_EMAC_MDIO_OFFSET,
55 .end = AM35XX_IPSS_EMAC_BASE + AM35XX_EMAC_MDIO_OFFSET +
56 SZ_4K - 1,
57 .flags = IORESOURCE_MEM,
58 },
59};
60
61static struct platform_device am3517_mdio_device = {
62 .name = "davinci_mdio",
63 .id = 0,
64 .num_resources = ARRAY_SIZE(am3517_mdio_resources),
65 .resource = am3517_mdio_resources,
66 .dev.platform_data = &am3517_evm_mdio_pdata,
67};
68
69static struct emac_platform_data am3517_evm_emac_pdata = {
70 .rmii_en = 1,
71};
72
73static struct resource am3517_emac_resources[] = {
74 {
75 .start = AM35XX_IPSS_EMAC_BASE,
76 .end = AM35XX_IPSS_EMAC_BASE + 0x2FFFF,
77 .flags = IORESOURCE_MEM,
78 },
79 {
80 .start = INT_35XX_EMAC_C0_RXTHRESH_IRQ,
81 .end = INT_35XX_EMAC_C0_RXTHRESH_IRQ,
82 .flags = IORESOURCE_IRQ,
83 },
84 {
85 .start = INT_35XX_EMAC_C0_RX_PULSE_IRQ,
86 .end = INT_35XX_EMAC_C0_RX_PULSE_IRQ,
87 .flags = IORESOURCE_IRQ,
88 },
89 {
90 .start = INT_35XX_EMAC_C0_TX_PULSE_IRQ,
91 .end = INT_35XX_EMAC_C0_TX_PULSE_IRQ,
92 .flags = IORESOURCE_IRQ,
93 },
94 {
95 .start = INT_35XX_EMAC_C0_MISC_PULSE_IRQ,
96 .end = INT_35XX_EMAC_C0_MISC_PULSE_IRQ,
97 .flags = IORESOURCE_IRQ,
98 },
99};
100
101static struct platform_device am3517_emac_device = {
102 .name = "davinci_emac",
103 .id = -1,
104 .num_resources = ARRAY_SIZE(am3517_emac_resources),
105 .resource = am3517_emac_resources,
106};
107
108static void am3517_enable_ethernet_int(void)
109{
110 u32 regval;
111
112 regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
113 regval = (regval | AM35XX_CPGMAC_C0_RX_PULSE_CLR |
114 AM35XX_CPGMAC_C0_TX_PULSE_CLR |
115 AM35XX_CPGMAC_C0_MISC_PULSE_CLR |
116 AM35XX_CPGMAC_C0_RX_THRESH_CLR);
117 omap_ctrl_writel(regval, AM35XX_CONTROL_LVL_INTR_CLEAR);
118 regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
119}
120
121static void am3517_disable_ethernet_int(void)
122{
123 u32 regval;
124
125 regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
126 regval = (regval | AM35XX_CPGMAC_C0_RX_PULSE_CLR |
127 AM35XX_CPGMAC_C0_TX_PULSE_CLR);
128 omap_ctrl_writel(regval, AM35XX_CONTROL_LVL_INTR_CLEAR);
129 regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
130}
131
132static void am3517_evm_ethernet_init(struct emac_platform_data *pdata)
133{
134 unsigned int regval;
135
136 pdata->ctrl_reg_offset = AM35XX_EMAC_CNTRL_OFFSET;
137 pdata->ctrl_mod_reg_offset = AM35XX_EMAC_CNTRL_MOD_OFFSET;
138 pdata->ctrl_ram_offset = AM35XX_EMAC_CNTRL_RAM_OFFSET;
139 pdata->ctrl_ram_size = AM35XX_EMAC_CNTRL_RAM_SIZE;
140 pdata->version = EMAC_VERSION_2;
141 pdata->hw_ram_addr = AM35XX_EMAC_HW_RAM_ADDR;
142 pdata->interrupt_enable = am3517_enable_ethernet_int;
143 pdata->interrupt_disable = am3517_disable_ethernet_int;
144 am3517_emac_device.dev.platform_data = pdata;
145 platform_device_register(&am3517_emac_device);
146 platform_device_register(&am3517_mdio_device);
147 clk_add_alias(NULL, dev_name(&am3517_mdio_device.dev),
148 NULL, &am3517_emac_device.dev);
149
150 regval = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
151 regval = regval & (~(AM35XX_CPGMACSS_SW_RST));
152 omap_ctrl_writel(regval, AM35XX_CONTROL_IP_SW_RESET);
153 regval = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
154
155 return ;
156}
157
158
159
160#define LCD_PANEL_PWR 176 47#define LCD_PANEL_PWR 176
161#define LCD_PANEL_BKLIGHT_PWR 182 48#define LCD_PANEL_BKLIGHT_PWR 182
162#define LCD_PANEL_PWM 181 49#define LCD_PANEL_PWM 181
@@ -498,13 +385,13 @@ static void __init am3517_evm_init(void)
498 i2c_register_board_info(1, am3517evm_i2c1_boardinfo, 385 i2c_register_board_info(1, am3517evm_i2c1_boardinfo,
499 ARRAY_SIZE(am3517evm_i2c1_boardinfo)); 386 ARRAY_SIZE(am3517evm_i2c1_boardinfo));
500 /*Ethernet*/ 387 /*Ethernet*/
501 am3517_evm_ethernet_init(&am3517_evm_emac_pdata); 388 am35xx_emac_init(AM35XX_DEFAULT_MDIO_FREQUENCY, 1);
502 389
503 /* MUSB */ 390 /* MUSB */
504 am3517_evm_musb_init(); 391 am3517_evm_musb_init();
505 392
506 /* MMC init function */ 393 /* MMC init function */
507 omap2_hsmmc_init(mmc); 394 omap_hsmmc_init(mmc);
508} 395}
509 396
510MACHINE_START(OMAP3517EVM, "OMAP3517/AM3517 EVM") 397MACHINE_START(OMAP3517EVM, "OMAP3517/AM3517 EVM")
diff --git a/arch/arm/mach-omap2/board-cm-t35.c b/arch/arm/mach-omap2/board-cm-t35.c
index d73316ed420..41b0a2fe0b0 100644
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -280,7 +280,6 @@ static struct omap_dss_board_info cm_t35_dss_data = {
280 280
281static struct omap2_mcspi_device_config tdo24m_mcspi_config = { 281static struct omap2_mcspi_device_config tdo24m_mcspi_config = {
282 .turbo_mode = 0, 282 .turbo_mode = 0,
283 .single_channel = 1, /* 0: slave, 1: master */
284}; 283};
285 284
286static struct tdo24m_platform_data tdo24m_config = { 285static struct tdo24m_platform_data tdo24m_config = {
@@ -413,7 +412,7 @@ static struct omap2_hsmmc_info mmc[] = {
413 .caps = MMC_CAP_4_BIT_DATA, 412 .caps = MMC_CAP_4_BIT_DATA,
414 .gpio_cd = -EINVAL, 413 .gpio_cd = -EINVAL,
415 .gpio_wp = -EINVAL, 414 .gpio_wp = -EINVAL,
416 415 .deferred = true,
417 }, 416 },
418 { 417 {
419 .mmc = 2, 418 .mmc = 2,
@@ -471,7 +470,7 @@ static int cm_t35_twl_gpio_setup(struct device *dev, unsigned gpio,
471 470
472 /* gpio + 0 is "mmc0_cd" (input/IRQ) */ 471 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
473 mmc[0].gpio_cd = gpio + 0; 472 mmc[0].gpio_cd = gpio + 0;
474 omap2_hsmmc_init(mmc); 473 omap_hsmmc_late_init(mmc);
475 474
476 return 0; 475 return 0;
477} 476}
@@ -639,6 +638,7 @@ static void __init cm_t3x_common_init(void)
639 omap_serial_init(); 638 omap_serial_init();
640 omap_sdrc_init(mt46h32m32lf6_sdrc_params, 639 omap_sdrc_init(mt46h32m32lf6_sdrc_params,
641 mt46h32m32lf6_sdrc_params); 640 mt46h32m32lf6_sdrc_params);
641 omap_hsmmc_init(mmc);
642 cm_t35_init_i2c(); 642 cm_t35_init_i2c();
643 omap_ads7846_init(1, CM_T35_GPIO_PENDOWN, 0, NULL); 643 omap_ads7846_init(1, CM_T35_GPIO_PENDOWN, 0, NULL);
644 cm_t35_init_ethernet(); 644 cm_t35_init_ethernet();
diff --git a/arch/arm/mach-omap2/board-cm-t3517.c b/arch/arm/mach-omap2/board-cm-t3517.c
index f36d694d215..9e66e167e4f 100644
--- a/arch/arm/mach-omap2/board-cm-t3517.c
+++ b/arch/arm/mach-omap2/board-cm-t3517.c
@@ -49,6 +49,7 @@
49#include "mux.h" 49#include "mux.h"
50#include "control.h" 50#include "control.h"
51#include "common-board-devices.h" 51#include "common-board-devices.h"
52#include "am35xx-emac.h"
52 53
53#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE) 54#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
54static struct gpio_led cm_t3517_leds[] = { 55static struct gpio_led cm_t3517_leds[] = {
@@ -291,6 +292,7 @@ static void __init cm_t3517_init(void)
291 cm_t3517_init_rtc(); 292 cm_t3517_init_rtc();
292 cm_t3517_init_usbh(); 293 cm_t3517_init_usbh();
293 cm_t3517_init_hecc(); 294 cm_t3517_init_hecc();
295 am35xx_emac_init(AM35XX_DEFAULT_MDIO_FREQUENCY, 1);
294} 296}
295 297
296MACHINE_START(CM_T3517, "Compulab CM-T3517") 298MACHINE_START(CM_T3517, "Compulab CM-T3517")
diff --git a/arch/arm/mach-omap2/board-devkit8000.c b/arch/arm/mach-omap2/board-devkit8000.c
index e873063f4fd..11cd2a80609 100644
--- a/arch/arm/mach-omap2/board-devkit8000.c
+++ b/arch/arm/mach-omap2/board-devkit8000.c
@@ -100,6 +100,7 @@ static struct omap2_hsmmc_info mmc[] = {
100 .mmc = 1, 100 .mmc = 1,
101 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA, 101 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
102 .gpio_wp = 29, 102 .gpio_wp = 29,
103 .deferred = true,
103 }, 104 },
104 {} /* Terminator */ 105 {} /* Terminator */
105}; 106};
@@ -228,7 +229,7 @@ static int devkit8000_twl_gpio_setup(struct device *dev,
228 229
229 /* gpio + 0 is "mmc0_cd" (input/IRQ) */ 230 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
230 mmc[0].gpio_cd = gpio + 0; 231 mmc[0].gpio_cd = gpio + 0;
231 omap2_hsmmc_init(mmc); 232 omap_hsmmc_late_init(mmc);
232 233
233 /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */ 234 /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */
234 gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1; 235 gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
@@ -636,6 +637,7 @@ static void __init devkit8000_init(void)
636 637
637 omap_dm9000_init(); 638 omap_dm9000_init();
638 639
640 omap_hsmmc_init(mmc);
639 devkit8000_i2c_init(); 641 devkit8000_i2c_init();
640 platform_add_devices(devkit8000_devices, 642 platform_add_devices(devkit8000_devices,
641 ARRAY_SIZE(devkit8000_devices)); 643 ARRAY_SIZE(devkit8000_devices));
diff --git a/arch/arm/mach-omap2/board-flash.c b/arch/arm/mach-omap2/board-flash.c
index 30a6f527510..0349fd2b68d 100644
--- a/arch/arm/mach-omap2/board-flash.c
+++ b/arch/arm/mach-omap2/board-flash.c
@@ -189,7 +189,7 @@ unmap:
189 * 189 *
190 * @return - void. 190 * @return - void.
191 */ 191 */
192void board_flash_init(struct flash_partitions partition_info[], 192void __init board_flash_init(struct flash_partitions partition_info[],
193 char chip_sel_board[][GPMC_CS_NUM], int nand_type) 193 char chip_sel_board[][GPMC_CS_NUM], int nand_type)
194{ 194{
195 u8 cs = 0; 195 u8 cs = 0;
diff --git a/arch/arm/mach-omap2/board-generic.c b/arch/arm/mach-omap2/board-generic.c
index 45fdfe2bd9d..74e1687b517 100644
--- a/arch/arm/mach-omap2/board-generic.c
+++ b/arch/arm/mach-omap2/board-generic.c
@@ -12,6 +12,7 @@
12 * published by the Free Software Foundation. 12 * published by the Free Software Foundation.
13 */ 13 */
14#include <linux/io.h> 14#include <linux/io.h>
15#include <linux/of_irq.h>
15#include <linux/of_platform.h> 16#include <linux/of_platform.h>
16#include <linux/irqdomain.h> 17#include <linux/irqdomain.h>
17#include <linux/i2c/twl.h> 18#include <linux/i2c/twl.h>
@@ -24,33 +25,23 @@
24#include "common.h" 25#include "common.h"
25#include "common-board-devices.h" 26#include "common-board-devices.h"
26 27
27/* 28#if !(defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3))
28 * XXX: Still needed to boot until the i2c & twl driver is adapted to 29#define omap_intc_of_init NULL
29 * device-tree 30#endif
30 */ 31#ifndef CONFIG_ARCH_OMAP4
31#ifdef CONFIG_ARCH_OMAP4 32#define gic_of_init NULL
32static struct twl4030_platform_data sdp4430_twldata = {
33 .irq_base = TWL6030_IRQ_BASE,
34 .irq_end = TWL6030_IRQ_END,
35};
36
37static void __init omap4_i2c_init(void)
38{
39 omap4_pmic_init("twl6030", &sdp4430_twldata);
40}
41#endif 33#endif
42 34
43#ifdef CONFIG_ARCH_OMAP3 35static struct of_device_id irq_match[] __initdata = {
44static struct twl4030_platform_data beagle_twldata = { 36 { .compatible = "ti,omap2-intc", .data = omap_intc_of_init, },
45 .irq_base = TWL4030_IRQ_BASE, 37 { .compatible = "arm,cortex-a9-gic", .data = gic_of_init, },
46 .irq_end = TWL4030_IRQ_END, 38 { }
47}; 39};
48 40
49static void __init omap3_i2c_init(void) 41static void __init omap_init_irq(void)
50{ 42{
51 omap3_pmic_init("twl4030", &beagle_twldata); 43 of_irq_init(irq_match);
52} 44}
53#endif
54 45
55static struct of_device_id omap_dt_match_table[] __initdata = { 46static struct of_device_id omap_dt_match_table[] __initdata = {
56 { .compatible = "simple-bus", }, 47 { .compatible = "simple-bus", },
@@ -58,51 +49,24 @@ static struct of_device_id omap_dt_match_table[] __initdata = {
58 { } 49 { }
59}; 50};
60 51
61static struct of_device_id intc_match[] __initdata = {
62 { .compatible = "ti,omap3-intc", },
63 { .compatible = "arm,cortex-a9-gic", },
64 { }
65};
66
67static void __init omap_generic_init(void) 52static void __init omap_generic_init(void)
68{ 53{
69 struct device_node *node = of_find_matching_node(NULL, intc_match);
70 if (node)
71 irq_domain_add_legacy(node, 32, 0, 0, &irq_domain_simple_ops, NULL);
72
73 omap_sdrc_init(NULL, NULL); 54 omap_sdrc_init(NULL, NULL);
74 55
75 of_platform_populate(NULL, omap_dt_match_table, NULL, NULL); 56 of_platform_populate(NULL, omap_dt_match_table, NULL, NULL);
76} 57}
77 58
78#ifdef CONFIG_ARCH_OMAP4 59#ifdef CONFIG_SOC_OMAP2420
79static void __init omap4_init(void)
80{
81 omap4_i2c_init();
82 omap_generic_init();
83}
84#endif
85
86#ifdef CONFIG_ARCH_OMAP3
87static void __init omap3_init(void)
88{
89 omap3_i2c_init();
90 omap_generic_init();
91}
92#endif
93
94#if defined(CONFIG_SOC_OMAP2420)
95static const char *omap242x_boards_compat[] __initdata = { 60static const char *omap242x_boards_compat[] __initdata = {
96 "ti,omap2420", 61 "ti,omap2420",
97 NULL, 62 NULL,
98}; 63};
99 64
100DT_MACHINE_START(OMAP242X_DT, "Generic OMAP2420 (Flattened Device Tree)") 65DT_MACHINE_START(OMAP242X_DT, "Generic OMAP2420 (Flattened Device Tree)")
101 .atag_offset = 0x100,
102 .reserve = omap_reserve, 66 .reserve = omap_reserve,
103 .map_io = omap242x_map_io, 67 .map_io = omap242x_map_io,
104 .init_early = omap2420_init_early, 68 .init_early = omap2420_init_early,
105 .init_irq = omap2_init_irq, 69 .init_irq = omap_init_irq,
106 .handle_irq = omap2_intc_handle_irq, 70 .handle_irq = omap2_intc_handle_irq,
107 .init_machine = omap_generic_init, 71 .init_machine = omap_generic_init,
108 .timer = &omap2_timer, 72 .timer = &omap2_timer,
@@ -111,18 +75,17 @@ DT_MACHINE_START(OMAP242X_DT, "Generic OMAP2420 (Flattened Device Tree)")
111MACHINE_END 75MACHINE_END
112#endif 76#endif
113 77
114#if defined(CONFIG_SOC_OMAP2430) 78#ifdef CONFIG_SOC_OMAP2430
115static const char *omap243x_boards_compat[] __initdata = { 79static const char *omap243x_boards_compat[] __initdata = {
116 "ti,omap2430", 80 "ti,omap2430",
117 NULL, 81 NULL,
118}; 82};
119 83
120DT_MACHINE_START(OMAP243X_DT, "Generic OMAP2430 (Flattened Device Tree)") 84DT_MACHINE_START(OMAP243X_DT, "Generic OMAP2430 (Flattened Device Tree)")
121 .atag_offset = 0x100,
122 .reserve = omap_reserve, 85 .reserve = omap_reserve,
123 .map_io = omap243x_map_io, 86 .map_io = omap243x_map_io,
124 .init_early = omap2430_init_early, 87 .init_early = omap2430_init_early,
125 .init_irq = omap2_init_irq, 88 .init_irq = omap_init_irq,
126 .handle_irq = omap2_intc_handle_irq, 89 .handle_irq = omap2_intc_handle_irq,
127 .init_machine = omap_generic_init, 90 .init_machine = omap_generic_init,
128 .timer = &omap2_timer, 91 .timer = &omap2_timer,
@@ -131,18 +94,33 @@ DT_MACHINE_START(OMAP243X_DT, "Generic OMAP2430 (Flattened Device Tree)")
131MACHINE_END 94MACHINE_END
132#endif 95#endif
133 96
134#if defined(CONFIG_ARCH_OMAP3) 97#ifdef CONFIG_ARCH_OMAP3
98static struct twl4030_platform_data beagle_twldata = {
99 .irq_base = TWL4030_IRQ_BASE,
100 .irq_end = TWL4030_IRQ_END,
101};
102
103static void __init omap3_i2c_init(void)
104{
105 omap3_pmic_init("twl4030", &beagle_twldata);
106}
107
108static void __init omap3_init(void)
109{
110 omap3_i2c_init();
111 omap_generic_init();
112}
113
135static const char *omap3_boards_compat[] __initdata = { 114static const char *omap3_boards_compat[] __initdata = {
136 "ti,omap3", 115 "ti,omap3",
137 NULL, 116 NULL,
138}; 117};
139 118
140DT_MACHINE_START(OMAP3_DT, "Generic OMAP3 (Flattened Device Tree)") 119DT_MACHINE_START(OMAP3_DT, "Generic OMAP3 (Flattened Device Tree)")
141 .atag_offset = 0x100,
142 .reserve = omap_reserve, 120 .reserve = omap_reserve,
143 .map_io = omap3_map_io, 121 .map_io = omap3_map_io,
144 .init_early = omap3430_init_early, 122 .init_early = omap3430_init_early,
145 .init_irq = omap3_init_irq, 123 .init_irq = omap_init_irq,
146 .handle_irq = omap3_intc_handle_irq, 124 .handle_irq = omap3_intc_handle_irq,
147 .init_machine = omap3_init, 125 .init_machine = omap3_init,
148 .timer = &omap3_timer, 126 .timer = &omap3_timer,
@@ -151,18 +129,33 @@ DT_MACHINE_START(OMAP3_DT, "Generic OMAP3 (Flattened Device Tree)")
151MACHINE_END 129MACHINE_END
152#endif 130#endif
153 131
154#if defined(CONFIG_ARCH_OMAP4) 132#ifdef CONFIG_ARCH_OMAP4
133static struct twl4030_platform_data sdp4430_twldata = {
134 .irq_base = TWL6030_IRQ_BASE,
135 .irq_end = TWL6030_IRQ_END,
136};
137
138static void __init omap4_i2c_init(void)
139{
140 omap4_pmic_init("twl6030", &sdp4430_twldata);
141}
142
143static void __init omap4_init(void)
144{
145 omap4_i2c_init();
146 omap_generic_init();
147}
148
155static const char *omap4_boards_compat[] __initdata = { 149static const char *omap4_boards_compat[] __initdata = {
156 "ti,omap4", 150 "ti,omap4",
157 NULL, 151 NULL,
158}; 152};
159 153
160DT_MACHINE_START(OMAP4_DT, "Generic OMAP4 (Flattened Device Tree)") 154DT_MACHINE_START(OMAP4_DT, "Generic OMAP4 (Flattened Device Tree)")
161 .atag_offset = 0x100,
162 .reserve = omap_reserve, 155 .reserve = omap_reserve,
163 .map_io = omap4_map_io, 156 .map_io = omap4_map_io,
164 .init_early = omap4430_init_early, 157 .init_early = omap4430_init_early,
165 .init_irq = gic_init_irq, 158 .init_irq = omap_init_irq,
166 .handle_irq = gic_handle_irq, 159 .handle_irq = gic_handle_irq,
167 .init_machine = omap4_init, 160 .init_machine = omap4_init,
168 .timer = &omap4_timer, 161 .timer = &omap4_timer,
diff --git a/arch/arm/mach-omap2/board-igep0020.c b/arch/arm/mach-omap2/board-igep0020.c
index a59ace0ed56..e558800adfd 100644
--- a/arch/arm/mach-omap2/board-igep0020.c
+++ b/arch/arm/mach-omap2/board-igep0020.c
@@ -295,6 +295,7 @@ static struct omap2_hsmmc_info mmc[] = {
295 .caps = MMC_CAP_4_BIT_DATA, 295 .caps = MMC_CAP_4_BIT_DATA,
296 .gpio_cd = -EINVAL, 296 .gpio_cd = -EINVAL,
297 .gpio_wp = -EINVAL, 297 .gpio_wp = -EINVAL,
298 .deferred = true,
298 }, 299 },
299#if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE) 300#if defined(CONFIG_LIBERTAS_SDIO) || defined(CONFIG_LIBERTAS_SDIO_MODULE)
300 { 301 {
@@ -402,7 +403,7 @@ static int igep_twl_gpio_setup(struct device *dev,
402 403
403 /* gpio + 0 is "mmc0_cd" (input/IRQ) */ 404 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
404 mmc[0].gpio_cd = gpio + 0; 405 mmc[0].gpio_cd = gpio + 0;
405 omap2_hsmmc_init(mmc); 406 omap_hsmmc_late_init(mmc);
406 407
407 /* TWL4030_GPIO_MAX + 1 == ledB (out, active low LED) */ 408 /* TWL4030_GPIO_MAX + 1 == ledB (out, active low LED) */
408#if !defined(CONFIG_LEDS_GPIO) && !defined(CONFIG_LEDS_GPIO_MODULE) 409#if !defined(CONFIG_LEDS_GPIO) && !defined(CONFIG_LEDS_GPIO_MODULE)
@@ -639,6 +640,9 @@ static void __init igep_init(void)
639 640
640 /* Get IGEP2 hardware revision */ 641 /* Get IGEP2 hardware revision */
641 igep2_get_revision(); 642 igep2_get_revision();
643
644 omap_hsmmc_init(mmc);
645
642 /* Register I2C busses and drivers */ 646 /* Register I2C busses and drivers */
643 igep_i2c_init(); 647 igep_i2c_init();
644 platform_add_devices(igep_devices, ARRAY_SIZE(igep_devices)); 648 platform_add_devices(igep_devices, ARRAY_SIZE(igep_devices));
diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
index 2d2a61f7dcb..d50a562adfa 100644
--- a/arch/arm/mach-omap2/board-ldp.c
+++ b/arch/arm/mach-omap2/board-ldp.c
@@ -27,7 +27,6 @@
27#include <linux/io.h> 27#include <linux/io.h>
28#include <linux/smsc911x.h> 28#include <linux/smsc911x.h>
29#include <linux/mmc/host.h> 29#include <linux/mmc/host.h>
30#include <linux/gpio.h>
31 30
32#include <mach/hardware.h> 31#include <mach/hardware.h>
33#include <asm/mach-types.h> 32#include <asm/mach-types.h>
@@ -424,7 +423,7 @@ static void __init omap_ldp_init(void)
424 board_nand_init(ldp_nand_partitions, 423 board_nand_init(ldp_nand_partitions,
425 ARRAY_SIZE(ldp_nand_partitions), ZOOM_NAND_CS, 0); 424 ARRAY_SIZE(ldp_nand_partitions), ZOOM_NAND_CS, 0);
426 425
427 omap2_hsmmc_init(mmc); 426 omap_hsmmc_init(mmc);
428 ldp_display_init(); 427 ldp_display_init();
429} 428}
430 429
diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
index 67226271760..518091c5f77 100644
--- a/arch/arm/mach-omap2/board-n8x0.c
+++ b/arch/arm/mach-omap2/board-n8x0.c
@@ -36,10 +36,6 @@
36 36
37#include "mux.h" 37#include "mux.h"
38 38
39static int slot1_cover_open;
40static int slot2_cover_open;
41static struct device *mmc_device;
42
43#define TUSB6010_ASYNC_CS 1 39#define TUSB6010_ASYNC_CS 1
44#define TUSB6010_SYNC_CS 4 40#define TUSB6010_SYNC_CS 4
45#define TUSB6010_GPIO_INT 58 41#define TUSB6010_GPIO_INT 58
@@ -137,7 +133,6 @@ static void __init n8x0_usb_init(void) {}
137 133
138static struct omap2_mcspi_device_config p54spi_mcspi_config = { 134static struct omap2_mcspi_device_config p54spi_mcspi_config = {
139 .turbo_mode = 0, 135 .turbo_mode = 0,
140 .single_channel = 1,
141}; 136};
142 137
143static struct spi_board_info n800_spi_board_info[] __initdata = { 138static struct spi_board_info n800_spi_board_info[] __initdata = {
@@ -211,6 +206,10 @@ static struct omap_onenand_platform_data board_onenand_data[] = {
211#define N810_EMMC_VSD_GPIO 23 206#define N810_EMMC_VSD_GPIO 23
212#define N810_EMMC_VIO_GPIO 9 207#define N810_EMMC_VIO_GPIO 9
213 208
209static int slot1_cover_open;
210static int slot2_cover_open;
211static struct device *mmc_device;
212
214static int n8x0_mmc_switch_slot(struct device *dev, int slot) 213static int n8x0_mmc_switch_slot(struct device *dev, int slot)
215{ 214{
216#ifdef CONFIG_MMC_DEBUG 215#ifdef CONFIG_MMC_DEBUG
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index 7ffcd2839e7..7be8d659d91 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -253,6 +253,7 @@ static struct omap2_hsmmc_info mmc[] = {
253 .mmc = 1, 253 .mmc = 1,
254 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA, 254 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
255 .gpio_wp = -EINVAL, 255 .gpio_wp = -EINVAL,
256 .deferred = true,
256 }, 257 },
257 {} /* Terminator */ 258 {} /* Terminator */
258}; 259};
@@ -272,12 +273,10 @@ static int beagle_twl_gpio_setup(struct device *dev,
272{ 273{
273 int r; 274 int r;
274 275
275 if (beagle_config.mmc1_gpio_wp != -EINVAL)
276 omap_mux_init_gpio(beagle_config.mmc1_gpio_wp, OMAP_PIN_INPUT);
277 mmc[0].gpio_wp = beagle_config.mmc1_gpio_wp; 276 mmc[0].gpio_wp = beagle_config.mmc1_gpio_wp;
278 /* gpio + 0 is "mmc0_cd" (input/IRQ) */ 277 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
279 mmc[0].gpio_cd = gpio + 0; 278 mmc[0].gpio_cd = gpio + 0;
280 omap2_hsmmc_init(mmc); 279 omap_hsmmc_late_init(mmc);
281 280
282 /* 281 /*
283 * TWL4030_GPIO_MAX + 0 == ledA, EHCI nEN_USB_PWR (out, XM active 282 * TWL4030_GPIO_MAX + 0 == ledA, EHCI nEN_USB_PWR (out, XM active
@@ -521,6 +520,11 @@ static void __init omap3_beagle_init(void)
521{ 520{
522 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB); 521 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
523 omap3_beagle_init_rev(); 522 omap3_beagle_init_rev();
523
524 if (beagle_config.mmc1_gpio_wp != -EINVAL)
525 omap_mux_init_gpio(beagle_config.mmc1_gpio_wp, OMAP_PIN_INPUT);
526 omap_hsmmc_init(mmc);
527
524 omap3_beagle_i2c_init(); 528 omap3_beagle_i2c_init();
525 529
526 gpio_buttons[0].gpio = beagle_config.usr_button_gpio; 530 gpio_buttons[0].gpio = beagle_config.usr_button_gpio;
diff --git a/arch/arm/mach-omap2/board-omap3evm.c b/arch/arm/mach-omap2/board-omap3evm.c
index c877236a844..a659e198892 100644
--- a/arch/arm/mach-omap2/board-omap3evm.c
+++ b/arch/arm/mach-omap2/board-omap3evm.c
@@ -317,6 +317,7 @@ static struct omap2_hsmmc_info mmc[] = {
317 .caps = MMC_CAP_4_BIT_DATA, 317 .caps = MMC_CAP_4_BIT_DATA,
318 .gpio_cd = -EINVAL, 318 .gpio_cd = -EINVAL,
319 .gpio_wp = 63, 319 .gpio_wp = 63,
320 .deferred = true,
320 }, 321 },
321#ifdef CONFIG_WL12XX_PLATFORM_DATA 322#ifdef CONFIG_WL12XX_PLATFORM_DATA
322 { 323 {
@@ -361,9 +362,8 @@ static int omap3evm_twl_gpio_setup(struct device *dev,
361 int r, lcd_bl_en; 362 int r, lcd_bl_en;
362 363
363 /* gpio + 0 is "mmc0_cd" (input/IRQ) */ 364 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
364 omap_mux_init_gpio(63, OMAP_PIN_INPUT);
365 mmc[0].gpio_cd = gpio + 0; 365 mmc[0].gpio_cd = gpio + 0;
366 omap2_hsmmc_init(mmc); 366 omap_hsmmc_late_init(mmc);
367 367
368 /* 368 /*
369 * Most GPIOs are for USB OTG. Some are mostly sent to 369 * Most GPIOs are for USB OTG. Some are mostly sent to
@@ -644,6 +644,9 @@ static void __init omap3_evm_init(void)
644 omap_board_config = omap3_evm_config; 644 omap_board_config = omap3_evm_config;
645 omap_board_config_size = ARRAY_SIZE(omap3_evm_config); 645 omap_board_config_size = ARRAY_SIZE(omap3_evm_config);
646 646
647 omap_mux_init_gpio(63, OMAP_PIN_INPUT);
648 omap_hsmmc_init(mmc);
649
647 omap3_evm_i2c_init(); 650 omap3_evm_i2c_init();
648 651
649 omap_display_init(&omap3_evm_dss_data); 652 omap_display_init(&omap3_evm_dss_data);
diff --git a/arch/arm/mach-omap2/board-omap3logic.c b/arch/arm/mach-omap2/board-omap3logic.c
index 4198dd017d8..4a7d8c8a75d 100644
--- a/arch/arm/mach-omap2/board-omap3logic.c
+++ b/arch/arm/mach-omap2/board-omap3logic.c
@@ -128,7 +128,7 @@ static void __init board_mmc_init(void)
128 return; 128 return;
129 } 129 }
130 130
131 omap2_hsmmc_init(board_mmc_info); 131 omap_hsmmc_init(board_mmc_info);
132} 132}
133 133
134static struct omap_smsc911x_platform_data __initdata board_smsc911x_data = { 134static struct omap_smsc911x_platform_data __initdata board_smsc911x_data = {
@@ -205,6 +205,7 @@ static void __init omap3logic_init(void)
205 205
206MACHINE_START(OMAP3_TORPEDO, "Logic OMAP3 Torpedo board") 206MACHINE_START(OMAP3_TORPEDO, "Logic OMAP3 Torpedo board")
207 .atag_offset = 0x100, 207 .atag_offset = 0x100,
208 .reserve = omap_reserve,
208 .map_io = omap3_map_io, 209 .map_io = omap3_map_io,
209 .init_early = omap35xx_init_early, 210 .init_early = omap35xx_init_early,
210 .init_irq = omap3_init_irq, 211 .init_irq = omap3_init_irq,
@@ -216,6 +217,7 @@ MACHINE_END
216 217
217MACHINE_START(OMAP3530_LV_SOM, "OMAP Logic 3530 LV SOM board") 218MACHINE_START(OMAP3530_LV_SOM, "OMAP Logic 3530 LV SOM board")
218 .atag_offset = 0x100, 219 .atag_offset = 0x100,
220 .reserve = omap_reserve,
219 .map_io = omap3_map_io, 221 .map_io = omap3_map_io,
220 .init_early = omap35xx_init_early, 222 .init_early = omap35xx_init_early,
221 .init_irq = omap3_init_irq, 223 .init_irq = omap3_init_irq,
diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c
index 1644b73017f..33d995d0f07 100644
--- a/arch/arm/mach-omap2/board-omap3pandora.c
+++ b/arch/arm/mach-omap2/board-omap3pandora.c
@@ -121,6 +121,11 @@ static struct platform_device pandora_leds_gpio = {
121 }, 121 },
122}; 122};
123 123
124static struct platform_device pandora_backlight = {
125 .name = "pandora-backlight",
126 .id = -1,
127};
128
124#define GPIO_BUTTON(gpio_num, ev_type, ev_code, act_low, descr) \ 129#define GPIO_BUTTON(gpio_num, ev_type, ev_code, act_low, descr) \
125{ \ 130{ \
126 .gpio = gpio_num, \ 131 .gpio = gpio_num, \
@@ -273,6 +278,7 @@ static struct omap2_hsmmc_info omap3pandora_mmc[] = {
273 .gpio_cd = -EINVAL, 278 .gpio_cd = -EINVAL,
274 .gpio_wp = 126, 279 .gpio_wp = 126,
275 .ext_clock = 0, 280 .ext_clock = 0,
281 .deferred = true,
276 }, 282 },
277 { 283 {
278 .mmc = 2, 284 .mmc = 2,
@@ -281,6 +287,7 @@ static struct omap2_hsmmc_info omap3pandora_mmc[] = {
281 .gpio_wp = 127, 287 .gpio_wp = 127,
282 .ext_clock = 1, 288 .ext_clock = 1,
283 .transceiver = true, 289 .transceiver = true,
290 .deferred = true,
284 }, 291 },
285 { 292 {
286 .mmc = 3, 293 .mmc = 3,
@@ -300,7 +307,7 @@ static int omap3pandora_twl_gpio_setup(struct device *dev,
300 /* gpio + {0,1} is "mmc{0,1}_cd" (input/IRQ) */ 307 /* gpio + {0,1} is "mmc{0,1}_cd" (input/IRQ) */
301 omap3pandora_mmc[0].gpio_cd = gpio + 0; 308 omap3pandora_mmc[0].gpio_cd = gpio + 0;
302 omap3pandora_mmc[1].gpio_cd = gpio + 1; 309 omap3pandora_mmc[1].gpio_cd = gpio + 1;
303 omap2_hsmmc_init(omap3pandora_mmc); 310 omap_hsmmc_late_init(omap3pandora_mmc);
304 311
305 /* gpio + 13 drives 32kHz buffer for wifi module */ 312 /* gpio + 13 drives 32kHz buffer for wifi module */
306 gpio_32khz = gpio + 13; 313 gpio_32khz = gpio + 13;
@@ -343,7 +350,7 @@ static struct regulator_consumer_supply pandora_vcc_lcd_supply[] = {
343}; 350};
344 351
345static struct regulator_consumer_supply pandora_usb_phy_supply[] = { 352static struct regulator_consumer_supply pandora_usb_phy_supply[] = {
346 REGULATOR_SUPPLY("hsusb0", "ehci-omap.0"), 353 REGULATOR_SUPPLY("hsusb1", "ehci-omap.0"),
347}; 354};
348 355
349/* ads7846 on SPI and 2 nub controllers on I2C */ 356/* ads7846 on SPI and 2 nub controllers on I2C */
@@ -476,6 +483,10 @@ static struct platform_device pandora_vwlan_device = {
476 483
477static struct twl4030_bci_platform_data pandora_bci_data; 484static struct twl4030_bci_platform_data pandora_bci_data;
478 485
486static struct twl4030_power_data pandora_power_data = {
487 .use_poweroff = true,
488};
489
479static struct twl4030_platform_data omap3pandora_twldata = { 490static struct twl4030_platform_data omap3pandora_twldata = {
480 .gpio = &omap3pandora_gpio_data, 491 .gpio = &omap3pandora_gpio_data,
481 .vmmc1 = &pandora_vmmc1, 492 .vmmc1 = &pandora_vmmc1,
@@ -486,6 +497,7 @@ static struct twl4030_platform_data omap3pandora_twldata = {
486 .vsim = &pandora_vsim, 497 .vsim = &pandora_vsim,
487 .keypad = &pandora_kp_data, 498 .keypad = &pandora_kp_data,
488 .bci = &pandora_bci_data, 499 .bci = &pandora_bci_data,
500 .power = &pandora_power_data,
489}; 501};
490 502
491static struct i2c_board_info __initdata omap3pandora_i2c3_boardinfo[] = { 503static struct i2c_board_info __initdata omap3pandora_i2c3_boardinfo[] = {
@@ -557,17 +569,18 @@ static struct platform_device *omap3pandora_devices[] __initdata = {
557 &pandora_leds_gpio, 569 &pandora_leds_gpio,
558 &pandora_keys_gpio, 570 &pandora_keys_gpio,
559 &pandora_vwlan_device, 571 &pandora_vwlan_device,
572 &pandora_backlight,
560}; 573};
561 574
562static const struct usbhs_omap_board_data usbhs_bdata __initconst = { 575static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
563 576
564 .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY, 577 .port_mode[0] = OMAP_USBHS_PORT_MODE_UNUSED,
565 .port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED, 578 .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
566 .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED, 579 .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
567 580
568 .phy_reset = true, 581 .phy_reset = true,
569 .reset_gpio_port[0] = 16, 582 .reset_gpio_port[0] = -EINVAL,
570 .reset_gpio_port[1] = -EINVAL, 583 .reset_gpio_port[1] = 16,
571 .reset_gpio_port[2] = -EINVAL 584 .reset_gpio_port[2] = -EINVAL
572}; 585};
573 586
@@ -580,6 +593,7 @@ static struct omap_board_mux board_mux[] __initdata = {
580static void __init omap3pandora_init(void) 593static void __init omap3pandora_init(void)
581{ 594{
582 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB); 595 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
596 omap_hsmmc_init(omap3pandora_mmc);
583 omap3pandora_i2c_init(); 597 omap3pandora_i2c_init();
584 pandora_wl1251_init(); 598 pandora_wl1251_init();
585 platform_add_devices(omap3pandora_devices, 599 platform_add_devices(omap3pandora_devices,
diff --git a/arch/arm/mach-omap2/board-omap3stalker.c b/arch/arm/mach-omap2/board-omap3stalker.c
index cb089a46f62..64100438079 100644
--- a/arch/arm/mach-omap2/board-omap3stalker.c
+++ b/arch/arm/mach-omap2/board-omap3stalker.c
@@ -209,10 +209,11 @@ static struct regulator_init_data omap3stalker_vsim = {
209 209
210static struct omap2_hsmmc_info mmc[] = { 210static struct omap2_hsmmc_info mmc[] = {
211 { 211 {
212 .mmc = 1, 212 .mmc = 1,
213 .caps = MMC_CAP_4_BIT_DATA, 213 .caps = MMC_CAP_4_BIT_DATA,
214 .gpio_cd = -EINVAL, 214 .gpio_cd = -EINVAL,
215 .gpio_wp = 23, 215 .gpio_wp = 23,
216 .deferred = true,
216 }, 217 },
217 {} /* Terminator */ 218 {} /* Terminator */
218}; 219};
@@ -282,9 +283,8 @@ omap3stalker_twl_gpio_setup(struct device *dev,
282 unsigned gpio, unsigned ngpio) 283 unsigned gpio, unsigned ngpio)
283{ 284{
284 /* gpio + 0 is "mmc0_cd" (input/IRQ) */ 285 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
285 omap_mux_init_gpio(23, OMAP_PIN_INPUT);
286 mmc[0].gpio_cd = gpio + 0; 286 mmc[0].gpio_cd = gpio + 0;
287 omap2_hsmmc_init(mmc); 287 omap_hsmmc_late_init(mmc);
288 288
289 /* 289 /*
290 * Most GPIOs are for USB OTG. Some are mostly sent to 290 * Most GPIOs are for USB OTG. Some are mostly sent to
@@ -425,6 +425,9 @@ static void __init omap3_stalker_init(void)
425 omap_board_config = omap3_stalker_config; 425 omap_board_config = omap3_stalker_config;
426 omap_board_config_size = ARRAY_SIZE(omap3_stalker_config); 426 omap_board_config_size = ARRAY_SIZE(omap3_stalker_config);
427 427
428 omap_mux_init_gpio(23, OMAP_PIN_INPUT);
429 omap_hsmmc_init(mmc);
430
428 omap3_stalker_i2c_init(); 431 omap3_stalker_i2c_init();
429 432
430 platform_add_devices(omap3_stalker_devices, 433 platform_add_devices(omap3_stalker_devices,
diff --git a/arch/arm/mach-omap2/board-omap3touchbook.c b/arch/arm/mach-omap2/board-omap3touchbook.c
index c4f55a8cc71..ae2251fa4a6 100644
--- a/arch/arm/mach-omap2/board-omap3touchbook.c
+++ b/arch/arm/mach-omap2/board-omap3touchbook.c
@@ -101,6 +101,7 @@ static struct omap2_hsmmc_info mmc[] = {
101 .mmc = 1, 101 .mmc = 1,
102 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA, 102 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
103 .gpio_wp = 29, 103 .gpio_wp = 29,
104 .deferred = true,
104 }, 105 },
105 {} /* Terminator */ 106 {} /* Terminator */
106}; 107};
@@ -118,15 +119,9 @@ static struct gpio_led gpio_leds[];
118static int touchbook_twl_gpio_setup(struct device *dev, 119static int touchbook_twl_gpio_setup(struct device *dev,
119 unsigned gpio, unsigned ngpio) 120 unsigned gpio, unsigned ngpio)
120{ 121{
121 if (system_rev >= 0x20 && system_rev <= 0x34301000) {
122 omap_mux_init_gpio(23, OMAP_PIN_INPUT);
123 mmc[0].gpio_wp = 23;
124 } else {
125 omap_mux_init_gpio(29, OMAP_PIN_INPUT);
126 }
127 /* gpio + 0 is "mmc0_cd" (input/IRQ) */ 122 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
128 mmc[0].gpio_cd = gpio + 0; 123 mmc[0].gpio_cd = gpio + 0;
129 omap2_hsmmc_init(mmc); 124 omap_hsmmc_late_init(mmc);
130 125
131 /* REVISIT: need ehci-omap hooks for external VBUS 126 /* REVISIT: need ehci-omap hooks for external VBUS
132 * power switch and overcurrent detect 127 * power switch and overcurrent detect
@@ -352,6 +347,14 @@ static void __init omap3_touchbook_init(void)
352 347
353 pm_power_off = omap3_touchbook_poweroff; 348 pm_power_off = omap3_touchbook_poweroff;
354 349
350 if (system_rev >= 0x20 && system_rev <= 0x34301000) {
351 omap_mux_init_gpio(23, OMAP_PIN_INPUT);
352 mmc[0].gpio_wp = 23;
353 } else {
354 omap_mux_init_gpio(29, OMAP_PIN_INPUT);
355 }
356 omap_hsmmc_init(mmc);
357
355 omap3_touchbook_i2c_init(); 358 omap3_touchbook_i2c_init();
356 platform_add_devices(omap3_touchbook_devices, 359 platform_add_devices(omap3_touchbook_devices,
357 ARRAY_SIZE(omap3_touchbook_devices)); 360 ARRAY_SIZE(omap3_touchbook_devices));
diff --git a/arch/arm/mach-omap2/board-omap4panda.c b/arch/arm/mach-omap2/board-omap4panda.c
index e4415917693..8bf8e99c358 100644
--- a/arch/arm/mach-omap2/board-omap4panda.c
+++ b/arch/arm/mach-omap2/board-omap4panda.c
@@ -116,10 +116,16 @@ static struct platform_device panda_abe_audio = {
116 }, 116 },
117}; 117};
118 118
119static struct platform_device btwilink_device = {
120 .name = "btwilink",
121 .id = -1,
122};
123
119static struct platform_device *panda_devices[] __initdata = { 124static struct platform_device *panda_devices[] __initdata = {
120 &leds_gpio, 125 &leds_gpio,
121 &wl1271_device, 126 &wl1271_device,
122 &panda_abe_audio, 127 &panda_abe_audio,
128 &btwilink_device,
123}; 129};
124 130
125static const struct usbhs_omap_board_data usbhs_bdata __initconst = { 131static const struct usbhs_omap_board_data usbhs_bdata __initconst = {
@@ -232,7 +238,7 @@ struct wl12xx_platform_data omap_panda_wlan_data __initdata = {
232 238
233static int omap4_twl6030_hsmmc_late_init(struct device *dev) 239static int omap4_twl6030_hsmmc_late_init(struct device *dev)
234{ 240{
235 int ret = 0; 241 int irq = 0;
236 struct platform_device *pdev = container_of(dev, 242 struct platform_device *pdev = container_of(dev,
237 struct platform_device, dev); 243 struct platform_device, dev);
238 struct omap_mmc_platform_data *pdata = dev->platform_data; 244 struct omap_mmc_platform_data *pdata = dev->platform_data;
@@ -243,14 +249,15 @@ static int omap4_twl6030_hsmmc_late_init(struct device *dev)
243 } 249 }
244 /* Setting MMC1 Card detect Irq */ 250 /* Setting MMC1 Card detect Irq */
245 if (pdev->id == 0) { 251 if (pdev->id == 0) {
246 ret = twl6030_mmc_card_detect_config(); 252 irq = twl6030_mmc_card_detect_config();
247 if (ret) 253 if (irq < 0) {
248 dev_err(dev, "%s: Error card detect config(%d)\n", 254 dev_err(dev, "%s: Error card detect config(%d)\n",
249 __func__, ret); 255 __func__, irq);
250 else 256 return irq;
251 pdata->slots[0].card_detect = twl6030_mmc_card_detect; 257 }
258 pdata->slots[0].card_detect = twl6030_mmc_card_detect;
252 } 259 }
253 return ret; 260 return 0;
254} 261}
255 262
256static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev) 263static __init void omap4_twl6030_hsmmc_set_late_init(struct device *dev)
@@ -271,9 +278,9 @@ static int __init omap4_twl6030_hsmmc_init(struct omap2_hsmmc_info *controllers)
271{ 278{
272 struct omap2_hsmmc_info *c; 279 struct omap2_hsmmc_info *c;
273 280
274 omap2_hsmmc_init(controllers); 281 omap_hsmmc_init(controllers);
275 for (c = controllers; c->mmc; c++) 282 for (c = controllers; c->mmc; c++)
276 omap4_twl6030_hsmmc_set_late_init(c->dev); 283 omap4_twl6030_hsmmc_set_late_init(&c->pdev->dev);
277 284
278 return 0; 285 return 0;
279} 286}
@@ -504,7 +511,7 @@ static struct omap_dss_board_info omap4_panda_dss_data = {
504 .default_device = &omap4_panda_dvi_device, 511 .default_device = &omap4_panda_dvi_device,
505}; 512};
506 513
507void omap4_panda_display_init(void) 514void __init omap4_panda_display_init(void)
508{ 515{
509 int r; 516 int r;
510 517
diff --git a/arch/arm/mach-omap2/board-overo.c b/arch/arm/mach-omap2/board-overo.c
index 52c0cef7716..668533e2a37 100644
--- a/arch/arm/mach-omap2/board-overo.c
+++ b/arch/arm/mach-omap2/board-overo.c
@@ -407,8 +407,6 @@ static inline void __init overo_init_keys(void) { return; }
407static int overo_twl_gpio_setup(struct device *dev, 407static int overo_twl_gpio_setup(struct device *dev,
408 unsigned gpio, unsigned ngpio) 408 unsigned gpio, unsigned ngpio)
409{ 409{
410 omap2_hsmmc_init(mmc);
411
412#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE) 410#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
413 /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */ 411 /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */
414 gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1; 412 gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
@@ -505,6 +503,7 @@ static void __init overo_init(void)
505 int ret; 503 int ret;
506 504
507 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB); 505 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
506 omap_hsmmc_init(mmc);
508 overo_i2c_init(); 507 overo_i2c_init();
509 omap_display_init(&overo_dss_data); 508 omap_display_init(&overo_dss_data);
510 omap_serial_init(); 509 omap_serial_init();
diff --git a/arch/arm/mach-omap2/board-rm680.c b/arch/arm/mach-omap2/board-rm680.c
index 8678b386c6a..ae53d71f0ce 100644
--- a/arch/arm/mach-omap2/board-rm680.c
+++ b/arch/arm/mach-omap2/board-rm680.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Board support file for Nokia RM-680. 2 * Board support file for Nokia RM-680/696.
3 * 3 *
4 * Copyright (C) 2010 Nokia 4 * Copyright (C) 2010 Nokia
5 * 5 *
@@ -120,7 +120,7 @@ static void __init rm680_peripherals_init(void)
120 ARRAY_SIZE(rm680_peripherals_devices)); 120 ARRAY_SIZE(rm680_peripherals_devices));
121 rm680_i2c_init(); 121 rm680_i2c_init();
122 gpmc_onenand_init(board_onenand_data); 122 gpmc_onenand_init(board_onenand_data);
123 omap2_hsmmc_init(mmc); 123 omap_hsmmc_init(mmc);
124} 124}
125 125
126#ifdef CONFIG_OMAP_MUX 126#ifdef CONFIG_OMAP_MUX
@@ -154,3 +154,15 @@ MACHINE_START(NOKIA_RM680, "Nokia RM-680 board")
154 .timer = &omap3_timer, 154 .timer = &omap3_timer,
155 .restart = omap_prcm_restart, 155 .restart = omap_prcm_restart,
156MACHINE_END 156MACHINE_END
157
158MACHINE_START(NOKIA_RM696, "Nokia RM-696 board")
159 .atag_offset = 0x100,
160 .reserve = omap_reserve,
161 .map_io = omap3_map_io,
162 .init_early = omap3630_init_early,
163 .init_irq = omap3_init_irq,
164 .handle_irq = omap3_intc_handle_irq,
165 .init_machine = rm680_init,
166 .timer = &omap3_timer,
167 .restart = omap_prcm_restart,
168MACHINE_END
diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c b/arch/arm/mach-omap2/board-rx51-peripherals.c
index 2bf84fda181..f120997309a 100644
--- a/arch/arm/mach-omap2/board-rx51-peripherals.c
+++ b/arch/arm/mach-omap2/board-rx51-peripherals.c
@@ -139,17 +139,14 @@ static struct lp5523_platform_data rx51_lp5523_platform_data = {
139 139
140static struct omap2_mcspi_device_config wl1251_mcspi_config = { 140static struct omap2_mcspi_device_config wl1251_mcspi_config = {
141 .turbo_mode = 0, 141 .turbo_mode = 0,
142 .single_channel = 1,
143}; 142};
144 143
145static struct omap2_mcspi_device_config mipid_mcspi_config = { 144static struct omap2_mcspi_device_config mipid_mcspi_config = {
146 .turbo_mode = 0, 145 .turbo_mode = 0,
147 .single_channel = 1,
148}; 146};
149 147
150static struct omap2_mcspi_device_config tsc2005_mcspi_config = { 148static struct omap2_mcspi_device_config tsc2005_mcspi_config = {
151 .turbo_mode = 0, 149 .turbo_mode = 0,
152 .single_channel = 1,
153}; 150};
154 151
155static struct spi_board_info rx51_peripherals_spi_board_info[] __initdata = { 152static struct spi_board_info rx51_peripherals_spi_board_info[] __initdata = {
@@ -1106,6 +1103,11 @@ static struct tsc2005_platform_data tsc2005_pdata = {
1106 .esd_timeout_ms = 8000, 1103 .esd_timeout_ms = 8000,
1107}; 1104};
1108 1105
1106static struct gpio rx51_tsc2005_gpios[] __initdata = {
1107 { RX51_TSC2005_IRQ_GPIO, GPIOF_IN, "tsc2005 IRQ" },
1108 { RX51_TSC2005_RESET_GPIO, GPIOF_OUT_INIT_HIGH, "tsc2005 reset" },
1109};
1110
1109static void rx51_tsc2005_set_reset(bool enable) 1111static void rx51_tsc2005_set_reset(bool enable)
1110{ 1112{
1111 gpio_set_value(RX51_TSC2005_RESET_GPIO, enable); 1113 gpio_set_value(RX51_TSC2005_RESET_GPIO, enable);
@@ -1115,20 +1117,18 @@ static void __init rx51_init_tsc2005(void)
1115{ 1117{
1116 int r; 1118 int r;
1117 1119
1118 r = gpio_request_one(RX51_TSC2005_IRQ_GPIO, GPIOF_IN, "tsc2005 IRQ"); 1120 omap_mux_init_gpio(RX51_TSC2005_RESET_GPIO, OMAP_PIN_OUTPUT);
1119 if (r < 0) { 1121 omap_mux_init_gpio(RX51_TSC2005_IRQ_GPIO, OMAP_PIN_INPUT_PULLUP);
1120 printk(KERN_ERR "unable to get %s GPIO\n", "tsc2005 IRQ");
1121 rx51_peripherals_spi_board_info[RX51_SPI_TSC2005].irq = 0;
1122 }
1123 1122
1124 r = gpio_request_one(RX51_TSC2005_RESET_GPIO, GPIOF_OUT_INIT_HIGH, 1123 r = gpio_request_array(rx51_tsc2005_gpios,
1125 "tsc2005 reset"); 1124 ARRAY_SIZE(rx51_tsc2005_gpios));
1126 if (r >= 0) { 1125 if (r < 0) {
1127 tsc2005_pdata.set_reset = rx51_tsc2005_set_reset; 1126 printk(KERN_ERR "tsc2005 board initialization failed\n");
1128 } else {
1129 printk(KERN_ERR "unable to get %s GPIO\n", "tsc2005 reset");
1130 tsc2005_pdata.esd_timeout_ms = 0; 1127 tsc2005_pdata.esd_timeout_ms = 0;
1128 return;
1131 } 1129 }
1130
1131 tsc2005_pdata.set_reset = rx51_tsc2005_set_reset;
1132} 1132}
1133 1133
1134void __init rx51_peripherals_init(void) 1134void __init rx51_peripherals_init(void)
@@ -1146,7 +1146,7 @@ void __init rx51_peripherals_init(void)
1146 1146
1147 partition = omap_mux_get("core"); 1147 partition = omap_mux_get("core");
1148 if (partition) 1148 if (partition)
1149 omap2_hsmmc_init(mmc); 1149 omap_hsmmc_init(mmc);
1150 1150
1151 rx51_charger_init(); 1151 rx51_charger_init();
1152} 1152}
diff --git a/arch/arm/mach-omap2/board-zoom-display.c b/arch/arm/mach-omap2/board-zoom-display.c
index d4683ba5f72..a43a765dd09 100644
--- a/arch/arm/mach-omap2/board-zoom-display.c
+++ b/arch/arm/mach-omap2/board-zoom-display.c
@@ -55,6 +55,7 @@ static void zoom_panel_disable_lcd(struct omap_dss_device *dssdev)
55 55
56static int zoom_set_bl_intensity(struct omap_dss_device *dssdev, int level) 56static int zoom_set_bl_intensity(struct omap_dss_device *dssdev, int level)
57{ 57{
58#ifdef CONFIG_TWL4030_CORE
58 unsigned char c; 59 unsigned char c;
59 u8 mux_pwm, enb_pwm; 60 u8 mux_pwm, enb_pwm;
60 61
@@ -90,6 +91,9 @@ static int zoom_set_bl_intensity(struct omap_dss_device *dssdev, int level)
90 c = ((50 * (100 - level)) / 100) + 1; 91 c = ((50 * (100 - level)) / 100) + 1;
91 twl_i2c_write_u8(TWL4030_MODULE_PWM1, 0x7F, TWL_LED_PWMOFF); 92 twl_i2c_write_u8(TWL4030_MODULE_PWM1, 0x7F, TWL_LED_PWMOFF);
92 twl_i2c_write_u8(TWL4030_MODULE_PWM1, c, TWL_LED_PWMON); 93 twl_i2c_write_u8(TWL4030_MODULE_PWM1, c, TWL_LED_PWMON);
94#else
95 pr_warn("Backlight not enabled\n");
96#endif
93 97
94 return 0; 98 return 0;
95} 99}
@@ -117,7 +121,6 @@ static struct omap_dss_board_info zoom_dss_data = {
117 121
118static struct omap2_mcspi_device_config dss_lcd_mcspi_config = { 122static struct omap2_mcspi_device_config dss_lcd_mcspi_config = {
119 .turbo_mode = 1, 123 .turbo_mode = 1,
120 .single_channel = 1, /* 0: slave, 1: master */
121}; 124};
122 125
123static struct spi_board_info nec_8048_spi_board_info[] __initdata = { 126static struct spi_board_info nec_8048_spi_board_info[] __initdata = {
diff --git a/arch/arm/mach-omap2/board-zoom-peripherals.c b/arch/arm/mach-omap2/board-zoom-peripherals.c
index c126461836a..3d39cdb2e25 100644
--- a/arch/arm/mach-omap2/board-zoom-peripherals.c
+++ b/arch/arm/mach-omap2/board-zoom-peripherals.c
@@ -205,6 +205,7 @@ static struct omap2_hsmmc_info mmc[] = {
205 .caps = MMC_CAP_4_BIT_DATA, 205 .caps = MMC_CAP_4_BIT_DATA,
206 .gpio_wp = -EINVAL, 206 .gpio_wp = -EINVAL,
207 .power_saving = true, 207 .power_saving = true,
208 .deferred = true,
208 }, 209 },
209 { 210 {
210 .name = "internal", 211 .name = "internal",
@@ -233,7 +234,7 @@ static int zoom_twl_gpio_setup(struct device *dev,
233 234
234 /* gpio + 0 is "mmc0_cd" (input/IRQ) */ 235 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
235 mmc[0].gpio_cd = gpio + 0; 236 mmc[0].gpio_cd = gpio + 0;
236 omap2_hsmmc_init(mmc); 237 omap_hsmmc_late_init(mmc);
237 238
238 ret = gpio_request_one(LCD_PANEL_ENABLE_GPIO, GPIOF_OUT_INIT_LOW, 239 ret = gpio_request_one(LCD_PANEL_ENABLE_GPIO, GPIOF_OUT_INIT_LOW,
239 "lcd enable"); 240 "lcd enable");
@@ -301,6 +302,7 @@ void __init zoom_peripherals_init(void)
301 if (ret) 302 if (ret)
302 pr_err("error setting wl12xx data: %d\n", ret); 303 pr_err("error setting wl12xx data: %d\n", ret);
303 304
305 omap_hsmmc_init(mmc);
304 omap_i2c_init(); 306 omap_i2c_init();
305 platform_device_register(&omap_vwlan_device); 307 platform_device_register(&omap_vwlan_device);
306 usb_musb_init(NULL); 308 usb_musb_init(NULL);
diff --git a/arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c b/arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c
index 39f9d5a58d0..7072e0d651b 100644
--- a/arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c
+++ b/arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c
@@ -33,6 +33,7 @@
33#include <linux/cpufreq.h> 33#include <linux/cpufreq.h>
34#include <linux/slab.h> 34#include <linux/slab.h>
35 35
36#include <plat/cpu.h>
36#include <plat/clock.h> 37#include <plat/clock.h>
37#include <plat/sram.h> 38#include <plat/sram.h>
38#include <plat/sdrc.h> 39#include <plat/sdrc.h>
diff --git a/arch/arm/mach-omap2/clkt_clksel.c b/arch/arm/mach-omap2/clkt_clksel.c
index e25364de028..04d551b1f7f 100644
--- a/arch/arm/mach-omap2/clkt_clksel.c
+++ b/arch/arm/mach-omap2/clkt_clksel.c
@@ -43,6 +43,7 @@
43#include <linux/errno.h> 43#include <linux/errno.h>
44#include <linux/clk.h> 44#include <linux/clk.h>
45#include <linux/io.h> 45#include <linux/io.h>
46#include <linux/bug.h>
46 47
47#include <plat/clock.h> 48#include <plat/clock.h>
48 49
diff --git a/arch/arm/mach-omap2/clkt_dpll.c b/arch/arm/mach-omap2/clkt_dpll.c
index e069a9be93d..cd7fd0f9114 100644
--- a/arch/arm/mach-omap2/clkt_dpll.c
+++ b/arch/arm/mach-omap2/clkt_dpll.c
@@ -22,6 +22,7 @@
22#include <asm/div64.h> 22#include <asm/div64.h>
23 23
24#include <plat/clock.h> 24#include <plat/clock.h>
25#include <plat/cpu.h>
25 26
26#include "clock.h" 27#include "clock.h"
27#include "cm-regbits-24xx.h" 28#include "cm-regbits-24xx.h"
diff --git a/arch/arm/mach-omap2/clock2420_data.c b/arch/arm/mach-omap2/clock2420_data.c
index 61ad3855f10..bace9308a4d 100644
--- a/arch/arm/mach-omap2/clock2420_data.c
+++ b/arch/arm/mach-omap2/clock2420_data.c
@@ -14,11 +14,14 @@
14 */ 14 */
15 15
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/io.h>
17#include <linux/clk.h> 18#include <linux/clk.h>
18#include <linux/list.h> 19#include <linux/list.h>
19 20
21#include <plat/hardware.h>
20#include <plat/clkdev_omap.h> 22#include <plat/clkdev_omap.h>
21 23
24#include "iomap.h"
22#include "clock.h" 25#include "clock.h"
23#include "clock2xxx.h" 26#include "clock2xxx.h"
24#include "opp2xxx.h" 27#include "opp2xxx.h"
diff --git a/arch/arm/mach-omap2/clock2430.c b/arch/arm/mach-omap2/clock2430.c
index d87bc9cb2a3..dfda9a3f2cb 100644
--- a/arch/arm/mach-omap2/clock2430.c
+++ b/arch/arm/mach-omap2/clock2430.c
@@ -21,8 +21,10 @@
21#include <linux/clk.h> 21#include <linux/clk.h>
22#include <linux/io.h> 22#include <linux/io.h>
23 23
24#include <plat/hardware.h>
24#include <plat/clock.h> 25#include <plat/clock.h>
25 26
27#include "iomap.h"
26#include "clock.h" 28#include "clock.h"
27#include "clock2xxx.h" 29#include "clock2xxx.h"
28#include "cm2xxx_3xxx.h" 30#include "cm2xxx_3xxx.h"
diff --git a/arch/arm/mach-omap2/clock2430_data.c b/arch/arm/mach-omap2/clock2430_data.c
index 0cc12879e7b..3b4d09a5039 100644
--- a/arch/arm/mach-omap2/clock2430_data.c
+++ b/arch/arm/mach-omap2/clock2430_data.c
@@ -17,8 +17,10 @@
17#include <linux/clk.h> 17#include <linux/clk.h>
18#include <linux/list.h> 18#include <linux/list.h>
19 19
20#include <plat/hardware.h>
20#include <plat/clkdev_omap.h> 21#include <plat/clkdev_omap.h>
21 22
23#include "iomap.h"
22#include "clock.h" 24#include "clock.h"
23#include "clock2xxx.h" 25#include "clock2xxx.h"
24#include "opp2xxx.h" 26#include "opp2xxx.h"
diff --git a/arch/arm/mach-omap2/clock2xxx.c b/arch/arm/mach-omap2/clock2xxx.c
index 80bb0f0e92e..12500097378 100644
--- a/arch/arm/mach-omap2/clock2xxx.c
+++ b/arch/arm/mach-omap2/clock2xxx.c
@@ -22,6 +22,7 @@
22#include <linux/clk.h> 22#include <linux/clk.h>
23#include <linux/io.h> 23#include <linux/io.h>
24 24
25#include <plat/cpu.h>
25#include <plat/clock.h> 26#include <plat/clock.h>
26 27
27#include "clock.h" 28#include "clock.h"
diff --git a/arch/arm/mach-omap2/clock3xxx.c b/arch/arm/mach-omap2/clock3xxx.c
index 952c3e01c9e..794d82702c8 100644
--- a/arch/arm/mach-omap2/clock3xxx.c
+++ b/arch/arm/mach-omap2/clock3xxx.c
@@ -21,6 +21,7 @@
21#include <linux/clk.h> 21#include <linux/clk.h>
22#include <linux/io.h> 22#include <linux/io.h>
23 23
24#include <plat/hardware.h>
24#include <plat/clock.h> 25#include <plat/clock.h>
25 26
26#include "clock.h" 27#include "clock.h"
diff --git a/arch/arm/mach-omap2/clock3xxx_data.c b/arch/arm/mach-omap2/clock3xxx_data.c
index d75e5f6b8a0..981b9f9111a 100644
--- a/arch/arm/mach-omap2/clock3xxx_data.c
+++ b/arch/arm/mach-omap2/clock3xxx_data.c
@@ -20,14 +20,15 @@
20#include <linux/clk.h> 20#include <linux/clk.h>
21#include <linux/list.h> 21#include <linux/list.h>
22 22
23#include <plat/hardware.h>
23#include <plat/clkdev_omap.h> 24#include <plat/clkdev_omap.h>
24 25
26#include "iomap.h"
25#include "clock.h" 27#include "clock.h"
26#include "clock3xxx.h" 28#include "clock3xxx.h"
27#include "clock34xx.h" 29#include "clock34xx.h"
28#include "clock36xx.h" 30#include "clock36xx.h"
29#include "clock3517.h" 31#include "clock3517.h"
30
31#include "cm2xxx_3xxx.h" 32#include "cm2xxx_3xxx.h"
32#include "cm-regbits-34xx.h" 33#include "cm-regbits-34xx.h"
33#include "prm2xxx_3xxx.h" 34#include "prm2xxx_3xxx.h"
diff --git a/arch/arm/mach-omap2/clock44xx_data.c b/arch/arm/mach-omap2/clock44xx_data.c
index 08e86d793a1..79b98f22f20 100644
--- a/arch/arm/mach-omap2/clock44xx_data.c
+++ b/arch/arm/mach-omap2/clock44xx_data.c
@@ -26,8 +26,11 @@
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/list.h> 27#include <linux/list.h>
28#include <linux/clk.h> 28#include <linux/clk.h>
29
30#include <plat/hardware.h>
29#include <plat/clkdev_omap.h> 31#include <plat/clkdev_omap.h>
30 32
33#include "iomap.h"
31#include "clock.h" 34#include "clock.h"
32#include "clock44xx.h" 35#include "clock44xx.h"
33#include "cm1_44xx.h" 36#include "cm1_44xx.h"
diff --git a/arch/arm/mach-omap2/cm2xxx_3xxx.c b/arch/arm/mach-omap2/cm2xxx_3xxx.c
index 04d39cdd211..389f9f8b570 100644
--- a/arch/arm/mach-omap2/cm2xxx_3xxx.c
+++ b/arch/arm/mach-omap2/cm2xxx_3xxx.c
@@ -18,8 +18,10 @@
18#include <linux/err.h> 18#include <linux/err.h>
19#include <linux/io.h> 19#include <linux/io.h>
20 20
21#include "common.h" 21#include <plat/hardware.h>
22 22
23#include "iomap.h"
24#include "common.h"
23#include "cm.h" 25#include "cm.h"
24#include "cm2xxx_3xxx.h" 26#include "cm2xxx_3xxx.h"
25#include "cm-regbits-24xx.h" 27#include "cm-regbits-24xx.h"
diff --git a/arch/arm/mach-omap2/cm44xx.c b/arch/arm/mach-omap2/cm44xx.c
index 6a836303252..535d66e2822 100644
--- a/arch/arm/mach-omap2/cm44xx.c
+++ b/arch/arm/mach-omap2/cm44xx.c
@@ -18,8 +18,8 @@
18#include <linux/err.h> 18#include <linux/err.h>
19#include <linux/io.h> 19#include <linux/io.h>
20 20
21#include "iomap.h"
21#include "common.h" 22#include "common.h"
22
23#include "cm.h" 23#include "cm.h"
24#include "cm1_44xx.h" 24#include "cm1_44xx.h"
25#include "cm2_44xx.h" 25#include "cm2_44xx.h"
diff --git a/arch/arm/mach-omap2/cminst44xx.c b/arch/arm/mach-omap2/cminst44xx.c
index 6204deaf85b..bd8810c3753 100644
--- a/arch/arm/mach-omap2/cminst44xx.c
+++ b/arch/arm/mach-omap2/cminst44xx.c
@@ -20,8 +20,8 @@
20#include <linux/err.h> 20#include <linux/err.h>
21#include <linux/io.h> 21#include <linux/io.h>
22 22
23#include "iomap.h"
23#include "common.h" 24#include "common.h"
24
25#include "cm.h" 25#include "cm.h"
26#include "cm1_44xx.h" 26#include "cm1_44xx.h"
27#include "cm2_44xx.h" 27#include "cm2_44xx.h"
diff --git a/arch/arm/mach-omap2/common-board-devices.c b/arch/arm/mach-omap2/common-board-devices.c
index bcb0c581716..9498b0f5fbd 100644
--- a/arch/arm/mach-omap2/common-board-devices.c
+++ b/arch/arm/mach-omap2/common-board-devices.c
@@ -33,7 +33,6 @@
33 defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE) 33 defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
34static struct omap2_mcspi_device_config ads7846_mcspi_config = { 34static struct omap2_mcspi_device_config ads7846_mcspi_config = {
35 .turbo_mode = 0, 35 .turbo_mode = 0,
36 .single_channel = 1, /* 0: slave, 1: master */
37}; 36};
38 37
39static struct ads7846_platform_data ads7846_config = { 38static struct ads7846_platform_data ads7846_config = {
@@ -76,13 +75,15 @@ void __init omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,
76 gpio_set_debounce(gpio_pendown, gpio_debounce); 75 gpio_set_debounce(gpio_pendown, gpio_debounce);
77 } 76 }
78 77
79 ads7846_config.gpio_pendown = gpio_pendown;
80
81 spi_bi->bus_num = bus_num; 78 spi_bi->bus_num = bus_num;
82 spi_bi->irq = OMAP_GPIO_IRQ(gpio_pendown); 79 spi_bi->irq = OMAP_GPIO_IRQ(gpio_pendown);
83 80
84 if (board_pdata) 81 if (board_pdata) {
82 board_pdata->gpio_pendown = gpio_pendown;
85 spi_bi->platform_data = board_pdata; 83 spi_bi->platform_data = board_pdata;
84 } else {
85 ads7846_config.gpio_pendown = gpio_pendown;
86 }
86 87
87 spi_register_board_info(&ads7846_spi_board_info, 1); 88 spi_register_board_info(&ads7846_spi_board_info, 1);
88} 89}
diff --git a/arch/arm/mach-omap2/common.c b/arch/arm/mach-omap2/common.c
index aaf421178c9..1549c11000d 100644
--- a/arch/arm/mach-omap2/common.c
+++ b/arch/arm/mach-omap2/common.c
@@ -17,12 +17,13 @@
17#include <linux/clk.h> 17#include <linux/clk.h>
18#include <linux/io.h> 18#include <linux/io.h>
19 19
20#include "common.h" 20#include <plat/hardware.h>
21#include <plat/board.h> 21#include <plat/board.h>
22#include <plat/mux.h> 22#include <plat/mux.h>
23
24#include <plat/clock.h> 23#include <plat/clock.h>
25 24
25#include "iomap.h"
26#include "common.h"
26#include "sdrc.h" 27#include "sdrc.h"
27#include "control.h" 28#include "control.h"
28 29
diff --git a/arch/arm/mach-omap2/common.h b/arch/arm/mach-omap2/common.h
index 7e9338e8d68..57da7f406e2 100644
--- a/arch/arm/mach-omap2/common.h
+++ b/arch/arm/mach-omap2/common.h
@@ -134,6 +134,8 @@ void omap4_map_io(void);
134void ti81xx_map_io(void); 134void ti81xx_map_io(void);
135void omap_barriers_init(void); 135void omap_barriers_init(void);
136 136
137extern void __init omap_init_consistent_dma_size(void);
138
137/** 139/**
138 * omap_test_timeout - busy-loop, testing a condition 140 * omap_test_timeout - busy-loop, testing a condition
139 * @cond: condition to test until it evaluates to true 141 * @cond: condition to test until it evaluates to true
@@ -175,6 +177,18 @@ void omap3_intc_handle_irq(struct pt_regs *regs);
175extern void __iomem *omap4_get_l2cache_base(void); 177extern void __iomem *omap4_get_l2cache_base(void);
176#endif 178#endif
177 179
180struct device_node;
181#ifdef CONFIG_OF
182int __init omap_intc_of_init(struct device_node *node,
183 struct device_node *parent);
184#else
185int __init omap_intc_of_init(struct device_node *node,
186 struct device_node *parent)
187{
188 return 0;
189}
190#endif
191
178#ifdef CONFIG_SMP 192#ifdef CONFIG_SMP
179extern void __iomem *omap4_get_scu_base(void); 193extern void __iomem *omap4_get_scu_base(void);
180#else 194#else
@@ -236,5 +250,10 @@ static inline u32 omap4_mpuss_read_prev_context_state(void)
236 return 0; 250 return 0;
237} 251}
238#endif 252#endif
253
254struct omap_sdrc_params;
255extern void omap_sdrc_init(struct omap_sdrc_params *sdrc_cs0,
256 struct omap_sdrc_params *sdrc_cs1);
257
239#endif /* __ASSEMBLER__ */ 258#endif /* __ASSEMBLER__ */
240#endif /* __ARCH_ARM_MACH_OMAP2PLUS_COMMON_H */ 259#endif /* __ARCH_ARM_MACH_OMAP2PLUS_COMMON_H */
diff --git a/arch/arm/mach-omap2/control.c b/arch/arm/mach-omap2/control.c
index 114c037e433..08e674bb041 100644
--- a/arch/arm/mach-omap2/control.c
+++ b/arch/arm/mach-omap2/control.c
@@ -15,9 +15,11 @@
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/io.h> 16#include <linux/io.h>
17 17
18#include "common.h" 18#include <plat/hardware.h>
19#include <plat/sdrc.h> 19#include <plat/sdrc.h>
20 20
21#include "iomap.h"
22#include "common.h"
21#include "cm-regbits-34xx.h" 23#include "cm-regbits-34xx.h"
22#include "prm-regbits-34xx.h" 24#include "prm-regbits-34xx.h"
23#include "prm2xxx_3xxx.h" 25#include "prm2xxx_3xxx.h"
diff --git a/arch/arm/mach-omap2/control.h b/arch/arm/mach-omap2/control.h
index 0ba68d3764b..a406fd045ce 100644
--- a/arch/arm/mach-omap2/control.h
+++ b/arch/arm/mach-omap2/control.h
@@ -16,7 +16,6 @@
16#ifndef __ARCH_ARM_MACH_OMAP2_CONTROL_H 16#ifndef __ARCH_ARM_MACH_OMAP2_CONTROL_H
17#define __ARCH_ARM_MACH_OMAP2_CONTROL_H 17#define __ARCH_ARM_MACH_OMAP2_CONTROL_H
18 18
19#include <mach/io.h>
20#include <mach/ctrl_module_core_44xx.h> 19#include <mach/ctrl_module_core_44xx.h>
21#include <mach/ctrl_module_wkup_44xx.h> 20#include <mach/ctrl_module_wkup_44xx.h>
22#include <mach/ctrl_module_pad_core_44xx.h> 21#include <mach/ctrl_module_pad_core_44xx.h>
@@ -339,6 +338,11 @@
339#define AM35XX_VPFE_PCLK_SW_RST BIT(4) 338#define AM35XX_VPFE_PCLK_SW_RST BIT(4)
340 339
341/* 340/*
341 * CONTROL AM33XX STATUS register
342 */
343#define AM33XX_CONTROL_STATUS 0x040
344
345/*
342 * CONTROL OMAP STATUS register to identify OMAP3 features 346 * CONTROL OMAP STATUS register to identify OMAP3 features
343 */ 347 */
344#define OMAP3_CONTROL_OMAP_STATUS 0x044c 348#define OMAP3_CONTROL_OMAP_STATUS 0x044c
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index f713818be06..e4336035c0e 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -25,7 +25,7 @@
25#include <asm/mach/map.h> 25#include <asm/mach/map.h>
26#include <asm/pmu.h> 26#include <asm/pmu.h>
27 27
28#include <plat/tc.h> 28#include "iomap.h"
29#include <plat/board.h> 29#include <plat/board.h>
30#include <plat/mmc.h> 30#include <plat/mmc.h>
31#include <plat/dma.h> 31#include <plat/dma.h>
@@ -276,7 +276,7 @@ int __init omap4_keyboard_init(struct omap4_keypad_platform_data
276} 276}
277 277
278#if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE) 278#if defined(CONFIG_OMAP_MBOX_FWK) || defined(CONFIG_OMAP_MBOX_FWK_MODULE)
279static inline void omap_init_mbox(void) 279static inline void __init omap_init_mbox(void)
280{ 280{
281 struct omap_hwmod *oh; 281 struct omap_hwmod *oh;
282 struct platform_device *pdev; 282 struct platform_device *pdev;
@@ -316,7 +316,7 @@ static inline void omap_init_audio(void) {}
316#if defined(CONFIG_SND_OMAP_SOC_MCPDM) || \ 316#if defined(CONFIG_SND_OMAP_SOC_MCPDM) || \
317 defined(CONFIG_SND_OMAP_SOC_MCPDM_MODULE) 317 defined(CONFIG_SND_OMAP_SOC_MCPDM_MODULE)
318 318
319static void omap_init_mcpdm(void) 319static void __init omap_init_mcpdm(void)
320{ 320{
321 struct omap_hwmod *oh; 321 struct omap_hwmod *oh;
322 struct platform_device *pdev; 322 struct platform_device *pdev;
@@ -337,7 +337,7 @@ static inline void omap_init_mcpdm(void) {}
337#if defined(CONFIG_SND_OMAP_SOC_DMIC) || \ 337#if defined(CONFIG_SND_OMAP_SOC_DMIC) || \
338 defined(CONFIG_SND_OMAP_SOC_DMIC_MODULE) 338 defined(CONFIG_SND_OMAP_SOC_DMIC_MODULE)
339 339
340static void omap_init_dmic(void) 340static void __init omap_init_dmic(void)
341{ 341{
342 struct omap_hwmod *oh; 342 struct omap_hwmod *oh;
343 struct platform_device *pdev; 343 struct platform_device *pdev;
@@ -359,7 +359,7 @@ static inline void omap_init_dmic(void) {}
359 359
360#include <plat/mcspi.h> 360#include <plat/mcspi.h>
361 361
362static int omap_mcspi_init(struct omap_hwmod *oh, void *unused) 362static int __init omap_mcspi_init(struct omap_hwmod *oh, void *unused)
363{ 363{
364 struct platform_device *pdev; 364 struct platform_device *pdev;
365 char *name = "omap2_mcspi"; 365 char *name = "omap2_mcspi";
@@ -633,9 +633,7 @@ void __init omap242x_init_mmc(struct omap_mmc_platform_data **mmc_data)
633/*-------------------------------------------------------------------------*/ 633/*-------------------------------------------------------------------------*/
634 634
635#if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE) 635#if defined(CONFIG_HDQ_MASTER_OMAP) || defined(CONFIG_HDQ_MASTER_OMAP_MODULE)
636#if defined(CONFIG_SOC_OMAP2430) || defined(CONFIG_SOC_OMAP3430)
637#define OMAP_HDQ_BASE 0x480B2000 636#define OMAP_HDQ_BASE 0x480B2000
638#endif
639static struct resource omap_hdq_resources[] = { 637static struct resource omap_hdq_resources[] = {
640 { 638 {
641 .start = OMAP_HDQ_BASE, 639 .start = OMAP_HDQ_BASE,
@@ -658,7 +656,10 @@ static struct platform_device omap_hdq_dev = {
658}; 656};
659static inline void omap_hdq_init(void) 657static inline void omap_hdq_init(void)
660{ 658{
661 (void) platform_device_register(&omap_hdq_dev); 659 if (cpu_is_omap2420())
660 return;
661
662 platform_device_register(&omap_hdq_dev);
662} 663}
663#else 664#else
664static inline void omap_hdq_init(void) {} 665static inline void omap_hdq_init(void) {}
diff --git a/arch/arm/mach-omap2/display.c b/arch/arm/mach-omap2/display.c
index 3677b1f58b8..9706c648bc1 100644
--- a/arch/arm/mach-omap2/display.c
+++ b/arch/arm/mach-omap2/display.c
@@ -30,6 +30,7 @@
30#include <plat/omap-pm.h> 30#include <plat/omap-pm.h>
31#include "common.h" 31#include "common.h"
32 32
33#include "iomap.h"
33#include "mux.h" 34#include "mux.h"
34#include "control.h" 35#include "control.h"
35#include "display.h" 36#include "display.h"
@@ -124,7 +125,7 @@ static void omap4_hdmi_mux_pads(enum omap_hdmi_flags flags)
124 } 125 }
125} 126}
126 127
127static int omap4_dsi_mux_pads(int dsi_id, unsigned lanes) 128static int __init omap4_dsi_mux_pads(int dsi_id, unsigned lanes)
128{ 129{
129 u32 enable_mask, enable_shift; 130 u32 enable_mask, enable_shift;
130 u32 pipd_mask, pipd_shift; 131 u32 pipd_mask, pipd_shift;
@@ -157,7 +158,7 @@ static int omap4_dsi_mux_pads(int dsi_id, unsigned lanes)
157 return 0; 158 return 0;
158} 159}
159 160
160int omap_hdmi_init(enum omap_hdmi_flags flags) 161int __init omap_hdmi_init(enum omap_hdmi_flags flags)
161{ 162{
162 if (cpu_is_omap44xx()) 163 if (cpu_is_omap44xx())
163 omap4_hdmi_mux_pads(flags); 164 omap4_hdmi_mux_pads(flags);
@@ -165,7 +166,7 @@ int omap_hdmi_init(enum omap_hdmi_flags flags)
165 return 0; 166 return 0;
166} 167}
167 168
168static int omap_dsi_enable_pads(int dsi_id, unsigned lane_mask) 169static int __init omap_dsi_enable_pads(int dsi_id, unsigned lane_mask)
169{ 170{
170 if (cpu_is_omap44xx()) 171 if (cpu_is_omap44xx())
171 return omap4_dsi_mux_pads(dsi_id, lane_mask); 172 return omap4_dsi_mux_pads(dsi_id, lane_mask);
@@ -173,7 +174,7 @@ static int omap_dsi_enable_pads(int dsi_id, unsigned lane_mask)
173 return 0; 174 return 0;
174} 175}
175 176
176static void omap_dsi_disable_pads(int dsi_id, unsigned lane_mask) 177static void __init omap_dsi_disable_pads(int dsi_id, unsigned lane_mask)
177{ 178{
178 if (cpu_is_omap44xx()) 179 if (cpu_is_omap44xx())
179 omap4_dsi_mux_pads(dsi_id, 0); 180 omap4_dsi_mux_pads(dsi_id, 0);
diff --git a/arch/arm/mach-omap2/dma.c b/arch/arm/mach-omap2/dma.c
index a59a45a0096..b19d8496c16 100644
--- a/arch/arm/mach-omap2/dma.c
+++ b/arch/arm/mach-omap2/dma.c
@@ -227,7 +227,7 @@ static int __init omap2_system_dma_init_dev(struct omap_hwmod *oh, void *unused)
227 227
228 dma_stride = OMAP2_DMA_STRIDE; 228 dma_stride = OMAP2_DMA_STRIDE;
229 dma_common_ch_start = CSDP; 229 dma_common_ch_start = CSDP;
230 if (cpu_is_omap3630() || cpu_is_omap4430()) 230 if (cpu_is_omap3630() || cpu_is_omap44xx())
231 dma_common_ch_end = CCDN; 231 dma_common_ch_end = CCDN;
232 else 232 else
233 dma_common_ch_end = CCFN; 233 dma_common_ch_end = CCFN;
diff --git a/arch/arm/mach-omap2/emu.c b/arch/arm/mach-omap2/emu.c
index 9c442e290cc..e28e761b7ab 100644
--- a/arch/arm/mach-omap2/emu.c
+++ b/arch/arm/mach-omap2/emu.c
@@ -21,6 +21,10 @@
21#include <linux/clk.h> 21#include <linux/clk.h>
22#include <linux/err.h> 22#include <linux/err.h>
23 23
24#include <mach/hardware.h>
25
26#include "iomap.h"
27
24MODULE_LICENSE("GPL"); 28MODULE_LICENSE("GPL");
25MODULE_AUTHOR("Alexander Shishkin"); 29MODULE_AUTHOR("Alexander Shishkin");
26 30
@@ -30,29 +34,8 @@ MODULE_AUTHOR("Alexander Shishkin");
30#define ETB_BASE (L4_EMU_34XX_PHYS + 0x1b000) 34#define ETB_BASE (L4_EMU_34XX_PHYS + 0x1b000)
31#define DAPCTL (L4_EMU_34XX_PHYS + 0x1d000) 35#define DAPCTL (L4_EMU_34XX_PHYS + 0x1d000)
32 36
33static struct amba_device omap3_etb_device = { 37static AMBA_APB_DEVICE(omap3_etb, "etb", 0x000bb907, ETB_BASE, { }, NULL);
34 .dev = { 38static AMBA_APB_DEVICE(omap3_etm, "etm", 0x102bb921, ETM_BASE, { }, NULL);
35 .init_name = "etb",
36 },
37 .res = {
38 .start = ETB_BASE,
39 .end = ETB_BASE + SZ_4K - 1,
40 .flags = IORESOURCE_MEM,
41 },
42 .periphid = 0x000bb907,
43};
44
45static struct amba_device omap3_etm_device = {
46 .dev = {
47 .init_name = "etm",
48 },
49 .res = {
50 .start = ETM_BASE,
51 .end = ETM_BASE + SZ_4K - 1,
52 .flags = IORESOURCE_MEM,
53 },
54 .periphid = 0x102bb921,
55};
56 39
57static int __init emu_init(void) 40static int __init emu_init(void)
58{ 41{
@@ -66,4 +49,3 @@ static int __init emu_init(void)
66} 49}
67 50
68subsys_initcall(emu_init); 51subsys_initcall(emu_init);
69
diff --git a/arch/arm/mach-omap2/gpio.c b/arch/arm/mach-omap2/gpio.c
index 8cbfbc2918c..2f994e5194e 100644
--- a/arch/arm/mach-omap2/gpio.c
+++ b/arch/arm/mach-omap2/gpio.c
@@ -23,14 +23,18 @@
23 23
24#include <plat/omap_hwmod.h> 24#include <plat/omap_hwmod.h>
25#include <plat/omap_device.h> 25#include <plat/omap_device.h>
26#include <plat/omap-pm.h>
26 27
27static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused) 28#include "powerdomain.h"
29
30static int __init omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
28{ 31{
29 struct platform_device *pdev; 32 struct platform_device *pdev;
30 struct omap_gpio_platform_data *pdata; 33 struct omap_gpio_platform_data *pdata;
31 struct omap_gpio_dev_attr *dev_attr; 34 struct omap_gpio_dev_attr *dev_attr;
32 char *name = "omap_gpio"; 35 char *name = "omap_gpio";
33 int id; 36 int id;
37 struct powerdomain *pwrdm;
34 38
35 /* 39 /*
36 * extract the device id from name field available in the 40 * extract the device id from name field available in the
@@ -52,7 +56,7 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
52 pdata->bank_width = dev_attr->bank_width; 56 pdata->bank_width = dev_attr->bank_width;
53 pdata->dbck_flag = dev_attr->dbck_flag; 57 pdata->dbck_flag = dev_attr->dbck_flag;
54 pdata->virtual_irq_start = IH_GPIO_BASE + 32 * (id - 1); 58 pdata->virtual_irq_start = IH_GPIO_BASE + 32 * (id - 1);
55 59 pdata->get_context_loss_count = omap_pm_get_dev_context_loss_count;
56 pdata->regs = kzalloc(sizeof(struct omap_gpio_reg_offs), GFP_KERNEL); 60 pdata->regs = kzalloc(sizeof(struct omap_gpio_reg_offs), GFP_KERNEL);
57 if (!pdata) { 61 if (!pdata) {
58 pr_err("gpio%d: Memory allocation failed\n", id); 62 pr_err("gpio%d: Memory allocation failed\n", id);
@@ -61,8 +65,15 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
61 65
62 switch (oh->class->rev) { 66 switch (oh->class->rev) {
63 case 0: 67 case 0:
68 if (id == 1)
69 /* non-wakeup GPIO pins for OMAP2 Bank1 */
70 pdata->non_wakeup_gpios = 0xe203ffc0;
71 else if (id == 2)
72 /* non-wakeup GPIO pins for OMAP2 Bank2 */
73 pdata->non_wakeup_gpios = 0x08700040;
74 /* fall through */
75
64 case 1: 76 case 1:
65 pdata->bank_type = METHOD_GPIO_24XX;
66 pdata->regs->revision = OMAP24XX_GPIO_REVISION; 77 pdata->regs->revision = OMAP24XX_GPIO_REVISION;
67 pdata->regs->direction = OMAP24XX_GPIO_OE; 78 pdata->regs->direction = OMAP24XX_GPIO_OE;
68 pdata->regs->datain = OMAP24XX_GPIO_DATAIN; 79 pdata->regs->datain = OMAP24XX_GPIO_DATAIN;
@@ -72,13 +83,19 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
72 pdata->regs->irqstatus = OMAP24XX_GPIO_IRQSTATUS1; 83 pdata->regs->irqstatus = OMAP24XX_GPIO_IRQSTATUS1;
73 pdata->regs->irqstatus2 = OMAP24XX_GPIO_IRQSTATUS2; 84 pdata->regs->irqstatus2 = OMAP24XX_GPIO_IRQSTATUS2;
74 pdata->regs->irqenable = OMAP24XX_GPIO_IRQENABLE1; 85 pdata->regs->irqenable = OMAP24XX_GPIO_IRQENABLE1;
86 pdata->regs->irqenable2 = OMAP24XX_GPIO_IRQENABLE2;
75 pdata->regs->set_irqenable = OMAP24XX_GPIO_SETIRQENABLE1; 87 pdata->regs->set_irqenable = OMAP24XX_GPIO_SETIRQENABLE1;
76 pdata->regs->clr_irqenable = OMAP24XX_GPIO_CLEARIRQENABLE1; 88 pdata->regs->clr_irqenable = OMAP24XX_GPIO_CLEARIRQENABLE1;
77 pdata->regs->debounce = OMAP24XX_GPIO_DEBOUNCE_VAL; 89 pdata->regs->debounce = OMAP24XX_GPIO_DEBOUNCE_VAL;
78 pdata->regs->debounce_en = OMAP24XX_GPIO_DEBOUNCE_EN; 90 pdata->regs->debounce_en = OMAP24XX_GPIO_DEBOUNCE_EN;
91 pdata->regs->ctrl = OMAP24XX_GPIO_CTRL;
92 pdata->regs->wkup_en = OMAP24XX_GPIO_WAKE_EN;
93 pdata->regs->leveldetect0 = OMAP24XX_GPIO_LEVELDETECT0;
94 pdata->regs->leveldetect1 = OMAP24XX_GPIO_LEVELDETECT1;
95 pdata->regs->risingdetect = OMAP24XX_GPIO_RISINGDETECT;
96 pdata->regs->fallingdetect = OMAP24XX_GPIO_FALLINGDETECT;
79 break; 97 break;
80 case 2: 98 case 2:
81 pdata->bank_type = METHOD_GPIO_44XX;
82 pdata->regs->revision = OMAP4_GPIO_REVISION; 99 pdata->regs->revision = OMAP4_GPIO_REVISION;
83 pdata->regs->direction = OMAP4_GPIO_OE; 100 pdata->regs->direction = OMAP4_GPIO_OE;
84 pdata->regs->datain = OMAP4_GPIO_DATAIN; 101 pdata->regs->datain = OMAP4_GPIO_DATAIN;
@@ -88,10 +105,17 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
88 pdata->regs->irqstatus = OMAP4_GPIO_IRQSTATUS0; 105 pdata->regs->irqstatus = OMAP4_GPIO_IRQSTATUS0;
89 pdata->regs->irqstatus2 = OMAP4_GPIO_IRQSTATUS1; 106 pdata->regs->irqstatus2 = OMAP4_GPIO_IRQSTATUS1;
90 pdata->regs->irqenable = OMAP4_GPIO_IRQSTATUSSET0; 107 pdata->regs->irqenable = OMAP4_GPIO_IRQSTATUSSET0;
108 pdata->regs->irqenable2 = OMAP4_GPIO_IRQSTATUSSET1;
91 pdata->regs->set_irqenable = OMAP4_GPIO_IRQSTATUSSET0; 109 pdata->regs->set_irqenable = OMAP4_GPIO_IRQSTATUSSET0;
92 pdata->regs->clr_irqenable = OMAP4_GPIO_IRQSTATUSCLR0; 110 pdata->regs->clr_irqenable = OMAP4_GPIO_IRQSTATUSCLR0;
93 pdata->regs->debounce = OMAP4_GPIO_DEBOUNCINGTIME; 111 pdata->regs->debounce = OMAP4_GPIO_DEBOUNCINGTIME;
94 pdata->regs->debounce_en = OMAP4_GPIO_DEBOUNCENABLE; 112 pdata->regs->debounce_en = OMAP4_GPIO_DEBOUNCENABLE;
113 pdata->regs->ctrl = OMAP4_GPIO_CTRL;
114 pdata->regs->wkup_en = OMAP4_GPIO_IRQWAKEN0;
115 pdata->regs->leveldetect0 = OMAP4_GPIO_LEVELDETECT0;
116 pdata->regs->leveldetect1 = OMAP4_GPIO_LEVELDETECT1;
117 pdata->regs->risingdetect = OMAP4_GPIO_RISINGDETECT;
118 pdata->regs->fallingdetect = OMAP4_GPIO_FALLINGDETECT;
95 break; 119 break;
96 default: 120 default:
97 WARN(1, "Invalid gpio bank_type\n"); 121 WARN(1, "Invalid gpio bank_type\n");
@@ -99,6 +123,9 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
99 return -EINVAL; 123 return -EINVAL;
100 } 124 }
101 125
126 pwrdm = omap_hwmod_get_pwrdm(oh);
127 pdata->loses_context = pwrdm_can_ever_lose_context(pwrdm);
128
102 pdev = omap_device_build(name, id - 1, oh, pdata, 129 pdev = omap_device_build(name, id - 1, oh, pdata,
103 sizeof(*pdata), NULL, 0, false); 130 sizeof(*pdata), NULL, 0, false);
104 kfree(pdata); 131 kfree(pdata);
@@ -109,9 +136,6 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused)
109 return PTR_ERR(pdev); 136 return PTR_ERR(pdev);
110 } 137 }
111 138
112 omap_device_disable_idle_on_suspend(pdev);
113
114 gpio_bank_count++;
115 return 0; 139 return 0;
116} 140}
117 141
diff --git a/arch/arm/mach-omap2/gpmc-nand.c b/arch/arm/mach-omap2/gpmc-nand.c
index 8ad210bda9a..386dec8d235 100644
--- a/arch/arm/mach-omap2/gpmc-nand.c
+++ b/arch/arm/mach-omap2/gpmc-nand.c
@@ -16,6 +16,7 @@
16 16
17#include <asm/mach/flash.h> 17#include <asm/mach/flash.h>
18 18
19#include <plat/cpu.h>
19#include <plat/nand.h> 20#include <plat/nand.h>
20#include <plat/board.h> 21#include <plat/board.h>
21#include <plat/gpmc.h> 22#include <plat/gpmc.h>
diff --git a/arch/arm/mach-omap2/gpmc-onenand.c b/arch/arm/mach-omap2/gpmc-onenand.c
index 5cdce10d618..385b3e02c4a 100644
--- a/arch/arm/mach-omap2/gpmc-onenand.c
+++ b/arch/arm/mach-omap2/gpmc-onenand.c
@@ -18,6 +18,7 @@
18 18
19#include <asm/mach/flash.h> 19#include <asm/mach/flash.h>
20 20
21#include <plat/cpu.h>
21#include <plat/onenand.h> 22#include <plat/onenand.h>
22#include <plat/board.h> 23#include <plat/board.h>
23#include <plat/gpmc.h> 24#include <plat/gpmc.h>
diff --git a/arch/arm/mach-omap2/gpmc-smsc911x.c b/arch/arm/mach-omap2/gpmc-smsc911x.c
index bbb870c04a5..5e5880d6d09 100644
--- a/arch/arm/mach-omap2/gpmc-smsc911x.c
+++ b/arch/arm/mach-omap2/gpmc-smsc911x.c
@@ -101,10 +101,13 @@ void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data)
101 101
102 gpmc_cfg = board_data; 102 gpmc_cfg = board_data;
103 103
104 ret = platform_device_register(&gpmc_smsc911x_regulator); 104 if (!gpmc_cfg->id) {
105 if (ret < 0) { 105 ret = platform_device_register(&gpmc_smsc911x_regulator);
106 pr_err("Unable to register smsc911x regulators: %d\n", ret); 106 if (ret < 0) {
107 return; 107 pr_err("Unable to register smsc911x regulators: %d\n",
108 ret);
109 return;
110 }
108 } 111 }
109 112
110 if (gpmc_cs_request(gpmc_cfg->cs, SZ_16M, &cs_mem_base) < 0) { 113 if (gpmc_cs_request(gpmc_cfg->cs, SZ_16M, &cs_mem_base) < 0) {
diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index dfffbbf4c00..00d510858e2 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -888,6 +888,7 @@ int gpmc_enable_hwecc(int cs, int mode, int dev_width, int ecc_size)
888 gpmc_write_reg(GPMC_ECC_CONFIG, val); 888 gpmc_write_reg(GPMC_ECC_CONFIG, val);
889 return 0; 889 return 0;
890} 890}
891EXPORT_SYMBOL_GPL(gpmc_enable_hwecc);
891 892
892/** 893/**
893 * gpmc_calculate_ecc - generate non-inverted ecc bytes 894 * gpmc_calculate_ecc - generate non-inverted ecc bytes
@@ -918,3 +919,4 @@ int gpmc_calculate_ecc(int cs, const u_char *dat, u_char *ecc_code)
918 gpmc_ecc_used = -EINVAL; 919 gpmc_ecc_used = -EINVAL;
919 return 0; 920 return 0;
920} 921}
922EXPORT_SYMBOL_GPL(gpmc_calculate_ecc);
diff --git a/arch/arm/mach-omap2/hsmmc.c b/arch/arm/mach-omap2/hsmmc.c
index 19dd1657245..8121720e942 100644
--- a/arch/arm/mach-omap2/hsmmc.c
+++ b/arch/arm/mach-omap2/hsmmc.c
@@ -293,8 +293,8 @@ static inline void omap_hsmmc_mux(struct omap_mmc_platform_data *mmc_controller,
293 } 293 }
294} 294}
295 295
296static int omap_hsmmc_pdata_init(struct omap2_hsmmc_info *c, 296static int __init omap_hsmmc_pdata_init(struct omap2_hsmmc_info *c,
297 struct omap_mmc_platform_data *mmc) 297 struct omap_mmc_platform_data *mmc)
298{ 298{
299 char *hc_name; 299 char *hc_name;
300 300
@@ -429,66 +429,131 @@ static int omap_hsmmc_pdata_init(struct omap2_hsmmc_info *c,
429} 429}
430 430
431static int omap_hsmmc_done; 431static int omap_hsmmc_done;
432
433void omap_hsmmc_late_init(struct omap2_hsmmc_info *c)
434{
435 struct platform_device *pdev;
436 struct omap_mmc_platform_data *mmc_pdata;
437 int res;
438
439 if (omap_hsmmc_done != 1)
440 return;
441
442 omap_hsmmc_done++;
443
444 for (; c->mmc; c++) {
445 if (!c->deferred)
446 continue;
447
448 pdev = c->pdev;
449 if (!pdev)
450 continue;
451
452 mmc_pdata = pdev->dev.platform_data;
453 if (!mmc_pdata)
454 continue;
455
456 mmc_pdata->slots[0].switch_pin = c->gpio_cd;
457 mmc_pdata->slots[0].gpio_wp = c->gpio_wp;
458
459 res = omap_device_register(pdev);
460 if (res)
461 pr_err("Could not late init MMC %s\n",
462 c->name);
463 }
464}
465
432#define MAX_OMAP_MMC_HWMOD_NAME_LEN 16 466#define MAX_OMAP_MMC_HWMOD_NAME_LEN 16
433 467
434void omap_init_hsmmc(struct omap2_hsmmc_info *hsmmcinfo, int ctrl_nr) 468static void __init omap_hsmmc_init_one(struct omap2_hsmmc_info *hsmmcinfo,
469 int ctrl_nr)
435{ 470{
436 struct omap_hwmod *oh; 471 struct omap_hwmod *oh;
472 struct omap_hwmod *ohs[1];
473 struct omap_device *od;
437 struct platform_device *pdev; 474 struct platform_device *pdev;
438 char oh_name[MAX_OMAP_MMC_HWMOD_NAME_LEN]; 475 char oh_name[MAX_OMAP_MMC_HWMOD_NAME_LEN];
439 struct omap_mmc_platform_data *mmc_data; 476 struct omap_mmc_platform_data *mmc_data;
440 struct omap_mmc_dev_attr *mmc_dev_attr; 477 struct omap_mmc_dev_attr *mmc_dev_attr;
441 char *name; 478 char *name;
442 int l; 479 int res;
443 480
444 mmc_data = kzalloc(sizeof(struct omap_mmc_platform_data), GFP_KERNEL); 481 mmc_data = kzalloc(sizeof(struct omap_mmc_platform_data), GFP_KERNEL);
445 if (!mmc_data) { 482 if (!mmc_data) {
446 pr_err("Cannot allocate memory for mmc device!\n"); 483 pr_err("Cannot allocate memory for mmc device!\n");
447 goto done; 484 return;
448 } 485 }
449 486
450 if (omap_hsmmc_pdata_init(hsmmcinfo, mmc_data) < 0) { 487 res = omap_hsmmc_pdata_init(hsmmcinfo, mmc_data);
451 pr_err("%s fails!\n", __func__); 488 if (res < 0)
452 goto done; 489 goto free_mmc;
453 } 490
454 omap_hsmmc_mux(mmc_data, (ctrl_nr - 1)); 491 omap_hsmmc_mux(mmc_data, (ctrl_nr - 1));
455 492
456 name = "omap_hsmmc"; 493 name = "omap_hsmmc";
457 494 res = snprintf(oh_name, MAX_OMAP_MMC_HWMOD_NAME_LEN,
458 l = snprintf(oh_name, MAX_OMAP_MMC_HWMOD_NAME_LEN,
459 "mmc%d", ctrl_nr); 495 "mmc%d", ctrl_nr);
460 WARN(l >= MAX_OMAP_MMC_HWMOD_NAME_LEN, 496 WARN(res >= MAX_OMAP_MMC_HWMOD_NAME_LEN,
461 "String buffer overflow in MMC%d device setup\n", ctrl_nr); 497 "String buffer overflow in MMC%d device setup\n", ctrl_nr);
498
462 oh = omap_hwmod_lookup(oh_name); 499 oh = omap_hwmod_lookup(oh_name);
463 if (!oh) { 500 if (!oh) {
464 pr_err("Could not look up %s\n", oh_name); 501 pr_err("Could not look up %s\n", oh_name);
465 kfree(mmc_data->slots[0].name); 502 goto free_name;
466 goto done;
467 } 503 }
468 504 ohs[0] = oh;
469 if (oh->dev_attr != NULL) { 505 if (oh->dev_attr != NULL) {
470 mmc_dev_attr = oh->dev_attr; 506 mmc_dev_attr = oh->dev_attr;
471 mmc_data->controller_flags = mmc_dev_attr->flags; 507 mmc_data->controller_flags = mmc_dev_attr->flags;
472 } 508 }
473 509
474 pdev = omap_device_build(name, ctrl_nr - 1, oh, mmc_data, 510 pdev = platform_device_alloc(name, ctrl_nr - 1);
475 sizeof(struct omap_mmc_platform_data), NULL, 0, false); 511 if (!pdev) {
476 if (IS_ERR(pdev)) { 512 pr_err("Could not allocate pdev for %s\n", name);
477 WARN(1, "Can't build omap_device for %s:%s.\n", name, oh->name); 513 goto free_name;
478 kfree(mmc_data->slots[0].name);
479 goto done;
480 } 514 }
481 /* 515 dev_set_name(&pdev->dev, "%s.%d", pdev->name, pdev->id);
482 * return device handle to board setup code 516
483 * required to populate for regulator framework structure 517 od = omap_device_alloc(pdev, ohs, 1, NULL, 0);
484 */ 518 if (!od) {
485 hsmmcinfo->dev = &pdev->dev; 519 pr_err("Could not allocate od for %s\n", name);
520 goto put_pdev;
521 }
522
523 res = platform_device_add_data(pdev, mmc_data,
524 sizeof(struct omap_mmc_platform_data));
525 if (res) {
526 pr_err("Could not add pdata for %s\n", name);
527 goto put_pdev;
528 }
529
530 hsmmcinfo->pdev = pdev;
531
532 if (hsmmcinfo->deferred)
533 goto free_mmc;
534
535 res = omap_device_register(pdev);
536 if (res) {
537 pr_err("Could not register od for %s\n", name);
538 goto free_od;
539 }
540
541 goto free_mmc;
542
543free_od:
544 omap_device_delete(od);
545
546put_pdev:
547 platform_device_put(pdev);
548
549free_name:
550 kfree(mmc_data->slots[0].name);
486 551
487done: 552free_mmc:
488 kfree(mmc_data); 553 kfree(mmc_data);
489} 554}
490 555
491void omap2_hsmmc_init(struct omap2_hsmmc_info *controllers) 556void __init omap_hsmmc_init(struct omap2_hsmmc_info *controllers)
492{ 557{
493 u32 reg; 558 u32 reg;
494 559
@@ -521,7 +586,7 @@ void omap2_hsmmc_init(struct omap2_hsmmc_info *controllers)
521 } 586 }
522 587
523 for (; controllers->mmc; controllers++) 588 for (; controllers->mmc; controllers++)
524 omap_init_hsmmc(controllers, controllers->mmc); 589 omap_hsmmc_init_one(controllers, controllers->mmc);
525 590
526} 591}
527 592
diff --git a/arch/arm/mach-omap2/hsmmc.h b/arch/arm/mach-omap2/hsmmc.h
index c4409730c4b..07831cc3c17 100644
--- a/arch/arm/mach-omap2/hsmmc.h
+++ b/arch/arm/mach-omap2/hsmmc.h
@@ -21,10 +21,11 @@ struct omap2_hsmmc_info {
21 bool no_off; /* power_saving and power is not to go off */ 21 bool no_off; /* power_saving and power is not to go off */
22 bool no_off_init; /* no power off when not in MMC sleep state */ 22 bool no_off_init; /* no power off when not in MMC sleep state */
23 bool vcc_aux_disable_is_sleep; /* Regulator off remapped to sleep */ 23 bool vcc_aux_disable_is_sleep; /* Regulator off remapped to sleep */
24 bool deferred; /* mmc needs a deferred probe */
24 int gpio_cd; /* or -EINVAL */ 25 int gpio_cd; /* or -EINVAL */
25 int gpio_wp; /* or -EINVAL */ 26 int gpio_wp; /* or -EINVAL */
26 char *name; /* or NULL for default */ 27 char *name; /* or NULL for default */
27 struct device *dev; /* returned: pointer to mmc adapter */ 28 struct platform_device *pdev; /* mmc controller instance */
28 int ocr_mask; /* temporary HACK */ 29 int ocr_mask; /* temporary HACK */
29 /* Remux (pad configuration) when powering on/off */ 30 /* Remux (pad configuration) when powering on/off */
30 void (*remux)(struct device *dev, int slot, int power_on); 31 void (*remux)(struct device *dev, int slot, int power_on);
@@ -34,11 +35,16 @@ struct omap2_hsmmc_info {
34 35
35#if defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE) 36#if defined(CONFIG_MMC_OMAP_HS) || defined(CONFIG_MMC_OMAP_HS_MODULE)
36 37
37void omap2_hsmmc_init(struct omap2_hsmmc_info *); 38void omap_hsmmc_init(struct omap2_hsmmc_info *);
39void omap_hsmmc_late_init(struct omap2_hsmmc_info *);
38 40
39#else 41#else
40 42
41static inline void omap2_hsmmc_init(struct omap2_hsmmc_info *info) 43static inline void omap_hsmmc_init(struct omap2_hsmmc_info *info)
44{
45}
46
47static inline void omap_hsmmc_late_init(struct omap2_hsmmc_info *info)
42{ 48{
43} 49}
44 50
diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c
index 719ee423abe..0e79b7bc6aa 100644
--- a/arch/arm/mach-omap2/id.c
+++ b/arch/arm/mach-omap2/id.c
@@ -29,7 +29,7 @@
29#include "control.h" 29#include "control.h"
30 30
31static unsigned int omap_revision; 31static unsigned int omap_revision;
32 32static const char *cpu_rev;
33u32 omap_features; 33u32 omap_features;
34 34
35unsigned int omap_rev(void) 35unsigned int omap_rev(void)
@@ -44,6 +44,8 @@ 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()) {
48 val = omap_ctrl_readl(AM33XX_CONTROL_STATUS);
47 } else if (cpu_is_omap34xx()) { 49 } else if (cpu_is_omap34xx()) {
48 val = omap_ctrl_readl(OMAP343X_CONTROL_STATUS); 50 val = omap_ctrl_readl(OMAP343X_CONTROL_STATUS);
49 } else if (cpu_is_omap44xx()) { 51 } else if (cpu_is_omap44xx()) {
@@ -112,7 +114,7 @@ void omap_get_die_id(struct omap_die_id *odi)
112 odi->id_3 = read_tap_reg(OMAP_TAP_DIE_ID_3); 114 odi->id_3 = read_tap_reg(OMAP_TAP_DIE_ID_3);
113} 115}
114 116
115static void __init omap24xx_check_revision(void) 117void __init omap2xxx_check_revision(void)
116{ 118{
117 int i, j; 119 int i, j;
118 u32 idcode, prod_id; 120 u32 idcode, prod_id;
@@ -166,13 +168,63 @@ static void __init omap24xx_check_revision(void)
166 pr_info("\n"); 168 pr_info("\n");
167} 169}
168 170
171#define OMAP3_SHOW_FEATURE(feat) \
172 if (omap3_has_ ##feat()) \
173 printk(#feat" ");
174
175static void __init omap3_cpuinfo(void)
176{
177 const char *cpu_name;
178
179 /*
180 * OMAP3430 and OMAP3530 are assumed to be same.
181 *
182 * OMAP3525, OMAP3515 and OMAP3503 can be detected only based
183 * on available features. Upon detection, update the CPU id
184 * and CPU class bits.
185 */
186 if (cpu_is_omap3630()) {
187 cpu_name = "OMAP3630";
188 } else if (cpu_is_omap3517()) {
189 /* AM35xx devices */
190 cpu_name = (omap3_has_sgx()) ? "AM3517" : "AM3505";
191 } else if (cpu_is_ti816x()) {
192 cpu_name = "TI816X";
193 } else if (cpu_is_am335x()) {
194 cpu_name = "AM335X";
195 } else if (cpu_is_ti814x()) {
196 cpu_name = "TI814X";
197 } else if (omap3_has_iva() && omap3_has_sgx()) {
198 /* OMAP3430, OMAP3525, OMAP3515, OMAP3503 devices */
199 cpu_name = "OMAP3430/3530";
200 } else if (omap3_has_iva()) {
201 cpu_name = "OMAP3525";
202 } else if (omap3_has_sgx()) {
203 cpu_name = "OMAP3515";
204 } else {
205 cpu_name = "OMAP3503";
206 }
207
208 /* Print verbose information */
209 pr_info("%s ES%s (", cpu_name, cpu_rev);
210
211 OMAP3_SHOW_FEATURE(l2cache);
212 OMAP3_SHOW_FEATURE(iva);
213 OMAP3_SHOW_FEATURE(sgx);
214 OMAP3_SHOW_FEATURE(neon);
215 OMAP3_SHOW_FEATURE(isp);
216 OMAP3_SHOW_FEATURE(192mhz_clk);
217
218 printk(")\n");
219}
220
169#define OMAP3_CHECK_FEATURE(status,feat) \ 221#define OMAP3_CHECK_FEATURE(status,feat) \
170 if (((status & OMAP3_ ##feat## _MASK) \ 222 if (((status & OMAP3_ ##feat## _MASK) \
171 >> OMAP3_ ##feat## _SHIFT) != FEAT_ ##feat## _NONE) { \ 223 >> OMAP3_ ##feat## _SHIFT) != FEAT_ ##feat## _NONE) { \
172 omap_features |= OMAP3_HAS_ ##feat; \ 224 omap_features |= OMAP3_HAS_ ##feat; \
173 } 225 }
174 226
175static void __init omap3_check_features(void) 227void __init omap3xxx_check_features(void)
176{ 228{
177 u32 status; 229 u32 status;
178 230
@@ -199,9 +251,11 @@ static void __init omap3_check_features(void)
199 * TODO: Get additional info (where applicable) 251 * TODO: Get additional info (where applicable)
200 * e.g. Size of L2 cache. 252 * e.g. Size of L2 cache.
201 */ 253 */
254
255 omap3_cpuinfo();
202} 256}
203 257
204static void __init omap4_check_features(void) 258void __init omap4xxx_check_features(void)
205{ 259{
206 u32 si_type; 260 u32 si_type;
207 261
@@ -226,12 +280,13 @@ static void __init omap4_check_features(void)
226 } 280 }
227} 281}
228 282
229static void __init ti81xx_check_features(void) 283void __init ti81xx_check_features(void)
230{ 284{
231 omap_features = OMAP3_HAS_NEON; 285 omap_features = OMAP3_HAS_NEON;
286 omap3_cpuinfo();
232} 287}
233 288
234static void __init omap3_check_revision(const char **cpu_rev) 289void __init omap3xxx_check_revision(void)
235{ 290{
236 u32 cpuid, idcode; 291 u32 cpuid, idcode;
237 u16 hawkeye; 292 u16 hawkeye;
@@ -245,7 +300,7 @@ static void __init omap3_check_revision(const char **cpu_rev)
245 cpuid = read_cpuid(CPUID_ID); 300 cpuid = read_cpuid(CPUID_ID);
246 if ((((cpuid >> 4) & 0xfff) == 0xc08) && ((cpuid & 0xf) == 0x0)) { 301 if ((((cpuid >> 4) & 0xfff) == 0xc08) && ((cpuid & 0xf) == 0x0)) {
247 omap_revision = OMAP3430_REV_ES1_0; 302 omap_revision = OMAP3430_REV_ES1_0;
248 *cpu_rev = "1.0"; 303 cpu_rev = "1.0";
249 return; 304 return;
250 } 305 }
251 306
@@ -266,26 +321,26 @@ static void __init omap3_check_revision(const char **cpu_rev)
266 case 0: /* Take care of early samples */ 321 case 0: /* Take care of early samples */
267 case 1: 322 case 1:
268 omap_revision = OMAP3430_REV_ES2_0; 323 omap_revision = OMAP3430_REV_ES2_0;
269 *cpu_rev = "2.0"; 324 cpu_rev = "2.0";
270 break; 325 break;
271 case 2: 326 case 2:
272 omap_revision = OMAP3430_REV_ES2_1; 327 omap_revision = OMAP3430_REV_ES2_1;
273 *cpu_rev = "2.1"; 328 cpu_rev = "2.1";
274 break; 329 break;
275 case 3: 330 case 3:
276 omap_revision = OMAP3430_REV_ES3_0; 331 omap_revision = OMAP3430_REV_ES3_0;
277 *cpu_rev = "3.0"; 332 cpu_rev = "3.0";
278 break; 333 break;
279 case 4: 334 case 4:
280 omap_revision = OMAP3430_REV_ES3_1; 335 omap_revision = OMAP3430_REV_ES3_1;
281 *cpu_rev = "3.1"; 336 cpu_rev = "3.1";
282 break; 337 break;
283 case 7: 338 case 7:
284 /* FALLTHROUGH */ 339 /* FALLTHROUGH */
285 default: 340 default:
286 /* Use the latest known revision as default */ 341 /* Use the latest known revision as default */
287 omap_revision = OMAP3430_REV_ES3_1_2; 342 omap_revision = OMAP3430_REV_ES3_1_2;
288 *cpu_rev = "3.1.2"; 343 cpu_rev = "3.1.2";
289 } 344 }
290 break; 345 break;
291 case 0xb868: 346 case 0xb868:
@@ -298,13 +353,13 @@ static void __init omap3_check_revision(const char **cpu_rev)
298 switch (rev) { 353 switch (rev) {
299 case 0: 354 case 0:
300 omap_revision = OMAP3517_REV_ES1_0; 355 omap_revision = OMAP3517_REV_ES1_0;
301 *cpu_rev = "1.0"; 356 cpu_rev = "1.0";
302 break; 357 break;
303 case 1: 358 case 1:
304 /* FALLTHROUGH */ 359 /* FALLTHROUGH */
305 default: 360 default:
306 omap_revision = OMAP3517_REV_ES1_1; 361 omap_revision = OMAP3517_REV_ES1_1;
307 *cpu_rev = "1.1"; 362 cpu_rev = "1.1";
308 } 363 }
309 break; 364 break;
310 case 0xb891: 365 case 0xb891:
@@ -313,36 +368,36 @@ static void __init omap3_check_revision(const char **cpu_rev)
313 switch(rev) { 368 switch(rev) {
314 case 0: /* Take care of early samples */ 369 case 0: /* Take care of early samples */
315 omap_revision = OMAP3630_REV_ES1_0; 370 omap_revision = OMAP3630_REV_ES1_0;
316 *cpu_rev = "1.0"; 371 cpu_rev = "1.0";
317 break; 372 break;
318 case 1: 373 case 1:
319 omap_revision = OMAP3630_REV_ES1_1; 374 omap_revision = OMAP3630_REV_ES1_1;
320 *cpu_rev = "1.1"; 375 cpu_rev = "1.1";
321 break; 376 break;
322 case 2: 377 case 2:
323 /* FALLTHROUGH */ 378 /* FALLTHROUGH */
324 default: 379 default:
325 omap_revision = OMAP3630_REV_ES1_2; 380 omap_revision = OMAP3630_REV_ES1_2;
326 *cpu_rev = "1.2"; 381 cpu_rev = "1.2";
327 } 382 }
328 break; 383 break;
329 case 0xb81e: 384 case 0xb81e:
330 switch (rev) { 385 switch (rev) {
331 case 0: 386 case 0:
332 omap_revision = TI8168_REV_ES1_0; 387 omap_revision = TI8168_REV_ES1_0;
333 *cpu_rev = "1.0"; 388 cpu_rev = "1.0";
334 break; 389 break;
335 case 1: 390 case 1:
336 /* FALLTHROUGH */ 391 /* FALLTHROUGH */
337 default: 392 default:
338 omap_revision = TI8168_REV_ES1_1; 393 omap_revision = TI8168_REV_ES1_1;
339 *cpu_rev = "1.1"; 394 cpu_rev = "1.1";
340 break; 395 break;
341 } 396 }
342 break; 397 break;
343 case 0xb944: 398 case 0xb944:
344 omap_revision = AM335X_REV_ES1_0; 399 omap_revision = AM335X_REV_ES1_0;
345 *cpu_rev = "1.0"; 400 cpu_rev = "1.0";
346 break; 401 break;
347 case 0xb8f2: 402 case 0xb8f2:
348 switch (rev) { 403 switch (rev) {
@@ -350,29 +405,29 @@ static void __init omap3_check_revision(const char **cpu_rev)
350 /* FALLTHROUGH */ 405 /* FALLTHROUGH */
351 case 1: 406 case 1:
352 omap_revision = TI8148_REV_ES1_0; 407 omap_revision = TI8148_REV_ES1_0;
353 *cpu_rev = "1.0"; 408 cpu_rev = "1.0";
354 break; 409 break;
355 case 2: 410 case 2:
356 omap_revision = TI8148_REV_ES2_0; 411 omap_revision = TI8148_REV_ES2_0;
357 *cpu_rev = "2.0"; 412 cpu_rev = "2.0";
358 break; 413 break;
359 case 3: 414 case 3:
360 /* FALLTHROUGH */ 415 /* FALLTHROUGH */
361 default: 416 default:
362 omap_revision = TI8148_REV_ES2_1; 417 omap_revision = TI8148_REV_ES2_1;
363 *cpu_rev = "2.1"; 418 cpu_rev = "2.1";
364 break; 419 break;
365 } 420 }
366 break; 421 break;
367 default: 422 default:
368 /* Unknown default to latest silicon rev as default */ 423 /* Unknown default to latest silicon rev as default */
369 omap_revision = OMAP3630_REV_ES1_2; 424 omap_revision = OMAP3630_REV_ES1_2;
370 *cpu_rev = "1.2"; 425 cpu_rev = "1.2";
371 pr_warn("Warning: unknown chip type; assuming OMAP3630ES1.2\n"); 426 pr_warn("Warning: unknown chip type; assuming OMAP3630ES1.2\n");
372 } 427 }
373} 428}
374 429
375static void __init omap4_check_revision(void) 430void __init omap4xxx_check_revision(void)
376{ 431{
377 u32 idcode; 432 u32 idcode;
378 u16 hawkeye; 433 u16 hawkeye;
@@ -445,89 +500,6 @@ static void __init omap4_check_revision(void)
445 ((omap_rev() >> 12) & 0xf), ((omap_rev() >> 8) & 0xf)); 500 ((omap_rev() >> 12) & 0xf), ((omap_rev() >> 8) & 0xf));
446} 501}
447 502
448#define OMAP3_SHOW_FEATURE(feat) \
449 if (omap3_has_ ##feat()) \
450 printk(#feat" ");
451
452static void __init omap3_cpuinfo(const char *cpu_rev)
453{
454 const char *cpu_name;
455
456 /*
457 * OMAP3430 and OMAP3530 are assumed to be same.
458 *
459 * OMAP3525, OMAP3515 and OMAP3503 can be detected only based
460 * on available features. Upon detection, update the CPU id
461 * and CPU class bits.
462 */
463 if (cpu_is_omap3630()) {
464 cpu_name = "OMAP3630";
465 } else if (cpu_is_omap3517()) {
466 /* AM35xx devices */
467 cpu_name = (omap3_has_sgx()) ? "AM3517" : "AM3505";
468 } else if (cpu_is_ti816x()) {
469 cpu_name = "TI816X";
470 } else if (cpu_is_am335x()) {
471 cpu_name = "AM335X";
472 } else if (cpu_is_ti814x()) {
473 cpu_name = "TI814X";
474 } else if (omap3_has_iva() && omap3_has_sgx()) {
475 /* OMAP3430, OMAP3525, OMAP3515, OMAP3503 devices */
476 cpu_name = "OMAP3430/3530";
477 } else if (omap3_has_iva()) {
478 cpu_name = "OMAP3525";
479 } else if (omap3_has_sgx()) {
480 cpu_name = "OMAP3515";
481 } else {
482 cpu_name = "OMAP3503";
483 }
484
485 /* Print verbose information */
486 pr_info("%s ES%s (", cpu_name, cpu_rev);
487
488 OMAP3_SHOW_FEATURE(l2cache);
489 OMAP3_SHOW_FEATURE(iva);
490 OMAP3_SHOW_FEATURE(sgx);
491 OMAP3_SHOW_FEATURE(neon);
492 OMAP3_SHOW_FEATURE(isp);
493 OMAP3_SHOW_FEATURE(192mhz_clk);
494
495 printk(")\n");
496}
497
498/*
499 * Try to detect the exact revision of the omap we're running on
500 */
501void __init omap2_check_revision(void)
502{
503 const char *cpu_rev;
504
505 /*
506 * At this point we have an idea about the processor revision set
507 * earlier with omap2_set_globals_tap().
508 */
509 if (cpu_is_omap24xx()) {
510 omap24xx_check_revision();
511 } else if (cpu_is_omap34xx()) {
512 omap3_check_revision(&cpu_rev);
513
514 /* TI81XX doesn't have feature register */
515 if (!cpu_is_ti81xx())
516 omap3_check_features();
517 else
518 ti81xx_check_features();
519
520 omap3_cpuinfo(cpu_rev);
521 return;
522 } else if (cpu_is_omap44xx()) {
523 omap4_check_revision();
524 omap4_check_features();
525 return;
526 } else {
527 pr_err("OMAP revision unknown, please fix!\n");
528 }
529}
530
531/* 503/*
532 * Set up things for map_io and processor detection later on. Gets called 504 * Set up things for map_io and processor detection later on. Gets called
533 * pretty much first thing from board init. For multi-omap, this gets 505 * pretty much first thing from board init. For multi-omap, this gets
diff --git a/arch/arm/mach-omap2/include/mach/entry-macro.S b/arch/arm/mach-omap2/include/mach/entry-macro.S
deleted file mode 100644
index 56964a0c4c7..00000000000
--- a/arch/arm/mach-omap2/include/mach/entry-macro.S
+++ /dev/null
@@ -1,18 +0,0 @@
1/*
2 * arch/arm/plat-omap/include/mach/entry-macro.S
3 *
4 * Low-level IRQ helper macros for OMAP-based platforms
5 *
6 * Copyright (C) 2009 Texas Instruments
7 * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com>
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 .macro disable_fiq
15 .endm
16
17 .macro arch_ret_to_user, tmp1, tmp2
18 .endm
diff --git a/arch/arm/mach-omap2/include/mach/io.h b/arch/arm/mach-omap2/include/mach/io.h
index fd78f31aa1a..b8758c8a939 100644
--- a/arch/arm/mach-omap2/include/mach/io.h
+++ b/arch/arm/mach-omap2/include/mach/io.h
@@ -1,5 +1,49 @@
1/* 1/*
2 * arch/arm/mach-omap2/include/mach/io.h 2 * arch/arm/mach-omap2/include/mach/io.h
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 Texas Instruments
10 * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com>
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 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
20 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * You should have received a copy of the GNU General Public License along
29 * with this program; if not, write to the Free Software Foundation, Inc.,
30 * 675 Mass Ave, Cambridge, MA 02139, USA.
31 *
32 * Modifications:
33 * 06-12-1997 RMK Created.
34 * 07-04-1999 RMK Major cleanup
3 */ 35 */
4 36
5#include <plat/io.h> 37#ifndef __ASM_ARM_ARCH_IO_H
38#define __ASM_ARM_ARCH_IO_H
39
40#define IO_SPACE_LIMIT 0xffffffff
41
42/*
43 * We don't actually have real ISA nor PCI buses, but there is so many
44 * drivers out there that might just work if we fake them...
45 */
46#define __io(a) __typesafe_io(a)
47#define __mem_pci(a) (a)
48
49#endif
diff --git a/arch/arm/mach-omap2/include/mach/system.h b/arch/arm/mach-omap2/include/mach/system.h
deleted file mode 100644
index d488721ab90..00000000000
--- a/arch/arm/mach-omap2/include/mach/system.h
+++ /dev/null
@@ -1,5 +0,0 @@
1/*
2 * arch/arm/mach-omap2/include/mach/system.h
3 */
4
5#include <plat/system.h>
diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
index e501b4972a6..065bd768987 100644
--- a/arch/arm/mach-omap2/io.c
+++ b/arch/arm/mach-omap2/io.c
@@ -23,33 +23,30 @@
23#include <linux/clk.h> 23#include <linux/clk.h>
24 24
25#include <asm/tlb.h> 25#include <asm/tlb.h>
26
27#include <asm/mach/map.h> 26#include <asm/mach/map.h>
28 27
29#include <plat/sram.h> 28#include <plat/sram.h>
30#include <plat/sdrc.h> 29#include <plat/sdrc.h>
31#include <plat/serial.h> 30#include <plat/serial.h>
32
33#include "clock2xxx.h"
34#include "clock3xxx.h"
35#include "clock44xx.h"
36
37#include "common.h"
38#include <plat/omap-pm.h> 31#include <plat/omap-pm.h>
32#include <plat/omap_hwmod.h>
33#include <plat/multi.h>
34
35#include "iomap.h"
39#include "voltage.h" 36#include "voltage.h"
40#include "powerdomain.h" 37#include "powerdomain.h"
41
42#include "clockdomain.h" 38#include "clockdomain.h"
43#include <plat/omap_hwmod.h>
44#include <plat/multi.h>
45#include "common.h" 39#include "common.h"
40#include "clock2xxx.h"
41#include "clock3xxx.h"
42#include "clock44xx.h"
46 43
47/* 44/*
48 * The machine specific code may provide the extra mapping besides the 45 * The machine specific code may provide the extra mapping besides the
49 * default mapping provided here. 46 * default mapping provided here.
50 */ 47 */
51 48
52#ifdef CONFIG_ARCH_OMAP2 49#if defined(CONFIG_SOC_OMAP2420) || defined(CONFIG_SOC_OMAP2430)
53static struct map_desc omap24xx_io_desc[] __initdata = { 50static struct map_desc omap24xx_io_desc[] __initdata = {
54 { 51 {
55 .virtual = L3_24XX_VIRT, 52 .virtual = L3_24XX_VIRT,
@@ -351,7 +348,6 @@ static int _set_hwmod_postsetup_state(struct omap_hwmod *oh, void *data)
351 348
352static void __init omap_common_init_early(void) 349static void __init omap_common_init_early(void)
353{ 350{
354 omap2_check_revision();
355 omap_init_consistent_dma_size(); 351 omap_init_consistent_dma_size();
356} 352}
357 353
@@ -392,6 +388,7 @@ static void __init omap_hwmod_init_postsetup(void)
392void __init omap2420_init_early(void) 388void __init omap2420_init_early(void)
393{ 389{
394 omap2_set_globals_242x(); 390 omap2_set_globals_242x();
391 omap2xxx_check_revision();
395 omap_common_init_early(); 392 omap_common_init_early();
396 omap2xxx_voltagedomains_init(); 393 omap2xxx_voltagedomains_init();
397 omap242x_powerdomains_init(); 394 omap242x_powerdomains_init();
@@ -406,6 +403,7 @@ void __init omap2420_init_early(void)
406void __init omap2430_init_early(void) 403void __init omap2430_init_early(void)
407{ 404{
408 omap2_set_globals_243x(); 405 omap2_set_globals_243x();
406 omap2xxx_check_revision();
409 omap_common_init_early(); 407 omap_common_init_early();
410 omap2xxx_voltagedomains_init(); 408 omap2xxx_voltagedomains_init();
411 omap243x_powerdomains_init(); 409 omap243x_powerdomains_init();
@@ -424,6 +422,8 @@ void __init omap2430_init_early(void)
424void __init omap3_init_early(void) 422void __init omap3_init_early(void)
425{ 423{
426 omap2_set_globals_3xxx(); 424 omap2_set_globals_3xxx();
425 omap3xxx_check_revision();
426 omap3xxx_check_features();
427 omap_common_init_early(); 427 omap_common_init_early();
428 omap3xxx_voltagedomains_init(); 428 omap3xxx_voltagedomains_init();
429 omap3xxx_powerdomains_init(); 429 omap3xxx_powerdomains_init();
@@ -456,6 +456,8 @@ void __init am35xx_init_early(void)
456void __init ti81xx_init_early(void) 456void __init ti81xx_init_early(void)
457{ 457{
458 omap2_set_globals_ti81xx(); 458 omap2_set_globals_ti81xx();
459 omap3xxx_check_revision();
460 ti81xx_check_features();
459 omap_common_init_early(); 461 omap_common_init_early();
460 omap3xxx_voltagedomains_init(); 462 omap3xxx_voltagedomains_init();
461 omap3xxx_powerdomains_init(); 463 omap3xxx_powerdomains_init();
@@ -470,6 +472,8 @@ void __init ti81xx_init_early(void)
470void __init omap4430_init_early(void) 472void __init omap4430_init_early(void)
471{ 473{
472 omap2_set_globals_443x(); 474 omap2_set_globals_443x();
475 omap4xxx_check_revision();
476 omap4xxx_check_features();
473 omap_common_init_early(); 477 omap_common_init_early();
474 omap44xx_voltagedomains_init(); 478 omap44xx_voltagedomains_init();
475 omap44xx_powerdomains_init(); 479 omap44xx_powerdomains_init();
@@ -490,43 +494,3 @@ void __init omap_sdrc_init(struct omap_sdrc_params *sdrc_cs0,
490 _omap2_init_reprogram_sdrc(); 494 _omap2_init_reprogram_sdrc();
491 } 495 }
492} 496}
493
494/*
495 * NOTE: Please use ioremap + __raw_read/write where possible instead of these
496 */
497
498u8 omap_readb(u32 pa)
499{
500 return __raw_readb(OMAP2_L4_IO_ADDRESS(pa));
501}
502EXPORT_SYMBOL(omap_readb);
503
504u16 omap_readw(u32 pa)
505{
506 return __raw_readw(OMAP2_L4_IO_ADDRESS(pa));
507}
508EXPORT_SYMBOL(omap_readw);
509
510u32 omap_readl(u32 pa)
511{
512 return __raw_readl(OMAP2_L4_IO_ADDRESS(pa));
513}
514EXPORT_SYMBOL(omap_readl);
515
516void omap_writeb(u8 v, u32 pa)
517{
518 __raw_writeb(v, OMAP2_L4_IO_ADDRESS(pa));
519}
520EXPORT_SYMBOL(omap_writeb);
521
522void omap_writew(u16 v, u32 pa)
523{
524 __raw_writew(v, OMAP2_L4_IO_ADDRESS(pa));
525}
526EXPORT_SYMBOL(omap_writew);
527
528void omap_writel(u32 v, u32 pa)
529{
530 __raw_writel(v, OMAP2_L4_IO_ADDRESS(pa));
531}
532EXPORT_SYMBOL(omap_writel);
diff --git a/arch/arm/plat-omap/include/plat/io.h b/arch/arm/mach-omap2/iomap.h
index 0696bae1818..e6f95816529 100644
--- a/arch/arm/plat-omap/include/plat/io.h
+++ b/arch/arm/mach-omap2/iomap.h
@@ -1,13 +1,5 @@
1/* 1/*
2 * arch/arm/plat-omap/include/mach/io.h 2 * IO mappings for OMAP2+
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 Texas Instruments
10 * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com>
11 * 3 *
12 * 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
13 * under the terms of the GNU General Public License as published by the 5 * under the terms of the GNU General Public License as published by the
@@ -25,33 +17,9 @@
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 17 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 18 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 * 19 *
28 * You should have received a copy of the GNU General Public License along 20 * You should have received a copy of the GNU General Public License along
29 * with this program; if not, write to the Free Software Foundation, Inc., 21 * with this program; if not, write to the Free Software Foundation, Inc.,
30 * 675 Mass Ave, Cambridge, MA 02139, USA. 22 * 675 Mass Ave, Cambridge, MA 02139, USA.
31 *
32 * Modifications:
33 * 06-12-1997 RMK Created.
34 * 07-04-1999 RMK Major cleanup
35 */
36
37#ifndef __ASM_ARM_ARCH_IO_H
38#define __ASM_ARM_ARCH_IO_H
39
40#include <mach/hardware.h>
41
42#define IO_SPACE_LIMIT 0xffffffff
43
44/*
45 * We don't actually have real ISA nor PCI buses, but there is so many
46 * drivers out there that might just work if we fake them...
47 */
48#define __io(a) __typesafe_io(a)
49#define __mem_pci(a) (a)
50
51/*
52 * ----------------------------------------------------------------------------
53 * I/O mapping
54 * ----------------------------------------------------------------------------
55 */ 23 */
56 24
57#ifdef __ASSEMBLER__ 25#ifdef __ASSEMBLER__
@@ -60,13 +28,9 @@
60#define IOMEM(x) ((void __force __iomem *)(x)) 28#define IOMEM(x) ((void __force __iomem *)(x))
61#endif 29#endif
62 30
63#define OMAP1_IO_OFFSET 0x01000000 /* Virtual IO = 0xfefb0000 */
64#define OMAP1_IO_ADDRESS(pa) IOMEM((pa) - OMAP1_IO_OFFSET)
65
66#define OMAP2_L3_IO_OFFSET 0x90000000 31#define OMAP2_L3_IO_OFFSET 0x90000000
67#define OMAP2_L3_IO_ADDRESS(pa) IOMEM((pa) + OMAP2_L3_IO_OFFSET) /* L3 */ 32#define OMAP2_L3_IO_ADDRESS(pa) IOMEM((pa) + OMAP2_L3_IO_OFFSET) /* L3 */
68 33
69
70#define OMAP2_L4_IO_OFFSET 0xb2000000 34#define OMAP2_L4_IO_OFFSET 0xb2000000
71#define OMAP2_L4_IO_ADDRESS(pa) IOMEM((pa) + OMAP2_L4_IO_OFFSET) /* L4 */ 35#define OMAP2_L4_IO_ADDRESS(pa) IOMEM((pa) + OMAP2_L4_IO_OFFSET) /* L4 */
72 36
@@ -87,16 +51,6 @@
87 51
88/* 52/*
89 * ---------------------------------------------------------------------------- 53 * ----------------------------------------------------------------------------
90 * Omap1 specific IO mapping
91 * ----------------------------------------------------------------------------
92 */
93
94#define OMAP1_IO_PHYS 0xFFFB0000
95#define OMAP1_IO_SIZE 0x40000
96#define OMAP1_IO_VIRT (OMAP1_IO_PHYS - OMAP1_IO_OFFSET)
97
98/*
99 * ----------------------------------------------------------------------------
100 * Omap2 specific IO mapping 54 * Omap2 specific IO mapping
101 * ---------------------------------------------------------------------------- 55 * ----------------------------------------------------------------------------
102 */ 56 */
@@ -247,31 +201,3 @@
247 /* 0x4e000000 --> 0xfd300000 */ 201 /* 0x4e000000 --> 0xfd300000 */
248#define OMAP44XX_DMM_SIZE SZ_1M 202#define OMAP44XX_DMM_SIZE SZ_1M
249#define OMAP44XX_DMM_VIRT (OMAP44XX_EMIF2_VIRT + OMAP44XX_EMIF2_SIZE) 203#define OMAP44XX_DMM_VIRT (OMAP44XX_EMIF2_VIRT + OMAP44XX_EMIF2_SIZE)
250/*
251 * ----------------------------------------------------------------------------
252 * Omap specific register access
253 * ----------------------------------------------------------------------------
254 */
255
256#ifndef __ASSEMBLER__
257
258/*
259 * NOTE: Please use ioremap + __raw_read/write where possible instead of these
260 */
261
262extern u8 omap_readb(u32 pa);
263extern u16 omap_readw(u32 pa);
264extern u32 omap_readl(u32 pa);
265extern void omap_writeb(u8 v, u32 pa);
266extern void omap_writew(u16 v, u32 pa);
267extern void omap_writel(u32 v, u32 pa);
268
269struct omap_sdrc_params;
270extern void omap_sdrc_init(struct omap_sdrc_params *sdrc_cs0,
271 struct omap_sdrc_params *sdrc_cs1);
272
273extern void __init omap_init_consistent_dma_size(void);
274
275#endif
276
277#endif
diff --git a/arch/arm/mach-omap2/irq.c b/arch/arm/mach-omap2/irq.c
index 1fef061f792..65f0d2571c9 100644
--- a/arch/arm/mach-omap2/irq.c
+++ b/arch/arm/mach-omap2/irq.c
@@ -11,13 +11,20 @@
11 * for more details. 11 * for more details.
12 */ 12 */
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/module.h>
14#include <linux/init.h> 15#include <linux/init.h>
15#include <linux/interrupt.h> 16#include <linux/interrupt.h>
16#include <linux/io.h> 17#include <linux/io.h>
17#include <mach/hardware.h> 18
18#include <asm/exception.h> 19#include <asm/exception.h>
19#include <asm/mach/irq.h> 20#include <asm/mach/irq.h>
21#include <linux/irqdomain.h>
22#include <linux/of.h>
23#include <linux/of_address.h>
20 24
25#include <mach/hardware.h>
26
27#include "iomap.h"
21 28
22/* selected INTC register offsets */ 29/* selected INTC register offsets */
23 30
@@ -57,6 +64,8 @@ static struct omap_irq_bank {
57 }, 64 },
58}; 65};
59 66
67static struct irq_domain *domain;
68
60/* Structure to save interrupt controller context */ 69/* Structure to save interrupt controller context */
61struct omap3_intc_regs { 70struct omap3_intc_regs {
62 u32 sysconfig; 71 u32 sysconfig;
@@ -147,17 +156,27 @@ omap_alloc_gc(void __iomem *base, unsigned int irq_start, unsigned int num)
147 IRQ_NOREQUEST | IRQ_NOPROBE, 0); 156 IRQ_NOREQUEST | IRQ_NOPROBE, 0);
148} 157}
149 158
150static void __init omap_init_irq(u32 base, int nr_irqs) 159static void __init omap_init_irq(u32 base, int nr_irqs,
160 struct device_node *node)
151{ 161{
152 void __iomem *omap_irq_base; 162 void __iomem *omap_irq_base;
153 unsigned long nr_of_irqs = 0; 163 unsigned long nr_of_irqs = 0;
154 unsigned int nr_banks = 0; 164 unsigned int nr_banks = 0;
155 int i, j; 165 int i, j, irq_base;
156 166
157 omap_irq_base = ioremap(base, SZ_4K); 167 omap_irq_base = ioremap(base, SZ_4K);
158 if (WARN_ON(!omap_irq_base)) 168 if (WARN_ON(!omap_irq_base))
159 return; 169 return;
160 170
171 irq_base = irq_alloc_descs(-1, 0, nr_irqs, 0);
172 if (irq_base < 0) {
173 pr_warn("Couldn't allocate IRQ numbers\n");
174 irq_base = 0;
175 }
176
177 domain = irq_domain_add_legacy(node, nr_irqs, irq_base, 0,
178 &irq_domain_simple_ops, NULL);
179
161 for (i = 0; i < ARRAY_SIZE(irq_banks); i++) { 180 for (i = 0; i < ARRAY_SIZE(irq_banks); i++) {
162 struct omap_irq_bank *bank = irq_banks + i; 181 struct omap_irq_bank *bank = irq_banks + i;
163 182
@@ -166,36 +185,36 @@ static void __init omap_init_irq(u32 base, int nr_irqs)
166 /* Static mapping, never released */ 185 /* Static mapping, never released */
167 bank->base_reg = ioremap(base, SZ_4K); 186 bank->base_reg = ioremap(base, SZ_4K);
168 if (!bank->base_reg) { 187 if (!bank->base_reg) {
169 printk(KERN_ERR "Could not ioremap irq bank%i\n", i); 188 pr_err("Could not ioremap irq bank%i\n", i);
170 continue; 189 continue;
171 } 190 }
172 191
173 omap_irq_bank_init_one(bank); 192 omap_irq_bank_init_one(bank);
174 193
175 for (j = 0; j < bank->nr_irqs; j += 32) 194 for (j = 0; j < bank->nr_irqs; j += 32)
176 omap_alloc_gc(bank->base_reg + j, j, 32); 195 omap_alloc_gc(bank->base_reg + j, j + irq_base, 32);
177 196
178 nr_of_irqs += bank->nr_irqs; 197 nr_of_irqs += bank->nr_irqs;
179 nr_banks++; 198 nr_banks++;
180 } 199 }
181 200
182 printk(KERN_INFO "Total of %ld interrupts on %d active controller%s\n", 201 pr_info("Total of %ld interrupts on %d active controller%s\n",
183 nr_of_irqs, nr_banks, nr_banks > 1 ? "s" : ""); 202 nr_of_irqs, nr_banks, nr_banks > 1 ? "s" : "");
184} 203}
185 204
186void __init omap2_init_irq(void) 205void __init omap2_init_irq(void)
187{ 206{
188 omap_init_irq(OMAP24XX_IC_BASE, 96); 207 omap_init_irq(OMAP24XX_IC_BASE, 96, NULL);
189} 208}
190 209
191void __init omap3_init_irq(void) 210void __init omap3_init_irq(void)
192{ 211{
193 omap_init_irq(OMAP34XX_IC_BASE, 96); 212 omap_init_irq(OMAP34XX_IC_BASE, 96, NULL);
194} 213}
195 214
196void __init ti81xx_init_irq(void) 215void __init ti81xx_init_irq(void)
197{ 216{
198 omap_init_irq(OMAP34XX_IC_BASE, 128); 217 omap_init_irq(OMAP34XX_IC_BASE, 128, NULL);
199} 218}
200 219
201static inline void omap_intc_handle_irq(void __iomem *base_addr, struct pt_regs *regs) 220static inline void omap_intc_handle_irq(void __iomem *base_addr, struct pt_regs *regs)
@@ -225,8 +244,10 @@ out:
225 irqnr = readl_relaxed(base_addr + INTCPS_SIR_IRQ_OFFSET); 244 irqnr = readl_relaxed(base_addr + INTCPS_SIR_IRQ_OFFSET);
226 irqnr &= ACTIVEIRQ_MASK; 245 irqnr &= ACTIVEIRQ_MASK;
227 246
228 if (irqnr) 247 if (irqnr) {
248 irqnr = irq_find_mapping(domain, irqnr);
229 handle_IRQ(irqnr, regs); 249 handle_IRQ(irqnr, regs);
250 }
230 } while (irqnr); 251 } while (irqnr);
231} 252}
232 253
@@ -236,6 +257,28 @@ asmlinkage void __exception_irq_entry omap2_intc_handle_irq(struct pt_regs *regs
236 omap_intc_handle_irq(base_addr, regs); 257 omap_intc_handle_irq(base_addr, regs);
237} 258}
238 259
260int __init omap_intc_of_init(struct device_node *node,
261 struct device_node *parent)
262{
263 struct resource res;
264 u32 nr_irqs = 96;
265
266 if (WARN_ON(!node))
267 return -ENODEV;
268
269 if (of_address_to_resource(node, 0, &res)) {
270 WARN(1, "unable to get intc registers\n");
271 return -EINVAL;
272 }
273
274 if (of_property_read_u32(node, "ti,intc-size", &nr_irqs))
275 pr_warn("unable to get intc-size, default to %d\n", nr_irqs);
276
277 omap_init_irq(res.start, nr_irqs, of_node_get(node));
278
279 return 0;
280}
281
239#ifdef CONFIG_ARCH_OMAP3 282#ifdef CONFIG_ARCH_OMAP3
240static struct omap3_intc_regs intc_context[ARRAY_SIZE(irq_banks)]; 283static struct omap3_intc_regs intc_context[ARRAY_SIZE(irq_banks)];
241 284
diff --git a/arch/arm/mach-omap2/mcbsp.c b/arch/arm/mach-omap2/mcbsp.c
index ecc039e794d..577cb77db26 100644
--- a/arch/arm/mach-omap2/mcbsp.c
+++ b/arch/arm/mach-omap2/mcbsp.c
@@ -158,7 +158,7 @@ static int omap3_enable_st_clock(unsigned int id, bool enable)
158 return 0; 158 return 0;
159} 159}
160 160
161static int omap_init_mcbsp(struct omap_hwmod *oh, void *unused) 161static int __init omap_init_mcbsp(struct omap_hwmod *oh, void *unused)
162{ 162{
163 int id, count = 1; 163 int id, count = 1;
164 char *name = "omap-mcbsp"; 164 char *name = "omap-mcbsp";
diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c
index e974d339a35..65c33911341 100644
--- a/arch/arm/mach-omap2/mux.c
+++ b/arch/arm/mach-omap2/mux.c
@@ -99,8 +99,8 @@ void omap_mux_write_array(struct omap_mux_partition *partition,
99 99
100static char *omap_mux_options; 100static char *omap_mux_options;
101 101
102static int _omap_mux_init_gpio(struct omap_mux_partition *partition, 102static int __init _omap_mux_init_gpio(struct omap_mux_partition *partition,
103 int gpio, int val) 103 int gpio, int val)
104{ 104{
105 struct omap_mux_entry *e; 105 struct omap_mux_entry *e;
106 struct omap_mux *gpio_mux = NULL; 106 struct omap_mux *gpio_mux = NULL;
@@ -144,7 +144,7 @@ static int _omap_mux_init_gpio(struct omap_mux_partition *partition,
144 return 0; 144 return 0;
145} 145}
146 146
147int omap_mux_init_gpio(int gpio, int val) 147int __init omap_mux_init_gpio(int gpio, int val)
148{ 148{
149 struct omap_mux_partition *partition; 149 struct omap_mux_partition *partition;
150 int ret; 150 int ret;
@@ -158,9 +158,9 @@ int omap_mux_init_gpio(int gpio, int val)
158 return -ENODEV; 158 return -ENODEV;
159} 159}
160 160
161static int _omap_mux_get_by_name(struct omap_mux_partition *partition, 161static int __init _omap_mux_get_by_name(struct omap_mux_partition *partition,
162 const char *muxname, 162 const char *muxname,
163 struct omap_mux **found_mux) 163 struct omap_mux **found_mux)
164{ 164{
165 struct omap_mux *mux = NULL; 165 struct omap_mux *mux = NULL;
166 struct omap_mux_entry *e; 166 struct omap_mux_entry *e;
@@ -217,7 +217,7 @@ static int _omap_mux_get_by_name(struct omap_mux_partition *partition,
217 return -ENODEV; 217 return -ENODEV;
218} 218}
219 219
220static int 220static int __init
221omap_mux_get_by_name(const char *muxname, 221omap_mux_get_by_name(const char *muxname,
222 struct omap_mux_partition **found_partition, 222 struct omap_mux_partition **found_partition,
223 struct omap_mux **found_mux) 223 struct omap_mux **found_mux)
@@ -239,7 +239,7 @@ omap_mux_get_by_name(const char *muxname,
239 return -ENODEV; 239 return -ENODEV;
240} 240}
241 241
242int omap_mux_init_signal(const char *muxname, int val) 242int __init omap_mux_init_signal(const char *muxname, int val)
243{ 243{
244 struct omap_mux_partition *partition = NULL; 244 struct omap_mux_partition *partition = NULL;
245 struct omap_mux *mux = NULL; 245 struct omap_mux *mux = NULL;
diff --git a/arch/arm/mach-omap2/mux.h b/arch/arm/mach-omap2/mux.h
index 2132308ad1e..69fe060a0b7 100644
--- a/arch/arm/mach-omap2/mux.h
+++ b/arch/arm/mach-omap2/mux.h
@@ -246,7 +246,7 @@ static inline void omap_hwmod_mux(struct omap_hwmod_mux_info *hmux, u8 state)
246{ 246{
247} 247}
248 248
249static struct omap_board_mux *board_mux __initdata __maybe_unused; 249static struct omap_board_mux *board_mux __maybe_unused;
250 250
251#endif 251#endif
252 252
diff --git a/arch/arm/mach-omap2/omap-hotplug.c b/arch/arm/mach-omap2/omap-hotplug.c
index adbe4d8c7ca..56c345b8b93 100644
--- a/arch/arm/mach-omap2/omap-hotplug.c
+++ b/arch/arm/mach-omap2/omap-hotplug.c
@@ -33,7 +33,7 @@ int platform_cpu_kill(unsigned int cpu)
33 * platform-specific code to shutdown a CPU 33 * platform-specific code to shutdown a CPU
34 * Called with IRQs disabled 34 * Called with IRQs disabled
35 */ 35 */
36void platform_cpu_die(unsigned int cpu) 36void __ref platform_cpu_die(unsigned int cpu)
37{ 37{
38 unsigned int this_cpu; 38 unsigned int this_cpu;
39 39
diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
index 069f8fc99d1..13670aa84e5 100644
--- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c
+++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
@@ -262,12 +262,10 @@ int omap4_enter_lowpower(unsigned int cpu, unsigned int power_state)
262 * In MPUSS OSWR or device OFF, interrupt controller contest is lost. 262 * In MPUSS OSWR or device OFF, interrupt controller contest is lost.
263 */ 263 */
264 mpuss_clear_prev_logic_pwrst(); 264 mpuss_clear_prev_logic_pwrst();
265 pwrdm_clear_all_prev_pwrst(mpuss_pd);
266 if ((pwrdm_read_next_pwrst(mpuss_pd) == PWRDM_POWER_RET) && 265 if ((pwrdm_read_next_pwrst(mpuss_pd) == PWRDM_POWER_RET) &&
267 (pwrdm_read_logic_retst(mpuss_pd) == PWRDM_POWER_OFF)) 266 (pwrdm_read_logic_retst(mpuss_pd) == PWRDM_POWER_OFF))
268 save_state = 2; 267 save_state = 2;
269 268
270 clear_cpu_prev_pwrst(cpu);
271 cpu_clear_prev_logic_pwrst(cpu); 269 cpu_clear_prev_logic_pwrst(cpu);
272 set_cpu_next_pwrst(cpu, power_state); 270 set_cpu_next_pwrst(cpu, power_state);
273 set_cpu_wakeup_addr(cpu, virt_to_phys(omap4_cpu_resume)); 271 set_cpu_wakeup_addr(cpu, virt_to_phys(omap4_cpu_resume));
@@ -299,7 +297,7 @@ int omap4_enter_lowpower(unsigned int cpu, unsigned int power_state)
299 * @cpu : CPU ID 297 * @cpu : CPU ID
300 * @power_state: CPU low power state. 298 * @power_state: CPU low power state.
301 */ 299 */
302int omap4_hotplug_cpu(unsigned int cpu, unsigned int power_state) 300int __cpuinit omap4_hotplug_cpu(unsigned int cpu, unsigned int power_state)
303{ 301{
304 unsigned int cpu_state = 0; 302 unsigned int cpu_state = 0;
305 303
diff --git a/arch/arm/mach-omap2/omap-smp.c b/arch/arm/mach-omap2/omap-smp.c
index c1bf3ef0ba0..deffbf1c962 100644
--- a/arch/arm/mach-omap2/omap-smp.c
+++ b/arch/arm/mach-omap2/omap-smp.c
@@ -23,11 +23,12 @@
23#include <asm/cacheflush.h> 23#include <asm/cacheflush.h>
24#include <asm/hardware/gic.h> 24#include <asm/hardware/gic.h>
25#include <asm/smp_scu.h> 25#include <asm/smp_scu.h>
26
26#include <mach/hardware.h> 27#include <mach/hardware.h>
27#include <mach/omap-secure.h> 28#include <mach/omap-secure.h>
28 29
30#include "iomap.h"
29#include "common.h" 31#include "common.h"
30
31#include "clockdomain.h" 32#include "clockdomain.h"
32 33
33/* SCU base address */ 34/* SCU base address */
diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
index d3d8971d7f3..42cd7fb5241 100644
--- a/arch/arm/mach-omap2/omap-wakeupgen.c
+++ b/arch/arm/mach-omap2/omap-wakeupgen.c
@@ -43,7 +43,6 @@
43 43
44static void __iomem *wakeupgen_base; 44static void __iomem *wakeupgen_base;
45static void __iomem *sar_base; 45static void __iomem *sar_base;
46static DEFINE_PER_CPU(u32 [NR_REG_BANKS], irqmasks);
47static DEFINE_SPINLOCK(wakeupgen_lock); 46static DEFINE_SPINLOCK(wakeupgen_lock);
48static unsigned int irq_target_cpu[NR_IRQS]; 47static unsigned int irq_target_cpu[NR_IRQS];
49 48
@@ -67,14 +66,6 @@ static inline void sar_writel(u32 val, u32 offset, u8 idx)
67 __raw_writel(val, sar_base + offset + (idx * 4)); 66 __raw_writel(val, sar_base + offset + (idx * 4));
68} 67}
69 68
70static void _wakeupgen_set_all(unsigned int cpu, unsigned int reg)
71{
72 u8 i;
73
74 for (i = 0; i < NR_REG_BANKS; i++)
75 wakeupgen_writel(reg, i, cpu);
76}
77
78static inline int _wakeupgen_get_irq_info(u32 irq, u32 *bit_posn, u8 *reg_index) 69static inline int _wakeupgen_get_irq_info(u32 irq, u32 *bit_posn, u8 *reg_index)
79{ 70{
80 unsigned int spi_irq; 71 unsigned int spi_irq;
@@ -130,22 +121,6 @@ static void _wakeupgen_set(unsigned int irq, unsigned int cpu)
130 wakeupgen_writel(val, i, cpu); 121 wakeupgen_writel(val, i, cpu);
131} 122}
132 123
133static void _wakeupgen_save_masks(unsigned int cpu)
134{
135 u8 i;
136
137 for (i = 0; i < NR_REG_BANKS; i++)
138 per_cpu(irqmasks, cpu)[i] = wakeupgen_readl(i, cpu);
139}
140
141static void _wakeupgen_restore_masks(unsigned int cpu)
142{
143 u8 i;
144
145 for (i = 0; i < NR_REG_BANKS; i++)
146 wakeupgen_writel(per_cpu(irqmasks, cpu)[i], i, cpu);
147}
148
149/* 124/*
150 * Architecture specific Mask extension 125 * Architecture specific Mask extension
151 */ 126 */
@@ -170,6 +145,33 @@ static void wakeupgen_unmask(struct irq_data *d)
170 spin_unlock_irqrestore(&wakeupgen_lock, flags); 145 spin_unlock_irqrestore(&wakeupgen_lock, flags);
171} 146}
172 147
148#ifdef CONFIG_HOTPLUG_CPU
149static DEFINE_PER_CPU(u32 [NR_REG_BANKS], irqmasks);
150
151static void _wakeupgen_save_masks(unsigned int cpu)
152{
153 u8 i;
154
155 for (i = 0; i < NR_REG_BANKS; i++)
156 per_cpu(irqmasks, cpu)[i] = wakeupgen_readl(i, cpu);
157}
158
159static void _wakeupgen_restore_masks(unsigned int cpu)
160{
161 u8 i;
162
163 for (i = 0; i < NR_REG_BANKS; i++)
164 wakeupgen_writel(per_cpu(irqmasks, cpu)[i], i, cpu);
165}
166
167static void _wakeupgen_set_all(unsigned int cpu, unsigned int reg)
168{
169 u8 i;
170
171 for (i = 0; i < NR_REG_BANKS; i++)
172 wakeupgen_writel(reg, i, cpu);
173}
174
173/* 175/*
174 * Mask or unmask all interrupts on given CPU. 176 * Mask or unmask all interrupts on given CPU.
175 * 0 = Mask all interrupts on the 'cpu' 177 * 0 = Mask all interrupts on the 'cpu'
@@ -191,6 +193,7 @@ static void wakeupgen_irqmask_all(unsigned int cpu, unsigned int set)
191 } 193 }
192 spin_unlock_irqrestore(&wakeupgen_lock, flags); 194 spin_unlock_irqrestore(&wakeupgen_lock, flags);
193} 195}
196#endif
194 197
195#ifdef CONFIG_CPU_PM 198#ifdef CONFIG_CPU_PM
196/* 199/*
diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
index 3c8dd928628..34b9766d1d2 100644
--- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
@@ -29,6 +29,7 @@
29 29
30#include "omap_hwmod_common_data.h" 30#include "omap_hwmod_common_data.h"
31 31
32#include "smartreflex.h"
32#include "prm-regbits-34xx.h" 33#include "prm-regbits-34xx.h"
33#include "cm-regbits-34xx.h" 34#include "cm-regbits-34xx.h"
34#include "wd_timer.h" 35#include "wd_timer.h"
@@ -376,6 +377,16 @@ static struct omap_hwmod_ocp_if omap3_l4_core__i2c3 = {
376 .user = OCP_USER_MPU | OCP_USER_SDMA, 377 .user = OCP_USER_MPU | OCP_USER_SDMA,
377}; 378};
378 379
380static struct omap_hwmod_irq_info omap3_smartreflex_mpu_irqs[] = {
381 { .irq = 18},
382 { .irq = -1 }
383};
384
385static struct omap_hwmod_irq_info omap3_smartreflex_core_irqs[] = {
386 { .irq = 19},
387 { .irq = -1 }
388};
389
379/* L4 CORE -> SR1 interface */ 390/* L4 CORE -> SR1 interface */
380static struct omap_hwmod_addr_space omap3_sr1_addr_space[] = { 391static struct omap_hwmod_addr_space omap3_sr1_addr_space[] = {
381 { 392 {
@@ -2664,6 +2675,10 @@ static struct omap_hwmod_class omap36xx_smartreflex_hwmod_class = {
2664}; 2675};
2665 2676
2666/* SR1 */ 2677/* SR1 */
2678static struct omap_smartreflex_dev_attr sr1_dev_attr = {
2679 .sensor_voltdm_name = "mpu_iva",
2680};
2681
2667static struct omap_hwmod_ocp_if *omap3_sr1_slaves[] = { 2682static struct omap_hwmod_ocp_if *omap3_sr1_slaves[] = {
2668 &omap3_l4_core__sr1, 2683 &omap3_l4_core__sr1,
2669}; 2684};
@@ -2672,7 +2687,6 @@ static struct omap_hwmod omap34xx_sr1_hwmod = {
2672 .name = "sr1_hwmod", 2687 .name = "sr1_hwmod",
2673 .class = &omap34xx_smartreflex_hwmod_class, 2688 .class = &omap34xx_smartreflex_hwmod_class,
2674 .main_clk = "sr1_fck", 2689 .main_clk = "sr1_fck",
2675 .vdd_name = "mpu_iva",
2676 .prcm = { 2690 .prcm = {
2677 .omap2 = { 2691 .omap2 = {
2678 .prcm_reg_id = 1, 2692 .prcm_reg_id = 1,
@@ -2684,6 +2698,8 @@ static struct omap_hwmod omap34xx_sr1_hwmod = {
2684 }, 2698 },
2685 .slaves = omap3_sr1_slaves, 2699 .slaves = omap3_sr1_slaves,
2686 .slaves_cnt = ARRAY_SIZE(omap3_sr1_slaves), 2700 .slaves_cnt = ARRAY_SIZE(omap3_sr1_slaves),
2701 .dev_attr = &sr1_dev_attr,
2702 .mpu_irqs = omap3_smartreflex_mpu_irqs,
2687 .flags = HWMOD_SET_DEFAULT_CLOCKACT, 2703 .flags = HWMOD_SET_DEFAULT_CLOCKACT,
2688}; 2704};
2689 2705
@@ -2691,7 +2707,6 @@ static struct omap_hwmod omap36xx_sr1_hwmod = {
2691 .name = "sr1_hwmod", 2707 .name = "sr1_hwmod",
2692 .class = &omap36xx_smartreflex_hwmod_class, 2708 .class = &omap36xx_smartreflex_hwmod_class,
2693 .main_clk = "sr1_fck", 2709 .main_clk = "sr1_fck",
2694 .vdd_name = "mpu_iva",
2695 .prcm = { 2710 .prcm = {
2696 .omap2 = { 2711 .omap2 = {
2697 .prcm_reg_id = 1, 2712 .prcm_reg_id = 1,
@@ -2703,9 +2718,15 @@ static struct omap_hwmod omap36xx_sr1_hwmod = {
2703 }, 2718 },
2704 .slaves = omap3_sr1_slaves, 2719 .slaves = omap3_sr1_slaves,
2705 .slaves_cnt = ARRAY_SIZE(omap3_sr1_slaves), 2720 .slaves_cnt = ARRAY_SIZE(omap3_sr1_slaves),
2721 .dev_attr = &sr1_dev_attr,
2722 .mpu_irqs = omap3_smartreflex_mpu_irqs,
2706}; 2723};
2707 2724
2708/* SR2 */ 2725/* SR2 */
2726static struct omap_smartreflex_dev_attr sr2_dev_attr = {
2727 .sensor_voltdm_name = "core",
2728};
2729
2709static struct omap_hwmod_ocp_if *omap3_sr2_slaves[] = { 2730static struct omap_hwmod_ocp_if *omap3_sr2_slaves[] = {
2710 &omap3_l4_core__sr2, 2731 &omap3_l4_core__sr2,
2711}; 2732};
@@ -2714,7 +2735,6 @@ static struct omap_hwmod omap34xx_sr2_hwmod = {
2714 .name = "sr2_hwmod", 2735 .name = "sr2_hwmod",
2715 .class = &omap34xx_smartreflex_hwmod_class, 2736 .class = &omap34xx_smartreflex_hwmod_class,
2716 .main_clk = "sr2_fck", 2737 .main_clk = "sr2_fck",
2717 .vdd_name = "core",
2718 .prcm = { 2738 .prcm = {
2719 .omap2 = { 2739 .omap2 = {
2720 .prcm_reg_id = 1, 2740 .prcm_reg_id = 1,
@@ -2726,6 +2746,8 @@ static struct omap_hwmod omap34xx_sr2_hwmod = {
2726 }, 2746 },
2727 .slaves = omap3_sr2_slaves, 2747 .slaves = omap3_sr2_slaves,
2728 .slaves_cnt = ARRAY_SIZE(omap3_sr2_slaves), 2748 .slaves_cnt = ARRAY_SIZE(omap3_sr2_slaves),
2749 .dev_attr = &sr2_dev_attr,
2750 .mpu_irqs = omap3_smartreflex_core_irqs,
2729 .flags = HWMOD_SET_DEFAULT_CLOCKACT, 2751 .flags = HWMOD_SET_DEFAULT_CLOCKACT,
2730}; 2752};
2731 2753
@@ -2733,7 +2755,6 @@ static struct omap_hwmod omap36xx_sr2_hwmod = {
2733 .name = "sr2_hwmod", 2755 .name = "sr2_hwmod",
2734 .class = &omap36xx_smartreflex_hwmod_class, 2756 .class = &omap36xx_smartreflex_hwmod_class,
2735 .main_clk = "sr2_fck", 2757 .main_clk = "sr2_fck",
2736 .vdd_name = "core",
2737 .prcm = { 2758 .prcm = {
2738 .omap2 = { 2759 .omap2 = {
2739 .prcm_reg_id = 1, 2760 .prcm_reg_id = 1,
@@ -2745,6 +2766,8 @@ static struct omap_hwmod omap36xx_sr2_hwmod = {
2745 }, 2766 },
2746 .slaves = omap3_sr2_slaves, 2767 .slaves = omap3_sr2_slaves,
2747 .slaves_cnt = ARRAY_SIZE(omap3_sr2_slaves), 2768 .slaves_cnt = ARRAY_SIZE(omap3_sr2_slaves),
2769 .dev_attr = &sr2_dev_attr,
2770 .mpu_irqs = omap3_smartreflex_core_irqs,
2748}; 2771};
2749 2772
2750/* 2773/*
diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
index ef0524c10a8..08daa5e0eb5 100644
--- a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
@@ -28,12 +28,12 @@
28#include <plat/mcspi.h> 28#include <plat/mcspi.h>
29#include <plat/mcbsp.h> 29#include <plat/mcbsp.h>
30#include <plat/mmc.h> 30#include <plat/mmc.h>
31#include <plat/i2c.h>
32#include <plat/dmtimer.h> 31#include <plat/dmtimer.h>
33#include <plat/common.h> 32#include <plat/common.h>
34 33
35#include "omap_hwmod_common_data.h" 34#include "omap_hwmod_common_data.h"
36 35
36#include "smartreflex.h"
37#include "cm1_44xx.h" 37#include "cm1_44xx.h"
38#include "cm2_44xx.h" 38#include "cm2_44xx.h"
39#include "prm44xx.h" 39#include "prm44xx.h"
@@ -3963,6 +3963,10 @@ static struct omap_hwmod_class omap44xx_smartreflex_hwmod_class = {
3963}; 3963};
3964 3964
3965/* smartreflex_core */ 3965/* smartreflex_core */
3966static struct omap_smartreflex_dev_attr smartreflex_core_dev_attr = {
3967 .sensor_voltdm_name = "core",
3968};
3969
3966static struct omap_hwmod omap44xx_smartreflex_core_hwmod; 3970static struct omap_hwmod omap44xx_smartreflex_core_hwmod;
3967static struct omap_hwmod_irq_info omap44xx_smartreflex_core_irqs[] = { 3971static struct omap_hwmod_irq_info omap44xx_smartreflex_core_irqs[] = {
3968 { .irq = 19 + OMAP44XX_IRQ_GIC_START }, 3972 { .irq = 19 + OMAP44XX_IRQ_GIC_START },
@@ -3999,7 +4003,6 @@ static struct omap_hwmod omap44xx_smartreflex_core_hwmod = {
3999 .mpu_irqs = omap44xx_smartreflex_core_irqs, 4003 .mpu_irqs = omap44xx_smartreflex_core_irqs,
4000 4004
4001 .main_clk = "smartreflex_core_fck", 4005 .main_clk = "smartreflex_core_fck",
4002 .vdd_name = "core",
4003 .prcm = { 4006 .prcm = {
4004 .omap4 = { 4007 .omap4 = {
4005 .clkctrl_offs = OMAP4_CM_ALWON_SR_CORE_CLKCTRL_OFFSET, 4008 .clkctrl_offs = OMAP4_CM_ALWON_SR_CORE_CLKCTRL_OFFSET,
@@ -4009,9 +4012,14 @@ static struct omap_hwmod omap44xx_smartreflex_core_hwmod = {
4009 }, 4012 },
4010 .slaves = omap44xx_smartreflex_core_slaves, 4013 .slaves = omap44xx_smartreflex_core_slaves,
4011 .slaves_cnt = ARRAY_SIZE(omap44xx_smartreflex_core_slaves), 4014 .slaves_cnt = ARRAY_SIZE(omap44xx_smartreflex_core_slaves),
4015 .dev_attr = &smartreflex_core_dev_attr,
4012}; 4016};
4013 4017
4014/* smartreflex_iva */ 4018/* smartreflex_iva */
4019static struct omap_smartreflex_dev_attr smartreflex_iva_dev_attr = {
4020 .sensor_voltdm_name = "iva",
4021};
4022
4015static struct omap_hwmod omap44xx_smartreflex_iva_hwmod; 4023static struct omap_hwmod omap44xx_smartreflex_iva_hwmod;
4016static struct omap_hwmod_irq_info omap44xx_smartreflex_iva_irqs[] = { 4024static struct omap_hwmod_irq_info omap44xx_smartreflex_iva_irqs[] = {
4017 { .irq = 102 + OMAP44XX_IRQ_GIC_START }, 4025 { .irq = 102 + OMAP44XX_IRQ_GIC_START },
@@ -4047,7 +4055,6 @@ static struct omap_hwmod omap44xx_smartreflex_iva_hwmod = {
4047 .clkdm_name = "l4_ao_clkdm", 4055 .clkdm_name = "l4_ao_clkdm",
4048 .mpu_irqs = omap44xx_smartreflex_iva_irqs, 4056 .mpu_irqs = omap44xx_smartreflex_iva_irqs,
4049 .main_clk = "smartreflex_iva_fck", 4057 .main_clk = "smartreflex_iva_fck",
4050 .vdd_name = "iva",
4051 .prcm = { 4058 .prcm = {
4052 .omap4 = { 4059 .omap4 = {
4053 .clkctrl_offs = OMAP4_CM_ALWON_SR_IVA_CLKCTRL_OFFSET, 4060 .clkctrl_offs = OMAP4_CM_ALWON_SR_IVA_CLKCTRL_OFFSET,
@@ -4057,9 +4064,14 @@ static struct omap_hwmod omap44xx_smartreflex_iva_hwmod = {
4057 }, 4064 },
4058 .slaves = omap44xx_smartreflex_iva_slaves, 4065 .slaves = omap44xx_smartreflex_iva_slaves,
4059 .slaves_cnt = ARRAY_SIZE(omap44xx_smartreflex_iva_slaves), 4066 .slaves_cnt = ARRAY_SIZE(omap44xx_smartreflex_iva_slaves),
4067 .dev_attr = &smartreflex_iva_dev_attr,
4060}; 4068};
4061 4069
4062/* smartreflex_mpu */ 4070/* smartreflex_mpu */
4071static struct omap_smartreflex_dev_attr smartreflex_mpu_dev_attr = {
4072 .sensor_voltdm_name = "mpu",
4073};
4074
4063static struct omap_hwmod omap44xx_smartreflex_mpu_hwmod; 4075static struct omap_hwmod omap44xx_smartreflex_mpu_hwmod;
4064static struct omap_hwmod_irq_info omap44xx_smartreflex_mpu_irqs[] = { 4076static struct omap_hwmod_irq_info omap44xx_smartreflex_mpu_irqs[] = {
4065 { .irq = 18 + OMAP44XX_IRQ_GIC_START }, 4077 { .irq = 18 + OMAP44XX_IRQ_GIC_START },
@@ -4095,7 +4107,6 @@ static struct omap_hwmod omap44xx_smartreflex_mpu_hwmod = {
4095 .clkdm_name = "l4_ao_clkdm", 4107 .clkdm_name = "l4_ao_clkdm",
4096 .mpu_irqs = omap44xx_smartreflex_mpu_irqs, 4108 .mpu_irqs = omap44xx_smartreflex_mpu_irqs,
4097 .main_clk = "smartreflex_mpu_fck", 4109 .main_clk = "smartreflex_mpu_fck",
4098 .vdd_name = "mpu",
4099 .prcm = { 4110 .prcm = {
4100 .omap4 = { 4111 .omap4 = {
4101 .clkctrl_offs = OMAP4_CM_ALWON_SR_MPU_CLKCTRL_OFFSET, 4112 .clkctrl_offs = OMAP4_CM_ALWON_SR_MPU_CLKCTRL_OFFSET,
@@ -4105,6 +4116,7 @@ static struct omap_hwmod omap44xx_smartreflex_mpu_hwmod = {
4105 }, 4116 },
4106 .slaves = omap44xx_smartreflex_mpu_slaves, 4117 .slaves = omap44xx_smartreflex_mpu_slaves,
4107 .slaves_cnt = ARRAY_SIZE(omap44xx_smartreflex_mpu_slaves), 4118 .slaves_cnt = ARRAY_SIZE(omap44xx_smartreflex_mpu_slaves),
4119 .dev_attr = &smartreflex_mpu_dev_attr,
4108}; 4120};
4109 4121
4110/* 4122/*
diff --git a/arch/arm/mach-omap2/opp2420_data.c b/arch/arm/mach-omap2/opp2420_data.c
index e6dda694fd5..5037e76e4e2 100644
--- a/arch/arm/mach-omap2/opp2420_data.c
+++ b/arch/arm/mach-omap2/opp2420_data.c
@@ -28,6 +28,8 @@
28 * http://repository.maemo.org/pool/diablo/free/k/kernel-source-diablo/ 28 * http://repository.maemo.org/pool/diablo/free/k/kernel-source-diablo/
29 */ 29 */
30 30
31#include <plat/hardware.h>
32
31#include "opp2xxx.h" 33#include "opp2xxx.h"
32#include "sdrc.h" 34#include "sdrc.h"
33#include "clock.h" 35#include "clock.h"
diff --git a/arch/arm/mach-omap2/opp2430_data.c b/arch/arm/mach-omap2/opp2430_data.c
index 1b9596ae201..750805c528d 100644
--- a/arch/arm/mach-omap2/opp2430_data.c
+++ b/arch/arm/mach-omap2/opp2430_data.c
@@ -26,6 +26,8 @@
26 * This is technically part of the OMAP2xxx clock code. 26 * This is technically part of the OMAP2xxx clock code.
27 */ 27 */
28 28
29#include <plat/hardware.h>
30
29#include "opp2xxx.h" 31#include "opp2xxx.h"
30#include "sdrc.h" 32#include "sdrc.h"
31#include "clock.h" 33#include "clock.h"
diff --git a/arch/arm/mach-omap2/pm-debug.c b/arch/arm/mach-omap2/pm-debug.c
index 4411163e012..814bcd90159 100644
--- a/arch/arm/mach-omap2/pm-debug.c
+++ b/arch/arm/mach-omap2/pm-debug.c
@@ -220,8 +220,8 @@ static int __init pwrdms_setup(struct powerdomain *pwrdm, void *dir)
220 return 0; 220 return 0;
221 221
222 d = debugfs_create_dir(pwrdm->name, (struct dentry *)dir); 222 d = debugfs_create_dir(pwrdm->name, (struct dentry *)dir);
223 223 if (!(IS_ERR_OR_NULL(d)))
224 (void) debugfs_create_file("suspend", S_IRUGO|S_IWUSR, d, 224 (void) debugfs_create_file("suspend", S_IRUGO|S_IWUSR, d,
225 (void *)pwrdm, &pwrdm_suspend_fops); 225 (void *)pwrdm, &pwrdm_suspend_fops);
226 226
227 return 0; 227 return 0;
@@ -264,7 +264,7 @@ static int __init pm_dbg_init(void)
264 return 0; 264 return 0;
265 265
266 d = debugfs_create_dir("pm_debug", NULL); 266 d = debugfs_create_dir("pm_debug", NULL);
267 if (IS_ERR(d)) 267 if (IS_ERR_OR_NULL(d))
268 return PTR_ERR(d); 268 return PTR_ERR(d);
269 269
270 (void) debugfs_create_file("count", S_IRUGO, 270 (void) debugfs_create_file("count", S_IRUGO,
diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
index 5a65dd04aa3..a7bdec69a2b 100644
--- a/arch/arm/mach-omap2/pm.c
+++ b/arch/arm/mach-omap2/pm.c
@@ -15,11 +15,13 @@
15#include <linux/err.h> 15#include <linux/err.h>
16#include <linux/opp.h> 16#include <linux/opp.h>
17#include <linux/export.h> 17#include <linux/export.h>
18#include <linux/suspend.h>
18 19
19#include <plat/omap-pm.h> 20#include <plat/omap-pm.h>
20#include <plat/omap_device.h> 21#include <plat/omap_device.h>
21#include "common.h" 22#include "common.h"
22 23
24#include "prcm-common.h"
23#include "voltage.h" 25#include "voltage.h"
24#include "powerdomain.h" 26#include "powerdomain.h"
25#include "clockdomain.h" 27#include "clockdomain.h"
@@ -28,7 +30,13 @@
28 30
29static struct omap_device_pm_latency *pm_lats; 31static struct omap_device_pm_latency *pm_lats;
30 32
31static int _init_omap_device(char *name) 33/*
34 * omap_pm_suspend: points to a function that does the SoC-specific
35 * suspend work
36 */
37int (*omap_pm_suspend)(void);
38
39static int __init _init_omap_device(char *name)
32{ 40{
33 struct omap_hwmod *oh; 41 struct omap_hwmod *oh;
34 struct platform_device *pdev; 42 struct platform_device *pdev;
@@ -49,7 +57,7 @@ static int _init_omap_device(char *name)
49/* 57/*
50 * Build omap_devices for processors and bus. 58 * Build omap_devices for processors and bus.
51 */ 59 */
52static void omap2_init_processor_devices(void) 60static void __init omap2_init_processor_devices(void)
53{ 61{
54 _init_omap_device("mpu"); 62 _init_omap_device("mpu");
55 if (omap3_has_iva()) 63 if (omap3_has_iva())
@@ -68,32 +76,41 @@ static void omap2_init_processor_devices(void)
68#define FORCEWAKEUP_SWITCH 0 76#define FORCEWAKEUP_SWITCH 0
69#define LOWPOWERSTATE_SWITCH 1 77#define LOWPOWERSTATE_SWITCH 1
70 78
79int __init omap_pm_clkdms_setup(struct clockdomain *clkdm, void *unused)
80{
81 if (clkdm->flags & CLKDM_CAN_ENABLE_AUTO)
82 clkdm_allow_idle(clkdm);
83 else if (clkdm->flags & CLKDM_CAN_FORCE_SLEEP &&
84 atomic_read(&clkdm->usecount) == 0)
85 clkdm_sleep(clkdm);
86 return 0;
87}
88
71/* 89/*
72 * This sets pwrdm state (other than mpu & core. Currently only ON & 90 * This sets pwrdm state (other than mpu & core. Currently only ON &
73 * RET are supported. 91 * RET are supported.
74 */ 92 */
75int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state) 93int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 pwrst)
76{ 94{
77 u32 cur_state; 95 u8 curr_pwrst, next_pwrst;
78 int sleep_switch = -1; 96 int sleep_switch = -1, ret = 0, hwsup = 0;
79 int ret = 0;
80 int hwsup = 0;
81 97
82 if (pwrdm == NULL || IS_ERR(pwrdm)) 98 if (!pwrdm || IS_ERR(pwrdm))
83 return -EINVAL; 99 return -EINVAL;
84 100
85 while (!(pwrdm->pwrsts & (1 << state))) { 101 while (!(pwrdm->pwrsts & (1 << pwrst))) {
86 if (state == PWRDM_POWER_OFF) 102 if (pwrst == PWRDM_POWER_OFF)
87 return ret; 103 return ret;
88 state--; 104 pwrst--;
89 } 105 }
90 106
91 cur_state = pwrdm_read_next_pwrst(pwrdm); 107 next_pwrst = pwrdm_read_next_pwrst(pwrdm);
92 if (cur_state == state) 108 if (next_pwrst == pwrst)
93 return ret; 109 return ret;
94 110
95 if (pwrdm_read_pwrst(pwrdm) < PWRDM_POWER_ON) { 111 curr_pwrst = pwrdm_read_pwrst(pwrdm);
96 if ((pwrdm_read_pwrst(pwrdm) > state) && 112 if (curr_pwrst < PWRDM_POWER_ON) {
113 if ((curr_pwrst > pwrst) &&
97 (pwrdm->flags & PWRDM_HAS_LOWPOWERSTATECHANGE)) { 114 (pwrdm->flags & PWRDM_HAS_LOWPOWERSTATECHANGE)) {
98 sleep_switch = LOWPOWERSTATE_SWITCH; 115 sleep_switch = LOWPOWERSTATE_SWITCH;
99 } else { 116 } else {
@@ -103,12 +120,10 @@ int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state)
103 } 120 }
104 } 121 }
105 122
106 ret = pwrdm_set_next_pwrst(pwrdm, state); 123 ret = pwrdm_set_next_pwrst(pwrdm, pwrst);
107 if (ret) { 124 if (ret)
108 pr_err("%s: unable to set state of powerdomain: %s\n", 125 pr_err("%s: unable to set power state of powerdomain: %s\n",
109 __func__, pwrdm->name); 126 __func__, pwrdm->name);
110 goto err;
111 }
112 127
113 switch (sleep_switch) { 128 switch (sleep_switch) {
114 case FORCEWAKEUP_SWITCH: 129 case FORCEWAKEUP_SWITCH:
@@ -119,16 +134,16 @@ int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state)
119 break; 134 break;
120 case LOWPOWERSTATE_SWITCH: 135 case LOWPOWERSTATE_SWITCH:
121 pwrdm_set_lowpwrstchange(pwrdm); 136 pwrdm_set_lowpwrstchange(pwrdm);
137 pwrdm_wait_transition(pwrdm);
138 pwrdm_state_switch(pwrdm);
122 break; 139 break;
123 default:
124 return ret;
125 } 140 }
126 141
127 pwrdm_state_switch(pwrdm);
128err:
129 return ret; 142 return ret;
130} 143}
131 144
145
146
132/* 147/*
133 * This API is to be called during init to set the various voltage 148 * This API is to be called during init to set the various voltage
134 * domains to the voltage as per the opp table. Typically we boot up 149 * domains to the voltage as per the opp table. Typically we boot up
@@ -199,6 +214,56 @@ exit:
199 return -EINVAL; 214 return -EINVAL;
200} 215}
201 216
217#ifdef CONFIG_SUSPEND
218static int omap_pm_enter(suspend_state_t suspend_state)
219{
220 int ret = 0;
221
222 if (!omap_pm_suspend)
223 return -ENOENT; /* XXX doublecheck */
224
225 switch (suspend_state) {
226 case PM_SUSPEND_STANDBY:
227 case PM_SUSPEND_MEM:
228 ret = omap_pm_suspend();
229 break;
230 default:
231 ret = -EINVAL;
232 }
233
234 return ret;
235}
236
237static int omap_pm_begin(suspend_state_t state)
238{
239 disable_hlt();
240 if (cpu_is_omap34xx())
241 omap_prcm_irq_prepare();
242 return 0;
243}
244
245static void omap_pm_end(void)
246{
247 enable_hlt();
248 return;
249}
250
251static void omap_pm_finish(void)
252{
253 if (cpu_is_omap34xx())
254 omap_prcm_irq_complete();
255}
256
257static const struct platform_suspend_ops omap_pm_ops = {
258 .begin = omap_pm_begin,
259 .end = omap_pm_end,
260 .enter = omap_pm_enter,
261 .finish = omap_pm_finish,
262 .valid = suspend_valid_only_mem,
263};
264
265#endif /* CONFIG_SUSPEND */
266
202static void __init omap3_init_voltages(void) 267static void __init omap3_init_voltages(void)
203{ 268{
204 if (!cpu_is_omap34xx()) 269 if (!cpu_is_omap34xx())
@@ -230,6 +295,14 @@ postcore_initcall(omap2_common_pm_init);
230 295
231static int __init omap2_common_pm_late_init(void) 296static int __init omap2_common_pm_late_init(void)
232{ 297{
298 /*
299 * In the case of DT, the PMIC and SR initialization will be done using
300 * a completely different mechanism.
301 * Disable this part if a DT blob is available.
302 */
303 if (of_have_populated_dt())
304 return 0;
305
233 /* Init the voltage layer */ 306 /* Init the voltage layer */
234 omap_pmic_late_init(); 307 omap_pmic_late_init();
235 omap_voltage_late_init(); 308 omap_voltage_late_init();
@@ -241,6 +314,10 @@ static int __init omap2_common_pm_late_init(void)
241 /* Smartreflex device init */ 314 /* Smartreflex device init */
242 omap_devinit_smartreflex(); 315 omap_devinit_smartreflex();
243 316
317#ifdef CONFIG_SUSPEND
318 suspend_set_ops(&omap_pm_ops);
319#endif
320
244 return 0; 321 return 0;
245} 322}
246late_initcall(omap2_common_pm_late_init); 323late_initcall(omap2_common_pm_late_init);
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
index b737b11e449..36fa90b6ece 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -18,10 +18,11 @@
18extern void *omap3_secure_ram_storage; 18extern void *omap3_secure_ram_storage;
19extern void omap3_pm_off_mode_enable(int); 19extern void omap3_pm_off_mode_enable(int);
20extern void omap_sram_idle(void); 20extern void omap_sram_idle(void);
21extern int omap3_can_sleep(void);
22extern int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state); 21extern int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state);
23extern int omap3_idle_init(void); 22extern int omap3_idle_init(void);
24extern int omap4_idle_init(void); 23extern int omap4_idle_init(void);
24extern int omap_pm_clkdms_setup(struct clockdomain *clkdm, void *unused);
25extern int (*omap_pm_suspend)(void);
25 26
26#if defined(CONFIG_PM_OPP) 27#if defined(CONFIG_PM_OPP)
27extern int omap3_opp_init(void); 28extern int omap3_opp_init(void);
diff --git a/arch/arm/mach-omap2/pm24xx.c b/arch/arm/mach-omap2/pm24xx.c
index 730bb009587..95442b69ae2 100644
--- a/arch/arm/mach-omap2/pm24xx.c
+++ b/arch/arm/mach-omap2/pm24xx.c
@@ -26,7 +26,6 @@
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/delay.h> 27#include <linux/delay.h>
28#include <linux/clk.h> 28#include <linux/clk.h>
29#include <linux/io.h>
30#include <linux/irq.h> 29#include <linux/irq.h>
31#include <linux/time.h> 30#include <linux/time.h>
32#include <linux/gpio.h> 31#include <linux/gpio.h>
@@ -36,12 +35,13 @@
36#include <asm/mach-types.h> 35#include <asm/mach-types.h>
37#include <asm/system_misc.h> 36#include <asm/system_misc.h>
38 37
39#include <mach/irqs.h>
40#include <plat/clock.h> 38#include <plat/clock.h>
41#include <plat/sram.h> 39#include <plat/sram.h>
42#include <plat/dma.h> 40#include <plat/dma.h>
43#include <plat/board.h> 41#include <plat/board.h>
44 42
43#include <mach/irqs.h>
44
45#include "common.h" 45#include "common.h"
46#include "prm2xxx_3xxx.h" 46#include "prm2xxx_3xxx.h"
47#include "prm-regbits-24xx.h" 47#include "prm-regbits-24xx.h"
@@ -50,23 +50,9 @@
50#include "sdrc.h" 50#include "sdrc.h"
51#include "pm.h" 51#include "pm.h"
52#include "control.h" 52#include "control.h"
53
54#include "powerdomain.h" 53#include "powerdomain.h"
55#include "clockdomain.h" 54#include "clockdomain.h"
56 55
57#ifdef CONFIG_SUSPEND
58static suspend_state_t suspend_state = PM_SUSPEND_ON;
59static inline bool is_suspending(void)
60{
61 return (suspend_state != PM_SUSPEND_ON);
62}
63#else
64static inline bool is_suspending(void)
65{
66 return false;
67}
68#endif
69
70static void (*omap2_sram_idle)(void); 56static void (*omap2_sram_idle)(void);
71static void (*omap2_sram_suspend)(u32 dllctrl, void __iomem *sdrc_dlla_ctrl, 57static void (*omap2_sram_suspend)(u32 dllctrl, void __iomem *sdrc_dlla_ctrl,
72 void __iomem *sdrc_power); 58 void __iomem *sdrc_power);
@@ -86,7 +72,7 @@ static int omap2_fclks_active(void)
86 return (f1 | f2) ? 1 : 0; 72 return (f1 | f2) ? 1 : 0;
87} 73}
88 74
89static void omap2_enter_full_retention(void) 75static int omap2_enter_full_retention(void)
90{ 76{
91 u32 l; 77 u32 l;
92 78
@@ -149,6 +135,8 @@ no_sleep:
149 135
150 /* Mask future PRCM-to-MPU interrupts */ 136 /* Mask future PRCM-to-MPU interrupts */
151 omap2_prm_write_mod_reg(0x0, OCP_MOD, OMAP2_PRCM_IRQSTATUS_MPU_OFFSET); 137 omap2_prm_write_mod_reg(0x0, OCP_MOD, OMAP2_PRCM_IRQSTATUS_MPU_OFFSET);
138
139 return 0;
152} 140}
153 141
154static int omap2_i2c_active(void) 142static int omap2_i2c_active(void)
@@ -227,7 +215,6 @@ static int omap2_can_sleep(void)
227 215
228static void omap2_pm_idle(void) 216static void omap2_pm_idle(void)
229{ 217{
230 local_irq_disable();
231 local_fiq_disable(); 218 local_fiq_disable();
232 219
233 if (!omap2_can_sleep()) { 220 if (!omap2_can_sleep()) {
@@ -244,78 +231,6 @@ static void omap2_pm_idle(void)
244 231
245out: 232out:
246 local_fiq_enable(); 233 local_fiq_enable();
247 local_irq_enable();
248}
249
250#ifdef CONFIG_SUSPEND
251static int omap2_pm_begin(suspend_state_t state)
252{
253 disable_hlt();
254 suspend_state = state;
255 return 0;
256}
257
258static int omap2_pm_suspend(void)
259{
260 u32 wken_wkup, mir1;
261
262 wken_wkup = omap2_prm_read_mod_reg(WKUP_MOD, PM_WKEN);
263 wken_wkup &= ~OMAP24XX_EN_GPT1_MASK;
264 omap2_prm_write_mod_reg(wken_wkup, WKUP_MOD, PM_WKEN);
265
266 /* Mask GPT1 */
267 mir1 = omap_readl(0x480fe0a4);
268 omap_writel(1 << 5, 0x480fe0ac);
269
270 omap2_enter_full_retention();
271
272 omap_writel(mir1, 0x480fe0a4);
273 omap2_prm_write_mod_reg(wken_wkup, WKUP_MOD, PM_WKEN);
274
275 return 0;
276}
277
278static int omap2_pm_enter(suspend_state_t state)
279{
280 int ret = 0;
281
282 switch (state) {
283 case PM_SUSPEND_STANDBY:
284 case PM_SUSPEND_MEM:
285 ret = omap2_pm_suspend();
286 break;
287 default:
288 ret = -EINVAL;
289 }
290
291 return ret;
292}
293
294static void omap2_pm_end(void)
295{
296 suspend_state = PM_SUSPEND_ON;
297 enable_hlt();
298}
299
300static const struct platform_suspend_ops omap_pm_ops = {
301 .begin = omap2_pm_begin,
302 .enter = omap2_pm_enter,
303 .end = omap2_pm_end,
304 .valid = suspend_valid_only_mem,
305};
306#else
307static const struct platform_suspend_ops __initdata omap_pm_ops;
308#endif /* CONFIG_SUSPEND */
309
310/* XXX This function should be shareable between OMAP2xxx and OMAP3 */
311static int __init clkdms_setup(struct clockdomain *clkdm, void *unused)
312{
313 if (clkdm->flags & CLKDM_CAN_ENABLE_AUTO)
314 clkdm_allow_idle(clkdm);
315 else if (clkdm->flags & CLKDM_CAN_FORCE_SLEEP &&
316 atomic_read(&clkdm->usecount) == 0)
317 clkdm_sleep(clkdm);
318 return 0;
319} 234}
320 235
321static void __init prcm_setup_regs(void) 236static void __init prcm_setup_regs(void)
@@ -359,9 +274,13 @@ static void __init prcm_setup_regs(void)
359 clkdm_sleep(gfx_clkdm); 274 clkdm_sleep(gfx_clkdm);
360 275
361 /* Enable hardware-supervised idle for all clkdms */ 276 /* Enable hardware-supervised idle for all clkdms */
362 clkdm_for_each(clkdms_setup, NULL); 277 clkdm_for_each(omap_pm_clkdms_setup, NULL);
363 clkdm_add_wkdep(mpu_clkdm, wkup_clkdm); 278 clkdm_add_wkdep(mpu_clkdm, wkup_clkdm);
364 279
280#ifdef CONFIG_SUSPEND
281 omap_pm_suspend = omap2_enter_full_retention;
282#endif
283
365 /* REVISIT: Configure number of 32 kHz clock cycles for sys_clk 284 /* REVISIT: Configure number of 32 kHz clock cycles for sys_clk
366 * stabilisation */ 285 * stabilisation */
367 omap2_prm_write_mod_reg(15 << OMAP_SETUP_TIME_SHIFT, OMAP24XX_GR_MOD, 286 omap2_prm_write_mod_reg(15 << OMAP_SETUP_TIME_SHIFT, OMAP24XX_GR_MOD,
@@ -462,8 +381,7 @@ static int __init omap2_pm_init(void)
462 omap24xx_cpu_suspend_sz); 381 omap24xx_cpu_suspend_sz);
463 } 382 }
464 383
465 suspend_set_ops(&omap_pm_ops); 384 arm_pm_idle = omap2_pm_idle;
466 pm_idle = omap2_pm_idle;
467 385
468 return 0; 386 return 0;
469} 387}
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 64d95e69bc5..238defc6f6d 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -51,10 +51,6 @@
51#include "sdrc.h" 51#include "sdrc.h"
52#include "control.h" 52#include "control.h"
53 53
54#ifdef CONFIG_SUSPEND
55static suspend_state_t suspend_state = PM_SUSPEND_ON;
56#endif
57
58/* pm34xx errata defined in pm.h */ 54/* pm34xx errata defined in pm.h */
59u16 pm34xx_errata; 55u16 pm34xx_errata;
60 56
@@ -76,16 +72,6 @@ static struct powerdomain *mpu_pwrdm, *neon_pwrdm;
76static struct powerdomain *core_pwrdm, *per_pwrdm; 72static struct powerdomain *core_pwrdm, *per_pwrdm;
77static struct powerdomain *cam_pwrdm; 73static struct powerdomain *cam_pwrdm;
78 74
79static inline void omap3_per_save_context(void)
80{
81 omap_gpio_save_context();
82}
83
84static inline void omap3_per_restore_context(void)
85{
86 omap_gpio_restore_context();
87}
88
89static void omap3_enable_io_chain(void) 75static void omap3_enable_io_chain(void)
90{ 76{
91 int timeout = 0; 77 int timeout = 0;
@@ -291,11 +277,6 @@ void omap_sram_idle(void)
291 int core_prev_state, per_prev_state; 277 int core_prev_state, per_prev_state;
292 u32 sdrc_pwr = 0; 278 u32 sdrc_pwr = 0;
293 279
294 pwrdm_clear_all_prev_pwrst(mpu_pwrdm);
295 pwrdm_clear_all_prev_pwrst(neon_pwrdm);
296 pwrdm_clear_all_prev_pwrst(core_pwrdm);
297 pwrdm_clear_all_prev_pwrst(per_pwrdm);
298
299 mpu_next_state = pwrdm_read_next_pwrst(mpu_pwrdm); 280 mpu_next_state = pwrdm_read_next_pwrst(mpu_pwrdm);
300 switch (mpu_next_state) { 281 switch (mpu_next_state) {
301 case PWRDM_POWER_ON: 282 case PWRDM_POWER_ON:
@@ -333,8 +314,6 @@ void omap_sram_idle(void)
333 if (per_next_state < PWRDM_POWER_ON) { 314 if (per_next_state < PWRDM_POWER_ON) {
334 per_going_off = (per_next_state == PWRDM_POWER_OFF) ? 1 : 0; 315 per_going_off = (per_next_state == PWRDM_POWER_OFF) ? 1 : 0;
335 omap2_gpio_prepare_for_idle(per_going_off); 316 omap2_gpio_prepare_for_idle(per_going_off);
336 if (per_next_state == PWRDM_POWER_OFF)
337 omap3_per_save_context();
338 } 317 }
339 318
340 /* CORE */ 319 /* CORE */
@@ -400,8 +379,6 @@ void omap_sram_idle(void)
400 if (per_next_state < PWRDM_POWER_ON) { 379 if (per_next_state < PWRDM_POWER_ON) {
401 per_prev_state = pwrdm_read_prev_pwrst(per_pwrdm); 380 per_prev_state = pwrdm_read_prev_pwrst(per_pwrdm);
402 omap2_gpio_resume_after_idle(); 381 omap2_gpio_resume_after_idle();
403 if (per_prev_state == PWRDM_POWER_OFF)
404 omap3_per_restore_context();
405 } 382 }
406 383
407 /* Disable IO-PAD and IO-CHAIN wakeup */ 384 /* Disable IO-PAD and IO-CHAIN wakeup */
@@ -419,10 +396,9 @@ void omap_sram_idle(void)
419 396
420static void omap3_pm_idle(void) 397static void omap3_pm_idle(void)
421{ 398{
422 local_irq_disable();
423 local_fiq_disable(); 399 local_fiq_disable();
424 400
425 if (omap_irq_pending() || need_resched()) 401 if (omap_irq_pending())
426 goto out; 402 goto out;
427 403
428 trace_power_start(POWER_CSTATE, 1, smp_processor_id()); 404 trace_power_start(POWER_CSTATE, 1, smp_processor_id());
@@ -435,7 +411,6 @@ static void omap3_pm_idle(void)
435 411
436out: 412out:
437 local_fiq_enable(); 413 local_fiq_enable();
438 local_irq_enable();
439} 414}
440 415
441#ifdef CONFIG_SUSPEND 416#ifdef CONFIG_SUSPEND
@@ -480,50 +455,6 @@ restore:
480 return ret; 455 return ret;
481} 456}
482 457
483static int omap3_pm_enter(suspend_state_t unused)
484{
485 int ret = 0;
486
487 switch (suspend_state) {
488 case PM_SUSPEND_STANDBY:
489 case PM_SUSPEND_MEM:
490 ret = omap3_pm_suspend();
491 break;
492 default:
493 ret = -EINVAL;
494 }
495
496 return ret;
497}
498
499/* Hooks to enable / disable UART interrupts during suspend */
500static int omap3_pm_begin(suspend_state_t state)
501{
502 disable_hlt();
503 suspend_state = state;
504 omap_prcm_irq_prepare();
505 return 0;
506}
507
508static void omap3_pm_end(void)
509{
510 suspend_state = PM_SUSPEND_ON;
511 enable_hlt();
512 return;
513}
514
515static void omap3_pm_finish(void)
516{
517 omap_prcm_irq_complete();
518}
519
520static const struct platform_suspend_ops omap_pm_ops = {
521 .begin = omap3_pm_begin,
522 .end = omap3_pm_end,
523 .enter = omap3_pm_enter,
524 .finish = omap3_pm_finish,
525 .valid = suspend_valid_only_mem,
526};
527#endif /* CONFIG_SUSPEND */ 458#endif /* CONFIG_SUSPEND */
528 459
529 460
@@ -744,21 +675,6 @@ static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused)
744} 675}
745 676
746/* 677/*
747 * Enable hw supervised mode for all clockdomains if it's
748 * supported. Initiate sleep transition for other clockdomains, if
749 * they are not used
750 */
751static int __init clkdms_setup(struct clockdomain *clkdm, void *unused)
752{
753 if (clkdm->flags & CLKDM_CAN_ENABLE_AUTO)
754 clkdm_allow_idle(clkdm);
755 else if (clkdm->flags & CLKDM_CAN_FORCE_SLEEP &&
756 atomic_read(&clkdm->usecount) == 0)
757 clkdm_sleep(clkdm);
758 return 0;
759}
760
761/*
762 * Push functions to SRAM 678 * Push functions to SRAM
763 * 679 *
764 * The minimum set of functions is pushed to SRAM for execution: 680 * The minimum set of functions is pushed to SRAM for execution:
@@ -827,7 +743,7 @@ static int __init omap3_pm_init(void)
827 goto err2; 743 goto err2;
828 } 744 }
829 745
830 (void) clkdm_for_each(clkdms_setup, NULL); 746 (void) clkdm_for_each(omap_pm_clkdms_setup, NULL);
831 747
832 mpu_pwrdm = pwrdm_lookup("mpu_pwrdm"); 748 mpu_pwrdm = pwrdm_lookup("mpu_pwrdm");
833 if (mpu_pwrdm == NULL) { 749 if (mpu_pwrdm == NULL) {
@@ -846,10 +762,10 @@ static int __init omap3_pm_init(void)
846 core_clkdm = clkdm_lookup("core_clkdm"); 762 core_clkdm = clkdm_lookup("core_clkdm");
847 763
848#ifdef CONFIG_SUSPEND 764#ifdef CONFIG_SUSPEND
849 suspend_set_ops(&omap_pm_ops); 765 omap_pm_suspend = omap3_pm_suspend;
850#endif /* CONFIG_SUSPEND */ 766#endif
851 767
852 pm_idle = omap3_pm_idle; 768 arm_pm_idle = omap3_pm_idle;
853 omap3_idle_init(); 769 omap3_idle_init();
854 770
855 /* 771 /*
diff --git a/arch/arm/mach-omap2/pm44xx.c b/arch/arm/mach-omap2/pm44xx.c
index a73e3255417..9ccaadc2cf0 100644
--- a/arch/arm/mach-omap2/pm44xx.c
+++ b/arch/arm/mach-omap2/pm44xx.c
@@ -84,59 +84,8 @@ static int omap4_pm_suspend(void)
84 84
85 return 0; 85 return 0;
86} 86}
87
88static int omap4_pm_enter(suspend_state_t suspend_state)
89{
90 int ret = 0;
91
92 switch (suspend_state) {
93 case PM_SUSPEND_STANDBY:
94 case PM_SUSPEND_MEM:
95 ret = omap4_pm_suspend();
96 break;
97 default:
98 ret = -EINVAL;
99 }
100
101 return ret;
102}
103
104static int omap4_pm_begin(suspend_state_t state)
105{
106 disable_hlt();
107 return 0;
108}
109
110static void omap4_pm_end(void)
111{
112 enable_hlt();
113 return;
114}
115
116static const struct platform_suspend_ops omap_pm_ops = {
117 .begin = omap4_pm_begin,
118 .end = omap4_pm_end,
119 .enter = omap4_pm_enter,
120 .valid = suspend_valid_only_mem,
121};
122#endif /* CONFIG_SUSPEND */ 87#endif /* CONFIG_SUSPEND */
123 88
124/*
125 * Enable hardware supervised mode for all clockdomains if it's
126 * supported. Initiate sleep transition for other clockdomains, if
127 * they are not used
128 */
129static int __init clkdms_setup(struct clockdomain *clkdm, void *unused)
130{
131 if (clkdm->flags & CLKDM_CAN_ENABLE_AUTO)
132 clkdm_allow_idle(clkdm);
133 else if (clkdm->flags & CLKDM_CAN_FORCE_SLEEP &&
134 atomic_read(&clkdm->usecount) == 0)
135 clkdm_sleep(clkdm);
136 return 0;
137}
138
139
140static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused) 89static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused)
141{ 90{
142 struct power_state *pwrst; 91 struct power_state *pwrst;
@@ -174,18 +123,16 @@ static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused)
174 * omap_default_idle - OMAP4 default ilde routine.' 123 * omap_default_idle - OMAP4 default ilde routine.'
175 * 124 *
176 * Implements OMAP4 memory, IO ordering requirements which can't be addressed 125 * Implements OMAP4 memory, IO ordering requirements which can't be addressed
177 * with default arch_idle() hook. Used by all CPUs with !CONFIG_CPUIDLE and 126 * with default cpu_do_idle() hook. Used by all CPUs with !CONFIG_CPUIDLE and
178 * by secondary CPU with CONFIG_CPUIDLE. 127 * by secondary CPU with CONFIG_CPUIDLE.
179 */ 128 */
180static void omap_default_idle(void) 129static void omap_default_idle(void)
181{ 130{
182 local_irq_disable();
183 local_fiq_disable(); 131 local_fiq_disable();
184 132
185 omap_do_wfi(); 133 omap_do_wfi();
186 134
187 local_fiq_enable(); 135 local_fiq_enable();
188 local_irq_enable();
189} 136}
190 137
191/** 138/**
@@ -250,14 +197,14 @@ static int __init omap4_pm_init(void)
250 goto err2; 197 goto err2;
251 } 198 }
252 199
253 (void) clkdm_for_each(clkdms_setup, NULL); 200 (void) clkdm_for_each(omap_pm_clkdms_setup, NULL);
254 201
255#ifdef CONFIG_SUSPEND 202#ifdef CONFIG_SUSPEND
256 suspend_set_ops(&omap_pm_ops); 203 omap_pm_suspend = omap4_pm_suspend;
257#endif /* CONFIG_SUSPEND */ 204#endif
258 205
259 /* Overwrite the default arch_idle() */ 206 /* Overwrite the default cpu_do_idle() */
260 pm_idle = omap_default_idle; 207 arm_pm_idle = omap_default_idle;
261 208
262 omap4_idle_init(); 209 omap4_idle_init();
263 210
diff --git a/arch/arm/mach-omap2/powerdomain-common.c b/arch/arm/mach-omap2/powerdomain-common.c
index f97afff68d6..c0aeabfcf00 100644
--- a/arch/arm/mach-omap2/powerdomain-common.c
+++ b/arch/arm/mach-omap2/powerdomain-common.c
@@ -13,6 +13,7 @@
13 13
14#include <linux/errno.h> 14#include <linux/errno.h>
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/bug.h>
16#include "pm.h" 17#include "pm.h"
17#include "cm.h" 18#include "cm.h"
18#include "cm-regbits-34xx.h" 19#include "cm-regbits-34xx.h"
diff --git a/arch/arm/mach-omap2/powerdomain2xxx_3xxx.c b/arch/arm/mach-omap2/powerdomain2xxx_3xxx.c
index 6a17e4ca1d7..0f0a9f1592f 100644
--- a/arch/arm/mach-omap2/powerdomain2xxx_3xxx.c
+++ b/arch/arm/mach-omap2/powerdomain2xxx_3xxx.c
@@ -15,6 +15,7 @@
15#include <linux/io.h> 15#include <linux/io.h>
16#include <linux/errno.h> 16#include <linux/errno.h>
17#include <linux/delay.h> 17#include <linux/delay.h>
18#include <linux/bug.h>
18 19
19#include <plat/prcm.h> 20#include <plat/prcm.h>
20 21
diff --git a/arch/arm/mach-omap2/powerdomain44xx.c b/arch/arm/mach-omap2/powerdomain44xx.c
index a7880af4b3d..601325b852a 100644
--- a/arch/arm/mach-omap2/powerdomain44xx.c
+++ b/arch/arm/mach-omap2/powerdomain44xx.c
@@ -15,6 +15,7 @@
15#include <linux/io.h> 15#include <linux/io.h>
16#include <linux/errno.h> 16#include <linux/errno.h>
17#include <linux/delay.h> 17#include <linux/delay.h>
18#include <linux/bug.h>
18 19
19#include "powerdomain.h" 20#include "powerdomain.h"
20#include <plat/prcm.h> 21#include <plat/prcm.h>
diff --git a/arch/arm/mach-omap2/powerdomains3xxx_data.c b/arch/arm/mach-omap2/powerdomains3xxx_data.c
index 8ef26daeed6..b7ea468eea3 100644
--- a/arch/arm/mach-omap2/powerdomains3xxx_data.c
+++ b/arch/arm/mach-omap2/powerdomains3xxx_data.c
@@ -13,6 +13,7 @@
13 13
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/bug.h>
16 17
17#include <plat/cpu.h> 18#include <plat/cpu.h>
18 19
diff --git a/arch/arm/mach-omap2/prcm_mpu44xx.c b/arch/arm/mach-omap2/prcm_mpu44xx.c
index ca669b50f39..928dbd4f20e 100644
--- a/arch/arm/mach-omap2/prcm_mpu44xx.c
+++ b/arch/arm/mach-omap2/prcm_mpu44xx.c
@@ -15,8 +15,8 @@
15#include <linux/err.h> 15#include <linux/err.h>
16#include <linux/io.h> 16#include <linux/io.h>
17 17
18#include "iomap.h"
18#include "common.h" 19#include "common.h"
19
20#include "prcm_mpu44xx.h" 20#include "prcm_mpu44xx.h"
21#include "cm-regbits-44xx.h" 21#include "cm-regbits-44xx.h"
22 22
diff --git a/arch/arm/mach-omap2/prm44xx.c b/arch/arm/mach-omap2/prm44xx.c
index a1d6154dc12..eac623c7c3d 100644
--- a/arch/arm/mach-omap2/prm44xx.c
+++ b/arch/arm/mach-omap2/prm44xx.c
@@ -17,11 +17,12 @@
17#include <linux/err.h> 17#include <linux/err.h>
18#include <linux/io.h> 18#include <linux/io.h>
19 19
20#include "common.h"
21#include <plat/cpu.h> 20#include <plat/cpu.h>
22#include <plat/irqs.h> 21#include <plat/irqs.h>
23#include <plat/prcm.h> 22#include <plat/prcm.h>
24 23
24#include "iomap.h"
25#include "common.h"
25#include "vp.h" 26#include "vp.h"
26#include "prm44xx.h" 27#include "prm44xx.h"
27#include "prm-regbits-44xx.h" 28#include "prm-regbits-44xx.h"
diff --git a/arch/arm/mach-omap2/prm_common.c b/arch/arm/mach-omap2/prm_common.c
index 860118ab43e..873b51d494e 100644
--- a/arch/arm/mach-omap2/prm_common.c
+++ b/arch/arm/mach-omap2/prm_common.c
@@ -24,7 +24,6 @@
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26 26
27#include <mach/system.h>
28#include <plat/common.h> 27#include <plat/common.h>
29#include <plat/prcm.h> 28#include <plat/prcm.h>
30#include <plat/irqs.h> 29#include <plat/irqs.h>
diff --git a/arch/arm/mach-omap2/prminst44xx.c b/arch/arm/mach-omap2/prminst44xx.c
index f6de5bc6b12..9b3898a3ac9 100644
--- a/arch/arm/mach-omap2/prminst44xx.c
+++ b/arch/arm/mach-omap2/prminst44xx.c
@@ -16,8 +16,8 @@
16#include <linux/err.h> 16#include <linux/err.h>
17#include <linux/io.h> 17#include <linux/io.h>
18 18
19#include "iomap.h"
19#include "common.h" 20#include "common.h"
20
21#include "prm44xx.h" 21#include "prm44xx.h"
22#include "prminst44xx.h" 22#include "prminst44xx.h"
23#include "prm-regbits-44xx.h" 23#include "prm-regbits-44xx.h"
diff --git a/arch/arm/mach-omap2/sdram-nokia.c b/arch/arm/mach-omap2/sdram-nokia.c
index 7479d7ea137..845c4fd2b12 100644
--- a/arch/arm/mach-omap2/sdram-nokia.c
+++ b/arch/arm/mach-omap2/sdram-nokia.c
@@ -17,7 +17,6 @@
17#include <linux/err.h> 17#include <linux/err.h>
18#include <linux/io.h> 18#include <linux/io.h>
19 19
20#include <plat/io.h>
21#include "common.h" 20#include "common.h"
22#include <plat/clock.h> 21#include <plat/clock.h>
23#include <plat/sdrc.h> 22#include <plat/sdrc.h>
diff --git a/arch/arm/mach-omap2/sdrc2xxx.c b/arch/arm/mach-omap2/sdrc2xxx.c
index 791a63cdceb..1133bb2f632 100644
--- a/arch/arm/mach-omap2/sdrc2xxx.c
+++ b/arch/arm/mach-omap2/sdrc2xxx.c
@@ -24,13 +24,15 @@
24#include <linux/clk.h> 24#include <linux/clk.h>
25#include <linux/io.h> 25#include <linux/io.h>
26 26
27#include "common.h" 27#include <plat/hardware.h>
28#include <plat/clock.h> 28#include <plat/clock.h>
29#include <plat/sram.h> 29#include <plat/sram.h>
30#include <plat/sdrc.h>
30 31
32#include "iomap.h"
33#include "common.h"
31#include "prm2xxx_3xxx.h" 34#include "prm2xxx_3xxx.h"
32#include "clock.h" 35#include "clock.h"
33#include <plat/sdrc.h>
34#include "sdrc.h" 36#include "sdrc.h"
35 37
36/* Memory timing, DLL mode flags */ 38/* Memory timing, DLL mode flags */
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index f590afc1f67..0cdd359a128 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -54,11 +54,9 @@
54 54
55struct omap_uart_state { 55struct omap_uart_state {
56 int num; 56 int num;
57 int can_sleep;
58 57
59 struct list_head node; 58 struct list_head node;
60 struct omap_hwmod *oh; 59 struct omap_hwmod *oh;
61 struct platform_device *pdev;
62}; 60};
63 61
64static LIST_HEAD(uart_list); 62static LIST_HEAD(uart_list);
@@ -381,8 +379,6 @@ void __init omap_serial_init_port(struct omap_board_data *bdata,
381 379
382 oh->mux = omap_hwmod_mux_init(bdata->pads, bdata->pads_cnt); 380 oh->mux = omap_hwmod_mux_init(bdata->pads, bdata->pads_cnt);
383 381
384 uart->pdev = pdev;
385
386 oh->dev_attr = uart; 382 oh->dev_attr = uart;
387 383
388 if (((cpu_is_omap34xx() || cpu_is_omap44xx()) && bdata->pads) 384 if (((cpu_is_omap34xx() || cpu_is_omap44xx()) && bdata->pads)
diff --git a/arch/arm/mach-omap2/sleep24xx.S b/arch/arm/mach-omap2/sleep24xx.S
index b5071a47ec3..d4bf904d84a 100644
--- a/arch/arm/mach-omap2/sleep24xx.S
+++ b/arch/arm/mach-omap2/sleep24xx.S
@@ -27,7 +27,6 @@
27 27
28#include <linux/linkage.h> 28#include <linux/linkage.h>
29#include <asm/assembler.h> 29#include <asm/assembler.h>
30#include <mach/io.h>
31 30
32#include <plat/omap24xx.h> 31#include <plat/omap24xx.h>
33 32
diff --git a/arch/arm/mach-omap2/sleep34xx.S b/arch/arm/mach-omap2/sleep34xx.S
index f2ea1bd1c69..1f62f23673f 100644
--- a/arch/arm/mach-omap2/sleep34xx.S
+++ b/arch/arm/mach-omap2/sleep34xx.S
@@ -23,10 +23,13 @@
23 * MA 02111-1307 USA 23 * MA 02111-1307 USA
24 */ 24 */
25#include <linux/linkage.h> 25#include <linux/linkage.h>
26
26#include <asm/assembler.h> 27#include <asm/assembler.h>
28
29#include <plat/hardware.h>
27#include <plat/sram.h> 30#include <plat/sram.h>
28#include <mach/io.h>
29 31
32#include "iomap.h"
30#include "cm2xxx_3xxx.h" 33#include "cm2xxx_3xxx.h"
31#include "prm2xxx_3xxx.h" 34#include "prm2xxx_3xxx.h"
32#include "sdrc.h" 35#include "sdrc.h"
diff --git a/arch/arm/mach-omap2/smartreflex-class3.c b/arch/arm/mach-omap2/smartreflex-class3.c
index 53d9d0a5b39..955566eefac 100644
--- a/arch/arm/mach-omap2/smartreflex-class3.c
+++ b/arch/arm/mach-omap2/smartreflex-class3.c
@@ -29,6 +29,7 @@ static int sr_class3_enable(struct voltagedomain *voltdm)
29 29
30static int sr_class3_disable(struct voltagedomain *voltdm, int is_volt_reset) 30static int sr_class3_disable(struct voltagedomain *voltdm, int is_volt_reset)
31{ 31{
32 sr_disable_errgen(voltdm);
32 omap_vp_disable(voltdm); 33 omap_vp_disable(voltdm);
33 sr_disable(voltdm); 34 sr_disable(voltdm);
34 if (is_volt_reset) 35 if (is_volt_reset)
diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c
index 7e755bb0ffc..008fbd7b935 100644
--- a/arch/arm/mach-omap2/smartreflex.c
+++ b/arch/arm/mach-omap2/smartreflex.c
@@ -36,6 +36,12 @@
36#define SR_DISABLE_TIMEOUT 200 36#define SR_DISABLE_TIMEOUT 200
37 37
38struct omap_sr { 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;
39 int srid; 45 int srid;
40 int ip_type; 46 int ip_type;
41 int nvalue_count; 47 int nvalue_count;
@@ -49,13 +55,7 @@ struct omap_sr {
49 u32 senp_avgweight; 55 u32 senp_avgweight;
50 u32 senp_mod; 56 u32 senp_mod;
51 u32 senn_mod; 57 u32 senn_mod;
52 unsigned int irq;
53 void __iomem *base; 58 void __iomem *base;
54 struct platform_device *pdev;
55 struct list_head node;
56 struct omap_sr_nvalue_table *nvalue_table;
57 struct voltagedomain *voltdm;
58 struct dentry *dbg_dir;
59}; 59};
60 60
61/* sr_list contains all the instances of smartreflex module */ 61/* sr_list contains all the instances of smartreflex module */
@@ -74,10 +74,6 @@ static inline void sr_modify_reg(struct omap_sr *sr, unsigned offset, u32 mask,
74 u32 value) 74 u32 value)
75{ 75{
76 u32 reg_val; 76 u32 reg_val;
77 u32 errconfig_offs = 0, errconfig_mask = 0;
78
79 reg_val = __raw_readl(sr->base + offset);
80 reg_val &= ~mask;
81 77
82 /* 78 /*
83 * Smartreflex error config register is special as it contains 79 * Smartreflex error config register is special as it contains
@@ -88,16 +84,15 @@ static inline void sr_modify_reg(struct omap_sr *sr, unsigned offset, u32 mask,
88 * if they are currently set, but does allow the caller to write 84 * if they are currently set, but does allow the caller to write
89 * those bits. 85 * those bits.
90 */ 86 */
91 if (sr->ip_type == SR_TYPE_V1) { 87 if (sr->ip_type == SR_TYPE_V1 && offset == ERRCONFIG_V1)
92 errconfig_offs = ERRCONFIG_V1; 88 mask |= ERRCONFIG_STATUS_V1_MASK;
93 errconfig_mask = ERRCONFIG_STATUS_V1_MASK; 89 else if (sr->ip_type == SR_TYPE_V2 && offset == ERRCONFIG_V2)
94 } else if (sr->ip_type == SR_TYPE_V2) { 90 mask |= ERRCONFIG_VPBOUNDINTST_V2;
95 errconfig_offs = ERRCONFIG_V2; 91
96 errconfig_mask = ERRCONFIG_VPBOUNDINTST_V2; 92 reg_val = __raw_readl(sr->base + offset);
97 } 93 reg_val &= ~mask;
98 94
99 if (offset == errconfig_offs) 95 value &= mask;
100 reg_val &= ~errconfig_mask;
101 96
102 reg_val |= value; 97 reg_val |= value;
103 98
@@ -128,21 +123,28 @@ static struct omap_sr *_sr_lookup(struct voltagedomain *voltdm)
128 123
129static irqreturn_t sr_interrupt(int irq, void *data) 124static irqreturn_t sr_interrupt(int irq, void *data)
130{ 125{
131 struct omap_sr *sr_info = (struct omap_sr *)data; 126 struct omap_sr *sr_info = data;
132 u32 status = 0; 127 u32 status = 0;
133 128
134 if (sr_info->ip_type == SR_TYPE_V1) { 129 switch (sr_info->ip_type) {
130 case SR_TYPE_V1:
135 /* Read the status bits */ 131 /* Read the status bits */
136 status = sr_read_reg(sr_info, ERRCONFIG_V1); 132 status = sr_read_reg(sr_info, ERRCONFIG_V1);
137 133
138 /* Clear them by writing back */ 134 /* Clear them by writing back */
139 sr_write_reg(sr_info, ERRCONFIG_V1, status); 135 sr_write_reg(sr_info, ERRCONFIG_V1, status);
140 } else if (sr_info->ip_type == SR_TYPE_V2) { 136 break;
137 case SR_TYPE_V2:
141 /* Read the status bits */ 138 /* Read the status bits */
142 status = sr_read_reg(sr_info, IRQSTATUS); 139 status = sr_read_reg(sr_info, IRQSTATUS);
143 140
144 /* Clear them by writing back */ 141 /* Clear them by writing back */
145 sr_write_reg(sr_info, IRQSTATUS, status); 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;
146 } 148 }
147 149
148 if (sr_class->notify) 150 if (sr_class->notify)
@@ -166,6 +168,7 @@ static void sr_set_clk_length(struct omap_sr *sr)
166 __func__); 168 __func__);
167 return; 169 return;
168 } 170 }
171
169 sys_clk_speed = clk_get_rate(sys_ck); 172 sys_clk_speed = clk_get_rate(sys_ck);
170 clk_put(sys_ck); 173 clk_put(sys_ck);
171 174
@@ -267,7 +270,7 @@ static int sr_late_init(struct omap_sr *sr_info)
267 goto error; 270 goto error;
268 } 271 }
269 ret = request_irq(sr_info->irq, sr_interrupt, 272 ret = request_irq(sr_info->irq, sr_interrupt,
270 0, name, (void *)sr_info); 273 0, name, sr_info);
271 if (ret) 274 if (ret)
272 goto error; 275 goto error;
273 disable_irq(sr_info->irq); 276 disable_irq(sr_info->irq);
@@ -288,12 +291,15 @@ error:
288 "not function as desired\n", __func__); 291 "not function as desired\n", __func__);
289 kfree(name); 292 kfree(name);
290 kfree(sr_info); 293 kfree(sr_info);
294
291 return ret; 295 return ret;
292} 296}
293 297
294static void sr_v1_disable(struct omap_sr *sr) 298static void sr_v1_disable(struct omap_sr *sr)
295{ 299{
296 int timeout = 0; 300 int timeout = 0;
301 int errconf_val = ERRCONFIG_MCUACCUMINTST | ERRCONFIG_MCUVALIDINTST |
302 ERRCONFIG_MCUBOUNDINTST;
297 303
298 /* Enable MCUDisableAcknowledge interrupt */ 304 /* Enable MCUDisableAcknowledge interrupt */
299 sr_modify_reg(sr, ERRCONFIG_V1, 305 sr_modify_reg(sr, ERRCONFIG_V1,
@@ -302,13 +308,13 @@ static void sr_v1_disable(struct omap_sr *sr)
302 /* SRCONFIG - disable SR */ 308 /* SRCONFIG - disable SR */
303 sr_modify_reg(sr, SRCONFIG, SRCONFIG_SRENABLE, 0x0); 309 sr_modify_reg(sr, SRCONFIG, SRCONFIG_SRENABLE, 0x0);
304 310
305 /* Disable all other SR interrupts and clear the status */ 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;
306 sr_modify_reg(sr, ERRCONFIG_V1, 314 sr_modify_reg(sr, ERRCONFIG_V1,
307 (ERRCONFIG_MCUACCUMINTEN | ERRCONFIG_MCUVALIDINTEN | 315 (ERRCONFIG_MCUACCUMINTEN | ERRCONFIG_MCUVALIDINTEN |
308 ERRCONFIG_MCUBOUNDINTEN | ERRCONFIG_VPBOUNDINTEN_V1), 316 ERRCONFIG_MCUBOUNDINTEN | ERRCONFIG_VPBOUNDINTEN_V1),
309 (ERRCONFIG_MCUACCUMINTST | ERRCONFIG_MCUVALIDINTST | 317 errconf_val);
310 ERRCONFIG_MCUBOUNDINTST |
311 ERRCONFIG_VPBOUNDINTST_V1));
312 318
313 /* 319 /*
314 * Wait for SR to be disabled. 320 * Wait for SR to be disabled.
@@ -337,9 +343,17 @@ static void sr_v2_disable(struct omap_sr *sr)
337 /* SRCONFIG - disable SR */ 343 /* SRCONFIG - disable SR */
338 sr_modify_reg(sr, SRCONFIG, SRCONFIG_SRENABLE, 0x0); 344 sr_modify_reg(sr, SRCONFIG, SRCONFIG_SRENABLE, 0x0);
339 345
340 /* Disable all other SR interrupts and clear the status */ 346 /*
341 sr_modify_reg(sr, ERRCONFIG_V2, ERRCONFIG_VPBOUNDINTEN_V2, 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,
342 ERRCONFIG_VPBOUNDINTST_V2); 353 ERRCONFIG_VPBOUNDINTST_V2);
354 else
355 sr_modify_reg(sr, ERRCONFIG_V2, ERRCONFIG_VPBOUNDINTEN_V2,
356 0x0);
343 sr_write_reg(sr, IRQENABLE_CLR, (IRQENABLE_MCUACCUMINT | 357 sr_write_reg(sr, IRQENABLE_CLR, (IRQENABLE_MCUACCUMINT |
344 IRQENABLE_MCUVALIDINT | 358 IRQENABLE_MCUVALIDINT |
345 IRQENABLE_MCUBOUNDSINT)); 359 IRQENABLE_MCUBOUNDSINT));
@@ -398,15 +412,16 @@ static u32 sr_retrieve_nvalue(struct omap_sr *sr, u32 efuse_offs)
398 */ 412 */
399int sr_configure_errgen(struct voltagedomain *voltdm) 413int sr_configure_errgen(struct voltagedomain *voltdm)
400{ 414{
401 u32 sr_config, sr_errconfig, errconfig_offs, vpboundint_en; 415 u32 sr_config, sr_errconfig, errconfig_offs;
402 u32 vpboundint_st, senp_en = 0, senn_en = 0; 416 u32 vpboundint_en, vpboundint_st;
417 u32 senp_en = 0, senn_en = 0;
403 u8 senp_shift, senn_shift; 418 u8 senp_shift, senn_shift;
404 struct omap_sr *sr = _sr_lookup(voltdm); 419 struct omap_sr *sr = _sr_lookup(voltdm);
405 420
406 if (IS_ERR(sr)) { 421 if (IS_ERR(sr)) {
407 pr_warning("%s: omap_sr struct for sr_%s not found\n", 422 pr_warning("%s: omap_sr struct for sr_%s not found\n",
408 __func__, voltdm->name); 423 __func__, voltdm->name);
409 return -EINVAL; 424 return PTR_ERR(sr);
410 } 425 }
411 426
412 if (!sr->clk_length) 427 if (!sr->clk_length)
@@ -418,20 +433,23 @@ int sr_configure_errgen(struct voltagedomain *voltdm)
418 sr_config = (sr->clk_length << SRCONFIG_SRCLKLENGTH_SHIFT) | 433 sr_config = (sr->clk_length << SRCONFIG_SRCLKLENGTH_SHIFT) |
419 SRCONFIG_SENENABLE | SRCONFIG_ERRGEN_EN; 434 SRCONFIG_SENENABLE | SRCONFIG_ERRGEN_EN;
420 435
421 if (sr->ip_type == SR_TYPE_V1) { 436 switch (sr->ip_type) {
437 case SR_TYPE_V1:
422 sr_config |= SRCONFIG_DELAYCTRL; 438 sr_config |= SRCONFIG_DELAYCTRL;
423 senn_shift = SRCONFIG_SENNENABLE_V1_SHIFT; 439 senn_shift = SRCONFIG_SENNENABLE_V1_SHIFT;
424 senp_shift = SRCONFIG_SENPENABLE_V1_SHIFT; 440 senp_shift = SRCONFIG_SENPENABLE_V1_SHIFT;
425 errconfig_offs = ERRCONFIG_V1; 441 errconfig_offs = ERRCONFIG_V1;
426 vpboundint_en = ERRCONFIG_VPBOUNDINTEN_V1; 442 vpboundint_en = ERRCONFIG_VPBOUNDINTEN_V1;
427 vpboundint_st = ERRCONFIG_VPBOUNDINTST_V1; 443 vpboundint_st = ERRCONFIG_VPBOUNDINTST_V1;
428 } else if (sr->ip_type == SR_TYPE_V2) { 444 break;
445 case SR_TYPE_V2:
429 senn_shift = SRCONFIG_SENNENABLE_V2_SHIFT; 446 senn_shift = SRCONFIG_SENNENABLE_V2_SHIFT;
430 senp_shift = SRCONFIG_SENPENABLE_V2_SHIFT; 447 senp_shift = SRCONFIG_SENPENABLE_V2_SHIFT;
431 errconfig_offs = ERRCONFIG_V2; 448 errconfig_offs = ERRCONFIG_V2;
432 vpboundint_en = ERRCONFIG_VPBOUNDINTEN_V2; 449 vpboundint_en = ERRCONFIG_VPBOUNDINTEN_V2;
433 vpboundint_st = ERRCONFIG_VPBOUNDINTST_V2; 450 vpboundint_st = ERRCONFIG_VPBOUNDINTST_V2;
434 } else { 451 break;
452 default:
435 dev_err(&sr->pdev->dev, "%s: Trying to Configure smartreflex" 453 dev_err(&sr->pdev->dev, "%s: Trying to Configure smartreflex"
436 "module without specifying the ip\n", __func__); 454 "module without specifying the ip\n", __func__);
437 return -EINVAL; 455 return -EINVAL;
@@ -447,8 +465,55 @@ int sr_configure_errgen(struct voltagedomain *voltdm)
447 sr_errconfig); 465 sr_errconfig);
448 466
449 /* Enabling the interrupts if the ERROR module is used */ 467 /* Enabling the interrupts if the ERROR module is used */
450 sr_modify_reg(sr, errconfig_offs, 468 sr_modify_reg(sr, errconfig_offs, (vpboundint_en | vpboundint_st),
451 vpboundint_en, (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);
452 517
453 return 0; 518 return 0;
454} 519}
@@ -475,7 +540,7 @@ int sr_configure_minmax(struct voltagedomain *voltdm)
475 if (IS_ERR(sr)) { 540 if (IS_ERR(sr)) {
476 pr_warning("%s: omap_sr struct for sr_%s not found\n", 541 pr_warning("%s: omap_sr struct for sr_%s not found\n",
477 __func__, voltdm->name); 542 __func__, voltdm->name);
478 return -EINVAL; 543 return PTR_ERR(sr);
479 } 544 }
480 545
481 if (!sr->clk_length) 546 if (!sr->clk_length)
@@ -488,14 +553,17 @@ int sr_configure_minmax(struct voltagedomain *voltdm)
488 SRCONFIG_SENENABLE | 553 SRCONFIG_SENENABLE |
489 (sr->accum_data << SRCONFIG_ACCUMDATA_SHIFT); 554 (sr->accum_data << SRCONFIG_ACCUMDATA_SHIFT);
490 555
491 if (sr->ip_type == SR_TYPE_V1) { 556 switch (sr->ip_type) {
557 case SR_TYPE_V1:
492 sr_config |= SRCONFIG_DELAYCTRL; 558 sr_config |= SRCONFIG_DELAYCTRL;
493 senn_shift = SRCONFIG_SENNENABLE_V1_SHIFT; 559 senn_shift = SRCONFIG_SENNENABLE_V1_SHIFT;
494 senp_shift = SRCONFIG_SENPENABLE_V1_SHIFT; 560 senp_shift = SRCONFIG_SENPENABLE_V1_SHIFT;
495 } else if (sr->ip_type == SR_TYPE_V2) { 561 break;
562 case SR_TYPE_V2:
496 senn_shift = SRCONFIG_SENNENABLE_V2_SHIFT; 563 senn_shift = SRCONFIG_SENNENABLE_V2_SHIFT;
497 senp_shift = SRCONFIG_SENPENABLE_V2_SHIFT; 564 senp_shift = SRCONFIG_SENPENABLE_V2_SHIFT;
498 } else { 565 break;
566 default:
499 dev_err(&sr->pdev->dev, "%s: Trying to Configure smartreflex" 567 dev_err(&sr->pdev->dev, "%s: Trying to Configure smartreflex"
500 "module without specifying the ip\n", __func__); 568 "module without specifying the ip\n", __func__);
501 return -EINVAL; 569 return -EINVAL;
@@ -511,20 +579,27 @@ int sr_configure_minmax(struct voltagedomain *voltdm)
511 * Enabling the interrupts if MINMAXAVG module is used. 579 * Enabling the interrupts if MINMAXAVG module is used.
512 * TODO: check if all the interrupts are mandatory 580 * TODO: check if all the interrupts are mandatory
513 */ 581 */
514 if (sr->ip_type == SR_TYPE_V1) { 582 switch (sr->ip_type) {
583 case SR_TYPE_V1:
515 sr_modify_reg(sr, ERRCONFIG_V1, 584 sr_modify_reg(sr, ERRCONFIG_V1,
516 (ERRCONFIG_MCUACCUMINTEN | ERRCONFIG_MCUVALIDINTEN | 585 (ERRCONFIG_MCUACCUMINTEN | ERRCONFIG_MCUVALIDINTEN |
517 ERRCONFIG_MCUBOUNDINTEN), 586 ERRCONFIG_MCUBOUNDINTEN),
518 (ERRCONFIG_MCUACCUMINTEN | ERRCONFIG_MCUACCUMINTST | 587 (ERRCONFIG_MCUACCUMINTEN | ERRCONFIG_MCUACCUMINTST |
519 ERRCONFIG_MCUVALIDINTEN | ERRCONFIG_MCUVALIDINTST | 588 ERRCONFIG_MCUVALIDINTEN | ERRCONFIG_MCUVALIDINTST |
520 ERRCONFIG_MCUBOUNDINTEN | ERRCONFIG_MCUBOUNDINTST)); 589 ERRCONFIG_MCUBOUNDINTEN | ERRCONFIG_MCUBOUNDINTST));
521 } else if (sr->ip_type == SR_TYPE_V2) { 590 break;
591 case SR_TYPE_V2:
522 sr_write_reg(sr, IRQSTATUS, 592 sr_write_reg(sr, IRQSTATUS,
523 IRQSTATUS_MCUACCUMINT | IRQSTATUS_MCVALIDINT | 593 IRQSTATUS_MCUACCUMINT | IRQSTATUS_MCVALIDINT |
524 IRQSTATUS_MCBOUNDSINT | IRQSTATUS_MCUDISABLEACKINT); 594 IRQSTATUS_MCBOUNDSINT | IRQSTATUS_MCUDISABLEACKINT);
525 sr_write_reg(sr, IRQENABLE_SET, 595 sr_write_reg(sr, IRQENABLE_SET,
526 IRQENABLE_MCUACCUMINT | IRQENABLE_MCUVALIDINT | 596 IRQENABLE_MCUACCUMINT | IRQENABLE_MCUVALIDINT |
527 IRQENABLE_MCUBOUNDSINT | IRQENABLE_MCUDISABLEACKINT); 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;
528 } 603 }
529 604
530 return 0; 605 return 0;
@@ -543,15 +618,15 @@ int sr_configure_minmax(struct voltagedomain *voltdm)
543 */ 618 */
544int sr_enable(struct voltagedomain *voltdm, unsigned long volt) 619int sr_enable(struct voltagedomain *voltdm, unsigned long volt)
545{ 620{
546 u32 nvalue_reciprocal;
547 struct omap_volt_data *volt_data; 621 struct omap_volt_data *volt_data;
548 struct omap_sr *sr = _sr_lookup(voltdm); 622 struct omap_sr *sr = _sr_lookup(voltdm);
623 u32 nvalue_reciprocal;
549 int ret; 624 int ret;
550 625
551 if (IS_ERR(sr)) { 626 if (IS_ERR(sr)) {
552 pr_warning("%s: omap_sr struct for sr_%s not found\n", 627 pr_warning("%s: omap_sr struct for sr_%s not found\n",
553 __func__, voltdm->name); 628 __func__, voltdm->name);
554 return -EINVAL; 629 return PTR_ERR(sr);
555 } 630 }
556 631
557 volt_data = omap_voltage_get_voltdata(sr->voltdm, volt); 632 volt_data = omap_voltage_get_voltdata(sr->voltdm, volt);
@@ -559,7 +634,7 @@ int sr_enable(struct voltagedomain *voltdm, unsigned long volt)
559 if (IS_ERR(volt_data)) { 634 if (IS_ERR(volt_data)) {
560 dev_warn(&sr->pdev->dev, "%s: Unable to get voltage table" 635 dev_warn(&sr->pdev->dev, "%s: Unable to get voltage table"
561 "for nominal voltage %ld\n", __func__, volt); 636 "for nominal voltage %ld\n", __func__, volt);
562 return -ENODATA; 637 return PTR_ERR(volt_data);
563 } 638 }
564 639
565 nvalue_reciprocal = sr_retrieve_nvalue(sr, volt_data->sr_efuse_offs); 640 nvalue_reciprocal = sr_retrieve_nvalue(sr, volt_data->sr_efuse_offs);
@@ -617,10 +692,17 @@ void sr_disable(struct voltagedomain *voltdm)
617 * disable the clocks. 692 * disable the clocks.
618 */ 693 */
619 if (sr_read_reg(sr, SRCONFIG) & SRCONFIG_SRENABLE) { 694 if (sr_read_reg(sr, SRCONFIG) & SRCONFIG_SRENABLE) {
620 if (sr->ip_type == SR_TYPE_V1) 695 switch (sr->ip_type) {
696 case SR_TYPE_V1:
621 sr_v1_disable(sr); 697 sr_v1_disable(sr);
622 else if (sr->ip_type == SR_TYPE_V2) 698 break;
699 case SR_TYPE_V2:
623 sr_v2_disable(sr); 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 }
624 } 706 }
625 707
626 pm_runtime_put_sync_suspend(&sr->pdev->dev); 708 pm_runtime_put_sync_suspend(&sr->pdev->dev);
@@ -779,10 +861,10 @@ void omap_sr_register_pmic(struct omap_sr_pmic_data *pmic_data)
779 sr_pmic_data = pmic_data; 861 sr_pmic_data = pmic_data;
780} 862}
781 863
782/* PM Debug Fs enteries to enable disable smartreflex. */ 864/* PM Debug FS entries to enable and disable smartreflex. */
783static int omap_sr_autocomp_show(void *data, u64 *val) 865static int omap_sr_autocomp_show(void *data, u64 *val)
784{ 866{
785 struct omap_sr *sr_info = (struct omap_sr *) data; 867 struct omap_sr *sr_info = data;
786 868
787 if (!sr_info) { 869 if (!sr_info) {
788 pr_warning("%s: omap_sr struct not found\n", __func__); 870 pr_warning("%s: omap_sr struct not found\n", __func__);
@@ -796,7 +878,7 @@ static int omap_sr_autocomp_show(void *data, u64 *val)
796 878
797static int omap_sr_autocomp_store(void *data, u64 val) 879static int omap_sr_autocomp_store(void *data, u64 val)
798{ 880{
799 struct omap_sr *sr_info = (struct omap_sr *) data; 881 struct omap_sr *sr_info = data;
800 882
801 if (!sr_info) { 883 if (!sr_info) {
802 pr_warning("%s: omap_sr struct not found\n", __func__); 884 pr_warning("%s: omap_sr struct not found\n", __func__);
@@ -804,7 +886,7 @@ static int omap_sr_autocomp_store(void *data, u64 val)
804 } 886 }
805 887
806 /* Sanity check */ 888 /* Sanity check */
807 if (val && (val != 1)) { 889 if (val > 1) {
808 pr_warning("%s: Invalid argument %lld\n", __func__, val); 890 pr_warning("%s: Invalid argument %lld\n", __func__, val);
809 return -EINVAL; 891 return -EINVAL;
810 } 892 }
@@ -821,11 +903,11 @@ static int omap_sr_autocomp_store(void *data, u64 val)
821} 903}
822 904
823DEFINE_SIMPLE_ATTRIBUTE(pm_sr_fops, omap_sr_autocomp_show, 905DEFINE_SIMPLE_ATTRIBUTE(pm_sr_fops, omap_sr_autocomp_show,
824 omap_sr_autocomp_store, "%llu\n"); 906 omap_sr_autocomp_store, "%llu\n");
825 907
826static int __init omap_sr_probe(struct platform_device *pdev) 908static int __init omap_sr_probe(struct platform_device *pdev)
827{ 909{
828 struct omap_sr *sr_info = kzalloc(sizeof(struct omap_sr), GFP_KERNEL); 910 struct omap_sr *sr_info;
829 struct omap_sr_data *pdata = pdev->dev.platform_data; 911 struct omap_sr_data *pdata = pdev->dev.platform_data;
830 struct resource *mem, *irq; 912 struct resource *mem, *irq;
831 struct dentry *nvalue_dir; 913 struct dentry *nvalue_dir;
@@ -833,12 +915,15 @@ static int __init omap_sr_probe(struct platform_device *pdev)
833 int i, ret = 0; 915 int i, ret = 0;
834 char *name; 916 char *name;
835 917
918 sr_info = kzalloc(sizeof(struct omap_sr), GFP_KERNEL);
836 if (!sr_info) { 919 if (!sr_info) {
837 dev_err(&pdev->dev, "%s: unable to allocate sr_info\n", 920 dev_err(&pdev->dev, "%s: unable to allocate sr_info\n",
838 __func__); 921 __func__);
839 return -ENOMEM; 922 return -ENOMEM;
840 } 923 }
841 924
925 platform_set_drvdata(pdev, sr_info);
926
842 if (!pdata) { 927 if (!pdata) {
843 dev_err(&pdev->dev, "%s: platform data missing\n", __func__); 928 dev_err(&pdev->dev, "%s: platform data missing\n", __func__);
844 ret = -EINVAL; 929 ret = -EINVAL;
@@ -904,7 +989,7 @@ static int __init omap_sr_probe(struct platform_device *pdev)
904 dev_info(&pdev->dev, "%s: SmartReflex driver initialized\n", __func__); 989 dev_info(&pdev->dev, "%s: SmartReflex driver initialized\n", __func__);
905 if (!sr_dbg_dir) { 990 if (!sr_dbg_dir) {
906 sr_dbg_dir = debugfs_create_dir("smartreflex", NULL); 991 sr_dbg_dir = debugfs_create_dir("smartreflex", NULL);
907 if (!sr_dbg_dir) { 992 if (IS_ERR_OR_NULL(sr_dbg_dir)) {
908 ret = PTR_ERR(sr_dbg_dir); 993 ret = PTR_ERR(sr_dbg_dir);
909 pr_err("%s:sr debugfs dir creation failed(%d)\n", 994 pr_err("%s:sr debugfs dir creation failed(%d)\n",
910 __func__, ret); 995 __func__, ret);
@@ -921,7 +1006,7 @@ static int __init omap_sr_probe(struct platform_device *pdev)
921 } 1006 }
922 sr_info->dbg_dir = debugfs_create_dir(name, sr_dbg_dir); 1007 sr_info->dbg_dir = debugfs_create_dir(name, sr_dbg_dir);
923 kfree(name); 1008 kfree(name);
924 if (IS_ERR(sr_info->dbg_dir)) { 1009 if (IS_ERR_OR_NULL(sr_info->dbg_dir)) {
925 dev_err(&pdev->dev, "%s: Unable to create debugfs directory\n", 1010 dev_err(&pdev->dev, "%s: Unable to create debugfs directory\n",
926 __func__); 1011 __func__);
927 ret = PTR_ERR(sr_info->dbg_dir); 1012 ret = PTR_ERR(sr_info->dbg_dir);
@@ -938,7 +1023,7 @@ static int __init omap_sr_probe(struct platform_device *pdev)
938 &sr_info->err_minlimit); 1023 &sr_info->err_minlimit);
939 1024
940 nvalue_dir = debugfs_create_dir("nvalue", sr_info->dbg_dir); 1025 nvalue_dir = debugfs_create_dir("nvalue", sr_info->dbg_dir);
941 if (IS_ERR(nvalue_dir)) { 1026 if (IS_ERR_OR_NULL(nvalue_dir)) {
942 dev_err(&pdev->dev, "%s: Unable to create debugfs directory" 1027 dev_err(&pdev->dev, "%s: Unable to create debugfs directory"
943 "for n-values\n", __func__); 1028 "for n-values\n", __func__);
944 ret = PTR_ERR(nvalue_dir); 1029 ret = PTR_ERR(nvalue_dir);
@@ -994,7 +1079,7 @@ static int __devexit omap_sr_remove(struct platform_device *pdev)
994 if (IS_ERR(sr_info)) { 1079 if (IS_ERR(sr_info)) {
995 dev_warn(&pdev->dev, "%s: omap_sr struct not found\n", 1080 dev_warn(&pdev->dev, "%s: omap_sr struct not found\n",
996 __func__); 1081 __func__);
997 return -EINVAL; 1082 return PTR_ERR(sr_info);
998 } 1083 }
999 1084
1000 if (sr_info->autocomp_active) 1085 if (sr_info->autocomp_active)
@@ -1011,8 +1096,32 @@ static int __devexit omap_sr_remove(struct platform_device *pdev)
1011 return 0; 1096 return 0;
1012} 1097}
1013 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
1014static struct platform_driver smartreflex_driver = { 1122static struct platform_driver smartreflex_driver = {
1015 .remove = omap_sr_remove, 1123 .remove = __devexit_p(omap_sr_remove),
1124 .shutdown = __devexit_p(omap_sr_shutdown),
1016 .driver = { 1125 .driver = {
1017 .name = "smartreflex", 1126 .name = "smartreflex",
1018 }, 1127 },
@@ -1042,12 +1151,12 @@ static int __init sr_init(void)
1042 1151
1043 return 0; 1152 return 0;
1044} 1153}
1154late_initcall(sr_init);
1045 1155
1046static void __exit sr_exit(void) 1156static void __exit sr_exit(void)
1047{ 1157{
1048 platform_driver_unregister(&smartreflex_driver); 1158 platform_driver_unregister(&smartreflex_driver);
1049} 1159}
1050late_initcall(sr_init);
1051module_exit(sr_exit); 1160module_exit(sr_exit);
1052 1161
1053MODULE_DESCRIPTION("OMAP Smartreflex Driver"); 1162MODULE_DESCRIPTION("OMAP Smartreflex Driver");
diff --git a/arch/arm/mach-omap2/smartreflex.h b/arch/arm/mach-omap2/smartreflex.h
index 5f35b9e2555..5809141171f 100644
--- a/arch/arm/mach-omap2/smartreflex.h
+++ b/arch/arm/mach-omap2/smartreflex.h
@@ -152,6 +152,15 @@ struct omap_sr_pmic_data {
152 void (*sr_pmic_init) (void); 152 void (*sr_pmic_init) (void);
153}; 153};
154 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
155#ifdef CONFIG_OMAP_SMARTREFLEX 164#ifdef CONFIG_OMAP_SMARTREFLEX
156/* 165/*
157 * The smart reflex driver supports CLASS1 CLASS2 and CLASS3 SR. 166 * The smart reflex driver supports CLASS1 CLASS2 and CLASS3 SR.
@@ -231,6 +240,7 @@ void omap_sr_register_pmic(struct omap_sr_pmic_data *pmic_data);
231int sr_enable(struct voltagedomain *voltdm, unsigned long volt); 240int sr_enable(struct voltagedomain *voltdm, unsigned long volt);
232void sr_disable(struct voltagedomain *voltdm); 241void sr_disable(struct voltagedomain *voltdm);
233int sr_configure_errgen(struct voltagedomain *voltdm); 242int sr_configure_errgen(struct voltagedomain *voltdm);
243int sr_disable_errgen(struct voltagedomain *voltdm);
234int sr_configure_minmax(struct voltagedomain *voltdm); 244int sr_configure_minmax(struct voltagedomain *voltdm);
235 245
236/* API to register the smartreflex class driver with the smartreflex driver */ 246/* API to register the smartreflex class driver with the smartreflex driver */
diff --git a/arch/arm/mach-omap2/sr_device.c b/arch/arm/mach-omap2/sr_device.c
index 9f43fcc05d3..a503e1e8358 100644
--- a/arch/arm/mach-omap2/sr_device.c
+++ b/arch/arm/mach-omap2/sr_device.c
@@ -69,11 +69,12 @@ static void __init sr_set_nvalues(struct omap_volt_data *volt_data,
69 sr_data->nvalue_count = count; 69 sr_data->nvalue_count = count;
70} 70}
71 71
72static int sr_dev_init(struct omap_hwmod *oh, void *user) 72static int __init sr_dev_init(struct omap_hwmod *oh, void *user)
73{ 73{
74 struct omap_sr_data *sr_data; 74 struct omap_sr_data *sr_data;
75 struct platform_device *pdev; 75 struct platform_device *pdev;
76 struct omap_volt_data *volt_data; 76 struct omap_volt_data *volt_data;
77 struct omap_smartreflex_dev_attr *sr_dev_attr;
77 char *name = "smartreflex"; 78 char *name = "smartreflex";
78 static int i; 79 static int i;
79 80
@@ -84,9 +85,11 @@ static int sr_dev_init(struct omap_hwmod *oh, void *user)
84 return -ENOMEM; 85 return -ENOMEM;
85 } 86 }
86 87
87 if (!oh->vdd_name) { 88 sr_dev_attr = (struct omap_smartreflex_dev_attr *)oh->dev_attr;
89 if (!sr_dev_attr || !sr_dev_attr->sensor_voltdm_name) {
88 pr_err("%s: No voltage domain specified for %s." 90 pr_err("%s: No voltage domain specified for %s."
89 "Cannot initialize\n", __func__, oh->name); 91 "Cannot initialize\n", __func__,
92 oh->name);
90 goto exit; 93 goto exit;
91 } 94 }
92 95
@@ -94,10 +97,10 @@ static int sr_dev_init(struct omap_hwmod *oh, void *user)
94 sr_data->senn_mod = 0x1; 97 sr_data->senn_mod = 0x1;
95 sr_data->senp_mod = 0x1; 98 sr_data->senp_mod = 0x1;
96 99
97 sr_data->voltdm = voltdm_lookup(oh->vdd_name); 100 sr_data->voltdm = voltdm_lookup(sr_dev_attr->sensor_voltdm_name);
98 if (IS_ERR(sr_data->voltdm)) { 101 if (IS_ERR(sr_data->voltdm)) {
99 pr_err("%s: Unable to get voltage domain pointer for VDD %s\n", 102 pr_err("%s: Unable to get voltage domain pointer for VDD %s\n",
100 __func__, oh->vdd_name); 103 __func__, sr_dev_attr->sensor_voltdm_name);
101 goto exit; 104 goto exit;
102 } 105 }
103 106
diff --git a/arch/arm/mach-omap2/sram242x.S b/arch/arm/mach-omap2/sram242x.S
index ff9b9dbcb30..ee0bfcc1410 100644
--- a/arch/arm/mach-omap2/sram242x.S
+++ b/arch/arm/mach-omap2/sram242x.S
@@ -29,10 +29,12 @@
29 * These crashes may be intermittent. 29 * These crashes may be intermittent.
30 */ 30 */
31#include <linux/linkage.h> 31#include <linux/linkage.h>
32
32#include <asm/assembler.h> 33#include <asm/assembler.h>
33#include <mach/io.h> 34
34#include <mach/hardware.h> 35#include <mach/hardware.h>
35 36
37#include "iomap.h"
36#include "prm2xxx_3xxx.h" 38#include "prm2xxx_3xxx.h"
37#include "cm2xxx_3xxx.h" 39#include "cm2xxx_3xxx.h"
38#include "sdrc.h" 40#include "sdrc.h"
diff --git a/arch/arm/mach-omap2/sram243x.S b/arch/arm/mach-omap2/sram243x.S
index 76730209fa0..d4d39ef0476 100644
--- a/arch/arm/mach-omap2/sram243x.S
+++ b/arch/arm/mach-omap2/sram243x.S
@@ -29,10 +29,12 @@
29 * These crashes may be intermittent. 29 * These crashes may be intermittent.
30 */ 30 */
31#include <linux/linkage.h> 31#include <linux/linkage.h>
32
32#include <asm/assembler.h> 33#include <asm/assembler.h>
33#include <mach/io.h> 34
34#include <mach/hardware.h> 35#include <mach/hardware.h>
35 36
37#include "iomap.h"
36#include "prm2xxx_3xxx.h" 38#include "prm2xxx_3xxx.h"
37#include "cm2xxx_3xxx.h" 39#include "cm2xxx_3xxx.h"
38#include "sdrc.h" 40#include "sdrc.h"
diff --git a/arch/arm/mach-omap2/sram34xx.S b/arch/arm/mach-omap2/sram34xx.S
index 6f5849aaa7c..df5a21322b0 100644
--- a/arch/arm/mach-omap2/sram34xx.S
+++ b/arch/arm/mach-omap2/sram34xx.S
@@ -26,11 +26,12 @@
26 * MA 02111-1307 USA 26 * MA 02111-1307 USA
27 */ 27 */
28#include <linux/linkage.h> 28#include <linux/linkage.h>
29
29#include <asm/assembler.h> 30#include <asm/assembler.h>
30#include <mach/hardware.h>
31 31
32#include <mach/io.h> 32#include <mach/hardware.h>
33 33
34#include "iomap.h"
34#include "sdrc.h" 35#include "sdrc.h"
35#include "cm2xxx_3xxx.h" 36#include "cm2xxx_3xxx.h"
36 37
diff --git a/arch/arm/mach-omap2/timer-mpu.c b/arch/arm/mach-omap2/timer-mpu.c
deleted file mode 100644
index 31c0ac4cd66..00000000000
--- a/arch/arm/mach-omap2/timer-mpu.c
+++ /dev/null
@@ -1,39 +0,0 @@
1/*
2 * The MPU local timer source file. In OMAP4, both cortex-a9 cores have
3 * own timer in it's MPU domain. These timers will be driving the
4 * linux kernel SMP tick framework when active. These timers are not
5 * part of the wake up domain.
6 *
7 * Copyright (C) 2009 Texas Instruments, Inc.
8 *
9 * Author:
10 * Santosh Shilimkar <santosh.shilimkar@ti.com>
11 *
12 * This file is based on arm realview smp platform file.
13 * Copyright (C) 2002 ARM Ltd.
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#include <linux/init.h>
20#include <linux/smp.h>
21#include <linux/clockchips.h>
22#include <asm/irq.h>
23#include <asm/smp_twd.h>
24#include <asm/localtimer.h>
25
26/*
27 * Setup the local clock events for a CPU.
28 */
29int __cpuinit local_timer_setup(struct clock_event_device *evt)
30{
31 /* Local timers are not supprted on OMAP4430 ES1.0 */
32 if (omap_rev() == OMAP4430_REV_ES1_0)
33 return -ENXIO;
34
35 evt->irq = OMAP44XX_IRQ_LOCALTIMER;
36 twd_timer_setup(evt);
37 return 0;
38}
39
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index 5c9acea9576..c512bac69ec 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -39,7 +39,7 @@
39 39
40#include <asm/mach/time.h> 40#include <asm/mach/time.h>
41#include <plat/dmtimer.h> 41#include <plat/dmtimer.h>
42#include <asm/localtimer.h> 42#include <asm/smp_twd.h>
43#include <asm/sched_clock.h> 43#include <asm/sched_clock.h>
44#include "common.h" 44#include "common.h"
45#include <plat/omap_hwmod.h> 45#include <plat/omap_hwmod.h>
@@ -324,14 +324,26 @@ OMAP_SYS_TIMER(3_secure)
324#endif 324#endif
325 325
326#ifdef CONFIG_ARCH_OMAP4 326#ifdef CONFIG_ARCH_OMAP4
327static void __init omap4_timer_init(void)
328{
329#ifdef CONFIG_LOCAL_TIMERS 327#ifdef CONFIG_LOCAL_TIMERS
330 twd_base = ioremap(OMAP44XX_LOCAL_TWD_BASE, SZ_256); 328static DEFINE_TWD_LOCAL_TIMER(twd_local_timer,
331 BUG_ON(!twd_base); 329 OMAP44XX_LOCAL_TWD_BASE,
330 OMAP44XX_IRQ_LOCALTIMER);
332#endif 331#endif
332
333static void __init omap4_timer_init(void)
334{
333 omap2_gp_clockevent_init(1, OMAP4_CLKEV_SOURCE); 335 omap2_gp_clockevent_init(1, OMAP4_CLKEV_SOURCE);
334 omap2_gp_clocksource_init(2, OMAP4_MPU_SOURCE); 336 omap2_gp_clocksource_init(2, OMAP4_MPU_SOURCE);
337#ifdef CONFIG_LOCAL_TIMERS
338 /* Local timers are not supprted on OMAP4430 ES1.0 */
339 if (omap_rev() != OMAP4430_REV_ES1_0) {
340 int err;
341
342 err = twd_local_timer_register(&twd_local_timer);
343 if (err)
344 pr_err("twd_local_timer_register failed %d\n", err);
345 }
346#endif
335} 347}
336OMAP_SYS_TIMER(4) 348OMAP_SYS_TIMER(4)
337#endif 349#endif
diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c
index 175b7d86d86..84da34f9a7c 100644
--- a/arch/arm/mach-omap2/vc.c
+++ b/arch/arm/mach-omap2/vc.c
@@ -10,6 +10,7 @@
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/delay.h> 11#include <linux/delay.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/bug.h>
13 14
14#include <plat/cpu.h> 15#include <plat/cpu.h>
15 16
diff --git a/arch/arm/mach-omap2/vp.c b/arch/arm/mach-omap2/vp.c
index 0df88820978..f95c1bad9dc 100644
--- a/arch/arm/mach-omap2/vp.c
+++ b/arch/arm/mach-omap2/vp.c
@@ -61,8 +61,8 @@ void __init omap_vp_init(struct voltagedomain *voltdm)
61 vddmin = voltdm->pmic->vp_vddmin; 61 vddmin = voltdm->pmic->vp_vddmin;
62 vddmax = voltdm->pmic->vp_vddmax; 62 vddmax = voltdm->pmic->vp_vddmax;
63 63
64 waittime = ((voltdm->pmic->step_size / voltdm->pmic->slew_rate) * 64 waittime = DIV_ROUND_UP(voltdm->pmic->step_size * sys_clk_rate,
65 sys_clk_rate) / 1000; 65 1000 * voltdm->pmic->slew_rate);
66 vstepmin = voltdm->pmic->vp_vstepmin; 66 vstepmin = voltdm->pmic->vp_vstepmin;
67 vstepmax = voltdm->pmic->vp_vstepmax; 67 vstepmax = voltdm->pmic->vp_vstepmax;
68 68
diff --git a/arch/arm/mach-orion5x/include/mach/entry-macro.S b/arch/arm/mach-orion5x/include/mach/entry-macro.S
index d658992e540..79eb502a1e6 100644
--- a/arch/arm/mach-orion5x/include/mach/entry-macro.S
+++ b/arch/arm/mach-orion5x/include/mach/entry-macro.S
@@ -10,12 +10,6 @@
10 10
11#include <mach/bridge-regs.h> 11#include <mach/bridge-regs.h>
12 12
13 .macro disable_fiq
14 .endm
15
16 .macro arch_ret_to_user, tmp1, tmp2
17 .endm
18
19 .macro get_irqnr_preamble, base, tmp 13 .macro get_irqnr_preamble, base, tmp
20 ldr \base, =MAIN_IRQ_CAUSE 14 ldr \base, =MAIN_IRQ_CAUSE
21 .endm 15 .endm
diff --git a/arch/arm/mach-orion5x/include/mach/system.h b/arch/arm/mach-orion5x/include/mach/system.h
deleted file mode 100644
index 825a2650cef..00000000000
--- a/arch/arm/mach-orion5x/include/mach/system.h
+++ /dev/null
@@ -1,19 +0,0 @@
1/*
2 * arch/arm/mach-orion5x/include/mach/system.h
3 *
4 * Tzachi Perelstein <tzachi@marvell.com>
5 *
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
9 */
10
11#ifndef __ASM_ARCH_SYSTEM_H
12#define __ASM_ARCH_SYSTEM_H
13
14static inline void arch_idle(void)
15{
16 cpu_do_idle();
17}
18
19#endif
diff --git a/arch/arm/mach-orion5x/pci.c b/arch/arm/mach-orion5x/pci.c
index 09a045f0c40..d6a91948e4d 100644
--- a/arch/arm/mach-orion5x/pci.c
+++ b/arch/arm/mach-orion5x/pci.c
@@ -171,13 +171,14 @@ static int __init pcie_setup(struct pci_sys_data *sys)
171 /* 171 /*
172 * IORESOURCE_IO 172 * IORESOURCE_IO
173 */ 173 */
174 sys->io_offset = 0;
174 res[0].name = "PCIe I/O Space"; 175 res[0].name = "PCIe I/O Space";
175 res[0].flags = IORESOURCE_IO; 176 res[0].flags = IORESOURCE_IO;
176 res[0].start = ORION5X_PCIE_IO_BUS_BASE; 177 res[0].start = ORION5X_PCIE_IO_BUS_BASE;
177 res[0].end = res[0].start + ORION5X_PCIE_IO_SIZE - 1; 178 res[0].end = res[0].start + ORION5X_PCIE_IO_SIZE - 1;
178 if (request_resource(&ioport_resource, &res[0])) 179 if (request_resource(&ioport_resource, &res[0]))
179 panic("Request PCIe IO resource failed\n"); 180 panic("Request PCIe IO resource failed\n");
180 pci_add_resource(&sys->resources, &res[0]); 181 pci_add_resource_offset(&sys->resources, &res[0], sys->io_offset);
181 182
182 /* 183 /*
183 * IORESOURCE_MEM 184 * IORESOURCE_MEM
@@ -188,9 +189,7 @@ static int __init pcie_setup(struct pci_sys_data *sys)
188 res[1].end = res[1].start + ORION5X_PCIE_MEM_SIZE - 1; 189 res[1].end = res[1].start + ORION5X_PCIE_MEM_SIZE - 1;
189 if (request_resource(&iomem_resource, &res[1])) 190 if (request_resource(&iomem_resource, &res[1]))
190 panic("Request PCIe Memory resource failed\n"); 191 panic("Request PCIe Memory resource failed\n");
191 pci_add_resource(&sys->resources, &res[1]); 192 pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset);
192
193 sys->io_offset = 0;
194 193
195 return 1; 194 return 1;
196} 195}
@@ -499,13 +498,14 @@ static int __init pci_setup(struct pci_sys_data *sys)
499 /* 498 /*
500 * IORESOURCE_IO 499 * IORESOURCE_IO
501 */ 500 */
501 sys->io_offset = 0;
502 res[0].name = "PCI I/O Space"; 502 res[0].name = "PCI I/O Space";
503 res[0].flags = IORESOURCE_IO; 503 res[0].flags = IORESOURCE_IO;
504 res[0].start = ORION5X_PCI_IO_BUS_BASE; 504 res[0].start = ORION5X_PCI_IO_BUS_BASE;
505 res[0].end = res[0].start + ORION5X_PCI_IO_SIZE - 1; 505 res[0].end = res[0].start + ORION5X_PCI_IO_SIZE - 1;
506 if (request_resource(&ioport_resource, &res[0])) 506 if (request_resource(&ioport_resource, &res[0]))
507 panic("Request PCI IO resource failed\n"); 507 panic("Request PCI IO resource failed\n");
508 pci_add_resource(&sys->resources, &res[0]); 508 pci_add_resource_offset(&sys->resources, &res[0], sys->io_offset);
509 509
510 /* 510 /*
511 * IORESOURCE_MEM 511 * IORESOURCE_MEM
@@ -516,9 +516,7 @@ static int __init pci_setup(struct pci_sys_data *sys)
516 res[1].end = res[1].start + ORION5X_PCI_MEM_SIZE - 1; 516 res[1].end = res[1].start + ORION5X_PCI_MEM_SIZE - 1;
517 if (request_resource(&iomem_resource, &res[1])) 517 if (request_resource(&iomem_resource, &res[1]))
518 panic("Request PCI Memory resource failed\n"); 518 panic("Request PCI Memory resource failed\n");
519 pci_add_resource(&sys->resources, &res[1]); 519 pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset);
520
521 sys->io_offset = 0;
522 520
523 return 1; 521 return 1;
524} 522}
diff --git a/arch/arm/mach-picoxcell/include/mach/entry-macro.S b/arch/arm/mach-picoxcell/include/mach/entry-macro.S
deleted file mode 100644
index 9b505ac00be..00000000000
--- a/arch/arm/mach-picoxcell/include/mach/entry-macro.S
+++ /dev/null
@@ -1,16 +0,0 @@
1/*
2 * entry-macro.S
3 *
4 * Copyright (c) 2011 Picochip Ltd., Jamie Iles
5 *
6 * Low-level IRQ helper macros for picoXcell 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 .macro disable_fiq
13 .endm
14
15 .macro arch_ret_to_user, tmp1, tmp2
16 .endm
diff --git a/arch/arm/mach-picoxcell/include/mach/system.h b/arch/arm/mach-picoxcell/include/mach/system.h
deleted file mode 100644
index 1a5d8cb57df..00000000000
--- a/arch/arm/mach-picoxcell/include/mach/system.h
+++ /dev/null
@@ -1,26 +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 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#ifndef __ASM_ARCH_SYSTEM_H
15#define __ASM_ARCH_SYSTEM_H
16
17static inline void arch_idle(void)
18{
19 /*
20 * This should do all the clock switching and wait for interrupt
21 * tricks.
22 */
23 cpu_do_idle();
24}
25
26#endif /* __ASM_ARCH_SYSTEM_H */
diff --git a/arch/arm/mach-pnx4008/include/mach/entry-macro.S b/arch/arm/mach-pnx4008/include/mach/entry-macro.S
index db7eeebf30d..77a55584671 100644
--- a/arch/arm/mach-pnx4008/include/mach/entry-macro.S
+++ b/arch/arm/mach-pnx4008/include/mach/entry-macro.S
@@ -25,15 +25,9 @@
25#define SIC1_BASE_INT 32 25#define SIC1_BASE_INT 32
26#define SIC2_BASE_INT 64 26#define SIC2_BASE_INT 64
27 27
28 .macro disable_fiq
29 .endm
30
31 .macro get_irqnr_preamble, base, tmp 28 .macro get_irqnr_preamble, base, tmp
32 .endm 29 .endm
33 30
34 .macro arch_ret_to_user, tmp1, tmp2
35 .endm
36
37 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp 31 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
38/* decode the MIC interrupt numbers */ 32/* decode the MIC interrupt numbers */
39 ldr \base, =IO_ADDRESS(PNX4008_INTCTRLMIC_BASE) 33 ldr \base, =IO_ADDRESS(PNX4008_INTCTRLMIC_BASE)
diff --git a/arch/arm/mach-pnx4008/include/mach/system.h b/arch/arm/mach-pnx4008/include/mach/system.h
deleted file mode 100644
index 60cfe718809..00000000000
--- a/arch/arm/mach-pnx4008/include/mach/system.h
+++ /dev/null
@@ -1,29 +0,0 @@
1/*
2 * arch/arm/mach-pnx4008/include/mach/system.h
3 *
4 * Copyright (C) 2003 Philips Semiconductors
5 * Copyright (C) 2005 MontaVista Software, Inc.
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 USA
20 */
21#ifndef __ASM_ARCH_SYSTEM_H
22#define __ASM_ARCH_SYSTEM_H
23
24static void arch_idle(void)
25{
26 cpu_do_idle();
27}
28
29#endif
diff --git a/arch/arm/mach-prima2/include/mach/entry-macro.S b/arch/arm/mach-prima2/include/mach/entry-macro.S
index 1c8a50f102a..86434e7a5be 100644
--- a/arch/arm/mach-prima2/include/mach/entry-macro.S
+++ b/arch/arm/mach-prima2/include/mach/entry-macro.S
@@ -20,10 +20,3 @@
20 cmp \irqnr, #0x40 @ the irq num can't be larger than 0x3f 20 cmp \irqnr, #0x40 @ the irq num can't be larger than 0x3f
21 movges \irqnr, #0 21 movges \irqnr, #0
22 .endm 22 .endm
23
24 .macro disable_fiq
25 .endm
26
27 .macro arch_ret_to_user, tmp1, tmp2
28 .endm
29
diff --git a/arch/arm/mach-prima2/include/mach/system.h b/arch/arm/mach-prima2/include/mach/system.h
deleted file mode 100644
index 2c7d2a9d0c9..00000000000
--- a/arch/arm/mach-prima2/include/mach/system.h
+++ /dev/null
@@ -1,17 +0,0 @@
1/*
2 * arch/arm/mach-prima2/include/mach/system.h
3 *
4 * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company.
5 *
6 * Licensed under GPLv2 or later.
7 */
8
9#ifndef __MACH_SYSTEM_H__
10#define __MACH_SYSTEM_H__
11
12static inline void arch_idle(void)
13{
14 cpu_do_idle();
15}
16
17#endif
diff --git a/arch/arm/mach-pxa/devices.c b/arch/arm/mach-pxa/devices.c
index 5bc13121eac..84f2d7015cf 100644
--- a/arch/arm/mach-pxa/devices.c
+++ b/arch/arm/mach-pxa/devices.c
@@ -406,20 +406,17 @@ static struct resource pxa_rtc_resources[] = {
406 [1] = { 406 [1] = {
407 .start = IRQ_RTC1Hz, 407 .start = IRQ_RTC1Hz,
408 .end = IRQ_RTC1Hz, 408 .end = IRQ_RTC1Hz,
409 .name = "rtc 1Hz",
409 .flags = IORESOURCE_IRQ, 410 .flags = IORESOURCE_IRQ,
410 }, 411 },
411 [2] = { 412 [2] = {
412 .start = IRQ_RTCAlrm, 413 .start = IRQ_RTCAlrm,
413 .end = IRQ_RTCAlrm, 414 .end = IRQ_RTCAlrm,
415 .name = "rtc alarm",
414 .flags = IORESOURCE_IRQ, 416 .flags = IORESOURCE_IRQ,
415 }, 417 },
416}; 418};
417 419
418struct platform_device sa1100_device_rtc = {
419 .name = "sa1100-rtc",
420 .id = -1,
421};
422
423struct platform_device pxa_device_rtc = { 420struct platform_device pxa_device_rtc = {
424 .name = "pxa-rtc", 421 .name = "pxa-rtc",
425 .id = -1, 422 .id = -1,
@@ -427,6 +424,27 @@ struct platform_device pxa_device_rtc = {
427 .resource = pxa_rtc_resources, 424 .resource = pxa_rtc_resources,
428}; 425};
429 426
427static struct resource sa1100_rtc_resources[] = {
428 {
429 .start = IRQ_RTC1Hz,
430 .end = IRQ_RTC1Hz,
431 .name = "rtc 1Hz",
432 .flags = IORESOURCE_IRQ,
433 }, {
434 .start = IRQ_RTCAlrm,
435 .end = IRQ_RTCAlrm,
436 .name = "rtc alarm",
437 .flags = IORESOURCE_IRQ,
438 },
439};
440
441struct platform_device sa1100_device_rtc = {
442 .name = "sa1100-rtc",
443 .id = -1,
444 .num_resources = ARRAY_SIZE(sa1100_rtc_resources),
445 .resource = sa1100_rtc_resources,
446};
447
430static struct resource pxa_ac97_resources[] = { 448static struct resource pxa_ac97_resources[] = {
431 [0] = { 449 [0] = {
432 .start = 0x40500000, 450 .start = 0x40500000,
diff --git a/arch/arm/mach-pxa/hx4700.c b/arch/arm/mach-pxa/hx4700.c
index 208eef1c048..3fa929d4a4f 100644
--- a/arch/arm/mach-pxa/hx4700.c
+++ b/arch/arm/mach-pxa/hx4700.c
@@ -28,7 +28,8 @@
28#include <linux/mtd/physmap.h> 28#include <linux/mtd/physmap.h>
29#include <linux/pda_power.h> 29#include <linux/pda_power.h>
30#include <linux/pwm_backlight.h> 30#include <linux/pwm_backlight.h>
31#include <linux/regulator/bq24022.h> 31#include <linux/regulator/driver.h>
32#include <linux/regulator/gpio-regulator.h>
32#include <linux/regulator/machine.h> 33#include <linux/regulator/machine.h>
33#include <linux/regulator/max1586.h> 34#include <linux/regulator/max1586.h>
34#include <linux/spi/ads7846.h> 35#include <linux/spi/ads7846.h>
@@ -97,9 +98,9 @@ static unsigned long hx4700_pin_config[] __initdata = {
97 98
98 /* BTUART */ 99 /* BTUART */
99 GPIO42_BTUART_RXD, 100 GPIO42_BTUART_RXD,
100 GPIO43_BTUART_TXD, 101 GPIO43_BTUART_TXD_LPM_LOW,
101 GPIO44_BTUART_CTS, 102 GPIO44_BTUART_CTS,
102 GPIO45_BTUART_RTS, 103 GPIO45_BTUART_RTS_LPM_LOW,
103 104
104 /* PWM 1 (Backlight) */ 105 /* PWM 1 (Backlight) */
105 GPIO17_PWM1_OUT, 106 GPIO17_PWM1_OUT,
@@ -245,6 +246,21 @@ static u16 asic3_gpio_config[] = {
245 ASIC3_GPIOD15_nPIOW, 246 ASIC3_GPIOD15_nPIOW,
246}; 247};
247 248
249static struct asic3_led asic3_leds[ASIC3_NUM_LEDS] = {
250 [0] = {
251 .name = "hx4700:amber",
252 .default_trigger = "ds2760-battery.0-charging-blink-full-solid",
253 },
254 [1] = {
255 .name = "hx4700:green",
256 .default_trigger = "unused",
257 },
258 [2] = {
259 .name = "hx4700:blue",
260 .default_trigger = "hx4700-radio",
261 },
262};
263
248static struct resource asic3_resources[] = { 264static struct resource asic3_resources[] = {
249 /* GPIO part */ 265 /* GPIO part */
250 [0] = { 266 [0] = {
@@ -275,6 +291,7 @@ static struct asic3_platform_data asic3_platform_data = {
275 .gpio_config_num = ARRAY_SIZE(asic3_gpio_config), 291 .gpio_config_num = ARRAY_SIZE(asic3_gpio_config),
276 .irq_base = IRQ_BOARD_START, 292 .irq_base = IRQ_BOARD_START,
277 .gpio_base = HX4700_ASIC3_GPIO_BASE, 293 .gpio_base = HX4700_ASIC3_GPIO_BASE,
294 .leds = asic3_leds,
278}; 295};
279 296
280static struct platform_device asic3 = { 297static struct platform_device asic3 = {
@@ -682,14 +699,34 @@ static struct regulator_init_data bq24022_init_data = {
682 .consumer_supplies = bq24022_consumers, 699 .consumer_supplies = bq24022_consumers,
683}; 700};
684 701
685static struct bq24022_mach_info bq24022_info = { 702static struct gpio bq24022_gpios[] = {
686 .gpio_nce = GPIO72_HX4700_BQ24022_nCHARGE_EN, 703 { GPIO96_HX4700_BQ24022_ISET2, GPIOF_OUT_INIT_LOW, "bq24022_iset2" },
687 .gpio_iset2 = GPIO96_HX4700_BQ24022_ISET2, 704};
688 .init_data = &bq24022_init_data, 705
706static struct gpio_regulator_state bq24022_states[] = {
707 { .value = 100000, .gpios = (0 << 0) },
708 { .value = 500000, .gpios = (1 << 0) },
709};
710
711static struct gpio_regulator_config bq24022_info = {
712 .supply_name = "bq24022",
713
714 .enable_gpio = GPIO72_HX4700_BQ24022_nCHARGE_EN,
715 .enable_high = 0,
716 .enabled_at_boot = 0,
717
718 .gpios = bq24022_gpios,
719 .nr_gpios = ARRAY_SIZE(bq24022_gpios),
720
721 .states = bq24022_states,
722 .nr_states = ARRAY_SIZE(bq24022_states),
723
724 .type = REGULATOR_CURRENT,
725 .init_data = &bq24022_init_data,
689}; 726};
690 727
691static struct platform_device bq24022 = { 728static struct platform_device bq24022 = {
692 .name = "bq24022", 729 .name = "gpio-regulator",
693 .id = -1, 730 .id = -1,
694 .dev = { 731 .dev = {
695 .platform_data = &bq24022_info, 732 .platform_data = &bq24022_info,
@@ -705,10 +742,9 @@ static void hx4700_set_vpp(struct platform_device *pdev, int vpp)
705 gpio_set_value(GPIO91_HX4700_FLASH_VPEN, vpp); 742 gpio_set_value(GPIO91_HX4700_FLASH_VPEN, vpp);
706} 743}
707 744
708static struct resource strataflash_resource = { 745static struct resource strataflash_resource[] = {
709 .start = PXA_CS0_PHYS, 746 [0] = DEFINE_RES_MEM(PXA_CS0_PHYS, SZ_64M),
710 .end = PXA_CS0_PHYS + SZ_128M - 1, 747 [1] = DEFINE_RES_MEM(PXA_CS0_PHYS + SZ_64M, SZ_64M),
711 .flags = IORESOURCE_MEM,
712}; 748};
713 749
714static struct physmap_flash_data strataflash_data = { 750static struct physmap_flash_data strataflash_data = {
@@ -719,8 +755,8 @@ static struct physmap_flash_data strataflash_data = {
719static struct platform_device strataflash = { 755static struct platform_device strataflash = {
720 .name = "physmap-flash", 756 .name = "physmap-flash",
721 .id = -1, 757 .id = -1,
722 .resource = &strataflash_resource, 758 .resource = strataflash_resource,
723 .num_resources = 1, 759 .num_resources = ARRAY_SIZE(strataflash_resource),
724 .dev = { 760 .dev = {
725 .platform_data = &strataflash_data, 761 .platform_data = &strataflash_data,
726 }, 762 },
@@ -788,17 +824,6 @@ static struct platform_device audio = {
788 824
789 825
790/* 826/*
791 * PCMCIA
792 */
793
794static struct platform_device pcmcia = {
795 .name = "hx4700-pcmcia",
796 .dev = {
797 .parent = &asic3.dev,
798 },
799};
800
801/*
802 * Platform devices 827 * Platform devices
803 */ 828 */
804 829
@@ -814,7 +839,6 @@ static struct platform_device *devices[] __initdata = {
814 &power_supply, 839 &power_supply,
815 &strataflash, 840 &strataflash,
816 &audio, 841 &audio,
817 &pcmcia,
818}; 842};
819 843
820static struct gpio global_gpios[] = { 844static struct gpio global_gpios[] = {
@@ -830,7 +854,6 @@ static struct gpio global_gpios[] = {
830 { GPIO32_HX4700_RS232_ON, GPIOF_OUT_INIT_HIGH, "RS232_ON" }, 854 { GPIO32_HX4700_RS232_ON, GPIOF_OUT_INIT_HIGH, "RS232_ON" },
831 { GPIO71_HX4700_ASIC3_nRESET, GPIOF_OUT_INIT_HIGH, "ASIC3_nRESET" }, 855 { GPIO71_HX4700_ASIC3_nRESET, GPIOF_OUT_INIT_HIGH, "ASIC3_nRESET" },
832 { GPIO82_HX4700_EUART_RESET, GPIOF_OUT_INIT_HIGH, "EUART_RESET" }, 856 { GPIO82_HX4700_EUART_RESET, GPIOF_OUT_INIT_HIGH, "EUART_RESET" },
833 { GPIO105_HX4700_nIR_ON, GPIOF_OUT_INIT_HIGH, "nIR_EN" },
834}; 857};
835 858
836static void __init hx4700_init(void) 859static void __init hx4700_init(void)
diff --git a/arch/arm/mach-pxa/include/mach/balloon3.h b/arch/arm/mach-pxa/include/mach/balloon3.h
index f02fa1e6ba8..954641e6c8b 100644
--- a/arch/arm/mach-pxa/include/mach/balloon3.h
+++ b/arch/arm/mach-pxa/include/mach/balloon3.h
@@ -174,7 +174,6 @@ enum balloon3_features {
174 174
175#define BALLOON3_AUX_NIRQ PXA_GPIO_TO_IRQ(BALLOON3_GPIO_AUX_NIRQ) 175#define BALLOON3_AUX_NIRQ PXA_GPIO_TO_IRQ(BALLOON3_GPIO_AUX_NIRQ)
176#define BALLOON3_CODEC_IRQ PXA_GPIO_TO_IRQ(BALLOON3_GPIO_CODEC_IRQ) 176#define BALLOON3_CODEC_IRQ PXA_GPIO_TO_IRQ(BALLOON3_GPIO_CODEC_IRQ)
177#define BALLOON3_S0_CD_IRQ PXA_GPIO_TO_IRQ(BALLOON3_GPIO_S0_CD)
178 177
179#define BALLOON3_NR_IRQS (IRQ_BOARD_START + 16) 178#define BALLOON3_NR_IRQS (IRQ_BOARD_START + 16)
180 179
diff --git a/arch/arm/mach-pxa/include/mach/entry-macro.S b/arch/arm/mach-pxa/include/mach/entry-macro.S
deleted file mode 100644
index 260c0c17692..00000000000
--- a/arch/arm/mach-pxa/include/mach/entry-macro.S
+++ /dev/null
@@ -1,15 +0,0 @@
1/*
2 * arch/arm/mach-pxa/include/mach/entry-macro.S
3 *
4 * Low-level IRQ helper macros for PXA-based platforms
5 *
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
9 */
10
11 .macro disable_fiq
12 .endm
13
14 .macro arch_ret_to_user, tmp1, tmp2
15 .endm
diff --git a/arch/arm/mach-pxa/include/mach/mfp-pxa27x.h b/arch/arm/mach-pxa/include/mach/mfp-pxa27x.h
index ec0f0b0b674..a65867209aa 100644
--- a/arch/arm/mach-pxa/include/mach/mfp-pxa27x.h
+++ b/arch/arm/mach-pxa/include/mach/mfp-pxa27x.h
@@ -158,7 +158,9 @@
158#define GPIO44_BTUART_CTS MFP_CFG_IN(GPIO44, AF1) 158#define GPIO44_BTUART_CTS MFP_CFG_IN(GPIO44, AF1)
159#define GPIO42_BTUART_RXD MFP_CFG_IN(GPIO42, AF1) 159#define GPIO42_BTUART_RXD MFP_CFG_IN(GPIO42, AF1)
160#define GPIO45_BTUART_RTS MFP_CFG_OUT(GPIO45, AF2, DRIVE_HIGH) 160#define GPIO45_BTUART_RTS MFP_CFG_OUT(GPIO45, AF2, DRIVE_HIGH)
161#define GPIO45_BTUART_RTS_LPM_LOW MFP_CFG_OUT(GPIO45, AF2, DRIVE_LOW)
161#define GPIO43_BTUART_TXD MFP_CFG_OUT(GPIO43, AF2, DRIVE_HIGH) 162#define GPIO43_BTUART_TXD MFP_CFG_OUT(GPIO43, AF2, DRIVE_HIGH)
163#define GPIO43_BTUART_TXD_LPM_LOW MFP_CFG_OUT(GPIO43, AF2, DRIVE_LOW)
162 164
163/* STUART */ 165/* STUART */
164#define GPIO46_STUART_RXD MFP_CFG_IN(GPIO46, AF2) 166#define GPIO46_STUART_RXD MFP_CFG_IN(GPIO46, AF2)
diff --git a/arch/arm/mach-pxa/include/mach/system.h b/arch/arm/mach-pxa/include/mach/system.h
deleted file mode 100644
index c5afacd3cc0..00000000000
--- a/arch/arm/mach-pxa/include/mach/system.h
+++ /dev/null
@@ -1,15 +0,0 @@
1/*
2 * arch/arm/mach-pxa/include/mach/system.h
3 *
4 * Author: Nicolas Pitre
5 * Created: Jun 15, 2001
6 * Copyright: MontaVista Software Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12static inline void arch_idle(void)
13{
14 cpu_do_idle();
15}
diff --git a/arch/arm/mach-pxa/lubbock.c b/arch/arm/mach-pxa/lubbock.c
index 6ebd276aebe..6bb3f47b1f1 100644
--- a/arch/arm/mach-pxa/lubbock.c
+++ b/arch/arm/mach-pxa/lubbock.c
@@ -223,6 +223,7 @@ static struct resource sa1111_resources[] = {
223 223
224static struct sa1111_platform_data sa1111_info = { 224static struct sa1111_platform_data sa1111_info = {
225 .irq_base = LUBBOCK_SA1111_IRQ_BASE, 225 .irq_base = LUBBOCK_SA1111_IRQ_BASE,
226 .disable_devs = SA1111_DEVID_SAC,
226}; 227};
227 228
228static struct platform_device sa1111_device = { 229static struct platform_device sa1111_device = {
diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c
index d4ab515dc5b..6f4785b347c 100644
--- a/arch/arm/mach-pxa/magician.c
+++ b/arch/arm/mach-pxa/magician.c
@@ -25,7 +25,8 @@
25#include <linux/mtd/physmap.h> 25#include <linux/mtd/physmap.h>
26#include <linux/pda_power.h> 26#include <linux/pda_power.h>
27#include <linux/pwm_backlight.h> 27#include <linux/pwm_backlight.h>
28#include <linux/regulator/bq24022.h> 28#include <linux/regulator/driver.h>
29#include <linux/regulator/gpio-regulator.h>
29#include <linux/regulator/machine.h> 30#include <linux/regulator/machine.h>
30#include <linux/usb/gpio_vbus.h> 31#include <linux/usb/gpio_vbus.h>
31#include <linux/i2c/pxa-i2c.h> 32#include <linux/i2c/pxa-i2c.h>
@@ -597,14 +598,34 @@ static struct regulator_init_data bq24022_init_data = {
597 .consumer_supplies = bq24022_consumers, 598 .consumer_supplies = bq24022_consumers,
598}; 599};
599 600
600static struct bq24022_mach_info bq24022_info = { 601static struct gpio bq24022_gpios[] = {
601 .gpio_nce = GPIO30_MAGICIAN_BQ24022_nCHARGE_EN, 602 { EGPIO_MAGICIAN_BQ24022_ISET2, GPIOF_OUT_INIT_LOW, "bq24022_iset2" },
602 .gpio_iset2 = EGPIO_MAGICIAN_BQ24022_ISET2, 603};
603 .init_data = &bq24022_init_data, 604
605static struct gpio_regulator_state bq24022_states[] = {
606 { .value = 100000, .gpios = (0 << 0) },
607 { .value = 500000, .gpios = (1 << 0) },
608};
609
610static struct gpio_regulator_config bq24022_info = {
611 .supply_name = "bq24022",
612
613 .enable_gpio = GPIO30_MAGICIAN_BQ24022_nCHARGE_EN,
614 .enable_high = 0,
615 .enabled_at_boot = 0,
616
617 .gpios = bq24022_gpios,
618 .nr_gpios = ARRAY_SIZE(bq24022_gpios),
619
620 .states = bq24022_states,
621 .nr_states = ARRAY_SIZE(bq24022_states),
622
623 .type = REGULATOR_CURRENT,
624 .init_data = &bq24022_init_data,
604}; 625};
605 626
606static struct platform_device bq24022 = { 627static struct platform_device bq24022 = {
607 .name = "bq24022", 628 .name = "gpio-regulator",
608 .id = -1, 629 .id = -1,
609 .dev = { 630 .dev = {
610 .platform_data = &bq24022_info, 631 .platform_data = &bq24022_info,
diff --git a/arch/arm/mach-pxa/pxa3xx.c b/arch/arm/mach-pxa/pxa3xx.c
index 3918a672238..1570d457fea 100644
--- a/arch/arm/mach-pxa/pxa3xx.c
+++ b/arch/arm/mach-pxa/pxa3xx.c
@@ -89,6 +89,7 @@ static struct clk_lookup pxa3xx_clkregs[] = {
89 INIT_CLKREG(&clk_pxa3xx_mmc2, "pxa2xx-mci.1", NULL), 89 INIT_CLKREG(&clk_pxa3xx_mmc2, "pxa2xx-mci.1", NULL),
90 INIT_CLKREG(&clk_pxa3xx_smemc, "pxa2xx-pcmcia", NULL), 90 INIT_CLKREG(&clk_pxa3xx_smemc, "pxa2xx-pcmcia", NULL),
91 INIT_CLKREG(&clk_pxa3xx_gpio, "pxa-gpio", NULL), 91 INIT_CLKREG(&clk_pxa3xx_gpio, "pxa-gpio", NULL),
92 INIT_CLKREG(&clk_dummy, "sa1100-rtc", NULL),
92}; 93};
93 94
94#ifdef CONFIG_PM 95#ifdef CONFIG_PM
diff --git a/arch/arm/mach-pxa/pxa95x.c b/arch/arm/mach-pxa/pxa95x.c
index 5ce434b95e8..47601f80e6e 100644
--- a/arch/arm/mach-pxa/pxa95x.c
+++ b/arch/arm/mach-pxa/pxa95x.c
@@ -231,6 +231,7 @@ static struct clk_lookup pxa95x_clkregs[] = {
231 INIT_CLKREG(&clk_pxa95x_pwm0, "pxa27x-pwm.0", NULL), 231 INIT_CLKREG(&clk_pxa95x_pwm0, "pxa27x-pwm.0", NULL),
232 INIT_CLKREG(&clk_pxa95x_pwm1, "pxa27x-pwm.1", NULL), 232 INIT_CLKREG(&clk_pxa95x_pwm1, "pxa27x-pwm.1", NULL),
233 INIT_CLKREG(&clk_pxa95x_gpio, "pxa-gpio", NULL), 233 INIT_CLKREG(&clk_pxa95x_gpio, "pxa-gpio", NULL),
234 INIT_CLKREG(&clk_dummy, "sa1100-rtc", NULL),
234}; 235};
235 236
236void __init pxa95x_init_irq(void) 237void __init pxa95x_init_irq(void)
diff --git a/arch/arm/mach-realview/core.h b/arch/arm/mach-realview/core.h
index 735b57aaf2d..f8f2c0ac4c0 100644
--- a/arch/arm/mach-realview/core.h
+++ b/arch/arm/mach-realview/core.h
@@ -28,21 +28,11 @@
28#include <asm/setup.h> 28#include <asm/setup.h>
29#include <asm/leds.h> 29#include <asm/leds.h>
30 30
31#define AMBA_DEVICE(name,busid,base,plat) \ 31#define APB_DEVICE(name, busid, base, plat) \
32static struct amba_device name##_device = { \ 32static AMBA_APB_DEVICE(name, busid, 0, REALVIEW_##base##_BASE, base##_IRQ, plat)
33 .dev = { \ 33
34 .coherent_dma_mask = ~0, \ 34#define AHB_DEVICE(name, busid, base, plat) \
35 .init_name = busid, \ 35static AMBA_AHB_DEVICE(name, busid, 0, REALVIEW_##base##_BASE, base##_IRQ, plat)
36 .platform_data = plat, \
37 }, \
38 .res = { \
39 .start = REALVIEW_##base##_BASE, \
40 .end = (REALVIEW_##base##_BASE) + SZ_4K - 1, \
41 .flags = IORESOURCE_MEM, \
42 }, \
43 .dma_mask = ~0, \
44 .irq = base##_IRQ, \
45}
46 36
47struct machine_desc; 37struct machine_desc;
48 38
diff --git a/arch/arm/mach-realview/include/mach/entry-macro.S b/arch/arm/mach-realview/include/mach/entry-macro.S
deleted file mode 100644
index e8a5179c265..00000000000
--- a/arch/arm/mach-realview/include/mach/entry-macro.S
+++ /dev/null
@@ -1,16 +0,0 @@
1/*
2 * arch/arm/mach-realview/include/mach/entry-macro.S
3 *
4 * Low-level IRQ helper macros for RealView platforms
5 *
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
9 */
10
11 .macro disable_fiq
12 .endm
13
14 .macro arch_ret_to_user, tmp1, tmp2
15 .endm
16
diff --git a/arch/arm/mach-realview/include/mach/irqs-eb.h b/arch/arm/mach-realview/include/mach/irqs-eb.h
index 204d5378f30..d6b5073692d 100644
--- a/arch/arm/mach-realview/include/mach/irqs-eb.h
+++ b/arch/arm/mach-realview/include/mach/irqs-eb.h
@@ -96,16 +96,19 @@
96#define IRQ_EB11MP_L220_SLAVE (IRQ_EB_GIC_START + 30) 96#define IRQ_EB11MP_L220_SLAVE (IRQ_EB_GIC_START + 30)
97#define IRQ_EB11MP_L220_DECODE (IRQ_EB_GIC_START + 31) 97#define IRQ_EB11MP_L220_DECODE (IRQ_EB_GIC_START + 31)
98 98
99#define IRQ_EB11MP_UART2 -1 99/*
100#define IRQ_EB11MP_UART3 -1 100 * The 11MPcore tile leaves the following unconnected.
101#define IRQ_EB11MP_CLCD -1 101 */
102#define IRQ_EB11MP_DMA -1 102#define IRQ_EB11MP_UART2 0
103#define IRQ_EB11MP_WDOG -1 103#define IRQ_EB11MP_UART3 0
104#define IRQ_EB11MP_GPIO0 -1 104#define IRQ_EB11MP_CLCD 0
105#define IRQ_EB11MP_GPIO1 -1 105#define IRQ_EB11MP_DMA 0
106#define IRQ_EB11MP_GPIO2 -1 106#define IRQ_EB11MP_WDOG 0
107#define IRQ_EB11MP_SCI -1 107#define IRQ_EB11MP_GPIO0 0
108#define IRQ_EB11MP_SSP -1 108#define IRQ_EB11MP_GPIO1 0
109#define IRQ_EB11MP_GPIO2 0
110#define IRQ_EB11MP_SCI 0
111#define IRQ_EB11MP_SSP 0
109 112
110#define NR_GIC_EB11MP 2 113#define NR_GIC_EB11MP 2
111 114
diff --git a/arch/arm/mach-realview/include/mach/irqs-pb1176.h b/arch/arm/mach-realview/include/mach/irqs-pb1176.h
index 5c3c625e3e0..708f84156f2 100644
--- a/arch/arm/mach-realview/include/mach/irqs-pb1176.h
+++ b/arch/arm/mach-realview/include/mach/irqs-pb1176.h
@@ -40,6 +40,7 @@
40#define IRQ_DC1176_L2CC (IRQ_DC1176_GIC_START + 13) 40#define IRQ_DC1176_L2CC (IRQ_DC1176_GIC_START + 13)
41#define IRQ_DC1176_RTC (IRQ_DC1176_GIC_START + 14) 41#define IRQ_DC1176_RTC (IRQ_DC1176_GIC_START + 14)
42#define IRQ_DC1176_CLCD (IRQ_DC1176_GIC_START + 15) /* CLCD controller */ 42#define IRQ_DC1176_CLCD (IRQ_DC1176_GIC_START + 15) /* CLCD controller */
43#define IRQ_DC1176_GPIO0 (IRQ_DC1176_GIC_START + 16)
43#define IRQ_DC1176_SSP (IRQ_DC1176_GIC_START + 17) /* SSP port */ 44#define IRQ_DC1176_SSP (IRQ_DC1176_GIC_START + 17) /* SSP port */
44#define IRQ_DC1176_UART0 (IRQ_DC1176_GIC_START + 18) /* UART 0 on development chip */ 45#define IRQ_DC1176_UART0 (IRQ_DC1176_GIC_START + 18) /* UART 0 on development chip */
45#define IRQ_DC1176_UART1 (IRQ_DC1176_GIC_START + 19) /* UART 1 on development chip */ 46#define IRQ_DC1176_UART1 (IRQ_DC1176_GIC_START + 19) /* UART 1 on development chip */
@@ -73,7 +74,6 @@
73#define IRQ_PB1176_DMAC (IRQ_PB1176_GIC_START + 24) /* DMA controller */ 74#define IRQ_PB1176_DMAC (IRQ_PB1176_GIC_START + 24) /* DMA controller */
74#define IRQ_PB1176_RTC (IRQ_PB1176_GIC_START + 25) /* Real Time Clock */ 75#define IRQ_PB1176_RTC (IRQ_PB1176_GIC_START + 25) /* Real Time Clock */
75 76
76#define IRQ_PB1176_GPIO0 -1
77#define IRQ_PB1176_SCTL -1 77#define IRQ_PB1176_SCTL -1
78 78
79#define NR_GIC_PB1176 2 79#define NR_GIC_PB1176 2
diff --git a/arch/arm/mach-realview/include/mach/system.h b/arch/arm/mach-realview/include/mach/system.h
deleted file mode 100644
index 471b671159c..00000000000
--- a/arch/arm/mach-realview/include/mach/system.h
+++ /dev/null
@@ -1,33 +0,0 @@
1/*
2 * arch/arm/mach-realview/include/mach/system.h
3 *
4 * Copyright (C) 2003 ARM Limited
5 * Copyright (C) 2000 Deep Blue Solutions Ltd
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 USA
20 */
21#ifndef __ASM_ARCH_SYSTEM_H
22#define __ASM_ARCH_SYSTEM_H
23
24static inline void arch_idle(void)
25{
26 /*
27 * This should do all the clock switching
28 * and wait for interrupt tricks
29 */
30 cpu_do_idle();
31}
32
33#endif
diff --git a/arch/arm/mach-realview/realview_eb.c b/arch/arm/mach-realview/realview_eb.c
index 9578145f2df..baf382c5e77 100644
--- a/arch/arm/mach-realview/realview_eb.c
+++ b/arch/arm/mach-realview/realview_eb.c
@@ -36,7 +36,7 @@
36#include <asm/pgtable.h> 36#include <asm/pgtable.h>
37#include <asm/hardware/gic.h> 37#include <asm/hardware/gic.h>
38#include <asm/hardware/cache-l2x0.h> 38#include <asm/hardware/cache-l2x0.h>
39#include <asm/localtimer.h> 39#include <asm/smp_twd.h>
40 40
41#include <asm/mach/arch.h> 41#include <asm/mach/arch.h>
42#include <asm/mach/map.h> 42#include <asm/mach/map.h>
@@ -135,63 +135,63 @@ static struct pl022_ssp_controller ssp0_plat_data = {
135/* 135/*
136 * These devices are connected via the core APB bridge 136 * These devices are connected via the core APB bridge
137 */ 137 */
138#define GPIO2_IRQ { IRQ_EB_GPIO2, NO_IRQ } 138#define GPIO2_IRQ { IRQ_EB_GPIO2 }
139#define GPIO3_IRQ { IRQ_EB_GPIO3, NO_IRQ } 139#define GPIO3_IRQ { IRQ_EB_GPIO3 }
140 140
141#define AACI_IRQ { IRQ_EB_AACI, NO_IRQ } 141#define AACI_IRQ { IRQ_EB_AACI }
142#define MMCI0_IRQ { IRQ_EB_MMCI0A, IRQ_EB_MMCI0B } 142#define MMCI0_IRQ { IRQ_EB_MMCI0A, IRQ_EB_MMCI0B }
143#define KMI0_IRQ { IRQ_EB_KMI0, NO_IRQ } 143#define KMI0_IRQ { IRQ_EB_KMI0 }
144#define KMI1_IRQ { IRQ_EB_KMI1, NO_IRQ } 144#define KMI1_IRQ { IRQ_EB_KMI1 }
145 145
146/* 146/*
147 * These devices are connected directly to the multi-layer AHB switch 147 * These devices are connected directly to the multi-layer AHB switch
148 */ 148 */
149#define EB_SMC_IRQ { NO_IRQ, NO_IRQ } 149#define EB_SMC_IRQ { }
150#define MPMC_IRQ { NO_IRQ, NO_IRQ } 150#define MPMC_IRQ { }
151#define EB_CLCD_IRQ { IRQ_EB_CLCD, NO_IRQ } 151#define EB_CLCD_IRQ { IRQ_EB_CLCD }
152#define DMAC_IRQ { IRQ_EB_DMA, NO_IRQ } 152#define DMAC_IRQ { IRQ_EB_DMA }
153 153
154/* 154/*
155 * These devices are connected via the core APB bridge 155 * These devices are connected via the core APB bridge
156 */ 156 */
157#define SCTL_IRQ { NO_IRQ, NO_IRQ } 157#define SCTL_IRQ { }
158#define EB_WATCHDOG_IRQ { IRQ_EB_WDOG, NO_IRQ } 158#define EB_WATCHDOG_IRQ { IRQ_EB_WDOG }
159#define EB_GPIO0_IRQ { IRQ_EB_GPIO0, NO_IRQ } 159#define EB_GPIO0_IRQ { IRQ_EB_GPIO0 }
160#define GPIO1_IRQ { IRQ_EB_GPIO1, NO_IRQ } 160#define GPIO1_IRQ { IRQ_EB_GPIO1 }
161#define EB_RTC_IRQ { IRQ_EB_RTC, NO_IRQ } 161#define EB_RTC_IRQ { IRQ_EB_RTC }
162 162
163/* 163/*
164 * These devices are connected via the DMA APB bridge 164 * These devices are connected via the DMA APB bridge
165 */ 165 */
166#define SCI_IRQ { IRQ_EB_SCI, NO_IRQ } 166#define SCI_IRQ { IRQ_EB_SCI }
167#define EB_UART0_IRQ { IRQ_EB_UART0, NO_IRQ } 167#define EB_UART0_IRQ { IRQ_EB_UART0 }
168#define EB_UART1_IRQ { IRQ_EB_UART1, NO_IRQ } 168#define EB_UART1_IRQ { IRQ_EB_UART1 }
169#define EB_UART2_IRQ { IRQ_EB_UART2, NO_IRQ } 169#define EB_UART2_IRQ { IRQ_EB_UART2 }
170#define EB_UART3_IRQ { IRQ_EB_UART3, NO_IRQ } 170#define EB_UART3_IRQ { IRQ_EB_UART3 }
171#define EB_SSP_IRQ { IRQ_EB_SSP, NO_IRQ } 171#define EB_SSP_IRQ { IRQ_EB_SSP }
172 172
173/* FPGA Primecells */ 173/* FPGA Primecells */
174AMBA_DEVICE(aaci, "fpga:aaci", AACI, NULL); 174APB_DEVICE(aaci, "fpga:aaci", AACI, NULL);
175AMBA_DEVICE(mmc0, "fpga:mmc0", MMCI0, &realview_mmc0_plat_data); 175APB_DEVICE(mmc0, "fpga:mmc0", MMCI0, &realview_mmc0_plat_data);
176AMBA_DEVICE(kmi0, "fpga:kmi0", KMI0, NULL); 176APB_DEVICE(kmi0, "fpga:kmi0", KMI0, NULL);
177AMBA_DEVICE(kmi1, "fpga:kmi1", KMI1, NULL); 177APB_DEVICE(kmi1, "fpga:kmi1", KMI1, NULL);
178AMBA_DEVICE(uart3, "fpga:uart3", EB_UART3, NULL); 178APB_DEVICE(uart3, "fpga:uart3", EB_UART3, NULL);
179 179
180/* DevChip Primecells */ 180/* DevChip Primecells */
181AMBA_DEVICE(smc, "dev:smc", EB_SMC, NULL); 181AHB_DEVICE(smc, "dev:smc", EB_SMC, NULL);
182AMBA_DEVICE(clcd, "dev:clcd", EB_CLCD, &clcd_plat_data); 182AHB_DEVICE(clcd, "dev:clcd", EB_CLCD, &clcd_plat_data);
183AMBA_DEVICE(dmac, "dev:dmac", DMAC, NULL); 183AHB_DEVICE(dmac, "dev:dmac", DMAC, NULL);
184AMBA_DEVICE(sctl, "dev:sctl", SCTL, NULL); 184AHB_DEVICE(sctl, "dev:sctl", SCTL, NULL);
185AMBA_DEVICE(wdog, "dev:wdog", EB_WATCHDOG, NULL); 185APB_DEVICE(wdog, "dev:wdog", EB_WATCHDOG, NULL);
186AMBA_DEVICE(gpio0, "dev:gpio0", EB_GPIO0, &gpio0_plat_data); 186APB_DEVICE(gpio0, "dev:gpio0", EB_GPIO0, &gpio0_plat_data);
187AMBA_DEVICE(gpio1, "dev:gpio1", GPIO1, &gpio1_plat_data); 187APB_DEVICE(gpio1, "dev:gpio1", GPIO1, &gpio1_plat_data);
188AMBA_DEVICE(gpio2, "dev:gpio2", GPIO2, &gpio2_plat_data); 188APB_DEVICE(gpio2, "dev:gpio2", GPIO2, &gpio2_plat_data);
189AMBA_DEVICE(rtc, "dev:rtc", EB_RTC, NULL); 189APB_DEVICE(rtc, "dev:rtc", EB_RTC, NULL);
190AMBA_DEVICE(sci0, "dev:sci0", SCI, NULL); 190APB_DEVICE(sci0, "dev:sci0", SCI, NULL);
191AMBA_DEVICE(uart0, "dev:uart0", EB_UART0, NULL); 191APB_DEVICE(uart0, "dev:uart0", EB_UART0, NULL);
192AMBA_DEVICE(uart1, "dev:uart1", EB_UART1, NULL); 192APB_DEVICE(uart1, "dev:uart1", EB_UART1, NULL);
193AMBA_DEVICE(uart2, "dev:uart2", EB_UART2, NULL); 193APB_DEVICE(uart2, "dev:uart2", EB_UART2, NULL);
194AMBA_DEVICE(ssp0, "dev:ssp0", EB_SSP, &ssp0_plat_data); 194APB_DEVICE(ssp0, "dev:ssp0", EB_SSP, &ssp0_plat_data);
195 195
196static struct amba_device *amba_devs[] __initdata = { 196static struct amba_device *amba_devs[] __initdata = {
197 &dmac_device, 197 &dmac_device,
@@ -383,6 +383,23 @@ static void realview_eb11mp_fixup(void)
383 realview_eb_isp1761_resources[1].end = IRQ_EB11MP_USB; 383 realview_eb_isp1761_resources[1].end = IRQ_EB11MP_USB;
384} 384}
385 385
386#ifdef CONFIG_HAVE_ARM_TWD
387static DEFINE_TWD_LOCAL_TIMER(twd_local_timer,
388 REALVIEW_EB11MP_TWD_BASE,
389 IRQ_LOCALTIMER);
390
391static void __init realview_eb_twd_init(void)
392{
393 if (core_tile_eb11mp() || core_tile_a9mp()) {
394 int err = twd_local_timer_register(&twd_local_timer);
395 if (err)
396 pr_err("twd_local_timer_register failed %d\n", err);
397 }
398}
399#else
400#define realview_eb_twd_init() do { } while(0)
401#endif
402
386static void __init realview_eb_timer_init(void) 403static void __init realview_eb_timer_init(void)
387{ 404{
388 unsigned int timer_irq; 405 unsigned int timer_irq;
@@ -392,15 +409,13 @@ static void __init realview_eb_timer_init(void)
392 timer2_va_base = __io_address(REALVIEW_EB_TIMER2_3_BASE); 409 timer2_va_base = __io_address(REALVIEW_EB_TIMER2_3_BASE);
393 timer3_va_base = __io_address(REALVIEW_EB_TIMER2_3_BASE) + 0x20; 410 timer3_va_base = __io_address(REALVIEW_EB_TIMER2_3_BASE) + 0x20;
394 411
395 if (core_tile_eb11mp() || core_tile_a9mp()) { 412 if (core_tile_eb11mp() || core_tile_a9mp())
396#ifdef CONFIG_LOCAL_TIMERS
397 twd_base = __io_address(REALVIEW_EB11MP_TWD_BASE);
398#endif
399 timer_irq = IRQ_EB11MP_TIMER0_1; 413 timer_irq = IRQ_EB11MP_TIMER0_1;
400 } else 414 else
401 timer_irq = IRQ_EB_TIMER0_1; 415 timer_irq = IRQ_EB_TIMER0_1;
402 416
403 realview_timer_init(timer_irq); 417 realview_timer_init(timer_irq);
418 realview_eb_twd_init();
404} 419}
405 420
406static struct sys_timer realview_eb_timer = { 421static struct sys_timer realview_eb_timer = {
diff --git a/arch/arm/mach-realview/realview_pb1176.c b/arch/arm/mach-realview/realview_pb1176.c
index e4abe94fb11..b1d7cafa1a6 100644
--- a/arch/arm/mach-realview/realview_pb1176.c
+++ b/arch/arm/mach-realview/realview_pb1176.c
@@ -132,50 +132,50 @@ static struct pl022_ssp_controller ssp0_plat_data = {
132/* 132/*
133 * RealView PB1176 AMBA devices 133 * RealView PB1176 AMBA devices
134 */ 134 */
135#define GPIO2_IRQ { IRQ_PB1176_GPIO2, NO_IRQ } 135#define GPIO2_IRQ { IRQ_PB1176_GPIO2 }
136#define GPIO3_IRQ { IRQ_PB1176_GPIO3, NO_IRQ } 136#define GPIO3_IRQ { IRQ_PB1176_GPIO3 }
137#define AACI_IRQ { IRQ_PB1176_AACI, NO_IRQ } 137#define AACI_IRQ { IRQ_PB1176_AACI }
138#define MMCI0_IRQ { IRQ_PB1176_MMCI0A, IRQ_PB1176_MMCI0B } 138#define MMCI0_IRQ { IRQ_PB1176_MMCI0A, IRQ_PB1176_MMCI0B }
139#define KMI0_IRQ { IRQ_PB1176_KMI0, NO_IRQ } 139#define KMI0_IRQ { IRQ_PB1176_KMI0 }
140#define KMI1_IRQ { IRQ_PB1176_KMI1, NO_IRQ } 140#define KMI1_IRQ { IRQ_PB1176_KMI1 }
141#define PB1176_SMC_IRQ { NO_IRQ, NO_IRQ } 141#define PB1176_SMC_IRQ { }
142#define MPMC_IRQ { NO_IRQ, NO_IRQ } 142#define MPMC_IRQ { }
143#define PB1176_CLCD_IRQ { IRQ_DC1176_CLCD, NO_IRQ } 143#define PB1176_CLCD_IRQ { IRQ_DC1176_CLCD }
144#define SCTL_IRQ { NO_IRQ, NO_IRQ } 144#define SCTL_IRQ { }
145#define PB1176_WATCHDOG_IRQ { IRQ_DC1176_WATCHDOG, NO_IRQ } 145#define PB1176_WATCHDOG_IRQ { IRQ_DC1176_WATCHDOG }
146#define PB1176_GPIO0_IRQ { IRQ_PB1176_GPIO0, NO_IRQ } 146#define PB1176_GPIO0_IRQ { IRQ_DC1176_GPIO0 }
147#define GPIO1_IRQ { IRQ_PB1176_GPIO1, NO_IRQ } 147#define GPIO1_IRQ { IRQ_PB1176_GPIO1 }
148#define PB1176_RTC_IRQ { IRQ_DC1176_RTC, NO_IRQ } 148#define PB1176_RTC_IRQ { IRQ_DC1176_RTC }
149#define SCI_IRQ { IRQ_PB1176_SCI, NO_IRQ } 149#define SCI_IRQ { IRQ_PB1176_SCI }
150#define PB1176_UART0_IRQ { IRQ_DC1176_UART0, NO_IRQ } 150#define PB1176_UART0_IRQ { IRQ_DC1176_UART0 }
151#define PB1176_UART1_IRQ { IRQ_DC1176_UART1, NO_IRQ } 151#define PB1176_UART1_IRQ { IRQ_DC1176_UART1 }
152#define PB1176_UART2_IRQ { IRQ_DC1176_UART2, NO_IRQ } 152#define PB1176_UART2_IRQ { IRQ_DC1176_UART2 }
153#define PB1176_UART3_IRQ { IRQ_DC1176_UART3, NO_IRQ } 153#define PB1176_UART3_IRQ { IRQ_DC1176_UART3 }
154#define PB1176_UART4_IRQ { IRQ_PB1176_UART4, NO_IRQ } 154#define PB1176_UART4_IRQ { IRQ_PB1176_UART4 }
155#define PB1176_SSP_IRQ { IRQ_DC1176_SSP, NO_IRQ } 155#define PB1176_SSP_IRQ { IRQ_DC1176_SSP }
156 156
157/* FPGA Primecells */ 157/* FPGA Primecells */
158AMBA_DEVICE(aaci, "fpga:aaci", AACI, NULL); 158APB_DEVICE(aaci, "fpga:aaci", AACI, NULL);
159AMBA_DEVICE(mmc0, "fpga:mmc0", MMCI0, &realview_mmc0_plat_data); 159APB_DEVICE(mmc0, "fpga:mmc0", MMCI0, &realview_mmc0_plat_data);
160AMBA_DEVICE(kmi0, "fpga:kmi0", KMI0, NULL); 160APB_DEVICE(kmi0, "fpga:kmi0", KMI0, NULL);
161AMBA_DEVICE(kmi1, "fpga:kmi1", KMI1, NULL); 161APB_DEVICE(kmi1, "fpga:kmi1", KMI1, NULL);
162AMBA_DEVICE(uart4, "fpga:uart4", PB1176_UART4, NULL); 162APB_DEVICE(uart4, "fpga:uart4", PB1176_UART4, NULL);
163 163
164/* DevChip Primecells */ 164/* DevChip Primecells */
165AMBA_DEVICE(smc, "dev:smc", PB1176_SMC, NULL); 165AHB_DEVICE(smc, "dev:smc", PB1176_SMC, NULL);
166AMBA_DEVICE(sctl, "dev:sctl", SCTL, NULL); 166AHB_DEVICE(sctl, "dev:sctl", SCTL, NULL);
167AMBA_DEVICE(wdog, "dev:wdog", PB1176_WATCHDOG, NULL); 167APB_DEVICE(wdog, "dev:wdog", PB1176_WATCHDOG, NULL);
168AMBA_DEVICE(gpio0, "dev:gpio0", PB1176_GPIO0, &gpio0_plat_data); 168APB_DEVICE(gpio0, "dev:gpio0", PB1176_GPIO0, &gpio0_plat_data);
169AMBA_DEVICE(gpio1, "dev:gpio1", GPIO1, &gpio1_plat_data); 169APB_DEVICE(gpio1, "dev:gpio1", GPIO1, &gpio1_plat_data);
170AMBA_DEVICE(gpio2, "dev:gpio2", GPIO2, &gpio2_plat_data); 170APB_DEVICE(gpio2, "dev:gpio2", GPIO2, &gpio2_plat_data);
171AMBA_DEVICE(rtc, "dev:rtc", PB1176_RTC, NULL); 171APB_DEVICE(rtc, "dev:rtc", PB1176_RTC, NULL);
172AMBA_DEVICE(sci0, "dev:sci0", SCI, NULL); 172APB_DEVICE(sci0, "dev:sci0", SCI, NULL);
173AMBA_DEVICE(uart0, "dev:uart0", PB1176_UART0, NULL); 173APB_DEVICE(uart0, "dev:uart0", PB1176_UART0, NULL);
174AMBA_DEVICE(uart1, "dev:uart1", PB1176_UART1, NULL); 174APB_DEVICE(uart1, "dev:uart1", PB1176_UART1, NULL);
175AMBA_DEVICE(uart2, "dev:uart2", PB1176_UART2, NULL); 175APB_DEVICE(uart2, "dev:uart2", PB1176_UART2, NULL);
176AMBA_DEVICE(uart3, "dev:uart3", PB1176_UART3, NULL); 176APB_DEVICE(uart3, "dev:uart3", PB1176_UART3, NULL);
177AMBA_DEVICE(ssp0, "dev:ssp0", PB1176_SSP, &ssp0_plat_data); 177APB_DEVICE(ssp0, "dev:ssp0", PB1176_SSP, &ssp0_plat_data);
178AMBA_DEVICE(clcd, "dev:clcd", PB1176_CLCD, &clcd_plat_data); 178AHB_DEVICE(clcd, "dev:clcd", PB1176_CLCD, &clcd_plat_data);
179 179
180static struct amba_device *amba_devs[] __initdata = { 180static struct amba_device *amba_devs[] __initdata = {
181 &uart0_device, 181 &uart0_device,
diff --git a/arch/arm/mach-realview/realview_pb11mp.c b/arch/arm/mach-realview/realview_pb11mp.c
index 2147335f66f..a98c536e332 100644
--- a/arch/arm/mach-realview/realview_pb11mp.c
+++ b/arch/arm/mach-realview/realview_pb11mp.c
@@ -36,7 +36,7 @@
36#include <asm/pgtable.h> 36#include <asm/pgtable.h>
37#include <asm/hardware/gic.h> 37#include <asm/hardware/gic.h>
38#include <asm/hardware/cache-l2x0.h> 38#include <asm/hardware/cache-l2x0.h>
39#include <asm/localtimer.h> 39#include <asm/smp_twd.h>
40 40
41#include <asm/mach/arch.h> 41#include <asm/mach/arch.h>
42#include <asm/mach/flash.h> 42#include <asm/mach/flash.h>
@@ -127,52 +127,52 @@ static struct pl022_ssp_controller ssp0_plat_data = {
127 * RealView PB11MPCore AMBA devices 127 * RealView PB11MPCore AMBA devices
128 */ 128 */
129 129
130#define GPIO2_IRQ { IRQ_PB11MP_GPIO2, NO_IRQ } 130#define GPIO2_IRQ { IRQ_PB11MP_GPIO2 }
131#define GPIO3_IRQ { IRQ_PB11MP_GPIO3, NO_IRQ } 131#define GPIO3_IRQ { IRQ_PB11MP_GPIO3 }
132#define AACI_IRQ { IRQ_TC11MP_AACI, NO_IRQ } 132#define AACI_IRQ { IRQ_TC11MP_AACI }
133#define MMCI0_IRQ { IRQ_TC11MP_MMCI0A, IRQ_TC11MP_MMCI0B } 133#define MMCI0_IRQ { IRQ_TC11MP_MMCI0A, IRQ_TC11MP_MMCI0B }
134#define KMI0_IRQ { IRQ_TC11MP_KMI0, NO_IRQ } 134#define KMI0_IRQ { IRQ_TC11MP_KMI0 }
135#define KMI1_IRQ { IRQ_TC11MP_KMI1, NO_IRQ } 135#define KMI1_IRQ { IRQ_TC11MP_KMI1 }
136#define PB11MP_SMC_IRQ { NO_IRQ, NO_IRQ } 136#define PB11MP_SMC_IRQ { }
137#define MPMC_IRQ { NO_IRQ, NO_IRQ } 137#define MPMC_IRQ { }
138#define PB11MP_CLCD_IRQ { IRQ_PB11MP_CLCD, NO_IRQ } 138#define PB11MP_CLCD_IRQ { IRQ_PB11MP_CLCD }
139#define DMAC_IRQ { IRQ_PB11MP_DMAC, NO_IRQ } 139#define DMAC_IRQ { IRQ_PB11MP_DMAC }
140#define SCTL_IRQ { NO_IRQ, NO_IRQ } 140#define SCTL_IRQ { }
141#define PB11MP_WATCHDOG_IRQ { IRQ_PB11MP_WATCHDOG, NO_IRQ } 141#define PB11MP_WATCHDOG_IRQ { IRQ_PB11MP_WATCHDOG }
142#define PB11MP_GPIO0_IRQ { IRQ_PB11MP_GPIO0, NO_IRQ } 142#define PB11MP_GPIO0_IRQ { IRQ_PB11MP_GPIO0 }
143#define GPIO1_IRQ { IRQ_PB11MP_GPIO1, NO_IRQ } 143#define GPIO1_IRQ { IRQ_PB11MP_GPIO1 }
144#define PB11MP_RTC_IRQ { IRQ_TC11MP_RTC, NO_IRQ } 144#define PB11MP_RTC_IRQ { IRQ_TC11MP_RTC }
145#define SCI_IRQ { IRQ_PB11MP_SCI, NO_IRQ } 145#define SCI_IRQ { IRQ_PB11MP_SCI }
146#define PB11MP_UART0_IRQ { IRQ_TC11MP_UART0, NO_IRQ } 146#define PB11MP_UART0_IRQ { IRQ_TC11MP_UART0 }
147#define PB11MP_UART1_IRQ { IRQ_TC11MP_UART1, NO_IRQ } 147#define PB11MP_UART1_IRQ { IRQ_TC11MP_UART1 }
148#define PB11MP_UART2_IRQ { IRQ_PB11MP_UART2, NO_IRQ } 148#define PB11MP_UART2_IRQ { IRQ_PB11MP_UART2 }
149#define PB11MP_UART3_IRQ { IRQ_PB11MP_UART3, NO_IRQ } 149#define PB11MP_UART3_IRQ { IRQ_PB11MP_UART3 }
150#define PB11MP_SSP_IRQ { IRQ_PB11MP_SSP, NO_IRQ } 150#define PB11MP_SSP_IRQ { IRQ_PB11MP_SSP }
151 151
152/* FPGA Primecells */ 152/* FPGA Primecells */
153AMBA_DEVICE(aaci, "fpga:aaci", AACI, NULL); 153APB_DEVICE(aaci, "fpga:aaci", AACI, NULL);
154AMBA_DEVICE(mmc0, "fpga:mmc0", MMCI0, &realview_mmc0_plat_data); 154APB_DEVICE(mmc0, "fpga:mmc0", MMCI0, &realview_mmc0_plat_data);
155AMBA_DEVICE(kmi0, "fpga:kmi0", KMI0, NULL); 155APB_DEVICE(kmi0, "fpga:kmi0", KMI0, NULL);
156AMBA_DEVICE(kmi1, "fpga:kmi1", KMI1, NULL); 156APB_DEVICE(kmi1, "fpga:kmi1", KMI1, NULL);
157AMBA_DEVICE(uart3, "fpga:uart3", PB11MP_UART3, NULL); 157APB_DEVICE(uart3, "fpga:uart3", PB11MP_UART3, NULL);
158 158
159/* DevChip Primecells */ 159/* DevChip Primecells */
160AMBA_DEVICE(smc, "dev:smc", PB11MP_SMC, NULL); 160AHB_DEVICE(smc, "dev:smc", PB11MP_SMC, NULL);
161AMBA_DEVICE(sctl, "dev:sctl", SCTL, NULL); 161AHB_DEVICE(sctl, "dev:sctl", SCTL, NULL);
162AMBA_DEVICE(wdog, "dev:wdog", PB11MP_WATCHDOG, NULL); 162APB_DEVICE(wdog, "dev:wdog", PB11MP_WATCHDOG, NULL);
163AMBA_DEVICE(gpio0, "dev:gpio0", PB11MP_GPIO0, &gpio0_plat_data); 163APB_DEVICE(gpio0, "dev:gpio0", PB11MP_GPIO0, &gpio0_plat_data);
164AMBA_DEVICE(gpio1, "dev:gpio1", GPIO1, &gpio1_plat_data); 164APB_DEVICE(gpio1, "dev:gpio1", GPIO1, &gpio1_plat_data);
165AMBA_DEVICE(gpio2, "dev:gpio2", GPIO2, &gpio2_plat_data); 165APB_DEVICE(gpio2, "dev:gpio2", GPIO2, &gpio2_plat_data);
166AMBA_DEVICE(rtc, "dev:rtc", PB11MP_RTC, NULL); 166APB_DEVICE(rtc, "dev:rtc", PB11MP_RTC, NULL);
167AMBA_DEVICE(sci0, "dev:sci0", SCI, NULL); 167APB_DEVICE(sci0, "dev:sci0", SCI, NULL);
168AMBA_DEVICE(uart0, "dev:uart0", PB11MP_UART0, NULL); 168APB_DEVICE(uart0, "dev:uart0", PB11MP_UART0, NULL);
169AMBA_DEVICE(uart1, "dev:uart1", PB11MP_UART1, NULL); 169APB_DEVICE(uart1, "dev:uart1", PB11MP_UART1, NULL);
170AMBA_DEVICE(uart2, "dev:uart2", PB11MP_UART2, NULL); 170APB_DEVICE(uart2, "dev:uart2", PB11MP_UART2, NULL);
171AMBA_DEVICE(ssp0, "dev:ssp0", PB11MP_SSP, &ssp0_plat_data); 171APB_DEVICE(ssp0, "dev:ssp0", PB11MP_SSP, &ssp0_plat_data);
172 172
173/* Primecells on the NEC ISSP chip */ 173/* Primecells on the NEC ISSP chip */
174AMBA_DEVICE(clcd, "issp:clcd", PB11MP_CLCD, &clcd_plat_data); 174AHB_DEVICE(clcd, "issp:clcd", PB11MP_CLCD, &clcd_plat_data);
175AMBA_DEVICE(dmac, "issp:dmac", DMAC, NULL); 175AHB_DEVICE(dmac, "issp:dmac", DMAC, NULL);
176 176
177static struct amba_device *amba_devs[] __initdata = { 177static struct amba_device *amba_devs[] __initdata = {
178 &dmac_device, 178 &dmac_device,
@@ -290,6 +290,21 @@ static void __init gic_init_irq(void)
290 gic_cascade_irq(1, IRQ_TC11MP_PB_IRQ1); 290 gic_cascade_irq(1, IRQ_TC11MP_PB_IRQ1);
291} 291}
292 292
293#ifdef CONFIG_HAVE_ARM_TWD
294static DEFINE_TWD_LOCAL_TIMER(twd_local_timer,
295 REALVIEW_TC11MP_TWD_BASE,
296 IRQ_LOCALTIMER);
297
298static void __init realview_pb11mp_twd_init(void)
299{
300 int err = twd_local_timer_register(&twd_local_timer);
301 if (err)
302 pr_err("twd_local_timer_register failed %d\n", err);
303}
304#else
305#define realview_pb11mp_twd_init() do {} while(0)
306#endif
307
293static void __init realview_pb11mp_timer_init(void) 308static void __init realview_pb11mp_timer_init(void)
294{ 309{
295 timer0_va_base = __io_address(REALVIEW_PB11MP_TIMER0_1_BASE); 310 timer0_va_base = __io_address(REALVIEW_PB11MP_TIMER0_1_BASE);
@@ -297,10 +312,8 @@ static void __init realview_pb11mp_timer_init(void)
297 timer2_va_base = __io_address(REALVIEW_PB11MP_TIMER2_3_BASE); 312 timer2_va_base = __io_address(REALVIEW_PB11MP_TIMER2_3_BASE);
298 timer3_va_base = __io_address(REALVIEW_PB11MP_TIMER2_3_BASE) + 0x20; 313 timer3_va_base = __io_address(REALVIEW_PB11MP_TIMER2_3_BASE) + 0x20;
299 314
300#ifdef CONFIG_LOCAL_TIMERS
301 twd_base = __io_address(REALVIEW_TC11MP_TWD_BASE);
302#endif
303 realview_timer_init(IRQ_TC11MP_TIMER0_1); 315 realview_timer_init(IRQ_TC11MP_TIMER0_1);
316 realview_pb11mp_twd_init();
304} 317}
305 318
306static struct sys_timer realview_pb11mp_timer = { 319static struct sys_timer realview_pb11mp_timer = {
diff --git a/arch/arm/mach-realview/realview_pba8.c b/arch/arm/mach-realview/realview_pba8.c
index 25b2e59296f..59650174e6e 100644
--- a/arch/arm/mach-realview/realview_pba8.c
+++ b/arch/arm/mach-realview/realview_pba8.c
@@ -122,52 +122,52 @@ static struct pl022_ssp_controller ssp0_plat_data = {
122 * RealView PBA8Core AMBA devices 122 * RealView PBA8Core AMBA devices
123 */ 123 */
124 124
125#define GPIO2_IRQ { IRQ_PBA8_GPIO2, NO_IRQ } 125#define GPIO2_IRQ { IRQ_PBA8_GPIO2 }
126#define GPIO3_IRQ { IRQ_PBA8_GPIO3, NO_IRQ } 126#define GPIO3_IRQ { IRQ_PBA8_GPIO3 }
127#define AACI_IRQ { IRQ_PBA8_AACI, NO_IRQ } 127#define AACI_IRQ { IRQ_PBA8_AACI }
128#define MMCI0_IRQ { IRQ_PBA8_MMCI0A, IRQ_PBA8_MMCI0B } 128#define MMCI0_IRQ { IRQ_PBA8_MMCI0A, IRQ_PBA8_MMCI0B }
129#define KMI0_IRQ { IRQ_PBA8_KMI0, NO_IRQ } 129#define KMI0_IRQ { IRQ_PBA8_KMI0 }
130#define KMI1_IRQ { IRQ_PBA8_KMI1, NO_IRQ } 130#define KMI1_IRQ { IRQ_PBA8_KMI1 }
131#define PBA8_SMC_IRQ { NO_IRQ, NO_IRQ } 131#define PBA8_SMC_IRQ { }
132#define MPMC_IRQ { NO_IRQ, NO_IRQ } 132#define MPMC_IRQ { }
133#define PBA8_CLCD_IRQ { IRQ_PBA8_CLCD, NO_IRQ } 133#define PBA8_CLCD_IRQ { IRQ_PBA8_CLCD }
134#define DMAC_IRQ { IRQ_PBA8_DMAC, NO_IRQ } 134#define DMAC_IRQ { IRQ_PBA8_DMAC }
135#define SCTL_IRQ { NO_IRQ, NO_IRQ } 135#define SCTL_IRQ { }
136#define PBA8_WATCHDOG_IRQ { IRQ_PBA8_WATCHDOG, NO_IRQ } 136#define PBA8_WATCHDOG_IRQ { IRQ_PBA8_WATCHDOG }
137#define PBA8_GPIO0_IRQ { IRQ_PBA8_GPIO0, NO_IRQ } 137#define PBA8_GPIO0_IRQ { IRQ_PBA8_GPIO0 }
138#define GPIO1_IRQ { IRQ_PBA8_GPIO1, NO_IRQ } 138#define GPIO1_IRQ { IRQ_PBA8_GPIO1 }
139#define PBA8_RTC_IRQ { IRQ_PBA8_RTC, NO_IRQ } 139#define PBA8_RTC_IRQ { IRQ_PBA8_RTC }
140#define SCI_IRQ { IRQ_PBA8_SCI, NO_IRQ } 140#define SCI_IRQ { IRQ_PBA8_SCI }
141#define PBA8_UART0_IRQ { IRQ_PBA8_UART0, NO_IRQ } 141#define PBA8_UART0_IRQ { IRQ_PBA8_UART0 }
142#define PBA8_UART1_IRQ { IRQ_PBA8_UART1, NO_IRQ } 142#define PBA8_UART1_IRQ { IRQ_PBA8_UART1 }
143#define PBA8_UART2_IRQ { IRQ_PBA8_UART2, NO_IRQ } 143#define PBA8_UART2_IRQ { IRQ_PBA8_UART2 }
144#define PBA8_UART3_IRQ { IRQ_PBA8_UART3, NO_IRQ } 144#define PBA8_UART3_IRQ { IRQ_PBA8_UART3 }
145#define PBA8_SSP_IRQ { IRQ_PBA8_SSP, NO_IRQ } 145#define PBA8_SSP_IRQ { IRQ_PBA8_SSP }
146 146
147/* FPGA Primecells */ 147/* FPGA Primecells */
148AMBA_DEVICE(aaci, "fpga:aaci", AACI, NULL); 148APB_DEVICE(aaci, "fpga:aaci", AACI, NULL);
149AMBA_DEVICE(mmc0, "fpga:mmc0", MMCI0, &realview_mmc0_plat_data); 149APB_DEVICE(mmc0, "fpga:mmc0", MMCI0, &realview_mmc0_plat_data);
150AMBA_DEVICE(kmi0, "fpga:kmi0", KMI0, NULL); 150APB_DEVICE(kmi0, "fpga:kmi0", KMI0, NULL);
151AMBA_DEVICE(kmi1, "fpga:kmi1", KMI1, NULL); 151APB_DEVICE(kmi1, "fpga:kmi1", KMI1, NULL);
152AMBA_DEVICE(uart3, "fpga:uart3", PBA8_UART3, NULL); 152APB_DEVICE(uart3, "fpga:uart3", PBA8_UART3, NULL);
153 153
154/* DevChip Primecells */ 154/* DevChip Primecells */
155AMBA_DEVICE(smc, "dev:smc", PBA8_SMC, NULL); 155AHB_DEVICE(smc, "dev:smc", PBA8_SMC, NULL);
156AMBA_DEVICE(sctl, "dev:sctl", SCTL, NULL); 156AHB_DEVICE(sctl, "dev:sctl", SCTL, NULL);
157AMBA_DEVICE(wdog, "dev:wdog", PBA8_WATCHDOG, NULL); 157APB_DEVICE(wdog, "dev:wdog", PBA8_WATCHDOG, NULL);
158AMBA_DEVICE(gpio0, "dev:gpio0", PBA8_GPIO0, &gpio0_plat_data); 158APB_DEVICE(gpio0, "dev:gpio0", PBA8_GPIO0, &gpio0_plat_data);
159AMBA_DEVICE(gpio1, "dev:gpio1", GPIO1, &gpio1_plat_data); 159APB_DEVICE(gpio1, "dev:gpio1", GPIO1, &gpio1_plat_data);
160AMBA_DEVICE(gpio2, "dev:gpio2", GPIO2, &gpio2_plat_data); 160APB_DEVICE(gpio2, "dev:gpio2", GPIO2, &gpio2_plat_data);
161AMBA_DEVICE(rtc, "dev:rtc", PBA8_RTC, NULL); 161APB_DEVICE(rtc, "dev:rtc", PBA8_RTC, NULL);
162AMBA_DEVICE(sci0, "dev:sci0", SCI, NULL); 162APB_DEVICE(sci0, "dev:sci0", SCI, NULL);
163AMBA_DEVICE(uart0, "dev:uart0", PBA8_UART0, NULL); 163APB_DEVICE(uart0, "dev:uart0", PBA8_UART0, NULL);
164AMBA_DEVICE(uart1, "dev:uart1", PBA8_UART1, NULL); 164APB_DEVICE(uart1, "dev:uart1", PBA8_UART1, NULL);
165AMBA_DEVICE(uart2, "dev:uart2", PBA8_UART2, NULL); 165APB_DEVICE(uart2, "dev:uart2", PBA8_UART2, NULL);
166AMBA_DEVICE(ssp0, "dev:ssp0", PBA8_SSP, &ssp0_plat_data); 166APB_DEVICE(ssp0, "dev:ssp0", PBA8_SSP, &ssp0_plat_data);
167 167
168/* Primecells on the NEC ISSP chip */ 168/* Primecells on the NEC ISSP chip */
169AMBA_DEVICE(clcd, "issp:clcd", PBA8_CLCD, &clcd_plat_data); 169AHB_DEVICE(clcd, "issp:clcd", PBA8_CLCD, &clcd_plat_data);
170AMBA_DEVICE(dmac, "issp:dmac", DMAC, NULL); 170AHB_DEVICE(dmac, "issp:dmac", DMAC, NULL);
171 171
172static struct amba_device *amba_devs[] __initdata = { 172static struct amba_device *amba_devs[] __initdata = {
173 &dmac_device, 173 &dmac_device,
diff --git a/arch/arm/mach-realview/realview_pbx.c b/arch/arm/mach-realview/realview_pbx.c
index ac715645b86..3f2f605624e 100644
--- a/arch/arm/mach-realview/realview_pbx.c
+++ b/arch/arm/mach-realview/realview_pbx.c
@@ -144,52 +144,52 @@ static struct pl022_ssp_controller ssp0_plat_data = {
144 * RealView PBXCore AMBA devices 144 * RealView PBXCore AMBA devices
145 */ 145 */
146 146
147#define GPIO2_IRQ { IRQ_PBX_GPIO2, NO_IRQ } 147#define GPIO2_IRQ { IRQ_PBX_GPIO2 }
148#define GPIO3_IRQ { IRQ_PBX_GPIO3, NO_IRQ } 148#define GPIO3_IRQ { IRQ_PBX_GPIO3 }
149#define AACI_IRQ { IRQ_PBX_AACI, NO_IRQ } 149#define AACI_IRQ { IRQ_PBX_AACI }
150#define MMCI0_IRQ { IRQ_PBX_MMCI0A, IRQ_PBX_MMCI0B } 150#define MMCI0_IRQ { IRQ_PBX_MMCI0A, IRQ_PBX_MMCI0B }
151#define KMI0_IRQ { IRQ_PBX_KMI0, NO_IRQ } 151#define KMI0_IRQ { IRQ_PBX_KMI0 }
152#define KMI1_IRQ { IRQ_PBX_KMI1, NO_IRQ } 152#define KMI1_IRQ { IRQ_PBX_KMI1 }
153#define PBX_SMC_IRQ { NO_IRQ, NO_IRQ } 153#define PBX_SMC_IRQ { }
154#define MPMC_IRQ { NO_IRQ, NO_IRQ } 154#define MPMC_IRQ { }
155#define PBX_CLCD_IRQ { IRQ_PBX_CLCD, NO_IRQ } 155#define PBX_CLCD_IRQ { IRQ_PBX_CLCD }
156#define DMAC_IRQ { IRQ_PBX_DMAC, NO_IRQ } 156#define DMAC_IRQ { IRQ_PBX_DMAC }
157#define SCTL_IRQ { NO_IRQ, NO_IRQ } 157#define SCTL_IRQ { }
158#define PBX_WATCHDOG_IRQ { IRQ_PBX_WATCHDOG, NO_IRQ } 158#define PBX_WATCHDOG_IRQ { IRQ_PBX_WATCHDOG }
159#define PBX_GPIO0_IRQ { IRQ_PBX_GPIO0, NO_IRQ } 159#define PBX_GPIO0_IRQ { IRQ_PBX_GPIO0 }
160#define GPIO1_IRQ { IRQ_PBX_GPIO1, NO_IRQ } 160#define GPIO1_IRQ { IRQ_PBX_GPIO1 }
161#define PBX_RTC_IRQ { IRQ_PBX_RTC, NO_IRQ } 161#define PBX_RTC_IRQ { IRQ_PBX_RTC }
162#define SCI_IRQ { IRQ_PBX_SCI, NO_IRQ } 162#define SCI_IRQ { IRQ_PBX_SCI }
163#define PBX_UART0_IRQ { IRQ_PBX_UART0, NO_IRQ } 163#define PBX_UART0_IRQ { IRQ_PBX_UART0 }
164#define PBX_UART1_IRQ { IRQ_PBX_UART1, NO_IRQ } 164#define PBX_UART1_IRQ { IRQ_PBX_UART1 }
165#define PBX_UART2_IRQ { IRQ_PBX_UART2, NO_IRQ } 165#define PBX_UART2_IRQ { IRQ_PBX_UART2 }
166#define PBX_UART3_IRQ { IRQ_PBX_UART3, NO_IRQ } 166#define PBX_UART3_IRQ { IRQ_PBX_UART3 }
167#define PBX_SSP_IRQ { IRQ_PBX_SSP, NO_IRQ } 167#define PBX_SSP_IRQ { IRQ_PBX_SSP }
168 168
169/* FPGA Primecells */ 169/* FPGA Primecells */
170AMBA_DEVICE(aaci, "fpga:aaci", AACI, NULL); 170APB_DEVICE(aaci, "fpga:aaci", AACI, NULL);
171AMBA_DEVICE(mmc0, "fpga:mmc0", MMCI0, &realview_mmc0_plat_data); 171APB_DEVICE(mmc0, "fpga:mmc0", MMCI0, &realview_mmc0_plat_data);
172AMBA_DEVICE(kmi0, "fpga:kmi0", KMI0, NULL); 172APB_DEVICE(kmi0, "fpga:kmi0", KMI0, NULL);
173AMBA_DEVICE(kmi1, "fpga:kmi1", KMI1, NULL); 173APB_DEVICE(kmi1, "fpga:kmi1", KMI1, NULL);
174AMBA_DEVICE(uart3, "fpga:uart3", PBX_UART3, NULL); 174APB_DEVICE(uart3, "fpga:uart3", PBX_UART3, NULL);
175 175
176/* DevChip Primecells */ 176/* DevChip Primecells */
177AMBA_DEVICE(smc, "dev:smc", PBX_SMC, NULL); 177AHB_DEVICE(smc, "dev:smc", PBX_SMC, NULL);
178AMBA_DEVICE(sctl, "dev:sctl", SCTL, NULL); 178AHB_DEVICE(sctl, "dev:sctl", SCTL, NULL);
179AMBA_DEVICE(wdog, "dev:wdog", PBX_WATCHDOG, NULL); 179APB_DEVICE(wdog, "dev:wdog", PBX_WATCHDOG, NULL);
180AMBA_DEVICE(gpio0, "dev:gpio0", PBX_GPIO0, &gpio0_plat_data); 180APB_DEVICE(gpio0, "dev:gpio0", PBX_GPIO0, &gpio0_plat_data);
181AMBA_DEVICE(gpio1, "dev:gpio1", GPIO1, &gpio1_plat_data); 181APB_DEVICE(gpio1, "dev:gpio1", GPIO1, &gpio1_plat_data);
182AMBA_DEVICE(gpio2, "dev:gpio2", GPIO2, &gpio2_plat_data); 182APB_DEVICE(gpio2, "dev:gpio2", GPIO2, &gpio2_plat_data);
183AMBA_DEVICE(rtc, "dev:rtc", PBX_RTC, NULL); 183APB_DEVICE(rtc, "dev:rtc", PBX_RTC, NULL);
184AMBA_DEVICE(sci0, "dev:sci0", SCI, NULL); 184APB_DEVICE(sci0, "dev:sci0", SCI, NULL);
185AMBA_DEVICE(uart0, "dev:uart0", PBX_UART0, NULL); 185APB_DEVICE(uart0, "dev:uart0", PBX_UART0, NULL);
186AMBA_DEVICE(uart1, "dev:uart1", PBX_UART1, NULL); 186APB_DEVICE(uart1, "dev:uart1", PBX_UART1, NULL);
187AMBA_DEVICE(uart2, "dev:uart2", PBX_UART2, NULL); 187APB_DEVICE(uart2, "dev:uart2", PBX_UART2, NULL);
188AMBA_DEVICE(ssp0, "dev:ssp0", PBX_SSP, &ssp0_plat_data); 188APB_DEVICE(ssp0, "dev:ssp0", PBX_SSP, &ssp0_plat_data);
189 189
190/* Primecells on the NEC ISSP chip */ 190/* Primecells on the NEC ISSP chip */
191AMBA_DEVICE(clcd, "issp:clcd", PBX_CLCD, &clcd_plat_data); 191AHB_DEVICE(clcd, "issp:clcd", PBX_CLCD, &clcd_plat_data);
192AMBA_DEVICE(dmac, "issp:dmac", DMAC, NULL); 192AHB_DEVICE(dmac, "issp:dmac", DMAC, NULL);
193 193
194static struct amba_device *amba_devs[] __initdata = { 194static struct amba_device *amba_devs[] __initdata = {
195 &dmac_device, 195 &dmac_device,
@@ -298,6 +298,21 @@ static void __init gic_init_irq(void)
298 } 298 }
299} 299}
300 300
301#ifdef CONFIG_HAVE_ARM_TWD
302static DEFINE_TWD_LOCAL_TIMER(twd_local_timer,
303 REALVIEW_PBX_TILE_TWD_BASE,
304 IRQ_LOCALTIMER);
305
306static void __init realview_pbx_twd_init(void)
307{
308 int err = twd_local_timer_register(&twd_local_timer);
309 if (err)
310 pr_err("twd_local_timer_register failed %d\n", err);
311}
312#else
313#define realview_pbx_twd_init() do { } while(0)
314#endif
315
301static void __init realview_pbx_timer_init(void) 316static void __init realview_pbx_timer_init(void)
302{ 317{
303 timer0_va_base = __io_address(REALVIEW_PBX_TIMER0_1_BASE); 318 timer0_va_base = __io_address(REALVIEW_PBX_TIMER0_1_BASE);
@@ -305,11 +320,8 @@ static void __init realview_pbx_timer_init(void)
305 timer2_va_base = __io_address(REALVIEW_PBX_TIMER2_3_BASE); 320 timer2_va_base = __io_address(REALVIEW_PBX_TIMER2_3_BASE);
306 timer3_va_base = __io_address(REALVIEW_PBX_TIMER2_3_BASE) + 0x20; 321 timer3_va_base = __io_address(REALVIEW_PBX_TIMER2_3_BASE) + 0x20;
307 322
308#ifdef CONFIG_LOCAL_TIMERS
309 if (core_tile_pbx11mp() || core_tile_pbxa9mp())
310 twd_base = __io_address(REALVIEW_PBX_TILE_TWD_BASE);
311#endif
312 realview_timer_init(IRQ_PBX_TIMER0_1); 323 realview_timer_init(IRQ_PBX_TIMER0_1);
324 realview_pbx_twd_init();
313} 325}
314 326
315static struct sys_timer realview_pbx_timer = { 327static struct sys_timer realview_pbx_timer = {
diff --git a/arch/arm/mach-rpc/Makefile b/arch/arm/mach-rpc/Makefile
index aa77bc9efbb..992e28b4ae9 100644
--- a/arch/arm/mach-rpc/Makefile
+++ b/arch/arm/mach-rpc/Makefile
@@ -4,7 +4,7 @@
4 4
5# Object file lists. 5# Object file lists.
6 6
7obj-y := dma.o irq.o riscpc.o 7obj-y := dma.o ecard.o fiq.o irq.o riscpc.o time.o
8obj-m := 8obj-m :=
9obj-n := 9obj-n :=
10obj- := 10obj- :=
diff --git a/arch/arm/kernel/ecard.c b/arch/arm/mach-rpc/ecard.c
index 1651d495074..b91bc87b3dc 100644
--- a/arch/arm/kernel/ecard.c
+++ b/arch/arm/mach-rpc/ecard.c
@@ -42,6 +42,7 @@
42#include <linux/init.h> 42#include <linux/init.h>
43#include <linux/mutex.h> 43#include <linux/mutex.h>
44#include <linux/kthread.h> 44#include <linux/kthread.h>
45#include <linux/irq.h>
45#include <linux/io.h> 46#include <linux/io.h>
46 47
47#include <asm/dma.h> 48#include <asm/dma.h>
@@ -54,10 +55,6 @@
54 55
55#include "ecard.h" 56#include "ecard.h"
56 57
57#ifndef CONFIG_ARCH_RPC
58#define HAVE_EXPMASK
59#endif
60
61struct ecard_request { 58struct ecard_request {
62 void (*fn)(struct ecard_request *); 59 void (*fn)(struct ecard_request *);
63 ecard_t *ec; 60 ecard_t *ec;
@@ -77,9 +74,6 @@ struct expcard_blacklist {
77static ecard_t *cards; 74static ecard_t *cards;
78static ecard_t *slot_to_expcard[MAX_ECARDS]; 75static ecard_t *slot_to_expcard[MAX_ECARDS];
79static unsigned int ectcr; 76static unsigned int ectcr;
80#ifdef HAS_EXPMASK
81static unsigned int have_expmask;
82#endif
83 77
84/* List of descriptions of cards which don't have an extended 78/* List of descriptions of cards which don't have an extended
85 * identification, or chunk directories containing a description. 79 * identification, or chunk directories containing a description.
@@ -391,22 +385,10 @@ int ecard_readchunk(struct in_chunk_dir *cd, ecard_t *ec, int id, int num)
391 385
392static void ecard_def_irq_enable(ecard_t *ec, int irqnr) 386static void ecard_def_irq_enable(ecard_t *ec, int irqnr)
393{ 387{
394#ifdef HAS_EXPMASK
395 if (irqnr < 4 && have_expmask) {
396 have_expmask |= 1 << irqnr;
397 __raw_writeb(have_expmask, EXPMASK_ENABLE);
398 }
399#endif
400} 388}
401 389
402static void ecard_def_irq_disable(ecard_t *ec, int irqnr) 390static void ecard_def_irq_disable(ecard_t *ec, int irqnr)
403{ 391{
404#ifdef HAS_EXPMASK
405 if (irqnr < 4 && have_expmask) {
406 have_expmask &= ~(1 << irqnr);
407 __raw_writeb(have_expmask, EXPMASK_ENABLE);
408 }
409#endif
410} 392}
411 393
412static int ecard_def_irq_pending(ecard_t *ec) 394static int ecard_def_irq_pending(ecard_t *ec)
@@ -446,7 +428,7 @@ static expansioncard_ops_t ecard_default_ops = {
446 */ 428 */
447static void ecard_irq_unmask(struct irq_data *d) 429static void ecard_irq_unmask(struct irq_data *d)
448{ 430{
449 ecard_t *ec = slot_to_ecard(d->irq - 32); 431 ecard_t *ec = irq_data_get_irq_chip_data(d);
450 432
451 if (ec) { 433 if (ec) {
452 if (!ec->ops) 434 if (!ec->ops)
@@ -462,7 +444,7 @@ static void ecard_irq_unmask(struct irq_data *d)
462 444
463static void ecard_irq_mask(struct irq_data *d) 445static void ecard_irq_mask(struct irq_data *d)
464{ 446{
465 ecard_t *ec = slot_to_ecard(d->irq - 32); 447 ecard_t *ec = irq_data_get_irq_chip_data(d);
466 448
467 if (ec) { 449 if (ec) {
468 if (!ec->ops) 450 if (!ec->ops)
@@ -579,7 +561,7 @@ ecard_irq_handler(unsigned int irq, struct irq_desc *desc)
579 for (ec = cards; ec; ec = ec->next) { 561 for (ec = cards; ec; ec = ec->next) {
580 int pending; 562 int pending;
581 563
582 if (!ec->claimed || ec->irq == NO_IRQ || ec->slot_no == 8) 564 if (!ec->claimed || !ec->irq || ec->slot_no == 8)
583 continue; 565 continue;
584 566
585 if (ec->ops && ec->ops->irqpending) 567 if (ec->ops && ec->ops->irqpending)
@@ -598,83 +580,6 @@ ecard_irq_handler(unsigned int irq, struct irq_desc *desc)
598 ecard_check_lockup(desc); 580 ecard_check_lockup(desc);
599} 581}
600 582
601#ifdef HAS_EXPMASK
602static unsigned char priority_masks[] =
603{
604 0xf0, 0xf1, 0xf3, 0xf7, 0xff, 0xff, 0xff, 0xff
605};
606
607static unsigned char first_set[] =
608{
609 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00,
610 0x03, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00
611};
612
613static void
614ecard_irqexp_handler(unsigned int irq, struct irq_desc *desc)
615{
616 const unsigned int statusmask = 15;
617 unsigned int status;
618
619 status = __raw_readb(EXPMASK_STATUS) & statusmask;
620 if (status) {
621 unsigned int slot = first_set[status];
622 ecard_t *ec = slot_to_ecard(slot);
623
624 if (ec->claimed) {
625 /*
626 * this ugly code is so that we can operate a
627 * prioritorising system:
628 *
629 * Card 0 highest priority
630 * Card 1
631 * Card 2
632 * Card 3 lowest priority
633 *
634 * Serial cards should go in 0/1, ethernet/scsi in 2/3
635 * otherwise you will lose serial data at high speeds!
636 */
637 generic_handle_irq(ec->irq);
638 } else {
639 printk(KERN_WARNING "card%d: interrupt from unclaimed "
640 "card???\n", slot);
641 have_expmask &= ~(1 << slot);
642 __raw_writeb(have_expmask, EXPMASK_ENABLE);
643 }
644 } else
645 printk(KERN_WARNING "Wild interrupt from backplane (masks)\n");
646}
647
648static int __init ecard_probeirqhw(void)
649{
650 ecard_t *ec;
651 int found;
652
653 __raw_writeb(0x00, EXPMASK_ENABLE);
654 __raw_writeb(0xff, EXPMASK_STATUS);
655 found = (__raw_readb(EXPMASK_STATUS) & 15) == 0;
656 __raw_writeb(0xff, EXPMASK_ENABLE);
657
658 if (found) {
659 printk(KERN_DEBUG "Expansion card interrupt "
660 "management hardware found\n");
661
662 /* for each card present, set a bit to '1' */
663 have_expmask = 0x80000000;
664
665 for (ec = cards; ec; ec = ec->next)
666 have_expmask |= 1 << ec->slot_no;
667
668 __raw_writeb(have_expmask, EXPMASK_ENABLE);
669 }
670
671 return found;
672}
673#else
674#define ecard_irqexp_handler NULL
675#define ecard_probeirqhw() (0)
676#endif
677
678static void __iomem *__ecard_address(ecard_t *ec, card_type_t type, card_speed_t speed) 583static void __iomem *__ecard_address(ecard_t *ec, card_type_t type, card_speed_t speed)
679{ 584{
680 void __iomem *address = NULL; 585 void __iomem *address = NULL;
@@ -806,8 +711,8 @@ static struct expansion_card *__init ecard_alloc_card(int type, int slot)
806 711
807 ec->slot_no = slot; 712 ec->slot_no = slot;
808 ec->easi = type == ECARD_EASI; 713 ec->easi = type == ECARD_EASI;
809 ec->irq = NO_IRQ; 714 ec->irq = 0;
810 ec->fiq = NO_IRQ; 715 ec->fiq = 0;
811 ec->dma = NO_DMA; 716 ec->dma = NO_DMA;
812 ec->ops = &ecard_default_ops; 717 ec->ops = &ecard_default_ops;
813 718
@@ -978,8 +883,7 @@ EXPORT_SYMBOL(ecardm_iomap);
978 * If bit 1 of the first byte of the card is set, then the 883 * If bit 1 of the first byte of the card is set, then the
979 * card does not exist. 884 * card does not exist.
980 */ 885 */
981static int __init 886static int __init ecard_probe(int slot, unsigned irq, card_type_t type)
982ecard_probe(int slot, card_type_t type)
983{ 887{
984 ecard_t **ecp; 888 ecard_t **ecp;
985 ecard_t *ec; 889 ecard_t *ec;
@@ -1033,18 +937,18 @@ ecard_probe(int slot, card_type_t type)
1033 break; 937 break;
1034 } 938 }
1035 939
940 ec->irq = irq;
941
1036 /* 942 /*
1037 * hook the interrupt handlers 943 * hook the interrupt handlers
1038 */ 944 */
1039 if (slot < 8) { 945 if (slot < 8) {
1040 ec->irq = 32 + slot;
1041 irq_set_chip_and_handler(ec->irq, &ecard_chip, 946 irq_set_chip_and_handler(ec->irq, &ecard_chip,
1042 handle_level_irq); 947 handle_level_irq);
948 irq_set_chip_data(ec->irq, ec);
1043 set_irq_flags(ec->irq, IRQF_VALID); 949 set_irq_flags(ec->irq, IRQF_VALID);
1044 } 950 }
1045 951
1046 if (slot == 8)
1047 ec->irq = 11;
1048#ifdef CONFIG_ARCH_RPC 952#ifdef CONFIG_ARCH_RPC
1049 /* On RiscPC, only first two slots have DMA capability */ 953 /* On RiscPC, only first two slots have DMA capability */
1050 if (slot < 2) 954 if (slot < 2)
@@ -1074,28 +978,30 @@ ecard_probe(int slot, card_type_t type)
1074static int __init ecard_init(void) 978static int __init ecard_init(void)
1075{ 979{
1076 struct task_struct *task; 980 struct task_struct *task;
1077 int slot, irqhw; 981 int slot, irqbase;
982
983 irqbase = irq_alloc_descs(-1, 0, 8, -1);
984 if (irqbase < 0)
985 return irqbase;
1078 986
1079 task = kthread_run(ecard_task, NULL, "kecardd"); 987 task = kthread_run(ecard_task, NULL, "kecardd");
1080 if (IS_ERR(task)) { 988 if (IS_ERR(task)) {
1081 printk(KERN_ERR "Ecard: unable to create kernel thread: %ld\n", 989 printk(KERN_ERR "Ecard: unable to create kernel thread: %ld\n",
1082 PTR_ERR(task)); 990 PTR_ERR(task));
991 irq_free_descs(irqbase, 8);
1083 return PTR_ERR(task); 992 return PTR_ERR(task);
1084 } 993 }
1085 994
1086 printk("Probing expansion cards\n"); 995 printk("Probing expansion cards\n");
1087 996
1088 for (slot = 0; slot < 8; slot ++) { 997 for (slot = 0; slot < 8; slot ++) {
1089 if (ecard_probe(slot, ECARD_EASI) == -ENODEV) 998 if (ecard_probe(slot, irqbase + slot, ECARD_EASI) == -ENODEV)
1090 ecard_probe(slot, ECARD_IOC); 999 ecard_probe(slot, irqbase + slot, ECARD_IOC);
1091 } 1000 }
1092 1001
1093 ecard_probe(8, ECARD_IOC); 1002 ecard_probe(8, 11, ECARD_IOC);
1094
1095 irqhw = ecard_probeirqhw();
1096 1003
1097 irq_set_chained_handler(IRQ_EXPANSIONCARD, 1004 irq_set_chained_handler(IRQ_EXPANSIONCARD, ecard_irq_handler);
1098 irqhw ? ecard_irqexp_handler : ecard_irq_handler);
1099 1005
1100 ecard_proc_init(); 1006 ecard_proc_init();
1101 1007
diff --git a/arch/arm/kernel/ecard.h b/arch/arm/mach-rpc/ecard.h
index 4642d436be2..4642d436be2 100644
--- a/arch/arm/kernel/ecard.h
+++ b/arch/arm/mach-rpc/ecard.h
diff --git a/arch/arm/mach-rpc/fiq.S b/arch/arm/mach-rpc/fiq.S
new file mode 100644
index 00000000000..48ddd57db16
--- /dev/null
+++ b/arch/arm/mach-rpc/fiq.S
@@ -0,0 +1,16 @@
1#include <linux/linkage.h>
2#include <asm/assembler.h>
3#include <mach/hardware.h>
4#include <mach/entry-macro.S>
5
6 .text
7
8 .global rpc_default_fiq_end
9ENTRY(rpc_default_fiq_start)
10 mov r12, #ioc_base_high
11 .if ioc_base_low
12 orr r12, r12, #ioc_base_low
13 .endif
14 strb r12, [r12, #0x38] @ Disable FIQ register
15 subs pc, lr, #4
16rpc_default_fiq_end:
diff --git a/arch/arm/mach-rpc/include/mach/entry-macro.S b/arch/arm/mach-rpc/include/mach/entry-macro.S
index 4e7e5414409..7178368d706 100644
--- a/arch/arm/mach-rpc/include/mach/entry-macro.S
+++ b/arch/arm/mach-rpc/include/mach/entry-macro.S
@@ -10,7 +10,3 @@
10 orr \base, \base, #ioc_base_low 10 orr \base, \base, #ioc_base_low
11 .endif 11 .endif
12 .endm 12 .endm
13
14 .macro arch_ret_to_user, tmp1, tmp2
15 .endm
16
diff --git a/arch/arm/mach-rpc/include/mach/irqs.h b/arch/arm/mach-rpc/include/mach/irqs.h
index 3d2037496e3..6868e178274 100644
--- a/arch/arm/mach-rpc/include/mach/irqs.h
+++ b/arch/arm/mach-rpc/include/mach/irqs.h
@@ -42,6 +42,4 @@
42 */ 42 */
43#define FIQ_START 64 43#define FIQ_START 64
44 44
45#define IRQ_TIMER IRQ_TIMER0
46
47#define NR_IRQS 128 45#define NR_IRQS 128
diff --git a/arch/arm/mach-rpc/include/mach/system.h b/arch/arm/mach-rpc/include/mach/system.h
deleted file mode 100644
index 359bab94b6a..00000000000
--- a/arch/arm/mach-rpc/include/mach/system.h
+++ /dev/null
@@ -1,13 +0,0 @@
1/*
2 * arch/arm/mach-rpc/include/mach/system.h
3 *
4 * Copyright (C) 1996-1999 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 */
10static inline void arch_idle(void)
11{
12 cpu_do_idle();
13}
diff --git a/arch/arm/mach-rpc/irq.c b/arch/arm/mach-rpc/irq.c
index 2e1b5309fba..cf0e669eaf1 100644
--- a/arch/arm/mach-rpc/irq.c
+++ b/arch/arm/mach-rpc/irq.c
@@ -5,6 +5,7 @@
5#include <asm/mach/irq.h> 5#include <asm/mach/irq.h>
6#include <asm/hardware/iomd.h> 6#include <asm/hardware/iomd.h>
7#include <asm/irq.h> 7#include <asm/irq.h>
8#include <asm/fiq.h>
8 9
9static void iomd_ack_irq_a(struct irq_data *d) 10static void iomd_ack_irq_a(struct irq_data *d)
10{ 11{
@@ -112,6 +113,8 @@ static struct irq_chip iomd_fiq_chip = {
112 .irq_unmask = iomd_unmask_irq_fiq, 113 .irq_unmask = iomd_unmask_irq_fiq,
113}; 114};
114 115
116extern unsigned char rpc_default_fiq_start, rpc_default_fiq_end;
117
115void __init rpc_init_irq(void) 118void __init rpc_init_irq(void)
116{ 119{
117 unsigned int irq, flags; 120 unsigned int irq, flags;
@@ -121,6 +124,9 @@ void __init rpc_init_irq(void)
121 iomd_writeb(0, IOMD_FIQMASK); 124 iomd_writeb(0, IOMD_FIQMASK);
122 iomd_writeb(0, IOMD_DMAMASK); 125 iomd_writeb(0, IOMD_DMAMASK);
123 126
127 set_fiq_handler(&rpc_default_fiq_start,
128 &rpc_default_fiq_end - &rpc_default_fiq_start);
129
124 for (irq = 0; irq < NR_IRQS; irq++) { 130 for (irq = 0; irq < NR_IRQS; irq++) {
125 flags = IRQF_VALID; 131 flags = IRQF_VALID;
126 132
diff --git a/arch/arm/mach-rpc/riscpc.c b/arch/arm/mach-rpc/riscpc.c
index e95859748fa..f3fa259ce01 100644
--- a/arch/arm/mach-rpc/riscpc.c
+++ b/arch/arm/mach-rpc/riscpc.c
@@ -99,15 +99,9 @@ static void __init rpc_map_io(void)
99} 99}
100 100
101static struct resource acornfb_resources[] = { 101static struct resource acornfb_resources[] = {
102 { /* VIDC */ 102 /* VIDC */
103 .start = 0x03400000, 103 DEFINE_RES_MEM(0x03400000, 0x00200000),
104 .end = 0x035fffff, 104 DEFINE_RES_IRQ(IRQ_VSYNCPULSE),
105 .flags = IORESOURCE_MEM,
106 }, {
107 .start = IRQ_VSYNCPULSE,
108 .end = IRQ_VSYNCPULSE,
109 .flags = IORESOURCE_IRQ,
110 },
111}; 105};
112 106
113static struct platform_device acornfb_device = { 107static struct platform_device acornfb_device = {
@@ -121,11 +115,7 @@ static struct platform_device acornfb_device = {
121}; 115};
122 116
123static struct resource iomd_resources[] = { 117static struct resource iomd_resources[] = {
124 { 118 DEFINE_RES_MEM(0x03200000, 0x10000),
125 .start = 0x03200000,
126 .end = 0x0320ffff,
127 .flags = IORESOURCE_MEM,
128 },
129}; 119};
130 120
131static struct platform_device iomd_device = { 121static struct platform_device iomd_device = {
@@ -135,18 +125,25 @@ static struct platform_device iomd_device = {
135 .resource = iomd_resources, 125 .resource = iomd_resources,
136}; 126};
137 127
128static struct resource iomd_kart_resources[] = {
129 DEFINE_RES_IRQ(IRQ_KEYBOARDRX),
130 DEFINE_RES_IRQ(IRQ_KEYBOARDTX),
131};
132
138static struct platform_device kbd_device = { 133static struct platform_device kbd_device = {
139 .name = "kart", 134 .name = "kart",
140 .id = -1, 135 .id = -1,
141 .dev = { 136 .dev = {
142 .parent = &iomd_device.dev, 137 .parent = &iomd_device.dev,
143 }, 138 },
139 .num_resources = ARRAY_SIZE(iomd_kart_resources),
140 .resource = iomd_kart_resources,
144}; 141};
145 142
146static struct plat_serial8250_port serial_platform_data[] = { 143static struct plat_serial8250_port serial_platform_data[] = {
147 { 144 {
148 .mapbase = 0x03010fe0, 145 .mapbase = 0x03010fe0,
149 .irq = 10, 146 .irq = IRQ_SERIALPORT,
150 .uartclk = 1843200, 147 .uartclk = 1843200,
151 .regshift = 2, 148 .regshift = 2,
152 .iotype = UPIO_MEM, 149 .iotype = UPIO_MEM,
@@ -168,21 +165,9 @@ static struct pata_platform_info pata_platform_data = {
168}; 165};
169 166
170static struct resource pata_resources[] = { 167static struct resource pata_resources[] = {
171 [0] = { 168 DEFINE_RES_MEM(0x030107c0, 0x20),
172 .start = 0x030107c0, 169 DEFINE_RES_MEM(0x03010fd8, 0x04),
173 .end = 0x030107df, 170 DEFINE_RES_IRQ(IRQ_HARDDISK),
174 .flags = IORESOURCE_MEM,
175 },
176 [1] = {
177 .start = 0x03010fd8,
178 .end = 0x03010fdb,
179 .flags = IORESOURCE_MEM,
180 },
181 [2] = {
182 .start = IRQ_HARDDISK,
183 .end = IRQ_HARDDISK,
184 .flags = IORESOURCE_IRQ,
185 },
186}; 171};
187 172
188static struct platform_device pata_device = { 173static struct platform_device pata_device = {
diff --git a/arch/arm/common/time-acorn.c b/arch/arm/mach-rpc/time.c
index deeed561b16..581fca934bb 100644
--- a/arch/arm/common/time-acorn.c
+++ b/arch/arm/mach-rpc/time.c
@@ -85,7 +85,7 @@ static struct irqaction ioc_timer_irq = {
85static void __init ioc_timer_init(void) 85static void __init ioc_timer_init(void)
86{ 86{
87 ioctime_init(); 87 ioctime_init();
88 setup_irq(IRQ_TIMER, &ioc_timer_irq); 88 setup_irq(IRQ_TIMER0, &ioc_timer_irq);
89} 89}
90 90
91struct sys_timer ioc_timer = { 91struct sys_timer ioc_timer = {
diff --git a/arch/arm/mach-s3c2410/Kconfig b/arch/arm/mach-s3c2410/Kconfig
index 5261a7ed099..68d89cb96af 100644
--- a/arch/arm/mach-s3c2410/Kconfig
+++ b/arch/arm/mach-s3c2410/Kconfig
@@ -2,42 +2,6 @@
2# 2#
3# Licensed under GPLv2 3# Licensed under GPLv2
4 4
5config CPU_S3C2410
6 bool
7 depends on ARCH_S3C2410
8 select CPU_ARM920T
9 select S3C2410_CLOCK
10 select CPU_LLSERIAL_S3C2410
11 select S3C2410_PM if PM
12 select S3C2410_CPUFREQ if CPU_FREQ_S3C24XX
13 help
14 Support for S3C2410 and S3C2410A family from the S3C24XX line
15 of Samsung Mobile CPUs.
16
17config CPU_S3C2410_DMA
18 bool
19 depends on S3C2410_DMA && (CPU_S3C2410 || CPU_S3C2442)
20 default y if CPU_S3C2410 || CPU_S3C2442
21 help
22 DMA device selection for S3C2410 and compatible CPUs
23
24config S3C2410_PM
25 bool
26 help
27 Power Management code common to S3C2410 and better
28
29config SIMTEC_NOR
30 bool
31 help
32 Internal node to specify machine has simtec NOR mapping
33
34config MACH_BAST_IDE
35 bool
36 select HAVE_PATA_PLATFORM
37 help
38 Internal node for machines with an BAST style IDE
39 interface
40
41# cpu frequency scaling support 5# cpu frequency scaling support
42 6
43config S3C2410_CPUFREQ 7config S3C2410_CPUFREQ
@@ -54,121 +18,3 @@ config S3C2410_PLLTABLE
54 help 18 help
55 Select the PLL table for the S3C2410 19 Select the PLL table for the S3C2410
56 20
57menu "S3C2410 Machines"
58
59config ARCH_SMDK2410
60 bool "SMDK2410/A9M2410"
61 select CPU_S3C2410
62 select MACH_SMDK
63 help
64 Say Y here if you are using the SMDK2410 or the derived module A9M2410
65 <http://www.fsforth.de>
66
67config ARCH_H1940
68 bool "IPAQ H1940"
69 select CPU_S3C2410
70 select PM_H1940 if PM
71 select S3C_DEV_USB_HOST
72 select S3C_DEV_NAND
73 select S3C2410_SETUP_TS
74 help
75 Say Y here if you are using the HP IPAQ H1940
76
77config H1940BT
78 tristate "Control the state of H1940 bluetooth chip"
79 depends on ARCH_H1940
80 select RFKILL
81 help
82 This is a simple driver that is able to control
83 the state of built in bluetooth chip on h1940.
84
85config PM_H1940
86 bool
87 help
88 Internal node for H1940 and related PM
89
90config MACH_N30
91 bool "Acer N30 family"
92 select CPU_S3C2410
93 select MACH_N35
94 select S3C_DEV_USB_HOST
95 select S3C_DEV_NAND
96 help
97 Say Y here if you want suppt for the Acer N30, Acer N35,
98 Navman PiN570, Yakumo AlphaX or Airis NC05 PDAs.
99
100config MACH_N35
101 bool
102 help
103 Internal node in order to enable support for Acer N35 if Acer N30 is
104 selected.
105
106config ARCH_BAST
107 bool "Simtec Electronics BAST (EB2410ITX)"
108 select CPU_S3C2410
109 select S3C2410_IOTIMING if S3C2410_CPUFREQ
110 select PM_SIMTEC if PM
111 select SIMTEC_NOR
112 select MACH_BAST_IDE
113 select S3C24XX_DCLK
114 select ISA
115 select S3C_DEV_HWMON
116 select S3C_DEV_USB_HOST
117 select S3C_DEV_NAND
118 help
119 Say Y here if you are using the Simtec Electronics EB2410ITX
120 development board (also known as BAST)
121
122config MACH_OTOM
123 bool "NexVision OTOM Board"
124 select CPU_S3C2410
125 select S3C_DEV_USB_HOST
126 select S3C_DEV_NAND
127 help
128 Say Y here if you are using the Nex Vision OTOM board
129
130config MACH_AML_M5900
131 bool "AML M5900 Series"
132 select CPU_S3C2410
133 select PM_SIMTEC if PM
134 select S3C_DEV_USB_HOST
135 help
136 Say Y here if you are using the American Microsystems M5900 Series
137 <http://www.amltd.com>
138
139config BAST_PC104_IRQ
140 bool "BAST PC104 IRQ support"
141 depends on ARCH_BAST
142 default y
143 help
144 Say Y here to enable the PC104 IRQ routing on the
145 Simtec BAST (EB2410ITX)
146
147config MACH_TCT_HAMMER
148 bool "TCT Hammer Board"
149 select CPU_S3C2410
150 select S3C_DEV_USB_HOST
151 help
152 Say Y here if you are using the TinCanTools Hammer Board
153 <http://www.tincantools.com>
154
155config MACH_VR1000
156 bool "Thorcom VR1000"
157 select PM_SIMTEC if PM
158 select S3C24XX_DCLK
159 select SIMTEC_NOR
160 select MACH_BAST_IDE
161 select CPU_S3C2410
162 select S3C_DEV_USB_HOST
163 help
164 Say Y here if you are using the Thorcom VR1000 board.
165
166config MACH_QT2410
167 bool "QT2410"
168 select CPU_S3C2410
169 select S3C_DEV_USB_HOST
170 select S3C_DEV_NAND
171 help
172 Say Y here if you are using the Armzone QT2410
173
174endmenu
diff --git a/arch/arm/mach-s3c2410/Makefile b/arch/arm/mach-s3c2410/Makefile
index 782fd81144e..6b9a316e004 100644
--- a/arch/arm/mach-s3c2410/Makefile
+++ b/arch/arm/mach-s3c2410/Makefile
@@ -9,32 +9,6 @@ obj-m :=
9obj-n := 9obj-n :=
10obj- := 10obj- :=
11 11
12obj-$(CONFIG_CPU_S3C2410) += s3c2410.o
13obj-$(CONFIG_CPU_S3C2410_DMA) += dma.o
14obj-$(CONFIG_CPU_S3C2410_DMA) += dma.o
15obj-$(CONFIG_S3C2410_PM) += pm.o sleep.o
16obj-$(CONFIG_S3C2410_CPUFREQ) += cpu-freq.o 12obj-$(CONFIG_S3C2410_CPUFREQ) += cpu-freq.o
17obj-$(CONFIG_S3C2410_PLLTABLE) += pll.o 13obj-$(CONFIG_S3C2410_PLLTABLE) += pll.o
18 14
19# Machine support
20
21obj-$(CONFIG_ARCH_SMDK2410) += mach-smdk2410.o
22obj-$(CONFIG_ARCH_H1940) += mach-h1940.o
23obj-$(CONFIG_H1940BT) += h1940-bluetooth.o
24obj-$(CONFIG_PM_H1940) += pm-h1940.o
25obj-$(CONFIG_MACH_N30) += mach-n30.o
26obj-$(CONFIG_ARCH_BAST) += mach-bast.o usb-simtec.o
27obj-$(CONFIG_MACH_OTOM) += mach-otom.o
28obj-$(CONFIG_MACH_AML_M5900) += mach-amlm5900.o
29obj-$(CONFIG_BAST_PC104_IRQ) += bast-irq.o
30obj-$(CONFIG_MACH_TCT_HAMMER) += mach-tct_hammer.o
31obj-$(CONFIG_MACH_VR1000) += mach-vr1000.o usb-simtec.o
32obj-$(CONFIG_MACH_QT2410) += mach-qt2410.o
33
34# Common bits of machine support
35
36obj-$(CONFIG_SIMTEC_NOR) += nor-simtec.o
37
38# machine additions
39
40obj-$(CONFIG_MACH_BAST_IDE) += bast-ide.o
diff --git a/arch/arm/mach-s3c2410/common.h b/arch/arm/mach-s3c2410/common.h
deleted file mode 100644
index f65dc806296..00000000000
--- a/arch/arm/mach-s3c2410/common.h
+++ /dev/null
@@ -1,17 +0,0 @@
1/*
2 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
3 * http://www.samsung.com
4 *
5 * Common Header for S3C2410 machines
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#ifndef __ARCH_ARM_MACH_S3C2410_COMMON_H
13#define __ARCH_ARM_MACH_S3C2410_COMMON_H
14
15void s3c2410_restart(char mode, const char *cmd);
16
17#endif /* __ARCH_ARM_MACH_S3C2410_COMMON_H */
diff --git a/arch/arm/mach-s3c2410/include/mach/spi.h b/arch/arm/mach-s3c2410/include/mach/spi.h
deleted file mode 100644
index 4d9588373aa..00000000000
--- a/arch/arm/mach-s3c2410/include/mach/spi.h
+++ /dev/null
@@ -1,38 +0,0 @@
1/* arch/arm/mach-s3c2410/include/mach/spi.h
2 *
3 * Copyright (c) 2006 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
5 *
6 * S3C2410 - SPI Controller platform_device info
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13#ifndef __ASM_ARCH_SPI_H
14#define __ASM_ARCH_SPI_H __FILE__
15
16struct s3c2410_spi_info {
17 int pin_cs; /* simple gpio cs */
18 unsigned int num_cs; /* total chipselects */
19 int bus_num; /* bus number to use. */
20
21 unsigned int use_fiq:1; /* use fiq */
22
23 void (*gpio_setup)(struct s3c2410_spi_info *spi, int enable);
24 void (*set_cs)(struct s3c2410_spi_info *spi, int cs, int pol);
25};
26
27/* Standard setup / suspend routines for SPI GPIO pins. */
28
29extern void s3c24xx_spi_gpiocfg_bus0_gpe11_12_13(struct s3c2410_spi_info *spi,
30 int enable);
31
32extern void s3c24xx_spi_gpiocfg_bus1_gpg5_6_7(struct s3c2410_spi_info *spi,
33 int enable);
34
35extern void s3c24xx_spi_gpiocfg_bus1_gpd8_9_10(struct s3c2410_spi_info *spi,
36 int enable);
37
38#endif /* __ASM_ARCH_SPI_H */
diff --git a/arch/arm/mach-s3c2410/include/mach/system.h b/arch/arm/mach-s3c2410/include/mach/system.h
deleted file mode 100644
index 5e215c1a5c8..00000000000
--- a/arch/arm/mach-s3c2410/include/mach/system.h
+++ /dev/null
@@ -1,54 +0,0 @@
1/* arch/arm/mach-s3c2410/include/mach/system.h
2 *
3 * Copyright (c) 2003 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
5 *
6 * S3C2410 - System function defines and includes
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/io.h>
14#include <mach/hardware.h>
15
16#include <mach/map.h>
17#include <mach/idle.h>
18
19#include <mach/regs-clock.h>
20
21void (*s3c24xx_idle)(void);
22
23void s3c24xx_default_idle(void)
24{
25 unsigned long tmp;
26 int i;
27
28 /* idle the system by using the idle mode which will wait for an
29 * interrupt to happen before restarting the system.
30 */
31
32 /* Warning: going into idle state upsets jtag scanning */
33
34 __raw_writel(__raw_readl(S3C2410_CLKCON) | S3C2410_CLKCON_IDLE,
35 S3C2410_CLKCON);
36
37 /* the samsung port seems to do a loop and then unset idle.. */
38 for (i = 0; i < 50; i++) {
39 tmp += __raw_readl(S3C2410_CLKCON); /* ensure loop not optimised out */
40 }
41
42 /* this bit is not cleared on re-start... */
43
44 __raw_writel(__raw_readl(S3C2410_CLKCON) & ~S3C2410_CLKCON_IDLE,
45 S3C2410_CLKCON);
46}
47
48static void arch_idle(void)
49{
50 if (s3c24xx_idle != NULL)
51 (s3c24xx_idle)();
52 else
53 s3c24xx_default_idle();
54}
diff --git a/arch/arm/mach-s3c2410/usb-simtec.h b/arch/arm/mach-s3c2410/usb-simtec.h
deleted file mode 100644
index 03842ede9e7..00000000000
--- a/arch/arm/mach-s3c2410/usb-simtec.h
+++ /dev/null
@@ -1,16 +0,0 @@
1/* linux/arch/arm/mach-s3c2410/usb-simtec.h
2 *
3 * Copyright (c) 2004 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
5 *
6 * http://www.simtec.co.uk/products/EB2410ITX/
7 *
8 * Simtec BAST and Thorcom VR1000 USB port support functions
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13*/
14
15extern int usb_simtec_init(void);
16
diff --git a/arch/arm/mach-s3c2412/Kconfig b/arch/arm/mach-s3c2412/Kconfig
index b8b9029e9f2..c5256f4e90b 100644
--- a/arch/arm/mach-s3c2412/Kconfig
+++ b/arch/arm/mach-s3c2412/Kconfig
@@ -2,41 +2,6 @@
2# 2#
3# Licensed under GPLv2 3# Licensed under GPLv2
4 4
5config CPU_S3C2412
6 bool
7 depends on ARCH_S3C2410
8 select CPU_ARM926T
9 select CPU_LLSERIAL_S3C2440
10 select S3C2412_PM if PM
11 select S3C2412_DMA if S3C2410_DMA
12 help
13 Support for the S3C2412 and S3C2413 SoCs from the S3C24XX line
14
15config CPU_S3C2412_ONLY
16 bool
17 depends on ARCH_S3C2410 && !CPU_S3C2410 && \
18 !CPU_S3C2416 && !CPU_S3C2440 && !CPU_S3C2442 && \
19 !CPU_S3C2443 && CPU_S3C2412
20 default y if CPU_S3C2412
21
22config S3C2412_DMA
23 bool
24 depends on CPU_S3C2412
25 help
26 Internal config node for S3C2412 DMA support
27
28config S3C2412_PM
29 bool
30 select S3C2412_PM_SLEEP
31 help
32 Internal config node to apply S3C2412 power management
33
34config S3C2412_PM_SLEEP
35 bool
36 help
37 Internal config node to apply sleep for S3C2412 power management.
38 Can be selected by another SoCs with similar sleep procedure.
39
40# Note, the S3C2412 IOtiming support is in plat-s3c24xx 5# Note, the S3C2412 IOtiming support is in plat-s3c24xx
41 6
42config S3C2412_CPUFREQ 7config S3C2412_CPUFREQ
@@ -46,53 +11,3 @@ config S3C2412_CPUFREQ
46 default y 11 default y
47 help 12 help
48 CPU Frequency scaling support for S3C2412 and S3C2413 SoC CPUs. 13 CPU Frequency scaling support for S3C2412 and S3C2413 SoC CPUs.
49
50menu "S3C2412 Machines"
51
52config MACH_JIVE
53 bool "Logitech Jive"
54 select CPU_S3C2412
55 select S3C_DEV_USB_HOST
56 select S3C_DEV_NAND
57 help
58 Say Y here if you are using the Logitech Jive.
59
60config MACH_JIVE_SHOW_BOOTLOADER
61 bool "Allow access to bootloader partitions in MTD (EXPERIMENTAL)"
62 depends on MACH_JIVE && EXPERIMENTAL
63
64config MACH_SMDK2413
65 bool "SMDK2413"
66 select CPU_S3C2412
67 select MACH_S3C2413
68 select MACH_SMDK
69 select S3C_DEV_USB_HOST
70 select S3C_DEV_NAND
71 help
72 Say Y here if you are using an SMDK2413
73
74config MACH_S3C2413
75 bool
76 help
77 Internal node for S3C2413 version of SMDK2413, so that
78 machine_is_s3c2413() will work when MACH_SMDK2413 is
79 selected
80
81config MACH_SMDK2412
82 bool "SMDK2412"
83 select MACH_SMDK2413
84 help
85 Say Y here if you are using an SMDK2412
86
87 Note, this shares support with SMDK2413, so will automatically
88 select MACH_SMDK2413.
89
90config MACH_VSTMS
91 bool "VMSTMS"
92 select CPU_S3C2412
93 select S3C_DEV_USB_HOST
94 select S3C_DEV_NAND
95 help
96 Say Y here if you are using an VSTMS board
97
98endmenu
diff --git a/arch/arm/mach-s3c2412/Makefile b/arch/arm/mach-s3c2412/Makefile
index 7e4d95fa8a9..41a6c279fb2 100644
--- a/arch/arm/mach-s3c2412/Makefile
+++ b/arch/arm/mach-s3c2412/Makefile
@@ -9,16 +9,4 @@ obj-m :=
9obj-n := 9obj-n :=
10obj- := 10obj- :=
11 11
12obj-$(CONFIG_CPU_S3C2412) += s3c2412.o
13obj-$(CONFIG_CPU_S3C2412) += irq.o
14obj-$(CONFIG_CPU_S3C2412) += clock.o
15obj-$(CONFIG_S3C2412_DMA) += dma.o
16obj-$(CONFIG_S3C2412_PM) += pm.o
17obj-$(CONFIG_S3C2412_PM_SLEEP) += sleep.o
18obj-$(CONFIG_S3C2412_CPUFREQ) += cpu-freq.o 12obj-$(CONFIG_S3C2412_CPUFREQ) += cpu-freq.o
19
20# Machine support
21
22obj-$(CONFIG_MACH_JIVE) += mach-jive.o
23obj-$(CONFIG_MACH_SMDK2413) += mach-smdk2413.o
24obj-$(CONFIG_MACH_VSTMS) += mach-vstms.o
diff --git a/arch/arm/mach-s3c2416/Kconfig b/arch/arm/mach-s3c2416/Kconfig
deleted file mode 100644
index 84c7b03e5a3..00000000000
--- a/arch/arm/mach-s3c2416/Kconfig
+++ /dev/null
@@ -1,60 +0,0 @@
1# arch/arm/mach-s3c2416/Kconfig
2#
3# Copyright 2009 Yauhen Kharuzhy <jekhor@gmail.com>
4#
5# Licensed under GPLv2
6
7# note, this also supports the S3C2450 which is so similar it has the same
8# ID code as the S3C2416.
9
10config CPU_S3C2416
11 bool
12 depends on ARCH_S3C2410
13 select CPU_ARM926T
14 select S3C2416_DMA if S3C2410_DMA
15 select CPU_LLSERIAL_S3C2440
16 select SAMSUNG_CLKSRC
17 select S3C2443_CLOCK
18 help
19 Support for the S3C2416 SoC from the S3C24XX line
20
21config S3C2416_DMA
22 bool
23 depends on CPU_S3C2416
24 help
25 Internal config node for S3C2416 DMA support
26
27config S3C2416_PM
28 bool
29 select S3C2412_PM_SLEEP
30 help
31 Internal config node to apply S3C2416 power management
32
33config S3C2416_SETUP_SDHCI
34 bool
35 select S3C2416_SETUP_SDHCI_GPIO
36 help
37 Internal helper functions for S3C2416 based SDHCI systems
38
39config S3C2416_SETUP_SDHCI_GPIO
40 bool
41 help
42 Common setup code for SDHCI gpio.
43
44menu "S3C2416 Machines"
45
46config MACH_SMDK2416
47 bool "SMDK2416"
48 select CPU_S3C2416
49 select MACH_SMDK
50 select S3C_DEV_FB
51 select S3C_DEV_HSMMC
52 select S3C_DEV_HSMMC1
53 select S3C_DEV_NAND
54 select S3C_DEV_USB_HOST
55 select S3C2416_SETUP_SDHCI
56 select S3C2416_PM if PM
57 help
58 Say Y here if you are using an SMDK2416
59
60endmenu
diff --git a/arch/arm/mach-s3c2416/Makefile b/arch/arm/mach-s3c2416/Makefile
deleted file mode 100644
index ca0cd227f87..00000000000
--- a/arch/arm/mach-s3c2416/Makefile
+++ /dev/null
@@ -1,22 +0,0 @@
1# arch/arm/mach-s3c2416/Makefile
2#
3# Copyright 2009 Yauhen Kharuzhy <jekhor@gmail.com>
4#
5# Licensed under GPLv2
6
7obj-y :=
8obj-m :=
9obj-n :=
10obj- :=
11
12obj-$(CONFIG_CPU_S3C2416) += s3c2416.o clock.o
13obj-$(CONFIG_CPU_S3C2416) += irq.o
14obj-$(CONFIG_S3C2416_PM) += pm.o
15#obj-$(CONFIG_S3C2416_DMA) += dma.o
16
17# Device setup
18obj-$(CONFIG_S3C2416_SETUP_SDHCI_GPIO) += setup-sdhci-gpio.o
19
20# Machine support
21
22obj-$(CONFIG_MACH_SMDK2416) += mach-smdk2416.o
diff --git a/arch/arm/mach-s3c2440/Kconfig b/arch/arm/mach-s3c2440/Kconfig
index 914e620f125..ece7a10fe3c 100644
--- a/arch/arm/mach-s3c2440/Kconfig
+++ b/arch/arm/mach-s3c2440/Kconfig
@@ -2,35 +2,6 @@
2# 2#
3# Licensed under GPLv2 3# Licensed under GPLv2
4 4
5config CPU_S3C2440
6 bool
7 select CPU_ARM920T
8 select S3C2410_CLOCK
9 select S3C2410_PM if PM
10 select S3C2440_DMA if S3C2410_DMA
11 select CPU_S3C244X
12 select CPU_LLSERIAL_S3C2440
13 help
14 Support for S3C2440 Samsung Mobile CPU based systems.
15
16config CPU_S3C2442
17 bool
18 select CPU_ARM920T
19 select S3C2410_CLOCK
20 select S3C2410_PM if PM
21 select CPU_S3C244X
22 select CPU_LLSERIAL_S3C2440
23 help
24 Support for S3C2442 Samsung Mobile CPU based systems.
25
26config CPU_S3C244X
27 bool
28 depends on CPU_S3C2440 || CPU_S3C2442
29 help
30 Support for S3C2440 and S3C2442 Samsung Mobile CPU based systems.
31
32
33
34config S3C2440_CPUFREQ 5config S3C2440_CPUFREQ
35 bool "S3C2440/S3C2442 CPU Frequency scaling support" 6 bool "S3C2440/S3C2442 CPU Frequency scaling support"
36 depends on CPU_FREQ_S3C24XX && (CPU_S3C2440 || CPU_S3C2442) 7 depends on CPU_FREQ_S3C24XX && (CPU_S3C2440 || CPU_S3C2442)
@@ -64,139 +35,3 @@ config S3C2440_PLL_16934400
64 default y if CPU_FREQ_S3C24XX_PLL 35 default y if CPU_FREQ_S3C24XX_PLL
65 help 36 help
66 PLL tables for S3C2440 or S3C2442 CPUs with 16.934MHz crystals. 37 PLL tables for S3C2440 or S3C2442 CPUs with 16.934MHz crystals.
67
68config S3C2440_DMA
69 bool
70 depends on CPU_S3C2440
71 help
72 Support for S3C2440 specific DMA code5A
73
74menu "S3C2440 and S3C2442 Machines"
75
76config MACH_ANUBIS
77 bool "Simtec Electronics ANUBIS"
78 select CPU_S3C2440
79 select S3C24XX_DCLK
80 select PM_SIMTEC if PM
81 select HAVE_PATA_PLATFORM
82 select S3C24XX_GPIO_EXTRA64
83 select S3C2440_XTAL_12000000
84 select S3C_DEV_USB_HOST
85 help
86 Say Y here if you are using the Simtec Electronics ANUBIS
87 development system
88
89config MACH_NEO1973_GTA02
90 bool "Openmoko GTA02 / Freerunner phone"
91 select CPU_S3C2442
92 select MFD_PCF50633
93 select PCF50633_GPIO
94 select I2C
95 select POWER_SUPPLY
96 select MACH_NEO1973
97 select S3C2410_PWM
98 select S3C_DEV_USB_HOST
99 help
100 Say Y here if you are using the Openmoko GTA02 / Freerunner GSM Phone
101
102config MACH_OSIRIS
103 bool "Simtec IM2440D20 (OSIRIS) module"
104 select CPU_S3C2440
105 select S3C24XX_DCLK
106 select PM_SIMTEC if PM
107 select S3C24XX_GPIO_EXTRA128
108 select S3C2440_XTAL_12000000
109 select S3C2410_IOTIMING if S3C2440_CPUFREQ
110 select S3C_DEV_USB_HOST
111 select S3C_DEV_NAND
112 help
113 Say Y here if you are using the Simtec IM2440D20 module, also
114 known as the Osiris.
115
116config MACH_OSIRIS_DVS
117 tristate "Simtec IM2440D20 (OSIRIS) Dynamic Voltage Scaling driver"
118 depends on MACH_OSIRIS
119 select TPS65010
120 help
121 Say Y/M here if you want to have dynamic voltage scaling support
122 on the Simtec IM2440D20 (OSIRIS) module via the TPS65011.
123
124 The DVS driver alters the voltage supplied to the ARM core
125 depending on the frequency it is running at. The driver itself
126 does not do any of the frequency alteration, which is left up
127 to the cpufreq driver.
128
129config MACH_RX3715
130 bool "HP iPAQ rx3715"
131 select CPU_S3C2440
132 select S3C2440_XTAL_16934400
133 select PM_H1940 if PM
134 select S3C_DEV_NAND
135 help
136 Say Y here if you are using the HP iPAQ rx3715.
137
138config ARCH_S3C2440
139 bool "SMDK2440"
140 select CPU_S3C2440
141 select S3C2440_XTAL_16934400
142 select MACH_SMDK
143 select S3C_DEV_USB_HOST
144 select S3C_DEV_NAND
145 help
146 Say Y here if you are using the SMDK2440.
147
148config MACH_NEXCODER_2440
149 bool "NexVision NEXCODER 2440 Light Board"
150 select CPU_S3C2440
151 select S3C2440_XTAL_12000000
152 select S3C_DEV_USB_HOST
153 select S3C_DEV_NAND
154 help
155 Say Y here if you are using the Nex Vision NEXCODER 2440 Light Board
156
157config SMDK2440_CPU2440
158 bool "SMDK2440 with S3C2440 CPU module"
159 default y if ARCH_S3C2440
160 select S3C2440_XTAL_16934400
161 select CPU_S3C2440
162
163config SMDK2440_CPU2442
164 bool "SMDM2440 with S3C2442 CPU module"
165 select CPU_S3C2442
166
167config MACH_AT2440EVB
168 bool "Avantech AT2440EVB development board"
169 select CPU_S3C2440
170 select S3C_DEV_USB_HOST
171 select S3C_DEV_NAND
172 help
173 Say Y here if you are using the AT2440EVB development board
174
175config MACH_MINI2440
176 bool "MINI2440 development board"
177 select CPU_S3C2440
178 select EEPROM_AT24
179 select NEW_LEDS
180 select LEDS_CLASS
181 select LEDS_TRIGGER
182 select LEDS_TRIGGER_BACKLIGHT
183 select S3C_DEV_NAND
184 select S3C_DEV_USB_HOST
185 help
186 Say Y here to select support for the MINI2440. Is a 10cm x 10cm board
187 available via various sources. It can come with a 3.5" or 7" touch LCD.
188
189config MACH_RX1950
190 bool "HP iPAQ rx1950"
191 select CPU_S3C2442
192 select S3C24XX_DCLK
193 select PM_H1940 if PM
194 select I2C
195 select S3C2410_PWM
196 select S3C_DEV_NAND
197 select S3C2410_IOTIMING if S3C2440_CPUFREQ
198 select S3C2440_XTAL_16934400
199 help
200 Say Y here if you're using HP iPAQ rx1950
201
202endmenu
diff --git a/arch/arm/mach-s3c2440/Makefile b/arch/arm/mach-s3c2440/Makefile
index d5440fa34b0..c4609243981 100644
--- a/arch/arm/mach-s3c2440/Makefile
+++ b/arch/arm/mach-s3c2440/Makefile
@@ -9,33 +9,9 @@ obj-m :=
9obj-n := 9obj-n :=
10obj- := 10obj- :=
11 11
12obj-$(CONFIG_CPU_S3C2440) += s3c2440.o dsc.o 12obj-$(CONFIG_CPU_S3C2440) += dsc.o
13obj-$(CONFIG_CPU_S3C2442) += s3c2442.o
14 13
15obj-$(CONFIG_CPU_S3C2440) += irq.o
16obj-$(CONFIG_CPU_S3C2440) += clock.o
17obj-$(CONFIG_S3C2440_DMA) += dma.o
18
19obj-$(CONFIG_CPU_S3C244X) += s3c244x.o
20obj-$(CONFIG_CPU_S3C244X) += s3c244x-irq.o
21obj-$(CONFIG_CPU_S3C244X) += s3c244x-clock.o
22obj-$(CONFIG_S3C2440_CPUFREQ) += s3c2440-cpufreq.o 14obj-$(CONFIG_S3C2440_CPUFREQ) += s3c2440-cpufreq.o
23 15
24obj-$(CONFIG_S3C2440_PLL_12000000) += s3c2440-pll-12000000.o 16obj-$(CONFIG_S3C2440_PLL_12000000) += s3c2440-pll-12000000.o
25obj-$(CONFIG_S3C2440_PLL_16934400) += s3c2440-pll-16934400.o 17obj-$(CONFIG_S3C2440_PLL_16934400) += s3c2440-pll-16934400.o
26
27# Machine support
28
29obj-$(CONFIG_MACH_ANUBIS) += mach-anubis.o
30obj-$(CONFIG_MACH_OSIRIS) += mach-osiris.o
31obj-$(CONFIG_MACH_RX3715) += mach-rx3715.o
32obj-$(CONFIG_ARCH_S3C2440) += mach-smdk2440.o
33obj-$(CONFIG_MACH_NEXCODER_2440) += mach-nexcoder.o
34obj-$(CONFIG_MACH_AT2440EVB) += mach-at2440evb.o
35obj-$(CONFIG_MACH_MINI2440) += mach-mini2440.o
36obj-$(CONFIG_MACH_NEO1973_GTA02) += mach-gta02.o
37obj-$(CONFIG_MACH_RX1950) += mach-rx1950.o
38
39# extra machine support
40
41obj-$(CONFIG_MACH_OSIRIS_DVS) += mach-osiris-dvs.o
diff --git a/arch/arm/mach-s3c2440/common.h b/arch/arm/mach-s3c2440/common.h
deleted file mode 100644
index 0c1eb1dfc53..00000000000
--- a/arch/arm/mach-s3c2440/common.h
+++ /dev/null
@@ -1,17 +0,0 @@
1/*
2 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
3 * http://www.samsung.com
4 *
5 * Common Header for S3C2440 machines
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#ifndef __ARCH_ARM_MACH_S3C2440_COMMON_H
13#define __ARCH_ARM_MACH_S3C2440_COMMON_H
14
15void s3c244x_restart(char mode, const char *cmd);
16
17#endif /* __ARCH_ARM_MACH_S3C2440_COMMON_H */
diff --git a/arch/arm/mach-s3c2443/Kconfig b/arch/arm/mach-s3c2443/Kconfig
deleted file mode 100644
index 8814031516c..00000000000
--- a/arch/arm/mach-s3c2443/Kconfig
+++ /dev/null
@@ -1,32 +0,0 @@
1# Copyright 2007 Simtec Electronics
2#
3# Licensed under GPLv2
4
5config CPU_S3C2443
6 bool
7 depends on ARCH_S3C2410
8 select CPU_ARM920T
9 select S3C2443_DMA if S3C2410_DMA
10 select CPU_LLSERIAL_S3C2440
11 select SAMSUNG_CLKSRC
12 select S3C2443_CLOCK
13 help
14 Support for the S3C2443 SoC from the S3C24XX line
15
16config S3C2443_DMA
17 bool
18 depends on CPU_S3C2443
19 help
20 Internal config node for S3C2443 DMA support
21
22menu "S3C2443 Machines"
23
24config MACH_SMDK2443
25 bool "SMDK2443"
26 select CPU_S3C2443
27 select MACH_SMDK
28 select S3C_DEV_HSMMC1
29 help
30 Say Y here if you are using an SMDK2443
31
32endmenu
diff --git a/arch/arm/mach-s3c2443/Makefile b/arch/arm/mach-s3c2443/Makefile
deleted file mode 100644
index d1843c9eb8b..00000000000
--- a/arch/arm/mach-s3c2443/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
1# arch/arm/mach-s3c2443/Makefile
2#
3# Copyright 2007 Simtec Electronics
4#
5# Licensed under GPLv2
6
7obj-y :=
8obj-m :=
9obj-n :=
10obj- :=
11
12obj-$(CONFIG_CPU_S3C2443) += s3c2443.o
13obj-$(CONFIG_CPU_S3C2443) += irq.o
14obj-$(CONFIG_CPU_S3C2443) += clock.o
15
16obj-$(CONFIG_S3C2443_DMA) += dma.o
17
18# Machine support
19
20obj-$(CONFIG_MACH_SMDK2443) += mach-smdk2443.o
diff --git a/arch/arm/mach-s3c24xx/Kconfig b/arch/arm/mach-s3c24xx/Kconfig
new file mode 100644
index 00000000000..0f3a327ebca
--- /dev/null
+++ b/arch/arm/mach-s3c24xx/Kconfig
@@ -0,0 +1,538 @@
1# arch/arm/mach-s3c24xx/Kconfig
2#
3# Copyright (c) 2012 Samsung Electronics Co., Ltd.
4# http://www.samsung.com/
5#
6# Copyright 2007 Simtec Electronics
7#
8# Licensed under GPLv2
9
10if ARCH_S3C24XX
11
12menu "SAMSUNG S3C24XX SoCs Support"
13
14comment "S3C24XX SoCs"
15
16config CPU_S3C2410
17 bool "SAMSUNG S3C2410"
18 default y
19 select CPU_ARM920T
20 select S3C2410_CLOCK
21 select CPU_LLSERIAL_S3C2410
22 select S3C2410_PM if PM
23 select S3C2410_CPUFREQ if CPU_FREQ_S3C24XX
24 help
25 Support for S3C2410 and S3C2410A family from the S3C24XX line
26 of Samsung Mobile CPUs.
27
28config CPU_S3C2412
29 bool "SAMSUNG S3C2412"
30 depends on ARCH_S3C24XX
31 select CPU_ARM926T
32 select CPU_LLSERIAL_S3C2440
33 select S3C2412_PM if PM
34 select S3C2412_DMA if S3C24XX_DMA
35 help
36 Support for the S3C2412 and S3C2413 SoCs from the S3C24XX line
37
38config CPU_S3C2416
39 bool "SAMSUNG S3C2416/S3C2450"
40 depends on ARCH_S3C24XX
41 select CPU_ARM926T
42 select CPU_LLSERIAL_S3C2440
43 select SAMSUNG_CLKSRC
44 select S3C2443_COMMON
45 select S3C2443_DMA if S3C24XX_DMA
46 select S3C2416_PM if PM
47 help
48 Support for the S3C2416 SoC from the S3C24XX line
49
50config CPU_S3C2440
51 bool "SAMSUNG S3C2440"
52 select CPU_ARM920T
53 select CPU_LLSERIAL_S3C2440
54 select S3C2410_CLOCK
55 select S3C2410_PM if PM
56 select S3C2440_DMA if S3C24XX_DMA
57 help
58 Support for S3C2440 Samsung Mobile CPU based systems.
59
60config CPU_S3C2442
61 bool "SAMSUNG S3C2442"
62 select CPU_ARM920T
63 select CPU_LLSERIAL_S3C2440
64 select S3C2410_CLOCK
65 select S3C2410_PM if PM
66 help
67 Support for S3C2442 Samsung Mobile CPU based systems.
68
69config CPU_S3C244X
70 def_bool y
71 depends on CPU_S3C2440 || CPU_S3C2442
72
73config CPU_S3C2443
74 bool "SAMSUNG S3C2443"
75 depends on ARCH_S3C24XX
76 select CPU_ARM920T
77 select CPU_LLSERIAL_S3C2440
78 select SAMSUNG_CLKSRC
79 select S3C2443_COMMON
80 select S3C2443_DMA if S3C24XX_DMA
81 help
82 Support for the S3C2443 SoC from the S3C24XX line
83
84# common code
85
86config S3C24XX_SMDK
87 bool
88 help
89 Common machine code for SMDK2410 and SMDK2440
90
91config S3C24XX_SIMTEC_AUDIO
92 bool
93 depends on (ARCH_BAST || MACH_VR1000 || MACH_OSIRIS || MACH_ANUBIS)
94 default y
95 help
96 Add audio devices for common Simtec S3C24XX boards
97
98config S3C24XX_SIMTEC_PM
99 bool
100 help
101 Common power management code for systems that are
102 compatible with the Simtec style of power management
103
104config S3C24XX_SIMTEC_USB
105 bool
106 help
107 USB management code for common Simtec S3C24XX boards
108
109config S3C24XX_SETUP_TS
110 bool
111 help
112 Compile in platform device definition for Samsung TouchScreen.
113
114# cpu-specific sections
115
116if CPU_S3C2410
117
118config S3C2410_DMA
119 bool
120 depends on S3C24XX_DMA && (CPU_S3C2410 || CPU_S3C2442)
121 default y if CPU_S3C2410 || CPU_S3C2442
122 help
123 DMA device selection for S3C2410 and compatible CPUs
124
125config S3C2410_PM
126 bool
127 help
128 Power Management code common to S3C2410 and better
129
130config S3C24XX_SIMTEC_NOR
131 bool
132 help
133 Internal node to specify machine has simtec NOR mapping
134
135config MACH_BAST_IDE
136 bool
137 select HAVE_PATA_PLATFORM
138 help
139 Internal node for machines with an BAST style IDE
140 interface
141
142comment "S3C2410 Boards"
143
144#
145# The "S3C2410 Boards" list is ordered alphabetically by option text.
146# (without ARCH_ or MACH_)
147#
148
149config MACH_AML_M5900
150 bool "AML M5900 Series"
151 select S3C24XX_SIMTEC_PM if PM
152 select S3C_DEV_USB_HOST
153 help
154 Say Y here if you are using the American Microsystems M5900 Series
155 <http://www.amltd.com>
156
157config ARCH_BAST
158 bool "Simtec Electronics BAST (EB2410ITX)"
159 select S3C2410_IOTIMING if S3C2410_CPUFREQ
160 select S3C24XX_SIMTEC_PM if PM
161 select S3C24XX_SIMTEC_NOR
162 select S3C24XX_SIMTEC_USB
163 select MACH_BAST_IDE
164 select S3C24XX_DCLK
165 select ISA
166 select S3C_DEV_HWMON
167 select S3C_DEV_USB_HOST
168 select S3C_DEV_NAND
169 help
170 Say Y here if you are using the Simtec Electronics EB2410ITX
171 development board (also known as BAST)
172
173config BAST_PC104_IRQ
174 bool "BAST PC104 IRQ support"
175 depends on ARCH_BAST
176 default y
177 help
178 Say Y here to enable the PC104 IRQ routing on the
179 Simtec BAST (EB2410ITX)
180
181config ARCH_H1940
182 bool "IPAQ H1940"
183 select PM_H1940 if PM
184 select S3C_DEV_USB_HOST
185 select S3C_DEV_NAND
186 select S3C24XX_SETUP_TS
187 help
188 Say Y here if you are using the HP IPAQ H1940
189
190config H1940BT
191 tristate "Control the state of H1940 bluetooth chip"
192 depends on ARCH_H1940
193 select RFKILL
194 help
195 This is a simple driver that is able to control
196 the state of built in bluetooth chip on h1940.
197
198config PM_H1940
199 bool
200 help
201 Internal node for H1940 and related PM
202
203config MACH_N30
204 bool "Acer N30 family"
205 select MACH_N35
206 select S3C_DEV_USB_HOST
207 select S3C_DEV_NAND
208 help
209 Say Y here if you want suppt for the Acer N30, Acer N35,
210 Navman PiN570, Yakumo AlphaX or Airis NC05 PDAs.
211
212config MACH_OTOM
213 bool "NexVision OTOM Board"
214 select S3C_DEV_USB_HOST
215 select S3C_DEV_NAND
216 help
217 Say Y here if you are using the Nex Vision OTOM board
218
219config MACH_QT2410
220 bool "QT2410"
221 select S3C_DEV_USB_HOST
222 select S3C_DEV_NAND
223 help
224 Say Y here if you are using the Armzone QT2410
225
226config ARCH_SMDK2410
227 bool "SMDK2410/A9M2410"
228 select S3C24XX_SMDK
229 help
230 Say Y here if you are using the SMDK2410 or the derived module A9M2410
231 <http://www.fsforth.de>
232
233config MACH_TCT_HAMMER
234 bool "TCT Hammer Board"
235 select S3C_DEV_USB_HOST
236 help
237 Say Y here if you are using the TinCanTools Hammer Board
238 <http://www.tincantools.com>
239
240config MACH_VR1000
241 bool "Thorcom VR1000"
242 select S3C24XX_SIMTEC_PM if PM
243 select S3C24XX_DCLK
244 select S3C24XX_SIMTEC_NOR
245 select MACH_BAST_IDE
246 select S3C_DEV_USB_HOST
247 select S3C24XX_SIMTEC_USB
248 help
249 Say Y here if you are using the Thorcom VR1000 board.
250
251endif # CPU_S3C2410
252
253config S3C2412_PM_SLEEP
254 bool
255 help
256 Internal config node to apply sleep for S3C2412 power management.
257 Can be selected by another SoCs such as S3C2416 with similar
258 sleep procedure.
259
260if CPU_S3C2412
261
262config CPU_S3C2412_ONLY
263 bool
264 depends on ARCH_S3C24XX && !CPU_S3C2410 && \
265 !CPU_S3C2416 && !CPU_S3C2440 && !CPU_S3C2442 && \
266 !CPU_S3C2443 && CPU_S3C2412
267 default y
268
269config S3C2412_DMA
270 bool
271 help
272 Internal config node for S3C2412 DMA support
273
274config S3C2412_PM
275 bool
276 help
277 Internal config node to apply S3C2412 power management
278
279comment "S3C2412 Boards"
280
281#
282# The "S3C2412 Boards" list is ordered alphabetically by option text.
283# (without ARCH_ or MACH_)
284#
285
286config MACH_JIVE
287 bool "Logitech Jive"
288 select S3C_DEV_USB_HOST
289 select S3C_DEV_NAND
290 help
291 Say Y here if you are using the Logitech Jive.
292
293config MACH_JIVE_SHOW_BOOTLOADER
294 bool "Allow access to bootloader partitions in MTD (EXPERIMENTAL)"
295 depends on MACH_JIVE && EXPERIMENTAL
296
297config MACH_S3C2413
298 bool
299 help
300 Internal node for S3C2413 version of SMDK2413, so that
301 machine_is_s3c2413() will work when MACH_SMDK2413 is
302 selected
303
304config MACH_SMDK2412
305 bool "SMDK2412"
306 select MACH_SMDK2413
307 help
308 Say Y here if you are using an SMDK2412
309
310 Note, this shares support with SMDK2413, so will automatically
311 select MACH_SMDK2413.
312
313config MACH_SMDK2413
314 bool "SMDK2413"
315 select MACH_S3C2413
316 select S3C24XX_SMDK
317 select S3C_DEV_USB_HOST
318 select S3C_DEV_NAND
319 help
320 Say Y here if you are using an SMDK2413
321
322config MACH_VSTMS
323 bool "VMSTMS"
324 select S3C_DEV_USB_HOST
325 select S3C_DEV_NAND
326 help
327 Say Y here if you are using an VSTMS board
328
329endif # CPU_S3C2412
330
331if CPU_S3C2416
332
333config S3C2416_PM
334 bool
335 select S3C2412_PM_SLEEP
336 help
337 Internal config node to apply S3C2416 power management
338
339config S3C2416_SETUP_SDHCI
340 bool
341 select S3C2416_SETUP_SDHCI_GPIO
342 help
343 Internal helper functions for S3C2416 based SDHCI systems
344
345config S3C2416_SETUP_SDHCI_GPIO
346 bool
347 help
348 Common setup code for SDHCI gpio.
349
350comment "S3C2416 Boards"
351
352config MACH_SMDK2416
353 bool "SMDK2416"
354 select S3C24XX_SMDK
355 select S3C_DEV_FB
356 select S3C_DEV_HSMMC
357 select S3C_DEV_HSMMC1
358 select S3C_DEV_NAND
359 select S3C_DEV_USB_HOST
360 select S3C2416_SETUP_SDHCI
361 help
362 Say Y here if you are using an SMDK2416
363
364endif # CPU_S3C2416
365
366if CPU_S3C2440
367
368config S3C2440_DMA
369 bool
370 help
371 Support for S3C2440 specific DMA code5A
372
373comment "S3C2440 Boards"
374
375#
376# The "S3C2440 Boards" list is ordered alphabetically by option text.
377# (without ARCH_ or MACH_)
378#
379
380config MACH_ANUBIS
381 bool "Simtec Electronics ANUBIS"
382 select S3C24XX_DCLK
383 select S3C24XX_SIMTEC_PM if PM
384 select HAVE_PATA_PLATFORM
385 select S3C24XX_GPIO_EXTRA64
386 select S3C2440_XTAL_12000000
387 select S3C_DEV_USB_HOST
388 help
389 Say Y here if you are using the Simtec Electronics ANUBIS
390 development system
391
392config MACH_AT2440EVB
393 bool "Avantech AT2440EVB development board"
394 select S3C_DEV_USB_HOST
395 select S3C_DEV_NAND
396 help
397 Say Y here if you are using the AT2440EVB development board
398
399config MACH_MINI2440
400 bool "MINI2440 development board"
401 select EEPROM_AT24
402 select NEW_LEDS
403 select LEDS_CLASS
404 select LEDS_TRIGGER
405 select LEDS_TRIGGER_BACKLIGHT
406 select S3C_DEV_NAND
407 select S3C_DEV_USB_HOST
408 help
409 Say Y here to select support for the MINI2440. Is a 10cm x 10cm board
410 available via various sources. It can come with a 3.5" or 7" touch LCD.
411
412config MACH_NEXCODER_2440
413 bool "NexVision NEXCODER 2440 Light Board"
414 select S3C2440_XTAL_12000000
415 select S3C_DEV_USB_HOST
416 select S3C_DEV_NAND
417 help
418 Say Y here if you are using the Nex Vision NEXCODER 2440 Light Board
419
420config MACH_OSIRIS
421 bool "Simtec IM2440D20 (OSIRIS) module"
422 select S3C24XX_DCLK
423 select S3C24XX_SIMTEC_PM if PM
424 select S3C24XX_GPIO_EXTRA128
425 select S3C2440_XTAL_12000000
426 select S3C2410_IOTIMING if S3C2440_CPUFREQ
427 select S3C_DEV_USB_HOST
428 select S3C_DEV_NAND
429 help
430 Say Y here if you are using the Simtec IM2440D20 module, also
431 known as the Osiris.
432
433config MACH_OSIRIS_DVS
434 tristate "Simtec IM2440D20 (OSIRIS) Dynamic Voltage Scaling driver"
435 depends on MACH_OSIRIS
436 select TPS65010
437 help
438 Say Y/M here if you want to have dynamic voltage scaling support
439 on the Simtec IM2440D20 (OSIRIS) module via the TPS65011.
440
441 The DVS driver alters the voltage supplied to the ARM core
442 depending on the frequency it is running at. The driver itself
443 does not do any of the frequency alteration, which is left up
444 to the cpufreq driver.
445
446config MACH_RX3715
447 bool "HP iPAQ rx3715"
448 select S3C2440_XTAL_16934400
449 select PM_H1940 if PM
450 select S3C_DEV_NAND
451 help
452 Say Y here if you are using the HP iPAQ rx3715.
453
454config ARCH_S3C2440
455 bool "SMDK2440"
456 select S3C2440_XTAL_16934400
457 select S3C24XX_SMDK
458 select S3C_DEV_USB_HOST
459 select S3C_DEV_NAND
460 help
461 Say Y here if you are using the SMDK2440.
462
463config SMDK2440_CPU2440
464 bool "SMDK2440 with S3C2440 CPU module"
465 default y if ARCH_S3C2440
466 select S3C2440_XTAL_16934400
467
468endif # CPU_S3C2440
469
470if CPU_S3C2442
471
472comment "S3C2442 Boards"
473
474#
475# The "S3C2442 Boards" list is ordered alphabetically by option text.
476# (without ARCH_ or MACH_)
477#
478
479config MACH_NEO1973_GTA02
480 bool "Openmoko GTA02 / Freerunner phone"
481 select MFD_PCF50633
482 select PCF50633_GPIO
483 select I2C
484 select POWER_SUPPLY
485 select MACH_NEO1973
486 select S3C2410_PWM
487 select S3C_DEV_USB_HOST
488 help
489 Say Y here if you are using the Openmoko GTA02 / Freerunner GSM Phone
490
491config MACH_RX1950
492 bool "HP iPAQ rx1950"
493 select S3C24XX_DCLK
494 select PM_H1940 if PM
495 select I2C
496 select S3C2410_PWM
497 select S3C_DEV_NAND
498 select S3C2410_IOTIMING if S3C2440_CPUFREQ
499 select S3C2440_XTAL_16934400
500 help
501 Say Y here if you're using HP iPAQ rx1950
502
503config SMDK2440_CPU2442
504 bool "SMDM2440 with S3C2442 CPU module"
505
506endif # CPU_S3C2440
507
508if CPU_S3C2443 || CPU_S3C2416
509
510config S3C2443_COMMON
511 bool
512 help
513 Common code for the S3C2443 and similar processors, which includes
514 the S3C2416 and S3C2450.
515
516config S3C2443_DMA
517 bool
518 help
519 Internal config node for S3C2443 DMA support
520
521endif # CPU_S3C2443 || CPU_S3C2416
522
523if CPU_S3C2443
524
525comment "S3C2443 Boards"
526
527config MACH_SMDK2443
528 bool "SMDK2443"
529 select S3C24XX_SMDK
530 select S3C_DEV_HSMMC1
531 help
532 Say Y here if you are using an SMDK2443
533
534endif # CPU_S3C2443
535
536endmenu # SAMSUNG S3C24XX SoCs Support
537
538endif # ARCH_S3C24XX
diff --git a/arch/arm/mach-s3c24xx/Makefile b/arch/arm/mach-s3c24xx/Makefile
new file mode 100644
index 00000000000..3518fe812d5
--- /dev/null
+++ b/arch/arm/mach-s3c24xx/Makefile
@@ -0,0 +1,95 @@
1# arch/arm/mach-s3c24xx/Makefile
2#
3# Copyright (c) 2012 Samsung Electronics Co., Ltd.
4# http://www.samsung.com/
5#
6# Copyright 2007 Simtec Electronics
7#
8# Licensed under GPLv2
9
10obj-y :=
11obj-m :=
12obj-n :=
13obj- :=
14
15# core
16
17obj-$(CONFIG_CPU_S3C2410) += s3c2410.o
18obj-$(CONFIG_S3C2410_DMA) += dma-s3c2410.o
19obj-$(CONFIG_S3C2410_PM) += pm-s3c2410.o sleep-s3c2410.o
20
21obj-$(CONFIG_CPU_S3C2412) += s3c2412.o irq-s3c2412.o clock-s3c2412.o
22obj-$(CONFIG_S3C2412_DMA) += dma-s3c2412.o
23obj-$(CONFIG_S3C2412_PM) += pm-s3c2412.o
24obj-$(CONFIG_S3C2412_PM_SLEEP) += sleep-s3c2412.o
25
26obj-$(CONFIG_CPU_S3C2416) += s3c2416.o irq-s3c2416.o clock-s3c2416.o
27obj-$(CONFIG_S3C2416_PM) += pm-s3c2416.o
28
29obj-$(CONFIG_CPU_S3C2440) += s3c2440.o irq-s3c2440.o clock-s3c2440.o
30obj-$(CONFIG_CPU_S3C2442) += s3c2442.o
31obj-$(CONFIG_CPU_S3C244X) += s3c244x.o irq-s3c244x.o clock-s3c244x.o
32obj-$(CONFIG_S3C2440_DMA) += dma-s3c2440.o
33
34obj-$(CONFIG_CPU_S3C2443) += s3c2443.o irq-s3c2443.o clock-s3c2443.o
35
36# common code
37
38obj-$(CONFIG_S3C2443_COMMON) += common-s3c2443.o
39obj-$(CONFIG_S3C2443_DMA) += dma-s3c2443.o
40
41#
42# machine support
43# following is ordered alphabetically by option text.
44#
45
46obj-$(CONFIG_MACH_AML_M5900) += mach-amlm5900.o
47obj-$(CONFIG_ARCH_BAST) += mach-bast.o
48obj-$(CONFIG_BAST_PC104_IRQ) += bast-irq.o
49obj-$(CONFIG_ARCH_H1940) += mach-h1940.o
50obj-$(CONFIG_H1940BT) += h1940-bluetooth.o
51obj-$(CONFIG_PM_H1940) += pm-h1940.o
52obj-$(CONFIG_MACH_N30) += mach-n30.o
53obj-$(CONFIG_MACH_OTOM) += mach-otom.o
54obj-$(CONFIG_MACH_QT2410) += mach-qt2410.o
55obj-$(CONFIG_ARCH_SMDK2410) += mach-smdk2410.o
56obj-$(CONFIG_MACH_TCT_HAMMER) += mach-tct_hammer.o
57obj-$(CONFIG_MACH_VR1000) += mach-vr1000.o
58
59obj-$(CONFIG_MACH_JIVE) += mach-jive.o
60obj-$(CONFIG_MACH_SMDK2413) += mach-smdk2413.o
61obj-$(CONFIG_MACH_VSTMS) += mach-vstms.o
62
63obj-$(CONFIG_MACH_SMDK2416) += mach-smdk2416.o
64
65obj-$(CONFIG_MACH_ANUBIS) += mach-anubis.o
66obj-$(CONFIG_MACH_AT2440EVB) += mach-at2440evb.o
67obj-$(CONFIG_MACH_MINI2440) += mach-mini2440.o
68obj-$(CONFIG_MACH_NEXCODER_2440) += mach-nexcoder.o
69obj-$(CONFIG_MACH_OSIRIS) += mach-osiris.o
70obj-$(CONFIG_MACH_RX3715) += mach-rx3715.o
71obj-$(CONFIG_ARCH_S3C2440) += mach-smdk2440.o
72
73obj-$(CONFIG_MACH_NEO1973_GTA02) += mach-gta02.o
74obj-$(CONFIG_MACH_RX1950) += mach-rx1950.o
75
76obj-$(CONFIG_MACH_SMDK2443) += mach-smdk2443.o
77
78# common bits of machine support
79
80obj-$(CONFIG_S3C24XX_SMDK) += common-smdk.o
81obj-$(CONFIG_S3C24XX_SIMTEC_AUDIO) += simtec-audio.o
82obj-$(CONFIG_S3C24XX_SIMTEC_NOR) += simtec-nor.o
83obj-$(CONFIG_S3C24XX_SIMTEC_PM) += simtec-pm.o
84obj-$(CONFIG_S3C24XX_SIMTEC_USB) += simtec-usb.o
85
86# machine additions
87
88obj-$(CONFIG_MACH_BAST_IDE) += bast-ide.o
89obj-$(CONFIG_MACH_OSIRIS_DVS) += mach-osiris-dvs.o
90
91# device setup
92
93obj-$(CONFIG_S3C2416_SETUP_SDHCI_GPIO) += setup-sdhci-gpio.o
94obj-$(CONFIG_ARCH_S3C24XX) += setup-i2c.o
95obj-$(CONFIG_S3C24XX_SETUP_TS) += setup-ts.o
diff --git a/arch/arm/mach-s3c2410/Makefile.boot b/arch/arm/mach-s3c24xx/Makefile.boot
index 4457605ba04..4457605ba04 100644
--- a/arch/arm/mach-s3c2410/Makefile.boot
+++ b/arch/arm/mach-s3c24xx/Makefile.boot
diff --git a/arch/arm/mach-s3c2410/bast-ide.c b/arch/arm/mach-s3c24xx/bast-ide.c
index 298ececfa36..298ececfa36 100644
--- a/arch/arm/mach-s3c2410/bast-ide.c
+++ b/arch/arm/mach-s3c24xx/bast-ide.c
diff --git a/arch/arm/mach-s3c2410/bast-irq.c b/arch/arm/mach-s3c24xx/bast-irq.c
index ac7b2ad5c40..ac7b2ad5c40 100644
--- a/arch/arm/mach-s3c2410/bast-irq.c
+++ b/arch/arm/mach-s3c24xx/bast-irq.c
diff --git a/arch/arm/mach-s3c2412/clock.c b/arch/arm/mach-s3c24xx/clock-s3c2412.c
index d10b695a906..d10b695a906 100644
--- a/arch/arm/mach-s3c2412/clock.c
+++ b/arch/arm/mach-s3c24xx/clock-s3c2412.c
diff --git a/arch/arm/mach-s3c2416/clock.c b/arch/arm/mach-s3c24xx/clock-s3c2416.c
index 59f54d1d7f8..dbc9ab4aaca 100644
--- a/arch/arm/mach-s3c2416/clock.c
+++ b/arch/arm/mach-s3c24xx/clock-s3c2416.c
@@ -15,7 +15,6 @@
15#include <linux/clk.h> 15#include <linux/clk.h>
16 16
17#include <plat/s3c2416.h> 17#include <plat/s3c2416.h>
18#include <plat/s3c2443.h>
19#include <plat/clock.h> 18#include <plat/clock.h>
20#include <plat/clock-clksrc.h> 19#include <plat/clock-clksrc.h>
21#include <plat/cpu.h> 20#include <plat/cpu.h>
@@ -132,12 +131,6 @@ static struct clk hsmmc0_clk = {
132 .ctrlbit = S3C2416_HCLKCON_HSMMC0, 131 .ctrlbit = S3C2416_HCLKCON_HSMMC0,
133}; 132};
134 133
135void __init_or_cpufreq s3c2416_setup_clocks(void)
136{
137 s3c2443_common_setup_clocks(s3c2416_get_pll);
138}
139
140
141static struct clksrc_clk *clksrcs[] __initdata = { 134static struct clksrc_clk *clksrcs[] __initdata = {
142 &hsspi_eplldiv, 135 &hsspi_eplldiv,
143 &hsspi_mux, 136 &hsspi_mux,
diff --git a/arch/arm/mach-s3c2440/clock.c b/arch/arm/mach-s3c24xx/clock-s3c2440.c
index 414364eb426..414364eb426 100644
--- a/arch/arm/mach-s3c2440/clock.c
+++ b/arch/arm/mach-s3c24xx/clock-s3c2440.c
diff --git a/arch/arm/mach-s3c2443/clock.c b/arch/arm/mach-s3c24xx/clock-s3c2443.c
index 6dde2696f8f..efb3ac35956 100644
--- a/arch/arm/mach-s3c2443/clock.c
+++ b/arch/arm/mach-s3c24xx/clock-s3c2443.c
@@ -179,11 +179,6 @@ static struct clk *clks[] __initdata = {
179 &clk_hsmmc, 179 &clk_hsmmc,
180}; 180};
181 181
182void __init_or_cpufreq s3c2443_setup_clocks(void)
183{
184 s3c2443_common_setup_clocks(s3c2443_get_mpll);
185}
186
187void __init s3c2443_init_clocks(int xtal) 182void __init s3c2443_init_clocks(int xtal)
188{ 183{
189 unsigned long epllcon = __raw_readl(S3C2443_EPLLCON); 184 unsigned long epllcon = __raw_readl(S3C2443_EPLLCON);
@@ -196,8 +191,6 @@ void __init s3c2443_init_clocks(int xtal)
196 armdiv, ARRAY_SIZE(armdiv), 191 armdiv, ARRAY_SIZE(armdiv),
197 S3C2443_CLKDIV0_ARMDIV_MASK); 192 S3C2443_CLKDIV0_ARMDIV_MASK);
198 193
199 s3c2443_setup_clocks();
200
201 s3c24xx_register_clocks(clks, ARRAY_SIZE(clks)); 194 s3c24xx_register_clocks(clks, ARRAY_SIZE(clks));
202 195
203 for (ptr = 0; ptr < ARRAY_SIZE(clksrcs); ptr++) 196 for (ptr = 0; ptr < ARRAY_SIZE(clksrcs); ptr++)
diff --git a/arch/arm/mach-s3c2440/s3c244x-clock.c b/arch/arm/mach-s3c24xx/clock-s3c244x.c
index 6d9b688c442..6d9b688c442 100644
--- a/arch/arm/mach-s3c2440/s3c244x-clock.c
+++ b/arch/arm/mach-s3c24xx/clock-s3c244x.c
diff --git a/arch/arm/plat-s3c24xx/s3c2443-clock.c b/arch/arm/mach-s3c24xx/common-s3c2443.c
index 95e68190d59..460431589f3 100644
--- a/arch/arm/plat-s3c24xx/s3c2443-clock.c
+++ b/arch/arm/mach-s3c24xx/common-s3c2443.c
@@ -1,9 +1,18 @@
1/* linux/arch/arm/plat-s3c24xx/s3c2443-clock.c 1/*
2 * Common code for SoCs starting with the S3C2443
2 * 3 *
3 * Copyright (c) 2007, 2010 Simtec Electronics 4 * Copyright (c) 2007, 2010 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk> 5 * Ben Dooks <ben@simtec.co.uk>
5 * 6 *
6 * S3C2443 Clock control suport - common code 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.
7 */ 16 */
8 17
9#include <linux/init.h> 18#include <linux/init.h>
@@ -12,7 +21,6 @@
12 21
13#include <mach/regs-s3c2443-clock.h> 22#include <mach/regs-s3c2443-clock.h>
14 23
15#include <plat/s3c2443.h>
16#include <plat/clock.h> 24#include <plat/clock.h>
17#include <plat/clock-clksrc.h> 25#include <plat/clock-clksrc.h>
18#include <plat/cpu.h> 26#include <plat/cpu.h>
@@ -53,7 +61,7 @@ int s3c2443_clkcon_enable_s(struct clk *clk, int enable)
53 * elided as the EPLL can be either sourced by the XTAL or EXTCLK and as 61 * elided as the EPLL can be either sourced by the XTAL or EXTCLK and as
54 * such directly equating the two source clocks is impossible. 62 * such directly equating the two source clocks is impossible.
55 */ 63 */
56struct clk clk_mpllref = { 64static struct clk clk_mpllref = {
57 .name = "mpllref", 65 .name = "mpllref",
58 .parent = &clk_xtal, 66 .parent = &clk_xtal,
59}; 67};
@@ -160,6 +168,44 @@ static struct clk clk_prediv = {
160 }, 168 },
161}; 169};
162 170
171/* hclk divider
172 *
173 * divides the prediv and provides the hclk.
174 */
175
176static unsigned long s3c2443_hclkdiv_getrate(struct clk *clk)
177{
178 unsigned long rate = clk_get_rate(clk->parent);
179 unsigned long clkdiv0 = __raw_readl(S3C2443_CLKDIV0);
180
181 clkdiv0 &= S3C2443_CLKDIV0_HCLKDIV_MASK;
182
183 return rate / (clkdiv0 + 1);
184}
185
186static struct clk_ops clk_h_ops = {
187 .get_rate = s3c2443_hclkdiv_getrate,
188};
189
190/* pclk divider
191 *
192 * divides the hclk and provides the pclk.
193 */
194
195static unsigned long s3c2443_pclkdiv_getrate(struct clk *clk)
196{
197 unsigned long rate = clk_get_rate(clk->parent);
198 unsigned long clkdiv0 = __raw_readl(S3C2443_CLKDIV0);
199
200 clkdiv0 = ((clkdiv0 & S3C2443_CLKDIV0_HALF_PCLK) ? 1 : 0);
201
202 return rate / (clkdiv0 + 1);
203}
204
205static struct clk_ops clk_p_ops = {
206 .get_rate = s3c2443_pclkdiv_getrate,
207};
208
163/* armdiv 209/* armdiv
164 * 210 *
165 * this clock is sourced from msysclk and can have a number of 211 * this clock is sourced from msysclk and can have a number of
@@ -516,26 +562,15 @@ static struct clk hsmmc1_clk = {
516 .ctrlbit = S3C2443_HCLKCON_HSMMC, 562 .ctrlbit = S3C2443_HCLKCON_HSMMC,
517}; 563};
518 564
519static inline unsigned long s3c2443_get_hdiv(unsigned long clkcon0)
520{
521 clkcon0 &= S3C2443_CLKDIV0_HCLKDIV_MASK;
522
523 return clkcon0 + 1;
524}
525
526/* EPLLCON compatible enough to get on/off information */ 565/* EPLLCON compatible enough to get on/off information */
527 566
528void __init_or_cpufreq s3c2443_common_setup_clocks(pll_fn get_mpll) 567void __init_or_cpufreq s3c2443_common_setup_clocks(pll_fn get_mpll)
529{ 568{
530 unsigned long epllcon = __raw_readl(S3C2443_EPLLCON); 569 unsigned long epllcon = __raw_readl(S3C2443_EPLLCON);
531 unsigned long mpllcon = __raw_readl(S3C2443_MPLLCON); 570 unsigned long mpllcon = __raw_readl(S3C2443_MPLLCON);
532 unsigned long clkdiv0 = __raw_readl(S3C2443_CLKDIV0);
533 struct clk *xtal_clk; 571 struct clk *xtal_clk;
534 unsigned long xtal; 572 unsigned long xtal;
535 unsigned long pll; 573 unsigned long pll;
536 unsigned long fclk;
537 unsigned long hclk;
538 unsigned long pclk;
539 int ptr; 574 int ptr;
540 575
541 xtal_clk = clk_get(NULL, "xtal"); 576 xtal_clk = clk_get(NULL, "xtal");
@@ -544,18 +579,13 @@ void __init_or_cpufreq s3c2443_common_setup_clocks(pll_fn get_mpll)
544 579
545 pll = get_mpll(mpllcon, xtal); 580 pll = get_mpll(mpllcon, xtal);
546 clk_msysclk.clk.rate = pll; 581 clk_msysclk.clk.rate = pll;
547 582 clk_mpll.rate = pll;
548 fclk = clk_get_rate(&clk_armdiv);
549 hclk = s3c2443_prediv_getrate(&clk_prediv);
550 hclk /= s3c2443_get_hdiv(clkdiv0);
551 pclk = hclk / ((clkdiv0 & S3C2443_CLKDIV0_HALF_PCLK) ? 2 : 1);
552
553 s3c24xx_setup_clocks(fclk, hclk, pclk);
554 583
555 printk("CPU: MPLL %s %ld.%03ld MHz, cpu %ld.%03ld MHz, mem %ld.%03ld MHz, pclk %ld.%03ld MHz\n", 584 printk("CPU: MPLL %s %ld.%03ld MHz, cpu %ld.%03ld MHz, mem %ld.%03ld MHz, pclk %ld.%03ld MHz\n",
556 (mpllcon & S3C2443_PLLCON_OFF) ? "off":"on", 585 (mpllcon & S3C2443_PLLCON_OFF) ? "off" : "on",
557 print_mhz(pll), print_mhz(fclk), 586 print_mhz(pll), print_mhz(clk_get_rate(&clk_armdiv)),
558 print_mhz(hclk), print_mhz(pclk)); 587 print_mhz(clk_get_rate(&clk_h)),
588 print_mhz(clk_get_rate(&clk_p)));
559 589
560 for (ptr = 0; ptr < ARRAY_SIZE(clksrc_clks); ptr++) 590 for (ptr = 0; ptr < ARRAY_SIZE(clksrc_clks); ptr++)
561 s3c_set_clksrc(&clksrc_clks[ptr], true); 591 s3c_set_clksrc(&clksrc_clks[ptr], true);
@@ -568,7 +598,7 @@ void __init_or_cpufreq s3c2443_common_setup_clocks(pll_fn get_mpll)
568 } 598 }
569 599
570 printk("CPU: EPLL %s %ld.%03ld MHz, usb-bus %ld.%03ld MHz\n", 600 printk("CPU: EPLL %s %ld.%03ld MHz, usb-bus %ld.%03ld MHz\n",
571 (epllcon & S3C2443_PLLCON_OFF) ? "off":"on", 601 (epllcon & S3C2443_PLLCON_OFF) ? "off" : "on",
572 print_mhz(clk_get_rate(&clk_epll)), 602 print_mhz(clk_get_rate(&clk_epll)),
573 print_mhz(clk_get_rate(&clk_usb_bus))); 603 print_mhz(clk_get_rate(&clk_usb_bus)));
574} 604}
@@ -611,9 +641,13 @@ void __init s3c2443_common_init_clocks(int xtal, pll_fn get_mpll,
611 nr_armdiv = nr_divs; 641 nr_armdiv = nr_divs;
612 armdivmask = divmask; 642 armdivmask = divmask;
613 643
614 /* s3c2443 parents h and p clocks from prediv */ 644 /* s3c2443 parents h clock from prediv */
615 clk_h.parent = &clk_prediv; 645 clk_h.parent = &clk_prediv;
616 clk_p.parent = &clk_prediv; 646 clk_h.ops = &clk_h_ops;
647
648 /* and p clock from h clock */
649 clk_p.parent = &clk_h;
650 clk_p.ops = &clk_p_ops;
617 651
618 clk_usb_bus.parent = &clk_usb_bus_host.clk; 652 clk_usb_bus.parent = &clk_usb_bus_host.clk;
619 clk_epll.parent = &clk_epllref.clk; 653 clk_epll.parent = &clk_epllref.clk;
diff --git a/arch/arm/plat-s3c24xx/common-smdk.c b/arch/arm/mach-s3c24xx/common-smdk.c
index 084604be6ad..084604be6ad 100644
--- a/arch/arm/plat-s3c24xx/common-smdk.c
+++ b/arch/arm/mach-s3c24xx/common-smdk.c
diff --git a/arch/arm/mach-s3c2410/dma.c b/arch/arm/mach-s3c24xx/dma-s3c2410.c
index 4803338cf56..4803338cf56 100644
--- a/arch/arm/mach-s3c2410/dma.c
+++ b/arch/arm/mach-s3c24xx/dma-s3c2410.c
diff --git a/arch/arm/mach-s3c2412/dma.c b/arch/arm/mach-s3c24xx/dma-s3c2412.c
index 38472ac920f..38472ac920f 100644
--- a/arch/arm/mach-s3c2412/dma.c
+++ b/arch/arm/mach-s3c24xx/dma-s3c2412.c
diff --git a/arch/arm/mach-s3c2440/dma.c b/arch/arm/mach-s3c24xx/dma-s3c2440.c
index 5f0a0c8ef84..5f0a0c8ef84 100644
--- a/arch/arm/mach-s3c2440/dma.c
+++ b/arch/arm/mach-s3c24xx/dma-s3c2440.c
diff --git a/arch/arm/mach-s3c2443/dma.c b/arch/arm/mach-s3c24xx/dma-s3c2443.c
index 14224517e62..e227c472a40 100644
--- a/arch/arm/mach-s3c2443/dma.c
+++ b/arch/arm/mach-s3c24xx/dma-s3c2443.c
@@ -51,7 +51,7 @@ static struct s3c24xx_dma_map __initdata s3c2443_dma_mappings[] = {
51 .name = "xdreq1", 51 .name = "xdreq1",
52 .channels = MAP(S3C2443_DMAREQSEL_XDREQ1), 52 .channels = MAP(S3C2443_DMAREQSEL_XDREQ1),
53 }, 53 },
54 [DMACH_SDI] = { 54 [DMACH_SDI] = { /* only on S3C2443 */
55 .name = "sdi", 55 .name = "sdi",
56 .channels = MAP(S3C2443_DMAREQSEL_SDI), 56 .channels = MAP(S3C2443_DMAREQSEL_SDI),
57 }, 57 },
@@ -59,7 +59,7 @@ static struct s3c24xx_dma_map __initdata s3c2443_dma_mappings[] = {
59 .name = "spi0", 59 .name = "spi0",
60 .channels = MAP(S3C2443_DMAREQSEL_SPI0TX), 60 .channels = MAP(S3C2443_DMAREQSEL_SPI0TX),
61 }, 61 },
62 [DMACH_SPI1] = { 62 [DMACH_SPI1] = { /* only on S3C2443/S3C2450 */
63 .name = "spi1", 63 .name = "spi1",
64 .channels = MAP(S3C2443_DMAREQSEL_SPI1TX), 64 .channels = MAP(S3C2443_DMAREQSEL_SPI1TX),
65 }, 65 },
@@ -71,11 +71,11 @@ static struct s3c24xx_dma_map __initdata s3c2443_dma_mappings[] = {
71 .name = "uart1", 71 .name = "uart1",
72 .channels = MAP(S3C2443_DMAREQSEL_UART1_0), 72 .channels = MAP(S3C2443_DMAREQSEL_UART1_0),
73 }, 73 },
74 [DMACH_UART2] = { 74 [DMACH_UART2] = {
75 .name = "uart2", 75 .name = "uart2",
76 .channels = MAP(S3C2443_DMAREQSEL_UART2_0), 76 .channels = MAP(S3C2443_DMAREQSEL_UART2_0),
77 }, 77 },
78 [DMACH_UART3] = { 78 [DMACH_UART3] = {
79 .name = "uart3", 79 .name = "uart3",
80 .channels = MAP(S3C2443_DMAREQSEL_UART3_0), 80 .channels = MAP(S3C2443_DMAREQSEL_UART3_0),
81 }, 81 },
@@ -87,11 +87,11 @@ static struct s3c24xx_dma_map __initdata s3c2443_dma_mappings[] = {
87 .name = "uart1", 87 .name = "uart1",
88 .channels = MAP(S3C2443_DMAREQSEL_UART1_1), 88 .channels = MAP(S3C2443_DMAREQSEL_UART1_1),
89 }, 89 },
90 [DMACH_UART2_SRC2] = { 90 [DMACH_UART2_SRC2] = {
91 .name = "uart2", 91 .name = "uart2",
92 .channels = MAP(S3C2443_DMAREQSEL_UART2_1), 92 .channels = MAP(S3C2443_DMAREQSEL_UART2_1),
93 }, 93 },
94 [DMACH_UART3_SRC2] = { 94 [DMACH_UART3_SRC2] = {
95 .name = "uart3", 95 .name = "uart3",
96 .channels = MAP(S3C2443_DMAREQSEL_UART3_1), 96 .channels = MAP(S3C2443_DMAREQSEL_UART3_1),
97 }, 97 },
@@ -142,6 +142,23 @@ static int __init s3c2443_dma_add(struct device *dev,
142 return s3c24xx_dma_init_map(&s3c2443_dma_sel); 142 return s3c24xx_dma_init_map(&s3c2443_dma_sel);
143} 143}
144 144
145#ifdef CONFIG_CPU_S3C2416
146/* S3C2416 DMA contains the same selection table as the S3C2443 */
147static struct subsys_interface s3c2416_dma_interface = {
148 .name = "s3c2416_dma",
149 .subsys = &s3c2416_subsys,
150 .add_dev = s3c2443_dma_add,
151};
152
153static int __init s3c2416_dma_init(void)
154{
155 return subsys_interface_register(&s3c2416_dma_interface);
156}
157
158arch_initcall(s3c2416_dma_init);
159#endif
160
161#ifdef CONFIG_CPU_S3C2443
145static struct subsys_interface s3c2443_dma_interface = { 162static struct subsys_interface s3c2443_dma_interface = {
146 .name = "s3c2443_dma", 163 .name = "s3c2443_dma",
147 .subsys = &s3c2443_subsys, 164 .subsys = &s3c2443_subsys,
@@ -154,3 +171,4 @@ static int __init s3c2443_dma_init(void)
154} 171}
155 172
156arch_initcall(s3c2443_dma_init); 173arch_initcall(s3c2443_dma_init);
174#endif
diff --git a/arch/arm/mach-s3c2410/h1940-bluetooth.c b/arch/arm/mach-s3c24xx/h1940-bluetooth.c
index a5eeb62ce1c..a5eeb62ce1c 100644
--- a/arch/arm/mach-s3c2410/h1940-bluetooth.c
+++ b/arch/arm/mach-s3c24xx/h1940-bluetooth.c
diff --git a/arch/arm/mach-s3c2410/include/mach/anubis-cpld.h b/arch/arm/mach-s3c24xx/include/mach/anubis-cpld.h
index 1b614d5a81f..1b614d5a81f 100644
--- a/arch/arm/mach-s3c2410/include/mach/anubis-cpld.h
+++ b/arch/arm/mach-s3c24xx/include/mach/anubis-cpld.h
diff --git a/arch/arm/mach-s3c2410/include/mach/anubis-irq.h b/arch/arm/mach-s3c24xx/include/mach/anubis-irq.h
index a2a328134e3..a2a328134e3 100644
--- a/arch/arm/mach-s3c2410/include/mach/anubis-irq.h
+++ b/arch/arm/mach-s3c24xx/include/mach/anubis-irq.h
diff --git a/arch/arm/mach-s3c2410/include/mach/anubis-map.h b/arch/arm/mach-s3c24xx/include/mach/anubis-map.h
index c9deb3a5b2c..c9deb3a5b2c 100644
--- a/arch/arm/mach-s3c2410/include/mach/anubis-map.h
+++ b/arch/arm/mach-s3c24xx/include/mach/anubis-map.h
diff --git a/arch/arm/mach-s3c2410/include/mach/bast-cpld.h b/arch/arm/mach-s3c24xx/include/mach/bast-cpld.h
index bee2a7a932a..bee2a7a932a 100644
--- a/arch/arm/mach-s3c2410/include/mach/bast-cpld.h
+++ b/arch/arm/mach-s3c24xx/include/mach/bast-cpld.h
diff --git a/arch/arm/mach-s3c2410/include/mach/bast-irq.h b/arch/arm/mach-s3c24xx/include/mach/bast-irq.h
index cac428c42e7..cac428c42e7 100644
--- a/arch/arm/mach-s3c2410/include/mach/bast-irq.h
+++ b/arch/arm/mach-s3c24xx/include/mach/bast-irq.h
diff --git a/arch/arm/mach-s3c2410/include/mach/bast-map.h b/arch/arm/mach-s3c24xx/include/mach/bast-map.h
index 6e7dc9d0cf0..6e7dc9d0cf0 100644
--- a/arch/arm/mach-s3c2410/include/mach/bast-map.h
+++ b/arch/arm/mach-s3c24xx/include/mach/bast-map.h
diff --git a/arch/arm/mach-s3c2410/include/mach/bast-pmu.h b/arch/arm/mach-s3c24xx/include/mach/bast-pmu.h
index 4c38b39b741..4c38b39b741 100644
--- a/arch/arm/mach-s3c2410/include/mach/bast-pmu.h
+++ b/arch/arm/mach-s3c24xx/include/mach/bast-pmu.h
diff --git a/arch/arm/mach-s3c2410/include/mach/debug-macro.S b/arch/arm/mach-s3c24xx/include/mach/debug-macro.S
index 4135de87d1f..4135de87d1f 100644
--- a/arch/arm/mach-s3c2410/include/mach/debug-macro.S
+++ b/arch/arm/mach-s3c24xx/include/mach/debug-macro.S
diff --git a/arch/arm/mach-s3c2410/include/mach/dma.h b/arch/arm/mach-s3c24xx/include/mach/dma.h
index acbdfecd418..acbdfecd418 100644
--- a/arch/arm/mach-s3c2410/include/mach/dma.h
+++ b/arch/arm/mach-s3c24xx/include/mach/dma.h
diff --git a/arch/arm/mach-s3c2410/include/mach/entry-macro.S b/arch/arm/mach-s3c24xx/include/mach/entry-macro.S
index 473b3cd37d9..7615a14773f 100644
--- a/arch/arm/mach-s3c2410/include/mach/entry-macro.S
+++ b/arch/arm/mach-s3c24xx/include/mach/entry-macro.S
@@ -25,9 +25,6 @@
25 .macro get_irqnr_preamble, base, tmp 25 .macro get_irqnr_preamble, base, tmp
26 .endm 26 .endm
27 27
28 .macro arch_ret_to_user, tmp1, tmp2
29 .endm
30
31 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp 28 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
32 29
33 mov \base, #S3C24XX_VA_IRQ 30 mov \base, #S3C24XX_VA_IRQ
@@ -71,8 +68,3 @@
71 @@ exit here, Z flag unset if IRQ 68 @@ exit here, Z flag unset if IRQ
72 69
73 .endm 70 .endm
74
75 /* currently don't need an disable_fiq macro */
76
77 .macro disable_fiq
78 .endm
diff --git a/arch/arm/mach-s3c2410/include/mach/fb.h b/arch/arm/mach-s3c24xx/include/mach/fb.h
index a957bc8ed44..a957bc8ed44 100644
--- a/arch/arm/mach-s3c2410/include/mach/fb.h
+++ b/arch/arm/mach-s3c24xx/include/mach/fb.h
diff --git a/arch/arm/mach-s3c2410/include/mach/gpio-fns.h b/arch/arm/mach-s3c24xx/include/mach/gpio-fns.h
index c53ad34c657..c53ad34c657 100644
--- a/arch/arm/mach-s3c2410/include/mach/gpio-fns.h
+++ b/arch/arm/mach-s3c24xx/include/mach/gpio-fns.h
diff --git a/arch/arm/mach-s3c2410/include/mach/gpio-nrs.h b/arch/arm/mach-s3c24xx/include/mach/gpio-nrs.h
index 019ea86057f..019ea86057f 100644
--- a/arch/arm/mach-s3c2410/include/mach/gpio-nrs.h
+++ b/arch/arm/mach-s3c24xx/include/mach/gpio-nrs.h
diff --git a/arch/arm/mach-s3c2410/include/mach/gpio-track.h b/arch/arm/mach-s3c24xx/include/mach/gpio-track.h
index c410a078622..c410a078622 100644
--- a/arch/arm/mach-s3c2410/include/mach/gpio-track.h
+++ b/arch/arm/mach-s3c24xx/include/mach/gpio-track.h
diff --git a/arch/arm/mach-s3c2410/include/mach/gpio.h b/arch/arm/mach-s3c24xx/include/mach/gpio.h
index 6fac70f3484..6fac70f3484 100644
--- a/arch/arm/mach-s3c2410/include/mach/gpio.h
+++ b/arch/arm/mach-s3c24xx/include/mach/gpio.h
diff --git a/arch/arm/mach-s3c2440/include/mach/gta02.h b/arch/arm/mach-s3c24xx/include/mach/gta02.h
index 3a56a229cac..3a56a229cac 100644
--- a/arch/arm/mach-s3c2440/include/mach/gta02.h
+++ b/arch/arm/mach-s3c24xx/include/mach/gta02.h
diff --git a/arch/arm/mach-s3c2410/include/mach/h1940-latch.h b/arch/arm/mach-s3c24xx/include/mach/h1940-latch.h
index fc897d3a056..fc897d3a056 100644
--- a/arch/arm/mach-s3c2410/include/mach/h1940-latch.h
+++ b/arch/arm/mach-s3c24xx/include/mach/h1940-latch.h
diff --git a/arch/arm/mach-s3c2410/include/mach/h1940.h b/arch/arm/mach-s3c24xx/include/mach/h1940.h
index 2aa683c8d3d..2aa683c8d3d 100644
--- a/arch/arm/mach-s3c2410/include/mach/h1940.h
+++ b/arch/arm/mach-s3c24xx/include/mach/h1940.h
diff --git a/arch/arm/mach-s3c2410/include/mach/hardware.h b/arch/arm/mach-s3c24xx/include/mach/hardware.h
index aef5631eac5..aef5631eac5 100644
--- a/arch/arm/mach-s3c2410/include/mach/hardware.h
+++ b/arch/arm/mach-s3c24xx/include/mach/hardware.h
diff --git a/arch/arm/mach-s3c2410/include/mach/idle.h b/arch/arm/mach-s3c24xx/include/mach/idle.h
index e9ddd706b16..e9ddd706b16 100644
--- a/arch/arm/mach-s3c2410/include/mach/idle.h
+++ b/arch/arm/mach-s3c24xx/include/mach/idle.h
diff --git a/arch/arm/mach-s3c2410/include/mach/io.h b/arch/arm/mach-s3c24xx/include/mach/io.h
index 118749f37c4..118749f37c4 100644
--- a/arch/arm/mach-s3c2410/include/mach/io.h
+++ b/arch/arm/mach-s3c24xx/include/mach/io.h
diff --git a/arch/arm/mach-s3c2410/include/mach/irqs.h b/arch/arm/mach-s3c24xx/include/mach/irqs.h
index e53b2177319..e53b2177319 100644
--- a/arch/arm/mach-s3c2410/include/mach/irqs.h
+++ b/arch/arm/mach-s3c24xx/include/mach/irqs.h
diff --git a/arch/arm/mach-s3c2410/include/mach/leds-gpio.h b/arch/arm/mach-s3c24xx/include/mach/leds-gpio.h
index d8a7672519b..d8a7672519b 100644
--- a/arch/arm/mach-s3c2410/include/mach/leds-gpio.h
+++ b/arch/arm/mach-s3c24xx/include/mach/leds-gpio.h
diff --git a/arch/arm/mach-s3c2410/include/mach/map.h b/arch/arm/mach-s3c24xx/include/mach/map.h
index 78ae807f128..78ae807f128 100644
--- a/arch/arm/mach-s3c2410/include/mach/map.h
+++ b/arch/arm/mach-s3c24xx/include/mach/map.h
diff --git a/arch/arm/mach-s3c2410/include/mach/osiris-cpld.h b/arch/arm/mach-s3c24xx/include/mach/osiris-cpld.h
index e9e36b0abba..e9e36b0abba 100644
--- a/arch/arm/mach-s3c2410/include/mach/osiris-cpld.h
+++ b/arch/arm/mach-s3c24xx/include/mach/osiris-cpld.h
diff --git a/arch/arm/mach-s3c2410/include/mach/osiris-map.h b/arch/arm/mach-s3c24xx/include/mach/osiris-map.h
index 17380f84842..17380f84842 100644
--- a/arch/arm/mach-s3c2410/include/mach/osiris-map.h
+++ b/arch/arm/mach-s3c24xx/include/mach/osiris-map.h
diff --git a/arch/arm/mach-s3c2410/include/mach/otom-map.h b/arch/arm/mach-s3c24xx/include/mach/otom-map.h
index f9277a52c14..f9277a52c14 100644
--- a/arch/arm/mach-s3c2410/include/mach/otom-map.h
+++ b/arch/arm/mach-s3c24xx/include/mach/otom-map.h
diff --git a/arch/arm/mach-s3c2410/include/mach/pm-core.h b/arch/arm/mach-s3c24xx/include/mach/pm-core.h
index 2eef7e6f767..2eef7e6f767 100644
--- a/arch/arm/mach-s3c2410/include/mach/pm-core.h
+++ b/arch/arm/mach-s3c24xx/include/mach/pm-core.h
diff --git a/arch/arm/mach-s3c2410/include/mach/regs-clock.h b/arch/arm/mach-s3c24xx/include/mach/regs-clock.h
index 3415b60082d..3415b60082d 100644
--- a/arch/arm/mach-s3c2410/include/mach/regs-clock.h
+++ b/arch/arm/mach-s3c24xx/include/mach/regs-clock.h
diff --git a/arch/arm/mach-s3c2410/include/mach/regs-dsc.h b/arch/arm/mach-s3c24xx/include/mach/regs-dsc.h
index 98fd4a05587..98fd4a05587 100644
--- a/arch/arm/mach-s3c2410/include/mach/regs-dsc.h
+++ b/arch/arm/mach-s3c24xx/include/mach/regs-dsc.h
diff --git a/arch/arm/mach-s3c2410/include/mach/regs-gpio.h b/arch/arm/mach-s3c24xx/include/mach/regs-gpio.h
index cac1ad6b582..cac1ad6b582 100644
--- a/arch/arm/mach-s3c2410/include/mach/regs-gpio.h
+++ b/arch/arm/mach-s3c24xx/include/mach/regs-gpio.h
diff --git a/arch/arm/mach-s3c2410/include/mach/regs-gpioj.h b/arch/arm/mach-s3c24xx/include/mach/regs-gpioj.h
index 19575e06111..19575e06111 100644
--- a/arch/arm/mach-s3c2410/include/mach/regs-gpioj.h
+++ b/arch/arm/mach-s3c24xx/include/mach/regs-gpioj.h
diff --git a/arch/arm/mach-s3c2410/include/mach/regs-irq.h b/arch/arm/mach-s3c24xx/include/mach/regs-irq.h
index 0f07ba30b1f..0f07ba30b1f 100644
--- a/arch/arm/mach-s3c2410/include/mach/regs-irq.h
+++ b/arch/arm/mach-s3c24xx/include/mach/regs-irq.h
diff --git a/arch/arm/mach-s3c2410/include/mach/regs-lcd.h b/arch/arm/mach-s3c24xx/include/mach/regs-lcd.h
index ee8f040aff5..ee8f040aff5 100644
--- a/arch/arm/mach-s3c2410/include/mach/regs-lcd.h
+++ b/arch/arm/mach-s3c24xx/include/mach/regs-lcd.h
diff --git a/arch/arm/mach-s3c2410/include/mach/regs-mem.h b/arch/arm/mach-s3c24xx/include/mach/regs-mem.h
index e0c67b0163d..e0c67b0163d 100644
--- a/arch/arm/mach-s3c2410/include/mach/regs-mem.h
+++ b/arch/arm/mach-s3c24xx/include/mach/regs-mem.h
diff --git a/arch/arm/mach-s3c2410/include/mach/regs-power.h b/arch/arm/mach-s3c24xx/include/mach/regs-power.h
index 4932b87bdf3..4932b87bdf3 100644
--- a/arch/arm/mach-s3c2410/include/mach/regs-power.h
+++ b/arch/arm/mach-s3c24xx/include/mach/regs-power.h
diff --git a/arch/arm/mach-s3c2410/include/mach/regs-s3c2412-mem.h b/arch/arm/mach-s3c24xx/include/mach/regs-s3c2412-mem.h
index fb635251509..fb635251509 100644
--- a/arch/arm/mach-s3c2410/include/mach/regs-s3c2412-mem.h
+++ b/arch/arm/mach-s3c24xx/include/mach/regs-s3c2412-mem.h
diff --git a/arch/arm/mach-s3c2410/include/mach/regs-s3c2412.h b/arch/arm/mach-s3c24xx/include/mach/regs-s3c2412.h
index aa69dc79bc3..aa69dc79bc3 100644
--- a/arch/arm/mach-s3c2410/include/mach/regs-s3c2412.h
+++ b/arch/arm/mach-s3c24xx/include/mach/regs-s3c2412.h
diff --git a/arch/arm/mach-s3c2410/include/mach/regs-s3c2416-mem.h b/arch/arm/mach-s3c24xx/include/mach/regs-s3c2416-mem.h
index 2f31b74974a..2f31b74974a 100644
--- a/arch/arm/mach-s3c2410/include/mach/regs-s3c2416-mem.h
+++ b/arch/arm/mach-s3c24xx/include/mach/regs-s3c2416-mem.h
diff --git a/arch/arm/mach-s3c2410/include/mach/regs-s3c2416.h b/arch/arm/mach-s3c24xx/include/mach/regs-s3c2416.h
index e443167efb8..e443167efb8 100644
--- a/arch/arm/mach-s3c2410/include/mach/regs-s3c2416.h
+++ b/arch/arm/mach-s3c24xx/include/mach/regs-s3c2416.h
diff --git a/arch/arm/mach-s3c2410/include/mach/regs-s3c2443-clock.h b/arch/arm/mach-s3c24xx/include/mach/regs-s3c2443-clock.h
index c3feff3c048..c3feff3c048 100644
--- a/arch/arm/mach-s3c2410/include/mach/regs-s3c2443-clock.h
+++ b/arch/arm/mach-s3c24xx/include/mach/regs-s3c2443-clock.h
diff --git a/arch/arm/mach-s3c2410/include/mach/regs-sdi.h b/arch/arm/mach-s3c24xx/include/mach/regs-sdi.h
index cbf2d8884e3..cbf2d8884e3 100644
--- a/arch/arm/mach-s3c2410/include/mach/regs-sdi.h
+++ b/arch/arm/mach-s3c24xx/include/mach/regs-sdi.h
diff --git a/arch/arm/mach-s3c2410/include/mach/tick.h b/arch/arm/mach-s3c24xx/include/mach/tick.h
index 544da41979d..544da41979d 100644
--- a/arch/arm/mach-s3c2410/include/mach/tick.h
+++ b/arch/arm/mach-s3c24xx/include/mach/tick.h
diff --git a/arch/arm/mach-s3c2410/include/mach/timex.h b/arch/arm/mach-s3c24xx/include/mach/timex.h
index fe9ca1ffd51..fe9ca1ffd51 100644
--- a/arch/arm/mach-s3c2410/include/mach/timex.h
+++ b/arch/arm/mach-s3c24xx/include/mach/timex.h
diff --git a/arch/arm/mach-s3c2410/include/mach/uncompress.h b/arch/arm/mach-s3c24xx/include/mach/uncompress.h
index 8b283f847da..8b283f847da 100644
--- a/arch/arm/mach-s3c2410/include/mach/uncompress.h
+++ b/arch/arm/mach-s3c24xx/include/mach/uncompress.h
diff --git a/arch/arm/mach-s3c2410/include/mach/vr1000-cpld.h b/arch/arm/mach-s3c24xx/include/mach/vr1000-cpld.h
index e4119913d7c..e4119913d7c 100644
--- a/arch/arm/mach-s3c2410/include/mach/vr1000-cpld.h
+++ b/arch/arm/mach-s3c24xx/include/mach/vr1000-cpld.h
diff --git a/arch/arm/mach-s3c2410/include/mach/vr1000-irq.h b/arch/arm/mach-s3c24xx/include/mach/vr1000-irq.h
index 47add133b8e..47add133b8e 100644
--- a/arch/arm/mach-s3c2410/include/mach/vr1000-irq.h
+++ b/arch/arm/mach-s3c24xx/include/mach/vr1000-irq.h
diff --git a/arch/arm/mach-s3c2410/include/mach/vr1000-map.h b/arch/arm/mach-s3c24xx/include/mach/vr1000-map.h
index 99612fcc4eb..99612fcc4eb 100644
--- a/arch/arm/mach-s3c2410/include/mach/vr1000-map.h
+++ b/arch/arm/mach-s3c24xx/include/mach/vr1000-map.h
diff --git a/arch/arm/mach-s3c2412/irq.c b/arch/arm/mach-s3c24xx/irq-s3c2412.c
index e65619ddbcc..e65619ddbcc 100644
--- a/arch/arm/mach-s3c2412/irq.c
+++ b/arch/arm/mach-s3c24xx/irq-s3c2412.c
diff --git a/arch/arm/mach-s3c2416/irq.c b/arch/arm/mach-s3c24xx/irq-s3c2416.c
index fd49f35e448..fd49f35e448 100644
--- a/arch/arm/mach-s3c2416/irq.c
+++ b/arch/arm/mach-s3c24xx/irq-s3c2416.c
diff --git a/arch/arm/mach-s3c2440/irq.c b/arch/arm/mach-s3c24xx/irq-s3c2440.c
index 4a18cde439c..4a18cde439c 100644
--- a/arch/arm/mach-s3c2440/irq.c
+++ b/arch/arm/mach-s3c24xx/irq-s3c2440.c
diff --git a/arch/arm/mach-s3c2443/irq.c b/arch/arm/mach-s3c24xx/irq-s3c2443.c
index ac2829f56d1..ac2829f56d1 100644
--- a/arch/arm/mach-s3c2443/irq.c
+++ b/arch/arm/mach-s3c24xx/irq-s3c2443.c
diff --git a/arch/arm/mach-s3c2440/s3c244x-irq.c b/arch/arm/mach-s3c24xx/irq-s3c244x.c
index 5fe8e58d3af..5fe8e58d3af 100644
--- a/arch/arm/mach-s3c2440/s3c244x-irq.c
+++ b/arch/arm/mach-s3c24xx/irq-s3c244x.c
diff --git a/arch/arm/mach-s3c2410/mach-amlm5900.c b/arch/arm/mach-s3c24xx/mach-amlm5900.c
index 4220cc60de3..4220cc60de3 100644
--- a/arch/arm/mach-s3c2410/mach-amlm5900.c
+++ b/arch/arm/mach-s3c24xx/mach-amlm5900.c
diff --git a/arch/arm/mach-s3c2440/mach-anubis.c b/arch/arm/mach-s3c24xx/mach-anubis.c
index 19b577bc09b..60c72c54c21 100644
--- a/arch/arm/mach-s3c2440/mach-anubis.c
+++ b/arch/arm/mach-s3c24xx/mach-anubis.c
@@ -55,6 +55,7 @@
55#include <plat/cpu.h> 55#include <plat/cpu.h>
56#include <plat/audio-simtec.h> 56#include <plat/audio-simtec.h>
57 57
58#include "simtec.h"
58#include "common.h" 59#include "common.h"
59 60
60#define COPYRIGHT ", Copyright 2005-2009 Simtec Electronics" 61#define COPYRIGHT ", Copyright 2005-2009 Simtec Electronics"
diff --git a/arch/arm/mach-s3c2440/mach-at2440evb.c b/arch/arm/mach-s3c24xx/mach-at2440evb.c
index d7ae49c9011..d7ae49c9011 100644
--- a/arch/arm/mach-s3c2440/mach-at2440evb.c
+++ b/arch/arm/mach-s3c24xx/mach-at2440evb.c
diff --git a/arch/arm/mach-s3c2410/mach-bast.c b/arch/arm/mach-s3c24xx/mach-bast.c
index feeaf73933d..53219c02eca 100644
--- a/arch/arm/mach-s3c2410/mach-bast.c
+++ b/arch/arm/mach-s3c24xx/mach-bast.c
@@ -64,8 +64,7 @@
64#include <plat/gpio-cfg.h> 64#include <plat/gpio-cfg.h>
65#include <plat/audio-simtec.h> 65#include <plat/audio-simtec.h>
66 66
67#include "usb-simtec.h" 67#include "simtec.h"
68#include "nor-simtec.h"
69#include "common.h" 68#include "common.h"
70 69
71#define COPYRIGHT ", Copyright 2004-2008 Simtec Electronics" 70#define COPYRIGHT ", Copyright 2004-2008 Simtec Electronics"
diff --git a/arch/arm/mach-s3c2440/mach-gta02.c b/arch/arm/mach-s3c24xx/mach-gta02.c
index 9a4a5bc008e..ba5d8539410 100644
--- a/arch/arm/mach-s3c2440/mach-gta02.c
+++ b/arch/arm/mach-s3c24xx/mach-gta02.c
@@ -38,6 +38,7 @@
38#include <linux/platform_device.h> 38#include <linux/platform_device.h>
39#include <linux/serial_core.h> 39#include <linux/serial_core.h>
40#include <linux/spi/spi.h> 40#include <linux/spi/spi.h>
41#include <linux/spi/s3c24xx.h>
41 42
42#include <linux/mmc/host.h> 43#include <linux/mmc/host.h>
43 44
@@ -73,7 +74,6 @@
73#include <mach/regs-gpioj.h> 74#include <mach/regs-gpioj.h>
74#include <mach/fb.h> 75#include <mach/fb.h>
75 76
76#include <mach/spi.h>
77#include <plat/usb-control.h> 77#include <plat/usb-control.h>
78#include <mach/regs-mem.h> 78#include <mach/regs-mem.h>
79#include <mach/hardware.h> 79#include <mach/hardware.h>
@@ -258,7 +258,7 @@ static struct pcf50633_bl_platform_data gta02_backlight_data = {
258 .ramp_time = 5, 258 .ramp_time = 5,
259}; 259};
260 260
261struct pcf50633_platform_data gta02_pcf_pdata = { 261static struct pcf50633_platform_data gta02_pcf_pdata = {
262 .resumers = { 262 .resumers = {
263 [0] = PCF50633_INT1_USBINS | 263 [0] = PCF50633_INT1_USBINS |
264 PCF50633_INT1_USBREM | 264 PCF50633_INT1_USBREM |
@@ -404,7 +404,7 @@ static struct platform_device gta02_nor_flash = {
404}; 404};
405 405
406 406
407struct platform_device s3c24xx_pwm_device = { 407static struct platform_device s3c24xx_pwm_device = {
408 .name = "s3c24xx_pwm", 408 .name = "s3c24xx_pwm",
409 .num_resources = 0, 409 .num_resources = 0,
410}; 410};
diff --git a/arch/arm/mach-s3c2410/mach-h1940.c b/arch/arm/mach-s3c24xx/mach-h1940.c
index 41245a60398..6b21ba107ea 100644
--- a/arch/arm/mach-s3c2410/mach-h1940.c
+++ b/arch/arm/mach-s3c24xx/mach-h1940.c
@@ -162,7 +162,7 @@ static int h1940_gpiolib_latch_get(struct gpio_chip *chip,
162 return (latch_state >> (offset + 16)) & 1; 162 return (latch_state >> (offset + 16)) & 1;
163} 163}
164 164
165struct gpio_chip h1940_latch_gpiochip = { 165static struct gpio_chip h1940_latch_gpiochip = {
166 .base = H1940_LATCH_GPIO(0), 166 .base = H1940_LATCH_GPIO(0),
167 .owner = THIS_MODULE, 167 .owner = THIS_MODULE,
168 .label = "H1940_LATCH", 168 .label = "H1940_LATCH",
@@ -304,7 +304,7 @@ static const struct s3c_adc_bat_thresh bat_lut_acin[] = {
304 { .volt = 3841, .cur = 0, .level = 0}, 304 { .volt = 3841, .cur = 0, .level = 0},
305}; 305};
306 306
307int h1940_bat_init(void) 307static int h1940_bat_init(void)
308{ 308{
309 int ret; 309 int ret;
310 310
@@ -317,17 +317,17 @@ int h1940_bat_init(void)
317 317
318} 318}
319 319
320void h1940_bat_exit(void) 320static void h1940_bat_exit(void)
321{ 321{
322 gpio_free(H1940_LATCH_SM803_ENABLE); 322 gpio_free(H1940_LATCH_SM803_ENABLE);
323} 323}
324 324
325void h1940_enable_charger(void) 325static void h1940_enable_charger(void)
326{ 326{
327 gpio_set_value(H1940_LATCH_SM803_ENABLE, 1); 327 gpio_set_value(H1940_LATCH_SM803_ENABLE, 1);
328} 328}
329 329
330void h1940_disable_charger(void) 330static void h1940_disable_charger(void)
331{ 331{
332 gpio_set_value(H1940_LATCH_SM803_ENABLE, 0); 332 gpio_set_value(H1940_LATCH_SM803_ENABLE, 0);
333} 333}
@@ -364,7 +364,7 @@ static struct platform_device h1940_battery = {
364 }, 364 },
365}; 365};
366 366
367DEFINE_SPINLOCK(h1940_blink_spin); 367static DEFINE_SPINLOCK(h1940_blink_spin);
368 368
369int h1940_led_blink_set(unsigned gpio, int state, 369int h1940_led_blink_set(unsigned gpio, int state,
370 unsigned long *delay_on, unsigned long *delay_off) 370 unsigned long *delay_on, unsigned long *delay_off)
diff --git a/arch/arm/mach-s3c2412/mach-jive.c b/arch/arm/mach-s3c24xx/mach-jive.c
index ae73ba34ecc..ae73ba34ecc 100644
--- a/arch/arm/mach-s3c2412/mach-jive.c
+++ b/arch/arm/mach-s3c24xx/mach-jive.c
diff --git a/arch/arm/mach-s3c2440/mach-mini2440.c b/arch/arm/mach-s3c24xx/mach-mini2440.c
index 5d66fb218a4..5d66fb218a4 100644
--- a/arch/arm/mach-s3c2440/mach-mini2440.c
+++ b/arch/arm/mach-s3c24xx/mach-mini2440.c
diff --git a/arch/arm/mach-s3c2410/mach-n30.c b/arch/arm/mach-s3c24xx/mach-n30.c
index 383d00ca8f6..383d00ca8f6 100644
--- a/arch/arm/mach-s3c2410/mach-n30.c
+++ b/arch/arm/mach-s3c24xx/mach-n30.c
diff --git a/arch/arm/mach-s3c2440/mach-nexcoder.c b/arch/arm/mach-s3c24xx/mach-nexcoder.c
index 5198e3e1c5b..5198e3e1c5b 100644
--- a/arch/arm/mach-s3c2440/mach-nexcoder.c
+++ b/arch/arm/mach-s3c24xx/mach-nexcoder.c
diff --git a/arch/arm/mach-s3c2440/mach-osiris-dvs.c b/arch/arm/mach-s3c24xx/mach-osiris-dvs.c
index ad2792dfbee..ad2792dfbee 100644
--- a/arch/arm/mach-s3c2440/mach-osiris-dvs.c
+++ b/arch/arm/mach-s3c24xx/mach-osiris-dvs.c
diff --git a/arch/arm/mach-s3c2440/mach-osiris.c b/arch/arm/mach-s3c24xx/mach-osiris.c
index c5daeb612a8..c5daeb612a8 100644
--- a/arch/arm/mach-s3c2440/mach-osiris.c
+++ b/arch/arm/mach-s3c24xx/mach-osiris.c
diff --git a/arch/arm/mach-s3c2410/mach-otom.c b/arch/arm/mach-s3c24xx/mach-otom.c
index 5f1e0eeb38a..5f1e0eeb38a 100644
--- a/arch/arm/mach-s3c2410/mach-otom.c
+++ b/arch/arm/mach-s3c24xx/mach-otom.c
diff --git a/arch/arm/mach-s3c2410/mach-qt2410.c b/arch/arm/mach-s3c24xx/mach-qt2410.c
index 91c16d9d245..91c16d9d245 100644
--- a/arch/arm/mach-s3c2410/mach-qt2410.c
+++ b/arch/arm/mach-s3c24xx/mach-qt2410.c
diff --git a/arch/arm/mach-s3c2440/mach-rx1950.c b/arch/arm/mach-s3c24xx/mach-rx1950.c
index 6f68abf44fa..200debb4c72 100644
--- a/arch/arm/mach-s3c2440/mach-rx1950.c
+++ b/arch/arm/mach-s3c24xx/mach-rx1950.c
@@ -217,7 +217,7 @@ static const struct s3c_adc_bat_thresh bat_lut_acin[] = {
217 { .volt = 3820, .cur = 0, .level = 0}, 217 { .volt = 3820, .cur = 0, .level = 0},
218}; 218};
219 219
220int rx1950_bat_init(void) 220static int rx1950_bat_init(void)
221{ 221{
222 int ret; 222 int ret;
223 223
@@ -236,25 +236,25 @@ err_gpio1:
236 return ret; 236 return ret;
237} 237}
238 238
239void rx1950_bat_exit(void) 239static void rx1950_bat_exit(void)
240{ 240{
241 gpio_free(S3C2410_GPJ(2)); 241 gpio_free(S3C2410_GPJ(2));
242 gpio_free(S3C2410_GPJ(3)); 242 gpio_free(S3C2410_GPJ(3));
243} 243}
244 244
245void rx1950_enable_charger(void) 245static void rx1950_enable_charger(void)
246{ 246{
247 gpio_direction_output(S3C2410_GPJ(2), 1); 247 gpio_direction_output(S3C2410_GPJ(2), 1);
248 gpio_direction_output(S3C2410_GPJ(3), 1); 248 gpio_direction_output(S3C2410_GPJ(3), 1);
249} 249}
250 250
251void rx1950_disable_charger(void) 251static void rx1950_disable_charger(void)
252{ 252{
253 gpio_direction_output(S3C2410_GPJ(2), 0); 253 gpio_direction_output(S3C2410_GPJ(2), 0);
254 gpio_direction_output(S3C2410_GPJ(3), 0); 254 gpio_direction_output(S3C2410_GPJ(3), 0);
255} 255}
256 256
257DEFINE_SPINLOCK(rx1950_blink_spin); 257static DEFINE_SPINLOCK(rx1950_blink_spin);
258 258
259static int rx1950_led_blink_set(unsigned gpio, int state, 259static int rx1950_led_blink_set(unsigned gpio, int state,
260 unsigned long *delay_on, unsigned long *delay_off) 260 unsigned long *delay_on, unsigned long *delay_off)
@@ -382,7 +382,7 @@ static struct s3c2410fb_mach_info rx1950_lcd_cfg = {
382 382
383static struct pwm_device *lcd_pwm; 383static struct pwm_device *lcd_pwm;
384 384
385void rx1950_lcd_power(int enable) 385static void rx1950_lcd_power(int enable)
386{ 386{
387 int i; 387 int i;
388 static int enabled; 388 static int enabled;
diff --git a/arch/arm/mach-s3c2440/mach-rx3715.c b/arch/arm/mach-s3c24xx/mach-rx3715.c
index 56af3544759..56af3544759 100644
--- a/arch/arm/mach-s3c2440/mach-rx3715.c
+++ b/arch/arm/mach-s3c24xx/mach-rx3715.c
diff --git a/arch/arm/mach-s3c2410/mach-smdk2410.c b/arch/arm/mach-s3c24xx/mach-smdk2410.c
index bdc27e77287..bdc27e77287 100644
--- a/arch/arm/mach-s3c2410/mach-smdk2410.c
+++ b/arch/arm/mach-s3c24xx/mach-smdk2410.c
diff --git a/arch/arm/mach-s3c2412/mach-smdk2413.c b/arch/arm/mach-s3c24xx/mach-smdk2413.c
index b11451b853d..b11451b853d 100644
--- a/arch/arm/mach-s3c2412/mach-smdk2413.c
+++ b/arch/arm/mach-s3c24xx/mach-smdk2413.c
diff --git a/arch/arm/mach-s3c2416/mach-smdk2416.c b/arch/arm/mach-s3c24xx/mach-smdk2416.c
index eebe1e72b93..30a44f806e0 100644
--- a/arch/arm/mach-s3c2416/mach-smdk2416.c
+++ b/arch/arm/mach-s3c24xx/mach-smdk2416.c
@@ -125,7 +125,7 @@ static struct s3c2410_uartcfg smdk2416_uartcfgs[] __initdata = {
125 } 125 }
126}; 126};
127 127
128void smdk2416_hsudc_gpio_init(void) 128static void smdk2416_hsudc_gpio_init(void)
129{ 129{
130 s3c_gpio_setpull(S3C2410_GPH(14), S3C_GPIO_PULL_UP); 130 s3c_gpio_setpull(S3C2410_GPH(14), S3C_GPIO_PULL_UP);
131 s3c_gpio_setpull(S3C2410_GPF(2), S3C_GPIO_PULL_NONE); 131 s3c_gpio_setpull(S3C2410_GPF(2), S3C_GPIO_PULL_NONE);
@@ -133,20 +133,20 @@ void smdk2416_hsudc_gpio_init(void)
133 s3c2410_modify_misccr(S3C2416_MISCCR_SEL_SUSPND, 0); 133 s3c2410_modify_misccr(S3C2416_MISCCR_SEL_SUSPND, 0);
134} 134}
135 135
136void smdk2416_hsudc_gpio_uninit(void) 136static void smdk2416_hsudc_gpio_uninit(void)
137{ 137{
138 s3c2410_modify_misccr(S3C2416_MISCCR_SEL_SUSPND, 1); 138 s3c2410_modify_misccr(S3C2416_MISCCR_SEL_SUSPND, 1);
139 s3c_gpio_setpull(S3C2410_GPH(14), S3C_GPIO_PULL_NONE); 139 s3c_gpio_setpull(S3C2410_GPH(14), S3C_GPIO_PULL_NONE);
140 s3c_gpio_cfgpin(S3C2410_GPH(14), S3C_GPIO_SFN(0)); 140 s3c_gpio_cfgpin(S3C2410_GPH(14), S3C_GPIO_SFN(0));
141} 141}
142 142
143struct s3c24xx_hsudc_platdata smdk2416_hsudc_platdata = { 143static struct s3c24xx_hsudc_platdata smdk2416_hsudc_platdata = {
144 .epnum = 9, 144 .epnum = 9,
145 .gpio_init = smdk2416_hsudc_gpio_init, 145 .gpio_init = smdk2416_hsudc_gpio_init,
146 .gpio_uninit = smdk2416_hsudc_gpio_uninit, 146 .gpio_uninit = smdk2416_hsudc_gpio_uninit,
147}; 147};
148 148
149struct s3c_fb_pd_win smdk2416_fb_win[] = { 149static struct s3c_fb_pd_win smdk2416_fb_win[] = {
150 [0] = { 150 [0] = {
151 /* think this is the same as the smdk6410 */ 151 /* think this is the same as the smdk6410 */
152 .win_mode = { 152 .win_mode = {
diff --git a/arch/arm/mach-s3c2440/mach-smdk2440.c b/arch/arm/mach-s3c24xx/mach-smdk2440.c
index 83a1036d7dc..83a1036d7dc 100644
--- a/arch/arm/mach-s3c2440/mach-smdk2440.c
+++ b/arch/arm/mach-s3c24xx/mach-smdk2440.c
diff --git a/arch/arm/mach-s3c2443/mach-smdk2443.c b/arch/arm/mach-s3c24xx/mach-smdk2443.c
index 20923695622..20923695622 100644
--- a/arch/arm/mach-s3c2443/mach-smdk2443.c
+++ b/arch/arm/mach-s3c24xx/mach-smdk2443.c
diff --git a/arch/arm/mach-s3c2410/mach-tct_hammer.c b/arch/arm/mach-s3c24xx/mach-tct_hammer.c
index 1114666f0ef..1114666f0ef 100644
--- a/arch/arm/mach-s3c2410/mach-tct_hammer.c
+++ b/arch/arm/mach-s3c24xx/mach-tct_hammer.c
diff --git a/arch/arm/mach-s3c2410/mach-vr1000.c b/arch/arm/mach-s3c24xx/mach-vr1000.c
index dbe668a803e..87608d45dac 100644
--- a/arch/arm/mach-s3c2410/mach-vr1000.c
+++ b/arch/arm/mach-s3c24xx/mach-vr1000.c
@@ -51,8 +51,7 @@
51#include <plat/iic.h> 51#include <plat/iic.h>
52#include <plat/audio-simtec.h> 52#include <plat/audio-simtec.h>
53 53
54#include "usb-simtec.h" 54#include "simtec.h"
55#include "nor-simtec.h"
56#include "common.h" 55#include "common.h"
57 56
58/* macros for virtual address mods for the io space entries */ 57/* macros for virtual address mods for the io space entries */
diff --git a/arch/arm/mach-s3c2412/mach-vstms.c b/arch/arm/mach-s3c24xx/mach-vstms.c
index 94bfaa1fb14..94bfaa1fb14 100644
--- a/arch/arm/mach-s3c2412/mach-vstms.c
+++ b/arch/arm/mach-s3c24xx/mach-vstms.c
diff --git a/arch/arm/mach-s3c2410/pm-h1940.S b/arch/arm/mach-s3c24xx/pm-h1940.S
index c93bf2db9f4..c93bf2db9f4 100644
--- a/arch/arm/mach-s3c2410/pm-h1940.S
+++ b/arch/arm/mach-s3c24xx/pm-h1940.S
diff --git a/arch/arm/mach-s3c2410/pm.c b/arch/arm/mach-s3c24xx/pm-s3c2410.c
index 03f706dd600..03f706dd600 100644
--- a/arch/arm/mach-s3c2410/pm.c
+++ b/arch/arm/mach-s3c24xx/pm-s3c2410.c
diff --git a/arch/arm/mach-s3c2412/pm.c b/arch/arm/mach-s3c24xx/pm-s3c2412.c
index d04588506ec..d04588506ec 100644
--- a/arch/arm/mach-s3c2412/pm.c
+++ b/arch/arm/mach-s3c24xx/pm-s3c2412.c
diff --git a/arch/arm/mach-s3c2416/pm.c b/arch/arm/mach-s3c24xx/pm-s3c2416.c
index 1bd4817b8eb..1bd4817b8eb 100644
--- a/arch/arm/mach-s3c2416/pm.c
+++ b/arch/arm/mach-s3c24xx/pm-s3c2416.c
diff --git a/arch/arm/mach-s3c2410/s3c2410.c b/arch/arm/mach-s3c24xx/s3c2410.c
index a3c5cb086ee..a3c5cb086ee 100644
--- a/arch/arm/mach-s3c2410/s3c2410.c
+++ b/arch/arm/mach-s3c24xx/s3c2410.c
diff --git a/arch/arm/mach-s3c2412/s3c2412.c b/arch/arm/mach-s3c24xx/s3c2412.c
index 100ef1c320e..d4bc7f960bb 100644
--- a/arch/arm/mach-s3c2412/s3c2412.c
+++ b/arch/arm/mach-s3c24xx/s3c2412.c
@@ -33,8 +33,6 @@
33#include <asm/irq.h> 33#include <asm/irq.h>
34#include <asm/system_misc.h> 34#include <asm/system_misc.h>
35 35
36#include <mach/idle.h>
37
38#include <plat/cpu-freq.h> 36#include <plat/cpu-freq.h>
39 37
40#include <mach/regs-clock.h> 38#include <mach/regs-clock.h>
@@ -165,7 +163,7 @@ void __init s3c2412_map_io(void)
165 163
166 /* set our idle function */ 164 /* set our idle function */
167 165
168 s3c24xx_idle = s3c2412_idle; 166 arm_pm_idle = s3c2412_idle;
169 167
170 /* register our io-tables */ 168 /* register our io-tables */
171 169
diff --git a/arch/arm/mach-s3c2416/s3c2416.c b/arch/arm/mach-s3c24xx/s3c2416.c
index ed67ec9c83d..7743fade50d 100644
--- a/arch/arm/mach-s3c2416/s3c2416.c
+++ b/arch/arm/mach-s3c24xx/s3c2416.c
@@ -45,7 +45,6 @@
45#include <asm/irq.h> 45#include <asm/irq.h>
46#include <asm/system_misc.h> 46#include <asm/system_misc.h>
47 47
48#include <mach/idle.h>
49#include <mach/regs-s3c2443-clock.h> 48#include <mach/regs-s3c2443-clock.h>
50 49
51#include <plat/gpio-core.h> 50#include <plat/gpio-core.h>
@@ -61,6 +60,7 @@
61#include <plat/fb-core.h> 60#include <plat/fb-core.h>
62#include <plat/nand-core.h> 61#include <plat/nand-core.h>
63#include <plat/adc-core.h> 62#include <plat/adc-core.h>
63#include <plat/rtc-core.h>
64 64
65static struct map_desc s3c2416_iodesc[] __initdata = { 65static struct map_desc s3c2416_iodesc[] __initdata = {
66 IODESC_ENT(WATCHDOG), 66 IODESC_ENT(WATCHDOG),
@@ -89,8 +89,6 @@ int __init s3c2416_init(void)
89{ 89{
90 printk(KERN_INFO "S3C2416: Initializing architecture\n"); 90 printk(KERN_INFO "S3C2416: Initializing architecture\n");
91 91
92 /* s3c24xx_idle = s3c2416_idle; */
93
94 /* change WDT IRQ number */ 92 /* change WDT IRQ number */
95 s3c_device_wdt.resource[1].start = IRQ_S3C2443_WDT; 93 s3c_device_wdt.resource[1].start = IRQ_S3C2443_WDT;
96 s3c_device_wdt.resource[1].end = IRQ_S3C2443_WDT; 94 s3c_device_wdt.resource[1].end = IRQ_S3C2443_WDT;
@@ -102,6 +100,7 @@ int __init s3c2416_init(void)
102 s3c_fb_setname("s3c2443-fb"); 100 s3c_fb_setname("s3c2443-fb");
103 101
104 s3c_adc_setname("s3c2416-adc"); 102 s3c_adc_setname("s3c2416-adc");
103 s3c_rtc_setname("s3c2416-rtc");
105 104
106#ifdef CONFIG_PM 105#ifdef CONFIG_PM
107 register_syscore_ops(&s3c2416_pm_syscore_ops); 106 register_syscore_ops(&s3c2416_pm_syscore_ops);
diff --git a/arch/arm/mach-s3c2440/s3c2440.c b/arch/arm/mach-s3c24xx/s3c2440.c
index 2b3dddb49af..2b3dddb49af 100644
--- a/arch/arm/mach-s3c2440/s3c2440.c
+++ b/arch/arm/mach-s3c24xx/s3c2440.c
diff --git a/arch/arm/mach-s3c2440/s3c2442.c b/arch/arm/mach-s3c24xx/s3c2442.c
index 22cb7c94a8c..22cb7c94a8c 100644
--- a/arch/arm/mach-s3c2440/s3c2442.c
+++ b/arch/arm/mach-s3c24xx/s3c2442.c
diff --git a/arch/arm/mach-s3c2443/s3c2443.c b/arch/arm/mach-s3c24xx/s3c2443.c
index 9318847bdc3..ab648ad8fa5 100644
--- a/arch/arm/mach-s3c2443/s3c2443.c
+++ b/arch/arm/mach-s3c24xx/s3c2443.c
@@ -42,6 +42,7 @@
42#include <plat/fb-core.h> 42#include <plat/fb-core.h>
43#include <plat/nand-core.h> 43#include <plat/nand-core.h>
44#include <plat/adc-core.h> 44#include <plat/adc-core.h>
45#include <plat/rtc-core.h>
45 46
46static struct map_desc s3c2443_iodesc[] __initdata = { 47static struct map_desc s3c2443_iodesc[] __initdata = {
47 IODESC_ENT(WATCHDOG), 48 IODESC_ENT(WATCHDOG),
@@ -74,6 +75,7 @@ int __init s3c2443_init(void)
74 s3c_fb_setname("s3c2443-fb"); 75 s3c_fb_setname("s3c2443-fb");
75 76
76 s3c_adc_setname("s3c2443-adc"); 77 s3c_adc_setname("s3c2443-adc");
78 s3c_rtc_setname("s3c2443-rtc");
77 79
78 /* change WDT IRQ number */ 80 /* change WDT IRQ number */
79 s3c_device_wdt.resource[1].start = IRQ_S3C2443_WDT; 81 s3c_device_wdt.resource[1].start = IRQ_S3C2443_WDT;
diff --git a/arch/arm/mach-s3c2440/s3c244x.c b/arch/arm/mach-s3c24xx/s3c244x.c
index 6f74118f60c..6f74118f60c 100644
--- a/arch/arm/mach-s3c2440/s3c244x.c
+++ b/arch/arm/mach-s3c24xx/s3c244x.c
diff --git a/arch/arm/plat-s3c24xx/setup-i2c.c b/arch/arm/mach-s3c24xx/setup-i2c.c
index 9e90a7cbd1d..9e90a7cbd1d 100644
--- a/arch/arm/plat-s3c24xx/setup-i2c.c
+++ b/arch/arm/mach-s3c24xx/setup-i2c.c
diff --git a/arch/arm/mach-s3c2416/setup-sdhci-gpio.c b/arch/arm/mach-s3c24xx/setup-sdhci-gpio.c
index f65cb3ef16c..f65cb3ef16c 100644
--- a/arch/arm/mach-s3c2416/setup-sdhci-gpio.c
+++ b/arch/arm/mach-s3c24xx/setup-sdhci-gpio.c
diff --git a/arch/arm/plat-s3c24xx/setup-ts.c b/arch/arm/mach-s3c24xx/setup-ts.c
index ed263866367..ed263866367 100644
--- a/arch/arm/plat-s3c24xx/setup-ts.c
+++ b/arch/arm/mach-s3c24xx/setup-ts.c
diff --git a/arch/arm/plat-s3c24xx/simtec-audio.c b/arch/arm/mach-s3c24xx/simtec-audio.c
index 6bc832e0d8e..11881c9a38c 100644
--- a/arch/arm/plat-s3c24xx/simtec-audio.c
+++ b/arch/arm/mach-s3c24xx/simtec-audio.c
@@ -27,6 +27,8 @@
27#include <plat/audio-simtec.h> 27#include <plat/audio-simtec.h>
28#include <plat/devs.h> 28#include <plat/devs.h>
29 29
30#include "simtec.h"
31
30/* platform ops for audio */ 32/* platform ops for audio */
31 33
32static void simtec_audio_startup_lrroute(void) 34static void simtec_audio_startup_lrroute(void)
diff --git a/arch/arm/mach-s3c2410/nor-simtec.c b/arch/arm/mach-s3c24xx/simtec-nor.c
index ad9f750f1e5..2119ca6a73b 100644
--- a/arch/arm/mach-s3c2410/nor-simtec.c
+++ b/arch/arm/mach-s3c24xx/simtec-nor.c
@@ -30,7 +30,7 @@
30#include <mach/bast-map.h> 30#include <mach/bast-map.h>
31#include <mach/bast-cpld.h> 31#include <mach/bast-cpld.h>
32 32
33#include "nor-simtec.h" 33#include "simtec.h"
34 34
35static void simtec_nor_vpp(struct platform_device *pdev, int vpp) 35static void simtec_nor_vpp(struct platform_device *pdev, int vpp)
36{ 36{
diff --git a/arch/arm/plat-s3c24xx/pm-simtec.c b/arch/arm/mach-s3c24xx/simtec-pm.c
index 699f9317129..699f9317129 100644
--- a/arch/arm/plat-s3c24xx/pm-simtec.c
+++ b/arch/arm/mach-s3c24xx/simtec-pm.c
diff --git a/arch/arm/mach-s3c2410/usb-simtec.c b/arch/arm/mach-s3c24xx/simtec-usb.c
index 29bd3d987be..d91c1a72513 100644
--- a/arch/arm/mach-s3c2410/usb-simtec.c
+++ b/arch/arm/mach-s3c24xx/simtec-usb.c
@@ -37,7 +37,7 @@
37#include <plat/usb-control.h> 37#include <plat/usb-control.h>
38#include <plat/devs.h> 38#include <plat/devs.h>
39 39
40#include "usb-simtec.h" 40#include "simtec.h"
41 41
42/* control power and monitor over-current events on various Simtec 42/* control power and monitor over-current events on various Simtec
43 * designed boards. 43 * designed boards.
diff --git a/arch/arm/mach-s3c2410/nor-simtec.h b/arch/arm/mach-s3c24xx/simtec.h
index f619c1e0d0c..ae8f4f9ad2e 100644
--- a/arch/arm/mach-s3c2410/nor-simtec.h
+++ b/arch/arm/mach-s3c24xx/simtec.h
@@ -4,11 +4,18 @@
4 * http://armlinux.simtec.co.uk/ 4 * http://armlinux.simtec.co.uk/
5 * Ben Dooks <ben@simtec.co.uk> 5 * Ben Dooks <ben@simtec.co.uk>
6 * 6 *
7 * Simtec NOR mapping 7 * Simtec common functions
8 * 8 *
9 * 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
10 * it under the terms of the GNU General Public License version 2 as 10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation. 11 * published by the Free Software Foundation.
12*/ 12*/
13 13
14struct s3c24xx_audio_simtec_pdata;
15
14extern void nor_simtec_init(void); 16extern void nor_simtec_init(void);
17
18extern int usb_simtec_init(void);
19
20extern int simtec_audio_add(const char *codec_name, bool has_lr_routing,
21 struct s3c24xx_audio_simtec_pdata *pdata);
diff --git a/arch/arm/mach-s3c2410/sleep.S b/arch/arm/mach-s3c24xx/sleep-s3c2410.S
index dd5b6388a5a..dd5b6388a5a 100644
--- a/arch/arm/mach-s3c2410/sleep.S
+++ b/arch/arm/mach-s3c24xx/sleep-s3c2410.S
diff --git a/arch/arm/mach-s3c2412/sleep.S b/arch/arm/mach-s3c24xx/sleep-s3c2412.S
index c82418ed714..c82418ed714 100644
--- a/arch/arm/mach-s3c2412/sleep.S
+++ b/arch/arm/mach-s3c24xx/sleep-s3c2412.S
diff --git a/arch/arm/mach-s3c64xx/Kconfig b/arch/arm/mach-s3c64xx/Kconfig
index dd20c66cd70..82c0915729e 100644
--- a/arch/arm/mach-s3c64xx/Kconfig
+++ b/arch/arm/mach-s3c64xx/Kconfig
@@ -83,6 +83,11 @@ config S3C64XX_SETUP_SPI
83 help 83 help
84 Common setup code for SPI GPIO configurations 84 Common setup code for SPI GPIO configurations
85 85
86config S3C64XX_SETUP_USB_PHY
87 bool
88 help
89 Common setup code for USB PHY controller
90
86# S36400 Macchine support 91# S36400 Macchine support
87 92
88config MACH_SMDK6400 93config MACH_SMDK6400
@@ -157,6 +162,7 @@ config MACH_SMDK6410
157 select S3C64XX_SETUP_IDE 162 select S3C64XX_SETUP_IDE
158 select S3C64XX_SETUP_FB_24BPP 163 select S3C64XX_SETUP_FB_24BPP
159 select S3C64XX_SETUP_KEYPAD 164 select S3C64XX_SETUP_KEYPAD
165 select S3C64XX_SETUP_USB_PHY
160 help 166 help
161 Machine support for the Samsung SMDK6410 167 Machine support for the Samsung SMDK6410
162 168
@@ -256,6 +262,7 @@ config MACH_SMARTQ
256 select S3C_DEV_USB_HOST 262 select S3C_DEV_USB_HOST
257 select S3C64XX_SETUP_SDHCI 263 select S3C64XX_SETUP_SDHCI
258 select S3C64XX_SETUP_FB_24BPP 264 select S3C64XX_SETUP_FB_24BPP
265 select S3C64XX_SETUP_USB_PHY
259 select SAMSUNG_DEV_ADC 266 select SAMSUNG_DEV_ADC
260 select SAMSUNG_DEV_PWM 267 select SAMSUNG_DEV_PWM
261 select SAMSUNG_DEV_TS 268 select SAMSUNG_DEV_TS
@@ -283,6 +290,7 @@ config MACH_WLF_CRAGG_6410
283 select S3C64XX_SETUP_FB_24BPP 290 select S3C64XX_SETUP_FB_24BPP
284 select S3C64XX_SETUP_KEYPAD 291 select S3C64XX_SETUP_KEYPAD
285 select S3C64XX_SETUP_SPI 292 select S3C64XX_SETUP_SPI
293 select S3C64XX_SETUP_USB_PHY
286 select SAMSUNG_DEV_ADC 294 select SAMSUNG_DEV_ADC
287 select SAMSUNG_DEV_KEYPAD 295 select SAMSUNG_DEV_KEYPAD
288 select S3C_DEV_USB_HOST 296 select S3C_DEV_USB_HOST
@@ -296,5 +304,6 @@ config MACH_WLF_CRAGG_6410
296 select S3C64XX_DEV_SPI0 304 select S3C64XX_DEV_SPI0
297 select SAMSUNG_GPIO_EXTRA128 305 select SAMSUNG_GPIO_EXTRA128
298 select I2C 306 select I2C
307 select LEDS_GPIO_REGISTER
299 help 308 help
300 Machine support for the Wolfson Cragganmore S3C6410 variant. 309 Machine support for the Wolfson Cragganmore S3C6410 variant.
diff --git a/arch/arm/mach-s3c64xx/Makefile b/arch/arm/mach-s3c64xx/Makefile
index 1822ac2eba3..f9ce1dc28ce 100644
--- a/arch/arm/mach-s3c64xx/Makefile
+++ b/arch/arm/mach-s3c64xx/Makefile
@@ -22,6 +22,7 @@ obj-$(CONFIG_CPU_S3C6410) += s3c6410.o
22# PM 22# PM
23 23
24obj-$(CONFIG_PM) += pm.o irq-pm.o sleep.o 24obj-$(CONFIG_PM) += pm.o irq-pm.o sleep.o
25obj-$(CONFIG_CPU_IDLE) += cpuidle.o
25 26
26# DMA support 27# DMA support
27 28
@@ -42,6 +43,7 @@ obj-$(CONFIG_S3C64XX_SETUP_IDE) += setup-ide.o
42obj-$(CONFIG_S3C64XX_SETUP_KEYPAD) += setup-keypad.o 43obj-$(CONFIG_S3C64XX_SETUP_KEYPAD) += setup-keypad.o
43obj-$(CONFIG_S3C64XX_SETUP_SDHCI_GPIO) += setup-sdhci-gpio.o 44obj-$(CONFIG_S3C64XX_SETUP_SDHCI_GPIO) += setup-sdhci-gpio.o
44obj-$(CONFIG_S3C64XX_SETUP_SPI) += setup-spi.o 45obj-$(CONFIG_S3C64XX_SETUP_SPI) += setup-spi.o
46obj-$(CONFIG_S3C64XX_SETUP_USB_PHY) += setup-usb-phy.o
45 47
46# Machine support 48# Machine support
47 49
diff --git a/arch/arm/mach-s3c64xx/clock.c b/arch/arm/mach-s3c64xx/clock.c
index aebbcc291b4..52f079a691c 100644
--- a/arch/arm/mach-s3c64xx/clock.c
+++ b/arch/arm/mach-s3c64xx/clock.c
@@ -207,6 +207,15 @@ static struct clk init_clocks_off[] = {
207 .enable = s3c64xx_sclk_ctrl, 207 .enable = s3c64xx_sclk_ctrl,
208 .ctrlbit = S3C_CLKCON_SCLK_MMC2_48, 208 .ctrlbit = S3C_CLKCON_SCLK_MMC2_48,
209 }, { 209 }, {
210 .name = "ac97",
211 .parent = &clk_p,
212 .ctrlbit = S3C_CLKCON_PCLK_AC97,
213 }, {
214 .name = "cfcon",
215 .parent = &clk_h,
216 .enable = s3c64xx_hclk_ctrl,
217 .ctrlbit = S3C_CLKCON_HCLK_IHOST,
218 }, {
210 .name = "dma0", 219 .name = "dma0",
211 .parent = &clk_h, 220 .parent = &clk_h,
212 .enable = s3c64xx_hclk_ctrl, 221 .enable = s3c64xx_hclk_ctrl,
@@ -216,6 +225,107 @@ static struct clk init_clocks_off[] = {
216 .parent = &clk_h, 225 .parent = &clk_h,
217 .enable = s3c64xx_hclk_ctrl, 226 .enable = s3c64xx_hclk_ctrl,
218 .ctrlbit = S3C_CLKCON_HCLK_DMA1, 227 .ctrlbit = S3C_CLKCON_HCLK_DMA1,
228 }, {
229 .name = "3dse",
230 .parent = &clk_h,
231 .enable = s3c64xx_hclk_ctrl,
232 .ctrlbit = S3C_CLKCON_HCLK_3DSE,
233 }, {
234 .name = "hclk_secur",
235 .parent = &clk_h,
236 .enable = s3c64xx_hclk_ctrl,
237 .ctrlbit = S3C_CLKCON_HCLK_SECUR,
238 }, {
239 .name = "sdma1",
240 .parent = &clk_h,
241 .enable = s3c64xx_hclk_ctrl,
242 .ctrlbit = S3C_CLKCON_HCLK_SDMA1,
243 }, {
244 .name = "sdma0",
245 .parent = &clk_h,
246 .enable = s3c64xx_hclk_ctrl,
247 .ctrlbit = S3C_CLKCON_HCLK_SDMA0,
248 }, {
249 .name = "hclk_jpeg",
250 .parent = &clk_h,
251 .enable = s3c64xx_hclk_ctrl,
252 .ctrlbit = S3C_CLKCON_HCLK_JPEG,
253 }, {
254 .name = "camif",
255 .parent = &clk_h,
256 .enable = s3c64xx_hclk_ctrl,
257 .ctrlbit = S3C_CLKCON_HCLK_CAMIF,
258 }, {
259 .name = "hclk_scaler",
260 .parent = &clk_h,
261 .enable = s3c64xx_hclk_ctrl,
262 .ctrlbit = S3C_CLKCON_HCLK_SCALER,
263 }, {
264 .name = "2d",
265 .parent = &clk_h,
266 .enable = s3c64xx_hclk_ctrl,
267 .ctrlbit = S3C_CLKCON_HCLK_2D,
268 }, {
269 .name = "tv",
270 .parent = &clk_h,
271 .enable = s3c64xx_hclk_ctrl,
272 .ctrlbit = S3C_CLKCON_HCLK_TV,
273 }, {
274 .name = "post0",
275 .parent = &clk_h,
276 .enable = s3c64xx_hclk_ctrl,
277 .ctrlbit = S3C_CLKCON_HCLK_POST0,
278 }, {
279 .name = "rot",
280 .parent = &clk_h,
281 .enable = s3c64xx_hclk_ctrl,
282 .ctrlbit = S3C_CLKCON_HCLK_ROT,
283 }, {
284 .name = "hclk_mfc",
285 .parent = &clk_h,
286 .enable = s3c64xx_hclk_ctrl,
287 .ctrlbit = S3C_CLKCON_HCLK_MFC,
288 }, {
289 .name = "pclk_mfc",
290 .parent = &clk_p,
291 .enable = s3c64xx_pclk_ctrl,
292 .ctrlbit = S3C_CLKCON_PCLK_MFC,
293 }, {
294 .name = "dac27",
295 .enable = s3c64xx_sclk_ctrl,
296 .ctrlbit = S3C_CLKCON_SCLK_DAC27,
297 }, {
298 .name = "tv27",
299 .enable = s3c64xx_sclk_ctrl,
300 .ctrlbit = S3C_CLKCON_SCLK_TV27,
301 }, {
302 .name = "scaler27",
303 .enable = s3c64xx_sclk_ctrl,
304 .ctrlbit = S3C_CLKCON_SCLK_SCALER27,
305 }, {
306 .name = "sclk_scaler",
307 .enable = s3c64xx_sclk_ctrl,
308 .ctrlbit = S3C_CLKCON_SCLK_SCALER,
309 }, {
310 .name = "post0_27",
311 .enable = s3c64xx_sclk_ctrl,
312 .ctrlbit = S3C_CLKCON_SCLK_POST0_27,
313 }, {
314 .name = "secur",
315 .enable = s3c64xx_sclk_ctrl,
316 .ctrlbit = S3C_CLKCON_SCLK_SECUR,
317 }, {
318 .name = "sclk_mfc",
319 .enable = s3c64xx_sclk_ctrl,
320 .ctrlbit = S3C_CLKCON_SCLK_MFC,
321 }, {
322 .name = "cam",
323 .enable = s3c64xx_sclk_ctrl,
324 .ctrlbit = S3C_CLKCON_SCLK_CAM,
325 }, {
326 .name = "sclk_jpeg",
327 .enable = s3c64xx_sclk_ctrl,
328 .ctrlbit = S3C_CLKCON_SCLK_JPEG,
219 }, 329 },
220}; 330};
221 331
@@ -289,16 +399,7 @@ static struct clk init_clocks[] = {
289 .name = "watchdog", 399 .name = "watchdog",
290 .parent = &clk_p, 400 .parent = &clk_p,
291 .ctrlbit = S3C_CLKCON_PCLK_WDT, 401 .ctrlbit = S3C_CLKCON_PCLK_WDT,
292 }, { 402 },
293 .name = "ac97",
294 .parent = &clk_p,
295 .ctrlbit = S3C_CLKCON_PCLK_AC97,
296 }, {
297 .name = "cfcon",
298 .parent = &clk_h,
299 .enable = s3c64xx_hclk_ctrl,
300 .ctrlbit = S3C_CLKCON_HCLK_IHOST,
301 }
302}; 403};
303 404
304static struct clk clk_hsmmc0 = { 405static struct clk clk_hsmmc0 = {
diff --git a/arch/arm/mach-s3c64xx/common.h b/arch/arm/mach-s3c64xx/common.h
index 5eb9c9a7d73..7a10be629ab 100644
--- a/arch/arm/mach-s3c64xx/common.h
+++ b/arch/arm/mach-s3c64xx/common.h
@@ -25,8 +25,6 @@ void s3c64xx_setup_clocks(void);
25 25
26void s3c64xx_restart(char mode, const char *cmd); 26void s3c64xx_restart(char mode, const char *cmd);
27 27
28extern struct syscore_ops s3c64xx_irq_syscore_ops;
29
30#ifdef CONFIG_CPU_S3C6400 28#ifdef CONFIG_CPU_S3C6400
31 29
32extern int s3c6400_init(void); 30extern int s3c6400_init(void);
diff --git a/arch/arm/mach-s3c64xx/cpuidle.c b/arch/arm/mach-s3c64xx/cpuidle.c
new file mode 100644
index 00000000000..179460f38db
--- /dev/null
+++ b/arch/arm/mach-s3c64xx/cpuidle.c
@@ -0,0 +1,91 @@
1/* linux/arch/arm/mach-s3c64xx/cpuidle.c
2 *
3 * Copyright (c) 2011 Wolfson Microelectronics, plc
4 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10*/
11
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/cpuidle.h>
15#include <linux/io.h>
16#include <linux/export.h>
17#include <linux/time.h>
18
19#include <asm/proc-fns.h>
20
21#include <mach/map.h>
22
23#include <mach/regs-sys.h>
24#include <mach/regs-syscon-power.h>
25
26static int s3c64xx_enter_idle(struct cpuidle_device *dev,
27 struct cpuidle_driver *drv,
28 int index)
29{
30 struct timeval before, after;
31 unsigned long tmp;
32 int idle_time;
33
34 local_irq_disable();
35 do_gettimeofday(&before);
36
37 /* Setup PWRCFG to enter idle mode */
38 tmp = __raw_readl(S3C64XX_PWR_CFG);
39 tmp &= ~S3C64XX_PWRCFG_CFG_WFI_MASK;
40 tmp |= S3C64XX_PWRCFG_CFG_WFI_IDLE;
41 __raw_writel(tmp, S3C64XX_PWR_CFG);
42
43 cpu_do_idle();
44
45 do_gettimeofday(&after);
46 local_irq_enable();
47 idle_time = (after.tv_sec - before.tv_sec) * USEC_PER_SEC +
48 (after.tv_usec - before.tv_usec);
49
50 dev->last_residency = idle_time;
51 return index;
52}
53
54static struct cpuidle_state s3c64xx_cpuidle_set[] = {
55 [0] = {
56 .enter = s3c64xx_enter_idle,
57 .exit_latency = 1,
58 .target_residency = 1,
59 .flags = CPUIDLE_FLAG_TIME_VALID,
60 .name = "IDLE",
61 .desc = "System active, ARM gated",
62 },
63};
64
65static struct cpuidle_driver s3c64xx_cpuidle_driver = {
66 .name = "s3c64xx_cpuidle",
67 .owner = THIS_MODULE,
68 .state_count = ARRAY_SIZE(s3c64xx_cpuidle_set),
69};
70
71static struct cpuidle_device s3c64xx_cpuidle_device = {
72 .state_count = ARRAY_SIZE(s3c64xx_cpuidle_set),
73};
74
75static int __init s3c64xx_init_cpuidle(void)
76{
77 int ret;
78
79 memcpy(s3c64xx_cpuidle_driver.states, s3c64xx_cpuidle_set,
80 sizeof(s3c64xx_cpuidle_set));
81 cpuidle_register_driver(&s3c64xx_cpuidle_driver);
82
83 ret = cpuidle_register_device(&s3c64xx_cpuidle_device);
84 if (ret) {
85 pr_err("Failed to register cpuidle device: %d\n", ret);
86 return ret;
87 }
88
89 return 0;
90}
91device_initcall(s3c64xx_init_cpuidle);
diff --git a/arch/arm/mach-s3c64xx/include/mach/entry-macro.S b/arch/arm/mach-s3c64xx/include/mach/entry-macro.S
deleted file mode 100644
index dc2bc15142c..00000000000
--- a/arch/arm/mach-s3c64xx/include/mach/entry-macro.S
+++ /dev/null
@@ -1,19 +0,0 @@
1/* arch/arm/mach-s3c6400/include/mach/entry-macro.S
2 *
3 * Copyright 2008 Openmoko, Inc.
4 * Copyright 2008 Simtec Electronics
5 * http://armlinux.simtec.co.uk/
6 * Ben Dooks <ben@simtec.co.uk>
7 *
8 * Low-level IRQ helper macros for the Samsung S3C64XX series
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 .macro disable_fiq
16 .endm
17
18 .macro arch_ret_to_user, tmp1, tmp2
19 .endm
diff --git a/arch/arm/mach-s3c64xx/include/mach/system.h b/arch/arm/mach-s3c64xx/include/mach/system.h
deleted file mode 100644
index 353ed4389ae..00000000000
--- a/arch/arm/mach-s3c64xx/include/mach/system.h
+++ /dev/null
@@ -1,19 +0,0 @@
1/* linux/arch/arm/mach-s3c6400/include/mach/system.h
2 *
3 * Copyright 2008 Openmoko, Inc.
4 * Copyright 2008 Simtec Electronics
5 * Ben Dooks <ben@simtec.co.uk>
6 * http://armlinux.simtec.co.uk/
7 *
8 * S3C6400 - system implementation
9 */
10
11#ifndef __ASM_ARCH_SYSTEM_H
12#define __ASM_ARCH_SYSTEM_H __FILE__
13
14static void arch_idle(void)
15{
16 /* nothing here yet */
17}
18
19#endif /* __ASM_ARCH_IRQ_H */
diff --git a/arch/arm/mach-s3c64xx/irq-pm.c b/arch/arm/mach-s3c64xx/irq-pm.c
index 8bec61e242c..0c7e1d960ca 100644
--- a/arch/arm/mach-s3c64xx/irq-pm.c
+++ b/arch/arm/mach-s3c64xx/irq-pm.c
@@ -96,7 +96,7 @@ static void s3c64xx_irq_pm_resume(void)
96 S3C_PMDBG("%s: IRQ configuration restored\n", __func__); 96 S3C_PMDBG("%s: IRQ configuration restored\n", __func__);
97} 97}
98 98
99struct syscore_ops s3c64xx_irq_syscore_ops = { 99static struct syscore_ops s3c64xx_irq_syscore_ops = {
100 .suspend = s3c64xx_irq_pm_suspend, 100 .suspend = s3c64xx_irq_pm_suspend,
101 .resume = s3c64xx_irq_pm_resume, 101 .resume = s3c64xx_irq_pm_resume,
102}; 102};
diff --git a/arch/arm/mach-s3c64xx/mach-crag6410-module.c b/arch/arm/mach-s3c64xx/mach-crag6410-module.c
index 32a30f38ba0..0ace108c3e3 100644
--- a/arch/arm/mach-s3c64xx/mach-crag6410-module.c
+++ b/arch/arm/mach-s3c64xx/mach-crag6410-module.c
@@ -11,18 +11,38 @@
11#include <linux/export.h> 11#include <linux/export.h>
12#include <linux/interrupt.h> 12#include <linux/interrupt.h>
13#include <linux/i2c.h> 13#include <linux/i2c.h>
14#include <linux/spi/spi.h>
14 15
15#include <linux/mfd/wm831x/irq.h> 16#include <linux/mfd/wm831x/irq.h>
16#include <linux/mfd/wm831x/gpio.h> 17#include <linux/mfd/wm831x/gpio.h>
17#include <linux/mfd/wm8994/pdata.h> 18#include <linux/mfd/wm8994/pdata.h>
18 19
20#include <linux/regulator/machine.h>
21
19#include <sound/wm5100.h> 22#include <sound/wm5100.h>
20#include <sound/wm8996.h> 23#include <sound/wm8996.h>
21#include <sound/wm8962.h> 24#include <sound/wm8962.h>
22#include <sound/wm9081.h> 25#include <sound/wm9081.h>
23 26
27#include <plat/s3c64xx-spi.h>
28
24#include <mach/crag6410.h> 29#include <mach/crag6410.h>
25 30
31static struct s3c64xx_spi_csinfo wm0010_spi_csinfo = {
32 .set_level = gpio_set_value,
33 .line = S3C64XX_GPC(3),
34};
35
36static struct spi_board_info wm1253_devs[] = {
37 [0] = {
38 .modalias = "wm0010",
39 .bus_num = 0,
40 .chip_select = 0,
41 .mode = SPI_MODE_0,
42 .controller_data = &wm0010_spi_csinfo,
43 },
44};
45
26static struct wm5100_pdata wm5100_pdata = { 46static struct wm5100_pdata wm5100_pdata = {
27 .ldo_ena = S3C64XX_GPN(7), 47 .ldo_ena = S3C64XX_GPN(7),
28 .irq_flags = IRQF_TRIGGER_HIGH, 48 .irq_flags = IRQF_TRIGGER_HIGH,
@@ -135,6 +155,14 @@ static const struct i2c_board_info wm1259_devs[] = {
135 }, 155 },
136}; 156};
137 157
158static struct regulator_init_data wm8994_ldo1 = {
159 .supply_regulator = "WALLVDD",
160};
161
162static struct regulator_init_data wm8994_ldo2 = {
163 .supply_regulator = "WALLVDD",
164};
165
138static struct wm8994_pdata wm8994_pdata = { 166static struct wm8994_pdata wm8994_pdata = {
139 .gpio_base = CODEC_GPIO_BASE, 167 .gpio_base = CODEC_GPIO_BASE,
140 .gpio_defaults = { 168 .gpio_defaults = {
@@ -142,8 +170,8 @@ static struct wm8994_pdata wm8994_pdata = {
142 }, 170 },
143 .irq_base = CODEC_IRQ_BASE, 171 .irq_base = CODEC_IRQ_BASE,
144 .ldo = { 172 .ldo = {
145 { .supply = "WALLVDD" }, 173 { .init_data = &wm8994_ldo1, },
146 { .supply = "WALLVDD" }, 174 { .init_data = &wm8994_ldo2, },
147 }, 175 },
148}; 176};
149 177
@@ -159,14 +187,21 @@ static __devinitdata const struct {
159 const char *name; 187 const char *name;
160 const struct i2c_board_info *i2c_devs; 188 const struct i2c_board_info *i2c_devs;
161 int num_i2c_devs; 189 int num_i2c_devs;
190 const struct spi_board_info *spi_devs;
191 int num_spi_devs;
162} gf_mods[] = { 192} gf_mods[] = {
163 { .id = 0x01, .name = "1250-EV1 Springbank" }, 193 { .id = 0x01, .name = "1250-EV1 Springbank" },
164 { .id = 0x02, .name = "1251-EV1 Jura" }, 194 { .id = 0x02, .name = "1251-EV1 Jura" },
165 { .id = 0x03, .name = "1252-EV1 Glenlivet" }, 195 { .id = 0x03, .name = "1252-EV1 Glenlivet" },
166 { .id = 0x11, .name = "6249-EV2 Glenfarclas", }, 196 { .id = 0x11, .name = "6249-EV2 Glenfarclas", },
197 { .id = 0x14, .name = "6271-EV1 Lochnagar" },
198 { .id = 0x15, .name = "XXXX-EV1 Bells" },
167 { .id = 0x21, .name = "1275-EV1 Mortlach" }, 199 { .id = 0x21, .name = "1275-EV1 Mortlach" },
168 { .id = 0x25, .name = "1274-EV1 Glencadam" }, 200 { .id = 0x25, .name = "1274-EV1 Glencadam" },
169 { .id = 0x31, .name = "1253-EV1 Tomatin", }, 201 { .id = 0x31, .name = "1253-EV1 Tomatin",
202 .spi_devs = wm1253_devs, .num_spi_devs = ARRAY_SIZE(wm1253_devs) },
203 { .id = 0x32, .name = "XXXX-EV1 Caol Illa" },
204 { .id = 0x33, .name = "XXXX-EV1 Oban" },
170 { .id = 0x39, .name = "1254-EV1 Dallas Dhu", 205 { .id = 0x39, .name = "1254-EV1 Dallas Dhu",
171 .i2c_devs = wm1254_devs, .num_i2c_devs = ARRAY_SIZE(wm1254_devs) }, 206 .i2c_devs = wm1254_devs, .num_i2c_devs = ARRAY_SIZE(wm1254_devs) },
172 { .id = 0x3a, .name = "1259-EV1 Tobermory", 207 { .id = 0x3a, .name = "1259-EV1 Tobermory",
@@ -198,12 +233,16 @@ static __devinit int wlf_gf_module_probe(struct i2c_client *i2c,
198 if (i < ARRAY_SIZE(gf_mods)) { 233 if (i < ARRAY_SIZE(gf_mods)) {
199 dev_info(&i2c->dev, "%s revision %d\n", 234 dev_info(&i2c->dev, "%s revision %d\n",
200 gf_mods[i].name, rev + 1); 235 gf_mods[i].name, rev + 1);
236
201 for (j = 0; j < gf_mods[i].num_i2c_devs; j++) { 237 for (j = 0; j < gf_mods[i].num_i2c_devs; j++) {
202 if (!i2c_new_device(i2c->adapter, 238 if (!i2c_new_device(i2c->adapter,
203 &(gf_mods[i].i2c_devs[j]))) 239 &(gf_mods[i].i2c_devs[j])))
204 dev_err(&i2c->dev, 240 dev_err(&i2c->dev,
205 "Failed to register dev: %d\n", ret); 241 "Failed to register dev: %d\n", ret);
206 } 242 }
243
244 spi_register_board_info(gf_mods[i].spi_devs,
245 gf_mods[i].num_spi_devs);
207 } else { 246 } else {
208 dev_warn(&i2c->dev, "Unknown module ID 0x%x revision %d\n", 247 dev_warn(&i2c->dev, "Unknown module ID 0x%x revision %d\n",
209 id, rev + 1); 248 id, rev + 1);
diff --git a/arch/arm/mach-s3c64xx/mach-crag6410.c b/arch/arm/mach-s3c64xx/mach-crag6410.c
index 8077f650eb0..e20bf583536 100644
--- a/arch/arm/mach-s3c64xx/mach-crag6410.c
+++ b/arch/arm/mach-s3c64xx/mach-crag6410.c
@@ -19,7 +19,9 @@
19#include <linux/io.h> 19#include <linux/io.h>
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/gpio.h> 21#include <linux/gpio.h>
22#include <linux/leds.h>
22#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/mmc/host.h>
23#include <linux/regulator/machine.h> 25#include <linux/regulator/machine.h>
24#include <linux/regulator/fixed.h> 26#include <linux/regulator/fixed.h>
25#include <linux/pwm_backlight.h> 27#include <linux/pwm_backlight.h>
@@ -59,6 +61,7 @@
59#include <plat/sdhci.h> 61#include <plat/sdhci.h>
60#include <plat/gpio-cfg.h> 62#include <plat/gpio-cfg.h>
61#include <plat/s3c64xx-spi.h> 63#include <plat/s3c64xx-spi.h>
64#include <plat/udc-hs.h>
62 65
63#include <plat/keypad.h> 66#include <plat/keypad.h>
64#include <plat/clock.h> 67#include <plat/clock.h>
@@ -298,6 +301,7 @@ static struct platform_device littlemill_device = {
298}; 301};
299 302
300static struct regulator_consumer_supply wallvdd_consumers[] = { 303static struct regulator_consumer_supply wallvdd_consumers[] = {
304 REGULATOR_SUPPLY("SPKVDD", "1-001a"),
301 REGULATOR_SUPPLY("SPKVDD1", "1-001a"), 305 REGULATOR_SUPPLY("SPKVDD1", "1-001a"),
302 REGULATOR_SUPPLY("SPKVDD2", "1-001a"), 306 REGULATOR_SUPPLY("SPKVDD2", "1-001a"),
303 REGULATOR_SUPPLY("SPKVDDL", "1-001a"), 307 REGULATOR_SUPPLY("SPKVDDL", "1-001a"),
@@ -574,11 +578,19 @@ static struct s3c2410_platform_i2c i2c0_pdata = {
574 .frequency = 400000, 578 .frequency = 400000,
575}; 579};
576 580
581static struct regulator_consumer_supply pvdd_1v2_consumers[] __initdata = {
582 REGULATOR_SUPPLY("DCVDD", "spi0.0"),
583 REGULATOR_SUPPLY("AVDD", "spi0.0"),
584};
585
577static struct regulator_init_data pvdd_1v2 __initdata = { 586static struct regulator_init_data pvdd_1v2 __initdata = {
578 .constraints = { 587 .constraints = {
579 .name = "PVDD_1V2", 588 .name = "PVDD_1V2",
580 .always_on = 1, 589 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
581 }, 590 },
591
592 .consumer_supplies = pvdd_1v2_consumers,
593 .num_consumer_supplies = ARRAY_SIZE(pvdd_1v2_consumers),
582}; 594};
583 595
584static struct regulator_consumer_supply pvdd_1v8_consumers[] __initdata = { 596static struct regulator_consumer_supply pvdd_1v8_consumers[] __initdata = {
@@ -592,6 +604,7 @@ static struct regulator_consumer_supply pvdd_1v8_consumers[] __initdata = {
592 REGULATOR_SUPPLY("AVDD2", "1-001a"), 604 REGULATOR_SUPPLY("AVDD2", "1-001a"),
593 REGULATOR_SUPPLY("DCVDD", "1-001a"), 605 REGULATOR_SUPPLY("DCVDD", "1-001a"),
594 REGULATOR_SUPPLY("AVDD", "1-001a"), 606 REGULATOR_SUPPLY("AVDD", "1-001a"),
607 REGULATOR_SUPPLY("DBVDD", "spi0.0"),
595}; 608};
596 609
597static struct regulator_init_data pvdd_1v8 __initdata = { 610static struct regulator_init_data pvdd_1v8 __initdata = {
@@ -681,6 +694,7 @@ static void __init crag6410_map_io(void)
681static struct s3c_sdhci_platdata crag6410_hsmmc2_pdata = { 694static struct s3c_sdhci_platdata crag6410_hsmmc2_pdata = {
682 .max_width = 4, 695 .max_width = 4,
683 .cd_type = S3C_SDHCI_CD_PERMANENT, 696 .cd_type = S3C_SDHCI_CD_PERMANENT,
697 .host_caps = MMC_CAP_POWER_OFF_CARD,
684}; 698};
685 699
686static void crag6410_cfg_sdhci0(struct platform_device *dev, int width) 700static void crag6410_cfg_sdhci0(struct platform_device *dev, int width)
@@ -696,8 +710,59 @@ static struct s3c_sdhci_platdata crag6410_hsmmc0_pdata = {
696 .max_width = 4, 710 .max_width = 4,
697 .cd_type = S3C_SDHCI_CD_INTERNAL, 711 .cd_type = S3C_SDHCI_CD_INTERNAL,
698 .cfg_gpio = crag6410_cfg_sdhci0, 712 .cfg_gpio = crag6410_cfg_sdhci0,
713 .host_caps = MMC_CAP_POWER_OFF_CARD,
714};
715
716static const struct gpio_led gpio_leds[] = {
717 {
718 .name = "d13:green:",
719 .gpio = MMGPIO_GPIO_BASE + 0,
720 .default_state = LEDS_GPIO_DEFSTATE_ON,
721 },
722 {
723 .name = "d14:green:",
724 .gpio = MMGPIO_GPIO_BASE + 1,
725 .default_state = LEDS_GPIO_DEFSTATE_ON,
726 },
727 {
728 .name = "d15:green:",
729 .gpio = MMGPIO_GPIO_BASE + 2,
730 .default_state = LEDS_GPIO_DEFSTATE_ON,
731 },
732 {
733 .name = "d16:green:",
734 .gpio = MMGPIO_GPIO_BASE + 3,
735 .default_state = LEDS_GPIO_DEFSTATE_ON,
736 },
737 {
738 .name = "d17:green:",
739 .gpio = MMGPIO_GPIO_BASE + 4,
740 .default_state = LEDS_GPIO_DEFSTATE_ON,
741 },
742 {
743 .name = "d18:green:",
744 .gpio = MMGPIO_GPIO_BASE + 5,
745 .default_state = LEDS_GPIO_DEFSTATE_ON,
746 },
747 {
748 .name = "d19:green:",
749 .gpio = MMGPIO_GPIO_BASE + 6,
750 .default_state = LEDS_GPIO_DEFSTATE_ON,
751 },
752 {
753 .name = "d20:green:",
754 .gpio = MMGPIO_GPIO_BASE + 7,
755 .default_state = LEDS_GPIO_DEFSTATE_ON,
756 },
699}; 757};
700 758
759static const struct gpio_led_platform_data gpio_leds_pdata = {
760 .leds = gpio_leds,
761 .num_leds = ARRAY_SIZE(gpio_leds),
762};
763
764static struct s3c_hsotg_plat crag6410_hsotg_pdata;
765
701static void __init crag6410_machine_init(void) 766static void __init crag6410_machine_init(void)
702{ 767{
703 /* Open drain IRQs need pullups */ 768 /* Open drain IRQs need pullups */
@@ -722,14 +787,18 @@ static void __init crag6410_machine_init(void)
722 s3c_i2c0_set_platdata(&i2c0_pdata); 787 s3c_i2c0_set_platdata(&i2c0_pdata);
723 s3c_i2c1_set_platdata(&i2c1_pdata); 788 s3c_i2c1_set_platdata(&i2c1_pdata);
724 s3c_fb_set_platdata(&crag6410_lcd_pdata); 789 s3c_fb_set_platdata(&crag6410_lcd_pdata);
790 s3c_hsotg_set_platdata(&crag6410_hsotg_pdata);
725 791
726 i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0)); 792 i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
727 i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1)); 793 i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
728 794
729 samsung_keypad_set_platdata(&crag6410_keypad_data); 795 samsung_keypad_set_platdata(&crag6410_keypad_data);
796 s3c64xx_spi0_set_platdata(&s3c64xx_spi0_pdata, 0, 1);
730 797
731 platform_add_devices(crag6410_devices, ARRAY_SIZE(crag6410_devices)); 798 platform_add_devices(crag6410_devices, ARRAY_SIZE(crag6410_devices));
732 799
800 gpio_led_register_device(-1, &gpio_leds_pdata);
801
733 regulator_has_full_constraints(); 802 regulator_has_full_constraints();
734 803
735 s3c64xx_pm_init(); 804 s3c64xx_pm_init();
diff --git a/arch/arm/mach-s3c64xx/mach-smartq.c b/arch/arm/mach-s3c64xx/mach-smartq.c
index ce31db13623..ce745e19aa2 100644
--- a/arch/arm/mach-s3c64xx/mach-smartq.c
+++ b/arch/arm/mach-s3c64xx/mach-smartq.c
@@ -187,6 +187,8 @@ static struct s3c_hwmon_pdata smartq_hwmon_pdata __initdata = {
187 }, 187 },
188}; 188};
189 189
190static struct s3c_hsotg_plat smartq_hsotg_pdata;
191
190static int __init smartq_lcd_setup_gpio(void) 192static int __init smartq_lcd_setup_gpio(void)
191{ 193{
192 int ret; 194 int ret;
@@ -383,6 +385,7 @@ void __init smartq_map_io(void)
383void __init smartq_machine_init(void) 385void __init smartq_machine_init(void)
384{ 386{
385 s3c_i2c0_set_platdata(NULL); 387 s3c_i2c0_set_platdata(NULL);
388 s3c_hsotg_set_platdata(&smartq_hsotg_pdata);
386 s3c_hwmon_set_platdata(&smartq_hwmon_pdata); 389 s3c_hwmon_set_platdata(&smartq_hwmon_pdata);
387 s3c_sdhci1_set_platdata(&smartq_internal_hsmmc_pdata); 390 s3c_sdhci1_set_platdata(&smartq_internal_hsmmc_pdata);
388 s3c_sdhci2_set_platdata(&smartq_internal_hsmmc_pdata); 391 s3c_sdhci2_set_platdata(&smartq_internal_hsmmc_pdata);
diff --git a/arch/arm/mach-s3c64xx/mach-smdk6410.c b/arch/arm/mach-s3c64xx/mach-smdk6410.c
index ca6fc204f0e..d55bc96d958 100644
--- a/arch/arm/mach-s3c64xx/mach-smdk6410.c
+++ b/arch/arm/mach-s3c64xx/mach-smdk6410.c
@@ -72,6 +72,7 @@
72#include <plat/keypad.h> 72#include <plat/keypad.h>
73#include <plat/backlight.h> 73#include <plat/backlight.h>
74#include <plat/regs-fb-v4.h> 74#include <plat/regs-fb-v4.h>
75#include <plat/udc-hs.h>
75 76
76#include "common.h" 77#include "common.h"
77 78
@@ -631,6 +632,8 @@ static struct platform_pwm_backlight_data smdk6410_bl_data = {
631 .pwm_id = 1, 632 .pwm_id = 1,
632}; 633};
633 634
635static struct s3c_hsotg_plat smdk6410_hsotg_pdata;
636
634static void __init smdk6410_map_io(void) 637static void __init smdk6410_map_io(void)
635{ 638{
636 u32 tmp; 639 u32 tmp;
@@ -659,6 +662,7 @@ static void __init smdk6410_machine_init(void)
659 s3c_i2c0_set_platdata(NULL); 662 s3c_i2c0_set_platdata(NULL);
660 s3c_i2c1_set_platdata(NULL); 663 s3c_i2c1_set_platdata(NULL);
661 s3c_fb_set_platdata(&smdk6410_lcd_pdata); 664 s3c_fb_set_platdata(&smdk6410_lcd_pdata);
665 s3c_hsotg_set_platdata(&smdk6410_hsotg_pdata);
662 666
663 samsung_keypad_set_platdata(&smdk6410_keypad_data); 667 samsung_keypad_set_platdata(&smdk6410_keypad_data);
664 668
diff --git a/arch/arm/mach-s3c64xx/setup-usb-phy.c b/arch/arm/mach-s3c64xx/setup-usb-phy.c
new file mode 100644
index 00000000000..f6757e02d7d
--- /dev/null
+++ b/arch/arm/mach-s3c64xx/setup-usb-phy.c
@@ -0,0 +1,90 @@
1/*
2 * Copyright (C) 2011 Samsung Electronics Co.Ltd
3 * Author: Joonyoung Shim <jy0922.shim@samsung.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
9 *
10 */
11
12#include <linux/clk.h>
13#include <linux/delay.h>
14#include <linux/err.h>
15#include <linux/io.h>
16#include <linux/platform_device.h>
17#include <mach/map.h>
18#include <mach/regs-sys.h>
19#include <plat/cpu.h>
20#include <plat/regs-usb-hsotg-phy.h>
21#include <plat/usb-phy.h>
22
23static int s3c_usb_otgphy_init(struct platform_device *pdev)
24{
25 struct clk *xusbxti;
26 u32 phyclk;
27
28 writel(readl(S3C64XX_OTHERS) | S3C64XX_OTHERS_USBMASK, S3C64XX_OTHERS);
29
30 /* set clock frequency for PLL */
31 phyclk = readl(S3C_PHYCLK) & ~S3C_PHYCLK_CLKSEL_MASK;
32
33 xusbxti = clk_get(&pdev->dev, "xusbxti");
34 if (xusbxti && !IS_ERR(xusbxti)) {
35 switch (clk_get_rate(xusbxti)) {
36 case 12 * MHZ:
37 phyclk |= S3C_PHYCLK_CLKSEL_12M;
38 break;
39 case 24 * MHZ:
40 phyclk |= S3C_PHYCLK_CLKSEL_24M;
41 break;
42 default:
43 case 48 * MHZ:
44 /* default reference clock */
45 break;
46 }
47 clk_put(xusbxti);
48 }
49
50 /* TODO: select external clock/oscillator */
51 writel(phyclk | S3C_PHYCLK_CLK_FORCE, S3C_PHYCLK);
52
53 /* set to normal OTG PHY */
54 writel((readl(S3C_PHYPWR) & ~S3C_PHYPWR_NORMAL_MASK), S3C_PHYPWR);
55 mdelay(1);
56
57 /* reset OTG PHY and Link */
58 writel(S3C_RSTCON_PHY | S3C_RSTCON_HCLK | S3C_RSTCON_PHYCLK,
59 S3C_RSTCON);
60 udelay(20); /* at-least 10uS */
61 writel(0, S3C_RSTCON);
62
63 return 0;
64}
65
66static int s3c_usb_otgphy_exit(struct platform_device *pdev)
67{
68 writel((readl(S3C_PHYPWR) | S3C_PHYPWR_ANALOG_POWERDOWN |
69 S3C_PHYPWR_OTG_DISABLE), S3C_PHYPWR);
70
71 writel(readl(S3C64XX_OTHERS) & ~S3C64XX_OTHERS_USBMASK, S3C64XX_OTHERS);
72
73 return 0;
74}
75
76int s5p_usb_phy_init(struct platform_device *pdev, int type)
77{
78 if (type == S5P_USB_PHY_DEVICE)
79 return s3c_usb_otgphy_init(pdev);
80
81 return -EINVAL;
82}
83
84int s5p_usb_phy_exit(struct platform_device *pdev, int type)
85{
86 if (type == S5P_USB_PHY_DEVICE)
87 return s3c_usb_otgphy_exit(pdev);
88
89 return -EINVAL;
90}
diff --git a/arch/arm/mach-s5p64x0/clock.c b/arch/arm/mach-s5p64x0/clock.c
index 241d0e645c8..57e718957ef 100644
--- a/arch/arm/mach-s5p64x0/clock.c
+++ b/arch/arm/mach-s5p64x0/clock.c
@@ -73,7 +73,7 @@ static const u32 clock_table[][3] = {
73 {L2 * 1000, (3 << ARM_DIV_RATIO_SHIFT), (0 << S5P64X0_CLKDIV0_HCLK_SHIFT)}, 73 {L2 * 1000, (3 << ARM_DIV_RATIO_SHIFT), (0 << S5P64X0_CLKDIV0_HCLK_SHIFT)},
74}; 74};
75 75
76unsigned long s5p64x0_armclk_get_rate(struct clk *clk) 76static unsigned long s5p64x0_armclk_get_rate(struct clk *clk)
77{ 77{
78 unsigned long rate = clk_get_rate(clk->parent); 78 unsigned long rate = clk_get_rate(clk->parent);
79 u32 clkdiv; 79 u32 clkdiv;
@@ -84,7 +84,8 @@ unsigned long s5p64x0_armclk_get_rate(struct clk *clk)
84 return rate / (clkdiv + 1); 84 return rate / (clkdiv + 1);
85} 85}
86 86
87unsigned long s5p64x0_armclk_round_rate(struct clk *clk, unsigned long rate) 87static unsigned long s5p64x0_armclk_round_rate(struct clk *clk,
88 unsigned long rate)
88{ 89{
89 u32 iter; 90 u32 iter;
90 91
@@ -96,7 +97,7 @@ unsigned long s5p64x0_armclk_round_rate(struct clk *clk, unsigned long rate)
96 return clock_table[ARRAY_SIZE(clock_table) - 1][0]; 97 return clock_table[ARRAY_SIZE(clock_table) - 1][0];
97} 98}
98 99
99int s5p64x0_armclk_set_rate(struct clk *clk, unsigned long rate) 100static int s5p64x0_armclk_set_rate(struct clk *clk, unsigned long rate)
100{ 101{
101 u32 round_tmp; 102 u32 round_tmp;
102 u32 iter; 103 u32 iter;
@@ -148,7 +149,7 @@ int s5p64x0_armclk_set_rate(struct clk *clk, unsigned long rate)
148 return 0; 149 return 0;
149} 150}
150 151
151struct clk_ops s5p64x0_clkarm_ops = { 152static struct clk_ops s5p64x0_clkarm_ops = {
152 .get_rate = s5p64x0_armclk_get_rate, 153 .get_rate = s5p64x0_armclk_get_rate,
153 .set_rate = s5p64x0_armclk_set_rate, 154 .set_rate = s5p64x0_armclk_set_rate,
154 .round_rate = s5p64x0_armclk_round_rate, 155 .round_rate = s5p64x0_armclk_round_rate,
@@ -173,7 +174,7 @@ struct clksrc_clk clk_dout_mpll = {
173 .reg_div = { .reg = S5P64X0_CLK_DIV0, .shift = 4, .size = 1 }, 174 .reg_div = { .reg = S5P64X0_CLK_DIV0, .shift = 4, .size = 1 },
174}; 175};
175 176
176struct clk *clkset_hclk_low_list[] = { 177static struct clk *clkset_hclk_low_list[] = {
177 &clk_mout_apll.clk, 178 &clk_mout_apll.clk,
178 &clk_mout_mpll.clk, 179 &clk_mout_mpll.clk,
179}; 180};
diff --git a/arch/arm/mach-s5p64x0/common.c b/arch/arm/mach-s5p64x0/common.c
index 4325b93940a..6e6a0a9d677 100644
--- a/arch/arm/mach-s5p64x0/common.c
+++ b/arch/arm/mach-s5p64x0/common.c
@@ -147,15 +147,12 @@ static void s5p64x0_idle(void)
147{ 147{
148 unsigned long val; 148 unsigned long val;
149 149
150 if (!need_resched()) { 150 val = __raw_readl(S5P64X0_PWR_CFG);
151 val = __raw_readl(S5P64X0_PWR_CFG); 151 val &= ~(0x3 << 5);
152 val &= ~(0x3 << 5); 152 val |= (0x1 << 5);
153 val |= (0x1 << 5); 153 __raw_writel(val, S5P64X0_PWR_CFG);
154 __raw_writel(val, S5P64X0_PWR_CFG);
155 154
156 cpu_do_idle(); 155 cpu_do_idle();
157 }
158 local_irq_enable();
159} 156}
160 157
161/* 158/*
@@ -287,7 +284,7 @@ int __init s5p64x0_init(void)
287 printk(KERN_INFO "S5P64X0(S5P6440/S5P6450): Initializing architecture\n"); 284 printk(KERN_INFO "S5P64X0(S5P6440/S5P6450): Initializing architecture\n");
288 285
289 /* set idle function */ 286 /* set idle function */
290 pm_idle = s5p64x0_idle; 287 arm_pm_idle = s5p64x0_idle;
291 288
292 return device_register(&s5p64x0_dev); 289 return device_register(&s5p64x0_dev);
293} 290}
diff --git a/arch/arm/mach-s5p64x0/dma.c b/arch/arm/mach-s5p64x0/dma.c
index f820c074440..2ee5dc069b3 100644
--- a/arch/arm/mach-s5p64x0/dma.c
+++ b/arch/arm/mach-s5p64x0/dma.c
@@ -38,7 +38,7 @@
38 38
39static u64 dma_dmamask = DMA_BIT_MASK(32); 39static u64 dma_dmamask = DMA_BIT_MASK(32);
40 40
41u8 s5p6440_pdma_peri[] = { 41static u8 s5p6440_pdma_peri[] = {
42 DMACH_UART0_RX, 42 DMACH_UART0_RX,
43 DMACH_UART0_TX, 43 DMACH_UART0_TX,
44 DMACH_UART1_RX, 44 DMACH_UART1_RX,
@@ -63,12 +63,12 @@ u8 s5p6440_pdma_peri[] = {
63 DMACH_SPI1_RX, 63 DMACH_SPI1_RX,
64}; 64};
65 65
66struct dma_pl330_platdata s5p6440_pdma_pdata = { 66static struct dma_pl330_platdata s5p6440_pdma_pdata = {
67 .nr_valid_peri = ARRAY_SIZE(s5p6440_pdma_peri), 67 .nr_valid_peri = ARRAY_SIZE(s5p6440_pdma_peri),
68 .peri_id = s5p6440_pdma_peri, 68 .peri_id = s5p6440_pdma_peri,
69}; 69};
70 70
71u8 s5p6450_pdma_peri[] = { 71static u8 s5p6450_pdma_peri[] = {
72 DMACH_UART0_RX, 72 DMACH_UART0_RX,
73 DMACH_UART0_TX, 73 DMACH_UART0_TX,
74 DMACH_UART1_RX, 74 DMACH_UART1_RX,
@@ -103,39 +103,27 @@ u8 s5p6450_pdma_peri[] = {
103 DMACH_UART5_TX, 103 DMACH_UART5_TX,
104}; 104};
105 105
106struct dma_pl330_platdata s5p6450_pdma_pdata = { 106static struct dma_pl330_platdata s5p6450_pdma_pdata = {
107 .nr_valid_peri = ARRAY_SIZE(s5p6450_pdma_peri), 107 .nr_valid_peri = ARRAY_SIZE(s5p6450_pdma_peri),
108 .peri_id = s5p6450_pdma_peri, 108 .peri_id = s5p6450_pdma_peri,
109}; 109};
110 110
111struct amba_device s5p64x0_device_pdma = { 111static AMBA_AHB_DEVICE(s5p64x0_pdma, "dma-pl330", 0x00041330,
112 .dev = { 112 S5P64X0_PA_PDMA, {IRQ_DMA0}, NULL);
113 .init_name = "dma-pl330",
114 .dma_mask = &dma_dmamask,
115 .coherent_dma_mask = DMA_BIT_MASK(32),
116 },
117 .res = {
118 .start = S5P64X0_PA_PDMA,
119 .end = S5P64X0_PA_PDMA + SZ_4K,
120 .flags = IORESOURCE_MEM,
121 },
122 .irq = {IRQ_DMA0, NO_IRQ},
123 .periphid = 0x00041330,
124};
125 113
126static int __init s5p64x0_dma_init(void) 114static int __init s5p64x0_dma_init(void)
127{ 115{
128 if (soc_is_s5p6450()) { 116 if (soc_is_s5p6450()) {
129 dma_cap_set(DMA_SLAVE, s5p6450_pdma_pdata.cap_mask); 117 dma_cap_set(DMA_SLAVE, s5p6450_pdma_pdata.cap_mask);
130 dma_cap_set(DMA_CYCLIC, s5p6450_pdma_pdata.cap_mask); 118 dma_cap_set(DMA_CYCLIC, s5p6450_pdma_pdata.cap_mask);
131 s5p64x0_device_pdma.dev.platform_data = &s5p6450_pdma_pdata; 119 s5p64x0_pdma_device.dev.platform_data = &s5p6450_pdma_pdata;
132 } else { 120 } else {
133 dma_cap_set(DMA_SLAVE, s5p6440_pdma_pdata.cap_mask); 121 dma_cap_set(DMA_SLAVE, s5p6440_pdma_pdata.cap_mask);
134 dma_cap_set(DMA_CYCLIC, s5p6440_pdma_pdata.cap_mask); 122 dma_cap_set(DMA_CYCLIC, s5p6440_pdma_pdata.cap_mask);
135 s5p64x0_device_pdma.dev.platform_data = &s5p6440_pdma_pdata; 123 s5p64x0_pdma_device.dev.platform_data = &s5p6440_pdma_pdata;
136 } 124 }
137 125
138 amba_device_register(&s5p64x0_device_pdma, &iomem_resource); 126 amba_device_register(&s5p64x0_pdma_device, &iomem_resource);
139 127
140 return 0; 128 return 0;
141} 129}
diff --git a/arch/arm/mach-s5p64x0/include/mach/entry-macro.S b/arch/arm/mach-s5p64x0/include/mach/entry-macro.S
deleted file mode 100644
index fbb246d0a3d..00000000000
--- a/arch/arm/mach-s5p64x0/include/mach/entry-macro.S
+++ /dev/null
@@ -1,17 +0,0 @@
1/* linux/arch/arm/mach-s5p64x0/include/mach/entry-macro.S
2 *
3 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * Low-level IRQ helper macros for the Samsung S5P64X0
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 .macro disable_fiq
14 .endm
15
16 .macro arch_ret_to_user, tmp1, tmp2
17 .endm
diff --git a/arch/arm/mach-s5p64x0/include/mach/s5p64x0-clock.h b/arch/arm/mach-s5p64x0/include/mach/s5p64x0-clock.h
index ff85b4b6e8d..0ef47d1b767 100644
--- a/arch/arm/mach-s5p64x0/include/mach/s5p64x0-clock.h
+++ b/arch/arm/mach-s5p64x0/include/mach/s5p64x0-clock.h
@@ -22,16 +22,9 @@ extern struct clksrc_clk clk_mout_epll;
22extern int s5p64x0_epll_enable(struct clk *clk, int enable); 22extern int s5p64x0_epll_enable(struct clk *clk, int enable);
23extern unsigned long s5p64x0_epll_get_rate(struct clk *clk); 23extern unsigned long s5p64x0_epll_get_rate(struct clk *clk);
24 24
25extern unsigned long s5p64x0_armclk_get_rate(struct clk *clk);
26extern unsigned long s5p64x0_armclk_round_rate(struct clk *clk, unsigned long rate);
27extern int s5p64x0_armclk_set_rate(struct clk *clk, unsigned long rate);
28
29extern struct clk_ops s5p64x0_clkarm_ops;
30
31extern struct clksrc_clk clk_armclk; 25extern struct clksrc_clk clk_armclk;
32extern struct clksrc_clk clk_dout_mpll; 26extern struct clksrc_clk clk_dout_mpll;
33 27
34extern struct clk *clkset_hclk_low_list[];
35extern struct clksrc_sources clkset_hclk_low; 28extern struct clksrc_sources clkset_hclk_low;
36 29
37extern int s5p64x0_pclk_ctrl(struct clk *clk, int enable); 30extern int s5p64x0_pclk_ctrl(struct clk *clk, int enable);
diff --git a/arch/arm/mach-s5p64x0/include/mach/system.h b/arch/arm/mach-s5p64x0/include/mach/system.h
deleted file mode 100644
index cf26e0954a2..00000000000
--- a/arch/arm/mach-s5p64x0/include/mach/system.h
+++ /dev/null
@@ -1,21 +0,0 @@
1/* linux/arch/arm/mach-s5p64x0/include/mach/system.h
2 *
3 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * S5P64X0 - system support header
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13#ifndef __ASM_ARCH_SYSTEM_H
14#define __ASM_ARCH_SYSTEM_H __FILE__
15
16static void arch_idle(void)
17{
18 /* nothing here yet */
19}
20
21#endif /* __ASM_ARCH_SYSTEM_H */
diff --git a/arch/arm/mach-s5pc100/clock.c b/arch/arm/mach-s5pc100/clock.c
index 247194dd366..16eca4ea201 100644
--- a/arch/arm/mach-s5pc100/clock.c
+++ b/arch/arm/mach-s5pc100/clock.c
@@ -170,7 +170,7 @@ static struct clk *clk_src_mout_am_list[] = {
170 [1] = &clk_div_apll2.clk, 170 [1] = &clk_div_apll2.clk,
171}; 171};
172 172
173struct clksrc_sources clk_src_mout_am = { 173static struct clksrc_sources clk_src_mout_am = {
174 .sources = clk_src_mout_am_list, 174 .sources = clk_src_mout_am_list,
175 .nr_sources = ARRAY_SIZE(clk_src_mout_am_list), 175 .nr_sources = ARRAY_SIZE(clk_src_mout_am_list),
176}; 176};
@@ -212,7 +212,7 @@ static struct clk *clk_src_mout_onenand_list[] = {
212 [1] = &clk_div_d1_bus.clk, 212 [1] = &clk_div_d1_bus.clk,
213}; 213};
214 214
215struct clksrc_sources clk_src_mout_onenand = { 215static struct clksrc_sources clk_src_mout_onenand = {
216 .sources = clk_src_mout_onenand_list, 216 .sources = clk_src_mout_onenand_list,
217 .nr_sources = ARRAY_SIZE(clk_src_mout_onenand_list), 217 .nr_sources = ARRAY_SIZE(clk_src_mout_onenand_list),
218}; 218};
@@ -756,7 +756,7 @@ static struct clk *clk_src_group1_list[] = {
756 [3] = &clk_mout_hpll.clk, 756 [3] = &clk_mout_hpll.clk,
757}; 757};
758 758
759struct clksrc_sources clk_src_group1 = { 759static struct clksrc_sources clk_src_group1 = {
760 .sources = clk_src_group1_list, 760 .sources = clk_src_group1_list,
761 .nr_sources = ARRAY_SIZE(clk_src_group1_list), 761 .nr_sources = ARRAY_SIZE(clk_src_group1_list),
762}; 762};
@@ -766,7 +766,7 @@ static struct clk *clk_src_group2_list[] = {
766 [1] = &clk_div_mpll.clk, 766 [1] = &clk_div_mpll.clk,
767}; 767};
768 768
769struct clksrc_sources clk_src_group2 = { 769static struct clksrc_sources clk_src_group2 = {
770 .sources = clk_src_group2_list, 770 .sources = clk_src_group2_list,
771 .nr_sources = ARRAY_SIZE(clk_src_group2_list), 771 .nr_sources = ARRAY_SIZE(clk_src_group2_list),
772}; 772};
@@ -780,7 +780,7 @@ static struct clk *clk_src_group3_list[] = {
780 [5] = &clk_mout_hpll.clk, 780 [5] = &clk_mout_hpll.clk,
781}; 781};
782 782
783struct clksrc_sources clk_src_group3 = { 783static struct clksrc_sources clk_src_group3 = {
784 .sources = clk_src_group3_list, 784 .sources = clk_src_group3_list,
785 .nr_sources = ARRAY_SIZE(clk_src_group3_list), 785 .nr_sources = ARRAY_SIZE(clk_src_group3_list),
786}; 786};
@@ -806,7 +806,7 @@ static struct clk *clk_src_group4_list[] = {
806 [5] = &clk_mout_hpll.clk, 806 [5] = &clk_mout_hpll.clk,
807}; 807};
808 808
809struct clksrc_sources clk_src_group4 = { 809static struct clksrc_sources clk_src_group4 = {
810 .sources = clk_src_group4_list, 810 .sources = clk_src_group4_list,
811 .nr_sources = ARRAY_SIZE(clk_src_group4_list), 811 .nr_sources = ARRAY_SIZE(clk_src_group4_list),
812}; 812};
@@ -831,7 +831,7 @@ static struct clk *clk_src_group5_list[] = {
831 [4] = &clk_mout_hpll.clk, 831 [4] = &clk_mout_hpll.clk,
832}; 832};
833 833
834struct clksrc_sources clk_src_group5 = { 834static struct clksrc_sources clk_src_group5 = {
835 .sources = clk_src_group5_list, 835 .sources = clk_src_group5_list,
836 .nr_sources = ARRAY_SIZE(clk_src_group5_list), 836 .nr_sources = ARRAY_SIZE(clk_src_group5_list),
837}; 837};
@@ -854,7 +854,7 @@ static struct clk *clk_src_group6_list[] = {
854 [2] = &clk_div_hdmi.clk, 854 [2] = &clk_div_hdmi.clk,
855}; 855};
856 856
857struct clksrc_sources clk_src_group6 = { 857static struct clksrc_sources clk_src_group6 = {
858 .sources = clk_src_group6_list, 858 .sources = clk_src_group6_list,
859 .nr_sources = ARRAY_SIZE(clk_src_group6_list), 859 .nr_sources = ARRAY_SIZE(clk_src_group6_list),
860}; 860};
@@ -866,7 +866,7 @@ static struct clk *clk_src_group7_list[] = {
866 [3] = &clk_vclk54m, 866 [3] = &clk_vclk54m,
867}; 867};
868 868
869struct clksrc_sources clk_src_group7 = { 869static struct clksrc_sources clk_src_group7 = {
870 .sources = clk_src_group7_list, 870 .sources = clk_src_group7_list,
871 .nr_sources = ARRAY_SIZE(clk_src_group7_list), 871 .nr_sources = ARRAY_SIZE(clk_src_group7_list),
872}; 872};
@@ -877,7 +877,7 @@ static struct clk *clk_src_mmc0_list[] = {
877 [2] = &clk_fin_epll, 877 [2] = &clk_fin_epll,
878}; 878};
879 879
880struct clksrc_sources clk_src_mmc0 = { 880static struct clksrc_sources clk_src_mmc0 = {
881 .sources = clk_src_mmc0_list, 881 .sources = clk_src_mmc0_list,
882 .nr_sources = ARRAY_SIZE(clk_src_mmc0_list), 882 .nr_sources = ARRAY_SIZE(clk_src_mmc0_list),
883}; 883};
@@ -889,7 +889,7 @@ static struct clk *clk_src_mmc12_list[] = {
889 [3] = &clk_mout_hpll.clk, 889 [3] = &clk_mout_hpll.clk,
890}; 890};
891 891
892struct clksrc_sources clk_src_mmc12 = { 892static struct clksrc_sources clk_src_mmc12 = {
893 .sources = clk_src_mmc12_list, 893 .sources = clk_src_mmc12_list,
894 .nr_sources = ARRAY_SIZE(clk_src_mmc12_list), 894 .nr_sources = ARRAY_SIZE(clk_src_mmc12_list),
895}; 895};
@@ -901,7 +901,7 @@ static struct clk *clk_src_irda_usb_list[] = {
901 [3] = &clk_mout_hpll.clk, 901 [3] = &clk_mout_hpll.clk,
902}; 902};
903 903
904struct clksrc_sources clk_src_irda_usb = { 904static struct clksrc_sources clk_src_irda_usb = {
905 .sources = clk_src_irda_usb_list, 905 .sources = clk_src_irda_usb_list,
906 .nr_sources = ARRAY_SIZE(clk_src_irda_usb_list), 906 .nr_sources = ARRAY_SIZE(clk_src_irda_usb_list),
907}; 907};
@@ -912,7 +912,7 @@ static struct clk *clk_src_pwi_list[] = {
912 [2] = &clk_div_mpll.clk, 912 [2] = &clk_div_mpll.clk,
913}; 913};
914 914
915struct clksrc_sources clk_src_pwi = { 915static struct clksrc_sources clk_src_pwi = {
916 .sources = clk_src_pwi_list, 916 .sources = clk_src_pwi_list,
917 .nr_sources = ARRAY_SIZE(clk_src_pwi_list), 917 .nr_sources = ARRAY_SIZE(clk_src_pwi_list),
918}; 918};
@@ -923,7 +923,7 @@ static struct clk *clk_sclk_spdif_list[] = {
923 [2] = &clk_sclk_audio2.clk, 923 [2] = &clk_sclk_audio2.clk,
924}; 924};
925 925
926struct clksrc_sources clk_src_sclk_spdif = { 926static struct clksrc_sources clk_src_sclk_spdif = {
927 .sources = clk_sclk_spdif_list, 927 .sources = clk_sclk_spdif_list,
928 .nr_sources = ARRAY_SIZE(clk_sclk_spdif_list), 928 .nr_sources = ARRAY_SIZE(clk_sclk_spdif_list),
929}; 929};
diff --git a/arch/arm/mach-s5pc100/common.c b/arch/arm/mach-s5pc100/common.c
index df3a41e8bb0..62190865886 100644
--- a/arch/arm/mach-s5pc100/common.c
+++ b/arch/arm/mach-s5pc100/common.c
@@ -130,14 +130,6 @@ static struct map_desc s5pc100_iodesc[] __initdata = {
130 } 130 }
131}; 131};
132 132
133static void s5pc100_idle(void)
134{
135 if (!need_resched())
136 cpu_do_idle();
137
138 local_irq_enable();
139}
140
141/* 133/*
142 * s5pc100_map_io 134 * s5pc100_map_io
143 * 135 *
@@ -211,10 +203,6 @@ core_initcall(s5pc100_core_init);
211int __init s5pc100_init(void) 203int __init s5pc100_init(void)
212{ 204{
213 printk(KERN_INFO "S5PC100: Initializing architecture\n"); 205 printk(KERN_INFO "S5PC100: Initializing architecture\n");
214
215 /* set idle function */
216 pm_idle = s5pc100_idle;
217
218 return device_register(&s5pc100_dev); 206 return device_register(&s5pc100_dev);
219} 207}
220 208
diff --git a/arch/arm/mach-s5pc100/dma.c b/arch/arm/mach-s5pc100/dma.c
index c841f4d313f..afd8db2d599 100644
--- a/arch/arm/mach-s5pc100/dma.c
+++ b/arch/arm/mach-s5pc100/dma.c
@@ -35,7 +35,7 @@
35 35
36static u64 dma_dmamask = DMA_BIT_MASK(32); 36static u64 dma_dmamask = DMA_BIT_MASK(32);
37 37
38u8 pdma0_peri[] = { 38static u8 pdma0_peri[] = {
39 DMACH_UART0_RX, 39 DMACH_UART0_RX,
40 DMACH_UART0_TX, 40 DMACH_UART0_TX,
41 DMACH_UART1_RX, 41 DMACH_UART1_RX,
@@ -68,28 +68,15 @@ u8 pdma0_peri[] = {
68 DMACH_HSI_TX, 68 DMACH_HSI_TX,
69}; 69};
70 70
71struct dma_pl330_platdata s5pc100_pdma0_pdata = { 71static struct dma_pl330_platdata s5pc100_pdma0_pdata = {
72 .nr_valid_peri = ARRAY_SIZE(pdma0_peri), 72 .nr_valid_peri = ARRAY_SIZE(pdma0_peri),
73 .peri_id = pdma0_peri, 73 .peri_id = pdma0_peri,
74}; 74};
75 75
76struct amba_device s5pc100_device_pdma0 = { 76static AMBA_AHB_DEVICE(s5pc100_pdma0, "dma-pl330.0", 0x00041330,
77 .dev = { 77 S5PC100_PA_PDMA0, {IRQ_PDMA0}, &s5pc100_pdma0_pdata);
78 .init_name = "dma-pl330.0",
79 .dma_mask = &dma_dmamask,
80 .coherent_dma_mask = DMA_BIT_MASK(32),
81 .platform_data = &s5pc100_pdma0_pdata,
82 },
83 .res = {
84 .start = S5PC100_PA_PDMA0,
85 .end = S5PC100_PA_PDMA0 + SZ_4K,
86 .flags = IORESOURCE_MEM,
87 },
88 .irq = {IRQ_PDMA0, NO_IRQ},
89 .periphid = 0x00041330,
90};
91 78
92u8 pdma1_peri[] = { 79static u8 pdma1_peri[] = {
93 DMACH_UART0_RX, 80 DMACH_UART0_RX,
94 DMACH_UART0_TX, 81 DMACH_UART0_TX,
95 DMACH_UART1_RX, 82 DMACH_UART1_RX,
@@ -122,36 +109,23 @@ u8 pdma1_peri[] = {
122 DMACH_MSM_REQ3, 109 DMACH_MSM_REQ3,
123}; 110};
124 111
125struct dma_pl330_platdata s5pc100_pdma1_pdata = { 112static struct dma_pl330_platdata s5pc100_pdma1_pdata = {
126 .nr_valid_peri = ARRAY_SIZE(pdma1_peri), 113 .nr_valid_peri = ARRAY_SIZE(pdma1_peri),
127 .peri_id = pdma1_peri, 114 .peri_id = pdma1_peri,
128}; 115};
129 116
130struct amba_device s5pc100_device_pdma1 = { 117static AMBA_AHB_DEVICE(s5pc100_pdma1, "dma-pl330.1", 0x00041330,
131 .dev = { 118 S5PC100_PA_PDMA1, {IRQ_PDMA1}, &s5pc100_pdma1_pdata);
132 .init_name = "dma-pl330.1",
133 .dma_mask = &dma_dmamask,
134 .coherent_dma_mask = DMA_BIT_MASK(32),
135 .platform_data = &s5pc100_pdma1_pdata,
136 },
137 .res = {
138 .start = S5PC100_PA_PDMA1,
139 .end = S5PC100_PA_PDMA1 + SZ_4K,
140 .flags = IORESOURCE_MEM,
141 },
142 .irq = {IRQ_PDMA1, NO_IRQ},
143 .periphid = 0x00041330,
144};
145 119
146static int __init s5pc100_dma_init(void) 120static int __init s5pc100_dma_init(void)
147{ 121{
148 dma_cap_set(DMA_SLAVE, s5pc100_pdma0_pdata.cap_mask); 122 dma_cap_set(DMA_SLAVE, s5pc100_pdma0_pdata.cap_mask);
149 dma_cap_set(DMA_CYCLIC, s5pc100_pdma0_pdata.cap_mask); 123 dma_cap_set(DMA_CYCLIC, s5pc100_pdma0_pdata.cap_mask);
150 amba_device_register(&s5pc100_device_pdma0, &iomem_resource); 124 amba_device_register(&s5pc100_pdma0_device, &iomem_resource);
151 125
152 dma_cap_set(DMA_SLAVE, s5pc100_pdma1_pdata.cap_mask); 126 dma_cap_set(DMA_SLAVE, s5pc100_pdma1_pdata.cap_mask);
153 dma_cap_set(DMA_CYCLIC, s5pc100_pdma1_pdata.cap_mask); 127 dma_cap_set(DMA_CYCLIC, s5pc100_pdma1_pdata.cap_mask);
154 amba_device_register(&s5pc100_device_pdma1, &iomem_resource); 128 amba_device_register(&s5pc100_pdma1_device, &iomem_resource);
155 129
156 return 0; 130 return 0;
157} 131}
diff --git a/arch/arm/mach-s5pc100/include/mach/entry-macro.S b/arch/arm/mach-s5pc100/include/mach/entry-macro.S
index b8c242edfa2..bad0700457d 100644
--- a/arch/arm/mach-s5pc100/include/mach/entry-macro.S
+++ b/arch/arm/mach-s5pc100/include/mach/entry-macro.S
@@ -12,14 +12,8 @@
12 * warranty of any kind, whether express or implied. 12 * warranty of any kind, whether express or implied.
13*/ 13*/
14 14
15 .macro disable_fiq
16 .endm
17
18 .macro get_irqnr_preamble, base, tmp 15 .macro get_irqnr_preamble, base, tmp
19 .endm 16 .endm
20 17
21 .macro arch_ret_to_user, tmp1, tmp2
22 .endm
23
24 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp 18 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
25 .endm 19 .endm
diff --git a/arch/arm/mach-s5pc100/include/mach/system.h b/arch/arm/mach-s5pc100/include/mach/system.h
deleted file mode 100644
index afc96c29851..00000000000
--- a/arch/arm/mach-s5pc100/include/mach/system.h
+++ /dev/null
@@ -1,19 +0,0 @@
1/* linux/arch/arm/mach-s5pc100/include/mach/system.h
2 *
3 * Copyright 2009 Samsung Electronics Co.
4 * Byungho Min <bhmin@samsung.com>
5 *
6 * S5PC100 - system implementation
7 *
8 * Based on mach-s3c6400/include/mach/system.h
9 */
10
11#ifndef __ASM_ARCH_SYSTEM_H
12#define __ASM_ARCH_SYSTEM_H __FILE__
13
14static void arch_idle(void)
15{
16 /* nothing here yet */
17}
18
19#endif /* __ASM_ARCH_IRQ_H */
diff --git a/arch/arm/mach-s5pv210/Kconfig b/arch/arm/mach-s5pv210/Kconfig
index 2cdc42e838b..29594fc4fdf 100644
--- a/arch/arm/mach-s5pv210/Kconfig
+++ b/arch/arm/mach-s5pv210/Kconfig
@@ -65,6 +65,11 @@ config S5PV210_SETUP_SPI
65 help 65 help
66 Common setup code for SPI GPIO configurations. 66 Common setup code for SPI GPIO configurations.
67 67
68config S5PV210_SETUP_USB_PHY
69 bool
70 help
71 Common setup code for USB PHY controller
72
68menu "S5PC110 Machines" 73menu "S5PC110 Machines"
69 74
70config MACH_AQUILA 75config MACH_AQUILA
@@ -107,6 +112,7 @@ config MACH_GONI
107 select S5PV210_SETUP_KEYPAD 112 select S5PV210_SETUP_KEYPAD
108 select S5PV210_SETUP_SDHCI 113 select S5PV210_SETUP_SDHCI
109 select S5PV210_SETUP_FIMC 114 select S5PV210_SETUP_FIMC
115 select S5PV210_SETUP_USB_PHY
110 help 116 help
111 Machine support for Samsung GONI board 117 Machine support for Samsung GONI board
112 S5PC110(MCP) is one of package option of S5PV210 118 S5PC110(MCP) is one of package option of S5PV210
@@ -118,6 +124,10 @@ config MACH_SMDKC110
118 select S3C_DEV_I2C2 124 select S3C_DEV_I2C2
119 select S3C_DEV_RTC 125 select S3C_DEV_RTC
120 select S3C_DEV_WDT 126 select S3C_DEV_WDT
127 select S5P_DEV_FIMC0
128 select S5P_DEV_FIMC1
129 select S5P_DEV_FIMC2
130 select S5P_DEV_MFC
121 select SAMSUNG_DEV_IDE 131 select SAMSUNG_DEV_IDE
122 select S5PV210_SETUP_I2C1 132 select S5PV210_SETUP_I2C1
123 select S5PV210_SETUP_I2C2 133 select S5PV210_SETUP_I2C2
@@ -142,6 +152,11 @@ config MACH_SMDKV210
142 select S3C_DEV_I2C2 152 select S3C_DEV_I2C2
143 select S3C_DEV_RTC 153 select S3C_DEV_RTC
144 select S3C_DEV_WDT 154 select S3C_DEV_WDT
155 select S5P_DEV_FIMC0
156 select S5P_DEV_FIMC1
157 select S5P_DEV_FIMC2
158 select S5P_DEV_JPEG
159 select S5P_DEV_MFC
145 select SAMSUNG_DEV_ADC 160 select SAMSUNG_DEV_ADC
146 select SAMSUNG_DEV_BACKLIGHT 161 select SAMSUNG_DEV_BACKLIGHT
147 select SAMSUNG_DEV_IDE 162 select SAMSUNG_DEV_IDE
diff --git a/arch/arm/mach-s5pv210/Makefile b/arch/arm/mach-s5pv210/Makefile
index 76a121dd52b..1c4e41998a1 100644
--- a/arch/arm/mach-s5pv210/Makefile
+++ b/arch/arm/mach-s5pv210/Makefile
@@ -39,3 +39,4 @@ obj-$(CONFIG_S5PV210_SETUP_IDE) += setup-ide.o
39obj-$(CONFIG_S5PV210_SETUP_KEYPAD) += setup-keypad.o 39obj-$(CONFIG_S5PV210_SETUP_KEYPAD) += setup-keypad.o
40obj-$(CONFIG_S5PV210_SETUP_SDHCI_GPIO) += setup-sdhci-gpio.o 40obj-$(CONFIG_S5PV210_SETUP_SDHCI_GPIO) += setup-sdhci-gpio.o
41obj-$(CONFIG_S5PV210_SETUP_SPI) += setup-spi.o 41obj-$(CONFIG_S5PV210_SETUP_SPI) += setup-spi.o
42obj-$(CONFIG_S5PV210_SETUP_USB_PHY) += setup-usb-phy.o
diff --git a/arch/arm/mach-s5pv210/clock.c b/arch/arm/mach-s5pv210/clock.c
index b9ec0c35379..09609d50961 100644
--- a/arch/arm/mach-s5pv210/clock.c
+++ b/arch/arm/mach-s5pv210/clock.c
@@ -340,6 +340,11 @@ static struct clk init_clocks_off[] = {
340 .enable = s5pv210_clk_ip0_ctrl, 340 .enable = s5pv210_clk_ip0_ctrl,
341 .ctrlbit = (1 << 26), 341 .ctrlbit = (1 << 26),
342 }, { 342 }, {
343 .name = "jpeg",
344 .parent = &clk_hclk_dsys.clk,
345 .enable = s5pv210_clk_ip0_ctrl,
346 .ctrlbit = (1 << 28),
347 }, {
343 .name = "mfc", 348 .name = "mfc",
344 .devname = "s5p-mfc", 349 .devname = "s5p-mfc",
345 .parent = &clk_pclk_psys.clk, 350 .parent = &clk_pclk_psys.clk,
diff --git a/arch/arm/mach-s5pv210/common.c b/arch/arm/mach-s5pv210/common.c
index 9c1bcdcc12c..4c9e9027df9 100644
--- a/arch/arm/mach-s5pv210/common.c
+++ b/arch/arm/mach-s5pv210/common.c
@@ -142,14 +142,6 @@ static struct map_desc s5pv210_iodesc[] __initdata = {
142 } 142 }
143}; 143};
144 144
145static void s5pv210_idle(void)
146{
147 if (!need_resched())
148 cpu_do_idle();
149
150 local_irq_enable();
151}
152
153void s5pv210_restart(char mode, const char *cmd) 145void s5pv210_restart(char mode, const char *cmd)
154{ 146{
155 __raw_writel(0x1, S5P_SWRESET); 147 __raw_writel(0x1, S5P_SWRESET);
@@ -247,10 +239,6 @@ core_initcall(s5pv210_core_init);
247int __init s5pv210_init(void) 239int __init s5pv210_init(void)
248{ 240{
249 printk(KERN_INFO "S5PV210: Initializing architecture\n"); 241 printk(KERN_INFO "S5PV210: Initializing architecture\n");
250
251 /* set idle function */
252 pm_idle = s5pv210_idle;
253
254 return device_register(&s5pv210_dev); 242 return device_register(&s5pv210_dev);
255} 243}
256 244
diff --git a/arch/arm/mach-s5pv210/dma.c b/arch/arm/mach-s5pv210/dma.c
index a6113e0267f..86ce62f6619 100644
--- a/arch/arm/mach-s5pv210/dma.c
+++ b/arch/arm/mach-s5pv210/dma.c
@@ -35,7 +35,7 @@
35 35
36static u64 dma_dmamask = DMA_BIT_MASK(32); 36static u64 dma_dmamask = DMA_BIT_MASK(32);
37 37
38u8 pdma0_peri[] = { 38static u8 pdma0_peri[] = {
39 DMACH_UART0_RX, 39 DMACH_UART0_RX,
40 DMACH_UART0_TX, 40 DMACH_UART0_TX,
41 DMACH_UART1_RX, 41 DMACH_UART1_RX,
@@ -66,28 +66,15 @@ u8 pdma0_peri[] = {
66 DMACH_SPDIF, 66 DMACH_SPDIF,
67}; 67};
68 68
69struct dma_pl330_platdata s5pv210_pdma0_pdata = { 69static struct dma_pl330_platdata s5pv210_pdma0_pdata = {
70 .nr_valid_peri = ARRAY_SIZE(pdma0_peri), 70 .nr_valid_peri = ARRAY_SIZE(pdma0_peri),
71 .peri_id = pdma0_peri, 71 .peri_id = pdma0_peri,
72}; 72};
73 73
74struct amba_device s5pv210_device_pdma0 = { 74static AMBA_AHB_DEVICE(s5pv210_pdma0, "dma-pl330.0", 0x00041330,
75 .dev = { 75 S5PV210_PA_PDMA0, {IRQ_PDMA0}, &s5pv210_pdma0_pdata);
76 .init_name = "dma-pl330.0",
77 .dma_mask = &dma_dmamask,
78 .coherent_dma_mask = DMA_BIT_MASK(32),
79 .platform_data = &s5pv210_pdma0_pdata,
80 },
81 .res = {
82 .start = S5PV210_PA_PDMA0,
83 .end = S5PV210_PA_PDMA0 + SZ_4K,
84 .flags = IORESOURCE_MEM,
85 },
86 .irq = {IRQ_PDMA0, NO_IRQ},
87 .periphid = 0x00041330,
88};
89 76
90u8 pdma1_peri[] = { 77static u8 pdma1_peri[] = {
91 DMACH_UART0_RX, 78 DMACH_UART0_RX,
92 DMACH_UART0_TX, 79 DMACH_UART0_TX,
93 DMACH_UART1_RX, 80 DMACH_UART1_RX,
@@ -122,36 +109,23 @@ u8 pdma1_peri[] = {
122 DMACH_PCM2_TX, 109 DMACH_PCM2_TX,
123}; 110};
124 111
125struct dma_pl330_platdata s5pv210_pdma1_pdata = { 112static struct dma_pl330_platdata s5pv210_pdma1_pdata = {
126 .nr_valid_peri = ARRAY_SIZE(pdma1_peri), 113 .nr_valid_peri = ARRAY_SIZE(pdma1_peri),
127 .peri_id = pdma1_peri, 114 .peri_id = pdma1_peri,
128}; 115};
129 116
130struct amba_device s5pv210_device_pdma1 = { 117static AMBA_AHB_DEVICE(s5pv210_pdma1, "dma-pl330.1", 0x00041330,
131 .dev = { 118 S5PV210_PA_PDMA1, {IRQ_PDMA1}, &s5pv210_pdma1_pdata);
132 .init_name = "dma-pl330.1",
133 .dma_mask = &dma_dmamask,
134 .coherent_dma_mask = DMA_BIT_MASK(32),
135 .platform_data = &s5pv210_pdma1_pdata,
136 },
137 .res = {
138 .start = S5PV210_PA_PDMA1,
139 .end = S5PV210_PA_PDMA1 + SZ_4K,
140 .flags = IORESOURCE_MEM,
141 },
142 .irq = {IRQ_PDMA1, NO_IRQ},
143 .periphid = 0x00041330,
144};
145 119
146static int __init s5pv210_dma_init(void) 120static int __init s5pv210_dma_init(void)
147{ 121{
148 dma_cap_set(DMA_SLAVE, s5pv210_pdma0_pdata.cap_mask); 122 dma_cap_set(DMA_SLAVE, s5pv210_pdma0_pdata.cap_mask);
149 dma_cap_set(DMA_CYCLIC, s5pv210_pdma0_pdata.cap_mask); 123 dma_cap_set(DMA_CYCLIC, s5pv210_pdma0_pdata.cap_mask);
150 amba_device_register(&s5pv210_device_pdma0, &iomem_resource); 124 amba_device_register(&s5pv210_pdma0_device, &iomem_resource);
151 125
152 dma_cap_set(DMA_SLAVE, s5pv210_pdma1_pdata.cap_mask); 126 dma_cap_set(DMA_SLAVE, s5pv210_pdma1_pdata.cap_mask);
153 dma_cap_set(DMA_CYCLIC, s5pv210_pdma1_pdata.cap_mask); 127 dma_cap_set(DMA_CYCLIC, s5pv210_pdma1_pdata.cap_mask);
154 amba_device_register(&s5pv210_device_pdma1, &iomem_resource); 128 amba_device_register(&s5pv210_pdma1_device, &iomem_resource);
155 129
156 return 0; 130 return 0;
157} 131}
diff --git a/arch/arm/mach-s5pv210/include/mach/entry-macro.S b/arch/arm/mach-s5pv210/include/mach/entry-macro.S
deleted file mode 100644
index bebca1b5d0b..00000000000
--- a/arch/arm/mach-s5pv210/include/mach/entry-macro.S
+++ /dev/null
@@ -1,17 +0,0 @@
1/* linux/arch/arm/mach-s5pv210/include/mach/entry-macro.S
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
5 *
6 * Low-level IRQ helper macros for the Samsung S5PV210
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13 .macro disable_fiq
14 .endm
15
16 .macro arch_ret_to_user, tmp1, tmp2
17 .endm
diff --git a/arch/arm/mach-s5pv210/include/mach/map.h b/arch/arm/mach-s5pv210/include/mach/map.h
index 89c34b8f73b..b7c8a1917ff 100644
--- a/arch/arm/mach-s5pv210/include/mach/map.h
+++ b/arch/arm/mach-s5pv210/include/mach/map.h
@@ -90,6 +90,8 @@
90#define S5PV210_PA_FIMC1 0xFB300000 90#define S5PV210_PA_FIMC1 0xFB300000
91#define S5PV210_PA_FIMC2 0xFB400000 91#define S5PV210_PA_FIMC2 0xFB400000
92 92
93#define S5PV210_PA_JPEG 0xFB600000
94
93#define S5PV210_PA_SDO 0xF9000000 95#define S5PV210_PA_SDO 0xF9000000
94#define S5PV210_PA_VP 0xF9100000 96#define S5PV210_PA_VP 0xF9100000
95#define S5PV210_PA_MIXER 0xF9200000 97#define S5PV210_PA_MIXER 0xF9200000
@@ -132,6 +134,8 @@
132#define S5P_PA_SYSCON S5PV210_PA_SYSCON 134#define S5P_PA_SYSCON S5PV210_PA_SYSCON
133#define S5P_PA_TIMER S5PV210_PA_TIMER 135#define S5P_PA_TIMER S5PV210_PA_TIMER
134 136
137#define S5P_PA_JPEG S5PV210_PA_JPEG
138
135#define SAMSUNG_PA_ADC S5PV210_PA_ADC 139#define SAMSUNG_PA_ADC S5PV210_PA_ADC
136#define SAMSUNG_PA_CFCON S5PV210_PA_CFCON 140#define SAMSUNG_PA_CFCON S5PV210_PA_CFCON
137#define SAMSUNG_PA_KEYPAD S5PV210_PA_KEYPAD 141#define SAMSUNG_PA_KEYPAD S5PV210_PA_KEYPAD
diff --git a/arch/arm/mach-s5pv210/include/mach/regs-sys.h b/arch/arm/mach-s5pv210/include/mach/regs-sys.h
index 26691d39d0f..cccb1eddaa3 100644
--- a/arch/arm/mach-s5pv210/include/mach/regs-sys.h
+++ b/arch/arm/mach-s5pv210/include/mach/regs-sys.h
@@ -13,7 +13,3 @@
13#define S5PV210_USB_PHY_CON (S3C_VA_SYS + 0xE80C) 13#define S5PV210_USB_PHY_CON (S3C_VA_SYS + 0xE80C)
14#define S5PV210_USB_PHY0_EN (1 << 0) 14#define S5PV210_USB_PHY0_EN (1 << 0)
15#define S5PV210_USB_PHY1_EN (1 << 1) 15#define S5PV210_USB_PHY1_EN (1 << 1)
16
17/* compatibility defines for s3c-hsotg driver */
18#define S3C64XX_OTHERS S5PV210_USB_PHY_CON
19#define S3C64XX_OTHERS_USBMASK S5PV210_USB_PHY0_EN
diff --git a/arch/arm/mach-s5pv210/include/mach/system.h b/arch/arm/mach-s5pv210/include/mach/system.h
deleted file mode 100644
index bf288ced860..00000000000
--- a/arch/arm/mach-s5pv210/include/mach/system.h
+++ /dev/null
@@ -1,21 +0,0 @@
1/* linux/arch/arm/mach-s5pv210/include/mach/system.h
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com/
5 *
6 * S5PV210 - system support header
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13#ifndef __ASM_ARCH_SYSTEM_H
14#define __ASM_ARCH_SYSTEM_H __FILE__
15
16static void arch_idle(void)
17{
18 /* nothing here yet */
19}
20
21#endif /* __ASM_ARCH_SYSTEM_H */
diff --git a/arch/arm/mach-s5pv210/mach-aquila.c b/arch/arm/mach-s5pv210/mach-aquila.c
index 5e734d025a6..a9ea64e0da0 100644
--- a/arch/arm/mach-s5pv210/mach-aquila.c
+++ b/arch/arm/mach-s5pv210/mach-aquila.c
@@ -616,6 +616,7 @@ static struct platform_device *aquila_devices[] __initdata = {
616 &s5p_device_fimc0, 616 &s5p_device_fimc0,
617 &s5p_device_fimc1, 617 &s5p_device_fimc1,
618 &s5p_device_fimc2, 618 &s5p_device_fimc2,
619 &s5p_device_fimc_md,
619 &s5pv210_device_iis0, 620 &s5pv210_device_iis0,
620 &wm8994_fixed_voltage0, 621 &wm8994_fixed_voltage0,
621 &wm8994_fixed_voltage1, 622 &wm8994_fixed_voltage1,
diff --git a/arch/arm/mach-s5pv210/mach-goni.c b/arch/arm/mach-s5pv210/mach-goni.c
index ff915261043..2cf5ed75f39 100644
--- a/arch/arm/mach-s5pv210/mach-goni.c
+++ b/arch/arm/mach-s5pv210/mach-goni.c
@@ -844,7 +844,7 @@ static struct s5p_fimc_isp_info goni_camera_sensors[] = {
844 }, 844 },
845}; 845};
846 846
847struct s5p_platform_fimc goni_fimc_md_platdata __initdata = { 847static struct s5p_platform_fimc goni_fimc_md_platdata __initdata = {
848 .isp_info = goni_camera_sensors, 848 .isp_info = goni_camera_sensors,
849 .num_clients = ARRAY_SIZE(goni_camera_sensors), 849 .num_clients = ARRAY_SIZE(goni_camera_sensors),
850}; 850};
diff --git a/arch/arm/mach-s5pv210/mach-smdkc110.c b/arch/arm/mach-s5pv210/mach-smdkc110.c
index b323983b2c5..dfc29236321 100644
--- a/arch/arm/mach-s5pv210/mach-smdkc110.c
+++ b/arch/arm/mach-s5pv210/mach-smdkc110.c
@@ -31,6 +31,7 @@
31#include <plat/iic.h> 31#include <plat/iic.h>
32#include <plat/pm.h> 32#include <plat/pm.h>
33#include <plat/s5p-time.h> 33#include <plat/s5p-time.h>
34#include <plat/mfc.h>
34 35
35#include "common.h" 36#include "common.h"
36 37
@@ -94,6 +95,13 @@ static struct platform_device *smdkc110_devices[] __initdata = {
94 &s3c_device_i2c2, 95 &s3c_device_i2c2,
95 &s3c_device_rtc, 96 &s3c_device_rtc,
96 &s3c_device_wdt, 97 &s3c_device_wdt,
98 &s5p_device_fimc0,
99 &s5p_device_fimc1,
100 &s5p_device_fimc2,
101 &s5p_device_fimc_md,
102 &s5p_device_mfc,
103 &s5p_device_mfc_l,
104 &s5p_device_mfc_r,
97}; 105};
98 106
99static struct i2c_board_info smdkc110_i2c_devs0[] __initdata = { 107static struct i2c_board_info smdkc110_i2c_devs0[] __initdata = {
@@ -117,6 +125,11 @@ static void __init smdkc110_map_io(void)
117 s5p_set_timer_source(S5P_PWM3, S5P_PWM4); 125 s5p_set_timer_source(S5P_PWM3, S5P_PWM4);
118} 126}
119 127
128static void __init smdkc110_reserve(void)
129{
130 s5p_mfc_reserve_mem(0x43000000, 8 << 20, 0x51000000, 8 << 20);
131}
132
120static void __init smdkc110_machine_init(void) 133static void __init smdkc110_machine_init(void)
121{ 134{
122 s3c_pm_init(); 135 s3c_pm_init();
@@ -145,4 +158,5 @@ MACHINE_START(SMDKC110, "SMDKC110")
145 .init_machine = smdkc110_machine_init, 158 .init_machine = smdkc110_machine_init,
146 .timer = &s5p_timer, 159 .timer = &s5p_timer,
147 .restart = s5pv210_restart, 160 .restart = s5pv210_restart,
161 .reserve = &smdkc110_reserve,
148MACHINE_END 162MACHINE_END
diff --git a/arch/arm/mach-s5pv210/mach-smdkv210.c b/arch/arm/mach-s5pv210/mach-smdkv210.c
index dff9ea7b5bb..91d4ad8bcc7 100644
--- a/arch/arm/mach-s5pv210/mach-smdkv210.c
+++ b/arch/arm/mach-s5pv210/mach-smdkv210.c
@@ -46,6 +46,7 @@
46#include <plat/s5p-time.h> 46#include <plat/s5p-time.h>
47#include <plat/backlight.h> 47#include <plat/backlight.h>
48#include <plat/regs-fb-v4.h> 48#include <plat/regs-fb-v4.h>
49#include <plat/mfc.h>
49 50
50#include "common.h" 51#include "common.h"
51 52
@@ -140,7 +141,7 @@ static struct dm9000_plat_data smdkv210_dm9000_platdata = {
140 .dev_addr = { 0x00, 0x09, 0xc0, 0xff, 0xec, 0x48 }, 141 .dev_addr = { 0x00, 0x09, 0xc0, 0xff, 0xec, 0x48 },
141}; 142};
142 143
143struct platform_device smdkv210_dm9000 = { 144static struct platform_device smdkv210_dm9000 = {
144 .name = "dm9000", 145 .name = "dm9000",
145 .id = -1, 146 .id = -1,
146 .num_resources = ARRAY_SIZE(smdkv210_dm9000_resources), 147 .num_resources = ARRAY_SIZE(smdkv210_dm9000_resources),
@@ -223,6 +224,14 @@ static struct platform_device *smdkv210_devices[] __initdata = {
223 &s3c_device_rtc, 224 &s3c_device_rtc,
224 &s3c_device_ts, 225 &s3c_device_ts,
225 &s3c_device_wdt, 226 &s3c_device_wdt,
227 &s5p_device_fimc0,
228 &s5p_device_fimc1,
229 &s5p_device_fimc2,
230 &s5p_device_fimc_md,
231 &s5p_device_jpeg,
232 &s5p_device_mfc,
233 &s5p_device_mfc_l,
234 &s5p_device_mfc_r,
226 &s5pv210_device_ac97, 235 &s5pv210_device_ac97,
227 &s5pv210_device_iis0, 236 &s5pv210_device_iis0,
228 &s5pv210_device_spdif, 237 &s5pv210_device_spdif,
@@ -282,6 +291,11 @@ static void __init smdkv210_map_io(void)
282 s5p_set_timer_source(S5P_PWM2, S5P_PWM4); 291 s5p_set_timer_source(S5P_PWM2, S5P_PWM4);
283} 292}
284 293
294static void __init smdkv210_reserve(void)
295{
296 s5p_mfc_reserve_mem(0x43000000, 8 << 20, 0x51000000, 8 << 20);
297}
298
285static void __init smdkv210_machine_init(void) 299static void __init smdkv210_machine_init(void)
286{ 300{
287 s3c_pm_init(); 301 s3c_pm_init();
@@ -319,4 +333,5 @@ MACHINE_START(SMDKV210, "SMDKV210")
319 .init_machine = smdkv210_machine_init, 333 .init_machine = smdkv210_machine_init,
320 .timer = &s5p_timer, 334 .timer = &s5p_timer,
321 .restart = s5pv210_restart, 335 .restart = s5pv210_restart,
336 .reserve = &smdkv210_reserve,
322MACHINE_END 337MACHINE_END
diff --git a/arch/arm/mach-s5pv210/setup-usb-phy.c b/arch/arm/mach-s5pv210/setup-usb-phy.c
new file mode 100644
index 00000000000..be39cf4aa91
--- /dev/null
+++ b/arch/arm/mach-s5pv210/setup-usb-phy.c
@@ -0,0 +1,90 @@
1/*
2 * Copyright (C) 2012 Samsung Electronics Co.Ltd
3 * Author: Joonyoung Shim <jy0922.shim@samsung.com>
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 Foundationr
8 */
9
10#include <linux/clk.h>
11#include <linux/delay.h>
12#include <linux/err.h>
13#include <linux/io.h>
14#include <linux/platform_device.h>
15#include <mach/map.h>
16#include <mach/regs-sys.h>
17#include <plat/cpu.h>
18#include <plat/regs-usb-hsotg-phy.h>
19#include <plat/usb-phy.h>
20
21static int s5pv210_usb_otgphy_init(struct platform_device *pdev)
22{
23 struct clk *xusbxti;
24 u32 phyclk;
25
26 writel(readl(S5PV210_USB_PHY_CON) | S5PV210_USB_PHY0_EN,
27 S5PV210_USB_PHY_CON);
28
29 /* set clock frequency for PLL */
30 phyclk = readl(S3C_PHYCLK) & ~S3C_PHYCLK_CLKSEL_MASK;
31
32 xusbxti = clk_get(&pdev->dev, "xusbxti");
33 if (xusbxti && !IS_ERR(xusbxti)) {
34 switch (clk_get_rate(xusbxti)) {
35 case 12 * MHZ:
36 phyclk |= S3C_PHYCLK_CLKSEL_12M;
37 break;
38 case 24 * MHZ:
39 phyclk |= S3C_PHYCLK_CLKSEL_24M;
40 break;
41 default:
42 case 48 * MHZ:
43 /* default reference clock */
44 break;
45 }
46 clk_put(xusbxti);
47 }
48
49 /* TODO: select external clock/oscillator */
50 writel(phyclk | S3C_PHYCLK_CLK_FORCE, S3C_PHYCLK);
51
52 /* set to normal OTG PHY */
53 writel((readl(S3C_PHYPWR) & ~S3C_PHYPWR_NORMAL_MASK), S3C_PHYPWR);
54 mdelay(1);
55
56 /* reset OTG PHY and Link */
57 writel(S3C_RSTCON_PHY | S3C_RSTCON_HCLK | S3C_RSTCON_PHYCLK,
58 S3C_RSTCON);
59 udelay(20); /* at-least 10uS */
60 writel(0, S3C_RSTCON);
61
62 return 0;
63}
64
65static int s5pv210_usb_otgphy_exit(struct platform_device *pdev)
66{
67 writel((readl(S3C_PHYPWR) | S3C_PHYPWR_ANALOG_POWERDOWN |
68 S3C_PHYPWR_OTG_DISABLE), S3C_PHYPWR);
69
70 writel(readl(S5PV210_USB_PHY_CON) & ~S5PV210_USB_PHY0_EN,
71 S5PV210_USB_PHY_CON);
72
73 return 0;
74}
75
76int s5p_usb_phy_init(struct platform_device *pdev, int type)
77{
78 if (type == S5P_USB_PHY_DEVICE)
79 return s5pv210_usb_otgphy_init(pdev);
80
81 return -EINVAL;
82}
83
84int s5p_usb_phy_exit(struct platform_device *pdev, int type)
85{
86 if (type == S5P_USB_PHY_DEVICE)
87 return s5pv210_usb_otgphy_exit(pdev);
88
89 return -EINVAL;
90}
diff --git a/arch/arm/mach-sa1100/Makefile b/arch/arm/mach-sa1100/Makefile
index ed7408d3216..60b97ec0167 100644
--- a/arch/arm/mach-sa1100/Makefile
+++ b/arch/arm/mach-sa1100/Makefile
@@ -3,7 +3,7 @@
3# 3#
4 4
5# Common support 5# Common support
6obj-y := clock.o generic.o irq.o dma.o time.o #nmi-oopser.o 6obj-y := clock.o generic.o irq.o time.o #nmi-oopser.o
7obj-m := 7obj-m :=
8obj-n := 8obj-n :=
9obj- := 9obj- :=
diff --git a/arch/arm/mach-sa1100/assabet.c b/arch/arm/mach-sa1100/assabet.c
index 0c4b76ab4d8..375d3f779a8 100644
--- a/arch/arm/mach-sa1100/assabet.c
+++ b/arch/arm/mach-sa1100/assabet.c
@@ -15,14 +15,16 @@
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/ioport.h> 16#include <linux/ioport.h>
17#include <linux/serial_core.h> 17#include <linux/serial_core.h>
18#include <linux/mfd/ucb1x00.h>
18#include <linux/mtd/mtd.h> 19#include <linux/mtd/mtd.h>
19#include <linux/mtd/partitions.h> 20#include <linux/mtd/partitions.h>
20#include <linux/delay.h> 21#include <linux/delay.h>
21#include <linux/mm.h> 22#include <linux/mm.h>
22 23
24#include <video/sa1100fb.h>
25
23#include <mach/hardware.h> 26#include <mach/hardware.h>
24#include <asm/mach-types.h> 27#include <asm/mach-types.h>
25#include <asm/irq.h>
26#include <asm/setup.h> 28#include <asm/setup.h>
27#include <asm/page.h> 29#include <asm/page.h>
28#include <asm/pgtable-hwdef.h> 30#include <asm/pgtable-hwdef.h>
@@ -36,17 +38,18 @@
36#include <asm/mach/serial_sa1100.h> 38#include <asm/mach/serial_sa1100.h>
37#include <mach/assabet.h> 39#include <mach/assabet.h>
38#include <mach/mcp.h> 40#include <mach/mcp.h>
41#include <mach/irqs.h>
39 42
40#include "generic.h" 43#include "generic.h"
41 44
42#define ASSABET_BCR_DB1110 \ 45#define ASSABET_BCR_DB1110 \
43 (ASSABET_BCR_SPK_OFF | ASSABET_BCR_QMUTE | \ 46 (ASSABET_BCR_SPK_OFF | \
44 ASSABET_BCR_LED_GREEN | ASSABET_BCR_LED_RED | \ 47 ASSABET_BCR_LED_GREEN | ASSABET_BCR_LED_RED | \
45 ASSABET_BCR_RS232EN | ASSABET_BCR_LCD_12RGB | \ 48 ASSABET_BCR_RS232EN | ASSABET_BCR_LCD_12RGB | \
46 ASSABET_BCR_IRDA_MD0) 49 ASSABET_BCR_IRDA_MD0)
47 50
48#define ASSABET_BCR_DB1111 \ 51#define ASSABET_BCR_DB1111 \
49 (ASSABET_BCR_SPK_OFF | ASSABET_BCR_QMUTE | \ 52 (ASSABET_BCR_SPK_OFF | \
50 ASSABET_BCR_LED_GREEN | ASSABET_BCR_LED_RED | \ 53 ASSABET_BCR_LED_GREEN | ASSABET_BCR_LED_RED | \
51 ASSABET_BCR_RS232EN | ASSABET_BCR_LCD_12RGB | \ 54 ASSABET_BCR_RS232EN | ASSABET_BCR_LCD_12RGB | \
52 ASSABET_BCR_CF_BUS_OFF | ASSABET_BCR_STEREO_LB | \ 55 ASSABET_BCR_CF_BUS_OFF | ASSABET_BCR_STEREO_LB | \
@@ -69,31 +72,10 @@ void ASSABET_BCR_frob(unsigned int mask, unsigned int val)
69 72
70EXPORT_SYMBOL(ASSABET_BCR_frob); 73EXPORT_SYMBOL(ASSABET_BCR_frob);
71 74
72static void assabet_backlight_power(int on) 75static void assabet_ucb1x00_reset(enum ucb1x00_reset state)
73{
74#ifndef ASSABET_PAL_VIDEO
75 if (on)
76 ASSABET_BCR_set(ASSABET_BCR_LIGHT_ON);
77 else
78#endif
79 ASSABET_BCR_clear(ASSABET_BCR_LIGHT_ON);
80}
81
82/*
83 * Turn on/off the backlight. When turning the backlight on,
84 * we wait 500us after turning it on so we don't cause the
85 * supplies to droop when we enable the LCD controller (and
86 * cause a hard reset.)
87 */
88static void assabet_lcd_power(int on)
89{ 76{
90#ifndef ASSABET_PAL_VIDEO 77 if (state == UCB_RST_PROBE)
91 if (on) { 78 ASSABET_BCR_set(ASSABET_BCR_CODEC_RST);
92 ASSABET_BCR_set(ASSABET_BCR_LCD_ON);
93 udelay(500);
94 } else
95#endif
96 ASSABET_BCR_clear(ASSABET_BCR_LCD_ON);
97} 79}
98 80
99 81
@@ -152,15 +134,8 @@ static struct flash_platform_data assabet_flash_data = {
152}; 134};
153 135
154static struct resource assabet_flash_resources[] = { 136static struct resource assabet_flash_resources[] = {
155 { 137 DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_32M),
156 .start = SA1100_CS0_PHYS, 138 DEFINE_RES_MEM(SA1100_CS1_PHYS, SZ_32M),
157 .end = SA1100_CS0_PHYS + SZ_32M - 1,
158 .flags = IORESOURCE_MEM,
159 }, {
160 .start = SA1100_CS1_PHYS,
161 .end = SA1100_CS1_PHYS + SZ_32M - 1,
162 .flags = IORESOURCE_MEM,
163 }
164}; 139};
165 140
166 141
@@ -199,18 +174,126 @@ static struct irda_platform_data assabet_irda_data = {
199 .set_speed = assabet_irda_set_speed, 174 .set_speed = assabet_irda_set_speed,
200}; 175};
201 176
177static struct ucb1x00_plat_data assabet_ucb1x00_data = {
178 .reset = assabet_ucb1x00_reset,
179 .gpio_base = -1,
180};
181
202static struct mcp_plat_data assabet_mcp_data = { 182static struct mcp_plat_data assabet_mcp_data = {
203 .mccr0 = MCCR0_ADM, 183 .mccr0 = MCCR0_ADM,
204 .sclk_rate = 11981000, 184 .sclk_rate = 11981000,
185 .codec_pdata = &assabet_ucb1x00_data,
186};
187
188static void assabet_lcd_set_visual(u32 visual)
189{
190 u_int is_true_color = visual == FB_VISUAL_TRUECOLOR;
191
192 if (machine_is_assabet()) {
193#if 1 // phase 4 or newer Assabet's
194 if (is_true_color)
195 ASSABET_BCR_set(ASSABET_BCR_LCD_12RGB);
196 else
197 ASSABET_BCR_clear(ASSABET_BCR_LCD_12RGB);
198#else
199 // older Assabet's
200 if (is_true_color)
201 ASSABET_BCR_clear(ASSABET_BCR_LCD_12RGB);
202 else
203 ASSABET_BCR_set(ASSABET_BCR_LCD_12RGB);
204#endif
205 }
206}
207
208#ifndef ASSABET_PAL_VIDEO
209static void assabet_lcd_backlight_power(int on)
210{
211 if (on)
212 ASSABET_BCR_set(ASSABET_BCR_LIGHT_ON);
213 else
214 ASSABET_BCR_clear(ASSABET_BCR_LIGHT_ON);
215}
216
217/*
218 * Turn on/off the backlight. When turning the backlight on, we wait
219 * 500us after turning it on so we don't cause the supplies to droop
220 * when we enable the LCD controller (and cause a hard reset.)
221 */
222static void assabet_lcd_power(int on)
223{
224 if (on) {
225 ASSABET_BCR_set(ASSABET_BCR_LCD_ON);
226 udelay(500);
227 } else
228 ASSABET_BCR_clear(ASSABET_BCR_LCD_ON);
229}
230
231/*
232 * The assabet uses a sharp LQ039Q2DS54 LCD module. It is actually
233 * takes an RGB666 signal, but we provide it with an RGB565 signal
234 * instead (def_rgb_16).
235 */
236static struct sa1100fb_mach_info lq039q2ds54_info = {
237 .pixclock = 171521, .bpp = 16,
238 .xres = 320, .yres = 240,
239
240 .hsync_len = 5, .vsync_len = 1,
241 .left_margin = 61, .upper_margin = 3,
242 .right_margin = 9, .lower_margin = 0,
243
244 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
245
246 .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
247 .lccr3 = LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(2),
248
249 .backlight_power = assabet_lcd_backlight_power,
250 .lcd_power = assabet_lcd_power,
251 .set_visual = assabet_lcd_set_visual,
252};
253#else
254static void assabet_pal_backlight_power(int on)
255{
256 ASSABET_BCR_clear(ASSABET_BCR_LIGHT_ON);
257}
258
259static void assabet_pal_power(int on)
260{
261 ASSABET_BCR_clear(ASSABET_BCR_LCD_ON);
262}
263
264static struct sa1100fb_mach_info pal_info = {
265 .pixclock = 67797, .bpp = 16,
266 .xres = 640, .yres = 512,
267
268 .hsync_len = 64, .vsync_len = 6,
269 .left_margin = 125, .upper_margin = 70,
270 .right_margin = 115, .lower_margin = 36,
271
272 .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
273 .lccr3 = LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(512),
274
275 .backlight_power = assabet_pal_backlight_power,
276 .lcd_power = assabet_pal_power,
277 .set_visual = assabet_lcd_set_visual,
205}; 278};
279#endif
280
281#ifdef CONFIG_ASSABET_NEPONSET
282static struct resource neponset_resources[] = {
283 DEFINE_RES_MEM(0x10000000, 0x08000000),
284 DEFINE_RES_MEM(0x18000000, 0x04000000),
285 DEFINE_RES_MEM(0x40000000, SZ_8K),
286 DEFINE_RES_IRQ(IRQ_GPIO25),
287};
288#endif
206 289
207static void __init assabet_init(void) 290static void __init assabet_init(void)
208{ 291{
209 /* 292 /*
210 * Ensure that the power supply is in "high power" mode. 293 * Ensure that the power supply is in "high power" mode.
211 */ 294 */
212 GPDR |= GPIO_GPIO16;
213 GPSR = GPIO_GPIO16; 295 GPSR = GPIO_GPIO16;
296 GPDR |= GPIO_GPIO16;
214 297
215 /* 298 /*
216 * Ensure that these pins are set as outputs and are driving 299 * Ensure that these pins are set as outputs and are driving
@@ -218,8 +301,16 @@ static void __init assabet_init(void)
218 * the WS latch in the CPLD, and we don't float causing 301 * the WS latch in the CPLD, and we don't float causing
219 * excessive power drain. --rmk 302 * excessive power drain. --rmk
220 */ 303 */
221 GPDR |= GPIO_SSP_TXD | GPIO_SSP_SCLK | GPIO_SSP_SFRM;
222 GPCR = GPIO_SSP_TXD | GPIO_SSP_SCLK | GPIO_SSP_SFRM; 304 GPCR = GPIO_SSP_TXD | GPIO_SSP_SCLK | GPIO_SSP_SFRM;
305 GPDR |= GPIO_SSP_TXD | GPIO_SSP_SCLK | GPIO_SSP_SFRM;
306
307 /*
308 * Also set GPIO27 as an output; this is used to clock UART3
309 * via the FPGA and as otherwise has no pullups or pulldowns,
310 * so stop it floating.
311 */
312 GPCR = GPIO_GPIO27;
313 GPDR |= GPIO_GPIO27;
223 314
224 /* 315 /*
225 * Set up registers for sleep mode. 316 * Set up registers for sleep mode.
@@ -231,8 +322,7 @@ static void __init assabet_init(void)
231 PPDR |= PPC_TXD3 | PPC_TXD1; 322 PPDR |= PPC_TXD3 | PPC_TXD1;
232 PPSR |= PPC_TXD3 | PPC_TXD1; 323 PPSR |= PPC_TXD3 | PPC_TXD1;
233 324
234 sa1100fb_lcd_power = assabet_lcd_power; 325 sa11x0_ppc_configure_mcp();
235 sa1100fb_backlight_power = assabet_backlight_power;
236 326
237 if (machine_has_neponset()) { 327 if (machine_has_neponset()) {
238 /* 328 /*
@@ -246,9 +336,17 @@ static void __init assabet_init(void)
246#ifndef CONFIG_ASSABET_NEPONSET 336#ifndef CONFIG_ASSABET_NEPONSET
247 printk( "Warning: Neponset detected but full support " 337 printk( "Warning: Neponset detected but full support "
248 "hasn't been configured in the kernel\n" ); 338 "hasn't been configured in the kernel\n" );
339#else
340 platform_device_register_simple("neponset", 0,
341 neponset_resources, ARRAY_SIZE(neponset_resources));
249#endif 342#endif
250 } 343 }
251 344
345#ifndef ASSABET_PAL_VIDEO
346 sa11x0_register_lcd(&lq039q2ds54_info);
347#else
348 sa11x0_register_lcd(&pal_video);
349#endif
252 sa11x0_register_mtd(&assabet_flash_data, assabet_flash_resources, 350 sa11x0_register_mtd(&assabet_flash_data, assabet_flash_resources,
253 ARRAY_SIZE(assabet_flash_resources)); 351 ARRAY_SIZE(assabet_flash_resources));
254 sa11x0_register_irda(&assabet_irda_data); 352 sa11x0_register_irda(&assabet_irda_data);
@@ -412,21 +510,8 @@ static void __init assabet_map_io(void)
412 */ 510 */
413 Ser1SDCR0 |= SDCR0_SUS; 511 Ser1SDCR0 |= SDCR0_SUS;
414 512
415 if (machine_has_neponset()) { 513 if (!machine_has_neponset())
416#ifdef CONFIG_ASSABET_NEPONSET
417 extern void neponset_map_io(void);
418
419 /*
420 * We map Neponset registers even if it isn't present since
421 * many drivers will try to probe their stuff (and fail).
422 * This is still more friendly than a kernel paging request
423 * crash.
424 */
425 neponset_map_io();
426#endif
427 } else {
428 sa1100_register_uart_fns(&assabet_port_fns); 514 sa1100_register_uart_fns(&assabet_port_fns);
429 }
430 515
431 /* 516 /*
432 * When Neponset is attached, the first UART should be 517 * When Neponset is attached, the first UART should be
@@ -449,6 +534,7 @@ MACHINE_START(ASSABET, "Intel-Assabet")
449 .atag_offset = 0x100, 534 .atag_offset = 0x100,
450 .fixup = fixup_assabet, 535 .fixup = fixup_assabet,
451 .map_io = assabet_map_io, 536 .map_io = assabet_map_io,
537 .nr_irqs = SA1100_NR_IRQS,
452 .init_irq = sa1100_init_irq, 538 .init_irq = sa1100_init_irq,
453 .timer = &sa1100_timer, 539 .timer = &sa1100_timer,
454 .init_machine = assabet_init, 540 .init_machine = assabet_init,
diff --git a/arch/arm/mach-sa1100/badge4.c b/arch/arm/mach-sa1100/badge4.c
index b07a2c024cb..e0f0c030258 100644
--- a/arch/arm/mach-sa1100/badge4.c
+++ b/arch/arm/mach-sa1100/badge4.c
@@ -39,20 +39,27 @@
39#include "generic.h" 39#include "generic.h"
40 40
41static struct resource sa1111_resources[] = { 41static struct resource sa1111_resources[] = {
42 [0] = { 42 [0] = DEFINE_RES_MEM(BADGE4_SA1111_BASE, 0x2000),
43 .start = BADGE4_SA1111_BASE, 43 [1] = DEFINE_RES_IRQ(BADGE4_IRQ_GPIO_SA1111),
44 .end = BADGE4_SA1111_BASE + 0x00001fff,
45 .flags = IORESOURCE_MEM,
46 },
47 [1] = {
48 .start = BADGE4_IRQ_GPIO_SA1111,
49 .end = BADGE4_IRQ_GPIO_SA1111,
50 .flags = IORESOURCE_IRQ,
51 },
52}; 44};
53 45
46static int badge4_sa1111_enable(void *data, unsigned devid)
47{
48 if (devid == SA1111_DEVID_USB)
49 badge4_set_5V(BADGE4_5V_USB, 1);
50 return 0;
51}
52
53static void badge4_sa1111_disable(void *data, unsigned devid)
54{
55 if (devid == SA1111_DEVID_USB)
56 badge4_set_5V(BADGE4_5V_USB, 0);
57}
58
54static struct sa1111_platform_data sa1111_info = { 59static struct sa1111_platform_data sa1111_info = {
55 .irq_base = IRQ_BOARD_END, 60 .disable_devs = SA1111_DEVID_PS2_MSE,
61 .enable = badge4_sa1111_enable,
62 .disable = badge4_sa1111_disable,
56}; 63};
57 64
58static u64 sa1111_dmamask = 0xffffffffUL; 65static u64 sa1111_dmamask = 0xffffffffUL;
@@ -121,11 +128,8 @@ static struct flash_platform_data badge4_flash_data = {
121 .nr_parts = ARRAY_SIZE(badge4_partitions), 128 .nr_parts = ARRAY_SIZE(badge4_partitions),
122}; 129};
123 130
124static struct resource badge4_flash_resource = { 131static struct resource badge4_flash_resource =
125 .start = SA1100_CS0_PHYS, 132 DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_64M);
126 .end = SA1100_CS0_PHYS + SZ_64M - 1,
127 .flags = IORESOURCE_MEM,
128};
129 133
130static int five_v_on __initdata = 0; 134static int five_v_on __initdata = 0;
131 135
@@ -269,11 +273,6 @@ static struct map_desc badge4_io_desc[] __initdata = {
269 .pfn = __phys_to_pfn(0x10000000), 273 .pfn = __phys_to_pfn(0x10000000),
270 .length = 0x00100000, 274 .length = 0x00100000,
271 .type = MT_DEVICE 275 .type = MT_DEVICE
272 }, { /* SA-1111 */
273 .virtual = 0xf4000000,
274 .pfn = __phys_to_pfn(0x48000000),
275 .length = 0x00100000,
276 .type = MT_DEVICE
277 } 276 }
278}; 277};
279 278
@@ -304,6 +303,7 @@ static void __init badge4_map_io(void)
304MACHINE_START(BADGE4, "Hewlett-Packard Laboratories BadgePAD 4") 303MACHINE_START(BADGE4, "Hewlett-Packard Laboratories BadgePAD 4")
305 .atag_offset = 0x100, 304 .atag_offset = 0x100,
306 .map_io = badge4_map_io, 305 .map_io = badge4_map_io,
306 .nr_irqs = SA1100_NR_IRQS,
307 .init_irq = sa1100_init_irq, 307 .init_irq = sa1100_init_irq,
308 .timer = &sa1100_timer, 308 .timer = &sa1100_timer,
309#ifdef CONFIG_SA1111 309#ifdef CONFIG_SA1111
diff --git a/arch/arm/mach-sa1100/cerf.c b/arch/arm/mach-sa1100/cerf.c
index 11bb6d0b9be..4a61f60e050 100644
--- a/arch/arm/mach-sa1100/cerf.c
+++ b/arch/arm/mach-sa1100/cerf.c
@@ -18,7 +18,6 @@
18#include <linux/mtd/mtd.h> 18#include <linux/mtd/mtd.h>
19#include <linux/mtd/partitions.h> 19#include <linux/mtd/partitions.h>
20 20
21#include <asm/irq.h>
22#include <mach/hardware.h> 21#include <mach/hardware.h>
23#include <asm/setup.h> 22#include <asm/setup.h>
24 23
@@ -30,14 +29,11 @@
30 29
31#include <mach/cerf.h> 30#include <mach/cerf.h>
32#include <mach/mcp.h> 31#include <mach/mcp.h>
32#include <mach/irqs.h>
33#include "generic.h" 33#include "generic.h"
34 34
35static struct resource cerfuart2_resources[] = { 35static struct resource cerfuart2_resources[] = {
36 [0] = { 36 [0] = DEFINE_RES_MEM(0x80030000, SZ_64K),
37 .start = 0x80030000,
38 .end = 0x8003ffff,
39 .flags = IORESOURCE_MEM,
40 },
41}; 37};
42 38
43static struct platform_device cerfuart2_device = { 39static struct platform_device cerfuart2_device = {
@@ -87,11 +83,8 @@ static struct flash_platform_data cerf_flash_data = {
87 .nr_parts = ARRAY_SIZE(cerf_partitions), 83 .nr_parts = ARRAY_SIZE(cerf_partitions),
88}; 84};
89 85
90static struct resource cerf_flash_resource = { 86static struct resource cerf_flash_resource =
91 .start = SA1100_CS0_PHYS, 87 DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_32M);
92 .end = SA1100_CS0_PHYS + SZ_32M - 1,
93 .flags = IORESOURCE_MEM,
94};
95 88
96static void __init cerf_init_irq(void) 89static void __init cerf_init_irq(void)
97{ 90{
@@ -128,6 +121,7 @@ static struct mcp_plat_data cerf_mcp_data = {
128 121
129static void __init cerf_init(void) 122static void __init cerf_init(void)
130{ 123{
124 sa11x0_ppc_configure_mcp();
131 platform_add_devices(cerf_devices, ARRAY_SIZE(cerf_devices)); 125 platform_add_devices(cerf_devices, ARRAY_SIZE(cerf_devices));
132 sa11x0_register_mtd(&cerf_flash_data, &cerf_flash_resource, 1); 126 sa11x0_register_mtd(&cerf_flash_data, &cerf_flash_resource, 1);
133 sa11x0_register_mcp(&cerf_mcp_data); 127 sa11x0_register_mcp(&cerf_mcp_data);
@@ -136,6 +130,7 @@ static void __init cerf_init(void)
136MACHINE_START(CERF, "Intrinsyc CerfBoard/CerfCube") 130MACHINE_START(CERF, "Intrinsyc CerfBoard/CerfCube")
137 /* Maintainer: support@intrinsyc.com */ 131 /* Maintainer: support@intrinsyc.com */
138 .map_io = cerf_map_io, 132 .map_io = cerf_map_io,
133 .nr_irqs = SA1100_NR_IRQS,
139 .init_irq = cerf_init_irq, 134 .init_irq = cerf_init_irq,
140 .timer = &sa1100_timer, 135 .timer = &sa1100_timer,
141 .init_machine = cerf_init, 136 .init_machine = cerf_init,
diff --git a/arch/arm/mach-sa1100/clock.c b/arch/arm/mach-sa1100/clock.c
index dab3c6347a8..172ebd0ee0a 100644
--- a/arch/arm/mach-sa1100/clock.c
+++ b/arch/arm/mach-sa1100/clock.c
@@ -11,17 +11,29 @@
11#include <linux/clk.h> 11#include <linux/clk.h>
12#include <linux/spinlock.h> 12#include <linux/spinlock.h>
13#include <linux/mutex.h> 13#include <linux/mutex.h>
14#include <linux/io.h>
15#include <linux/clkdev.h>
14 16
15#include <mach/hardware.h> 17#include <mach/hardware.h>
16 18
17/* 19struct clkops {
18 * Very simple clock implementation - we only have one clock to deal with. 20 void (*enable)(struct clk *);
19 */ 21 void (*disable)(struct clk *);
22};
23
20struct clk { 24struct clk {
25 const struct clkops *ops;
21 unsigned int enabled; 26 unsigned int enabled;
22}; 27};
23 28
24static void clk_gpio27_enable(void) 29#define DEFINE_CLK(_name, _ops) \
30struct clk clk_##_name = { \
31 .ops = _ops, \
32 }
33
34static DEFINE_SPINLOCK(clocks_lock);
35
36static void clk_gpio27_enable(struct clk *clk)
25{ 37{
26 /* 38 /*
27 * First, set up the 3.6864MHz clock on GPIO 27 for the SA-1111: 39 * First, set up the 3.6864MHz clock on GPIO 27 for the SA-1111:
@@ -32,38 +44,24 @@ static void clk_gpio27_enable(void)
32 TUCR = TUCR_3_6864MHz; 44 TUCR = TUCR_3_6864MHz;
33} 45}
34 46
35static void clk_gpio27_disable(void) 47static void clk_gpio27_disable(struct clk *clk)
36{ 48{
37 TUCR = 0; 49 TUCR = 0;
38 GPDR &= ~GPIO_32_768kHz; 50 GPDR &= ~GPIO_32_768kHz;
39 GAFR &= ~GPIO_32_768kHz; 51 GAFR &= ~GPIO_32_768kHz;
40} 52}
41 53
42static struct clk clk_gpio27;
43
44static DEFINE_SPINLOCK(clocks_lock);
45
46struct clk *clk_get(struct device *dev, const char *id)
47{
48 const char *devname = dev_name(dev);
49
50 return strcmp(devname, "sa1111.0") ? ERR_PTR(-ENOENT) : &clk_gpio27;
51}
52EXPORT_SYMBOL(clk_get);
53
54void clk_put(struct clk *clk)
55{
56}
57EXPORT_SYMBOL(clk_put);
58
59int clk_enable(struct clk *clk) 54int clk_enable(struct clk *clk)
60{ 55{
61 unsigned long flags; 56 unsigned long flags;
62 57
63 spin_lock_irqsave(&clocks_lock, flags); 58 if (clk) {
64 if (clk->enabled++ == 0) 59 spin_lock_irqsave(&clocks_lock, flags);
65 clk_gpio27_enable(); 60 if (clk->enabled++ == 0)
66 spin_unlock_irqrestore(&clocks_lock, flags); 61 clk->ops->enable(clk);
62 spin_unlock_irqrestore(&clocks_lock, flags);
63 }
64
67 return 0; 65 return 0;
68} 66}
69EXPORT_SYMBOL(clk_enable); 67EXPORT_SYMBOL(clk_enable);
@@ -72,17 +70,31 @@ void clk_disable(struct clk *clk)
72{ 70{
73 unsigned long flags; 71 unsigned long flags;
74 72
75 WARN_ON(clk->enabled == 0); 73 if (clk) {
76 74 WARN_ON(clk->enabled == 0);
77 spin_lock_irqsave(&clocks_lock, flags); 75 spin_lock_irqsave(&clocks_lock, flags);
78 if (--clk->enabled == 0) 76 if (--clk->enabled == 0)
79 clk_gpio27_disable(); 77 clk->ops->disable(clk);
80 spin_unlock_irqrestore(&clocks_lock, flags); 78 spin_unlock_irqrestore(&clocks_lock, flags);
79 }
81} 80}
82EXPORT_SYMBOL(clk_disable); 81EXPORT_SYMBOL(clk_disable);
83 82
84unsigned long clk_get_rate(struct clk *clk) 83const struct clkops clk_gpio27_ops = {
84 .enable = clk_gpio27_enable,
85 .disable = clk_gpio27_disable,
86};
87
88static DEFINE_CLK(gpio27, &clk_gpio27_ops);
89
90static struct clk_lookup sa11xx_clkregs[] = {
91 CLKDEV_INIT("sa1111.0", NULL, &clk_gpio27),
92 CLKDEV_INIT("sa1100-rtc", NULL, NULL),
93};
94
95static int __init sa11xx_clk_init(void)
85{ 96{
86 return 3686400; 97 clkdev_add_table(sa11xx_clkregs, ARRAY_SIZE(sa11xx_clkregs));
98 return 0;
87} 99}
88EXPORT_SYMBOL(clk_get_rate); 100core_initcall(sa11xx_clk_init);
diff --git a/arch/arm/mach-sa1100/collie.c b/arch/arm/mach-sa1100/collie.c
index fd5652118ed..48885b7efd6 100644
--- a/arch/arm/mach-sa1100/collie.c
+++ b/arch/arm/mach-sa1100/collie.c
@@ -22,15 +22,17 @@
22#include <linux/tty.h> 22#include <linux/tty.h>
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/mfd/ucb1x00.h>
25#include <linux/mtd/mtd.h> 26#include <linux/mtd/mtd.h>
26#include <linux/mtd/partitions.h> 27#include <linux/mtd/partitions.h>
27#include <linux/timer.h> 28#include <linux/timer.h>
28#include <linux/gpio.h> 29#include <linux/gpio.h>
29#include <linux/pda_power.h> 30#include <linux/pda_power.h>
30 31
32#include <video/sa1100fb.h>
33
31#include <mach/hardware.h> 34#include <mach/hardware.h>
32#include <asm/mach-types.h> 35#include <asm/mach-types.h>
33#include <asm/irq.h>
34#include <asm/page.h> 36#include <asm/page.h>
35#include <asm/setup.h> 37#include <asm/setup.h>
36#include <mach/collie.h> 38#include <mach/collie.h>
@@ -44,15 +46,12 @@
44#include <asm/mach/sharpsl_param.h> 46#include <asm/mach/sharpsl_param.h>
45#include <asm/hardware/locomo.h> 47#include <asm/hardware/locomo.h>
46#include <mach/mcp.h> 48#include <mach/mcp.h>
49#include <mach/irqs.h>
47 50
48#include "generic.h" 51#include "generic.h"
49 52
50static struct resource collie_scoop_resources[] = { 53static struct resource collie_scoop_resources[] = {
51 [0] = { 54 [0] = DEFINE_RES_MEM(0x40800000, SZ_4K),
52 .start = 0x40800000,
53 .end = 0x40800fff,
54 .flags = IORESOURCE_MEM,
55 },
56}; 55};
57 56
58static struct scoop_config collie_scoop_setup = { 57static struct scoop_config collie_scoop_setup = {
@@ -85,10 +84,14 @@ static struct scoop_pcmcia_config collie_pcmcia_config = {
85 .num_devs = 1, 84 .num_devs = 1,
86}; 85};
87 86
87static struct ucb1x00_plat_data collie_ucb1x00_data = {
88 .gpio_base = COLLIE_TC35143_GPIO_BASE,
89};
90
88static struct mcp_plat_data collie_mcp_data = { 91static struct mcp_plat_data collie_mcp_data = {
89 .mccr0 = MCCR0_ADM | MCCR0_ExtClk, 92 .mccr0 = MCCR0_ADM | MCCR0_ExtClk,
90 .sclk_rate = 9216000, 93 .sclk_rate = 9216000,
91 .gpio_base = COLLIE_TC35143_GPIO_BASE, 94 .codec_pdata = &collie_ucb1x00_data,
92}; 95};
93 96
94/* 97/*
@@ -221,16 +224,8 @@ device_initcall(collie_uart_init);
221 224
222 225
223static struct resource locomo_resources[] = { 226static struct resource locomo_resources[] = {
224 [0] = { 227 [0] = DEFINE_RES_MEM(0x40000000, SZ_8K),
225 .start = 0x40000000, 228 [1] = DEFINE_RES_IRQ(IRQ_GPIO25),
226 .end = 0x40001fff,
227 .flags = IORESOURCE_MEM,
228 },
229 [1] = {
230 .start = IRQ_GPIO25,
231 .end = IRQ_GPIO25,
232 .flags = IORESOURCE_IRQ,
233 },
234}; 229};
235 230
236static struct locomo_platform_data locomo_info = { 231static struct locomo_platform_data locomo_info = {
@@ -303,11 +298,21 @@ static struct flash_platform_data collie_flash_data = {
303}; 298};
304 299
305static struct resource collie_flash_resources[] = { 300static struct resource collie_flash_resources[] = {
306 { 301 DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_32M),
307 .start = SA1100_CS0_PHYS, 302};
308 .end = SA1100_CS0_PHYS + SZ_32M - 1, 303
309 .flags = IORESOURCE_MEM, 304static struct sa1100fb_mach_info collie_lcd_info = {
310 } 305 .pixclock = 171521, .bpp = 16,
306 .xres = 320, .yres = 240,
307
308 .hsync_len = 5, .vsync_len = 1,
309 .left_margin = 11, .upper_margin = 2,
310 .right_margin = 30, .lower_margin = 0,
311
312 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
313
314 .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
315 .lccr3 = LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(2),
311}; 316};
312 317
313static void __init collie_init(void) 318static void __init collie_init(void)
@@ -341,6 +346,10 @@ static void __init collie_init(void)
341 346
342 collie_power_resource[0].start = gpio_to_irq(COLLIE_GPIO_AC_IN); 347 collie_power_resource[0].start = gpio_to_irq(COLLIE_GPIO_AC_IN);
343 collie_power_resource[0].end = gpio_to_irq(COLLIE_GPIO_AC_IN); 348 collie_power_resource[0].end = gpio_to_irq(COLLIE_GPIO_AC_IN);
349
350 sa11x0_ppc_configure_mcp();
351
352
344 platform_scoop_config = &collie_pcmcia_config; 353 platform_scoop_config = &collie_pcmcia_config;
345 354
346 ret = platform_add_devices(devices, ARRAY_SIZE(devices)); 355 ret = platform_add_devices(devices, ARRAY_SIZE(devices));
@@ -348,6 +357,7 @@ static void __init collie_init(void)
348 printk(KERN_WARNING "collie: Unable to register LoCoMo device\n"); 357 printk(KERN_WARNING "collie: Unable to register LoCoMo device\n");
349 } 358 }
350 359
360 sa11x0_register_lcd(&collie_lcd_info);
351 sa11x0_register_mtd(&collie_flash_data, collie_flash_resources, 361 sa11x0_register_mtd(&collie_flash_data, collie_flash_resources,
352 ARRAY_SIZE(collie_flash_resources)); 362 ARRAY_SIZE(collie_flash_resources));
353 sa11x0_register_mcp(&collie_mcp_data); 363 sa11x0_register_mcp(&collie_mcp_data);
@@ -383,6 +393,7 @@ static void __init collie_map_io(void)
383 393
384MACHINE_START(COLLIE, "Sharp-Collie") 394MACHINE_START(COLLIE, "Sharp-Collie")
385 .map_io = collie_map_io, 395 .map_io = collie_map_io,
396 .nr_irqs = SA1100_NR_IRQS,
386 .init_irq = sa1100_init_irq, 397 .init_irq = sa1100_init_irq,
387 .timer = &sa1100_timer, 398 .timer = &sa1100_timer,
388 .init_machine = collie_init, 399 .init_machine = collie_init,
diff --git a/arch/arm/mach-sa1100/dma.c b/arch/arm/mach-sa1100/dma.c
deleted file mode 100644
index 56e13333512..00000000000
--- a/arch/arm/mach-sa1100/dma.c
+++ /dev/null
@@ -1,347 +0,0 @@
1/*
2 * arch/arm/mach-sa1100/dma.c
3 *
4 * Support functions for the SA11x0 internal DMA channels.
5 *
6 * Copyright (C) 2000, 2001 by Nicolas Pitre
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/module.h>
14#include <linux/interrupt.h>
15#include <linux/init.h>
16#include <linux/spinlock.h>
17#include <linux/errno.h>
18
19#include <asm/irq.h>
20#include <mach/hardware.h>
21#include <mach/dma.h>
22
23
24#undef DEBUG
25#ifdef DEBUG
26#define DPRINTK( s, arg... ) printk( "dma<%p>: " s, regs , ##arg )
27#else
28#define DPRINTK( x... )
29#endif
30
31
32typedef struct {
33 const char *device_id; /* device name */
34 u_long device; /* this channel device, 0 if unused*/
35 dma_callback_t callback; /* to call when DMA completes */
36 void *data; /* ... with private data ptr */
37} sa1100_dma_t;
38
39static sa1100_dma_t dma_chan[SA1100_DMA_CHANNELS];
40
41static DEFINE_SPINLOCK(dma_list_lock);
42
43
44static irqreturn_t dma_irq_handler(int irq, void *dev_id)
45{
46 dma_regs_t *dma_regs = dev_id;
47 sa1100_dma_t *dma = dma_chan + (((u_int)dma_regs >> 5) & 7);
48 int status = dma_regs->RdDCSR;
49
50 if (status & (DCSR_ERROR)) {
51 printk(KERN_CRIT "DMA on \"%s\" caused an error\n", dma->device_id);
52 dma_regs->ClrDCSR = DCSR_ERROR;
53 }
54
55 dma_regs->ClrDCSR = status & (DCSR_DONEA | DCSR_DONEB);
56 if (dma->callback) {
57 if (status & DCSR_DONEA)
58 dma->callback(dma->data);
59 if (status & DCSR_DONEB)
60 dma->callback(dma->data);
61 }
62 return IRQ_HANDLED;
63}
64
65
66/**
67 * sa1100_request_dma - allocate one of the SA11x0's DMA channels
68 * @device: The SA11x0 peripheral targeted by this request
69 * @device_id: An ascii name for the claiming device
70 * @callback: Function to be called when the DMA completes
71 * @data: A cookie passed back to the callback function
72 * @dma_regs: Pointer to the location of the allocated channel's identifier
73 *
74 * This function will search for a free DMA channel and returns the
75 * address of the hardware registers for that channel as the channel
76 * identifier. This identifier is written to the location pointed by
77 * @dma_regs. The list of possible values for @device are listed into
78 * arch/arm/mach-sa1100/include/mach/dma.h as a dma_device_t enum.
79 *
80 * Note that reading from a port and writing to the same port are
81 * actually considered as two different streams requiring separate
82 * DMA registrations.
83 *
84 * The @callback function is called from interrupt context when one
85 * of the two possible DMA buffers in flight has terminated. That
86 * function has to be small and efficient while posponing more complex
87 * processing to a lower priority execution context.
88 *
89 * If no channels are available, or if the desired @device is already in
90 * use by another DMA channel, then an error code is returned. This
91 * function must be called before any other DMA calls.
92 **/
93
94int sa1100_request_dma (dma_device_t device, const char *device_id,
95 dma_callback_t callback, void *data,
96 dma_regs_t **dma_regs)
97{
98 sa1100_dma_t *dma = NULL;
99 dma_regs_t *regs;
100 int i, err;
101
102 *dma_regs = NULL;
103
104 err = 0;
105 spin_lock(&dma_list_lock);
106 for (i = 0; i < SA1100_DMA_CHANNELS; i++) {
107 if (dma_chan[i].device == device) {
108 err = -EBUSY;
109 break;
110 } else if (!dma_chan[i].device && !dma) {
111 dma = &dma_chan[i];
112 }
113 }
114 if (!err) {
115 if (dma)
116 dma->device = device;
117 else
118 err = -ENOSR;
119 }
120 spin_unlock(&dma_list_lock);
121 if (err)
122 return err;
123
124 i = dma - dma_chan;
125 regs = (dma_regs_t *)&DDAR(i);
126 err = request_irq(IRQ_DMA0 + i, dma_irq_handler, IRQF_DISABLED,
127 device_id, regs);
128 if (err) {
129 printk(KERN_ERR
130 "%s: unable to request IRQ %d for %s\n",
131 __func__, IRQ_DMA0 + i, device_id);
132 dma->device = 0;
133 return err;
134 }
135
136 *dma_regs = regs;
137 dma->device_id = device_id;
138 dma->callback = callback;
139 dma->data = data;
140
141 regs->ClrDCSR =
142 (DCSR_DONEA | DCSR_DONEB | DCSR_STRTA | DCSR_STRTB |
143 DCSR_IE | DCSR_ERROR | DCSR_RUN);
144 regs->DDAR = device;
145
146 return 0;
147}
148
149
150/**
151 * sa1100_free_dma - free a SA11x0 DMA channel
152 * @regs: identifier for the channel to free
153 *
154 * This clears all activities on a given DMA channel and releases it
155 * for future requests. The @regs identifier is provided by a
156 * successful call to sa1100_request_dma().
157 **/
158
159void sa1100_free_dma(dma_regs_t *regs)
160{
161 int i;
162
163 for (i = 0; i < SA1100_DMA_CHANNELS; i++)
164 if (regs == (dma_regs_t *)&DDAR(i))
165 break;
166 if (i >= SA1100_DMA_CHANNELS) {
167 printk(KERN_ERR "%s: bad DMA identifier\n", __func__);
168 return;
169 }
170
171 if (!dma_chan[i].device) {
172 printk(KERN_ERR "%s: Trying to free free DMA\n", __func__);
173 return;
174 }
175
176 regs->ClrDCSR =
177 (DCSR_DONEA | DCSR_DONEB | DCSR_STRTA | DCSR_STRTB |
178 DCSR_IE | DCSR_ERROR | DCSR_RUN);
179 free_irq(IRQ_DMA0 + i, regs);
180 dma_chan[i].device = 0;
181}
182
183
184/**
185 * sa1100_start_dma - submit a data buffer for DMA
186 * @regs: identifier for the channel to use
187 * @dma_ptr: buffer physical (or bus) start address
188 * @size: buffer size
189 *
190 * This function hands the given data buffer to the hardware for DMA
191 * access. If another buffer is already in flight then this buffer
192 * will be queued so the DMA engine will switch to it automatically
193 * when the previous one is done. The DMA engine is actually toggling
194 * between two buffers so at most 2 successful calls can be made before
195 * one of them terminates and the callback function is called.
196 *
197 * The @regs identifier is provided by a successful call to
198 * sa1100_request_dma().
199 *
200 * The @size must not be larger than %MAX_DMA_SIZE. If a given buffer
201 * is larger than that then it's the caller's responsibility to split
202 * it into smaller chunks and submit them separately. If this is the
203 * case then a @size of %CUT_DMA_SIZE is recommended to avoid ending
204 * up with too small chunks. The callback function can be used to chain
205 * submissions of buffer chunks.
206 *
207 * Error return values:
208 * %-EOVERFLOW: Given buffer size is too big.
209 * %-EBUSY: Both DMA buffers are already in use.
210 * %-EAGAIN: Both buffers were busy but one of them just completed
211 * but the interrupt handler has to execute first.
212 *
213 * This function returs 0 on success.
214 **/
215
216int sa1100_start_dma(dma_regs_t *regs, dma_addr_t dma_ptr, u_int size)
217{
218 unsigned long flags;
219 u_long status;
220 int ret;
221
222 if (dma_ptr & 3)
223 printk(KERN_WARNING "DMA: unaligned start address (0x%08lx)\n",
224 (unsigned long)dma_ptr);
225
226 if (size > MAX_DMA_SIZE)
227 return -EOVERFLOW;
228
229 local_irq_save(flags);
230 status = regs->RdDCSR;
231
232 /* If both DMA buffers are started, there's nothing else we can do. */
233 if ((status & (DCSR_STRTA | DCSR_STRTB)) == (DCSR_STRTA | DCSR_STRTB)) {
234 DPRINTK("start: st %#x busy\n", status);
235 ret = -EBUSY;
236 goto out;
237 }
238
239 if (((status & DCSR_BIU) && (status & DCSR_STRTB)) ||
240 (!(status & DCSR_BIU) && !(status & DCSR_STRTA))) {
241 if (status & DCSR_DONEA) {
242 /* give a chance for the interrupt to be processed */
243 ret = -EAGAIN;
244 goto out;
245 }
246 regs->DBSA = dma_ptr;
247 regs->DBTA = size;
248 regs->SetDCSR = DCSR_STRTA | DCSR_IE | DCSR_RUN;
249 DPRINTK("start a=%#x s=%d on A\n", dma_ptr, size);
250 } else {
251 if (status & DCSR_DONEB) {
252 /* give a chance for the interrupt to be processed */
253 ret = -EAGAIN;
254 goto out;
255 }
256 regs->DBSB = dma_ptr;
257 regs->DBTB = size;
258 regs->SetDCSR = DCSR_STRTB | DCSR_IE | DCSR_RUN;
259 DPRINTK("start a=%#x s=%d on B\n", dma_ptr, size);
260 }
261 ret = 0;
262
263out:
264 local_irq_restore(flags);
265 return ret;
266}
267
268
269/**
270 * sa1100_get_dma_pos - return current DMA position
271 * @regs: identifier for the channel to use
272 *
273 * This function returns the current physical (or bus) address for the
274 * given DMA channel. If the channel is running i.e. not in a stopped
275 * state then the caller must disable interrupts prior calling this
276 * function and process the returned value before re-enabling them to
277 * prevent races with the completion interrupt handler and the callback
278 * function. The validation of the returned value is the caller's
279 * responsibility as well -- the hardware seems to return out of range
280 * values when the DMA engine completes a buffer.
281 *
282 * The @regs identifier is provided by a successful call to
283 * sa1100_request_dma().
284 **/
285
286dma_addr_t sa1100_get_dma_pos(dma_regs_t *regs)
287{
288 int status;
289
290 /*
291 * We must determine whether buffer A or B is active.
292 * Two possibilities: either we are in the middle of
293 * a buffer, or the DMA controller just switched to the
294 * next toggle but the interrupt hasn't been serviced yet.
295 * The former case is straight forward. In the later case,
296 * we'll do like if DMA is just at the end of the previous
297 * toggle since all registers haven't been reset yet.
298 * This goes around the edge case and since we're always
299 * a little behind anyways it shouldn't make a big difference.
300 * If DMA has been stopped prior calling this then the
301 * position is exact.
302 */
303 status = regs->RdDCSR;
304 if ((!(status & DCSR_BIU) && (status & DCSR_STRTA)) ||
305 ( (status & DCSR_BIU) && !(status & DCSR_STRTB)))
306 return regs->DBSA;
307 else
308 return regs->DBSB;
309}
310
311
312/**
313 * sa1100_reset_dma - reset a DMA channel
314 * @regs: identifier for the channel to use
315 *
316 * This function resets and reconfigure the given DMA channel. This is
317 * particularly useful after a sleep/wakeup event.
318 *
319 * The @regs identifier is provided by a successful call to
320 * sa1100_request_dma().
321 **/
322
323void sa1100_reset_dma(dma_regs_t *regs)
324{
325 int i;
326
327 for (i = 0; i < SA1100_DMA_CHANNELS; i++)
328 if (regs == (dma_regs_t *)&DDAR(i))
329 break;
330 if (i >= SA1100_DMA_CHANNELS) {
331 printk(KERN_ERR "%s: bad DMA identifier\n", __func__);
332 return;
333 }
334
335 regs->ClrDCSR =
336 (DCSR_DONEA | DCSR_DONEB | DCSR_STRTA | DCSR_STRTB |
337 DCSR_IE | DCSR_ERROR | DCSR_RUN);
338 regs->DDAR = dma_chan[i].device;
339}
340
341
342EXPORT_SYMBOL(sa1100_request_dma);
343EXPORT_SYMBOL(sa1100_free_dma);
344EXPORT_SYMBOL(sa1100_start_dma);
345EXPORT_SYMBOL(sa1100_get_dma_pos);
346EXPORT_SYMBOL(sa1100_reset_dma);
347
diff --git a/arch/arm/mach-sa1100/generic.c b/arch/arm/mach-sa1100/generic.c
index 9ad94691743..7c524b4e415 100644
--- a/arch/arm/mach-sa1100/generic.c
+++ b/arch/arm/mach-sa1100/generic.c
@@ -14,18 +14,23 @@
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/dma-mapping.h>
17#include <linux/pm.h> 18#include <linux/pm.h>
18#include <linux/cpufreq.h> 19#include <linux/cpufreq.h>
19#include <linux/ioport.h> 20#include <linux/ioport.h>
20#include <linux/platform_device.h> 21#include <linux/platform_device.h>
21 22
23#include <video/sa1100fb.h>
24
22#include <asm/div64.h> 25#include <asm/div64.h>
23#include <mach/hardware.h>
24#include <asm/mach/map.h> 26#include <asm/mach/map.h>
25#include <asm/mach/flash.h> 27#include <asm/mach/flash.h>
26#include <asm/irq.h> 28#include <asm/irq.h>
27#include <asm/system_misc.h> 29#include <asm/system_misc.h>
28 30
31#include <mach/hardware.h>
32#include <mach/irqs.h>
33
29#include "generic.h" 34#include "generic.h"
30 35
31unsigned int reset_status; 36unsigned int reset_status;
@@ -149,16 +154,8 @@ static void sa11x0_register_device(struct platform_device *dev, void *data)
149 154
150 155
151static struct resource sa11x0udc_resources[] = { 156static struct resource sa11x0udc_resources[] = {
152 [0] = { 157 [0] = DEFINE_RES_MEM(__PREG(Ser0UDCCR), SZ_64K),
153 .start = __PREG(Ser0UDCCR), 158 [1] = DEFINE_RES_IRQ(IRQ_Ser0UDC),
154 .end = __PREG(Ser0UDCCR) + 0xffff,
155 .flags = IORESOURCE_MEM,
156 },
157 [1] = {
158 .start = IRQ_Ser0UDC,
159 .end = IRQ_Ser0UDC,
160 .flags = IORESOURCE_IRQ,
161 },
162}; 159};
163 160
164static u64 sa11x0udc_dma_mask = 0xffffffffUL; 161static u64 sa11x0udc_dma_mask = 0xffffffffUL;
@@ -175,16 +172,8 @@ static struct platform_device sa11x0udc_device = {
175}; 172};
176 173
177static struct resource sa11x0uart1_resources[] = { 174static struct resource sa11x0uart1_resources[] = {
178 [0] = { 175 [0] = DEFINE_RES_MEM(__PREG(Ser1UTCR0), SZ_64K),
179 .start = __PREG(Ser1UTCR0), 176 [1] = DEFINE_RES_IRQ(IRQ_Ser1UART),
180 .end = __PREG(Ser1UTCR0) + 0xffff,
181 .flags = IORESOURCE_MEM,
182 },
183 [1] = {
184 .start = IRQ_Ser1UART,
185 .end = IRQ_Ser1UART,
186 .flags = IORESOURCE_IRQ,
187 },
188}; 177};
189 178
190static struct platform_device sa11x0uart1_device = { 179static struct platform_device sa11x0uart1_device = {
@@ -195,16 +184,8 @@ static struct platform_device sa11x0uart1_device = {
195}; 184};
196 185
197static struct resource sa11x0uart3_resources[] = { 186static struct resource sa11x0uart3_resources[] = {
198 [0] = { 187 [0] = DEFINE_RES_MEM(__PREG(Ser3UTCR0), SZ_64K),
199 .start = __PREG(Ser3UTCR0), 188 [1] = DEFINE_RES_IRQ(IRQ_Ser3UART),
200 .end = __PREG(Ser3UTCR0) + 0xffff,
201 .flags = IORESOURCE_MEM,
202 },
203 [1] = {
204 .start = IRQ_Ser3UART,
205 .end = IRQ_Ser3UART,
206 .flags = IORESOURCE_IRQ,
207 },
208}; 189};
209 190
210static struct platform_device sa11x0uart3_device = { 191static struct platform_device sa11x0uart3_device = {
@@ -215,16 +196,9 @@ static struct platform_device sa11x0uart3_device = {
215}; 196};
216 197
217static struct resource sa11x0mcp_resources[] = { 198static struct resource sa11x0mcp_resources[] = {
218 [0] = { 199 [0] = DEFINE_RES_MEM(__PREG(Ser4MCCR0), SZ_64K),
219 .start = __PREG(Ser4MCCR0), 200 [1] = DEFINE_RES_MEM(__PREG(Ser4MCCR1), 4),
220 .end = __PREG(Ser4MCCR0) + 0xffff, 201 [2] = DEFINE_RES_IRQ(IRQ_Ser4MCP),
221 .flags = IORESOURCE_MEM,
222 },
223 [1] = {
224 .start = IRQ_Ser4MCP,
225 .end = IRQ_Ser4MCP,
226 .flags = IORESOURCE_IRQ,
227 },
228}; 202};
229 203
230static u64 sa11x0mcp_dma_mask = 0xffffffffUL; 204static u64 sa11x0mcp_dma_mask = 0xffffffffUL;
@@ -240,22 +214,24 @@ static struct platform_device sa11x0mcp_device = {
240 .resource = sa11x0mcp_resources, 214 .resource = sa11x0mcp_resources,
241}; 215};
242 216
217void __init sa11x0_ppc_configure_mcp(void)
218{
219 /* Setup the PPC unit for the MCP */
220 PPDR &= ~PPC_RXD4;
221 PPDR |= PPC_TXD4 | PPC_SCLK | PPC_SFRM;
222 PSDR |= PPC_RXD4;
223 PSDR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM);
224 PPSR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM);
225}
226
243void sa11x0_register_mcp(struct mcp_plat_data *data) 227void sa11x0_register_mcp(struct mcp_plat_data *data)
244{ 228{
245 sa11x0_register_device(&sa11x0mcp_device, data); 229 sa11x0_register_device(&sa11x0mcp_device, data);
246} 230}
247 231
248static struct resource sa11x0ssp_resources[] = { 232static struct resource sa11x0ssp_resources[] = {
249 [0] = { 233 [0] = DEFINE_RES_MEM(0x80070000, SZ_64K),
250 .start = 0x80070000, 234 [1] = DEFINE_RES_IRQ(IRQ_Ser4SSP),
251 .end = 0x8007ffff,
252 .flags = IORESOURCE_MEM,
253 },
254 [1] = {
255 .start = IRQ_Ser4SSP,
256 .end = IRQ_Ser4SSP,
257 .flags = IORESOURCE_IRQ,
258 },
259}; 235};
260 236
261static u64 sa11x0ssp_dma_mask = 0xffffffffUL; 237static u64 sa11x0ssp_dma_mask = 0xffffffffUL;
@@ -272,16 +248,8 @@ static struct platform_device sa11x0ssp_device = {
272}; 248};
273 249
274static struct resource sa11x0fb_resources[] = { 250static struct resource sa11x0fb_resources[] = {
275 [0] = { 251 [0] = DEFINE_RES_MEM(0xb0100000, SZ_64K),
276 .start = 0xb0100000, 252 [1] = DEFINE_RES_IRQ(IRQ_LCD),
277 .end = 0xb010ffff,
278 .flags = IORESOURCE_MEM,
279 },
280 [1] = {
281 .start = IRQ_LCD,
282 .end = IRQ_LCD,
283 .flags = IORESOURCE_IRQ,
284 },
285}; 253};
286 254
287static struct platform_device sa11x0fb_device = { 255static struct platform_device sa11x0fb_device = {
@@ -294,6 +262,11 @@ static struct platform_device sa11x0fb_device = {
294 .resource = sa11x0fb_resources, 262 .resource = sa11x0fb_resources,
295}; 263};
296 264
265void sa11x0_register_lcd(struct sa1100fb_mach_info *inf)
266{
267 sa11x0_register_device(&sa11x0fb_device, inf);
268}
269
297static struct platform_device sa11x0pcmcia_device = { 270static struct platform_device sa11x0pcmcia_device = {
298 .name = "sa11x0-pcmcia", 271 .name = "sa11x0-pcmcia",
299 .id = -1, 272 .id = -1,
@@ -314,23 +287,10 @@ void sa11x0_register_mtd(struct flash_platform_data *flash,
314} 287}
315 288
316static struct resource sa11x0ir_resources[] = { 289static struct resource sa11x0ir_resources[] = {
317 { 290 DEFINE_RES_MEM(__PREG(Ser2UTCR0), 0x24),
318 .start = __PREG(Ser2UTCR0), 291 DEFINE_RES_MEM(__PREG(Ser2HSCR0), 0x1c),
319 .end = __PREG(Ser2UTCR0) + 0x24 - 1, 292 DEFINE_RES_MEM(__PREG(Ser2HSCR2), 0x04),
320 .flags = IORESOURCE_MEM, 293 DEFINE_RES_IRQ(IRQ_Ser2ICP),
321 }, {
322 .start = __PREG(Ser2HSCR0),
323 .end = __PREG(Ser2HSCR0) + 0x1c - 1,
324 .flags = IORESOURCE_MEM,
325 }, {
326 .start = __PREG(Ser2HSCR2),
327 .end = __PREG(Ser2HSCR2) + 0x04 - 1,
328 .flags = IORESOURCE_MEM,
329 }, {
330 .start = IRQ_Ser2ICP,
331 .end = IRQ_Ser2ICP,
332 .flags = IORESOURCE_IRQ,
333 }
334}; 294};
335 295
336static struct platform_device sa11x0ir_device = { 296static struct platform_device sa11x0ir_device = {
@@ -345,9 +305,40 @@ void sa11x0_register_irda(struct irda_platform_data *irda)
345 sa11x0_register_device(&sa11x0ir_device, irda); 305 sa11x0_register_device(&sa11x0ir_device, irda);
346} 306}
347 307
308static struct resource sa1100_rtc_resources[] = {
309 DEFINE_RES_MEM(0x90010000, 0x9001003f),
310 DEFINE_RES_IRQ_NAMED(IRQ_RTC1Hz, "rtc 1Hz"),
311 DEFINE_RES_IRQ_NAMED(IRQ_RTCAlrm, "rtc alarm"),
312};
313
348static struct platform_device sa11x0rtc_device = { 314static struct platform_device sa11x0rtc_device = {
349 .name = "sa1100-rtc", 315 .name = "sa1100-rtc",
350 .id = -1, 316 .id = -1,
317 .num_resources = ARRAY_SIZE(sa1100_rtc_resources),
318 .resource = sa1100_rtc_resources,
319};
320
321static struct resource sa11x0dma_resources[] = {
322 DEFINE_RES_MEM(DMA_PHYS, DMA_SIZE),
323 DEFINE_RES_IRQ(IRQ_DMA0),
324 DEFINE_RES_IRQ(IRQ_DMA1),
325 DEFINE_RES_IRQ(IRQ_DMA2),
326 DEFINE_RES_IRQ(IRQ_DMA3),
327 DEFINE_RES_IRQ(IRQ_DMA4),
328 DEFINE_RES_IRQ(IRQ_DMA5),
329};
330
331static u64 sa11x0dma_dma_mask = DMA_BIT_MASK(32);
332
333static struct platform_device sa11x0dma_device = {
334 .name = "sa11x0-dma",
335 .id = -1,
336 .dev = {
337 .dma_mask = &sa11x0dma_dma_mask,
338 .coherent_dma_mask = 0xffffffff,
339 },
340 .num_resources = ARRAY_SIZE(sa11x0dma_resources),
341 .resource = sa11x0dma_resources,
351}; 342};
352 343
353static struct platform_device *sa11x0_devices[] __initdata = { 344static struct platform_device *sa11x0_devices[] __initdata = {
@@ -356,8 +347,8 @@ static struct platform_device *sa11x0_devices[] __initdata = {
356 &sa11x0uart3_device, 347 &sa11x0uart3_device,
357 &sa11x0ssp_device, 348 &sa11x0ssp_device,
358 &sa11x0pcmcia_device, 349 &sa11x0pcmcia_device,
359 &sa11x0fb_device,
360 &sa11x0rtc_device, 350 &sa11x0rtc_device,
351 &sa11x0dma_device,
361}; 352};
362 353
363static int __init sa1100_init(void) 354static int __init sa1100_init(void)
@@ -368,12 +359,6 @@ static int __init sa1100_init(void)
368 359
369arch_initcall(sa1100_init); 360arch_initcall(sa1100_init);
370 361
371void (*sa1100fb_backlight_power)(int on);
372void (*sa1100fb_lcd_power)(int on);
373
374EXPORT_SYMBOL(sa1100fb_backlight_power);
375EXPORT_SYMBOL(sa1100fb_lcd_power);
376
377 362
378/* 363/*
379 * Common I/O mapping: 364 * Common I/O mapping:
@@ -428,7 +413,7 @@ void __init sa1100_map_io(void)
428 * the MBGNT signal false to ensure the SA1111 doesn't own the 413 * the MBGNT signal false to ensure the SA1111 doesn't own the
429 * SDRAM bus. 414 * SDRAM bus.
430 */ 415 */
431void __init sa1110_mb_disable(void) 416void sa1110_mb_disable(void)
432{ 417{
433 unsigned long flags; 418 unsigned long flags;
434 419
@@ -447,7 +432,7 @@ void __init sa1110_mb_disable(void)
447 * If the system is going to use the SA-1111 DMA engines, set up 432 * If the system is going to use the SA-1111 DMA engines, set up
448 * the memory bus request/grant pins. 433 * the memory bus request/grant pins.
449 */ 434 */
450void __devinit sa1110_mb_enable(void) 435void sa1110_mb_enable(void)
451{ 436{
452 unsigned long flags; 437 unsigned long flags;
453 438
diff --git a/arch/arm/mach-sa1100/generic.h b/arch/arm/mach-sa1100/generic.h
index 33268cf6be3..9eb3b3cd5a6 100644
--- a/arch/arm/mach-sa1100/generic.h
+++ b/arch/arm/mach-sa1100/generic.h
@@ -16,9 +16,6 @@ extern void sa11x0_restart(char, const char *);
16 mi->bank[__nr].start = (__start), \ 16 mi->bank[__nr].start = (__start), \
17 mi->bank[__nr].size = (__size) 17 mi->bank[__nr].size = (__size)
18 18
19extern void (*sa1100fb_backlight_power)(int on);
20extern void (*sa1100fb_lcd_power)(int on);
21
22extern void sa1110_mb_enable(void); 19extern void sa1110_mb_enable(void);
23extern void sa1110_mb_disable(void); 20extern void sa1110_mb_disable(void);
24 21
@@ -39,4 +36,8 @@ struct irda_platform_data;
39void sa11x0_register_irda(struct irda_platform_data *irda); 36void sa11x0_register_irda(struct irda_platform_data *irda);
40 37
41struct mcp_plat_data; 38struct mcp_plat_data;
39void sa11x0_ppc_configure_mcp(void);
42void sa11x0_register_mcp(struct mcp_plat_data *data); 40void sa11x0_register_mcp(struct mcp_plat_data *data);
41
42struct sa1100fb_mach_info;
43void sa11x0_register_lcd(struct sa1100fb_mach_info *inf);
diff --git a/arch/arm/mach-sa1100/h3100.c b/arch/arm/mach-sa1100/h3100.c
index 1e6b3c105ba..b2e8d0f418e 100644
--- a/arch/arm/mach-sa1100/h3100.c
+++ b/arch/arm/mach-sa1100/h3100.c
@@ -14,11 +14,14 @@
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/gpio.h> 15#include <linux/gpio.h>
16 16
17#include <video/sa1100fb.h>
18
17#include <asm/mach-types.h> 19#include <asm/mach-types.h>
18#include <asm/mach/arch.h> 20#include <asm/mach/arch.h>
19#include <asm/mach/irda.h> 21#include <asm/mach/irda.h>
20 22
21#include <mach/h3xxx.h> 23#include <mach/h3xxx.h>
24#include <mach/irqs.h>
22 25
23#include "generic.h" 26#include "generic.h"
24 27
@@ -36,13 +39,28 @@ static void h3100_lcd_power(int enable)
36 } 39 }
37} 40}
38 41
42static struct sa1100fb_mach_info h3100_lcd_info = {
43 .pixclock = 406977, .bpp = 4,
44 .xres = 320, .yres = 240,
45
46 .hsync_len = 26, .vsync_len = 41,
47 .left_margin = 4, .upper_margin = 0,
48 .right_margin = 4, .lower_margin = 0,
49
50 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
51 .cmap_greyscale = 1,
52 .cmap_inverse = 1,
53
54 .lccr0 = LCCR0_Mono | LCCR0_4PixMono | LCCR0_Sngl | LCCR0_Pas,
55 .lccr3 = LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(2),
56
57 .lcd_power = h3100_lcd_power,
58};
39 59
40static void __init h3100_map_io(void) 60static void __init h3100_map_io(void)
41{ 61{
42 h3xxx_map_io(); 62 h3xxx_map_io();
43 63
44 sa1100fb_lcd_power = h3100_lcd_power;
45
46 /* Older bootldrs put GPIO2-9 in alternate mode on the 64 /* Older bootldrs put GPIO2-9 in alternate mode on the
47 assumption that they are used for video */ 65 assumption that they are used for video */
48 GAFR &= ~0x000001fb; 66 GAFR &= ~0x000001fb;
@@ -80,12 +98,15 @@ static void __init h3100_mach_init(void)
80{ 98{
81 h3xxx_init_gpio(h3100_default_gpio, ARRAY_SIZE(h3100_default_gpio)); 99 h3xxx_init_gpio(h3100_default_gpio, ARRAY_SIZE(h3100_default_gpio));
82 h3xxx_mach_init(); 100 h3xxx_mach_init();
101
102 sa11x0_register_lcd(&h3100_lcd_info);
83 sa11x0_register_irda(&h3100_irda_data); 103 sa11x0_register_irda(&h3100_irda_data);
84} 104}
85 105
86MACHINE_START(H3100, "Compaq iPAQ H3100") 106MACHINE_START(H3100, "Compaq iPAQ H3100")
87 .atag_offset = 0x100, 107 .atag_offset = 0x100,
88 .map_io = h3100_map_io, 108 .map_io = h3100_map_io,
109 .nr_irqs = SA1100_NR_IRQS,
89 .init_irq = sa1100_init_irq, 110 .init_irq = sa1100_init_irq,
90 .timer = &sa1100_timer, 111 .timer = &sa1100_timer,
91 .init_machine = h3100_mach_init, 112 .init_machine = h3100_mach_init,
diff --git a/arch/arm/mach-sa1100/h3600.c b/arch/arm/mach-sa1100/h3600.c
index 6b58e7460ec..cb6659f294f 100644
--- a/arch/arm/mach-sa1100/h3600.c
+++ b/arch/arm/mach-sa1100/h3600.c
@@ -14,11 +14,14 @@
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/gpio.h> 15#include <linux/gpio.h>
16 16
17#include <video/sa1100fb.h>
18
17#include <asm/mach-types.h> 19#include <asm/mach-types.h>
18#include <asm/mach/arch.h> 20#include <asm/mach/arch.h>
19#include <asm/mach/irda.h> 21#include <asm/mach/irda.h>
20 22
21#include <mach/h3xxx.h> 23#include <mach/h3xxx.h>
24#include <mach/irqs.h>
22 25
23#include "generic.h" 26#include "generic.h"
24 27
@@ -56,11 +59,35 @@ err2: gpio_free(H3XXX_EGPIO_LCD_ON);
56err1: return; 59err1: return;
57} 60}
58 61
62static const struct sa1100fb_rgb h3600_rgb_16 = {
63 .red = { .offset = 12, .length = 4, },
64 .green = { .offset = 7, .length = 4, },
65 .blue = { .offset = 1, .length = 4, },
66 .transp = { .offset = 0, .length = 0, },
67};
68
69static struct sa1100fb_mach_info h3600_lcd_info = {
70 .pixclock = 174757, .bpp = 16,
71 .xres = 320, .yres = 240,
72
73 .hsync_len = 3, .vsync_len = 3,
74 .left_margin = 12, .upper_margin = 10,
75 .right_margin = 17, .lower_margin = 1,
76
77 .cmap_static = 1,
78
79 .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
80 .lccr3 = LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(2),
81
82 .rgb[RGB_16] = &h3600_rgb_16,
83
84 .lcd_power = h3600_lcd_power,
85};
86
87
59static void __init h3600_map_io(void) 88static void __init h3600_map_io(void)
60{ 89{
61 h3xxx_map_io(); 90 h3xxx_map_io();
62
63 sa1100fb_lcd_power = h3600_lcd_power;
64} 91}
65 92
66/* 93/*
@@ -121,12 +148,15 @@ static void __init h3600_mach_init(void)
121{ 148{
122 h3xxx_init_gpio(h3600_default_gpio, ARRAY_SIZE(h3600_default_gpio)); 149 h3xxx_init_gpio(h3600_default_gpio, ARRAY_SIZE(h3600_default_gpio));
123 h3xxx_mach_init(); 150 h3xxx_mach_init();
151
152 sa11x0_register_lcd(&h3600_lcd_info);
124 sa11x0_register_irda(&h3600_irda_data); 153 sa11x0_register_irda(&h3600_irda_data);
125} 154}
126 155
127MACHINE_START(H3600, "Compaq iPAQ H3600") 156MACHINE_START(H3600, "Compaq iPAQ H3600")
128 .atag_offset = 0x100, 157 .atag_offset = 0x100,
129 .map_io = h3600_map_io, 158 .map_io = h3600_map_io,
159 .nr_irqs = SA1100_NR_IRQS,
130 .init_irq = sa1100_init_irq, 160 .init_irq = sa1100_init_irq,
131 .timer = &sa1100_timer, 161 .timer = &sa1100_timer,
132 .init_machine = h3600_mach_init, 162 .init_machine = h3600_mach_init,
diff --git a/arch/arm/mach-sa1100/h3xxx.c b/arch/arm/mach-sa1100/h3xxx.c
index b0784c974c2..63150e1ffe9 100644
--- a/arch/arm/mach-sa1100/h3xxx.c
+++ b/arch/arm/mach-sa1100/h3xxx.c
@@ -109,11 +109,8 @@ static struct flash_platform_data h3xxx_flash_data = {
109 .nr_parts = ARRAY_SIZE(h3xxx_partitions), 109 .nr_parts = ARRAY_SIZE(h3xxx_partitions),
110}; 110};
111 111
112static struct resource h3xxx_flash_resource = { 112static struct resource h3xxx_flash_resource =
113 .start = SA1100_CS0_PHYS, 113 DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_32M);
114 .end = SA1100_CS0_PHYS + SZ_32M - 1,
115 .flags = IORESOURCE_MEM,
116};
117 114
118 115
119/* 116/*
@@ -186,11 +183,7 @@ static struct sa1100_port_fns h3xxx_port_fns __initdata = {
186 */ 183 */
187 184
188static struct resource egpio_resources[] = { 185static struct resource egpio_resources[] = {
189 [0] = { 186 [0] = DEFINE_RES_MEM(H3600_EGPIO_PHYS, 0x4),
190 .start = H3600_EGPIO_PHYS,
191 .end = H3600_EGPIO_PHYS + 0x4 - 1,
192 .flags = IORESOURCE_MEM,
193 },
194}; 187};
195 188
196static struct htc_egpio_chip egpio_chips[] = { 189static struct htc_egpio_chip egpio_chips[] = {
diff --git a/arch/arm/mach-sa1100/hackkit.c b/arch/arm/mach-sa1100/hackkit.c
index c01bb36db94..5535475bf58 100644
--- a/arch/arm/mach-sa1100/hackkit.c
+++ b/arch/arm/mach-sa1100/hackkit.c
@@ -22,12 +22,10 @@
22#include <linux/mtd/mtd.h> 22#include <linux/mtd/mtd.h>
23#include <linux/mtd/partitions.h> 23#include <linux/mtd/partitions.h>
24 24
25#include <mach/hardware.h>
26#include <asm/mach-types.h> 25#include <asm/mach-types.h>
27#include <asm/setup.h> 26#include <asm/setup.h>
28#include <asm/page.h> 27#include <asm/page.h>
29#include <asm/pgtable.h> 28#include <asm/pgtable.h>
30#include <asm/irq.h>
31 29
32#include <asm/mach/arch.h> 30#include <asm/mach/arch.h>
33#include <asm/mach/flash.h> 31#include <asm/mach/flash.h>
@@ -35,6 +33,9 @@
35#include <asm/mach/irq.h> 33#include <asm/mach/irq.h>
36#include <asm/mach/serial_sa1100.h> 34#include <asm/mach/serial_sa1100.h>
37 35
36#include <mach/hardware.h>
37#include <mach/irqs.h>
38
38#include "generic.h" 39#include "generic.h"
39 40
40/********************************************************************** 41/**********************************************************************
@@ -179,11 +180,8 @@ static struct flash_platform_data hackkit_flash_data = {
179 .nr_parts = ARRAY_SIZE(hackkit_partitions), 180 .nr_parts = ARRAY_SIZE(hackkit_partitions),
180}; 181};
181 182
182static struct resource hackkit_flash_resource = { 183static struct resource hackkit_flash_resource =
183 .start = SA1100_CS0_PHYS, 184 DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_32M);
184 .end = SA1100_CS0_PHYS + SZ_32M,
185 .flags = IORESOURCE_MEM,
186};
187 185
188static void __init hackkit_init(void) 186static void __init hackkit_init(void)
189{ 187{
@@ -197,6 +195,7 @@ static void __init hackkit_init(void)
197MACHINE_START(HACKKIT, "HackKit Cpu Board") 195MACHINE_START(HACKKIT, "HackKit Cpu Board")
198 .atag_offset = 0x100, 196 .atag_offset = 0x100,
199 .map_io = hackkit_map_io, 197 .map_io = hackkit_map_io,
198 .nr_irqs = SA1100_NR_IRQS,
200 .init_irq = sa1100_init_irq, 199 .init_irq = sa1100_init_irq,
201 .timer = &sa1100_timer, 200 .timer = &sa1100_timer,
202 .init_machine = hackkit_init, 201 .init_machine = hackkit_init,
diff --git a/arch/arm/mach-sa1100/include/mach/SA-1100.h b/arch/arm/mach-sa1100/include/mach/SA-1100.h
index bae8296f5db..3f2d1b60188 100644
--- a/arch/arm/mach-sa1100/include/mach/SA-1100.h
+++ b/arch/arm/mach-sa1100/include/mach/SA-1100.h
@@ -1590,224 +1590,9 @@
1590 1590
1591/* 1591/*
1592 * Direct Memory Access (DMA) control registers 1592 * Direct Memory Access (DMA) control registers
1593 *
1594 * Registers
1595 * DDAR0 Direct Memory Access (DMA) Device Address Register
1596 * channel 0 (read/write).
1597 * DCSR0 Direct Memory Access (DMA) Control and Status
1598 * Register channel 0 (read/write).
1599 * DBSA0 Direct Memory Access (DMA) Buffer Start address
1600 * register A channel 0 (read/write).
1601 * DBTA0 Direct Memory Access (DMA) Buffer Transfer count
1602 * register A channel 0 (read/write).
1603 * DBSB0 Direct Memory Access (DMA) Buffer Start address
1604 * register B channel 0 (read/write).
1605 * DBTB0 Direct Memory Access (DMA) Buffer Transfer count
1606 * register B channel 0 (read/write).
1607 *
1608 * DDAR1 Direct Memory Access (DMA) Device Address Register
1609 * channel 1 (read/write).
1610 * DCSR1 Direct Memory Access (DMA) Control and Status
1611 * Register channel 1 (read/write).
1612 * DBSA1 Direct Memory Access (DMA) Buffer Start address
1613 * register A channel 1 (read/write).
1614 * DBTA1 Direct Memory Access (DMA) Buffer Transfer count
1615 * register A channel 1 (read/write).
1616 * DBSB1 Direct Memory Access (DMA) Buffer Start address
1617 * register B channel 1 (read/write).
1618 * DBTB1 Direct Memory Access (DMA) Buffer Transfer count
1619 * register B channel 1 (read/write).
1620 *
1621 * DDAR2 Direct Memory Access (DMA) Device Address Register
1622 * channel 2 (read/write).
1623 * DCSR2 Direct Memory Access (DMA) Control and Status
1624 * Register channel 2 (read/write).
1625 * DBSA2 Direct Memory Access (DMA) Buffer Start address
1626 * register A channel 2 (read/write).
1627 * DBTA2 Direct Memory Access (DMA) Buffer Transfer count
1628 * register A channel 2 (read/write).
1629 * DBSB2 Direct Memory Access (DMA) Buffer Start address
1630 * register B channel 2 (read/write).
1631 * DBTB2 Direct Memory Access (DMA) Buffer Transfer count
1632 * register B channel 2 (read/write).
1633 *
1634 * DDAR3 Direct Memory Access (DMA) Device Address Register
1635 * channel 3 (read/write).
1636 * DCSR3 Direct Memory Access (DMA) Control and Status
1637 * Register channel 3 (read/write).
1638 * DBSA3 Direct Memory Access (DMA) Buffer Start address
1639 * register A channel 3 (read/write).
1640 * DBTA3 Direct Memory Access (DMA) Buffer Transfer count
1641 * register A channel 3 (read/write).
1642 * DBSB3 Direct Memory Access (DMA) Buffer Start address
1643 * register B channel 3 (read/write).
1644 * DBTB3 Direct Memory Access (DMA) Buffer Transfer count
1645 * register B channel 3 (read/write).
1646 *
1647 * DDAR4 Direct Memory Access (DMA) Device Address Register
1648 * channel 4 (read/write).
1649 * DCSR4 Direct Memory Access (DMA) Control and Status
1650 * Register channel 4 (read/write).
1651 * DBSA4 Direct Memory Access (DMA) Buffer Start address
1652 * register A channel 4 (read/write).
1653 * DBTA4 Direct Memory Access (DMA) Buffer Transfer count
1654 * register A channel 4 (read/write).
1655 * DBSB4 Direct Memory Access (DMA) Buffer Start address
1656 * register B channel 4 (read/write).
1657 * DBTB4 Direct Memory Access (DMA) Buffer Transfer count
1658 * register B channel 4 (read/write).
1659 *
1660 * DDAR5 Direct Memory Access (DMA) Device Address Register
1661 * channel 5 (read/write).
1662 * DCSR5 Direct Memory Access (DMA) Control and Status
1663 * Register channel 5 (read/write).
1664 * DBSA5 Direct Memory Access (DMA) Buffer Start address
1665 * register A channel 5 (read/write).
1666 * DBTA5 Direct Memory Access (DMA) Buffer Transfer count
1667 * register A channel 5 (read/write).
1668 * DBSB5 Direct Memory Access (DMA) Buffer Start address
1669 * register B channel 5 (read/write).
1670 * DBTB5 Direct Memory Access (DMA) Buffer Transfer count
1671 * register B channel 5 (read/write).
1672 */ 1593 */
1673 1594#define DMA_SIZE (6 * 0x20)
1674#define DMASp 0x00000020 /* DMA control reg. Space [byte] */ 1595#define DMA_PHYS 0xb0000000
1675
1676#define DDAR(Nb) __REG(0xB0000000 + (Nb)*DMASp) /* DMA Device Address Reg. channel [0..5] */
1677#define SetDCSR(Nb) __REG(0xB0000004 + (Nb)*DMASp) /* Set DMA Control & Status Reg. channel [0..5] (write) */
1678#define ClrDCSR(Nb) __REG(0xB0000008 + (Nb)*DMASp) /* Clear DMA Control & Status Reg. channel [0..5] (write) */
1679#define RdDCSR(Nb) __REG(0xB000000C + (Nb)*DMASp) /* Read DMA Control & Status Reg. channel [0..5] (read) */
1680#define DBSA(Nb) __REG(0xB0000010 + (Nb)*DMASp) /* DMA Buffer Start address reg. A channel [0..5] */
1681#define DBTA(Nb) __REG(0xB0000014 + (Nb)*DMASp) /* DMA Buffer Transfer count reg. A channel [0..5] */
1682#define DBSB(Nb) __REG(0xB0000018 + (Nb)*DMASp) /* DMA Buffer Start address reg. B channel [0..5] */
1683#define DBTB(Nb) __REG(0xB000001C + (Nb)*DMASp) /* DMA Buffer Transfer count reg. B channel [0..5] */
1684
1685#define DDAR_RW 0x00000001 /* device data Read/Write */
1686#define DDAR_DevWr (DDAR_RW*0) /* Device data Write */
1687 /* (memory -> device) */
1688#define DDAR_DevRd (DDAR_RW*1) /* Device data Read */
1689 /* (device -> memory) */
1690#define DDAR_E 0x00000002 /* big/little Endian device */
1691#define DDAR_LtlEnd (DDAR_E*0) /* Little Endian device */
1692#define DDAR_BigEnd (DDAR_E*1) /* Big Endian device */
1693#define DDAR_BS 0x00000004 /* device Burst Size */
1694#define DDAR_Brst4 (DDAR_BS*0) /* Burst-of-4 device */
1695#define DDAR_Brst8 (DDAR_BS*1) /* Burst-of-8 device */
1696#define DDAR_DW 0x00000008 /* device Data Width */
1697#define DDAR_8BitDev (DDAR_DW*0) /* 8-Bit Device */
1698#define DDAR_16BitDev (DDAR_DW*1) /* 16-Bit Device */
1699#define DDAR_DS Fld (4, 4) /* Device Select */
1700#define DDAR_Ser0UDCTr /* Ser. port 0 UDC Transmit */ \
1701 (0x0 << FShft (DDAR_DS))
1702#define DDAR_Ser0UDCRc /* Ser. port 0 UDC Receive */ \
1703 (0x1 << FShft (DDAR_DS))
1704#define DDAR_Ser1SDLCTr /* Ser. port 1 SDLC Transmit */ \
1705 (0x2 << FShft (DDAR_DS))
1706#define DDAR_Ser1SDLCRc /* Ser. port 1 SDLC Receive */ \
1707 (0x3 << FShft (DDAR_DS))
1708#define DDAR_Ser1UARTTr /* Ser. port 1 UART Transmit */ \
1709 (0x4 << FShft (DDAR_DS))
1710#define DDAR_Ser1UARTRc /* Ser. port 1 UART Receive */ \
1711 (0x5 << FShft (DDAR_DS))
1712#define DDAR_Ser2ICPTr /* Ser. port 2 ICP Transmit */ \
1713 (0x6 << FShft (DDAR_DS))
1714#define DDAR_Ser2ICPRc /* Ser. port 2 ICP Receive */ \
1715 (0x7 << FShft (DDAR_DS))
1716#define DDAR_Ser3UARTTr /* Ser. port 3 UART Transmit */ \
1717 (0x8 << FShft (DDAR_DS))
1718#define DDAR_Ser3UARTRc /* Ser. port 3 UART Receive */ \
1719 (0x9 << FShft (DDAR_DS))
1720#define DDAR_Ser4MCP0Tr /* Ser. port 4 MCP 0 Transmit */ \
1721 /* (audio) */ \
1722 (0xA << FShft (DDAR_DS))
1723#define DDAR_Ser4MCP0Rc /* Ser. port 4 MCP 0 Receive */ \
1724 /* (audio) */ \
1725 (0xB << FShft (DDAR_DS))
1726#define DDAR_Ser4MCP1Tr /* Ser. port 4 MCP 1 Transmit */ \
1727 /* (telecom) */ \
1728 (0xC << FShft (DDAR_DS))
1729#define DDAR_Ser4MCP1Rc /* Ser. port 4 MCP 1 Receive */ \
1730 /* (telecom) */ \
1731 (0xD << FShft (DDAR_DS))
1732#define DDAR_Ser4SSPTr /* Ser. port 4 SSP Transmit */ \
1733 (0xE << FShft (DDAR_DS))
1734#define DDAR_Ser4SSPRc /* Ser. port 4 SSP Receive */ \
1735 (0xF << FShft (DDAR_DS))
1736#define DDAR_DA Fld (24, 8) /* Device Address */
1737#define DDAR_DevAdd(Add) /* Device Address */ \
1738 (((Add) & 0xF0000000) | \
1739 (((Add) & 0X003FFFFC) << (FShft (DDAR_DA) - 2)))
1740#define DDAR_Ser0UDCWr /* Ser. port 0 UDC Write */ \
1741 (DDAR_DevWr + DDAR_Brst8 + DDAR_8BitDev + \
1742 DDAR_Ser0UDCTr + DDAR_DevAdd (__PREG(Ser0UDCDR)))
1743#define DDAR_Ser0UDCRd /* Ser. port 0 UDC Read */ \
1744 (DDAR_DevRd + DDAR_Brst8 + DDAR_8BitDev + \
1745 DDAR_Ser0UDCRc + DDAR_DevAdd (__PREG(Ser0UDCDR)))
1746#define DDAR_Ser1UARTWr /* Ser. port 1 UART Write */ \
1747 (DDAR_DevWr + DDAR_Brst4 + DDAR_8BitDev + \
1748 DDAR_Ser1UARTTr + DDAR_DevAdd (__PREG(Ser1UTDR)))
1749#define DDAR_Ser1UARTRd /* Ser. port 1 UART Read */ \
1750 (DDAR_DevRd + DDAR_Brst4 + DDAR_8BitDev + \
1751 DDAR_Ser1UARTRc + DDAR_DevAdd (__PREG(Ser1UTDR)))
1752#define DDAR_Ser1SDLCWr /* Ser. port 1 SDLC Write */ \
1753 (DDAR_DevWr + DDAR_Brst4 + DDAR_8BitDev + \
1754 DDAR_Ser1SDLCTr + DDAR_DevAdd (__PREG(Ser1SDDR)))
1755#define DDAR_Ser1SDLCRd /* Ser. port 1 SDLC Read */ \
1756 (DDAR_DevRd + DDAR_Brst4 + DDAR_8BitDev + \
1757 DDAR_Ser1SDLCRc + DDAR_DevAdd (__PREG(Ser1SDDR)))
1758#define DDAR_Ser2UARTWr /* Ser. port 2 UART Write */ \
1759 (DDAR_DevWr + DDAR_Brst4 + DDAR_8BitDev + \
1760 DDAR_Ser2ICPTr + DDAR_DevAdd (__PREG(Ser2UTDR)))
1761#define DDAR_Ser2UARTRd /* Ser. port 2 UART Read */ \
1762 (DDAR_DevRd + DDAR_Brst4 + DDAR_8BitDev + \
1763 DDAR_Ser2ICPRc + DDAR_DevAdd (__PREG(Ser2UTDR)))
1764#define DDAR_Ser2HSSPWr /* Ser. port 2 HSSP Write */ \
1765 (DDAR_DevWr + DDAR_Brst8 + DDAR_8BitDev + \
1766 DDAR_Ser2ICPTr + DDAR_DevAdd (__PREG(Ser2HSDR)))
1767#define DDAR_Ser2HSSPRd /* Ser. port 2 HSSP Read */ \
1768 (DDAR_DevRd + DDAR_Brst8 + DDAR_8BitDev + \
1769 DDAR_Ser2ICPRc + DDAR_DevAdd (__PREG(Ser2HSDR)))
1770#define DDAR_Ser3UARTWr /* Ser. port 3 UART Write */ \
1771 (DDAR_DevWr + DDAR_Brst4 + DDAR_8BitDev + \
1772 DDAR_Ser3UARTTr + DDAR_DevAdd (__PREG(Ser3UTDR)))
1773#define DDAR_Ser3UARTRd /* Ser. port 3 UART Read */ \
1774 (DDAR_DevRd + DDAR_Brst4 + DDAR_8BitDev + \
1775 DDAR_Ser3UARTRc + DDAR_DevAdd (__PREG(Ser3UTDR)))
1776#define DDAR_Ser4MCP0Wr /* Ser. port 4 MCP 0 Write (audio) */ \
1777 (DDAR_DevWr + DDAR_Brst4 + DDAR_16BitDev + \
1778 DDAR_Ser4MCP0Tr + DDAR_DevAdd (__PREG(Ser4MCDR0)))
1779#define DDAR_Ser4MCP0Rd /* Ser. port 4 MCP 0 Read (audio) */ \
1780 (DDAR_DevRd + DDAR_Brst4 + DDAR_16BitDev + \
1781 DDAR_Ser4MCP0Rc + DDAR_DevAdd (__PREG(Ser4MCDR0)))
1782#define DDAR_Ser4MCP1Wr /* Ser. port 4 MCP 1 Write */ \
1783 /* (telecom) */ \
1784 (DDAR_DevWr + DDAR_Brst4 + DDAR_16BitDev + \
1785 DDAR_Ser4MCP1Tr + DDAR_DevAdd (__PREG(Ser4MCDR1)))
1786#define DDAR_Ser4MCP1Rd /* Ser. port 4 MCP 1 Read */ \
1787 /* (telecom) */ \
1788 (DDAR_DevRd + DDAR_Brst4 + DDAR_16BitDev + \
1789 DDAR_Ser4MCP1Rc + DDAR_DevAdd (__PREG(Ser4MCDR1)))
1790#define DDAR_Ser4SSPWr /* Ser. port 4 SSP Write (16 bits) */ \
1791 (DDAR_DevWr + DDAR_Brst4 + DDAR_16BitDev + \
1792 DDAR_Ser4SSPTr + DDAR_DevAdd (__PREG(Ser4SSDR)))
1793#define DDAR_Ser4SSPRd /* Ser. port 4 SSP Read (16 bits) */ \
1794 (DDAR_DevRd + DDAR_Brst4 + DDAR_16BitDev + \
1795 DDAR_Ser4SSPRc + DDAR_DevAdd (__PREG(Ser4SSDR)))
1796
1797#define DCSR_RUN 0x00000001 /* DMA running */
1798#define DCSR_IE 0x00000002 /* DMA Interrupt Enable */
1799#define DCSR_ERROR 0x00000004 /* DMA ERROR */
1800#define DCSR_DONEA 0x00000008 /* DONE DMA transfer buffer A */
1801#define DCSR_STRTA 0x00000010 /* STaRTed DMA transfer buffer A */
1802#define DCSR_DONEB 0x00000020 /* DONE DMA transfer buffer B */
1803#define DCSR_STRTB 0x00000040 /* STaRTed DMA transfer buffer B */
1804#define DCSR_BIU 0x00000080 /* DMA Buffer In Use */
1805#define DCSR_BufA (DCSR_BIU*0) /* DMA Buffer A in use */
1806#define DCSR_BufB (DCSR_BIU*1) /* DMA Buffer B in use */
1807
1808#define DBT_TC Fld (13, 0) /* Transfer Count */
1809#define DBTA_TCA DBT_TC /* Transfer Count buffer A */
1810#define DBTB_TCB DBT_TC /* Transfer Count buffer B */
1811 1596
1812 1597
1813/* 1598/*
@@ -1903,16 +1688,6 @@
1903#define LCD_Int100_0A 0xF /* LCD Intensity = 100.0% = 1 */ 1688#define LCD_Int100_0A 0xF /* LCD Intensity = 100.0% = 1 */
1904 /* (Alternative) */ 1689 /* (Alternative) */
1905 1690
1906#define LCCR0 __REG(0xB0100000) /* LCD Control Reg. 0 */
1907#define LCSR __REG(0xB0100004) /* LCD Status Reg. */
1908#define DBAR1 __REG(0xB0100010) /* LCD DMA Base Address Reg. channel 1 */
1909#define DCAR1 __REG(0xB0100014) /* LCD DMA Current Address Reg. channel 1 */
1910#define DBAR2 __REG(0xB0100018) /* LCD DMA Base Address Reg. channel 2 */
1911#define DCAR2 __REG(0xB010001C) /* LCD DMA Current Address Reg. channel 2 */
1912#define LCCR1 __REG(0xB0100020) /* LCD Control Reg. 1 */
1913#define LCCR2 __REG(0xB0100024) /* LCD Control Reg. 2 */
1914#define LCCR3 __REG(0xB0100028) /* LCD Control Reg. 3 */
1915
1916#define LCCR0_LEN 0x00000001 /* LCD ENable */ 1691#define LCCR0_LEN 0x00000001 /* LCD ENable */
1917#define LCCR0_CMS 0x00000002 /* Color/Monochrome display Select */ 1692#define LCCR0_CMS 0x00000002 /* Color/Monochrome display Select */
1918#define LCCR0_Color (LCCR0_CMS*0) /* Color display */ 1693#define LCCR0_Color (LCCR0_CMS*0) /* Color display */
diff --git a/arch/arm/mach-sa1100/include/mach/assabet.h b/arch/arm/mach-sa1100/include/mach/assabet.h
index 28c2cf50c25..307391488c2 100644
--- a/arch/arm/mach-sa1100/include/mach/assabet.h
+++ b/arch/arm/mach-sa1100/include/mach/assabet.h
@@ -85,21 +85,18 @@ extern void ASSABET_BCR_frob(unsigned int mask, unsigned int set);
85#define ASSABET_BSR_RAD_RI (1 << 31) 85#define ASSABET_BSR_RAD_RI (1 << 31)
86 86
87 87
88/* GPIOs for which the generic definition doesn't say much */ 88/* GPIOs (bitmasks) for which the generic definition doesn't say much */
89#define ASSABET_GPIO_RADIO_IRQ GPIO_GPIO (14) /* Radio interrupt request */ 89#define ASSABET_GPIO_RADIO_IRQ GPIO_GPIO (14) /* Radio interrupt request */
90#define ASSABET_GPIO_PS_MODE_SYNC GPIO_GPIO (16) /* Power supply mode/sync */ 90#define ASSABET_GPIO_PS_MODE_SYNC GPIO_GPIO (16) /* Power supply mode/sync */
91#define ASSABET_GPIO_STEREO_64FS_CLK GPIO_GPIO (19) /* SSP UDA1341 clock input */ 91#define ASSABET_GPIO_STEREO_64FS_CLK GPIO_GPIO (19) /* SSP UDA1341 clock input */
92#define ASSABET_GPIO_CF_IRQ GPIO_GPIO (21) /* CF IRQ */
93#define ASSABET_GPIO_CF_CD GPIO_GPIO (22) /* CF CD */
94#define ASSABET_GPIO_CF_BVD2 GPIO_GPIO (24) /* CF BVD */
95#define ASSABET_GPIO_GFX_IRQ GPIO_GPIO (24) /* Graphics IRQ */ 92#define ASSABET_GPIO_GFX_IRQ GPIO_GPIO (24) /* Graphics IRQ */
96#define ASSABET_GPIO_CF_BVD1 GPIO_GPIO (25) /* CF BVD */
97#define ASSABET_GPIO_BATT_LOW GPIO_GPIO (26) /* Low battery */ 93#define ASSABET_GPIO_BATT_LOW GPIO_GPIO (26) /* Low battery */
98#define ASSABET_GPIO_RCLK GPIO_GPIO (26) /* CCLK/2 */ 94#define ASSABET_GPIO_RCLK GPIO_GPIO (26) /* CCLK/2 */
99 95
100#define ASSABET_IRQ_GPIO_CF_IRQ IRQ_GPIO21 96/* These are gpiolib GPIO numbers, not bitmasks */
101#define ASSABET_IRQ_GPIO_CF_CD IRQ_GPIO22 97#define ASSABET_GPIO_CF_IRQ 21 /* CF IRQ */
102#define ASSABET_IRQ_GPIO_CF_BVD2 IRQ_GPIO24 98#define ASSABET_GPIO_CF_CD 22 /* CF CD */
103#define ASSABET_IRQ_GPIO_CF_BVD1 IRQ_GPIO25 99#define ASSABET_GPIO_CF_BVD2 24 /* CF BVD / IOSPKR */
100#define ASSABET_GPIO_CF_BVD1 25 /* CF BVD / IOSTSCHG */
104 101
105#endif 102#endif
diff --git a/arch/arm/mach-sa1100/include/mach/cerf.h b/arch/arm/mach-sa1100/include/mach/cerf.h
index c3ac3d0f946..88fd9c006ce 100644
--- a/arch/arm/mach-sa1100/include/mach/cerf.h
+++ b/arch/arm/mach-sa1100/include/mach/cerf.h
@@ -14,15 +14,10 @@
14#define CERF_ETH_IO 0xf0000000 14#define CERF_ETH_IO 0xf0000000
15#define CERF_ETH_IRQ IRQ_GPIO26 15#define CERF_ETH_IRQ IRQ_GPIO26
16 16
17#define CERF_GPIO_CF_BVD2 GPIO_GPIO (19) 17#define CERF_GPIO_CF_BVD2 19
18#define CERF_GPIO_CF_BVD1 GPIO_GPIO (20) 18#define CERF_GPIO_CF_BVD1 20
19#define CERF_GPIO_CF_RESET GPIO_GPIO (21) 19#define CERF_GPIO_CF_RESET 21
20#define CERF_GPIO_CF_IRQ GPIO_GPIO (22) 20#define CERF_GPIO_CF_IRQ 22
21#define CERF_GPIO_CF_CD GPIO_GPIO (23) 21#define CERF_GPIO_CF_CD 23
22
23#define CERF_IRQ_GPIO_CF_BVD2 IRQ_GPIO19
24#define CERF_IRQ_GPIO_CF_BVD1 IRQ_GPIO20
25#define CERF_IRQ_GPIO_CF_IRQ IRQ_GPIO22
26#define CERF_IRQ_GPIO_CF_CD IRQ_GPIO23
27 22
28#endif // _INCLUDE_CERF_H_ 23#endif // _INCLUDE_CERF_H_
diff --git a/arch/arm/mach-sa1100/include/mach/dma.h b/arch/arm/mach-sa1100/include/mach/dma.h
deleted file mode 100644
index dda1b351310..00000000000
--- a/arch/arm/mach-sa1100/include/mach/dma.h
+++ /dev/null
@@ -1,117 +0,0 @@
1/*
2 * arch/arm/mach-sa1100/include/mach/dma.h
3 *
4 * Generic SA1100 DMA support
5 *
6 * Copyright (C) 2000 Nicolas Pitre
7 *
8 */
9
10#ifndef __ASM_ARCH_DMA_H
11#define __ASM_ARCH_DMA_H
12
13#include "hardware.h"
14
15
16/*
17 * The SA1100 has six internal DMA channels.
18 */
19#define SA1100_DMA_CHANNELS 6
20
21/*
22 * Maximum physical DMA buffer size
23 */
24#define MAX_DMA_SIZE 0x1fff
25#define CUT_DMA_SIZE 0x1000
26
27/*
28 * All possible SA1100 devices a DMA channel can be attached to.
29 */
30typedef enum {
31 DMA_Ser0UDCWr = DDAR_Ser0UDCWr, /* Ser. port 0 UDC Write */
32 DMA_Ser0UDCRd = DDAR_Ser0UDCRd, /* Ser. port 0 UDC Read */
33 DMA_Ser1UARTWr = DDAR_Ser1UARTWr, /* Ser. port 1 UART Write */
34 DMA_Ser1UARTRd = DDAR_Ser1UARTRd, /* Ser. port 1 UART Read */
35 DMA_Ser1SDLCWr = DDAR_Ser1SDLCWr, /* Ser. port 1 SDLC Write */
36 DMA_Ser1SDLCRd = DDAR_Ser1SDLCRd, /* Ser. port 1 SDLC Read */
37 DMA_Ser2UARTWr = DDAR_Ser2UARTWr, /* Ser. port 2 UART Write */
38 DMA_Ser2UARTRd = DDAR_Ser2UARTRd, /* Ser. port 2 UART Read */
39 DMA_Ser2HSSPWr = DDAR_Ser2HSSPWr, /* Ser. port 2 HSSP Write */
40 DMA_Ser2HSSPRd = DDAR_Ser2HSSPRd, /* Ser. port 2 HSSP Read */
41 DMA_Ser3UARTWr = DDAR_Ser3UARTWr, /* Ser. port 3 UART Write */
42 DMA_Ser3UARTRd = DDAR_Ser3UARTRd, /* Ser. port 3 UART Read */
43 DMA_Ser4MCP0Wr = DDAR_Ser4MCP0Wr, /* Ser. port 4 MCP 0 Write (audio) */
44 DMA_Ser4MCP0Rd = DDAR_Ser4MCP0Rd, /* Ser. port 4 MCP 0 Read (audio) */
45 DMA_Ser4MCP1Wr = DDAR_Ser4MCP1Wr, /* Ser. port 4 MCP 1 Write */
46 DMA_Ser4MCP1Rd = DDAR_Ser4MCP1Rd, /* Ser. port 4 MCP 1 Read */
47 DMA_Ser4SSPWr = DDAR_Ser4SSPWr, /* Ser. port 4 SSP Write (16 bits) */
48 DMA_Ser4SSPRd = DDAR_Ser4SSPRd /* Ser. port 4 SSP Read (16 bits) */
49} dma_device_t;
50
51typedef struct {
52 volatile u_long DDAR;
53 volatile u_long SetDCSR;
54 volatile u_long ClrDCSR;
55 volatile u_long RdDCSR;
56 volatile dma_addr_t DBSA;
57 volatile u_long DBTA;
58 volatile dma_addr_t DBSB;
59 volatile u_long DBTB;
60} dma_regs_t;
61
62typedef void (*dma_callback_t)(void *data);
63
64/*
65 * DMA function prototypes
66 */
67
68extern int sa1100_request_dma( dma_device_t device, const char *device_id,
69 dma_callback_t callback, void *data,
70 dma_regs_t **regs );
71extern void sa1100_free_dma( dma_regs_t *regs );
72extern int sa1100_start_dma( dma_regs_t *regs, dma_addr_t dma_ptr, u_int size );
73extern dma_addr_t sa1100_get_dma_pos(dma_regs_t *regs);
74extern void sa1100_reset_dma(dma_regs_t *regs);
75
76/**
77 * sa1100_stop_dma - stop DMA in progress
78 * @regs: identifier for the channel to use
79 *
80 * This stops DMA without clearing buffer pointers. Unlike
81 * sa1100_clear_dma() this allows subsequent use of sa1100_resume_dma()
82 * or sa1100_get_dma_pos().
83 *
84 * The @regs identifier is provided by a successful call to
85 * sa1100_request_dma().
86 **/
87
88#define sa1100_stop_dma(regs) ((regs)->ClrDCSR = DCSR_IE|DCSR_RUN)
89
90/**
91 * sa1100_resume_dma - resume DMA on a stopped channel
92 * @regs: identifier for the channel to use
93 *
94 * This resumes DMA on a channel previously stopped with
95 * sa1100_stop_dma().
96 *
97 * The @regs identifier is provided by a successful call to
98 * sa1100_request_dma().
99 **/
100
101#define sa1100_resume_dma(regs) ((regs)->SetDCSR = DCSR_IE|DCSR_RUN)
102
103/**
104 * sa1100_clear_dma - clear DMA pointers
105 * @regs: identifier for the channel to use
106 *
107 * This clear any DMA state so the DMA engine is ready to restart
108 * with new buffers through sa1100_start_dma(). Any buffers in flight
109 * are discarded.
110 *
111 * The @regs identifier is provided by a successful call to
112 * sa1100_request_dma().
113 **/
114
115#define sa1100_clear_dma(regs) ((regs)->ClrDCSR = DCSR_IE|DCSR_RUN|DCSR_STRTA|DCSR_STRTB)
116
117#endif /* _ASM_ARCH_DMA_H */
diff --git a/arch/arm/mach-sa1100/include/mach/entry-macro.S b/arch/arm/mach-sa1100/include/mach/entry-macro.S
index 6aa13c46c5d..8cf7630bf02 100644
--- a/arch/arm/mach-sa1100/include/mach/entry-macro.S
+++ b/arch/arm/mach-sa1100/include/mach/entry-macro.S
@@ -8,17 +8,11 @@
8 * warranty of any kind, whether express or implied. 8 * warranty of any kind, whether express or implied.
9 */ 9 */
10 10
11 .macro disable_fiq
12 .endm
13
14 .macro get_irqnr_preamble, base, tmp 11 .macro get_irqnr_preamble, base, tmp
15 mov \base, #0xfa000000 @ ICIP = 0xfa050000 12 mov \base, #0xfa000000 @ ICIP = 0xfa050000
16 add \base, \base, #0x00050000 13 add \base, \base, #0x00050000
17 .endm 14 .endm
18 15
19 .macro arch_ret_to_user, tmp1, tmp2
20 .endm
21
22 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp 16 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
23 ldr \irqstat, [\base] @ get irqs 17 ldr \irqstat, [\base] @ get irqs
24 ldr \irqnr, [\base, #4] @ ICMR = 0xfa050004 18 ldr \irqnr, [\base, #4] @ ICMR = 0xfa050004
diff --git a/arch/arm/mach-sa1100/include/mach/irqs.h b/arch/arm/mach-sa1100/include/mach/irqs.h
index d18f21abef8..3790298b714 100644
--- a/arch/arm/mach-sa1100/include/mach/irqs.h
+++ b/arch/arm/mach-sa1100/include/mach/irqs.h
@@ -71,22 +71,19 @@
71/* 71/*
72 * Figure out the MAX IRQ number. 72 * Figure out the MAX IRQ number.
73 * 73 *
74 * If we have an SA1111, the max IRQ is S1_BVD1_STSCHG+1. 74 * Neponset, SA1111 and UCB1x00 are sparse IRQ aware, so can dynamically
75 * If we have an LoCoMo, the max IRQ is IRQ_BOARD_START + 4 75 * allocate their IRQs above NR_IRQS.
76 * Otherwise, we have the standard IRQs only. 76 *
77 * LoCoMo has 4 additional IRQs, but is not sparse IRQ aware, and so has
78 * to be included in the NR_IRQS calculation.
77 */ 79 */
78#ifdef CONFIG_SA1111 80#ifdef CONFIG_SHARP_LOCOMO
79#define NR_IRQS (IRQ_BOARD_END + 55) 81#define NR_IRQS_LOCOMO 4
80#elif defined(CONFIG_SHARP_LOCOMO)
81#define NR_IRQS (IRQ_BOARD_START + 4)
82#else 82#else
83#define NR_IRQS (IRQ_BOARD_START) 83#define NR_IRQS_LOCOMO 0
84#endif 84#endif
85 85
86/* 86#ifndef NR_IRQS
87 * Board specific IRQs. Define them here. 87#define NR_IRQS (IRQ_BOARD_START + NR_IRQS_LOCOMO)
88 * Do not surround them with ifdefs. 88#endif
89 */ 89#define SA1100_NR_IRQS (IRQ_BOARD_START + NR_IRQS_LOCOMO)
90#define IRQ_NEPONSET_SMC9196 (IRQ_BOARD_START + 0)
91#define IRQ_NEPONSET_USAR (IRQ_BOARD_START + 1)
92#define IRQ_NEPONSET_SA1111 (IRQ_BOARD_START + 2)
diff --git a/arch/arm/mach-sa1100/include/mach/mcp.h b/arch/arm/mach-sa1100/include/mach/mcp.h
index ed1a331508a..4b2860ae382 100644
--- a/arch/arm/mach-sa1100/include/mach/mcp.h
+++ b/arch/arm/mach-sa1100/include/mach/mcp.h
@@ -16,7 +16,7 @@ struct mcp_plat_data {
16 u32 mccr0; 16 u32 mccr0;
17 u32 mccr1; 17 u32 mccr1;
18 unsigned int sclk_rate; 18 unsigned int sclk_rate;
19 int gpio_base; 19 void *codec_pdata;
20}; 20};
21 21
22#endif 22#endif
diff --git a/arch/arm/mach-sa1100/include/mach/nanoengine.h b/arch/arm/mach-sa1100/include/mach/nanoengine.h
index 14f8382d066..5ebd469a31f 100644
--- a/arch/arm/mach-sa1100/include/mach/nanoengine.h
+++ b/arch/arm/mach-sa1100/include/mach/nanoengine.h
@@ -16,12 +16,12 @@
16 16
17#include <mach/irqs.h> 17#include <mach/irqs.h>
18 18
19#define GPIO_PC_READY0 GPIO_GPIO(11) /* ready for socket 0 (active high)*/ 19#define GPIO_PC_READY0 11 /* ready for socket 0 (active high)*/
20#define GPIO_PC_READY1 GPIO_GPIO(12) /* ready for socket 1 (active high) */ 20#define GPIO_PC_READY1 12 /* ready for socket 1 (active high) */
21#define GPIO_PC_CD0 GPIO_GPIO(13) /* detect for socket 0 (active low) */ 21#define GPIO_PC_CD0 13 /* detect for socket 0 (active low) */
22#define GPIO_PC_CD1 GPIO_GPIO(14) /* detect for socket 1 (active low) */ 22#define GPIO_PC_CD1 14 /* detect for socket 1 (active low) */
23#define GPIO_PC_RESET0 GPIO_GPIO(15) /* reset socket 0 */ 23#define GPIO_PC_RESET0 15 /* reset socket 0 */
24#define GPIO_PC_RESET1 GPIO_GPIO(16) /* reset socket 1 */ 24#define GPIO_PC_RESET1 16 /* reset socket 1 */
25 25
26#define NANOENGINE_IRQ_GPIO_PCI IRQ_GPIO0 26#define NANOENGINE_IRQ_GPIO_PCI IRQ_GPIO0
27#define NANOENGINE_IRQ_GPIO_PC_READY0 IRQ_GPIO11 27#define NANOENGINE_IRQ_GPIO_PC_READY0 IRQ_GPIO11
diff --git a/arch/arm/mach-sa1100/include/mach/neponset.h b/arch/arm/mach-sa1100/include/mach/neponset.h
index ffe2bc45eed..5516a52a329 100644
--- a/arch/arm/mach-sa1100/include/mach/neponset.h
+++ b/arch/arm/mach-sa1100/include/mach/neponset.h
@@ -15,54 +15,6 @@
15/* 15/*
16 * Neponset definitions: 16 * Neponset definitions:
17 */ 17 */
18
19#define NEPONSET_CPLD_BASE (0x10000000)
20#define Nep_p2v( x ) ((x) - NEPONSET_CPLD_BASE + 0xf3000000)
21#define Nep_v2p( x ) ((x) - 0xf3000000 + NEPONSET_CPLD_BASE)
22
23#define _IRR 0x10000024 /* Interrupt Reason Register */
24#define _AUD_CTL 0x100000c0 /* Audio controls (RW) */
25#define _MDM_CTL_0 0x100000b0 /* Modem control 0 (RW) */
26#define _MDM_CTL_1 0x100000b4 /* Modem control 1 (RW) */
27#define _NCR_0 0x100000a0 /* Control Register (RW) */
28#define _KP_X_OUT 0x10000090 /* Keypad row write (RW) */
29#define _KP_Y_IN 0x10000080 /* Keypad column read (RO) */
30#define _SWPK 0x10000020 /* Switch pack (RO) */
31#define _WHOAMI 0x10000000 /* System ID Register (RO) */
32
33#define _LEDS 0x10000010 /* LEDs [31:0] (WO) */
34
35#define IRR (*((volatile u_char *) Nep_p2v(_IRR)))
36#define AUD_CTL (*((volatile u_char *) Nep_p2v(_AUD_CTL)))
37#define MDM_CTL_0 (*((volatile u_char *) Nep_p2v(_MDM_CTL_0)))
38#define MDM_CTL_1 (*((volatile u_char *) Nep_p2v(_MDM_CTL_1)))
39#define NCR_0 (*((volatile u_char *) Nep_p2v(_NCR_0)))
40#define KP_X_OUT (*((volatile u_char *) Nep_p2v(_KP_X_OUT)))
41#define KP_Y_IN (*((volatile u_char *) Nep_p2v(_KP_Y_IN)))
42#define SWPK (*((volatile u_char *) Nep_p2v(_SWPK)))
43#define WHOAMI (*((volatile u_char *) Nep_p2v(_WHOAMI)))
44
45#define LEDS (*((volatile Word *) Nep_p2v(_LEDS)))
46
47#define IRR_ETHERNET (1<<0)
48#define IRR_USAR (1<<1)
49#define IRR_SA1111 (1<<2)
50
51#define AUD_SEL_1341 (1<<0)
52#define AUD_MUTE_1341 (1<<1)
53
54#define MDM_CTL0_RTS1 (1 << 0)
55#define MDM_CTL0_DTR1 (1 << 1)
56#define MDM_CTL0_RTS2 (1 << 2)
57#define MDM_CTL0_DTR2 (1 << 3)
58
59#define MDM_CTL1_CTS1 (1 << 0)
60#define MDM_CTL1_DSR1 (1 << 1)
61#define MDM_CTL1_DCD1 (1 << 2)
62#define MDM_CTL1_CTS2 (1 << 3)
63#define MDM_CTL1_DSR2 (1 << 4)
64#define MDM_CTL1_DCD2 (1 << 5)
65
66#define NCR_GP01_OFF (1<<0) 18#define NCR_GP01_OFF (1<<0)
67#define NCR_TP_PWR_EN (1<<1) 19#define NCR_TP_PWR_EN (1<<1)
68#define NCR_MS_PWR_EN (1<<2) 20#define NCR_MS_PWR_EN (1<<2)
@@ -71,4 +23,8 @@
71#define NCR_A0VPP (1<<5) 23#define NCR_A0VPP (1<<5)
72#define NCR_A1VPP (1<<6) 24#define NCR_A1VPP (1<<6)
73 25
26void neponset_ncr_frob(unsigned int, unsigned int);
27#define neponset_ncr_set(v) neponset_ncr_frob(0, v)
28#define neponset_ncr_clear(v) neponset_ncr_frob(v, 0)
29
74#endif 30#endif
diff --git a/arch/arm/mach-sa1100/include/mach/shannon.h b/arch/arm/mach-sa1100/include/mach/shannon.h
index ec27d6e1214..fff39e02b49 100644
--- a/arch/arm/mach-sa1100/include/mach/shannon.h
+++ b/arch/arm/mach-sa1100/include/mach/shannon.h
@@ -21,16 +21,12 @@
21#define SHANNON_GPIO_U3_RTS GPIO_GPIO (19) /* ?? */ 21#define SHANNON_GPIO_U3_RTS GPIO_GPIO (19) /* ?? */
22#define SHANNON_GPIO_U3_CTS GPIO_GPIO (20) /* ?? */ 22#define SHANNON_GPIO_U3_CTS GPIO_GPIO (20) /* ?? */
23#define SHANNON_GPIO_SENSE_12V GPIO_GPIO (21) /* Input, 12v flash unprotect detected */ 23#define SHANNON_GPIO_SENSE_12V GPIO_GPIO (21) /* Input, 12v flash unprotect detected */
24#define SHANNON_GPIO_DISP_EN GPIO_GPIO (22) /* out */ 24#define SHANNON_GPIO_DISP_EN 22 /* out */
25/* XXX GPIO 23 unaccounted for */ 25/* XXX GPIO 23 unaccounted for */
26#define SHANNON_GPIO_EJECT_0 GPIO_GPIO (24) /* in */ 26#define SHANNON_GPIO_EJECT_0 24 /* in */
27#define SHANNON_IRQ_GPIO_EJECT_0 IRQ_GPIO24 27#define SHANNON_GPIO_EJECT_1 25 /* in */
28#define SHANNON_GPIO_EJECT_1 GPIO_GPIO (25) /* in */ 28#define SHANNON_GPIO_RDY_0 26 /* in */
29#define SHANNON_IRQ_GPIO_EJECT_1 IRQ_GPIO25 29#define SHANNON_GPIO_RDY_1 27 /* in */
30#define SHANNON_GPIO_RDY_0 GPIO_GPIO (26) /* in */
31#define SHANNON_IRQ_GPIO_RDY_0 IRQ_GPIO26
32#define SHANNON_GPIO_RDY_1 GPIO_GPIO (27) /* in */
33#define SHANNON_IRQ_GPIO_RDY_1 IRQ_GPIO27
34 30
35/* MCP UCB codec GPIO pins... */ 31/* MCP UCB codec GPIO pins... */
36 32
diff --git a/arch/arm/mach-sa1100/include/mach/simpad.h b/arch/arm/mach-sa1100/include/mach/simpad.h
index db28118103e..cdea671e893 100644
--- a/arch/arm/mach-sa1100/include/mach/simpad.h
+++ b/arch/arm/mach-sa1100/include/mach/simpad.h
@@ -39,10 +39,8 @@
39 39
40 40
41/*--- PCMCIA ---*/ 41/*--- PCMCIA ---*/
42#define GPIO_CF_CD GPIO_GPIO24 42#define GPIO_CF_CD 24
43#define GPIO_CF_IRQ GPIO_GPIO1 43#define GPIO_CF_IRQ 1
44#define IRQ_GPIO_CF_IRQ IRQ_GPIO1
45#define IRQ_GPIO_CF_CD IRQ_GPIO24
46 44
47/*--- SmartCard ---*/ 45/*--- SmartCard ---*/
48#define GPIO_SMART_CARD GPIO_GPIO10 46#define GPIO_SMART_CARD GPIO_GPIO10
diff --git a/arch/arm/mach-sa1100/include/mach/system.h b/arch/arm/mach-sa1100/include/mach/system.h
deleted file mode 100644
index e17b208f76d..00000000000
--- a/arch/arm/mach-sa1100/include/mach/system.h
+++ /dev/null
@@ -1,9 +0,0 @@
1/*
2 * arch/arm/mach-sa1100/include/mach/system.h
3 *
4 * Copyright (c) 1999 Nicolas Pitre <nico@fluxnic.net>
5 */
6static inline void arch_idle(void)
7{
8 cpu_do_idle();
9}
diff --git a/arch/arm/mach-sa1100/irq.c b/arch/arm/mach-sa1100/irq.c
index dfbf824a69f..516ccc25d7f 100644
--- a/arch/arm/mach-sa1100/irq.c
+++ b/arch/arm/mach-sa1100/irq.c
@@ -17,6 +17,7 @@
17#include <linux/syscore_ops.h> 17#include <linux/syscore_ops.h>
18 18
19#include <mach/hardware.h> 19#include <mach/hardware.h>
20#include <mach/irqs.h>
20#include <asm/mach/irq.h> 21#include <asm/mach/irq.h>
21 22
22#include "generic.h" 23#include "generic.h"
@@ -221,11 +222,8 @@ static struct irq_chip sa1100_normal_chip = {
221 .irq_set_wake = sa1100_set_wake, 222 .irq_set_wake = sa1100_set_wake,
222}; 223};
223 224
224static struct resource irq_resource = { 225static struct resource irq_resource =
225 .name = "irqs", 226 DEFINE_RES_MEM_NAMED(0x90050000, SZ_64K, "irqs");
226 .start = 0x90050000,
227 .end = 0x9005ffff,
228};
229 227
230static struct sa1100irq_state { 228static struct sa1100irq_state {
231 unsigned int saved; 229 unsigned int saved;
diff --git a/arch/arm/mach-sa1100/jornada720.c b/arch/arm/mach-sa1100/jornada720.c
index ee121d6f048..ca7a7e83472 100644
--- a/arch/arm/mach-sa1100/jornada720.c
+++ b/arch/arm/mach-sa1100/jornada720.c
@@ -23,9 +23,7 @@
23#include <linux/mtd/partitions.h> 23#include <linux/mtd/partitions.h>
24#include <video/s1d13xxxfb.h> 24#include <video/s1d13xxxfb.h>
25 25
26#include <mach/hardware.h>
27#include <asm/hardware/sa1111.h> 26#include <asm/hardware/sa1111.h>
28#include <asm/irq.h>
29#include <asm/page.h> 27#include <asm/page.h>
30#include <asm/mach-types.h> 28#include <asm/mach-types.h>
31#include <asm/setup.h> 29#include <asm/setup.h>
@@ -34,6 +32,9 @@
34#include <asm/mach/map.h> 32#include <asm/mach/map.h>
35#include <asm/mach/serial_sa1100.h> 33#include <asm/mach/serial_sa1100.h>
36 34
35#include <mach/hardware.h>
36#include <mach/irqs.h>
37
37#include "generic.h" 38#include "generic.h"
38 39
39/* 40/*
@@ -46,7 +47,7 @@
46 47
47/* memory space (line 52 of HP's doc) */ 48/* memory space (line 52 of HP's doc) */
48#define SA1111REGSTART 0x40000000 49#define SA1111REGSTART 0x40000000
49#define SA1111REGLEN 0x00001fff 50#define SA1111REGLEN 0x00002000
50#define EPSONREGSTART 0x48000000 51#define EPSONREGSTART 0x48000000
51#define EPSONREGLEN 0x00100000 52#define EPSONREGLEN 0x00100000
52#define EPSONFBSTART 0x48200000 53#define EPSONFBSTART 0x48200000
@@ -174,16 +175,8 @@ static struct s1d13xxxfb_pdata s1d13xxxfb_data = {
174}; 175};
175 176
176static struct resource s1d13xxxfb_resources[] = { 177static struct resource s1d13xxxfb_resources[] = {
177 [0] = { 178 [0] = DEFINE_RES_MEM(EPSONFBSTART, EPSONFBLEN),
178 .start = EPSONFBSTART, 179 [1] = DEFINE_RES_MEM(EPSONREGSTART, EPSONREGLEN),
179 .end = EPSONFBSTART + EPSONFBLEN,
180 .flags = IORESOURCE_MEM,
181 },
182 [1] = {
183 .start = EPSONREGSTART,
184 .end = EPSONREGSTART + EPSONREGLEN,
185 .flags = IORESOURCE_MEM,
186 }
187}; 180};
188 181
189static struct platform_device s1d13xxxfb_device = { 182static struct platform_device s1d13xxxfb_device = {
@@ -197,20 +190,12 @@ static struct platform_device s1d13xxxfb_device = {
197}; 190};
198 191
199static struct resource sa1111_resources[] = { 192static struct resource sa1111_resources[] = {
200 [0] = { 193 [0] = DEFINE_RES_MEM(SA1111REGSTART, SA1111REGLEN),
201 .start = SA1111REGSTART, 194 [1] = DEFINE_RES_IRQ(IRQ_GPIO1),
202 .end = SA1111REGSTART + SA1111REGLEN,
203 .flags = IORESOURCE_MEM,
204 },
205 [1] = {
206 .start = IRQ_GPIO1,
207 .end = IRQ_GPIO1,
208 .flags = IORESOURCE_IRQ,
209 },
210}; 195};
211 196
212static struct sa1111_platform_data sa1111_info = { 197static struct sa1111_platform_data sa1111_info = {
213 .irq_base = IRQ_BOARD_END, 198 .disable_devs = SA1111_DEVID_PS2_MSE,
214}; 199};
215 200
216static u64 sa1111_dmamask = 0xffffffffUL; 201static u64 sa1111_dmamask = 0xffffffffUL;
@@ -284,11 +269,6 @@ static struct map_desc jornada720_io_desc[] __initdata = {
284 .pfn = __phys_to_pfn(EPSONFBSTART), 269 .pfn = __phys_to_pfn(EPSONFBSTART),
285 .length = EPSONFBLEN, 270 .length = EPSONFBLEN,
286 .type = MT_DEVICE 271 .type = MT_DEVICE
287 }, { /* SA-1111 */
288 .virtual = 0xf4000000,
289 .pfn = __phys_to_pfn(SA1111REGSTART),
290 .length = SA1111REGLEN,
291 .type = MT_DEVICE
292 } 272 }
293}; 273};
294 274
@@ -352,11 +332,8 @@ static struct flash_platform_data jornada720_flash_data = {
352 .nr_parts = ARRAY_SIZE(jornada720_partitions), 332 .nr_parts = ARRAY_SIZE(jornada720_partitions),
353}; 333};
354 334
355static struct resource jornada720_flash_resource = { 335static struct resource jornada720_flash_resource =
356 .start = SA1100_CS0_PHYS, 336 DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_32M);
357 .end = SA1100_CS0_PHYS + SZ_32M - 1,
358 .flags = IORESOURCE_MEM,
359};
360 337
361static void __init jornada720_mach_init(void) 338static void __init jornada720_mach_init(void)
362{ 339{
@@ -367,6 +344,7 @@ MACHINE_START(JORNADA720, "HP Jornada 720")
367 /* Maintainer: Kristoffer Ericson <Kristoffer.Ericson@gmail.com> */ 344 /* Maintainer: Kristoffer Ericson <Kristoffer.Ericson@gmail.com> */
368 .atag_offset = 0x100, 345 .atag_offset = 0x100,
369 .map_io = jornada720_map_io, 346 .map_io = jornada720_map_io,
347 .nr_irqs = SA1100_NR_IRQS,
370 .init_irq = sa1100_init_irq, 348 .init_irq = sa1100_init_irq,
371 .timer = &sa1100_timer, 349 .timer = &sa1100_timer,
372 .init_machine = jornada720_mach_init, 350 .init_machine = jornada720_mach_init,
diff --git a/arch/arm/mach-sa1100/lart.c b/arch/arm/mach-sa1100/lart.c
index af4e2761f3d..eb6534e0b0d 100644
--- a/arch/arm/mach-sa1100/lart.c
+++ b/arch/arm/mach-sa1100/lart.c
@@ -6,6 +6,8 @@
6#include <linux/kernel.h> 6#include <linux/kernel.h>
7#include <linux/tty.h> 7#include <linux/tty.h>
8 8
9#include <video/sa1100fb.h>
10
9#include <mach/hardware.h> 11#include <mach/hardware.h>
10#include <asm/setup.h> 12#include <asm/setup.h>
11#include <asm/mach-types.h> 13#include <asm/mach-types.h>
@@ -15,6 +17,7 @@
15#include <asm/mach/map.h> 17#include <asm/mach/map.h>
16#include <asm/mach/serial_sa1100.h> 18#include <asm/mach/serial_sa1100.h>
17#include <mach/mcp.h> 19#include <mach/mcp.h>
20#include <mach/irqs.h>
18 21
19#include "generic.h" 22#include "generic.h"
20 23
@@ -26,8 +29,86 @@ static struct mcp_plat_data lart_mcp_data = {
26 .sclk_rate = 11981000, 29 .sclk_rate = 11981000,
27}; 30};
28 31
32#ifdef LART_GREY_LCD
33static struct sa1100fb_mach_info lart_grey_info = {
34 .pixclock = 150000, .bpp = 4,
35 .xres = 320, .yres = 240,
36
37 .hsync_len = 1, .vsync_len = 1,
38 .left_margin = 4, .upper_margin = 0,
39 .right_margin = 2, .lower_margin = 0,
40
41 .cmap_greyscale = 1,
42 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
43
44 .lccr0 = LCCR0_Mono | LCCR0_Sngl | LCCR0_Pas | LCCR0_4PixMono,
45 .lccr3 = LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(512),
46};
47#endif
48#ifdef LART_COLOR_LCD
49static struct sa1100fb_mach_info lart_color_info = {
50 .pixclock = 150000, .bpp = 16,
51 .xres = 320, .yres = 240,
52
53 .hsync_len = 2, .vsync_len = 3,
54 .left_margin = 69, .upper_margin = 14,
55 .right_margin = 8, .lower_margin = 4,
56
57 .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
58 .lccr3 = LCCR3_OutEnH | LCCR3_PixFlEdg | LCCR3_ACBsDiv(512),
59};
60#endif
61#ifdef LART_VIDEO_OUT
62static struct sa1100fb_mach_info lart_video_info = {
63 .pixclock = 39721, .bpp = 16,
64 .xres = 640, .yres = 480,
65
66 .hsync_len = 95, .vsync_len = 2,
67 .left_margin = 40, .upper_margin = 32,
68 .right_margin = 24, .lower_margin = 11,
69
70 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
71
72 .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
73 .lccr3 = LCCR3_OutEnL | LCCR3_PixFlEdg | LCCR3_ACBsDiv(512),
74};
75#endif
76
77#ifdef LART_KIT01_LCD
78static struct sa1100fb_mach_info lart_kit01_info = {
79 .pixclock = 63291, .bpp = 16,
80 .xres = 640, .yres = 480,
81
82 .hsync_len = 64, .vsync_len = 3,
83 .left_margin = 122, .upper_margin = 45,
84 .right_margin = 10, .lower_margin = 10,
85
86 .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
87 .lccr3 = LCCR3_OutEnH | LCCR3_PixFlEdg
88};
89#endif
90
29static void __init lart_init(void) 91static void __init lart_init(void)
30{ 92{
93 struct sa1100fb_mach_info *inf = NULL;
94
95#ifdef LART_GREY_LCD
96 inf = &lart_grey_info;
97#endif
98#ifdef LART_COLOR_LCD
99 inf = &lart_color_info;
100#endif
101#ifdef LART_VIDEO_OUT
102 inf = &lart_video_info;
103#endif
104#ifdef LART_KIT01_LCD
105 inf = &lart_kit01_info;
106#endif
107
108 if (inf)
109 sa11x0_register_lcd(inf);
110
111 sa11x0_ppc_configure_mcp();
31 sa11x0_register_mcp(&lart_mcp_data); 112 sa11x0_register_mcp(&lart_mcp_data);
32} 113}
33 114
@@ -63,6 +144,7 @@ static void __init lart_map_io(void)
63MACHINE_START(LART, "LART") 144MACHINE_START(LART, "LART")
64 .atag_offset = 0x100, 145 .atag_offset = 0x100,
65 .map_io = lart_map_io, 146 .map_io = lart_map_io,
147 .nr_irqs = SA1100_NR_IRQS,
66 .init_irq = sa1100_init_irq, 148 .init_irq = sa1100_init_irq,
67 .init_machine = lart_init, 149 .init_machine = lart_init,
68 .timer = &sa1100_timer, 150 .timer = &sa1100_timer,
diff --git a/arch/arm/mach-sa1100/nanoengine.c b/arch/arm/mach-sa1100/nanoengine.c
index 85f6ee67222..8f6446b9f02 100644
--- a/arch/arm/mach-sa1100/nanoengine.c
+++ b/arch/arm/mach-sa1100/nanoengine.c
@@ -28,6 +28,7 @@
28 28
29#include <mach/hardware.h> 29#include <mach/hardware.h>
30#include <mach/nanoengine.h> 30#include <mach/nanoengine.h>
31#include <mach/irqs.h>
31 32
32#include "generic.h" 33#include "generic.h"
33 34
@@ -58,15 +59,8 @@ static struct flash_platform_data nanoengine_flash_data = {
58}; 59};
59 60
60static struct resource nanoengine_flash_resources[] = { 61static struct resource nanoengine_flash_resources[] = {
61 { 62 DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_32M),
62 .start = SA1100_CS0_PHYS, 63 DEFINE_RES_MEM(SA1100_CS1_PHYS, SZ_32M),
63 .end = SA1100_CS0_PHYS + SZ_32M - 1,
64 .flags = IORESOURCE_MEM,
65 }, {
66 .start = SA1100_CS1_PHYS,
67 .end = SA1100_CS1_PHYS + SZ_32M - 1,
68 .flags = IORESOURCE_MEM,
69 }
70}; 64};
71 65
72static struct map_desc nanoengine_io_desc[] __initdata = { 66static struct map_desc nanoengine_io_desc[] __initdata = {
@@ -114,6 +108,7 @@ static void __init nanoengine_init(void)
114MACHINE_START(NANOENGINE, "BSE nanoEngine") 108MACHINE_START(NANOENGINE, "BSE nanoEngine")
115 .atag_offset = 0x100, 109 .atag_offset = 0x100,
116 .map_io = nanoengine_map_io, 110 .map_io = nanoengine_map_io,
111 .nr_irqs = SA1100_NR_IRQS,
117 .init_irq = sa1100_init_irq, 112 .init_irq = sa1100_init_irq,
118 .timer = &sa1100_timer, 113 .timer = &sa1100_timer,
119 .init_machine = nanoengine_init, 114 .init_machine = nanoengine_init,
diff --git a/arch/arm/mach-sa1100/neponset.c b/arch/arm/mach-sa1100/neponset.c
index b4fa53a1427..6c58f01b358 100644
--- a/arch/arm/mach-sa1100/neponset.c
+++ b/arch/arm/mach-sa1100/neponset.c
@@ -1,89 +1,104 @@
1/* 1/*
2 * linux/arch/arm/mach-sa1100/neponset.c 2 * linux/arch/arm/mach-sa1100/neponset.c
3 *
4 */ 3 */
5#include <linux/kernel.h> 4#include <linux/err.h>
6#include <linux/init.h> 5#include <linux/init.h>
7#include <linux/tty.h>
8#include <linux/ioport.h> 6#include <linux/ioport.h>
9#include <linux/serial_core.h> 7#include <linux/irq.h>
8#include <linux/kernel.h>
9#include <linux/module.h>
10#include <linux/platform_device.h> 10#include <linux/platform_device.h>
11#include <linux/pm.h>
12#include <linux/serial_core.h>
13#include <linux/slab.h>
11 14
12#include <mach/hardware.h>
13#include <asm/mach-types.h> 15#include <asm/mach-types.h>
14#include <asm/irq.h>
15#include <asm/mach/map.h> 16#include <asm/mach/map.h>
16#include <asm/mach/irq.h>
17#include <asm/mach/serial_sa1100.h> 17#include <asm/mach/serial_sa1100.h>
18#include <mach/assabet.h>
19#include <mach/neponset.h>
20#include <asm/hardware/sa1111.h> 18#include <asm/hardware/sa1111.h>
21#include <asm/sizes.h> 19#include <asm/sizes.h>
22 20
23/* 21#include <mach/hardware.h>
24 * Install handler for Neponset IRQ. Note that we have to loop here 22#include <mach/assabet.h>
25 * since the ETHERNET and USAR IRQs are level based, and we need to 23#include <mach/neponset.h>
26 * ensure that the IRQ signal is deasserted before returning. This 24#include <mach/irqs.h>
27 * is rather unfortunate. 25
28 */ 26#define NEP_IRQ_SMC91X 0
29static void 27#define NEP_IRQ_USAR 1
30neponset_irq_handler(unsigned int irq, struct irq_desc *desc) 28#define NEP_IRQ_SA1111 2
31{ 29#define NEP_IRQ_NR 3
32 unsigned int irr; 30
33 31#define WHOAMI 0x00
34 while (1) { 32#define LEDS 0x10
35 /* 33#define SWPK 0x20
36 * Acknowledge the parent IRQ. 34#define IRR 0x24
37 */ 35#define KP_Y_IN 0x80
38 desc->irq_data.chip->irq_ack(&desc->irq_data); 36#define KP_X_OUT 0x90
39 37#define NCR_0 0xa0
40 /* 38#define MDM_CTL_0 0xb0
41 * Read the interrupt reason register. Let's have all 39#define MDM_CTL_1 0xb4
42 * active IRQ bits high. Note: there is a typo in the 40#define AUD_CTL 0xc0
43 * Neponset user's guide for the SA1111 IRR level. 41
44 */ 42#define IRR_ETHERNET (1 << 0)
45 irr = IRR ^ (IRR_ETHERNET | IRR_USAR); 43#define IRR_USAR (1 << 1)
46 44#define IRR_SA1111 (1 << 2)
47 if ((irr & (IRR_ETHERNET | IRR_USAR | IRR_SA1111)) == 0) 45
48 break; 46#define MDM_CTL0_RTS1 (1 << 0)
49 47#define MDM_CTL0_DTR1 (1 << 1)
50 /* 48#define MDM_CTL0_RTS2 (1 << 2)
51 * Since there is no individual mask, we have to 49#define MDM_CTL0_DTR2 (1 << 3)
52 * mask the parent IRQ. This is safe, since we'll 50
53 * recheck the register for any pending IRQs. 51#define MDM_CTL1_CTS1 (1 << 0)
54 */ 52#define MDM_CTL1_DSR1 (1 << 1)
55 if (irr & (IRR_ETHERNET | IRR_USAR)) { 53#define MDM_CTL1_DCD1 (1 << 2)
56 desc->irq_data.chip->irq_mask(&desc->irq_data); 54#define MDM_CTL1_CTS2 (1 << 3)
57 55#define MDM_CTL1_DSR2 (1 << 4)
58 /* 56#define MDM_CTL1_DCD2 (1 << 5)
59 * Ack the interrupt now to prevent re-entering 57
60 * this neponset handler. Again, this is safe 58#define AUD_SEL_1341 (1 << 0)
61 * since we'll check the IRR register prior to 59#define AUD_MUTE_1341 (1 << 1)
62 * leaving.
63 */
64 desc->irq_data.chip->irq_ack(&desc->irq_data);
65 60
66 if (irr & IRR_ETHERNET) { 61extern void sa1110_mb_disable(void);
67 generic_handle_irq(IRQ_NEPONSET_SMC9196);
68 }
69 62
70 if (irr & IRR_USAR) { 63struct neponset_drvdata {
71 generic_handle_irq(IRQ_NEPONSET_USAR); 64 void __iomem *base;
72 } 65 struct platform_device *sa1111;
66 struct platform_device *smc91x;
67 unsigned irq_base;
68#ifdef CONFIG_PM_SLEEP
69 u32 ncr0;
70 u32 mdm_ctl_0;
71#endif
72};
73 73
74 desc->irq_data.chip->irq_unmask(&desc->irq_data); 74static void __iomem *nep_base;
75 }
76 75
77 if (irr & IRR_SA1111) { 76void neponset_ncr_frob(unsigned int mask, unsigned int val)
78 generic_handle_irq(IRQ_NEPONSET_SA1111); 77{
79 } 78 void __iomem *base = nep_base;
79
80 if (base) {
81 unsigned long flags;
82 unsigned v;
83
84 local_irq_save(flags);
85 v = readb_relaxed(base + NCR_0);
86 writeb_relaxed((v & ~mask) | val, base + NCR_0);
87 local_irq_restore(flags);
88 } else {
89 WARN(1, "nep_base unset\n");
80 } 90 }
81} 91}
82 92
83static void neponset_set_mctrl(struct uart_port *port, u_int mctrl) 93static void neponset_set_mctrl(struct uart_port *port, u_int mctrl)
84{ 94{
85 u_int mdm_ctl0 = MDM_CTL_0; 95 void __iomem *base = nep_base;
96 u_int mdm_ctl0;
86 97
98 if (!base)
99 return;
100
101 mdm_ctl0 = readb_relaxed(base + MDM_CTL_0);
87 if (port->mapbase == _Ser1UTCR0) { 102 if (port->mapbase == _Ser1UTCR0) {
88 if (mctrl & TIOCM_RTS) 103 if (mctrl & TIOCM_RTS)
89 mdm_ctl0 &= ~MDM_CTL0_RTS2; 104 mdm_ctl0 &= ~MDM_CTL0_RTS2;
@@ -106,14 +121,19 @@ static void neponset_set_mctrl(struct uart_port *port, u_int mctrl)
106 mdm_ctl0 |= MDM_CTL0_DTR1; 121 mdm_ctl0 |= MDM_CTL0_DTR1;
107 } 122 }
108 123
109 MDM_CTL_0 = mdm_ctl0; 124 writeb_relaxed(mdm_ctl0, base + MDM_CTL_0);
110} 125}
111 126
112static u_int neponset_get_mctrl(struct uart_port *port) 127static u_int neponset_get_mctrl(struct uart_port *port)
113{ 128{
129 void __iomem *base = nep_base;
114 u_int ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR; 130 u_int ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR;
115 u_int mdm_ctl1 = MDM_CTL_1; 131 u_int mdm_ctl1;
132
133 if (!base)
134 return ret;
116 135
136 mdm_ctl1 = readb_relaxed(base + MDM_CTL_1);
117 if (port->mapbase == _Ser1UTCR0) { 137 if (port->mapbase == _Ser1UTCR0) {
118 if (mdm_ctl1 & MDM_CTL1_DCD2) 138 if (mdm_ctl1 & MDM_CTL1_DCD2)
119 ret &= ~TIOCM_CD; 139 ret &= ~TIOCM_CD;
@@ -138,209 +158,278 @@ static struct sa1100_port_fns neponset_port_fns __devinitdata = {
138 .get_mctrl = neponset_get_mctrl, 158 .get_mctrl = neponset_get_mctrl,
139}; 159};
140 160
141static int __devinit neponset_probe(struct platform_device *dev) 161/*
162 * Install handler for Neponset IRQ. Note that we have to loop here
163 * since the ETHERNET and USAR IRQs are level based, and we need to
164 * ensure that the IRQ signal is deasserted before returning. This
165 * is rather unfortunate.
166 */
167static void neponset_irq_handler(unsigned int irq, struct irq_desc *desc)
142{ 168{
143 sa1100_register_uart_fns(&neponset_port_fns); 169 struct neponset_drvdata *d = irq_desc_get_handler_data(desc);
170 unsigned int irr;
144 171
145 /* 172 while (1) {
146 * Install handler for GPIO25. 173 /*
147 */ 174 * Acknowledge the parent IRQ.
148 irq_set_irq_type(IRQ_GPIO25, IRQ_TYPE_EDGE_RISING); 175 */
149 irq_set_chained_handler(IRQ_GPIO25, neponset_irq_handler); 176 desc->irq_data.chip->irq_ack(&desc->irq_data);
150 177
151 /* 178 /*
152 * We would set IRQ_GPIO25 to be a wake-up IRQ, but 179 * Read the interrupt reason register. Let's have all
153 * unfortunately something on the Neponset activates 180 * active IRQ bits high. Note: there is a typo in the
154 * this IRQ on sleep (ethernet?) 181 * Neponset user's guide for the SA1111 IRR level.
155 */ 182 */
156#if 0 183 irr = readb_relaxed(d->base + IRR);
157 enable_irq_wake(IRQ_GPIO25); 184 irr ^= IRR_ETHERNET | IRR_USAR;
158#endif
159 185
160 /* 186 if ((irr & (IRR_ETHERNET | IRR_USAR | IRR_SA1111)) == 0)
161 * Setup other Neponset IRQs. SA1111 will be done by the 187 break;
162 * generic SA1111 code.
163 */
164 irq_set_handler(IRQ_NEPONSET_SMC9196, handle_simple_irq);
165 set_irq_flags(IRQ_NEPONSET_SMC9196, IRQF_VALID | IRQF_PROBE);
166 irq_set_handler(IRQ_NEPONSET_USAR, handle_simple_irq);
167 set_irq_flags(IRQ_NEPONSET_USAR, IRQF_VALID | IRQF_PROBE);
168 188
169 /* 189 /*
170 * Disable GPIO 0/1 drivers so the buttons work on the module. 190 * Since there is no individual mask, we have to
171 */ 191 * mask the parent IRQ. This is safe, since we'll
172 NCR_0 = NCR_GP01_OFF; 192 * recheck the register for any pending IRQs.
193 */
194 if (irr & (IRR_ETHERNET | IRR_USAR)) {
195 desc->irq_data.chip->irq_mask(&desc->irq_data);
173 196
174 return 0; 197 /*
175} 198 * Ack the interrupt now to prevent re-entering
199 * this neponset handler. Again, this is safe
200 * since we'll check the IRR register prior to
201 * leaving.
202 */
203 desc->irq_data.chip->irq_ack(&desc->irq_data);
176 204
177#ifdef CONFIG_PM 205 if (irr & IRR_ETHERNET)
206 generic_handle_irq(d->irq_base + NEP_IRQ_SMC91X);
178 207
179/* 208 if (irr & IRR_USAR)
180 * LDM power management. 209 generic_handle_irq(d->irq_base + NEP_IRQ_USAR);
181 */
182static unsigned int neponset_saved_state;
183 210
184static int neponset_suspend(struct platform_device *dev, pm_message_t state) 211 desc->irq_data.chip->irq_unmask(&desc->irq_data);
185{ 212 }
186 /*
187 * Save state.
188 */
189 neponset_saved_state = NCR_0;
190 213
191 return 0; 214 if (irr & IRR_SA1111)
215 generic_handle_irq(d->irq_base + NEP_IRQ_SA1111);
216 }
192} 217}
193 218
194static int neponset_resume(struct platform_device *dev) 219/* Yes, we really do not have any kind of masking or unmasking */
220static void nochip_noop(struct irq_data *irq)
195{ 221{
196 NCR_0 = neponset_saved_state;
197
198 return 0;
199} 222}
200 223
201#else 224static struct irq_chip nochip = {
202#define neponset_suspend NULL 225 .name = "neponset",
203#define neponset_resume NULL 226 .irq_ack = nochip_noop,
204#endif 227 .irq_mask = nochip_noop,
205 228 .irq_unmask = nochip_noop,
206static struct platform_driver neponset_device_driver = {
207 .probe = neponset_probe,
208 .suspend = neponset_suspend,
209 .resume = neponset_resume,
210 .driver = {
211 .name = "neponset",
212 },
213};
214
215static struct resource neponset_resources[] = {
216 [0] = {
217 .start = 0x10000000,
218 .end = 0x17ffffff,
219 .flags = IORESOURCE_MEM,
220 },
221};
222
223static struct platform_device neponset_device = {
224 .name = "neponset",
225 .id = 0,
226 .num_resources = ARRAY_SIZE(neponset_resources),
227 .resource = neponset_resources,
228};
229
230static struct resource sa1111_resources[] = {
231 [0] = {
232 .start = 0x40000000,
233 .end = 0x40001fff,
234 .flags = IORESOURCE_MEM,
235 },
236 [1] = {
237 .start = IRQ_NEPONSET_SA1111,
238 .end = IRQ_NEPONSET_SA1111,
239 .flags = IORESOURCE_IRQ,
240 },
241}; 229};
242 230
243static struct sa1111_platform_data sa1111_info = { 231static struct sa1111_platform_data sa1111_info = {
244 .irq_base = IRQ_BOARD_END, 232 .disable_devs = SA1111_DEVID_PS2_MSE,
245}; 233};
246 234
247static u64 sa1111_dmamask = 0xffffffffUL; 235static int __devinit neponset_probe(struct platform_device *dev)
236{
237 struct neponset_drvdata *d;
238 struct resource *nep_res, *sa1111_res, *smc91x_res;
239 struct resource sa1111_resources[] = {
240 DEFINE_RES_MEM(0x40000000, SZ_8K),
241 { .flags = IORESOURCE_IRQ },
242 };
243 struct platform_device_info sa1111_devinfo = {
244 .parent = &dev->dev,
245 .name = "sa1111",
246 .id = 0,
247 .res = sa1111_resources,
248 .num_res = ARRAY_SIZE(sa1111_resources),
249 .data = &sa1111_info,
250 .size_data = sizeof(sa1111_info),
251 .dma_mask = 0xffffffffUL,
252 };
253 struct resource smc91x_resources[] = {
254 DEFINE_RES_MEM_NAMED(SA1100_CS3_PHYS,
255 0x02000000, "smc91x-regs"),
256 DEFINE_RES_MEM_NAMED(SA1100_CS3_PHYS + 0x02000000,
257 0x02000000, "smc91x-attrib"),
258 { .flags = IORESOURCE_IRQ },
259 };
260 struct platform_device_info smc91x_devinfo = {
261 .parent = &dev->dev,
262 .name = "smc91x",
263 .id = 0,
264 .res = smc91x_resources,
265 .num_res = ARRAY_SIZE(smc91x_resources),
266 };
267 int ret, irq;
268
269 if (nep_base)
270 return -EBUSY;
271
272 irq = ret = platform_get_irq(dev, 0);
273 if (ret < 0)
274 goto err_alloc;
275
276 nep_res = platform_get_resource(dev, IORESOURCE_MEM, 0);
277 smc91x_res = platform_get_resource(dev, IORESOURCE_MEM, 1);
278 sa1111_res = platform_get_resource(dev, IORESOURCE_MEM, 2);
279 if (!nep_res || !smc91x_res || !sa1111_res) {
280 ret = -ENXIO;
281 goto err_alloc;
282 }
248 283
249static struct platform_device sa1111_device = { 284 d = kzalloc(sizeof(*d), GFP_KERNEL);
250 .name = "sa1111", 285 if (!d) {
251 .id = 0, 286 ret = -ENOMEM;
252 .dev = { 287 goto err_alloc;
253 .dma_mask = &sa1111_dmamask, 288 }
254 .coherent_dma_mask = 0xffffffff,
255 .platform_data = &sa1111_info,
256 },
257 .num_resources = ARRAY_SIZE(sa1111_resources),
258 .resource = sa1111_resources,
259};
260 289
261static struct resource smc91x_resources[] = { 290 d->base = ioremap(nep_res->start, SZ_4K);
262 [0] = { 291 if (!d->base) {
263 .name = "smc91x-regs", 292 ret = -ENOMEM;
264 .start = SA1100_CS3_PHYS, 293 goto err_ioremap;
265 .end = SA1100_CS3_PHYS + 0x01ffffff, 294 }
266 .flags = IORESOURCE_MEM,
267 },
268 [1] = {
269 .start = IRQ_NEPONSET_SMC9196,
270 .end = IRQ_NEPONSET_SMC9196,
271 .flags = IORESOURCE_IRQ,
272 },
273 [2] = {
274 .name = "smc91x-attrib",
275 .start = SA1100_CS3_PHYS + 0x02000000,
276 .end = SA1100_CS3_PHYS + 0x03ffffff,
277 .flags = IORESOURCE_MEM,
278 },
279};
280 295
281static struct platform_device smc91x_device = { 296 if (readb_relaxed(d->base + WHOAMI) != 0x11) {
282 .name = "smc91x", 297 dev_warn(&dev->dev, "Neponset board detected, but wrong ID: %02x\n",
283 .id = 0, 298 readb_relaxed(d->base + WHOAMI));
284 .num_resources = ARRAY_SIZE(smc91x_resources), 299 ret = -ENODEV;
285 .resource = smc91x_resources, 300 goto err_id;
286}; 301 }
287 302
288static struct platform_device *devices[] __initdata = { 303 ret = irq_alloc_descs(-1, IRQ_BOARD_START, NEP_IRQ_NR, -1);
289 &neponset_device, 304 if (ret <= 0) {
290 &sa1111_device, 305 dev_err(&dev->dev, "unable to allocate %u irqs: %d\n",
291 &smc91x_device, 306 NEP_IRQ_NR, ret);
292}; 307 if (ret == 0)
308 ret = -ENOMEM;
309 goto err_irq_alloc;
310 }
293 311
294extern void sa1110_mb_disable(void); 312 d->irq_base = ret;
295 313
296static int __init neponset_init(void) 314 irq_set_chip_and_handler(d->irq_base + NEP_IRQ_SMC91X, &nochip,
297{ 315 handle_simple_irq);
298 platform_driver_register(&neponset_device_driver); 316 set_irq_flags(d->irq_base + NEP_IRQ_SMC91X, IRQF_VALID | IRQF_PROBE);
317 irq_set_chip_and_handler(d->irq_base + NEP_IRQ_USAR, &nochip,
318 handle_simple_irq);
319 set_irq_flags(d->irq_base + NEP_IRQ_USAR, IRQF_VALID | IRQF_PROBE);
320 irq_set_chip(d->irq_base + NEP_IRQ_SA1111, &nochip);
299 321
300 /* 322 irq_set_irq_type(irq, IRQ_TYPE_EDGE_RISING);
301 * The Neponset is only present on the Assabet machine type. 323 irq_set_handler_data(irq, d);
302 */ 324 irq_set_chained_handler(irq, neponset_irq_handler);
303 if (!machine_is_assabet())
304 return -ENODEV;
305 325
306 /* 326 /*
307 * Ensure that the memory bus request/grant signals are setup, 327 * We would set IRQ_GPIO25 to be a wake-up IRQ, but unfortunately
308 * and the grant is held in its inactive state, whether or not 328 * something on the Neponset activates this IRQ on sleep (eth?)
309 * we actually have a Neponset attached.
310 */ 329 */
330#if 0
331 enable_irq_wake(irq);
332#endif
333
334 dev_info(&dev->dev, "Neponset daughter board, providing IRQ%u-%u\n",
335 d->irq_base, d->irq_base + NEP_IRQ_NR - 1);
336 nep_base = d->base;
337
338 sa1100_register_uart_fns(&neponset_port_fns);
339
340 /* Ensure that the memory bus request/grant signals are setup */
311 sa1110_mb_disable(); 341 sa1110_mb_disable();
312 342
313 if (!machine_has_neponset()) { 343 /* Disable GPIO 0/1 drivers so the buttons work on the Assabet */
314 printk(KERN_DEBUG "Neponset expansion board not present\n"); 344 writeb_relaxed(NCR_GP01_OFF, d->base + NCR_0);
315 return -ENODEV;
316 }
317 345
318 if (WHOAMI != 0x11) { 346 sa1111_resources[0].parent = sa1111_res;
319 printk(KERN_WARNING "Neponset board detected, but " 347 sa1111_resources[1].start = d->irq_base + NEP_IRQ_SA1111;
320 "wrong ID: %02x\n", WHOAMI); 348 sa1111_resources[1].end = d->irq_base + NEP_IRQ_SA1111;
321 return -ENODEV; 349 d->sa1111 = platform_device_register_full(&sa1111_devinfo);
322 } 350
351 smc91x_resources[0].parent = smc91x_res;
352 smc91x_resources[1].parent = smc91x_res;
353 smc91x_resources[2].start = d->irq_base + NEP_IRQ_SMC91X;
354 smc91x_resources[2].end = d->irq_base + NEP_IRQ_SMC91X;
355 d->smc91x = platform_device_register_full(&smc91x_devinfo);
356
357 platform_set_drvdata(dev, d);
323 358
324 return platform_add_devices(devices, ARRAY_SIZE(devices)); 359 return 0;
360
361 err_irq_alloc:
362 err_id:
363 iounmap(d->base);
364 err_ioremap:
365 kfree(d);
366 err_alloc:
367 return ret;
325} 368}
326 369
327subsys_initcall(neponset_init); 370static int __devexit neponset_remove(struct platform_device *dev)
371{
372 struct neponset_drvdata *d = platform_get_drvdata(dev);
373 int irq = platform_get_irq(dev, 0);
374
375 if (!IS_ERR(d->sa1111))
376 platform_device_unregister(d->sa1111);
377 if (!IS_ERR(d->smc91x))
378 platform_device_unregister(d->smc91x);
379 irq_set_chained_handler(irq, NULL);
380 irq_free_descs(d->irq_base, NEP_IRQ_NR);
381 nep_base = NULL;
382 iounmap(d->base);
383 kfree(d);
328 384
329static struct map_desc neponset_io_desc[] __initdata = { 385 return 0;
330 { /* System Registers */ 386}
331 .virtual = 0xf3000000, 387
332 .pfn = __phys_to_pfn(0x10000000), 388#ifdef CONFIG_PM_SLEEP
333 .length = SZ_1M, 389static int neponset_suspend(struct device *dev)
334 .type = MT_DEVICE 390{
335 }, { /* SA-1111 */ 391 struct neponset_drvdata *d = dev_get_drvdata(dev);
336 .virtual = 0xf4000000, 392
337 .pfn = __phys_to_pfn(0x40000000), 393 d->ncr0 = readb_relaxed(d->base + NCR_0);
338 .length = SZ_1M, 394 d->mdm_ctl_0 = readb_relaxed(d->base + MDM_CTL_0);
339 .type = MT_DEVICE 395
340 } 396 return 0;
397}
398
399static int neponset_resume(struct device *dev)
400{
401 struct neponset_drvdata *d = dev_get_drvdata(dev);
402
403 writeb_relaxed(d->ncr0, d->base + NCR_0);
404 writeb_relaxed(d->mdm_ctl_0, d->base + MDM_CTL_0);
405
406 return 0;
407}
408
409static const struct dev_pm_ops neponset_pm_ops = {
410 .suspend_noirq = neponset_suspend,
411 .resume_noirq = neponset_resume,
412 .freeze_noirq = neponset_suspend,
413 .restore_noirq = neponset_resume,
414};
415#define PM_OPS &neponset_pm_ops
416#else
417#define PM_OPS NULL
418#endif
419
420static struct platform_driver neponset_device_driver = {
421 .probe = neponset_probe,
422 .remove = __devexit_p(neponset_remove),
423 .driver = {
424 .name = "neponset",
425 .owner = THIS_MODULE,
426 .pm = PM_OPS,
427 },
341}; 428};
342 429
343void __init neponset_map_io(void) 430static int __init neponset_init(void)
344{ 431{
345 iotable_init(neponset_io_desc, ARRAY_SIZE(neponset_io_desc)); 432 return platform_driver_register(&neponset_device_driver);
346} 433}
434
435subsys_initcall(neponset_init);
diff --git a/arch/arm/mach-sa1100/pci-nanoengine.c b/arch/arm/mach-sa1100/pci-nanoengine.c
index 0d01ca78892..b49108b890a 100644
--- a/arch/arm/mach-sa1100/pci-nanoengine.c
+++ b/arch/arm/mach-sa1100/pci-nanoengine.c
@@ -135,12 +135,8 @@ struct pci_bus * __init pci_nanoengine_scan_bus(int nr, struct pci_sys_data *sys
135 &sys->resources); 135 &sys->resources);
136} 136}
137 137
138static struct resource pci_io_ports = { 138static struct resource pci_io_ports =
139 .name = "PCI IO", 139 DEFINE_RES_IO_NAMED(0x400, 0x400, "PCI IO");
140 .start = 0x400,
141 .end = 0x7FF,
142 .flags = IORESOURCE_IO,
143};
144 140
145static struct resource pci_non_prefetchable_memory = { 141static struct resource pci_non_prefetchable_memory = {
146 .name = "PCI non-prefetchable", 142 .name = "PCI non-prefetchable",
@@ -244,9 +240,11 @@ static int __init pci_nanoengine_setup_resources(struct pci_sys_data *sys)
244 printk(KERN_ERR "PCI: unable to allocate prefetchable\n"); 240 printk(KERN_ERR "PCI: unable to allocate prefetchable\n");
245 return -EBUSY; 241 return -EBUSY;
246 } 242 }
247 pci_add_resource(&sys->resources, &pci_io_ports); 243 pci_add_resource_offset(&sys->resources, &pci_io_ports, sys->io_offset);
248 pci_add_resource(&sys->resources, &pci_non_prefetchable_memory); 244 pci_add_resource_offset(&sys->resources,
249 pci_add_resource(&sys->resources, &pci_prefetchable_memory); 245 &pci_non_prefetchable_memory, sys->mem_offset);
246 pci_add_resource_offset(&sys->resources,
247 &pci_prefetchable_memory, sys->mem_offset);
250 248
251 return 1; 249 return 1;
252} 250}
diff --git a/arch/arm/mach-sa1100/pleb.c b/arch/arm/mach-sa1100/pleb.c
index 9307df05353..1602575a0d5 100644
--- a/arch/arm/mach-sa1100/pleb.c
+++ b/arch/arm/mach-sa1100/pleb.c
@@ -37,17 +37,9 @@
37#define IRQ_GPIO_ETH0_IRQ IRQ_GPIO21 37#define IRQ_GPIO_ETH0_IRQ IRQ_GPIO21
38 38
39static struct resource smc91x_resources[] = { 39static struct resource smc91x_resources[] = {
40 [0] = { 40 [0] = DEFINE_RES_MEM(PLEB_ETH0_P, 0x04000000),
41 .start = PLEB_ETH0_P,
42 .end = PLEB_ETH0_P | 0x03ffffff,
43 .flags = IORESOURCE_MEM,
44 },
45#if 0 /* Autoprobe instead, to get rising/falling edge characteristic right */ 41#if 0 /* Autoprobe instead, to get rising/falling edge characteristic right */
46 [1] = { 42 [1] = DEFINE_RES_IRQ(IRQ_GPIO_ETH0_IRQ),
47 .start = IRQ_GPIO_ETH0_IRQ,
48 .end = IRQ_GPIO_ETH0_IRQ,
49 .flags = IORESOURCE_IRQ,
50 },
51#endif 43#endif
52}; 44};
53 45
@@ -70,16 +62,8 @@ static struct platform_device *devices[] __initdata = {
70 * the two SA1100 lowest chip select outputs. 62 * the two SA1100 lowest chip select outputs.
71 */ 63 */
72static struct resource pleb_flash_resources[] = { 64static struct resource pleb_flash_resources[] = {
73 [0] = { 65 [0] = DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_8M),
74 .start = SA1100_CS0_PHYS, 66 [1] = DEFINE_RES_MEM(SA1100_CS1_PHYS, SZ_8M),
75 .end = SA1100_CS0_PHYS + SZ_8M - 1,
76 .flags = IORESOURCE_MEM,
77 },
78 [1] = {
79 .start = SA1100_CS1_PHYS,
80 .end = SA1100_CS1_PHYS + SZ_8M - 1,
81 .flags = IORESOURCE_MEM,
82 }
83}; 67};
84 68
85 69
@@ -147,6 +131,7 @@ static void __init pleb_map_io(void)
147 131
148MACHINE_START(PLEB, "PLEB") 132MACHINE_START(PLEB, "PLEB")
149 .map_io = pleb_map_io, 133 .map_io = pleb_map_io,
134 .nr_irqs = SA1100_NR_IRQS,
150 .init_irq = sa1100_init_irq, 135 .init_irq = sa1100_init_irq,
151 .timer = &sa1100_timer, 136 .timer = &sa1100_timer,
152 .init_machine = pleb_init, 137 .init_machine = pleb_init,
diff --git a/arch/arm/mach-sa1100/shannon.c b/arch/arm/mach-sa1100/shannon.c
index 318b2b766a0..ca8bf59b904 100644
--- a/arch/arm/mach-sa1100/shannon.c
+++ b/arch/arm/mach-sa1100/shannon.c
@@ -9,6 +9,8 @@
9#include <linux/mtd/mtd.h> 9#include <linux/mtd/mtd.h>
10#include <linux/mtd/partitions.h> 10#include <linux/mtd/partitions.h>
11 11
12#include <video/sa1100fb.h>
13
12#include <mach/hardware.h> 14#include <mach/hardware.h>
13#include <asm/mach-types.h> 15#include <asm/mach-types.h>
14#include <asm/setup.h> 16#include <asm/setup.h>
@@ -19,6 +21,7 @@
19#include <asm/mach/serial_sa1100.h> 21#include <asm/mach/serial_sa1100.h>
20#include <mach/mcp.h> 22#include <mach/mcp.h>
21#include <mach/shannon.h> 23#include <mach/shannon.h>
24#include <mach/irqs.h>
22 25
23#include "generic.h" 26#include "generic.h"
24 27
@@ -46,19 +49,32 @@ static struct flash_platform_data shannon_flash_data = {
46 .nr_parts = ARRAY_SIZE(shannon_partitions), 49 .nr_parts = ARRAY_SIZE(shannon_partitions),
47}; 50};
48 51
49static struct resource shannon_flash_resource = { 52static struct resource shannon_flash_resource =
50 .start = SA1100_CS0_PHYS, 53 DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_4M);
51 .end = SA1100_CS0_PHYS + SZ_4M - 1,
52 .flags = IORESOURCE_MEM,
53};
54 54
55static struct mcp_plat_data shannon_mcp_data = { 55static struct mcp_plat_data shannon_mcp_data = {
56 .mccr0 = MCCR0_ADM, 56 .mccr0 = MCCR0_ADM,
57 .sclk_rate = 11981000, 57 .sclk_rate = 11981000,
58}; 58};
59 59
60static struct sa1100fb_mach_info shannon_lcd_info = {
61 .pixclock = 152500, .bpp = 8,
62 .xres = 640, .yres = 480,
63
64 .hsync_len = 4, .vsync_len = 3,
65 .left_margin = 2, .upper_margin = 0,
66 .right_margin = 1, .lower_margin = 0,
67
68 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
69
70 .lccr0 = LCCR0_Color | LCCR0_Dual | LCCR0_Pas,
71 .lccr3 = LCCR3_ACBsDiv(512),
72};
73
60static void __init shannon_init(void) 74static void __init shannon_init(void)
61{ 75{
76 sa11x0_ppc_configure_mcp();
77 sa11x0_register_lcd(&shannon_lcd_info);
62 sa11x0_register_mtd(&shannon_flash_data, &shannon_flash_resource, 1); 78 sa11x0_register_mtd(&shannon_flash_data, &shannon_flash_resource, 1);
63 sa11x0_register_mcp(&shannon_mcp_data); 79 sa11x0_register_mcp(&shannon_mcp_data);
64} 80}
@@ -84,6 +100,7 @@ static void __init shannon_map_io(void)
84MACHINE_START(SHANNON, "Shannon (AKA: Tuxscreen)") 100MACHINE_START(SHANNON, "Shannon (AKA: Tuxscreen)")
85 .atag_offset = 0x100, 101 .atag_offset = 0x100,
86 .map_io = shannon_map_io, 102 .map_io = shannon_map_io,
103 .nr_irqs = SA1100_NR_IRQS,
87 .init_irq = sa1100_init_irq, 104 .init_irq = sa1100_init_irq,
88 .timer = &sa1100_timer, 105 .timer = &sa1100_timer,
89 .init_machine = shannon_init, 106 .init_machine = shannon_init,
diff --git a/arch/arm/mach-sa1100/simpad.c b/arch/arm/mach-sa1100/simpad.c
index e17c04d6e32..3efae03cb3d 100644
--- a/arch/arm/mach-sa1100/simpad.c
+++ b/arch/arm/mach-sa1100/simpad.c
@@ -7,15 +7,15 @@
7#include <linux/kernel.h> 7#include <linux/kernel.h>
8#include <linux/tty.h> 8#include <linux/tty.h>
9#include <linux/proc_fs.h> 9#include <linux/proc_fs.h>
10#include <linux/string.h> 10#include <linux/string.h>
11#include <linux/pm.h> 11#include <linux/pm.h>
12#include <linux/platform_device.h> 12#include <linux/platform_device.h>
13#include <linux/mfd/ucb1x00.h>
13#include <linux/mtd/mtd.h> 14#include <linux/mtd/mtd.h>
14#include <linux/mtd/partitions.h> 15#include <linux/mtd/partitions.h>
15#include <linux/io.h> 16#include <linux/io.h>
16#include <linux/gpio.h> 17#include <linux/gpio.h>
17 18
18#include <asm/irq.h>
19#include <mach/hardware.h> 19#include <mach/hardware.h>
20#include <asm/setup.h> 20#include <asm/setup.h>
21 21
@@ -26,6 +26,7 @@
26#include <asm/mach/serial_sa1100.h> 26#include <asm/mach/serial_sa1100.h>
27#include <mach/mcp.h> 27#include <mach/mcp.h>
28#include <mach/simpad.h> 28#include <mach/simpad.h>
29#include <mach/irqs.h>
29 30
30#include <linux/serial_core.h> 31#include <linux/serial_core.h>
31#include <linux/ioport.h> 32#include <linux/ioport.h>
@@ -176,21 +177,18 @@ static struct flash_platform_data simpad_flash_data = {
176 177
177 178
178static struct resource simpad_flash_resources [] = { 179static struct resource simpad_flash_resources [] = {
179 { 180 DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_16M),
180 .start = SA1100_CS0_PHYS, 181 DEFINE_RES_MEM(SA1100_CS1_PHYS, SZ_16M),
181 .end = SA1100_CS0_PHYS + SZ_16M -1, 182};
182 .flags = IORESOURCE_MEM, 183
183 }, { 184static struct ucb1x00_plat_data simpad_ucb1x00_data = {
184 .start = SA1100_CS1_PHYS, 185 .gpio_base = SIMPAD_UCB1X00_GPIO_BASE,
185 .end = SA1100_CS1_PHYS + SZ_16M -1,
186 .flags = IORESOURCE_MEM,
187 }
188}; 186};
189 187
190static struct mcp_plat_data simpad_mcp_data = { 188static struct mcp_plat_data simpad_mcp_data = {
191 .mccr0 = MCCR0_ADM, 189 .mccr0 = MCCR0_ADM,
192 .sclk_rate = 11981000, 190 .sclk_rate = 11981000,
193 .gpio_base = SIMPAD_UCB1X00_GPIO_BASE, 191 .codec_pdata = &simpad_ucb1x00_data,
194}; 192};
195 193
196 194
@@ -376,6 +374,7 @@ static int __init simpad_init(void)
376 374
377 pm_power_off = simpad_power_off; 375 pm_power_off = simpad_power_off;
378 376
377 sa11x0_ppc_configure_mcp();
379 sa11x0_register_mtd(&simpad_flash_data, simpad_flash_resources, 378 sa11x0_register_mtd(&simpad_flash_data, simpad_flash_resources,
380 ARRAY_SIZE(simpad_flash_resources)); 379 ARRAY_SIZE(simpad_flash_resources));
381 sa11x0_register_mcp(&simpad_mcp_data); 380 sa11x0_register_mcp(&simpad_mcp_data);
@@ -394,6 +393,7 @@ MACHINE_START(SIMPAD, "Simpad")
394 /* Maintainer: Holger Freyther */ 393 /* Maintainer: Holger Freyther */
395 .atag_offset = 0x100, 394 .atag_offset = 0x100,
396 .map_io = simpad_map_io, 395 .map_io = simpad_map_io,
396 .nr_irqs = SA1100_NR_IRQS,
397 .init_irq = sa1100_init_irq, 397 .init_irq = sa1100_init_irq,
398 .timer = &sa1100_timer, 398 .timer = &sa1100_timer,
399 .restart = sa11x0_restart, 399 .restart = sa11x0_restart,
diff --git a/arch/arm/mach-sa1100/sleep.S b/arch/arm/mach-sa1100/sleep.S
index e8223315b44..30cc6721665 100644
--- a/arch/arm/mach-sa1100/sleep.S
+++ b/arch/arm/mach-sa1100/sleep.S
@@ -26,27 +26,36 @@
26 * 26 *
27 * Causes sa11x0 to enter sleep state 27 * Causes sa11x0 to enter sleep state
28 * 28 *
29 * Must be aligned to a cacheline.
29 */ 30 */
30 31 .balign 32
31ENTRY(sa1100_finish_suspend) 32ENTRY(sa1100_finish_suspend)
32 @ disable clock switching 33 @ disable clock switching
33 mcr p15, 0, r1, c15, c2, 2 34 mcr p15, 0, r1, c15, c2, 2
34 35
35 @ Adjust memory timing before lowering CPU clock 36 ldr r6, =MDREFR
36 @ Clock speed adjustment without changing memory timing makes 37 ldr r4, [r6]
37 @ CPU hang in some cases 38 orr r4, r4, #MDREFR_K1DB2
38 ldr r0, =MDREFR 39 ldr r5, =PPCR
39 ldr r1, [r0] 40
40 orr r1, r1, #MDREFR_K1DB2 41 @ Pre-load __udelay into the I-cache
41 str r1, [r0] 42 mov r0, #1
43 bl __udelay
44 mov r0, r0
45
46 @ The following must all exist in a single cache line to
47 @ avoid accessing memory until this sequence is complete,
48 @ otherwise we occasionally hang.
49
50 @ Adjust memory timing before lowering CPU clock
51 str r4, [r6]
42 52
43 @ delay 90us and set CPU PLL to lowest speed 53 @ delay 90us and set CPU PLL to lowest speed
44 @ fixes resume problem on high speed SA1110 54 @ fixes resume problem on high speed SA1110
45 mov r0, #90 55 mov r0, #90
46 bl __udelay 56 bl __udelay
47 ldr r0, =PPCR
48 mov r1, #0 57 mov r1, #0
49 str r1, [r0] 58 str r1, [r5]
50 mov r0, #90 59 mov r0, #90
51 bl __udelay 60 bl __udelay
52 61
@@ -85,12 +94,10 @@ ENTRY(sa1100_finish_suspend)
85 bic r5, r5, #FMsk(MSC_RT) 94 bic r5, r5, #FMsk(MSC_RT)
86 bic r5, r5, #FMsk(MSC_RT)<<16 95 bic r5, r5, #FMsk(MSC_RT)<<16
87 96
88 ldr r6, =MDREFR
89
90 ldr r7, [r6] 97 ldr r7, [r6]
91bic r7, r7, #0x0000FF00 98 bic r7, r7, #0x0000FF00
92bic r7, r7, #0x000000F0 99 bic r7, r7, #0x000000F0
93orr r8, r7, #MDREFR_SLFRSH 100 orr r8, r7, #MDREFR_SLFRSH
94 101
95 ldr r9, =MDCNFG 102 ldr r9, =MDCNFG
96 ldr r10, [r9] 103 ldr r10, [r9]
diff --git a/arch/arm/mach-sa1100/ssp.c b/arch/arm/mach-sa1100/ssp.c
index b20ff93b84a..e22fca9ad5e 100644
--- a/arch/arm/mach-sa1100/ssp.c
+++ b/arch/arm/mach-sa1100/ssp.c
@@ -19,8 +19,8 @@
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/io.h> 20#include <linux/io.h>
21 21
22#include <asm/irq.h>
23#include <mach/hardware.h> 22#include <mach/hardware.h>
23#include <mach/irqs.h>
24#include <asm/hardware/ssp.h> 24#include <asm/hardware/ssp.h>
25 25
26#define TIMEOUT 100000 26#define TIMEOUT 100000
diff --git a/arch/arm/mach-sa1100/time.c b/arch/arm/mach-sa1100/time.c
index 69e33535dee..6af26e8d55e 100644
--- a/arch/arm/mach-sa1100/time.c
+++ b/arch/arm/mach-sa1100/time.c
@@ -18,6 +18,7 @@
18#include <asm/mach/time.h> 18#include <asm/mach/time.h>
19#include <asm/sched_clock.h> 19#include <asm/sched_clock.h>
20#include <mach/hardware.h> 20#include <mach/hardware.h>
21#include <mach/irqs.h>
21 22
22static u32 notrace sa1100_read_sched_clock(void) 23static u32 notrace sa1100_read_sched_clock(void)
23{ 24{
diff --git a/arch/arm/mach-shark/core.c b/arch/arm/mach-shark/core.c
index a851c254ad6..6a2a7f2c255 100644
--- a/arch/arm/mach-shark/core.c
+++ b/arch/arm/mach-shark/core.c
@@ -149,10 +149,16 @@ static struct sys_timer shark_timer = {
149 .init = shark_timer_init, 149 .init = shark_timer_init,
150}; 150};
151 151
152static void shark_init_early(void)
153{
154 disable_hlt();
155}
156
152MACHINE_START(SHARK, "Shark") 157MACHINE_START(SHARK, "Shark")
153 /* Maintainer: Alexander Schulz */ 158 /* Maintainer: Alexander Schulz */
154 .atag_offset = 0x3000, 159 .atag_offset = 0x3000,
155 .map_io = shark_map_io, 160 .map_io = shark_map_io,
161 .init_early = shark_init_early,
156 .init_irq = shark_init_irq, 162 .init_irq = shark_init_irq,
157 .timer = &shark_timer, 163 .timer = &shark_timer,
158 .dma_zone_size = SZ_4M, 164 .dma_zone_size = SZ_4M,
diff --git a/arch/arm/mach-shark/include/mach/entry-macro.S b/arch/arm/mach-shark/include/mach/entry-macro.S
index 0bb6cc626eb..5901b09fc96 100644
--- a/arch/arm/mach-shark/include/mach/entry-macro.S
+++ b/arch/arm/mach-shark/include/mach/entry-macro.S
@@ -7,16 +7,10 @@
7 * License version 2. This program is licensed "as is" without any 7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied. 8 * warranty of any kind, whether express or implied.
9 */ 9 */
10 .macro disable_fiq
11 .endm
12
13 .macro get_irqnr_preamble, base, tmp 10 .macro get_irqnr_preamble, base, tmp
14 mov \base, #0xe0000000 11 mov \base, #0xe0000000
15 .endm 12 .endm
16 13
17 .macro arch_ret_to_user, tmp1, tmp2
18 .endm
19
20 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp 14 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
21 15
22 mov \irqstat, #0x0C 16 mov \irqstat, #0x0C
diff --git a/arch/arm/mach-shark/include/mach/system.h b/arch/arm/mach-shark/include/mach/system.h
deleted file mode 100644
index 1b2f2c5050a..00000000000
--- a/arch/arm/mach-shark/include/mach/system.h
+++ /dev/null
@@ -1,13 +0,0 @@
1/*
2 * arch/arm/mach-shark/include/mach/system.h
3 *
4 * by Alexander Schulz
5 */
6#ifndef __ASM_ARCH_SYSTEM_H
7#define __ASM_ARCH_SYSTEM_H
8
9static inline void arch_idle(void)
10{
11}
12
13#endif
diff --git a/arch/arm/mach-shmobile/Makefile b/arch/arm/mach-shmobile/Makefile
index 7ad6954c46c..e7c2590b75d 100644
--- a/arch/arm/mach-shmobile/Makefile
+++ b/arch/arm/mach-shmobile/Makefile
@@ -16,7 +16,6 @@ obj-$(CONFIG_ARCH_R8A7779) += setup-r8a7779.o clock-r8a7779.o intc-r8a7779.o
16# SMP objects 16# SMP objects
17smp-y := platsmp.o headsmp.o 17smp-y := platsmp.o headsmp.o
18smp-$(CONFIG_HOTPLUG_CPU) += hotplug.o 18smp-$(CONFIG_HOTPLUG_CPU) += hotplug.o
19smp-$(CONFIG_LOCAL_TIMERS) += localtimer.o
20smp-$(CONFIG_ARCH_SH73A0) += smp-sh73a0.o 19smp-$(CONFIG_ARCH_SH73A0) += smp-sh73a0.o
21smp-$(CONFIG_ARCH_R8A7779) += smp-r8a7779.o 20smp-$(CONFIG_ARCH_R8A7779) += smp-r8a7779.o
22 21
diff --git a/arch/arm/mach-shmobile/board-ag5evm.c b/arch/arm/mach-shmobile/board-ag5evm.c
index 12c431f3443..f50d7c8b122 100644
--- a/arch/arm/mach-shmobile/board-ag5evm.c
+++ b/arch/arm/mach-shmobile/board-ag5evm.c
@@ -47,8 +47,6 @@
47#include <mach/common.h> 47#include <mach/common.h>
48#include <asm/mach-types.h> 48#include <asm/mach-types.h>
49#include <asm/mach/arch.h> 49#include <asm/mach/arch.h>
50#include <asm/mach/map.h>
51#include <asm/mach/time.h>
52#include <asm/hardware/gic.h> 50#include <asm/hardware/gic.h>
53#include <asm/hardware/cache-l2x0.h> 51#include <asm/hardware/cache-l2x0.h>
54#include <asm/traps.h> 52#include <asm/traps.h>
@@ -477,27 +475,6 @@ static struct platform_device *ag5evm_devices[] __initdata = {
477 &sdhi1_device, 475 &sdhi1_device,
478}; 476};
479 477
480static struct map_desc ag5evm_io_desc[] __initdata = {
481 /* create a 1:1 entity map for 0xe6xxxxxx
482 * used by CPGA, INTC and PFC.
483 */
484 {
485 .virtual = 0xe6000000,
486 .pfn = __phys_to_pfn(0xe6000000),
487 .length = 256 << 20,
488 .type = MT_DEVICE_NONSHARED
489 },
490};
491
492static void __init ag5evm_map_io(void)
493{
494 iotable_init(ag5evm_io_desc, ARRAY_SIZE(ag5evm_io_desc));
495
496 /* setup early devices and console here as well */
497 sh73a0_add_early_devices();
498 shmobile_setup_console();
499}
500
501static void __init ag5evm_init(void) 478static void __init ag5evm_init(void)
502{ 479{
503 sh73a0_pinmux_init(); 480 sh73a0_pinmux_init();
@@ -613,22 +590,12 @@ static void __init ag5evm_init(void)
613 platform_add_devices(ag5evm_devices, ARRAY_SIZE(ag5evm_devices)); 590 platform_add_devices(ag5evm_devices, ARRAY_SIZE(ag5evm_devices));
614} 591}
615 592
616static void __init ag5evm_timer_init(void)
617{
618 sh73a0_clock_init();
619 shmobile_timer.init();
620 return;
621}
622
623struct sys_timer ag5evm_timer = {
624 .init = ag5evm_timer_init,
625};
626
627MACHINE_START(AG5EVM, "ag5evm") 593MACHINE_START(AG5EVM, "ag5evm")
628 .map_io = ag5evm_map_io, 594 .map_io = sh73a0_map_io,
595 .init_early = sh73a0_add_early_devices,
629 .nr_irqs = NR_IRQS_LEGACY, 596 .nr_irqs = NR_IRQS_LEGACY,
630 .init_irq = sh73a0_init_irq, 597 .init_irq = sh73a0_init_irq,
631 .handle_irq = gic_handle_irq, 598 .handle_irq = gic_handle_irq,
632 .init_machine = ag5evm_init, 599 .init_machine = ag5evm_init,
633 .timer = &ag5evm_timer, 600 .timer = &shmobile_timer,
634MACHINE_END 601MACHINE_END
diff --git a/arch/arm/mach-shmobile/board-ap4evb.c b/arch/arm/mach-shmobile/board-ap4evb.c
index f90ba5b850a..b56dde2732b 100644
--- a/arch/arm/mach-shmobile/board-ap4evb.c
+++ b/arch/arm/mach-shmobile/board-ap4evb.c
@@ -61,8 +61,6 @@
61 61
62#include <asm/mach-types.h> 62#include <asm/mach-types.h>
63#include <asm/mach/arch.h> 63#include <asm/mach/arch.h>
64#include <asm/mach/map.h>
65#include <asm/mach/time.h>
66#include <asm/setup.h> 64#include <asm/setup.h>
67 65
68/* 66/*
@@ -1188,26 +1186,6 @@ static struct i2c_board_info i2c1_devices[] = {
1188 }, 1186 },
1189}; 1187};
1190 1188
1191static struct map_desc ap4evb_io_desc[] __initdata = {
1192 /* create a 1:1 entity map for 0xe6xxxxxx
1193 * used by CPGA, INTC and PFC.
1194 */
1195 {
1196 .virtual = 0xe6000000,
1197 .pfn = __phys_to_pfn(0xe6000000),
1198 .length = 256 << 20,
1199 .type = MT_DEVICE_NONSHARED
1200 },
1201};
1202
1203static void __init ap4evb_map_io(void)
1204{
1205 iotable_init(ap4evb_io_desc, ARRAY_SIZE(ap4evb_io_desc));
1206
1207 /* setup early devices and console here as well */
1208 sh7372_add_early_devices();
1209 shmobile_setup_console();
1210}
1211 1189
1212#define GPIO_PORT9CR 0xE6051009 1190#define GPIO_PORT9CR 0xE6051009
1213#define GPIO_PORT10CR 0xE605100A 1191#define GPIO_PORT10CR 0xE605100A
@@ -1217,6 +1195,9 @@ static void __init ap4evb_init(void)
1217 u32 srcr4; 1195 u32 srcr4;
1218 struct clk *clk; 1196 struct clk *clk;
1219 1197
1198 /* External clock source */
1199 clk_set_rate(&sh7372_dv_clki_clk, 27000000);
1200
1220 sh7372_pinmux_init(); 1201 sh7372_pinmux_init();
1221 1202
1222 /* enable SCIFA0 */ 1203 /* enable SCIFA0 */
@@ -1453,23 +1434,11 @@ static void __init ap4evb_init(void)
1453 pm_clk_add(&lcdc1_device.dev, "hdmi"); 1434 pm_clk_add(&lcdc1_device.dev, "hdmi");
1454} 1435}
1455 1436
1456static void __init ap4evb_timer_init(void)
1457{
1458 sh7372_clock_init();
1459 shmobile_timer.init();
1460
1461 /* External clock source */
1462 clk_set_rate(&sh7372_dv_clki_clk, 27000000);
1463}
1464
1465static struct sys_timer ap4evb_timer = {
1466 .init = ap4evb_timer_init,
1467};
1468
1469MACHINE_START(AP4EVB, "ap4evb") 1437MACHINE_START(AP4EVB, "ap4evb")
1470 .map_io = ap4evb_map_io, 1438 .map_io = sh7372_map_io,
1439 .init_early = sh7372_add_early_devices,
1471 .init_irq = sh7372_init_irq, 1440 .init_irq = sh7372_init_irq,
1472 .handle_irq = shmobile_handle_irq_intc, 1441 .handle_irq = shmobile_handle_irq_intc,
1473 .init_machine = ap4evb_init, 1442 .init_machine = ap4evb_init,
1474 .timer = &ap4evb_timer, 1443 .timer = &shmobile_timer,
1475MACHINE_END 1444MACHINE_END
diff --git a/arch/arm/mach-shmobile/board-bonito.c b/arch/arm/mach-shmobile/board-bonito.c
index c79baa9ef61..8b2124da245 100644
--- a/arch/arm/mach-shmobile/board-bonito.c
+++ b/arch/arm/mach-shmobile/board-bonito.c
@@ -328,28 +328,6 @@ static struct platform_device *bonito_base_devices[] __initdata = {
328 * map I/O 328 * map I/O
329 */ 329 */
330static struct map_desc bonito_io_desc[] __initdata = { 330static struct map_desc bonito_io_desc[] __initdata = {
331 /*
332 * for CPGA/INTC/PFC
333 * 0xe6000000-0xefffffff -> 0xe6000000-0xefffffff
334 */
335 {
336 .virtual = 0xe6000000,
337 .pfn = __phys_to_pfn(0xe6000000),
338 .length = 160 << 20,
339 .type = MT_DEVICE_NONSHARED
340 },
341#ifdef CONFIG_CACHE_L2X0
342 /*
343 * for l2x0_init()
344 * 0xf0100000-0xf0101000 -> 0xf0002000-0xf0003000
345 */
346 {
347 .virtual = 0xf0002000,
348 .pfn = __phys_to_pfn(0xf0100000),
349 .length = PAGE_SIZE,
350 .type = MT_DEVICE_NONSHARED
351 },
352#endif
353 /* 331 /*
354 * for FPGA (0x1800000-0x19ffffff) 332 * for FPGA (0x1800000-0x19ffffff)
355 * 0x18000000-0x18002000 -> 0xf0003000-0xf0005000 333 * 0x18000000-0x18002000 -> 0xf0003000-0xf0005000
@@ -364,11 +342,8 @@ static struct map_desc bonito_io_desc[] __initdata = {
364 342
365static void __init bonito_map_io(void) 343static void __init bonito_map_io(void)
366{ 344{
345 r8a7740_map_io();
367 iotable_init(bonito_io_desc, ARRAY_SIZE(bonito_io_desc)); 346 iotable_init(bonito_io_desc, ARRAY_SIZE(bonito_io_desc));
368
369 /* setup early devices and console here as well */
370 r8a7740_add_early_devices();
371 shmobile_setup_console();
372} 347}
373 348
374/* 349/*
@@ -492,7 +467,7 @@ static void __init bonito_init(void)
492 } 467 }
493} 468}
494 469
495static void __init bonito_timer_init(void) 470static void __init bonito_earlytimer_init(void)
496{ 471{
497 u16 val; 472 u16 val;
498 u8 md_ck = 0; 473 u8 md_ck = 0;
@@ -507,17 +482,22 @@ static void __init bonito_timer_init(void)
507 md_ck |= MD_CK0; 482 md_ck |= MD_CK0;
508 483
509 r8a7740_clock_init(md_ck); 484 r8a7740_clock_init(md_ck);
510 shmobile_timer.init(); 485 shmobile_earlytimer_init();
511} 486}
512 487
513struct sys_timer bonito_timer = { 488void __init bonito_add_early_devices(void)
514 .init = bonito_timer_init, 489{
515}; 490 r8a7740_add_early_devices();
491
492 /* override timer setup with board-specific code */
493 shmobile_timer.init = bonito_earlytimer_init;
494}
516 495
517MACHINE_START(BONITO, "bonito") 496MACHINE_START(BONITO, "bonito")
518 .map_io = bonito_map_io, 497 .map_io = bonito_map_io,
498 .init_early = bonito_add_early_devices,
519 .init_irq = r8a7740_init_irq, 499 .init_irq = r8a7740_init_irq,
520 .handle_irq = shmobile_handle_irq_intc, 500 .handle_irq = shmobile_handle_irq_intc,
521 .init_machine = bonito_init, 501 .init_machine = bonito_init,
522 .timer = &bonito_timer, 502 .timer = &shmobile_timer,
523MACHINE_END 503MACHINE_END
diff --git a/arch/arm/mach-shmobile/board-g3evm.c b/arch/arm/mach-shmobile/board-g3evm.c
index 72d557281b1..b627e89037f 100644
--- a/arch/arm/mach-shmobile/board-g3evm.c
+++ b/arch/arm/mach-shmobile/board-g3evm.c
@@ -37,8 +37,6 @@
37#include <mach/common.h> 37#include <mach/common.h>
38#include <asm/mach-types.h> 38#include <asm/mach-types.h>
39#include <asm/mach/arch.h> 39#include <asm/mach/arch.h>
40#include <asm/mach/map.h>
41#include <asm/mach/time.h>
42 40
43/* 41/*
44 * IrDA 42 * IrDA
@@ -246,27 +244,6 @@ static struct platform_device *g3evm_devices[] __initdata = {
246 &irda_device, 244 &irda_device,
247}; 245};
248 246
249static struct map_desc g3evm_io_desc[] __initdata = {
250 /* create a 1:1 entity map for 0xe6xxxxxx
251 * used by CPGA, INTC and PFC.
252 */
253 {
254 .virtual = 0xe6000000,
255 .pfn = __phys_to_pfn(0xe6000000),
256 .length = 256 << 20,
257 .type = MT_DEVICE_NONSHARED
258 },
259};
260
261static void __init g3evm_map_io(void)
262{
263 iotable_init(g3evm_io_desc, ARRAY_SIZE(g3evm_io_desc));
264
265 /* setup early devices and console here as well */
266 sh7367_add_early_devices();
267 shmobile_setup_console();
268}
269
270static void __init g3evm_init(void) 247static void __init g3evm_init(void)
271{ 248{
272 sh7367_pinmux_init(); 249 sh7367_pinmux_init();
@@ -354,20 +331,11 @@ static void __init g3evm_init(void)
354 platform_add_devices(g3evm_devices, ARRAY_SIZE(g3evm_devices)); 331 platform_add_devices(g3evm_devices, ARRAY_SIZE(g3evm_devices));
355} 332}
356 333
357static void __init g3evm_timer_init(void)
358{
359 sh7367_clock_init();
360 shmobile_timer.init();
361}
362
363static struct sys_timer g3evm_timer = {
364 .init = g3evm_timer_init,
365};
366
367MACHINE_START(G3EVM, "g3evm") 334MACHINE_START(G3EVM, "g3evm")
368 .map_io = g3evm_map_io, 335 .map_io = sh7367_map_io,
336 .init_early = sh7367_add_early_devices,
369 .init_irq = sh7367_init_irq, 337 .init_irq = sh7367_init_irq,
370 .handle_irq = shmobile_handle_irq_intc, 338 .handle_irq = shmobile_handle_irq_intc,
371 .init_machine = g3evm_init, 339 .init_machine = g3evm_init,
372 .timer = &g3evm_timer, 340 .timer = &shmobile_timer,
373MACHINE_END 341MACHINE_END
diff --git a/arch/arm/mach-shmobile/board-g4evm.c b/arch/arm/mach-shmobile/board-g4evm.c
index 2220b885cff..46d757d2759 100644
--- a/arch/arm/mach-shmobile/board-g4evm.c
+++ b/arch/arm/mach-shmobile/board-g4evm.c
@@ -38,8 +38,6 @@
38#include <mach/common.h> 38#include <mach/common.h>
39#include <asm/mach-types.h> 39#include <asm/mach-types.h>
40#include <asm/mach/arch.h> 40#include <asm/mach/arch.h>
41#include <asm/mach/map.h>
42#include <asm/mach/time.h>
43 41
44/* 42/*
45 * SDHI 43 * SDHI
@@ -260,27 +258,6 @@ static struct platform_device *g4evm_devices[] __initdata = {
260 &sdhi1_device, 258 &sdhi1_device,
261}; 259};
262 260
263static struct map_desc g4evm_io_desc[] __initdata = {
264 /* create a 1:1 entity map for 0xe6xxxxxx
265 * used by CPGA, INTC and PFC.
266 */
267 {
268 .virtual = 0xe6000000,
269 .pfn = __phys_to_pfn(0xe6000000),
270 .length = 256 << 20,
271 .type = MT_DEVICE_NONSHARED
272 },
273};
274
275static void __init g4evm_map_io(void)
276{
277 iotable_init(g4evm_io_desc, ARRAY_SIZE(g4evm_io_desc));
278
279 /* setup early devices and console here as well */
280 sh7377_add_early_devices();
281 shmobile_setup_console();
282}
283
284#define GPIO_SDHID0_D0 0xe60520fc 261#define GPIO_SDHID0_D0 0xe60520fc
285#define GPIO_SDHID0_D1 0xe60520fd 262#define GPIO_SDHID0_D1 0xe60520fd
286#define GPIO_SDHID0_D2 0xe60520fe 263#define GPIO_SDHID0_D2 0xe60520fe
@@ -397,20 +374,11 @@ static void __init g4evm_init(void)
397 platform_add_devices(g4evm_devices, ARRAY_SIZE(g4evm_devices)); 374 platform_add_devices(g4evm_devices, ARRAY_SIZE(g4evm_devices));
398} 375}
399 376
400static void __init g4evm_timer_init(void)
401{
402 sh7377_clock_init();
403 shmobile_timer.init();
404}
405
406static struct sys_timer g4evm_timer = {
407 .init = g4evm_timer_init,
408};
409
410MACHINE_START(G4EVM, "g4evm") 377MACHINE_START(G4EVM, "g4evm")
411 .map_io = g4evm_map_io, 378 .map_io = sh7377_map_io,
379 .init_early = sh7377_add_early_devices,
412 .init_irq = sh7377_init_irq, 380 .init_irq = sh7377_init_irq,
413 .handle_irq = shmobile_handle_irq_intc, 381 .handle_irq = shmobile_handle_irq_intc,
414 .init_machine = g4evm_init, 382 .init_machine = g4evm_init,
415 .timer = &g4evm_timer, 383 .timer = &shmobile_timer,
416MACHINE_END 384MACHINE_END
diff --git a/arch/arm/mach-shmobile/board-kota2.c b/arch/arm/mach-shmobile/board-kota2.c
index c8e7ca23fc0..61c06729466 100644
--- a/arch/arm/mach-shmobile/board-kota2.c
+++ b/arch/arm/mach-shmobile/board-kota2.c
@@ -43,7 +43,6 @@
43#include <mach/common.h> 43#include <mach/common.h>
44#include <asm/mach-types.h> 44#include <asm/mach-types.h>
45#include <asm/mach/arch.h> 45#include <asm/mach/arch.h>
46#include <asm/mach/map.h>
47#include <asm/mach/time.h> 46#include <asm/mach/time.h>
48#include <asm/hardware/gic.h> 47#include <asm/hardware/gic.h>
49#include <asm/hardware/cache-l2x0.h> 48#include <asm/hardware/cache-l2x0.h>
@@ -409,27 +408,6 @@ static struct platform_device *kota2_devices[] __initdata = {
409 &sdhi1_device, 408 &sdhi1_device,
410}; 409};
411 410
412static struct map_desc kota2_io_desc[] __initdata = {
413 /* create a 1:1 entity map for 0xe6xxxxxx
414 * used by CPGA, INTC and PFC.
415 */
416 {
417 .virtual = 0xe6000000,
418 .pfn = __phys_to_pfn(0xe6000000),
419 .length = 256 << 20,
420 .type = MT_DEVICE_NONSHARED
421 },
422};
423
424static void __init kota2_map_io(void)
425{
426 iotable_init(kota2_io_desc, ARRAY_SIZE(kota2_io_desc));
427
428 /* setup early devices and console here as well */
429 sh73a0_add_early_devices();
430 shmobile_setup_console();
431}
432
433static void __init kota2_init(void) 411static void __init kota2_init(void)
434{ 412{
435 sh73a0_pinmux_init(); 413 sh73a0_pinmux_init();
@@ -535,22 +513,12 @@ static void __init kota2_init(void)
535 platform_add_devices(kota2_devices, ARRAY_SIZE(kota2_devices)); 513 platform_add_devices(kota2_devices, ARRAY_SIZE(kota2_devices));
536} 514}
537 515
538static void __init kota2_timer_init(void)
539{
540 sh73a0_clock_init();
541 shmobile_timer.init();
542 return;
543}
544
545struct sys_timer kota2_timer = {
546 .init = kota2_timer_init,
547};
548
549MACHINE_START(KOTA2, "kota2") 516MACHINE_START(KOTA2, "kota2")
550 .map_io = kota2_map_io, 517 .map_io = sh73a0_map_io,
518 .init_early = sh73a0_add_early_devices,
551 .nr_irqs = NR_IRQS_LEGACY, 519 .nr_irqs = NR_IRQS_LEGACY,
552 .init_irq = sh73a0_init_irq, 520 .init_irq = sh73a0_init_irq,
553 .handle_irq = gic_handle_irq, 521 .handle_irq = gic_handle_irq,
554 .init_machine = kota2_init, 522 .init_machine = kota2_init,
555 .timer = &kota2_timer, 523 .timer = &shmobile_timer,
556MACHINE_END 524MACHINE_END
diff --git a/arch/arm/mach-shmobile/board-mackerel.c b/arch/arm/mach-shmobile/board-mackerel.c
index 865d56d9629..ca609502d6c 100644
--- a/arch/arm/mach-shmobile/board-mackerel.c
+++ b/arch/arm/mach-shmobile/board-mackerel.c
@@ -57,8 +57,6 @@
57#include <mach/sh7372.h> 57#include <mach/sh7372.h>
58 58
59#include <asm/mach/arch.h> 59#include <asm/mach/arch.h>
60#include <asm/mach/time.h>
61#include <asm/mach/map.h>
62#include <asm/mach-types.h> 60#include <asm/mach-types.h>
63 61
64/* 62/*
@@ -1329,31 +1327,6 @@ static struct i2c_board_info i2c1_devices[] = {
1329 }, 1327 },
1330}; 1328};
1331 1329
1332static struct map_desc mackerel_io_desc[] __initdata = {
1333 /* create a 1:1 entity map for 0xe6xxxxxx
1334 * used by CPGA, INTC and PFC.
1335 */
1336 {
1337 .virtual = 0xe6000000,
1338 .pfn = __phys_to_pfn(0xe6000000),
1339 .length = 256 << 20,
1340 .type = MT_DEVICE_NONSHARED
1341 },
1342};
1343
1344static void __init mackerel_map_io(void)
1345{
1346 iotable_init(mackerel_io_desc, ARRAY_SIZE(mackerel_io_desc));
1347 /* DMA memory at 0xff200000 - 0xffdfffff. The default 2MB size isn't
1348 * enough to allocate the frame buffer memory.
1349 */
1350 init_consistent_dma_size(12 << 20);
1351
1352 /* setup early devices and console here as well */
1353 sh7372_add_early_devices();
1354 shmobile_setup_console();
1355}
1356
1357#define GPIO_PORT9CR 0xE6051009 1330#define GPIO_PORT9CR 0xE6051009
1358#define GPIO_PORT10CR 0xE605100A 1331#define GPIO_PORT10CR 0xE605100A
1359#define GPIO_PORT167CR 0xE60520A7 1332#define GPIO_PORT167CR 0xE60520A7
@@ -1366,6 +1339,9 @@ static void __init mackerel_init(void)
1366 struct clk *clk; 1339 struct clk *clk;
1367 int ret; 1340 int ret;
1368 1341
1342 /* External clock source */
1343 clk_set_rate(&sh7372_dv_clki_clk, 27000000);
1344
1369 sh7372_pinmux_init(); 1345 sh7372_pinmux_init();
1370 1346
1371 /* enable SCIFA0 */ 1347 /* enable SCIFA0 */
@@ -1569,23 +1545,11 @@ static void __init mackerel_init(void)
1569 pm_clk_add(&hdmi_lcdc_device.dev, "hdmi"); 1545 pm_clk_add(&hdmi_lcdc_device.dev, "hdmi");
1570} 1546}
1571 1547
1572static void __init mackerel_timer_init(void)
1573{
1574 sh7372_clock_init();
1575 shmobile_timer.init();
1576
1577 /* External clock source */
1578 clk_set_rate(&sh7372_dv_clki_clk, 27000000);
1579}
1580
1581static struct sys_timer mackerel_timer = {
1582 .init = mackerel_timer_init,
1583};
1584
1585MACHINE_START(MACKEREL, "mackerel") 1548MACHINE_START(MACKEREL, "mackerel")
1586 .map_io = mackerel_map_io, 1549 .map_io = sh7372_map_io,
1550 .init_early = sh7372_add_early_devices,
1587 .init_irq = sh7372_init_irq, 1551 .init_irq = sh7372_init_irq,
1588 .handle_irq = shmobile_handle_irq_intc, 1552 .handle_irq = shmobile_handle_irq_intc,
1589 .init_machine = mackerel_init, 1553 .init_machine = mackerel_init,
1590 .timer = &mackerel_timer, 1554 .timer = &shmobile_timer,
1591MACHINE_END 1555MACHINE_END
diff --git a/arch/arm/mach-shmobile/board-marzen.c b/arch/arm/mach-shmobile/board-marzen.c
index f0e02c0ce99..cbd5e4cd06d 100644
--- a/arch/arm/mach-shmobile/board-marzen.c
+++ b/arch/arm/mach-shmobile/board-marzen.c
@@ -33,8 +33,6 @@
33#include <mach/common.h> 33#include <mach/common.h>
34#include <asm/mach-types.h> 34#include <asm/mach-types.h>
35#include <asm/mach/arch.h> 35#include <asm/mach/arch.h>
36#include <asm/mach/map.h>
37#include <asm/mach/time.h>
38#include <asm/hardware/gic.h> 36#include <asm/hardware/gic.h>
39#include <asm/traps.h> 37#include <asm/traps.h>
40 38
@@ -72,49 +70,6 @@ static struct platform_device *marzen_devices[] __initdata = {
72 &eth_device, 70 &eth_device,
73}; 71};
74 72
75static struct map_desc marzen_io_desc[] __initdata = {
76 /* 2M entity map for 0xf0000000 (MPCORE) */
77 {
78 .virtual = 0xf0000000,
79 .pfn = __phys_to_pfn(0xf0000000),
80 .length = SZ_2M,
81 .type = MT_DEVICE_NONSHARED
82 },
83 /* 16M entity map for 0xfexxxxxx (DMAC-S/HPBREG/INTC2/LRAM/DBSC) */
84 {
85 .virtual = 0xfe000000,
86 .pfn = __phys_to_pfn(0xfe000000),
87 .length = SZ_16M,
88 .type = MT_DEVICE_NONSHARED
89 },
90};
91
92static void __init marzen_map_io(void)
93{
94 iotable_init(marzen_io_desc, ARRAY_SIZE(marzen_io_desc));
95}
96
97static void __init marzen_init_early(void)
98{
99 r8a7779_add_early_devices();
100
101 /* Early serial console setup is not included here due to
102 * memory map collisions. The SCIF serial ports in r8a7779
103 * are difficult to entity map 1:1 due to collision with the
104 * virtual memory range used by the coherent DMA code on ARM.
105 *
106 * Anyone wanting to debug early can remove UPF_IOREMAP from
107 * the sh-sci serial console platform data, adjust mapbase
108 * to a static M:N virt:phys mapping that needs to be added to
109 * the mappings passed with iotable_init() above.
110 *
111 * Then add a call to shmobile_setup_console() from this function.
112 *
113 * As a final step pass earlyprint=sh-sci.2,115200 on the kernel
114 * command line.
115 */
116}
117
118static void __init marzen_init(void) 73static void __init marzen_init(void)
119{ 74{
120 r8a7779_pinmux_init(); 75 r8a7779_pinmux_init();
@@ -135,23 +90,12 @@ static void __init marzen_init(void)
135 platform_add_devices(marzen_devices, ARRAY_SIZE(marzen_devices)); 90 platform_add_devices(marzen_devices, ARRAY_SIZE(marzen_devices));
136} 91}
137 92
138static void __init marzen_timer_init(void)
139{
140 r8a7779_clock_init();
141 shmobile_timer.init();
142 return;
143}
144
145struct sys_timer marzen_timer = {
146 .init = marzen_timer_init,
147};
148
149MACHINE_START(MARZEN, "marzen") 93MACHINE_START(MARZEN, "marzen")
150 .map_io = marzen_map_io, 94 .map_io = r8a7779_map_io,
151 .init_early = marzen_init_early, 95 .init_early = r8a7779_add_early_devices,
152 .nr_irqs = NR_IRQS_LEGACY, 96 .nr_irqs = NR_IRQS_LEGACY,
153 .init_irq = r8a7779_init_irq, 97 .init_irq = r8a7779_init_irq,
154 .handle_irq = gic_handle_irq, 98 .handle_irq = gic_handle_irq,
155 .init_machine = marzen_init, 99 .init_machine = marzen_init,
156 .timer = &marzen_timer, 100 .timer = &shmobile_timer,
157MACHINE_END 101MACHINE_END
diff --git a/arch/arm/mach-shmobile/clock-r8a7740.c b/arch/arm/mach-shmobile/clock-r8a7740.c
index 3b35b9afc00..99c4d743a99 100644
--- a/arch/arm/mach-shmobile/clock-r8a7740.c
+++ b/arch/arm/mach-shmobile/clock-r8a7740.c
@@ -93,7 +93,7 @@ static unsigned long div_recalc(struct clk *clk)
93 return clk->parent->rate / (int)(clk->priv); 93 return clk->parent->rate / (int)(clk->priv);
94} 94}
95 95
96static struct clk_ops div_clk_ops = { 96static struct sh_clk_ops div_clk_ops = {
97 .recalc = div_recalc, 97 .recalc = div_recalc,
98}; 98};
99 99
@@ -125,7 +125,7 @@ static struct clk extal2_div2_clk = {
125 .parent = &extal2_clk, 125 .parent = &extal2_clk,
126}; 126};
127 127
128static struct clk_ops followparent_clk_ops = { 128static struct sh_clk_ops followparent_clk_ops = {
129 .recalc = followparent_recalc, 129 .recalc = followparent_recalc,
130}; 130};
131 131
@@ -156,7 +156,7 @@ static unsigned long pllc01_recalc(struct clk *clk)
156 return clk->parent->rate * mult; 156 return clk->parent->rate * mult;
157} 157}
158 158
159static struct clk_ops pllc01_clk_ops = { 159static struct sh_clk_ops pllc01_clk_ops = {
160 .recalc = pllc01_recalc, 160 .recalc = pllc01_recalc,
161}; 161};
162 162
@@ -376,7 +376,7 @@ void __init r8a7740_clock_init(u8 md_ck)
376 clkdev_add_table(lookups, ARRAY_SIZE(lookups)); 376 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
377 377
378 if (!ret) 378 if (!ret)
379 clk_init(); 379 shmobile_clk_init();
380 else 380 else
381 panic("failed to setup r8a7740 clocks\n"); 381 panic("failed to setup r8a7740 clocks\n");
382} 382}
diff --git a/arch/arm/mach-shmobile/clock-r8a7779.c b/arch/arm/mach-shmobile/clock-r8a7779.c
index b4b0e8cd096..7d6e9fe47b5 100644
--- a/arch/arm/mach-shmobile/clock-r8a7779.c
+++ b/arch/arm/mach-shmobile/clock-r8a7779.c
@@ -107,7 +107,7 @@ static unsigned long mul4_recalc(struct clk *clk)
107 return clk->parent->rate * 4; 107 return clk->parent->rate * 4;
108} 108}
109 109
110static struct clk_ops mul4_clk_ops = { 110static struct sh_clk_ops mul4_clk_ops = {
111 .recalc = mul4_recalc, 111 .recalc = mul4_recalc,
112}; 112};
113 113
@@ -170,7 +170,7 @@ void __init r8a7779_clock_init(void)
170 clkdev_add_table(lookups, ARRAY_SIZE(lookups)); 170 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
171 171
172 if (!ret) 172 if (!ret)
173 clk_init(); 173 shmobile_clk_init();
174 else 174 else
175 panic("failed to setup r8a7779 clocks\n"); 175 panic("failed to setup r8a7779 clocks\n");
176} 176}
diff --git a/arch/arm/mach-shmobile/clock-sh7367.c b/arch/arm/mach-shmobile/clock-sh7367.c
index 5218c34a9cc..006e7b5d304 100644
--- a/arch/arm/mach-shmobile/clock-sh7367.c
+++ b/arch/arm/mach-shmobile/clock-sh7367.c
@@ -74,7 +74,7 @@ static unsigned long div2_recalc(struct clk *clk)
74 return clk->parent->rate / 2; 74 return clk->parent->rate / 2;
75} 75}
76 76
77static struct clk_ops div2_clk_ops = { 77static struct sh_clk_ops div2_clk_ops = {
78 .recalc = div2_recalc, 78 .recalc = div2_recalc,
79}; 79};
80 80
@@ -101,7 +101,7 @@ static unsigned long pllc1_recalc(struct clk *clk)
101 return clk->parent->rate * mult; 101 return clk->parent->rate * mult;
102} 102}
103 103
104static struct clk_ops pllc1_clk_ops = { 104static struct sh_clk_ops pllc1_clk_ops = {
105 .recalc = pllc1_recalc, 105 .recalc = pllc1_recalc,
106}; 106};
107 107
@@ -128,7 +128,7 @@ static unsigned long pllc2_recalc(struct clk *clk)
128 return clk->parent->rate * mult; 128 return clk->parent->rate * mult;
129} 129}
130 130
131static struct clk_ops pllc2_clk_ops = { 131static struct sh_clk_ops pllc2_clk_ops = {
132 .recalc = pllc2_recalc, 132 .recalc = pllc2_recalc,
133}; 133};
134 134
@@ -349,7 +349,7 @@ void __init sh7367_clock_init(void)
349 clkdev_add_table(lookups, ARRAY_SIZE(lookups)); 349 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
350 350
351 if (!ret) 351 if (!ret)
352 clk_init(); 352 shmobile_clk_init();
353 else 353 else
354 panic("failed to setup sh7367 clocks\n"); 354 panic("failed to setup sh7367 clocks\n");
355} 355}
diff --git a/arch/arm/mach-shmobile/clock-sh7372.c b/arch/arm/mach-shmobile/clock-sh7372.c
index 293456d8dcf..de243e3c839 100644
--- a/arch/arm/mach-shmobile/clock-sh7372.c
+++ b/arch/arm/mach-shmobile/clock-sh7372.c
@@ -89,7 +89,7 @@ static unsigned long div2_recalc(struct clk *clk)
89 return clk->parent->rate / 2; 89 return clk->parent->rate / 2;
90} 90}
91 91
92static struct clk_ops div2_clk_ops = { 92static struct sh_clk_ops div2_clk_ops = {
93 .recalc = div2_recalc, 93 .recalc = div2_recalc,
94}; 94};
95 95
@@ -128,7 +128,7 @@ static unsigned long pllc01_recalc(struct clk *clk)
128 return clk->parent->rate * mult; 128 return clk->parent->rate * mult;
129} 129}
130 130
131static struct clk_ops pllc01_clk_ops = { 131static struct sh_clk_ops pllc01_clk_ops = {
132 .recalc = pllc01_recalc, 132 .recalc = pllc01_recalc,
133}; 133};
134 134
@@ -276,7 +276,7 @@ static int pllc2_set_parent(struct clk *clk, struct clk *parent)
276 return 0; 276 return 0;
277} 277}
278 278
279static struct clk_ops pllc2_clk_ops = { 279static struct sh_clk_ops pllc2_clk_ops = {
280 .recalc = pllc2_recalc, 280 .recalc = pllc2_recalc,
281 .round_rate = pllc2_round_rate, 281 .round_rate = pllc2_round_rate,
282 .set_rate = pllc2_set_rate, 282 .set_rate = pllc2_set_rate,
@@ -468,7 +468,7 @@ static int fsidiv_set_rate(struct clk *clk, unsigned long rate)
468 return 0; 468 return 0;
469} 469}
470 470
471static struct clk_ops fsidiv_clk_ops = { 471static struct sh_clk_ops fsidiv_clk_ops = {
472 .recalc = fsidiv_recalc, 472 .recalc = fsidiv_recalc,
473 .round_rate = fsidiv_round_rate, 473 .round_rate = fsidiv_round_rate,
474 .set_rate = fsidiv_set_rate, 474 .set_rate = fsidiv_set_rate,
@@ -710,7 +710,7 @@ void __init sh7372_clock_init(void)
710 clkdev_add_table(lookups, ARRAY_SIZE(lookups)); 710 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
711 711
712 if (!ret) 712 if (!ret)
713 clk_init(); 713 shmobile_clk_init();
714 else 714 else
715 panic("failed to setup sh7372 clocks\n"); 715 panic("failed to setup sh7372 clocks\n");
716 716
diff --git a/arch/arm/mach-shmobile/clock-sh7377.c b/arch/arm/mach-shmobile/clock-sh7377.c
index 8cee7b151ae..0798a15936c 100644
--- a/arch/arm/mach-shmobile/clock-sh7377.c
+++ b/arch/arm/mach-shmobile/clock-sh7377.c
@@ -77,7 +77,7 @@ static unsigned long div2_recalc(struct clk *clk)
77 return clk->parent->rate / 2; 77 return clk->parent->rate / 2;
78} 78}
79 79
80static struct clk_ops div2_clk_ops = { 80static struct sh_clk_ops div2_clk_ops = {
81 .recalc = div2_recalc, 81 .recalc = div2_recalc,
82}; 82};
83 83
@@ -110,7 +110,7 @@ static unsigned long pllc1_recalc(struct clk *clk)
110 return clk->parent->rate * mult; 110 return clk->parent->rate * mult;
111} 111}
112 112
113static struct clk_ops pllc1_clk_ops = { 113static struct sh_clk_ops pllc1_clk_ops = {
114 .recalc = pllc1_recalc, 114 .recalc = pllc1_recalc,
115}; 115};
116 116
@@ -137,7 +137,7 @@ static unsigned long pllc2_recalc(struct clk *clk)
137 return clk->parent->rate * mult; 137 return clk->parent->rate * mult;
138} 138}
139 139
140static struct clk_ops pllc2_clk_ops = { 140static struct sh_clk_ops pllc2_clk_ops = {
141 .recalc = pllc2_recalc, 141 .recalc = pllc2_recalc,
142}; 142};
143 143
@@ -360,7 +360,7 @@ void __init sh7377_clock_init(void)
360 clkdev_add_table(lookups, ARRAY_SIZE(lookups)); 360 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
361 361
362 if (!ret) 362 if (!ret)
363 clk_init(); 363 shmobile_clk_init();
364 else 364 else
365 panic("failed to setup sh7377 clocks\n"); 365 panic("failed to setup sh7377 clocks\n");
366} 366}
diff --git a/arch/arm/mach-shmobile/clock-sh73a0.c b/arch/arm/mach-shmobile/clock-sh73a0.c
index 7727cca6136..472d1f5361e 100644
--- a/arch/arm/mach-shmobile/clock-sh73a0.c
+++ b/arch/arm/mach-shmobile/clock-sh73a0.c
@@ -88,7 +88,7 @@ static unsigned long div2_recalc(struct clk *clk)
88 return clk->parent->rate / 2; 88 return clk->parent->rate / 2;
89} 89}
90 90
91static struct clk_ops div2_clk_ops = { 91static struct sh_clk_ops div2_clk_ops = {
92 .recalc = div2_recalc, 92 .recalc = div2_recalc,
93}; 93};
94 94
@@ -97,7 +97,7 @@ static unsigned long div7_recalc(struct clk *clk)
97 return clk->parent->rate / 7; 97 return clk->parent->rate / 7;
98} 98}
99 99
100static struct clk_ops div7_clk_ops = { 100static struct sh_clk_ops div7_clk_ops = {
101 .recalc = div7_recalc, 101 .recalc = div7_recalc,
102}; 102};
103 103
@@ -106,7 +106,7 @@ static unsigned long div13_recalc(struct clk *clk)
106 return clk->parent->rate / 13; 106 return clk->parent->rate / 13;
107} 107}
108 108
109static struct clk_ops div13_clk_ops = { 109static struct sh_clk_ops div13_clk_ops = {
110 .recalc = div13_recalc, 110 .recalc = div13_recalc,
111}; 111};
112 112
@@ -122,7 +122,7 @@ static struct clk extal2_div2_clk = {
122 .parent = &sh73a0_extal2_clk, 122 .parent = &sh73a0_extal2_clk,
123}; 123};
124 124
125static struct clk_ops main_clk_ops = { 125static struct sh_clk_ops main_clk_ops = {
126 .recalc = followparent_recalc, 126 .recalc = followparent_recalc,
127}; 127};
128 128
@@ -156,7 +156,7 @@ static unsigned long pll_recalc(struct clk *clk)
156 return clk->parent->rate * mult; 156 return clk->parent->rate * mult;
157} 157}
158 158
159static struct clk_ops pll_clk_ops = { 159static struct sh_clk_ops pll_clk_ops = {
160 .recalc = pll_recalc, 160 .recalc = pll_recalc,
161}; 161};
162 162
@@ -438,7 +438,7 @@ static int dsiphy_set_rate(struct clk *clk, unsigned long rate)
438 return 0; 438 return 0;
439} 439}
440 440
441static struct clk_ops dsiphy_clk_ops = { 441static struct sh_clk_ops dsiphy_clk_ops = {
442 .recalc = dsiphy_recalc, 442 .recalc = dsiphy_recalc,
443 .round_rate = dsiphy_round_rate, 443 .round_rate = dsiphy_round_rate,
444 .set_rate = dsiphy_set_rate, 444 .set_rate = dsiphy_set_rate,
@@ -620,7 +620,7 @@ void __init sh73a0_clock_init(void)
620 clkdev_add_table(lookups, ARRAY_SIZE(lookups)); 620 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
621 621
622 if (!ret) 622 if (!ret)
623 clk_init(); 623 shmobile_clk_init();
624 else 624 else
625 panic("failed to setup sh73a0 clocks\n"); 625 panic("failed to setup sh73a0 clocks\n");
626} 626}
diff --git a/arch/arm/mach-shmobile/clock.c b/arch/arm/mach-shmobile/clock.c
index 31654d78b96..e816ca9bd21 100644
--- a/arch/arm/mach-shmobile/clock.c
+++ b/arch/arm/mach-shmobile/clock.c
@@ -24,7 +24,7 @@
24#include <linux/sh_clk.h> 24#include <linux/sh_clk.h>
25#include <linux/export.h> 25#include <linux/export.h>
26 26
27int __init clk_init(void) 27int __init shmobile_clk_init(void)
28{ 28{
29 /* Kick the child clocks.. */ 29 /* Kick the child clocks.. */
30 recalculate_root_clocks(); 30 recalculate_root_clocks();
diff --git a/arch/arm/mach-shmobile/include/mach/common.h b/arch/arm/mach-shmobile/include/mach/common.h
index e4b945e271e..83ad3fe0a75 100644
--- a/arch/arm/mach-shmobile/include/mach/common.h
+++ b/arch/arm/mach-shmobile/include/mach/common.h
@@ -1,12 +1,15 @@
1#ifndef __ARCH_MACH_COMMON_H 1#ifndef __ARCH_MACH_COMMON_H
2#define __ARCH_MACH_COMMON_H 2#define __ARCH_MACH_COMMON_H
3 3
4extern void shmobile_earlytimer_init(void);
4extern struct sys_timer shmobile_timer; 5extern struct sys_timer shmobile_timer;
6struct twd_local_timer;
7void shmobile_twd_init(struct twd_local_timer *twd_local_timer);
5extern void shmobile_setup_console(void); 8extern void shmobile_setup_console(void);
6extern void shmobile_secondary_vector(void); 9extern void shmobile_secondary_vector(void);
7extern int shmobile_platform_cpu_kill(unsigned int cpu); 10extern int shmobile_platform_cpu_kill(unsigned int cpu);
8struct clk; 11struct clk;
9extern int clk_init(void); 12extern int shmobile_clk_init(void);
10extern void shmobile_handle_irq_intc(struct pt_regs *); 13extern void shmobile_handle_irq_intc(struct pt_regs *);
11extern struct platform_suspend_ops shmobile_suspend_ops; 14extern struct platform_suspend_ops shmobile_suspend_ops;
12struct cpuidle_driver; 15struct cpuidle_driver;
@@ -14,6 +17,7 @@ extern void (*shmobile_cpuidle_modes[])(void);
14extern void (*shmobile_cpuidle_setup)(struct cpuidle_driver *drv); 17extern void (*shmobile_cpuidle_setup)(struct cpuidle_driver *drv);
15 18
16extern void sh7367_init_irq(void); 19extern void sh7367_init_irq(void);
20extern void sh7367_map_io(void);
17extern void sh7367_add_early_devices(void); 21extern void sh7367_add_early_devices(void);
18extern void sh7367_add_standard_devices(void); 22extern void sh7367_add_standard_devices(void);
19extern void sh7367_clock_init(void); 23extern void sh7367_clock_init(void);
@@ -22,6 +26,7 @@ extern struct clk sh7367_extalb1_clk;
22extern struct clk sh7367_extal2_clk; 26extern struct clk sh7367_extal2_clk;
23 27
24extern void sh7377_init_irq(void); 28extern void sh7377_init_irq(void);
29extern void sh7377_map_io(void);
25extern void sh7377_add_early_devices(void); 30extern void sh7377_add_early_devices(void);
26extern void sh7377_add_standard_devices(void); 31extern void sh7377_add_standard_devices(void);
27extern void sh7377_clock_init(void); 32extern void sh7377_clock_init(void);
@@ -30,6 +35,7 @@ extern struct clk sh7377_extalc1_clk;
30extern struct clk sh7377_extal2_clk; 35extern struct clk sh7377_extal2_clk;
31 36
32extern void sh7372_init_irq(void); 37extern void sh7372_init_irq(void);
38extern void sh7372_map_io(void);
33extern void sh7372_add_early_devices(void); 39extern void sh7372_add_early_devices(void);
34extern void sh7372_add_standard_devices(void); 40extern void sh7372_add_standard_devices(void);
35extern void sh7372_clock_init(void); 41extern void sh7372_clock_init(void);
@@ -41,6 +47,7 @@ extern struct clk sh7372_extal1_clk;
41extern struct clk sh7372_extal2_clk; 47extern struct clk sh7372_extal2_clk;
42 48
43extern void sh73a0_init_irq(void); 49extern void sh73a0_init_irq(void);
50extern void sh73a0_map_io(void);
44extern void sh73a0_add_early_devices(void); 51extern void sh73a0_add_early_devices(void);
45extern void sh73a0_add_standard_devices(void); 52extern void sh73a0_add_standard_devices(void);
46extern void sh73a0_clock_init(void); 53extern void sh73a0_clock_init(void);
@@ -56,12 +63,14 @@ extern int sh73a0_boot_secondary(unsigned int cpu);
56extern void sh73a0_smp_prepare_cpus(void); 63extern void sh73a0_smp_prepare_cpus(void);
57 64
58extern void r8a7740_init_irq(void); 65extern void r8a7740_init_irq(void);
66extern void r8a7740_map_io(void);
59extern void r8a7740_add_early_devices(void); 67extern void r8a7740_add_early_devices(void);
60extern void r8a7740_add_standard_devices(void); 68extern void r8a7740_add_standard_devices(void);
61extern void r8a7740_clock_init(u8 md_ck); 69extern void r8a7740_clock_init(u8 md_ck);
62extern void r8a7740_pinmux_init(void); 70extern void r8a7740_pinmux_init(void);
63 71
64extern void r8a7779_init_irq(void); 72extern void r8a7779_init_irq(void);
73extern void r8a7779_map_io(void);
65extern void r8a7779_add_early_devices(void); 74extern void r8a7779_add_early_devices(void);
66extern void r8a7779_add_standard_devices(void); 75extern void r8a7779_add_standard_devices(void);
67extern void r8a7779_clock_init(void); 76extern void r8a7779_clock_init(void);
diff --git a/arch/arm/mach-shmobile/include/mach/entry-macro.S b/arch/arm/mach-shmobile/include/mach/entry-macro.S
deleted file mode 100644
index 2a57b2964ee..00000000000
--- a/arch/arm/mach-shmobile/include/mach/entry-macro.S
+++ /dev/null
@@ -1,22 +0,0 @@
1/*
2 * Copyright (C) 2010 Paul Mundt
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; version 2 of the License.
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, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17
18 .macro disable_fiq
19 .endm
20
21 .macro arch_ret_to_user, tmp1, tmp2
22 .endm
diff --git a/arch/arm/mach-shmobile/include/mach/system.h b/arch/arm/mach-shmobile/include/mach/system.h
index 92042703b94..540eaff08f3 100644
--- a/arch/arm/mach-shmobile/include/mach/system.h
+++ b/arch/arm/mach-shmobile/include/mach/system.h
@@ -3,11 +3,6 @@
3 3
4#include <asm/system_misc.h> 4#include <asm/system_misc.h>
5 5
6static inline void arch_idle(void)
7{
8 cpu_do_idle();
9}
10
11static inline void arch_reset(char mode, const char *cmd) 6static inline void arch_reset(char mode, const char *cmd)
12{ 7{
13 soft_restart(0); 8 soft_restart(0);
diff --git a/arch/arm/mach-shmobile/localtimer.c b/arch/arm/mach-shmobile/localtimer.c
deleted file mode 100644
index ad9ccc9900c..00000000000
--- a/arch/arm/mach-shmobile/localtimer.c
+++ /dev/null
@@ -1,26 +0,0 @@
1/*
2 * SMP support for R-Mobile / SH-Mobile - local timer portion
3 *
4 * Copyright (C) 2010 Magnus Damm
5 *
6 * Based on vexpress, Copyright (C) 2002 ARM Ltd, All Rights Reserved
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12#include <linux/init.h>
13#include <linux/smp.h>
14#include <linux/clockchips.h>
15#include <asm/smp_twd.h>
16#include <asm/localtimer.h>
17
18/*
19 * Setup the local clock events for a CPU.
20 */
21int __cpuinit local_timer_setup(struct clock_event_device *evt)
22{
23 evt->irq = 29;
24 twd_timer_setup(evt);
25 return 0;
26}
diff --git a/arch/arm/mach-shmobile/platsmp.c b/arch/arm/mach-shmobile/platsmp.c
index 993381257f6..45fa3924c6a 100644
--- a/arch/arm/mach-shmobile/platsmp.c
+++ b/arch/arm/mach-shmobile/platsmp.c
@@ -17,7 +17,6 @@
17#include <linux/smp.h> 17#include <linux/smp.h>
18#include <linux/io.h> 18#include <linux/io.h>
19#include <asm/hardware/gic.h> 19#include <asm/hardware/gic.h>
20#include <asm/localtimer.h>
21#include <asm/mach-types.h> 20#include <asm/mach-types.h>
22#include <mach/common.h> 21#include <mach/common.h>
23 22
diff --git a/arch/arm/mach-shmobile/setup-r8a7740.c b/arch/arm/mach-shmobile/setup-r8a7740.c
index 986dca6b3fa..74e52341dd1 100644
--- a/arch/arm/mach-shmobile/setup-r8a7740.c
+++ b/arch/arm/mach-shmobile/setup-r8a7740.c
@@ -25,8 +25,41 @@
25#include <linux/serial_sci.h> 25#include <linux/serial_sci.h>
26#include <linux/sh_timer.h> 26#include <linux/sh_timer.h>
27#include <mach/r8a7740.h> 27#include <mach/r8a7740.h>
28#include <mach/common.h>
28#include <asm/mach-types.h> 29#include <asm/mach-types.h>
30#include <asm/mach/map.h>
29#include <asm/mach/arch.h> 31#include <asm/mach/arch.h>
32#include <asm/mach/time.h>
33
34static struct map_desc r8a7740_io_desc[] __initdata = {
35 /*
36 * for CPGA/INTC/PFC
37 * 0xe6000000-0xefffffff -> 0xe6000000-0xefffffff
38 */
39 {
40 .virtual = 0xe6000000,
41 .pfn = __phys_to_pfn(0xe6000000),
42 .length = 160 << 20,
43 .type = MT_DEVICE_NONSHARED
44 },
45#ifdef CONFIG_CACHE_L2X0
46 /*
47 * for l2x0_init()
48 * 0xf0100000-0xf0101000 -> 0xf0002000-0xf0003000
49 */
50 {
51 .virtual = 0xf0002000,
52 .pfn = __phys_to_pfn(0xf0100000),
53 .length = PAGE_SIZE,
54 .type = MT_DEVICE_NONSHARED
55 },
56#endif
57};
58
59void __init r8a7740_map_io(void)
60{
61 iotable_init(r8a7740_io_desc, ARRAY_SIZE(r8a7740_io_desc));
62}
30 63
31/* SCIFA0 */ 64/* SCIFA0 */
32static struct plat_sci_port scif0_platform_data = { 65static struct plat_sci_port scif0_platform_data = {
@@ -345,8 +378,20 @@ void __init r8a7740_add_standard_devices(void)
345 ARRAY_SIZE(r8a7740_late_devices)); 378 ARRAY_SIZE(r8a7740_late_devices));
346} 379}
347 380
381static void __init r8a7740_earlytimer_init(void)
382{
383 r8a7740_clock_init(0);
384 shmobile_earlytimer_init();
385}
386
348void __init r8a7740_add_early_devices(void) 387void __init r8a7740_add_early_devices(void)
349{ 388{
350 early_platform_add_devices(r8a7740_early_devices, 389 early_platform_add_devices(r8a7740_early_devices,
351 ARRAY_SIZE(r8a7740_early_devices)); 390 ARRAY_SIZE(r8a7740_early_devices));
391
392 /* setup early console here as well */
393 shmobile_setup_console();
394
395 /* override timer setup with soc-specific code */
396 shmobile_timer.init = r8a7740_earlytimer_init;
352} 397}
diff --git a/arch/arm/mach-shmobile/setup-r8a7779.c b/arch/arm/mach-shmobile/setup-r8a7779.c
index 4725663bd03..6820d785493 100644
--- a/arch/arm/mach-shmobile/setup-r8a7779.c
+++ b/arch/arm/mach-shmobile/setup-r8a7779.c
@@ -33,6 +33,31 @@
33#include <mach/common.h> 33#include <mach/common.h>
34#include <asm/mach-types.h> 34#include <asm/mach-types.h>
35#include <asm/mach/arch.h> 35#include <asm/mach/arch.h>
36#include <asm/mach/time.h>
37#include <asm/mach/map.h>
38#include <asm/hardware/cache-l2x0.h>
39
40static struct map_desc r8a7779_io_desc[] __initdata = {
41 /* 2M entity map for 0xf0000000 (MPCORE) */
42 {
43 .virtual = 0xf0000000,
44 .pfn = __phys_to_pfn(0xf0000000),
45 .length = SZ_2M,
46 .type = MT_DEVICE_NONSHARED
47 },
48 /* 16M entity map for 0xfexxxxxx (DMAC-S/HPBREG/INTC2/LRAM/DBSC) */
49 {
50 .virtual = 0xfe000000,
51 .pfn = __phys_to_pfn(0xfe000000),
52 .length = SZ_16M,
53 .type = MT_DEVICE_NONSHARED
54 },
55};
56
57void __init r8a7779_map_io(void)
58{
59 iotable_init(r8a7779_io_desc, ARRAY_SIZE(r8a7779_io_desc));
60}
36 61
37static struct plat_sci_port scif0_platform_data = { 62static struct plat_sci_port scif0_platform_data = {
38 .mapbase = 0xffe40000, 63 .mapbase = 0xffe40000,
@@ -219,6 +244,10 @@ static struct platform_device *r8a7779_late_devices[] __initdata = {
219 244
220void __init r8a7779_add_standard_devices(void) 245void __init r8a7779_add_standard_devices(void)
221{ 246{
247#ifdef CONFIG_CACHE_L2X0
248 /* Early BRESP enable, Shared attribute override enable, 64K*16way */
249 l2x0_init((void __iomem __force *)(0xf0100000), 0x40470000, 0x82000fff);
250#endif
222 r8a7779_pm_init(); 251 r8a7779_pm_init();
223 252
224 r8a7779_init_pm_domain(&r8a7779_sh4a); 253 r8a7779_init_pm_domain(&r8a7779_sh4a);
@@ -232,8 +261,33 @@ void __init r8a7779_add_standard_devices(void)
232 ARRAY_SIZE(r8a7779_late_devices)); 261 ARRAY_SIZE(r8a7779_late_devices));
233} 262}
234 263
264static void __init r8a7779_earlytimer_init(void)
265{
266 r8a7779_clock_init();
267 shmobile_earlytimer_init();
268}
269
235void __init r8a7779_add_early_devices(void) 270void __init r8a7779_add_early_devices(void)
236{ 271{
237 early_platform_add_devices(r8a7779_early_devices, 272 early_platform_add_devices(r8a7779_early_devices,
238 ARRAY_SIZE(r8a7779_early_devices)); 273 ARRAY_SIZE(r8a7779_early_devices));
274
275 /* Early serial console setup is not included here due to
276 * memory map collisions. The SCIF serial ports in r8a7779
277 * are difficult to entity map 1:1 due to collision with the
278 * virtual memory range used by the coherent DMA code on ARM.
279 *
280 * Anyone wanting to debug early can remove UPF_IOREMAP from
281 * the sh-sci serial console platform data, adjust mapbase
282 * to a static M:N virt:phys mapping that needs to be added to
283 * the mappings passed with iotable_init() above.
284 *
285 * Then add a call to shmobile_setup_console() from this function.
286 *
287 * As a final step pass earlyprint=sh-sci.2,115200 on the kernel
288 * command line in case of the marzen board.
289 */
290
291 /* override timer setup with soc-specific code */
292 shmobile_timer.init = r8a7779_earlytimer_init;
239} 293}
diff --git a/arch/arm/mach-shmobile/setup-sh7367.c b/arch/arm/mach-shmobile/setup-sh7367.c
index e546017f15d..a51e1a1e699 100644
--- a/arch/arm/mach-shmobile/setup-sh7367.c
+++ b/arch/arm/mach-shmobile/setup-sh7367.c
@@ -29,8 +29,28 @@
29#include <linux/serial_sci.h> 29#include <linux/serial_sci.h>
30#include <linux/sh_timer.h> 30#include <linux/sh_timer.h>
31#include <mach/hardware.h> 31#include <mach/hardware.h>
32#include <mach/common.h>
32#include <asm/mach-types.h> 33#include <asm/mach-types.h>
33#include <asm/mach/arch.h> 34#include <asm/mach/arch.h>
35#include <asm/mach/map.h>
36#include <asm/mach/time.h>
37
38static struct map_desc sh7367_io_desc[] __initdata = {
39 /* create a 1:1 entity map for 0xe6xxxxxx
40 * used by CPGA, INTC and PFC.
41 */
42 {
43 .virtual = 0xe6000000,
44 .pfn = __phys_to_pfn(0xe6000000),
45 .length = 256 << 20,
46 .type = MT_DEVICE_NONSHARED
47 },
48};
49
50void __init sh7367_map_io(void)
51{
52 iotable_init(sh7367_io_desc, ARRAY_SIZE(sh7367_io_desc));
53}
34 54
35/* SCIFA0 */ 55/* SCIFA0 */
36static struct plat_sci_port scif0_platform_data = { 56static struct plat_sci_port scif0_platform_data = {
@@ -435,6 +455,12 @@ void __init sh7367_add_standard_devices(void)
435 ARRAY_SIZE(sh7367_devices)); 455 ARRAY_SIZE(sh7367_devices));
436} 456}
437 457
458static void __init sh7367_earlytimer_init(void)
459{
460 sh7367_clock_init();
461 shmobile_earlytimer_init();
462}
463
438#define SYMSTPCR2 0xe6158048 464#define SYMSTPCR2 0xe6158048
439#define SYMSTPCR2_CMT1 (1 << 29) 465#define SYMSTPCR2_CMT1 (1 << 29)
440 466
@@ -445,4 +471,10 @@ void __init sh7367_add_early_devices(void)
445 471
446 early_platform_add_devices(sh7367_early_devices, 472 early_platform_add_devices(sh7367_early_devices,
447 ARRAY_SIZE(sh7367_early_devices)); 473 ARRAY_SIZE(sh7367_early_devices));
474
475 /* setup early console here as well */
476 shmobile_setup_console();
477
478 /* override timer setup with soc-specific code */
479 shmobile_timer.init = sh7367_earlytimer_init;
448} 480}
diff --git a/arch/arm/mach-shmobile/setup-sh7372.c b/arch/arm/mach-shmobile/setup-sh7372.c
index cccf91b8fae..4e818b7de78 100644
--- a/arch/arm/mach-shmobile/setup-sh7372.c
+++ b/arch/arm/mach-shmobile/setup-sh7372.c
@@ -31,10 +31,37 @@
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 <linux/pm_domain.h> 33#include <linux/pm_domain.h>
34#include <linux/dma-mapping.h>
34#include <mach/hardware.h> 35#include <mach/hardware.h>
35#include <mach/sh7372.h> 36#include <mach/sh7372.h>
37#include <mach/common.h>
38#include <asm/mach/map.h>
36#include <asm/mach-types.h> 39#include <asm/mach-types.h>
37#include <asm/mach/arch.h> 40#include <asm/mach/arch.h>
41#include <asm/mach/time.h>
42
43static struct map_desc sh7372_io_desc[] __initdata = {
44 /* create a 1:1 entity map for 0xe6xxxxxx
45 * used by CPGA, INTC and PFC.
46 */
47 {
48 .virtual = 0xe6000000,
49 .pfn = __phys_to_pfn(0xe6000000),
50 .length = 256 << 20,
51 .type = MT_DEVICE_NONSHARED
52 },
53};
54
55void __init sh7372_map_io(void)
56{
57 iotable_init(sh7372_io_desc, ARRAY_SIZE(sh7372_io_desc));
58
59 /*
60 * DMA memory at 0xff200000 - 0xffdfffff. The default 2MB size isn't
61 * enough to allocate the frame buffer memory.
62 */
63 init_consistent_dma_size(12 << 20);
64}
38 65
39/* SCIFA0 */ 66/* SCIFA0 */
40static struct plat_sci_port scif0_platform_data = { 67static struct plat_sci_port scif0_platform_data = {
@@ -1047,8 +1074,20 @@ void __init sh7372_add_standard_devices(void)
1047 sh7372_add_device_to_domain(&sh7372_a4r, &tmu01_device); 1074 sh7372_add_device_to_domain(&sh7372_a4r, &tmu01_device);
1048} 1075}
1049 1076
1077static void __init sh7372_earlytimer_init(void)
1078{
1079 sh7372_clock_init();
1080 shmobile_earlytimer_init();
1081}
1082
1050void __init sh7372_add_early_devices(void) 1083void __init sh7372_add_early_devices(void)
1051{ 1084{
1052 early_platform_add_devices(sh7372_early_devices, 1085 early_platform_add_devices(sh7372_early_devices,
1053 ARRAY_SIZE(sh7372_early_devices)); 1086 ARRAY_SIZE(sh7372_early_devices));
1087
1088 /* setup early console here as well */
1089 shmobile_setup_console();
1090
1091 /* override timer setup with soc-specific code */
1092 shmobile_timer.init = sh7372_earlytimer_init;
1054} 1093}
diff --git a/arch/arm/mach-shmobile/setup-sh7377.c b/arch/arm/mach-shmobile/setup-sh7377.c
index bb405b8e459..9f146095098 100644
--- a/arch/arm/mach-shmobile/setup-sh7377.c
+++ b/arch/arm/mach-shmobile/setup-sh7377.c
@@ -30,8 +30,28 @@
30#include <linux/sh_intc.h> 30#include <linux/sh_intc.h>
31#include <linux/sh_timer.h> 31#include <linux/sh_timer.h>
32#include <mach/hardware.h> 32#include <mach/hardware.h>
33#include <mach/common.h>
34#include <asm/mach/map.h>
33#include <asm/mach-types.h> 35#include <asm/mach-types.h>
34#include <asm/mach/arch.h> 36#include <asm/mach/arch.h>
37#include <asm/mach/time.h>
38
39static struct map_desc sh7377_io_desc[] __initdata = {
40 /* create a 1:1 entity map for 0xe6xxxxxx
41 * used by CPGA, INTC and PFC.
42 */
43 {
44 .virtual = 0xe6000000,
45 .pfn = __phys_to_pfn(0xe6000000),
46 .length = 256 << 20,
47 .type = MT_DEVICE_NONSHARED
48 },
49};
50
51void __init sh7377_map_io(void)
52{
53 iotable_init(sh7377_io_desc, ARRAY_SIZE(sh7377_io_desc));
54}
35 55
36/* SCIFA0 */ 56/* SCIFA0 */
37static struct plat_sci_port scif0_platform_data = { 57static struct plat_sci_port scif0_platform_data = {
@@ -456,6 +476,12 @@ void __init sh7377_add_standard_devices(void)
456 ARRAY_SIZE(sh7377_devices)); 476 ARRAY_SIZE(sh7377_devices));
457} 477}
458 478
479static void __init sh7377_earlytimer_init(void)
480{
481 sh7377_clock_init();
482 shmobile_earlytimer_init();
483}
484
459#define SMSTPCR3 0xe615013c 485#define SMSTPCR3 0xe615013c
460#define SMSTPCR3_CMT1 (1 << 29) 486#define SMSTPCR3_CMT1 (1 << 29)
461 487
@@ -466,4 +492,10 @@ void __init sh7377_add_early_devices(void)
466 492
467 early_platform_add_devices(sh7377_early_devices, 493 early_platform_add_devices(sh7377_early_devices,
468 ARRAY_SIZE(sh7377_early_devices)); 494 ARRAY_SIZE(sh7377_early_devices));
495
496 /* setup early console here as well */
497 shmobile_setup_console();
498
499 /* override timer setup with soc-specific code */
500 shmobile_timer.init = sh7377_earlytimer_init;
469} 501}
diff --git a/arch/arm/mach-shmobile/setup-sh73a0.c b/arch/arm/mach-shmobile/setup-sh73a0.c
index 20e71e5cace..b6a0734a738 100644
--- a/arch/arm/mach-shmobile/setup-sh73a0.c
+++ b/arch/arm/mach-shmobile/setup-sh73a0.c
@@ -32,8 +32,28 @@
32#include <linux/sh_timer.h> 32#include <linux/sh_timer.h>
33#include <mach/hardware.h> 33#include <mach/hardware.h>
34#include <mach/sh73a0.h> 34#include <mach/sh73a0.h>
35#include <mach/common.h>
35#include <asm/mach-types.h> 36#include <asm/mach-types.h>
37#include <asm/mach/map.h>
36#include <asm/mach/arch.h> 38#include <asm/mach/arch.h>
39#include <asm/mach/time.h>
40
41static struct map_desc sh73a0_io_desc[] __initdata = {
42 /* create a 1:1 entity map for 0xe6xxxxxx
43 * used by CPGA, INTC and PFC.
44 */
45 {
46 .virtual = 0xe6000000,
47 .pfn = __phys_to_pfn(0xe6000000),
48 .length = 256 << 20,
49 .type = MT_DEVICE_NONSHARED
50 },
51};
52
53void __init sh73a0_map_io(void)
54{
55 iotable_init(sh73a0_io_desc, ARRAY_SIZE(sh73a0_io_desc));
56}
37 57
38static struct plat_sci_port scif0_platform_data = { 58static struct plat_sci_port scif0_platform_data = {
39 .mapbase = 0xe6c40000, 59 .mapbase = 0xe6c40000,
@@ -667,8 +687,20 @@ void __init sh73a0_add_standard_devices(void)
667 ARRAY_SIZE(sh73a0_late_devices)); 687 ARRAY_SIZE(sh73a0_late_devices));
668} 688}
669 689
690static void __init sh73a0_earlytimer_init(void)
691{
692 sh73a0_clock_init();
693 shmobile_earlytimer_init();
694}
695
670void __init sh73a0_add_early_devices(void) 696void __init sh73a0_add_early_devices(void)
671{ 697{
672 early_platform_add_devices(sh73a0_early_devices, 698 early_platform_add_devices(sh73a0_early_devices,
673 ARRAY_SIZE(sh73a0_early_devices)); 699 ARRAY_SIZE(sh73a0_early_devices));
700
701 /* setup early console here as well */
702 shmobile_setup_console();
703
704 /* override timer setup with soc-specific code */
705 shmobile_timer.init = sh73a0_earlytimer_init;
674} 706}
diff --git a/arch/arm/mach-shmobile/smp-r8a7779.c b/arch/arm/mach-shmobile/smp-r8a7779.c
index 4fe2e9eaf50..9bb7b8575a1 100644
--- a/arch/arm/mach-shmobile/smp-r8a7779.c
+++ b/arch/arm/mach-shmobile/smp-r8a7779.c
@@ -64,6 +64,8 @@ static void __iomem *scu_base_addr(void)
64static DEFINE_SPINLOCK(scu_lock); 64static DEFINE_SPINLOCK(scu_lock);
65static unsigned long tmp; 65static unsigned long tmp;
66 66
67static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, 0xf0000600, 29);
68
67static void modify_scu_cpu_psr(unsigned long set, unsigned long clr) 69static void modify_scu_cpu_psr(unsigned long set, unsigned long clr)
68{ 70{
69 void __iomem *scu_base = scu_base_addr(); 71 void __iomem *scu_base = scu_base_addr();
@@ -82,11 +84,7 @@ unsigned int __init r8a7779_get_core_count(void)
82{ 84{
83 void __iomem *scu_base = scu_base_addr(); 85 void __iomem *scu_base = scu_base_addr();
84 86
85#ifdef CONFIG_HAVE_ARM_TWD 87 shmobile_twd_init(&twd_local_timer);
86 /* twd_base needs to be initialized before percpu_timer_setup() */
87 twd_base = (void __iomem *)0xf0000600;
88#endif
89
90 return scu_get_core_count(scu_base); 88 return scu_get_core_count(scu_base);
91} 89}
92 90
diff --git a/arch/arm/mach-shmobile/smp-sh73a0.c b/arch/arm/mach-shmobile/smp-sh73a0.c
index 2d0d4212be4..c0a9093ba3a 100644
--- a/arch/arm/mach-shmobile/smp-sh73a0.c
+++ b/arch/arm/mach-shmobile/smp-sh73a0.c
@@ -42,6 +42,8 @@ static void __iomem *scu_base_addr(void)
42static DEFINE_SPINLOCK(scu_lock); 42static DEFINE_SPINLOCK(scu_lock);
43static unsigned long tmp; 43static unsigned long tmp;
44 44
45static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, 0xf0000600, 29);
46
45static void modify_scu_cpu_psr(unsigned long set, unsigned long clr) 47static void modify_scu_cpu_psr(unsigned long set, unsigned long clr)
46{ 48{
47 void __iomem *scu_base = scu_base_addr(); 49 void __iomem *scu_base = scu_base_addr();
@@ -60,11 +62,7 @@ unsigned int __init sh73a0_get_core_count(void)
60{ 62{
61 void __iomem *scu_base = scu_base_addr(); 63 void __iomem *scu_base = scu_base_addr();
62 64
63#ifdef CONFIG_HAVE_ARM_TWD 65 shmobile_twd_init(&twd_local_timer);
64 /* twd_base needs to be initialized before percpu_timer_setup() */
65 twd_base = (void __iomem *)0xf0000600;
66#endif
67
68 return scu_get_core_count(scu_base); 66 return scu_get_core_count(scu_base);
69} 67}
70 68
diff --git a/arch/arm/mach-shmobile/timer.c b/arch/arm/mach-shmobile/timer.c
index 895794b543c..2fba5f3d1c8 100644
--- a/arch/arm/mach-shmobile/timer.c
+++ b/arch/arm/mach-shmobile/timer.c
@@ -20,6 +20,7 @@
20 */ 20 */
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <asm/mach/time.h> 22#include <asm/mach/time.h>
23#include <asm/smp_twd.h>
23 24
24static void __init shmobile_late_time_init(void) 25static void __init shmobile_late_time_init(void)
25{ 26{
@@ -36,11 +37,24 @@ static void __init shmobile_late_time_init(void)
36 early_platform_driver_probe("earlytimer", 2, 0); 37 early_platform_driver_probe("earlytimer", 2, 0);
37} 38}
38 39
39static void __init shmobile_timer_init(void) 40void __init shmobile_earlytimer_init(void)
40{ 41{
41 late_time_init = shmobile_late_time_init; 42 late_time_init = shmobile_late_time_init;
42} 43}
43 44
45static void __init shmobile_timer_init(void)
46{
47}
48
49void __init shmobile_twd_init(struct twd_local_timer *twd_local_timer)
50{
51#ifdef CONFIG_HAVE_ARM_TWD
52 int err = twd_local_timer_register(twd_local_timer);
53 if (err)
54 pr_err("twd_local_timer_register failed %d\n", err);
55#endif
56}
57
44struct sys_timer shmobile_timer = { 58struct sys_timer shmobile_timer = {
45 .init = shmobile_timer_init, 59 .init = shmobile_timer_init,
46}; 60};
diff --git a/arch/arm/mach-spear3xx/include/mach/entry-macro.S b/arch/arm/mach-spear3xx/include/mach/entry-macro.S
deleted file mode 100644
index de3bb41c8e9..00000000000
--- a/arch/arm/mach-spear3xx/include/mach/entry-macro.S
+++ /dev/null
@@ -1,18 +0,0 @@
1/*
2 * arch/arm/mach-spear3xx/include/mach/entry-macro.S
3 *
4 * Low-level IRQ helper macros for SPEAr3xx machine family
5 *
6 * Copyright (C) 2009 ST Microelectronics
7 * Viresh Kumar<viresh.kumar@st.com>
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 .macro disable_fiq
15 .endm
16
17 .macro arch_ret_to_user, tmp1, tmp2
18 .endm
diff --git a/arch/arm/mach-spear3xx/include/mach/system.h b/arch/arm/mach-spear3xx/include/mach/system.h
deleted file mode 100644
index 92cee6335c9..00000000000
--- a/arch/arm/mach-spear3xx/include/mach/system.h
+++ /dev/null
@@ -1,19 +0,0 @@
1/*
2 * arch/arm/mach-spear3xx/include/mach/system.h
3 *
4 * SPEAr3xx Machine family specific architecture functions
5 *
6 * Copyright (C) 2009 ST Microelectronics
7 * Viresh Kumar<viresh.kumar@st.com>
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#ifndef __MACH_SYSTEM_H
15#define __MACH_SYSTEM_H
16
17#include <plat/system.h>
18
19#endif /* __MACH_SYSTEM_H */
diff --git a/arch/arm/mach-spear3xx/spear300.c b/arch/arm/mach-spear3xx/spear300.c
index 4f7f5182dd4..f7db66812ab 100644
--- a/arch/arm/mach-spear3xx/spear300.c
+++ b/arch/arm/mach-spear3xx/spear300.c
@@ -430,18 +430,8 @@ static struct pl061_platform_data gpio1_plat_data = {
430 .irq_base = SPEAR300_GPIO1_INT_BASE, 430 .irq_base = SPEAR300_GPIO1_INT_BASE,
431}; 431};
432 432
433struct amba_device spear300_gpio1_device = { 433AMBA_APB_DEVICE(spear300_gpio1, "gpio1", 0, SPEAR300_GPIO_BASE,
434 .dev = { 434 {SPEAR300_VIRQ_GPIO1}, &gpio1_plat_data);
435 .init_name = "gpio1",
436 .platform_data = &gpio1_plat_data,
437 },
438 .res = {
439 .start = SPEAR300_GPIO_BASE,
440 .end = SPEAR300_GPIO_BASE + SZ_4K - 1,
441 .flags = IORESOURCE_MEM,
442 },
443 .irq = {SPEAR300_VIRQ_GPIO1, NO_IRQ},
444};
445 435
446/* spear300 routines */ 436/* spear300 routines */
447void __init spear300_init(struct pmx_mode *pmx_mode, struct pmx_dev **pmx_devs, 437void __init spear300_init(struct pmx_mode *pmx_mode, struct pmx_dev **pmx_devs,
diff --git a/arch/arm/mach-spear3xx/spear3xx.c b/arch/arm/mach-spear3xx/spear3xx.c
index 10af45da86a..b1733c37f20 100644
--- a/arch/arm/mach-spear3xx/spear3xx.c
+++ b/arch/arm/mach-spear3xx/spear3xx.c
@@ -28,31 +28,12 @@ static struct pl061_platform_data gpio_plat_data = {
28 .irq_base = SPEAR3XX_GPIO_INT_BASE, 28 .irq_base = SPEAR3XX_GPIO_INT_BASE,
29}; 29};
30 30
31struct amba_device spear3xx_gpio_device = { 31AMBA_APB_DEVICE(spear3xx_gpio, "gpio", 0, SPEAR3XX_ICM3_GPIO_BASE,
32 .dev = { 32 {SPEAR3XX_IRQ_BASIC_GPIO}, &gpio_plat_data);
33 .init_name = "gpio",
34 .platform_data = &gpio_plat_data,
35 },
36 .res = {
37 .start = SPEAR3XX_ICM3_GPIO_BASE,
38 .end = SPEAR3XX_ICM3_GPIO_BASE + SZ_4K - 1,
39 .flags = IORESOURCE_MEM,
40 },
41 .irq = {SPEAR3XX_IRQ_BASIC_GPIO, NO_IRQ},
42};
43 33
44/* uart device registration */ 34/* uart device registration */
45struct amba_device spear3xx_uart_device = { 35AMBA_APB_DEVICE(spear3xx_uart, "uart", 0, SPEAR3XX_ICM1_UART_BASE,
46 .dev = { 36 {SPEAR3XX_IRQ_UART}, NULL);
47 .init_name = "uart",
48 },
49 .res = {
50 .start = SPEAR3XX_ICM1_UART_BASE,
51 .end = SPEAR3XX_ICM1_UART_BASE + SZ_4K - 1,
52 .flags = IORESOURCE_MEM,
53 },
54 .irq = {SPEAR3XX_IRQ_UART, NO_IRQ},
55};
56 37
57/* Do spear3xx familiy common initialization part here */ 38/* Do spear3xx familiy common initialization part here */
58void __init spear3xx_init(void) 39void __init spear3xx_init(void)
diff --git a/arch/arm/mach-spear6xx/Kconfig b/arch/arm/mach-spear6xx/Kconfig
index ff4ae5ba00f..fbe298bd1d9 100644
--- a/arch/arm/mach-spear6xx/Kconfig
+++ b/arch/arm/mach-spear6xx/Kconfig
@@ -5,11 +5,12 @@
5if ARCH_SPEAR6XX 5if ARCH_SPEAR6XX
6 6
7menu "SPEAr6xx Implementations" 7menu "SPEAr6xx Implementations"
8config BOARD_SPEAR600_EVB 8config BOARD_SPEAR600_DT
9 bool "SPEAr600 Evaluation Board" 9 bool "SPEAr600 generic board configured via device-tree"
10 select MACH_SPEAR600 10 select MACH_SPEAR600
11 select USE_OF
11 help 12 help
12 Supports ST SPEAr600 Evaluation Board 13 Supports ST SPEAr600 boards configured via the device-tree
13 14
14endmenu 15endmenu
15 16
diff --git a/arch/arm/mach-spear6xx/Makefile b/arch/arm/mach-spear6xx/Makefile
index cc1a4d82d45..76e5750552f 100644
--- a/arch/arm/mach-spear6xx/Makefile
+++ b/arch/arm/mach-spear6xx/Makefile
@@ -4,9 +4,3 @@
4 4
5# common files 5# common files
6obj-y += clock.o spear6xx.o 6obj-y += clock.o spear6xx.o
7
8# spear600 specific files
9obj-$(CONFIG_MACH_SPEAR600) += spear600.o
10
11# spear600 boards files
12obj-$(CONFIG_BOARD_SPEAR600_EVB) += spear600_evb.o
diff --git a/arch/arm/mach-spear6xx/clock.c b/arch/arm/mach-spear6xx/clock.c
index ac70e0d88fe..358f2800f17 100644
--- a/arch/arm/mach-spear6xx/clock.c
+++ b/arch/arm/mach-spear6xx/clock.c
@@ -641,8 +641,8 @@ static struct clk_lookup spear_clk_lookups[] = {
641 { .con_id = "gpt0_synth_clk", .clk = &gpt0_synth_clk}, 641 { .con_id = "gpt0_synth_clk", .clk = &gpt0_synth_clk},
642 { .con_id = "gpt2_synth_clk", .clk = &gpt2_synth_clk}, 642 { .con_id = "gpt2_synth_clk", .clk = &gpt2_synth_clk},
643 { .con_id = "gpt3_synth_clk", .clk = &gpt3_synth_clk}, 643 { .con_id = "gpt3_synth_clk", .clk = &gpt3_synth_clk},
644 { .dev_id = "uart0", .clk = &uart0_clk}, 644 { .dev_id = "d0000000.serial", .clk = &uart0_clk},
645 { .dev_id = "uart1", .clk = &uart1_clk}, 645 { .dev_id = "d0080000.serial", .clk = &uart1_clk},
646 { .dev_id = "firda", .clk = &firda_clk}, 646 { .dev_id = "firda", .clk = &firda_clk},
647 { .dev_id = "clcd", .clk = &clcd_clk}, 647 { .dev_id = "clcd", .clk = &clcd_clk},
648 { .dev_id = "gpt0", .clk = &gpt0_clk}, 648 { .dev_id = "gpt0", .clk = &gpt0_clk},
@@ -655,20 +655,20 @@ static struct clk_lookup spear_clk_lookups[] = {
655 { .con_id = "usbh.1_clk", .clk = &usbh1_clk}, 655 { .con_id = "usbh.1_clk", .clk = &usbh1_clk},
656 /* clock derived from ahb clk */ 656 /* clock derived from ahb clk */
657 { .con_id = "apb_clk", .clk = &apb_clk}, 657 { .con_id = "apb_clk", .clk = &apb_clk},
658 { .dev_id = "i2c_designware.0", .clk = &i2c_clk}, 658 { .dev_id = "d0200000.i2c", .clk = &i2c_clk},
659 { .dev_id = "dma", .clk = &dma_clk}, 659 { .dev_id = "dma", .clk = &dma_clk},
660 { .dev_id = "jpeg", .clk = &jpeg_clk}, 660 { .dev_id = "jpeg", .clk = &jpeg_clk},
661 { .dev_id = "gmac", .clk = &gmac_clk}, 661 { .dev_id = "gmac", .clk = &gmac_clk},
662 { .dev_id = "smi", .clk = &smi_clk}, 662 { .dev_id = "smi", .clk = &smi_clk},
663 { .con_id = "fsmc", .clk = &fsmc_clk}, 663 { .dev_id = "fsmc-nand", .clk = &fsmc_clk},
664 /* clock derived from apb clk */ 664 /* clock derived from apb clk */
665 { .dev_id = "adc", .clk = &adc_clk}, 665 { .dev_id = "adc", .clk = &adc_clk},
666 { .dev_id = "ssp-pl022.0", .clk = &ssp0_clk}, 666 { .dev_id = "ssp-pl022.0", .clk = &ssp0_clk},
667 { .dev_id = "ssp-pl022.1", .clk = &ssp1_clk}, 667 { .dev_id = "ssp-pl022.1", .clk = &ssp1_clk},
668 { .dev_id = "ssp-pl022.2", .clk = &ssp2_clk}, 668 { .dev_id = "ssp-pl022.2", .clk = &ssp2_clk},
669 { .dev_id = "gpio0", .clk = &gpio0_clk}, 669 { .dev_id = "f0100000.gpio", .clk = &gpio0_clk},
670 { .dev_id = "gpio1", .clk = &gpio1_clk}, 670 { .dev_id = "fc980000.gpio", .clk = &gpio1_clk},
671 { .dev_id = "gpio2", .clk = &gpio2_clk}, 671 { .dev_id = "d8100000.gpio", .clk = &gpio2_clk},
672}; 672};
673 673
674void __init spear6xx_clk_init(void) 674void __init spear6xx_clk_init(void)
diff --git a/arch/arm/mach-spear6xx/include/mach/entry-macro.S b/arch/arm/mach-spear6xx/include/mach/entry-macro.S
deleted file mode 100644
index d490a910d92..00000000000
--- a/arch/arm/mach-spear6xx/include/mach/entry-macro.S
+++ /dev/null
@@ -1,18 +0,0 @@
1/*
2 * arch/arm/mach-spear6xx/include/mach/entry-macro.S
3 *
4 * Low-level IRQ helper macros for SPEAr6xx machine family
5 *
6 * Copyright (C) 2009 ST Microelectronics
7 * Rajeev Kumar<rajeev-dlh.kumar@st.com>
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 .macro disable_fiq
15 .endm
16
17 .macro arch_ret_to_user, tmp1, tmp2
18 .endm
diff --git a/arch/arm/mach-spear6xx/include/mach/system.h b/arch/arm/mach-spear6xx/include/mach/system.h
deleted file mode 100644
index 0b1d2be81cf..00000000000
--- a/arch/arm/mach-spear6xx/include/mach/system.h
+++ /dev/null
@@ -1,19 +0,0 @@
1/*
2 * arch/arm/mach-spear6xx/include/mach/system.h
3 *
4 * SPEAr6xx Machine family specific architecture functions
5 *
6 * Copyright (C) 2009 ST Microelectronics
7 * Rajeev Kumar<rajeev-dlh.kumar@st.com>
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#ifndef __MACH_SYSTEM_H
15#define __MACH_SYSTEM_H
16
17#include <plat/system.h>
18
19#endif /* __MACH_SYSTEM_H */
diff --git a/arch/arm/mach-spear6xx/spear600.c b/arch/arm/mach-spear6xx/spear600.c
deleted file mode 100644
index d0e6eeae9b0..00000000000
--- a/arch/arm/mach-spear6xx/spear600.c
+++ /dev/null
@@ -1,25 +0,0 @@
1/*
2 * arch/arm/mach-spear6xx/spear600.c
3 *
4 * SPEAr600 machine source file
5 *
6 * Copyright (C) 2009 ST Microelectronics
7 * Rajeev Kumar<rajeev-dlh.kumar@st.com>
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/ptrace.h>
15#include <asm/irq.h>
16#include <mach/generic.h>
17#include <mach/hardware.h>
18
19/* Add spear600 specific devices here */
20
21void __init spear600_init(void)
22{
23 /* call spear6xx family common init function */
24 spear6xx_init();
25}
diff --git a/arch/arm/mach-spear6xx/spear600_evb.c b/arch/arm/mach-spear6xx/spear600_evb.c
deleted file mode 100644
index c6e4254741c..00000000000
--- a/arch/arm/mach-spear6xx/spear600_evb.c
+++ /dev/null
@@ -1,54 +0,0 @@
1/*
2 * arch/arm/mach-spear6xx/spear600_evb.c
3 *
4 * SPEAr600 evaluation board source file
5 *
6 * Copyright (C) 2009 ST Microelectronics
7 * Viresh Kumar<viresh.kumar@st.com>
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 <asm/hardware/vic.h>
15#include <asm/mach/arch.h>
16#include <asm/mach-types.h>
17#include <mach/generic.h>
18#include <mach/hardware.h>
19
20static struct amba_device *amba_devs[] __initdata = {
21 &gpio_device[0],
22 &gpio_device[1],
23 &gpio_device[2],
24 &uart_device[0],
25 &uart_device[1],
26};
27
28static struct platform_device *plat_devs[] __initdata = {
29};
30
31static void __init spear600_evb_init(void)
32{
33 unsigned int i;
34
35 /* call spear600 machine init function */
36 spear600_init();
37
38 /* Add Platform Devices */
39 platform_add_devices(plat_devs, ARRAY_SIZE(plat_devs));
40
41 /* Add Amba Devices */
42 for (i = 0; i < ARRAY_SIZE(amba_devs); i++)
43 amba_device_register(amba_devs[i], &iomem_resource);
44}
45
46MACHINE_START(SPEAR600, "ST-SPEAR600-EVB")
47 .atag_offset = 0x100,
48 .map_io = spear6xx_map_io,
49 .init_irq = spear6xx_init_irq,
50 .handle_irq = vic_handle_irq,
51 .timer = &spear6xx_timer,
52 .init_machine = spear600_evb_init,
53 .restart = spear_restart,
54MACHINE_END
diff --git a/arch/arm/mach-spear6xx/spear6xx.c b/arch/arm/mach-spear6xx/spear6xx.c
index e0f6628c8b2..2ed8b14c82c 100644
--- a/arch/arm/mach-spear6xx/spear6xx.c
+++ b/arch/arm/mach-spear6xx/spear6xx.c
@@ -6,111 +6,21 @@
6 * Copyright (C) 2009 ST Microelectronics 6 * Copyright (C) 2009 ST Microelectronics
7 * Rajeev Kumar<rajeev-dlh.kumar@st.com> 7 * Rajeev Kumar<rajeev-dlh.kumar@st.com>
8 * 8 *
9 * Copyright 2012 Stefan Roese <sr@denx.de>
10 *
9 * This file is licensed under the terms of the GNU General Public 11 * This file is licensed under the terms of the GNU General Public
10 * License version 2. This program is licensed "as is" without any 12 * License version 2. This program is licensed "as is" without any
11 * warranty of any kind, whether express or implied. 13 * warranty of any kind, whether express or implied.
12 */ 14 */
13 15
14#include <linux/types.h> 16#include <linux/of.h>
15#include <linux/amba/pl061.h> 17#include <linux/of_address.h>
16#include <linux/ptrace.h> 18#include <linux/of_irq.h>
17#include <linux/io.h> 19#include <linux/of_platform.h>
18#include <asm/hardware/vic.h> 20#include <asm/hardware/vic.h>
19#include <asm/irq.h>
20#include <asm/mach/arch.h> 21#include <asm/mach/arch.h>
21#include <mach/generic.h> 22#include <mach/generic.h>
22#include <mach/hardware.h> 23#include <mach/hardware.h>
23#include <mach/irqs.h>
24
25/* Add spear6xx machines common devices here */
26/* uart device registration */
27struct amba_device uart_device[] = {
28 {
29 .dev = {
30 .init_name = "uart0",
31 },
32 .res = {
33 .start = SPEAR6XX_ICM1_UART0_BASE,
34 .end = SPEAR6XX_ICM1_UART0_BASE + SZ_4K - 1,
35 .flags = IORESOURCE_MEM,
36 },
37 .irq = {IRQ_UART_0, NO_IRQ},
38 }, {
39 .dev = {
40 .init_name = "uart1",
41 },
42 .res = {
43 .start = SPEAR6XX_ICM1_UART1_BASE,
44 .end = SPEAR6XX_ICM1_UART1_BASE + SZ_4K - 1,
45 .flags = IORESOURCE_MEM,
46 },
47 .irq = {IRQ_UART_1, NO_IRQ},
48 }
49};
50
51/* gpio device registration */
52static struct pl061_platform_data gpio_plat_data[] = {
53 {
54 .gpio_base = 0,
55 .irq_base = SPEAR_GPIO0_INT_BASE,
56 }, {
57 .gpio_base = 8,
58 .irq_base = SPEAR_GPIO1_INT_BASE,
59 }, {
60 .gpio_base = 16,
61 .irq_base = SPEAR_GPIO2_INT_BASE,
62 },
63};
64
65struct amba_device gpio_device[] = {
66 {
67 .dev = {
68 .init_name = "gpio0",
69 .platform_data = &gpio_plat_data[0],
70 },
71 .res = {
72 .start = SPEAR6XX_CPU_GPIO_BASE,
73 .end = SPEAR6XX_CPU_GPIO_BASE + SZ_4K - 1,
74 .flags = IORESOURCE_MEM,
75 },
76 .irq = {IRQ_LOCAL_GPIO, NO_IRQ},
77 }, {
78 .dev = {
79 .init_name = "gpio1",
80 .platform_data = &gpio_plat_data[1],
81 },
82 .res = {
83 .start = SPEAR6XX_ICM3_GPIO_BASE,
84 .end = SPEAR6XX_ICM3_GPIO_BASE + SZ_4K - 1,
85 .flags = IORESOURCE_MEM,
86 },
87 .irq = {IRQ_BASIC_GPIO, NO_IRQ},
88 }, {
89 .dev = {
90 .init_name = "gpio2",
91 .platform_data = &gpio_plat_data[2],
92 },
93 .res = {
94 .start = SPEAR6XX_ICM2_GPIO_BASE,
95 .end = SPEAR6XX_ICM2_GPIO_BASE + SZ_4K - 1,
96 .flags = IORESOURCE_MEM,
97 },
98 .irq = {IRQ_APPL_GPIO, NO_IRQ},
99 }
100};
101
102/* This will add devices, and do machine specific tasks */
103void __init spear6xx_init(void)
104{
105 /* nothing to do for now */
106}
107
108/* This will initialize vic */
109void __init spear6xx_init_irq(void)
110{
111 vic_init((void __iomem *)VA_SPEAR6XX_CPU_VIC_PRI_BASE, 0, ~0, 0);
112 vic_init((void __iomem *)VA_SPEAR6XX_CPU_VIC_SEC_BASE, 32, ~0, 0);
113}
114 24
115/* Following will create static virtual/physical mappings */ 25/* Following will create static virtual/physical mappings */
116static struct map_desc spear6xx_io_desc[] __initdata = { 26static struct map_desc spear6xx_io_desc[] __initdata = {
@@ -181,3 +91,33 @@ static void __init spear6xx_timer_init(void)
181struct sys_timer spear6xx_timer = { 91struct sys_timer spear6xx_timer = {
182 .init = spear6xx_timer_init, 92 .init = spear6xx_timer_init,
183}; 93};
94
95static void __init spear600_dt_init(void)
96{
97 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
98}
99
100static const char *spear600_dt_board_compat[] = {
101 "st,spear600",
102 NULL
103};
104
105static const struct of_device_id vic_of_match[] __initconst = {
106 { .compatible = "arm,pl190-vic", .data = vic_of_init, },
107 { /* Sentinel */ }
108};
109
110static void __init spear6xx_dt_init_irq(void)
111{
112 of_irq_init(vic_of_match);
113}
114
115DT_MACHINE_START(SPEAR600_DT, "ST SPEAr600 (Flattened Device Tree)")
116 .map_io = spear6xx_map_io,
117 .init_irq = spear6xx_dt_init_irq,
118 .handle_irq = vic_handle_irq,
119 .timer = &spear6xx_timer,
120 .init_machine = spear600_dt_init,
121 .restart = spear_restart,
122 .dt_compat = spear600_dt_board_compat,
123MACHINE_END
diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig
index 32b420a90c3..d0f2546706c 100644
--- a/arch/arm/mach-tegra/Kconfig
+++ b/arch/arm/mach-tegra/Kconfig
@@ -10,8 +10,16 @@ config ARCH_TEGRA_2x_SOC
10 select PINCTRL 10 select PINCTRL
11 select PINCTRL_TEGRA20 11 select PINCTRL_TEGRA20
12 select USB_ARCH_HAS_EHCI if USB_SUPPORT 12 select USB_ARCH_HAS_EHCI if USB_SUPPORT
13 select USB_ULPI if USB_SUPPORT 13 select USB_ULPI if USB
14 select USB_ULPI_VIEWPORT if USB_SUPPORT 14 select USB_ULPI_VIEWPORT if USB_SUPPORT
15 select ARM_ERRATA_720789
16 select ARM_ERRATA_742230
17 select ARM_ERRATA_751472
18 select ARM_ERRATA_754327
19 select ARM_ERRATA_764369
20 select PL310_ERRATA_727915 if CACHE_L2X0
21 select PL310_ERRATA_769419 if CACHE_L2X0
22 select CPU_FREQ_TABLE if CPU_FREQ
15 help 23 help
16 Support for NVIDIA Tegra AP20 and T20 processors, based on the 24 Support for NVIDIA Tegra AP20 and T20 processors, based on the
17 ARM CortexA9MP CPU and the ARM PL310 L2 cache controller 25 ARM CortexA9MP CPU and the ARM PL310 L2 cache controller
@@ -24,9 +32,15 @@ config ARCH_TEGRA_3x_SOC
24 select PINCTRL 32 select PINCTRL
25 select PINCTRL_TEGRA30 33 select PINCTRL_TEGRA30
26 select USB_ARCH_HAS_EHCI if USB_SUPPORT 34 select USB_ARCH_HAS_EHCI if USB_SUPPORT
27 select USB_ULPI if USB_SUPPORT 35 select USB_ULPI if USB
28 select USB_ULPI_VIEWPORT if USB_SUPPORT 36 select USB_ULPI_VIEWPORT if USB_SUPPORT
29 select USE_OF 37 select USE_OF
38 select ARM_ERRATA_743622
39 select ARM_ERRATA_751472
40 select ARM_ERRATA_754322
41 select ARM_ERRATA_764369
42 select PL310_ERRATA_769419 if CACHE_L2X0
43 select CPU_FREQ_TABLE if CPU_FREQ
30 help 44 help
31 Support for NVIDIA Tegra T30 processor family, based on the 45 Support for NVIDIA Tegra T30 processor family, based on the
32 ARM CortexA9MP CPU and the ARM PL310 L2 cache controller 46 ARM CortexA9MP CPU and the ARM PL310 L2 cache controller
diff --git a/arch/arm/mach-tegra/Makefile b/arch/arm/mach-tegra/Makefile
index e120ff54f66..d87d968115e 100644
--- a/arch/arm/mach-tegra/Makefile
+++ b/arch/arm/mach-tegra/Makefile
@@ -7,15 +7,21 @@ obj-y += clock.o
7obj-y += timer.o 7obj-y += timer.o
8obj-y += pinmux.o 8obj-y += pinmux.o
9obj-y += fuse.o 9obj-y += fuse.o
10obj-y += pmc.o
11obj-y += flowctrl.o
12obj-$(CONFIG_CPU_IDLE) += cpuidle.o
13obj-$(CONFIG_CPU_IDLE) += sleep.o
10obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += powergate.o 14obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += powergate.o
11obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += tegra2_clocks.o 15obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += tegra2_clocks.o
12obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += tegra2_emc.o 16obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += tegra2_emc.o
13obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += pinmux-tegra20-tables.o 17obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += pinmux-tegra20-tables.o
14obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += pinmux-tegra30-tables.o 18obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += pinmux-tegra30-tables.o
15obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += board-dt-tegra30.o 19obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += board-dt-tegra30.o
16obj-$(CONFIG_SMP) += platsmp.o localtimer.o headsmp.o 20obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += tegra30_clocks.o
21obj-$(CONFIG_SMP) += platsmp.o headsmp.o
22obj-$(CONFIG_SMP) += reset.o
17obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o 23obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
18obj-$(CONFIG_TEGRA_SYSTEM_DMA) += dma.o 24obj-$(CONFIG_TEGRA_SYSTEM_DMA) += dma.o apbio.o
19obj-$(CONFIG_CPU_FREQ) += cpu-tegra.o 25obj-$(CONFIG_CPU_FREQ) += cpu-tegra.o
20obj-$(CONFIG_TEGRA_PCI) += pcie.o 26obj-$(CONFIG_TEGRA_PCI) += pcie.o
21obj-$(CONFIG_USB_SUPPORT) += usb_phy.o 27obj-$(CONFIG_USB_SUPPORT) += usb_phy.o
diff --git a/arch/arm/mach-tegra/apbio.c b/arch/arm/mach-tegra/apbio.c
new file mode 100644
index 00000000000..e75451e517b
--- /dev/null
+++ b/arch/arm/mach-tegra/apbio.c
@@ -0,0 +1,145 @@
1/*
2 * Copyright (C) 2010 NVIDIA Corporation.
3 * Copyright (C) 2010 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#include <linux/io.h>
18#include <linux/dma-mapping.h>
19#include <linux/spinlock.h>
20#include <linux/completion.h>
21#include <linux/sched.h>
22#include <linux/mutex.h>
23
24#include <mach/dma.h>
25#include <mach/iomap.h>
26
27#include "apbio.h"
28
29static DEFINE_MUTEX(tegra_apb_dma_lock);
30
31static struct tegra_dma_channel *tegra_apb_dma;
32static u32 *tegra_apb_bb;
33static dma_addr_t tegra_apb_bb_phys;
34static DECLARE_COMPLETION(tegra_apb_wait);
35
36bool tegra_apb_init(void)
37{
38 struct tegra_dma_channel *ch;
39
40 mutex_lock(&tegra_apb_dma_lock);
41
42 /* Check to see if we raced to setup */
43 if (tegra_apb_dma)
44 goto out;
45
46 ch = tegra_dma_allocate_channel(TEGRA_DMA_MODE_ONESHOT |
47 TEGRA_DMA_SHARED);
48
49 if (!ch)
50 goto out_fail;
51
52 tegra_apb_bb = dma_alloc_coherent(NULL, sizeof(u32),
53 &tegra_apb_bb_phys, GFP_KERNEL);
54 if (!tegra_apb_bb) {
55 pr_err("%s: can not allocate bounce buffer\n", __func__);
56 tegra_dma_free_channel(ch);
57 goto out_fail;
58 }
59
60 tegra_apb_dma = ch;
61out:
62 mutex_unlock(&tegra_apb_dma_lock);
63 return true;
64
65out_fail:
66 mutex_unlock(&tegra_apb_dma_lock);
67 return false;
68}
69
70static void apb_dma_complete(struct tegra_dma_req *req)
71{
72 complete(&tegra_apb_wait);
73}
74
75u32 tegra_apb_readl(unsigned long offset)
76{
77 struct tegra_dma_req req;
78 int ret;
79
80 if (!tegra_apb_dma && !tegra_apb_init())
81 return readl(IO_TO_VIRT(offset));
82
83 mutex_lock(&tegra_apb_dma_lock);
84 req.complete = apb_dma_complete;
85 req.to_memory = 1;
86 req.dest_addr = tegra_apb_bb_phys;
87 req.dest_bus_width = 32;
88 req.dest_wrap = 1;
89 req.source_addr = offset;
90 req.source_bus_width = 32;
91 req.source_wrap = 4;
92 req.req_sel = TEGRA_DMA_REQ_SEL_CNTR;
93 req.size = 4;
94
95 INIT_COMPLETION(tegra_apb_wait);
96
97 tegra_dma_enqueue_req(tegra_apb_dma, &req);
98
99 ret = wait_for_completion_timeout(&tegra_apb_wait,
100 msecs_to_jiffies(50));
101
102 if (WARN(ret == 0, "apb read dma timed out")) {
103 tegra_dma_dequeue_req(tegra_apb_dma, &req);
104 *(u32 *)tegra_apb_bb = 0;
105 }
106
107 mutex_unlock(&tegra_apb_dma_lock);
108 return *((u32 *)tegra_apb_bb);
109}
110
111void tegra_apb_writel(u32 value, unsigned long offset)
112{
113 struct tegra_dma_req req;
114 int ret;
115
116 if (!tegra_apb_dma && !tegra_apb_init()) {
117 writel(value, IO_TO_VIRT(offset));
118 return;
119 }
120
121 mutex_lock(&tegra_apb_dma_lock);
122 *((u32 *)tegra_apb_bb) = value;
123 req.complete = apb_dma_complete;
124 req.to_memory = 0;
125 req.dest_addr = offset;
126 req.dest_wrap = 4;
127 req.dest_bus_width = 32;
128 req.source_addr = tegra_apb_bb_phys;
129 req.source_bus_width = 32;
130 req.source_wrap = 1;
131 req.req_sel = TEGRA_DMA_REQ_SEL_CNTR;
132 req.size = 4;
133
134 INIT_COMPLETION(tegra_apb_wait);
135
136 tegra_dma_enqueue_req(tegra_apb_dma, &req);
137
138 ret = wait_for_completion_timeout(&tegra_apb_wait,
139 msecs_to_jiffies(50));
140
141 if (WARN(ret == 0, "apb write dma timed out"))
142 tegra_dma_dequeue_req(tegra_apb_dma, &req);
143
144 mutex_unlock(&tegra_apb_dma_lock);
145}
diff --git a/arch/arm/mach-tegra/include/mach/system.h b/arch/arm/mach-tegra/apbio.h
index a312988bf6f..8b49e8c89a6 100644
--- a/arch/arm/mach-tegra/include/mach/system.h
+++ b/arch/arm/mach-tegra/apbio.h
@@ -1,12 +1,7 @@
1/* 1/*
2 * arch/arm/mach-tegra/include/mach/system.h 2 * Copyright (C) 2010 NVIDIA Corporation.
3 *
4 * Copyright (C) 2010 Google, Inc. 3 * Copyright (C) 2010 Google, Inc.
5 * 4 *
6 * Author:
7 * Colin Cross <ccross@google.com>
8 * Erik Gilling <konkers@google.com>
9 *
10 * This software is licensed under the terms of the GNU General Public 5 * This software is licensed under the terms of the GNU General Public
11 * License version 2, as published by the Free Software Foundation, and 6 * License version 2, as published by the Free Software Foundation, and
12 * may be copied, distributed, and modified under those terms. 7 * may be copied, distributed, and modified under those terms.
@@ -18,11 +13,27 @@
18 * 13 *
19 */ 14 */
20 15
21#ifndef __MACH_TEGRA_SYSTEM_H 16#ifndef __MACH_TEGRA_APBIO_H
22#define __MACH_TEGRA_SYSTEM_H 17#define __MACH_TEGRA_APBIO_H
18
19#ifdef CONFIG_TEGRA_SYSTEM_DMA
20
21u32 tegra_apb_readl(unsigned long offset);
22void tegra_apb_writel(u32 value, unsigned long offset);
23
24#else
25#include <asm/io.h>
26#include <mach/io.h>
23 27
24static inline void arch_idle(void) 28static inline u32 tegra_apb_readl(unsigned long offset)
25{ 29{
30 return readl(IO_TO_VIRT(offset));
26} 31}
27 32
33static inline void tegra_apb_writel(u32 value, unsigned long offset)
34{
35 writel(value, IO_TO_VIRT(offset));
36}
37#endif
38
28#endif 39#endif
diff --git a/arch/arm/mach-tegra/board-dt-tegra20.c b/arch/arm/mach-tegra/board-dt-tegra20.c
index 7a95e0bc4ab..e20b419d598 100644
--- a/arch/arm/mach-tegra/board-dt-tegra20.c
+++ b/arch/arm/mach-tegra/board-dt-tegra20.c
@@ -131,11 +131,7 @@ static void __init tegra_dt_init(void)
131} 131}
132 132
133static const char *tegra20_dt_board_compat[] = { 133static const char *tegra20_dt_board_compat[] = {
134 "compulab,trimslice", 134 "nvidia,tegra20",
135 "nvidia,harmony",
136 "compal,paz00",
137 "nvidia,seaboard",
138 "nvidia,ventana",
139 NULL 135 NULL
140}; 136};
141 137
diff --git a/arch/arm/mach-tegra/board-dt-tegra30.c b/arch/arm/mach-tegra/board-dt-tegra30.c
index 3c197e2440b..5f7c03e972f 100644
--- a/arch/arm/mach-tegra/board-dt-tegra30.c
+++ b/arch/arm/mach-tegra/board-dt-tegra30.c
@@ -34,20 +34,42 @@
34#include <asm/hardware/gic.h> 34#include <asm/hardware/gic.h>
35 35
36#include "board.h" 36#include "board.h"
37#include "clock.h"
37 38
38static struct of_device_id tegra_dt_match_table[] __initdata = { 39static struct of_device_id tegra_dt_match_table[] __initdata = {
39 { .compatible = "simple-bus", }, 40 { .compatible = "simple-bus", },
40 {} 41 {}
41}; 42};
42 43
44struct of_dev_auxdata tegra30_auxdata_lookup[] __initdata = {
45 OF_DEV_AUXDATA("nvidia,tegra20-sdhci", 0x78000000, "sdhci-tegra.0", NULL),
46 OF_DEV_AUXDATA("nvidia,tegra20-sdhci", 0x78000200, "sdhci-tegra.1", NULL),
47 OF_DEV_AUXDATA("nvidia,tegra20-sdhci", 0x78000400, "sdhci-tegra.2", NULL),
48 OF_DEV_AUXDATA("nvidia,tegra20-sdhci", 0x78000600, "sdhci-tegra.3", NULL),
49 OF_DEV_AUXDATA("nvidia,tegra20-i2c", 0x7000C000, "tegra-i2c.0", NULL),
50 OF_DEV_AUXDATA("nvidia,tegra20-i2c", 0x7000C400, "tegra-i2c.1", NULL),
51 OF_DEV_AUXDATA("nvidia,tegra20-i2c", 0x7000C500, "tegra-i2c.2", NULL),
52 OF_DEV_AUXDATA("nvidia,tegra20-i2c", 0x7000C700, "tegra-i2c.3", NULL),
53 OF_DEV_AUXDATA("nvidia,tegra20-i2c", 0x7000D000, "tegra-i2c.4", NULL),
54 {}
55};
56
57static __initdata struct tegra_clk_init_table tegra_dt_clk_init_table[] = {
58 /* name parent rate enabled */
59 { "uarta", "pll_p", 408000000, true },
60 { NULL, NULL, 0, 0},
61};
62
43static void __init tegra30_dt_init(void) 63static void __init tegra30_dt_init(void)
44{ 64{
65 tegra_clk_init_from_table(tegra_dt_clk_init_table);
66
45 of_platform_populate(NULL, tegra_dt_match_table, 67 of_platform_populate(NULL, tegra_dt_match_table,
46 NULL, NULL); 68 tegra30_auxdata_lookup, NULL);
47} 69}
48 70
49static const char *tegra30_dt_board_compat[] = { 71static const char *tegra30_dt_board_compat[] = {
50 "nvidia,cardhu", 72 "nvidia,tegra30",
51 NULL 73 NULL
52}; 74};
53 75
diff --git a/arch/arm/mach-tegra/board-harmony-pinmux.c b/arch/arm/mach-tegra/board-harmony-pinmux.c
index 465808c8ac0..1af85bccc0f 100644
--- a/arch/arm/mach-tegra/board-harmony-pinmux.c
+++ b/arch/arm/mach-tegra/board-harmony-pinmux.c
@@ -53,7 +53,7 @@ static struct tegra_pingroup_config harmony_pinmux[] = {
53 {TEGRA_PINGROUP_GME, TEGRA_MUX_SDIO4, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL}, 53 {TEGRA_PINGROUP_GME, TEGRA_MUX_SDIO4, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL},
54 {TEGRA_PINGROUP_GPU, TEGRA_MUX_GMI, TEGRA_PUPD_NORMAL, TEGRA_TRI_TRISTATE}, 54 {TEGRA_PINGROUP_GPU, TEGRA_MUX_GMI, TEGRA_PUPD_NORMAL, TEGRA_TRI_TRISTATE},
55 {TEGRA_PINGROUP_GPU7, TEGRA_MUX_RTCK, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL}, 55 {TEGRA_PINGROUP_GPU7, TEGRA_MUX_RTCK, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL},
56 {TEGRA_PINGROUP_GPV, TEGRA_MUX_PCIE, TEGRA_PUPD_NORMAL, TEGRA_TRI_TRISTATE}, 56 {TEGRA_PINGROUP_GPV, TEGRA_MUX_PCIE, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL},
57 {TEGRA_PINGROUP_HDINT, TEGRA_MUX_HDMI, TEGRA_PUPD_PULL_UP, TEGRA_TRI_TRISTATE}, 57 {TEGRA_PINGROUP_HDINT, TEGRA_MUX_HDMI, TEGRA_PUPD_PULL_UP, TEGRA_TRI_TRISTATE},
58 {TEGRA_PINGROUP_I2CP, TEGRA_MUX_I2C, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL}, 58 {TEGRA_PINGROUP_I2CP, TEGRA_MUX_I2C, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL},
59 {TEGRA_PINGROUP_IRRX, TEGRA_MUX_UARTA, TEGRA_PUPD_PULL_UP, TEGRA_TRI_TRISTATE}, 59 {TEGRA_PINGROUP_IRRX, TEGRA_MUX_UARTA, TEGRA_PUPD_PULL_UP, TEGRA_TRI_TRISTATE},
@@ -112,10 +112,10 @@ static struct tegra_pingroup_config harmony_pinmux[] = {
112 {TEGRA_PINGROUP_SDC, TEGRA_MUX_PWM, TEGRA_PUPD_PULL_UP, TEGRA_TRI_NORMAL}, 112 {TEGRA_PINGROUP_SDC, TEGRA_MUX_PWM, TEGRA_PUPD_PULL_UP, TEGRA_TRI_NORMAL},
113 {TEGRA_PINGROUP_SDD, TEGRA_MUX_PWM, TEGRA_PUPD_PULL_UP, TEGRA_TRI_TRISTATE}, 113 {TEGRA_PINGROUP_SDD, TEGRA_MUX_PWM, TEGRA_PUPD_PULL_UP, TEGRA_TRI_TRISTATE},
114 {TEGRA_PINGROUP_SDIO1, TEGRA_MUX_SDIO1, TEGRA_PUPD_NORMAL, TEGRA_TRI_TRISTATE}, 114 {TEGRA_PINGROUP_SDIO1, TEGRA_MUX_SDIO1, TEGRA_PUPD_NORMAL, TEGRA_TRI_TRISTATE},
115 {TEGRA_PINGROUP_SLXA, TEGRA_MUX_PCIE, TEGRA_PUPD_NORMAL, TEGRA_TRI_TRISTATE}, 115 {TEGRA_PINGROUP_SLXA, TEGRA_MUX_PCIE, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL},
116 {TEGRA_PINGROUP_SLXC, TEGRA_MUX_SPDIF, TEGRA_PUPD_NORMAL, TEGRA_TRI_TRISTATE}, 116 {TEGRA_PINGROUP_SLXC, TEGRA_MUX_SPDIF, TEGRA_PUPD_NORMAL, TEGRA_TRI_TRISTATE},
117 {TEGRA_PINGROUP_SLXD, TEGRA_MUX_SPDIF, TEGRA_PUPD_NORMAL, TEGRA_TRI_TRISTATE}, 117 {TEGRA_PINGROUP_SLXD, TEGRA_MUX_SPDIF, TEGRA_PUPD_NORMAL, TEGRA_TRI_TRISTATE},
118 {TEGRA_PINGROUP_SLXK, TEGRA_MUX_PCIE, TEGRA_PUPD_NORMAL, TEGRA_TRI_TRISTATE}, 118 {TEGRA_PINGROUP_SLXK, TEGRA_MUX_PCIE, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL},
119 {TEGRA_PINGROUP_SPDI, TEGRA_MUX_RSVD2, TEGRA_PUPD_NORMAL, TEGRA_TRI_TRISTATE}, 119 {TEGRA_PINGROUP_SPDI, TEGRA_MUX_RSVD2, TEGRA_PUPD_NORMAL, TEGRA_TRI_TRISTATE},
120 {TEGRA_PINGROUP_SPDO, TEGRA_MUX_RSVD2, TEGRA_PUPD_NORMAL, TEGRA_TRI_TRISTATE}, 120 {TEGRA_PINGROUP_SPDO, TEGRA_MUX_RSVD2, TEGRA_PUPD_NORMAL, TEGRA_TRI_TRISTATE},
121 {TEGRA_PINGROUP_SPIA, TEGRA_MUX_GMI, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL}, 121 {TEGRA_PINGROUP_SPIA, TEGRA_MUX_GMI, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL},
diff --git a/arch/arm/mach-tegra/board-harmony-power.c b/arch/arm/mach-tegra/board-harmony-power.c
index 21d1285731b..82f32300796 100644
--- a/arch/arm/mach-tegra/board-harmony-power.c
+++ b/arch/arm/mach-tegra/board-harmony-power.c
@@ -18,31 +18,27 @@
18#include <linux/i2c.h> 18#include <linux/i2c.h>
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/io.h>
22#include <linux/regulator/machine.h> 21#include <linux/regulator/machine.h>
23#include <linux/mfd/tps6586x.h> 22#include <linux/mfd/tps6586x.h>
24 23
25#include <mach/iomap.h>
26#include <mach/irqs.h> 24#include <mach/irqs.h>
27 25
28#include "board-harmony.h" 26#include "board-harmony.h"
29 27
30#define PMC_CTRL 0x0
31#define PMC_CTRL_INTR_LOW (1 << 17)
32
33static struct regulator_consumer_supply tps658621_ldo0_supply[] = { 28static struct regulator_consumer_supply tps658621_ldo0_supply[] = {
34 REGULATOR_SUPPLY("pex_clk", NULL), 29 REGULATOR_SUPPLY("pex_clk", NULL),
35}; 30};
36 31
37static struct regulator_init_data ldo0_data = { 32static struct regulator_init_data ldo0_data = {
38 .constraints = { 33 .constraints = {
39 .min_uV = 1250 * 1000, 34 .min_uV = 3300 * 1000,
40 .max_uV = 3300 * 1000, 35 .max_uV = 3300 * 1000,
41 .valid_modes_mask = (REGULATOR_MODE_NORMAL | 36 .valid_modes_mask = (REGULATOR_MODE_NORMAL |
42 REGULATOR_MODE_STANDBY), 37 REGULATOR_MODE_STANDBY),
43 .valid_ops_mask = (REGULATOR_CHANGE_MODE | 38 .valid_ops_mask = (REGULATOR_CHANGE_MODE |
44 REGULATOR_CHANGE_STATUS | 39 REGULATOR_CHANGE_STATUS |
45 REGULATOR_CHANGE_VOLTAGE), 40 REGULATOR_CHANGE_VOLTAGE),
41 .apply_uV = 1,
46 }, 42 },
47 .num_consumer_supplies = ARRAY_SIZE(tps658621_ldo0_supply), 43 .num_consumer_supplies = ARRAY_SIZE(tps658621_ldo0_supply),
48 .consumer_supplies = tps658621_ldo0_supply, 44 .consumer_supplies = tps658621_ldo0_supply,
@@ -114,16 +110,6 @@ static struct i2c_board_info __initdata harmony_regulators[] = {
114 110
115int __init harmony_regulator_init(void) 111int __init harmony_regulator_init(void)
116{ 112{
117 void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE);
118 u32 pmc_ctrl;
119
120 /*
121 * Configure the power management controller to trigger PMU
122 * interrupts when low
123 */
124 pmc_ctrl = readl(pmc + PMC_CTRL);
125 writel(pmc_ctrl | PMC_CTRL_INTR_LOW, pmc + PMC_CTRL);
126
127 i2c_register_board_info(3, harmony_regulators, 1); 113 i2c_register_board_info(3, harmony_regulators, 1);
128 114
129 return 0; 115 return 0;
diff --git a/arch/arm/mach-tegra/board-harmony.c b/arch/arm/mach-tegra/board-harmony.c
index 789bdc9e8f9..c00aadb01e0 100644
--- a/arch/arm/mach-tegra/board-harmony.c
+++ b/arch/arm/mach-tegra/board-harmony.c
@@ -101,7 +101,6 @@ static struct wm8903_platform_data harmony_wm8903_pdata = {
101static struct i2c_board_info __initdata wm8903_board_info = { 101static struct i2c_board_info __initdata wm8903_board_info = {
102 I2C_BOARD_INFO("wm8903", 0x1a), 102 I2C_BOARD_INFO("wm8903", 0x1a),
103 .platform_data = &harmony_wm8903_pdata, 103 .platform_data = &harmony_wm8903_pdata,
104 .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_CDC_IRQ),
105}; 104};
106 105
107static void __init harmony_i2c_init(void) 106static void __init harmony_i2c_init(void)
@@ -111,6 +110,7 @@ static void __init harmony_i2c_init(void)
111 platform_device_register(&tegra_i2c_device3); 110 platform_device_register(&tegra_i2c_device3);
112 platform_device_register(&tegra_i2c_device4); 111 platform_device_register(&tegra_i2c_device4);
113 112
113 wm8903_board_info.irq = gpio_to_irq(TEGRA_GPIO_CDC_IRQ);
114 i2c_register_board_info(0, &wm8903_board_info, 1); 114 i2c_register_board_info(0, &wm8903_board_info, 1);
115} 115}
116 116
diff --git a/arch/arm/mach-tegra/board-seaboard.c b/arch/arm/mach-tegra/board-seaboard.c
index ebac65f5251..d669847f048 100644
--- a/arch/arm/mach-tegra/board-seaboard.c
+++ b/arch/arm/mach-tegra/board-seaboard.c
@@ -159,7 +159,6 @@ static struct platform_device *seaboard_devices[] __initdata = {
159 159
160static struct i2c_board_info __initdata isl29018_device = { 160static struct i2c_board_info __initdata isl29018_device = {
161 I2C_BOARD_INFO("isl29018", 0x44), 161 I2C_BOARD_INFO("isl29018", 0x44),
162 .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_ISL29018_IRQ),
163}; 162};
164 163
165static struct i2c_board_info __initdata adt7461_device = { 164static struct i2c_board_info __initdata adt7461_device = {
@@ -183,7 +182,6 @@ static struct wm8903_platform_data wm8903_pdata = {
183static struct i2c_board_info __initdata wm8903_device = { 182static struct i2c_board_info __initdata wm8903_device = {
184 I2C_BOARD_INFO("wm8903", 0x1a), 183 I2C_BOARD_INFO("wm8903", 0x1a),
185 .platform_data = &wm8903_pdata, 184 .platform_data = &wm8903_pdata,
186 .irq = TEGRA_GPIO_TO_IRQ(TEGRA_GPIO_CDC_IRQ),
187}; 185};
188 186
189static int seaboard_ehci_init(void) 187static int seaboard_ehci_init(void)
@@ -214,7 +212,10 @@ static void __init seaboard_i2c_init(void)
214 gpio_request(TEGRA_GPIO_ISL29018_IRQ, "isl29018"); 212 gpio_request(TEGRA_GPIO_ISL29018_IRQ, "isl29018");
215 gpio_direction_input(TEGRA_GPIO_ISL29018_IRQ); 213 gpio_direction_input(TEGRA_GPIO_ISL29018_IRQ);
216 214
215 isl29018_device.irq = gpio_to_irq(TEGRA_GPIO_ISL29018_IRQ);
217 i2c_register_board_info(0, &isl29018_device, 1); 216 i2c_register_board_info(0, &isl29018_device, 1);
217
218 wm8903_device.irq = gpio_to_irq(TEGRA_GPIO_CDC_IRQ);
218 i2c_register_board_info(0, &wm8903_device, 1); 219 i2c_register_board_info(0, &wm8903_device, 1);
219 220
220 i2c_register_board_info(3, &adt7461_device, 1); 221 i2c_register_board_info(3, &adt7461_device, 1);
diff --git a/arch/arm/mach-tegra/clock.c b/arch/arm/mach-tegra/clock.c
index 8337068a4ab..8dad8d18cb4 100644
--- a/arch/arm/mach-tegra/clock.c
+++ b/arch/arm/mach-tegra/clock.c
@@ -399,6 +399,28 @@ void tegra_periph_reset_assert(struct clk *c)
399} 399}
400EXPORT_SYMBOL(tegra_periph_reset_assert); 400EXPORT_SYMBOL(tegra_periph_reset_assert);
401 401
402/* Several extended clock configuration bits (e.g., clock routing, clock
403 * phase control) are included in PLL and peripheral clock source
404 * registers. */
405int tegra_clk_cfg_ex(struct clk *c, enum tegra_clk_ex_param p, u32 setting)
406{
407 int ret = 0;
408 unsigned long flags;
409
410 spin_lock_irqsave(&c->spinlock, flags);
411
412 if (!c->ops || !c->ops->clk_cfg_ex) {
413 ret = -ENOSYS;
414 goto out;
415 }
416 ret = c->ops->clk_cfg_ex(c, p, setting);
417
418out:
419 spin_unlock_irqrestore(&c->spinlock, flags);
420
421 return ret;
422}
423
402#ifdef CONFIG_DEBUG_FS 424#ifdef CONFIG_DEBUG_FS
403 425
404static int __clk_lock_all_spinlocks(void) 426static int __clk_lock_all_spinlocks(void)
diff --git a/arch/arm/mach-tegra/clock.h b/arch/arm/mach-tegra/clock.h
index 5c44106616c..bc300657deb 100644
--- a/arch/arm/mach-tegra/clock.h
+++ b/arch/arm/mach-tegra/clock.h
@@ -24,6 +24,8 @@
24#include <linux/list.h> 24#include <linux/list.h>
25#include <linux/spinlock.h> 25#include <linux/spinlock.h>
26 26
27#include <mach/clk.h>
28
27#define DIV_BUS (1 << 0) 29#define DIV_BUS (1 << 0)
28#define DIV_U71 (1 << 1) 30#define DIV_U71 (1 << 1)
29#define DIV_U71_FIXED (1 << 2) 31#define DIV_U71_FIXED (1 << 2)
@@ -39,7 +41,16 @@
39#define PERIPH_MANUAL_RESET (1 << 12) 41#define PERIPH_MANUAL_RESET (1 << 12)
40#define PLL_ALT_MISC_REG (1 << 13) 42#define PLL_ALT_MISC_REG (1 << 13)
41#define PLLU (1 << 14) 43#define PLLU (1 << 14)
44#define PLLX (1 << 15)
45#define MUX_PWM (1 << 16)
46#define MUX8 (1 << 17)
47#define DIV_U71_UART (1 << 18)
48#define MUX_CLK_OUT (1 << 19)
49#define PLLM (1 << 20)
50#define DIV_U71_INT (1 << 21)
51#define DIV_U71_IDLE (1 << 22)
42#define ENABLE_ON_INIT (1 << 28) 52#define ENABLE_ON_INIT (1 << 28)
53#define PERIPH_ON_APB (1 << 29)
43 54
44struct clk; 55struct clk;
45 56
@@ -65,6 +76,8 @@ struct clk_ops {
65 int (*set_rate)(struct clk *, unsigned long); 76 int (*set_rate)(struct clk *, unsigned long);
66 long (*round_rate)(struct clk *, unsigned long); 77 long (*round_rate)(struct clk *, unsigned long);
67 void (*reset)(struct clk *, bool); 78 void (*reset)(struct clk *, bool);
79 int (*clk_cfg_ex)(struct clk *,
80 enum tegra_clk_ex_param, u32);
68}; 81};
69 82
70enum clk_state { 83enum clk_state {
@@ -114,6 +127,7 @@ struct clk {
114 unsigned long vco_max; 127 unsigned long vco_max;
115 const struct clk_pll_freq_table *freq_table; 128 const struct clk_pll_freq_table *freq_table;
116 int lock_delay; 129 int lock_delay;
130 unsigned long fixed_rate;
117 } pll; 131 } pll;
118 struct { 132 struct {
119 u32 sel; 133 u32 sel;
@@ -146,6 +160,7 @@ struct tegra_clk_init_table {
146}; 160};
147 161
148void tegra2_init_clocks(void); 162void tegra2_init_clocks(void);
163void tegra30_init_clocks(void);
149void clk_init(struct clk *clk); 164void clk_init(struct clk *clk);
150struct clk *tegra_get_clock_by_name(const char *name); 165struct clk *tegra_get_clock_by_name(const char *name);
151int clk_reparent(struct clk *c, struct clk *parent); 166int clk_reparent(struct clk *c, struct clk *parent);
diff --git a/arch/arm/mach-tegra/common.c b/arch/arm/mach-tegra/common.c
index a2eb90169ae..22df10fb997 100644
--- a/arch/arm/mach-tegra/common.c
+++ b/arch/arm/mach-tegra/common.c
@@ -27,11 +27,29 @@
27#include <asm/hardware/gic.h> 27#include <asm/hardware/gic.h>
28 28
29#include <mach/iomap.h> 29#include <mach/iomap.h>
30#include <mach/system.h> 30#include <mach/powergate.h>
31 31
32#include "board.h" 32#include "board.h"
33#include "clock.h" 33#include "clock.h"
34#include "fuse.h" 34#include "fuse.h"
35#include "pmc.h"
36
37/*
38 * Storage for debug-macro.S's state.
39 *
40 * This must be in .data not .bss so that it gets initialized each time the
41 * kernel is loaded. The data is declared here rather than debug-macro.S so
42 * that multiple inclusions of debug-macro.S point at the same data.
43 */
44#define TEGRA_DEBUG_UART_OFFSET (TEGRA_DEBUG_UART_BASE & 0xFFFF)
45u32 tegra_uart_config[3] = {
46 /* Debug UART initialization required */
47 1,
48 /* Debug UART physical address */
49 (u32)(IO_APB_PHYS + TEGRA_DEBUG_UART_OFFSET),
50 /* Debug UART virtual address */
51 (u32)(IO_APB_VIRT + TEGRA_DEBUG_UART_OFFSET),
52};
35 53
36#ifdef CONFIG_OF 54#ifdef CONFIG_OF
37static const struct of_device_id tegra_dt_irq_match[] __initconst = { 55static const struct of_device_id tegra_dt_irq_match[] __initconst = {
@@ -100,11 +118,17 @@ void __init tegra20_init_early(void)
100 tegra2_init_clocks(); 118 tegra2_init_clocks();
101 tegra_clk_init_from_table(tegra20_clk_init_table); 119 tegra_clk_init_from_table(tegra20_clk_init_table);
102 tegra_init_cache(0x331, 0x441); 120 tegra_init_cache(0x331, 0x441);
121 tegra_pmc_init();
122 tegra_powergate_init();
103} 123}
104#endif 124#endif
105#ifdef CONFIG_ARCH_TEGRA_3x_SOC 125#ifdef CONFIG_ARCH_TEGRA_3x_SOC
106void __init tegra30_init_early(void) 126void __init tegra30_init_early(void)
107{ 127{
128 tegra_init_fuse();
129 tegra30_init_clocks();
108 tegra_init_cache(0x441, 0x551); 130 tegra_init_cache(0x441, 0x551);
131 tegra_pmc_init();
132 tegra_powergate_init();
109} 133}
110#endif 134#endif
diff --git a/arch/arm/mach-tegra/cpuidle.c b/arch/arm/mach-tegra/cpuidle.c
new file mode 100644
index 00000000000..d83a8c0296f
--- /dev/null
+++ b/arch/arm/mach-tegra/cpuidle.c
@@ -0,0 +1,107 @@
1/*
2 * arch/arm/mach-tegra/cpuidle.c
3 *
4 * CPU idle driver for Tegra CPUs
5 *
6 * Copyright (c) 2010-2012, NVIDIA Corporation.
7 * Copyright (c) 2011 Google, Inc.
8 * Author: Colin Cross <ccross@android.com>
9 * Gary King <gking@nvidia.com>
10 *
11 * Rework for 3.3 by Peter De Schrijver <pdeschrijver@nvidia.com>
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful, but WITHOUT
19 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
21 * more details.
22 */
23
24#include <linux/kernel.h>
25#include <linux/module.h>
26#include <linux/cpu.h>
27#include <linux/cpuidle.h>
28#include <linux/hrtimer.h>
29
30#include <mach/iomap.h>
31
32extern void tegra_cpu_wfi(void);
33
34static int tegra_idle_enter_lp3(struct cpuidle_device *dev,
35 struct cpuidle_driver *drv, int index);
36
37struct cpuidle_driver tegra_idle_driver = {
38 .name = "tegra_idle",
39 .owner = THIS_MODULE,
40 .state_count = 1,
41 .states = {
42 [0] = {
43 .enter = tegra_idle_enter_lp3,
44 .exit_latency = 10,
45 .target_residency = 10,
46 .power_usage = 600,
47 .flags = CPUIDLE_FLAG_TIME_VALID,
48 .name = "LP3",
49 .desc = "CPU flow-controlled",
50 },
51 },
52};
53
54static DEFINE_PER_CPU(struct cpuidle_device, tegra_idle_device);
55
56static int tegra_idle_enter_lp3(struct cpuidle_device *dev,
57 struct cpuidle_driver *drv, int index)
58{
59 ktime_t enter, exit;
60 s64 us;
61
62 local_irq_disable();
63 local_fiq_disable();
64
65 enter = ktime_get();
66
67 tegra_cpu_wfi();
68
69 exit = ktime_sub(ktime_get(), enter);
70 us = ktime_to_us(exit);
71
72 local_fiq_enable();
73 local_irq_enable();
74
75 dev->last_residency = us;
76
77 return index;
78}
79
80static int __init tegra_cpuidle_init(void)
81{
82 int ret;
83 unsigned int cpu;
84 struct cpuidle_device *dev;
85 struct cpuidle_driver *drv = &tegra_idle_driver;
86
87 ret = cpuidle_register_driver(&tegra_idle_driver);
88 if (ret) {
89 pr_err("CPUidle driver registration failed\n");
90 return ret;
91 }
92
93 for_each_possible_cpu(cpu) {
94 dev = &per_cpu(tegra_idle_device, cpu);
95 dev->cpu = cpu;
96
97 dev->state_count = drv->state_count;
98 ret = cpuidle_register_device(dev);
99 if (ret) {
100 pr_err("CPU%u: CPUidle device registration failed\n",
101 cpu);
102 return ret;
103 }
104 }
105 return 0;
106}
107device_initcall(tegra_cpuidle_init);
diff --git a/arch/arm/mach-tegra/dma.c b/arch/arm/mach-tegra/dma.c
index c0cf967e47d..abea4f6e2dd 100644
--- a/arch/arm/mach-tegra/dma.c
+++ b/arch/arm/mach-tegra/dma.c
@@ -33,6 +33,8 @@
33#include <mach/iomap.h> 33#include <mach/iomap.h>
34#include <mach/suspend.h> 34#include <mach/suspend.h>
35 35
36#include "apbio.h"
37
36#define APB_DMA_GEN 0x000 38#define APB_DMA_GEN 0x000
37#define GEN_ENABLE (1<<31) 39#define GEN_ENABLE (1<<31)
38 40
@@ -50,8 +52,6 @@
50#define CSR_ONCE (1<<27) 52#define CSR_ONCE (1<<27)
51#define CSR_FLOW (1<<21) 53#define CSR_FLOW (1<<21)
52#define CSR_REQ_SEL_SHIFT 16 54#define CSR_REQ_SEL_SHIFT 16
53#define CSR_REQ_SEL_MASK (0x1F<<CSR_REQ_SEL_SHIFT)
54#define CSR_REQ_SEL_INVALID (31<<CSR_REQ_SEL_SHIFT)
55#define CSR_WCOUNT_SHIFT 2 55#define CSR_WCOUNT_SHIFT 2
56#define CSR_WCOUNT_MASK 0xFFFC 56#define CSR_WCOUNT_MASK 0xFFFC
57 57
@@ -133,6 +133,7 @@ struct tegra_dma_channel {
133 133
134static bool tegra_dma_initialized; 134static bool tegra_dma_initialized;
135static DEFINE_MUTEX(tegra_dma_lock); 135static DEFINE_MUTEX(tegra_dma_lock);
136static DEFINE_SPINLOCK(enable_lock);
136 137
137static DECLARE_BITMAP(channel_usage, NV_DMA_MAX_CHANNELS); 138static DECLARE_BITMAP(channel_usage, NV_DMA_MAX_CHANNELS);
138static struct tegra_dma_channel dma_channels[NV_DMA_MAX_CHANNELS]; 139static struct tegra_dma_channel dma_channels[NV_DMA_MAX_CHANNELS];
@@ -180,36 +181,94 @@ static void tegra_dma_stop(struct tegra_dma_channel *ch)
180 181
181static int tegra_dma_cancel(struct tegra_dma_channel *ch) 182static int tegra_dma_cancel(struct tegra_dma_channel *ch)
182{ 183{
183 u32 csr;
184 unsigned long irq_flags; 184 unsigned long irq_flags;
185 185
186 spin_lock_irqsave(&ch->lock, irq_flags); 186 spin_lock_irqsave(&ch->lock, irq_flags);
187 while (!list_empty(&ch->list)) 187 while (!list_empty(&ch->list))
188 list_del(ch->list.next); 188 list_del(ch->list.next);
189 189
190 csr = readl(ch->addr + APB_DMA_CHAN_CSR);
191 csr &= ~CSR_REQ_SEL_MASK;
192 csr |= CSR_REQ_SEL_INVALID;
193 writel(csr, ch->addr + APB_DMA_CHAN_CSR);
194
195 tegra_dma_stop(ch); 190 tegra_dma_stop(ch);
196 191
197 spin_unlock_irqrestore(&ch->lock, irq_flags); 192 spin_unlock_irqrestore(&ch->lock, irq_flags);
198 return 0; 193 return 0;
199} 194}
200 195
196static unsigned int get_channel_status(struct tegra_dma_channel *ch,
197 struct tegra_dma_req *req, bool is_stop_dma)
198{
199 void __iomem *addr = IO_ADDRESS(TEGRA_APB_DMA_BASE);
200 unsigned int status;
201
202 if (is_stop_dma) {
203 /*
204 * STOP the DMA and get the transfer count.
205 * Getting the transfer count is tricky.
206 * - Globally disable DMA on all channels
207 * - Read the channel's status register to know the number
208 * of pending bytes to be transfered.
209 * - Stop the dma channel
210 * - Globally re-enable DMA to resume other transfers
211 */
212 spin_lock(&enable_lock);
213 writel(0, addr + APB_DMA_GEN);
214 udelay(20);
215 status = readl(ch->addr + APB_DMA_CHAN_STA);
216 tegra_dma_stop(ch);
217 writel(GEN_ENABLE, addr + APB_DMA_GEN);
218 spin_unlock(&enable_lock);
219 if (status & STA_ISE_EOC) {
220 pr_err("Got Dma Int here clearing");
221 writel(status, ch->addr + APB_DMA_CHAN_STA);
222 }
223 req->status = TEGRA_DMA_REQ_ERROR_ABORTED;
224 } else {
225 status = readl(ch->addr + APB_DMA_CHAN_STA);
226 }
227 return status;
228}
229
230/* should be called with the channel lock held */
231static unsigned int dma_active_count(struct tegra_dma_channel *ch,
232 struct tegra_dma_req *req, unsigned int status)
233{
234 unsigned int to_transfer;
235 unsigned int req_transfer_count;
236 unsigned int bytes_transferred;
237
238 to_transfer = ((status & STA_COUNT_MASK) >> STA_COUNT_SHIFT) + 1;
239 req_transfer_count = ch->req_transfer_count + 1;
240 bytes_transferred = req_transfer_count;
241 if (status & STA_BUSY)
242 bytes_transferred -= to_transfer;
243 /*
244 * In continuous transfer mode, DMA only tracks the count of the
245 * half DMA buffer. So, if the DMA already finished half the DMA
246 * then add the half buffer to the completed count.
247 */
248 if (ch->mode & TEGRA_DMA_MODE_CONTINOUS) {
249 if (req->buffer_status == TEGRA_DMA_REQ_BUF_STATUS_HALF_FULL)
250 bytes_transferred += req_transfer_count;
251 if (status & STA_ISE_EOC)
252 bytes_transferred += req_transfer_count;
253 }
254 bytes_transferred *= 4;
255 return bytes_transferred;
256}
257
201int tegra_dma_dequeue_req(struct tegra_dma_channel *ch, 258int tegra_dma_dequeue_req(struct tegra_dma_channel *ch,
202 struct tegra_dma_req *_req) 259 struct tegra_dma_req *_req)
203{ 260{
204 unsigned int csr;
205 unsigned int status; 261 unsigned int status;
206 struct tegra_dma_req *req = NULL; 262 struct tegra_dma_req *req = NULL;
207 int found = 0; 263 int found = 0;
208 unsigned long irq_flags; 264 unsigned long irq_flags;
209 int to_transfer; 265 int stop = 0;
210 int req_transfer_count;
211 266
212 spin_lock_irqsave(&ch->lock, irq_flags); 267 spin_lock_irqsave(&ch->lock, irq_flags);
268
269 if (list_entry(ch->list.next, struct tegra_dma_req, node) == _req)
270 stop = 1;
271
213 list_for_each_entry(req, &ch->list, node) { 272 list_for_each_entry(req, &ch->list, node) {
214 if (req == _req) { 273 if (req == _req) {
215 list_del(&req->node); 274 list_del(&req->node);
@@ -222,47 +281,12 @@ int tegra_dma_dequeue_req(struct tegra_dma_channel *ch,
222 return 0; 281 return 0;
223 } 282 }
224 283
225 /* STOP the DMA and get the transfer count. 284 if (!stop)
226 * Getting the transfer count is tricky. 285 goto skip_stop_dma;
227 * - Change the source selector to invalid to stop the DMA from
228 * FIFO to memory.
229 * - Read the status register to know the number of pending
230 * bytes to be transferred.
231 * - Finally stop or program the DMA to the next buffer in the
232 * list.
233 */
234 csr = readl(ch->addr + APB_DMA_CHAN_CSR);
235 csr &= ~CSR_REQ_SEL_MASK;
236 csr |= CSR_REQ_SEL_INVALID;
237 writel(csr, ch->addr + APB_DMA_CHAN_CSR);
238
239 /* Get the transfer count */
240 status = readl(ch->addr + APB_DMA_CHAN_STA);
241 to_transfer = (status & STA_COUNT_MASK) >> STA_COUNT_SHIFT;
242 req_transfer_count = ch->req_transfer_count;
243 req_transfer_count += 1;
244 to_transfer += 1;
245
246 req->bytes_transferred = req_transfer_count;
247
248 if (status & STA_BUSY)
249 req->bytes_transferred -= to_transfer;
250
251 /* In continuous transfer mode, DMA only tracks the count of the
252 * half DMA buffer. So, if the DMA already finished half the DMA
253 * then add the half buffer to the completed count.
254 *
255 * FIXME: There can be a race here. What if the req to
256 * dequue happens at the same time as the DMA just moved to
257 * the new buffer and SW didn't yet received the interrupt?
258 */
259 if (ch->mode & TEGRA_DMA_MODE_CONTINOUS)
260 if (req->buffer_status == TEGRA_DMA_REQ_BUF_STATUS_HALF_FULL)
261 req->bytes_transferred += req_transfer_count;
262 286
263 req->bytes_transferred *= 4; 287 status = get_channel_status(ch, req, true);
288 req->bytes_transferred = dma_active_count(ch, req, status);
264 289
265 tegra_dma_stop(ch);
266 if (!list_empty(&ch->list)) { 290 if (!list_empty(&ch->list)) {
267 /* if the list is not empty, queue the next request */ 291 /* if the list is not empty, queue the next request */
268 struct tegra_dma_req *next_req; 292 struct tegra_dma_req *next_req;
@@ -270,6 +294,8 @@ int tegra_dma_dequeue_req(struct tegra_dma_channel *ch,
270 typeof(*next_req), node); 294 typeof(*next_req), node);
271 tegra_dma_update_hw(ch, next_req); 295 tegra_dma_update_hw(ch, next_req);
272 } 296 }
297
298skip_stop_dma:
273 req->status = -TEGRA_DMA_REQ_ERROR_ABORTED; 299 req->status = -TEGRA_DMA_REQ_ERROR_ABORTED;
274 300
275 spin_unlock_irqrestore(&ch->lock, irq_flags); 301 spin_unlock_irqrestore(&ch->lock, irq_flags);
@@ -357,7 +383,7 @@ struct tegra_dma_channel *tegra_dma_allocate_channel(int mode)
357 int channel; 383 int channel;
358 struct tegra_dma_channel *ch = NULL; 384 struct tegra_dma_channel *ch = NULL;
359 385
360 if (WARN_ON(!tegra_dma_initialized)) 386 if (!tegra_dma_initialized)
361 return NULL; 387 return NULL;
362 388
363 mutex_lock(&tegra_dma_lock); 389 mutex_lock(&tegra_dma_lock);
diff --git a/arch/arm/mach-tegra/flowctrl.c b/arch/arm/mach-tegra/flowctrl.c
new file mode 100644
index 00000000000..fef66a7486e
--- /dev/null
+++ b/arch/arm/mach-tegra/flowctrl.c
@@ -0,0 +1,62 @@
1/*
2 * arch/arm/mach-tegra/flowctrl.c
3 *
4 * functions and macros to control the flowcontroller
5 *
6 * Copyright (c) 2010-2012, NVIDIA Corporation. All rights reserved.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms and conditions of the GNU General Public License,
10 * version 2, as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include <linux/init.h>
22#include <linux/kernel.h>
23#include <linux/io.h>
24
25#include <mach/iomap.h>
26
27#include "flowctrl.h"
28
29u8 flowctrl_offset_halt_cpu[] = {
30 FLOW_CTRL_HALT_CPU0_EVENTS,
31 FLOW_CTRL_HALT_CPU1_EVENTS,
32 FLOW_CTRL_HALT_CPU1_EVENTS + 8,
33 FLOW_CTRL_HALT_CPU1_EVENTS + 16,
34};
35
36u8 flowctrl_offset_cpu_csr[] = {
37 FLOW_CTRL_CPU0_CSR,
38 FLOW_CTRL_CPU1_CSR,
39 FLOW_CTRL_CPU1_CSR + 8,
40 FLOW_CTRL_CPU1_CSR + 16,
41};
42
43static void flowctrl_update(u8 offset, u32 value)
44{
45 void __iomem *addr = IO_ADDRESS(TEGRA_FLOW_CTRL_BASE) + offset;
46
47 writel(value, addr);
48
49 /* ensure the update has reached the flow controller */
50 wmb();
51 readl_relaxed(addr);
52}
53
54void flowctrl_write_cpu_csr(unsigned int cpuid, u32 value)
55{
56 return flowctrl_update(flowctrl_offset_halt_cpu[cpuid], value);
57}
58
59void flowctrl_write_cpu_halt(unsigned int cpuid, u32 value)
60{
61 return flowctrl_update(flowctrl_offset_cpu_csr[cpuid], value);
62}
diff --git a/arch/arm/mach-tegra/flowctrl.h b/arch/arm/mach-tegra/flowctrl.h
new file mode 100644
index 00000000000..19428173855
--- /dev/null
+++ b/arch/arm/mach-tegra/flowctrl.h
@@ -0,0 +1,42 @@
1/*
2 * arch/arm/mach-tegra/flowctrl.h
3 *
4 * functions and macros to control the flowcontroller
5 *
6 * Copyright (c) 2010-2012, NVIDIA Corporation. All rights reserved.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms and conditions of the GNU General Public License,
10 * version 2, as published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef __MACH_TEGRA_FLOWCTRL_H
22#define __MACH_TEGRA_FLOWCTRL_H
23
24#define FLOW_CTRL_HALT_CPU0_EVENTS 0x0
25#define FLOW_CTRL_WAITEVENT (2 << 29)
26#define FLOW_CTRL_WAIT_FOR_INTERRUPT (4 << 29)
27#define FLOW_CTRL_JTAG_RESUME (1 << 28)
28#define FLOW_CTRL_HALT_CPU_IRQ (1 << 10)
29#define FLOW_CTRL_HALT_CPU_FIQ (1 << 8)
30#define FLOW_CTRL_CPU0_CSR 0x8
31#define FLOW_CTRL_CSR_INTR_FLAG (1 << 15)
32#define FLOW_CTRL_CSR_EVENT_FLAG (1 << 14)
33#define FLOW_CTRL_CSR_ENABLE (1 << 0)
34#define FLOW_CTRL_HALT_CPU1_EVENTS 0x14
35#define FLOW_CTRL_CPU1_CSR 0x18
36
37#ifndef __ASSEMBLY__
38void flowctrl_write_cpu_csr(unsigned int cpuid, u32 value);
39void flowctrl_write_cpu_halt(unsigned int cpuid, u32 value);
40#endif
41
42#endif
diff --git a/arch/arm/mach-tegra/fuse.c b/arch/arm/mach-tegra/fuse.c
index ea49bd93c6b..f946d129423 100644
--- a/arch/arm/mach-tegra/fuse.c
+++ b/arch/arm/mach-tegra/fuse.c
@@ -19,68 +19,113 @@
19 19
20#include <linux/kernel.h> 20#include <linux/kernel.h>
21#include <linux/io.h> 21#include <linux/io.h>
22#include <linux/module.h> 22#include <linux/export.h>
23 23
24#include <mach/iomap.h> 24#include <mach/iomap.h>
25 25
26#include "fuse.h" 26#include "fuse.h"
27#include "apbio.h"
27 28
28#define FUSE_UID_LOW 0x108 29#define FUSE_UID_LOW 0x108
29#define FUSE_UID_HIGH 0x10c 30#define FUSE_UID_HIGH 0x10c
30#define FUSE_SKU_INFO 0x110 31#define FUSE_SKU_INFO 0x110
31#define FUSE_SPARE_BIT 0x200 32#define FUSE_SPARE_BIT 0x200
32 33
33static inline u32 fuse_readl(unsigned long offset) 34int tegra_sku_id;
35int tegra_cpu_process_id;
36int tegra_core_process_id;
37int tegra_chip_id;
38enum tegra_revision tegra_revision;
39
40/* The BCT to use at boot is specified by board straps that can be read
41 * through a APB misc register and decoded. 2 bits, i.e. 4 possible BCTs.
42 */
43int tegra_bct_strapping;
44
45#define STRAP_OPT 0x008
46#define GMI_AD0 (1 << 4)
47#define GMI_AD1 (1 << 5)
48#define RAM_ID_MASK (GMI_AD0 | GMI_AD1)
49#define RAM_CODE_SHIFT 4
50
51static const char *tegra_revision_name[TEGRA_REVISION_MAX] = {
52 [TEGRA_REVISION_UNKNOWN] = "unknown",
53 [TEGRA_REVISION_A01] = "A01",
54 [TEGRA_REVISION_A02] = "A02",
55 [TEGRA_REVISION_A03] = "A03",
56 [TEGRA_REVISION_A03p] = "A03 prime",
57 [TEGRA_REVISION_A04] = "A04",
58};
59
60static inline u32 tegra_fuse_readl(unsigned long offset)
34{ 61{
35 return readl(IO_TO_VIRT(TEGRA_FUSE_BASE + offset)); 62 return tegra_apb_readl(TEGRA_FUSE_BASE + offset);
36} 63}
37 64
38static inline void fuse_writel(u32 value, unsigned long offset) 65static inline bool get_spare_fuse(int bit)
39{ 66{
40 writel(value, IO_TO_VIRT(TEGRA_FUSE_BASE + offset)); 67 return tegra_fuse_readl(FUSE_SPARE_BIT + bit * 4);
68}
69
70static enum tegra_revision tegra_get_revision(u32 id)
71{
72 u32 minor_rev = (id >> 16) & 0xf;
73
74 switch (minor_rev) {
75 case 1:
76 return TEGRA_REVISION_A01;
77 case 2:
78 return TEGRA_REVISION_A02;
79 case 3:
80 if (tegra_chip_id == TEGRA20 &&
81 (get_spare_fuse(18) || get_spare_fuse(19)))
82 return TEGRA_REVISION_A03p;
83 else
84 return TEGRA_REVISION_A03;
85 case 4:
86 return TEGRA_REVISION_A04;
87 default:
88 return TEGRA_REVISION_UNKNOWN;
89 }
41} 90}
42 91
43void tegra_init_fuse(void) 92void tegra_init_fuse(void)
44{ 93{
94 u32 id;
95
45 u32 reg = readl(IO_TO_VIRT(TEGRA_CLK_RESET_BASE + 0x48)); 96 u32 reg = readl(IO_TO_VIRT(TEGRA_CLK_RESET_BASE + 0x48));
46 reg |= 1 << 28; 97 reg |= 1 << 28;
47 writel(reg, IO_TO_VIRT(TEGRA_CLK_RESET_BASE + 0x48)); 98 writel(reg, IO_TO_VIRT(TEGRA_CLK_RESET_BASE + 0x48));
48 99
49 pr_info("Tegra SKU: %d CPU Process: %d Core Process: %d\n", 100 reg = tegra_fuse_readl(FUSE_SKU_INFO);
50 tegra_sku_id(), tegra_cpu_process_id(), 101 tegra_sku_id = reg & 0xFF;
51 tegra_core_process_id()); 102
103 reg = tegra_fuse_readl(FUSE_SPARE_BIT);
104 tegra_cpu_process_id = (reg >> 6) & 3;
105
106 reg = tegra_fuse_readl(FUSE_SPARE_BIT);
107 tegra_core_process_id = (reg >> 12) & 3;
108
109 reg = tegra_apb_readl(TEGRA_APB_MISC_BASE + STRAP_OPT);
110 tegra_bct_strapping = (reg & RAM_ID_MASK) >> RAM_CODE_SHIFT;
111
112 id = readl_relaxed(IO_ADDRESS(TEGRA_APB_MISC_BASE) + 0x804);
113 tegra_chip_id = (id >> 8) & 0xff;
114
115 tegra_revision = tegra_get_revision(id);
116
117 pr_info("Tegra Revision: %s SKU: %d CPU Process: %d Core Process: %d\n",
118 tegra_revision_name[tegra_revision],
119 tegra_sku_id, tegra_cpu_process_id,
120 tegra_core_process_id);
52} 121}
53 122
54unsigned long long tegra_chip_uid(void) 123unsigned long long tegra_chip_uid(void)
55{ 124{
56 unsigned long long lo, hi; 125 unsigned long long lo, hi;
57 126
58 lo = fuse_readl(FUSE_UID_LOW); 127 lo = tegra_fuse_readl(FUSE_UID_LOW);
59 hi = fuse_readl(FUSE_UID_HIGH); 128 hi = tegra_fuse_readl(FUSE_UID_HIGH);
60 return (hi << 32ull) | lo; 129 return (hi << 32ull) | lo;
61} 130}
62EXPORT_SYMBOL(tegra_chip_uid); 131EXPORT_SYMBOL(tegra_chip_uid);
63
64int tegra_sku_id(void)
65{
66 int sku_id;
67 u32 reg = fuse_readl(FUSE_SKU_INFO);
68 sku_id = reg & 0xFF;
69 return sku_id;
70}
71
72int tegra_cpu_process_id(void)
73{
74 int cpu_process_id;
75 u32 reg = fuse_readl(FUSE_SPARE_BIT);
76 cpu_process_id = (reg >> 6) & 3;
77 return cpu_process_id;
78}
79
80int tegra_core_process_id(void)
81{
82 int core_process_id;
83 u32 reg = fuse_readl(FUSE_SPARE_BIT);
84 core_process_id = (reg >> 12) & 3;
85 return core_process_id;
86}
diff --git a/arch/arm/mach-tegra/fuse.h b/arch/arm/mach-tegra/fuse.h
index 584b2e27dbd..d2107b2cb85 100644
--- a/arch/arm/mach-tegra/fuse.h
+++ b/arch/arm/mach-tegra/fuse.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/arm/mach-tegra/fuse.c
3 *
4 * Copyright (C) 2010 Google, Inc. 2 * Copyright (C) 2010 Google, Inc.
5 * 3 *
6 * Author: 4 * Author:
@@ -17,8 +15,38 @@
17 * 15 *
18 */ 16 */
19 17
18#ifndef __MACH_TEGRA_FUSE_H
19#define __MACH_TEGRA_FUSE_H
20
21enum tegra_revision {
22 TEGRA_REVISION_UNKNOWN = 0,
23 TEGRA_REVISION_A01,
24 TEGRA_REVISION_A02,
25 TEGRA_REVISION_A03,
26 TEGRA_REVISION_A03p,
27 TEGRA_REVISION_A04,
28 TEGRA_REVISION_MAX,
29};
30
31#define SKU_ID_T20 8
32#define SKU_ID_T25SE 20
33#define SKU_ID_AP25 23
34#define SKU_ID_T25 24
35#define SKU_ID_AP25E 27
36#define SKU_ID_T25E 28
37
38#define TEGRA20 0x20
39#define TEGRA30 0x30
40
41extern int tegra_sku_id;
42extern int tegra_cpu_process_id;
43extern int tegra_core_process_id;
44extern int tegra_chip_id;
45extern enum tegra_revision tegra_revision;
46
47extern int tegra_bct_strapping;
48
20unsigned long long tegra_chip_uid(void); 49unsigned long long tegra_chip_uid(void);
21int tegra_sku_id(void);
22int tegra_cpu_process_id(void);
23int tegra_core_process_id(void);
24void tegra_init_fuse(void); 50void tegra_init_fuse(void);
51
52#endif
diff --git a/arch/arm/mach-tegra/headsmp.S b/arch/arm/mach-tegra/headsmp.S
index b5349b2f13d..fef9c2c5137 100644
--- a/arch/arm/mach-tegra/headsmp.S
+++ b/arch/arm/mach-tegra/headsmp.S
@@ -1,6 +1,23 @@
1#include <linux/linkage.h> 1#include <linux/linkage.h>
2#include <linux/init.h> 2#include <linux/init.h>
3 3
4#include <asm/cache.h>
5
6#include <mach/iomap.h>
7
8#include "flowctrl.h"
9#include "reset.h"
10
11#define APB_MISC_GP_HIDREV 0x804
12#define PMC_SCRATCH41 0x140
13
14#define RESET_DATA(x) ((TEGRA_RESET_##x)*4)
15
16 .macro mov32, reg, val
17 movw \reg, #:lower16:\val
18 movt \reg, #:upper16:\val
19 .endm
20
4 .section ".text.head", "ax" 21 .section ".text.head", "ax"
5 __CPUINIT 22 __CPUINIT
6 23
@@ -47,15 +64,149 @@ ENTRY(v7_invalidate_l1)
47 mov pc, lr 64 mov pc, lr
48ENDPROC(v7_invalidate_l1) 65ENDPROC(v7_invalidate_l1)
49 66
67
50ENTRY(tegra_secondary_startup) 68ENTRY(tegra_secondary_startup)
51 msr cpsr_fsxc, #0xd3
52 bl v7_invalidate_l1 69 bl v7_invalidate_l1
53 mrc p15, 0, r0, c0, c0, 5 70 /* Enable coresight */
54 and r0, r0, #15 71 mov32 r0, 0xC5ACCE55
55 ldr r1, =0x6000f100 72 mcr p14, 0, r0, c7, c12, 6
56 str r0, [r1]
571: ldr r2, [r1]
58 cmp r0, r2
59 beq 1b
60 b secondary_startup 73 b secondary_startup
61ENDPROC(tegra_secondary_startup) 74ENDPROC(tegra_secondary_startup)
75
76 .align L1_CACHE_SHIFT
77ENTRY(__tegra_cpu_reset_handler_start)
78
79/*
80 * __tegra_cpu_reset_handler:
81 *
82 * Common handler for all CPU reset events.
83 *
84 * Register usage within the reset handler:
85 *
86 * R7 = CPU present (to the OS) mask
87 * R8 = CPU in LP1 state mask
88 * R9 = CPU in LP2 state mask
89 * R10 = CPU number
90 * R11 = CPU mask
91 * R12 = pointer to reset handler data
92 *
93 * NOTE: This code is copied to IRAM. All code and data accesses
94 * must be position-independent.
95 */
96
97 .align L1_CACHE_SHIFT
98ENTRY(__tegra_cpu_reset_handler)
99
100 cpsid aif, 0x13 @ SVC mode, interrupts disabled
101 mrc p15, 0, r10, c0, c0, 5 @ MPIDR
102 and r10, r10, #0x3 @ R10 = CPU number
103 mov r11, #1
104 mov r11, r11, lsl r10 @ R11 = CPU mask
105 adr r12, __tegra_cpu_reset_handler_data
106
107#ifdef CONFIG_SMP
108 /* Does the OS know about this CPU? */
109 ldr r7, [r12, #RESET_DATA(MASK_PRESENT)]
110 tst r7, r11 @ if !present
111 bleq __die @ CPU not present (to OS)
112#endif
113
114#ifdef CONFIG_ARCH_TEGRA_2x_SOC
115 /* Are we on Tegra20? */
116 mov32 r6, TEGRA_APB_MISC_BASE
117 ldr r0, [r6, #APB_MISC_GP_HIDREV]
118 and r0, r0, #0xff00
119 cmp r0, #(0x20 << 8)
120 bne 1f
121 /* If not CPU0, don't let CPU0 reset CPU1 now that CPU1 is coming up. */
122 mov32 r6, TEGRA_PMC_BASE
123 mov r0, #0
124 cmp r10, #0
125 strne r0, [r6, #PMC_SCRATCH41]
1261:
127#endif
128
129#ifdef CONFIG_SMP
130 /*
131 * Can only be secondary boot (initial or hotplug) but CPU 0
132 * cannot be here.
133 */
134 cmp r10, #0
135 bleq __die @ CPU0 cannot be here
136 ldr lr, [r12, #RESET_DATA(STARTUP_SECONDARY)]
137 cmp lr, #0
138 bleq __die @ no secondary startup handler
139 bx lr
140#endif
141
142/*
143 * We don't know why the CPU reset. Just kill it.
144 * The LR register will contain the address we died at + 4.
145 */
146
147__die:
148 sub lr, lr, #4
149 mov32 r7, TEGRA_PMC_BASE
150 str lr, [r7, #PMC_SCRATCH41]
151
152 mov32 r7, TEGRA_CLK_RESET_BASE
153
154 /* Are we on Tegra20? */
155 mov32 r6, TEGRA_APB_MISC_BASE
156 ldr r0, [r6, #APB_MISC_GP_HIDREV]
157 and r0, r0, #0xff00
158 cmp r0, #(0x20 << 8)
159 bne 1f
160
161#ifdef CONFIG_ARCH_TEGRA_2x_SOC
162 mov32 r0, 0x1111
163 mov r1, r0, lsl r10
164 str r1, [r7, #0x340] @ CLK_RST_CPU_CMPLX_SET
165#endif
1661:
167#ifdef CONFIG_ARCH_TEGRA_3x_SOC
168 mov32 r6, TEGRA_FLOW_CTRL_BASE
169
170 cmp r10, #0
171 moveq r1, #FLOW_CTRL_HALT_CPU0_EVENTS
172 moveq r2, #FLOW_CTRL_CPU0_CSR
173 movne r1, r10, lsl #3
174 addne r2, r1, #(FLOW_CTRL_CPU1_CSR-8)
175 addne r1, r1, #(FLOW_CTRL_HALT_CPU1_EVENTS-8)
176
177 /* Clear CPU "event" and "interrupt" flags and power gate
178 it when halting but not before it is in the "WFI" state. */
179 ldr r0, [r6, +r2]
180 orr r0, r0, #FLOW_CTRL_CSR_INTR_FLAG | FLOW_CTRL_CSR_EVENT_FLAG
181 orr r0, r0, #FLOW_CTRL_CSR_ENABLE
182 str r0, [r6, +r2]
183
184 /* Unconditionally halt this CPU */
185 mov r0, #FLOW_CTRL_WAITEVENT
186 str r0, [r6, +r1]
187 ldr r0, [r6, +r1] @ memory barrier
188
189 dsb
190 isb
191 wfi @ CPU should be power gated here
192
193 /* If the CPU didn't power gate above just kill it's clock. */
194
195 mov r0, r11, lsl #8
196 str r0, [r7, #348] @ CLK_CPU_CMPLX_SET
197#endif
198
199 /* If the CPU still isn't dead, just spin here. */
200 b .
201ENDPROC(__tegra_cpu_reset_handler)
202
203 .align L1_CACHE_SHIFT
204 .type __tegra_cpu_reset_handler_data, %object
205 .globl __tegra_cpu_reset_handler_data
206__tegra_cpu_reset_handler_data:
207 .rept TEGRA_RESET_DATA_SIZE
208 .long 0
209 .endr
210 .align L1_CACHE_SHIFT
211
212ENTRY(__tegra_cpu_reset_handler_end)
diff --git a/arch/arm/mach-tegra/include/mach/clk.h b/arch/arm/mach-tegra/include/mach/clk.h
index fc3ecb66de0..d97e403303a 100644
--- a/arch/arm/mach-tegra/include/mach/clk.h
+++ b/arch/arm/mach-tegra/include/mach/clk.h
@@ -22,10 +22,20 @@
22 22
23struct clk; 23struct clk;
24 24
25enum tegra_clk_ex_param {
26 TEGRA_CLK_VI_INP_SEL,
27 TEGRA_CLK_DTV_INVERT,
28 TEGRA_CLK_NAND_PAD_DIV2_ENB,
29 TEGRA_CLK_PLLD_CSI_OUT_ENB,
30 TEGRA_CLK_PLLD_DSI_OUT_ENB,
31 TEGRA_CLK_PLLD_MIPI_MUX_SEL,
32};
33
25void tegra_periph_reset_deassert(struct clk *c); 34void tegra_periph_reset_deassert(struct clk *c);
26void tegra_periph_reset_assert(struct clk *c); 35void tegra_periph_reset_assert(struct clk *c);
27 36
28unsigned long clk_get_rate_all_locked(struct clk *c); 37unsigned long clk_get_rate_all_locked(struct clk *c);
29void tegra2_sdmmc_tap_delay(struct clk *c, int delay); 38void tegra2_sdmmc_tap_delay(struct clk *c, int delay);
39int tegra_clk_cfg_ex(struct clk *c, enum tegra_clk_ex_param p, u32 setting);
30 40
31#endif 41#endif
diff --git a/arch/arm/mach-tegra/include/mach/debug-macro.S b/arch/arm/mach-tegra/include/mach/debug-macro.S
index 619abc63aee..90069abd37b 100644
--- a/arch/arm/mach-tegra/include/mach/debug-macro.S
+++ b/arch/arm/mach-tegra/include/mach/debug-macro.S
@@ -1,11 +1,17 @@
1/* 1/*
2 * arch/arm/mach-tegra/include/mach/debug-macro.S 2 * arch/arm/mach-tegra/include/mach/debug-macro.S
3 * 3 *
4 * Copyright (C) 2010 Google, Inc. 4 * Copyright (C) 2010,2011 Google, Inc.
5 * Copyright (C) 2011-2012 NVIDIA CORPORATION. All Rights Reserved.
5 * 6 *
6 * Author: 7 * Author:
7 * Colin Cross <ccross@google.com> 8 * Colin Cross <ccross@google.com>
8 * Erik Gilling <konkers@google.com> 9 * Erik Gilling <konkers@google.com>
10 * Doug Anderson <dianders@chromium.org>
11 * Stephen Warren <swarren@nvidia.com>
12 *
13 * Portions based on mach-omap2's debug-macro.S
14 * Copyright (C) 1994-1999 Russell King
9 * 15 *
10 * This software is licensed under the terms of the GNU General Public 16 * This software is licensed under the terms of the GNU General Public
11 * License version 2, as published by the Free Software Foundation, and 17 * License version 2, as published by the Free Software Foundation, and
@@ -18,18 +24,78 @@
18 * 24 *
19 */ 25 */
20 26
27#include <linux/serial_reg.h>
28
21#include <mach/io.h> 29#include <mach/io.h>
22#include <mach/iomap.h> 30#include <mach/iomap.h>
31#include <mach/irammap.h>
32
33 .macro addruart, rp, rv, tmp
34 adr \rp, 99f @ actual addr of 99f
35 ldr \rv, [\rp] @ linked addr is stored there
36 sub \rv, \rv, \rp @ offset between the two
37 ldr \rp, [\rp, #4] @ linked tegra_uart_config
38 sub \tmp, \rp, \rv @ actual tegra_uart_config
39 ldr \rp, [\tmp] @ Load tegra_uart_config
40 cmp \rp, #1 @ needs intitialization?
41 bne 100f @ no; go load the addresses
42 mov \rv, #0 @ yes; record init is done
43 str \rv, [\tmp]
44 mov \rp, #TEGRA_IRAM_BASE @ See if cookie is in IRAM
45 ldr \rv, [\rp, #TEGRA_IRAM_DEBUG_UART_OFFSET]
46 movw \rp, #TEGRA_IRAM_DEBUG_UART_COOKIE & 0xffff
47 movt \rp, #TEGRA_IRAM_DEBUG_UART_COOKIE >> 16
48 cmp \rv, \rp @ Cookie present?
49 bne 100f @ No, use default UART
50 mov \rp, #TEGRA_IRAM_BASE @ Load UART address from IRAM
51 ldr \rv, [\rp, #TEGRA_IRAM_DEBUG_UART_OFFSET + 4]
52 str \rv, [\tmp, #4] @ Store in tegra_uart_phys
53 sub \rv, \rv, #IO_APB_PHYS @ Calculate virt address
54 add \rv, \rv, #IO_APB_VIRT
55 str \rv, [\tmp, #8] @ Store in tegra_uart_virt
56 b 100f
57
58 .align
5999: .word .
60 .word tegra_uart_config
61 .ltorg
62
63100: ldr \rp, [\tmp, #4] @ Load tegra_uart_phys
64 ldr \rv, [\tmp, #8] @ Load tegra_uart_virt
65 .endm
66
67#define UART_SHIFT 2
68
69/*
70 * Code below is swiped from <asm/hardware/debug-8250.S>, but add an extra
71 * check to make sure that we aren't in the CONFIG_TEGRA_DEBUG_UART_NONE case.
72 * We use the fact that all 5 valid UART addresses all have something in the
73 * 2nd-to-lowest byte.
74 */
23 75
24 .macro addruart, rp, rv, tmp 76 .macro senduart, rd, rx
25 ldr \rp, =IO_APB_PHYS @ physical 77 tst \rx, #0x0000ff00
26 ldr \rv, =IO_APB_VIRT @ virtual 78 strneb \rd, [\rx, #UART_TX << UART_SHIFT]
27 orr \rp, \rp, #(TEGRA_DEBUG_UART_BASE & 0xFF) 791001:
28 orr \rp, \rp, #(TEGRA_DEBUG_UART_BASE & 0xFF00) 80 .endm
29 orr \rv, \rv, #(TEGRA_DEBUG_UART_BASE & 0xFF)
30 orr \rv, \rv, #(TEGRA_DEBUG_UART_BASE & 0xFF00)
31 .endm
32 81
33#define UART_SHIFT 2 82 .macro busyuart, rd, rx
34#include <asm/hardware/debug-8250.S> 83 tst \rx, #0x0000ff00
84 beq 1002f
851001: ldrb \rd, [\rx, #UART_LSR << UART_SHIFT]
86 and \rd, \rd, #UART_LSR_TEMT | UART_LSR_THRE
87 teq \rd, #UART_LSR_TEMT | UART_LSR_THRE
88 bne 1001b
891002:
90 .endm
35 91
92 .macro waituart, rd, rx
93#ifdef FLOW_CONTROL
94 tst \rx, #0x0000ff00
95 beq 1002f
961001: ldrb \rd, [\rx, #UART_MSR << UART_SHIFT]
97 tst \rd, #UART_MSR_CTS
98 beq 1001b
991002:
100#endif
101 .endm
diff --git a/arch/arm/mach-tegra/include/mach/entry-macro.S b/arch/arm/mach-tegra/include/mach/entry-macro.S
deleted file mode 100644
index e577cfe27e7..00000000000
--- a/arch/arm/mach-tegra/include/mach/entry-macro.S
+++ /dev/null
@@ -1,20 +0,0 @@
1/* arch/arm/mach-tegra/include/mach/entry-macro.S
2 *
3 * Copyright (C) 2009 Palm, 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 .macro disable_fiq
17 .endm
18
19 .macro arch_ret_to_user, tmp1, tmp2
20 .endm
diff --git a/arch/arm/mach-tegra/include/mach/gpio-tegra.h b/arch/arm/mach-tegra/include/mach/gpio-tegra.h
index 87d37fdf508..6140820555e 100644
--- a/arch/arm/mach-tegra/include/mach/gpio-tegra.h
+++ b/arch/arm/mach-tegra/include/mach/gpio-tegra.h
@@ -25,8 +25,6 @@
25 25
26#define TEGRA_NR_GPIOS INT_GPIO_NR 26#define TEGRA_NR_GPIOS INT_GPIO_NR
27 27
28#define TEGRA_GPIO_TO_IRQ(gpio) (INT_GPIO_BASE + (gpio))
29
30struct tegra_gpio_table { 28struct tegra_gpio_table {
31 int gpio; /* GPIO number */ 29 int gpio; /* GPIO number */
32 bool enable; /* Enable for GPIO at init? */ 30 bool enable; /* Enable for GPIO at init? */
diff --git a/arch/arm/mach-tegra/include/mach/iomap.h b/arch/arm/mach-tegra/include/mach/iomap.h
index 19dec3ac085..cff672a344f 100644
--- a/arch/arm/mach-tegra/include/mach/iomap.h
+++ b/arch/arm/mach-tegra/include/mach/iomap.h
@@ -74,6 +74,9 @@
74#define TEGRA_QUATERNARY_ICTLR_BASE 0x60004300 74#define TEGRA_QUATERNARY_ICTLR_BASE 0x60004300
75#define TEGRA_QUATERNARY_ICTLR_SIZE SZ_64 75#define TEGRA_QUATERNARY_ICTLR_SIZE SZ_64
76 76
77#define TEGRA_QUINARY_ICTLR_BASE 0x60004400
78#define TEGRA_QUINARY_ICTLR_SIZE SZ_64
79
77#define TEGRA_TMR1_BASE 0x60005000 80#define TEGRA_TMR1_BASE 0x60005000
78#define TEGRA_TMR1_SIZE SZ_8 81#define TEGRA_TMR1_SIZE SZ_8
79 82
@@ -110,6 +113,9 @@
110#define TEGRA_AHB_GIZMO_BASE 0x6000C004 113#define TEGRA_AHB_GIZMO_BASE 0x6000C004
111#define TEGRA_AHB_GIZMO_SIZE 0x10C 114#define TEGRA_AHB_GIZMO_SIZE 0x10C
112 115
116#define TEGRA_SB_BASE 0x6000C200
117#define TEGRA_SB_SIZE 256
118
113#define TEGRA_STATMON_BASE 0x6000C400 119#define TEGRA_STATMON_BASE 0x6000C400
114#define TEGRA_STATMON_SIZE SZ_1K 120#define TEGRA_STATMON_SIZE SZ_1K
115 121
diff --git a/arch/arm/mach-tegra/include/mach/irammap.h b/arch/arm/mach-tegra/include/mach/irammap.h
new file mode 100644
index 00000000000..0cbe6326185
--- /dev/null
+++ b/arch/arm/mach-tegra/include/mach/irammap.h
@@ -0,0 +1,35 @@
1/*
2 * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
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
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef __MACH_TEGRA_IRAMMAP_H
18#define __MACH_TEGRA_IRAMMAP_H
19
20#include <asm/sizes.h>
21
22/* The first 1K of IRAM is permanently reserved for the CPU reset handler */
23#define TEGRA_IRAM_RESET_HANDLER_OFFSET 0
24#define TEGRA_IRAM_RESET_HANDLER_SIZE SZ_1K
25
26/*
27 * These locations are written to by uncompress.h, and read by debug-macro.S.
28 * The first word holds the cookie value if the data is valid. The second
29 * word holds the UART physical address.
30 */
31#define TEGRA_IRAM_DEBUG_UART_OFFSET SZ_1K
32#define TEGRA_IRAM_DEBUG_UART_SIZE 8
33#define TEGRA_IRAM_DEBUG_UART_COOKIE 0x55415254
34
35#endif
diff --git a/arch/arm/mach-tegra/include/mach/irqs.h b/arch/arm/mach-tegra/include/mach/irqs.h
index a2146cd6867..aad1a2c1d71 100644
--- a/arch/arm/mach-tegra/include/mach/irqs.h
+++ b/arch/arm/mach-tegra/include/mach/irqs.h
@@ -165,11 +165,12 @@
165#define INT_QUAD_RES_30 (INT_QUAD_BASE + 30) 165#define INT_QUAD_RES_30 (INT_QUAD_BASE + 30)
166#define INT_QUAD_RES_31 (INT_QUAD_BASE + 31) 166#define INT_QUAD_RES_31 (INT_QUAD_BASE + 31)
167 167
168#define INT_MAIN_NR (INT_QUAD_BASE + 32 - INT_PRI_BASE) 168/* Tegra30 has 5 banks of 32 IRQs */
169 169#define INT_MAIN_NR (32 * 5)
170#define INT_GPIO_BASE (INT_PRI_BASE + INT_MAIN_NR) 170#define INT_GPIO_BASE (INT_PRI_BASE + INT_MAIN_NR)
171 171
172#define INT_GPIO_NR (28 * 8) 172/* Tegra30 has 8 banks of 32 GPIOs */
173#define INT_GPIO_NR (32 * 8)
173 174
174#define TEGRA_NR_IRQS (INT_GPIO_BASE + INT_GPIO_NR) 175#define TEGRA_NR_IRQS (INT_GPIO_BASE + INT_GPIO_NR)
175 176
diff --git a/arch/arm/mach-tegra/include/mach/powergate.h b/arch/arm/mach-tegra/include/mach/powergate.h
index 39c396d2ddb..4752b1a68f3 100644
--- a/arch/arm/mach-tegra/include/mach/powergate.h
+++ b/arch/arm/mach-tegra/include/mach/powergate.h
@@ -27,8 +27,21 @@
27#define TEGRA_POWERGATE_VDEC 4 27#define TEGRA_POWERGATE_VDEC 4
28#define TEGRA_POWERGATE_L2 5 28#define TEGRA_POWERGATE_L2 5
29#define TEGRA_POWERGATE_MPE 6 29#define TEGRA_POWERGATE_MPE 6
30#define TEGRA_NUM_POWERGATE 7 30#define TEGRA_POWERGATE_HEG 7
31#define TEGRA_POWERGATE_SATA 8
32#define TEGRA_POWERGATE_CPU1 9
33#define TEGRA_POWERGATE_CPU2 10
34#define TEGRA_POWERGATE_CPU3 11
35#define TEGRA_POWERGATE_CELP 12
36#define TEGRA_POWERGATE_3D1 13
31 37
38#define TEGRA_POWERGATE_CPU0 TEGRA_POWERGATE_CPU
39#define TEGRA_POWERGATE_3D0 TEGRA_POWERGATE_3D
40
41int __init tegra_powergate_init(void);
42
43int tegra_cpu_powergate_id(int cpuid);
44int tegra_powergate_is_powered(int id);
32int tegra_powergate_power_on(int id); 45int tegra_powergate_power_on(int id);
33int tegra_powergate_power_off(int id); 46int tegra_powergate_power_off(int id);
34int tegra_powergate_remove_clamping(int id); 47int tegra_powergate_remove_clamping(int id);
diff --git a/arch/arm/mach-tegra/include/mach/smmu.h b/arch/arm/mach-tegra/include/mach/smmu.h
new file mode 100644
index 00000000000..dad403a9cf0
--- /dev/null
+++ b/arch/arm/mach-tegra/include/mach/smmu.h
@@ -0,0 +1,63 @@
1/*
2 * IOMMU API for SMMU in Tegra30
3 *
4 * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope 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 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20#ifndef MACH_SMMU_H
21#define MACH_SMMU_H
22
23enum smmu_hwgrp {
24 HWGRP_AFI,
25 HWGRP_AVPC,
26 HWGRP_DC,
27 HWGRP_DCB,
28 HWGRP_EPP,
29 HWGRP_G2,
30 HWGRP_HC,
31 HWGRP_HDA,
32 HWGRP_ISP,
33 HWGRP_MPE,
34 HWGRP_NV,
35 HWGRP_NV2,
36 HWGRP_PPCS,
37 HWGRP_SATA,
38 HWGRP_VDE,
39 HWGRP_VI,
40
41 HWGRP_COUNT,
42
43 HWGRP_END = ~0,
44};
45
46#define HWG_AFI (1 << HWGRP_AFI)
47#define HWG_AVPC (1 << HWGRP_AVPC)
48#define HWG_DC (1 << HWGRP_DC)
49#define HWG_DCB (1 << HWGRP_DCB)
50#define HWG_EPP (1 << HWGRP_EPP)
51#define HWG_G2 (1 << HWGRP_G2)
52#define HWG_HC (1 << HWGRP_HC)
53#define HWG_HDA (1 << HWGRP_HDA)
54#define HWG_ISP (1 << HWGRP_ISP)
55#define HWG_MPE (1 << HWGRP_MPE)
56#define HWG_NV (1 << HWGRP_NV)
57#define HWG_NV2 (1 << HWGRP_NV2)
58#define HWG_PPCS (1 << HWGRP_PPCS)
59#define HWG_SATA (1 << HWGRP_SATA)
60#define HWG_VDE (1 << HWGRP_VDE)
61#define HWG_VI (1 << HWGRP_VI)
62
63#endif /* MACH_SMMU_H */
diff --git a/arch/arm/mach-tegra/include/mach/uncompress.h b/arch/arm/mach-tegra/include/mach/uncompress.h
index 4e8323770c7..5a440f315e5 100644
--- a/arch/arm/mach-tegra/include/mach/uncompress.h
+++ b/arch/arm/mach-tegra/include/mach/uncompress.h
@@ -2,10 +2,14 @@
2 * arch/arm/mach-tegra/include/mach/uncompress.h 2 * arch/arm/mach-tegra/include/mach/uncompress.h
3 * 3 *
4 * Copyright (C) 2010 Google, Inc. 4 * Copyright (C) 2010 Google, Inc.
5 * Copyright (C) 2011 Google, Inc.
6 * Copyright (C) 2011-2012 NVIDIA CORPORATION. All Rights Reserved.
5 * 7 *
6 * Author: 8 * Author:
7 * Colin Cross <ccross@google.com> 9 * Colin Cross <ccross@google.com>
8 * Erik Gilling <konkers@google.com> 10 * Erik Gilling <konkers@google.com>
11 * Doug Anderson <dianders@chromium.org>
12 * Stephen Warren <swarren@nvidia.com>
9 * 13 *
10 * This software is licensed under the terms of the GNU General Public 14 * This software is licensed under the terms of the GNU General Public
11 * License version 2, as published by the Free Software Foundation, and 15 * License version 2, as published by the Free Software Foundation, and
@@ -25,36 +29,130 @@
25#include <linux/serial_reg.h> 29#include <linux/serial_reg.h>
26 30
27#include <mach/iomap.h> 31#include <mach/iomap.h>
32#include <mach/irammap.h>
33
34#define BIT(x) (1 << (x))
35#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
36
37#define DEBUG_UART_SHIFT 2
38
39volatile u8 *uart;
28 40
29static void putc(int c) 41static void putc(int c)
30{ 42{
31 volatile u8 *uart = (volatile u8 *)TEGRA_DEBUG_UART_BASE;
32 int shift = 2;
33
34 if (uart == NULL) 43 if (uart == NULL)
35 return; 44 return;
36 45
37 while (!(uart[UART_LSR << shift] & UART_LSR_THRE)) 46 while (!(uart[UART_LSR << DEBUG_UART_SHIFT] & UART_LSR_THRE))
38 barrier(); 47 barrier();
39 uart[UART_TX << shift] = c; 48 uart[UART_TX << DEBUG_UART_SHIFT] = c;
40} 49}
41 50
42static inline void flush(void) 51static inline void flush(void)
43{ 52{
44} 53}
45 54
55static inline void save_uart_address(void)
56{
57 u32 *buf = (u32 *)(TEGRA_IRAM_BASE + TEGRA_IRAM_DEBUG_UART_OFFSET);
58
59 if (uart) {
60 buf[0] = TEGRA_IRAM_DEBUG_UART_COOKIE;
61 buf[1] = (u32)uart;
62 } else
63 buf[0] = 0;
64}
65
66/*
67 * Setup before decompression. This is where we do UART selection for
68 * earlyprintk and init the uart_base register.
69 */
46static inline void arch_decomp_setup(void) 70static inline void arch_decomp_setup(void)
47{ 71{
48 volatile u8 *uart = (volatile u8 *)TEGRA_DEBUG_UART_BASE; 72 static const struct {
49 int shift = 2; 73 u32 base;
74 u32 reset_reg;
75 u32 clock_reg;
76 u32 bit;
77 } uarts[] = {
78 {
79 TEGRA_UARTA_BASE,
80 TEGRA_CLK_RESET_BASE + 0x04,
81 TEGRA_CLK_RESET_BASE + 0x10,
82 6,
83 },
84 {
85 TEGRA_UARTB_BASE,
86 TEGRA_CLK_RESET_BASE + 0x04,
87 TEGRA_CLK_RESET_BASE + 0x10,
88 7,
89 },
90 {
91 TEGRA_UARTC_BASE,
92 TEGRA_CLK_RESET_BASE + 0x08,
93 TEGRA_CLK_RESET_BASE + 0x14,
94 23,
95 },
96 {
97 TEGRA_UARTD_BASE,
98 TEGRA_CLK_RESET_BASE + 0x0c,
99 TEGRA_CLK_RESET_BASE + 0x18,
100 1,
101 },
102 {
103 TEGRA_UARTE_BASE,
104 TEGRA_CLK_RESET_BASE + 0x0c,
105 TEGRA_CLK_RESET_BASE + 0x18,
106 2,
107 },
108 };
109 int i;
110 volatile u32 *apb_misc = (volatile u32 *)TEGRA_APB_MISC_BASE;
111 u32 chip, div;
112
113 /*
114 * Look for the first UART that:
115 * a) Is not in reset.
116 * b) Is clocked.
117 * c) Has a 'D' in the scratchpad register.
118 *
119 * Note that on Tegra30, the first two conditions are required, since
120 * if not true, accesses to the UART scratch register will hang.
121 * Tegra20 doesn't have this issue.
122 *
123 * The intent is that the bootloader will tell the kernel which UART
124 * to use by setting up those conditions. If nothing found, we'll fall
125 * back to what's specified in TEGRA_DEBUG_UART_BASE.
126 */
127 for (i = 0; i < ARRAY_SIZE(uarts); i++) {
128 if (*(u8 *)uarts[i].reset_reg & BIT(uarts[i].bit))
129 continue;
50 130
131 if (!(*(u8 *)uarts[i].clock_reg & BIT(uarts[i].bit)))
132 continue;
133
134 uart = (volatile u8 *)uarts[i].base;
135 if (uart[UART_SCR << DEBUG_UART_SHIFT] != 'D')
136 continue;
137
138 break;
139 }
140 if (i == ARRAY_SIZE(uarts))
141 uart = (volatile u8 *)TEGRA_DEBUG_UART_BASE;
142 save_uart_address();
51 if (uart == NULL) 143 if (uart == NULL)
52 return; 144 return;
53 145
54 uart[UART_LCR << shift] |= UART_LCR_DLAB; 146 chip = (apb_misc[0x804 / 4] >> 8) & 0xff;
55 uart[UART_DLL << shift] = 0x75; 147 if (chip == 0x20)
56 uart[UART_DLM << shift] = 0x0; 148 div = 0x0075;
57 uart[UART_LCR << shift] = 3; 149 else
150 div = 0x00dd;
151
152 uart[UART_LCR << DEBUG_UART_SHIFT] |= UART_LCR_DLAB;
153 uart[UART_DLL << DEBUG_UART_SHIFT] = div & 0xff;
154 uart[UART_DLM << DEBUG_UART_SHIFT] = div >> 8;
155 uart[UART_LCR << DEBUG_UART_SHIFT] = 3;
58} 156}
59 157
60static inline void arch_decomp_wdog(void) 158static inline void arch_decomp_wdog(void)
diff --git a/arch/arm/mach-tegra/irq.c b/arch/arm/mach-tegra/irq.c
index 4e1afcd54fa..2f5bd2db8e1 100644
--- a/arch/arm/mach-tegra/irq.c
+++ b/arch/arm/mach-tegra/irq.c
@@ -44,14 +44,16 @@
44#define ICTLR_COP_IER_CLR 0x38 44#define ICTLR_COP_IER_CLR 0x38
45#define ICTLR_COP_IEP_CLASS 0x3c 45#define ICTLR_COP_IEP_CLASS 0x3c
46 46
47#define NUM_ICTLRS 4
48#define FIRST_LEGACY_IRQ 32 47#define FIRST_LEGACY_IRQ 32
49 48
49static int num_ictlrs;
50
50static void __iomem *ictlr_reg_base[] = { 51static void __iomem *ictlr_reg_base[] = {
51 IO_ADDRESS(TEGRA_PRIMARY_ICTLR_BASE), 52 IO_ADDRESS(TEGRA_PRIMARY_ICTLR_BASE),
52 IO_ADDRESS(TEGRA_SECONDARY_ICTLR_BASE), 53 IO_ADDRESS(TEGRA_SECONDARY_ICTLR_BASE),
53 IO_ADDRESS(TEGRA_TERTIARY_ICTLR_BASE), 54 IO_ADDRESS(TEGRA_TERTIARY_ICTLR_BASE),
54 IO_ADDRESS(TEGRA_QUATERNARY_ICTLR_BASE), 55 IO_ADDRESS(TEGRA_QUATERNARY_ICTLR_BASE),
56 IO_ADDRESS(TEGRA_QUINARY_ICTLR_BASE),
55}; 57};
56 58
57static inline void tegra_irq_write_mask(unsigned int irq, unsigned long reg) 59static inline void tegra_irq_write_mask(unsigned int irq, unsigned long reg)
@@ -60,7 +62,7 @@ static inline void tegra_irq_write_mask(unsigned int irq, unsigned long reg)
60 u32 mask; 62 u32 mask;
61 63
62 BUG_ON(irq < FIRST_LEGACY_IRQ || 64 BUG_ON(irq < FIRST_LEGACY_IRQ ||
63 irq >= FIRST_LEGACY_IRQ + NUM_ICTLRS * 32); 65 irq >= FIRST_LEGACY_IRQ + num_ictlrs * 32);
64 66
65 base = ictlr_reg_base[(irq - FIRST_LEGACY_IRQ) / 32]; 67 base = ictlr_reg_base[(irq - FIRST_LEGACY_IRQ) / 32];
66 mask = BIT((irq - FIRST_LEGACY_IRQ) % 32); 68 mask = BIT((irq - FIRST_LEGACY_IRQ) % 32);
@@ -113,8 +115,18 @@ static int tegra_retrigger(struct irq_data *d)
113void __init tegra_init_irq(void) 115void __init tegra_init_irq(void)
114{ 116{
115 int i; 117 int i;
118 void __iomem *distbase;
119
120 distbase = IO_ADDRESS(TEGRA_ARM_INT_DIST_BASE);
121 num_ictlrs = readl_relaxed(distbase + GIC_DIST_CTR) & 0x1f;
122
123 if (num_ictlrs > ARRAY_SIZE(ictlr_reg_base)) {
124 WARN(1, "Too many (%d) interrupt controllers found. Maximum is %d.",
125 num_ictlrs, ARRAY_SIZE(ictlr_reg_base));
126 num_ictlrs = ARRAY_SIZE(ictlr_reg_base);
127 }
116 128
117 for (i = 0; i < NUM_ICTLRS; i++) { 129 for (i = 0; i < num_ictlrs; i++) {
118 void __iomem *ictlr = ictlr_reg_base[i]; 130 void __iomem *ictlr = ictlr_reg_base[i];
119 writel(~0, ictlr + ICTLR_CPU_IER_CLR); 131 writel(~0, ictlr + ICTLR_CPU_IER_CLR);
120 writel(0, ictlr + ICTLR_CPU_IEP_CLASS); 132 writel(0, ictlr + ICTLR_CPU_IEP_CLASS);
@@ -131,6 +143,6 @@ void __init tegra_init_irq(void)
131 * initialized elsewhere under DT. 143 * initialized elsewhere under DT.
132 */ 144 */
133 if (!of_have_populated_dt()) 145 if (!of_have_populated_dt())
134 gic_init(0, 29, IO_ADDRESS(TEGRA_ARM_INT_DIST_BASE), 146 gic_init(0, 29, distbase,
135 IO_ADDRESS(TEGRA_ARM_PERIF_BASE + 0x100)); 147 IO_ADDRESS(TEGRA_ARM_PERIF_BASE + 0x100));
136} 148}
diff --git a/arch/arm/mach-tegra/localtimer.c b/arch/arm/mach-tegra/localtimer.c
deleted file mode 100644
index e91d681d45a..00000000000
--- a/arch/arm/mach-tegra/localtimer.c
+++ /dev/null
@@ -1,26 +0,0 @@
1/*
2 * arch/arm/mach-tegra/localtimer.c
3 *
4 * Copyright (C) 2002 ARM Ltd.
5 * All Rights Reserved
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#include <linux/init.h>
12#include <linux/smp.h>
13#include <linux/clockchips.h>
14#include <asm/irq.h>
15#include <asm/smp_twd.h>
16#include <asm/localtimer.h>
17
18/*
19 * Setup the local clock events for a CPU.
20 */
21int __cpuinit local_timer_setup(struct clock_event_device *evt)
22{
23 evt->irq = IRQ_LOCALTIMER;
24 twd_timer_setup(evt);
25 return 0;
26}
diff --git a/arch/arm/mach-tegra/pcie.c b/arch/arm/mach-tegra/pcie.c
index af8b6343572..54a816ff384 100644
--- a/arch/arm/mach-tegra/pcie.c
+++ b/arch/arm/mach-tegra/pcie.c
@@ -408,7 +408,7 @@ static int tegra_pcie_setup(int nr, struct pci_sys_data *sys)
408 pp->res[0].flags = IORESOURCE_IO; 408 pp->res[0].flags = IORESOURCE_IO;
409 if (request_resource(&ioport_resource, &pp->res[0])) 409 if (request_resource(&ioport_resource, &pp->res[0]))
410 panic("Request PCIe IO resource failed\n"); 410 panic("Request PCIe IO resource failed\n");
411 pci_add_resource(&sys->resources, &pp->res[0]); 411 pci_add_resource_offset(&sys->resources, &pp->res[0], sys->io_offset);
412 412
413 /* 413 /*
414 * IORESOURCE_MEM 414 * IORESOURCE_MEM
@@ -427,7 +427,7 @@ static int tegra_pcie_setup(int nr, struct pci_sys_data *sys)
427 pp->res[1].flags = IORESOURCE_MEM; 427 pp->res[1].flags = IORESOURCE_MEM;
428 if (request_resource(&iomem_resource, &pp->res[1])) 428 if (request_resource(&iomem_resource, &pp->res[1]))
429 panic("Request PCIe Memory resource failed\n"); 429 panic("Request PCIe Memory resource failed\n");
430 pci_add_resource(&sys->resources, &pp->res[1]); 430 pci_add_resource_offset(&sys->resources, &pp->res[1], sys->mem_offset);
431 431
432 /* 432 /*
433 * IORESOURCE_MEM | IORESOURCE_PREFETCH 433 * IORESOURCE_MEM | IORESOURCE_PREFETCH
@@ -446,7 +446,7 @@ static int tegra_pcie_setup(int nr, struct pci_sys_data *sys)
446 pp->res[2].flags = IORESOURCE_MEM | IORESOURCE_PREFETCH; 446 pp->res[2].flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
447 if (request_resource(&iomem_resource, &pp->res[2])) 447 if (request_resource(&iomem_resource, &pp->res[2]))
448 panic("Request PCIe Prefetch Memory resource failed\n"); 448 panic("Request PCIe Prefetch Memory resource failed\n");
449 pci_add_resource(&sys->resources, &pp->res[2]); 449 pci_add_resource_offset(&sys->resources, &pp->res[2], sys->mem_offset);
450 450
451 return 1; 451 return 1;
452} 452}
@@ -585,10 +585,10 @@ static void tegra_pcie_setup_translations(void)
585 afi_writel(0, AFI_MSI_BAR_SZ); 585 afi_writel(0, AFI_MSI_BAR_SZ);
586} 586}
587 587
588static void tegra_pcie_enable_controller(void) 588static int tegra_pcie_enable_controller(void)
589{ 589{
590 u32 val, reg; 590 u32 val, reg;
591 int i; 591 int i, timeout;
592 592
593 /* Enable slot clock and pulse the reset signals */ 593 /* Enable slot clock and pulse the reset signals */
594 for (i = 0, reg = AFI_PEX0_CTRL; i < 2; i++, reg += 0x8) { 594 for (i = 0, reg = AFI_PEX0_CTRL; i < 2; i++, reg += 0x8) {
@@ -639,8 +639,14 @@ static void tegra_pcie_enable_controller(void)
639 pads_writel(0xfa5cfa5c, 0xc8); 639 pads_writel(0xfa5cfa5c, 0xc8);
640 640
641 /* Wait for the PLL to lock */ 641 /* Wait for the PLL to lock */
642 timeout = 300;
642 do { 643 do {
643 val = pads_readl(PADS_PLL_CTL); 644 val = pads_readl(PADS_PLL_CTL);
645 usleep_range(1000, 1000);
646 if (--timeout == 0) {
647 pr_err("Tegra PCIe error: timeout waiting for PLL\n");
648 return -EBUSY;
649 }
644 } while (!(val & PADS_PLL_CTL_LOCKDET)); 650 } while (!(val & PADS_PLL_CTL_LOCKDET));
645 651
646 /* turn off IDDQ override */ 652 /* turn off IDDQ override */
@@ -671,7 +677,7 @@ static void tegra_pcie_enable_controller(void)
671 /* Disable all execptions */ 677 /* Disable all execptions */
672 afi_writel(0, AFI_FPCI_ERROR_MASKS); 678 afi_writel(0, AFI_FPCI_ERROR_MASKS);
673 679
674 return; 680 return 0;
675} 681}
676 682
677static void tegra_pcie_xclk_clamp(bool clamp) 683static void tegra_pcie_xclk_clamp(bool clamp)
@@ -921,7 +927,9 @@ int __init tegra_pcie_init(bool init_port0, bool init_port1)
921 if (err) 927 if (err)
922 return err; 928 return err;
923 929
924 tegra_pcie_enable_controller(); 930 err = tegra_pcie_enable_controller();
931 if (err)
932 return err;
925 933
926 /* setup the AFI address translations */ 934 /* setup the AFI address translations */
927 tegra_pcie_setup_translations(); 935 tegra_pcie_setup_translations();
diff --git a/arch/arm/mach-tegra/platsmp.c b/arch/arm/mach-tegra/platsmp.c
index 7d2b5d03c1d..1a208dbf682 100644
--- a/arch/arm/mach-tegra/platsmp.c
+++ b/arch/arm/mach-tegra/platsmp.c
@@ -24,19 +24,31 @@
24#include <asm/mach-types.h> 24#include <asm/mach-types.h>
25#include <asm/smp_scu.h> 25#include <asm/smp_scu.h>
26 26
27#include <mach/clk.h>
27#include <mach/iomap.h> 28#include <mach/iomap.h>
29#include <mach/powergate.h>
30
31#include "fuse.h"
32#include "flowctrl.h"
33#include "reset.h"
28 34
29extern void tegra_secondary_startup(void); 35extern void tegra_secondary_startup(void);
30 36
31static DEFINE_SPINLOCK(boot_lock);
32static void __iomem *scu_base = IO_ADDRESS(TEGRA_ARM_PERIF_BASE); 37static void __iomem *scu_base = IO_ADDRESS(TEGRA_ARM_PERIF_BASE);
33 38
34#define EVP_CPU_RESET_VECTOR \ 39#define EVP_CPU_RESET_VECTOR \
35 (IO_ADDRESS(TEGRA_EXCEPTION_VECTORS_BASE) + 0x100) 40 (IO_ADDRESS(TEGRA_EXCEPTION_VECTORS_BASE) + 0x100)
36#define CLK_RST_CONTROLLER_CLK_CPU_CMPLX \ 41#define CLK_RST_CONTROLLER_CLK_CPU_CMPLX \
37 (IO_ADDRESS(TEGRA_CLK_RESET_BASE) + 0x4c) 42 (IO_ADDRESS(TEGRA_CLK_RESET_BASE) + 0x4c)
43#define CLK_RST_CONTROLLER_RST_CPU_CMPLX_SET \
44 (IO_ADDRESS(TEGRA_CLK_RESET_BASE) + 0x340)
38#define CLK_RST_CONTROLLER_RST_CPU_CMPLX_CLR \ 45#define CLK_RST_CONTROLLER_RST_CPU_CMPLX_CLR \
39 (IO_ADDRESS(TEGRA_CLK_RESET_BASE) + 0x344) 46 (IO_ADDRESS(TEGRA_CLK_RESET_BASE) + 0x344)
47#define CLK_RST_CONTROLLER_CLK_CPU_CMPLX_CLR \
48 (IO_ADDRESS(TEGRA_CLK_RESET_BASE) + 0x34c)
49
50#define CPU_CLOCK(cpu) (0x1<<(8+cpu))
51#define CPU_RESET(cpu) (0x1111ul<<(cpu))
40 52
41void __cpuinit platform_secondary_init(unsigned int cpu) 53void __cpuinit platform_secondary_init(unsigned int cpu)
42{ 54{
@@ -47,63 +59,106 @@ void __cpuinit platform_secondary_init(unsigned int cpu)
47 */ 59 */
48 gic_secondary_init(0); 60 gic_secondary_init(0);
49 61
50 /*
51 * Synchronise with the boot thread.
52 */
53 spin_lock(&boot_lock);
54 spin_unlock(&boot_lock);
55} 62}
56 63
57int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle) 64static int tegra20_power_up_cpu(unsigned int cpu)
58{ 65{
59 unsigned long old_boot_vector;
60 unsigned long boot_vector;
61 unsigned long timeout;
62 u32 reg; 66 u32 reg;
63 67
64 /* 68 /* Enable the CPU clock. */
65 * set synchronisation state between this boot processor 69 reg = readl(CLK_RST_CONTROLLER_CLK_CPU_CMPLX);
66 * and the secondary one 70 writel(reg & ~CPU_CLOCK(cpu), CLK_RST_CONTROLLER_CLK_CPU_CMPLX);
67 */ 71 barrier();
68 spin_lock(&boot_lock); 72 reg = readl(CLK_RST_CONTROLLER_CLK_CPU_CMPLX);
69 73
74 /* Clear flow controller CSR. */
75 flowctrl_write_cpu_csr(cpu, 0);
70 76
71 /* set the reset vector to point to the secondary_startup routine */ 77 return 0;
78}
72 79
73 boot_vector = virt_to_phys(tegra_secondary_startup); 80static int tegra30_power_up_cpu(unsigned int cpu)
74 old_boot_vector = readl(EVP_CPU_RESET_VECTOR); 81{
75 writel(boot_vector, EVP_CPU_RESET_VECTOR); 82 u32 reg;
83 int ret, pwrgateid;
84 unsigned long timeout;
76 85
77 /* enable cpu clock on cpu1 */ 86 pwrgateid = tegra_cpu_powergate_id(cpu);
78 reg = readl(CLK_RST_CONTROLLER_CLK_CPU_CMPLX); 87 if (pwrgateid < 0)
79 writel(reg & ~(1<<9), CLK_RST_CONTROLLER_CLK_CPU_CMPLX); 88 return pwrgateid;
89
90 /* If this is the first boot, toggle powergates directly. */
91 if (!tegra_powergate_is_powered(pwrgateid)) {
92 ret = tegra_powergate_power_on(pwrgateid);
93 if (ret)
94 return ret;
95
96 /* Wait for the power to come up. */
97 timeout = jiffies + 10*HZ;
98 while (tegra_powergate_is_powered(pwrgateid)) {
99 if (time_after(jiffies, timeout))
100 return -ETIMEDOUT;
101 udelay(10);
102 }
103 }
80 104
81 reg = (1<<13) | (1<<9) | (1<<5) | (1<<1); 105 /* CPU partition is powered. Enable the CPU clock. */
82 writel(reg, CLK_RST_CONTROLLER_RST_CPU_CMPLX_CLR); 106 writel(CPU_CLOCK(cpu), CLK_RST_CONTROLLER_CLK_CPU_CMPLX_CLR);
107 reg = readl(CLK_RST_CONTROLLER_CLK_CPU_CMPLX_CLR);
108 udelay(10);
83 109
84 smp_wmb(); 110 /* Remove I/O clamps. */
85 flush_cache_all(); 111 ret = tegra_powergate_remove_clamping(pwrgateid);
112 udelay(10);
86 113
87 /* unhalt the cpu */ 114 /* Clear flow controller CSR. */
88 writel(0, IO_ADDRESS(TEGRA_FLOW_CTRL_BASE) + 0x14); 115 flowctrl_write_cpu_csr(cpu, 0);
89 116
90 timeout = jiffies + (1 * HZ); 117 return 0;
91 while (time_before(jiffies, timeout)) { 118}
92 if (readl(EVP_CPU_RESET_VECTOR) != boot_vector) 119
93 break; 120int __cpuinit boot_secondary(unsigned int cpu, struct task_struct *idle)
94 udelay(10); 121{
95 } 122 int status;
96 123
97 /* put the old boot vector back */ 124 /*
98 writel(old_boot_vector, EVP_CPU_RESET_VECTOR); 125 * Force the CPU into reset. The CPU must remain in reset when the
126 * flow controller state is cleared (which will cause the flow
127 * controller to stop driving reset if the CPU has been power-gated
128 * via the flow controller). This will have no effect on first boot
129 * of the CPU since it should already be in reset.
130 */
131 writel(CPU_RESET(cpu), CLK_RST_CONTROLLER_RST_CPU_CMPLX_SET);
132 dmb();
99 133
100 /* 134 /*
101 * now the secondary core is starting up let it run its 135 * Unhalt the CPU. If the flow controller was used to power-gate the
102 * calibrations, then wait for it to finish 136 * CPU this will cause the flow controller to stop driving reset.
137 * The CPU will remain in reset because the clock and reset block
138 * is now driving reset.
103 */ 139 */
104 spin_unlock(&boot_lock); 140 flowctrl_write_cpu_halt(cpu, 0);
141
142 switch (tegra_chip_id) {
143 case TEGRA20:
144 status = tegra20_power_up_cpu(cpu);
145 break;
146 case TEGRA30:
147 status = tegra30_power_up_cpu(cpu);
148 break;
149 default:
150 status = -EINVAL;
151 break;
152 }
105 153
106 return 0; 154 if (status)
155 goto done;
156
157 /* Take the CPU out of reset. */
158 writel(CPU_RESET(cpu), CLK_RST_CONTROLLER_RST_CPU_CMPLX_CLR);
159 wmb();
160done:
161 return status;
107} 162}
108 163
109/* 164/*
@@ -128,6 +183,6 @@ void __init smp_init_cpus(void)
128 183
129void __init platform_smp_prepare_cpus(unsigned int max_cpus) 184void __init platform_smp_prepare_cpus(unsigned int max_cpus)
130{ 185{
131 186 tegra_cpu_reset_handler_init();
132 scu_enable(scu_base); 187 scu_enable(scu_base);
133} 188}
diff --git a/arch/arm/mach-tegra/pmc.c b/arch/arm/mach-tegra/pmc.c
new file mode 100644
index 00000000000..7af6a54404b
--- /dev/null
+++ b/arch/arm/mach-tegra/pmc.c
@@ -0,0 +1,76 @@
1/*
2 * Copyright (C) 2012 NVIDIA CORPORATION. All rights reserved.
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
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18#include <linux/kernel.h>
19#include <linux/io.h>
20#include <linux/of.h>
21
22#include <mach/iomap.h>
23
24#define PMC_CTRL 0x0
25#define PMC_CTRL_INTR_LOW (1 << 17)
26
27static inline u32 tegra_pmc_readl(u32 reg)
28{
29 return readl(IO_ADDRESS(TEGRA_PMC_BASE + reg));
30}
31
32static inline void tegra_pmc_writel(u32 val, u32 reg)
33{
34 writel(val, IO_ADDRESS(TEGRA_PMC_BASE + reg));
35}
36
37#ifdef CONFIG_OF
38static const struct of_device_id matches[] __initconst = {
39 { .compatible = "nvidia,tegra20-pmc" },
40 { }
41};
42#endif
43
44void __init tegra_pmc_init(void)
45{
46 /*
47 * For now, Harmony is the only board that uses the PMC, and it wants
48 * the signal inverted. Seaboard would too if it used the PMC.
49 * Hopefully by the time other boards want to use the PMC, everything
50 * will be device-tree, or they also want it inverted.
51 */
52 bool invert_interrupt = true;
53 u32 val;
54
55#ifdef CONFIG_OF
56 if (of_have_populated_dt()) {
57 struct device_node *np;
58
59 invert_interrupt = false;
60
61 np = of_find_matching_node(NULL, matches);
62 if (np) {
63 if (of_find_property(np, "nvidia,invert-interrupt",
64 NULL))
65 invert_interrupt = true;
66 }
67 }
68#endif
69
70 val = tegra_pmc_readl(PMC_CTRL);
71 if (invert_interrupt)
72 val |= PMC_CTRL_INTR_LOW;
73 else
74 val &= ~PMC_CTRL_INTR_LOW;
75 tegra_pmc_writel(val, PMC_CTRL);
76}
diff --git a/arch/arm/mach-highbank/include/mach/system.h b/arch/arm/mach-tegra/pmc.h
index b1d8b5fbe37..8995ee4a876 100644
--- a/arch/arm/mach-highbank/include/mach/system.h
+++ b/arch/arm/mach-tegra/pmc.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright 2010-2011 Calxeda, Inc. 2 * Copyright (C) 2012 NVIDIA CORPORATION. All rights reserved.
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,
@@ -10,15 +10,14 @@
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details. 11 * more details.
12 * 12 *
13 * You should have received a copy of the GNU General Public License along with 13 * You should have received a copy of the GNU General Public License
14 * this program. If not, see <http://www.gnu.org/licenses/>. 14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
15 */ 16 */
16#ifndef __MACH_SYSTEM_H
17#define __MACH_SYSTEM_H
18 17
19static inline void arch_idle(void) 18#ifndef __MACH_TEGRA_PMC_H
20{ 19#define __MACH_TEGRA_PMC_H
21 cpu_do_idle(); 20
22} 21void tegra_pmc_init(void);
23 22
24#endif 23#endif
diff --git a/arch/arm/mach-tegra/powergate.c b/arch/arm/mach-tegra/powergate.c
index 948306491a5..c238699ae86 100644
--- a/arch/arm/mach-tegra/powergate.c
+++ b/arch/arm/mach-tegra/powergate.c
@@ -31,6 +31,8 @@
31#include <mach/iomap.h> 31#include <mach/iomap.h>
32#include <mach/powergate.h> 32#include <mach/powergate.h>
33 33
34#include "fuse.h"
35
34#define PWRGATE_TOGGLE 0x30 36#define PWRGATE_TOGGLE 0x30
35#define PWRGATE_TOGGLE_START (1 << 8) 37#define PWRGATE_TOGGLE_START (1 << 8)
36 38
@@ -38,6 +40,16 @@
38 40
39#define PWRGATE_STATUS 0x38 41#define PWRGATE_STATUS 0x38
40 42
43static int tegra_num_powerdomains;
44static int tegra_num_cpu_domains;
45static u8 *tegra_cpu_domains;
46static u8 tegra30_cpu_domains[] = {
47 TEGRA_POWERGATE_CPU0,
48 TEGRA_POWERGATE_CPU1,
49 TEGRA_POWERGATE_CPU2,
50 TEGRA_POWERGATE_CPU3,
51};
52
41static DEFINE_SPINLOCK(tegra_powergate_lock); 53static DEFINE_SPINLOCK(tegra_powergate_lock);
42 54
43static void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE); 55static void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE);
@@ -75,7 +87,7 @@ static int tegra_powergate_set(int id, bool new_state)
75 87
76int tegra_powergate_power_on(int id) 88int tegra_powergate_power_on(int id)
77{ 89{
78 if (id < 0 || id >= TEGRA_NUM_POWERGATE) 90 if (id < 0 || id >= tegra_num_powerdomains)
79 return -EINVAL; 91 return -EINVAL;
80 92
81 return tegra_powergate_set(id, true); 93 return tegra_powergate_set(id, true);
@@ -83,17 +95,18 @@ int tegra_powergate_power_on(int id)
83 95
84int tegra_powergate_power_off(int id) 96int tegra_powergate_power_off(int id)
85{ 97{
86 if (id < 0 || id >= TEGRA_NUM_POWERGATE) 98 if (id < 0 || id >= tegra_num_powerdomains)
87 return -EINVAL; 99 return -EINVAL;
88 100
89 return tegra_powergate_set(id, false); 101 return tegra_powergate_set(id, false);
90} 102}
91 103
92static bool tegra_powergate_is_powered(int id) 104int tegra_powergate_is_powered(int id)
93{ 105{
94 u32 status; 106 u32 status;
95 107
96 WARN_ON(id < 0 || id >= TEGRA_NUM_POWERGATE); 108 if (id < 0 || id >= tegra_num_powerdomains)
109 return -EINVAL;
97 110
98 status = pmc_read(PWRGATE_STATUS) & (1 << id); 111 status = pmc_read(PWRGATE_STATUS) & (1 << id);
99 return !!status; 112 return !!status;
@@ -103,7 +116,7 @@ int tegra_powergate_remove_clamping(int id)
103{ 116{
104 u32 mask; 117 u32 mask;
105 118
106 if (id < 0 || id >= TEGRA_NUM_POWERGATE) 119 if (id < 0 || id >= tegra_num_powerdomains)
107 return -EINVAL; 120 return -EINVAL;
108 121
109 /* 122 /*
@@ -156,6 +169,34 @@ err_power:
156 return ret; 169 return ret;
157} 170}
158 171
172int tegra_cpu_powergate_id(int cpuid)
173{
174 if (cpuid > 0 && cpuid < tegra_num_cpu_domains)
175 return tegra_cpu_domains[cpuid];
176
177 return -EINVAL;
178}
179
180int __init tegra_powergate_init(void)
181{
182 switch (tegra_chip_id) {
183 case TEGRA20:
184 tegra_num_powerdomains = 7;
185 break;
186 case TEGRA30:
187 tegra_num_powerdomains = 14;
188 tegra_num_cpu_domains = 4;
189 tegra_cpu_domains = tegra30_cpu_domains;
190 break;
191 default:
192 /* Unknown Tegra variant. Disable powergating */
193 tegra_num_powerdomains = 0;
194 break;
195 }
196
197 return 0;
198}
199
159#ifdef CONFIG_DEBUG_FS 200#ifdef CONFIG_DEBUG_FS
160 201
161static const char * const powergate_name[] = { 202static const char * const powergate_name[] = {
@@ -175,7 +216,7 @@ static int powergate_show(struct seq_file *s, void *data)
175 seq_printf(s, " powergate powered\n"); 216 seq_printf(s, " powergate powered\n");
176 seq_printf(s, "------------------\n"); 217 seq_printf(s, "------------------\n");
177 218
178 for (i = 0; i < TEGRA_NUM_POWERGATE; i++) 219 for (i = 0; i < tegra_num_powerdomains; i++)
179 seq_printf(s, " %9s %7s\n", powergate_name[i], 220 seq_printf(s, " %9s %7s\n", powergate_name[i],
180 tegra_powergate_is_powered(i) ? "yes" : "no"); 221 tegra_powergate_is_powered(i) ? "yes" : "no");
181 return 0; 222 return 0;
diff --git a/arch/arm/mach-tegra/reset.c b/arch/arm/mach-tegra/reset.c
new file mode 100644
index 00000000000..4d6a2ee99c3
--- /dev/null
+++ b/arch/arm/mach-tegra/reset.c
@@ -0,0 +1,84 @@
1/*
2 * arch/arm/mach-tegra/reset.c
3 *
4 * Copyright (C) 2011,2012 NVIDIA Corporation.
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#include <linux/init.h>
18#include <linux/io.h>
19#include <linux/cpumask.h>
20#include <linux/bitops.h>
21
22#include <asm/cacheflush.h>
23#include <asm/hardware/cache-l2x0.h>
24
25#include <mach/iomap.h>
26#include <mach/irammap.h>
27
28#include "reset.h"
29#include "fuse.h"
30
31#define TEGRA_IRAM_RESET_BASE (TEGRA_IRAM_BASE + \
32 TEGRA_IRAM_RESET_HANDLER_OFFSET)
33
34static bool is_enabled;
35
36static void tegra_cpu_reset_handler_enable(void)
37{
38 void __iomem *iram_base = IO_ADDRESS(TEGRA_IRAM_RESET_BASE);
39 void __iomem *evp_cpu_reset =
40 IO_ADDRESS(TEGRA_EXCEPTION_VECTORS_BASE + 0x100);
41 void __iomem *sb_ctrl = IO_ADDRESS(TEGRA_SB_BASE);
42 u32 reg;
43
44 BUG_ON(is_enabled);
45 BUG_ON(tegra_cpu_reset_handler_size > TEGRA_IRAM_RESET_HANDLER_SIZE);
46
47 memcpy(iram_base, (void *)__tegra_cpu_reset_handler_start,
48 tegra_cpu_reset_handler_size);
49
50 /*
51 * NOTE: This must be the one and only write to the EVP CPU reset
52 * vector in the entire system.
53 */
54 writel(TEGRA_IRAM_RESET_BASE + tegra_cpu_reset_handler_offset,
55 evp_cpu_reset);
56 wmb();
57 reg = readl(evp_cpu_reset);
58
59 /*
60 * Prevent further modifications to the physical reset vector.
61 * NOTE: Has no effect on chips prior to Tegra30.
62 */
63 if (tegra_chip_id != TEGRA20) {
64 reg = readl(sb_ctrl);
65 reg |= 2;
66 writel(reg, sb_ctrl);
67 wmb();
68 }
69
70 is_enabled = true;
71}
72
73void __init tegra_cpu_reset_handler_init(void)
74{
75
76#ifdef CONFIG_SMP
77 __tegra_cpu_reset_handler_data[TEGRA_RESET_MASK_PRESENT] =
78 *((u32 *)cpu_present_mask);
79 __tegra_cpu_reset_handler_data[TEGRA_RESET_STARTUP_SECONDARY] =
80 virt_to_phys((void *)tegra_secondary_startup);
81#endif
82
83 tegra_cpu_reset_handler_enable();
84}
diff --git a/arch/arm/mach-tegra/reset.h b/arch/arm/mach-tegra/reset.h
new file mode 100644
index 00000000000..de88bf851dd
--- /dev/null
+++ b/arch/arm/mach-tegra/reset.h
@@ -0,0 +1,50 @@
1/*
2 * arch/arm/mach-tegra/reset.h
3 *
4 * CPU reset dispatcher.
5 *
6 * Copyright (c) 2011, NVIDIA Corporation.
7 *
8 * This software is licensed under the terms of the GNU General Public
9 * License version 2, as published by the Free Software Foundation, and
10 * may be copied, distributed, and modified under those terms.
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 */
18
19#ifndef __MACH_TEGRA_RESET_H
20#define __MACH_TEGRA_RESET_H
21
22#define TEGRA_RESET_MASK_PRESENT 0
23#define TEGRA_RESET_MASK_LP1 1
24#define TEGRA_RESET_MASK_LP2 2
25#define TEGRA_RESET_STARTUP_SECONDARY 3
26#define TEGRA_RESET_STARTUP_LP2 4
27#define TEGRA_RESET_STARTUP_LP1 5
28#define TEGRA_RESET_DATA_SIZE 6
29
30#ifndef __ASSEMBLY__
31
32extern unsigned long __tegra_cpu_reset_handler_data[TEGRA_RESET_DATA_SIZE];
33
34void __tegra_cpu_reset_handler_start(void);
35void __tegra_cpu_reset_handler(void);
36void __tegra_cpu_reset_handler_end(void);
37void tegra_secondary_startup(void);
38
39#define tegra_cpu_reset_handler_offset \
40 ((u32)__tegra_cpu_reset_handler - \
41 (u32)__tegra_cpu_reset_handler_start)
42
43#define tegra_cpu_reset_handler_size \
44 (__tegra_cpu_reset_handler_end - \
45 __tegra_cpu_reset_handler_start)
46
47void __init tegra_cpu_reset_handler_init(void);
48
49#endif
50#endif
diff --git a/arch/arm/mach-tegra/sleep.S b/arch/arm/mach-tegra/sleep.S
new file mode 100644
index 00000000000..8f9fde161c3
--- /dev/null
+++ b/arch/arm/mach-tegra/sleep.S
@@ -0,0 +1,91 @@
1/*
2 * arch/arm/mach-tegra/sleep.S
3 *
4 * Copyright (c) 2010-2011, NVIDIA Corporation.
5 * Copyright (c) 2011, Google, Inc.
6 *
7 * Author: Colin Cross <ccross@android.com>
8 * Gary King <gking@nvidia.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, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 * more details.
19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 */
24
25#include <linux/linkage.h>
26#include <mach/io.h>
27#include <mach/iomap.h>
28
29#include "flowctrl.h"
30
31#define TEGRA_FLOW_CTRL_VIRT (TEGRA_FLOW_CTRL_BASE - IO_PPSB_PHYS \
32 + IO_PPSB_VIRT)
33
34/* returns the offset of the flow controller halt register for a cpu */
35.macro cpu_to_halt_reg rd, rcpu
36 cmp \rcpu, #0
37 subne \rd, \rcpu, #1
38 movne \rd, \rd, lsl #3
39 addne \rd, \rd, #0x14
40 moveq \rd, #0
41.endm
42
43/* returns the offset of the flow controller csr register for a cpu */
44.macro cpu_to_csr_reg rd, rcpu
45 cmp \rcpu, #0
46 subne \rd, \rcpu, #1
47 movne \rd, \rd, lsl #3
48 addne \rd, \rd, #0x18
49 moveq \rd, #8
50.endm
51
52/* returns the ID of the current processor */
53.macro cpu_id, rd
54 mrc p15, 0, \rd, c0, c0, 5
55 and \rd, \rd, #0xF
56.endm
57
58/* loads a 32-bit value into a register without a data access */
59.macro mov32, reg, val
60 movw \reg, #:lower16:\val
61 movt \reg, #:upper16:\val
62.endm
63
64/*
65 * tegra_cpu_wfi
66 *
67 * puts current CPU in clock-gated wfi using the flow controller
68 *
69 * corrupts r0-r3
70 * must be called with MMU on
71 */
72
73ENTRY(tegra_cpu_wfi)
74 cpu_id r0
75 cpu_to_halt_reg r1, r0
76 cpu_to_csr_reg r2, r0
77 mov32 r0, TEGRA_FLOW_CTRL_VIRT
78 mov r3, #FLOW_CTRL_CSR_INTR_FLAG | FLOW_CTRL_CSR_EVENT_FLAG
79 str r3, [r0, r2] @ clear event & interrupt status
80 mov r3, #FLOW_CTRL_WAIT_FOR_INTERRUPT | FLOW_CTRL_JTAG_RESUME
81 str r3, [r0, r1] @ put flow controller in wait irq mode
82 dsb
83 wfi
84 mov r3, #0
85 str r3, [r0, r1] @ clear flow controller halt status
86 mov r3, #FLOW_CTRL_CSR_INTR_FLAG | FLOW_CTRL_CSR_EVENT_FLAG
87 str r3, [r0, r2] @ clear event & interrupt status
88 dsb
89 mov pc, lr
90ENDPROC(tegra_cpu_wfi)
91
diff --git a/arch/arm/mach-tegra/tegra2_clocks.c b/arch/arm/mach-tegra/tegra2_clocks.c
index ff9e6b6c046..592a4eeb532 100644
--- a/arch/arm/mach-tegra/tegra2_clocks.c
+++ b/arch/arm/mach-tegra/tegra2_clocks.c
@@ -720,7 +720,7 @@ static void tegra2_pllx_clk_init(struct clk *c)
720{ 720{
721 tegra2_pll_clk_init(c); 721 tegra2_pll_clk_init(c);
722 722
723 if (tegra_sku_id() == 7) 723 if (tegra_sku_id == 7)
724 c->max_rate = 750000000; 724 c->max_rate = 750000000;
725} 725}
726 726
@@ -1143,15 +1143,35 @@ static void tegra2_emc_clk_init(struct clk *c)
1143 1143
1144static long tegra2_emc_clk_round_rate(struct clk *c, unsigned long rate) 1144static long tegra2_emc_clk_round_rate(struct clk *c, unsigned long rate)
1145{ 1145{
1146 long new_rate = rate; 1146 long emc_rate;
1147 long clk_rate;
1147 1148
1148 new_rate = tegra_emc_round_rate(new_rate); 1149 /*
1149 if (new_rate < 0) 1150 * The slowest entry in the EMC clock table that is at least as
1151 * fast as rate.
1152 */
1153 emc_rate = tegra_emc_round_rate(rate);
1154 if (emc_rate < 0)
1150 return c->max_rate; 1155 return c->max_rate;
1151 1156
1152 BUG_ON(new_rate != tegra2_periph_clk_round_rate(c, new_rate)); 1157 /*
1158 * The fastest rate the PLL will generate that is at most the
1159 * requested rate.
1160 */
1161 clk_rate = tegra2_periph_clk_round_rate(c, emc_rate);
1162
1163 /*
1164 * If this fails, and emc_rate > clk_rate, it's because the maximum
1165 * rate in the EMC tables is larger than the maximum rate of the EMC
1166 * clock. The EMC clock's max rate is the rate it was running when the
1167 * kernel booted. Such a mismatch is probably due to using the wrong
1168 * BCT, i.e. using a Tegra20 BCT with an EMC table written for Tegra25.
1169 */
1170 WARN_ONCE(emc_rate != clk_rate,
1171 "emc_rate %ld != clk_rate %ld",
1172 emc_rate, clk_rate);
1153 1173
1154 return new_rate; 1174 return emc_rate;
1155} 1175}
1156 1176
1157static int tegra2_emc_clk_set_rate(struct clk *c, unsigned long rate) 1177static int tegra2_emc_clk_set_rate(struct clk *c, unsigned long rate)
diff --git a/arch/arm/mach-tegra/tegra2_emc.c b/arch/arm/mach-tegra/tegra2_emc.c
index 0f7ae6e90b5..5070d833bdd 100644
--- a/arch/arm/mach-tegra/tegra2_emc.c
+++ b/arch/arm/mach-tegra/tegra2_emc.c
@@ -16,14 +16,19 @@
16 */ 16 */
17 17
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/device.h>
19#include <linux/clk.h> 20#include <linux/clk.h>
20#include <linux/err.h> 21#include <linux/err.h>
21#include <linux/io.h> 22#include <linux/io.h>
22#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/of.h>
25#include <linux/platform_device.h>
26#include <linux/platform_data/tegra_emc.h>
23 27
24#include <mach/iomap.h> 28#include <mach/iomap.h>
25 29
26#include "tegra2_emc.h" 30#include "tegra2_emc.h"
31#include "fuse.h"
27 32
28#ifdef CONFIG_TEGRA_EMC_SCALING_ENABLE 33#ifdef CONFIG_TEGRA_EMC_SCALING_ENABLE
29static bool emc_enable = true; 34static bool emc_enable = true;
@@ -32,18 +37,17 @@ static bool emc_enable;
32#endif 37#endif
33module_param(emc_enable, bool, 0644); 38module_param(emc_enable, bool, 0644);
34 39
35static void __iomem *emc = IO_ADDRESS(TEGRA_EMC_BASE); 40static struct platform_device *emc_pdev;
36static const struct tegra_emc_table *tegra_emc_table; 41static void __iomem *emc_regbase;
37static int tegra_emc_table_size;
38 42
39static inline void emc_writel(u32 val, unsigned long addr) 43static inline void emc_writel(u32 val, unsigned long addr)
40{ 44{
41 writel(val, emc + addr); 45 writel(val, emc_regbase + addr);
42} 46}
43 47
44static inline u32 emc_readl(unsigned long addr) 48static inline u32 emc_readl(unsigned long addr)
45{ 49{
46 return readl(emc + addr); 50 return readl(emc_regbase + addr);
47} 51}
48 52
49static const unsigned long emc_reg_addr[TEGRA_EMC_NUM_REGS] = { 53static const unsigned long emc_reg_addr[TEGRA_EMC_NUM_REGS] = {
@@ -98,15 +102,15 @@ static const unsigned long emc_reg_addr[TEGRA_EMC_NUM_REGS] = {
98/* Select the closest EMC rate that is higher than the requested rate */ 102/* Select the closest EMC rate that is higher than the requested rate */
99long tegra_emc_round_rate(unsigned long rate) 103long tegra_emc_round_rate(unsigned long rate)
100{ 104{
105 struct tegra_emc_pdata *pdata;
101 int i; 106 int i;
102 int best = -1; 107 int best = -1;
103 unsigned long distance = ULONG_MAX; 108 unsigned long distance = ULONG_MAX;
104 109
105 if (!tegra_emc_table) 110 if (!emc_pdev)
106 return -EINVAL; 111 return -EINVAL;
107 112
108 if (!emc_enable) 113 pdata = emc_pdev->dev.platform_data;
109 return -EINVAL;
110 114
111 pr_debug("%s: %lu\n", __func__, rate); 115 pr_debug("%s: %lu\n", __func__, rate);
112 116
@@ -116,10 +120,10 @@ long tegra_emc_round_rate(unsigned long rate)
116 */ 120 */
117 rate = rate / 2 / 1000; 121 rate = rate / 2 / 1000;
118 122
119 for (i = 0; i < tegra_emc_table_size; i++) { 123 for (i = 0; i < pdata->num_tables; i++) {
120 if (tegra_emc_table[i].rate >= rate && 124 if (pdata->tables[i].rate >= rate &&
121 (tegra_emc_table[i].rate - rate) < distance) { 125 (pdata->tables[i].rate - rate) < distance) {
122 distance = tegra_emc_table[i].rate - rate; 126 distance = pdata->tables[i].rate - rate;
123 best = i; 127 best = i;
124 } 128 }
125 } 129 }
@@ -127,9 +131,9 @@ long tegra_emc_round_rate(unsigned long rate)
127 if (best < 0) 131 if (best < 0)
128 return -EINVAL; 132 return -EINVAL;
129 133
130 pr_debug("%s: using %lu\n", __func__, tegra_emc_table[best].rate); 134 pr_debug("%s: using %lu\n", __func__, pdata->tables[best].rate);
131 135
132 return tegra_emc_table[best].rate * 2 * 1000; 136 return pdata->tables[best].rate * 2 * 1000;
133} 137}
134 138
135/* 139/*
@@ -142,37 +146,211 @@ long tegra_emc_round_rate(unsigned long rate)
142 */ 146 */
143int tegra_emc_set_rate(unsigned long rate) 147int tegra_emc_set_rate(unsigned long rate)
144{ 148{
149 struct tegra_emc_pdata *pdata;
145 int i; 150 int i;
146 int j; 151 int j;
147 152
148 if (!tegra_emc_table) 153 if (!emc_pdev)
149 return -EINVAL; 154 return -EINVAL;
150 155
156 pdata = emc_pdev->dev.platform_data;
157
151 /* 158 /*
152 * The EMC clock rate is twice the bus rate, and the bus rate is 159 * The EMC clock rate is twice the bus rate, and the bus rate is
153 * measured in kHz 160 * measured in kHz
154 */ 161 */
155 rate = rate / 2 / 1000; 162 rate = rate / 2 / 1000;
156 163
157 for (i = 0; i < tegra_emc_table_size; i++) 164 for (i = 0; i < pdata->num_tables; i++)
158 if (tegra_emc_table[i].rate == rate) 165 if (pdata->tables[i].rate == rate)
159 break; 166 break;
160 167
161 if (i >= tegra_emc_table_size) 168 if (i >= pdata->num_tables)
162 return -EINVAL; 169 return -EINVAL;
163 170
164 pr_debug("%s: setting to %lu\n", __func__, rate); 171 pr_debug("%s: setting to %lu\n", __func__, rate);
165 172
166 for (j = 0; j < TEGRA_EMC_NUM_REGS; j++) 173 for (j = 0; j < TEGRA_EMC_NUM_REGS; j++)
167 emc_writel(tegra_emc_table[i].regs[j], emc_reg_addr[j]); 174 emc_writel(pdata->tables[i].regs[j], emc_reg_addr[j]);
168 175
169 emc_readl(tegra_emc_table[i].regs[TEGRA_EMC_NUM_REGS - 1]); 176 emc_readl(pdata->tables[i].regs[TEGRA_EMC_NUM_REGS - 1]);
170 177
171 return 0; 178 return 0;
172} 179}
173 180
174void tegra_init_emc(const struct tegra_emc_table *table, int table_size) 181#ifdef CONFIG_OF
182static struct device_node *tegra_emc_ramcode_devnode(struct device_node *np)
183{
184 struct device_node *iter;
185 u32 reg;
186
187 for_each_child_of_node(np, iter) {
188 if (of_property_read_u32(np, "nvidia,ram-code", &reg))
189 continue;
190 if (reg == tegra_bct_strapping)
191 return of_node_get(iter);
192 }
193
194 return NULL;
195}
196
197static struct tegra_emc_pdata *tegra_emc_dt_parse_pdata(
198 struct platform_device *pdev)
199{
200 struct device_node *np = pdev->dev.of_node;
201 struct device_node *tnp, *iter;
202 struct tegra_emc_pdata *pdata;
203 int ret, i, num_tables;
204
205 if (!np)
206 return NULL;
207
208 if (of_find_property(np, "nvidia,use-ram-code", NULL)) {
209 tnp = tegra_emc_ramcode_devnode(np);
210 if (!tnp)
211 dev_warn(&pdev->dev,
212 "can't find emc table for ram-code 0x%02x\n",
213 tegra_bct_strapping);
214 } else
215 tnp = of_node_get(np);
216
217 if (!tnp)
218 return NULL;
219
220 num_tables = 0;
221 for_each_child_of_node(tnp, iter)
222 if (of_device_is_compatible(iter, "nvidia,tegra20-emc-table"))
223 num_tables++;
224
225 if (!num_tables) {
226 pdata = NULL;
227 goto out;
228 }
229
230 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
231 pdata->tables = devm_kzalloc(&pdev->dev,
232 sizeof(*pdata->tables) * num_tables,
233 GFP_KERNEL);
234
235 i = 0;
236 for_each_child_of_node(tnp, iter) {
237 u32 prop;
238
239 ret = of_property_read_u32(iter, "clock-frequency", &prop);
240 if (ret) {
241 dev_err(&pdev->dev, "no clock-frequency in %s\n",
242 iter->full_name);
243 continue;
244 }
245 pdata->tables[i].rate = prop;
246
247 ret = of_property_read_u32_array(iter, "nvidia,emc-registers",
248 pdata->tables[i].regs,
249 TEGRA_EMC_NUM_REGS);
250 if (ret) {
251 dev_err(&pdev->dev,
252 "malformed emc-registers property in %s\n",
253 iter->full_name);
254 continue;
255 }
256
257 i++;
258 }
259 pdata->num_tables = i;
260
261out:
262 of_node_put(tnp);
263 return pdata;
264}
265#else
266static struct tegra_emc_pdata *tegra_emc_dt_parse_pdata(
267 struct platform_device *pdev)
268{
269 return NULL;
270}
271#endif
272
273static struct tegra_emc_pdata __devinit *tegra_emc_fill_pdata(struct platform_device *pdev)
274{
275 struct clk *c = clk_get_sys(NULL, "emc");
276 struct tegra_emc_pdata *pdata;
277 unsigned long khz;
278 int i;
279
280 WARN_ON(pdev->dev.platform_data);
281 BUG_ON(IS_ERR_OR_NULL(c));
282
283 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
284 pdata->tables = devm_kzalloc(&pdev->dev, sizeof(*pdata->tables),
285 GFP_KERNEL);
286
287 pdata->tables[0].rate = clk_get_rate(c) / 2 / 1000;
288
289 for (i = 0; i < TEGRA_EMC_NUM_REGS; i++)
290 pdata->tables[0].regs[i] = emc_readl(emc_reg_addr[i]);
291
292 pdata->num_tables = 1;
293
294 khz = pdata->tables[0].rate;
295 dev_info(&pdev->dev, "no tables provided, using %ld kHz emc, "
296 "%ld kHz mem\n", khz * 2, khz);
297
298 return pdata;
299}
300
301static int __devinit tegra_emc_probe(struct platform_device *pdev)
302{
303 struct tegra_emc_pdata *pdata;
304 struct resource *res;
305
306 if (!emc_enable) {
307 dev_err(&pdev->dev, "disabled per module parameter\n");
308 return -ENODEV;
309 }
310
311 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
312 if (!res) {
313 dev_err(&pdev->dev, "missing register base\n");
314 return -ENOMEM;
315 }
316
317 emc_regbase = devm_request_and_ioremap(&pdev->dev, res);
318 if (!emc_regbase) {
319 dev_err(&pdev->dev, "failed to remap registers\n");
320 return -ENOMEM;
321 }
322
323 pdata = pdev->dev.platform_data;
324
325 if (!pdata)
326 pdata = tegra_emc_dt_parse_pdata(pdev);
327
328 if (!pdata)
329 pdata = tegra_emc_fill_pdata(pdev);
330
331 pdev->dev.platform_data = pdata;
332
333 emc_pdev = pdev;
334
335 return 0;
336}
337
338static struct of_device_id tegra_emc_of_match[] __devinitdata = {
339 { .compatible = "nvidia,tegra20-emc", },
340 { },
341};
342
343static struct platform_driver tegra_emc_driver = {
344 .driver = {
345 .name = "tegra-emc",
346 .owner = THIS_MODULE,
347 .of_match_table = tegra_emc_of_match,
348 },
349 .probe = tegra_emc_probe,
350};
351
352static int __init tegra_emc_init(void)
175{ 353{
176 tegra_emc_table = table; 354 return platform_driver_register(&tegra_emc_driver);
177 tegra_emc_table_size = table_size;
178} 355}
356device_initcall(tegra_emc_init);
diff --git a/arch/arm/mach-tegra/tegra2_emc.h b/arch/arm/mach-tegra/tegra2_emc.h
index 19f08cb3160..f61409b54cb 100644
--- a/arch/arm/mach-tegra/tegra2_emc.h
+++ b/arch/arm/mach-tegra/tegra2_emc.h
@@ -15,13 +15,10 @@
15 * 15 *
16 */ 16 */
17 17
18#define TEGRA_EMC_NUM_REGS 46 18#ifndef __MACH_TEGRA_TEGRA2_EMC_H_
19 19#define __MACH_TEGRA_TEGRA2_EMC_H
20struct tegra_emc_table {
21 unsigned long rate;
22 u32 regs[TEGRA_EMC_NUM_REGS];
23};
24 20
25int tegra_emc_set_rate(unsigned long rate); 21int tegra_emc_set_rate(unsigned long rate);
26long tegra_emc_round_rate(unsigned long rate); 22long tegra_emc_round_rate(unsigned long rate);
27void tegra_init_emc(const struct tegra_emc_table *table, int table_size); 23
24#endif
diff --git a/arch/arm/mach-tegra/tegra30_clocks.c b/arch/arm/mach-tegra/tegra30_clocks.c
new file mode 100644
index 00000000000..6d08b53f92d
--- /dev/null
+++ b/arch/arm/mach-tegra/tegra30_clocks.c
@@ -0,0 +1,3099 @@
1/*
2 * arch/arm/mach-tegra/tegra30_clocks.c
3 *
4 * Copyright (c) 2010-2011 NVIDIA CORPORATION. All rights reserved.
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, 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 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20
21#include <linux/kernel.h>
22#include <linux/module.h>
23#include <linux/list.h>
24#include <linux/spinlock.h>
25#include <linux/delay.h>
26#include <linux/err.h>
27#include <linux/io.h>
28#include <linux/clk.h>
29#include <linux/cpufreq.h>
30#include <linux/syscore_ops.h>
31
32#include <asm/clkdev.h>
33
34#include <mach/iomap.h>
35
36#include "clock.h"
37#include "fuse.h"
38
39#define USE_PLL_LOCK_BITS 0
40
41#define RST_DEVICES_L 0x004
42#define RST_DEVICES_H 0x008
43#define RST_DEVICES_U 0x00C
44#define RST_DEVICES_V 0x358
45#define RST_DEVICES_W 0x35C
46#define RST_DEVICES_SET_L 0x300
47#define RST_DEVICES_CLR_L 0x304
48#define RST_DEVICES_SET_V 0x430
49#define RST_DEVICES_CLR_V 0x434
50#define RST_DEVICES_NUM 5
51
52#define CLK_OUT_ENB_L 0x010
53#define CLK_OUT_ENB_H 0x014
54#define CLK_OUT_ENB_U 0x018
55#define CLK_OUT_ENB_V 0x360
56#define CLK_OUT_ENB_W 0x364
57#define CLK_OUT_ENB_SET_L 0x320
58#define CLK_OUT_ENB_CLR_L 0x324
59#define CLK_OUT_ENB_SET_V 0x440
60#define CLK_OUT_ENB_CLR_V 0x444
61#define CLK_OUT_ENB_NUM 5
62
63#define RST_DEVICES_V_SWR_CPULP_RST_DIS (0x1 << 1)
64#define CLK_OUT_ENB_V_CLK_ENB_CPULP_EN (0x1 << 1)
65
66#define PERIPH_CLK_TO_BIT(c) (1 << (c->u.periph.clk_num % 32))
67#define PERIPH_CLK_TO_RST_REG(c) \
68 periph_clk_to_reg((c), RST_DEVICES_L, RST_DEVICES_V, 4)
69#define PERIPH_CLK_TO_RST_SET_REG(c) \
70 periph_clk_to_reg((c), RST_DEVICES_SET_L, RST_DEVICES_SET_V, 8)
71#define PERIPH_CLK_TO_RST_CLR_REG(c) \
72 periph_clk_to_reg((c), RST_DEVICES_CLR_L, RST_DEVICES_CLR_V, 8)
73
74#define PERIPH_CLK_TO_ENB_REG(c) \
75 periph_clk_to_reg((c), CLK_OUT_ENB_L, CLK_OUT_ENB_V, 4)
76#define PERIPH_CLK_TO_ENB_SET_REG(c) \
77 periph_clk_to_reg((c), CLK_OUT_ENB_SET_L, CLK_OUT_ENB_SET_V, 8)
78#define PERIPH_CLK_TO_ENB_CLR_REG(c) \
79 periph_clk_to_reg((c), CLK_OUT_ENB_CLR_L, CLK_OUT_ENB_CLR_V, 8)
80
81#define CLK_MASK_ARM 0x44
82#define MISC_CLK_ENB 0x48
83
84#define OSC_CTRL 0x50
85#define OSC_CTRL_OSC_FREQ_MASK (0xF<<28)
86#define OSC_CTRL_OSC_FREQ_13MHZ (0x0<<28)
87#define OSC_CTRL_OSC_FREQ_19_2MHZ (0x4<<28)
88#define OSC_CTRL_OSC_FREQ_12MHZ (0x8<<28)
89#define OSC_CTRL_OSC_FREQ_26MHZ (0xC<<28)
90#define OSC_CTRL_OSC_FREQ_16_8MHZ (0x1<<28)
91#define OSC_CTRL_OSC_FREQ_38_4MHZ (0x5<<28)
92#define OSC_CTRL_OSC_FREQ_48MHZ (0x9<<28)
93#define OSC_CTRL_MASK (0x3f2 | OSC_CTRL_OSC_FREQ_MASK)
94
95#define OSC_CTRL_PLL_REF_DIV_MASK (3<<26)
96#define OSC_CTRL_PLL_REF_DIV_1 (0<<26)
97#define OSC_CTRL_PLL_REF_DIV_2 (1<<26)
98#define OSC_CTRL_PLL_REF_DIV_4 (2<<26)
99
100#define OSC_FREQ_DET 0x58
101#define OSC_FREQ_DET_TRIG (1<<31)
102
103#define OSC_FREQ_DET_STATUS 0x5C
104#define OSC_FREQ_DET_BUSY (1<<31)
105#define OSC_FREQ_DET_CNT_MASK 0xFFFF
106
107#define PERIPH_CLK_SOURCE_I2S1 0x100
108#define PERIPH_CLK_SOURCE_EMC 0x19c
109#define PERIPH_CLK_SOURCE_OSC 0x1fc
110#define PERIPH_CLK_SOURCE_NUM1 \
111 ((PERIPH_CLK_SOURCE_OSC - PERIPH_CLK_SOURCE_I2S1) / 4)
112
113#define PERIPH_CLK_SOURCE_G3D2 0x3b0
114#define PERIPH_CLK_SOURCE_SE 0x42c
115#define PERIPH_CLK_SOURCE_NUM2 \
116 ((PERIPH_CLK_SOURCE_SE - PERIPH_CLK_SOURCE_G3D2) / 4 + 1)
117
118#define AUDIO_DLY_CLK 0x49c
119#define AUDIO_SYNC_CLK_SPDIF 0x4b4
120#define PERIPH_CLK_SOURCE_NUM3 \
121 ((AUDIO_SYNC_CLK_SPDIF - AUDIO_DLY_CLK) / 4 + 1)
122
123#define PERIPH_CLK_SOURCE_NUM (PERIPH_CLK_SOURCE_NUM1 + \
124 PERIPH_CLK_SOURCE_NUM2 + \
125 PERIPH_CLK_SOURCE_NUM3)
126
127#define CPU_SOFTRST_CTRL 0x380
128
129#define PERIPH_CLK_SOURCE_DIVU71_MASK 0xFF
130#define PERIPH_CLK_SOURCE_DIVU16_MASK 0xFFFF
131#define PERIPH_CLK_SOURCE_DIV_SHIFT 0
132#define PERIPH_CLK_SOURCE_DIVIDLE_SHIFT 8
133#define PERIPH_CLK_SOURCE_DIVIDLE_VAL 50
134#define PERIPH_CLK_UART_DIV_ENB (1<<24)
135#define PERIPH_CLK_VI_SEL_EX_SHIFT 24
136#define PERIPH_CLK_VI_SEL_EX_MASK (0x3<<PERIPH_CLK_VI_SEL_EX_SHIFT)
137#define PERIPH_CLK_NAND_DIV_EX_ENB (1<<8)
138#define PERIPH_CLK_DTV_POLARITY_INV (1<<25)
139
140#define AUDIO_SYNC_SOURCE_MASK 0x0F
141#define AUDIO_SYNC_DISABLE_BIT 0x10
142#define AUDIO_SYNC_TAP_NIBBLE_SHIFT(c) ((c->reg_shift - 24) * 4)
143
144#define PLL_BASE 0x0
145#define PLL_BASE_BYPASS (1<<31)
146#define PLL_BASE_ENABLE (1<<30)
147#define PLL_BASE_REF_ENABLE (1<<29)
148#define PLL_BASE_OVERRIDE (1<<28)
149#define PLL_BASE_LOCK (1<<27)
150#define PLL_BASE_DIVP_MASK (0x7<<20)
151#define PLL_BASE_DIVP_SHIFT 20
152#define PLL_BASE_DIVN_MASK (0x3FF<<8)
153#define PLL_BASE_DIVN_SHIFT 8
154#define PLL_BASE_DIVM_MASK (0x1F)
155#define PLL_BASE_DIVM_SHIFT 0
156
157#define PLL_OUT_RATIO_MASK (0xFF<<8)
158#define PLL_OUT_RATIO_SHIFT 8
159#define PLL_OUT_OVERRIDE (1<<2)
160#define PLL_OUT_CLKEN (1<<1)
161#define PLL_OUT_RESET_DISABLE (1<<0)
162
163#define PLL_MISC(c) \
164 (((c)->flags & PLL_ALT_MISC_REG) ? 0x4 : 0xc)
165#define PLL_MISC_LOCK_ENABLE(c) \
166 (((c)->flags & (PLLU | PLLD)) ? (1<<22) : (1<<18))
167
168#define PLL_MISC_DCCON_SHIFT 20
169#define PLL_MISC_CPCON_SHIFT 8
170#define PLL_MISC_CPCON_MASK (0xF<<PLL_MISC_CPCON_SHIFT)
171#define PLL_MISC_LFCON_SHIFT 4
172#define PLL_MISC_LFCON_MASK (0xF<<PLL_MISC_LFCON_SHIFT)
173#define PLL_MISC_VCOCON_SHIFT 0
174#define PLL_MISC_VCOCON_MASK (0xF<<PLL_MISC_VCOCON_SHIFT)
175#define PLLD_MISC_CLKENABLE (1<<30)
176
177#define PLLU_BASE_POST_DIV (1<<20)
178
179#define PLLD_BASE_DSIB_MUX_SHIFT 25
180#define PLLD_BASE_DSIB_MUX_MASK (1<<PLLD_BASE_DSIB_MUX_SHIFT)
181#define PLLD_BASE_CSI_CLKENABLE (1<<26)
182#define PLLD_MISC_DSI_CLKENABLE (1<<30)
183#define PLLD_MISC_DIV_RST (1<<23)
184#define PLLD_MISC_DCCON_SHIFT 12
185
186#define PLLDU_LFCON_SET_DIVN 600
187
188/* FIXME: OUT_OF_TABLE_CPCON per pll */
189#define OUT_OF_TABLE_CPCON 0x8
190
191#define SUPER_CLK_MUX 0x00
192#define SUPER_STATE_SHIFT 28
193#define SUPER_STATE_MASK (0xF << SUPER_STATE_SHIFT)
194#define SUPER_STATE_STANDBY (0x0 << SUPER_STATE_SHIFT)
195#define SUPER_STATE_IDLE (0x1 << SUPER_STATE_SHIFT)
196#define SUPER_STATE_RUN (0x2 << SUPER_STATE_SHIFT)
197#define SUPER_STATE_IRQ (0x3 << SUPER_STATE_SHIFT)
198#define SUPER_STATE_FIQ (0x4 << SUPER_STATE_SHIFT)
199#define SUPER_LP_DIV2_BYPASS (0x1 << 16)
200#define SUPER_SOURCE_MASK 0xF
201#define SUPER_FIQ_SOURCE_SHIFT 12
202#define SUPER_IRQ_SOURCE_SHIFT 8
203#define SUPER_RUN_SOURCE_SHIFT 4
204#define SUPER_IDLE_SOURCE_SHIFT 0
205
206#define SUPER_CLK_DIVIDER 0x04
207#define SUPER_CLOCK_DIV_U71_SHIFT 16
208#define SUPER_CLOCK_DIV_U71_MASK (0xff << SUPER_CLOCK_DIV_U71_SHIFT)
209/* guarantees safe cpu backup */
210#define SUPER_CLOCK_DIV_U71_MIN 0x2
211
212#define BUS_CLK_DISABLE (1<<3)
213#define BUS_CLK_DIV_MASK 0x3
214
215#define PMC_CTRL 0x0
216 #define PMC_CTRL_BLINK_ENB (1 << 7)
217
218#define PMC_DPD_PADS_ORIDE 0x1c
219 #define PMC_DPD_PADS_ORIDE_BLINK_ENB (1 << 20)
220
221#define PMC_BLINK_TIMER_DATA_ON_SHIFT 0
222#define PMC_BLINK_TIMER_DATA_ON_MASK 0x7fff
223#define PMC_BLINK_TIMER_ENB (1 << 15)
224#define PMC_BLINK_TIMER_DATA_OFF_SHIFT 16
225#define PMC_BLINK_TIMER_DATA_OFF_MASK 0xffff
226
227#define PMC_PLLP_WB0_OVERRIDE 0xf8
228#define PMC_PLLP_WB0_OVERRIDE_PLLM_ENABLE (1 << 12)
229
230#define UTMIP_PLL_CFG2 0x488
231#define UTMIP_PLL_CFG2_STABLE_COUNT(x) (((x) & 0xfff) << 6)
232#define UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(x) (((x) & 0x3f) << 18)
233#define UTMIP_PLL_CFG2_FORCE_PD_SAMP_A_POWERDOWN (1 << 0)
234#define UTMIP_PLL_CFG2_FORCE_PD_SAMP_B_POWERDOWN (1 << 2)
235#define UTMIP_PLL_CFG2_FORCE_PD_SAMP_C_POWERDOWN (1 << 4)
236
237#define UTMIP_PLL_CFG1 0x484
238#define UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(x) (((x) & 0x1f) << 27)
239#define UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(x) (((x) & 0xfff) << 0)
240#define UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN (1 << 14)
241#define UTMIP_PLL_CFG1_FORCE_PLL_ACTIVE_POWERDOWN (1 << 12)
242#define UTMIP_PLL_CFG1_FORCE_PLLU_POWERDOWN (1 << 16)
243
244#define PLLE_BASE_CML_ENABLE (1<<31)
245#define PLLE_BASE_ENABLE (1<<30)
246#define PLLE_BASE_DIVCML_SHIFT 24
247#define PLLE_BASE_DIVCML_MASK (0xf<<PLLE_BASE_DIVCML_SHIFT)
248#define PLLE_BASE_DIVP_SHIFT 16
249#define PLLE_BASE_DIVP_MASK (0x3f<<PLLE_BASE_DIVP_SHIFT)
250#define PLLE_BASE_DIVN_SHIFT 8
251#define PLLE_BASE_DIVN_MASK (0xFF<<PLLE_BASE_DIVN_SHIFT)
252#define PLLE_BASE_DIVM_SHIFT 0
253#define PLLE_BASE_DIVM_MASK (0xFF<<PLLE_BASE_DIVM_SHIFT)
254#define PLLE_BASE_DIV_MASK \
255 (PLLE_BASE_DIVCML_MASK | PLLE_BASE_DIVP_MASK | \
256 PLLE_BASE_DIVN_MASK | PLLE_BASE_DIVM_MASK)
257#define PLLE_BASE_DIV(m, n, p, cml) \
258 (((cml)<<PLLE_BASE_DIVCML_SHIFT) | ((p)<<PLLE_BASE_DIVP_SHIFT) | \
259 ((n)<<PLLE_BASE_DIVN_SHIFT) | ((m)<<PLLE_BASE_DIVM_SHIFT))
260
261#define PLLE_MISC_SETUP_BASE_SHIFT 16
262#define PLLE_MISC_SETUP_BASE_MASK (0xFFFF<<PLLE_MISC_SETUP_BASE_SHIFT)
263#define PLLE_MISC_READY (1<<15)
264#define PLLE_MISC_LOCK (1<<11)
265#define PLLE_MISC_LOCK_ENABLE (1<<9)
266#define PLLE_MISC_SETUP_EX_SHIFT 2
267#define PLLE_MISC_SETUP_EX_MASK (0x3<<PLLE_MISC_SETUP_EX_SHIFT)
268#define PLLE_MISC_SETUP_MASK \
269 (PLLE_MISC_SETUP_BASE_MASK | PLLE_MISC_SETUP_EX_MASK)
270#define PLLE_MISC_SETUP_VALUE \
271 ((0x7<<PLLE_MISC_SETUP_BASE_SHIFT) | (0x0<<PLLE_MISC_SETUP_EX_SHIFT))
272
273#define PLLE_SS_CTRL 0x68
274#define PLLE_SS_INCINTRV_SHIFT 24
275#define PLLE_SS_INCINTRV_MASK (0x3f<<PLLE_SS_INCINTRV_SHIFT)
276#define PLLE_SS_INC_SHIFT 16
277#define PLLE_SS_INC_MASK (0xff<<PLLE_SS_INC_SHIFT)
278#define PLLE_SS_MAX_SHIFT 0
279#define PLLE_SS_MAX_MASK (0x1ff<<PLLE_SS_MAX_SHIFT)
280#define PLLE_SS_COEFFICIENTS_MASK \
281 (PLLE_SS_INCINTRV_MASK | PLLE_SS_INC_MASK | PLLE_SS_MAX_MASK)
282#define PLLE_SS_COEFFICIENTS_12MHZ \
283 ((0x18<<PLLE_SS_INCINTRV_SHIFT) | (0x1<<PLLE_SS_INC_SHIFT) | \
284 (0x24<<PLLE_SS_MAX_SHIFT))
285#define PLLE_SS_DISABLE ((1<<12) | (1<<11) | (1<<10))
286
287#define PLLE_AUX 0x48c
288#define PLLE_AUX_PLLP_SEL (1<<2)
289#define PLLE_AUX_CML_SATA_ENABLE (1<<1)
290#define PLLE_AUX_CML_PCIE_ENABLE (1<<0)
291
292#define PMC_SATA_PWRGT 0x1ac
293#define PMC_SATA_PWRGT_PLLE_IDDQ_VALUE (1<<5)
294#define PMC_SATA_PWRGT_PLLE_IDDQ_SWCTL (1<<4)
295
296#define ROUND_DIVIDER_UP 0
297#define ROUND_DIVIDER_DOWN 1
298
299/* FIXME: recommended safety delay after lock is detected */
300#define PLL_POST_LOCK_DELAY 100
301
302/**
303* Structure defining the fields for USB UTMI clocks Parameters.
304*/
305struct utmi_clk_param {
306 /* Oscillator Frequency in KHz */
307 u32 osc_frequency;
308 /* UTMIP PLL Enable Delay Count */
309 u8 enable_delay_count;
310 /* UTMIP PLL Stable count */
311 u8 stable_count;
312 /* UTMIP PLL Active delay count */
313 u8 active_delay_count;
314 /* UTMIP PLL Xtal frequency count */
315 u8 xtal_freq_count;
316};
317
318static const struct utmi_clk_param utmi_parameters[] = {
319 {
320 .osc_frequency = 13000000,
321 .enable_delay_count = 0x02,
322 .stable_count = 0x33,
323 .active_delay_count = 0x05,
324 .xtal_freq_count = 0x7F
325 },
326 {
327 .osc_frequency = 19200000,
328 .enable_delay_count = 0x03,
329 .stable_count = 0x4B,
330 .active_delay_count = 0x06,
331 .xtal_freq_count = 0xBB},
332 {
333 .osc_frequency = 12000000,
334 .enable_delay_count = 0x02,
335 .stable_count = 0x2F,
336 .active_delay_count = 0x04,
337 .xtal_freq_count = 0x76
338 },
339 {
340 .osc_frequency = 26000000,
341 .enable_delay_count = 0x04,
342 .stable_count = 0x66,
343 .active_delay_count = 0x09,
344 .xtal_freq_count = 0xFE
345 },
346 {
347 .osc_frequency = 16800000,
348 .enable_delay_count = 0x03,
349 .stable_count = 0x41,
350 .active_delay_count = 0x0A,
351 .xtal_freq_count = 0xA4
352 },
353};
354
355static void __iomem *reg_clk_base = IO_ADDRESS(TEGRA_CLK_RESET_BASE);
356static void __iomem *reg_pmc_base = IO_ADDRESS(TEGRA_PMC_BASE);
357static void __iomem *misc_gp_hidrev_base = IO_ADDRESS(TEGRA_APB_MISC_BASE);
358
359#define MISC_GP_HIDREV 0x804
360
361/*
362 * Some peripheral clocks share an enable bit, so refcount the enable bits
363 * in registers CLK_ENABLE_L, ... CLK_ENABLE_W
364 */
365static int tegra_periph_clk_enable_refcount[CLK_OUT_ENB_NUM * 32];
366
367#define clk_writel(value, reg) \
368 __raw_writel(value, (u32)reg_clk_base + (reg))
369#define clk_readl(reg) \
370 __raw_readl((u32)reg_clk_base + (reg))
371#define pmc_writel(value, reg) \
372 __raw_writel(value, (u32)reg_pmc_base + (reg))
373#define pmc_readl(reg) \
374 __raw_readl((u32)reg_pmc_base + (reg))
375#define chipid_readl() \
376 __raw_readl((u32)misc_gp_hidrev_base + MISC_GP_HIDREV)
377
378#define clk_writel_delay(value, reg) \
379 do { \
380 __raw_writel((value), (u32)reg_clk_base + (reg)); \
381 udelay(2); \
382 } while (0)
383
384
385static inline int clk_set_div(struct clk *c, u32 n)
386{
387 return clk_set_rate(c, (clk_get_rate(c->parent) + n-1) / n);
388}
389
390static inline u32 periph_clk_to_reg(
391 struct clk *c, u32 reg_L, u32 reg_V, int offs)
392{
393 u32 reg = c->u.periph.clk_num / 32;
394 BUG_ON(reg >= RST_DEVICES_NUM);
395 if (reg < 3)
396 reg = reg_L + (reg * offs);
397 else
398 reg = reg_V + ((reg - 3) * offs);
399 return reg;
400}
401
402static unsigned long clk_measure_input_freq(void)
403{
404 u32 clock_autodetect;
405 clk_writel(OSC_FREQ_DET_TRIG | 1, OSC_FREQ_DET);
406 do {} while (clk_readl(OSC_FREQ_DET_STATUS) & OSC_FREQ_DET_BUSY);
407 clock_autodetect = clk_readl(OSC_FREQ_DET_STATUS);
408 if (clock_autodetect >= 732 - 3 && clock_autodetect <= 732 + 3) {
409 return 12000000;
410 } else if (clock_autodetect >= 794 - 3 && clock_autodetect <= 794 + 3) {
411 return 13000000;
412 } else if (clock_autodetect >= 1172 - 3 && clock_autodetect <= 1172 + 3) {
413 return 19200000;
414 } else if (clock_autodetect >= 1587 - 3 && clock_autodetect <= 1587 + 3) {
415 return 26000000;
416 } else if (clock_autodetect >= 1025 - 3 && clock_autodetect <= 1025 + 3) {
417 return 16800000;
418 } else if (clock_autodetect >= 2344 - 3 && clock_autodetect <= 2344 + 3) {
419 return 38400000;
420 } else if (clock_autodetect >= 2928 - 3 && clock_autodetect <= 2928 + 3) {
421 return 48000000;
422 } else {
423 pr_err("%s: Unexpected clock autodetect value %d", __func__,
424 clock_autodetect);
425 BUG();
426 return 0;
427 }
428}
429
430static int clk_div71_get_divider(unsigned long parent_rate, unsigned long rate,
431 u32 flags, u32 round_mode)
432{
433 s64 divider_u71 = parent_rate;
434 if (!rate)
435 return -EINVAL;
436
437 if (!(flags & DIV_U71_INT))
438 divider_u71 *= 2;
439 if (round_mode == ROUND_DIVIDER_UP)
440 divider_u71 += rate - 1;
441 do_div(divider_u71, rate);
442 if (flags & DIV_U71_INT)
443 divider_u71 *= 2;
444
445 if (divider_u71 - 2 < 0)
446 return 0;
447
448 if (divider_u71 - 2 > 255)
449 return -EINVAL;
450
451 return divider_u71 - 2;
452}
453
454static int clk_div16_get_divider(unsigned long parent_rate, unsigned long rate)
455{
456 s64 divider_u16;
457
458 divider_u16 = parent_rate;
459 if (!rate)
460 return -EINVAL;
461 divider_u16 += rate - 1;
462 do_div(divider_u16, rate);
463
464 if (divider_u16 - 1 < 0)
465 return 0;
466
467 if (divider_u16 - 1 > 0xFFFF)
468 return -EINVAL;
469
470 return divider_u16 - 1;
471}
472
473/* clk_m functions */
474static unsigned long tegra30_clk_m_autodetect_rate(struct clk *c)
475{
476 u32 osc_ctrl = clk_readl(OSC_CTRL);
477 u32 auto_clock_control = osc_ctrl & ~OSC_CTRL_OSC_FREQ_MASK;
478 u32 pll_ref_div = osc_ctrl & OSC_CTRL_PLL_REF_DIV_MASK;
479
480 c->rate = clk_measure_input_freq();
481 switch (c->rate) {
482 case 12000000:
483 auto_clock_control |= OSC_CTRL_OSC_FREQ_12MHZ;
484 BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_1);
485 break;
486 case 13000000:
487 auto_clock_control |= OSC_CTRL_OSC_FREQ_13MHZ;
488 BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_1);
489 break;
490 case 19200000:
491 auto_clock_control |= OSC_CTRL_OSC_FREQ_19_2MHZ;
492 BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_1);
493 break;
494 case 26000000:
495 auto_clock_control |= OSC_CTRL_OSC_FREQ_26MHZ;
496 BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_1);
497 break;
498 case 16800000:
499 auto_clock_control |= OSC_CTRL_OSC_FREQ_16_8MHZ;
500 BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_1);
501 break;
502 case 38400000:
503 auto_clock_control |= OSC_CTRL_OSC_FREQ_38_4MHZ;
504 BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_2);
505 break;
506 case 48000000:
507 auto_clock_control |= OSC_CTRL_OSC_FREQ_48MHZ;
508 BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_4);
509 break;
510 default:
511 pr_err("%s: Unexpected clock rate %ld", __func__, c->rate);
512 BUG();
513 }
514 clk_writel(auto_clock_control, OSC_CTRL);
515 return c->rate;
516}
517
518static void tegra30_clk_m_init(struct clk *c)
519{
520 pr_debug("%s on clock %s\n", __func__, c->name);
521 tegra30_clk_m_autodetect_rate(c);
522}
523
524static int tegra30_clk_m_enable(struct clk *c)
525{
526 pr_debug("%s on clock %s\n", __func__, c->name);
527 return 0;
528}
529
530static void tegra30_clk_m_disable(struct clk *c)
531{
532 pr_debug("%s on clock %s\n", __func__, c->name);
533 WARN(1, "Attempting to disable main SoC clock\n");
534}
535
536static struct clk_ops tegra_clk_m_ops = {
537 .init = tegra30_clk_m_init,
538 .enable = tegra30_clk_m_enable,
539 .disable = tegra30_clk_m_disable,
540};
541
542static struct clk_ops tegra_clk_m_div_ops = {
543 .enable = tegra30_clk_m_enable,
544};
545
546/* PLL reference divider functions */
547static void tegra30_pll_ref_init(struct clk *c)
548{
549 u32 pll_ref_div = clk_readl(OSC_CTRL) & OSC_CTRL_PLL_REF_DIV_MASK;
550 pr_debug("%s on clock %s\n", __func__, c->name);
551
552 switch (pll_ref_div) {
553 case OSC_CTRL_PLL_REF_DIV_1:
554 c->div = 1;
555 break;
556 case OSC_CTRL_PLL_REF_DIV_2:
557 c->div = 2;
558 break;
559 case OSC_CTRL_PLL_REF_DIV_4:
560 c->div = 4;
561 break;
562 default:
563 pr_err("%s: Invalid pll ref divider %d", __func__, pll_ref_div);
564 BUG();
565 }
566 c->mul = 1;
567 c->state = ON;
568}
569
570static struct clk_ops tegra_pll_ref_ops = {
571 .init = tegra30_pll_ref_init,
572 .enable = tegra30_clk_m_enable,
573 .disable = tegra30_clk_m_disable,
574};
575
576/* super clock functions */
577/* "super clocks" on tegra30 have two-stage muxes, fractional 7.1 divider and
578 * clock skipping super divider. We will ignore the clock skipping divider,
579 * since we can't lower the voltage when using the clock skip, but we can if
580 * we lower the PLL frequency. We will use 7.1 divider for CPU super-clock
581 * only when its parent is a fixed rate PLL, since we can't change PLL rate
582 * in this case.
583 */
584static void tegra30_super_clk_init(struct clk *c)
585{
586 u32 val;
587 int source;
588 int shift;
589 const struct clk_mux_sel *sel;
590 val = clk_readl(c->reg + SUPER_CLK_MUX);
591 c->state = ON;
592 BUG_ON(((val & SUPER_STATE_MASK) != SUPER_STATE_RUN) &&
593 ((val & SUPER_STATE_MASK) != SUPER_STATE_IDLE));
594 shift = ((val & SUPER_STATE_MASK) == SUPER_STATE_IDLE) ?
595 SUPER_IDLE_SOURCE_SHIFT : SUPER_RUN_SOURCE_SHIFT;
596 source = (val >> shift) & SUPER_SOURCE_MASK;
597 if (c->flags & DIV_2)
598 source |= val & SUPER_LP_DIV2_BYPASS;
599 for (sel = c->inputs; sel->input != NULL; sel++) {
600 if (sel->value == source)
601 break;
602 }
603 BUG_ON(sel->input == NULL);
604 c->parent = sel->input;
605
606 if (c->flags & DIV_U71) {
607 /* Init safe 7.1 divider value (does not affect PLLX path) */
608 clk_writel(SUPER_CLOCK_DIV_U71_MIN << SUPER_CLOCK_DIV_U71_SHIFT,
609 c->reg + SUPER_CLK_DIVIDER);
610 c->mul = 2;
611 c->div = 2;
612 if (!(c->parent->flags & PLLX))
613 c->div += SUPER_CLOCK_DIV_U71_MIN;
614 } else
615 clk_writel(0, c->reg + SUPER_CLK_DIVIDER);
616}
617
618static int tegra30_super_clk_enable(struct clk *c)
619{
620 return 0;
621}
622
623static void tegra30_super_clk_disable(struct clk *c)
624{
625 /* since tegra 3 has 2 CPU super clocks - low power lp-mode clock and
626 geared up g-mode super clock - mode switch may request to disable
627 either of them; accept request with no affect on h/w */
628}
629
630static int tegra30_super_clk_set_parent(struct clk *c, struct clk *p)
631{
632 u32 val;
633 const struct clk_mux_sel *sel;
634 int shift;
635
636 val = clk_readl(c->reg + SUPER_CLK_MUX);
637 BUG_ON(((val & SUPER_STATE_MASK) != SUPER_STATE_RUN) &&
638 ((val & SUPER_STATE_MASK) != SUPER_STATE_IDLE));
639 shift = ((val & SUPER_STATE_MASK) == SUPER_STATE_IDLE) ?
640 SUPER_IDLE_SOURCE_SHIFT : SUPER_RUN_SOURCE_SHIFT;
641 for (sel = c->inputs; sel->input != NULL; sel++) {
642 if (sel->input == p) {
643 /* For LP mode super-clock switch between PLLX direct
644 and divided-by-2 outputs is allowed only when other
645 than PLLX clock source is current parent */
646 if ((c->flags & DIV_2) && (p->flags & PLLX) &&
647 ((sel->value ^ val) & SUPER_LP_DIV2_BYPASS)) {
648 if (c->parent->flags & PLLX)
649 return -EINVAL;
650 val ^= SUPER_LP_DIV2_BYPASS;
651 clk_writel_delay(val, c->reg);
652 }
653 val &= ~(SUPER_SOURCE_MASK << shift);
654 val |= (sel->value & SUPER_SOURCE_MASK) << shift;
655
656 /* 7.1 divider for CPU super-clock does not affect
657 PLLX path */
658 if (c->flags & DIV_U71) {
659 u32 div = 0;
660 if (!(p->flags & PLLX)) {
661 div = clk_readl(c->reg +
662 SUPER_CLK_DIVIDER);
663 div &= SUPER_CLOCK_DIV_U71_MASK;
664 div >>= SUPER_CLOCK_DIV_U71_SHIFT;
665 }
666 c->div = div + 2;
667 c->mul = 2;
668 }
669
670 if (c->refcnt)
671 clk_enable(p);
672
673 clk_writel_delay(val, c->reg);
674
675 if (c->refcnt && c->parent)
676 clk_disable(c->parent);
677
678 clk_reparent(c, p);
679 return 0;
680 }
681 }
682 return -EINVAL;
683}
684
685/*
686 * Do not use super clocks "skippers", since dividing using a clock skipper
687 * does not allow the voltage to be scaled down. Instead adjust the rate of
688 * the parent clock. This requires that the parent of a super clock have no
689 * other children, otherwise the rate will change underneath the other
690 * children. Special case: if fixed rate PLL is CPU super clock parent the
691 * rate of this PLL can't be changed, and it has many other children. In
692 * this case use 7.1 fractional divider to adjust the super clock rate.
693 */
694static int tegra30_super_clk_set_rate(struct clk *c, unsigned long rate)
695{
696 if ((c->flags & DIV_U71) && (c->parent->flags & PLL_FIXED)) {
697 int div = clk_div71_get_divider(c->parent->u.pll.fixed_rate,
698 rate, c->flags, ROUND_DIVIDER_DOWN);
699 div = max(div, SUPER_CLOCK_DIV_U71_MIN);
700
701 clk_writel(div << SUPER_CLOCK_DIV_U71_SHIFT,
702 c->reg + SUPER_CLK_DIVIDER);
703 c->div = div + 2;
704 c->mul = 2;
705 return 0;
706 }
707 return clk_set_rate(c->parent, rate);
708}
709
710static struct clk_ops tegra_super_ops = {
711 .init = tegra30_super_clk_init,
712 .enable = tegra30_super_clk_enable,
713 .disable = tegra30_super_clk_disable,
714 .set_parent = tegra30_super_clk_set_parent,
715 .set_rate = tegra30_super_clk_set_rate,
716};
717
718static int tegra30_twd_clk_set_rate(struct clk *c, unsigned long rate)
719{
720 /* The input value 'rate' is the clock rate of the CPU complex. */
721 c->rate = (rate * c->mul) / c->div;
722 return 0;
723}
724
725static struct clk_ops tegra30_twd_ops = {
726 .set_rate = tegra30_twd_clk_set_rate,
727};
728
729/* Blink output functions */
730
731static void tegra30_blink_clk_init(struct clk *c)
732{
733 u32 val;
734
735 val = pmc_readl(PMC_CTRL);
736 c->state = (val & PMC_CTRL_BLINK_ENB) ? ON : OFF;
737 c->mul = 1;
738 val = pmc_readl(c->reg);
739
740 if (val & PMC_BLINK_TIMER_ENB) {
741 unsigned int on_off;
742
743 on_off = (val >> PMC_BLINK_TIMER_DATA_ON_SHIFT) &
744 PMC_BLINK_TIMER_DATA_ON_MASK;
745 val >>= PMC_BLINK_TIMER_DATA_OFF_SHIFT;
746 val &= PMC_BLINK_TIMER_DATA_OFF_MASK;
747 on_off += val;
748 /* each tick in the blink timer is 4 32KHz clocks */
749 c->div = on_off * 4;
750 } else {
751 c->div = 1;
752 }
753}
754
755static int tegra30_blink_clk_enable(struct clk *c)
756{
757 u32 val;
758
759 val = pmc_readl(PMC_DPD_PADS_ORIDE);
760 pmc_writel(val | PMC_DPD_PADS_ORIDE_BLINK_ENB, PMC_DPD_PADS_ORIDE);
761
762 val = pmc_readl(PMC_CTRL);
763 pmc_writel(val | PMC_CTRL_BLINK_ENB, PMC_CTRL);
764
765 return 0;
766}
767
768static void tegra30_blink_clk_disable(struct clk *c)
769{
770 u32 val;
771
772 val = pmc_readl(PMC_CTRL);
773 pmc_writel(val & ~PMC_CTRL_BLINK_ENB, PMC_CTRL);
774
775 val = pmc_readl(PMC_DPD_PADS_ORIDE);
776 pmc_writel(val & ~PMC_DPD_PADS_ORIDE_BLINK_ENB, PMC_DPD_PADS_ORIDE);
777}
778
779static int tegra30_blink_clk_set_rate(struct clk *c, unsigned long rate)
780{
781 unsigned long parent_rate = clk_get_rate(c->parent);
782 if (rate >= parent_rate) {
783 c->div = 1;
784 pmc_writel(0, c->reg);
785 } else {
786 unsigned int on_off;
787 u32 val;
788
789 on_off = DIV_ROUND_UP(parent_rate / 8, rate);
790 c->div = on_off * 8;
791
792 val = (on_off & PMC_BLINK_TIMER_DATA_ON_MASK) <<
793 PMC_BLINK_TIMER_DATA_ON_SHIFT;
794 on_off &= PMC_BLINK_TIMER_DATA_OFF_MASK;
795 on_off <<= PMC_BLINK_TIMER_DATA_OFF_SHIFT;
796 val |= on_off;
797 val |= PMC_BLINK_TIMER_ENB;
798 pmc_writel(val, c->reg);
799 }
800
801 return 0;
802}
803
804static struct clk_ops tegra_blink_clk_ops = {
805 .init = &tegra30_blink_clk_init,
806 .enable = &tegra30_blink_clk_enable,
807 .disable = &tegra30_blink_clk_disable,
808 .set_rate = &tegra30_blink_clk_set_rate,
809};
810
811/* PLL Functions */
812static int tegra30_pll_clk_wait_for_lock(struct clk *c, u32 lock_reg,
813 u32 lock_bit)
814{
815#if USE_PLL_LOCK_BITS
816 int i;
817 for (i = 0; i < c->u.pll.lock_delay; i++) {
818 if (clk_readl(lock_reg) & lock_bit) {
819 udelay(PLL_POST_LOCK_DELAY);
820 return 0;
821 }
822 udelay(2); /* timeout = 2 * lock time */
823 }
824 pr_err("Timed out waiting for lock bit on pll %s", c->name);
825 return -1;
826#endif
827 udelay(c->u.pll.lock_delay);
828
829 return 0;
830}
831
832
833static void tegra30_utmi_param_configure(struct clk *c)
834{
835 u32 reg;
836 int i;
837 unsigned long main_rate =
838 clk_get_rate(c->parent->parent);
839
840 for (i = 0; i < ARRAY_SIZE(utmi_parameters); i++) {
841 if (main_rate == utmi_parameters[i].osc_frequency)
842 break;
843 }
844
845 if (i >= ARRAY_SIZE(utmi_parameters)) {
846 pr_err("%s: Unexpected main rate %lu\n", __func__, main_rate);
847 return;
848 }
849
850 reg = clk_readl(UTMIP_PLL_CFG2);
851
852 /* Program UTMIP PLL stable and active counts */
853 /* [FIXME] arclk_rst.h says WRONG! This should be 1ms -> 0x50 Check! */
854 reg &= ~UTMIP_PLL_CFG2_STABLE_COUNT(~0);
855 reg |= UTMIP_PLL_CFG2_STABLE_COUNT(
856 utmi_parameters[i].stable_count);
857
858 reg &= ~UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(~0);
859
860 reg |= UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(
861 utmi_parameters[i].active_delay_count);
862
863 /* Remove power downs from UTMIP PLL control bits */
864 reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_A_POWERDOWN;
865 reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_B_POWERDOWN;
866 reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_C_POWERDOWN;
867
868 clk_writel(reg, UTMIP_PLL_CFG2);
869
870 /* Program UTMIP PLL delay and oscillator frequency counts */
871 reg = clk_readl(UTMIP_PLL_CFG1);
872 reg &= ~UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(~0);
873
874 reg |= UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(
875 utmi_parameters[i].enable_delay_count);
876
877 reg &= ~UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(~0);
878 reg |= UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(
879 utmi_parameters[i].xtal_freq_count);
880
881 /* Remove power downs from UTMIP PLL control bits */
882 reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN;
883 reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ACTIVE_POWERDOWN;
884 reg &= ~UTMIP_PLL_CFG1_FORCE_PLLU_POWERDOWN;
885
886 clk_writel(reg, UTMIP_PLL_CFG1);
887}
888
889static void tegra30_pll_clk_init(struct clk *c)
890{
891 u32 val = clk_readl(c->reg + PLL_BASE);
892
893 c->state = (val & PLL_BASE_ENABLE) ? ON : OFF;
894
895 if (c->flags & PLL_FIXED && !(val & PLL_BASE_OVERRIDE)) {
896 const struct clk_pll_freq_table *sel;
897 unsigned long input_rate = clk_get_rate(c->parent);
898 for (sel = c->u.pll.freq_table; sel->input_rate != 0; sel++) {
899 if (sel->input_rate == input_rate &&
900 sel->output_rate == c->u.pll.fixed_rate) {
901 c->mul = sel->n;
902 c->div = sel->m * sel->p;
903 return;
904 }
905 }
906 pr_err("Clock %s has unknown fixed frequency\n", c->name);
907 BUG();
908 } else if (val & PLL_BASE_BYPASS) {
909 c->mul = 1;
910 c->div = 1;
911 } else {
912 c->mul = (val & PLL_BASE_DIVN_MASK) >> PLL_BASE_DIVN_SHIFT;
913 c->div = (val & PLL_BASE_DIVM_MASK) >> PLL_BASE_DIVM_SHIFT;
914 if (c->flags & PLLU)
915 c->div *= (val & PLLU_BASE_POST_DIV) ? 1 : 2;
916 else
917 c->div *= (0x1 << ((val & PLL_BASE_DIVP_MASK) >>
918 PLL_BASE_DIVP_SHIFT));
919 if (c->flags & PLL_FIXED) {
920 unsigned long rate = clk_get_rate_locked(c);
921 BUG_ON(rate != c->u.pll.fixed_rate);
922 }
923 }
924
925 if (c->flags & PLLU)
926 tegra30_utmi_param_configure(c);
927}
928
929static int tegra30_pll_clk_enable(struct clk *c)
930{
931 u32 val;
932 pr_debug("%s on clock %s\n", __func__, c->name);
933
934#if USE_PLL_LOCK_BITS
935 val = clk_readl(c->reg + PLL_MISC(c));
936 val |= PLL_MISC_LOCK_ENABLE(c);
937 clk_writel(val, c->reg + PLL_MISC(c));
938#endif
939 val = clk_readl(c->reg + PLL_BASE);
940 val &= ~PLL_BASE_BYPASS;
941 val |= PLL_BASE_ENABLE;
942 clk_writel(val, c->reg + PLL_BASE);
943
944 if (c->flags & PLLM) {
945 val = pmc_readl(PMC_PLLP_WB0_OVERRIDE);
946 val |= PMC_PLLP_WB0_OVERRIDE_PLLM_ENABLE;
947 pmc_writel(val, PMC_PLLP_WB0_OVERRIDE);
948 }
949
950 tegra30_pll_clk_wait_for_lock(c, c->reg + PLL_BASE, PLL_BASE_LOCK);
951
952 return 0;
953}
954
955static void tegra30_pll_clk_disable(struct clk *c)
956{
957 u32 val;
958 pr_debug("%s on clock %s\n", __func__, c->name);
959
960 val = clk_readl(c->reg);
961 val &= ~(PLL_BASE_BYPASS | PLL_BASE_ENABLE);
962 clk_writel(val, c->reg);
963
964 if (c->flags & PLLM) {
965 val = pmc_readl(PMC_PLLP_WB0_OVERRIDE);
966 val &= ~PMC_PLLP_WB0_OVERRIDE_PLLM_ENABLE;
967 pmc_writel(val, PMC_PLLP_WB0_OVERRIDE);
968 }
969}
970
971static int tegra30_pll_clk_set_rate(struct clk *c, unsigned long rate)
972{
973 u32 val, p_div, old_base;
974 unsigned long input_rate;
975 const struct clk_pll_freq_table *sel;
976 struct clk_pll_freq_table cfg;
977
978 pr_debug("%s: %s %lu\n", __func__, c->name, rate);
979
980 if (c->flags & PLL_FIXED) {
981 int ret = 0;
982 if (rate != c->u.pll.fixed_rate) {
983 pr_err("%s: Can not change %s fixed rate %lu to %lu\n",
984 __func__, c->name, c->u.pll.fixed_rate, rate);
985 ret = -EINVAL;
986 }
987 return ret;
988 }
989
990 if (c->flags & PLLM) {
991 if (rate != clk_get_rate_locked(c)) {
992 pr_err("%s: Can not change memory %s rate in flight\n",
993 __func__, c->name);
994 return -EINVAL;
995 }
996 return 0;
997 }
998
999 p_div = 0;
1000 input_rate = clk_get_rate(c->parent);
1001
1002 /* Check if the target rate is tabulated */
1003 for (sel = c->u.pll.freq_table; sel->input_rate != 0; sel++) {
1004 if (sel->input_rate == input_rate && sel->output_rate == rate) {
1005 if (c->flags & PLLU) {
1006 BUG_ON(sel->p < 1 || sel->p > 2);
1007 if (sel->p == 1)
1008 p_div = PLLU_BASE_POST_DIV;
1009 } else {
1010 BUG_ON(sel->p < 1);
1011 for (val = sel->p; val > 1; val >>= 1)
1012 p_div++;
1013 p_div <<= PLL_BASE_DIVP_SHIFT;
1014 }
1015 break;
1016 }
1017 }
1018
1019 /* Configure out-of-table rate */
1020 if (sel->input_rate == 0) {
1021 unsigned long cfreq;
1022 BUG_ON(c->flags & PLLU);
1023 sel = &cfg;
1024
1025 switch (input_rate) {
1026 case 12000000:
1027 case 26000000:
1028 cfreq = (rate <= 1000000 * 1000) ? 1000000 : 2000000;
1029 break;
1030 case 13000000:
1031 cfreq = (rate <= 1000000 * 1000) ? 1000000 : 2600000;
1032 break;
1033 case 16800000:
1034 case 19200000:
1035 cfreq = (rate <= 1200000 * 1000) ? 1200000 : 2400000;
1036 break;
1037 default:
1038 pr_err("%s: Unexpected reference rate %lu\n",
1039 __func__, input_rate);
1040 BUG();
1041 }
1042
1043 /* Raise VCO to guarantee 0.5% accuracy */
1044 for (cfg.output_rate = rate; cfg.output_rate < 200 * cfreq;
1045 cfg.output_rate <<= 1)
1046 p_div++;
1047
1048 cfg.p = 0x1 << p_div;
1049 cfg.m = input_rate / cfreq;
1050 cfg.n = cfg.output_rate / cfreq;
1051 cfg.cpcon = OUT_OF_TABLE_CPCON;
1052
1053 if ((cfg.m > (PLL_BASE_DIVM_MASK >> PLL_BASE_DIVM_SHIFT)) ||
1054 (cfg.n > (PLL_BASE_DIVN_MASK >> PLL_BASE_DIVN_SHIFT)) ||
1055 (p_div > (PLL_BASE_DIVP_MASK >> PLL_BASE_DIVP_SHIFT)) ||
1056 (cfg.output_rate > c->u.pll.vco_max)) {
1057 pr_err("%s: Failed to set %s out-of-table rate %lu\n",
1058 __func__, c->name, rate);
1059 return -EINVAL;
1060 }
1061 p_div <<= PLL_BASE_DIVP_SHIFT;
1062 }
1063
1064 c->mul = sel->n;
1065 c->div = sel->m * sel->p;
1066
1067 old_base = val = clk_readl(c->reg + PLL_BASE);
1068 val &= ~(PLL_BASE_DIVM_MASK | PLL_BASE_DIVN_MASK |
1069 ((c->flags & PLLU) ? PLLU_BASE_POST_DIV : PLL_BASE_DIVP_MASK));
1070 val |= (sel->m << PLL_BASE_DIVM_SHIFT) |
1071 (sel->n << PLL_BASE_DIVN_SHIFT) | p_div;
1072 if (val == old_base)
1073 return 0;
1074
1075 if (c->state == ON) {
1076 tegra30_pll_clk_disable(c);
1077 val &= ~(PLL_BASE_BYPASS | PLL_BASE_ENABLE);
1078 }
1079 clk_writel(val, c->reg + PLL_BASE);
1080
1081 if (c->flags & PLL_HAS_CPCON) {
1082 val = clk_readl(c->reg + PLL_MISC(c));
1083 val &= ~PLL_MISC_CPCON_MASK;
1084 val |= sel->cpcon << PLL_MISC_CPCON_SHIFT;
1085 if (c->flags & (PLLU | PLLD)) {
1086 val &= ~PLL_MISC_LFCON_MASK;
1087 if (sel->n >= PLLDU_LFCON_SET_DIVN)
1088 val |= 0x1 << PLL_MISC_LFCON_SHIFT;
1089 } else if (c->flags & (PLLX | PLLM)) {
1090 val &= ~(0x1 << PLL_MISC_DCCON_SHIFT);
1091 if (rate >= (c->u.pll.vco_max >> 1))
1092 val |= 0x1 << PLL_MISC_DCCON_SHIFT;
1093 }
1094 clk_writel(val, c->reg + PLL_MISC(c));
1095 }
1096
1097 if (c->state == ON)
1098 tegra30_pll_clk_enable(c);
1099
1100 return 0;
1101}
1102
1103static struct clk_ops tegra_pll_ops = {
1104 .init = tegra30_pll_clk_init,
1105 .enable = tegra30_pll_clk_enable,
1106 .disable = tegra30_pll_clk_disable,
1107 .set_rate = tegra30_pll_clk_set_rate,
1108};
1109
1110static int
1111tegra30_plld_clk_cfg_ex(struct clk *c, enum tegra_clk_ex_param p, u32 setting)
1112{
1113 u32 val, mask, reg;
1114
1115 switch (p) {
1116 case TEGRA_CLK_PLLD_CSI_OUT_ENB:
1117 mask = PLLD_BASE_CSI_CLKENABLE;
1118 reg = c->reg + PLL_BASE;
1119 break;
1120 case TEGRA_CLK_PLLD_DSI_OUT_ENB:
1121 mask = PLLD_MISC_DSI_CLKENABLE;
1122 reg = c->reg + PLL_MISC(c);
1123 break;
1124 case TEGRA_CLK_PLLD_MIPI_MUX_SEL:
1125 if (!(c->flags & PLL_ALT_MISC_REG)) {
1126 mask = PLLD_BASE_DSIB_MUX_MASK;
1127 reg = c->reg + PLL_BASE;
1128 break;
1129 }
1130 /* fall through - error since PLLD2 does not have MUX_SEL control */
1131 default:
1132 return -EINVAL;
1133 }
1134
1135 val = clk_readl(reg);
1136 if (setting)
1137 val |= mask;
1138 else
1139 val &= ~mask;
1140 clk_writel(val, reg);
1141 return 0;
1142}
1143
1144static struct clk_ops tegra_plld_ops = {
1145 .init = tegra30_pll_clk_init,
1146 .enable = tegra30_pll_clk_enable,
1147 .disable = tegra30_pll_clk_disable,
1148 .set_rate = tegra30_pll_clk_set_rate,
1149 .clk_cfg_ex = tegra30_plld_clk_cfg_ex,
1150};
1151
1152static void tegra30_plle_clk_init(struct clk *c)
1153{
1154 u32 val;
1155
1156 val = clk_readl(PLLE_AUX);
1157 c->parent = (val & PLLE_AUX_PLLP_SEL) ?
1158 tegra_get_clock_by_name("pll_p") :
1159 tegra_get_clock_by_name("pll_ref");
1160
1161 val = clk_readl(c->reg + PLL_BASE);
1162 c->state = (val & PLLE_BASE_ENABLE) ? ON : OFF;
1163 c->mul = (val & PLLE_BASE_DIVN_MASK) >> PLLE_BASE_DIVN_SHIFT;
1164 c->div = (val & PLLE_BASE_DIVM_MASK) >> PLLE_BASE_DIVM_SHIFT;
1165 c->div *= (val & PLLE_BASE_DIVP_MASK) >> PLLE_BASE_DIVP_SHIFT;
1166}
1167
1168static void tegra30_plle_clk_disable(struct clk *c)
1169{
1170 u32 val;
1171 pr_debug("%s on clock %s\n", __func__, c->name);
1172
1173 val = clk_readl(c->reg + PLL_BASE);
1174 val &= ~(PLLE_BASE_CML_ENABLE | PLLE_BASE_ENABLE);
1175 clk_writel(val, c->reg + PLL_BASE);
1176}
1177
1178static void tegra30_plle_training(struct clk *c)
1179{
1180 u32 val;
1181
1182 /* PLLE is already disabled, and setup cleared;
1183 * create falling edge on PLLE IDDQ input */
1184 val = pmc_readl(PMC_SATA_PWRGT);
1185 val |= PMC_SATA_PWRGT_PLLE_IDDQ_VALUE;
1186 pmc_writel(val, PMC_SATA_PWRGT);
1187
1188 val = pmc_readl(PMC_SATA_PWRGT);
1189 val |= PMC_SATA_PWRGT_PLLE_IDDQ_SWCTL;
1190 pmc_writel(val, PMC_SATA_PWRGT);
1191
1192 val = pmc_readl(PMC_SATA_PWRGT);
1193 val &= ~PMC_SATA_PWRGT_PLLE_IDDQ_VALUE;
1194 pmc_writel(val, PMC_SATA_PWRGT);
1195
1196 do {
1197 val = clk_readl(c->reg + PLL_MISC(c));
1198 } while (!(val & PLLE_MISC_READY));
1199}
1200
1201static int tegra30_plle_configure(struct clk *c, bool force_training)
1202{
1203 u32 val;
1204 const struct clk_pll_freq_table *sel;
1205 unsigned long rate = c->u.pll.fixed_rate;
1206 unsigned long input_rate = clk_get_rate(c->parent);
1207
1208 for (sel = c->u.pll.freq_table; sel->input_rate != 0; sel++) {
1209 if (sel->input_rate == input_rate && sel->output_rate == rate)
1210 break;
1211 }
1212
1213 if (sel->input_rate == 0)
1214 return -ENOSYS;
1215
1216 /* disable PLLE, clear setup fiels */
1217 tegra30_plle_clk_disable(c);
1218
1219 val = clk_readl(c->reg + PLL_MISC(c));
1220 val &= ~(PLLE_MISC_LOCK_ENABLE | PLLE_MISC_SETUP_MASK);
1221 clk_writel(val, c->reg + PLL_MISC(c));
1222
1223 /* training */
1224 val = clk_readl(c->reg + PLL_MISC(c));
1225 if (force_training || (!(val & PLLE_MISC_READY)))
1226 tegra30_plle_training(c);
1227
1228 /* configure dividers, setup, disable SS */
1229 val = clk_readl(c->reg + PLL_BASE);
1230 val &= ~PLLE_BASE_DIV_MASK;
1231 val |= PLLE_BASE_DIV(sel->m, sel->n, sel->p, sel->cpcon);
1232 clk_writel(val, c->reg + PLL_BASE);
1233 c->mul = sel->n;
1234 c->div = sel->m * sel->p;
1235
1236 val = clk_readl(c->reg + PLL_MISC(c));
1237 val |= PLLE_MISC_SETUP_VALUE;
1238 val |= PLLE_MISC_LOCK_ENABLE;
1239 clk_writel(val, c->reg + PLL_MISC(c));
1240
1241 val = clk_readl(PLLE_SS_CTRL);
1242 val |= PLLE_SS_DISABLE;
1243 clk_writel(val, PLLE_SS_CTRL);
1244
1245 /* enable and lock PLLE*/
1246 val = clk_readl(c->reg + PLL_BASE);
1247 val |= (PLLE_BASE_CML_ENABLE | PLLE_BASE_ENABLE);
1248 clk_writel(val, c->reg + PLL_BASE);
1249
1250 tegra30_pll_clk_wait_for_lock(c, c->reg + PLL_MISC(c), PLLE_MISC_LOCK);
1251
1252 return 0;
1253}
1254
1255static int tegra30_plle_clk_enable(struct clk *c)
1256{
1257 pr_debug("%s on clock %s\n", __func__, c->name);
1258 return tegra30_plle_configure(c, !c->set);
1259}
1260
1261static struct clk_ops tegra_plle_ops = {
1262 .init = tegra30_plle_clk_init,
1263 .enable = tegra30_plle_clk_enable,
1264 .disable = tegra30_plle_clk_disable,
1265};
1266
1267/* Clock divider ops */
1268static void tegra30_pll_div_clk_init(struct clk *c)
1269{
1270 if (c->flags & DIV_U71) {
1271 u32 divu71;
1272 u32 val = clk_readl(c->reg);
1273 val >>= c->reg_shift;
1274 c->state = (val & PLL_OUT_CLKEN) ? ON : OFF;
1275 if (!(val & PLL_OUT_RESET_DISABLE))
1276 c->state = OFF;
1277
1278 divu71 = (val & PLL_OUT_RATIO_MASK) >> PLL_OUT_RATIO_SHIFT;
1279 c->div = (divu71 + 2);
1280 c->mul = 2;
1281 } else if (c->flags & DIV_2) {
1282 c->state = ON;
1283 if (c->flags & (PLLD | PLLX)) {
1284 c->div = 2;
1285 c->mul = 1;
1286 } else
1287 BUG();
1288 } else {
1289 c->state = ON;
1290 c->div = 1;
1291 c->mul = 1;
1292 }
1293}
1294
1295static int tegra30_pll_div_clk_enable(struct clk *c)
1296{
1297 u32 val;
1298 u32 new_val;
1299
1300 pr_debug("%s: %s\n", __func__, c->name);
1301 if (c->flags & DIV_U71) {
1302 val = clk_readl(c->reg);
1303 new_val = val >> c->reg_shift;
1304 new_val &= 0xFFFF;
1305
1306 new_val |= PLL_OUT_CLKEN | PLL_OUT_RESET_DISABLE;
1307
1308 val &= ~(0xFFFF << c->reg_shift);
1309 val |= new_val << c->reg_shift;
1310 clk_writel_delay(val, c->reg);
1311 return 0;
1312 } else if (c->flags & DIV_2) {
1313 return 0;
1314 }
1315 return -EINVAL;
1316}
1317
1318static void tegra30_pll_div_clk_disable(struct clk *c)
1319{
1320 u32 val;
1321 u32 new_val;
1322
1323 pr_debug("%s: %s\n", __func__, c->name);
1324 if (c->flags & DIV_U71) {
1325 val = clk_readl(c->reg);
1326 new_val = val >> c->reg_shift;
1327 new_val &= 0xFFFF;
1328
1329 new_val &= ~(PLL_OUT_CLKEN | PLL_OUT_RESET_DISABLE);
1330
1331 val &= ~(0xFFFF << c->reg_shift);
1332 val |= new_val << c->reg_shift;
1333 clk_writel_delay(val, c->reg);
1334 }
1335}
1336
1337static int tegra30_pll_div_clk_set_rate(struct clk *c, unsigned long rate)
1338{
1339 u32 val;
1340 u32 new_val;
1341 int divider_u71;
1342 unsigned long parent_rate = clk_get_rate(c->parent);
1343
1344 pr_debug("%s: %s %lu\n", __func__, c->name, rate);
1345 if (c->flags & DIV_U71) {
1346 divider_u71 = clk_div71_get_divider(
1347 parent_rate, rate, c->flags, ROUND_DIVIDER_UP);
1348 if (divider_u71 >= 0) {
1349 val = clk_readl(c->reg);
1350 new_val = val >> c->reg_shift;
1351 new_val &= 0xFFFF;
1352 if (c->flags & DIV_U71_FIXED)
1353 new_val |= PLL_OUT_OVERRIDE;
1354 new_val &= ~PLL_OUT_RATIO_MASK;
1355 new_val |= divider_u71 << PLL_OUT_RATIO_SHIFT;
1356
1357 val &= ~(0xFFFF << c->reg_shift);
1358 val |= new_val << c->reg_shift;
1359 clk_writel_delay(val, c->reg);
1360 c->div = divider_u71 + 2;
1361 c->mul = 2;
1362 return 0;
1363 }
1364 } else if (c->flags & DIV_2)
1365 return clk_set_rate(c->parent, rate * 2);
1366
1367 return -EINVAL;
1368}
1369
1370static long tegra30_pll_div_clk_round_rate(struct clk *c, unsigned long rate)
1371{
1372 int divider;
1373 unsigned long parent_rate = clk_get_rate(c->parent);
1374 pr_debug("%s: %s %lu\n", __func__, c->name, rate);
1375
1376 if (c->flags & DIV_U71) {
1377 divider = clk_div71_get_divider(
1378 parent_rate, rate, c->flags, ROUND_DIVIDER_UP);
1379 if (divider < 0)
1380 return divider;
1381 return DIV_ROUND_UP(parent_rate * 2, divider + 2);
1382 } else if (c->flags & DIV_2)
1383 /* no rounding - fixed DIV_2 dividers pass rate to parent PLL */
1384 return rate;
1385
1386 return -EINVAL;
1387}
1388
1389static struct clk_ops tegra_pll_div_ops = {
1390 .init = tegra30_pll_div_clk_init,
1391 .enable = tegra30_pll_div_clk_enable,
1392 .disable = tegra30_pll_div_clk_disable,
1393 .set_rate = tegra30_pll_div_clk_set_rate,
1394 .round_rate = tegra30_pll_div_clk_round_rate,
1395};
1396
1397/* Periph clk ops */
1398static inline u32 periph_clk_source_mask(struct clk *c)
1399{
1400 if (c->flags & MUX8)
1401 return 7 << 29;
1402 else if (c->flags & MUX_PWM)
1403 return 3 << 28;
1404 else if (c->flags & MUX_CLK_OUT)
1405 return 3 << (c->u.periph.clk_num + 4);
1406 else if (c->flags & PLLD)
1407 return PLLD_BASE_DSIB_MUX_MASK;
1408 else
1409 return 3 << 30;
1410}
1411
1412static inline u32 periph_clk_source_shift(struct clk *c)
1413{
1414 if (c->flags & MUX8)
1415 return 29;
1416 else if (c->flags & MUX_PWM)
1417 return 28;
1418 else if (c->flags & MUX_CLK_OUT)
1419 return c->u.periph.clk_num + 4;
1420 else if (c->flags & PLLD)
1421 return PLLD_BASE_DSIB_MUX_SHIFT;
1422 else
1423 return 30;
1424}
1425
1426static void tegra30_periph_clk_init(struct clk *c)
1427{
1428 u32 val = clk_readl(c->reg);
1429 const struct clk_mux_sel *mux = 0;
1430 const struct clk_mux_sel *sel;
1431 if (c->flags & MUX) {
1432 for (sel = c->inputs; sel->input != NULL; sel++) {
1433 if (((val & periph_clk_source_mask(c)) >>
1434 periph_clk_source_shift(c)) == sel->value)
1435 mux = sel;
1436 }
1437 BUG_ON(!mux);
1438
1439 c->parent = mux->input;
1440 } else {
1441 c->parent = c->inputs[0].input;
1442 }
1443
1444 if (c->flags & DIV_U71) {
1445 u32 divu71 = val & PERIPH_CLK_SOURCE_DIVU71_MASK;
1446 if ((c->flags & DIV_U71_UART) &&
1447 (!(val & PERIPH_CLK_UART_DIV_ENB))) {
1448 divu71 = 0;
1449 }
1450 if (c->flags & DIV_U71_IDLE) {
1451 val &= ~(PERIPH_CLK_SOURCE_DIVU71_MASK <<
1452 PERIPH_CLK_SOURCE_DIVIDLE_SHIFT);
1453 val |= (PERIPH_CLK_SOURCE_DIVIDLE_VAL <<
1454 PERIPH_CLK_SOURCE_DIVIDLE_SHIFT);
1455 clk_writel(val, c->reg);
1456 }
1457 c->div = divu71 + 2;
1458 c->mul = 2;
1459 } else if (c->flags & DIV_U16) {
1460 u32 divu16 = val & PERIPH_CLK_SOURCE_DIVU16_MASK;
1461 c->div = divu16 + 1;
1462 c->mul = 1;
1463 } else {
1464 c->div = 1;
1465 c->mul = 1;
1466 }
1467
1468 c->state = ON;
1469 if (!(clk_readl(PERIPH_CLK_TO_ENB_REG(c)) & PERIPH_CLK_TO_BIT(c)))
1470 c->state = OFF;
1471 if (!(c->flags & PERIPH_NO_RESET))
1472 if (clk_readl(PERIPH_CLK_TO_RST_REG(c)) & PERIPH_CLK_TO_BIT(c))
1473 c->state = OFF;
1474}
1475
1476static int tegra30_periph_clk_enable(struct clk *c)
1477{
1478 pr_debug("%s on clock %s\n", __func__, c->name);
1479
1480 tegra_periph_clk_enable_refcount[c->u.periph.clk_num]++;
1481 if (tegra_periph_clk_enable_refcount[c->u.periph.clk_num] > 1)
1482 return 0;
1483
1484 clk_writel_delay(PERIPH_CLK_TO_BIT(c), PERIPH_CLK_TO_ENB_SET_REG(c));
1485 if (!(c->flags & PERIPH_NO_RESET) &&
1486 !(c->flags & PERIPH_MANUAL_RESET)) {
1487 if (clk_readl(PERIPH_CLK_TO_RST_REG(c)) &
1488 PERIPH_CLK_TO_BIT(c)) {
1489 udelay(5); /* reset propagation delay */
1490 clk_writel(PERIPH_CLK_TO_BIT(c),
1491 PERIPH_CLK_TO_RST_CLR_REG(c));
1492 }
1493 }
1494 return 0;
1495}
1496
1497static void tegra30_periph_clk_disable(struct clk *c)
1498{
1499 unsigned long val;
1500 pr_debug("%s on clock %s\n", __func__, c->name);
1501
1502 if (c->refcnt)
1503 tegra_periph_clk_enable_refcount[c->u.periph.clk_num]--;
1504
1505 if (tegra_periph_clk_enable_refcount[c->u.periph.clk_num] == 0) {
1506 /* If peripheral is in the APB bus then read the APB bus to
1507 * flush the write operation in apb bus. This will avoid the
1508 * peripheral access after disabling clock*/
1509 if (c->flags & PERIPH_ON_APB)
1510 val = chipid_readl();
1511
1512 clk_writel_delay(
1513 PERIPH_CLK_TO_BIT(c), PERIPH_CLK_TO_ENB_CLR_REG(c));
1514 }
1515}
1516
1517static void tegra30_periph_clk_reset(struct clk *c, bool assert)
1518{
1519 unsigned long val;
1520 pr_debug("%s %s on clock %s\n", __func__,
1521 assert ? "assert" : "deassert", c->name);
1522
1523 if (!(c->flags & PERIPH_NO_RESET)) {
1524 if (assert) {
1525 /* If peripheral is in the APB bus then read the APB
1526 * bus to flush the write operation in apb bus. This
1527 * will avoid the peripheral access after disabling
1528 * clock */
1529 if (c->flags & PERIPH_ON_APB)
1530 val = chipid_readl();
1531
1532 clk_writel(PERIPH_CLK_TO_BIT(c),
1533 PERIPH_CLK_TO_RST_SET_REG(c));
1534 } else
1535 clk_writel(PERIPH_CLK_TO_BIT(c),
1536 PERIPH_CLK_TO_RST_CLR_REG(c));
1537 }
1538}
1539
1540static int tegra30_periph_clk_set_parent(struct clk *c, struct clk *p)
1541{
1542 u32 val;
1543 const struct clk_mux_sel *sel;
1544 pr_debug("%s: %s %s\n", __func__, c->name, p->name);
1545
1546 if (!(c->flags & MUX))
1547 return (p == c->parent) ? 0 : (-EINVAL);
1548
1549 for (sel = c->inputs; sel->input != NULL; sel++) {
1550 if (sel->input == p) {
1551 val = clk_readl(c->reg);
1552 val &= ~periph_clk_source_mask(c);
1553 val |= (sel->value << periph_clk_source_shift(c));
1554
1555 if (c->refcnt)
1556 clk_enable(p);
1557
1558 clk_writel_delay(val, c->reg);
1559
1560 if (c->refcnt && c->parent)
1561 clk_disable(c->parent);
1562
1563 clk_reparent(c, p);
1564 return 0;
1565 }
1566 }
1567
1568 return -EINVAL;
1569}
1570
1571static int tegra30_periph_clk_set_rate(struct clk *c, unsigned long rate)
1572{
1573 u32 val;
1574 int divider;
1575 unsigned long parent_rate = clk_get_rate(c->parent);
1576
1577 if (c->flags & DIV_U71) {
1578 divider = clk_div71_get_divider(
1579 parent_rate, rate, c->flags, ROUND_DIVIDER_UP);
1580 if (divider >= 0) {
1581 val = clk_readl(c->reg);
1582 val &= ~PERIPH_CLK_SOURCE_DIVU71_MASK;
1583 val |= divider;
1584 if (c->flags & DIV_U71_UART) {
1585 if (divider)
1586 val |= PERIPH_CLK_UART_DIV_ENB;
1587 else
1588 val &= ~PERIPH_CLK_UART_DIV_ENB;
1589 }
1590 clk_writel_delay(val, c->reg);
1591 c->div = divider + 2;
1592 c->mul = 2;
1593 return 0;
1594 }
1595 } else if (c->flags & DIV_U16) {
1596 divider = clk_div16_get_divider(parent_rate, rate);
1597 if (divider >= 0) {
1598 val = clk_readl(c->reg);
1599 val &= ~PERIPH_CLK_SOURCE_DIVU16_MASK;
1600 val |= divider;
1601 clk_writel_delay(val, c->reg);
1602 c->div = divider + 1;
1603 c->mul = 1;
1604 return 0;
1605 }
1606 } else if (parent_rate <= rate) {
1607 c->div = 1;
1608 c->mul = 1;
1609 return 0;
1610 }
1611 return -EINVAL;
1612}
1613
1614static long tegra30_periph_clk_round_rate(struct clk *c,
1615 unsigned long rate)
1616{
1617 int divider;
1618 unsigned long parent_rate = clk_get_rate(c->parent);
1619 pr_debug("%s: %s %lu\n", __func__, c->name, rate);
1620
1621 if (c->flags & DIV_U71) {
1622 divider = clk_div71_get_divider(
1623 parent_rate, rate, c->flags, ROUND_DIVIDER_UP);
1624 if (divider < 0)
1625 return divider;
1626
1627 return DIV_ROUND_UP(parent_rate * 2, divider + 2);
1628 } else if (c->flags & DIV_U16) {
1629 divider = clk_div16_get_divider(parent_rate, rate);
1630 if (divider < 0)
1631 return divider;
1632 return DIV_ROUND_UP(parent_rate, divider + 1);
1633 }
1634 return -EINVAL;
1635}
1636
1637static struct clk_ops tegra_periph_clk_ops = {
1638 .init = &tegra30_periph_clk_init,
1639 .enable = &tegra30_periph_clk_enable,
1640 .disable = &tegra30_periph_clk_disable,
1641 .set_parent = &tegra30_periph_clk_set_parent,
1642 .set_rate = &tegra30_periph_clk_set_rate,
1643 .round_rate = &tegra30_periph_clk_round_rate,
1644 .reset = &tegra30_periph_clk_reset,
1645};
1646
1647
1648/* Periph extended clock configuration ops */
1649static int
1650tegra30_vi_clk_cfg_ex(struct clk *c, enum tegra_clk_ex_param p, u32 setting)
1651{
1652 if (p == TEGRA_CLK_VI_INP_SEL) {
1653 u32 val = clk_readl(c->reg);
1654 val &= ~PERIPH_CLK_VI_SEL_EX_MASK;
1655 val |= (setting << PERIPH_CLK_VI_SEL_EX_SHIFT) &
1656 PERIPH_CLK_VI_SEL_EX_MASK;
1657 clk_writel(val, c->reg);
1658 return 0;
1659 }
1660 return -EINVAL;
1661}
1662
1663static struct clk_ops tegra_vi_clk_ops = {
1664 .init = &tegra30_periph_clk_init,
1665 .enable = &tegra30_periph_clk_enable,
1666 .disable = &tegra30_periph_clk_disable,
1667 .set_parent = &tegra30_periph_clk_set_parent,
1668 .set_rate = &tegra30_periph_clk_set_rate,
1669 .round_rate = &tegra30_periph_clk_round_rate,
1670 .clk_cfg_ex = &tegra30_vi_clk_cfg_ex,
1671 .reset = &tegra30_periph_clk_reset,
1672};
1673
1674static int
1675tegra30_nand_clk_cfg_ex(struct clk *c, enum tegra_clk_ex_param p, u32 setting)
1676{
1677 if (p == TEGRA_CLK_NAND_PAD_DIV2_ENB) {
1678 u32 val = clk_readl(c->reg);
1679 if (setting)
1680 val |= PERIPH_CLK_NAND_DIV_EX_ENB;
1681 else
1682 val &= ~PERIPH_CLK_NAND_DIV_EX_ENB;
1683 clk_writel(val, c->reg);
1684 return 0;
1685 }
1686 return -EINVAL;
1687}
1688
1689static struct clk_ops tegra_nand_clk_ops = {
1690 .init = &tegra30_periph_clk_init,
1691 .enable = &tegra30_periph_clk_enable,
1692 .disable = &tegra30_periph_clk_disable,
1693 .set_parent = &tegra30_periph_clk_set_parent,
1694 .set_rate = &tegra30_periph_clk_set_rate,
1695 .round_rate = &tegra30_periph_clk_round_rate,
1696 .clk_cfg_ex = &tegra30_nand_clk_cfg_ex,
1697 .reset = &tegra30_periph_clk_reset,
1698};
1699
1700
1701static int
1702tegra30_dtv_clk_cfg_ex(struct clk *c, enum tegra_clk_ex_param p, u32 setting)
1703{
1704 if (p == TEGRA_CLK_DTV_INVERT) {
1705 u32 val = clk_readl(c->reg);
1706 if (setting)
1707 val |= PERIPH_CLK_DTV_POLARITY_INV;
1708 else
1709 val &= ~PERIPH_CLK_DTV_POLARITY_INV;
1710 clk_writel(val, c->reg);
1711 return 0;
1712 }
1713 return -EINVAL;
1714}
1715
1716static struct clk_ops tegra_dtv_clk_ops = {
1717 .init = &tegra30_periph_clk_init,
1718 .enable = &tegra30_periph_clk_enable,
1719 .disable = &tegra30_periph_clk_disable,
1720 .set_parent = &tegra30_periph_clk_set_parent,
1721 .set_rate = &tegra30_periph_clk_set_rate,
1722 .round_rate = &tegra30_periph_clk_round_rate,
1723 .clk_cfg_ex = &tegra30_dtv_clk_cfg_ex,
1724 .reset = &tegra30_periph_clk_reset,
1725};
1726
1727static int tegra30_dsib_clk_set_parent(struct clk *c, struct clk *p)
1728{
1729 const struct clk_mux_sel *sel;
1730 struct clk *d = tegra_get_clock_by_name("pll_d");
1731
1732 pr_debug("%s: %s %s\n", __func__, c->name, p->name);
1733
1734 for (sel = c->inputs; sel->input != NULL; sel++) {
1735 if (sel->input == p) {
1736 if (c->refcnt)
1737 clk_enable(p);
1738
1739 /* The DSIB parent selection bit is in PLLD base
1740 register - can not do direct r-m-w, must be
1741 protected by PLLD lock */
1742 tegra_clk_cfg_ex(
1743 d, TEGRA_CLK_PLLD_MIPI_MUX_SEL, sel->value);
1744
1745 if (c->refcnt && c->parent)
1746 clk_disable(c->parent);
1747
1748 clk_reparent(c, p);
1749 return 0;
1750 }
1751 }
1752
1753 return -EINVAL;
1754}
1755
1756static struct clk_ops tegra_dsib_clk_ops = {
1757 .init = &tegra30_periph_clk_init,
1758 .enable = &tegra30_periph_clk_enable,
1759 .disable = &tegra30_periph_clk_disable,
1760 .set_parent = &tegra30_dsib_clk_set_parent,
1761 .set_rate = &tegra30_periph_clk_set_rate,
1762 .round_rate = &tegra30_periph_clk_round_rate,
1763 .reset = &tegra30_periph_clk_reset,
1764};
1765
1766/* pciex clock support only reset function */
1767static struct clk_ops tegra_pciex_clk_ops = {
1768 .reset = tegra30_periph_clk_reset,
1769};
1770
1771/* Output clock ops */
1772
1773static DEFINE_SPINLOCK(clk_out_lock);
1774
1775static void tegra30_clk_out_init(struct clk *c)
1776{
1777 const struct clk_mux_sel *mux = 0;
1778 const struct clk_mux_sel *sel;
1779 u32 val = pmc_readl(c->reg);
1780
1781 c->state = (val & (0x1 << c->u.periph.clk_num)) ? ON : OFF;
1782 c->mul = 1;
1783 c->div = 1;
1784
1785 for (sel = c->inputs; sel->input != NULL; sel++) {
1786 if (((val & periph_clk_source_mask(c)) >>
1787 periph_clk_source_shift(c)) == sel->value)
1788 mux = sel;
1789 }
1790 BUG_ON(!mux);
1791 c->parent = mux->input;
1792}
1793
1794static int tegra30_clk_out_enable(struct clk *c)
1795{
1796 u32 val;
1797 unsigned long flags;
1798
1799 pr_debug("%s on clock %s\n", __func__, c->name);
1800
1801 spin_lock_irqsave(&clk_out_lock, flags);
1802 val = pmc_readl(c->reg);
1803 val |= (0x1 << c->u.periph.clk_num);
1804 pmc_writel(val, c->reg);
1805 spin_unlock_irqrestore(&clk_out_lock, flags);
1806
1807 return 0;
1808}
1809
1810static void tegra30_clk_out_disable(struct clk *c)
1811{
1812 u32 val;
1813 unsigned long flags;
1814
1815 pr_debug("%s on clock %s\n", __func__, c->name);
1816
1817 spin_lock_irqsave(&clk_out_lock, flags);
1818 val = pmc_readl(c->reg);
1819 val &= ~(0x1 << c->u.periph.clk_num);
1820 pmc_writel(val, c->reg);
1821 spin_unlock_irqrestore(&clk_out_lock, flags);
1822}
1823
1824static int tegra30_clk_out_set_parent(struct clk *c, struct clk *p)
1825{
1826 u32 val;
1827 unsigned long flags;
1828 const struct clk_mux_sel *sel;
1829
1830 pr_debug("%s: %s %s\n", __func__, c->name, p->name);
1831
1832 for (sel = c->inputs; sel->input != NULL; sel++) {
1833 if (sel->input == p) {
1834 if (c->refcnt)
1835 clk_enable(p);
1836
1837 spin_lock_irqsave(&clk_out_lock, flags);
1838 val = pmc_readl(c->reg);
1839 val &= ~periph_clk_source_mask(c);
1840 val |= (sel->value << periph_clk_source_shift(c));
1841 pmc_writel(val, c->reg);
1842 spin_unlock_irqrestore(&clk_out_lock, flags);
1843
1844 if (c->refcnt && c->parent)
1845 clk_disable(c->parent);
1846
1847 clk_reparent(c, p);
1848 return 0;
1849 }
1850 }
1851 return -EINVAL;
1852}
1853
1854static struct clk_ops tegra_clk_out_ops = {
1855 .init = &tegra30_clk_out_init,
1856 .enable = &tegra30_clk_out_enable,
1857 .disable = &tegra30_clk_out_disable,
1858 .set_parent = &tegra30_clk_out_set_parent,
1859};
1860
1861
1862/* Clock doubler ops */
1863static void tegra30_clk_double_init(struct clk *c)
1864{
1865 u32 val = clk_readl(c->reg);
1866 c->mul = val & (0x1 << c->reg_shift) ? 1 : 2;
1867 c->div = 1;
1868 c->state = ON;
1869 if (!(clk_readl(PERIPH_CLK_TO_ENB_REG(c)) & PERIPH_CLK_TO_BIT(c)))
1870 c->state = OFF;
1871};
1872
1873static int tegra30_clk_double_set_rate(struct clk *c, unsigned long rate)
1874{
1875 u32 val;
1876 unsigned long parent_rate = clk_get_rate(c->parent);
1877 if (rate == parent_rate) {
1878 val = clk_readl(c->reg) | (0x1 << c->reg_shift);
1879 clk_writel(val, c->reg);
1880 c->mul = 1;
1881 c->div = 1;
1882 return 0;
1883 } else if (rate == 2 * parent_rate) {
1884 val = clk_readl(c->reg) & (~(0x1 << c->reg_shift));
1885 clk_writel(val, c->reg);
1886 c->mul = 2;
1887 c->div = 1;
1888 return 0;
1889 }
1890 return -EINVAL;
1891}
1892
1893static struct clk_ops tegra_clk_double_ops = {
1894 .init = &tegra30_clk_double_init,
1895 .enable = &tegra30_periph_clk_enable,
1896 .disable = &tegra30_periph_clk_disable,
1897 .set_rate = &tegra30_clk_double_set_rate,
1898};
1899
1900/* Audio sync clock ops */
1901static int tegra30_sync_source_set_rate(struct clk *c, unsigned long rate)
1902{
1903 c->rate = rate;
1904 return 0;
1905}
1906
1907static struct clk_ops tegra_sync_source_ops = {
1908 .set_rate = &tegra30_sync_source_set_rate,
1909};
1910
1911static void tegra30_audio_sync_clk_init(struct clk *c)
1912{
1913 int source;
1914 const struct clk_mux_sel *sel;
1915 u32 val = clk_readl(c->reg);
1916 c->state = (val & AUDIO_SYNC_DISABLE_BIT) ? OFF : ON;
1917 source = val & AUDIO_SYNC_SOURCE_MASK;
1918 for (sel = c->inputs; sel->input != NULL; sel++)
1919 if (sel->value == source)
1920 break;
1921 BUG_ON(sel->input == NULL);
1922 c->parent = sel->input;
1923}
1924
1925static int tegra30_audio_sync_clk_enable(struct clk *c)
1926{
1927 u32 val = clk_readl(c->reg);
1928 clk_writel((val & (~AUDIO_SYNC_DISABLE_BIT)), c->reg);
1929 return 0;
1930}
1931
1932static void tegra30_audio_sync_clk_disable(struct clk *c)
1933{
1934 u32 val = clk_readl(c->reg);
1935 clk_writel((val | AUDIO_SYNC_DISABLE_BIT), c->reg);
1936}
1937
1938static int tegra30_audio_sync_clk_set_parent(struct clk *c, struct clk *p)
1939{
1940 u32 val;
1941 const struct clk_mux_sel *sel;
1942 for (sel = c->inputs; sel->input != NULL; sel++) {
1943 if (sel->input == p) {
1944 val = clk_readl(c->reg);
1945 val &= ~AUDIO_SYNC_SOURCE_MASK;
1946 val |= sel->value;
1947
1948 if (c->refcnt)
1949 clk_enable(p);
1950
1951 clk_writel(val, c->reg);
1952
1953 if (c->refcnt && c->parent)
1954 clk_disable(c->parent);
1955
1956 clk_reparent(c, p);
1957 return 0;
1958 }
1959 }
1960
1961 return -EINVAL;
1962}
1963
1964static struct clk_ops tegra_audio_sync_clk_ops = {
1965 .init = tegra30_audio_sync_clk_init,
1966 .enable = tegra30_audio_sync_clk_enable,
1967 .disable = tegra30_audio_sync_clk_disable,
1968 .set_parent = tegra30_audio_sync_clk_set_parent,
1969};
1970
1971/* cml0 (pcie), and cml1 (sata) clock ops */
1972static void tegra30_cml_clk_init(struct clk *c)
1973{
1974 u32 val = clk_readl(c->reg);
1975 c->state = val & (0x1 << c->u.periph.clk_num) ? ON : OFF;
1976}
1977
1978static int tegra30_cml_clk_enable(struct clk *c)
1979{
1980 u32 val = clk_readl(c->reg);
1981 val |= (0x1 << c->u.periph.clk_num);
1982 clk_writel(val, c->reg);
1983 return 0;
1984}
1985
1986static void tegra30_cml_clk_disable(struct clk *c)
1987{
1988 u32 val = clk_readl(c->reg);
1989 val &= ~(0x1 << c->u.periph.clk_num);
1990 clk_writel(val, c->reg);
1991}
1992
1993static struct clk_ops tegra_cml_clk_ops = {
1994 .init = &tegra30_cml_clk_init,
1995 .enable = &tegra30_cml_clk_enable,
1996 .disable = &tegra30_cml_clk_disable,
1997};
1998
1999/* Clock definitions */
2000static struct clk tegra_clk_32k = {
2001 .name = "clk_32k",
2002 .rate = 32768,
2003 .ops = NULL,
2004 .max_rate = 32768,
2005};
2006
2007static struct clk tegra_clk_m = {
2008 .name = "clk_m",
2009 .flags = ENABLE_ON_INIT,
2010 .ops = &tegra_clk_m_ops,
2011 .reg = 0x1fc,
2012 .reg_shift = 28,
2013 .max_rate = 48000000,
2014};
2015
2016static struct clk tegra_clk_m_div2 = {
2017 .name = "clk_m_div2",
2018 .ops = &tegra_clk_m_div_ops,
2019 .parent = &tegra_clk_m,
2020 .mul = 1,
2021 .div = 2,
2022 .state = ON,
2023 .max_rate = 24000000,
2024};
2025
2026static struct clk tegra_clk_m_div4 = {
2027 .name = "clk_m_div4",
2028 .ops = &tegra_clk_m_div_ops,
2029 .parent = &tegra_clk_m,
2030 .mul = 1,
2031 .div = 4,
2032 .state = ON,
2033 .max_rate = 12000000,
2034};
2035
2036static struct clk tegra_pll_ref = {
2037 .name = "pll_ref",
2038 .flags = ENABLE_ON_INIT,
2039 .ops = &tegra_pll_ref_ops,
2040 .parent = &tegra_clk_m,
2041 .max_rate = 26000000,
2042};
2043
2044static struct clk_pll_freq_table tegra_pll_c_freq_table[] = {
2045 { 12000000, 1040000000, 520, 6, 1, 8},
2046 { 13000000, 1040000000, 480, 6, 1, 8},
2047 { 16800000, 1040000000, 495, 8, 1, 8}, /* actual: 1039.5 MHz */
2048 { 19200000, 1040000000, 325, 6, 1, 6},
2049 { 26000000, 1040000000, 520, 13, 1, 8},
2050
2051 { 12000000, 832000000, 416, 6, 1, 8},
2052 { 13000000, 832000000, 832, 13, 1, 8},
2053 { 16800000, 832000000, 396, 8, 1, 8}, /* actual: 831.6 MHz */
2054 { 19200000, 832000000, 260, 6, 1, 8},
2055 { 26000000, 832000000, 416, 13, 1, 8},
2056
2057 { 12000000, 624000000, 624, 12, 1, 8},
2058 { 13000000, 624000000, 624, 13, 1, 8},
2059 { 16800000, 600000000, 520, 14, 1, 8},
2060 { 19200000, 624000000, 520, 16, 1, 8},
2061 { 26000000, 624000000, 624, 26, 1, 8},
2062
2063 { 12000000, 600000000, 600, 12, 1, 8},
2064 { 13000000, 600000000, 600, 13, 1, 8},
2065 { 16800000, 600000000, 500, 14, 1, 8},
2066 { 19200000, 600000000, 375, 12, 1, 6},
2067 { 26000000, 600000000, 600, 26, 1, 8},
2068
2069 { 12000000, 520000000, 520, 12, 1, 8},
2070 { 13000000, 520000000, 520, 13, 1, 8},
2071 { 16800000, 520000000, 495, 16, 1, 8}, /* actual: 519.75 MHz */
2072 { 19200000, 520000000, 325, 12, 1, 6},
2073 { 26000000, 520000000, 520, 26, 1, 8},
2074
2075 { 12000000, 416000000, 416, 12, 1, 8},
2076 { 13000000, 416000000, 416, 13, 1, 8},
2077 { 16800000, 416000000, 396, 16, 1, 8}, /* actual: 415.8 MHz */
2078 { 19200000, 416000000, 260, 12, 1, 6},
2079 { 26000000, 416000000, 416, 26, 1, 8},
2080 { 0, 0, 0, 0, 0, 0 },
2081};
2082
2083static struct clk tegra_pll_c = {
2084 .name = "pll_c",
2085 .flags = PLL_HAS_CPCON,
2086 .ops = &tegra_pll_ops,
2087 .reg = 0x80,
2088 .parent = &tegra_pll_ref,
2089 .max_rate = 1400000000,
2090 .u.pll = {
2091 .input_min = 2000000,
2092 .input_max = 31000000,
2093 .cf_min = 1000000,
2094 .cf_max = 6000000,
2095 .vco_min = 20000000,
2096 .vco_max = 1400000000,
2097 .freq_table = tegra_pll_c_freq_table,
2098 .lock_delay = 300,
2099 },
2100};
2101
2102static struct clk tegra_pll_c_out1 = {
2103 .name = "pll_c_out1",
2104 .ops = &tegra_pll_div_ops,
2105 .flags = DIV_U71,
2106 .parent = &tegra_pll_c,
2107 .reg = 0x84,
2108 .reg_shift = 0,
2109 .max_rate = 700000000,
2110};
2111
2112static struct clk_pll_freq_table tegra_pll_m_freq_table[] = {
2113 { 12000000, 666000000, 666, 12, 1, 8},
2114 { 13000000, 666000000, 666, 13, 1, 8},
2115 { 16800000, 666000000, 555, 14, 1, 8},
2116 { 19200000, 666000000, 555, 16, 1, 8},
2117 { 26000000, 666000000, 666, 26, 1, 8},
2118 { 12000000, 600000000, 600, 12, 1, 8},
2119 { 13000000, 600000000, 600, 13, 1, 8},
2120 { 16800000, 600000000, 500, 14, 1, 8},
2121 { 19200000, 600000000, 375, 12, 1, 6},
2122 { 26000000, 600000000, 600, 26, 1, 8},
2123 { 0, 0, 0, 0, 0, 0 },
2124};
2125
2126static struct clk tegra_pll_m = {
2127 .name = "pll_m",
2128 .flags = PLL_HAS_CPCON | PLLM,
2129 .ops = &tegra_pll_ops,
2130 .reg = 0x90,
2131 .parent = &tegra_pll_ref,
2132 .max_rate = 800000000,
2133 .u.pll = {
2134 .input_min = 2000000,
2135 .input_max = 31000000,
2136 .cf_min = 1000000,
2137 .cf_max = 6000000,
2138 .vco_min = 20000000,
2139 .vco_max = 1200000000,
2140 .freq_table = tegra_pll_m_freq_table,
2141 .lock_delay = 300,
2142 },
2143};
2144
2145static struct clk tegra_pll_m_out1 = {
2146 .name = "pll_m_out1",
2147 .ops = &tegra_pll_div_ops,
2148 .flags = DIV_U71,
2149 .parent = &tegra_pll_m,
2150 .reg = 0x94,
2151 .reg_shift = 0,
2152 .max_rate = 600000000,
2153};
2154
2155static struct clk_pll_freq_table tegra_pll_p_freq_table[] = {
2156 { 12000000, 216000000, 432, 12, 2, 8},
2157 { 13000000, 216000000, 432, 13, 2, 8},
2158 { 16800000, 216000000, 360, 14, 2, 8},
2159 { 19200000, 216000000, 360, 16, 2, 8},
2160 { 26000000, 216000000, 432, 26, 2, 8},
2161 { 0, 0, 0, 0, 0, 0 },
2162};
2163
2164static struct clk tegra_pll_p = {
2165 .name = "pll_p",
2166 .flags = ENABLE_ON_INIT | PLL_FIXED | PLL_HAS_CPCON,
2167 .ops = &tegra_pll_ops,
2168 .reg = 0xa0,
2169 .parent = &tegra_pll_ref,
2170 .max_rate = 432000000,
2171 .u.pll = {
2172 .input_min = 2000000,
2173 .input_max = 31000000,
2174 .cf_min = 1000000,
2175 .cf_max = 6000000,
2176 .vco_min = 20000000,
2177 .vco_max = 1400000000,
2178 .freq_table = tegra_pll_p_freq_table,
2179 .lock_delay = 300,
2180 .fixed_rate = 408000000,
2181 },
2182};
2183
2184static struct clk tegra_pll_p_out1 = {
2185 .name = "pll_p_out1",
2186 .ops = &tegra_pll_div_ops,
2187 .flags = ENABLE_ON_INIT | DIV_U71 | DIV_U71_FIXED,
2188 .parent = &tegra_pll_p,
2189 .reg = 0xa4,
2190 .reg_shift = 0,
2191 .max_rate = 432000000,
2192};
2193
2194static struct clk tegra_pll_p_out2 = {
2195 .name = "pll_p_out2",
2196 .ops = &tegra_pll_div_ops,
2197 .flags = ENABLE_ON_INIT | DIV_U71 | DIV_U71_FIXED,
2198 .parent = &tegra_pll_p,
2199 .reg = 0xa4,
2200 .reg_shift = 16,
2201 .max_rate = 432000000,
2202};
2203
2204static struct clk tegra_pll_p_out3 = {
2205 .name = "pll_p_out3",
2206 .ops = &tegra_pll_div_ops,
2207 .flags = ENABLE_ON_INIT | DIV_U71 | DIV_U71_FIXED,
2208 .parent = &tegra_pll_p,
2209 .reg = 0xa8,
2210 .reg_shift = 0,
2211 .max_rate = 432000000,
2212};
2213
2214static struct clk tegra_pll_p_out4 = {
2215 .name = "pll_p_out4",
2216 .ops = &tegra_pll_div_ops,
2217 .flags = ENABLE_ON_INIT | DIV_U71 | DIV_U71_FIXED,
2218 .parent = &tegra_pll_p,
2219 .reg = 0xa8,
2220 .reg_shift = 16,
2221 .max_rate = 432000000,
2222};
2223
2224static struct clk_pll_freq_table tegra_pll_a_freq_table[] = {
2225 { 9600000, 564480000, 294, 5, 1, 4},
2226 { 9600000, 552960000, 288, 5, 1, 4},
2227 { 9600000, 24000000, 5, 2, 1, 1},
2228
2229 { 28800000, 56448000, 49, 25, 1, 1},
2230 { 28800000, 73728000, 64, 25, 1, 1},
2231 { 28800000, 24000000, 5, 6, 1, 1},
2232 { 0, 0, 0, 0, 0, 0 },
2233};
2234
2235static struct clk tegra_pll_a = {
2236 .name = "pll_a",
2237 .flags = PLL_HAS_CPCON,
2238 .ops = &tegra_pll_ops,
2239 .reg = 0xb0,
2240 .parent = &tegra_pll_p_out1,
2241 .max_rate = 700000000,
2242 .u.pll = {
2243 .input_min = 2000000,
2244 .input_max = 31000000,
2245 .cf_min = 1000000,
2246 .cf_max = 6000000,
2247 .vco_min = 20000000,
2248 .vco_max = 1400000000,
2249 .freq_table = tegra_pll_a_freq_table,
2250 .lock_delay = 300,
2251 },
2252};
2253
2254static struct clk tegra_pll_a_out0 = {
2255 .name = "pll_a_out0",
2256 .ops = &tegra_pll_div_ops,
2257 .flags = DIV_U71,
2258 .parent = &tegra_pll_a,
2259 .reg = 0xb4,
2260 .reg_shift = 0,
2261 .max_rate = 100000000,
2262};
2263
2264static struct clk_pll_freq_table tegra_pll_d_freq_table[] = {
2265 { 12000000, 216000000, 216, 12, 1, 4},
2266 { 13000000, 216000000, 216, 13, 1, 4},
2267 { 16800000, 216000000, 180, 14, 1, 4},
2268 { 19200000, 216000000, 180, 16, 1, 4},
2269 { 26000000, 216000000, 216, 26, 1, 4},
2270
2271 { 12000000, 594000000, 594, 12, 1, 8},
2272 { 13000000, 594000000, 594, 13, 1, 8},
2273 { 16800000, 594000000, 495, 14, 1, 8},
2274 { 19200000, 594000000, 495, 16, 1, 8},
2275 { 26000000, 594000000, 594, 26, 1, 8},
2276
2277 { 12000000, 1000000000, 1000, 12, 1, 12},
2278 { 13000000, 1000000000, 1000, 13, 1, 12},
2279 { 19200000, 1000000000, 625, 12, 1, 8},
2280 { 26000000, 1000000000, 1000, 26, 1, 12},
2281
2282 { 0, 0, 0, 0, 0, 0 },
2283};
2284
2285static struct clk tegra_pll_d = {
2286 .name = "pll_d",
2287 .flags = PLL_HAS_CPCON | PLLD,
2288 .ops = &tegra_plld_ops,
2289 .reg = 0xd0,
2290 .parent = &tegra_pll_ref,
2291 .max_rate = 1000000000,
2292 .u.pll = {
2293 .input_min = 2000000,
2294 .input_max = 40000000,
2295 .cf_min = 1000000,
2296 .cf_max = 6000000,
2297 .vco_min = 40000000,
2298 .vco_max = 1000000000,
2299 .freq_table = tegra_pll_d_freq_table,
2300 .lock_delay = 1000,
2301 },
2302};
2303
2304static struct clk tegra_pll_d_out0 = {
2305 .name = "pll_d_out0",
2306 .ops = &tegra_pll_div_ops,
2307 .flags = DIV_2 | PLLD,
2308 .parent = &tegra_pll_d,
2309 .max_rate = 500000000,
2310};
2311
2312static struct clk tegra_pll_d2 = {
2313 .name = "pll_d2",
2314 .flags = PLL_HAS_CPCON | PLL_ALT_MISC_REG | PLLD,
2315 .ops = &tegra_plld_ops,
2316 .reg = 0x4b8,
2317 .parent = &tegra_pll_ref,
2318 .max_rate = 1000000000,
2319 .u.pll = {
2320 .input_min = 2000000,
2321 .input_max = 40000000,
2322 .cf_min = 1000000,
2323 .cf_max = 6000000,
2324 .vco_min = 40000000,
2325 .vco_max = 1000000000,
2326 .freq_table = tegra_pll_d_freq_table,
2327 .lock_delay = 1000,
2328 },
2329};
2330
2331static struct clk tegra_pll_d2_out0 = {
2332 .name = "pll_d2_out0",
2333 .ops = &tegra_pll_div_ops,
2334 .flags = DIV_2 | PLLD,
2335 .parent = &tegra_pll_d2,
2336 .max_rate = 500000000,
2337};
2338
2339static struct clk_pll_freq_table tegra_pll_u_freq_table[] = {
2340 { 12000000, 480000000, 960, 12, 2, 12},
2341 { 13000000, 480000000, 960, 13, 2, 12},
2342 { 16800000, 480000000, 400, 7, 2, 5},
2343 { 19200000, 480000000, 200, 4, 2, 3},
2344 { 26000000, 480000000, 960, 26, 2, 12},
2345 { 0, 0, 0, 0, 0, 0 },
2346};
2347
2348static struct clk tegra_pll_u = {
2349 .name = "pll_u",
2350 .flags = PLL_HAS_CPCON | PLLU,
2351 .ops = &tegra_pll_ops,
2352 .reg = 0xc0,
2353 .parent = &tegra_pll_ref,
2354 .max_rate = 480000000,
2355 .u.pll = {
2356 .input_min = 2000000,
2357 .input_max = 40000000,
2358 .cf_min = 1000000,
2359 .cf_max = 6000000,
2360 .vco_min = 480000000,
2361 .vco_max = 960000000,
2362 .freq_table = tegra_pll_u_freq_table,
2363 .lock_delay = 1000,
2364 },
2365};
2366
2367static struct clk_pll_freq_table tegra_pll_x_freq_table[] = {
2368 /* 1.7 GHz */
2369 { 12000000, 1700000000, 850, 6, 1, 8},
2370 { 13000000, 1700000000, 915, 7, 1, 8}, /* actual: 1699.2 MHz */
2371 { 16800000, 1700000000, 708, 7, 1, 8}, /* actual: 1699.2 MHz */
2372 { 19200000, 1700000000, 885, 10, 1, 8}, /* actual: 1699.2 MHz */
2373 { 26000000, 1700000000, 850, 13, 1, 8},
2374
2375 /* 1.6 GHz */
2376 { 12000000, 1600000000, 800, 6, 1, 8},
2377 { 13000000, 1600000000, 738, 6, 1, 8}, /* actual: 1599.0 MHz */
2378 { 16800000, 1600000000, 857, 9, 1, 8}, /* actual: 1599.7 MHz */
2379 { 19200000, 1600000000, 500, 6, 1, 8},
2380 { 26000000, 1600000000, 800, 13, 1, 8},
2381
2382 /* 1.5 GHz */
2383 { 12000000, 1500000000, 750, 6, 1, 8},
2384 { 13000000, 1500000000, 923, 8, 1, 8}, /* actual: 1499.8 MHz */
2385 { 16800000, 1500000000, 625, 7, 1, 8},
2386 { 19200000, 1500000000, 625, 8, 1, 8},
2387 { 26000000, 1500000000, 750, 13, 1, 8},
2388
2389 /* 1.4 GHz */
2390 { 12000000, 1400000000, 700, 6, 1, 8},
2391 { 13000000, 1400000000, 969, 9, 1, 8}, /* actual: 1399.7 MHz */
2392 { 16800000, 1400000000, 1000, 12, 1, 8},
2393 { 19200000, 1400000000, 875, 12, 1, 8},
2394 { 26000000, 1400000000, 700, 13, 1, 8},
2395
2396 /* 1.3 GHz */
2397 { 12000000, 1300000000, 975, 9, 1, 8},
2398 { 13000000, 1300000000, 1000, 10, 1, 8},
2399 { 16800000, 1300000000, 928, 12, 1, 8}, /* actual: 1299.2 MHz */
2400 { 19200000, 1300000000, 812, 12, 1, 8}, /* actual: 1299.2 MHz */
2401 { 26000000, 1300000000, 650, 13, 1, 8},
2402
2403 /* 1.2 GHz */
2404 { 12000000, 1200000000, 1000, 10, 1, 8},
2405 { 13000000, 1200000000, 923, 10, 1, 8}, /* actual: 1199.9 MHz */
2406 { 16800000, 1200000000, 1000, 14, 1, 8},
2407 { 19200000, 1200000000, 1000, 16, 1, 8},
2408 { 26000000, 1200000000, 600, 13, 1, 8},
2409
2410 /* 1.1 GHz */
2411 { 12000000, 1100000000, 825, 9, 1, 8},
2412 { 13000000, 1100000000, 846, 10, 1, 8}, /* actual: 1099.8 MHz */
2413 { 16800000, 1100000000, 982, 15, 1, 8}, /* actual: 1099.8 MHz */
2414 { 19200000, 1100000000, 859, 15, 1, 8}, /* actual: 1099.5 MHz */
2415 { 26000000, 1100000000, 550, 13, 1, 8},
2416
2417 /* 1 GHz */
2418 { 12000000, 1000000000, 1000, 12, 1, 8},
2419 { 13000000, 1000000000, 1000, 13, 1, 8},
2420 { 16800000, 1000000000, 833, 14, 1, 8}, /* actual: 999.6 MHz */
2421 { 19200000, 1000000000, 625, 12, 1, 8},
2422 { 26000000, 1000000000, 1000, 26, 1, 8},
2423
2424 { 0, 0, 0, 0, 0, 0 },
2425};
2426
2427static struct clk tegra_pll_x = {
2428 .name = "pll_x",
2429 .flags = PLL_HAS_CPCON | PLL_ALT_MISC_REG | PLLX,
2430 .ops = &tegra_pll_ops,
2431 .reg = 0xe0,
2432 .parent = &tegra_pll_ref,
2433 .max_rate = 1700000000,
2434 .u.pll = {
2435 .input_min = 2000000,
2436 .input_max = 31000000,
2437 .cf_min = 1000000,
2438 .cf_max = 6000000,
2439 .vco_min = 20000000,
2440 .vco_max = 1700000000,
2441 .freq_table = tegra_pll_x_freq_table,
2442 .lock_delay = 300,
2443 },
2444};
2445
2446static struct clk tegra_pll_x_out0 = {
2447 .name = "pll_x_out0",
2448 .ops = &tegra_pll_div_ops,
2449 .flags = DIV_2 | PLLX,
2450 .parent = &tegra_pll_x,
2451 .max_rate = 850000000,
2452};
2453
2454
2455static struct clk_pll_freq_table tegra_pll_e_freq_table[] = {
2456 /* PLLE special case: use cpcon field to store cml divider value */
2457 { 12000000, 100000000, 150, 1, 18, 11},
2458 { 216000000, 100000000, 200, 18, 24, 13},
2459 { 0, 0, 0, 0, 0, 0 },
2460};
2461
2462static struct clk tegra_pll_e = {
2463 .name = "pll_e",
2464 .flags = PLL_ALT_MISC_REG,
2465 .ops = &tegra_plle_ops,
2466 .reg = 0xe8,
2467 .max_rate = 100000000,
2468 .u.pll = {
2469 .input_min = 12000000,
2470 .input_max = 216000000,
2471 .cf_min = 12000000,
2472 .cf_max = 12000000,
2473 .vco_min = 1200000000,
2474 .vco_max = 2400000000U,
2475 .freq_table = tegra_pll_e_freq_table,
2476 .lock_delay = 300,
2477 .fixed_rate = 100000000,
2478 },
2479};
2480
2481static struct clk tegra_cml0_clk = {
2482 .name = "cml0",
2483 .parent = &tegra_pll_e,
2484 .ops = &tegra_cml_clk_ops,
2485 .reg = PLLE_AUX,
2486 .max_rate = 100000000,
2487 .u.periph = {
2488 .clk_num = 0,
2489 },
2490};
2491
2492static struct clk tegra_cml1_clk = {
2493 .name = "cml1",
2494 .parent = &tegra_pll_e,
2495 .ops = &tegra_cml_clk_ops,
2496 .reg = PLLE_AUX,
2497 .max_rate = 100000000,
2498 .u.periph = {
2499 .clk_num = 1,
2500 },
2501};
2502
2503static struct clk tegra_pciex_clk = {
2504 .name = "pciex",
2505 .parent = &tegra_pll_e,
2506 .ops = &tegra_pciex_clk_ops,
2507 .max_rate = 100000000,
2508 .u.periph = {
2509 .clk_num = 74,
2510 },
2511};
2512
2513/* Audio sync clocks */
2514#define SYNC_SOURCE(_id) \
2515 { \
2516 .name = #_id "_sync", \
2517 .rate = 24000000, \
2518 .max_rate = 24000000, \
2519 .ops = &tegra_sync_source_ops \
2520 }
2521static struct clk tegra_sync_source_list[] = {
2522 SYNC_SOURCE(spdif_in),
2523 SYNC_SOURCE(i2s0),
2524 SYNC_SOURCE(i2s1),
2525 SYNC_SOURCE(i2s2),
2526 SYNC_SOURCE(i2s3),
2527 SYNC_SOURCE(i2s4),
2528 SYNC_SOURCE(vimclk),
2529};
2530
2531static struct clk_mux_sel mux_audio_sync_clk[] = {
2532 { .input = &tegra_sync_source_list[0], .value = 0},
2533 { .input = &tegra_sync_source_list[1], .value = 1},
2534 { .input = &tegra_sync_source_list[2], .value = 2},
2535 { .input = &tegra_sync_source_list[3], .value = 3},
2536 { .input = &tegra_sync_source_list[4], .value = 4},
2537 { .input = &tegra_sync_source_list[5], .value = 5},
2538 { .input = &tegra_pll_a_out0, .value = 6},
2539 { .input = &tegra_sync_source_list[6], .value = 7},
2540 { 0, 0 }
2541};
2542
2543#define AUDIO_SYNC_CLK(_id, _index) \
2544 { \
2545 .name = #_id, \
2546 .inputs = mux_audio_sync_clk, \
2547 .reg = 0x4A0 + (_index) * 4, \
2548 .max_rate = 24000000, \
2549 .ops = &tegra_audio_sync_clk_ops \
2550 }
2551static struct clk tegra_clk_audio_list[] = {
2552 AUDIO_SYNC_CLK(audio0, 0),
2553 AUDIO_SYNC_CLK(audio1, 1),
2554 AUDIO_SYNC_CLK(audio2, 2),
2555 AUDIO_SYNC_CLK(audio3, 3),
2556 AUDIO_SYNC_CLK(audio4, 4),
2557 AUDIO_SYNC_CLK(audio, 5), /* SPDIF */
2558};
2559
2560#define AUDIO_SYNC_2X_CLK(_id, _index) \
2561 { \
2562 .name = #_id "_2x", \
2563 .flags = PERIPH_NO_RESET, \
2564 .max_rate = 48000000, \
2565 .ops = &tegra_clk_double_ops, \
2566 .reg = 0x49C, \
2567 .reg_shift = 24 + (_index), \
2568 .parent = &tegra_clk_audio_list[(_index)], \
2569 .u.periph = { \
2570 .clk_num = 113 + (_index), \
2571 }, \
2572 }
2573static struct clk tegra_clk_audio_2x_list[] = {
2574 AUDIO_SYNC_2X_CLK(audio0, 0),
2575 AUDIO_SYNC_2X_CLK(audio1, 1),
2576 AUDIO_SYNC_2X_CLK(audio2, 2),
2577 AUDIO_SYNC_2X_CLK(audio3, 3),
2578 AUDIO_SYNC_2X_CLK(audio4, 4),
2579 AUDIO_SYNC_2X_CLK(audio, 5), /* SPDIF */
2580};
2581
2582#define MUX_I2S_SPDIF(_id, _index) \
2583static struct clk_mux_sel mux_pllaout0_##_id##_2x_pllp_clkm[] = { \
2584 {.input = &tegra_pll_a_out0, .value = 0}, \
2585 {.input = &tegra_clk_audio_2x_list[(_index)], .value = 1}, \
2586 {.input = &tegra_pll_p, .value = 2}, \
2587 {.input = &tegra_clk_m, .value = 3}, \
2588 { 0, 0}, \
2589}
2590MUX_I2S_SPDIF(audio0, 0);
2591MUX_I2S_SPDIF(audio1, 1);
2592MUX_I2S_SPDIF(audio2, 2);
2593MUX_I2S_SPDIF(audio3, 3);
2594MUX_I2S_SPDIF(audio4, 4);
2595MUX_I2S_SPDIF(audio, 5); /* SPDIF */
2596
2597/* External clock outputs (through PMC) */
2598#define MUX_EXTERN_OUT(_id) \
2599static struct clk_mux_sel mux_clkm_clkm2_clkm4_extern##_id[] = { \
2600 {.input = &tegra_clk_m, .value = 0}, \
2601 {.input = &tegra_clk_m_div2, .value = 1}, \
2602 {.input = &tegra_clk_m_div4, .value = 2}, \
2603 {.input = NULL, .value = 3}, /* placeholder */ \
2604 { 0, 0}, \
2605}
2606MUX_EXTERN_OUT(1);
2607MUX_EXTERN_OUT(2);
2608MUX_EXTERN_OUT(3);
2609
2610static struct clk_mux_sel *mux_extern_out_list[] = {
2611 mux_clkm_clkm2_clkm4_extern1,
2612 mux_clkm_clkm2_clkm4_extern2,
2613 mux_clkm_clkm2_clkm4_extern3,
2614};
2615
2616#define CLK_OUT_CLK(_id) \
2617 { \
2618 .name = "clk_out_" #_id, \
2619 .lookup = { \
2620 .dev_id = "clk_out_" #_id, \
2621 .con_id = "extern" #_id, \
2622 }, \
2623 .ops = &tegra_clk_out_ops, \
2624 .reg = 0x1a8, \
2625 .inputs = mux_clkm_clkm2_clkm4_extern##_id, \
2626 .flags = MUX_CLK_OUT, \
2627 .max_rate = 216000000, \
2628 .u.periph = { \
2629 .clk_num = (_id - 1) * 8 + 2, \
2630 }, \
2631 }
2632static struct clk tegra_clk_out_list[] = {
2633 CLK_OUT_CLK(1),
2634 CLK_OUT_CLK(2),
2635 CLK_OUT_CLK(3),
2636};
2637
2638/* called after peripheral external clocks are initialized */
2639static void init_clk_out_mux(void)
2640{
2641 int i;
2642 struct clk *c;
2643
2644 /* output clock con_id is the name of peripheral
2645 external clock connected to input 3 of the output mux */
2646 for (i = 0; i < ARRAY_SIZE(tegra_clk_out_list); i++) {
2647 c = tegra_get_clock_by_name(
2648 tegra_clk_out_list[i].lookup.con_id);
2649 if (!c)
2650 pr_err("%s: could not find clk %s\n", __func__,
2651 tegra_clk_out_list[i].lookup.con_id);
2652 mux_extern_out_list[i][3].input = c;
2653 }
2654}
2655
2656/* Peripheral muxes */
2657static struct clk_mux_sel mux_sclk[] = {
2658 { .input = &tegra_clk_m, .value = 0},
2659 { .input = &tegra_pll_c_out1, .value = 1},
2660 { .input = &tegra_pll_p_out4, .value = 2},
2661 { .input = &tegra_pll_p_out3, .value = 3},
2662 { .input = &tegra_pll_p_out2, .value = 4},
2663 /* { .input = &tegra_clk_d, .value = 5}, - no use on tegra30 */
2664 { .input = &tegra_clk_32k, .value = 6},
2665 { .input = &tegra_pll_m_out1, .value = 7},
2666 { 0, 0},
2667};
2668
2669static struct clk tegra_clk_sclk = {
2670 .name = "sclk",
2671 .inputs = mux_sclk,
2672 .reg = 0x28,
2673 .ops = &tegra_super_ops,
2674 .max_rate = 334000000,
2675 .min_rate = 40000000,
2676};
2677
2678static struct clk tegra_clk_blink = {
2679 .name = "blink",
2680 .parent = &tegra_clk_32k,
2681 .reg = 0x40,
2682 .ops = &tegra_blink_clk_ops,
2683 .max_rate = 32768,
2684};
2685
2686static struct clk_mux_sel mux_pllm_pllc_pllp_plla[] = {
2687 { .input = &tegra_pll_m, .value = 0},
2688 { .input = &tegra_pll_c, .value = 1},
2689 { .input = &tegra_pll_p, .value = 2},
2690 { .input = &tegra_pll_a_out0, .value = 3},
2691 { 0, 0},
2692};
2693
2694static struct clk_mux_sel mux_pllp_pllc_pllm_clkm[] = {
2695 { .input = &tegra_pll_p, .value = 0},
2696 { .input = &tegra_pll_c, .value = 1},
2697 { .input = &tegra_pll_m, .value = 2},
2698 { .input = &tegra_clk_m, .value = 3},
2699 { 0, 0},
2700};
2701
2702static struct clk_mux_sel mux_pllp_clkm[] = {
2703 { .input = &tegra_pll_p, .value = 0},
2704 { .input = &tegra_clk_m, .value = 3},
2705 { 0, 0},
2706};
2707
2708static struct clk_mux_sel mux_pllp_plld_pllc_clkm[] = {
2709 {.input = &tegra_pll_p, .value = 0},
2710 {.input = &tegra_pll_d_out0, .value = 1},
2711 {.input = &tegra_pll_c, .value = 2},
2712 {.input = &tegra_clk_m, .value = 3},
2713 { 0, 0},
2714};
2715
2716static struct clk_mux_sel mux_pllp_pllm_plld_plla_pllc_plld2_clkm[] = {
2717 {.input = &tegra_pll_p, .value = 0},
2718 {.input = &tegra_pll_m, .value = 1},
2719 {.input = &tegra_pll_d_out0, .value = 2},
2720 {.input = &tegra_pll_a_out0, .value = 3},
2721 {.input = &tegra_pll_c, .value = 4},
2722 {.input = &tegra_pll_d2_out0, .value = 5},
2723 {.input = &tegra_clk_m, .value = 6},
2724 { 0, 0},
2725};
2726
2727static struct clk_mux_sel mux_plla_pllc_pllp_clkm[] = {
2728 { .input = &tegra_pll_a_out0, .value = 0},
2729 /* { .input = &tegra_pll_c, .value = 1}, no use on tegra30 */
2730 { .input = &tegra_pll_p, .value = 2},
2731 { .input = &tegra_clk_m, .value = 3},
2732 { 0, 0},
2733};
2734
2735static struct clk_mux_sel mux_pllp_pllc_clk32_clkm[] = {
2736 {.input = &tegra_pll_p, .value = 0},
2737 {.input = &tegra_pll_c, .value = 1},
2738 {.input = &tegra_clk_32k, .value = 2},
2739 {.input = &tegra_clk_m, .value = 3},
2740 { 0, 0},
2741};
2742
2743static struct clk_mux_sel mux_pllp_pllc_clkm_clk32[] = {
2744 {.input = &tegra_pll_p, .value = 0},
2745 {.input = &tegra_pll_c, .value = 1},
2746 {.input = &tegra_clk_m, .value = 2},
2747 {.input = &tegra_clk_32k, .value = 3},
2748 { 0, 0},
2749};
2750
2751static struct clk_mux_sel mux_pllp_pllc_pllm[] = {
2752 {.input = &tegra_pll_p, .value = 0},
2753 {.input = &tegra_pll_c, .value = 1},
2754 {.input = &tegra_pll_m, .value = 2},
2755 { 0, 0},
2756};
2757
2758static struct clk_mux_sel mux_clk_m[] = {
2759 { .input = &tegra_clk_m, .value = 0},
2760 { 0, 0},
2761};
2762
2763static struct clk_mux_sel mux_pllp_out3[] = {
2764 { .input = &tegra_pll_p_out3, .value = 0},
2765 { 0, 0},
2766};
2767
2768static struct clk_mux_sel mux_plld_out0[] = {
2769 { .input = &tegra_pll_d_out0, .value = 0},
2770 { 0, 0},
2771};
2772
2773static struct clk_mux_sel mux_plld_out0_plld2_out0[] = {
2774 { .input = &tegra_pll_d_out0, .value = 0},
2775 { .input = &tegra_pll_d2_out0, .value = 1},
2776 { 0, 0},
2777};
2778
2779static struct clk_mux_sel mux_clk_32k[] = {
2780 { .input = &tegra_clk_32k, .value = 0},
2781 { 0, 0},
2782};
2783
2784static struct clk_mux_sel mux_plla_clk32_pllp_clkm_plle[] = {
2785 { .input = &tegra_pll_a_out0, .value = 0},
2786 { .input = &tegra_clk_32k, .value = 1},
2787 { .input = &tegra_pll_p, .value = 2},
2788 { .input = &tegra_clk_m, .value = 3},
2789 { .input = &tegra_pll_e, .value = 4},
2790 { 0, 0},
2791};
2792
2793static struct clk_mux_sel mux_cclk_g[] = {
2794 { .input = &tegra_clk_m, .value = 0},
2795 { .input = &tegra_pll_c, .value = 1},
2796 { .input = &tegra_clk_32k, .value = 2},
2797 { .input = &tegra_pll_m, .value = 3},
2798 { .input = &tegra_pll_p, .value = 4},
2799 { .input = &tegra_pll_p_out4, .value = 5},
2800 { .input = &tegra_pll_p_out3, .value = 6},
2801 { .input = &tegra_pll_x, .value = 8},
2802 { 0, 0},
2803};
2804
2805static struct clk tegra_clk_cclk_g = {
2806 .name = "cclk_g",
2807 .flags = DIV_U71 | DIV_U71_INT,
2808 .inputs = mux_cclk_g,
2809 .reg = 0x368,
2810 .ops = &tegra_super_ops,
2811 .max_rate = 1700000000,
2812};
2813
2814static struct clk tegra30_clk_twd = {
2815 .parent = &tegra_clk_cclk_g,
2816 .name = "twd",
2817 .ops = &tegra30_twd_ops,
2818 .max_rate = 1400000000, /* Same as tegra_clk_cpu_cmplx.max_rate */
2819 .mul = 1,
2820 .div = 2,
2821};
2822
2823#define PERIPH_CLK(_name, _dev, _con, _clk_num, _reg, _max, _inputs, _flags) \
2824 { \
2825 .name = _name, \
2826 .lookup = { \
2827 .dev_id = _dev, \
2828 .con_id = _con, \
2829 }, \
2830 .ops = &tegra_periph_clk_ops, \
2831 .reg = _reg, \
2832 .inputs = _inputs, \
2833 .flags = _flags, \
2834 .max_rate = _max, \
2835 .u.periph = { \
2836 .clk_num = _clk_num, \
2837 }, \
2838 }
2839
2840#define PERIPH_CLK_EX(_name, _dev, _con, _clk_num, _reg, _max, _inputs, \
2841 _flags, _ops) \
2842 { \
2843 .name = _name, \
2844 .lookup = { \
2845 .dev_id = _dev, \
2846 .con_id = _con, \
2847 }, \
2848 .ops = _ops, \
2849 .reg = _reg, \
2850 .inputs = _inputs, \
2851 .flags = _flags, \
2852 .max_rate = _max, \
2853 .u.periph = { \
2854 .clk_num = _clk_num, \
2855 }, \
2856 }
2857
2858#define SHARED_CLK(_name, _dev, _con, _parent, _id, _div, _mode)\
2859 { \
2860 .name = _name, \
2861 .lookup = { \
2862 .dev_id = _dev, \
2863 .con_id = _con, \
2864 }, \
2865 .ops = &tegra_clk_shared_bus_ops, \
2866 .parent = _parent, \
2867 .u.shared_bus_user = { \
2868 .client_id = _id, \
2869 .client_div = _div, \
2870 .mode = _mode, \
2871 }, \
2872 }
2873struct clk tegra_list_clks[] = {
2874 PERIPH_CLK("apbdma", "tegra-dma", 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),
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),
2878 PERIPH_CLK("kfuse", "kfuse-tegra", NULL, 40, 0, 26000000, mux_clk_m, 0),
2879 PERIPH_CLK("fuse", "fuse-tegra", "fuse", 39, 0, 26000000, mux_clk_m, PERIPH_ON_APB),
2880 PERIPH_CLK("fuse_burn", "fuse-tegra", "fuse_burn", 39, 0, 26000000, mux_clk_m, PERIPH_ON_APB),
2881 PERIPH_CLK("apbif", "tegra30-ahub", "apbif", 107, 0, 26000000, mux_clk_m, 0),
2882 PERIPH_CLK("i2s0", "tegra30-i2s.0", NULL, 30, 0x1d8, 26000000, mux_pllaout0_audio0_2x_pllp_clkm, MUX | DIV_U71 | PERIPH_ON_APB),
2883 PERIPH_CLK("i2s1", "tegra30-i2s.1", NULL, 11, 0x100, 26000000, mux_pllaout0_audio1_2x_pllp_clkm, MUX | DIV_U71 | PERIPH_ON_APB),
2884 PERIPH_CLK("i2s2", "tegra30-i2s.2", NULL, 18, 0x104, 26000000, mux_pllaout0_audio2_2x_pllp_clkm, MUX | DIV_U71 | PERIPH_ON_APB),
2885 PERIPH_CLK("i2s3", "tegra30-i2s.3", NULL, 101, 0x3bc, 26000000, mux_pllaout0_audio3_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),
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),
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),
2892 PERIPH_CLK("dam1", "tegra30-dam.1", NULL, 109, 0x3dc, 48000000, mux_plla_pllc_pllp_clkm, MUX | DIV_U71),
2893 PERIPH_CLK("dam2", "tegra30-dam.2", NULL, 110, 0x3e0, 48000000, mux_plla_pllc_pllp_clkm, MUX | DIV_U71),
2894 PERIPH_CLK("hda", "tegra30-hda", "hda", 125, 0x428, 108000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71),
2895 PERIPH_CLK("hda2codec_2x", "tegra30-hda", "hda2codec", 111, 0x3e4, 48000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71),
2896 PERIPH_CLK("hda2hdmi", "tegra30-hda", "hda2hdmi", 128, 0, 48000000, mux_clk_m, 0),
2897 PERIPH_CLK("sbc1", "spi_tegra.0", NULL, 41, 0x134, 160000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | PERIPH_ON_APB),
2898 PERIPH_CLK("sbc2", "spi_tegra.1", NULL, 44, 0x118, 160000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | PERIPH_ON_APB),
2899 PERIPH_CLK("sbc3", "spi_tegra.2", NULL, 46, 0x11c, 160000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | PERIPH_ON_APB),
2900 PERIPH_CLK("sbc4", "spi_tegra.3", NULL, 68, 0x1b4, 160000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | PERIPH_ON_APB),
2901 PERIPH_CLK("sbc5", "spi_tegra.4", NULL, 104, 0x3c8, 160000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | PERIPH_ON_APB),
2902 PERIPH_CLK("sbc6", "spi_tegra.5", NULL, 105, 0x3cc, 160000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | PERIPH_ON_APB),
2903 PERIPH_CLK("sata_oob", "tegra_sata_oob", NULL, 123, 0x420, 216000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71),
2904 PERIPH_CLK("sata", "tegra_sata", NULL, 124, 0x424, 216000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71),
2905 PERIPH_CLK("sata_cold", "tegra_sata_cold", NULL, 129, 0, 48000000, mux_clk_m, 0),
2906 PERIPH_CLK_EX("ndflash", "tegra_nand", NULL, 13, 0x160, 240000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71, &tegra_nand_clk_ops),
2907 PERIPH_CLK("ndspeed", "tegra_nand_speed", NULL, 80, 0x3f8, 240000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71),
2908 PERIPH_CLK("vfir", "vfir", NULL, 7, 0x168, 72000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | PERIPH_ON_APB),
2909 PERIPH_CLK("sdmmc1", "sdhci-tegra.0", NULL, 14, 0x150, 208000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), /* scales with voltage */
2910 PERIPH_CLK("sdmmc2", "sdhci-tegra.1", NULL, 9, 0x154, 104000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), /* scales with voltage */
2911 PERIPH_CLK("sdmmc3", "sdhci-tegra.2", NULL, 69, 0x1bc, 208000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), /* scales with voltage */
2912 PERIPH_CLK("sdmmc4", "sdhci-tegra.3", NULL, 15, 0x164, 104000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), /* scales with voltage */
2913 PERIPH_CLK("vcp", "tegra-avp", "vcp", 29, 0, 250000000, mux_clk_m, 0),
2914 PERIPH_CLK("bsea", "tegra-avp", "bsea", 62, 0, 250000000, mux_clk_m, 0),
2915 PERIPH_CLK("bsev", "tegra-aes", "bsev", 63, 0, 250000000, mux_clk_m, 0),
2916 PERIPH_CLK("vde", "vde", NULL, 61, 0x1c8, 520000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | DIV_U71_INT),
2917 PERIPH_CLK("csite", "csite", NULL, 73, 0x1d4, 144000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), /* max rate ??? */
2918 PERIPH_CLK("la", "la", NULL, 76, 0x1f8, 26000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71),
2919 PERIPH_CLK("owr", "tegra_w1", NULL, 71, 0x1cc, 26000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | PERIPH_ON_APB),
2920 PERIPH_CLK("nor", "nor", NULL, 42, 0x1d0, 127000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71), /* requires min voltage */
2921 PERIPH_CLK("mipi", "mipi", NULL, 50, 0x174, 60000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | PERIPH_ON_APB), /* scales with voltage */
2922 PERIPH_CLK("i2c1", "tegra-i2c.0", NULL, 12, 0x124, 26000000, mux_pllp_clkm, MUX | DIV_U16 | PERIPH_ON_APB),
2923 PERIPH_CLK("i2c2", "tegra-i2c.1", NULL, 54, 0x198, 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),
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),
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),
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),
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),
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),
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),
2940 PERIPH_CLK("2d", "2d", NULL, 21, 0x15c, 520000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71 | DIV_U71_INT | DIV_U71_IDLE),
2941 PERIPH_CLK("vi_sensor", "tegra_camera", "vi_sensor", 20, 0x1a8, 150000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71 | PERIPH_NO_RESET),
2942 PERIPH_CLK("epp", "epp", NULL, 19, 0x16c, 520000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71 | DIV_U71_INT),
2943 PERIPH_CLK("mpe", "mpe", NULL, 60, 0x170, 520000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71 | DIV_U71_INT),
2944 PERIPH_CLK("host1x", "host1x", NULL, 28, 0x180, 260000000, mux_pllm_pllc_pllp_plla, MUX | DIV_U71 | DIV_U71_INT),
2945 PERIPH_CLK("cve", "cve", NULL, 49, 0x140, 250000000, mux_pllp_plld_pllc_clkm, MUX | DIV_U71), /* requires min voltage */
2946 PERIPH_CLK("tvo", "tvo", NULL, 49, 0x188, 250000000, mux_pllp_plld_pllc_clkm, MUX | DIV_U71), /* requires min voltage */
2947 PERIPH_CLK_EX("dtv", "dtv", NULL, 79, 0x1dc, 250000000, mux_clk_m, 0, &tegra_dtv_clk_ops),
2948 PERIPH_CLK("hdmi", "hdmi", NULL, 51, 0x18c, 148500000, mux_pllp_pllm_plld_plla_pllc_plld2_clkm, MUX | MUX8 | DIV_U71),
2949 PERIPH_CLK("tvdac", "tvdac", NULL, 53, 0x194, 220000000, mux_pllp_plld_pllc_clkm, MUX | DIV_U71), /* requires min voltage */
2950 PERIPH_CLK("disp1", "tegradc.0", NULL, 27, 0x138, 600000000, mux_pllp_pllm_plld_plla_pllc_plld2_clkm, MUX | MUX8),
2951 PERIPH_CLK("disp2", "tegradc.1", NULL, 26, 0x13c, 600000000, mux_pllp_pllm_plld_plla_pllc_plld2_clkm, MUX | MUX8),
2952 PERIPH_CLK("usbd", "fsl-tegra-udc", NULL, 22, 0, 480000000, mux_clk_m, 0), /* requires min voltage */
2953 PERIPH_CLK("usb2", "tegra-ehci.1", NULL, 58, 0, 480000000, mux_clk_m, 0), /* requires min voltage */
2954 PERIPH_CLK("usb3", "tegra-ehci.2", NULL, 59, 0, 480000000, mux_clk_m, 0), /* requires min voltage */
2955 PERIPH_CLK("dsia", "tegradc.0", "dsia", 48, 0, 500000000, mux_plld_out0, 0),
2956 PERIPH_CLK_EX("dsib", "tegradc.1", "dsib", 82, 0xd0, 500000000, mux_plld_out0_plld2_out0, MUX | PLLD, &tegra_dsib_clk_ops),
2957 PERIPH_CLK("csi", "tegra_camera", "csi", 52, 0, 102000000, mux_pllp_out3, 0),
2958 PERIPH_CLK("isp", "tegra_camera", "isp", 23, 0, 150000000, mux_clk_m, 0), /* same frequency as VI */
2959 PERIPH_CLK("csus", "tegra_camera", "csus", 92, 0, 150000000, mux_clk_m, PERIPH_NO_RESET),
2960
2961 PERIPH_CLK("tsensor", "tegra-tsensor", NULL, 100, 0x3b8, 216000000, mux_pllp_pllc_clkm_clk32, MUX | DIV_U71),
2962 PERIPH_CLK("actmon", "actmon", NULL, 119, 0x3e8, 216000000, mux_pllp_pllc_clk32_clkm, MUX | DIV_U71),
2963 PERIPH_CLK("extern1", "extern1", NULL, 120, 0x3ec, 216000000, mux_plla_clk32_pllp_clkm_plle, MUX | MUX8 | DIV_U71),
2964 PERIPH_CLK("extern2", "extern2", NULL, 121, 0x3f0, 216000000, mux_plla_clk32_pllp_clkm_plle, MUX | MUX8 | DIV_U71),
2965 PERIPH_CLK("extern3", "extern3", NULL, 122, 0x3f4, 216000000, mux_plla_clk32_pllp_clkm_plle, MUX | MUX8 | DIV_U71),
2966 PERIPH_CLK("i2cslow", "i2cslow", NULL, 81, 0x3fc, 26000000, mux_pllp_pllc_clk32_clkm, MUX | DIV_U71 | PERIPH_ON_APB),
2967 PERIPH_CLK("pcie", "tegra-pcie", "pcie", 70, 0, 250000000, mux_clk_m, 0),
2968 PERIPH_CLK("afi", "tegra-pcie", "afi", 72, 0, 250000000, mux_clk_m, 0),
2969 PERIPH_CLK("se", "se", NULL, 127, 0x42c, 520000000, mux_pllp_pllc_pllm_clkm, MUX | DIV_U71 | DIV_U71_INT),
2970};
2971
2972#define CLK_DUPLICATE(_name, _dev, _con) \
2973 { \
2974 .name = _name, \
2975 .lookup = { \
2976 .dev_id = _dev, \
2977 .con_id = _con, \
2978 }, \
2979 }
2980
2981/* Some clocks may be used by different drivers depending on the board
2982 * configuration. List those here to register them twice in the clock lookup
2983 * table under two names.
2984 */
2985struct clk_duplicate tegra_clk_duplicates[] = {
2986 CLK_DUPLICATE("usbd", "utmip-pad", NULL),
2987 CLK_DUPLICATE("usbd", "tegra-ehci.0", NULL),
2988 CLK_DUPLICATE("usbd", "tegra-otg", NULL),
2989 CLK_DUPLICATE("hdmi", "tegradc.0", "hdmi"),
2990 CLK_DUPLICATE("hdmi", "tegradc.1", "hdmi"),
2991 CLK_DUPLICATE("dsib", "tegradc.0", "dsib"),
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"),
2998 CLK_DUPLICATE("bsev", "nvavp", "bsev"),
2999 CLK_DUPLICATE("vde", "tegra-aes", "vde"),
3000 CLK_DUPLICATE("bsea", "tegra-aes", "bsea"),
3001 CLK_DUPLICATE("bsea", "nvavp", "bsea"),
3002 CLK_DUPLICATE("cml1", "tegra_sata_cml", NULL),
3003 CLK_DUPLICATE("cml0", "tegra_pcie", "cml"),
3004 CLK_DUPLICATE("pciex", "tegra_pcie", "pciex"),
3005 CLK_DUPLICATE("i2c1", "tegra-i2c-slave.0", NULL),
3006 CLK_DUPLICATE("i2c2", "tegra-i2c-slave.1", NULL),
3007 CLK_DUPLICATE("i2c3", "tegra-i2c-slave.2", NULL),
3008 CLK_DUPLICATE("i2c4", "tegra-i2c-slave.3", NULL),
3009 CLK_DUPLICATE("i2c5", "tegra-i2c-slave.4", NULL),
3010 CLK_DUPLICATE("sbc1", "spi_slave_tegra.0", NULL),
3011 CLK_DUPLICATE("sbc2", "spi_slave_tegra.1", NULL),
3012 CLK_DUPLICATE("sbc3", "spi_slave_tegra.2", NULL),
3013 CLK_DUPLICATE("sbc4", "spi_slave_tegra.3", NULL),
3014 CLK_DUPLICATE("sbc5", "spi_slave_tegra.4", NULL),
3015 CLK_DUPLICATE("sbc6", "spi_slave_tegra.5", NULL),
3016 CLK_DUPLICATE("twd", "smp_twd", NULL),
3017 CLK_DUPLICATE("vcp", "nvavp", "vcp"),
3018};
3019
3020struct clk *tegra_ptr_clks[] = {
3021 &tegra_clk_32k,
3022 &tegra_clk_m,
3023 &tegra_clk_m_div2,
3024 &tegra_clk_m_div4,
3025 &tegra_pll_ref,
3026 &tegra_pll_m,
3027 &tegra_pll_m_out1,
3028 &tegra_pll_c,
3029 &tegra_pll_c_out1,
3030 &tegra_pll_p,
3031 &tegra_pll_p_out1,
3032 &tegra_pll_p_out2,
3033 &tegra_pll_p_out3,
3034 &tegra_pll_p_out4,
3035 &tegra_pll_a,
3036 &tegra_pll_a_out0,
3037 &tegra_pll_d,
3038 &tegra_pll_d_out0,
3039 &tegra_pll_d2,
3040 &tegra_pll_d2_out0,
3041 &tegra_pll_u,
3042 &tegra_pll_x,
3043 &tegra_pll_x_out0,
3044 &tegra_pll_e,
3045 &tegra_clk_cclk_g,
3046 &tegra_cml0_clk,
3047 &tegra_cml1_clk,
3048 &tegra_pciex_clk,
3049 &tegra_clk_sclk,
3050 &tegra_clk_blink,
3051 &tegra30_clk_twd,
3052};
3053
3054
3055static void tegra30_init_one_clock(struct clk *c)
3056{
3057 clk_init(c);
3058 INIT_LIST_HEAD(&c->shared_bus_list);
3059 if (!c->lookup.dev_id && !c->lookup.con_id)
3060 c->lookup.con_id = c->name;
3061 c->lookup.clk = c;
3062 clkdev_add(&c->lookup);
3063}
3064
3065void __init tegra30_init_clocks(void)
3066{
3067 int i;
3068 struct clk *c;
3069
3070 for (i = 0; i < ARRAY_SIZE(tegra_ptr_clks); i++)
3071 tegra30_init_one_clock(tegra_ptr_clks[i]);
3072
3073 for (i = 0; i < ARRAY_SIZE(tegra_list_clks); i++)
3074 tegra30_init_one_clock(&tegra_list_clks[i]);
3075
3076 for (i = 0; i < ARRAY_SIZE(tegra_clk_duplicates); i++) {
3077 c = tegra_get_clock_by_name(tegra_clk_duplicates[i].name);
3078 if (!c) {
3079 pr_err("%s: Unknown duplicate clock %s\n", __func__,
3080 tegra_clk_duplicates[i].name);
3081 continue;
3082 }
3083
3084 tegra_clk_duplicates[i].lookup.clk = c;
3085 clkdev_add(&tegra_clk_duplicates[i].lookup);
3086 }
3087
3088 for (i = 0; i < ARRAY_SIZE(tegra_sync_source_list); i++)
3089 tegra30_init_one_clock(&tegra_sync_source_list[i]);
3090 for (i = 0; i < ARRAY_SIZE(tegra_clk_audio_list); i++)
3091 tegra30_init_one_clock(&tegra_clk_audio_list[i]);
3092 for (i = 0; i < ARRAY_SIZE(tegra_clk_audio_2x_list); i++)
3093 tegra30_init_one_clock(&tegra_clk_audio_2x_list[i]);
3094
3095 init_clk_out_mux();
3096 for (i = 0; i < ARRAY_SIZE(tegra_clk_out_list); i++)
3097 tegra30_init_one_clock(&tegra_clk_out_list[i]);
3098
3099}
diff --git a/arch/arm/mach-tegra/timer.c b/arch/arm/mach-tegra/timer.c
index 1d1acda4f3e..1eed8d4a80e 100644
--- a/arch/arm/mach-tegra/timer.c
+++ b/arch/arm/mach-tegra/timer.c
@@ -28,7 +28,7 @@
28#include <linux/io.h> 28#include <linux/io.h>
29 29
30#include <asm/mach/time.h> 30#include <asm/mach/time.h>
31#include <asm/localtimer.h> 31#include <asm/smp_twd.h>
32#include <asm/sched_clock.h> 32#include <asm/sched_clock.h>
33 33
34#include <mach/iomap.h> 34#include <mach/iomap.h>
@@ -162,6 +162,21 @@ static struct irqaction tegra_timer_irq = {
162 .irq = INT_TMR3, 162 .irq = INT_TMR3,
163}; 163};
164 164
165#ifdef CONFIG_HAVE_ARM_TWD
166static DEFINE_TWD_LOCAL_TIMER(twd_local_timer,
167 TEGRA_ARM_PERIF_BASE + 0x600,
168 IRQ_LOCALTIMER);
169
170static void __init tegra_twd_init(void)
171{
172 int err = twd_local_timer_register(&twd_local_timer);
173 if (err)
174 pr_err("twd_local_timer_register failed %d\n", err);
175}
176#else
177#define tegra_twd_init() do {} while(0)
178#endif
179
165static void __init tegra_init_timer(void) 180static void __init tegra_init_timer(void)
166{ 181{
167 struct clk *clk; 182 struct clk *clk;
@@ -188,10 +203,6 @@ static void __init tegra_init_timer(void)
188 else 203 else
189 clk_enable(clk); 204 clk_enable(clk);
190 205
191#ifdef CONFIG_HAVE_ARM_TWD
192 twd_base = IO_ADDRESS(TEGRA_ARM_PERIF_BASE + 0x600);
193#endif
194
195 switch (rate) { 206 switch (rate) {
196 case 12000000: 207 case 12000000:
197 timer_writel(0x000b, TIMERUS_USEC_CFG); 208 timer_writel(0x000b, TIMERUS_USEC_CFG);
@@ -231,6 +242,7 @@ static void __init tegra_init_timer(void)
231 tegra_clockevent.cpumask = cpu_all_mask; 242 tegra_clockevent.cpumask = cpu_all_mask;
232 tegra_clockevent.irq = tegra_timer_irq.irq; 243 tegra_clockevent.irq = tegra_timer_irq.irq;
233 clockevents_register_device(&tegra_clockevent); 244 clockevents_register_device(&tegra_clockevent);
245 tegra_twd_init();
234} 246}
235 247
236struct sys_timer tegra_timer = { 248struct sys_timer tegra_timer = {
diff --git a/arch/arm/mach-tegra/usb_phy.c b/arch/arm/mach-tegra/usb_phy.c
index ad321f9e2bb..c5b2ac04e2a 100644
--- a/arch/arm/mach-tegra/usb_phy.c
+++ b/arch/arm/mach-tegra/usb_phy.c
@@ -22,6 +22,7 @@
22#include <linux/delay.h> 22#include <linux/delay.h>
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/err.h> 24#include <linux/err.h>
25#include <linux/export.h>
25#include <linux/platform_device.h> 26#include <linux/platform_device.h>
26#include <linux/io.h> 27#include <linux/io.h>
27#include <linux/gpio.h> 28#include <linux/gpio.h>
@@ -730,6 +731,7 @@ err0:
730 kfree(phy); 731 kfree(phy);
731 return ERR_PTR(err); 732 return ERR_PTR(err);
732} 733}
734EXPORT_SYMBOL_GPL(tegra_usb_phy_open);
733 735
734int tegra_usb_phy_power_on(struct tegra_usb_phy *phy) 736int tegra_usb_phy_power_on(struct tegra_usb_phy *phy)
735{ 737{
@@ -738,6 +740,7 @@ int tegra_usb_phy_power_on(struct tegra_usb_phy *phy)
738 else 740 else
739 return utmi_phy_power_on(phy); 741 return utmi_phy_power_on(phy);
740} 742}
743EXPORT_SYMBOL_GPL(tegra_usb_phy_power_on);
741 744
742void tegra_usb_phy_power_off(struct tegra_usb_phy *phy) 745void tegra_usb_phy_power_off(struct tegra_usb_phy *phy)
743{ 746{
@@ -746,18 +749,21 @@ void tegra_usb_phy_power_off(struct tegra_usb_phy *phy)
746 else 749 else
747 utmi_phy_power_off(phy); 750 utmi_phy_power_off(phy);
748} 751}
752EXPORT_SYMBOL_GPL(tegra_usb_phy_power_off);
749 753
750void tegra_usb_phy_preresume(struct tegra_usb_phy *phy) 754void tegra_usb_phy_preresume(struct tegra_usb_phy *phy)
751{ 755{
752 if (!phy_is_ulpi(phy)) 756 if (!phy_is_ulpi(phy))
753 utmi_phy_preresume(phy); 757 utmi_phy_preresume(phy);
754} 758}
759EXPORT_SYMBOL_GPL(tegra_usb_phy_preresume);
755 760
756void tegra_usb_phy_postresume(struct tegra_usb_phy *phy) 761void tegra_usb_phy_postresume(struct tegra_usb_phy *phy)
757{ 762{
758 if (!phy_is_ulpi(phy)) 763 if (!phy_is_ulpi(phy))
759 utmi_phy_postresume(phy); 764 utmi_phy_postresume(phy);
760} 765}
766EXPORT_SYMBOL_GPL(tegra_usb_phy_postresume);
761 767
762void tegra_ehci_phy_restore_start(struct tegra_usb_phy *phy, 768void tegra_ehci_phy_restore_start(struct tegra_usb_phy *phy,
763 enum tegra_usb_phy_port_speed port_speed) 769 enum tegra_usb_phy_port_speed port_speed)
@@ -765,24 +771,28 @@ void tegra_ehci_phy_restore_start(struct tegra_usb_phy *phy,
765 if (!phy_is_ulpi(phy)) 771 if (!phy_is_ulpi(phy))
766 utmi_phy_restore_start(phy, port_speed); 772 utmi_phy_restore_start(phy, port_speed);
767} 773}
774EXPORT_SYMBOL_GPL(tegra_ehci_phy_restore_start);
768 775
769void tegra_ehci_phy_restore_end(struct tegra_usb_phy *phy) 776void tegra_ehci_phy_restore_end(struct tegra_usb_phy *phy)
770{ 777{
771 if (!phy_is_ulpi(phy)) 778 if (!phy_is_ulpi(phy))
772 utmi_phy_restore_end(phy); 779 utmi_phy_restore_end(phy);
773} 780}
781EXPORT_SYMBOL_GPL(tegra_ehci_phy_restore_end);
774 782
775void tegra_usb_phy_clk_disable(struct tegra_usb_phy *phy) 783void tegra_usb_phy_clk_disable(struct tegra_usb_phy *phy)
776{ 784{
777 if (!phy_is_ulpi(phy)) 785 if (!phy_is_ulpi(phy))
778 utmi_phy_clk_disable(phy); 786 utmi_phy_clk_disable(phy);
779} 787}
788EXPORT_SYMBOL_GPL(tegra_usb_phy_clk_disable);
780 789
781void tegra_usb_phy_clk_enable(struct tegra_usb_phy *phy) 790void tegra_usb_phy_clk_enable(struct tegra_usb_phy *phy)
782{ 791{
783 if (!phy_is_ulpi(phy)) 792 if (!phy_is_ulpi(phy))
784 utmi_phy_clk_enable(phy); 793 utmi_phy_clk_enable(phy);
785} 794}
795EXPORT_SYMBOL_GPL(tegra_usb_phy_clk_enable);
786 796
787void tegra_usb_phy_close(struct tegra_usb_phy *phy) 797void tegra_usb_phy_close(struct tegra_usb_phy *phy)
788{ 798{
@@ -794,3 +804,4 @@ void tegra_usb_phy_close(struct tegra_usb_phy *phy)
794 clk_put(phy->pll_u); 804 clk_put(phy->pll_u);
795 kfree(phy); 805 kfree(phy);
796} 806}
807EXPORT_SYMBOL_GPL(tegra_usb_phy_close);
diff --git a/arch/arm/mach-u300/Makefile b/arch/arm/mach-u300/Makefile
index 285538124e5..fd3a5c382f4 100644
--- a/arch/arm/mach-u300/Makefile
+++ b/arch/arm/mach-u300/Makefile
@@ -8,7 +8,6 @@ obj-n :=
8obj- := 8obj- :=
9 9
10obj-$(CONFIG_ARCH_U300) += u300.o 10obj-$(CONFIG_ARCH_U300) += u300.o
11obj-$(CONFIG_MMC) += mmc.o
12obj-$(CONFIG_SPI_PL022) += spi.o 11obj-$(CONFIG_SPI_PL022) += spi.o
13obj-$(CONFIG_MACH_U300_SPIDUMMY) += dummyspichip.o 12obj-$(CONFIG_MACH_U300_SPIDUMMY) += dummyspichip.o
14obj-$(CONFIG_I2C_STU300) += i2c.o 13obj-$(CONFIG_I2C_STU300) += i2c.o
diff --git a/arch/arm/mach-u300/core.c b/arch/arm/mach-u300/core.c
index a7b3f36e226..8b90c44d237 100644
--- a/arch/arm/mach-u300/core.c
+++ b/arch/arm/mach-u300/core.c
@@ -18,6 +18,7 @@
18#include <linux/termios.h> 18#include <linux/termios.h>
19#include <linux/dmaengine.h> 19#include <linux/dmaengine.h>
20#include <linux/amba/bus.h> 20#include <linux/amba/bus.h>
21#include <linux/amba/mmci.h>
21#include <linux/amba/serial.h> 22#include <linux/amba/serial.h>
22#include <linux/platform_device.h> 23#include <linux/platform_device.h>
23#include <linux/gpio.h> 24#include <linux/gpio.h>
@@ -44,9 +45,9 @@
44#include <mach/gpio-u300.h> 45#include <mach/gpio-u300.h>
45 46
46#include "clock.h" 47#include "clock.h"
47#include "mmc.h"
48#include "spi.h" 48#include "spi.h"
49#include "i2c.h" 49#include "i2c.h"
50#include "u300-gpio.h"
50 51
51/* 52/*
52 * Static I/O mappings that are needed for booting the U300 platforms. The 53 * Static I/O mappings that are needed for booting the U300 platforms. The
@@ -95,19 +96,9 @@ static struct amba_pl011_data uart0_plat_data = {
95#endif 96#endif
96}; 97};
97 98
98static struct amba_device uart0_device = { 99/* Slow device at 0x3000 offset */
99 .dev = { 100static AMBA_APB_DEVICE(uart0, "uart0", 0, U300_UART0_BASE,
100 .coherent_dma_mask = ~0, 101 { IRQ_U300_UART0 }, &uart0_plat_data);
101 .init_name = "uart0", /* Slow device at 0x3000 offset */
102 .platform_data = &uart0_plat_data,
103 },
104 .res = {
105 .start = U300_UART0_BASE,
106 .end = U300_UART0_BASE + SZ_4K - 1,
107 .flags = IORESOURCE_MEM,
108 },
109 .irq = { IRQ_U300_UART0, NO_IRQ },
110};
111 102
112/* The U335 have an additional UART1 on the APP CPU */ 103/* The U335 have an additional UART1 on the APP CPU */
113#ifdef CONFIG_MACH_U300_BS335 104#ifdef CONFIG_MACH_U300_BS335
@@ -119,72 +110,42 @@ static struct amba_pl011_data uart1_plat_data = {
119#endif 110#endif
120}; 111};
121 112
122static struct amba_device uart1_device = { 113/* Fast device at 0x7000 offset */
123 .dev = { 114static AMBA_APB_DEVICE(uart1, "uart1", 0, U300_UART1_BASE,
124 .coherent_dma_mask = ~0, 115 { IRQ_U300_UART1 }, &uart1_plat_data);
125 .init_name = "uart1", /* Fast device at 0x7000 offset */
126 .platform_data = &uart1_plat_data,
127 },
128 .res = {
129 .start = U300_UART1_BASE,
130 .end = U300_UART1_BASE + SZ_4K - 1,
131 .flags = IORESOURCE_MEM,
132 },
133 .irq = { IRQ_U300_UART1, NO_IRQ },
134};
135#endif 116#endif
136 117
137static struct amba_device pl172_device = { 118/* AHB device at 0x4000 offset */
138 .dev = { 119static AMBA_APB_DEVICE(pl172, "pl172", 0, U300_EMIF_CFG_BASE, { }, NULL);
139 .init_name = "pl172", /* AHB device at 0x4000 offset */
140 .platform_data = NULL,
141 },
142 .res = {
143 .start = U300_EMIF_CFG_BASE,
144 .end = U300_EMIF_CFG_BASE + SZ_4K - 1,
145 .flags = IORESOURCE_MEM,
146 },
147};
148 120
121/* Fast device at 0x6000 offset */
122static AMBA_APB_DEVICE(pl022, "pl022", 0, U300_SPI_BASE,
123 { IRQ_U300_SPI }, NULL);
149 124
150/* 125/* Fast device at 0x1000 offset */
151 * Everything within this next ifdef deals with external devices connected to 126#define U300_MMCSD_IRQS { IRQ_U300_MMCSD_MCIINTR0, IRQ_U300_MMCSD_MCIINTR1 }
152 * the APP SPI bus.
153 */
154static struct amba_device pl022_device = {
155 .dev = {
156 .coherent_dma_mask = ~0,
157 .init_name = "pl022", /* Fast device at 0x6000 offset */
158 },
159 .res = {
160 .start = U300_SPI_BASE,
161 .end = U300_SPI_BASE + SZ_4K - 1,
162 .flags = IORESOURCE_MEM,
163 },
164 .irq = {IRQ_U300_SPI, NO_IRQ },
165 /*
166 * This device has a DMA channel but the Linux driver does not use
167 * it currently.
168 */
169};
170 127
171static struct amba_device mmcsd_device = { 128static struct mmci_platform_data mmcsd_platform_data = {
172 .dev = {
173 .init_name = "mmci", /* Fast device at 0x1000 offset */
174 .platform_data = NULL, /* Added later */
175 },
176 .res = {
177 .start = U300_MMCSD_BASE,
178 .end = U300_MMCSD_BASE + SZ_4K - 1,
179 .flags = IORESOURCE_MEM,
180 },
181 .irq = {IRQ_U300_MMCSD_MCIINTR0, IRQ_U300_MMCSD_MCIINTR1 },
182 /* 129 /*
183 * This device has a DMA channel but the Linux driver does not use 130 * Do not set ocr_mask or voltage translation function,
184 * it currently. 131 * we have a regulator we can control instead.
185 */ 132 */
133 .f_max = 24000000,
134 .gpio_wp = -1,
135 .gpio_cd = U300_GPIO_PIN_MMC_CD,
136 .cd_invert = true,
137 .capabilities = MMC_CAP_MMC_HIGHSPEED |
138 MMC_CAP_SD_HIGHSPEED | MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
139#ifdef CONFIG_COH901318
140 .dma_filter = coh901318_filter_id,
141 .dma_rx_param = (void *) U300_DMA_MMCSD_RX_TX,
142 /* Don't specify a TX channel, this RX channel is bidirectional */
143#endif
186}; 144};
187 145
146static AMBA_APB_DEVICE(mmcsd, "mmci", 0, U300_MMCSD_BASE,
147 U300_MMCSD_IRQS, &mmcsd_platform_data);
148
188/* 149/*
189 * The order of device declaration may be important, since some devices 150 * The order of device declaration may be important, since some devices
190 * have dependencies on other devices being initialized first. 151 * have dependencies on other devices being initialized first.
@@ -1883,16 +1844,6 @@ void __init u300_init_devices(void)
1883 writew(val, U300_SYSCON_VBASE + U300_SYSCON_SMCR); 1844 writew(val, U300_SYSCON_VBASE + U300_SYSCON_SMCR);
1884} 1845}
1885 1846
1886static int core_module_init(void)
1887{
1888 /*
1889 * This needs to be initialized later: it needs the input framework
1890 * to be initialized first.
1891 */
1892 return mmc_init(&mmcsd_device);
1893}
1894module_init(core_module_init);
1895
1896/* Forward declare this function from the watchdog */ 1847/* Forward declare this function from the watchdog */
1897void coh901327_watchdog_reset(void); 1848void coh901327_watchdog_reset(void);
1898 1849
diff --git a/arch/arm/mach-u300/include/mach/entry-macro.S b/arch/arm/mach-u300/include/mach/entry-macro.S
deleted file mode 100644
index 7181d6ac665..00000000000
--- a/arch/arm/mach-u300/include/mach/entry-macro.S
+++ /dev/null
@@ -1,16 +0,0 @@
1/*
2 *
3 * arch-arm/mach-u300/include/mach/entry-macro.S
4 *
5 *
6 * Copyright (C) 2006-2009 ST-Ericsson AB
7 * License terms: GNU General Public License (GPL) version 2
8 * Low-level IRQ helper macros for ST-Ericsson U300
9 * Author: Linus Walleij <linus.walleij@stericsson.com>
10 */
11
12 .macro disable_fiq
13 .endm
14
15 .macro arch_ret_to_user, tmp1, tmp2
16 .endm
diff --git a/arch/arm/mach-u300/include/mach/system.h b/arch/arm/mach-u300/include/mach/system.h
deleted file mode 100644
index 574d46e3829..00000000000
--- a/arch/arm/mach-u300/include/mach/system.h
+++ /dev/null
@@ -1,14 +0,0 @@
1/*
2 *
3 * arch/arm/mach-u300/include/mach/system.h
4 *
5 *
6 * Copyright (C) 2007-2009 ST-Ericsson AB
7 * License terms: GNU General Public License (GPL) version 2
8 * System shutdown and reset functions.
9 * Author: Linus Walleij <linus.walleij@stericsson.com>
10 */
11static inline void arch_idle(void)
12{
13 cpu_do_idle();
14}
diff --git a/arch/arm/mach-u300/mmc.c b/arch/arm/mach-u300/mmc.c
deleted file mode 100644
index 05abd6ad9fa..00000000000
--- a/arch/arm/mach-u300/mmc.c
+++ /dev/null
@@ -1,52 +0,0 @@
1/*
2 *
3 * arch/arm/mach-u300/mmc.c
4 *
5 *
6 * Copyright (C) 2009 ST-Ericsson SA
7 * License terms: GNU General Public License (GPL) version 2
8 *
9 * Author: Linus Walleij <linus.walleij@stericsson.com>
10 * Author: Johan Lundin
11 * Author: Jonas Aaberg <jonas.aberg@stericsson.com>
12 */
13#include <linux/device.h>
14#include <linux/amba/bus.h>
15#include <linux/mmc/host.h>
16#include <linux/dmaengine.h>
17#include <linux/amba/mmci.h>
18#include <linux/slab.h>
19#include <mach/coh901318.h>
20#include <mach/dma_channels.h>
21
22#include "u300-gpio.h"
23#include "mmc.h"
24
25static struct mmci_platform_data mmc0_plat_data = {
26 /*
27 * Do not set ocr_mask or voltage translation function,
28 * we have a regulator we can control instead.
29 */
30 /* Nominally 2.85V on our platform */
31 .f_max = 24000000,
32 .gpio_wp = -1,
33 .gpio_cd = U300_GPIO_PIN_MMC_CD,
34 .cd_invert = true,
35 .capabilities = MMC_CAP_MMC_HIGHSPEED |
36 MMC_CAP_SD_HIGHSPEED | MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
37#ifdef CONFIG_COH901318
38 .dma_filter = coh901318_filter_id,
39 .dma_rx_param = (void *) U300_DMA_MMCSD_RX_TX,
40 /* Don't specify a TX channel, this RX channel is bidirectional */
41#endif
42};
43
44int __devinit mmc_init(struct amba_device *adev)
45{
46 struct device *mmcsd_device = &adev->dev;
47 int ret = 0;
48
49 mmcsd_device->platform_data = &mmc0_plat_data;
50
51 return ret;
52}
diff --git a/arch/arm/mach-u300/mmc.h b/arch/arm/mach-u300/mmc.h
deleted file mode 100644
index 92b85125abb..00000000000
--- a/arch/arm/mach-u300/mmc.h
+++ /dev/null
@@ -1,18 +0,0 @@
1/*
2 *
3 * arch/arm/mach-u300/mmc.h
4 *
5 *
6 * Copyright (C) 2009 ST-Ericsson AB
7 * License terms: GNU General Public License (GPL) version 2
8 *
9 * Author: Jonas Aaberg <jonas.aberg@stericsson.com>
10 */
11#ifndef MMC_H
12#define MMC_H
13
14#include <linux/amba/bus.h>
15
16int __devinit mmc_init(struct amba_device *adev);
17
18#endif
diff --git a/arch/arm/mach-ux500/Kconfig b/arch/arm/mach-ux500/Kconfig
index c59e8b892d6..880d02ec89d 100644
--- a/arch/arm/mach-ux500/Kconfig
+++ b/arch/arm/mach-ux500/Kconfig
@@ -8,47 +8,62 @@ config UX500_SOC_COMMON
8 select PL310_ERRATA_753970 8 select PL310_ERRATA_753970
9 select ARM_ERRATA_754322 9 select ARM_ERRATA_754322
10 select ARM_ERRATA_764369 10 select ARM_ERRATA_764369
11 11 select CACHE_L2X0
12menu "Ux500 SoC"
13 12
14config UX500_SOC_DB5500 13config UX500_SOC_DB5500
15 bool "DB5500" 14 bool
16 select MFD_DB5500_PRCMU 15 select MFD_DB5500_PRCMU
17 16
18config UX500_SOC_DB8500 17config UX500_SOC_DB8500
19 bool "DB8500" 18 bool
20 select MFD_DB8500_PRCMU 19 select MFD_DB8500_PRCMU
21 select REGULATOR_DB8500_PRCMU 20 select REGULATOR_DB8500_PRCMU
22 21 select CPU_FREQ_TABLE if CPU_FREQ
23endmenu
24 22
25menu "Ux500 target platform (boards)" 23menu "Ux500 target platform (boards)"
26 24
27config MACH_U8500 25config MACH_MOP500
28 bool "U8500 Development platform" 26 bool "U8500 Development platform, MOP500 versions"
29 depends on UX500_SOC_DB8500 27 select UX500_SOC_DB8500
30 select TPS6105X 28 select I2C
29 select I2C_NOMADIK
30 select SOC_BUS
31 help 31 help
32 Include support for the mop500 development platform. 32 Include support for the MOP500 development platform.
33 33
34config MACH_HREFV60 34config MACH_HREFV60
35 bool "U85000 Development platform, HREFv60 version" 35 bool "U8500 Development platform, HREFv60 version"
36 depends on UX500_SOC_DB8500 36 select MACH_MOP500
37 help 37 help
38 Include support for the HREFv60 new development platform. 38 Include support for the HREFv60 new development platform.
39 Includes HREFv70, v71 etc.
39 40
40config MACH_SNOWBALL 41config MACH_SNOWBALL
41 bool "U8500 Snowball platform" 42 bool "U8500 Snowball platform"
42 depends on UX500_SOC_DB8500 43 select MACH_MOP500
43 select MACH_U8500
44 help 44 help
45 Include support for the snowball development platform. 45 Include support for the snowball development platform.
46 46
47config MACH_U5500 47config MACH_U5500
48 bool "U5500 Development platform" 48 bool "U5500 Development platform"
49 depends on UX500_SOC_DB5500 49 select UX500_SOC_DB5500
50 help 50 help
51 Include support for the U5500 development platform. 51 Include support for the U5500 development platform.
52
53config UX500_AUTO_PLATFORM
54 def_bool y
55 depends on !MACH_U5500
56 select MACH_MOP500
57 help
58 At least one platform needs to be selected in order to build
59 a working kernel. If everything else is disabled, this
60 automatically enables MACH_MOP500.
61
62config MACH_UX500_DT
63 bool "Generic U8500 support using device tree"
64 depends on MACH_MOP500
65 select USE_OF
66
52endmenu 67endmenu
53 68
54config UX500_DEBUG_UART 69config UX500_DEBUG_UART
diff --git a/arch/arm/mach-ux500/Makefile b/arch/arm/mach-ux500/Makefile
index 6bd2f451c18..465b9ec9510 100644
--- a/arch/arm/mach-ux500/Makefile
+++ b/arch/arm/mach-ux500/Makefile
@@ -7,7 +7,7 @@ obj-y := clock.o cpu.o devices.o devices-common.o \
7obj-$(CONFIG_CACHE_L2X0) += cache-l2x0.o 7obj-$(CONFIG_CACHE_L2X0) += cache-l2x0.o
8obj-$(CONFIG_UX500_SOC_DB5500) += cpu-db5500.o dma-db5500.o 8obj-$(CONFIG_UX500_SOC_DB5500) += cpu-db5500.o dma-db5500.o
9obj-$(CONFIG_UX500_SOC_DB8500) += cpu-db8500.o devices-db8500.o 9obj-$(CONFIG_UX500_SOC_DB8500) += cpu-db8500.o devices-db8500.o
10obj-$(CONFIG_MACH_U8500) += board-mop500.o board-mop500-sdi.o \ 10obj-$(CONFIG_MACH_MOP500) += board-mop500.o board-mop500-sdi.o \
11 board-mop500-regulators.o \ 11 board-mop500-regulators.o \
12 board-mop500-uib.o board-mop500-stuib.o \ 12 board-mop500-uib.o board-mop500-stuib.o \
13 board-mop500-u8500uib.o \ 13 board-mop500-u8500uib.o \
@@ -15,7 +15,6 @@ obj-$(CONFIG_MACH_U8500) += board-mop500.o board-mop500-sdi.o \
15obj-$(CONFIG_MACH_U5500) += board-u5500.o board-u5500-sdi.o 15obj-$(CONFIG_MACH_U5500) += board-u5500.o board-u5500-sdi.o
16obj-$(CONFIG_SMP) += platsmp.o headsmp.o 16obj-$(CONFIG_SMP) += platsmp.o headsmp.o
17obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o 17obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
18obj-$(CONFIG_LOCAL_TIMERS) += localtimer.o
19obj-$(CONFIG_U5500_MODEM_IRQ) += modem-irq-db5500.o 18obj-$(CONFIG_U5500_MODEM_IRQ) += modem-irq-db5500.o
20obj-$(CONFIG_U5500_MBOX) += mbox-db5500.o 19obj-$(CONFIG_U5500_MBOX) += mbox-db5500.o
21 20
diff --git a/arch/arm/mach-ux500/Makefile.boot b/arch/arm/mach-ux500/Makefile.boot
index ff0a4b5b0a8..dd5cd00e255 100644
--- a/arch/arm/mach-ux500/Makefile.boot
+++ b/arch/arm/mach-ux500/Makefile.boot
@@ -2,3 +2,4 @@
2params_phys-y := 0x00000100 2params_phys-y := 0x00000100
3initrd_phys-y := 0x00800000 3initrd_phys-y := 0x00800000
4 4
5dtb-$(CONFIG_MACH_SNOWBALL) += snowball.dtb
diff --git a/arch/arm/mach-ux500/board-mop500-pins.c b/arch/arm/mach-ux500/board-mop500-pins.c
index 74bfcff2bdf..f5413dca532 100644
--- a/arch/arm/mach-ux500/board-mop500-pins.c
+++ b/arch/arm/mach-ux500/board-mop500-pins.c
@@ -6,6 +6,7 @@
6 6
7#include <linux/kernel.h> 7#include <linux/kernel.h>
8#include <linux/init.h> 8#include <linux/init.h>
9#include <linux/bug.h>
9 10
10#include <asm/mach-types.h> 11#include <asm/mach-types.h>
11#include <plat/pincfg.h> 12#include <plat/pincfg.h>
diff --git a/arch/arm/mach-ux500/board-mop500-regulators.c b/arch/arm/mach-ux500/board-mop500-regulators.c
index 2735d03996c..52426a42578 100644
--- a/arch/arm/mach-ux500/board-mop500-regulators.c
+++ b/arch/arm/mach-ux500/board-mop500-regulators.c
@@ -74,6 +74,26 @@ static struct regulator_consumer_supply ab8500_vtvout_consumers[] = {
74 REGULATOR_SUPPLY("vddadc", "ab8500-gpadc.0"), 74 REGULATOR_SUPPLY("vddadc", "ab8500-gpadc.0"),
75}; 75};
76 76
77static struct regulator_consumer_supply ab8500_vaud_consumers[] = {
78 /* AB8500 audio-codec main supply */
79 REGULATOR_SUPPLY("vaud", "ab8500-codec.0"),
80};
81
82static struct regulator_consumer_supply ab8500_vamic1_consumers[] = {
83 /* AB8500 audio-codec Mic1 supply */
84 REGULATOR_SUPPLY("vamic1", "ab8500-codec.0"),
85};
86
87static struct regulator_consumer_supply ab8500_vamic2_consumers[] = {
88 /* AB8500 audio-codec Mic2 supply */
89 REGULATOR_SUPPLY("vamic2", "ab8500-codec.0"),
90};
91
92static struct regulator_consumer_supply ab8500_vdmic_consumers[] = {
93 /* AB8500 audio-codec DMic supply */
94 REGULATOR_SUPPLY("vdmic", "ab8500-codec.0"),
95};
96
77static struct regulator_consumer_supply ab8500_vintcore_consumers[] = { 97static struct regulator_consumer_supply ab8500_vintcore_consumers[] = {
78 /* SoC core supply, no device */ 98 /* SoC core supply, no device */
79 REGULATOR_SUPPLY("v-intcore", NULL), 99 REGULATOR_SUPPLY("v-intcore", NULL),
@@ -323,6 +343,8 @@ struct regulator_init_data ab8500_regulators[AB8500_NUM_REGULATORS] = {
323 .name = "V-AUD", 343 .name = "V-AUD",
324 .valid_ops_mask = REGULATOR_CHANGE_STATUS, 344 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
325 }, 345 },
346 .num_consumer_supplies = ARRAY_SIZE(ab8500_vaud_consumers),
347 .consumer_supplies = ab8500_vaud_consumers,
326 }, 348 },
327 /* supply for v-anamic1 VAMic1-LDO */ 349 /* supply for v-anamic1 VAMic1-LDO */
328 [AB8500_LDO_ANAMIC1] = { 350 [AB8500_LDO_ANAMIC1] = {
@@ -330,6 +352,8 @@ struct regulator_init_data ab8500_regulators[AB8500_NUM_REGULATORS] = {
330 .name = "V-AMIC1", 352 .name = "V-AMIC1",
331 .valid_ops_mask = REGULATOR_CHANGE_STATUS, 353 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
332 }, 354 },
355 .num_consumer_supplies = ARRAY_SIZE(ab8500_vamic1_consumers),
356 .consumer_supplies = ab8500_vamic1_consumers,
333 }, 357 },
334 /* supply for v-amic2, VAMIC2 LDO, reuse constants for AMIC1 */ 358 /* supply for v-amic2, VAMIC2 LDO, reuse constants for AMIC1 */
335 [AB8500_LDO_ANAMIC2] = { 359 [AB8500_LDO_ANAMIC2] = {
@@ -337,6 +361,8 @@ struct regulator_init_data ab8500_regulators[AB8500_NUM_REGULATORS] = {
337 .name = "V-AMIC2", 361 .name = "V-AMIC2",
338 .valid_ops_mask = REGULATOR_CHANGE_STATUS, 362 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
339 }, 363 },
364 .num_consumer_supplies = ARRAY_SIZE(ab8500_vamic2_consumers),
365 .consumer_supplies = ab8500_vamic2_consumers,
340 }, 366 },
341 /* supply for v-dmic, VDMIC LDO */ 367 /* supply for v-dmic, VDMIC LDO */
342 [AB8500_LDO_DMIC] = { 368 [AB8500_LDO_DMIC] = {
@@ -344,6 +370,8 @@ struct regulator_init_data ab8500_regulators[AB8500_NUM_REGULATORS] = {
344 .name = "V-DMIC", 370 .name = "V-DMIC",
345 .valid_ops_mask = REGULATOR_CHANGE_STATUS, 371 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
346 }, 372 },
373 .num_consumer_supplies = ARRAY_SIZE(ab8500_vdmic_consumers),
374 .consumer_supplies = ab8500_vdmic_consumers,
347 }, 375 },
348 /* supply for v-intcore12, VINTCORE12 LDO */ 376 /* supply for v-intcore12, VINTCORE12 LDO */
349 [AB8500_LDO_INTCORE] = { 377 [AB8500_LDO_INTCORE] = {
diff --git a/arch/arm/mach-ux500/board-mop500-sdi.c b/arch/arm/mach-ux500/board-mop500-sdi.c
index 5dde4d4ebe8..920251cf834 100644
--- a/arch/arm/mach-ux500/board-mop500-sdi.c
+++ b/arch/arm/mach-ux500/board-mop500-sdi.c
@@ -31,21 +31,13 @@
31 * SDI 0 (MicroSD slot) 31 * SDI 0 (MicroSD slot)
32 */ 32 */
33 33
34/* MMCIPOWER bits */
35#define MCI_DATA2DIREN (1 << 2)
36#define MCI_CMDDIREN (1 << 3)
37#define MCI_DATA0DIREN (1 << 4)
38#define MCI_DATA31DIREN (1 << 5)
39#define MCI_FBCLKEN (1 << 7)
40
41/* GPIO pins used by the sdi0 level shifter */ 34/* GPIO pins used by the sdi0 level shifter */
42static int sdi0_en = -1; 35static int sdi0_en = -1;
43static int sdi0_vsel = -1; 36static int sdi0_vsel = -1;
44 37
45static u32 mop500_sdi0_vdd_handler(struct device *dev, unsigned int vdd, 38static int mop500_sdi0_ios_handler(struct device *dev, struct mmc_ios *ios)
46 unsigned char power_mode)
47{ 39{
48 switch (power_mode) { 40 switch (ios->power_mode) {
49 case MMC_POWER_UP: 41 case MMC_POWER_UP:
50 case MMC_POWER_ON: 42 case MMC_POWER_ON:
51 /* 43 /*
@@ -65,8 +57,7 @@ static u32 mop500_sdi0_vdd_handler(struct device *dev, unsigned int vdd,
65 break; 57 break;
66 } 58 }
67 59
68 return MCI_FBCLKEN | MCI_CMDDIREN | MCI_DATA0DIREN | 60 return 0;
69 MCI_DATA2DIREN | MCI_DATA31DIREN;
70} 61}
71 62
72#ifdef CONFIG_STE_DMA40 63#ifdef CONFIG_STE_DMA40
@@ -90,13 +81,17 @@ static struct stedma40_chan_cfg mop500_sdi0_dma_cfg_tx = {
90#endif 81#endif
91 82
92static struct mmci_platform_data mop500_sdi0_data = { 83static struct mmci_platform_data mop500_sdi0_data = {
93 .vdd_handler = mop500_sdi0_vdd_handler, 84 .ios_handler = mop500_sdi0_ios_handler,
94 .ocr_mask = MMC_VDD_29_30, 85 .ocr_mask = MMC_VDD_29_30,
95 .f_max = 50000000, 86 .f_max = 50000000,
96 .capabilities = MMC_CAP_4_BIT_DATA | 87 .capabilities = MMC_CAP_4_BIT_DATA |
97 MMC_CAP_SD_HIGHSPEED | 88 MMC_CAP_SD_HIGHSPEED |
98 MMC_CAP_MMC_HIGHSPEED, 89 MMC_CAP_MMC_HIGHSPEED,
99 .gpio_wp = -1, 90 .gpio_wp = -1,
91 .sigdir = MCI_ST_FBCLKEN |
92 MCI_ST_CMDDIREN |
93 MCI_ST_DATA0DIREN |
94 MCI_ST_DATA2DIREN,
100#ifdef CONFIG_STE_DMA40 95#ifdef CONFIG_STE_DMA40
101 .dma_filter = stedma40_filter, 96 .dma_filter = stedma40_filter,
102 .dma_rx_param = &mop500_sdi0_dma_cfg_rx, 97 .dma_rx_param = &mop500_sdi0_dma_cfg_rx,
@@ -104,7 +99,7 @@ static struct mmci_platform_data mop500_sdi0_data = {
104#endif 99#endif
105}; 100};
106 101
107static void sdi0_configure(void) 102static void sdi0_configure(struct device *parent)
108{ 103{
109 int ret; 104 int ret;
110 105
@@ -123,15 +118,15 @@ static void sdi0_configure(void)
123 gpio_direction_output(sdi0_en, 1); 118 gpio_direction_output(sdi0_en, 1);
124 119
125 /* Add the device, force v2 to subrevision 1 */ 120 /* Add the device, force v2 to subrevision 1 */
126 db8500_add_sdi0(&mop500_sdi0_data, U8500_SDI_V2_PERIPHID); 121 db8500_add_sdi0(parent, &mop500_sdi0_data, U8500_SDI_V2_PERIPHID);
127} 122}
128 123
129void mop500_sdi_tc35892_init(void) 124void mop500_sdi_tc35892_init(struct device *parent)
130{ 125{
131 mop500_sdi0_data.gpio_cd = GPIO_SDMMC_CD; 126 mop500_sdi0_data.gpio_cd = GPIO_SDMMC_CD;
132 sdi0_en = GPIO_SDMMC_EN; 127 sdi0_en = GPIO_SDMMC_EN;
133 sdi0_vsel = GPIO_SDMMC_1V8_3V_SEL; 128 sdi0_vsel = GPIO_SDMMC_1V8_3V_SEL;
134 sdi0_configure(); 129 sdi0_configure(parent);
135} 130}
136 131
137/* 132/*
@@ -246,12 +241,13 @@ static struct mmci_platform_data mop500_sdi4_data = {
246#endif 241#endif
247}; 242};
248 243
249void __init mop500_sdi_init(void) 244void __init mop500_sdi_init(struct device *parent)
250{ 245{
251 /* PoP:ed eMMC */ 246 /* PoP:ed eMMC */
252 db8500_add_sdi2(&mop500_sdi2_data, U8500_SDI_V2_PERIPHID); 247 db8500_add_sdi2(parent, &mop500_sdi2_data, U8500_SDI_V2_PERIPHID);
253 /* On-board eMMC */ 248 /* On-board eMMC */
254 db8500_add_sdi4(&mop500_sdi4_data, U8500_SDI_V2_PERIPHID); 249 db8500_add_sdi4(parent, &mop500_sdi4_data, U8500_SDI_V2_PERIPHID);
250
255 /* 251 /*
256 * On boards with the TC35892 GPIO expander, sdi0 will finally 252 * On boards with the TC35892 GPIO expander, sdi0 will finally
257 * be added when the TC35892 initializes and calls 253 * be added when the TC35892 initializes and calls
@@ -259,31 +255,31 @@ void __init mop500_sdi_init(void)
259 */ 255 */
260} 256}
261 257
262void __init snowball_sdi_init(void) 258void __init snowball_sdi_init(struct device *parent)
263{ 259{
264 /* On Snowball MMC_CAP_SD_HIGHSPEED isn't supported (Hardware issue?) */ 260 /* On Snowball MMC_CAP_SD_HIGHSPEED isn't supported (Hardware issue?) */
265 mop500_sdi0_data.capabilities &= ~MMC_CAP_SD_HIGHSPEED; 261 mop500_sdi0_data.capabilities &= ~MMC_CAP_SD_HIGHSPEED;
266 /* On-board eMMC */ 262 /* On-board eMMC */
267 db8500_add_sdi4(&mop500_sdi4_data, U8500_SDI_V2_PERIPHID); 263 db8500_add_sdi4(parent, &mop500_sdi4_data, U8500_SDI_V2_PERIPHID);
268 /* External Micro SD slot */ 264 /* External Micro SD slot */
269 mop500_sdi0_data.gpio_cd = SNOWBALL_SDMMC_CD_GPIO; 265 mop500_sdi0_data.gpio_cd = SNOWBALL_SDMMC_CD_GPIO;
270 mop500_sdi0_data.cd_invert = true; 266 mop500_sdi0_data.cd_invert = true;
271 sdi0_en = SNOWBALL_SDMMC_EN_GPIO; 267 sdi0_en = SNOWBALL_SDMMC_EN_GPIO;
272 sdi0_vsel = SNOWBALL_SDMMC_1V8_3V_GPIO; 268 sdi0_vsel = SNOWBALL_SDMMC_1V8_3V_GPIO;
273 sdi0_configure(); 269 sdi0_configure(parent);
274} 270}
275 271
276void __init hrefv60_sdi_init(void) 272void __init hrefv60_sdi_init(struct device *parent)
277{ 273{
278 /* PoP:ed eMMC */ 274 /* PoP:ed eMMC */
279 db8500_add_sdi2(&mop500_sdi2_data, U8500_SDI_V2_PERIPHID); 275 db8500_add_sdi2(parent, &mop500_sdi2_data, U8500_SDI_V2_PERIPHID);
280 /* On-board eMMC */ 276 /* On-board eMMC */
281 db8500_add_sdi4(&mop500_sdi4_data, U8500_SDI_V2_PERIPHID); 277 db8500_add_sdi4(parent, &mop500_sdi4_data, U8500_SDI_V2_PERIPHID);
282 /* External Micro SD slot */ 278 /* External Micro SD slot */
283 mop500_sdi0_data.gpio_cd = HREFV60_SDMMC_CD_GPIO; 279 mop500_sdi0_data.gpio_cd = HREFV60_SDMMC_CD_GPIO;
284 sdi0_en = HREFV60_SDMMC_EN_GPIO; 280 sdi0_en = HREFV60_SDMMC_EN_GPIO;
285 sdi0_vsel = HREFV60_SDMMC_1V8_3V_GPIO; 281 sdi0_vsel = HREFV60_SDMMC_1V8_3V_GPIO;
286 sdi0_configure(); 282 sdi0_configure(parent);
287 /* WLAN SDIO channel */ 283 /* WLAN SDIO channel */
288 db8500_add_sdi1(&mop500_sdi1_data, U8500_SDI_V2_PERIPHID); 284 db8500_add_sdi1(parent, &mop500_sdi1_data, U8500_SDI_V2_PERIPHID);
289} 285}
diff --git a/arch/arm/mach-ux500/board-mop500-u8500uib.c b/arch/arm/mach-ux500/board-mop500-u8500uib.c
index feb5744d98b..ead91c968ff 100644
--- a/arch/arm/mach-ux500/board-mop500-u8500uib.c
+++ b/arch/arm/mach-ux500/board-mop500-u8500uib.c
@@ -8,7 +8,6 @@
8#include <linux/kernel.h> 8#include <linux/kernel.h>
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/i2c.h> 10#include <linux/i2c.h>
11#include <linux/gpio.h>
12#include <linux/interrupt.h> 11#include <linux/interrupt.h>
13#include <linux/mfd/tc3589x.h> 12#include <linux/mfd/tc3589x.h>
14#include <linux/input/matrix_keypad.h> 13#include <linux/input/matrix_keypad.h>
diff --git a/arch/arm/mach-ux500/board-mop500.c b/arch/arm/mach-ux500/board-mop500.c
index 5c00712907d..77d03c1fbd0 100644
--- a/arch/arm/mach-ux500/board-mop500.c
+++ b/arch/arm/mach-ux500/board-mop500.c
@@ -30,6 +30,9 @@
30#include <linux/gpio_keys.h> 30#include <linux/gpio_keys.h>
31#include <linux/delay.h> 31#include <linux/delay.h>
32 32
33#include <linux/of.h>
34#include <linux/of_platform.h>
35
33#include <linux/leds.h> 36#include <linux/leds.h>
34#include <asm/mach-types.h> 37#include <asm/mach-types.h>
35#include <asm/mach/arch.h> 38#include <asm/mach/arch.h>
@@ -72,7 +75,7 @@ static struct platform_device snowball_led_dev = {
72}; 75};
73 76
74static struct ab8500_gpio_platform_data ab8500_gpio_pdata = { 77static struct ab8500_gpio_platform_data ab8500_gpio_pdata = {
75 .gpio_base = MOP500_AB8500_GPIO(0), 78 .gpio_base = MOP500_AB8500_PIN_GPIO(1),
76 .irq_base = MOP500_AB8500_VIR_GPIO_IRQ_BASE, 79 .irq_base = MOP500_AB8500_VIR_GPIO_IRQ_BASE,
77 /* config_reg is the initial configuration of ab8500 pins. 80 /* config_reg is the initial configuration of ab8500 pins.
78 * The pins can be configured as GPIO or alt functions based 81 * The pins can be configured as GPIO or alt functions based
@@ -226,7 +229,12 @@ static struct tps6105x_platform_data mop500_tps61052_data = {
226 229
227static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base) 230static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base)
228{ 231{
229 mop500_sdi_tc35892_init(); 232 struct device *parent = NULL;
233#if 0
234 /* FIXME: Is the sdi actually part of tc3589x? */
235 parent = tc3589x->dev;
236#endif
237 mop500_sdi_tc35892_init(parent);
230} 238}
231 239
232static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = { 240static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = {
@@ -353,12 +361,12 @@ U8500_I2C_CONTROLLER(1, 0xe, 1, 8, 100000, 200, I2C_FREQ_MODE_FAST);
353U8500_I2C_CONTROLLER(2, 0xe, 1, 8, 100000, 200, I2C_FREQ_MODE_FAST); 361U8500_I2C_CONTROLLER(2, 0xe, 1, 8, 100000, 200, I2C_FREQ_MODE_FAST);
354U8500_I2C_CONTROLLER(3, 0xe, 1, 8, 100000, 200, I2C_FREQ_MODE_FAST); 362U8500_I2C_CONTROLLER(3, 0xe, 1, 8, 100000, 200, I2C_FREQ_MODE_FAST);
355 363
356static void __init mop500_i2c_init(void) 364static void __init mop500_i2c_init(struct device *parent)
357{ 365{
358 db8500_add_i2c0(&u8500_i2c0_data); 366 db8500_add_i2c0(parent, &u8500_i2c0_data);
359 db8500_add_i2c1(&u8500_i2c1_data); 367 db8500_add_i2c1(parent, &u8500_i2c1_data);
360 db8500_add_i2c2(&u8500_i2c2_data); 368 db8500_add_i2c2(parent, &u8500_i2c2_data);
361 db8500_add_i2c3(&u8500_i2c3_data); 369 db8500_add_i2c3(parent, &u8500_i2c3_data);
362} 370}
363 371
364static struct gpio_keys_button mop500_gpio_keys[] = { 372static struct gpio_keys_button mop500_gpio_keys[] = {
@@ -435,7 +443,7 @@ static struct stedma40_chan_cfg ssp0_dma_cfg_tx = {
435}; 443};
436#endif 444#endif
437 445
438static struct pl022_ssp_controller ssp0_platform_data = { 446static struct pl022_ssp_controller ssp0_plat = {
439 .bus_id = 0, 447 .bus_id = 0,
440#ifdef CONFIG_STE_DMA40 448#ifdef CONFIG_STE_DMA40
441 .enable_dma = 1, 449 .enable_dma = 1,
@@ -451,9 +459,9 @@ static struct pl022_ssp_controller ssp0_platform_data = {
451 .num_chipselect = 5, 459 .num_chipselect = 5,
452}; 460};
453 461
454static void __init mop500_spi_init(void) 462static void __init mop500_spi_init(struct device *parent)
455{ 463{
456 db8500_add_ssp0(&ssp0_platform_data); 464 db8500_add_ssp0(parent, &ssp0_plat);
457} 465}
458 466
459#ifdef CONFIG_STE_DMA40 467#ifdef CONFIG_STE_DMA40
@@ -587,11 +595,11 @@ static struct amba_pl011_data uart2_plat = {
587#endif 595#endif
588}; 596};
589 597
590static void __init mop500_uart_init(void) 598static void __init mop500_uart_init(struct device *parent)
591{ 599{
592 db8500_add_uart0(&uart0_plat); 600 db8500_add_uart0(parent, &uart0_plat);
593 db8500_add_uart1(&uart1_plat); 601 db8500_add_uart1(parent, &uart1_plat);
594 db8500_add_uart2(&uart2_plat); 602 db8500_add_uart2(parent, &uart2_plat);
595} 603}
596 604
597static struct platform_device *snowball_platform_devs[] __initdata = { 605static struct platform_device *snowball_platform_devs[] __initdata = {
@@ -603,21 +611,27 @@ static struct platform_device *snowball_platform_devs[] __initdata = {
603 611
604static void __init mop500_init_machine(void) 612static void __init mop500_init_machine(void)
605{ 613{
614 struct device *parent = NULL;
606 int i2c0_devs; 615 int i2c0_devs;
616 int i;
607 617
608 mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR; 618 mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR;
609 619
610 u8500_init_devices(); 620 parent = u8500_init_devices();
611 621
612 mop500_pins_init(); 622 mop500_pins_init();
613 623
624 /* FIXME: parent of ab8500 should be prcmu */
625 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
626 mop500_platform_devs[i]->dev.parent = parent;
627
614 platform_add_devices(mop500_platform_devs, 628 platform_add_devices(mop500_platform_devs,
615 ARRAY_SIZE(mop500_platform_devs)); 629 ARRAY_SIZE(mop500_platform_devs));
616 630
617 mop500_i2c_init(); 631 mop500_i2c_init(parent);
618 mop500_sdi_init(); 632 mop500_sdi_init(parent);
619 mop500_spi_init(); 633 mop500_spi_init(parent);
620 mop500_uart_init(); 634 mop500_uart_init(parent);
621 635
622 i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices); 636 i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
623 637
@@ -631,19 +645,24 @@ static void __init mop500_init_machine(void)
631 645
632static void __init snowball_init_machine(void) 646static void __init snowball_init_machine(void)
633{ 647{
648 struct device *parent = NULL;
634 int i2c0_devs; 649 int i2c0_devs;
650 int i;
635 651
636 u8500_init_devices(); 652 parent = u8500_init_devices();
637 653
638 snowball_pins_init(); 654 snowball_pins_init();
639 655
656 for (i = 0; i < ARRAY_SIZE(snowball_platform_devs); i++)
657 snowball_platform_devs[i]->dev.parent = parent;
658
640 platform_add_devices(snowball_platform_devs, 659 platform_add_devices(snowball_platform_devs,
641 ARRAY_SIZE(snowball_platform_devs)); 660 ARRAY_SIZE(snowball_platform_devs));
642 661
643 mop500_i2c_init(); 662 mop500_i2c_init(parent);
644 snowball_sdi_init(); 663 snowball_sdi_init(parent);
645 mop500_spi_init(); 664 mop500_spi_init(parent);
646 mop500_uart_init(); 665 mop500_uart_init(parent);
647 666
648 i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices); 667 i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
649 i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs); 668 i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs);
@@ -656,7 +675,9 @@ static void __init snowball_init_machine(void)
656 675
657static void __init hrefv60_init_machine(void) 676static void __init hrefv60_init_machine(void)
658{ 677{
678 struct device *parent = NULL;
659 int i2c0_devs; 679 int i2c0_devs;
680 int i;
660 681
661 /* 682 /*
662 * The HREFv60 board removed a GPIO expander and routed 683 * The HREFv60 board removed a GPIO expander and routed
@@ -665,17 +686,20 @@ static void __init hrefv60_init_machine(void)
665 */ 686 */
666 mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO; 687 mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO;
667 688
668 u8500_init_devices(); 689 parent = u8500_init_devices();
669 690
670 hrefv60_pins_init(); 691 hrefv60_pins_init();
671 692
693 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
694 mop500_platform_devs[i]->dev.parent = parent;
695
672 platform_add_devices(mop500_platform_devs, 696 platform_add_devices(mop500_platform_devs,
673 ARRAY_SIZE(mop500_platform_devs)); 697 ARRAY_SIZE(mop500_platform_devs));
674 698
675 mop500_i2c_init(); 699 mop500_i2c_init(parent);
676 hrefv60_sdi_init(); 700 hrefv60_sdi_init(parent);
677 mop500_spi_init(); 701 mop500_spi_init(parent);
678 mop500_uart_init(); 702 mop500_uart_init(parent);
679 703
680 i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices); 704 i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
681 705
@@ -718,3 +742,94 @@ MACHINE_START(SNOWBALL, "Calao Systems Snowball platform")
718 .handle_irq = gic_handle_irq, 742 .handle_irq = gic_handle_irq,
719 .init_machine = snowball_init_machine, 743 .init_machine = snowball_init_machine,
720MACHINE_END 744MACHINE_END
745
746#ifdef CONFIG_MACH_UX500_DT
747
748struct of_dev_auxdata u8500_auxdata_lookup[] __initdata = {
749 OF_DEV_AUXDATA("arm,pl011", 0x80120000, "uart0", &uart0_plat),
750 OF_DEV_AUXDATA("arm,pl011", 0x80121000, "uart1", &uart1_plat),
751 OF_DEV_AUXDATA("arm,pl011", 0x80007000, "uart2", &uart2_plat),
752 OF_DEV_AUXDATA("arm,pl022", 0x80002000, "ssp0", &ssp0_plat),
753 {},
754};
755
756static const struct of_device_id u8500_soc_node[] = {
757 /* only create devices below soc node */
758 { .compatible = "stericsson,db8500", },
759 { },
760};
761
762static void __init u8500_init_machine(void)
763{
764 struct device *parent = NULL;
765 int i2c0_devs;
766 int i;
767
768 parent = u8500_init_devices();
769 i2c0_devs = ARRAY_SIZE(mop500_i2c0_devices);
770
771 for (i = 0; i < ARRAY_SIZE(mop500_platform_devs); i++)
772 mop500_platform_devs[i]->dev.parent = parent;
773 for (i = 0; i < ARRAY_SIZE(snowball_platform_devs); i++)
774 snowball_platform_devs[i]->dev.parent = parent;
775
776 /* automatically probe child nodes of db8500 device */
777 of_platform_populate(NULL, u8500_soc_node, u8500_auxdata_lookup, parent);
778
779 if (of_machine_is_compatible("st-ericsson,mop500")) {
780 mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR;
781 mop500_pins_init();
782
783 platform_add_devices(mop500_platform_devs,
784 ARRAY_SIZE(mop500_platform_devs));
785
786 mop500_sdi_init(parent);
787 } else if (of_machine_is_compatible("calaosystems,snowball-a9500")) {
788 snowball_pins_init();
789 platform_add_devices(snowball_platform_devs,
790 ARRAY_SIZE(snowball_platform_devs));
791
792 snowball_sdi_init(parent);
793 } else if (of_machine_is_compatible("st-ericsson,hrefv60+")) {
794 /*
795 * The HREFv60 board removed a GPIO expander and routed
796 * all these GPIO pins to the internal GPIO controller
797 * instead.
798 */
799 mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO;
800 i2c0_devs -= NUM_PRE_V60_I2C0_DEVICES;
801 hrefv60_pins_init();
802 platform_add_devices(mop500_platform_devs,
803 ARRAY_SIZE(mop500_platform_devs));
804
805 hrefv60_sdi_init(parent);
806 }
807 mop500_i2c_init(parent);
808
809 i2c_register_board_info(0, mop500_i2c0_devices, i2c0_devs);
810 i2c_register_board_info(2, mop500_i2c2_devices,
811 ARRAY_SIZE(mop500_i2c2_devices));
812
813 /* This board has full regulator constraints */
814 regulator_has_full_constraints();
815}
816
817static const char * u8500_dt_board_compat[] = {
818 "calaosystems,snowball-a9500",
819 "st-ericsson,hrefv60+",
820 "st-ericsson,u8500",
821 "st-ericsson,mop500",
822 NULL,
823};
824
825
826DT_MACHINE_START(U8500_DT, "ST-Ericsson U8500 platform (Device Tree Support)")
827 .map_io = u8500_map_io,
828 .init_irq = ux500_init_irq,
829 /* we re-use nomadik timer here */
830 .timer = &ux500_timer,
831 .handle_irq = gic_handle_irq,
832 .init_machine = u8500_init_machine,
833 .dt_compat = u8500_dt_board_compat,
834MACHINE_END
835#endif
diff --git a/arch/arm/mach-ux500/board-mop500.h b/arch/arm/mach-ux500/board-mop500.h
index f926d3db620..fdcfa8721bb 100644
--- a/arch/arm/mach-ux500/board-mop500.h
+++ b/arch/arm/mach-ux500/board-mop500.h
@@ -63,7 +63,7 @@
63 * because the AB8500 GPIO pins are enumbered starting from 1, so the value in 63 * because the AB8500 GPIO pins are enumbered starting from 1, so the value in
64 * parens matches the GPIO pin number in the data sheet. 64 * parens matches the GPIO pin number in the data sheet.
65 */ 65 */
66#define MOP500_AB8500_GPIO(x) (MOP500_EGPIO_END + (x) - 1) 66#define MOP500_AB8500_PIN_GPIO(x) (MOP500_EGPIO_END + (x) - 1)
67/*Snowball AB8500 GPIO */ 67/*Snowball AB8500 GPIO */
68#define SNOWBALL_VSMPS2_1V8_GPIO MOP500_AB8500_PIN_GPIO(1) /* SYSCLKREQ2/GPIO1 */ 68#define SNOWBALL_VSMPS2_1V8_GPIO MOP500_AB8500_PIN_GPIO(1) /* SYSCLKREQ2/GPIO1 */
69#define SNOWBALL_PM_GPIO1_GPIO MOP500_AB8500_PIN_GPIO(2) /* SYSCLKREQ3/GPIO2 */ 69#define SNOWBALL_PM_GPIO1_GPIO MOP500_AB8500_PIN_GPIO(2) /* SYSCLKREQ3/GPIO2 */
@@ -75,10 +75,10 @@
75 75
76struct i2c_board_info; 76struct i2c_board_info;
77 77
78extern void mop500_sdi_init(void); 78extern void mop500_sdi_init(struct device *parent);
79extern void snowball_sdi_init(void); 79extern void snowball_sdi_init(struct device *parent);
80extern void hrefv60_sdi_init(void); 80extern void hrefv60_sdi_init(struct device *parent);
81extern void mop500_sdi_tc35892_init(void); 81extern void mop500_sdi_tc35892_init(struct device *parent);
82void __init mop500_u8500uib_init(void); 82void __init mop500_u8500uib_init(void);
83void __init mop500_stuib_init(void); 83void __init mop500_stuib_init(void);
84void __init mop500_pins_init(void); 84void __init mop500_pins_init(void);
diff --git a/arch/arm/mach-ux500/board-u5500-sdi.c b/arch/arm/mach-ux500/board-u5500-sdi.c
index 63c3f8058ff..836112eedde 100644
--- a/arch/arm/mach-ux500/board-u5500-sdi.c
+++ b/arch/arm/mach-ux500/board-u5500-sdi.c
@@ -66,9 +66,9 @@ static struct mmci_platform_data u5500_sdi0_data = {
66#endif 66#endif
67}; 67};
68 68
69void __init u5500_sdi_init(void) 69void __init u5500_sdi_init(struct device *parent)
70{ 70{
71 nmk_config_pins(u5500_sdi_pins, ARRAY_SIZE(u5500_sdi_pins)); 71 nmk_config_pins(u5500_sdi_pins, ARRAY_SIZE(u5500_sdi_pins));
72 72
73 db5500_add_sdi0(&u5500_sdi0_data); 73 db5500_add_sdi0(parent, &u5500_sdi0_data);
74} 74}
diff --git a/arch/arm/mach-ux500/board-u5500.c b/arch/arm/mach-ux500/board-u5500.c
index 9de9e9c4dbb..0ff4be72a80 100644
--- a/arch/arm/mach-ux500/board-u5500.c
+++ b/arch/arm/mach-ux500/board-u5500.c
@@ -97,9 +97,9 @@ static struct i2c_board_info __initdata u5500_i2c2_devices[] = {
97 }, 97 },
98}; 98};
99 99
100static void __init u5500_i2c_init(void) 100static void __init u5500_i2c_init(struct device *parent)
101{ 101{
102 db5500_add_i2c2(&u5500_i2c2_data); 102 db5500_add_i2c2(parent, &u5500_i2c2_data);
103 i2c_register_board_info(2, ARRAY_AND_SIZE(u5500_i2c2_devices)); 103 i2c_register_board_info(2, ARRAY_AND_SIZE(u5500_i2c2_devices));
104} 104}
105 105
@@ -126,20 +126,27 @@ static struct platform_device *u5500_platform_devices[] __initdata = {
126 &ab5500_device, 126 &ab5500_device,
127}; 127};
128 128
129static void __init u5500_uart_init(void) 129static void __init u5500_uart_init(struct device *parent)
130{ 130{
131 db5500_add_uart0(NULL); 131 db5500_add_uart0(parent, NULL);
132 db5500_add_uart1(NULL); 132 db5500_add_uart1(parent, NULL);
133 db5500_add_uart2(NULL); 133 db5500_add_uart2(parent, NULL);
134} 134}
135 135
136static void __init u5500_init_machine(void) 136static void __init u5500_init_machine(void)
137{ 137{
138 u5500_init_devices(); 138 struct device *parent = NULL;
139 int i;
140
141 parent = u5500_init_devices();
139 nmk_config_pins(u5500_pins, ARRAY_SIZE(u5500_pins)); 142 nmk_config_pins(u5500_pins, ARRAY_SIZE(u5500_pins));
140 u5500_i2c_init(); 143
141 u5500_sdi_init(); 144 u5500_i2c_init(parent);
142 u5500_uart_init(); 145 u5500_sdi_init(parent);
146 u5500_uart_init(parent);
147
148 for (i = 0; i < ARRAY_SIZE(u5500_platform_devices); i++)
149 u5500_platform_devices[i]->dev.parent = parent;
143 150
144 platform_add_devices(u5500_platform_devices, 151 platform_add_devices(u5500_platform_devices,
145 ARRAY_SIZE(u5500_platform_devices)); 152 ARRAY_SIZE(u5500_platform_devices));
diff --git a/arch/arm/mach-ux500/cache-l2x0.c b/arch/arm/mach-ux500/cache-l2x0.c
index da5569d83d5..77a75ed0df6 100644
--- a/arch/arm/mach-ux500/cache-l2x0.c
+++ b/arch/arm/mach-ux500/cache-l2x0.c
@@ -5,6 +5,8 @@
5 */ 5 */
6 6
7#include <linux/io.h> 7#include <linux/io.h>
8#include <linux/of.h>
9
8#include <asm/cacheflush.h> 10#include <asm/cacheflush.h>
9#include <asm/hardware/cache-l2x0.h> 11#include <asm/hardware/cache-l2x0.h>
10#include <mach/hardware.h> 12#include <mach/hardware.h>
@@ -45,7 +47,10 @@ static int __init ux500_l2x0_init(void)
45 ux500_l2x0_unlock(); 47 ux500_l2x0_unlock();
46 48
47 /* 64KB way size, 8 way associativity, force WA */ 49 /* 64KB way size, 8 way associativity, force WA */
48 l2x0_init(l2x0_base, 0x3e060000, 0xc0000fff); 50 if (of_have_populated_dt())
51 l2x0_of_init(0x3e060000, 0xc0000fff);
52 else
53 l2x0_init(l2x0_base, 0x3e060000, 0xc0000fff);
49 54
50 /* 55 /*
51 * We can't disable l2 as we are in non secure mode, currently 56 * We can't disable l2 as we are in non secure mode, currently
diff --git a/arch/arm/mach-ux500/clock.c b/arch/arm/mach-ux500/clock.c
index 73790753700..ec35f0aa566 100644
--- a/arch/arm/mach-ux500/clock.c
+++ b/arch/arm/mach-ux500/clock.c
@@ -223,6 +223,13 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
223} 223}
224EXPORT_SYMBOL(clk_set_rate); 224EXPORT_SYMBOL(clk_set_rate);
225 225
226int clk_set_parent(struct clk *clk, struct clk *parent)
227{
228 /*TODO*/
229 return -ENOSYS;
230}
231EXPORT_SYMBOL(clk_set_parent);
232
226static void clk_prcmu_enable(struct clk *clk) 233static void clk_prcmu_enable(struct clk *clk)
227{ 234{
228 void __iomem *cg_set_reg = __io_address(U8500_PRCMU_BASE) 235 void __iomem *cg_set_reg = __io_address(U8500_PRCMU_BASE)
diff --git a/arch/arm/mach-ux500/clock.h b/arch/arm/mach-ux500/clock.h
index 07449070522..d776ada08db 100644
--- a/arch/arm/mach-ux500/clock.h
+++ b/arch/arm/mach-ux500/clock.h
@@ -21,6 +21,7 @@ struct clkops {
21 void (*enable) (struct clk *); 21 void (*enable) (struct clk *);
22 void (*disable) (struct clk *); 22 void (*disable) (struct clk *);
23 unsigned long (*get_rate) (struct clk *); 23 unsigned long (*get_rate) (struct clk *);
24 int (*set_parent)(struct clk *, struct clk *);
24}; 25};
25 26
26/** 27/**
diff --git a/arch/arm/mach-ux500/cpu-db5500.c b/arch/arm/mach-ux500/cpu-db5500.c
index 18aa5c05c69..bca47f32082 100644
--- a/arch/arm/mach-ux500/cpu-db5500.c
+++ b/arch/arm/mach-ux500/cpu-db5500.c
@@ -147,13 +147,13 @@ static resource_size_t __initdata db5500_gpio_base[] = {
147 U5500_GPIOBANK7_BASE, 147 U5500_GPIOBANK7_BASE,
148}; 148};
149 149
150static void __init db5500_add_gpios(void) 150static void __init db5500_add_gpios(struct device *parent)
151{ 151{
152 struct nmk_gpio_platform_data pdata = { 152 struct nmk_gpio_platform_data pdata = {
153 /* No custom data yet */ 153 /* No custom data yet */
154 }; 154 };
155 155
156 dbx500_add_gpios(ARRAY_AND_SIZE(db5500_gpio_base), 156 dbx500_add_gpios(parent, ARRAY_AND_SIZE(db5500_gpio_base),
157 IRQ_DB5500_GPIO0, &pdata); 157 IRQ_DB5500_GPIO0, &pdata);
158} 158}
159 159
@@ -212,14 +212,36 @@ static int usb_db5500_tx_dma_cfg[] = {
212 DB5500_DMA_DEV38_USB_OTG_OEP_8 212 DB5500_DMA_DEV38_USB_OTG_OEP_8
213}; 213};
214 214
215void __init u5500_init_devices(void) 215static const char *db5500_read_soc_id(void)
216{ 216{
217 db5500_add_gpios(); 217 return kasprintf(GFP_KERNEL, "u5500 currently unsupported\n");
218}
219
220static struct device * __init db5500_soc_device_init(void)
221{
222 const char *soc_id = db5500_read_soc_id();
223
224 return ux500_soc_device_init(soc_id);
225}
226
227struct device * __init u5500_init_devices(void)
228{
229 struct device *parent;
230 int i;
231
232 parent = db5500_soc_device_init();
233
234 db5500_add_gpios(parent);
218 db5500_pmu_init(); 235 db5500_pmu_init();
219 db5500_dma_init(); 236 db5500_dma_init(parent);
220 db5500_add_rtc(); 237 db5500_add_rtc(parent);
221 db5500_add_usb(usb_db5500_rx_dma_cfg, usb_db5500_tx_dma_cfg); 238 db5500_add_usb(parent, usb_db5500_rx_dma_cfg, usb_db5500_tx_dma_cfg);
239
240 for (i = 0; i < ARRAY_SIZE(db5500_platform_devs); i++)
241 db5500_platform_devs[i]->dev.parent = parent;
222 242
223 platform_add_devices(db5500_platform_devs, 243 platform_add_devices(db5500_platform_devs,
224 ARRAY_SIZE(db5500_platform_devs)); 244 ARRAY_SIZE(db5500_platform_devs));
245
246 return parent;
225} 247}
diff --git a/arch/arm/mach-ux500/cpu-db8500.c b/arch/arm/mach-ux500/cpu-db8500.c
index 7176ee7491a..9bd8163896c 100644
--- a/arch/arm/mach-ux500/cpu-db8500.c
+++ b/arch/arm/mach-ux500/cpu-db8500.c
@@ -24,6 +24,7 @@
24#include <mach/setup.h> 24#include <mach/setup.h>
25#include <mach/devices.h> 25#include <mach/devices.h>
26#include <mach/usb.h> 26#include <mach/usb.h>
27#include <mach/db8500-regs.h>
27 28
28#include "devices-db8500.h" 29#include "devices-db8500.h"
29#include "ste-dma40-db8500.h" 30#include "ste-dma40-db8500.h"
@@ -132,13 +133,13 @@ static resource_size_t __initdata db8500_gpio_base[] = {
132 U8500_GPIOBANK8_BASE, 133 U8500_GPIOBANK8_BASE,
133}; 134};
134 135
135static void __init db8500_add_gpios(void) 136static void __init db8500_add_gpios(struct device *parent)
136{ 137{
137 struct nmk_gpio_platform_data pdata = { 138 struct nmk_gpio_platform_data pdata = {
138 .supports_sleepmode = true, 139 .supports_sleepmode = true,
139 }; 140 };
140 141
141 dbx500_add_gpios(ARRAY_AND_SIZE(db8500_gpio_base), 142 dbx500_add_gpios(parent, ARRAY_AND_SIZE(db8500_gpio_base),
142 IRQ_DB8500_GPIO0, &pdata); 143 IRQ_DB8500_GPIO0, &pdata);
143} 144}
144 145
@@ -164,17 +165,44 @@ static int usb_db8500_tx_dma_cfg[] = {
164 DB8500_DMA_DEV39_USB_OTG_OEP_8 165 DB8500_DMA_DEV39_USB_OTG_OEP_8
165}; 166};
166 167
168static const char *db8500_read_soc_id(void)
169{
170 void __iomem *uid = __io_address(U8500_BB_UID_BASE);
171
172 return kasprintf(GFP_KERNEL, "%08x%08x%08x%08x%08x",
173 readl((u32 *)uid+1),
174 readl((u32 *)uid+1), readl((u32 *)uid+2),
175 readl((u32 *)uid+3), readl((u32 *)uid+4));
176}
177
178static struct device * __init db8500_soc_device_init(void)
179{
180 const char *soc_id = db8500_read_soc_id();
181
182 return ux500_soc_device_init(soc_id);
183}
184
167/* 185/*
168 * This function is called from the board init 186 * This function is called from the board init
169 */ 187 */
170void __init u8500_init_devices(void) 188struct device * __init u8500_init_devices(void)
171{ 189{
172 db8500_add_rtc(); 190 struct device *parent;
173 db8500_add_gpios(); 191 int i;
174 db8500_add_usb(usb_db8500_rx_dma_cfg, usb_db8500_tx_dma_cfg); 192
193 parent = db8500_soc_device_init();
194
195 db8500_add_rtc(parent);
196 db8500_add_gpios(parent);
197 db8500_add_usb(parent, usb_db8500_rx_dma_cfg, usb_db8500_tx_dma_cfg);
198
199 platform_device_register_data(parent,
200 "cpufreq-u8500", -1, NULL, 0);
201
202 for (i = 0; i < ARRAY_SIZE(platform_devs); i++)
203 platform_devs[i]->dev.parent = parent;
175 204
176 platform_device_register_simple("cpufreq-u8500", -1, NULL, 0);
177 platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs)); 205 platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
178 206
179 return ; 207 return parent;
180} 208}
diff --git a/arch/arm/mach-ux500/cpu.c b/arch/arm/mach-ux500/cpu.c
index f4185749437..d11f3892a27 100644
--- a/arch/arm/mach-ux500/cpu.c
+++ b/arch/arm/mach-ux500/cpu.c
@@ -2,6 +2,7 @@
2 * Copyright (C) ST-Ericsson SA 2010 2 * Copyright (C) ST-Ericsson SA 2010
3 * 3 *
4 * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson 4 * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson
5 * Author: Lee Jones <lee.jones@linaro.org> for ST-Ericsson
5 * License terms: GNU General Public License (GPL) version 2 6 * License terms: GNU General Public License (GPL) version 2
6 */ 7 */
7 8
@@ -11,10 +12,15 @@
11#include <linux/mfd/db8500-prcmu.h> 12#include <linux/mfd/db8500-prcmu.h>
12#include <linux/mfd/db5500-prcmu.h> 13#include <linux/mfd/db5500-prcmu.h>
13#include <linux/clksrc-dbx500-prcmu.h> 14#include <linux/clksrc-dbx500-prcmu.h>
15#include <linux/sys_soc.h>
16#include <linux/err.h>
17#include <linux/slab.h>
18#include <linux/stat.h>
19#include <linux/of.h>
20#include <linux/of_irq.h>
14 21
15#include <asm/hardware/gic.h> 22#include <asm/hardware/gic.h>
16#include <asm/mach/map.h> 23#include <asm/mach/map.h>
17#include <asm/localtimer.h>
18 24
19#include <mach/hardware.h> 25#include <mach/hardware.h>
20#include <mach/setup.h> 26#include <mach/setup.h>
@@ -24,6 +30,11 @@
24 30
25void __iomem *_PRCMU_BASE; 31void __iomem *_PRCMU_BASE;
26 32
33static const struct of_device_id ux500_dt_irq_match[] = {
34 { .compatible = "arm,cortex-a9-gic", .data = gic_of_init, },
35 {},
36};
37
27void __init ux500_init_irq(void) 38void __init ux500_init_irq(void)
28{ 39{
29 void __iomem *dist_base; 40 void __iomem *dist_base;
@@ -38,7 +49,12 @@ void __init ux500_init_irq(void)
38 } else 49 } else
39 ux500_unknown_soc(); 50 ux500_unknown_soc();
40 51
41 gic_init(0, 29, dist_base, cpu_base); 52#ifdef CONFIG_OF
53 if (of_have_populated_dt())
54 of_irq_init(ux500_dt_irq_match);
55 else
56#endif
57 gic_init(0, 29, dist_base, cpu_base);
42 58
43 /* 59 /*
44 * Init clocks here so that they are available for system timer 60 * Init clocks here so that they are available for system timer
@@ -50,3 +66,73 @@ void __init ux500_init_irq(void)
50 db8500_prcmu_early_init(); 66 db8500_prcmu_early_init();
51 clk_init(); 67 clk_init();
52} 68}
69
70static const char * __init ux500_get_machine(void)
71{
72 return kasprintf(GFP_KERNEL, "DB%4x", dbx500_partnumber());
73}
74
75static const char * __init ux500_get_family(void)
76{
77 return kasprintf(GFP_KERNEL, "ux500");
78}
79
80static const char * __init ux500_get_revision(void)
81{
82 unsigned int rev = dbx500_revision();
83
84 if (rev == 0x01)
85 return kasprintf(GFP_KERNEL, "%s", "ED");
86 else if (rev >= 0xA0)
87 return kasprintf(GFP_KERNEL, "%d.%d",
88 (rev >> 4) - 0xA + 1, rev & 0xf);
89
90 return kasprintf(GFP_KERNEL, "%s", "Unknown");
91}
92
93static ssize_t ux500_get_process(struct device *dev,
94 struct device_attribute *attr,
95 char *buf)
96{
97 if (dbx500_id.process == 0x00)
98 return sprintf(buf, "Standard\n");
99
100 return sprintf(buf, "%02xnm\n", dbx500_id.process);
101}
102
103static void __init soc_info_populate(struct soc_device_attribute *soc_dev_attr,
104 const char *soc_id)
105{
106 soc_dev_attr->soc_id = soc_id;
107 soc_dev_attr->machine = ux500_get_machine();
108 soc_dev_attr->family = ux500_get_family();
109 soc_dev_attr->revision = ux500_get_revision();
110}
111
112struct device_attribute ux500_soc_attr =
113 __ATTR(process, S_IRUGO, ux500_get_process, NULL);
114
115struct device * __init ux500_soc_device_init(const char *soc_id)
116{
117 struct device *parent;
118 struct soc_device *soc_dev;
119 struct soc_device_attribute *soc_dev_attr;
120
121 soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
122 if (!soc_dev_attr)
123 return ERR_PTR(-ENOMEM);
124
125 soc_info_populate(soc_dev_attr, soc_id);
126
127 soc_dev = soc_device_register(soc_dev_attr);
128 if (IS_ERR_OR_NULL(soc_dev)) {
129 kfree(soc_dev_attr);
130 return NULL;
131 }
132
133 parent = soc_device_to_device(soc_dev);
134 if (!IS_ERR_OR_NULL(parent))
135 device_create_file(parent, &ux500_soc_attr);
136
137 return parent;
138}
diff --git a/arch/arm/mach-ux500/devices-common.c b/arch/arm/mach-ux500/devices-common.c
index c563e5418d8..c5312a4b49f 100644
--- a/arch/arm/mach-ux500/devices-common.c
+++ b/arch/arm/mach-ux500/devices-common.c
@@ -20,35 +20,31 @@
20#include "devices-common.h" 20#include "devices-common.h"
21 21
22struct amba_device * 22struct amba_device *
23dbx500_add_amba_device(const char *name, resource_size_t base, 23dbx500_add_amba_device(struct device *parent, const char *name,
24 int irq, void *pdata, unsigned int periphid) 24 resource_size_t base, int irq, void *pdata,
25 unsigned int periphid)
25{ 26{
26 struct amba_device *dev; 27 struct amba_device *dev;
27 int ret; 28 int ret;
28 29
29 dev = kzalloc(sizeof *dev, GFP_KERNEL); 30 dev = amba_device_alloc(name, base, SZ_4K);
30 if (!dev) 31 if (!dev)
31 return ERR_PTR(-ENOMEM); 32 return ERR_PTR(-ENOMEM);
32 33
33 dev->dev.init_name = name;
34
35 dev->res.start = base;
36 dev->res.end = base + SZ_4K - 1;
37 dev->res.flags = IORESOURCE_MEM;
38
39 dev->dma_mask = DMA_BIT_MASK(32); 34 dev->dma_mask = DMA_BIT_MASK(32);
40 dev->dev.coherent_dma_mask = DMA_BIT_MASK(32); 35 dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
41 36
42 dev->irq[0] = irq; 37 dev->irq[0] = irq;
43 dev->irq[1] = NO_IRQ;
44 38
45 dev->periphid = periphid; 39 dev->periphid = periphid;
46 40
47 dev->dev.platform_data = pdata; 41 dev->dev.platform_data = pdata;
48 42
49 ret = amba_device_register(dev, &iomem_resource); 43 dev->dev.parent = parent;
44
45 ret = amba_device_add(dev, &iomem_resource);
50 if (ret) { 46 if (ret) {
51 kfree(dev); 47 amba_device_put(dev);
52 return ERR_PTR(ret); 48 return ERR_PTR(ret);
53 } 49 }
54 50
@@ -56,60 +52,7 @@ dbx500_add_amba_device(const char *name, resource_size_t base,
56} 52}
57 53
58static struct platform_device * 54static struct platform_device *
59dbx500_add_platform_device(const char *name, int id, void *pdata, 55dbx500_add_gpio(struct device *parent, int id, resource_size_t addr, int irq,
60 struct resource *res, int resnum)
61{
62 struct platform_device *dev;
63 int ret;
64
65 dev = platform_device_alloc(name, id);
66 if (!dev)
67 return ERR_PTR(-ENOMEM);
68
69 dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
70 dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
71
72 ret = platform_device_add_resources(dev, res, resnum);
73 if (ret)
74 goto out_free;
75
76 dev->dev.platform_data = pdata;
77
78 ret = platform_device_add(dev);
79 if (ret)
80 goto out_free;
81
82 return dev;
83
84out_free:
85 platform_device_put(dev);
86 return ERR_PTR(ret);
87}
88
89struct platform_device *
90dbx500_add_platform_device_4k1irq(const char *name, int id,
91 resource_size_t base,
92 int irq, void *pdata)
93{
94 struct resource resources[] = {
95 [0] = {
96 .start = base,
97 .end = base + SZ_4K - 1,
98 .flags = IORESOURCE_MEM,
99 },
100 [1] = {
101 .start = irq,
102 .end = irq,
103 .flags = IORESOURCE_IRQ,
104 }
105 };
106
107 return dbx500_add_platform_device(name, id, pdata, resources,
108 ARRAY_SIZE(resources));
109}
110
111static struct platform_device *
112dbx500_add_gpio(int id, resource_size_t addr, int irq,
113 struct nmk_gpio_platform_data *pdata) 56 struct nmk_gpio_platform_data *pdata)
114{ 57{
115 struct resource resources[] = { 58 struct resource resources[] = {
@@ -125,13 +68,18 @@ dbx500_add_gpio(int id, resource_size_t addr, int irq,
125 } 68 }
126 }; 69 };
127 70
128 return platform_device_register_resndata(NULL, "gpio", id, 71 return platform_device_register_resndata(
129 resources, ARRAY_SIZE(resources), 72 parent,
130 pdata, sizeof(*pdata)); 73 "gpio",
74 id,
75 resources,
76 ARRAY_SIZE(resources),
77 pdata,
78 sizeof(*pdata));
131} 79}
132 80
133void dbx500_add_gpios(resource_size_t *base, int num, int irq, 81void dbx500_add_gpios(struct device *parent, resource_size_t *base, int num,
134 struct nmk_gpio_platform_data *pdata) 82 int irq, struct nmk_gpio_platform_data *pdata)
135{ 83{
136 int first = 0; 84 int first = 0;
137 int i; 85 int i;
@@ -141,6 +89,6 @@ void dbx500_add_gpios(resource_size_t *base, int num, int irq,
141 pdata->first_irq = NOMADIK_GPIO_TO_IRQ(first); 89 pdata->first_irq = NOMADIK_GPIO_TO_IRQ(first);
142 pdata->num_gpio = 32; 90 pdata->num_gpio = 32;
143 91
144 dbx500_add_gpio(i, base[i], irq, pdata); 92 dbx500_add_gpio(parent, i, base[i], irq, pdata);
145 } 93 }
146} 94}
diff --git a/arch/arm/mach-ux500/devices-common.h b/arch/arm/mach-ux500/devices-common.h
index 7825705033b..39c74ec82ad 100644
--- a/arch/arm/mach-ux500/devices-common.h
+++ b/arch/arm/mach-ux500/devices-common.h
@@ -8,80 +8,89 @@
8#ifndef __DEVICES_COMMON_H 8#ifndef __DEVICES_COMMON_H
9#define __DEVICES_COMMON_H 9#define __DEVICES_COMMON_H
10 10
11extern struct amba_device * 11#include <linux/platform_device.h>
12dbx500_add_amba_device(const char *name, resource_size_t base, 12#include <linux/dma-mapping.h>
13 int irq, void *pdata, unsigned int periphid); 13#include <linux/sys_soc.h>
14#include <plat/i2c.h>
14 15
15extern struct platform_device * 16extern struct amba_device *
16dbx500_add_platform_device_4k1irq(const char *name, int id, 17dbx500_add_amba_device(struct device *parent, const char *name,
17 resource_size_t base, 18 resource_size_t base, int irq, void *pdata,
18 int irq, void *pdata); 19 unsigned int periphid);
19 20
20struct spi_master_cntlr; 21struct spi_master_cntlr;
21 22
22static inline struct amba_device * 23static inline struct amba_device *
23dbx500_add_msp_spi(const char *name, resource_size_t base, int irq, 24dbx500_add_msp_spi(struct device *parent, const char *name,
25 resource_size_t base, int irq,
24 struct spi_master_cntlr *pdata) 26 struct spi_master_cntlr *pdata)
25{ 27{
26 return dbx500_add_amba_device(name, base, irq, pdata, 0); 28 return dbx500_add_amba_device(parent, name, base, irq,
29 pdata, 0);
27} 30}
28 31
29static inline struct amba_device * 32static inline struct amba_device *
30dbx500_add_spi(const char *name, resource_size_t base, int irq, 33dbx500_add_spi(struct device *parent, const char *name, resource_size_t base,
31 struct spi_master_cntlr *pdata, 34 int irq, struct spi_master_cntlr *pdata,
32 u32 periphid) 35 u32 periphid)
33{ 36{
34 return dbx500_add_amba_device(name, base, irq, pdata, periphid); 37 return dbx500_add_amba_device(parent, name, base, irq,
38 pdata, periphid);
35} 39}
36 40
37struct mmci_platform_data; 41struct mmci_platform_data;
38 42
39static inline struct amba_device * 43static inline struct amba_device *
40dbx500_add_sdi(const char *name, resource_size_t base, int irq, 44dbx500_add_sdi(struct device *parent, const char *name, resource_size_t base,
41 struct mmci_platform_data *pdata, 45 int irq, struct mmci_platform_data *pdata, u32 periphid)
42 u32 periphid)
43{ 46{
44 return dbx500_add_amba_device(name, base, irq, pdata, periphid); 47 return dbx500_add_amba_device(parent, name, base, irq,
48 pdata, periphid);
45} 49}
46 50
47struct amba_pl011_data; 51struct amba_pl011_data;
48 52
49static inline struct amba_device * 53static inline struct amba_device *
50dbx500_add_uart(const char *name, resource_size_t base, int irq, 54dbx500_add_uart(struct device *parent, const char *name, resource_size_t base,
51 struct amba_pl011_data *pdata) 55 int irq, struct amba_pl011_data *pdata)
52{ 56{
53 return dbx500_add_amba_device(name, base, irq, pdata, 0); 57 return dbx500_add_amba_device(parent, name, base, irq, pdata, 0);
54} 58}
55 59
56struct nmk_i2c_controller; 60struct nmk_i2c_controller;
57 61
58static inline struct platform_device * 62static inline struct platform_device *
59dbx500_add_i2c(int id, resource_size_t base, int irq, 63dbx500_add_i2c(struct device *parent, int id, resource_size_t base, int irq,
60 struct nmk_i2c_controller *pdata) 64 struct nmk_i2c_controller *data)
61{
62 return dbx500_add_platform_device_4k1irq("nmk-i2c", id, base, irq,
63 pdata);
64}
65
66struct msp_i2s_platform_data;
67
68static inline struct platform_device *
69dbx500_add_msp_i2s(int id, resource_size_t base, int irq,
70 struct msp_i2s_platform_data *pdata)
71{ 65{
72 return dbx500_add_platform_device_4k1irq("MSP_I2S", id, base, irq, 66 struct resource res[] = {
73 pdata); 67 DEFINE_RES_MEM(base, SZ_4K),
68 DEFINE_RES_IRQ(irq),
69 };
70
71 struct platform_device_info pdevinfo = {
72 .parent = parent,
73 .name = "nmk-i2c",
74 .id = id,
75 .res = res,
76 .num_res = ARRAY_SIZE(res),
77 .data = data,
78 .size_data = sizeof(*data),
79 .dma_mask = DMA_BIT_MASK(32),
80 };
81
82 return platform_device_register_full(&pdevinfo);
74} 83}
75 84
76static inline struct amba_device * 85static inline struct amba_device *
77dbx500_add_rtc(resource_size_t base, int irq) 86dbx500_add_rtc(struct device *parent, resource_size_t base, int irq)
78{ 87{
79 return dbx500_add_amba_device("rtc-pl031", base, irq, NULL, 0); 88 return dbx500_add_amba_device(parent, "rtc-pl031", base, irq, NULL, 0);
80} 89}
81 90
82struct nmk_gpio_platform_data; 91struct nmk_gpio_platform_data;
83 92
84void dbx500_add_gpios(resource_size_t *base, int num, int irq, 93void dbx500_add_gpios(struct device *parent, resource_size_t *base, int num,
85 struct nmk_gpio_platform_data *pdata); 94 int irq, struct nmk_gpio_platform_data *pdata);
86 95
87#endif 96#endif
diff --git a/arch/arm/mach-ux500/devices-db5500.h b/arch/arm/mach-ux500/devices-db5500.h
index 0c4bccd02b9..e70955502c3 100644
--- a/arch/arm/mach-ux500/devices-db5500.h
+++ b/arch/arm/mach-ux500/devices-db5500.h
@@ -10,70 +10,90 @@
10 10
11#include "devices-common.h" 11#include "devices-common.h"
12 12
13#define db5500_add_i2c1(pdata) \ 13#define db5500_add_i2c1(parent, pdata) \
14 dbx500_add_i2c(1, U5500_I2C1_BASE, IRQ_DB5500_I2C1, pdata) 14 dbx500_add_i2c(parent, 1, U5500_I2C1_BASE, IRQ_DB5500_I2C1, pdata)
15#define db5500_add_i2c2(pdata) \ 15#define db5500_add_i2c2(parent, pdata) \
16 dbx500_add_i2c(2, U5500_I2C2_BASE, IRQ_DB5500_I2C2, pdata) 16 dbx500_add_i2c(parent, 2, U5500_I2C2_BASE, IRQ_DB5500_I2C2, pdata)
17#define db5500_add_i2c3(pdata) \ 17#define db5500_add_i2c3(parent, pdata) \
18 dbx500_add_i2c(3, U5500_I2C3_BASE, IRQ_DB5500_I2C3, pdata) 18 dbx500_add_i2c(parent, 3, U5500_I2C3_BASE, IRQ_DB5500_I2C3, pdata)
19 19
20#define db5500_add_msp0_i2s(pdata) \ 20#define db5500_add_msp0_spi(parent, pdata) \
21 dbx500_add_msp_i2s(0, U5500_MSP0_BASE, IRQ_DB5500_MSP0, pdata) 21 dbx500_add_msp_spi(parent, "msp0", U5500_MSP0_BASE, \
22#define db5500_add_msp1_i2s(pdata) \ 22 IRQ_DB5500_MSP0, pdata)
23 dbx500_add_msp_i2s(1, U5500_MSP1_BASE, IRQ_DB5500_MSP1, pdata) 23#define db5500_add_msp1_spi(parent, pdata) \
24#define db5500_add_msp2_i2s(pdata) \ 24 dbx500_add_msp_spi(parent, "msp1", U5500_MSP1_BASE, \
25 dbx500_add_msp_i2s(2, U5500_MSP2_BASE, IRQ_DB5500_MSP2, pdata) 25 IRQ_DB5500_MSP1, pdata)
26#define db5500_add_msp2_spi(parent, pdata) \
27 dbx500_add_msp_spi(parent, "msp2", U5500_MSP2_BASE, \
28 IRQ_DB5500_MSP2, pdata)
26 29
27#define db5500_add_msp0_spi(pdata) \ 30#define db5500_add_msp0_spi(parent, pdata) \
28 dbx500_add_msp_spi("msp0", U5500_MSP0_BASE, IRQ_DB5500_MSP0, pdata) 31 dbx500_add_msp_spi(parent, "msp0", U5500_MSP0_BASE, \
29#define db5500_add_msp1_spi(pdata) \ 32 IRQ_DB5500_MSP0, pdata)
30 dbx500_add_msp_spi("msp1", U5500_MSP1_BASE, IRQ_DB5500_MSP1, pdata) 33#define db5500_add_msp1_spi(parent, pdata) \
31#define db5500_add_msp2_spi(pdata) \ 34 dbx500_add_msp_spi(parent, "msp1", U5500_MSP1_BASE, \
32 dbx500_add_msp_spi("msp2", U5500_MSP2_BASE, IRQ_DB5500_MSP2, pdata) 35 IRQ_DB5500_MSP1, pdata)
36#define db5500_add_msp2_spi(parent, pdata) \
37 dbx500_add_msp_spi(parent, "msp2", U5500_MSP2_BASE, \
38 IRQ_DB5500_MSP2, pdata)
33 39
34#define db5500_add_rtc() \ 40#define db5500_add_rtc(parent) \
35 dbx500_add_rtc(U5500_RTC_BASE, IRQ_DB5500_RTC); 41 dbx500_add_rtc(parent, U5500_RTC_BASE, IRQ_DB5500_RTC);
36 42
37#define db5500_add_usb(rx_cfg, tx_cfg) \ 43#define db5500_add_usb(parent, rx_cfg, tx_cfg) \
38 ux500_add_usb(U5500_USBOTG_BASE, IRQ_DB5500_USBOTG, rx_cfg, tx_cfg) 44 ux500_add_usb(parent, U5500_USBOTG_BASE, \
45 IRQ_DB5500_USBOTG, rx_cfg, tx_cfg)
39 46
40#define db5500_add_sdi0(pdata) \ 47#define db5500_add_sdi0(parent, pdata) \
41 dbx500_add_sdi("sdi0", U5500_SDI0_BASE, IRQ_DB5500_SDMMC0, pdata, \ 48 dbx500_add_sdi(parent, "sdi0", U5500_SDI0_BASE, \
49 IRQ_DB5500_SDMMC0, pdata, \
42 0x10480180) 50 0x10480180)
43#define db5500_add_sdi1(pdata) \ 51#define db5500_add_sdi1(parent, pdata) \
44 dbx500_add_sdi("sdi1", U5500_SDI1_BASE, IRQ_DB5500_SDMMC1, pdata, \ 52 dbx500_add_sdi(parent, "sdi1", U5500_SDI1_BASE, \
53 IRQ_DB5500_SDMMC1, pdata, \
45 0x10480180) 54 0x10480180)
46#define db5500_add_sdi2(pdata) \ 55#define db5500_add_sdi2(parent, pdata) \
47 dbx500_add_sdi("sdi2", U5500_SDI2_BASE, IRQ_DB5500_SDMMC2, pdata \ 56 dbx500_add_sdi(parent, "sdi2", U5500_SDI2_BASE, \
57 IRQ_DB5500_SDMMC2, pdata \
48 0x10480180) 58 0x10480180)
49#define db5500_add_sdi3(pdata) \ 59#define db5500_add_sdi3(parent, pdata) \
50 dbx500_add_sdi("sdi3", U5500_SDI3_BASE, IRQ_DB5500_SDMMC3, pdata \ 60 dbx500_add_sdi(parent, "sdi3", U5500_SDI3_BASE, \
61 IRQ_DB5500_SDMMC3, pdata \
51 0x10480180) 62 0x10480180)
52#define db5500_add_sdi4(pdata) \ 63#define db5500_add_sdi4(parent, pdata) \
53 dbx500_add_sdi("sdi4", U5500_SDI4_BASE, IRQ_DB5500_SDMMC4, pdata \ 64 dbx500_add_sdi(parent, "sdi4", U5500_SDI4_BASE, \
65 IRQ_DB5500_SDMMC4, pdata \
54 0x10480180) 66 0x10480180)
55 67
56/* This one has a bad peripheral ID in the U5500 silicon */ 68/* This one has a bad peripheral ID in the U5500 silicon */
57#define db5500_add_spi0(pdata) \ 69#define db5500_add_spi0(parent, pdata) \
58 dbx500_add_spi("spi0", U5500_SPI0_BASE, IRQ_DB5500_SPI0, pdata, \ 70 dbx500_add_spi(parent, "spi0", U5500_SPI0_BASE, \
71 IRQ_DB5500_SPI0, pdata, \
59 0x10080023) 72 0x10080023)
60#define db5500_add_spi1(pdata) \ 73#define db5500_add_spi1(parent, pdata) \
61 dbx500_add_spi("spi1", U5500_SPI1_BASE, IRQ_DB5500_SPI1, pdata, \ 74 dbx500_add_spi(parent, "spi1", U5500_SPI1_BASE, \
75 IRQ_DB5500_SPI1, pdata, \
62 0x10080023) 76 0x10080023)
63#define db5500_add_spi2(pdata) \ 77#define db5500_add_spi2(parent, pdata) \
64 dbx500_add_spi("spi2", U5500_SPI2_BASE, IRQ_DB5500_SPI2, pdata \ 78 dbx500_add_spi(parent, "spi2", U5500_SPI2_BASE, \
79 IRQ_DB5500_SPI2, pdata \
65 0x10080023) 80 0x10080023)
66#define db5500_add_spi3(pdata) \ 81#define db5500_add_spi3(parent, pdata) \
67 dbx500_add_spi("spi3", U5500_SPI3_BASE, IRQ_DB5500_SPI3, pdata \ 82 dbx500_add_spi(parent, "spi3", U5500_SPI3_BASE, \
83 IRQ_DB5500_SPI3, pdata \
68 0x10080023) 84 0x10080023)
69 85
70#define db5500_add_uart0(plat) \ 86#define db5500_add_uart0(parent, plat) \
71 dbx500_add_uart("uart0", U5500_UART0_BASE, IRQ_DB5500_UART0, plat) 87 dbx500_add_uart(parent, "uart0", U5500_UART0_BASE, \
72#define db5500_add_uart1(plat) \ 88 IRQ_DB5500_UART0, plat)
73 dbx500_add_uart("uart1", U5500_UART1_BASE, IRQ_DB5500_UART1, plat) 89#define db5500_add_uart1(parent, plat) \
74#define db5500_add_uart2(plat) \ 90 dbx500_add_uart(parent, "uart1", U5500_UART1_BASE, \
75 dbx500_add_uart("uart2", U5500_UART2_BASE, IRQ_DB5500_UART2, plat) 91 IRQ_DB5500_UART1, plat)
76#define db5500_add_uart3(plat) \ 92#define db5500_add_uart2(parent, plat) \
77 dbx500_add_uart("uart3", U5500_UART3_BASE, IRQ_DB5500_UART3, plat) 93 dbx500_add_uart(parent, "uart2", U5500_UART2_BASE, \
94 IRQ_DB5500_UART2, plat)
95#define db5500_add_uart3(parent, plat) \
96 dbx500_add_uart(parent, "uart3", U5500_UART3_BASE, \
97 IRQ_DB5500_UART3, plat)
78 98
79#endif 99#endif
diff --git a/arch/arm/mach-ux500/devices-db8500.c b/arch/arm/mach-ux500/devices-db8500.c
index a7c6cdc9b11..6e66d3777ed 100644
--- a/arch/arm/mach-ux500/devices-db8500.c
+++ b/arch/arm/mach-ux500/devices-db8500.c
@@ -101,6 +101,9 @@ static const dma_addr_t dma40_tx_map[DB8500_DMA_NR_DEV] = {
101 [DB8500_DMA_DEV41_SD_MM3_TX] = -1, 101 [DB8500_DMA_DEV41_SD_MM3_TX] = -1,
102 [DB8500_DMA_DEV42_SD_MM4_TX] = -1, 102 [DB8500_DMA_DEV42_SD_MM4_TX] = -1,
103 [DB8500_DMA_DEV43_SD_MM5_TX] = -1, 103 [DB8500_DMA_DEV43_SD_MM5_TX] = -1,
104 [DB8500_DMA_DEV14_MSP2_TX] = U8500_MSP2_BASE + MSP_TX_RX_REG_OFFSET,
105 [DB8500_DMA_DEV30_MSP1_TX] = U8500_MSP1_BASE + MSP_TX_RX_REG_OFFSET,
106 [DB8500_DMA_DEV31_MSP0_TX_SLIM0_CH0_TX] = U8500_MSP0_BASE + MSP_TX_RX_REG_OFFSET,
104}; 107};
105 108
106/* Mapping between source event lines and physical device address */ 109/* Mapping between source event lines and physical device address */
@@ -133,6 +136,9 @@ static const dma_addr_t dma40_rx_map[DB8500_DMA_NR_DEV] = {
133 [DB8500_DMA_DEV41_SD_MM3_RX] = -1, 136 [DB8500_DMA_DEV41_SD_MM3_RX] = -1,
134 [DB8500_DMA_DEV42_SD_MM4_RX] = -1, 137 [DB8500_DMA_DEV42_SD_MM4_RX] = -1,
135 [DB8500_DMA_DEV43_SD_MM5_RX] = -1, 138 [DB8500_DMA_DEV43_SD_MM5_RX] = -1,
139 [DB8500_DMA_DEV14_MSP2_RX] = U8500_MSP2_BASE + MSP_TX_RX_REG_OFFSET,
140 [DB8500_DMA_DEV30_MSP3_RX] = U8500_MSP3_BASE + MSP_TX_RX_REG_OFFSET,
141 [DB8500_DMA_DEV31_MSP0_RX_SLIM0_CH0_RX] = U8500_MSP0_BASE + MSP_TX_RX_REG_OFFSET,
136}; 142};
137 143
138/* Reserved event lines for memcpy only */ 144/* Reserved event lines for memcpy only */
diff --git a/arch/arm/mach-ux500/devices-db8500.h b/arch/arm/mach-ux500/devices-db8500.h
index cbd4a9ae810..9fd93e9da52 100644
--- a/arch/arm/mach-ux500/devices-db8500.h
+++ b/arch/arm/mach-ux500/devices-db8500.h
@@ -14,88 +14,114 @@ struct ske_keypad_platform_data;
14struct pl022_ssp_controller; 14struct pl022_ssp_controller;
15 15
16static inline struct platform_device * 16static inline struct platform_device *
17db8500_add_ske_keypad(struct ske_keypad_platform_data *pdata) 17db8500_add_ske_keypad(struct device *parent,
18 struct ske_keypad_platform_data *pdata,
19 size_t size)
18{ 20{
19 return dbx500_add_platform_device_4k1irq("nmk-ske-keypad", -1, 21 struct resource resources[] = {
20 U8500_SKE_BASE, 22 DEFINE_RES_MEM(U8500_SKE_BASE, SZ_4K),
21 IRQ_DB8500_KB, pdata); 23 DEFINE_RES_IRQ(IRQ_DB8500_KB),
24 };
25
26 return platform_device_register_resndata(parent, "nmk-ske-keypad", -1,
27 resources, 2, pdata, size);
22} 28}
23 29
24static inline struct amba_device * 30static inline struct amba_device *
25db8500_add_ssp(const char *name, resource_size_t base, int irq, 31db8500_add_ssp(struct device *parent, const char *name, resource_size_t base,
26 struct pl022_ssp_controller *pdata) 32 int irq, struct pl022_ssp_controller *pdata)
27{ 33{
28 return dbx500_add_amba_device(name, base, irq, pdata, 0); 34 return dbx500_add_amba_device(parent, name, base, irq, pdata, 0);
29} 35}
30 36
31 37
32#define db8500_add_i2c0(pdata) \ 38#define db8500_add_i2c0(parent, pdata) \
33 dbx500_add_i2c(0, U8500_I2C0_BASE, IRQ_DB8500_I2C0, pdata) 39 dbx500_add_i2c(parent, 0, U8500_I2C0_BASE, IRQ_DB8500_I2C0, pdata)
34#define db8500_add_i2c1(pdata) \ 40#define db8500_add_i2c1(parent, pdata) \
35 dbx500_add_i2c(1, U8500_I2C1_BASE, IRQ_DB8500_I2C1, pdata) 41 dbx500_add_i2c(parent, 1, U8500_I2C1_BASE, IRQ_DB8500_I2C1, pdata)
36#define db8500_add_i2c2(pdata) \ 42#define db8500_add_i2c2(parent, pdata) \
37 dbx500_add_i2c(2, U8500_I2C2_BASE, IRQ_DB8500_I2C2, pdata) 43 dbx500_add_i2c(parent, 2, U8500_I2C2_BASE, IRQ_DB8500_I2C2, pdata)
38#define db8500_add_i2c3(pdata) \ 44#define db8500_add_i2c3(parent, pdata) \
39 dbx500_add_i2c(3, U8500_I2C3_BASE, IRQ_DB8500_I2C3, pdata) 45 dbx500_add_i2c(parent, 3, U8500_I2C3_BASE, IRQ_DB8500_I2C3, pdata)
40#define db8500_add_i2c4(pdata) \ 46#define db8500_add_i2c4(parent, pdata) \
41 dbx500_add_i2c(4, U8500_I2C4_BASE, IRQ_DB8500_I2C4, pdata) 47 dbx500_add_i2c(parent, 4, U8500_I2C4_BASE, IRQ_DB8500_I2C4, pdata)
42 48
43#define db8500_add_msp0_i2s(pdata) \ 49#define db8500_add_msp0_i2s(parent, pdata) \
44 dbx500_add_msp_i2s(0, U8500_MSP0_BASE, IRQ_DB8500_MSP0, pdata) 50 dbx500_add_msp_i2s(parent, 0, U8500_MSP0_BASE, IRQ_DB8500_MSP0, pdata)
45#define db8500_add_msp1_i2s(pdata) \ 51#define db8500_add_msp1_i2s(parent, pdata) \
46 dbx500_add_msp_i2s(1, U8500_MSP1_BASE, IRQ_DB8500_MSP1, pdata) 52 dbx500_add_msp_i2s(parent, 1, U8500_MSP1_BASE, IRQ_DB8500_MSP1, pdata)
47#define db8500_add_msp2_i2s(pdata) \ 53#define db8500_add_msp2_i2s(parent, pdata) \
48 dbx500_add_msp_i2s(2, U8500_MSP2_BASE, IRQ_DB8500_MSP2, pdata) 54 dbx500_add_msp_i2s(parent, 2, U8500_MSP2_BASE, IRQ_DB8500_MSP2, pdata)
49#define db8500_add_msp3_i2s(pdata) \ 55#define db8500_add_msp3_i2s(parent, pdata) \
50 dbx500_add_msp_i2s(3, U8500_MSP3_BASE, IRQ_DB8500_MSP1, pdata) 56 dbx500_add_msp_i2s(parent, 3, U8500_MSP3_BASE, IRQ_DB8500_MSP1, pdata)
51 57
52#define db8500_add_msp0_spi(pdata) \ 58#define db8500_add_msp0_spi(parent, pdata) \
53 dbx500_add_msp_spi("msp0", U8500_MSP0_BASE, IRQ_DB8500_MSP0, pdata) 59 dbx500_add_msp_spi(parent, "msp0", U8500_MSP0_BASE, \
54#define db8500_add_msp1_spi(pdata) \ 60 IRQ_DB8500_MSP0, pdata)
55 dbx500_add_msp_spi("msp1", U8500_MSP1_BASE, IRQ_DB8500_MSP1, pdata) 61#define db8500_add_msp1_spi(parent, pdata) \
56#define db8500_add_msp2_spi(pdata) \ 62 dbx500_add_msp_spi(parent, "msp1", U8500_MSP1_BASE, \
57 dbx500_add_msp_spi("msp2", U8500_MSP2_BASE, IRQ_DB8500_MSP2, pdata) 63 IRQ_DB8500_MSP1, pdata)
58#define db8500_add_msp3_spi(pdata) \ 64#define db8500_add_msp2_spi(parent, pdata) \
59 dbx500_add_msp_spi("msp3", U8500_MSP3_BASE, IRQ_DB8500_MSP1, pdata) 65 dbx500_add_msp_spi(parent, "msp2", U8500_MSP2_BASE, \
60 66 IRQ_DB8500_MSP2, pdata)
61#define db8500_add_rtc() \ 67#define db8500_add_msp3_spi(parent, pdata) \
62 dbx500_add_rtc(U8500_RTC_BASE, IRQ_DB8500_RTC); 68 dbx500_add_msp_spi(parent, "msp3", U8500_MSP3_BASE, \
63 69 IRQ_DB8500_MSP1, pdata)
64#define db8500_add_usb(rx_cfg, tx_cfg) \ 70
65 ux500_add_usb(U8500_USBOTG_BASE, IRQ_DB8500_USBOTG, rx_cfg, tx_cfg) 71#define db8500_add_rtc(parent) \
66 72 dbx500_add_rtc(parent, U8500_RTC_BASE, IRQ_DB8500_RTC);
67#define db8500_add_sdi0(pdata, pid) \ 73
68 dbx500_add_sdi("sdi0", U8500_SDI0_BASE, IRQ_DB8500_SDMMC0, pdata, pid) 74#define db8500_add_usb(parent, rx_cfg, tx_cfg) \
69#define db8500_add_sdi1(pdata, pid) \ 75 ux500_add_usb(parent, U8500_USBOTG_BASE, \
70 dbx500_add_sdi("sdi1", U8500_SDI1_BASE, IRQ_DB8500_SDMMC1, pdata, pid) 76 IRQ_DB8500_USBOTG, rx_cfg, tx_cfg)
71#define db8500_add_sdi2(pdata, pid) \ 77
72 dbx500_add_sdi("sdi2", U8500_SDI2_BASE, IRQ_DB8500_SDMMC2, pdata, pid) 78#define db8500_add_sdi0(parent, pdata, pid) \
73#define db8500_add_sdi3(pdata, pid) \ 79 dbx500_add_sdi(parent, "sdi0", U8500_SDI0_BASE, \
74 dbx500_add_sdi("sdi3", U8500_SDI3_BASE, IRQ_DB8500_SDMMC3, pdata, pid) 80 IRQ_DB8500_SDMMC0, pdata, pid)
75#define db8500_add_sdi4(pdata, pid) \ 81#define db8500_add_sdi1(parent, pdata, pid) \
76 dbx500_add_sdi("sdi4", U8500_SDI4_BASE, IRQ_DB8500_SDMMC4, pdata, pid) 82 dbx500_add_sdi(parent, "sdi1", U8500_SDI1_BASE, \
77#define db8500_add_sdi5(pdata, pid) \ 83 IRQ_DB8500_SDMMC1, pdata, pid)
78 dbx500_add_sdi("sdi5", U8500_SDI5_BASE, IRQ_DB8500_SDMMC5, pdata, pid) 84#define db8500_add_sdi2(parent, pdata, pid) \
79 85 dbx500_add_sdi(parent, "sdi2", U8500_SDI2_BASE, \
80#define db8500_add_ssp0(pdata) \ 86 IRQ_DB8500_SDMMC2, pdata, pid)
81 db8500_add_ssp("ssp0", U8500_SSP0_BASE, IRQ_DB8500_SSP0, pdata) 87#define db8500_add_sdi3(parent, pdata, pid) \
82#define db8500_add_ssp1(pdata) \ 88 dbx500_add_sdi(parent, "sdi3", U8500_SDI3_BASE, \
83 db8500_add_ssp("ssp1", U8500_SSP1_BASE, IRQ_DB8500_SSP1, pdata) 89 IRQ_DB8500_SDMMC3, pdata, pid)
84 90#define db8500_add_sdi4(parent, pdata, pid) \
85#define db8500_add_spi0(pdata) \ 91 dbx500_add_sdi(parent, "sdi4", U8500_SDI4_BASE, \
86 dbx500_add_spi("spi0", U8500_SPI0_BASE, IRQ_DB8500_SPI0, pdata, 0) 92 IRQ_DB8500_SDMMC4, pdata, pid)
87#define db8500_add_spi1(pdata) \ 93#define db8500_add_sdi5(parent, pdata, pid) \
88 dbx500_add_spi("spi1", U8500_SPI1_BASE, IRQ_DB8500_SPI1, pdata, 0) 94 dbx500_add_sdi(parent, "sdi5", U8500_SDI5_BASE, \
89#define db8500_add_spi2(pdata) \ 95 IRQ_DB8500_SDMMC5, pdata, pid)
90 dbx500_add_spi("spi2", U8500_SPI2_BASE, IRQ_DB8500_SPI2, pdata, 0) 96
91#define db8500_add_spi3(pdata) \ 97#define db8500_add_ssp0(parent, pdata) \
92 dbx500_add_spi("spi3", U8500_SPI3_BASE, IRQ_DB8500_SPI3, pdata, 0) 98 db8500_add_ssp(parent, "ssp0", U8500_SSP0_BASE, \
93 99 IRQ_DB8500_SSP0, pdata)
94#define db8500_add_uart0(pdata) \ 100#define db8500_add_ssp1(parent, pdata) \
95 dbx500_add_uart("uart0", U8500_UART0_BASE, IRQ_DB8500_UART0, pdata) 101 db8500_add_ssp(parent, "ssp1", U8500_SSP1_BASE, \
96#define db8500_add_uart1(pdata) \ 102 IRQ_DB8500_SSP1, pdata)
97 dbx500_add_uart("uart1", U8500_UART1_BASE, IRQ_DB8500_UART1, pdata) 103
98#define db8500_add_uart2(pdata) \ 104#define db8500_add_spi0(parent, pdata) \
99 dbx500_add_uart("uart2", U8500_UART2_BASE, IRQ_DB8500_UART2, pdata) 105 dbx500_add_spi(parent, "spi0", U8500_SPI0_BASE, \
106 IRQ_DB8500_SPI0, pdata, 0)
107#define db8500_add_spi1(parent, pdata) \
108 dbx500_add_spi(parent, "spi1", U8500_SPI1_BASE, \
109 IRQ_DB8500_SPI1, pdata, 0)
110#define db8500_add_spi2(parent, pdata) \
111 dbx500_add_spi(parent, "spi2", U8500_SPI2_BASE, \
112 IRQ_DB8500_SPI2, pdata, 0)
113#define db8500_add_spi3(parent, pdata) \
114 dbx500_add_spi(parent, "spi3", U8500_SPI3_BASE, \
115 IRQ_DB8500_SPI3, pdata, 0)
116
117#define db8500_add_uart0(parent, pdata) \
118 dbx500_add_uart(parent, "uart0", U8500_UART0_BASE, \
119 IRQ_DB8500_UART0, pdata)
120#define db8500_add_uart1(parent, pdata) \
121 dbx500_add_uart(parent, "uart1", U8500_UART1_BASE, \
122 IRQ_DB8500_UART1, pdata)
123#define db8500_add_uart2(parent, pdata) \
124 dbx500_add_uart(parent, "uart2", U8500_UART2_BASE, \
125 IRQ_DB8500_UART2, pdata)
100 126
101#endif 127#endif
diff --git a/arch/arm/mach-ux500/dma-db5500.c b/arch/arm/mach-ux500/dma-db5500.c
index 1cfab68ae41..41e9470fa0e 100644
--- a/arch/arm/mach-ux500/dma-db5500.c
+++ b/arch/arm/mach-ux500/dma-db5500.c
@@ -125,10 +125,11 @@ static struct platform_device dma40_device = {
125 .resource = dma40_resources 125 .resource = dma40_resources
126}; 126};
127 127
128void __init db5500_dma_init(void) 128void __init db5500_dma_init(struct device *parent)
129{ 129{
130 int ret; 130 int ret;
131 131
132 dma40_device.dev.parent = parent;
132 ret = platform_device_register(&dma40_device); 133 ret = platform_device_register(&dma40_device);
133 if (ret) 134 if (ret)
134 dev_err(&dma40_device.dev, "unable to register device: %d\n", ret); 135 dev_err(&dma40_device.dev, "unable to register device: %d\n", ret);
diff --git a/arch/arm/mach-ux500/include/mach/db8500-regs.h b/arch/arm/mach-ux500/include/mach/db8500-regs.h
index 80e10f50282..9ec20b96d8f 100644
--- a/arch/arm/mach-ux500/include/mach/db8500-regs.h
+++ b/arch/arm/mach-ux500/include/mach/db8500-regs.h
@@ -161,4 +161,7 @@
161#define U8500_MODEM_BASE 0xe000000 161#define U8500_MODEM_BASE 0xe000000
162#define U8500_APE_BASE 0x6000000 162#define U8500_APE_BASE 0x6000000
163 163
164/* SoC identification number information */
165#define U8500_BB_UID_BASE (U8500_BACKUPRAM1_BASE + 0xFC0)
166
164#endif 167#endif
diff --git a/arch/arm/mach-ux500/include/mach/entry-macro.S b/arch/arm/mach-ux500/include/mach/entry-macro.S
deleted file mode 100644
index e16299e1020..00000000000
--- a/arch/arm/mach-ux500/include/mach/entry-macro.S
+++ /dev/null
@@ -1,18 +0,0 @@
1/*
2 * Low-level IRQ helper macros for U8500 platforms
3 *
4 * Copyright (C) 2009 ST-Ericsson.
5 *
6 * This file is a copy of ARM Realview platform.
7 * -just satisfied checkpatch script.
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 .macro disable_fiq
15 .endm
16
17 .macro arch_ret_to_user, tmp1, tmp2
18 .endm
diff --git a/arch/arm/mach-ux500/include/mach/hardware.h b/arch/arm/mach-ux500/include/mach/hardware.h
index b6ba26a1367..d93d6dbef25 100644
--- a/arch/arm/mach-ux500/include/mach/hardware.h
+++ b/arch/arm/mach-ux500/include/mach/hardware.h
@@ -30,6 +30,8 @@
30#include <mach/db8500-regs.h> 30#include <mach/db8500-regs.h>
31#include <mach/db5500-regs.h> 31#include <mach/db5500-regs.h>
32 32
33#define MSP_TX_RX_REG_OFFSET 0
34
33#ifndef __ASSEMBLY__ 35#ifndef __ASSEMBLY__
34 36
35#include <mach/id.h> 37#include <mach/id.h>
diff --git a/arch/arm/mach-ux500/include/mach/irqs-board-mop500.h b/arch/arm/mach-ux500/include/mach/irqs-board-mop500.h
index d2d4131435a..7d34c52798b 100644
--- a/arch/arm/mach-ux500/include/mach/irqs-board-mop500.h
+++ b/arch/arm/mach-ux500/include/mach/irqs-board-mop500.h
@@ -13,7 +13,7 @@
13 13
14#define MOP500_AB8500_IRQ_BASE IRQ_BOARD_START 14#define MOP500_AB8500_IRQ_BASE IRQ_BOARD_START
15#define MOP500_AB8500_IRQ_END (MOP500_AB8500_IRQ_BASE \ 15#define MOP500_AB8500_IRQ_END (MOP500_AB8500_IRQ_BASE \
16 + AB8500_NR_IRQS) 16 + AB8500_MAX_NR_IRQS)
17 17
18/* TC35892 */ 18/* TC35892 */
19#define TC35892_NR_INTERNAL_IRQS 8 19#define TC35892_NR_INTERNAL_IRQS 8
diff --git a/arch/arm/mach-ux500/include/mach/irqs.h b/arch/arm/mach-ux500/include/mach/irqs.h
index 9db68d264c5..c23a6b5f0c4 100644
--- a/arch/arm/mach-ux500/include/mach/irqs.h
+++ b/arch/arm/mach-ux500/include/mach/irqs.h
@@ -43,7 +43,7 @@
43/* This will be overridden by board-specific irq headers */ 43/* This will be overridden by board-specific irq headers */
44#define IRQ_BOARD_END IRQ_BOARD_START 44#define IRQ_BOARD_END IRQ_BOARD_START
45 45
46#ifdef CONFIG_MACH_U8500 46#ifdef CONFIG_MACH_MOP500
47#include <mach/irqs-board-mop500.h> 47#include <mach/irqs-board-mop500.h>
48#endif 48#endif
49 49
diff --git a/arch/arm/mach-ux500/include/mach/setup.h b/arch/arm/mach-ux500/include/mach/setup.h
index a7d363fdb4c..3dc00ffa7bf 100644
--- a/arch/arm/mach-ux500/include/mach/setup.h
+++ b/arch/arm/mach-ux500/include/mach/setup.h
@@ -18,17 +18,16 @@ void __init ux500_map_io(void);
18extern void __init u5500_map_io(void); 18extern void __init u5500_map_io(void);
19extern void __init u8500_map_io(void); 19extern void __init u8500_map_io(void);
20 20
21extern void __init u5500_init_devices(void); 21extern struct device * __init u5500_init_devices(void);
22extern void __init u8500_init_devices(void); 22extern struct device * __init u8500_init_devices(void);
23 23
24extern void __init ux500_init_irq(void); 24extern void __init ux500_init_irq(void);
25 25
26extern void __init u5500_sdi_init(void); 26extern void __init u5500_sdi_init(struct device *parent);
27 27
28extern void __init db5500_dma_init(void); 28extern void __init db5500_dma_init(struct device *parent);
29 29
30/* We re-use nomadik_timer for this platform */ 30extern struct device *ux500_soc_device_init(const char *soc_id);
31extern void nmdk_timer_init(void);
32 31
33struct amba_device; 32struct amba_device;
34extern void __init amba_add_devices(struct amba_device *devs[], int num); 33extern void __init amba_add_devices(struct amba_device *devs[], int num);
diff --git a/arch/arm/mach-ux500/include/mach/system.h b/arch/arm/mach-ux500/include/mach/system.h
deleted file mode 100644
index 258e5c919c2..00000000000
--- a/arch/arm/mach-ux500/include/mach/system.h
+++ /dev/null
@@ -1,20 +0,0 @@
1/*
2 * Copyright (C) 2009 ST-Ericsson.
3 *
4 * This file is licensed under the terms of the GNU General Public
5 * License version 2. This program is licensed "as is" without any
6 * warranty of any kind, whether express or implied.
7 */
8#ifndef __ASM_ARCH_SYSTEM_H
9#define __ASM_ARCH_SYSTEM_H
10
11static inline void arch_idle(void)
12{
13 /*
14 * This should do all the clock switching
15 * and wait for interrupt tricks
16 */
17 cpu_do_idle();
18}
19
20#endif
diff --git a/arch/arm/mach-ux500/include/mach/usb.h b/arch/arm/mach-ux500/include/mach/usb.h
index d3739d41881..4c1cc50a595 100644
--- a/arch/arm/mach-ux500/include/mach/usb.h
+++ b/arch/arm/mach-ux500/include/mach/usb.h
@@ -20,6 +20,6 @@ struct ux500_musb_board_data {
20 bool (*dma_filter)(struct dma_chan *chan, void *filter_param); 20 bool (*dma_filter)(struct dma_chan *chan, void *filter_param);
21}; 21};
22 22
23void ux500_add_usb(resource_size_t base, int irq, int *dma_rx_cfg, 23void ux500_add_usb(struct device *parent, resource_size_t base,
24 int *dma_tx_cfg); 24 int irq, int *dma_rx_cfg, int *dma_tx_cfg);
25#endif 25#endif
diff --git a/arch/arm/mach-ux500/localtimer.c b/arch/arm/mach-ux500/localtimer.c
deleted file mode 100644
index 5ba113309a0..00000000000
--- a/arch/arm/mach-ux500/localtimer.c
+++ /dev/null
@@ -1,29 +0,0 @@
1/*
2 * Copyright (C) 2008-2009 ST-Ericsson
3 * Srinidhi Kasagar <srinidhi.kasagar@stericsson.com>
4 *
5 * This file is heavily based on relaview platform, almost a copy.
6 *
7 * Copyright (C) 2002 ARM Ltd.
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#include <linux/init.h>
14#include <linux/smp.h>
15#include <linux/clockchips.h>
16
17#include <asm/irq.h>
18#include <asm/smp_twd.h>
19#include <asm/localtimer.h>
20
21/*
22 * Setup the local clock events for a CPU.
23 */
24int __cpuinit local_timer_setup(struct clock_event_device *evt)
25{
26 evt->irq = IRQ_LOCALTIMER;
27 twd_timer_setup(evt);
28 return 0;
29}
diff --git a/arch/arm/mach-ux500/timer.c b/arch/arm/mach-ux500/timer.c
index aea467d04ff..d37df98b5c3 100644
--- a/arch/arm/mach-ux500/timer.c
+++ b/arch/arm/mach-ux500/timer.c
@@ -7,29 +7,52 @@
7#include <linux/io.h> 7#include <linux/io.h>
8#include <linux/errno.h> 8#include <linux/errno.h>
9#include <linux/clksrc-dbx500-prcmu.h> 9#include <linux/clksrc-dbx500-prcmu.h>
10#include <linux/of.h>
10 11
11#include <asm/localtimer.h> 12#include <asm/smp_twd.h>
12 13
13#include <plat/mtu.h> 14#include <plat/mtu.h>
14 15
15#include <mach/setup.h> 16#include <mach/setup.h>
16#include <mach/hardware.h> 17#include <mach/hardware.h>
18#include <mach/irqs.h>
19
20#ifdef CONFIG_HAVE_ARM_TWD
21static DEFINE_TWD_LOCAL_TIMER(u5500_twd_local_timer,
22 U5500_TWD_BASE, IRQ_LOCALTIMER);
23static DEFINE_TWD_LOCAL_TIMER(u8500_twd_local_timer,
24 U8500_TWD_BASE, IRQ_LOCALTIMER);
25
26static void __init ux500_twd_init(void)
27{
28 struct twd_local_timer *twd_local_timer;
29 int err;
30
31 twd_local_timer = cpu_is_u5500() ? &u5500_twd_local_timer :
32 &u8500_twd_local_timer;
33
34 if (of_have_populated_dt())
35 twd_local_timer_of_register();
36 else {
37 err = twd_local_timer_register(twd_local_timer);
38 if (err)
39 pr_err("twd_local_timer_register failed %d\n", err);
40 }
41}
42#else
43#define ux500_twd_init() do { } while(0)
44#endif
17 45
18static void __init ux500_timer_init(void) 46static void __init ux500_timer_init(void)
19{ 47{
48 void __iomem *mtu_timer_base;
20 void __iomem *prcmu_timer_base; 49 void __iomem *prcmu_timer_base;
21 50
22 if (cpu_is_u5500()) { 51 if (cpu_is_u5500()) {
23#ifdef CONFIG_LOCAL_TIMERS 52 mtu_timer_base = __io_address(U5500_MTU0_BASE);
24 twd_base = __io_address(U5500_TWD_BASE);
25#endif
26 mtu_base = __io_address(U5500_MTU0_BASE);
27 prcmu_timer_base = __io_address(U5500_PRCMU_TIMER_3_BASE); 53 prcmu_timer_base = __io_address(U5500_PRCMU_TIMER_3_BASE);
28 } else if (cpu_is_u8500()) { 54 } else if (cpu_is_u8500()) {
29#ifdef CONFIG_LOCAL_TIMERS 55 mtu_timer_base = __io_address(U8500_MTU0_BASE);
30 twd_base = __io_address(U8500_TWD_BASE);
31#endif
32 mtu_base = __io_address(U8500_MTU0_BASE);
33 prcmu_timer_base = __io_address(U8500_PRCMU_TIMER_4_BASE); 56 prcmu_timer_base = __io_address(U8500_PRCMU_TIMER_4_BASE);
34 } else { 57 } else {
35 ux500_unknown_soc(); 58 ux500_unknown_soc();
@@ -52,8 +75,9 @@ static void __init ux500_timer_init(void)
52 * 75 *
53 */ 76 */
54 77
55 nmdk_timer_init(); 78 nmdk_timer_init(mtu_timer_base);
56 clksrc_dbx500_prcmu_init(prcmu_timer_base); 79 clksrc_dbx500_prcmu_init(prcmu_timer_base);
80 ux500_twd_init();
57} 81}
58 82
59static void ux500_timer_reset(void) 83static void ux500_timer_reset(void)
diff --git a/arch/arm/mach-ux500/usb.c b/arch/arm/mach-ux500/usb.c
index 9f9e1c20306..a74af389bc6 100644
--- a/arch/arm/mach-ux500/usb.c
+++ b/arch/arm/mach-ux500/usb.c
@@ -7,6 +7,7 @@
7#include <linux/platform_device.h> 7#include <linux/platform_device.h>
8#include <linux/usb/musb.h> 8#include <linux/usb/musb.h>
9#include <linux/dma-mapping.h> 9#include <linux/dma-mapping.h>
10
10#include <plat/ste_dma40.h> 11#include <plat/ste_dma40.h>
11#include <mach/hardware.h> 12#include <mach/hardware.h>
12#include <mach/usb.h> 13#include <mach/usb.h>
@@ -140,8 +141,8 @@ static inline void ux500_usb_dma_update_tx_ch_config(int *dst_dev_type)
140 musb_dma_tx_ch[idx].dst_dev_type = dst_dev_type[idx]; 141 musb_dma_tx_ch[idx].dst_dev_type = dst_dev_type[idx];
141} 142}
142 143
143void ux500_add_usb(resource_size_t base, int irq, int *dma_rx_cfg, 144void ux500_add_usb(struct device *parent, resource_size_t base, int irq,
144 int *dma_tx_cfg) 145 int *dma_rx_cfg, int *dma_tx_cfg)
145{ 146{
146 ux500_musb_device.resource[0].start = base; 147 ux500_musb_device.resource[0].start = base;
147 ux500_musb_device.resource[0].end = base + SZ_64K - 1; 148 ux500_musb_device.resource[0].end = base + SZ_64K - 1;
@@ -151,5 +152,7 @@ void ux500_add_usb(resource_size_t base, int irq, int *dma_rx_cfg,
151 ux500_usb_dma_update_rx_ch_config(dma_rx_cfg); 152 ux500_usb_dma_update_rx_ch_config(dma_rx_cfg);
152 ux500_usb_dma_update_tx_ch_config(dma_tx_cfg); 153 ux500_usb_dma_update_tx_ch_config(dma_tx_cfg);
153 154
155 ux500_musb_device.dev.parent = parent;
156
154 platform_device_register(&ux500_musb_device); 157 platform_device_register(&ux500_musb_device);
155} 158}
diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c
index 4cf706165af..6bbd74e950a 100644
--- a/arch/arm/mach-versatile/core.c
+++ b/arch/arm/mach-versatile/core.c
@@ -584,58 +584,58 @@ static struct pl022_ssp_controller ssp0_plat_data = {
584 .num_chipselect = 1, 584 .num_chipselect = 1,
585}; 585};
586 586
587#define AACI_IRQ { IRQ_AACI, NO_IRQ } 587#define AACI_IRQ { IRQ_AACI }
588#define MMCI0_IRQ { IRQ_MMCI0A,IRQ_SIC_MMCI0B } 588#define MMCI0_IRQ { IRQ_MMCI0A,IRQ_SIC_MMCI0B }
589#define KMI0_IRQ { IRQ_SIC_KMI0, NO_IRQ } 589#define KMI0_IRQ { IRQ_SIC_KMI0 }
590#define KMI1_IRQ { IRQ_SIC_KMI1, NO_IRQ } 590#define KMI1_IRQ { IRQ_SIC_KMI1 }
591 591
592/* 592/*
593 * These devices are connected directly to the multi-layer AHB switch 593 * These devices are connected directly to the multi-layer AHB switch
594 */ 594 */
595#define SMC_IRQ { NO_IRQ, NO_IRQ } 595#define SMC_IRQ { }
596#define MPMC_IRQ { NO_IRQ, NO_IRQ } 596#define MPMC_IRQ { }
597#define CLCD_IRQ { IRQ_CLCDINT, NO_IRQ } 597#define CLCD_IRQ { IRQ_CLCDINT }
598#define DMAC_IRQ { IRQ_DMAINT, NO_IRQ } 598#define DMAC_IRQ { IRQ_DMAINT }
599 599
600/* 600/*
601 * These devices are connected via the core APB bridge 601 * These devices are connected via the core APB bridge
602 */ 602 */
603#define SCTL_IRQ { NO_IRQ, NO_IRQ } 603#define SCTL_IRQ { }
604#define WATCHDOG_IRQ { IRQ_WDOGINT, NO_IRQ } 604#define WATCHDOG_IRQ { IRQ_WDOGINT }
605#define GPIO0_IRQ { IRQ_GPIOINT0, NO_IRQ } 605#define GPIO0_IRQ { IRQ_GPIOINT0 }
606#define GPIO1_IRQ { IRQ_GPIOINT1, NO_IRQ } 606#define GPIO1_IRQ { IRQ_GPIOINT1 }
607#define RTC_IRQ { IRQ_RTCINT, NO_IRQ } 607#define RTC_IRQ { IRQ_RTCINT }
608 608
609/* 609/*
610 * These devices are connected via the DMA APB bridge 610 * These devices are connected via the DMA APB bridge
611 */ 611 */
612#define SCI_IRQ { IRQ_SCIINT, NO_IRQ } 612#define SCI_IRQ { IRQ_SCIINT }
613#define UART0_IRQ { IRQ_UARTINT0, NO_IRQ } 613#define UART0_IRQ { IRQ_UARTINT0 }
614#define UART1_IRQ { IRQ_UARTINT1, NO_IRQ } 614#define UART1_IRQ { IRQ_UARTINT1 }
615#define UART2_IRQ { IRQ_UARTINT2, NO_IRQ } 615#define UART2_IRQ { IRQ_UARTINT2 }
616#define SSP_IRQ { IRQ_SSPINT, NO_IRQ } 616#define SSP_IRQ { IRQ_SSPINT }
617 617
618/* FPGA Primecells */ 618/* FPGA Primecells */
619AMBA_DEVICE(aaci, "fpga:04", AACI, NULL); 619APB_DEVICE(aaci, "fpga:04", AACI, NULL);
620AMBA_DEVICE(mmc0, "fpga:05", MMCI0, &mmc0_plat_data); 620APB_DEVICE(mmc0, "fpga:05", MMCI0, &mmc0_plat_data);
621AMBA_DEVICE(kmi0, "fpga:06", KMI0, NULL); 621APB_DEVICE(kmi0, "fpga:06", KMI0, NULL);
622AMBA_DEVICE(kmi1, "fpga:07", KMI1, NULL); 622APB_DEVICE(kmi1, "fpga:07", KMI1, NULL);
623 623
624/* DevChip Primecells */ 624/* DevChip Primecells */
625AMBA_DEVICE(smc, "dev:00", SMC, NULL); 625AHB_DEVICE(smc, "dev:00", SMC, NULL);
626AMBA_DEVICE(mpmc, "dev:10", MPMC, NULL); 626AHB_DEVICE(mpmc, "dev:10", MPMC, NULL);
627AMBA_DEVICE(clcd, "dev:20", CLCD, &clcd_plat_data); 627AHB_DEVICE(clcd, "dev:20", CLCD, &clcd_plat_data);
628AMBA_DEVICE(dmac, "dev:30", DMAC, NULL); 628AHB_DEVICE(dmac, "dev:30", DMAC, NULL);
629AMBA_DEVICE(sctl, "dev:e0", SCTL, NULL); 629APB_DEVICE(sctl, "dev:e0", SCTL, NULL);
630AMBA_DEVICE(wdog, "dev:e1", WATCHDOG, NULL); 630APB_DEVICE(wdog, "dev:e1", WATCHDOG, NULL);
631AMBA_DEVICE(gpio0, "dev:e4", GPIO0, &gpio0_plat_data); 631APB_DEVICE(gpio0, "dev:e4", GPIO0, &gpio0_plat_data);
632AMBA_DEVICE(gpio1, "dev:e5", GPIO1, &gpio1_plat_data); 632APB_DEVICE(gpio1, "dev:e5", GPIO1, &gpio1_plat_data);
633AMBA_DEVICE(rtc, "dev:e8", RTC, NULL); 633APB_DEVICE(rtc, "dev:e8", RTC, NULL);
634AMBA_DEVICE(sci0, "dev:f0", SCI, NULL); 634APB_DEVICE(sci0, "dev:f0", SCI, NULL);
635AMBA_DEVICE(uart0, "dev:f1", UART0, NULL); 635APB_DEVICE(uart0, "dev:f1", UART0, NULL);
636AMBA_DEVICE(uart1, "dev:f2", UART1, NULL); 636APB_DEVICE(uart1, "dev:f2", UART1, NULL);
637AMBA_DEVICE(uart2, "dev:f3", UART2, NULL); 637APB_DEVICE(uart2, "dev:f3", UART2, NULL);
638AMBA_DEVICE(ssp0, "dev:f4", SSP, &ssp0_plat_data); 638APB_DEVICE(ssp0, "dev:f4", SSP, &ssp0_plat_data);
639 639
640static struct amba_device *amba_devs[] __initdata = { 640static struct amba_device *amba_devs[] __initdata = {
641 &dmac_device, 641 &dmac_device,
diff --git a/arch/arm/mach-versatile/core.h b/arch/arm/mach-versatile/core.h
index 2ef2f555f31..683e60776a8 100644
--- a/arch/arm/mach-versatile/core.h
+++ b/arch/arm/mach-versatile/core.h
@@ -36,20 +36,10 @@ extern unsigned int mmc_status(struct device *dev);
36extern struct of_dev_auxdata versatile_auxdata_lookup[]; 36extern struct of_dev_auxdata versatile_auxdata_lookup[];
37#endif 37#endif
38 38
39#define AMBA_DEVICE(name,busid,base,plat) \ 39#define APB_DEVICE(name, busid, base, plat) \
40static struct amba_device name##_device = { \ 40static AMBA_APB_DEVICE(name, busid, 0, VERSATILE_##base##_BASE, base##_IRQ, plat)
41 .dev = { \ 41
42 .coherent_dma_mask = ~0, \ 42#define AHB_DEVICE(name, busid, base, plat) \
43 .init_name = busid, \ 43static AMBA_AHB_DEVICE(name, busid, 0, VERSATILE_##base##_BASE, base##_IRQ, plat)
44 .platform_data = plat, \
45 }, \
46 .res = { \
47 .start = VERSATILE_##base##_BASE, \
48 .end = (VERSATILE_##base##_BASE) + SZ_4K - 1,\
49 .flags = IORESOURCE_MEM, \
50 }, \
51 .dma_mask = ~0, \
52 .irq = base##_IRQ, \
53}
54 44
55#endif 45#endif
diff --git a/arch/arm/mach-versatile/include/mach/entry-macro.S b/arch/arm/mach-versatile/include/mach/entry-macro.S
deleted file mode 100644
index b6f0dbf122e..00000000000
--- a/arch/arm/mach-versatile/include/mach/entry-macro.S
+++ /dev/null
@@ -1,15 +0,0 @@
1/*
2 * arch/arm/mach-versatile/include/mach/entry-macro.S
3 *
4 * Low-level IRQ helper macros for Versatile platforms
5 *
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
9 */
10
11 .macro disable_fiq
12 .endm
13
14 .macro arch_ret_to_user, tmp1, tmp2
15 .endm
diff --git a/arch/arm/mach-versatile/include/mach/system.h b/arch/arm/mach-versatile/include/mach/system.h
deleted file mode 100644
index f3fa347895f..00000000000
--- a/arch/arm/mach-versatile/include/mach/system.h
+++ /dev/null
@@ -1,33 +0,0 @@
1/*
2 * arch/arm/mach-versatile/include/mach/system.h
3 *
4 * Copyright (C) 2003 ARM Limited
5 * Copyright (C) 2000 Deep Blue Solutions Ltd
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 USA
20 */
21#ifndef __ASM_ARCH_SYSTEM_H
22#define __ASM_ARCH_SYSTEM_H
23
24static inline void arch_idle(void)
25{
26 /*
27 * This should do all the clock switching
28 * and wait for interrupt tricks
29 */
30 cpu_do_idle();
31}
32
33#endif
diff --git a/arch/arm/mach-versatile/pci.c b/arch/arm/mach-versatile/pci.c
index 787cf5f26da..a6e23f46452 100644
--- a/arch/arm/mach-versatile/pci.c
+++ b/arch/arm/mach-versatile/pci.c
@@ -218,9 +218,9 @@ static int __init pci_versatile_setup_resources(struct list_head *resources)
218 * the mem resource for this bus 218 * the mem resource for this bus
219 * the prefetch mem resource for this bus 219 * the prefetch mem resource for this bus
220 */ 220 */
221 pci_add_resource(resources, &io_mem); 221 pci_add_resource_offset(resources, &io_mem, sys->io_offset);
222 pci_add_resource(resources, &non_mem); 222 pci_add_resource_offset(resources, &non_mem, sys->mem_offset);
223 pci_add_resource(resources, &pre_mem); 223 pci_add_resource_offset(resources, &pre_mem, sys->mem_offset);
224 224
225 goto out; 225 goto out;
226 226
diff --git a/arch/arm/mach-versatile/versatile_pb.c b/arch/arm/mach-versatile/versatile_pb.c
index 9581c197500..19738331bd3 100644
--- a/arch/arm/mach-versatile/versatile_pb.c
+++ b/arch/arm/mach-versatile/versatile_pb.c
@@ -58,28 +58,28 @@ static struct pl061_platform_data gpio3_plat_data = {
58 .irq_base = IRQ_GPIO3_START, 58 .irq_base = IRQ_GPIO3_START,
59}; 59};
60 60
61#define UART3_IRQ { IRQ_SIC_UART3, NO_IRQ } 61#define UART3_IRQ { IRQ_SIC_UART3 }
62#define SCI1_IRQ { IRQ_SIC_SCI3, NO_IRQ } 62#define SCI1_IRQ { IRQ_SIC_SCI3 }
63#define MMCI1_IRQ { IRQ_MMCI1A, IRQ_SIC_MMCI1B } 63#define MMCI1_IRQ { IRQ_MMCI1A, IRQ_SIC_MMCI1B }
64 64
65/* 65/*
66 * These devices are connected via the core APB bridge 66 * These devices are connected via the core APB bridge
67 */ 67 */
68#define GPIO2_IRQ { IRQ_GPIOINT2, NO_IRQ } 68#define GPIO2_IRQ { IRQ_GPIOINT2 }
69#define GPIO3_IRQ { IRQ_GPIOINT3, NO_IRQ } 69#define GPIO3_IRQ { IRQ_GPIOINT3 }
70 70
71/* 71/*
72 * These devices are connected via the DMA APB bridge 72 * These devices are connected via the DMA APB bridge
73 */ 73 */
74 74
75/* FPGA Primecells */ 75/* FPGA Primecells */
76AMBA_DEVICE(uart3, "fpga:09", UART3, NULL); 76APB_DEVICE(uart3, "fpga:09", UART3, NULL);
77AMBA_DEVICE(sci1, "fpga:0a", SCI1, NULL); 77APB_DEVICE(sci1, "fpga:0a", SCI1, NULL);
78AMBA_DEVICE(mmc1, "fpga:0b", MMCI1, &mmc1_plat_data); 78APB_DEVICE(mmc1, "fpga:0b", MMCI1, &mmc1_plat_data);
79 79
80/* DevChip Primecells */ 80/* DevChip Primecells */
81AMBA_DEVICE(gpio2, "dev:e6", GPIO2, &gpio2_plat_data); 81APB_DEVICE(gpio2, "dev:e6", GPIO2, &gpio2_plat_data);
82AMBA_DEVICE(gpio3, "dev:e7", GPIO3, &gpio3_plat_data); 82APB_DEVICE(gpio3, "dev:e7", GPIO3, &gpio3_plat_data);
83 83
84static struct amba_device *amba_devs[] __initdata = { 84static struct amba_device *amba_devs[] __initdata = {
85 &uart3_device, 85 &uart3_device,
diff --git a/arch/arm/mach-vexpress/Kconfig b/arch/arm/mach-vexpress/Kconfig
index 88c3ba151e8..cf8730d35e7 100644
--- a/arch/arm/mach-vexpress/Kconfig
+++ b/arch/arm/mach-vexpress/Kconfig
@@ -1,14 +1,55 @@
1menu "Versatile Express platform type" 1menu "Versatile Express platform type"
2 depends on ARCH_VEXPRESS 2 depends on ARCH_VEXPRESS
3 3
4config ARCH_VEXPRESS_CORTEX_A5_A9_ERRATA
5 bool
6 select ARM_ERRATA_720789
7 select ARM_ERRATA_751472
8 select PL310_ERRATA_753970 if CACHE_PL310
9 help
10 Provides common dependencies for Versatile Express platforms
11 based on Cortex-A5 and Cortex-A9 processors. In order to
12 build a working kernel, you must also enable relevant core
13 tile support or Flattened Device Tree based support options.
14
4config ARCH_VEXPRESS_CA9X4 15config ARCH_VEXPRESS_CA9X4
5 bool "Versatile Express Cortex-A9x4 tile" 16 bool "Versatile Express Cortex-A9x4 tile"
17 select ARCH_VEXPRESS_CORTEX_A5_A9_ERRATA
18 select ARM_GIC
6 select CPU_V7 19 select CPU_V7
20 select HAVE_SMP
21 select MIGHT_HAVE_CACHE_L2X0
22
23config ARCH_VEXPRESS_DT
24 bool "Device Tree support for Versatile Express platforms"
25 select ARCH_VEXPRESS_CORTEX_A5_A9_ERRATA
7 select ARM_GIC 26 select ARM_GIC
8 select ARM_ERRATA_720789 27 select ARM_PATCH_PHYS_VIRT
9 select ARM_ERRATA_751472 28 select AUTO_ZRELADDR
10 select PL310_ERRATA_753970 29 select CPU_V7
11 select HAVE_SMP 30 select HAVE_SMP
12 select MIGHT_HAVE_CACHE_L2X0 31 select MIGHT_HAVE_CACHE_L2X0
32 select USE_OF
33 help
34 New Versatile Express platforms require Flattened Device Tree to
35 be passed to the kernel.
36
37 This option enables support for systems using Cortex processor based
38 ARM core and logic (FPGA) tiles on the Versatile Express motherboard,
39 for example:
40
41 - CoreTile Express A5x2 (V2P-CA5s)
42 - CoreTile Express A9x4 (V2P-CA9)
43 - CoreTile Express A15x2 (V2P-CA15)
44 - LogicTile Express 13MG (V2F-2XV6) with A5, A7, A9 or A15 SMMs
45 (Soft Macrocell Models)
46 - Versatile Express RTSMs (Models)
47
48 You must boot using a Flattened Device Tree in order to use these
49 platforms. The traditional (ATAGs) boot method is not usable on
50 these boards with this option.
51
52 If your bootloader supports Flattened Device Tree based booting,
53 say Y here.
13 54
14endmenu 55endmenu
diff --git a/arch/arm/mach-vexpress/Makefile.boot b/arch/arm/mach-vexpress/Makefile.boot
index 8630b3d10a4..909f85ebf5f 100644
--- a/arch/arm/mach-vexpress/Makefile.boot
+++ b/arch/arm/mach-vexpress/Makefile.boot
@@ -1,3 +1,9 @@
1# Those numbers are used only by the non-DT V2P-CA9 platform
2# The DT-enabled ones require CONFIG_AUTO_ZRELADDR=y
1 zreladdr-y += 0x60008000 3 zreladdr-y += 0x60008000
2params_phys-y := 0x60000100 4params_phys-y := 0x60000100
3initrd_phys-y := 0x60800000 5initrd_phys-y := 0x60800000
6
7dtb-$(CONFIG_ARCH_VEXPRESS_DT) += vexpress-v2p-ca5s.dtb \
8 vexpress-v2p-ca9.dtb \
9 vexpress-v2p-ca15-tc1.dtb
diff --git a/arch/arm/mach-vexpress/core.h b/arch/arm/mach-vexpress/core.h
index f4397159c17..a3a4980770b 100644
--- a/arch/arm/mach-vexpress/core.h
+++ b/arch/arm/mach-vexpress/core.h
@@ -1,19 +1,7 @@
1#define __MMIO_P2V(x) (((x) & 0xfffff) | (((x) & 0x0f000000) >> 4) | 0xf8000000) 1/* 2MB large area for motherboard's peripherals static mapping */
2#define MMIO_P2V(x) ((void __iomem *)__MMIO_P2V(x)) 2#define V2M_PERIPH 0xf8000000
3 3
4#define AMBA_DEVICE(name,busid,base,plat) \ 4/* Tile's peripherals static mappings should start here */
5struct amba_device name##_device = { \ 5#define V2T_PERIPH 0xf8200000
6 .dev = { \ 6
7 .coherent_dma_mask = ~0UL, \ 7void vexpress_dt_smp_map_io(void);
8 .init_name = busid, \
9 .platform_data = plat, \
10 }, \
11 .res = { \
12 .start = base, \
13 .end = base + SZ_4K - 1, \
14 .flags = IORESOURCE_MEM, \
15 }, \
16 .dma_mask = ~0UL, \
17 .irq = IRQ_##base, \
18 /* .dma = DMA_##base,*/ \
19}
diff --git a/arch/arm/mach-vexpress/ct-ca9x4.c b/arch/arm/mach-vexpress/ct-ca9x4.c
index b1e87c184e5..c65cc3b462a 100644
--- a/arch/arm/mach-vexpress/ct-ca9x4.c
+++ b/arch/arm/mach-vexpress/ct-ca9x4.c
@@ -30,57 +30,40 @@
30 30
31#include <plat/clcd.h> 31#include <plat/clcd.h>
32 32
33#define V2M_PA_CS7 0x10000000
34
35static struct map_desc ct_ca9x4_io_desc[] __initdata = { 33static struct map_desc ct_ca9x4_io_desc[] __initdata = {
36 { 34 {
37 .virtual = __MMIO_P2V(CT_CA9X4_MPIC), 35 .virtual = V2T_PERIPH,
38 .pfn = __phys_to_pfn(CT_CA9X4_MPIC), 36 .pfn = __phys_to_pfn(CT_CA9X4_MPIC),
39 .length = SZ_16K, 37 .length = SZ_8K,
40 .type = MT_DEVICE, 38 .type = MT_DEVICE,
41 }, {
42 .virtual = __MMIO_P2V(CT_CA9X4_SP804_TIMER),
43 .pfn = __phys_to_pfn(CT_CA9X4_SP804_TIMER),
44 .length = SZ_4K,
45 .type = MT_DEVICE,
46 }, {
47 .virtual = __MMIO_P2V(CT_CA9X4_L2CC),
48 .pfn = __phys_to_pfn(CT_CA9X4_L2CC),
49 .length = SZ_4K,
50 .type = MT_DEVICE,
51 }, 39 },
52}; 40};
53 41
54static void __init ct_ca9x4_map_io(void) 42static void __init ct_ca9x4_map_io(void)
55{ 43{
56#ifdef CONFIG_LOCAL_TIMERS
57 twd_base = MMIO_P2V(A9_MPCORE_TWD);
58#endif
59 iotable_init(ct_ca9x4_io_desc, ARRAY_SIZE(ct_ca9x4_io_desc)); 44 iotable_init(ct_ca9x4_io_desc, ARRAY_SIZE(ct_ca9x4_io_desc));
60} 45}
61 46
62static void __init ct_ca9x4_init_irq(void) 47#ifdef CONFIG_HAVE_ARM_TWD
48static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, A9_MPCORE_TWD, IRQ_LOCALTIMER);
49
50static void __init ca9x4_twd_init(void)
63{ 51{
64 gic_init(0, 29, MMIO_P2V(A9_MPCORE_GIC_DIST), 52 int err = twd_local_timer_register(&twd_local_timer);
65 MMIO_P2V(A9_MPCORE_GIC_CPU)); 53 if (err)
54 pr_err("twd_local_timer_register failed %d\n", err);
66} 55}
56#else
57#define ca9x4_twd_init() do {} while(0)
58#endif
67 59
68#if 0 60static void __init ct_ca9x4_init_irq(void)
69static void __init ct_ca9x4_timer_init(void)
70{ 61{
71 writel(0, MMIO_P2V(CT_CA9X4_TIMER0) + TIMER_CTRL); 62 gic_init(0, 29, ioremap(A9_MPCORE_GIC_DIST, SZ_4K),
72 writel(0, MMIO_P2V(CT_CA9X4_TIMER1) + TIMER_CTRL); 63 ioremap(A9_MPCORE_GIC_CPU, SZ_256));
73 64 ca9x4_twd_init();
74 sp804_clocksource_init(MMIO_P2V(CT_CA9X4_TIMER1), "ct-timer1");
75 sp804_clockevents_init(MMIO_P2V(CT_CA9X4_TIMER0), IRQ_CT_CA9X4_TIMER0,
76 "ct-timer0");
77} 65}
78 66
79static struct sys_timer ct_ca9x4_timer = {
80 .init = ct_ca9x4_timer_init,
81};
82#endif
83
84static void ct_ca9x4_clcd_enable(struct clcd_fb *fb) 67static void ct_ca9x4_clcd_enable(struct clcd_fb *fb)
85{ 68{
86 v2m_cfg_write(SYS_CFG_MUXFPGA | SYS_CFG_SITE_DB1, 0); 69 v2m_cfg_write(SYS_CFG_MUXFPGA | SYS_CFG_SITE_DB1, 0);
@@ -109,10 +92,10 @@ static struct clcd_board ct_ca9x4_clcd_data = {
109 .remove = versatile_clcd_remove_dma, 92 .remove = versatile_clcd_remove_dma,
110}; 93};
111 94
112static AMBA_DEVICE(clcd, "ct:clcd", CT_CA9X4_CLCDC, &ct_ca9x4_clcd_data); 95static AMBA_AHB_DEVICE(clcd, "ct:clcd", 0, CT_CA9X4_CLCDC, IRQ_CT_CA9X4_CLCDC, &ct_ca9x4_clcd_data);
113static AMBA_DEVICE(dmc, "ct:dmc", CT_CA9X4_DMC, NULL); 96static AMBA_APB_DEVICE(dmc, "ct:dmc", 0, CT_CA9X4_DMC, IRQ_CT_CA9X4_DMC, NULL);
114static AMBA_DEVICE(smc, "ct:smc", CT_CA9X4_SMC, NULL); 97static AMBA_APB_DEVICE(smc, "ct:smc", 0, CT_CA9X4_SMC, IRQ_CT_CA9X4_SMC, NULL);
115static AMBA_DEVICE(gpio, "ct:gpio", CT_CA9X4_GPIO, NULL); 98static AMBA_APB_DEVICE(gpio, "ct:gpio", 0, CT_CA9X4_GPIO, IRQ_CT_CA9X4_GPIO, NULL);
116 99
117static struct amba_device *ct_ca9x4_amba_devs[] __initdata = { 100static struct amba_device *ct_ca9x4_amba_devs[] __initdata = {
118 &clcd_device, 101 &clcd_device,
@@ -201,7 +184,7 @@ static void __init ct_ca9x4_init(void)
201 int i; 184 int i;
202 185
203#ifdef CONFIG_CACHE_L2X0 186#ifdef CONFIG_CACHE_L2X0
204 void __iomem *l2x0_base = MMIO_P2V(CT_CA9X4_L2CC); 187 void __iomem *l2x0_base = ioremap(CT_CA9X4_L2CC, SZ_4K);
205 188
206 /* set RAM latencies to 1 cycle for this core tile. */ 189 /* set RAM latencies to 1 cycle for this core tile. */
207 writel(0, l2x0_base + L2X0_TAG_LATENCY_CTRL); 190 writel(0, l2x0_base + L2X0_TAG_LATENCY_CTRL);
@@ -217,9 +200,17 @@ static void __init ct_ca9x4_init(void)
217} 200}
218 201
219#ifdef CONFIG_SMP 202#ifdef CONFIG_SMP
203static void *ct_ca9x4_scu_base __initdata;
204
220static void __init ct_ca9x4_init_cpu_map(void) 205static void __init ct_ca9x4_init_cpu_map(void)
221{ 206{
222 int i, ncores = scu_get_core_count(MMIO_P2V(A9_MPCORE_SCU)); 207 int i, ncores;
208
209 ct_ca9x4_scu_base = ioremap(A9_MPCORE_SCU, SZ_128);
210 if (WARN_ON(!ct_ca9x4_scu_base))
211 return;
212
213 ncores = scu_get_core_count(ct_ca9x4_scu_base);
223 214
224 if (ncores > nr_cpu_ids) { 215 if (ncores > nr_cpu_ids) {
225 pr_warn("SMP: %u cores greater than maximum (%u), clipping\n", 216 pr_warn("SMP: %u cores greater than maximum (%u), clipping\n",
@@ -235,7 +226,7 @@ static void __init ct_ca9x4_init_cpu_map(void)
235 226
236static void __init ct_ca9x4_smp_enable(unsigned int max_cpus) 227static void __init ct_ca9x4_smp_enable(unsigned int max_cpus)
237{ 228{
238 scu_enable(MMIO_P2V(A9_MPCORE_SCU)); 229 scu_enable(ct_ca9x4_scu_base);
239} 230}
240#endif 231#endif
241 232
diff --git a/arch/arm/mach-vexpress/include/mach/ct-ca9x4.h b/arch/arm/mach-vexpress/include/mach/ct-ca9x4.h
index a34d3d4faae..84acf8439d4 100644
--- a/arch/arm/mach-vexpress/include/mach/ct-ca9x4.h
+++ b/arch/arm/mach-vexpress/include/mach/ct-ca9x4.h
@@ -22,9 +22,6 @@
22#define CT_CA9X4_SYSWDT (0x1e007000) 22#define CT_CA9X4_SYSWDT (0x1e007000)
23#define CT_CA9X4_L2CC (0x1e00a000) 23#define CT_CA9X4_L2CC (0x1e00a000)
24 24
25#define CT_CA9X4_TIMER0 (CT_CA9X4_SP804_TIMER + 0x000)
26#define CT_CA9X4_TIMER1 (CT_CA9X4_SP804_TIMER + 0x020)
27
28#define A9_MPCORE_SCU (CT_CA9X4_MPIC + 0x0000) 25#define A9_MPCORE_SCU (CT_CA9X4_MPIC + 0x0000)
29#define A9_MPCORE_GIC_CPU (CT_CA9X4_MPIC + 0x0100) 26#define A9_MPCORE_GIC_CPU (CT_CA9X4_MPIC + 0x0100)
30#define A9_MPCORE_GIT (CT_CA9X4_MPIC + 0x0200) 27#define A9_MPCORE_GIT (CT_CA9X4_MPIC + 0x0200)
@@ -35,7 +32,7 @@
35 * Interrupts. Those in {} are for AMBA devices 32 * Interrupts. Those in {} are for AMBA devices
36 */ 33 */
37#define IRQ_CT_CA9X4_CLCDC { 76 } 34#define IRQ_CT_CA9X4_CLCDC { 76 }
38#define IRQ_CT_CA9X4_DMC { -1 } 35#define IRQ_CT_CA9X4_DMC { 0 }
39#define IRQ_CT_CA9X4_SMC { 77, 78 } 36#define IRQ_CT_CA9X4_SMC { 77, 78 }
40#define IRQ_CT_CA9X4_TIMER0 80 37#define IRQ_CT_CA9X4_TIMER0 80
41#define IRQ_CT_CA9X4_TIMER1 81 38#define IRQ_CT_CA9X4_TIMER1 81
diff --git a/arch/arm/mach-vexpress/include/mach/debug-macro.S b/arch/arm/mach-vexpress/include/mach/debug-macro.S
index fd9e6c7ea49..fa8224794e0 100644
--- a/arch/arm/mach-vexpress/include/mach/debug-macro.S
+++ b/arch/arm/mach-vexpress/include/mach/debug-macro.S
@@ -10,12 +10,34 @@
10 * published by the Free Software Foundation. 10 * published by the Free Software Foundation.
11 */ 11 */
12 12
13#define DEBUG_LL_UART_OFFSET 0x00009000 13#define DEBUG_LL_PHYS_BASE 0x10000000
14#define DEBUG_LL_UART_OFFSET 0x00009000
15
16#define DEBUG_LL_PHYS_BASE_RS1 0x1c000000
17#define DEBUG_LL_UART_OFFSET_RS1 0x00090000
18
19#define DEBUG_LL_VIRT_BASE 0xf8000000
14 20
15 .macro addruart,rp,rv,tmp 21 .macro addruart,rp,rv,tmp
16 mov \rp, #DEBUG_LL_UART_OFFSET 22
17 orr \rv, \rp, #0xf8000000 @ virtual base 23 @ Make an educated guess regarding the memory map:
18 orr \rp, \rp, #0x10000000 @ physical base 24 @ - the original A9 core tile, which has MPCore peripherals
25 @ located at 0x1e000000, should use UART at 0x10009000
26 @ - all other (RS1 complaint) tiles use UART mapped
27 @ at 0x1c090000
28 mrc p15, 4, \tmp, c15, c0, 0
29 cmp \tmp, #0x1e000000
30
31 @ Original memory map
32 moveq \rp, #DEBUG_LL_UART_OFFSET
33 orreq \rv, \rp, #DEBUG_LL_VIRT_BASE
34 orreq \rp, \rp, #DEBUG_LL_PHYS_BASE
35
36 @ RS1 memory map
37 movne \rp, #DEBUG_LL_UART_OFFSET_RS1
38 orrne \rv, \rp, #DEBUG_LL_VIRT_BASE
39 orrne \rp, \rp, #DEBUG_LL_PHYS_BASE_RS1
40
19 .endm 41 .endm
20 42
21#include <asm/hardware/debug-pl01x.S> 43#include <asm/hardware/debug-pl01x.S>
diff --git a/arch/arm/mach-vexpress/include/mach/entry-macro.S b/arch/arm/mach-vexpress/include/mach/entry-macro.S
deleted file mode 100644
index a14f9e62ca9..00000000000
--- a/arch/arm/mach-vexpress/include/mach/entry-macro.S
+++ /dev/null
@@ -1,5 +0,0 @@
1 .macro disable_fiq
2 .endm
3
4 .macro arch_ret_to_user, tmp1, tmp2
5 .endm
diff --git a/arch/arm/mach-vexpress/include/mach/irqs.h b/arch/arm/mach-vexpress/include/mach/irqs.h
index 7054cbfc9de..4b10ee7657a 100644
--- a/arch/arm/mach-vexpress/include/mach/irqs.h
+++ b/arch/arm/mach-vexpress/include/mach/irqs.h
@@ -1,4 +1,4 @@
1#define IRQ_LOCALTIMER 29 1#define IRQ_LOCALTIMER 29
2#define IRQ_LOCALWDOG 30 2#define IRQ_LOCALWDOG 30
3 3
4#define NR_IRQS 128 4#define NR_IRQS 256
diff --git a/arch/arm/mach-vexpress/include/mach/motherboard.h b/arch/arm/mach-vexpress/include/mach/motherboard.h
index 0a3a3751840..31a92890893 100644
--- a/arch/arm/mach-vexpress/include/mach/motherboard.h
+++ b/arch/arm/mach-vexpress/include/mach/motherboard.h
@@ -39,33 +39,30 @@
39#define V2M_CF (V2M_PA_CS7 + 0x0001a000) 39#define V2M_CF (V2M_PA_CS7 + 0x0001a000)
40#define V2M_CLCD (V2M_PA_CS7 + 0x0001f000) 40#define V2M_CLCD (V2M_PA_CS7 + 0x0001f000)
41 41
42#define V2M_SYS_ID (V2M_SYSREGS + 0x000) 42/*
43#define V2M_SYS_SW (V2M_SYSREGS + 0x004) 43 * Offsets from SYSREGS base
44#define V2M_SYS_LED (V2M_SYSREGS + 0x008) 44 */
45#define V2M_SYS_100HZ (V2M_SYSREGS + 0x024) 45#define V2M_SYS_ID 0x000
46#define V2M_SYS_FLAGS (V2M_SYSREGS + 0x030) 46#define V2M_SYS_SW 0x004
47#define V2M_SYS_FLAGSSET (V2M_SYSREGS + 0x030) 47#define V2M_SYS_LED 0x008
48#define V2M_SYS_FLAGSCLR (V2M_SYSREGS + 0x034) 48#define V2M_SYS_100HZ 0x024
49#define V2M_SYS_NVFLAGS (V2M_SYSREGS + 0x038) 49#define V2M_SYS_FLAGS 0x030
50#define V2M_SYS_NVFLAGSSET (V2M_SYSREGS + 0x038) 50#define V2M_SYS_FLAGSSET 0x030
51#define V2M_SYS_NVFLAGSCLR (V2M_SYSREGS + 0x03c) 51#define V2M_SYS_FLAGSCLR 0x034
52#define V2M_SYS_MCI (V2M_SYSREGS + 0x048) 52#define V2M_SYS_NVFLAGS 0x038
53#define V2M_SYS_FLASH (V2M_SYSREGS + 0x03c) 53#define V2M_SYS_NVFLAGSSET 0x038
54#define V2M_SYS_CFGSW (V2M_SYSREGS + 0x058) 54#define V2M_SYS_NVFLAGSCLR 0x03c
55#define V2M_SYS_24MHZ (V2M_SYSREGS + 0x05c) 55#define V2M_SYS_MCI 0x048
56#define V2M_SYS_MISC (V2M_SYSREGS + 0x060) 56#define V2M_SYS_FLASH 0x03c
57#define V2M_SYS_DMA (V2M_SYSREGS + 0x064) 57#define V2M_SYS_CFGSW 0x058
58#define V2M_SYS_PROCID0 (V2M_SYSREGS + 0x084) 58#define V2M_SYS_24MHZ 0x05c
59#define V2M_SYS_PROCID1 (V2M_SYSREGS + 0x088) 59#define V2M_SYS_MISC 0x060
60#define V2M_SYS_CFGDATA (V2M_SYSREGS + 0x0a0) 60#define V2M_SYS_DMA 0x064
61#define V2M_SYS_CFGCTRL (V2M_SYSREGS + 0x0a4) 61#define V2M_SYS_PROCID0 0x084
62#define V2M_SYS_CFGSTAT (V2M_SYSREGS + 0x0a8) 62#define V2M_SYS_PROCID1 0x088
63 63#define V2M_SYS_CFGDATA 0x0a0
64#define V2M_TIMER0 (V2M_TIMER01 + 0x000) 64#define V2M_SYS_CFGCTRL 0x0a4
65#define V2M_TIMER1 (V2M_TIMER01 + 0x020) 65#define V2M_SYS_CFGSTAT 0x0a8
66
67#define V2M_TIMER2 (V2M_TIMER23 + 0x000)
68#define V2M_TIMER3 (V2M_TIMER23 + 0x020)
69 66
70 67
71/* 68/*
@@ -117,6 +114,13 @@
117 114
118int v2m_cfg_write(u32 devfn, u32 data); 115int v2m_cfg_write(u32 devfn, u32 data);
119int v2m_cfg_read(u32 devfn, u32 *data); 116int v2m_cfg_read(u32 devfn, u32 *data);
117void v2m_flags_set(u32 data);
118
119/*
120 * Miscellaneous
121 */
122#define SYS_MISC_MASTERSITE (1 << 14)
123#define SYS_PROCIDx_HBI_MASK 0xfff
120 124
121/* 125/*
122 * Core tile IDs 126 * Core tile IDs
diff --git a/arch/arm/mach-vexpress/include/mach/system.h b/arch/arm/mach-vexpress/include/mach/system.h
deleted file mode 100644
index f653a8e265b..00000000000
--- a/arch/arm/mach-vexpress/include/mach/system.h
+++ /dev/null
@@ -1,33 +0,0 @@
1/*
2 * arch/arm/mach-vexpress/include/mach/system.h
3 *
4 * Copyright (C) 2003 ARM Limited
5 * Copyright (C) 2000 Deep Blue Solutions Ltd
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 USA
20 */
21#ifndef __ASM_ARCH_SYSTEM_H
22#define __ASM_ARCH_SYSTEM_H
23
24static inline void arch_idle(void)
25{
26 /*
27 * This should do all the clock switching
28 * and wait for interrupt tricks
29 */
30 cpu_do_idle();
31}
32
33#endif
diff --git a/arch/arm/mach-vexpress/include/mach/uncompress.h b/arch/arm/mach-vexpress/include/mach/uncompress.h
index 7972c5748d0..7dab5596b86 100644
--- a/arch/arm/mach-vexpress/include/mach/uncompress.h
+++ b/arch/arm/mach-vexpress/include/mach/uncompress.h
@@ -22,7 +22,27 @@
22#define AMBA_UART_CR(base) (*(volatile unsigned char *)((base) + 0x30)) 22#define AMBA_UART_CR(base) (*(volatile unsigned char *)((base) + 0x30))
23#define AMBA_UART_FR(base) (*(volatile unsigned char *)((base) + 0x18)) 23#define AMBA_UART_FR(base) (*(volatile unsigned char *)((base) + 0x18))
24 24
25#define get_uart_base() (0x10000000 + 0x00009000) 25#define UART_BASE 0x10009000
26#define UART_BASE_RS1 0x1c090000
27
28static unsigned long get_uart_base(void)
29{
30 unsigned long mpcore_periph;
31
32 /*
33 * Make an educated guess regarding the memory map:
34 * - the original A9 core tile, which has MPCore peripherals
35 * located at 0x1e000000, should use UART at 0x10009000
36 * - all other (RS1 complaint) tiles use UART mapped
37 * at 0x1c090000
38 */
39 asm("mrc p15, 4, %0, c15, c0, 0" : "=r" (mpcore_periph));
40
41 if (mpcore_periph == 0x1e000000)
42 return UART_BASE;
43 else
44 return UART_BASE_RS1;
45}
26 46
27/* 47/*
28 * This does not append a newline 48 * This does not append a newline
diff --git a/arch/arm/mach-vexpress/platsmp.c b/arch/arm/mach-vexpress/platsmp.c
index 124ffb16909..14ba1128ae8 100644
--- a/arch/arm/mach-vexpress/platsmp.c
+++ b/arch/arm/mach-vexpress/platsmp.c
@@ -12,21 +12,168 @@
12#include <linux/errno.h> 12#include <linux/errno.h>
13#include <linux/smp.h> 13#include <linux/smp.h>
14#include <linux/io.h> 14#include <linux/io.h>
15#include <linux/of_fdt.h>
16
17#include <asm/smp_scu.h>
18#include <asm/hardware/gic.h>
19#include <asm/mach/map.h>
15 20
16#include <mach/motherboard.h> 21#include <mach/motherboard.h>
17#define V2M_PA_CS7 0x10000000
18 22
19#include "core.h" 23#include "core.h"
20 24
21extern void versatile_secondary_startup(void); 25extern void versatile_secondary_startup(void);
22 26
27#if defined(CONFIG_OF)
28
29static enum {
30 GENERIC_SCU,
31 CORTEX_A9_SCU,
32} vexpress_dt_scu __initdata = GENERIC_SCU;
33
34static struct map_desc vexpress_dt_cortex_a9_scu_map __initdata = {
35 .virtual = V2T_PERIPH,
36 /* .pfn set in vexpress_dt_init_cortex_a9_scu() */
37 .length = SZ_128,
38 .type = MT_DEVICE,
39};
40
41static void *vexpress_dt_cortex_a9_scu_base __initdata;
42
43const static char *vexpress_dt_cortex_a9_match[] __initconst = {
44 "arm,cortex-a5-scu",
45 "arm,cortex-a9-scu",
46 NULL
47};
48
49static int __init vexpress_dt_find_scu(unsigned long node,
50 const char *uname, int depth, void *data)
51{
52 if (of_flat_dt_match(node, vexpress_dt_cortex_a9_match)) {
53 phys_addr_t phys_addr;
54 __be32 *reg = of_get_flat_dt_prop(node, "reg", NULL);
55
56 if (WARN_ON(!reg))
57 return -EINVAL;
58
59 phys_addr = be32_to_cpup(reg);
60 vexpress_dt_scu = CORTEX_A9_SCU;
61
62 vexpress_dt_cortex_a9_scu_map.pfn = __phys_to_pfn(phys_addr);
63 iotable_init(&vexpress_dt_cortex_a9_scu_map, 1);
64 vexpress_dt_cortex_a9_scu_base = ioremap(phys_addr, SZ_256);
65 if (WARN_ON(!vexpress_dt_cortex_a9_scu_base))
66 return -EFAULT;
67 }
68
69 return 0;
70}
71
72void __init vexpress_dt_smp_map_io(void)
73{
74 if (initial_boot_params)
75 WARN_ON(of_scan_flat_dt(vexpress_dt_find_scu, NULL));
76}
77
78static int __init vexpress_dt_cpus_num(unsigned long node, const char *uname,
79 int depth, void *data)
80{
81 static int prev_depth = -1;
82 static int nr_cpus = -1;
83
84 if (prev_depth > depth && nr_cpus > 0)
85 return nr_cpus;
86
87 if (nr_cpus < 0 && strcmp(uname, "cpus") == 0)
88 nr_cpus = 0;
89
90 if (nr_cpus >= 0) {
91 const char *device_type = of_get_flat_dt_prop(node,
92 "device_type", NULL);
93
94 if (device_type && strcmp(device_type, "cpu") == 0)
95 nr_cpus++;
96 }
97
98 prev_depth = depth;
99
100 return 0;
101}
102
103static void __init vexpress_dt_smp_init_cpus(void)
104{
105 int ncores = 0, i;
106
107 switch (vexpress_dt_scu) {
108 case GENERIC_SCU:
109 ncores = of_scan_flat_dt(vexpress_dt_cpus_num, NULL);
110 break;
111 case CORTEX_A9_SCU:
112 ncores = scu_get_core_count(vexpress_dt_cortex_a9_scu_base);
113 break;
114 default:
115 WARN_ON(1);
116 break;
117 }
118
119 if (ncores < 2)
120 return;
121
122 if (ncores > nr_cpu_ids) {
123 pr_warn("SMP: %u cores greater than maximum (%u), clipping\n",
124 ncores, nr_cpu_ids);
125 ncores = nr_cpu_ids;
126 }
127
128 for (i = 0; i < ncores; ++i)
129 set_cpu_possible(i, true);
130
131 set_smp_cross_call(gic_raise_softirq);
132}
133
134static void __init vexpress_dt_smp_prepare_cpus(unsigned int max_cpus)
135{
136 int i;
137
138 switch (vexpress_dt_scu) {
139 case GENERIC_SCU:
140 for (i = 0; i < max_cpus; i++)
141 set_cpu_present(i, true);
142 break;
143 case CORTEX_A9_SCU:
144 scu_enable(vexpress_dt_cortex_a9_scu_base);
145 break;
146 default:
147 WARN_ON(1);
148 break;
149 }
150}
151
152#else
153
154static void __init vexpress_dt_smp_init_cpus(void)
155{
156 WARN_ON(1);
157}
158
159void __init vexpress_dt_smp_prepare_cpus(unsigned int max_cpus)
160{
161 WARN_ON(1);
162}
163
164#endif
165
23/* 166/*
24 * Initialise the CPU possible map early - this describes the CPUs 167 * Initialise the CPU possible map early - this describes the CPUs
25 * which may be present or become present in the system. 168 * which may be present or become present in the system.
26 */ 169 */
27void __init smp_init_cpus(void) 170void __init smp_init_cpus(void)
28{ 171{
29 ct_desc->init_cpu_map(); 172 if (ct_desc)
173 ct_desc->init_cpu_map();
174 else
175 vexpress_dt_smp_init_cpus();
176
30} 177}
31 178
32void __init platform_smp_prepare_cpus(unsigned int max_cpus) 179void __init platform_smp_prepare_cpus(unsigned int max_cpus)
@@ -35,7 +182,10 @@ void __init platform_smp_prepare_cpus(unsigned int max_cpus)
35 * Initialise the present map, which describes the set of CPUs 182 * Initialise the present map, which describes the set of CPUs
36 * actually populated at the present time. 183 * actually populated at the present time.
37 */ 184 */
38 ct_desc->smp_enable(max_cpus); 185 if (ct_desc)
186 ct_desc->smp_enable(max_cpus);
187 else
188 vexpress_dt_smp_prepare_cpus(max_cpus);
39 189
40 /* 190 /*
41 * Write the address of secondary startup into the 191 * Write the address of secondary startup into the
@@ -43,7 +193,5 @@ void __init platform_smp_prepare_cpus(unsigned int max_cpus)
43 * until it receives a soft interrupt, and then the 193 * until it receives a soft interrupt, and then the
44 * secondary CPU branches to this address. 194 * secondary CPU branches to this address.
45 */ 195 */
46 writel(~0, MMIO_P2V(V2M_SYS_FLAGSCLR)); 196 v2m_flags_set(virt_to_phys(versatile_secondary_startup));
47 writel(virt_to_phys(versatile_secondary_startup),
48 MMIO_P2V(V2M_SYS_FLAGSSET));
49} 197}
diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c
index b4a28ca0e50..47cdcca5a7e 100644
--- a/arch/arm/mach-vexpress/v2m.c
+++ b/arch/arm/mach-vexpress/v2m.c
@@ -6,6 +6,10 @@
6#include <linux/amba/mmci.h> 6#include <linux/amba/mmci.h>
7#include <linux/io.h> 7#include <linux/io.h>
8#include <linux/init.h> 8#include <linux/init.h>
9#include <linux/of_address.h>
10#include <linux/of_fdt.h>
11#include <linux/of_irq.h>
12#include <linux/of_platform.h>
9#include <linux/platform_device.h> 13#include <linux/platform_device.h>
10#include <linux/ata_platform.h> 14#include <linux/ata_platform.h>
11#include <linux/smsc911x.h> 15#include <linux/smsc911x.h>
@@ -21,6 +25,8 @@
21#include <asm/mach/map.h> 25#include <asm/mach/map.h>
22#include <asm/mach/time.h> 26#include <asm/mach/time.h>
23#include <asm/hardware/arm_timer.h> 27#include <asm/hardware/arm_timer.h>
28#include <asm/hardware/cache-l2x0.h>
29#include <asm/hardware/gic.h>
24#include <asm/hardware/timer-sp.h> 30#include <asm/hardware/timer-sp.h>
25#include <asm/hardware/sp810.h> 31#include <asm/hardware/sp810.h>
26#include <asm/hardware/gic.h> 32#include <asm/hardware/gic.h>
@@ -40,29 +46,45 @@
40 46
41static struct map_desc v2m_io_desc[] __initdata = { 47static struct map_desc v2m_io_desc[] __initdata = {
42 { 48 {
43 .virtual = __MMIO_P2V(V2M_PA_CS7), 49 .virtual = V2M_PERIPH,
44 .pfn = __phys_to_pfn(V2M_PA_CS7), 50 .pfn = __phys_to_pfn(V2M_PA_CS7),
45 .length = SZ_128K, 51 .length = SZ_128K,
46 .type = MT_DEVICE, 52 .type = MT_DEVICE,
47 }, 53 },
48}; 54};
49 55
50static void __init v2m_timer_init(void) 56static void __iomem *v2m_sysreg_base;
57
58static void __init v2m_sysctl_init(void __iomem *base)
51{ 59{
52 u32 scctrl; 60 u32 scctrl;
53 61
62 if (WARN_ON(!base))
63 return;
64
54 /* Select 1MHz TIMCLK as the reference clock for SP804 timers */ 65 /* Select 1MHz TIMCLK as the reference clock for SP804 timers */
55 scctrl = readl(MMIO_P2V(V2M_SYSCTL + SCCTRL)); 66 scctrl = readl(base + SCCTRL);
56 scctrl |= SCCTRL_TIMEREN0SEL_TIMCLK; 67 scctrl |= SCCTRL_TIMEREN0SEL_TIMCLK;
57 scctrl |= SCCTRL_TIMEREN1SEL_TIMCLK; 68 scctrl |= SCCTRL_TIMEREN1SEL_TIMCLK;
58 writel(scctrl, MMIO_P2V(V2M_SYSCTL + SCCTRL)); 69 writel(scctrl, base + SCCTRL);
70}
71
72static void __init v2m_sp804_init(void __iomem *base, unsigned int irq)
73{
74 if (WARN_ON(!base || irq == NO_IRQ))
75 return;
76
77 writel(0, base + TIMER_1_BASE + TIMER_CTRL);
78 writel(0, base + TIMER_2_BASE + TIMER_CTRL);
59 79
60 writel(0, MMIO_P2V(V2M_TIMER0) + TIMER_CTRL); 80 sp804_clocksource_init(base + TIMER_2_BASE, "v2m-timer1");
61 writel(0, MMIO_P2V(V2M_TIMER1) + TIMER_CTRL); 81 sp804_clockevents_init(base + TIMER_1_BASE, irq, "v2m-timer0");
82}
62 83
63 sp804_clocksource_init(MMIO_P2V(V2M_TIMER1), "v2m-timer1"); 84static void __init v2m_timer_init(void)
64 sp804_clockevents_init(MMIO_P2V(V2M_TIMER0), IRQ_V2M_TIMER0, 85{
65 "v2m-timer0"); 86 v2m_sysctl_init(ioremap(V2M_SYSCTL, SZ_4K));
87 v2m_sp804_init(ioremap(V2M_TIMER01, SZ_4K), IRQ_V2M_TIMER0);
66} 88}
67 89
68static struct sys_timer v2m_timer = { 90static struct sys_timer v2m_timer = {
@@ -82,14 +104,14 @@ int v2m_cfg_write(u32 devfn, u32 data)
82 devfn |= SYS_CFG_START | SYS_CFG_WRITE; 104 devfn |= SYS_CFG_START | SYS_CFG_WRITE;
83 105
84 spin_lock(&v2m_cfg_lock); 106 spin_lock(&v2m_cfg_lock);
85 val = readl(MMIO_P2V(V2M_SYS_CFGSTAT)); 107 val = readl(v2m_sysreg_base + V2M_SYS_CFGSTAT);
86 writel(val & ~SYS_CFG_COMPLETE, MMIO_P2V(V2M_SYS_CFGSTAT)); 108 writel(val & ~SYS_CFG_COMPLETE, v2m_sysreg_base + V2M_SYS_CFGSTAT);
87 109
88 writel(data, MMIO_P2V(V2M_SYS_CFGDATA)); 110 writel(data, v2m_sysreg_base + V2M_SYS_CFGDATA);
89 writel(devfn, MMIO_P2V(V2M_SYS_CFGCTRL)); 111 writel(devfn, v2m_sysreg_base + V2M_SYS_CFGCTRL);
90 112
91 do { 113 do {
92 val = readl(MMIO_P2V(V2M_SYS_CFGSTAT)); 114 val = readl(v2m_sysreg_base + V2M_SYS_CFGSTAT);
93 } while (val == 0); 115 } while (val == 0);
94 spin_unlock(&v2m_cfg_lock); 116 spin_unlock(&v2m_cfg_lock);
95 117
@@ -103,22 +125,28 @@ int v2m_cfg_read(u32 devfn, u32 *data)
103 devfn |= SYS_CFG_START; 125 devfn |= SYS_CFG_START;
104 126
105 spin_lock(&v2m_cfg_lock); 127 spin_lock(&v2m_cfg_lock);
106 writel(0, MMIO_P2V(V2M_SYS_CFGSTAT)); 128 writel(0, v2m_sysreg_base + V2M_SYS_CFGSTAT);
107 writel(devfn, MMIO_P2V(V2M_SYS_CFGCTRL)); 129 writel(devfn, v2m_sysreg_base + V2M_SYS_CFGCTRL);
108 130
109 mb(); 131 mb();
110 132
111 do { 133 do {
112 cpu_relax(); 134 cpu_relax();
113 val = readl(MMIO_P2V(V2M_SYS_CFGSTAT)); 135 val = readl(v2m_sysreg_base + V2M_SYS_CFGSTAT);
114 } while (val == 0); 136 } while (val == 0);
115 137
116 *data = readl(MMIO_P2V(V2M_SYS_CFGDATA)); 138 *data = readl(v2m_sysreg_base + V2M_SYS_CFGDATA);
117 spin_unlock(&v2m_cfg_lock); 139 spin_unlock(&v2m_cfg_lock);
118 140
119 return !!(val & SYS_CFG_ERR); 141 return !!(val & SYS_CFG_ERR);
120} 142}
121 143
144void __init v2m_flags_set(u32 data)
145{
146 writel(~0, v2m_sysreg_base + V2M_SYS_FLAGSCLR);
147 writel(data, v2m_sysreg_base + V2M_SYS_FLAGSSET);
148}
149
122 150
123static struct resource v2m_pcie_i2c_resource = { 151static struct resource v2m_pcie_i2c_resource = {
124 .start = V2M_SERIAL_BUS_PCI, 152 .start = V2M_SERIAL_BUS_PCI,
@@ -204,7 +232,7 @@ static struct platform_device v2m_usb_device = {
204 232
205static void v2m_flash_set_vpp(struct platform_device *pdev, int on) 233static void v2m_flash_set_vpp(struct platform_device *pdev, int on)
206{ 234{
207 writel(on != 0, MMIO_P2V(V2M_SYS_FLASH)); 235 writel(on != 0, v2m_sysreg_base + V2M_SYS_FLASH);
208} 236}
209 237
210static struct physmap_flash_data v2m_flash_data = { 238static struct physmap_flash_data v2m_flash_data = {
@@ -258,7 +286,7 @@ static struct platform_device v2m_cf_device = {
258 286
259static unsigned int v2m_mmci_status(struct device *dev) 287static unsigned int v2m_mmci_status(struct device *dev)
260{ 288{
261 return readl(MMIO_P2V(V2M_SYS_MCI)) & (1 << 0); 289 return readl(v2m_sysreg_base + V2M_SYS_MCI) & (1 << 0);
262} 290}
263 291
264static struct mmci_platform_data v2m_mmci_data = { 292static struct mmci_platform_data v2m_mmci_data = {
@@ -266,16 +294,16 @@ static struct mmci_platform_data v2m_mmci_data = {
266 .status = v2m_mmci_status, 294 .status = v2m_mmci_status,
267}; 295};
268 296
269static AMBA_DEVICE(aaci, "mb:aaci", V2M_AACI, NULL); 297static AMBA_APB_DEVICE(aaci, "mb:aaci", 0, V2M_AACI, IRQ_V2M_AACI, NULL);
270static AMBA_DEVICE(mmci, "mb:mmci", V2M_MMCI, &v2m_mmci_data); 298static AMBA_APB_DEVICE(mmci, "mb:mmci", 0, V2M_MMCI, IRQ_V2M_MMCI, &v2m_mmci_data);
271static AMBA_DEVICE(kmi0, "mb:kmi0", V2M_KMI0, NULL); 299static AMBA_APB_DEVICE(kmi0, "mb:kmi0", 0, V2M_KMI0, IRQ_V2M_KMI0, NULL);
272static AMBA_DEVICE(kmi1, "mb:kmi1", V2M_KMI1, NULL); 300static AMBA_APB_DEVICE(kmi1, "mb:kmi1", 0, V2M_KMI1, IRQ_V2M_KMI1, NULL);
273static AMBA_DEVICE(uart0, "mb:uart0", V2M_UART0, NULL); 301static AMBA_APB_DEVICE(uart0, "mb:uart0", 0, V2M_UART0, IRQ_V2M_UART0, NULL);
274static AMBA_DEVICE(uart1, "mb:uart1", V2M_UART1, NULL); 302static AMBA_APB_DEVICE(uart1, "mb:uart1", 0, V2M_UART1, IRQ_V2M_UART1, NULL);
275static AMBA_DEVICE(uart2, "mb:uart2", V2M_UART2, NULL); 303static AMBA_APB_DEVICE(uart2, "mb:uart2", 0, V2M_UART2, IRQ_V2M_UART2, NULL);
276static AMBA_DEVICE(uart3, "mb:uart3", V2M_UART3, NULL); 304static AMBA_APB_DEVICE(uart3, "mb:uart3", 0, V2M_UART3, IRQ_V2M_UART3, NULL);
277static AMBA_DEVICE(wdt, "mb:wdt", V2M_WDT, NULL); 305static AMBA_APB_DEVICE(wdt, "mb:wdt", 0, V2M_WDT, IRQ_V2M_WDT, NULL);
278static AMBA_DEVICE(rtc, "mb:rtc", V2M_RTC, NULL); 306static AMBA_APB_DEVICE(rtc, "mb:rtc", 0, V2M_RTC, IRQ_V2M_RTC, NULL);
279 307
280static struct amba_device *v2m_amba_devs[] __initdata = { 308static struct amba_device *v2m_amba_devs[] __initdata = {
281 &aaci_device, 309 &aaci_device,
@@ -371,7 +399,7 @@ static void __init v2m_init_early(void)
371{ 399{
372 ct_desc->init_early(); 400 ct_desc->init_early();
373 clkdev_add_table(v2m_lookups, ARRAY_SIZE(v2m_lookups)); 401 clkdev_add_table(v2m_lookups, ARRAY_SIZE(v2m_lookups));
374 versatile_sched_clock_init(MMIO_P2V(V2M_SYS_24MHZ), 24000000); 402 versatile_sched_clock_init(v2m_sysreg_base + V2M_SYS_24MHZ, 24000000);
375} 403}
376 404
377static void v2m_power_off(void) 405static void v2m_power_off(void)
@@ -400,20 +428,23 @@ static void __init v2m_populate_ct_desc(void)
400 u32 current_tile_id; 428 u32 current_tile_id;
401 429
402 ct_desc = NULL; 430 ct_desc = NULL;
403 current_tile_id = readl(MMIO_P2V(V2M_SYS_PROCID0)) & V2M_CT_ID_MASK; 431 current_tile_id = readl(v2m_sysreg_base + V2M_SYS_PROCID0)
432 & V2M_CT_ID_MASK;
404 433
405 for (i = 0; i < ARRAY_SIZE(ct_descs) && !ct_desc; ++i) 434 for (i = 0; i < ARRAY_SIZE(ct_descs) && !ct_desc; ++i)
406 if (ct_descs[i]->id == current_tile_id) 435 if (ct_descs[i]->id == current_tile_id)
407 ct_desc = ct_descs[i]; 436 ct_desc = ct_descs[i];
408 437
409 if (!ct_desc) 438 if (!ct_desc)
410 panic("vexpress: failed to populate core tile description " 439 panic("vexpress: this kernel does not support core tile ID 0x%08x when booting via ATAGs.\n"
411 "for tile ID 0x%8x\n", current_tile_id); 440 "You may need a device tree blob or a different kernel to boot on this board.\n",
441 current_tile_id);
412} 442}
413 443
414static void __init v2m_map_io(void) 444static void __init v2m_map_io(void)
415{ 445{
416 iotable_init(v2m_io_desc, ARRAY_SIZE(v2m_io_desc)); 446 iotable_init(v2m_io_desc, ARRAY_SIZE(v2m_io_desc));
447 v2m_sysreg_base = ioremap(V2M_SYSREGS, SZ_4K);
417 v2m_populate_ct_desc(); 448 v2m_populate_ct_desc();
418 ct_desc->map_io(); 449 ct_desc->map_io();
419} 450}
@@ -452,3 +483,205 @@ MACHINE_START(VEXPRESS, "ARM-Versatile Express")
452 .init_machine = v2m_init, 483 .init_machine = v2m_init,
453 .restart = v2m_restart, 484 .restart = v2m_restart,
454MACHINE_END 485MACHINE_END
486
487#if defined(CONFIG_ARCH_VEXPRESS_DT)
488
489static struct map_desc v2m_rs1_io_desc __initdata = {
490 .virtual = V2M_PERIPH,
491 .pfn = __phys_to_pfn(0x1c000000),
492 .length = SZ_2M,
493 .type = MT_DEVICE,
494};
495
496static int __init v2m_dt_scan_memory_map(unsigned long node, const char *uname,
497 int depth, void *data)
498{
499 const char **map = data;
500
501 if (strcmp(uname, "motherboard") != 0)
502 return 0;
503
504 *map = of_get_flat_dt_prop(node, "arm,v2m-memory-map", NULL);
505
506 return 1;
507}
508
509void __init v2m_dt_map_io(void)
510{
511 const char *map = NULL;
512
513 of_scan_flat_dt(v2m_dt_scan_memory_map, &map);
514
515 if (map && strcmp(map, "rs1") == 0)
516 iotable_init(&v2m_rs1_io_desc, 1);
517 else
518 iotable_init(v2m_io_desc, ARRAY_SIZE(v2m_io_desc));
519
520#if defined(CONFIG_SMP)
521 vexpress_dt_smp_map_io();
522#endif
523}
524
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)
597{
598 struct device_node *node;
599 u32 dt_hbi;
600
601 node = of_find_compatible_node(NULL, NULL, "arm,vexpress-sysreg");
602 v2m_sysreg_base = of_iomap(node, 0);
603 if (WARN_ON(!v2m_sysreg_base))
604 return;
605
606 /* Confirm board type against DT property, if available */
607 if (of_property_read_u32(allnodes, "arm,hbi", &dt_hbi) == 0) {
608 u32 misc = readl(v2m_sysreg_base + V2M_SYS_MISC);
609 u32 id = readl(v2m_sysreg_base + (misc & SYS_MISC_MASTERSITE ?
610 V2M_SYS_PROCID1 : V2M_SYS_PROCID0));
611 u32 hbi = id & SYS_PROCIDx_HBI_MASK;
612
613 if (WARN_ON(dt_hbi != hbi))
614 pr_warning("vexpress: DT HBI (%x) is not matching "
615 "hardware (%x)!\n", dt_hbi, hbi);
616 }
617
618 clkdev_add_table(v2m_dt_lookups, ARRAY_SIZE(v2m_dt_lookups));
619 versatile_sched_clock_init(v2m_sysreg_base + V2M_SYS_24MHZ, 24000000);
620}
621
622static struct of_device_id vexpress_irq_match[] __initdata = {
623 { .compatible = "arm,cortex-a9-gic", .data = gic_of_init, },
624 {}
625};
626
627static void __init v2m_dt_init_irq(void)
628{
629 of_irq_init(vexpress_irq_match);
630}
631
632static void __init v2m_dt_timer_init(void)
633{
634 struct device_node *node;
635 const char *path;
636 int err;
637
638 node = of_find_compatible_node(NULL, NULL, "arm,sp810");
639 v2m_sysctl_init(of_iomap(node, 0));
640
641 err = of_property_read_string(of_aliases, "arm,v2m_timer", &path);
642 if (WARN_ON(err))
643 return;
644 node = of_find_node_by_path(path);
645 v2m_sp804_init(of_iomap(node, 0), irq_of_parse_and_map(node, 0));
646}
647
648static struct sys_timer v2m_dt_timer = {
649 .init = v2m_dt_timer_init,
650};
651
652static struct of_dev_auxdata v2m_dt_auxdata_lookup[] __initdata = {
653 OF_DEV_AUXDATA("arm,vexpress-flash", V2M_NOR0, "physmap-flash",
654 &v2m_flash_data),
655 OF_DEV_AUXDATA("arm,primecell", V2M_MMCI, "mb:mmci", &v2m_mmci_data),
656 /* RS1 memory map */
657 OF_DEV_AUXDATA("arm,vexpress-flash", 0x08000000, "physmap-flash",
658 &v2m_flash_data),
659 OF_DEV_AUXDATA("arm,primecell", 0x1c050000, "mb:mmci", &v2m_mmci_data),
660 {}
661};
662
663static void __init v2m_dt_init(void)
664{
665 l2x0_of_init(0x00400000, 0xfe0fffff);
666 of_platform_populate(NULL, of_default_bus_match_table,
667 v2m_dt_auxdata_lookup, NULL);
668 pm_power_off = v2m_power_off;
669}
670
671const static char *v2m_dt_match[] __initconst = {
672 "arm,vexpress",
673 NULL,
674};
675
676DT_MACHINE_START(VEXPRESS_DT, "ARM-Versatile Express")
677 .dt_compat = v2m_dt_match,
678 .map_io = v2m_dt_map_io,
679 .init_early = v2m_dt_init_early,
680 .init_irq = v2m_dt_init_irq,
681 .timer = &v2m_dt_timer,
682 .init_machine = v2m_dt_init,
683 .handle_irq = gic_handle_irq,
684 .restart = v2m_restart,
685MACHINE_END
686
687#endif
diff --git a/arch/arm/mach-vt8500/include/mach/entry-macro.S b/arch/arm/mach-vt8500/include/mach/entry-macro.S
index 92684c7eaed..367d1b55fb9 100644
--- a/arch/arm/mach-vt8500/include/mach/entry-macro.S
+++ b/arch/arm/mach-vt8500/include/mach/entry-macro.S
@@ -8,18 +8,12 @@
8 * warranty of any kind, whether express or implied. 8 * warranty of any kind, whether express or implied.
9 */ 9 */
10 10
11 .macro disable_fiq
12 .endm
13
14 .macro get_irqnr_preamble, base, tmp 11 .macro get_irqnr_preamble, base, tmp
15 @ physical 0xd8140000 is virtual 0xf8140000 12 @ physical 0xd8140000 is virtual 0xf8140000
16 mov \base, #0xf8000000 13 mov \base, #0xf8000000
17 orr \base, \base, #0x00140000 14 orr \base, \base, #0x00140000
18 .endm 15 .endm
19 16
20 .macro arch_ret_to_user, tmp1, tmp2
21 .endm
22
23 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp 17 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
24 ldr \irqnr, [\base] 18 ldr \irqnr, [\base]
25 cmp \irqnr, #63 @ may be false positive, check interrupt status 19 cmp \irqnr, #63 @ may be false positive, check interrupt status
diff --git a/arch/arm/mach-vt8500/include/mach/system.h b/arch/arm/mach-vt8500/include/mach/system.h
index d6c757eaf26..58fa8010ee6 100644
--- a/arch/arm/mach-vt8500/include/mach/system.h
+++ b/arch/arm/mach-vt8500/include/mach/system.h
@@ -7,11 +7,6 @@
7/* PM Software Reset request register */ 7/* PM Software Reset request register */
8#define VT8500_PMSR_VIRT 0xf8130060 8#define VT8500_PMSR_VIRT 0xf8130060
9 9
10static inline void arch_idle(void)
11{
12 cpu_do_idle();
13}
14
15static inline void arch_reset(char mode, const char *cmd) 10static inline void arch_reset(char mode, const char *cmd)
16{ 11{
17 writel(1, VT8500_PMSR_VIRT); 12 writel(1, VT8500_PMSR_VIRT);
diff --git a/arch/arm/mach-w90x900/dev.c b/arch/arm/mach-w90x900/dev.c
index 78110befb7a..db82568a998 100644
--- a/arch/arm/mach-w90x900/dev.c
+++ b/arch/arm/mach-w90x900/dev.c
@@ -530,6 +530,7 @@ static struct platform_device *nuc900_public_dev[] __initdata = {
530 530
531void __init nuc900_board_init(struct platform_device **device, int size) 531void __init nuc900_board_init(struct platform_device **device, int size)
532{ 532{
533 disable_hlt();
533 platform_add_devices(device, size); 534 platform_add_devices(device, size);
534 platform_add_devices(nuc900_public_dev, ARRAY_SIZE(nuc900_public_dev)); 535 platform_add_devices(nuc900_public_dev, ARRAY_SIZE(nuc900_public_dev));
535 spi_register_board_info(nuc900_spi_board_info, 536 spi_register_board_info(nuc900_spi_board_info,
diff --git a/arch/arm/mach-w90x900/include/mach/entry-macro.S b/arch/arm/mach-w90x900/include/mach/entry-macro.S
index d39aca5be9e..e286daca682 100644
--- a/arch/arm/mach-w90x900/include/mach/entry-macro.S
+++ b/arch/arm/mach-w90x900/include/mach/entry-macro.S
@@ -15,9 +15,6 @@
15 .macro get_irqnr_preamble, base, tmp 15 .macro get_irqnr_preamble, base, tmp
16 .endm 16 .endm
17 17
18 .macro arch_ret_to_user, tmp1, tmp2
19 .endm
20
21 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp 18 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
22 19
23 mov \base, #AIC_BA 20 mov \base, #AIC_BA
@@ -27,8 +24,3 @@
27 cmp \irqnr, #0 24 cmp \irqnr, #0
28 25
29 .endm 26 .endm
30
31 /* currently don't need an disable_fiq macro */
32
33 .macro disable_fiq
34 .endm
diff --git a/arch/arm/mach-w90x900/include/mach/system.h b/arch/arm/mach-w90x900/include/mach/system.h
deleted file mode 100644
index 2aaeb931161..00000000000
--- a/arch/arm/mach-w90x900/include/mach/system.h
+++ /dev/null
@@ -1,19 +0,0 @@
1/*
2 * arch/arm/mach-w90x900/include/mach/system.h
3 *
4 * Copyright (c) 2008 Nuvoton technology corporation
5 * All rights reserved.
6 *
7 * Wan ZongShun <mcuos.com@gmail.com>
8 *
9 * Based on arch/arm/mach-s3c2410/include/mach/system.h
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 */
17static void arch_idle(void)
18{
19}
diff --git a/arch/arm/mach-zynq/include/mach/entry-macro.S b/arch/arm/mach-zynq/include/mach/entry-macro.S
deleted file mode 100644
index d621fb73256..00000000000
--- a/arch/arm/mach-zynq/include/mach/entry-macro.S
+++ /dev/null
@@ -1,27 +0,0 @@
1/*
2 * arch/arm/mach-zynq/include/mach/entry-macro.S
3 *
4 * Low-level IRQ helper macros
5 *
6 * Copyright (C) 2011 Xilinx
7 *
8 * based on arch/plat-mxc/include/mach/entry-macro.S
9 *
10 * Copyright (C) 2007 Lennert Buytenhek <buytenh@wantstofly.org>
11 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
12 *
13 * This software is licensed under the terms of the GNU General Public
14 * License version 2, as published by the Free Software Foundation, and
15 * may be copied, distributed, and modified under those terms.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 */
22
23 .macro disable_fiq
24 .endm
25
26 .macro arch_ret_to_user, tmp1, tmp2
27 .endm
diff --git a/arch/arm/mach-zynq/include/mach/system.h b/arch/arm/mach-zynq/include/mach/system.h
deleted file mode 100644
index 8e88e0b8d2b..00000000000
--- a/arch/arm/mach-zynq/include/mach/system.h
+++ /dev/null
@@ -1,23 +0,0 @@
1/* arch/arm/mach-zynq/include/mach/system.h
2 *
3 * Copyright (C) 2011 Xilinx
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#ifndef __MACH_SYSTEM_H__
16#define __MACH_SYSTEM_H__
17
18static inline void arch_idle(void)
19{
20 cpu_do_idle();
21}
22
23#endif
diff --git a/arch/arm/mm/iomap.c b/arch/arm/mm/iomap.c
index e62956e1203..4614208369f 100644
--- a/arch/arm/mm/iomap.c
+++ b/arch/arm/mm/iomap.c
@@ -32,9 +32,6 @@ EXPORT_SYMBOL(pcibios_min_io);
32unsigned long pcibios_min_mem = 0x01000000; 32unsigned long pcibios_min_mem = 0x01000000;
33EXPORT_SYMBOL(pcibios_min_mem); 33EXPORT_SYMBOL(pcibios_min_mem);
34 34
35unsigned int pci_flags = PCI_REASSIGN_ALL_RSRC;
36EXPORT_SYMBOL(pci_flags);
37
38void pci_iounmap(struct pci_dev *dev, void __iomem *addr) 35void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
39{ 36{
40 if ((unsigned long)addr >= VMALLOC_START && 37 if ((unsigned long)addr >= VMALLOC_START &&
diff --git a/arch/arm/plat-iop/pci.c b/arch/arm/plat-iop/pci.c
index bb269819666..0da42058a20 100644
--- a/arch/arm/plat-iop/pci.c
+++ b/arch/arm/plat-iop/pci.c
@@ -214,8 +214,8 @@ int iop3xx_pci_setup(int nr, struct pci_sys_data *sys)
214 sys->mem_offset = IOP3XX_PCI_LOWER_MEM_PA - *IOP3XX_OMWTVR0; 214 sys->mem_offset = IOP3XX_PCI_LOWER_MEM_PA - *IOP3XX_OMWTVR0;
215 sys->io_offset = IOP3XX_PCI_LOWER_IO_PA - *IOP3XX_OIOWTVR; 215 sys->io_offset = IOP3XX_PCI_LOWER_IO_PA - *IOP3XX_OIOWTVR;
216 216
217 pci_add_resource(&sys->resources, &res[0]); 217 pci_add_resource_offset(&sys->resources, &res[0], sys->io_offset);
218 pci_add_resource(&sys->resources, &res[1]); 218 pci_add_resource_offset(&sys->resources, &res[1], sys->mem_offset);
219 219
220 return 1; 220 return 1;
221} 221}
diff --git a/arch/arm/plat-mxc/avic.c b/arch/arm/plat-mxc/avic.c
index 55f15699a38..689f81f9593 100644
--- a/arch/arm/plat-mxc/avic.c
+++ b/arch/arm/plat-mxc/avic.c
@@ -60,7 +60,7 @@ static int avic_irq_set_priority(unsigned char irq, unsigned char prio)
60 unsigned int mask = 0x0F << irq % 8 * 4; 60 unsigned int mask = 0x0F << irq % 8 * 4;
61 61
62 if (irq >= AVIC_NUM_IRQS) 62 if (irq >= AVIC_NUM_IRQS)
63 return -EINVAL;; 63 return -EINVAL;
64 64
65 temp = __raw_readl(avic_base + AVIC_NIPRIORITY(irq / 8)); 65 temp = __raw_readl(avic_base + AVIC_NIPRIORITY(irq / 8));
66 temp &= ~mask; 66 temp &= ~mask;
diff --git a/arch/arm/plat-mxc/cpu.c b/arch/arm/plat-mxc/cpu.c
index f5b7e0fa237..220dd6f9312 100644
--- a/arch/arm/plat-mxc/cpu.c
+++ b/arch/arm/plat-mxc/cpu.c
@@ -1,5 +1,6 @@
1 1
2#include <linux/module.h> 2#include <linux/module.h>
3#include <linux/io.h>
3#include <mach/hardware.h> 4#include <mach/hardware.h>
4 5
5unsigned int __mxc_cpu_type; 6unsigned int __mxc_cpu_type;
@@ -18,3 +19,26 @@ void imx_print_silicon_rev(const char *cpu, int srev)
18 pr_info("CPU identified as %s, silicon rev %d.%d\n", 19 pr_info("CPU identified as %s, silicon rev %d.%d\n",
19 cpu, (srev >> 4) & 0xf, srev & 0xf); 20 cpu, (srev >> 4) & 0xf, srev & 0xf);
20} 21}
22
23void __init imx_set_aips(void __iomem *base)
24{
25 unsigned int reg;
26/*
27 * Set all MPROTx to be non-bufferable, trusted for R/W,
28 * not forced to user-mode.
29 */
30 __raw_writel(0x77777777, base + 0x0);
31 __raw_writel(0x77777777, base + 0x4);
32
33/*
34 * Set all OPACRx to be non-bufferable, to not require
35 * supervisor privilege level for access, allow for
36 * write access and untrusted master access.
37 */
38 __raw_writel(0x0, base + 0x40);
39 __raw_writel(0x0, base + 0x44);
40 __raw_writel(0x0, base + 0x48);
41 __raw_writel(0x0, base + 0x4C);
42 reg = __raw_readl(base + 0x50) & 0x00FFFFFF;
43 __raw_writel(reg, base + 0x50);
44}
diff --git a/arch/arm/plat-mxc/devices/platform-ahci-imx.c b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
index d8a56aee521..ade4a1c4e2a 100644
--- a/arch/arm/plat-mxc/devices/platform-ahci-imx.c
+++ b/arch/arm/plat-mxc/devices/platform-ahci-imx.c
@@ -60,9 +60,9 @@ static int imx_sata_init(struct device *dev, void __iomem *addr)
60 dev_err(dev, "no sata clock.\n"); 60 dev_err(dev, "no sata clock.\n");
61 return PTR_ERR(sata_clk); 61 return PTR_ERR(sata_clk);
62 } 62 }
63 ret = clk_enable(sata_clk); 63 ret = clk_prepare_enable(sata_clk);
64 if (ret) { 64 if (ret) {
65 dev_err(dev, "can't enable sata clock.\n"); 65 dev_err(dev, "can't prepare/enable sata clock.\n");
66 goto put_sata_clk; 66 goto put_sata_clk;
67 } 67 }
68 68
@@ -73,9 +73,9 @@ static int imx_sata_init(struct device *dev, void __iomem *addr)
73 ret = PTR_ERR(sata_ref_clk); 73 ret = PTR_ERR(sata_ref_clk);
74 goto release_sata_clk; 74 goto release_sata_clk;
75 } 75 }
76 ret = clk_enable(sata_ref_clk); 76 ret = clk_prepare_enable(sata_ref_clk);
77 if (ret) { 77 if (ret) {
78 dev_err(dev, "can't enable sata ref clock.\n"); 78 dev_err(dev, "can't prepare/enable sata ref clock.\n");
79 goto put_sata_ref_clk; 79 goto put_sata_ref_clk;
80 } 80 }
81 81
@@ -104,11 +104,11 @@ static int imx_sata_init(struct device *dev, void __iomem *addr)
104 return 0; 104 return 0;
105 105
106release_sata_ref_clk: 106release_sata_ref_clk:
107 clk_disable(sata_ref_clk); 107 clk_disable_unprepare(sata_ref_clk);
108put_sata_ref_clk: 108put_sata_ref_clk:
109 clk_put(sata_ref_clk); 109 clk_put(sata_ref_clk);
110release_sata_clk: 110release_sata_clk:
111 clk_disable(sata_clk); 111 clk_disable_unprepare(sata_clk);
112put_sata_clk: 112put_sata_clk:
113 clk_put(sata_clk); 113 clk_put(sata_clk);
114 114
@@ -117,10 +117,10 @@ put_sata_clk:
117 117
118static void imx_sata_exit(struct device *dev) 118static void imx_sata_exit(struct device *dev)
119{ 119{
120 clk_disable(sata_ref_clk); 120 clk_disable_unprepare(sata_ref_clk);
121 clk_put(sata_ref_clk); 121 clk_put(sata_ref_clk);
122 122
123 clk_disable(sata_clk); 123 clk_disable_unprepare(sata_clk);
124 clk_put(sata_clk); 124 clk_put(sata_clk);
125 125
126} 126}
diff --git a/arch/arm/plat-mxc/devices/platform-mx2-camera.c b/arch/arm/plat-mxc/devices/platform-mx2-camera.c
index b3f4828dc44..11eace953a0 100644
--- a/arch/arm/plat-mxc/devices/platform-mx2-camera.c
+++ b/arch/arm/plat-mxc/devices/platform-mx2-camera.c
@@ -62,3 +62,21 @@ struct platform_device *__init imx_add_mx2_camera(
62 res, data->iobaseemmaprp ? 4 : 2, 62 res, data->iobaseemmaprp ? 4 : 2,
63 pdata, sizeof(*pdata), DMA_BIT_MASK(32)); 63 pdata, sizeof(*pdata), DMA_BIT_MASK(32));
64} 64}
65
66struct platform_device *__init imx_add_mx2_emmaprp(
67 const struct imx_mx2_camera_data *data)
68{
69 struct resource res[] = {
70 {
71 .start = data->iobaseemmaprp,
72 .end = data->iobaseemmaprp + data->iosizeemmaprp - 1,
73 .flags = IORESOURCE_MEM,
74 }, {
75 .start = data->irqemmaprp,
76 .end = data->irqemmaprp,
77 .flags = IORESOURCE_IRQ,
78 },
79 };
80 return imx_add_platform_device_dmamask("m2m-emmaprp", 0,
81 res, 2, NULL, 0, DMA_BIT_MASK(32));
82}
diff --git a/arch/arm/plat-mxc/epit.c b/arch/arm/plat-mxc/epit.c
index d3467f818c3..9129c9e7d53 100644
--- a/arch/arm/plat-mxc/epit.c
+++ b/arch/arm/plat-mxc/epit.c
@@ -203,7 +203,7 @@ static int __init epit_clockevent_init(struct clk *timer_clk)
203 203
204void __init epit_timer_init(struct clk *timer_clk, void __iomem *base, int irq) 204void __init epit_timer_init(struct clk *timer_clk, void __iomem *base, int irq)
205{ 205{
206 clk_enable(timer_clk); 206 clk_prepare_enable(timer_clk);
207 207
208 timer_base = base; 208 timer_base = base;
209 209
diff --git a/arch/arm/plat-mxc/include/mach/board-mx31ads.h b/arch/arm/plat-mxc/include/mach/board-mx31ads.h
deleted file mode 100644
index 94b60dd4713..00000000000
--- a/arch/arm/plat-mxc/include/mach/board-mx31ads.h
+++ /dev/null
@@ -1,33 +0,0 @@
1/*
2 * Copyright 2005-2007 Freescale Semiconductor, Inc. All Rights Reserved.
3 */
4
5/*
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __ASM_ARCH_MXC_BOARD_MX31ADS_H__
12#define __ASM_ARCH_MXC_BOARD_MX31ADS_H__
13
14#include <mach/hardware.h>
15
16/*
17 * These symbols are used by drivers/net/cs89x0.c.
18 * This is ugly as hell, but we have to provide them until
19 * someone fixed the driver.
20 */
21
22/* Base address of PBC controller */
23#define PBC_BASE_ADDRESS MX31_CS4_BASE_ADDR_VIRT
24/* Offsets for the PBC Controller register */
25
26/* Ethernet Controller IO base address */
27#define PBC_CS8900A_IOBASE 0x020000
28
29#define MXC_EXP_IO_BASE (MXC_BOARD_IRQ_START)
30
31#define EXPIO_INT_ENET_INT (MXC_EXP_IO_BASE + 8)
32
33#endif /* __ASM_ARCH_MXC_BOARD_MX31ADS_H__ */
diff --git a/arch/arm/plat-mxc/include/mach/common.h b/arch/arm/plat-mxc/include/mach/common.h
index 1bf0df81bdc..0319c4a0caf 100644
--- a/arch/arm/plat-mxc/include/mach/common.h
+++ b/arch/arm/plat-mxc/include/mach/common.h
@@ -65,6 +65,7 @@ extern int mx51_clocks_init(unsigned long ckil, unsigned long osc,
65 unsigned long ckih1, unsigned long ckih2); 65 unsigned long ckih1, unsigned long ckih2);
66extern int mx53_clocks_init(unsigned long ckil, unsigned long osc, 66extern int mx53_clocks_init(unsigned long ckil, unsigned long osc,
67 unsigned long ckih1, unsigned long ckih2); 67 unsigned long ckih1, unsigned long ckih2);
68extern int mx27_clocks_init_dt(void);
68extern int mx51_clocks_init_dt(void); 69extern int mx51_clocks_init_dt(void);
69extern int mx53_clocks_init_dt(void); 70extern int mx53_clocks_init_dt(void);
70extern int mx6q_clocks_init(void); 71extern int mx6q_clocks_init(void);
@@ -75,6 +76,7 @@ extern void mxc_restart(char, const char *);
75extern void mxc_arch_reset_init(void __iomem *); 76extern void mxc_arch_reset_init(void __iomem *);
76extern int mx53_revision(void); 77extern int mx53_revision(void);
77extern int mx53_display_revision(void); 78extern int mx53_display_revision(void);
79extern void imx_set_aips(void __iomem *);
78 80
79enum mxc_cpu_pwr_mode { 81enum mxc_cpu_pwr_mode {
80 WAIT_CLOCKED, /* wfi only */ 82 WAIT_CLOCKED, /* wfi only */
@@ -84,6 +86,14 @@ enum mxc_cpu_pwr_mode {
84 STOP_POWER_OFF, /* STOP + SRPG */ 86 STOP_POWER_OFF, /* STOP + SRPG */
85}; 87};
86 88
89enum mx3_cpu_pwr_mode {
90 MX3_RUN,
91 MX3_WAIT,
92 MX3_DOZE,
93 MX3_SLEEP,
94};
95
96extern void mx3_cpu_lp_set(enum mx3_cpu_pwr_mode mode);
87extern void mx5_cpu_lp_set(enum mxc_cpu_pwr_mode mode); 97extern void mx5_cpu_lp_set(enum mxc_cpu_pwr_mode mode);
88extern void imx_print_silicon_rev(const char *cpu, int srev); 98extern void imx_print_silicon_rev(const char *cpu, int srev);
89 99
diff --git a/arch/arm/plat-mxc/include/mach/debug-macro.S b/arch/arm/plat-mxc/include/mach/debug-macro.S
index 6e192c4a391..8ddda365f1a 100644
--- a/arch/arm/plat-mxc/include/mach/debug-macro.S
+++ b/arch/arm/plat-mxc/include/mach/debug-macro.S
@@ -24,7 +24,7 @@
24#define UART_PADDR MX51_UART1_BASE_ADDR 24#define UART_PADDR MX51_UART1_BASE_ADDR
25#elif defined (CONFIG_DEBUG_IMX50_IMX53_UART) 25#elif defined (CONFIG_DEBUG_IMX50_IMX53_UART)
26#define UART_PADDR MX53_UART1_BASE_ADDR 26#define UART_PADDR MX53_UART1_BASE_ADDR
27#elif defined (CONFIG_DEBUG_IMX6Q_UART) 27#elif defined (CONFIG_DEBUG_IMX6Q_UART4)
28#define UART_PADDR MX6Q_UART4_BASE_ADDR 28#define UART_PADDR MX6Q_UART4_BASE_ADDR
29#endif 29#endif
30 30
diff --git a/arch/arm/plat-mxc/include/mach/devices-common.h b/arch/arm/plat-mxc/include/mach/devices-common.h
index def9ba53e23..1b2258daa05 100644
--- a/arch/arm/plat-mxc/include/mach/devices-common.h
+++ b/arch/arm/plat-mxc/include/mach/devices-common.h
@@ -223,6 +223,8 @@ struct imx_mx2_camera_data {
223struct platform_device *__init imx_add_mx2_camera( 223struct platform_device *__init imx_add_mx2_camera(
224 const struct imx_mx2_camera_data *data, 224 const struct imx_mx2_camera_data *data,
225 const struct mx2_camera_platform_data *pdata); 225 const struct mx2_camera_platform_data *pdata);
226struct platform_device *__init imx_add_mx2_emmaprp(
227 const struct imx_mx2_camera_data *data);
226 228
227#include <mach/mxc_ehci.h> 229#include <mach/mxc_ehci.h>
228struct imx_mxc_ehci_data { 230struct imx_mxc_ehci_data {
diff --git a/arch/arm/plat-mxc/include/mach/dma.h b/arch/arm/plat-mxc/include/mach/dma.h
index 233d0a5e2d6..1b9080385b4 100644
--- a/arch/arm/plat-mxc/include/mach/dma.h
+++ b/arch/arm/plat-mxc/include/mach/dma.h
@@ -60,8 +60,7 @@ static inline int imx_dma_is_ipu(struct dma_chan *chan)
60 60
61static inline int imx_dma_is_general_purpose(struct dma_chan *chan) 61static inline int imx_dma_is_general_purpose(struct dma_chan *chan)
62{ 62{
63 return !strcmp(dev_name(chan->device->dev), "imx31-sdma") || 63 return strstr(dev_name(chan->device->dev), "sdma") ||
64 !strcmp(dev_name(chan->device->dev), "imx35-sdma") ||
65 !strcmp(dev_name(chan->device->dev), "imx-dma"); 64 !strcmp(dev_name(chan->device->dev), "imx-dma");
66} 65}
67 66
diff --git a/arch/arm/plat-mxc/include/mach/entry-macro.S b/arch/arm/plat-mxc/include/mach/entry-macro.S
deleted file mode 100644
index def5d30cb67..00000000000
--- a/arch/arm/plat-mxc/include/mach/entry-macro.S
+++ /dev/null
@@ -1,16 +0,0 @@
1/*
2 * Copyright (C) 2007 Lennert Buytenhek <buytenh@wantstofly.org>
3 * Copyright 2004-2009 Freescale Semiconductor, Inc. All Rights Reserved.
4 */
5
6/*
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12 .macro disable_fiq
13 .endm
14
15 .macro arch_ret_to_user, tmp1, tmp2
16 .endm
diff --git a/arch/arm/plat-mxc/include/mach/iomux-mx25.h b/arch/arm/plat-mxc/include/mach/iomux-mx25.h
index f0726d48df2..c61ec0fc10d 100644
--- a/arch/arm/plat-mxc/include/mach/iomux-mx25.h
+++ b/arch/arm/plat-mxc/include/mach/iomux-mx25.h
@@ -139,15 +139,15 @@
139#define MX25_PAD_NFRB__GPIO_3_31 IOMUX_PAD(0x27c, 0x084, 0x15, 0, 0, NO_PAD_CTRL) 139#define MX25_PAD_NFRB__GPIO_3_31 IOMUX_PAD(0x27c, 0x084, 0x15, 0, 0, NO_PAD_CTRL)
140 140
141#define MX25_PAD_D15__D15 IOMUX_PAD(0x280, 0x088, 0x00, 0, 0, NO_PAD_CTRL) 141#define MX25_PAD_D15__D15 IOMUX_PAD(0x280, 0x088, 0x00, 0, 0, NO_PAD_CTRL)
142#define MX25_PAD_D15__LD16 IOMUX_PAD(0x280, 0x088, 0x01, 0, 0, NO_PAD_CTRL) 142#define MX25_PAD_D15__LD16 IOMUX_PAD(0x280, 0x088, 0x01, 0, 0, PAD_CTL_SRE_FAST)
143#define MX25_PAD_D15__GPIO_4_5 IOMUX_PAD(0x280, 0x088, 0x05, 0, 0, NO_PAD_CTRL) 143#define MX25_PAD_D15__GPIO_4_5 IOMUX_PAD(0x280, 0x088, 0x05, 0, 0, NO_PAD_CTRL)
144 144
145#define MX25_PAD_D14__D14 IOMUX_PAD(0x284, 0x08c, 0x00, 0, 0, NO_PAD_CTRL) 145#define MX25_PAD_D14__D14 IOMUX_PAD(0x284, 0x08c, 0x00, 0, 0, NO_PAD_CTRL)
146#define MX25_PAD_D14__LD17 IOMUX_PAD(0x284, 0x08c, 0x01, 0, 0, NO_PAD_CTRL) 146#define MX25_PAD_D14__LD17 IOMUX_PAD(0x284, 0x08c, 0x01, 0, 0, PAD_CTL_SRE_FAST)
147#define MX25_PAD_D14__GPIO_4_6 IOMUX_PAD(0x284, 0x08c, 0x05, 0, 0, NO_PAD_CTRL) 147#define MX25_PAD_D14__GPIO_4_6 IOMUX_PAD(0x284, 0x08c, 0x05, 0, 0, NO_PAD_CTRL)
148 148
149#define MX25_PAD_D13__D13 IOMUX_PAD(0x288, 0x090, 0x00, 0, 0, NO_PAD_CTRL) 149#define MX25_PAD_D13__D13 IOMUX_PAD(0x288, 0x090, 0x00, 0, 0, NO_PAD_CTRL)
150#define MX25_PAD_D13__LD18 IOMUX_PAD(0x288, 0x090, 0x01, 0, 0, NO_PAD_CTRL) 150#define MX25_PAD_D13__LD18 IOMUX_PAD(0x288, 0x090, 0x01, 0, 0, PAD_CTL_SRE_FAST)
151#define MX25_PAD_D13__GPIO_4_7 IOMUX_PAD(0x288, 0x090, 0x05, 0, 0, NO_PAD_CTRL) 151#define MX25_PAD_D13__GPIO_4_7 IOMUX_PAD(0x288, 0x090, 0x05, 0, 0, NO_PAD_CTRL)
152 152
153#define MX25_PAD_D12__D12 IOMUX_PAD(0x28c, 0x094, 0x00, 0, 0, NO_PAD_CTRL) 153#define MX25_PAD_D12__D12 IOMUX_PAD(0x28c, 0x094, 0x00, 0, 0, NO_PAD_CTRL)
@@ -192,54 +192,54 @@
192#define MX25_PAD_D0__D0 IOMUX_PAD(0x2bc, 0x0c4, 0x00, 0, 0, NO_PAD_CTRL) 192#define MX25_PAD_D0__D0 IOMUX_PAD(0x2bc, 0x0c4, 0x00, 0, 0, NO_PAD_CTRL)
193#define MX25_PAD_D0__GPIO_4_20 IOMUX_PAD(0x2bc, 0x0c4, 0x05, 0, 0, NO_PAD_CTRL) 193#define MX25_PAD_D0__GPIO_4_20 IOMUX_PAD(0x2bc, 0x0c4, 0x05, 0, 0, NO_PAD_CTRL)
194 194
195#define MX25_PAD_LD0__LD0 IOMUX_PAD(0x2c0, 0x0c8, 0x10, 0, 0, NO_PAD_CTRL) 195#define MX25_PAD_LD0__LD0 IOMUX_PAD(0x2c0, 0x0c8, 0x10, 0, 0, PAD_CTL_SRE_FAST)
196#define MX25_PAD_LD0__CSI_D0 IOMUX_PAD(0x2c0, 0x0c8, 0x12, 0x488, 0, NO_PAD_CTRL) 196#define MX25_PAD_LD0__CSI_D0 IOMUX_PAD(0x2c0, 0x0c8, 0x12, 0x488, 0, NO_PAD_CTRL)
197#define MX25_PAD_LD0__GPIO_2_15 IOMUX_PAD(0x2c0, 0x0c8, 0x15, 0, 0, NO_PAD_CTRL) 197#define MX25_PAD_LD0__GPIO_2_15 IOMUX_PAD(0x2c0, 0x0c8, 0x15, 0, 0, NO_PAD_CTRL)
198 198
199#define MX25_PAD_LD1__LD1 IOMUX_PAD(0x2c4, 0x0cc, 0x10, 0, 0, NO_PAD_CTRL) 199#define MX25_PAD_LD1__LD1 IOMUX_PAD(0x2c4, 0x0cc, 0x10, 0, 0, PAD_CTL_SRE_FAST)
200#define MX25_PAD_LD1__CSI_D1 IOMUX_PAD(0x2c4, 0x0cc, 0x12, 0x48c, 0, NO_PAD_CTRL) 200#define MX25_PAD_LD1__CSI_D1 IOMUX_PAD(0x2c4, 0x0cc, 0x12, 0x48c, 0, NO_PAD_CTRL)
201#define MX25_PAD_LD1__GPIO_2_16 IOMUX_PAD(0x2c4, 0x0cc, 0x15, 0, 0, NO_PAD_CTRL) 201#define MX25_PAD_LD1__GPIO_2_16 IOMUX_PAD(0x2c4, 0x0cc, 0x15, 0, 0, NO_PAD_CTRL)
202 202
203#define MX25_PAD_LD2__LD2 IOMUX_PAD(0x2c8, 0x0d0, 0x10, 0, 0, NO_PAD_CTRL) 203#define MX25_PAD_LD2__LD2 IOMUX_PAD(0x2c8, 0x0d0, 0x10, 0, 0, PAD_CTL_SRE_FAST)
204#define MX25_PAD_LD2__GPIO_2_17 IOMUX_PAD(0x2c8, 0x0d0, 0x15, 0, 0, NO_PAD_CTRL) 204#define MX25_PAD_LD2__GPIO_2_17 IOMUX_PAD(0x2c8, 0x0d0, 0x15, 0, 0, NO_PAD_CTRL)
205 205
206#define MX25_PAD_LD3__LD3 IOMUX_PAD(0x2cc, 0x0d4, 0x10, 0, 0, NO_PAD_CTRL) 206#define MX25_PAD_LD3__LD3 IOMUX_PAD(0x2cc, 0x0d4, 0x10, 0, 0, PAD_CTL_SRE_FAST)
207#define MX25_PAD_LD3__GPIO_2_18 IOMUX_PAD(0x2cc, 0x0d4, 0x15, 0, 0, NO_PAD_CTRL) 207#define MX25_PAD_LD3__GPIO_2_18 IOMUX_PAD(0x2cc, 0x0d4, 0x15, 0, 0, NO_PAD_CTRL)
208 208
209#define MX25_PAD_LD4__LD4 IOMUX_PAD(0x2d0, 0x0d8, 0x10, 0, 0, NO_PAD_CTRL) 209#define MX25_PAD_LD4__LD4 IOMUX_PAD(0x2d0, 0x0d8, 0x10, 0, 0, PAD_CTL_SRE_FAST)
210#define MX25_PAD_LD4__GPIO_2_19 IOMUX_PAD(0x2d0, 0x0d8, 0x15, 0, 0, NO_PAD_CTRL) 210#define MX25_PAD_LD4__GPIO_2_19 IOMUX_PAD(0x2d0, 0x0d8, 0x15, 0, 0, NO_PAD_CTRL)
211 211
212#define MX25_PAD_LD5__LD5 IOMUX_PAD(0x2d4, 0x0dc, 0x10, 0, 0, NO_PAD_CTRL) 212#define MX25_PAD_LD5__LD5 IOMUX_PAD(0x2d4, 0x0dc, 0x10, 0, 0, PAD_CTL_SRE_FAST)
213#define MX25_PAD_LD5__GPIO_1_19 IOMUX_PAD(0x2d4, 0x0dc, 0x15, 0, 0, NO_PAD_CTRL) 213#define MX25_PAD_LD5__GPIO_1_19 IOMUX_PAD(0x2d4, 0x0dc, 0x15, 0, 0, NO_PAD_CTRL)
214 214
215#define MX25_PAD_LD6__LD6 IOMUX_PAD(0x2d8, 0x0e0, 0x10, 0, 0, NO_PAD_CTRL) 215#define MX25_PAD_LD6__LD6 IOMUX_PAD(0x2d8, 0x0e0, 0x10, 0, 0, PAD_CTL_SRE_FAST)
216#define MX25_PAD_LD6__GPIO_1_20 IOMUX_PAD(0x2d8, 0x0e0, 0x15, 0, 0, NO_PAD_CTRL) 216#define MX25_PAD_LD6__GPIO_1_20 IOMUX_PAD(0x2d8, 0x0e0, 0x15, 0, 0, NO_PAD_CTRL)
217 217
218#define MX25_PAD_LD7__LD7 IOMUX_PAD(0x2dc, 0x0e4, 0x10, 0, 0, NO_PAD_CTRL) 218#define MX25_PAD_LD7__LD7 IOMUX_PAD(0x2dc, 0x0e4, 0x10, 0, 0, PAD_CTL_SRE_FAST)
219#define MX25_PAD_LD7__GPIO_1_21 IOMUX_PAD(0x2dc, 0x0e4, 0x15, 0, 0, NO_PAD_CTRL) 219#define MX25_PAD_LD7__GPIO_1_21 IOMUX_PAD(0x2dc, 0x0e4, 0x15, 0, 0, NO_PAD_CTRL)
220 220
221#define MX25_PAD_LD8__LD8 IOMUX_PAD(0x2e0, 0x0e8, 0x10, 0, 0, NO_PAD_CTRL) 221#define MX25_PAD_LD8__LD8 IOMUX_PAD(0x2e0, 0x0e8, 0x10, 0, 0, PAD_CTL_SRE_FAST)
222#define MX25_PAD_LD8__FEC_TX_ERR IOMUX_PAD(0x2e0, 0x0e8, 0x15, 0, 0, NO_PAD_CTRL) 222#define MX25_PAD_LD8__FEC_TX_ERR IOMUX_PAD(0x2e0, 0x0e8, 0x15, 0, 0, NO_PAD_CTRL)
223 223
224#define MX25_PAD_LD9__LD9 IOMUX_PAD(0x2e4, 0x0ec, 0x10, 0, 0, NO_PAD_CTRL) 224#define MX25_PAD_LD9__LD9 IOMUX_PAD(0x2e4, 0x0ec, 0x10, 0, 0, PAD_CTL_SRE_FAST)
225#define MX25_PAD_LD9__FEC_COL IOMUX_PAD(0x2e4, 0x0ec, 0x15, 0x504, 1, NO_PAD_CTRL) 225#define MX25_PAD_LD9__FEC_COL IOMUX_PAD(0x2e4, 0x0ec, 0x15, 0x504, 1, NO_PAD_CTRL)
226 226
227#define MX25_PAD_LD10__LD10 IOMUX_PAD(0x2e8, 0x0f0, 0x10, 0, 0, NO_PAD_CTRL) 227#define MX25_PAD_LD10__LD10 IOMUX_PAD(0x2e8, 0x0f0, 0x10, 0, 0, PAD_CTL_SRE_FAST)
228#define MX25_PAD_LD10__FEC_RX_ER IOMUX_PAD(0x2e8, 0x0f0, 0x15, 0x518, 1, NO_PAD_CTRL) 228#define MX25_PAD_LD10__FEC_RX_ER IOMUX_PAD(0x2e8, 0x0f0, 0x15, 0x518, 1, NO_PAD_CTRL)
229 229
230#define MX25_PAD_LD11__LD11 IOMUX_PAD(0x2ec, 0x0f4, 0x10, 0, 0, NO_PAD_CTRL) 230#define MX25_PAD_LD11__LD11 IOMUX_PAD(0x2ec, 0x0f4, 0x10, 0, 0, PAD_CTL_SRE_FAST)
231#define MX25_PAD_LD11__FEC_RDATA2 IOMUX_PAD(0x2ec, 0x0f4, 0x15, 0x50c, 1, NO_PAD_CTRL) 231#define MX25_PAD_LD11__FEC_RDATA2 IOMUX_PAD(0x2ec, 0x0f4, 0x15, 0x50c, 1, NO_PAD_CTRL)
232 232
233#define MX25_PAD_LD12__LD12 IOMUX_PAD(0x2f0, 0x0f8, 0x10, 0, 0, NO_PAD_CTRL) 233#define MX25_PAD_LD12__LD12 IOMUX_PAD(0x2f0, 0x0f8, 0x10, 0, 0, PAD_CTL_SRE_FAST)
234#define MX25_PAD_LD12__FEC_RDATA3 IOMUX_PAD(0x2f0, 0x0f8, 0x15, 0x510, 1, NO_PAD_CTRL) 234#define MX25_PAD_LD12__FEC_RDATA3 IOMUX_PAD(0x2f0, 0x0f8, 0x15, 0x510, 1, NO_PAD_CTRL)
235 235
236#define MX25_PAD_LD13__LD13 IOMUX_PAD(0x2f4, 0x0fc, 0x10, 0, 0, NO_PAD_CTRL) 236#define MX25_PAD_LD13__LD13 IOMUX_PAD(0x2f4, 0x0fc, 0x10, 0, 0, PAD_CTL_SRE_FAST)
237#define MX25_PAD_LD13__FEC_TDATA2 IOMUX_PAD(0x2f4, 0x0fc, 0x15, 0, 0, NO_PAD_CTRL) 237#define MX25_PAD_LD13__FEC_TDATA2 IOMUX_PAD(0x2f4, 0x0fc, 0x15, 0, 0, NO_PAD_CTRL)
238 238
239#define MX25_PAD_LD14__LD14 IOMUX_PAD(0x2f8, 0x100, 0x10, 0, 0, NO_PAD_CTRL) 239#define MX25_PAD_LD14__LD14 IOMUX_PAD(0x2f8, 0x100, 0x10, 0, 0, PAD_CTL_SRE_FAST)
240#define MX25_PAD_LD14__FEC_TDATA3 IOMUX_PAD(0x2f8, 0x100, 0x15, 0, 0, NO_PAD_CTRL) 240#define MX25_PAD_LD14__FEC_TDATA3 IOMUX_PAD(0x2f8, 0x100, 0x15, 0, 0, NO_PAD_CTRL)
241 241
242#define MX25_PAD_LD15__LD15 IOMUX_PAD(0x2fc, 0x104, 0x10, 0, 0, NO_PAD_CTRL) 242#define MX25_PAD_LD15__LD15 IOMUX_PAD(0x2fc, 0x104, 0x10, 0, 0, PAD_CTL_SRE_FAST)
243#define MX25_PAD_LD15__FEC_RX_CLK IOMUX_PAD(0x2fc, 0x104, 0x15, 0x514, 1, NO_PAD_CTRL) 243#define MX25_PAD_LD15__FEC_RX_CLK IOMUX_PAD(0x2fc, 0x104, 0x15, 0x514, 1, NO_PAD_CTRL)
244 244
245#define MX25_PAD_HSYNC__HSYNC IOMUX_PAD(0x300, 0x108, 0x10, 0, 0, NO_PAD_CTRL) 245#define MX25_PAD_HSYNC__HSYNC IOMUX_PAD(0x300, 0x108, 0x10, 0, 0, NO_PAD_CTRL)
@@ -468,11 +468,11 @@
468#define MX25_PAD_GPIO_C__CAN2_TX IOMUX_PAD(0x3f8, 0x1fc, 0x16, 0, 0, PAD_CTL_PUS_22K_UP) 468#define MX25_PAD_GPIO_C__CAN2_TX IOMUX_PAD(0x3f8, 0x1fc, 0x16, 0, 0, PAD_CTL_PUS_22K_UP)
469 469
470#define MX25_PAD_GPIO_D__GPIO_D IOMUX_PAD(0x3fc, 0x200, 0x10, 0, 0, NO_PAD_CTRL) 470#define MX25_PAD_GPIO_D__GPIO_D IOMUX_PAD(0x3fc, 0x200, 0x10, 0, 0, NO_PAD_CTRL)
471#define MX25_PAD_GPIO_E__LD16 IOMUX_PAD(0x400, 0x204, 0x02, 0, 0, NO_PAD_CTRL) 471#define MX25_PAD_GPIO_E__LD16 IOMUX_PAD(0x400, 0x204, 0x02, 0, 0, PAD_CTL_SRE_FAST)
472#define MX25_PAD_GPIO_D__CAN2_RX IOMUX_PAD(0x3fc, 0x200, 0x16, 0x484, 1, PAD_CTL_PUS_22K_UP) 472#define MX25_PAD_GPIO_D__CAN2_RX IOMUX_PAD(0x3fc, 0x200, 0x16, 0x484, 1, PAD_CTL_PUS_22K_UP)
473 473
474#define MX25_PAD_GPIO_E__GPIO_E IOMUX_PAD(0x400, 0x204, 0x10, 0, 0, NO_PAD_CTRL) 474#define MX25_PAD_GPIO_E__GPIO_E IOMUX_PAD(0x400, 0x204, 0x10, 0, 0, NO_PAD_CTRL)
475#define MX25_PAD_GPIO_F__LD17 IOMUX_PAD(0x404, 0x208, 0x02, 0, 0, NO_PAD_CTRL) 475#define MX25_PAD_GPIO_F__LD17 IOMUX_PAD(0x404, 0x208, 0x02, 0, 0, PAD_CTL_SRE_FAST)
476#define MX25_PAD_GPIO_E__AUD7_TXD IOMUX_PAD(0x400, 0x204, 0x14, 0, 0, NO_PAD_CTRL) 476#define MX25_PAD_GPIO_E__AUD7_TXD IOMUX_PAD(0x400, 0x204, 0x14, 0, 0, NO_PAD_CTRL)
477 477
478#define MX25_PAD_GPIO_F__GPIO_F IOMUX_PAD(0x404, 0x208, 0x10, 0, 0, NO_PAD_CTRL) 478#define MX25_PAD_GPIO_F__GPIO_F IOMUX_PAD(0x404, 0x208, 0x10, 0, 0, NO_PAD_CTRL)
diff --git a/arch/arm/plat-mxc/include/mach/system.h b/arch/arm/plat-mxc/include/mach/system.h
deleted file mode 100644
index 13ad0df2e86..00000000000
--- a/arch/arm/plat-mxc/include/mach/system.h
+++ /dev/null
@@ -1,25 +0,0 @@
1/*
2 * Copyright (C) 1999 ARM Limited
3 * Copyright (C) 2000 Deep Blue Solutions Ltd
4 * Copyright 2004-2008 Freescale Semiconductor, Inc. All Rights Reserved.
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
17#ifndef __ASM_ARCH_MXC_SYSTEM_H__
18#define __ASM_ARCH_MXC_SYSTEM_H__
19
20static inline void arch_idle(void)
21{
22 cpu_do_idle();
23}
24
25#endif /* __ASM_ARCH_MXC_SYSTEM_H__ */
diff --git a/arch/arm/plat-mxc/pwm.c b/arch/arm/plat-mxc/pwm.c
index e032717f7d0..c0cab2270dd 100644
--- a/arch/arm/plat-mxc/pwm.c
+++ b/arch/arm/plat-mxc/pwm.c
@@ -132,7 +132,7 @@ int pwm_enable(struct pwm_device *pwm)
132 int rc = 0; 132 int rc = 0;
133 133
134 if (!pwm->clk_enabled) { 134 if (!pwm->clk_enabled) {
135 rc = clk_enable(pwm->clk); 135 rc = clk_prepare_enable(pwm->clk);
136 if (!rc) 136 if (!rc)
137 pwm->clk_enabled = 1; 137 pwm->clk_enabled = 1;
138 } 138 }
@@ -145,7 +145,7 @@ void pwm_disable(struct pwm_device *pwm)
145 writel(0, pwm->mmio_base + MX3_PWMCR); 145 writel(0, pwm->mmio_base + MX3_PWMCR);
146 146
147 if (pwm->clk_enabled) { 147 if (pwm->clk_enabled) {
148 clk_disable(pwm->clk); 148 clk_disable_unprepare(pwm->clk);
149 pwm->clk_enabled = 0; 149 pwm->clk_enabled = 0;
150 } 150 }
151} 151}
diff --git a/arch/arm/plat-mxc/system.c b/arch/arm/plat-mxc/system.c
index c195d6d04d1..1996c3e3b8f 100644
--- a/arch/arm/plat-mxc/system.c
+++ b/arch/arm/plat-mxc/system.c
@@ -48,7 +48,7 @@ void mxc_restart(char mode, const char *cmd)
48 48
49 clk = clk_get_sys("imx2-wdt.0", NULL); 49 clk = clk_get_sys("imx2-wdt.0", NULL);
50 if (!IS_ERR(clk)) 50 if (!IS_ERR(clk))
51 clk_enable(clk); 51 clk_prepare_enable(clk);
52 wcr_enable = (1 << 2); 52 wcr_enable = (1 << 2);
53 } 53 }
54 54
diff --git a/arch/arm/plat-mxc/time.c b/arch/arm/plat-mxc/time.c
index 1c96cdb4c35..7daf7c9a413 100644
--- a/arch/arm/plat-mxc/time.c
+++ b/arch/arm/plat-mxc/time.c
@@ -283,7 +283,7 @@ void __init mxc_timer_init(struct clk *timer_clk, void __iomem *base, int irq)
283{ 283{
284 uint32_t tctl_val; 284 uint32_t tctl_val;
285 285
286 clk_enable(timer_clk); 286 clk_prepare_enable(timer_clk);
287 287
288 timer_base = base; 288 timer_base = base;
289 289
diff --git a/arch/arm/plat-nomadik/include/plat/mtu.h b/arch/arm/plat-nomadik/include/plat/mtu.h
index 6508e7694a4..582641f3dc0 100644
--- a/arch/arm/plat-nomadik/include/plat/mtu.h
+++ b/arch/arm/plat-nomadik/include/plat/mtu.h
@@ -1,9 +1,7 @@
1#ifndef __PLAT_MTU_H 1#ifndef __PLAT_MTU_H
2#define __PLAT_MTU_H 2#define __PLAT_MTU_H
3 3
4/* should be set by the platform code */ 4void nmdk_timer_init(void __iomem *base);
5extern void __iomem *mtu_base;
6
7void nmdk_clkevt_reset(void); 5void nmdk_clkevt_reset(void);
8void nmdk_clksrc_reset(void); 6void nmdk_clksrc_reset(void);
9 7
diff --git a/arch/arm/plat-nomadik/timer.c b/arch/arm/plat-nomadik/timer.c
index ad1b45b605a..9222e5522a4 100644
--- a/arch/arm/plat-nomadik/timer.c
+++ b/arch/arm/plat-nomadik/timer.c
@@ -21,12 +21,6 @@
21#include <asm/sched_clock.h> 21#include <asm/sched_clock.h>
22 22
23/* 23/*
24 * Guaranteed runtime conversion range in seconds for
25 * the clocksource and clockevent.
26 */
27#define MTU_MIN_RANGE 4
28
29/*
30 * The MTU device hosts four different counters, with 4 set of 24 * The MTU device hosts four different counters, with 4 set of
31 * registers. These are register names. 25 * registers. These are register names.
32 */ 26 */
@@ -66,12 +60,11 @@
66#define MTU_PCELL2 0xff8 60#define MTU_PCELL2 0xff8
67#define MTU_PCELL3 0xffC 61#define MTU_PCELL3 0xffC
68 62
63static void __iomem *mtu_base;
69static bool clkevt_periodic; 64static bool clkevt_periodic;
70static u32 clk_prescale; 65static u32 clk_prescale;
71static u32 nmdk_cycle; /* write-once */ 66static u32 nmdk_cycle; /* write-once */
72 67
73void __iomem *mtu_base; /* Assigned by machine code */
74
75#ifdef CONFIG_NOMADIK_MTU_SCHED_CLOCK 68#ifdef CONFIG_NOMADIK_MTU_SCHED_CLOCK
76/* 69/*
77 * Override the global weak sched_clock symbol with this 70 * Override the global weak sched_clock symbol with this
@@ -103,7 +96,6 @@ static int nmdk_clkevt_next(unsigned long evt, struct clock_event_device *ev)
103void nmdk_clkevt_reset(void) 96void nmdk_clkevt_reset(void)
104{ 97{
105 if (clkevt_periodic) { 98 if (clkevt_periodic) {
106
107 /* Timer: configure load and background-load, and fire it up */ 99 /* Timer: configure load and background-load, and fire it up */
108 writel(nmdk_cycle, mtu_base + MTU_LR(1)); 100 writel(nmdk_cycle, mtu_base + MTU_LR(1));
109 writel(nmdk_cycle, mtu_base + MTU_BGLR(1)); 101 writel(nmdk_cycle, mtu_base + MTU_BGLR(1));
@@ -121,7 +113,6 @@ void nmdk_clkevt_reset(void)
121static void nmdk_clkevt_mode(enum clock_event_mode mode, 113static void nmdk_clkevt_mode(enum clock_event_mode mode,
122 struct clock_event_device *dev) 114 struct clock_event_device *dev)
123{ 115{
124
125 switch (mode) { 116 switch (mode) {
126 case CLOCK_EVT_MODE_PERIODIC: 117 case CLOCK_EVT_MODE_PERIODIC:
127 clkevt_periodic = true; 118 clkevt_periodic = true;
@@ -183,15 +174,16 @@ void nmdk_clksrc_reset(void)
183 mtu_base + MTU_CR(0)); 174 mtu_base + MTU_CR(0));
184} 175}
185 176
186void __init nmdk_timer_init(void) 177void __init nmdk_timer_init(void __iomem *base)
187{ 178{
188 unsigned long rate; 179 unsigned long rate;
189 struct clk *clk0; 180 struct clk *clk0;
190 181
182 mtu_base = base;
191 clk0 = clk_get_sys("mtu0", NULL); 183 clk0 = clk_get_sys("mtu0", NULL);
192 BUG_ON(IS_ERR(clk0)); 184 BUG_ON(IS_ERR(clk0));
193 185 BUG_ON(clk_prepare(clk0) < 0);
194 clk_enable(clk0); 186 BUG_ON(clk_enable(clk0) < 0);
195 187
196 /* 188 /*
197 * Tick rate is 2.4MHz for Nomadik and 2.4Mhz, 100MHz or 133 MHz 189 * Tick rate is 2.4MHz for Nomadik and 2.4Mhz, 100MHz or 133 MHz
@@ -224,17 +216,8 @@ void __init nmdk_timer_init(void)
224 setup_sched_clock(nomadik_read_sched_clock, 32, rate); 216 setup_sched_clock(nomadik_read_sched_clock, 32, rate);
225#endif 217#endif
226 218
227 /* Timer 1 is used for events */ 219 /* Timer 1 is used for events, register irq and clockevents */
228
229 clockevents_calc_mult_shift(&nmdk_clkevt, rate, MTU_MIN_RANGE);
230
231 nmdk_clkevt.max_delta_ns =
232 clockevent_delta2ns(0xffffffff, &nmdk_clkevt);
233 nmdk_clkevt.min_delta_ns =
234 clockevent_delta2ns(0x00000002, &nmdk_clkevt);
235 nmdk_clkevt.cpumask = cpumask_of(0);
236
237 /* Register irq and clockevents */
238 setup_irq(IRQ_MTU0, &nmdk_timer_irq); 220 setup_irq(IRQ_MTU0, &nmdk_timer_irq);
239 clockevents_register_device(&nmdk_clkevt); 221 nmdk_clkevt.cpumask = cpumask_of(0);
222 clockevents_config_and_register(&nmdk_clkevt, rate, 2, 0xffffffffU);
240} 223}
diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
index 8f81503a4df..ce1e9b96ba1 100644
--- a/arch/arm/plat-omap/Kconfig
+++ b/arch/arm/plat-omap/Kconfig
@@ -14,6 +14,7 @@ config ARCH_OMAP1
14 select CLKDEV_LOOKUP 14 select CLKDEV_LOOKUP
15 select CLKSRC_MMIO 15 select CLKSRC_MMIO
16 select GENERIC_IRQ_CHIP 16 select GENERIC_IRQ_CHIP
17 select IRQ_DOMAIN
17 select HAVE_IDE 18 select HAVE_IDE
18 select NEED_MACH_MEMORY_H 19 select NEED_MACH_MEMORY_H
19 help 20 help
@@ -24,6 +25,8 @@ config ARCH_OMAP2PLUS
24 select CLKDEV_LOOKUP 25 select CLKDEV_LOOKUP
25 select GENERIC_IRQ_CHIP 26 select GENERIC_IRQ_CHIP
26 select OMAP_DM_TIMER 27 select OMAP_DM_TIMER
28 select USE_OF
29 select PROC_DEVICETREE if PROC_FS
27 help 30 help
28 "Systems based on OMAP2, OMAP3 or OMAP4" 31 "Systems based on OMAP2, OMAP3 or OMAP4"
29 32
diff --git a/arch/arm/plat-omap/clock.c b/arch/arm/plat-omap/clock.c
index 567e4b54f24..56b6f8b7053 100644
--- a/arch/arm/plat-omap/clock.c
+++ b/arch/arm/plat-omap/clock.c
@@ -20,7 +20,6 @@
20#include <linux/clk.h> 20#include <linux/clk.h>
21#include <linux/mutex.h> 21#include <linux/mutex.h>
22#include <linux/cpufreq.h> 22#include <linux/cpufreq.h>
23#include <linux/debugfs.h>
24#include <linux/io.h> 23#include <linux/io.h>
25 24
26#include <plat/clock.h> 25#include <plat/clock.h>
diff --git a/arch/arm/plat-omap/counter_32k.c b/arch/arm/plat-omap/counter_32k.c
index 5f0f2292b7f..5068fe5a691 100644
--- a/arch/arm/plat-omap/counter_32k.c
+++ b/arch/arm/plat-omap/counter_32k.c
@@ -21,6 +21,7 @@
21 21
22#include <asm/sched_clock.h> 22#include <asm/sched_clock.h>
23 23
24#include <plat/hardware.h>
24#include <plat/common.h> 25#include <plat/common.h>
25#include <plat/board.h> 26#include <plat/board.h>
26 27
diff --git a/arch/arm/plat-omap/dma.c b/arch/arm/plat-omap/dma.c
index dbb10497d2a..ecdb3da0dea 100644
--- a/arch/arm/plat-omap/dma.c
+++ b/arch/arm/plat-omap/dma.c
@@ -163,6 +163,8 @@ static inline void set_gdma_dev(int req, int dev)
163} 163}
164#else 164#else
165#define set_gdma_dev(req, dev) do {} while (0) 165#define set_gdma_dev(req, dev) do {} while (0)
166#define omap_readl(reg) 0
167#define omap_writel(val, reg) do {} while (0)
166#endif 168#endif
167 169
168void omap_set_dma_priority(int lch, int dst_port, int priority) 170void omap_set_dma_priority(int lch, int dst_port, int priority)
@@ -2124,7 +2126,7 @@ static int __devexit omap_system_dma_remove(struct platform_device *pdev)
2124 2126
2125static struct platform_driver omap_system_dma_driver = { 2127static struct platform_driver omap_system_dma_driver = {
2126 .probe = omap_system_dma_probe, 2128 .probe = omap_system_dma_probe,
2127 .remove = omap_system_dma_remove, 2129 .remove = __devexit_p(omap_system_dma_remove),
2128 .driver = { 2130 .driver = {
2129 .name = "omap_dma_system" 2131 .name = "omap_dma_system"
2130 }, 2132 },
diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
index af3b92be845..652139c0339 100644
--- a/arch/arm/plat-omap/dmtimer.c
+++ b/arch/arm/plat-omap/dmtimer.c
@@ -43,6 +43,8 @@
43 43
44#include <plat/dmtimer.h> 44#include <plat/dmtimer.h>
45 45
46#include <mach/hardware.h>
47
46static LIST_HEAD(omap_timer_list); 48static LIST_HEAD(omap_timer_list);
47static DEFINE_SPINLOCK(dm_timer_lock); 49static DEFINE_SPINLOCK(dm_timer_lock);
48 50
@@ -80,9 +82,9 @@ static void omap_dm_timer_write_reg(struct omap_dm_timer *timer, u32 reg,
80 82
81static void omap_timer_restore_context(struct omap_dm_timer *timer) 83static void omap_timer_restore_context(struct omap_dm_timer *timer)
82{ 84{
83 omap_dm_timer_write_reg(timer, OMAP_TIMER_OCP_CFG_OFFSET, 85 __raw_writel(timer->context.tiocp_cfg,
84 timer->context.tiocp_cfg); 86 timer->io_base + OMAP_TIMER_OCP_CFG_OFFSET);
85 if (timer->revision > 1) 87 if (timer->revision == 1)
86 __raw_writel(timer->context.tistat, timer->sys_stat); 88 __raw_writel(timer->context.tistat, timer->sys_stat);
87 89
88 __raw_writel(timer->context.tisr, timer->irq_stat); 90 __raw_writel(timer->context.tisr, timer->irq_stat);
@@ -357,6 +359,19 @@ int omap_dm_timer_stop(struct omap_dm_timer *timer)
357 359
358 __omap_dm_timer_stop(timer, timer->posted, rate); 360 __omap_dm_timer_stop(timer, timer->posted, rate);
359 361
362 if (timer->loses_context && timer->get_context_loss_count)
363 timer->ctx_loss_count =
364 timer->get_context_loss_count(&timer->pdev->dev);
365
366 /*
367 * Since the register values are computed and written within
368 * __omap_dm_timer_stop, we need to use read to retrieve the
369 * context.
370 */
371 timer->context.tclr =
372 omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG);
373 timer->context.tisr = __raw_readl(timer->irq_stat);
374 omap_dm_timer_disable(timer);
360 return 0; 375 return 0;
361} 376}
362EXPORT_SYMBOL_GPL(omap_dm_timer_stop); 377EXPORT_SYMBOL_GPL(omap_dm_timer_stop);
diff --git a/arch/arm/plat-omap/include/plat/board-ams-delta.h b/arch/arm/plat-omap/include/plat/board-ams-delta.h
index 51b102dc906..ad6f865d1f1 100644
--- a/arch/arm/plat-omap/include/plat/board-ams-delta.h
+++ b/arch/arm/plat-omap/include/plat/board-ams-delta.h
@@ -28,33 +28,8 @@
28 28
29#if defined (CONFIG_MACH_AMS_DELTA) 29#if defined (CONFIG_MACH_AMS_DELTA)
30 30
31#define AMS_DELTA_LATCH1_PHYS 0x01000000
32#define AMS_DELTA_LATCH1_VIRT 0xEA000000
33#define AMS_DELTA_MODEM_PHYS 0x04000000
34#define AMS_DELTA_MODEM_VIRT 0xEB000000
35#define AMS_DELTA_LATCH2_PHYS 0x08000000
36#define AMS_DELTA_LATCH2_VIRT 0xEC000000
37
38#define AMS_DELTA_LATCH1_LED_CAMERA 0x01
39#define AMS_DELTA_LATCH1_LED_ADVERT 0x02
40#define AMS_DELTA_LATCH1_LED_EMAIL 0x04
41#define AMS_DELTA_LATCH1_LED_HANDSFREE 0x08
42#define AMS_DELTA_LATCH1_LED_VOICEMAIL 0x10
43#define AMS_DELTA_LATCH1_LED_VOICE 0x20
44
45#define AMS_DELTA_LATCH2_LCD_VBLEN 0x0001
46#define AMS_DELTA_LATCH2_LCD_NDISP 0x0002
47#define AMS_DELTA_LATCH2_NAND_NCE 0x0004
48#define AMS_DELTA_LATCH2_NAND_NRE 0x0008
49#define AMS_DELTA_LATCH2_NAND_NWP 0x0010
50#define AMS_DELTA_LATCH2_NAND_NWE 0x0020
51#define AMS_DELTA_LATCH2_NAND_ALE 0x0040
52#define AMS_DELTA_LATCH2_NAND_CLE 0x0080
53#define AMD_DELTA_LATCH2_KEYBRD_PWR 0x0100
54#define AMD_DELTA_LATCH2_KEYBRD_DATA 0x0200
55#define AMD_DELTA_LATCH2_SCARD_RSTIN 0x0400 31#define AMD_DELTA_LATCH2_SCARD_RSTIN 0x0400
56#define AMD_DELTA_LATCH2_SCARD_CMDVCC 0x0800 32#define AMD_DELTA_LATCH2_SCARD_CMDVCC 0x0800
57#define AMS_DELTA_LATCH2_MODEM_NRESET 0x1000
58#define AMS_DELTA_LATCH2_MODEM_CODEC 0x2000 33#define AMS_DELTA_LATCH2_MODEM_CODEC 0x2000
59 34
60#define AMS_DELTA_GPIO_PIN_KEYBRD_DATA 0 35#define AMS_DELTA_GPIO_PIN_KEYBRD_DATA 0
@@ -66,9 +41,29 @@
66#define AMS_DELTA_GPIO_PIN_CONFIG 11 41#define AMS_DELTA_GPIO_PIN_CONFIG 11
67#define AMS_DELTA_GPIO_PIN_NAND_RB 12 42#define AMS_DELTA_GPIO_PIN_NAND_RB 12
68 43
44#define AMS_DELTA_GPIO_PIN_LCD_VBLEN 240
45#define AMS_DELTA_GPIO_PIN_LCD_NDISP 241
46#define AMS_DELTA_GPIO_PIN_NAND_NCE 242
47#define AMS_DELTA_GPIO_PIN_NAND_NRE 243
48#define AMS_DELTA_GPIO_PIN_NAND_NWP 244
49#define AMS_DELTA_GPIO_PIN_NAND_NWE 245
50#define AMS_DELTA_GPIO_PIN_NAND_ALE 246
51#define AMS_DELTA_GPIO_PIN_NAND_CLE 247
52#define AMS_DELTA_GPIO_PIN_KEYBRD_PWR 248
53#define AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT 249
54#define AMS_DELTA_GPIO_PIN_SCARD_RSTIN 250
55#define AMS_DELTA_GPIO_PIN_SCARD_CMDVCC 251
56#define AMS_DELTA_GPIO_PIN_MODEM_NRESET 252
57#define AMS_DELTA_GPIO_PIN_MODEM_CODEC 253
58
59#define AMS_DELTA_LATCH2_GPIO_BASE AMS_DELTA_GPIO_PIN_LCD_VBLEN
60#define AMS_DELTA_LATCH2_NGPIO 16
61
69#ifndef __ASSEMBLY__ 62#ifndef __ASSEMBLY__
70void ams_delta_latch1_write(u8 mask, u8 value); 63void ams_delta_latch_write(int base, int ngpio, u16 mask, u16 value);
71void ams_delta_latch2_write(u16 mask, u16 value); 64#define ams_delta_latch2_write(mask, value) \
65 ams_delta_latch_write(AMS_DELTA_LATCH2_GPIO_BASE, \
66 AMS_DELTA_LATCH2_NGPIO, (mask), (value))
72#endif 67#endif
73 68
74#endif /* CONFIG_MACH_AMS_DELTA */ 69#endif /* CONFIG_MACH_AMS_DELTA */
diff --git a/arch/arm/plat-omap/include/plat/cpu.h b/arch/arm/plat-omap/include/plat/cpu.h
index 6b51086fce1..dc6a86bf217 100644
--- a/arch/arm/plat-omap/include/plat/cpu.h
+++ b/arch/arm/plat-omap/include/plat/cpu.h
@@ -250,7 +250,6 @@ IS_AM_SUBCLASS(335x, 0x335)
250 * cpu_is_omap2423(): True for OMAP2423 250 * cpu_is_omap2423(): True for OMAP2423
251 * cpu_is_omap2430(): True for OMAP2430 251 * cpu_is_omap2430(): True for OMAP2430
252 * cpu_is_omap3430(): True for OMAP3430 252 * cpu_is_omap3430(): True for OMAP3430
253 * cpu_is_omap4430(): True for OMAP4430
254 * cpu_is_omap3505(): True for OMAP3505 253 * cpu_is_omap3505(): True for OMAP3505
255 * cpu_is_omap3517(): True for OMAP3517 254 * cpu_is_omap3517(): True for OMAP3517
256 */ 255 */
@@ -299,7 +298,6 @@ IS_OMAP_TYPE(3517, 0x3517)
299#define cpu_is_omap3505() 0 298#define cpu_is_omap3505() 0
300#define cpu_is_omap3517() 0 299#define cpu_is_omap3517() 0
301#define cpu_is_omap3430() 0 300#define cpu_is_omap3430() 0
302#define cpu_is_omap4430() 0
303#define cpu_is_omap3630() 0 301#define cpu_is_omap3630() 0
304 302
305/* 303/*
@@ -451,7 +449,12 @@ IS_OMAP_TYPE(3517, 0x3517)
451#define OMAP447X_CLASS 0x44700044 449#define OMAP447X_CLASS 0x44700044
452#define OMAP4470_REV_ES1_0 (OMAP447X_CLASS | (0x10 << 8)) 450#define OMAP4470_REV_ES1_0 (OMAP447X_CLASS | (0x10 << 8))
453 451
454void omap2_check_revision(void); 452void omap2xxx_check_revision(void);
453void omap3xxx_check_revision(void);
454void omap4xxx_check_revision(void);
455void omap3xxx_check_features(void);
456void ti81xx_check_features(void);
457void omap4xxx_check_features(void);
455 458
456/* 459/*
457 * Runtime detection of OMAP3 features 460 * Runtime detection of OMAP3 features
diff --git a/arch/arm/plat-omap/include/plat/gpio.h b/arch/arm/plat-omap/include/plat/gpio.h
index 9e86ee0aed0..b8a96c6a1a3 100644
--- a/arch/arm/plat-omap/include/plat/gpio.h
+++ b/arch/arm/plat-omap/include/plat/gpio.h
@@ -162,13 +162,6 @@
162 IH_MPUIO_BASE + ((nr) & 0x0f) : \ 162 IH_MPUIO_BASE + ((nr) & 0x0f) : \
163 IH_GPIO_BASE + (nr)) 163 IH_GPIO_BASE + (nr))
164 164
165#define METHOD_MPUIO 0
166#define METHOD_GPIO_1510 1
167#define METHOD_GPIO_1610 2
168#define METHOD_GPIO_7XX 3
169#define METHOD_GPIO_24XX 5
170#define METHOD_GPIO_44XX 6
171
172struct omap_gpio_dev_attr { 165struct omap_gpio_dev_attr {
173 int bank_width; /* GPIO bank width */ 166 int bank_width; /* GPIO bank width */
174 bool dbck_flag; /* dbck required or not - True for OMAP3&4 */ 167 bool dbck_flag; /* dbck required or not - True for OMAP3&4 */
@@ -184,10 +177,21 @@ struct omap_gpio_reg_offs {
184 u16 irqstatus; 177 u16 irqstatus;
185 u16 irqstatus2; 178 u16 irqstatus2;
186 u16 irqenable; 179 u16 irqenable;
180 u16 irqenable2;
187 u16 set_irqenable; 181 u16 set_irqenable;
188 u16 clr_irqenable; 182 u16 clr_irqenable;
189 u16 debounce; 183 u16 debounce;
190 u16 debounce_en; 184 u16 debounce_en;
185 u16 ctrl;
186 u16 wkup_en;
187 u16 leveldetect0;
188 u16 leveldetect1;
189 u16 risingdetect;
190 u16 fallingdetect;
191 u16 irqctrl;
192 u16 edgectrl1;
193 u16 edgectrl2;
194 u16 pinctrl;
191 195
192 bool irqenable_inv; 196 bool irqenable_inv;
193}; 197};
@@ -198,45 +202,30 @@ struct omap_gpio_platform_data {
198 int bank_width; /* GPIO bank width */ 202 int bank_width; /* GPIO bank width */
199 int bank_stride; /* Only needed for omap1 MPUIO */ 203 int bank_stride; /* Only needed for omap1 MPUIO */
200 bool dbck_flag; /* dbck required or not - True for OMAP3&4 */ 204 bool dbck_flag; /* dbck required or not - True for OMAP3&4 */
205 bool loses_context; /* whether the bank would ever lose context */
206 bool is_mpuio; /* whether the bank is of type MPUIO */
207 u32 non_wakeup_gpios;
201 208
202 struct omap_gpio_reg_offs *regs; 209 struct omap_gpio_reg_offs *regs;
203};
204 210
205/* TODO: Analyze removing gpio_bank_count usage from driver code */ 211 /* Return context loss count due to PM states changing */
206extern int gpio_bank_count; 212 int (*get_context_loss_count)(struct device *dev);
213};
207 214
208extern void omap2_gpio_prepare_for_idle(int off_mode); 215extern void omap2_gpio_prepare_for_idle(int off_mode);
209extern void omap2_gpio_resume_after_idle(void); 216extern void omap2_gpio_resume_after_idle(void);
210extern void omap_set_gpio_debounce(int gpio, int enable); 217extern void omap_set_gpio_debounce(int gpio, int enable);
211extern void omap_set_gpio_debounce_time(int gpio, int enable); 218extern void omap_set_gpio_debounce_time(int gpio, int enable);
212extern void omap_gpio_save_context(void);
213extern void omap_gpio_restore_context(void);
214/*-------------------------------------------------------------------------*/ 219/*-------------------------------------------------------------------------*/
215 220
216/* Wrappers for "new style" GPIO calls, using the new infrastructure 221/*
222 * Wrappers for "new style" GPIO calls, using the new infrastructure
217 * which lets us plug in FPGA, I2C, and other implementations. 223 * which lets us plug in FPGA, I2C, and other implementations.
218 * * 224 *
219 * The original OMAP-specific calls should eventually be removed. 225 * The original OMAP-specific calls should eventually be removed.
220 */ 226 */
221 227
222#include <linux/errno.h> 228#include <linux/errno.h>
223#include <asm-generic/gpio.h> 229#include <asm-generic/gpio.h>
224 230
225static inline int irq_to_gpio(unsigned irq)
226{
227 int tmp;
228
229 /* omap1 SOC mpuio */
230 if (cpu_class_is_omap1() && (irq < (IH_MPUIO_BASE + 16)))
231 return (irq - IH_MPUIO_BASE) + OMAP_MAX_GPIO_LINES;
232
233 /* SOC gpio */
234 tmp = irq - IH_GPIO_BASE;
235 if (tmp < OMAP_MAX_GPIO_LINES)
236 return tmp;
237
238 /* we don't supply reverse mappings for non-SOC gpios */
239 return -EIO;
240}
241
242#endif 231#endif
diff --git a/arch/arm/plat-omap/include/plat/hardware.h b/arch/arm/plat-omap/include/plat/hardware.h
index e897978371c..537b05ae1f5 100644
--- a/arch/arm/plat-omap/include/plat/hardware.h
+++ b/arch/arm/plat-omap/include/plat/hardware.h
@@ -43,6 +43,12 @@
43#endif 43#endif
44#include <plat/serial.h> 44#include <plat/serial.h>
45 45
46#ifdef __ASSEMBLER__
47#define IOMEM(x) (x)
48#else
49#define IOMEM(x) ((void __force __iomem *)(x))
50#endif
51
46/* 52/*
47 * --------------------------------------------------------------------------- 53 * ---------------------------------------------------------------------------
48 * Common definitions for all OMAP processors 54 * Common definitions for all OMAP processors
diff --git a/arch/arm/plat-omap/include/plat/keypad.h b/arch/arm/plat-omap/include/plat/keypad.h
index 793ce9d5329..a6b21eddb21 100644
--- a/arch/arm/plat-omap/include/plat/keypad.h
+++ b/arch/arm/plat-omap/include/plat/keypad.h
@@ -12,6 +12,8 @@
12 12
13#ifndef CONFIG_ARCH_OMAP1 13#ifndef CONFIG_ARCH_OMAP1
14#warning Please update the board to use matrix-keypad driver 14#warning Please update the board to use matrix-keypad driver
15#define omap_readw(reg) 0
16#define omap_writew(val, reg) do {} while (0)
15#endif 17#endif
16#include <linux/input/matrix_keypad.h> 18#include <linux/input/matrix_keypad.h>
17 19
diff --git a/arch/arm/plat-omap/include/plat/mcspi.h b/arch/arm/plat-omap/include/plat/mcspi.h
index 3d51b18131c..a357eb26bd2 100644
--- a/arch/arm/plat-omap/include/plat/mcspi.h
+++ b/arch/arm/plat-omap/include/plat/mcspi.h
@@ -18,9 +18,6 @@ struct omap2_mcspi_dev_attr {
18 18
19struct omap2_mcspi_device_config { 19struct omap2_mcspi_device_config {
20 unsigned turbo_mode:1; 20 unsigned turbo_mode:1;
21
22 /* Do we want one channel enabled at the same time? */
23 unsigned single_channel:1;
24}; 21};
25 22
26#endif 23#endif
diff --git a/arch/arm/plat-omap/include/plat/omap_device.h b/arch/arm/plat-omap/include/plat/omap_device.h
index 51423d2727a..4327b2c90c3 100644
--- a/arch/arm/plat-omap/include/plat/omap_device.h
+++ b/arch/arm/plat-omap/include/plat/omap_device.h
@@ -36,7 +36,7 @@
36 36
37#include <plat/omap_hwmod.h> 37#include <plat/omap_hwmod.h>
38 38
39extern struct device omap_device_parent; 39extern struct dev_pm_domain omap_device_pm_domain;
40 40
41/* omap_device._state values */ 41/* omap_device._state values */
42#define OMAP_DEVICE_STATE_UNKNOWN 0 42#define OMAP_DEVICE_STATE_UNKNOWN 0
@@ -100,6 +100,13 @@ struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
100 struct omap_device_pm_latency *pm_lats, 100 struct omap_device_pm_latency *pm_lats,
101 int pm_lats_cnt, int is_early_device); 101 int pm_lats_cnt, int is_early_device);
102 102
103struct omap_device *omap_device_alloc(struct platform_device *pdev,
104 struct omap_hwmod **ohs, int oh_cnt,
105 struct omap_device_pm_latency *pm_lats,
106 int pm_lats_cnt);
107void omap_device_delete(struct omap_device *od);
108int omap_device_register(struct platform_device *pdev);
109
103void __iomem *omap_device_get_rt_va(struct omap_device *od); 110void __iomem *omap_device_get_rt_va(struct omap_device *od);
104struct device *omap_device_get_by_hwmod_name(const char *oh_name); 111struct device *omap_device_get_by_hwmod_name(const char *oh_name);
105 112
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h
index 647010109af..9e8e63d52aa 100644
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -484,7 +484,6 @@ struct omap_hwmod_class {
484 * @main_clk: main clock: OMAP clock name 484 * @main_clk: main clock: OMAP clock name
485 * @_clk: pointer to the main struct clk (filled in at runtime) 485 * @_clk: pointer to the main struct clk (filled in at runtime)
486 * @opt_clks: other device clocks that drivers can request (0..*) 486 * @opt_clks: other device clocks that drivers can request (0..*)
487 * @vdd_name: voltage domain name
488 * @voltdm: pointer to voltage domain (filled in at runtime) 487 * @voltdm: pointer to voltage domain (filled in at runtime)
489 * @masters: ptr to array of OCP ifs that this hwmod can initiate on 488 * @masters: ptr to array of OCP ifs that this hwmod can initiate on
490 * @slaves: ptr to array of OCP ifs that this hwmod can respond on 489 * @slaves: ptr to array of OCP ifs that this hwmod can respond on
@@ -528,7 +527,6 @@ struct omap_hwmod {
528 struct omap_hwmod_opt_clk *opt_clks; 527 struct omap_hwmod_opt_clk *opt_clks;
529 char *clkdm_name; 528 char *clkdm_name;
530 struct clockdomain *clkdm; 529 struct clockdomain *clkdm;
531 char *vdd_name;
532 struct omap_hwmod_ocp_if **masters; /* connect to *_IA */ 530 struct omap_hwmod_ocp_if **masters; /* connect to *_IA */
533 struct omap_hwmod_ocp_if **slaves; /* connect to *_TA */ 531 struct omap_hwmod_ocp_if **slaves; /* connect to *_TA */
534 void *dev_attr; 532 void *dev_attr;
diff --git a/arch/arm/plat-omap/include/plat/remoteproc.h b/arch/arm/plat-omap/include/plat/remoteproc.h
new file mode 100644
index 00000000000..b10eac89e2e
--- /dev/null
+++ b/arch/arm/plat-omap/include/plat/remoteproc.h
@@ -0,0 +1,57 @@
1/*
2 * Remote Processor - omap-specific bits
3 *
4 * Copyright (C) 2011 Texas Instruments, Inc.
5 * Copyright (C) 2011 Google, Inc.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2 as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#ifndef _PLAT_REMOTEPROC_H
18#define _PLAT_REMOTEPROC_H
19
20struct rproc_ops;
21struct platform_device;
22
23/*
24 * struct omap_rproc_pdata - omap remoteproc's platform data
25 * @name: the remoteproc's name
26 * @oh_name: omap hwmod device
27 * @oh_name_opt: optional, secondary omap hwmod device
28 * @firmware: name of firmware file to load
29 * @mbox_name: name of omap mailbox device to use with this rproc
30 * @ops: start/stop rproc handlers
31 * @device_enable: omap-specific handler for enabling a device
32 * @device_shutdown: omap-specific handler for shutting down a device
33 */
34struct omap_rproc_pdata {
35 const char *name;
36 const char *oh_name;
37 const char *oh_name_opt;
38 const char *firmware;
39 const char *mbox_name;
40 const struct rproc_ops *ops;
41 int (*device_enable) (struct platform_device *pdev);
42 int (*device_shutdown) (struct platform_device *pdev);
43};
44
45#if defined(CONFIG_OMAP_REMOTEPROC) || defined(CONFIG_OMAP_REMOTEPROC_MODULE)
46
47void __init omap_rproc_reserve_cma(void);
48
49#else
50
51void __init omap_rproc_reserve_cma(void)
52{
53}
54
55#endif
56
57#endif /* _PLAT_REMOTEPROC_H */
diff --git a/arch/arm/plat-omap/include/plat/serial.h b/arch/arm/plat-omap/include/plat/serial.h
index 198d1e6a4a6..b073e5f2b19 100644
--- a/arch/arm/plat-omap/include/plat/serial.h
+++ b/arch/arm/plat-omap/include/plat/serial.h
@@ -110,7 +110,6 @@ struct omap_board_data;
110struct omap_uart_port_info; 110struct omap_uart_port_info;
111 111
112extern void omap_serial_init(void); 112extern void omap_serial_init(void);
113extern int omap_uart_can_sleep(void);
114extern void omap_serial_board_init(struct omap_uart_port_info *platform_data); 113extern void omap_serial_board_init(struct omap_uart_port_info *platform_data);
115extern void omap_serial_init_port(struct omap_board_data *bdata, 114extern void omap_serial_init_port(struct omap_board_data *bdata,
116 struct omap_uart_port_info *platform_data); 115 struct omap_uart_port_info *platform_data);
diff --git a/arch/arm/plat-omap/include/plat/sram.h b/arch/arm/plat-omap/include/plat/sram.h
index 75aa1b2bef5..227ae265755 100644
--- a/arch/arm/plat-omap/include/plat/sram.h
+++ b/arch/arm/plat-omap/include/plat/sram.h
@@ -101,4 +101,5 @@ static inline void omap_push_sram_idle(void) {}
101#else 101#else
102#define OMAP4_SRAM_PA 0x40300000 102#define OMAP4_SRAM_PA 0x40300000
103#endif 103#endif
104#define AM33XX_SRAM_PA 0x40300000
104#endif 105#endif
diff --git a/arch/arm/plat-omap/include/plat/system.h b/arch/arm/plat-omap/include/plat/system.h
deleted file mode 100644
index 8e5ebd74b12..00000000000
--- a/arch/arm/plat-omap/include/plat/system.h
+++ /dev/null
@@ -1,15 +0,0 @@
1/*
2 * Copied from arch/arm/mach-sa1100/include/mach/system.h
3 * Copyright (c) 1999 Nicolas Pitre <nico@fluxnic.net>
4 */
5#ifndef __ASM_ARCH_SYSTEM_H
6#define __ASM_ARCH_SYSTEM_H
7
8#include <asm/proc-fns.h>
9
10static inline void arch_idle(void)
11{
12 cpu_do_idle();
13}
14
15#endif
diff --git a/arch/arm/plat-omap/include/plat/tc.h b/arch/arm/plat-omap/include/plat/tc.h
index d2fcd789bb9..1b4b2da8620 100644
--- a/arch/arm/plat-omap/include/plat/tc.h
+++ b/arch/arm/plat-omap/include/plat/tc.h
@@ -84,23 +84,6 @@
84#define EMIFS_CCS(n) (EMIFS_CS0_CONFIG + (4 * (n))) 84#define EMIFS_CCS(n) (EMIFS_CS0_CONFIG + (4 * (n)))
85#define EMIFS_ACS(n) (EMIFS_ACS0 + (4 * (n))) 85#define EMIFS_ACS(n) (EMIFS_ACS0 + (4 * (n)))
86 86
87/* Almost all documentation for chip and board memory maps assumes
88 * BM is clear. Most devel boards have a switch to control booting
89 * from NOR flash (using external chipselect 3) rather than mask ROM,
90 * which uses BM to interchange the physical CS0 and CS3 addresses.
91 */
92static inline u32 omap_cs0_phys(void)
93{
94 return (omap_readl(EMIFS_CONFIG) & OMAP_EMIFS_CONFIG_BM)
95 ? OMAP_CS3_PHYS : 0;
96}
97
98static inline u32 omap_cs3_phys(void)
99{
100 return (omap_readl(EMIFS_CONFIG) & OMAP_EMIFS_CONFIG_BM)
101 ? 0 : OMAP_CS3_PHYS;
102}
103
104#endif /* __ASSEMBLER__ */ 87#endif /* __ASSEMBLER__ */
105 88
106#endif /* __ASM_ARCH_TC_H */ 89#endif /* __ASM_ARCH_TC_H */
diff --git a/arch/arm/plat-omap/include/plat/uncompress.h b/arch/arm/plat-omap/include/plat/uncompress.h
index 6ee90495ca4..cc3f11ba7a9 100644
--- a/arch/arm/plat-omap/include/plat/uncompress.h
+++ b/arch/arm/plat-omap/include/plat/uncompress.h
@@ -160,6 +160,7 @@ static inline void __arch_decomp_setup(unsigned long arch_id)
160 DEBUG_LL_OMAP3(3, igep0020); 160 DEBUG_LL_OMAP3(3, igep0020);
161 DEBUG_LL_OMAP3(3, igep0030); 161 DEBUG_LL_OMAP3(3, igep0030);
162 DEBUG_LL_OMAP3(3, nokia_rm680); 162 DEBUG_LL_OMAP3(3, nokia_rm680);
163 DEBUG_LL_OMAP3(3, nokia_rm696);
163 DEBUG_LL_OMAP3(3, nokia_rx51); 164 DEBUG_LL_OMAP3(3, nokia_rx51);
164 DEBUG_LL_OMAP3(3, omap3517evm); 165 DEBUG_LL_OMAP3(3, omap3517evm);
165 DEBUG_LL_OMAP3(3, omap3_beagle); 166 DEBUG_LL_OMAP3(3, omap3_beagle);
diff --git a/arch/arm/plat-omap/include/plat/usb.h b/arch/arm/plat-omap/include/plat/usb.h
index dc864b580da..d0fc9f4dc15 100644
--- a/arch/arm/plat-omap/include/plat/usb.h
+++ b/arch/arm/plat-omap/include/plat/usb.h
@@ -3,6 +3,7 @@
3#ifndef __ASM_ARCH_OMAP_USB_H 3#ifndef __ASM_ARCH_OMAP_USB_H
4#define __ASM_ARCH_OMAP_USB_H 4#define __ASM_ARCH_OMAP_USB_H
5 5
6#include <linux/io.h>
6#include <linux/usb/musb.h> 7#include <linux/usb/musb.h>
7#include <plat/board.h> 8#include <plat/board.h>
8 9
@@ -105,6 +106,46 @@ extern int omap4430_phy_set_clk(struct device *dev, int on);
105extern int omap4430_phy_init(struct device *dev); 106extern int omap4430_phy_init(struct device *dev);
106extern int omap4430_phy_exit(struct device *dev); 107extern int omap4430_phy_exit(struct device *dev);
107extern int omap4430_phy_suspend(struct device *dev, int suspend); 108extern int omap4430_phy_suspend(struct device *dev, int suspend);
109
110/*
111 * NOTE: Please update omap USB drivers to use ioremap + read/write
112 */
113
114#define OMAP2_L4_IO_OFFSET 0xb2000000
115#define IOMEM(x) ((void __force __iomem *)(x))
116#define OMAP2_L4_IO_ADDRESS(pa) IOMEM((pa) + OMAP2_L4_IO_OFFSET)
117
118static inline u8 omap_readb(u32 pa)
119{
120 return __raw_readb(OMAP2_L4_IO_ADDRESS(pa));
121}
122
123static inline u16 omap_readw(u32 pa)
124{
125 return __raw_readw(OMAP2_L4_IO_ADDRESS(pa));
126}
127
128static inline u32 omap_readl(u32 pa)
129{
130 return __raw_readl(OMAP2_L4_IO_ADDRESS(pa));
131}
132
133static inline void omap_writeb(u8 v, u32 pa)
134{
135 __raw_writeb(v, OMAP2_L4_IO_ADDRESS(pa));
136}
137
138
139static inline void omap_writew(u16 v, u32 pa)
140{
141 __raw_writew(v, OMAP2_L4_IO_ADDRESS(pa));
142}
143
144static inline void omap_writel(u32 v, u32 pa)
145{
146 __raw_writel(v, OMAP2_L4_IO_ADDRESS(pa));
147}
148
108#endif 149#endif
109 150
110extern void am35x_musb_reset(void); 151extern void am35x_musb_reset(void);
diff --git a/arch/arm/plat-omap/mailbox.c b/arch/arm/plat-omap/mailbox.c
index ad80112c227..ad32621aa52 100644
--- a/arch/arm/plat-omap/mailbox.c
+++ b/arch/arm/plat-omap/mailbox.c
@@ -307,7 +307,7 @@ static void omap_mbox_fini(struct omap_mbox *mbox)
307 if (!--mbox->use_count) { 307 if (!--mbox->use_count) {
308 free_irq(mbox->irq, mbox); 308 free_irq(mbox->irq, mbox);
309 tasklet_kill(&mbox->txq->tasklet); 309 tasklet_kill(&mbox->txq->tasklet);
310 flush_work_sync(&mbox->rxq->work); 310 flush_work_sync(&mbox->rxq->work);
311 mbox_queue_free(mbox->txq); 311 mbox_queue_free(mbox->txq);
312 mbox_queue_free(mbox->rxq); 312 mbox_queue_free(mbox->rxq);
313 } 313 }
diff --git a/arch/arm/plat-omap/mux.c b/arch/arm/plat-omap/mux.c
index 976fc801029..cff8712122b 100644
--- a/arch/arm/plat-omap/mux.c
+++ b/arch/arm/plat-omap/mux.c
@@ -27,6 +27,10 @@
27#include <linux/kernel.h> 27#include <linux/kernel.h>
28#include <linux/io.h> 28#include <linux/io.h>
29#include <linux/spinlock.h> 29#include <linux/spinlock.h>
30
31#include <asm/system.h>
32
33#include <plat/cpu.h>
30#include <plat/mux.h> 34#include <plat/mux.h>
31 35
32#ifdef CONFIG_OMAP_MUX 36#ifdef CONFIG_OMAP_MUX
diff --git a/arch/arm/plat-omap/omap-pm-noop.c b/arch/arm/plat-omap/omap-pm-noop.c
index 3dc3801aace..5a97b4d98d4 100644
--- a/arch/arm/plat-omap/omap-pm-noop.c
+++ b/arch/arm/plat-omap/omap-pm-noop.c
@@ -319,7 +319,7 @@ int omap_pm_get_dev_context_loss_count(struct device *dev)
319 if (WARN_ON(!dev)) 319 if (WARN_ON(!dev))
320 return -ENODEV; 320 return -ENODEV;
321 321
322 if (dev->parent == &omap_device_parent) { 322 if (dev->pm_domain == &omap_device_pm_domain) {
323 count = omap_device_get_context_loss_count(pdev); 323 count = omap_device_get_context_loss_count(pdev);
324 } else { 324 } else {
325 WARN_ONCE(off_mode_enabled, "omap_pm: using dummy context loss counter; device %s should be converted to omap_device", 325 WARN_ONCE(off_mode_enabled, "omap_pm: using dummy context loss counter; device %s should be converted to omap_device",
diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c
index e8d98693d2d..d50cbc6385b 100644
--- a/arch/arm/plat-omap/omap_device.c
+++ b/arch/arm/plat-omap/omap_device.c
@@ -1,3 +1,4 @@
1
1/* 2/*
2 * omap_device implementation 3 * omap_device implementation
3 * 4 *
@@ -97,14 +98,7 @@
97#define USE_WAKEUP_LAT 0 98#define USE_WAKEUP_LAT 0
98#define IGNORE_WAKEUP_LAT 1 99#define IGNORE_WAKEUP_LAT 1
99 100
100static int omap_device_register(struct platform_device *pdev);
101static int omap_early_device_register(struct platform_device *pdev); 101static int omap_early_device_register(struct platform_device *pdev);
102static struct omap_device *omap_device_alloc(struct platform_device *pdev,
103 struct omap_hwmod **ohs, int oh_cnt,
104 struct omap_device_pm_latency *pm_lats,
105 int pm_lats_cnt);
106static void omap_device_delete(struct omap_device *od);
107
108 102
109static struct omap_device_pm_latency omap_default_latency[] = { 103static struct omap_device_pm_latency omap_default_latency[] = {
110 { 104 {
@@ -320,8 +314,6 @@ static void _add_hwmod_clocks_clkdev(struct omap_device *od,
320} 314}
321 315
322 316
323static struct dev_pm_domain omap_device_pm_domain;
324
325/** 317/**
326 * omap_device_build_from_dt - build an omap_device with multiple hwmods 318 * omap_device_build_from_dt - build an omap_device with multiple hwmods
327 * @pdev_name: name of the platform_device driver to use 319 * @pdev_name: name of the platform_device driver to use
@@ -348,7 +340,7 @@ static int omap_device_build_from_dt(struct platform_device *pdev)
348 340
349 oh_cnt = of_property_count_strings(node, "ti,hwmods"); 341 oh_cnt = of_property_count_strings(node, "ti,hwmods");
350 if (!oh_cnt || IS_ERR_VALUE(oh_cnt)) { 342 if (!oh_cnt || IS_ERR_VALUE(oh_cnt)) {
351 dev_warn(&pdev->dev, "No 'hwmods' to build omap_device\n"); 343 dev_dbg(&pdev->dev, "No 'hwmods' to build omap_device\n");
352 return -ENODEV; 344 return -ENODEV;
353 } 345 }
354 346
@@ -509,7 +501,7 @@ static int omap_device_fill_resources(struct omap_device *od,
509 * 501 *
510 * Returns an struct omap_device pointer or ERR_PTR() on error; 502 * Returns an struct omap_device pointer or ERR_PTR() on error;
511 */ 503 */
512static struct omap_device *omap_device_alloc(struct platform_device *pdev, 504struct omap_device *omap_device_alloc(struct platform_device *pdev,
513 struct omap_hwmod **ohs, int oh_cnt, 505 struct omap_hwmod **ohs, int oh_cnt,
514 struct omap_device_pm_latency *pm_lats, 506 struct omap_device_pm_latency *pm_lats,
515 int pm_lats_cnt) 507 int pm_lats_cnt)
@@ -591,7 +583,7 @@ oda_exit1:
591 return ERR_PTR(ret); 583 return ERR_PTR(ret);
592} 584}
593 585
594static void omap_device_delete(struct omap_device *od) 586void omap_device_delete(struct omap_device *od)
595{ 587{
596 if (!od) 588 if (!od)
597 return; 589 return;
@@ -619,7 +611,7 @@ static void omap_device_delete(struct omap_device *od)
619 * information. Returns ERR_PTR(-EINVAL) if @oh is NULL; otherwise, 611 * information. Returns ERR_PTR(-EINVAL) if @oh is NULL; otherwise,
620 * passes along the return value of omap_device_build_ss(). 612 * passes along the return value of omap_device_build_ss().
621 */ 613 */
622struct platform_device *omap_device_build(const char *pdev_name, int pdev_id, 614struct platform_device __init *omap_device_build(const char *pdev_name, int pdev_id,
623 struct omap_hwmod *oh, void *pdata, 615 struct omap_hwmod *oh, void *pdata,
624 int pdata_len, 616 int pdata_len,
625 struct omap_device_pm_latency *pm_lats, 617 struct omap_device_pm_latency *pm_lats,
@@ -652,7 +644,7 @@ struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
652 * platform_device record. Returns an ERR_PTR() on error, or passes 644 * platform_device record. Returns an ERR_PTR() on error, or passes
653 * along the return value of omap_device_register(). 645 * along the return value of omap_device_register().
654 */ 646 */
655struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id, 647struct platform_device __init *omap_device_build_ss(const char *pdev_name, int pdev_id,
656 struct omap_hwmod **ohs, int oh_cnt, 648 struct omap_hwmod **ohs, int oh_cnt,
657 void *pdata, int pdata_len, 649 void *pdata, int pdata_len,
658 struct omap_device_pm_latency *pm_lats, 650 struct omap_device_pm_latency *pm_lats,
@@ -717,7 +709,7 @@ odbs_exit:
717 * platform_early_add_device() on the underlying platform_device. 709 * platform_early_add_device() on the underlying platform_device.
718 * Returns 0 by default. 710 * Returns 0 by default.
719 */ 711 */
720static int omap_early_device_register(struct platform_device *pdev) 712static int __init omap_early_device_register(struct platform_device *pdev)
721{ 713{
722 struct platform_device *devices[1]; 714 struct platform_device *devices[1];
723 715
@@ -762,14 +754,12 @@ static int _od_suspend_noirq(struct device *dev)
762 struct omap_device *od = to_omap_device(pdev); 754 struct omap_device *od = to_omap_device(pdev);
763 int ret; 755 int ret;
764 756
765 if (od->flags & OMAP_DEVICE_NO_IDLE_ON_SUSPEND)
766 return pm_generic_suspend_noirq(dev);
767
768 ret = pm_generic_suspend_noirq(dev); 757 ret = pm_generic_suspend_noirq(dev);
769 758
770 if (!ret && !pm_runtime_status_suspended(dev)) { 759 if (!ret && !pm_runtime_status_suspended(dev)) {
771 if (pm_generic_runtime_suspend(dev) == 0) { 760 if (pm_generic_runtime_suspend(dev) == 0) {
772 omap_device_idle(pdev); 761 if (!(od->flags & OMAP_DEVICE_NO_IDLE_ON_SUSPEND))
762 omap_device_idle(pdev);
773 od->flags |= OMAP_DEVICE_SUSPENDED; 763 od->flags |= OMAP_DEVICE_SUSPENDED;
774 } 764 }
775 } 765 }
@@ -782,13 +772,11 @@ static int _od_resume_noirq(struct device *dev)
782 struct platform_device *pdev = to_platform_device(dev); 772 struct platform_device *pdev = to_platform_device(dev);
783 struct omap_device *od = to_omap_device(pdev); 773 struct omap_device *od = to_omap_device(pdev);
784 774
785 if (od->flags & OMAP_DEVICE_NO_IDLE_ON_SUSPEND)
786 return pm_generic_resume_noirq(dev);
787
788 if ((od->flags & OMAP_DEVICE_SUSPENDED) && 775 if ((od->flags & OMAP_DEVICE_SUSPENDED) &&
789 !pm_runtime_status_suspended(dev)) { 776 !pm_runtime_status_suspended(dev)) {
790 od->flags &= ~OMAP_DEVICE_SUSPENDED; 777 od->flags &= ~OMAP_DEVICE_SUSPENDED;
791 omap_device_enable(pdev); 778 if (!(od->flags & OMAP_DEVICE_NO_IDLE_ON_SUSPEND))
779 omap_device_enable(pdev);
792 pm_generic_runtime_resume(dev); 780 pm_generic_runtime_resume(dev);
793 } 781 }
794 782
@@ -799,7 +787,7 @@ static int _od_resume_noirq(struct device *dev)
799#define _od_resume_noirq NULL 787#define _od_resume_noirq NULL
800#endif 788#endif
801 789
802static struct dev_pm_domain omap_device_pm_domain = { 790struct dev_pm_domain omap_device_pm_domain = {
803 .ops = { 791 .ops = {
804 SET_RUNTIME_PM_OPS(_od_runtime_suspend, _od_runtime_resume, 792 SET_RUNTIME_PM_OPS(_od_runtime_suspend, _od_runtime_resume,
805 _od_runtime_idle) 793 _od_runtime_idle)
@@ -817,11 +805,10 @@ static struct dev_pm_domain omap_device_pm_domain = {
817 * platform_device_register() on the underlying platform_device. 805 * platform_device_register() on the underlying platform_device.
818 * Returns the return value of platform_device_register(). 806 * Returns the return value of platform_device_register().
819 */ 807 */
820static int omap_device_register(struct platform_device *pdev) 808int omap_device_register(struct platform_device *pdev)
821{ 809{
822 pr_debug("omap_device: %s: registering\n", pdev->name); 810 pr_debug("omap_device: %s: registering\n", pdev->name);
823 811
824 pdev->dev.parent = &omap_device_parent;
825 pdev->dev.pm_domain = &omap_device_pm_domain; 812 pdev->dev.pm_domain = &omap_device_pm_domain;
826 return platform_device_add(pdev); 813 return platform_device_add(pdev);
827} 814}
@@ -1130,11 +1117,6 @@ int omap_device_enable_clocks(struct omap_device *od)
1130 return 0; 1117 return 0;
1131} 1118}
1132 1119
1133struct device omap_device_parent = {
1134 .init_name = "omap",
1135 .parent = &platform_bus,
1136};
1137
1138static struct notifier_block platform_nb = { 1120static struct notifier_block platform_nb = {
1139 .notifier_call = _omap_device_notifier_call, 1121 .notifier_call = _omap_device_notifier_call,
1140}; 1122};
@@ -1142,6 +1124,6 @@ static struct notifier_block platform_nb = {
1142static int __init omap_device_init(void) 1124static int __init omap_device_init(void)
1143{ 1125{
1144 bus_register_notifier(&platform_bus_type, &platform_nb); 1126 bus_register_notifier(&platform_bus_type, &platform_nb);
1145 return device_register(&omap_device_parent); 1127 return 0;
1146} 1128}
1147core_initcall(omap_device_init); 1129core_initcall(omap_device_init);
diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
index 4243bdcc87b..eec98afa0f8 100644
--- a/arch/arm/plat-omap/sram.c
+++ b/arch/arm/plat-omap/sram.c
@@ -31,11 +31,10 @@
31 31
32#include "sram.h" 32#include "sram.h"
33 33
34/* XXX These "sideways" includes are a sign that something is wrong */ 34/* XXX These "sideways" includes will disappear when sram.c becomes a driver */
35#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) 35#include "../mach-omap2/iomap.h"
36# include "../mach-omap2/prm2xxx_3xxx.h" 36#include "../mach-omap2/prm2xxx_3xxx.h"
37# include "../mach-omap2/sdrc.h" 37#include "../mach-omap2/sdrc.h"
38#endif
39 38
40#define OMAP1_SRAM_PA 0x20000000 39#define OMAP1_SRAM_PA 0x20000000
41#define OMAP2_SRAM_PUB_PA (OMAP2_SRAM_PA + 0xf800) 40#define OMAP2_SRAM_PUB_PA (OMAP2_SRAM_PA + 0xf800)
@@ -86,7 +85,7 @@ static int is_sram_locked(void)
86 __raw_writel(0xCFDE, OMAP24XX_VA_READPERM0); /* all i-read */ 85 __raw_writel(0xCFDE, OMAP24XX_VA_READPERM0); /* all i-read */
87 __raw_writel(0xCFDE, OMAP24XX_VA_WRITEPERM0); /* all i-write */ 86 __raw_writel(0xCFDE, OMAP24XX_VA_WRITEPERM0); /* all i-write */
88 } 87 }
89 if (cpu_is_omap34xx()) { 88 if (cpu_is_omap34xx() && !cpu_is_am33xx()) {
90 __raw_writel(0xFFFF, OMAP34XX_VA_REQINFOPERM0); /* all q-vects */ 89 __raw_writel(0xFFFF, OMAP34XX_VA_REQINFOPERM0); /* all q-vects */
91 __raw_writel(0xFFFF, OMAP34XX_VA_READPERM0); /* all i-read */ 90 __raw_writel(0xFFFF, OMAP34XX_VA_READPERM0); /* all i-read */
92 __raw_writel(0xFFFF, OMAP34XX_VA_WRITEPERM0); /* all i-write */ 91 __raw_writel(0xFFFF, OMAP34XX_VA_WRITEPERM0); /* all i-write */
@@ -124,7 +123,10 @@ static void __init omap_detect_sram(void)
124 omap_sram_size = 0x800; /* 2K */ 123 omap_sram_size = 0x800; /* 2K */
125 } 124 }
126 } else { 125 } else {
127 if (cpu_is_omap34xx()) { 126 if (cpu_is_am33xx()) {
127 omap_sram_start = AM33XX_SRAM_PA;
128 omap_sram_size = 0x10000; /* 64K */
129 } else if (cpu_is_omap34xx()) {
128 omap_sram_start = OMAP3_SRAM_PA; 130 omap_sram_start = OMAP3_SRAM_PA;
129 omap_sram_size = 0x10000; /* 64K */ 131 omap_sram_size = 0x10000; /* 64K */
130 } else if (cpu_is_omap44xx()) { 132 } else if (cpu_is_omap44xx()) {
@@ -368,6 +370,11 @@ static inline int omap34xx_sram_init(void)
368 return 0; 370 return 0;
369} 371}
370 372
373static inline int am33xx_sram_init(void)
374{
375 return 0;
376}
377
371int __init omap_sram_init(void) 378int __init omap_sram_init(void)
372{ 379{
373 omap_detect_sram(); 380 omap_detect_sram();
@@ -379,6 +386,8 @@ int __init omap_sram_init(void)
379 omap242x_sram_init(); 386 omap242x_sram_init();
380 else if (cpu_is_omap2430()) 387 else if (cpu_is_omap2430())
381 omap243x_sram_init(); 388 omap243x_sram_init();
389 else if (cpu_is_am33xx())
390 am33xx_sram_init();
382 else if (cpu_is_omap34xx()) 391 else if (cpu_is_omap34xx())
383 omap34xx_sram_init(); 392 omap34xx_sram_init();
384 393
diff --git a/arch/arm/plat-omap/usb.c b/arch/arm/plat-omap/usb.c
index f3570884883..d2bbfd1cb0b 100644
--- a/arch/arm/plat-omap/usb.c
+++ b/arch/arm/plat-omap/usb.c
@@ -29,6 +29,10 @@
29#include <plat/usb.h> 29#include <plat/usb.h>
30#include <plat/board.h> 30#include <plat/board.h>
31 31
32#include <mach/hardware.h>
33
34#include "../mach-omap2/common.h"
35
32#ifdef CONFIG_ARCH_OMAP_OTG 36#ifdef CONFIG_ARCH_OMAP_OTG
33 37
34void __init 38void __init
diff --git a/arch/arm/plat-orion/common.c b/arch/arm/plat-orion/common.c
index 089899a7db7..74daf5ed143 100644
--- a/arch/arm/plat-orion/common.c
+++ b/arch/arm/plat-orion/common.c
@@ -21,6 +21,7 @@
21#include <plat/orion_wdt.h> 21#include <plat/orion_wdt.h>
22#include <plat/mv_xor.h> 22#include <plat/mv_xor.h>
23#include <plat/ehci-orion.h> 23#include <plat/ehci-orion.h>
24#include <mach/bridge-regs.h>
24 25
25/* Fill in the resources structure and link it into the platform 26/* Fill in the resources structure and link it into the platform
26 device structure. There is always a memory region, and nearly 27 device structure. There is always a memory region, and nearly
@@ -568,13 +569,17 @@ void __init orion_spi_1_init(unsigned long mapbase,
568 ****************************************************************************/ 569 ****************************************************************************/
569static struct orion_wdt_platform_data orion_wdt_data; 570static struct orion_wdt_platform_data orion_wdt_data;
570 571
572static struct resource orion_wdt_resource =
573 DEFINE_RES_MEM(TIMER_VIRT_BASE, 0x28);
574
571static struct platform_device orion_wdt_device = { 575static struct platform_device orion_wdt_device = {
572 .name = "orion_wdt", 576 .name = "orion_wdt",
573 .id = -1, 577 .id = -1,
574 .dev = { 578 .dev = {
575 .platform_data = &orion_wdt_data, 579 .platform_data = &orion_wdt_data,
576 }, 580 },
577 .num_resources = 0, 581 .resource = &orion_wdt_resource,
582 .num_resources = 1,
578}; 583};
579 584
580void __init orion_wdt_init(unsigned long tclk) 585void __init orion_wdt_init(unsigned long tclk)
diff --git a/arch/arm/plat-orion/include/plat/audio.h b/arch/arm/plat-orion/include/plat/audio.h
index 885f8abd927..d6a55bd2e57 100644
--- a/arch/arm/plat-orion/include/plat/audio.h
+++ b/arch/arm/plat-orion/include/plat/audio.h
@@ -2,7 +2,6 @@
2#define __PLAT_AUDIO_H 2#define __PLAT_AUDIO_H
3 3
4struct kirkwood_asoc_platform_data { 4struct kirkwood_asoc_platform_data {
5 u32 tclk;
6 int burst; 5 int burst;
7}; 6};
8#endif 7#endif
diff --git a/arch/arm/plat-s3c24xx/Kconfig b/arch/arm/plat-s3c24xx/Kconfig
index d8973ac46bc..21bf6adb919 100644
--- a/arch/arm/plat-s3c24xx/Kconfig
+++ b/arch/arm/plat-s3c24xx/Kconfig
@@ -4,7 +4,7 @@
4 4
5config PLAT_S3C24XX 5config PLAT_S3C24XX
6 bool 6 bool
7 depends on ARCH_S3C2410 7 depends on ARCH_S3C24XX
8 default y 8 default y
9 select NO_IOPORT 9 select NO_IOPORT
10 select ARCH_REQUIRE_GPIOLIB 10 select ARCH_REQUIRE_GPIOLIB
@@ -44,12 +44,6 @@ config S3C2410_CLOCK
44 Clock code for the S3C2410, and similar processors which 44 Clock code for the S3C2410, and similar processors which
45 is currently includes the S3C2410, S3C2440, S3C2442. 45 is currently includes the S3C2410, S3C2440, S3C2442.
46 46
47config S3C2443_CLOCK
48 bool
49 help
50 Clock code for the S3C2443 and similar processors, which includes
51 the S3C2416 and S3C2450.
52
53config S3C24XX_DCLK 47config S3C24XX_DCLK
54 bool 48 bool
55 help 49 help
@@ -76,15 +70,9 @@ config S3C24XX_GPIO_EXTRA128
76 Add an extra 128 gpio numbers to the available GPIO pool. This is 70 Add an extra 128 gpio numbers to the available GPIO pool. This is
77 available for boards that need extra gpios for external devices. 71 available for boards that need extra gpios for external devices.
78 72
79config PM_SIMTEC 73config S3C24XX_DMA
80 bool
81 help
82 Common power management code for systems that are
83 compatible with the Simtec style of power management
84
85config S3C2410_DMA
86 bool "S3C2410 DMA support" 74 bool "S3C2410 DMA support"
87 depends on ARCH_S3C2410 75 depends on ARCH_S3C24XX
88 select S3C_DMA 76 select S3C_DMA
89 help 77 help
90 S3C2410 DMA support. This is needed for drivers like sound which 78 S3C2410 DMA support. This is needed for drivers like sound which
@@ -93,31 +81,11 @@ config S3C2410_DMA
93 81
94config S3C2410_DMA_DEBUG 82config S3C2410_DMA_DEBUG
95 bool "S3C2410 DMA support debug" 83 bool "S3C2410 DMA support debug"
96 depends on ARCH_S3C2410 && S3C2410_DMA 84 depends on ARCH_S3C24XX && S3C2410_DMA
97 help 85 help
98 Enable debugging output for the DMA code. This option sends info 86 Enable debugging output for the DMA code. This option sends info
99 to the kernel log, at priority KERN_DEBUG. 87 to the kernel log, at priority KERN_DEBUG.
100 88
101# SPI default pin configuration code
102
103config S3C24XX_SPI_BUS0_GPE11_GPE12_GPE13
104 bool
105 help
106 SPI GPIO configuration code for BUS0 when connected to
107 GPE11, GPE12 and GPE13.
108
109config S3C24XX_SPI_BUS1_GPG5_GPG6_GPG7
110 bool
111 help
112 SPI GPIO configuration code for BUS 1 when connected to
113 GPG5, GPG6 and GPG7.
114
115config S3C24XX_SPI_BUS1_GPD8_GPD9_GPD10
116 bool
117 help
118 SPI GPIO configuration code for BUS 1 when connected to
119 GPD8, GPD9 and GPD10.
120
121# common code for s3c24xx based machines, such as the SMDKs. 89# common code for s3c24xx based machines, such as the SMDKs.
122 90
123# cpu frequency items common between s3c2410 and s3c2440/s3c2442 91# cpu frequency items common between s3c2410 and s3c2440/s3c2442
@@ -145,21 +113,4 @@ config S3C2412_IOTIMING
145 Intel node to select io timing code that is common to the s3c2412 113 Intel node to select io timing code that is common to the s3c2412
146 and the s3c2443. 114 and the s3c2443.
147 115
148config MACH_SMDK
149 bool
150 help
151 Common machine code for SMDK2410 and SMDK2440
152
153config S3C24XX_SIMTEC_AUDIO
154 bool
155 depends on (ARCH_BAST || MACH_VR1000 || MACH_OSIRIS || MACH_ANUBIS)
156 default y
157 help
158 Add audio devices for common Simtec S3C24XX boards
159
160config S3C2410_SETUP_TS
161 bool
162 help
163 Compile in platform device definition for Samsung TouchScreen.
164
165endif 116endif
diff --git a/arch/arm/plat-s3c24xx/Makefile b/arch/arm/plat-s3c24xx/Makefile
index b2b01125de6..2467b800cc7 100644
--- a/arch/arm/plat-s3c24xx/Makefile
+++ b/arch/arm/plat-s3c24xx/Makefile
@@ -23,28 +23,11 @@ obj-$(CONFIG_CPU_FREQ_S3C24XX_DEBUGFS) += cpu-freq-debugfs.o
23 23
24# Architecture dependent builds 24# Architecture dependent builds
25 25
26obj-$(CONFIG_PM_SIMTEC) += pm-simtec.o
27obj-$(CONFIG_PM) += pm.o 26obj-$(CONFIG_PM) += pm.o
28obj-$(CONFIG_PM) += irq-pm.o 27obj-$(CONFIG_PM) += irq-pm.o
29obj-$(CONFIG_PM) += sleep.o 28obj-$(CONFIG_PM) += sleep.o
30obj-$(CONFIG_S3C2410_CLOCK) += s3c2410-clock.o 29obj-$(CONFIG_S3C2410_CLOCK) += s3c2410-clock.o
31obj-$(CONFIG_S3C2443_CLOCK) += s3c2443-clock.o 30obj-$(CONFIG_S3C24XX_DMA) += dma.o
32obj-$(CONFIG_S3C2410_DMA) += dma.o
33obj-$(CONFIG_S3C2410_IOTIMING) += s3c2410-iotiming.o 31obj-$(CONFIG_S3C2410_IOTIMING) += s3c2410-iotiming.o
34obj-$(CONFIG_S3C2412_IOTIMING) += s3c2412-iotiming.o 32obj-$(CONFIG_S3C2412_IOTIMING) += s3c2412-iotiming.o
35obj-$(CONFIG_S3C2410_CPUFREQ_UTILS) += s3c2410-cpufreq-utils.o 33obj-$(CONFIG_S3C2410_CPUFREQ_UTILS) += s3c2410-cpufreq-utils.o
36
37# device specific setup and/or initialisation
38obj-$(CONFIG_ARCH_S3C2410) += setup-i2c.o
39obj-$(CONFIG_S3C2410_SETUP_TS) += setup-ts.o
40
41# SPI gpio central GPIO functions
42
43obj-$(CONFIG_S3C24XX_SPI_BUS0_GPE11_GPE12_GPE13) += spi-bus0-gpe11_12_13.o
44obj-$(CONFIG_S3C24XX_SPI_BUS1_GPG5_GPG6_GPG7) += spi-bus1-gpg5_6_7.o
45obj-$(CONFIG_S3C24XX_SPI_BUS1_GPD8_GPD9_GPD10) += spi-bus1-gpd8_9_10.o
46
47# machine common support
48
49obj-$(CONFIG_MACH_SMDK) += common-smdk.o
50obj-$(CONFIG_S3C24XX_SIMTEC_AUDIO) += simtec-audio.o
diff --git a/arch/arm/plat-s3c24xx/cpu.c b/arch/arm/plat-s3c24xx/cpu.c
index ded64318fcc..0db73ae646b 100644
--- a/arch/arm/plat-s3c24xx/cpu.c
+++ b/arch/arm/plat-s3c24xx/cpu.c
@@ -32,6 +32,7 @@
32#include <linux/io.h> 32#include <linux/io.h>
33 33
34#include <mach/hardware.h> 34#include <mach/hardware.h>
35#include <mach/regs-clock.h>
35#include <asm/irq.h> 36#include <asm/irq.h>
36#include <asm/cacheflush.h> 37#include <asm/cacheflush.h>
37#include <asm/system_info.h> 38#include <asm/system_info.h>
@@ -191,8 +192,34 @@ static unsigned long s3c24xx_read_idcode_v4(void)
191 return __raw_readl(S3C2410_GSTATUS1); 192 return __raw_readl(S3C2410_GSTATUS1);
192} 193}
193 194
195static void s3c24xx_default_idle(void)
196{
197 unsigned long tmp;
198 int i;
199
200 /* idle the system by using the idle mode which will wait for an
201 * interrupt to happen before restarting the system.
202 */
203
204 /* Warning: going into idle state upsets jtag scanning */
205
206 __raw_writel(__raw_readl(S3C2410_CLKCON) | S3C2410_CLKCON_IDLE,
207 S3C2410_CLKCON);
208
209 /* the samsung port seems to do a loop and then unset idle.. */
210 for (i = 0; i < 50; i++)
211 tmp += __raw_readl(S3C2410_CLKCON); /* ensure loop not optimised out */
212
213 /* this bit is not cleared on re-start... */
214
215 __raw_writel(__raw_readl(S3C2410_CLKCON) & ~S3C2410_CLKCON_IDLE,
216 S3C2410_CLKCON);
217}
218
194void __init s3c24xx_init_io(struct map_desc *mach_desc, int size) 219void __init s3c24xx_init_io(struct map_desc *mach_desc, int size)
195{ 220{
221 arm_pm_idle = s3c24xx_default_idle;
222
196 /* initialise the io descriptors we need for initialisation */ 223 /* initialise the io descriptors we need for initialisation */
197 iotable_init(mach_desc, size); 224 iotable_init(mach_desc, size);
198 iotable_init(s3c_iodesc, ARRAY_SIZE(s3c_iodesc)); 225 iotable_init(s3c_iodesc, ARRAY_SIZE(s3c_iodesc));
diff --git a/arch/arm/plat-s3c24xx/spi-bus0-gpe11_12_13.c b/arch/arm/plat-s3c24xx/spi-bus0-gpe11_12_13.c
deleted file mode 100644
index 704175b0573..00000000000
--- a/arch/arm/plat-s3c24xx/spi-bus0-gpe11_12_13.c
+++ /dev/null
@@ -1,36 +0,0 @@
1/* linux/arch/arm/plat-s3c24xx/spi-bus0-gpe11_12_13.c
2 *
3 * Copyright (c) 2008 Simtec Electronics
4 * http://armlinux.simtec.co.uk/
5 * Ben Dooks <ben@simtec.co.uk>
6 *
7 * S3C24XX SPI - gpio configuration for bus 0 on gpe11,12,13
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/kernel.h>
15#include <linux/gpio.h>
16
17#include <mach/spi.h>
18#include <mach/regs-gpio.h>
19
20void s3c24xx_spi_gpiocfg_bus0_gpe11_12_13(struct s3c2410_spi_info *spi,
21 int enable)
22{
23 if (enable) {
24 s3c_gpio_cfgpin(S3C2410_GPE(13), S3C2410_GPE13_SPICLK0);
25 s3c_gpio_cfgpin(S3C2410_GPE(12), S3C2410_GPE12_SPIMOSI0);
26 s3c_gpio_cfgpin(S3C2410_GPE(11), S3C2410_GPE11_SPIMISO0);
27 s3c2410_gpio_pullup(S3C2410_GPE(11), 0);
28 s3c2410_gpio_pullup(S3C2410_GPE(13), 0);
29 } else {
30 s3c_gpio_cfgpin(S3C2410_GPE(13), S3C2410_GPIO_INPUT);
31 s3c_gpio_cfgpin(S3C2410_GPE(11), S3C2410_GPIO_INPUT);
32 s3c_gpio_setpull(S3C2410_GPE(11), S3C_GPIO_PULL_NONE);
33 s3c_gpio_setpull(S3C2410_GPE(12), S3C_GPIO_PULL_NONE);
34 s3c_gpio_setpull(S3C2410_GPE(13), S3C_GPIO_PULL_NONE);
35 }
36}
diff --git a/arch/arm/plat-s3c24xx/spi-bus1-gpd8_9_10.c b/arch/arm/plat-s3c24xx/spi-bus1-gpd8_9_10.c
deleted file mode 100644
index 72457afd625..00000000000
--- a/arch/arm/plat-s3c24xx/spi-bus1-gpd8_9_10.c
+++ /dev/null
@@ -1,38 +0,0 @@
1/* linux/arch/arm/plat-s3c24xx/spi-bus0-gpd8_9_10.c
2 *
3 * Copyright (c) 2008 Simtec Electronics
4 * http://armlinux.simtec.co.uk/
5 * Ben Dooks <ben@simtec.co.uk>
6 *
7 * S3C24XX SPI - gpio configuration for bus 1 on gpd8,9,10
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/kernel.h>
15#include <linux/gpio.h>
16
17#include <mach/spi.h>
18#include <mach/regs-gpio.h>
19
20void s3c24xx_spi_gpiocfg_bus1_gpd8_9_10(struct s3c2410_spi_info *spi,
21 int enable)
22{
23
24 printk(KERN_INFO "%s(%d)\n", __func__, enable);
25 if (enable) {
26 s3c_gpio_cfgpin(S3C2410_GPD(10), S3C2440_GPD10_SPICLK1);
27 s3c_gpio_cfgpin(S3C2410_GPD(9), S3C2440_GPD9_SPIMOSI1);
28 s3c_gpio_cfgpin(S3C2410_GPD(8), S3C2440_GPD8_SPIMISO1);
29 s3c2410_gpio_pullup(S3C2410_GPD(10), 0);
30 s3c2410_gpio_pullup(S3C2410_GPD(9), 0);
31 } else {
32 s3c_gpio_cfgpin(S3C2410_GPD(8), S3C2410_GPIO_INPUT);
33 s3c_gpio_cfgpin(S3C2410_GPD(9), S3C2410_GPIO_INPUT);
34 s3c_gpio_setpull(S3C2410_GPD(10), S3C_GPIO_PULL_NONE);
35 s3c_gpio_setpull(S3C2410_GPD(9), S3C_GPIO_PULL_NONE);
36 s3c_gpio_setpull(S3C2410_GPD(8), S3C_GPIO_PULL_NONE);
37 }
38}
diff --git a/arch/arm/plat-s3c24xx/spi-bus1-gpg5_6_7.c b/arch/arm/plat-s3c24xx/spi-bus1-gpg5_6_7.c
deleted file mode 100644
index c3972b645d1..00000000000
--- a/arch/arm/plat-s3c24xx/spi-bus1-gpg5_6_7.c
+++ /dev/null
@@ -1,36 +0,0 @@
1/* linux/arch/arm/plat-s3c24xx/spi-bus0-gpg5_6_7.c
2 *
3 * Copyright (c) 2008 Simtec Electronics
4 * http://armlinux.simtec.co.uk/
5 * Ben Dooks <ben@simtec.co.uk>
6 *
7 * S3C24XX SPI - gpio configuration for bus 1 on gpg5,6,7
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/kernel.h>
15#include <linux/gpio.h>
16
17#include <mach/spi.h>
18#include <mach/regs-gpio.h>
19
20void s3c24xx_spi_gpiocfg_bus1_gpg5_6_7(struct s3c2410_spi_info *spi,
21 int enable)
22{
23 if (enable) {
24 s3c_gpio_cfgpin(S3C2410_GPG(7), S3C2410_GPG7_SPICLK1);
25 s3c_gpio_cfgpin(S3C2410_GPG(6), S3C2410_GPG6_SPIMOSI1);
26 s3c_gpio_cfgpin(S3C2410_GPG(5), S3C2410_GPG5_SPIMISO1);
27 s3c2410_gpio_pullup(S3C2410_GPG(5), 0);
28 s3c2410_gpio_pullup(S3C2410_GPG(6), 0);
29 } else {
30 s3c_gpio_cfgpin(S3C2410_GPG(7), S3C2410_GPIO_INPUT);
31 s3c_gpio_cfgpin(S3C2410_GPG(5), S3C2410_GPIO_INPUT);
32 s3c_gpio_setpull(S3C2410_GPG(5), S3C_GPIO_PULL_NONE);
33 s3c_gpio_setpull(S3C2410_GPG(6), S3C_GPIO_PULL_NONE);
34 s3c_gpio_setpull(S3C2410_GPG(7), S3C_GPIO_PULL_NONE);
35 }
36}
diff --git a/arch/arm/plat-s5p/Kconfig b/arch/arm/plat-s5p/Kconfig
index 8167ce66188..96bea320230 100644
--- a/arch/arm/plat-s5p/Kconfig
+++ b/arch/arm/plat-s5p/Kconfig
@@ -9,8 +9,8 @@ config PLAT_S5P
9 bool 9 bool
10 depends on (ARCH_S5P64X0 || ARCH_S5PC100 || ARCH_S5PV210 || ARCH_EXYNOS) 10 depends on (ARCH_S5P64X0 || ARCH_S5PC100 || ARCH_S5PV210 || ARCH_EXYNOS)
11 default y 11 default y
12 select ARM_VIC if !ARCH_EXYNOS4 12 select ARM_VIC if !ARCH_EXYNOS
13 select ARM_GIC if ARCH_EXYNOS4 13 select ARM_GIC if ARCH_EXYNOS
14 select GIC_NON_BANKED if ARCH_EXYNOS4 14 select GIC_NON_BANKED if ARCH_EXYNOS4
15 select NO_IOPORT 15 select NO_IOPORT
16 select ARCH_REQUIRE_GPIOLIB 16 select ARCH_REQUIRE_GPIOLIB
@@ -40,6 +40,10 @@ config S5P_HRT
40 help 40 help
41 Use the High Resolution timer support 41 Use the High Resolution timer support
42 42
43config S5P_DEV_UART
44 def_bool y
45 depends on (ARCH_S5P64X0 || ARCH_S5PC100 || ARCH_S5PV210)
46
43config S5P_PM 47config S5P_PM
44 bool 48 bool
45 help 49 help
@@ -80,6 +84,16 @@ config S5P_DEV_FIMC3
80 help 84 help
81 Compile in platform device definitions for FIMC controller 3 85 Compile in platform device definitions for FIMC controller 3
82 86
87config S5P_DEV_JPEG
88 bool
89 help
90 Compile in platform device definitions for JPEG codec
91
92config S5P_DEV_G2D
93 bool
94 help
95 Compile in platform device definitions for G2D device
96
83config S5P_DEV_FIMD0 97config S5P_DEV_FIMD0
84 bool 98 bool
85 help 99 help
diff --git a/arch/arm/plat-s5p/Makefile b/arch/arm/plat-s5p/Makefile
index 30d8c3016e6..4bd82413665 100644
--- a/arch/arm/plat-s5p/Makefile
+++ b/arch/arm/plat-s5p/Makefile
@@ -12,7 +12,6 @@ obj- :=
12 12
13# Core files 13# Core files
14 14
15obj-y += dev-uart.o
16obj-y += clock.o 15obj-y += clock.o
17obj-y += irq.o 16obj-y += irq.o
18obj-$(CONFIG_S5P_EXT_INT) += irq-eint.o 17obj-$(CONFIG_S5P_EXT_INT) += irq-eint.o
@@ -23,5 +22,7 @@ obj-$(CONFIG_S5P_SLEEP) += sleep.o
23obj-$(CONFIG_S5P_HRT) += s5p-time.o 22obj-$(CONFIG_S5P_HRT) += s5p-time.o
24 23
25# devices 24# devices
25
26obj-$(CONFIG_S5P_DEV_UART) += dev-uart.o
26obj-$(CONFIG_S5P_DEV_MFC) += dev-mfc.o 27obj-$(CONFIG_S5P_DEV_MFC) += dev-mfc.o
27obj-$(CONFIG_S5P_SETUP_MIPIPHY) += setup-mipiphy.o 28obj-$(CONFIG_S5P_SETUP_MIPIPHY) += setup-mipiphy.o
diff --git a/arch/arm/plat-s5p/clock.c b/arch/arm/plat-s5p/clock.c
index 963edea7f7e..f68a9bb1194 100644
--- a/arch/arm/plat-s5p/clock.c
+++ b/arch/arm/plat-s5p/clock.c
@@ -61,6 +61,20 @@ struct clk clk_fout_apll = {
61 .id = -1, 61 .id = -1,
62}; 62};
63 63
64/* BPLL clock output */
65
66struct clk clk_fout_bpll = {
67 .name = "fout_bpll",
68 .id = -1,
69};
70
71/* CPLL clock output */
72
73struct clk clk_fout_cpll = {
74 .name = "fout_cpll",
75 .id = -1,
76};
77
64/* MPLL clock output 78/* MPLL clock output
65 * No need .ctrlbit, this is always on 79 * No need .ctrlbit, this is always on
66*/ 80*/
@@ -101,6 +115,28 @@ struct clksrc_sources clk_src_apll = {
101 .nr_sources = ARRAY_SIZE(clk_src_apll_list), 115 .nr_sources = ARRAY_SIZE(clk_src_apll_list),
102}; 116};
103 117
118/* Possible clock sources for BPLL Mux */
119static struct clk *clk_src_bpll_list[] = {
120 [0] = &clk_fin_bpll,
121 [1] = &clk_fout_bpll,
122};
123
124struct clksrc_sources clk_src_bpll = {
125 .sources = clk_src_bpll_list,
126 .nr_sources = ARRAY_SIZE(clk_src_bpll_list),
127};
128
129/* Possible clock sources for CPLL Mux */
130static struct clk *clk_src_cpll_list[] = {
131 [0] = &clk_fin_cpll,
132 [1] = &clk_fout_cpll,
133};
134
135struct clksrc_sources clk_src_cpll = {
136 .sources = clk_src_cpll_list,
137 .nr_sources = ARRAY_SIZE(clk_src_cpll_list),
138};
139
104/* Possible clock sources for MPLL Mux */ 140/* Possible clock sources for MPLL Mux */
105static struct clk *clk_src_mpll_list[] = { 141static struct clk *clk_src_mpll_list[] = {
106 [0] = &clk_fin_mpll, 142 [0] = &clk_fin_mpll,
diff --git a/arch/arm/plat-s5p/irq-eint.c b/arch/arm/plat-s5p/irq-eint.c
index c496b359c37..139c050918c 100644
--- a/arch/arm/plat-s5p/irq-eint.c
+++ b/arch/arm/plat-s5p/irq-eint.c
@@ -200,7 +200,7 @@ static struct irq_chip s5p_irq_vic_eint = {
200#endif 200#endif
201}; 201};
202 202
203int __init s5p_init_irq_eint(void) 203static int __init s5p_init_irq_eint(void)
204{ 204{
205 int irq; 205 int irq;
206 206
diff --git a/arch/arm/plat-s5p/irq-gpioint.c b/arch/arm/plat-s5p/irq-gpioint.c
index 1fdfaa4599c..82c7311017a 100644
--- a/arch/arm/plat-s5p/irq-gpioint.c
+++ b/arch/arm/plat-s5p/irq-gpioint.c
@@ -41,7 +41,7 @@ struct s5p_gpioint_bank {
41 void (*handler)(unsigned int, struct irq_desc *); 41 void (*handler)(unsigned int, struct irq_desc *);
42}; 42};
43 43
44LIST_HEAD(banks); 44static LIST_HEAD(banks);
45 45
46static int s5p_gpioint_set_type(struct irq_data *d, unsigned int type) 46static int s5p_gpioint_set_type(struct irq_data *d, unsigned int type)
47{ 47{
diff --git a/arch/arm/plat-s5p/irq-pm.c b/arch/arm/plat-s5p/irq-pm.c
index 327acb3a446..d1bfecae6c9 100644
--- a/arch/arm/plat-s5p/irq-pm.c
+++ b/arch/arm/plat-s5p/irq-pm.c
@@ -39,19 +39,32 @@ unsigned long s3c_irqwake_eintallow = 0xffffffffL;
39int s3c_irq_wake(struct irq_data *data, unsigned int state) 39int s3c_irq_wake(struct irq_data *data, unsigned int state)
40{ 40{
41 unsigned long irqbit; 41 unsigned long irqbit;
42 unsigned int irq_rtc_tic, irq_rtc_alarm;
43
44#ifdef CONFIG_ARCH_EXYNOS
45 if (soc_is_exynos5250()) {
46 irq_rtc_tic = EXYNOS5_IRQ_RTC_TIC;
47 irq_rtc_alarm = EXYNOS5_IRQ_RTC_ALARM;
48 } else {
49 irq_rtc_tic = EXYNOS4_IRQ_RTC_TIC;
50 irq_rtc_alarm = EXYNOS4_IRQ_RTC_ALARM;
51 }
52#else
53 irq_rtc_tic = IRQ_RTC_TIC;
54 irq_rtc_alarm = IRQ_RTC_ALARM;
55#endif
56
57 if (data->irq == irq_rtc_tic || data->irq == irq_rtc_alarm) {
58 irqbit = 1 << (data->irq + 1 - irq_rtc_alarm);
42 59
43 switch (data->irq) {
44 case IRQ_RTC_TIC:
45 case IRQ_RTC_ALARM:
46 irqbit = 1 << (data->irq + 1 - IRQ_RTC_ALARM);
47 if (!state) 60 if (!state)
48 s3c_irqwake_intmask |= irqbit; 61 s3c_irqwake_intmask |= irqbit;
49 else 62 else
50 s3c_irqwake_intmask &= ~irqbit; 63 s3c_irqwake_intmask &= ~irqbit;
51 break; 64 } else {
52 default:
53 return -ENOENT; 65 return -ENOENT;
54 } 66 }
67
55 return 0; 68 return 0;
56} 69}
57 70
diff --git a/arch/arm/plat-s5p/sleep.S b/arch/arm/plat-s5p/sleep.S
index 0fd591bfc9f..006bd01eda0 100644
--- a/arch/arm/plat-s5p/sleep.S
+++ b/arch/arm/plat-s5p/sleep.S
@@ -23,9 +23,18 @@
23*/ 23*/
24 24
25#include <linux/linkage.h> 25#include <linux/linkage.h>
26#include <asm/assembler.h> 26#include <asm/asm-offsets.h>
27#include <asm/hardware/cache-l2x0.h>
27 28
28 .text 29/*
30 * The following code is located into the .data section. This is to
31 * allow l2x0_regs_phys to be accessed with a relative load while we
32 * can't rely on any MMU translation. We could have put l2x0_regs_phys
33 * in the .text section as well, but some setups might insist on it to
34 * be truly read-only. (Reference from: arch/arm/kernel/sleep.S)
35 */
36 .data
37 .align
29 38
30 /* 39 /*
31 * sleep magic, to allow the bootloader to check for an valid 40 * sleep magic, to allow the bootloader to check for an valid
@@ -39,11 +48,34 @@
39 * s3c_cpu_resume 48 * s3c_cpu_resume
40 * 49 *
41 * resume code entry for bootloader to call 50 * resume code entry for bootloader to call
42 *
43 * we must put this code here in the data segment as we have no
44 * other way of restoring the stack pointer after sleep, and we
45 * must not write to the code segment (code is read-only)
46 */ 51 */
47 52
48ENTRY(s3c_cpu_resume) 53ENTRY(s3c_cpu_resume)
54#ifdef CONFIG_CACHE_L2X0
55 adr r0, l2x0_regs_phys
56 ldr r0, [r0]
57 ldr r1, [r0, #L2X0_R_PHY_BASE]
58 ldr r2, [r1, #L2X0_CTRL]
59 tst r2, #0x1
60 bne resume_l2on
61 ldr r2, [r0, #L2X0_R_AUX_CTRL]
62 str r2, [r1, #L2X0_AUX_CTRL]
63 ldr r2, [r0, #L2X0_R_TAG_LATENCY]
64 str r2, [r1, #L2X0_TAG_LATENCY_CTRL]
65 ldr r2, [r0, #L2X0_R_DATA_LATENCY]
66 str r2, [r1, #L2X0_DATA_LATENCY_CTRL]
67 ldr r2, [r0, #L2X0_R_PREFETCH_CTRL]
68 str r2, [r1, #L2X0_PREFETCH_CTRL]
69 ldr r2, [r0, #L2X0_R_PWR_CTRL]
70 str r2, [r1, #L2X0_POWER_CTRL]
71 mov r2, #1
72 str r2, [r1, #L2X0_CTRL]
73resume_l2on:
74#endif
49 b cpu_resume 75 b cpu_resume
76ENDPROC(s3c_cpu_resume)
77#ifdef CONFIG_CACHE_L2X0
78 .globl l2x0_regs_phys
79l2x0_regs_phys:
80 .long 0
81#endif
diff --git a/arch/arm/plat-samsung/Kconfig b/arch/arm/plat-samsung/Kconfig
index 6a2abe67c8b..71553f41001 100644
--- a/arch/arm/plat-samsung/Kconfig
+++ b/arch/arm/plat-samsung/Kconfig
@@ -205,7 +205,7 @@ config S3C_DEV_USB_HSOTG
205 205
206config S3C_DEV_WDT 206config S3C_DEV_WDT
207 bool 207 bool
208 default y if ARCH_S3C2410 208 default y if ARCH_S3C24XX
209 help 209 help
210 Complie in platform device definition for Watchdog Timer 210 Complie in platform device definition for Watchdog Timer
211 211
@@ -264,7 +264,7 @@ config SAMSUNG_DEV_KEYPAD
264 264
265config SAMSUNG_DEV_PWM 265config SAMSUNG_DEV_PWM
266 bool 266 bool
267 default y if ARCH_S3C2410 267 default y if ARCH_S3C24XX
268 help 268 help
269 Compile in platform device definition for PWM Timer 269 Compile in platform device definition for PWM Timer
270 270
diff --git a/arch/arm/plat-samsung/clock.c b/arch/arm/plat-samsung/clock.c
index 10f71179071..65c5eca475e 100644
--- a/arch/arm/plat-samsung/clock.c
+++ b/arch/arm/plat-samsung/clock.c
@@ -84,31 +84,35 @@ static int clk_null_enable(struct clk *clk, int enable)
84 84
85int clk_enable(struct clk *clk) 85int clk_enable(struct clk *clk)
86{ 86{
87 unsigned long flags;
88
87 if (IS_ERR(clk) || clk == NULL) 89 if (IS_ERR(clk) || clk == NULL)
88 return -EINVAL; 90 return -EINVAL;
89 91
90 clk_enable(clk->parent); 92 clk_enable(clk->parent);
91 93
92 spin_lock(&clocks_lock); 94 spin_lock_irqsave(&clocks_lock, flags);
93 95
94 if ((clk->usage++) == 0) 96 if ((clk->usage++) == 0)
95 (clk->enable)(clk, 1); 97 (clk->enable)(clk, 1);
96 98
97 spin_unlock(&clocks_lock); 99 spin_unlock_irqrestore(&clocks_lock, flags);
98 return 0; 100 return 0;
99} 101}
100 102
101void clk_disable(struct clk *clk) 103void clk_disable(struct clk *clk)
102{ 104{
105 unsigned long flags;
106
103 if (IS_ERR(clk) || clk == NULL) 107 if (IS_ERR(clk) || clk == NULL)
104 return; 108 return;
105 109
106 spin_lock(&clocks_lock); 110 spin_lock_irqsave(&clocks_lock, flags);
107 111
108 if ((--clk->usage) == 0) 112 if ((--clk->usage) == 0)
109 (clk->enable)(clk, 0); 113 (clk->enable)(clk, 0);
110 114
111 spin_unlock(&clocks_lock); 115 spin_unlock_irqrestore(&clocks_lock, flags);
112 clk_disable(clk->parent); 116 clk_disable(clk->parent);
113} 117}
114 118
diff --git a/arch/arm/plat-samsung/dev-backlight.c b/arch/arm/plat-samsung/dev-backlight.c
index a976c023b28..5f197dcaf10 100644
--- a/arch/arm/plat-samsung/dev-backlight.c
+++ b/arch/arm/plat-samsung/dev-backlight.c
@@ -77,7 +77,7 @@ static struct platform_device samsung_dfl_bl_device __initdata = {
77 * @gpio_info: structure containing GPIO info for PWM timer 77 * @gpio_info: structure containing GPIO info for PWM timer
78 * @bl_data: structure containing Backlight control data 78 * @bl_data: structure containing Backlight control data
79 */ 79 */
80void samsung_bl_set(struct samsung_bl_gpio_info *gpio_info, 80void __init samsung_bl_set(struct samsung_bl_gpio_info *gpio_info,
81 struct platform_pwm_backlight_data *bl_data) 81 struct platform_pwm_backlight_data *bl_data)
82{ 82{
83 int ret = 0; 83 int ret = 0;
@@ -115,6 +115,8 @@ void samsung_bl_set(struct samsung_bl_gpio_info *gpio_info,
115 samsung_bl_data->init = bl_data->init; 115 samsung_bl_data->init = bl_data->init;
116 if (bl_data->notify) 116 if (bl_data->notify)
117 samsung_bl_data->notify = bl_data->notify; 117 samsung_bl_data->notify = bl_data->notify;
118 if (bl_data->notify_after)
119 samsung_bl_data->notify_after = bl_data->notify_after;
118 if (bl_data->exit) 120 if (bl_data->exit)
119 samsung_bl_data->exit = bl_data->exit; 121 samsung_bl_data->exit = bl_data->exit;
120 if (bl_data->check_fb) 122 if (bl_data->check_fb)
diff --git a/arch/arm/plat-samsung/devs.c b/arch/arm/plat-samsung/devs.c
index d21d744e4d9..8b928f9bc1c 100644
--- a/arch/arm/plat-samsung/devs.c
+++ b/arch/arm/plat-samsung/devs.c
@@ -57,6 +57,7 @@
57#include <plat/sdhci.h> 57#include <plat/sdhci.h>
58#include <plat/ts.h> 58#include <plat/ts.h>
59#include <plat/udc.h> 59#include <plat/udc.h>
60#include <plat/udc-hs.h>
60#include <plat/usb-control.h> 61#include <plat/usb-control.h>
61#include <plat/usb-phy.h> 62#include <plat/usb-phy.h>
62#include <plat/regs-iic.h> 63#include <plat/regs-iic.h>
@@ -267,6 +268,52 @@ struct platform_device s5p_device_fimc3 = {
267}; 268};
268#endif /* CONFIG_S5P_DEV_FIMC3 */ 269#endif /* CONFIG_S5P_DEV_FIMC3 */
269 270
271/* G2D */
272
273#ifdef CONFIG_S5P_DEV_G2D
274static struct resource s5p_g2d_resource[] = {
275 [0] = {
276 .start = S5P_PA_G2D,
277 .end = S5P_PA_G2D + SZ_4K - 1,
278 .flags = IORESOURCE_MEM,
279 },
280 [1] = {
281 .start = IRQ_2D,
282 .end = IRQ_2D,
283 .flags = IORESOURCE_IRQ,
284 },
285};
286
287struct platform_device s5p_device_g2d = {
288 .name = "s5p-g2d",
289 .id = 0,
290 .num_resources = ARRAY_SIZE(s5p_g2d_resource),
291 .resource = s5p_g2d_resource,
292 .dev = {
293 .dma_mask = &samsung_device_dma_mask,
294 .coherent_dma_mask = DMA_BIT_MASK(32),
295 },
296};
297#endif /* CONFIG_S5P_DEV_G2D */
298
299#ifdef CONFIG_S5P_DEV_JPEG
300static struct resource s5p_jpeg_resource[] = {
301 [0] = DEFINE_RES_MEM(S5P_PA_JPEG, SZ_4K),
302 [1] = DEFINE_RES_IRQ(IRQ_JPEG),
303};
304
305struct platform_device s5p_device_jpeg = {
306 .name = "s5p-jpeg",
307 .id = 0,
308 .num_resources = ARRAY_SIZE(s5p_jpeg_resource),
309 .resource = s5p_jpeg_resource,
310 .dev = {
311 .dma_mask = &samsung_device_dma_mask,
312 .coherent_dma_mask = DMA_BIT_MASK(32),
313 },
314};
315#endif /* CONFIG_S5P_DEV_JPEG */
316
270/* FIMD0 */ 317/* FIMD0 */
271 318
272#ifdef CONFIG_S5P_DEV_FIMD0 319#ifdef CONFIG_S5P_DEV_FIMD0
@@ -744,17 +791,6 @@ struct platform_device s3c_device_iis = {
744}; 791};
745#endif /* CONFIG_PLAT_S3C24XX */ 792#endif /* CONFIG_PLAT_S3C24XX */
746 793
747#ifdef CONFIG_CPU_S3C2440
748struct platform_device s3c2412_device_iis = {
749 .name = "s3c2412-iis",
750 .id = -1,
751 .dev = {
752 .dma_mask = &samsung_device_dma_mask,
753 .coherent_dma_mask = DMA_BIT_MASK(32),
754 }
755};
756#endif /* CONFIG_CPU_S3C2440 */
757
758/* IDE CFCON */ 794/* IDE CFCON */
759 795
760#ifdef CONFIG_SAMSUNG_DEV_IDE 796#ifdef CONFIG_SAMSUNG_DEV_IDE
@@ -769,7 +805,7 @@ struct platform_device s3c_device_cfcon = {
769 .resource = s3c_cfcon_resource, 805 .resource = s3c_cfcon_resource,
770}; 806};
771 807
772void s3c_ide_set_platdata(struct s3c_ide_platdata *pdata) 808void __init s3c_ide_set_platdata(struct s3c_ide_platdata *pdata)
773{ 809{
774 s3c_set_platdata(pdata, sizeof(struct s3c_ide_platdata), 810 s3c_set_platdata(pdata, sizeof(struct s3c_ide_platdata),
775 &s3c_device_cfcon); 811 &s3c_device_cfcon);
@@ -887,7 +923,7 @@ struct platform_device s5p_device_mfc_r = {
887 923
888#ifdef CONFIG_S5P_DEV_CSIS0 924#ifdef CONFIG_S5P_DEV_CSIS0
889static struct resource s5p_mipi_csis0_resource[] = { 925static struct resource s5p_mipi_csis0_resource[] = {
890 [0] = DEFINE_RES_MEM(S5P_PA_MIPI_CSIS0, SZ_4K), 926 [0] = DEFINE_RES_MEM(S5P_PA_MIPI_CSIS0, SZ_16K),
891 [1] = DEFINE_RES_IRQ(IRQ_MIPI_CSIS0), 927 [1] = DEFINE_RES_IRQ(IRQ_MIPI_CSIS0),
892}; 928};
893 929
@@ -901,7 +937,7 @@ struct platform_device s5p_device_mipi_csis0 = {
901 937
902#ifdef CONFIG_S5P_DEV_CSIS1 938#ifdef CONFIG_S5P_DEV_CSIS1
903static struct resource s5p_mipi_csis1_resource[] = { 939static struct resource s5p_mipi_csis1_resource[] = {
904 [0] = DEFINE_RES_MEM(S5P_PA_MIPI_CSIS1, SZ_4K), 940 [0] = DEFINE_RES_MEM(S5P_PA_MIPI_CSIS1, SZ_16K),
905 [1] = DEFINE_RES_IRQ(IRQ_MIPI_CSIS1), 941 [1] = DEFINE_RES_IRQ(IRQ_MIPI_CSIS1),
906}; 942};
907 943
@@ -1049,7 +1085,7 @@ struct platform_device s3c64xx_device_onenand1 = {
1049 .resource = s3c64xx_onenand1_resources, 1085 .resource = s3c64xx_onenand1_resources,
1050}; 1086};
1051 1087
1052void s3c64xx_onenand1_set_platdata(struct onenand_platform_data *pdata) 1088void __init s3c64xx_onenand1_set_platdata(struct onenand_platform_data *pdata)
1053{ 1089{
1054 s3c_set_platdata(pdata, sizeof(struct onenand_platform_data), 1090 s3c_set_platdata(pdata, sizeof(struct onenand_platform_data),
1055 &s3c64xx_device_onenand1); 1091 &s3c64xx_device_onenand1);
@@ -1078,7 +1114,7 @@ static struct resource s5p_pmu_resource[] = {
1078 DEFINE_RES_IRQ(IRQ_PMU) 1114 DEFINE_RES_IRQ(IRQ_PMU)
1079}; 1115};
1080 1116
1081struct platform_device s5p_device_pmu = { 1117static struct platform_device s5p_device_pmu = {
1082 .name = "arm-pmu", 1118 .name = "arm-pmu",
1083 .id = ARM_PMU_DEVICE_CPU, 1119 .id = ARM_PMU_DEVICE_CPU,
1084 .num_resources = ARRAY_SIZE(s5p_pmu_resource), 1120 .num_resources = ARRAY_SIZE(s5p_pmu_resource),
@@ -1423,6 +1459,19 @@ struct platform_device s3c_device_usb_hsotg = {
1423 .coherent_dma_mask = DMA_BIT_MASK(32), 1459 .coherent_dma_mask = DMA_BIT_MASK(32),
1424 }, 1460 },
1425}; 1461};
1462
1463void __init s3c_hsotg_set_platdata(struct s3c_hsotg_plat *pd)
1464{
1465 struct s3c_hsotg_plat *npd;
1466
1467 npd = s3c_set_platdata(pd, sizeof(struct s3c_hsotg_plat),
1468 &s3c_device_usb_hsotg);
1469
1470 if (!npd->phy_init)
1471 npd->phy_init = s5p_usb_phy_init;
1472 if (!npd->phy_exit)
1473 npd->phy_exit = s5p_usb_phy_exit;
1474}
1426#endif /* CONFIG_S3C_DEV_USB_HSOTG */ 1475#endif /* CONFIG_S3C_DEV_USB_HSOTG */
1427 1476
1428/* USB High Spped 2.0 Device (Gadget) */ 1477/* USB High Spped 2.0 Device (Gadget) */
diff --git a/arch/arm/plat-samsung/dma-ops.c b/arch/arm/plat-samsung/dma-ops.c
index 0747c77a2fd..301d9c319d0 100644
--- a/arch/arm/plat-samsung/dma-ops.c
+++ b/arch/arm/plat-samsung/dma-ops.c
@@ -116,7 +116,7 @@ static inline int samsung_dmadev_flush(unsigned ch)
116 return dmaengine_terminate_all((struct dma_chan *)ch); 116 return dmaengine_terminate_all((struct dma_chan *)ch);
117} 117}
118 118
119struct samsung_dma_ops dmadev_ops = { 119static struct samsung_dma_ops dmadev_ops = {
120 .request = samsung_dmadev_request, 120 .request = samsung_dmadev_request,
121 .release = samsung_dmadev_release, 121 .release = samsung_dmadev_release,
122 .prepare = samsung_dmadev_prepare, 122 .prepare = samsung_dmadev_prepare,
diff --git a/arch/arm/plat-samsung/include/plat/audio-simtec.h b/arch/arm/plat-samsung/include/plat/audio-simtec.h
index 5345364e742..376af5286a3 100644
--- a/arch/arm/plat-samsung/include/plat/audio-simtec.h
+++ b/arch/arm/plat-samsung/include/plat/audio-simtec.h
@@ -32,6 +32,3 @@ struct s3c24xx_audio_simtec_pdata {
32 32
33 void (*startup)(void); 33 void (*startup)(void);
34}; 34};
35
36extern int simtec_audio_add(const char *codec_name, bool has_lr_routing,
37 struct s3c24xx_audio_simtec_pdata *pdata);
diff --git a/arch/arm/plat-samsung/include/plat/clock.h b/arch/arm/plat-samsung/include/plat/clock.h
index 73c66d4d10f..a62753dc15b 100644
--- a/arch/arm/plat-samsung/include/plat/clock.h
+++ b/arch/arm/plat-samsung/include/plat/clock.h
@@ -79,6 +79,10 @@ extern struct clk clk_epll;
79extern struct clk clk_xtal; 79extern struct clk clk_xtal;
80extern struct clk clk_ext; 80extern struct clk clk_ext;
81 81
82/* S3C2443/S3C2416 specific clocks */
83extern struct clksrc_clk clk_epllref;
84extern struct clksrc_clk clk_esysclk;
85
82/* S3C64XX specific clocks */ 86/* S3C64XX specific clocks */
83extern struct clk clk_h2; 87extern struct clk clk_h2;
84extern struct clk clk_27m; 88extern struct clk clk_27m;
@@ -114,7 +118,23 @@ extern void s3c24xx_setup_clocks(unsigned long fclk,
114extern void s3c2410_setup_clocks(void); 118extern void s3c2410_setup_clocks(void);
115extern void s3c2412_setup_clocks(void); 119extern void s3c2412_setup_clocks(void);
116extern void s3c244x_setup_clocks(void); 120extern void s3c244x_setup_clocks(void);
117extern void s3c2443_setup_clocks(void); 121
122/* S3C2410 specific clock functions */
123
124extern int s3c2410_baseclk_add(void);
125
126/* S3C2443/S3C2416 specific clock functions */
127
128typedef unsigned int (*pll_fn)(unsigned int reg, unsigned int base);
129
130extern void s3c2443_common_setup_clocks(pll_fn get_mpll);
131extern void s3c2443_common_init_clocks(int xtal, pll_fn get_mpll,
132 unsigned int *divs, int nr_divs,
133 int divmask);
134
135extern int s3c2443_clkcon_enable_h(struct clk *clk, int enable);
136extern int s3c2443_clkcon_enable_p(struct clk *clk, int enable);
137extern int s3c2443_clkcon_enable_s(struct clk *clk, int enable);
118 138
119/* S3C64XX specific functions and clocks */ 139/* S3C64XX specific functions and clocks */
120 140
diff --git a/arch/arm/plat-samsung/include/plat/cpu.h b/arch/arm/plat-samsung/include/plat/cpu.h
index 73cb3cfd068..787ceaca0be 100644
--- a/arch/arm/plat-samsung/include/plat/cpu.h
+++ b/arch/arm/plat-samsung/include/plat/cpu.h
@@ -42,6 +42,9 @@ extern unsigned long samsung_cpu_id;
42#define EXYNOS4412_CPU_ID 0xE4412200 42#define EXYNOS4412_CPU_ID 0xE4412200
43#define EXYNOS4_CPU_MASK 0xFFFE0000 43#define EXYNOS4_CPU_MASK 0xFFFE0000
44 44
45#define EXYNOS5250_SOC_ID 0x43520000
46#define EXYNOS5_SOC_MASK 0xFFFFF000
47
45#define IS_SAMSUNG_CPU(name, id, mask) \ 48#define IS_SAMSUNG_CPU(name, id, mask) \
46static inline int is_samsung_##name(void) \ 49static inline int is_samsung_##name(void) \
47{ \ 50{ \
@@ -58,6 +61,7 @@ IS_SAMSUNG_CPU(s5pv210, S5PV210_CPU_ID, S5PV210_CPU_MASK)
58IS_SAMSUNG_CPU(exynos4210, EXYNOS4210_CPU_ID, EXYNOS4_CPU_MASK) 61IS_SAMSUNG_CPU(exynos4210, EXYNOS4210_CPU_ID, EXYNOS4_CPU_MASK)
59IS_SAMSUNG_CPU(exynos4212, EXYNOS4212_CPU_ID, EXYNOS4_CPU_MASK) 62IS_SAMSUNG_CPU(exynos4212, EXYNOS4212_CPU_ID, EXYNOS4_CPU_MASK)
60IS_SAMSUNG_CPU(exynos4412, EXYNOS4412_CPU_ID, EXYNOS4_CPU_MASK) 63IS_SAMSUNG_CPU(exynos4412, EXYNOS4412_CPU_ID, EXYNOS4_CPU_MASK)
64IS_SAMSUNG_CPU(exynos5250, EXYNOS5250_SOC_ID, EXYNOS5_SOC_MASK)
61 65
62#if defined(CONFIG_CPU_S3C2410) || defined(CONFIG_CPU_S3C2412) || \ 66#if defined(CONFIG_CPU_S3C2410) || defined(CONFIG_CPU_S3C2412) || \
63 defined(CONFIG_CPU_S3C2416) || defined(CONFIG_CPU_S3C2440) || \ 67 defined(CONFIG_CPU_S3C2416) || defined(CONFIG_CPU_S3C2440) || \
@@ -120,6 +124,12 @@ IS_SAMSUNG_CPU(exynos4412, EXYNOS4412_CPU_ID, EXYNOS4_CPU_MASK)
120#define EXYNOS4210_REV_1_0 (0x10) 124#define EXYNOS4210_REV_1_0 (0x10)
121#define EXYNOS4210_REV_1_1 (0x11) 125#define EXYNOS4210_REV_1_1 (0x11)
122 126
127#if defined(CONFIG_SOC_EXYNOS5250)
128# define soc_is_exynos5250() is_samsung_exynos5250()
129#else
130# define soc_is_exynos5250() 0
131#endif
132
123#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 }
124 134
125#ifndef MHZ 135#ifndef MHZ
diff --git a/arch/arm/plat-samsung/include/plat/devs.h b/arch/arm/plat-samsung/include/plat/devs.h
index 4214ea0ff8f..2155d4af62a 100644
--- a/arch/arm/plat-samsung/include/plat/devs.h
+++ b/arch/arm/plat-samsung/include/plat/devs.h
@@ -26,6 +26,8 @@ struct s3c24xx_uart_resources {
26extern struct s3c24xx_uart_resources s3c2410_uart_resources[]; 26extern struct s3c24xx_uart_resources s3c2410_uart_resources[];
27extern struct s3c24xx_uart_resources s3c64xx_uart_resources[]; 27extern struct s3c24xx_uart_resources s3c64xx_uart_resources[];
28extern struct s3c24xx_uart_resources s5p_uart_resources[]; 28extern struct s3c24xx_uart_resources s5p_uart_resources[];
29extern struct s3c24xx_uart_resources exynos4_uart_resources[];
30extern struct s3c24xx_uart_resources exynos5_uart_resources[];
29 31
30extern struct platform_device *s3c24xx_uart_devs[]; 32extern struct platform_device *s3c24xx_uart_devs[];
31extern struct platform_device *s3c24xx_uart_src[]; 33extern struct platform_device *s3c24xx_uart_src[];
@@ -79,6 +81,8 @@ extern struct platform_device s5p_device_fimc1;
79extern struct platform_device s5p_device_fimc2; 81extern struct platform_device s5p_device_fimc2;
80extern struct platform_device s5p_device_fimc3; 82extern struct platform_device s5p_device_fimc3;
81extern struct platform_device s5p_device_fimc_md; 83extern struct platform_device s5p_device_fimc_md;
84extern struct platform_device s5p_device_jpeg;
85extern struct platform_device s5p_device_g2d;
82extern struct platform_device s5p_device_fimd0; 86extern struct platform_device s5p_device_fimd0;
83extern struct platform_device s5p_device_hdmi; 87extern struct platform_device s5p_device_hdmi;
84extern struct platform_device s5p_device_i2c_hdmiphy; 88extern struct platform_device s5p_device_i2c_hdmiphy;
diff --git a/arch/arm/plat-samsung/include/plat/dma-pl330.h b/arch/arm/plat-samsung/include/plat/dma-pl330.h
index c5eaad529de..0670f37aaae 100644
--- a/arch/arm/plat-samsung/include/plat/dma-pl330.h
+++ b/arch/arm/plat-samsung/include/plat/dma-pl330.h
@@ -82,6 +82,22 @@ enum dma_ch {
82 DMACH_SLIMBUS4_TX, 82 DMACH_SLIMBUS4_TX,
83 DMACH_SLIMBUS5_RX, 83 DMACH_SLIMBUS5_RX,
84 DMACH_SLIMBUS5_TX, 84 DMACH_SLIMBUS5_TX,
85 DMACH_MIPI_HSI0,
86 DMACH_MIPI_HSI1,
87 DMACH_MIPI_HSI2,
88 DMACH_MIPI_HSI3,
89 DMACH_MIPI_HSI4,
90 DMACH_MIPI_HSI5,
91 DMACH_MIPI_HSI6,
92 DMACH_MIPI_HSI7,
93 DMACH_MTOM_0,
94 DMACH_MTOM_1,
95 DMACH_MTOM_2,
96 DMACH_MTOM_3,
97 DMACH_MTOM_4,
98 DMACH_MTOM_5,
99 DMACH_MTOM_6,
100 DMACH_MTOM_7,
85 /* END Marker, also used to denote a reserved channel */ 101 /* END Marker, also used to denote a reserved channel */
86 DMACH_MAX, 102 DMACH_MAX,
87}; 103};
diff --git a/arch/arm/plat-samsung/include/plat/regs-dma.h b/arch/arm/plat-samsung/include/plat/regs-dma.h
index 178bccbe480..a7d622ef16a 100644
--- a/arch/arm/plat-samsung/include/plat/regs-dma.h
+++ b/arch/arm/plat-samsung/include/plat/regs-dma.h
@@ -119,7 +119,7 @@
119#define S3C2412_DMAREQSEL_UART2_1 S3C2412_DMAREQSEL_SRC(24) 119#define S3C2412_DMAREQSEL_UART2_1 S3C2412_DMAREQSEL_SRC(24)
120#endif /* CONFIG_CPU_S3C2412 */ 120#endif /* CONFIG_CPU_S3C2412 */
121 121
122#ifdef CONFIG_CPU_S3C2443 122#if defined(CONFIG_CPU_S3C2416) || defined(CONFIG_CPU_S3C2443)
123 123
124#define S3C2443_DMAREQSEL_SRC(x) ((x) << 1) 124#define S3C2443_DMAREQSEL_SRC(x) ((x) << 1)
125 125
diff --git a/arch/arm/plat-samsung/include/plat/regs-rtc.h b/arch/arm/plat-samsung/include/plat/regs-rtc.h
index 30b7cc14cef..0f8263e93ee 100644
--- a/arch/arm/plat-samsung/include/plat/regs-rtc.h
+++ b/arch/arm/plat-samsung/include/plat/regs-rtc.h
@@ -18,51 +18,54 @@
18#define S3C2410_INTP_ALM (1 << 1) 18#define S3C2410_INTP_ALM (1 << 1)
19#define S3C2410_INTP_TIC (1 << 0) 19#define S3C2410_INTP_TIC (1 << 0)
20 20
21#define S3C2410_RTCCON S3C2410_RTCREG(0x40) 21#define S3C2410_RTCCON S3C2410_RTCREG(0x40)
22#define S3C2410_RTCCON_RTCEN (1<<0) 22#define S3C2410_RTCCON_RTCEN (1 << 0)
23#define S3C2410_RTCCON_CLKSEL (1<<1) 23#define S3C2410_RTCCON_CNTSEL (1 << 2)
24#define S3C2410_RTCCON_CNTSEL (1<<2) 24#define S3C2410_RTCCON_CLKRST (1 << 3)
25#define S3C2410_RTCCON_CLKRST (1<<3) 25#define S3C2443_RTCCON_TICSEL (1 << 4)
26#define S3C64XX_RTCCON_TICEN (1<<8) 26#define S3C64XX_RTCCON_TICEN (1 << 8)
27 27
28#define S3C64XX_RTCCON_TICMSK (0xF<<7) 28#define S3C2410_TICNT S3C2410_RTCREG(0x44)
29#define S3C64XX_RTCCON_TICSHT (7) 29#define S3C2410_TICNT_ENABLE (1 << 7)
30 30
31#define S3C2410_TICNT S3C2410_RTCREG(0x44) 31/* S3C2443: tick count is 15 bit wide
32#define S3C2410_TICNT_ENABLE (1<<7) 32 * TICNT[6:0] contains upper 7 bits
33 * TICNT1[7:0] contains lower 8 bits
34 */
35#define S3C2443_TICNT_PART(x) ((x & 0x7f00) >> 8)
36#define S3C2443_TICNT1 S3C2410_RTCREG(0x4C)
37#define S3C2443_TICNT1_PART(x) (x & 0xff)
33 38
34#define S3C2410_RTCALM S3C2410_RTCREG(0x50) 39/* S3C2416: tick count is 32 bit wide
35#define S3C2410_RTCALM_ALMEN (1<<6) 40 * TICNT[6:0] contains bits [14:8]
36#define S3C2410_RTCALM_YEAREN (1<<5) 41 * TICNT1[7:0] contains lower 8 bits
37#define S3C2410_RTCALM_MONEN (1<<4) 42 * TICNT2[16:0] contains upper 17 bits
38#define S3C2410_RTCALM_DAYEN (1<<3) 43 */
39#define S3C2410_RTCALM_HOUREN (1<<2) 44#define S3C2416_TICNT2 S3C2410_RTCREG(0x48)
40#define S3C2410_RTCALM_MINEN (1<<1) 45#define S3C2416_TICNT2_PART(x) ((x & 0xffff8000) >> 15)
41#define S3C2410_RTCALM_SECEN (1<<0)
42 46
43#define S3C2410_RTCALM_ALL \ 47#define S3C2410_RTCALM S3C2410_RTCREG(0x50)
44 S3C2410_RTCALM_ALMEN | S3C2410_RTCALM_YEAREN | S3C2410_RTCALM_MONEN |\ 48#define S3C2410_RTCALM_ALMEN (1 << 6)
45 S3C2410_RTCALM_DAYEN | S3C2410_RTCALM_HOUREN | S3C2410_RTCALM_MINEN |\ 49#define S3C2410_RTCALM_YEAREN (1 << 5)
46 S3C2410_RTCALM_SECEN 50#define S3C2410_RTCALM_MONEN (1 << 4)
51#define S3C2410_RTCALM_DAYEN (1 << 3)
52#define S3C2410_RTCALM_HOUREN (1 << 2)
53#define S3C2410_RTCALM_MINEN (1 << 1)
54#define S3C2410_RTCALM_SECEN (1 << 0)
47 55
56#define S3C2410_ALMSEC S3C2410_RTCREG(0x54)
57#define S3C2410_ALMMIN S3C2410_RTCREG(0x58)
58#define S3C2410_ALMHOUR S3C2410_RTCREG(0x5c)
48 59
49#define S3C2410_ALMSEC S3C2410_RTCREG(0x54) 60#define S3C2410_ALMDATE S3C2410_RTCREG(0x60)
50#define S3C2410_ALMMIN S3C2410_RTCREG(0x58) 61#define S3C2410_ALMMON S3C2410_RTCREG(0x64)
51#define S3C2410_ALMHOUR S3C2410_RTCREG(0x5c) 62#define S3C2410_ALMYEAR S3C2410_RTCREG(0x68)
52
53#define S3C2410_ALMDATE S3C2410_RTCREG(0x60)
54#define S3C2410_ALMMON S3C2410_RTCREG(0x64)
55#define S3C2410_ALMYEAR S3C2410_RTCREG(0x68)
56
57#define S3C2410_RTCRST S3C2410_RTCREG(0x6c)
58
59#define S3C2410_RTCSEC S3C2410_RTCREG(0x70)
60#define S3C2410_RTCMIN S3C2410_RTCREG(0x74)
61#define S3C2410_RTCHOUR S3C2410_RTCREG(0x78)
62#define S3C2410_RTCDATE S3C2410_RTCREG(0x7c)
63#define S3C2410_RTCDAY S3C2410_RTCREG(0x80)
64#define S3C2410_RTCMON S3C2410_RTCREG(0x84)
65#define S3C2410_RTCYEAR S3C2410_RTCREG(0x88)
66 63
64#define S3C2410_RTCSEC S3C2410_RTCREG(0x70)
65#define S3C2410_RTCMIN S3C2410_RTCREG(0x74)
66#define S3C2410_RTCHOUR S3C2410_RTCREG(0x78)
67#define S3C2410_RTCDATE S3C2410_RTCREG(0x7c)
68#define S3C2410_RTCMON S3C2410_RTCREG(0x84)
69#define S3C2410_RTCYEAR S3C2410_RTCREG(0x88)
67 70
68#endif /* __ASM_ARCH_REGS_RTC_H */ 71#endif /* __ASM_ARCH_REGS_RTC_H */
diff --git a/arch/arm/plat-samsung/include/plat/regs-usb-hsotg-phy.h b/arch/arm/plat-samsung/include/plat/regs-usb-hsotg-phy.h
index a111ad87183..fcf27966206 100644
--- a/arch/arm/plat-samsung/include/plat/regs-usb-hsotg-phy.h
+++ b/arch/arm/plat-samsung/include/plat/regs-usb-hsotg-phy.h
@@ -25,8 +25,9 @@
25#define S3C_HSOTG_PHYREG(x) ((x) + S3C_VA_USB_HSPHY) 25#define S3C_HSOTG_PHYREG(x) ((x) + S3C_VA_USB_HSPHY)
26 26
27#define S3C_PHYPWR S3C_HSOTG_PHYREG(0x00) 27#define S3C_PHYPWR S3C_HSOTG_PHYREG(0x00)
28#define SRC_PHYPWR_OTG_DISABLE (1 << 4) 28#define S3C_PHYPWR_NORMAL_MASK (0x19 << 0)
29#define SRC_PHYPWR_ANALOG_POWERDOWN (1 << 3) 29#define S3C_PHYPWR_OTG_DISABLE (1 << 4)
30#define S3C_PHYPWR_ANALOG_POWERDOWN (1 << 3)
30#define SRC_PHYPWR_FORCE_SUSPEND (1 << 1) 31#define SRC_PHYPWR_FORCE_SUSPEND (1 << 1)
31 32
32#define S3C_PHYCLK S3C_HSOTG_PHYREG(0x04) 33#define S3C_PHYCLK S3C_HSOTG_PHYREG(0x04)
@@ -42,7 +43,7 @@
42 43
43#define S3C_RSTCON S3C_HSOTG_PHYREG(0x08) 44#define S3C_RSTCON S3C_HSOTG_PHYREG(0x08)
44#define S3C_RSTCON_PHYCLK (1 << 2) 45#define S3C_RSTCON_PHYCLK (1 << 2)
45#define S3C_RSTCON_HCLK (1 << 2) 46#define S3C_RSTCON_HCLK (1 << 1)
46#define S3C_RSTCON_PHY (1 << 0) 47#define S3C_RSTCON_PHY (1 << 0)
47 48
48#define S3C_PHYTUNE S3C_HSOTG_PHYREG(0x20) 49#define S3C_PHYTUNE S3C_HSOTG_PHYREG(0x20)
diff --git a/arch/arm/plat-samsung/include/plat/rtc-core.h b/arch/arm/plat-samsung/include/plat/rtc-core.h
new file mode 100644
index 00000000000..21d8594d37c
--- /dev/null
+++ b/arch/arm/plat-samsung/include/plat/rtc-core.h
@@ -0,0 +1,27 @@
1/* linux/arch/arm/plat-samsung/include/plat/rtc-core.h
2 *
3 * Copyright (c) 2011 Heiko Stuebner <heiko@sntech.de>
4 *
5 * Samsung RTC Controller core functions
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10*/
11
12#ifndef __ASM_PLAT_RTC_CORE_H
13#define __ASM_PLAT_RTC_CORE_H __FILE__
14
15/* These functions are only for use with the core support code, such as
16 * the cpu specific initialisation code
17 */
18
19/* re-define device name depending on support. */
20static inline void s3c_rtc_setname(char *name)
21{
22#if defined(CONFIG_SAMSUNG_DEV_RTC) || defined(CONFIG_PLAT_S3C24XX)
23 s3c_device_rtc.name = name;
24#endif
25}
26
27#endif /* __ASM_PLAT_RTC_CORE_H */
diff --git a/arch/arm/plat-samsung/include/plat/s3c2410.h b/arch/arm/plat-samsung/include/plat/s3c2410.h
index 3986497dd3f..55b0e5f51e9 100644
--- a/arch/arm/plat-samsung/include/plat/s3c2410.h
+++ b/arch/arm/plat-samsung/include/plat/s3c2410.h
@@ -29,5 +29,3 @@ extern void s3c2410_init_clocks(int xtal);
29#define s3c2410_init NULL 29#define s3c2410_init NULL
30#define s3c2410a_init NULL 30#define s3c2410a_init NULL
31#endif 31#endif
32
33extern int s3c2410_baseclk_add(void);
diff --git a/arch/arm/plat-samsung/include/plat/s3c2443.h b/arch/arm/plat-samsung/include/plat/s3c2443.h
index dce05b43d51..a5b794ff838 100644
--- a/arch/arm/plat-samsung/include/plat/s3c2443.h
+++ b/arch/arm/plat-samsung/include/plat/s3c2443.h
@@ -32,23 +32,3 @@ extern void s3c2443_restart(char mode, const char *cmd);
32#define s3c2443_init NULL 32#define s3c2443_init NULL
33#define s3c2443_restart NULL 33#define s3c2443_restart NULL
34#endif 34#endif
35
36/* common code used by s3c2443 and others.
37 * note, not to be used outside of arch/arm/mach-s3c* */
38
39struct clk; /* some files don't need clk.h otherwise */
40
41typedef unsigned int (*pll_fn)(unsigned int reg, unsigned int base);
42
43extern void s3c2443_common_setup_clocks(pll_fn get_mpll);
44extern void s3c2443_common_init_clocks(int xtal, pll_fn get_mpll,
45 unsigned int *divs, int nr_divs,
46 int divmask);
47
48extern int s3c2443_clkcon_enable_h(struct clk *clk, int enable);
49extern int s3c2443_clkcon_enable_p(struct clk *clk, int enable);
50extern int s3c2443_clkcon_enable_s(struct clk *clk, int enable);
51
52extern struct clksrc_clk clk_epllref;
53extern struct clksrc_clk clk_esysclk;
54extern struct clksrc_clk clk_msysclk;
diff --git a/arch/arm/plat-samsung/include/plat/s5p-clock.h b/arch/arm/plat-samsung/include/plat/s5p-clock.h
index 984bf9e7bc8..1de4b32f98e 100644
--- a/arch/arm/plat-samsung/include/plat/s5p-clock.h
+++ b/arch/arm/plat-samsung/include/plat/s5p-clock.h
@@ -18,6 +18,8 @@
18#define GET_DIV(clk, field) ((((clk) & field##_MASK) >> field##_SHIFT) + 1) 18#define GET_DIV(clk, field) ((((clk) & field##_MASK) >> field##_SHIFT) + 1)
19 19
20#define clk_fin_apll clk_ext_xtal_mux 20#define clk_fin_apll clk_ext_xtal_mux
21#define clk_fin_bpll clk_ext_xtal_mux
22#define clk_fin_cpll clk_ext_xtal_mux
21#define clk_fin_mpll clk_ext_xtal_mux 23#define clk_fin_mpll clk_ext_xtal_mux
22#define clk_fin_epll clk_ext_xtal_mux 24#define clk_fin_epll clk_ext_xtal_mux
23#define clk_fin_dpll clk_ext_xtal_mux 25#define clk_fin_dpll clk_ext_xtal_mux
@@ -29,6 +31,8 @@ extern struct clk clk_xusbxti;
29extern struct clk clk_48m; 31extern struct clk clk_48m;
30extern struct clk s5p_clk_27m; 32extern struct clk s5p_clk_27m;
31extern struct clk clk_fout_apll; 33extern struct clk clk_fout_apll;
34extern struct clk clk_fout_bpll;
35extern struct clk clk_fout_cpll;
32extern struct clk clk_fout_mpll; 36extern struct clk clk_fout_mpll;
33extern struct clk clk_fout_epll; 37extern struct clk clk_fout_epll;
34extern struct clk clk_fout_dpll; 38extern struct clk clk_fout_dpll;
@@ -37,6 +41,8 @@ extern struct clk clk_arm;
37extern struct clk clk_vpll; 41extern struct clk clk_vpll;
38 42
39extern struct clksrc_sources clk_src_apll; 43extern struct clksrc_sources clk_src_apll;
44extern struct clksrc_sources clk_src_bpll;
45extern struct clksrc_sources clk_src_cpll;
40extern struct clksrc_sources clk_src_mpll; 46extern struct clksrc_sources clk_src_mpll;
41extern struct clksrc_sources clk_src_epll; 47extern struct clksrc_sources clk_src_epll;
42extern struct clksrc_sources clk_src_dpll; 48extern struct clksrc_sources clk_src_dpll;
diff --git a/arch/arm/plat-samsung/include/plat/sdhci.h b/arch/arm/plat-samsung/include/plat/sdhci.h
index f82f888b91a..317e246ffc5 100644
--- a/arch/arm/plat-samsung/include/plat/sdhci.h
+++ b/arch/arm/plat-samsung/include/plat/sdhci.h
@@ -40,6 +40,7 @@ enum clk_types {
40 * struct s3c_sdhci_platdata() - Platform device data for Samsung SDHCI 40 * struct s3c_sdhci_platdata() - Platform device data for Samsung SDHCI
41 * @max_width: The maximum number of data bits supported. 41 * @max_width: The maximum number of data bits supported.
42 * @host_caps: Standard MMC host capabilities bit field. 42 * @host_caps: Standard MMC host capabilities bit field.
43 * @host_caps2: The second standard MMC host capabilities bit field.
43 * @cd_type: Type of Card Detection method (see cd_types enum above) 44 * @cd_type: Type of Card Detection method (see cd_types enum above)
44 * @clk_type: Type of clock divider method (see clk_types enum above) 45 * @clk_type: Type of clock divider method (see clk_types enum above)
45 * @ext_cd_init: Initialize external card detect subsystem. Called on 46 * @ext_cd_init: Initialize external card detect subsystem. Called on
@@ -63,6 +64,7 @@ enum clk_types {
63struct s3c_sdhci_platdata { 64struct s3c_sdhci_platdata {
64 unsigned int max_width; 65 unsigned int max_width;
65 unsigned int host_caps; 66 unsigned int host_caps;
67 unsigned int host_caps2;
66 unsigned int pm_caps; 68 unsigned int pm_caps;
67 enum cd_types cd_type; 69 enum cd_types cd_type;
68 enum clk_types clk_type; 70 enum clk_types clk_type;
diff --git a/arch/arm/plat-samsung/include/plat/udc-hs.h b/arch/arm/plat-samsung/include/plat/udc-hs.h
index a22a4f2eea9..c9e3667cb2b 100644
--- a/arch/arm/plat-samsung/include/plat/udc-hs.h
+++ b/arch/arm/plat-samsung/include/plat/udc-hs.h
@@ -26,4 +26,9 @@ enum s3c_hsotg_dmamode {
26struct s3c_hsotg_plat { 26struct s3c_hsotg_plat {
27 enum s3c_hsotg_dmamode dma; 27 enum s3c_hsotg_dmamode dma;
28 unsigned int is_osc : 1; 28 unsigned int is_osc : 1;
29
30 int (*phy_init)(struct platform_device *pdev, int type);
31 int (*phy_exit)(struct platform_device *pdev, int type);
29}; 32};
33
34extern void s3c_hsotg_set_platdata(struct s3c_hsotg_plat *pd);
diff --git a/arch/arm/plat-samsung/include/plat/uncompress.h b/arch/arm/plat-samsung/include/plat/uncompress.h
index ee48e12a1e7..7e068d182c3 100644
--- a/arch/arm/plat-samsung/include/plat/uncompress.h
+++ b/arch/arm/plat-samsung/include/plat/uncompress.h
@@ -37,7 +37,9 @@ static void arch_detect_cpu(void);
37/* how many bytes we allow into the FIFO at a time in FIFO mode */ 37/* how many bytes we allow into the FIFO at a time in FIFO mode */
38#define FIFO_MAX (14) 38#define FIFO_MAX (14)
39 39
40#ifdef S3C_PA_UART
40#define uart_base S3C_PA_UART + (S3C_UART_OFFSET * CONFIG_S3C_LOWLEVEL_UART_PORT) 41#define uart_base S3C_PA_UART + (S3C_UART_OFFSET * CONFIG_S3C_LOWLEVEL_UART_PORT)
42#endif
41 43
42static __inline__ void 44static __inline__ void
43uart_wr(unsigned int reg, unsigned int val) 45uart_wr(unsigned int reg, unsigned int val)
diff --git a/arch/arm/plat-samsung/irq-vic-timer.c b/arch/arm/plat-samsung/irq-vic-timer.c
index 51583cd3016..f980cf3d2ba 100644
--- a/arch/arm/plat-samsung/irq-vic-timer.c
+++ b/arch/arm/plat-samsung/irq-vic-timer.c
@@ -19,6 +19,7 @@
19#include <linux/io.h> 19#include <linux/io.h>
20 20
21#include <mach/map.h> 21#include <mach/map.h>
22#include <plat/cpu.h>
22#include <plat/irq-vic-timer.h> 23#include <plat/irq-vic-timer.h>
23#include <plat/regs-timer.h> 24#include <plat/regs-timer.h>
24 25
@@ -57,6 +58,21 @@ void __init s3c_init_vic_timer_irq(unsigned int num, unsigned int timer_irq)
57 struct irq_chip_type *ct; 58 struct irq_chip_type *ct;
58 unsigned int i; 59 unsigned int i;
59 60
61#ifdef CONFIG_ARCH_EXYNOS
62 if (soc_is_exynos5250()) {
63 pirq[0] = EXYNOS5_IRQ_TIMER0_VIC;
64 pirq[1] = EXYNOS5_IRQ_TIMER1_VIC;
65 pirq[2] = EXYNOS5_IRQ_TIMER2_VIC;
66 pirq[3] = EXYNOS5_IRQ_TIMER3_VIC;
67 pirq[4] = EXYNOS5_IRQ_TIMER4_VIC;
68 } else {
69 pirq[0] = EXYNOS4_IRQ_TIMER0_VIC;
70 pirq[1] = EXYNOS4_IRQ_TIMER1_VIC;
71 pirq[2] = EXYNOS4_IRQ_TIMER2_VIC;
72 pirq[3] = EXYNOS4_IRQ_TIMER3_VIC;
73 pirq[4] = EXYNOS4_IRQ_TIMER4_VIC;
74 }
75#endif
60 s3c_tgc = irq_alloc_generic_chip("s3c-timer", 1, timer_irq, 76 s3c_tgc = irq_alloc_generic_chip("s3c-timer", 1, timer_irq,
61 S3C64XX_TINT_CSTAT, handle_level_irq); 77 S3C64XX_TINT_CSTAT, handle_level_irq);
62 78
diff --git a/arch/arm/plat-samsung/platformdata.c b/arch/arm/plat-samsung/platformdata.c
index 0f707184eae..fa78aa710ed 100644
--- a/arch/arm/plat-samsung/platformdata.c
+++ b/arch/arm/plat-samsung/platformdata.c
@@ -53,6 +53,8 @@ void s3c_sdhci_set_platdata(struct s3c_sdhci_platdata *pd,
53 set->cfg_gpio = pd->cfg_gpio; 53 set->cfg_gpio = pd->cfg_gpio;
54 if (pd->host_caps) 54 if (pd->host_caps)
55 set->host_caps |= pd->host_caps; 55 set->host_caps |= pd->host_caps;
56 if (pd->host_caps2)
57 set->host_caps2 |= pd->host_caps2;
56 if (pd->pm_caps) 58 if (pd->pm_caps)
57 set->pm_caps |= pd->pm_caps; 59 set->pm_caps |= pd->pm_caps;
58 if (pd->clk_type) 60 if (pd->clk_type)
diff --git a/arch/arm/plat-spear/include/plat/system.h b/arch/arm/plat-spear/include/plat/system.h
deleted file mode 100644
index 86c6f83b44c..00000000000
--- a/arch/arm/plat-spear/include/plat/system.h
+++ /dev/null
@@ -1,26 +0,0 @@
1/*
2 * arch/arm/plat-spear/include/plat/system.h
3 *
4 * SPEAr platform specific architecture functions
5 *
6 * Copyright (C) 2009 ST Microelectronics
7 * Viresh Kumar<viresh.kumar@st.com>
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#ifndef __PLAT_SYSTEM_H
15#define __PLAT_SYSTEM_H
16
17static inline void arch_idle(void)
18{
19 /*
20 * This should do all the clock switching
21 * and wait for interrupt tricks
22 */
23 cpu_do_idle();
24}
25
26#endif /* __PLAT_SYSTEM_H */
diff --git a/arch/arm/plat-versatile/Makefile b/arch/arm/plat-versatile/Makefile
index 69714db47c3..a5cb1945bdc 100644
--- a/arch/arm/plat-versatile/Makefile
+++ b/arch/arm/plat-versatile/Makefile
@@ -1,5 +1,4 @@
1obj-y := clock.o 1obj-y := clock.o
2obj-$(CONFIG_LOCAL_TIMERS) += localtimer.o
3obj-$(CONFIG_PLAT_VERSATILE_CLCD) += clcd.o 2obj-$(CONFIG_PLAT_VERSATILE_CLCD) += clcd.o
4obj-$(CONFIG_PLAT_VERSATILE_FPGA_IRQ) += fpga-irq.o 3obj-$(CONFIG_PLAT_VERSATILE_FPGA_IRQ) += fpga-irq.o
5obj-$(CONFIG_PLAT_VERSATILE_LEDS) += leds.o 4obj-$(CONFIG_PLAT_VERSATILE_LEDS) += leds.o
diff --git a/arch/arm/plat-versatile/localtimer.c b/arch/arm/plat-versatile/localtimer.c
deleted file mode 100644
index 0fb3961999b..00000000000
--- a/arch/arm/plat-versatile/localtimer.c
+++ /dev/null
@@ -1,27 +0,0 @@
1/*
2 * linux/arch/arm/plat-versatile/localtimer.c
3 *
4 * Copyright (C) 2002 ARM Ltd.
5 * All Rights Reserved
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#include <linux/init.h>
12#include <linux/smp.h>
13#include <linux/clockchips.h>
14
15#include <asm/smp_twd.h>
16#include <asm/localtimer.h>
17#include <mach/irqs.h>
18
19/*
20 * Setup the local clock events for a CPU.
21 */
22int __cpuinit local_timer_setup(struct clock_event_device *evt)
23{
24 evt->irq = IRQ_LOCALTIMER;
25 twd_timer_setup(evt);
26 return 0;
27}
diff --git a/arch/avr32/boards/atngw100/setup.c b/arch/avr32/boards/atngw100/setup.c
index 7c756fb189f..afeae8978a8 100644
--- a/arch/avr32/boards/atngw100/setup.c
+++ b/arch/avr32/boards/atngw100/setup.c
@@ -97,6 +97,7 @@ static struct atmel_nand_data atngw100mkii_nand_data __initdata = {
97 .rdy_pin = GPIO_PIN_PB(28), 97 .rdy_pin = GPIO_PIN_PB(28),
98 .enable_pin = GPIO_PIN_PE(23), 98 .enable_pin = GPIO_PIN_PE(23),
99 .bus_width_16 = true, 99 .bus_width_16 = true,
100 .ecc_mode = NAND_ECC_SOFT,
100 .parts = nand_partitions, 101 .parts = nand_partitions,
101 .num_parts = ARRAY_SIZE(nand_partitions), 102 .num_parts = ARRAY_SIZE(nand_partitions),
102}; 103};
diff --git a/arch/avr32/boards/atstk1000/atstk1002.c b/arch/avr32/boards/atstk1000/atstk1002.c
index c56ddac85d6..dc526332148 100644
--- a/arch/avr32/boards/atstk1000/atstk1002.c
+++ b/arch/avr32/boards/atstk1000/atstk1002.c
@@ -95,6 +95,7 @@ static struct atmel_nand_data atstk1006_nand_data __initdata = {
95 .ale = 22, 95 .ale = 22,
96 .rdy_pin = GPIO_PIN_PB(30), 96 .rdy_pin = GPIO_PIN_PB(30),
97 .enable_pin = GPIO_PIN_PB(29), 97 .enable_pin = GPIO_PIN_PB(29),
98 .ecc_mode = NAND_ECC_SOFT,
98 .parts = nand_partitions, 99 .parts = nand_partitions,
99 .num_parts = ARRAY_SIZE(num_partitions), 100 .num_parts = ARRAY_SIZE(num_partitions),
100}; 101};
diff --git a/arch/avr32/include/asm/io.h b/arch/avr32/include/asm/io.h
index 22c97ef9220..cf60d0a9f17 100644
--- a/arch/avr32/include/asm/io.h
+++ b/arch/avr32/include/asm/io.h
@@ -1,6 +1,7 @@
1#ifndef __ASM_AVR32_IO_H 1#ifndef __ASM_AVR32_IO_H
2#define __ASM_AVR32_IO_H 2#define __ASM_AVR32_IO_H
3 3
4#include <linux/bug.h>
4#include <linux/kernel.h> 5#include <linux/kernel.h>
5#include <linux/string.h> 6#include <linux/string.h>
6#include <linux/types.h> 7#include <linux/types.h>
diff --git a/arch/avr32/mach-at32ap/at32ap700x.c b/arch/avr32/mach-at32ap/at32ap700x.c
index 402a7bb7266..889c544688c 100644
--- a/arch/avr32/mach-at32ap/at32ap700x.c
+++ b/arch/avr32/mach-at32ap/at32ap700x.c
@@ -1055,8 +1055,6 @@ struct platform_device *__init at32_add_device_usart(unsigned int id)
1055 return at32_usarts[id]; 1055 return at32_usarts[id];
1056} 1056}
1057 1057
1058struct platform_device *atmel_default_console_device;
1059
1060void __init at32_setup_serial_console(unsigned int usart_id) 1058void __init at32_setup_serial_console(unsigned int usart_id)
1061{ 1059{
1062 atmel_default_console_device = at32_usarts[usart_id]; 1060 atmel_default_console_device = at32_usarts[usart_id];
diff --git a/arch/avr32/mach-at32ap/include/mach/board.h b/arch/avr32/mach-at32ap/include/mach/board.h
index 67b111ce332..71733866cb4 100644
--- a/arch/avr32/mach-at32ap/include/mach/board.h
+++ b/arch/avr32/mach-at32ap/include/mach/board.h
@@ -7,6 +7,7 @@
7#include <linux/types.h> 7#include <linux/types.h>
8#include <linux/serial.h> 8#include <linux/serial.h>
9#include <linux/platform_data/macb.h> 9#include <linux/platform_data/macb.h>
10#include <linux/platform_data/atmel_nand.h>
10 11
11#define GPIO_PIN_NONE (-1) 12#define GPIO_PIN_NONE (-1)
12 13
@@ -116,18 +117,6 @@ struct platform_device *
116at32_add_device_cf(unsigned int id, unsigned int extint, 117at32_add_device_cf(unsigned int id, unsigned int extint,
117 struct cf_platform_data *data); 118 struct cf_platform_data *data);
118 119
119/* NAND / SmartMedia */
120struct atmel_nand_data {
121 int enable_pin; /* chip enable */
122 int det_pin; /* card detect */
123 int rdy_pin; /* ready/busy */
124 u8 rdy_pin_active_low; /* rdy_pin value is inverted */
125 u8 ale; /* address line number connected to ALE */
126 u8 cle; /* address line number connected to CLE */
127 u8 bus_width_16; /* buswidth is 16 bit */
128 struct mtd_partition *parts;
129 unsigned int num_parts;
130};
131struct platform_device * 120struct platform_device *
132at32_add_device_nand(unsigned int id, struct atmel_nand_data *data); 121at32_add_device_nand(unsigned int id, struct atmel_nand_data *data);
133 122
diff --git a/arch/avr32/mach-at32ap/include/mach/cpu.h b/arch/avr32/mach-at32ap/include/mach/cpu.h
index 8181293115e..16a24b14146 100644
--- a/arch/avr32/mach-at32ap/include/mach/cpu.h
+++ b/arch/avr32/mach-at32ap/include/mach/cpu.h
@@ -30,9 +30,6 @@
30#define cpu_is_at91sam9261() (0) 30#define cpu_is_at91sam9261() (0)
31#define cpu_is_at91sam9263() (0) 31#define cpu_is_at91sam9263() (0)
32#define cpu_is_at91sam9rl() (0) 32#define cpu_is_at91sam9rl() (0)
33#define cpu_is_at91cap9() (0)
34#define cpu_is_at91cap9_revB() (0)
35#define cpu_is_at91cap9_revC() (0)
36#define cpu_is_at91sam9g10() (0) 33#define cpu_is_at91sam9g10() (0)
37#define cpu_is_at91sam9g20() (0) 34#define cpu_is_at91sam9g20() (0)
38#define cpu_is_at91sam9g45() (0) 35#define cpu_is_at91sam9g45() (0)
diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig
index abe5a9e8514..c1269a1085e 100644
--- a/arch/blackfin/Kconfig
+++ b/arch/blackfin/Kconfig
@@ -36,6 +36,7 @@ config BLACKFIN
36 select GENERIC_ATOMIC64 36 select GENERIC_ATOMIC64
37 select GENERIC_IRQ_PROBE 37 select GENERIC_IRQ_PROBE
38 select IRQ_PER_CPU if SMP 38 select IRQ_PER_CPU if SMP
39 select HAVE_NMI_WATCHDOG if NMI_WATCHDOG
39 40
40config GENERIC_CSUM 41config GENERIC_CSUM
41 def_bool y 42 def_bool y
diff --git a/arch/blackfin/include/asm/irq.h b/arch/blackfin/include/asm/irq.h
index 12f4060a31b..89de539ed01 100644
--- a/arch/blackfin/include/asm/irq.h
+++ b/arch/blackfin/include/asm/irq.h
@@ -38,8 +38,4 @@
38 38
39#include <asm-generic/irq.h> 39#include <asm-generic/irq.h>
40 40
41#ifdef CONFIG_NMI_WATCHDOG
42# define ARCH_HAS_NMI_WATCHDOG
43#endif
44
45#endif /* _BFIN_IRQ_H_ */ 41#endif /* _BFIN_IRQ_H_ */
diff --git a/arch/c6x/include/asm/pgtable.h b/arch/c6x/include/asm/pgtable.h
index 68c8af4f1f9..38a4312eb2c 100644
--- a/arch/c6x/include/asm/pgtable.h
+++ b/arch/c6x/include/asm/pgtable.h
@@ -73,9 +73,6 @@ extern unsigned long empty_zero_page;
73#define pgtable_cache_init() do { } while (0) 73#define pgtable_cache_init() do { } while (0)
74#define io_remap_pfn_range remap_pfn_range 74#define io_remap_pfn_range remap_pfn_range
75 75
76#define io_remap_page_range(vma, vaddr, paddr, size, prot) \
77 remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
78
79#include <asm-generic/pgtable.h> 76#include <asm-generic/pgtable.h>
80 77
81#endif /* _ASM_C6X_PGTABLE_H */ 78#endif /* _ASM_C6X_PGTABLE_H */
diff --git a/arch/hexagon/kernel/signal.c b/arch/hexagon/kernel/signal.c
index b45be318119..ecbab345760 100644
--- a/arch/hexagon/kernel/signal.c
+++ b/arch/hexagon/kernel/signal.c
@@ -192,12 +192,7 @@ static int handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka,
192 if (rc) 192 if (rc)
193 return rc; 193 return rc;
194 194
195 spin_lock_irq(&current->sighand->siglock); 195 block_sigmask(ka, sig);
196 sigorsets(&current->blocked, &current->blocked, &ka->sa.sa_mask);
197 if (!(ka->sa.sa_flags & SA_NODEFER))
198 sigaddset(&current->blocked, sig);
199 recalc_sigpending();
200 spin_unlock_irq(&current->sighand->siglock);
201 196
202 return 0; 197 return 0;
203} 198}
@@ -305,10 +300,7 @@ asmlinkage int sys_rt_sigreturn(void)
305 goto badframe; 300 goto badframe;
306 301
307 sigdelsetmask(&blocked, ~_BLOCKABLE); 302 sigdelsetmask(&blocked, ~_BLOCKABLE);
308 spin_lock_irq(&current->sighand->siglock); 303 set_current_blocked(&blocked);
309 current->blocked = blocked;
310 recalc_sigpending();
311 spin_unlock_irq(&current->sighand->siglock);
312 304
313 if (restore_sigcontext(regs, &frame->uc.uc_mcontext)) 305 if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
314 goto badframe; 306 goto badframe;
diff --git a/arch/hexagon/kernel/vdso.c b/arch/hexagon/kernel/vdso.c
index 16277c33308..f212a453b52 100644
--- a/arch/hexagon/kernel/vdso.c
+++ b/arch/hexagon/kernel/vdso.c
@@ -78,8 +78,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
78 /* MAYWRITE to allow gdb to COW and set breakpoints. */ 78 /* MAYWRITE to allow gdb to COW and set breakpoints. */
79 ret = install_special_mapping(mm, vdso_base, PAGE_SIZE, 79 ret = install_special_mapping(mm, vdso_base, PAGE_SIZE,
80 VM_READ|VM_EXEC| 80 VM_READ|VM_EXEC|
81 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC| 81 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
82 VM_ALWAYSDUMP,
83 &vdso_page); 82 &vdso_page);
84 83
85 if (ret) 84 if (ret)
diff --git a/arch/ia64/include/asm/kvm.h b/arch/ia64/include/asm/kvm.h
index bc90c75adf6..b9f82c84f09 100644
--- a/arch/ia64/include/asm/kvm.h
+++ b/arch/ia64/include/asm/kvm.h
@@ -261,4 +261,8 @@ struct kvm_debug_exit_arch {
261struct kvm_guest_debug_arch { 261struct kvm_guest_debug_arch {
262}; 262};
263 263
264/* definition of registers in kvm_run */
265struct kvm_sync_regs {
266};
267
264#endif 268#endif
diff --git a/arch/ia64/include/asm/kvm_host.h b/arch/ia64/include/asm/kvm_host.h
index 2689ee54a1c..e35b3a84a40 100644
--- a/arch/ia64/include/asm/kvm_host.h
+++ b/arch/ia64/include/asm/kvm_host.h
@@ -459,6 +459,9 @@ struct kvm_sal_data {
459 unsigned long boot_gp; 459 unsigned long boot_gp;
460}; 460};
461 461
462struct kvm_arch_memory_slot {
463};
464
462struct kvm_arch { 465struct kvm_arch {
463 spinlock_t dirty_log_lock; 466 spinlock_t dirty_log_lock;
464 467
diff --git a/arch/ia64/include/asm/pci.h b/arch/ia64/include/asm/pci.h
index c5e6da95522..5e04b591e42 100644
--- a/arch/ia64/include/asm/pci.h
+++ b/arch/ia64/include/asm/pci.h
@@ -116,12 +116,6 @@ static inline int pci_proc_domain(struct pci_bus *bus)
116 return (pci_domain_nr(bus) != 0); 116 return (pci_domain_nr(bus) != 0);
117} 117}
118 118
119extern void pcibios_resource_to_bus(struct pci_dev *dev,
120 struct pci_bus_region *region, struct resource *res);
121
122extern void pcibios_bus_to_resource(struct pci_dev *dev,
123 struct resource *res, struct pci_bus_region *region);
124
125static inline struct resource * 119static inline struct resource *
126pcibios_select_root(struct pci_dev *pdev, struct resource *res) 120pcibios_select_root(struct pci_dev *pdev, struct resource *res)
127{ 121{
diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c
index 93c648887f8..d1cc81e63ba 100644
--- a/arch/ia64/kernel/acpi.c
+++ b/arch/ia64/kernel/acpi.c
@@ -348,11 +348,11 @@ acpi_parse_int_src_ovr(struct acpi_subtable_header * header,
348 348
349 iosapic_override_isa_irq(p->source_irq, p->global_irq, 349 iosapic_override_isa_irq(p->source_irq, p->global_irq,
350 ((p->inti_flags & ACPI_MADT_POLARITY_MASK) == 350 ((p->inti_flags & ACPI_MADT_POLARITY_MASK) ==
351 ACPI_MADT_POLARITY_ACTIVE_HIGH) ? 351 ACPI_MADT_POLARITY_ACTIVE_LOW) ?
352 IOSAPIC_POL_HIGH : IOSAPIC_POL_LOW, 352 IOSAPIC_POL_LOW : IOSAPIC_POL_HIGH,
353 ((p->inti_flags & ACPI_MADT_TRIGGER_MASK) == 353 ((p->inti_flags & ACPI_MADT_TRIGGER_MASK) ==
354 ACPI_MADT_TRIGGER_EDGE) ? 354 ACPI_MADT_TRIGGER_LEVEL) ?
355 IOSAPIC_EDGE : IOSAPIC_LEVEL); 355 IOSAPIC_LEVEL : IOSAPIC_EDGE);
356 return 0; 356 return 0;
357} 357}
358 358
diff --git a/arch/ia64/kernel/machine_kexec.c b/arch/ia64/kernel/machine_kexec.c
index 4eed3581499..070e8effa17 100644
--- a/arch/ia64/kernel/machine_kexec.c
+++ b/arch/ia64/kernel/machine_kexec.c
@@ -157,7 +157,7 @@ void arch_crash_save_vmcoreinfo(void)
157#endif 157#endif
158#ifdef CONFIG_PGTABLE_3 158#ifdef CONFIG_PGTABLE_3
159 VMCOREINFO_CONFIG(PGTABLE_3); 159 VMCOREINFO_CONFIG(PGTABLE_3);
160#elif CONFIG_PGTABLE_4 160#elif defined(CONFIG_PGTABLE_4)
161 VMCOREINFO_CONFIG(PGTABLE_4); 161 VMCOREINFO_CONFIG(PGTABLE_4);
162#endif 162#endif
163} 163}
diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
index 9198a799140..a39fe098a73 100644
--- a/arch/ia64/kernel/mca.c
+++ b/arch/ia64/kernel/mca.c
@@ -1446,6 +1446,8 @@ out:
1446 /* Get the CMC error record and log it */ 1446 /* Get the CMC error record and log it */
1447 ia64_mca_log_sal_error_record(SAL_INFO_TYPE_CMC); 1447 ia64_mca_log_sal_error_record(SAL_INFO_TYPE_CMC);
1448 1448
1449 local_irq_disable();
1450
1449 return IRQ_HANDLED; 1451 return IRQ_HANDLED;
1450} 1452}
1451 1453
diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
index 40505200249..f5104b7c52c 100644
--- a/arch/ia64/kvm/kvm-ia64.c
+++ b/arch/ia64/kvm/kvm-ia64.c
@@ -809,10 +809,13 @@ static void kvm_build_io_pmt(struct kvm *kvm)
809#define GUEST_PHYSICAL_RR4 0x2739 809#define GUEST_PHYSICAL_RR4 0x2739
810#define VMM_INIT_RR 0x1660 810#define VMM_INIT_RR 0x1660
811 811
812int kvm_arch_init_vm(struct kvm *kvm) 812int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
813{ 813{
814 BUG_ON(!kvm); 814 BUG_ON(!kvm);
815 815
816 if (type)
817 return -EINVAL;
818
816 kvm->arch.is_sn2 = ia64_platform_is("sn2"); 819 kvm->arch.is_sn2 = ia64_platform_is("sn2");
817 820
818 kvm->arch.metaphysical_rr0 = GUEST_PHYSICAL_RR0; 821 kvm->arch.metaphysical_rr0 = GUEST_PHYSICAL_RR0;
@@ -1169,6 +1172,11 @@ out:
1169 1172
1170#define PALE_RESET_ENTRY 0x80000000ffffffb0UL 1173#define PALE_RESET_ENTRY 0x80000000ffffffb0UL
1171 1174
1175bool kvm_vcpu_compatible(struct kvm_vcpu *vcpu)
1176{
1177 return irqchip_in_kernel(vcpu->kcm) == (vcpu->arch.apic != NULL);
1178}
1179
1172int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu) 1180int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
1173{ 1181{
1174 struct kvm_vcpu *v; 1182 struct kvm_vcpu *v;
@@ -1563,6 +1571,21 @@ out:
1563 return r; 1571 return r;
1564} 1572}
1565 1573
1574int kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf)
1575{
1576 return VM_FAULT_SIGBUS;
1577}
1578
1579void kvm_arch_free_memslot(struct kvm_memory_slot *free,
1580 struct kvm_memory_slot *dont)
1581{
1582}
1583
1584int kvm_arch_create_memslot(struct kvm_memory_slot *slot, unsigned long npages)
1585{
1586 return 0;
1587}
1588
1566int kvm_arch_prepare_memory_region(struct kvm *kvm, 1589int kvm_arch_prepare_memory_region(struct kvm *kvm,
1567 struct kvm_memory_slot *memslot, 1590 struct kvm_memory_slot *memslot,
1568 struct kvm_memory_slot old, 1591 struct kvm_memory_slot old,
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index 94627926552..524df4295c9 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -319,7 +319,8 @@ static __devinit acpi_status add_window(struct acpi_resource *res, void *data)
319 * Ignore these tiny memory ranges */ 319 * Ignore these tiny memory ranges */
320 if (!((window->resource.flags & IORESOURCE_MEM) && 320 if (!((window->resource.flags & IORESOURCE_MEM) &&
321 (window->resource.end - window->resource.start < 16))) 321 (window->resource.end - window->resource.start < 16)))
322 pci_add_resource(&info->resources, &window->resource); 322 pci_add_resource_offset(&info->resources, &window->resource,
323 window->offset);
323 324
324 return AE_OK; 325 return AE_OK;
325} 326}
@@ -394,54 +395,6 @@ out1:
394 return NULL; 395 return NULL;
395} 396}
396 397
397void pcibios_resource_to_bus(struct pci_dev *dev,
398 struct pci_bus_region *region, struct resource *res)
399{
400 struct pci_controller *controller = PCI_CONTROLLER(dev);
401 unsigned long offset = 0;
402 int i;
403
404 for (i = 0; i < controller->windows; i++) {
405 struct pci_window *window = &controller->window[i];
406 if (!(window->resource.flags & res->flags))
407 continue;
408 if (window->resource.start > res->start)
409 continue;
410 if (window->resource.end < res->end)
411 continue;
412 offset = window->offset;
413 break;
414 }
415
416 region->start = res->start - offset;
417 region->end = res->end - offset;
418}
419EXPORT_SYMBOL(pcibios_resource_to_bus);
420
421void pcibios_bus_to_resource(struct pci_dev *dev,
422 struct resource *res, struct pci_bus_region *region)
423{
424 struct pci_controller *controller = PCI_CONTROLLER(dev);
425 unsigned long offset = 0;
426 int i;
427
428 for (i = 0; i < controller->windows; i++) {
429 struct pci_window *window = &controller->window[i];
430 if (!(window->resource.flags & res->flags))
431 continue;
432 if (window->resource.start - window->offset > region->start)
433 continue;
434 if (window->resource.end - window->offset < region->end)
435 continue;
436 offset = window->offset;
437 break;
438 }
439
440 res->start = region->start + offset;
441 res->end = region->end + offset;
442}
443EXPORT_SYMBOL(pcibios_bus_to_resource);
444
445static int __devinit is_valid_resource(struct pci_dev *dev, int idx) 398static int __devinit is_valid_resource(struct pci_dev *dev, int idx)
446{ 399{
447 unsigned int i, type_mask = IORESOURCE_IO | IORESOURCE_MEM; 400 unsigned int i, type_mask = IORESOURCE_IO | IORESOURCE_MEM;
@@ -463,15 +416,11 @@ static int __devinit is_valid_resource(struct pci_dev *dev, int idx)
463static void __devinit 416static void __devinit
464pcibios_fixup_resources(struct pci_dev *dev, int start, int limit) 417pcibios_fixup_resources(struct pci_dev *dev, int start, int limit)
465{ 418{
466 struct pci_bus_region region;
467 int i; 419 int i;
468 420
469 for (i = start; i < limit; i++) { 421 for (i = start; i < limit; i++) {
470 if (!dev->resource[i].flags) 422 if (!dev->resource[i].flags)
471 continue; 423 continue;
472 region.start = dev->resource[i].start;
473 region.end = dev->resource[i].end;
474 pcibios_bus_to_resource(dev, &dev->resource[i], &region);
475 if ((is_valid_resource(dev, i))) 424 if ((is_valid_resource(dev, i)))
476 pci_claim_resource(dev, i); 425 pci_claim_resource(dev, i);
477 } 426 }
diff --git a/arch/ia64/sn/kernel/huberror.c b/arch/ia64/sn/kernel/huberror.c
index 08b0d9bb62e..f925dec2da9 100644
--- a/arch/ia64/sn/kernel/huberror.c
+++ b/arch/ia64/sn/kernel/huberror.c
@@ -192,6 +192,7 @@ void hub_error_init(struct hubdev_info *hubdev_info)
192 hubdev_info); 192 hubdev_info);
193 return; 193 return;
194 } 194 }
195 irq_set_handler(SGI_II_ERROR, handle_level_irq);
195 sn_set_err_irq_affinity(SGI_II_ERROR); 196 sn_set_err_irq_affinity(SGI_II_ERROR);
196} 197}
197 198
@@ -213,6 +214,7 @@ void ice_error_init(struct hubdev_info *hubdev_info)
213 hubdev_info); 214 hubdev_info);
214 return; 215 return;
215 } 216 }
217 irq_set_handler(SGI_TIO_ERROR, handle_level_irq);
216 sn_set_err_irq_affinity(SGI_TIO_ERROR); 218 sn_set_err_irq_affinity(SGI_TIO_ERROR);
217} 219}
218 220
diff --git a/arch/ia64/sn/kernel/io_common.c b/arch/ia64/sn/kernel/io_common.c
index 4433dd019d3..fbb5f2f87ee 100644
--- a/arch/ia64/sn/kernel/io_common.c
+++ b/arch/ia64/sn/kernel/io_common.c
@@ -7,6 +7,7 @@
7 */ 7 */
8 8
9#include <linux/bootmem.h> 9#include <linux/bootmem.h>
10#include <linux/export.h>
10#include <linux/slab.h> 11#include <linux/slab.h>
11#include <asm/sn/types.h> 12#include <asm/sn/types.h>
12#include <asm/sn/addrs.h> 13#include <asm/sn/addrs.h>
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
index 0a36f082eaf..238e2c511d9 100644
--- a/arch/ia64/sn/kernel/io_init.c
+++ b/arch/ia64/sn/kernel/io_init.c
@@ -297,7 +297,8 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
297 s64 status = 0; 297 s64 status = 0;
298 struct pci_controller *controller; 298 struct pci_controller *controller;
299 struct pcibus_bussoft *prom_bussoft_ptr; 299 struct pcibus_bussoft *prom_bussoft_ptr;
300 300 LIST_HEAD(resources);
301 int i;
301 302
302 status = sal_get_pcibus_info((u64) segment, (u64) busnum, 303 status = sal_get_pcibus_info((u64) segment, (u64) busnum,
303 (u64) ia64_tpa(&prom_bussoft_ptr)); 304 (u64) ia64_tpa(&prom_bussoft_ptr));
@@ -315,7 +316,15 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
315 */ 316 */
316 controller->platform_data = prom_bussoft_ptr; 317 controller->platform_data = prom_bussoft_ptr;
317 318
318 bus = pci_scan_bus(busnum, &pci_root_ops, controller); 319 sn_legacy_pci_window_fixup(controller,
320 prom_bussoft_ptr->bs_legacy_io,
321 prom_bussoft_ptr->bs_legacy_mem);
322 for (i = 0; i < controller->windows; i++)
323 pci_add_resource_offset(&resources,
324 &controller->window[i].resource,
325 controller->window[i].offset);
326 bus = pci_scan_root_bus(NULL, busnum, &pci_root_ops, controller,
327 &resources);
319 if (bus == NULL) 328 if (bus == NULL)
320 goto error_return; /* error, or bus already scanned */ 329 goto error_return; /* error, or bus already scanned */
321 330
@@ -348,9 +357,6 @@ sn_bus_fixup(struct pci_bus *bus)
348 return; 357 return;
349 } 358 }
350 sn_common_bus_fixup(bus, prom_bussoft_ptr); 359 sn_common_bus_fixup(bus, prom_bussoft_ptr);
351 sn_legacy_pci_window_fixup(PCI_CONTROLLER(bus),
352 prom_bussoft_ptr->bs_legacy_io,
353 prom_bussoft_ptr->bs_legacy_mem);
354 } 360 }
355 list_for_each_entry(pci_dev, &bus->devices, bus_list) { 361 list_for_each_entry(pci_dev, &bus->devices, bus_list) {
356 sn_io_slot_fixup(pci_dev); 362 sn_io_slot_fixup(pci_dev);
diff --git a/arch/ia64/sn/kernel/irq.c b/arch/ia64/sn/kernel/irq.c
index dfac09ab027..62cf4dde6a0 100644
--- a/arch/ia64/sn/kernel/irq.c
+++ b/arch/ia64/sn/kernel/irq.c
@@ -352,6 +352,8 @@ void sn_irq_fixup(struct pci_dev *pci_dev, struct sn_irq_info *sn_irq_info)
352 spin_lock(&sn_irq_info_lock); 352 spin_lock(&sn_irq_info_lock);
353 list_add_rcu(&sn_irq_info->list, sn_irq_lh[sn_irq_info->irq_irq]); 353 list_add_rcu(&sn_irq_info->list, sn_irq_lh[sn_irq_info->irq_irq]);
354 reserve_irq_vector(sn_irq_info->irq_irq); 354 reserve_irq_vector(sn_irq_info->irq_irq);
355 if (sn_irq_info->irq_int_bit != -1)
356 irq_set_handler(sn_irq_info->irq_irq, handle_level_irq);
355 spin_unlock(&sn_irq_info_lock); 357 spin_unlock(&sn_irq_info_lock);
356 358
357 register_intr_pda(sn_irq_info); 359 register_intr_pda(sn_irq_info);
diff --git a/arch/ia64/sn/kernel/sn2/sn_hwperf.c b/arch/ia64/sn/kernel/sn2/sn_hwperf.c
index 2de41d44266..4554f68b786 100644
--- a/arch/ia64/sn/kernel/sn2/sn_hwperf.c
+++ b/arch/ia64/sn/kernel/sn2/sn_hwperf.c
@@ -25,6 +25,7 @@
25 25
26#include <linux/fs.h> 26#include <linux/fs.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/export.h>
28#include <linux/vmalloc.h> 29#include <linux/vmalloc.h>
29#include <linux/seq_file.h> 30#include <linux/seq_file.h>
30#include <linux/miscdevice.h> 31#include <linux/miscdevice.h>
diff --git a/arch/ia64/sn/kernel/tiocx.c b/arch/ia64/sn/kernel/tiocx.c
index 26aeccb04f8..14c1711238c 100644
--- a/arch/ia64/sn/kernel/tiocx.c
+++ b/arch/ia64/sn/kernel/tiocx.c
@@ -190,6 +190,7 @@ cx_device_register(nasid_t nasid, int part_num, int mfg_num,
190 struct hubdev_info *hubdev, int bt) 190 struct hubdev_info *hubdev, int bt)
191{ 191{
192 struct cx_dev *cx_dev; 192 struct cx_dev *cx_dev;
193 int r;
193 194
194 cx_dev = kzalloc(sizeof(struct cx_dev), GFP_KERNEL); 195 cx_dev = kzalloc(sizeof(struct cx_dev), GFP_KERNEL);
195 DBG("cx_dev= 0x%p\n", cx_dev); 196 DBG("cx_dev= 0x%p\n", cx_dev);
@@ -206,7 +207,11 @@ cx_device_register(nasid_t nasid, int part_num, int mfg_num,
206 cx_dev->dev.bus = &tiocx_bus_type; 207 cx_dev->dev.bus = &tiocx_bus_type;
207 cx_dev->dev.release = tiocx_bus_release; 208 cx_dev->dev.release = tiocx_bus_release;
208 dev_set_name(&cx_dev->dev, "%d", cx_dev->cx_id.nasid); 209 dev_set_name(&cx_dev->dev, "%d", cx_dev->cx_id.nasid);
209 device_register(&cx_dev->dev); 210 r = device_register(&cx_dev->dev);
211 if (r) {
212 kfree(cx_dev);
213 return r;
214 }
210 get_device(&cx_dev->dev); 215 get_device(&cx_dev->dev);
211 216
212 device_create_file(&cx_dev->dev, &dev_attr_cxdev_control); 217 device_create_file(&cx_dev->dev, &dev_attr_cxdev_control);
diff --git a/arch/ia64/sn/pci/pcibr/pcibr_provider.c b/arch/ia64/sn/pci/pcibr/pcibr_provider.c
index 8886a0bc4a1..8dbbef4a4f4 100644
--- a/arch/ia64/sn/pci/pcibr/pcibr_provider.c
+++ b/arch/ia64/sn/pci/pcibr/pcibr_provider.c
@@ -146,6 +146,7 @@ pcibr_bus_fixup(struct pcibus_bussoft *prom_bussoft, struct pci_controller *cont
146 printk(KERN_WARNING 146 printk(KERN_WARNING
147 "pcibr cannot allocate interrupt for error handler\n"); 147 "pcibr cannot allocate interrupt for error handler\n");
148 } 148 }
149 irq_set_handler(SGI_PCIASIC_ERROR, handle_level_irq);
149 sn_set_err_irq_affinity(SGI_PCIASIC_ERROR); 150 sn_set_err_irq_affinity(SGI_PCIASIC_ERROR);
150 151
151 /* 152 /*
diff --git a/arch/ia64/sn/pci/tioca_provider.c b/arch/ia64/sn/pci/tioca_provider.c
index e77c477245f..a70b11fd57d 100644
--- a/arch/ia64/sn/pci/tioca_provider.c
+++ b/arch/ia64/sn/pci/tioca_provider.c
@@ -649,6 +649,7 @@ tioca_bus_fixup(struct pcibus_bussoft *prom_bussoft, struct pci_controller *cont
649 __func__, SGI_TIOCA_ERROR, 649 __func__, SGI_TIOCA_ERROR,
650 (int)tioca_common->ca_common.bs_persist_busnum); 650 (int)tioca_common->ca_common.bs_persist_busnum);
651 651
652 irq_set_handler(SGI_TIOCA_ERROR, handle_level_irq);
652 sn_set_err_irq_affinity(SGI_TIOCA_ERROR); 653 sn_set_err_irq_affinity(SGI_TIOCA_ERROR);
653 654
654 /* Setup locality information */ 655 /* Setup locality information */
diff --git a/arch/ia64/sn/pci/tioce_provider.c b/arch/ia64/sn/pci/tioce_provider.c
index 27faba035f3..46d3df4b03a 100644
--- a/arch/ia64/sn/pci/tioce_provider.c
+++ b/arch/ia64/sn/pci/tioce_provider.c
@@ -1037,6 +1037,7 @@ tioce_bus_fixup(struct pcibus_bussoft *prom_bussoft, struct pci_controller *cont
1037 tioce_common->ce_pcibus.bs_persist_segment, 1037 tioce_common->ce_pcibus.bs_persist_segment,
1038 tioce_common->ce_pcibus.bs_persist_busnum); 1038 tioce_common->ce_pcibus.bs_persist_busnum);
1039 1039
1040 irq_set_handler(SGI_PCIASIC_ERROR, handle_level_irq);
1040 sn_set_err_irq_affinity(SGI_PCIASIC_ERROR); 1041 sn_set_err_irq_affinity(SGI_PCIASIC_ERROR);
1041 return tioce_common; 1042 return tioce_common;
1042} 1043}
diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index 11060fa87da..ac22dc7f4ca 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -1,6 +1,7 @@
1config MICROBLAZE 1config MICROBLAZE
2 def_bool y 2 def_bool y
3 select HAVE_MEMBLOCK 3 select HAVE_MEMBLOCK
4 select HAVE_MEMBLOCK_NODE_MAP
4 select HAVE_FUNCTION_TRACER 5 select HAVE_FUNCTION_TRACER
5 select HAVE_FUNCTION_TRACE_MCOUNT_TEST 6 select HAVE_FUNCTION_TRACE_MCOUNT_TEST
6 select HAVE_FUNCTION_GRAPH_TRACER 7 select HAVE_FUNCTION_GRAPH_TRACER
@@ -28,6 +29,12 @@ config SWAP
28config RWSEM_GENERIC_SPINLOCK 29config RWSEM_GENERIC_SPINLOCK
29 def_bool y 30 def_bool y
30 31
32config ZONE_DMA
33 def_bool y
34
35config ARCH_POPULATES_NODE_MAP
36 def_bool y
37
31config RWSEM_XCHGADD_ALGORITHM 38config RWSEM_XCHGADD_ALGORITHM
32 bool 39 bool
33 40
@@ -153,20 +160,18 @@ config XILINX_UNCACHED_SHADOW
153 The feature requires the design to define the RAM memory controller 160 The feature requires the design to define the RAM memory controller
154 window to be twice as large as the actual physical memory. 161 window to be twice as large as the actual physical memory.
155 162
156config HIGHMEM_START_BOOL 163config HIGHMEM
157 bool "Set high memory pool address" 164 bool "High memory support"
158 depends on ADVANCED_OPTIONS && HIGHMEM 165 depends on MMU
159 help 166 help
160 This option allows you to set the base address of the kernel virtual 167 The address space of Microblaze processors is only 4 Gigabytes large
161 area used to map high memory pages. This can be useful in 168 and it has to accommodate user address space, kernel address
162 optimizing the layout of kernel virtual memory. 169 space as well as some memory mapped IO. That means that, if you
170 have a large amount of physical memory and/or IO, not all of the
171 memory can be "permanently mapped" by the kernel. The physical
172 memory that is not permanently mapped is called "high memory".
163 173
164 Say N here unless you know what you are doing. 174 If unsure, say n.
165
166config HIGHMEM_START
167 hex "Virtual start address of high memory pool" if HIGHMEM_START_BOOL
168 depends on MMU
169 default "0xfe000000"
170 175
171config LOWMEM_SIZE_BOOL 176config LOWMEM_SIZE_BOOL
172 bool "Set maximum low memory" 177 bool "Set maximum low memory"
@@ -255,6 +260,10 @@ config MICROBLAZE_32K_PAGES
255 260
256endchoice 261endchoice
257 262
263config KERNEL_PAD
264 hex "Kernel PAD for unpacking" if ADVANCED_OPTIONS
265 default "0x80000" if MMU
266
258endmenu 267endmenu
259 268
260source "mm/Kconfig" 269source "mm/Kconfig"
diff --git a/arch/microblaze/boot/Makefile b/arch/microblaze/boot/Makefile
index 0c796cf8158..34940c828de 100644
--- a/arch/microblaze/boot/Makefile
+++ b/arch/microblaze/boot/Makefile
@@ -8,7 +8,7 @@ obj-y += linked_dtb.o
8 8
9targets := linux.bin linux.bin.gz simpleImage.% 9targets := linux.bin linux.bin.gz simpleImage.%
10 10
11OBJCOPYFLAGS := -O binary 11OBJCOPYFLAGS := -R .note -R .comment -R .note.gnu.build-id -O binary
12 12
13# Ensure system.dtb exists 13# Ensure system.dtb exists
14$(obj)/linked_dtb.o: $(obj)/system.dtb 14$(obj)/linked_dtb.o: $(obj)/system.dtb
diff --git a/arch/microblaze/include/asm/fixmap.h b/arch/microblaze/include/asm/fixmap.h
new file mode 100644
index 00000000000..f2b312e10b1
--- /dev/null
+++ b/arch/microblaze/include/asm/fixmap.h
@@ -0,0 +1,109 @@
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 * Copyright 2008 Freescale Semiconductor Inc.
11 * Port to powerpc added by Kumar Gala
12 *
13 * Copyright 2011 Michal Simek <monstr@monstr.eu>
14 * Copyright 2011 PetaLogix Qld Pty Ltd
15 * Port to Microblaze
16 */
17
18#ifndef _ASM_FIXMAP_H
19#define _ASM_FIXMAP_H
20
21#ifndef __ASSEMBLY__
22#include <linux/kernel.h>
23#include <asm/page.h>
24#ifdef CONFIG_HIGHMEM
25#include <linux/threads.h>
26#include <asm/kmap_types.h>
27#endif
28
29#define FIXADDR_TOP ((unsigned long)(-PAGE_SIZE))
30
31/*
32 * Here we define all the compile-time 'special' virtual
33 * addresses. The point is to have a constant address at
34 * compile time, but to set the physical address only
35 * in the boot process. We allocate these special addresses
36 * from the end of virtual memory (0xfffff000) backwards.
37 * Also this lets us do fail-safe vmalloc(), we
38 * can guarantee that these special addresses and
39 * vmalloc()-ed addresses never overlap.
40 *
41 * these 'compile-time allocated' memory buffers are
42 * fixed-size 4k pages. (or larger if used with an increment
43 * highger than 1) use fixmap_set(idx,phys) to associate
44 * physical memory with fixmap indices.
45 *
46 * TLB entries of such buffers will not be flushed across
47 * task switches.
48 */
49enum fixed_addresses {
50 FIX_HOLE,
51#ifdef CONFIG_HIGHMEM
52 FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */
53 FIX_KMAP_END = FIX_KMAP_BEGIN + (KM_TYPE_NR * num_possible_cpus()) - 1,
54#endif
55 __end_of_fixed_addresses
56};
57
58extern void __set_fixmap(enum fixed_addresses idx,
59 phys_addr_t phys, pgprot_t flags);
60
61#define set_fixmap(idx, phys) \
62 __set_fixmap(idx, phys, PAGE_KERNEL)
63/*
64 * Some hardware wants to get fixmapped without caching.
65 */
66#define set_fixmap_nocache(idx, phys) \
67 __set_fixmap(idx, phys, PAGE_KERNEL_CI)
68
69#define clear_fixmap(idx) \
70 __set_fixmap(idx, 0, __pgprot(0))
71
72#define __FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)
73#define FIXADDR_START (FIXADDR_TOP - __FIXADDR_SIZE)
74
75#define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
76#define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
77
78extern void __this_fixmap_does_not_exist(void);
79
80/*
81 * 'index to address' translation. If anyone tries to use the idx
82 * directly without tranlation, we catch the bug with a NULL-deference
83 * kernel oops. Illegal ranges of incoming indices are caught too.
84 */
85static __always_inline unsigned long fix_to_virt(const unsigned int idx)
86{
87 /*
88 * this branch gets completely eliminated after inlining,
89 * except when someone tries to use fixaddr indices in an
90 * illegal way. (such as mixing up address types or using
91 * out-of-range indices).
92 *
93 * If it doesn't get removed, the linker will complain
94 * loudly with a reasonably clear error message..
95 */
96 if (idx >= __end_of_fixed_addresses)
97 __this_fixmap_does_not_exist();
98
99 return __fix_to_virt(idx);
100}
101
102static inline unsigned long virt_to_fix(const unsigned long vaddr)
103{
104 BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
105 return __virt_to_fix(vaddr);
106}
107
108#endif /* !__ASSEMBLY__ */
109#endif
diff --git a/arch/microblaze/include/asm/highmem.h b/arch/microblaze/include/asm/highmem.h
new file mode 100644
index 00000000000..2446a73140a
--- /dev/null
+++ b/arch/microblaze/include/asm/highmem.h
@@ -0,0 +1,96 @@
1/*
2 * highmem.h: virtual kernel memory mappings for high memory
3 *
4 * Used in CONFIG_HIGHMEM systems for memory pages which
5 * are not addressable by direct kernel virtual addresses.
6 *
7 * Copyright (C) 1999 Gerhard Wichert, Siemens AG
8 * Gerhard.Wichert@pdb.siemens.de
9 *
10 *
11 * Redesigned the x86 32-bit VM architecture to deal with
12 * up to 16 Terabyte physical memory. With current x86 CPUs
13 * we now support up to 64 Gigabytes physical RAM.
14 *
15 * Copyright (C) 1999 Ingo Molnar <mingo@redhat.com>
16 */
17#ifndef _ASM_HIGHMEM_H
18#define _ASM_HIGHMEM_H
19
20#ifdef __KERNEL__
21
22#include <linux/init.h>
23#include <linux/interrupt.h>
24#include <linux/uaccess.h>
25#include <asm/fixmap.h>
26
27extern pte_t *kmap_pte;
28extern pgprot_t kmap_prot;
29extern pte_t *pkmap_page_table;
30
31/*
32 * Right now we initialize only a single pte table. It can be extended
33 * easily, subsequent pte tables have to be allocated in one physical
34 * chunk of RAM.
35 */
36/*
37 * We use one full pte table with 4K pages. And with 16K/64K/256K pages pte
38 * table covers enough memory (32MB/512MB/2GB resp.), so that both FIXMAP
39 * and PKMAP can be placed in a single pte table. We use 512 pages for PKMAP
40 * in case of 16K/64K/256K page sizes.
41 */
42
43#define PKMAP_ORDER PTE_SHIFT
44#define LAST_PKMAP (1 << PKMAP_ORDER)
45
46#define PKMAP_BASE ((FIXADDR_START - PAGE_SIZE * (LAST_PKMAP + 1)) \
47 & PMD_MASK)
48
49#define LAST_PKMAP_MASK (LAST_PKMAP - 1)
50#define PKMAP_NR(virt) ((virt - PKMAP_BASE) >> PAGE_SHIFT)
51#define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT))
52
53extern void *kmap_high(struct page *page);
54extern void kunmap_high(struct page *page);
55extern void *kmap_atomic_prot(struct page *page, pgprot_t prot);
56extern void __kunmap_atomic(void *kvaddr);
57
58static inline void *kmap(struct page *page)
59{
60 might_sleep();
61 if (!PageHighMem(page))
62 return page_address(page);
63 return kmap_high(page);
64}
65
66static inline void kunmap(struct page *page)
67{
68 BUG_ON(in_interrupt());
69 if (!PageHighMem(page))
70 return;
71 kunmap_high(page);
72}
73
74static inline void *__kmap_atomic(struct page *page)
75{
76 return kmap_atomic_prot(page, kmap_prot);
77}
78
79static inline struct page *kmap_atomic_to_page(void *ptr)
80{
81 unsigned long idx, vaddr = (unsigned long) ptr;
82 pte_t *pte;
83
84 if (vaddr < FIXADDR_START)
85 return virt_to_page(ptr);
86
87 idx = virt_to_fix(vaddr);
88 pte = kmap_pte - (idx - FIX_KMAP_BEGIN);
89 return pte_page(*pte);
90}
91
92#define flush_cache_kmaps() { flush_icache(); flush_dcache(); }
93
94#endif /* __KERNEL__ */
95
96#endif /* _ASM_HIGHMEM_H */
diff --git a/arch/microblaze/include/asm/mmu.h b/arch/microblaze/include/asm/mmu.h
index 8d6a654ceff..1f9edddf7f4 100644
--- a/arch/microblaze/include/asm/mmu.h
+++ b/arch/microblaze/include/asm/mmu.h
@@ -56,6 +56,12 @@ typedef struct _SEGREG {
56 56
57extern void _tlbie(unsigned long va); /* invalidate a TLB entry */ 57extern void _tlbie(unsigned long va); /* invalidate a TLB entry */
58extern void _tlbia(void); /* invalidate all TLB entries */ 58extern void _tlbia(void); /* invalidate all TLB entries */
59
60/*
61 * tlb_skip size stores actual number skipped TLBs from TLB0 - every directy TLB
62 * mapping has to increase tlb_skip size.
63 */
64extern u32 tlb_skip;
59# endif /* __ASSEMBLY__ */ 65# endif /* __ASSEMBLY__ */
60 66
61/* 67/*
@@ -69,6 +75,12 @@ extern void _tlbia(void); /* invalidate all TLB entries */
69 75
70# define MICROBLAZE_TLB_SIZE 64 76# define MICROBLAZE_TLB_SIZE 64
71 77
78/* For cases when you want to skip some TLB entries */
79# define MICROBLAZE_TLB_SKIP 0
80
81/* Use the last TLB for temporary access to LMB */
82# define MICROBLAZE_LMB_TLB_ID 63
83
72/* 84/*
73 * TLB entries are defined by a "high" tag portion and a "low" data 85 * TLB entries are defined by a "high" tag portion and a "low" data
74 * portion. The data portion is 32-bits. 86 * portion. The data portion is 32-bits.
diff --git a/arch/microblaze/include/asm/page.h b/arch/microblaze/include/asm/page.h
index a25e6b5e2ad..287c5485d28 100644
--- a/arch/microblaze/include/asm/page.h
+++ b/arch/microblaze/include/asm/page.h
@@ -135,8 +135,10 @@ extern unsigned long min_low_pfn;
135extern unsigned long max_pfn; 135extern unsigned long max_pfn;
136 136
137extern unsigned long memory_start; 137extern unsigned long memory_start;
138extern unsigned long memory_end;
139extern unsigned long memory_size; 138extern unsigned long memory_size;
139extern unsigned long lowmem_size;
140
141extern unsigned long kernel_tlb;
140 142
141extern int page_is_ram(unsigned long pfn); 143extern int page_is_ram(unsigned long pfn);
142 144
diff --git a/arch/microblaze/include/asm/pci-bridge.h b/arch/microblaze/include/asm/pci-bridge.h
index e9834b2991d..cb5d3979480 100644
--- a/arch/microblaze/include/asm/pci-bridge.h
+++ b/arch/microblaze/include/asm/pci-bridge.h
@@ -10,7 +10,6 @@
10#include <linux/pci.h> 10#include <linux/pci.h>
11#include <linux/list.h> 11#include <linux/list.h>
12#include <linux/ioport.h> 12#include <linux/ioport.h>
13#include <asm-generic/pci-bridge.h>
14 13
15struct device_node; 14struct device_node;
16 15
diff --git a/arch/microblaze/include/asm/pci.h b/arch/microblaze/include/asm/pci.h
index 033137628e8..a0da88bf70c 100644
--- a/arch/microblaze/include/asm/pci.h
+++ b/arch/microblaze/include/asm/pci.h
@@ -94,14 +94,6 @@ extern int pci_mmap_legacy_page_range(struct pci_bus *bus,
94 */ 94 */
95#define PCI_DMA_BUS_IS_PHYS (1) 95#define PCI_DMA_BUS_IS_PHYS (1)
96 96
97extern void pcibios_resource_to_bus(struct pci_dev *dev,
98 struct pci_bus_region *region,
99 struct resource *res);
100
101extern void pcibios_bus_to_resource(struct pci_dev *dev,
102 struct resource *res,
103 struct pci_bus_region *region);
104
105static inline struct resource *pcibios_select_root(struct pci_dev *pdev, 97static inline struct resource *pcibios_select_root(struct pci_dev *pdev,
106 struct resource *res) 98 struct resource *res)
107{ 99{
diff --git a/arch/microblaze/include/asm/pgtable.h b/arch/microblaze/include/asm/pgtable.h
index b2af42311a1..3ef7b9cafec 100644
--- a/arch/microblaze/include/asm/pgtable.h
+++ b/arch/microblaze/include/asm/pgtable.h
@@ -94,8 +94,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
94/* Start and end of the vmalloc area. */ 94/* Start and end of the vmalloc area. */
95/* Make sure to map the vmalloc area above the pinned kernel memory area 95/* Make sure to map the vmalloc area above the pinned kernel memory area
96 of 32Mb. */ 96 of 32Mb. */
97#define VMALLOC_START (CONFIG_KERNEL_START + \ 97#define VMALLOC_START (CONFIG_KERNEL_START + CONFIG_LOWMEM_SIZE)
98 max(32 * 1024 * 1024UL, memory_size))
99#define VMALLOC_END ioremap_bot 98#define VMALLOC_END ioremap_bot
100 99
101#endif /* __ASSEMBLY__ */ 100#endif /* __ASSEMBLY__ */
@@ -543,8 +542,6 @@ extern unsigned long iopa(unsigned long addr);
543/* Needs to be defined here and not in linux/mm.h, as it is arch dependent */ 542/* Needs to be defined here and not in linux/mm.h, as it is arch dependent */
544#define kern_addr_valid(addr) (1) 543#define kern_addr_valid(addr) (1)
545 544
546#define io_remap_page_range remap_page_range
547
548/* 545/*
549 * No page table caches to initialise 546 * No page table caches to initialise
550 */ 547 */
diff --git a/arch/microblaze/include/asm/setup.h b/arch/microblaze/include/asm/setup.h
index aa22511819d..0061aa13a34 100644
--- a/arch/microblaze/include/asm/setup.h
+++ b/arch/microblaze/include/asm/setup.h
@@ -41,7 +41,8 @@ extern void of_platform_reset_gpio_probe(void);
41void time_init(void); 41void time_init(void);
42void init_IRQ(void); 42void init_IRQ(void);
43void machine_early_init(const char *cmdline, unsigned int ram, 43void machine_early_init(const char *cmdline, unsigned int ram,
44 unsigned int fdt, unsigned int msr); 44 unsigned int fdt, unsigned int msr, unsigned int tlb0,
45 unsigned int tlb1);
45 46
46void machine_restart(char *cmd); 47void machine_restart(char *cmd);
47void machine_shutdown(void); 48void machine_shutdown(void);
diff --git a/arch/microblaze/include/asm/uaccess.h b/arch/microblaze/include/asm/uaccess.h
index 072b0077abf..ef25f7538d4 100644
--- a/arch/microblaze/include/asm/uaccess.h
+++ b/arch/microblaze/include/asm/uaccess.h
@@ -80,7 +80,7 @@ extern unsigned long search_exception_table(unsigned long);
80static inline int ___range_ok(unsigned long addr, unsigned long size) 80static inline int ___range_ok(unsigned long addr, unsigned long size)
81{ 81{
82 return ((addr < memory_start) || 82 return ((addr < memory_start) ||
83 ((addr + size) > memory_end)); 83 ((addr + size - 1) > (memory_start + memory_size - 1)));
84} 84}
85 85
86#define __range_ok(addr, size) \ 86#define __range_ok(addr, size) \
diff --git a/arch/microblaze/kernel/cpu/cpuinfo.c b/arch/microblaze/kernel/cpu/cpuinfo.c
index 54194b28574..eab6abf5652 100644
--- a/arch/microblaze/kernel/cpu/cpuinfo.c
+++ b/arch/microblaze/kernel/cpu/cpuinfo.c
@@ -35,6 +35,8 @@ const struct cpu_ver_key cpu_ver_lookup[] = {
35 {"8.00.b", 0x13}, 35 {"8.00.b", 0x13},
36 {"8.10.a", 0x14}, 36 {"8.10.a", 0x14},
37 {"8.20.a", 0x15}, 37 {"8.20.a", 0x15},
38 {"8.20.b", 0x16},
39 {"8.30.a", 0x17},
38 {NULL, 0}, 40 {NULL, 0},
39}; 41};
40 42
diff --git a/arch/microblaze/kernel/early_printk.c b/arch/microblaze/kernel/early_printk.c
index 8356e47631c..ec485876d0d 100644
--- a/arch/microblaze/kernel/early_printk.c
+++ b/arch/microblaze/kernel/early_printk.c
@@ -171,10 +171,24 @@ void __init remap_early_printk(void)
171{ 171{
172 if (!early_console_initialized || !early_console) 172 if (!early_console_initialized || !early_console)
173 return; 173 return;
174 printk(KERN_INFO "early_printk_console remaping from 0x%x to ", 174 printk(KERN_INFO "early_printk_console remapping from 0x%x to ",
175 base_addr); 175 base_addr);
176 base_addr = (u32) ioremap(base_addr, PAGE_SIZE); 176 base_addr = (u32) ioremap(base_addr, PAGE_SIZE);
177 printk(KERN_CONT "0x%x\n", base_addr); 177 printk(KERN_CONT "0x%x\n", base_addr);
178
179 /*
180 * Early console is on the top of skipped TLB entries
181 * decrease tlb_skip size ensure that hardcoded TLB entry will be
182 * used by generic algorithm
183 * FIXME check if early console mapping is on the top by rereading
184 * TLB entry and compare baseaddr
185 * mts rtlbx, (tlb_skip - 1)
186 * nop
187 * mfs rX, rtlblo
188 * nop
189 * cmp rX, orig_base_addr
190 */
191 tlb_skip -= 1;
178} 192}
179 193
180void __init disable_early_printk(void) 194void __init disable_early_printk(void)
diff --git a/arch/microblaze/kernel/head.S b/arch/microblaze/kernel/head.S
index 77320b8fc16..98b17f9f904 100644
--- a/arch/microblaze/kernel/head.S
+++ b/arch/microblaze/kernel/head.S
@@ -63,9 +63,7 @@ ENTRY(_start)
63real_start: 63real_start:
64#endif 64#endif
65 65
66 mfs r1, rmsr 66 mts rmsr, r0
67 andi r1, r1, ~2
68 mts rmsr, r1
69/* 67/*
70 * According to Xilinx, msrclr instruction behaves like 'mfs rX,rpc' 68 * According to Xilinx, msrclr instruction behaves like 'mfs rX,rpc'
71 * if the msrclr instruction is not enabled. We use this to detect 69 * if the msrclr instruction is not enabled. We use this to detect
@@ -73,6 +71,7 @@ real_start:
73 * r8 == 0 - msr instructions are implemented 71 * r8 == 0 - msr instructions are implemented
74 * r8 != 0 - msr instructions are not implemented 72 * r8 != 0 - msr instructions are not implemented
75 */ 73 */
74 mfs r1, rmsr
76 msrclr r8, 0 /* clear nothing - just read msr for test */ 75 msrclr r8, 0 /* clear nothing - just read msr for test */
77 cmpu r8, r8, r1 /* r1 must contain msr reg content */ 76 cmpu r8, r8, r1 /* r1 must contain msr reg content */
78 77
@@ -96,7 +95,7 @@ big_endian:
96_prepare_copy_fdt: 95_prepare_copy_fdt:
97 or r11, r0, r0 /* incremment */ 96 or r11, r0, r0 /* incremment */
98 ori r4, r0, TOPHYS(_fdt_start) 97 ori r4, r0, TOPHYS(_fdt_start)
99 ori r3, r0, (0x4000 - 4) 98 ori r3, r0, (0x8000 - 4)
100_copy_fdt: 99_copy_fdt:
101 lw r12, r7, r11 /* r12 = r7 + r11 */ 100 lw r12, r7, r11 /* r12 = r7 + r11 */
102 sw r12, r4, r11 /* addr[r4 + r11] = r12 */ 101 sw r12, r4, r11 /* addr[r4 + r11] = r12 */
@@ -150,6 +149,7 @@ _copy_bram:
150_invalidate: 149_invalidate:
151 mts rtlbx, r3 150 mts rtlbx, r3
152 mts rtlbhi, r0 /* flush: ensure V is clear */ 151 mts rtlbhi, r0 /* flush: ensure V is clear */
152 mts rtlblo, r0
153 bgtid r3, _invalidate /* loop for all entries */ 153 bgtid r3, _invalidate /* loop for all entries */
154 addik r3, r3, -1 154 addik r3, r3, -1
155 /* sync */ 155 /* sync */
@@ -169,6 +169,53 @@ _invalidate:
169 addik r3,r0, CONFIG_KERNEL_START /* Load the kernel virtual address */ 169 addik r3,r0, CONFIG_KERNEL_START /* Load the kernel virtual address */
170 tophys(r4,r3) /* Load the kernel physical address */ 170 tophys(r4,r3) /* Load the kernel physical address */
171 171
172 /* start to do TLB calculation */
173 addik r12, r0, _end
174 rsub r12, r3, r12
175 addik r12, r12, CONFIG_KERNEL_PAD /* that's the pad */
176
177 or r9, r0, r0 /* TLB0 = 0 */
178 or r10, r0, r0 /* TLB1 = 0 */
179
180 addik r11, r12, -0x1000000
181 bgei r11, GT16 /* size is greater than 16MB */
182 addik r11, r12, -0x0800000
183 bgei r11, GT8 /* size is greater than 8MB */
184 addik r11, r12, -0x0400000
185 bgei r11, GT4 /* size is greater than 4MB */
186 /* size is less than 4MB */
187 addik r11, r12, -0x0200000
188 bgei r11, GT2 /* size is greater than 2MB */
189 addik r9, r0, 0x0100000 /* TLB0 must be 1MB */
190 addik r11, r12, -0x0100000
191 bgei r11, GT1 /* size is greater than 1MB */
192 /* TLB1 is 0 which is setup above */
193 bri tlb_end
194GT4: /* r11 contains the rest - will be either 1 or 4 */
195 ori r9, r0, 0x400000 /* TLB0 is 4MB */
196 bri TLB1
197GT16: /* TLB0 is 16MB */
198 addik r9, r0, 0x1000000 /* means TLB0 is 16MB */
199TLB1:
200 /* must be used r2 because of substract if failed */
201 addik r2, r11, -0x0400000
202 bgei r2, GT20 /* size is greater than 16MB */
203 /* size is >16MB and <20MB */
204 addik r11, r11, -0x0100000
205 bgei r11, GT17 /* size is greater than 17MB */
206 /* kernel is >16MB and < 17MB */
207GT1:
208 addik r10, r0, 0x0100000 /* means TLB1 is 1MB */
209 bri tlb_end
210GT2: /* TLB0 is 0 and TLB1 will be 4MB */
211GT17: /* TLB1 is 4MB - kernel size <20MB */
212 addik r10, r0, 0x0400000 /* means TLB1 is 4MB */
213 bri tlb_end
214GT8: /* TLB0 is still zero that's why I can use only TLB1 */
215GT20: /* TLB1 is 16MB - kernel size >20MB */
216 addik r10, r0, 0x1000000 /* means TLB1 is 16MB */
217tlb_end:
218
172 /* 219 /*
173 * Configure and load two entries into TLB slots 0 and 1. 220 * Configure and load two entries into TLB slots 0 and 1.
174 * In case we are pinning TLBs, these are reserved in by the 221 * In case we are pinning TLBs, these are reserved in by the
@@ -178,28 +225,81 @@ _invalidate:
178 andi r4,r4,0xfffffc00 /* Mask off the real page number */ 225 andi r4,r4,0xfffffc00 /* Mask off the real page number */
179 ori r4,r4,(TLB_WR | TLB_EX) /* Set the write and execute bits */ 226 ori r4,r4,(TLB_WR | TLB_EX) /* Set the write and execute bits */
180 227
228 /*
229 * TLB0 is always used - check if is not zero (r9 stores TLB0 value)
230 * if is use TLB1 value and clear it (r10 stores TLB1 value)
231 */
232 bnei r9, tlb0_not_zero
233 add r9, r10, r0
234 add r10, r0, r0
235tlb0_not_zero:
236
237 /* look at the code below */
238 ori r30, r0, 0x200
239 andi r29, r9, 0x100000
240 bneid r29, 1f
241 addik r30, r30, 0x80
242 andi r29, r9, 0x400000
243 bneid r29, 1f
244 addik r30, r30, 0x80
245 andi r29, r9, 0x1000000
246 bneid r29, 1f
247 addik r30, r30, 0x80
2481:
181 andi r3,r3,0xfffffc00 /* Mask off the effective page number */ 249 andi r3,r3,0xfffffc00 /* Mask off the effective page number */
182 ori r3,r3,(TLB_VALID | TLB_PAGESZ(PAGESZ_16M)) 250 ori r3,r3,(TLB_VALID)
251 or r3, r3, r30
183 252
184 mts rtlbx,r0 /* TLB slow 0 */ 253 /* Load tlb_skip size value which is index to first unused TLB entry */
254 lwi r11, r0, TOPHYS(tlb_skip)
255 mts rtlbx,r11 /* TLB slow 0 */
185 256
186 mts rtlblo,r4 /* Load the data portion of the entry */ 257 mts rtlblo,r4 /* Load the data portion of the entry */
187 mts rtlbhi,r3 /* Load the tag portion of the entry */ 258 mts rtlbhi,r3 /* Load the tag portion of the entry */
188 259
189 addik r4, r4, 0x01000000 /* Map next 16 M entries */ 260 /* Increase tlb_skip size */
190 addik r3, r3, 0x01000000 261 addik r11, r11, 1
262 swi r11, r0, TOPHYS(tlb_skip)
263
264 /* TLB1 can be zeroes that's why we not setup it */
265 beqi r10, jump_over2
266
267 /* look at the code below */
268 ori r30, r0, 0x200
269 andi r29, r10, 0x100000
270 bneid r29, 1f
271 addik r30, r30, 0x80
272 andi r29, r10, 0x400000
273 bneid r29, 1f
274 addik r30, r30, 0x80
275 andi r29, r10, 0x1000000
276 bneid r29, 1f
277 addik r30, r30, 0x80
2781:
279 addk r4, r4, r9 /* previous addr + TLB0 size */
280 addk r3, r3, r9
191 281
192 ori r6,r0,1 /* TLB slot 1 */ 282 andi r3,r3,0xfffffc00 /* Mask off the effective page number */
193 mts rtlbx,r6 283 ori r3,r3,(TLB_VALID)
284 or r3, r3, r30
285
286 lwi r11, r0, TOPHYS(tlb_skip)
287 mts rtlbx, r11 /* r11 is used from TLB0 */
194 288
195 mts rtlblo,r4 /* Load the data portion of the entry */ 289 mts rtlblo,r4 /* Load the data portion of the entry */
196 mts rtlbhi,r3 /* Load the tag portion of the entry */ 290 mts rtlbhi,r3 /* Load the tag portion of the entry */
197 291
292 /* Increase tlb_skip size */
293 addik r11, r11, 1
294 swi r11, r0, TOPHYS(tlb_skip)
295
296jump_over2:
198 /* 297 /*
199 * Load a TLB entry for LMB, since we need access to 298 * Load a TLB entry for LMB, since we need access to
200 * the exception vectors, using a 4k real==virtual mapping. 299 * the exception vectors, using a 4k real==virtual mapping.
201 */ 300 */
202 ori r6,r0,3 /* TLB slot 3 */ 301 /* Use temporary TLB_ID for LMB - clear this temporary mapping later */
302 ori r6, r0, MICROBLAZE_LMB_TLB_ID
203 mts rtlbx,r6 303 mts rtlbx,r6
204 304
205 ori r4,r0,(TLB_WR | TLB_EX) 305 ori r4,r0,(TLB_WR | TLB_EX)
@@ -238,8 +338,8 @@ start_here:
238 * Please see $(ARCH)/mach-$(SUBARCH)/setup.c for 338 * Please see $(ARCH)/mach-$(SUBARCH)/setup.c for
239 * the function. 339 * the function.
240 */ 340 */
241 addik r9, r0, machine_early_init 341 addik r11, r0, machine_early_init
242 brald r15, r9 342 brald r15, r11
243 nop 343 nop
244 344
245#ifndef CONFIG_MMU 345#ifndef CONFIG_MMU
@@ -268,8 +368,7 @@ start_here:
268 368
269 /* Load up the kernel context */ 369 /* Load up the kernel context */
270kernel_load_context: 370kernel_load_context:
271 # Keep entry 0 and 1 valid. Entry 3 mapped to LMB can go away. 371 ori r5, r0, MICROBLAZE_LMB_TLB_ID
272 ori r5,r0,3
273 mts rtlbx,r5 372 mts rtlbx,r5
274 nop 373 nop
275 mts rtlbhi,r0 374 mts rtlbhi,r0
diff --git a/arch/microblaze/kernel/hw_exception_handler.S b/arch/microblaze/kernel/hw_exception_handler.S
index e62be837960..aa510f450ac 100644
--- a/arch/microblaze/kernel/hw_exception_handler.S
+++ b/arch/microblaze/kernel/hw_exception_handler.S
@@ -820,19 +820,26 @@ ex_handler_done:
820 * Upon exit, we reload everything and RFI. 820 * Upon exit, we reload everything and RFI.
821 * A common place to load the TLB. 821 * A common place to load the TLB.
822 */ 822 */
823.section .data
824.align 4
825.global tlb_skip
826 tlb_skip:
827 .long MICROBLAZE_TLB_SKIP
823 tlb_index: 828 tlb_index:
824 .long 1 /* MS: storing last used tlb index */ 829 /* MS: storing last used tlb index */
830 .long MICROBLAZE_TLB_SIZE/2
831.previous
825 finish_tlb_load: 832 finish_tlb_load:
826 /* MS: load the last used TLB index. */ 833 /* MS: load the last used TLB index. */
827 lwi r5, r0, TOPHYS(tlb_index) 834 lwi r5, r0, TOPHYS(tlb_index)
828 addik r5, r5, 1 /* MS: inc tlb_index -> use next one */ 835 addik r5, r5, 1 /* MS: inc tlb_index -> use next one */
829 836
830/* MS: FIXME this is potential fault, because this is mask not count */ 837/* MS: FIXME this is potential fault, because this is mask not count */
831 andi r5, r5, (MICROBLAZE_TLB_SIZE-1) 838 andi r5, r5, MICROBLAZE_TLB_SIZE - 1
832 ori r6, r0, 1 839 ori r6, r0, 1
833 cmp r31, r5, r6 840 cmp r31, r5, r6
834 blti r31, ex12 841 blti r31, ex12
835 addik r5, r6, 1 842 lwi r5, r0, TOPHYS(tlb_skip)
836 ex12: 843 ex12:
837 /* MS: save back current TLB index */ 844 /* MS: save back current TLB index */
838 swi r5, r0, TOPHYS(tlb_index) 845 swi r5, r0, TOPHYS(tlb_index)
diff --git a/arch/microblaze/kernel/intc.c b/arch/microblaze/kernel/intc.c
index ad120672cee..6c54d4dcdec 100644
--- a/arch/microblaze/kernel/intc.c
+++ b/arch/microblaze/kernel/intc.c
@@ -151,8 +151,8 @@ void __init init_IRQ(void)
151#ifdef CONFIG_SELFMOD_INTC 151#ifdef CONFIG_SELFMOD_INTC
152 selfmod_function((int *) arr_func, intc_baseaddr); 152 selfmod_function((int *) arr_func, intc_baseaddr);
153#endif 153#endif
154 printk(KERN_INFO "XPS intc #0 at 0x%08x, num_irq=%d, edge=0x%x\n", 154 printk(KERN_INFO "%s #0 at 0x%08x, num_irq=%d, edge=0x%x\n",
155 intc_baseaddr, nr_irq, intr_mask); 155 intc->name, intc_baseaddr, nr_irq, intr_mask);
156 156
157 /* 157 /*
158 * Disable all external interrupts until they are 158 * Disable all external interrupts until they are
diff --git a/arch/microblaze/kernel/misc.S b/arch/microblaze/kernel/misc.S
index 206da3da361..1dafddeb8a0 100644
--- a/arch/microblaze/kernel/misc.S
+++ b/arch/microblaze/kernel/misc.S
@@ -29,16 +29,16 @@
29.type _tlbia, @function 29.type _tlbia, @function
30.align 4; 30.align 4;
31_tlbia: 31_tlbia:
32 addik r12, r0, MICROBLAZE_TLB_SIZE - 1 /* flush all entries (63 - 3) */ 32 lwi r12, r0, tlb_skip;
33 /* isync */ 33 /* isync */
34_tlbia_1: 34_tlbia_1:
35 mts rtlbx, r12 35 mts rtlbx, r12
36 nop 36 nop
37 mts rtlbhi, r0 /* flush: ensure V is clear */ 37 mts rtlbhi, r0 /* flush: ensure V is clear */
38 nop 38 nop
39 addik r11, r12, -2 39 rsubi r11, r12, MICROBLAZE_TLB_SIZE - 1
40 bneid r11, _tlbia_1 /* loop for all entries */ 40 bneid r11, _tlbia_1 /* loop for all entries */
41 addik r12, r12, -1 41 addik r12, r12, 1
42 /* sync */ 42 /* sync */
43 rtsd r15, 8 43 rtsd r15, 8
44 nop 44 nop
@@ -75,7 +75,7 @@ early_console_reg_tlb_alloc:
75 * Load a TLB entry for the UART, so that microblaze_progress() can use 75 * Load a TLB entry for the UART, so that microblaze_progress() can use
76 * the UARTs nice and early. We use a 4k real==virtual mapping. 76 * the UARTs nice and early. We use a 4k real==virtual mapping.
77 */ 77 */
78 ori r4, r0, MICROBLAZE_TLB_SIZE - 1 78 lwi r4, r0, tlb_skip
79 mts rtlbx, r4 /* TLB slot 63 */ 79 mts rtlbx, r4 /* TLB slot 63 */
80 80
81 or r4,r5,r0 81 or r4,r5,r0
@@ -89,6 +89,11 @@ early_console_reg_tlb_alloc:
89 nop 89 nop
90 mts rtlbhi,r5 /* Load the tag portion of the entry */ 90 mts rtlbhi,r5 /* Load the tag portion of the entry */
91 nop 91 nop
92
93 lwi r5, r0, tlb_skip
94 addik r5, r5, 1
95 swi r5, r0, tlb_skip
96
92 rtsd r15, 8 97 rtsd r15, 8
93 nop 98 nop
94 99
diff --git a/arch/microblaze/kernel/setup.c b/arch/microblaze/kernel/setup.c
index 7a9f39efbf3..71af974aa24 100644
--- a/arch/microblaze/kernel/setup.c
+++ b/arch/microblaze/kernel/setup.c
@@ -94,8 +94,11 @@ inline unsigned get_romfs_len(unsigned *addr)
94} 94}
95#endif /* CONFIG_MTD_UCLINUX_EBSS */ 95#endif /* CONFIG_MTD_UCLINUX_EBSS */
96 96
97unsigned long kernel_tlb;
98
97void __init machine_early_init(const char *cmdline, unsigned int ram, 99void __init machine_early_init(const char *cmdline, unsigned int ram,
98 unsigned int fdt, unsigned int msr) 100 unsigned int fdt, unsigned int msr, unsigned int tlb0,
101 unsigned int tlb1)
99{ 102{
100 unsigned long *src, *dst; 103 unsigned long *src, *dst;
101 unsigned int offset = 0; 104 unsigned int offset = 0;
@@ -142,6 +145,12 @@ void __init machine_early_init(const char *cmdline, unsigned int ram,
142 setup_early_printk(NULL); 145 setup_early_printk(NULL);
143#endif 146#endif
144 147
148 /* setup kernel_tlb after BSS cleaning
149 * Maybe worth to move to asm code */
150 kernel_tlb = tlb0 + tlb1;
151 /* printk("TLB1 0x%08x, TLB0 0x%08x, tlb 0x%x\n", tlb0,
152 tlb1, kernel_tlb); */
153
145 printk("Ramdisk addr 0x%08x, ", ram); 154 printk("Ramdisk addr 0x%08x, ", ram);
146 if (fdt) 155 if (fdt)
147 printk("FDT at 0x%08x\n", fdt); 156 printk("FDT at 0x%08x\n", fdt);
@@ -196,6 +205,19 @@ static int microblaze_debugfs_init(void)
196 return of_debugfs_root == NULL; 205 return of_debugfs_root == NULL;
197} 206}
198arch_initcall(microblaze_debugfs_init); 207arch_initcall(microblaze_debugfs_init);
208
209static int __init debugfs_tlb(void)
210{
211 struct dentry *d;
212
213 if (!of_debugfs_root)
214 return -ENODEV;
215
216 d = debugfs_create_u32("tlb_skip", S_IRUGO, of_debugfs_root, &tlb_skip);
217 if (!d)
218 return -ENOMEM;
219}
220device_initcall(debugfs_tlb);
199#endif 221#endif
200 222
201static int dflt_bus_notify(struct notifier_block *nb, 223static int dflt_bus_notify(struct notifier_block *nb,
diff --git a/arch/microblaze/kernel/timer.c b/arch/microblaze/kernel/timer.c
index d3a38eca12d..522defa7d41 100644
--- a/arch/microblaze/kernel/timer.c
+++ b/arch/microblaze/kernel/timer.c
@@ -78,7 +78,7 @@ static inline void microblaze_timer0_start_periodic(unsigned long load_val)
78 * !PWMA - disable pwm 78 * !PWMA - disable pwm
79 * TINT - clear interrupt status 79 * TINT - clear interrupt status
80 * ENT- enable timer itself 80 * ENT- enable timer itself
81 * EINT - enable interrupt 81 * ENIT - enable interrupt
82 * !LOAD - clear the bit to let go 82 * !LOAD - clear the bit to let go
83 * ARHT - auto reload 83 * ARHT - auto reload
84 * !CAPT - no external trigger 84 * !CAPT - no external trigger
@@ -273,8 +273,8 @@ void __init time_init(void)
273#ifdef CONFIG_SELFMOD_TIMER 273#ifdef CONFIG_SELFMOD_TIMER
274 selfmod_function((int *) arr_func, timer_baseaddr); 274 selfmod_function((int *) arr_func, timer_baseaddr);
275#endif 275#endif
276 printk(KERN_INFO "XPS timer #0 at 0x%08x, irq=%d\n", 276 printk(KERN_INFO "%s #0 at 0x%08x, irq=%d\n",
277 timer_baseaddr, irq); 277 timer->name, timer_baseaddr, irq);
278 278
279 /* If there is clock-frequency property than use it */ 279 /* If there is clock-frequency property than use it */
280 prop = of_get_property(timer, "clock-frequency", NULL); 280 prop = of_get_property(timer, "clock-frequency", NULL);
diff --git a/arch/microblaze/kernel/vmlinux.lds.S b/arch/microblaze/kernel/vmlinux.lds.S
index ac0e1a5d478..109e9d86ade 100644
--- a/arch/microblaze/kernel/vmlinux.lds.S
+++ b/arch/microblaze/kernel/vmlinux.lds.S
@@ -44,7 +44,7 @@ SECTIONS {
44 __fdt_blob : AT(ADDR(__fdt_blob) - LOAD_OFFSET) { 44 __fdt_blob : AT(ADDR(__fdt_blob) - LOAD_OFFSET) {
45 _fdt_start = . ; /* place for fdt blob */ 45 _fdt_start = . ; /* place for fdt blob */
46 *(__fdt_blob) ; /* Any link-placed DTB */ 46 *(__fdt_blob) ; /* Any link-placed DTB */
47 . = _fdt_start + 0x4000; /* Pad up to 16kbyte */ 47 . = _fdt_start + 0x8000; /* Pad up to 32kbyte */
48 _fdt_end = . ; 48 _fdt_end = . ;
49 } 49 }
50 50
diff --git a/arch/microblaze/mm/Makefile b/arch/microblaze/mm/Makefile
index 09c49ed8723..7313bd8acbb 100644
--- a/arch/microblaze/mm/Makefile
+++ b/arch/microblaze/mm/Makefile
@@ -5,3 +5,4 @@
5obj-y := consistent.o init.o 5obj-y := consistent.o init.o
6 6
7obj-$(CONFIG_MMU) += pgtable.o mmu_context.o fault.o 7obj-$(CONFIG_MMU) += pgtable.o mmu_context.o fault.o
8obj-$(CONFIG_HIGHMEM) += highmem.o
diff --git a/arch/microblaze/mm/highmem.c b/arch/microblaze/mm/highmem.c
new file mode 100644
index 00000000000..7d78838e8bf
--- /dev/null
+++ b/arch/microblaze/mm/highmem.c
@@ -0,0 +1,88 @@
1/*
2 * highmem.c: virtual kernel memory mappings for high memory
3 *
4 * PowerPC version, stolen from the i386 version.
5 *
6 * Used in CONFIG_HIGHMEM systems for memory pages which
7 * are not addressable by direct kernel virtual addresses.
8 *
9 * Copyright (C) 1999 Gerhard Wichert, Siemens AG
10 * Gerhard.Wichert@pdb.siemens.de
11 *
12 *
13 * Redesigned the x86 32-bit VM architecture to deal with
14 * up to 16 Terrabyte physical memory. With current x86 CPUs
15 * we now support up to 64 Gigabytes physical RAM.
16 *
17 * Copyright (C) 1999 Ingo Molnar <mingo@redhat.com>
18 *
19 * Reworked for PowerPC by various contributors. Moved from
20 * highmem.h by Benjamin Herrenschmidt (c) 2009 IBM Corp.
21 */
22
23#include <linux/highmem.h>
24#include <linux/module.h>
25
26/*
27 * The use of kmap_atomic/kunmap_atomic is discouraged - kmap/kunmap
28 * gives a more generic (and caching) interface. But kmap_atomic can
29 * be used in IRQ contexts, so in some (very limited) cases we need
30 * it.
31 */
32#include <asm/tlbflush.h>
33
34void *kmap_atomic_prot(struct page *page, pgprot_t prot)
35{
36
37 unsigned long vaddr;
38 int idx, type;
39
40 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
41 pagefault_disable();
42 if (!PageHighMem(page))
43 return page_address(page);
44
45
46 type = kmap_atomic_idx_push();
47 idx = type + KM_TYPE_NR*smp_processor_id();
48 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
49#ifdef CONFIG_DEBUG_HIGHMEM
50 BUG_ON(!pte_none(*(kmap_pte-idx)));
51#endif
52 set_pte_at(&init_mm, vaddr, kmap_pte-idx, mk_pte(page, prot));
53 local_flush_tlb_page(NULL, vaddr);
54
55 return (void *) vaddr;
56}
57EXPORT_SYMBOL(kmap_atomic_prot);
58
59void __kunmap_atomic(void *kvaddr)
60{
61 unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
62 int type;
63
64 if (vaddr < __fix_to_virt(FIX_KMAP_END)) {
65 pagefault_enable();
66 return;
67 }
68
69 type = kmap_atomic_idx();
70#ifdef CONFIG_DEBUG_HIGHMEM
71 {
72 unsigned int idx;
73
74 idx = type + KM_TYPE_NR * smp_processor_id();
75 BUG_ON(vaddr != __fix_to_virt(FIX_KMAP_BEGIN + idx));
76
77 /*
78 * force other mappings to Oops if they'll try to access
79 * this pte without first remap it
80 */
81 pte_clear(&init_mm, vaddr, kmap_pte-idx);
82 local_flush_tlb_page(NULL, vaddr);
83 }
84#endif
85 kmap_atomic_idx_pop();
86 pagefault_enable();
87}
88EXPORT_SYMBOL(__kunmap_atomic);
diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
index 565d193c7eb..ce80823051b 100644
--- a/arch/microblaze/mm/init.c
+++ b/arch/microblaze/mm/init.c
@@ -24,6 +24,7 @@
24#include <asm/pgalloc.h> 24#include <asm/pgalloc.h>
25#include <asm/sections.h> 25#include <asm/sections.h>
26#include <asm/tlb.h> 26#include <asm/tlb.h>
27#include <asm/fixmap.h>
27 28
28/* Use for MMU and noMMU because of PCI generic code */ 29/* Use for MMU and noMMU because of PCI generic code */
29int mem_init_done; 30int mem_init_done;
@@ -44,9 +45,56 @@ char *klimit = _end;
44 */ 45 */
45unsigned long memory_start; 46unsigned long memory_start;
46EXPORT_SYMBOL(memory_start); 47EXPORT_SYMBOL(memory_start);
47unsigned long memory_end; /* due to mm/nommu.c */
48unsigned long memory_size; 48unsigned long memory_size;
49EXPORT_SYMBOL(memory_size); 49EXPORT_SYMBOL(memory_size);
50unsigned long lowmem_size;
51
52#ifdef CONFIG_HIGHMEM
53pte_t *kmap_pte;
54EXPORT_SYMBOL(kmap_pte);
55pgprot_t kmap_prot;
56EXPORT_SYMBOL(kmap_prot);
57
58static inline pte_t *virt_to_kpte(unsigned long vaddr)
59{
60 return pte_offset_kernel(pmd_offset(pgd_offset_k(vaddr),
61 vaddr), vaddr);
62}
63
64static void __init highmem_init(void)
65{
66 pr_debug("%x\n", (u32)PKMAP_BASE);
67 map_page(PKMAP_BASE, 0, 0); /* XXX gross */
68 pkmap_page_table = virt_to_kpte(PKMAP_BASE);
69
70 kmap_pte = virt_to_kpte(__fix_to_virt(FIX_KMAP_BEGIN));
71 kmap_prot = PAGE_KERNEL;
72}
73
74static unsigned long highmem_setup(void)
75{
76 unsigned long pfn;
77 unsigned long reservedpages = 0;
78
79 for (pfn = max_low_pfn; pfn < max_pfn; ++pfn) {
80 struct page *page = pfn_to_page(pfn);
81
82 /* FIXME not sure about */
83 if (memblock_is_reserved(pfn << PAGE_SHIFT))
84 continue;
85 ClearPageReserved(page);
86 init_page_count(page);
87 __free_page(page);
88 totalhigh_pages++;
89 reservedpages++;
90 }
91 totalram_pages += totalhigh_pages;
92 printk(KERN_INFO "High memory: %luk\n",
93 totalhigh_pages << (PAGE_SHIFT-10));
94
95 return reservedpages;
96}
97#endif /* CONFIG_HIGHMEM */
50 98
51/* 99/*
52 * paging_init() sets up the page tables - in fact we've already done this. 100 * paging_init() sets up the page tables - in fact we've already done this.
@@ -54,17 +102,28 @@ EXPORT_SYMBOL(memory_size);
54static void __init paging_init(void) 102static void __init paging_init(void)
55{ 103{
56 unsigned long zones_size[MAX_NR_ZONES]; 104 unsigned long zones_size[MAX_NR_ZONES];
105#ifdef CONFIG_MMU
106 int idx;
107
108 /* Setup fixmaps */
109 for (idx = 0; idx < __end_of_fixed_addresses; idx++)
110 clear_fixmap(idx);
111#endif
57 112
58 /* Clean every zones */ 113 /* Clean every zones */
59 memset(zones_size, 0, sizeof(zones_size)); 114 memset(zones_size, 0, sizeof(zones_size));
60 115
61 /* 116#ifdef CONFIG_HIGHMEM
62 * old: we can DMA to/from any address.put all page into ZONE_DMA 117 highmem_init();
63 * We use only ZONE_NORMAL
64 */
65 zones_size[ZONE_NORMAL] = max_mapnr;
66 118
67 free_area_init(zones_size); 119 zones_size[ZONE_DMA] = max_low_pfn;
120 zones_size[ZONE_HIGHMEM] = max_pfn;
121#else
122 zones_size[ZONE_DMA] = max_pfn;
123#endif
124
125 /* We don't have holes in memory map */
126 free_area_init_nodes(zones_size);
68} 127}
69 128
70void __init setup_memory(void) 129void __init setup_memory(void)
@@ -78,32 +137,31 @@ void __init setup_memory(void)
78 /* Find main memory where is the kernel */ 137 /* Find main memory where is the kernel */
79 for_each_memblock(memory, reg) { 138 for_each_memblock(memory, reg) {
80 memory_start = (u32)reg->base; 139 memory_start = (u32)reg->base;
81 memory_end = (u32) reg->base + reg->size; 140 lowmem_size = reg->size;
82 if ((memory_start <= (u32)_text) && 141 if ((memory_start <= (u32)_text) &&
83 ((u32)_text <= memory_end)) { 142 ((u32)_text <= (memory_start + lowmem_size - 1))) {
84 memory_size = memory_end - memory_start; 143 memory_size = lowmem_size;
85 PAGE_OFFSET = memory_start; 144 PAGE_OFFSET = memory_start;
86 printk(KERN_INFO "%s: Main mem: 0x%x-0x%x, " 145 printk(KERN_INFO "%s: Main mem: 0x%x, "
87 "size 0x%08x\n", __func__, (u32) memory_start, 146 "size 0x%08x\n", __func__, (u32) memory_start,
88 (u32) memory_end, (u32) memory_size); 147 (u32) memory_size);
89 break; 148 break;
90 } 149 }
91 } 150 }
92 151
93 if (!memory_start || !memory_end) { 152 if (!memory_start || !memory_size) {
94 panic("%s: Missing memory setting 0x%08x-0x%08x\n", 153 panic("%s: Missing memory setting 0x%08x, size=0x%08x\n",
95 __func__, (u32) memory_start, (u32) memory_end); 154 __func__, (u32) memory_start, (u32) memory_size);
96 } 155 }
97 156
98 /* reservation of region where is the kernel */ 157 /* reservation of region where is the kernel */
99 kernel_align_start = PAGE_DOWN((u32)_text); 158 kernel_align_start = PAGE_DOWN((u32)_text);
100 /* ALIGN can be remove because _end in vmlinux.lds.S is align */ 159 /* ALIGN can be remove because _end in vmlinux.lds.S is align */
101 kernel_align_size = PAGE_UP((u32)klimit) - kernel_align_start; 160 kernel_align_size = PAGE_UP((u32)klimit) - kernel_align_start;
102 memblock_reserve(kernel_align_start, kernel_align_size); 161 printk(KERN_INFO "%s: kernel addr:0x%08x-0x%08x size=0x%08x\n",
103 printk(KERN_INFO "%s: kernel addr=0x%08x-0x%08x size=0x%08x\n",
104 __func__, kernel_align_start, kernel_align_start 162 __func__, kernel_align_start, kernel_align_start
105 + kernel_align_size, kernel_align_size); 163 + kernel_align_size, kernel_align_size);
106 164 memblock_reserve(kernel_align_start, kernel_align_size);
107#endif 165#endif
108 /* 166 /*
109 * Kernel: 167 * Kernel:
@@ -120,11 +178,13 @@ void __init setup_memory(void)
120 min_low_pfn = memory_start >> PAGE_SHIFT; /* minimum for allocation */ 178 min_low_pfn = memory_start >> PAGE_SHIFT; /* minimum for allocation */
121 /* RAM is assumed contiguous */ 179 /* RAM is assumed contiguous */
122 num_physpages = max_mapnr = memory_size >> PAGE_SHIFT; 180 num_physpages = max_mapnr = memory_size >> PAGE_SHIFT;
123 max_pfn = max_low_pfn = memory_end >> PAGE_SHIFT; 181 max_low_pfn = ((u64)memory_start + (u64)lowmem_size) >> PAGE_SHIFT;
182 max_pfn = ((u64)memory_start + (u64)memory_size) >> PAGE_SHIFT;
124 183
125 printk(KERN_INFO "%s: max_mapnr: %#lx\n", __func__, max_mapnr); 184 printk(KERN_INFO "%s: max_mapnr: %#lx\n", __func__, max_mapnr);
126 printk(KERN_INFO "%s: min_low_pfn: %#lx\n", __func__, min_low_pfn); 185 printk(KERN_INFO "%s: min_low_pfn: %#lx\n", __func__, min_low_pfn);
127 printk(KERN_INFO "%s: max_low_pfn: %#lx\n", __func__, max_low_pfn); 186 printk(KERN_INFO "%s: max_low_pfn: %#lx\n", __func__, max_low_pfn);
187 printk(KERN_INFO "%s: max_pfn: %#lx\n", __func__, max_pfn);
128 188
129 /* 189 /*
130 * Find an area to use for the bootmem bitmap. 190 * Find an area to use for the bootmem bitmap.
@@ -137,15 +197,39 @@ void __init setup_memory(void)
137 PFN_UP(TOPHYS((u32)klimit)), min_low_pfn, max_low_pfn); 197 PFN_UP(TOPHYS((u32)klimit)), min_low_pfn, max_low_pfn);
138 memblock_reserve(PFN_UP(TOPHYS((u32)klimit)) << PAGE_SHIFT, map_size); 198 memblock_reserve(PFN_UP(TOPHYS((u32)klimit)) << PAGE_SHIFT, map_size);
139 199
200 /* Add active regions with valid PFNs */
201 for_each_memblock(memory, reg) {
202 unsigned long start_pfn, end_pfn;
203
204 start_pfn = memblock_region_memory_base_pfn(reg);
205 end_pfn = memblock_region_memory_end_pfn(reg);
206 memblock_set_node(start_pfn << PAGE_SHIFT,
207 (end_pfn - start_pfn) << PAGE_SHIFT, 0);
208 }
209
140 /* free bootmem is whole main memory */ 210 /* free bootmem is whole main memory */
141 free_bootmem(memory_start, memory_size); 211 free_bootmem_with_active_regions(0, max_low_pfn);
142 212
143 /* reserve allocate blocks */ 213 /* reserve allocate blocks */
144 for_each_memblock(reserved, reg) { 214 for_each_memblock(reserved, reg) {
145 pr_debug("reserved - 0x%08x-0x%08x\n", 215 unsigned long top = reg->base + reg->size - 1;
146 (u32) reg->base, (u32) reg->size); 216
147 reserve_bootmem(reg->base, reg->size, BOOTMEM_DEFAULT); 217 pr_debug("reserved - 0x%08x-0x%08x, %lx, %lx\n",
218 (u32) reg->base, (u32) reg->size, top,
219 memory_start + lowmem_size - 1);
220
221 if (top <= (memory_start + lowmem_size - 1)) {
222 reserve_bootmem(reg->base, reg->size, BOOTMEM_DEFAULT);
223 } else if (reg->base < (memory_start + lowmem_size - 1)) {
224 unsigned long trunc_size = memory_start + lowmem_size -
225 reg->base;
226 reserve_bootmem(reg->base, trunc_size, BOOTMEM_DEFAULT);
227 }
148 } 228 }
229
230 /* XXX need to clip this if using highmem? */
231 sparse_memory_present_with_active_regions(0);
232
149#ifdef CONFIG_MMU 233#ifdef CONFIG_MMU
150 init_bootmem_done = 1; 234 init_bootmem_done = 1;
151#endif 235#endif
@@ -190,13 +274,58 @@ void free_initmem(void)
190 274
191void __init mem_init(void) 275void __init mem_init(void)
192{ 276{
193 high_memory = (void *)__va(memory_end); 277 pg_data_t *pgdat;
278 unsigned long reservedpages = 0, codesize, initsize, datasize, bsssize;
279
280 high_memory = (void *)__va(memory_start + lowmem_size - 1);
281
194 /* this will put all memory onto the freelists */ 282 /* this will put all memory onto the freelists */
195 totalram_pages += free_all_bootmem(); 283 totalram_pages += free_all_bootmem();
196 284
197 printk(KERN_INFO "Memory: %luk/%luk available\n", 285 for_each_online_pgdat(pgdat) {
198 nr_free_pages() << (PAGE_SHIFT-10), 286 unsigned long i;
199 num_physpages << (PAGE_SHIFT-10)); 287 struct page *page;
288
289 for (i = 0; i < pgdat->node_spanned_pages; i++) {
290 if (!pfn_valid(pgdat->node_start_pfn + i))
291 continue;
292 page = pgdat_page_nr(pgdat, i);
293 if (PageReserved(page))
294 reservedpages++;
295 }
296 }
297
298#ifdef CONFIG_HIGHMEM
299 reservedpages -= highmem_setup();
300#endif
301
302 codesize = (unsigned long)&_sdata - (unsigned long)&_stext;
303 datasize = (unsigned long)&_edata - (unsigned long)&_sdata;
304 initsize = (unsigned long)&__init_end - (unsigned long)&__init_begin;
305 bsssize = (unsigned long)&__bss_stop - (unsigned long)&__bss_start;
306
307 pr_info("Memory: %luk/%luk available (%luk kernel code, "
308 "%luk reserved, %luk data, %luk bss, %luk init)\n",
309 nr_free_pages() << (PAGE_SHIFT-10),
310 num_physpages << (PAGE_SHIFT-10),
311 codesize >> 10,
312 reservedpages << (PAGE_SHIFT-10),
313 datasize >> 10,
314 bsssize >> 10,
315 initsize >> 10);
316
317#ifdef CONFIG_MMU
318 pr_info("Kernel virtual memory layout:\n");
319 pr_info(" * 0x%08lx..0x%08lx : fixmap\n", FIXADDR_START, FIXADDR_TOP);
320#ifdef CONFIG_HIGHMEM
321 pr_info(" * 0x%08lx..0x%08lx : highmem PTEs\n",
322 PKMAP_BASE, PKMAP_ADDR(LAST_PKMAP));
323#endif /* CONFIG_HIGHMEM */
324 pr_info(" * 0x%08lx..0x%08lx : early ioremap\n",
325 ioremap_bot, ioremap_base);
326 pr_info(" * 0x%08lx..0x%08lx : vmalloc & ioremap\n",
327 (unsigned long)VMALLOC_START, VMALLOC_END);
328#endif
200 mem_init_done = 1; 329 mem_init_done = 1;
201} 330}
202 331
@@ -226,7 +355,6 @@ static void mm_cmdline_setup(void)
226 maxmem = memparse(p, &p); 355 maxmem = memparse(p, &p);
227 if (maxmem && memory_size > maxmem) { 356 if (maxmem && memory_size > maxmem) {
228 memory_size = maxmem; 357 memory_size = maxmem;
229 memory_end = memory_start + memory_size;
230 memblock.memory.regions[0].size = memory_size; 358 memblock.memory.regions[0].size = memory_size;
231 } 359 }
232 } 360 }
@@ -270,15 +398,26 @@ asmlinkage void __init mmu_init(void)
270 machine_restart(NULL); 398 machine_restart(NULL);
271 } 399 }
272 400
273 if ((u32) memblock.memory.regions[0].size < 0x1000000) { 401 if ((u32) memblock.memory.regions[0].size < 0x400000) {
274 printk(KERN_EMERG "Memory must be greater than 16MB\n"); 402 printk(KERN_EMERG "Memory must be greater than 4MB\n");
403 machine_restart(NULL);
404 }
405
406 if ((u32) memblock.memory.regions[0].size < kernel_tlb) {
407 printk(KERN_EMERG "Kernel size is greater than memory node\n");
275 machine_restart(NULL); 408 machine_restart(NULL);
276 } 409 }
410
277 /* Find main memory where the kernel is */ 411 /* Find main memory where the kernel is */
278 memory_start = (u32) memblock.memory.regions[0].base; 412 memory_start = (u32) memblock.memory.regions[0].base;
279 memory_end = (u32) memblock.memory.regions[0].base + 413 lowmem_size = memory_size = (u32) memblock.memory.regions[0].size;
280 (u32) memblock.memory.regions[0].size; 414
281 memory_size = memory_end - memory_start; 415 if (lowmem_size > CONFIG_LOWMEM_SIZE) {
416 lowmem_size = CONFIG_LOWMEM_SIZE;
417#ifndef CONFIG_HIGHMEM
418 memory_size = lowmem_size;
419#endif
420 }
282 421
283 mm_cmdline_setup(); /* FIXME parse args from command line - not used */ 422 mm_cmdline_setup(); /* FIXME parse args from command line - not used */
284 423
@@ -305,15 +444,20 @@ asmlinkage void __init mmu_init(void)
305 /* Map in all of RAM starting at CONFIG_KERNEL_START */ 444 /* Map in all of RAM starting at CONFIG_KERNEL_START */
306 mapin_ram(); 445 mapin_ram();
307 446
308#ifdef CONFIG_HIGHMEM_START_BOOL 447 /* Extend vmalloc and ioremap area as big as possible */
309 ioremap_base = CONFIG_HIGHMEM_START; 448#ifdef CONFIG_HIGHMEM
449 ioremap_base = ioremap_bot = PKMAP_BASE;
310#else 450#else
311 ioremap_base = 0xfe000000UL; /* for now, could be 0xfffff000 */ 451 ioremap_base = ioremap_bot = FIXADDR_START;
312#endif /* CONFIG_HIGHMEM_START_BOOL */ 452#endif
313 ioremap_bot = ioremap_base;
314 453
315 /* Initialize the context management stuff */ 454 /* Initialize the context management stuff */
316 mmu_context_init(); 455 mmu_context_init();
456
457 /* Shortly after that, the entire linear mapping will be available */
458 /* This will also cause that unflatten device tree will be allocated
459 * inside 768MB limit */
460 memblock_set_current_limit(memory_start + lowmem_size - 1);
317} 461}
318 462
319/* This is only called until mem_init is done. */ 463/* This is only called until mem_init is done. */
@@ -324,11 +468,11 @@ void __init *early_get_page(void)
324 p = alloc_bootmem_pages(PAGE_SIZE); 468 p = alloc_bootmem_pages(PAGE_SIZE);
325 } else { 469 } else {
326 /* 470 /*
327 * Mem start + 32MB -> here is limit 471 * Mem start + kernel_tlb -> here is limit
328 * because of mem mapping from head.S 472 * because of mem mapping from head.S
329 */ 473 */
330 p = __va(memblock_alloc_base(PAGE_SIZE, PAGE_SIZE, 474 p = __va(memblock_alloc_base(PAGE_SIZE, PAGE_SIZE,
331 memory_start + 0x2000000)); 475 memory_start + kernel_tlb));
332 } 476 }
333 return p; 477 return p;
334} 478}
diff --git a/arch/microblaze/mm/pgtable.c b/arch/microblaze/mm/pgtable.c
index 59bf2335a4c..d1c06d07fed 100644
--- a/arch/microblaze/mm/pgtable.c
+++ b/arch/microblaze/mm/pgtable.c
@@ -37,6 +37,7 @@
37#include <linux/io.h> 37#include <linux/io.h>
38#include <asm/mmu.h> 38#include <asm/mmu.h>
39#include <asm/sections.h> 39#include <asm/sections.h>
40#include <asm/fixmap.h>
40 41
41#define flush_HPTE(X, va, pg) _tlbie(va) 42#define flush_HPTE(X, va, pg) _tlbie(va)
42 43
@@ -44,11 +45,6 @@ unsigned long ioremap_base;
44unsigned long ioremap_bot; 45unsigned long ioremap_bot;
45EXPORT_SYMBOL(ioremap_bot); 46EXPORT_SYMBOL(ioremap_bot);
46 47
47/* The maximum lowmem defaults to 768Mb, but this can be configured to
48 * another value.
49 */
50#define MAX_LOW_MEM CONFIG_LOWMEM_SIZE
51
52#ifndef CONFIG_SMP 48#ifndef CONFIG_SMP
53struct pgtable_cache_struct quicklists; 49struct pgtable_cache_struct quicklists;
54#endif 50#endif
@@ -80,7 +76,7 @@ static void __iomem *__ioremap(phys_addr_t addr, unsigned long size,
80 !(p >= virt_to_phys((unsigned long)&__bss_stop) && 76 !(p >= virt_to_phys((unsigned long)&__bss_stop) &&
81 p < virt_to_phys((unsigned long)__bss_stop))) { 77 p < virt_to_phys((unsigned long)__bss_stop))) {
82 printk(KERN_WARNING "__ioremap(): phys addr "PTE_FMT 78 printk(KERN_WARNING "__ioremap(): phys addr "PTE_FMT
83 " is RAM lr %p\n", (unsigned long)p, 79 " is RAM lr %pf\n", (unsigned long)p,
84 __builtin_return_address(0)); 80 __builtin_return_address(0));
85 return NULL; 81 return NULL;
86 } 82 }
@@ -171,7 +167,7 @@ void __init mapin_ram(void)
171 167
172 v = CONFIG_KERNEL_START; 168 v = CONFIG_KERNEL_START;
173 p = memory_start; 169 p = memory_start;
174 for (s = 0; s < memory_size; s += PAGE_SIZE) { 170 for (s = 0; s < lowmem_size; s += PAGE_SIZE) {
175 f = _PAGE_PRESENT | _PAGE_ACCESSED | 171 f = _PAGE_PRESENT | _PAGE_ACCESSED |
176 _PAGE_SHARED | _PAGE_HWEXEC; 172 _PAGE_SHARED | _PAGE_HWEXEC;
177 if ((char *) v < _stext || (char *) v >= _etext) 173 if ((char *) v < _stext || (char *) v >= _etext)
@@ -254,3 +250,13 @@ __init_refok pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
254 } 250 }
255 return pte; 251 return pte;
256} 252}
253
254void __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t flags)
255{
256 unsigned long address = __fix_to_virt(idx);
257
258 if (idx >= __end_of_fixed_addresses)
259 BUG();
260
261 map_page(address, phys, pgprot_val(flags));
262}
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 85f2ac1230a..d10403dadd2 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -46,9 +46,6 @@ static int global_phb_number; /* Global phb counter */
46/* ISA Memory physical address */ 46/* ISA Memory physical address */
47resource_size_t isa_mem_base; 47resource_size_t isa_mem_base;
48 48
49/* Default PCI flags is 0 on ppc32, modified at boot on ppc64 */
50unsigned int pci_flags;
51
52static struct dma_map_ops *pci_dma_ops = &dma_direct_ops; 49static struct dma_map_ops *pci_dma_ops = &dma_direct_ops;
53 50
54unsigned long isa_io_base; 51unsigned long isa_io_base;
@@ -833,64 +830,7 @@ int pci_proc_domain(struct pci_bus *bus)
833{ 830{
834 struct pci_controller *hose = pci_bus_to_host(bus); 831 struct pci_controller *hose = pci_bus_to_host(bus);
835 832
836 if (!(pci_flags & PCI_ENABLE_PROC_DOMAINS)) 833 return 0;
837 return 0;
838 if (pci_flags & PCI_COMPAT_DOMAIN_0)
839 return hose->global_number != 0;
840 return 1;
841}
842
843void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
844 struct resource *res)
845{
846 resource_size_t offset = 0, mask = (resource_size_t)-1;
847 struct pci_controller *hose = pci_bus_to_host(dev->bus);
848
849 if (!hose)
850 return;
851 if (res->flags & IORESOURCE_IO) {
852 offset = (unsigned long)hose->io_base_virt - _IO_BASE;
853 mask = 0xffffffffu;
854 } else if (res->flags & IORESOURCE_MEM)
855 offset = hose->pci_mem_offset;
856
857 region->start = (res->start - offset) & mask;
858 region->end = (res->end - offset) & mask;
859}
860EXPORT_SYMBOL(pcibios_resource_to_bus);
861
862void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
863 struct pci_bus_region *region)
864{
865 resource_size_t offset = 0, mask = (resource_size_t)-1;
866 struct pci_controller *hose = pci_bus_to_host(dev->bus);
867
868 if (!hose)
869 return;
870 if (res->flags & IORESOURCE_IO) {
871 offset = (unsigned long)hose->io_base_virt - _IO_BASE;
872 mask = 0xffffffffu;
873 } else if (res->flags & IORESOURCE_MEM)
874 offset = hose->pci_mem_offset;
875 res->start = (region->start + offset) & mask;
876 res->end = (region->end + offset) & mask;
877}
878EXPORT_SYMBOL(pcibios_bus_to_resource);
879
880/* Fixup a bus resource into a linux resource */
881static void __devinit fixup_resource(struct resource *res, struct pci_dev *dev)
882{
883 struct pci_controller *hose = pci_bus_to_host(dev->bus);
884 resource_size_t offset = 0, mask = (resource_size_t)-1;
885
886 if (res->flags & IORESOURCE_IO) {
887 offset = (unsigned long)hose->io_base_virt - _IO_BASE;
888 mask = 0xffffffffu;
889 } else if (res->flags & IORESOURCE_MEM)
890 offset = hose->pci_mem_offset;
891
892 res->start = (res->start + offset) & mask;
893 res->end = (res->end + offset) & mask;
894} 834}
895 835
896/* This header fixup will do the resource fixup for all devices as they are 836/* This header fixup will do the resource fixup for all devices as they are
@@ -910,13 +850,7 @@ static void __devinit pcibios_fixup_resources(struct pci_dev *dev)
910 struct resource *res = dev->resource + i; 850 struct resource *res = dev->resource + i;
911 if (!res->flags) 851 if (!res->flags)
912 continue; 852 continue;
913 /* On platforms that have PCI_PROBE_ONLY set, we don't 853 if (res->start == 0) {
914 * consider 0 as an unassigned BAR value. It's technically
915 * a valid value, but linux doesn't like it... so when we can
916 * re-assign things, we do so, but if we can't, we keep it
917 * around and hope for the best...
918 */
919 if (res->start == 0 && !(pci_flags & PCI_PROBE_ONLY)) {
920 pr_debug("PCI:%s Resource %d %016llx-%016llx [%x]" \ 854 pr_debug("PCI:%s Resource %d %016llx-%016llx [%x]" \
921 "is unassigned\n", 855 "is unassigned\n",
922 pci_name(dev), i, 856 pci_name(dev), i,
@@ -929,18 +863,11 @@ static void __devinit pcibios_fixup_resources(struct pci_dev *dev)
929 continue; 863 continue;
930 } 864 }
931 865
932 pr_debug("PCI:%s Resource %d %016llx-%016llx [%x] fixup...\n", 866 pr_debug("PCI:%s Resource %d %016llx-%016llx [%x]\n",
933 pci_name(dev), i, 867 pci_name(dev), i,
934 (unsigned long long)res->start,\ 868 (unsigned long long)res->start,\
935 (unsigned long long)res->end, 869 (unsigned long long)res->end,
936 (unsigned int)res->flags); 870 (unsigned int)res->flags);
937
938 fixup_resource(res, dev);
939
940 pr_debug("PCI:%s %016llx-%016llx\n",
941 pci_name(dev),
942 (unsigned long long)res->start,
943 (unsigned long long)res->end);
944 } 871 }
945} 872}
946DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pcibios_fixup_resources); 873DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pcibios_fixup_resources);
@@ -959,10 +886,6 @@ static int __devinit pcibios_uninitialized_bridge_resource(struct pci_bus *bus,
959 u16 command; 886 u16 command;
960 int i; 887 int i;
961 888
962 /* We don't do anything if PCI_PROBE_ONLY is set */
963 if (pci_flags & PCI_PROBE_ONLY)
964 return 0;
965
966 /* Job is a bit different between memory and IO */ 889 /* Job is a bit different between memory and IO */
967 if (res->flags & IORESOURCE_MEM) { 890 if (res->flags & IORESOURCE_MEM) {
968 /* If the BAR is non-0 (res != pci_mem_offset) then it's 891 /* If the BAR is non-0 (res != pci_mem_offset) then it's
@@ -1037,9 +960,6 @@ static void __devinit pcibios_fixup_bridge(struct pci_bus *bus)
1037 (unsigned long long)res->end, 960 (unsigned long long)res->end,
1038 (unsigned int)res->flags); 961 (unsigned int)res->flags);
1039 962
1040 /* Perform fixup */
1041 fixup_resource(res, dev);
1042
1043 /* Try to detect uninitialized P2P bridge resources, 963 /* Try to detect uninitialized P2P bridge resources,
1044 * and clear them out so they get re-assigned later 964 * and clear them out so they get re-assigned later
1045 */ 965 */
@@ -1107,9 +1027,6 @@ EXPORT_SYMBOL(pcibios_fixup_bus);
1107 1027
1108static int skip_isa_ioresource_align(struct pci_dev *dev) 1028static int skip_isa_ioresource_align(struct pci_dev *dev)
1109{ 1029{
1110 if ((pci_flags & PCI_CAN_SKIP_ISA_ALIGN) &&
1111 !(dev->bus->bridge_ctl & PCI_BRIDGE_CTL_ISA))
1112 return 1;
1113 return 0; 1030 return 0;
1114} 1031}
1115 1032
@@ -1236,8 +1153,6 @@ void pcibios_allocate_bus_resources(struct pci_bus *bus)
1236 * and as such ensure proper re-allocation 1153 * and as such ensure proper re-allocation
1237 * later. 1154 * later.
1238 */ 1155 */
1239 if (pci_flags & PCI_REASSIGN_ALL_RSRC)
1240 goto clear_resource;
1241 pr = pci_find_parent_resource(bus->self, res); 1156 pr = pci_find_parent_resource(bus->self, res);
1242 if (pr == res) { 1157 if (pr == res) {
1243 /* this happens when the generic PCI 1158 /* this happens when the generic PCI
@@ -1422,27 +1337,19 @@ void __init pcibios_resource_survey(void)
1422 list_for_each_entry(b, &pci_root_buses, node) 1337 list_for_each_entry(b, &pci_root_buses, node)
1423 pcibios_allocate_bus_resources(b); 1338 pcibios_allocate_bus_resources(b);
1424 1339
1425 if (!(pci_flags & PCI_REASSIGN_ALL_RSRC)) { 1340 pcibios_allocate_resources(0);
1426 pcibios_allocate_resources(0); 1341 pcibios_allocate_resources(1);
1427 pcibios_allocate_resources(1);
1428 }
1429 1342
1430 /* Before we start assigning unassigned resource, we try to reserve 1343 /* Before we start assigning unassigned resource, we try to reserve
1431 * the low IO area and the VGA memory area if they intersect the 1344 * the low IO area and the VGA memory area if they intersect the
1432 * bus available resources to avoid allocating things on top of them 1345 * bus available resources to avoid allocating things on top of them
1433 */ 1346 */
1434 if (!(pci_flags & PCI_PROBE_ONLY)) { 1347 list_for_each_entry(b, &pci_root_buses, node)
1435 list_for_each_entry(b, &pci_root_buses, node) 1348 pcibios_reserve_legacy_regions(b);
1436 pcibios_reserve_legacy_regions(b);
1437 }
1438 1349
1439 /* Now, if the platform didn't decide to blindly trust the firmware, 1350 /* Now proceed to assigning things that were left unassigned */
1440 * we proceed to assigning things that were left unassigned 1351 pr_debug("PCI: Assigning unassigned resources...\n");
1441 */ 1352 pci_assign_unassigned_resources();
1442 if (!(pci_flags & PCI_PROBE_ONLY)) {
1443 pr_debug("PCI: Assigning unassigned resources...\n");
1444 pci_assign_unassigned_resources();
1445 }
1446} 1353}
1447 1354
1448#ifdef CONFIG_HOTPLUG 1355#ifdef CONFIG_HOTPLUG
@@ -1535,7 +1442,7 @@ static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, s
1535 res->end = res->start + IO_SPACE_LIMIT; 1442 res->end = res->start + IO_SPACE_LIMIT;
1536 res->flags = IORESOURCE_IO; 1443 res->flags = IORESOURCE_IO;
1537 } 1444 }
1538 pci_add_resource(resources, res); 1445 pci_add_resource_offset(resources, res, hose->io_base_virt - _IO_BASE);
1539 1446
1540 pr_debug("PCI: PHB IO resource = %016llx-%016llx [%lx]\n", 1447 pr_debug("PCI: PHB IO resource = %016llx-%016llx [%lx]\n",
1541 (unsigned long long)res->start, 1448 (unsigned long long)res->start,
@@ -1558,7 +1465,7 @@ static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, s
1558 res->flags = IORESOURCE_MEM; 1465 res->flags = IORESOURCE_MEM;
1559 1466
1560 } 1467 }
1561 pci_add_resource(resources, res); 1468 pci_add_resource_offset(resources, res, hose->pci_mem_offset);
1562 1469
1563 pr_debug("PCI: PHB MEM resource %d = %016llx-%016llx [%lx]\n", 1470 pr_debug("PCI: PHB MEM resource %d = %016llx-%016llx [%lx]\n",
1564 i, (unsigned long long)res->start, 1471 i, (unsigned long long)res->start,
diff --git a/arch/mips/fw/arc/cmdline.c b/arch/mips/fw/arc/cmdline.c
index 9fdf07e50f1..c0122a1dc58 100644
--- a/arch/mips/fw/arc/cmdline.c
+++ b/arch/mips/fw/arc/cmdline.c
@@ -7,6 +7,7 @@
7 * 7 *
8 * Copyright (C) 1996 David S. Miller (davem@davemloft.net) 8 * Copyright (C) 1996 David S. Miller (davem@davemloft.net)
9 */ 9 */
10#include <linux/bug.h>
10#include <linux/init.h> 11#include <linux/init.h>
11#include <linux/kernel.h> 12#include <linux/kernel.h>
12#include <linux/string.h> 13#include <linux/string.h>
diff --git a/arch/mips/fw/arc/identify.c b/arch/mips/fw/arc/identify.c
index 788060a53dc..54a33c756f6 100644
--- a/arch/mips/fw/arc/identify.c
+++ b/arch/mips/fw/arc/identify.c
@@ -11,6 +11,7 @@
11 * 11 *
12 * Copyright (C) 1996 David S. Miller (davem@davemloft.net) 12 * Copyright (C) 1996 David S. Miller (davem@davemloft.net)
13 */ 13 */
14#include <linux/bug.h>
14#include <linux/init.h> 15#include <linux/init.h>
15#include <linux/kernel.h> 16#include <linux/kernel.h>
16#include <linux/types.h> 17#include <linux/types.h>
diff --git a/arch/mips/include/asm/mman.h b/arch/mips/include/asm/mman.h
index 785b4ea4ec3..46d3da0d4b9 100644
--- a/arch/mips/include/asm/mman.h
+++ b/arch/mips/include/asm/mman.h
@@ -80,6 +80,10 @@
80#define MADV_HUGEPAGE 14 /* Worth backing with hugepages */ 80#define MADV_HUGEPAGE 14 /* Worth backing with hugepages */
81#define MADV_NOHUGEPAGE 15 /* Not worth backing with hugepages */ 81#define MADV_NOHUGEPAGE 15 /* Not worth backing with hugepages */
82 82
83#define MADV_DONTDUMP 16 /* Explicity exclude from the core dump,
84 overrides the coredump filter bits */
85#define MADV_DODUMP 17 /* Clear the MADV_NODUMP flag */
86
83/* compatibility flags */ 87/* compatibility flags */
84#define MAP_FILE 0 88#define MAP_FILE 0
85 89
diff --git a/arch/mips/include/asm/pci.h b/arch/mips/include/asm/pci.h
index 576397c6992..fcd4060f642 100644
--- a/arch/mips/include/asm/pci.h
+++ b/arch/mips/include/asm/pci.h
@@ -92,6 +92,7 @@ extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
92#include <asm/scatterlist.h> 92#include <asm/scatterlist.h>
93#include <linux/string.h> 93#include <linux/string.h>
94#include <asm/io.h> 94#include <asm/io.h>
95#include <asm-generic/pci-bridge.h>
95 96
96struct pci_dev; 97struct pci_dev;
97 98
@@ -112,12 +113,6 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
112} 113}
113#endif 114#endif
114 115
115extern void pcibios_resource_to_bus(struct pci_dev *dev,
116 struct pci_bus_region *region, struct resource *res);
117
118extern void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
119 struct pci_bus_region *region);
120
121#define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index 116#define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index
122 117
123static inline int pci_proc_domain(struct pci_bus *bus) 118static inline int pci_proc_domain(struct pci_bus *bus)
@@ -145,8 +140,6 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
145#define arch_setup_msi_irqs arch_setup_msi_irqs 140#define arch_setup_msi_irqs arch_setup_msi_irqs
146#endif 141#endif
147 142
148extern int pci_probe_only;
149
150extern char * (*pcibios_plat_setup)(char *str); 143extern char * (*pcibios_plat_setup)(char *str);
151 144
152#endif /* _ASM_PCI_H */ 145#endif /* _ASM_PCI_H */
diff --git a/arch/mips/kernel/vdso.c b/arch/mips/kernel/vdso.c
index e5cdfd603f8..0f1af58b036 100644
--- a/arch/mips/kernel/vdso.c
+++ b/arch/mips/kernel/vdso.c
@@ -88,8 +88,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
88 88
89 ret = install_special_mapping(mm, addr, PAGE_SIZE, 89 ret = install_special_mapping(mm, addr, PAGE_SIZE,
90 VM_READ|VM_EXEC| 90 VM_READ|VM_EXEC|
91 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC| 91 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
92 VM_ALWAYSDUMP,
93 &vdso_page); 92 &vdso_page);
94 93
95 if (ret) 94 if (ret)
diff --git a/arch/mips/pci/fixup-cobalt.c b/arch/mips/pci/fixup-cobalt.c
index acacd1407c6..9553b14002d 100644
--- a/arch/mips/pci/fixup-cobalt.c
+++ b/arch/mips/pci/fixup-cobalt.c
@@ -51,67 +51,6 @@ 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 __devinit cobalt_legacy_ide_resource_fixup(struct pci_dev *dev,
55 struct resource *res)
56{
57 struct pci_controller *hose = (struct pci_controller *)dev->sysdata;
58 unsigned long offset = hose->io_offset;
59 struct resource orig = *res;
60
61 if (!(res->flags & IORESOURCE_IO) ||
62 !(res->flags & IORESOURCE_PCI_FIXED))
63 return;
64
65 res->start -= offset;
66 res->end -= offset;
67 dev_printk(KERN_DEBUG, &dev->dev, "converted legacy %pR to bus %pR\n",
68 &orig, res);
69}
70
71static void __devinit cobalt_legacy_ide_fixup(struct pci_dev *dev)
72{
73 u32 class;
74 u8 progif;
75
76 /*
77 * If the IDE controller is in legacy mode, pci_setup_device() fills in
78 * the resources with the legacy addresses that normally appear on the
79 * PCI bus, just as if we had read them from a BAR.
80 *
81 * However, with the GT-64111, those legacy addresses, e.g., 0x1f0,
82 * will never appear on the PCI bus because it converts memory accesses
83 * in the PCI I/O region (which is never at address zero) into I/O port
84 * accesses with no address translation.
85 *
86 * For example, if GT_DEF_PCI0_IO_BASE is 0x10000000, a load or store
87 * to physical address 0x100001f0 will become a PCI access to I/O port
88 * 0x100001f0. There's no way to generate an access to I/O port 0x1f0,
89 * but the VT82C586 IDE controller does respond at 0x100001f0 because
90 * it only decodes the low 24 bits of the address.
91 *
92 * When this quirk runs, the pci_dev resources should contain bus
93 * addresses, not Linux I/O port numbers, so convert legacy addresses
94 * like 0x1f0 to bus addresses like 0x100001f0. Later, we'll convert
95 * them back with pcibios_fixup_bus() or pcibios_bus_to_resource().
96 */
97 class = dev->class >> 8;
98 if (class != PCI_CLASS_STORAGE_IDE)
99 return;
100
101 pci_read_config_byte(dev, PCI_CLASS_PROG, &progif);
102 if ((progif & 1) == 0) {
103 cobalt_legacy_ide_resource_fixup(dev, &dev->resource[0]);
104 cobalt_legacy_ide_resource_fixup(dev, &dev->resource[1]);
105 }
106 if ((progif & 4) == 0) {
107 cobalt_legacy_ide_resource_fixup(dev, &dev->resource[2]);
108 cobalt_legacy_ide_resource_fixup(dev, &dev->resource[3]);
109 }
110}
111
112DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_1,
113 cobalt_legacy_ide_fixup);
114
115static void qube_raq_via_bmIDE_fixup(struct pci_dev *dev) 54static void qube_raq_via_bmIDE_fixup(struct pci_dev *dev)
116{ 55{
117 unsigned short cfgword; 56 unsigned short cfgword;
diff --git a/arch/mips/pci/pci-bcm1480.c b/arch/mips/pci/pci-bcm1480.c
index af8c3199696..37b52dc3d27 100644
--- a/arch/mips/pci/pci-bcm1480.c
+++ b/arch/mips/pci/pci-bcm1480.c
@@ -204,7 +204,7 @@ static int __init bcm1480_pcibios_init(void)
204 uint64_t reg; 204 uint64_t reg;
205 205
206 /* CFE will assign PCI resources */ 206 /* CFE will assign PCI resources */
207 pci_probe_only = 1; 207 pci_set_flags(PCI_PROBE_ONLY);
208 208
209 /* Avoid ISA compat ranges. */ 209 /* Avoid ISA compat ranges. */
210 PCIBIOS_MIN_IO = 0x00008000UL; 210 PCIBIOS_MIN_IO = 0x00008000UL;
diff --git a/arch/mips/pci/pci-ip27.c b/arch/mips/pci/pci-ip27.c
index 193e9494f98..0fbe4c0c170 100644
--- a/arch/mips/pci/pci-ip27.c
+++ b/arch/mips/pci/pci-ip27.c
@@ -50,7 +50,7 @@ int __cpuinit bridge_probe(nasid_t nasid, int widget_id, int masterwid)
50 bridge_t *bridge; 50 bridge_t *bridge;
51 int slot; 51 int slot;
52 52
53 pci_probe_only = 1; 53 pci_set_flags(PCI_PROBE_ONLY);
54 54
55 printk("a bridge\n"); 55 printk("a bridge\n");
56 56
diff --git a/arch/mips/pci/pci-lantiq.c b/arch/mips/pci/pci-lantiq.c
index be1e1afe12c..030c77e7926 100644
--- a/arch/mips/pci/pci-lantiq.c
+++ b/arch/mips/pci/pci-lantiq.c
@@ -270,7 +270,8 @@ static int __devinit ltq_pci_probe(struct platform_device *pdev)
270{ 270{
271 struct ltq_pci_data *ltq_pci_data = 271 struct ltq_pci_data *ltq_pci_data =
272 (struct ltq_pci_data *) pdev->dev.platform_data; 272 (struct ltq_pci_data *) pdev->dev.platform_data;
273 pci_probe_only = 0; 273
274 pci_clear_flags(PCI_PROBE_ONLY);
274 ltq_pci_irq_map = ltq_pci_data->irq; 275 ltq_pci_irq_map = ltq_pci_data->irq;
275 ltq_pci_membase = ioremap_nocache(PCI_CR_BASE_ADDR, PCI_CR_SIZE); 276 ltq_pci_membase = ioremap_nocache(PCI_CR_BASE_ADDR, PCI_CR_SIZE);
276 ltq_pci_mapped_cfg = 277 ltq_pci_mapped_cfg =
diff --git a/arch/mips/pci/pci-sb1250.c b/arch/mips/pci/pci-sb1250.c
index 1711e8e101b..dd97f3a83ba 100644
--- a/arch/mips/pci/pci-sb1250.c
+++ b/arch/mips/pci/pci-sb1250.c
@@ -213,7 +213,7 @@ static int __init sb1250_pcibios_init(void)
213 uint64_t reg; 213 uint64_t reg;
214 214
215 /* CFE will assign PCI resources */ 215 /* CFE will assign PCI resources */
216 pci_probe_only = 1; 216 pci_set_flags(PCI_PROBE_ONLY);
217 217
218 /* Avoid ISA compat ranges. */ 218 /* Avoid ISA compat ranges. */
219 PCIBIOS_MIN_IO = 0x00008000UL; 219 PCIBIOS_MIN_IO = 0x00008000UL;
diff --git a/arch/mips/pci/pci-xlr.c b/arch/mips/pci/pci-xlr.c
index 3d701a962ef..1644805a673 100644
--- a/arch/mips/pci/pci-xlr.c
+++ b/arch/mips/pci/pci-xlr.c
@@ -292,7 +292,7 @@ int pcibios_plat_dev_init(struct pci_dev *dev)
292static int __init pcibios_init(void) 292static int __init pcibios_init(void)
293{ 293{
294 /* PSB assigns PCI resources */ 294 /* PSB assigns PCI resources */
295 pci_probe_only = 1; 295 pci_set_flags(PCI_PROBE_ONLY);
296 pci_config_base = ioremap(DEFAULT_PCI_CONFIG_BASE, 16 << 20); 296 pci_config_base = ioremap(DEFAULT_PCI_CONFIG_BASE, 16 << 20);
297 297
298 /* Extend IO port for memory mapped io */ 298 /* Extend IO port for memory mapped io */
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c
index 15521505ebe..0514866fa92 100644
--- a/arch/mips/pci/pci.c
+++ b/arch/mips/pci/pci.c
@@ -20,16 +20,9 @@
20#include <asm/cpu-info.h> 20#include <asm/cpu-info.h>
21 21
22/* 22/*
23 * Indicate whether we respect the PCI setup left by the firmware. 23 * If PCI_PROBE_ONLY in pci_flags is set, we don't change any PCI resource
24 * 24 * assignments.
25 * Make this long-lived so that we know when shutting down
26 * whether we probed only or not.
27 */ 25 */
28int pci_probe_only;
29
30#define PCI_ASSIGN_ALL_BUSSES 1
31
32unsigned int pci_probe = PCI_ASSIGN_ALL_BUSSES;
33 26
34/* 27/*
35 * The PCI controller list. 28 * The PCI controller list.
@@ -92,11 +85,12 @@ static void __devinit pcibios_scanbus(struct pci_controller *hose)
92 if (!hose->iommu) 85 if (!hose->iommu)
93 PCI_DMA_BUS_IS_PHYS = 1; 86 PCI_DMA_BUS_IS_PHYS = 1;
94 87
95 if (hose->get_busno && pci_probe_only) 88 if (hose->get_busno && pci_has_flag(PCI_PROBE_ONLY))
96 next_busno = (*hose->get_busno)(); 89 next_busno = (*hose->get_busno)();
97 90
98 pci_add_resource(&resources, hose->mem_resource); 91 pci_add_resource_offset(&resources,
99 pci_add_resource(&resources, hose->io_resource); 92 hose->mem_resource, hose->mem_offset);
93 pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset);
100 bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose, 94 bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
101 &resources); 95 &resources);
102 if (!bus) 96 if (!bus)
@@ -115,7 +109,7 @@ static void __devinit pcibios_scanbus(struct pci_controller *hose)
115 need_domain_info = 1; 109 need_domain_info = 1;
116 } 110 }
117 111
118 if (!pci_probe_only) { 112 if (!pci_has_flag(PCI_PROBE_ONLY)) {
119 pci_bus_size_bridges(bus); 113 pci_bus_size_bridges(bus);
120 pci_bus_assign_resources(bus); 114 pci_bus_assign_resources(bus);
121 pci_enable_bridges(bus); 115 pci_enable_bridges(bus);
@@ -241,7 +235,7 @@ static int pcibios_enable_resources(struct pci_dev *dev, int mask)
241 235
242unsigned int pcibios_assign_all_busses(void) 236unsigned int pcibios_assign_all_busses(void)
243{ 237{
244 return (pci_probe & PCI_ASSIGN_ALL_BUSSES) ? 1 : 0; 238 return 1;
245} 239}
246 240
247int pcibios_enable_device(struct pci_dev *dev, int mask) 241int pcibios_enable_device(struct pci_dev *dev, int mask)
@@ -254,42 +248,13 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
254 return pcibios_plat_dev_init(dev); 248 return pcibios_plat_dev_init(dev);
255} 249}
256 250
257static void pcibios_fixup_device_resources(struct pci_dev *dev,
258 struct pci_bus *bus)
259{
260 /* Update device resources. */
261 struct pci_controller *hose = (struct pci_controller *)bus->sysdata;
262 unsigned long offset = 0;
263 int i;
264
265 for (i = 0; i < PCI_NUM_RESOURCES; i++) {
266 if (!dev->resource[i].start)
267 continue;
268 if (dev->resource[i].flags & IORESOURCE_IO)
269 offset = hose->io_offset;
270 else if (dev->resource[i].flags & IORESOURCE_MEM)
271 offset = hose->mem_offset;
272
273 dev->resource[i].start += offset;
274 dev->resource[i].end += offset;
275 }
276}
277
278void __devinit pcibios_fixup_bus(struct pci_bus *bus) 251void __devinit pcibios_fixup_bus(struct pci_bus *bus)
279{ 252{
280 /* Propagate hose info into the subordinate devices. */
281
282 struct pci_dev *dev = bus->self; 253 struct pci_dev *dev = bus->self;
283 254
284 if (pci_probe_only && dev && 255 if (pci_has_flag(PCI_PROBE_ONLY) && dev &&
285 (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) { 256 (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {
286 pci_read_bridge_bases(bus); 257 pci_read_bridge_bases(bus);
287 pcibios_fixup_device_resources(dev, bus);
288 }
289
290 list_for_each_entry(dev, &bus->devices, bus_list) {
291 if ((dev->class >> 8) != PCI_CLASS_BRIDGE_PCI)
292 pcibios_fixup_device_resources(dev, bus);
293 } 258 }
294} 259}
295 260
@@ -299,40 +264,7 @@ pcibios_update_irq(struct pci_dev *dev, int irq)
299 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); 264 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
300} 265}
301 266
302void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
303 struct resource *res)
304{
305 struct pci_controller *hose = (struct pci_controller *)dev->sysdata;
306 unsigned long offset = 0;
307
308 if (res->flags & IORESOURCE_IO)
309 offset = hose->io_offset;
310 else if (res->flags & IORESOURCE_MEM)
311 offset = hose->mem_offset;
312
313 region->start = res->start - offset;
314 region->end = res->end - offset;
315}
316
317void __devinit
318pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
319 struct pci_bus_region *region)
320{
321 struct pci_controller *hose = (struct pci_controller *)dev->sysdata;
322 unsigned long offset = 0;
323
324 if (res->flags & IORESOURCE_IO)
325 offset = hose->io_offset;
326 else if (res->flags & IORESOURCE_MEM)
327 offset = hose->mem_offset;
328
329 res->start = region->start + offset;
330 res->end = region->end + offset;
331}
332
333#ifdef CONFIG_HOTPLUG 267#ifdef CONFIG_HOTPLUG
334EXPORT_SYMBOL(pcibios_resource_to_bus);
335EXPORT_SYMBOL(pcibios_bus_to_resource);
336EXPORT_SYMBOL(PCIBIOS_MIN_IO); 268EXPORT_SYMBOL(PCIBIOS_MIN_IO);
337EXPORT_SYMBOL(PCIBIOS_MIN_MEM); 269EXPORT_SYMBOL(PCIBIOS_MIN_MEM);
338#endif 270#endif
diff --git a/arch/mn10300/Kconfig b/arch/mn10300/Kconfig
index 8f1c40d5817..3aa3de01715 100644
--- a/arch/mn10300/Kconfig
+++ b/arch/mn10300/Kconfig
@@ -5,6 +5,7 @@ config MN10300
5 select GENERIC_IRQ_SHOW 5 select GENERIC_IRQ_SHOW
6 select HAVE_ARCH_TRACEHOOK 6 select HAVE_ARCH_TRACEHOOK
7 select HAVE_ARCH_KGDB 7 select HAVE_ARCH_KGDB
8 select HAVE_NMI_WATCHDOG if MN10300_WD_TIMER
8 9
9config AM33_2 10config AM33_2
10 def_bool n 11 def_bool n
diff --git a/arch/mn10300/include/asm/pci.h b/arch/mn10300/include/asm/pci.h
index 6095a28561d..8137c25c4e1 100644
--- a/arch/mn10300/include/asm/pci.h
+++ b/arch/mn10300/include/asm/pci.h
@@ -85,22 +85,6 @@ extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
85/* implement the pci_ DMA API in terms of the generic device dma_ one */ 85/* implement the pci_ DMA API in terms of the generic device dma_ one */
86#include <asm-generic/pci-dma-compat.h> 86#include <asm-generic/pci-dma-compat.h>
87 87
88/**
89 * pcibios_resource_to_bus - convert resource to PCI bus address
90 * @dev: device which owns this resource
91 * @region: converted bus-centric region (start,end)
92 * @res: resource to convert
93 *
94 * Convert a resource to a PCI device bus address or bus window.
95 */
96extern void pcibios_resource_to_bus(struct pci_dev *dev,
97 struct pci_bus_region *region,
98 struct resource *res);
99
100extern void pcibios_bus_to_resource(struct pci_dev *dev,
101 struct resource *res,
102 struct pci_bus_region *region);
103
104static inline struct resource * 88static inline struct resource *
105pcibios_select_root(struct pci_dev *pdev, struct resource *res) 89pcibios_select_root(struct pci_dev *pdev, struct resource *res)
106{ 90{
diff --git a/arch/mn10300/include/asm/reset-regs.h b/arch/mn10300/include/asm/reset-regs.h
index 10c7502a113..8ca2a42d365 100644
--- a/arch/mn10300/include/asm/reset-regs.h
+++ b/arch/mn10300/include/asm/reset-regs.h
@@ -17,10 +17,6 @@
17 17
18#ifdef __KERNEL__ 18#ifdef __KERNEL__
19 19
20#ifdef CONFIG_MN10300_WD_TIMER
21#define ARCH_HAS_NMI_WATCHDOG /* See include/linux/nmi.h */
22#endif
23
24/* 20/*
25 * watchdog timer registers 21 * watchdog timer registers
26 */ 22 */
diff --git a/arch/mn10300/unit-asb2305/pci.c b/arch/mn10300/unit-asb2305/pci.c
index a7c5f08ca9f..6dce9fc2cf3 100644
--- a/arch/mn10300/unit-asb2305/pci.c
+++ b/arch/mn10300/unit-asb2305/pci.c
@@ -32,8 +32,7 @@ struct pci_ops *pci_root_ops;
32 * insert specific PCI bus resources instead of using the platform-level bus 32 * insert specific PCI bus resources instead of using the platform-level bus
33 * resources directly for the PCI root bus. 33 * resources directly for the PCI root bus.
34 * 34 *
35 * These are configured and inserted by pcibios_init() and are attached to the 35 * These are configured and inserted by pcibios_init().
36 * root bus by pcibios_fixup_bus().
37 */ 36 */
38static struct resource pci_ioport_resource = { 37static struct resource pci_ioport_resource = {
39 .name = "PCI IO", 38 .name = "PCI IO",
@@ -78,52 +77,6 @@ static inline int __query(const struct pci_bus *bus, unsigned int devfn)
78} 77}
79 78
80/* 79/*
81 * translate Linuxcentric addresses to PCI bus addresses
82 */
83void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
84 struct resource *res)
85{
86 if (res->flags & IORESOURCE_IO) {
87 region->start = (res->start & 0x00ffffff);
88 region->end = (res->end & 0x00ffffff);
89 }
90
91 if (res->flags & IORESOURCE_MEM) {
92 region->start = (res->start & 0x03ffffff) | MEM_PAGING_REG;
93 region->end = (res->end & 0x03ffffff) | MEM_PAGING_REG;
94 }
95
96#if 0
97 printk(KERN_DEBUG "RES->BUS: %lx-%lx => %lx-%lx\n",
98 res->start, res->end, region->start, region->end);
99#endif
100}
101EXPORT_SYMBOL(pcibios_resource_to_bus);
102
103/*
104 * translate PCI bus addresses to Linuxcentric addresses
105 */
106void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
107 struct pci_bus_region *region)
108{
109 if (res->flags & IORESOURCE_IO) {
110 res->start = (region->start & 0x00ffffff) | 0xbe000000;
111 res->end = (region->end & 0x00ffffff) | 0xbe000000;
112 }
113
114 if (res->flags & IORESOURCE_MEM) {
115 res->start = (region->start & 0x03ffffff) | 0xb8000000;
116 res->end = (region->end & 0x03ffffff) | 0xb8000000;
117 }
118
119#if 0
120 printk(KERN_INFO "BUS->RES: %lx-%lx => %lx-%lx\n",
121 region->start, region->end, res->start, res->end);
122#endif
123}
124EXPORT_SYMBOL(pcibios_bus_to_resource);
125
126/*
127 * 80 *
128 */ 81 */
129static int pci_ampci_read_config_byte(struct pci_bus *bus, unsigned int devfn, 82static int pci_ampci_read_config_byte(struct pci_bus *bus, unsigned int devfn,
@@ -364,9 +317,6 @@ static void __devinit pcibios_fixup_device_resources(struct pci_dev *dev)
364 if (!dev->resource[i].flags) 317 if (!dev->resource[i].flags)
365 continue; 318 continue;
366 319
367 region.start = dev->resource[i].start;
368 region.end = dev->resource[i].end;
369 pcibios_bus_to_resource(dev, &dev->resource[i], &region);
370 if (is_valid_resource(dev, i)) 320 if (is_valid_resource(dev, i))
371 pci_claim_resource(dev, i); 321 pci_claim_resource(dev, i);
372 } 322 }
@@ -397,6 +347,7 @@ void __devinit pcibios_fixup_bus(struct pci_bus *bus)
397 */ 347 */
398static int __init pcibios_init(void) 348static int __init pcibios_init(void)
399{ 349{
350 resource_size_t io_offset, mem_offset;
400 LIST_HEAD(resources); 351 LIST_HEAD(resources);
401 352
402 ioport_resource.start = 0xA0000000; 353 ioport_resource.start = 0xA0000000;
@@ -420,8 +371,13 @@ static int __init pcibios_init(void)
420 printk(KERN_INFO "PCI: Probing PCI hardware [mempage %08x]\n", 371 printk(KERN_INFO "PCI: Probing PCI hardware [mempage %08x]\n",
421 MEM_PAGING_REG); 372 MEM_PAGING_REG);
422 373
423 pci_add_resource(&resources, &pci_ioport_resource); 374 io_offset = pci_ioport_resource.start -
424 pci_add_resource(&resources, &pci_iomem_resource); 375 (pci_ioport_resource.start & 0x00ffffff);
376 mem_offset = pci_iomem_resource.start -
377 ((pci_iomem_resource.start & 0x03ffffff) | MEM_PAGING_REG);
378
379 pci_add_resource_offset(&resources, &pci_ioport_resource, io_offset);
380 pci_add_resource_offset(&resources, &pci_iomem_resource, mem_offset);
425 pci_root_bus = pci_scan_root_bus(NULL, 0, &pci_direct_ampci, NULL, 381 pci_root_bus = pci_scan_root_bus(NULL, 0, &pci_direct_ampci, NULL,
426 &resources); 382 &resources);
427 383
diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
index bc428b5f126..a4787197d8f 100644
--- a/arch/openrisc/Kconfig
+++ b/arch/openrisc/Kconfig
@@ -16,6 +16,7 @@ config OPENRISC
16 select GENERIC_IRQ_SHOW 16 select GENERIC_IRQ_SHOW
17 select GENERIC_IOMAP 17 select GENERIC_IOMAP
18 select GENERIC_CPU_DEVICES 18 select GENERIC_CPU_DEVICES
19 select GENERIC_ATOMIC64
19 20
20config MMU 21config MMU
21 def_bool y 22 def_bool y
diff --git a/arch/openrisc/include/asm/page.h b/arch/openrisc/include/asm/page.h
index b041b344b22..108906f991d 100644
--- a/arch/openrisc/include/asm/page.h
+++ b/arch/openrisc/include/asm/page.h
@@ -71,9 +71,6 @@ typedef struct page *pgtable_t;
71#define __pgd(x) ((pgd_t) { (x) }) 71#define __pgd(x) ((pgd_t) { (x) })
72#define __pgprot(x) ((pgprot_t) { (x) }) 72#define __pgprot(x) ((pgprot_t) { (x) })
73 73
74extern unsigned long memory_start;
75extern unsigned long memory_end;
76
77#endif /* !__ASSEMBLY__ */ 74#endif /* !__ASSEMBLY__ */
78 75
79 76
@@ -94,8 +91,7 @@ extern unsigned long memory_end;
94 91
95#define pfn_valid(pfn) ((pfn) < max_mapnr) 92#define pfn_valid(pfn) ((pfn) < max_mapnr)
96 93
97#define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \ 94#define virt_addr_valid(kaddr) (pfn_valid(virt_to_pfn(kaddr)))
98 ((void *)(kaddr) < (void *)memory_end))
99 95
100#endif /* __ASSEMBLY__ */ 96#endif /* __ASSEMBLY__ */
101 97
diff --git a/arch/openrisc/include/asm/pgtable.h b/arch/openrisc/include/asm/pgtable.h
index 043505d7f68..14c900cfd30 100644
--- a/arch/openrisc/include/asm/pgtable.h
+++ b/arch/openrisc/include/asm/pgtable.h
@@ -455,7 +455,6 @@ static inline void update_mmu_cache(struct vm_area_struct *vma,
455 * No page table caches to initialise 455 * No page table caches to initialise
456 */ 456 */
457#define pgtable_cache_init() do { } while (0) 457#define pgtable_cache_init() do { } while (0)
458#define io_remap_page_range remap_page_range
459 458
460typedef pte_t *pte_addr_t; 459typedef pte_t *pte_addr_t;
461 460
diff --git a/arch/openrisc/include/asm/processor.h b/arch/openrisc/include/asm/processor.h
index bb54c97b978..f7516fa78b5 100644
--- a/arch/openrisc/include/asm/processor.h
+++ b/arch/openrisc/include/asm/processor.h
@@ -81,8 +81,8 @@ extern inline void prepare_to_copy(struct task_struct *tsk)
81#define INIT_THREAD { } 81#define INIT_THREAD { }
82 82
83 83
84#define KSTK_EIP(tsk) (task_pt_regs(tsk)->pc); 84#define KSTK_EIP(tsk) (task_pt_regs(tsk)->pc)
85#define KSTK_ESP(tsk) (task_pt_regs(tsk)->sp); 85#define KSTK_ESP(tsk) (task_pt_regs(tsk)->sp)
86 86
87 87
88extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags); 88extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
diff --git a/arch/openrisc/include/asm/ptrace.h b/arch/openrisc/include/asm/ptrace.h
index e612ce4512c..4651a737591 100644
--- a/arch/openrisc/include/asm/ptrace.h
+++ b/arch/openrisc/include/asm/ptrace.h
@@ -73,9 +73,13 @@ struct pt_regs {
73 }; 73 };
74 }; 74 };
75 long pc; 75 long pc;
76 /* For restarting system calls:
77 * Set to syscall number for syscall exceptions,
78 * -1 for all other exceptions.
79 */
76 long orig_gpr11; /* For restarting system calls */ 80 long orig_gpr11; /* For restarting system calls */
77 long syscallno; /* Syscall number (used by strace) */
78 long dummy; /* Cheap alignment fix */ 81 long dummy; /* Cheap alignment fix */
82 long dummy2; /* Cheap alignment fix */
79}; 83};
80 84
81/* TODO: Rename this to REDZONE because that's what it is */ 85/* TODO: Rename this to REDZONE because that's what it is */
diff --git a/arch/openrisc/include/asm/syscall.h b/arch/openrisc/include/asm/syscall.h
index 9f0337055d2..b752bb67891 100644
--- a/arch/openrisc/include/asm/syscall.h
+++ b/arch/openrisc/include/asm/syscall.h
@@ -25,7 +25,7 @@
25static inline int 25static inline int
26syscall_get_nr(struct task_struct *task, struct pt_regs *regs) 26syscall_get_nr(struct task_struct *task, struct pt_regs *regs)
27{ 27{
28 return regs->syscallno ? regs->syscallno : -1; 28 return regs->orig_gpr11;
29} 29}
30 30
31static inline void 31static inline void
@@ -50,10 +50,7 @@ static inline void
50syscall_set_return_value(struct task_struct *task, struct pt_regs *regs, 50syscall_set_return_value(struct task_struct *task, struct pt_regs *regs,
51 int error, long val) 51 int error, long val)
52{ 52{
53 if (error) 53 regs->gpr[11] = (long) error ?: val;
54 regs->gpr[11] = -error;
55 else
56 regs->gpr[11] = val;
57} 54}
58 55
59static inline void 56static inline void
diff --git a/arch/openrisc/include/asm/uaccess.h b/arch/openrisc/include/asm/uaccess.h
index c310e45b538..f5abaa0ffc3 100644
--- a/arch/openrisc/include/asm/uaccess.h
+++ b/arch/openrisc/include/asm/uaccess.h
@@ -26,7 +26,6 @@
26#include <linux/thread_info.h> 26#include <linux/thread_info.h>
27#include <linux/prefetch.h> 27#include <linux/prefetch.h>
28#include <linux/string.h> 28#include <linux/string.h>
29#include <linux/thread_info.h>
30#include <asm/page.h> 29#include <asm/page.h>
31 30
32#define VERIFY_READ 0 31#define VERIFY_READ 0
diff --git a/arch/openrisc/kernel/entry.S b/arch/openrisc/kernel/entry.S
index d5f9c35a583..6e61af8682b 100644
--- a/arch/openrisc/kernel/entry.S
+++ b/arch/openrisc/kernel/entry.S
@@ -95,7 +95,6 @@ handler: ;\
95 /* r1, EPCR, ESR a already saved */ ;\ 95 /* r1, EPCR, ESR a already saved */ ;\
96 l.sw PT_GPR2(r1),r2 ;\ 96 l.sw PT_GPR2(r1),r2 ;\
97 l.sw PT_GPR3(r1),r3 ;\ 97 l.sw PT_GPR3(r1),r3 ;\
98 l.sw PT_ORIG_GPR11(r1),r11 ;\
99 /* r4 already save */ ;\ 98 /* r4 already save */ ;\
100 l.sw PT_GPR5(r1),r5 ;\ 99 l.sw PT_GPR5(r1),r5 ;\
101 l.sw PT_GPR6(r1),r6 ;\ 100 l.sw PT_GPR6(r1),r6 ;\
@@ -125,7 +124,9 @@ handler: ;\
125 /* r30 already save */ ;\ 124 /* r30 already save */ ;\
126/* l.sw PT_GPR30(r1),r30*/ ;\ 125/* l.sw PT_GPR30(r1),r30*/ ;\
127 l.sw PT_GPR31(r1),r31 ;\ 126 l.sw PT_GPR31(r1),r31 ;\
128 l.sw PT_SYSCALLNO(r1),r0 127 /* Store -1 in orig_gpr11 for non-syscall exceptions */ ;\
128 l.addi r30,r0,-1 ;\
129 l.sw PT_ORIG_GPR11(r1),r30
129 130
130#define UNHANDLED_EXCEPTION(handler,vector) \ 131#define UNHANDLED_EXCEPTION(handler,vector) \
131 .global handler ;\ 132 .global handler ;\
@@ -133,7 +134,6 @@ handler: ;\
133 /* r1, EPCR, ESR already saved */ ;\ 134 /* r1, EPCR, ESR already saved */ ;\
134 l.sw PT_GPR2(r1),r2 ;\ 135 l.sw PT_GPR2(r1),r2 ;\
135 l.sw PT_GPR3(r1),r3 ;\ 136 l.sw PT_GPR3(r1),r3 ;\
136 l.sw PT_ORIG_GPR11(r1),r11 ;\
137 l.sw PT_GPR5(r1),r5 ;\ 137 l.sw PT_GPR5(r1),r5 ;\
138 l.sw PT_GPR6(r1),r6 ;\ 138 l.sw PT_GPR6(r1),r6 ;\
139 l.sw PT_GPR7(r1),r7 ;\ 139 l.sw PT_GPR7(r1),r7 ;\
@@ -162,7 +162,9 @@ handler: ;\
162 /* r31 already saved */ ;\ 162 /* r31 already saved */ ;\
163 l.sw PT_GPR30(r1),r30 ;\ 163 l.sw PT_GPR30(r1),r30 ;\
164/* l.sw PT_GPR31(r1),r31 */ ;\ 164/* l.sw PT_GPR31(r1),r31 */ ;\
165 l.sw PT_SYSCALLNO(r1),r0 ;\ 165 /* Store -1 in orig_gpr11 for non-syscall exceptions */ ;\
166 l.addi r30,r0,-1 ;\
167 l.sw PT_ORIG_GPR11(r1),r30 ;\
166 l.addi r3,r1,0 ;\ 168 l.addi r3,r1,0 ;\
167 /* r4 is exception EA */ ;\ 169 /* r4 is exception EA */ ;\
168 l.addi r5,r0,vector ;\ 170 l.addi r5,r0,vector ;\
@@ -554,6 +556,7 @@ ENTRY(_sys_call_handler)
554 l.sw PT_GPR9(r1),r9 556 l.sw PT_GPR9(r1),r9
555 /* r10 already saved */ 557 /* r10 already saved */
556 l.sw PT_GPR11(r1),r11 558 l.sw PT_GPR11(r1),r11
559 /* orig_gpr11 must be set for syscalls */
557 l.sw PT_ORIG_GPR11(r1),r11 560 l.sw PT_ORIG_GPR11(r1),r11
558 /* r12,r13 already saved */ 561 /* r12,r13 already saved */
559 562
@@ -567,9 +570,6 @@ ENTRY(_sys_call_handler)
567 /* r30 is the only register we clobber in the fast path */ 570 /* r30 is the only register we clobber in the fast path */
568 /* r30 already saved */ 571 /* r30 already saved */
569/* l.sw PT_GPR30(r1),r30 */ 572/* l.sw PT_GPR30(r1),r30 */
570 /* This is used by do_signal to determine whether to check for
571 * syscall restart or not */
572 l.sw PT_SYSCALLNO(r1),r11
573 573
574_syscall_check_trace_enter: 574_syscall_check_trace_enter:
575 /* If TIF_SYSCALL_TRACE is set, then we want to do syscall tracing */ 575 /* If TIF_SYSCALL_TRACE is set, then we want to do syscall tracing */
@@ -731,7 +731,7 @@ _syscall_trace_enter:
731 * so that we can do the syscall for real and return to the syscall 731 * so that we can do the syscall for real and return to the syscall
732 * hot path. 732 * hot path.
733 */ 733 */
734 l.lwz r11,PT_SYSCALLNO(r1) 734 l.lwz r11,PT_GPR11(r1)
735 l.lwz r3,PT_GPR3(r1) 735 l.lwz r3,PT_GPR3(r1)
736 l.lwz r4,PT_GPR4(r1) 736 l.lwz r4,PT_GPR4(r1)
737 l.lwz r5,PT_GPR5(r1) 737 l.lwz r5,PT_GPR5(r1)
diff --git a/arch/openrisc/kernel/head.S b/arch/openrisc/kernel/head.S
index c75018d2264..1088b5fca3b 100644
--- a/arch/openrisc/kernel/head.S
+++ b/arch/openrisc/kernel/head.S
@@ -26,6 +26,7 @@
26#include <asm/cache.h> 26#include <asm/cache.h>
27#include <asm/spr_defs.h> 27#include <asm/spr_defs.h>
28#include <asm/asm-offsets.h> 28#include <asm/asm-offsets.h>
29#include <linux/of_fdt.h>
29 30
30#define tophys(rd,rs) \ 31#define tophys(rd,rs) \
31 l.movhi rd,hi(-KERNELBASE) ;\ 32 l.movhi rd,hi(-KERNELBASE) ;\
@@ -440,6 +441,9 @@ _dispatch_do_ipage_fault:
440 __HEAD 441 __HEAD
441 .global _start 442 .global _start
442_start: 443_start:
444 /* save kernel parameters */
445 l.or r25,r0,r3 /* pointer to fdt */
446
443 /* 447 /*
444 * ensure a deterministic start 448 * ensure a deterministic start
445 */ 449 */
@@ -471,7 +475,6 @@ _start:
471 CLEAR_GPR(r22) 475 CLEAR_GPR(r22)
472 CLEAR_GPR(r23) 476 CLEAR_GPR(r23)
473 CLEAR_GPR(r24) 477 CLEAR_GPR(r24)
474 CLEAR_GPR(r25)
475 CLEAR_GPR(r26) 478 CLEAR_GPR(r26)
476 CLEAR_GPR(r27) 479 CLEAR_GPR(r27)
477 CLEAR_GPR(r28) 480 CLEAR_GPR(r28)
@@ -565,6 +568,18 @@ enable_mmu:
565 // reset the simulation counters 568 // reset the simulation counters
566 l.nop 5 569 l.nop 5
567 570
571 /* check fdt header magic word */
572 l.lwz r3,0(r25) /* load magic from fdt into r3 */
573 l.movhi r4,hi(OF_DT_HEADER)
574 l.ori r4,r4,lo(OF_DT_HEADER)
575 l.sfeq r3,r4
576 l.bf _fdt_found
577 l.nop
578 /* magic number mismatch, set fdt pointer to null */
579 l.or r25,r0,r0
580_fdt_found:
581 /* pass fdt pointer to or32_early_setup in r3 */
582 l.or r3,r0,r25
568 LOAD_SYMBOL_2_GPR(r24, or32_early_setup) 583 LOAD_SYMBOL_2_GPR(r24, or32_early_setup)
569 l.jalr r24 584 l.jalr r24
570 l.nop 585 l.nop
diff --git a/arch/openrisc/kernel/ptrace.c b/arch/openrisc/kernel/ptrace.c
index 967d499da68..e71781d24b0 100644
--- a/arch/openrisc/kernel/ptrace.c
+++ b/arch/openrisc/kernel/ptrace.c
@@ -187,11 +187,11 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
187 */ 187 */
188 ret = -1L; 188 ret = -1L;
189 189
190 audit_syscall_entry(audit_arch(), regs->syscallno, 190 audit_syscall_entry(audit_arch(), regs->gpr[11],
191 regs->gpr[3], regs->gpr[4], 191 regs->gpr[3], regs->gpr[4],
192 regs->gpr[5], regs->gpr[6]); 192 regs->gpr[5], regs->gpr[6]);
193 193
194 return ret ? : regs->syscallno; 194 return ret ? : regs->gpr[11];
195} 195}
196 196
197asmlinkage void do_syscall_trace_leave(struct pt_regs *regs) 197asmlinkage void do_syscall_trace_leave(struct pt_regs *regs)
diff --git a/arch/openrisc/kernel/setup.c b/arch/openrisc/kernel/setup.c
index ad2c290f239..f4d5bedc3b4 100644
--- a/arch/openrisc/kernel/setup.c
+++ b/arch/openrisc/kernel/setup.c
@@ -206,18 +206,18 @@ void __init setup_cpuinfo(void)
206 * Handles the pointer to the device tree that this kernel is to use 206 * Handles the pointer to the device tree that this kernel is to use
207 * for establishing the available platform devices. 207 * for establishing the available platform devices.
208 * 208 *
209 * For now, this is limited to using the built-in device tree. In the future, 209 * Falls back on built-in device tree in case null pointer is passed.
210 * it is intended that this function will take a pointer to the device tree
211 * that is potentially built-in, but potentially also passed in by the
212 * bootloader, or discovered by some equally clever means...
213 */ 210 */
214 211
215void __init or32_early_setup(void) 212void __init or32_early_setup(unsigned int fdt)
216{ 213{
217 214 if (fdt) {
218 early_init_devtree(__dtb_start); 215 early_init_devtree((void*) fdt);
219 216 printk(KERN_INFO "FDT at 0x%08x\n", fdt);
220 printk(KERN_INFO "Compiled-in FDT at 0x%p\n", __dtb_start); 217 } else {
218 early_init_devtree(__dtb_start);
219 printk(KERN_INFO "Compiled-in FDT at %p\n", __dtb_start);
220 }
221} 221}
222 222
223static int __init openrisc_device_probe(void) 223static int __init openrisc_device_probe(void)
diff --git a/arch/openrisc/kernel/signal.c b/arch/openrisc/kernel/signal.c
index 95207ab0c99..e970743251a 100644
--- a/arch/openrisc/kernel/signal.c
+++ b/arch/openrisc/kernel/signal.c
@@ -102,10 +102,7 @@ asmlinkage long _sys_rt_sigreturn(struct pt_regs *regs)
102 goto badframe; 102 goto badframe;
103 103
104 sigdelsetmask(&set, ~_BLOCKABLE); 104 sigdelsetmask(&set, ~_BLOCKABLE);
105 spin_lock_irq(&current->sighand->siglock); 105 set_current_blocked(&set);
106 current->blocked = set;
107 recalc_sigpending();
108 spin_unlock_irq(&current->sighand->siglock);
109 106
110 if (restore_sigcontext(regs, &frame->uc.uc_mcontext)) 107 if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
111 goto badframe; 108 goto badframe;
@@ -189,8 +186,8 @@ static inline void __user *get_sigframe(struct k_sigaction *ka,
189 * trampoline which performs the syscall sigreturn, or a provided 186 * trampoline which performs the syscall sigreturn, or a provided
190 * user-mode trampoline. 187 * user-mode trampoline.
191 */ 188 */
192static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, 189static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
193 sigset_t *set, struct pt_regs *regs) 190 sigset_t *set, struct pt_regs *regs)
194{ 191{
195 struct rt_sigframe *frame; 192 struct rt_sigframe *frame;
196 unsigned long return_ip; 193 unsigned long return_ip;
@@ -247,31 +244,27 @@ static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
247 /* actually move the usp to reflect the stacked frame */ 244 /* actually move the usp to reflect the stacked frame */
248 regs->sp = (unsigned long)frame; 245 regs->sp = (unsigned long)frame;
249 246
250 return; 247 return 0;
251 248
252give_sigsegv: 249give_sigsegv:
253 if (sig == SIGSEGV) 250 force_sigsegv(sig, current);
254 ka->sa.sa_handler = SIG_DFL; 251 return -EFAULT;
255 force_sig(SIGSEGV, current);
256} 252}
257 253
258static inline void 254static inline int
259handle_signal(unsigned long sig, 255handle_signal(unsigned long sig,
260 siginfo_t *info, struct k_sigaction *ka, 256 siginfo_t *info, struct k_sigaction *ka,
261 sigset_t *oldset, struct pt_regs *regs) 257 sigset_t *oldset, struct pt_regs *regs)
262{ 258{
263 setup_rt_frame(sig, ka, info, oldset, regs); 259 int ret;
264 260
265 if (ka->sa.sa_flags & SA_ONESHOT) 261 ret = setup_rt_frame(sig, ka, info, oldset, regs);
266 ka->sa.sa_handler = SIG_DFL; 262 if (ret)
263 return ret;
267 264
268 spin_lock_irq(&current->sighand->siglock); 265 block_sigmask(ka, sig);
269 sigorsets(&current->blocked, &current->blocked, &ka->sa.sa_mask);
270 if (!(ka->sa.sa_flags & SA_NODEFER))
271 sigaddset(&current->blocked, sig);
272 recalc_sigpending();
273 266
274 spin_unlock_irq(&current->sighand->siglock); 267 return 0;
275} 268}
276 269
277/* 270/*
@@ -312,7 +305,7 @@ void do_signal(struct pt_regs *regs)
312 * below mean that the syscall executed to completion and no 305 * below mean that the syscall executed to completion and no
313 * restart is necessary. 306 * restart is necessary.
314 */ 307 */
315 if (regs->syscallno) { 308 if (regs->orig_gpr11) {
316 int restart = 0; 309 int restart = 0;
317 310
318 switch (regs->gpr[11]) { 311 switch (regs->gpr[11]) {
@@ -360,13 +353,13 @@ void do_signal(struct pt_regs *regs)
360 oldset = &current->blocked; 353 oldset = &current->blocked;
361 354
362 /* Whee! Actually deliver the signal. */ 355 /* Whee! Actually deliver the signal. */
363 handle_signal(signr, &info, &ka, oldset, regs); 356 if (!handle_signal(signr, &info, &ka, oldset, regs)) {
364 /* a signal was successfully delivered; the saved 357 /* a signal was successfully delivered; the saved
365 * sigmask will have been stored in the signal frame, 358 * sigmask will have been stored in the signal frame,
366 * and will be restored by sigreturn, so we can simply 359 * and will be restored by sigreturn, so we can simply
367 * clear the TIF_RESTORE_SIGMASK flag */ 360 * clear the TIF_RESTORE_SIGMASK flag */
368 if (test_thread_flag(TIF_RESTORE_SIGMASK))
369 clear_thread_flag(TIF_RESTORE_SIGMASK); 361 clear_thread_flag(TIF_RESTORE_SIGMASK);
362 }
370 363
371 tracehook_signal_handler(signr, &info, &ka, regs, 364 tracehook_signal_handler(signr, &info, &ka, regs,
372 test_thread_flag(TIF_SINGLESTEP)); 365 test_thread_flag(TIF_SINGLESTEP));
diff --git a/arch/openrisc/kernel/time.c b/arch/openrisc/kernel/time.c
index bd946ef1623..7c52e9494a8 100644
--- a/arch/openrisc/kernel/time.c
+++ b/arch/openrisc/kernel/time.c
@@ -125,16 +125,13 @@ irqreturn_t __irq_entry timer_interrupt(struct pt_regs *regs)
125 125
126static __init void openrisc_clockevent_init(void) 126static __init void openrisc_clockevent_init(void)
127{ 127{
128 clockevents_calc_mult_shift(&clockevent_openrisc_timer, 128 clockevent_openrisc_timer.cpumask = cpumask_of(0);
129 cpuinfo.clock_frequency, 4);
130 129
131 /* We only have 28 bits */ 130 /* We only have 28 bits */
132 clockevent_openrisc_timer.max_delta_ns = 131 clockevents_config_and_register(&clockevent_openrisc_timer,
133 clockevent_delta2ns((u32) 0x0fffffff, &clockevent_openrisc_timer); 132 cpuinfo.clock_frequency,
134 clockevent_openrisc_timer.min_delta_ns = 133 100, 0x0fffffff);
135 clockevent_delta2ns(1, &clockevent_openrisc_timer); 134
136 clockevent_openrisc_timer.cpumask = cpumask_of(0);
137 clockevents_register_device(&clockevent_openrisc_timer);
138} 135}
139 136
140/** 137/**
diff --git a/arch/openrisc/kernel/traps.c b/arch/openrisc/kernel/traps.c
index 52ca32b5b65..5cce396016d 100644
--- a/arch/openrisc/kernel/traps.c
+++ b/arch/openrisc/kernel/traps.c
@@ -114,6 +114,7 @@ void dump_stack(void)
114 114
115 show_stack(current, &stack); 115 show_stack(current, &stack);
116} 116}
117EXPORT_SYMBOL(dump_stack);
117 118
118void show_registers(struct pt_regs *regs) 119void show_registers(struct pt_regs *regs)
119{ 120{
@@ -144,8 +145,8 @@ void show_registers(struct pt_regs *regs)
144 regs->gpr[24], regs->gpr[25], regs->gpr[26], regs->gpr[27]); 145 regs->gpr[24], regs->gpr[25], regs->gpr[26], regs->gpr[27]);
145 printk("GPR28: %08lx GPR29: %08lx GPR30: %08lx GPR31: %08lx\n", 146 printk("GPR28: %08lx GPR29: %08lx GPR30: %08lx GPR31: %08lx\n",
146 regs->gpr[28], regs->gpr[29], regs->gpr[30], regs->gpr[31]); 147 regs->gpr[28], regs->gpr[29], regs->gpr[30], regs->gpr[31]);
147 printk(" RES: %08lx oGPR11: %08lx syscallno: %08lx\n", 148 printk(" RES: %08lx oGPR11: %08lx\n",
148 regs->gpr[11], regs->orig_gpr11, regs->syscallno); 149 regs->gpr[11], regs->orig_gpr11);
149 150
150 printk("Process %s (pid: %d, stackpage=%08lx)\n", 151 printk("Process %s (pid: %d, stackpage=%08lx)\n",
151 current->comm, current->pid, (unsigned long)current); 152 current->comm, current->pid, (unsigned long)current);
@@ -206,8 +207,8 @@ void nommu_dump_state(struct pt_regs *regs,
206 regs->gpr[24], regs->gpr[25], regs->gpr[26], regs->gpr[27]); 207 regs->gpr[24], regs->gpr[25], regs->gpr[26], regs->gpr[27]);
207 printk("GPR28: %08lx GPR29: %08lx GPR30: %08lx GPR31: %08lx\n", 208 printk("GPR28: %08lx GPR29: %08lx GPR30: %08lx GPR31: %08lx\n",
208 regs->gpr[28], regs->gpr[29], regs->gpr[30], regs->gpr[31]); 209 regs->gpr[28], regs->gpr[29], regs->gpr[30], regs->gpr[31]);
209 printk(" RES: %08lx oGPR11: %08lx syscallno: %08lx\n", 210 printk(" RES: %08lx oGPR11: %08lx\n",
210 regs->gpr[11], regs->orig_gpr11, regs->syscallno); 211 regs->gpr[11], regs->orig_gpr11);
211 212
212 printk("Process %s (pid: %d, stackpage=%08lx)\n", 213 printk("Process %s (pid: %d, stackpage=%08lx)\n",
213 ((struct task_struct *)(__pa(current)))->comm, 214 ((struct task_struct *)(__pa(current)))->comm,
diff --git a/arch/openrisc/mm/init.c b/arch/openrisc/mm/init.c
index 1cf3a8a3154..79dea9740a3 100644
--- a/arch/openrisc/mm/init.c
+++ b/arch/openrisc/mm/init.c
@@ -221,8 +221,7 @@ void __init mem_init(void)
221{ 221{
222 int codesize, reservedpages, datasize, initsize; 222 int codesize, reservedpages, datasize, initsize;
223 223
224 if (!mem_map) 224 BUG_ON(!mem_map);
225 BUG();
226 225
227 set_max_mapnr_init(); 226 set_max_mapnr_init();
228 227
diff --git a/arch/parisc/include/asm/mman.h b/arch/parisc/include/asm/mman.h
index f5b7bf5fba6..12219ebce86 100644
--- a/arch/parisc/include/asm/mman.h
+++ b/arch/parisc/include/asm/mman.h
@@ -62,6 +62,10 @@
62#define MADV_HUGEPAGE 67 /* Worth backing with hugepages */ 62#define MADV_HUGEPAGE 67 /* Worth backing with hugepages */
63#define MADV_NOHUGEPAGE 68 /* Not worth backing with hugepages */ 63#define MADV_NOHUGEPAGE 68 /* Not worth backing with hugepages */
64 64
65#define MADV_DONTDUMP 69 /* Explicity exclude from the core dump,
66 overrides the coredump filter bits */
67#define MADV_DODUMP 70 /* Clear the MADV_NODUMP flag */
68
65/* compatibility flags */ 69/* compatibility flags */
66#define MAP_FILE 0 70#define MAP_FILE 0
67#define MAP_VARIABLE 0 71#define MAP_VARIABLE 0
diff --git a/arch/parisc/include/asm/pci.h b/arch/parisc/include/asm/pci.h
index 2242a5c636c..3234f492d57 100644
--- a/arch/parisc/include/asm/pci.h
+++ b/arch/parisc/include/asm/pci.h
@@ -82,38 +82,8 @@ struct pci_hba_data {
82 82
83#ifdef CONFIG_64BIT 83#ifdef CONFIG_64BIT
84#define PCI_F_EXTEND 0xffffffff00000000UL 84#define PCI_F_EXTEND 0xffffffff00000000UL
85#define PCI_IS_LMMIO(hba,a) pci_is_lmmio(hba,a)
86
87/* We need to know if an address is LMMMIO or GMMIO.
88 * LMMIO requires mangling and GMMIO we must use as-is.
89 */
90static __inline__ int pci_is_lmmio(struct pci_hba_data *hba, unsigned long a)
91{
92 return(((a) & PCI_F_EXTEND) == PCI_F_EXTEND);
93}
94
95/*
96** Convert between PCI (IO_VIEW) addresses and processor (PA_VIEW) addresses.
97** See pci.c for more conversions used by Generic PCI code.
98**
99** Platform characteristics/firmware guarantee that
100** (1) PA_VIEW - IO_VIEW = lmmio_offset for both LMMIO and ELMMIO
101** (2) PA_VIEW == IO_VIEW for GMMIO
102*/
103#define PCI_BUS_ADDR(hba,a) (PCI_IS_LMMIO(hba,a) \
104 ? ((a) - hba->lmmio_space_offset) /* mangle LMMIO */ \
105 : (a)) /* GMMIO */
106#define PCI_HOST_ADDR(hba,a) (((a) & PCI_F_EXTEND) == 0 \
107 ? (a) + hba->lmmio_space_offset \
108 : (a))
109
110#else /* !CONFIG_64BIT */ 85#else /* !CONFIG_64BIT */
111
112#define PCI_BUS_ADDR(hba,a) (a)
113#define PCI_HOST_ADDR(hba,a) (a)
114#define PCI_F_EXTEND 0UL 86#define PCI_F_EXTEND 0UL
115#define PCI_IS_LMMIO(hba,a) (1) /* 32-bit doesn't support GMMIO */
116
117#endif /* !CONFIG_64BIT */ 87#endif /* !CONFIG_64BIT */
118 88
119/* 89/*
@@ -245,14 +215,6 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
245} 215}
246#endif 216#endif
247 217
248extern void
249pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
250 struct resource *res);
251
252extern void
253pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
254 struct pci_bus_region *region);
255
256static inline void pcibios_penalize_isa_irq(int irq, int active) 218static inline void pcibios_penalize_isa_irq(int irq, int active)
257{ 219{
258 /* We don't need to penalize isa irq's */ 220 /* We don't need to penalize isa irq's */
diff --git a/arch/parisc/kernel/pci.c b/arch/parisc/kernel/pci.c
index 4f0cf0c9b0a..24644aca10c 100644
--- a/arch/parisc/kernel/pci.c
+++ b/arch/parisc/kernel/pci.c
@@ -194,58 +194,6 @@ void __init pcibios_init_bus(struct pci_bus *bus)
194 pci_write_config_word(dev, PCI_BRIDGE_CONTROL, bridge_ctl); 194 pci_write_config_word(dev, PCI_BRIDGE_CONTROL, bridge_ctl);
195} 195}
196 196
197/* called by drivers/pci/setup-bus.c:pci_setup_bridge(). */
198void __devinit pcibios_resource_to_bus(struct pci_dev *dev,
199 struct pci_bus_region *region, struct resource *res)
200{
201#ifdef CONFIG_64BIT
202 struct pci_hba_data *hba = HBA_DATA(dev->bus->bridge->platform_data);
203#endif
204
205 if (res->flags & IORESOURCE_IO) {
206 /*
207 ** I/O space may see busnumbers here. Something
208 ** in the form of 0xbbxxxx where bb is the bus num
209 ** and xxxx is the I/O port space address.
210 ** Remaining address translation are done in the
211 ** PCI Host adapter specific code - ie dino_out8.
212 */
213 region->start = PCI_PORT_ADDR(res->start);
214 region->end = PCI_PORT_ADDR(res->end);
215 } else if (res->flags & IORESOURCE_MEM) {
216 /* Convert MMIO addr to PCI addr (undo global virtualization) */
217 region->start = PCI_BUS_ADDR(hba, res->start);
218 region->end = PCI_BUS_ADDR(hba, res->end);
219 }
220
221 DBG_RES("pcibios_resource_to_bus(%02x %s [%lx,%lx])\n",
222 dev->bus->number, res->flags & IORESOURCE_IO ? "IO" : "MEM",
223 region->start, region->end);
224}
225
226void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
227 struct pci_bus_region *region)
228{
229#ifdef CONFIG_64BIT
230 struct pci_hba_data *hba = HBA_DATA(dev->bus->bridge->platform_data);
231#endif
232
233 if (res->flags & IORESOURCE_MEM) {
234 res->start = PCI_HOST_ADDR(hba, region->start);
235 res->end = PCI_HOST_ADDR(hba, region->end);
236 }
237
238 if (res->flags & IORESOURCE_IO) {
239 res->start = region->start;
240 res->end = region->end;
241 }
242}
243
244#ifdef CONFIG_HOTPLUG
245EXPORT_SYMBOL(pcibios_resource_to_bus);
246EXPORT_SYMBOL(pcibios_bus_to_resource);
247#endif
248
249/* 197/*
250 * pcibios align resources() is called every time generic PCI code 198 * pcibios align resources() is called every time generic PCI code
251 * wants to generate a new address. The process of looking for 199 * wants to generate a new address. The process of looking for
diff --git a/arch/parisc/math-emu/fpudispatch.c b/arch/parisc/math-emu/fpudispatch.c
index 6e28f9f4c62..673b73e8420 100644
--- a/arch/parisc/math-emu/fpudispatch.c
+++ b/arch/parisc/math-emu/fpudispatch.c
@@ -50,6 +50,7 @@
50#define FPUDEBUG 0 50#define FPUDEBUG 0
51 51
52#include "float.h" 52#include "float.h"
53#include <linux/bug.h>
53#include <linux/kernel.h> 54#include <linux/kernel.h>
54#include <asm/processor.h> 55#include <asm/processor.h>
55/* #include <sys/debug.h> */ 56/* #include <sys/debug.h> */
diff --git a/arch/powerpc/boot/.gitignore b/arch/powerpc/boot/.gitignore
index 12da77ec022..1c1aadc8c48 100644
--- a/arch/powerpc/boot/.gitignore
+++ b/arch/powerpc/boot/.gitignore
@@ -27,7 +27,6 @@ zImage.bin.*
27zImage.chrp 27zImage.chrp
28zImage.coff 28zImage.coff
29zImage.holly 29zImage.holly
30zImage.iseries
31zImage.*lds 30zImage.*lds
32zImage.miboot 31zImage.miboot
33zImage.pmac 32zImage.pmac
diff --git a/arch/powerpc/include/asm/iommu.h b/arch/powerpc/include/asm/iommu.h
index edfc9803ec9..957a83f4364 100644
--- a/arch/powerpc/include/asm/iommu.h
+++ b/arch/powerpc/include/asm/iommu.h
@@ -112,7 +112,6 @@ extern void iommu_unmap_page(struct iommu_table *tbl, dma_addr_t dma_handle,
112 struct dma_attrs *attrs); 112 struct dma_attrs *attrs);
113 113
114extern void iommu_init_early_pSeries(void); 114extern void iommu_init_early_pSeries(void);
115extern void iommu_init_early_iSeries(void);
116extern void iommu_init_early_dart(void); 115extern void iommu_init_early_dart(void);
117extern void iommu_init_early_pasemi(void); 116extern void iommu_init_early_pasemi(void);
118 117
diff --git a/arch/powerpc/include/asm/irq.h b/arch/powerpc/include/asm/irq.h
index fe0b09dceb7..cf417e51073 100644
--- a/arch/powerpc/include/asm/irq.h
+++ b/arch/powerpc/include/asm/irq.h
@@ -27,12 +27,6 @@ extern atomic_t ppc_n_lost_interrupts;
27/* This number is used when no interrupt has been assigned */ 27/* This number is used when no interrupt has been assigned */
28#define NO_IRQ (0) 28#define NO_IRQ (0)
29 29
30/* This is a special irq number to return from get_irq() to tell that
31 * no interrupt happened _and_ ignore it (don't count it as bad). Some
32 * platforms like iSeries rely on that.
33 */
34#define NO_IRQ_IGNORE ((unsigned int)-1)
35
36/* Total number of virq in the platform */ 30/* Total number of virq in the platform */
37#define NR_IRQS CONFIG_NR_IRQS 31#define NR_IRQS CONFIG_NR_IRQS
38 32
diff --git a/arch/powerpc/include/asm/kvm.h b/arch/powerpc/include/asm/kvm.h
index f7727d91ac6..b921c3f4892 100644
--- a/arch/powerpc/include/asm/kvm.h
+++ b/arch/powerpc/include/asm/kvm.h
@@ -265,12 +265,9 @@ struct kvm_debug_exit_arch {
265struct kvm_guest_debug_arch { 265struct kvm_guest_debug_arch {
266}; 266};
267 267
268#define KVM_REG_MASK 0x001f 268/* definition of registers in kvm_run */
269#define KVM_REG_EXT_MASK 0xffe0 269struct kvm_sync_regs {
270#define KVM_REG_GPR 0x0000 270};
271#define KVM_REG_FPR 0x0020
272#define KVM_REG_QPR 0x0040
273#define KVM_REG_FQPR 0x0060
274 271
275#define KVM_INTERRUPT_SET -1U 272#define KVM_INTERRUPT_SET -1U
276#define KVM_INTERRUPT_UNSET -2U 273#define KVM_INTERRUPT_UNSET -2U
@@ -292,4 +289,41 @@ struct kvm_allocate_rma {
292 __u64 rma_size; 289 __u64 rma_size;
293}; 290};
294 291
292struct kvm_book3e_206_tlb_entry {
293 __u32 mas8;
294 __u32 mas1;
295 __u64 mas2;
296 __u64 mas7_3;
297};
298
299struct kvm_book3e_206_tlb_params {
300 /*
301 * For mmu types KVM_MMU_FSL_BOOKE_NOHV and KVM_MMU_FSL_BOOKE_HV:
302 *
303 * - The number of ways of TLB0 must be a power of two between 2 and
304 * 16.
305 * - TLB1 must be fully associative.
306 * - The size of TLB0 must be a multiple of the number of ways, and
307 * the number of sets must be a power of two.
308 * - The size of TLB1 may not exceed 64 entries.
309 * - TLB0 supports 4 KiB pages.
310 * - The page sizes supported by TLB1 are as indicated by
311 * TLB1CFG (if MMUCFG[MAVN] = 0) or TLB1PS (if MMUCFG[MAVN] = 1)
312 * as returned by KVM_GET_SREGS.
313 * - TLB2 and TLB3 are reserved, and their entries in tlb_sizes[]
314 * and tlb_ways[] must be zero.
315 *
316 * tlb_ways[n] = tlb_sizes[n] means the array is fully associative.
317 *
318 * KVM will adjust TLBnCFG based on the sizes configured here,
319 * though arrays greater than 2048 entries will have TLBnCFG[NENTRY]
320 * set to zero.
321 */
322 __u32 tlb_sizes[4];
323 __u32 tlb_ways[4];
324 __u32 reserved[8];
325};
326
327#define KVM_REG_PPC_HIOR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x1)
328
295#endif /* __LINUX_KVM_POWERPC_H */ 329#endif /* __LINUX_KVM_POWERPC_H */
diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/include/asm/kvm_book3s.h
index 69c7377d207..aa795ccef29 100644
--- a/arch/powerpc/include/asm/kvm_book3s.h
+++ b/arch/powerpc/include/asm/kvm_book3s.h
@@ -90,6 +90,8 @@ struct kvmppc_vcpu_book3s {
90#endif 90#endif
91 int context_id[SID_CONTEXTS]; 91 int context_id[SID_CONTEXTS];
92 92
93 bool hior_explicit; /* HIOR is set by ioctl, not PVR */
94
93 struct hlist_head hpte_hash_pte[HPTEG_HASH_NUM_PTE]; 95 struct hlist_head hpte_hash_pte[HPTEG_HASH_NUM_PTE];
94 struct hlist_head hpte_hash_pte_long[HPTEG_HASH_NUM_PTE_LONG]; 96 struct hlist_head hpte_hash_pte_long[HPTEG_HASH_NUM_PTE_LONG];
95 struct hlist_head hpte_hash_vpte[HPTEG_HASH_NUM_VPTE]; 97 struct hlist_head hpte_hash_vpte[HPTEG_HASH_NUM_VPTE];
@@ -119,6 +121,11 @@ extern void kvmppc_mmu_book3s_hv_init(struct kvm_vcpu *vcpu);
119extern int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *pte); 121extern int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *pte);
120extern int kvmppc_mmu_map_segment(struct kvm_vcpu *vcpu, ulong eaddr); 122extern int kvmppc_mmu_map_segment(struct kvm_vcpu *vcpu, ulong eaddr);
121extern void kvmppc_mmu_flush_segments(struct kvm_vcpu *vcpu); 123extern void kvmppc_mmu_flush_segments(struct kvm_vcpu *vcpu);
124extern int kvmppc_book3s_hv_page_fault(struct kvm_run *run,
125 struct kvm_vcpu *vcpu, unsigned long addr,
126 unsigned long status);
127extern long kvmppc_hv_find_lock_hpte(struct kvm *kvm, gva_t eaddr,
128 unsigned long slb_v, unsigned long valid);
122 129
123extern void kvmppc_mmu_hpte_cache_map(struct kvm_vcpu *vcpu, struct hpte_cache *pte); 130extern void kvmppc_mmu_hpte_cache_map(struct kvm_vcpu *vcpu, struct hpte_cache *pte);
124extern struct hpte_cache *kvmppc_mmu_hpte_cache_next(struct kvm_vcpu *vcpu); 131extern struct hpte_cache *kvmppc_mmu_hpte_cache_next(struct kvm_vcpu *vcpu);
@@ -138,6 +145,21 @@ extern void kvmppc_set_bat(struct kvm_vcpu *vcpu, struct kvmppc_bat *bat,
138extern void kvmppc_giveup_ext(struct kvm_vcpu *vcpu, ulong msr); 145extern void kvmppc_giveup_ext(struct kvm_vcpu *vcpu, ulong msr);
139extern int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu); 146extern int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu);
140extern pfn_t kvmppc_gfn_to_pfn(struct kvm_vcpu *vcpu, gfn_t gfn); 147extern pfn_t kvmppc_gfn_to_pfn(struct kvm_vcpu *vcpu, gfn_t gfn);
148extern void kvmppc_add_revmap_chain(struct kvm *kvm, struct revmap_entry *rev,
149 unsigned long *rmap, long pte_index, int realmode);
150extern void kvmppc_invalidate_hpte(struct kvm *kvm, unsigned long *hptep,
151 unsigned long pte_index);
152void kvmppc_clear_ref_hpte(struct kvm *kvm, unsigned long *hptep,
153 unsigned long pte_index);
154extern void *kvmppc_pin_guest_page(struct kvm *kvm, unsigned long addr,
155 unsigned long *nb_ret);
156extern void kvmppc_unpin_guest_page(struct kvm *kvm, void *addr);
157extern long kvmppc_virtmode_h_enter(struct kvm_vcpu *vcpu, unsigned long flags,
158 long pte_index, unsigned long pteh, unsigned long ptel);
159extern long kvmppc_h_enter(struct kvm_vcpu *vcpu, unsigned long flags,
160 long pte_index, unsigned long pteh, unsigned long ptel);
161extern long kvmppc_hv_get_dirty_log(struct kvm *kvm,
162 struct kvm_memory_slot *memslot);
141 163
142extern void kvmppc_entry_trampoline(void); 164extern void kvmppc_entry_trampoline(void);
143extern void kvmppc_hv_entry_trampoline(void); 165extern void kvmppc_hv_entry_trampoline(void);
@@ -183,7 +205,9 @@ static inline void kvmppc_update_int_pending(struct kvm_vcpu *vcpu,
183static inline void kvmppc_set_gpr(struct kvm_vcpu *vcpu, int num, ulong val) 205static inline void kvmppc_set_gpr(struct kvm_vcpu *vcpu, int num, ulong val)
184{ 206{
185 if ( num < 14 ) { 207 if ( num < 14 ) {
186 to_svcpu(vcpu)->gpr[num] = val; 208 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
209 svcpu->gpr[num] = val;
210 svcpu_put(svcpu);
187 to_book3s(vcpu)->shadow_vcpu->gpr[num] = val; 211 to_book3s(vcpu)->shadow_vcpu->gpr[num] = val;
188 } else 212 } else
189 vcpu->arch.gpr[num] = val; 213 vcpu->arch.gpr[num] = val;
@@ -191,80 +215,120 @@ static inline void kvmppc_set_gpr(struct kvm_vcpu *vcpu, int num, ulong val)
191 215
192static inline ulong kvmppc_get_gpr(struct kvm_vcpu *vcpu, int num) 216static inline ulong kvmppc_get_gpr(struct kvm_vcpu *vcpu, int num)
193{ 217{
194 if ( num < 14 ) 218 if ( num < 14 ) {
195 return to_svcpu(vcpu)->gpr[num]; 219 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
196 else 220 ulong r = svcpu->gpr[num];
221 svcpu_put(svcpu);
222 return r;
223 } else
197 return vcpu->arch.gpr[num]; 224 return vcpu->arch.gpr[num];
198} 225}
199 226
200static inline void kvmppc_set_cr(struct kvm_vcpu *vcpu, u32 val) 227static inline void kvmppc_set_cr(struct kvm_vcpu *vcpu, u32 val)
201{ 228{
202 to_svcpu(vcpu)->cr = val; 229 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
230 svcpu->cr = val;
231 svcpu_put(svcpu);
203 to_book3s(vcpu)->shadow_vcpu->cr = val; 232 to_book3s(vcpu)->shadow_vcpu->cr = val;
204} 233}
205 234
206static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu) 235static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu)
207{ 236{
208 return to_svcpu(vcpu)->cr; 237 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
238 u32 r;
239 r = svcpu->cr;
240 svcpu_put(svcpu);
241 return r;
209} 242}
210 243
211static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, u32 val) 244static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, u32 val)
212{ 245{
213 to_svcpu(vcpu)->xer = val; 246 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
247 svcpu->xer = val;
214 to_book3s(vcpu)->shadow_vcpu->xer = val; 248 to_book3s(vcpu)->shadow_vcpu->xer = val;
249 svcpu_put(svcpu);
215} 250}
216 251
217static inline u32 kvmppc_get_xer(struct kvm_vcpu *vcpu) 252static inline u32 kvmppc_get_xer(struct kvm_vcpu *vcpu)
218{ 253{
219 return to_svcpu(vcpu)->xer; 254 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
255 u32 r;
256 r = svcpu->xer;
257 svcpu_put(svcpu);
258 return r;
220} 259}
221 260
222static inline void kvmppc_set_ctr(struct kvm_vcpu *vcpu, ulong val) 261static inline void kvmppc_set_ctr(struct kvm_vcpu *vcpu, ulong val)
223{ 262{
224 to_svcpu(vcpu)->ctr = val; 263 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
264 svcpu->ctr = val;
265 svcpu_put(svcpu);
225} 266}
226 267
227static inline ulong kvmppc_get_ctr(struct kvm_vcpu *vcpu) 268static inline ulong kvmppc_get_ctr(struct kvm_vcpu *vcpu)
228{ 269{
229 return to_svcpu(vcpu)->ctr; 270 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
271 ulong r;
272 r = svcpu->ctr;
273 svcpu_put(svcpu);
274 return r;
230} 275}
231 276
232static inline void kvmppc_set_lr(struct kvm_vcpu *vcpu, ulong val) 277static inline void kvmppc_set_lr(struct kvm_vcpu *vcpu, ulong val)
233{ 278{
234 to_svcpu(vcpu)->lr = val; 279 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
280 svcpu->lr = val;
281 svcpu_put(svcpu);
235} 282}
236 283
237static inline ulong kvmppc_get_lr(struct kvm_vcpu *vcpu) 284static inline ulong kvmppc_get_lr(struct kvm_vcpu *vcpu)
238{ 285{
239 return to_svcpu(vcpu)->lr; 286 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
287 ulong r;
288 r = svcpu->lr;
289 svcpu_put(svcpu);
290 return r;
240} 291}
241 292
242static inline void kvmppc_set_pc(struct kvm_vcpu *vcpu, ulong val) 293static inline void kvmppc_set_pc(struct kvm_vcpu *vcpu, ulong val)
243{ 294{
244 to_svcpu(vcpu)->pc = val; 295 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
296 svcpu->pc = val;
297 svcpu_put(svcpu);
245} 298}
246 299
247static inline ulong kvmppc_get_pc(struct kvm_vcpu *vcpu) 300static inline ulong kvmppc_get_pc(struct kvm_vcpu *vcpu)
248{ 301{
249 return to_svcpu(vcpu)->pc; 302 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
303 ulong r;
304 r = svcpu->pc;
305 svcpu_put(svcpu);
306 return r;
250} 307}
251 308
252static inline u32 kvmppc_get_last_inst(struct kvm_vcpu *vcpu) 309static inline u32 kvmppc_get_last_inst(struct kvm_vcpu *vcpu)
253{ 310{
254 ulong pc = kvmppc_get_pc(vcpu); 311 ulong pc = kvmppc_get_pc(vcpu);
255 struct kvmppc_book3s_shadow_vcpu *svcpu = to_svcpu(vcpu); 312 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
313 u32 r;
256 314
257 /* Load the instruction manually if it failed to do so in the 315 /* Load the instruction manually if it failed to do so in the
258 * exit path */ 316 * exit path */
259 if (svcpu->last_inst == KVM_INST_FETCH_FAILED) 317 if (svcpu->last_inst == KVM_INST_FETCH_FAILED)
260 kvmppc_ld(vcpu, &pc, sizeof(u32), &svcpu->last_inst, false); 318 kvmppc_ld(vcpu, &pc, sizeof(u32), &svcpu->last_inst, false);
261 319
262 return svcpu->last_inst; 320 r = svcpu->last_inst;
321 svcpu_put(svcpu);
322 return r;
263} 323}
264 324
265static inline ulong kvmppc_get_fault_dar(struct kvm_vcpu *vcpu) 325static inline ulong kvmppc_get_fault_dar(struct kvm_vcpu *vcpu)
266{ 326{
267 return to_svcpu(vcpu)->fault_dar; 327 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
328 ulong r;
329 r = svcpu->fault_dar;
330 svcpu_put(svcpu);
331 return r;
268} 332}
269 333
270static inline bool kvmppc_critical_section(struct kvm_vcpu *vcpu) 334static inline bool kvmppc_critical_section(struct kvm_vcpu *vcpu)
diff --git a/arch/powerpc/include/asm/kvm_book3s_32.h b/arch/powerpc/include/asm/kvm_book3s_32.h
index de604db135f..38040ff8206 100644
--- a/arch/powerpc/include/asm/kvm_book3s_32.h
+++ b/arch/powerpc/include/asm/kvm_book3s_32.h
@@ -20,11 +20,15 @@
20#ifndef __ASM_KVM_BOOK3S_32_H__ 20#ifndef __ASM_KVM_BOOK3S_32_H__
21#define __ASM_KVM_BOOK3S_32_H__ 21#define __ASM_KVM_BOOK3S_32_H__
22 22
23static inline struct kvmppc_book3s_shadow_vcpu *to_svcpu(struct kvm_vcpu *vcpu) 23static inline struct kvmppc_book3s_shadow_vcpu *svcpu_get(struct kvm_vcpu *vcpu)
24{ 24{
25 return to_book3s(vcpu)->shadow_vcpu; 25 return to_book3s(vcpu)->shadow_vcpu;
26} 26}
27 27
28static inline void svcpu_put(struct kvmppc_book3s_shadow_vcpu *svcpu)
29{
30}
31
28#define PTE_SIZE 12 32#define PTE_SIZE 12
29#define VSID_ALL 0 33#define VSID_ALL 0
30#define SR_INVALID 0x00000001 /* VSID 1 should always be unused */ 34#define SR_INVALID 0x00000001 /* VSID 1 should always be unused */
diff --git a/arch/powerpc/include/asm/kvm_book3s_64.h b/arch/powerpc/include/asm/kvm_book3s_64.h
index d0ac94f98f9..b0c08b14277 100644
--- a/arch/powerpc/include/asm/kvm_book3s_64.h
+++ b/arch/powerpc/include/asm/kvm_book3s_64.h
@@ -21,14 +21,56 @@
21#define __ASM_KVM_BOOK3S_64_H__ 21#define __ASM_KVM_BOOK3S_64_H__
22 22
23#ifdef CONFIG_KVM_BOOK3S_PR 23#ifdef CONFIG_KVM_BOOK3S_PR
24static inline struct kvmppc_book3s_shadow_vcpu *to_svcpu(struct kvm_vcpu *vcpu) 24static inline struct kvmppc_book3s_shadow_vcpu *svcpu_get(struct kvm_vcpu *vcpu)
25{ 25{
26 preempt_disable();
26 return &get_paca()->shadow_vcpu; 27 return &get_paca()->shadow_vcpu;
27} 28}
29
30static inline void svcpu_put(struct kvmppc_book3s_shadow_vcpu *svcpu)
31{
32 preempt_enable();
33}
28#endif 34#endif
29 35
30#define SPAPR_TCE_SHIFT 12 36#define SPAPR_TCE_SHIFT 12
31 37
38#ifdef CONFIG_KVM_BOOK3S_64_HV
39/* For now use fixed-size 16MB page table */
40#define HPT_ORDER 24
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
45
46#define VRMA_VSID 0x1ffffffUL /* 1TB VSID reserved for VRMA */
47
48/*
49 * We use a lock bit in HPTE dword 0 to synchronize updates and
50 * accesses to each HPTE, and another bit to indicate non-present
51 * HPTEs.
52 */
53#define HPTE_V_HVLOCK 0x40UL
54#define HPTE_V_ABSENT 0x20UL
55
56static inline long try_lock_hpte(unsigned long *hpte, unsigned long bits)
57{
58 unsigned long tmp, old;
59
60 asm volatile(" ldarx %0,0,%2\n"
61 " and. %1,%0,%3\n"
62 " bne 2f\n"
63 " ori %0,%0,%4\n"
64 " stdcx. %0,0,%2\n"
65 " beq+ 2f\n"
66 " li %1,%3\n"
67 "2: isync"
68 : "=&r" (tmp), "=&r" (old)
69 : "r" (hpte), "r" (bits), "i" (HPTE_V_HVLOCK)
70 : "cc", "memory");
71 return old == 0;
72}
73
32static inline unsigned long compute_tlbie_rb(unsigned long v, unsigned long r, 74static inline unsigned long compute_tlbie_rb(unsigned long v, unsigned long r,
33 unsigned long pte_index) 75 unsigned long pte_index)
34{ 76{
@@ -62,4 +104,140 @@ static inline unsigned long compute_tlbie_rb(unsigned long v, unsigned long r,
62 return rb; 104 return rb;
63} 105}
64 106
107static inline unsigned long hpte_page_size(unsigned long h, unsigned long l)
108{
109 /* only handle 4k, 64k and 16M pages for now */
110 if (!(h & HPTE_V_LARGE))
111 return 1ul << 12; /* 4k page */
112 if ((l & 0xf000) == 0x1000 && cpu_has_feature(CPU_FTR_ARCH_206))
113 return 1ul << 16; /* 64k page */
114 if ((l & 0xff000) == 0)
115 return 1ul << 24; /* 16M page */
116 return 0; /* error */
117}
118
119static inline unsigned long hpte_rpn(unsigned long ptel, unsigned long psize)
120{
121 return ((ptel & HPTE_R_RPN) & ~(psize - 1)) >> PAGE_SHIFT;
122}
123
124static inline int hpte_is_writable(unsigned long ptel)
125{
126 unsigned long pp = ptel & (HPTE_R_PP0 | HPTE_R_PP);
127
128 return pp != PP_RXRX && pp != PP_RXXX;
129}
130
131static inline unsigned long hpte_make_readonly(unsigned long ptel)
132{
133 if ((ptel & HPTE_R_PP0) || (ptel & HPTE_R_PP) == PP_RWXX)
134 ptel = (ptel & ~HPTE_R_PP) | PP_RXXX;
135 else
136 ptel |= PP_RXRX;
137 return ptel;
138}
139
140static inline int hpte_cache_flags_ok(unsigned long ptel, unsigned long io_type)
141{
142 unsigned int wimg = ptel & HPTE_R_WIMG;
143
144 /* Handle SAO */
145 if (wimg == (HPTE_R_W | HPTE_R_I | HPTE_R_M) &&
146 cpu_has_feature(CPU_FTR_ARCH_206))
147 wimg = HPTE_R_M;
148
149 if (!io_type)
150 return wimg == HPTE_R_M;
151
152 return (wimg & (HPTE_R_W | HPTE_R_I)) == io_type;
153}
154
155/*
156 * Lock and read a linux PTE. If it's present and writable, atomically
157 * set dirty and referenced bits and return the PTE, otherwise return 0.
158 */
159static inline pte_t kvmppc_read_update_linux_pte(pte_t *p, int writing)
160{
161 pte_t pte, tmp;
162
163 /* wait until _PAGE_BUSY is clear then set it atomically */
164 __asm__ __volatile__ (
165 "1: ldarx %0,0,%3\n"
166 " andi. %1,%0,%4\n"
167 " bne- 1b\n"
168 " ori %1,%0,%4\n"
169 " stdcx. %1,0,%3\n"
170 " bne- 1b"
171 : "=&r" (pte), "=&r" (tmp), "=m" (*p)
172 : "r" (p), "i" (_PAGE_BUSY)
173 : "cc");
174
175 if (pte_present(pte)) {
176 pte = pte_mkyoung(pte);
177 if (writing && pte_write(pte))
178 pte = pte_mkdirty(pte);
179 }
180
181 *p = pte; /* clears _PAGE_BUSY */
182
183 return pte;
184}
185
186/* Return HPTE cache control bits corresponding to Linux pte bits */
187static inline unsigned long hpte_cache_bits(unsigned long pte_val)
188{
189#if _PAGE_NO_CACHE == HPTE_R_I && _PAGE_WRITETHRU == HPTE_R_W
190 return pte_val & (HPTE_R_W | HPTE_R_I);
191#else
192 return ((pte_val & _PAGE_NO_CACHE) ? HPTE_R_I : 0) +
193 ((pte_val & _PAGE_WRITETHRU) ? HPTE_R_W : 0);
194#endif
195}
196
197static inline bool hpte_read_permission(unsigned long pp, unsigned long key)
198{
199 if (key)
200 return PP_RWRX <= pp && pp <= PP_RXRX;
201 return 1;
202}
203
204static inline bool hpte_write_permission(unsigned long pp, unsigned long key)
205{
206 if (key)
207 return pp == PP_RWRW;
208 return pp <= PP_RWRW;
209}
210
211static inline int hpte_get_skey_perm(unsigned long hpte_r, unsigned long amr)
212{
213 unsigned long skey;
214
215 skey = ((hpte_r & HPTE_R_KEY_HI) >> 57) |
216 ((hpte_r & HPTE_R_KEY_LO) >> 9);
217 return (amr >> (62 - 2 * skey)) & 3;
218}
219
220static inline void lock_rmap(unsigned long *rmap)
221{
222 do {
223 while (test_bit(KVMPPC_RMAP_LOCK_BIT, rmap))
224 cpu_relax();
225 } while (test_and_set_bit_lock(KVMPPC_RMAP_LOCK_BIT, rmap));
226}
227
228static inline void unlock_rmap(unsigned long *rmap)
229{
230 __clear_bit_unlock(KVMPPC_RMAP_LOCK_BIT, rmap);
231}
232
233static inline bool slot_is_aligned(struct kvm_memory_slot *memslot,
234 unsigned long pagesize)
235{
236 unsigned long mask = (pagesize >> PAGE_SHIFT) - 1;
237
238 if (pagesize <= PAGE_SIZE)
239 return 1;
240 return !(memslot->base_gfn & mask) && !(memslot->npages & mask);
241}
242
65#endif /* __ASM_KVM_BOOK3S_64_H__ */ 243#endif /* __ASM_KVM_BOOK3S_64_H__ */
diff --git a/arch/powerpc/include/asm/kvm_e500.h b/arch/powerpc/include/asm/kvm_e500.h
index adbfca9dd10..8cd50a51427 100644
--- a/arch/powerpc/include/asm/kvm_e500.h
+++ b/arch/powerpc/include/asm/kvm_e500.h
@@ -22,46 +22,55 @@
22#define E500_PID_NUM 3 22#define E500_PID_NUM 3
23#define E500_TLB_NUM 2 23#define E500_TLB_NUM 2
24 24
25struct tlbe{
26 u32 mas1;
27 u32 mas2;
28 u32 mas3;
29 u32 mas7;
30};
31
32#define E500_TLB_VALID 1 25#define E500_TLB_VALID 1
33#define E500_TLB_DIRTY 2 26#define E500_TLB_DIRTY 2
34 27
35struct tlbe_priv { 28struct tlbe_ref {
36 pfn_t pfn; 29 pfn_t pfn;
37 unsigned int flags; /* E500_TLB_* */ 30 unsigned int flags; /* E500_TLB_* */
38}; 31};
39 32
33struct tlbe_priv {
34 struct tlbe_ref ref; /* TLB0 only -- TLB1 uses tlb_refs */
35};
36
40struct vcpu_id_table; 37struct vcpu_id_table;
41 38
39struct kvmppc_e500_tlb_params {
40 int entries, ways, sets;
41};
42
42struct kvmppc_vcpu_e500 { 43struct kvmppc_vcpu_e500 {
43 /* Unmodified copy of the guest's TLB. */ 44 /* Unmodified copy of the guest's TLB -- shared with host userspace. */
44 struct tlbe *gtlb_arch[E500_TLB_NUM]; 45 struct kvm_book3e_206_tlb_entry *gtlb_arch;
46
47 /* Starting entry number in gtlb_arch[] */
48 int gtlb_offset[E500_TLB_NUM];
45 49
46 /* KVM internal information associated with each guest TLB entry */ 50 /* KVM internal information associated with each guest TLB entry */
47 struct tlbe_priv *gtlb_priv[E500_TLB_NUM]; 51 struct tlbe_priv *gtlb_priv[E500_TLB_NUM];
48 52
49 unsigned int gtlb_size[E500_TLB_NUM]; 53 struct kvmppc_e500_tlb_params gtlb_params[E500_TLB_NUM];
54
50 unsigned int gtlb_nv[E500_TLB_NUM]; 55 unsigned int gtlb_nv[E500_TLB_NUM];
51 56
57 /*
58 * information associated with each host TLB entry --
59 * TLB1 only for now. If/when guest TLB1 entries can be
60 * mapped with host TLB0, this will be used for that too.
61 *
62 * We don't want to use this for guest TLB0 because then we'd
63 * have the overhead of doing the translation again even if
64 * the entry is still in the guest TLB (e.g. we swapped out
65 * and back, and our host TLB entries got evicted).
66 */
67 struct tlbe_ref *tlb_refs[E500_TLB_NUM];
68 unsigned int host_tlb1_nv;
69
52 u32 host_pid[E500_PID_NUM]; 70 u32 host_pid[E500_PID_NUM];
53 u32 pid[E500_PID_NUM]; 71 u32 pid[E500_PID_NUM];
54 u32 svr; 72 u32 svr;
55 73
56 u32 mas0;
57 u32 mas1;
58 u32 mas2;
59 u32 mas3;
60 u32 mas4;
61 u32 mas5;
62 u32 mas6;
63 u32 mas7;
64
65 /* vcpu id table */ 74 /* vcpu id table */
66 struct vcpu_id_table *idt; 75 struct vcpu_id_table *idt;
67 76
@@ -73,6 +82,9 @@ struct kvmppc_vcpu_e500 {
73 u32 tlb1cfg; 82 u32 tlb1cfg;
74 u64 mcar; 83 u64 mcar;
75 84
85 struct page **shared_tlb_pages;
86 int num_shared_tlb_pages;
87
76 struct kvm_vcpu vcpu; 88 struct kvm_vcpu vcpu;
77}; 89};
78 90
diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
index bf8af5d5d5d..52eb9c1f4fe 100644
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -32,17 +32,32 @@
32#include <linux/atomic.h> 32#include <linux/atomic.h>
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 36
36#define KVM_MAX_VCPUS NR_CPUS 37#define KVM_MAX_VCPUS NR_CPUS
37#define KVM_MAX_VCORES NR_CPUS 38#define KVM_MAX_VCORES NR_CPUS
38#define KVM_MEMORY_SLOTS 32 39#define KVM_MEMORY_SLOTS 32
39/* memory slots that does not exposed to userspace */ 40/* memory slots that does not exposed to userspace */
40#define KVM_PRIVATE_MEM_SLOTS 4 41#define KVM_PRIVATE_MEM_SLOTS 4
42#define KVM_MEM_SLOTS_NUM (KVM_MEMORY_SLOTS + KVM_PRIVATE_MEM_SLOTS)
41 43
42#ifdef CONFIG_KVM_MMIO 44#ifdef CONFIG_KVM_MMIO
43#define KVM_COALESCED_MMIO_PAGE_OFFSET 1 45#define KVM_COALESCED_MMIO_PAGE_OFFSET 1
44#endif 46#endif
45 47
48#ifdef CONFIG_KVM_BOOK3S_64_HV
49#include <linux/mmu_notifier.h>
50
51#define KVM_ARCH_WANT_MMU_NOTIFIER
52
53struct kvm;
54extern int kvm_unmap_hva(struct kvm *kvm, unsigned long hva);
55extern int kvm_age_hva(struct kvm *kvm, unsigned long hva);
56extern int kvm_test_age_hva(struct kvm *kvm, unsigned long hva);
57extern void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte);
58
59#endif
60
46/* We don't currently support large pages. */ 61/* We don't currently support large pages. */
47#define KVM_HPAGE_GFN_SHIFT(x) 0 62#define KVM_HPAGE_GFN_SHIFT(x) 0
48#define KVM_NR_PAGE_SIZES 1 63#define KVM_NR_PAGE_SIZES 1
@@ -158,34 +173,72 @@ struct kvmppc_spapr_tce_table {
158 struct page *pages[0]; 173 struct page *pages[0];
159}; 174};
160 175
161struct kvmppc_rma_info { 176struct kvmppc_linear_info {
162 void *base_virt; 177 void *base_virt;
163 unsigned long base_pfn; 178 unsigned long base_pfn;
164 unsigned long npages; 179 unsigned long npages;
165 struct list_head list; 180 struct list_head list;
166 atomic_t use_count; 181 atomic_t use_count;
182 int type;
183};
184
185/*
186 * The reverse mapping array has one entry for each HPTE,
187 * which stores the guest's view of the second word of the HPTE
188 * (including the guest physical address of the mapping),
189 * plus forward and backward pointers in a doubly-linked ring
190 * of HPTEs that map the same host page. The pointers in this
191 * ring are 32-bit HPTE indexes, to save space.
192 */
193struct revmap_entry {
194 unsigned long guest_rpte;
195 unsigned int forw, back;
196};
197
198/*
199 * We use the top bit of each memslot->rmap entry as a lock bit,
200 * and bit 32 as a present flag. The bottom 32 bits are the
201 * index in the guest HPT of a HPTE that points to the page.
202 */
203#define KVMPPC_RMAP_LOCK_BIT 63
204#define KVMPPC_RMAP_RC_SHIFT 32
205#define KVMPPC_RMAP_REFERENCED (HPTE_R_R << KVMPPC_RMAP_RC_SHIFT)
206#define KVMPPC_RMAP_CHANGED (HPTE_R_C << KVMPPC_RMAP_RC_SHIFT)
207#define KVMPPC_RMAP_PRESENT 0x100000000ul
208#define KVMPPC_RMAP_INDEX 0xfffffffful
209
210/* Low-order bits in kvm->arch.slot_phys[][] */
211#define KVMPPC_PAGE_ORDER_MASK 0x1f
212#define KVMPPC_PAGE_NO_CACHE HPTE_R_I /* 0x20 */
213#define KVMPPC_PAGE_WRITETHRU HPTE_R_W /* 0x40 */
214#define KVMPPC_GOT_PAGE 0x80
215
216struct kvm_arch_memory_slot {
167}; 217};
168 218
169struct kvm_arch { 219struct kvm_arch {
170#ifdef CONFIG_KVM_BOOK3S_64_HV 220#ifdef CONFIG_KVM_BOOK3S_64_HV
171 unsigned long hpt_virt; 221 unsigned long hpt_virt;
172 unsigned long ram_npages; 222 struct revmap_entry *revmap;
173 unsigned long ram_psize;
174 unsigned long ram_porder;
175 struct kvmppc_pginfo *ram_pginfo;
176 unsigned int lpid; 223 unsigned int lpid;
177 unsigned int host_lpid; 224 unsigned int host_lpid;
178 unsigned long host_lpcr; 225 unsigned long host_lpcr;
179 unsigned long sdr1; 226 unsigned long sdr1;
180 unsigned long host_sdr1; 227 unsigned long host_sdr1;
181 int tlbie_lock; 228 int tlbie_lock;
182 int n_rma_pages;
183 unsigned long lpcr; 229 unsigned long lpcr;
184 unsigned long rmor; 230 unsigned long rmor;
185 struct kvmppc_rma_info *rma; 231 struct kvmppc_linear_info *rma;
232 unsigned long vrma_slb_v;
233 int rma_setup_done;
234 int using_mmu_notifiers;
186 struct list_head spapr_tce_tables; 235 struct list_head spapr_tce_tables;
236 spinlock_t slot_phys_lock;
237 unsigned long *slot_phys[KVM_MEM_SLOTS_NUM];
238 int slot_npages[KVM_MEM_SLOTS_NUM];
187 unsigned short last_vcpu[NR_CPUS]; 239 unsigned short last_vcpu[NR_CPUS];
188 struct kvmppc_vcore *vcores[KVM_MAX_VCORES]; 240 struct kvmppc_vcore *vcores[KVM_MAX_VCORES];
241 struct kvmppc_linear_info *hpt_li;
189#endif /* CONFIG_KVM_BOOK3S_64_HV */ 242#endif /* CONFIG_KVM_BOOK3S_64_HV */
190}; 243};
191 244
@@ -318,10 +371,6 @@ struct kvm_vcpu_arch {
318 u32 vrsave; /* also USPRG0 */ 371 u32 vrsave; /* also USPRG0 */
319 u32 mmucr; 372 u32 mmucr;
320 ulong shadow_msr; 373 ulong shadow_msr;
321 ulong sprg4;
322 ulong sprg5;
323 ulong sprg6;
324 ulong sprg7;
325 ulong csrr0; 374 ulong csrr0;
326 ulong csrr1; 375 ulong csrr1;
327 ulong dsrr0; 376 ulong dsrr0;
@@ -329,16 +378,14 @@ struct kvm_vcpu_arch {
329 ulong mcsrr0; 378 ulong mcsrr0;
330 ulong mcsrr1; 379 ulong mcsrr1;
331 ulong mcsr; 380 ulong mcsr;
332 ulong esr;
333 u32 dec; 381 u32 dec;
334 u32 decar; 382 u32 decar;
335 u32 tbl; 383 u32 tbl;
336 u32 tbu; 384 u32 tbu;
337 u32 tcr; 385 u32 tcr;
338 u32 tsr; 386 ulong tsr; /* we need to perform set/clr_bits() which requires ulong */
339 u32 ivor[64]; 387 u32 ivor[64];
340 ulong ivpr; 388 ulong ivpr;
341 u32 pir;
342 u32 pvr; 389 u32 pvr;
343 390
344 u32 shadow_pid; 391 u32 shadow_pid;
@@ -427,9 +474,14 @@ struct kvm_vcpu_arch {
427#ifdef CONFIG_KVM_BOOK3S_64_HV 474#ifdef CONFIG_KVM_BOOK3S_64_HV
428 struct kvm_vcpu_arch_shared shregs; 475 struct kvm_vcpu_arch_shared shregs;
429 476
477 unsigned long pgfault_addr;
478 long pgfault_index;
479 unsigned long pgfault_hpte[2];
480
430 struct list_head run_list; 481 struct list_head run_list;
431 struct task_struct *run_task; 482 struct task_struct *run_task;
432 struct kvm_run *kvm_run; 483 struct kvm_run *kvm_run;
484 pgd_t *pgdir;
433#endif 485#endif
434}; 486};
435 487
@@ -438,4 +490,12 @@ struct kvm_vcpu_arch {
438#define KVMPPC_VCPU_BUSY_IN_HOST 1 490#define KVMPPC_VCPU_BUSY_IN_HOST 1
439#define KVMPPC_VCPU_RUNNABLE 2 491#define KVMPPC_VCPU_RUNNABLE 2
440 492
493/* Values for vcpu->arch.io_gpr */
494#define KVM_MMIO_REG_MASK 0x001f
495#define KVM_MMIO_REG_EXT_MASK 0xffe0
496#define KVM_MMIO_REG_GPR 0x0000
497#define KVM_MMIO_REG_FPR 0x0020
498#define KVM_MMIO_REG_QPR 0x0040
499#define KVM_MMIO_REG_FQPR 0x0060
500
441#endif /* __POWERPC_KVM_HOST_H__ */ 501#endif /* __POWERPC_KVM_HOST_H__ */
diff --git a/arch/powerpc/include/asm/kvm_para.h b/arch/powerpc/include/asm/kvm_para.h
index 50533f9adf4..7b754e74300 100644
--- a/arch/powerpc/include/asm/kvm_para.h
+++ b/arch/powerpc/include/asm/kvm_para.h
@@ -22,6 +22,16 @@
22 22
23#include <linux/types.h> 23#include <linux/types.h>
24 24
25/*
26 * Additions to this struct must only occur at the end, and should be
27 * accompanied by a KVM_MAGIC_FEAT flag to advertise that they are present
28 * (albeit not necessarily relevant to the current target hardware platform).
29 *
30 * Struct fields are always 32 or 64 bit aligned, depending on them being 32
31 * or 64 bit wide respectively.
32 *
33 * See Documentation/virtual/kvm/ppc-pv.txt
34 */
25struct kvm_vcpu_arch_shared { 35struct kvm_vcpu_arch_shared {
26 __u64 scratch1; 36 __u64 scratch1;
27 __u64 scratch2; 37 __u64 scratch2;
@@ -33,11 +43,35 @@ struct kvm_vcpu_arch_shared {
33 __u64 sprg3; 43 __u64 sprg3;
34 __u64 srr0; 44 __u64 srr0;
35 __u64 srr1; 45 __u64 srr1;
36 __u64 dar; 46 __u64 dar; /* dear on BookE */
37 __u64 msr; 47 __u64 msr;
38 __u32 dsisr; 48 __u32 dsisr;
39 __u32 int_pending; /* Tells the guest if we have an interrupt */ 49 __u32 int_pending; /* Tells the guest if we have an interrupt */
40 __u32 sr[16]; 50 __u32 sr[16];
51 __u32 mas0;
52 __u32 mas1;
53 __u64 mas7_3;
54 __u64 mas2;
55 __u32 mas4;
56 __u32 mas6;
57 __u32 esr;
58 __u32 pir;
59
60 /*
61 * SPRG4-7 are user-readable, so we can only keep these consistent
62 * between the shared area and the real registers when there's an
63 * intervening exit to KVM. This also applies to SPRG3 on some
64 * chips.
65 *
66 * This suffices for access by guest userspace, since in PR-mode
67 * KVM, an exit must occur when changing the guest's MSR[PR].
68 * If the guest kernel writes to SPRG3-7 via the shared area, it
69 * must also use the shared area for reading while in kernel space.
70 */
71 __u64 sprg4;
72 __u64 sprg5;
73 __u64 sprg6;
74 __u64 sprg7;
41}; 75};
42 76
43#define KVM_SC_MAGIC_R0 0x4b564d21 /* "KVM!" */ 77#define KVM_SC_MAGIC_R0 0x4b564d21 /* "KVM!" */
@@ -47,7 +81,10 @@ struct kvm_vcpu_arch_shared {
47 81
48#define KVM_FEATURE_MAGIC_PAGE 1 82#define KVM_FEATURE_MAGIC_PAGE 1
49 83
50#define KVM_MAGIC_FEAT_SR (1 << 0) 84#define KVM_MAGIC_FEAT_SR (1 << 0)
85
86/* MASn, ESR, PIR, and high SPRGs */
87#define KVM_MAGIC_FEAT_MAS0_TO_SPRG7 (1 << 1)
51 88
52#ifdef __KERNEL__ 89#ifdef __KERNEL__
53 90
diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h
index 46efd1a265c..9d6dee0f7d4 100644
--- a/arch/powerpc/include/asm/kvm_ppc.h
+++ b/arch/powerpc/include/asm/kvm_ppc.h
@@ -66,6 +66,7 @@ extern int kvmppc_emulate_instruction(struct kvm_run *run,
66extern int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu); 66extern int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu);
67extern void kvmppc_emulate_dec(struct kvm_vcpu *vcpu); 67extern void kvmppc_emulate_dec(struct kvm_vcpu *vcpu);
68extern u32 kvmppc_get_dec(struct kvm_vcpu *vcpu, u64 tb); 68extern u32 kvmppc_get_dec(struct kvm_vcpu *vcpu, u64 tb);
69extern void kvmppc_decrementer_func(unsigned long data);
69extern int kvmppc_sanity_check(struct kvm_vcpu *vcpu); 70extern int kvmppc_sanity_check(struct kvm_vcpu *vcpu);
70 71
71/* Core-specific hooks */ 72/* Core-specific hooks */
@@ -94,7 +95,7 @@ extern int kvmppc_core_vcpu_translate(struct kvm_vcpu *vcpu,
94extern void kvmppc_core_vcpu_load(struct kvm_vcpu *vcpu, int cpu); 95extern void kvmppc_core_vcpu_load(struct kvm_vcpu *vcpu, int cpu);
95extern void kvmppc_core_vcpu_put(struct kvm_vcpu *vcpu); 96extern void kvmppc_core_vcpu_put(struct kvm_vcpu *vcpu);
96 97
97extern void kvmppc_core_deliver_interrupts(struct kvm_vcpu *vcpu); 98extern void kvmppc_core_prepare_to_enter(struct kvm_vcpu *vcpu);
98extern int kvmppc_core_pending_dec(struct kvm_vcpu *vcpu); 99extern int kvmppc_core_pending_dec(struct kvm_vcpu *vcpu);
99extern void kvmppc_core_queue_program(struct kvm_vcpu *vcpu, ulong flags); 100extern void kvmppc_core_queue_program(struct kvm_vcpu *vcpu, ulong flags);
100extern void kvmppc_core_queue_dec(struct kvm_vcpu *vcpu); 101extern void kvmppc_core_queue_dec(struct kvm_vcpu *vcpu);
@@ -120,15 +121,17 @@ extern long kvmppc_alloc_hpt(struct kvm *kvm);
120extern void kvmppc_free_hpt(struct kvm *kvm); 121extern void kvmppc_free_hpt(struct kvm *kvm);
121extern long kvmppc_prepare_vrma(struct kvm *kvm, 122extern long kvmppc_prepare_vrma(struct kvm *kvm,
122 struct kvm_userspace_memory_region *mem); 123 struct kvm_userspace_memory_region *mem);
123extern void kvmppc_map_vrma(struct kvm *kvm, 124extern void kvmppc_map_vrma(struct kvm_vcpu *vcpu,
124 struct kvm_userspace_memory_region *mem); 125 struct kvm_memory_slot *memslot, unsigned long porder);
125extern int kvmppc_pseries_do_hcall(struct kvm_vcpu *vcpu); 126extern int kvmppc_pseries_do_hcall(struct kvm_vcpu *vcpu);
126extern long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm, 127extern long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm,
127 struct kvm_create_spapr_tce *args); 128 struct kvm_create_spapr_tce *args);
128extern long kvm_vm_ioctl_allocate_rma(struct kvm *kvm, 129extern long kvm_vm_ioctl_allocate_rma(struct kvm *kvm,
129 struct kvm_allocate_rma *rma); 130 struct kvm_allocate_rma *rma);
130extern struct kvmppc_rma_info *kvm_alloc_rma(void); 131extern struct kvmppc_linear_info *kvm_alloc_rma(void);
131extern void kvm_release_rma(struct kvmppc_rma_info *ri); 132extern void kvm_release_rma(struct kvmppc_linear_info *ri);
133extern struct kvmppc_linear_info *kvm_alloc_hpt(void);
134extern void kvm_release_hpt(struct kvmppc_linear_info *li);
132extern int kvmppc_core_init_vm(struct kvm *kvm); 135extern int kvmppc_core_init_vm(struct kvm *kvm);
133extern void kvmppc_core_destroy_vm(struct kvm *kvm); 136extern void kvmppc_core_destroy_vm(struct kvm *kvm);
134extern int kvmppc_core_prepare_memory_region(struct kvm *kvm, 137extern int kvmppc_core_prepare_memory_region(struct kvm *kvm,
@@ -175,6 +178,9 @@ int kvmppc_core_set_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs);
175void kvmppc_get_sregs_ivor(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs); 178void kvmppc_get_sregs_ivor(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs);
176int kvmppc_set_sregs_ivor(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs); 179int kvmppc_set_sregs_ivor(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs);
177 180
181int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg);
182int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg);
183
178void kvmppc_set_pid(struct kvm_vcpu *vcpu, u32 pid); 184void kvmppc_set_pid(struct kvm_vcpu *vcpu, u32 pid);
179 185
180#ifdef CONFIG_KVM_BOOK3S_64_HV 186#ifdef CONFIG_KVM_BOOK3S_64_HV
@@ -183,14 +189,19 @@ static inline void kvmppc_set_xics_phys(int cpu, unsigned long addr)
183 paca[cpu].kvm_hstate.xics_phys = addr; 189 paca[cpu].kvm_hstate.xics_phys = addr;
184} 190}
185 191
186extern void kvm_rma_init(void); 192extern void kvm_linear_init(void);
187 193
188#else 194#else
189static inline void kvmppc_set_xics_phys(int cpu, unsigned long addr) 195static inline void kvmppc_set_xics_phys(int cpu, unsigned long addr)
190{} 196{}
191 197
192static inline void kvm_rma_init(void) 198static inline void kvm_linear_init(void)
193{} 199{}
194#endif 200#endif
195 201
202int kvm_vcpu_ioctl_config_tlb(struct kvm_vcpu *vcpu,
203 struct kvm_config_tlb *cfg);
204int kvm_vcpu_ioctl_dirty_tlb(struct kvm_vcpu *vcpu,
205 struct kvm_dirty_tlb *cfg);
206
196#endif /* __POWERPC_KVM_PPC_H__ */ 207#endif /* __POWERPC_KVM_PPC_H__ */
diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index bf37931d1ad..42ce570812c 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -99,9 +99,7 @@ struct machdep_calls {
99 99
100 void (*init_IRQ)(void); 100 void (*init_IRQ)(void);
101 101
102 /* Return an irq, or NO_IRQ to indicate there are none pending. 102 /* Return an irq, or NO_IRQ to indicate there are none pending. */
103 * If for some reason there is no irq, but the interrupt
104 * shouldn't be counted as spurious, return NO_IRQ_IGNORE. */
105 unsigned int (*get_irq)(void); 103 unsigned int (*get_irq)(void);
106 104
107 /* PCI stuff */ 105 /* PCI stuff */
diff --git a/arch/powerpc/include/asm/mmu-book3e.h b/arch/powerpc/include/asm/mmu-book3e.h
index f5f89cafebd..cdb5421877e 100644
--- a/arch/powerpc/include/asm/mmu-book3e.h
+++ b/arch/powerpc/include/asm/mmu-book3e.h
@@ -41,9 +41,10 @@
41/* MAS registers bit definitions */ 41/* MAS registers bit definitions */
42 42
43#define MAS0_TLBSEL(x) (((x) << 28) & 0x30000000) 43#define MAS0_TLBSEL(x) (((x) << 28) & 0x30000000)
44#define MAS0_ESEL(x) (((x) << 16) & 0x0FFF0000)
45#define MAS0_NV(x) ((x) & 0x00000FFF)
46#define MAS0_ESEL_MASK 0x0FFF0000 44#define MAS0_ESEL_MASK 0x0FFF0000
45#define MAS0_ESEL_SHIFT 16
46#define MAS0_ESEL(x) (((x) << MAS0_ESEL_SHIFT) & MAS0_ESEL_MASK)
47#define MAS0_NV(x) ((x) & 0x00000FFF)
47#define MAS0_HES 0x00004000 48#define MAS0_HES 0x00004000
48#define MAS0_WQ_ALLWAYS 0x00000000 49#define MAS0_WQ_ALLWAYS 0x00000000
49#define MAS0_WQ_COND 0x00001000 50#define MAS0_WQ_COND 0x00001000
@@ -167,6 +168,7 @@
167#define TLBnCFG_MAXSIZE 0x000f0000 /* Maximum Page Size (v1.0) */ 168#define TLBnCFG_MAXSIZE 0x000f0000 /* Maximum Page Size (v1.0) */
168#define TLBnCFG_MAXSIZE_SHIFT 16 169#define TLBnCFG_MAXSIZE_SHIFT 16
169#define TLBnCFG_ASSOC 0xff000000 /* Associativity */ 170#define TLBnCFG_ASSOC 0xff000000 /* Associativity */
171#define TLBnCFG_ASSOC_SHIFT 24
170 172
171/* TLBnPS encoding */ 173/* TLBnPS encoding */
172#define TLBnPS_4K 0x00000004 174#define TLBnPS_4K 0x00000004
diff --git a/arch/powerpc/include/asm/mmu-hash64.h b/arch/powerpc/include/asm/mmu-hash64.h
index 412ba493cb9..1c65a59881e 100644
--- a/arch/powerpc/include/asm/mmu-hash64.h
+++ b/arch/powerpc/include/asm/mmu-hash64.h
@@ -108,11 +108,11 @@ extern char initial_stab[];
108#define HPTE_V_VRMA_MASK ASM_CONST(0x4001ffffff000000) 108#define HPTE_V_VRMA_MASK ASM_CONST(0x4001ffffff000000)
109 109
110/* Values for PP (assumes Ks=0, Kp=1) */ 110/* Values for PP (assumes Ks=0, Kp=1) */
111/* pp0 will always be 0 for linux */
112#define PP_RWXX 0 /* Supervisor read/write, User none */ 111#define PP_RWXX 0 /* Supervisor read/write, User none */
113#define PP_RWRX 1 /* Supervisor read/write, User read */ 112#define PP_RWRX 1 /* Supervisor read/write, User read */
114#define PP_RWRW 2 /* Supervisor read/write, User read/write */ 113#define PP_RWRW 2 /* Supervisor read/write, User read/write */
115#define PP_RXRX 3 /* Supervisor read, User read */ 114#define PP_RXRX 3 /* Supervisor read, User read */
115#define PP_RXXX (HPTE_R_PP0 | 2) /* Supervisor read, user none */
116 116
117#ifndef __ASSEMBLY__ 117#ifndef __ASSEMBLY__
118 118
@@ -267,7 +267,6 @@ extern void demote_segment_4k(struct mm_struct *mm, unsigned long addr);
267 267
268extern void hpte_init_native(void); 268extern void hpte_init_native(void);
269extern void hpte_init_lpar(void); 269extern void hpte_init_lpar(void);
270extern void hpte_init_iSeries(void);
271extern void hpte_init_beat(void); 270extern void hpte_init_beat(void);
272extern void hpte_init_beat_v3(void); 271extern void hpte_init_beat_v3(void);
273 272
@@ -325,9 +324,6 @@ extern void slb_set_size(u16 size);
325 * WARNING - If you change these you must make sure the asm 324 * WARNING - If you change these you must make sure the asm
326 * implementations in slb_allocate (slb_low.S), do_stab_bolted 325 * implementations in slb_allocate (slb_low.S), do_stab_bolted
327 * (head.S) and ASM_VSID_SCRAMBLE (below) are changed accordingly. 326 * (head.S) and ASM_VSID_SCRAMBLE (below) are changed accordingly.
328 *
329 * You'll also need to change the precomputed VSID values in head.S
330 * which are used by the iSeries firmware.
331 */ 327 */
332 328
333#define VSID_MULTIPLIER_256M ASM_CONST(200730139) /* 28-bit prime */ 329#define VSID_MULTIPLIER_256M ASM_CONST(200730139) /* 28-bit prime */
@@ -484,14 +480,6 @@ static inline unsigned long get_vsid(unsigned long context, unsigned long ea,
484 | (ea >> SID_SHIFT_1T), 1T); 480 | (ea >> SID_SHIFT_1T), 1T);
485} 481}
486 482
487/*
488 * This is only used on legacy iSeries in lparmap.c,
489 * hence the 256MB segment assumption.
490 */
491#define VSID_SCRAMBLE(pvsid) (((pvsid) * VSID_MULTIPLIER_256M) % \
492 VSID_MODULUS_256M)
493#define KERNEL_VSID(ea) VSID_SCRAMBLE(GET_ESID(ea))
494
495#endif /* __ASSEMBLY__ */ 483#endif /* __ASSEMBLY__ */
496 484
497#endif /* _ASM_POWERPC_MMU_HASH64_H_ */ 485#endif /* _ASM_POWERPC_MMU_HASH64_H_ */
diff --git a/arch/powerpc/include/asm/pci-bridge.h b/arch/powerpc/include/asm/pci-bridge.h
index 5d487657322..ac39e6a3b25 100644
--- a/arch/powerpc/include/asm/pci-bridge.h
+++ b/arch/powerpc/include/asm/pci-bridge.h
@@ -155,14 +155,7 @@ struct pci_dn {
155 155
156 struct pci_dev *pcidev; /* back-pointer to the pci device */ 156 struct pci_dev *pcidev; /* back-pointer to the pci device */
157#ifdef CONFIG_EEH 157#ifdef CONFIG_EEH
158 int class_code; /* pci device class */ 158 struct eeh_dev *edev; /* eeh device */
159 int eeh_mode; /* See eeh.h for possible EEH_MODEs */
160 int eeh_config_addr;
161 int eeh_pe_config_addr; /* new-style partition endpoint address */
162 int eeh_check_count; /* # times driver ignored error */
163 int eeh_freeze_count; /* # times this device froze up. */
164 int eeh_false_positives; /* # times this device reported #ff's */
165 u32 config_space[16]; /* saved PCI config space */
166#endif 159#endif
167#define IODA_INVALID_PE (-1) 160#define IODA_INVALID_PE (-1)
168#ifdef CONFIG_PPC_POWERNV 161#ifdef CONFIG_PPC_POWERNV
@@ -185,6 +178,13 @@ static inline int pci_device_from_OF_node(struct device_node *np,
185 return 0; 178 return 0;
186} 179}
187 180
181#if defined(CONFIG_EEH)
182static inline struct eeh_dev *of_node_to_eeh_dev(struct device_node *dn)
183{
184 return PCI_DN(dn)->edev;
185}
186#endif
187
188/** Find the bus corresponding to the indicated device node */ 188/** Find the bus corresponding to the indicated device node */
189extern struct pci_bus *pcibios_find_pci_bus(struct device_node *dn); 189extern struct pci_bus *pcibios_find_pci_bus(struct device_node *dn);
190 190
diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h
index f54b3d26ce9..6653f2743c4 100644
--- a/arch/powerpc/include/asm/pci.h
+++ b/arch/powerpc/include/asm/pci.h
@@ -154,14 +154,6 @@ extern int pci_mmap_legacy_page_range(struct pci_bus *bus,
154 154
155#endif /* CONFIG_PPC64 */ 155#endif /* CONFIG_PPC64 */
156 156
157extern void pcibios_resource_to_bus(struct pci_dev *dev,
158 struct pci_bus_region *region,
159 struct resource *res);
160
161extern void pcibios_bus_to_resource(struct pci_dev *dev,
162 struct resource *res,
163 struct pci_bus_region *region);
164
165extern void pcibios_claim_one_bus(struct pci_bus *b); 157extern void pcibios_claim_one_bus(struct pci_bus *b);
166 158
167extern void pcibios_finish_adding_to_bus(struct pci_bus *bus); 159extern void pcibios_finish_adding_to_bus(struct pci_bus *bus);
@@ -190,6 +182,7 @@ extern void pci_resource_to_user(const struct pci_dev *dev, int bar,
190 const struct resource *rsrc, 182 const struct resource *rsrc,
191 resource_size_t *start, resource_size_t *end); 183 resource_size_t *start, resource_size_t *end);
192 184
185extern resource_size_t pcibios_io_space_offset(struct pci_controller *hose);
193extern void pcibios_setup_bus_devices(struct pci_bus *bus); 186extern void pcibios_setup_bus_devices(struct pci_bus *bus);
194extern void pcibios_setup_bus_self(struct pci_bus *bus); 187extern void pcibios_setup_bus_self(struct pci_bus *bus);
195extern void pcibios_setup_phb_io_space(struct pci_controller *hose); 188extern void pcibios_setup_phb_io_space(struct pci_controller *hose);
diff --git a/arch/powerpc/include/asm/perf_event_server.h b/arch/powerpc/include/asm/perf_event_server.h
index 1a8093fa8f7..078019b5b35 100644
--- a/arch/powerpc/include/asm/perf_event_server.h
+++ b/arch/powerpc/include/asm/perf_event_server.h
@@ -47,6 +47,8 @@ struct power_pmu {
47 */ 47 */
48#define PPMU_LIMITED_PMC5_6 1 /* PMC5/6 have limited function */ 48#define PPMU_LIMITED_PMC5_6 1 /* PMC5/6 have limited function */
49#define PPMU_ALT_SIPR 2 /* uses alternate posn for SIPR/HV */ 49#define PPMU_ALT_SIPR 2 /* uses alternate posn for SIPR/HV */
50#define PPMU_NO_SIPR 4 /* no SIPR/HV in MMCRA at all */
51#define PPMU_NO_CONT_SAMPLING 8 /* no continuous sampling */
50 52
51/* 53/*
52 * Values for flags to get_alternatives() 54 * Values for flags to get_alternatives()
diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h
index e980faae422..d81f99430fe 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -45,6 +45,7 @@
45#define PPC_INST_MFSPR_DSCR_MASK 0xfc1fffff 45#define PPC_INST_MFSPR_DSCR_MASK 0xfc1fffff
46#define PPC_INST_MTSPR_DSCR 0x7c1103a6 46#define PPC_INST_MTSPR_DSCR 0x7c1103a6
47#define PPC_INST_MTSPR_DSCR_MASK 0xfc1fffff 47#define PPC_INST_MTSPR_DSCR_MASK 0xfc1fffff
48#define PPC_INST_SLBFEE 0x7c0007a7
48 49
49#define PPC_INST_STRING 0x7c00042a 50#define PPC_INST_STRING 0x7c00042a
50#define PPC_INST_STRING_MASK 0xfc0007fe 51#define PPC_INST_STRING_MASK 0xfc0007fe
@@ -183,7 +184,8 @@
183 __PPC_RS(t) | __PPC_RA(a) | __PPC_RB(b)) 184 __PPC_RS(t) | __PPC_RA(a) | __PPC_RB(b))
184#define PPC_ERATSX_DOT(t, a, w) stringify_in_c(.long PPC_INST_ERATSX_DOT | \ 185#define PPC_ERATSX_DOT(t, a, w) stringify_in_c(.long PPC_INST_ERATSX_DOT | \
185 __PPC_RS(t) | __PPC_RA(a) | __PPC_RB(b)) 186 __PPC_RS(t) | __PPC_RA(a) | __PPC_RB(b))
186 187#define PPC_SLBFEE_DOT(t, b) stringify_in_c(.long PPC_INST_SLBFEE | \
188 __PPC_RT(t) | __PPC_RB(b))
187 189
188/* 190/*
189 * Define what the VSX XX1 form instructions will look like, then add 191 * Define what the VSX XX1 form instructions will look like, then add
diff --git a/arch/powerpc/include/asm/ppc-pci.h b/arch/powerpc/include/asm/ppc-pci.h
index e660b37aa7d..80fa704d410 100644
--- a/arch/powerpc/include/asm/ppc-pci.h
+++ b/arch/powerpc/include/asm/ppc-pci.h
@@ -45,8 +45,6 @@ extern void init_pci_config_tokens (void);
45extern unsigned long get_phb_buid (struct device_node *); 45extern unsigned long get_phb_buid (struct device_node *);
46extern int rtas_setup_phb(struct pci_controller *phb); 46extern int rtas_setup_phb(struct pci_controller *phb);
47 47
48extern unsigned long pci_probe_only;
49
50#ifdef CONFIG_EEH 48#ifdef CONFIG_EEH
51 49
52void pci_addr_cache_build(void); 50void pci_addr_cache_build(void);
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index b1a215eabef..9d7f0fb6902 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -216,6 +216,7 @@
216#define DSISR_ISSTORE 0x02000000 /* access was a store */ 216#define DSISR_ISSTORE 0x02000000 /* access was a store */
217#define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */ 217#define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
218#define DSISR_NOSEGMENT 0x00200000 /* STAB/SLB miss */ 218#define DSISR_NOSEGMENT 0x00200000 /* STAB/SLB miss */
219#define DSISR_KEYFAULT 0x00200000 /* Key fault */
219#define SPRN_TBRL 0x10C /* Time Base Read Lower Register (user, R/O) */ 220#define SPRN_TBRL 0x10C /* Time Base Read Lower Register (user, R/O) */
220#define SPRN_TBRU 0x10D /* Time Base Read Upper Register (user, R/O) */ 221#define SPRN_TBRU 0x10D /* Time Base Read Upper Register (user, R/O) */
221#define SPRN_TBWL 0x11C /* Time Base Lower Register (super, R/W) */ 222#define SPRN_TBWL 0x11C /* Time Base Lower Register (super, R/W) */
@@ -237,6 +238,7 @@
237#define LPCR_ISL (1ul << (63-2)) 238#define LPCR_ISL (1ul << (63-2))
238#define LPCR_VC_SH (63-2) 239#define LPCR_VC_SH (63-2)
239#define LPCR_DPFD_SH (63-11) 240#define LPCR_DPFD_SH (63-11)
241#define LPCR_VRMASD (0x1ful << (63-16))
240#define LPCR_VRMA_L (1ul << (63-12)) 242#define LPCR_VRMA_L (1ul << (63-12))
241#define LPCR_VRMA_LP0 (1ul << (63-15)) 243#define LPCR_VRMA_LP0 (1ul << (63-15))
242#define LPCR_VRMA_LP1 (1ul << (63-16)) 244#define LPCR_VRMA_LP1 (1ul << (63-16))
@@ -493,6 +495,9 @@
493#define SPRN_SPRG7 0x117 /* Special Purpose Register General 7 */ 495#define SPRN_SPRG7 0x117 /* Special Purpose Register General 7 */
494#define SPRN_SRR0 0x01A /* Save/Restore Register 0 */ 496#define SPRN_SRR0 0x01A /* Save/Restore Register 0 */
495#define SPRN_SRR1 0x01B /* Save/Restore Register 1 */ 497#define SPRN_SRR1 0x01B /* Save/Restore Register 1 */
498#define SRR1_ISI_NOPT 0x40000000 /* ISI: Not found in hash */
499#define SRR1_ISI_N_OR_G 0x10000000 /* ISI: Access is no-exec or G */
500#define SRR1_ISI_PROT 0x08000000 /* ISI: Other protection fault */
496#define SRR1_WAKEMASK 0x00380000 /* reason for wakeup */ 501#define SRR1_WAKEMASK 0x00380000 /* reason for wakeup */
497#define SRR1_WAKESYSERR 0x00300000 /* System error */ 502#define SRR1_WAKESYSERR 0x00300000 /* System error */
498#define SRR1_WAKEEE 0x00200000 /* External interrupt */ 503#define SRR1_WAKEEE 0x00200000 /* External interrupt */
diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h
index 9d6c37a11ee..557cff845de 100644
--- a/arch/powerpc/include/asm/rtas.h
+++ b/arch/powerpc/include/asm/rtas.h
@@ -74,7 +74,6 @@ struct rtas_suspend_me_data {
74/* RTAS event classes */ 74/* RTAS event classes */
75#define RTAS_INTERNAL_ERROR 0x80000000 /* set bit 0 */ 75#define RTAS_INTERNAL_ERROR 0x80000000 /* set bit 0 */
76#define RTAS_EPOW_WARNING 0x40000000 /* set bit 1 */ 76#define RTAS_EPOW_WARNING 0x40000000 /* set bit 1 */
77#define RTAS_POWERMGM_EVENTS 0x20000000 /* set bit 2 */
78#define RTAS_HOTPLUG_EVENTS 0x10000000 /* set bit 3 */ 77#define RTAS_HOTPLUG_EVENTS 0x10000000 /* set bit 3 */
79#define RTAS_IO_EVENTS 0x08000000 /* set bit 4 */ 78#define RTAS_IO_EVENTS 0x08000000 /* set bit 4 */
80#define RTAS_EVENT_SCAN_ALL_EVENTS 0xffffffff 79#define RTAS_EVENT_SCAN_ALL_EVENTS 0xffffffff
@@ -204,6 +203,39 @@ struct rtas_ext_event_log_v6 {
204 /* Variable length. */ 203 /* Variable length. */
205}; 204};
206 205
206/* pSeries event log format */
207
208/* Two bytes ASCII section IDs */
209#define PSERIES_ELOG_SECT_ID_PRIV_HDR (('P' << 8) | 'H')
210#define PSERIES_ELOG_SECT_ID_USER_HDR (('U' << 8) | 'H')
211#define PSERIES_ELOG_SECT_ID_PRIMARY_SRC (('P' << 8) | 'S')
212#define PSERIES_ELOG_SECT_ID_EXTENDED_UH (('E' << 8) | 'H')
213#define PSERIES_ELOG_SECT_ID_FAILING_MTMS (('M' << 8) | 'T')
214#define PSERIES_ELOG_SECT_ID_SECONDARY_SRC (('S' << 8) | 'S')
215#define PSERIES_ELOG_SECT_ID_DUMP_LOCATOR (('D' << 8) | 'H')
216#define PSERIES_ELOG_SECT_ID_FW_ERROR (('S' << 8) | 'W')
217#define PSERIES_ELOG_SECT_ID_IMPACT_PART_ID (('L' << 8) | 'P')
218#define PSERIES_ELOG_SECT_ID_LOGIC_RESOURCE_ID (('L' << 8) | 'R')
219#define PSERIES_ELOG_SECT_ID_HMC_ID (('H' << 8) | 'M')
220#define PSERIES_ELOG_SECT_ID_EPOW (('E' << 8) | 'P')
221#define PSERIES_ELOG_SECT_ID_IO_EVENT (('I' << 8) | 'E')
222#define PSERIES_ELOG_SECT_ID_MANUFACT_INFO (('M' << 8) | 'I')
223#define PSERIES_ELOG_SECT_ID_CALL_HOME (('C' << 8) | 'H')
224#define PSERIES_ELOG_SECT_ID_USER_DEF (('U' << 8) | 'D')
225
226/* Vendor specific Platform Event Log Format, Version 6, section header */
227struct pseries_errorlog {
228 uint16_t id; /* 0x00 2-byte ASCII section ID */
229 uint16_t length; /* 0x02 Section length in bytes */
230 uint8_t version; /* 0x04 Section version */
231 uint8_t subtype; /* 0x05 Section subtype */
232 uint16_t creator_component; /* 0x06 Creator component ID */
233 uint8_t data[]; /* 0x08 Start of section data */
234};
235
236struct pseries_errorlog *get_pseries_errorlog(struct rtas_error_log *log,
237 uint16_t section_id);
238
207/* 239/*
208 * This can be set by the rtas_flash module so that it can get called 240 * This can be set by the rtas_flash module so that it can get called
209 * as the absolutely last thing before the kernel terminates. 241 * as the absolutely last thing before the kernel terminates.
diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
index adba970ce91..ebc24dc5b1a 100644
--- a/arch/powerpc/include/asm/smp.h
+++ b/arch/powerpc/include/asm/smp.h
@@ -122,7 +122,6 @@ extern void smp_muxed_ipi_set_data(int cpu, unsigned long data);
122extern void smp_muxed_ipi_message_pass(int cpu, int msg); 122extern void smp_muxed_ipi_message_pass(int cpu, int msg);
123extern irqreturn_t smp_ipi_demux(void); 123extern irqreturn_t smp_ipi_demux(void);
124 124
125void smp_init_iSeries(void);
126void smp_init_pSeries(void); 125void smp_init_pSeries(void);
127void smp_init_cell(void); 126void smp_init_cell(void);
128void smp_init_celleb(void); 127void smp_init_celleb(void);
diff --git a/arch/powerpc/include/asm/udbg.h b/arch/powerpc/include/asm/udbg.h
index 8338aef5a4d..b3038817b8d 100644
--- a/arch/powerpc/include/asm/udbg.h
+++ b/arch/powerpc/include/asm/udbg.h
@@ -44,7 +44,6 @@ extern void __init udbg_init_debug_lpar_hvsi(void);
44extern void __init udbg_init_pmac_realmode(void); 44extern void __init udbg_init_pmac_realmode(void);
45extern void __init udbg_init_maple_realmode(void); 45extern void __init udbg_init_maple_realmode(void);
46extern void __init udbg_init_pas_realmode(void); 46extern void __init udbg_init_pas_realmode(void);
47extern void __init udbg_init_iseries(void);
48extern void __init udbg_init_rtas_panel(void); 47extern void __init udbg_init_rtas_panel(void);
49extern void __init udbg_init_rtas_console(void); 48extern void __init udbg_init_rtas_console(void);
50extern void __init udbg_init_debug_beat(void); 49extern void __init udbg_init_debug_beat(void);
diff --git a/arch/powerpc/include/asm/vio.h b/arch/powerpc/include/asm/vio.h
index 0a290a19594..6bfd5ffe1d4 100644
--- a/arch/powerpc/include/asm/vio.h
+++ b/arch/powerpc/include/asm/vio.h
@@ -69,6 +69,7 @@ struct vio_dev {
69}; 69};
70 70
71struct vio_driver { 71struct vio_driver {
72 const char *name;
72 const struct vio_device_id *id_table; 73 const struct vio_device_id *id_table;
73 int (*probe)(struct vio_dev *dev, const struct vio_device_id *id); 74 int (*probe)(struct vio_dev *dev, const struct vio_device_id *id);
74 int (*remove)(struct vio_dev *dev); 75 int (*remove)(struct vio_dev *dev);
@@ -76,10 +77,17 @@ struct vio_driver {
76 * be loaded in a CMO environment if it uses DMA. 77 * be loaded in a CMO environment if it uses DMA.
77 */ 78 */
78 unsigned long (*get_desired_dma)(struct vio_dev *dev); 79 unsigned long (*get_desired_dma)(struct vio_dev *dev);
80 const struct dev_pm_ops *pm;
79 struct device_driver driver; 81 struct device_driver driver;
80}; 82};
81 83
82extern int vio_register_driver(struct vio_driver *drv); 84extern int __vio_register_driver(struct vio_driver *drv, struct module *owner,
85 const char *mod_name);
86/*
87 * vio_register_driver must be a macro so that KBUILD_MODNAME can be expanded
88 */
89#define vio_register_driver(driver) \
90 __vio_register_driver(driver, THIS_MODULE, KBUILD_MODNAME)
83extern void vio_unregister_driver(struct vio_driver *drv); 91extern void vio_unregister_driver(struct vio_driver *drv);
84 92
85extern int vio_cmo_entitlement_update(size_t); 93extern int vio_cmo_entitlement_update(size_t);
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index cc492e48ddf..34b8afe94a5 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -412,16 +412,23 @@ int main(void)
412 DEFINE(VCPU_SPRG2, offsetof(struct kvm_vcpu, arch.shregs.sprg2)); 412 DEFINE(VCPU_SPRG2, offsetof(struct kvm_vcpu, arch.shregs.sprg2));
413 DEFINE(VCPU_SPRG3, offsetof(struct kvm_vcpu, arch.shregs.sprg3)); 413 DEFINE(VCPU_SPRG3, offsetof(struct kvm_vcpu, arch.shregs.sprg3));
414#endif 414#endif
415 DEFINE(VCPU_SPRG4, offsetof(struct kvm_vcpu, arch.sprg4)); 415 DEFINE(VCPU_SHARED_SPRG4, offsetof(struct kvm_vcpu_arch_shared, sprg4));
416 DEFINE(VCPU_SPRG5, offsetof(struct kvm_vcpu, arch.sprg5)); 416 DEFINE(VCPU_SHARED_SPRG5, offsetof(struct kvm_vcpu_arch_shared, sprg5));
417 DEFINE(VCPU_SPRG6, offsetof(struct kvm_vcpu, arch.sprg6)); 417 DEFINE(VCPU_SHARED_SPRG6, offsetof(struct kvm_vcpu_arch_shared, sprg6));
418 DEFINE(VCPU_SPRG7, offsetof(struct kvm_vcpu, arch.sprg7)); 418 DEFINE(VCPU_SHARED_SPRG7, offsetof(struct kvm_vcpu_arch_shared, sprg7));
419 DEFINE(VCPU_SHADOW_PID, offsetof(struct kvm_vcpu, arch.shadow_pid)); 419 DEFINE(VCPU_SHADOW_PID, offsetof(struct kvm_vcpu, arch.shadow_pid));
420 DEFINE(VCPU_SHADOW_PID1, offsetof(struct kvm_vcpu, arch.shadow_pid1)); 420 DEFINE(VCPU_SHADOW_PID1, offsetof(struct kvm_vcpu, arch.shadow_pid1));
421 DEFINE(VCPU_SHARED, offsetof(struct kvm_vcpu, arch.shared)); 421 DEFINE(VCPU_SHARED, offsetof(struct kvm_vcpu, arch.shared));
422 DEFINE(VCPU_SHARED_MSR, offsetof(struct kvm_vcpu_arch_shared, msr)); 422 DEFINE(VCPU_SHARED_MSR, offsetof(struct kvm_vcpu_arch_shared, msr));
423 DEFINE(VCPU_SHADOW_MSR, offsetof(struct kvm_vcpu, arch.shadow_msr)); 423 DEFINE(VCPU_SHADOW_MSR, offsetof(struct kvm_vcpu, arch.shadow_msr));
424 424
425 DEFINE(VCPU_SHARED_MAS0, offsetof(struct kvm_vcpu_arch_shared, mas0));
426 DEFINE(VCPU_SHARED_MAS1, offsetof(struct kvm_vcpu_arch_shared, mas1));
427 DEFINE(VCPU_SHARED_MAS2, offsetof(struct kvm_vcpu_arch_shared, mas2));
428 DEFINE(VCPU_SHARED_MAS7_3, offsetof(struct kvm_vcpu_arch_shared, mas7_3));
429 DEFINE(VCPU_SHARED_MAS4, offsetof(struct kvm_vcpu_arch_shared, mas4));
430 DEFINE(VCPU_SHARED_MAS6, offsetof(struct kvm_vcpu_arch_shared, mas6));
431
425 /* book3s */ 432 /* book3s */
426#ifdef CONFIG_KVM_BOOK3S_64_HV 433#ifdef CONFIG_KVM_BOOK3S_64_HV
427 DEFINE(KVM_LPID, offsetof(struct kvm, arch.lpid)); 434 DEFINE(KVM_LPID, offsetof(struct kvm, arch.lpid));
@@ -434,6 +441,7 @@ int main(void)
434 DEFINE(KVM_LAST_VCPU, offsetof(struct kvm, arch.last_vcpu)); 441 DEFINE(KVM_LAST_VCPU, offsetof(struct kvm, arch.last_vcpu));
435 DEFINE(KVM_LPCR, offsetof(struct kvm, arch.lpcr)); 442 DEFINE(KVM_LPCR, offsetof(struct kvm, arch.lpcr));
436 DEFINE(KVM_RMOR, offsetof(struct kvm, arch.rmor)); 443 DEFINE(KVM_RMOR, offsetof(struct kvm, arch.rmor));
444 DEFINE(KVM_VRMA_SLB_V, offsetof(struct kvm, arch.vrma_slb_v));
437 DEFINE(VCPU_DSISR, offsetof(struct kvm_vcpu, arch.shregs.dsisr)); 445 DEFINE(VCPU_DSISR, offsetof(struct kvm_vcpu, arch.shregs.dsisr));
438 DEFINE(VCPU_DAR, offsetof(struct kvm_vcpu, arch.shregs.dar)); 446 DEFINE(VCPU_DAR, offsetof(struct kvm_vcpu, arch.shregs.dar));
439#endif 447#endif
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
index 2d0868a4e2f..cb705fdbb45 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -101,14 +101,14 @@ data_access_not_stab:
101END_MMU_FTR_SECTION_IFCLR(MMU_FTR_SLB) 101END_MMU_FTR_SECTION_IFCLR(MMU_FTR_SLB)
102#endif 102#endif
103 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, data_access_common, EXC_STD, 103 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, data_access_common, EXC_STD,
104 KVMTEST_PR, 0x300) 104 KVMTEST, 0x300)
105 105
106 . = 0x380 106 . = 0x380
107 .globl data_access_slb_pSeries 107 .globl data_access_slb_pSeries
108data_access_slb_pSeries: 108data_access_slb_pSeries:
109 HMT_MEDIUM 109 HMT_MEDIUM
110 SET_SCRATCH0(r13) 110 SET_SCRATCH0(r13)
111 EXCEPTION_PROLOG_1(PACA_EXSLB, KVMTEST_PR, 0x380) 111 EXCEPTION_PROLOG_1(PACA_EXSLB, KVMTEST, 0x380)
112 std r3,PACA_EXSLB+EX_R3(r13) 112 std r3,PACA_EXSLB+EX_R3(r13)
113 mfspr r3,SPRN_DAR 113 mfspr r3,SPRN_DAR
114#ifdef __DISABLED__ 114#ifdef __DISABLED__
@@ -330,8 +330,8 @@ do_stab_bolted_pSeries:
330 EXCEPTION_PROLOG_PSERIES_1(.do_stab_bolted, EXC_STD) 330 EXCEPTION_PROLOG_PSERIES_1(.do_stab_bolted, EXC_STD)
331#endif /* CONFIG_POWER4_ONLY */ 331#endif /* CONFIG_POWER4_ONLY */
332 332
333 KVM_HANDLER_PR_SKIP(PACA_EXGEN, EXC_STD, 0x300) 333 KVM_HANDLER_SKIP(PACA_EXGEN, EXC_STD, 0x300)
334 KVM_HANDLER_PR_SKIP(PACA_EXSLB, EXC_STD, 0x380) 334 KVM_HANDLER_SKIP(PACA_EXSLB, EXC_STD, 0x380)
335 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x400) 335 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x400)
336 KVM_HANDLER_PR(PACA_EXSLB, EXC_STD, 0x480) 336 KVM_HANDLER_PR(PACA_EXSLB, EXC_STD, 0x480)
337 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x900) 337 KVM_HANDLER_PR(PACA_EXGEN, EXC_STD, 0x900)
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 2c5635dce05..243dbabfe74 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -208,8 +208,8 @@ notrace void arch_local_irq_restore(unsigned long en)
208 * we are checking the "new" CPU instead of the old one. This 208 * we are checking the "new" CPU instead of the old one. This
209 * is only a problem if an event happened on the "old" CPU. 209 * is only a problem if an event happened on the "old" CPU.
210 * 210 *
211 * External interrupt events on non-iseries will have caused 211 * External interrupt events will have caused interrupts to
212 * interrupts to be hard-disabled, so there is no problem, we 212 * be hard-disabled, so there is no problem, we
213 * cannot have preempted. 213 * cannot have preempted.
214 */ 214 */
215 irq_happened = get_irq_happened(); 215 irq_happened = get_irq_happened();
@@ -445,9 +445,9 @@ void do_IRQ(struct pt_regs *regs)
445 may_hard_irq_enable(); 445 may_hard_irq_enable();
446 446
447 /* And finally process it */ 447 /* And finally process it */
448 if (irq != NO_IRQ && irq != NO_IRQ_IGNORE) 448 if (irq != NO_IRQ)
449 handle_one_irq(irq); 449 handle_one_irq(irq);
450 else if (irq != NO_IRQ_IGNORE) 450 else
451 __get_cpu_var(irq_stat).spurious_irqs++; 451 __get_cpu_var(irq_stat).spurious_irqs++;
452 452
453 irq_exit(); 453 irq_exit();
diff --git a/arch/powerpc/kernel/kvm.c b/arch/powerpc/kernel/kvm.c
index 2985338d0e1..62bdf238966 100644
--- a/arch/powerpc/kernel/kvm.c
+++ b/arch/powerpc/kernel/kvm.c
@@ -1,5 +1,6 @@
1/* 1/*
2 * Copyright (C) 2010 SUSE Linux Products GmbH. All rights reserved. 2 * Copyright (C) 2010 SUSE Linux Products GmbH. All rights reserved.
3 * Copyright 2010-2011 Freescale Semiconductor, Inc.
3 * 4 *
4 * Authors: 5 * Authors:
5 * Alexander Graf <agraf@suse.de> 6 * Alexander Graf <agraf@suse.de>
@@ -29,6 +30,7 @@
29#include <asm/sections.h> 30#include <asm/sections.h>
30#include <asm/cacheflush.h> 31#include <asm/cacheflush.h>
31#include <asm/disassemble.h> 32#include <asm/disassemble.h>
33#include <asm/ppc-opcode.h>
32 34
33#define KVM_MAGIC_PAGE (-4096L) 35#define KVM_MAGIC_PAGE (-4096L)
34#define magic_var(x) KVM_MAGIC_PAGE + offsetof(struct kvm_vcpu_arch_shared, x) 36#define magic_var(x) KVM_MAGIC_PAGE + offsetof(struct kvm_vcpu_arch_shared, x)
@@ -41,34 +43,30 @@
41#define KVM_INST_B 0x48000000 43#define KVM_INST_B 0x48000000
42#define KVM_INST_B_MASK 0x03ffffff 44#define KVM_INST_B_MASK 0x03ffffff
43#define KVM_INST_B_MAX 0x01ffffff 45#define KVM_INST_B_MAX 0x01ffffff
46#define KVM_INST_LI 0x38000000
44 47
45#define KVM_MASK_RT 0x03e00000 48#define KVM_MASK_RT 0x03e00000
46#define KVM_RT_30 0x03c00000 49#define KVM_RT_30 0x03c00000
47#define KVM_MASK_RB 0x0000f800 50#define KVM_MASK_RB 0x0000f800
48#define KVM_INST_MFMSR 0x7c0000a6 51#define KVM_INST_MFMSR 0x7c0000a6
49#define KVM_INST_MFSPR_SPRG0 0x7c1042a6 52
50#define KVM_INST_MFSPR_SPRG1 0x7c1142a6 53#define SPR_FROM 0
51#define KVM_INST_MFSPR_SPRG2 0x7c1242a6 54#define SPR_TO 0x100
52#define KVM_INST_MFSPR_SPRG3 0x7c1342a6 55
53#define KVM_INST_MFSPR_SRR0 0x7c1a02a6 56#define KVM_INST_SPR(sprn, moveto) (0x7c0002a6 | \
54#define KVM_INST_MFSPR_SRR1 0x7c1b02a6 57 (((sprn) & 0x1f) << 16) | \
55#define KVM_INST_MFSPR_DAR 0x7c1302a6 58 (((sprn) & 0x3e0) << 6) | \
56#define KVM_INST_MFSPR_DSISR 0x7c1202a6 59 (moveto))
57 60
58#define KVM_INST_MTSPR_SPRG0 0x7c1043a6 61#define KVM_INST_MFSPR(sprn) KVM_INST_SPR(sprn, SPR_FROM)
59#define KVM_INST_MTSPR_SPRG1 0x7c1143a6 62#define KVM_INST_MTSPR(sprn) KVM_INST_SPR(sprn, SPR_TO)
60#define KVM_INST_MTSPR_SPRG2 0x7c1243a6
61#define KVM_INST_MTSPR_SPRG3 0x7c1343a6
62#define KVM_INST_MTSPR_SRR0 0x7c1a03a6
63#define KVM_INST_MTSPR_SRR1 0x7c1b03a6
64#define KVM_INST_MTSPR_DAR 0x7c1303a6
65#define KVM_INST_MTSPR_DSISR 0x7c1203a6
66 63
67#define KVM_INST_TLBSYNC 0x7c00046c 64#define KVM_INST_TLBSYNC 0x7c00046c
68#define KVM_INST_MTMSRD_L0 0x7c000164 65#define KVM_INST_MTMSRD_L0 0x7c000164
69#define KVM_INST_MTMSRD_L1 0x7c010164 66#define KVM_INST_MTMSRD_L1 0x7c010164
70#define KVM_INST_MTMSR 0x7c000124 67#define KVM_INST_MTMSR 0x7c000124
71 68
69#define KVM_INST_WRTEE 0x7c000106
72#define KVM_INST_WRTEEI_0 0x7c000146 70#define KVM_INST_WRTEEI_0 0x7c000146
73#define KVM_INST_WRTEEI_1 0x7c008146 71#define KVM_INST_WRTEEI_1 0x7c008146
74 72
@@ -270,26 +268,27 @@ static void kvm_patch_ins_mtmsr(u32 *inst, u32 rt)
270 268
271#ifdef CONFIG_BOOKE 269#ifdef CONFIG_BOOKE
272 270
273extern u32 kvm_emulate_wrteei_branch_offs; 271extern u32 kvm_emulate_wrtee_branch_offs;
274extern u32 kvm_emulate_wrteei_ee_offs; 272extern u32 kvm_emulate_wrtee_reg_offs;
275extern u32 kvm_emulate_wrteei_len; 273extern u32 kvm_emulate_wrtee_orig_ins_offs;
276extern u32 kvm_emulate_wrteei[]; 274extern u32 kvm_emulate_wrtee_len;
275extern u32 kvm_emulate_wrtee[];
277 276
278static void kvm_patch_ins_wrteei(u32 *inst) 277static void kvm_patch_ins_wrtee(u32 *inst, u32 rt, int imm_one)
279{ 278{
280 u32 *p; 279 u32 *p;
281 int distance_start; 280 int distance_start;
282 int distance_end; 281 int distance_end;
283 ulong next_inst; 282 ulong next_inst;
284 283
285 p = kvm_alloc(kvm_emulate_wrteei_len * 4); 284 p = kvm_alloc(kvm_emulate_wrtee_len * 4);
286 if (!p) 285 if (!p)
287 return; 286 return;
288 287
289 /* Find out where we are and put everything there */ 288 /* Find out where we are and put everything there */
290 distance_start = (ulong)p - (ulong)inst; 289 distance_start = (ulong)p - (ulong)inst;
291 next_inst = ((ulong)inst + 4); 290 next_inst = ((ulong)inst + 4);
292 distance_end = next_inst - (ulong)&p[kvm_emulate_wrteei_branch_offs]; 291 distance_end = next_inst - (ulong)&p[kvm_emulate_wrtee_branch_offs];
293 292
294 /* Make sure we only write valid b instructions */ 293 /* Make sure we only write valid b instructions */
295 if (distance_start > KVM_INST_B_MAX) { 294 if (distance_start > KVM_INST_B_MAX) {
@@ -298,10 +297,65 @@ static void kvm_patch_ins_wrteei(u32 *inst)
298 } 297 }
299 298
300 /* Modify the chunk to fit the invocation */ 299 /* Modify the chunk to fit the invocation */
301 memcpy(p, kvm_emulate_wrteei, kvm_emulate_wrteei_len * 4); 300 memcpy(p, kvm_emulate_wrtee, kvm_emulate_wrtee_len * 4);
302 p[kvm_emulate_wrteei_branch_offs] |= distance_end & KVM_INST_B_MASK; 301 p[kvm_emulate_wrtee_branch_offs] |= distance_end & KVM_INST_B_MASK;
303 p[kvm_emulate_wrteei_ee_offs] |= (*inst & MSR_EE); 302
304 flush_icache_range((ulong)p, (ulong)p + kvm_emulate_wrteei_len * 4); 303 if (imm_one) {
304 p[kvm_emulate_wrtee_reg_offs] =
305 KVM_INST_LI | __PPC_RT(30) | MSR_EE;
306 } else {
307 /* Make clobbered registers work too */
308 switch (get_rt(rt)) {
309 case 30:
310 kvm_patch_ins_ll(&p[kvm_emulate_wrtee_reg_offs],
311 magic_var(scratch2), KVM_RT_30);
312 break;
313 case 31:
314 kvm_patch_ins_ll(&p[kvm_emulate_wrtee_reg_offs],
315 magic_var(scratch1), KVM_RT_30);
316 break;
317 default:
318 p[kvm_emulate_wrtee_reg_offs] |= rt;
319 break;
320 }
321 }
322
323 p[kvm_emulate_wrtee_orig_ins_offs] = *inst;
324 flush_icache_range((ulong)p, (ulong)p + kvm_emulate_wrtee_len * 4);
325
326 /* Patch the invocation */
327 kvm_patch_ins_b(inst, distance_start);
328}
329
330extern u32 kvm_emulate_wrteei_0_branch_offs;
331extern u32 kvm_emulate_wrteei_0_len;
332extern u32 kvm_emulate_wrteei_0[];
333
334static void kvm_patch_ins_wrteei_0(u32 *inst)
335{
336 u32 *p;
337 int distance_start;
338 int distance_end;
339 ulong next_inst;
340
341 p = kvm_alloc(kvm_emulate_wrteei_0_len * 4);
342 if (!p)
343 return;
344
345 /* Find out where we are and put everything there */
346 distance_start = (ulong)p - (ulong)inst;
347 next_inst = ((ulong)inst + 4);
348 distance_end = next_inst - (ulong)&p[kvm_emulate_wrteei_0_branch_offs];
349
350 /* Make sure we only write valid b instructions */
351 if (distance_start > KVM_INST_B_MAX) {
352 kvm_patching_worked = false;
353 return;
354 }
355
356 memcpy(p, kvm_emulate_wrteei_0, kvm_emulate_wrteei_0_len * 4);
357 p[kvm_emulate_wrteei_0_branch_offs] |= distance_end & KVM_INST_B_MASK;
358 flush_icache_range((ulong)p, (ulong)p + kvm_emulate_wrteei_0_len * 4);
305 359
306 /* Patch the invocation */ 360 /* Patch the invocation */
307 kvm_patch_ins_b(inst, distance_start); 361 kvm_patch_ins_b(inst, distance_start);
@@ -380,56 +434,191 @@ static void kvm_check_ins(u32 *inst, u32 features)
380 case KVM_INST_MFMSR: 434 case KVM_INST_MFMSR:
381 kvm_patch_ins_ld(inst, magic_var(msr), inst_rt); 435 kvm_patch_ins_ld(inst, magic_var(msr), inst_rt);
382 break; 436 break;
383 case KVM_INST_MFSPR_SPRG0: 437 case KVM_INST_MFSPR(SPRN_SPRG0):
384 kvm_patch_ins_ld(inst, magic_var(sprg0), inst_rt); 438 kvm_patch_ins_ld(inst, magic_var(sprg0), inst_rt);
385 break; 439 break;
386 case KVM_INST_MFSPR_SPRG1: 440 case KVM_INST_MFSPR(SPRN_SPRG1):
387 kvm_patch_ins_ld(inst, magic_var(sprg1), inst_rt); 441 kvm_patch_ins_ld(inst, magic_var(sprg1), inst_rt);
388 break; 442 break;
389 case KVM_INST_MFSPR_SPRG2: 443 case KVM_INST_MFSPR(SPRN_SPRG2):
390 kvm_patch_ins_ld(inst, magic_var(sprg2), inst_rt); 444 kvm_patch_ins_ld(inst, magic_var(sprg2), inst_rt);
391 break; 445 break;
392 case KVM_INST_MFSPR_SPRG3: 446 case KVM_INST_MFSPR(SPRN_SPRG3):
393 kvm_patch_ins_ld(inst, magic_var(sprg3), inst_rt); 447 kvm_patch_ins_ld(inst, magic_var(sprg3), inst_rt);
394 break; 448 break;
395 case KVM_INST_MFSPR_SRR0: 449 case KVM_INST_MFSPR(SPRN_SRR0):
396 kvm_patch_ins_ld(inst, magic_var(srr0), inst_rt); 450 kvm_patch_ins_ld(inst, magic_var(srr0), inst_rt);
397 break; 451 break;
398 case KVM_INST_MFSPR_SRR1: 452 case KVM_INST_MFSPR(SPRN_SRR1):
399 kvm_patch_ins_ld(inst, magic_var(srr1), inst_rt); 453 kvm_patch_ins_ld(inst, magic_var(srr1), inst_rt);
400 break; 454 break;
401 case KVM_INST_MFSPR_DAR: 455#ifdef CONFIG_BOOKE
456 case KVM_INST_MFSPR(SPRN_DEAR):
457#else
458 case KVM_INST_MFSPR(SPRN_DAR):
459#endif
402 kvm_patch_ins_ld(inst, magic_var(dar), inst_rt); 460 kvm_patch_ins_ld(inst, magic_var(dar), inst_rt);
403 break; 461 break;
404 case KVM_INST_MFSPR_DSISR: 462 case KVM_INST_MFSPR(SPRN_DSISR):
405 kvm_patch_ins_lwz(inst, magic_var(dsisr), inst_rt); 463 kvm_patch_ins_lwz(inst, magic_var(dsisr), inst_rt);
406 break; 464 break;
407 465
466#ifdef CONFIG_PPC_BOOK3E_MMU
467 case KVM_INST_MFSPR(SPRN_MAS0):
468 if (features & KVM_MAGIC_FEAT_MAS0_TO_SPRG7)
469 kvm_patch_ins_lwz(inst, magic_var(mas0), inst_rt);
470 break;
471 case KVM_INST_MFSPR(SPRN_MAS1):
472 if (features & KVM_MAGIC_FEAT_MAS0_TO_SPRG7)
473 kvm_patch_ins_lwz(inst, magic_var(mas1), inst_rt);
474 break;
475 case KVM_INST_MFSPR(SPRN_MAS2):
476 if (features & KVM_MAGIC_FEAT_MAS0_TO_SPRG7)
477 kvm_patch_ins_ld(inst, magic_var(mas2), inst_rt);
478 break;
479 case KVM_INST_MFSPR(SPRN_MAS3):
480 if (features & KVM_MAGIC_FEAT_MAS0_TO_SPRG7)
481 kvm_patch_ins_lwz(inst, magic_var(mas7_3) + 4, inst_rt);
482 break;
483 case KVM_INST_MFSPR(SPRN_MAS4):
484 if (features & KVM_MAGIC_FEAT_MAS0_TO_SPRG7)
485 kvm_patch_ins_lwz(inst, magic_var(mas4), inst_rt);
486 break;
487 case KVM_INST_MFSPR(SPRN_MAS6):
488 if (features & KVM_MAGIC_FEAT_MAS0_TO_SPRG7)
489 kvm_patch_ins_lwz(inst, magic_var(mas6), inst_rt);
490 break;
491 case KVM_INST_MFSPR(SPRN_MAS7):
492 if (features & KVM_MAGIC_FEAT_MAS0_TO_SPRG7)
493 kvm_patch_ins_lwz(inst, magic_var(mas7_3), inst_rt);
494 break;
495#endif /* CONFIG_PPC_BOOK3E_MMU */
496
497 case KVM_INST_MFSPR(SPRN_SPRG4):
498#ifdef CONFIG_BOOKE
499 case KVM_INST_MFSPR(SPRN_SPRG4R):
500#endif
501 if (features & KVM_MAGIC_FEAT_MAS0_TO_SPRG7)
502 kvm_patch_ins_ld(inst, magic_var(sprg4), inst_rt);
503 break;
504 case KVM_INST_MFSPR(SPRN_SPRG5):
505#ifdef CONFIG_BOOKE
506 case KVM_INST_MFSPR(SPRN_SPRG5R):
507#endif
508 if (features & KVM_MAGIC_FEAT_MAS0_TO_SPRG7)
509 kvm_patch_ins_ld(inst, magic_var(sprg5), inst_rt);
510 break;
511 case KVM_INST_MFSPR(SPRN_SPRG6):
512#ifdef CONFIG_BOOKE
513 case KVM_INST_MFSPR(SPRN_SPRG6R):
514#endif
515 if (features & KVM_MAGIC_FEAT_MAS0_TO_SPRG7)
516 kvm_patch_ins_ld(inst, magic_var(sprg6), inst_rt);
517 break;
518 case KVM_INST_MFSPR(SPRN_SPRG7):
519#ifdef CONFIG_BOOKE
520 case KVM_INST_MFSPR(SPRN_SPRG7R):
521#endif
522 if (features & KVM_MAGIC_FEAT_MAS0_TO_SPRG7)
523 kvm_patch_ins_ld(inst, magic_var(sprg7), inst_rt);
524 break;
525
526#ifdef CONFIG_BOOKE
527 case KVM_INST_MFSPR(SPRN_ESR):
528 if (features & KVM_MAGIC_FEAT_MAS0_TO_SPRG7)
529 kvm_patch_ins_lwz(inst, magic_var(esr), inst_rt);
530 break;
531#endif
532
533 case KVM_INST_MFSPR(SPRN_PIR):
534 if (features & KVM_MAGIC_FEAT_MAS0_TO_SPRG7)
535 kvm_patch_ins_lwz(inst, magic_var(pir), inst_rt);
536 break;
537
538
408 /* Stores */ 539 /* Stores */
409 case KVM_INST_MTSPR_SPRG0: 540 case KVM_INST_MTSPR(SPRN_SPRG0):
410 kvm_patch_ins_std(inst, magic_var(sprg0), inst_rt); 541 kvm_patch_ins_std(inst, magic_var(sprg0), inst_rt);
411 break; 542 break;
412 case KVM_INST_MTSPR_SPRG1: 543 case KVM_INST_MTSPR(SPRN_SPRG1):
413 kvm_patch_ins_std(inst, magic_var(sprg1), inst_rt); 544 kvm_patch_ins_std(inst, magic_var(sprg1), inst_rt);
414 break; 545 break;
415 case KVM_INST_MTSPR_SPRG2: 546 case KVM_INST_MTSPR(SPRN_SPRG2):
416 kvm_patch_ins_std(inst, magic_var(sprg2), inst_rt); 547 kvm_patch_ins_std(inst, magic_var(sprg2), inst_rt);
417 break; 548 break;
418 case KVM_INST_MTSPR_SPRG3: 549 case KVM_INST_MTSPR(SPRN_SPRG3):
419 kvm_patch_ins_std(inst, magic_var(sprg3), inst_rt); 550 kvm_patch_ins_std(inst, magic_var(sprg3), inst_rt);
420 break; 551 break;
421 case KVM_INST_MTSPR_SRR0: 552 case KVM_INST_MTSPR(SPRN_SRR0):
422 kvm_patch_ins_std(inst, magic_var(srr0), inst_rt); 553 kvm_patch_ins_std(inst, magic_var(srr0), inst_rt);
423 break; 554 break;
424 case KVM_INST_MTSPR_SRR1: 555 case KVM_INST_MTSPR(SPRN_SRR1):
425 kvm_patch_ins_std(inst, magic_var(srr1), inst_rt); 556 kvm_patch_ins_std(inst, magic_var(srr1), inst_rt);
426 break; 557 break;
427 case KVM_INST_MTSPR_DAR: 558#ifdef CONFIG_BOOKE
559 case KVM_INST_MTSPR(SPRN_DEAR):
560#else
561 case KVM_INST_MTSPR(SPRN_DAR):
562#endif
428 kvm_patch_ins_std(inst, magic_var(dar), inst_rt); 563 kvm_patch_ins_std(inst, magic_var(dar), inst_rt);
429 break; 564 break;
430 case KVM_INST_MTSPR_DSISR: 565 case KVM_INST_MTSPR(SPRN_DSISR):
431 kvm_patch_ins_stw(inst, magic_var(dsisr), inst_rt); 566 kvm_patch_ins_stw(inst, magic_var(dsisr), inst_rt);
432 break; 567 break;
568#ifdef CONFIG_PPC_BOOK3E_MMU
569 case KVM_INST_MTSPR(SPRN_MAS0):
570 if (features & KVM_MAGIC_FEAT_MAS0_TO_SPRG7)
571 kvm_patch_ins_stw(inst, magic_var(mas0), inst_rt);
572 break;
573 case KVM_INST_MTSPR(SPRN_MAS1):
574 if (features & KVM_MAGIC_FEAT_MAS0_TO_SPRG7)
575 kvm_patch_ins_stw(inst, magic_var(mas1), inst_rt);
576 break;
577 case KVM_INST_MTSPR(SPRN_MAS2):
578 if (features & KVM_MAGIC_FEAT_MAS0_TO_SPRG7)
579 kvm_patch_ins_std(inst, magic_var(mas2), inst_rt);
580 break;
581 case KVM_INST_MTSPR(SPRN_MAS3):
582 if (features & KVM_MAGIC_FEAT_MAS0_TO_SPRG7)
583 kvm_patch_ins_stw(inst, magic_var(mas7_3) + 4, inst_rt);
584 break;
585 case KVM_INST_MTSPR(SPRN_MAS4):
586 if (features & KVM_MAGIC_FEAT_MAS0_TO_SPRG7)
587 kvm_patch_ins_stw(inst, magic_var(mas4), inst_rt);
588 break;
589 case KVM_INST_MTSPR(SPRN_MAS6):
590 if (features & KVM_MAGIC_FEAT_MAS0_TO_SPRG7)
591 kvm_patch_ins_stw(inst, magic_var(mas6), inst_rt);
592 break;
593 case KVM_INST_MTSPR(SPRN_MAS7):
594 if (features & KVM_MAGIC_FEAT_MAS0_TO_SPRG7)
595 kvm_patch_ins_stw(inst, magic_var(mas7_3), inst_rt);
596 break;
597#endif /* CONFIG_PPC_BOOK3E_MMU */
598
599 case KVM_INST_MTSPR(SPRN_SPRG4):
600 if (features & KVM_MAGIC_FEAT_MAS0_TO_SPRG7)
601 kvm_patch_ins_std(inst, magic_var(sprg4), inst_rt);
602 break;
603 case KVM_INST_MTSPR(SPRN_SPRG5):
604 if (features & KVM_MAGIC_FEAT_MAS0_TO_SPRG7)
605 kvm_patch_ins_std(inst, magic_var(sprg5), inst_rt);
606 break;
607 case KVM_INST_MTSPR(SPRN_SPRG6):
608 if (features & KVM_MAGIC_FEAT_MAS0_TO_SPRG7)
609 kvm_patch_ins_std(inst, magic_var(sprg6), inst_rt);
610 break;
611 case KVM_INST_MTSPR(SPRN_SPRG7):
612 if (features & KVM_MAGIC_FEAT_MAS0_TO_SPRG7)
613 kvm_patch_ins_std(inst, magic_var(sprg7), inst_rt);
614 break;
615
616#ifdef CONFIG_BOOKE
617 case KVM_INST_MTSPR(SPRN_ESR):
618 if (features & KVM_MAGIC_FEAT_MAS0_TO_SPRG7)
619 kvm_patch_ins_stw(inst, magic_var(esr), inst_rt);
620 break;
621#endif
433 622
434 /* Nops */ 623 /* Nops */
435 case KVM_INST_TLBSYNC: 624 case KVM_INST_TLBSYNC:
@@ -444,6 +633,11 @@ static void kvm_check_ins(u32 *inst, u32 features)
444 case KVM_INST_MTMSRD_L0: 633 case KVM_INST_MTMSRD_L0:
445 kvm_patch_ins_mtmsr(inst, inst_rt); 634 kvm_patch_ins_mtmsr(inst, inst_rt);
446 break; 635 break;
636#ifdef CONFIG_BOOKE
637 case KVM_INST_WRTEE:
638 kvm_patch_ins_wrtee(inst, inst_rt, 0);
639 break;
640#endif
447 } 641 }
448 642
449 switch (inst_no_rt & ~KVM_MASK_RB) { 643 switch (inst_no_rt & ~KVM_MASK_RB) {
@@ -461,13 +655,19 @@ static void kvm_check_ins(u32 *inst, u32 features)
461 switch (_inst) { 655 switch (_inst) {
462#ifdef CONFIG_BOOKE 656#ifdef CONFIG_BOOKE
463 case KVM_INST_WRTEEI_0: 657 case KVM_INST_WRTEEI_0:
658 kvm_patch_ins_wrteei_0(inst);
659 break;
660
464 case KVM_INST_WRTEEI_1: 661 case KVM_INST_WRTEEI_1:
465 kvm_patch_ins_wrteei(inst); 662 kvm_patch_ins_wrtee(inst, 0, 1);
466 break; 663 break;
467#endif 664#endif
468 } 665 }
469} 666}
470 667
668extern u32 kvm_template_start[];
669extern u32 kvm_template_end[];
670
471static void kvm_use_magic_page(void) 671static void kvm_use_magic_page(void)
472{ 672{
473 u32 *p; 673 u32 *p;
@@ -488,8 +688,23 @@ static void kvm_use_magic_page(void)
488 start = (void*)_stext; 688 start = (void*)_stext;
489 end = (void*)_etext; 689 end = (void*)_etext;
490 690
491 for (p = start; p < end; p++) 691 /*
692 * Being interrupted in the middle of patching would
693 * be bad for SPRG4-7, which KVM can't keep in sync
694 * with emulated accesses because reads don't trap.
695 */
696 local_irq_disable();
697
698 for (p = start; p < end; p++) {
699 /* Avoid patching the template code */
700 if (p >= kvm_template_start && p < kvm_template_end) {
701 p = kvm_template_end - 1;
702 continue;
703 }
492 kvm_check_ins(p, features); 704 kvm_check_ins(p, features);
705 }
706
707 local_irq_enable();
493 708
494 printk(KERN_INFO "KVM: Live patching for a fast VM %s\n", 709 printk(KERN_INFO "KVM: Live patching for a fast VM %s\n",
495 kvm_patching_worked ? "worked" : "failed"); 710 kvm_patching_worked ? "worked" : "failed");
diff --git a/arch/powerpc/kernel/kvm_emul.S b/arch/powerpc/kernel/kvm_emul.S
index f2b1b2523e6..e291cf3cf95 100644
--- a/arch/powerpc/kernel/kvm_emul.S
+++ b/arch/powerpc/kernel/kvm_emul.S
@@ -13,6 +13,7 @@
13 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 13 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14 * 14 *
15 * Copyright SUSE Linux Products GmbH 2010 15 * Copyright SUSE Linux Products GmbH 2010
16 * Copyright 2010-2011 Freescale Semiconductor, Inc.
16 * 17 *
17 * Authors: Alexander Graf <agraf@suse.de> 18 * Authors: Alexander Graf <agraf@suse.de>
18 */ 19 */
@@ -65,6 +66,9 @@ kvm_hypercall_start:
65 shared->critical == r1 and r2 is always != r1 */ \ 66 shared->critical == r1 and r2 is always != r1 */ \
66 STL64(r2, KVM_MAGIC_PAGE + KVM_MAGIC_CRITICAL, 0); 67 STL64(r2, KVM_MAGIC_PAGE + KVM_MAGIC_CRITICAL, 0);
67 68
69.global kvm_template_start
70kvm_template_start:
71
68.global kvm_emulate_mtmsrd 72.global kvm_emulate_mtmsrd
69kvm_emulate_mtmsrd: 73kvm_emulate_mtmsrd:
70 74
@@ -167,6 +171,9 @@ maybe_stay_in_guest:
167kvm_emulate_mtmsr_reg2: 171kvm_emulate_mtmsr_reg2:
168 ori r30, r0, 0 172 ori r30, r0, 0
169 173
174 /* Put MSR into magic page because we don't call mtmsr */
175 STL64(r30, KVM_MAGIC_PAGE + KVM_MAGIC_MSR, 0)
176
170 /* Check if we have to fetch an interrupt */ 177 /* Check if we have to fetch an interrupt */
171 lwz r31, (KVM_MAGIC_PAGE + KVM_MAGIC_INT)(0) 178 lwz r31, (KVM_MAGIC_PAGE + KVM_MAGIC_INT)(0)
172 cmpwi r31, 0 179 cmpwi r31, 0
@@ -174,15 +181,10 @@ kvm_emulate_mtmsr_reg2:
174 181
175 /* Check if we may trigger an interrupt */ 182 /* Check if we may trigger an interrupt */
176 andi. r31, r30, MSR_EE 183 andi. r31, r30, MSR_EE
177 beq no_mtmsr 184 bne do_mtmsr
178
179 b do_mtmsr
180 185
181no_mtmsr: 186no_mtmsr:
182 187
183 /* Put MSR into magic page because we don't call mtmsr */
184 STL64(r30, KVM_MAGIC_PAGE + KVM_MAGIC_MSR, 0)
185
186 SCRATCH_RESTORE 188 SCRATCH_RESTORE
187 189
188 /* Go back to caller */ 190 /* Go back to caller */
@@ -210,24 +212,80 @@ kvm_emulate_mtmsr_orig_ins_offs:
210kvm_emulate_mtmsr_len: 212kvm_emulate_mtmsr_len:
211 .long (kvm_emulate_mtmsr_end - kvm_emulate_mtmsr) / 4 213 .long (kvm_emulate_mtmsr_end - kvm_emulate_mtmsr) / 4
212 214
215/* also used for wrteei 1 */
216.global kvm_emulate_wrtee
217kvm_emulate_wrtee:
218
219 SCRATCH_SAVE
220
221 /* Fetch old MSR in r31 */
222 LL64(r31, KVM_MAGIC_PAGE + KVM_MAGIC_MSR, 0)
223
224 /* Insert new MSR[EE] */
225kvm_emulate_wrtee_reg:
226 ori r30, r0, 0
227 rlwimi r31, r30, 0, MSR_EE
228
229 /*
230 * If MSR[EE] is now set, check for a pending interrupt.
231 * We could skip this if MSR[EE] was already on, but that
232 * should be rare, so don't bother.
233 */
234 andi. r30, r30, MSR_EE
235
236 /* Put MSR into magic page because we don't call wrtee */
237 STL64(r31, KVM_MAGIC_PAGE + KVM_MAGIC_MSR, 0)
238
239 beq no_wrtee
240
241 /* Check if we have to fetch an interrupt */
242 lwz r30, (KVM_MAGIC_PAGE + KVM_MAGIC_INT)(0)
243 cmpwi r30, 0
244 bne do_wrtee
245
246no_wrtee:
247 SCRATCH_RESTORE
248
249 /* Go back to caller */
250kvm_emulate_wrtee_branch:
251 b .
252
253do_wrtee:
254 SCRATCH_RESTORE
213 255
256 /* Just fire off the wrtee if it's critical */
257kvm_emulate_wrtee_orig_ins:
258 wrtee r0
214 259
215.global kvm_emulate_wrteei 260 b kvm_emulate_wrtee_branch
216kvm_emulate_wrteei:
217 261
262kvm_emulate_wrtee_end:
263
264.global kvm_emulate_wrtee_branch_offs
265kvm_emulate_wrtee_branch_offs:
266 .long (kvm_emulate_wrtee_branch - kvm_emulate_wrtee) / 4
267
268.global kvm_emulate_wrtee_reg_offs
269kvm_emulate_wrtee_reg_offs:
270 .long (kvm_emulate_wrtee_reg - kvm_emulate_wrtee) / 4
271
272.global kvm_emulate_wrtee_orig_ins_offs
273kvm_emulate_wrtee_orig_ins_offs:
274 .long (kvm_emulate_wrtee_orig_ins - kvm_emulate_wrtee) / 4
275
276.global kvm_emulate_wrtee_len
277kvm_emulate_wrtee_len:
278 .long (kvm_emulate_wrtee_end - kvm_emulate_wrtee) / 4
279
280.global kvm_emulate_wrteei_0
281kvm_emulate_wrteei_0:
218 SCRATCH_SAVE 282 SCRATCH_SAVE
219 283
220 /* Fetch old MSR in r31 */ 284 /* Fetch old MSR in r31 */
221 LL64(r31, KVM_MAGIC_PAGE + KVM_MAGIC_MSR, 0) 285 LL64(r31, KVM_MAGIC_PAGE + KVM_MAGIC_MSR, 0)
222 286
223 /* Remove MSR_EE from old MSR */ 287 /* Remove MSR_EE from old MSR */
224 li r30, 0 288 rlwinm r31, r31, 0, ~MSR_EE
225 ori r30, r30, MSR_EE
226 andc r31, r31, r30
227
228 /* OR new MSR_EE onto the old MSR */
229kvm_emulate_wrteei_ee:
230 ori r31, r31, 0
231 289
232 /* Write new MSR value back */ 290 /* Write new MSR value back */
233 STL64(r31, KVM_MAGIC_PAGE + KVM_MAGIC_MSR, 0) 291 STL64(r31, KVM_MAGIC_PAGE + KVM_MAGIC_MSR, 0)
@@ -235,22 +293,17 @@ kvm_emulate_wrteei_ee:
235 SCRATCH_RESTORE 293 SCRATCH_RESTORE
236 294
237 /* Go back to caller */ 295 /* Go back to caller */
238kvm_emulate_wrteei_branch: 296kvm_emulate_wrteei_0_branch:
239 b . 297 b .
240kvm_emulate_wrteei_end: 298kvm_emulate_wrteei_0_end:
241
242.global kvm_emulate_wrteei_branch_offs
243kvm_emulate_wrteei_branch_offs:
244 .long (kvm_emulate_wrteei_branch - kvm_emulate_wrteei) / 4
245 299
246.global kvm_emulate_wrteei_ee_offs 300.global kvm_emulate_wrteei_0_branch_offs
247kvm_emulate_wrteei_ee_offs: 301kvm_emulate_wrteei_0_branch_offs:
248 .long (kvm_emulate_wrteei_ee - kvm_emulate_wrteei) / 4 302 .long (kvm_emulate_wrteei_0_branch - kvm_emulate_wrteei_0) / 4
249
250.global kvm_emulate_wrteei_len
251kvm_emulate_wrteei_len:
252 .long (kvm_emulate_wrteei_end - kvm_emulate_wrteei) / 4
253 303
304.global kvm_emulate_wrteei_0_len
305kvm_emulate_wrteei_0_len:
306 .long (kvm_emulate_wrteei_0_end - kvm_emulate_wrteei_0) / 4
254 307
255.global kvm_emulate_mtsrin 308.global kvm_emulate_mtsrin
256kvm_emulate_mtsrin: 309kvm_emulate_mtsrin:
@@ -300,3 +353,6 @@ kvm_emulate_mtsrin_orig_ins_offs:
300.global kvm_emulate_mtsrin_len 353.global kvm_emulate_mtsrin_len
301kvm_emulate_mtsrin_len: 354kvm_emulate_mtsrin_len:
302 .long (kvm_emulate_mtsrin_end - kvm_emulate_mtsrin) / 4 355 .long (kvm_emulate_mtsrin_end - kvm_emulate_mtsrin) / 4
356
357.global kvm_template_end
358kvm_template_end:
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index d0373bcb7c9..8e78e93c818 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -49,9 +49,6 @@ static int global_phb_number; /* Global phb counter */
49/* ISA Memory physical address */ 49/* ISA Memory physical address */
50resource_size_t isa_mem_base; 50resource_size_t isa_mem_base;
51 51
52/* Default PCI flags is 0 on ppc32, modified at boot on ppc64 */
53unsigned int pci_flags = 0;
54
55 52
56static struct dma_map_ops *pci_dma_ops = &dma_direct_ops; 53static struct dma_map_ops *pci_dma_ops = &dma_direct_ops;
57 54
@@ -834,60 +831,6 @@ int pci_proc_domain(struct pci_bus *bus)
834 return 1; 831 return 1;
835} 832}
836 833
837void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
838 struct resource *res)
839{
840 resource_size_t offset = 0, mask = (resource_size_t)-1;
841 struct pci_controller *hose = pci_bus_to_host(dev->bus);
842
843 if (!hose)
844 return;
845 if (res->flags & IORESOURCE_IO) {
846 offset = (unsigned long)hose->io_base_virt - _IO_BASE;
847 mask = 0xffffffffu;
848 } else if (res->flags & IORESOURCE_MEM)
849 offset = hose->pci_mem_offset;
850
851 region->start = (res->start - offset) & mask;
852 region->end = (res->end - offset) & mask;
853}
854EXPORT_SYMBOL(pcibios_resource_to_bus);
855
856void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
857 struct pci_bus_region *region)
858{
859 resource_size_t offset = 0, mask = (resource_size_t)-1;
860 struct pci_controller *hose = pci_bus_to_host(dev->bus);
861
862 if (!hose)
863 return;
864 if (res->flags & IORESOURCE_IO) {
865 offset = (unsigned long)hose->io_base_virt - _IO_BASE;
866 mask = 0xffffffffu;
867 } else if (res->flags & IORESOURCE_MEM)
868 offset = hose->pci_mem_offset;
869 res->start = (region->start + offset) & mask;
870 res->end = (region->end + offset) & mask;
871}
872EXPORT_SYMBOL(pcibios_bus_to_resource);
873
874/* Fixup a bus resource into a linux resource */
875static void __devinit fixup_resource(struct resource *res, struct pci_dev *dev)
876{
877 struct pci_controller *hose = pci_bus_to_host(dev->bus);
878 resource_size_t offset = 0, mask = (resource_size_t)-1;
879
880 if (res->flags & IORESOURCE_IO) {
881 offset = (unsigned long)hose->io_base_virt - _IO_BASE;
882 mask = 0xffffffffu;
883 } else if (res->flags & IORESOURCE_MEM)
884 offset = hose->pci_mem_offset;
885
886 res->start = (res->start + offset) & mask;
887 res->end = (res->end + offset) & mask;
888}
889
890
891/* This header fixup will do the resource fixup for all devices as they are 834/* This header fixup will do the resource fixup for all devices as they are
892 * probed, but not for bridge ranges 835 * probed, but not for bridge ranges
893 */ 836 */
@@ -927,18 +870,11 @@ static void __devinit pcibios_fixup_resources(struct pci_dev *dev)
927 continue; 870 continue;
928 } 871 }
929 872
930 pr_debug("PCI:%s Resource %d %016llx-%016llx [%x] fixup...\n", 873 pr_debug("PCI:%s Resource %d %016llx-%016llx [%x]\n",
931 pci_name(dev), i, 874 pci_name(dev), i,
932 (unsigned long long)res->start,\ 875 (unsigned long long)res->start,\
933 (unsigned long long)res->end, 876 (unsigned long long)res->end,
934 (unsigned int)res->flags); 877 (unsigned int)res->flags);
935
936 fixup_resource(res, dev);
937
938 pr_debug("PCI:%s %016llx-%016llx\n",
939 pci_name(dev),
940 (unsigned long long)res->start,
941 (unsigned long long)res->end);
942 } 878 }
943 879
944 /* Call machine specific resource fixup */ 880 /* Call machine specific resource fixup */
@@ -1040,27 +976,18 @@ static void __devinit pcibios_fixup_bridge(struct pci_bus *bus)
1040 continue; 976 continue;
1041 } 977 }
1042 978
1043 pr_debug("PCI:%s Bus rsrc %d %016llx-%016llx [%x] fixup...\n", 979 pr_debug("PCI:%s Bus rsrc %d %016llx-%016llx [%x]\n",
1044 pci_name(dev), i, 980 pci_name(dev), i,
1045 (unsigned long long)res->start,\ 981 (unsigned long long)res->start,\
1046 (unsigned long long)res->end, 982 (unsigned long long)res->end,
1047 (unsigned int)res->flags); 983 (unsigned int)res->flags);
1048 984
1049 /* Perform fixup */
1050 fixup_resource(res, dev);
1051
1052 /* Try to detect uninitialized P2P bridge resources, 985 /* Try to detect uninitialized P2P bridge resources,
1053 * and clear them out so they get re-assigned later 986 * and clear them out so they get re-assigned later
1054 */ 987 */
1055 if (pcibios_uninitialized_bridge_resource(bus, res)) { 988 if (pcibios_uninitialized_bridge_resource(bus, res)) {
1056 res->flags = 0; 989 res->flags = 0;
1057 pr_debug("PCI:%s (unassigned)\n", pci_name(dev)); 990 pr_debug("PCI:%s (unassigned)\n", pci_name(dev));
1058 } else {
1059
1060 pr_debug("PCI:%s %016llx-%016llx\n",
1061 pci_name(dev),
1062 (unsigned long long)res->start,
1063 (unsigned long long)res->end);
1064 } 991 }
1065 } 992 }
1066} 993}
@@ -1550,6 +1477,11 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
1550 return pci_enable_resources(dev, mask); 1477 return pci_enable_resources(dev, mask);
1551} 1478}
1552 1479
1480resource_size_t pcibios_io_space_offset(struct pci_controller *hose)
1481{
1482 return (unsigned long) hose->io_base_virt - _IO_BASE;
1483}
1484
1553static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, struct list_head *resources) 1485static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, struct list_head *resources)
1554{ 1486{
1555 struct resource *res; 1487 struct resource *res;
@@ -1574,7 +1506,7 @@ static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, s
1574 (unsigned long long)res->start, 1506 (unsigned long long)res->start,
1575 (unsigned long long)res->end, 1507 (unsigned long long)res->end,
1576 (unsigned long)res->flags); 1508 (unsigned long)res->flags);
1577 pci_add_resource(resources, res); 1509 pci_add_resource_offset(resources, res, pcibios_io_space_offset(hose));
1578 1510
1579 /* Hookup PHB Memory resources */ 1511 /* Hookup PHB Memory resources */
1580 for (i = 0; i < 3; ++i) { 1512 for (i = 0; i < 3; ++i) {
@@ -1597,7 +1529,7 @@ static void __devinit pcibios_setup_phb_resources(struct pci_controller *hose, s
1597 (unsigned long long)res->start, 1529 (unsigned long long)res->start,
1598 (unsigned long long)res->end, 1530 (unsigned long long)res->end,
1599 (unsigned long)res->flags); 1531 (unsigned long)res->flags);
1600 pci_add_resource(resources, res); 1532 pci_add_resource_offset(resources, res, hose->pci_mem_offset);
1601 } 1533 }
1602 1534
1603 pr_debug("PCI: PHB MEM offset = %016llx\n", 1535 pr_debug("PCI: PHB MEM offset = %016llx\n",
diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c
index fdd1a3d951d..4b06ec5a502 100644
--- a/arch/powerpc/kernel/pci_32.c
+++ b/arch/powerpc/kernel/pci_32.c
@@ -219,9 +219,9 @@ void __devinit pcibios_setup_phb_io_space(struct pci_controller *hose)
219 struct resource *res = &hose->io_resource; 219 struct resource *res = &hose->io_resource;
220 220
221 /* Fixup IO space offset */ 221 /* Fixup IO space offset */
222 io_offset = (unsigned long)hose->io_base_virt - isa_io_base; 222 io_offset = pcibios_io_space_offset(hose);
223 res->start = (res->start + io_offset) & 0xffffffffu; 223 res->start += io_offset;
224 res->end = (res->end + io_offset) & 0xffffffffu; 224 res->end += io_offset;
225} 225}
226 226
227static int __init pcibios_init(void) 227static int __init pcibios_init(void)
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index 3318d39b7d4..94a54f61d34 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -33,8 +33,6 @@
33#include <asm/machdep.h> 33#include <asm/machdep.h>
34#include <asm/ppc-pci.h> 34#include <asm/ppc-pci.h>
35 35
36unsigned long pci_probe_only = 1;
37
38/* pci_io_base -- the base address from which io bars are offsets. 36/* pci_io_base -- the base address from which io bars are offsets.
39 * This is the lowest I/O base address (so bar values are always positive), 37 * This is the lowest I/O base address (so bar values are always positive),
40 * and it *must* be the start of ISA space if an ISA bus exists because 38 * and it *must* be the start of ISA space if an ISA bus exists because
@@ -55,9 +53,6 @@ static int __init pcibios_init(void)
55 */ 53 */
56 ppc_md.phys_mem_access_prot = pci_phys_mem_access_prot; 54 ppc_md.phys_mem_access_prot = pci_phys_mem_access_prot;
57 55
58 if (pci_probe_only)
59 pci_add_flags(PCI_PROBE_ONLY);
60
61 /* On ppc64, we always enable PCI domains and we keep domain 0 56 /* On ppc64, we always enable PCI domains and we keep domain 0
62 * backward compatible in /proc for video cards 57 * backward compatible in /proc for video cards
63 */ 58 */
@@ -173,7 +168,7 @@ static int __devinit pcibios_map_phb_io_space(struct pci_controller *hose)
173 return -ENOMEM; 168 return -ENOMEM;
174 169
175 /* Fixup hose IO resource */ 170 /* Fixup hose IO resource */
176 io_virt_offset = (unsigned long)hose->io_base_virt - _IO_BASE; 171 io_virt_offset = pcibios_io_space_offset(hose);
177 hose->io_resource.start += io_virt_offset; 172 hose->io_resource.start += io_virt_offset;
178 hose->io_resource.end += io_virt_offset; 173 hose->io_resource.end += io_virt_offset;
179 174
diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c
index b37d0b5a796..89dde171a6f 100644
--- a/arch/powerpc/kernel/pci_of_scan.c
+++ b/arch/powerpc/kernel/pci_of_scan.c
@@ -75,6 +75,7 @@ static void of_pci_parse_addrs(struct device_node *node, struct pci_dev *dev)
75{ 75{
76 u64 base, size; 76 u64 base, size;
77 unsigned int flags; 77 unsigned int flags;
78 struct pci_bus_region region;
78 struct resource *res; 79 struct resource *res;
79 const u32 *addrs; 80 const u32 *addrs;
80 u32 i; 81 u32 i;
@@ -106,10 +107,11 @@ static void of_pci_parse_addrs(struct device_node *node, struct pci_dev *dev)
106 printk(KERN_ERR "PCI: bad cfg reg num 0x%x\n", i); 107 printk(KERN_ERR "PCI: bad cfg reg num 0x%x\n", i);
107 continue; 108 continue;
108 } 109 }
109 res->start = base;
110 res->end = base + size - 1;
111 res->flags = flags; 110 res->flags = flags;
112 res->name = pci_name(dev); 111 res->name = pci_name(dev);
112 region.start = base;
113 region.end = base + size - 1;
114 pcibios_bus_to_resource(dev, res, &region);
113 } 115 }
114} 116}
115 117
@@ -209,6 +211,7 @@ void __devinit of_scan_pci_bridge(struct pci_dev *dev)
209 struct pci_bus *bus; 211 struct pci_bus *bus;
210 const u32 *busrange, *ranges; 212 const u32 *busrange, *ranges;
211 int len, i, mode; 213 int len, i, mode;
214 struct pci_bus_region region;
212 struct resource *res; 215 struct resource *res;
213 unsigned int flags; 216 unsigned int flags;
214 u64 size; 217 u64 size;
@@ -270,9 +273,10 @@ void __devinit of_scan_pci_bridge(struct pci_dev *dev)
270 res = bus->resource[i]; 273 res = bus->resource[i];
271 ++i; 274 ++i;
272 } 275 }
273 res->start = of_read_number(&ranges[1], 2);
274 res->end = res->start + size - 1;
275 res->flags = flags; 276 res->flags = flags;
277 region.start = of_read_number(&ranges[1], 2);
278 region.end = region.start + size - 1;
279 pcibios_bus_to_resource(dev, res, &region);
276 } 280 }
277 sprintf(bus->name, "PCI Bus %04x:%02x", pci_domain_nr(bus), 281 sprintf(bus->name, "PCI Bus %04x:%02x", pci_domain_nr(bus),
278 bus->number); 282 bus->number);
diff --git a/arch/powerpc/kernel/pmc.c b/arch/powerpc/kernel/pmc.c
index a841a9d136a..58eaa3ddf7b 100644
--- a/arch/powerpc/kernel/pmc.c
+++ b/arch/powerpc/kernel/pmc.c
@@ -13,6 +13,7 @@
13 */ 13 */
14 14
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/bug.h>
16#include <linux/spinlock.h> 17#include <linux/spinlock.h>
17#include <linux/export.h> 18#include <linux/export.h>
18 19
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index b2aae219b4b..99860273211 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -446,7 +446,7 @@ static void __init __attribute__((noreturn)) prom_panic(const char *reason)
446 if (RELOC(of_platform) == PLATFORM_POWERMAC) 446 if (RELOC(of_platform) == PLATFORM_POWERMAC)
447 asm("trap\n"); 447 asm("trap\n");
448 448
449 /* ToDo: should put up an SRC here on p/iSeries */ 449 /* ToDo: should put up an SRC here on pSeries */
450 call_prom("exit", 0, 0); 450 call_prom("exit", 0, 0);
451 451
452 for (;;) /* should never get here */ 452 for (;;) /* should never get here */
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index 3dc679930d0..fcec38241f7 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -867,6 +867,40 @@ int rtas_ibm_suspend_me(struct rtas_args *args)
867} 867}
868#endif 868#endif
869 869
870/**
871 * Find a specific pseries error log in an RTAS extended event log.
872 * @log: RTAS error/event log
873 * @section_id: two character section identifier
874 *
875 * Returns a pointer to the specified errorlog or NULL if not found.
876 */
877struct pseries_errorlog *get_pseries_errorlog(struct rtas_error_log *log,
878 uint16_t section_id)
879{
880 struct rtas_ext_event_log_v6 *ext_log =
881 (struct rtas_ext_event_log_v6 *)log->buffer;
882 struct pseries_errorlog *sect;
883 unsigned char *p, *log_end;
884
885 /* Check that we understand the format */
886 if (log->extended_log_length < sizeof(struct rtas_ext_event_log_v6) ||
887 ext_log->log_format != RTAS_V6EXT_LOG_FORMAT_EVENT_LOG ||
888 ext_log->company_id != RTAS_V6EXT_COMPANY_ID_IBM)
889 return NULL;
890
891 log_end = log->buffer + log->extended_log_length;
892 p = ext_log->vendor_log;
893
894 while (p < log_end) {
895 sect = (struct pseries_errorlog *)p;
896 if (sect->id == section_id)
897 return sect;
898 p += sect->length;
899 }
900
901 return NULL;
902}
903
870asmlinkage int ppc_rtas(struct rtas_args __user *uargs) 904asmlinkage int ppc_rtas(struct rtas_args __user *uargs)
871{ 905{
872 struct rtas_args args; 906 struct rtas_args args;
diff --git a/arch/powerpc/kernel/rtas_pci.c b/arch/powerpc/kernel/rtas_pci.c
index 517bd86bc3f..179af906dcd 100644
--- a/arch/powerpc/kernel/rtas_pci.c
+++ b/arch/powerpc/kernel/rtas_pci.c
@@ -279,7 +279,7 @@ void __init find_and_init_phbs(void)
279 eeh_dev_phb_init(); 279 eeh_dev_phb_init();
280 280
281 /* 281 /*
282 * pci_probe_only and pci_assign_all_buses can be set via properties 282 * PCI_PROBE_ONLY and PCI_REASSIGN_ALL_BUS can be set via properties
283 * in chosen. 283 * in chosen.
284 */ 284 */
285 if (of_chosen) { 285 if (of_chosen) {
@@ -287,8 +287,12 @@ void __init find_and_init_phbs(void)
287 287
288 prop = of_get_property(of_chosen, 288 prop = of_get_property(of_chosen,
289 "linux,pci-probe-only", NULL); 289 "linux,pci-probe-only", NULL);
290 if (prop) 290 if (prop) {
291 pci_probe_only = *prop; 291 if (*prop)
292 pci_add_flags(PCI_PROBE_ONLY);
293 else
294 pci_clear_flags(PCI_PROBE_ONLY);
295 }
292 296
293#ifdef CONFIG_PPC32 /* Will be made generic soon */ 297#ifdef CONFIG_PPC32 /* Will be made generic soon */
294 prop = of_get_property(of_chosen, 298 prop = of_get_property(of_chosen,
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 6d639b2d24c..389bd4f0cdb 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -597,7 +597,7 @@ void __init setup_arch(char **cmdline_p)
597 /* Initialize the MMU context management stuff */ 597 /* Initialize the MMU context management stuff */
598 mmu_context_init(); 598 mmu_context_init();
599 599
600 kvm_rma_init(); 600 kvm_linear_init();
601 601
602 ppc64_boot_msg(0x15, "Setup Done"); 602 ppc64_boot_msg(0x15, "Setup Done");
603} 603}
diff --git a/arch/powerpc/kernel/udbg.c b/arch/powerpc/kernel/udbg.c
index 57fa2c0a531..c39c1ca77f4 100644
--- a/arch/powerpc/kernel/udbg.c
+++ b/arch/powerpc/kernel/udbg.c
@@ -46,9 +46,6 @@ void __init udbg_early_init(void)
46#elif defined(CONFIG_PPC_EARLY_DEBUG_MAPLE) 46#elif defined(CONFIG_PPC_EARLY_DEBUG_MAPLE)
47 /* Maple real mode debug */ 47 /* Maple real mode debug */
48 udbg_init_maple_realmode(); 48 udbg_init_maple_realmode();
49#elif defined(CONFIG_PPC_EARLY_DEBUG_ISERIES)
50 /* For iSeries - hit Ctrl-x Ctrl-x to see the output */
51 udbg_init_iseries();
52#elif defined(CONFIG_PPC_EARLY_DEBUG_BEAT) 49#elif defined(CONFIG_PPC_EARLY_DEBUG_BEAT)
53 udbg_init_debug_beat(); 50 udbg_init_debug_beat();
54#elif defined(CONFIG_PPC_EARLY_DEBUG_PAS_REALMODE) 51#elif defined(CONFIG_PPC_EARLY_DEBUG_PAS_REALMODE)
diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
index 1ce1ec410a1..9eb5b9b536a 100644
--- a/arch/powerpc/kernel/vdso.c
+++ b/arch/powerpc/kernel/vdso.c
@@ -262,17 +262,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
262 * the "data" page of the vDSO or you'll stop getting kernel updates 262 * the "data" page of the vDSO or you'll stop getting kernel updates
263 * and your nice userland gettimeofday will be totally dead. 263 * and your nice userland gettimeofday will be totally dead.
264 * It's fine to use that for setting breakpoints in the vDSO code 264 * It's fine to use that for setting breakpoints in the vDSO code
265 * pages though 265 * pages though.
266 *
267 * Make sure the vDSO gets into every core dump.
268 * Dumping its contents makes post-mortem fully interpretable later
269 * without matching up the same kernel and hardware config to see
270 * what PC values meant.
271 */ 266 */
272 rc = install_special_mapping(mm, vdso_base, vdso_pages << PAGE_SHIFT, 267 rc = install_special_mapping(mm, vdso_base, vdso_pages << PAGE_SHIFT,
273 VM_READ|VM_EXEC| 268 VM_READ|VM_EXEC|
274 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC| 269 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
275 VM_ALWAYSDUMP,
276 vdso_pagelist); 270 vdso_pagelist);
277 if (rc) { 271 if (rc) {
278 current->mm->context.vdso_base = 0; 272 current->mm->context.vdso_base = 0;
@@ -726,10 +720,10 @@ static int __init vdso_init(void)
726 vdso_data->version.minor = SYSTEMCFG_MINOR; 720 vdso_data->version.minor = SYSTEMCFG_MINOR;
727 vdso_data->processor = mfspr(SPRN_PVR); 721 vdso_data->processor = mfspr(SPRN_PVR);
728 /* 722 /*
729 * Fake the old platform number for pSeries and iSeries and add 723 * Fake the old platform number for pSeries and add
730 * in LPAR bit if necessary 724 * in LPAR bit if necessary
731 */ 725 */
732 vdso_data->platform = machine_is(iseries) ? 0x200 : 0x100; 726 vdso_data->platform = 0x100;
733 if (firmware_has_feature(FW_FEATURE_LPAR)) 727 if (firmware_has_feature(FW_FEATURE_LPAR))
734 vdso_data->platform |= 1; 728 vdso_data->platform |= 1;
735 vdso_data->physicalMemorySize = memblock_phys_mem_size(); 729 vdso_data->physicalMemorySize = memblock_phys_mem_size();
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index bca3fc427b4..b2f7c8480bf 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -1159,17 +1159,21 @@ static int vio_bus_remove(struct device *dev)
1159 * vio_register_driver: - Register a new vio driver 1159 * vio_register_driver: - Register a new vio driver
1160 * @drv: The vio_driver structure to be registered. 1160 * @drv: The vio_driver structure to be registered.
1161 */ 1161 */
1162int vio_register_driver(struct vio_driver *viodrv) 1162int __vio_register_driver(struct vio_driver *viodrv, struct module *owner,
1163 const char *mod_name)
1163{ 1164{
1164 printk(KERN_DEBUG "%s: driver %s registering\n", __func__, 1165 pr_debug("%s: driver %s registering\n", __func__, viodrv->name);
1165 viodrv->driver.name);
1166 1166
1167 /* fill in 'struct driver' fields */ 1167 /* fill in 'struct driver' fields */
1168 viodrv->driver.name = viodrv->name;
1169 viodrv->driver.pm = viodrv->pm;
1168 viodrv->driver.bus = &vio_bus_type; 1170 viodrv->driver.bus = &vio_bus_type;
1171 viodrv->driver.owner = owner;
1172 viodrv->driver.mod_name = mod_name;
1169 1173
1170 return driver_register(&viodrv->driver); 1174 return driver_register(&viodrv->driver);
1171} 1175}
1172EXPORT_SYMBOL(vio_register_driver); 1176EXPORT_SYMBOL(__vio_register_driver);
1173 1177
1174/** 1178/**
1175 * vio_unregister_driver - Remove registration of vio driver. 1179 * vio_unregister_driver - Remove registration of vio driver.
diff --git a/arch/powerpc/kvm/Kconfig b/arch/powerpc/kvm/Kconfig
index 78133deb4b6..8f64709ae33 100644
--- a/arch/powerpc/kvm/Kconfig
+++ b/arch/powerpc/kvm/Kconfig
@@ -69,6 +69,7 @@ config KVM_BOOK3S_64
69config KVM_BOOK3S_64_HV 69config KVM_BOOK3S_64_HV
70 bool "KVM support for POWER7 and PPC970 using hypervisor mode in host" 70 bool "KVM support for POWER7 and PPC970 using hypervisor mode in host"
71 depends on KVM_BOOK3S_64 71 depends on KVM_BOOK3S_64
72 select MMU_NOTIFIER
72 ---help--- 73 ---help---
73 Support running unmodified book3s_64 guest kernels in 74 Support running unmodified book3s_64 guest kernels in
74 virtual machines on POWER7 and PPC970 processors that have 75 virtual machines on POWER7 and PPC970 processors that have
diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c
index e41ac6f7dcf..7d54f4ed6d9 100644
--- a/arch/powerpc/kvm/book3s.c
+++ b/arch/powerpc/kvm/book3s.c
@@ -258,7 +258,7 @@ static bool clear_irqprio(struct kvm_vcpu *vcpu, unsigned int priority)
258 return true; 258 return true;
259} 259}
260 260
261void kvmppc_core_deliver_interrupts(struct kvm_vcpu *vcpu) 261void kvmppc_core_prepare_to_enter(struct kvm_vcpu *vcpu)
262{ 262{
263 unsigned long *pending = &vcpu->arch.pending_exceptions; 263 unsigned long *pending = &vcpu->arch.pending_exceptions;
264 unsigned long old_pending = vcpu->arch.pending_exceptions; 264 unsigned long old_pending = vcpu->arch.pending_exceptions;
@@ -423,10 +423,10 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
423 regs->sprg1 = vcpu->arch.shared->sprg1; 423 regs->sprg1 = vcpu->arch.shared->sprg1;
424 regs->sprg2 = vcpu->arch.shared->sprg2; 424 regs->sprg2 = vcpu->arch.shared->sprg2;
425 regs->sprg3 = vcpu->arch.shared->sprg3; 425 regs->sprg3 = vcpu->arch.shared->sprg3;
426 regs->sprg4 = vcpu->arch.sprg4; 426 regs->sprg4 = vcpu->arch.shared->sprg4;
427 regs->sprg5 = vcpu->arch.sprg5; 427 regs->sprg5 = vcpu->arch.shared->sprg5;
428 regs->sprg6 = vcpu->arch.sprg6; 428 regs->sprg6 = vcpu->arch.shared->sprg6;
429 regs->sprg7 = vcpu->arch.sprg7; 429 regs->sprg7 = vcpu->arch.shared->sprg7;
430 430
431 for (i = 0; i < ARRAY_SIZE(regs->gpr); i++) 431 for (i = 0; i < ARRAY_SIZE(regs->gpr); i++)
432 regs->gpr[i] = kvmppc_get_gpr(vcpu, i); 432 regs->gpr[i] = kvmppc_get_gpr(vcpu, i);
@@ -450,10 +450,10 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
450 vcpu->arch.shared->sprg1 = regs->sprg1; 450 vcpu->arch.shared->sprg1 = regs->sprg1;
451 vcpu->arch.shared->sprg2 = regs->sprg2; 451 vcpu->arch.shared->sprg2 = regs->sprg2;
452 vcpu->arch.shared->sprg3 = regs->sprg3; 452 vcpu->arch.shared->sprg3 = regs->sprg3;
453 vcpu->arch.sprg4 = regs->sprg4; 453 vcpu->arch.shared->sprg4 = regs->sprg4;
454 vcpu->arch.sprg5 = regs->sprg5; 454 vcpu->arch.shared->sprg5 = regs->sprg5;
455 vcpu->arch.sprg6 = regs->sprg6; 455 vcpu->arch.shared->sprg6 = regs->sprg6;
456 vcpu->arch.sprg7 = regs->sprg7; 456 vcpu->arch.shared->sprg7 = regs->sprg7;
457 457
458 for (i = 0; i < ARRAY_SIZE(regs->gpr); i++) 458 for (i = 0; i < ARRAY_SIZE(regs->gpr); i++)
459 kvmppc_set_gpr(vcpu, i, regs->gpr[i]); 459 kvmppc_set_gpr(vcpu, i, regs->gpr[i]);
@@ -477,41 +477,10 @@ int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu,
477 return 0; 477 return 0;
478} 478}
479 479
480/* 480void kvmppc_decrementer_func(unsigned long data)
481 * Get (and clear) the dirty memory log for a memory slot.
482 */
483int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
484 struct kvm_dirty_log *log)
485{ 481{
486 struct kvm_memory_slot *memslot; 482 struct kvm_vcpu *vcpu = (struct kvm_vcpu *)data;
487 struct kvm_vcpu *vcpu;
488 ulong ga, ga_end;
489 int is_dirty = 0;
490 int r;
491 unsigned long n;
492
493 mutex_lock(&kvm->slots_lock);
494
495 r = kvm_get_dirty_log(kvm, log, &is_dirty);
496 if (r)
497 goto out;
498
499 /* If nothing is dirty, don't bother messing with page tables. */
500 if (is_dirty) {
501 memslot = id_to_memslot(kvm->memslots, log->slot);
502 483
503 ga = memslot->base_gfn << PAGE_SHIFT; 484 kvmppc_core_queue_dec(vcpu);
504 ga_end = ga + (memslot->npages << PAGE_SHIFT); 485 kvm_vcpu_kick(vcpu);
505
506 kvm_for_each_vcpu(n, vcpu, kvm)
507 kvmppc_mmu_pte_pflush(vcpu, ga, ga_end);
508
509 n = kvm_dirty_bitmap_bytes(memslot);
510 memset(memslot->dirty_bitmap, 0, n);
511 }
512
513 r = 0;
514out:
515 mutex_unlock(&kvm->slots_lock);
516 return r;
517} 486}
diff --git a/arch/powerpc/kvm/book3s_32_mmu_host.c b/arch/powerpc/kvm/book3s_32_mmu_host.c
index 9fecbfbce77..f922c29bb23 100644
--- a/arch/powerpc/kvm/book3s_32_mmu_host.c
+++ b/arch/powerpc/kvm/book3s_32_mmu_host.c
@@ -151,13 +151,15 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte)
151 bool primary = false; 151 bool primary = false;
152 bool evict = false; 152 bool evict = false;
153 struct hpte_cache *pte; 153 struct hpte_cache *pte;
154 int r = 0;
154 155
155 /* Get host physical address for gpa */ 156 /* Get host physical address for gpa */
156 hpaddr = kvmppc_gfn_to_pfn(vcpu, orig_pte->raddr >> PAGE_SHIFT); 157 hpaddr = kvmppc_gfn_to_pfn(vcpu, orig_pte->raddr >> PAGE_SHIFT);
157 if (is_error_pfn(hpaddr)) { 158 if (is_error_pfn(hpaddr)) {
158 printk(KERN_INFO "Couldn't get guest page for gfn %lx!\n", 159 printk(KERN_INFO "Couldn't get guest page for gfn %lx!\n",
159 orig_pte->eaddr); 160 orig_pte->eaddr);
160 return -EINVAL; 161 r = -EINVAL;
162 goto out;
161 } 163 }
162 hpaddr <<= PAGE_SHIFT; 164 hpaddr <<= PAGE_SHIFT;
163 165
@@ -249,7 +251,8 @@ next_pteg:
249 251
250 kvmppc_mmu_hpte_cache_map(vcpu, pte); 252 kvmppc_mmu_hpte_cache_map(vcpu, pte);
251 253
252 return 0; 254out:
255 return r;
253} 256}
254 257
255static struct kvmppc_sid_map *create_sid_map(struct kvm_vcpu *vcpu, u64 gvsid) 258static struct kvmppc_sid_map *create_sid_map(struct kvm_vcpu *vcpu, u64 gvsid)
@@ -297,12 +300,14 @@ int kvmppc_mmu_map_segment(struct kvm_vcpu *vcpu, ulong eaddr)
297 u64 gvsid; 300 u64 gvsid;
298 u32 sr; 301 u32 sr;
299 struct kvmppc_sid_map *map; 302 struct kvmppc_sid_map *map;
300 struct kvmppc_book3s_shadow_vcpu *svcpu = to_svcpu(vcpu); 303 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
304 int r = 0;
301 305
302 if (vcpu->arch.mmu.esid_to_vsid(vcpu, esid, &gvsid)) { 306 if (vcpu->arch.mmu.esid_to_vsid(vcpu, esid, &gvsid)) {
303 /* Invalidate an entry */ 307 /* Invalidate an entry */
304 svcpu->sr[esid] = SR_INVALID; 308 svcpu->sr[esid] = SR_INVALID;
305 return -ENOENT; 309 r = -ENOENT;
310 goto out;
306 } 311 }
307 312
308 map = find_sid_vsid(vcpu, gvsid); 313 map = find_sid_vsid(vcpu, gvsid);
@@ -315,17 +320,21 @@ int kvmppc_mmu_map_segment(struct kvm_vcpu *vcpu, ulong eaddr)
315 320
316 dprintk_sr("MMU: mtsr %d, 0x%x\n", esid, sr); 321 dprintk_sr("MMU: mtsr %d, 0x%x\n", esid, sr);
317 322
318 return 0; 323out:
324 svcpu_put(svcpu);
325 return r;
319} 326}
320 327
321void kvmppc_mmu_flush_segments(struct kvm_vcpu *vcpu) 328void kvmppc_mmu_flush_segments(struct kvm_vcpu *vcpu)
322{ 329{
323 int i; 330 int i;
324 struct kvmppc_book3s_shadow_vcpu *svcpu = to_svcpu(vcpu); 331 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
325 332
326 dprintk_sr("MMU: flushing all segments (%d)\n", ARRAY_SIZE(svcpu->sr)); 333 dprintk_sr("MMU: flushing all segments (%d)\n", ARRAY_SIZE(svcpu->sr));
327 for (i = 0; i < ARRAY_SIZE(svcpu->sr); i++) 334 for (i = 0; i < ARRAY_SIZE(svcpu->sr); i++)
328 svcpu->sr[i] = SR_INVALID; 335 svcpu->sr[i] = SR_INVALID;
336
337 svcpu_put(svcpu);
329} 338}
330 339
331void kvmppc_mmu_destroy(struct kvm_vcpu *vcpu) 340void kvmppc_mmu_destroy(struct kvm_vcpu *vcpu)
diff --git a/arch/powerpc/kvm/book3s_64_mmu_host.c b/arch/powerpc/kvm/book3s_64_mmu_host.c
index fa2f08434ba..6f87f39a1ac 100644
--- a/arch/powerpc/kvm/book3s_64_mmu_host.c
+++ b/arch/powerpc/kvm/book3s_64_mmu_host.c
@@ -88,12 +88,14 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte)
88 int vflags = 0; 88 int vflags = 0;
89 int attempt = 0; 89 int attempt = 0;
90 struct kvmppc_sid_map *map; 90 struct kvmppc_sid_map *map;
91 int r = 0;
91 92
92 /* Get host physical address for gpa */ 93 /* Get host physical address for gpa */
93 hpaddr = kvmppc_gfn_to_pfn(vcpu, orig_pte->raddr >> PAGE_SHIFT); 94 hpaddr = kvmppc_gfn_to_pfn(vcpu, orig_pte->raddr >> PAGE_SHIFT);
94 if (is_error_pfn(hpaddr)) { 95 if (is_error_pfn(hpaddr)) {
95 printk(KERN_INFO "Couldn't get guest page for gfn %lx!\n", orig_pte->eaddr); 96 printk(KERN_INFO "Couldn't get guest page for gfn %lx!\n", orig_pte->eaddr);
96 return -EINVAL; 97 r = -EINVAL;
98 goto out;
97 } 99 }
98 hpaddr <<= PAGE_SHIFT; 100 hpaddr <<= PAGE_SHIFT;
99 hpaddr |= orig_pte->raddr & (~0xfffULL & ~PAGE_MASK); 101 hpaddr |= orig_pte->raddr & (~0xfffULL & ~PAGE_MASK);
@@ -110,7 +112,8 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte)
110 printk(KERN_ERR "KVM: Segment map for 0x%llx (0x%lx) failed\n", 112 printk(KERN_ERR "KVM: Segment map for 0x%llx (0x%lx) failed\n",
111 vsid, orig_pte->eaddr); 113 vsid, orig_pte->eaddr);
112 WARN_ON(true); 114 WARN_ON(true);
113 return -EINVAL; 115 r = -EINVAL;
116 goto out;
114 } 117 }
115 118
116 vsid = map->host_vsid; 119 vsid = map->host_vsid;
@@ -131,8 +134,10 @@ map_again:
131 134
132 /* In case we tried normal mapping already, let's nuke old entries */ 135 /* In case we tried normal mapping already, let's nuke old entries */
133 if (attempt > 1) 136 if (attempt > 1)
134 if (ppc_md.hpte_remove(hpteg) < 0) 137 if (ppc_md.hpte_remove(hpteg) < 0) {
135 return -1; 138 r = -1;
139 goto out;
140 }
136 141
137 ret = ppc_md.hpte_insert(hpteg, va, hpaddr, rflags, vflags, MMU_PAGE_4K, MMU_SEGSIZE_256M); 142 ret = ppc_md.hpte_insert(hpteg, va, hpaddr, rflags, vflags, MMU_PAGE_4K, MMU_SEGSIZE_256M);
138 143
@@ -162,7 +167,8 @@ map_again:
162 kvmppc_mmu_hpte_cache_map(vcpu, pte); 167 kvmppc_mmu_hpte_cache_map(vcpu, pte);
163 } 168 }
164 169
165 return 0; 170out:
171 return r;
166} 172}
167 173
168static struct kvmppc_sid_map *create_sid_map(struct kvm_vcpu *vcpu, u64 gvsid) 174static struct kvmppc_sid_map *create_sid_map(struct kvm_vcpu *vcpu, u64 gvsid)
@@ -207,25 +213,30 @@ static struct kvmppc_sid_map *create_sid_map(struct kvm_vcpu *vcpu, u64 gvsid)
207 213
208static int kvmppc_mmu_next_segment(struct kvm_vcpu *vcpu, ulong esid) 214static int kvmppc_mmu_next_segment(struct kvm_vcpu *vcpu, ulong esid)
209{ 215{
216 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
210 int i; 217 int i;
211 int max_slb_size = 64; 218 int max_slb_size = 64;
212 int found_inval = -1; 219 int found_inval = -1;
213 int r; 220 int r;
214 221
215 if (!to_svcpu(vcpu)->slb_max) 222 if (!svcpu->slb_max)
216 to_svcpu(vcpu)->slb_max = 1; 223 svcpu->slb_max = 1;
217 224
218 /* Are we overwriting? */ 225 /* Are we overwriting? */
219 for (i = 1; i < to_svcpu(vcpu)->slb_max; i++) { 226 for (i = 1; i < svcpu->slb_max; i++) {
220 if (!(to_svcpu(vcpu)->slb[i].esid & SLB_ESID_V)) 227 if (!(svcpu->slb[i].esid & SLB_ESID_V))
221 found_inval = i; 228 found_inval = i;
222 else if ((to_svcpu(vcpu)->slb[i].esid & ESID_MASK) == esid) 229 else if ((svcpu->slb[i].esid & ESID_MASK) == esid) {
223 return i; 230 r = i;
231 goto out;
232 }
224 } 233 }
225 234
226 /* Found a spare entry that was invalidated before */ 235 /* Found a spare entry that was invalidated before */
227 if (found_inval > 0) 236 if (found_inval > 0) {
228 return found_inval; 237 r = found_inval;
238 goto out;
239 }
229 240
230 /* No spare invalid entry, so create one */ 241 /* No spare invalid entry, so create one */
231 242
@@ -233,30 +244,35 @@ static int kvmppc_mmu_next_segment(struct kvm_vcpu *vcpu, ulong esid)
233 max_slb_size = mmu_slb_size; 244 max_slb_size = mmu_slb_size;
234 245
235 /* Overflowing -> purge */ 246 /* Overflowing -> purge */
236 if ((to_svcpu(vcpu)->slb_max) == max_slb_size) 247 if ((svcpu->slb_max) == max_slb_size)
237 kvmppc_mmu_flush_segments(vcpu); 248 kvmppc_mmu_flush_segments(vcpu);
238 249
239 r = to_svcpu(vcpu)->slb_max; 250 r = svcpu->slb_max;
240 to_svcpu(vcpu)->slb_max++; 251 svcpu->slb_max++;
241 252
253out:
254 svcpu_put(svcpu);
242 return r; 255 return r;
243} 256}
244 257
245int kvmppc_mmu_map_segment(struct kvm_vcpu *vcpu, ulong eaddr) 258int kvmppc_mmu_map_segment(struct kvm_vcpu *vcpu, ulong eaddr)
246{ 259{
260 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
247 u64 esid = eaddr >> SID_SHIFT; 261 u64 esid = eaddr >> SID_SHIFT;
248 u64 slb_esid = (eaddr & ESID_MASK) | SLB_ESID_V; 262 u64 slb_esid = (eaddr & ESID_MASK) | SLB_ESID_V;
249 u64 slb_vsid = SLB_VSID_USER; 263 u64 slb_vsid = SLB_VSID_USER;
250 u64 gvsid; 264 u64 gvsid;
251 int slb_index; 265 int slb_index;
252 struct kvmppc_sid_map *map; 266 struct kvmppc_sid_map *map;
267 int r = 0;
253 268
254 slb_index = kvmppc_mmu_next_segment(vcpu, eaddr & ESID_MASK); 269 slb_index = kvmppc_mmu_next_segment(vcpu, eaddr & ESID_MASK);
255 270
256 if (vcpu->arch.mmu.esid_to_vsid(vcpu, esid, &gvsid)) { 271 if (vcpu->arch.mmu.esid_to_vsid(vcpu, esid, &gvsid)) {
257 /* Invalidate an entry */ 272 /* Invalidate an entry */
258 to_svcpu(vcpu)->slb[slb_index].esid = 0; 273 svcpu->slb[slb_index].esid = 0;
259 return -ENOENT; 274 r = -ENOENT;
275 goto out;
260 } 276 }
261 277
262 map = find_sid_vsid(vcpu, gvsid); 278 map = find_sid_vsid(vcpu, gvsid);
@@ -269,18 +285,22 @@ int kvmppc_mmu_map_segment(struct kvm_vcpu *vcpu, ulong eaddr)
269 slb_vsid &= ~SLB_VSID_KP; 285 slb_vsid &= ~SLB_VSID_KP;
270 slb_esid |= slb_index; 286 slb_esid |= slb_index;
271 287
272 to_svcpu(vcpu)->slb[slb_index].esid = slb_esid; 288 svcpu->slb[slb_index].esid = slb_esid;
273 to_svcpu(vcpu)->slb[slb_index].vsid = slb_vsid; 289 svcpu->slb[slb_index].vsid = slb_vsid;
274 290
275 trace_kvm_book3s_slbmte(slb_vsid, slb_esid); 291 trace_kvm_book3s_slbmte(slb_vsid, slb_esid);
276 292
277 return 0; 293out:
294 svcpu_put(svcpu);
295 return r;
278} 296}
279 297
280void kvmppc_mmu_flush_segments(struct kvm_vcpu *vcpu) 298void kvmppc_mmu_flush_segments(struct kvm_vcpu *vcpu)
281{ 299{
282 to_svcpu(vcpu)->slb_max = 1; 300 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
283 to_svcpu(vcpu)->slb[0].esid = 0; 301 svcpu->slb_max = 1;
302 svcpu->slb[0].esid = 0;
303 svcpu_put(svcpu);
284} 304}
285 305
286void kvmppc_mmu_destroy(struct kvm_vcpu *vcpu) 306void kvmppc_mmu_destroy(struct kvm_vcpu *vcpu)
diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c
index bc3a2ea9421..ddc485a529f 100644
--- a/arch/powerpc/kvm/book3s_64_mmu_hv.c
+++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c
@@ -23,6 +23,7 @@
23#include <linux/gfp.h> 23#include <linux/gfp.h>
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/hugetlb.h> 25#include <linux/hugetlb.h>
26#include <linux/vmalloc.h>
26 27
27#include <asm/tlbflush.h> 28#include <asm/tlbflush.h>
28#include <asm/kvm_ppc.h> 29#include <asm/kvm_ppc.h>
@@ -33,15 +34,6 @@
33#include <asm/ppc-opcode.h> 34#include <asm/ppc-opcode.h>
34#include <asm/cputable.h> 35#include <asm/cputable.h>
35 36
36/* For now use fixed-size 16MB page table */
37#define HPT_ORDER 24
38#define HPT_NPTEG (1ul << (HPT_ORDER - 7)) /* 128B per pteg */
39#define HPT_HASH_MASK (HPT_NPTEG - 1)
40
41/* Pages in the VRMA are 16MB pages */
42#define VRMA_PAGE_ORDER 24
43#define VRMA_VSID 0x1ffffffUL /* 1TB VSID reserved for VRMA */
44
45/* POWER7 has 10-bit LPIDs, PPC970 has 6-bit LPIDs */ 37/* POWER7 has 10-bit LPIDs, PPC970 has 6-bit LPIDs */
46#define MAX_LPID_970 63 38#define MAX_LPID_970 63
47#define NR_LPIDS (LPID_RSVD + 1) 39#define NR_LPIDS (LPID_RSVD + 1)
@@ -51,21 +43,41 @@ long kvmppc_alloc_hpt(struct kvm *kvm)
51{ 43{
52 unsigned long hpt; 44 unsigned long hpt;
53 unsigned long lpid; 45 unsigned long lpid;
46 struct revmap_entry *rev;
47 struct kvmppc_linear_info *li;
48
49 /* Allocate guest's hashed page table */
50 li = kvm_alloc_hpt();
51 if (li) {
52 /* using preallocated memory */
53 hpt = (ulong)li->base_virt;
54 kvm->arch.hpt_li = li;
55 } else {
56 /* using dynamic memory */
57 hpt = __get_free_pages(GFP_KERNEL|__GFP_ZERO|__GFP_REPEAT|
58 __GFP_NOWARN, HPT_ORDER - PAGE_SHIFT);
59 }
54 60
55 hpt = __get_free_pages(GFP_KERNEL|__GFP_ZERO|__GFP_REPEAT|__GFP_NOWARN,
56 HPT_ORDER - PAGE_SHIFT);
57 if (!hpt) { 61 if (!hpt) {
58 pr_err("kvm_alloc_hpt: Couldn't alloc HPT\n"); 62 pr_err("kvm_alloc_hpt: Couldn't alloc HPT\n");
59 return -ENOMEM; 63 return -ENOMEM;
60 } 64 }
61 kvm->arch.hpt_virt = hpt; 65 kvm->arch.hpt_virt = hpt;
62 66
67 /* Allocate reverse map array */
68 rev = vmalloc(sizeof(struct revmap_entry) * HPT_NPTE);
69 if (!rev) {
70 pr_err("kvmppc_alloc_hpt: Couldn't alloc reverse map array\n");
71 goto out_freehpt;
72 }
73 kvm->arch.revmap = rev;
74
75 /* Allocate the guest's logical partition ID */
63 do { 76 do {
64 lpid = find_first_zero_bit(lpid_inuse, NR_LPIDS); 77 lpid = find_first_zero_bit(lpid_inuse, NR_LPIDS);
65 if (lpid >= NR_LPIDS) { 78 if (lpid >= NR_LPIDS) {
66 pr_err("kvm_alloc_hpt: No LPIDs free\n"); 79 pr_err("kvm_alloc_hpt: No LPIDs free\n");
67 free_pages(hpt, HPT_ORDER - PAGE_SHIFT); 80 goto out_freeboth;
68 return -ENOMEM;
69 } 81 }
70 } while (test_and_set_bit(lpid, lpid_inuse)); 82 } while (test_and_set_bit(lpid, lpid_inuse));
71 83
@@ -74,37 +86,64 @@ long kvmppc_alloc_hpt(struct kvm *kvm)
74 86
75 pr_info("KVM guest htab at %lx, LPID %lx\n", hpt, lpid); 87 pr_info("KVM guest htab at %lx, LPID %lx\n", hpt, lpid);
76 return 0; 88 return 0;
89
90 out_freeboth:
91 vfree(rev);
92 out_freehpt:
93 free_pages(hpt, HPT_ORDER - PAGE_SHIFT);
94 return -ENOMEM;
77} 95}
78 96
79void kvmppc_free_hpt(struct kvm *kvm) 97void kvmppc_free_hpt(struct kvm *kvm)
80{ 98{
81 clear_bit(kvm->arch.lpid, lpid_inuse); 99 clear_bit(kvm->arch.lpid, lpid_inuse);
82 free_pages(kvm->arch.hpt_virt, HPT_ORDER - PAGE_SHIFT); 100 vfree(kvm->arch.revmap);
101 if (kvm->arch.hpt_li)
102 kvm_release_hpt(kvm->arch.hpt_li);
103 else
104 free_pages(kvm->arch.hpt_virt, HPT_ORDER - PAGE_SHIFT);
105}
106
107/* Bits in first HPTE dword for pagesize 4k, 64k or 16M */
108static inline unsigned long hpte0_pgsize_encoding(unsigned long pgsize)
109{
110 return (pgsize > 0x1000) ? HPTE_V_LARGE : 0;
111}
112
113/* Bits in second HPTE dword for pagesize 4k, 64k or 16M */
114static inline unsigned long hpte1_pgsize_encoding(unsigned long pgsize)
115{
116 return (pgsize == 0x10000) ? 0x1000 : 0;
83} 117}
84 118
85void kvmppc_map_vrma(struct kvm *kvm, struct kvm_userspace_memory_region *mem) 119void kvmppc_map_vrma(struct kvm_vcpu *vcpu, struct kvm_memory_slot *memslot,
120 unsigned long porder)
86{ 121{
87 unsigned long i; 122 unsigned long i;
88 unsigned long npages = kvm->arch.ram_npages; 123 unsigned long npages;
89 unsigned long pfn; 124 unsigned long hp_v, hp_r;
90 unsigned long *hpte; 125 unsigned long addr, hash;
91 unsigned long hash; 126 unsigned long psize;
92 struct kvmppc_pginfo *pginfo = kvm->arch.ram_pginfo; 127 unsigned long hp0, hp1;
128 long ret;
93 129
94 if (!pginfo) 130 psize = 1ul << porder;
95 return; 131 npages = memslot->npages >> (porder - PAGE_SHIFT);
96 132
97 /* VRMA can't be > 1TB */ 133 /* VRMA can't be > 1TB */
98 if (npages > 1ul << (40 - kvm->arch.ram_porder)) 134 if (npages > 1ul << (40 - porder))
99 npages = 1ul << (40 - kvm->arch.ram_porder); 135 npages = 1ul << (40 - porder);
100 /* Can't use more than 1 HPTE per HPTEG */ 136 /* Can't use more than 1 HPTE per HPTEG */
101 if (npages > HPT_NPTEG) 137 if (npages > HPT_NPTEG)
102 npages = HPT_NPTEG; 138 npages = HPT_NPTEG;
103 139
140 hp0 = HPTE_V_1TB_SEG | (VRMA_VSID << (40 - 16)) |
141 HPTE_V_BOLTED | hpte0_pgsize_encoding(psize);
142 hp1 = hpte1_pgsize_encoding(psize) |
143 HPTE_R_R | HPTE_R_C | HPTE_R_M | PP_RWXX;
144
104 for (i = 0; i < npages; ++i) { 145 for (i = 0; i < npages; ++i) {
105 pfn = pginfo[i].pfn; 146 addr = i << porder;
106 if (!pfn)
107 break;
108 /* can't use hpt_hash since va > 64 bits */ 147 /* can't use hpt_hash since va > 64 bits */
109 hash = (i ^ (VRMA_VSID ^ (VRMA_VSID << 25))) & HPT_HASH_MASK; 148 hash = (i ^ (VRMA_VSID ^ (VRMA_VSID << 25))) & HPT_HASH_MASK;
110 /* 149 /*
@@ -113,15 +152,15 @@ void kvmppc_map_vrma(struct kvm *kvm, struct kvm_userspace_memory_region *mem)
113 * at most one HPTE per HPTEG, we just assume entry 7 152 * at most one HPTE per HPTEG, we just assume entry 7
114 * is available and use it. 153 * is available and use it.
115 */ 154 */
116 hpte = (unsigned long *) (kvm->arch.hpt_virt + (hash << 7)); 155 hash = (hash << 3) + 7;
117 hpte += 7 * 2; 156 hp_v = hp0 | ((addr >> 16) & ~0x7fUL);
118 /* HPTE low word - RPN, protection, etc. */ 157 hp_r = hp1 | addr;
119 hpte[1] = (pfn << PAGE_SHIFT) | HPTE_R_R | HPTE_R_C | 158 ret = kvmppc_virtmode_h_enter(vcpu, H_EXACT, hash, hp_v, hp_r);
120 HPTE_R_M | PP_RWXX; 159 if (ret != H_SUCCESS) {
121 wmb(); 160 pr_err("KVM: map_vrma at %lx failed, ret=%ld\n",
122 hpte[0] = HPTE_V_1TB_SEG | (VRMA_VSID << (40 - 16)) | 161 addr, ret);
123 (i << (VRMA_PAGE_ORDER - 16)) | HPTE_V_BOLTED | 162 break;
124 HPTE_V_LARGE | HPTE_V_VALID; 163 }
125 } 164 }
126} 165}
127 166
@@ -158,10 +197,814 @@ static void kvmppc_mmu_book3s_64_hv_reset_msr(struct kvm_vcpu *vcpu)
158 kvmppc_set_msr(vcpu, MSR_SF | MSR_ME); 197 kvmppc_set_msr(vcpu, MSR_SF | MSR_ME);
159} 198}
160 199
200/*
201 * This is called to get a reference to a guest page if there isn't
202 * one already in the kvm->arch.slot_phys[][] arrays.
203 */
204static long kvmppc_get_guest_page(struct kvm *kvm, unsigned long gfn,
205 struct kvm_memory_slot *memslot,
206 unsigned long psize)
207{
208 unsigned long start;
209 long np, err;
210 struct page *page, *hpage, *pages[1];
211 unsigned long s, pgsize;
212 unsigned long *physp;
213 unsigned int is_io, got, pgorder;
214 struct vm_area_struct *vma;
215 unsigned long pfn, i, npages;
216
217 physp = kvm->arch.slot_phys[memslot->id];
218 if (!physp)
219 return -EINVAL;
220 if (physp[gfn - memslot->base_gfn])
221 return 0;
222
223 is_io = 0;
224 got = 0;
225 page = NULL;
226 pgsize = psize;
227 err = -EINVAL;
228 start = gfn_to_hva_memslot(memslot, gfn);
229
230 /* Instantiate and get the page we want access to */
231 np = get_user_pages_fast(start, 1, 1, pages);
232 if (np != 1) {
233 /* Look up the vma for the page */
234 down_read(&current->mm->mmap_sem);
235 vma = find_vma(current->mm, start);
236 if (!vma || vma->vm_start > start ||
237 start + psize > vma->vm_end ||
238 !(vma->vm_flags & VM_PFNMAP))
239 goto up_err;
240 is_io = hpte_cache_bits(pgprot_val(vma->vm_page_prot));
241 pfn = vma->vm_pgoff + ((start - vma->vm_start) >> PAGE_SHIFT);
242 /* check alignment of pfn vs. requested page size */
243 if (psize > PAGE_SIZE && (pfn & ((psize >> PAGE_SHIFT) - 1)))
244 goto up_err;
245 up_read(&current->mm->mmap_sem);
246
247 } else {
248 page = pages[0];
249 got = KVMPPC_GOT_PAGE;
250
251 /* See if this is a large page */
252 s = PAGE_SIZE;
253 if (PageHuge(page)) {
254 hpage = compound_head(page);
255 s <<= compound_order(hpage);
256 /* Get the whole large page if slot alignment is ok */
257 if (s > psize && slot_is_aligned(memslot, s) &&
258 !(memslot->userspace_addr & (s - 1))) {
259 start &= ~(s - 1);
260 pgsize = s;
261 page = hpage;
262 }
263 }
264 if (s < psize)
265 goto out;
266 pfn = page_to_pfn(page);
267 }
268
269 npages = pgsize >> PAGE_SHIFT;
270 pgorder = __ilog2(npages);
271 physp += (gfn - memslot->base_gfn) & ~(npages - 1);
272 spin_lock(&kvm->arch.slot_phys_lock);
273 for (i = 0; i < npages; ++i) {
274 if (!physp[i]) {
275 physp[i] = ((pfn + i) << PAGE_SHIFT) +
276 got + is_io + pgorder;
277 got = 0;
278 }
279 }
280 spin_unlock(&kvm->arch.slot_phys_lock);
281 err = 0;
282
283 out:
284 if (got) {
285 if (PageHuge(page))
286 page = compound_head(page);
287 put_page(page);
288 }
289 return err;
290
291 up_err:
292 up_read(&current->mm->mmap_sem);
293 return err;
294}
295
296/*
297 * We come here on a H_ENTER call from the guest when we are not
298 * using mmu notifiers and we don't have the requested page pinned
299 * already.
300 */
301long kvmppc_virtmode_h_enter(struct kvm_vcpu *vcpu, unsigned long flags,
302 long pte_index, unsigned long pteh, unsigned long ptel)
303{
304 struct kvm *kvm = vcpu->kvm;
305 unsigned long psize, gpa, gfn;
306 struct kvm_memory_slot *memslot;
307 long ret;
308
309 if (kvm->arch.using_mmu_notifiers)
310 goto do_insert;
311
312 psize = hpte_page_size(pteh, ptel);
313 if (!psize)
314 return H_PARAMETER;
315
316 pteh &= ~(HPTE_V_HVLOCK | HPTE_V_ABSENT | HPTE_V_VALID);
317
318 /* Find the memslot (if any) for this address */
319 gpa = (ptel & HPTE_R_RPN) & ~(psize - 1);
320 gfn = gpa >> PAGE_SHIFT;
321 memslot = gfn_to_memslot(kvm, gfn);
322 if (memslot && !(memslot->flags & KVM_MEMSLOT_INVALID)) {
323 if (!slot_is_aligned(memslot, psize))
324 return H_PARAMETER;
325 if (kvmppc_get_guest_page(kvm, gfn, memslot, psize) < 0)
326 return H_PARAMETER;
327 }
328
329 do_insert:
330 /* Protect linux PTE lookup from page table destruction */
331 rcu_read_lock_sched(); /* this disables preemption too */
332 vcpu->arch.pgdir = current->mm->pgd;
333 ret = kvmppc_h_enter(vcpu, flags, pte_index, pteh, ptel);
334 rcu_read_unlock_sched();
335 if (ret == H_TOO_HARD) {
336 /* this can't happen */
337 pr_err("KVM: Oops, kvmppc_h_enter returned too hard!\n");
338 ret = H_RESOURCE; /* or something */
339 }
340 return ret;
341
342}
343
344static struct kvmppc_slb *kvmppc_mmu_book3s_hv_find_slbe(struct kvm_vcpu *vcpu,
345 gva_t eaddr)
346{
347 u64 mask;
348 int i;
349
350 for (i = 0; i < vcpu->arch.slb_nr; i++) {
351 if (!(vcpu->arch.slb[i].orige & SLB_ESID_V))
352 continue;
353
354 if (vcpu->arch.slb[i].origv & SLB_VSID_B_1T)
355 mask = ESID_MASK_1T;
356 else
357 mask = ESID_MASK;
358
359 if (((vcpu->arch.slb[i].orige ^ eaddr) & mask) == 0)
360 return &vcpu->arch.slb[i];
361 }
362 return NULL;
363}
364
365static unsigned long kvmppc_mmu_get_real_addr(unsigned long v, unsigned long r,
366 unsigned long ea)
367{
368 unsigned long ra_mask;
369
370 ra_mask = hpte_page_size(v, r) - 1;
371 return (r & HPTE_R_RPN & ~ra_mask) | (ea & ra_mask);
372}
373
161static int kvmppc_mmu_book3s_64_hv_xlate(struct kvm_vcpu *vcpu, gva_t eaddr, 374static int kvmppc_mmu_book3s_64_hv_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,
162 struct kvmppc_pte *gpte, bool data) 375 struct kvmppc_pte *gpte, bool data)
376{
377 struct kvm *kvm = vcpu->kvm;
378 struct kvmppc_slb *slbe;
379 unsigned long slb_v;
380 unsigned long pp, key;
381 unsigned long v, gr;
382 unsigned long *hptep;
383 int index;
384 int virtmode = vcpu->arch.shregs.msr & (data ? MSR_DR : MSR_IR);
385
386 /* Get SLB entry */
387 if (virtmode) {
388 slbe = kvmppc_mmu_book3s_hv_find_slbe(vcpu, eaddr);
389 if (!slbe)
390 return -EINVAL;
391 slb_v = slbe->origv;
392 } else {
393 /* real mode access */
394 slb_v = vcpu->kvm->arch.vrma_slb_v;
395 }
396
397 /* Find the HPTE in the hash table */
398 index = kvmppc_hv_find_lock_hpte(kvm, eaddr, slb_v,
399 HPTE_V_VALID | HPTE_V_ABSENT);
400 if (index < 0)
401 return -ENOENT;
402 hptep = (unsigned long *)(kvm->arch.hpt_virt + (index << 4));
403 v = hptep[0] & ~HPTE_V_HVLOCK;
404 gr = kvm->arch.revmap[index].guest_rpte;
405
406 /* Unlock the HPTE */
407 asm volatile("lwsync" : : : "memory");
408 hptep[0] = v;
409
410 gpte->eaddr = eaddr;
411 gpte->vpage = ((v & HPTE_V_AVPN) << 4) | ((eaddr >> 12) & 0xfff);
412
413 /* Get PP bits and key for permission check */
414 pp = gr & (HPTE_R_PP0 | HPTE_R_PP);
415 key = (vcpu->arch.shregs.msr & MSR_PR) ? SLB_VSID_KP : SLB_VSID_KS;
416 key &= slb_v;
417
418 /* Calculate permissions */
419 gpte->may_read = hpte_read_permission(pp, key);
420 gpte->may_write = hpte_write_permission(pp, key);
421 gpte->may_execute = gpte->may_read && !(gr & (HPTE_R_N | HPTE_R_G));
422
423 /* Storage key permission check for POWER7 */
424 if (data && virtmode && cpu_has_feature(CPU_FTR_ARCH_206)) {
425 int amrfield = hpte_get_skey_perm(gr, vcpu->arch.amr);
426 if (amrfield & 1)
427 gpte->may_read = 0;
428 if (amrfield & 2)
429 gpte->may_write = 0;
430 }
431
432 /* Get the guest physical address */
433 gpte->raddr = kvmppc_mmu_get_real_addr(v, gr, eaddr);
434 return 0;
435}
436
437/*
438 * Quick test for whether an instruction is a load or a store.
439 * If the instruction is a load or a store, then this will indicate
440 * which it is, at least on server processors. (Embedded processors
441 * have some external PID instructions that don't follow the rule
442 * embodied here.) If the instruction isn't a load or store, then
443 * this doesn't return anything useful.
444 */
445static int instruction_is_store(unsigned int instr)
446{
447 unsigned int mask;
448
449 mask = 0x10000000;
450 if ((instr & 0xfc000000) == 0x7c000000)
451 mask = 0x100; /* major opcode 31 */
452 return (instr & mask) != 0;
453}
454
455static int kvmppc_hv_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu,
456 unsigned long gpa, int is_store)
457{
458 int ret;
459 u32 last_inst;
460 unsigned long srr0 = kvmppc_get_pc(vcpu);
461
462 /* We try to load the last instruction. We don't let
463 * emulate_instruction do it as it doesn't check what
464 * kvmppc_ld returns.
465 * If we fail, we just return to the guest and try executing it again.
466 */
467 if (vcpu->arch.last_inst == KVM_INST_FETCH_FAILED) {
468 ret = kvmppc_ld(vcpu, &srr0, sizeof(u32), &last_inst, false);
469 if (ret != EMULATE_DONE || last_inst == KVM_INST_FETCH_FAILED)
470 return RESUME_GUEST;
471 vcpu->arch.last_inst = last_inst;
472 }
473
474 /*
475 * WARNING: We do not know for sure whether the instruction we just
476 * read from memory is the same that caused the fault in the first
477 * place. If the instruction we read is neither an load or a store,
478 * then it can't access memory, so we don't need to worry about
479 * enforcing access permissions. So, assuming it is a load or
480 * store, we just check that its direction (load or store) is
481 * consistent with the original fault, since that's what we
482 * checked the access permissions against. If there is a mismatch
483 * we just return and retry the instruction.
484 */
485
486 if (instruction_is_store(vcpu->arch.last_inst) != !!is_store)
487 return RESUME_GUEST;
488
489 /*
490 * Emulated accesses are emulated by looking at the hash for
491 * translation once, then performing the access later. The
492 * translation could be invalidated in the meantime in which
493 * point performing the subsequent memory access on the old
494 * physical address could possibly be a security hole for the
495 * guest (but not the host).
496 *
497 * This is less of an issue for MMIO stores since they aren't
498 * globally visible. It could be an issue for MMIO loads to
499 * a certain extent but we'll ignore it for now.
500 */
501
502 vcpu->arch.paddr_accessed = gpa;
503 return kvmppc_emulate_mmio(run, vcpu);
504}
505
506int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
507 unsigned long ea, unsigned long dsisr)
508{
509 struct kvm *kvm = vcpu->kvm;
510 unsigned long *hptep, hpte[3], r;
511 unsigned long mmu_seq, psize, pte_size;
512 unsigned long gfn, hva, pfn;
513 struct kvm_memory_slot *memslot;
514 unsigned long *rmap;
515 struct revmap_entry *rev;
516 struct page *page, *pages[1];
517 long index, ret, npages;
518 unsigned long is_io;
519 unsigned int writing, write_ok;
520 struct vm_area_struct *vma;
521 unsigned long rcbits;
522
523 /*
524 * Real-mode code has already searched the HPT and found the
525 * entry we're interested in. Lock the entry and check that
526 * it hasn't changed. If it has, just return and re-execute the
527 * instruction.
528 */
529 if (ea != vcpu->arch.pgfault_addr)
530 return RESUME_GUEST;
531 index = vcpu->arch.pgfault_index;
532 hptep = (unsigned long *)(kvm->arch.hpt_virt + (index << 4));
533 rev = &kvm->arch.revmap[index];
534 preempt_disable();
535 while (!try_lock_hpte(hptep, HPTE_V_HVLOCK))
536 cpu_relax();
537 hpte[0] = hptep[0] & ~HPTE_V_HVLOCK;
538 hpte[1] = hptep[1];
539 hpte[2] = r = rev->guest_rpte;
540 asm volatile("lwsync" : : : "memory");
541 hptep[0] = hpte[0];
542 preempt_enable();
543
544 if (hpte[0] != vcpu->arch.pgfault_hpte[0] ||
545 hpte[1] != vcpu->arch.pgfault_hpte[1])
546 return RESUME_GUEST;
547
548 /* Translate the logical address and get the page */
549 psize = hpte_page_size(hpte[0], r);
550 gfn = hpte_rpn(r, psize);
551 memslot = gfn_to_memslot(kvm, gfn);
552
553 /* No memslot means it's an emulated MMIO region */
554 if (!memslot || (memslot->flags & KVM_MEMSLOT_INVALID)) {
555 unsigned long gpa = (gfn << PAGE_SHIFT) | (ea & (psize - 1));
556 return kvmppc_hv_emulate_mmio(run, vcpu, gpa,
557 dsisr & DSISR_ISSTORE);
558 }
559
560 if (!kvm->arch.using_mmu_notifiers)
561 return -EFAULT; /* should never get here */
562
563 /* used to check for invalidations in progress */
564 mmu_seq = kvm->mmu_notifier_seq;
565 smp_rmb();
566
567 is_io = 0;
568 pfn = 0;
569 page = NULL;
570 pte_size = PAGE_SIZE;
571 writing = (dsisr & DSISR_ISSTORE) != 0;
572 /* If writing != 0, then the HPTE must allow writing, if we get here */
573 write_ok = writing;
574 hva = gfn_to_hva_memslot(memslot, gfn);
575 npages = get_user_pages_fast(hva, 1, writing, pages);
576 if (npages < 1) {
577 /* Check if it's an I/O mapping */
578 down_read(&current->mm->mmap_sem);
579 vma = find_vma(current->mm, hva);
580 if (vma && vma->vm_start <= hva && hva + psize <= vma->vm_end &&
581 (vma->vm_flags & VM_PFNMAP)) {
582 pfn = vma->vm_pgoff +
583 ((hva - vma->vm_start) >> PAGE_SHIFT);
584 pte_size = psize;
585 is_io = hpte_cache_bits(pgprot_val(vma->vm_page_prot));
586 write_ok = vma->vm_flags & VM_WRITE;
587 }
588 up_read(&current->mm->mmap_sem);
589 if (!pfn)
590 return -EFAULT;
591 } else {
592 page = pages[0];
593 if (PageHuge(page)) {
594 page = compound_head(page);
595 pte_size <<= compound_order(page);
596 }
597 /* if the guest wants write access, see if that is OK */
598 if (!writing && hpte_is_writable(r)) {
599 pte_t *ptep, pte;
600
601 /*
602 * We need to protect against page table destruction
603 * while looking up and updating the pte.
604 */
605 rcu_read_lock_sched();
606 ptep = find_linux_pte_or_hugepte(current->mm->pgd,
607 hva, NULL);
608 if (ptep && pte_present(*ptep)) {
609 pte = kvmppc_read_update_linux_pte(ptep, 1);
610 if (pte_write(pte))
611 write_ok = 1;
612 }
613 rcu_read_unlock_sched();
614 }
615 pfn = page_to_pfn(page);
616 }
617
618 ret = -EFAULT;
619 if (psize > pte_size)
620 goto out_put;
621
622 /* Check WIMG vs. the actual page we're accessing */
623 if (!hpte_cache_flags_ok(r, is_io)) {
624 if (is_io)
625 return -EFAULT;
626 /*
627 * Allow guest to map emulated device memory as
628 * uncacheable, but actually make it cacheable.
629 */
630 r = (r & ~(HPTE_R_W|HPTE_R_I|HPTE_R_G)) | HPTE_R_M;
631 }
632
633 /* Set the HPTE to point to pfn */
634 r = (r & ~(HPTE_R_PP0 - pte_size)) | (pfn << PAGE_SHIFT);
635 if (hpte_is_writable(r) && !write_ok)
636 r = hpte_make_readonly(r);
637 ret = RESUME_GUEST;
638 preempt_disable();
639 while (!try_lock_hpte(hptep, HPTE_V_HVLOCK))
640 cpu_relax();
641 if ((hptep[0] & ~HPTE_V_HVLOCK) != hpte[0] || hptep[1] != hpte[1] ||
642 rev->guest_rpte != hpte[2])
643 /* HPTE has been changed under us; let the guest retry */
644 goto out_unlock;
645 hpte[0] = (hpte[0] & ~HPTE_V_ABSENT) | HPTE_V_VALID;
646
647 rmap = &memslot->rmap[gfn - memslot->base_gfn];
648 lock_rmap(rmap);
649
650 /* Check if we might have been invalidated; let the guest retry if so */
651 ret = RESUME_GUEST;
652 if (mmu_notifier_retry(vcpu, mmu_seq)) {
653 unlock_rmap(rmap);
654 goto out_unlock;
655 }
656
657 /* Only set R/C in real HPTE if set in both *rmap and guest_rpte */
658 rcbits = *rmap >> KVMPPC_RMAP_RC_SHIFT;
659 r &= rcbits | ~(HPTE_R_R | HPTE_R_C);
660
661 if (hptep[0] & HPTE_V_VALID) {
662 /* HPTE was previously valid, so we need to invalidate it */
663 unlock_rmap(rmap);
664 hptep[0] |= HPTE_V_ABSENT;
665 kvmppc_invalidate_hpte(kvm, hptep, index);
666 /* don't lose previous R and C bits */
667 r |= hptep[1] & (HPTE_R_R | HPTE_R_C);
668 } else {
669 kvmppc_add_revmap_chain(kvm, rev, rmap, index, 0);
670 }
671
672 hptep[1] = r;
673 eieio();
674 hptep[0] = hpte[0];
675 asm volatile("ptesync" : : : "memory");
676 preempt_enable();
677 if (page && hpte_is_writable(r))
678 SetPageDirty(page);
679
680 out_put:
681 if (page)
682 put_page(page);
683 return ret;
684
685 out_unlock:
686 hptep[0] &= ~HPTE_V_HVLOCK;
687 preempt_enable();
688 goto out_put;
689}
690
691static int kvm_handle_hva(struct kvm *kvm, unsigned long hva,
692 int (*handler)(struct kvm *kvm, unsigned long *rmapp,
693 unsigned long gfn))
694{
695 int ret;
696 int retval = 0;
697 struct kvm_memslots *slots;
698 struct kvm_memory_slot *memslot;
699
700 slots = kvm_memslots(kvm);
701 kvm_for_each_memslot(memslot, slots) {
702 unsigned long start = memslot->userspace_addr;
703 unsigned long end;
704
705 end = start + (memslot->npages << PAGE_SHIFT);
706 if (hva >= start && hva < end) {
707 gfn_t gfn_offset = (hva - start) >> PAGE_SHIFT;
708
709 ret = handler(kvm, &memslot->rmap[gfn_offset],
710 memslot->base_gfn + gfn_offset);
711 retval |= ret;
712 }
713 }
714
715 return retval;
716}
717
718static int kvm_unmap_rmapp(struct kvm *kvm, unsigned long *rmapp,
719 unsigned long gfn)
720{
721 struct revmap_entry *rev = kvm->arch.revmap;
722 unsigned long h, i, j;
723 unsigned long *hptep;
724 unsigned long ptel, psize, rcbits;
725
726 for (;;) {
727 lock_rmap(rmapp);
728 if (!(*rmapp & KVMPPC_RMAP_PRESENT)) {
729 unlock_rmap(rmapp);
730 break;
731 }
732
733 /*
734 * To avoid an ABBA deadlock with the HPTE lock bit,
735 * we can't spin on the HPTE lock while holding the
736 * rmap chain lock.
737 */
738 i = *rmapp & KVMPPC_RMAP_INDEX;
739 hptep = (unsigned long *) (kvm->arch.hpt_virt + (i << 4));
740 if (!try_lock_hpte(hptep, HPTE_V_HVLOCK)) {
741 /* unlock rmap before spinning on the HPTE lock */
742 unlock_rmap(rmapp);
743 while (hptep[0] & HPTE_V_HVLOCK)
744 cpu_relax();
745 continue;
746 }
747 j = rev[i].forw;
748 if (j == i) {
749 /* chain is now empty */
750 *rmapp &= ~(KVMPPC_RMAP_PRESENT | KVMPPC_RMAP_INDEX);
751 } else {
752 /* remove i from chain */
753 h = rev[i].back;
754 rev[h].forw = j;
755 rev[j].back = h;
756 rev[i].forw = rev[i].back = i;
757 *rmapp = (*rmapp & ~KVMPPC_RMAP_INDEX) | j;
758 }
759
760 /* Now check and modify the HPTE */
761 ptel = rev[i].guest_rpte;
762 psize = hpte_page_size(hptep[0], ptel);
763 if ((hptep[0] & HPTE_V_VALID) &&
764 hpte_rpn(ptel, psize) == gfn) {
765 hptep[0] |= HPTE_V_ABSENT;
766 kvmppc_invalidate_hpte(kvm, hptep, i);
767 /* Harvest R and C */
768 rcbits = hptep[1] & (HPTE_R_R | HPTE_R_C);
769 *rmapp |= rcbits << KVMPPC_RMAP_RC_SHIFT;
770 rev[i].guest_rpte = ptel | rcbits;
771 }
772 unlock_rmap(rmapp);
773 hptep[0] &= ~HPTE_V_HVLOCK;
774 }
775 return 0;
776}
777
778int kvm_unmap_hva(struct kvm *kvm, unsigned long hva)
779{
780 if (kvm->arch.using_mmu_notifiers)
781 kvm_handle_hva(kvm, hva, kvm_unmap_rmapp);
782 return 0;
783}
784
785static int kvm_age_rmapp(struct kvm *kvm, unsigned long *rmapp,
786 unsigned long gfn)
787{
788 struct revmap_entry *rev = kvm->arch.revmap;
789 unsigned long head, i, j;
790 unsigned long *hptep;
791 int ret = 0;
792
793 retry:
794 lock_rmap(rmapp);
795 if (*rmapp & KVMPPC_RMAP_REFERENCED) {
796 *rmapp &= ~KVMPPC_RMAP_REFERENCED;
797 ret = 1;
798 }
799 if (!(*rmapp & KVMPPC_RMAP_PRESENT)) {
800 unlock_rmap(rmapp);
801 return ret;
802 }
803
804 i = head = *rmapp & KVMPPC_RMAP_INDEX;
805 do {
806 hptep = (unsigned long *) (kvm->arch.hpt_virt + (i << 4));
807 j = rev[i].forw;
808
809 /* If this HPTE isn't referenced, ignore it */
810 if (!(hptep[1] & HPTE_R_R))
811 continue;
812
813 if (!try_lock_hpte(hptep, HPTE_V_HVLOCK)) {
814 /* unlock rmap before spinning on the HPTE lock */
815 unlock_rmap(rmapp);
816 while (hptep[0] & HPTE_V_HVLOCK)
817 cpu_relax();
818 goto retry;
819 }
820
821 /* Now check and modify the HPTE */
822 if ((hptep[0] & HPTE_V_VALID) && (hptep[1] & HPTE_R_R)) {
823 kvmppc_clear_ref_hpte(kvm, hptep, i);
824 rev[i].guest_rpte |= HPTE_R_R;
825 ret = 1;
826 }
827 hptep[0] &= ~HPTE_V_HVLOCK;
828 } while ((i = j) != head);
829
830 unlock_rmap(rmapp);
831 return ret;
832}
833
834int kvm_age_hva(struct kvm *kvm, unsigned long hva)
835{
836 if (!kvm->arch.using_mmu_notifiers)
837 return 0;
838 return kvm_handle_hva(kvm, hva, kvm_age_rmapp);
839}
840
841static int kvm_test_age_rmapp(struct kvm *kvm, unsigned long *rmapp,
842 unsigned long gfn)
843{
844 struct revmap_entry *rev = kvm->arch.revmap;
845 unsigned long head, i, j;
846 unsigned long *hp;
847 int ret = 1;
848
849 if (*rmapp & KVMPPC_RMAP_REFERENCED)
850 return 1;
851
852 lock_rmap(rmapp);
853 if (*rmapp & KVMPPC_RMAP_REFERENCED)
854 goto out;
855
856 if (*rmapp & KVMPPC_RMAP_PRESENT) {
857 i = head = *rmapp & KVMPPC_RMAP_INDEX;
858 do {
859 hp = (unsigned long *)(kvm->arch.hpt_virt + (i << 4));
860 j = rev[i].forw;
861 if (hp[1] & HPTE_R_R)
862 goto out;
863 } while ((i = j) != head);
864 }
865 ret = 0;
866
867 out:
868 unlock_rmap(rmapp);
869 return ret;
870}
871
872int kvm_test_age_hva(struct kvm *kvm, unsigned long hva)
873{
874 if (!kvm->arch.using_mmu_notifiers)
875 return 0;
876 return kvm_handle_hva(kvm, hva, kvm_test_age_rmapp);
877}
878
879void kvm_set_spte_hva(struct kvm *kvm, unsigned long hva, pte_t pte)
163{ 880{
164 return -ENOENT; 881 if (!kvm->arch.using_mmu_notifiers)
882 return;
883 kvm_handle_hva(kvm, hva, kvm_unmap_rmapp);
884}
885
886static int kvm_test_clear_dirty(struct kvm *kvm, unsigned long *rmapp)
887{
888 struct revmap_entry *rev = kvm->arch.revmap;
889 unsigned long head, i, j;
890 unsigned long *hptep;
891 int ret = 0;
892
893 retry:
894 lock_rmap(rmapp);
895 if (*rmapp & KVMPPC_RMAP_CHANGED) {
896 *rmapp &= ~KVMPPC_RMAP_CHANGED;
897 ret = 1;
898 }
899 if (!(*rmapp & KVMPPC_RMAP_PRESENT)) {
900 unlock_rmap(rmapp);
901 return ret;
902 }
903
904 i = head = *rmapp & KVMPPC_RMAP_INDEX;
905 do {
906 hptep = (unsigned long *) (kvm->arch.hpt_virt + (i << 4));
907 j = rev[i].forw;
908
909 if (!(hptep[1] & HPTE_R_C))
910 continue;
911
912 if (!try_lock_hpte(hptep, HPTE_V_HVLOCK)) {
913 /* unlock rmap before spinning on the HPTE lock */
914 unlock_rmap(rmapp);
915 while (hptep[0] & HPTE_V_HVLOCK)
916 cpu_relax();
917 goto retry;
918 }
919
920 /* Now check and modify the HPTE */
921 if ((hptep[0] & HPTE_V_VALID) && (hptep[1] & HPTE_R_C)) {
922 /* need to make it temporarily absent to clear C */
923 hptep[0] |= HPTE_V_ABSENT;
924 kvmppc_invalidate_hpte(kvm, hptep, i);
925 hptep[1] &= ~HPTE_R_C;
926 eieio();
927 hptep[0] = (hptep[0] & ~HPTE_V_ABSENT) | HPTE_V_VALID;
928 rev[i].guest_rpte |= HPTE_R_C;
929 ret = 1;
930 }
931 hptep[0] &= ~HPTE_V_HVLOCK;
932 } while ((i = j) != head);
933
934 unlock_rmap(rmapp);
935 return ret;
936}
937
938long kvmppc_hv_get_dirty_log(struct kvm *kvm, struct kvm_memory_slot *memslot)
939{
940 unsigned long i;
941 unsigned long *rmapp, *map;
942
943 preempt_disable();
944 rmapp = memslot->rmap;
945 map = memslot->dirty_bitmap;
946 for (i = 0; i < memslot->npages; ++i) {
947 if (kvm_test_clear_dirty(kvm, rmapp))
948 __set_bit_le(i, map);
949 ++rmapp;
950 }
951 preempt_enable();
952 return 0;
953}
954
955void *kvmppc_pin_guest_page(struct kvm *kvm, unsigned long gpa,
956 unsigned long *nb_ret)
957{
958 struct kvm_memory_slot *memslot;
959 unsigned long gfn = gpa >> PAGE_SHIFT;
960 struct page *page, *pages[1];
961 int npages;
962 unsigned long hva, psize, offset;
963 unsigned long pa;
964 unsigned long *physp;
965
966 memslot = gfn_to_memslot(kvm, gfn);
967 if (!memslot || (memslot->flags & KVM_MEMSLOT_INVALID))
968 return NULL;
969 if (!kvm->arch.using_mmu_notifiers) {
970 physp = kvm->arch.slot_phys[memslot->id];
971 if (!physp)
972 return NULL;
973 physp += gfn - memslot->base_gfn;
974 pa = *physp;
975 if (!pa) {
976 if (kvmppc_get_guest_page(kvm, gfn, memslot,
977 PAGE_SIZE) < 0)
978 return NULL;
979 pa = *physp;
980 }
981 page = pfn_to_page(pa >> PAGE_SHIFT);
982 } else {
983 hva = gfn_to_hva_memslot(memslot, gfn);
984 npages = get_user_pages_fast(hva, 1, 1, pages);
985 if (npages < 1)
986 return NULL;
987 page = pages[0];
988 }
989 psize = PAGE_SIZE;
990 if (PageHuge(page)) {
991 page = compound_head(page);
992 psize <<= compound_order(page);
993 }
994 if (!kvm->arch.using_mmu_notifiers)
995 get_page(page);
996 offset = gpa & (psize - 1);
997 if (nb_ret)
998 *nb_ret = psize - offset;
999 return page_address(page) + offset;
1000}
1001
1002void kvmppc_unpin_guest_page(struct kvm *kvm, void *va)
1003{
1004 struct page *page = virt_to_page(va);
1005
1006 page = compound_head(page);
1007 put_page(page);
165} 1008}
166 1009
167void kvmppc_mmu_book3s_hv_init(struct kvm_vcpu *vcpu) 1010void kvmppc_mmu_book3s_hv_init(struct kvm_vcpu *vcpu)
diff --git a/arch/powerpc/kvm/book3s_emulate.c b/arch/powerpc/kvm/book3s_emulate.c
index 0c9dc62532d..f1950d13182 100644
--- a/arch/powerpc/kvm/book3s_emulate.c
+++ b/arch/powerpc/kvm/book3s_emulate.c
@@ -230,9 +230,12 @@ int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
230 230
231 r = kvmppc_st(vcpu, &addr, 32, zeros, true); 231 r = kvmppc_st(vcpu, &addr, 32, zeros, true);
232 if ((r == -ENOENT) || (r == -EPERM)) { 232 if ((r == -ENOENT) || (r == -EPERM)) {
233 struct kvmppc_book3s_shadow_vcpu *svcpu;
234
235 svcpu = svcpu_get(vcpu);
233 *advance = 0; 236 *advance = 0;
234 vcpu->arch.shared->dar = vaddr; 237 vcpu->arch.shared->dar = vaddr;
235 to_svcpu(vcpu)->fault_dar = vaddr; 238 svcpu->fault_dar = vaddr;
236 239
237 dsisr = DSISR_ISSTORE; 240 dsisr = DSISR_ISSTORE;
238 if (r == -ENOENT) 241 if (r == -ENOENT)
@@ -241,7 +244,8 @@ int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
241 dsisr |= DSISR_PROTFAULT; 244 dsisr |= DSISR_PROTFAULT;
242 245
243 vcpu->arch.shared->dsisr = dsisr; 246 vcpu->arch.shared->dsisr = dsisr;
244 to_svcpu(vcpu)->fault_dsisr = dsisr; 247 svcpu->fault_dsisr = dsisr;
248 svcpu_put(svcpu);
245 249
246 kvmppc_book3s_queue_irqprio(vcpu, 250 kvmppc_book3s_queue_irqprio(vcpu,
247 BOOK3S_INTERRUPT_DATA_STORAGE); 251 BOOK3S_INTERRUPT_DATA_STORAGE);
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index ab4267760b7..01294a5099d 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -49,22 +49,14 @@
49#include <linux/gfp.h> 49#include <linux/gfp.h>
50#include <linux/vmalloc.h> 50#include <linux/vmalloc.h>
51#include <linux/highmem.h> 51#include <linux/highmem.h>
52 52#include <linux/hugetlb.h>
53/*
54 * For now, limit memory to 64GB and require it to be large pages.
55 * This value is chosen because it makes the ram_pginfo array be
56 * 64kB in size, which is about as large as we want to be trying
57 * to allocate with kmalloc.
58 */
59#define MAX_MEM_ORDER 36
60
61#define LARGE_PAGE_ORDER 24 /* 16MB pages */
62 53
63/* #define EXIT_DEBUG */ 54/* #define EXIT_DEBUG */
64/* #define EXIT_DEBUG_SIMPLE */ 55/* #define EXIT_DEBUG_SIMPLE */
65/* #define EXIT_DEBUG_INT */ 56/* #define EXIT_DEBUG_INT */
66 57
67static 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);
68 60
69void kvmppc_core_vcpu_load(struct kvm_vcpu *vcpu, int cpu) 61void kvmppc_core_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
70{ 62{
@@ -147,10 +139,10 @@ static unsigned long do_h_register_vpa(struct kvm_vcpu *vcpu,
147 unsigned long vcpuid, unsigned long vpa) 139 unsigned long vcpuid, unsigned long vpa)
148{ 140{
149 struct kvm *kvm = vcpu->kvm; 141 struct kvm *kvm = vcpu->kvm;
150 unsigned long pg_index, ra, len; 142 unsigned long len, nb;
151 unsigned long pg_offset;
152 void *va; 143 void *va;
153 struct kvm_vcpu *tvcpu; 144 struct kvm_vcpu *tvcpu;
145 int err = H_PARAMETER;
154 146
155 tvcpu = kvmppc_find_vcpu(kvm, vcpuid); 147 tvcpu = kvmppc_find_vcpu(kvm, vcpuid);
156 if (!tvcpu) 148 if (!tvcpu)
@@ -163,45 +155,41 @@ static unsigned long do_h_register_vpa(struct kvm_vcpu *vcpu,
163 if (flags < 4) { 155 if (flags < 4) {
164 if (vpa & 0x7f) 156 if (vpa & 0x7f)
165 return H_PARAMETER; 157 return H_PARAMETER;
158 if (flags >= 2 && !tvcpu->arch.vpa)
159 return H_RESOURCE;
166 /* registering new area; convert logical addr to real */ 160 /* registering new area; convert logical addr to real */
167 pg_index = vpa >> kvm->arch.ram_porder; 161 va = kvmppc_pin_guest_page(kvm, vpa, &nb);
168 pg_offset = vpa & (kvm->arch.ram_psize - 1); 162 if (va == NULL)
169 if (pg_index >= kvm->arch.ram_npages)
170 return H_PARAMETER; 163 return H_PARAMETER;
171 if (kvm->arch.ram_pginfo[pg_index].pfn == 0)
172 return H_PARAMETER;
173 ra = kvm->arch.ram_pginfo[pg_index].pfn << PAGE_SHIFT;
174 ra |= pg_offset;
175 va = __va(ra);
176 if (flags <= 1) 164 if (flags <= 1)
177 len = *(unsigned short *)(va + 4); 165 len = *(unsigned short *)(va + 4);
178 else 166 else
179 len = *(unsigned int *)(va + 4); 167 len = *(unsigned int *)(va + 4);
180 if (pg_offset + len > kvm->arch.ram_psize) 168 if (len > nb)
181 return H_PARAMETER; 169 goto out_unpin;
182 switch (flags) { 170 switch (flags) {
183 case 1: /* register VPA */ 171 case 1: /* register VPA */
184 if (len < 640) 172 if (len < 640)
185 return H_PARAMETER; 173 goto out_unpin;
174 if (tvcpu->arch.vpa)
175 kvmppc_unpin_guest_page(kvm, vcpu->arch.vpa);
186 tvcpu->arch.vpa = va; 176 tvcpu->arch.vpa = va;
187 init_vpa(vcpu, va); 177 init_vpa(vcpu, va);
188 break; 178 break;
189 case 2: /* register DTL */ 179 case 2: /* register DTL */
190 if (len < 48) 180 if (len < 48)
191 return H_PARAMETER; 181 goto out_unpin;
192 if (!tvcpu->arch.vpa)
193 return H_RESOURCE;
194 len -= len % 48; 182 len -= len % 48;
183 if (tvcpu->arch.dtl)
184 kvmppc_unpin_guest_page(kvm, vcpu->arch.dtl);
195 tvcpu->arch.dtl = va; 185 tvcpu->arch.dtl = va;
196 tvcpu->arch.dtl_end = va + len; 186 tvcpu->arch.dtl_end = va + len;
197 break; 187 break;
198 case 3: /* register SLB shadow buffer */ 188 case 3: /* register SLB shadow buffer */
199 if (len < 8) 189 if (len < 16)
200 return H_PARAMETER; 190 goto out_unpin;
201 if (!tvcpu->arch.vpa) 191 if (tvcpu->arch.slb_shadow)
202 return H_RESOURCE; 192 kvmppc_unpin_guest_page(kvm, vcpu->arch.slb_shadow);
203 tvcpu->arch.slb_shadow = va;
204 len = (len - 16) / 16;
205 tvcpu->arch.slb_shadow = va; 193 tvcpu->arch.slb_shadow = va;
206 break; 194 break;
207 } 195 }
@@ -210,17 +198,30 @@ static unsigned long do_h_register_vpa(struct kvm_vcpu *vcpu,
210 case 5: /* unregister VPA */ 198 case 5: /* unregister VPA */
211 if (tvcpu->arch.slb_shadow || tvcpu->arch.dtl) 199 if (tvcpu->arch.slb_shadow || tvcpu->arch.dtl)
212 return H_RESOURCE; 200 return H_RESOURCE;
201 if (!tvcpu->arch.vpa)
202 break;
203 kvmppc_unpin_guest_page(kvm, tvcpu->arch.vpa);
213 tvcpu->arch.vpa = NULL; 204 tvcpu->arch.vpa = NULL;
214 break; 205 break;
215 case 6: /* unregister DTL */ 206 case 6: /* unregister DTL */
207 if (!tvcpu->arch.dtl)
208 break;
209 kvmppc_unpin_guest_page(kvm, tvcpu->arch.dtl);
216 tvcpu->arch.dtl = NULL; 210 tvcpu->arch.dtl = NULL;
217 break; 211 break;
218 case 7: /* unregister SLB shadow buffer */ 212 case 7: /* unregister SLB shadow buffer */
213 if (!tvcpu->arch.slb_shadow)
214 break;
215 kvmppc_unpin_guest_page(kvm, tvcpu->arch.slb_shadow);
219 tvcpu->arch.slb_shadow = NULL; 216 tvcpu->arch.slb_shadow = NULL;
220 break; 217 break;
221 } 218 }
222 } 219 }
223 return H_SUCCESS; 220 return H_SUCCESS;
221
222 out_unpin:
223 kvmppc_unpin_guest_page(kvm, va);
224 return err;
224} 225}
225 226
226int kvmppc_pseries_do_hcall(struct kvm_vcpu *vcpu) 227int kvmppc_pseries_do_hcall(struct kvm_vcpu *vcpu)
@@ -230,6 +231,12 @@ int kvmppc_pseries_do_hcall(struct kvm_vcpu *vcpu)
230 struct kvm_vcpu *tvcpu; 231 struct kvm_vcpu *tvcpu;
231 232
232 switch (req) { 233 switch (req) {
234 case H_ENTER:
235 ret = kvmppc_virtmode_h_enter(vcpu, kvmppc_get_gpr(vcpu, 4),
236 kvmppc_get_gpr(vcpu, 5),
237 kvmppc_get_gpr(vcpu, 6),
238 kvmppc_get_gpr(vcpu, 7));
239 break;
233 case H_CEDE: 240 case H_CEDE:
234 break; 241 break;
235 case H_PROD: 242 case H_PROD:
@@ -319,20 +326,19 @@ static int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
319 break; 326 break;
320 } 327 }
321 /* 328 /*
322 * We get these next two if the guest does a bad real-mode access, 329 * We get these next two if the guest accesses a page which it thinks
323 * as we have enabled VRMA (virtualized real mode area) mode in the 330 * it has mapped but which is not actually present, either because
324 * LPCR. We just generate an appropriate DSI/ISI to the guest. 331 * it is for an emulated I/O device or because the corresonding
332 * host page has been paged out. Any other HDSI/HISI interrupts
333 * have been handled already.
325 */ 334 */
326 case BOOK3S_INTERRUPT_H_DATA_STORAGE: 335 case BOOK3S_INTERRUPT_H_DATA_STORAGE:
327 vcpu->arch.shregs.dsisr = vcpu->arch.fault_dsisr; 336 r = kvmppc_book3s_hv_page_fault(run, vcpu,
328 vcpu->arch.shregs.dar = vcpu->arch.fault_dar; 337 vcpu->arch.fault_dar, vcpu->arch.fault_dsisr);
329 kvmppc_inject_interrupt(vcpu, BOOK3S_INTERRUPT_DATA_STORAGE, 0);
330 r = RESUME_GUEST;
331 break; 338 break;
332 case BOOK3S_INTERRUPT_H_INST_STORAGE: 339 case BOOK3S_INTERRUPT_H_INST_STORAGE:
333 kvmppc_inject_interrupt(vcpu, BOOK3S_INTERRUPT_INST_STORAGE, 340 r = kvmppc_book3s_hv_page_fault(run, vcpu,
334 0x08000000); 341 kvmppc_get_pc(vcpu), 0);
335 r = RESUME_GUEST;
336 break; 342 break;
337 /* 343 /*
338 * This occurs if the guest executes an illegal instruction. 344 * This occurs if the guest executes an illegal instruction.
@@ -392,6 +398,42 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
392 return 0; 398 return 0;
393} 399}
394 400
401int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
402{
403 int r = -EINVAL;
404
405 switch (reg->id) {
406 case KVM_REG_PPC_HIOR:
407 r = put_user(0, (u64 __user *)reg->addr);
408 break;
409 default:
410 break;
411 }
412
413 return r;
414}
415
416int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
417{
418 int r = -EINVAL;
419
420 switch (reg->id) {
421 case KVM_REG_PPC_HIOR:
422 {
423 u64 hior;
424 /* Only allow this to be set to zero */
425 r = get_user(hior, (u64 __user *)reg->addr);
426 if (!r && (hior != 0))
427 r = -EINVAL;
428 break;
429 }
430 default:
431 break;
432 }
433
434 return r;
435}
436
395int kvmppc_core_check_processor_compat(void) 437int kvmppc_core_check_processor_compat(void)
396{ 438{
397 if (cpu_has_feature(CPU_FTR_HVMODE)) 439 if (cpu_has_feature(CPU_FTR_HVMODE))
@@ -411,7 +453,7 @@ struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm, unsigned int id)
411 goto out; 453 goto out;
412 454
413 err = -ENOMEM; 455 err = -ENOMEM;
414 vcpu = kzalloc(sizeof(struct kvm_vcpu), GFP_KERNEL); 456 vcpu = kmem_cache_zalloc(kvm_vcpu_cache, GFP_KERNEL);
415 if (!vcpu) 457 if (!vcpu)
416 goto out; 458 goto out;
417 459
@@ -463,15 +505,21 @@ struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm, unsigned int id)
463 return vcpu; 505 return vcpu;
464 506
465free_vcpu: 507free_vcpu:
466 kfree(vcpu); 508 kmem_cache_free(kvm_vcpu_cache, vcpu);
467out: 509out:
468 return ERR_PTR(err); 510 return ERR_PTR(err);
469} 511}
470 512
471void kvmppc_core_vcpu_free(struct kvm_vcpu *vcpu) 513void kvmppc_core_vcpu_free(struct kvm_vcpu *vcpu)
472{ 514{
515 if (vcpu->arch.dtl)
516 kvmppc_unpin_guest_page(vcpu->kvm, vcpu->arch.dtl);
517 if (vcpu->arch.slb_shadow)
518 kvmppc_unpin_guest_page(vcpu->kvm, vcpu->arch.slb_shadow);
519 if (vcpu->arch.vpa)
520 kvmppc_unpin_guest_page(vcpu->kvm, vcpu->arch.vpa);
473 kvm_vcpu_uninit(vcpu); 521 kvm_vcpu_uninit(vcpu);
474 kfree(vcpu); 522 kmem_cache_free(kvm_vcpu_cache, vcpu);
475} 523}
476 524
477static void kvmppc_set_timer(struct kvm_vcpu *vcpu) 525static void kvmppc_set_timer(struct kvm_vcpu *vcpu)
@@ -482,7 +530,7 @@ static void kvmppc_set_timer(struct kvm_vcpu *vcpu)
482 if (now > vcpu->arch.dec_expires) { 530 if (now > vcpu->arch.dec_expires) {
483 /* decrementer has already gone negative */ 531 /* decrementer has already gone negative */
484 kvmppc_core_queue_dec(vcpu); 532 kvmppc_core_queue_dec(vcpu);
485 kvmppc_core_deliver_interrupts(vcpu); 533 kvmppc_core_prepare_to_enter(vcpu);
486 return; 534 return;
487 } 535 }
488 dec_nsec = (vcpu->arch.dec_expires - now) * NSEC_PER_SEC 536 dec_nsec = (vcpu->arch.dec_expires - now) * NSEC_PER_SEC
@@ -797,7 +845,7 @@ static int kvmppc_run_vcpu(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
797 845
798 list_for_each_entry_safe(v, vn, &vc->runnable_threads, 846 list_for_each_entry_safe(v, vn, &vc->runnable_threads,
799 arch.run_list) { 847 arch.run_list) {
800 kvmppc_core_deliver_interrupts(v); 848 kvmppc_core_prepare_to_enter(v);
801 if (signal_pending(v->arch.run_task)) { 849 if (signal_pending(v->arch.run_task)) {
802 kvmppc_remove_runnable(vc, v); 850 kvmppc_remove_runnable(vc, v);
803 v->stat.signal_exits++; 851 v->stat.signal_exits++;
@@ -836,20 +884,26 @@ int kvmppc_vcpu_run(struct kvm_run *run, struct kvm_vcpu *vcpu)
836 return -EINVAL; 884 return -EINVAL;
837 } 885 }
838 886
887 kvmppc_core_prepare_to_enter(vcpu);
888
839 /* No need to go into the guest when all we'll do is come back out */ 889 /* No need to go into the guest when all we'll do is come back out */
840 if (signal_pending(current)) { 890 if (signal_pending(current)) {
841 run->exit_reason = KVM_EXIT_INTR; 891 run->exit_reason = KVM_EXIT_INTR;
842 return -EINTR; 892 return -EINTR;
843 } 893 }
844 894
845 /* On PPC970, check that we have an RMA region */ 895 /* On the first time here, set up VRMA or RMA */
846 if (!vcpu->kvm->arch.rma && cpu_has_feature(CPU_FTR_ARCH_201)) 896 if (!vcpu->kvm->arch.rma_setup_done) {
847 return -EPERM; 897 r = kvmppc_hv_setup_rma(vcpu);
898 if (r)
899 return r;
900 }
848 901
849 flush_fp_to_thread(current); 902 flush_fp_to_thread(current);
850 flush_altivec_to_thread(current); 903 flush_altivec_to_thread(current);
851 flush_vsx_to_thread(current); 904 flush_vsx_to_thread(current);
852 vcpu->arch.wqp = &vcpu->arch.vcore->wq; 905 vcpu->arch.wqp = &vcpu->arch.vcore->wq;
906 vcpu->arch.pgdir = current->mm->pgd;
853 907
854 do { 908 do {
855 r = kvmppc_run_vcpu(run, vcpu); 909 r = kvmppc_run_vcpu(run, vcpu);
@@ -857,7 +911,7 @@ int kvmppc_vcpu_run(struct kvm_run *run, struct kvm_vcpu *vcpu)
857 if (run->exit_reason == KVM_EXIT_PAPR_HCALL && 911 if (run->exit_reason == KVM_EXIT_PAPR_HCALL &&
858 !(vcpu->arch.shregs.msr & MSR_PR)) { 912 !(vcpu->arch.shregs.msr & MSR_PR)) {
859 r = kvmppc_pseries_do_hcall(vcpu); 913 r = kvmppc_pseries_do_hcall(vcpu);
860 kvmppc_core_deliver_interrupts(vcpu); 914 kvmppc_core_prepare_to_enter(vcpu);
861 } 915 }
862 } while (r == RESUME_GUEST); 916 } while (r == RESUME_GUEST);
863 return r; 917 return r;
@@ -1001,7 +1055,7 @@ static inline int lpcr_rmls(unsigned long rma_size)
1001 1055
1002static int kvm_rma_fault(struct vm_area_struct *vma, struct vm_fault *vmf) 1056static int kvm_rma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
1003{ 1057{
1004 struct kvmppc_rma_info *ri = vma->vm_file->private_data; 1058 struct kvmppc_linear_info *ri = vma->vm_file->private_data;
1005 struct page *page; 1059 struct page *page;
1006 1060
1007 if (vmf->pgoff >= ri->npages) 1061 if (vmf->pgoff >= ri->npages)
@@ -1026,7 +1080,7 @@ static int kvm_rma_mmap(struct file *file, struct vm_area_struct *vma)
1026 1080
1027static int kvm_rma_release(struct inode *inode, struct file *filp) 1081static int kvm_rma_release(struct inode *inode, struct file *filp)
1028{ 1082{
1029 struct kvmppc_rma_info *ri = filp->private_data; 1083 struct kvmppc_linear_info *ri = filp->private_data;
1030 1084
1031 kvm_release_rma(ri); 1085 kvm_release_rma(ri);
1032 return 0; 1086 return 0;
@@ -1039,7 +1093,7 @@ static struct file_operations kvm_rma_fops = {
1039 1093
1040long kvm_vm_ioctl_allocate_rma(struct kvm *kvm, struct kvm_allocate_rma *ret) 1094long kvm_vm_ioctl_allocate_rma(struct kvm *kvm, struct kvm_allocate_rma *ret)
1041{ 1095{
1042 struct kvmppc_rma_info *ri; 1096 struct kvmppc_linear_info *ri;
1043 long fd; 1097 long fd;
1044 1098
1045 ri = kvm_alloc_rma(); 1099 ri = kvm_alloc_rma();
@@ -1054,89 +1108,189 @@ long kvm_vm_ioctl_allocate_rma(struct kvm *kvm, struct kvm_allocate_rma *ret)
1054 return fd; 1108 return fd;
1055} 1109}
1056 1110
1057static struct page *hva_to_page(unsigned long addr) 1111/*
1112 * Get (and clear) the dirty memory log for a memory slot.
1113 */
1114int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, struct kvm_dirty_log *log)
1058{ 1115{
1059 struct page *page[1]; 1116 struct kvm_memory_slot *memslot;
1060 int npages; 1117 int r;
1118 unsigned long n;
1061 1119
1062 might_sleep(); 1120 mutex_lock(&kvm->slots_lock);
1063 1121
1064 npages = get_user_pages_fast(addr, 1, 1, page); 1122 r = -EINVAL;
1123 if (log->slot >= KVM_MEMORY_SLOTS)
1124 goto out;
1065 1125
1066 if (unlikely(npages != 1)) 1126 memslot = id_to_memslot(kvm->memslots, log->slot);
1067 return 0; 1127 r = -ENOENT;
1128 if (!memslot->dirty_bitmap)
1129 goto out;
1130
1131 n = kvm_dirty_bitmap_bytes(memslot);
1132 memset(memslot->dirty_bitmap, 0, n);
1133
1134 r = kvmppc_hv_get_dirty_log(kvm, memslot);
1135 if (r)
1136 goto out;
1068 1137
1069 return page[0]; 1138 r = -EFAULT;
1139 if (copy_to_user(log->dirty_bitmap, memslot->dirty_bitmap, n))
1140 goto out;
1141
1142 r = 0;
1143out:
1144 mutex_unlock(&kvm->slots_lock);
1145 return r;
1146}
1147
1148static unsigned long slb_pgsize_encoding(unsigned long psize)
1149{
1150 unsigned long senc = 0;
1151
1152 if (psize > 0x1000) {
1153 senc = SLB_VSID_L;
1154 if (psize == 0x10000)
1155 senc |= SLB_VSID_LP_01;
1156 }
1157 return senc;
1070} 1158}
1071 1159
1072int kvmppc_core_prepare_memory_region(struct kvm *kvm, 1160int kvmppc_core_prepare_memory_region(struct kvm *kvm,
1073 struct kvm_userspace_memory_region *mem) 1161 struct kvm_userspace_memory_region *mem)
1074{ 1162{
1075 unsigned long psize, porder; 1163 unsigned long npages;
1076 unsigned long i, npages, totalpages; 1164 unsigned long *phys;
1077 unsigned long pg_ix; 1165
1078 struct kvmppc_pginfo *pginfo; 1166 /* Allocate a slot_phys array */
1079 unsigned long hva; 1167 phys = kvm->arch.slot_phys[mem->slot];
1080 struct kvmppc_rma_info *ri = NULL; 1168 if (!kvm->arch.using_mmu_notifiers && !phys) {
1169 npages = mem->memory_size >> PAGE_SHIFT;
1170 phys = vzalloc(npages * sizeof(unsigned long));
1171 if (!phys)
1172 return -ENOMEM;
1173 kvm->arch.slot_phys[mem->slot] = phys;
1174 kvm->arch.slot_npages[mem->slot] = npages;
1175 }
1176
1177 return 0;
1178}
1179
1180static void unpin_slot(struct kvm *kvm, int slot_id)
1181{
1182 unsigned long *physp;
1183 unsigned long j, npages, pfn;
1081 struct page *page; 1184 struct page *page;
1082 1185
1083 /* For now, only allow 16MB pages */ 1186 physp = kvm->arch.slot_phys[slot_id];
1084 porder = LARGE_PAGE_ORDER; 1187 npages = kvm->arch.slot_npages[slot_id];
1085 psize = 1ul << porder; 1188 if (physp) {
1086 if ((mem->memory_size & (psize - 1)) || 1189 spin_lock(&kvm->arch.slot_phys_lock);
1087 (mem->guest_phys_addr & (psize - 1))) { 1190 for (j = 0; j < npages; j++) {
1088 pr_err("bad memory_size=%llx @ %llx\n", 1191 if (!(physp[j] & KVMPPC_GOT_PAGE))
1089 mem->memory_size, mem->guest_phys_addr); 1192 continue;
1090 return -EINVAL; 1193 pfn = physp[j] >> PAGE_SHIFT;
1194 page = pfn_to_page(pfn);
1195 if (PageHuge(page))
1196 page = compound_head(page);
1197 SetPageDirty(page);
1198 put_page(page);
1199 }
1200 kvm->arch.slot_phys[slot_id] = NULL;
1201 spin_unlock(&kvm->arch.slot_phys_lock);
1202 vfree(physp);
1091 } 1203 }
1204}
1092 1205
1093 npages = mem->memory_size >> porder; 1206void kvmppc_core_commit_memory_region(struct kvm *kvm,
1094 totalpages = (mem->guest_phys_addr + mem->memory_size) >> porder; 1207 struct kvm_userspace_memory_region *mem)
1208{
1209}
1095 1210
1096 /* More memory than we have space to track? */ 1211static int kvmppc_hv_setup_rma(struct kvm_vcpu *vcpu)
1097 if (totalpages > (1ul << (MAX_MEM_ORDER - LARGE_PAGE_ORDER))) 1212{
1098 return -EINVAL; 1213 int err = 0;
1214 struct kvm *kvm = vcpu->kvm;
1215 struct kvmppc_linear_info *ri = NULL;
1216 unsigned long hva;
1217 struct kvm_memory_slot *memslot;
1218 struct vm_area_struct *vma;
1219 unsigned long lpcr, senc;
1220 unsigned long psize, porder;
1221 unsigned long rma_size;
1222 unsigned long rmls;
1223 unsigned long *physp;
1224 unsigned long i, npages;
1099 1225
1100 /* Do we already have an RMA registered? */ 1226 mutex_lock(&kvm->lock);
1101 if (mem->guest_phys_addr == 0 && kvm->arch.rma) 1227 if (kvm->arch.rma_setup_done)
1102 return -EINVAL; 1228 goto out; /* another vcpu beat us to it */
1103 1229
1104 if (totalpages > kvm->arch.ram_npages) 1230 /* Look up the memslot for guest physical address 0 */
1105 kvm->arch.ram_npages = totalpages; 1231 memslot = gfn_to_memslot(kvm, 0);
1232
1233 /* We must have some memory at 0 by now */
1234 err = -EINVAL;
1235 if (!memslot || (memslot->flags & KVM_MEMSLOT_INVALID))
1236 goto out;
1237
1238 /* Look up the VMA for the start of this memory slot */
1239 hva = memslot->userspace_addr;
1240 down_read(&current->mm->mmap_sem);
1241 vma = find_vma(current->mm, hva);
1242 if (!vma || vma->vm_start > hva || (vma->vm_flags & VM_IO))
1243 goto up_out;
1244
1245 psize = vma_kernel_pagesize(vma);
1246 porder = __ilog2(psize);
1106 1247
1107 /* Is this one of our preallocated RMAs? */ 1248 /* Is this one of our preallocated RMAs? */
1108 if (mem->guest_phys_addr == 0) { 1249 if (vma->vm_file && vma->vm_file->f_op == &kvm_rma_fops &&
1109 struct vm_area_struct *vma; 1250 hva == vma->vm_start)
1110 1251 ri = vma->vm_file->private_data;
1111 down_read(&current->mm->mmap_sem); 1252
1112 vma = find_vma(current->mm, mem->userspace_addr); 1253 up_read(&current->mm->mmap_sem);
1113 if (vma && vma->vm_file && 1254
1114 vma->vm_file->f_op == &kvm_rma_fops && 1255 if (!ri) {
1115 mem->userspace_addr == vma->vm_start) 1256 /* On POWER7, use VRMA; on PPC970, give up */
1116 ri = vma->vm_file->private_data; 1257 err = -EPERM;
1117 up_read(&current->mm->mmap_sem); 1258 if (cpu_has_feature(CPU_FTR_ARCH_201)) {
1118 if (!ri && cpu_has_feature(CPU_FTR_ARCH_201)) { 1259 pr_err("KVM: CPU requires an RMO\n");
1119 pr_err("CPU requires an RMO\n"); 1260 goto out;
1120 return -EINVAL;
1121 } 1261 }
1122 }
1123 1262
1124 if (ri) { 1263 /* We can handle 4k, 64k or 16M pages in the VRMA */
1125 unsigned long rma_size; 1264 err = -EINVAL;
1126 unsigned long lpcr; 1265 if (!(psize == 0x1000 || psize == 0x10000 ||
1127 long rmls; 1266 psize == 0x1000000))
1267 goto out;
1268
1269 /* Update VRMASD field in the LPCR */
1270 senc = slb_pgsize_encoding(psize);
1271 kvm->arch.vrma_slb_v = senc | SLB_VSID_B_1T |
1272 (VRMA_VSID << SLB_VSID_SHIFT_1T);
1273 lpcr = kvm->arch.lpcr & ~LPCR_VRMASD;
1274 lpcr |= senc << (LPCR_VRMASD_SH - 4);
1275 kvm->arch.lpcr = lpcr;
1128 1276
1129 rma_size = ri->npages << PAGE_SHIFT; 1277 /* Create HPTEs in the hash page table for the VRMA */
1130 if (rma_size > mem->memory_size) 1278 kvmppc_map_vrma(vcpu, memslot, porder);
1131 rma_size = mem->memory_size; 1279
1280 } else {
1281 /* Set up to use an RMO region */
1282 rma_size = ri->npages;
1283 if (rma_size > memslot->npages)
1284 rma_size = memslot->npages;
1285 rma_size <<= PAGE_SHIFT;
1132 rmls = lpcr_rmls(rma_size); 1286 rmls = lpcr_rmls(rma_size);
1287 err = -EINVAL;
1133 if (rmls < 0) { 1288 if (rmls < 0) {
1134 pr_err("Can't use RMA of 0x%lx bytes\n", rma_size); 1289 pr_err("KVM: Can't use RMA of 0x%lx bytes\n", rma_size);
1135 return -EINVAL; 1290 goto out;
1136 } 1291 }
1137 atomic_inc(&ri->use_count); 1292 atomic_inc(&ri->use_count);
1138 kvm->arch.rma = ri; 1293 kvm->arch.rma = ri;
1139 kvm->arch.n_rma_pages = rma_size >> porder;
1140 1294
1141 /* Update LPCR and RMOR */ 1295 /* Update LPCR and RMOR */
1142 lpcr = kvm->arch.lpcr; 1296 lpcr = kvm->arch.lpcr;
@@ -1156,53 +1310,35 @@ int kvmppc_core_prepare_memory_region(struct kvm *kvm,
1156 kvm->arch.rmor = kvm->arch.rma->base_pfn << PAGE_SHIFT; 1310 kvm->arch.rmor = kvm->arch.rma->base_pfn << PAGE_SHIFT;
1157 } 1311 }
1158 kvm->arch.lpcr = lpcr; 1312 kvm->arch.lpcr = lpcr;
1159 pr_info("Using RMO at %lx size %lx (LPCR = %lx)\n", 1313 pr_info("KVM: Using RMO at %lx size %lx (LPCR = %lx)\n",
1160 ri->base_pfn << PAGE_SHIFT, rma_size, lpcr); 1314 ri->base_pfn << PAGE_SHIFT, rma_size, lpcr);
1161 }
1162 1315
1163 pg_ix = mem->guest_phys_addr >> porder; 1316 /* Initialize phys addrs of pages in RMO */
1164 pginfo = kvm->arch.ram_pginfo + pg_ix; 1317 npages = ri->npages;
1165 for (i = 0; i < npages; ++i, ++pg_ix) { 1318 porder = __ilog2(npages);
1166 if (ri && pg_ix < kvm->arch.n_rma_pages) { 1319 physp = kvm->arch.slot_phys[memslot->id];
1167 pginfo[i].pfn = ri->base_pfn + 1320 spin_lock(&kvm->arch.slot_phys_lock);
1168 (pg_ix << (porder - PAGE_SHIFT)); 1321 for (i = 0; i < npages; ++i)
1169 continue; 1322 physp[i] = ((ri->base_pfn + i) << PAGE_SHIFT) + porder;
1170 } 1323 spin_unlock(&kvm->arch.slot_phys_lock);
1171 hva = mem->userspace_addr + (i << porder);
1172 page = hva_to_page(hva);
1173 if (!page) {
1174 pr_err("oops, no pfn for hva %lx\n", hva);
1175 goto err;
1176 }
1177 /* Check it's a 16MB page */
1178 if (!PageHead(page) ||
1179 compound_order(page) != (LARGE_PAGE_ORDER - PAGE_SHIFT)) {
1180 pr_err("page at %lx isn't 16MB (o=%d)\n",
1181 hva, compound_order(page));
1182 goto err;
1183 }
1184 pginfo[i].pfn = page_to_pfn(page);
1185 } 1324 }
1186 1325
1187 return 0; 1326 /* Order updates to kvm->arch.lpcr etc. vs. rma_setup_done */
1188 1327 smp_wmb();
1189 err: 1328 kvm->arch.rma_setup_done = 1;
1190 return -EINVAL; 1329 err = 0;
1191} 1330 out:
1331 mutex_unlock(&kvm->lock);
1332 return err;
1192 1333
1193void kvmppc_core_commit_memory_region(struct kvm *kvm, 1334 up_out:
1194 struct kvm_userspace_memory_region *mem) 1335 up_read(&current->mm->mmap_sem);
1195{ 1336 goto out;
1196 if (mem->guest_phys_addr == 0 && mem->memory_size != 0 &&
1197 !kvm->arch.rma)
1198 kvmppc_map_vrma(kvm, mem);
1199} 1337}
1200 1338
1201int kvmppc_core_init_vm(struct kvm *kvm) 1339int kvmppc_core_init_vm(struct kvm *kvm)
1202{ 1340{
1203 long r; 1341 long r;
1204 unsigned long npages = 1ul << (MAX_MEM_ORDER - LARGE_PAGE_ORDER);
1205 long err = -ENOMEM;
1206 unsigned long lpcr; 1342 unsigned long lpcr;
1207 1343
1208 /* Allocate hashed page table */ 1344 /* Allocate hashed page table */
@@ -1212,19 +1348,7 @@ int kvmppc_core_init_vm(struct kvm *kvm)
1212 1348
1213 INIT_LIST_HEAD(&kvm->arch.spapr_tce_tables); 1349 INIT_LIST_HEAD(&kvm->arch.spapr_tce_tables);
1214 1350
1215 kvm->arch.ram_pginfo = kzalloc(npages * sizeof(struct kvmppc_pginfo),
1216 GFP_KERNEL);
1217 if (!kvm->arch.ram_pginfo) {
1218 pr_err("kvmppc_core_init_vm: couldn't alloc %lu bytes\n",
1219 npages * sizeof(struct kvmppc_pginfo));
1220 goto out_free;
1221 }
1222
1223 kvm->arch.ram_npages = 0;
1224 kvm->arch.ram_psize = 1ul << LARGE_PAGE_ORDER;
1225 kvm->arch.ram_porder = LARGE_PAGE_ORDER;
1226 kvm->arch.rma = NULL; 1351 kvm->arch.rma = NULL;
1227 kvm->arch.n_rma_pages = 0;
1228 1352
1229 kvm->arch.host_sdr1 = mfspr(SPRN_SDR1); 1353 kvm->arch.host_sdr1 = mfspr(SPRN_SDR1);
1230 1354
@@ -1242,30 +1366,25 @@ int kvmppc_core_init_vm(struct kvm *kvm)
1242 kvm->arch.host_lpcr = lpcr = mfspr(SPRN_LPCR); 1366 kvm->arch.host_lpcr = lpcr = mfspr(SPRN_LPCR);
1243 lpcr &= LPCR_PECE | LPCR_LPES; 1367 lpcr &= LPCR_PECE | LPCR_LPES;
1244 lpcr |= (4UL << LPCR_DPFD_SH) | LPCR_HDICE | 1368 lpcr |= (4UL << LPCR_DPFD_SH) | LPCR_HDICE |
1245 LPCR_VPM0 | LPCR_VRMA_L; 1369 LPCR_VPM0 | LPCR_VPM1;
1370 kvm->arch.vrma_slb_v = SLB_VSID_B_1T |
1371 (VRMA_VSID << SLB_VSID_SHIFT_1T);
1246 } 1372 }
1247 kvm->arch.lpcr = lpcr; 1373 kvm->arch.lpcr = lpcr;
1248 1374
1375 kvm->arch.using_mmu_notifiers = !!cpu_has_feature(CPU_FTR_ARCH_206);
1376 spin_lock_init(&kvm->arch.slot_phys_lock);
1249 return 0; 1377 return 0;
1250
1251 out_free:
1252 kvmppc_free_hpt(kvm);
1253 return err;
1254} 1378}
1255 1379
1256void kvmppc_core_destroy_vm(struct kvm *kvm) 1380void kvmppc_core_destroy_vm(struct kvm *kvm)
1257{ 1381{
1258 struct kvmppc_pginfo *pginfo;
1259 unsigned long i; 1382 unsigned long i;
1260 1383
1261 if (kvm->arch.ram_pginfo) { 1384 if (!kvm->arch.using_mmu_notifiers)
1262 pginfo = kvm->arch.ram_pginfo; 1385 for (i = 0; i < KVM_MEM_SLOTS_NUM; i++)
1263 kvm->arch.ram_pginfo = NULL; 1386 unpin_slot(kvm, i);
1264 for (i = kvm->arch.n_rma_pages; i < kvm->arch.ram_npages; ++i) 1387
1265 if (pginfo[i].pfn)
1266 put_page(pfn_to_page(pginfo[i].pfn));
1267 kfree(pginfo);
1268 }
1269 if (kvm->arch.rma) { 1388 if (kvm->arch.rma) {
1270 kvm_release_rma(kvm->arch.rma); 1389 kvm_release_rma(kvm->arch.rma);
1271 kvm->arch.rma = NULL; 1390 kvm->arch.rma = NULL;
diff --git a/arch/powerpc/kvm/book3s_hv_builtin.c b/arch/powerpc/kvm/book3s_hv_builtin.c
index a795a13f4a7..bed1279aa6a 100644
--- a/arch/powerpc/kvm/book3s_hv_builtin.c
+++ b/arch/powerpc/kvm/book3s_hv_builtin.c
@@ -18,6 +18,15 @@
18#include <asm/kvm_ppc.h> 18#include <asm/kvm_ppc.h>
19#include <asm/kvm_book3s.h> 19#include <asm/kvm_book3s.h>
20 20
21#define KVM_LINEAR_RMA 0
22#define KVM_LINEAR_HPT 1
23
24static void __init kvm_linear_init_one(ulong size, int count, int type);
25static struct kvmppc_linear_info *kvm_alloc_linear(int type);
26static void kvm_release_linear(struct kvmppc_linear_info *ri);
27
28/*************** RMA *************/
29
21/* 30/*
22 * This maintains a list of RMAs (real mode areas) for KVM guests to use. 31 * This maintains a list of RMAs (real mode areas) for KVM guests to use.
23 * Each RMA has to be physically contiguous and of a size that the 32 * Each RMA has to be physically contiguous and of a size that the
@@ -29,32 +38,6 @@
29static unsigned long kvm_rma_size = 64 << 20; /* 64MB */ 38static unsigned long kvm_rma_size = 64 << 20; /* 64MB */
30static unsigned long kvm_rma_count; 39static unsigned long kvm_rma_count;
31 40
32static int __init early_parse_rma_size(char *p)
33{
34 if (!p)
35 return 1;
36
37 kvm_rma_size = memparse(p, &p);
38
39 return 0;
40}
41early_param("kvm_rma_size", early_parse_rma_size);
42
43static int __init early_parse_rma_count(char *p)
44{
45 if (!p)
46 return 1;
47
48 kvm_rma_count = simple_strtoul(p, NULL, 0);
49
50 return 0;
51}
52early_param("kvm_rma_count", early_parse_rma_count);
53
54static struct kvmppc_rma_info *rma_info;
55static LIST_HEAD(free_rmas);
56static DEFINE_SPINLOCK(rma_lock);
57
58/* Work out RMLS (real mode limit selector) field value for a given RMA size. 41/* Work out RMLS (real mode limit selector) field value for a given RMA size.
59 Assumes POWER7 or PPC970. */ 42 Assumes POWER7 or PPC970. */
60static inline int lpcr_rmls(unsigned long rma_size) 43static inline int lpcr_rmls(unsigned long rma_size)
@@ -81,45 +64,106 @@ static inline int lpcr_rmls(unsigned long rma_size)
81 } 64 }
82} 65}
83 66
67static int __init early_parse_rma_size(char *p)
68{
69 if (!p)
70 return 1;
71
72 kvm_rma_size = memparse(p, &p);
73
74 return 0;
75}
76early_param("kvm_rma_size", early_parse_rma_size);
77
78static int __init early_parse_rma_count(char *p)
79{
80 if (!p)
81 return 1;
82
83 kvm_rma_count = simple_strtoul(p, NULL, 0);
84
85 return 0;
86}
87early_param("kvm_rma_count", early_parse_rma_count);
88
89struct kvmppc_linear_info *kvm_alloc_rma(void)
90{
91 return kvm_alloc_linear(KVM_LINEAR_RMA);
92}
93EXPORT_SYMBOL_GPL(kvm_alloc_rma);
94
95void kvm_release_rma(struct kvmppc_linear_info *ri)
96{
97 kvm_release_linear(ri);
98}
99EXPORT_SYMBOL_GPL(kvm_release_rma);
100
101/*************** HPT *************/
102
84/* 103/*
85 * Called at boot time while the bootmem allocator is active, 104 * This maintains a list of big linear HPT tables that contain the GVA->HPA
86 * to allocate contiguous physical memory for the real memory 105 * memory mappings. If we don't reserve those early on, we might not be able
87 * areas for guests. 106 * to get a big (usually 16MB) linear memory region from the kernel anymore.
88 */ 107 */
89void __init kvm_rma_init(void) 108
109static unsigned long kvm_hpt_count;
110
111static int __init early_parse_hpt_count(char *p)
112{
113 if (!p)
114 return 1;
115
116 kvm_hpt_count = simple_strtoul(p, NULL, 0);
117
118 return 0;
119}
120early_param("kvm_hpt_count", early_parse_hpt_count);
121
122struct kvmppc_linear_info *kvm_alloc_hpt(void)
123{
124 return kvm_alloc_linear(KVM_LINEAR_HPT);
125}
126EXPORT_SYMBOL_GPL(kvm_alloc_hpt);
127
128void kvm_release_hpt(struct kvmppc_linear_info *li)
129{
130 kvm_release_linear(li);
131}
132EXPORT_SYMBOL_GPL(kvm_release_hpt);
133
134/*************** generic *************/
135
136static LIST_HEAD(free_linears);
137static DEFINE_SPINLOCK(linear_lock);
138
139static void __init kvm_linear_init_one(ulong size, int count, int type)
90{ 140{
91 unsigned long i; 141 unsigned long i;
92 unsigned long j, npages; 142 unsigned long j, npages;
93 void *rma; 143 void *linear;
94 struct page *pg; 144 struct page *pg;
145 const char *typestr;
146 struct kvmppc_linear_info *linear_info;
95 147
96 /* Only do this on PPC970 in HV mode */ 148 if (!count)
97 if (!cpu_has_feature(CPU_FTR_HVMODE) ||
98 !cpu_has_feature(CPU_FTR_ARCH_201))
99 return;
100
101 if (!kvm_rma_size || !kvm_rma_count)
102 return; 149 return;
103 150
104 /* Check that the requested size is one supported in hardware */ 151 typestr = (type == KVM_LINEAR_RMA) ? "RMA" : "HPT";
105 if (lpcr_rmls(kvm_rma_size) < 0) { 152
106 pr_err("RMA size of 0x%lx not supported\n", kvm_rma_size); 153 npages = size >> PAGE_SHIFT;
107 return; 154 linear_info = alloc_bootmem(count * sizeof(struct kvmppc_linear_info));
108 } 155 for (i = 0; i < count; ++i) {
109 156 linear = alloc_bootmem_align(size, size);
110 npages = kvm_rma_size >> PAGE_SHIFT; 157 pr_info("Allocated KVM %s at %p (%ld MB)\n", typestr, linear,
111 rma_info = alloc_bootmem(kvm_rma_count * sizeof(struct kvmppc_rma_info)); 158 size >> 20);
112 for (i = 0; i < kvm_rma_count; ++i) { 159 linear_info[i].base_virt = linear;
113 rma = alloc_bootmem_align(kvm_rma_size, kvm_rma_size); 160 linear_info[i].base_pfn = __pa(linear) >> PAGE_SHIFT;
114 pr_info("Allocated KVM RMA at %p (%ld MB)\n", rma, 161 linear_info[i].npages = npages;
115 kvm_rma_size >> 20); 162 linear_info[i].type = type;
116 rma_info[i].base_virt = rma; 163 list_add_tail(&linear_info[i].list, &free_linears);
117 rma_info[i].base_pfn = __pa(rma) >> PAGE_SHIFT; 164 atomic_set(&linear_info[i].use_count, 0);
118 rma_info[i].npages = npages; 165
119 list_add_tail(&rma_info[i].list, &free_rmas); 166 pg = pfn_to_page(linear_info[i].base_pfn);
120 atomic_set(&rma_info[i].use_count, 0);
121
122 pg = pfn_to_page(rma_info[i].base_pfn);
123 for (j = 0; j < npages; ++j) { 167 for (j = 0; j < npages; ++j) {
124 atomic_inc(&pg->_count); 168 atomic_inc(&pg->_count);
125 ++pg; 169 ++pg;
@@ -127,30 +171,59 @@ void __init kvm_rma_init(void)
127 } 171 }
128} 172}
129 173
130struct kvmppc_rma_info *kvm_alloc_rma(void) 174static struct kvmppc_linear_info *kvm_alloc_linear(int type)
131{ 175{
132 struct kvmppc_rma_info *ri; 176 struct kvmppc_linear_info *ri;
133 177
134 ri = NULL; 178 ri = NULL;
135 spin_lock(&rma_lock); 179 spin_lock(&linear_lock);
136 if (!list_empty(&free_rmas)) { 180 list_for_each_entry(ri, &free_linears, list) {
137 ri = list_first_entry(&free_rmas, struct kvmppc_rma_info, list); 181 if (ri->type != type)
182 continue;
183
138 list_del(&ri->list); 184 list_del(&ri->list);
139 atomic_inc(&ri->use_count); 185 atomic_inc(&ri->use_count);
186 break;
140 } 187 }
141 spin_unlock(&rma_lock); 188 spin_unlock(&linear_lock);
189 memset(ri->base_virt, 0, ri->npages << PAGE_SHIFT);
142 return ri; 190 return ri;
143} 191}
144EXPORT_SYMBOL_GPL(kvm_alloc_rma);
145 192
146void kvm_release_rma(struct kvmppc_rma_info *ri) 193static void kvm_release_linear(struct kvmppc_linear_info *ri)
147{ 194{
148 if (atomic_dec_and_test(&ri->use_count)) { 195 if (atomic_dec_and_test(&ri->use_count)) {
149 spin_lock(&rma_lock); 196 spin_lock(&linear_lock);
150 list_add_tail(&ri->list, &free_rmas); 197 list_add_tail(&ri->list, &free_linears);
151 spin_unlock(&rma_lock); 198 spin_unlock(&linear_lock);
152 199
153 } 200 }
154} 201}
155EXPORT_SYMBOL_GPL(kvm_release_rma);
156 202
203/*
204 * Called at boot time while the bootmem allocator is active,
205 * to allocate contiguous physical memory for the hash page
206 * tables for guests.
207 */
208void __init kvm_linear_init(void)
209{
210 /* HPT */
211 kvm_linear_init_one(1 << HPT_ORDER, kvm_hpt_count, KVM_LINEAR_HPT);
212
213 /* RMA */
214 /* Only do this on PPC970 in HV mode */
215 if (!cpu_has_feature(CPU_FTR_HVMODE) ||
216 !cpu_has_feature(CPU_FTR_ARCH_201))
217 return;
218
219 if (!kvm_rma_size || !kvm_rma_count)
220 return;
221
222 /* Check that the requested size is one supported in hardware */
223 if (lpcr_rmls(kvm_rma_size) < 0) {
224 pr_err("RMA size of 0x%lx not supported\n", kvm_rma_size);
225 return;
226 }
227
228 kvm_linear_init_one(kvm_rma_size, kvm_rma_count, KVM_LINEAR_RMA);
229}
diff --git a/arch/powerpc/kvm/book3s_hv_rm_mmu.c b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
index bacb0cfa360..def880aea63 100644
--- a/arch/powerpc/kvm/book3s_hv_rm_mmu.c
+++ b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
@@ -11,6 +11,7 @@
11#include <linux/kvm.h> 11#include <linux/kvm.h>
12#include <linux/kvm_host.h> 12#include <linux/kvm_host.h>
13#include <linux/hugetlb.h> 13#include <linux/hugetlb.h>
14#include <linux/module.h>
14 15
15#include <asm/tlbflush.h> 16#include <asm/tlbflush.h>
16#include <asm/kvm_ppc.h> 17#include <asm/kvm_ppc.h>
@@ -20,95 +21,307 @@
20#include <asm/synch.h> 21#include <asm/synch.h>
21#include <asm/ppc-opcode.h> 22#include <asm/ppc-opcode.h>
22 23
23/* For now use fixed-size 16MB page table */ 24/* Translate address of a vmalloc'd thing to a linear map address */
24#define HPT_ORDER 24 25static void *real_vmalloc_addr(void *x)
25#define HPT_NPTEG (1ul << (HPT_ORDER - 7)) /* 128B per pteg */ 26{
26#define HPT_HASH_MASK (HPT_NPTEG - 1) 27 unsigned long addr = (unsigned long) x;
28 pte_t *p;
27 29
28#define HPTE_V_HVLOCK 0x40UL 30 p = find_linux_pte(swapper_pg_dir, addr);
31 if (!p || !pte_present(*p))
32 return NULL;
33 /* assume we don't have huge pages in vmalloc space... */
34 addr = (pte_pfn(*p) << PAGE_SHIFT) | (addr & ~PAGE_MASK);
35 return __va(addr);
36}
29 37
30static inline long lock_hpte(unsigned long *hpte, unsigned long bits) 38/*
39 * Add this HPTE into the chain for the real page.
40 * Must be called with the chain locked; it unlocks the chain.
41 */
42void kvmppc_add_revmap_chain(struct kvm *kvm, struct revmap_entry *rev,
43 unsigned long *rmap, long pte_index, int realmode)
31{ 44{
32 unsigned long tmp, old; 45 struct revmap_entry *head, *tail;
46 unsigned long i;
33 47
34 asm volatile(" ldarx %0,0,%2\n" 48 if (*rmap & KVMPPC_RMAP_PRESENT) {
35 " and. %1,%0,%3\n" 49 i = *rmap & KVMPPC_RMAP_INDEX;
36 " bne 2f\n" 50 head = &kvm->arch.revmap[i];
37 " ori %0,%0,%4\n" 51 if (realmode)
38 " stdcx. %0,0,%2\n" 52 head = real_vmalloc_addr(head);
39 " beq+ 2f\n" 53 tail = &kvm->arch.revmap[head->back];
40 " li %1,%3\n" 54 if (realmode)
41 "2: isync" 55 tail = real_vmalloc_addr(tail);
42 : "=&r" (tmp), "=&r" (old) 56 rev->forw = i;
43 : "r" (hpte), "r" (bits), "i" (HPTE_V_HVLOCK) 57 rev->back = head->back;
44 : "cc", "memory"); 58 tail->forw = pte_index;
45 return old == 0; 59 head->back = pte_index;
60 } else {
61 rev->forw = rev->back = pte_index;
62 i = pte_index;
63 }
64 smp_wmb();
65 *rmap = i | KVMPPC_RMAP_REFERENCED | KVMPPC_RMAP_PRESENT; /* unlock */
66}
67EXPORT_SYMBOL_GPL(kvmppc_add_revmap_chain);
68
69/* Remove this HPTE from the chain for a real page */
70static void remove_revmap_chain(struct kvm *kvm, long pte_index,
71 struct revmap_entry *rev,
72 unsigned long hpte_v, unsigned long hpte_r)
73{
74 struct revmap_entry *next, *prev;
75 unsigned long gfn, ptel, head;
76 struct kvm_memory_slot *memslot;
77 unsigned long *rmap;
78 unsigned long rcbits;
79
80 rcbits = hpte_r & (HPTE_R_R | HPTE_R_C);
81 ptel = rev->guest_rpte |= rcbits;
82 gfn = hpte_rpn(ptel, hpte_page_size(hpte_v, ptel));
83 memslot = __gfn_to_memslot(kvm_memslots(kvm), gfn);
84 if (!memslot || (memslot->flags & KVM_MEMSLOT_INVALID))
85 return;
86
87 rmap = real_vmalloc_addr(&memslot->rmap[gfn - memslot->base_gfn]);
88 lock_rmap(rmap);
89
90 head = *rmap & KVMPPC_RMAP_INDEX;
91 next = real_vmalloc_addr(&kvm->arch.revmap[rev->forw]);
92 prev = real_vmalloc_addr(&kvm->arch.revmap[rev->back]);
93 next->back = rev->back;
94 prev->forw = rev->forw;
95 if (head == pte_index) {
96 head = rev->forw;
97 if (head == pte_index)
98 *rmap &= ~(KVMPPC_RMAP_PRESENT | KVMPPC_RMAP_INDEX);
99 else
100 *rmap = (*rmap & ~KVMPPC_RMAP_INDEX) | head;
101 }
102 *rmap |= rcbits << KVMPPC_RMAP_RC_SHIFT;
103 unlock_rmap(rmap);
104}
105
106static pte_t lookup_linux_pte(struct kvm_vcpu *vcpu, unsigned long hva,
107 int writing, unsigned long *pte_sizep)
108{
109 pte_t *ptep;
110 unsigned long ps = *pte_sizep;
111 unsigned int shift;
112
113 ptep = find_linux_pte_or_hugepte(vcpu->arch.pgdir, hva, &shift);
114 if (!ptep)
115 return __pte(0);
116 if (shift)
117 *pte_sizep = 1ul << shift;
118 else
119 *pte_sizep = PAGE_SIZE;
120 if (ps > *pte_sizep)
121 return __pte(0);
122 if (!pte_present(*ptep))
123 return __pte(0);
124 return kvmppc_read_update_linux_pte(ptep, writing);
125}
126
127static inline void unlock_hpte(unsigned long *hpte, unsigned long hpte_v)
128{
129 asm volatile(PPC_RELEASE_BARRIER "" : : : "memory");
130 hpte[0] = hpte_v;
46} 131}
47 132
48long kvmppc_h_enter(struct kvm_vcpu *vcpu, unsigned long flags, 133long kvmppc_h_enter(struct kvm_vcpu *vcpu, unsigned long flags,
49 long pte_index, unsigned long pteh, unsigned long ptel) 134 long pte_index, unsigned long pteh, unsigned long ptel)
50{ 135{
51 unsigned long porder;
52 struct kvm *kvm = vcpu->kvm; 136 struct kvm *kvm = vcpu->kvm;
53 unsigned long i, lpn, pa; 137 unsigned long i, pa, gpa, gfn, psize;
138 unsigned long slot_fn, hva;
54 unsigned long *hpte; 139 unsigned long *hpte;
140 struct revmap_entry *rev;
141 unsigned long g_ptel = ptel;
142 struct kvm_memory_slot *memslot;
143 unsigned long *physp, pte_size;
144 unsigned long is_io;
145 unsigned long *rmap;
146 pte_t pte;
147 unsigned int writing;
148 unsigned long mmu_seq;
149 unsigned long rcbits;
150 bool realmode = vcpu->arch.vcore->vcore_state == VCORE_RUNNING;
55 151
56 /* only handle 4k, 64k and 16M pages for now */ 152 psize = hpte_page_size(pteh, ptel);
57 porder = 12; 153 if (!psize)
58 if (pteh & HPTE_V_LARGE) { 154 return H_PARAMETER;
59 if (cpu_has_feature(CPU_FTR_ARCH_206) && 155 writing = hpte_is_writable(ptel);
60 (ptel & 0xf000) == 0x1000) { 156 pteh &= ~(HPTE_V_HVLOCK | HPTE_V_ABSENT | HPTE_V_VALID);
61 /* 64k page */ 157
62 porder = 16; 158 /* used later to detect if we might have been invalidated */
63 } else if ((ptel & 0xff000) == 0) { 159 mmu_seq = kvm->mmu_notifier_seq;
64 /* 16M page */ 160 smp_rmb();
65 porder = 24; 161
66 /* lowest AVA bit must be 0 for 16M pages */ 162 /* Find the memslot (if any) for this address */
67 if (pteh & 0x80) 163 gpa = (ptel & HPTE_R_RPN) & ~(psize - 1);
68 return H_PARAMETER; 164 gfn = gpa >> PAGE_SHIFT;
69 } else 165 memslot = __gfn_to_memslot(kvm_memslots(kvm), gfn);
166 pa = 0;
167 is_io = ~0ul;
168 rmap = NULL;
169 if (!(memslot && !(memslot->flags & KVM_MEMSLOT_INVALID))) {
170 /* PPC970 can't do emulated MMIO */
171 if (!cpu_has_feature(CPU_FTR_ARCH_206))
70 return H_PARAMETER; 172 return H_PARAMETER;
173 /* Emulated MMIO - mark this with key=31 */
174 pteh |= HPTE_V_ABSENT;
175 ptel |= HPTE_R_KEY_HI | HPTE_R_KEY_LO;
176 goto do_insert;
71 } 177 }
72 lpn = (ptel & HPTE_R_RPN) >> kvm->arch.ram_porder; 178
73 if (lpn >= kvm->arch.ram_npages || porder > kvm->arch.ram_porder) 179 /* Check if the requested page fits entirely in the memslot. */
74 return H_PARAMETER; 180 if (!slot_is_aligned(memslot, psize))
75 pa = kvm->arch.ram_pginfo[lpn].pfn << PAGE_SHIFT;
76 if (!pa)
77 return H_PARAMETER; 181 return H_PARAMETER;
78 /* Check WIMG */ 182 slot_fn = gfn - memslot->base_gfn;
79 if ((ptel & HPTE_R_WIMG) != HPTE_R_M && 183 rmap = &memslot->rmap[slot_fn];
80 (ptel & HPTE_R_WIMG) != (HPTE_R_W | HPTE_R_I | HPTE_R_M)) 184
185 if (!kvm->arch.using_mmu_notifiers) {
186 physp = kvm->arch.slot_phys[memslot->id];
187 if (!physp)
188 return H_PARAMETER;
189 physp += slot_fn;
190 if (realmode)
191 physp = real_vmalloc_addr(physp);
192 pa = *physp;
193 if (!pa)
194 return H_TOO_HARD;
195 is_io = pa & (HPTE_R_I | HPTE_R_W);
196 pte_size = PAGE_SIZE << (pa & KVMPPC_PAGE_ORDER_MASK);
197 pa &= PAGE_MASK;
198 } else {
199 /* Translate to host virtual address */
200 hva = gfn_to_hva_memslot(memslot, gfn);
201
202 /* Look up the Linux PTE for the backing page */
203 pte_size = psize;
204 pte = lookup_linux_pte(vcpu, hva, writing, &pte_size);
205 if (pte_present(pte)) {
206 if (writing && !pte_write(pte))
207 /* make the actual HPTE be read-only */
208 ptel = hpte_make_readonly(ptel);
209 is_io = hpte_cache_bits(pte_val(pte));
210 pa = pte_pfn(pte) << PAGE_SHIFT;
211 }
212 }
213 if (pte_size < psize)
81 return H_PARAMETER; 214 return H_PARAMETER;
82 pteh &= ~0x60UL; 215 if (pa && pte_size > psize)
83 ptel &= ~(HPTE_R_PP0 - kvm->arch.ram_psize); 216 pa |= gpa & (pte_size - 1);
217
218 ptel &= ~(HPTE_R_PP0 - psize);
84 ptel |= pa; 219 ptel |= pa;
85 if (pte_index >= (HPT_NPTEG << 3)) 220
221 if (pa)
222 pteh |= HPTE_V_VALID;
223 else
224 pteh |= HPTE_V_ABSENT;
225
226 /* Check WIMG */
227 if (is_io != ~0ul && !hpte_cache_flags_ok(ptel, is_io)) {
228 if (is_io)
229 return H_PARAMETER;
230 /*
231 * Allow guest to map emulated device memory as
232 * uncacheable, but actually make it cacheable.
233 */
234 ptel &= ~(HPTE_R_W|HPTE_R_I|HPTE_R_G);
235 ptel |= HPTE_R_M;
236 }
237
238 /* Find and lock the HPTEG slot to use */
239 do_insert:
240 if (pte_index >= HPT_NPTE)
86 return H_PARAMETER; 241 return H_PARAMETER;
87 if (likely((flags & H_EXACT) == 0)) { 242 if (likely((flags & H_EXACT) == 0)) {
88 pte_index &= ~7UL; 243 pte_index &= ~7UL;
89 hpte = (unsigned long *)(kvm->arch.hpt_virt + (pte_index << 4)); 244 hpte = (unsigned long *)(kvm->arch.hpt_virt + (pte_index << 4));
90 for (i = 0; ; ++i) { 245 for (i = 0; i < 8; ++i) {
91 if (i == 8)
92 return H_PTEG_FULL;
93 if ((*hpte & HPTE_V_VALID) == 0 && 246 if ((*hpte & HPTE_V_VALID) == 0 &&
94 lock_hpte(hpte, HPTE_V_HVLOCK | HPTE_V_VALID)) 247 try_lock_hpte(hpte, HPTE_V_HVLOCK | HPTE_V_VALID |
248 HPTE_V_ABSENT))
95 break; 249 break;
96 hpte += 2; 250 hpte += 2;
97 } 251 }
252 if (i == 8) {
253 /*
254 * Since try_lock_hpte doesn't retry (not even stdcx.
255 * failures), it could be that there is a free slot
256 * but we transiently failed to lock it. Try again,
257 * actually locking each slot and checking it.
258 */
259 hpte -= 16;
260 for (i = 0; i < 8; ++i) {
261 while (!try_lock_hpte(hpte, HPTE_V_HVLOCK))
262 cpu_relax();
263 if (!(*hpte & (HPTE_V_VALID | HPTE_V_ABSENT)))
264 break;
265 *hpte &= ~HPTE_V_HVLOCK;
266 hpte += 2;
267 }
268 if (i == 8)
269 return H_PTEG_FULL;
270 }
271 pte_index += i;
98 } else { 272 } else {
99 i = 0;
100 hpte = (unsigned long *)(kvm->arch.hpt_virt + (pte_index << 4)); 273 hpte = (unsigned long *)(kvm->arch.hpt_virt + (pte_index << 4));
101 if (!lock_hpte(hpte, HPTE_V_HVLOCK | HPTE_V_VALID)) 274 if (!try_lock_hpte(hpte, HPTE_V_HVLOCK | HPTE_V_VALID |
102 return H_PTEG_FULL; 275 HPTE_V_ABSENT)) {
276 /* Lock the slot and check again */
277 while (!try_lock_hpte(hpte, HPTE_V_HVLOCK))
278 cpu_relax();
279 if (*hpte & (HPTE_V_VALID | HPTE_V_ABSENT)) {
280 *hpte &= ~HPTE_V_HVLOCK;
281 return H_PTEG_FULL;
282 }
283 }
103 } 284 }
285
286 /* Save away the guest's idea of the second HPTE dword */
287 rev = &kvm->arch.revmap[pte_index];
288 if (realmode)
289 rev = real_vmalloc_addr(rev);
290 if (rev)
291 rev->guest_rpte = g_ptel;
292
293 /* Link HPTE into reverse-map chain */
294 if (pteh & HPTE_V_VALID) {
295 if (realmode)
296 rmap = real_vmalloc_addr(rmap);
297 lock_rmap(rmap);
298 /* Check for pending invalidations under the rmap chain lock */
299 if (kvm->arch.using_mmu_notifiers &&
300 mmu_notifier_retry(vcpu, mmu_seq)) {
301 /* inval in progress, write a non-present HPTE */
302 pteh |= HPTE_V_ABSENT;
303 pteh &= ~HPTE_V_VALID;
304 unlock_rmap(rmap);
305 } else {
306 kvmppc_add_revmap_chain(kvm, rev, rmap, pte_index,
307 realmode);
308 /* Only set R/C in real HPTE if already set in *rmap */
309 rcbits = *rmap >> KVMPPC_RMAP_RC_SHIFT;
310 ptel &= rcbits | ~(HPTE_R_R | HPTE_R_C);
311 }
312 }
313
104 hpte[1] = ptel; 314 hpte[1] = ptel;
315
316 /* Write the first HPTE dword, unlocking the HPTE and making it valid */
105 eieio(); 317 eieio();
106 hpte[0] = pteh; 318 hpte[0] = pteh;
107 asm volatile("ptesync" : : : "memory"); 319 asm volatile("ptesync" : : : "memory");
108 atomic_inc(&kvm->arch.ram_pginfo[lpn].refcnt); 320
109 vcpu->arch.gpr[4] = pte_index + i; 321 vcpu->arch.gpr[4] = pte_index;
110 return H_SUCCESS; 322 return H_SUCCESS;
111} 323}
324EXPORT_SYMBOL_GPL(kvmppc_h_enter);
112 325
113#define LOCK_TOKEN (*(u32 *)(&get_paca()->lock_token)) 326#define LOCK_TOKEN (*(u32 *)(&get_paca()->lock_token))
114 327
@@ -137,37 +350,46 @@ long kvmppc_h_remove(struct kvm_vcpu *vcpu, unsigned long flags,
137 struct kvm *kvm = vcpu->kvm; 350 struct kvm *kvm = vcpu->kvm;
138 unsigned long *hpte; 351 unsigned long *hpte;
139 unsigned long v, r, rb; 352 unsigned long v, r, rb;
353 struct revmap_entry *rev;
140 354
141 if (pte_index >= (HPT_NPTEG << 3)) 355 if (pte_index >= HPT_NPTE)
142 return H_PARAMETER; 356 return H_PARAMETER;
143 hpte = (unsigned long *)(kvm->arch.hpt_virt + (pte_index << 4)); 357 hpte = (unsigned long *)(kvm->arch.hpt_virt + (pte_index << 4));
144 while (!lock_hpte(hpte, HPTE_V_HVLOCK)) 358 while (!try_lock_hpte(hpte, HPTE_V_HVLOCK))
145 cpu_relax(); 359 cpu_relax();
146 if ((hpte[0] & HPTE_V_VALID) == 0 || 360 if ((hpte[0] & (HPTE_V_ABSENT | HPTE_V_VALID)) == 0 ||
147 ((flags & H_AVPN) && (hpte[0] & ~0x7fUL) != avpn) || 361 ((flags & H_AVPN) && (hpte[0] & ~0x7fUL) != avpn) ||
148 ((flags & H_ANDCOND) && (hpte[0] & avpn) != 0)) { 362 ((flags & H_ANDCOND) && (hpte[0] & avpn) != 0)) {
149 hpte[0] &= ~HPTE_V_HVLOCK; 363 hpte[0] &= ~HPTE_V_HVLOCK;
150 return H_NOT_FOUND; 364 return H_NOT_FOUND;
151 } 365 }
152 if (atomic_read(&kvm->online_vcpus) == 1) 366
153 flags |= H_LOCAL; 367 rev = real_vmalloc_addr(&kvm->arch.revmap[pte_index]);
154 vcpu->arch.gpr[4] = v = hpte[0] & ~HPTE_V_HVLOCK; 368 v = hpte[0] & ~HPTE_V_HVLOCK;
155 vcpu->arch.gpr[5] = r = hpte[1]; 369 if (v & HPTE_V_VALID) {
156 rb = compute_tlbie_rb(v, r, pte_index); 370 hpte[0] &= ~HPTE_V_VALID;
157 hpte[0] = 0; 371 rb = compute_tlbie_rb(v, hpte[1], pte_index);
158 if (!(flags & H_LOCAL)) { 372 if (!(flags & H_LOCAL) && atomic_read(&kvm->online_vcpus) > 1) {
159 while(!try_lock_tlbie(&kvm->arch.tlbie_lock)) 373 while (!try_lock_tlbie(&kvm->arch.tlbie_lock))
160 cpu_relax(); 374 cpu_relax();
161 asm volatile("ptesync" : : : "memory"); 375 asm volatile("ptesync" : : : "memory");
162 asm volatile(PPC_TLBIE(%1,%0)"; eieio; tlbsync" 376 asm volatile(PPC_TLBIE(%1,%0)"; eieio; tlbsync"
163 : : "r" (rb), "r" (kvm->arch.lpid)); 377 : : "r" (rb), "r" (kvm->arch.lpid));
164 asm volatile("ptesync" : : : "memory"); 378 asm volatile("ptesync" : : : "memory");
165 kvm->arch.tlbie_lock = 0; 379 kvm->arch.tlbie_lock = 0;
166 } else { 380 } else {
167 asm volatile("ptesync" : : : "memory"); 381 asm volatile("ptesync" : : : "memory");
168 asm volatile("tlbiel %0" : : "r" (rb)); 382 asm volatile("tlbiel %0" : : "r" (rb));
169 asm volatile("ptesync" : : : "memory"); 383 asm volatile("ptesync" : : : "memory");
384 }
385 /* Read PTE low word after tlbie to get final R/C values */
386 remove_revmap_chain(kvm, pte_index, rev, v, hpte[1]);
170 } 387 }
388 r = rev->guest_rpte;
389 unlock_hpte(hpte, 0);
390
391 vcpu->arch.gpr[4] = v;
392 vcpu->arch.gpr[5] = r;
171 return H_SUCCESS; 393 return H_SUCCESS;
172} 394}
173 395
@@ -175,78 +397,117 @@ long kvmppc_h_bulk_remove(struct kvm_vcpu *vcpu)
175{ 397{
176 struct kvm *kvm = vcpu->kvm; 398 struct kvm *kvm = vcpu->kvm;
177 unsigned long *args = &vcpu->arch.gpr[4]; 399 unsigned long *args = &vcpu->arch.gpr[4];
178 unsigned long *hp, tlbrb[4]; 400 unsigned long *hp, *hptes[4], tlbrb[4];
179 long int i, found; 401 long int i, j, k, n, found, indexes[4];
180 long int n_inval = 0; 402 unsigned long flags, req, pte_index, rcbits;
181 unsigned long flags, req, pte_index;
182 long int local = 0; 403 long int local = 0;
183 long int ret = H_SUCCESS; 404 long int ret = H_SUCCESS;
405 struct revmap_entry *rev, *revs[4];
184 406
185 if (atomic_read(&kvm->online_vcpus) == 1) 407 if (atomic_read(&kvm->online_vcpus) == 1)
186 local = 1; 408 local = 1;
187 for (i = 0; i < 4; ++i) { 409 for (i = 0; i < 4 && ret == H_SUCCESS; ) {
188 pte_index = args[i * 2]; 410 n = 0;
189 flags = pte_index >> 56; 411 for (; i < 4; ++i) {
190 pte_index &= ((1ul << 56) - 1); 412 j = i * 2;
191 req = flags >> 6; 413 pte_index = args[j];
192 flags &= 3; 414 flags = pte_index >> 56;
193 if (req == 3) 415 pte_index &= ((1ul << 56) - 1);
194 break; 416 req = flags >> 6;
195 if (req != 1 || flags == 3 || 417 flags &= 3;
196 pte_index >= (HPT_NPTEG << 3)) { 418 if (req == 3) { /* no more requests */
197 /* parameter error */ 419 i = 4;
198 args[i * 2] = ((0xa0 | flags) << 56) + pte_index;
199 ret = H_PARAMETER;
200 break;
201 }
202 hp = (unsigned long *)(kvm->arch.hpt_virt + (pte_index << 4));
203 while (!lock_hpte(hp, HPTE_V_HVLOCK))
204 cpu_relax();
205 found = 0;
206 if (hp[0] & HPTE_V_VALID) {
207 switch (flags & 3) {
208 case 0: /* absolute */
209 found = 1;
210 break; 420 break;
211 case 1: /* andcond */ 421 }
212 if (!(hp[0] & args[i * 2 + 1])) 422 if (req != 1 || flags == 3 || pte_index >= HPT_NPTE) {
213 found = 1; 423 /* parameter error */
424 args[j] = ((0xa0 | flags) << 56) + pte_index;
425 ret = H_PARAMETER;
214 break; 426 break;
215 case 2: /* AVPN */ 427 }
216 if ((hp[0] & ~0x7fUL) == args[i * 2 + 1]) 428 hp = (unsigned long *)
429 (kvm->arch.hpt_virt + (pte_index << 4));
430 /* to avoid deadlock, don't spin except for first */
431 if (!try_lock_hpte(hp, HPTE_V_HVLOCK)) {
432 if (n)
433 break;
434 while (!try_lock_hpte(hp, HPTE_V_HVLOCK))
435 cpu_relax();
436 }
437 found = 0;
438 if (hp[0] & (HPTE_V_ABSENT | HPTE_V_VALID)) {
439 switch (flags & 3) {
440 case 0: /* absolute */
217 found = 1; 441 found = 1;
218 break; 442 break;
443 case 1: /* andcond */
444 if (!(hp[0] & args[j + 1]))
445 found = 1;
446 break;
447 case 2: /* AVPN */
448 if ((hp[0] & ~0x7fUL) == args[j + 1])
449 found = 1;
450 break;
451 }
452 }
453 if (!found) {
454 hp[0] &= ~HPTE_V_HVLOCK;
455 args[j] = ((0x90 | flags) << 56) + pte_index;
456 continue;
219 } 457 }
458
459 args[j] = ((0x80 | flags) << 56) + pte_index;
460 rev = real_vmalloc_addr(&kvm->arch.revmap[pte_index]);
461
462 if (!(hp[0] & HPTE_V_VALID)) {
463 /* insert R and C bits from PTE */
464 rcbits = rev->guest_rpte & (HPTE_R_R|HPTE_R_C);
465 args[j] |= rcbits << (56 - 5);
466 continue;
467 }
468
469 hp[0] &= ~HPTE_V_VALID; /* leave it locked */
470 tlbrb[n] = compute_tlbie_rb(hp[0], hp[1], pte_index);
471 indexes[n] = j;
472 hptes[n] = hp;
473 revs[n] = rev;
474 ++n;
475 }
476
477 if (!n)
478 break;
479
480 /* Now that we've collected a batch, do the tlbies */
481 if (!local) {
482 while(!try_lock_tlbie(&kvm->arch.tlbie_lock))
483 cpu_relax();
484 asm volatile("ptesync" : : : "memory");
485 for (k = 0; k < n; ++k)
486 asm volatile(PPC_TLBIE(%1,%0) : :
487 "r" (tlbrb[k]),
488 "r" (kvm->arch.lpid));
489 asm volatile("eieio; tlbsync; ptesync" : : : "memory");
490 kvm->arch.tlbie_lock = 0;
491 } else {
492 asm volatile("ptesync" : : : "memory");
493 for (k = 0; k < n; ++k)
494 asm volatile("tlbiel %0" : : "r" (tlbrb[k]));
495 asm volatile("ptesync" : : : "memory");
220 } 496 }
221 if (!found) { 497
222 hp[0] &= ~HPTE_V_HVLOCK; 498 /* Read PTE low words after tlbie to get final R/C values */
223 args[i * 2] = ((0x90 | flags) << 56) + pte_index; 499 for (k = 0; k < n; ++k) {
224 continue; 500 j = indexes[k];
501 pte_index = args[j] & ((1ul << 56) - 1);
502 hp = hptes[k];
503 rev = revs[k];
504 remove_revmap_chain(kvm, pte_index, rev, hp[0], hp[1]);
505 rcbits = rev->guest_rpte & (HPTE_R_R|HPTE_R_C);
506 args[j] |= rcbits << (56 - 5);
507 hp[0] = 0;
225 } 508 }
226 /* insert R and C bits from PTE */
227 flags |= (hp[1] >> 5) & 0x0c;
228 args[i * 2] = ((0x80 | flags) << 56) + pte_index;
229 tlbrb[n_inval++] = compute_tlbie_rb(hp[0], hp[1], pte_index);
230 hp[0] = 0;
231 }
232 if (n_inval == 0)
233 return ret;
234
235 if (!local) {
236 while(!try_lock_tlbie(&kvm->arch.tlbie_lock))
237 cpu_relax();
238 asm volatile("ptesync" : : : "memory");
239 for (i = 0; i < n_inval; ++i)
240 asm volatile(PPC_TLBIE(%1,%0)
241 : : "r" (tlbrb[i]), "r" (kvm->arch.lpid));
242 asm volatile("eieio; tlbsync; ptesync" : : : "memory");
243 kvm->arch.tlbie_lock = 0;
244 } else {
245 asm volatile("ptesync" : : : "memory");
246 for (i = 0; i < n_inval; ++i)
247 asm volatile("tlbiel %0" : : "r" (tlbrb[i]));
248 asm volatile("ptesync" : : : "memory");
249 } 509 }
510
250 return ret; 511 return ret;
251} 512}
252 513
@@ -256,40 +517,55 @@ long kvmppc_h_protect(struct kvm_vcpu *vcpu, unsigned long flags,
256{ 517{
257 struct kvm *kvm = vcpu->kvm; 518 struct kvm *kvm = vcpu->kvm;
258 unsigned long *hpte; 519 unsigned long *hpte;
259 unsigned long v, r, rb; 520 struct revmap_entry *rev;
521 unsigned long v, r, rb, mask, bits;
260 522
261 if (pte_index >= (HPT_NPTEG << 3)) 523 if (pte_index >= HPT_NPTE)
262 return H_PARAMETER; 524 return H_PARAMETER;
525
263 hpte = (unsigned long *)(kvm->arch.hpt_virt + (pte_index << 4)); 526 hpte = (unsigned long *)(kvm->arch.hpt_virt + (pte_index << 4));
264 while (!lock_hpte(hpte, HPTE_V_HVLOCK)) 527 while (!try_lock_hpte(hpte, HPTE_V_HVLOCK))
265 cpu_relax(); 528 cpu_relax();
266 if ((hpte[0] & HPTE_V_VALID) == 0 || 529 if ((hpte[0] & (HPTE_V_ABSENT | HPTE_V_VALID)) == 0 ||
267 ((flags & H_AVPN) && (hpte[0] & ~0x7fUL) != avpn)) { 530 ((flags & H_AVPN) && (hpte[0] & ~0x7fUL) != avpn)) {
268 hpte[0] &= ~HPTE_V_HVLOCK; 531 hpte[0] &= ~HPTE_V_HVLOCK;
269 return H_NOT_FOUND; 532 return H_NOT_FOUND;
270 } 533 }
534
271 if (atomic_read(&kvm->online_vcpus) == 1) 535 if (atomic_read(&kvm->online_vcpus) == 1)
272 flags |= H_LOCAL; 536 flags |= H_LOCAL;
273 v = hpte[0]; 537 v = hpte[0];
274 r = hpte[1] & ~(HPTE_R_PP0 | HPTE_R_PP | HPTE_R_N | 538 bits = (flags << 55) & HPTE_R_PP0;
275 HPTE_R_KEY_HI | HPTE_R_KEY_LO); 539 bits |= (flags << 48) & HPTE_R_KEY_HI;
276 r |= (flags << 55) & HPTE_R_PP0; 540 bits |= flags & (HPTE_R_PP | HPTE_R_N | HPTE_R_KEY_LO);
277 r |= (flags << 48) & HPTE_R_KEY_HI; 541
278 r |= flags & (HPTE_R_PP | HPTE_R_N | HPTE_R_KEY_LO); 542 /* Update guest view of 2nd HPTE dword */
279 rb = compute_tlbie_rb(v, r, pte_index); 543 mask = HPTE_R_PP0 | HPTE_R_PP | HPTE_R_N |
280 hpte[0] = v & ~HPTE_V_VALID; 544 HPTE_R_KEY_HI | HPTE_R_KEY_LO;
281 if (!(flags & H_LOCAL)) { 545 rev = real_vmalloc_addr(&kvm->arch.revmap[pte_index]);
282 while(!try_lock_tlbie(&kvm->arch.tlbie_lock)) 546 if (rev) {
283 cpu_relax(); 547 r = (rev->guest_rpte & ~mask) | bits;
284 asm volatile("ptesync" : : : "memory"); 548 rev->guest_rpte = r;
285 asm volatile(PPC_TLBIE(%1,%0)"; eieio; tlbsync" 549 }
286 : : "r" (rb), "r" (kvm->arch.lpid)); 550 r = (hpte[1] & ~mask) | bits;
287 asm volatile("ptesync" : : : "memory"); 551
288 kvm->arch.tlbie_lock = 0; 552 /* Update HPTE */
289 } else { 553 if (v & HPTE_V_VALID) {
290 asm volatile("ptesync" : : : "memory"); 554 rb = compute_tlbie_rb(v, r, pte_index);
291 asm volatile("tlbiel %0" : : "r" (rb)); 555 hpte[0] = v & ~HPTE_V_VALID;
292 asm volatile("ptesync" : : : "memory"); 556 if (!(flags & H_LOCAL)) {
557 while(!try_lock_tlbie(&kvm->arch.tlbie_lock))
558 cpu_relax();
559 asm volatile("ptesync" : : : "memory");
560 asm volatile(PPC_TLBIE(%1,%0)"; eieio; tlbsync"
561 : : "r" (rb), "r" (kvm->arch.lpid));
562 asm volatile("ptesync" : : : "memory");
563 kvm->arch.tlbie_lock = 0;
564 } else {
565 asm volatile("ptesync" : : : "memory");
566 asm volatile("tlbiel %0" : : "r" (rb));
567 asm volatile("ptesync" : : : "memory");
568 }
293 } 569 }
294 hpte[1] = r; 570 hpte[1] = r;
295 eieio(); 571 eieio();
@@ -298,40 +574,243 @@ long kvmppc_h_protect(struct kvm_vcpu *vcpu, unsigned long flags,
298 return H_SUCCESS; 574 return H_SUCCESS;
299} 575}
300 576
301static unsigned long reverse_xlate(struct kvm *kvm, unsigned long realaddr)
302{
303 long int i;
304 unsigned long offset, rpn;
305
306 offset = realaddr & (kvm->arch.ram_psize - 1);
307 rpn = (realaddr - offset) >> PAGE_SHIFT;
308 for (i = 0; i < kvm->arch.ram_npages; ++i)
309 if (rpn == kvm->arch.ram_pginfo[i].pfn)
310 return (i << PAGE_SHIFT) + offset;
311 return HPTE_R_RPN; /* all 1s in the RPN field */
312}
313
314long kvmppc_h_read(struct kvm_vcpu *vcpu, unsigned long flags, 577long kvmppc_h_read(struct kvm_vcpu *vcpu, unsigned long flags,
315 unsigned long pte_index) 578 unsigned long pte_index)
316{ 579{
317 struct kvm *kvm = vcpu->kvm; 580 struct kvm *kvm = vcpu->kvm;
318 unsigned long *hpte, r; 581 unsigned long *hpte, v, r;
319 int i, n = 1; 582 int i, n = 1;
583 struct revmap_entry *rev = NULL;
320 584
321 if (pte_index >= (HPT_NPTEG << 3)) 585 if (pte_index >= HPT_NPTE)
322 return H_PARAMETER; 586 return H_PARAMETER;
323 if (flags & H_READ_4) { 587 if (flags & H_READ_4) {
324 pte_index &= ~3; 588 pte_index &= ~3;
325 n = 4; 589 n = 4;
326 } 590 }
591 rev = real_vmalloc_addr(&kvm->arch.revmap[pte_index]);
327 for (i = 0; i < n; ++i, ++pte_index) { 592 for (i = 0; i < n; ++i, ++pte_index) {
328 hpte = (unsigned long *)(kvm->arch.hpt_virt + (pte_index << 4)); 593 hpte = (unsigned long *)(kvm->arch.hpt_virt + (pte_index << 4));
594 v = hpte[0] & ~HPTE_V_HVLOCK;
329 r = hpte[1]; 595 r = hpte[1];
330 if ((flags & H_R_XLATE) && (hpte[0] & HPTE_V_VALID)) 596 if (v & HPTE_V_ABSENT) {
331 r = reverse_xlate(kvm, r & HPTE_R_RPN) | 597 v &= ~HPTE_V_ABSENT;
332 (r & ~HPTE_R_RPN); 598 v |= HPTE_V_VALID;
333 vcpu->arch.gpr[4 + i * 2] = hpte[0]; 599 }
600 if (v & HPTE_V_VALID)
601 r = rev[i].guest_rpte | (r & (HPTE_R_R | HPTE_R_C));
602 vcpu->arch.gpr[4 + i * 2] = v;
334 vcpu->arch.gpr[5 + i * 2] = r; 603 vcpu->arch.gpr[5 + i * 2] = r;
335 } 604 }
336 return H_SUCCESS; 605 return H_SUCCESS;
337} 606}
607
608void kvmppc_invalidate_hpte(struct kvm *kvm, unsigned long *hptep,
609 unsigned long pte_index)
610{
611 unsigned long rb;
612
613 hptep[0] &= ~HPTE_V_VALID;
614 rb = compute_tlbie_rb(hptep[0], hptep[1], pte_index);
615 while (!try_lock_tlbie(&kvm->arch.tlbie_lock))
616 cpu_relax();
617 asm volatile("ptesync" : : : "memory");
618 asm volatile(PPC_TLBIE(%1,%0)"; eieio; tlbsync"
619 : : "r" (rb), "r" (kvm->arch.lpid));
620 asm volatile("ptesync" : : : "memory");
621 kvm->arch.tlbie_lock = 0;
622}
623EXPORT_SYMBOL_GPL(kvmppc_invalidate_hpte);
624
625void kvmppc_clear_ref_hpte(struct kvm *kvm, unsigned long *hptep,
626 unsigned long pte_index)
627{
628 unsigned long rb;
629 unsigned char rbyte;
630
631 rb = compute_tlbie_rb(hptep[0], hptep[1], pte_index);
632 rbyte = (hptep[1] & ~HPTE_R_R) >> 8;
633 /* modify only the second-last byte, which contains the ref bit */
634 *((char *)hptep + 14) = rbyte;
635 while (!try_lock_tlbie(&kvm->arch.tlbie_lock))
636 cpu_relax();
637 asm volatile(PPC_TLBIE(%1,%0)"; eieio; tlbsync"
638 : : "r" (rb), "r" (kvm->arch.lpid));
639 asm volatile("ptesync" : : : "memory");
640 kvm->arch.tlbie_lock = 0;
641}
642EXPORT_SYMBOL_GPL(kvmppc_clear_ref_hpte);
643
644static int slb_base_page_shift[4] = {
645 24, /* 16M */
646 16, /* 64k */
647 34, /* 16G */
648 20, /* 1M, unsupported */
649};
650
651long kvmppc_hv_find_lock_hpte(struct kvm *kvm, gva_t eaddr, unsigned long slb_v,
652 unsigned long valid)
653{
654 unsigned int i;
655 unsigned int pshift;
656 unsigned long somask;
657 unsigned long vsid, hash;
658 unsigned long avpn;
659 unsigned long *hpte;
660 unsigned long mask, val;
661 unsigned long v, r;
662
663 /* Get page shift, work out hash and AVPN etc. */
664 mask = SLB_VSID_B | HPTE_V_AVPN | HPTE_V_SECONDARY;
665 val = 0;
666 pshift = 12;
667 if (slb_v & SLB_VSID_L) {
668 mask |= HPTE_V_LARGE;
669 val |= HPTE_V_LARGE;
670 pshift = slb_base_page_shift[(slb_v & SLB_VSID_LP) >> 4];
671 }
672 if (slb_v & SLB_VSID_B_1T) {
673 somask = (1UL << 40) - 1;
674 vsid = (slb_v & ~SLB_VSID_B) >> SLB_VSID_SHIFT_1T;
675 vsid ^= vsid << 25;
676 } else {
677 somask = (1UL << 28) - 1;
678 vsid = (slb_v & ~SLB_VSID_B) >> SLB_VSID_SHIFT;
679 }
680 hash = (vsid ^ ((eaddr & somask) >> pshift)) & HPT_HASH_MASK;
681 avpn = slb_v & ~(somask >> 16); /* also includes B */
682 avpn |= (eaddr & somask) >> 16;
683
684 if (pshift >= 24)
685 avpn &= ~((1UL << (pshift - 16)) - 1);
686 else
687 avpn &= ~0x7fUL;
688 val |= avpn;
689
690 for (;;) {
691 hpte = (unsigned long *)(kvm->arch.hpt_virt + (hash << 7));
692
693 for (i = 0; i < 16; i += 2) {
694 /* Read the PTE racily */
695 v = hpte[i] & ~HPTE_V_HVLOCK;
696
697 /* Check valid/absent, hash, segment size and AVPN */
698 if (!(v & valid) || (v & mask) != val)
699 continue;
700
701 /* Lock the PTE and read it under the lock */
702 while (!try_lock_hpte(&hpte[i], HPTE_V_HVLOCK))
703 cpu_relax();
704 v = hpte[i] & ~HPTE_V_HVLOCK;
705 r = hpte[i+1];
706
707 /*
708 * Check the HPTE again, including large page size
709 * Since we don't currently allow any MPSS (mixed
710 * page-size segment) page sizes, it is sufficient
711 * to check against the actual page size.
712 */
713 if ((v & valid) && (v & mask) == val &&
714 hpte_page_size(v, r) == (1ul << pshift))
715 /* Return with the HPTE still locked */
716 return (hash << 3) + (i >> 1);
717
718 /* Unlock and move on */
719 hpte[i] = v;
720 }
721
722 if (val & HPTE_V_SECONDARY)
723 break;
724 val |= HPTE_V_SECONDARY;
725 hash = hash ^ HPT_HASH_MASK;
726 }
727 return -1;
728}
729EXPORT_SYMBOL(kvmppc_hv_find_lock_hpte);
730
731/*
732 * Called in real mode to check whether an HPTE not found fault
733 * is due to accessing a paged-out page or an emulated MMIO page,
734 * or if a protection fault is due to accessing a page that the
735 * guest wanted read/write access to but which we made read-only.
736 * Returns a possibly modified status (DSISR) value if not
737 * (i.e. pass the interrupt to the guest),
738 * -1 to pass the fault up to host kernel mode code, -2 to do that
739 * and also load the instruction word (for MMIO emulation),
740 * or 0 if we should make the guest retry the access.
741 */
742long kvmppc_hpte_hv_fault(struct kvm_vcpu *vcpu, unsigned long addr,
743 unsigned long slb_v, unsigned int status, bool data)
744{
745 struct kvm *kvm = vcpu->kvm;
746 long int index;
747 unsigned long v, r, gr;
748 unsigned long *hpte;
749 unsigned long valid;
750 struct revmap_entry *rev;
751 unsigned long pp, key;
752
753 /* For protection fault, expect to find a valid HPTE */
754 valid = HPTE_V_VALID;
755 if (status & DSISR_NOHPTE)
756 valid |= HPTE_V_ABSENT;
757
758 index = kvmppc_hv_find_lock_hpte(kvm, addr, slb_v, valid);
759 if (index < 0) {
760 if (status & DSISR_NOHPTE)
761 return status; /* there really was no HPTE */
762 return 0; /* for prot fault, HPTE disappeared */
763 }
764 hpte = (unsigned long *)(kvm->arch.hpt_virt + (index << 4));
765 v = hpte[0] & ~HPTE_V_HVLOCK;
766 r = hpte[1];
767 rev = real_vmalloc_addr(&kvm->arch.revmap[index]);
768 gr = rev->guest_rpte;
769
770 unlock_hpte(hpte, v);
771
772 /* For not found, if the HPTE is valid by now, retry the instruction */
773 if ((status & DSISR_NOHPTE) && (v & HPTE_V_VALID))
774 return 0;
775
776 /* Check access permissions to the page */
777 pp = gr & (HPTE_R_PP0 | HPTE_R_PP);
778 key = (vcpu->arch.shregs.msr & MSR_PR) ? SLB_VSID_KP : SLB_VSID_KS;
779 status &= ~DSISR_NOHPTE; /* DSISR_NOHPTE == SRR1_ISI_NOPT */
780 if (!data) {
781 if (gr & (HPTE_R_N | HPTE_R_G))
782 return status | SRR1_ISI_N_OR_G;
783 if (!hpte_read_permission(pp, slb_v & key))
784 return status | SRR1_ISI_PROT;
785 } else if (status & DSISR_ISSTORE) {
786 /* check write permission */
787 if (!hpte_write_permission(pp, slb_v & key))
788 return status | DSISR_PROTFAULT;
789 } else {
790 if (!hpte_read_permission(pp, slb_v & key))
791 return status | DSISR_PROTFAULT;
792 }
793
794 /* Check storage key, if applicable */
795 if (data && (vcpu->arch.shregs.msr & MSR_DR)) {
796 unsigned int perm = hpte_get_skey_perm(gr, vcpu->arch.amr);
797 if (status & DSISR_ISSTORE)
798 perm >>= 1;
799 if (perm & 1)
800 return status | DSISR_KEYFAULT;
801 }
802
803 /* Save HPTE info for virtual-mode handler */
804 vcpu->arch.pgfault_addr = addr;
805 vcpu->arch.pgfault_index = index;
806 vcpu->arch.pgfault_hpte[0] = v;
807 vcpu->arch.pgfault_hpte[1] = r;
808
809 /* Check the storage key to see if it is possibly emulated MMIO */
810 if (data && (vcpu->arch.shregs.msr & MSR_IR) &&
811 (r & (HPTE_R_KEY_HI | HPTE_R_KEY_LO)) ==
812 (HPTE_R_KEY_HI | HPTE_R_KEY_LO))
813 return -2; /* MMIO emulation - load instr word */
814
815 return -1; /* send fault up to host kernel mode */
816}
diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
index 5c8b26183f5..b70bf22a3ff 100644
--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
+++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
@@ -601,6 +601,30 @@ kvmppc_interrupt:
601 601
602 stw r12,VCPU_TRAP(r9) 602 stw r12,VCPU_TRAP(r9)
603 603
604 /* Save HEIR (HV emulation assist reg) in last_inst
605 if this is an HEI (HV emulation interrupt, e40) */
606 li r3,KVM_INST_FETCH_FAILED
607BEGIN_FTR_SECTION
608 cmpwi r12,BOOK3S_INTERRUPT_H_EMUL_ASSIST
609 bne 11f
610 mfspr r3,SPRN_HEIR
611END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206)
61211: stw r3,VCPU_LAST_INST(r9)
613
614 /* these are volatile across C function calls */
615 mfctr r3
616 mfxer r4
617 std r3, VCPU_CTR(r9)
618 stw r4, VCPU_XER(r9)
619
620BEGIN_FTR_SECTION
621 /* If this is a page table miss then see if it's theirs or ours */
622 cmpwi r12, BOOK3S_INTERRUPT_H_DATA_STORAGE
623 beq kvmppc_hdsi
624 cmpwi r12, BOOK3S_INTERRUPT_H_INST_STORAGE
625 beq kvmppc_hisi
626END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206)
627
604 /* See if this is a leftover HDEC interrupt */ 628 /* See if this is a leftover HDEC interrupt */
605 cmpwi r12,BOOK3S_INTERRUPT_HV_DECREMENTER 629 cmpwi r12,BOOK3S_INTERRUPT_HV_DECREMENTER
606 bne 2f 630 bne 2f
@@ -608,7 +632,7 @@ kvmppc_interrupt:
608 cmpwi r3,0 632 cmpwi r3,0
609 bge ignore_hdec 633 bge ignore_hdec
6102: 6342:
611 /* See if this is something we can handle in real mode */ 635 /* See if this is an hcall we can handle in real mode */
612 cmpwi r12,BOOK3S_INTERRUPT_SYSCALL 636 cmpwi r12,BOOK3S_INTERRUPT_SYSCALL
613 beq hcall_try_real_mode 637 beq hcall_try_real_mode
614 638
@@ -624,6 +648,7 @@ BEGIN_FTR_SECTION
6241: 6481:
625END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206) 649END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206)
626 650
651nohpte_cont:
627hcall_real_cont: /* r9 = vcpu, r12 = trap, r13 = paca */ 652hcall_real_cont: /* r9 = vcpu, r12 = trap, r13 = paca */
628 /* Save DEC */ 653 /* Save DEC */
629 mfspr r5,SPRN_DEC 654 mfspr r5,SPRN_DEC
@@ -632,36 +657,21 @@ hcall_real_cont: /* r9 = vcpu, r12 = trap, r13 = paca */
632 add r5,r5,r6 657 add r5,r5,r6
633 std r5,VCPU_DEC_EXPIRES(r9) 658 std r5,VCPU_DEC_EXPIRES(r9)
634 659
635 /* Save HEIR (HV emulation assist reg) in last_inst
636 if this is an HEI (HV emulation interrupt, e40) */
637 li r3,-1
638BEGIN_FTR_SECTION
639 cmpwi r12,BOOK3S_INTERRUPT_H_EMUL_ASSIST
640 bne 11f
641 mfspr r3,SPRN_HEIR
642END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206)
64311: stw r3,VCPU_LAST_INST(r9)
644
645 /* Save more register state */ 660 /* Save more register state */
646 mfxer r5
647 mfdar r6 661 mfdar r6
648 mfdsisr r7 662 mfdsisr r7
649 mfctr r8
650
651 stw r5, VCPU_XER(r9)
652 std r6, VCPU_DAR(r9) 663 std r6, VCPU_DAR(r9)
653 stw r7, VCPU_DSISR(r9) 664 stw r7, VCPU_DSISR(r9)
654 std r8, VCPU_CTR(r9)
655 /* grab HDAR & HDSISR if HV data storage interrupt (HDSI) */
656BEGIN_FTR_SECTION 665BEGIN_FTR_SECTION
666 /* don't overwrite fault_dar/fault_dsisr if HDSI */
657 cmpwi r12,BOOK3S_INTERRUPT_H_DATA_STORAGE 667 cmpwi r12,BOOK3S_INTERRUPT_H_DATA_STORAGE
658 beq 6f 668 beq 6f
659END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206) 669END_FTR_SECTION_IFSET(CPU_FTR_ARCH_206)
6607: std r6, VCPU_FAULT_DAR(r9) 670 std r6, VCPU_FAULT_DAR(r9)
661 stw r7, VCPU_FAULT_DSISR(r9) 671 stw r7, VCPU_FAULT_DSISR(r9)
662 672
663 /* Save guest CTRL register, set runlatch to 1 */ 673 /* Save guest CTRL register, set runlatch to 1 */
664 mfspr r6,SPRN_CTRLF 6746: mfspr r6,SPRN_CTRLF
665 stw r6,VCPU_CTRL(r9) 675 stw r6,VCPU_CTRL(r9)
666 andi. r0,r6,1 676 andi. r0,r6,1
667 bne 4f 677 bne 4f
@@ -1094,9 +1104,131 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201)
1094 mtspr SPRN_HSRR1, r7 1104 mtspr SPRN_HSRR1, r7
1095 ba 0x500 1105 ba 0x500
1096 1106
10976: mfspr r6,SPRN_HDAR 1107/*
1098 mfspr r7,SPRN_HDSISR 1108 * Check whether an HDSI is an HPTE not found fault or something else.
1099 b 7b 1109 * If it is an HPTE not found fault that is due to the guest accessing
1110 * a page that they have mapped but which we have paged out, then
1111 * we continue on with the guest exit path. In all other cases,
1112 * reflect the HDSI to the guest as a DSI.
1113 */
1114kvmppc_hdsi:
1115 mfspr r4, SPRN_HDAR
1116 mfspr r6, SPRN_HDSISR
1117 /* HPTE not found fault or protection fault? */
1118 andis. r0, r6, (DSISR_NOHPTE | DSISR_PROTFAULT)@h
1119 beq 1f /* if not, send it to the guest */
1120 andi. r0, r11, MSR_DR /* data relocation enabled? */
1121 beq 3f
1122 clrrdi r0, r4, 28
1123 PPC_SLBFEE_DOT(r5, r0) /* if so, look up SLB */
1124 bne 1f /* if no SLB entry found */
11254: std r4, VCPU_FAULT_DAR(r9)
1126 stw r6, VCPU_FAULT_DSISR(r9)
1127
1128 /* Search the hash table. */
1129 mr r3, r9 /* vcpu pointer */
1130 li r7, 1 /* data fault */
1131 bl .kvmppc_hpte_hv_fault
1132 ld r9, HSTATE_KVM_VCPU(r13)
1133 ld r10, VCPU_PC(r9)
1134 ld r11, VCPU_MSR(r9)
1135 li r12, BOOK3S_INTERRUPT_H_DATA_STORAGE
1136 cmpdi r3, 0 /* retry the instruction */
1137 beq 6f
1138 cmpdi r3, -1 /* handle in kernel mode */
1139 beq nohpte_cont
1140 cmpdi r3, -2 /* MMIO emulation; need instr word */
1141 beq 2f
1142
1143 /* Synthesize a DSI for the guest */
1144 ld r4, VCPU_FAULT_DAR(r9)
1145 mr r6, r3
11461: mtspr SPRN_DAR, r4
1147 mtspr SPRN_DSISR, r6
1148 mtspr SPRN_SRR0, r10
1149 mtspr SPRN_SRR1, r11
1150 li r10, BOOK3S_INTERRUPT_DATA_STORAGE
1151 li r11, (MSR_ME << 1) | 1 /* synthesize MSR_SF | MSR_ME */
1152 rotldi r11, r11, 63
11536: ld r7, VCPU_CTR(r9)
1154 lwz r8, VCPU_XER(r9)
1155 mtctr r7
1156 mtxer r8
1157 mr r4, r9
1158 b fast_guest_return
1159
11603: ld r5, VCPU_KVM(r9) /* not relocated, use VRMA */
1161 ld r5, KVM_VRMA_SLB_V(r5)
1162 b 4b
1163
1164 /* If this is for emulated MMIO, load the instruction word */
11652: li r8, KVM_INST_FETCH_FAILED /* In case lwz faults */
1166
1167 /* Set guest mode to 'jump over instruction' so if lwz faults
1168 * we'll just continue at the next IP. */
1169 li r0, KVM_GUEST_MODE_SKIP
1170 stb r0, HSTATE_IN_GUEST(r13)
1171
1172 /* Do the access with MSR:DR enabled */
1173 mfmsr r3
1174 ori r4, r3, MSR_DR /* Enable paging for data */
1175 mtmsrd r4
1176 lwz r8, 0(r10)
1177 mtmsrd r3
1178
1179 /* Store the result */
1180 stw r8, VCPU_LAST_INST(r9)
1181
1182 /* Unset guest mode. */
1183 li r0, KVM_GUEST_MODE_NONE
1184 stb r0, HSTATE_IN_GUEST(r13)
1185 b nohpte_cont
1186
1187/*
1188 * Similarly for an HISI, reflect it to the guest as an ISI unless
1189 * it is an HPTE not found fault for a page that we have paged out.
1190 */
1191kvmppc_hisi:
1192 andis. r0, r11, SRR1_ISI_NOPT@h
1193 beq 1f
1194 andi. r0, r11, MSR_IR /* instruction relocation enabled? */
1195 beq 3f
1196 clrrdi r0, r10, 28
1197 PPC_SLBFEE_DOT(r5, r0) /* if so, look up SLB */
1198 bne 1f /* if no SLB entry found */
11994:
1200 /* Search the hash table. */
1201 mr r3, r9 /* vcpu pointer */
1202 mr r4, r10
1203 mr r6, r11
1204 li r7, 0 /* instruction fault */
1205 bl .kvmppc_hpte_hv_fault
1206 ld r9, HSTATE_KVM_VCPU(r13)
1207 ld r10, VCPU_PC(r9)
1208 ld r11, VCPU_MSR(r9)
1209 li r12, BOOK3S_INTERRUPT_H_INST_STORAGE
1210 cmpdi r3, 0 /* retry the instruction */
1211 beq 6f
1212 cmpdi r3, -1 /* handle in kernel mode */
1213 beq nohpte_cont
1214
1215 /* Synthesize an ISI for the guest */
1216 mr r11, r3
12171: mtspr SPRN_SRR0, r10
1218 mtspr SPRN_SRR1, r11
1219 li r10, BOOK3S_INTERRUPT_INST_STORAGE
1220 li r11, (MSR_ME << 1) | 1 /* synthesize MSR_SF | MSR_ME */
1221 rotldi r11, r11, 63
12226: ld r7, VCPU_CTR(r9)
1223 lwz r8, VCPU_XER(r9)
1224 mtctr r7
1225 mtxer r8
1226 mr r4, r9
1227 b fast_guest_return
1228
12293: ld r6, VCPU_KVM(r9) /* not relocated, use VRMA */
1230 ld r5, KVM_VRMA_SLB_V(r6)
1231 b 4b
1100 1232
1101/* 1233/*
1102 * Try to handle an hcall in real mode. 1234 * Try to handle an hcall in real mode.
diff --git a/arch/powerpc/kvm/book3s_paired_singles.c b/arch/powerpc/kvm/book3s_paired_singles.c
index 7b0ee96c1be..e70ef2d8643 100644
--- a/arch/powerpc/kvm/book3s_paired_singles.c
+++ b/arch/powerpc/kvm/book3s_paired_singles.c
@@ -196,7 +196,8 @@ static int kvmppc_emulate_fpr_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
196 kvmppc_inject_pf(vcpu, addr, false); 196 kvmppc_inject_pf(vcpu, addr, false);
197 goto done_load; 197 goto done_load;
198 } else if (r == EMULATE_DO_MMIO) { 198 } else if (r == EMULATE_DO_MMIO) {
199 emulated = kvmppc_handle_load(run, vcpu, KVM_REG_FPR | rs, len, 1); 199 emulated = kvmppc_handle_load(run, vcpu, KVM_MMIO_REG_FPR | rs,
200 len, 1);
200 goto done_load; 201 goto done_load;
201 } 202 }
202 203
@@ -286,11 +287,13 @@ static int kvmppc_emulate_psq_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
286 kvmppc_inject_pf(vcpu, addr, false); 287 kvmppc_inject_pf(vcpu, addr, false);
287 goto done_load; 288 goto done_load;
288 } else if ((r == EMULATE_DO_MMIO) && w) { 289 } else if ((r == EMULATE_DO_MMIO) && w) {
289 emulated = kvmppc_handle_load(run, vcpu, KVM_REG_FPR | rs, 4, 1); 290 emulated = kvmppc_handle_load(run, vcpu, KVM_MMIO_REG_FPR | rs,
291 4, 1);
290 vcpu->arch.qpr[rs] = tmp[1]; 292 vcpu->arch.qpr[rs] = tmp[1];
291 goto done_load; 293 goto done_load;
292 } else if (r == EMULATE_DO_MMIO) { 294 } else if (r == EMULATE_DO_MMIO) {
293 emulated = kvmppc_handle_load(run, vcpu, KVM_REG_FQPR | rs, 8, 1); 295 emulated = kvmppc_handle_load(run, vcpu, KVM_MMIO_REG_FQPR | rs,
296 8, 1);
294 goto done_load; 297 goto done_load;
295 } 298 }
296 299
diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c
index 220fcdf2697..7340e1090b7 100644
--- a/arch/powerpc/kvm/book3s_pr.c
+++ b/arch/powerpc/kvm/book3s_pr.c
@@ -51,15 +51,19 @@ static int kvmppc_handle_ext(struct kvm_vcpu *vcpu, unsigned int exit_nr,
51#define MSR_USER32 MSR_USER 51#define MSR_USER32 MSR_USER
52#define MSR_USER64 MSR_USER 52#define MSR_USER64 MSR_USER
53#define HW_PAGE_SIZE PAGE_SIZE 53#define HW_PAGE_SIZE PAGE_SIZE
54#define __hard_irq_disable local_irq_disable
55#define __hard_irq_enable local_irq_enable
54#endif 56#endif
55 57
56void kvmppc_core_vcpu_load(struct kvm_vcpu *vcpu, int cpu) 58void kvmppc_core_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
57{ 59{
58#ifdef CONFIG_PPC_BOOK3S_64 60#ifdef CONFIG_PPC_BOOK3S_64
59 memcpy(to_svcpu(vcpu)->slb, to_book3s(vcpu)->slb_shadow, sizeof(to_svcpu(vcpu)->slb)); 61 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
62 memcpy(svcpu->slb, to_book3s(vcpu)->slb_shadow, sizeof(svcpu->slb));
60 memcpy(&get_paca()->shadow_vcpu, to_book3s(vcpu)->shadow_vcpu, 63 memcpy(&get_paca()->shadow_vcpu, to_book3s(vcpu)->shadow_vcpu,
61 sizeof(get_paca()->shadow_vcpu)); 64 sizeof(get_paca()->shadow_vcpu));
62 to_svcpu(vcpu)->slb_max = to_book3s(vcpu)->slb_shadow_max; 65 svcpu->slb_max = to_book3s(vcpu)->slb_shadow_max;
66 svcpu_put(svcpu);
63#endif 67#endif
64 68
65#ifdef CONFIG_PPC_BOOK3S_32 69#ifdef CONFIG_PPC_BOOK3S_32
@@ -70,10 +74,12 @@ void kvmppc_core_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
70void kvmppc_core_vcpu_put(struct kvm_vcpu *vcpu) 74void kvmppc_core_vcpu_put(struct kvm_vcpu *vcpu)
71{ 75{
72#ifdef CONFIG_PPC_BOOK3S_64 76#ifdef CONFIG_PPC_BOOK3S_64
73 memcpy(to_book3s(vcpu)->slb_shadow, to_svcpu(vcpu)->slb, sizeof(to_svcpu(vcpu)->slb)); 77 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
78 memcpy(to_book3s(vcpu)->slb_shadow, svcpu->slb, sizeof(svcpu->slb));
74 memcpy(to_book3s(vcpu)->shadow_vcpu, &get_paca()->shadow_vcpu, 79 memcpy(to_book3s(vcpu)->shadow_vcpu, &get_paca()->shadow_vcpu,
75 sizeof(get_paca()->shadow_vcpu)); 80 sizeof(get_paca()->shadow_vcpu));
76 to_book3s(vcpu)->slb_shadow_max = to_svcpu(vcpu)->slb_max; 81 to_book3s(vcpu)->slb_shadow_max = svcpu->slb_max;
82 svcpu_put(svcpu);
77#endif 83#endif
78 84
79 kvmppc_giveup_ext(vcpu, MSR_FP); 85 kvmppc_giveup_ext(vcpu, MSR_FP);
@@ -151,14 +157,16 @@ void kvmppc_set_pvr(struct kvm_vcpu *vcpu, u32 pvr)
151#ifdef CONFIG_PPC_BOOK3S_64 157#ifdef CONFIG_PPC_BOOK3S_64
152 if ((pvr >= 0x330000) && (pvr < 0x70330000)) { 158 if ((pvr >= 0x330000) && (pvr < 0x70330000)) {
153 kvmppc_mmu_book3s_64_init(vcpu); 159 kvmppc_mmu_book3s_64_init(vcpu);
154 to_book3s(vcpu)->hior = 0xfff00000; 160 if (!to_book3s(vcpu)->hior_explicit)
161 to_book3s(vcpu)->hior = 0xfff00000;
155 to_book3s(vcpu)->msr_mask = 0xffffffffffffffffULL; 162 to_book3s(vcpu)->msr_mask = 0xffffffffffffffffULL;
156 vcpu->arch.cpu_type = KVM_CPU_3S_64; 163 vcpu->arch.cpu_type = KVM_CPU_3S_64;
157 } else 164 } else
158#endif 165#endif
159 { 166 {
160 kvmppc_mmu_book3s_32_init(vcpu); 167 kvmppc_mmu_book3s_32_init(vcpu);
161 to_book3s(vcpu)->hior = 0; 168 if (!to_book3s(vcpu)->hior_explicit)
169 to_book3s(vcpu)->hior = 0;
162 to_book3s(vcpu)->msr_mask = 0xffffffffULL; 170 to_book3s(vcpu)->msr_mask = 0xffffffffULL;
163 vcpu->arch.cpu_type = KVM_CPU_3S_32; 171 vcpu->arch.cpu_type = KVM_CPU_3S_32;
164 } 172 }
@@ -308,19 +316,22 @@ int kvmppc_handle_pagefault(struct kvm_run *run, struct kvm_vcpu *vcpu,
308 316
309 if (page_found == -ENOENT) { 317 if (page_found == -ENOENT) {
310 /* Page not found in guest PTE entries */ 318 /* Page not found in guest PTE entries */
319 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
311 vcpu->arch.shared->dar = kvmppc_get_fault_dar(vcpu); 320 vcpu->arch.shared->dar = kvmppc_get_fault_dar(vcpu);
312 vcpu->arch.shared->dsisr = to_svcpu(vcpu)->fault_dsisr; 321 vcpu->arch.shared->dsisr = svcpu->fault_dsisr;
313 vcpu->arch.shared->msr |= 322 vcpu->arch.shared->msr |=
314 (to_svcpu(vcpu)->shadow_srr1 & 0x00000000f8000000ULL); 323 (svcpu->shadow_srr1 & 0x00000000f8000000ULL);
324 svcpu_put(svcpu);
315 kvmppc_book3s_queue_irqprio(vcpu, vec); 325 kvmppc_book3s_queue_irqprio(vcpu, vec);
316 } else if (page_found == -EPERM) { 326 } else if (page_found == -EPERM) {
317 /* Storage protection */ 327 /* Storage protection */
328 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
318 vcpu->arch.shared->dar = kvmppc_get_fault_dar(vcpu); 329 vcpu->arch.shared->dar = kvmppc_get_fault_dar(vcpu);
319 vcpu->arch.shared->dsisr = 330 vcpu->arch.shared->dsisr = svcpu->fault_dsisr & ~DSISR_NOHPTE;
320 to_svcpu(vcpu)->fault_dsisr & ~DSISR_NOHPTE;
321 vcpu->arch.shared->dsisr |= DSISR_PROTFAULT; 331 vcpu->arch.shared->dsisr |= DSISR_PROTFAULT;
322 vcpu->arch.shared->msr |= 332 vcpu->arch.shared->msr |=
323 (to_svcpu(vcpu)->shadow_srr1 & 0x00000000f8000000ULL); 333 svcpu->shadow_srr1 & 0x00000000f8000000ULL;
334 svcpu_put(svcpu);
324 kvmppc_book3s_queue_irqprio(vcpu, vec); 335 kvmppc_book3s_queue_irqprio(vcpu, vec);
325 } else if (page_found == -EINVAL) { 336 } else if (page_found == -EINVAL) {
326 /* Page not found in guest SLB */ 337 /* Page not found in guest SLB */
@@ -517,24 +528,29 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
517 run->ready_for_interrupt_injection = 1; 528 run->ready_for_interrupt_injection = 1;
518 529
519 trace_kvm_book3s_exit(exit_nr, vcpu); 530 trace_kvm_book3s_exit(exit_nr, vcpu);
531 preempt_enable();
520 kvm_resched(vcpu); 532 kvm_resched(vcpu);
521 switch (exit_nr) { 533 switch (exit_nr) {
522 case BOOK3S_INTERRUPT_INST_STORAGE: 534 case BOOK3S_INTERRUPT_INST_STORAGE:
535 {
536 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
537 ulong shadow_srr1 = svcpu->shadow_srr1;
523 vcpu->stat.pf_instruc++; 538 vcpu->stat.pf_instruc++;
524 539
525#ifdef CONFIG_PPC_BOOK3S_32 540#ifdef CONFIG_PPC_BOOK3S_32
526 /* We set segments as unused segments when invalidating them. So 541 /* We set segments as unused segments when invalidating them. So
527 * treat the respective fault as segment fault. */ 542 * treat the respective fault as segment fault. */
528 if (to_svcpu(vcpu)->sr[kvmppc_get_pc(vcpu) >> SID_SHIFT] 543 if (svcpu->sr[kvmppc_get_pc(vcpu) >> SID_SHIFT] == SR_INVALID) {
529 == SR_INVALID) {
530 kvmppc_mmu_map_segment(vcpu, kvmppc_get_pc(vcpu)); 544 kvmppc_mmu_map_segment(vcpu, kvmppc_get_pc(vcpu));
531 r = RESUME_GUEST; 545 r = RESUME_GUEST;
546 svcpu_put(svcpu);
532 break; 547 break;
533 } 548 }
534#endif 549#endif
550 svcpu_put(svcpu);
535 551
536 /* only care about PTEG not found errors, but leave NX alone */ 552 /* only care about PTEG not found errors, but leave NX alone */
537 if (to_svcpu(vcpu)->shadow_srr1 & 0x40000000) { 553 if (shadow_srr1 & 0x40000000) {
538 r = kvmppc_handle_pagefault(run, vcpu, kvmppc_get_pc(vcpu), exit_nr); 554 r = kvmppc_handle_pagefault(run, vcpu, kvmppc_get_pc(vcpu), exit_nr);
539 vcpu->stat.sp_instruc++; 555 vcpu->stat.sp_instruc++;
540 } else if (vcpu->arch.mmu.is_dcbz32(vcpu) && 556 } else if (vcpu->arch.mmu.is_dcbz32(vcpu) &&
@@ -547,33 +563,37 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
547 kvmppc_mmu_pte_flush(vcpu, kvmppc_get_pc(vcpu), ~0xFFFUL); 563 kvmppc_mmu_pte_flush(vcpu, kvmppc_get_pc(vcpu), ~0xFFFUL);
548 r = RESUME_GUEST; 564 r = RESUME_GUEST;
549 } else { 565 } else {
550 vcpu->arch.shared->msr |= 566 vcpu->arch.shared->msr |= shadow_srr1 & 0x58000000;
551 to_svcpu(vcpu)->shadow_srr1 & 0x58000000;
552 kvmppc_book3s_queue_irqprio(vcpu, exit_nr); 567 kvmppc_book3s_queue_irqprio(vcpu, exit_nr);
553 r = RESUME_GUEST; 568 r = RESUME_GUEST;
554 } 569 }
555 break; 570 break;
571 }
556 case BOOK3S_INTERRUPT_DATA_STORAGE: 572 case BOOK3S_INTERRUPT_DATA_STORAGE:
557 { 573 {
558 ulong dar = kvmppc_get_fault_dar(vcpu); 574 ulong dar = kvmppc_get_fault_dar(vcpu);
575 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
576 u32 fault_dsisr = svcpu->fault_dsisr;
559 vcpu->stat.pf_storage++; 577 vcpu->stat.pf_storage++;
560 578
561#ifdef CONFIG_PPC_BOOK3S_32 579#ifdef CONFIG_PPC_BOOK3S_32
562 /* We set segments as unused segments when invalidating them. So 580 /* We set segments as unused segments when invalidating them. So
563 * treat the respective fault as segment fault. */ 581 * treat the respective fault as segment fault. */
564 if ((to_svcpu(vcpu)->sr[dar >> SID_SHIFT]) == SR_INVALID) { 582 if ((svcpu->sr[dar >> SID_SHIFT]) == SR_INVALID) {
565 kvmppc_mmu_map_segment(vcpu, dar); 583 kvmppc_mmu_map_segment(vcpu, dar);
566 r = RESUME_GUEST; 584 r = RESUME_GUEST;
585 svcpu_put(svcpu);
567 break; 586 break;
568 } 587 }
569#endif 588#endif
589 svcpu_put(svcpu);
570 590
571 /* The only case we need to handle is missing shadow PTEs */ 591 /* The only case we need to handle is missing shadow PTEs */
572 if (to_svcpu(vcpu)->fault_dsisr & DSISR_NOHPTE) { 592 if (fault_dsisr & DSISR_NOHPTE) {
573 r = kvmppc_handle_pagefault(run, vcpu, dar, exit_nr); 593 r = kvmppc_handle_pagefault(run, vcpu, dar, exit_nr);
574 } else { 594 } else {
575 vcpu->arch.shared->dar = dar; 595 vcpu->arch.shared->dar = dar;
576 vcpu->arch.shared->dsisr = to_svcpu(vcpu)->fault_dsisr; 596 vcpu->arch.shared->dsisr = fault_dsisr;
577 kvmppc_book3s_queue_irqprio(vcpu, exit_nr); 597 kvmppc_book3s_queue_irqprio(vcpu, exit_nr);
578 r = RESUME_GUEST; 598 r = RESUME_GUEST;
579 } 599 }
@@ -609,10 +629,13 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
609 case BOOK3S_INTERRUPT_PROGRAM: 629 case BOOK3S_INTERRUPT_PROGRAM:
610 { 630 {
611 enum emulation_result er; 631 enum emulation_result er;
632 struct kvmppc_book3s_shadow_vcpu *svcpu;
612 ulong flags; 633 ulong flags;
613 634
614program_interrupt: 635program_interrupt:
615 flags = to_svcpu(vcpu)->shadow_srr1 & 0x1f0000ull; 636 svcpu = svcpu_get(vcpu);
637 flags = svcpu->shadow_srr1 & 0x1f0000ull;
638 svcpu_put(svcpu);
616 639
617 if (vcpu->arch.shared->msr & MSR_PR) { 640 if (vcpu->arch.shared->msr & MSR_PR) {
618#ifdef EXIT_DEBUG 641#ifdef EXIT_DEBUG
@@ -740,20 +763,33 @@ program_interrupt:
740 r = RESUME_GUEST; 763 r = RESUME_GUEST;
741 break; 764 break;
742 default: 765 default:
766 {
767 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
768 ulong shadow_srr1 = svcpu->shadow_srr1;
769 svcpu_put(svcpu);
743 /* Ugh - bork here! What did we get? */ 770 /* Ugh - bork here! What did we get? */
744 printk(KERN_EMERG "exit_nr=0x%x | pc=0x%lx | msr=0x%lx\n", 771 printk(KERN_EMERG "exit_nr=0x%x | pc=0x%lx | msr=0x%lx\n",
745 exit_nr, kvmppc_get_pc(vcpu), to_svcpu(vcpu)->shadow_srr1); 772 exit_nr, kvmppc_get_pc(vcpu), shadow_srr1);
746 r = RESUME_HOST; 773 r = RESUME_HOST;
747 BUG(); 774 BUG();
748 break; 775 break;
749 } 776 }
750 777 }
751 778
752 if (!(r & RESUME_HOST)) { 779 if (!(r & RESUME_HOST)) {
753 /* To avoid clobbering exit_reason, only check for signals if 780 /* To avoid clobbering exit_reason, only check for signals if
754 * we aren't already exiting to userspace for some other 781 * we aren't already exiting to userspace for some other
755 * reason. */ 782 * reason. */
783
784 /*
785 * Interrupts could be timers for the guest which we have to
786 * inject again, so let's postpone them until we're in the guest
787 * and if we really did time things so badly, then we just exit
788 * again due to a host external interrupt.
789 */
790 __hard_irq_disable();
756 if (signal_pending(current)) { 791 if (signal_pending(current)) {
792 __hard_irq_enable();
757#ifdef EXIT_DEBUG 793#ifdef EXIT_DEBUG
758 printk(KERN_EMERG "KVM: Going back to host\n"); 794 printk(KERN_EMERG "KVM: Going back to host\n");
759#endif 795#endif
@@ -761,10 +797,12 @@ program_interrupt:
761 run->exit_reason = KVM_EXIT_INTR; 797 run->exit_reason = KVM_EXIT_INTR;
762 r = -EINTR; 798 r = -EINTR;
763 } else { 799 } else {
800 preempt_disable();
801
764 /* In case an interrupt came in that was triggered 802 /* In case an interrupt came in that was triggered
765 * from userspace (like DEC), we need to check what 803 * from userspace (like DEC), we need to check what
766 * to inject now! */ 804 * to inject now! */
767 kvmppc_core_deliver_interrupts(vcpu); 805 kvmppc_core_prepare_to_enter(vcpu);
768 } 806 }
769 } 807 }
770 808
@@ -836,6 +874,38 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
836 return 0; 874 return 0;
837} 875}
838 876
877int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
878{
879 int r = -EINVAL;
880
881 switch (reg->id) {
882 case KVM_REG_PPC_HIOR:
883 r = put_user(to_book3s(vcpu)->hior, (u64 __user *)reg->addr);
884 break;
885 default:
886 break;
887 }
888
889 return r;
890}
891
892int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
893{
894 int r = -EINVAL;
895
896 switch (reg->id) {
897 case KVM_REG_PPC_HIOR:
898 r = get_user(to_book3s(vcpu)->hior, (u64 __user *)reg->addr);
899 if (!r)
900 to_book3s(vcpu)->hior_explicit = true;
901 break;
902 default:
903 break;
904 }
905
906 return r;
907}
908
839int kvmppc_core_check_processor_compat(void) 909int kvmppc_core_check_processor_compat(void)
840{ 910{
841 return 0; 911 return 0;
@@ -923,16 +993,31 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
923#endif 993#endif
924 ulong ext_msr; 994 ulong ext_msr;
925 995
996 preempt_disable();
997
926 /* Check if we can run the vcpu at all */ 998 /* Check if we can run the vcpu at all */
927 if (!vcpu->arch.sane) { 999 if (!vcpu->arch.sane) {
928 kvm_run->exit_reason = KVM_EXIT_INTERNAL_ERROR; 1000 kvm_run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
929 return -EINVAL; 1001 ret = -EINVAL;
1002 goto out;
930 } 1003 }
931 1004
1005 kvmppc_core_prepare_to_enter(vcpu);
1006
1007 /*
1008 * Interrupts could be timers for the guest which we have to inject
1009 * again, so let's postpone them until we're in the guest and if we
1010 * really did time things so badly, then we just exit again due to
1011 * a host external interrupt.
1012 */
1013 __hard_irq_disable();
1014
932 /* No need to go into the guest when all we do is going out */ 1015 /* No need to go into the guest when all we do is going out */
933 if (signal_pending(current)) { 1016 if (signal_pending(current)) {
1017 __hard_irq_enable();
934 kvm_run->exit_reason = KVM_EXIT_INTR; 1018 kvm_run->exit_reason = KVM_EXIT_INTR;
935 return -EINTR; 1019 ret = -EINTR;
1020 goto out;
936 } 1021 }
937 1022
938 /* Save FPU state in stack */ 1023 /* Save FPU state in stack */
@@ -974,8 +1059,6 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
974 1059
975 kvm_guest_exit(); 1060 kvm_guest_exit();
976 1061
977 local_irq_disable();
978
979 current->thread.regs->msr = ext_msr; 1062 current->thread.regs->msr = ext_msr;
980 1063
981 /* Make sure we save the guest FPU/Altivec/VSX state */ 1064 /* Make sure we save the guest FPU/Altivec/VSX state */
@@ -1002,9 +1085,50 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
1002 current->thread.used_vsr = used_vsr; 1085 current->thread.used_vsr = used_vsr;
1003#endif 1086#endif
1004 1087
1088out:
1089 preempt_enable();
1005 return ret; 1090 return ret;
1006} 1091}
1007 1092
1093/*
1094 * Get (and clear) the dirty memory log for a memory slot.
1095 */
1096int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
1097 struct kvm_dirty_log *log)
1098{
1099 struct kvm_memory_slot *memslot;
1100 struct kvm_vcpu *vcpu;
1101 ulong ga, ga_end;
1102 int is_dirty = 0;
1103 int r;
1104 unsigned long n;
1105
1106 mutex_lock(&kvm->slots_lock);
1107
1108 r = kvm_get_dirty_log(kvm, log, &is_dirty);
1109 if (r)
1110 goto out;
1111
1112 /* If nothing is dirty, don't bother messing with page tables. */
1113 if (is_dirty) {
1114 memslot = id_to_memslot(kvm->memslots, log->slot);
1115
1116 ga = memslot->base_gfn << PAGE_SHIFT;
1117 ga_end = ga + (memslot->npages << PAGE_SHIFT);
1118
1119 kvm_for_each_vcpu(n, vcpu, kvm)
1120 kvmppc_mmu_pte_pflush(vcpu, ga, ga_end);
1121
1122 n = kvm_dirty_bitmap_bytes(memslot);
1123 memset(memslot->dirty_bitmap, 0, n);
1124 }
1125
1126 r = 0;
1127out:
1128 mutex_unlock(&kvm->slots_lock);
1129 return r;
1130}
1131
1008int kvmppc_core_prepare_memory_region(struct kvm *kvm, 1132int kvmppc_core_prepare_memory_region(struct kvm *kvm,
1009 struct kvm_userspace_memory_region *mem) 1133 struct kvm_userspace_memory_region *mem)
1010{ 1134{
diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index bb6c988f010..ee9e1ee9c85 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -124,12 +124,6 @@ void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr)
124 vcpu->arch.shared->msr = new_msr; 124 vcpu->arch.shared->msr = new_msr;
125 125
126 kvmppc_mmu_msr_notify(vcpu, old_msr); 126 kvmppc_mmu_msr_notify(vcpu, old_msr);
127
128 if (vcpu->arch.shared->msr & MSR_WE) {
129 kvm_vcpu_block(vcpu);
130 kvmppc_set_exit_type(vcpu, EMULATED_MTMSRWE_EXITS);
131 };
132
133 kvmppc_vcpu_sync_spe(vcpu); 127 kvmppc_vcpu_sync_spe(vcpu);
134} 128}
135 129
@@ -258,9 +252,11 @@ static int kvmppc_booke_irqprio_deliver(struct kvm_vcpu *vcpu,
258 allowed = vcpu->arch.shared->msr & MSR_ME; 252 allowed = vcpu->arch.shared->msr & MSR_ME;
259 msr_mask = 0; 253 msr_mask = 0;
260 break; 254 break;
261 case BOOKE_IRQPRIO_EXTERNAL:
262 case BOOKE_IRQPRIO_DECREMENTER: 255 case BOOKE_IRQPRIO_DECREMENTER:
263 case BOOKE_IRQPRIO_FIT: 256 case BOOKE_IRQPRIO_FIT:
257 keep_irq = true;
258 /* fall through */
259 case BOOKE_IRQPRIO_EXTERNAL:
264 allowed = vcpu->arch.shared->msr & MSR_EE; 260 allowed = vcpu->arch.shared->msr & MSR_EE;
265 allowed = allowed && !crit; 261 allowed = allowed && !crit;
266 msr_mask = MSR_CE|MSR_ME|MSR_DE; 262 msr_mask = MSR_CE|MSR_ME|MSR_DE;
@@ -276,7 +272,7 @@ static int kvmppc_booke_irqprio_deliver(struct kvm_vcpu *vcpu,
276 vcpu->arch.shared->srr1 = vcpu->arch.shared->msr; 272 vcpu->arch.shared->srr1 = vcpu->arch.shared->msr;
277 vcpu->arch.pc = vcpu->arch.ivpr | vcpu->arch.ivor[priority]; 273 vcpu->arch.pc = vcpu->arch.ivpr | vcpu->arch.ivor[priority];
278 if (update_esr == true) 274 if (update_esr == true)
279 vcpu->arch.esr = vcpu->arch.queued_esr; 275 vcpu->arch.shared->esr = vcpu->arch.queued_esr;
280 if (update_dear == true) 276 if (update_dear == true)
281 vcpu->arch.shared->dar = vcpu->arch.queued_dear; 277 vcpu->arch.shared->dar = vcpu->arch.queued_dear;
282 kvmppc_set_msr(vcpu, vcpu->arch.shared->msr & msr_mask); 278 kvmppc_set_msr(vcpu, vcpu->arch.shared->msr & msr_mask);
@@ -288,13 +284,26 @@ static int kvmppc_booke_irqprio_deliver(struct kvm_vcpu *vcpu,
288 return allowed; 284 return allowed;
289} 285}
290 286
291/* Check pending exceptions and deliver one, if possible. */ 287static void update_timer_ints(struct kvm_vcpu *vcpu)
292void kvmppc_core_deliver_interrupts(struct kvm_vcpu *vcpu) 288{
289 if ((vcpu->arch.tcr & TCR_DIE) && (vcpu->arch.tsr & TSR_DIS))
290 kvmppc_core_queue_dec(vcpu);
291 else
292 kvmppc_core_dequeue_dec(vcpu);
293}
294
295static void kvmppc_core_check_exceptions(struct kvm_vcpu *vcpu)
293{ 296{
294 unsigned long *pending = &vcpu->arch.pending_exceptions; 297 unsigned long *pending = &vcpu->arch.pending_exceptions;
295 unsigned long old_pending = vcpu->arch.pending_exceptions;
296 unsigned int priority; 298 unsigned int priority;
297 299
300 if (vcpu->requests) {
301 if (kvm_check_request(KVM_REQ_PENDING_TIMER, vcpu)) {
302 smp_mb();
303 update_timer_ints(vcpu);
304 }
305 }
306
298 priority = __ffs(*pending); 307 priority = __ffs(*pending);
299 while (priority <= BOOKE_IRQPRIO_MAX) { 308 while (priority <= BOOKE_IRQPRIO_MAX) {
300 if (kvmppc_booke_irqprio_deliver(vcpu, priority)) 309 if (kvmppc_booke_irqprio_deliver(vcpu, priority))
@@ -306,10 +315,24 @@ void kvmppc_core_deliver_interrupts(struct kvm_vcpu *vcpu)
306 } 315 }
307 316
308 /* Tell the guest about our interrupt status */ 317 /* Tell the guest about our interrupt status */
309 if (*pending) 318 vcpu->arch.shared->int_pending = !!*pending;
310 vcpu->arch.shared->int_pending = 1; 319}
311 else if (old_pending) 320
312 vcpu->arch.shared->int_pending = 0; 321/* Check pending exceptions and deliver one, if possible. */
322void kvmppc_core_prepare_to_enter(struct kvm_vcpu *vcpu)
323{
324 WARN_ON_ONCE(!irqs_disabled());
325
326 kvmppc_core_check_exceptions(vcpu);
327
328 if (vcpu->arch.shared->msr & MSR_WE) {
329 local_irq_enable();
330 kvm_vcpu_block(vcpu);
331 local_irq_disable();
332
333 kvmppc_set_exit_type(vcpu, EMULATED_MTMSRWE_EXITS);
334 kvmppc_core_check_exceptions(vcpu);
335 };
313} 336}
314 337
315int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) 338int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
@@ -322,11 +345,21 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
322 } 345 }
323 346
324 local_irq_disable(); 347 local_irq_disable();
348
349 kvmppc_core_prepare_to_enter(vcpu);
350
351 if (signal_pending(current)) {
352 kvm_run->exit_reason = KVM_EXIT_INTR;
353 ret = -EINTR;
354 goto out;
355 }
356
325 kvm_guest_enter(); 357 kvm_guest_enter();
326 ret = __kvmppc_vcpu_run(kvm_run, vcpu); 358 ret = __kvmppc_vcpu_run(kvm_run, vcpu);
327 kvm_guest_exit(); 359 kvm_guest_exit();
328 local_irq_enable();
329 360
361out:
362 local_irq_enable();
330 return ret; 363 return ret;
331} 364}
332 365
@@ -603,7 +636,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
603 636
604 local_irq_disable(); 637 local_irq_disable();
605 638
606 kvmppc_core_deliver_interrupts(vcpu); 639 kvmppc_core_prepare_to_enter(vcpu);
607 640
608 if (!(r & RESUME_HOST)) { 641 if (!(r & RESUME_HOST)) {
609 /* To avoid clobbering exit_reason, only check for signals if 642 /* To avoid clobbering exit_reason, only check for signals if
@@ -628,6 +661,7 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
628 vcpu->arch.pc = 0; 661 vcpu->arch.pc = 0;
629 vcpu->arch.shared->msr = 0; 662 vcpu->arch.shared->msr = 0;
630 vcpu->arch.shadow_msr = MSR_USER | MSR_DE | MSR_IS | MSR_DS; 663 vcpu->arch.shadow_msr = MSR_USER | MSR_DE | MSR_IS | MSR_DS;
664 vcpu->arch.shared->pir = vcpu->vcpu_id;
631 kvmppc_set_gpr(vcpu, 1, (16<<20) - 8); /* -8 for the callee-save LR slot */ 665 kvmppc_set_gpr(vcpu, 1, (16<<20) - 8); /* -8 for the callee-save LR slot */
632 666
633 vcpu->arch.shadow_pid = 1; 667 vcpu->arch.shadow_pid = 1;
@@ -662,10 +696,10 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
662 regs->sprg1 = vcpu->arch.shared->sprg1; 696 regs->sprg1 = vcpu->arch.shared->sprg1;
663 regs->sprg2 = vcpu->arch.shared->sprg2; 697 regs->sprg2 = vcpu->arch.shared->sprg2;
664 regs->sprg3 = vcpu->arch.shared->sprg3; 698 regs->sprg3 = vcpu->arch.shared->sprg3;
665 regs->sprg4 = vcpu->arch.sprg4; 699 regs->sprg4 = vcpu->arch.shared->sprg4;
666 regs->sprg5 = vcpu->arch.sprg5; 700 regs->sprg5 = vcpu->arch.shared->sprg5;
667 regs->sprg6 = vcpu->arch.sprg6; 701 regs->sprg6 = vcpu->arch.shared->sprg6;
668 regs->sprg7 = vcpu->arch.sprg7; 702 regs->sprg7 = vcpu->arch.shared->sprg7;
669 703
670 for (i = 0; i < ARRAY_SIZE(regs->gpr); i++) 704 for (i = 0; i < ARRAY_SIZE(regs->gpr); i++)
671 regs->gpr[i] = kvmppc_get_gpr(vcpu, i); 705 regs->gpr[i] = kvmppc_get_gpr(vcpu, i);
@@ -690,10 +724,10 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
690 vcpu->arch.shared->sprg1 = regs->sprg1; 724 vcpu->arch.shared->sprg1 = regs->sprg1;
691 vcpu->arch.shared->sprg2 = regs->sprg2; 725 vcpu->arch.shared->sprg2 = regs->sprg2;
692 vcpu->arch.shared->sprg3 = regs->sprg3; 726 vcpu->arch.shared->sprg3 = regs->sprg3;
693 vcpu->arch.sprg4 = regs->sprg4; 727 vcpu->arch.shared->sprg4 = regs->sprg4;
694 vcpu->arch.sprg5 = regs->sprg5; 728 vcpu->arch.shared->sprg5 = regs->sprg5;
695 vcpu->arch.sprg6 = regs->sprg6; 729 vcpu->arch.shared->sprg6 = regs->sprg6;
696 vcpu->arch.sprg7 = regs->sprg7; 730 vcpu->arch.shared->sprg7 = regs->sprg7;
697 731
698 for (i = 0; i < ARRAY_SIZE(regs->gpr); i++) 732 for (i = 0; i < ARRAY_SIZE(regs->gpr); i++)
699 kvmppc_set_gpr(vcpu, i, regs->gpr[i]); 733 kvmppc_set_gpr(vcpu, i, regs->gpr[i]);
@@ -711,7 +745,7 @@ static void get_sregs_base(struct kvm_vcpu *vcpu,
711 sregs->u.e.csrr0 = vcpu->arch.csrr0; 745 sregs->u.e.csrr0 = vcpu->arch.csrr0;
712 sregs->u.e.csrr1 = vcpu->arch.csrr1; 746 sregs->u.e.csrr1 = vcpu->arch.csrr1;
713 sregs->u.e.mcsr = vcpu->arch.mcsr; 747 sregs->u.e.mcsr = vcpu->arch.mcsr;
714 sregs->u.e.esr = vcpu->arch.esr; 748 sregs->u.e.esr = vcpu->arch.shared->esr;
715 sregs->u.e.dear = vcpu->arch.shared->dar; 749 sregs->u.e.dear = vcpu->arch.shared->dar;
716 sregs->u.e.tsr = vcpu->arch.tsr; 750 sregs->u.e.tsr = vcpu->arch.tsr;
717 sregs->u.e.tcr = vcpu->arch.tcr; 751 sregs->u.e.tcr = vcpu->arch.tcr;
@@ -729,28 +763,19 @@ static int set_sregs_base(struct kvm_vcpu *vcpu,
729 vcpu->arch.csrr0 = sregs->u.e.csrr0; 763 vcpu->arch.csrr0 = sregs->u.e.csrr0;
730 vcpu->arch.csrr1 = sregs->u.e.csrr1; 764 vcpu->arch.csrr1 = sregs->u.e.csrr1;
731 vcpu->arch.mcsr = sregs->u.e.mcsr; 765 vcpu->arch.mcsr = sregs->u.e.mcsr;
732 vcpu->arch.esr = sregs->u.e.esr; 766 vcpu->arch.shared->esr = sregs->u.e.esr;
733 vcpu->arch.shared->dar = sregs->u.e.dear; 767 vcpu->arch.shared->dar = sregs->u.e.dear;
734 vcpu->arch.vrsave = sregs->u.e.vrsave; 768 vcpu->arch.vrsave = sregs->u.e.vrsave;
735 vcpu->arch.tcr = sregs->u.e.tcr; 769 kvmppc_set_tcr(vcpu, sregs->u.e.tcr);
736 770
737 if (sregs->u.e.update_special & KVM_SREGS_E_UPDATE_DEC) 771 if (sregs->u.e.update_special & KVM_SREGS_E_UPDATE_DEC) {
738 vcpu->arch.dec = sregs->u.e.dec; 772 vcpu->arch.dec = sregs->u.e.dec;
739 773 kvmppc_emulate_dec(vcpu);
740 kvmppc_emulate_dec(vcpu); 774 }
741 775
742 if (sregs->u.e.update_special & KVM_SREGS_E_UPDATE_TSR) { 776 if (sregs->u.e.update_special & KVM_SREGS_E_UPDATE_TSR) {
743 /* 777 vcpu->arch.tsr = sregs->u.e.tsr;
744 * FIXME: existing KVM timer handling is incomplete. 778 update_timer_ints(vcpu);
745 * TSR cannot be read by the guest, and its value in
746 * vcpu->arch is always zero. For now, just handle
747 * the case where the caller is trying to inject a
748 * decrementer interrupt.
749 */
750
751 if ((sregs->u.e.tsr & TSR_DIS) &&
752 (vcpu->arch.tcr & TCR_DIE))
753 kvmppc_core_queue_dec(vcpu);
754 } 779 }
755 780
756 return 0; 781 return 0;
@@ -761,7 +786,7 @@ static void get_sregs_arch206(struct kvm_vcpu *vcpu,
761{ 786{
762 sregs->u.e.features |= KVM_SREGS_E_ARCH206; 787 sregs->u.e.features |= KVM_SREGS_E_ARCH206;
763 788
764 sregs->u.e.pir = 0; 789 sregs->u.e.pir = vcpu->vcpu_id;
765 sregs->u.e.mcsrr0 = vcpu->arch.mcsrr0; 790 sregs->u.e.mcsrr0 = vcpu->arch.mcsrr0;
766 sregs->u.e.mcsrr1 = vcpu->arch.mcsrr1; 791 sregs->u.e.mcsrr1 = vcpu->arch.mcsrr1;
767 sregs->u.e.decar = vcpu->arch.decar; 792 sregs->u.e.decar = vcpu->arch.decar;
@@ -774,7 +799,7 @@ static int set_sregs_arch206(struct kvm_vcpu *vcpu,
774 if (!(sregs->u.e.features & KVM_SREGS_E_ARCH206)) 799 if (!(sregs->u.e.features & KVM_SREGS_E_ARCH206))
775 return 0; 800 return 0;
776 801
777 if (sregs->u.e.pir != 0) 802 if (sregs->u.e.pir != vcpu->vcpu_id)
778 return -EINVAL; 803 return -EINVAL;
779 804
780 vcpu->arch.mcsrr0 = sregs->u.e.mcsrr0; 805 vcpu->arch.mcsrr0 = sregs->u.e.mcsrr0;
@@ -862,6 +887,16 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
862 return kvmppc_core_set_sregs(vcpu, sregs); 887 return kvmppc_core_set_sregs(vcpu, sregs);
863} 888}
864 889
890int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
891{
892 return -EINVAL;
893}
894
895int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
896{
897 return -EINVAL;
898}
899
865int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) 900int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
866{ 901{
867 return -ENOTSUPP; 902 return -ENOTSUPP;
@@ -906,6 +941,33 @@ void kvmppc_core_destroy_vm(struct kvm *kvm)
906{ 941{
907} 942}
908 943
944void kvmppc_set_tcr(struct kvm_vcpu *vcpu, u32 new_tcr)
945{
946 vcpu->arch.tcr = new_tcr;
947 update_timer_ints(vcpu);
948}
949
950void kvmppc_set_tsr_bits(struct kvm_vcpu *vcpu, u32 tsr_bits)
951{
952 set_bits(tsr_bits, &vcpu->arch.tsr);
953 smp_wmb();
954 kvm_make_request(KVM_REQ_PENDING_TIMER, vcpu);
955 kvm_vcpu_kick(vcpu);
956}
957
958void kvmppc_clr_tsr_bits(struct kvm_vcpu *vcpu, u32 tsr_bits)
959{
960 clear_bits(tsr_bits, &vcpu->arch.tsr);
961 update_timer_ints(vcpu);
962}
963
964void kvmppc_decrementer_func(unsigned long data)
965{
966 struct kvm_vcpu *vcpu = (struct kvm_vcpu *)data;
967
968 kvmppc_set_tsr_bits(vcpu, TSR_DIS);
969}
970
909int __init kvmppc_booke_init(void) 971int __init kvmppc_booke_init(void)
910{ 972{
911 unsigned long ivor[16]; 973 unsigned long ivor[16];
diff --git a/arch/powerpc/kvm/booke.h b/arch/powerpc/kvm/booke.h
index 8e1fe33d64e..2fe202705a3 100644
--- a/arch/powerpc/kvm/booke.h
+++ b/arch/powerpc/kvm/booke.h
@@ -55,6 +55,10 @@ extern unsigned long kvmppc_booke_handlers;
55void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr); 55void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr);
56void kvmppc_mmu_msr_notify(struct kvm_vcpu *vcpu, u32 old_msr); 56void kvmppc_mmu_msr_notify(struct kvm_vcpu *vcpu, u32 old_msr);
57 57
58void kvmppc_set_tcr(struct kvm_vcpu *vcpu, u32 new_tcr);
59void kvmppc_set_tsr_bits(struct kvm_vcpu *vcpu, u32 tsr_bits);
60void kvmppc_clr_tsr_bits(struct kvm_vcpu *vcpu, u32 tsr_bits);
61
58int kvmppc_booke_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu, 62int kvmppc_booke_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
59 unsigned int inst, int *advance); 63 unsigned int inst, int *advance);
60int kvmppc_booke_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, int rt); 64int kvmppc_booke_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, int rt);
diff --git a/arch/powerpc/kvm/booke_emulate.c b/arch/powerpc/kvm/booke_emulate.c
index 1260f5f24c0..3e652da3653 100644
--- a/arch/powerpc/kvm/booke_emulate.c
+++ b/arch/powerpc/kvm/booke_emulate.c
@@ -13,6 +13,7 @@
13 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 13 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14 * 14 *
15 * Copyright IBM Corp. 2008 15 * Copyright IBM Corp. 2008
16 * Copyright 2011 Freescale Semiconductor, Inc.
16 * 17 *
17 * Authors: Hollis Blanchard <hollisb@us.ibm.com> 18 * Authors: Hollis Blanchard <hollisb@us.ibm.com>
18 */ 19 */
@@ -107,7 +108,7 @@ int kvmppc_booke_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, int rs)
107 case SPRN_DEAR: 108 case SPRN_DEAR:
108 vcpu->arch.shared->dar = spr_val; break; 109 vcpu->arch.shared->dar = spr_val; break;
109 case SPRN_ESR: 110 case SPRN_ESR:
110 vcpu->arch.esr = spr_val; break; 111 vcpu->arch.shared->esr = spr_val; break;
111 case SPRN_DBCR0: 112 case SPRN_DBCR0:
112 vcpu->arch.dbcr0 = spr_val; break; 113 vcpu->arch.dbcr0 = spr_val; break;
113 case SPRN_DBCR1: 114 case SPRN_DBCR1:
@@ -115,23 +116,23 @@ int kvmppc_booke_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, int rs)
115 case SPRN_DBSR: 116 case SPRN_DBSR:
116 vcpu->arch.dbsr &= ~spr_val; break; 117 vcpu->arch.dbsr &= ~spr_val; break;
117 case SPRN_TSR: 118 case SPRN_TSR:
118 vcpu->arch.tsr &= ~spr_val; break; 119 kvmppc_clr_tsr_bits(vcpu, spr_val);
120 break;
119 case SPRN_TCR: 121 case SPRN_TCR:
120 vcpu->arch.tcr = spr_val; 122 kvmppc_set_tcr(vcpu, spr_val);
121 kvmppc_emulate_dec(vcpu);
122 break; 123 break;
123 124
124 /* Note: SPRG4-7 are user-readable. These values are 125 /* Note: SPRG4-7 are user-readable. These values are
125 * loaded into the real SPRGs when resuming the 126 * loaded into the real SPRGs when resuming the
126 * guest. */ 127 * guest. */
127 case SPRN_SPRG4: 128 case SPRN_SPRG4:
128 vcpu->arch.sprg4 = spr_val; break; 129 vcpu->arch.shared->sprg4 = spr_val; break;
129 case SPRN_SPRG5: 130 case SPRN_SPRG5:
130 vcpu->arch.sprg5 = spr_val; break; 131 vcpu->arch.shared->sprg5 = spr_val; break;
131 case SPRN_SPRG6: 132 case SPRN_SPRG6:
132 vcpu->arch.sprg6 = spr_val; break; 133 vcpu->arch.shared->sprg6 = spr_val; break;
133 case SPRN_SPRG7: 134 case SPRN_SPRG7:
134 vcpu->arch.sprg7 = spr_val; break; 135 vcpu->arch.shared->sprg7 = spr_val; break;
135 136
136 case SPRN_IVPR: 137 case SPRN_IVPR:
137 vcpu->arch.ivpr = spr_val; 138 vcpu->arch.ivpr = spr_val;
@@ -202,13 +203,17 @@ int kvmppc_booke_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, int rt)
202 case SPRN_DEAR: 203 case SPRN_DEAR:
203 kvmppc_set_gpr(vcpu, rt, vcpu->arch.shared->dar); break; 204 kvmppc_set_gpr(vcpu, rt, vcpu->arch.shared->dar); break;
204 case SPRN_ESR: 205 case SPRN_ESR:
205 kvmppc_set_gpr(vcpu, rt, vcpu->arch.esr); break; 206 kvmppc_set_gpr(vcpu, rt, vcpu->arch.shared->esr); break;
206 case SPRN_DBCR0: 207 case SPRN_DBCR0:
207 kvmppc_set_gpr(vcpu, rt, vcpu->arch.dbcr0); break; 208 kvmppc_set_gpr(vcpu, rt, vcpu->arch.dbcr0); break;
208 case SPRN_DBCR1: 209 case SPRN_DBCR1:
209 kvmppc_set_gpr(vcpu, rt, vcpu->arch.dbcr1); break; 210 kvmppc_set_gpr(vcpu, rt, vcpu->arch.dbcr1); break;
210 case SPRN_DBSR: 211 case SPRN_DBSR:
211 kvmppc_set_gpr(vcpu, rt, vcpu->arch.dbsr); break; 212 kvmppc_set_gpr(vcpu, rt, vcpu->arch.dbsr); break;
213 case SPRN_TSR:
214 kvmppc_set_gpr(vcpu, rt, vcpu->arch.tsr); break;
215 case SPRN_TCR:
216 kvmppc_set_gpr(vcpu, rt, vcpu->arch.tcr); break;
212 217
213 case SPRN_IVOR0: 218 case SPRN_IVOR0:
214 kvmppc_set_gpr(vcpu, rt, vcpu->arch.ivor[BOOKE_IRQPRIO_CRITICAL]); 219 kvmppc_set_gpr(vcpu, rt, vcpu->arch.ivor[BOOKE_IRQPRIO_CRITICAL]);
diff --git a/arch/powerpc/kvm/booke_interrupts.S b/arch/powerpc/kvm/booke_interrupts.S
index 42f2fb1f66e..10d8ef602e5 100644
--- a/arch/powerpc/kvm/booke_interrupts.S
+++ b/arch/powerpc/kvm/booke_interrupts.S
@@ -402,19 +402,25 @@ lightweight_exit:
402 /* Save vcpu pointer for the exception handlers. */ 402 /* Save vcpu pointer for the exception handlers. */
403 mtspr SPRN_SPRG_WVCPU, r4 403 mtspr SPRN_SPRG_WVCPU, r4
404 404
405 lwz r5, VCPU_SHARED(r4)
406
405 /* Can't switch the stack pointer until after IVPR is switched, 407 /* Can't switch the stack pointer until after IVPR is switched,
406 * because host interrupt handlers would get confused. */ 408 * because host interrupt handlers would get confused. */
407 lwz r1, VCPU_GPR(r1)(r4) 409 lwz r1, VCPU_GPR(r1)(r4)
408 410
409 /* Host interrupt handlers may have clobbered these guest-readable 411 /*
410 * SPRGs, so we need to reload them here with the guest's values. */ 412 * Host interrupt handlers may have clobbered these
411 lwz r3, VCPU_SPRG4(r4) 413 * guest-readable SPRGs, or the guest kernel may have
414 * written directly to the shared area, so we
415 * need to reload them here with the guest's values.
416 */
417 lwz r3, VCPU_SHARED_SPRG4(r5)
412 mtspr SPRN_SPRG4W, r3 418 mtspr SPRN_SPRG4W, r3
413 lwz r3, VCPU_SPRG5(r4) 419 lwz r3, VCPU_SHARED_SPRG5(r5)
414 mtspr SPRN_SPRG5W, r3 420 mtspr SPRN_SPRG5W, r3
415 lwz r3, VCPU_SPRG6(r4) 421 lwz r3, VCPU_SHARED_SPRG6(r5)
416 mtspr SPRN_SPRG6W, r3 422 mtspr SPRN_SPRG6W, r3
417 lwz r3, VCPU_SPRG7(r4) 423 lwz r3, VCPU_SHARED_SPRG7(r5)
418 mtspr SPRN_SPRG7W, r3 424 mtspr SPRN_SPRG7W, r3
419 425
420#ifdef CONFIG_KVM_EXIT_TIMING 426#ifdef CONFIG_KVM_EXIT_TIMING
diff --git a/arch/powerpc/kvm/e500.c b/arch/powerpc/kvm/e500.c
index 8c0d45a6faf..ddcd896fa2f 100644
--- a/arch/powerpc/kvm/e500.c
+++ b/arch/powerpc/kvm/e500.c
@@ -71,9 +71,6 @@ int kvmppc_core_vcpu_setup(struct kvm_vcpu *vcpu)
71 vcpu->arch.pvr = mfspr(SPRN_PVR); 71 vcpu->arch.pvr = mfspr(SPRN_PVR);
72 vcpu_e500->svr = mfspr(SPRN_SVR); 72 vcpu_e500->svr = mfspr(SPRN_SVR);
73 73
74 /* Since booke kvm only support one core, update all vcpus' PIR to 0 */
75 vcpu->vcpu_id = 0;
76
77 vcpu->arch.cpu_type = KVM_CPU_E500V2; 74 vcpu->arch.cpu_type = KVM_CPU_E500V2;
78 75
79 return 0; 76 return 0;
@@ -118,12 +115,12 @@ void kvmppc_core_get_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs)
118 sregs->u.e.impl.fsl.hid0 = vcpu_e500->hid0; 115 sregs->u.e.impl.fsl.hid0 = vcpu_e500->hid0;
119 sregs->u.e.impl.fsl.mcar = vcpu_e500->mcar; 116 sregs->u.e.impl.fsl.mcar = vcpu_e500->mcar;
120 117
121 sregs->u.e.mas0 = vcpu_e500->mas0; 118 sregs->u.e.mas0 = vcpu->arch.shared->mas0;
122 sregs->u.e.mas1 = vcpu_e500->mas1; 119 sregs->u.e.mas1 = vcpu->arch.shared->mas1;
123 sregs->u.e.mas2 = vcpu_e500->mas2; 120 sregs->u.e.mas2 = vcpu->arch.shared->mas2;
124 sregs->u.e.mas7_3 = ((u64)vcpu_e500->mas7 << 32) | vcpu_e500->mas3; 121 sregs->u.e.mas7_3 = vcpu->arch.shared->mas7_3;
125 sregs->u.e.mas4 = vcpu_e500->mas4; 122 sregs->u.e.mas4 = vcpu->arch.shared->mas4;
126 sregs->u.e.mas6 = vcpu_e500->mas6; 123 sregs->u.e.mas6 = vcpu->arch.shared->mas6;
127 124
128 sregs->u.e.mmucfg = mfspr(SPRN_MMUCFG); 125 sregs->u.e.mmucfg = mfspr(SPRN_MMUCFG);
129 sregs->u.e.tlbcfg[0] = vcpu_e500->tlb0cfg; 126 sregs->u.e.tlbcfg[0] = vcpu_e500->tlb0cfg;
@@ -151,13 +148,12 @@ int kvmppc_core_set_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs)
151 } 148 }
152 149
153 if (sregs->u.e.features & KVM_SREGS_E_ARCH206_MMU) { 150 if (sregs->u.e.features & KVM_SREGS_E_ARCH206_MMU) {
154 vcpu_e500->mas0 = sregs->u.e.mas0; 151 vcpu->arch.shared->mas0 = sregs->u.e.mas0;
155 vcpu_e500->mas1 = sregs->u.e.mas1; 152 vcpu->arch.shared->mas1 = sregs->u.e.mas1;
156 vcpu_e500->mas2 = sregs->u.e.mas2; 153 vcpu->arch.shared->mas2 = sregs->u.e.mas2;
157 vcpu_e500->mas7 = sregs->u.e.mas7_3 >> 32; 154 vcpu->arch.shared->mas7_3 = sregs->u.e.mas7_3;
158 vcpu_e500->mas3 = (u32)sregs->u.e.mas7_3; 155 vcpu->arch.shared->mas4 = sregs->u.e.mas4;
159 vcpu_e500->mas4 = sregs->u.e.mas4; 156 vcpu->arch.shared->mas6 = sregs->u.e.mas6;
160 vcpu_e500->mas6 = sregs->u.e.mas6;
161 } 157 }
162 158
163 if (!(sregs->u.e.features & KVM_SREGS_E_IVOR)) 159 if (!(sregs->u.e.features & KVM_SREGS_E_IVOR))
@@ -233,6 +229,10 @@ static int __init kvmppc_e500_init(void)
233 unsigned long ivor[3]; 229 unsigned long ivor[3];
234 unsigned long max_ivor = 0; 230 unsigned long max_ivor = 0;
235 231
232 r = kvmppc_core_check_processor_compat();
233 if (r)
234 return r;
235
236 r = kvmppc_booke_init(); 236 r = kvmppc_booke_init();
237 if (r) 237 if (r)
238 return r; 238 return r;
diff --git a/arch/powerpc/kvm/e500_emulate.c b/arch/powerpc/kvm/e500_emulate.c
index d48ae396f41..6d0b2bd54fb 100644
--- a/arch/powerpc/kvm/e500_emulate.c
+++ b/arch/powerpc/kvm/e500_emulate.c
@@ -89,19 +89,23 @@ int kvmppc_core_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, int rs)
89 return EMULATE_FAIL; 89 return EMULATE_FAIL;
90 vcpu_e500->pid[2] = spr_val; break; 90 vcpu_e500->pid[2] = spr_val; break;
91 case SPRN_MAS0: 91 case SPRN_MAS0:
92 vcpu_e500->mas0 = spr_val; break; 92 vcpu->arch.shared->mas0 = spr_val; break;
93 case SPRN_MAS1: 93 case SPRN_MAS1:
94 vcpu_e500->mas1 = spr_val; break; 94 vcpu->arch.shared->mas1 = spr_val; break;
95 case SPRN_MAS2: 95 case SPRN_MAS2:
96 vcpu_e500->mas2 = spr_val; break; 96 vcpu->arch.shared->mas2 = spr_val; break;
97 case SPRN_MAS3: 97 case SPRN_MAS3:
98 vcpu_e500->mas3 = spr_val; break; 98 vcpu->arch.shared->mas7_3 &= ~(u64)0xffffffff;
99 vcpu->arch.shared->mas7_3 |= spr_val;
100 break;
99 case SPRN_MAS4: 101 case SPRN_MAS4:
100 vcpu_e500->mas4 = spr_val; break; 102 vcpu->arch.shared->mas4 = spr_val; break;
101 case SPRN_MAS6: 103 case SPRN_MAS6:
102 vcpu_e500->mas6 = spr_val; break; 104 vcpu->arch.shared->mas6 = spr_val; break;
103 case SPRN_MAS7: 105 case SPRN_MAS7:
104 vcpu_e500->mas7 = spr_val; break; 106 vcpu->arch.shared->mas7_3 &= (u64)0xffffffff;
107 vcpu->arch.shared->mas7_3 |= (u64)spr_val << 32;
108 break;
105 case SPRN_L1CSR0: 109 case SPRN_L1CSR0:
106 vcpu_e500->l1csr0 = spr_val; 110 vcpu_e500->l1csr0 = spr_val;
107 vcpu_e500->l1csr0 &= ~(L1CSR0_DCFI | L1CSR0_CLFC); 111 vcpu_e500->l1csr0 &= ~(L1CSR0_DCFI | L1CSR0_CLFC);
@@ -143,6 +147,7 @@ int kvmppc_core_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, int rt)
143{ 147{
144 struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu); 148 struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
145 int emulated = EMULATE_DONE; 149 int emulated = EMULATE_DONE;
150 unsigned long val;
146 151
147 switch (sprn) { 152 switch (sprn) {
148 case SPRN_PID: 153 case SPRN_PID:
@@ -152,20 +157,23 @@ int kvmppc_core_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, int rt)
152 case SPRN_PID2: 157 case SPRN_PID2:
153 kvmppc_set_gpr(vcpu, rt, vcpu_e500->pid[2]); break; 158 kvmppc_set_gpr(vcpu, rt, vcpu_e500->pid[2]); break;
154 case SPRN_MAS0: 159 case SPRN_MAS0:
155 kvmppc_set_gpr(vcpu, rt, vcpu_e500->mas0); break; 160 kvmppc_set_gpr(vcpu, rt, vcpu->arch.shared->mas0); break;
156 case SPRN_MAS1: 161 case SPRN_MAS1:
157 kvmppc_set_gpr(vcpu, rt, vcpu_e500->mas1); break; 162 kvmppc_set_gpr(vcpu, rt, vcpu->arch.shared->mas1); break;
158 case SPRN_MAS2: 163 case SPRN_MAS2:
159 kvmppc_set_gpr(vcpu, rt, vcpu_e500->mas2); break; 164 kvmppc_set_gpr(vcpu, rt, vcpu->arch.shared->mas2); break;
160 case SPRN_MAS3: 165 case SPRN_MAS3:
161 kvmppc_set_gpr(vcpu, rt, vcpu_e500->mas3); break; 166 val = (u32)vcpu->arch.shared->mas7_3;
167 kvmppc_set_gpr(vcpu, rt, val);
168 break;
162 case SPRN_MAS4: 169 case SPRN_MAS4:
163 kvmppc_set_gpr(vcpu, rt, vcpu_e500->mas4); break; 170 kvmppc_set_gpr(vcpu, rt, vcpu->arch.shared->mas4); break;
164 case SPRN_MAS6: 171 case SPRN_MAS6:
165 kvmppc_set_gpr(vcpu, rt, vcpu_e500->mas6); break; 172 kvmppc_set_gpr(vcpu, rt, vcpu->arch.shared->mas6); break;
166 case SPRN_MAS7: 173 case SPRN_MAS7:
167 kvmppc_set_gpr(vcpu, rt, vcpu_e500->mas7); break; 174 val = vcpu->arch.shared->mas7_3 >> 32;
168 175 kvmppc_set_gpr(vcpu, rt, val);
176 break;
169 case SPRN_TLB0CFG: 177 case SPRN_TLB0CFG:
170 kvmppc_set_gpr(vcpu, rt, vcpu_e500->tlb0cfg); break; 178 kvmppc_set_gpr(vcpu, rt, vcpu_e500->tlb0cfg); break;
171 case SPRN_TLB1CFG: 179 case SPRN_TLB1CFG:
diff --git a/arch/powerpc/kvm/e500_tlb.c b/arch/powerpc/kvm/e500_tlb.c
index 13c432ea2fa..6e53e4164de 100644
--- a/arch/powerpc/kvm/e500_tlb.c
+++ b/arch/powerpc/kvm/e500_tlb.c
@@ -12,12 +12,19 @@
12 * published by the Free Software Foundation. 12 * published by the Free Software Foundation.
13 */ 13 */
14 14
15#include <linux/kernel.h>
15#include <linux/types.h> 16#include <linux/types.h>
16#include <linux/slab.h> 17#include <linux/slab.h>
17#include <linux/string.h> 18#include <linux/string.h>
18#include <linux/kvm.h> 19#include <linux/kvm.h>
19#include <linux/kvm_host.h> 20#include <linux/kvm_host.h>
20#include <linux/highmem.h> 21#include <linux/highmem.h>
22#include <linux/log2.h>
23#include <linux/uaccess.h>
24#include <linux/sched.h>
25#include <linux/rwsem.h>
26#include <linux/vmalloc.h>
27#include <linux/hugetlb.h>
21#include <asm/kvm_ppc.h> 28#include <asm/kvm_ppc.h>
22#include <asm/kvm_e500.h> 29#include <asm/kvm_e500.h>
23 30
@@ -26,7 +33,7 @@
26#include "trace.h" 33#include "trace.h"
27#include "timing.h" 34#include "timing.h"
28 35
29#define to_htlb1_esel(esel) (tlb1_entry_num - (esel) - 1) 36#define to_htlb1_esel(esel) (host_tlb_params[1].entries - (esel) - 1)
30 37
31struct id { 38struct id {
32 unsigned long val; 39 unsigned long val;
@@ -63,7 +70,14 @@ static DEFINE_PER_CPU(struct pcpu_id_table, pcpu_sids);
63 * The valid range of shadow ID is [1..255] */ 70 * The valid range of shadow ID is [1..255] */
64static DEFINE_PER_CPU(unsigned long, pcpu_last_used_sid); 71static DEFINE_PER_CPU(unsigned long, pcpu_last_used_sid);
65 72
66static unsigned int tlb1_entry_num; 73static struct kvmppc_e500_tlb_params host_tlb_params[E500_TLB_NUM];
74
75static struct kvm_book3e_206_tlb_entry *get_entry(
76 struct kvmppc_vcpu_e500 *vcpu_e500, int tlbsel, int entry)
77{
78 int offset = vcpu_e500->gtlb_offset[tlbsel];
79 return &vcpu_e500->gtlb_arch[offset + entry];
80}
67 81
68/* 82/*
69 * Allocate a free shadow id and setup a valid sid mapping in given entry. 83 * Allocate a free shadow id and setup a valid sid mapping in given entry.
@@ -116,13 +130,11 @@ static inline int local_sid_lookup(struct id *entry)
116 return -1; 130 return -1;
117} 131}
118 132
119/* Invalidate all id mappings on local core */ 133/* Invalidate all id mappings on local core -- call with preempt disabled */
120static inline void local_sid_destroy_all(void) 134static inline void local_sid_destroy_all(void)
121{ 135{
122 preempt_disable();
123 __get_cpu_var(pcpu_last_used_sid) = 0; 136 __get_cpu_var(pcpu_last_used_sid) = 0;
124 memset(&__get_cpu_var(pcpu_sids), 0, sizeof(__get_cpu_var(pcpu_sids))); 137 memset(&__get_cpu_var(pcpu_sids), 0, sizeof(__get_cpu_var(pcpu_sids)));
125 preempt_enable();
126} 138}
127 139
128static void *kvmppc_e500_id_table_alloc(struct kvmppc_vcpu_e500 *vcpu_e500) 140static void *kvmppc_e500_id_table_alloc(struct kvmppc_vcpu_e500 *vcpu_e500)
@@ -218,34 +230,13 @@ void kvmppc_e500_recalc_shadow_pid(struct kvmppc_vcpu_e500 *vcpu_e500)
218 preempt_enable(); 230 preempt_enable();
219} 231}
220 232
221void kvmppc_dump_tlbs(struct kvm_vcpu *vcpu) 233static inline unsigned int gtlb0_get_next_victim(
222{
223 struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
224 struct tlbe *tlbe;
225 int i, tlbsel;
226
227 printk("| %8s | %8s | %8s | %8s | %8s |\n",
228 "nr", "mas1", "mas2", "mas3", "mas7");
229
230 for (tlbsel = 0; tlbsel < 2; tlbsel++) {
231 printk("Guest TLB%d:\n", tlbsel);
232 for (i = 0; i < vcpu_e500->gtlb_size[tlbsel]; i++) {
233 tlbe = &vcpu_e500->gtlb_arch[tlbsel][i];
234 if (tlbe->mas1 & MAS1_VALID)
235 printk(" G[%d][%3d] | %08X | %08X | %08X | %08X |\n",
236 tlbsel, i, tlbe->mas1, tlbe->mas2,
237 tlbe->mas3, tlbe->mas7);
238 }
239 }
240}
241
242static inline unsigned int tlb0_get_next_victim(
243 struct kvmppc_vcpu_e500 *vcpu_e500) 234 struct kvmppc_vcpu_e500 *vcpu_e500)
244{ 235{
245 unsigned int victim; 236 unsigned int victim;
246 237
247 victim = vcpu_e500->gtlb_nv[0]++; 238 victim = vcpu_e500->gtlb_nv[0]++;
248 if (unlikely(vcpu_e500->gtlb_nv[0] >= KVM_E500_TLB0_WAY_NUM)) 239 if (unlikely(vcpu_e500->gtlb_nv[0] >= vcpu_e500->gtlb_params[0].ways))
249 vcpu_e500->gtlb_nv[0] = 0; 240 vcpu_e500->gtlb_nv[0] = 0;
250 241
251 return victim; 242 return victim;
@@ -254,12 +245,12 @@ static inline unsigned int tlb0_get_next_victim(
254static inline unsigned int tlb1_max_shadow_size(void) 245static inline unsigned int tlb1_max_shadow_size(void)
255{ 246{
256 /* reserve one entry for magic page */ 247 /* reserve one entry for magic page */
257 return tlb1_entry_num - tlbcam_index - 1; 248 return host_tlb_params[1].entries - tlbcam_index - 1;
258} 249}
259 250
260static inline int tlbe_is_writable(struct tlbe *tlbe) 251static inline int tlbe_is_writable(struct kvm_book3e_206_tlb_entry *tlbe)
261{ 252{
262 return tlbe->mas3 & (MAS3_SW|MAS3_UW); 253 return tlbe->mas7_3 & (MAS3_SW|MAS3_UW);
263} 254}
264 255
265static inline u32 e500_shadow_mas3_attrib(u32 mas3, int usermode) 256static inline u32 e500_shadow_mas3_attrib(u32 mas3, int usermode)
@@ -290,40 +281,66 @@ static inline u32 e500_shadow_mas2_attrib(u32 mas2, int usermode)
290/* 281/*
291 * writing shadow tlb entry to host TLB 282 * writing shadow tlb entry to host TLB
292 */ 283 */
293static inline void __write_host_tlbe(struct tlbe *stlbe, uint32_t mas0) 284static inline void __write_host_tlbe(struct kvm_book3e_206_tlb_entry *stlbe,
285 uint32_t mas0)
294{ 286{
295 unsigned long flags; 287 unsigned long flags;
296 288
297 local_irq_save(flags); 289 local_irq_save(flags);
298 mtspr(SPRN_MAS0, mas0); 290 mtspr(SPRN_MAS0, mas0);
299 mtspr(SPRN_MAS1, stlbe->mas1); 291 mtspr(SPRN_MAS1, stlbe->mas1);
300 mtspr(SPRN_MAS2, stlbe->mas2); 292 mtspr(SPRN_MAS2, (unsigned long)stlbe->mas2);
301 mtspr(SPRN_MAS3, stlbe->mas3); 293 mtspr(SPRN_MAS3, (u32)stlbe->mas7_3);
302 mtspr(SPRN_MAS7, stlbe->mas7); 294 mtspr(SPRN_MAS7, (u32)(stlbe->mas7_3 >> 32));
303 asm volatile("isync; tlbwe" : : : "memory"); 295 asm volatile("isync; tlbwe" : : : "memory");
304 local_irq_restore(flags); 296 local_irq_restore(flags);
297
298 trace_kvm_booke206_stlb_write(mas0, stlbe->mas8, stlbe->mas1,
299 stlbe->mas2, stlbe->mas7_3);
300}
301
302/*
303 * Acquire a mas0 with victim hint, as if we just took a TLB miss.
304 *
305 * We don't care about the address we're searching for, other than that it's
306 * in the right set and is not present in the TLB. Using a zero PID and a
307 * userspace address means we don't have to set and then restore MAS5, or
308 * calculate a proper MAS6 value.
309 */
310static u32 get_host_mas0(unsigned long eaddr)
311{
312 unsigned long flags;
313 u32 mas0;
314
315 local_irq_save(flags);
316 mtspr(SPRN_MAS6, 0);
317 asm volatile("tlbsx 0, %0" : : "b" (eaddr & ~CONFIG_PAGE_OFFSET));
318 mas0 = mfspr(SPRN_MAS0);
319 local_irq_restore(flags);
320
321 return mas0;
305} 322}
306 323
324/* sesel is for tlb1 only */
307static inline void write_host_tlbe(struct kvmppc_vcpu_e500 *vcpu_e500, 325static inline void write_host_tlbe(struct kvmppc_vcpu_e500 *vcpu_e500,
308 int tlbsel, int esel, struct tlbe *stlbe) 326 int tlbsel, int sesel, struct kvm_book3e_206_tlb_entry *stlbe)
309{ 327{
328 u32 mas0;
329
310 if (tlbsel == 0) { 330 if (tlbsel == 0) {
311 __write_host_tlbe(stlbe, 331 mas0 = get_host_mas0(stlbe->mas2);
312 MAS0_TLBSEL(0) | 332 __write_host_tlbe(stlbe, mas0);
313 MAS0_ESEL(esel & (KVM_E500_TLB0_WAY_NUM - 1)));
314 } else { 333 } else {
315 __write_host_tlbe(stlbe, 334 __write_host_tlbe(stlbe,
316 MAS0_TLBSEL(1) | 335 MAS0_TLBSEL(1) |
317 MAS0_ESEL(to_htlb1_esel(esel))); 336 MAS0_ESEL(to_htlb1_esel(sesel)));
318 } 337 }
319 trace_kvm_stlb_write(index_of(tlbsel, esel), stlbe->mas1, stlbe->mas2,
320 stlbe->mas3, stlbe->mas7);
321} 338}
322 339
323void kvmppc_map_magic(struct kvm_vcpu *vcpu) 340void kvmppc_map_magic(struct kvm_vcpu *vcpu)
324{ 341{
325 struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu); 342 struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
326 struct tlbe magic; 343 struct kvm_book3e_206_tlb_entry magic;
327 ulong shared_page = ((ulong)vcpu->arch.shared) & PAGE_MASK; 344 ulong shared_page = ((ulong)vcpu->arch.shared) & PAGE_MASK;
328 unsigned int stid; 345 unsigned int stid;
329 pfn_t pfn; 346 pfn_t pfn;
@@ -337,9 +354,9 @@ void kvmppc_map_magic(struct kvm_vcpu *vcpu)
337 magic.mas1 = MAS1_VALID | MAS1_TS | MAS1_TID(stid) | 354 magic.mas1 = MAS1_VALID | MAS1_TS | MAS1_TID(stid) |
338 MAS1_TSIZE(BOOK3E_PAGESZ_4K); 355 MAS1_TSIZE(BOOK3E_PAGESZ_4K);
339 magic.mas2 = vcpu->arch.magic_page_ea | MAS2_M; 356 magic.mas2 = vcpu->arch.magic_page_ea | MAS2_M;
340 magic.mas3 = (pfn << PAGE_SHIFT) | 357 magic.mas7_3 = ((u64)pfn << PAGE_SHIFT) |
341 MAS3_SW | MAS3_SR | MAS3_UW | MAS3_UR; 358 MAS3_SW | MAS3_SR | MAS3_UW | MAS3_UR;
342 magic.mas7 = pfn >> (32 - PAGE_SHIFT); 359 magic.mas8 = 0;
343 360
344 __write_host_tlbe(&magic, MAS0_TLBSEL(1) | MAS0_ESEL(tlbcam_index)); 361 __write_host_tlbe(&magic, MAS0_TLBSEL(1) | MAS0_ESEL(tlbcam_index));
345 preempt_enable(); 362 preempt_enable();
@@ -357,10 +374,11 @@ void kvmppc_e500_tlb_put(struct kvm_vcpu *vcpu)
357{ 374{
358} 375}
359 376
360static void kvmppc_e500_stlbe_invalidate(struct kvmppc_vcpu_e500 *vcpu_e500, 377static void inval_gtlbe_on_host(struct kvmppc_vcpu_e500 *vcpu_e500,
361 int tlbsel, int esel) 378 int tlbsel, int esel)
362{ 379{
363 struct tlbe *gtlbe = &vcpu_e500->gtlb_arch[tlbsel][esel]; 380 struct kvm_book3e_206_tlb_entry *gtlbe =
381 get_entry(vcpu_e500, tlbsel, esel);
364 struct vcpu_id_table *idt = vcpu_e500->idt; 382 struct vcpu_id_table *idt = vcpu_e500->idt;
365 unsigned int pr, tid, ts, pid; 383 unsigned int pr, tid, ts, pid;
366 u32 val, eaddr; 384 u32 val, eaddr;
@@ -414,25 +432,57 @@ static void kvmppc_e500_stlbe_invalidate(struct kvmppc_vcpu_e500 *vcpu_e500,
414 preempt_enable(); 432 preempt_enable();
415} 433}
416 434
435static int tlb0_set_base(gva_t addr, int sets, int ways)
436{
437 int set_base;
438
439 set_base = (addr >> PAGE_SHIFT) & (sets - 1);
440 set_base *= ways;
441
442 return set_base;
443}
444
445static int gtlb0_set_base(struct kvmppc_vcpu_e500 *vcpu_e500, gva_t addr)
446{
447 return tlb0_set_base(addr, vcpu_e500->gtlb_params[0].sets,
448 vcpu_e500->gtlb_params[0].ways);
449}
450
451static unsigned int get_tlb_esel(struct kvm_vcpu *vcpu, int tlbsel)
452{
453 struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
454 int esel = get_tlb_esel_bit(vcpu);
455
456 if (tlbsel == 0) {
457 esel &= vcpu_e500->gtlb_params[0].ways - 1;
458 esel += gtlb0_set_base(vcpu_e500, vcpu->arch.shared->mas2);
459 } else {
460 esel &= vcpu_e500->gtlb_params[tlbsel].entries - 1;
461 }
462
463 return esel;
464}
465
417/* Search the guest TLB for a matching entry. */ 466/* Search the guest TLB for a matching entry. */
418static int kvmppc_e500_tlb_index(struct kvmppc_vcpu_e500 *vcpu_e500, 467static int kvmppc_e500_tlb_index(struct kvmppc_vcpu_e500 *vcpu_e500,
419 gva_t eaddr, int tlbsel, unsigned int pid, int as) 468 gva_t eaddr, int tlbsel, unsigned int pid, int as)
420{ 469{
421 int size = vcpu_e500->gtlb_size[tlbsel]; 470 int size = vcpu_e500->gtlb_params[tlbsel].entries;
422 int set_base; 471 unsigned int set_base, offset;
423 int i; 472 int i;
424 473
425 if (tlbsel == 0) { 474 if (tlbsel == 0) {
426 int mask = size / KVM_E500_TLB0_WAY_NUM - 1; 475 set_base = gtlb0_set_base(vcpu_e500, eaddr);
427 set_base = (eaddr >> PAGE_SHIFT) & mask; 476 size = vcpu_e500->gtlb_params[0].ways;
428 set_base *= KVM_E500_TLB0_WAY_NUM;
429 size = KVM_E500_TLB0_WAY_NUM;
430 } else { 477 } else {
431 set_base = 0; 478 set_base = 0;
432 } 479 }
433 480
481 offset = vcpu_e500->gtlb_offset[tlbsel];
482
434 for (i = 0; i < size; i++) { 483 for (i = 0; i < size; i++) {
435 struct tlbe *tlbe = &vcpu_e500->gtlb_arch[tlbsel][set_base + i]; 484 struct kvm_book3e_206_tlb_entry *tlbe =
485 &vcpu_e500->gtlb_arch[offset + set_base + i];
436 unsigned int tid; 486 unsigned int tid;
437 487
438 if (eaddr < get_tlb_eaddr(tlbe)) 488 if (eaddr < get_tlb_eaddr(tlbe))
@@ -457,27 +507,55 @@ static int kvmppc_e500_tlb_index(struct kvmppc_vcpu_e500 *vcpu_e500,
457 return -1; 507 return -1;
458} 508}
459 509
460static inline void kvmppc_e500_priv_setup(struct tlbe_priv *priv, 510static inline void kvmppc_e500_ref_setup(struct tlbe_ref *ref,
461 struct tlbe *gtlbe, 511 struct kvm_book3e_206_tlb_entry *gtlbe,
462 pfn_t pfn) 512 pfn_t pfn)
463{ 513{
464 priv->pfn = pfn; 514 ref->pfn = pfn;
465 priv->flags = E500_TLB_VALID; 515 ref->flags = E500_TLB_VALID;
466 516
467 if (tlbe_is_writable(gtlbe)) 517 if (tlbe_is_writable(gtlbe))
468 priv->flags |= E500_TLB_DIRTY; 518 ref->flags |= E500_TLB_DIRTY;
469} 519}
470 520
471static inline void kvmppc_e500_priv_release(struct tlbe_priv *priv) 521static inline void kvmppc_e500_ref_release(struct tlbe_ref *ref)
472{ 522{
473 if (priv->flags & E500_TLB_VALID) { 523 if (ref->flags & E500_TLB_VALID) {
474 if (priv->flags & E500_TLB_DIRTY) 524 if (ref->flags & E500_TLB_DIRTY)
475 kvm_release_pfn_dirty(priv->pfn); 525 kvm_release_pfn_dirty(ref->pfn);
476 else 526 else
477 kvm_release_pfn_clean(priv->pfn); 527 kvm_release_pfn_clean(ref->pfn);
528
529 ref->flags = 0;
530 }
531}
532
533static void clear_tlb_privs(struct kvmppc_vcpu_e500 *vcpu_e500)
534{
535 int tlbsel = 0;
536 int i;
537
538 for (i = 0; i < vcpu_e500->gtlb_params[tlbsel].entries; i++) {
539 struct tlbe_ref *ref =
540 &vcpu_e500->gtlb_priv[tlbsel][i].ref;
541 kvmppc_e500_ref_release(ref);
542 }
543}
544
545static void clear_tlb_refs(struct kvmppc_vcpu_e500 *vcpu_e500)
546{
547 int stlbsel = 1;
548 int i;
549
550 kvmppc_e500_id_table_reset_all(vcpu_e500);
478 551
479 priv->flags = 0; 552 for (i = 0; i < host_tlb_params[stlbsel].entries; i++) {
553 struct tlbe_ref *ref =
554 &vcpu_e500->tlb_refs[stlbsel][i];
555 kvmppc_e500_ref_release(ref);
480 } 556 }
557
558 clear_tlb_privs(vcpu_e500);
481} 559}
482 560
483static inline void kvmppc_e500_deliver_tlb_miss(struct kvm_vcpu *vcpu, 561static inline void kvmppc_e500_deliver_tlb_miss(struct kvm_vcpu *vcpu,
@@ -488,59 +566,54 @@ static inline void kvmppc_e500_deliver_tlb_miss(struct kvm_vcpu *vcpu,
488 int tlbsel; 566 int tlbsel;
489 567
490 /* since we only have two TLBs, only lower bit is used. */ 568 /* since we only have two TLBs, only lower bit is used. */
491 tlbsel = (vcpu_e500->mas4 >> 28) & 0x1; 569 tlbsel = (vcpu->arch.shared->mas4 >> 28) & 0x1;
492 victim = (tlbsel == 0) ? tlb0_get_next_victim(vcpu_e500) : 0; 570 victim = (tlbsel == 0) ? gtlb0_get_next_victim(vcpu_e500) : 0;
493 pidsel = (vcpu_e500->mas4 >> 16) & 0xf; 571 pidsel = (vcpu->arch.shared->mas4 >> 16) & 0xf;
494 tsized = (vcpu_e500->mas4 >> 7) & 0x1f; 572 tsized = (vcpu->arch.shared->mas4 >> 7) & 0x1f;
495 573
496 vcpu_e500->mas0 = MAS0_TLBSEL(tlbsel) | MAS0_ESEL(victim) 574 vcpu->arch.shared->mas0 = MAS0_TLBSEL(tlbsel) | MAS0_ESEL(victim)
497 | MAS0_NV(vcpu_e500->gtlb_nv[tlbsel]); 575 | MAS0_NV(vcpu_e500->gtlb_nv[tlbsel]);
498 vcpu_e500->mas1 = MAS1_VALID | (as ? MAS1_TS : 0) 576 vcpu->arch.shared->mas1 = MAS1_VALID | (as ? MAS1_TS : 0)
499 | MAS1_TID(vcpu_e500->pid[pidsel]) 577 | MAS1_TID(vcpu_e500->pid[pidsel])
500 | MAS1_TSIZE(tsized); 578 | MAS1_TSIZE(tsized);
501 vcpu_e500->mas2 = (eaddr & MAS2_EPN) 579 vcpu->arch.shared->mas2 = (eaddr & MAS2_EPN)
502 | (vcpu_e500->mas4 & MAS2_ATTRIB_MASK); 580 | (vcpu->arch.shared->mas4 & MAS2_ATTRIB_MASK);
503 vcpu_e500->mas3 &= MAS3_U0 | MAS3_U1 | MAS3_U2 | MAS3_U3; 581 vcpu->arch.shared->mas7_3 &= MAS3_U0 | MAS3_U1 | MAS3_U2 | MAS3_U3;
504 vcpu_e500->mas6 = (vcpu_e500->mas6 & MAS6_SPID1) 582 vcpu->arch.shared->mas6 = (vcpu->arch.shared->mas6 & MAS6_SPID1)
505 | (get_cur_pid(vcpu) << 16) 583 | (get_cur_pid(vcpu) << 16)
506 | (as ? MAS6_SAS : 0); 584 | (as ? MAS6_SAS : 0);
507 vcpu_e500->mas7 = 0;
508} 585}
509 586
510static inline void kvmppc_e500_setup_stlbe(struct kvmppc_vcpu_e500 *vcpu_e500, 587/* TID must be supplied by the caller */
511 struct tlbe *gtlbe, int tsize, 588static inline void kvmppc_e500_setup_stlbe(
512 struct tlbe_priv *priv, 589 struct kvmppc_vcpu_e500 *vcpu_e500,
513 u64 gvaddr, struct tlbe *stlbe) 590 struct kvm_book3e_206_tlb_entry *gtlbe,
591 int tsize, struct tlbe_ref *ref, u64 gvaddr,
592 struct kvm_book3e_206_tlb_entry *stlbe)
514{ 593{
515 pfn_t pfn = priv->pfn; 594 pfn_t pfn = ref->pfn;
516 unsigned int stid;
517 595
518 stid = kvmppc_e500_get_sid(vcpu_e500, get_tlb_ts(gtlbe), 596 BUG_ON(!(ref->flags & E500_TLB_VALID));
519 get_tlb_tid(gtlbe),
520 get_cur_pr(&vcpu_e500->vcpu), 0);
521 597
522 /* Force TS=1 IPROT=0 for all guest mappings. */ 598 /* Force TS=1 IPROT=0 for all guest mappings. */
523 stlbe->mas1 = MAS1_TSIZE(tsize) 599 stlbe->mas1 = MAS1_TSIZE(tsize) | MAS1_TS | MAS1_VALID;
524 | MAS1_TID(stid) | MAS1_TS | MAS1_VALID;
525 stlbe->mas2 = (gvaddr & MAS2_EPN) 600 stlbe->mas2 = (gvaddr & MAS2_EPN)
526 | e500_shadow_mas2_attrib(gtlbe->mas2, 601 | e500_shadow_mas2_attrib(gtlbe->mas2,
527 vcpu_e500->vcpu.arch.shared->msr & MSR_PR); 602 vcpu_e500->vcpu.arch.shared->msr & MSR_PR);
528 stlbe->mas3 = ((pfn << PAGE_SHIFT) & MAS3_RPN) 603 stlbe->mas7_3 = ((u64)pfn << PAGE_SHIFT)
529 | e500_shadow_mas3_attrib(gtlbe->mas3, 604 | e500_shadow_mas3_attrib(gtlbe->mas7_3,
530 vcpu_e500->vcpu.arch.shared->msr & MSR_PR); 605 vcpu_e500->vcpu.arch.shared->msr & MSR_PR);
531 stlbe->mas7 = (pfn >> (32 - PAGE_SHIFT)) & MAS7_RPN;
532} 606}
533 607
534
535static inline void kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500, 608static inline void kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,
536 u64 gvaddr, gfn_t gfn, struct tlbe *gtlbe, int tlbsel, int esel, 609 u64 gvaddr, gfn_t gfn, struct kvm_book3e_206_tlb_entry *gtlbe,
537 struct tlbe *stlbe) 610 int tlbsel, struct kvm_book3e_206_tlb_entry *stlbe,
611 struct tlbe_ref *ref)
538{ 612{
539 struct kvm_memory_slot *slot; 613 struct kvm_memory_slot *slot;
540 unsigned long pfn, hva; 614 unsigned long pfn, hva;
541 int pfnmap = 0; 615 int pfnmap = 0;
542 int tsize = BOOK3E_PAGESZ_4K; 616 int tsize = BOOK3E_PAGESZ_4K;
543 struct tlbe_priv *priv;
544 617
545 /* 618 /*
546 * Translate guest physical to true physical, acquiring 619 * Translate guest physical to true physical, acquiring
@@ -621,12 +694,31 @@ static inline void kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,
621 pfn &= ~(tsize_pages - 1); 694 pfn &= ~(tsize_pages - 1);
622 break; 695 break;
623 } 696 }
697 } else if (vma && hva >= vma->vm_start &&
698 (vma->vm_flags & VM_HUGETLB)) {
699 unsigned long psize = vma_kernel_pagesize(vma);
700
701 tsize = (gtlbe->mas1 & MAS1_TSIZE_MASK) >>
702 MAS1_TSIZE_SHIFT;
703
704 /*
705 * Take the largest page size that satisfies both host
706 * and guest mapping
707 */
708 tsize = min(__ilog2(psize) - 10, tsize);
709
710 /*
711 * e500 doesn't implement the lowest tsize bit,
712 * or 1K pages.
713 */
714 tsize = max(BOOK3E_PAGESZ_4K, tsize & ~1);
624 } 715 }
625 716
626 up_read(&current->mm->mmap_sem); 717 up_read(&current->mm->mmap_sem);
627 } 718 }
628 719
629 if (likely(!pfnmap)) { 720 if (likely(!pfnmap)) {
721 unsigned long tsize_pages = 1 << (tsize + 10 - PAGE_SHIFT);
630 pfn = gfn_to_pfn_memslot(vcpu_e500->vcpu.kvm, slot, gfn); 722 pfn = gfn_to_pfn_memslot(vcpu_e500->vcpu.kvm, slot, gfn);
631 if (is_error_pfn(pfn)) { 723 if (is_error_pfn(pfn)) {
632 printk(KERN_ERR "Couldn't get real page for gfn %lx!\n", 724 printk(KERN_ERR "Couldn't get real page for gfn %lx!\n",
@@ -634,45 +726,52 @@ static inline void kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,
634 kvm_release_pfn_clean(pfn); 726 kvm_release_pfn_clean(pfn);
635 return; 727 return;
636 } 728 }
729
730 /* Align guest and physical address to page map boundaries */
731 pfn &= ~(tsize_pages - 1);
732 gvaddr &= ~((tsize_pages << PAGE_SHIFT) - 1);
637 } 733 }
638 734
639 /* Drop old priv and setup new one. */ 735 /* Drop old ref and setup new one. */
640 priv = &vcpu_e500->gtlb_priv[tlbsel][esel]; 736 kvmppc_e500_ref_release(ref);
641 kvmppc_e500_priv_release(priv); 737 kvmppc_e500_ref_setup(ref, gtlbe, pfn);
642 kvmppc_e500_priv_setup(priv, gtlbe, pfn);
643 738
644 kvmppc_e500_setup_stlbe(vcpu_e500, gtlbe, tsize, priv, gvaddr, stlbe); 739 kvmppc_e500_setup_stlbe(vcpu_e500, gtlbe, tsize, ref, gvaddr, stlbe);
645} 740}
646 741
647/* XXX only map the one-one case, for now use TLB0 */ 742/* XXX only map the one-one case, for now use TLB0 */
648static int kvmppc_e500_tlb0_map(struct kvmppc_vcpu_e500 *vcpu_e500, 743static void kvmppc_e500_tlb0_map(struct kvmppc_vcpu_e500 *vcpu_e500,
649 int esel, struct tlbe *stlbe) 744 int esel,
745 struct kvm_book3e_206_tlb_entry *stlbe)
650{ 746{
651 struct tlbe *gtlbe; 747 struct kvm_book3e_206_tlb_entry *gtlbe;
748 struct tlbe_ref *ref;
652 749
653 gtlbe = &vcpu_e500->gtlb_arch[0][esel]; 750 gtlbe = get_entry(vcpu_e500, 0, esel);
751 ref = &vcpu_e500->gtlb_priv[0][esel].ref;
654 752
655 kvmppc_e500_shadow_map(vcpu_e500, get_tlb_eaddr(gtlbe), 753 kvmppc_e500_shadow_map(vcpu_e500, get_tlb_eaddr(gtlbe),
656 get_tlb_raddr(gtlbe) >> PAGE_SHIFT, 754 get_tlb_raddr(gtlbe) >> PAGE_SHIFT,
657 gtlbe, 0, esel, stlbe); 755 gtlbe, 0, stlbe, ref);
658
659 return esel;
660} 756}
661 757
662/* Caller must ensure that the specified guest TLB entry is safe to insert into 758/* Caller must ensure that the specified guest TLB entry is safe to insert into
663 * the shadow TLB. */ 759 * the shadow TLB. */
664/* XXX for both one-one and one-to-many , for now use TLB1 */ 760/* XXX for both one-one and one-to-many , for now use TLB1 */
665static int kvmppc_e500_tlb1_map(struct kvmppc_vcpu_e500 *vcpu_e500, 761static int kvmppc_e500_tlb1_map(struct kvmppc_vcpu_e500 *vcpu_e500,
666 u64 gvaddr, gfn_t gfn, struct tlbe *gtlbe, struct tlbe *stlbe) 762 u64 gvaddr, gfn_t gfn, struct kvm_book3e_206_tlb_entry *gtlbe,
763 struct kvm_book3e_206_tlb_entry *stlbe)
667{ 764{
765 struct tlbe_ref *ref;
668 unsigned int victim; 766 unsigned int victim;
669 767
670 victim = vcpu_e500->gtlb_nv[1]++; 768 victim = vcpu_e500->host_tlb1_nv++;
671 769
672 if (unlikely(vcpu_e500->gtlb_nv[1] >= tlb1_max_shadow_size())) 770 if (unlikely(vcpu_e500->host_tlb1_nv >= tlb1_max_shadow_size()))
673 vcpu_e500->gtlb_nv[1] = 0; 771 vcpu_e500->host_tlb1_nv = 0;
674 772
675 kvmppc_e500_shadow_map(vcpu_e500, gvaddr, gfn, gtlbe, 1, victim, stlbe); 773 ref = &vcpu_e500->tlb_refs[1][victim];
774 kvmppc_e500_shadow_map(vcpu_e500, gvaddr, gfn, gtlbe, 1, stlbe, ref);
676 775
677 return victim; 776 return victim;
678} 777}
@@ -689,7 +788,8 @@ static inline int kvmppc_e500_gtlbe_invalidate(
689 struct kvmppc_vcpu_e500 *vcpu_e500, 788 struct kvmppc_vcpu_e500 *vcpu_e500,
690 int tlbsel, int esel) 789 int tlbsel, int esel)
691{ 790{
692 struct tlbe *gtlbe = &vcpu_e500->gtlb_arch[tlbsel][esel]; 791 struct kvm_book3e_206_tlb_entry *gtlbe =
792 get_entry(vcpu_e500, tlbsel, esel);
693 793
694 if (unlikely(get_tlb_iprot(gtlbe))) 794 if (unlikely(get_tlb_iprot(gtlbe)))
695 return -1; 795 return -1;
@@ -704,10 +804,10 @@ int kvmppc_e500_emul_mt_mmucsr0(struct kvmppc_vcpu_e500 *vcpu_e500, ulong value)
704 int esel; 804 int esel;
705 805
706 if (value & MMUCSR0_TLB0FI) 806 if (value & MMUCSR0_TLB0FI)
707 for (esel = 0; esel < vcpu_e500->gtlb_size[0]; esel++) 807 for (esel = 0; esel < vcpu_e500->gtlb_params[0].entries; esel++)
708 kvmppc_e500_gtlbe_invalidate(vcpu_e500, 0, esel); 808 kvmppc_e500_gtlbe_invalidate(vcpu_e500, 0, esel);
709 if (value & MMUCSR0_TLB1FI) 809 if (value & MMUCSR0_TLB1FI)
710 for (esel = 0; esel < vcpu_e500->gtlb_size[1]; esel++) 810 for (esel = 0; esel < vcpu_e500->gtlb_params[1].entries; esel++)
711 kvmppc_e500_gtlbe_invalidate(vcpu_e500, 1, esel); 811 kvmppc_e500_gtlbe_invalidate(vcpu_e500, 1, esel);
712 812
713 /* Invalidate all vcpu id mappings */ 813 /* Invalidate all vcpu id mappings */
@@ -732,7 +832,8 @@ int kvmppc_e500_emul_tlbivax(struct kvm_vcpu *vcpu, int ra, int rb)
732 832
733 if (ia) { 833 if (ia) {
734 /* invalidate all entries */ 834 /* invalidate all entries */
735 for (esel = 0; esel < vcpu_e500->gtlb_size[tlbsel]; esel++) 835 for (esel = 0; esel < vcpu_e500->gtlb_params[tlbsel].entries;
836 esel++)
736 kvmppc_e500_gtlbe_invalidate(vcpu_e500, tlbsel, esel); 837 kvmppc_e500_gtlbe_invalidate(vcpu_e500, tlbsel, esel);
737 } else { 838 } else {
738 ea &= 0xfffff000; 839 ea &= 0xfffff000;
@@ -752,18 +853,17 @@ int kvmppc_e500_emul_tlbre(struct kvm_vcpu *vcpu)
752{ 853{
753 struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu); 854 struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
754 int tlbsel, esel; 855 int tlbsel, esel;
755 struct tlbe *gtlbe; 856 struct kvm_book3e_206_tlb_entry *gtlbe;
756 857
757 tlbsel = get_tlb_tlbsel(vcpu_e500); 858 tlbsel = get_tlb_tlbsel(vcpu);
758 esel = get_tlb_esel(vcpu_e500, tlbsel); 859 esel = get_tlb_esel(vcpu, tlbsel);
759 860
760 gtlbe = &vcpu_e500->gtlb_arch[tlbsel][esel]; 861 gtlbe = get_entry(vcpu_e500, tlbsel, esel);
761 vcpu_e500->mas0 &= ~MAS0_NV(~0); 862 vcpu->arch.shared->mas0 &= ~MAS0_NV(~0);
762 vcpu_e500->mas0 |= MAS0_NV(vcpu_e500->gtlb_nv[tlbsel]); 863 vcpu->arch.shared->mas0 |= MAS0_NV(vcpu_e500->gtlb_nv[tlbsel]);
763 vcpu_e500->mas1 = gtlbe->mas1; 864 vcpu->arch.shared->mas1 = gtlbe->mas1;
764 vcpu_e500->mas2 = gtlbe->mas2; 865 vcpu->arch.shared->mas2 = gtlbe->mas2;
765 vcpu_e500->mas3 = gtlbe->mas3; 866 vcpu->arch.shared->mas7_3 = gtlbe->mas7_3;
766 vcpu_e500->mas7 = gtlbe->mas7;
767 867
768 return EMULATE_DONE; 868 return EMULATE_DONE;
769} 869}
@@ -771,10 +871,10 @@ int kvmppc_e500_emul_tlbre(struct kvm_vcpu *vcpu)
771int kvmppc_e500_emul_tlbsx(struct kvm_vcpu *vcpu, int rb) 871int kvmppc_e500_emul_tlbsx(struct kvm_vcpu *vcpu, int rb)
772{ 872{
773 struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu); 873 struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
774 int as = !!get_cur_sas(vcpu_e500); 874 int as = !!get_cur_sas(vcpu);
775 unsigned int pid = get_cur_spid(vcpu_e500); 875 unsigned int pid = get_cur_spid(vcpu);
776 int esel, tlbsel; 876 int esel, tlbsel;
777 struct tlbe *gtlbe = NULL; 877 struct kvm_book3e_206_tlb_entry *gtlbe = NULL;
778 gva_t ea; 878 gva_t ea;
779 879
780 ea = kvmppc_get_gpr(vcpu, rb); 880 ea = kvmppc_get_gpr(vcpu, rb);
@@ -782,70 +882,90 @@ int kvmppc_e500_emul_tlbsx(struct kvm_vcpu *vcpu, int rb)
782 for (tlbsel = 0; tlbsel < 2; tlbsel++) { 882 for (tlbsel = 0; tlbsel < 2; tlbsel++) {
783 esel = kvmppc_e500_tlb_index(vcpu_e500, ea, tlbsel, pid, as); 883 esel = kvmppc_e500_tlb_index(vcpu_e500, ea, tlbsel, pid, as);
784 if (esel >= 0) { 884 if (esel >= 0) {
785 gtlbe = &vcpu_e500->gtlb_arch[tlbsel][esel]; 885 gtlbe = get_entry(vcpu_e500, tlbsel, esel);
786 break; 886 break;
787 } 887 }
788 } 888 }
789 889
790 if (gtlbe) { 890 if (gtlbe) {
791 vcpu_e500->mas0 = MAS0_TLBSEL(tlbsel) | MAS0_ESEL(esel) 891 esel &= vcpu_e500->gtlb_params[tlbsel].ways - 1;
892
893 vcpu->arch.shared->mas0 = MAS0_TLBSEL(tlbsel) | MAS0_ESEL(esel)
792 | MAS0_NV(vcpu_e500->gtlb_nv[tlbsel]); 894 | MAS0_NV(vcpu_e500->gtlb_nv[tlbsel]);
793 vcpu_e500->mas1 = gtlbe->mas1; 895 vcpu->arch.shared->mas1 = gtlbe->mas1;
794 vcpu_e500->mas2 = gtlbe->mas2; 896 vcpu->arch.shared->mas2 = gtlbe->mas2;
795 vcpu_e500->mas3 = gtlbe->mas3; 897 vcpu->arch.shared->mas7_3 = gtlbe->mas7_3;
796 vcpu_e500->mas7 = gtlbe->mas7;
797 } else { 898 } else {
798 int victim; 899 int victim;
799 900
800 /* since we only have two TLBs, only lower bit is used. */ 901 /* since we only have two TLBs, only lower bit is used. */
801 tlbsel = vcpu_e500->mas4 >> 28 & 0x1; 902 tlbsel = vcpu->arch.shared->mas4 >> 28 & 0x1;
802 victim = (tlbsel == 0) ? tlb0_get_next_victim(vcpu_e500) : 0; 903 victim = (tlbsel == 0) ? gtlb0_get_next_victim(vcpu_e500) : 0;
803 904
804 vcpu_e500->mas0 = MAS0_TLBSEL(tlbsel) | MAS0_ESEL(victim) 905 vcpu->arch.shared->mas0 = MAS0_TLBSEL(tlbsel)
906 | MAS0_ESEL(victim)
805 | MAS0_NV(vcpu_e500->gtlb_nv[tlbsel]); 907 | MAS0_NV(vcpu_e500->gtlb_nv[tlbsel]);
806 vcpu_e500->mas1 = (vcpu_e500->mas6 & MAS6_SPID0) 908 vcpu->arch.shared->mas1 =
807 | (vcpu_e500->mas6 & (MAS6_SAS ? MAS1_TS : 0)) 909 (vcpu->arch.shared->mas6 & MAS6_SPID0)
808 | (vcpu_e500->mas4 & MAS4_TSIZED(~0)); 910 | (vcpu->arch.shared->mas6 & (MAS6_SAS ? MAS1_TS : 0))
809 vcpu_e500->mas2 &= MAS2_EPN; 911 | (vcpu->arch.shared->mas4 & MAS4_TSIZED(~0));
810 vcpu_e500->mas2 |= vcpu_e500->mas4 & MAS2_ATTRIB_MASK; 912 vcpu->arch.shared->mas2 &= MAS2_EPN;
811 vcpu_e500->mas3 &= MAS3_U0 | MAS3_U1 | MAS3_U2 | MAS3_U3; 913 vcpu->arch.shared->mas2 |= vcpu->arch.shared->mas4 &
812 vcpu_e500->mas7 = 0; 914 MAS2_ATTRIB_MASK;
915 vcpu->arch.shared->mas7_3 &= MAS3_U0 | MAS3_U1 |
916 MAS3_U2 | MAS3_U3;
813 } 917 }
814 918
815 kvmppc_set_exit_type(vcpu, EMULATED_TLBSX_EXITS); 919 kvmppc_set_exit_type(vcpu, EMULATED_TLBSX_EXITS);
816 return EMULATE_DONE; 920 return EMULATE_DONE;
817} 921}
818 922
923/* sesel is for tlb1 only */
924static void write_stlbe(struct kvmppc_vcpu_e500 *vcpu_e500,
925 struct kvm_book3e_206_tlb_entry *gtlbe,
926 struct kvm_book3e_206_tlb_entry *stlbe,
927 int stlbsel, int sesel)
928{
929 int stid;
930
931 preempt_disable();
932 stid = kvmppc_e500_get_sid(vcpu_e500, get_tlb_ts(gtlbe),
933 get_tlb_tid(gtlbe),
934 get_cur_pr(&vcpu_e500->vcpu), 0);
935
936 stlbe->mas1 |= MAS1_TID(stid);
937 write_host_tlbe(vcpu_e500, stlbsel, sesel, stlbe);
938 preempt_enable();
939}
940
819int kvmppc_e500_emul_tlbwe(struct kvm_vcpu *vcpu) 941int kvmppc_e500_emul_tlbwe(struct kvm_vcpu *vcpu)
820{ 942{
821 struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu); 943 struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
822 struct tlbe *gtlbe; 944 struct kvm_book3e_206_tlb_entry *gtlbe;
823 int tlbsel, esel; 945 int tlbsel, esel;
824 946
825 tlbsel = get_tlb_tlbsel(vcpu_e500); 947 tlbsel = get_tlb_tlbsel(vcpu);
826 esel = get_tlb_esel(vcpu_e500, tlbsel); 948 esel = get_tlb_esel(vcpu, tlbsel);
827 949
828 gtlbe = &vcpu_e500->gtlb_arch[tlbsel][esel]; 950 gtlbe = get_entry(vcpu_e500, tlbsel, esel);
829 951
830 if (get_tlb_v(gtlbe)) 952 if (get_tlb_v(gtlbe))
831 kvmppc_e500_stlbe_invalidate(vcpu_e500, tlbsel, esel); 953 inval_gtlbe_on_host(vcpu_e500, tlbsel, esel);
832 954
833 gtlbe->mas1 = vcpu_e500->mas1; 955 gtlbe->mas1 = vcpu->arch.shared->mas1;
834 gtlbe->mas2 = vcpu_e500->mas2; 956 gtlbe->mas2 = vcpu->arch.shared->mas2;
835 gtlbe->mas3 = vcpu_e500->mas3; 957 gtlbe->mas7_3 = vcpu->arch.shared->mas7_3;
836 gtlbe->mas7 = vcpu_e500->mas7;
837 958
838 trace_kvm_gtlb_write(vcpu_e500->mas0, gtlbe->mas1, gtlbe->mas2, 959 trace_kvm_booke206_gtlb_write(vcpu->arch.shared->mas0, gtlbe->mas1,
839 gtlbe->mas3, gtlbe->mas7); 960 gtlbe->mas2, gtlbe->mas7_3);
840 961
841 /* Invalidate shadow mappings for the about-to-be-clobbered TLBE. */ 962 /* Invalidate shadow mappings for the about-to-be-clobbered TLBE. */
842 if (tlbe_is_host_safe(vcpu, gtlbe)) { 963 if (tlbe_is_host_safe(vcpu, gtlbe)) {
843 struct tlbe stlbe; 964 struct kvm_book3e_206_tlb_entry stlbe;
844 int stlbsel, sesel; 965 int stlbsel, sesel;
845 u64 eaddr; 966 u64 eaddr;
846 u64 raddr; 967 u64 raddr;
847 968
848 preempt_disable();
849 switch (tlbsel) { 969 switch (tlbsel) {
850 case 0: 970 case 0:
851 /* TLB0 */ 971 /* TLB0 */
@@ -853,7 +973,8 @@ int kvmppc_e500_emul_tlbwe(struct kvm_vcpu *vcpu)
853 gtlbe->mas1 |= MAS1_TSIZE(BOOK3E_PAGESZ_4K); 973 gtlbe->mas1 |= MAS1_TSIZE(BOOK3E_PAGESZ_4K);
854 974
855 stlbsel = 0; 975 stlbsel = 0;
856 sesel = kvmppc_e500_tlb0_map(vcpu_e500, esel, &stlbe); 976 kvmppc_e500_tlb0_map(vcpu_e500, esel, &stlbe);
977 sesel = 0; /* unused */
857 978
858 break; 979 break;
859 980
@@ -874,8 +995,8 @@ int kvmppc_e500_emul_tlbwe(struct kvm_vcpu *vcpu)
874 default: 995 default:
875 BUG(); 996 BUG();
876 } 997 }
877 write_host_tlbe(vcpu_e500, stlbsel, sesel, &stlbe); 998
878 preempt_enable(); 999 write_stlbe(vcpu_e500, gtlbe, &stlbe, stlbsel, sesel);
879 } 1000 }
880 1001
881 kvmppc_set_exit_type(vcpu, EMULATED_TLBWE_EXITS); 1002 kvmppc_set_exit_type(vcpu, EMULATED_TLBWE_EXITS);
@@ -914,9 +1035,11 @@ gpa_t kvmppc_mmu_xlate(struct kvm_vcpu *vcpu, unsigned int index,
914 gva_t eaddr) 1035 gva_t eaddr)
915{ 1036{
916 struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu); 1037 struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
917 struct tlbe *gtlbe = 1038 struct kvm_book3e_206_tlb_entry *gtlbe;
918 &vcpu_e500->gtlb_arch[tlbsel_of(index)][esel_of(index)]; 1039 u64 pgmask;
919 u64 pgmask = get_tlb_bytes(gtlbe) - 1; 1040
1041 gtlbe = get_entry(vcpu_e500, tlbsel_of(index), esel_of(index));
1042 pgmask = get_tlb_bytes(gtlbe) - 1;
920 1043
921 return get_tlb_raddr(gtlbe) | (eaddr & pgmask); 1044 return get_tlb_raddr(gtlbe) | (eaddr & pgmask);
922} 1045}
@@ -930,22 +1053,21 @@ void kvmppc_mmu_map(struct kvm_vcpu *vcpu, u64 eaddr, gpa_t gpaddr,
930{ 1053{
931 struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu); 1054 struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
932 struct tlbe_priv *priv; 1055 struct tlbe_priv *priv;
933 struct tlbe *gtlbe, stlbe; 1056 struct kvm_book3e_206_tlb_entry *gtlbe, stlbe;
934 int tlbsel = tlbsel_of(index); 1057 int tlbsel = tlbsel_of(index);
935 int esel = esel_of(index); 1058 int esel = esel_of(index);
936 int stlbsel, sesel; 1059 int stlbsel, sesel;
937 1060
938 gtlbe = &vcpu_e500->gtlb_arch[tlbsel][esel]; 1061 gtlbe = get_entry(vcpu_e500, tlbsel, esel);
939 1062
940 preempt_disable();
941 switch (tlbsel) { 1063 switch (tlbsel) {
942 case 0: 1064 case 0:
943 stlbsel = 0; 1065 stlbsel = 0;
944 sesel = esel; 1066 sesel = 0; /* unused */
945 priv = &vcpu_e500->gtlb_priv[stlbsel][sesel]; 1067 priv = &vcpu_e500->gtlb_priv[tlbsel][esel];
946 1068
947 kvmppc_e500_setup_stlbe(vcpu_e500, gtlbe, BOOK3E_PAGESZ_4K, 1069 kvmppc_e500_setup_stlbe(vcpu_e500, gtlbe, BOOK3E_PAGESZ_4K,
948 priv, eaddr, &stlbe); 1070 &priv->ref, eaddr, &stlbe);
949 break; 1071 break;
950 1072
951 case 1: { 1073 case 1: {
@@ -962,8 +1084,7 @@ void kvmppc_mmu_map(struct kvm_vcpu *vcpu, u64 eaddr, gpa_t gpaddr,
962 break; 1084 break;
963 } 1085 }
964 1086
965 write_host_tlbe(vcpu_e500, stlbsel, sesel, &stlbe); 1087 write_stlbe(vcpu_e500, gtlbe, &stlbe, stlbsel, sesel);
966 preempt_enable();
967} 1088}
968 1089
969int kvmppc_e500_tlb_search(struct kvm_vcpu *vcpu, 1090int kvmppc_e500_tlb_search(struct kvm_vcpu *vcpu,
@@ -993,85 +1114,279 @@ void kvmppc_set_pid(struct kvm_vcpu *vcpu, u32 pid)
993 1114
994void kvmppc_e500_tlb_setup(struct kvmppc_vcpu_e500 *vcpu_e500) 1115void kvmppc_e500_tlb_setup(struct kvmppc_vcpu_e500 *vcpu_e500)
995{ 1116{
996 struct tlbe *tlbe; 1117 struct kvm_book3e_206_tlb_entry *tlbe;
997 1118
998 /* Insert large initial mapping for guest. */ 1119 /* Insert large initial mapping for guest. */
999 tlbe = &vcpu_e500->gtlb_arch[1][0]; 1120 tlbe = get_entry(vcpu_e500, 1, 0);
1000 tlbe->mas1 = MAS1_VALID | MAS1_TSIZE(BOOK3E_PAGESZ_256M); 1121 tlbe->mas1 = MAS1_VALID | MAS1_TSIZE(BOOK3E_PAGESZ_256M);
1001 tlbe->mas2 = 0; 1122 tlbe->mas2 = 0;
1002 tlbe->mas3 = E500_TLB_SUPER_PERM_MASK; 1123 tlbe->mas7_3 = E500_TLB_SUPER_PERM_MASK;
1003 tlbe->mas7 = 0;
1004 1124
1005 /* 4K map for serial output. Used by kernel wrapper. */ 1125 /* 4K map for serial output. Used by kernel wrapper. */
1006 tlbe = &vcpu_e500->gtlb_arch[1][1]; 1126 tlbe = get_entry(vcpu_e500, 1, 1);
1007 tlbe->mas1 = MAS1_VALID | MAS1_TSIZE(BOOK3E_PAGESZ_4K); 1127 tlbe->mas1 = MAS1_VALID | MAS1_TSIZE(BOOK3E_PAGESZ_4K);
1008 tlbe->mas2 = (0xe0004500 & 0xFFFFF000) | MAS2_I | MAS2_G; 1128 tlbe->mas2 = (0xe0004500 & 0xFFFFF000) | MAS2_I | MAS2_G;
1009 tlbe->mas3 = (0xe0004500 & 0xFFFFF000) | E500_TLB_SUPER_PERM_MASK; 1129 tlbe->mas7_3 = (0xe0004500 & 0xFFFFF000) | E500_TLB_SUPER_PERM_MASK;
1010 tlbe->mas7 = 0; 1130}
1131
1132static void free_gtlb(struct kvmppc_vcpu_e500 *vcpu_e500)
1133{
1134 int i;
1135
1136 clear_tlb_refs(vcpu_e500);
1137 kfree(vcpu_e500->gtlb_priv[0]);
1138 kfree(vcpu_e500->gtlb_priv[1]);
1139
1140 if (vcpu_e500->shared_tlb_pages) {
1141 vfree((void *)(round_down((uintptr_t)vcpu_e500->gtlb_arch,
1142 PAGE_SIZE)));
1143
1144 for (i = 0; i < vcpu_e500->num_shared_tlb_pages; i++) {
1145 set_page_dirty_lock(vcpu_e500->shared_tlb_pages[i]);
1146 put_page(vcpu_e500->shared_tlb_pages[i]);
1147 }
1148
1149 vcpu_e500->num_shared_tlb_pages = 0;
1150 vcpu_e500->shared_tlb_pages = NULL;
1151 } else {
1152 kfree(vcpu_e500->gtlb_arch);
1153 }
1154
1155 vcpu_e500->gtlb_arch = NULL;
1156}
1157
1158int kvm_vcpu_ioctl_config_tlb(struct kvm_vcpu *vcpu,
1159 struct kvm_config_tlb *cfg)
1160{
1161 struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
1162 struct kvm_book3e_206_tlb_params params;
1163 char *virt;
1164 struct page **pages;
1165 struct tlbe_priv *privs[2] = {};
1166 size_t array_len;
1167 u32 sets;
1168 int num_pages, ret, i;
1169
1170 if (cfg->mmu_type != KVM_MMU_FSL_BOOKE_NOHV)
1171 return -EINVAL;
1172
1173 if (copy_from_user(&params, (void __user *)(uintptr_t)cfg->params,
1174 sizeof(params)))
1175 return -EFAULT;
1176
1177 if (params.tlb_sizes[1] > 64)
1178 return -EINVAL;
1179 if (params.tlb_ways[1] != params.tlb_sizes[1])
1180 return -EINVAL;
1181 if (params.tlb_sizes[2] != 0 || params.tlb_sizes[3] != 0)
1182 return -EINVAL;
1183 if (params.tlb_ways[2] != 0 || params.tlb_ways[3] != 0)
1184 return -EINVAL;
1185
1186 if (!is_power_of_2(params.tlb_ways[0]))
1187 return -EINVAL;
1188
1189 sets = params.tlb_sizes[0] >> ilog2(params.tlb_ways[0]);
1190 if (!is_power_of_2(sets))
1191 return -EINVAL;
1192
1193 array_len = params.tlb_sizes[0] + params.tlb_sizes[1];
1194 array_len *= sizeof(struct kvm_book3e_206_tlb_entry);
1195
1196 if (cfg->array_len < array_len)
1197 return -EINVAL;
1198
1199 num_pages = DIV_ROUND_UP(cfg->array + array_len - 1, PAGE_SIZE) -
1200 cfg->array / PAGE_SIZE;
1201 pages = kmalloc(sizeof(struct page *) * num_pages, GFP_KERNEL);
1202 if (!pages)
1203 return -ENOMEM;
1204
1205 ret = get_user_pages_fast(cfg->array, num_pages, 1, pages);
1206 if (ret < 0)
1207 goto err_pages;
1208
1209 if (ret != num_pages) {
1210 num_pages = ret;
1211 ret = -EFAULT;
1212 goto err_put_page;
1213 }
1214
1215 virt = vmap(pages, num_pages, VM_MAP, PAGE_KERNEL);
1216 if (!virt)
1217 goto err_put_page;
1218
1219 privs[0] = kzalloc(sizeof(struct tlbe_priv) * params.tlb_sizes[0],
1220 GFP_KERNEL);
1221 privs[1] = kzalloc(sizeof(struct tlbe_priv) * params.tlb_sizes[1],
1222 GFP_KERNEL);
1223
1224 if (!privs[0] || !privs[1])
1225 goto err_put_page;
1226
1227 free_gtlb(vcpu_e500);
1228
1229 vcpu_e500->gtlb_priv[0] = privs[0];
1230 vcpu_e500->gtlb_priv[1] = privs[1];
1231
1232 vcpu_e500->gtlb_arch = (struct kvm_book3e_206_tlb_entry *)
1233 (virt + (cfg->array & (PAGE_SIZE - 1)));
1234
1235 vcpu_e500->gtlb_params[0].entries = params.tlb_sizes[0];
1236 vcpu_e500->gtlb_params[1].entries = params.tlb_sizes[1];
1237
1238 vcpu_e500->gtlb_offset[0] = 0;
1239 vcpu_e500->gtlb_offset[1] = params.tlb_sizes[0];
1240
1241 vcpu_e500->tlb0cfg &= ~(TLBnCFG_N_ENTRY | TLBnCFG_ASSOC);
1242 if (params.tlb_sizes[0] <= 2048)
1243 vcpu_e500->tlb0cfg |= params.tlb_sizes[0];
1244 vcpu_e500->tlb0cfg |= params.tlb_ways[0] << TLBnCFG_ASSOC_SHIFT;
1245
1246 vcpu_e500->tlb1cfg &= ~(TLBnCFG_N_ENTRY | TLBnCFG_ASSOC);
1247 vcpu_e500->tlb1cfg |= params.tlb_sizes[1];
1248 vcpu_e500->tlb1cfg |= params.tlb_ways[1] << TLBnCFG_ASSOC_SHIFT;
1249
1250 vcpu_e500->shared_tlb_pages = pages;
1251 vcpu_e500->num_shared_tlb_pages = num_pages;
1252
1253 vcpu_e500->gtlb_params[0].ways = params.tlb_ways[0];
1254 vcpu_e500->gtlb_params[0].sets = sets;
1255
1256 vcpu_e500->gtlb_params[1].ways = params.tlb_sizes[1];
1257 vcpu_e500->gtlb_params[1].sets = 1;
1258
1259 return 0;
1260
1261err_put_page:
1262 kfree(privs[0]);
1263 kfree(privs[1]);
1264
1265 for (i = 0; i < num_pages; i++)
1266 put_page(pages[i]);
1267
1268err_pages:
1269 kfree(pages);
1270 return ret;
1271}
1272
1273int kvm_vcpu_ioctl_dirty_tlb(struct kvm_vcpu *vcpu,
1274 struct kvm_dirty_tlb *dirty)
1275{
1276 struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
1277
1278 clear_tlb_refs(vcpu_e500);
1279 return 0;
1011} 1280}
1012 1281
1013int kvmppc_e500_tlb_init(struct kvmppc_vcpu_e500 *vcpu_e500) 1282int kvmppc_e500_tlb_init(struct kvmppc_vcpu_e500 *vcpu_e500)
1014{ 1283{
1015 tlb1_entry_num = mfspr(SPRN_TLB1CFG) & 0xFFF; 1284 int entry_size = sizeof(struct kvm_book3e_206_tlb_entry);
1016 1285 int entries = KVM_E500_TLB0_SIZE + KVM_E500_TLB1_SIZE;
1017 vcpu_e500->gtlb_size[0] = KVM_E500_TLB0_SIZE; 1286
1018 vcpu_e500->gtlb_arch[0] = 1287 host_tlb_params[0].entries = mfspr(SPRN_TLB0CFG) & TLBnCFG_N_ENTRY;
1019 kzalloc(sizeof(struct tlbe) * KVM_E500_TLB0_SIZE, GFP_KERNEL); 1288 host_tlb_params[1].entries = mfspr(SPRN_TLB1CFG) & TLBnCFG_N_ENTRY;
1020 if (vcpu_e500->gtlb_arch[0] == NULL) 1289
1021 goto err_out; 1290 /*
1022 1291 * This should never happen on real e500 hardware, but is
1023 vcpu_e500->gtlb_size[1] = KVM_E500_TLB1_SIZE; 1292 * architecturally possible -- e.g. in some weird nested
1024 vcpu_e500->gtlb_arch[1] = 1293 * virtualization case.
1025 kzalloc(sizeof(struct tlbe) * KVM_E500_TLB1_SIZE, GFP_KERNEL); 1294 */
1026 if (vcpu_e500->gtlb_arch[1] == NULL) 1295 if (host_tlb_params[0].entries == 0 ||
1027 goto err_out_guest0; 1296 host_tlb_params[1].entries == 0) {
1028 1297 pr_err("%s: need to know host tlb size\n", __func__);
1029 vcpu_e500->gtlb_priv[0] = (struct tlbe_priv *) 1298 return -ENODEV;
1030 kzalloc(sizeof(struct tlbe_priv) * KVM_E500_TLB0_SIZE, GFP_KERNEL); 1299 }
1031 if (vcpu_e500->gtlb_priv[0] == NULL) 1300
1032 goto err_out_guest1; 1301 host_tlb_params[0].ways = (mfspr(SPRN_TLB0CFG) & TLBnCFG_ASSOC) >>
1033 vcpu_e500->gtlb_priv[1] = (struct tlbe_priv *) 1302 TLBnCFG_ASSOC_SHIFT;
1034 kzalloc(sizeof(struct tlbe_priv) * KVM_E500_TLB1_SIZE, GFP_KERNEL); 1303 host_tlb_params[1].ways = host_tlb_params[1].entries;
1035 1304
1036 if (vcpu_e500->gtlb_priv[1] == NULL) 1305 if (!is_power_of_2(host_tlb_params[0].entries) ||
1037 goto err_out_priv0; 1306 !is_power_of_2(host_tlb_params[0].ways) ||
1307 host_tlb_params[0].entries < host_tlb_params[0].ways ||
1308 host_tlb_params[0].ways == 0) {
1309 pr_err("%s: bad tlb0 host config: %u entries %u ways\n",
1310 __func__, host_tlb_params[0].entries,
1311 host_tlb_params[0].ways);
1312 return -ENODEV;
1313 }
1314
1315 host_tlb_params[0].sets =
1316 host_tlb_params[0].entries / host_tlb_params[0].ways;
1317 host_tlb_params[1].sets = 1;
1318
1319 vcpu_e500->gtlb_params[0].entries = KVM_E500_TLB0_SIZE;
1320 vcpu_e500->gtlb_params[1].entries = KVM_E500_TLB1_SIZE;
1321
1322 vcpu_e500->gtlb_params[0].ways = KVM_E500_TLB0_WAY_NUM;
1323 vcpu_e500->gtlb_params[0].sets =
1324 KVM_E500_TLB0_SIZE / KVM_E500_TLB0_WAY_NUM;
1325
1326 vcpu_e500->gtlb_params[1].ways = KVM_E500_TLB1_SIZE;
1327 vcpu_e500->gtlb_params[1].sets = 1;
1328
1329 vcpu_e500->gtlb_arch = kmalloc(entries * entry_size, GFP_KERNEL);
1330 if (!vcpu_e500->gtlb_arch)
1331 return -ENOMEM;
1332
1333 vcpu_e500->gtlb_offset[0] = 0;
1334 vcpu_e500->gtlb_offset[1] = KVM_E500_TLB0_SIZE;
1335
1336 vcpu_e500->tlb_refs[0] =
1337 kzalloc(sizeof(struct tlbe_ref) * host_tlb_params[0].entries,
1338 GFP_KERNEL);
1339 if (!vcpu_e500->tlb_refs[0])
1340 goto err;
1341
1342 vcpu_e500->tlb_refs[1] =
1343 kzalloc(sizeof(struct tlbe_ref) * host_tlb_params[1].entries,
1344 GFP_KERNEL);
1345 if (!vcpu_e500->tlb_refs[1])
1346 goto err;
1347
1348 vcpu_e500->gtlb_priv[0] = kzalloc(sizeof(struct tlbe_ref) *
1349 vcpu_e500->gtlb_params[0].entries,
1350 GFP_KERNEL);
1351 if (!vcpu_e500->gtlb_priv[0])
1352 goto err;
1353
1354 vcpu_e500->gtlb_priv[1] = kzalloc(sizeof(struct tlbe_ref) *
1355 vcpu_e500->gtlb_params[1].entries,
1356 GFP_KERNEL);
1357 if (!vcpu_e500->gtlb_priv[1])
1358 goto err;
1038 1359
1039 if (kvmppc_e500_id_table_alloc(vcpu_e500) == NULL) 1360 if (kvmppc_e500_id_table_alloc(vcpu_e500) == NULL)
1040 goto err_out_priv1; 1361 goto err;
1041 1362
1042 /* Init TLB configuration register */ 1363 /* Init TLB configuration register */
1043 vcpu_e500->tlb0cfg = mfspr(SPRN_TLB0CFG) & ~0xfffUL; 1364 vcpu_e500->tlb0cfg = mfspr(SPRN_TLB0CFG) &
1044 vcpu_e500->tlb0cfg |= vcpu_e500->gtlb_size[0]; 1365 ~(TLBnCFG_N_ENTRY | TLBnCFG_ASSOC);
1045 vcpu_e500->tlb1cfg = mfspr(SPRN_TLB1CFG) & ~0xfffUL; 1366 vcpu_e500->tlb0cfg |= vcpu_e500->gtlb_params[0].entries;
1046 vcpu_e500->tlb1cfg |= vcpu_e500->gtlb_size[1]; 1367 vcpu_e500->tlb0cfg |=
1368 vcpu_e500->gtlb_params[0].ways << TLBnCFG_ASSOC_SHIFT;
1369
1370 vcpu_e500->tlb1cfg = mfspr(SPRN_TLB1CFG) &
1371 ~(TLBnCFG_N_ENTRY | TLBnCFG_ASSOC);
1372 vcpu_e500->tlb0cfg |= vcpu_e500->gtlb_params[1].entries;
1373 vcpu_e500->tlb0cfg |=
1374 vcpu_e500->gtlb_params[1].ways << TLBnCFG_ASSOC_SHIFT;
1047 1375
1048 return 0; 1376 return 0;
1049 1377
1050err_out_priv1: 1378err:
1051 kfree(vcpu_e500->gtlb_priv[1]); 1379 free_gtlb(vcpu_e500);
1052err_out_priv0: 1380 kfree(vcpu_e500->tlb_refs[0]);
1053 kfree(vcpu_e500->gtlb_priv[0]); 1381 kfree(vcpu_e500->tlb_refs[1]);
1054err_out_guest1:
1055 kfree(vcpu_e500->gtlb_arch[1]);
1056err_out_guest0:
1057 kfree(vcpu_e500->gtlb_arch[0]);
1058err_out:
1059 return -1; 1382 return -1;
1060} 1383}
1061 1384
1062void kvmppc_e500_tlb_uninit(struct kvmppc_vcpu_e500 *vcpu_e500) 1385void kvmppc_e500_tlb_uninit(struct kvmppc_vcpu_e500 *vcpu_e500)
1063{ 1386{
1064 int stlbsel, i; 1387 free_gtlb(vcpu_e500);
1065
1066 /* release all privs */
1067 for (stlbsel = 0; stlbsel < 2; stlbsel++)
1068 for (i = 0; i < vcpu_e500->gtlb_size[stlbsel]; i++) {
1069 struct tlbe_priv *priv =
1070 &vcpu_e500->gtlb_priv[stlbsel][i];
1071 kvmppc_e500_priv_release(priv);
1072 }
1073
1074 kvmppc_e500_id_table_free(vcpu_e500); 1388 kvmppc_e500_id_table_free(vcpu_e500);
1075 kfree(vcpu_e500->gtlb_arch[1]); 1389
1076 kfree(vcpu_e500->gtlb_arch[0]); 1390 kfree(vcpu_e500->tlb_refs[0]);
1391 kfree(vcpu_e500->tlb_refs[1]);
1077} 1392}
diff --git a/arch/powerpc/kvm/e500_tlb.h b/arch/powerpc/kvm/e500_tlb.h
index 59b88e99a23..5c6d2d7bf05 100644
--- a/arch/powerpc/kvm/e500_tlb.h
+++ b/arch/powerpc/kvm/e500_tlb.h
@@ -20,13 +20,9 @@
20#include <asm/tlb.h> 20#include <asm/tlb.h>
21#include <asm/kvm_e500.h> 21#include <asm/kvm_e500.h>
22 22
23#define KVM_E500_TLB0_WAY_SIZE_BIT 7 /* Fixed */ 23/* This geometry is the legacy default -- can be overridden by userspace */
24#define KVM_E500_TLB0_WAY_SIZE (1UL << KVM_E500_TLB0_WAY_SIZE_BIT) 24#define KVM_E500_TLB0_WAY_SIZE 128
25#define KVM_E500_TLB0_WAY_SIZE_MASK (KVM_E500_TLB0_WAY_SIZE - 1) 25#define KVM_E500_TLB0_WAY_NUM 2
26
27#define KVM_E500_TLB0_WAY_NUM_BIT 1 /* No greater than 7 */
28#define KVM_E500_TLB0_WAY_NUM (1UL << KVM_E500_TLB0_WAY_NUM_BIT)
29#define KVM_E500_TLB0_WAY_NUM_MASK (KVM_E500_TLB0_WAY_NUM - 1)
30 26
31#define KVM_E500_TLB0_SIZE (KVM_E500_TLB0_WAY_SIZE * KVM_E500_TLB0_WAY_NUM) 27#define KVM_E500_TLB0_SIZE (KVM_E500_TLB0_WAY_SIZE * KVM_E500_TLB0_WAY_NUM)
32#define KVM_E500_TLB1_SIZE 16 28#define KVM_E500_TLB1_SIZE 16
@@ -58,50 +54,54 @@ extern void kvmppc_e500_tlb_setup(struct kvmppc_vcpu_e500 *);
58extern void kvmppc_e500_recalc_shadow_pid(struct kvmppc_vcpu_e500 *); 54extern void kvmppc_e500_recalc_shadow_pid(struct kvmppc_vcpu_e500 *);
59 55
60/* TLB helper functions */ 56/* TLB helper functions */
61static inline unsigned int get_tlb_size(const struct tlbe *tlbe) 57static inline unsigned int
58get_tlb_size(const struct kvm_book3e_206_tlb_entry *tlbe)
62{ 59{
63 return (tlbe->mas1 >> 7) & 0x1f; 60 return (tlbe->mas1 >> 7) & 0x1f;
64} 61}
65 62
66static inline gva_t get_tlb_eaddr(const struct tlbe *tlbe) 63static inline gva_t get_tlb_eaddr(const struct kvm_book3e_206_tlb_entry *tlbe)
67{ 64{
68 return tlbe->mas2 & 0xfffff000; 65 return tlbe->mas2 & 0xfffff000;
69} 66}
70 67
71static inline u64 get_tlb_bytes(const struct tlbe *tlbe) 68static inline u64 get_tlb_bytes(const struct kvm_book3e_206_tlb_entry *tlbe)
72{ 69{
73 unsigned int pgsize = get_tlb_size(tlbe); 70 unsigned int pgsize = get_tlb_size(tlbe);
74 return 1ULL << 10 << pgsize; 71 return 1ULL << 10 << pgsize;
75} 72}
76 73
77static inline gva_t get_tlb_end(const struct tlbe *tlbe) 74static inline gva_t get_tlb_end(const struct kvm_book3e_206_tlb_entry *tlbe)
78{ 75{
79 u64 bytes = get_tlb_bytes(tlbe); 76 u64 bytes = get_tlb_bytes(tlbe);
80 return get_tlb_eaddr(tlbe) + bytes - 1; 77 return get_tlb_eaddr(tlbe) + bytes - 1;
81} 78}
82 79
83static inline u64 get_tlb_raddr(const struct tlbe *tlbe) 80static inline u64 get_tlb_raddr(const struct kvm_book3e_206_tlb_entry *tlbe)
84{ 81{
85 u64 rpn = tlbe->mas7; 82 return tlbe->mas7_3 & ~0xfffULL;
86 return (rpn << 32) | (tlbe->mas3 & 0xfffff000);
87} 83}
88 84
89static inline unsigned int get_tlb_tid(const struct tlbe *tlbe) 85static inline unsigned int
86get_tlb_tid(const struct kvm_book3e_206_tlb_entry *tlbe)
90{ 87{
91 return (tlbe->mas1 >> 16) & 0xff; 88 return (tlbe->mas1 >> 16) & 0xff;
92} 89}
93 90
94static inline unsigned int get_tlb_ts(const struct tlbe *tlbe) 91static inline unsigned int
92get_tlb_ts(const struct kvm_book3e_206_tlb_entry *tlbe)
95{ 93{
96 return (tlbe->mas1 >> 12) & 0x1; 94 return (tlbe->mas1 >> 12) & 0x1;
97} 95}
98 96
99static inline unsigned int get_tlb_v(const struct tlbe *tlbe) 97static inline unsigned int
98get_tlb_v(const struct kvm_book3e_206_tlb_entry *tlbe)
100{ 99{
101 return (tlbe->mas1 >> 31) & 0x1; 100 return (tlbe->mas1 >> 31) & 0x1;
102} 101}
103 102
104static inline unsigned int get_tlb_iprot(const struct tlbe *tlbe) 103static inline unsigned int
104get_tlb_iprot(const struct kvm_book3e_206_tlb_entry *tlbe)
105{ 105{
106 return (tlbe->mas1 >> 30) & 0x1; 106 return (tlbe->mas1 >> 30) & 0x1;
107} 107}
@@ -121,59 +121,37 @@ static inline unsigned int get_cur_pr(struct kvm_vcpu *vcpu)
121 return !!(vcpu->arch.shared->msr & MSR_PR); 121 return !!(vcpu->arch.shared->msr & MSR_PR);
122} 122}
123 123
124static inline unsigned int get_cur_spid( 124static inline unsigned int get_cur_spid(const struct kvm_vcpu *vcpu)
125 const struct kvmppc_vcpu_e500 *vcpu_e500)
126{ 125{
127 return (vcpu_e500->mas6 >> 16) & 0xff; 126 return (vcpu->arch.shared->mas6 >> 16) & 0xff;
128} 127}
129 128
130static inline unsigned int get_cur_sas( 129static inline unsigned int get_cur_sas(const struct kvm_vcpu *vcpu)
131 const struct kvmppc_vcpu_e500 *vcpu_e500)
132{ 130{
133 return vcpu_e500->mas6 & 0x1; 131 return vcpu->arch.shared->mas6 & 0x1;
134} 132}
135 133
136static inline unsigned int get_tlb_tlbsel( 134static inline unsigned int get_tlb_tlbsel(const struct kvm_vcpu *vcpu)
137 const struct kvmppc_vcpu_e500 *vcpu_e500)
138{ 135{
139 /* 136 /*
140 * Manual says that tlbsel has 2 bits wide. 137 * Manual says that tlbsel has 2 bits wide.
141 * Since we only have two TLBs, only lower bit is used. 138 * Since we only have two TLBs, only lower bit is used.
142 */ 139 */
143 return (vcpu_e500->mas0 >> 28) & 0x1; 140 return (vcpu->arch.shared->mas0 >> 28) & 0x1;
144}
145
146static inline unsigned int get_tlb_nv_bit(
147 const struct kvmppc_vcpu_e500 *vcpu_e500)
148{
149 return vcpu_e500->mas0 & 0xfff;
150} 141}
151 142
152static inline unsigned int get_tlb_esel_bit( 143static inline unsigned int get_tlb_nv_bit(const struct kvm_vcpu *vcpu)
153 const struct kvmppc_vcpu_e500 *vcpu_e500)
154{ 144{
155 return (vcpu_e500->mas0 >> 16) & 0xfff; 145 return vcpu->arch.shared->mas0 & 0xfff;
156} 146}
157 147
158static inline unsigned int get_tlb_esel( 148static inline unsigned int get_tlb_esel_bit(const struct kvm_vcpu *vcpu)
159 const struct kvmppc_vcpu_e500 *vcpu_e500,
160 int tlbsel)
161{ 149{
162 unsigned int esel = get_tlb_esel_bit(vcpu_e500); 150 return (vcpu->arch.shared->mas0 >> 16) & 0xfff;
163
164 if (tlbsel == 0) {
165 esel &= KVM_E500_TLB0_WAY_NUM_MASK;
166 esel |= ((vcpu_e500->mas2 >> 12) & KVM_E500_TLB0_WAY_SIZE_MASK)
167 << KVM_E500_TLB0_WAY_NUM_BIT;
168 } else {
169 esel &= KVM_E500_TLB1_SIZE - 1;
170 }
171
172 return esel;
173} 151}
174 152
175static inline int tlbe_is_host_safe(const struct kvm_vcpu *vcpu, 153static inline int tlbe_is_host_safe(const struct kvm_vcpu *vcpu,
176 const struct tlbe *tlbe) 154 const struct kvm_book3e_206_tlb_entry *tlbe)
177{ 155{
178 gpa_t gpa; 156 gpa_t gpa;
179 157
diff --git a/arch/powerpc/kvm/emulate.c b/arch/powerpc/kvm/emulate.c
index 141dce3c681..968f4010188 100644
--- a/arch/powerpc/kvm/emulate.c
+++ b/arch/powerpc/kvm/emulate.c
@@ -13,6 +13,7 @@
13 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 13 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14 * 14 *
15 * Copyright IBM Corp. 2007 15 * Copyright IBM Corp. 2007
16 * Copyright 2011 Freescale Semiconductor, Inc.
16 * 17 *
17 * Authors: Hollis Blanchard <hollisb@us.ibm.com> 18 * Authors: Hollis Blanchard <hollisb@us.ibm.com>
18 */ 19 */
@@ -69,54 +70,55 @@
69#define OP_STH 44 70#define OP_STH 44
70#define OP_STHU 45 71#define OP_STHU 45
71 72
72#ifdef CONFIG_PPC_BOOK3S
73static int kvmppc_dec_enabled(struct kvm_vcpu *vcpu)
74{
75 return 1;
76}
77#else
78static int kvmppc_dec_enabled(struct kvm_vcpu *vcpu)
79{
80 return vcpu->arch.tcr & TCR_DIE;
81}
82#endif
83
84void kvmppc_emulate_dec(struct kvm_vcpu *vcpu) 73void kvmppc_emulate_dec(struct kvm_vcpu *vcpu)
85{ 74{
86 unsigned long dec_nsec; 75 unsigned long dec_nsec;
76 unsigned long long dec_time;
87 77
88 pr_debug("mtDEC: %x\n", vcpu->arch.dec); 78 pr_debug("mtDEC: %x\n", vcpu->arch.dec);
79 hrtimer_try_to_cancel(&vcpu->arch.dec_timer);
80
89#ifdef CONFIG_PPC_BOOK3S 81#ifdef CONFIG_PPC_BOOK3S
90 /* mtdec lowers the interrupt line when positive. */ 82 /* mtdec lowers the interrupt line when positive. */
91 kvmppc_core_dequeue_dec(vcpu); 83 kvmppc_core_dequeue_dec(vcpu);
92 84
93 /* POWER4+ triggers a dec interrupt if the value is < 0 */ 85 /* POWER4+ triggers a dec interrupt if the value is < 0 */
94 if (vcpu->arch.dec & 0x80000000) { 86 if (vcpu->arch.dec & 0x80000000) {
95 hrtimer_try_to_cancel(&vcpu->arch.dec_timer);
96 kvmppc_core_queue_dec(vcpu); 87 kvmppc_core_queue_dec(vcpu);
97 return; 88 return;
98 } 89 }
99#endif 90#endif
100 if (kvmppc_dec_enabled(vcpu)) { 91
101 /* The decrementer ticks at the same rate as the timebase, so 92#ifdef CONFIG_BOOKE
102 * that's how we convert the guest DEC value to the number of 93 /* On BOOKE, DEC = 0 is as good as decrementer not enabled */
103 * host ticks. */ 94 if (vcpu->arch.dec == 0)
104 95 return;
105 hrtimer_try_to_cancel(&vcpu->arch.dec_timer); 96#endif
106 dec_nsec = vcpu->arch.dec; 97
107 dec_nsec *= 1000; 98 /*
108 dec_nsec /= tb_ticks_per_usec; 99 * The decrementer ticks at the same rate as the timebase, so
109 hrtimer_start(&vcpu->arch.dec_timer, ktime_set(0, dec_nsec), 100 * that's how we convert the guest DEC value to the number of
110 HRTIMER_MODE_REL); 101 * host ticks.
111 vcpu->arch.dec_jiffies = get_tb(); 102 */
112 } else { 103
113 hrtimer_try_to_cancel(&vcpu->arch.dec_timer); 104 dec_time = vcpu->arch.dec;
114 } 105 dec_time *= 1000;
106 do_div(dec_time, tb_ticks_per_usec);
107 dec_nsec = do_div(dec_time, NSEC_PER_SEC);
108 hrtimer_start(&vcpu->arch.dec_timer,
109 ktime_set(dec_time, dec_nsec), HRTIMER_MODE_REL);
110 vcpu->arch.dec_jiffies = get_tb();
115} 111}
116 112
117u32 kvmppc_get_dec(struct kvm_vcpu *vcpu, u64 tb) 113u32 kvmppc_get_dec(struct kvm_vcpu *vcpu, u64 tb)
118{ 114{
119 u64 jd = tb - vcpu->arch.dec_jiffies; 115 u64 jd = tb - vcpu->arch.dec_jiffies;
116
117#ifdef CONFIG_BOOKE
118 if (vcpu->arch.dec < jd)
119 return 0;
120#endif
121
120 return vcpu->arch.dec - jd; 122 return vcpu->arch.dec - jd;
121} 123}
122 124
@@ -159,7 +161,8 @@ int kvmppc_emulate_instruction(struct kvm_run *run, struct kvm_vcpu *vcpu)
159 case OP_TRAP_64: 161 case OP_TRAP_64:
160 kvmppc_core_queue_program(vcpu, SRR1_PROGTRAP); 162 kvmppc_core_queue_program(vcpu, SRR1_PROGTRAP);
161#else 163#else
162 kvmppc_core_queue_program(vcpu, vcpu->arch.esr | ESR_PTR); 164 kvmppc_core_queue_program(vcpu,
165 vcpu->arch.shared->esr | ESR_PTR);
163#endif 166#endif
164 advance = 0; 167 advance = 0;
165 break; 168 break;
diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
index 607fbdf24b8..00d7e345b3f 100644
--- a/arch/powerpc/kvm/powerpc.c
+++ b/arch/powerpc/kvm/powerpc.c
@@ -39,7 +39,8 @@
39int kvm_arch_vcpu_runnable(struct kvm_vcpu *v) 39int kvm_arch_vcpu_runnable(struct kvm_vcpu *v)
40{ 40{
41 return !(v->arch.shared->msr & MSR_WE) || 41 return !(v->arch.shared->msr & MSR_WE) ||
42 !!(v->arch.pending_exceptions); 42 !!(v->arch.pending_exceptions) ||
43 v->requests;
43} 44}
44 45
45int kvmppc_kvm_pv(struct kvm_vcpu *vcpu) 46int kvmppc_kvm_pv(struct kvm_vcpu *vcpu)
@@ -66,7 +67,7 @@ int kvmppc_kvm_pv(struct kvm_vcpu *vcpu)
66 vcpu->arch.magic_page_pa = param1; 67 vcpu->arch.magic_page_pa = param1;
67 vcpu->arch.magic_page_ea = param2; 68 vcpu->arch.magic_page_ea = param2;
68 69
69 r2 = KVM_MAGIC_FEAT_SR; 70 r2 = KVM_MAGIC_FEAT_SR | KVM_MAGIC_FEAT_MAS0_TO_SPRG7;
70 71
71 r = HC_EV_SUCCESS; 72 r = HC_EV_SUCCESS;
72 break; 73 break;
@@ -171,8 +172,11 @@ void kvm_arch_check_processor_compat(void *rtn)
171 *(int *)rtn = kvmppc_core_check_processor_compat(); 172 *(int *)rtn = kvmppc_core_check_processor_compat();
172} 173}
173 174
174int kvm_arch_init_vm(struct kvm *kvm) 175int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
175{ 176{
177 if (type)
178 return -EINVAL;
179
176 return kvmppc_core_init_vm(kvm); 180 return kvmppc_core_init_vm(kvm);
177} 181}
178 182
@@ -208,17 +212,22 @@ int kvm_dev_ioctl_check_extension(long ext)
208 case KVM_CAP_PPC_BOOKE_SREGS: 212 case KVM_CAP_PPC_BOOKE_SREGS:
209#else 213#else
210 case KVM_CAP_PPC_SEGSTATE: 214 case KVM_CAP_PPC_SEGSTATE:
215 case KVM_CAP_PPC_HIOR:
211 case KVM_CAP_PPC_PAPR: 216 case KVM_CAP_PPC_PAPR:
212#endif 217#endif
213 case KVM_CAP_PPC_UNSET_IRQ: 218 case KVM_CAP_PPC_UNSET_IRQ:
214 case KVM_CAP_PPC_IRQ_LEVEL: 219 case KVM_CAP_PPC_IRQ_LEVEL:
215 case KVM_CAP_ENABLE_CAP: 220 case KVM_CAP_ENABLE_CAP:
221 case KVM_CAP_ONE_REG:
216 r = 1; 222 r = 1;
217 break; 223 break;
218#ifndef CONFIG_KVM_BOOK3S_64_HV 224#ifndef CONFIG_KVM_BOOK3S_64_HV
219 case KVM_CAP_PPC_PAIRED_SINGLES: 225 case KVM_CAP_PPC_PAIRED_SINGLES:
220 case KVM_CAP_PPC_OSI: 226 case KVM_CAP_PPC_OSI:
221 case KVM_CAP_PPC_GET_PVINFO: 227 case KVM_CAP_PPC_GET_PVINFO:
228#ifdef CONFIG_KVM_E500
229 case KVM_CAP_SW_TLB:
230#endif
222 r = 1; 231 r = 1;
223 break; 232 break;
224 case KVM_CAP_COALESCED_MMIO: 233 case KVM_CAP_COALESCED_MMIO:
@@ -238,7 +247,26 @@ int kvm_dev_ioctl_check_extension(long ext)
238 if (cpu_has_feature(CPU_FTR_ARCH_201)) 247 if (cpu_has_feature(CPU_FTR_ARCH_201))
239 r = 2; 248 r = 2;
240 break; 249 break;
250 case KVM_CAP_SYNC_MMU:
251 r = cpu_has_feature(CPU_FTR_ARCH_206) ? 1 : 0;
252 break;
241#endif 253#endif
254 case KVM_CAP_NR_VCPUS:
255 /*
256 * Recommending a number of CPUs is somewhat arbitrary; we
257 * return the number of present CPUs for -HV (since a host
258 * will have secondary threads "offline"), and for other KVM
259 * implementations just count online CPUs.
260 */
261#ifdef CONFIG_KVM_BOOK3S_64_HV
262 r = num_present_cpus();
263#else
264 r = num_online_cpus();
265#endif
266 break;
267 case KVM_CAP_MAX_VCPUS:
268 r = KVM_MAX_VCPUS;
269 break;
242 default: 270 default:
243 r = 0; 271 r = 0;
244 break; 272 break;
@@ -253,6 +281,16 @@ long kvm_arch_dev_ioctl(struct file *filp,
253 return -EINVAL; 281 return -EINVAL;
254} 282}
255 283
284void kvm_arch_free_memslot(struct kvm_memory_slot *free,
285 struct kvm_memory_slot *dont)
286{
287}
288
289int kvm_arch_create_memslot(struct kvm_memory_slot *slot, unsigned long npages)
290{
291 return 0;
292}
293
256int kvm_arch_prepare_memory_region(struct kvm *kvm, 294int kvm_arch_prepare_memory_region(struct kvm *kvm,
257 struct kvm_memory_slot *memslot, 295 struct kvm_memory_slot *memslot,
258 struct kvm_memory_slot old, 296 struct kvm_memory_slot old,
@@ -279,9 +317,10 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id)
279{ 317{
280 struct kvm_vcpu *vcpu; 318 struct kvm_vcpu *vcpu;
281 vcpu = kvmppc_core_vcpu_create(kvm, id); 319 vcpu = kvmppc_core_vcpu_create(kvm, id);
282 vcpu->arch.wqp = &vcpu->wq; 320 if (!IS_ERR(vcpu)) {
283 if (!IS_ERR(vcpu)) 321 vcpu->arch.wqp = &vcpu->wq;
284 kvmppc_create_vcpu_debugfs(vcpu, id); 322 kvmppc_create_vcpu_debugfs(vcpu, id);
323 }
285 return vcpu; 324 return vcpu;
286} 325}
287 326
@@ -305,18 +344,6 @@ int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu)
305 return kvmppc_core_pending_dec(vcpu); 344 return kvmppc_core_pending_dec(vcpu);
306} 345}
307 346
308static void kvmppc_decrementer_func(unsigned long data)
309{
310 struct kvm_vcpu *vcpu = (struct kvm_vcpu *)data;
311
312 kvmppc_core_queue_dec(vcpu);
313
314 if (waitqueue_active(vcpu->arch.wqp)) {
315 wake_up_interruptible(vcpu->arch.wqp);
316 vcpu->stat.halt_wakeup++;
317 }
318}
319
320/* 347/*
321 * low level hrtimer wake routine. Because this runs in hardirq context 348 * low level hrtimer wake routine. Because this runs in hardirq context
322 * we schedule a tasklet to do the real work. 349 * we schedule a tasklet to do the real work.
@@ -431,20 +458,20 @@ static void kvmppc_complete_mmio_load(struct kvm_vcpu *vcpu,
431 458
432 kvmppc_set_gpr(vcpu, vcpu->arch.io_gpr, gpr); 459 kvmppc_set_gpr(vcpu, vcpu->arch.io_gpr, gpr);
433 460
434 switch (vcpu->arch.io_gpr & KVM_REG_EXT_MASK) { 461 switch (vcpu->arch.io_gpr & KVM_MMIO_REG_EXT_MASK) {
435 case KVM_REG_GPR: 462 case KVM_MMIO_REG_GPR:
436 kvmppc_set_gpr(vcpu, vcpu->arch.io_gpr, gpr); 463 kvmppc_set_gpr(vcpu, vcpu->arch.io_gpr, gpr);
437 break; 464 break;
438 case KVM_REG_FPR: 465 case KVM_MMIO_REG_FPR:
439 vcpu->arch.fpr[vcpu->arch.io_gpr & KVM_REG_MASK] = gpr; 466 vcpu->arch.fpr[vcpu->arch.io_gpr & KVM_MMIO_REG_MASK] = gpr;
440 break; 467 break;
441#ifdef CONFIG_PPC_BOOK3S 468#ifdef CONFIG_PPC_BOOK3S
442 case KVM_REG_QPR: 469 case KVM_MMIO_REG_QPR:
443 vcpu->arch.qpr[vcpu->arch.io_gpr & KVM_REG_MASK] = gpr; 470 vcpu->arch.qpr[vcpu->arch.io_gpr & KVM_MMIO_REG_MASK] = gpr;
444 break; 471 break;
445 case KVM_REG_FQPR: 472 case KVM_MMIO_REG_FQPR:
446 vcpu->arch.fpr[vcpu->arch.io_gpr & KVM_REG_MASK] = gpr; 473 vcpu->arch.fpr[vcpu->arch.io_gpr & KVM_MMIO_REG_MASK] = gpr;
447 vcpu->arch.qpr[vcpu->arch.io_gpr & KVM_REG_MASK] = gpr; 474 vcpu->arch.qpr[vcpu->arch.io_gpr & KVM_MMIO_REG_MASK] = gpr;
448 break; 475 break;
449#endif 476#endif
450 default: 477 default:
@@ -553,8 +580,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
553 vcpu->arch.hcall_needed = 0; 580 vcpu->arch.hcall_needed = 0;
554 } 581 }
555 582
556 kvmppc_core_deliver_interrupts(vcpu);
557
558 r = kvmppc_vcpu_run(run, vcpu); 583 r = kvmppc_vcpu_run(run, vcpu);
559 584
560 if (vcpu->sigset_active) 585 if (vcpu->sigset_active)
@@ -563,6 +588,21 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
563 return r; 588 return r;
564} 589}
565 590
591void kvm_vcpu_kick(struct kvm_vcpu *vcpu)
592{
593 int me;
594 int cpu = vcpu->cpu;
595
596 me = get_cpu();
597 if (waitqueue_active(vcpu->arch.wqp)) {
598 wake_up_interruptible(vcpu->arch.wqp);
599 vcpu->stat.halt_wakeup++;
600 } else if (cpu != me && cpu != -1) {
601 smp_send_reschedule(vcpu->cpu);
602 }
603 put_cpu();
604}
605
566int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, struct kvm_interrupt *irq) 606int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, struct kvm_interrupt *irq)
567{ 607{
568 if (irq->irq == KVM_INTERRUPT_UNSET) { 608 if (irq->irq == KVM_INTERRUPT_UNSET) {
@@ -571,13 +611,7 @@ int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, struct kvm_interrupt *irq)
571 } 611 }
572 612
573 kvmppc_core_queue_external(vcpu, irq); 613 kvmppc_core_queue_external(vcpu, irq);
574 614 kvm_vcpu_kick(vcpu);
575 if (waitqueue_active(vcpu->arch.wqp)) {
576 wake_up_interruptible(vcpu->arch.wqp);
577 vcpu->stat.halt_wakeup++;
578 } else if (vcpu->cpu != -1) {
579 smp_send_reschedule(vcpu->cpu);
580 }
581 615
582 return 0; 616 return 0;
583} 617}
@@ -599,6 +633,19 @@ static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu,
599 r = 0; 633 r = 0;
600 vcpu->arch.papr_enabled = true; 634 vcpu->arch.papr_enabled = true;
601 break; 635 break;
636#ifdef CONFIG_KVM_E500
637 case KVM_CAP_SW_TLB: {
638 struct kvm_config_tlb cfg;
639 void __user *user_ptr = (void __user *)(uintptr_t)cap->args[0];
640
641 r = -EFAULT;
642 if (copy_from_user(&cfg, user_ptr, sizeof(cfg)))
643 break;
644
645 r = kvm_vcpu_ioctl_config_tlb(vcpu, &cfg);
646 break;
647 }
648#endif
602 default: 649 default:
603 r = -EINVAL; 650 r = -EINVAL;
604 break; 651 break;
@@ -648,6 +695,32 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
648 r = kvm_vcpu_ioctl_enable_cap(vcpu, &cap); 695 r = kvm_vcpu_ioctl_enable_cap(vcpu, &cap);
649 break; 696 break;
650 } 697 }
698
699 case KVM_SET_ONE_REG:
700 case KVM_GET_ONE_REG:
701 {
702 struct kvm_one_reg reg;
703 r = -EFAULT;
704 if (copy_from_user(&reg, argp, sizeof(reg)))
705 goto out;
706 if (ioctl == KVM_SET_ONE_REG)
707 r = kvm_vcpu_ioctl_set_one_reg(vcpu, &reg);
708 else
709 r = kvm_vcpu_ioctl_get_one_reg(vcpu, &reg);
710 break;
711 }
712
713#ifdef CONFIG_KVM_E500
714 case KVM_DIRTY_TLB: {
715 struct kvm_dirty_tlb dirty;
716 r = -EFAULT;
717 if (copy_from_user(&dirty, argp, sizeof(dirty)))
718 goto out;
719 r = kvm_vcpu_ioctl_dirty_tlb(vcpu, &dirty);
720 break;
721 }
722#endif
723
651 default: 724 default:
652 r = -EINVAL; 725 r = -EINVAL;
653 } 726 }
@@ -656,6 +729,11 @@ out:
656 return r; 729 return r;
657} 730}
658 731
732int kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf)
733{
734 return VM_FAULT_SIGBUS;
735}
736
659static int kvm_vm_ioctl_get_pvinfo(struct kvm_ppc_pvinfo *pvinfo) 737static int kvm_vm_ioctl_get_pvinfo(struct kvm_ppc_pvinfo *pvinfo)
660{ 738{
661 u32 inst_lis = 0x3c000000; 739 u32 inst_lis = 0x3c000000;
diff --git a/arch/powerpc/kvm/trace.h b/arch/powerpc/kvm/trace.h
index b135d3d397d..877186b7b1c 100644
--- a/arch/powerpc/kvm/trace.h
+++ b/arch/powerpc/kvm/trace.h
@@ -118,11 +118,14 @@ TRACE_EVENT(kvm_book3s_exit,
118 ), 118 ),
119 119
120 TP_fast_assign( 120 TP_fast_assign(
121 struct kvmppc_book3s_shadow_vcpu *svcpu;
121 __entry->exit_nr = exit_nr; 122 __entry->exit_nr = exit_nr;
122 __entry->pc = kvmppc_get_pc(vcpu); 123 __entry->pc = kvmppc_get_pc(vcpu);
123 __entry->dar = kvmppc_get_fault_dar(vcpu); 124 __entry->dar = kvmppc_get_fault_dar(vcpu);
124 __entry->msr = vcpu->arch.shared->msr; 125 __entry->msr = vcpu->arch.shared->msr;
125 __entry->srr1 = to_svcpu(vcpu)->shadow_srr1; 126 svcpu = svcpu_get(vcpu);
127 __entry->srr1 = svcpu->shadow_srr1;
128 svcpu_put(svcpu);
126 ), 129 ),
127 130
128 TP_printk("exit=0x%x | pc=0x%lx | msr=0x%lx | dar=0x%lx | srr1=0x%lx", 131 TP_printk("exit=0x%x | pc=0x%lx | msr=0x%lx | dar=0x%lx | srr1=0x%lx",
@@ -337,6 +340,63 @@ TRACE_EVENT(kvm_book3s_slbmte,
337 340
338#endif /* CONFIG_PPC_BOOK3S */ 341#endif /* CONFIG_PPC_BOOK3S */
339 342
343
344/*************************************************************************
345 * Book3E trace points *
346 *************************************************************************/
347
348#ifdef CONFIG_BOOKE
349
350TRACE_EVENT(kvm_booke206_stlb_write,
351 TP_PROTO(__u32 mas0, __u32 mas8, __u32 mas1, __u64 mas2, __u64 mas7_3),
352 TP_ARGS(mas0, mas8, mas1, mas2, mas7_3),
353
354 TP_STRUCT__entry(
355 __field( __u32, mas0 )
356 __field( __u32, mas8 )
357 __field( __u32, mas1 )
358 __field( __u64, mas2 )
359 __field( __u64, mas7_3 )
360 ),
361
362 TP_fast_assign(
363 __entry->mas0 = mas0;
364 __entry->mas8 = mas8;
365 __entry->mas1 = mas1;
366 __entry->mas2 = mas2;
367 __entry->mas7_3 = mas7_3;
368 ),
369
370 TP_printk("mas0=%x mas8=%x mas1=%x mas2=%llx mas7_3=%llx",
371 __entry->mas0, __entry->mas8, __entry->mas1,
372 __entry->mas2, __entry->mas7_3)
373);
374
375TRACE_EVENT(kvm_booke206_gtlb_write,
376 TP_PROTO(__u32 mas0, __u32 mas1, __u64 mas2, __u64 mas7_3),
377 TP_ARGS(mas0, mas1, mas2, mas7_3),
378
379 TP_STRUCT__entry(
380 __field( __u32, mas0 )
381 __field( __u32, mas1 )
382 __field( __u64, mas2 )
383 __field( __u64, mas7_3 )
384 ),
385
386 TP_fast_assign(
387 __entry->mas0 = mas0;
388 __entry->mas1 = mas1;
389 __entry->mas2 = mas2;
390 __entry->mas7_3 = mas7_3;
391 ),
392
393 TP_printk("mas0=%x mas1=%x mas2=%llx mas7_3=%llx",
394 __entry->mas0, __entry->mas1,
395 __entry->mas2, __entry->mas7_3)
396);
397
398#endif
399
340#endif /* _TRACE_KVM_H */ 400#endif /* _TRACE_KVM_H */
341 401
342/* This part must be outside protection */ 402/* This part must be outside protection */
diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
index 57c7465e656..fb05b123218 100644
--- a/arch/powerpc/mm/hugetlbpage.c
+++ b/arch/powerpc/mm/hugetlbpage.c
@@ -12,6 +12,7 @@
12#include <linux/io.h> 12#include <linux/io.h>
13#include <linux/slab.h> 13#include <linux/slab.h>
14#include <linux/hugetlb.h> 14#include <linux/hugetlb.h>
15#include <linux/export.h>
15#include <linux/of_fdt.h> 16#include <linux/of_fdt.h>
16#include <linux/memblock.h> 17#include <linux/memblock.h>
17#include <linux/bootmem.h> 18#include <linux/bootmem.h>
@@ -103,6 +104,7 @@ pte_t *find_linux_pte_or_hugepte(pgd_t *pgdir, unsigned long ea, unsigned *shift
103 *shift = hugepd_shift(*hpdp); 104 *shift = hugepd_shift(*hpdp);
104 return hugepte_offset(hpdp, ea, pdshift); 105 return hugepte_offset(hpdp, ea, pdshift);
105} 106}
107EXPORT_SYMBOL_GPL(find_linux_pte_or_hugepte);
106 108
107pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr) 109pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
108{ 110{
@@ -310,7 +312,8 @@ void __init reserve_hugetlb_gpages(void)
310 int i; 312 int i;
311 313
312 strlcpy(cmdline, boot_command_line, COMMAND_LINE_SIZE); 314 strlcpy(cmdline, boot_command_line, COMMAND_LINE_SIZE);
313 parse_args("hugetlb gpages", cmdline, NULL, 0, &do_gpage_early_setup); 315 parse_args("hugetlb gpages", cmdline, NULL, 0, 0, 0,
316 &do_gpage_early_setup);
314 317
315 /* 318 /*
316 * Walk gpage list in reverse, allocating larger page sizes first. 319 * Walk gpage list in reverse, allocating larger page sizes first.
diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
index c2e27ede07e..02aee03e713 100644
--- a/arch/powerpc/perf/core-book3s.c
+++ b/arch/powerpc/perf/core-book3s.c
@@ -116,14 +116,45 @@ static inline void perf_get_data_addr(struct pt_regs *regs, u64 *addrp)
116 *addrp = mfspr(SPRN_SDAR); 116 *addrp = mfspr(SPRN_SDAR);
117} 117}
118 118
119static inline u32 perf_flags_from_msr(struct pt_regs *regs)
120{
121 if (regs->msr & MSR_PR)
122 return PERF_RECORD_MISC_USER;
123 if ((regs->msr & MSR_HV) && freeze_events_kernel != MMCR0_FCHV)
124 return PERF_RECORD_MISC_HYPERVISOR;
125 return PERF_RECORD_MISC_KERNEL;
126}
127
119static inline u32 perf_get_misc_flags(struct pt_regs *regs) 128static inline u32 perf_get_misc_flags(struct pt_regs *regs)
120{ 129{
121 unsigned long mmcra = regs->dsisr; 130 unsigned long mmcra = regs->dsisr;
122 unsigned long sihv = MMCRA_SIHV; 131 unsigned long sihv = MMCRA_SIHV;
123 unsigned long sipr = MMCRA_SIPR; 132 unsigned long sipr = MMCRA_SIPR;
124 133
134 /* Not a PMU interrupt: Make up flags from regs->msr */
125 if (TRAP(regs) != 0xf00) 135 if (TRAP(regs) != 0xf00)
126 return 0; /* not a PMU interrupt */ 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);
145
146 /*
147 * If we don't have flags in MMCRA, rather than using
148 * the MSR, we intuit the flags from the address in
149 * SIAR which should give slightly more reliable
150 * results
151 */
152 if (ppmu->flags & PPMU_NO_SIPR) {
153 unsigned long siar = mfspr(SPRN_SIAR);
154 if (siar >= PAGE_OFFSET)
155 return PERF_RECORD_MISC_KERNEL;
156 return PERF_RECORD_MISC_USER;
157 }
127 158
128 if (ppmu->flags & PPMU_ALT_SIPR) { 159 if (ppmu->flags & PPMU_ALT_SIPR) {
129 sihv = POWER6_MMCRA_SIHV; 160 sihv = POWER6_MMCRA_SIHV;
@@ -1299,13 +1330,18 @@ unsigned long perf_misc_flags(struct pt_regs *regs)
1299 */ 1330 */
1300unsigned long perf_instruction_pointer(struct pt_regs *regs) 1331unsigned long perf_instruction_pointer(struct pt_regs *regs)
1301{ 1332{
1302 unsigned long ip; 1333 unsigned long mmcra = regs->dsisr;
1303 1334
1335 /* Not a PMU interrupt */
1304 if (TRAP(regs) != 0xf00) 1336 if (TRAP(regs) != 0xf00)
1305 return regs->nip; /* not a PMU interrupt */ 1337 return regs->nip;
1338
1339 /* Processor doesn't support sampling non marked events */
1340 if ((ppmu->flags & PPMU_NO_CONT_SAMPLING) &&
1341 !(mmcra & MMCRA_SAMPLE_ENABLE))
1342 return regs->nip;
1306 1343
1307 ip = mfspr(SPRN_SIAR) + perf_ip_adjust(regs); 1344 return mfspr(SPRN_SIAR) + perf_ip_adjust(regs);
1308 return ip;
1309} 1345}
1310 1346
1311static bool pmc_overflow(unsigned long val) 1347static bool pmc_overflow(unsigned long val)
diff --git a/arch/powerpc/perf/power4-pmu.c b/arch/powerpc/perf/power4-pmu.c
index b4f1dda4d08..9103a1de864 100644
--- a/arch/powerpc/perf/power4-pmu.c
+++ b/arch/powerpc/perf/power4-pmu.c
@@ -607,6 +607,7 @@ static struct power_pmu power4_pmu = {
607 .n_generic = ARRAY_SIZE(p4_generic_events), 607 .n_generic = ARRAY_SIZE(p4_generic_events),
608 .generic_events = p4_generic_events, 608 .generic_events = p4_generic_events,
609 .cache_events = &power4_cache_events, 609 .cache_events = &power4_cache_events,
610 .flags = PPMU_NO_SIPR | PPMU_NO_CONT_SAMPLING,
610}; 611};
611 612
612static int __init init_power4_pmu(void) 613static int __init init_power4_pmu(void)
diff --git a/arch/powerpc/perf/ppc970-pmu.c b/arch/powerpc/perf/ppc970-pmu.c
index 111eb25bb0b..20139ceeacf 100644
--- a/arch/powerpc/perf/ppc970-pmu.c
+++ b/arch/powerpc/perf/ppc970-pmu.c
@@ -487,6 +487,7 @@ static struct power_pmu ppc970_pmu = {
487 .n_generic = ARRAY_SIZE(ppc970_generic_events), 487 .n_generic = ARRAY_SIZE(ppc970_generic_events),
488 .generic_events = ppc970_generic_events, 488 .generic_events = ppc970_generic_events,
489 .cache_events = &ppc970_cache_events, 489 .cache_events = &ppc970_cache_events,
490 .flags = PPMU_NO_SIPR | PPMU_NO_CONT_SAMPLING,
490}; 491};
491 492
492static int __init init_ppc970_pmu(void) 493static int __init init_ppc970_pmu(void)
diff --git a/arch/powerpc/platforms/cell/beat_htab.c b/arch/powerpc/platforms/cell/beat_htab.c
index 2516c1cf846..943c9d39aa1 100644
--- a/arch/powerpc/platforms/cell/beat_htab.c
+++ b/arch/powerpc/platforms/cell/beat_htab.c
@@ -95,7 +95,6 @@ static long beat_lpar_hpte_insert(unsigned long hpte_group,
95 unsigned long lpar_rc; 95 unsigned long lpar_rc;
96 u64 hpte_v, hpte_r, slot; 96 u64 hpte_v, hpte_r, slot;
97 97
98 /* same as iseries */
99 if (vflags & HPTE_V_SECONDARY) 98 if (vflags & HPTE_V_SECONDARY)
100 return -1; 99 return -1;
101 100
@@ -319,7 +318,6 @@ static long beat_lpar_hpte_insert_v3(unsigned long hpte_group,
319 unsigned long lpar_rc; 318 unsigned long lpar_rc;
320 u64 hpte_v, hpte_r, slot; 319 u64 hpte_v, hpte_r, slot;
321 320
322 /* same as iseries */
323 if (vflags & HPTE_V_SECONDARY) 321 if (vflags & HPTE_V_SECONDARY)
324 return -1; 322 return -1;
325 323
diff --git a/arch/powerpc/platforms/maple/pci.c b/arch/powerpc/platforms/maple/pci.c
index 401e3f3f74c..465ee8f5c08 100644
--- a/arch/powerpc/platforms/maple/pci.c
+++ b/arch/powerpc/platforms/maple/pci.c
@@ -620,7 +620,7 @@ void __init maple_pci_init(void)
620 } 620 }
621 621
622 /* Tell pci.c to not change any resource allocations. */ 622 /* Tell pci.c to not change any resource allocations. */
623 pci_probe_only = 1; 623 pci_add_flags(PCI_PROBE_ONLY);
624} 624}
625 625
626int maple_pci_get_legacy_ide_irq(struct pci_dev *pdev, int channel) 626int maple_pci_get_legacy_ide_irq(struct pci_dev *pdev, int channel)
diff --git a/arch/powerpc/platforms/pasemi/pci.c b/arch/powerpc/platforms/pasemi/pci.c
index b6a0ec45c69..aa862713258 100644
--- a/arch/powerpc/platforms/pasemi/pci.c
+++ b/arch/powerpc/platforms/pasemi/pci.c
@@ -229,9 +229,6 @@ void __init pas_pci_init(void)
229 229
230 /* Setup the linkage between OF nodes and PHBs */ 230 /* Setup the linkage between OF nodes and PHBs */
231 pci_devs_phb_init(); 231 pci_devs_phb_init();
232
233 /* Use the common resource allocation mechanism */
234 pci_probe_only = 1;
235} 232}
236 233
237void __iomem *pasemi_pci_getcfgaddr(struct pci_dev *dev, int offset) 234void __iomem *pasemi_pci_getcfgaddr(struct pci_dev *dev, int offset)
diff --git a/arch/powerpc/platforms/powermac/pci.c b/arch/powerpc/platforms/powermac/pci.c
index 31a7d3a7ce2..43bbe1bda93 100644
--- a/arch/powerpc/platforms/powermac/pci.c
+++ b/arch/powerpc/platforms/powermac/pci.c
@@ -1059,9 +1059,6 @@ void __init pmac_pci_init(void)
1059 } 1059 }
1060 /* pmac_check_ht_link(); */ 1060 /* pmac_check_ht_link(); */
1061 1061
1062 /* We can allocate missing resources if any */
1063 pci_probe_only = 0;
1064
1065#else /* CONFIG_PPC64 */ 1062#else /* CONFIG_PPC64 */
1066 init_p2pbridge(); 1063 init_p2pbridge();
1067 init_second_ohare(); 1064 init_second_ohare();
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index 5e155dfc432..fbdd74dac3a 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -1299,15 +1299,14 @@ void __init pnv_pci_init_ioda1_phb(struct device_node *np)
1299 /* Setup MSI support */ 1299 /* Setup MSI support */
1300 pnv_pci_init_ioda_msis(phb); 1300 pnv_pci_init_ioda_msis(phb);
1301 1301
1302 /* We set both probe_only and PCI_REASSIGN_ALL_RSRC. This is an 1302 /* We set both PCI_PROBE_ONLY and PCI_REASSIGN_ALL_RSRC. This is an
1303 * odd combination which essentially means that we skip all resource 1303 * odd combination which essentially means that we skip all resource
1304 * fixups and assignments in the generic code, and do it all 1304 * fixups and assignments in the generic code, and do it all
1305 * ourselves here 1305 * ourselves here
1306 */ 1306 */
1307 pci_probe_only = 1;
1308 ppc_md.pcibios_fixup_phb = pnv_pci_ioda_fixup_phb; 1307 ppc_md.pcibios_fixup_phb = pnv_pci_ioda_fixup_phb;
1309 ppc_md.pcibios_enable_device_hook = pnv_pci_enable_device_hook; 1308 ppc_md.pcibios_enable_device_hook = pnv_pci_enable_device_hook;
1310 pci_add_flags(PCI_REASSIGN_ALL_RSRC); 1309 pci_add_flags(PCI_PROBE_ONLY | PCI_REASSIGN_ALL_RSRC);
1311 1310
1312 /* Reset IODA tables to a clean state */ 1311 /* Reset IODA tables to a clean state */
1313 rc = opal_pci_reset(phb_id, OPAL_PCI_IODA_TABLE_RESET, OPAL_ASSERT_RESET); 1312 rc = opal_pci_reset(phb_id, OPAL_PCI_IODA_TABLE_RESET, OPAL_ASSERT_RESET);
diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c
index 214478d781a..be3cfc5ceab 100644
--- a/arch/powerpc/platforms/powernv/pci.c
+++ b/arch/powerpc/platforms/powernv/pci.c
@@ -562,10 +562,7 @@ void __init pnv_pci_init(void)
562{ 562{
563 struct device_node *np; 563 struct device_node *np;
564 564
565 pci_set_flags(PCI_CAN_SKIP_ISA_ALIGN); 565 pci_add_flags(PCI_CAN_SKIP_ISA_ALIGN);
566
567 /* We do not want to just probe */
568 pci_probe_only = 0;
569 566
570 /* OPAL absent, try POPAL first then RTAS detection of PHBs */ 567 /* OPAL absent, try POPAL first then RTAS detection of PHBs */
571 if (!firmware_has_feature(FW_FEATURE_OPAL)) { 568 if (!firmware_has_feature(FW_FEATURE_OPAL)) {
diff --git a/arch/powerpc/platforms/pseries/eeh.c b/arch/powerpc/platforms/pseries/eeh.c
index 8011088392d..309d38ef732 100644
--- a/arch/powerpc/platforms/pseries/eeh.c
+++ b/arch/powerpc/platforms/pseries/eeh.c
@@ -984,7 +984,8 @@ int __exit eeh_ops_unregister(const char *name)
984 */ 984 */
985void __init eeh_init(void) 985void __init eeh_init(void)
986{ 986{
987 struct device_node *phb, *np; 987 struct pci_controller *hose, *tmp;
988 struct device_node *phb;
988 int ret; 989 int ret;
989 990
990 /* call platform initialization function */ 991 /* call platform initialization function */
@@ -1000,19 +1001,9 @@ void __init eeh_init(void)
1000 1001
1001 raw_spin_lock_init(&confirm_error_lock); 1002 raw_spin_lock_init(&confirm_error_lock);
1002 1003
1003 np = of_find_node_by_path("/rtas"); 1004 /* Enable EEH for all adapters */
1004 if (np == NULL) 1005 list_for_each_entry_safe(hose, tmp, &hose_list, list_node) {
1005 return; 1006 phb = hose->dn;
1006
1007 /* Enable EEH for all adapters. Note that eeh requires buid's */
1008 for (phb = of_find_node_by_name(NULL, "pci"); phb;
1009 phb = of_find_node_by_name(phb, "pci")) {
1010 unsigned long buid;
1011
1012 buid = get_phb_buid(phb);
1013 if (buid == 0 || !of_node_to_eeh_dev(phb))
1014 continue;
1015
1016 traverse_pci_devices(phb, eeh_early_enable, NULL); 1007 traverse_pci_devices(phb, eeh_early_enable, NULL);
1017 } 1008 }
1018 1009
diff --git a/arch/powerpc/platforms/pseries/eeh_dev.c b/arch/powerpc/platforms/pseries/eeh_dev.c
index f3aed7dcae9..c4507d09590 100644
--- a/arch/powerpc/platforms/pseries/eeh_dev.c
+++ b/arch/powerpc/platforms/pseries/eeh_dev.c
@@ -62,7 +62,7 @@ void * __devinit eeh_dev_init(struct device_node *dn, void *data)
62 } 62 }
63 63
64 /* Associate EEH device with OF node */ 64 /* Associate EEH device with OF node */
65 dn->edev = edev; 65 PCI_DN(dn)->edev = edev;
66 edev->dn = dn; 66 edev->dn = dn;
67 edev->phb = phb; 67 edev->phb = phb;
68 68
diff --git a/arch/powerpc/platforms/pseries/io_event_irq.c b/arch/powerpc/platforms/pseries/io_event_irq.c
index 1a709bc48ce..ef9d9d84c7d 100644
--- a/arch/powerpc/platforms/pseries/io_event_irq.c
+++ b/arch/powerpc/platforms/pseries/io_event_irq.c
@@ -63,73 +63,9 @@ EXPORT_SYMBOL_GPL(pseries_ioei_notifier_list);
63 63
64static int ioei_check_exception_token; 64static int ioei_check_exception_token;
65 65
66/* pSeries event log format */
67
68/* Two bytes ASCII section IDs */
69#define PSERIES_ELOG_SECT_ID_PRIV_HDR (('P' << 8) | 'H')
70#define PSERIES_ELOG_SECT_ID_USER_HDR (('U' << 8) | 'H')
71#define PSERIES_ELOG_SECT_ID_PRIMARY_SRC (('P' << 8) | 'S')
72#define PSERIES_ELOG_SECT_ID_EXTENDED_UH (('E' << 8) | 'H')
73#define PSERIES_ELOG_SECT_ID_FAILING_MTMS (('M' << 8) | 'T')
74#define PSERIES_ELOG_SECT_ID_SECONDARY_SRC (('S' << 8) | 'S')
75#define PSERIES_ELOG_SECT_ID_DUMP_LOCATOR (('D' << 8) | 'H')
76#define PSERIES_ELOG_SECT_ID_FW_ERROR (('S' << 8) | 'W')
77#define PSERIES_ELOG_SECT_ID_IMPACT_PART_ID (('L' << 8) | 'P')
78#define PSERIES_ELOG_SECT_ID_LOGIC_RESOURCE_ID (('L' << 8) | 'R')
79#define PSERIES_ELOG_SECT_ID_HMC_ID (('H' << 8) | 'M')
80#define PSERIES_ELOG_SECT_ID_EPOW (('E' << 8) | 'P')
81#define PSERIES_ELOG_SECT_ID_IO_EVENT (('I' << 8) | 'E')
82#define PSERIES_ELOG_SECT_ID_MANUFACT_INFO (('M' << 8) | 'I')
83#define PSERIES_ELOG_SECT_ID_CALL_HOME (('C' << 8) | 'H')
84#define PSERIES_ELOG_SECT_ID_USER_DEF (('U' << 8) | 'D')
85
86/* Vendor specific Platform Event Log Format, Version 6, section header */
87struct pseries_elog_section {
88 uint16_t id; /* 0x00 2-byte ASCII section ID */
89 uint16_t length; /* 0x02 Section length in bytes */
90 uint8_t version; /* 0x04 Section version */
91 uint8_t subtype; /* 0x05 Section subtype */
92 uint16_t creator_component; /* 0x06 Creator component ID */
93 uint8_t data[]; /* 0x08 Start of section data */
94};
95
96static char ioei_rtas_buf[RTAS_DATA_BUF_SIZE] __cacheline_aligned; 66static char ioei_rtas_buf[RTAS_DATA_BUF_SIZE] __cacheline_aligned;
97 67
98/** 68/**
99 * Find data portion of a specific section in RTAS extended event log.
100 * @elog: RTAS error/event log.
101 * @sect_id: secsion ID.
102 *
103 * Return:
104 * pointer to the section data of the specified section
105 * NULL if not found
106 */
107static struct pseries_elog_section *find_xelog_section(struct rtas_error_log *elog,
108 uint16_t sect_id)
109{
110 struct rtas_ext_event_log_v6 *xelog =
111 (struct rtas_ext_event_log_v6 *) elog->buffer;
112 struct pseries_elog_section *sect;
113 unsigned char *p, *log_end;
114
115 /* Check that we understand the format */
116 if (elog->extended_log_length < sizeof(struct rtas_ext_event_log_v6) ||
117 xelog->log_format != RTAS_V6EXT_LOG_FORMAT_EVENT_LOG ||
118 xelog->company_id != RTAS_V6EXT_COMPANY_ID_IBM)
119 return NULL;
120
121 log_end = elog->buffer + elog->extended_log_length;
122 p = xelog->vendor_log;
123 while (p < log_end) {
124 sect = (struct pseries_elog_section *)p;
125 if (sect->id == sect_id)
126 return sect;
127 p += sect->length;
128 }
129 return NULL;
130}
131
132/**
133 * Find the data portion of an IO Event section from event log. 69 * Find the data portion of an IO Event section from event log.
134 * @elog: RTAS error/event log. 70 * @elog: RTAS error/event log.
135 * 71 *
@@ -138,7 +74,7 @@ static struct pseries_elog_section *find_xelog_section(struct rtas_error_log *el
138 */ 74 */
139static struct pseries_io_event * ioei_find_event(struct rtas_error_log *elog) 75static struct pseries_io_event * ioei_find_event(struct rtas_error_log *elog)
140{ 76{
141 struct pseries_elog_section *sect; 77 struct pseries_errorlog *sect;
142 78
143 /* We should only ever get called for io-event interrupts, but if 79 /* We should only ever get called for io-event interrupts, but if
144 * we do get called for another type then something went wrong so 80 * we do get called for another type then something went wrong so
@@ -152,7 +88,7 @@ static struct pseries_io_event * ioei_find_event(struct rtas_error_log *elog)
152 return NULL; 88 return NULL;
153 } 89 }
154 90
155 sect = find_xelog_section(elog, PSERIES_ELOG_SECT_ID_IO_EVENT); 91 sect = get_pseries_errorlog(elog, PSERIES_ELOG_SECT_ID_IO_EVENT);
156 if (unlikely(!sect)) { 92 if (unlikely(!sect)) {
157 printk_once(KERN_WARNING "io_event_irq: RTAS extended event " 93 printk_once(KERN_WARNING "io_event_irq: RTAS extended event "
158 "log does not contain an IO Event section. " 94 "log does not contain an IO Event section. "
diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index c442f2b1980..0915b1ad66c 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -809,8 +809,7 @@ machine_arch_initcall(pseries, find_existing_ddw_windows);
809static int query_ddw(struct pci_dev *dev, const u32 *ddw_avail, 809static int query_ddw(struct pci_dev *dev, const u32 *ddw_avail,
810 struct ddw_query_response *query) 810 struct ddw_query_response *query)
811{ 811{
812 struct device_node *dn; 812 struct eeh_dev *edev;
813 struct pci_dn *pcidn;
814 u32 cfg_addr; 813 u32 cfg_addr;
815 u64 buid; 814 u64 buid;
816 int ret; 815 int ret;
@@ -821,12 +820,12 @@ static int query_ddw(struct pci_dev *dev, const u32 *ddw_avail,
821 * Retrieve them from the pci device, not the node with the 820 * Retrieve them from the pci device, not the node with the
822 * dma-window property 821 * dma-window property
823 */ 822 */
824 dn = pci_device_to_OF_node(dev); 823 edev = pci_dev_to_eeh_dev(dev);
825 pcidn = PCI_DN(dn); 824 cfg_addr = edev->config_addr;
826 cfg_addr = pcidn->eeh_config_addr; 825 if (edev->pe_config_addr)
827 if (pcidn->eeh_pe_config_addr) 826 cfg_addr = edev->pe_config_addr;
828 cfg_addr = pcidn->eeh_pe_config_addr; 827 buid = edev->phb->buid;
829 buid = pcidn->phb->buid; 828
830 ret = rtas_call(ddw_avail[0], 3, 5, (u32 *)query, 829 ret = rtas_call(ddw_avail[0], 3, 5, (u32 *)query,
831 cfg_addr, BUID_HI(buid), BUID_LO(buid)); 830 cfg_addr, BUID_HI(buid), BUID_LO(buid));
832 dev_info(&dev->dev, "ibm,query-pe-dma-windows(%x) %x %x %x" 831 dev_info(&dev->dev, "ibm,query-pe-dma-windows(%x) %x %x %x"
@@ -839,8 +838,7 @@ static int create_ddw(struct pci_dev *dev, const u32 *ddw_avail,
839 struct ddw_create_response *create, int page_shift, 838 struct ddw_create_response *create, int page_shift,
840 int window_shift) 839 int window_shift)
841{ 840{
842 struct device_node *dn; 841 struct eeh_dev *edev;
843 struct pci_dn *pcidn;
844 u32 cfg_addr; 842 u32 cfg_addr;
845 u64 buid; 843 u64 buid;
846 int ret; 844 int ret;
@@ -851,12 +849,11 @@ static int create_ddw(struct pci_dev *dev, const u32 *ddw_avail,
851 * Retrieve them from the pci device, not the node with the 849 * Retrieve them from the pci device, not the node with the
852 * dma-window property 850 * dma-window property
853 */ 851 */
854 dn = pci_device_to_OF_node(dev); 852 edev = pci_dev_to_eeh_dev(dev);
855 pcidn = PCI_DN(dn); 853 cfg_addr = edev->config_addr;
856 cfg_addr = pcidn->eeh_config_addr; 854 if (edev->pe_config_addr)
857 if (pcidn->eeh_pe_config_addr) 855 cfg_addr = edev->pe_config_addr;
858 cfg_addr = pcidn->eeh_pe_config_addr; 856 buid = edev->phb->buid;
859 buid = pcidn->phb->buid;
860 857
861 do { 858 do {
862 /* extra outputs are LIOBN and dma-addr (hi, lo) */ 859 /* extra outputs are LIOBN and dma-addr (hi, lo) */
diff --git a/arch/powerpc/platforms/pseries/pci_dlpar.c b/arch/powerpc/platforms/pseries/pci_dlpar.c
index fbb21fc3080..8b7bafa489c 100644
--- a/arch/powerpc/platforms/pseries/pci_dlpar.c
+++ b/arch/powerpc/platforms/pseries/pci_dlpar.c
@@ -84,7 +84,7 @@ void pcibios_remove_pci_devices(struct pci_bus *bus)
84 list_for_each_entry_safe(dev, tmp, &bus->devices, bus_list) { 84 list_for_each_entry_safe(dev, tmp, &bus->devices, bus_list) {
85 pr_debug(" * Removing %s...\n", pci_name(dev)); 85 pr_debug(" * Removing %s...\n", pci_name(dev));
86 eeh_remove_bus_device(dev); 86 eeh_remove_bus_device(dev);
87 pci_remove_bus_device(dev); 87 pci_stop_and_remove_bus_device(dev);
88 } 88 }
89} 89}
90EXPORT_SYMBOL_GPL(pcibios_remove_pci_devices); 90EXPORT_SYMBOL_GPL(pcibios_remove_pci_devices);
diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powerpc/platforms/pseries/ras.c
index 9e248ef6cc6..c4dfccd3a3d 100644
--- a/arch/powerpc/platforms/pseries/ras.c
+++ b/arch/powerpc/platforms/pseries/ras.c
@@ -16,36 +16,15 @@
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 18
19/* Change Activity:
20 * 2001/09/21 : engebret : Created with minimal EPOW and HW exception support.
21 * End Change Activity
22 */
23
24#include <linux/errno.h>
25#include <linux/threads.h>
26#include <linux/kernel_stat.h>
27#include <linux/signal.h>
28#include <linux/sched.h> 19#include <linux/sched.h>
29#include <linux/ioport.h>
30#include <linux/interrupt.h> 20#include <linux/interrupt.h>
31#include <linux/timex.h>
32#include <linux/init.h>
33#include <linux/delay.h>
34#include <linux/irq.h> 21#include <linux/irq.h>
35#include <linux/random.h> 22#include <linux/of.h>
36#include <linux/sysrq.h> 23#include <linux/fs.h>
37#include <linux/bitops.h> 24#include <linux/reboot.h>
38 25
39#include <asm/uaccess.h>
40#include <asm/io.h>
41#include <asm/pgtable.h>
42#include <asm/irq.h>
43#include <asm/cache.h>
44#include <asm/prom.h>
45#include <asm/ptrace.h>
46#include <asm/machdep.h> 26#include <asm/machdep.h>
47#include <asm/rtas.h> 27#include <asm/rtas.h>
48#include <asm/udbg.h>
49#include <asm/firmware.h> 28#include <asm/firmware.h>
50 29
51#include "pseries.h" 30#include "pseries.h"
@@ -56,7 +35,6 @@ static DEFINE_SPINLOCK(ras_log_buf_lock);
56static char global_mce_data_buf[RTAS_ERROR_LOG_MAX]; 35static char global_mce_data_buf[RTAS_ERROR_LOG_MAX];
57static DEFINE_PER_CPU(__u64, mce_data_buf); 36static DEFINE_PER_CPU(__u64, mce_data_buf);
58 37
59static int ras_get_sensor_state_token;
60static int ras_check_exception_token; 38static int ras_check_exception_token;
61 39
62#define EPOW_SENSOR_TOKEN 9 40#define EPOW_SENSOR_TOKEN 9
@@ -74,7 +52,6 @@ static int __init init_ras_IRQ(void)
74{ 52{
75 struct device_node *np; 53 struct device_node *np;
76 54
77 ras_get_sensor_state_token = rtas_token("get-sensor-state");
78 ras_check_exception_token = rtas_token("check-exception"); 55 ras_check_exception_token = rtas_token("check-exception");
79 56
80 /* Internal Errors */ 57 /* Internal Errors */
@@ -94,26 +71,126 @@ static int __init init_ras_IRQ(void)
94 71
95 return 0; 72 return 0;
96} 73}
97__initcall(init_ras_IRQ); 74subsys_initcall(init_ras_IRQ);
98 75
99/* 76#define EPOW_SHUTDOWN_NORMAL 1
100 * Handle power subsystem events (EPOW). 77#define EPOW_SHUTDOWN_ON_UPS 2
101 * 78#define EPOW_SHUTDOWN_LOSS_OF_CRITICAL_FUNCTIONS 3
102 * Presently we just log the event has occurred. This should be fixed 79#define EPOW_SHUTDOWN_AMBIENT_TEMPERATURE_TOO_HIGH 4
103 * to examine the type of power failure and take appropriate action where 80
104 * the time horizon permits something useful to be done. 81static void handle_system_shutdown(char event_modifier)
105 */ 82{
83 switch (event_modifier) {
84 case EPOW_SHUTDOWN_NORMAL:
85 pr_emerg("Firmware initiated power off");
86 orderly_poweroff(1);
87 break;
88
89 case EPOW_SHUTDOWN_ON_UPS:
90 pr_emerg("Loss of power reported by firmware, system is "
91 "running on UPS/battery");
92 break;
93
94 case EPOW_SHUTDOWN_LOSS_OF_CRITICAL_FUNCTIONS:
95 pr_emerg("Loss of system critical functions reported by "
96 "firmware");
97 pr_emerg("Check RTAS error log for details");
98 orderly_poweroff(1);
99 break;
100
101 case EPOW_SHUTDOWN_AMBIENT_TEMPERATURE_TOO_HIGH:
102 pr_emerg("Ambient temperature too high reported by firmware");
103 pr_emerg("Check RTAS error log for details");
104 orderly_poweroff(1);
105 break;
106
107 default:
108 pr_err("Unknown power/cooling shutdown event (modifier %d)",
109 event_modifier);
110 }
111}
112
113struct epow_errorlog {
114 unsigned char sensor_value;
115 unsigned char event_modifier;
116 unsigned char extended_modifier;
117 unsigned char reserved;
118 unsigned char platform_reason;
119};
120
121#define EPOW_RESET 0
122#define EPOW_WARN_COOLING 1
123#define EPOW_WARN_POWER 2
124#define EPOW_SYSTEM_SHUTDOWN 3
125#define EPOW_SYSTEM_HALT 4
126#define EPOW_MAIN_ENCLOSURE 5
127#define EPOW_POWER_OFF 7
128
129void rtas_parse_epow_errlog(struct rtas_error_log *log)
130{
131 struct pseries_errorlog *pseries_log;
132 struct epow_errorlog *epow_log;
133 char action_code;
134 char modifier;
135
136 pseries_log = get_pseries_errorlog(log, PSERIES_ELOG_SECT_ID_EPOW);
137 if (pseries_log == NULL)
138 return;
139
140 epow_log = (struct epow_errorlog *)pseries_log->data;
141 action_code = epow_log->sensor_value & 0xF; /* bottom 4 bits */
142 modifier = epow_log->event_modifier & 0xF; /* bottom 4 bits */
143
144 switch (action_code) {
145 case EPOW_RESET:
146 pr_err("Non critical power or cooling issue cleared");
147 break;
148
149 case EPOW_WARN_COOLING:
150 pr_err("Non critical cooling issue reported by firmware");
151 pr_err("Check RTAS error log for details");
152 break;
153
154 case EPOW_WARN_POWER:
155 pr_err("Non critical power issue reported by firmware");
156 pr_err("Check RTAS error log for details");
157 break;
158
159 case EPOW_SYSTEM_SHUTDOWN:
160 handle_system_shutdown(epow_log->event_modifier);
161 break;
162
163 case EPOW_SYSTEM_HALT:
164 pr_emerg("Firmware initiated power off");
165 orderly_poweroff(1);
166 break;
167
168 case EPOW_MAIN_ENCLOSURE:
169 case EPOW_POWER_OFF:
170 pr_emerg("Critical power/cooling issue reported by firmware");
171 pr_emerg("Check RTAS error log for details");
172 pr_emerg("Immediate power off");
173 emergency_sync();
174 kernel_power_off();
175 break;
176
177 default:
178 pr_err("Unknown power/cooling event (action code %d)",
179 action_code);
180 }
181}
182
183/* Handle environmental and power warning (EPOW) interrupts. */
106static irqreturn_t ras_epow_interrupt(int irq, void *dev_id) 184static irqreturn_t ras_epow_interrupt(int irq, void *dev_id)
107{ 185{
108 int status = 0xdeadbeef; 186 int status;
109 int state = 0; 187 int state;
110 int critical; 188 int critical;
111 189
112 status = rtas_call(ras_get_sensor_state_token, 2, 2, &state, 190 status = rtas_get_sensor(EPOW_SENSOR_TOKEN, EPOW_SENSOR_INDEX, &state);
113 EPOW_SENSOR_TOKEN, EPOW_SENSOR_INDEX);
114 191
115 if (state > 3) 192 if (state > 3)
116 critical = 1; /* Time Critical */ 193 critical = 1; /* Time Critical */
117 else 194 else
118 critical = 0; 195 critical = 0;
119 196
@@ -122,18 +199,14 @@ static irqreturn_t ras_epow_interrupt(int irq, void *dev_id)
122 status = rtas_call(ras_check_exception_token, 6, 1, NULL, 199 status = rtas_call(ras_check_exception_token, 6, 1, NULL,
123 RTAS_VECTOR_EXTERNAL_INTERRUPT, 200 RTAS_VECTOR_EXTERNAL_INTERRUPT,
124 virq_to_hw(irq), 201 virq_to_hw(irq),
125 RTAS_EPOW_WARNING | RTAS_POWERMGM_EVENTS, 202 RTAS_EPOW_WARNING,
126 critical, __pa(&ras_log_buf), 203 critical, __pa(&ras_log_buf),
127 rtas_get_error_log_max()); 204 rtas_get_error_log_max());
128 205
129 udbg_printf("EPOW <0x%lx 0x%x 0x%x>\n",
130 *((unsigned long *)&ras_log_buf), status, state);
131 printk(KERN_WARNING "EPOW <0x%lx 0x%x 0x%x>\n",
132 *((unsigned long *)&ras_log_buf), status, state);
133
134 /* format and print the extended information */
135 log_error(ras_log_buf, ERR_TYPE_RTAS_LOG, 0); 206 log_error(ras_log_buf, ERR_TYPE_RTAS_LOG, 0);
136 207
208 rtas_parse_epow_errlog((struct rtas_error_log *)ras_log_buf);
209
137 spin_unlock(&ras_log_buf_lock); 210 spin_unlock(&ras_log_buf_lock);
138 return IRQ_HANDLED; 211 return IRQ_HANDLED;
139} 212}
@@ -149,7 +222,7 @@ static irqreturn_t ras_epow_interrupt(int irq, void *dev_id)
149static irqreturn_t ras_error_interrupt(int irq, void *dev_id) 222static irqreturn_t ras_error_interrupt(int irq, void *dev_id)
150{ 223{
151 struct rtas_error_log *rtas_elog; 224 struct rtas_error_log *rtas_elog;
152 int status = 0xdeadbeef; 225 int status;
153 int fatal; 226 int fatal;
154 227
155 spin_lock(&ras_log_buf_lock); 228 spin_lock(&ras_log_buf_lock);
@@ -157,7 +230,7 @@ static irqreturn_t ras_error_interrupt(int irq, void *dev_id)
157 status = rtas_call(ras_check_exception_token, 6, 1, NULL, 230 status = rtas_call(ras_check_exception_token, 6, 1, NULL,
158 RTAS_VECTOR_EXTERNAL_INTERRUPT, 231 RTAS_VECTOR_EXTERNAL_INTERRUPT,
159 virq_to_hw(irq), 232 virq_to_hw(irq),
160 RTAS_INTERNAL_ERROR, 1 /*Time Critical */, 233 RTAS_INTERNAL_ERROR, 1 /* Time Critical */,
161 __pa(&ras_log_buf), 234 __pa(&ras_log_buf),
162 rtas_get_error_log_max()); 235 rtas_get_error_log_max());
163 236
@@ -172,24 +245,13 @@ static irqreturn_t ras_error_interrupt(int irq, void *dev_id)
172 log_error(ras_log_buf, ERR_TYPE_RTAS_LOG, fatal); 245 log_error(ras_log_buf, ERR_TYPE_RTAS_LOG, fatal);
173 246
174 if (fatal) { 247 if (fatal) {
175 udbg_printf("Fatal HW Error <0x%lx 0x%x>\n", 248 pr_emerg("Fatal hardware error reported by firmware");
176 *((unsigned long *)&ras_log_buf), status); 249 pr_emerg("Check RTAS error log for details");
177 printk(KERN_EMERG "Error: Fatal hardware error <0x%lx 0x%x>\n", 250 pr_emerg("Immediate power off");
178 *((unsigned long *)&ras_log_buf), status); 251 emergency_sync();
179 252 kernel_power_off();
180#ifndef DEBUG_RTAS_POWER_OFF
181 /* Don't actually power off when debugging so we can test
182 * without actually failing while injecting errors.
183 * Error data will not be logged to syslog.
184 */
185 ppc_md.power_off();
186#endif
187 } else { 253 } else {
188 udbg_printf("Recoverable HW Error <0x%lx 0x%x>\n", 254 pr_err("Recoverable hardware error reported by firmware");
189 *((unsigned long *)&ras_log_buf), status);
190 printk(KERN_WARNING
191 "Warning: Recoverable hardware error <0x%lx 0x%x>\n",
192 *((unsigned long *)&ras_log_buf), status);
193 } 255 }
194 256
195 spin_unlock(&ras_log_buf_lock); 257 spin_unlock(&ras_log_buf_lock);
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index 8f137af616a..51ecac920dd 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -383,6 +383,9 @@ static void __init pSeries_setup_arch(void)
383 383
384 fwnmi_init(); 384 fwnmi_init();
385 385
386 /* By default, only probe PCI (can be overriden by rtas_pci) */
387 pci_add_flags(PCI_PROBE_ONLY);
388
386 /* Find and initialize PCI host bridges */ 389 /* Find and initialize PCI host bridges */
387 init_pci_config_tokens(); 390 init_pci_config_tokens();
388 eeh_pseries_init(); 391 eeh_pseries_init();
diff --git a/arch/powerpc/platforms/wsp/wsp_pci.c b/arch/powerpc/platforms/wsp/wsp_pci.c
index 386879412e9..1526551f9fe 100644
--- a/arch/powerpc/platforms/wsp/wsp_pci.c
+++ b/arch/powerpc/platforms/wsp/wsp_pci.c
@@ -683,7 +683,6 @@ static int __init wsp_setup_one_phb(struct device_node *np)
683 /* XXX Force re-assigning of everything for now */ 683 /* XXX Force re-assigning of everything for now */
684 pci_add_flags(PCI_REASSIGN_ALL_BUS | PCI_REASSIGN_ALL_RSRC | 684 pci_add_flags(PCI_REASSIGN_ALL_BUS | PCI_REASSIGN_ALL_RSRC |
685 PCI_ENABLE_PROC_DOMAINS); 685 PCI_ENABLE_PROC_DOMAINS);
686 pci_probe_only = 0;
687 686
688 /* Calculate how the TCE space is divided */ 687 /* Calculate how the TCE space is divided */
689 phb->dma32_base = 0; 688 phb->dma32_base = 0;
diff --git a/arch/powerpc/xmon/ppc-opc.c b/arch/powerpc/xmon/ppc-opc.c
index af3780e52e7..6845e91ba04 100644
--- a/arch/powerpc/xmon/ppc-opc.c
+++ b/arch/powerpc/xmon/ppc-opc.c
@@ -22,6 +22,7 @@
22 22
23#include <linux/stddef.h> 23#include <linux/stddef.h>
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/bug.h>
25#include "nonstdio.h" 26#include "nonstdio.h"
26#include "ppc.h" 27#include "ppc.h"
27 28
diff --git a/arch/powerpc/xmon/spu-opc.c b/arch/powerpc/xmon/spu-opc.c
index 530df3d6d7b..7d37597c4bc 100644
--- a/arch/powerpc/xmon/spu-opc.c
+++ b/arch/powerpc/xmon/spu-opc.c
@@ -19,6 +19,7 @@
19 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ 19 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
20 20
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/bug.h>
22#include "spu.h" 23#include "spu.h"
23 24
24/* This file holds the Spu opcode table */ 25/* This file holds the Spu opcode table */
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 6d99a5fcc09..465d5be1f0f 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -64,6 +64,7 @@ config ARCH_SUPPORTS_DEBUG_PAGEALLOC
64config S390 64config S390
65 def_bool y 65 def_bool y
66 select USE_GENERIC_SMP_HELPERS if SMP 66 select USE_GENERIC_SMP_HELPERS if SMP
67 select GENERIC_CPU_DEVICES if !SMP
67 select HAVE_SYSCALL_WRAPPERS 68 select HAVE_SYSCALL_WRAPPERS
68 select HAVE_FUNCTION_TRACER 69 select HAVE_FUNCTION_TRACER
69 select HAVE_FUNCTION_TRACE_MCOUNT_TEST 70 select HAVE_FUNCTION_TRACE_MCOUNT_TEST
diff --git a/arch/s390/include/asm/cpu_mf.h b/arch/s390/include/asm/cpu_mf.h
new file mode 100644
index 00000000000..e49db5d5d06
--- /dev/null
+++ b/arch/s390/include/asm/cpu_mf.h
@@ -0,0 +1,95 @@
1/*
2 * CPU-measurement facilities
3 *
4 * Copyright IBM Corp. 2012
5 * Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
6 * Jan Glauber <jang@linux.vnet.ibm.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License (version 2 only)
10 * as published by the Free Software Foundation.
11 */
12#ifndef _ASM_S390_CPU_MF_H
13#define _ASM_S390_CPU_MF_H
14
15#define CPU_MF_INT_SF_IAE (1 << 31) /* invalid entry address */
16#define CPU_MF_INT_SF_ISE (1 << 30) /* incorrect SDBT entry */
17#define CPU_MF_INT_SF_PRA (1 << 29) /* program request alert */
18#define CPU_MF_INT_SF_SACA (1 << 23) /* sampler auth. change alert */
19#define CPU_MF_INT_SF_LSDA (1 << 22) /* loss of sample data alert */
20#define CPU_MF_INT_CF_CACA (1 << 7) /* counter auth. change alert */
21#define CPU_MF_INT_CF_LCDA (1 << 6) /* loss of counter data alert */
22
23#define CPU_MF_INT_CF_MASK (CPU_MF_INT_CF_CACA|CPU_MF_INT_CF_LCDA)
24#define CPU_MF_INT_SF_MASK (CPU_MF_INT_SF_IAE|CPU_MF_INT_SF_ISE| \
25 CPU_MF_INT_SF_PRA|CPU_MF_INT_SF_SACA| \
26 CPU_MF_INT_SF_LSDA)
27
28/* CPU measurement facility support */
29static inline int cpum_cf_avail(void)
30{
31 return MACHINE_HAS_SPP && test_facility(67);
32}
33
34static inline int cpum_sf_avail(void)
35{
36 return MACHINE_HAS_SPP && test_facility(68);
37}
38
39
40struct cpumf_ctr_info {
41 u16 cfvn;
42 u16 auth_ctl;
43 u16 enable_ctl;
44 u16 act_ctl;
45 u16 max_cpu;
46 u16 csvn;
47 u16 max_cg;
48 u16 reserved1;
49 u32 reserved2[12];
50} __packed;
51
52/* Query counter information */
53static inline int qctri(struct cpumf_ctr_info *info)
54{
55 int rc = -EINVAL;
56
57 asm volatile (
58 "0: .insn s,0xb28e0000,%1\n"
59 "1: lhi %0,0\n"
60 "2:\n"
61 EX_TABLE(1b, 2b)
62 : "+d" (rc), "=Q" (*info));
63 return rc;
64}
65
66/* Load CPU-counter-set controls */
67static inline int lcctl(u64 ctl)
68{
69 int cc;
70
71 asm volatile (
72 " .insn s,0xb2840000,%1\n"
73 " ipm %0\n"
74 " srl %0,28\n"
75 : "=d" (cc) : "m" (ctl) : "cc");
76 return cc;
77}
78
79/* Extract CPU counter */
80static inline int ecctr(u64 ctr, u64 *val)
81{
82 register u64 content asm("4") = 0;
83 int cc;
84
85 asm volatile (
86 " .insn rre,0xb2e40000,%0,%2\n"
87 " ipm %1\n"
88 " srl %1,28\n"
89 : "=d" (content), "=d" (cc) : "d" (ctr) : "cc");
90 if (!cc)
91 *val = content;
92 return cc;
93}
94
95#endif /* _ASM_S390_CPU_MF_H */
diff --git a/arch/s390/include/asm/irq.h b/arch/s390/include/asm/irq.h
index acee1806f61..5289cacd486 100644
--- a/arch/s390/include/asm/irq.h
+++ b/arch/s390/include/asm/irq.h
@@ -45,5 +45,7 @@ int register_external_interrupt(u16 code, ext_int_handler_t handler);
45int unregister_external_interrupt(u16 code, ext_int_handler_t handler); 45int unregister_external_interrupt(u16 code, ext_int_handler_t handler);
46void service_subclass_irq_register(void); 46void service_subclass_irq_register(void);
47void service_subclass_irq_unregister(void); 47void service_subclass_irq_unregister(void);
48void measurement_alert_subclass_register(void);
49void measurement_alert_subclass_unregister(void);
48 50
49#endif /* _ASM_IRQ_H */ 51#endif /* _ASM_IRQ_H */
diff --git a/arch/s390/include/asm/kvm.h b/arch/s390/include/asm/kvm.h
index 82b32a100c7..96076676e22 100644
--- a/arch/s390/include/asm/kvm.h
+++ b/arch/s390/include/asm/kvm.h
@@ -41,4 +41,15 @@ struct kvm_debug_exit_arch {
41struct kvm_guest_debug_arch { 41struct kvm_guest_debug_arch {
42}; 42};
43 43
44#define KVM_SYNC_PREFIX (1UL << 0)
45#define KVM_SYNC_GPRS (1UL << 1)
46#define KVM_SYNC_ACRS (1UL << 2)
47#define KVM_SYNC_CRS (1UL << 3)
48/* definition of registers in kvm_run */
49struct kvm_sync_regs {
50 __u64 prefix; /* prefix register */
51 __u64 gprs[16]; /* general purpose registers */
52 __u32 acrs[16]; /* access registers */
53 __u64 crs[16]; /* control registers */
54};
44#endif 55#endif
diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h
index b0c235cb6ad..7343872890a 100644
--- a/arch/s390/include/asm/kvm_host.h
+++ b/arch/s390/include/asm/kvm_host.h
@@ -220,18 +220,17 @@ struct kvm_s390_float_interrupt {
220 struct list_head list; 220 struct list_head list;
221 atomic_t active; 221 atomic_t active;
222 int next_rr_cpu; 222 int next_rr_cpu;
223 unsigned long idle_mask [(64 + sizeof(long) - 1) / sizeof(long)]; 223 unsigned long idle_mask[(KVM_MAX_VCPUS + sizeof(long) - 1)
224 struct kvm_s390_local_interrupt *local_int[64]; 224 / sizeof(long)];
225 struct kvm_s390_local_interrupt *local_int[KVM_MAX_VCPUS];
225}; 226};
226 227
227 228
228struct kvm_vcpu_arch { 229struct kvm_vcpu_arch {
229 struct kvm_s390_sie_block *sie_block; 230 struct kvm_s390_sie_block *sie_block;
230 unsigned long guest_gprs[16];
231 s390_fp_regs host_fpregs; 231 s390_fp_regs host_fpregs;
232 unsigned int host_acrs[NUM_ACRS]; 232 unsigned int host_acrs[NUM_ACRS];
233 s390_fp_regs guest_fpregs; 233 s390_fp_regs guest_fpregs;
234 unsigned int guest_acrs[NUM_ACRS];
235 struct kvm_s390_local_interrupt local_int; 234 struct kvm_s390_local_interrupt local_int;
236 struct hrtimer ckc_timer; 235 struct hrtimer ckc_timer;
237 struct tasklet_struct tasklet; 236 struct tasklet_struct tasklet;
@@ -246,6 +245,9 @@ struct kvm_vm_stat {
246 u32 remote_tlb_flush; 245 u32 remote_tlb_flush;
247}; 246};
248 247
248struct kvm_arch_memory_slot {
249};
250
249struct kvm_arch{ 251struct kvm_arch{
250 struct sca_block *sca; 252 struct sca_block *sca;
251 debug_info_t *dbf; 253 debug_info_t *dbf;
@@ -253,5 +255,5 @@ struct kvm_arch{
253 struct gmap *gmap; 255 struct gmap *gmap;
254}; 256};
255 257
256extern int sie64a(struct kvm_s390_sie_block *, unsigned long *); 258extern int sie64a(struct kvm_s390_sie_block *, u64 *);
257#endif 259#endif
diff --git a/arch/s390/include/asm/perf_event.h b/arch/s390/include/asm/perf_event.h
index 4eb444edbe4..7941968e12b 100644
--- a/arch/s390/include/asm/perf_event.h
+++ b/arch/s390/include/asm/perf_event.h
@@ -1,8 +1,16 @@
1/* 1/*
2 * Performance event support - s390 specific definitions. 2 * Performance event support - s390 specific definitions.
3 * 3 *
4 * Copyright 2009 Martin Schwidefsky, IBM Corporation. 4 * Copyright IBM Corp. 2009, 2012
5 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
6 * Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
5 */ 7 */
6 8
7/* Empty, just to avoid compiling error */ 9#include <asm/cpu_mf.h>
8 10
11/* CPU-measurement counter facility */
12#define PERF_CPUM_CF_MAX_CTR 160
13
14/* Per-CPU flags for PMU states */
15#define PMU_F_RESERVED 0x1000
16#define PMU_F_ENABLED 0x2000
diff --git a/arch/s390/kernel/Makefile b/arch/s390/kernel/Makefile
index 16b0b433f1f..884b18afc86 100644
--- a/arch/s390/kernel/Makefile
+++ b/arch/s390/kernel/Makefile
@@ -48,6 +48,7 @@ obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o
48obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o 48obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o
49obj-$(CONFIG_FTRACE_SYSCALLS) += ftrace.o 49obj-$(CONFIG_FTRACE_SYSCALLS) += ftrace.o
50obj-$(CONFIG_CRASH_DUMP) += crash_dump.o 50obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
51obj-$(CONFIG_PERF_EVENTS) += perf_event.o perf_cpum_cf.o
51 52
52# Kexec part 53# Kexec part
53S390_KEXEC_OBJS := machine_kexec.o crash.o 54S390_KEXEC_OBJS := machine_kexec.o crash.o
diff --git a/arch/s390/kernel/irq.c b/arch/s390/kernel/irq.c
index 2429ecd6887..1c2cdd59ccd 100644
--- a/arch/s390/kernel/irq.c
+++ b/arch/s390/kernel/irq.c
@@ -255,3 +255,26 @@ void service_subclass_irq_unregister(void)
255 spin_unlock(&sc_irq_lock); 255 spin_unlock(&sc_irq_lock);
256} 256}
257EXPORT_SYMBOL(service_subclass_irq_unregister); 257EXPORT_SYMBOL(service_subclass_irq_unregister);
258
259static DEFINE_SPINLOCK(ma_subclass_lock);
260static int ma_subclass_refcount;
261
262void measurement_alert_subclass_register(void)
263{
264 spin_lock(&ma_subclass_lock);
265 if (!ma_subclass_refcount)
266 ctl_set_bit(0, 5);
267 ma_subclass_refcount++;
268 spin_unlock(&ma_subclass_lock);
269}
270EXPORT_SYMBOL(measurement_alert_subclass_register);
271
272void measurement_alert_subclass_unregister(void)
273{
274 spin_lock(&ma_subclass_lock);
275 ma_subclass_refcount--;
276 if (!ma_subclass_refcount)
277 ctl_clear_bit(0, 5);
278 spin_unlock(&ma_subclass_lock);
279}
280EXPORT_SYMBOL(measurement_alert_subclass_unregister);
diff --git a/arch/s390/kernel/perf_cpum_cf.c b/arch/s390/kernel/perf_cpum_cf.c
new file mode 100644
index 00000000000..8481ecf2ad7
--- /dev/null
+++ b/arch/s390/kernel/perf_cpum_cf.c
@@ -0,0 +1,690 @@
1/*
2 * Performance event support for s390x - CPU-measurement Counter Facility
3 *
4 * Copyright IBM Corp. 2012
5 * Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
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 only)
9 * as published by the Free Software Foundation.
10 */
11#define KMSG_COMPONENT "cpum_cf"
12#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
13
14#include <linux/kernel.h>
15#include <linux/kernel_stat.h>
16#include <linux/perf_event.h>
17#include <linux/percpu.h>
18#include <linux/notifier.h>
19#include <linux/init.h>
20#include <linux/export.h>
21#include <asm/system.h>
22#include <asm/irq.h>
23#include <asm/cpu_mf.h>
24
25/* CPU-measurement counter facility supports these CPU counter sets:
26 * For CPU counter sets:
27 * Basic counter set: 0-31
28 * Problem-state counter set: 32-63
29 * Crypto-activity counter set: 64-127
30 * Extented counter set: 128-159
31 */
32enum cpumf_ctr_set {
33 /* CPU counter sets */
34 CPUMF_CTR_SET_BASIC = 0,
35 CPUMF_CTR_SET_USER = 1,
36 CPUMF_CTR_SET_CRYPTO = 2,
37 CPUMF_CTR_SET_EXT = 3,
38
39 /* Maximum number of counter sets */
40 CPUMF_CTR_SET_MAX,
41};
42
43#define CPUMF_LCCTL_ENABLE_SHIFT 16
44#define CPUMF_LCCTL_ACTCTL_SHIFT 0
45static const u64 cpumf_state_ctl[CPUMF_CTR_SET_MAX] = {
46 [CPUMF_CTR_SET_BASIC] = 0x02,
47 [CPUMF_CTR_SET_USER] = 0x04,
48 [CPUMF_CTR_SET_CRYPTO] = 0x08,
49 [CPUMF_CTR_SET_EXT] = 0x01,
50};
51
52static void ctr_set_enable(u64 *state, int ctr_set)
53{
54 *state |= cpumf_state_ctl[ctr_set] << CPUMF_LCCTL_ENABLE_SHIFT;
55}
56static void ctr_set_disable(u64 *state, int ctr_set)
57{
58 *state &= ~(cpumf_state_ctl[ctr_set] << CPUMF_LCCTL_ENABLE_SHIFT);
59}
60static void ctr_set_start(u64 *state, int ctr_set)
61{
62 *state |= cpumf_state_ctl[ctr_set] << CPUMF_LCCTL_ACTCTL_SHIFT;
63}
64static void ctr_set_stop(u64 *state, int ctr_set)
65{
66 *state &= ~(cpumf_state_ctl[ctr_set] << CPUMF_LCCTL_ACTCTL_SHIFT);
67}
68
69/* Local CPUMF event structure */
70struct cpu_hw_events {
71 struct cpumf_ctr_info info;
72 atomic_t ctr_set[CPUMF_CTR_SET_MAX];
73 u64 state, tx_state;
74 unsigned int flags;
75};
76static DEFINE_PER_CPU(struct cpu_hw_events, cpu_hw_events) = {
77 .ctr_set = {
78 [CPUMF_CTR_SET_BASIC] = ATOMIC_INIT(0),
79 [CPUMF_CTR_SET_USER] = ATOMIC_INIT(0),
80 [CPUMF_CTR_SET_CRYPTO] = ATOMIC_INIT(0),
81 [CPUMF_CTR_SET_EXT] = ATOMIC_INIT(0),
82 },
83 .state = 0,
84 .flags = 0,
85};
86
87static int get_counter_set(u64 event)
88{
89 int set = -1;
90
91 if (event < 32)
92 set = CPUMF_CTR_SET_BASIC;
93 else if (event < 64)
94 set = CPUMF_CTR_SET_USER;
95 else if (event < 128)
96 set = CPUMF_CTR_SET_CRYPTO;
97 else if (event < 160)
98 set = CPUMF_CTR_SET_EXT;
99
100 return set;
101}
102
103static int validate_event(const struct hw_perf_event *hwc)
104{
105 switch (hwc->config_base) {
106 case CPUMF_CTR_SET_BASIC:
107 case CPUMF_CTR_SET_USER:
108 case CPUMF_CTR_SET_CRYPTO:
109 case CPUMF_CTR_SET_EXT:
110 /* check for reserved counters */
111 if ((hwc->config >= 6 && hwc->config <= 31) ||
112 (hwc->config >= 38 && hwc->config <= 63) ||
113 (hwc->config >= 80 && hwc->config <= 127))
114 return -EOPNOTSUPP;
115 break;
116 default:
117 return -EINVAL;
118 }
119
120 return 0;
121}
122
123static int validate_ctr_version(const struct hw_perf_event *hwc)
124{
125 struct cpu_hw_events *cpuhw;
126 int err = 0;
127
128 cpuhw = &get_cpu_var(cpu_hw_events);
129
130 /* check required version for counter sets */
131 switch (hwc->config_base) {
132 case CPUMF_CTR_SET_BASIC:
133 case CPUMF_CTR_SET_USER:
134 if (cpuhw->info.cfvn < 1)
135 err = -EOPNOTSUPP;
136 break;
137 case CPUMF_CTR_SET_CRYPTO:
138 case CPUMF_CTR_SET_EXT:
139 if (cpuhw->info.csvn < 1)
140 err = -EOPNOTSUPP;
141 break;
142 }
143
144 put_cpu_var(cpu_hw_events);
145 return err;
146}
147
148static int validate_ctr_auth(const struct hw_perf_event *hwc)
149{
150 struct cpu_hw_events *cpuhw;
151 u64 ctrs_state;
152 int err = 0;
153
154 cpuhw = &get_cpu_var(cpu_hw_events);
155
156 /* check authorization for cpu counter sets */
157 ctrs_state = cpumf_state_ctl[hwc->config_base];
158 if (!(ctrs_state & cpuhw->info.auth_ctl))
159 err = -EPERM;
160
161 put_cpu_var(cpu_hw_events);
162 return err;
163}
164
165/*
166 * Change the CPUMF state to active.
167 * Enable and activate the CPU-counter sets according
168 * to the per-cpu control state.
169 */
170static void cpumf_pmu_enable(struct pmu *pmu)
171{
172 struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events);
173 int err;
174
175 if (cpuhw->flags & PMU_F_ENABLED)
176 return;
177
178 err = lcctl(cpuhw->state);
179 if (err) {
180 pr_err("Enabling the performance measuring unit "
181 "failed with rc=%lx\n", err);
182 return;
183 }
184
185 cpuhw->flags |= PMU_F_ENABLED;
186}
187
188/*
189 * Change the CPUMF state to inactive.
190 * Disable and enable (inactive) the CPU-counter sets according
191 * to the per-cpu control state.
192 */
193static void cpumf_pmu_disable(struct pmu *pmu)
194{
195 struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events);
196 int err;
197 u64 inactive;
198
199 if (!(cpuhw->flags & PMU_F_ENABLED))
200 return;
201
202 inactive = cpuhw->state & ~((1 << CPUMF_LCCTL_ENABLE_SHIFT) - 1);
203 err = lcctl(inactive);
204 if (err) {
205 pr_err("Disabling the performance measuring unit "
206 "failed with rc=%lx\n", err);
207 return;
208 }
209
210 cpuhw->flags &= ~PMU_F_ENABLED;
211}
212
213
214/* Number of perf events counting hardware events */
215static atomic_t num_events = ATOMIC_INIT(0);
216/* Used to avoid races in calling reserve/release_cpumf_hardware */
217static DEFINE_MUTEX(pmc_reserve_mutex);
218
219/* CPU-measurement alerts for the counter facility */
220static void cpumf_measurement_alert(struct ext_code ext_code,
221 unsigned int alert, unsigned long unused)
222{
223 struct cpu_hw_events *cpuhw;
224
225 if (!(alert & CPU_MF_INT_CF_MASK))
226 return;
227
228 kstat_cpu(smp_processor_id()).irqs[EXTINT_CPM]++;
229 cpuhw = &__get_cpu_var(cpu_hw_events);
230
231 /* Measurement alerts are shared and might happen when the PMU
232 * is not reserved. Ignore these alerts in this case. */
233 if (!(cpuhw->flags & PMU_F_RESERVED))
234 return;
235
236 /* counter authorization change alert */
237 if (alert & CPU_MF_INT_CF_CACA)
238 qctri(&cpuhw->info);
239
240 /* loss of counter data alert */
241 if (alert & CPU_MF_INT_CF_LCDA)
242 pr_err("CPU[%i] Counter data was lost\n", smp_processor_id());
243}
244
245#define PMC_INIT 0
246#define PMC_RELEASE 1
247static void setup_pmc_cpu(void *flags)
248{
249 struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events);
250
251 switch (*((int *) flags)) {
252 case PMC_INIT:
253 memset(&cpuhw->info, 0, sizeof(cpuhw->info));
254 qctri(&cpuhw->info);
255 cpuhw->flags |= PMU_F_RESERVED;
256 break;
257
258 case PMC_RELEASE:
259 cpuhw->flags &= ~PMU_F_RESERVED;
260 break;
261 }
262
263 /* Disable CPU counter sets */
264 lcctl(0);
265}
266
267/* Initialize the CPU-measurement facility */
268static int reserve_pmc_hardware(void)
269{
270 int flags = PMC_INIT;
271
272 on_each_cpu(setup_pmc_cpu, &flags, 1);
273 measurement_alert_subclass_register();
274
275 return 0;
276}
277
278/* Release the CPU-measurement facility */
279static void release_pmc_hardware(void)
280{
281 int flags = PMC_RELEASE;
282
283 on_each_cpu(setup_pmc_cpu, &flags, 1);
284 measurement_alert_subclass_unregister();
285}
286
287/* Release the PMU if event is the last perf event */
288static void hw_perf_event_destroy(struct perf_event *event)
289{
290 if (!atomic_add_unless(&num_events, -1, 1)) {
291 mutex_lock(&pmc_reserve_mutex);
292 if (atomic_dec_return(&num_events) == 0)
293 release_pmc_hardware();
294 mutex_unlock(&pmc_reserve_mutex);
295 }
296}
297
298/* CPUMF <-> perf event mappings for kernel+userspace (basic set) */
299static const int cpumf_generic_events_basic[] = {
300 [PERF_COUNT_HW_CPU_CYCLES] = 0,
301 [PERF_COUNT_HW_INSTRUCTIONS] = 1,
302 [PERF_COUNT_HW_CACHE_REFERENCES] = -1,
303 [PERF_COUNT_HW_CACHE_MISSES] = -1,
304 [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = -1,
305 [PERF_COUNT_HW_BRANCH_MISSES] = -1,
306 [PERF_COUNT_HW_BUS_CYCLES] = -1,
307};
308/* CPUMF <-> perf event mappings for userspace (problem-state set) */
309static const int cpumf_generic_events_user[] = {
310 [PERF_COUNT_HW_CPU_CYCLES] = 32,
311 [PERF_COUNT_HW_INSTRUCTIONS] = 33,
312 [PERF_COUNT_HW_CACHE_REFERENCES] = -1,
313 [PERF_COUNT_HW_CACHE_MISSES] = -1,
314 [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = -1,
315 [PERF_COUNT_HW_BRANCH_MISSES] = -1,
316 [PERF_COUNT_HW_BUS_CYCLES] = -1,
317};
318
319static int __hw_perf_event_init(struct perf_event *event)
320{
321 struct perf_event_attr *attr = &event->attr;
322 struct hw_perf_event *hwc = &event->hw;
323 int err;
324 u64 ev;
325
326 switch (attr->type) {
327 case PERF_TYPE_RAW:
328 /* Raw events are used to access counters directly,
329 * hence do not permit excludes */
330 if (attr->exclude_kernel || attr->exclude_user ||
331 attr->exclude_hv)
332 return -EOPNOTSUPP;
333 ev = attr->config;
334 break;
335
336 case PERF_TYPE_HARDWARE:
337 ev = attr->config;
338 /* Count user space (problem-state) only */
339 if (!attr->exclude_user && attr->exclude_kernel) {
340 if (ev >= ARRAY_SIZE(cpumf_generic_events_user))
341 return -EOPNOTSUPP;
342 ev = cpumf_generic_events_user[ev];
343
344 /* No support for kernel space counters only */
345 } else if (!attr->exclude_kernel && attr->exclude_user) {
346 return -EOPNOTSUPP;
347
348 /* Count user and kernel space */
349 } else {
350 if (ev >= ARRAY_SIZE(cpumf_generic_events_basic))
351 return -EOPNOTSUPP;
352 ev = cpumf_generic_events_basic[ev];
353 }
354 break;
355
356 default:
357 return -ENOENT;
358 }
359
360 if (ev == -1)
361 return -ENOENT;
362
363 if (ev >= PERF_CPUM_CF_MAX_CTR)
364 return -EINVAL;
365
366 /* The CPU measurement counter facility does not have any interrupts
367 * to do sampling. Sampling must be provided by external means,
368 * for example, by timers.
369 */
370 if (hwc->sample_period)
371 return -EINVAL;
372
373 /* Use the hardware perf event structure to store the counter number
374 * in 'config' member and the counter set to which the counter belongs
375 * in the 'config_base'. The counter set (config_base) is then used
376 * to enable/disable the counters.
377 */
378 hwc->config = ev;
379 hwc->config_base = get_counter_set(ev);
380
381 /* Validate the counter that is assigned to this event.
382 * Because the counter facility can use numerous counters at the
383 * same time without constraints, it is not necessary to explicity
384 * validate event groups (event->group_leader != event).
385 */
386 err = validate_event(hwc);
387 if (err)
388 return err;
389
390 /* Initialize for using the CPU-measurement counter facility */
391 if (!atomic_inc_not_zero(&num_events)) {
392 mutex_lock(&pmc_reserve_mutex);
393 if (atomic_read(&num_events) == 0 && reserve_pmc_hardware())
394 err = -EBUSY;
395 else
396 atomic_inc(&num_events);
397 mutex_unlock(&pmc_reserve_mutex);
398 }
399 event->destroy = hw_perf_event_destroy;
400
401 /* Finally, validate version and authorization of the counter set */
402 err = validate_ctr_auth(hwc);
403 if (!err)
404 err = validate_ctr_version(hwc);
405
406 return err;
407}
408
409static int cpumf_pmu_event_init(struct perf_event *event)
410{
411 int err;
412
413 switch (event->attr.type) {
414 case PERF_TYPE_HARDWARE:
415 case PERF_TYPE_HW_CACHE:
416 case PERF_TYPE_RAW:
417 err = __hw_perf_event_init(event);
418 break;
419 default:
420 return -ENOENT;
421 }
422
423 if (unlikely(err) && event->destroy)
424 event->destroy(event);
425
426 return err;
427}
428
429static int hw_perf_event_reset(struct perf_event *event)
430{
431 u64 prev, new;
432 int err;
433
434 do {
435 prev = local64_read(&event->hw.prev_count);
436 err = ecctr(event->hw.config, &new);
437 if (err) {
438 if (err != 3)
439 break;
440 /* The counter is not (yet) available. This
441 * might happen if the counter set to which
442 * this counter belongs is in the disabled
443 * state.
444 */
445 new = 0;
446 }
447 } while (local64_cmpxchg(&event->hw.prev_count, prev, new) != prev);
448
449 return err;
450}
451
452static int hw_perf_event_update(struct perf_event *event)
453{
454 u64 prev, new, delta;
455 int err;
456
457 do {
458 prev = local64_read(&event->hw.prev_count);
459 err = ecctr(event->hw.config, &new);
460 if (err)
461 goto out;
462 } while (local64_cmpxchg(&event->hw.prev_count, prev, new) != prev);
463
464 delta = (prev <= new) ? new - prev
465 : (-1ULL - prev) + new + 1; /* overflow */
466 local64_add(delta, &event->count);
467out:
468 return err;
469}
470
471static void cpumf_pmu_read(struct perf_event *event)
472{
473 if (event->hw.state & PERF_HES_STOPPED)
474 return;
475
476 hw_perf_event_update(event);
477}
478
479static void cpumf_pmu_start(struct perf_event *event, int flags)
480{
481 struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events);
482 struct hw_perf_event *hwc = &event->hw;
483
484 if (WARN_ON_ONCE(!(hwc->state & PERF_HES_STOPPED)))
485 return;
486
487 if (WARN_ON_ONCE(hwc->config == -1))
488 return;
489
490 if (flags & PERF_EF_RELOAD)
491 WARN_ON_ONCE(!(hwc->state & PERF_HES_UPTODATE));
492
493 hwc->state = 0;
494
495 /* (Re-)enable and activate the counter set */
496 ctr_set_enable(&cpuhw->state, hwc->config_base);
497 ctr_set_start(&cpuhw->state, hwc->config_base);
498
499 /* The counter set to which this counter belongs can be already active.
500 * Because all counters in a set are active, the event->hw.prev_count
501 * needs to be synchronized. At this point, the counter set can be in
502 * the inactive or disabled state.
503 */
504 hw_perf_event_reset(event);
505
506 /* increment refcount for this counter set */
507 atomic_inc(&cpuhw->ctr_set[hwc->config_base]);
508}
509
510static void cpumf_pmu_stop(struct perf_event *event, int flags)
511{
512 struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events);
513 struct hw_perf_event *hwc = &event->hw;
514
515 if (!(hwc->state & PERF_HES_STOPPED)) {
516 /* Decrement reference count for this counter set and if this
517 * is the last used counter in the set, clear activation
518 * control and set the counter set state to inactive.
519 */
520 if (!atomic_dec_return(&cpuhw->ctr_set[hwc->config_base]))
521 ctr_set_stop(&cpuhw->state, hwc->config_base);
522 event->hw.state |= PERF_HES_STOPPED;
523 }
524
525 if ((flags & PERF_EF_UPDATE) && !(hwc->state & PERF_HES_UPTODATE)) {
526 hw_perf_event_update(event);
527 event->hw.state |= PERF_HES_UPTODATE;
528 }
529}
530
531static int cpumf_pmu_add(struct perf_event *event, int flags)
532{
533 struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events);
534
535 /* Check authorization for the counter set to which this
536 * counter belongs.
537 * For group events transaction, the authorization check is
538 * done in cpumf_pmu_commit_txn().
539 */
540 if (!(cpuhw->flags & PERF_EVENT_TXN))
541 if (validate_ctr_auth(&event->hw))
542 return -EPERM;
543
544 ctr_set_enable(&cpuhw->state, event->hw.config_base);
545 event->hw.state = PERF_HES_UPTODATE | PERF_HES_STOPPED;
546
547 if (flags & PERF_EF_START)
548 cpumf_pmu_start(event, PERF_EF_RELOAD);
549
550 perf_event_update_userpage(event);
551
552 return 0;
553}
554
555static void cpumf_pmu_del(struct perf_event *event, int flags)
556{
557 struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events);
558
559 cpumf_pmu_stop(event, PERF_EF_UPDATE);
560
561 /* Check if any counter in the counter set is still used. If not used,
562 * change the counter set to the disabled state. This also clears the
563 * content of all counters in the set.
564 *
565 * When a new perf event has been added but not yet started, this can
566 * clear enable control and resets all counters in a set. Therefore,
567 * cpumf_pmu_start() always has to reenable a counter set.
568 */
569 if (!atomic_read(&cpuhw->ctr_set[event->hw.config_base]))
570 ctr_set_disable(&cpuhw->state, event->hw.config_base);
571
572 perf_event_update_userpage(event);
573}
574
575/*
576 * Start group events scheduling transaction.
577 * Set flags to perform a single test at commit time.
578 */
579static void cpumf_pmu_start_txn(struct pmu *pmu)
580{
581 struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events);
582
583 perf_pmu_disable(pmu);
584 cpuhw->flags |= PERF_EVENT_TXN;
585 cpuhw->tx_state = cpuhw->state;
586}
587
588/*
589 * Stop and cancel a group events scheduling tranctions.
590 * Assumes cpumf_pmu_del() is called for each successful added
591 * cpumf_pmu_add() during the transaction.
592 */
593static void cpumf_pmu_cancel_txn(struct pmu *pmu)
594{
595 struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events);
596
597 WARN_ON(cpuhw->tx_state != cpuhw->state);
598
599 cpuhw->flags &= ~PERF_EVENT_TXN;
600 perf_pmu_enable(pmu);
601}
602
603/*
604 * Commit the group events scheduling transaction. On success, the
605 * transaction is closed. On error, the transaction is kept open
606 * until cpumf_pmu_cancel_txn() is called.
607 */
608static int cpumf_pmu_commit_txn(struct pmu *pmu)
609{
610 struct cpu_hw_events *cpuhw = &__get_cpu_var(cpu_hw_events);
611 u64 state;
612
613 /* check if the updated state can be scheduled */
614 state = cpuhw->state & ~((1 << CPUMF_LCCTL_ENABLE_SHIFT) - 1);
615 state >>= CPUMF_LCCTL_ENABLE_SHIFT;
616 if ((state & cpuhw->info.auth_ctl) != state)
617 return -EPERM;
618
619 cpuhw->flags &= ~PERF_EVENT_TXN;
620 perf_pmu_enable(pmu);
621 return 0;
622}
623
624/* Performance monitoring unit for s390x */
625static struct pmu cpumf_pmu = {
626 .pmu_enable = cpumf_pmu_enable,
627 .pmu_disable = cpumf_pmu_disable,
628 .event_init = cpumf_pmu_event_init,
629 .add = cpumf_pmu_add,
630 .del = cpumf_pmu_del,
631 .start = cpumf_pmu_start,
632 .stop = cpumf_pmu_stop,
633 .read = cpumf_pmu_read,
634 .start_txn = cpumf_pmu_start_txn,
635 .commit_txn = cpumf_pmu_commit_txn,
636 .cancel_txn = cpumf_pmu_cancel_txn,
637};
638
639static int __cpuinit cpumf_pmu_notifier(struct notifier_block *self,
640 unsigned long action, void *hcpu)
641{
642 unsigned int cpu = (long) hcpu;
643 int flags;
644
645 switch (action & ~CPU_TASKS_FROZEN) {
646 case CPU_ONLINE:
647 flags = PMC_INIT;
648 smp_call_function_single(cpu, setup_pmc_cpu, &flags, 1);
649 break;
650 case CPU_DOWN_PREPARE:
651 flags = PMC_RELEASE;
652 smp_call_function_single(cpu, setup_pmc_cpu, &flags, 1);
653 break;
654 default:
655 break;
656 }
657
658 return NOTIFY_OK;
659}
660
661static int __init cpumf_pmu_init(void)
662{
663 int rc;
664
665 if (!cpum_cf_avail())
666 return -ENODEV;
667
668 /* clear bit 15 of cr0 to unauthorize problem-state to
669 * extract measurement counters */
670 ctl_clear_bit(0, 48);
671
672 /* register handler for measurement-alert interruptions */
673 rc = register_external_interrupt(0x1407, cpumf_measurement_alert);
674 if (rc) {
675 pr_err("Registering for CPU-measurement alerts "
676 "failed with rc=%i\n", rc);
677 goto out;
678 }
679
680 rc = perf_pmu_register(&cpumf_pmu, "cpum_cf", PERF_TYPE_RAW);
681 if (rc) {
682 pr_err("Registering the cpum_cf PMU failed with rc=%i\n", rc);
683 unregister_external_interrupt(0x1407, cpumf_measurement_alert);
684 goto out;
685 }
686 perf_cpu_notifier(cpumf_pmu_notifier);
687out:
688 return rc;
689}
690early_initcall(cpumf_pmu_init);
diff --git a/arch/s390/kernel/perf_event.c b/arch/s390/kernel/perf_event.c
new file mode 100644
index 00000000000..609f985198c
--- /dev/null
+++ b/arch/s390/kernel/perf_event.c
@@ -0,0 +1,125 @@
1/*
2 * Performance event support for s390x
3 *
4 * Copyright IBM Corp. 2012
5 * Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
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 only)
9 * as published by the Free Software Foundation.
10 */
11#define KMSG_COMPONENT "perf"
12#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
13
14#include <linux/kernel.h>
15#include <linux/perf_event.h>
16#include <linux/percpu.h>
17#include <linux/export.h>
18#include <asm/system.h>
19#include <asm/irq.h>
20#include <asm/cpu_mf.h>
21#include <asm/lowcore.h>
22#include <asm/processor.h>
23
24const char *perf_pmu_name(void)
25{
26 if (cpum_cf_avail() || cpum_sf_avail())
27 return "CPU-measurement facilities (CPUMF)";
28 return "pmu";
29}
30EXPORT_SYMBOL(perf_pmu_name);
31
32int perf_num_counters(void)
33{
34 int num = 0;
35
36 if (cpum_cf_avail())
37 num += PERF_CPUM_CF_MAX_CTR;
38
39 return num;
40}
41EXPORT_SYMBOL(perf_num_counters);
42
43void perf_event_print_debug(void)
44{
45 struct cpumf_ctr_info cf_info;
46 unsigned long flags;
47 int cpu;
48
49 if (!cpum_cf_avail())
50 return;
51
52 local_irq_save(flags);
53
54 cpu = smp_processor_id();
55 memset(&cf_info, 0, sizeof(cf_info));
56 if (!qctri(&cf_info)) {
57 pr_info("CPU[%i] CPUM_CF: ver=%u.%u A=%04x E=%04x C=%04x\n",
58 cpu, cf_info.cfvn, cf_info.csvn,
59 cf_info.auth_ctl, cf_info.enable_ctl, cf_info.act_ctl);
60 print_hex_dump_bytes("CPUMF Query: ", DUMP_PREFIX_OFFSET,
61 &cf_info, sizeof(cf_info));
62 }
63
64 local_irq_restore(flags);
65}
66
67/* See also arch/s390/kernel/traps.c */
68static unsigned long __store_trace(struct perf_callchain_entry *entry,
69 unsigned long sp,
70 unsigned long low, unsigned long high)
71{
72 struct stack_frame *sf;
73 struct pt_regs *regs;
74
75 while (1) {
76 sp = sp & PSW_ADDR_INSN;
77 if (sp < low || sp > high - sizeof(*sf))
78 return sp;
79 sf = (struct stack_frame *) sp;
80 perf_callchain_store(entry, sf->gprs[8] & PSW_ADDR_INSN);
81 /* Follow the backchain. */
82 while (1) {
83 low = sp;
84 sp = sf->back_chain & PSW_ADDR_INSN;
85 if (!sp)
86 break;
87 if (sp <= low || sp > high - sizeof(*sf))
88 return sp;
89 sf = (struct stack_frame *) sp;
90 perf_callchain_store(entry,
91 sf->gprs[8] & PSW_ADDR_INSN);
92 }
93 /* Zero backchain detected, check for interrupt frame. */
94 sp = (unsigned long) (sf + 1);
95 if (sp <= low || sp > high - sizeof(*regs))
96 return sp;
97 regs = (struct pt_regs *) sp;
98 perf_callchain_store(entry, sf->gprs[8] & PSW_ADDR_INSN);
99 low = sp;
100 sp = regs->gprs[15];
101 }
102}
103
104void perf_callchain_kernel(struct perf_callchain_entry *entry,
105 struct pt_regs *regs)
106{
107 unsigned long head;
108 struct stack_frame *head_sf;
109
110 if (user_mode(regs))
111 return;
112
113 head = regs->gprs[15];
114 head_sf = (struct stack_frame *) head;
115
116 if (!head_sf || !head_sf->back_chain)
117 return;
118
119 head = head_sf->back_chain;
120 head = __store_trace(entry, head, S390_lowcore.async_stack - ASYNC_SIZE,
121 S390_lowcore.async_stack);
122
123 __store_trace(entry, head, S390_lowcore.thread_info,
124 S390_lowcore.thread_info + THREAD_SIZE);
125}
diff --git a/arch/s390/kernel/vdso.c b/arch/s390/kernel/vdso.c
index d95427e32a5..ea5590fdca3 100644
--- a/arch/s390/kernel/vdso.c
+++ b/arch/s390/kernel/vdso.c
@@ -241,17 +241,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
241 * on the "data" page of the vDSO or you'll stop getting kernel 241 * on the "data" page of the vDSO or you'll stop getting kernel
242 * updates and your nice userland gettimeofday will be totally dead. 242 * updates and your nice userland gettimeofday will be totally dead.
243 * It's fine to use that for setting breakpoints in the vDSO code 243 * It's fine to use that for setting breakpoints in the vDSO code
244 * pages though 244 * pages though.
245 *
246 * Make sure the vDSO gets into every core dump.
247 * Dumping its contents makes post-mortem fully interpretable later
248 * without matching up the same kernel and hardware config to see
249 * what PC values meant.
250 */ 245 */
251 rc = install_special_mapping(mm, vdso_base, vdso_pages << PAGE_SHIFT, 246 rc = install_special_mapping(mm, vdso_base, vdso_pages << PAGE_SHIFT,
252 VM_READ|VM_EXEC| 247 VM_READ|VM_EXEC|
253 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC| 248 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
254 VM_ALWAYSDUMP,
255 vdso_pagelist); 249 vdso_pagelist);
256 if (rc) 250 if (rc)
257 current->mm->context.vdso_base = 0; 251 current->mm->context.vdso_base = 0;
diff --git a/arch/s390/kvm/Kconfig b/arch/s390/kvm/Kconfig
index a21634173a6..78eb9847008 100644
--- a/arch/s390/kvm/Kconfig
+++ b/arch/s390/kvm/Kconfig
@@ -34,6 +34,15 @@ config KVM
34 34
35 If unsure, say N. 35 If unsure, say N.
36 36
37config KVM_S390_UCONTROL
38 bool "Userspace controlled virtual machines"
39 depends on KVM
40 ---help---
41 Allow CAP_SYS_ADMIN users to create KVM virtual machines that are
42 controlled by userspace.
43
44 If unsure, say N.
45
37# OK, it's a little counter-intuitive to do this, but it puts it neatly under 46# OK, it's a little counter-intuitive to do this, but it puts it neatly under
38# the virtualization menu. 47# the virtualization menu.
39source drivers/vhost/Kconfig 48source drivers/vhost/Kconfig
diff --git a/arch/s390/kvm/diag.c b/arch/s390/kvm/diag.c
index 8943e82cd4d..a353f0ea45c 100644
--- a/arch/s390/kvm/diag.c
+++ b/arch/s390/kvm/diag.c
@@ -20,8 +20,8 @@ static int diag_release_pages(struct kvm_vcpu *vcpu)
20 unsigned long start, end; 20 unsigned long start, end;
21 unsigned long prefix = vcpu->arch.sie_block->prefix; 21 unsigned long prefix = vcpu->arch.sie_block->prefix;
22 22
23 start = vcpu->arch.guest_gprs[(vcpu->arch.sie_block->ipa & 0xf0) >> 4]; 23 start = vcpu->run->s.regs.gprs[(vcpu->arch.sie_block->ipa & 0xf0) >> 4];
24 end = vcpu->arch.guest_gprs[vcpu->arch.sie_block->ipa & 0xf] + 4096; 24 end = vcpu->run->s.regs.gprs[vcpu->arch.sie_block->ipa & 0xf] + 4096;
25 25
26 if (start & ~PAGE_MASK || end & ~PAGE_MASK || start > end 26 if (start & ~PAGE_MASK || end & ~PAGE_MASK || start > end
27 || start < 2 * PAGE_SIZE) 27 || start < 2 * PAGE_SIZE)
@@ -56,7 +56,7 @@ static int __diag_time_slice_end(struct kvm_vcpu *vcpu)
56static int __diag_ipl_functions(struct kvm_vcpu *vcpu) 56static int __diag_ipl_functions(struct kvm_vcpu *vcpu)
57{ 57{
58 unsigned int reg = vcpu->arch.sie_block->ipa & 0xf; 58 unsigned int reg = vcpu->arch.sie_block->ipa & 0xf;
59 unsigned long subcode = vcpu->arch.guest_gprs[reg] & 0xffff; 59 unsigned long subcode = vcpu->run->s.regs.gprs[reg] & 0xffff;
60 60
61 VCPU_EVENT(vcpu, 5, "diag ipl functions, subcode %lx", subcode); 61 VCPU_EVENT(vcpu, 5, "diag ipl functions, subcode %lx", subcode);
62 switch (subcode) { 62 switch (subcode) {
diff --git a/arch/s390/kvm/intercept.c b/arch/s390/kvm/intercept.c
index 02434543eab..361456577c6 100644
--- a/arch/s390/kvm/intercept.c
+++ b/arch/s390/kvm/intercept.c
@@ -36,7 +36,7 @@ static int handle_lctlg(struct kvm_vcpu *vcpu)
36 36
37 useraddr = disp2; 37 useraddr = disp2;
38 if (base2) 38 if (base2)
39 useraddr += vcpu->arch.guest_gprs[base2]; 39 useraddr += vcpu->run->s.regs.gprs[base2];
40 40
41 if (useraddr & 7) 41 if (useraddr & 7)
42 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); 42 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
@@ -75,7 +75,7 @@ static int handle_lctl(struct kvm_vcpu *vcpu)
75 75
76 useraddr = disp2; 76 useraddr = disp2;
77 if (base2) 77 if (base2)
78 useraddr += vcpu->arch.guest_gprs[base2]; 78 useraddr += vcpu->run->s.regs.gprs[base2];
79 79
80 if (useraddr & 3) 80 if (useraddr & 3)
81 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); 81 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
@@ -133,13 +133,6 @@ static int handle_stop(struct kvm_vcpu *vcpu)
133 133
134 vcpu->stat.exit_stop_request++; 134 vcpu->stat.exit_stop_request++;
135 spin_lock_bh(&vcpu->arch.local_int.lock); 135 spin_lock_bh(&vcpu->arch.local_int.lock);
136 if (vcpu->arch.local_int.action_bits & ACTION_STORE_ON_STOP) {
137 vcpu->arch.local_int.action_bits &= ~ACTION_STORE_ON_STOP;
138 rc = kvm_s390_vcpu_store_status(vcpu,
139 KVM_S390_STORE_STATUS_NOADDR);
140 if (rc >= 0)
141 rc = -EOPNOTSUPP;
142 }
143 136
144 if (vcpu->arch.local_int.action_bits & ACTION_RELOADVCPU_ON_STOP) { 137 if (vcpu->arch.local_int.action_bits & ACTION_RELOADVCPU_ON_STOP) {
145 vcpu->arch.local_int.action_bits &= ~ACTION_RELOADVCPU_ON_STOP; 138 vcpu->arch.local_int.action_bits &= ~ACTION_RELOADVCPU_ON_STOP;
@@ -155,7 +148,18 @@ static int handle_stop(struct kvm_vcpu *vcpu)
155 rc = -EOPNOTSUPP; 148 rc = -EOPNOTSUPP;
156 } 149 }
157 150
158 spin_unlock_bh(&vcpu->arch.local_int.lock); 151 if (vcpu->arch.local_int.action_bits & ACTION_STORE_ON_STOP) {
152 vcpu->arch.local_int.action_bits &= ~ACTION_STORE_ON_STOP;
153 /* store status must be called unlocked. Since local_int.lock
154 * only protects local_int.* and not guest memory we can give
155 * up the lock here */
156 spin_unlock_bh(&vcpu->arch.local_int.lock);
157 rc = kvm_s390_vcpu_store_status(vcpu,
158 KVM_S390_STORE_STATUS_NOADDR);
159 if (rc >= 0)
160 rc = -EOPNOTSUPP;
161 } else
162 spin_unlock_bh(&vcpu->arch.local_int.lock);
159 return rc; 163 return rc;
160} 164}
161 165
diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
index f0647ce6da2..2d9f9a72bb8 100644
--- a/arch/s390/kvm/interrupt.c
+++ b/arch/s390/kvm/interrupt.c
@@ -236,8 +236,7 @@ static void __do_deliver_interrupt(struct kvm_vcpu *vcpu,
236 VCPU_EVENT(vcpu, 4, "interrupt: set prefix to %x", 236 VCPU_EVENT(vcpu, 4, "interrupt: set prefix to %x",
237 inti->prefix.address); 237 inti->prefix.address);
238 vcpu->stat.deliver_prefix_signal++; 238 vcpu->stat.deliver_prefix_signal++;
239 vcpu->arch.sie_block->prefix = inti->prefix.address; 239 kvm_s390_set_prefix(vcpu, inti->prefix.address);
240 vcpu->arch.sie_block->ihcpu = 0xffff;
241 break; 240 break;
242 241
243 case KVM_S390_RESTART: 242 case KVM_S390_RESTART:
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index d56de16a651..217ce44395a 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -129,6 +129,10 @@ int kvm_dev_ioctl_check_extension(long ext)
129 case KVM_CAP_S390_PSW: 129 case KVM_CAP_S390_PSW:
130 case KVM_CAP_S390_GMAP: 130 case KVM_CAP_S390_GMAP:
131 case KVM_CAP_SYNC_MMU: 131 case KVM_CAP_SYNC_MMU:
132#ifdef CONFIG_KVM_S390_UCONTROL
133 case KVM_CAP_S390_UCONTROL:
134#endif
135 case KVM_CAP_SYNC_REGS:
132 r = 1; 136 r = 1;
133 break; 137 break;
134 default: 138 default:
@@ -171,11 +175,22 @@ long kvm_arch_vm_ioctl(struct file *filp,
171 return r; 175 return r;
172} 176}
173 177
174int kvm_arch_init_vm(struct kvm *kvm) 178int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
175{ 179{
176 int rc; 180 int rc;
177 char debug_name[16]; 181 char debug_name[16];
178 182
183 rc = -EINVAL;
184#ifdef CONFIG_KVM_S390_UCONTROL
185 if (type & ~KVM_VM_S390_UCONTROL)
186 goto out_err;
187 if ((type & KVM_VM_S390_UCONTROL) && (!capable(CAP_SYS_ADMIN)))
188 goto out_err;
189#else
190 if (type)
191 goto out_err;
192#endif
193
179 rc = s390_enable_sie(); 194 rc = s390_enable_sie();
180 if (rc) 195 if (rc)
181 goto out_err; 196 goto out_err;
@@ -198,10 +213,13 @@ int kvm_arch_init_vm(struct kvm *kvm)
198 debug_register_view(kvm->arch.dbf, &debug_sprintf_view); 213 debug_register_view(kvm->arch.dbf, &debug_sprintf_view);
199 VM_EVENT(kvm, 3, "%s", "vm created"); 214 VM_EVENT(kvm, 3, "%s", "vm created");
200 215
201 kvm->arch.gmap = gmap_alloc(current->mm); 216 if (type & KVM_VM_S390_UCONTROL) {
202 if (!kvm->arch.gmap) 217 kvm->arch.gmap = NULL;
203 goto out_nogmap; 218 } else {
204 219 kvm->arch.gmap = gmap_alloc(current->mm);
220 if (!kvm->arch.gmap)
221 goto out_nogmap;
222 }
205 return 0; 223 return 0;
206out_nogmap: 224out_nogmap:
207 debug_unregister(kvm->arch.dbf); 225 debug_unregister(kvm->arch.dbf);
@@ -214,11 +232,18 @@ out_err:
214void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu) 232void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu)
215{ 233{
216 VCPU_EVENT(vcpu, 3, "%s", "free cpu"); 234 VCPU_EVENT(vcpu, 3, "%s", "free cpu");
217 clear_bit(63 - vcpu->vcpu_id, (unsigned long *) &vcpu->kvm->arch.sca->mcn); 235 if (!kvm_is_ucontrol(vcpu->kvm)) {
218 if (vcpu->kvm->arch.sca->cpu[vcpu->vcpu_id].sda == 236 clear_bit(63 - vcpu->vcpu_id,
219 (__u64) vcpu->arch.sie_block) 237 (unsigned long *) &vcpu->kvm->arch.sca->mcn);
220 vcpu->kvm->arch.sca->cpu[vcpu->vcpu_id].sda = 0; 238 if (vcpu->kvm->arch.sca->cpu[vcpu->vcpu_id].sda ==
239 (__u64) vcpu->arch.sie_block)
240 vcpu->kvm->arch.sca->cpu[vcpu->vcpu_id].sda = 0;
241 }
221 smp_mb(); 242 smp_mb();
243
244 if (kvm_is_ucontrol(vcpu->kvm))
245 gmap_free(vcpu->arch.gmap);
246
222 free_page((unsigned long)(vcpu->arch.sie_block)); 247 free_page((unsigned long)(vcpu->arch.sie_block));
223 kvm_vcpu_uninit(vcpu); 248 kvm_vcpu_uninit(vcpu);
224 kfree(vcpu); 249 kfree(vcpu);
@@ -249,13 +274,25 @@ void kvm_arch_destroy_vm(struct kvm *kvm)
249 kvm_free_vcpus(kvm); 274 kvm_free_vcpus(kvm);
250 free_page((unsigned long)(kvm->arch.sca)); 275 free_page((unsigned long)(kvm->arch.sca));
251 debug_unregister(kvm->arch.dbf); 276 debug_unregister(kvm->arch.dbf);
252 gmap_free(kvm->arch.gmap); 277 if (!kvm_is_ucontrol(kvm))
278 gmap_free(kvm->arch.gmap);
253} 279}
254 280
255/* Section: vcpu related */ 281/* Section: vcpu related */
256int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu) 282int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
257{ 283{
284 if (kvm_is_ucontrol(vcpu->kvm)) {
285 vcpu->arch.gmap = gmap_alloc(current->mm);
286 if (!vcpu->arch.gmap)
287 return -ENOMEM;
288 return 0;
289 }
290
258 vcpu->arch.gmap = vcpu->kvm->arch.gmap; 291 vcpu->arch.gmap = vcpu->kvm->arch.gmap;
292 vcpu->run->kvm_valid_regs = KVM_SYNC_PREFIX |
293 KVM_SYNC_GPRS |
294 KVM_SYNC_ACRS |
295 KVM_SYNC_CRS;
259 return 0; 296 return 0;
260} 297}
261 298
@@ -270,7 +307,7 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
270 save_access_regs(vcpu->arch.host_acrs); 307 save_access_regs(vcpu->arch.host_acrs);
271 vcpu->arch.guest_fpregs.fpc &= FPC_VALID_MASK; 308 vcpu->arch.guest_fpregs.fpc &= FPC_VALID_MASK;
272 restore_fp_regs(&vcpu->arch.guest_fpregs); 309 restore_fp_regs(&vcpu->arch.guest_fpregs);
273 restore_access_regs(vcpu->arch.guest_acrs); 310 restore_access_regs(vcpu->run->s.regs.acrs);
274 gmap_enable(vcpu->arch.gmap); 311 gmap_enable(vcpu->arch.gmap);
275 atomic_set_mask(CPUSTAT_RUNNING, &vcpu->arch.sie_block->cpuflags); 312 atomic_set_mask(CPUSTAT_RUNNING, &vcpu->arch.sie_block->cpuflags);
276} 313}
@@ -280,7 +317,7 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
280 atomic_clear_mask(CPUSTAT_RUNNING, &vcpu->arch.sie_block->cpuflags); 317 atomic_clear_mask(CPUSTAT_RUNNING, &vcpu->arch.sie_block->cpuflags);
281 gmap_disable(vcpu->arch.gmap); 318 gmap_disable(vcpu->arch.gmap);
282 save_fp_regs(&vcpu->arch.guest_fpregs); 319 save_fp_regs(&vcpu->arch.guest_fpregs);
283 save_access_regs(vcpu->arch.guest_acrs); 320 save_access_regs(vcpu->run->s.regs.acrs);
284 restore_fp_regs(&vcpu->arch.host_fpregs); 321 restore_fp_regs(&vcpu->arch.host_fpregs);
285 restore_access_regs(vcpu->arch.host_acrs); 322 restore_access_regs(vcpu->arch.host_acrs);
286} 323}
@@ -290,8 +327,7 @@ static void kvm_s390_vcpu_initial_reset(struct kvm_vcpu *vcpu)
290 /* this equals initial cpu reset in pop, but we don't switch to ESA */ 327 /* this equals initial cpu reset in pop, but we don't switch to ESA */
291 vcpu->arch.sie_block->gpsw.mask = 0UL; 328 vcpu->arch.sie_block->gpsw.mask = 0UL;
292 vcpu->arch.sie_block->gpsw.addr = 0UL; 329 vcpu->arch.sie_block->gpsw.addr = 0UL;
293 vcpu->arch.sie_block->prefix = 0UL; 330 kvm_s390_set_prefix(vcpu, 0);
294 vcpu->arch.sie_block->ihcpu = 0xffff;
295 vcpu->arch.sie_block->cputm = 0UL; 331 vcpu->arch.sie_block->cputm = 0UL;
296 vcpu->arch.sie_block->ckc = 0UL; 332 vcpu->arch.sie_block->ckc = 0UL;
297 vcpu->arch.sie_block->todpr = 0; 333 vcpu->arch.sie_block->todpr = 0;
@@ -342,12 +378,19 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm,
342 goto out_free_cpu; 378 goto out_free_cpu;
343 379
344 vcpu->arch.sie_block->icpua = id; 380 vcpu->arch.sie_block->icpua = id;
345 BUG_ON(!kvm->arch.sca); 381 if (!kvm_is_ucontrol(kvm)) {
346 if (!kvm->arch.sca->cpu[id].sda) 382 if (!kvm->arch.sca) {
347 kvm->arch.sca->cpu[id].sda = (__u64) vcpu->arch.sie_block; 383 WARN_ON_ONCE(1);
348 vcpu->arch.sie_block->scaoh = (__u32)(((__u64)kvm->arch.sca) >> 32); 384 goto out_free_cpu;
349 vcpu->arch.sie_block->scaol = (__u32)(__u64)kvm->arch.sca; 385 }
350 set_bit(63 - id, (unsigned long *) &kvm->arch.sca->mcn); 386 if (!kvm->arch.sca->cpu[id].sda)
387 kvm->arch.sca->cpu[id].sda =
388 (__u64) vcpu->arch.sie_block;
389 vcpu->arch.sie_block->scaoh =
390 (__u32)(((__u64)kvm->arch.sca) >> 32);
391 vcpu->arch.sie_block->scaol = (__u32)(__u64)kvm->arch.sca;
392 set_bit(63 - id, (unsigned long *) &kvm->arch.sca->mcn);
393 }
351 394
352 spin_lock_init(&vcpu->arch.local_int.lock); 395 spin_lock_init(&vcpu->arch.local_int.lock);
353 INIT_LIST_HEAD(&vcpu->arch.local_int.list); 396 INIT_LIST_HEAD(&vcpu->arch.local_int.list);
@@ -388,29 +431,29 @@ static int kvm_arch_vcpu_ioctl_initial_reset(struct kvm_vcpu *vcpu)
388 431
389int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) 432int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
390{ 433{
391 memcpy(&vcpu->arch.guest_gprs, &regs->gprs, sizeof(regs->gprs)); 434 memcpy(&vcpu->run->s.regs.gprs, &regs->gprs, sizeof(regs->gprs));
392 return 0; 435 return 0;
393} 436}
394 437
395int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) 438int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
396{ 439{
397 memcpy(&regs->gprs, &vcpu->arch.guest_gprs, sizeof(regs->gprs)); 440 memcpy(&regs->gprs, &vcpu->run->s.regs.gprs, sizeof(regs->gprs));
398 return 0; 441 return 0;
399} 442}
400 443
401int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, 444int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
402 struct kvm_sregs *sregs) 445 struct kvm_sregs *sregs)
403{ 446{
404 memcpy(&vcpu->arch.guest_acrs, &sregs->acrs, sizeof(sregs->acrs)); 447 memcpy(&vcpu->run->s.regs.acrs, &sregs->acrs, sizeof(sregs->acrs));
405 memcpy(&vcpu->arch.sie_block->gcr, &sregs->crs, sizeof(sregs->crs)); 448 memcpy(&vcpu->arch.sie_block->gcr, &sregs->crs, sizeof(sregs->crs));
406 restore_access_regs(vcpu->arch.guest_acrs); 449 restore_access_regs(vcpu->run->s.regs.acrs);
407 return 0; 450 return 0;
408} 451}
409 452
410int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu, 453int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu,
411 struct kvm_sregs *sregs) 454 struct kvm_sregs *sregs)
412{ 455{
413 memcpy(&sregs->acrs, &vcpu->arch.guest_acrs, sizeof(sregs->acrs)); 456 memcpy(&sregs->acrs, &vcpu->run->s.regs.acrs, sizeof(sregs->acrs));
414 memcpy(&sregs->crs, &vcpu->arch.sie_block->gcr, sizeof(sregs->crs)); 457 memcpy(&sregs->crs, &vcpu->arch.sie_block->gcr, sizeof(sregs->crs));
415 return 0; 458 return 0;
416} 459}
@@ -418,7 +461,7 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu,
418int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu) 461int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
419{ 462{
420 memcpy(&vcpu->arch.guest_fpregs.fprs, &fpu->fprs, sizeof(fpu->fprs)); 463 memcpy(&vcpu->arch.guest_fpregs.fprs, &fpu->fprs, sizeof(fpu->fprs));
421 vcpu->arch.guest_fpregs.fpc = fpu->fpc; 464 vcpu->arch.guest_fpregs.fpc = fpu->fpc & FPC_VALID_MASK;
422 restore_fp_regs(&vcpu->arch.guest_fpregs); 465 restore_fp_regs(&vcpu->arch.guest_fpregs);
423 return 0; 466 return 0;
424} 467}
@@ -467,9 +510,11 @@ int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu,
467 return -EINVAL; /* not implemented yet */ 510 return -EINVAL; /* not implemented yet */
468} 511}
469 512
470static void __vcpu_run(struct kvm_vcpu *vcpu) 513static int __vcpu_run(struct kvm_vcpu *vcpu)
471{ 514{
472 memcpy(&vcpu->arch.sie_block->gg14, &vcpu->arch.guest_gprs[14], 16); 515 int rc;
516
517 memcpy(&vcpu->arch.sie_block->gg14, &vcpu->run->s.regs.gprs[14], 16);
473 518
474 if (need_resched()) 519 if (need_resched())
475 schedule(); 520 schedule();
@@ -477,7 +522,8 @@ static void __vcpu_run(struct kvm_vcpu *vcpu)
477 if (test_thread_flag(TIF_MCCK_PENDING)) 522 if (test_thread_flag(TIF_MCCK_PENDING))
478 s390_handle_mcck(); 523 s390_handle_mcck();
479 524
480 kvm_s390_deliver_pending_interrupts(vcpu); 525 if (!kvm_is_ucontrol(vcpu->kvm))
526 kvm_s390_deliver_pending_interrupts(vcpu);
481 527
482 vcpu->arch.sie_block->icptcode = 0; 528 vcpu->arch.sie_block->icptcode = 0;
483 local_irq_disable(); 529 local_irq_disable();
@@ -485,9 +531,15 @@ static void __vcpu_run(struct kvm_vcpu *vcpu)
485 local_irq_enable(); 531 local_irq_enable();
486 VCPU_EVENT(vcpu, 6, "entering sie flags %x", 532 VCPU_EVENT(vcpu, 6, "entering sie flags %x",
487 atomic_read(&vcpu->arch.sie_block->cpuflags)); 533 atomic_read(&vcpu->arch.sie_block->cpuflags));
488 if (sie64a(vcpu->arch.sie_block, vcpu->arch.guest_gprs)) { 534 rc = sie64a(vcpu->arch.sie_block, vcpu->run->s.regs.gprs);
489 VCPU_EVENT(vcpu, 3, "%s", "fault in sie instruction"); 535 if (rc) {
490 kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING); 536 if (kvm_is_ucontrol(vcpu->kvm)) {
537 rc = SIE_INTERCEPT_UCONTROL;
538 } else {
539 VCPU_EVENT(vcpu, 3, "%s", "fault in sie instruction");
540 kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING);
541 rc = 0;
542 }
491 } 543 }
492 VCPU_EVENT(vcpu, 6, "exit sie icptcode %d", 544 VCPU_EVENT(vcpu, 6, "exit sie icptcode %d",
493 vcpu->arch.sie_block->icptcode); 545 vcpu->arch.sie_block->icptcode);
@@ -495,7 +547,8 @@ static void __vcpu_run(struct kvm_vcpu *vcpu)
495 kvm_guest_exit(); 547 kvm_guest_exit();
496 local_irq_enable(); 548 local_irq_enable();
497 549
498 memcpy(&vcpu->arch.guest_gprs[14], &vcpu->arch.sie_block->gg14, 16); 550 memcpy(&vcpu->run->s.regs.gprs[14], &vcpu->arch.sie_block->gg14, 16);
551 return rc;
499} 552}
500 553
501int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) 554int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
@@ -516,6 +569,7 @@ rerun_vcpu:
516 case KVM_EXIT_UNKNOWN: 569 case KVM_EXIT_UNKNOWN:
517 case KVM_EXIT_INTR: 570 case KVM_EXIT_INTR:
518 case KVM_EXIT_S390_RESET: 571 case KVM_EXIT_S390_RESET:
572 case KVM_EXIT_S390_UCONTROL:
519 break; 573 break;
520 default: 574 default:
521 BUG(); 575 BUG();
@@ -523,12 +577,26 @@ rerun_vcpu:
523 577
524 vcpu->arch.sie_block->gpsw.mask = kvm_run->psw_mask; 578 vcpu->arch.sie_block->gpsw.mask = kvm_run->psw_mask;
525 vcpu->arch.sie_block->gpsw.addr = kvm_run->psw_addr; 579 vcpu->arch.sie_block->gpsw.addr = kvm_run->psw_addr;
580 if (kvm_run->kvm_dirty_regs & KVM_SYNC_PREFIX) {
581 kvm_run->kvm_dirty_regs &= ~KVM_SYNC_PREFIX;
582 kvm_s390_set_prefix(vcpu, kvm_run->s.regs.prefix);
583 }
584 if (kvm_run->kvm_dirty_regs & KVM_SYNC_CRS) {
585 kvm_run->kvm_dirty_regs &= ~KVM_SYNC_CRS;
586 memcpy(&vcpu->arch.sie_block->gcr, &kvm_run->s.regs.crs, 128);
587 kvm_s390_set_prefix(vcpu, kvm_run->s.regs.prefix);
588 }
526 589
527 might_fault(); 590 might_fault();
528 591
529 do { 592 do {
530 __vcpu_run(vcpu); 593 rc = __vcpu_run(vcpu);
531 rc = kvm_handle_sie_intercept(vcpu); 594 if (rc)
595 break;
596 if (kvm_is_ucontrol(vcpu->kvm))
597 rc = -EOPNOTSUPP;
598 else
599 rc = kvm_handle_sie_intercept(vcpu);
532 } while (!signal_pending(current) && !rc); 600 } while (!signal_pending(current) && !rc);
533 601
534 if (rc == SIE_INTERCEPT_RERUNVCPU) 602 if (rc == SIE_INTERCEPT_RERUNVCPU)
@@ -539,6 +607,16 @@ rerun_vcpu:
539 rc = -EINTR; 607 rc = -EINTR;
540 } 608 }
541 609
610#ifdef CONFIG_KVM_S390_UCONTROL
611 if (rc == SIE_INTERCEPT_UCONTROL) {
612 kvm_run->exit_reason = KVM_EXIT_S390_UCONTROL;
613 kvm_run->s390_ucontrol.trans_exc_code =
614 current->thread.gmap_addr;
615 kvm_run->s390_ucontrol.pgm_code = 0x10;
616 rc = 0;
617 }
618#endif
619
542 if (rc == -EOPNOTSUPP) { 620 if (rc == -EOPNOTSUPP) {
543 /* intercept cannot be handled in-kernel, prepare kvm-run */ 621 /* intercept cannot be handled in-kernel, prepare kvm-run */
544 kvm_run->exit_reason = KVM_EXIT_S390_SIEIC; 622 kvm_run->exit_reason = KVM_EXIT_S390_SIEIC;
@@ -556,6 +634,8 @@ rerun_vcpu:
556 634
557 kvm_run->psw_mask = vcpu->arch.sie_block->gpsw.mask; 635 kvm_run->psw_mask = vcpu->arch.sie_block->gpsw.mask;
558 kvm_run->psw_addr = vcpu->arch.sie_block->gpsw.addr; 636 kvm_run->psw_addr = vcpu->arch.sie_block->gpsw.addr;
637 kvm_run->s.regs.prefix = vcpu->arch.sie_block->prefix;
638 memcpy(&kvm_run->s.regs.crs, &vcpu->arch.sie_block->gcr, 128);
559 639
560 if (vcpu->sigset_active) 640 if (vcpu->sigset_active)
561 sigprocmask(SIG_SETMASK, &sigsaved, NULL); 641 sigprocmask(SIG_SETMASK, &sigsaved, NULL);
@@ -602,7 +682,7 @@ int kvm_s390_vcpu_store_status(struct kvm_vcpu *vcpu, unsigned long addr)
602 return -EFAULT; 682 return -EFAULT;
603 683
604 if (__guestcopy(vcpu, addr + offsetof(struct save_area, gp_regs), 684 if (__guestcopy(vcpu, addr + offsetof(struct save_area, gp_regs),
605 vcpu->arch.guest_gprs, 128, prefix)) 685 vcpu->run->s.regs.gprs, 128, prefix))
606 return -EFAULT; 686 return -EFAULT;
607 687
608 if (__guestcopy(vcpu, addr + offsetof(struct save_area, psw), 688 if (__guestcopy(vcpu, addr + offsetof(struct save_area, psw),
@@ -631,7 +711,7 @@ int kvm_s390_vcpu_store_status(struct kvm_vcpu *vcpu, unsigned long addr)
631 return -EFAULT; 711 return -EFAULT;
632 712
633 if (__guestcopy(vcpu, addr + offsetof(struct save_area, acc_regs), 713 if (__guestcopy(vcpu, addr + offsetof(struct save_area, acc_regs),
634 &vcpu->arch.guest_acrs, 64, prefix)) 714 &vcpu->run->s.regs.acrs, 64, prefix))
635 return -EFAULT; 715 return -EFAULT;
636 716
637 if (__guestcopy(vcpu, 717 if (__guestcopy(vcpu,
@@ -673,12 +753,77 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
673 case KVM_S390_INITIAL_RESET: 753 case KVM_S390_INITIAL_RESET:
674 r = kvm_arch_vcpu_ioctl_initial_reset(vcpu); 754 r = kvm_arch_vcpu_ioctl_initial_reset(vcpu);
675 break; 755 break;
756#ifdef CONFIG_KVM_S390_UCONTROL
757 case KVM_S390_UCAS_MAP: {
758 struct kvm_s390_ucas_mapping ucasmap;
759
760 if (copy_from_user(&ucasmap, argp, sizeof(ucasmap))) {
761 r = -EFAULT;
762 break;
763 }
764
765 if (!kvm_is_ucontrol(vcpu->kvm)) {
766 r = -EINVAL;
767 break;
768 }
769
770 r = gmap_map_segment(vcpu->arch.gmap, ucasmap.user_addr,
771 ucasmap.vcpu_addr, ucasmap.length);
772 break;
773 }
774 case KVM_S390_UCAS_UNMAP: {
775 struct kvm_s390_ucas_mapping ucasmap;
776
777 if (copy_from_user(&ucasmap, argp, sizeof(ucasmap))) {
778 r = -EFAULT;
779 break;
780 }
781
782 if (!kvm_is_ucontrol(vcpu->kvm)) {
783 r = -EINVAL;
784 break;
785 }
786
787 r = gmap_unmap_segment(vcpu->arch.gmap, ucasmap.vcpu_addr,
788 ucasmap.length);
789 break;
790 }
791#endif
792 case KVM_S390_VCPU_FAULT: {
793 r = gmap_fault(arg, vcpu->arch.gmap);
794 if (!IS_ERR_VALUE(r))
795 r = 0;
796 break;
797 }
676 default: 798 default:
677 r = -EINVAL; 799 r = -ENOTTY;
678 } 800 }
679 return r; 801 return r;
680} 802}
681 803
804int kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf)
805{
806#ifdef CONFIG_KVM_S390_UCONTROL
807 if ((vmf->pgoff == KVM_S390_SIE_PAGE_OFFSET)
808 && (kvm_is_ucontrol(vcpu->kvm))) {
809 vmf->page = virt_to_page(vcpu->arch.sie_block);
810 get_page(vmf->page);
811 return 0;
812 }
813#endif
814 return VM_FAULT_SIGBUS;
815}
816
817void kvm_arch_free_memslot(struct kvm_memory_slot *free,
818 struct kvm_memory_slot *dont)
819{
820}
821
822int kvm_arch_create_memslot(struct kvm_memory_slot *slot, unsigned long npages)
823{
824 return 0;
825}
826
682/* Section: memory related */ 827/* Section: memory related */
683int kvm_arch_prepare_memory_region(struct kvm *kvm, 828int kvm_arch_prepare_memory_region(struct kvm *kvm,
684 struct kvm_memory_slot *memslot, 829 struct kvm_memory_slot *memslot,
diff --git a/arch/s390/kvm/kvm-s390.h b/arch/s390/kvm/kvm-s390.h
index 99b0b759711..ff28f9d1c9e 100644
--- a/arch/s390/kvm/kvm-s390.h
+++ b/arch/s390/kvm/kvm-s390.h
@@ -26,6 +26,7 @@ typedef int (*intercept_handler_t)(struct kvm_vcpu *vcpu);
26 26
27/* negativ values are error codes, positive values for internal conditions */ 27/* negativ values are error codes, positive values for internal conditions */
28#define SIE_INTERCEPT_RERUNVCPU (1<<0) 28#define SIE_INTERCEPT_RERUNVCPU (1<<0)
29#define SIE_INTERCEPT_UCONTROL (1<<1)
29int kvm_handle_sie_intercept(struct kvm_vcpu *vcpu); 30int kvm_handle_sie_intercept(struct kvm_vcpu *vcpu);
30 31
31#define VM_EVENT(d_kvm, d_loglevel, d_string, d_args...)\ 32#define VM_EVENT(d_kvm, d_loglevel, d_string, d_args...)\
@@ -47,6 +48,23 @@ static inline int __cpu_is_stopped(struct kvm_vcpu *vcpu)
47 return atomic_read(&vcpu->arch.sie_block->cpuflags) & CPUSTAT_STOP_INT; 48 return atomic_read(&vcpu->arch.sie_block->cpuflags) & CPUSTAT_STOP_INT;
48} 49}
49 50
51static inline int kvm_is_ucontrol(struct kvm *kvm)
52{
53#ifdef CONFIG_KVM_S390_UCONTROL
54 if (kvm->arch.gmap)
55 return 0;
56 return 1;
57#else
58 return 0;
59#endif
60}
61
62static inline void kvm_s390_set_prefix(struct kvm_vcpu *vcpu, u32 prefix)
63{
64 vcpu->arch.sie_block->prefix = prefix & 0x7fffe000u;
65 vcpu->arch.sie_block->ihcpu = 0xffff;
66}
67
50int kvm_s390_handle_wait(struct kvm_vcpu *vcpu); 68int kvm_s390_handle_wait(struct kvm_vcpu *vcpu);
51enum hrtimer_restart kvm_s390_idle_wakeup(struct hrtimer *timer); 69enum hrtimer_restart kvm_s390_idle_wakeup(struct hrtimer *timer);
52void kvm_s390_tasklet(unsigned long parm); 70void kvm_s390_tasklet(unsigned long parm);
diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c
index d0263895992..e5a45dbd26a 100644
--- a/arch/s390/kvm/priv.c
+++ b/arch/s390/kvm/priv.c
@@ -33,7 +33,7 @@ static int handle_set_prefix(struct kvm_vcpu *vcpu)
33 33
34 operand2 = disp2; 34 operand2 = disp2;
35 if (base2) 35 if (base2)
36 operand2 += vcpu->arch.guest_gprs[base2]; 36 operand2 += vcpu->run->s.regs.gprs[base2];
37 37
38 /* must be word boundary */ 38 /* must be word boundary */
39 if (operand2 & 3) { 39 if (operand2 & 3) {
@@ -56,8 +56,7 @@ static int handle_set_prefix(struct kvm_vcpu *vcpu)
56 goto out; 56 goto out;
57 } 57 }
58 58
59 vcpu->arch.sie_block->prefix = address; 59 kvm_s390_set_prefix(vcpu, address);
60 vcpu->arch.sie_block->ihcpu = 0xffff;
61 60
62 VCPU_EVENT(vcpu, 5, "setting prefix to %x", address); 61 VCPU_EVENT(vcpu, 5, "setting prefix to %x", address);
63out: 62out:
@@ -74,7 +73,7 @@ static int handle_store_prefix(struct kvm_vcpu *vcpu)
74 vcpu->stat.instruction_stpx++; 73 vcpu->stat.instruction_stpx++;
75 operand2 = disp2; 74 operand2 = disp2;
76 if (base2) 75 if (base2)
77 operand2 += vcpu->arch.guest_gprs[base2]; 76 operand2 += vcpu->run->s.regs.gprs[base2];
78 77
79 /* must be word boundary */ 78 /* must be word boundary */
80 if (operand2 & 3) { 79 if (operand2 & 3) {
@@ -106,7 +105,7 @@ static int handle_store_cpu_address(struct kvm_vcpu *vcpu)
106 vcpu->stat.instruction_stap++; 105 vcpu->stat.instruction_stap++;
107 useraddr = disp2; 106 useraddr = disp2;
108 if (base2) 107 if (base2)
109 useraddr += vcpu->arch.guest_gprs[base2]; 108 useraddr += vcpu->run->s.regs.gprs[base2];
110 109
111 if (useraddr & 1) { 110 if (useraddr & 1) {
112 kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); 111 kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
@@ -181,7 +180,7 @@ static int handle_stidp(struct kvm_vcpu *vcpu)
181 vcpu->stat.instruction_stidp++; 180 vcpu->stat.instruction_stidp++;
182 operand2 = disp2; 181 operand2 = disp2;
183 if (base2) 182 if (base2)
184 operand2 += vcpu->arch.guest_gprs[base2]; 183 operand2 += vcpu->run->s.regs.gprs[base2];
185 184
186 if (operand2 & 7) { 185 if (operand2 & 7) {
187 kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); 186 kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
@@ -232,9 +231,9 @@ static void handle_stsi_3_2_2(struct kvm_vcpu *vcpu, struct sysinfo_3_2_2 *mem)
232 231
233static int handle_stsi(struct kvm_vcpu *vcpu) 232static int handle_stsi(struct kvm_vcpu *vcpu)
234{ 233{
235 int fc = (vcpu->arch.guest_gprs[0] & 0xf0000000) >> 28; 234 int fc = (vcpu->run->s.regs.gprs[0] & 0xf0000000) >> 28;
236 int sel1 = vcpu->arch.guest_gprs[0] & 0xff; 235 int sel1 = vcpu->run->s.regs.gprs[0] & 0xff;
237 int sel2 = vcpu->arch.guest_gprs[1] & 0xffff; 236 int sel2 = vcpu->run->s.regs.gprs[1] & 0xffff;
238 int base2 = vcpu->arch.sie_block->ipb >> 28; 237 int base2 = vcpu->arch.sie_block->ipb >> 28;
239 int disp2 = ((vcpu->arch.sie_block->ipb & 0x0fff0000) >> 16); 238 int disp2 = ((vcpu->arch.sie_block->ipb & 0x0fff0000) >> 16);
240 u64 operand2; 239 u64 operand2;
@@ -245,14 +244,14 @@ static int handle_stsi(struct kvm_vcpu *vcpu)
245 244
246 operand2 = disp2; 245 operand2 = disp2;
247 if (base2) 246 if (base2)
248 operand2 += vcpu->arch.guest_gprs[base2]; 247 operand2 += vcpu->run->s.regs.gprs[base2];
249 248
250 if (operand2 & 0xfff && fc > 0) 249 if (operand2 & 0xfff && fc > 0)
251 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); 250 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION);
252 251
253 switch (fc) { 252 switch (fc) {
254 case 0: 253 case 0:
255 vcpu->arch.guest_gprs[0] = 3 << 28; 254 vcpu->run->s.regs.gprs[0] = 3 << 28;
256 vcpu->arch.sie_block->gpsw.mask &= ~(3ul << 44); 255 vcpu->arch.sie_block->gpsw.mask &= ~(3ul << 44);
257 return 0; 256 return 0;
258 case 1: /* same handling for 1 and 2 */ 257 case 1: /* same handling for 1 and 2 */
@@ -281,7 +280,7 @@ static int handle_stsi(struct kvm_vcpu *vcpu)
281 } 280 }
282 free_page(mem); 281 free_page(mem);
283 vcpu->arch.sie_block->gpsw.mask &= ~(3ul << 44); 282 vcpu->arch.sie_block->gpsw.mask &= ~(3ul << 44);
284 vcpu->arch.guest_gprs[0] = 0; 283 vcpu->run->s.regs.gprs[0] = 0;
285 return 0; 284 return 0;
286out_mem: 285out_mem:
287 free_page(mem); 286 free_page(mem);
@@ -333,8 +332,8 @@ static int handle_tprot(struct kvm_vcpu *vcpu)
333 int disp1 = (vcpu->arch.sie_block->ipb & 0x0fff0000) >> 16; 332 int disp1 = (vcpu->arch.sie_block->ipb & 0x0fff0000) >> 16;
334 int base2 = (vcpu->arch.sie_block->ipb & 0xf000) >> 12; 333 int base2 = (vcpu->arch.sie_block->ipb & 0xf000) >> 12;
335 int disp2 = vcpu->arch.sie_block->ipb & 0x0fff; 334 int disp2 = vcpu->arch.sie_block->ipb & 0x0fff;
336 u64 address1 = disp1 + base1 ? vcpu->arch.guest_gprs[base1] : 0; 335 u64 address1 = disp1 + base1 ? vcpu->run->s.regs.gprs[base1] : 0;
337 u64 address2 = disp2 + base2 ? vcpu->arch.guest_gprs[base2] : 0; 336 u64 address2 = disp2 + base2 ? vcpu->run->s.regs.gprs[base2] : 0;
338 struct vm_area_struct *vma; 337 struct vm_area_struct *vma;
339 unsigned long user_address; 338 unsigned long user_address;
340 339
diff --git a/arch/s390/kvm/sigp.c b/arch/s390/kvm/sigp.c
index 0a7941d74bc..0ad4cf23839 100644
--- a/arch/s390/kvm/sigp.c
+++ b/arch/s390/kvm/sigp.c
@@ -48,7 +48,7 @@
48 48
49 49
50static int __sigp_sense(struct kvm_vcpu *vcpu, u16 cpu_addr, 50static int __sigp_sense(struct kvm_vcpu *vcpu, u16 cpu_addr,
51 unsigned long *reg) 51 u64 *reg)
52{ 52{
53 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int; 53 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int;
54 int rc; 54 int rc;
@@ -160,12 +160,15 @@ static int __inject_sigp_stop(struct kvm_s390_local_interrupt *li, int action)
160 inti->type = KVM_S390_SIGP_STOP; 160 inti->type = KVM_S390_SIGP_STOP;
161 161
162 spin_lock_bh(&li->lock); 162 spin_lock_bh(&li->lock);
163 if ((atomic_read(li->cpuflags) & CPUSTAT_STOPPED))
164 goto out;
163 list_add_tail(&inti->list, &li->list); 165 list_add_tail(&inti->list, &li->list);
164 atomic_set(&li->active, 1); 166 atomic_set(&li->active, 1);
165 atomic_set_mask(CPUSTAT_STOP_INT, li->cpuflags); 167 atomic_set_mask(CPUSTAT_STOP_INT, li->cpuflags);
166 li->action_bits |= action; 168 li->action_bits |= action;
167 if (waitqueue_active(&li->wq)) 169 if (waitqueue_active(&li->wq))
168 wake_up_interruptible(&li->wq); 170 wake_up_interruptible(&li->wq);
171out:
169 spin_unlock_bh(&li->lock); 172 spin_unlock_bh(&li->lock);
170 173
171 return 0; /* order accepted */ 174 return 0; /* order accepted */
@@ -220,7 +223,7 @@ static int __sigp_set_arch(struct kvm_vcpu *vcpu, u32 parameter)
220} 223}
221 224
222static int __sigp_set_prefix(struct kvm_vcpu *vcpu, u16 cpu_addr, u32 address, 225static int __sigp_set_prefix(struct kvm_vcpu *vcpu, u16 cpu_addr, u32 address,
223 unsigned long *reg) 226 u64 *reg)
224{ 227{
225 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int; 228 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int;
226 struct kvm_s390_local_interrupt *li = NULL; 229 struct kvm_s390_local_interrupt *li = NULL;
@@ -278,7 +281,7 @@ out_fi:
278} 281}
279 282
280static int __sigp_sense_running(struct kvm_vcpu *vcpu, u16 cpu_addr, 283static int __sigp_sense_running(struct kvm_vcpu *vcpu, u16 cpu_addr,
281 unsigned long *reg) 284 u64 *reg)
282{ 285{
283 int rc; 286 int rc;
284 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int; 287 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int;
@@ -309,6 +312,34 @@ static int __sigp_sense_running(struct kvm_vcpu *vcpu, u16 cpu_addr,
309 return rc; 312 return rc;
310} 313}
311 314
315static int __sigp_restart(struct kvm_vcpu *vcpu, u16 cpu_addr)
316{
317 int rc = 0;
318 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int;
319 struct kvm_s390_local_interrupt *li;
320
321 if (cpu_addr >= KVM_MAX_VCPUS)
322 return 3; /* not operational */
323
324 spin_lock(&fi->lock);
325 li = fi->local_int[cpu_addr];
326 if (li == NULL) {
327 rc = 3; /* not operational */
328 goto out;
329 }
330
331 spin_lock_bh(&li->lock);
332 if (li->action_bits & ACTION_STOP_ON_STOP)
333 rc = 2; /* busy */
334 else
335 VCPU_EVENT(vcpu, 4, "sigp restart %x to handle userspace",
336 cpu_addr);
337 spin_unlock_bh(&li->lock);
338out:
339 spin_unlock(&fi->lock);
340 return rc;
341}
342
312int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu) 343int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu)
313{ 344{
314 int r1 = (vcpu->arch.sie_block->ipa & 0x00f0) >> 4; 345 int r1 = (vcpu->arch.sie_block->ipa & 0x00f0) >> 4;
@@ -316,7 +347,7 @@ int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu)
316 int base2 = vcpu->arch.sie_block->ipb >> 28; 347 int base2 = vcpu->arch.sie_block->ipb >> 28;
317 int disp2 = ((vcpu->arch.sie_block->ipb & 0x0fff0000) >> 16); 348 int disp2 = ((vcpu->arch.sie_block->ipb & 0x0fff0000) >> 16);
318 u32 parameter; 349 u32 parameter;
319 u16 cpu_addr = vcpu->arch.guest_gprs[r3]; 350 u16 cpu_addr = vcpu->run->s.regs.gprs[r3];
320 u8 order_code; 351 u8 order_code;
321 int rc; 352 int rc;
322 353
@@ -327,18 +358,18 @@ int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu)
327 358
328 order_code = disp2; 359 order_code = disp2;
329 if (base2) 360 if (base2)
330 order_code += vcpu->arch.guest_gprs[base2]; 361 order_code += vcpu->run->s.regs.gprs[base2];
331 362
332 if (r1 % 2) 363 if (r1 % 2)
333 parameter = vcpu->arch.guest_gprs[r1]; 364 parameter = vcpu->run->s.regs.gprs[r1];
334 else 365 else
335 parameter = vcpu->arch.guest_gprs[r1 + 1]; 366 parameter = vcpu->run->s.regs.gprs[r1 + 1];
336 367
337 switch (order_code) { 368 switch (order_code) {
338 case SIGP_SENSE: 369 case SIGP_SENSE:
339 vcpu->stat.instruction_sigp_sense++; 370 vcpu->stat.instruction_sigp_sense++;
340 rc = __sigp_sense(vcpu, cpu_addr, 371 rc = __sigp_sense(vcpu, cpu_addr,
341 &vcpu->arch.guest_gprs[r1]); 372 &vcpu->run->s.regs.gprs[r1]);
342 break; 373 break;
343 case SIGP_EXTERNAL_CALL: 374 case SIGP_EXTERNAL_CALL:
344 vcpu->stat.instruction_sigp_external_call++; 375 vcpu->stat.instruction_sigp_external_call++;
@@ -354,7 +385,8 @@ int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu)
354 break; 385 break;
355 case SIGP_STOP_STORE_STATUS: 386 case SIGP_STOP_STORE_STATUS:
356 vcpu->stat.instruction_sigp_stop++; 387 vcpu->stat.instruction_sigp_stop++;
357 rc = __sigp_stop(vcpu, cpu_addr, ACTION_STORE_ON_STOP); 388 rc = __sigp_stop(vcpu, cpu_addr, ACTION_STORE_ON_STOP |
389 ACTION_STOP_ON_STOP);
358 break; 390 break;
359 case SIGP_SET_ARCH: 391 case SIGP_SET_ARCH:
360 vcpu->stat.instruction_sigp_arch++; 392 vcpu->stat.instruction_sigp_arch++;
@@ -363,15 +395,18 @@ int kvm_s390_handle_sigp(struct kvm_vcpu *vcpu)
363 case SIGP_SET_PREFIX: 395 case SIGP_SET_PREFIX:
364 vcpu->stat.instruction_sigp_prefix++; 396 vcpu->stat.instruction_sigp_prefix++;
365 rc = __sigp_set_prefix(vcpu, cpu_addr, parameter, 397 rc = __sigp_set_prefix(vcpu, cpu_addr, parameter,
366 &vcpu->arch.guest_gprs[r1]); 398 &vcpu->run->s.regs.gprs[r1]);
367 break; 399 break;
368 case SIGP_SENSE_RUNNING: 400 case SIGP_SENSE_RUNNING:
369 vcpu->stat.instruction_sigp_sense_running++; 401 vcpu->stat.instruction_sigp_sense_running++;
370 rc = __sigp_sense_running(vcpu, cpu_addr, 402 rc = __sigp_sense_running(vcpu, cpu_addr,
371 &vcpu->arch.guest_gprs[r1]); 403 &vcpu->run->s.regs.gprs[r1]);
372 break; 404 break;
373 case SIGP_RESTART: 405 case SIGP_RESTART:
374 vcpu->stat.instruction_sigp_restart++; 406 vcpu->stat.instruction_sigp_restart++;
407 rc = __sigp_restart(vcpu, cpu_addr);
408 if (rc == 2) /* busy */
409 break;
375 /* user space must know about restart */ 410 /* user space must know about restart */
376 default: 411 default:
377 return -EOPNOTSUPP; 412 return -EOPNOTSUPP;
diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
index a0155c02e32..2857c48486e 100644
--- a/arch/s390/mm/mmap.c
+++ b/arch/s390/mm/mmap.c
@@ -100,7 +100,6 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
100 mm->unmap_area = arch_unmap_area_topdown; 100 mm->unmap_area = arch_unmap_area_topdown;
101 } 101 }
102} 102}
103EXPORT_SYMBOL_GPL(arch_pick_mmap_layout);
104 103
105#else 104#else
106 105
@@ -175,6 +174,5 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
175 mm->unmap_area = arch_unmap_area_topdown; 174 mm->unmap_area = arch_unmap_area_topdown;
176 } 175 }
177} 176}
178EXPORT_SYMBOL_GPL(arch_pick_mmap_layout);
179 177
180#endif 178#endif
diff --git a/arch/s390/oprofile/hwsampler.c b/arch/s390/oprofile/hwsampler.c
index 59c9278befc..c6646de07bf 100644
--- a/arch/s390/oprofile/hwsampler.c
+++ b/arch/s390/oprofile/hwsampler.c
@@ -19,7 +19,7 @@
19#include <linux/oprofile.h> 19#include <linux/oprofile.h>
20 20
21#include <asm/facility.h> 21#include <asm/facility.h>
22#include <asm/lowcore.h> 22#include <asm/cpu_mf.h>
23#include <asm/irq.h> 23#include <asm/irq.h>
24 24
25#include "hwsampler.h" 25#include "hwsampler.h"
@@ -31,12 +31,6 @@
31#define ALERT_REQ_MASK 0x4000000000000000ul 31#define ALERT_REQ_MASK 0x4000000000000000ul
32#define BUFFER_FULL_MASK 0x8000000000000000ul 32#define BUFFER_FULL_MASK 0x8000000000000000ul
33 33
34#define EI_IEA (1 << 31) /* invalid entry address */
35#define EI_ISE (1 << 30) /* incorrect SDBT entry */
36#define EI_PRA (1 << 29) /* program request alert */
37#define EI_SACA (1 << 23) /* sampler authorization change alert */
38#define EI_LSDA (1 << 22) /* loss of sample data alert */
39
40DECLARE_PER_CPU(struct hws_cpu_buffer, sampler_cpu_buffer); 34DECLARE_PER_CPU(struct hws_cpu_buffer, sampler_cpu_buffer);
41 35
42struct hws_execute_parms { 36struct hws_execute_parms {
@@ -233,9 +227,20 @@ static inline unsigned long *trailer_entry_ptr(unsigned long v)
233 return (unsigned long *) ret; 227 return (unsigned long *) ret;
234} 228}
235 229
236/* prototypes for external interrupt handler and worker */
237static void hws_ext_handler(struct ext_code ext_code, 230static void hws_ext_handler(struct ext_code ext_code,
238 unsigned int param32, unsigned long param64); 231 unsigned int param32, unsigned long param64)
232{
233 struct hws_cpu_buffer *cb = &__get_cpu_var(sampler_cpu_buffer);
234
235 if (!(param32 & CPU_MF_INT_SF_MASK))
236 return;
237
238 kstat_cpu(smp_processor_id()).irqs[EXTINT_CPM]++;
239 atomic_xchg(&cb->ext_params, atomic_read(&cb->ext_params) | param32);
240
241 if (hws_wq)
242 queue_work(hws_wq, &cb->worker);
243}
239 244
240static void worker(struct work_struct *work); 245static void worker(struct work_struct *work);
241 246
@@ -674,18 +679,6 @@ int hwsampler_activate(unsigned int cpu)
674 return rc; 679 return rc;
675} 680}
676 681
677static void hws_ext_handler(struct ext_code ext_code,
678 unsigned int param32, unsigned long param64)
679{
680 struct hws_cpu_buffer *cb;
681
682 kstat_cpu(smp_processor_id()).irqs[EXTINT_CPM]++;
683 cb = &__get_cpu_var(sampler_cpu_buffer);
684 atomic_xchg(&cb->ext_params, atomic_read(&cb->ext_params) | param32);
685 if (hws_wq)
686 queue_work(hws_wq, &cb->worker);
687}
688
689static int check_qsi_on_setup(void) 682static int check_qsi_on_setup(void)
690{ 683{
691 int rc; 684 int rc;
@@ -761,23 +754,23 @@ static int worker_check_error(unsigned int cpu, int ext_params)
761 if (!sdbt || !*sdbt) 754 if (!sdbt || !*sdbt)
762 return -EINVAL; 755 return -EINVAL;
763 756
764 if (ext_params & EI_PRA) 757 if (ext_params & CPU_MF_INT_SF_PRA)
765 cb->req_alert++; 758 cb->req_alert++;
766 759
767 if (ext_params & EI_LSDA) 760 if (ext_params & CPU_MF_INT_SF_LSDA)
768 cb->loss_of_sample_data++; 761 cb->loss_of_sample_data++;
769 762
770 if (ext_params & EI_IEA) { 763 if (ext_params & CPU_MF_INT_SF_IAE) {
771 cb->invalid_entry_address++; 764 cb->invalid_entry_address++;
772 rc = -EINVAL; 765 rc = -EINVAL;
773 } 766 }
774 767
775 if (ext_params & EI_ISE) { 768 if (ext_params & CPU_MF_INT_SF_ISE) {
776 cb->incorrect_sdbt_entry++; 769 cb->incorrect_sdbt_entry++;
777 rc = -EINVAL; 770 rc = -EINVAL;
778 } 771 }
779 772
780 if (ext_params & EI_SACA) { 773 if (ext_params & CPU_MF_INT_SF_SACA) {
781 cb->sample_auth_change_alert++; 774 cb->sample_auth_change_alert++;
782 rc = -EINVAL; 775 rc = -EINVAL;
783 } 776 }
@@ -1010,7 +1003,7 @@ int hwsampler_deallocate(void)
1010 if (hws_state != HWS_STOPPED) 1003 if (hws_state != HWS_STOPPED)
1011 goto deallocate_exit; 1004 goto deallocate_exit;
1012 1005
1013 ctl_clear_bit(0, 5); /* set bit 58 CR0 off */ 1006 measurement_alert_subclass_unregister();
1014 deallocate_sdbt(); 1007 deallocate_sdbt();
1015 1008
1016 hws_state = HWS_DEALLOCATED; 1009 hws_state = HWS_DEALLOCATED;
@@ -1124,7 +1117,7 @@ int hwsampler_shutdown(void)
1124 mutex_lock(&hws_sem); 1117 mutex_lock(&hws_sem);
1125 1118
1126 if (hws_state == HWS_STOPPED) { 1119 if (hws_state == HWS_STOPPED) {
1127 ctl_clear_bit(0, 5); /* set bit 58 CR0 off */ 1120 measurement_alert_subclass_unregister();
1128 deallocate_sdbt(); 1121 deallocate_sdbt();
1129 } 1122 }
1130 if (hws_wq) { 1123 if (hws_wq) {
@@ -1199,7 +1192,7 @@ start_all_exit:
1199 hws_oom = 1; 1192 hws_oom = 1;
1200 hws_flush_all = 0; 1193 hws_flush_all = 0;
1201 /* now let them in, 1407 CPUMF external interrupts */ 1194 /* now let them in, 1407 CPUMF external interrupts */
1202 ctl_set_bit(0, 5); /* set CR0 bit 58 */ 1195 measurement_alert_subclass_register();
1203 1196
1204 return 0; 1197 return 0;
1205} 1198}
diff --git a/arch/sh/boards/mach-highlander/setup.c b/arch/sh/boards/mach-highlander/setup.c
index 74b8db1b74a..4a52590fe3d 100644
--- a/arch/sh/boards/mach-highlander/setup.c
+++ b/arch/sh/boards/mach-highlander/setup.c
@@ -322,7 +322,7 @@ static void ivdr_clk_disable(struct clk *clk)
322 __raw_writew(__raw_readw(PA_IVDRCTL) & ~(1 << IVDR_CK_ON), PA_IVDRCTL); 322 __raw_writew(__raw_readw(PA_IVDRCTL) & ~(1 << IVDR_CK_ON), PA_IVDRCTL);
323} 323}
324 324
325static struct clk_ops ivdr_clk_ops = { 325static struct sh_clk_ops ivdr_clk_ops = {
326 .enable = ivdr_clk_enable, 326 .enable = ivdr_clk_enable,
327 .disable = ivdr_clk_disable, 327 .disable = ivdr_clk_disable,
328}; 328};
diff --git a/arch/sh/boards/mach-sdk7786/setup.c b/arch/sh/boards/mach-sdk7786/setup.c
index 486d1ac3694..27a2314f50a 100644
--- a/arch/sh/boards/mach-sdk7786/setup.c
+++ b/arch/sh/boards/mach-sdk7786/setup.c
@@ -167,7 +167,7 @@ static void sdk7786_pcie_clk_disable(struct clk *clk)
167 fpga_write_reg(fpga_read_reg(PCIECR) & ~PCIECR_CLKEN, PCIECR); 167 fpga_write_reg(fpga_read_reg(PCIECR) & ~PCIECR_CLKEN, PCIECR);
168} 168}
169 169
170static struct clk_ops sdk7786_pcie_clk_ops = { 170static struct sh_clk_ops sdk7786_pcie_clk_ops = {
171 .enable = sdk7786_pcie_clk_enable, 171 .enable = sdk7786_pcie_clk_enable,
172 .disable = sdk7786_pcie_clk_disable, 172 .disable = sdk7786_pcie_clk_disable,
173}; 173};
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index 1e7b0e2e764..9d10a3cb879 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -37,11 +37,20 @@ static void __devinit pcibios_scanbus(struct pci_channel *hose)
37 static int next_busno; 37 static int next_busno;
38 static int need_domain_info; 38 static int need_domain_info;
39 LIST_HEAD(resources); 39 LIST_HEAD(resources);
40 struct resource *res;
41 resource_size_t offset;
40 int i; 42 int i;
41 struct pci_bus *bus; 43 struct pci_bus *bus;
42 44
43 for (i = 0; i < hose->nr_resources; i++) 45 for (i = 0; i < hose->nr_resources; i++) {
44 pci_add_resource(&resources, hose->resources + i); 46 res = hose->resources + i;
47 offset = 0;
48 if (res->flags & IORESOURCE_IO)
49 offset = hose->io_offset;
50 else if (res->flags & IORESOURCE_MEM)
51 offset = hose->mem_offset;
52 pci_add_resource_offset(&resources, res, offset);
53 }
45 54
46 bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose, 55 bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose,
47 &resources); 56 &resources);
@@ -143,42 +152,12 @@ static int __init pcibios_init(void)
143} 152}
144subsys_initcall(pcibios_init); 153subsys_initcall(pcibios_init);
145 154
146static void pcibios_fixup_device_resources(struct pci_dev *dev,
147 struct pci_bus *bus)
148{
149 /* Update device resources. */
150 struct pci_channel *hose = bus->sysdata;
151 unsigned long offset = 0;
152 int i;
153
154 for (i = 0; i < PCI_NUM_RESOURCES; i++) {
155 if (!dev->resource[i].start)
156 continue;
157 if (dev->resource[i].flags & IORESOURCE_IO)
158 offset = hose->io_offset;
159 else if (dev->resource[i].flags & IORESOURCE_MEM)
160 offset = hose->mem_offset;
161
162 dev->resource[i].start += offset;
163 dev->resource[i].end += offset;
164 }
165}
166
167/* 155/*
168 * Called after each bus is probed, but before its children 156 * Called after each bus is probed, but before its children
169 * are examined. 157 * are examined.
170 */ 158 */
171void __devinit pcibios_fixup_bus(struct pci_bus *bus) 159void __devinit pcibios_fixup_bus(struct pci_bus *bus)
172{ 160{
173 struct pci_dev *dev;
174 struct list_head *ln;
175
176 for (ln = bus->devices.next; ln != &bus->devices; ln = ln->next) {
177 dev = pci_dev_b(ln);
178
179 if ((dev->class >> 8) != PCI_CLASS_BRIDGE_PCI)
180 pcibios_fixup_device_resources(dev, bus);
181 }
182} 161}
183 162
184/* 163/*
@@ -208,36 +187,6 @@ resource_size_t pcibios_align_resource(void *data, const struct resource *res,
208 return start; 187 return start;
209} 188}
210 189
211void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
212 struct resource *res)
213{
214 struct pci_channel *hose = dev->sysdata;
215 unsigned long offset = 0;
216
217 if (res->flags & IORESOURCE_IO)
218 offset = hose->io_offset;
219 else if (res->flags & IORESOURCE_MEM)
220 offset = hose->mem_offset;
221
222 region->start = res->start - offset;
223 region->end = res->end - offset;
224}
225
226void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
227 struct pci_bus_region *region)
228{
229 struct pci_channel *hose = dev->sysdata;
230 unsigned long offset = 0;
231
232 if (res->flags & IORESOURCE_IO)
233 offset = hose->io_offset;
234 else if (res->flags & IORESOURCE_MEM)
235 offset = hose->mem_offset;
236
237 res->start = region->start + offset;
238 res->end = region->end + offset;
239}
240
241int pcibios_enable_device(struct pci_dev *dev, int mask) 190int pcibios_enable_device(struct pci_dev *dev, int mask)
242{ 191{
243 return pci_enable_resources(dev, mask); 192 return pci_enable_resources(dev, mask);
@@ -381,8 +330,6 @@ EXPORT_SYMBOL(pci_iounmap);
381#endif /* CONFIG_GENERIC_IOMAP */ 330#endif /* CONFIG_GENERIC_IOMAP */
382 331
383#ifdef CONFIG_HOTPLUG 332#ifdef CONFIG_HOTPLUG
384EXPORT_SYMBOL(pcibios_resource_to_bus);
385EXPORT_SYMBOL(pcibios_bus_to_resource);
386EXPORT_SYMBOL(PCIBIOS_MIN_IO); 333EXPORT_SYMBOL(PCIBIOS_MIN_IO);
387EXPORT_SYMBOL(PCIBIOS_MIN_MEM); 334EXPORT_SYMBOL(PCIBIOS_MIN_MEM);
388#endif 335#endif
diff --git a/arch/sh/include/asm/clock.h b/arch/sh/include/asm/clock.h
index 803d4c7f09d..0390a07e7e3 100644
--- a/arch/sh/include/asm/clock.h
+++ b/arch/sh/include/asm/clock.h
@@ -4,7 +4,7 @@
4#include <linux/sh_clk.h> 4#include <linux/sh_clk.h>
5 5
6/* Should be defined by processor-specific code */ 6/* Should be defined by processor-specific code */
7void __deprecated arch_init_clk_ops(struct clk_ops **, int type); 7void __deprecated arch_init_clk_ops(struct sh_clk_ops **, int type);
8int __init arch_clk_init(void); 8int __init arch_clk_init(void);
9 9
10/* arch/sh/kernel/cpu/clock-cpg.c */ 10/* arch/sh/kernel/cpu/clock-cpg.c */
diff --git a/arch/sh/include/asm/pci.h b/arch/sh/include/asm/pci.h
index cb21e2399dc..bff96c2e7d2 100644
--- a/arch/sh/include/asm/pci.h
+++ b/arch/sh/include/asm/pci.h
@@ -114,12 +114,6 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
114/* Board-specific fixup routines. */ 114/* Board-specific fixup routines. */
115int pcibios_map_platform_irq(const struct pci_dev *dev, u8 slot, u8 pin); 115int pcibios_map_platform_irq(const struct pci_dev *dev, u8 slot, u8 pin);
116 116
117extern void pcibios_resource_to_bus(struct pci_dev *dev,
118 struct pci_bus_region *region, struct resource *res);
119
120extern void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
121 struct pci_bus_region *region);
122
123#define pci_domain_nr(bus) ((struct pci_channel *)(bus)->sysdata)->index 117#define pci_domain_nr(bus) ((struct pci_channel *)(bus)->sysdata)->index
124 118
125static inline int pci_proc_domain(struct pci_bus *bus) 119static inline int pci_proc_domain(struct pci_bus *bus)
diff --git a/arch/sh/kernel/cpu/sh2/clock-sh7619.c b/arch/sh/kernel/cpu/sh2/clock-sh7619.c
index 5b7f12e58a8..e80252ae5bc 100644
--- a/arch/sh/kernel/cpu/sh2/clock-sh7619.c
+++ b/arch/sh/kernel/cpu/sh2/clock-sh7619.c
@@ -28,7 +28,7 @@ static void master_clk_init(struct clk *clk)
28 clk->rate *= pll2_mult * pll1rate[(__raw_readw(FREQCR) >> 8) & 7]; 28 clk->rate *= pll2_mult * pll1rate[(__raw_readw(FREQCR) >> 8) & 7];
29} 29}
30 30
31static struct clk_ops sh7619_master_clk_ops = { 31static struct sh_clk_ops sh7619_master_clk_ops = {
32 .init = master_clk_init, 32 .init = master_clk_init,
33}; 33};
34 34
@@ -38,7 +38,7 @@ static unsigned long module_clk_recalc(struct clk *clk)
38 return clk->parent->rate / pfc_divisors[idx]; 38 return clk->parent->rate / pfc_divisors[idx];
39} 39}
40 40
41static struct clk_ops sh7619_module_clk_ops = { 41static struct sh_clk_ops sh7619_module_clk_ops = {
42 .recalc = module_clk_recalc, 42 .recalc = module_clk_recalc,
43}; 43};
44 44
@@ -47,22 +47,22 @@ static unsigned long bus_clk_recalc(struct clk *clk)
47 return clk->parent->rate / pll1rate[(__raw_readw(FREQCR) >> 8) & 7]; 47 return clk->parent->rate / pll1rate[(__raw_readw(FREQCR) >> 8) & 7];
48} 48}
49 49
50static struct clk_ops sh7619_bus_clk_ops = { 50static struct sh_clk_ops sh7619_bus_clk_ops = {
51 .recalc = bus_clk_recalc, 51 .recalc = bus_clk_recalc,
52}; 52};
53 53
54static struct clk_ops sh7619_cpu_clk_ops = { 54static struct sh_clk_ops sh7619_cpu_clk_ops = {
55 .recalc = followparent_recalc, 55 .recalc = followparent_recalc,
56}; 56};
57 57
58static struct clk_ops *sh7619_clk_ops[] = { 58static struct sh_clk_ops *sh7619_clk_ops[] = {
59 &sh7619_master_clk_ops, 59 &sh7619_master_clk_ops,
60 &sh7619_module_clk_ops, 60 &sh7619_module_clk_ops,
61 &sh7619_bus_clk_ops, 61 &sh7619_bus_clk_ops,
62 &sh7619_cpu_clk_ops, 62 &sh7619_cpu_clk_ops,
63}; 63};
64 64
65void __init arch_init_clk_ops(struct clk_ops **ops, int idx) 65void __init arch_init_clk_ops(struct sh_clk_ops **ops, int idx)
66{ 66{
67 if (test_mode_pin(MODE_PIN2 | MODE_PIN0) || 67 if (test_mode_pin(MODE_PIN2 | MODE_PIN0) ||
68 test_mode_pin(MODE_PIN2 | MODE_PIN1)) 68 test_mode_pin(MODE_PIN2 | MODE_PIN1))
diff --git a/arch/sh/kernel/cpu/sh2a/clock-sh7201.c b/arch/sh/kernel/cpu/sh2a/clock-sh7201.c
index 1174e2d96c0..532a36c7232 100644
--- a/arch/sh/kernel/cpu/sh2a/clock-sh7201.c
+++ b/arch/sh/kernel/cpu/sh2a/clock-sh7201.c
@@ -30,7 +30,7 @@ static void master_clk_init(struct clk *clk)
30 pll1rate[(__raw_readw(FREQCR) >> 8) & 0x0007]; 30 pll1rate[(__raw_readw(FREQCR) >> 8) & 0x0007];
31} 31}
32 32
33static struct clk_ops sh7201_master_clk_ops = { 33static struct sh_clk_ops sh7201_master_clk_ops = {
34 .init = master_clk_init, 34 .init = master_clk_init,
35}; 35};
36 36
@@ -40,7 +40,7 @@ static unsigned long module_clk_recalc(struct clk *clk)
40 return clk->parent->rate / pfc_divisors[idx]; 40 return clk->parent->rate / pfc_divisors[idx];
41} 41}
42 42
43static struct clk_ops sh7201_module_clk_ops = { 43static struct sh_clk_ops sh7201_module_clk_ops = {
44 .recalc = module_clk_recalc, 44 .recalc = module_clk_recalc,
45}; 45};
46 46
@@ -50,7 +50,7 @@ static unsigned long bus_clk_recalc(struct clk *clk)
50 return clk->parent->rate / pfc_divisors[idx]; 50 return clk->parent->rate / pfc_divisors[idx];
51} 51}
52 52
53static struct clk_ops sh7201_bus_clk_ops = { 53static struct sh_clk_ops sh7201_bus_clk_ops = {
54 .recalc = bus_clk_recalc, 54 .recalc = bus_clk_recalc,
55}; 55};
56 56
@@ -60,18 +60,18 @@ static unsigned long cpu_clk_recalc(struct clk *clk)
60 return clk->parent->rate / ifc_divisors[idx]; 60 return clk->parent->rate / ifc_divisors[idx];
61} 61}
62 62
63static struct clk_ops sh7201_cpu_clk_ops = { 63static struct sh_clk_ops sh7201_cpu_clk_ops = {
64 .recalc = cpu_clk_recalc, 64 .recalc = cpu_clk_recalc,
65}; 65};
66 66
67static struct clk_ops *sh7201_clk_ops[] = { 67static struct sh_clk_ops *sh7201_clk_ops[] = {
68 &sh7201_master_clk_ops, 68 &sh7201_master_clk_ops,
69 &sh7201_module_clk_ops, 69 &sh7201_module_clk_ops,
70 &sh7201_bus_clk_ops, 70 &sh7201_bus_clk_ops,
71 &sh7201_cpu_clk_ops, 71 &sh7201_cpu_clk_ops,
72}; 72};
73 73
74void __init arch_init_clk_ops(struct clk_ops **ops, int idx) 74void __init arch_init_clk_ops(struct sh_clk_ops **ops, int idx)
75{ 75{
76 if (test_mode_pin(MODE_PIN1 | MODE_PIN0)) 76 if (test_mode_pin(MODE_PIN1 | MODE_PIN0))
77 pll2_mult = 1; 77 pll2_mult = 1;
diff --git a/arch/sh/kernel/cpu/sh2a/clock-sh7203.c b/arch/sh/kernel/cpu/sh2a/clock-sh7203.c
index 95a008e8b73..529f719b6e3 100644
--- a/arch/sh/kernel/cpu/sh2a/clock-sh7203.c
+++ b/arch/sh/kernel/cpu/sh2a/clock-sh7203.c
@@ -32,7 +32,7 @@ static void master_clk_init(struct clk *clk)
32 clk->rate *= pll1rate[(__raw_readw(FREQCR) >> 8) & 0x0003] * pll2_mult; 32 clk->rate *= pll1rate[(__raw_readw(FREQCR) >> 8) & 0x0003] * pll2_mult;
33} 33}
34 34
35static struct clk_ops sh7203_master_clk_ops = { 35static struct sh_clk_ops sh7203_master_clk_ops = {
36 .init = master_clk_init, 36 .init = master_clk_init,
37}; 37};
38 38
@@ -42,7 +42,7 @@ static unsigned long module_clk_recalc(struct clk *clk)
42 return clk->parent->rate / pfc_divisors[idx]; 42 return clk->parent->rate / pfc_divisors[idx];
43} 43}
44 44
45static struct clk_ops sh7203_module_clk_ops = { 45static struct sh_clk_ops sh7203_module_clk_ops = {
46 .recalc = module_clk_recalc, 46 .recalc = module_clk_recalc,
47}; 47};
48 48
@@ -52,22 +52,22 @@ static unsigned long bus_clk_recalc(struct clk *clk)
52 return clk->parent->rate / pfc_divisors[idx-2]; 52 return clk->parent->rate / pfc_divisors[idx-2];
53} 53}
54 54
55static struct clk_ops sh7203_bus_clk_ops = { 55static struct sh_clk_ops sh7203_bus_clk_ops = {
56 .recalc = bus_clk_recalc, 56 .recalc = bus_clk_recalc,
57}; 57};
58 58
59static struct clk_ops sh7203_cpu_clk_ops = { 59static struct sh_clk_ops sh7203_cpu_clk_ops = {
60 .recalc = followparent_recalc, 60 .recalc = followparent_recalc,
61}; 61};
62 62
63static struct clk_ops *sh7203_clk_ops[] = { 63static struct sh_clk_ops *sh7203_clk_ops[] = {
64 &sh7203_master_clk_ops, 64 &sh7203_master_clk_ops,
65 &sh7203_module_clk_ops, 65 &sh7203_module_clk_ops,
66 &sh7203_bus_clk_ops, 66 &sh7203_bus_clk_ops,
67 &sh7203_cpu_clk_ops, 67 &sh7203_cpu_clk_ops,
68}; 68};
69 69
70void __init arch_init_clk_ops(struct clk_ops **ops, int idx) 70void __init arch_init_clk_ops(struct sh_clk_ops **ops, int idx)
71{ 71{
72 if (test_mode_pin(MODE_PIN1)) 72 if (test_mode_pin(MODE_PIN1))
73 pll2_mult = 4; 73 pll2_mult = 4;
diff --git a/arch/sh/kernel/cpu/sh2a/clock-sh7206.c b/arch/sh/kernel/cpu/sh2a/clock-sh7206.c
index 3c314d7cd6e..17778983467 100644
--- a/arch/sh/kernel/cpu/sh2a/clock-sh7206.c
+++ b/arch/sh/kernel/cpu/sh2a/clock-sh7206.c
@@ -29,7 +29,7 @@ static void master_clk_init(struct clk *clk)
29 clk->rate *= pll2_mult * pll1rate[(__raw_readw(FREQCR) >> 8) & 0x0007]; 29 clk->rate *= pll2_mult * pll1rate[(__raw_readw(FREQCR) >> 8) & 0x0007];
30} 30}
31 31
32static struct clk_ops sh7206_master_clk_ops = { 32static struct sh_clk_ops sh7206_master_clk_ops = {
33 .init = master_clk_init, 33 .init = master_clk_init,
34}; 34};
35 35
@@ -39,7 +39,7 @@ static unsigned long module_clk_recalc(struct clk *clk)
39 return clk->parent->rate / pfc_divisors[idx]; 39 return clk->parent->rate / pfc_divisors[idx];
40} 40}
41 41
42static struct clk_ops sh7206_module_clk_ops = { 42static struct sh_clk_ops sh7206_module_clk_ops = {
43 .recalc = module_clk_recalc, 43 .recalc = module_clk_recalc,
44}; 44};
45 45
@@ -48,7 +48,7 @@ static unsigned long bus_clk_recalc(struct clk *clk)
48 return clk->parent->rate / pll1rate[(__raw_readw(FREQCR) >> 8) & 0x0007]; 48 return clk->parent->rate / pll1rate[(__raw_readw(FREQCR) >> 8) & 0x0007];
49} 49}
50 50
51static struct clk_ops sh7206_bus_clk_ops = { 51static struct sh_clk_ops sh7206_bus_clk_ops = {
52 .recalc = bus_clk_recalc, 52 .recalc = bus_clk_recalc,
53}; 53};
54 54
@@ -58,18 +58,18 @@ static unsigned long cpu_clk_recalc(struct clk *clk)
58 return clk->parent->rate / ifc_divisors[idx]; 58 return clk->parent->rate / ifc_divisors[idx];
59} 59}
60 60
61static struct clk_ops sh7206_cpu_clk_ops = { 61static struct sh_clk_ops sh7206_cpu_clk_ops = {
62 .recalc = cpu_clk_recalc, 62 .recalc = cpu_clk_recalc,
63}; 63};
64 64
65static struct clk_ops *sh7206_clk_ops[] = { 65static struct sh_clk_ops *sh7206_clk_ops[] = {
66 &sh7206_master_clk_ops, 66 &sh7206_master_clk_ops,
67 &sh7206_module_clk_ops, 67 &sh7206_module_clk_ops,
68 &sh7206_bus_clk_ops, 68 &sh7206_bus_clk_ops,
69 &sh7206_cpu_clk_ops, 69 &sh7206_cpu_clk_ops,
70}; 70};
71 71
72void __init arch_init_clk_ops(struct clk_ops **ops, int idx) 72void __init arch_init_clk_ops(struct sh_clk_ops **ops, int idx)
73{ 73{
74 if (test_mode_pin(MODE_PIN2 | MODE_PIN1 | MODE_PIN0)) 74 if (test_mode_pin(MODE_PIN2 | MODE_PIN1 | MODE_PIN0))
75 pll2_mult = 1; 75 pll2_mult = 1;
diff --git a/arch/sh/kernel/cpu/sh3/clock-sh3.c b/arch/sh/kernel/cpu/sh3/clock-sh3.c
index b78384afac0..90faa44ca94 100644
--- a/arch/sh/kernel/cpu/sh3/clock-sh3.c
+++ b/arch/sh/kernel/cpu/sh3/clock-sh3.c
@@ -34,7 +34,7 @@ static void master_clk_init(struct clk *clk)
34 clk->rate *= pfc_divisors[idx]; 34 clk->rate *= pfc_divisors[idx];
35} 35}
36 36
37static struct clk_ops sh3_master_clk_ops = { 37static struct sh_clk_ops sh3_master_clk_ops = {
38 .init = master_clk_init, 38 .init = master_clk_init,
39}; 39};
40 40
@@ -46,7 +46,7 @@ static unsigned long module_clk_recalc(struct clk *clk)
46 return clk->parent->rate / pfc_divisors[idx]; 46 return clk->parent->rate / pfc_divisors[idx];
47} 47}
48 48
49static struct clk_ops sh3_module_clk_ops = { 49static struct sh_clk_ops sh3_module_clk_ops = {
50 .recalc = module_clk_recalc, 50 .recalc = module_clk_recalc,
51}; 51};
52 52
@@ -58,7 +58,7 @@ static unsigned long bus_clk_recalc(struct clk *clk)
58 return clk->parent->rate / stc_multipliers[idx]; 58 return clk->parent->rate / stc_multipliers[idx];
59} 59}
60 60
61static struct clk_ops sh3_bus_clk_ops = { 61static struct sh_clk_ops sh3_bus_clk_ops = {
62 .recalc = bus_clk_recalc, 62 .recalc = bus_clk_recalc,
63}; 63};
64 64
@@ -70,18 +70,18 @@ static unsigned long cpu_clk_recalc(struct clk *clk)
70 return clk->parent->rate / ifc_divisors[idx]; 70 return clk->parent->rate / ifc_divisors[idx];
71} 71}
72 72
73static struct clk_ops sh3_cpu_clk_ops = { 73static struct sh_clk_ops sh3_cpu_clk_ops = {
74 .recalc = cpu_clk_recalc, 74 .recalc = cpu_clk_recalc,
75}; 75};
76 76
77static struct clk_ops *sh3_clk_ops[] = { 77static struct sh_clk_ops *sh3_clk_ops[] = {
78 &sh3_master_clk_ops, 78 &sh3_master_clk_ops,
79 &sh3_module_clk_ops, 79 &sh3_module_clk_ops,
80 &sh3_bus_clk_ops, 80 &sh3_bus_clk_ops,
81 &sh3_cpu_clk_ops, 81 &sh3_cpu_clk_ops,
82}; 82};
83 83
84void __init arch_init_clk_ops(struct clk_ops **ops, int idx) 84void __init arch_init_clk_ops(struct sh_clk_ops **ops, int idx)
85{ 85{
86 if (idx < ARRAY_SIZE(sh3_clk_ops)) 86 if (idx < ARRAY_SIZE(sh3_clk_ops))
87 *ops = sh3_clk_ops[idx]; 87 *ops = sh3_clk_ops[idx];
diff --git a/arch/sh/kernel/cpu/sh3/clock-sh7705.c b/arch/sh/kernel/cpu/sh3/clock-sh7705.c
index 0ecea1451c6..a8da4a9986b 100644
--- a/arch/sh/kernel/cpu/sh3/clock-sh7705.c
+++ b/arch/sh/kernel/cpu/sh3/clock-sh7705.c
@@ -35,7 +35,7 @@ static void master_clk_init(struct clk *clk)
35 clk->rate *= pfc_divisors[__raw_readw(FRQCR) & 0x0003]; 35 clk->rate *= pfc_divisors[__raw_readw(FRQCR) & 0x0003];
36} 36}
37 37
38static struct clk_ops sh7705_master_clk_ops = { 38static struct sh_clk_ops sh7705_master_clk_ops = {
39 .init = master_clk_init, 39 .init = master_clk_init,
40}; 40};
41 41
@@ -45,7 +45,7 @@ static unsigned long module_clk_recalc(struct clk *clk)
45 return clk->parent->rate / pfc_divisors[idx]; 45 return clk->parent->rate / pfc_divisors[idx];
46} 46}
47 47
48static struct clk_ops sh7705_module_clk_ops = { 48static struct sh_clk_ops sh7705_module_clk_ops = {
49 .recalc = module_clk_recalc, 49 .recalc = module_clk_recalc,
50}; 50};
51 51
@@ -55,7 +55,7 @@ static unsigned long bus_clk_recalc(struct clk *clk)
55 return clk->parent->rate / stc_multipliers[idx]; 55 return clk->parent->rate / stc_multipliers[idx];
56} 56}
57 57
58static struct clk_ops sh7705_bus_clk_ops = { 58static struct sh_clk_ops sh7705_bus_clk_ops = {
59 .recalc = bus_clk_recalc, 59 .recalc = bus_clk_recalc,
60}; 60};
61 61
@@ -65,18 +65,18 @@ static unsigned long cpu_clk_recalc(struct clk *clk)
65 return clk->parent->rate / ifc_divisors[idx]; 65 return clk->parent->rate / ifc_divisors[idx];
66} 66}
67 67
68static struct clk_ops sh7705_cpu_clk_ops = { 68static struct sh_clk_ops sh7705_cpu_clk_ops = {
69 .recalc = cpu_clk_recalc, 69 .recalc = cpu_clk_recalc,
70}; 70};
71 71
72static struct clk_ops *sh7705_clk_ops[] = { 72static struct sh_clk_ops *sh7705_clk_ops[] = {
73 &sh7705_master_clk_ops, 73 &sh7705_master_clk_ops,
74 &sh7705_module_clk_ops, 74 &sh7705_module_clk_ops,
75 &sh7705_bus_clk_ops, 75 &sh7705_bus_clk_ops,
76 &sh7705_cpu_clk_ops, 76 &sh7705_cpu_clk_ops,
77}; 77};
78 78
79void __init arch_init_clk_ops(struct clk_ops **ops, int idx) 79void __init arch_init_clk_ops(struct sh_clk_ops **ops, int idx)
80{ 80{
81 if (idx < ARRAY_SIZE(sh7705_clk_ops)) 81 if (idx < ARRAY_SIZE(sh7705_clk_ops))
82 *ops = sh7705_clk_ops[idx]; 82 *ops = sh7705_clk_ops[idx];
diff --git a/arch/sh/kernel/cpu/sh3/clock-sh7706.c b/arch/sh/kernel/cpu/sh3/clock-sh7706.c
index 6f9ff8b57dd..a4088e5b220 100644
--- a/arch/sh/kernel/cpu/sh3/clock-sh7706.c
+++ b/arch/sh/kernel/cpu/sh3/clock-sh7706.c
@@ -30,7 +30,7 @@ static void master_clk_init(struct clk *clk)
30 clk->rate *= pfc_divisors[idx]; 30 clk->rate *= pfc_divisors[idx];
31} 31}
32 32
33static struct clk_ops sh7706_master_clk_ops = { 33static struct sh_clk_ops sh7706_master_clk_ops = {
34 .init = master_clk_init, 34 .init = master_clk_init,
35}; 35};
36 36
@@ -42,7 +42,7 @@ static unsigned long module_clk_recalc(struct clk *clk)
42 return clk->parent->rate / pfc_divisors[idx]; 42 return clk->parent->rate / pfc_divisors[idx];
43} 43}
44 44
45static struct clk_ops sh7706_module_clk_ops = { 45static struct sh_clk_ops sh7706_module_clk_ops = {
46 .recalc = module_clk_recalc, 46 .recalc = module_clk_recalc,
47}; 47};
48 48
@@ -54,7 +54,7 @@ static unsigned long bus_clk_recalc(struct clk *clk)
54 return clk->parent->rate / stc_multipliers[idx]; 54 return clk->parent->rate / stc_multipliers[idx];
55} 55}
56 56
57static struct clk_ops sh7706_bus_clk_ops = { 57static struct sh_clk_ops sh7706_bus_clk_ops = {
58 .recalc = bus_clk_recalc, 58 .recalc = bus_clk_recalc,
59}; 59};
60 60
@@ -66,18 +66,18 @@ static unsigned long cpu_clk_recalc(struct clk *clk)
66 return clk->parent->rate / ifc_divisors[idx]; 66 return clk->parent->rate / ifc_divisors[idx];
67} 67}
68 68
69static struct clk_ops sh7706_cpu_clk_ops = { 69static struct sh_clk_ops sh7706_cpu_clk_ops = {
70 .recalc = cpu_clk_recalc, 70 .recalc = cpu_clk_recalc,
71}; 71};
72 72
73static struct clk_ops *sh7706_clk_ops[] = { 73static struct sh_clk_ops *sh7706_clk_ops[] = {
74 &sh7706_master_clk_ops, 74 &sh7706_master_clk_ops,
75 &sh7706_module_clk_ops, 75 &sh7706_module_clk_ops,
76 &sh7706_bus_clk_ops, 76 &sh7706_bus_clk_ops,
77 &sh7706_cpu_clk_ops, 77 &sh7706_cpu_clk_ops,
78}; 78};
79 79
80void __init arch_init_clk_ops(struct clk_ops **ops, int idx) 80void __init arch_init_clk_ops(struct sh_clk_ops **ops, int idx)
81{ 81{
82 if (idx < ARRAY_SIZE(sh7706_clk_ops)) 82 if (idx < ARRAY_SIZE(sh7706_clk_ops))
83 *ops = sh7706_clk_ops[idx]; 83 *ops = sh7706_clk_ops[idx];
diff --git a/arch/sh/kernel/cpu/sh3/clock-sh7709.c b/arch/sh/kernel/cpu/sh3/clock-sh7709.c
index f302ba09e68..54a6d4bcc0d 100644
--- a/arch/sh/kernel/cpu/sh3/clock-sh7709.c
+++ b/arch/sh/kernel/cpu/sh3/clock-sh7709.c
@@ -30,7 +30,7 @@ static void master_clk_init(struct clk *clk)
30 clk->rate *= pfc_divisors[idx]; 30 clk->rate *= pfc_divisors[idx];
31} 31}
32 32
33static struct clk_ops sh7709_master_clk_ops = { 33static struct sh_clk_ops sh7709_master_clk_ops = {
34 .init = master_clk_init, 34 .init = master_clk_init,
35}; 35};
36 36
@@ -42,7 +42,7 @@ static unsigned long module_clk_recalc(struct clk *clk)
42 return clk->parent->rate / pfc_divisors[idx]; 42 return clk->parent->rate / pfc_divisors[idx];
43} 43}
44 44
45static struct clk_ops sh7709_module_clk_ops = { 45static struct sh_clk_ops sh7709_module_clk_ops = {
46 .recalc = module_clk_recalc, 46 .recalc = module_clk_recalc,
47}; 47};
48 48
@@ -55,7 +55,7 @@ static unsigned long bus_clk_recalc(struct clk *clk)
55 return clk->parent->rate * stc_multipliers[idx]; 55 return clk->parent->rate * stc_multipliers[idx];
56} 56}
57 57
58static struct clk_ops sh7709_bus_clk_ops = { 58static struct sh_clk_ops sh7709_bus_clk_ops = {
59 .recalc = bus_clk_recalc, 59 .recalc = bus_clk_recalc,
60}; 60};
61 61
@@ -67,18 +67,18 @@ static unsigned long cpu_clk_recalc(struct clk *clk)
67 return clk->parent->rate / ifc_divisors[idx]; 67 return clk->parent->rate / ifc_divisors[idx];
68} 68}
69 69
70static struct clk_ops sh7709_cpu_clk_ops = { 70static struct sh_clk_ops sh7709_cpu_clk_ops = {
71 .recalc = cpu_clk_recalc, 71 .recalc = cpu_clk_recalc,
72}; 72};
73 73
74static struct clk_ops *sh7709_clk_ops[] = { 74static struct sh_clk_ops *sh7709_clk_ops[] = {
75 &sh7709_master_clk_ops, 75 &sh7709_master_clk_ops,
76 &sh7709_module_clk_ops, 76 &sh7709_module_clk_ops,
77 &sh7709_bus_clk_ops, 77 &sh7709_bus_clk_ops,
78 &sh7709_cpu_clk_ops, 78 &sh7709_cpu_clk_ops,
79}; 79};
80 80
81void __init arch_init_clk_ops(struct clk_ops **ops, int idx) 81void __init arch_init_clk_ops(struct sh_clk_ops **ops, int idx)
82{ 82{
83 if (idx < ARRAY_SIZE(sh7709_clk_ops)) 83 if (idx < ARRAY_SIZE(sh7709_clk_ops))
84 *ops = sh7709_clk_ops[idx]; 84 *ops = sh7709_clk_ops[idx];
diff --git a/arch/sh/kernel/cpu/sh3/clock-sh7710.c b/arch/sh/kernel/cpu/sh3/clock-sh7710.c
index 29a87d8946a..ce601b2e397 100644
--- a/arch/sh/kernel/cpu/sh3/clock-sh7710.c
+++ b/arch/sh/kernel/cpu/sh3/clock-sh7710.c
@@ -29,7 +29,7 @@ static void master_clk_init(struct clk *clk)
29 clk->rate *= md_table[__raw_readw(FRQCR) & 0x0007]; 29 clk->rate *= md_table[__raw_readw(FRQCR) & 0x0007];
30} 30}
31 31
32static struct clk_ops sh7710_master_clk_ops = { 32static struct sh_clk_ops sh7710_master_clk_ops = {
33 .init = master_clk_init, 33 .init = master_clk_init,
34}; 34};
35 35
@@ -39,7 +39,7 @@ static unsigned long module_clk_recalc(struct clk *clk)
39 return clk->parent->rate / md_table[idx]; 39 return clk->parent->rate / md_table[idx];
40} 40}
41 41
42static struct clk_ops sh7710_module_clk_ops = { 42static struct sh_clk_ops sh7710_module_clk_ops = {
43 .recalc = module_clk_recalc, 43 .recalc = module_clk_recalc,
44}; 44};
45 45
@@ -49,7 +49,7 @@ static unsigned long bus_clk_recalc(struct clk *clk)
49 return clk->parent->rate / md_table[idx]; 49 return clk->parent->rate / md_table[idx];
50} 50}
51 51
52static struct clk_ops sh7710_bus_clk_ops = { 52static struct sh_clk_ops sh7710_bus_clk_ops = {
53 .recalc = bus_clk_recalc, 53 .recalc = bus_clk_recalc,
54}; 54};
55 55
@@ -59,18 +59,18 @@ static unsigned long cpu_clk_recalc(struct clk *clk)
59 return clk->parent->rate / md_table[idx]; 59 return clk->parent->rate / md_table[idx];
60} 60}
61 61
62static struct clk_ops sh7710_cpu_clk_ops = { 62static struct sh_clk_ops sh7710_cpu_clk_ops = {
63 .recalc = cpu_clk_recalc, 63 .recalc = cpu_clk_recalc,
64}; 64};
65 65
66static struct clk_ops *sh7710_clk_ops[] = { 66static struct sh_clk_ops *sh7710_clk_ops[] = {
67 &sh7710_master_clk_ops, 67 &sh7710_master_clk_ops,
68 &sh7710_module_clk_ops, 68 &sh7710_module_clk_ops,
69 &sh7710_bus_clk_ops, 69 &sh7710_bus_clk_ops,
70 &sh7710_cpu_clk_ops, 70 &sh7710_cpu_clk_ops,
71}; 71};
72 72
73void __init arch_init_clk_ops(struct clk_ops **ops, int idx) 73void __init arch_init_clk_ops(struct sh_clk_ops **ops, int idx)
74{ 74{
75 if (idx < ARRAY_SIZE(sh7710_clk_ops)) 75 if (idx < ARRAY_SIZE(sh7710_clk_ops))
76 *ops = sh7710_clk_ops[idx]; 76 *ops = sh7710_clk_ops[idx];
diff --git a/arch/sh/kernel/cpu/sh3/clock-sh7712.c b/arch/sh/kernel/cpu/sh3/clock-sh7712.c
index b0d0c520399..21438a9a1ae 100644
--- a/arch/sh/kernel/cpu/sh3/clock-sh7712.c
+++ b/arch/sh/kernel/cpu/sh3/clock-sh7712.c
@@ -29,7 +29,7 @@ static void master_clk_init(struct clk *clk)
29 clk->rate *= multipliers[idx]; 29 clk->rate *= multipliers[idx];
30} 30}
31 31
32static struct clk_ops sh7712_master_clk_ops = { 32static struct sh_clk_ops sh7712_master_clk_ops = {
33 .init = master_clk_init, 33 .init = master_clk_init,
34}; 34};
35 35
@@ -41,7 +41,7 @@ static unsigned long module_clk_recalc(struct clk *clk)
41 return clk->parent->rate / divisors[idx]; 41 return clk->parent->rate / divisors[idx];
42} 42}
43 43
44static struct clk_ops sh7712_module_clk_ops = { 44static struct sh_clk_ops sh7712_module_clk_ops = {
45 .recalc = module_clk_recalc, 45 .recalc = module_clk_recalc,
46}; 46};
47 47
@@ -53,17 +53,17 @@ static unsigned long cpu_clk_recalc(struct clk *clk)
53 return clk->parent->rate / divisors[idx]; 53 return clk->parent->rate / divisors[idx];
54} 54}
55 55
56static struct clk_ops sh7712_cpu_clk_ops = { 56static struct sh_clk_ops sh7712_cpu_clk_ops = {
57 .recalc = cpu_clk_recalc, 57 .recalc = cpu_clk_recalc,
58}; 58};
59 59
60static struct clk_ops *sh7712_clk_ops[] = { 60static struct sh_clk_ops *sh7712_clk_ops[] = {
61 &sh7712_master_clk_ops, 61 &sh7712_master_clk_ops,
62 &sh7712_module_clk_ops, 62 &sh7712_module_clk_ops,
63 &sh7712_cpu_clk_ops, 63 &sh7712_cpu_clk_ops,
64}; 64};
65 65
66void __init arch_init_clk_ops(struct clk_ops **ops, int idx) 66void __init arch_init_clk_ops(struct sh_clk_ops **ops, int idx)
67{ 67{
68 if (idx < ARRAY_SIZE(sh7712_clk_ops)) 68 if (idx < ARRAY_SIZE(sh7712_clk_ops))
69 *ops = sh7712_clk_ops[idx]; 69 *ops = sh7712_clk_ops[idx];
diff --git a/arch/sh/kernel/cpu/sh4/clock-sh4-202.c b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
index f4e262adb39..4b5bab5f875 100644
--- a/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
+++ b/arch/sh/kernel/cpu/sh4/clock-sh4-202.c
@@ -41,7 +41,7 @@ static inline int frqcr3_lookup(struct clk *clk, unsigned long rate)
41 return 5; 41 return 5;
42} 42}
43 43
44static struct clk_ops sh4202_emi_clk_ops = { 44static struct sh_clk_ops sh4202_emi_clk_ops = {
45 .recalc = emi_clk_recalc, 45 .recalc = emi_clk_recalc,
46}; 46};
47 47
@@ -56,7 +56,7 @@ static unsigned long femi_clk_recalc(struct clk *clk)
56 return clk->parent->rate / frqcr3_divisors[idx]; 56 return clk->parent->rate / frqcr3_divisors[idx];
57} 57}
58 58
59static struct clk_ops sh4202_femi_clk_ops = { 59static struct sh_clk_ops sh4202_femi_clk_ops = {
60 .recalc = femi_clk_recalc, 60 .recalc = femi_clk_recalc,
61}; 61};
62 62
@@ -130,7 +130,7 @@ static int shoc_clk_set_rate(struct clk *clk, unsigned long rate)
130 return 0; 130 return 0;
131} 131}
132 132
133static struct clk_ops sh4202_shoc_clk_ops = { 133static struct sh_clk_ops sh4202_shoc_clk_ops = {
134 .init = shoc_clk_init, 134 .init = shoc_clk_init,
135 .recalc = shoc_clk_recalc, 135 .recalc = shoc_clk_recalc,
136 .set_rate = shoc_clk_set_rate, 136 .set_rate = shoc_clk_set_rate,
diff --git a/arch/sh/kernel/cpu/sh4/clock-sh4.c b/arch/sh/kernel/cpu/sh4/clock-sh4.c
index 5add75c1f53..99e5ec8b483 100644
--- a/arch/sh/kernel/cpu/sh4/clock-sh4.c
+++ b/arch/sh/kernel/cpu/sh4/clock-sh4.c
@@ -31,7 +31,7 @@ static void master_clk_init(struct clk *clk)
31 clk->rate *= pfc_divisors[__raw_readw(FRQCR) & 0x0007]; 31 clk->rate *= pfc_divisors[__raw_readw(FRQCR) & 0x0007];
32} 32}
33 33
34static struct clk_ops sh4_master_clk_ops = { 34static struct sh_clk_ops sh4_master_clk_ops = {
35 .init = master_clk_init, 35 .init = master_clk_init,
36}; 36};
37 37
@@ -41,7 +41,7 @@ static unsigned long module_clk_recalc(struct clk *clk)
41 return clk->parent->rate / pfc_divisors[idx]; 41 return clk->parent->rate / pfc_divisors[idx];
42} 42}
43 43
44static struct clk_ops sh4_module_clk_ops = { 44static struct sh_clk_ops sh4_module_clk_ops = {
45 .recalc = module_clk_recalc, 45 .recalc = module_clk_recalc,
46}; 46};
47 47
@@ -51,7 +51,7 @@ static unsigned long bus_clk_recalc(struct clk *clk)
51 return clk->parent->rate / bfc_divisors[idx]; 51 return clk->parent->rate / bfc_divisors[idx];
52} 52}
53 53
54static struct clk_ops sh4_bus_clk_ops = { 54static struct sh_clk_ops sh4_bus_clk_ops = {
55 .recalc = bus_clk_recalc, 55 .recalc = bus_clk_recalc,
56}; 56};
57 57
@@ -61,18 +61,18 @@ static unsigned long cpu_clk_recalc(struct clk *clk)
61 return clk->parent->rate / ifc_divisors[idx]; 61 return clk->parent->rate / ifc_divisors[idx];
62} 62}
63 63
64static struct clk_ops sh4_cpu_clk_ops = { 64static struct sh_clk_ops sh4_cpu_clk_ops = {
65 .recalc = cpu_clk_recalc, 65 .recalc = cpu_clk_recalc,
66}; 66};
67 67
68static struct clk_ops *sh4_clk_ops[] = { 68static struct sh_clk_ops *sh4_clk_ops[] = {
69 &sh4_master_clk_ops, 69 &sh4_master_clk_ops,
70 &sh4_module_clk_ops, 70 &sh4_module_clk_ops,
71 &sh4_bus_clk_ops, 71 &sh4_bus_clk_ops,
72 &sh4_cpu_clk_ops, 72 &sh4_cpu_clk_ops,
73}; 73};
74 74
75void __init arch_init_clk_ops(struct clk_ops **ops, int idx) 75void __init arch_init_clk_ops(struct sh_clk_ops **ops, int idx)
76{ 76{
77 if (idx < ARRAY_SIZE(sh4_clk_ops)) 77 if (idx < ARRAY_SIZE(sh4_clk_ops))
78 *ops = sh4_clk_ops[idx]; 78 *ops = sh4_clk_ops[idx];
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7343.c b/arch/sh/kernel/cpu/sh4a/clock-sh7343.c
index 70e45bdaadc..ea01a72f1b9 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7343.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7343.c
@@ -61,7 +61,7 @@ static unsigned long dll_recalc(struct clk *clk)
61 return clk->parent->rate * mult; 61 return clk->parent->rate * mult;
62} 62}
63 63
64static struct clk_ops dll_clk_ops = { 64static struct sh_clk_ops dll_clk_ops = {
65 .recalc = dll_recalc, 65 .recalc = dll_recalc,
66}; 66};
67 67
@@ -81,7 +81,7 @@ static unsigned long pll_recalc(struct clk *clk)
81 return clk->parent->rate * mult; 81 return clk->parent->rate * mult;
82} 82}
83 83
84static struct clk_ops pll_clk_ops = { 84static struct sh_clk_ops pll_clk_ops = {
85 .recalc = pll_recalc, 85 .recalc = pll_recalc,
86}; 86};
87 87
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7366.c b/arch/sh/kernel/cpu/sh4a/clock-sh7366.c
index 3c3165000c5..7ac07b4f75d 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7366.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7366.c
@@ -61,7 +61,7 @@ static unsigned long dll_recalc(struct clk *clk)
61 return clk->parent->rate * mult; 61 return clk->parent->rate * mult;
62} 62}
63 63
64static struct clk_ops dll_clk_ops = { 64static struct sh_clk_ops dll_clk_ops = {
65 .recalc = dll_recalc, 65 .recalc = dll_recalc,
66}; 66};
67 67
@@ -84,7 +84,7 @@ static unsigned long pll_recalc(struct clk *clk)
84 return (clk->parent->rate * mult) / div; 84 return (clk->parent->rate * mult) / div;
85} 85}
86 86
87static struct clk_ops pll_clk_ops = { 87static struct sh_clk_ops pll_clk_ops = {
88 .recalc = pll_recalc, 88 .recalc = pll_recalc,
89}; 89};
90 90
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
index 212c72ef959..8e1f97010c0 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
@@ -64,7 +64,7 @@ static unsigned long dll_recalc(struct clk *clk)
64 return clk->parent->rate * mult; 64 return clk->parent->rate * mult;
65} 65}
66 66
67static struct clk_ops dll_clk_ops = { 67static struct sh_clk_ops dll_clk_ops = {
68 .recalc = dll_recalc, 68 .recalc = dll_recalc,
69}; 69};
70 70
@@ -87,7 +87,7 @@ static unsigned long pll_recalc(struct clk *clk)
87 return (clk->parent->rate * mult) / div; 87 return (clk->parent->rate * mult) / div;
88} 88}
89 89
90static struct clk_ops pll_clk_ops = { 90static struct sh_clk_ops pll_clk_ops = {
91 .recalc = pll_recalc, 91 .recalc = pll_recalc,
92}; 92};
93 93
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7723.c b/arch/sh/kernel/cpu/sh4a/clock-sh7723.c
index 2f8c9179da4..35f75cf0c7e 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7723.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7723.c
@@ -65,7 +65,7 @@ static unsigned long dll_recalc(struct clk *clk)
65 return clk->parent->rate * mult; 65 return clk->parent->rate * mult;
66} 66}
67 67
68static struct clk_ops dll_clk_ops = { 68static struct sh_clk_ops dll_clk_ops = {
69 .recalc = dll_recalc, 69 .recalc = dll_recalc,
70}; 70};
71 71
@@ -88,7 +88,7 @@ static unsigned long pll_recalc(struct clk *clk)
88 return (clk->parent->rate * mult) / div; 88 return (clk->parent->rate * mult) / div;
89} 89}
90 90
91static struct clk_ops pll_clk_ops = { 91static struct sh_clk_ops pll_clk_ops = {
92 .recalc = pll_recalc, 92 .recalc = pll_recalc,
93}; 93};
94 94
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
index 70bd96646f4..2a87901673f 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7724.c
@@ -70,7 +70,7 @@ static unsigned long fll_recalc(struct clk *clk)
70 return (clk->parent->rate * mult) / div; 70 return (clk->parent->rate * mult) / div;
71} 71}
72 72
73static struct clk_ops fll_clk_ops = { 73static struct sh_clk_ops fll_clk_ops = {
74 .recalc = fll_recalc, 74 .recalc = fll_recalc,
75}; 75};
76 76
@@ -90,7 +90,7 @@ static unsigned long pll_recalc(struct clk *clk)
90 return clk->parent->rate * mult; 90 return clk->parent->rate * mult;
91} 91}
92 92
93static struct clk_ops pll_clk_ops = { 93static struct sh_clk_ops pll_clk_ops = {
94 .recalc = pll_recalc, 94 .recalc = pll_recalc,
95}; 95};
96 96
@@ -105,7 +105,7 @@ static unsigned long div3_recalc(struct clk *clk)
105 return clk->parent->rate / 3; 105 return clk->parent->rate / 3;
106} 106}
107 107
108static struct clk_ops div3_clk_ops = { 108static struct sh_clk_ops div3_clk_ops = {
109 .recalc = div3_recalc, 109 .recalc = div3_recalc,
110}; 110};
111 111
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7757.c b/arch/sh/kernel/cpu/sh4a/clock-sh7757.c
index 0bd21c82151..5853989586e 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7757.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7757.c
@@ -33,7 +33,7 @@ static unsigned long pll_recalc(struct clk *clk)
33 return clk->parent->rate * multiplier; 33 return clk->parent->rate * multiplier;
34} 34}
35 35
36static struct clk_ops pll_clk_ops = { 36static struct sh_clk_ops pll_clk_ops = {
37 .recalc = pll_recalc, 37 .recalc = pll_recalc,
38}; 38};
39 39
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7763.c b/arch/sh/kernel/cpu/sh4a/clock-sh7763.c
index 2d4c7fd79c0..7707e35aea4 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7763.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7763.c
@@ -27,7 +27,7 @@ static void master_clk_init(struct clk *clk)
27 clk->rate *= p0fc_divisors[(__raw_readl(FRQCR) >> 4) & 0x07]; 27 clk->rate *= p0fc_divisors[(__raw_readl(FRQCR) >> 4) & 0x07];
28} 28}
29 29
30static struct clk_ops sh7763_master_clk_ops = { 30static struct sh_clk_ops sh7763_master_clk_ops = {
31 .init = master_clk_init, 31 .init = master_clk_init,
32}; 32};
33 33
@@ -37,7 +37,7 @@ static unsigned long module_clk_recalc(struct clk *clk)
37 return clk->parent->rate / p0fc_divisors[idx]; 37 return clk->parent->rate / p0fc_divisors[idx];
38} 38}
39 39
40static struct clk_ops sh7763_module_clk_ops = { 40static struct sh_clk_ops sh7763_module_clk_ops = {
41 .recalc = module_clk_recalc, 41 .recalc = module_clk_recalc,
42}; 42};
43 43
@@ -47,22 +47,22 @@ static unsigned long bus_clk_recalc(struct clk *clk)
47 return clk->parent->rate / bfc_divisors[idx]; 47 return clk->parent->rate / bfc_divisors[idx];
48} 48}
49 49
50static struct clk_ops sh7763_bus_clk_ops = { 50static struct sh_clk_ops sh7763_bus_clk_ops = {
51 .recalc = bus_clk_recalc, 51 .recalc = bus_clk_recalc,
52}; 52};
53 53
54static struct clk_ops sh7763_cpu_clk_ops = { 54static struct sh_clk_ops sh7763_cpu_clk_ops = {
55 .recalc = followparent_recalc, 55 .recalc = followparent_recalc,
56}; 56};
57 57
58static struct clk_ops *sh7763_clk_ops[] = { 58static struct sh_clk_ops *sh7763_clk_ops[] = {
59 &sh7763_master_clk_ops, 59 &sh7763_master_clk_ops,
60 &sh7763_module_clk_ops, 60 &sh7763_module_clk_ops,
61 &sh7763_bus_clk_ops, 61 &sh7763_bus_clk_ops,
62 &sh7763_cpu_clk_ops, 62 &sh7763_cpu_clk_ops,
63}; 63};
64 64
65void __init arch_init_clk_ops(struct clk_ops **ops, int idx) 65void __init arch_init_clk_ops(struct sh_clk_ops **ops, int idx)
66{ 66{
67 if (idx < ARRAY_SIZE(sh7763_clk_ops)) 67 if (idx < ARRAY_SIZE(sh7763_clk_ops))
68 *ops = sh7763_clk_ops[idx]; 68 *ops = sh7763_clk_ops[idx];
@@ -74,7 +74,7 @@ static unsigned long shyway_clk_recalc(struct clk *clk)
74 return clk->parent->rate / cfc_divisors[idx]; 74 return clk->parent->rate / cfc_divisors[idx];
75} 75}
76 76
77static struct clk_ops sh7763_shyway_clk_ops = { 77static struct sh_clk_ops sh7763_shyway_clk_ops = {
78 .recalc = shyway_clk_recalc, 78 .recalc = shyway_clk_recalc,
79}; 79};
80 80
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7770.c b/arch/sh/kernel/cpu/sh4a/clock-sh7770.c
index 9e3354365d4..5d36f334bb0 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7770.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7770.c
@@ -24,7 +24,7 @@ static void master_clk_init(struct clk *clk)
24 clk->rate *= pfc_divisors[(__raw_readl(FRQCR) >> 28) & 0x000f]; 24 clk->rate *= pfc_divisors[(__raw_readl(FRQCR) >> 28) & 0x000f];
25} 25}
26 26
27static struct clk_ops sh7770_master_clk_ops = { 27static struct sh_clk_ops sh7770_master_clk_ops = {
28 .init = master_clk_init, 28 .init = master_clk_init,
29}; 29};
30 30
@@ -34,7 +34,7 @@ static unsigned long module_clk_recalc(struct clk *clk)
34 return clk->parent->rate / pfc_divisors[idx]; 34 return clk->parent->rate / pfc_divisors[idx];
35} 35}
36 36
37static struct clk_ops sh7770_module_clk_ops = { 37static struct sh_clk_ops sh7770_module_clk_ops = {
38 .recalc = module_clk_recalc, 38 .recalc = module_clk_recalc,
39}; 39};
40 40
@@ -44,7 +44,7 @@ static unsigned long bus_clk_recalc(struct clk *clk)
44 return clk->parent->rate / bfc_divisors[idx]; 44 return clk->parent->rate / bfc_divisors[idx];
45} 45}
46 46
47static struct clk_ops sh7770_bus_clk_ops = { 47static struct sh_clk_ops sh7770_bus_clk_ops = {
48 .recalc = bus_clk_recalc, 48 .recalc = bus_clk_recalc,
49}; 49};
50 50
@@ -54,18 +54,18 @@ static unsigned long cpu_clk_recalc(struct clk *clk)
54 return clk->parent->rate / ifc_divisors[idx]; 54 return clk->parent->rate / ifc_divisors[idx];
55} 55}
56 56
57static struct clk_ops sh7770_cpu_clk_ops = { 57static struct sh_clk_ops sh7770_cpu_clk_ops = {
58 .recalc = cpu_clk_recalc, 58 .recalc = cpu_clk_recalc,
59}; 59};
60 60
61static struct clk_ops *sh7770_clk_ops[] = { 61static struct sh_clk_ops *sh7770_clk_ops[] = {
62 &sh7770_master_clk_ops, 62 &sh7770_master_clk_ops,
63 &sh7770_module_clk_ops, 63 &sh7770_module_clk_ops,
64 &sh7770_bus_clk_ops, 64 &sh7770_bus_clk_ops,
65 &sh7770_cpu_clk_ops, 65 &sh7770_cpu_clk_ops,
66}; 66};
67 67
68void __init arch_init_clk_ops(struct clk_ops **ops, int idx) 68void __init arch_init_clk_ops(struct sh_clk_ops **ops, int idx)
69{ 69{
70 if (idx < ARRAY_SIZE(sh7770_clk_ops)) 70 if (idx < ARRAY_SIZE(sh7770_clk_ops))
71 *ops = sh7770_clk_ops[idx]; 71 *ops = sh7770_clk_ops[idx];
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7780.c b/arch/sh/kernel/cpu/sh4a/clock-sh7780.c
index 3b53348fe2f..793dae42a2f 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7780.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7780.c
@@ -27,7 +27,7 @@ static void master_clk_init(struct clk *clk)
27 clk->rate *= pfc_divisors[__raw_readl(FRQCR) & 0x0003]; 27 clk->rate *= pfc_divisors[__raw_readl(FRQCR) & 0x0003];
28} 28}
29 29
30static struct clk_ops sh7780_master_clk_ops = { 30static struct sh_clk_ops sh7780_master_clk_ops = {
31 .init = master_clk_init, 31 .init = master_clk_init,
32}; 32};
33 33
@@ -37,7 +37,7 @@ static unsigned long module_clk_recalc(struct clk *clk)
37 return clk->parent->rate / pfc_divisors[idx]; 37 return clk->parent->rate / pfc_divisors[idx];
38} 38}
39 39
40static struct clk_ops sh7780_module_clk_ops = { 40static struct sh_clk_ops sh7780_module_clk_ops = {
41 .recalc = module_clk_recalc, 41 .recalc = module_clk_recalc,
42}; 42};
43 43
@@ -47,7 +47,7 @@ static unsigned long bus_clk_recalc(struct clk *clk)
47 return clk->parent->rate / bfc_divisors[idx]; 47 return clk->parent->rate / bfc_divisors[idx];
48} 48}
49 49
50static struct clk_ops sh7780_bus_clk_ops = { 50static struct sh_clk_ops sh7780_bus_clk_ops = {
51 .recalc = bus_clk_recalc, 51 .recalc = bus_clk_recalc,
52}; 52};
53 53
@@ -57,18 +57,18 @@ static unsigned long cpu_clk_recalc(struct clk *clk)
57 return clk->parent->rate / ifc_divisors[idx]; 57 return clk->parent->rate / ifc_divisors[idx];
58} 58}
59 59
60static struct clk_ops sh7780_cpu_clk_ops = { 60static struct sh_clk_ops sh7780_cpu_clk_ops = {
61 .recalc = cpu_clk_recalc, 61 .recalc = cpu_clk_recalc,
62}; 62};
63 63
64static struct clk_ops *sh7780_clk_ops[] = { 64static struct sh_clk_ops *sh7780_clk_ops[] = {
65 &sh7780_master_clk_ops, 65 &sh7780_master_clk_ops,
66 &sh7780_module_clk_ops, 66 &sh7780_module_clk_ops,
67 &sh7780_bus_clk_ops, 67 &sh7780_bus_clk_ops,
68 &sh7780_cpu_clk_ops, 68 &sh7780_cpu_clk_ops,
69}; 69};
70 70
71void __init arch_init_clk_ops(struct clk_ops **ops, int idx) 71void __init arch_init_clk_ops(struct sh_clk_ops **ops, int idx)
72{ 72{
73 if (idx < ARRAY_SIZE(sh7780_clk_ops)) 73 if (idx < ARRAY_SIZE(sh7780_clk_ops))
74 *ops = sh7780_clk_ops[idx]; 74 *ops = sh7780_clk_ops[idx];
@@ -80,7 +80,7 @@ static unsigned long shyway_clk_recalc(struct clk *clk)
80 return clk->parent->rate / cfc_divisors[idx]; 80 return clk->parent->rate / cfc_divisors[idx];
81} 81}
82 82
83static struct clk_ops sh7780_shyway_clk_ops = { 83static struct sh_clk_ops sh7780_shyway_clk_ops = {
84 .recalc = shyway_clk_recalc, 84 .recalc = shyway_clk_recalc,
85}; 85};
86 86
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7785.c b/arch/sh/kernel/cpu/sh4a/clock-sh7785.c
index 2b314439d35..ab1c58f2d10 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7785.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7785.c
@@ -36,7 +36,7 @@ static unsigned long pll_recalc(struct clk *clk)
36 return clk->parent->rate * multiplier; 36 return clk->parent->rate * multiplier;
37} 37}
38 38
39static struct clk_ops pll_clk_ops = { 39static struct sh_clk_ops pll_clk_ops = {
40 .recalc = pll_recalc, 40 .recalc = pll_recalc,
41}; 41};
42 42
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7786.c b/arch/sh/kernel/cpu/sh4a/clock-sh7786.c
index f6c0c3d5599..491709483e1 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7786.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7786.c
@@ -38,7 +38,7 @@ static unsigned long pll_recalc(struct clk *clk)
38 return clk->parent->rate * multiplier; 38 return clk->parent->rate * multiplier;
39} 39}
40 40
41static struct clk_ops pll_clk_ops = { 41static struct sh_clk_ops pll_clk_ops = {
42 .recalc = pll_recalc, 42 .recalc = pll_recalc,
43}; 43};
44 44
diff --git a/arch/sh/kernel/cpu/sh4a/clock-shx3.c b/arch/sh/kernel/cpu/sh4a/clock-shx3.c
index bf2d00b8b90..0f11b392bf4 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-shx3.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-shx3.c
@@ -32,7 +32,7 @@ static unsigned long pll_recalc(struct clk *clk)
32 return clk->parent->rate * 72; 32 return clk->parent->rate * 72;
33} 33}
34 34
35static struct clk_ops pll_clk_ops = { 35static struct sh_clk_ops pll_clk_ops = {
36 .recalc = pll_recalc, 36 .recalc = pll_recalc,
37}; 37};
38 38
diff --git a/arch/sh/kernel/cpu/sh5/clock-sh5.c b/arch/sh/kernel/cpu/sh5/clock-sh5.c
index 9cfc19b8dbe..c48b93d4c08 100644
--- a/arch/sh/kernel/cpu/sh5/clock-sh5.c
+++ b/arch/sh/kernel/cpu/sh5/clock-sh5.c
@@ -28,7 +28,7 @@ static void master_clk_init(struct clk *clk)
28 clk->rate *= ifc_table[idx]; 28 clk->rate *= ifc_table[idx];
29} 29}
30 30
31static struct clk_ops sh5_master_clk_ops = { 31static struct sh_clk_ops sh5_master_clk_ops = {
32 .init = master_clk_init, 32 .init = master_clk_init,
33}; 33};
34 34
@@ -38,7 +38,7 @@ static unsigned long module_clk_recalc(struct clk *clk)
38 return clk->parent->rate / ifc_table[idx]; 38 return clk->parent->rate / ifc_table[idx];
39} 39}
40 40
41static struct clk_ops sh5_module_clk_ops = { 41static struct sh_clk_ops sh5_module_clk_ops = {
42 .recalc = module_clk_recalc, 42 .recalc = module_clk_recalc,
43}; 43};
44 44
@@ -48,7 +48,7 @@ static unsigned long bus_clk_recalc(struct clk *clk)
48 return clk->parent->rate / ifc_table[idx]; 48 return clk->parent->rate / ifc_table[idx];
49} 49}
50 50
51static struct clk_ops sh5_bus_clk_ops = { 51static struct sh_clk_ops sh5_bus_clk_ops = {
52 .recalc = bus_clk_recalc, 52 .recalc = bus_clk_recalc,
53}; 53};
54 54
@@ -58,18 +58,18 @@ static unsigned long cpu_clk_recalc(struct clk *clk)
58 return clk->parent->rate / ifc_table[idx]; 58 return clk->parent->rate / ifc_table[idx];
59} 59}
60 60
61static struct clk_ops sh5_cpu_clk_ops = { 61static struct sh_clk_ops sh5_cpu_clk_ops = {
62 .recalc = cpu_clk_recalc, 62 .recalc = cpu_clk_recalc,
63}; 63};
64 64
65static struct clk_ops *sh5_clk_ops[] = { 65static struct sh_clk_ops *sh5_clk_ops[] = {
66 &sh5_master_clk_ops, 66 &sh5_master_clk_ops,
67 &sh5_module_clk_ops, 67 &sh5_module_clk_ops,
68 &sh5_bus_clk_ops, 68 &sh5_bus_clk_ops,
69 &sh5_cpu_clk_ops, 69 &sh5_cpu_clk_ops,
70}; 70};
71 71
72void __init arch_init_clk_ops(struct clk_ops **ops, int idx) 72void __init arch_init_clk_ops(struct sh_clk_ops **ops, int idx)
73{ 73{
74 cprc_base = (unsigned long)ioremap_nocache(CPRC_BASE, 1024); 74 cprc_base = (unsigned long)ioremap_nocache(CPRC_BASE, 1024);
75 BUG_ON(!cprc_base); 75 BUG_ON(!cprc_base);
diff --git a/arch/sh/kernel/vsyscall/vsyscall.c b/arch/sh/kernel/vsyscall/vsyscall.c
index 1d6d51a1ce7..5ca579720a0 100644
--- a/arch/sh/kernel/vsyscall/vsyscall.c
+++ b/arch/sh/kernel/vsyscall/vsyscall.c
@@ -73,8 +73,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
73 73
74 ret = install_special_mapping(mm, addr, PAGE_SIZE, 74 ret = install_special_mapping(mm, addr, PAGE_SIZE,
75 VM_READ | VM_EXEC | 75 VM_READ | VM_EXEC |
76 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC | 76 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
77 VM_ALWAYSDUMP,
78 syscall_pages); 77 syscall_pages);
79 if (unlikely(ret)) 78 if (unlikely(ret))
80 goto up_fail; 79 goto up_fail;
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index ca5580e4d81..1666de84d47 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -29,6 +29,7 @@ config SPARC
29 select GENERIC_IRQ_SHOW 29 select GENERIC_IRQ_SHOW
30 select USE_GENERIC_SMP_HELPERS if SMP 30 select USE_GENERIC_SMP_HELPERS if SMP
31 select GENERIC_PCI_IOMAP 31 select GENERIC_PCI_IOMAP
32 select HAVE_NMI_WATCHDOG if SPARC64
32 33
33config SPARC32 34config SPARC32
34 def_bool !64BIT 35 def_bool !64BIT
diff --git a/arch/sparc/include/asm/irq_64.h b/arch/sparc/include/asm/irq_64.h
index 16dcae6d56e..abf6afe82ca 100644
--- a/arch/sparc/include/asm/irq_64.h
+++ b/arch/sparc/include/asm/irq_64.h
@@ -95,7 +95,6 @@ void arch_trigger_all_cpu_backtrace(void);
95extern void *hardirq_stack[NR_CPUS]; 95extern void *hardirq_stack[NR_CPUS];
96extern void *softirq_stack[NR_CPUS]; 96extern void *softirq_stack[NR_CPUS];
97#define __ARCH_HAS_DO_SOFTIRQ 97#define __ARCH_HAS_DO_SOFTIRQ
98#define ARCH_HAS_NMI_WATCHDOG
99 98
100#define NO_IRQ 0xffffffff 99#define NO_IRQ 0xffffffff
101 100
diff --git a/arch/sparc/include/asm/pci_32.h b/arch/sparc/include/asm/pci_32.h
index 6de7f7bf956..dc503297481 100644
--- a/arch/sparc/include/asm/pci_32.h
+++ b/arch/sparc/include/asm/pci_32.h
@@ -52,14 +52,6 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
52 * 64Kbytes by the Host controller. 52 * 64Kbytes by the Host controller.
53 */ 53 */
54 54
55extern void
56pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
57 struct resource *res);
58
59extern void
60pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
61 struct pci_bus_region *region);
62
63static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) 55static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
64{ 56{
65 return PCI_IRQ_NONE; 57 return PCI_IRQ_NONE;
diff --git a/arch/sparc/include/asm/pci_64.h b/arch/sparc/include/asm/pci_64.h
index 755a4bb6bcd..1633b718d3b 100644
--- a/arch/sparc/include/asm/pci_64.h
+++ b/arch/sparc/include/asm/pci_64.h
@@ -73,14 +73,6 @@ extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
73 enum pci_mmap_state mmap_state, 73 enum pci_mmap_state mmap_state,
74 int write_combine); 74 int write_combine);
75 75
76extern void
77pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
78 struct resource *res);
79
80extern void
81pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
82 struct pci_bus_region *region);
83
84static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) 76static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
85{ 77{
86 return PCI_IRQ_NONE; 78 return PCI_IRQ_NONE;
diff --git a/arch/sparc/include/asm/vga.h b/arch/sparc/include/asm/vga.h
index c69d5b2ba19..ec0e9967d93 100644
--- a/arch/sparc/include/asm/vga.h
+++ b/arch/sparc/include/asm/vga.h
@@ -7,6 +7,7 @@
7#ifndef _LINUX_ASM_VGA_H_ 7#ifndef _LINUX_ASM_VGA_H_
8#define _LINUX_ASM_VGA_H_ 8#define _LINUX_ASM_VGA_H_
9 9
10#include <linux/bug.h>
10#include <asm/types.h> 11#include <asm/types.h>
11 12
12#define VT_BUF_HAVE_RW 13#define VT_BUF_HAVE_RW
diff --git a/arch/sparc/include/asm/vio.h b/arch/sparc/include/asm/vio.h
index 9d83d3bcb49..432afa83886 100644
--- a/arch/sparc/include/asm/vio.h
+++ b/arch/sparc/include/asm/vio.h
@@ -284,6 +284,7 @@ struct vio_dev {
284}; 284};
285 285
286struct vio_driver { 286struct vio_driver {
287 const char *name;
287 struct list_head node; 288 struct list_head node;
288 const struct vio_device_id *id_table; 289 const struct vio_device_id *id_table;
289 int (*probe)(struct vio_dev *dev, const struct vio_device_id *id); 290 int (*probe)(struct vio_dev *dev, const struct vio_device_id *id);
@@ -371,7 +372,13 @@ do { if (vio->debug & VIO_DEBUG_##TYPE) \
371 vio->vdev->channel_id, ## a); \ 372 vio->vdev->channel_id, ## a); \
372} while (0) 373} while (0)
373 374
374extern int vio_register_driver(struct vio_driver *drv); 375extern int __vio_register_driver(struct vio_driver *drv, struct module *owner,
376 const char *mod_name);
377/*
378 * vio_register_driver must be a macro so that KBUILD_MODNAME can be expanded
379 */
380#define vio_register_driver(driver) \
381 __vio_register_driver(driver, THIS_MODULE, KBUILD_MODNAME)
375extern void vio_unregister_driver(struct vio_driver *drv); 382extern void vio_unregister_driver(struct vio_driver *drv);
376 383
377static inline struct vio_driver *to_vio_driver(struct device_driver *drv) 384static inline struct vio_driver *to_vio_driver(struct device_driver *drv)
diff --git a/arch/sparc/kernel/ds.c b/arch/sparc/kernel/ds.c
index 381edcd5bc2..fea13c7b1ae 100644
--- a/arch/sparc/kernel/ds.c
+++ b/arch/sparc/kernel/ds.c
@@ -1244,10 +1244,7 @@ static struct vio_driver ds_driver = {
1244 .id_table = ds_match, 1244 .id_table = ds_match,
1245 .probe = ds_probe, 1245 .probe = ds_probe,
1246 .remove = ds_remove, 1246 .remove = ds_remove,
1247 .driver = { 1247 .name = "ds",
1248 .name = "ds",
1249 .owner = THIS_MODULE,
1250 }
1251}; 1248};
1252 1249
1253static int __init ds_init(void) 1250static int __init ds_init(void)
diff --git a/arch/sparc/kernel/leon_pci.c b/arch/sparc/kernel/leon_pci.c
index c7bec25fdb1..aba6b958b2a 100644
--- a/arch/sparc/kernel/leon_pci.c
+++ b/arch/sparc/kernel/leon_pci.c
@@ -15,14 +15,19 @@
15 15
16/* The LEON architecture does not rely on a BIOS or bootloader to setup 16/* The LEON architecture does not rely on a BIOS or bootloader to setup
17 * PCI for us. The Linux generic routines are used to setup resources, 17 * PCI for us. The Linux generic routines are used to setup resources,
18 * reset values of confuration-space registers settings ae preseved. 18 * reset values of configuration-space register settings are preserved.
19 *
20 * PCI Memory and Prefetchable Memory is direct-mapped. However I/O Space is
21 * accessed through a Window which is translated to low 64KB in PCI space, the
22 * first 4KB is not used so 60KB is available.
19 */ 23 */
20void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info) 24void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info)
21{ 25{
22 LIST_HEAD(resources); 26 LIST_HEAD(resources);
23 struct pci_bus *root_bus; 27 struct pci_bus *root_bus;
24 28
25 pci_add_resource(&resources, &info->io_space); 29 pci_add_resource_offset(&resources, &info->io_space,
30 info->io_space.start - 0x1000);
26 pci_add_resource(&resources, &info->mem_space); 31 pci_add_resource(&resources, &info->mem_space);
27 32
28 root_bus = pci_scan_root_bus(&ofdev->dev, 0, info->ops, info, 33 root_bus = pci_scan_root_bus(&ofdev->dev, 0, info->ops, info,
@@ -38,44 +43,6 @@ void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info)
38 } 43 }
39} 44}
40 45
41/* PCI Memory and Prefetchable Memory is direct-mapped. However I/O Space is
42 * accessed through a Window which is translated to low 64KB in PCI space, the
43 * first 4KB is not used so 60KB is available.
44 *
45 * This function is used by generic code to translate resource addresses into
46 * PCI addresses.
47 */
48void pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
49 struct resource *res)
50{
51 struct leon_pci_info *info = dev->bus->sysdata;
52
53 region->start = res->start;
54 region->end = res->end;
55
56 if (res->flags & IORESOURCE_IO) {
57 region->start -= (info->io_space.start - 0x1000);
58 region->end -= (info->io_space.start - 0x1000);
59 }
60}
61EXPORT_SYMBOL(pcibios_resource_to_bus);
62
63/* see pcibios_resource_to_bus() comment */
64void pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
65 struct pci_bus_region *region)
66{
67 struct leon_pci_info *info = dev->bus->sysdata;
68
69 res->start = region->start;
70 res->end = region->end;
71
72 if (res->flags & IORESOURCE_IO) {
73 res->start += (info->io_space.start - 0x1000);
74 res->end += (info->io_space.start - 0x1000);
75 }
76}
77EXPORT_SYMBOL(pcibios_bus_to_resource);
78
79void __devinit pcibios_fixup_bus(struct pci_bus *pbus) 46void __devinit pcibios_fixup_bus(struct pci_bus *pbus)
80{ 47{
81 struct leon_pci_info *info = pbus->sysdata; 48 struct leon_pci_info *info = pbus->sysdata;
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c
index bb8bc2e519a..fdaf2181167 100644
--- a/arch/sparc/kernel/pci.c
+++ b/arch/sparc/kernel/pci.c
@@ -375,13 +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
378static void pci_resource_adjust(struct resource *res,
379 struct resource *root)
380{
381 res->start += root->start;
382 res->end += root->start;
383}
384
385/* For PCI bus devices which lack a 'ranges' property we interrogate 378/* For PCI bus devices which lack a 'ranges' property we interrogate
386 * the config space values to set the resources, just like the generic 379 * the config space values to set the resources, just like the generic
387 * Linux PCI probing code does. 380 * Linux PCI probing code does.
@@ -390,7 +383,8 @@ static void __devinit pci_cfg_fake_ranges(struct pci_dev *dev,
390 struct pci_bus *bus, 383 struct pci_bus *bus,
391 struct pci_pbm_info *pbm) 384 struct pci_pbm_info *pbm)
392{ 385{
393 struct resource *res; 386 struct pci_bus_region region;
387 struct resource *res, res2;
394 u8 io_base_lo, io_limit_lo; 388 u8 io_base_lo, io_limit_lo;
395 u16 mem_base_lo, mem_limit_lo; 389 u16 mem_base_lo, mem_limit_lo;
396 unsigned long base, limit; 390 unsigned long base, limit;
@@ -412,11 +406,14 @@ static void __devinit pci_cfg_fake_ranges(struct pci_dev *dev,
412 res = bus->resource[0]; 406 res = bus->resource[0];
413 if (base <= limit) { 407 if (base <= limit) {
414 res->flags = (io_base_lo & PCI_IO_RANGE_TYPE_MASK) | IORESOURCE_IO; 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);
415 if (!res->start) 413 if (!res->start)
416 res->start = base; 414 res->start = res2.start;
417 if (!res->end) 415 if (!res->end)
418 res->end = limit + 0xfff; 416 res->end = res2.end;
419 pci_resource_adjust(res, &pbm->io_space);
420 } 417 }
421 418
422 pci_read_config_word(dev, PCI_MEMORY_BASE, &mem_base_lo); 419 pci_read_config_word(dev, PCI_MEMORY_BASE, &mem_base_lo);
@@ -428,9 +425,9 @@ static void __devinit pci_cfg_fake_ranges(struct pci_dev *dev,
428 if (base <= limit) { 425 if (base <= limit) {
429 res->flags = ((mem_base_lo & PCI_MEMORY_RANGE_TYPE_MASK) | 426 res->flags = ((mem_base_lo & PCI_MEMORY_RANGE_TYPE_MASK) |
430 IORESOURCE_MEM); 427 IORESOURCE_MEM);
431 res->start = base; 428 region.start = base;
432 res->end = limit + 0xfffff; 429 region.end = limit + 0xfffff;
433 pci_resource_adjust(res, &pbm->mem_space); 430 pcibios_bus_to_resource(dev, res, &region);
434 } 431 }
435 432
436 pci_read_config_word(dev, PCI_PREF_MEMORY_BASE, &mem_base_lo); 433 pci_read_config_word(dev, PCI_PREF_MEMORY_BASE, &mem_base_lo);
@@ -459,9 +456,9 @@ static void __devinit pci_cfg_fake_ranges(struct pci_dev *dev,
459 if (base <= limit) { 456 if (base <= limit) {
460 res->flags = ((mem_base_lo & PCI_MEMORY_RANGE_TYPE_MASK) | 457 res->flags = ((mem_base_lo & PCI_MEMORY_RANGE_TYPE_MASK) |
461 IORESOURCE_MEM | IORESOURCE_PREFETCH); 458 IORESOURCE_MEM | IORESOURCE_PREFETCH);
462 res->start = base; 459 region.start = base;
463 res->end = limit + 0xfffff; 460 region.end = limit + 0xfffff;
464 pci_resource_adjust(res, &pbm->mem_space); 461 pcibios_bus_to_resource(dev, res, &region);
465 } 462 }
466} 463}
467 464
@@ -472,6 +469,7 @@ static void __devinit apb_fake_ranges(struct pci_dev *dev,
472 struct pci_bus *bus, 469 struct pci_bus *bus,
473 struct pci_pbm_info *pbm) 470 struct pci_pbm_info *pbm)
474{ 471{
472 struct pci_bus_region region;
475 struct resource *res; 473 struct resource *res;
476 u32 first, last; 474 u32 first, last;
477 u8 map; 475 u8 map;
@@ -479,18 +477,18 @@ static void __devinit apb_fake_ranges(struct pci_dev *dev,
479 pci_read_config_byte(dev, APB_IO_ADDRESS_MAP, &map); 477 pci_read_config_byte(dev, APB_IO_ADDRESS_MAP, &map);
480 apb_calc_first_last(map, &first, &last); 478 apb_calc_first_last(map, &first, &last);
481 res = bus->resource[0]; 479 res = bus->resource[0];
482 res->start = (first << 21);
483 res->end = (last << 21) + ((1 << 21) - 1);
484 res->flags = IORESOURCE_IO; 480 res->flags = IORESOURCE_IO;
485 pci_resource_adjust(res, &pbm->io_space); 481 region.start = (first << 21);
482 region.end = (last << 21) + ((1 << 21) - 1);
483 pcibios_bus_to_resource(dev, res, &region);
486 484
487 pci_read_config_byte(dev, APB_MEM_ADDRESS_MAP, &map); 485 pci_read_config_byte(dev, APB_MEM_ADDRESS_MAP, &map);
488 apb_calc_first_last(map, &first, &last); 486 apb_calc_first_last(map, &first, &last);
489 res = bus->resource[1]; 487 res = bus->resource[1];
490 res->start = (first << 21);
491 res->end = (last << 21) + ((1 << 21) - 1);
492 res->flags = IORESOURCE_MEM; 488 res->flags = IORESOURCE_MEM;
493 pci_resource_adjust(res, &pbm->mem_space); 489 region.start = (first << 21);
490 region.end = (last << 21) + ((1 << 21) - 1);
491 pcibios_bus_to_resource(dev, res, &region);
494} 492}
495 493
496static void __devinit pci_of_scan_bus(struct pci_pbm_info *pbm, 494static void __devinit pci_of_scan_bus(struct pci_pbm_info *pbm,
@@ -506,6 +504,7 @@ static void __devinit of_scan_pci_bridge(struct pci_pbm_info *pbm,
506 struct pci_bus *bus; 504 struct pci_bus *bus;
507 const u32 *busrange, *ranges; 505 const u32 *busrange, *ranges;
508 int len, i, simba; 506 int len, i, simba;
507 struct pci_bus_region region;
509 struct resource *res; 508 struct resource *res;
510 unsigned int flags; 509 unsigned int flags;
511 u64 size; 510 u64 size;
@@ -556,8 +555,6 @@ static void __devinit of_scan_pci_bridge(struct pci_pbm_info *pbm,
556 } 555 }
557 i = 1; 556 i = 1;
558 for (; len >= 32; len -= 32, ranges += 8) { 557 for (; len >= 32; len -= 32, ranges += 8) {
559 struct resource *root;
560
561 flags = pci_parse_of_flags(ranges[0]); 558 flags = pci_parse_of_flags(ranges[0]);
562 size = GET_64BIT(ranges, 6); 559 size = GET_64BIT(ranges, 6);
563 if (flags == 0 || size == 0) 560 if (flags == 0 || size == 0)
@@ -569,7 +566,6 @@ static void __devinit of_scan_pci_bridge(struct pci_pbm_info *pbm,
569 " for bridge %s\n", node->full_name); 566 " for bridge %s\n", node->full_name);
570 continue; 567 continue;
571 } 568 }
572 root = &pbm->io_space;
573 } else { 569 } else {
574 if (i >= PCI_NUM_RESOURCES - PCI_BRIDGE_RESOURCES) { 570 if (i >= PCI_NUM_RESOURCES - PCI_BRIDGE_RESOURCES) {
575 printk(KERN_ERR "PCI: too many memory ranges" 571 printk(KERN_ERR "PCI: too many memory ranges"
@@ -578,18 +574,12 @@ static void __devinit of_scan_pci_bridge(struct pci_pbm_info *pbm,
578 } 574 }
579 res = bus->resource[i]; 575 res = bus->resource[i];
580 ++i; 576 ++i;
581 root = &pbm->mem_space;
582 } 577 }
583 578
584 res->start = GET_64BIT(ranges, 1);
585 res->end = res->start + size - 1;
586 res->flags = flags; 579 res->flags = flags;
587 580 region.start = GET_64BIT(ranges, 1);
588 /* Another way to implement this would be to add an of_device 581 region.end = region.start + size - 1;
589 * layer routine that can calculate a resource for a given 582 pcibios_bus_to_resource(dev, res, &region);
590 * range property value in a PCI device.
591 */
592 pci_resource_adjust(res, root);
593 } 583 }
594after_ranges: 584after_ranges:
595 sprintf(bus->name, "PCI Bus %04x:%02x", pci_domain_nr(bus), 585 sprintf(bus->name, "PCI Bus %04x:%02x", pci_domain_nr(bus),
@@ -691,8 +681,10 @@ struct pci_bus * __devinit pci_scan_one_pbm(struct pci_pbm_info *pbm,
691 681
692 printk("PCI: Scanning PBM %s\n", node->full_name); 682 printk("PCI: Scanning PBM %s\n", node->full_name);
693 683
694 pci_add_resource(&resources, &pbm->io_space); 684 pci_add_resource_offset(&resources, &pbm->io_space,
695 pci_add_resource(&resources, &pbm->mem_space); 685 pbm->io_space.start);
686 pci_add_resource_offset(&resources, &pbm->mem_space,
687 pbm->mem_space.start);
696 bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops, 688 bus = pci_create_root_bus(parent, pbm->pci_first_busno, pbm->pci_ops,
697 pbm, &resources); 689 pbm, &resources);
698 if (!bus) { 690 if (!bus) {
@@ -755,46 +747,6 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
755 return 0; 747 return 0;
756} 748}
757 749
758void pcibios_resource_to_bus(struct pci_dev *pdev, struct pci_bus_region *region,
759 struct resource *res)
760{
761 struct pci_pbm_info *pbm = pdev->bus->sysdata;
762 struct resource zero_res, *root;
763
764 zero_res.start = 0;
765 zero_res.end = 0;
766 zero_res.flags = res->flags;
767
768 if (res->flags & IORESOURCE_IO)
769 root = &pbm->io_space;
770 else
771 root = &pbm->mem_space;
772
773 pci_resource_adjust(&zero_res, root);
774
775 region->start = res->start - zero_res.start;
776 region->end = res->end - zero_res.start;
777}
778EXPORT_SYMBOL(pcibios_resource_to_bus);
779
780void pcibios_bus_to_resource(struct pci_dev *pdev, struct resource *res,
781 struct pci_bus_region *region)
782{
783 struct pci_pbm_info *pbm = pdev->bus->sysdata;
784 struct resource *root;
785
786 res->start = region->start;
787 res->end = region->end;
788
789 if (res->flags & IORESOURCE_IO)
790 root = &pbm->io_space;
791 else
792 root = &pbm->mem_space;
793
794 pci_resource_adjust(res, root);
795}
796EXPORT_SYMBOL(pcibios_bus_to_resource);
797
798char * __devinit pcibios_setup(char *str) 750char * __devinit pcibios_setup(char *str)
799{ 751{
800 return str; 752 return str;
diff --git a/arch/sparc/kernel/vio.c b/arch/sparc/kernel/vio.c
index f67e28ef598..5cffdc55f07 100644
--- a/arch/sparc/kernel/vio.c
+++ b/arch/sparc/kernel/vio.c
@@ -119,13 +119,17 @@ static struct bus_type vio_bus_type = {
119 .remove = vio_device_remove, 119 .remove = vio_device_remove,
120}; 120};
121 121
122int vio_register_driver(struct vio_driver *viodrv) 122int __vio_register_driver(struct vio_driver *viodrv, struct module *owner,
123 const char *mod_name)
123{ 124{
124 viodrv->driver.bus = &vio_bus_type; 125 viodrv->driver.bus = &vio_bus_type;
126 viodrv->driver.name = viodrv->name;
127 viodrv->driver.owner = owner;
128 viodrv->driver.mod_name = mod_name;
125 129
126 return driver_register(&viodrv->driver); 130 return driver_register(&viodrv->driver);
127} 131}
128EXPORT_SYMBOL(vio_register_driver); 132EXPORT_SYMBOL(__vio_register_driver);
129 133
130void vio_unregister_driver(struct vio_driver *viodrv) 134void vio_unregister_driver(struct vio_driver *viodrv)
131{ 135{
diff --git a/arch/tile/mm/elf.c b/arch/tile/mm/elf.c
index 33368d1aea9..758b6038c2b 100644
--- a/arch/tile/mm/elf.c
+++ b/arch/tile/mm/elf.c
@@ -118,17 +118,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
118 118
119 /* 119 /*
120 * MAYWRITE to allow gdb to COW and set breakpoints 120 * MAYWRITE to allow gdb to COW and set breakpoints
121 *
122 * Make sure the vDSO gets into every core dump. Dumping its
123 * contents makes post-mortem fully interpretable later
124 * without matching up the same kernel and hardware config to
125 * see what PC values meant.
126 */ 121 */
127 vdso_base = VDSO_BASE; 122 vdso_base = VDSO_BASE;
128 retval = install_special_mapping(mm, vdso_base, PAGE_SIZE, 123 retval = install_special_mapping(mm, vdso_base, PAGE_SIZE,
129 VM_READ|VM_EXEC| 124 VM_READ|VM_EXEC|
130 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC| 125 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
131 VM_ALWAYSDUMP,
132 vdso_pages); 126 vdso_pages);
133 127
134#ifndef __tilegx__ 128#ifndef __tilegx__
diff --git a/arch/um/Kconfig.common b/arch/um/Kconfig.common
index b37ae706af3..20a49ba93cb 100644
--- a/arch/um/Kconfig.common
+++ b/arch/um/Kconfig.common
@@ -9,6 +9,7 @@ config UML
9 select HAVE_GENERIC_HARDIRQS 9 select HAVE_GENERIC_HARDIRQS
10 select GENERIC_IRQ_SHOW 10 select GENERIC_IRQ_SHOW
11 select GENERIC_CPU_DEVICES 11 select GENERIC_CPU_DEVICES
12 select GENERIC_IO
12 13
13config MMU 14config MMU
14 bool 15 bool
diff --git a/arch/um/Makefile b/arch/um/Makefile
index 28688e6d96d..55c0661e2b5 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -28,6 +28,7 @@ ifeq ($(SUBARCH),i386)
28endif 28endif
29ifeq ($(SUBARCH),x86_64) 29ifeq ($(SUBARCH),x86_64)
30 HEADER_ARCH := x86 30 HEADER_ARCH := x86
31 KBUILD_CFLAGS += -mcmodel=large
31endif 32endif
32 33
33HOST_DIR := arch/$(HEADER_ARCH) 34HOST_DIR := arch/$(HEADER_ARCH)
@@ -50,7 +51,7 @@ KBUILD_CPPFLAGS += -I$(srctree)/$(HOST_DIR)/um
50# 51#
51# These apply to USER_CFLAGS to. 52# These apply to USER_CFLAGS to.
52 53
53KBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \ 54KBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ \
54 $(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap \ 55 $(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap \
55 -Din6addr_loopback=kernel_in6addr_loopback \ 56 -Din6addr_loopback=kernel_in6addr_loopback \
56 -Din6addr_any=kernel_in6addr_any -Dstrrchr=kernel_strrchr 57 -Din6addr_any=kernel_in6addr_any -Dstrrchr=kernel_strrchr
@@ -99,7 +100,7 @@ KBUILD_KCONFIG := $(HOST_DIR)/um/Kconfig
99 100
100archheaders: 101archheaders:
101 $(Q)$(MAKE) -C '$(srctree)' KBUILD_SRC= \ 102 $(Q)$(MAKE) -C '$(srctree)' KBUILD_SRC= \
102 ARCH=$(SUBARCH) O='$(objtree)' archheaders 103 ARCH=$(HEADER_ARCH) O='$(objtree)' archheaders
103 104
104archprepare: include/generated/user_constants.h 105archprepare: include/generated/user_constants.h
105 106
diff --git a/arch/um/defconfig b/arch/um/defconfig
index 761f5e1a657..fdc97e2c3d7 100644
--- a/arch/um/defconfig
+++ b/arch/um/defconfig
@@ -1,10 +1,8 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated file; DO NOT EDIT.
3# Linux kernel version: 2.6.24 3# User Mode Linux/i386 3.3.0 Kernel Configuration
4# Thu Feb 7 11:48:55 2008
5# 4#
6CONFIG_DEFCONFIG_LIST="arch/$ARCH/defconfig" 5CONFIG_DEFCONFIG_LIST="arch/$ARCH/defconfig"
7CONFIG_GENERIC_HARDIRQS=y
8CONFIG_UML=y 6CONFIG_UML=y
9CONFIG_MMU=y 7CONFIG_MMU=y
10CONFIG_NO_IOMEM=y 8CONFIG_NO_IOMEM=y
@@ -20,12 +18,10 @@ CONFIG_HZ=100
20# 18#
21# UML-specific options 19# UML-specific options
22# 20#
23# CONFIG_STATIC_LINK is not set
24 21
25# 22#
26# Host processor type and features 23# Host processor type and features
27# 24#
28# CONFIG_M386 is not set
29# CONFIG_M486 is not set 25# CONFIG_M486 is not set
30# CONFIG_M586 is not set 26# CONFIG_M586 is not set
31# CONFIG_M586TSC is not set 27# CONFIG_M586TSC is not set
@@ -41,17 +37,17 @@ CONFIG_M686=y
41# CONFIG_MCRUSOE is not set 37# CONFIG_MCRUSOE is not set
42# CONFIG_MEFFICEON is not set 38# CONFIG_MEFFICEON is not set
43# CONFIG_MWINCHIPC6 is not set 39# CONFIG_MWINCHIPC6 is not set
44# CONFIG_MWINCHIP2 is not set
45# CONFIG_MWINCHIP3D is not set 40# CONFIG_MWINCHIP3D is not set
41# CONFIG_MELAN is not set
46# CONFIG_MGEODEGX1 is not set 42# CONFIG_MGEODEGX1 is not set
47# CONFIG_MGEODE_LX is not set 43# CONFIG_MGEODE_LX is not set
48# CONFIG_MCYRIXIII is not set 44# CONFIG_MCYRIXIII is not set
49# CONFIG_MVIAC3_2 is not set 45# CONFIG_MVIAC3_2 is not set
50# CONFIG_MVIAC7 is not set 46# CONFIG_MVIAC7 is not set
51# CONFIG_MPSC is not set
52# CONFIG_MCORE2 is not set 47# CONFIG_MCORE2 is not set
53# CONFIG_GENERIC_CPU is not set 48# CONFIG_MATOM is not set
54# CONFIG_X86_GENERIC is not set 49# CONFIG_X86_GENERIC is not set
50CONFIG_X86_INTERNODE_CACHE_SHIFT=5
55CONFIG_X86_CMPXCHG=y 51CONFIG_X86_CMPXCHG=y
56CONFIG_X86_L1_CACHE_SHIFT=5 52CONFIG_X86_L1_CACHE_SHIFT=5
57CONFIG_X86_XADD=y 53CONFIG_X86_XADD=y
@@ -60,47 +56,59 @@ CONFIG_X86_WP_WORKS_OK=y
60CONFIG_X86_INVLPG=y 56CONFIG_X86_INVLPG=y
61CONFIG_X86_BSWAP=y 57CONFIG_X86_BSWAP=y
62CONFIG_X86_POPAD_OK=y 58CONFIG_X86_POPAD_OK=y
63CONFIG_X86_GOOD_APIC=y
64CONFIG_X86_USE_PPRO_CHECKSUM=y 59CONFIG_X86_USE_PPRO_CHECKSUM=y
65CONFIG_X86_TSC=y 60CONFIG_X86_TSC=y
61CONFIG_X86_CMPXCHG64=y
66CONFIG_X86_CMOV=y 62CONFIG_X86_CMOV=y
67CONFIG_X86_MINIMUM_CPU_FAMILY=4 63CONFIG_X86_MINIMUM_CPU_FAMILY=5
68CONFIG_X86_DEBUGCTLMSR=y 64CONFIG_CPU_SUP_INTEL=y
65CONFIG_CPU_SUP_CYRIX_32=y
66CONFIG_CPU_SUP_AMD=y
67CONFIG_CPU_SUP_CENTAUR=y
68CONFIG_CPU_SUP_TRANSMETA_32=y
69CONFIG_CPU_SUP_UMC_32=y
69CONFIG_UML_X86=y 70CONFIG_UML_X86=y
70CONFIG_X86_32=y
71CONFIG_RWSEM_XCHGADD_ALGORITHM=y
72# CONFIG_64BIT is not set 71# CONFIG_64BIT is not set
73CONFIG_SEMAPHORE_SLEEPERS=y 72CONFIG_X86_32=y
73# CONFIG_X86_64 is not set
74# CONFIG_RWSEM_XCHGADD_ALGORITHM is not set
75CONFIG_RWSEM_GENERIC_SPINLOCK=y
74# CONFIG_3_LEVEL_PGTABLES is not set 76# CONFIG_3_LEVEL_PGTABLES is not set
75CONFIG_ARCH_HAS_SC_SIGNALS=y 77CONFIG_ARCH_HAS_SC_SIGNALS=y
76CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA=y 78CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA=y
77CONFIG_GENERIC_HWEIGHT=y 79CONFIG_GENERIC_HWEIGHT=y
80# CONFIG_STATIC_LINK is not set
78CONFIG_SELECT_MEMORY_MODEL=y 81CONFIG_SELECT_MEMORY_MODEL=y
79CONFIG_FLATMEM_MANUAL=y 82CONFIG_FLATMEM_MANUAL=y
80# CONFIG_DISCONTIGMEM_MANUAL is not set
81# CONFIG_SPARSEMEM_MANUAL is not set
82CONFIG_FLATMEM=y 83CONFIG_FLATMEM=y
83CONFIG_FLAT_NODE_MEM_MAP=y 84CONFIG_FLAT_NODE_MEM_MAP=y
84# CONFIG_SPARSEMEM_STATIC is not set 85CONFIG_PAGEFLAGS_EXTENDED=y
85# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
86CONFIG_SPLIT_PTLOCK_CPUS=4 86CONFIG_SPLIT_PTLOCK_CPUS=4
87# CONFIG_RESOURCES_64BIT is not set 87# CONFIG_COMPACTION is not set
88# CONFIG_PHYS_ADDR_T_64BIT is not set
88CONFIG_ZONE_DMA_FLAG=0 89CONFIG_ZONE_DMA_FLAG=0
89CONFIG_VIRT_TO_BUS=y 90CONFIG_VIRT_TO_BUS=y
91# CONFIG_KSM is not set
92CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
93CONFIG_NEED_PER_CPU_KM=y
94# CONFIG_CLEANCACHE is not set
90CONFIG_TICK_ONESHOT=y 95CONFIG_TICK_ONESHOT=y
91CONFIG_NO_HZ=y 96CONFIG_NO_HZ=y
92CONFIG_HIGH_RES_TIMERS=y 97CONFIG_HIGH_RES_TIMERS=y
93CONFIG_GENERIC_CLOCKEVENTS_BUILD=y 98CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
94CONFIG_LD_SCRIPT_DYN=y 99CONFIG_LD_SCRIPT_DYN=y
95CONFIG_BINFMT_ELF=y 100CONFIG_BINFMT_ELF=y
101CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y
102CONFIG_HAVE_AOUT=y
96# CONFIG_BINFMT_AOUT is not set 103# CONFIG_BINFMT_AOUT is not set
97CONFIG_BINFMT_MISC=m 104CONFIG_BINFMT_MISC=m
98CONFIG_HOSTFS=y 105CONFIG_HOSTFS=y
99# CONFIG_HPPFS is not set 106# CONFIG_HPPFS is not set
100CONFIG_MCONSOLE=y 107CONFIG_MCONSOLE=y
101CONFIG_MAGIC_SYSRQ=y 108CONFIG_MAGIC_SYSRQ=y
102# CONFIG_HIGHMEM is not set
103CONFIG_KERNEL_STACK_ORDER=0 109CONFIG_KERNEL_STACK_ORDER=0
110# CONFIG_MMAPPER is not set
111CONFIG_NO_DMA=y
104 112
105# 113#
106# General setup 114# General setup
@@ -108,99 +116,169 @@ CONFIG_KERNEL_STACK_ORDER=0
108CONFIG_EXPERIMENTAL=y 116CONFIG_EXPERIMENTAL=y
109CONFIG_BROKEN_ON_SMP=y 117CONFIG_BROKEN_ON_SMP=y
110CONFIG_INIT_ENV_ARG_LIMIT=128 118CONFIG_INIT_ENV_ARG_LIMIT=128
119CONFIG_CROSS_COMPILE=""
111CONFIG_LOCALVERSION="" 120CONFIG_LOCALVERSION=""
112CONFIG_LOCALVERSION_AUTO=y 121CONFIG_LOCALVERSION_AUTO=y
122CONFIG_DEFAULT_HOSTNAME="(none)"
113CONFIG_SWAP=y 123CONFIG_SWAP=y
114CONFIG_SYSVIPC=y 124CONFIG_SYSVIPC=y
115CONFIG_SYSVIPC_SYSCTL=y 125CONFIG_SYSVIPC_SYSCTL=y
116CONFIG_POSIX_MQUEUE=y 126CONFIG_POSIX_MQUEUE=y
127CONFIG_POSIX_MQUEUE_SYSCTL=y
117CONFIG_BSD_PROCESS_ACCT=y 128CONFIG_BSD_PROCESS_ACCT=y
118# CONFIG_BSD_PROCESS_ACCT_V3 is not set 129# CONFIG_BSD_PROCESS_ACCT_V3 is not set
130# CONFIG_FHANDLE is not set
119# CONFIG_TASKSTATS is not set 131# CONFIG_TASKSTATS is not set
120# CONFIG_USER_NS is not set
121# CONFIG_PID_NS is not set
122# CONFIG_AUDIT is not set 132# CONFIG_AUDIT is not set
133CONFIG_HAVE_GENERIC_HARDIRQS=y
134
135#
136# IRQ subsystem
137#
138CONFIG_GENERIC_HARDIRQS=y
139CONFIG_GENERIC_IRQ_SHOW=y
140
141#
142# RCU Subsystem
143#
144CONFIG_TINY_RCU=y
145# CONFIG_PREEMPT_RCU is not set
146# CONFIG_RCU_TRACE is not set
147# CONFIG_TREE_RCU_TRACE is not set
123CONFIG_IKCONFIG=y 148CONFIG_IKCONFIG=y
124CONFIG_IKCONFIG_PROC=y 149CONFIG_IKCONFIG_PROC=y
125CONFIG_LOG_BUF_SHIFT=14 150CONFIG_LOG_BUF_SHIFT=14
126# CONFIG_CGROUPS is not set 151CONFIG_CGROUPS=y
152# CONFIG_CGROUP_DEBUG is not set
153CONFIG_CGROUP_FREEZER=y
154CONFIG_CGROUP_DEVICE=y
155CONFIG_CPUSETS=y
156CONFIG_PROC_PID_CPUSET=y
157CONFIG_CGROUP_CPUACCT=y
158CONFIG_RESOURCE_COUNTERS=y
159CONFIG_CGROUP_MEM_RES_CTLR=y
160CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y
161# CONFIG_CGROUP_MEM_RES_CTLR_SWAP_ENABLED is not set
162# CONFIG_CGROUP_MEM_RES_CTLR_KMEM is not set
163CONFIG_CGROUP_SCHED=y
127CONFIG_FAIR_GROUP_SCHED=y 164CONFIG_FAIR_GROUP_SCHED=y
128CONFIG_FAIR_USER_SCHED=y 165# CONFIG_CFS_BANDWIDTH is not set
129# CONFIG_FAIR_CGROUP_SCHED is not set 166# CONFIG_RT_GROUP_SCHED is not set
167CONFIG_BLK_CGROUP=m
168# CONFIG_DEBUG_BLK_CGROUP is not set
169# CONFIG_CHECKPOINT_RESTORE is not set
170CONFIG_NAMESPACES=y
171CONFIG_UTS_NS=y
172CONFIG_IPC_NS=y
173# CONFIG_USER_NS is not set
174# CONFIG_PID_NS is not set
175CONFIG_NET_NS=y
176# CONFIG_SCHED_AUTOGROUP is not set
177CONFIG_MM_OWNER=y
130CONFIG_SYSFS_DEPRECATED=y 178CONFIG_SYSFS_DEPRECATED=y
179# CONFIG_SYSFS_DEPRECATED_V2 is not set
131# CONFIG_RELAY is not set 180# CONFIG_RELAY is not set
132# CONFIG_BLK_DEV_INITRD is not set 181# CONFIG_BLK_DEV_INITRD is not set
133CONFIG_CC_OPTIMIZE_FOR_SIZE=y 182CONFIG_CC_OPTIMIZE_FOR_SIZE=y
134CONFIG_SYSCTL=y 183CONFIG_SYSCTL=y
184CONFIG_ANON_INODES=y
135# CONFIG_EXPERT is not set 185# CONFIG_EXPERT is not set
136CONFIG_UID16=y 186CONFIG_UID16=y
137CONFIG_SYSCTL_SYSCALL=y 187# CONFIG_SYSCTL_SYSCALL is not set
138CONFIG_KALLSYMS=y 188CONFIG_KALLSYMS=y
139# CONFIG_KALLSYMS_ALL is not set 189# CONFIG_KALLSYMS_ALL is not set
140CONFIG_KALLSYMS_EXTRA_PASS=y
141CONFIG_HOTPLUG=y 190CONFIG_HOTPLUG=y
142CONFIG_PRINTK=y 191CONFIG_PRINTK=y
143CONFIG_BUG=y 192CONFIG_BUG=y
144CONFIG_ELF_CORE=y 193CONFIG_ELF_CORE=y
145CONFIG_BASE_FULL=y 194CONFIG_BASE_FULL=y
146CONFIG_FUTEX=y 195CONFIG_FUTEX=y
147CONFIG_ANON_INODES=y
148CONFIG_EPOLL=y 196CONFIG_EPOLL=y
149CONFIG_SIGNALFD=y 197CONFIG_SIGNALFD=y
150CONFIG_TIMERFD=y 198CONFIG_TIMERFD=y
151CONFIG_EVENTFD=y 199CONFIG_EVENTFD=y
152CONFIG_SHMEM=y 200CONFIG_SHMEM=y
201CONFIG_AIO=y
202# CONFIG_EMBEDDED is not set
203
204#
205# Kernel Performance Events And Counters
206#
153CONFIG_VM_EVENT_COUNTERS=y 207CONFIG_VM_EVENT_COUNTERS=y
208CONFIG_COMPAT_BRK=y
154CONFIG_SLAB=y 209CONFIG_SLAB=y
155# CONFIG_SLUB is not set 210# CONFIG_SLUB is not set
156# CONFIG_SLOB is not set
157# CONFIG_PROFILING is not set 211# CONFIG_PROFILING is not set
158# CONFIG_MARKERS is not set 212
159# CONFIG_HAVE_OPROFILE is not set 213#
160# CONFIG_HAVE_KPROBES is not set 214# GCOV-based kernel profiling
161CONFIG_PROC_PAGE_MONITOR=y 215#
216# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
162CONFIG_SLABINFO=y 217CONFIG_SLABINFO=y
163CONFIG_RT_MUTEXES=y 218CONFIG_RT_MUTEXES=y
164# CONFIG_TINY_SHMEM is not set
165CONFIG_BASE_SMALL=0 219CONFIG_BASE_SMALL=0
166CONFIG_MODULES=y 220CONFIG_MODULES=y
221# CONFIG_MODULE_FORCE_LOAD is not set
167CONFIG_MODULE_UNLOAD=y 222CONFIG_MODULE_UNLOAD=y
168# CONFIG_MODULE_FORCE_UNLOAD is not set 223# CONFIG_MODULE_FORCE_UNLOAD is not set
169# CONFIG_MODVERSIONS is not set 224# CONFIG_MODVERSIONS is not set
170# CONFIG_MODULE_SRCVERSION_ALL is not set 225# CONFIG_MODULE_SRCVERSION_ALL is not set
171CONFIG_KMOD=y
172CONFIG_BLOCK=y 226CONFIG_BLOCK=y
173# CONFIG_LBD is not set 227CONFIG_LBDAF=y
174# CONFIG_BLK_DEV_IO_TRACE is not set
175# CONFIG_LSF is not set
176# CONFIG_BLK_DEV_BSG is not set 228# CONFIG_BLK_DEV_BSG is not set
229# CONFIG_BLK_DEV_BSGLIB is not set
230# CONFIG_BLK_DEV_INTEGRITY is not set
231
232#
233# Partition Types
234#
235# CONFIG_PARTITION_ADVANCED is not set
236CONFIG_MSDOS_PARTITION=y
177 237
178# 238#
179# IO Schedulers 239# IO Schedulers
180# 240#
181CONFIG_IOSCHED_NOOP=y 241CONFIG_IOSCHED_NOOP=y
182CONFIG_IOSCHED_AS=y
183CONFIG_IOSCHED_DEADLINE=y 242CONFIG_IOSCHED_DEADLINE=y
184CONFIG_IOSCHED_CFQ=y 243CONFIG_IOSCHED_CFQ=m
185CONFIG_DEFAULT_AS=y 244# CONFIG_CFQ_GROUP_IOSCHED is not set
186# CONFIG_DEFAULT_DEADLINE is not set 245CONFIG_DEFAULT_DEADLINE=y
187# CONFIG_DEFAULT_CFQ is not set 246# CONFIG_DEFAULT_CFQ is not set
188# CONFIG_DEFAULT_NOOP is not set 247# CONFIG_DEFAULT_NOOP is not set
189CONFIG_DEFAULT_IOSCHED="anticipatory" 248CONFIG_DEFAULT_IOSCHED="deadline"
190CONFIG_CLASSIC_RCU=y 249# CONFIG_INLINE_SPIN_TRYLOCK is not set
191# CONFIG_PREEMPT_RCU is not set 250# CONFIG_INLINE_SPIN_TRYLOCK_BH is not set
192CONFIG_BLK_DEV=y 251# CONFIG_INLINE_SPIN_LOCK is not set
193CONFIG_BLK_DEV_UBD=y 252# CONFIG_INLINE_SPIN_LOCK_BH is not set
194# CONFIG_BLK_DEV_UBD_SYNC is not set 253# CONFIG_INLINE_SPIN_LOCK_IRQ is not set
195CONFIG_BLK_DEV_COW_COMMON=y 254# CONFIG_INLINE_SPIN_LOCK_IRQSAVE is not set
196CONFIG_BLK_DEV_LOOP=m 255CONFIG_INLINE_SPIN_UNLOCK=y
197# CONFIG_BLK_DEV_CRYPTOLOOP is not set 256# CONFIG_INLINE_SPIN_UNLOCK_BH is not set
198CONFIG_BLK_DEV_NBD=m 257CONFIG_INLINE_SPIN_UNLOCK_IRQ=y
199# CONFIG_BLK_DEV_RAM is not set 258# CONFIG_INLINE_SPIN_UNLOCK_IRQRESTORE is not set
200# CONFIG_ATA_OVER_ETH is not set 259# CONFIG_INLINE_READ_TRYLOCK is not set
260# CONFIG_INLINE_READ_LOCK is not set
261# CONFIG_INLINE_READ_LOCK_BH is not set
262# CONFIG_INLINE_READ_LOCK_IRQ is not set
263# CONFIG_INLINE_READ_LOCK_IRQSAVE is not set
264CONFIG_INLINE_READ_UNLOCK=y
265# CONFIG_INLINE_READ_UNLOCK_BH is not set
266CONFIG_INLINE_READ_UNLOCK_IRQ=y
267# CONFIG_INLINE_READ_UNLOCK_IRQRESTORE is not set
268# CONFIG_INLINE_WRITE_TRYLOCK is not set
269# CONFIG_INLINE_WRITE_LOCK is not set
270# CONFIG_INLINE_WRITE_LOCK_BH is not set
271# CONFIG_INLINE_WRITE_LOCK_IRQ is not set
272# CONFIG_INLINE_WRITE_LOCK_IRQSAVE is not set
273CONFIG_INLINE_WRITE_UNLOCK=y
274# CONFIG_INLINE_WRITE_UNLOCK_BH is not set
275CONFIG_INLINE_WRITE_UNLOCK_IRQ=y
276# CONFIG_INLINE_WRITE_UNLOCK_IRQRESTORE is not set
277# CONFIG_MUTEX_SPIN_ON_OWNER is not set
278CONFIG_FREEZER=y
201 279
202# 280#
203# Character Devices 281# UML Character Devices
204# 282#
205CONFIG_STDERR_CONSOLE=y 283CONFIG_STDERR_CONSOLE=y
206CONFIG_STDIO_CONSOLE=y 284CONFIG_STDIO_CONSOLE=y
@@ -214,40 +292,191 @@ CONFIG_XTERM_CHAN=y
214CONFIG_CON_ZERO_CHAN="fd:0,fd:1" 292CONFIG_CON_ZERO_CHAN="fd:0,fd:1"
215CONFIG_CON_CHAN="xterm" 293CONFIG_CON_CHAN="xterm"
216CONFIG_SSL_CHAN="pts" 294CONFIG_SSL_CHAN="pts"
217CONFIG_UNIX98_PTYS=y
218CONFIG_LEGACY_PTYS=y
219# CONFIG_RAW_DRIVER is not set
220CONFIG_LEGACY_PTY_COUNT=32
221# CONFIG_WATCHDOG is not set
222CONFIG_UML_SOUND=m 295CONFIG_UML_SOUND=m
223CONFIG_SOUND=m 296CONFIG_SOUND=m
297CONFIG_SOUND_OSS_CORE=y
224CONFIG_HOSTAUDIO=m 298CONFIG_HOSTAUDIO=m
225# CONFIG_HW_RANDOM is not set 299
226CONFIG_UML_RANDOM=y 300#
227# CONFIG_MMAPPER is not set 301# Device Drivers
302#
228 303
229# 304#
230# Generic Driver Options 305# Generic Driver Options
231# 306#
232CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 307CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
308CONFIG_DEVTMPFS=y
309CONFIG_DEVTMPFS_MOUNT=y
233CONFIG_STANDALONE=y 310CONFIG_STANDALONE=y
234CONFIG_PREVENT_FIRMWARE_BUILD=y 311CONFIG_PREVENT_FIRMWARE_BUILD=y
235# CONFIG_FW_LOADER is not set 312CONFIG_FW_LOADER=y
313CONFIG_FIRMWARE_IN_KERNEL=y
314CONFIG_EXTRA_FIRMWARE=""
236# CONFIG_DEBUG_DRIVER is not set 315# CONFIG_DEBUG_DRIVER is not set
237# CONFIG_DEBUG_DEVRES is not set 316# CONFIG_DEBUG_DEVRES is not set
238# CONFIG_SYS_HYPERVISOR is not set 317# CONFIG_SYS_HYPERVISOR is not set
318CONFIG_GENERIC_CPU_DEVICES=y
319# CONFIG_DMA_SHARED_BUFFER is not set
320# CONFIG_CONNECTOR is not set
321# CONFIG_MTD is not set
322CONFIG_BLK_DEV=y
323CONFIG_BLK_DEV_UBD=y
324# CONFIG_BLK_DEV_UBD_SYNC is not set
325CONFIG_BLK_DEV_COW_COMMON=y
326CONFIG_BLK_DEV_LOOP=m
327CONFIG_BLK_DEV_LOOP_MIN_COUNT=8
328# CONFIG_BLK_DEV_CRYPTOLOOP is not set
329
330#
331# DRBD disabled because PROC_FS, INET or CONNECTOR not selected
332#
333CONFIG_BLK_DEV_NBD=m
334# CONFIG_BLK_DEV_RAM is not set
335# CONFIG_ATA_OVER_ETH is not set
336# CONFIG_BLK_DEV_RBD is not set
337
338#
339# Misc devices
340#
341# CONFIG_ENCLOSURE_SERVICES is not set
342# CONFIG_C2PORT is not set
343
344#
345# EEPROM support
346#
347# CONFIG_EEPROM_93CX6 is not set
348
349#
350# Texas Instruments shared transport line discipline
351#
352
353#
354# Altera FPGA firmware download module
355#
356
357#
358# SCSI device support
359#
360CONFIG_SCSI_MOD=y
361# CONFIG_RAID_ATTRS is not set
362# CONFIG_SCSI is not set
363# CONFIG_SCSI_DMA is not set
364# CONFIG_SCSI_NETLINK is not set
365# CONFIG_MD is not set
366CONFIG_NETDEVICES=y
367CONFIG_NET_CORE=y
368# CONFIG_BONDING is not set
369CONFIG_DUMMY=m
370# CONFIG_EQUALIZER is not set
371# CONFIG_MII is not set
372# CONFIG_NET_TEAM is not set
373# CONFIG_MACVLAN is not set
374# CONFIG_NETCONSOLE is not set
375# CONFIG_NETPOLL is not set
376# CONFIG_NET_POLL_CONTROLLER is not set
377CONFIG_TUN=m
378# CONFIG_VETH is not set
379
380#
381# CAIF transport drivers
382#
383CONFIG_ETHERNET=y
384CONFIG_NET_VENDOR_CHELSIO=y
385CONFIG_NET_VENDOR_INTEL=y
386CONFIG_NET_VENDOR_I825XX=y
387CONFIG_NET_VENDOR_MARVELL=y
388CONFIG_NET_VENDOR_NATSEMI=y
389CONFIG_NET_VENDOR_8390=y
390# CONFIG_PHYLIB is not set
391CONFIG_PPP=m
392# CONFIG_PPP_BSDCOMP is not set
393# CONFIG_PPP_DEFLATE is not set
394# CONFIG_PPP_FILTER is not set
395# CONFIG_PPP_MPPE is not set
396# CONFIG_PPP_MULTILINK is not set
397# CONFIG_PPPOE is not set
398# CONFIG_PPP_ASYNC is not set
399# CONFIG_PPP_SYNC_TTY is not set
400CONFIG_SLIP=m
401CONFIG_SLHC=m
402# CONFIG_SLIP_COMPRESSED is not set
403# CONFIG_SLIP_SMART is not set
404# CONFIG_SLIP_MODE_SLIP6 is not set
405CONFIG_WLAN=y
406# CONFIG_HOSTAP is not set
407
408#
409# Enable WiMAX (Networking options) to see the WiMAX drivers
410#
411# CONFIG_WAN is not set
412
413#
414# Character devices
415#
416CONFIG_UNIX98_PTYS=y
417# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
418CONFIG_LEGACY_PTYS=y
419CONFIG_LEGACY_PTY_COUNT=32
420# CONFIG_N_GSM is not set
421# CONFIG_TRACE_SINK is not set
422CONFIG_DEVKMEM=y
423# CONFIG_HW_RANDOM is not set
424CONFIG_UML_RANDOM=y
425# CONFIG_R3964 is not set
426# CONFIG_NSC_GPIO is not set
427# CONFIG_RAW_DRIVER is not set
428
429#
430# PPS support
431#
432# CONFIG_PPS is not set
433
434#
435# PPS generators support
436#
437
438#
439# PTP clock support
440#
441
442#
443# Enable Device Drivers -> PPS to see the PTP clock options.
444#
445# CONFIG_POWER_SUPPLY is not set
446# CONFIG_THERMAL is not set
447# CONFIG_WATCHDOG is not set
448# CONFIG_REGULATOR is not set
449CONFIG_SOUND_OSS_CORE_PRECLAIM=y
450# CONFIG_MEMSTICK is not set
451# CONFIG_NEW_LEDS is not set
452# CONFIG_ACCESSIBILITY is not set
453# CONFIG_AUXDISPLAY is not set
454# CONFIG_UIO is not set
455
456#
457# Virtio drivers
458#
459# CONFIG_VIRTIO_BALLOON is not set
460
461#
462# Microsoft Hyper-V guest support
463#
464# CONFIG_STAGING is not set
239 465
240# 466#
241# Networking 467# Hardware Spinlock drivers
242# 468#
469CONFIG_IOMMU_SUPPORT=y
470# CONFIG_VIRT_DRIVERS is not set
471# CONFIG_PM_DEVFREQ is not set
243CONFIG_NET=y 472CONFIG_NET=y
244 473
245# 474#
246# Networking options 475# Networking options
247# 476#
248CONFIG_PACKET=y 477CONFIG_PACKET=y
249CONFIG_PACKET_MMAP=y
250CONFIG_UNIX=y 478CONFIG_UNIX=y
479# CONFIG_UNIX_DIAG is not set
251CONFIG_XFRM=y 480CONFIG_XFRM=y
252# CONFIG_XFRM_USER is not set 481# CONFIG_XFRM_USER is not set
253# CONFIG_XFRM_SUB_POLICY is not set 482# CONFIG_XFRM_SUB_POLICY is not set
@@ -257,10 +486,9 @@ CONFIG_XFRM=y
257CONFIG_INET=y 486CONFIG_INET=y
258# CONFIG_IP_MULTICAST is not set 487# CONFIG_IP_MULTICAST is not set
259# CONFIG_IP_ADVANCED_ROUTER is not set 488# CONFIG_IP_ADVANCED_ROUTER is not set
260CONFIG_IP_FIB_HASH=y
261# CONFIG_IP_PNP is not set 489# CONFIG_IP_PNP is not set
262# CONFIG_NET_IPIP is not set 490# CONFIG_NET_IPIP is not set
263# CONFIG_NET_IPGRE is not set 491# CONFIG_NET_IPGRE_DEMUX is not set
264# CONFIG_ARPD is not set 492# CONFIG_ARPD is not set
265# CONFIG_SYN_COOKIES is not set 493# CONFIG_SYN_COOKIES is not set
266# CONFIG_INET_AH is not set 494# CONFIG_INET_AH is not set
@@ -274,20 +502,23 @@ CONFIG_INET_XFRM_MODE_BEET=y
274# CONFIG_INET_LRO is not set 502# CONFIG_INET_LRO is not set
275CONFIG_INET_DIAG=y 503CONFIG_INET_DIAG=y
276CONFIG_INET_TCP_DIAG=y 504CONFIG_INET_TCP_DIAG=y
505# CONFIG_INET_UDP_DIAG is not set
277# CONFIG_TCP_CONG_ADVANCED is not set 506# CONFIG_TCP_CONG_ADVANCED is not set
278CONFIG_TCP_CONG_CUBIC=y 507CONFIG_TCP_CONG_CUBIC=y
279CONFIG_DEFAULT_TCP_CONG="cubic" 508CONFIG_DEFAULT_TCP_CONG="cubic"
280# CONFIG_TCP_MD5SIG is not set 509# CONFIG_TCP_MD5SIG is not set
281# CONFIG_IPV6 is not set 510# CONFIG_IPV6 is not set
282# CONFIG_INET6_XFRM_TUNNEL is not set
283# CONFIG_INET6_TUNNEL is not set
284# CONFIG_NETWORK_SECMARK is not set 511# CONFIG_NETWORK_SECMARK is not set
512# CONFIG_NETWORK_PHY_TIMESTAMPING is not set
285# CONFIG_NETFILTER is not set 513# CONFIG_NETFILTER is not set
286# CONFIG_IP_DCCP is not set 514# CONFIG_IP_DCCP is not set
287# CONFIG_IP_SCTP is not set 515# CONFIG_IP_SCTP is not set
516# CONFIG_RDS is not set
288# CONFIG_TIPC is not set 517# CONFIG_TIPC is not set
289# CONFIG_ATM is not set 518# CONFIG_ATM is not set
519# CONFIG_L2TP is not set
290# CONFIG_BRIDGE is not set 520# CONFIG_BRIDGE is not set
521# CONFIG_NET_DSA is not set
291# CONFIG_VLAN_8021Q is not set 522# CONFIG_VLAN_8021Q is not set
292# CONFIG_DECNET is not set 523# CONFIG_DECNET is not set
293# CONFIG_LLC2 is not set 524# CONFIG_LLC2 is not set
@@ -297,7 +528,14 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
297# CONFIG_LAPB is not set 528# CONFIG_LAPB is not set
298# CONFIG_ECONET is not set 529# CONFIG_ECONET is not set
299# CONFIG_WAN_ROUTER is not set 530# CONFIG_WAN_ROUTER is not set
531# CONFIG_PHONET is not set
532# CONFIG_IEEE802154 is not set
300# CONFIG_NET_SCHED is not set 533# CONFIG_NET_SCHED is not set
534# CONFIG_DCB is not set
535# CONFIG_BATMAN_ADV is not set
536# CONFIG_OPENVSWITCH is not set
537# CONFIG_NETPRIO_CGROUP is not set
538CONFIG_BQL=y
301 539
302# 540#
303# Network testing 541# Network testing
@@ -308,16 +546,19 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
308# CONFIG_IRDA is not set 546# CONFIG_IRDA is not set
309# CONFIG_BT is not set 547# CONFIG_BT is not set
310# CONFIG_AF_RXRPC is not set 548# CONFIG_AF_RXRPC is not set
549CONFIG_WIRELESS=y
550# CONFIG_CFG80211 is not set
551# CONFIG_LIB80211 is not set
311 552
312# 553#
313# Wireless 554# CFG80211 needs to be enabled for MAC80211
314# 555#
315# CONFIG_CFG80211 is not set 556# CONFIG_WIMAX is not set
316# CONFIG_WIRELESS_EXT is not set
317# CONFIG_MAC80211 is not set
318# CONFIG_IEEE80211 is not set
319# CONFIG_RFKILL is not set 557# CONFIG_RFKILL is not set
320# CONFIG_NET_9P is not set 558# CONFIG_NET_9P is not set
559# CONFIG_CAIF is not set
560# CONFIG_CEPH_LIB is not set
561# CONFIG_NFC is not set
321 562
322# 563#
323# UML Network Devices 564# UML Network Devices
@@ -331,76 +572,51 @@ CONFIG_UML_NET_DAEMON=y
331CONFIG_UML_NET_MCAST=y 572CONFIG_UML_NET_MCAST=y
332# CONFIG_UML_NET_PCAP is not set 573# CONFIG_UML_NET_PCAP is not set
333CONFIG_UML_NET_SLIRP=y 574CONFIG_UML_NET_SLIRP=y
334CONFIG_NETDEVICES=y
335# CONFIG_NETDEVICES_MULTIQUEUE is not set
336CONFIG_DUMMY=m
337# CONFIG_BONDING is not set
338# CONFIG_MACVLAN is not set
339# CONFIG_EQUALIZER is not set
340CONFIG_TUN=m
341# CONFIG_VETH is not set
342
343#
344# Wireless LAN
345#
346# CONFIG_WLAN_PRE80211 is not set
347# CONFIG_WLAN_80211 is not set
348# CONFIG_WAN is not set
349CONFIG_PPP=m
350# CONFIG_PPP_MULTILINK is not set
351# CONFIG_PPP_FILTER is not set
352# CONFIG_PPP_ASYNC is not set
353# CONFIG_PPP_SYNC_TTY is not set
354# CONFIG_PPP_DEFLATE is not set
355# CONFIG_PPP_BSDCOMP is not set
356# CONFIG_PPP_MPPE is not set
357# CONFIG_PPPOE is not set
358# CONFIG_PPPOL2TP is not set
359CONFIG_SLIP=m
360# CONFIG_SLIP_COMPRESSED is not set
361CONFIG_SLHC=m
362# CONFIG_SLIP_SMART is not set
363# CONFIG_SLIP_MODE_SLIP6 is not set
364# CONFIG_NETCONSOLE is not set
365# CONFIG_NETPOLL is not set
366# CONFIG_NET_POLL_CONTROLLER is not set
367# CONFIG_CONNECTOR is not set
368 575
369# 576#
370# File systems 577# File systems
371# 578#
372CONFIG_EXT2_FS=y 579# CONFIG_EXT2_FS is not set
373# CONFIG_EXT2_FS_XATTR is not set 580# CONFIG_EXT3_FS is not set
374# CONFIG_EXT2_FS_XIP is not set 581CONFIG_EXT4_FS=y
375CONFIG_EXT3_FS=y 582CONFIG_EXT4_USE_FOR_EXT23=y
376# CONFIG_EXT3_FS_XATTR is not set 583CONFIG_EXT4_FS_XATTR=y
377# CONFIG_EXT4DEV_FS is not set 584# CONFIG_EXT4_FS_POSIX_ACL is not set
378CONFIG_JBD=y 585# CONFIG_EXT4_FS_SECURITY is not set
586# CONFIG_EXT4_DEBUG is not set
587CONFIG_JBD2=y
588CONFIG_FS_MBCACHE=y
379CONFIG_REISERFS_FS=y 589CONFIG_REISERFS_FS=y
380# CONFIG_REISERFS_CHECK is not set 590# CONFIG_REISERFS_CHECK is not set
381# CONFIG_REISERFS_PROC_INFO is not set 591# CONFIG_REISERFS_PROC_INFO is not set
382# CONFIG_REISERFS_FS_XATTR is not set 592# CONFIG_REISERFS_FS_XATTR is not set
383# CONFIG_JFS_FS is not set 593# CONFIG_JFS_FS is not set
384# CONFIG_FS_POSIX_ACL is not set
385# CONFIG_XFS_FS is not set 594# CONFIG_XFS_FS is not set
386# CONFIG_GFS2_FS is not set 595# CONFIG_GFS2_FS is not set
387# CONFIG_OCFS2_FS is not set 596# CONFIG_BTRFS_FS is not set
388# CONFIG_MINIX_FS is not set 597# CONFIG_NILFS2_FS is not set
389# CONFIG_ROMFS_FS is not set 598# CONFIG_FS_POSIX_ACL is not set
390CONFIG_INOTIFY=y 599CONFIG_FILE_LOCKING=y
600CONFIG_FSNOTIFY=y
601CONFIG_DNOTIFY=y
391CONFIG_INOTIFY_USER=y 602CONFIG_INOTIFY_USER=y
603# CONFIG_FANOTIFY is not set
392CONFIG_QUOTA=y 604CONFIG_QUOTA=y
393# CONFIG_QUOTA_NETLINK_INTERFACE is not set 605# CONFIG_QUOTA_NETLINK_INTERFACE is not set
394CONFIG_PRINT_QUOTA_WARNING=y 606CONFIG_PRINT_QUOTA_WARNING=y
607# CONFIG_QUOTA_DEBUG is not set
395# CONFIG_QFMT_V1 is not set 608# CONFIG_QFMT_V1 is not set
396# CONFIG_QFMT_V2 is not set 609# CONFIG_QFMT_V2 is not set
397CONFIG_QUOTACTL=y 610CONFIG_QUOTACTL=y
398CONFIG_DNOTIFY=y
399CONFIG_AUTOFS_FS=m
400CONFIG_AUTOFS4_FS=m 611CONFIG_AUTOFS4_FS=m
401# CONFIG_FUSE_FS is not set 612# CONFIG_FUSE_FS is not set
402 613
403# 614#
615# Caches
616#
617# CONFIG_FSCACHE is not set
618
619#
404# CD-ROM/DVD Filesystems 620# CD-ROM/DVD Filesystems
405# 621#
406CONFIG_ISO9660_FS=m 622CONFIG_ISO9660_FS=m
@@ -421,15 +637,14 @@ CONFIG_JOLIET=y
421CONFIG_PROC_FS=y 637CONFIG_PROC_FS=y
422CONFIG_PROC_KCORE=y 638CONFIG_PROC_KCORE=y
423CONFIG_PROC_SYSCTL=y 639CONFIG_PROC_SYSCTL=y
640CONFIG_PROC_PAGE_MONITOR=y
424CONFIG_SYSFS=y 641CONFIG_SYSFS=y
425CONFIG_TMPFS=y 642CONFIG_TMPFS=y
426# CONFIG_TMPFS_POSIX_ACL is not set 643# CONFIG_TMPFS_POSIX_ACL is not set
644# CONFIG_TMPFS_XATTR is not set
427# CONFIG_HUGETLB_PAGE is not set 645# CONFIG_HUGETLB_PAGE is not set
428# CONFIG_CONFIGFS_FS is not set 646# CONFIG_CONFIGFS_FS is not set
429 647CONFIG_MISC_FILESYSTEMS=y
430#
431# Miscellaneous filesystems
432#
433# CONFIG_ADFS_FS is not set 648# CONFIG_ADFS_FS is not set
434# CONFIG_AFFS_FS is not set 649# CONFIG_AFFS_FS is not set
435# CONFIG_HFS_FS is not set 650# CONFIG_HFS_FS is not set
@@ -437,26 +652,26 @@ CONFIG_TMPFS=y
437# CONFIG_BEFS_FS is not set 652# CONFIG_BEFS_FS is not set
438# CONFIG_BFS_FS is not set 653# CONFIG_BFS_FS is not set
439# CONFIG_EFS_FS is not set 654# CONFIG_EFS_FS is not set
655# CONFIG_LOGFS is not set
440# CONFIG_CRAMFS is not set 656# CONFIG_CRAMFS is not set
657# CONFIG_SQUASHFS is not set
441# CONFIG_VXFS_FS is not set 658# CONFIG_VXFS_FS is not set
659# CONFIG_MINIX_FS is not set
660# CONFIG_OMFS_FS is not set
442# CONFIG_HPFS_FS is not set 661# CONFIG_HPFS_FS is not set
443# CONFIG_QNX4FS_FS is not set 662# CONFIG_QNX4FS_FS is not set
663# CONFIG_ROMFS_FS is not set
664# CONFIG_PSTORE is not set
444# CONFIG_SYSV_FS is not set 665# CONFIG_SYSV_FS is not set
445# CONFIG_UFS_FS is not set 666# CONFIG_UFS_FS is not set
446CONFIG_NETWORK_FILESYSTEMS=y 667CONFIG_NETWORK_FILESYSTEMS=y
447# CONFIG_NFS_FS is not set 668# CONFIG_NFS_FS is not set
448# CONFIG_NFSD is not set 669# CONFIG_NFSD is not set
449# CONFIG_SMB_FS is not set 670# CONFIG_CEPH_FS is not set
450# CONFIG_CIFS is not set 671# CONFIG_CIFS is not set
451# CONFIG_NCP_FS is not set 672# CONFIG_NCP_FS is not set
452# CONFIG_CODA_FS is not set 673# CONFIG_CODA_FS is not set
453# CONFIG_AFS_FS is not set 674# CONFIG_AFS_FS is not set
454
455#
456# Partition Types
457#
458# CONFIG_PARTITION_ADVANCED is not set
459CONFIG_MSDOS_PARTITION=y
460CONFIG_NLS=y 675CONFIG_NLS=y
461CONFIG_NLS_DEFAULT="iso8859-1" 676CONFIG_NLS_DEFAULT="iso8859-1"
462# CONFIG_NLS_CODEPAGE_437 is not set 677# CONFIG_NLS_CODEPAGE_437 is not set
@@ -497,119 +712,191 @@ CONFIG_NLS_DEFAULT="iso8859-1"
497# CONFIG_NLS_KOI8_R is not set 712# CONFIG_NLS_KOI8_R is not set
498# CONFIG_NLS_KOI8_U is not set 713# CONFIG_NLS_KOI8_U is not set
499# CONFIG_NLS_UTF8 is not set 714# CONFIG_NLS_UTF8 is not set
500# CONFIG_DLM is not set
501 715
502# 716#
503# Security options 717# Security options
504# 718#
505# CONFIG_KEYS is not set 719# CONFIG_KEYS is not set
720# CONFIG_SECURITY_DMESG_RESTRICT is not set
506# CONFIG_SECURITY is not set 721# CONFIG_SECURITY is not set
507# CONFIG_SECURITY_FILE_CAPABILITIES is not set 722# CONFIG_SECURITYFS is not set
723CONFIG_DEFAULT_SECURITY_DAC=y
724CONFIG_DEFAULT_SECURITY=""
508CONFIG_CRYPTO=y 725CONFIG_CRYPTO=y
509# CONFIG_CRYPTO_SEQIV is not set 726
727#
728# Crypto core or helper
729#
730# CONFIG_CRYPTO_FIPS is not set
731CONFIG_CRYPTO_ALGAPI=m
732CONFIG_CRYPTO_ALGAPI2=m
733CONFIG_CRYPTO_RNG=m
734CONFIG_CRYPTO_RNG2=m
510# CONFIG_CRYPTO_MANAGER is not set 735# CONFIG_CRYPTO_MANAGER is not set
736# CONFIG_CRYPTO_MANAGER2 is not set
737# CONFIG_CRYPTO_USER is not set
738# CONFIG_CRYPTO_GF128MUL is not set
739# CONFIG_CRYPTO_NULL is not set
740# CONFIG_CRYPTO_CRYPTD is not set
741# CONFIG_CRYPTO_AUTHENC is not set
742# CONFIG_CRYPTO_TEST is not set
743
744#
745# Authenticated Encryption with Associated Data
746#
747# CONFIG_CRYPTO_CCM is not set
748# CONFIG_CRYPTO_GCM is not set
749# CONFIG_CRYPTO_SEQIV is not set
750
751#
752# Block modes
753#
754# CONFIG_CRYPTO_CBC is not set
755# CONFIG_CRYPTO_CTR is not set
756# CONFIG_CRYPTO_CTS is not set
757# CONFIG_CRYPTO_ECB is not set
758# CONFIG_CRYPTO_LRW is not set
759# CONFIG_CRYPTO_PCBC is not set
760# CONFIG_CRYPTO_XTS is not set
761
762#
763# Hash modes
764#
511# CONFIG_CRYPTO_HMAC is not set 765# CONFIG_CRYPTO_HMAC is not set
512# CONFIG_CRYPTO_XCBC is not set 766# CONFIG_CRYPTO_XCBC is not set
513# CONFIG_CRYPTO_NULL is not set 767# CONFIG_CRYPTO_VMAC is not set
768
769#
770# Digest
771#
772# CONFIG_CRYPTO_CRC32C is not set
773# CONFIG_CRYPTO_GHASH is not set
514# CONFIG_CRYPTO_MD4 is not set 774# CONFIG_CRYPTO_MD4 is not set
515# CONFIG_CRYPTO_MD5 is not set 775# CONFIG_CRYPTO_MD5 is not set
776# CONFIG_CRYPTO_MICHAEL_MIC is not set
777# CONFIG_CRYPTO_RMD128 is not set
778# CONFIG_CRYPTO_RMD160 is not set
779# CONFIG_CRYPTO_RMD256 is not set
780# CONFIG_CRYPTO_RMD320 is not set
516# CONFIG_CRYPTO_SHA1 is not set 781# CONFIG_CRYPTO_SHA1 is not set
517# CONFIG_CRYPTO_SHA256 is not set 782# CONFIG_CRYPTO_SHA256 is not set
518# CONFIG_CRYPTO_SHA512 is not set 783# CONFIG_CRYPTO_SHA512 is not set
519# CONFIG_CRYPTO_WP512 is not set
520# CONFIG_CRYPTO_TGR192 is not set 784# CONFIG_CRYPTO_TGR192 is not set
521# CONFIG_CRYPTO_GF128MUL is not set 785# CONFIG_CRYPTO_WP512 is not set
522# CONFIG_CRYPTO_ECB is not set 786
523# CONFIG_CRYPTO_CBC is not set 787#
524# CONFIG_CRYPTO_PCBC is not set 788# Ciphers
525# CONFIG_CRYPTO_LRW is not set 789#
526# CONFIG_CRYPTO_XTS is not set 790CONFIG_CRYPTO_AES=m
527# CONFIG_CRYPTO_CTR is not set
528# CONFIG_CRYPTO_GCM is not set
529# CONFIG_CRYPTO_CCM is not set
530# CONFIG_CRYPTO_CRYPTD is not set
531# CONFIG_CRYPTO_DES is not set
532# CONFIG_CRYPTO_FCRYPT is not set
533# CONFIG_CRYPTO_BLOWFISH is not set
534# CONFIG_CRYPTO_TWOFISH is not set
535# CONFIG_CRYPTO_TWOFISH_586 is not set
536# CONFIG_CRYPTO_SERPENT is not set
537# CONFIG_CRYPTO_AES is not set
538# CONFIG_CRYPTO_AES_586 is not set 791# CONFIG_CRYPTO_AES_586 is not set
792# CONFIG_CRYPTO_ANUBIS is not set
793# CONFIG_CRYPTO_ARC4 is not set
794# CONFIG_CRYPTO_BLOWFISH is not set
795# CONFIG_CRYPTO_CAMELLIA is not set
539# CONFIG_CRYPTO_CAST5 is not set 796# CONFIG_CRYPTO_CAST5 is not set
540# CONFIG_CRYPTO_CAST6 is not set 797# CONFIG_CRYPTO_CAST6 is not set
541# CONFIG_CRYPTO_TEA is not set 798# CONFIG_CRYPTO_DES is not set
542# CONFIG_CRYPTO_ARC4 is not set 799# CONFIG_CRYPTO_FCRYPT is not set
543# CONFIG_CRYPTO_KHAZAD is not set 800# CONFIG_CRYPTO_KHAZAD is not set
544# CONFIG_CRYPTO_ANUBIS is not set
545# CONFIG_CRYPTO_SEED is not set
546# CONFIG_CRYPTO_SALSA20 is not set 801# CONFIG_CRYPTO_SALSA20 is not set
547# CONFIG_CRYPTO_SALSA20_586 is not set 802# CONFIG_CRYPTO_SALSA20_586 is not set
803# CONFIG_CRYPTO_SEED is not set
804# CONFIG_CRYPTO_SERPENT is not set
805# CONFIG_CRYPTO_TEA is not set
806# CONFIG_CRYPTO_TWOFISH is not set
807# CONFIG_CRYPTO_TWOFISH_586 is not set
808
809#
810# Compression
811#
548# CONFIG_CRYPTO_DEFLATE is not set 812# CONFIG_CRYPTO_DEFLATE is not set
549# CONFIG_CRYPTO_MICHAEL_MIC is not set 813# CONFIG_CRYPTO_ZLIB is not set
550# CONFIG_CRYPTO_CRC32C is not set
551# CONFIG_CRYPTO_CAMELLIA is not set
552# CONFIG_CRYPTO_TEST is not set
553# CONFIG_CRYPTO_AUTHENC is not set
554# CONFIG_CRYPTO_LZO is not set 814# CONFIG_CRYPTO_LZO is not set
815
816#
817# Random Number Generation
818#
819CONFIG_CRYPTO_ANSI_CPRNG=m
820# CONFIG_CRYPTO_USER_API_HASH is not set
821# CONFIG_CRYPTO_USER_API_SKCIPHER is not set
555CONFIG_CRYPTO_HW=y 822CONFIG_CRYPTO_HW=y
823# CONFIG_BINARY_PRINTF is not set
556 824
557# 825#
558# Library routines 826# Library routines
559# 827#
560CONFIG_BITREVERSE=m 828CONFIG_BITREVERSE=y
829CONFIG_GENERIC_FIND_FIRST_BIT=y
830CONFIG_GENERIC_IO=y
561# CONFIG_CRC_CCITT is not set 831# CONFIG_CRC_CCITT is not set
562# CONFIG_CRC16 is not set 832CONFIG_CRC16=y
833# CONFIG_CRC_T10DIF is not set
563# CONFIG_CRC_ITU_T is not set 834# CONFIG_CRC_ITU_T is not set
564CONFIG_CRC32=m 835CONFIG_CRC32=y
565# CONFIG_CRC7 is not set 836# CONFIG_CRC7 is not set
566# CONFIG_LIBCRC32C is not set 837# CONFIG_LIBCRC32C is not set
567CONFIG_PLIST=y 838# CONFIG_CRC8 is not set
568 839# CONFIG_XZ_DEC is not set
569# 840# CONFIG_XZ_DEC_BCJ is not set
570# SCSI device support 841CONFIG_DQL=y
571# 842CONFIG_NLATTR=y
572# CONFIG_RAID_ATTRS is not set 843# CONFIG_AVERAGE is not set
573# CONFIG_SCSI is not set 844# CONFIG_CORDIC is not set
574# CONFIG_SCSI_DMA is not set
575# CONFIG_SCSI_NETLINK is not set
576# CONFIG_MD is not set
577# CONFIG_INPUT is not set
578 845
579# 846#
580# Kernel hacking 847# Kernel hacking
581# 848#
582# CONFIG_PRINTK_TIME is not set 849# CONFIG_PRINTK_TIME is not set
850CONFIG_DEFAULT_MESSAGE_LOGLEVEL=4
583CONFIG_ENABLE_WARN_DEPRECATED=y 851CONFIG_ENABLE_WARN_DEPRECATED=y
584CONFIG_ENABLE_MUST_CHECK=y 852CONFIG_ENABLE_MUST_CHECK=y
853CONFIG_FRAME_WARN=1024
854# CONFIG_STRIP_ASM_SYMS is not set
585# CONFIG_UNUSED_SYMBOLS is not set 855# CONFIG_UNUSED_SYMBOLS is not set
586# CONFIG_DEBUG_FS is not set 856# CONFIG_DEBUG_FS is not set
857# CONFIG_DEBUG_SECTION_MISMATCH is not set
587CONFIG_DEBUG_KERNEL=y 858CONFIG_DEBUG_KERNEL=y
588# CONFIG_DEBUG_SHIRQ is not set 859# CONFIG_DEBUG_SHIRQ is not set
589CONFIG_DETECT_SOFTLOCKUP=y 860# CONFIG_LOCKUP_DETECTOR is not set
861# CONFIG_HARDLOCKUP_DETECTOR is not set
862# CONFIG_DETECT_HUNG_TASK is not set
590CONFIG_SCHED_DEBUG=y 863CONFIG_SCHED_DEBUG=y
591# CONFIG_SCHEDSTATS is not set 864# CONFIG_SCHEDSTATS is not set
592# CONFIG_TIMER_STATS is not set 865# CONFIG_TIMER_STATS is not set
866# CONFIG_DEBUG_OBJECTS is not set
593# CONFIG_DEBUG_SLAB is not set 867# CONFIG_DEBUG_SLAB is not set
594# CONFIG_DEBUG_RT_MUTEXES is not set 868# CONFIG_DEBUG_RT_MUTEXES is not set
595# CONFIG_RT_MUTEX_TESTER is not set 869# CONFIG_RT_MUTEX_TESTER is not set
596# CONFIG_DEBUG_SPINLOCK is not set 870# CONFIG_DEBUG_SPINLOCK is not set
597# CONFIG_DEBUG_MUTEXES is not set 871# CONFIG_DEBUG_MUTEXES is not set
598# CONFIG_DEBUG_SPINLOCK_SLEEP is not set 872# CONFIG_SPARSE_RCU_POINTER is not set
873# CONFIG_DEBUG_ATOMIC_SLEEP is not set
599# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set 874# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
875# CONFIG_DEBUG_STACK_USAGE is not set
600# CONFIG_DEBUG_KOBJECT is not set 876# CONFIG_DEBUG_KOBJECT is not set
601CONFIG_DEBUG_BUGVERBOSE=y 877CONFIG_DEBUG_BUGVERBOSE=y
602CONFIG_DEBUG_INFO=y 878CONFIG_DEBUG_INFO=y
879# CONFIG_DEBUG_INFO_REDUCED is not set
603# CONFIG_DEBUG_VM is not set 880# CONFIG_DEBUG_VM is not set
881# CONFIG_DEBUG_WRITECOUNT is not set
882CONFIG_DEBUG_MEMORY_INIT=y
604# CONFIG_DEBUG_LIST is not set 883# CONFIG_DEBUG_LIST is not set
884# CONFIG_TEST_LIST_SORT is not set
605# CONFIG_DEBUG_SG is not set 885# CONFIG_DEBUG_SG is not set
886# CONFIG_DEBUG_NOTIFIERS is not set
887# CONFIG_DEBUG_CREDENTIALS is not set
606CONFIG_FRAME_POINTER=y 888CONFIG_FRAME_POINTER=y
607CONFIG_FORCED_INLINING=y
608# CONFIG_BOOT_PRINTK_DELAY is not set 889# CONFIG_BOOT_PRINTK_DELAY is not set
609# CONFIG_RCU_TORTURE_TEST is not set 890# CONFIG_RCU_TORTURE_TEST is not set
610# CONFIG_BACKTRACE_SELF_TEST is not set 891# CONFIG_BACKTRACE_SELF_TEST is not set
892# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
893# CONFIG_DEBUG_FORCE_WEAK_PER_CPU is not set
611# CONFIG_FAULT_INJECTION is not set 894# CONFIG_FAULT_INJECTION is not set
895# CONFIG_SYSCTL_SYSCALL_CHECK is not set
896# CONFIG_DEBUG_PAGEALLOC is not set
897# CONFIG_ATOMIC64_SELFTEST is not set
612# CONFIG_SAMPLES is not set 898# CONFIG_SAMPLES is not set
899# CONFIG_TEST_KSTRTOX is not set
613# CONFIG_GPROF is not set 900# CONFIG_GPROF is not set
614# CONFIG_GCOV is not set 901# CONFIG_GCOV is not set
615# CONFIG_DEBUG_STACK_USAGE is not set 902CONFIG_EARLY_PRINTK=y
diff --git a/arch/um/drivers/chan.h b/arch/um/drivers/chan.h
index 8df0fd9024d..02b5a76e98d 100644
--- a/arch/um/drivers/chan.h
+++ b/arch/um/drivers/chan.h
@@ -27,24 +27,24 @@ struct chan {
27 void *data; 27 void *data;
28}; 28};
29 29
30extern void chan_interrupt(struct list_head *chans, struct delayed_work *task, 30extern void chan_interrupt(struct line *line,
31 struct tty_struct *tty, int irq); 31 struct tty_struct *tty, int irq);
32extern int parse_chan_pair(char *str, struct line *line, int device, 32extern int parse_chan_pair(char *str, struct line *line, int device,
33 const struct chan_opts *opts, char **error_out); 33 const struct chan_opts *opts, char **error_out);
34extern int write_chan(struct list_head *chans, const char *buf, int len, 34extern int write_chan(struct chan *chan, const char *buf, int len,
35 int write_irq); 35 int write_irq);
36extern int console_write_chan(struct list_head *chans, const char *buf, 36extern int console_write_chan(struct chan *chan, const char *buf,
37 int len); 37 int len);
38extern int console_open_chan(struct line *line, struct console *co); 38extern int console_open_chan(struct line *line, struct console *co);
39extern void deactivate_chan(struct list_head *chans, int irq); 39extern void deactivate_chan(struct chan *chan, int irq);
40extern void reactivate_chan(struct list_head *chans, int irq); 40extern void reactivate_chan(struct chan *chan, int irq);
41extern void chan_enable_winch(struct list_head *chans, struct tty_struct *tty); 41extern void chan_enable_winch(struct chan *chan, struct tty_struct *tty);
42extern int enable_chan(struct line *line); 42extern int enable_chan(struct line *line);
43extern void close_chan(struct list_head *chans, int delay_free_irq); 43extern void close_chan(struct line *line);
44extern int chan_window_size(struct list_head *chans, 44extern int chan_window_size(struct line *line,
45 unsigned short *rows_out, 45 unsigned short *rows_out,
46 unsigned short *cols_out); 46 unsigned short *cols_out);
47extern int chan_config_string(struct list_head *chans, char *str, int size, 47extern int chan_config_string(struct line *line, char *str, int size,
48 char **error_out); 48 char **error_out);
49 49
50#endif 50#endif
diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c
index 420e2c80079..ca4c7ebfd0a 100644
--- a/arch/um/drivers/chan_kern.c
+++ b/arch/um/drivers/chan_kern.c
@@ -140,18 +140,18 @@ static int open_chan(struct list_head *chans)
140 return err; 140 return err;
141} 141}
142 142
143void chan_enable_winch(struct list_head *chans, struct tty_struct *tty) 143void chan_enable_winch(struct chan *chan, struct tty_struct *tty)
144{ 144{
145 struct list_head *ele; 145 if (chan && chan->primary && chan->ops->winch)
146 struct chan *chan; 146 register_winch(chan->fd, tty);
147}
147 148
148 list_for_each(ele, chans) { 149static void line_timer_cb(struct work_struct *work)
149 chan = list_entry(ele, struct chan, list); 150{
150 if (chan->primary && chan->output && chan->ops->winch) { 151 struct line *line = container_of(work, struct line, task.work);
151 register_winch(chan->fd, tty); 152
152 return; 153 if (!line->throttled)
153 } 154 chan_interrupt(line, line->tty, line->driver->read_irq);
154 }
155} 155}
156 156
157int enable_chan(struct line *line) 157int enable_chan(struct line *line)
@@ -160,6 +160,8 @@ int enable_chan(struct line *line)
160 struct chan *chan; 160 struct chan *chan;
161 int err; 161 int err;
162 162
163 INIT_DELAYED_WORK(&line->task, line_timer_cb);
164
163 list_for_each(ele, &line->chan_list) { 165 list_for_each(ele, &line->chan_list) {
164 chan = list_entry(ele, struct chan, list); 166 chan = list_entry(ele, struct chan, list);
165 err = open_one_chan(chan); 167 err = open_one_chan(chan);
@@ -183,7 +185,7 @@ int enable_chan(struct line *line)
183 return 0; 185 return 0;
184 186
185 out_close: 187 out_close:
186 close_chan(&line->chan_list, 0); 188 close_chan(line);
187 return err; 189 return err;
188} 190}
189 191
@@ -244,7 +246,7 @@ static void close_one_chan(struct chan *chan, int delay_free_irq)
244 chan->fd = -1; 246 chan->fd = -1;
245} 247}
246 248
247void close_chan(struct list_head *chans, int delay_free_irq) 249void close_chan(struct line *line)
248{ 250{
249 struct chan *chan; 251 struct chan *chan;
250 252
@@ -253,77 +255,50 @@ void close_chan(struct list_head *chans, int delay_free_irq)
253 * state. Then, the first one opened will have the original state, 255 * state. Then, the first one opened will have the original state,
254 * so it must be the last closed. 256 * so it must be the last closed.
255 */ 257 */
256 list_for_each_entry_reverse(chan, chans, list) { 258 list_for_each_entry_reverse(chan, &line->chan_list, list) {
257 close_one_chan(chan, delay_free_irq); 259 close_one_chan(chan, 0);
258 } 260 }
259} 261}
260 262
261void deactivate_chan(struct list_head *chans, int irq) 263void deactivate_chan(struct chan *chan, int irq)
262{ 264{
263 struct list_head *ele; 265 if (chan && chan->enabled)
264 266 deactivate_fd(chan->fd, irq);
265 struct chan *chan;
266 list_for_each(ele, chans) {
267 chan = list_entry(ele, struct chan, list);
268
269 if (chan->enabled && chan->input)
270 deactivate_fd(chan->fd, irq);
271 }
272} 267}
273 268
274void reactivate_chan(struct list_head *chans, int irq) 269void reactivate_chan(struct chan *chan, int irq)
275{ 270{
276 struct list_head *ele; 271 if (chan && chan->enabled)
277 struct chan *chan; 272 reactivate_fd(chan->fd, irq);
278
279 list_for_each(ele, chans) {
280 chan = list_entry(ele, struct chan, list);
281
282 if (chan->enabled && chan->input)
283 reactivate_fd(chan->fd, irq);
284 }
285} 273}
286 274
287int write_chan(struct list_head *chans, const char *buf, int len, 275int write_chan(struct chan *chan, const char *buf, int len,
288 int write_irq) 276 int write_irq)
289{ 277{
290 struct list_head *ele;
291 struct chan *chan = NULL;
292 int n, ret = 0; 278 int n, ret = 0;
293 279
294 if (len == 0) 280 if (len == 0 || !chan || !chan->ops->write)
295 return 0; 281 return 0;
296 282
297 list_for_each(ele, chans) { 283 n = chan->ops->write(chan->fd, buf, len, chan->data);
298 chan = list_entry(ele, struct chan, list); 284 if (chan->primary) {
299 if (!chan->output || (chan->ops->write == NULL)) 285 ret = n;
300 continue; 286 if ((ret == -EAGAIN) || ((ret >= 0) && (ret < len)))
301 287 reactivate_fd(chan->fd, write_irq);
302 n = chan->ops->write(chan->fd, buf, len, chan->data);
303 if (chan->primary) {
304 ret = n;
305 if ((ret == -EAGAIN) || ((ret >= 0) && (ret < len)))
306 reactivate_fd(chan->fd, write_irq);
307 }
308 } 288 }
309 return ret; 289 return ret;
310} 290}
311 291
312int console_write_chan(struct list_head *chans, const char *buf, int len) 292int console_write_chan(struct chan *chan, const char *buf, int len)
313{ 293{
314 struct list_head *ele;
315 struct chan *chan;
316 int n, ret = 0; 294 int n, ret = 0;
317 295
318 list_for_each(ele, chans) { 296 if (!chan || !chan->ops->console_write)
319 chan = list_entry(ele, struct chan, list); 297 return 0;
320 if (!chan->output || (chan->ops->console_write == NULL))
321 continue;
322 298
323 n = chan->ops->console_write(chan->fd, buf, len); 299 n = chan->ops->console_write(chan->fd, buf, len);
324 if (chan->primary) 300 if (chan->primary)
325 ret = n; 301 ret = n;
326 }
327 return ret; 302 return ret;
328} 303}
329 304
@@ -340,20 +315,24 @@ int console_open_chan(struct line *line, struct console *co)
340 return 0; 315 return 0;
341} 316}
342 317
343int chan_window_size(struct list_head *chans, unsigned short *rows_out, 318int chan_window_size(struct line *line, unsigned short *rows_out,
344 unsigned short *cols_out) 319 unsigned short *cols_out)
345{ 320{
346 struct list_head *ele;
347 struct chan *chan; 321 struct chan *chan;
348 322
349 list_for_each(ele, chans) { 323 chan = line->chan_in;
350 chan = list_entry(ele, struct chan, list); 324 if (chan && chan->primary) {
351 if (chan->primary) { 325 if (chan->ops->window_size == NULL)
352 if (chan->ops->window_size == NULL) 326 return 0;
353 return 0; 327 return chan->ops->window_size(chan->fd, chan->data,
354 return chan->ops->window_size(chan->fd, chan->data, 328 rows_out, cols_out);
355 rows_out, cols_out); 329 }
356 } 330 chan = line->chan_out;
331 if (chan && chan->primary) {
332 if (chan->ops->window_size == NULL)
333 return 0;
334 return chan->ops->window_size(chan->fd, chan->data,
335 rows_out, cols_out);
357 } 336 }
358 return 0; 337 return 0;
359} 338}
@@ -429,21 +408,15 @@ static int chan_pair_config_string(struct chan *in, struct chan *out,
429 return n; 408 return n;
430} 409}
431 410
432int chan_config_string(struct list_head *chans, char *str, int size, 411int chan_config_string(struct line *line, char *str, int size,
433 char **error_out) 412 char **error_out)
434{ 413{
435 struct list_head *ele; 414 struct chan *in = line->chan_in, *out = line->chan_out;
436 struct chan *chan, *in = NULL, *out = NULL;
437 415
438 list_for_each(ele, chans) { 416 if (in && !in->primary)
439 chan = list_entry(ele, struct chan, list); 417 in = NULL;
440 if (!chan->primary) 418 if (out && !out->primary)
441 continue; 419 out = NULL;
442 if (chan->input)
443 in = chan;
444 if (chan->output)
445 out = chan;
446 }
447 420
448 return chan_pair_config_string(in, out, str, size, error_out); 421 return chan_pair_config_string(in, out, str, size, error_out);
449} 422}
@@ -547,10 +520,14 @@ int parse_chan_pair(char *str, struct line *line, int device,
547 char *in, *out; 520 char *in, *out;
548 521
549 if (!list_empty(chans)) { 522 if (!list_empty(chans)) {
523 line->chan_in = line->chan_out = NULL;
550 free_chan(chans); 524 free_chan(chans);
551 INIT_LIST_HEAD(chans); 525 INIT_LIST_HEAD(chans);
552 } 526 }
553 527
528 if (!str)
529 return 0;
530
554 out = strchr(str, ','); 531 out = strchr(str, ',');
555 if (out != NULL) { 532 if (out != NULL) {
556 in = str; 533 in = str;
@@ -562,6 +539,7 @@ int parse_chan_pair(char *str, struct line *line, int device,
562 539
563 new->input = 1; 540 new->input = 1;
564 list_add(&new->list, chans); 541 list_add(&new->list, chans);
542 line->chan_in = new;
565 543
566 new = parse_chan(line, out, device, opts, error_out); 544 new = parse_chan(line, out, device, opts, error_out);
567 if (new == NULL) 545 if (new == NULL)
@@ -569,6 +547,7 @@ int parse_chan_pair(char *str, struct line *line, int device,
569 547
570 list_add(&new->list, chans); 548 list_add(&new->list, chans);
571 new->output = 1; 549 new->output = 1;
550 line->chan_out = new;
572 } 551 }
573 else { 552 else {
574 new = parse_chan(line, str, device, opts, error_out); 553 new = parse_chan(line, str, device, opts, error_out);
@@ -578,43 +557,42 @@ int parse_chan_pair(char *str, struct line *line, int device,
578 list_add(&new->list, chans); 557 list_add(&new->list, chans);
579 new->input = 1; 558 new->input = 1;
580 new->output = 1; 559 new->output = 1;
560 line->chan_in = line->chan_out = new;
581 } 561 }
582 return 0; 562 return 0;
583} 563}
584 564
585void chan_interrupt(struct list_head *chans, struct delayed_work *task, 565void chan_interrupt(struct line *line, struct tty_struct *tty, int irq)
586 struct tty_struct *tty, int irq)
587{ 566{
588 struct list_head *ele, *next; 567 struct chan *chan = line->chan_in;
589 struct chan *chan;
590 int err; 568 int err;
591 char c; 569 char c;
592 570
593 list_for_each_safe(ele, next, chans) { 571 if (!chan || !chan->ops->read)
594 chan = list_entry(ele, struct chan, list); 572 goto out;
595 if (!chan->input || (chan->ops->read == NULL)) 573
596 continue; 574 do {
597 do { 575 if (tty && !tty_buffer_request_room(tty, 1)) {
598 if (tty && !tty_buffer_request_room(tty, 1)) { 576 schedule_delayed_work(&line->task, 1);
599 schedule_delayed_work(task, 1); 577 goto out;
600 goto out;
601 }
602 err = chan->ops->read(chan->fd, &c, chan->data);
603 if (err > 0)
604 tty_receive_char(tty, c);
605 } while (err > 0);
606
607 if (err == 0)
608 reactivate_fd(chan->fd, irq);
609 if (err == -EIO) {
610 if (chan->primary) {
611 if (tty != NULL)
612 tty_hangup(tty);
613 close_chan(chans, 1);
614 return;
615 }
616 else close_one_chan(chan, 1);
617 } 578 }
579 err = chan->ops->read(chan->fd, &c, chan->data);
580 if (err > 0)
581 tty_receive_char(tty, c);
582 } while (err > 0);
583
584 if (err == 0)
585 reactivate_fd(chan->fd, irq);
586 if (err == -EIO) {
587 if (chan->primary) {
588 if (tty != NULL)
589 tty_hangup(tty);
590 if (line->chan_out != chan)
591 close_one_chan(line->chan_out, 1);
592 }
593 close_one_chan(chan, 1);
594 if (chan->primary)
595 return;
618 } 596 }
619 out: 597 out:
620 if (tty) 598 if (tty)
diff --git a/arch/um/drivers/chan_user.h b/arch/um/drivers/chan_user.h
index 9b9ced85b70..6257b7a6e1a 100644
--- a/arch/um/drivers/chan_user.h
+++ b/arch/um/drivers/chan_user.h
@@ -14,8 +14,6 @@ struct chan_opts {
14 const int raw; 14 const int raw;
15}; 15};
16 16
17enum chan_init_pri { INIT_STATIC, INIT_ALL, INIT_ONE };
18
19struct chan_ops { 17struct chan_ops {
20 char *type; 18 char *type;
21 void *(*init)(char *, int, const struct chan_opts *); 19 void *(*init)(char *, int, const struct chan_opts *);
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
index c1cf2206b84..4ab0d9c0911 100644
--- a/arch/um/drivers/line.c
+++ b/arch/um/drivers/line.c
@@ -21,19 +21,10 @@ static irqreturn_t line_interrupt(int irq, void *data)
21 struct line *line = chan->line; 21 struct line *line = chan->line;
22 22
23 if (line) 23 if (line)
24 chan_interrupt(&line->chan_list, &line->task, line->tty, irq); 24 chan_interrupt(line, line->tty, irq);
25 return IRQ_HANDLED; 25 return IRQ_HANDLED;
26} 26}
27 27
28static void line_timer_cb(struct work_struct *work)
29{
30 struct line *line = container_of(work, struct line, task.work);
31
32 if (!line->throttled)
33 chan_interrupt(&line->chan_list, &line->task, line->tty,
34 line->driver->read_irq);
35}
36
37/* 28/*
38 * Returns the free space inside the ring buffer of this line. 29 * Returns the free space inside the ring buffer of this line.
39 * 30 *
@@ -145,7 +136,7 @@ static int flush_buffer(struct line *line)
145 /* line->buffer + LINE_BUFSIZE is the end of the buffer! */ 136 /* line->buffer + LINE_BUFSIZE is the end of the buffer! */
146 count = line->buffer + LINE_BUFSIZE - line->head; 137 count = line->buffer + LINE_BUFSIZE - line->head;
147 138
148 n = write_chan(&line->chan_list, line->head, count, 139 n = write_chan(line->chan_out, line->head, count,
149 line->driver->write_irq); 140 line->driver->write_irq);
150 if (n < 0) 141 if (n < 0)
151 return n; 142 return n;
@@ -162,7 +153,7 @@ static int flush_buffer(struct line *line)
162 } 153 }
163 154
164 count = line->tail - line->head; 155 count = line->tail - line->head;
165 n = write_chan(&line->chan_list, line->head, count, 156 n = write_chan(line->chan_out, line->head, count,
166 line->driver->write_irq); 157 line->driver->write_irq);
167 158
168 if (n < 0) 159 if (n < 0)
@@ -206,7 +197,7 @@ int line_write(struct tty_struct *tty, const unsigned char *buf, int len)
206 if (line->head != line->tail) 197 if (line->head != line->tail)
207 ret = buffer_data(line, buf, len); 198 ret = buffer_data(line, buf, len);
208 else { 199 else {
209 n = write_chan(&line->chan_list, buf, len, 200 n = write_chan(line->chan_out, buf, len,
210 line->driver->write_irq); 201 line->driver->write_irq);
211 if (n < 0) { 202 if (n < 0) {
212 ret = n; 203 ret = n;
@@ -318,7 +309,7 @@ void line_throttle(struct tty_struct *tty)
318{ 309{
319 struct line *line = tty->driver_data; 310 struct line *line = tty->driver_data;
320 311
321 deactivate_chan(&line->chan_list, line->driver->read_irq); 312 deactivate_chan(line->chan_in, line->driver->read_irq);
322 line->throttled = 1; 313 line->throttled = 1;
323} 314}
324 315
@@ -327,8 +318,7 @@ void line_unthrottle(struct tty_struct *tty)
327 struct line *line = tty->driver_data; 318 struct line *line = tty->driver_data;
328 319
329 line->throttled = 0; 320 line->throttled = 0;
330 chan_interrupt(&line->chan_list, &line->task, tty, 321 chan_interrupt(line, tty, line->driver->read_irq);
331 line->driver->read_irq);
332 322
333 /* 323 /*
334 * Maybe there is enough stuff pending that calling the interrupt 324 * Maybe there is enough stuff pending that calling the interrupt
@@ -336,7 +326,7 @@ void line_unthrottle(struct tty_struct *tty)
336 * again and we shouldn't turn the interrupt back on. 326 * again and we shouldn't turn the interrupt back on.
337 */ 327 */
338 if (!line->throttled) 328 if (!line->throttled)
339 reactivate_chan(&line->chan_list, line->driver->read_irq); 329 reactivate_chan(line->chan_in, line->driver->read_irq);
340} 330}
341 331
342static irqreturn_t line_write_interrupt(int irq, void *data) 332static irqreturn_t line_write_interrupt(int irq, void *data)
@@ -347,13 +337,14 @@ static irqreturn_t line_write_interrupt(int irq, void *data)
347 int err; 337 int err;
348 338
349 /* 339 /*
350 * Interrupts are disabled here because we registered the interrupt with 340 * Interrupts are disabled here because genirq keep irqs disabled when
351 * IRQF_DISABLED (see line_setup_irq). 341 * calling the action handler.
352 */ 342 */
353 343
354 spin_lock(&line->lock); 344 spin_lock(&line->lock);
355 err = flush_buffer(line); 345 err = flush_buffer(line);
356 if (err == 0) { 346 if (err == 0) {
347 spin_unlock(&line->lock);
357 return IRQ_NONE; 348 return IRQ_NONE;
358 } else if (err < 0) { 349 } else if (err < 0) {
359 line->head = line->buffer; 350 line->head = line->buffer;
@@ -371,7 +362,7 @@ static irqreturn_t line_write_interrupt(int irq, void *data)
371int line_setup_irq(int fd, int input, int output, struct line *line, void *data) 362int line_setup_irq(int fd, int input, int output, struct line *line, void *data)
372{ 363{
373 const struct line_driver *driver = line->driver; 364 const struct line_driver *driver = line->driver;
374 int err = 0, flags = IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM; 365 int err = 0, flags = IRQF_SHARED | IRQF_SAMPLE_RANDOM;
375 366
376 if (input) 367 if (input)
377 err = um_request_irq(driver->read_irq, fd, IRQ_READ, 368 err = um_request_irq(driver->read_irq, fd, IRQ_READ,
@@ -383,7 +374,6 @@ int line_setup_irq(int fd, int input, int output, struct line *line, void *data)
383 err = um_request_irq(driver->write_irq, fd, IRQ_WRITE, 374 err = um_request_irq(driver->write_irq, fd, IRQ_WRITE,
384 line_write_interrupt, flags, 375 line_write_interrupt, flags,
385 driver->write_irq_name, data); 376 driver->write_irq_name, data);
386 line->have_irq = 1;
387 return err; 377 return err;
388} 378}
389 379
@@ -409,7 +399,7 @@ int line_open(struct line *lines, struct tty_struct *tty)
409 struct line *line = &lines[tty->index]; 399 struct line *line = &lines[tty->index];
410 int err = -ENODEV; 400 int err = -ENODEV;
411 401
412 spin_lock(&line->count_lock); 402 mutex_lock(&line->count_lock);
413 if (!line->valid) 403 if (!line->valid)
414 goto out_unlock; 404 goto out_unlock;
415 405
@@ -421,25 +411,19 @@ int line_open(struct line *lines, struct tty_struct *tty)
421 tty->driver_data = line; 411 tty->driver_data = line;
422 line->tty = tty; 412 line->tty = tty;
423 413
424 spin_unlock(&line->count_lock);
425 err = enable_chan(line); 414 err = enable_chan(line);
426 if (err) /* line_close() will be called by our caller */ 415 if (err) /* line_close() will be called by our caller */
427 return err; 416 goto out_unlock;
428
429 INIT_DELAYED_WORK(&line->task, line_timer_cb);
430 417
431 if (!line->sigio) { 418 if (!line->sigio) {
432 chan_enable_winch(&line->chan_list, tty); 419 chan_enable_winch(line->chan_out, tty);
433 line->sigio = 1; 420 line->sigio = 1;
434 } 421 }
435 422
436 chan_window_size(&line->chan_list, &tty->winsize.ws_row, 423 chan_window_size(line, &tty->winsize.ws_row,
437 &tty->winsize.ws_col); 424 &tty->winsize.ws_col);
438
439 return 0;
440
441out_unlock: 425out_unlock:
442 spin_unlock(&line->count_lock); 426 mutex_unlock(&line->count_lock);
443 return err; 427 return err;
444} 428}
445 429
@@ -459,7 +443,7 @@ void line_close(struct tty_struct *tty, struct file * filp)
459 /* We ignore the error anyway! */ 443 /* We ignore the error anyway! */
460 flush_buffer(line); 444 flush_buffer(line);
461 445
462 spin_lock(&line->count_lock); 446 mutex_lock(&line->count_lock);
463 BUG_ON(!line->valid); 447 BUG_ON(!line->valid);
464 448
465 if (--line->count) 449 if (--line->count)
@@ -468,17 +452,13 @@ void line_close(struct tty_struct *tty, struct file * filp)
468 line->tty = NULL; 452 line->tty = NULL;
469 tty->driver_data = NULL; 453 tty->driver_data = NULL;
470 454
471 spin_unlock(&line->count_lock);
472
473 if (line->sigio) { 455 if (line->sigio) {
474 unregister_winch(tty); 456 unregister_winch(tty);
475 line->sigio = 0; 457 line->sigio = 0;
476 } 458 }
477 459
478 return;
479
480out_unlock: 460out_unlock:
481 spin_unlock(&line->count_lock); 461 mutex_unlock(&line->count_lock);
482} 462}
483 463
484void close_lines(struct line *lines, int nlines) 464void close_lines(struct line *lines, int nlines)
@@ -486,34 +466,60 @@ void close_lines(struct line *lines, int nlines)
486 int i; 466 int i;
487 467
488 for(i = 0; i < nlines; i++) 468 for(i = 0; i < nlines; i++)
489 close_chan(&lines[i].chan_list, 0); 469 close_chan(&lines[i]);
490} 470}
491 471
492static int setup_one_line(struct line *lines, int n, char *init, int init_prio, 472int setup_one_line(struct line *lines, int n, char *init,
493 char **error_out) 473 const struct chan_opts *opts, char **error_out)
494{ 474{
495 struct line *line = &lines[n]; 475 struct line *line = &lines[n];
476 struct tty_driver *driver = line->driver->driver;
496 int err = -EINVAL; 477 int err = -EINVAL;
497 478
498 spin_lock(&line->count_lock); 479 mutex_lock(&line->count_lock);
499 480
500 if (line->count) { 481 if (line->count) {
501 *error_out = "Device is already open"; 482 *error_out = "Device is already open";
502 goto out; 483 goto out;
503 } 484 }
504 485
505 if (line->init_pri <= init_prio) { 486 if (!strcmp(init, "none")) {
506 line->init_pri = init_prio; 487 if (line->valid) {
507 if (!strcmp(init, "none")) 488 line->valid = 0;
489 kfree(line->init_str);
490 tty_unregister_device(driver, n);
491 parse_chan_pair(NULL, line, n, opts, error_out);
492 err = 0;
493 }
494 } else {
495 char *new = kstrdup(init, GFP_KERNEL);
496 if (!new) {
497 *error_out = "Failed to allocate memory";
498 return -ENOMEM;
499 }
500 if (line->valid) {
501 tty_unregister_device(driver, n);
502 kfree(line->init_str);
503 }
504 line->init_str = new;
505 line->valid = 1;
506 err = parse_chan_pair(new, line, n, opts, error_out);
507 if (!err) {
508 struct device *d = tty_register_device(driver, n, NULL);
509 if (IS_ERR(d)) {
510 *error_out = "Failed to register device";
511 err = PTR_ERR(d);
512 parse_chan_pair(NULL, line, n, opts, error_out);
513 }
514 }
515 if (err) {
516 line->init_str = NULL;
508 line->valid = 0; 517 line->valid = 0;
509 else { 518 kfree(new);
510 line->init_str = init;
511 line->valid = 1;
512 } 519 }
513 } 520 }
514 err = 0;
515out: 521out:
516 spin_unlock(&line->count_lock); 522 mutex_unlock(&line->count_lock);
517 return err; 523 return err;
518} 524}
519 525
@@ -524,54 +530,43 @@ out:
524 * @error_out is an error string in the case of failure; 530 * @error_out is an error string in the case of failure;
525 */ 531 */
526 532
527int line_setup(struct line *lines, unsigned int num, char *init, 533int line_setup(char **conf, unsigned int num, char **def,
528 char **error_out) 534 char *init, char *name)
529{ 535{
530 int i, n, err; 536 char *error;
531 char *end;
532 537
533 if (*init == '=') { 538 if (*init == '=') {
534 /* 539 /*
535 * We said con=/ssl= instead of con#=, so we are configuring all 540 * We said con=/ssl= instead of con#=, so we are configuring all
536 * consoles at once. 541 * consoles at once.
537 */ 542 */
538 n = -1; 543 *def = init + 1;
539 } 544 } else {
540 else { 545 char *end;
541 n = simple_strtoul(init, &end, 0); 546 unsigned n = simple_strtoul(init, &end, 0);
547
542 if (*end != '=') { 548 if (*end != '=') {
543 *error_out = "Couldn't parse device number"; 549 error = "Couldn't parse device number";
544 return -EINVAL; 550 goto out;
545 } 551 }
546 init = end; 552 if (n >= num) {
547 } 553 error = "Device number out of range";
548 init++; 554 goto out;
549
550 if (n >= (signed int) num) {
551 *error_out = "Device number out of range";
552 return -EINVAL;
553 }
554 else if (n >= 0) {
555 err = setup_one_line(lines, n, init, INIT_ONE, error_out);
556 if (err)
557 return err;
558 }
559 else {
560 for(i = 0; i < num; i++) {
561 err = setup_one_line(lines, i, init, INIT_ALL,
562 error_out);
563 if (err)
564 return err;
565 } 555 }
556 conf[n] = end + 1;
566 } 557 }
567 return n == -1 ? num : n; 558 return 0;
559
560out:
561 printk(KERN_ERR "Failed to set up %s with "
562 "configuration string \"%s\" : %s\n", name, init, error);
563 return -EINVAL;
568} 564}
569 565
570int line_config(struct line *lines, unsigned int num, char *str, 566int line_config(struct line *lines, unsigned int num, char *str,
571 const struct chan_opts *opts, char **error_out) 567 const struct chan_opts *opts, char **error_out)
572{ 568{
573 struct line *line; 569 char *end;
574 char *new;
575 int n; 570 int n;
576 571
577 if (*str == '=') { 572 if (*str == '=') {
@@ -579,17 +574,17 @@ int line_config(struct line *lines, unsigned int num, char *str,
579 return -EINVAL; 574 return -EINVAL;
580 } 575 }
581 576
582 new = kstrdup(str, GFP_KERNEL); 577 n = simple_strtoul(str, &end, 0);
583 if (new == NULL) { 578 if (*end++ != '=') {
584 *error_out = "Failed to allocate memory"; 579 *error_out = "Couldn't parse device number";
585 return -ENOMEM; 580 return -EINVAL;
581 }
582 if (n >= num) {
583 *error_out = "Device number out of range";
584 return -EINVAL;
586 } 585 }
587 n = line_setup(lines, num, new, error_out);
588 if (n < 0)
589 return n;
590 586
591 line = &lines[n]; 587 return setup_one_line(lines, n, end, opts, error_out);
592 return parse_chan_pair(line->init_str, line, n, opts, error_out);
593} 588}
594 589
595int line_get_config(char *name, struct line *lines, unsigned int num, char *str, 590int line_get_config(char *name, struct line *lines, unsigned int num, char *str,
@@ -612,13 +607,13 @@ int line_get_config(char *name, struct line *lines, unsigned int num, char *str,
612 607
613 line = &lines[dev]; 608 line = &lines[dev];
614 609
615 spin_lock(&line->count_lock); 610 mutex_lock(&line->count_lock);
616 if (!line->valid) 611 if (!line->valid)
617 CONFIG_CHUNK(str, size, n, "none", 1); 612 CONFIG_CHUNK(str, size, n, "none", 1);
618 else if (line->tty == NULL) 613 else if (line->tty == NULL)
619 CONFIG_CHUNK(str, size, n, line->init_str, 1); 614 CONFIG_CHUNK(str, size, n, line->init_str, 1);
620 else n = chan_config_string(&line->chan_list, str, size, error_out); 615 else n = chan_config_string(line, str, size, error_out);
621 spin_unlock(&line->count_lock); 616 mutex_unlock(&line->count_lock);
622 617
623 return n; 618 return n;
624} 619}
@@ -640,25 +635,23 @@ int line_id(char **str, int *start_out, int *end_out)
640 635
641int line_remove(struct line *lines, unsigned int num, int n, char **error_out) 636int line_remove(struct line *lines, unsigned int num, int n, char **error_out)
642{ 637{
643 int err; 638 if (n >= num) {
644 char config[sizeof("conxxxx=none\0")]; 639 *error_out = "Device number out of range";
645 640 return -EINVAL;
646 sprintf(config, "%d=none", n); 641 }
647 err = line_setup(lines, num, config, error_out); 642 return setup_one_line(lines, n, "none", NULL, error_out);
648 if (err >= 0)
649 err = 0;
650 return err;
651} 643}
652 644
653struct tty_driver *register_lines(struct line_driver *line_driver, 645int register_lines(struct line_driver *line_driver,
654 const struct tty_operations *ops, 646 const struct tty_operations *ops,
655 struct line *lines, int nlines) 647 struct line *lines, int nlines)
656{ 648{
657 int i;
658 struct tty_driver *driver = alloc_tty_driver(nlines); 649 struct tty_driver *driver = alloc_tty_driver(nlines);
650 int err;
651 int i;
659 652
660 if (!driver) 653 if (!driver)
661 return NULL; 654 return -ENOMEM;
662 655
663 driver->driver_name = line_driver->name; 656 driver->driver_name = line_driver->name;
664 driver->name = line_driver->device_name; 657 driver->name = line_driver->device_name;
@@ -666,54 +659,33 @@ struct tty_driver *register_lines(struct line_driver *line_driver,
666 driver->minor_start = line_driver->minor_start; 659 driver->minor_start = line_driver->minor_start;
667 driver->type = line_driver->type; 660 driver->type = line_driver->type;
668 driver->subtype = line_driver->subtype; 661 driver->subtype = line_driver->subtype;
669 driver->flags = TTY_DRIVER_REAL_RAW; 662 driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
670 driver->init_termios = tty_std_termios; 663 driver->init_termios = tty_std_termios;
664
665 for (i = 0; i < nlines; i++) {
666 spin_lock_init(&lines[i].lock);
667 mutex_init(&lines[i].count_lock);
668 lines[i].driver = line_driver;
669 INIT_LIST_HEAD(&lines[i].chan_list);
670 }
671 tty_set_operations(driver, ops); 671 tty_set_operations(driver, ops);
672 672
673 if (tty_register_driver(driver)) { 673 err = tty_register_driver(driver);
674 if (err) {
674 printk(KERN_ERR "register_lines : can't register %s driver\n", 675 printk(KERN_ERR "register_lines : can't register %s driver\n",
675 line_driver->name); 676 line_driver->name);
676 put_tty_driver(driver); 677 put_tty_driver(driver);
677 return NULL; 678 return err;
678 }
679
680 for(i = 0; i < nlines; i++) {
681 if (!lines[i].valid)
682 tty_unregister_device(driver, i);
683 } 679 }
684 680
681 line_driver->driver = driver;
685 mconsole_register_dev(&line_driver->mc); 682 mconsole_register_dev(&line_driver->mc);
686 return driver; 683 return 0;
687} 684}
688 685
689static DEFINE_SPINLOCK(winch_handler_lock); 686static DEFINE_SPINLOCK(winch_handler_lock);
690static LIST_HEAD(winch_handlers); 687static LIST_HEAD(winch_handlers);
691 688
692void lines_init(struct line *lines, int nlines, struct chan_opts *opts)
693{
694 struct line *line;
695 char *error;
696 int i;
697
698 for(i = 0; i < nlines; i++) {
699 line = &lines[i];
700 INIT_LIST_HEAD(&line->chan_list);
701
702 if (line->init_str == NULL)
703 continue;
704
705 line->init_str = kstrdup(line->init_str, GFP_KERNEL);
706 if (line->init_str == NULL)
707 printk(KERN_ERR "lines_init - kstrdup returned NULL\n");
708
709 if (parse_chan_pair(line->init_str, line, i, opts, &error)) {
710 printk(KERN_ERR "parse_chan_pair failed for "
711 "device %d : %s\n", i, error);
712 line->valid = 0;
713 }
714 }
715}
716
717struct winch { 689struct winch {
718 struct list_head list; 690 struct list_head list;
719 int fd; 691 int fd;
@@ -777,7 +749,7 @@ static irqreturn_t winch_interrupt(int irq, void *data)
777 if (tty != NULL) { 749 if (tty != NULL) {
778 line = tty->driver_data; 750 line = tty->driver_data;
779 if (line != NULL) { 751 if (line != NULL) {
780 chan_window_size(&line->chan_list, &tty->winsize.ws_row, 752 chan_window_size(line, &tty->winsize.ws_row,
781 &tty->winsize.ws_col); 753 &tty->winsize.ws_col);
782 kill_pgrp(tty->pgrp, SIGWINCH, 1); 754 kill_pgrp(tty->pgrp, SIGWINCH, 1);
783 } 755 }
@@ -807,7 +779,7 @@ void register_winch_irq(int fd, int tty_fd, int pid, struct tty_struct *tty,
807 .stack = stack }); 779 .stack = stack });
808 780
809 if (um_request_irq(WINCH_IRQ, fd, IRQ_READ, winch_interrupt, 781 if (um_request_irq(WINCH_IRQ, fd, IRQ_READ, winch_interrupt,
810 IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM, 782 IRQF_SHARED | IRQF_SAMPLE_RANDOM,
811 "winch", winch) < 0) { 783 "winch", winch) < 0) {
812 printk(KERN_ERR "register_winch_irq - failed to register " 784 printk(KERN_ERR "register_winch_irq - failed to register "
813 "IRQ\n"); 785 "IRQ\n");
diff --git a/arch/um/drivers/line.h b/arch/um/drivers/line.h
index 63df3ca02ac..0a1834719db 100644
--- a/arch/um/drivers/line.h
+++ b/arch/um/drivers/line.h
@@ -15,7 +15,7 @@
15#include "chan_user.h" 15#include "chan_user.h"
16#include "mconsole_kern.h" 16#include "mconsole_kern.h"
17 17
18/* There's only one modifiable field in this - .mc.list */ 18/* There's only two modifiable fields in this - .mc.list and .driver */
19struct line_driver { 19struct line_driver {
20 const char *name; 20 const char *name;
21 const char *device_name; 21 const char *device_name;
@@ -28,17 +28,18 @@ struct line_driver {
28 const int write_irq; 28 const int write_irq;
29 const char *write_irq_name; 29 const char *write_irq_name;
30 struct mc_device mc; 30 struct mc_device mc;
31 struct tty_driver *driver;
31}; 32};
32 33
33struct line { 34struct line {
34 struct tty_struct *tty; 35 struct tty_struct *tty;
35 spinlock_t count_lock; 36 struct mutex count_lock;
36 unsigned long count; 37 unsigned long count;
37 int valid; 38 int valid;
38 39
39 char *init_str; 40 char *init_str;
40 int init_pri;
41 struct list_head chan_list; 41 struct list_head chan_list;
42 struct chan *chan_in, *chan_out;
42 43
43 /*This lock is actually, mostly, local to*/ 44 /*This lock is actually, mostly, local to*/
44 spinlock_t lock; 45 spinlock_t lock;
@@ -55,21 +56,12 @@ struct line {
55 int sigio; 56 int sigio;
56 struct delayed_work task; 57 struct delayed_work task;
57 const struct line_driver *driver; 58 const struct line_driver *driver;
58 int have_irq;
59}; 59};
60 60
61#define LINE_INIT(str, d) \
62 { .count_lock = __SPIN_LOCK_UNLOCKED((str).count_lock), \
63 .init_str = str, \
64 .init_pri = INIT_STATIC, \
65 .valid = 1, \
66 .lock = __SPIN_LOCK_UNLOCKED((str).lock), \
67 .driver = d }
68
69extern void line_close(struct tty_struct *tty, struct file * filp); 61extern void line_close(struct tty_struct *tty, struct file * filp);
70extern int line_open(struct line *lines, struct tty_struct *tty); 62extern int line_open(struct line *lines, struct tty_struct *tty);
71extern int line_setup(struct line *lines, unsigned int sizeof_lines, 63extern int line_setup(char **conf, unsigned nlines, char **def,
72 char *init, char **error_out); 64 char *init, char *name);
73extern int line_write(struct tty_struct *tty, const unsigned char *buf, 65extern int line_write(struct tty_struct *tty, const unsigned char *buf,
74 int len); 66 int len);
75extern int line_put_char(struct tty_struct *tty, unsigned char ch); 67extern int line_put_char(struct tty_struct *tty, unsigned char ch);
@@ -87,10 +79,11 @@ extern char *add_xterm_umid(char *base);
87extern int line_setup_irq(int fd, int input, int output, struct line *line, 79extern int line_setup_irq(int fd, int input, int output, struct line *line,
88 void *data); 80 void *data);
89extern void line_close_chan(struct line *line); 81extern void line_close_chan(struct line *line);
90extern struct tty_driver *register_lines(struct line_driver *line_driver, 82extern int register_lines(struct line_driver *line_driver,
91 const struct tty_operations *driver, 83 const struct tty_operations *driver,
92 struct line *lines, int nlines); 84 struct line *lines, int nlines);
93extern void lines_init(struct line *lines, int nlines, struct chan_opts *opts); 85extern int setup_one_line(struct line *lines, int n, char *init,
86 const struct chan_opts *opts, char **error_out);
94extern void close_lines(struct line *lines, int nlines); 87extern void close_lines(struct line *lines, int nlines);
95 88
96extern int line_config(struct line *lines, unsigned int sizeof_lines, 89extern int line_config(struct line *lines, unsigned int sizeof_lines,
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index c70e047eed7..e672bd6d43e 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -773,7 +773,7 @@ static int __init mconsole_init(void)
773 register_reboot_notifier(&reboot_notifier); 773 register_reboot_notifier(&reboot_notifier);
774 774
775 err = um_request_irq(MCONSOLE_IRQ, sock, IRQ_READ, mconsole_interrupt, 775 err = um_request_irq(MCONSOLE_IRQ, sock, IRQ_READ, mconsole_interrupt,
776 IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM, 776 IRQF_SHARED | IRQF_SAMPLE_RANDOM,
777 "mconsole", (void *)sock); 777 "mconsole", (void *)sock);
778 if (err) { 778 if (err) {
779 printk(KERN_ERR "Failed to get IRQ for management console\n"); 779 printk(KERN_ERR "Failed to get IRQ for management console\n");
diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c
index d2996183e58..95f4416e6d9 100644
--- a/arch/um/drivers/net_kern.c
+++ b/arch/um/drivers/net_kern.c
@@ -161,7 +161,7 @@ static int uml_net_open(struct net_device *dev)
161 } 161 }
162 162
163 err = um_request_irq(dev->irq, lp->fd, IRQ_READ, uml_net_interrupt, 163 err = um_request_irq(dev->irq, lp->fd, IRQ_READ, uml_net_interrupt,
164 IRQF_DISABLED | IRQF_SHARED, dev->name, dev); 164 IRQF_SHARED, dev->name, dev);
165 if (err != 0) { 165 if (err != 0) {
166 printk(KERN_ERR "uml_net_open: failed to get irq(%d)\n", err); 166 printk(KERN_ERR "uml_net_open: failed to get irq(%d)\n", err);
167 err = -ENETUNREACH; 167 err = -ENETUNREACH;
diff --git a/arch/um/drivers/port_kern.c b/arch/um/drivers/port_kern.c
index a11573be096..e31680e662a 100644
--- a/arch/um/drivers/port_kern.c
+++ b/arch/um/drivers/port_kern.c
@@ -100,7 +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_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM, 103 IRQF_SHARED | IRQF_SAMPLE_RANDOM,
104 "telnetd", conn)) { 104 "telnetd", conn)) {
105 printk(KERN_ERR "port_accept : failed to get IRQ for " 105 printk(KERN_ERR "port_accept : failed to get IRQ for "
106 "telnetd\n"); 106 "telnetd\n");
@@ -184,7 +184,7 @@ void *port_data(int port_num)
184 } 184 }
185 185
186 if (um_request_irq(ACCEPT_IRQ, fd, IRQ_READ, port_interrupt, 186 if (um_request_irq(ACCEPT_IRQ, fd, IRQ_READ, port_interrupt,
187 IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM, 187 IRQF_SHARED | IRQF_SAMPLE_RANDOM,
188 "port", port)) { 188 "port", port)) {
189 printk(KERN_ERR "Failed to get IRQ for port %d\n", port_num); 189 printk(KERN_ERR "Failed to get IRQ for port %d\n", port_num);
190 goto out_close; 190 goto out_close;
diff --git a/arch/um/drivers/random.c b/arch/um/drivers/random.c
index 981085a93f3..b25296e6218 100644
--- a/arch/um/drivers/random.c
+++ b/arch/um/drivers/random.c
@@ -131,7 +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_DISABLED | IRQF_SAMPLE_RANDOM, "random", 134 IRQF_SAMPLE_RANDOM, "random",
135 NULL); 135 NULL);
136 if (err) 136 if (err)
137 goto err_out_cleanup_hw; 137 goto err_out_cleanup_hw;
diff --git a/arch/um/drivers/ssl.c b/arch/um/drivers/ssl.c
index 9d8c20af6f8..e09801a1327 100644
--- a/arch/um/drivers/ssl.c
+++ b/arch/um/drivers/ssl.c
@@ -20,12 +20,6 @@
20 20
21static const int ssl_version = 1; 21static const int ssl_version = 1;
22 22
23/* Referenced only by tty_driver below - presumably it's locked correctly
24 * by the tty driver.
25 */
26
27static struct tty_driver *ssl_driver;
28
29#define NR_PORTS 64 23#define NR_PORTS 64
30 24
31static void ssl_announce(char *dev_name, int dev) 25static void ssl_announce(char *dev_name, int dev)
@@ -71,8 +65,9 @@ static struct line_driver driver = {
71/* The array is initialized by line_init, at initcall time. The 65/* The array is initialized by line_init, at initcall time. The
72 * elements are locked individually as needed. 66 * elements are locked individually as needed.
73 */ 67 */
74static struct line serial_lines[NR_PORTS] = 68static char *conf[NR_PORTS];
75 { [0 ... NR_PORTS - 1] = LINE_INIT(CONFIG_SSL_CHAN, &driver) }; 69static char *def_conf = CONFIG_SSL_CHAN;
70static struct line serial_lines[NR_PORTS];
76 71
77static int ssl_config(char *str, char **error_out) 72static int ssl_config(char *str, char **error_out)
78{ 73{
@@ -156,14 +151,14 @@ static void ssl_console_write(struct console *c, const char *string,
156 unsigned long flags; 151 unsigned long flags;
157 152
158 spin_lock_irqsave(&line->lock, flags); 153 spin_lock_irqsave(&line->lock, flags);
159 console_write_chan(&line->chan_list, string, len); 154 console_write_chan(line->chan_out, string, len);
160 spin_unlock_irqrestore(&line->lock, flags); 155 spin_unlock_irqrestore(&line->lock, flags);
161} 156}
162 157
163static struct tty_driver *ssl_console_device(struct console *c, int *index) 158static struct tty_driver *ssl_console_device(struct console *c, int *index)
164{ 159{
165 *index = c->index; 160 *index = c->index;
166 return ssl_driver; 161 return driver.driver;
167} 162}
168 163
169static int ssl_console_setup(struct console *co, char *options) 164static int ssl_console_setup(struct console *co, char *options)
@@ -186,17 +181,30 @@ static struct console ssl_cons = {
186static int ssl_init(void) 181static int ssl_init(void)
187{ 182{
188 char *new_title; 183 char *new_title;
184 int err;
185 int i;
189 186
190 printk(KERN_INFO "Initializing software serial port version %d\n", 187 printk(KERN_INFO "Initializing software serial port version %d\n",
191 ssl_version); 188 ssl_version);
192 ssl_driver = register_lines(&driver, &ssl_ops, serial_lines, 189
190 err = register_lines(&driver, &ssl_ops, serial_lines,
193 ARRAY_SIZE(serial_lines)); 191 ARRAY_SIZE(serial_lines));
192 if (err)
193 return err;
194 194
195 new_title = add_xterm_umid(opts.xterm_title); 195 new_title = add_xterm_umid(opts.xterm_title);
196 if (new_title != NULL) 196 if (new_title != NULL)
197 opts.xterm_title = new_title; 197 opts.xterm_title = new_title;
198 198
199 lines_init(serial_lines, ARRAY_SIZE(serial_lines), &opts); 199 for (i = 0; i < NR_PORTS; i++) {
200 char *error;
201 char *s = conf[i];
202 if (!s)
203 s = def_conf;
204 if (setup_one_line(serial_lines, i, s, &opts, &error))
205 printk(KERN_ERR "setup_one_line failed for "
206 "device %d : %s\n", i, error);
207 }
200 208
201 ssl_init_done = 1; 209 ssl_init_done = 1;
202 register_console(&ssl_cons); 210 register_console(&ssl_cons);
@@ -214,14 +222,7 @@ __uml_exitcall(ssl_exit);
214 222
215static int ssl_chan_setup(char *str) 223static int ssl_chan_setup(char *str)
216{ 224{
217 char *error; 225 line_setup(conf, NR_PORTS, &def_conf, str, "serial line");
218 int ret;
219
220 ret = line_setup(serial_lines, ARRAY_SIZE(serial_lines), str, &error);
221 if(ret < 0)
222 printk(KERN_ERR "Failed to set up serial line with "
223 "configuration string \"%s\" : %s\n", str, error);
224
225 return 1; 226 return 1;
226} 227}
227 228
diff --git a/arch/um/drivers/stdio_console.c b/arch/um/drivers/stdio_console.c
index 088776f0190..7663541c372 100644
--- a/arch/um/drivers/stdio_console.c
+++ b/arch/um/drivers/stdio_console.c
@@ -27,12 +27,6 @@
27 27
28#define MAX_TTYS (16) 28#define MAX_TTYS (16)
29 29
30/* Referenced only by tty_driver below - presumably it's locked correctly
31 * by the tty driver.
32 */
33
34static struct tty_driver *console_driver;
35
36static void stdio_announce(char *dev_name, int dev) 30static void stdio_announce(char *dev_name, int dev)
37{ 31{
38 printk(KERN_INFO "Virtual console %d assigned device '%s'\n", dev, 32 printk(KERN_INFO "Virtual console %d assigned device '%s'\n", dev,
@@ -76,9 +70,9 @@ static struct line_driver driver = {
76/* The array is initialized by line_init, at initcall time. The 70/* The array is initialized by line_init, at initcall time. The
77 * elements are locked individually as needed. 71 * elements are locked individually as needed.
78 */ 72 */
79static struct line vts[MAX_TTYS] = { LINE_INIT(CONFIG_CON_ZERO_CHAN, &driver), 73static char *vt_conf[MAX_TTYS];
80 [ 1 ... MAX_TTYS - 1 ] = 74static char *def_conf;
81 LINE_INIT(CONFIG_CON_CHAN, &driver) }; 75static struct line vts[MAX_TTYS];
82 76
83static int con_config(char *str, char **error_out) 77static int con_config(char *str, char **error_out)
84{ 78{
@@ -130,14 +124,14 @@ static void uml_console_write(struct console *console, const char *string,
130 unsigned long flags; 124 unsigned long flags;
131 125
132 spin_lock_irqsave(&line->lock, flags); 126 spin_lock_irqsave(&line->lock, flags);
133 console_write_chan(&line->chan_list, string, len); 127 console_write_chan(line->chan_out, string, len);
134 spin_unlock_irqrestore(&line->lock, flags); 128 spin_unlock_irqrestore(&line->lock, flags);
135} 129}
136 130
137static struct tty_driver *uml_console_device(struct console *c, int *index) 131static struct tty_driver *uml_console_device(struct console *c, int *index)
138{ 132{
139 *index = c->index; 133 *index = c->index;
140 return console_driver; 134 return driver.driver;
141} 135}
142 136
143static int uml_console_setup(struct console *co, char *options) 137static int uml_console_setup(struct console *co, char *options)
@@ -160,18 +154,31 @@ static struct console stdiocons = {
160static int stdio_init(void) 154static int stdio_init(void)
161{ 155{
162 char *new_title; 156 char *new_title;
157 int err;
158 int i;
163 159
164 console_driver = register_lines(&driver, &console_ops, vts, 160 err = register_lines(&driver, &console_ops, vts,
165 ARRAY_SIZE(vts)); 161 ARRAY_SIZE(vts));
166 if (console_driver == NULL) 162 if (err)
167 return -1; 163 return err;
164
168 printk(KERN_INFO "Initialized stdio console driver\n"); 165 printk(KERN_INFO "Initialized stdio console driver\n");
169 166
170 new_title = add_xterm_umid(opts.xterm_title); 167 new_title = add_xterm_umid(opts.xterm_title);
171 if(new_title != NULL) 168 if(new_title != NULL)
172 opts.xterm_title = new_title; 169 opts.xterm_title = new_title;
173 170
174 lines_init(vts, ARRAY_SIZE(vts), &opts); 171 for (i = 0; i < MAX_TTYS; i++) {
172 char *error;
173 char *s = vt_conf[i];
174 if (!s)
175 s = def_conf;
176 if (!s)
177 s = i ? CONFIG_CON_CHAN : CONFIG_CON_ZERO_CHAN;
178 if (setup_one_line(vts, i, s, &opts, &error))
179 printk(KERN_ERR "setup_one_line failed for "
180 "device %d : %s\n", i, error);
181 }
175 182
176 con_init_done = 1; 183 con_init_done = 1;
177 register_console(&stdiocons); 184 register_console(&stdiocons);
@@ -189,14 +196,7 @@ __uml_exitcall(console_exit);
189 196
190static int console_chan_setup(char *str) 197static int console_chan_setup(char *str)
191{ 198{
192 char *error; 199 line_setup(vt_conf, MAX_TTYS, &def_conf, str, "console");
193 int ret;
194
195 ret = line_setup(vts, ARRAY_SIZE(vts), str, &error);
196 if(ret < 0)
197 printk(KERN_ERR "Failed to set up console with "
198 "configuration string \"%s\" : %s\n", str, error);
199
200 return 1; 200 return 1;
201} 201}
202__setup("con", console_chan_setup); 202__setup("con", console_chan_setup);
diff --git a/arch/um/drivers/ubd_user.h b/arch/um/drivers/ubd.h
index 3845051f1b1..3845051f1b1 100644
--- a/arch/um/drivers/ubd_user.h
+++ b/arch/um/drivers/ubd.h
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 944453a3ec9..20505cafa29 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -19,40 +19,26 @@
19 19
20#define UBD_SHIFT 4 20#define UBD_SHIFT 4
21 21
22#include "linux/kernel.h" 22#include <linux/module.h>
23#include "linux/module.h" 23#include <linux/init.h>
24#include "linux/blkdev.h" 24#include <linux/blkdev.h>
25#include "linux/ata.h" 25#include <linux/ata.h>
26#include "linux/hdreg.h" 26#include <linux/hdreg.h>
27#include "linux/init.h" 27#include <linux/cdrom.h>
28#include "linux/cdrom.h" 28#include <linux/proc_fs.h>
29#include "linux/proc_fs.h" 29#include <linux/seq_file.h>
30#include "linux/seq_file.h" 30#include <linux/ctype.h>
31#include "linux/ctype.h" 31#include <linux/slab.h>
32#include "linux/capability.h" 32#include <linux/vmalloc.h>
33#include "linux/mm.h" 33#include <linux/platform_device.h>
34#include "linux/slab.h" 34#include <linux/scatterlist.h>
35#include "linux/vmalloc.h" 35#include <asm/tlbflush.h>
36#include "linux/mutex.h"
37#include "linux/blkpg.h"
38#include "linux/genhd.h"
39#include "linux/spinlock.h"
40#include "linux/platform_device.h"
41#include "linux/scatterlist.h"
42#include "asm/segment.h"
43#include "asm/uaccess.h"
44#include "asm/irq.h"
45#include "asm/types.h"
46#include "asm/tlbflush.h"
47#include "mem_user.h"
48#include "kern_util.h" 36#include "kern_util.h"
49#include "mconsole_kern.h" 37#include "mconsole_kern.h"
50#include "init.h" 38#include "init.h"
51#include "irq_user.h"
52#include "irq_kern.h" 39#include "irq_kern.h"
53#include "ubd_user.h" 40#include "ubd.h"
54#include "os.h" 41#include "os.h"
55#include "mem.h"
56#include "cow.h" 42#include "cow.h"
57 43
58enum ubd_req { UBD_READ, UBD_WRITE }; 44enum ubd_req { UBD_READ, UBD_WRITE };
@@ -1115,7 +1101,7 @@ static int __init ubd_driver_init(void){
1115 return 0; 1101 return 0;
1116 } 1102 }
1117 err = um_request_irq(UBD_IRQ, thread_fd, IRQ_READ, ubd_intr, 1103 err = um_request_irq(UBD_IRQ, thread_fd, IRQ_READ, ubd_intr,
1118 IRQF_DISABLED, "ubd", ubd_devs); 1104 0, "ubd", ubd_devs);
1119 if(err != 0) 1105 if(err != 0)
1120 printk(KERN_ERR "um_request_irq failed - errno = %d\n", -err); 1106 printk(KERN_ERR "um_request_irq failed - errno = %d\n", -err);
1121 return 0; 1107 return 0;
diff --git a/arch/um/drivers/ubd_user.c b/arch/um/drivers/ubd_user.c
index 007b94d9772..ffe02c431de 100644
--- a/arch/um/drivers/ubd_user.c
+++ b/arch/um/drivers/ubd_user.c
@@ -15,14 +15,12 @@
15#include <sys/socket.h> 15#include <sys/socket.h>
16#include <sys/mman.h> 16#include <sys/mman.h>
17#include <sys/param.h> 17#include <sys/param.h>
18#include "asm/types.h"
19#include "ubd_user.h"
20#include "os.h"
21#include "cow.h"
22
23#include <endian.h> 18#include <endian.h>
24#include <byteswap.h> 19#include <byteswap.h>
25 20
21#include "ubd.h"
22#include "os.h"
23
26void ignore_sigwinch_sig(void) 24void ignore_sigwinch_sig(void)
27{ 25{
28 signal(SIGWINCH, SIG_IGN); 26 signal(SIGWINCH, SIG_IGN);
diff --git a/arch/um/drivers/xterm_kern.c b/arch/um/drivers/xterm_kern.c
index b646bccef37..8bd130f0bda 100644
--- a/arch/um/drivers/xterm_kern.c
+++ b/arch/um/drivers/xterm_kern.c
@@ -50,7 +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_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM, 53 IRQF_SHARED | IRQF_SAMPLE_RANDOM,
54 "xterm", data); 54 "xterm", data);
55 if (err) { 55 if (err) {
56 printk(KERN_ERR "xterm_fd : failed to get IRQ for xterm, " 56 printk(KERN_ERR "xterm_fd : failed to get IRQ for xterm, "
diff --git a/arch/um/include/asm/Kbuild b/arch/um/include/asm/Kbuild
index 451f4517b33..8419f5cf2ac 100644
--- a/arch/um/include/asm/Kbuild
+++ b/arch/um/include/asm/Kbuild
@@ -1,3 +1,3 @@
1generic-y += bug.h cputime.h device.h emergency-restart.h futex.h hardirq.h 1generic-y += bug.h cputime.h device.h emergency-restart.h futex.h hardirq.h
2generic-y += hw_irq.h irq_regs.h kdebug.h percpu.h sections.h topology.h xor.h 2generic-y += hw_irq.h irq_regs.h kdebug.h percpu.h sections.h topology.h xor.h
3generic-y += ftrace.h 3generic-y += ftrace.h pci.h io.h param.h delay.h mutex.h current.h
diff --git a/arch/um/include/asm/asm-offsets.h b/arch/um/include/asm/asm-offsets.h
deleted file mode 100644
index d370ee36a18..00000000000
--- a/arch/um/include/asm/asm-offsets.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <generated/asm-offsets.h>
diff --git a/arch/um/include/asm/auxvec.h b/arch/um/include/asm/auxvec.h
deleted file mode 100644
index 1e5e1c2fc9b..00000000000
--- a/arch/um/include/asm/auxvec.h
+++ /dev/null
@@ -1,4 +0,0 @@
1#ifndef __UM_AUXVEC_H
2#define __UM_AUXVEC_H
3
4#endif
diff --git a/arch/um/include/asm/current.h b/arch/um/include/asm/current.h
deleted file mode 100644
index c2191d9aa03..00000000000
--- a/arch/um/include/asm/current.h
+++ /dev/null
@@ -1,13 +0,0 @@
1/*
2 * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL
4 */
5
6#ifndef __UM_CURRENT_H
7#define __UM_CURRENT_H
8
9#include "linux/thread_info.h"
10
11#define current (current_thread_info()->task)
12
13#endif
diff --git a/arch/um/include/asm/delay.h b/arch/um/include/asm/delay.h
deleted file mode 100644
index 8a5576d8eda..00000000000
--- a/arch/um/include/asm/delay.h
+++ /dev/null
@@ -1,18 +0,0 @@
1#ifndef __UM_DELAY_H
2#define __UM_DELAY_H
3
4/* Undefined on purpose */
5extern void __bad_udelay(void);
6extern void __bad_ndelay(void);
7
8extern void __udelay(unsigned long usecs);
9extern void __ndelay(unsigned long usecs);
10extern void __delay(unsigned long loops);
11
12#define udelay(n) ((__builtin_constant_p(n) && (n) > 20000) ? \
13 __bad_udelay() : __udelay(n))
14
15#define ndelay(n) ((__builtin_constant_p(n) && (n) > 20000) ? \
16 __bad_ndelay() : __ndelay(n))
17
18#endif
diff --git a/arch/um/include/asm/io.h b/arch/um/include/asm/io.h
deleted file mode 100644
index 44e8b8c772a..00000000000
--- a/arch/um/include/asm/io.h
+++ /dev/null
@@ -1,57 +0,0 @@
1#ifndef __UM_IO_H
2#define __UM_IO_H
3
4#include "asm/page.h"
5
6#define IO_SPACE_LIMIT 0xdeadbeef /* Sure hope nothing uses this */
7
8static inline int inb(unsigned long i) { return(0); }
9static inline void outb(char c, unsigned long i) { }
10
11/*
12 * Change virtual addresses to physical addresses and vv.
13 * These are pretty trivial
14 */
15static inline unsigned long virt_to_phys(volatile void * address)
16{
17 return __pa((void *) address);
18}
19
20static inline void * phys_to_virt(unsigned long address)
21{
22 return __va(address);
23}
24
25/*
26 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
27 * access
28 */
29#define xlate_dev_mem_ptr(p) __va(p)
30
31/*
32 * Convert a virtual cached pointer to an uncached pointer
33 */
34#define xlate_dev_kmem_ptr(p) p
35
36static inline void writeb(unsigned char b, volatile void __iomem *addr)
37{
38 *(volatile unsigned char __force *) addr = b;
39}
40static inline void writew(unsigned short b, volatile void __iomem *addr)
41{
42 *(volatile unsigned short __force *) addr = b;
43}
44static inline void writel(unsigned int b, volatile void __iomem *addr)
45{
46 *(volatile unsigned int __force *) addr = b;
47}
48static inline void writeq(unsigned int b, volatile void __iomem *addr)
49{
50 *(volatile unsigned long long __force *) addr = b;
51}
52#define __raw_writeb writeb
53#define __raw_writew writew
54#define __raw_writel writel
55#define __raw_writeq writeq
56
57#endif
diff --git a/arch/um/include/asm/mutex.h b/arch/um/include/asm/mutex.h
deleted file mode 100644
index 458c1f7fbc1..00000000000
--- a/arch/um/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/um/include/asm/param.h b/arch/um/include/asm/param.h
deleted file mode 100644
index e44f4e60d16..00000000000
--- a/arch/um/include/asm/param.h
+++ /dev/null
@@ -1,20 +0,0 @@
1#ifndef _UM_PARAM_H
2#define _UM_PARAM_H
3
4#define EXEC_PAGESIZE 4096
5
6#ifndef NOGROUP
7#define NOGROUP (-1)
8#endif
9
10#define MAXHOSTNAMELEN 64 /* max length of hostname */
11
12#ifdef __KERNEL__
13#define HZ CONFIG_HZ
14#define USER_HZ 100 /* .. some user interfaces are in "ticks" */
15#define CLOCKS_PER_SEC (USER_HZ) /* frequency at which times() counts */
16#else
17#define HZ 100
18#endif
19
20#endif
diff --git a/arch/um/include/asm/pci.h b/arch/um/include/asm/pci.h
deleted file mode 100644
index b44cf59ede1..00000000000
--- a/arch/um/include/asm/pci.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __UM_PCI_H
2#define __UM_PCI_H
3
4#define PCI_DMA_BUS_IS_PHYS (1)
5
6#endif
diff --git a/arch/um/include/asm/pgalloc.h b/arch/um/include/asm/pgalloc.h
index 32c8ce4e151..bf90b2aa200 100644
--- a/arch/um/include/asm/pgalloc.h
+++ b/arch/um/include/asm/pgalloc.h
@@ -8,8 +8,7 @@
8#ifndef __UM_PGALLOC_H 8#ifndef __UM_PGALLOC_H
9#define __UM_PGALLOC_H 9#define __UM_PGALLOC_H
10 10
11#include "linux/mm.h" 11#include <linux/mm.h>
12#include "asm/fixmap.h"
13 12
14#define pmd_populate_kernel(mm, pmd, pte) \ 13#define pmd_populate_kernel(mm, pmd, pte) \
15 set_pmd(pmd, __pmd(_PAGE_TABLE + (unsigned long) __pa(pte))) 14 set_pmd(pmd, __pmd(_PAGE_TABLE + (unsigned long) __pa(pte)))
diff --git a/arch/um/include/asm/pgtable.h b/arch/um/include/asm/pgtable.h
index 41474fb5eee..6a3f9845743 100644
--- a/arch/um/include/asm/pgtable.h
+++ b/arch/um/include/asm/pgtable.h
@@ -69,6 +69,8 @@ extern unsigned long end_iomem;
69#define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED) 69#define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED)
70#define PAGE_KERNEL_EXEC __pgprot(__PAGE_KERNEL_EXEC) 70#define PAGE_KERNEL_EXEC __pgprot(__PAGE_KERNEL_EXEC)
71 71
72#define io_remap_pfn_range remap_pfn_range
73
72/* 74/*
73 * The i386 can't do page protection for execute, and considers that the same 75 * The i386 can't do page protection for execute, and considers that the same
74 * are read. 76 * are read.
diff --git a/arch/um/include/asm/ptrace-generic.h b/arch/um/include/asm/ptrace-generic.h
index f605d3c4844..e786a6a3ec5 100644
--- a/arch/um/include/asm/ptrace-generic.h
+++ b/arch/um/include/asm/ptrace-generic.h
@@ -9,7 +9,6 @@
9#ifndef __ASSEMBLY__ 9#ifndef __ASSEMBLY__
10 10
11#include <asm/ptrace-abi.h> 11#include <asm/ptrace-abi.h>
12#include <asm/user.h>
13#include "sysdep/ptrace.h" 12#include "sysdep/ptrace.h"
14 13
15struct pt_regs { 14struct pt_regs {
diff --git a/arch/um/include/shared/common-offsets.h b/arch/um/include/shared/common-offsets.h
index d7fe563aa7e..40db8f71dea 100644
--- a/arch/um/include/shared/common-offsets.h
+++ b/arch/um/include/shared/common-offsets.h
@@ -2,8 +2,6 @@
2 2
3DEFINE(KERNEL_MADV_REMOVE, MADV_REMOVE); 3DEFINE(KERNEL_MADV_REMOVE, MADV_REMOVE);
4 4
5OFFSET(HOST_TASK_PID, task_struct, pid);
6
7DEFINE(UM_KERN_PAGE_SIZE, PAGE_SIZE); 5DEFINE(UM_KERN_PAGE_SIZE, PAGE_SIZE);
8DEFINE(UM_KERN_PAGE_MASK, PAGE_MASK); 6DEFINE(UM_KERN_PAGE_MASK, PAGE_MASK);
9DEFINE(UM_KERN_PAGE_SHIFT, PAGE_SHIFT); 7DEFINE(UM_KERN_PAGE_SHIFT, PAGE_SHIFT);
diff --git a/arch/um/include/shared/kern_util.h b/arch/um/include/shared/kern_util.h
index 0f148385246..00965d06d2c 100644
--- a/arch/um/include/shared/kern_util.h
+++ b/arch/um/include/shared/kern_util.h
@@ -48,7 +48,7 @@ extern void do_uml_exitcalls(void);
48 * GFP_ATOMIC. 48 * GFP_ATOMIC.
49 */ 49 */
50extern int __cant_sleep(void); 50extern int __cant_sleep(void);
51extern void *get_current(void); 51extern int get_current_pid(void);
52extern int copy_from_user_proc(void *to, void *from, int size); 52extern int copy_from_user_proc(void *to, void *from, int size);
53extern int cpu(void); 53extern int cpu(void);
54extern char *uml_strdup(const char *string); 54extern char *uml_strdup(const char *string);
diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile
index bc494741b1f..492bc4c1b62 100644
--- a/arch/um/kernel/Makefile
+++ b/arch/um/kernel/Makefile
@@ -3,7 +3,7 @@
3# Licensed under the GPL 3# Licensed under the GPL
4# 4#
5 5
6CPPFLAGS_vmlinux.lds := -U$(SUBARCH) -DSTART=$(LDS_START) \ 6CPPFLAGS_vmlinux.lds := -DSTART=$(LDS_START) \
7 -DELF_ARCH=$(LDS_ELF_ARCH) \ 7 -DELF_ARCH=$(LDS_ELF_ARCH) \
8 -DELF_FORMAT=$(LDS_ELF_FORMAT) 8 -DELF_FORMAT=$(LDS_ELF_FORMAT)
9extra-y := vmlinux.lds 9extra-y := vmlinux.lds
diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
index 69f24905abd..f386d04a84a 100644
--- a/arch/um/kernel/process.c
+++ b/arch/um/kernel/process.c
@@ -126,9 +126,9 @@ void exit_thread(void)
126{ 126{
127} 127}
128 128
129void *get_current(void) 129int get_current_pid(void)
130{ 130{
131 return current; 131 return task_pid_nr(current);
132} 132}
133 133
134/* 134/*
diff --git a/arch/um/kernel/sigio.c b/arch/um/kernel/sigio.c
index 2b272b63b51..2a163925576 100644
--- a/arch/um/kernel/sigio.c
+++ b/arch/um/kernel/sigio.c
@@ -25,7 +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_DISABLED|IRQF_SAMPLE_RANDOM, "write sigio", 28 IRQF_SAMPLE_RANDOM, "write sigio",
29 NULL); 29 NULL);
30 if (err) { 30 if (err) {
31 printk(KERN_ERR "write_sigio_irq : um_request_irq failed, " 31 printk(KERN_ERR "write_sigio_irq : um_request_irq failed, "
diff --git a/arch/um/kernel/signal.c b/arch/um/kernel/signal.c
index e8b889d3bce..fb12f4c5e64 100644
--- a/arch/um/kernel/signal.c
+++ b/arch/um/kernel/signal.c
@@ -65,21 +65,10 @@ static int handle_signal(struct pt_regs *regs, unsigned long signr,
65#endif 65#endif
66 err = setup_signal_stack_si(sp, signr, ka, regs, info, oldset); 66 err = setup_signal_stack_si(sp, signr, ka, regs, info, oldset);
67 67
68 if (err) { 68 if (err)
69 spin_lock_irq(&current->sighand->siglock);
70 current->blocked = *oldset;
71 recalc_sigpending();
72 spin_unlock_irq(&current->sighand->siglock);
73 force_sigsegv(signr, current); 69 force_sigsegv(signr, current);
74 } else { 70 else
75 spin_lock_irq(&current->sighand->siglock); 71 block_sigmask(ka, signr);
76 sigorsets(&current->blocked, &current->blocked,
77 &ka->sa.sa_mask);
78 if (!(ka->sa.sa_flags & SA_NODEFER))
79 sigaddset(&current->blocked, signr);
80 recalc_sigpending();
81 spin_unlock_irq(&current->sighand->siglock);
82 }
83 72
84 return err; 73 return err;
85} 74}
@@ -162,12 +151,11 @@ int do_signal(void)
162 */ 151 */
163long sys_sigsuspend(int history0, int history1, old_sigset_t mask) 152long sys_sigsuspend(int history0, int history1, old_sigset_t mask)
164{ 153{
154 sigset_t blocked;
155
165 mask &= _BLOCKABLE; 156 mask &= _BLOCKABLE;
166 spin_lock_irq(&current->sighand->siglock); 157 siginitset(&blocked, mask);
167 current->saved_sigmask = current->blocked; 158 set_current_blocked(&blocked);
168 siginitset(&current->blocked, mask);
169 recalc_sigpending();
170 spin_unlock_irq(&current->sighand->siglock);
171 159
172 current->state = TASK_INTERRUPTIBLE; 160 current->state = TASK_INTERRUPTIBLE;
173 schedule(); 161 schedule();
diff --git a/arch/um/kernel/time.c b/arch/um/kernel/time.c
index 82a6e22f1f3..d1a23fb3190 100644
--- a/arch/um/kernel/time.c
+++ b/arch/um/kernel/time.c
@@ -82,7 +82,7 @@ static void __init setup_itimer(void)
82{ 82{
83 int err; 83 int err;
84 84
85 err = request_irq(TIMER_IRQ, um_timer, IRQF_DISABLED, "timer", NULL); 85 err = request_irq(TIMER_IRQ, um_timer, 0, "timer", NULL);
86 if (err != 0) 86 if (err != 0)
87 printk(KERN_ERR "register_timer : request_irq failed - " 87 printk(KERN_ERR "register_timer : request_irq failed - "
88 "errno = %d\n", -err); 88 "errno = %d\n", -err);
diff --git a/arch/um/os-Linux/Makefile b/arch/um/os-Linux/Makefile
index dd764101e48..08ff5094fcd 100644
--- a/arch/um/os-Linux/Makefile
+++ b/arch/um/os-Linux/Makefile
@@ -13,8 +13,6 @@ USER_OBJS := $(user-objs-y) aio.o elf_aux.o execvp.o file.o helper.o irq.o \
13 main.o mem.o process.o registers.o sigio.o signal.o start_up.o time.o \ 13 main.o mem.o process.o registers.o sigio.o signal.o start_up.o time.o \
14 tty.o umid.o util.o 14 tty.o umid.o util.o
15 15
16CFLAGS_user_syms.o += -DSUBARCH_$(SUBARCH)
17
18HAVE_AIO_ABI := $(shell [ -r /usr/include/linux/aio_abi.h ] && \ 16HAVE_AIO_ABI := $(shell [ -r /usr/include/linux/aio_abi.h ] && \
19 echo -DHAVE_AIO_ABI ) 17 echo -DHAVE_AIO_ABI )
20CFLAGS_aio.o += $(HAVE_AIO_ABI) 18CFLAGS_aio.o += $(HAVE_AIO_ABI)
diff --git a/arch/um/os-Linux/user_syms.c b/arch/um/os-Linux/user_syms.c
index 45ffe46871e..73926fa3f96 100644
--- a/arch/um/os-Linux/user_syms.c
+++ b/arch/um/os-Linux/user_syms.c
@@ -45,7 +45,7 @@ EXPORT_SYMBOL(readdir64);
45extern void truncate64(void) __attribute__((weak)); 45extern void truncate64(void) __attribute__((weak));
46EXPORT_SYMBOL(truncate64); 46EXPORT_SYMBOL(truncate64);
47 47
48#ifdef SUBARCH_i386 48#ifdef CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA
49EXPORT_SYMBOL(vsyscall_ehdr); 49EXPORT_SYMBOL(vsyscall_ehdr);
50EXPORT_SYMBOL(vsyscall_end); 50EXPORT_SYMBOL(vsyscall_end);
51#endif 51#endif
diff --git a/arch/um/scripts/Makefile.rules b/arch/um/scripts/Makefile.rules
index 2eb2843b063..d50270d26b4 100644
--- a/arch/um/scripts/Makefile.rules
+++ b/arch/um/scripts/Makefile.rules
@@ -9,8 +9,6 @@ USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file))
9 9
10$(USER_OBJS:.o=.%): \ 10$(USER_OBJS:.o=.%): \
11 c_flags = -Wp,-MD,$(depfile) $(USER_CFLAGS) -include user.h $(CFLAGS_$(basetarget).o) 11 c_flags = -Wp,-MD,$(depfile) $(USER_CFLAGS) -include user.h $(CFLAGS_$(basetarget).o)
12$(USER_OBJS) : CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ \
13 -Dunix -D__unix__ -D__$(SUBARCH)__ $(CF)
14 12
15# These are like USER_OBJS but filter USER_CFLAGS through unprofile instead of 13# These are like USER_OBJS but filter USER_CFLAGS through unprofile instead of
16# using it directly. 14# using it directly.
@@ -18,8 +16,9 @@ UNPROFILE_OBJS := $(foreach file,$(UNPROFILE_OBJS),$(obj)/$(file))
18 16
19$(UNPROFILE_OBJS:.o=.%): \ 17$(UNPROFILE_OBJS:.o=.%): \
20 c_flags = -Wp,-MD,$(depfile) $(call unprofile,$(USER_CFLAGS)) $(CFLAGS_$(basetarget).o) 18 c_flags = -Wp,-MD,$(depfile) $(call unprofile,$(USER_CFLAGS)) $(CFLAGS_$(basetarget).o)
21$(UNPROFILE_OBJS) : CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ \ 19
22 -Dunix -D__unix__ -D__$(SUBARCH)__ $(CF) 20$(USER_OBJS) $(UNPROFILE_OBJS): \
21 CHECKFLAGS := $(patsubst $(NOSTDINC_FLAGS),,$(CHECKFLAGS))
23 22
24# The stubs can't try to call mcount or update basic block data 23# The stubs can't try to call mcount or update basic block data
25define unprofile 24define unprofile
diff --git a/arch/unicore32/include/asm/pci.h b/arch/unicore32/include/asm/pci.h
index dd3867727c3..f5e108f4a15 100644
--- a/arch/unicore32/include/asm/pci.h
+++ b/arch/unicore32/include/asm/pci.h
@@ -14,6 +14,7 @@
14 14
15#ifdef __KERNEL__ 15#ifdef __KERNEL__
16#include <asm-generic/pci-dma-compat.h> 16#include <asm-generic/pci-dma-compat.h>
17#include <asm-generic/pci-bridge.h>
17#include <asm-generic/pci.h> 18#include <asm-generic/pci.h>
18#include <mach/hardware.h> /* for PCIBIOS_MIN_* */ 19#include <mach/hardware.h> /* for PCIBIOS_MIN_* */
19 20
diff --git a/arch/unicore32/kernel/pci.c b/arch/unicore32/kernel/pci.c
index a8f07fe10ca..2fc2b1ba825 100644
--- a/arch/unicore32/kernel/pci.c
+++ b/arch/unicore32/kernel/pci.c
@@ -21,7 +21,6 @@
21#include <linux/io.h> 21#include <linux/io.h>
22 22
23static int debug_pci; 23static int debug_pci;
24static int use_firmware;
25 24
26#define CONFIG_CMD(bus, devfn, where) \ 25#define CONFIG_CMD(bus, devfn, where) \
27 (0x80000000 | (bus->number << 16) | (devfn << 8) | (where & ~3)) 26 (0x80000000 | (bus->number << 16) | (devfn << 8) | (where & ~3))
@@ -276,7 +275,7 @@ static int __init pci_common_init(void)
276 275
277 pci_fixup_irqs(pci_common_swizzle, pci_puv3_map_irq); 276 pci_fixup_irqs(pci_common_swizzle, pci_puv3_map_irq);
278 277
279 if (!use_firmware) { 278 if (!pci_has_flag(PCI_PROBE_ONLY)) {
280 /* 279 /*
281 * Size the bridge windows. 280 * Size the bridge windows.
282 */ 281 */
@@ -303,7 +302,7 @@ char * __devinit pcibios_setup(char *str)
303 debug_pci = 1; 302 debug_pci = 1;
304 return NULL; 303 return NULL;
305 } else if (!strcmp(str, "firmware")) { 304 } else if (!strcmp(str, "firmware")) {
306 use_firmware = 1; 305 pci_add_flags(PCI_PROBE_ONLY);
307 return NULL; 306 return NULL;
308 } 307 }
309 return str; 308 return str;
diff --git a/arch/unicore32/kernel/process.c b/arch/unicore32/kernel/process.c
index 1b3f152bb9c..b6f0458c314 100644
--- a/arch/unicore32/kernel/process.c
+++ b/arch/unicore32/kernel/process.c
@@ -380,7 +380,7 @@ int vectors_user_mapping(void)
380 return install_special_mapping(mm, 0xffff0000, PAGE_SIZE, 380 return install_special_mapping(mm, 0xffff0000, PAGE_SIZE,
381 VM_READ | VM_EXEC | 381 VM_READ | VM_EXEC |
382 VM_MAYREAD | VM_MAYEXEC | 382 VM_MAYREAD | VM_MAYEXEC |
383 VM_ALWAYSDUMP | VM_RESERVED, 383 VM_RESERVED,
384 NULL); 384 NULL);
385} 385}
386 386
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 90195235596..3ad653de710 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2125,6 +2125,13 @@ config NET5501
2125 ---help--- 2125 ---help---
2126 This option enables system support for the Soekris Engineering net5501. 2126 This option enables system support for the Soekris Engineering net5501.
2127 2127
2128config GEOS
2129 bool "Traverse Technologies GEOS System Support (LEDS, GPIO, etc)"
2130 select GPIOLIB
2131 depends on DMI
2132 ---help---
2133 This option enables system support for the Traverse Technologies GEOS.
2134
2128endif # X86_32 2135endif # X86_32
2129 2136
2130config AMD_NB 2137config AMD_NB
diff --git a/arch/x86/Makefile.um b/arch/x86/Makefile.um
index 36ddec6a41c..4be406abeef 100644
--- a/arch/x86/Makefile.um
+++ b/arch/x86/Makefile.um
@@ -8,15 +8,11 @@ ELF_ARCH := i386
8ELF_FORMAT := elf32-i386 8ELF_FORMAT := elf32-i386
9CHECKFLAGS += -D__i386__ 9CHECKFLAGS += -D__i386__
10 10
11ifeq ("$(origin SUBARCH)", "command line")
12ifneq ("$(shell uname -m | sed -e s/i.86/i386/)", "$(SUBARCH)")
13KBUILD_CFLAGS += $(call cc-option,-m32) 11KBUILD_CFLAGS += $(call cc-option,-m32)
14KBUILD_AFLAGS += $(call cc-option,-m32) 12KBUILD_AFLAGS += $(call cc-option,-m32)
15LINK-y += $(call cc-option,-m32) 13LINK-y += $(call cc-option,-m32)
16 14
17export LDFLAGS 15export LDFLAGS
18endif
19endif
20 16
21# First of all, tune CFLAGS for the specific CPU. This actually sets cflags-y. 17# First of all, tune CFLAGS for the specific CPU. This actually sets cflags-y.
22include $(srctree)/arch/x86/Makefile_32.cpu 18include $(srctree)/arch/x86/Makefile_32.cpu
diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
index 3e02148bb77..5a747dd884d 100644
--- a/arch/x86/boot/Makefile
+++ b/arch/x86/boot/Makefile
@@ -37,9 +37,9 @@ setup-y += video-bios.o
37targets += $(setup-y) 37targets += $(setup-y)
38hostprogs-y := mkcpustr tools/build 38hostprogs-y := mkcpustr tools/build
39 39
40HOSTCFLAGS_mkcpustr.o := -I$(srctree)/arch/$(SRCARCH)/include 40HOST_EXTRACFLAGS += -I$(srctree)/tools/include $(LINUXINCLUDE) \
41HOST_EXTRACFLAGS += -I$(objtree)/include -I$(srctree)/tools/include \ 41 -D__EXPORTED_HEADERS__
42 -include $(srctree)/include/linux/kconfig.h 42
43$(obj)/cpu.o: $(obj)/cpustr.h 43$(obj)/cpu.o: $(obj)/cpustr.h
44 44
45quiet_cmd_cpustr = CPUSTR $@ 45quiet_cmd_cpustr = CPUSTR $@
diff --git a/arch/x86/include/asm/debugreg.h b/arch/x86/include/asm/debugreg.h
index b903d5ea394..2d91580bf22 100644
--- a/arch/x86/include/asm/debugreg.h
+++ b/arch/x86/include/asm/debugreg.h
@@ -78,8 +78,75 @@
78 */ 78 */
79#ifdef __KERNEL__ 79#ifdef __KERNEL__
80 80
81#include <linux/bug.h>
82
81DECLARE_PER_CPU(unsigned long, cpu_dr7); 83DECLARE_PER_CPU(unsigned long, cpu_dr7);
82 84
85#ifndef CONFIG_PARAVIRT
86/*
87 * These special macros can be used to get or set a debugging register
88 */
89#define get_debugreg(var, register) \
90 (var) = native_get_debugreg(register)
91#define set_debugreg(value, register) \
92 native_set_debugreg(register, value)
93#endif
94
95static inline unsigned long native_get_debugreg(int regno)
96{
97 unsigned long val = 0; /* Damn you, gcc! */
98
99 switch (regno) {
100 case 0:
101 asm("mov %%db0, %0" :"=r" (val));
102 break;
103 case 1:
104 asm("mov %%db1, %0" :"=r" (val));
105 break;
106 case 2:
107 asm("mov %%db2, %0" :"=r" (val));
108 break;
109 case 3:
110 asm("mov %%db3, %0" :"=r" (val));
111 break;
112 case 6:
113 asm("mov %%db6, %0" :"=r" (val));
114 break;
115 case 7:
116 asm("mov %%db7, %0" :"=r" (val));
117 break;
118 default:
119 BUG();
120 }
121 return val;
122}
123
124static inline void native_set_debugreg(int regno, unsigned long value)
125{
126 switch (regno) {
127 case 0:
128 asm("mov %0, %%db0" ::"r" (value));
129 break;
130 case 1:
131 asm("mov %0, %%db1" ::"r" (value));
132 break;
133 case 2:
134 asm("mov %0, %%db2" ::"r" (value));
135 break;
136 case 3:
137 asm("mov %0, %%db3" ::"r" (value));
138 break;
139 case 6:
140 asm("mov %0, %%db6" ::"r" (value));
141 break;
142 case 7:
143 asm("mov %0, %%db7" ::"r" (value));
144 break;
145 default:
146 BUG();
147 }
148}
149
83static inline void hw_breakpoint_disable(void) 150static inline void hw_breakpoint_disable(void)
84{ 151{
85 /* Zero the control register for HW Breakpoint */ 152 /* Zero the control register for HW Breakpoint */
diff --git a/arch/x86/include/asm/kgdb.h b/arch/x86/include/asm/kgdb.h
index 77e95f54570..332f98c9111 100644
--- a/arch/x86/include/asm/kgdb.h
+++ b/arch/x86/include/asm/kgdb.h
@@ -64,11 +64,15 @@ enum regnames {
64 GDB_PS, /* 17 */ 64 GDB_PS, /* 17 */
65 GDB_CS, /* 18 */ 65 GDB_CS, /* 18 */
66 GDB_SS, /* 19 */ 66 GDB_SS, /* 19 */
67 GDB_DS, /* 20 */
68 GDB_ES, /* 21 */
69 GDB_FS, /* 22 */
70 GDB_GS, /* 23 */
67}; 71};
68#define GDB_ORIG_AX 57 72#define GDB_ORIG_AX 57
69#define DBG_MAX_REG_NUM 20 73#define DBG_MAX_REG_NUM 24
70/* 17 64 bit regs and 3 32 bit regs */ 74/* 17 64 bit regs and 5 32 bit regs */
71#define NUMREGBYTES ((17 * 8) + (3 * 4)) 75#define NUMREGBYTES ((17 * 8) + (5 * 4))
72#endif /* ! CONFIG_X86_32 */ 76#endif /* ! CONFIG_X86_32 */
73 77
74static inline void arch_kgdb_breakpoint(void) 78static inline void arch_kgdb_breakpoint(void)
diff --git a/arch/x86/include/asm/kvm.h b/arch/x86/include/asm/kvm.h
index 4d8dcbdfc12..e7d1c194d27 100644
--- a/arch/x86/include/asm/kvm.h
+++ b/arch/x86/include/asm/kvm.h
@@ -321,4 +321,8 @@ struct kvm_xcrs {
321 __u64 padding[16]; 321 __u64 padding[16];
322}; 322};
323 323
324/* definition of registers in kvm_run */
325struct kvm_sync_regs {
326};
327
324#endif /* _ASM_X86_KVM_H */ 328#endif /* _ASM_X86_KVM_H */
diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/include/asm/kvm_emulate.h
index 7b9cfc4878a..c222e1a1b12 100644
--- a/arch/x86/include/asm/kvm_emulate.h
+++ b/arch/x86/include/asm/kvm_emulate.h
@@ -176,6 +176,7 @@ struct x86_emulate_ops {
176 void (*set_idt)(struct x86_emulate_ctxt *ctxt, struct desc_ptr *dt); 176 void (*set_idt)(struct x86_emulate_ctxt *ctxt, struct desc_ptr *dt);
177 ulong (*get_cr)(struct x86_emulate_ctxt *ctxt, int cr); 177 ulong (*get_cr)(struct x86_emulate_ctxt *ctxt, int cr);
178 int (*set_cr)(struct x86_emulate_ctxt *ctxt, int cr, ulong val); 178 int (*set_cr)(struct x86_emulate_ctxt *ctxt, int cr, ulong val);
179 void (*set_rflags)(struct x86_emulate_ctxt *ctxt, ulong val);
179 int (*cpl)(struct x86_emulate_ctxt *ctxt); 180 int (*cpl)(struct x86_emulate_ctxt *ctxt);
180 int (*get_dr)(struct x86_emulate_ctxt *ctxt, int dr, ulong *dest); 181 int (*get_dr)(struct x86_emulate_ctxt *ctxt, int dr, ulong *dest);
181 int (*set_dr)(struct x86_emulate_ctxt *ctxt, int dr, ulong value); 182 int (*set_dr)(struct x86_emulate_ctxt *ctxt, int dr, ulong value);
@@ -388,7 +389,7 @@ bool x86_page_table_writing_insn(struct x86_emulate_ctxt *ctxt);
388#define EMULATION_INTERCEPTED 2 389#define EMULATION_INTERCEPTED 2
389int x86_emulate_insn(struct x86_emulate_ctxt *ctxt); 390int x86_emulate_insn(struct x86_emulate_ctxt *ctxt);
390int emulator_task_switch(struct x86_emulate_ctxt *ctxt, 391int emulator_task_switch(struct x86_emulate_ctxt *ctxt,
391 u16 tss_selector, int reason, 392 u16 tss_selector, int idt_index, int reason,
392 bool has_error_code, u32 error_code); 393 bool has_error_code, u32 error_code);
393int emulate_int_real(struct x86_emulate_ctxt *ctxt, int irq); 394int emulate_int_real(struct x86_emulate_ctxt *ctxt, int irq);
394#endif /* _ASM_X86_KVM_X86_EMULATE_H */ 395#endif /* _ASM_X86_KVM_X86_EMULATE_H */
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 52d6640a5ca..e216ba066e7 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -29,7 +29,7 @@
29#include <asm/msr-index.h> 29#include <asm/msr-index.h>
30 30
31#define KVM_MAX_VCPUS 254 31#define KVM_MAX_VCPUS 254
32#define KVM_SOFT_MAX_VCPUS 64 32#define KVM_SOFT_MAX_VCPUS 160
33#define KVM_MEMORY_SLOTS 32 33#define KVM_MEMORY_SLOTS 32
34/* memory slots that does not exposed to userspace */ 34/* memory slots that does not exposed to userspace */
35#define KVM_PRIVATE_MEM_SLOTS 4 35#define KVM_PRIVATE_MEM_SLOTS 4
@@ -181,13 +181,6 @@ struct kvm_mmu_memory_cache {
181 void *objects[KVM_NR_MEM_OBJS]; 181 void *objects[KVM_NR_MEM_OBJS];
182}; 182};
183 183
184#define NR_PTE_CHAIN_ENTRIES 5
185
186struct kvm_pte_chain {
187 u64 *parent_ptes[NR_PTE_CHAIN_ENTRIES];
188 struct hlist_node link;
189};
190
191/* 184/*
192 * kvm_mmu_page_role, below, is defined as: 185 * kvm_mmu_page_role, below, is defined as:
193 * 186 *
@@ -427,12 +420,16 @@ struct kvm_vcpu_arch {
427 420
428 u64 last_guest_tsc; 421 u64 last_guest_tsc;
429 u64 last_kernel_ns; 422 u64 last_kernel_ns;
430 u64 last_tsc_nsec; 423 u64 last_host_tsc;
431 u64 last_tsc_write; 424 u64 tsc_offset_adjustment;
432 u32 virtual_tsc_khz; 425 u64 this_tsc_nsec;
426 u64 this_tsc_write;
427 u8 this_tsc_generation;
433 bool tsc_catchup; 428 bool tsc_catchup;
434 u32 tsc_catchup_mult; 429 bool tsc_always_catchup;
435 s8 tsc_catchup_shift; 430 s8 virtual_tsc_shift;
431 u32 virtual_tsc_mult;
432 u32 virtual_tsc_khz;
436 433
437 atomic_t nmi_queued; /* unprocessed asynchronous NMIs */ 434 atomic_t nmi_queued; /* unprocessed asynchronous NMIs */
438 unsigned nmi_pending; /* NMI queued after currently running handler */ 435 unsigned nmi_pending; /* NMI queued after currently running handler */
@@ -478,6 +475,21 @@ struct kvm_vcpu_arch {
478 u32 id; 475 u32 id;
479 bool send_user_only; 476 bool send_user_only;
480 } apf; 477 } apf;
478
479 /* OSVW MSRs (AMD only) */
480 struct {
481 u64 length;
482 u64 status;
483 } osvw;
484};
485
486struct kvm_lpage_info {
487 unsigned long rmap_pde;
488 int write_count;
489};
490
491struct kvm_arch_memory_slot {
492 struct kvm_lpage_info *lpage_info[KVM_NR_PAGE_SIZES - 1];
481}; 493};
482 494
483struct kvm_arch { 495struct kvm_arch {
@@ -511,8 +523,12 @@ struct kvm_arch {
511 s64 kvmclock_offset; 523 s64 kvmclock_offset;
512 raw_spinlock_t tsc_write_lock; 524 raw_spinlock_t tsc_write_lock;
513 u64 last_tsc_nsec; 525 u64 last_tsc_nsec;
514 u64 last_tsc_offset;
515 u64 last_tsc_write; 526 u64 last_tsc_write;
527 u32 last_tsc_khz;
528 u64 cur_tsc_nsec;
529 u64 cur_tsc_write;
530 u64 cur_tsc_offset;
531 u8 cur_tsc_generation;
516 532
517 struct kvm_xen_hvm_config xen_hvm_config; 533 struct kvm_xen_hvm_config xen_hvm_config;
518 534
@@ -644,7 +660,7 @@ struct kvm_x86_ops {
644 u64 (*get_mt_mask)(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio); 660 u64 (*get_mt_mask)(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio);
645 int (*get_lpage_level)(void); 661 int (*get_lpage_level)(void);
646 bool (*rdtscp_supported)(void); 662 bool (*rdtscp_supported)(void);
647 void (*adjust_tsc_offset)(struct kvm_vcpu *vcpu, s64 adjustment); 663 void (*adjust_tsc_offset)(struct kvm_vcpu *vcpu, s64 adjustment, bool host);
648 664
649 void (*set_tdp_cr3)(struct kvm_vcpu *vcpu, unsigned long cr3); 665 void (*set_tdp_cr3)(struct kvm_vcpu *vcpu, unsigned long cr3);
650 666
@@ -652,7 +668,7 @@ struct kvm_x86_ops {
652 668
653 bool (*has_wbinvd_exit)(void); 669 bool (*has_wbinvd_exit)(void);
654 670
655 void (*set_tsc_khz)(struct kvm_vcpu *vcpu, u32 user_tsc_khz); 671 void (*set_tsc_khz)(struct kvm_vcpu *vcpu, u32 user_tsc_khz, bool scale);
656 void (*write_tsc_offset)(struct kvm_vcpu *vcpu, u64 offset); 672 void (*write_tsc_offset)(struct kvm_vcpu *vcpu, u64 offset);
657 673
658 u64 (*compute_tsc_offset)(struct kvm_vcpu *vcpu, u64 target_tsc); 674 u64 (*compute_tsc_offset)(struct kvm_vcpu *vcpu, u64 target_tsc);
@@ -674,6 +690,17 @@ struct kvm_arch_async_pf {
674 690
675extern struct kvm_x86_ops *kvm_x86_ops; 691extern struct kvm_x86_ops *kvm_x86_ops;
676 692
693static inline void adjust_tsc_offset_guest(struct kvm_vcpu *vcpu,
694 s64 adjustment)
695{
696 kvm_x86_ops->adjust_tsc_offset(vcpu, adjustment, false);
697}
698
699static inline void adjust_tsc_offset_host(struct kvm_vcpu *vcpu, s64 adjustment)
700{
701 kvm_x86_ops->adjust_tsc_offset(vcpu, adjustment, true);
702}
703
677int kvm_mmu_module_init(void); 704int kvm_mmu_module_init(void);
678void kvm_mmu_module_exit(void); 705void kvm_mmu_module_exit(void);
679 706
@@ -741,8 +768,8 @@ int kvm_emulate_wbinvd(struct kvm_vcpu *vcpu);
741void kvm_get_segment(struct kvm_vcpu *vcpu, struct kvm_segment *var, int seg); 768void kvm_get_segment(struct kvm_vcpu *vcpu, struct kvm_segment *var, int seg);
742int kvm_load_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector, int seg); 769int kvm_load_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector, int seg);
743 770
744int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int reason, 771int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int idt_index,
745 bool has_error_code, u32 error_code); 772 int reason, bool has_error_code, u32 error_code);
746 773
747int kvm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0); 774int kvm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0);
748int kvm_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3); 775int kvm_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3);
diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index c0180fd372d..aa0f9130836 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -10,6 +10,7 @@
10#include <asm/paravirt_types.h> 10#include <asm/paravirt_types.h>
11 11
12#ifndef __ASSEMBLY__ 12#ifndef __ASSEMBLY__
13#include <linux/bug.h>
13#include <linux/types.h> 14#include <linux/types.h>
14#include <linux/cpumask.h> 15#include <linux/cpumask.h>
15 16
diff --git a/arch/x86/include/asm/perf_event.h b/arch/x86/include/asm/perf_event.h
index e8fb2c7a5f4..2291895b183 100644
--- a/arch/x86/include/asm/perf_event.h
+++ b/arch/x86/include/asm/perf_event.h
@@ -23,6 +23,7 @@
23#define ARCH_PERFMON_EVENTSEL_USR (1ULL << 16) 23#define ARCH_PERFMON_EVENTSEL_USR (1ULL << 16)
24#define ARCH_PERFMON_EVENTSEL_OS (1ULL << 17) 24#define ARCH_PERFMON_EVENTSEL_OS (1ULL << 17)
25#define ARCH_PERFMON_EVENTSEL_EDGE (1ULL << 18) 25#define ARCH_PERFMON_EVENTSEL_EDGE (1ULL << 18)
26#define ARCH_PERFMON_EVENTSEL_PIN_CONTROL (1ULL << 19)
26#define ARCH_PERFMON_EVENTSEL_INT (1ULL << 20) 27#define ARCH_PERFMON_EVENTSEL_INT (1ULL << 20)
27#define ARCH_PERFMON_EVENTSEL_ANY (1ULL << 21) 28#define ARCH_PERFMON_EVENTSEL_ANY (1ULL << 21)
28#define ARCH_PERFMON_EVENTSEL_ENABLE (1ULL << 22) 29#define ARCH_PERFMON_EVENTSEL_ENABLE (1ULL << 22)
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 78e30ea492b..a19542c1685 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -484,61 +484,6 @@ struct thread_struct {
484 unsigned io_bitmap_max; 484 unsigned io_bitmap_max;
485}; 485};
486 486
487static inline unsigned long native_get_debugreg(int regno)
488{
489 unsigned long val = 0; /* Damn you, gcc! */
490
491 switch (regno) {
492 case 0:
493 asm("mov %%db0, %0" :"=r" (val));
494 break;
495 case 1:
496 asm("mov %%db1, %0" :"=r" (val));
497 break;
498 case 2:
499 asm("mov %%db2, %0" :"=r" (val));
500 break;
501 case 3:
502 asm("mov %%db3, %0" :"=r" (val));
503 break;
504 case 6:
505 asm("mov %%db6, %0" :"=r" (val));
506 break;
507 case 7:
508 asm("mov %%db7, %0" :"=r" (val));
509 break;
510 default:
511 BUG();
512 }
513 return val;
514}
515
516static inline void native_set_debugreg(int regno, unsigned long value)
517{
518 switch (regno) {
519 case 0:
520 asm("mov %0, %%db0" ::"r" (value));
521 break;
522 case 1:
523 asm("mov %0, %%db1" ::"r" (value));
524 break;
525 case 2:
526 asm("mov %0, %%db2" ::"r" (value));
527 break;
528 case 3:
529 asm("mov %0, %%db3" ::"r" (value));
530 break;
531 case 6:
532 asm("mov %0, %%db6" ::"r" (value));
533 break;
534 case 7:
535 asm("mov %0, %%db7" ::"r" (value));
536 break;
537 default:
538 BUG();
539 }
540}
541
542/* 487/*
543 * Set IOPL bits in EFLAGS from given mask 488 * Set IOPL bits in EFLAGS from given mask
544 */ 489 */
@@ -584,14 +529,6 @@ static inline void native_swapgs(void)
584#define __cpuid native_cpuid 529#define __cpuid native_cpuid
585#define paravirt_enabled() 0 530#define paravirt_enabled() 0
586 531
587/*
588 * These special macros can be used to get or set a debugging register
589 */
590#define get_debugreg(var, register) \
591 (var) = native_get_debugreg(register)
592#define set_debugreg(value, register) \
593 native_set_debugreg(register, value)
594
595static inline void load_sp0(struct tss_struct *tss, 532static inline void load_sp0(struct tss_struct *tss,
596 struct thread_struct *thread) 533 struct thread_struct *thread)
597{ 534{
diff --git a/arch/x86/include/asm/tsc.h b/arch/x86/include/asm/tsc.h
index 15d99153a96..c91e8b9d588 100644
--- a/arch/x86/include/asm/tsc.h
+++ b/arch/x86/include/asm/tsc.h
@@ -61,7 +61,7 @@ extern void check_tsc_sync_source(int cpu);
61extern void check_tsc_sync_target(void); 61extern void check_tsc_sync_target(void);
62 62
63extern int notsc_setup(char *); 63extern int notsc_setup(char *);
64extern void save_sched_clock_state(void); 64extern void tsc_save_sched_clock_state(void);
65extern void restore_sched_clock_state(void); 65extern void tsc_restore_sched_clock_state(void);
66 66
67#endif /* _ASM_X86_TSC_H */ 67#endif /* _ASM_X86_TSC_H */
diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
index 517d4767ffd..baaca8defec 100644
--- a/arch/x86/include/asm/x86_init.h
+++ b/arch/x86/include/asm/x86_init.h
@@ -145,9 +145,11 @@ struct x86_init_ops {
145/** 145/**
146 * struct x86_cpuinit_ops - platform specific cpu hotplug setups 146 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
147 * @setup_percpu_clockev: set up the per cpu clock event device 147 * @setup_percpu_clockev: set up the per cpu clock event device
148 * @early_percpu_clock_init: early init of the per cpu clock event device
148 */ 149 */
149struct x86_cpuinit_ops { 150struct x86_cpuinit_ops {
150 void (*setup_percpu_clockev)(void); 151 void (*setup_percpu_clockev)(void);
152 void (*early_percpu_clock_init)(void);
151 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node); 153 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
152}; 154};
153 155
@@ -160,6 +162,8 @@ struct x86_cpuinit_ops {
160 * @is_untracked_pat_range exclude from PAT logic 162 * @is_untracked_pat_range exclude from PAT logic
161 * @nmi_init enable NMI on cpus 163 * @nmi_init enable NMI on cpus
162 * @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
166 * @restore_sched_clock_state: restore state for sched_clock() on resume
163 */ 167 */
164struct x86_platform_ops { 168struct x86_platform_ops {
165 unsigned long (*calibrate_tsc)(void); 169 unsigned long (*calibrate_tsc)(void);
@@ -171,6 +175,8 @@ struct x86_platform_ops {
171 void (*nmi_init)(void); 175 void (*nmi_init)(void);
172 unsigned char (*get_nmi_reason)(void); 176 unsigned char (*get_nmi_reason)(void);
173 int (*i8042_detect)(void); 177 int (*i8042_detect)(void);
178 void (*save_sched_clock_state)(void);
179 void (*restore_sched_clock_state)(void);
174}; 180};
175 181
176struct pci_dev; 182struct pci_dev;
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index ade9c794ed9..e49477444ff 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -18,6 +18,7 @@
18#include <asm/archrandom.h> 18#include <asm/archrandom.h>
19#include <asm/hypervisor.h> 19#include <asm/hypervisor.h>
20#include <asm/processor.h> 20#include <asm/processor.h>
21#include <asm/debugreg.h>
21#include <asm/sections.h> 22#include <asm/sections.h>
22#include <linux/topology.h> 23#include <linux/topology.h>
23#include <linux/cpumask.h> 24#include <linux/cpumask.h>
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 0a18d16cb58..fa2900c0e39 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -643,14 +643,14 @@ static bool __perf_sched_find_counter(struct perf_sched *sched)
643 /* Prefer fixed purpose counters */ 643 /* Prefer fixed purpose counters */
644 if (x86_pmu.num_counters_fixed) { 644 if (x86_pmu.num_counters_fixed) {
645 idx = X86_PMC_IDX_FIXED; 645 idx = X86_PMC_IDX_FIXED;
646 for_each_set_bit_cont(idx, c->idxmsk, X86_PMC_IDX_MAX) { 646 for_each_set_bit_from(idx, c->idxmsk, X86_PMC_IDX_MAX) {
647 if (!__test_and_set_bit(idx, sched->state.used)) 647 if (!__test_and_set_bit(idx, sched->state.used))
648 goto done; 648 goto done;
649 } 649 }
650 } 650 }
651 /* Grab the first unused counter starting with idx */ 651 /* Grab the first unused counter starting with idx */
652 idx = sched->state.counter; 652 idx = sched->state.counter;
653 for_each_set_bit_cont(idx, c->idxmsk, X86_PMC_IDX_FIXED) { 653 for_each_set_bit_from(idx, c->idxmsk, X86_PMC_IDX_FIXED) {
654 if (!__test_and_set_bit(idx, sched->state.used)) 654 if (!__test_and_set_bit(idx, sched->state.used))
655 goto done; 655 goto done;
656 } 656 }
diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index 79d97e68f04..7b784f4ef1e 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -98,12 +98,6 @@
98#endif 98#endif
99.endm 99.endm
100 100
101#ifdef CONFIG_VM86
102#define resume_userspace_sig check_userspace
103#else
104#define resume_userspace_sig resume_userspace
105#endif
106
107/* 101/*
108 * User gs save/restore 102 * User gs save/restore
109 * 103 *
@@ -327,10 +321,19 @@ ret_from_exception:
327 preempt_stop(CLBR_ANY) 321 preempt_stop(CLBR_ANY)
328ret_from_intr: 322ret_from_intr:
329 GET_THREAD_INFO(%ebp) 323 GET_THREAD_INFO(%ebp)
330check_userspace: 324resume_userspace_sig:
325#ifdef CONFIG_VM86
331 movl PT_EFLAGS(%esp), %eax # mix EFLAGS and CS 326 movl PT_EFLAGS(%esp), %eax # mix EFLAGS and CS
332 movb PT_CS(%esp), %al 327 movb PT_CS(%esp), %al
333 andl $(X86_EFLAGS_VM | SEGMENT_RPL_MASK), %eax 328 andl $(X86_EFLAGS_VM | SEGMENT_RPL_MASK), %eax
329#else
330 /*
331 * We can be coming here from a syscall done in the kernel space,
332 * e.g. a failed kernel_execve().
333 */
334 movl PT_CS(%esp), %eax
335 andl $SEGMENT_RPL_MASK, %eax
336#endif
334 cmpl $USER_RPL, %eax 337 cmpl $USER_RPL, %eax
335 jb resume_kernel # not returning to v8086 or userspace 338 jb resume_kernel # not returning to v8086 or userspace
336 339
diff --git a/arch/x86/kernel/irqinit.c b/arch/x86/kernel/irqinit.c
index 99b85b423bb..6d5fc8cfd5d 100644
--- a/arch/x86/kernel/irqinit.c
+++ b/arch/x86/kernel/irqinit.c
@@ -305,10 +305,10 @@ void __init native_init_IRQ(void)
305 * us. (some of these will be overridden and become 305 * us. (some of these will be overridden and become
306 * 'special' SMP interrupts) 306 * 'special' SMP interrupts)
307 */ 307 */
308 for (i = FIRST_EXTERNAL_VECTOR; i < NR_VECTORS; i++) { 308 i = FIRST_EXTERNAL_VECTOR;
309 for_each_clear_bit_from(i, used_vectors, NR_VECTORS) {
309 /* IA32_SYSCALL_VECTOR could be used in trap_init already. */ 310 /* IA32_SYSCALL_VECTOR could be used in trap_init already. */
310 if (!test_bit(i, used_vectors)) 311 set_intr_gate(i, interrupt[i - FIRST_EXTERNAL_VECTOR]);
311 set_intr_gate(i, interrupt[i-FIRST_EXTERNAL_VECTOR]);
312 } 312 }
313 313
314 if (!acpi_ioapic && !of_ioapic) 314 if (!acpi_ioapic && !of_ioapic)
diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
index 4425a12ece4..db6720edfdd 100644
--- a/arch/x86/kernel/kgdb.c
+++ b/arch/x86/kernel/kgdb.c
@@ -66,8 +66,6 @@ struct dbg_reg_def_t dbg_reg_def[DBG_MAX_REG_NUM] =
66 { "ss", 4, offsetof(struct pt_regs, ss) }, 66 { "ss", 4, offsetof(struct pt_regs, ss) },
67 { "ds", 4, offsetof(struct pt_regs, ds) }, 67 { "ds", 4, offsetof(struct pt_regs, ds) },
68 { "es", 4, offsetof(struct pt_regs, es) }, 68 { "es", 4, offsetof(struct pt_regs, es) },
69 { "fs", 4, -1 },
70 { "gs", 4, -1 },
71#else 69#else
72 { "ax", 8, offsetof(struct pt_regs, ax) }, 70 { "ax", 8, offsetof(struct pt_regs, ax) },
73 { "bx", 8, offsetof(struct pt_regs, bx) }, 71 { "bx", 8, offsetof(struct pt_regs, bx) },
@@ -89,7 +87,11 @@ struct dbg_reg_def_t dbg_reg_def[DBG_MAX_REG_NUM] =
89 { "flags", 4, offsetof(struct pt_regs, flags) }, 87 { "flags", 4, offsetof(struct pt_regs, flags) },
90 { "cs", 4, offsetof(struct pt_regs, cs) }, 88 { "cs", 4, offsetof(struct pt_regs, cs) },
91 { "ss", 4, offsetof(struct pt_regs, ss) }, 89 { "ss", 4, offsetof(struct pt_regs, ss) },
90 { "ds", 4, -1 },
91 { "es", 4, -1 },
92#endif 92#endif
93 { "fs", 4, -1 },
94 { "gs", 4, -1 },
93}; 95};
94 96
95int dbg_set_reg(int regno, void *mem, struct pt_regs *regs) 97int dbg_set_reg(int regno, void *mem, struct pt_regs *regs)
diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
index 44842d756b2..f8492da65bf 100644
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -136,6 +136,15 @@ int kvm_register_clock(char *txt)
136 return ret; 136 return ret;
137} 137}
138 138
139static void kvm_save_sched_clock_state(void)
140{
141}
142
143static void kvm_restore_sched_clock_state(void)
144{
145 kvm_register_clock("primary cpu clock, resume");
146}
147
139#ifdef CONFIG_X86_LOCAL_APIC 148#ifdef CONFIG_X86_LOCAL_APIC
140static void __cpuinit kvm_setup_secondary_clock(void) 149static void __cpuinit kvm_setup_secondary_clock(void)
141{ 150{
@@ -144,8 +153,6 @@ static void __cpuinit kvm_setup_secondary_clock(void)
144 * we shouldn't fail. 153 * we shouldn't fail.
145 */ 154 */
146 WARN_ON(kvm_register_clock("secondary cpu clock")); 155 WARN_ON(kvm_register_clock("secondary cpu clock"));
147 /* ok, done with our trickery, call native */
148 setup_secondary_APIC_clock();
149} 156}
150#endif 157#endif
151 158
@@ -194,9 +201,11 @@ void __init kvmclock_init(void)
194 x86_platform.get_wallclock = kvm_get_wallclock; 201 x86_platform.get_wallclock = kvm_get_wallclock;
195 x86_platform.set_wallclock = kvm_set_wallclock; 202 x86_platform.set_wallclock = kvm_set_wallclock;
196#ifdef CONFIG_X86_LOCAL_APIC 203#ifdef CONFIG_X86_LOCAL_APIC
197 x86_cpuinit.setup_percpu_clockev = 204 x86_cpuinit.early_percpu_clock_init =
198 kvm_setup_secondary_clock; 205 kvm_setup_secondary_clock;
199#endif 206#endif
207 x86_platform.save_sched_clock_state = kvm_save_sched_clock_state;
208 x86_platform.restore_sched_clock_state = kvm_restore_sched_clock_state;
200 machine_ops.shutdown = kvm_shutdown; 209 machine_ops.shutdown = kvm_shutdown;
201#ifdef CONFIG_KEXEC 210#ifdef CONFIG_KEXEC
202 machine_ops.crash_shutdown = kvm_crash_shutdown; 211 machine_ops.crash_shutdown = kvm_crash_shutdown;
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
index 2b26485f0c1..ab137605e69 100644
--- a/arch/x86/kernel/paravirt.c
+++ b/arch/x86/kernel/paravirt.c
@@ -26,6 +26,7 @@
26 26
27#include <asm/bug.h> 27#include <asm/bug.h>
28#include <asm/paravirt.h> 28#include <asm/paravirt.h>
29#include <asm/debugreg.h>
29#include <asm/desc.h> 30#include <asm/desc.h>
30#include <asm/setup.h> 31#include <asm/setup.h>
31#include <asm/pgtable.h> 32#include <asm/pgtable.h>
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 1c4d769e21e..28e5e06fcba 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -262,10 +262,11 @@ rootfs_initcall(pci_iommu_init);
262 262
263static __devinit void via_no_dac(struct pci_dev *dev) 263static __devinit void via_no_dac(struct pci_dev *dev)
264{ 264{
265 if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI && forbid_dac == 0) { 265 if (forbid_dac == 0) {
266 dev_info(&dev->dev, "disabling DAC on VIA PCI bridge\n"); 266 dev_info(&dev->dev, "disabling DAC on VIA PCI bridge\n");
267 forbid_dac = 1; 267 forbid_dac = 1;
268 } 268 }
269} 269}
270DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_ANY_ID, via_no_dac); 270DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_VIA, PCI_ANY_ID,
271 PCI_CLASS_BRIDGE_PCI, 8, via_no_dac);
271#endif 272#endif
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index e578a79a309..5104a2b685c 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -255,6 +255,7 @@ notrace static void __cpuinit start_secondary(void *unused)
255 * most necessary things. 255 * most necessary things.
256 */ 256 */
257 cpu_init(); 257 cpu_init();
258 x86_cpuinit.early_percpu_clock_init();
258 preempt_disable(); 259 preempt_disable();
259 smp_callin(); 260 smp_callin();
260 261
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 183c5925a9f..899a03f2d18 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -630,7 +630,7 @@ static void set_cyc2ns_scale(unsigned long cpu_khz, int cpu)
630 630
631static unsigned long long cyc2ns_suspend; 631static unsigned long long cyc2ns_suspend;
632 632
633void save_sched_clock_state(void) 633void tsc_save_sched_clock_state(void)
634{ 634{
635 if (!sched_clock_stable) 635 if (!sched_clock_stable)
636 return; 636 return;
@@ -646,7 +646,7 @@ void save_sched_clock_state(void)
646 * that sched_clock() continues from the point where it was left off during 646 * that sched_clock() continues from the point where it was left off during
647 * suspend. 647 * suspend.
648 */ 648 */
649void restore_sched_clock_state(void) 649void tsc_restore_sched_clock_state(void)
650{ 650{
651 unsigned long long offset; 651 unsigned long long offset;
652 unsigned long flags; 652 unsigned long flags;
diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
index 947a06ccc67..e9f265fd79a 100644
--- a/arch/x86/kernel/x86_init.c
+++ b/arch/x86/kernel/x86_init.c
@@ -91,6 +91,7 @@ struct x86_init_ops x86_init __initdata = {
91}; 91};
92 92
93struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = { 93struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
94 .early_percpu_clock_init = x86_init_noop,
94 .setup_percpu_clockev = setup_secondary_APIC_clock, 95 .setup_percpu_clockev = setup_secondary_APIC_clock,
95 .fixup_cpu_id = x86_default_fixup_cpu_id, 96 .fixup_cpu_id = x86_default_fixup_cpu_id,
96}; 97};
@@ -107,7 +108,9 @@ struct x86_platform_ops x86_platform = {
107 .is_untracked_pat_range = is_ISA_range, 108 .is_untracked_pat_range = is_ISA_range,
108 .nmi_init = default_nmi_init, 109 .nmi_init = default_nmi_init,
109 .get_nmi_reason = default_get_nmi_reason, 110 .get_nmi_reason = default_get_nmi_reason,
110 .i8042_detect = default_i8042_detect 111 .i8042_detect = default_i8042_detect,
112 .save_sched_clock_state = tsc_save_sched_clock_state,
113 .restore_sched_clock_state = tsc_restore_sched_clock_state,
111}; 114};
112 115
113EXPORT_SYMBOL_GPL(x86_platform); 116EXPORT_SYMBOL_GPL(x86_platform);
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 89b02bfaaca..9fed5bedaad 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -236,7 +236,7 @@ static int do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
236 const u32 kvm_supported_word6_x86_features = 236 const u32 kvm_supported_word6_x86_features =
237 F(LAHF_LM) | F(CMP_LEGACY) | 0 /*SVM*/ | 0 /* ExtApicSpace */ | 237 F(LAHF_LM) | F(CMP_LEGACY) | 0 /*SVM*/ | 0 /* ExtApicSpace */ |
238 F(CR8_LEGACY) | F(ABM) | F(SSE4A) | F(MISALIGNSSE) | 238 F(CR8_LEGACY) | F(ABM) | F(SSE4A) | F(MISALIGNSSE) |
239 F(3DNOWPREFETCH) | 0 /* OSVW */ | 0 /* IBS */ | F(XOP) | 239 F(3DNOWPREFETCH) | F(OSVW) | 0 /* IBS */ | F(XOP) |
240 0 /* SKINIT, WDT, LWP */ | F(FMA4) | F(TBM); 240 0 /* SKINIT, WDT, LWP */ | F(FMA4) | F(TBM);
241 241
242 /* cpuid 0xC0000001.edx */ 242 /* cpuid 0xC0000001.edx */
diff --git a/arch/x86/kvm/cpuid.h b/arch/x86/kvm/cpuid.h
index 5b97e1797a6..26d1fb437eb 100644
--- a/arch/x86/kvm/cpuid.h
+++ b/arch/x86/kvm/cpuid.h
@@ -43,4 +43,12 @@ static inline bool guest_cpuid_has_fsgsbase(struct kvm_vcpu *vcpu)
43 return best && (best->ebx & bit(X86_FEATURE_FSGSBASE)); 43 return best && (best->ebx & bit(X86_FEATURE_FSGSBASE));
44} 44}
45 45
46static inline bool guest_cpuid_has_osvw(struct kvm_vcpu *vcpu)
47{
48 struct kvm_cpuid_entry2 *best;
49
50 best = kvm_find_cpuid_entry(vcpu, 0x80000001, 0);
51 return best && (best->ecx & bit(X86_FEATURE_OSVW));
52}
53
46#endif 54#endif
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 0982507b962..83756223f8a 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -57,6 +57,7 @@
57#define OpDS 23ull /* DS */ 57#define OpDS 23ull /* DS */
58#define OpFS 24ull /* FS */ 58#define OpFS 24ull /* FS */
59#define OpGS 25ull /* GS */ 59#define OpGS 25ull /* GS */
60#define OpMem8 26ull /* 8-bit zero extended memory operand */
60 61
61#define OpBits 5 /* Width of operand field */ 62#define OpBits 5 /* Width of operand field */
62#define OpMask ((1ull << OpBits) - 1) 63#define OpMask ((1ull << OpBits) - 1)
@@ -101,6 +102,7 @@
101#define SrcAcc (OpAcc << SrcShift) 102#define SrcAcc (OpAcc << SrcShift)
102#define SrcImmU16 (OpImmU16 << SrcShift) 103#define SrcImmU16 (OpImmU16 << SrcShift)
103#define SrcDX (OpDX << SrcShift) 104#define SrcDX (OpDX << SrcShift)
105#define SrcMem8 (OpMem8 << SrcShift)
104#define SrcMask (OpMask << SrcShift) 106#define SrcMask (OpMask << SrcShift)
105#define BitOp (1<<11) 107#define BitOp (1<<11)
106#define MemAbs (1<<12) /* Memory operand is absolute displacement */ 108#define MemAbs (1<<12) /* Memory operand is absolute displacement */
@@ -858,8 +860,7 @@ static void write_sse_reg(struct x86_emulate_ctxt *ctxt, sse128_t *data,
858} 860}
859 861
860static void decode_register_operand(struct x86_emulate_ctxt *ctxt, 862static void decode_register_operand(struct x86_emulate_ctxt *ctxt,
861 struct operand *op, 863 struct operand *op)
862 int inhibit_bytereg)
863{ 864{
864 unsigned reg = ctxt->modrm_reg; 865 unsigned reg = ctxt->modrm_reg;
865 int highbyte_regs = ctxt->rex_prefix == 0; 866 int highbyte_regs = ctxt->rex_prefix == 0;
@@ -876,7 +877,7 @@ static void decode_register_operand(struct x86_emulate_ctxt *ctxt,
876 } 877 }
877 878
878 op->type = OP_REG; 879 op->type = OP_REG;
879 if ((ctxt->d & ByteOp) && !inhibit_bytereg) { 880 if (ctxt->d & ByteOp) {
880 op->addr.reg = decode_register(reg, ctxt->regs, highbyte_regs); 881 op->addr.reg = decode_register(reg, ctxt->regs, highbyte_regs);
881 op->bytes = 1; 882 op->bytes = 1;
882 } else { 883 } else {
@@ -1151,6 +1152,22 @@ static int pio_in_emulated(struct x86_emulate_ctxt *ctxt,
1151 return 1; 1152 return 1;
1152} 1153}
1153 1154
1155static int read_interrupt_descriptor(struct x86_emulate_ctxt *ctxt,
1156 u16 index, struct desc_struct *desc)
1157{
1158 struct desc_ptr dt;
1159 ulong addr;
1160
1161 ctxt->ops->get_idt(ctxt, &dt);
1162
1163 if (dt.size < index * 8 + 7)
1164 return emulate_gp(ctxt, index << 3 | 0x2);
1165
1166 addr = dt.address + index * 8;
1167 return ctxt->ops->read_std(ctxt, addr, desc, sizeof *desc,
1168 &ctxt->exception);
1169}
1170
1154static void get_descriptor_table_ptr(struct x86_emulate_ctxt *ctxt, 1171static void get_descriptor_table_ptr(struct x86_emulate_ctxt *ctxt,
1155 u16 selector, struct desc_ptr *dt) 1172 u16 selector, struct desc_ptr *dt)
1156{ 1173{
@@ -1227,6 +1244,8 @@ static int load_segment_descriptor(struct x86_emulate_ctxt *ctxt,
1227 seg_desc.type = 3; 1244 seg_desc.type = 3;
1228 seg_desc.p = 1; 1245 seg_desc.p = 1;
1229 seg_desc.s = 1; 1246 seg_desc.s = 1;
1247 if (ctxt->mode == X86EMUL_MODE_VM86)
1248 seg_desc.dpl = 3;
1230 goto load; 1249 goto load;
1231 } 1250 }
1232 1251
@@ -1891,6 +1910,17 @@ setup_syscalls_segments(struct x86_emulate_ctxt *ctxt,
1891 ss->p = 1; 1910 ss->p = 1;
1892} 1911}
1893 1912
1913static bool vendor_intel(struct x86_emulate_ctxt *ctxt)
1914{
1915 u32 eax, ebx, ecx, edx;
1916
1917 eax = ecx = 0;
1918 return ctxt->ops->get_cpuid(ctxt, &eax, &ebx, &ecx, &edx)
1919 && ebx == X86EMUL_CPUID_VENDOR_GenuineIntel_ebx
1920 && ecx == X86EMUL_CPUID_VENDOR_GenuineIntel_ecx
1921 && edx == X86EMUL_CPUID_VENDOR_GenuineIntel_edx;
1922}
1923
1894static bool em_syscall_is_enabled(struct x86_emulate_ctxt *ctxt) 1924static bool em_syscall_is_enabled(struct x86_emulate_ctxt *ctxt)
1895{ 1925{
1896 struct x86_emulate_ops *ops = ctxt->ops; 1926 struct x86_emulate_ops *ops = ctxt->ops;
@@ -2007,6 +2037,14 @@ static int em_sysenter(struct x86_emulate_ctxt *ctxt)
2007 if (ctxt->mode == X86EMUL_MODE_REAL) 2037 if (ctxt->mode == X86EMUL_MODE_REAL)
2008 return emulate_gp(ctxt, 0); 2038 return emulate_gp(ctxt, 0);
2009 2039
2040 /*
2041 * Not recognized on AMD in compat mode (but is recognized in legacy
2042 * mode).
2043 */
2044 if ((ctxt->mode == X86EMUL_MODE_PROT32) && (efer & EFER_LMA)
2045 && !vendor_intel(ctxt))
2046 return emulate_ud(ctxt);
2047
2010 /* XXX sysenter/sysexit have not been tested in 64bit mode. 2048 /* XXX sysenter/sysexit have not been tested in 64bit mode.
2011 * Therefore, we inject an #UD. 2049 * Therefore, we inject an #UD.
2012 */ 2050 */
@@ -2306,6 +2344,8 @@ static int load_state_from_tss32(struct x86_emulate_ctxt *ctxt,
2306 return emulate_gp(ctxt, 0); 2344 return emulate_gp(ctxt, 0);
2307 ctxt->_eip = tss->eip; 2345 ctxt->_eip = tss->eip;
2308 ctxt->eflags = tss->eflags | 2; 2346 ctxt->eflags = tss->eflags | 2;
2347
2348 /* General purpose registers */
2309 ctxt->regs[VCPU_REGS_RAX] = tss->eax; 2349 ctxt->regs[VCPU_REGS_RAX] = tss->eax;
2310 ctxt->regs[VCPU_REGS_RCX] = tss->ecx; 2350 ctxt->regs[VCPU_REGS_RCX] = tss->ecx;
2311 ctxt->regs[VCPU_REGS_RDX] = tss->edx; 2351 ctxt->regs[VCPU_REGS_RDX] = tss->edx;
@@ -2328,6 +2368,24 @@ static int load_state_from_tss32(struct x86_emulate_ctxt *ctxt,
2328 set_segment_selector(ctxt, tss->gs, VCPU_SREG_GS); 2368 set_segment_selector(ctxt, tss->gs, VCPU_SREG_GS);
2329 2369
2330 /* 2370 /*
2371 * If we're switching between Protected Mode and VM86, we need to make
2372 * sure to update the mode before loading the segment descriptors so
2373 * that the selectors are interpreted correctly.
2374 *
2375 * Need to get rflags to the vcpu struct immediately because it
2376 * influences the CPL which is checked at least when loading the segment
2377 * descriptors and when pushing an error code to the new kernel stack.
2378 *
2379 * TODO Introduce a separate ctxt->ops->set_cpl callback
2380 */
2381 if (ctxt->eflags & X86_EFLAGS_VM)
2382 ctxt->mode = X86EMUL_MODE_VM86;
2383 else
2384 ctxt->mode = X86EMUL_MODE_PROT32;
2385
2386 ctxt->ops->set_rflags(ctxt, ctxt->eflags);
2387
2388 /*
2331 * Now load segment descriptors. If fault happenes at this stage 2389 * Now load segment descriptors. If fault happenes at this stage
2332 * it is handled in a context of new task 2390 * it is handled in a context of new task
2333 */ 2391 */
@@ -2401,7 +2459,7 @@ static int task_switch_32(struct x86_emulate_ctxt *ctxt,
2401} 2459}
2402 2460
2403static int emulator_do_task_switch(struct x86_emulate_ctxt *ctxt, 2461static int emulator_do_task_switch(struct x86_emulate_ctxt *ctxt,
2404 u16 tss_selector, int reason, 2462 u16 tss_selector, int idt_index, int reason,
2405 bool has_error_code, u32 error_code) 2463 bool has_error_code, u32 error_code)
2406{ 2464{
2407 struct x86_emulate_ops *ops = ctxt->ops; 2465 struct x86_emulate_ops *ops = ctxt->ops;
@@ -2423,12 +2481,35 @@ static int emulator_do_task_switch(struct x86_emulate_ctxt *ctxt,
2423 2481
2424 /* FIXME: check that next_tss_desc is tss */ 2482 /* FIXME: check that next_tss_desc is tss */
2425 2483
2426 if (reason != TASK_SWITCH_IRET) { 2484 /*
2427 if ((tss_selector & 3) > next_tss_desc.dpl || 2485 * Check privileges. The three cases are task switch caused by...
2428 ops->cpl(ctxt) > next_tss_desc.dpl) 2486 *
2429 return emulate_gp(ctxt, 0); 2487 * 1. jmp/call/int to task gate: Check against DPL of the task gate
2488 * 2. Exception/IRQ/iret: No check is performed
2489 * 3. jmp/call to TSS: Check agains DPL of the TSS
2490 */
2491 if (reason == TASK_SWITCH_GATE) {
2492 if (idt_index != -1) {
2493 /* Software interrupts */
2494 struct desc_struct task_gate_desc;
2495 int dpl;
2496
2497 ret = read_interrupt_descriptor(ctxt, idt_index,
2498 &task_gate_desc);
2499 if (ret != X86EMUL_CONTINUE)
2500 return ret;
2501
2502 dpl = task_gate_desc.dpl;
2503 if ((tss_selector & 3) > dpl || ops->cpl(ctxt) > dpl)
2504 return emulate_gp(ctxt, (idt_index << 3) | 0x2);
2505 }
2506 } else if (reason != TASK_SWITCH_IRET) {
2507 int dpl = next_tss_desc.dpl;
2508 if ((tss_selector & 3) > dpl || ops->cpl(ctxt) > dpl)
2509 return emulate_gp(ctxt, tss_selector);
2430 } 2510 }
2431 2511
2512
2432 desc_limit = desc_limit_scaled(&next_tss_desc); 2513 desc_limit = desc_limit_scaled(&next_tss_desc);
2433 if (!next_tss_desc.p || 2514 if (!next_tss_desc.p ||
2434 ((desc_limit < 0x67 && (next_tss_desc.type & 8)) || 2515 ((desc_limit < 0x67 && (next_tss_desc.type & 8)) ||
@@ -2481,7 +2562,7 @@ static int emulator_do_task_switch(struct x86_emulate_ctxt *ctxt,
2481} 2562}
2482 2563
2483int emulator_task_switch(struct x86_emulate_ctxt *ctxt, 2564int emulator_task_switch(struct x86_emulate_ctxt *ctxt,
2484 u16 tss_selector, int reason, 2565 u16 tss_selector, int idt_index, int reason,
2485 bool has_error_code, u32 error_code) 2566 bool has_error_code, u32 error_code)
2486{ 2567{
2487 int rc; 2568 int rc;
@@ -2489,7 +2570,7 @@ int emulator_task_switch(struct x86_emulate_ctxt *ctxt,
2489 ctxt->_eip = ctxt->eip; 2570 ctxt->_eip = ctxt->eip;
2490 ctxt->dst.type = OP_NONE; 2571 ctxt->dst.type = OP_NONE;
2491 2572
2492 rc = emulator_do_task_switch(ctxt, tss_selector, reason, 2573 rc = emulator_do_task_switch(ctxt, tss_selector, idt_index, reason,
2493 has_error_code, error_code); 2574 has_error_code, error_code);
2494 2575
2495 if (rc == X86EMUL_CONTINUE) 2576 if (rc == X86EMUL_CONTINUE)
@@ -3514,13 +3595,13 @@ static struct opcode twobyte_table[256] = {
3514 I(DstMem | SrcReg | ModRM | BitOp | Lock, em_btr), 3595 I(DstMem | SrcReg | ModRM | BitOp | Lock, em_btr),
3515 I(DstReg | SrcMemFAddr | ModRM | Src2FS, em_lseg), 3596 I(DstReg | SrcMemFAddr | ModRM | Src2FS, em_lseg),
3516 I(DstReg | SrcMemFAddr | ModRM | Src2GS, em_lseg), 3597 I(DstReg | SrcMemFAddr | ModRM | Src2GS, em_lseg),
3517 D(ByteOp | DstReg | SrcMem | ModRM | Mov), D(DstReg | SrcMem16 | ModRM | Mov), 3598 D(DstReg | SrcMem8 | ModRM | Mov), D(DstReg | SrcMem16 | ModRM | Mov),
3518 /* 0xB8 - 0xBF */ 3599 /* 0xB8 - 0xBF */
3519 N, N, 3600 N, N,
3520 G(BitOp, group8), 3601 G(BitOp, group8),
3521 I(DstMem | SrcReg | ModRM | BitOp | Lock | PageTable, em_btc), 3602 I(DstMem | SrcReg | ModRM | BitOp | Lock | PageTable, em_btc),
3522 I(DstReg | SrcMem | ModRM, em_bsf), I(DstReg | SrcMem | ModRM, em_bsr), 3603 I(DstReg | SrcMem | ModRM, em_bsf), I(DstReg | SrcMem | ModRM, em_bsr),
3523 D(ByteOp | DstReg | SrcMem | ModRM | Mov), D(DstReg | SrcMem16 | ModRM | Mov), 3604 D(DstReg | SrcMem8 | ModRM | Mov), D(DstReg | SrcMem16 | ModRM | Mov),
3524 /* 0xC0 - 0xCF */ 3605 /* 0xC0 - 0xCF */
3525 D2bv(DstMem | SrcReg | ModRM | Lock), 3606 D2bv(DstMem | SrcReg | ModRM | Lock),
3526 N, D(DstMem | SrcReg | ModRM | Mov), 3607 N, D(DstMem | SrcReg | ModRM | Mov),
@@ -3602,9 +3683,7 @@ static int decode_operand(struct x86_emulate_ctxt *ctxt, struct operand *op,
3602 3683
3603 switch (d) { 3684 switch (d) {
3604 case OpReg: 3685 case OpReg:
3605 decode_register_operand(ctxt, op, 3686 decode_register_operand(ctxt, op);
3606 op == &ctxt->dst &&
3607 ctxt->twobyte && (ctxt->b == 0xb6 || ctxt->b == 0xb7));
3608 break; 3687 break;
3609 case OpImmUByte: 3688 case OpImmUByte:
3610 rc = decode_imm(ctxt, op, 1, false); 3689 rc = decode_imm(ctxt, op, 1, false);
@@ -3656,6 +3735,9 @@ static int decode_operand(struct x86_emulate_ctxt *ctxt, struct operand *op,
3656 case OpImm: 3735 case OpImm:
3657 rc = decode_imm(ctxt, op, imm_size(ctxt), true); 3736 rc = decode_imm(ctxt, op, imm_size(ctxt), true);
3658 break; 3737 break;
3738 case OpMem8:
3739 ctxt->memop.bytes = 1;
3740 goto mem_common;
3659 case OpMem16: 3741 case OpMem16:
3660 ctxt->memop.bytes = 2; 3742 ctxt->memop.bytes = 2;
3661 goto mem_common; 3743 goto mem_common;
diff --git a/arch/x86/kvm/i8259.c b/arch/x86/kvm/i8259.c
index b6a73537e1e..81cf4fa4a2b 100644
--- a/arch/x86/kvm/i8259.c
+++ b/arch/x86/kvm/i8259.c
@@ -307,6 +307,7 @@ static void pic_ioport_write(void *opaque, u32 addr, u32 val)
307 if (val & 0x10) { 307 if (val & 0x10) {
308 s->init4 = val & 1; 308 s->init4 = val & 1;
309 s->last_irr = 0; 309 s->last_irr = 0;
310 s->irr &= s->elcr;
310 s->imr = 0; 311 s->imr = 0;
311 s->priority_add = 0; 312 s->priority_add = 0;
312 s->special_mask = 0; 313 s->special_mask = 0;
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 31bfc6927bc..858432287ab 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -433,7 +433,7 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
433 break; 433 break;
434 434
435 case APIC_DM_INIT: 435 case APIC_DM_INIT:
436 if (level) { 436 if (!trig_mode || level) {
437 result = 1; 437 result = 1;
438 vcpu->arch.mp_state = KVM_MP_STATE_INIT_RECEIVED; 438 vcpu->arch.mp_state = KVM_MP_STATE_INIT_RECEIVED;
439 kvm_make_request(KVM_REQ_EVENT, vcpu); 439 kvm_make_request(KVM_REQ_EVENT, vcpu);
@@ -731,7 +731,7 @@ static void start_apic_timer(struct kvm_lapic *apic)
731 u64 guest_tsc, tscdeadline = apic->lapic_timer.tscdeadline; 731 u64 guest_tsc, tscdeadline = apic->lapic_timer.tscdeadline;
732 u64 ns = 0; 732 u64 ns = 0;
733 struct kvm_vcpu *vcpu = apic->vcpu; 733 struct kvm_vcpu *vcpu = apic->vcpu;
734 unsigned long this_tsc_khz = vcpu_tsc_khz(vcpu); 734 unsigned long this_tsc_khz = vcpu->arch.virtual_tsc_khz;
735 unsigned long flags; 735 unsigned long flags;
736 736
737 if (unlikely(!tscdeadline || !this_tsc_khz)) 737 if (unlikely(!tscdeadline || !this_tsc_khz))
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 224b02c3cda..4cb16426884 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -688,9 +688,8 @@ static struct kvm_lpage_info *lpage_info_slot(gfn_t gfn,
688{ 688{
689 unsigned long idx; 689 unsigned long idx;
690 690
691 idx = (gfn >> KVM_HPAGE_GFN_SHIFT(level)) - 691 idx = gfn_to_index(gfn, slot->base_gfn, level);
692 (slot->base_gfn >> KVM_HPAGE_GFN_SHIFT(level)); 692 return &slot->arch.lpage_info[level - 2][idx];
693 return &slot->lpage_info[level - 2][idx];
694} 693}
695 694
696static void account_shadowed(struct kvm *kvm, gfn_t gfn) 695static void account_shadowed(struct kvm *kvm, gfn_t gfn)
@@ -946,7 +945,7 @@ static void pte_list_walk(unsigned long *pte_list, pte_list_walk_fn fn)
946 } 945 }
947} 946}
948 947
949static unsigned long *__gfn_to_rmap(struct kvm *kvm, gfn_t gfn, int level, 948static unsigned long *__gfn_to_rmap(gfn_t gfn, int level,
950 struct kvm_memory_slot *slot) 949 struct kvm_memory_slot *slot)
951{ 950{
952 struct kvm_lpage_info *linfo; 951 struct kvm_lpage_info *linfo;
@@ -966,7 +965,7 @@ static unsigned long *gfn_to_rmap(struct kvm *kvm, gfn_t gfn, int level)
966 struct kvm_memory_slot *slot; 965 struct kvm_memory_slot *slot;
967 966
968 slot = gfn_to_memslot(kvm, gfn); 967 slot = gfn_to_memslot(kvm, gfn);
969 return __gfn_to_rmap(kvm, gfn, level, slot); 968 return __gfn_to_rmap(gfn, level, slot);
970} 969}
971 970
972static bool rmap_can_add(struct kvm_vcpu *vcpu) 971static bool rmap_can_add(struct kvm_vcpu *vcpu)
@@ -988,7 +987,7 @@ static int rmap_add(struct kvm_vcpu *vcpu, u64 *spte, gfn_t gfn)
988 return pte_list_add(vcpu, spte, rmapp); 987 return pte_list_add(vcpu, spte, rmapp);
989} 988}
990 989
991static u64 *rmap_next(struct kvm *kvm, unsigned long *rmapp, u64 *spte) 990static u64 *rmap_next(unsigned long *rmapp, u64 *spte)
992{ 991{
993 return pte_list_next(rmapp, spte); 992 return pte_list_next(rmapp, spte);
994} 993}
@@ -1018,8 +1017,8 @@ int kvm_mmu_rmap_write_protect(struct kvm *kvm, u64 gfn,
1018 u64 *spte; 1017 u64 *spte;
1019 int i, write_protected = 0; 1018 int i, write_protected = 0;
1020 1019
1021 rmapp = __gfn_to_rmap(kvm, gfn, PT_PAGE_TABLE_LEVEL, slot); 1020 rmapp = __gfn_to_rmap(gfn, PT_PAGE_TABLE_LEVEL, slot);
1022 spte = rmap_next(kvm, rmapp, NULL); 1021 spte = rmap_next(rmapp, NULL);
1023 while (spte) { 1022 while (spte) {
1024 BUG_ON(!(*spte & PT_PRESENT_MASK)); 1023 BUG_ON(!(*spte & PT_PRESENT_MASK));
1025 rmap_printk("rmap_write_protect: spte %p %llx\n", spte, *spte); 1024 rmap_printk("rmap_write_protect: spte %p %llx\n", spte, *spte);
@@ -1027,14 +1026,14 @@ int kvm_mmu_rmap_write_protect(struct kvm *kvm, u64 gfn,
1027 mmu_spte_update(spte, *spte & ~PT_WRITABLE_MASK); 1026 mmu_spte_update(spte, *spte & ~PT_WRITABLE_MASK);
1028 write_protected = 1; 1027 write_protected = 1;
1029 } 1028 }
1030 spte = rmap_next(kvm, rmapp, spte); 1029 spte = rmap_next(rmapp, spte);
1031 } 1030 }
1032 1031
1033 /* check for huge page mappings */ 1032 /* check for huge page mappings */
1034 for (i = PT_DIRECTORY_LEVEL; 1033 for (i = PT_DIRECTORY_LEVEL;
1035 i < PT_PAGE_TABLE_LEVEL + KVM_NR_PAGE_SIZES; ++i) { 1034 i < PT_PAGE_TABLE_LEVEL + KVM_NR_PAGE_SIZES; ++i) {
1036 rmapp = __gfn_to_rmap(kvm, gfn, i, slot); 1035 rmapp = __gfn_to_rmap(gfn, i, slot);
1037 spte = rmap_next(kvm, rmapp, NULL); 1036 spte = rmap_next(rmapp, NULL);
1038 while (spte) { 1037 while (spte) {
1039 BUG_ON(!(*spte & PT_PRESENT_MASK)); 1038 BUG_ON(!(*spte & PT_PRESENT_MASK));
1040 BUG_ON(!is_large_pte(*spte)); 1039 BUG_ON(!is_large_pte(*spte));
@@ -1045,7 +1044,7 @@ int kvm_mmu_rmap_write_protect(struct kvm *kvm, u64 gfn,
1045 spte = NULL; 1044 spte = NULL;
1046 write_protected = 1; 1045 write_protected = 1;
1047 } 1046 }
1048 spte = rmap_next(kvm, rmapp, spte); 1047 spte = rmap_next(rmapp, spte);
1049 } 1048 }
1050 } 1049 }
1051 1050
@@ -1066,7 +1065,7 @@ static int kvm_unmap_rmapp(struct kvm *kvm, unsigned long *rmapp,
1066 u64 *spte; 1065 u64 *spte;
1067 int need_tlb_flush = 0; 1066 int need_tlb_flush = 0;
1068 1067
1069 while ((spte = rmap_next(kvm, rmapp, NULL))) { 1068 while ((spte = rmap_next(rmapp, NULL))) {
1070 BUG_ON(!(*spte & PT_PRESENT_MASK)); 1069 BUG_ON(!(*spte & PT_PRESENT_MASK));
1071 rmap_printk("kvm_rmap_unmap_hva: spte %p %llx\n", spte, *spte); 1070 rmap_printk("kvm_rmap_unmap_hva: spte %p %llx\n", spte, *spte);
1072 drop_spte(kvm, spte); 1071 drop_spte(kvm, spte);
@@ -1085,14 +1084,14 @@ static int kvm_set_pte_rmapp(struct kvm *kvm, unsigned long *rmapp,
1085 1084
1086 WARN_ON(pte_huge(*ptep)); 1085 WARN_ON(pte_huge(*ptep));
1087 new_pfn = pte_pfn(*ptep); 1086 new_pfn = pte_pfn(*ptep);
1088 spte = rmap_next(kvm, rmapp, NULL); 1087 spte = rmap_next(rmapp, NULL);
1089 while (spte) { 1088 while (spte) {
1090 BUG_ON(!is_shadow_present_pte(*spte)); 1089 BUG_ON(!is_shadow_present_pte(*spte));
1091 rmap_printk("kvm_set_pte_rmapp: spte %p %llx\n", spte, *spte); 1090 rmap_printk("kvm_set_pte_rmapp: spte %p %llx\n", spte, *spte);
1092 need_flush = 1; 1091 need_flush = 1;
1093 if (pte_write(*ptep)) { 1092 if (pte_write(*ptep)) {
1094 drop_spte(kvm, spte); 1093 drop_spte(kvm, spte);
1095 spte = rmap_next(kvm, rmapp, NULL); 1094 spte = rmap_next(rmapp, NULL);
1096 } else { 1095 } else {
1097 new_spte = *spte &~ (PT64_BASE_ADDR_MASK); 1096 new_spte = *spte &~ (PT64_BASE_ADDR_MASK);
1098 new_spte |= (u64)new_pfn << PAGE_SHIFT; 1097 new_spte |= (u64)new_pfn << PAGE_SHIFT;
@@ -1102,7 +1101,7 @@ static int kvm_set_pte_rmapp(struct kvm *kvm, unsigned long *rmapp,
1102 new_spte &= ~shadow_accessed_mask; 1101 new_spte &= ~shadow_accessed_mask;
1103 mmu_spte_clear_track_bits(spte); 1102 mmu_spte_clear_track_bits(spte);
1104 mmu_spte_set(spte, new_spte); 1103 mmu_spte_set(spte, new_spte);
1105 spte = rmap_next(kvm, rmapp, spte); 1104 spte = rmap_next(rmapp, spte);
1106 } 1105 }
1107 } 1106 }
1108 if (need_flush) 1107 if (need_flush)
@@ -1176,7 +1175,7 @@ static int kvm_age_rmapp(struct kvm *kvm, unsigned long *rmapp,
1176 if (!shadow_accessed_mask) 1175 if (!shadow_accessed_mask)
1177 return kvm_unmap_rmapp(kvm, rmapp, data); 1176 return kvm_unmap_rmapp(kvm, rmapp, data);
1178 1177
1179 spte = rmap_next(kvm, rmapp, NULL); 1178 spte = rmap_next(rmapp, NULL);
1180 while (spte) { 1179 while (spte) {
1181 int _young; 1180 int _young;
1182 u64 _spte = *spte; 1181 u64 _spte = *spte;
@@ -1186,7 +1185,7 @@ static int kvm_age_rmapp(struct kvm *kvm, unsigned long *rmapp,
1186 young = 1; 1185 young = 1;
1187 clear_bit(PT_ACCESSED_SHIFT, (unsigned long *)spte); 1186 clear_bit(PT_ACCESSED_SHIFT, (unsigned long *)spte);
1188 } 1187 }
1189 spte = rmap_next(kvm, rmapp, spte); 1188 spte = rmap_next(rmapp, spte);
1190 } 1189 }
1191 return young; 1190 return young;
1192} 1191}
@@ -1205,7 +1204,7 @@ static int kvm_test_age_rmapp(struct kvm *kvm, unsigned long *rmapp,
1205 if (!shadow_accessed_mask) 1204 if (!shadow_accessed_mask)
1206 goto out; 1205 goto out;
1207 1206
1208 spte = rmap_next(kvm, rmapp, NULL); 1207 spte = rmap_next(rmapp, NULL);
1209 while (spte) { 1208 while (spte) {
1210 u64 _spte = *spte; 1209 u64 _spte = *spte;
1211 BUG_ON(!(_spte & PT_PRESENT_MASK)); 1210 BUG_ON(!(_spte & PT_PRESENT_MASK));
@@ -1214,7 +1213,7 @@ static int kvm_test_age_rmapp(struct kvm *kvm, unsigned long *rmapp,
1214 young = 1; 1213 young = 1;
1215 break; 1214 break;
1216 } 1215 }
1217 spte = rmap_next(kvm, rmapp, spte); 1216 spte = rmap_next(rmapp, spte);
1218 } 1217 }
1219out: 1218out:
1220 return young; 1219 return young;
@@ -1391,11 +1390,6 @@ struct kvm_mmu_pages {
1391 unsigned int nr; 1390 unsigned int nr;
1392}; 1391};
1393 1392
1394#define for_each_unsync_children(bitmap, idx) \
1395 for (idx = find_first_bit(bitmap, 512); \
1396 idx < 512; \
1397 idx = find_next_bit(bitmap, 512, idx+1))
1398
1399static int mmu_pages_add(struct kvm_mmu_pages *pvec, struct kvm_mmu_page *sp, 1393static int mmu_pages_add(struct kvm_mmu_pages *pvec, struct kvm_mmu_page *sp,
1400 int idx) 1394 int idx)
1401{ 1395{
@@ -1417,7 +1411,7 @@ static int __mmu_unsync_walk(struct kvm_mmu_page *sp,
1417{ 1411{
1418 int i, ret, nr_unsync_leaf = 0; 1412 int i, ret, nr_unsync_leaf = 0;
1419 1413
1420 for_each_unsync_children(sp->unsync_child_bitmap, i) { 1414 for_each_set_bit(i, sp->unsync_child_bitmap, 512) {
1421 struct kvm_mmu_page *child; 1415 struct kvm_mmu_page *child;
1422 u64 ent = sp->spt[i]; 1416 u64 ent = sp->spt[i];
1423 1417
@@ -1803,6 +1797,7 @@ static void drop_large_spte(struct kvm_vcpu *vcpu, u64 *sptep)
1803{ 1797{
1804 if (is_large_pte(*sptep)) { 1798 if (is_large_pte(*sptep)) {
1805 drop_spte(vcpu->kvm, sptep); 1799 drop_spte(vcpu->kvm, sptep);
1800 --vcpu->kvm->stat.lpages;
1806 kvm_flush_remote_tlbs(vcpu->kvm); 1801 kvm_flush_remote_tlbs(vcpu->kvm);
1807 } 1802 }
1808} 1803}
@@ -3190,15 +3185,14 @@ static bool sync_mmio_spte(u64 *sptep, gfn_t gfn, unsigned access,
3190#undef PTTYPE 3185#undef PTTYPE
3191 3186
3192static void reset_rsvds_bits_mask(struct kvm_vcpu *vcpu, 3187static void reset_rsvds_bits_mask(struct kvm_vcpu *vcpu,
3193 struct kvm_mmu *context, 3188 struct kvm_mmu *context)
3194 int level)
3195{ 3189{
3196 int maxphyaddr = cpuid_maxphyaddr(vcpu); 3190 int maxphyaddr = cpuid_maxphyaddr(vcpu);
3197 u64 exb_bit_rsvd = 0; 3191 u64 exb_bit_rsvd = 0;
3198 3192
3199 if (!context->nx) 3193 if (!context->nx)
3200 exb_bit_rsvd = rsvd_bits(63, 63); 3194 exb_bit_rsvd = rsvd_bits(63, 63);
3201 switch (level) { 3195 switch (context->root_level) {
3202 case PT32_ROOT_LEVEL: 3196 case PT32_ROOT_LEVEL:
3203 /* no rsvd bits for 2 level 4K page table entries */ 3197 /* no rsvd bits for 2 level 4K page table entries */
3204 context->rsvd_bits_mask[0][1] = 0; 3198 context->rsvd_bits_mask[0][1] = 0;
@@ -3256,8 +3250,9 @@ static int paging64_init_context_common(struct kvm_vcpu *vcpu,
3256 int level) 3250 int level)
3257{ 3251{
3258 context->nx = is_nx(vcpu); 3252 context->nx = is_nx(vcpu);
3253 context->root_level = level;
3259 3254
3260 reset_rsvds_bits_mask(vcpu, context, level); 3255 reset_rsvds_bits_mask(vcpu, context);
3261 3256
3262 ASSERT(is_pae(vcpu)); 3257 ASSERT(is_pae(vcpu));
3263 context->new_cr3 = paging_new_cr3; 3258 context->new_cr3 = paging_new_cr3;
@@ -3267,7 +3262,6 @@ static int paging64_init_context_common(struct kvm_vcpu *vcpu,
3267 context->invlpg = paging64_invlpg; 3262 context->invlpg = paging64_invlpg;
3268 context->update_pte = paging64_update_pte; 3263 context->update_pte = paging64_update_pte;
3269 context->free = paging_free; 3264 context->free = paging_free;
3270 context->root_level = level;
3271 context->shadow_root_level = level; 3265 context->shadow_root_level = level;
3272 context->root_hpa = INVALID_PAGE; 3266 context->root_hpa = INVALID_PAGE;
3273 context->direct_map = false; 3267 context->direct_map = false;
@@ -3284,8 +3278,9 @@ static int paging32_init_context(struct kvm_vcpu *vcpu,
3284 struct kvm_mmu *context) 3278 struct kvm_mmu *context)
3285{ 3279{
3286 context->nx = false; 3280 context->nx = false;
3281 context->root_level = PT32_ROOT_LEVEL;
3287 3282
3288 reset_rsvds_bits_mask(vcpu, context, PT32_ROOT_LEVEL); 3283 reset_rsvds_bits_mask(vcpu, context);
3289 3284
3290 context->new_cr3 = paging_new_cr3; 3285 context->new_cr3 = paging_new_cr3;
3291 context->page_fault = paging32_page_fault; 3286 context->page_fault = paging32_page_fault;
@@ -3294,7 +3289,6 @@ static int paging32_init_context(struct kvm_vcpu *vcpu,
3294 context->sync_page = paging32_sync_page; 3289 context->sync_page = paging32_sync_page;
3295 context->invlpg = paging32_invlpg; 3290 context->invlpg = paging32_invlpg;
3296 context->update_pte = paging32_update_pte; 3291 context->update_pte = paging32_update_pte;
3297 context->root_level = PT32_ROOT_LEVEL;
3298 context->shadow_root_level = PT32E_ROOT_LEVEL; 3292 context->shadow_root_level = PT32E_ROOT_LEVEL;
3299 context->root_hpa = INVALID_PAGE; 3293 context->root_hpa = INVALID_PAGE;
3300 context->direct_map = false; 3294 context->direct_map = false;
@@ -3325,7 +3319,6 @@ static int init_kvm_tdp_mmu(struct kvm_vcpu *vcpu)
3325 context->get_cr3 = get_cr3; 3319 context->get_cr3 = get_cr3;
3326 context->get_pdptr = kvm_pdptr_read; 3320 context->get_pdptr = kvm_pdptr_read;
3327 context->inject_page_fault = kvm_inject_page_fault; 3321 context->inject_page_fault = kvm_inject_page_fault;
3328 context->nx = is_nx(vcpu);
3329 3322
3330 if (!is_paging(vcpu)) { 3323 if (!is_paging(vcpu)) {
3331 context->nx = false; 3324 context->nx = false;
@@ -3333,19 +3326,19 @@ static int init_kvm_tdp_mmu(struct kvm_vcpu *vcpu)
3333 context->root_level = 0; 3326 context->root_level = 0;
3334 } else if (is_long_mode(vcpu)) { 3327 } else if (is_long_mode(vcpu)) {
3335 context->nx = is_nx(vcpu); 3328 context->nx = is_nx(vcpu);
3336 reset_rsvds_bits_mask(vcpu, context, PT64_ROOT_LEVEL);
3337 context->gva_to_gpa = paging64_gva_to_gpa;
3338 context->root_level = PT64_ROOT_LEVEL; 3329 context->root_level = PT64_ROOT_LEVEL;
3330 reset_rsvds_bits_mask(vcpu, context);
3331 context->gva_to_gpa = paging64_gva_to_gpa;
3339 } else if (is_pae(vcpu)) { 3332 } else if (is_pae(vcpu)) {
3340 context->nx = is_nx(vcpu); 3333 context->nx = is_nx(vcpu);
3341 reset_rsvds_bits_mask(vcpu, context, PT32E_ROOT_LEVEL);
3342 context->gva_to_gpa = paging64_gva_to_gpa;
3343 context->root_level = PT32E_ROOT_LEVEL; 3334 context->root_level = PT32E_ROOT_LEVEL;
3335 reset_rsvds_bits_mask(vcpu, context);
3336 context->gva_to_gpa = paging64_gva_to_gpa;
3344 } else { 3337 } else {
3345 context->nx = false; 3338 context->nx = false;
3346 reset_rsvds_bits_mask(vcpu, context, PT32_ROOT_LEVEL);
3347 context->gva_to_gpa = paging32_gva_to_gpa;
3348 context->root_level = PT32_ROOT_LEVEL; 3339 context->root_level = PT32_ROOT_LEVEL;
3340 reset_rsvds_bits_mask(vcpu, context);
3341 context->gva_to_gpa = paging32_gva_to_gpa;
3349 } 3342 }
3350 3343
3351 return 0; 3344 return 0;
@@ -3408,18 +3401,18 @@ static int init_kvm_nested_mmu(struct kvm_vcpu *vcpu)
3408 g_context->gva_to_gpa = nonpaging_gva_to_gpa_nested; 3401 g_context->gva_to_gpa = nonpaging_gva_to_gpa_nested;
3409 } else if (is_long_mode(vcpu)) { 3402 } else if (is_long_mode(vcpu)) {
3410 g_context->nx = is_nx(vcpu); 3403 g_context->nx = is_nx(vcpu);
3411 reset_rsvds_bits_mask(vcpu, g_context, PT64_ROOT_LEVEL);
3412 g_context->root_level = PT64_ROOT_LEVEL; 3404 g_context->root_level = PT64_ROOT_LEVEL;
3405 reset_rsvds_bits_mask(vcpu, g_context);
3413 g_context->gva_to_gpa = paging64_gva_to_gpa_nested; 3406 g_context->gva_to_gpa = paging64_gva_to_gpa_nested;
3414 } else if (is_pae(vcpu)) { 3407 } else if (is_pae(vcpu)) {
3415 g_context->nx = is_nx(vcpu); 3408 g_context->nx = is_nx(vcpu);
3416 reset_rsvds_bits_mask(vcpu, g_context, PT32E_ROOT_LEVEL);
3417 g_context->root_level = PT32E_ROOT_LEVEL; 3409 g_context->root_level = PT32E_ROOT_LEVEL;
3410 reset_rsvds_bits_mask(vcpu, g_context);
3418 g_context->gva_to_gpa = paging64_gva_to_gpa_nested; 3411 g_context->gva_to_gpa = paging64_gva_to_gpa_nested;
3419 } else { 3412 } else {
3420 g_context->nx = false; 3413 g_context->nx = false;
3421 reset_rsvds_bits_mask(vcpu, g_context, PT32_ROOT_LEVEL);
3422 g_context->root_level = PT32_ROOT_LEVEL; 3414 g_context->root_level = PT32_ROOT_LEVEL;
3415 reset_rsvds_bits_mask(vcpu, g_context);
3423 g_context->gva_to_gpa = paging32_gva_to_gpa_nested; 3416 g_context->gva_to_gpa = paging32_gva_to_gpa_nested;
3424 } 3417 }
3425 3418
@@ -3555,7 +3548,7 @@ static u64 mmu_pte_write_fetch_gpte(struct kvm_vcpu *vcpu, gpa_t *gpa,
3555 * If we're seeing too many writes to a page, it may no longer be a page table, 3548 * If we're seeing too many writes to a page, it may no longer be a page table,
3556 * or we may be forking, in which case it is better to unmap the page. 3549 * or we may be forking, in which case it is better to unmap the page.
3557 */ 3550 */
3558static bool detect_write_flooding(struct kvm_mmu_page *sp, u64 *spte) 3551static bool detect_write_flooding(struct kvm_mmu_page *sp)
3559{ 3552{
3560 /* 3553 /*
3561 * Skip write-flooding detected for the sp whose level is 1, because 3554 * Skip write-flooding detected for the sp whose level is 1, because
@@ -3664,10 +3657,8 @@ void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
3664 3657
3665 mask.cr0_wp = mask.cr4_pae = mask.nxe = 1; 3658 mask.cr0_wp = mask.cr4_pae = mask.nxe = 1;
3666 for_each_gfn_indirect_valid_sp(vcpu->kvm, sp, gfn, node) { 3659 for_each_gfn_indirect_valid_sp(vcpu->kvm, sp, gfn, node) {
3667 spte = get_written_sptes(sp, gpa, &npte);
3668
3669 if (detect_write_misaligned(sp, gpa, bytes) || 3660 if (detect_write_misaligned(sp, gpa, bytes) ||
3670 detect_write_flooding(sp, spte)) { 3661 detect_write_flooding(sp)) {
3671 zap_page |= !!kvm_mmu_prepare_zap_page(vcpu->kvm, sp, 3662 zap_page |= !!kvm_mmu_prepare_zap_page(vcpu->kvm, sp,
3672 &invalid_list); 3663 &invalid_list);
3673 ++vcpu->kvm->stat.mmu_flooded; 3664 ++vcpu->kvm->stat.mmu_flooded;
diff --git a/arch/x86/kvm/mmu_audit.c b/arch/x86/kvm/mmu_audit.c
index ea7b4fd3467..715da5a19a5 100644
--- a/arch/x86/kvm/mmu_audit.c
+++ b/arch/x86/kvm/mmu_audit.c
@@ -200,13 +200,13 @@ static void audit_write_protection(struct kvm *kvm, struct kvm_mmu_page *sp)
200 slot = gfn_to_memslot(kvm, sp->gfn); 200 slot = gfn_to_memslot(kvm, sp->gfn);
201 rmapp = &slot->rmap[sp->gfn - slot->base_gfn]; 201 rmapp = &slot->rmap[sp->gfn - slot->base_gfn];
202 202
203 spte = rmap_next(kvm, rmapp, NULL); 203 spte = rmap_next(rmapp, NULL);
204 while (spte) { 204 while (spte) {
205 if (is_writable_pte(*spte)) 205 if (is_writable_pte(*spte))
206 audit_printk(kvm, "shadow page has writable " 206 audit_printk(kvm, "shadow page has writable "
207 "mappings: gfn %llx role %x\n", 207 "mappings: gfn %llx role %x\n",
208 sp->gfn, sp->role.word); 208 sp->gfn, sp->role.word);
209 spte = rmap_next(kvm, rmapp, spte); 209 spte = rmap_next(rmapp, spte);
210 } 210 }
211} 211}
212 212
diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c
index 7aad5446f39..a73f0c10481 100644
--- a/arch/x86/kvm/pmu.c
+++ b/arch/x86/kvm/pmu.c
@@ -33,10 +33,11 @@ static struct kvm_arch_event_perf_mapping {
33 [4] = { 0x2e, 0x41, PERF_COUNT_HW_CACHE_MISSES }, 33 [4] = { 0x2e, 0x41, PERF_COUNT_HW_CACHE_MISSES },
34 [5] = { 0xc4, 0x00, PERF_COUNT_HW_BRANCH_INSTRUCTIONS }, 34 [5] = { 0xc4, 0x00, PERF_COUNT_HW_BRANCH_INSTRUCTIONS },
35 [6] = { 0xc5, 0x00, PERF_COUNT_HW_BRANCH_MISSES }, 35 [6] = { 0xc5, 0x00, PERF_COUNT_HW_BRANCH_MISSES },
36 [7] = { 0x00, 0x30, PERF_COUNT_HW_REF_CPU_CYCLES },
36}; 37};
37 38
38/* mapping between fixed pmc index and arch_events array */ 39/* mapping between fixed pmc index and arch_events array */
39int fixed_pmc_events[] = {1, 0, 2}; 40int fixed_pmc_events[] = {1, 0, 7};
40 41
41static bool pmc_is_gp(struct kvm_pmc *pmc) 42static bool pmc_is_gp(struct kvm_pmc *pmc)
42{ 43{
@@ -210,6 +211,9 @@ static void reprogram_gp_counter(struct kvm_pmc *pmc, u64 eventsel)
210 unsigned config, type = PERF_TYPE_RAW; 211 unsigned config, type = PERF_TYPE_RAW;
211 u8 event_select, unit_mask; 212 u8 event_select, unit_mask;
212 213
214 if (eventsel & ARCH_PERFMON_EVENTSEL_PIN_CONTROL)
215 printk_once("kvm pmu: pin control bit is ignored\n");
216
213 pmc->eventsel = eventsel; 217 pmc->eventsel = eventsel;
214 218
215 stop_counter(pmc); 219 stop_counter(pmc);
@@ -220,7 +224,7 @@ static void reprogram_gp_counter(struct kvm_pmc *pmc, u64 eventsel)
220 event_select = eventsel & ARCH_PERFMON_EVENTSEL_EVENT; 224 event_select = eventsel & ARCH_PERFMON_EVENTSEL_EVENT;
221 unit_mask = (eventsel & ARCH_PERFMON_EVENTSEL_UMASK) >> 8; 225 unit_mask = (eventsel & ARCH_PERFMON_EVENTSEL_UMASK) >> 8;
222 226
223 if (!(event_select & (ARCH_PERFMON_EVENTSEL_EDGE | 227 if (!(eventsel & (ARCH_PERFMON_EVENTSEL_EDGE |
224 ARCH_PERFMON_EVENTSEL_INV | 228 ARCH_PERFMON_EVENTSEL_INV |
225 ARCH_PERFMON_EVENTSEL_CMASK))) { 229 ARCH_PERFMON_EVENTSEL_CMASK))) {
226 config = find_arch_event(&pmc->vcpu->arch.pmu, event_select, 230 config = find_arch_event(&pmc->vcpu->arch.pmu, event_select,
@@ -413,7 +417,7 @@ int kvm_pmu_read_pmc(struct kvm_vcpu *vcpu, unsigned pmc, u64 *data)
413 struct kvm_pmc *counters; 417 struct kvm_pmc *counters;
414 u64 ctr; 418 u64 ctr;
415 419
416 pmc &= (3u << 30) - 1; 420 pmc &= ~(3u << 30);
417 if (!fixed && pmc >= pmu->nr_arch_gp_counters) 421 if (!fixed && pmc >= pmu->nr_arch_gp_counters)
418 return 1; 422 return 1;
419 if (fixed && pmc >= pmu->nr_arch_fixed_counters) 423 if (fixed && pmc >= pmu->nr_arch_fixed_counters)
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index e385214711c..e334389e1c7 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -111,6 +111,12 @@ struct nested_state {
111#define MSRPM_OFFSETS 16 111#define MSRPM_OFFSETS 16
112static u32 msrpm_offsets[MSRPM_OFFSETS] __read_mostly; 112static u32 msrpm_offsets[MSRPM_OFFSETS] __read_mostly;
113 113
114/*
115 * Set osvw_len to higher value when updated Revision Guides
116 * are published and we know what the new status bits are
117 */
118static uint64_t osvw_len = 4, osvw_status;
119
114struct vcpu_svm { 120struct vcpu_svm {
115 struct kvm_vcpu vcpu; 121 struct kvm_vcpu vcpu;
116 struct vmcb *vmcb; 122 struct vmcb *vmcb;
@@ -177,11 +183,13 @@ static bool npt_enabled = true;
177#else 183#else
178static bool npt_enabled; 184static bool npt_enabled;
179#endif 185#endif
180static int npt = 1;
181 186
187/* allow nested paging (virtualized MMU) for all guests */
188static int npt = true;
182module_param(npt, int, S_IRUGO); 189module_param(npt, int, S_IRUGO);
183 190
184static int nested = 1; 191/* allow nested virtualization in KVM/SVM */
192static int nested = true;
185module_param(nested, int, S_IRUGO); 193module_param(nested, int, S_IRUGO);
186 194
187static void svm_flush_tlb(struct kvm_vcpu *vcpu); 195static void svm_flush_tlb(struct kvm_vcpu *vcpu);
@@ -557,6 +565,27 @@ static void svm_init_erratum_383(void)
557 erratum_383_found = true; 565 erratum_383_found = true;
558} 566}
559 567
568static void svm_init_osvw(struct kvm_vcpu *vcpu)
569{
570 /*
571 * Guests should see errata 400 and 415 as fixed (assuming that
572 * HLT and IO instructions are intercepted).
573 */
574 vcpu->arch.osvw.length = (osvw_len >= 3) ? (osvw_len) : 3;
575 vcpu->arch.osvw.status = osvw_status & ~(6ULL);
576
577 /*
578 * By increasing VCPU's osvw.length to 3 we are telling the guest that
579 * all osvw.status bits inside that length, including bit 0 (which is
580 * reserved for erratum 298), are valid. However, if host processor's
581 * osvw_len is 0 then osvw_status[0] carries no information. We need to
582 * be conservative here and therefore we tell the guest that erratum 298
583 * is present (because we really don't know).
584 */
585 if (osvw_len == 0 && boot_cpu_data.x86 == 0x10)
586 vcpu->arch.osvw.status |= 1;
587}
588
560static int has_svm(void) 589static int has_svm(void)
561{ 590{
562 const char *msg; 591 const char *msg;
@@ -623,6 +652,36 @@ static int svm_hardware_enable(void *garbage)
623 __get_cpu_var(current_tsc_ratio) = TSC_RATIO_DEFAULT; 652 __get_cpu_var(current_tsc_ratio) = TSC_RATIO_DEFAULT;
624 } 653 }
625 654
655
656 /*
657 * Get OSVW bits.
658 *
659 * Note that it is possible to have a system with mixed processor
660 * revisions and therefore different OSVW bits. If bits are not the same
661 * on different processors then choose the worst case (i.e. if erratum
662 * is present on one processor and not on another then assume that the
663 * erratum is present everywhere).
664 */
665 if (cpu_has(&boot_cpu_data, X86_FEATURE_OSVW)) {
666 uint64_t len, status = 0;
667 int err;
668
669 len = native_read_msr_safe(MSR_AMD64_OSVW_ID_LENGTH, &err);
670 if (!err)
671 status = native_read_msr_safe(MSR_AMD64_OSVW_STATUS,
672 &err);
673
674 if (err)
675 osvw_status = osvw_len = 0;
676 else {
677 if (len < osvw_len)
678 osvw_len = len;
679 osvw_status |= status;
680 osvw_status &= (1ULL << osvw_len) - 1;
681 }
682 } else
683 osvw_status = osvw_len = 0;
684
626 svm_init_erratum_383(); 685 svm_init_erratum_383();
627 686
628 amd_pmu_enable_virt(); 687 amd_pmu_enable_virt();
@@ -910,20 +969,25 @@ static u64 svm_scale_tsc(struct kvm_vcpu *vcpu, u64 tsc)
910 return _tsc; 969 return _tsc;
911} 970}
912 971
913static void svm_set_tsc_khz(struct kvm_vcpu *vcpu, u32 user_tsc_khz) 972static void svm_set_tsc_khz(struct kvm_vcpu *vcpu, u32 user_tsc_khz, bool scale)
914{ 973{
915 struct vcpu_svm *svm = to_svm(vcpu); 974 struct vcpu_svm *svm = to_svm(vcpu);
916 u64 ratio; 975 u64 ratio;
917 u64 khz; 976 u64 khz;
918 977
919 /* TSC scaling supported? */ 978 /* Guest TSC same frequency as host TSC? */
920 if (!boot_cpu_has(X86_FEATURE_TSCRATEMSR)) 979 if (!scale) {
980 svm->tsc_ratio = TSC_RATIO_DEFAULT;
921 return; 981 return;
982 }
922 983
923 /* TSC-Scaling disabled or guest TSC same frequency as host TSC? */ 984 /* TSC scaling supported? */
924 if (user_tsc_khz == 0) { 985 if (!boot_cpu_has(X86_FEATURE_TSCRATEMSR)) {
925 vcpu->arch.virtual_tsc_khz = 0; 986 if (user_tsc_khz > tsc_khz) {
926 svm->tsc_ratio = TSC_RATIO_DEFAULT; 987 vcpu->arch.tsc_catchup = 1;
988 vcpu->arch.tsc_always_catchup = 1;
989 } else
990 WARN(1, "user requested TSC rate below hardware speed\n");
927 return; 991 return;
928 } 992 }
929 993
@@ -938,7 +1002,6 @@ static void svm_set_tsc_khz(struct kvm_vcpu *vcpu, u32 user_tsc_khz)
938 user_tsc_khz); 1002 user_tsc_khz);
939 return; 1003 return;
940 } 1004 }
941 vcpu->arch.virtual_tsc_khz = user_tsc_khz;
942 svm->tsc_ratio = ratio; 1005 svm->tsc_ratio = ratio;
943} 1006}
944 1007
@@ -958,10 +1021,14 @@ static void svm_write_tsc_offset(struct kvm_vcpu *vcpu, u64 offset)
958 mark_dirty(svm->vmcb, VMCB_INTERCEPTS); 1021 mark_dirty(svm->vmcb, VMCB_INTERCEPTS);
959} 1022}
960 1023
961static void svm_adjust_tsc_offset(struct kvm_vcpu *vcpu, s64 adjustment) 1024static void svm_adjust_tsc_offset(struct kvm_vcpu *vcpu, s64 adjustment, bool host)
962{ 1025{
963 struct vcpu_svm *svm = to_svm(vcpu); 1026 struct vcpu_svm *svm = to_svm(vcpu);
964 1027
1028 WARN_ON(adjustment < 0);
1029 if (host)
1030 adjustment = svm_scale_tsc(vcpu, adjustment);
1031
965 svm->vmcb->control.tsc_offset += adjustment; 1032 svm->vmcb->control.tsc_offset += adjustment;
966 if (is_guest_mode(vcpu)) 1033 if (is_guest_mode(vcpu))
967 svm->nested.hsave->control.tsc_offset += adjustment; 1034 svm->nested.hsave->control.tsc_offset += adjustment;
@@ -1191,6 +1258,8 @@ static struct kvm_vcpu *svm_create_vcpu(struct kvm *kvm, unsigned int id)
1191 if (kvm_vcpu_is_bsp(&svm->vcpu)) 1258 if (kvm_vcpu_is_bsp(&svm->vcpu))
1192 svm->vcpu.arch.apic_base |= MSR_IA32_APICBASE_BSP; 1259 svm->vcpu.arch.apic_base |= MSR_IA32_APICBASE_BSP;
1193 1260
1261 svm_init_osvw(&svm->vcpu);
1262
1194 return &svm->vcpu; 1263 return &svm->vcpu;
1195 1264
1196free_page4: 1265free_page4:
@@ -1268,6 +1337,21 @@ static void svm_vcpu_put(struct kvm_vcpu *vcpu)
1268 wrmsrl(host_save_user_msrs[i], svm->host_user_msrs[i]); 1337 wrmsrl(host_save_user_msrs[i], svm->host_user_msrs[i]);
1269} 1338}
1270 1339
1340static void svm_update_cpl(struct kvm_vcpu *vcpu)
1341{
1342 struct vcpu_svm *svm = to_svm(vcpu);
1343 int cpl;
1344
1345 if (!is_protmode(vcpu))
1346 cpl = 0;
1347 else if (svm->vmcb->save.rflags & X86_EFLAGS_VM)
1348 cpl = 3;
1349 else
1350 cpl = svm->vmcb->save.cs.selector & 0x3;
1351
1352 svm->vmcb->save.cpl = cpl;
1353}
1354
1271static unsigned long svm_get_rflags(struct kvm_vcpu *vcpu) 1355static unsigned long svm_get_rflags(struct kvm_vcpu *vcpu)
1272{ 1356{
1273 return to_svm(vcpu)->vmcb->save.rflags; 1357 return to_svm(vcpu)->vmcb->save.rflags;
@@ -1275,7 +1359,11 @@ static unsigned long svm_get_rflags(struct kvm_vcpu *vcpu)
1275 1359
1276static void svm_set_rflags(struct kvm_vcpu *vcpu, unsigned long rflags) 1360static void svm_set_rflags(struct kvm_vcpu *vcpu, unsigned long rflags)
1277{ 1361{
1362 unsigned long old_rflags = to_svm(vcpu)->vmcb->save.rflags;
1363
1278 to_svm(vcpu)->vmcb->save.rflags = rflags; 1364 to_svm(vcpu)->vmcb->save.rflags = rflags;
1365 if ((old_rflags ^ rflags) & X86_EFLAGS_VM)
1366 svm_update_cpl(vcpu);
1279} 1367}
1280 1368
1281static void svm_cache_reg(struct kvm_vcpu *vcpu, enum kvm_reg reg) 1369static void svm_cache_reg(struct kvm_vcpu *vcpu, enum kvm_reg reg)
@@ -1543,9 +1631,7 @@ static void svm_set_segment(struct kvm_vcpu *vcpu,
1543 s->attrib |= (var->g & 1) << SVM_SELECTOR_G_SHIFT; 1631 s->attrib |= (var->g & 1) << SVM_SELECTOR_G_SHIFT;
1544 } 1632 }
1545 if (seg == VCPU_SREG_CS) 1633 if (seg == VCPU_SREG_CS)
1546 svm->vmcb->save.cpl 1634 svm_update_cpl(vcpu);
1547 = (svm->vmcb->save.cs.attrib
1548 >> SVM_SELECTOR_DPL_SHIFT) & 3;
1549 1635
1550 mark_dirty(svm->vmcb, VMCB_SEG); 1636 mark_dirty(svm->vmcb, VMCB_SEG);
1551} 1637}
@@ -2735,7 +2821,10 @@ static int task_switch_interception(struct vcpu_svm *svm)
2735 (int_vec == OF_VECTOR || int_vec == BP_VECTOR))) 2821 (int_vec == OF_VECTOR || int_vec == BP_VECTOR)))
2736 skip_emulated_instruction(&svm->vcpu); 2822 skip_emulated_instruction(&svm->vcpu);
2737 2823
2738 if (kvm_task_switch(&svm->vcpu, tss_selector, reason, 2824 if (int_type != SVM_EXITINTINFO_TYPE_SOFT)
2825 int_vec = -1;
2826
2827 if (kvm_task_switch(&svm->vcpu, tss_selector, int_vec, reason,
2739 has_error_code, error_code) == EMULATE_FAIL) { 2828 has_error_code, error_code) == EMULATE_FAIL) {
2740 svm->vcpu.run->exit_reason = KVM_EXIT_INTERNAL_ERROR; 2829 svm->vcpu.run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
2741 svm->vcpu.run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION; 2830 svm->vcpu.run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION;
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 246490f643b..280751c8472 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -70,9 +70,6 @@ module_param(emulate_invalid_guest_state, bool, S_IRUGO);
70static bool __read_mostly vmm_exclusive = 1; 70static bool __read_mostly vmm_exclusive = 1;
71module_param(vmm_exclusive, bool, S_IRUGO); 71module_param(vmm_exclusive, bool, S_IRUGO);
72 72
73static bool __read_mostly yield_on_hlt = 1;
74module_param(yield_on_hlt, bool, S_IRUGO);
75
76static bool __read_mostly fasteoi = 1; 73static bool __read_mostly fasteoi = 1;
77module_param(fasteoi, bool, S_IRUGO); 74module_param(fasteoi, bool, S_IRUGO);
78 75
@@ -1655,17 +1652,6 @@ static void skip_emulated_instruction(struct kvm_vcpu *vcpu)
1655 vmx_set_interrupt_shadow(vcpu, 0); 1652 vmx_set_interrupt_shadow(vcpu, 0);
1656} 1653}
1657 1654
1658static void vmx_clear_hlt(struct kvm_vcpu *vcpu)
1659{
1660 /* Ensure that we clear the HLT state in the VMCS. We don't need to
1661 * explicitly skip the instruction because if the HLT state is set, then
1662 * the instruction is already executing and RIP has already been
1663 * advanced. */
1664 if (!yield_on_hlt &&
1665 vmcs_read32(GUEST_ACTIVITY_STATE) == GUEST_ACTIVITY_HLT)
1666 vmcs_write32(GUEST_ACTIVITY_STATE, GUEST_ACTIVITY_ACTIVE);
1667}
1668
1669/* 1655/*
1670 * KVM wants to inject page-faults which it got to the guest. This function 1656 * KVM wants to inject page-faults which it got to the guest. This function
1671 * checks whether in a nested guest, we need to inject them to L1 or L2. 1657 * checks whether in a nested guest, we need to inject them to L1 or L2.
@@ -1678,7 +1664,7 @@ static int nested_pf_handled(struct kvm_vcpu *vcpu)
1678 struct vmcs12 *vmcs12 = get_vmcs12(vcpu); 1664 struct vmcs12 *vmcs12 = get_vmcs12(vcpu);
1679 1665
1680 /* TODO: also check PFEC_MATCH/MASK, not just EB.PF. */ 1666 /* TODO: also check PFEC_MATCH/MASK, not just EB.PF. */
1681 if (!(vmcs12->exception_bitmap & PF_VECTOR)) 1667 if (!(vmcs12->exception_bitmap & (1u << PF_VECTOR)))
1682 return 0; 1668 return 0;
1683 1669
1684 nested_vmx_vmexit(vcpu); 1670 nested_vmx_vmexit(vcpu);
@@ -1718,7 +1704,6 @@ static void vmx_queue_exception(struct kvm_vcpu *vcpu, unsigned nr,
1718 intr_info |= INTR_TYPE_HARD_EXCEPTION; 1704 intr_info |= INTR_TYPE_HARD_EXCEPTION;
1719 1705
1720 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, intr_info); 1706 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, intr_info);
1721 vmx_clear_hlt(vcpu);
1722} 1707}
1723 1708
1724static bool vmx_rdtscp_supported(void) 1709static bool vmx_rdtscp_supported(void)
@@ -1817,13 +1802,19 @@ u64 vmx_read_l1_tsc(struct kvm_vcpu *vcpu)
1817} 1802}
1818 1803
1819/* 1804/*
1820 * Empty call-back. Needs to be implemented when VMX enables the SET_TSC_KHZ 1805 * Engage any workarounds for mis-matched TSC rates. Currently limited to
1821 * ioctl. In this case the call-back should update internal vmx state to make 1806 * software catchup for faster rates on slower CPUs.
1822 * the changes effective.
1823 */ 1807 */
1824static void vmx_set_tsc_khz(struct kvm_vcpu *vcpu, u32 user_tsc_khz) 1808static void vmx_set_tsc_khz(struct kvm_vcpu *vcpu, u32 user_tsc_khz, bool scale)
1825{ 1809{
1826 /* Nothing to do here */ 1810 if (!scale)
1811 return;
1812
1813 if (user_tsc_khz > tsc_khz) {
1814 vcpu->arch.tsc_catchup = 1;
1815 vcpu->arch.tsc_always_catchup = 1;
1816 } else
1817 WARN(1, "user requested TSC rate below hardware speed\n");
1827} 1818}
1828 1819
1829/* 1820/*
@@ -1850,7 +1841,7 @@ static void vmx_write_tsc_offset(struct kvm_vcpu *vcpu, u64 offset)
1850 } 1841 }
1851} 1842}
1852 1843
1853static void vmx_adjust_tsc_offset(struct kvm_vcpu *vcpu, s64 adjustment) 1844static void vmx_adjust_tsc_offset(struct kvm_vcpu *vcpu, s64 adjustment, bool host)
1854{ 1845{
1855 u64 offset = vmcs_read64(TSC_OFFSET); 1846 u64 offset = vmcs_read64(TSC_OFFSET);
1856 vmcs_write64(TSC_OFFSET, offset + adjustment); 1847 vmcs_write64(TSC_OFFSET, offset + adjustment);
@@ -2219,6 +2210,9 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data)
2219 msr = find_msr_entry(vmx, msr_index); 2210 msr = find_msr_entry(vmx, msr_index);
2220 if (msr) { 2211 if (msr) {
2221 msr->data = data; 2212 msr->data = data;
2213 if (msr - vmx->guest_msrs < vmx->save_nmsrs)
2214 kvm_set_shared_msr(msr->index, msr->data,
2215 msr->mask);
2222 break; 2216 break;
2223 } 2217 }
2224 ret = kvm_set_msr_common(vcpu, msr_index, data); 2218 ret = kvm_set_msr_common(vcpu, msr_index, data);
@@ -2399,7 +2393,7 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf)
2399 &_pin_based_exec_control) < 0) 2393 &_pin_based_exec_control) < 0)
2400 return -EIO; 2394 return -EIO;
2401 2395
2402 min = 2396 min = CPU_BASED_HLT_EXITING |
2403#ifdef CONFIG_X86_64 2397#ifdef CONFIG_X86_64
2404 CPU_BASED_CR8_LOAD_EXITING | 2398 CPU_BASED_CR8_LOAD_EXITING |
2405 CPU_BASED_CR8_STORE_EXITING | 2399 CPU_BASED_CR8_STORE_EXITING |
@@ -2414,9 +2408,6 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf)
2414 CPU_BASED_INVLPG_EXITING | 2408 CPU_BASED_INVLPG_EXITING |
2415 CPU_BASED_RDPMC_EXITING; 2409 CPU_BASED_RDPMC_EXITING;
2416 2410
2417 if (yield_on_hlt)
2418 min |= CPU_BASED_HLT_EXITING;
2419
2420 opt = CPU_BASED_TPR_SHADOW | 2411 opt = CPU_BASED_TPR_SHADOW |
2421 CPU_BASED_USE_MSR_BITMAPS | 2412 CPU_BASED_USE_MSR_BITMAPS |
2422 CPU_BASED_ACTIVATE_SECONDARY_CONTROLS; 2413 CPU_BASED_ACTIVATE_SECONDARY_CONTROLS;
@@ -4003,7 +3994,6 @@ static void vmx_inject_irq(struct kvm_vcpu *vcpu)
4003 } else 3994 } else
4004 intr |= INTR_TYPE_EXT_INTR; 3995 intr |= INTR_TYPE_EXT_INTR;
4005 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, intr); 3996 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, intr);
4006 vmx_clear_hlt(vcpu);
4007} 3997}
4008 3998
4009static void vmx_inject_nmi(struct kvm_vcpu *vcpu) 3999static void vmx_inject_nmi(struct kvm_vcpu *vcpu)
@@ -4035,7 +4025,6 @@ static void vmx_inject_nmi(struct kvm_vcpu *vcpu)
4035 } 4025 }
4036 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD, 4026 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD,
4037 INTR_TYPE_NMI_INTR | INTR_INFO_VALID_MASK | NMI_VECTOR); 4027 INTR_TYPE_NMI_INTR | INTR_INFO_VALID_MASK | NMI_VECTOR);
4038 vmx_clear_hlt(vcpu);
4039} 4028}
4040 4029
4041static int vmx_nmi_allowed(struct kvm_vcpu *vcpu) 4030static int vmx_nmi_allowed(struct kvm_vcpu *vcpu)
@@ -4672,9 +4661,10 @@ static int handle_task_switch(struct kvm_vcpu *vcpu)
4672 bool has_error_code = false; 4661 bool has_error_code = false;
4673 u32 error_code = 0; 4662 u32 error_code = 0;
4674 u16 tss_selector; 4663 u16 tss_selector;
4675 int reason, type, idt_v; 4664 int reason, type, idt_v, idt_index;
4676 4665
4677 idt_v = (vmx->idt_vectoring_info & VECTORING_INFO_VALID_MASK); 4666 idt_v = (vmx->idt_vectoring_info & VECTORING_INFO_VALID_MASK);
4667 idt_index = (vmx->idt_vectoring_info & VECTORING_INFO_VECTOR_MASK);
4678 type = (vmx->idt_vectoring_info & VECTORING_INFO_TYPE_MASK); 4668 type = (vmx->idt_vectoring_info & VECTORING_INFO_TYPE_MASK);
4679 4669
4680 exit_qualification = vmcs_readl(EXIT_QUALIFICATION); 4670 exit_qualification = vmcs_readl(EXIT_QUALIFICATION);
@@ -4712,8 +4702,9 @@ static int handle_task_switch(struct kvm_vcpu *vcpu)
4712 type != INTR_TYPE_NMI_INTR)) 4702 type != INTR_TYPE_NMI_INTR))
4713 skip_emulated_instruction(vcpu); 4703 skip_emulated_instruction(vcpu);
4714 4704
4715 if (kvm_task_switch(vcpu, tss_selector, reason, 4705 if (kvm_task_switch(vcpu, tss_selector,
4716 has_error_code, error_code) == EMULATE_FAIL) { 4706 type == INTR_TYPE_SOFT_INTR ? idt_index : -1, reason,
4707 has_error_code, error_code) == EMULATE_FAIL) {
4717 vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR; 4708 vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
4718 vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION; 4709 vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_EMULATION;
4719 vcpu->run->internal.ndata = 0; 4710 vcpu->run->internal.ndata = 0;
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 54696b5f844..4044ce0bf7c 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -97,6 +97,10 @@ EXPORT_SYMBOL_GPL(kvm_has_tsc_control);
97u32 kvm_max_guest_tsc_khz; 97u32 kvm_max_guest_tsc_khz;
98EXPORT_SYMBOL_GPL(kvm_max_guest_tsc_khz); 98EXPORT_SYMBOL_GPL(kvm_max_guest_tsc_khz);
99 99
100/* tsc tolerance in parts per million - default to 1/2 of the NTP threshold */
101static u32 tsc_tolerance_ppm = 250;
102module_param(tsc_tolerance_ppm, uint, S_IRUGO | S_IWUSR);
103
100#define KVM_NR_SHARED_MSRS 16 104#define KVM_NR_SHARED_MSRS 16
101 105
102struct kvm_shared_msrs_global { 106struct kvm_shared_msrs_global {
@@ -969,50 +973,51 @@ static inline u64 get_kernel_ns(void)
969static DEFINE_PER_CPU(unsigned long, cpu_tsc_khz); 973static DEFINE_PER_CPU(unsigned long, cpu_tsc_khz);
970unsigned long max_tsc_khz; 974unsigned long max_tsc_khz;
971 975
972static inline int kvm_tsc_changes_freq(void) 976static inline u64 nsec_to_cycles(struct kvm_vcpu *vcpu, u64 nsec)
973{ 977{
974 int cpu = get_cpu(); 978 return pvclock_scale_delta(nsec, vcpu->arch.virtual_tsc_mult,
975 int ret = !boot_cpu_has(X86_FEATURE_CONSTANT_TSC) && 979 vcpu->arch.virtual_tsc_shift);
976 cpufreq_quick_get(cpu) != 0;
977 put_cpu();
978 return ret;
979} 980}
980 981
981u64 vcpu_tsc_khz(struct kvm_vcpu *vcpu) 982static u32 adjust_tsc_khz(u32 khz, s32 ppm)
982{ 983{
983 if (vcpu->arch.virtual_tsc_khz) 984 u64 v = (u64)khz * (1000000 + ppm);
984 return vcpu->arch.virtual_tsc_khz; 985 do_div(v, 1000000);
985 else 986 return v;
986 return __this_cpu_read(cpu_tsc_khz);
987} 987}
988 988
989static inline u64 nsec_to_cycles(struct kvm_vcpu *vcpu, u64 nsec) 989static void kvm_set_tsc_khz(struct kvm_vcpu *vcpu, u32 this_tsc_khz)
990{ 990{
991 u64 ret; 991 u32 thresh_lo, thresh_hi;
992 992 int use_scaling = 0;
993 WARN_ON(preemptible());
994 if (kvm_tsc_changes_freq())
995 printk_once(KERN_WARNING
996 "kvm: unreliable cycle conversion on adjustable rate TSC\n");
997 ret = nsec * vcpu_tsc_khz(vcpu);
998 do_div(ret, USEC_PER_SEC);
999 return ret;
1000}
1001 993
1002static void kvm_init_tsc_catchup(struct kvm_vcpu *vcpu, u32 this_tsc_khz)
1003{
1004 /* Compute a scale to convert nanoseconds in TSC cycles */ 994 /* Compute a scale to convert nanoseconds in TSC cycles */
1005 kvm_get_time_scale(this_tsc_khz, NSEC_PER_SEC / 1000, 995 kvm_get_time_scale(this_tsc_khz, NSEC_PER_SEC / 1000,
1006 &vcpu->arch.tsc_catchup_shift, 996 &vcpu->arch.virtual_tsc_shift,
1007 &vcpu->arch.tsc_catchup_mult); 997 &vcpu->arch.virtual_tsc_mult);
998 vcpu->arch.virtual_tsc_khz = this_tsc_khz;
999
1000 /*
1001 * Compute the variation in TSC rate which is acceptable
1002 * within the range of tolerance and decide if the
1003 * rate being applied is within that bounds of the hardware
1004 * rate. If so, no scaling or compensation need be done.
1005 */
1006 thresh_lo = adjust_tsc_khz(tsc_khz, -tsc_tolerance_ppm);
1007 thresh_hi = adjust_tsc_khz(tsc_khz, tsc_tolerance_ppm);
1008 if (this_tsc_khz < thresh_lo || this_tsc_khz > thresh_hi) {
1009 pr_debug("kvm: requested TSC rate %u falls outside tolerance [%u,%u]\n", this_tsc_khz, thresh_lo, thresh_hi);
1010 use_scaling = 1;
1011 }
1012 kvm_x86_ops->set_tsc_khz(vcpu, this_tsc_khz, use_scaling);
1008} 1013}
1009 1014
1010static u64 compute_guest_tsc(struct kvm_vcpu *vcpu, s64 kernel_ns) 1015static u64 compute_guest_tsc(struct kvm_vcpu *vcpu, s64 kernel_ns)
1011{ 1016{
1012 u64 tsc = pvclock_scale_delta(kernel_ns-vcpu->arch.last_tsc_nsec, 1017 u64 tsc = pvclock_scale_delta(kernel_ns-vcpu->arch.this_tsc_nsec,
1013 vcpu->arch.tsc_catchup_mult, 1018 vcpu->arch.virtual_tsc_mult,
1014 vcpu->arch.tsc_catchup_shift); 1019 vcpu->arch.virtual_tsc_shift);
1015 tsc += vcpu->arch.last_tsc_write; 1020 tsc += vcpu->arch.this_tsc_write;
1016 return tsc; 1021 return tsc;
1017} 1022}
1018 1023
@@ -1021,48 +1026,88 @@ void kvm_write_tsc(struct kvm_vcpu *vcpu, u64 data)
1021 struct kvm *kvm = vcpu->kvm; 1026 struct kvm *kvm = vcpu->kvm;
1022 u64 offset, ns, elapsed; 1027 u64 offset, ns, elapsed;
1023 unsigned long flags; 1028 unsigned long flags;
1024 s64 sdiff; 1029 s64 usdiff;
1025 1030
1026 raw_spin_lock_irqsave(&kvm->arch.tsc_write_lock, flags); 1031 raw_spin_lock_irqsave(&kvm->arch.tsc_write_lock, flags);
1027 offset = kvm_x86_ops->compute_tsc_offset(vcpu, data); 1032 offset = kvm_x86_ops->compute_tsc_offset(vcpu, data);
1028 ns = get_kernel_ns(); 1033 ns = get_kernel_ns();
1029 elapsed = ns - kvm->arch.last_tsc_nsec; 1034 elapsed = ns - kvm->arch.last_tsc_nsec;
1030 sdiff = data - kvm->arch.last_tsc_write; 1035
1031 if (sdiff < 0) 1036 /* n.b - signed multiplication and division required */
1032 sdiff = -sdiff; 1037 usdiff = data - kvm->arch.last_tsc_write;
1038#ifdef CONFIG_X86_64
1039 usdiff = (usdiff * 1000) / vcpu->arch.virtual_tsc_khz;
1040#else
1041 /* do_div() only does unsigned */
1042 asm("idivl %2; xor %%edx, %%edx"
1043 : "=A"(usdiff)
1044 : "A"(usdiff * 1000), "rm"(vcpu->arch.virtual_tsc_khz));
1045#endif
1046 do_div(elapsed, 1000);
1047 usdiff -= elapsed;
1048 if (usdiff < 0)
1049 usdiff = -usdiff;
1033 1050
1034 /* 1051 /*
1035 * Special case: close write to TSC within 5 seconds of 1052 * Special case: TSC write with a small delta (1 second) of virtual
1036 * another CPU is interpreted as an attempt to synchronize 1053 * cycle time against real time is interpreted as an attempt to
1037 * The 5 seconds is to accommodate host load / swapping as 1054 * synchronize the CPU.
1038 * well as any reset of TSC during the boot process. 1055 *
1039 * 1056 * For a reliable TSC, we can match TSC offsets, and for an unstable
1040 * In that case, for a reliable TSC, we can match TSC offsets, 1057 * TSC, we add elapsed time in this computation. We could let the
1041 * or make a best guest using elapsed value. 1058 * compensation code attempt to catch up if we fall behind, but
1042 */ 1059 * it's better to try to match offsets from the beginning.
1043 if (sdiff < nsec_to_cycles(vcpu, 5ULL * NSEC_PER_SEC) && 1060 */
1044 elapsed < 5ULL * NSEC_PER_SEC) { 1061 if (usdiff < USEC_PER_SEC &&
1062 vcpu->arch.virtual_tsc_khz == kvm->arch.last_tsc_khz) {
1045 if (!check_tsc_unstable()) { 1063 if (!check_tsc_unstable()) {
1046 offset = kvm->arch.last_tsc_offset; 1064 offset = kvm->arch.cur_tsc_offset;
1047 pr_debug("kvm: matched tsc offset for %llu\n", data); 1065 pr_debug("kvm: matched tsc offset for %llu\n", data);
1048 } else { 1066 } else {
1049 u64 delta = nsec_to_cycles(vcpu, elapsed); 1067 u64 delta = nsec_to_cycles(vcpu, elapsed);
1050 offset += delta; 1068 data += delta;
1069 offset = kvm_x86_ops->compute_tsc_offset(vcpu, data);
1051 pr_debug("kvm: adjusted tsc offset by %llu\n", delta); 1070 pr_debug("kvm: adjusted tsc offset by %llu\n", delta);
1052 } 1071 }
1053 ns = kvm->arch.last_tsc_nsec; 1072 } else {
1073 /*
1074 * We split periods of matched TSC writes into generations.
1075 * For each generation, we track the original measured
1076 * nanosecond time, offset, and write, so if TSCs are in
1077 * sync, we can match exact offset, and if not, we can match
1078 * exact software computaion in compute_guest_tsc()
1079 *
1080 * These values are tracked in kvm->arch.cur_xxx variables.
1081 */
1082 kvm->arch.cur_tsc_generation++;
1083 kvm->arch.cur_tsc_nsec = ns;
1084 kvm->arch.cur_tsc_write = data;
1085 kvm->arch.cur_tsc_offset = offset;
1086 pr_debug("kvm: new tsc generation %u, clock %llu\n",
1087 kvm->arch.cur_tsc_generation, data);
1054 } 1088 }
1089
1090 /*
1091 * We also track th most recent recorded KHZ, write and time to
1092 * allow the matching interval to be extended at each write.
1093 */
1055 kvm->arch.last_tsc_nsec = ns; 1094 kvm->arch.last_tsc_nsec = ns;
1056 kvm->arch.last_tsc_write = data; 1095 kvm->arch.last_tsc_write = data;
1057 kvm->arch.last_tsc_offset = offset; 1096 kvm->arch.last_tsc_khz = vcpu->arch.virtual_tsc_khz;
1058 kvm_x86_ops->write_tsc_offset(vcpu, offset);
1059 raw_spin_unlock_irqrestore(&kvm->arch.tsc_write_lock, flags);
1060 1097
1061 /* Reset of TSC must disable overshoot protection below */ 1098 /* Reset of TSC must disable overshoot protection below */
1062 vcpu->arch.hv_clock.tsc_timestamp = 0; 1099 vcpu->arch.hv_clock.tsc_timestamp = 0;
1063 vcpu->arch.last_tsc_write = data; 1100 vcpu->arch.last_guest_tsc = data;
1064 vcpu->arch.last_tsc_nsec = ns; 1101
1102 /* Keep track of which generation this VCPU has synchronized to */
1103 vcpu->arch.this_tsc_generation = kvm->arch.cur_tsc_generation;
1104 vcpu->arch.this_tsc_nsec = kvm->arch.cur_tsc_nsec;
1105 vcpu->arch.this_tsc_write = kvm->arch.cur_tsc_write;
1106
1107 kvm_x86_ops->write_tsc_offset(vcpu, offset);
1108 raw_spin_unlock_irqrestore(&kvm->arch.tsc_write_lock, flags);
1065} 1109}
1110
1066EXPORT_SYMBOL_GPL(kvm_write_tsc); 1111EXPORT_SYMBOL_GPL(kvm_write_tsc);
1067 1112
1068static int kvm_guest_time_update(struct kvm_vcpu *v) 1113static int kvm_guest_time_update(struct kvm_vcpu *v)
@@ -1078,7 +1123,7 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
1078 local_irq_save(flags); 1123 local_irq_save(flags);
1079 tsc_timestamp = kvm_x86_ops->read_l1_tsc(v); 1124 tsc_timestamp = kvm_x86_ops->read_l1_tsc(v);
1080 kernel_ns = get_kernel_ns(); 1125 kernel_ns = get_kernel_ns();
1081 this_tsc_khz = vcpu_tsc_khz(v); 1126 this_tsc_khz = __get_cpu_var(cpu_tsc_khz);
1082 if (unlikely(this_tsc_khz == 0)) { 1127 if (unlikely(this_tsc_khz == 0)) {
1083 local_irq_restore(flags); 1128 local_irq_restore(flags);
1084 kvm_make_request(KVM_REQ_CLOCK_UPDATE, v); 1129 kvm_make_request(KVM_REQ_CLOCK_UPDATE, v);
@@ -1098,7 +1143,7 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
1098 if (vcpu->tsc_catchup) { 1143 if (vcpu->tsc_catchup) {
1099 u64 tsc = compute_guest_tsc(v, kernel_ns); 1144 u64 tsc = compute_guest_tsc(v, kernel_ns);
1100 if (tsc > tsc_timestamp) { 1145 if (tsc > tsc_timestamp) {
1101 kvm_x86_ops->adjust_tsc_offset(v, tsc - tsc_timestamp); 1146 adjust_tsc_offset_guest(v, tsc - tsc_timestamp);
1102 tsc_timestamp = tsc; 1147 tsc_timestamp = tsc;
1103 } 1148 }
1104 } 1149 }
@@ -1130,7 +1175,7 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
1130 * observed by the guest and ensure the new system time is greater. 1175 * observed by the guest and ensure the new system time is greater.
1131 */ 1176 */
1132 max_kernel_ns = 0; 1177 max_kernel_ns = 0;
1133 if (vcpu->hv_clock.tsc_timestamp && vcpu->last_guest_tsc) { 1178 if (vcpu->hv_clock.tsc_timestamp) {
1134 max_kernel_ns = vcpu->last_guest_tsc - 1179 max_kernel_ns = vcpu->last_guest_tsc -
1135 vcpu->hv_clock.tsc_timestamp; 1180 vcpu->hv_clock.tsc_timestamp;
1136 max_kernel_ns = pvclock_scale_delta(max_kernel_ns, 1181 max_kernel_ns = pvclock_scale_delta(max_kernel_ns,
@@ -1504,6 +1549,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
1504 case MSR_K7_HWCR: 1549 case MSR_K7_HWCR:
1505 data &= ~(u64)0x40; /* ignore flush filter disable */ 1550 data &= ~(u64)0x40; /* ignore flush filter disable */
1506 data &= ~(u64)0x100; /* ignore ignne emulation enable */ 1551 data &= ~(u64)0x100; /* ignore ignne emulation enable */
1552 data &= ~(u64)0x8; /* ignore TLB cache disable */
1507 if (data != 0) { 1553 if (data != 0) {
1508 pr_unimpl(vcpu, "unimplemented HWCR wrmsr: 0x%llx\n", 1554 pr_unimpl(vcpu, "unimplemented HWCR wrmsr: 0x%llx\n",
1509 data); 1555 data);
@@ -1676,6 +1722,16 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
1676 */ 1722 */
1677 pr_unimpl(vcpu, "ignored wrmsr: 0x%x data %llx\n", msr, data); 1723 pr_unimpl(vcpu, "ignored wrmsr: 0x%x data %llx\n", msr, data);
1678 break; 1724 break;
1725 case MSR_AMD64_OSVW_ID_LENGTH:
1726 if (!guest_cpuid_has_osvw(vcpu))
1727 return 1;
1728 vcpu->arch.osvw.length = data;
1729 break;
1730 case MSR_AMD64_OSVW_STATUS:
1731 if (!guest_cpuid_has_osvw(vcpu))
1732 return 1;
1733 vcpu->arch.osvw.status = data;
1734 break;
1679 default: 1735 default:
1680 if (msr && (msr == vcpu->kvm->arch.xen_hvm_config.msr)) 1736 if (msr && (msr == vcpu->kvm->arch.xen_hvm_config.msr))
1681 return xen_hvm_config(vcpu, data); 1737 return xen_hvm_config(vcpu, data);
@@ -1960,6 +2016,16 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
1960 */ 2016 */
1961 data = 0xbe702111; 2017 data = 0xbe702111;
1962 break; 2018 break;
2019 case MSR_AMD64_OSVW_ID_LENGTH:
2020 if (!guest_cpuid_has_osvw(vcpu))
2021 return 1;
2022 data = vcpu->arch.osvw.length;
2023 break;
2024 case MSR_AMD64_OSVW_STATUS:
2025 if (!guest_cpuid_has_osvw(vcpu))
2026 return 1;
2027 data = vcpu->arch.osvw.status;
2028 break;
1963 default: 2029 default:
1964 if (kvm_pmu_msr(vcpu, msr)) 2030 if (kvm_pmu_msr(vcpu, msr))
1965 return kvm_pmu_get_msr(vcpu, msr, pdata); 2031 return kvm_pmu_get_msr(vcpu, msr, pdata);
@@ -2080,6 +2146,7 @@ int kvm_dev_ioctl_check_extension(long ext)
2080 case KVM_CAP_XSAVE: 2146 case KVM_CAP_XSAVE:
2081 case KVM_CAP_ASYNC_PF: 2147 case KVM_CAP_ASYNC_PF:
2082 case KVM_CAP_GET_TSC_KHZ: 2148 case KVM_CAP_GET_TSC_KHZ:
2149 case KVM_CAP_PCI_2_3:
2083 r = 1; 2150 r = 1;
2084 break; 2151 break;
2085 case KVM_CAP_COALESCED_MMIO: 2152 case KVM_CAP_COALESCED_MMIO:
@@ -2214,19 +2281,23 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
2214 } 2281 }
2215 2282
2216 kvm_x86_ops->vcpu_load(vcpu, cpu); 2283 kvm_x86_ops->vcpu_load(vcpu, cpu);
2217 if (unlikely(vcpu->cpu != cpu) || check_tsc_unstable()) {
2218 /* Make sure TSC doesn't go backwards */
2219 s64 tsc_delta;
2220 u64 tsc;
2221 2284
2222 tsc = kvm_x86_ops->read_l1_tsc(vcpu); 2285 /* Apply any externally detected TSC adjustments (due to suspend) */
2223 tsc_delta = !vcpu->arch.last_guest_tsc ? 0 : 2286 if (unlikely(vcpu->arch.tsc_offset_adjustment)) {
2224 tsc - vcpu->arch.last_guest_tsc; 2287 adjust_tsc_offset_host(vcpu, vcpu->arch.tsc_offset_adjustment);
2288 vcpu->arch.tsc_offset_adjustment = 0;
2289 set_bit(KVM_REQ_CLOCK_UPDATE, &vcpu->requests);
2290 }
2225 2291
2292 if (unlikely(vcpu->cpu != cpu) || check_tsc_unstable()) {
2293 s64 tsc_delta = !vcpu->arch.last_host_tsc ? 0 :
2294 native_read_tsc() - vcpu->arch.last_host_tsc;
2226 if (tsc_delta < 0) 2295 if (tsc_delta < 0)
2227 mark_tsc_unstable("KVM discovered backwards TSC"); 2296 mark_tsc_unstable("KVM discovered backwards TSC");
2228 if (check_tsc_unstable()) { 2297 if (check_tsc_unstable()) {
2229 kvm_x86_ops->adjust_tsc_offset(vcpu, -tsc_delta); 2298 u64 offset = kvm_x86_ops->compute_tsc_offset(vcpu,
2299 vcpu->arch.last_guest_tsc);
2300 kvm_x86_ops->write_tsc_offset(vcpu, offset);
2230 vcpu->arch.tsc_catchup = 1; 2301 vcpu->arch.tsc_catchup = 1;
2231 } 2302 }
2232 kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu); 2303 kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
@@ -2243,7 +2314,7 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
2243{ 2314{
2244 kvm_x86_ops->vcpu_put(vcpu); 2315 kvm_x86_ops->vcpu_put(vcpu);
2245 kvm_put_guest_fpu(vcpu); 2316 kvm_put_guest_fpu(vcpu);
2246 vcpu->arch.last_guest_tsc = kvm_x86_ops->read_l1_tsc(vcpu); 2317 vcpu->arch.last_host_tsc = native_read_tsc();
2247} 2318}
2248 2319
2249static int kvm_vcpu_ioctl_get_lapic(struct kvm_vcpu *vcpu, 2320static int kvm_vcpu_ioctl_get_lapic(struct kvm_vcpu *vcpu,
@@ -2785,26 +2856,21 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
2785 u32 user_tsc_khz; 2856 u32 user_tsc_khz;
2786 2857
2787 r = -EINVAL; 2858 r = -EINVAL;
2788 if (!kvm_has_tsc_control)
2789 break;
2790
2791 user_tsc_khz = (u32)arg; 2859 user_tsc_khz = (u32)arg;
2792 2860
2793 if (user_tsc_khz >= kvm_max_guest_tsc_khz) 2861 if (user_tsc_khz >= kvm_max_guest_tsc_khz)
2794 goto out; 2862 goto out;
2795 2863
2796 kvm_x86_ops->set_tsc_khz(vcpu, user_tsc_khz); 2864 if (user_tsc_khz == 0)
2865 user_tsc_khz = tsc_khz;
2866
2867 kvm_set_tsc_khz(vcpu, user_tsc_khz);
2797 2868
2798 r = 0; 2869 r = 0;
2799 goto out; 2870 goto out;
2800 } 2871 }
2801 case KVM_GET_TSC_KHZ: { 2872 case KVM_GET_TSC_KHZ: {
2802 r = -EIO; 2873 r = vcpu->arch.virtual_tsc_khz;
2803 if (check_tsc_unstable())
2804 goto out;
2805
2806 r = vcpu_tsc_khz(vcpu);
2807
2808 goto out; 2874 goto out;
2809 } 2875 }
2810 default: 2876 default:
@@ -2815,6 +2881,11 @@ out:
2815 return r; 2881 return r;
2816} 2882}
2817 2883
2884int kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf)
2885{
2886 return VM_FAULT_SIGBUS;
2887}
2888
2818static int kvm_vm_ioctl_set_tss_addr(struct kvm *kvm, unsigned long addr) 2889static int kvm_vm_ioctl_set_tss_addr(struct kvm *kvm, unsigned long addr)
2819{ 2890{
2820 int ret; 2891 int ret;
@@ -2998,6 +3069,8 @@ static void write_protect_slot(struct kvm *kvm,
2998 unsigned long *dirty_bitmap, 3069 unsigned long *dirty_bitmap,
2999 unsigned long nr_dirty_pages) 3070 unsigned long nr_dirty_pages)
3000{ 3071{
3072 spin_lock(&kvm->mmu_lock);
3073
3001 /* Not many dirty pages compared to # of shadow pages. */ 3074 /* Not many dirty pages compared to # of shadow pages. */
3002 if (nr_dirty_pages < kvm->arch.n_used_mmu_pages) { 3075 if (nr_dirty_pages < kvm->arch.n_used_mmu_pages) {
3003 unsigned long gfn_offset; 3076 unsigned long gfn_offset;
@@ -3005,16 +3078,13 @@ static void write_protect_slot(struct kvm *kvm,
3005 for_each_set_bit(gfn_offset, dirty_bitmap, memslot->npages) { 3078 for_each_set_bit(gfn_offset, dirty_bitmap, memslot->npages) {
3006 unsigned long gfn = memslot->base_gfn + gfn_offset; 3079 unsigned long gfn = memslot->base_gfn + gfn_offset;
3007 3080
3008 spin_lock(&kvm->mmu_lock);
3009 kvm_mmu_rmap_write_protect(kvm, gfn, memslot); 3081 kvm_mmu_rmap_write_protect(kvm, gfn, memslot);
3010 spin_unlock(&kvm->mmu_lock);
3011 } 3082 }
3012 kvm_flush_remote_tlbs(kvm); 3083 kvm_flush_remote_tlbs(kvm);
3013 } else { 3084 } else
3014 spin_lock(&kvm->mmu_lock);
3015 kvm_mmu_slot_remove_write_access(kvm, memslot->id); 3085 kvm_mmu_slot_remove_write_access(kvm, memslot->id);
3016 spin_unlock(&kvm->mmu_lock); 3086
3017 } 3087 spin_unlock(&kvm->mmu_lock);
3018} 3088}
3019 3089
3020/* 3090/*
@@ -3133,6 +3203,9 @@ long kvm_arch_vm_ioctl(struct file *filp,
3133 r = -EEXIST; 3203 r = -EEXIST;
3134 if (kvm->arch.vpic) 3204 if (kvm->arch.vpic)
3135 goto create_irqchip_unlock; 3205 goto create_irqchip_unlock;
3206 r = -EINVAL;
3207 if (atomic_read(&kvm->online_vcpus))
3208 goto create_irqchip_unlock;
3136 r = -ENOMEM; 3209 r = -ENOMEM;
3137 vpic = kvm_create_pic(kvm); 3210 vpic = kvm_create_pic(kvm);
3138 if (vpic) { 3211 if (vpic) {
@@ -4063,6 +4136,11 @@ static int emulator_set_cr(struct x86_emulate_ctxt *ctxt, int cr, ulong val)
4063 return res; 4136 return res;
4064} 4137}
4065 4138
4139static void emulator_set_rflags(struct x86_emulate_ctxt *ctxt, ulong val)
4140{
4141 kvm_set_rflags(emul_to_vcpu(ctxt), val);
4142}
4143
4066static int emulator_get_cpl(struct x86_emulate_ctxt *ctxt) 4144static int emulator_get_cpl(struct x86_emulate_ctxt *ctxt)
4067{ 4145{
4068 return kvm_x86_ops->get_cpl(emul_to_vcpu(ctxt)); 4146 return kvm_x86_ops->get_cpl(emul_to_vcpu(ctxt));
@@ -4244,6 +4322,7 @@ static struct x86_emulate_ops emulate_ops = {
4244 .set_idt = emulator_set_idt, 4322 .set_idt = emulator_set_idt,
4245 .get_cr = emulator_get_cr, 4323 .get_cr = emulator_get_cr,
4246 .set_cr = emulator_set_cr, 4324 .set_cr = emulator_set_cr,
4325 .set_rflags = emulator_set_rflags,
4247 .cpl = emulator_get_cpl, 4326 .cpl = emulator_get_cpl,
4248 .get_dr = emulator_get_dr, 4327 .get_dr = emulator_get_dr,
4249 .set_dr = emulator_set_dr, 4328 .set_dr = emulator_set_dr,
@@ -5288,6 +5367,8 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
5288 profile_hit(KVM_PROFILING, (void *)rip); 5367 profile_hit(KVM_PROFILING, (void *)rip);
5289 } 5368 }
5290 5369
5370 if (unlikely(vcpu->arch.tsc_always_catchup))
5371 kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
5291 5372
5292 kvm_lapic_sync_from_vapic(vcpu); 5373 kvm_lapic_sync_from_vapic(vcpu);
5293 5374
@@ -5587,15 +5668,15 @@ int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu,
5587 return 0; 5668 return 0;
5588} 5669}
5589 5670
5590int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int reason, 5671int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int idt_index,
5591 bool has_error_code, u32 error_code) 5672 int reason, bool has_error_code, u32 error_code)
5592{ 5673{
5593 struct x86_emulate_ctxt *ctxt = &vcpu->arch.emulate_ctxt; 5674 struct x86_emulate_ctxt *ctxt = &vcpu->arch.emulate_ctxt;
5594 int ret; 5675 int ret;
5595 5676
5596 init_emulate_ctxt(vcpu); 5677 init_emulate_ctxt(vcpu);
5597 5678
5598 ret = emulator_task_switch(ctxt, tss_selector, reason, 5679 ret = emulator_task_switch(ctxt, tss_selector, idt_index, reason,
5599 has_error_code, error_code); 5680 has_error_code, error_code);
5600 5681
5601 if (ret) 5682 if (ret)
@@ -5928,13 +6009,88 @@ int kvm_arch_hardware_enable(void *garbage)
5928 struct kvm *kvm; 6009 struct kvm *kvm;
5929 struct kvm_vcpu *vcpu; 6010 struct kvm_vcpu *vcpu;
5930 int i; 6011 int i;
6012 int ret;
6013 u64 local_tsc;
6014 u64 max_tsc = 0;
6015 bool stable, backwards_tsc = false;
5931 6016
5932 kvm_shared_msr_cpu_online(); 6017 kvm_shared_msr_cpu_online();
5933 list_for_each_entry(kvm, &vm_list, vm_list) 6018 ret = kvm_x86_ops->hardware_enable(garbage);
5934 kvm_for_each_vcpu(i, vcpu, kvm) 6019 if (ret != 0)
5935 if (vcpu->cpu == smp_processor_id()) 6020 return ret;
5936 kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu); 6021
5937 return kvm_x86_ops->hardware_enable(garbage); 6022 local_tsc = native_read_tsc();
6023 stable = !check_tsc_unstable();
6024 list_for_each_entry(kvm, &vm_list, vm_list) {
6025 kvm_for_each_vcpu(i, vcpu, kvm) {
6026 if (!stable && vcpu->cpu == smp_processor_id())
6027 set_bit(KVM_REQ_CLOCK_UPDATE, &vcpu->requests);
6028 if (stable && vcpu->arch.last_host_tsc > local_tsc) {
6029 backwards_tsc = true;
6030 if (vcpu->arch.last_host_tsc > max_tsc)
6031 max_tsc = vcpu->arch.last_host_tsc;
6032 }
6033 }
6034 }
6035
6036 /*
6037 * Sometimes, even reliable TSCs go backwards. This happens on
6038 * platforms that reset TSC during suspend or hibernate actions, but
6039 * maintain synchronization. We must compensate. Fortunately, we can
6040 * detect that condition here, which happens early in CPU bringup,
6041 * before any KVM threads can be running. Unfortunately, we can't
6042 * bring the TSCs fully up to date with real time, as we aren't yet far
6043 * enough into CPU bringup that we know how much real time has actually
6044 * elapsed; our helper function, get_kernel_ns() will be using boot
6045 * variables that haven't been updated yet.
6046 *
6047 * So we simply find the maximum observed TSC above, then record the
6048 * adjustment to TSC in each VCPU. When the VCPU later gets loaded,
6049 * the adjustment will be applied. Note that we accumulate
6050 * adjustments, in case multiple suspend cycles happen before some VCPU
6051 * gets a chance to run again. In the event that no KVM threads get a
6052 * chance to run, we will miss the entire elapsed period, as we'll have
6053 * reset last_host_tsc, so VCPUs will not have the TSC adjusted and may
6054 * loose cycle time. This isn't too big a deal, since the loss will be
6055 * uniform across all VCPUs (not to mention the scenario is extremely
6056 * unlikely). It is possible that a second hibernate recovery happens
6057 * much faster than a first, causing the observed TSC here to be
6058 * smaller; this would require additional padding adjustment, which is
6059 * why we set last_host_tsc to the local tsc observed here.
6060 *
6061 * N.B. - this code below runs only on platforms with reliable TSC,
6062 * as that is the only way backwards_tsc is set above. Also note
6063 * that this runs for ALL vcpus, which is not a bug; all VCPUs should
6064 * have the same delta_cyc adjustment applied if backwards_tsc
6065 * is detected. Note further, this adjustment is only done once,
6066 * as we reset last_host_tsc on all VCPUs to stop this from being
6067 * called multiple times (one for each physical CPU bringup).
6068 *
6069 * Platforms with unnreliable TSCs don't have to deal with this, they
6070 * will be compensated by the logic in vcpu_load, which sets the TSC to
6071 * catchup mode. This will catchup all VCPUs to real time, but cannot
6072 * guarantee that they stay in perfect synchronization.
6073 */
6074 if (backwards_tsc) {
6075 u64 delta_cyc = max_tsc - local_tsc;
6076 list_for_each_entry(kvm, &vm_list, vm_list) {
6077 kvm_for_each_vcpu(i, vcpu, kvm) {
6078 vcpu->arch.tsc_offset_adjustment += delta_cyc;
6079 vcpu->arch.last_host_tsc = local_tsc;
6080 }
6081
6082 /*
6083 * We have to disable TSC offset matching.. if you were
6084 * booting a VM while issuing an S4 host suspend....
6085 * you may have some problem. Solving this issue is
6086 * left as an exercise to the reader.
6087 */
6088 kvm->arch.last_tsc_nsec = 0;
6089 kvm->arch.last_tsc_write = 0;
6090 }
6091
6092 }
6093 return 0;
5938} 6094}
5939 6095
5940void kvm_arch_hardware_disable(void *garbage) 6096void kvm_arch_hardware_disable(void *garbage)
@@ -5958,6 +6114,11 @@ void kvm_arch_check_processor_compat(void *rtn)
5958 kvm_x86_ops->check_processor_compatibility(rtn); 6114 kvm_x86_ops->check_processor_compatibility(rtn);
5959} 6115}
5960 6116
6117bool kvm_vcpu_compatible(struct kvm_vcpu *vcpu)
6118{
6119 return irqchip_in_kernel(vcpu->kvm) == (vcpu->arch.apic != NULL);
6120}
6121
5961int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu) 6122int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
5962{ 6123{
5963 struct page *page; 6124 struct page *page;
@@ -5980,7 +6141,7 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
5980 } 6141 }
5981 vcpu->arch.pio_data = page_address(page); 6142 vcpu->arch.pio_data = page_address(page);
5982 6143
5983 kvm_init_tsc_catchup(vcpu, max_tsc_khz); 6144 kvm_set_tsc_khz(vcpu, max_tsc_khz);
5984 6145
5985 r = kvm_mmu_create(vcpu); 6146 r = kvm_mmu_create(vcpu);
5986 if (r < 0) 6147 if (r < 0)
@@ -6032,8 +6193,11 @@ void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu)
6032 free_page((unsigned long)vcpu->arch.pio_data); 6193 free_page((unsigned long)vcpu->arch.pio_data);
6033} 6194}
6034 6195
6035int kvm_arch_init_vm(struct kvm *kvm) 6196int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
6036{ 6197{
6198 if (type)
6199 return -EINVAL;
6200
6037 INIT_LIST_HEAD(&kvm->arch.active_mmu_pages); 6201 INIT_LIST_HEAD(&kvm->arch.active_mmu_pages);
6038 INIT_LIST_HEAD(&kvm->arch.assigned_dev_head); 6202 INIT_LIST_HEAD(&kvm->arch.assigned_dev_head);
6039 6203
@@ -6093,6 +6257,65 @@ void kvm_arch_destroy_vm(struct kvm *kvm)
6093 put_page(kvm->arch.ept_identity_pagetable); 6257 put_page(kvm->arch.ept_identity_pagetable);
6094} 6258}
6095 6259
6260void kvm_arch_free_memslot(struct kvm_memory_slot *free,
6261 struct kvm_memory_slot *dont)
6262{
6263 int i;
6264
6265 for (i = 0; i < KVM_NR_PAGE_SIZES - 1; ++i) {
6266 if (!dont || free->arch.lpage_info[i] != dont->arch.lpage_info[i]) {
6267 vfree(free->arch.lpage_info[i]);
6268 free->arch.lpage_info[i] = NULL;
6269 }
6270 }
6271}
6272
6273int kvm_arch_create_memslot(struct kvm_memory_slot *slot, unsigned long npages)
6274{
6275 int i;
6276
6277 for (i = 0; i < KVM_NR_PAGE_SIZES - 1; ++i) {
6278 unsigned long ugfn;
6279 int lpages;
6280 int level = i + 2;
6281
6282 lpages = gfn_to_index(slot->base_gfn + npages - 1,
6283 slot->base_gfn, level) + 1;
6284
6285 slot->arch.lpage_info[i] =
6286 vzalloc(lpages * sizeof(*slot->arch.lpage_info[i]));
6287 if (!slot->arch.lpage_info[i])
6288 goto out_free;
6289
6290 if (slot->base_gfn & (KVM_PAGES_PER_HPAGE(level) - 1))
6291 slot->arch.lpage_info[i][0].write_count = 1;
6292 if ((slot->base_gfn + npages) & (KVM_PAGES_PER_HPAGE(level) - 1))
6293 slot->arch.lpage_info[i][lpages - 1].write_count = 1;
6294 ugfn = slot->userspace_addr >> PAGE_SHIFT;
6295 /*
6296 * If the gfn and userspace address are not aligned wrt each
6297 * other, or if explicitly asked to, disable large page
6298 * support for this slot
6299 */
6300 if ((slot->base_gfn ^ ugfn) & (KVM_PAGES_PER_HPAGE(level) - 1) ||
6301 !kvm_largepages_enabled()) {
6302 unsigned long j;
6303
6304 for (j = 0; j < lpages; ++j)
6305 slot->arch.lpage_info[i][j].write_count = 1;
6306 }
6307 }
6308
6309 return 0;
6310
6311out_free:
6312 for (i = 0; i < KVM_NR_PAGE_SIZES - 1; ++i) {
6313 vfree(slot->arch.lpage_info[i]);
6314 slot->arch.lpage_info[i] = NULL;
6315 }
6316 return -ENOMEM;
6317}
6318
6096int kvm_arch_prepare_memory_region(struct kvm *kvm, 6319int kvm_arch_prepare_memory_region(struct kvm *kvm,
6097 struct kvm_memory_slot *memslot, 6320 struct kvm_memory_slot *memslot,
6098 struct kvm_memory_slot old, 6321 struct kvm_memory_slot old,
diff --git a/arch/x86/mm/kmemcheck/selftest.c b/arch/x86/mm/kmemcheck/selftest.c
index 036efbea8b2..aef7140c006 100644
--- a/arch/x86/mm/kmemcheck/selftest.c
+++ b/arch/x86/mm/kmemcheck/selftest.c
@@ -1,3 +1,4 @@
1#include <linux/bug.h>
1#include <linux/kernel.h> 2#include <linux/kernel.h>
2 3
3#include "opcode.h" 4#include "opcode.h"
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index 49a5cb55429..ed2835e148b 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -416,7 +416,12 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_pci_root *root)
416 kfree(sd); 416 kfree(sd);
417 } else { 417 } else {
418 get_current_resources(device, busnum, domain, &resources); 418 get_current_resources(device, busnum, domain, &resources);
419 if (list_empty(&resources)) 419
420 /*
421 * _CRS with no apertures is normal, so only fall back to
422 * defaults or native bridge info if we're ignoring _CRS.
423 */
424 if (!pci_use_crs)
420 x86_pci_root_bus_resources(busnum, &resources); 425 x86_pci_root_bus_resources(busnum, &resources);
421 bus = pci_create_root_bus(NULL, busnum, &pci_root_ops, sd, 426 bus = pci_create_root_bus(NULL, busnum, &pci_root_ops, sd,
422 &resources); 427 &resources);
diff --git a/arch/x86/pci/fixup.c b/arch/x86/pci/fixup.c
index 6dd89555fbf..d0e6e403b4f 100644
--- a/arch/x86/pci/fixup.c
+++ b/arch/x86/pci/fixup.c
@@ -164,11 +164,11 @@ DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8367_0, pci_fixup_
164 */ 164 */
165static void __devinit pci_fixup_transparent_bridge(struct pci_dev *dev) 165static void __devinit pci_fixup_transparent_bridge(struct pci_dev *dev)
166{ 166{
167 if ((dev->class >> 8) == PCI_CLASS_BRIDGE_PCI && 167 if ((dev->device & 0xff00) == 0x2400)
168 (dev->device & 0xff00) == 0x2400)
169 dev->transparent = 1; 168 dev->transparent = 1;
170} 169}
171DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, pci_fixup_transparent_bridge); 170DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_VENDOR_ID_INTEL, PCI_ANY_ID,
171 PCI_CLASS_BRIDGE_PCI, 8, pci_fixup_transparent_bridge);
172 172
173/* 173/*
174 * Fixup for C1 Halt Disconnect problem on nForce2 systems. 174 * Fixup for C1 Halt Disconnect problem on nForce2 systems.
@@ -322,9 +322,6 @@ static void __devinit pci_fixup_video(struct pci_dev *pdev)
322 struct pci_bus *bus; 322 struct pci_bus *bus;
323 u16 config; 323 u16 config;
324 324
325 if ((pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA)
326 return;
327
328 /* Is VGA routed to us? */ 325 /* Is VGA routed to us? */
329 bus = pdev->bus; 326 bus = pdev->bus;
330 while (bus) { 327 while (bus) {
@@ -353,7 +350,8 @@ static void __devinit pci_fixup_video(struct pci_dev *pdev)
353 dev_printk(KERN_DEBUG, &pdev->dev, "Boot video device\n"); 350 dev_printk(KERN_DEBUG, &pdev->dev, "Boot video device\n");
354 } 351 }
355} 352}
356DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, pci_fixup_video); 353DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID,
354 PCI_CLASS_DISPLAY_VGA, 8, pci_fixup_video);
357 355
358 356
359static const struct dmi_system_id __devinitconst msi_k8t_dmi_table[] = { 357static const struct dmi_system_id __devinitconst msi_k8t_dmi_table[] = {
diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
index 91821a1a0c3..831971e731f 100644
--- a/arch/x86/pci/i386.c
+++ b/arch/x86/pci/i386.c
@@ -39,6 +39,87 @@
39#include <asm/io_apic.h> 39#include <asm/io_apic.h>
40 40
41 41
42/*
43 * This list of dynamic mappings is for temporarily maintaining
44 * original BIOS BAR addresses for possible reinstatement.
45 */
46struct pcibios_fwaddrmap {
47 struct list_head list;
48 struct pci_dev *dev;
49 resource_size_t fw_addr[DEVICE_COUNT_RESOURCE];
50};
51
52static LIST_HEAD(pcibios_fwaddrmappings);
53static DEFINE_SPINLOCK(pcibios_fwaddrmap_lock);
54
55/* Must be called with 'pcibios_fwaddrmap_lock' lock held. */
56static struct pcibios_fwaddrmap *pcibios_fwaddrmap_lookup(struct pci_dev *dev)
57{
58 struct pcibios_fwaddrmap *map;
59
60 WARN_ON(!spin_is_locked(&pcibios_fwaddrmap_lock));
61
62 list_for_each_entry(map, &pcibios_fwaddrmappings, list)
63 if (map->dev == dev)
64 return map;
65
66 return NULL;
67}
68
69static void
70pcibios_save_fw_addr(struct pci_dev *dev, int idx, resource_size_t fw_addr)
71{
72 unsigned long flags;
73 struct pcibios_fwaddrmap *map;
74
75 spin_lock_irqsave(&pcibios_fwaddrmap_lock, flags);
76 map = pcibios_fwaddrmap_lookup(dev);
77 if (!map) {
78 spin_unlock_irqrestore(&pcibios_fwaddrmap_lock, flags);
79 map = kzalloc(sizeof(*map), GFP_KERNEL);
80 if (!map)
81 return;
82
83 map->dev = pci_dev_get(dev);
84 map->fw_addr[idx] = fw_addr;
85 INIT_LIST_HEAD(&map->list);
86
87 spin_lock_irqsave(&pcibios_fwaddrmap_lock, flags);
88 list_add_tail(&map->list, &pcibios_fwaddrmappings);
89 } else
90 map->fw_addr[idx] = fw_addr;
91 spin_unlock_irqrestore(&pcibios_fwaddrmap_lock, flags);
92}
93
94resource_size_t pcibios_retrieve_fw_addr(struct pci_dev *dev, int idx)
95{
96 unsigned long flags;
97 struct pcibios_fwaddrmap *map;
98 resource_size_t fw_addr = 0;
99
100 spin_lock_irqsave(&pcibios_fwaddrmap_lock, flags);
101 map = pcibios_fwaddrmap_lookup(dev);
102 if (map)
103 fw_addr = map->fw_addr[idx];
104 spin_unlock_irqrestore(&pcibios_fwaddrmap_lock, flags);
105
106 return fw_addr;
107}
108
109static void pcibios_fw_addr_list_del(void)
110{
111 unsigned long flags;
112 struct pcibios_fwaddrmap *entry, *next;
113
114 spin_lock_irqsave(&pcibios_fwaddrmap_lock, flags);
115 list_for_each_entry_safe(entry, next, &pcibios_fwaddrmappings, list) {
116 list_del(&entry->list);
117 pci_dev_put(entry->dev);
118 kfree(entry);
119 }
120 spin_unlock_irqrestore(&pcibios_fwaddrmap_lock, flags);
121}
122
42static int 123static int
43skip_isa_ioresource_align(struct pci_dev *dev) { 124skip_isa_ioresource_align(struct pci_dev *dev) {
44 125
@@ -182,7 +263,8 @@ static void __init pcibios_allocate_resources(int pass)
182 idx, r, disabled, pass); 263 idx, r, disabled, pass);
183 if (pci_claim_resource(dev, idx) < 0) { 264 if (pci_claim_resource(dev, idx) < 0) {
184 /* We'll assign a new address later */ 265 /* We'll assign a new address later */
185 dev->fw_addr[idx] = r->start; 266 pcibios_save_fw_addr(dev,
267 idx, r->start);
186 r->end -= r->start; 268 r->end -= r->start;
187 r->start = 0; 269 r->start = 0;
188 } 270 }
@@ -228,6 +310,7 @@ static int __init pcibios_assign_resources(void)
228 } 310 }
229 311
230 pci_assign_unassigned_resources(); 312 pci_assign_unassigned_resources();
313 pcibios_fw_addr_list_del();
231 314
232 return 0; 315 return 0;
233} 316}
diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
index cb29191cee5..140942f66b3 100644
--- a/arch/x86/pci/mrst.c
+++ b/arch/x86/pci/mrst.c
@@ -43,6 +43,8 @@
43#define PCI_FIXED_BAR_4_SIZE 0x14 43#define PCI_FIXED_BAR_4_SIZE 0x14
44#define PCI_FIXED_BAR_5_SIZE 0x1c 44#define PCI_FIXED_BAR_5_SIZE 0x1c
45 45
46static int pci_soc_mode = 0;
47
46/** 48/**
47 * fixed_bar_cap - return the offset of the fixed BAR cap if found 49 * fixed_bar_cap - return the offset of the fixed BAR cap if found
48 * @bus: PCI bus 50 * @bus: PCI bus
@@ -148,7 +150,9 @@ static bool type1_access_ok(unsigned int bus, unsigned int devfn, int reg)
148 */ 150 */
149 if (reg >= 0x100 || reg == PCI_STATUS || reg == PCI_HEADER_TYPE) 151 if (reg >= 0x100 || reg == PCI_STATUS || reg == PCI_HEADER_TYPE)
150 return 0; 152 return 0;
151 if (bus == 0 && (devfn == PCI_DEVFN(2, 0) || devfn == PCI_DEVFN(0, 0))) 153 if (bus == 0 && (devfn == PCI_DEVFN(2, 0)
154 || devfn == PCI_DEVFN(0, 0)
155 || devfn == PCI_DEVFN(3, 0)))
152 return 1; 156 return 1;
153 return 0; /* langwell on others */ 157 return 0; /* langwell on others */
154} 158}
@@ -231,14 +235,43 @@ struct pci_ops pci_mrst_ops = {
231 */ 235 */
232int __init pci_mrst_init(void) 236int __init pci_mrst_init(void)
233{ 237{
234 printk(KERN_INFO "Moorestown platform detected, using MRST PCI ops\n"); 238 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
235 pci_mmcfg_late_init(); 239 pci_mmcfg_late_init();
236 pcibios_enable_irq = mrst_pci_irq_enable; 240 pcibios_enable_irq = mrst_pci_irq_enable;
237 pci_root_ops = pci_mrst_ops; 241 pci_root_ops = pci_mrst_ops;
242 pci_soc_mode = 1;
238 /* Continue with standard init */ 243 /* Continue with standard init */
239 return 1; 244 return 1;
240} 245}
241 246
247/* Langwell devices are not true pci devices, they are not subject to 10 ms
248 * d3 to d0 delay required by pci spec.
249 */
250static void __devinit pci_d3delay_fixup(struct pci_dev *dev)
251{
252 /* PCI fixups are effectively decided compile time. If we have a dual
253 SoC/non-SoC kernel we don't want to mangle d3 on non SoC devices */
254 if (!pci_soc_mode)
255 return;
256 /* true pci devices in lincroft should allow type 1 access, the rest
257 * are langwell fake pci devices.
258 */
259 if (type1_access_ok(dev->bus->number, dev->devfn, PCI_DEVICE_ID))
260 return;
261 dev->d3_delay = 0;
262}
263DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, pci_d3delay_fixup);
264
265static void __devinit mrst_power_off_unused_dev(struct pci_dev *dev)
266{
267 pci_set_power_state(dev, PCI_D3cold);
268}
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);
271DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x080C, mrst_power_off_unused_dev);
272DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0812, mrst_power_off_unused_dev);
273DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0815, mrst_power_off_unused_dev);
274
242/* 275/*
243 * Langwell devices reside at fixed offsets, don't try to move them. 276 * Langwell devices reside at fixed offsets, don't try to move them.
244 */ 277 */
@@ -248,6 +281,9 @@ static void __devinit pci_fixed_bar_fixup(struct pci_dev *dev)
248 u32 size; 281 u32 size;
249 int i; 282 int i;
250 283
284 if (!pci_soc_mode)
285 return;
286
251 /* Must have extended configuration space */ 287 /* Must have extended configuration space */
252 if (dev->cfg_size < PCIE_CAP_OFFSET + 4) 288 if (dev->cfg_size < PCIE_CAP_OFFSET + 4)
253 return; 289 return;
diff --git a/arch/x86/platform/ce4100/falconfalls.dts b/arch/x86/platform/ce4100/falconfalls.dts
index e70be38ce03..ce874f872cc 100644
--- a/arch/x86/platform/ce4100/falconfalls.dts
+++ b/arch/x86/platform/ce4100/falconfalls.dts
@@ -208,16 +208,19 @@
208 interrupts = <14 1>; 208 interrupts = <14 1>;
209 }; 209 };
210 210
211 gpio@b,1 { 211 pcigpio: gpio@b,1 {
212 #gpio-cells = <2>;
213 #interrupt-cells = <2>;
212 compatible = "pci8086,2e67.2", 214 compatible = "pci8086,2e67.2",
213 "pci8086,2e67", 215 "pci8086,2e67",
214 "pciclassff0000", 216 "pciclassff0000",
215 "pciclassff00"; 217 "pciclassff00";
216 218
217 #gpio-cells = <2>;
218 reg = <0x15900 0x0 0x0 0x0 0x0>; 219 reg = <0x15900 0x0 0x0 0x0 0x0>;
219 interrupts = <15 1>; 220 interrupts = <15 1>;
221 interrupt-controller;
220 gpio-controller; 222 gpio-controller;
223 intel,muxctl = <0>;
221 }; 224 };
222 225
223 i2c-controller@b,2 { 226 i2c-controller@b,2 {
diff --git a/arch/x86/platform/geode/Makefile b/arch/x86/platform/geode/Makefile
index 246b788847f..5b51194f4c8 100644
--- a/arch/x86/platform/geode/Makefile
+++ b/arch/x86/platform/geode/Makefile
@@ -1,2 +1,3 @@
1obj-$(CONFIG_ALIX) += alix.o 1obj-$(CONFIG_ALIX) += alix.o
2obj-$(CONFIG_NET5501) += net5501.o 2obj-$(CONFIG_NET5501) += net5501.o
3obj-$(CONFIG_GEOS) += geos.o
diff --git a/arch/x86/platform/geode/geos.c b/arch/x86/platform/geode/geos.c
new file mode 100644
index 00000000000..c2e6d53558b
--- /dev/null
+++ b/arch/x86/platform/geode/geos.c
@@ -0,0 +1,128 @@
1/*
2 * System Specific setup for Traverse Technologies GEOS.
3 * At the moment this means setup of GPIO control of LEDs.
4 *
5 * Copyright (C) 2008 Constantin Baranov <const@mimas.ru>
6 * Copyright (C) 2011 Ed Wildgoose <kernel@wildgooses.com>
7 * and Philip Prindeville <philipp@redfish-solutions.com>
8 *
9 * TODO: There are large similarities with leds-net5501.c
10 * by Alessandro Zummo <a.zummo@towertech.it>
11 * In the future leds-net5501.c should be migrated over to platform
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2
15 * as published by the Free Software Foundation.
16 */
17
18#include <linux/kernel.h>
19#include <linux/init.h>
20#include <linux/io.h>
21#include <linux/string.h>
22#include <linux/module.h>
23#include <linux/leds.h>
24#include <linux/platform_device.h>
25#include <linux/gpio.h>
26#include <linux/input.h>
27#include <linux/gpio_keys.h>
28#include <linux/dmi.h>
29
30#include <asm/geode.h>
31
32static struct gpio_keys_button geos_gpio_buttons[] = {
33 {
34 .code = KEY_RESTART,
35 .gpio = 3,
36 .active_low = 1,
37 .desc = "Reset button",
38 .type = EV_KEY,
39 .wakeup = 0,
40 .debounce_interval = 100,
41 .can_disable = 0,
42 }
43};
44static struct gpio_keys_platform_data geos_buttons_data = {
45 .buttons = geos_gpio_buttons,
46 .nbuttons = ARRAY_SIZE(geos_gpio_buttons),
47 .poll_interval = 20,
48};
49
50static struct platform_device geos_buttons_dev = {
51 .name = "gpio-keys-polled",
52 .id = 1,
53 .dev = {
54 .platform_data = &geos_buttons_data,
55 }
56};
57
58static struct gpio_led geos_leds[] = {
59 {
60 .name = "geos:1",
61 .gpio = 6,
62 .default_trigger = "default-on",
63 .active_low = 1,
64 },
65 {
66 .name = "geos:2",
67 .gpio = 25,
68 .default_trigger = "default-off",
69 .active_low = 1,
70 },
71 {
72 .name = "geos:3",
73 .gpio = 27,
74 .default_trigger = "default-off",
75 .active_low = 1,
76 },
77};
78
79static struct gpio_led_platform_data geos_leds_data = {
80 .num_leds = ARRAY_SIZE(geos_leds),
81 .leds = geos_leds,
82};
83
84static struct platform_device geos_leds_dev = {
85 .name = "leds-gpio",
86 .id = -1,
87 .dev.platform_data = &geos_leds_data,
88};
89
90static struct __initdata platform_device *geos_devs[] = {
91 &geos_buttons_dev,
92 &geos_leds_dev,
93};
94
95static void __init register_geos(void)
96{
97 /* Setup LED control through leds-gpio driver */
98 platform_add_devices(geos_devs, ARRAY_SIZE(geos_devs));
99}
100
101static int __init geos_init(void)
102{
103 const char *vendor, *product;
104
105 if (!is_geode())
106 return 0;
107
108 vendor = dmi_get_system_info(DMI_SYS_VENDOR);
109 if (!vendor || strcmp(vendor, "Traverse Technologies"))
110 return 0;
111
112 product = dmi_get_system_info(DMI_PRODUCT_NAME);
113 if (!product || strcmp(product, "Geos"))
114 return 0;
115
116 printk(KERN_INFO "%s: system is recognized as \"%s %s\"\n",
117 KBUILD_MODNAME, vendor, product);
118
119 register_geos();
120
121 return 0;
122}
123
124module_init(geos_init);
125
126MODULE_AUTHOR("Philip Prindeville <philipp@redfish-solutions.com>");
127MODULE_DESCRIPTION("Traverse Technologies Geos System Setup");
128MODULE_LICENSE("GPL");
diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
index 4889655ba78..47936830968 100644
--- a/arch/x86/power/cpu.c
+++ b/arch/x86/power/cpu.c
@@ -115,7 +115,7 @@ static void __save_processor_state(struct saved_context *ctxt)
115void save_processor_state(void) 115void save_processor_state(void)
116{ 116{
117 __save_processor_state(&saved_context); 117 __save_processor_state(&saved_context);
118 save_sched_clock_state(); 118 x86_platform.save_sched_clock_state();
119} 119}
120#ifdef CONFIG_X86_32 120#ifdef CONFIG_X86_32
121EXPORT_SYMBOL(save_processor_state); 121EXPORT_SYMBOL(save_processor_state);
@@ -231,8 +231,8 @@ static void __restore_processor_state(struct saved_context *ctxt)
231/* Needed by apm.c */ 231/* Needed by apm.c */
232void restore_processor_state(void) 232void restore_processor_state(void)
233{ 233{
234 x86_platform.restore_sched_clock_state();
234 __restore_processor_state(&saved_context); 235 __restore_processor_state(&saved_context);
235 restore_sched_clock_state();
236} 236}
237#ifdef CONFIG_X86_32 237#ifdef CONFIG_X86_32
238EXPORT_SYMBOL(restore_processor_state); 238EXPORT_SYMBOL(restore_processor_state);
diff --git a/arch/x86/syscalls/syscall_32.tbl b/arch/x86/syscalls/syscall_32.tbl
index ce98e287c06..e7e67cc3c14 100644
--- a/arch/x86/syscalls/syscall_32.tbl
+++ b/arch/x86/syscalls/syscall_32.tbl
@@ -288,7 +288,7 @@
288279 i386 mq_timedsend sys_mq_timedsend compat_sys_mq_timedsend 288279 i386 mq_timedsend sys_mq_timedsend compat_sys_mq_timedsend
289280 i386 mq_timedreceive sys_mq_timedreceive compat_sys_mq_timedreceive 289280 i386 mq_timedreceive sys_mq_timedreceive compat_sys_mq_timedreceive
290281 i386 mq_notify sys_mq_notify compat_sys_mq_notify 290281 i386 mq_notify sys_mq_notify compat_sys_mq_notify
291282 i386 mq_getsetaddr sys_mq_getsetattr compat_sys_mq_getsetattr 291282 i386 mq_getsetattr sys_mq_getsetattr compat_sys_mq_getsetattr
292283 i386 kexec_load sys_kexec_load compat_sys_kexec_load 292283 i386 kexec_load sys_kexec_load compat_sys_kexec_load
293284 i386 waitid sys_waitid compat_sys_waitid 293284 i386 waitid sys_waitid compat_sys_waitid
294# 285 sys_setaltroot 294# 285 sys_setaltroot
diff --git a/arch/x86/um/Kconfig b/arch/x86/um/Kconfig
index b2b54d2edf5..9926e11a772 100644
--- a/arch/x86/um/Kconfig
+++ b/arch/x86/um/Kconfig
@@ -15,8 +15,8 @@ config UML_X86
15 select GENERIC_FIND_FIRST_BIT 15 select GENERIC_FIND_FIRST_BIT
16 16
17config 64BIT 17config 64BIT
18 bool 18 bool "64-bit kernel" if SUBARCH = "x86"
19 default SUBARCH = "x86_64" 19 default SUBARCH != "i386"
20 20
21config X86_32 21config X86_32
22 def_bool !64BIT 22 def_bool !64BIT
diff --git a/arch/x86/um/asm/processor.h b/arch/x86/um/asm/processor.h
index 2c32df6fe23..04f82e020f2 100644
--- a/arch/x86/um/asm/processor.h
+++ b/arch/x86/um/asm/processor.h
@@ -17,6 +17,16 @@
17#define ARCH_IS_STACKGROW(address) \ 17#define ARCH_IS_STACKGROW(address) \
18 (address + 65536 + 32 * sizeof(unsigned long) >= UPT_SP(&current->thread.regs.regs)) 18 (address + 65536 + 32 * sizeof(unsigned long) >= UPT_SP(&current->thread.regs.regs))
19 19
20#include <asm/user.h>
21
22/* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
23static inline void rep_nop(void)
24{
25 __asm__ __volatile__("rep;nop": : :"memory");
26}
27
28#define cpu_relax() rep_nop()
29
20#include <asm/processor-generic.h> 30#include <asm/processor-generic.h>
21 31
22#endif 32#endif
diff --git a/arch/x86/um/asm/processor_32.h b/arch/x86/um/asm/processor_32.h
index 018f732704d..6c6689e574c 100644
--- a/arch/x86/um/asm/processor_32.h
+++ b/arch/x86/um/asm/processor_32.h
@@ -45,16 +45,6 @@ static inline void arch_copy_thread(struct arch_thread *from,
45 memcpy(&to->tls_array, &from->tls_array, sizeof(from->tls_array)); 45 memcpy(&to->tls_array, &from->tls_array, sizeof(from->tls_array));
46} 46}
47 47
48#include <asm/user.h>
49
50/* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
51static inline void rep_nop(void)
52{
53 __asm__ __volatile__("rep;nop": : :"memory");
54}
55
56#define cpu_relax() rep_nop()
57
58/* 48/*
59 * Default implementation of macro that returns current 49 * Default implementation of macro that returns current
60 * instruction pointer ("program counter"). Stolen 50 * instruction pointer ("program counter"). Stolen
diff --git a/arch/x86/um/asm/processor_64.h b/arch/x86/um/asm/processor_64.h
index 61de92d916c..4b02a8455bd 100644
--- a/arch/x86/um/asm/processor_64.h
+++ b/arch/x86/um/asm/processor_64.h
@@ -14,14 +14,6 @@ struct arch_thread {
14 struct faultinfo faultinfo; 14 struct faultinfo faultinfo;
15}; 15};
16 16
17/* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
18static inline void rep_nop(void)
19{
20 __asm__ __volatile__("rep;nop": : :"memory");
21}
22
23#define cpu_relax() rep_nop()
24
25#define INIT_ARCH_THREAD { .debugregs = { [ 0 ... 7 ] = 0 }, \ 17#define INIT_ARCH_THREAD { .debugregs = { [ 0 ... 7 ] = 0 }, \
26 .debugregs_seq = 0, \ 18 .debugregs_seq = 0, \
27 .fs = 0, \ 19 .fs = 0, \
@@ -37,8 +29,6 @@ static inline void arch_copy_thread(struct arch_thread *from,
37 to->fs = from->fs; 29 to->fs = from->fs;
38} 30}
39 31
40#include <asm/user.h>
41
42#define current_text_addr() \ 32#define current_text_addr() \
43 ({ void *pc; __asm__("movq $1f,%0\n1:":"=g" (pc)); pc; }) 33 ({ void *pc; __asm__("movq $1f,%0\n1:":"=g" (pc)); pc; })
44 34
diff --git a/arch/x86/um/bugs_32.c b/arch/x86/um/bugs_32.c
index a1fba5fb9db..17d88cf2c6c 100644
--- a/arch/x86/um/bugs_32.c
+++ b/arch/x86/um/bugs_32.c
@@ -13,8 +13,6 @@
13static int host_has_cmov = 1; 13static int host_has_cmov = 1;
14static jmp_buf cmov_test_return; 14static jmp_buf cmov_test_return;
15 15
16#define TASK_PID(task) *((int *) &(((char *) (task))[HOST_TASK_PID]))
17
18static void cmov_sigill_test_handler(int sig) 16static void cmov_sigill_test_handler(int sig)
19{ 17{
20 host_has_cmov = 0; 18 host_has_cmov = 0;
@@ -51,7 +49,7 @@ void arch_examine_signal(int sig, struct uml_pt_regs *regs)
51 * This is testing for a cmov (0x0f 0x4x) instruction causing a 49 * This is testing for a cmov (0x0f 0x4x) instruction causing a
52 * SIGILL in init. 50 * SIGILL in init.
53 */ 51 */
54 if ((sig != SIGILL) || (TASK_PID(get_current()) != 1)) 52 if ((sig != SIGILL) || (get_current_pid() != 1))
55 return; 53 return;
56 54
57 if (copy_from_user_proc(tmp, (void *) UPT_IP(regs), 2)) { 55 if (copy_from_user_proc(tmp, (void *) UPT_IP(regs), 2)) {
diff --git a/arch/x86/um/mem_32.c b/arch/x86/um/mem_32.c
index 639900a6fde..f40281e5d6a 100644
--- a/arch/x86/um/mem_32.c
+++ b/arch/x86/um/mem_32.c
@@ -23,14 +23,6 @@ static int __init gate_vma_init(void)
23 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC; 23 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
24 gate_vma.vm_page_prot = __P101; 24 gate_vma.vm_page_prot = __P101;
25 25
26 /*
27 * Make sure the vDSO gets into every core dump.
28 * Dumping its contents makes post-mortem fully interpretable later
29 * without matching up the same kernel and hardware config to see
30 * what PC values meant.
31 */
32 gate_vma.vm_flags |= VM_ALWAYSDUMP;
33
34 return 0; 26 return 0;
35} 27}
36__initcall(gate_vma_init); 28__initcall(gate_vma_init);
diff --git a/arch/x86/um/vdso/vma.c b/arch/x86/um/vdso/vma.c
index 91f4ec9a0a5..af91901babb 100644
--- a/arch/x86/um/vdso/vma.c
+++ b/arch/x86/um/vdso/vma.c
@@ -64,8 +64,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
64 64
65 err = install_special_mapping(mm, um_vdso_addr, PAGE_SIZE, 65 err = install_special_mapping(mm, um_vdso_addr, PAGE_SIZE,
66 VM_READ|VM_EXEC| 66 VM_READ|VM_EXEC|
67 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC| 67 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
68 VM_ALWAYSDUMP,
69 vdsop); 68 vdsop);
70 69
71 up_write(&mm->mmap_sem); 70 up_write(&mm->mmap_sem);
diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
index 468d591dde3..a944020fa85 100644
--- a/arch/x86/vdso/vdso32-setup.c
+++ b/arch/x86/vdso/vdso32-setup.c
@@ -250,13 +250,7 @@ static int __init gate_vma_init(void)
250 gate_vma.vm_end = FIXADDR_USER_END; 250 gate_vma.vm_end = FIXADDR_USER_END;
251 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC; 251 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
252 gate_vma.vm_page_prot = __P101; 252 gate_vma.vm_page_prot = __P101;
253 /* 253
254 * Make sure the vDSO gets into every core dump.
255 * Dumping its contents makes post-mortem fully interpretable later
256 * without matching up the same kernel and hardware config to see
257 * what PC values meant.
258 */
259 gate_vma.vm_flags |= VM_ALWAYSDUMP;
260 return 0; 254 return 0;
261} 255}
262 256
@@ -343,17 +337,10 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
343 if (compat_uses_vma || !compat) { 337 if (compat_uses_vma || !compat) {
344 /* 338 /*
345 * MAYWRITE to allow gdb to COW and set breakpoints 339 * MAYWRITE to allow gdb to COW and set breakpoints
346 *
347 * Make sure the vDSO gets into every core dump.
348 * Dumping its contents makes post-mortem fully
349 * interpretable later without matching up the same
350 * kernel and hardware config to see what PC values
351 * meant.
352 */ 340 */
353 ret = install_special_mapping(mm, addr, PAGE_SIZE, 341 ret = install_special_mapping(mm, addr, PAGE_SIZE,
354 VM_READ|VM_EXEC| 342 VM_READ|VM_EXEC|
355 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC| 343 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
356 VM_ALWAYSDUMP,
357 vdso32_pages); 344 vdso32_pages);
358 345
359 if (ret) 346 if (ret)
diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
index 153407c35b7..17e18279649 100644
--- a/arch/x86/vdso/vma.c
+++ b/arch/x86/vdso/vma.c
@@ -124,8 +124,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
124 124
125 ret = install_special_mapping(mm, addr, vdso_size, 125 ret = install_special_mapping(mm, addr, vdso_size,
126 VM_READ|VM_EXEC| 126 VM_READ|VM_EXEC|
127 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC| 127 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
128 VM_ALWAYSDUMP,
129 vdso_pages); 128 vdso_pages);
130 if (ret) { 129 if (ret) {
131 current->mm->context.vdso = NULL; 130 current->mm->context.vdso = NULL;
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 12366238d07..1ba8dff2675 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -10,6 +10,7 @@
10#include <linux/pm.h> 10#include <linux/pm.h>
11#include <linux/memblock.h> 11#include <linux/memblock.h>
12#include <linux/cpuidle.h> 12#include <linux/cpuidle.h>
13#include <linux/cpufreq.h>
13 14
14#include <asm/elf.h> 15#include <asm/elf.h>
15#include <asm/vdso.h> 16#include <asm/vdso.h>
@@ -420,6 +421,7 @@ void __init xen_arch_setup(void)
420 boot_cpu_data.hlt_works_ok = 1; 421 boot_cpu_data.hlt_works_ok = 1;
421#endif 422#endif
422 disable_cpuidle(); 423 disable_cpuidle();
424 disable_cpufreq();
423 WARN_ON(set_pm_idle_to_default()); 425 WARN_ON(set_pm_idle_to_default());
424 fiddle_vdso(); 426 fiddle_vdso();
425} 427}
diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
index 315d8fa0c8f..02900e8ce26 100644
--- a/arch/x86/xen/smp.c
+++ b/arch/x86/xen/smp.c
@@ -75,8 +75,14 @@ static void __cpuinit cpu_bringup(void)
75 75
76 xen_setup_cpu_clockevents(); 76 xen_setup_cpu_clockevents();
77 77
78 notify_cpu_starting(cpu);
79
80 ipi_call_lock();
78 set_cpu_online(cpu, true); 81 set_cpu_online(cpu, true);
82 ipi_call_unlock();
83
79 this_cpu_write(cpu_state, CPU_ONLINE); 84 this_cpu_write(cpu_state, CPU_ONLINE);
85
80 wmb(); 86 wmb();
81 87
82 /* We can take interrupts now: we're officially "up". */ 88 /* We can take interrupts now: we're officially "up". */
diff --git a/arch/xtensa/include/asm/mman.h b/arch/xtensa/include/asm/mman.h
index 30789010733..25bc6c1309c 100644
--- a/arch/xtensa/include/asm/mman.h
+++ b/arch/xtensa/include/asm/mman.h
@@ -86,6 +86,10 @@
86#define MADV_HUGEPAGE 14 /* Worth backing with hugepages */ 86#define MADV_HUGEPAGE 14 /* Worth backing with hugepages */
87#define MADV_NOHUGEPAGE 15 /* Not worth backing with hugepages */ 87#define MADV_NOHUGEPAGE 15 /* Not worth backing with hugepages */
88 88
89#define MADV_DONTDUMP 16 /* Explicity exclude from the core dump,
90 overrides the coredump filter bits */
91#define MADV_DODUMP 17 /* Clear the MADV_NODUMP flag */
92
89/* compatibility flags */ 93/* compatibility flags */
90#define MAP_FILE 0 94#define MAP_FILE 0
91 95
diff --git a/arch/xtensa/kernel/pci.c b/arch/xtensa/kernel/pci.c
index 61045c192e8..eb30e356f5b 100644
--- a/arch/xtensa/kernel/pci.c
+++ b/arch/xtensa/kernel/pci.c
@@ -153,7 +153,7 @@ static void __init pci_controller_apertures(struct pci_controller *pci_ctrl,
153 } 153 }
154 res->start += io_offset; 154 res->start += io_offset;
155 res->end += io_offset; 155 res->end += io_offset;
156 pci_add_resource(resources, res); 156 pci_add_resource_offset(resources, res, io_offset);
157 157
158 for (i = 0; i < 3; i++) { 158 for (i = 0; i < 3; i++) {
159 res = &pci_ctrl->mem_resources[i]; 159 res = &pci_ctrl->mem_resources[i];
@@ -200,24 +200,9 @@ subsys_initcall(pcibios_init);
200 200
201void __init pcibios_fixup_bus(struct pci_bus *bus) 201void __init pcibios_fixup_bus(struct pci_bus *bus)
202{ 202{
203 struct pci_controller *pci_ctrl = bus->sysdata;
204 struct resource *res;
205 unsigned long io_offset;
206 int i;
207
208 io_offset = (unsigned long)pci_ctrl->io_space.base;
209 if (bus->parent) { 203 if (bus->parent) {
210 /* This is a subordinate bridge */ 204 /* This is a subordinate bridge */
211 pci_read_bridge_bases(bus); 205 pci_read_bridge_bases(bus);
212
213 for (i = 0; i < 4; i++) {
214 if ((res = bus->resource[i]) == NULL || !res->flags)
215 continue;
216 if (io_offset && (res->flags & IORESOURCE_IO)) {
217 res->start += io_offset;
218 res->end += io_offset;
219 }
220 }
221 } 206 }
222} 207}
223 208