aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CREDITS5
-rw-r--r--Documentation/DocBook/media/v4l/vidioc-expbuf.xml8
-rw-r--r--Documentation/arm/Marvell/README24
-rw-r--r--Documentation/assoc_array.txt6
-rw-r--r--Documentation/device-mapper/cache.txt10
-rw-r--r--Documentation/devicetree/bindings/arm/marvell,berlin.txt24
-rw-r--r--Documentation/devicetree/bindings/arm/tegra/nvidia,tegra20-pmc.txt1
-rw-r--r--Documentation/devicetree/bindings/clock/nvidia,tegra114-car.txt4
-rw-r--r--Documentation/devicetree/bindings/clock/nvidia,tegra124-car.txt63
-rw-r--r--Documentation/devicetree/bindings/clock/nvidia,tegra20-car.txt4
-rw-r--r--Documentation/devicetree/bindings/clock/nvidia,tegra30-car.txt4
-rw-r--r--Documentation/devicetree/bindings/dma/tegra20-apbdma.txt14
-rw-r--r--Documentation/devicetree/bindings/gpu/nvidia,tegra20-host1x.txt122
-rw-r--r--Documentation/devicetree/bindings/i2c/nvidia,tegra20-i2c.txt27
-rw-r--r--Documentation/devicetree/bindings/input/nvidia,tegra20-kbc.txt9
-rw-r--r--Documentation/devicetree/bindings/interrupt-controller/snps,dw-apb-ictl.txt32
-rw-r--r--Documentation/devicetree/bindings/mmc/nvidia,tegra20-sdhci.txt9
-rw-r--r--Documentation/devicetree/bindings/net/davinci_emac.txt2
-rw-r--r--Documentation/devicetree/bindings/net/smsc-lan91c111.txt4
-rw-r--r--Documentation/devicetree/bindings/nvec/nvidia,nvec.txt12
-rw-r--r--Documentation/devicetree/bindings/pci/nvidia,tegra20-pcie.txt26
-rw-r--r--Documentation/devicetree/bindings/pwm/nvidia,tegra20-pwm.txt9
-rw-r--r--Documentation/devicetree/bindings/rtc/nvidia,tegra20-rtc.txt3
-rw-r--r--Documentation/devicetree/bindings/serial/nvidia,tegra20-hsuart.txt19
-rw-r--r--Documentation/devicetree/bindings/sound/nvidia,tegra-audio-alc5632.txt7
-rw-r--r--Documentation/devicetree/bindings/sound/nvidia,tegra-audio-rt5640.txt7
-rw-r--r--Documentation/devicetree/bindings/sound/nvidia,tegra-audio-wm8753.txt7
-rw-r--r--Documentation/devicetree/bindings/sound/nvidia,tegra-audio-wm8903.txt7
-rw-r--r--Documentation/devicetree/bindings/sound/nvidia,tegra-audio-wm9712.txt7
-rw-r--r--Documentation/devicetree/bindings/sound/nvidia,tegra20-ac97.txt20
-rw-r--r--Documentation/devicetree/bindings/sound/nvidia,tegra20-i2s.txt19
-rw-r--r--Documentation/devicetree/bindings/sound/nvidia,tegra30-ahub.txt63
-rw-r--r--Documentation/devicetree/bindings/sound/nvidia,tegra30-i2s.txt11
-rw-r--r--Documentation/devicetree/bindings/spi/nvidia,tegra114-spi.txt24
-rw-r--r--Documentation/devicetree/bindings/spi/nvidia,tegra20-sflash.txt20
-rw-r--r--Documentation/devicetree/bindings/spi/nvidia,tegra20-slink.txt20
-rw-r--r--Documentation/devicetree/bindings/timer/nvidia,tegra20-timer.txt3
-rw-r--r--Documentation/devicetree/bindings/timer/nvidia,tegra30-timer.txt3
-rw-r--r--Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt7
-rw-r--r--Documentation/mic/mpssd/mpssd.c18
-rw-r--r--Documentation/networking/packet_mmap.txt10
-rw-r--r--MAINTAINERS69
-rw-r--r--Makefile2
-rw-r--r--arch/arc/Kconfig1
-rw-r--r--arch/arc/include/uapi/asm/unistd.h5
-rw-r--r--arch/arc/kernel/perf_event.c4
-rw-r--r--arch/arm/Kconfig42
-rw-r--r--arch/arm/Kconfig.debug10
-rw-r--r--arch/arm/Makefile4
-rw-r--r--arch/arm/boot/compressed/Makefile2
-rw-r--r--arch/arm/boot/dts/Makefile6
-rw-r--r--arch/arm/boot/dts/am3517-evm.dts6
-rw-r--r--arch/arm/boot/dts/am3517.dtsi63
-rw-r--r--arch/arm/boot/dts/armv7-m.dtsi18
-rw-r--r--arch/arm/boot/dts/berlin2-sony-nsz-gs7.dts29
-rw-r--r--arch/arm/boot/dts/berlin2.dtsi227
-rw-r--r--arch/arm/boot/dts/berlin2cd-google-chromecast.dts29
-rw-r--r--arch/arm/boot/dts/berlin2cd.dtsi210
-rw-r--r--arch/arm/boot/dts/efm32gg-dk3750.dts86
-rw-r--r--arch/arm/boot/dts/efm32gg.dtsi172
-rw-r--r--arch/arm/boot/dts/omap3-n900.dts2
-rw-r--r--arch/arm/boot/dts/omap3-n950-n9.dtsi2
-rw-r--r--arch/arm/boot/dts/omap34xx-hs.dtsi16
-rw-r--r--arch/arm/boot/dts/omap36xx-hs.dtsi16
-rw-r--r--arch/arm/boot/dts/qcom-msm8974.dtsi33
-rw-r--r--arch/arm/boot/dts/sun6i-a31.dtsi27
-rw-r--r--arch/arm/boot/dts/sun7i-a20.dtsi42
-rw-r--r--arch/arm/boot/dts/tegra114.dtsi157
-rw-r--r--arch/arm/boot/dts/tegra20-paz00.dts2
-rw-r--r--arch/arm/boot/dts/tegra20.dtsi136
-rw-r--r--arch/arm/boot/dts/tegra30.dtsi175
-rw-r--r--arch/arm/common/timer-sp.c4
-rw-r--r--arch/arm/configs/ape6evm_defconfig2
-rw-r--r--arch/arm/configs/armadillo800eva_defconfig2
-rw-r--r--arch/arm/configs/bockw_defconfig2
-rw-r--r--arch/arm/configs/efm32_defconfig102
-rw-r--r--arch/arm/configs/keystone_defconfig20
-rw-r--r--arch/arm/configs/koelsch_defconfig2
-rw-r--r--arch/arm/configs/kzm9d_defconfig2
-rw-r--r--arch/arm/configs/kzm9g_defconfig2
-rw-r--r--arch/arm/configs/lager_defconfig2
-rw-r--r--arch/arm/configs/mackerel_defconfig2
-rw-r--r--arch/arm/configs/marzen_defconfig2
-rw-r--r--arch/arm/configs/moxart_defconfig149
-rw-r--r--arch/arm/configs/multi_v7_defconfig3
-rw-r--r--arch/arm/include/asm/memory.h31
-rw-r--r--arch/arm/include/debug/tegra.S34
-rw-r--r--arch/arm/kernel/head-nommu.S4
-rw-r--r--arch/arm/kernel/head.S2
-rw-r--r--arch/arm/kernel/process.c7
-rw-r--r--arch/arm/kernel/setup.c3
-rw-r--r--arch/arm/kernel/stacktrace.c2
-rw-r--r--arch/arm/kernel/traps.c3
-rw-r--r--arch/arm/mach-at91/Kconfig2
-rw-r--r--arch/arm/mach-at91/include/mach/cpu.h3
-rw-r--r--arch/arm/mach-at91/setup.c4
-rw-r--r--arch/arm/mach-berlin/Kconfig29
-rw-r--r--arch/arm/mach-berlin/Makefile1
-rw-r--r--arch/arm/mach-berlin/berlin.c39
-rw-r--r--arch/arm/mach-clps711x/common.c4
-rw-r--r--arch/arm/mach-davinci/devices-da8xx.c4
-rw-r--r--arch/arm/mach-davinci/dm355.c3
-rw-r--r--arch/arm/mach-davinci/dm365.c3
-rw-r--r--arch/arm/mach-davinci/dm644x.c3
-rw-r--r--arch/arm/mach-davinci/dm646x.c6
-rw-r--r--arch/arm/mach-davinci/time.c4
-rw-r--r--arch/arm/mach-efm32/Makefile1
-rw-r--r--arch/arm/mach-efm32/Makefile.boot3
-rw-r--r--arch/arm/mach-efm32/dtmachine.c15
-rw-r--r--arch/arm/mach-efm32/include/mach/entry-macro.S4
-rw-r--r--arch/arm/mach-efm32/include/mach/timex.h3
-rw-r--r--arch/arm/mach-ep93xx/Kconfig1
-rw-r--r--arch/arm/mach-ep93xx/core.c110
-rw-r--r--arch/arm/mach-ep93xx/include/mach/platform.h3
-rw-r--r--arch/arm/mach-highbank/highbank.c23
-rw-r--r--arch/arm/mach-imx/time.c4
-rw-r--r--arch/arm/mach-integrator/integrator_ap.c4
-rw-r--r--arch/arm/mach-ixp4xx/common.c4
-rw-r--r--arch/arm/mach-keystone/Kconfig2
-rw-r--r--arch/arm/mach-keystone/keystone.c4
-rw-r--r--arch/arm/mach-keystone/keystone.h1
-rw-r--r--arch/arm/mach-keystone/pm_domain.c2
-rw-r--r--arch/arm/mach-mmp/time.c4
-rw-r--r--arch/arm/mach-moxart/Kconfig31
-rw-r--r--arch/arm/mach-moxart/Makefile3
-rw-r--r--arch/arm/mach-moxart/moxart.c15
-rw-r--r--arch/arm/mach-msm/Kconfig15
-rw-r--r--arch/arm/mach-msm/board-trout.c12
-rw-r--r--arch/arm/mach-msm/timer.c4
-rw-r--r--arch/arm/mach-omap1/time.c4
-rw-r--r--arch/arm/mach-omap2/board-generic.c18
-rw-r--r--arch/arm/mach-omap2/omap_device.c24
-rw-r--r--arch/arm/mach-omap2/omap_device.h1
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.c143
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_3xxx_data.c13
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_44xx_data.c12
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_54xx_data.c13
-rw-r--r--arch/arm/mach-omap2/timer.c4
-rw-r--r--arch/arm/mach-pxa/reset.c8
-rw-r--r--arch/arm/mach-pxa/time.c4
-rw-r--r--arch/arm/mach-pxa/tosa.c102
-rw-r--r--arch/arm/mach-sa1100/time.c4
-rw-r--r--arch/arm/mach-shmobile/Kconfig24
-rw-r--r--arch/arm/mach-shmobile/Makefile1
-rw-r--r--arch/arm/mach-shmobile/Makefile.boot1
-rw-r--r--arch/arm/mach-shmobile/board-bockw.c1
-rw-r--r--arch/arm/mach-shmobile/board-kzm9d.c92
-rw-r--r--arch/arm/mach-shmobile/clock-r7s72100.c8
-rw-r--r--arch/arm/mach-shmobile/clock-r8a7740.c1
-rw-r--r--arch/arm/mach-shmobile/clock-r8a7778.c31
-rw-r--r--arch/arm/mach-shmobile/clock-r8a7779.c11
-rw-r--r--arch/arm/mach-shmobile/clock-r8a7790.c62
-rw-r--r--arch/arm/mach-shmobile/clock-r8a7791.c17
-rw-r--r--arch/arm/mach-shmobile/clock-sh73a0.c1
-rw-r--r--arch/arm/mach-shmobile/include/mach/emev2.h5
-rw-r--r--arch/arm/mach-shmobile/include/mach/r8a7778.h39
-rw-r--r--arch/arm/mach-shmobile/include/mach/r8a7791.h1
-rw-r--r--arch/arm/mach-shmobile/setup-emev2.c163
-rw-r--r--arch/arm/mach-shmobile/setup-r7s72100.c82
-rw-r--r--arch/arm/mach-shmobile/setup-r8a73a4.c68
-rw-r--r--arch/arm/mach-shmobile/setup-r8a7740.c195
-rw-r--r--arch/arm/mach-shmobile/setup-r8a7778.c166
-rw-r--r--arch/arm/mach-shmobile/setup-r8a7779.c128
-rw-r--r--arch/arm/mach-shmobile/setup-r8a7790.c141
-rw-r--r--arch/arm/mach-shmobile/setup-r8a7791.c188
-rw-r--r--arch/arm/mach-shmobile/setup-rcar-gen2.c29
-rw-r--r--arch/arm/mach-shmobile/setup-sh7372.c160
-rw-r--r--arch/arm/mach-shmobile/setup-sh73a0.c191
-rw-r--r--arch/arm/mach-tegra/Kconfig3
-rw-r--r--arch/arm/mach-tegra/fuse.c43
-rw-r--r--arch/arm/mach-tegra/iomap.h14
-rw-r--r--arch/arm/mach-tegra/powergate.c203
-rw-r--r--arch/arm/mach-tegra/tegra.c4
-rw-r--r--arch/arm/mach-u300/timer.c4
-rw-r--r--arch/arm/mm/dma-mapping.c91
-rw-r--r--arch/arm/mm/init.c2
-rw-r--r--arch/arm/plat-iop/time.c4
-rw-r--r--arch/arm/plat-omap/counter_32k.c4
-rw-r--r--arch/arm/plat-orion/time.c4
-rw-r--r--arch/arm/plat-samsung/s5p-irq-eint.c4
-rw-r--r--arch/arm/plat-versatile/sched-clock.c4
-rw-r--r--arch/arm64/Kconfig3
-rw-r--r--arch/arm64/include/asm/io.h2
-rw-r--r--arch/arm64/include/asm/pgtable-hwdef.h2
-rw-r--r--arch/arm64/kernel/head.S3
-rw-r--r--arch/arm64/mm/proc.S2
-rw-r--r--arch/avr32/boards/favr-32/setup.c4
-rw-r--r--arch/avr32/configs/atngw100_defconfig1
-rw-r--r--arch/avr32/configs/atngw100_evklcd100_defconfig1
-rw-r--r--arch/avr32/configs/atngw100_evklcd101_defconfig1
-rw-r--r--arch/avr32/configs/atngw100_mrmt_defconfig1
-rw-r--r--arch/avr32/configs/atngw100mkii_defconfig1
-rw-r--r--arch/avr32/configs/atngw100mkii_evklcd100_defconfig1
-rw-r--r--arch/avr32/configs/atngw100mkii_evklcd101_defconfig1
-rw-r--r--arch/avr32/configs/atstk1002_defconfig1
-rw-r--r--arch/avr32/configs/atstk1003_defconfig1
-rw-r--r--arch/avr32/configs/atstk1004_defconfig1
-rw-r--r--arch/avr32/configs/atstk1006_defconfig1
-rw-r--r--arch/avr32/configs/favr-32_defconfig1
-rw-r--r--arch/avr32/configs/hammerhead_defconfig1
-rw-r--r--arch/avr32/configs/merisc_defconfig1
-rw-r--r--arch/avr32/configs/mimc200_defconfig1
-rw-r--r--arch/avr32/kernel/time.c2
-rw-r--r--arch/avr32/mach-at32ap/pm.c2
-rw-r--r--arch/powerpc/boot/dts/mpc5121.dtsi1
-rw-r--r--arch/powerpc/configs/52xx/cm5200_defconfig3
-rw-r--r--arch/powerpc/configs/52xx/lite5200b_defconfig3
-rw-r--r--arch/powerpc/configs/52xx/motionpro_defconfig3
-rw-r--r--arch/powerpc/configs/52xx/pcm030_defconfig3
-rw-r--r--arch/powerpc/configs/52xx/tqm5200_defconfig3
-rw-r--r--arch/powerpc/configs/mpc5200_defconfig3
-rw-r--r--arch/powerpc/configs/pasemi_defconfig7
-rw-r--r--arch/powerpc/include/asm/pgalloc-32.h6
-rw-r--r--arch/powerpc/include/asm/pgalloc-64.h6
-rw-r--r--arch/powerpc/kernel/machine_kexec.c2
-rw-r--r--arch/powerpc/kernel/misc_64.S5
-rw-r--r--arch/powerpc/platforms/powernv/pci-ioda.c1
-rw-r--r--arch/powerpc/sysdev/ppc4xx_ocm.c2
-rw-r--r--arch/s390/Kconfig6
-rw-r--r--arch/s390/include/asm/sclp.h3
-rw-r--r--arch/s390/kernel/asm-offsets.c1
-rw-r--r--arch/s390/kernel/vdso.c2
-rw-r--r--arch/s390/kernel/vdso32/clock_gettime.S9
-rw-r--r--arch/s390/kernel/vdso64/clock_getres.S4
-rw-r--r--arch/s390/kernel/vdso64/clock_gettime.S10
-rw-r--r--arch/x86/Makefile8
-rw-r--r--arch/x86/boot/Makefile6
-rw-r--r--arch/x86/boot/compressed/Makefile1
-rw-r--r--arch/x86/kvm/lapic.c35
-rw-r--r--arch/x86/kvm/lapic.h4
-rw-r--r--arch/x86/kvm/x86.c40
-rw-r--r--arch/x86/platform/efi/efi.c7
-rw-r--r--arch/x86/platform/uv/tlb_uv.c5
-rw-r--r--arch/x86/realmode/rm/Makefile3
-rw-r--r--drivers/Makefile2
-rw-r--r--drivers/base/power/main.c3
-rw-r--r--drivers/base/regmap/regmap-mmio.c11
-rw-r--r--drivers/base/regmap/regmap.c8
-rw-r--r--drivers/block/null_blk.c8
-rw-r--r--drivers/char/i8k.c7
-rw-r--r--drivers/clk/tegra/Makefile7
-rw-r--r--drivers/clk/tegra/clk-id.h235
-rw-r--r--drivers/clk/tegra/clk-periph-gate.c30
-rw-r--r--drivers/clk/tegra/clk-periph.c72
-rw-r--r--drivers/clk/tegra/clk-pll.c407
-rw-r--r--drivers/clk/tegra/clk-tegra-audio.c215
-rw-r--r--drivers/clk/tegra/clk-tegra-fixed.c111
-rw-r--r--drivers/clk/tegra/clk-tegra-periph.c674
-rw-r--r--drivers/clk/tegra/clk-tegra-pmc.c132
-rw-r--r--drivers/clk/tegra/clk-tegra-super-gen4.c149
-rw-r--r--drivers/clk/tegra/clk-tegra114.c1688
-rw-r--r--drivers/clk/tegra/clk-tegra124.c1424
-rw-r--r--drivers/clk/tegra/clk-tegra20.c817
-rw-r--r--drivers/clk/tegra/clk-tegra30.c1504
-rw-r--r--drivers/clk/tegra/clk.c214
-rw-r--r--drivers/clk/tegra/clk.h116
-rw-r--r--drivers/cpufreq/at32ap-cpufreq.c2
-rw-r--r--drivers/cpufreq/cpufreq.c46
-rw-r--r--drivers/dma/amba-pl08x.c2
-rw-r--r--drivers/dma/dmaengine.c63
-rw-r--r--drivers/dma/mmp_pdma.c31
-rw-r--r--drivers/dma/of-dma.c15
-rw-r--r--drivers/dma/s3c24xx-dma.c33
-rw-r--r--drivers/dma/sh/rcar-hpbdma.c11
-rw-r--r--drivers/dma/tegra20-apb-dma.c52
-rw-r--r--drivers/edac/sb_edac.c2
-rw-r--r--drivers/extcon/extcon-arizona.c4
-rw-r--r--drivers/extcon/extcon-class.c3
-rw-r--r--drivers/gpio/gpio-davinci.c4
-rw-r--r--drivers/gpu/drm/drm_edid.c4
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_drv.c35
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_fimd.c2
-rw-r--r--drivers/gpu/drm/i915/i915_drv.c2
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c7
-rw-r--r--drivers/gpu/drm/i915/i915_gem_dmabuf.c13
-rw-r--r--drivers/gpu/drm/i915/i915_gem_execbuffer.c60
-rw-r--r--drivers/gpu/drm/i915/i915_gem_gtt.c6
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h1
-rw-r--r--drivers/gpu/drm/i915/intel_ddi.c5
-rw-r--r--drivers/gpu/drm/i915/intel_display.c14
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c34
-rw-r--r--drivers/gpu/drm/i915/intel_drv.h2
-rw-r--r--drivers/gpu/drm/i915/intel_pm.c15
-rw-r--r--drivers/gpu/drm/nouveau/Makefile1
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/device/nv50.c4
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/fifo/nv50.c3
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/fifo/nv84.c3
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/software/nv50.c2
-rw-r--r--drivers/gpu/drm/nouveau/core/include/subdev/clock.h4
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/clock/nv04.c7
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/clock/nvaa.c445
-rw-r--r--drivers/gpu/drm/nouveau/dispnv04/overlay.c42
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_display.c3
-rw-r--r--drivers/gpu/drm/nouveau/nv50_display.c2
-rw-r--r--drivers/gpu/drm/radeon/atombios_i2c.c15
-rw-r--r--drivers/gpu/drm/radeon/dce6_afmt.c12
-rw-r--r--drivers/gpu/drm/radeon/ni_dpm.c28
-rw-r--r--drivers/gpu/drm/radeon/r600_hdmi.c8
-rw-r--r--drivers/gpu/drm/radeon/radeon.h8
-rw-r--r--drivers/gpu/drm/radeon/radeon_atombios.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_cs.c4
-rw-r--r--drivers/gpu/drm/radeon/radeon_drv.h3
-rw-r--r--drivers/gpu/drm/radeon/radeon_gart.c16
-rw-r--r--drivers/gpu/drm/radeon/radeon_pm.c55
-rw-r--r--drivers/gpu/drm/radeon/radeon_trace.h33
-rw-r--r--drivers/gpu/drm/radeon/reg_srcs/cayman4
-rw-r--r--drivers/gpu/drm/radeon/reg_srcs/evergreen4
-rw-r--r--drivers/gpu/drm/radeon/si.c11
-rw-r--r--drivers/gpu/drm/tegra/Kconfig1
-rw-r--r--drivers/gpu/drm/tegra/dc.c10
-rw-r--r--drivers/gpu/drm/tegra/drm.c34
-rw-r--r--drivers/gpu/drm/tegra/drm.h5
-rw-r--r--drivers/gpu/drm/tegra/fb.c2
-rw-r--r--drivers/gpu/drm/tegra/gr3d.c22
-rw-r--r--drivers/gpu/drm/tegra/hdmi.c15
-rw-r--r--drivers/gpu/drm/tegra/rgb.c11
-rw-r--r--drivers/gpu/drm/udl/udl_gem.c6
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c2
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_drv.h1
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_kms.c1
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c4
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_resource.c118
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c5
-rw-r--r--drivers/gpu/host1x/bus.c5
-rw-r--r--drivers/gpu/host1x/hw/cdma_hw.c4
-rw-r--r--drivers/gpu/host1x/hw/debug_hw.c4
-rw-r--r--drivers/hid/hid-kye.c1
-rw-r--r--drivers/hid/hid-sensor-hub.c22
-rw-r--r--drivers/hwmon/hih6130.c16
-rw-r--r--drivers/hwmon/lm78.c2
-rw-r--r--drivers/hwmon/lm90.c4
-rw-r--r--drivers/hwmon/sis5595.c2
-rw-r--r--drivers/hwmon/vt8231.c2
-rw-r--r--drivers/hwmon/w83l786ng.c13
-rw-r--r--drivers/i2c/busses/i2c-imx.c4
-rw-r--r--drivers/i2c/busses/i2c-tegra.c13
-rw-r--r--drivers/i2c/i2c-mux.c2
-rw-r--r--drivers/iio/common/hid-sensors/Kconfig9
-rw-r--r--drivers/iio/common/hid-sensors/hid-sensor-trigger.c20
-rw-r--r--drivers/iio/light/Kconfig1
-rw-r--r--drivers/input/keyboard/adp5588-keys.c3
-rw-r--r--drivers/input/keyboard/adp5589-keys.c3
-rw-r--r--drivers/input/keyboard/bf54x-keys.c3
-rw-r--r--drivers/input/keyboard/tegra-kbc.c13
-rw-r--r--drivers/input/misc/adxl34x.c2
-rw-r--r--drivers/input/misc/pcf8574_keypad.c7
-rw-r--r--drivers/input/mouse/alps.c206
-rw-r--r--drivers/input/mouse/alps.h1
-rw-r--r--drivers/input/mouse/elantech.c1
-rw-r--r--drivers/input/serio/serio.c24
-rw-r--r--drivers/input/touchscreen/sur40.c4
-rw-r--r--drivers/input/touchscreen/usbtouchscreen.c22
-rw-r--r--drivers/iommu/arm-smmu.c66
-rw-r--r--drivers/irqchip/Kconfig4
-rw-r--r--drivers/irqchip/Makefile1
-rw-r--r--drivers/irqchip/irq-dw-apb-ictl.c150
-rw-r--r--drivers/md/dm-bufio.c5
-rw-r--r--drivers/md/dm-cache-policy-mq.c13
-rw-r--r--drivers/md/dm-cache-target.c2
-rw-r--r--drivers/md/dm-delay.c23
-rw-r--r--drivers/md/dm-snap.c71
-rw-r--r--drivers/md/dm-stats.c1
-rw-r--r--drivers/md/dm-table.c5
-rw-r--r--drivers/md/dm-thin-metadata.c8
-rw-r--r--drivers/md/dm-thin-metadata.h1
-rw-r--r--drivers/md/dm-thin.c66
-rw-r--r--drivers/md/persistent-data/dm-array.c10
-rw-r--r--drivers/md/persistent-data/dm-block-manager.c6
-rw-r--r--drivers/md/persistent-data/dm-block-manager.h7
-rw-r--r--drivers/md/persistent-data/dm-space-map-common.c32
-rw-r--r--drivers/md/persistent-data/dm-space-map-metadata.c8
-rw-r--r--drivers/media/common/siano/smscoreapi.h4
-rw-r--r--drivers/media/common/siano/smsdvb.h2
-rw-r--r--drivers/media/dvb-core/dvb_demux.c9
-rw-r--r--drivers/media/dvb-frontends/af9033.c12
-rw-r--r--drivers/media/dvb-frontends/cxd2820r_c.c2
-rw-r--r--drivers/media/dvb-frontends/dib8000.c4
-rw-r--r--drivers/media/dvb-frontends/drxk_hard.c18
-rw-r--r--drivers/media/dvb-frontends/rtl2830.c1
-rw-r--r--drivers/media/i2c/adv7183_regs.h6
-rw-r--r--drivers/media/i2c/adv7604.c2
-rw-r--r--drivers/media/i2c/adv7842.c2
-rw-r--r--drivers/media/i2c/ir-kbd-i2c.c2
-rw-r--r--drivers/media/i2c/m5mols/m5mols_controls.c2
-rw-r--r--drivers/media/i2c/mt9p031.c1
-rw-r--r--drivers/media/i2c/s5c73m3/s5c73m3-core.c2
-rw-r--r--drivers/media/i2c/s5c73m3/s5c73m3.h2
-rw-r--r--drivers/media/i2c/saa7115.c2
-rw-r--r--drivers/media/i2c/soc_camera/ov5642.c2
-rw-r--r--drivers/media/i2c/ths7303.c3
-rw-r--r--drivers/media/i2c/wm8775.c4
-rw-r--r--drivers/media/pci/bt8xx/bttv-driver.c3
-rw-r--r--drivers/media/pci/cx18/cx18-driver.h2
-rw-r--r--drivers/media/pci/cx23885/cx23885-417.c2
-rw-r--r--drivers/media/pci/pluto2/pluto2.c2
-rw-r--r--drivers/media/pci/saa7164/saa7164-core.c4
-rw-r--r--drivers/media/platform/coda.c2
-rw-r--r--drivers/media/platform/exynos4-is/fimc-core.c2
-rw-r--r--drivers/media/platform/exynos4-is/media-dev.c2
-rw-r--r--drivers/media/platform/marvell-ccic/mmp-driver.c46
-rw-r--r--drivers/media/platform/omap3isp/isp.c2
-rw-r--r--drivers/media/platform/omap3isp/ispvideo.c7
-rw-r--r--drivers/media/platform/s5p-mfc/regs-mfc.h2
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc.c12
-rw-r--r--drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c2
-rw-r--r--drivers/media/platform/s5p-tv/mixer.h2
-rw-r--r--drivers/media/platform/s5p-tv/mixer_video.c4
-rw-r--r--drivers/media/platform/soc_camera/omap1_camera.c2
-rw-r--r--drivers/media/platform/vivi.c4
-rw-r--r--drivers/media/platform/vsp1/vsp1_drv.c2
-rw-r--r--drivers/media/platform/vsp1/vsp1_video.c4
-rw-r--r--drivers/media/radio/radio-shark.c4
-rw-r--r--drivers/media/radio/radio-shark2.c4
-rw-r--r--drivers/media/radio/radio-si476x.c4
-rw-r--r--drivers/media/radio/radio-tea5764.c2
-rw-r--r--drivers/media/radio/tef6862.c2
-rw-r--r--drivers/media/rc/imon.c2
-rw-r--r--drivers/media/rc/redrat3.c2
-rw-r--r--drivers/media/tuners/mt2063.c4
-rw-r--r--drivers/media/tuners/tuner-xc2028-types.h2
-rw-r--r--drivers/media/usb/cx231xx/cx231xx-cards.c2
-rw-r--r--drivers/media/usb/dvb-usb-v2/af9035.c17
-rw-r--r--drivers/media/usb/dvb-usb-v2/mxl111sf.c4
-rw-r--r--drivers/media/usb/dvb-usb/technisat-usb2.c2
-rw-r--r--drivers/media/usb/em28xx/em28xx-video.c2
-rw-r--r--drivers/media/usb/gspca/gl860/gl860.c2
-rw-r--r--drivers/media/usb/gspca/pac207.c2
-rw-r--r--drivers/media/usb/gspca/pac7302.c2
-rw-r--r--drivers/media/usb/gspca/stk1135.c3
-rw-r--r--drivers/media/usb/gspca/stv0680.c2
-rw-r--r--drivers/media/usb/gspca/sunplus.c1
-rw-r--r--drivers/media/usb/gspca/zc3xx.c2
-rw-r--r--drivers/media/usb/pwc/pwc-if.c2
-rw-r--r--drivers/media/usb/usbtv/usbtv.c174
-rw-r--r--drivers/media/usb/uvc/uvc_video.c2
-rw-r--r--drivers/media/v4l2-core/v4l2-ctrls.c2
-rw-r--r--drivers/media/v4l2-core/videobuf2-core.c29
-rw-r--r--drivers/media/v4l2-core/videobuf2-dma-contig.c4
-rw-r--r--drivers/media/v4l2-core/videobuf2-dma-sg.c3
-rw-r--r--drivers/mfd/Kconfig2
-rw-r--r--drivers/mfd/lpc_ich.c2
-rw-r--r--drivers/mfd/sec-core.c30
-rw-r--r--drivers/mfd/sec-irq.c6
-rw-r--r--drivers/mfd/ti-ssp.c2
-rw-r--r--drivers/misc/mei/hw-me-regs.h5
-rw-r--r--drivers/misc/mei/pci-me.c4
-rw-r--r--drivers/misc/mic/card/mic_virtio.c33
-rw-r--r--drivers/misc/mic/card/mic_virtio.h7
-rw-r--r--drivers/misc/mic/host/mic_boot.c2
-rw-r--r--drivers/misc/mic/host/mic_virtio.c30
-rw-r--r--drivers/misc/mic/host/mic_x100.c4
-rw-r--r--drivers/mtd/nand/pxa3xx_nand.c6
-rw-r--r--drivers/net/bonding/bond_main.c6
-rw-r--r--drivers/net/bonding/bond_sysfs.c4
-rw-r--r--drivers/net/ethernet/allwinner/sun4i-emac.c5
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c5
-rw-r--r--drivers/net/ethernet/broadcom/tg3.c29
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4.h82
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c278
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/sge.c12
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/t4_hw.c230
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/t4_regs.h14
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h7
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4vf/adapter.h1
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c15
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4vf/sge.c2
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h24
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c4
-rw-r--r--drivers/net/ethernet/emulex/benet/be_hw.h3
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c41
-rw-r--r--drivers/net/ethernet/freescale/fec_main.c13
-rw-r--r--drivers/net/ethernet/ibm/ehea/ehea_main.c2
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_main.c3
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_phy.c5
-rw-r--r--drivers/net/ethernet/marvell/mvneta.c4
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/main.c2
-rw-r--r--drivers/net/ethernet/nvidia/forcedeth.c8
-rw-r--r--drivers/net/ethernet/qlogic/qlge/qlge.h2
-rw-r--r--drivers/net/ethernet/qlogic/qlge/qlge_ethtool.c4
-rw-r--r--drivers/net/ethernet/qlogic/qlge/qlge_main.c8
-rw-r--r--drivers/net/ethernet/sfc/efx.c8
-rw-r--r--drivers/net/ethernet/sfc/mcdi.c39
-rw-r--r--drivers/net/ethernet/sfc/net_driver.h3
-rw-r--r--drivers/net/ethernet/sfc/nic.h2
-rw-r--r--drivers/net/ethernet/sfc/ptp.c66
-rw-r--r--drivers/net/ethernet/sfc/rx.c6
-rw-r--r--drivers/net/ethernet/smsc/smc91x.c45
-rw-r--r--drivers/net/ethernet/tehuti/tehuti.c1
-rw-r--r--drivers/net/ethernet/ti/cpsw.c19
-rw-r--r--drivers/net/ethernet/ti/davinci_emac.c26
-rw-r--r--drivers/net/ethernet/xilinx/ll_temac_main.c2
-rw-r--r--drivers/net/ethernet/xilinx/xilinx_axienet_main.c2
-rw-r--r--drivers/net/ethernet/xilinx/xilinx_emaclite.c51
-rw-r--r--drivers/net/macvtap.c13
-rw-r--r--drivers/net/phy/micrel.c15
-rw-r--r--drivers/net/tun.c18
-rw-r--r--drivers/net/virtio_net.c17
-rw-r--r--drivers/net/vxlan.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_eeprom.c22
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c7
-rw-r--r--drivers/net/wireless/ath/ath9k/xmit.c4
-rw-r--r--drivers/net/wireless/ath/wcn36xx/smd.c19
-rw-r--r--drivers/net/wireless/brcm80211/Kconfig2
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-7000.c29
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-config.h5
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-csr.h5
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/bt-coex.c6
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/d3.c5
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/debugfs.c4
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/time-event.c7
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/drv.c21
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/internal.h8
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/rx.c7
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/trans.c3
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/tx.c6
-rw-r--r--drivers/net/wireless/mac80211_hwsim.c16
-rw-r--r--drivers/net/wireless/mwifiex/sta_ioctl.c4
-rw-r--r--drivers/net/xen-netback/interface.c20
-rw-r--r--drivers/net/xen-netback/netback.c266
-rw-r--r--drivers/pci/host/pci-mvebu.c5
-rw-r--r--drivers/pci/host/pci-tegra.c53
-rw-r--r--drivers/pci/pci-driver.c38
-rw-r--r--drivers/pci/pci.c8
-rw-r--r--drivers/pci/remove.c4
-rw-r--r--drivers/regulator/as3722-regulator.c2
-rw-r--r--drivers/regulator/core.c11
-rw-r--r--drivers/regulator/pfuze100-regulator.c2
-rw-r--r--drivers/regulator/s5m8767.c2
-rw-r--r--drivers/rtc/rtc-at91rm9200.c2
-rw-r--r--drivers/rtc/rtc-s5m.c118
-rw-r--r--drivers/s390/block/dasd_genhd.c1
-rw-r--r--drivers/s390/char/sclp_early.c5
-rw-r--r--drivers/spi/Kconfig3
-rw-r--r--drivers/spi/spi-tegra114.c66
-rw-r--r--drivers/spi/spi-tegra20-sflash.c18
-rw-r--r--drivers/spi/spi-tegra20-slink.c66
-rw-r--r--drivers/staging/nvec/nvec.c11
-rw-r--r--drivers/staging/nvec/nvec.h5
-rw-r--r--drivers/staging/tidspbridge/rmgr/drv_interface.c13
-rw-r--r--drivers/tty/n_tty.c6
-rw-r--r--drivers/tty/serial/serial-tegra.c38
-rw-r--r--drivers/tty/serial/sh-sci.c320
-rw-r--r--drivers/tty/serial/sh-sci.h2
-rw-r--r--drivers/usb/class/cdc-acm.c2
-rw-r--r--drivers/usb/core/hub.c5
-rw-r--r--drivers/usb/dwc3/ep0.c2
-rw-r--r--drivers/usb/dwc3/gadget.c5
-rw-r--r--drivers/usb/gadget/Kconfig1
-rw-r--r--drivers/usb/gadget/composite.c1
-rw-r--r--drivers/usb/gadget/f_fs.c2
-rw-r--r--drivers/usb/gadget/f_mass_storage.c27
-rw-r--r--drivers/usb/gadget/pxa25x_udc.c1
-rw-r--r--drivers/usb/gadget/s3c-hsotg.c7
-rw-r--r--drivers/usb/gadget/storage_common.h4
-rw-r--r--drivers/usb/gadget/tcm_usb_gadget.c2
-rw-r--r--drivers/usb/gadget/zero.c6
-rw-r--r--drivers/usb/host/ehci-tegra.c14
-rw-r--r--drivers/usb/host/ohci-pxa27x.c1
-rw-r--r--drivers/usb/host/xhci-ring.c54
-rw-r--r--drivers/usb/musb/musb_core.c9
-rw-r--r--drivers/usb/musb/musb_cppi41.c164
-rw-r--r--drivers/usb/musb/musb_gadget.c4
-rw-r--r--drivers/usb/phy/phy-am335x.c5
-rw-r--r--drivers/usb/phy/phy-generic.c68
-rw-r--r--drivers/usb/phy/phy-generic.h4
-rw-r--r--drivers/usb/phy/phy-mxs-usb.c2
-rw-r--r--drivers/usb/phy/phy-rcar-gen2-usb.c4
-rw-r--r--drivers/usb/serial/ftdi_sio.c37
-rw-r--r--drivers/usb/serial/generic.c12
-rw-r--r--drivers/usb/serial/mos7840.c32
-rw-r--r--drivers/usb/serial/option.c27
-rw-r--r--drivers/usb/serial/pl2303.c30
-rw-r--r--drivers/usb/serial/spcp8x5.c30
-rw-r--r--drivers/usb/wusbcore/devconnect.c72
-rw-r--r--drivers/usb/wusbcore/security.c98
-rw-r--r--drivers/usb/wusbcore/wusbhc.h6
-rw-r--r--drivers/video/offb.c29
-rw-r--r--drivers/watchdog/bcm2835_wdt.c1
-rw-r--r--drivers/watchdog/ep93xx_wdt.c1
-rw-r--r--drivers/watchdog/ie6xx_wdt.c1
-rw-r--r--drivers/watchdog/jz4740_wdt.c1
-rw-r--r--drivers/watchdog/kempld_wdt.c1
-rw-r--r--drivers/watchdog/max63xx_wdt.c1
-rw-r--r--drivers/watchdog/orion_wdt.c1
-rw-r--r--drivers/watchdog/pnx4008_wdt.c1
-rw-r--r--drivers/watchdog/rt2880_wdt.c1
-rw-r--r--drivers/watchdog/sc1200wdt.c3
-rw-r--r--drivers/watchdog/shwdt.c1
-rw-r--r--drivers/watchdog/softdog.c1
-rw-r--r--drivers/watchdog/stmp3xxx_rtc_wdt.c1
-rw-r--r--drivers/watchdog/txx9wdt.c1
-rw-r--r--drivers/watchdog/ux500_wdt.c1
-rw-r--r--fs/btrfs/extent-tree.c22
-rw-r--r--fs/btrfs/ioctl.c3
-rw-r--r--fs/btrfs/relocation.c81
-rw-r--r--fs/btrfs/send.c4
-rw-r--r--fs/btrfs/super.c5
-rw-r--r--fs/dcache.c2
-rw-r--r--fs/namei.c7
-rw-r--r--fs/nfsd/nfscache.c9
-rw-r--r--fs/proc/inode.c14
-rw-r--r--fs/xfs/xfs_discard.c5
-rw-r--r--fs/xfs/xfs_fsops.c6
-rw-r--r--fs/xfs/xfs_ioctl.c3
-rw-r--r--fs/xfs/xfs_ioctl32.c3
-rw-r--r--include/asm-generic/word-at-a-time.h8
-rw-r--r--include/crypto/scatterwalk.h2
-rw-r--r--include/dt-bindings/clock/r8a7790-clock.h100
-rw-r--r--include/dt-bindings/clock/r8a7791-clock.h105
-rw-r--r--include/dt-bindings/clock/tegra114-car.h8
-rw-r--r--include/dt-bindings/clock/tegra124-car.h341
-rw-r--r--include/dt-bindings/clock/tegra20-car.h2
-rw-r--r--include/dt-bindings/clock/tegra30-car.h12
-rw-r--r--include/linux/assoc_array.h6
-rw-r--r--include/linux/clk/tegra.h7
-rw-r--r--include/linux/compiler-intel.h2
-rw-r--r--include/linux/cpufreq.h8
-rw-r--r--include/linux/dcache.h2
-rw-r--r--include/linux/dmaengine.h9
-rw-r--r--include/linux/hid-sensor-hub.h2
-rw-r--r--include/linux/hid-sensor-ids.h12
-rw-r--r--include/linux/hugetlb.h5
-rw-r--r--include/linux/ipv6.h1
-rw-r--r--include/linux/kernel.h3
-rw-r--r--include/linux/kexec.h3
-rw-r--r--include/linux/mfd/samsung/core.h3
-rw-r--r--include/linux/micrel_phy.h2
-rw-r--r--include/linux/net.h2
-rw-r--r--include/linux/netdevice.h2
-rw-r--r--include/linux/pci.h31
-rw-r--r--include/linux/serial_sci.h34
-rw-r--r--include/linux/shmem_fs.h2
-rw-r--r--include/linux/skbuff.h39
-rw-r--r--include/linux/tegra-powergate.h55
-rw-r--r--include/linux/usb.h2
-rw-r--r--include/linux/usb/wusb.h2
-rw-r--r--include/media/videobuf2-core.h2
-rw-r--r--include/net/ipv6.h3
-rw-r--r--include/net/sctp/structs.h6
-rw-r--r--include/net/sock.h6
-rw-r--r--include/sound/dmaengine_pcm.h10
-rw-r--r--include/sound/memalloc.h2
-rw-r--r--include/uapi/linux/input.h3
-rw-r--r--include/uapi/linux/mic_common.h40
-rw-r--r--include/uapi/sound/compress_offload.h6
-rw-r--r--kernel/.gitignore1
-rw-r--r--kernel/futex.c7
-rw-r--r--kernel/kexec.c4
-rw-r--r--kernel/system_certificates.S14
-rw-r--r--kernel/system_keyring.c4
-rw-r--r--kernel/workqueue.c32
-rw-r--r--lib/assoc_array.c4
-rw-r--r--mm/huge_memory.c12
-rw-r--r--mm/memcontrol.c41
-rw-r--r--mm/shmem.c36
-rw-r--r--net/bridge/br_private.h10
-rw-r--r--net/bridge/br_stp_bpdu.c2
-rw-r--r--net/core/drop_monitor.c1
-rw-r--r--net/core/skbuff.c1
-rw-r--r--net/core/sock.c2
-rw-r--r--net/dccp/ipv6.c1
-rw-r--r--net/ipv4/fib_rules.c5
-rw-r--r--net/ipv4/tcp_memcontrol.c7
-rw-r--r--net/ipv4/udp.c47
-rw-r--r--net/ipv6/addrconf.c2
-rw-r--r--net/ipv6/datagram.c1
-rw-r--r--net/ipv6/fib6_rules.c6
-rw-r--r--net/ipv6/ndisc.c3
-rw-r--r--net/ipv6/raw.c1
-rw-r--r--net/ipv6/route.c30
-rw-r--r--net/ipv6/tcp_ipv6.c1
-rw-r--r--net/ipv6/udp.c1
-rw-r--r--net/l2tp/l2tp_ip6.c1
-rw-r--r--net/mac80211/cfg.c15
-rw-r--r--net/mac80211/ibss.c4
-rw-r--r--net/mac80211/ieee80211_i.h1
-rw-r--r--net/mac80211/iface.c1
-rw-r--r--net/mac80211/main.c3
-rw-r--r--net/mac80211/mesh.c20
-rw-r--r--net/mac80211/mlme.c2
-rw-r--r--net/mac80211/rc80211_minstrel_ht.c7
-rw-r--r--net/mac80211/rx.c3
-rw-r--r--net/mac80211/scan.c2
-rw-r--r--net/mac80211/spectmgmt.c2
-rw-r--r--net/mac80211/util.c11
-rw-r--r--net/netfilter/ipset/ip_set_hash_netnet.c2
-rw-r--r--net/netfilter/nf_tables_api.c46
-rw-r--r--net/netfilter/xt_hashlimit.c25
-rw-r--r--net/packet/af_packet.c65
-rw-r--r--net/rds/ib_send.c5
-rw-r--r--net/sched/act_api.c26
-rw-r--r--net/sched/act_csum.c2
-rw-r--r--net/sched/act_gact.c2
-rw-r--r--net/sched/act_ipt.c4
-rw-r--r--net/sched/act_mirred.c2
-rw-r--r--net/sched/act_nat.c2
-rw-r--r--net/sched/act_pedit.c2
-rw-r--r--net/sched/act_police.c1
-rw-r--r--net/sched/act_simple.c1
-rw-r--r--net/sched/act_skbedit.c1
-rw-r--r--net/sched/sch_htb.c20
-rw-r--r--net/sched/sch_tbf.c117
-rw-r--r--net/sctp/associola.c5
-rw-r--r--net/sctp/output.c3
-rw-r--r--net/sctp/sm_statefuns.c12
-rw-r--r--net/sctp/socket.c36
-rw-r--r--net/sctp/sysctl.c76
-rw-r--r--net/sctp/transport.c2
-rw-r--r--net/tipc/core.c7
-rw-r--r--net/tipc/handler.c11
-rw-r--r--net/unix/af_unix.c8
-rw-r--r--net/wireless/core.c9
-rw-r--r--net/wireless/ibss.c18
-rw-r--r--net/wireless/nl80211.c60
-rw-r--r--scripts/sortextable.c5
-rw-r--r--security/keys/big_key.c2
-rw-r--r--security/keys/key.c8
-rw-r--r--security/keys/keyring.c17
-rw-r--r--security/selinux/hooks.c177
-rw-r--r--security/selinux/include/xfrm.h8
-rw-r--r--security/selinux/ss/services.c42
-rw-r--r--security/selinux/xfrm.c62
-rw-r--r--sound/pci/hda/hda_generic.c47
-rw-r--r--sound/pci/hda/hda_generic.h3
-rw-r--r--sound/pci/hda/patch_analog.c10
-rw-r--r--sound/pci/hda/patch_conexant.c1
-rw-r--r--sound/pci/hda/patch_hdmi.c5
-rw-r--r--sound/pci/hda/patch_realtek.c11
-rw-r--r--sound/soc/soc-devres.c41
-rw-r--r--sound/soc/soc-generic-dmaengine-pcm.c94
-rw-r--r--sound/soc/tegra/Kconfig2
-rw-r--r--sound/soc/tegra/tegra20_ac97.c11
-rw-r--r--sound/soc/tegra/tegra20_i2s.c20
-rw-r--r--sound/soc/tegra/tegra30_ahub.c138
-rw-r--r--sound/soc/tegra/tegra30_ahub.h11
-rw-r--r--sound/soc/tegra/tegra30_i2s.c97
-rw-r--r--sound/soc/tegra/tegra30_i2s.h3
-rw-r--r--sound/soc/tegra/tegra_pcm.c17
-rw-r--r--sound/soc/tegra/tegra_pcm.h5
-rw-r--r--sound/usb/mixer_quirks.c2
-rw-r--r--tools/usb/Makefile5
-rw-r--r--virt/kvm/kvm_main.c3
743 files changed, 14944 insertions, 7639 deletions
diff --git a/CREDITS b/CREDITS
index 4fc997d58ab2..4c7738f49357 100644
--- a/CREDITS
+++ b/CREDITS
@@ -655,6 +655,11 @@ S: Stanford University
655S: Stanford, California 94305 655S: Stanford, California 94305
656S: USA 656S: USA
657 657
658N: Carlos Chinea
659E: carlos.chinea@nokia.com
660E: cch.devel@gmail.com
661D: Author of HSI Subsystem
662
658N: Randolph Chung 663N: Randolph Chung
659E: tausq@debian.org 664E: tausq@debian.org
660D: Linux/PA-RISC hacker 665D: Linux/PA-RISC hacker
diff --git a/Documentation/DocBook/media/v4l/vidioc-expbuf.xml b/Documentation/DocBook/media/v4l/vidioc-expbuf.xml
index e287c8fc803b..4165e7bfa4ff 100644
--- a/Documentation/DocBook/media/v4l/vidioc-expbuf.xml
+++ b/Documentation/DocBook/media/v4l/vidioc-expbuf.xml
@@ -73,7 +73,8 @@ range from zero to the maximal number of valid planes for the currently active
73format. For the single-planar API, applications must set <structfield> plane 73format. For the single-planar API, applications must set <structfield> plane
74</structfield> to zero. Additional flags may be posted in the <structfield> 74</structfield> to zero. Additional flags may be posted in the <structfield>
75flags </structfield> field. Refer to a manual for open() for details. 75flags </structfield> field. Refer to a manual for open() for details.
76Currently only O_CLOEXEC is supported. All other fields must be set to zero. 76Currently only O_CLOEXEC, O_RDONLY, O_WRONLY, and O_RDWR are supported. All
77other fields must be set to zero.
77In the case of multi-planar API, every plane is exported separately using 78In the case of multi-planar API, every plane is exported separately using
78multiple <constant> VIDIOC_EXPBUF </constant> calls. </para> 79multiple <constant> VIDIOC_EXPBUF </constant> calls. </para>
79 80
@@ -170,8 +171,9 @@ multi-planar API. Otherwise this value must be set to zero. </entry>
170 <entry>__u32</entry> 171 <entry>__u32</entry>
171 <entry><structfield>flags</structfield></entry> 172 <entry><structfield>flags</structfield></entry>
172 <entry>Flags for the newly created file, currently only <constant> 173 <entry>Flags for the newly created file, currently only <constant>
173O_CLOEXEC </constant> is supported, refer to the manual of open() for more 174O_CLOEXEC </constant>, <constant>O_RDONLY</constant>, <constant>O_WRONLY
174details.</entry> 175</constant>, and <constant>O_RDWR</constant> are supported, refer to the manual
176of open() for more details.</entry>
175 </row> 177 </row>
176 <row> 178 <row>
177 <entry>__s32</entry> 179 <entry>__s32</entry>
diff --git a/Documentation/arm/Marvell/README b/Documentation/arm/Marvell/README
index da0151db9964..5a930c1528ad 100644
--- a/Documentation/arm/Marvell/README
+++ b/Documentation/arm/Marvell/README
@@ -211,6 +211,30 @@ MMP/MMP2 family (communication processor)
211 Linux kernel mach directory: arch/arm/mach-mmp 211 Linux kernel mach directory: arch/arm/mach-mmp
212 Linux kernel plat directory: arch/arm/plat-pxa 212 Linux kernel plat directory: arch/arm/plat-pxa
213 213
214Berlin family (Digital Entertainment)
215-------------------------------------
216
217 Flavors:
218 88DE3005, Armada 1500-mini
219 Design name: BG2CD
220 Core: ARM Cortex-A9, PL310 L2CC
221 Homepage: http://www.marvell.com/digital-entertainment/armada-1500-mini/
222 88DE3100, Armada 1500
223 Design name: BG2
224 Core: Marvell PJ4B (ARMv7), Tauros3 L2CC
225 Homepage: http://www.marvell.com/digital-entertainment/armada-1500/
226 Product Brief: http://www.marvell.com/digital-entertainment/armada-1500/assets/Marvell-ARMADA-1500-Product-Brief.pdf
227 88DE????
228 Design name: BG3
229 Core: ARM Cortex-A15, CA15 integrated L2CC
230
231 Homepage: http://www.marvell.com/digital-entertainment/
232 Directory: arch/arm/mach-berlin
233
234 Comments:
235 * This line of SoCs is based on Marvell Sheeva or ARM Cortex CPUs
236 with Synopsys DesignWare (IRQ, GPIO, Timers, ...) and PXA IP (SDHCI, USB, ETH, ...).
237
214Long-term plans 238Long-term plans
215--------------- 239---------------
216 240
diff --git a/Documentation/assoc_array.txt b/Documentation/assoc_array.txt
index f4faec0f66e4..2f2c6cdd73c0 100644
--- a/Documentation/assoc_array.txt
+++ b/Documentation/assoc_array.txt
@@ -164,10 +164,10 @@ This points to a number of methods, all of which need to be provided:
164 164
165 (4) Diff the index keys of two objects. 165 (4) Diff the index keys of two objects.
166 166
167 int (*diff_objects)(const void *a, const void *b); 167 int (*diff_objects)(const void *object, const void *index_key);
168 168
169 Return the bit position at which the index keys of two objects differ or 169 Return the bit position at which the index key of the specified object
170 -1 if they are the same. 170 differs from the given index key or -1 if they are the same.
171 171
172 172
173 (5) Free an object. 173 (5) Free an object.
diff --git a/Documentation/device-mapper/cache.txt b/Documentation/device-mapper/cache.txt
index 274752f8bdf9..719320b5ed3f 100644
--- a/Documentation/device-mapper/cache.txt
+++ b/Documentation/device-mapper/cache.txt
@@ -266,10 +266,12 @@ E.g.
266Invalidation is removing an entry from the cache without writing it 266Invalidation is removing an entry from the cache without writing it
267back. Cache blocks can be invalidated via the invalidate_cblocks 267back. Cache blocks can be invalidated via the invalidate_cblocks
268message, which takes an arbitrary number of cblock ranges. Each cblock 268message, which takes an arbitrary number of cblock ranges. Each cblock
269must be expressed as a decimal value, in the future a variant message 269range's end value is "one past the end", meaning 5-10 expresses a range
270that takes cblock ranges expressed in hexidecimal may be needed to 270of values from 5 to 9. Each cblock must be expressed as a decimal
271better support efficient invalidation of larger caches. The cache must 271value, in the future a variant message that takes cblock ranges
272be in passthrough mode when invalidate_cblocks is used. 272expressed in hexidecimal may be needed to better support efficient
273invalidation of larger caches. The cache must be in passthrough mode
274when invalidate_cblocks is used.
273 275
274 invalidate_cblocks [<cblock>|<cblock begin>-<cblock end>]* 276 invalidate_cblocks [<cblock>|<cblock begin>-<cblock end>]*
275 277
diff --git a/Documentation/devicetree/bindings/arm/marvell,berlin.txt b/Documentation/devicetree/bindings/arm/marvell,berlin.txt
new file mode 100644
index 000000000000..737afa5f8148
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/marvell,berlin.txt
@@ -0,0 +1,24 @@
1Marvell Berlin SoC Family Device Tree Bindings
2---------------------------------------------------------------
3
4Boards with a SoC of the Marvell Berlin family, e.g. Armada 1500
5shall have the following properties:
6
7* Required root node properties:
8compatible: must contain "marvell,berlin"
9
10In addition, the above compatible shall be extended with the specific
11SoC and board used. Currently known SoC compatibles are:
12 "marvell,berlin2" for Marvell Armada 1500 (BG2, 88DE3100),
13 "marvell,berlin2cd" for Marvell Armada 1500-mini (BG2CD, 88DE3005)
14 "marvell,berlin2ct" for Marvell Armada ? (BG2CT, 88DE????)
15 "marvell,berlin3" for Marvell Armada ? (BG3, 88DE????)
16
17* Example:
18
19/ {
20 model = "Sony NSZ-GS7";
21 compatible = "sony,nsz-gs7", "marvell,berlin2", "marvell,berlin";
22
23 ...
24}
diff --git a/Documentation/devicetree/bindings/arm/tegra/nvidia,tegra20-pmc.txt b/Documentation/devicetree/bindings/arm/tegra/nvidia,tegra20-pmc.txt
index 1608a54e90e1..68ac65f82a1c 100644
--- a/Documentation/devicetree/bindings/arm/tegra/nvidia,tegra20-pmc.txt
+++ b/Documentation/devicetree/bindings/arm/tegra/nvidia,tegra20-pmc.txt
@@ -9,6 +9,7 @@ Required properties:
9- compatible : Should contain "nvidia,tegra<chip>-pmc". 9- compatible : Should contain "nvidia,tegra<chip>-pmc".
10- reg : Offset and length of the register set for the device 10- reg : Offset and length of the register set for the device
11- clocks : Must contain an entry for each entry in clock-names. 11- clocks : Must contain an entry for each entry in clock-names.
12 See ../clocks/clock-bindings.txt for details.
12- clock-names : Must include the following entries: 13- clock-names : Must include the following entries:
13 "pclk" (The Tegra clock of that name), 14 "pclk" (The Tegra clock of that name),
14 "clk32k_in" (The 32KHz clock input to Tegra). 15 "clk32k_in" (The 32KHz clock input to Tegra).
diff --git a/Documentation/devicetree/bindings/clock/nvidia,tegra114-car.txt b/Documentation/devicetree/bindings/clock/nvidia,tegra114-car.txt
index 0c80c2677104..9acea9d93160 100644
--- a/Documentation/devicetree/bindings/clock/nvidia,tegra114-car.txt
+++ b/Documentation/devicetree/bindings/clock/nvidia,tegra114-car.txt
@@ -15,6 +15,9 @@ Required properties :
15 In clock consumers, this cell represents the clock ID exposed by the 15 In clock consumers, this cell represents the clock ID exposed by the
16 CAR. The assignments may be found in header file 16 CAR. The assignments may be found in header file
17 <dt-bindings/clock/tegra114-car.h>. 17 <dt-bindings/clock/tegra114-car.h>.
18- #reset-cells : Should be 1.
19 In clock consumers, this cell represents the bit number in the CAR's
20 array of CLK_RST_CONTROLLER_RST_DEVICES_* registers.
18 21
19Example SoC include file: 22Example SoC include file:
20 23
@@ -23,6 +26,7 @@ Example SoC include file:
23 compatible = "nvidia,tegra114-car"; 26 compatible = "nvidia,tegra114-car";
24 reg = <0x60006000 0x1000>; 27 reg = <0x60006000 0x1000>;
25 #clock-cells = <1>; 28 #clock-cells = <1>;
29 #reset-cells = <1>;
26 }; 30 };
27 31
28 usb@c5004000 { 32 usb@c5004000 {
diff --git a/Documentation/devicetree/bindings/clock/nvidia,tegra124-car.txt b/Documentation/devicetree/bindings/clock/nvidia,tegra124-car.txt
new file mode 100644
index 000000000000..ded5d6212c84
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/nvidia,tegra124-car.txt
@@ -0,0 +1,63 @@
1NVIDIA Tegra124 Clock And Reset Controller
2
3This binding uses the common clock binding:
4Documentation/devicetree/bindings/clock/clock-bindings.txt
5
6The CAR (Clock And Reset) Controller on Tegra is the HW module responsible
7for muxing and gating Tegra's clocks, and setting their rates.
8
9Required properties :
10- compatible : Should be "nvidia,tegra124-car"
11- reg : Should contain CAR registers location and length
12- clocks : Should contain phandle and clock specifiers for two clocks:
13 the 32 KHz "32k_in", and the board-specific oscillator "osc".
14- #clock-cells : Should be 1.
15 In clock consumers, this cell represents the clock ID exposed by the
16 CAR. The assignments may be found in header file
17 <dt-bindings/clock/tegra124-car.h>.
18- #reset-cells : Should be 1.
19 In clock consumers, this cell represents the bit number in the CAR's
20 array of CLK_RST_CONTROLLER_RST_DEVICES_* registers.
21
22Example SoC include file:
23
24/ {
25 tegra_car: clock {
26 compatible = "nvidia,tegra124-car";
27 reg = <0x60006000 0x1000>;
28 #clock-cells = <1>;
29 #reset-cells = <1>;
30 };
31
32 usb@c5004000 {
33 clocks = <&tegra_car TEGRA124_CLK_USB2>;
34 };
35};
36
37Example board file:
38
39/ {
40 clocks {
41 compatible = "simple-bus";
42 #address-cells = <1>;
43 #size-cells = <0>;
44
45 osc: clock@0 {
46 compatible = "fixed-clock";
47 reg = <0>;
48 #clock-cells = <0>;
49 clock-frequency = <112400000>;
50 };
51
52 clk_32k: clock@1 {
53 compatible = "fixed-clock";
54 reg = <1>;
55 #clock-cells = <0>;
56 clock-frequency = <32768>;
57 };
58 };
59
60 &tegra_car {
61 clocks = <&clk_32k> <&osc>;
62 };
63};
diff --git a/Documentation/devicetree/bindings/clock/nvidia,tegra20-car.txt b/Documentation/devicetree/bindings/clock/nvidia,tegra20-car.txt
index fcfed5bf73fb..6c5901b503d0 100644
--- a/Documentation/devicetree/bindings/clock/nvidia,tegra20-car.txt
+++ b/Documentation/devicetree/bindings/clock/nvidia,tegra20-car.txt
@@ -15,6 +15,9 @@ Required properties :
15 In clock consumers, this cell represents the clock ID exposed by the 15 In clock consumers, this cell represents the clock ID exposed by the
16 CAR. The assignments may be found in header file 16 CAR. The assignments may be found in header file
17 <dt-bindings/clock/tegra20-car.h>. 17 <dt-bindings/clock/tegra20-car.h>.
18- #reset-cells : Should be 1.
19 In clock consumers, this cell represents the bit number in the CAR's
20 array of CLK_RST_CONTROLLER_RST_DEVICES_* registers.
18 21
19Example SoC include file: 22Example SoC include file:
20 23
@@ -23,6 +26,7 @@ Example SoC include file:
23 compatible = "nvidia,tegra20-car"; 26 compatible = "nvidia,tegra20-car";
24 reg = <0x60006000 0x1000>; 27 reg = <0x60006000 0x1000>;
25 #clock-cells = <1>; 28 #clock-cells = <1>;
29 #reset-cells = <1>;
26 }; 30 };
27 31
28 usb@c5004000 { 32 usb@c5004000 {
diff --git a/Documentation/devicetree/bindings/clock/nvidia,tegra30-car.txt b/Documentation/devicetree/bindings/clock/nvidia,tegra30-car.txt
index 0f714081e986..63618cde12df 100644
--- a/Documentation/devicetree/bindings/clock/nvidia,tegra30-car.txt
+++ b/Documentation/devicetree/bindings/clock/nvidia,tegra30-car.txt
@@ -15,6 +15,9 @@ Required properties :
15 In clock consumers, this cell represents the clock ID exposed by the 15 In clock consumers, this cell represents the clock ID exposed by the
16 CAR. The assignments may be found in header file 16 CAR. The assignments may be found in header file
17 <dt-bindings/clock/tegra30-car.h>. 17 <dt-bindings/clock/tegra30-car.h>.
18- #reset-cells : Should be 1.
19 In clock consumers, this cell represents the bit number in the CAR's
20 array of CLK_RST_CONTROLLER_RST_DEVICES_* registers.
18 21
19Example SoC include file: 22Example SoC include file:
20 23
@@ -23,6 +26,7 @@ Example SoC include file:
23 compatible = "nvidia,tegra30-car"; 26 compatible = "nvidia,tegra30-car";
24 reg = <0x60006000 0x1000>; 27 reg = <0x60006000 0x1000>;
25 #clock-cells = <1>; 28 #clock-cells = <1>;
29 #reset-cells = <1>;
26 }; 30 };
27 31
28 usb@c5004000 { 32 usb@c5004000 {
diff --git a/Documentation/devicetree/bindings/dma/tegra20-apbdma.txt b/Documentation/devicetree/bindings/dma/tegra20-apbdma.txt
index 90fa7da525b8..c6908e7c42cc 100644
--- a/Documentation/devicetree/bindings/dma/tegra20-apbdma.txt
+++ b/Documentation/devicetree/bindings/dma/tegra20-apbdma.txt
@@ -5,6 +5,16 @@ Required properties:
5- reg: Should contain DMA registers location and length. This shuld include 5- reg: Should contain DMA registers location and length. This shuld include
6 all of the per-channel registers. 6 all of the per-channel registers.
7- interrupts: Should contain all of the per-channel DMA interrupts. 7- interrupts: Should contain all of the per-channel DMA interrupts.
8- clocks: Must contain one entry, for the module clock.
9 See ../clocks/clock-bindings.txt for details.
10- resets : Must contain an entry for each entry in reset-names.
11 See ../reset/reset.txt for details.
12- reset-names : Must include the following entries:
13 - dma
14- #dma-cells : Must be <1>. This dictates the length of DMA specifiers in
15 client nodes' dmas properties. The specifier represents the DMA request
16 select value for the peripheral. For more details, consult the Tegra TRM's
17 documentation of the APB DMA channel control register REQ_SEL field.
8 18
9Examples: 19Examples:
10 20
@@ -27,4 +37,8 @@ apbdma: dma@6000a000 {
27 0 149 0x04 37 0 149 0x04
28 0 150 0x04 38 0 150 0x04
29 0 151 0x04 >; 39 0 151 0x04 >;
40 clocks = <&tegra_car 34>;
41 resets = <&tegra_car 34>;
42 reset-names = "dma";
43 #dma-cells = <1>;
30}; 44};
diff --git a/Documentation/devicetree/bindings/gpu/nvidia,tegra20-host1x.txt b/Documentation/devicetree/bindings/gpu/nvidia,tegra20-host1x.txt
index b4fa934ae3a2..ab45c02aa658 100644
--- a/Documentation/devicetree/bindings/gpu/nvidia,tegra20-host1x.txt
+++ b/Documentation/devicetree/bindings/gpu/nvidia,tegra20-host1x.txt
@@ -9,6 +9,12 @@ Required properties:
9- #size-cells: The number of cells used to represent the size of an address 9- #size-cells: The number of cells used to represent the size of an address
10 range in the host1x address space. Should be 1. 10 range in the host1x address space. Should be 1.
11- ranges: The mapping of the host1x address space to the CPU address space. 11- ranges: The mapping of the host1x address space to the CPU address space.
12- clocks: Must contain one entry, for the module clock.
13 See ../clocks/clock-bindings.txt for details.
14- resets: Must contain an entry for each entry in reset-names.
15 See ../reset/reset.txt for details.
16- reset-names: Must include the following entries:
17 - host1x
12 18
13The host1x top-level node defines a number of children, each representing one 19The host1x top-level node defines a number of children, each representing one
14of the following host1x client modules: 20of the following host1x client modules:
@@ -19,6 +25,12 @@ of the following host1x client modules:
19 - compatible: "nvidia,tegra<chip>-mpe" 25 - compatible: "nvidia,tegra<chip>-mpe"
20 - reg: Physical base address and length of the controller's registers. 26 - reg: Physical base address and length of the controller's registers.
21 - interrupts: The interrupt outputs from the controller. 27 - interrupts: The interrupt outputs from the controller.
28 - clocks: Must contain one entry, for the module clock.
29 See ../clocks/clock-bindings.txt for details.
30 - resets: Must contain an entry for each entry in reset-names.
31 See ../reset/reset.txt for details.
32 - reset-names: Must include the following entries:
33 - mpe
22 34
23- vi: video input 35- vi: video input
24 36
@@ -26,6 +38,12 @@ of the following host1x client modules:
26 - compatible: "nvidia,tegra<chip>-vi" 38 - compatible: "nvidia,tegra<chip>-vi"
27 - reg: Physical base address and length of the controller's registers. 39 - reg: Physical base address and length of the controller's registers.
28 - interrupts: The interrupt outputs from the controller. 40 - interrupts: The interrupt outputs from the controller.
41 - clocks: Must contain one entry, for the module clock.
42 See ../clocks/clock-bindings.txt for details.
43 - resets: Must contain an entry for each entry in reset-names.
44 See ../reset/reset.txt for details.
45 - reset-names: Must include the following entries:
46 - vi
29 47
30- epp: encoder pre-processor 48- epp: encoder pre-processor
31 49
@@ -33,6 +51,12 @@ of the following host1x client modules:
33 - compatible: "nvidia,tegra<chip>-epp" 51 - compatible: "nvidia,tegra<chip>-epp"
34 - reg: Physical base address and length of the controller's registers. 52 - reg: Physical base address and length of the controller's registers.
35 - interrupts: The interrupt outputs from the controller. 53 - interrupts: The interrupt outputs from the controller.
54 - clocks: Must contain one entry, for the module clock.
55 See ../clocks/clock-bindings.txt for details.
56 - resets: Must contain an entry for each entry in reset-names.
57 See ../reset/reset.txt for details.
58 - reset-names: Must include the following entries:
59 - epp
36 60
37- isp: image signal processor 61- isp: image signal processor
38 62
@@ -40,6 +64,12 @@ of the following host1x client modules:
40 - compatible: "nvidia,tegra<chip>-isp" 64 - compatible: "nvidia,tegra<chip>-isp"
41 - reg: Physical base address and length of the controller's registers. 65 - reg: Physical base address and length of the controller's registers.
42 - interrupts: The interrupt outputs from the controller. 66 - interrupts: The interrupt outputs from the controller.
67 - clocks: Must contain one entry, for the module clock.
68 See ../clocks/clock-bindings.txt for details.
69 - resets: Must contain an entry for each entry in reset-names.
70 See ../reset/reset.txt for details.
71 - reset-names: Must include the following entries:
72 - isp
43 73
44- gr2d: 2D graphics engine 74- gr2d: 2D graphics engine
45 75
@@ -47,12 +77,30 @@ of the following host1x client modules:
47 - compatible: "nvidia,tegra<chip>-gr2d" 77 - compatible: "nvidia,tegra<chip>-gr2d"
48 - reg: Physical base address and length of the controller's registers. 78 - reg: Physical base address and length of the controller's registers.
49 - interrupts: The interrupt outputs from the controller. 79 - interrupts: The interrupt outputs from the controller.
80 - clocks: Must contain one entry, for the module clock.
81 See ../clocks/clock-bindings.txt for details.
82 - resets: Must contain an entry for each entry in reset-names.
83 See ../reset/reset.txt for details.
84 - reset-names: Must include the following entries:
85 - 2d
50 86
51- gr3d: 3D graphics engine 87- gr3d: 3D graphics engine
52 88
53 Required properties: 89 Required properties:
54 - compatible: "nvidia,tegra<chip>-gr3d" 90 - compatible: "nvidia,tegra<chip>-gr3d"
55 - reg: Physical base address and length of the controller's registers. 91 - reg: Physical base address and length of the controller's registers.
92 - clocks: Must contain an entry for each entry in clock-names.
93 See ../clocks/clock-bindings.txt for details.
94 - clock-names: Must include the following entries:
95 (This property may be omitted if the only clock in the list is "3d")
96 - 3d
97 This MUST be the first entry.
98 - 3d2 (Only required on SoCs with two 3D clocks)
99 - resets: Must contain an entry for each entry in reset-names.
100 See ../reset/reset.txt for details.
101 - reset-names: Must include the following entries:
102 - 3d
103 - 3d2 (Only required on SoCs with two 3D clocks)
56 104
57- dc: display controller 105- dc: display controller
58 106
@@ -60,6 +108,16 @@ of the following host1x client modules:
60 - compatible: "nvidia,tegra<chip>-dc" 108 - compatible: "nvidia,tegra<chip>-dc"
61 - reg: Physical base address and length of the controller's registers. 109 - reg: Physical base address and length of the controller's registers.
62 - interrupts: The interrupt outputs from the controller. 110 - interrupts: The interrupt outputs from the controller.
111 - clocks: Must contain an entry for each entry in clock-names.
112 See ../clocks/clock-bindings.txt for details.
113 - clock-names: Must include the following entries:
114 - dc
115 This MUST be the first entry.
116 - parent
117 - resets: Must contain an entry for each entry in reset-names.
118 See ../reset/reset.txt for details.
119 - reset-names: Must include the following entries:
120 - dc
63 121
64 Each display controller node has a child node, named "rgb", that represents 122 Each display controller node has a child node, named "rgb", that represents
65 the RGB output associated with the controller. It can take the following 123 the RGB output associated with the controller. It can take the following
@@ -76,6 +134,16 @@ of the following host1x client modules:
76 - interrupts: The interrupt outputs from the controller. 134 - interrupts: The interrupt outputs from the controller.
77 - vdd-supply: regulator for supply voltage 135 - vdd-supply: regulator for supply voltage
78 - pll-supply: regulator for PLL 136 - pll-supply: regulator for PLL
137 - clocks: Must contain an entry for each entry in clock-names.
138 See ../clocks/clock-bindings.txt for details.
139 - clock-names: Must include the following entries:
140 - hdmi
141 This MUST be the first entry.
142 - parent
143 - resets: Must contain an entry for each entry in reset-names.
144 See ../reset/reset.txt for details.
145 - reset-names: Must include the following entries:
146 - hdmi
79 147
80 Optional properties: 148 Optional properties:
81 - nvidia,ddc-i2c-bus: phandle of an I2C controller used for DDC EDID probing 149 - nvidia,ddc-i2c-bus: phandle of an I2C controller used for DDC EDID probing
@@ -88,12 +156,24 @@ of the following host1x client modules:
88 - compatible: "nvidia,tegra<chip>-tvo" 156 - compatible: "nvidia,tegra<chip>-tvo"
89 - reg: Physical base address and length of the controller's registers. 157 - reg: Physical base address and length of the controller's registers.
90 - interrupts: The interrupt outputs from the controller. 158 - interrupts: The interrupt outputs from the controller.
159 - clocks: Must contain one entry, for the module clock.
160 See ../clocks/clock-bindings.txt for details.
91 161
92- dsi: display serial interface 162- dsi: display serial interface
93 163
94 Required properties: 164 Required properties:
95 - compatible: "nvidia,tegra<chip>-dsi" 165 - compatible: "nvidia,tegra<chip>-dsi"
96 - reg: Physical base address and length of the controller's registers. 166 - reg: Physical base address and length of the controller's registers.
167 - clocks: Must contain an entry for each entry in clock-names.
168 See ../clocks/clock-bindings.txt for details.
169 - clock-names: Must include the following entries:
170 - dsi
171 This MUST be the first entry.
172 - parent
173 - resets: Must contain an entry for each entry in reset-names.
174 See ../reset/reset.txt for details.
175 - reset-names: Must include the following entries:
176 - dsi
97 177
98Example: 178Example:
99 179
@@ -105,6 +185,9 @@ Example:
105 reg = <0x50000000 0x00024000>; 185 reg = <0x50000000 0x00024000>;
106 interrupts = <0 65 0x04 /* mpcore syncpt */ 186 interrupts = <0 65 0x04 /* mpcore syncpt */
107 0 67 0x04>; /* mpcore general */ 187 0 67 0x04>; /* mpcore general */
188 clocks = <&tegra_car TEGRA20_CLK_HOST1X>;
189 resets = <&tegra_car 28>;
190 reset-names = "host1x";
108 191
109 #address-cells = <1>; 192 #address-cells = <1>;
110 #size-cells = <1>; 193 #size-cells = <1>;
@@ -115,41 +198,64 @@ Example:
115 compatible = "nvidia,tegra20-mpe"; 198 compatible = "nvidia,tegra20-mpe";
116 reg = <0x54040000 0x00040000>; 199 reg = <0x54040000 0x00040000>;
117 interrupts = <0 68 0x04>; 200 interrupts = <0 68 0x04>;
201 clocks = <&tegra_car TEGRA20_CLK_MPE>;
202 resets = <&tegra_car 60>;
203 reset-names = "mpe";
118 }; 204 };
119 205
120 vi { 206 vi {
121 compatible = "nvidia,tegra20-vi"; 207 compatible = "nvidia,tegra20-vi";
122 reg = <0x54080000 0x00040000>; 208 reg = <0x54080000 0x00040000>;
123 interrupts = <0 69 0x04>; 209 interrupts = <0 69 0x04>;
210 clocks = <&tegra_car TEGRA20_CLK_VI>;
211 resets = <&tegra_car 100>;
212 reset-names = "vi";
124 }; 213 };
125 214
126 epp { 215 epp {
127 compatible = "nvidia,tegra20-epp"; 216 compatible = "nvidia,tegra20-epp";
128 reg = <0x540c0000 0x00040000>; 217 reg = <0x540c0000 0x00040000>;
129 interrupts = <0 70 0x04>; 218 interrupts = <0 70 0x04>;
219 clocks = <&tegra_car TEGRA20_CLK_EPP>;
220 resets = <&tegra_car 19>;
221 reset-names = "epp";
130 }; 222 };
131 223
132 isp { 224 isp {
133 compatible = "nvidia,tegra20-isp"; 225 compatible = "nvidia,tegra20-isp";
134 reg = <0x54100000 0x00040000>; 226 reg = <0x54100000 0x00040000>;
135 interrupts = <0 71 0x04>; 227 interrupts = <0 71 0x04>;
228 clocks = <&tegra_car TEGRA20_CLK_ISP>;
229 resets = <&tegra_car 23>;
230 reset-names = "isp";
136 }; 231 };
137 232
138 gr2d { 233 gr2d {
139 compatible = "nvidia,tegra20-gr2d"; 234 compatible = "nvidia,tegra20-gr2d";
140 reg = <0x54140000 0x00040000>; 235 reg = <0x54140000 0x00040000>;
141 interrupts = <0 72 0x04>; 236 interrupts = <0 72 0x04>;
237 clocks = <&tegra_car TEGRA20_CLK_GR2D>;
238 resets = <&tegra_car 21>;
239 reset-names = "2d";
142 }; 240 };
143 241
144 gr3d { 242 gr3d {
145 compatible = "nvidia,tegra20-gr3d"; 243 compatible = "nvidia,tegra20-gr3d";
146 reg = <0x54180000 0x00040000>; 244 reg = <0x54180000 0x00040000>;
245 clocks = <&tegra_car TEGRA20_CLK_GR3D>;
246 resets = <&tegra_car 24>;
247 reset-names = "3d";
147 }; 248 };
148 249
149 dc@54200000 { 250 dc@54200000 {
150 compatible = "nvidia,tegra20-dc"; 251 compatible = "nvidia,tegra20-dc";
151 reg = <0x54200000 0x00040000>; 252 reg = <0x54200000 0x00040000>;
152 interrupts = <0 73 0x04>; 253 interrupts = <0 73 0x04>;
254 clocks = <&tegra_car TEGRA20_CLK_DISP1>,
255 <&tegra_car TEGRA20_CLK_PLL_P>;
256 clock-names = "disp1", "parent";
257 resets = <&tegra_car 27>;
258 reset-names = "dc";
153 259
154 rgb { 260 rgb {
155 status = "disabled"; 261 status = "disabled";
@@ -160,6 +266,11 @@ Example:
160 compatible = "nvidia,tegra20-dc"; 266 compatible = "nvidia,tegra20-dc";
161 reg = <0x54240000 0x00040000>; 267 reg = <0x54240000 0x00040000>;
162 interrupts = <0 74 0x04>; 268 interrupts = <0 74 0x04>;
269 clocks = <&tegra_car TEGRA20_CLK_DISP2>,
270 <&tegra_car TEGRA20_CLK_PLL_P>;
271 clock-names = "disp2", "parent";
272 resets = <&tegra_car 26>;
273 reset-names = "dc";
163 274
164 rgb { 275 rgb {
165 status = "disabled"; 276 status = "disabled";
@@ -170,6 +281,11 @@ Example:
170 compatible = "nvidia,tegra20-hdmi"; 281 compatible = "nvidia,tegra20-hdmi";
171 reg = <0x54280000 0x00040000>; 282 reg = <0x54280000 0x00040000>;
172 interrupts = <0 75 0x04>; 283 interrupts = <0 75 0x04>;
284 clocks = <&tegra_car TEGRA20_CLK_HDMI>,
285 <&tegra_car TEGRA20_CLK_PLL_D_OUT0>;
286 clock-names = "hdmi", "parent";
287 resets = <&tegra_car 51>;
288 reset-names = "hdmi";
173 status = "disabled"; 289 status = "disabled";
174 }; 290 };
175 291
@@ -177,12 +293,18 @@ Example:
177 compatible = "nvidia,tegra20-tvo"; 293 compatible = "nvidia,tegra20-tvo";
178 reg = <0x542c0000 0x00040000>; 294 reg = <0x542c0000 0x00040000>;
179 interrupts = <0 76 0x04>; 295 interrupts = <0 76 0x04>;
296 clocks = <&tegra_car TEGRA20_CLK_TVO>;
180 status = "disabled"; 297 status = "disabled";
181 }; 298 };
182 299
183 dsi { 300 dsi {
184 compatible = "nvidia,tegra20-dsi"; 301 compatible = "nvidia,tegra20-dsi";
185 reg = <0x54300000 0x00040000>; 302 reg = <0x54300000 0x00040000>;
303 clocks = <&tegra_car TEGRA20_CLK_DSI>,
304 <&tegra_car TEGRA20_CLK_PLL_D_OUT0>;
305 clock-names = "dsi", "parent";
306 resets = <&tegra_car 48>;
307 reset-names = "dsi";
186 status = "disabled"; 308 status = "disabled";
187 }; 309 };
188 }; 310 };
diff --git a/Documentation/devicetree/bindings/i2c/nvidia,tegra20-i2c.txt b/Documentation/devicetree/bindings/i2c/nvidia,tegra20-i2c.txt
index ef77cc7a0e46..87507e9ce6db 100644
--- a/Documentation/devicetree/bindings/i2c/nvidia,tegra20-i2c.txt
+++ b/Documentation/devicetree/bindings/i2c/nvidia,tegra20-i2c.txt
@@ -39,12 +39,23 @@ Required properties:
39- interrupts: Should contain I2C controller interrupts. 39- interrupts: Should contain I2C controller interrupts.
40- address-cells: Address cells for I2C device address. 40- address-cells: Address cells for I2C device address.
41- size-cells: Size of the I2C device address. 41- size-cells: Size of the I2C device address.
42- clocks: Clock ID as per 42- clocks: Must contain an entry for each entry in clock-names.
43 Documentation/devicetree/bindings/clock/tegra<chip-id>.txt 43 See ../clocks/clock-bindings.txt for details.
44 for I2C controller. 44- clock-names: Must include the following entries:
45- clock-names: Name of the clock: 45 Tegra20/Tegra30:
46 Tegra20/Tegra30 I2C controller: "div-clk and "fast-clk". 46 - div-clk
47 Tegra114 I2C controller: "div-clk". 47 - fast-clk
48 Tegra114:
49 - div-clk
50- resets: Must contain an entry for each entry in reset-names.
51 See ../reset/reset.txt for details.
52- reset-names: Must include the following entries:
53 - i2c
54- dmas: Must contain an entry for each entry in clock-names.
55 See ../dma/dma.txt for details.
56- dma-names: Must include the following entries:
57 - rx
58 - tx
48 59
49Example: 60Example:
50 61
@@ -56,5 +67,9 @@ Example:
56 #size-cells = <0>; 67 #size-cells = <0>;
57 clocks = <&tegra_car 12>, <&tegra_car 124>; 68 clocks = <&tegra_car 12>, <&tegra_car 124>;
58 clock-names = "div-clk", "fast-clk"; 69 clock-names = "div-clk", "fast-clk";
70 resets = <&tegra_car 12>;
71 reset-names = "i2c";
72 dmas = <&apbdma 16>, <&apbdma 16>;
73 dma-names = "rx", "tx";
59 status = "disabled"; 74 status = "disabled";
60 }; 75 };
diff --git a/Documentation/devicetree/bindings/input/nvidia,tegra20-kbc.txt b/Documentation/devicetree/bindings/input/nvidia,tegra20-kbc.txt
index 2995fae7ee47..0382b8bd69c6 100644
--- a/Documentation/devicetree/bindings/input/nvidia,tegra20-kbc.txt
+++ b/Documentation/devicetree/bindings/input/nvidia,tegra20-kbc.txt
@@ -13,6 +13,12 @@ Required properties:
13 array of pin numbers which is used as column. 13 array of pin numbers which is used as column.
14- linux,keymap: The keymap for keys as described in the binding document 14- linux,keymap: The keymap for keys as described in the binding document
15 devicetree/bindings/input/matrix-keymap.txt. 15 devicetree/bindings/input/matrix-keymap.txt.
16- clocks: Must contain one entry, for the module clock.
17 See ../clocks/clock-bindings.txt for details.
18- resets: Must contain an entry for each entry in reset-names.
19 See ../reset/reset.txt for details.
20- reset-names: Must include the following entries:
21 - kbc
16 22
17Optional properties, in addition to those specified by the shared 23Optional properties, in addition to those specified by the shared
18matrix-keyboard bindings: 24matrix-keyboard bindings:
@@ -31,6 +37,9 @@ keyboard: keyboard {
31 compatible = "nvidia,tegra20-kbc"; 37 compatible = "nvidia,tegra20-kbc";
32 reg = <0x7000e200 0x100>; 38 reg = <0x7000e200 0x100>;
33 interrupts = <0 85 0x04>; 39 interrupts = <0 85 0x04>;
40 clocks = <&tegra_car 36>;
41 resets = <&tegra_car 36>;
42 reset-names = "kbc";
34 nvidia,ghost-filter; 43 nvidia,ghost-filter;
35 nvidia,debounce-delay-ms = <640>; 44 nvidia,debounce-delay-ms = <640>;
36 nvidia,kbc-row-pins = <0 1 2>; /* pin 0, 1, 2 as rows */ 45 nvidia,kbc-row-pins = <0 1 2>; /* pin 0, 1, 2 as rows */
diff --git a/Documentation/devicetree/bindings/interrupt-controller/snps,dw-apb-ictl.txt b/Documentation/devicetree/bindings/interrupt-controller/snps,dw-apb-ictl.txt
new file mode 100644
index 000000000000..492911744ca3
--- /dev/null
+++ b/Documentation/devicetree/bindings/interrupt-controller/snps,dw-apb-ictl.txt
@@ -0,0 +1,32 @@
1Synopsys DesignWare APB interrupt controller (dw_apb_ictl)
2
3Synopsys DesignWare provides interrupt controller IP for APB known as
4dw_apb_ictl. The IP is used as secondary interrupt controller in some SoCs with
5APB bus, e.g. Marvell Armada 1500.
6
7Required properties:
8- compatible: shall be "snps,dw-apb-ictl"
9- reg: physical base address of the controller and length of memory mapped
10 region starting with ENABLE_LOW register
11- interrupt-controller: identifies the node as an interrupt controller
12- #interrupt-cells: number of cells to encode an interrupt-specifier, shall be 1
13- interrupts: interrupt reference to primary interrupt controller
14- interrupt-parent: (optional) reference specific primary interrupt controller
15
16The interrupt sources map to the corresponding bits in the interrupt
17registers, i.e.
18- 0 maps to bit 0 of low interrupts,
19- 1 maps to bit 1 of low interrupts,
20- 32 maps to bit 0 of high interrupts,
21- 33 maps to bit 1 of high interrupts,
22- (optional) fast interrupts start at 64.
23
24Example:
25 aic: interrupt-controller@3000 {
26 compatible = "snps,dw-apb-ictl";
27 reg = <0x3000 0xc00>;
28 interrupt-controller;
29 #interrupt-cells = <1>;
30 interrupt-parent = <&gic>;
31 interrupts = <GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>;
32 };
diff --git a/Documentation/devicetree/bindings/mmc/nvidia,tegra20-sdhci.txt b/Documentation/devicetree/bindings/mmc/nvidia,tegra20-sdhci.txt
index c6d7b11db9eb..f357c16ea815 100644
--- a/Documentation/devicetree/bindings/mmc/nvidia,tegra20-sdhci.txt
+++ b/Documentation/devicetree/bindings/mmc/nvidia,tegra20-sdhci.txt
@@ -8,6 +8,12 @@ by mmc.txt and the properties used by the sdhci-tegra driver.
8 8
9Required properties: 9Required properties:
10- compatible : Should be "nvidia,<chip>-sdhci" 10- compatible : Should be "nvidia,<chip>-sdhci"
11- clocks : Must contain one entry, for the module clock.
12 See ../clocks/clock-bindings.txt for details.
13- resets : Must contain an entry for each entry in reset-names.
14 See ../reset/reset.txt for details.
15- reset-names : Must include the following entries:
16 - sdhci
11 17
12Optional properties: 18Optional properties:
13- power-gpios : Specify GPIOs for power control 19- power-gpios : Specify GPIOs for power control
@@ -18,6 +24,9 @@ sdhci@c8000200 {
18 compatible = "nvidia,tegra20-sdhci"; 24 compatible = "nvidia,tegra20-sdhci";
19 reg = <0xc8000200 0x200>; 25 reg = <0xc8000200 0x200>;
20 interrupts = <47>; 26 interrupts = <47>;
27 clocks = <&tegra_car 14>;
28 resets = <&tegra_car 14>;
29 reset-names = "sdhci";
21 cd-gpios = <&gpio 69 0>; /* gpio PI5 */ 30 cd-gpios = <&gpio 69 0>; /* gpio PI5 */
22 wp-gpios = <&gpio 57 0>; /* gpio PH1 */ 31 wp-gpios = <&gpio 57 0>; /* gpio PH1 */
23 power-gpios = <&gpio 155 0>; /* gpio PT3 */ 32 power-gpios = <&gpio 155 0>; /* gpio PT3 */
diff --git a/Documentation/devicetree/bindings/net/davinci_emac.txt b/Documentation/devicetree/bindings/net/davinci_emac.txt
index 48b259e29e87..bad381faf036 100644
--- a/Documentation/devicetree/bindings/net/davinci_emac.txt
+++ b/Documentation/devicetree/bindings/net/davinci_emac.txt
@@ -4,7 +4,7 @@ This file provides information, what the device node
4for the davinci_emac interface contains. 4for the davinci_emac interface contains.
5 5
6Required properties: 6Required properties:
7- compatible: "ti,davinci-dm6467-emac"; 7- compatible: "ti,davinci-dm6467-emac" or "ti,am3517-emac"
8- reg: Offset and length of the register set for the device 8- reg: Offset and length of the register set for the device
9- ti,davinci-ctrl-reg-offset: offset to control register 9- ti,davinci-ctrl-reg-offset: offset to control register
10- ti,davinci-ctrl-mod-reg-offset: offset to control module register 10- ti,davinci-ctrl-mod-reg-offset: offset to control module register
diff --git a/Documentation/devicetree/bindings/net/smsc-lan91c111.txt b/Documentation/devicetree/bindings/net/smsc-lan91c111.txt
index 953049b4248a..5a41a8658daa 100644
--- a/Documentation/devicetree/bindings/net/smsc-lan91c111.txt
+++ b/Documentation/devicetree/bindings/net/smsc-lan91c111.txt
@@ -8,3 +8,7 @@ Required properties:
8Optional properties: 8Optional properties:
9- phy-device : phandle to Ethernet phy 9- phy-device : phandle to Ethernet phy
10- local-mac-address : Ethernet mac address to use 10- local-mac-address : Ethernet mac address to use
11- reg-io-width : Mask of sizes (in bytes) of the IO accesses that
12 are supported on the device. Valid value for SMSC LAN91c111 are
13 1, 2 or 4. If it's omitted or invalid, the size would be 2 meaning
14 16-bit access only.
diff --git a/Documentation/devicetree/bindings/nvec/nvidia,nvec.txt b/Documentation/devicetree/bindings/nvec/nvidia,nvec.txt
index 5aeee53ff9f4..5ae601e7f51f 100644
--- a/Documentation/devicetree/bindings/nvec/nvidia,nvec.txt
+++ b/Documentation/devicetree/bindings/nvec/nvidia,nvec.txt
@@ -7,3 +7,15 @@ Required properties:
7- clock-frequency : the frequency of the i2c bus 7- clock-frequency : the frequency of the i2c bus
8- gpios : the gpio used for ec request 8- gpios : the gpio used for ec request
9- slave-addr: the i2c address of the slave controller 9- slave-addr: the i2c address of the slave controller
10- clocks : Must contain an entry for each entry in clock-names.
11 See ../clocks/clock-bindings.txt for details.
12- clock-names : Must include the following entries:
13 Tegra20/Tegra30:
14 - div-clk
15 - fast-clk
16 Tegra114:
17 - div-clk
18- resets : Must contain an entry for each entry in reset-names.
19 See ../reset/reset.txt for details.
20- reset-names : Must include the following entries:
21 - i2c
diff --git a/Documentation/devicetree/bindings/pci/nvidia,tegra20-pcie.txt b/Documentation/devicetree/bindings/pci/nvidia,tegra20-pcie.txt
index 6b7510775c50..24cee06915c9 100644
--- a/Documentation/devicetree/bindings/pci/nvidia,tegra20-pcie.txt
+++ b/Documentation/devicetree/bindings/pci/nvidia,tegra20-pcie.txt
@@ -42,14 +42,19 @@ Required properties:
42 - 0xc2000000: prefetchable memory region 42 - 0xc2000000: prefetchable memory region
43 Please refer to the standard PCI bus binding document for a more detailed 43 Please refer to the standard PCI bus binding document for a more detailed
44 explanation. 44 explanation.
45- clocks: List of clock inputs of the controller. Must contain an entry for 45- clocks: Must contain an entry for each entry in clock-names.
46 each entry in the clock-names property. 46 See ../clocks/clock-bindings.txt for details.
47- clock-names: Must include the following entries: 47- clock-names: Must include the following entries:
48 "pex": The Tegra clock of that name 48 - pex
49 "afi": The Tegra clock of that name 49 - afi
50 "pcie_xclk": The Tegra clock of that name 50 - pll_e
51 "pll_e": The Tegra clock of that name 51 - cml (not required for Tegra20)
52 "cml": The Tegra clock of that name (not required for Tegra20) 52- resets: Must contain an entry for each entry in reset-names.
53 See ../reset/reset.txt for details.
54- reset-names: Must include the following entries:
55 - pex
56 - afi
57 - pcie_x
53 58
54Root ports are defined as subnodes of the PCIe controller node. 59Root ports are defined as subnodes of the PCIe controller node.
55 60
@@ -91,9 +96,10 @@ SoC DTSI:
91 0x82000000 0 0xa0000000 0xa0000000 0 0x10000000 /* non-prefetchable memory */ 96 0x82000000 0 0xa0000000 0xa0000000 0 0x10000000 /* non-prefetchable memory */
92 0xc2000000 0 0xb0000000 0xb0000000 0 0x10000000>; /* prefetchable memory */ 97 0xc2000000 0 0xb0000000 0xb0000000 0 0x10000000>; /* prefetchable memory */
93 98
94 clocks = <&tegra_car 70>, <&tegra_car 72>, <&tegra_car 74>, 99 clocks = <&tegra_car 70>, <&tegra_car 72>, <&tegra_car 118>;
95 <&tegra_car 118>; 100 clock-names = "pex", "afi", "pll_e";
96 clock-names = "pex", "afi", "pcie_xclk", "pll_e"; 101 resets = <&tegra_car 70>, <&tegra_car 72>, <&tegra_car 74>;
102 reset-names = "pex", "afi", "pcie_x";
97 status = "disabled"; 103 status = "disabled";
98 104
99 pci@1,0 { 105 pci@1,0 {
diff --git a/Documentation/devicetree/bindings/pwm/nvidia,tegra20-pwm.txt b/Documentation/devicetree/bindings/pwm/nvidia,tegra20-pwm.txt
index c3fc57af8772..c7ea9d4a988b 100644
--- a/Documentation/devicetree/bindings/pwm/nvidia,tegra20-pwm.txt
+++ b/Documentation/devicetree/bindings/pwm/nvidia,tegra20-pwm.txt
@@ -7,6 +7,12 @@ Required properties:
7- reg: physical base address and length of the controller's registers 7- reg: physical base address and length of the controller's registers
8- #pwm-cells: should be 2. See pwm.txt in this directory for a description of 8- #pwm-cells: should be 2. See pwm.txt in this directory for a description of
9 the cells format. 9 the cells format.
10- clocks: Must contain one entry, for the module clock.
11 See ../clocks/clock-bindings.txt for details.
12- resets: Must contain an entry for each entry in reset-names.
13 See ../reset/reset.txt for details.
14- reset-names: Must include the following entries:
15 - pwm
10 16
11Example: 17Example:
12 18
@@ -14,4 +20,7 @@ Example:
14 compatible = "nvidia,tegra20-pwm"; 20 compatible = "nvidia,tegra20-pwm";
15 reg = <0x7000a000 0x100>; 21 reg = <0x7000a000 0x100>;
16 #pwm-cells = <2>; 22 #pwm-cells = <2>;
23 clocks = <&tegra_car 17>;
24 resets = <&tegra_car 17>;
25 reset-names = "pwm";
17 }; 26 };
diff --git a/Documentation/devicetree/bindings/rtc/nvidia,tegra20-rtc.txt b/Documentation/devicetree/bindings/rtc/nvidia,tegra20-rtc.txt
index 93f45e9dce7c..652d1ff2e8be 100644
--- a/Documentation/devicetree/bindings/rtc/nvidia,tegra20-rtc.txt
+++ b/Documentation/devicetree/bindings/rtc/nvidia,tegra20-rtc.txt
@@ -9,6 +9,8 @@ Required properties:
9- compatible : should be "nvidia,tegra20-rtc". 9- compatible : should be "nvidia,tegra20-rtc".
10- reg : Specifies base physical address and size of the registers. 10- reg : Specifies base physical address and size of the registers.
11- interrupts : A single interrupt specifier. 11- interrupts : A single interrupt specifier.
12- clocks : Must contain one entry, for the module clock.
13 See ../clocks/clock-bindings.txt for details.
12 14
13Example: 15Example:
14 16
@@ -16,4 +18,5 @@ timer {
16 compatible = "nvidia,tegra20-rtc"; 18 compatible = "nvidia,tegra20-rtc";
17 reg = <0x7000e000 0x100>; 19 reg = <0x7000e000 0x100>;
18 interrupts = <0 2 0x04>; 20 interrupts = <0 2 0x04>;
21 clocks = <&tegra_car 4>;
19}; 22};
diff --git a/Documentation/devicetree/bindings/serial/nvidia,tegra20-hsuart.txt b/Documentation/devicetree/bindings/serial/nvidia,tegra20-hsuart.txt
index 392a4493eebd..845850caf088 100644
--- a/Documentation/devicetree/bindings/serial/nvidia,tegra20-hsuart.txt
+++ b/Documentation/devicetree/bindings/serial/nvidia,tegra20-hsuart.txt
@@ -4,8 +4,17 @@ Required properties:
4- compatible : should be "nvidia,tegra30-hsuart", "nvidia,tegra20-hsuart". 4- compatible : should be "nvidia,tegra30-hsuart", "nvidia,tegra20-hsuart".
5- reg: Should contain UART controller registers location and length. 5- reg: Should contain UART controller registers location and length.
6- interrupts: Should contain UART controller interrupts. 6- interrupts: Should contain UART controller interrupts.
7- nvidia,dma-request-selector : The Tegra DMA controller's phandle and 7- clocks: Must contain one entry, for the module clock.
8 request selector for this UART controller. 8 See ../clocks/clock-bindings.txt for details.
9- resets : Must contain an entry for each entry in reset-names.
10 See ../reset/reset.txt for details.
11- reset-names : Must include the following entries:
12 - serial
13- dmas : Must contain an entry for each entry in clock-names.
14 See ../dma/dma.txt for details.
15- dma-names : Must include the following entries:
16 - rx
17 - tx
9 18
10Optional properties: 19Optional properties:
11- nvidia,enable-modem-interrupt: Enable modem interrupts. Should be enable 20- nvidia,enable-modem-interrupt: Enable modem interrupts. Should be enable
@@ -18,7 +27,11 @@ serial@70006000 {
18 reg = <0x70006000 0x40>; 27 reg = <0x70006000 0x40>;
19 reg-shift = <2>; 28 reg-shift = <2>;
20 interrupts = <0 36 0x04>; 29 interrupts = <0 36 0x04>;
21 nvidia,dma-request-selector = <&apbdma 8>;
22 nvidia,enable-modem-interrupt; 30 nvidia,enable-modem-interrupt;
31 clocks = <&tegra_car 6>;
32 resets = <&tegra_car 6>;
33 reset-names = "serial";
34 dmas = <&apbdma 8>, <&apbdma 8>;
35 dma-names = "rx", "tx";
23 status = "disabled"; 36 status = "disabled";
24}; 37};
diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-alc5632.txt b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-alc5632.txt
index 8b8903ef0800..57f40f93453e 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-alc5632.txt
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-alc5632.txt
@@ -3,10 +3,11 @@ NVIDIA Tegra audio complex
3Required properties: 3Required properties:
4- compatible : "nvidia,tegra-audio-alc5632" 4- compatible : "nvidia,tegra-audio-alc5632"
5- clocks : Must contain an entry for each entry in clock-names. 5- clocks : Must contain an entry for each entry in clock-names.
6 See ../clocks/clock-bindings.txt for details.
6- clock-names : Must include the following entries: 7- clock-names : Must include the following entries:
7 "pll_a" (The Tegra clock of that name), 8 - pll_a
8 "pll_a_out0" (The Tegra clock of that name), 9 - pll_a_out0
9 "mclk" (The Tegra cdev1/extern1 clock, which feeds the CODEC's mclk) 10 - mclk (The Tegra cdev1/extern1 clock, which feeds the CODEC's mclk)
10- nvidia,model : The user-visible name of this sound complex. 11- nvidia,model : The user-visible name of this sound complex.
11- nvidia,audio-routing : A list of the connections between audio components. 12- nvidia,audio-routing : A list of the connections between audio components.
12 Each entry is a pair of strings, the first being the connection's sink, 13 Each entry is a pair of strings, the first being the connection's sink,
diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-rt5640.txt b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-rt5640.txt
index dc6224994d69..7788808dcd0b 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-rt5640.txt
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-rt5640.txt
@@ -3,10 +3,11 @@ NVIDIA Tegra audio complex, with RT5640 CODEC
3Required properties: 3Required properties:
4- compatible : "nvidia,tegra-audio-rt5640" 4- compatible : "nvidia,tegra-audio-rt5640"
5- clocks : Must contain an entry for each entry in clock-names. 5- clocks : Must contain an entry for each entry in clock-names.
6 See ../clocks/clock-bindings.txt for details.
6- clock-names : Must include the following entries: 7- clock-names : Must include the following entries:
7 "pll_a" (The Tegra clock of that name), 8 - pll_a
8 "pll_a_out0" (The Tegra clock of that name), 9 - pll_a_out0
9 "mclk" (The Tegra cdev1/extern1 clock, which feeds the CODEC's mclk) 10 - mclk (The Tegra cdev1/extern1 clock, which feeds the CODEC's mclk)
10- nvidia,model : The user-visible name of this sound complex. 11- nvidia,model : The user-visible name of this sound complex.
11- nvidia,audio-routing : A list of the connections between audio components. 12- nvidia,audio-routing : A list of the connections between audio components.
12 Each entry is a pair of strings, the first being the connection's sink, 13 Each entry is a pair of strings, the first being the connection's sink,
diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-wm8753.txt b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-wm8753.txt
index aab6ce0ad2fc..96f6a57dd6b4 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-wm8753.txt
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-wm8753.txt
@@ -3,10 +3,11 @@ NVIDIA Tegra audio complex
3Required properties: 3Required properties:
4- compatible : "nvidia,tegra-audio-wm8753" 4- compatible : "nvidia,tegra-audio-wm8753"
5- clocks : Must contain an entry for each entry in clock-names. 5- clocks : Must contain an entry for each entry in clock-names.
6 See ../clocks/clock-bindings.txt for details.
6- clock-names : Must include the following entries: 7- clock-names : Must include the following entries:
7 "pll_a" (The Tegra clock of that name), 8 - pll_a
8 "pll_a_out0" (The Tegra clock of that name), 9 - pll_a_out0
9 "mclk" (The Tegra cdev1/extern1 clock, which feeds the CODEC's mclk) 10 - mclk (The Tegra cdev1/extern1 clock, which feeds the CODEC's mclk)
10- nvidia,model : The user-visible name of this sound complex. 11- nvidia,model : The user-visible name of this sound complex.
11- nvidia,audio-routing : A list of the connections between audio components. 12- nvidia,audio-routing : A list of the connections between audio components.
12 Each entry is a pair of strings, the first being the connection's sink, 13 Each entry is a pair of strings, the first being the connection's sink,
diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-wm8903.txt b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-wm8903.txt
index 4b44dfb6ca0d..b795d282818d 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-wm8903.txt
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-wm8903.txt
@@ -3,10 +3,11 @@ NVIDIA Tegra audio complex
3Required properties: 3Required properties:
4- compatible : "nvidia,tegra-audio-wm8903" 4- compatible : "nvidia,tegra-audio-wm8903"
5- clocks : Must contain an entry for each entry in clock-names. 5- clocks : Must contain an entry for each entry in clock-names.
6 See ../clocks/clock-bindings.txt for details.
6- clock-names : Must include the following entries: 7- clock-names : Must include the following entries:
7 "pll_a" (The Tegra clock of that name), 8 - pll_a
8 "pll_a_out0" (The Tegra clock of that name), 9 - pll_a_out0
9 "mclk" (The Tegra cdev1/extern1 clock, which feeds the CODEC's mclk) 10 - mclk (The Tegra cdev1/extern1 clock, which feeds the CODEC's mclk)
10- nvidia,model : The user-visible name of this sound complex. 11- nvidia,model : The user-visible name of this sound complex.
11- nvidia,audio-routing : A list of the connections between audio components. 12- nvidia,audio-routing : A list of the connections between audio components.
12 Each entry is a pair of strings, the first being the connection's sink, 13 Each entry is a pair of strings, the first being the connection's sink,
diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-wm9712.txt b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-wm9712.txt
index ad589b163639..436f6cd9d07c 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-wm9712.txt
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-wm9712.txt
@@ -3,10 +3,11 @@ NVIDIA Tegra audio complex
3Required properties: 3Required properties:
4- compatible : "nvidia,tegra-audio-wm9712" 4- compatible : "nvidia,tegra-audio-wm9712"
5- clocks : Must contain an entry for each entry in clock-names. 5- clocks : Must contain an entry for each entry in clock-names.
6 See ../clocks/clock-bindings.txt for details.
6- clock-names : Must include the following entries: 7- clock-names : Must include the following entries:
7 "pll_a" (The Tegra clock of that name), 8 - pll_a
8 "pll_a_out0" (The Tegra clock of that name), 9 - pll_a_out0
9 "mclk" (The Tegra cdev1/extern1 clock, which feeds the CODEC's mclk) 10 - mclk (The Tegra cdev1/extern1 clock, which feeds the CODEC's mclk)
10- nvidia,model : The user-visible name of this sound complex. 11- nvidia,model : The user-visible name of this sound complex.
11- nvidia,audio-routing : A list of the connections between audio components. 12- nvidia,audio-routing : A list of the connections between audio components.
12 Each entry is a pair of strings, the first being the connection's sink, 13 Each entry is a pair of strings, the first being the connection's sink,
diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra20-ac97.txt b/Documentation/devicetree/bindings/sound/nvidia,tegra20-ac97.txt
index c1454979c1ef..eaf00102d92c 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra20-ac97.txt
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra20-ac97.txt
@@ -4,19 +4,33 @@ Required properties:
4- compatible : "nvidia,tegra20-ac97" 4- compatible : "nvidia,tegra20-ac97"
5- reg : Should contain AC97 controller registers location and length 5- reg : Should contain AC97 controller registers location and length
6- interrupts : Should contain AC97 interrupt 6- interrupts : Should contain AC97 interrupt
7- nvidia,dma-request-selector : The Tegra DMA controller's phandle and 7- resets : Must contain an entry for each entry in reset-names.
8 request selector for the AC97 controller 8 See ../reset/reset.txt for details.
9- reset-names : Must include the following entries:
10 - ac97
11- dmas : Must contain an entry for each entry in clock-names.
12 See ../dma/dma.txt for details.
13- dma-names : Must include the following entries:
14 - rx
15 - tx
16- clocks : Must contain one entry, for the module clock.
17 See ../clocks/clock-bindings.txt for details.
9- nvidia,codec-reset-gpio : The Tegra GPIO controller's phandle and the number 18- nvidia,codec-reset-gpio : The Tegra GPIO controller's phandle and the number
10 of the GPIO used to reset the external AC97 codec 19 of the GPIO used to reset the external AC97 codec
11- nvidia,codec-sync-gpio : The Tegra GPIO controller's phandle and the number 20- nvidia,codec-sync-gpio : The Tegra GPIO controller's phandle and the number
12 of the GPIO corresponding with the AC97 DAP _FS line 21 of the GPIO corresponding with the AC97 DAP _FS line
22
13Example: 23Example:
14 24
15ac97@70002000 { 25ac97@70002000 {
16 compatible = "nvidia,tegra20-ac97"; 26 compatible = "nvidia,tegra20-ac97";
17 reg = <0x70002000 0x200>; 27 reg = <0x70002000 0x200>;
18 interrupts = <0 81 0x04>; 28 interrupts = <0 81 0x04>;
19 nvidia,dma-request-selector = <&apbdma 12>;
20 nvidia,codec-reset-gpio = <&gpio 170 0>; 29 nvidia,codec-reset-gpio = <&gpio 170 0>;
21 nvidia,codec-sync-gpio = <&gpio 120 0>; 30 nvidia,codec-sync-gpio = <&gpio 120 0>;
31 clocks = <&tegra_car 3>;
32 resets = <&tegra_car 3>;
33 reset-names = "ac97";
34 dmas = <&apbdma 12>, <&apbdma 12>;
35 dma-names = "rx", "tx";
22}; 36};
diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra20-i2s.txt b/Documentation/devicetree/bindings/sound/nvidia,tegra20-i2s.txt
index 0df2b5c816e3..dc30c6bfbe95 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra20-i2s.txt
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra20-i2s.txt
@@ -4,8 +4,17 @@ Required properties:
4- compatible : "nvidia,tegra20-i2s" 4- compatible : "nvidia,tegra20-i2s"
5- reg : Should contain I2S registers location and length 5- reg : Should contain I2S registers location and length
6- interrupts : Should contain I2S interrupt 6- interrupts : Should contain I2S interrupt
7- nvidia,dma-request-selector : The Tegra DMA controller's phandle and 7- resets : Must contain an entry for each entry in reset-names.
8 request selector for this I2S controller 8 See ../reset/reset.txt for details.
9- reset-names : Must include the following entries:
10 - i2s
11- dmas : Must contain an entry for each entry in clock-names.
12 See ../dma/dma.txt for details.
13- dma-names : Must include the following entries:
14 - rx
15 - tx
16- clocks : Must contain one entry, for the module clock.
17 See ../clocks/clock-bindings.txt for details.
9 18
10Example: 19Example:
11 20
@@ -13,5 +22,9 @@ i2s@70002800 {
13 compatible = "nvidia,tegra20-i2s"; 22 compatible = "nvidia,tegra20-i2s";
14 reg = <0x70002800 0x200>; 23 reg = <0x70002800 0x200>;
15 interrupts = < 45 >; 24 interrupts = < 45 >;
16 nvidia,dma-request-selector = < &apbdma 2 >; 25 clocks = <&tegra_car 11>;
26 resets = <&tegra_car 11>;
27 reset-names = "i2s";
28 dmas = <&apbdma 21>, <&apbdma 21>;
29 dma-names = "rx", "tx";
17}; 30};
diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra30-ahub.txt b/Documentation/devicetree/bindings/sound/nvidia,tegra30-ahub.txt
index 0e5c12c66523..946e2ac46091 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra30-ahub.txt
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra30-ahub.txt
@@ -7,18 +7,48 @@ Required properties:
7 - Tegra30 requires 2 entries, for the APBIF and AHUB/AUDIO register blocks. 7 - Tegra30 requires 2 entries, for the APBIF and AHUB/AUDIO register blocks.
8 - Tegra114 requires an additional entry, for the APBIF2 register block. 8 - Tegra114 requires an additional entry, for the APBIF2 register block.
9- interrupts : Should contain AHUB interrupt 9- interrupts : Should contain AHUB interrupt
10- nvidia,dma-request-selector : A list of the DMA channel specifiers. Each 10- clocks : Must contain an entry for each entry in clock-names.
11 entry contains the Tegra DMA controller's phandle and request selector. 11 See ../clocks/clock-bindings.txt for details.
12 If a single entry is present, the request selectors for the channels are
13 assumed to be contiguous, and increment from this value.
14 If multiple values are given, one value must be given per channel.
15- clocks : Must contain an entry for each required entry in clock-names.
16- clock-names : Must include the following entries: 12- clock-names : Must include the following entries:
17 - Tegra30: Requires d_audio, apbif, i2s0, i2s1, i2s2, i2s3, i2s4, dam0, 13 - d_audio
18 dam1, dam2, spdif_in. 14 - apbif
19 - Tegra114: Additionally requires amx, adx. 15- resets : Must contain an entry for each entry in reset-names.
16 See ../reset/reset.txt for details.
17- reset-names : Must include the following entries:
18 Tegra30 and later:
19 - d_audio
20 - apbif
21 - i2s0
22 - i2s1
23 - i2s2
24 - i2s3
25 - i2s4
26 - dam0
27 - dam1
28 - dam2
29 - spdif
30 Tegra114 and later additionally require:
31 - amx
32 - adx
33 Tegra124 and later additionally require:
34 - amx1
35 - adx1
36 - afc0
37 - afc1
38 - afc2
39 - afc3
40 - afc4
41 - afc5
20- ranges : The bus address mapping for the configlink register bus. 42- ranges : The bus address mapping for the configlink register bus.
21 Can be empty since the mapping is 1:1. 43 Can be empty since the mapping is 1:1.
44- dmas : Must contain an entry for each entry in clock-names.
45 See ../dma/dma.txt for details.
46- dma-names : Must include the following entries:
47 - rx0 .. rx<n>
48 - tx0 .. tx<n>
49 ... where n is:
50 Tegra30: 3
51 Tegra114, Tegra124: 9
22- #address-cells : For the configlink bus. Should be <1>; 52- #address-cells : For the configlink bus. Should be <1>;
23- #size-cells : For the configlink bus. Should be <1>. 53- #size-cells : For the configlink bus. Should be <1>.
24 54
@@ -35,13 +65,20 @@ ahub@70080000 {
35 reg = <0x70080000 0x200 0x70080200 0x100>; 65 reg = <0x70080000 0x200 0x70080200 0x100>;
36 interrupts = < 0 103 0x04 >; 66 interrupts = < 0 103 0x04 >;
37 nvidia,dma-request-selector = <&apbdma 1>; 67 nvidia,dma-request-selector = <&apbdma 1>;
38 clocks = <&tegra_car 106>, <&tegra_car 107>, <&tegra_car 30>, 68 clocks = <&tegra_car 106>, <&tegra_car 107>;
69 clock-names = "d_audio", "apbif";
70 resets = <&tegra_car 106>, <&tegra_car 107>, <&tegra_car 30>,
39 <&tegra_car 11>, <&tegra_car 18>, <&tegra_car 101>, 71 <&tegra_car 11>, <&tegra_car 18>, <&tegra_car 101>,
40 <&tegra_car 102>, <&tegra_car 108>, <&tegra_car 109>, 72 <&tegra_car 102>, <&tegra_car 108>, <&tegra_car 109>,
41 <&tegra_car 110>, <&tegra_car 162>; 73 <&tegra_car 110>, <&tegra_car 10>;
42 clock-names = "d_audio", "apbif", "i2s0", "i2s1", "i2s2", 74 reset-names = "d_audio", "apbif", "i2s0", "i2s1", "i2s2",
43 "i2s3", "i2s4", "dam0", "dam1", "dam2", 75 "i2s3", "i2s4", "dam0", "dam1", "dam2",
44 "spdif_in"; 76 "spdif";
77 dmas = <&apbdma 1>, <&apbdma 1>;
78 <&apbdma 2>, <&apbdma 2>;
79 <&apbdma 3>, <&apbdma 3>;
80 <&apbdma 4>, <&apbdma 4>;
81 dma-names = "rx0", "tx0", "rx1", "tx1", "rx2", "tx2", "rx3", "tx3";
45 ranges; 82 ranges;
46 #address-cells = <1>; 83 #address-cells = <1>;
47 #size-cells = <1>; 84 #size-cells = <1>;
diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra30-i2s.txt b/Documentation/devicetree/bindings/sound/nvidia,tegra30-i2s.txt
index dfa6c037124a..0c113ffe3814 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra30-i2s.txt
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra30-i2s.txt
@@ -3,13 +3,22 @@ NVIDIA Tegra30 I2S controller
3Required properties: 3Required properties:
4- compatible : "nvidia,tegra30-i2s" 4- compatible : "nvidia,tegra30-i2s"
5- reg : Should contain I2S registers location and length 5- reg : Should contain I2S registers location and length
6- clocks : Must contain one entry, for the module clock.
7 See ../clocks/clock-bindings.txt for details.
8- resets : Must contain an entry for each entry in reset-names.
9 See ../reset/reset.txt for details.
10- reset-names : Must include the following entries:
11 - i2s
6- nvidia,ahub-cif-ids : The list of AHUB CIF IDs for this port, rx (playback) 12- nvidia,ahub-cif-ids : The list of AHUB CIF IDs for this port, rx (playback)
7 first, tx (capture) second. See nvidia,tegra30-ahub.txt for values. 13 first, tx (capture) second. See nvidia,tegra30-ahub.txt for values.
8 14
9Example: 15Example:
10 16
11i2s@70002800 { 17i2s@70080300 {
12 compatible = "nvidia,tegra30-i2s"; 18 compatible = "nvidia,tegra30-i2s";
13 reg = <0x70080300 0x100>; 19 reg = <0x70080300 0x100>;
14 nvidia,ahub-cif-ids = <4 4>; 20 nvidia,ahub-cif-ids = <4 4>;
21 clocks = <&tegra_car 11>;
22 resets = <&tegra_car 11>;
23 reset-names = "i2s";
15}; 24};
diff --git a/Documentation/devicetree/bindings/spi/nvidia,tegra114-spi.txt b/Documentation/devicetree/bindings/spi/nvidia,tegra114-spi.txt
index 91ff771c7e77..7ea701e07dc2 100644
--- a/Documentation/devicetree/bindings/spi/nvidia,tegra114-spi.txt
+++ b/Documentation/devicetree/bindings/spi/nvidia,tegra114-spi.txt
@@ -4,10 +4,19 @@ Required properties:
4- compatible : should be "nvidia,tegra114-spi". 4- compatible : should be "nvidia,tegra114-spi".
5- reg: Should contain SPI registers location and length. 5- reg: Should contain SPI registers location and length.
6- interrupts: Should contain SPI interrupts. 6- interrupts: Should contain SPI interrupts.
7- nvidia,dma-request-selector : The Tegra DMA controller's phandle and 7- clock-names : Must include the following entries:
8 request selector for this SPI controller. 8 - spi
9- This is also require clock named "spi" as per binding document 9- resets : Must contain an entry for each entry in reset-names.
10 Documentation/devicetree/bindings/clock/clock-bindings.txt 10 See ../reset/reset.txt for details.
11- reset-names : Must include the following entries:
12 - spi
13- dmas : Must contain an entry for each entry in clock-names.
14 See ../dma/dma.txt for details.
15- dma-names : Must include the following entries:
16 - rx
17 - tx
18- clocks : Must contain an entry for each entry in clock-names.
19 See ../clocks/clock-bindings.txt for details.
11 20
12Recommended properties: 21Recommended properties:
13- spi-max-frequency: Definition as per 22- spi-max-frequency: Definition as per
@@ -18,9 +27,14 @@ spi@7000d600 {
18 compatible = "nvidia,tegra114-spi"; 27 compatible = "nvidia,tegra114-spi";
19 reg = <0x7000d600 0x200>; 28 reg = <0x7000d600 0x200>;
20 interrupts = <0 82 0x04>; 29 interrupts = <0 82 0x04>;
21 nvidia,dma-request-selector = <&apbdma 16>;
22 spi-max-frequency = <25000000>; 30 spi-max-frequency = <25000000>;
23 #address-cells = <1>; 31 #address-cells = <1>;
24 #size-cells = <0>; 32 #size-cells = <0>;
33 clocks = <&tegra_car 44>;
34 clock-names = "spi";
35 resets = <&tegra_car 44>;
36 reset-names = "spi";
37 dmas = <&apbdma 16>, <&apbdma 16>;
38 dma-names = "rx", "tx";
25 status = "disabled"; 39 status = "disabled";
26}; 40};
diff --git a/Documentation/devicetree/bindings/spi/nvidia,tegra20-sflash.txt b/Documentation/devicetree/bindings/spi/nvidia,tegra20-sflash.txt
index 7b53da5cb75b..bdf08e6dec9b 100644
--- a/Documentation/devicetree/bindings/spi/nvidia,tegra20-sflash.txt
+++ b/Documentation/devicetree/bindings/spi/nvidia,tegra20-sflash.txt
@@ -4,8 +4,17 @@ Required properties:
4- compatible : should be "nvidia,tegra20-sflash". 4- compatible : should be "nvidia,tegra20-sflash".
5- reg: Should contain SFLASH registers location and length. 5- reg: Should contain SFLASH registers location and length.
6- interrupts: Should contain SFLASH interrupts. 6- interrupts: Should contain SFLASH interrupts.
7- nvidia,dma-request-selector : The Tegra DMA controller's phandle and 7- clocks : Must contain one entry, for the module clock.
8 request selector for this SFLASH controller. 8 See ../clocks/clock-bindings.txt for details.
9- resets : Must contain an entry for each entry in reset-names.
10 See ../reset/reset.txt for details.
11- reset-names : Must include the following entries:
12 - spi
13- dmas : Must contain an entry for each entry in clock-names.
14 See ../dma/dma.txt for details.
15- dma-names : Must include the following entries:
16 - rx
17 - tx
9 18
10Recommended properties: 19Recommended properties:
11- spi-max-frequency: Definition as per 20- spi-max-frequency: Definition as per
@@ -17,10 +26,13 @@ spi@7000c380 {
17 compatible = "nvidia,tegra20-sflash"; 26 compatible = "nvidia,tegra20-sflash";
18 reg = <0x7000c380 0x80>; 27 reg = <0x7000c380 0x80>;
19 interrupts = <0 39 0x04>; 28 interrupts = <0 39 0x04>;
20 nvidia,dma-request-selector = <&apbdma 16>;
21 spi-max-frequency = <25000000>; 29 spi-max-frequency = <25000000>;
22 #address-cells = <1>; 30 #address-cells = <1>;
23 #size-cells = <0>; 31 #size-cells = <0>;
32 clocks = <&tegra_car 43>;
33 resets = <&tegra_car 43>;
34 reset-names = "spi";
35 dmas = <&apbdma 11>, <&apbdma 11>;
36 dma-names = "rx", "tx";
24 status = "disabled"; 37 status = "disabled";
25}; 38};
26
diff --git a/Documentation/devicetree/bindings/spi/nvidia,tegra20-slink.txt b/Documentation/devicetree/bindings/spi/nvidia,tegra20-slink.txt
index eefe15e3d95e..5db9144a33c8 100644
--- a/Documentation/devicetree/bindings/spi/nvidia,tegra20-slink.txt
+++ b/Documentation/devicetree/bindings/spi/nvidia,tegra20-slink.txt
@@ -4,8 +4,17 @@ Required properties:
4- compatible : should be "nvidia,tegra20-slink", "nvidia,tegra30-slink". 4- compatible : should be "nvidia,tegra20-slink", "nvidia,tegra30-slink".
5- reg: Should contain SLINK registers location and length. 5- reg: Should contain SLINK registers location and length.
6- interrupts: Should contain SLINK interrupts. 6- interrupts: Should contain SLINK interrupts.
7- nvidia,dma-request-selector : The Tegra DMA controller's phandle and 7- clocks : Must contain one entry, for the module clock.
8 request selector for this SLINK controller. 8 See ../clocks/clock-bindings.txt for details.
9- resets : Must contain an entry for each entry in reset-names.
10 See ../reset/reset.txt for details.
11- reset-names : Must include the following entries:
12 - spi
13- dmas : Must contain an entry for each entry in clock-names.
14 See ../dma/dma.txt for details.
15- dma-names : Must include the following entries:
16 - rx
17 - tx
9 18
10Recommended properties: 19Recommended properties:
11- spi-max-frequency: Definition as per 20- spi-max-frequency: Definition as per
@@ -17,10 +26,13 @@ spi@7000d600 {
17 compatible = "nvidia,tegra20-slink"; 26 compatible = "nvidia,tegra20-slink";
18 reg = <0x7000d600 0x200>; 27 reg = <0x7000d600 0x200>;
19 interrupts = <0 82 0x04>; 28 interrupts = <0 82 0x04>;
20 nvidia,dma-request-selector = <&apbdma 16>;
21 spi-max-frequency = <25000000>; 29 spi-max-frequency = <25000000>;
22 #address-cells = <1>; 30 #address-cells = <1>;
23 #size-cells = <0>; 31 #size-cells = <0>;
32 clocks = <&tegra_car 44>;
33 resets = <&tegra_car 44>;
34 reset-names = "spi";
35 dmas = <&apbdma 16>, <&apbdma 16>;
36 dma-names = "rx", "tx";
24 status = "disabled"; 37 status = "disabled";
25}; 38};
26
diff --git a/Documentation/devicetree/bindings/timer/nvidia,tegra20-timer.txt b/Documentation/devicetree/bindings/timer/nvidia,tegra20-timer.txt
index e019fdc38773..4a864bd10d3d 100644
--- a/Documentation/devicetree/bindings/timer/nvidia,tegra20-timer.txt
+++ b/Documentation/devicetree/bindings/timer/nvidia,tegra20-timer.txt
@@ -8,6 +8,8 @@ Required properties:
8- compatible : should be "nvidia,tegra20-timer". 8- compatible : should be "nvidia,tegra20-timer".
9- reg : Specifies base physical address and size of the registers. 9- reg : Specifies base physical address and size of the registers.
10- interrupts : A list of 4 interrupts; one per timer channel. 10- interrupts : A list of 4 interrupts; one per timer channel.
11- clocks : Must contain one entry, for the module clock.
12 See ../clocks/clock-bindings.txt for details.
11 13
12Example: 14Example:
13 15
@@ -18,4 +20,5 @@ timer {
18 0 1 0x04 20 0 1 0x04
19 0 41 0x04 21 0 41 0x04
20 0 42 0x04>; 22 0 42 0x04>;
23 clocks = <&tegra_car 132>;
21}; 24};
diff --git a/Documentation/devicetree/bindings/timer/nvidia,tegra30-timer.txt b/Documentation/devicetree/bindings/timer/nvidia,tegra30-timer.txt
index 906109d4c593..b5082a1cf461 100644
--- a/Documentation/devicetree/bindings/timer/nvidia,tegra30-timer.txt
+++ b/Documentation/devicetree/bindings/timer/nvidia,tegra30-timer.txt
@@ -10,6 +10,8 @@ Required properties:
10- reg : Specifies base physical address and size of the registers. 10- reg : Specifies base physical address and size of the registers.
11- interrupts : A list of 6 interrupts; one per each of timer channels 1 11- interrupts : A list of 6 interrupts; one per each of timer channels 1
12 through 5, and one for the shared interrupt for the remaining channels. 12 through 5, and one for the shared interrupt for the remaining channels.
13- clocks : Must contain one entry, for the module clock.
14 See ../clocks/clock-bindings.txt for details.
13 15
14timer { 16timer {
15 compatible = "nvidia,tegra30-timer", "nvidia,tegra20-timer"; 17 compatible = "nvidia,tegra30-timer", "nvidia,tegra20-timer";
@@ -20,4 +22,5 @@ timer {
20 0 42 0x04 22 0 42 0x04
21 0 121 0x04 23 0 121 0x04
22 0 122 0x04>; 24 0 122 0x04>;
25 clocks = <&tegra_car 214>;
23}; 26};
diff --git a/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt b/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt
index df0933043a5b..3dc9140e3dfb 100644
--- a/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt
+++ b/Documentation/devicetree/bindings/usb/nvidia,tegra20-ehci.txt
@@ -8,7 +8,12 @@ and additions :
8Required properties : 8Required properties :
9 - compatible : Should be "nvidia,tegra20-ehci". 9 - compatible : Should be "nvidia,tegra20-ehci".
10 - nvidia,phy : phandle of the PHY that the controller is connected to. 10 - nvidia,phy : phandle of the PHY that the controller is connected to.
11 - clocks : Contains a single entry which defines the USB controller's clock. 11 - clocks : Must contain one entry, for the module clock.
12 See ../clocks/clock-bindings.txt for details.
13 - resets : Must contain an entry for each entry in reset-names.
14 See ../reset/reset.txt for details.
15 - reset-names : Must include the following entries:
16 - usb
12 17
13Optional properties: 18Optional properties:
14 - nvidia,needs-double-reset : boolean is to be set for some of the Tegra20 19 - nvidia,needs-double-reset : boolean is to be set for some of the Tegra20
diff --git a/Documentation/mic/mpssd/mpssd.c b/Documentation/mic/mpssd/mpssd.c
index 0c980ad40b17..4d17487d5ad9 100644
--- a/Documentation/mic/mpssd/mpssd.c
+++ b/Documentation/mic/mpssd/mpssd.c
@@ -313,7 +313,7 @@ static struct mic_device_desc *get_device_desc(struct mic_info *mic, int type)
313 int i; 313 int i;
314 void *dp = get_dp(mic, type); 314 void *dp = get_dp(mic, type);
315 315
316 for (i = mic_aligned_size(struct mic_bootparam); i < PAGE_SIZE; 316 for (i = sizeof(struct mic_bootparam); i < PAGE_SIZE;
317 i += mic_total_desc_size(d)) { 317 i += mic_total_desc_size(d)) {
318 d = dp + i; 318 d = dp + i;
319 319
@@ -445,8 +445,8 @@ init_vr(struct mic_info *mic, int fd, int type,
445 __func__, mic->name, vr0->va, vr0->info, vr_size, 445 __func__, mic->name, vr0->va, vr0->info, vr_size,
446 vring_size(MIC_VRING_ENTRIES, MIC_VIRTIO_RING_ALIGN)); 446 vring_size(MIC_VRING_ENTRIES, MIC_VIRTIO_RING_ALIGN));
447 mpsslog("magic 0x%x expected 0x%x\n", 447 mpsslog("magic 0x%x expected 0x%x\n",
448 vr0->info->magic, MIC_MAGIC + type); 448 le32toh(vr0->info->magic), MIC_MAGIC + type);
449 assert(vr0->info->magic == MIC_MAGIC + type); 449 assert(le32toh(vr0->info->magic) == MIC_MAGIC + type);
450 if (vr1) { 450 if (vr1) {
451 vr1->va = (struct mic_vring *) 451 vr1->va = (struct mic_vring *)
452 &va[MIC_DEVICE_PAGE_END + vr_size]; 452 &va[MIC_DEVICE_PAGE_END + vr_size];
@@ -458,8 +458,8 @@ init_vr(struct mic_info *mic, int fd, int type,
458 __func__, mic->name, vr1->va, vr1->info, vr_size, 458 __func__, mic->name, vr1->va, vr1->info, vr_size,
459 vring_size(MIC_VRING_ENTRIES, MIC_VIRTIO_RING_ALIGN)); 459 vring_size(MIC_VRING_ENTRIES, MIC_VIRTIO_RING_ALIGN));
460 mpsslog("magic 0x%x expected 0x%x\n", 460 mpsslog("magic 0x%x expected 0x%x\n",
461 vr1->info->magic, MIC_MAGIC + type + 1); 461 le32toh(vr1->info->magic), MIC_MAGIC + type + 1);
462 assert(vr1->info->magic == MIC_MAGIC + type + 1); 462 assert(le32toh(vr1->info->magic) == MIC_MAGIC + type + 1);
463 } 463 }
464done: 464done:
465 return va; 465 return va;
@@ -520,7 +520,7 @@ static void *
520virtio_net(void *arg) 520virtio_net(void *arg)
521{ 521{
522 static __u8 vnet_hdr[2][sizeof(struct virtio_net_hdr)]; 522 static __u8 vnet_hdr[2][sizeof(struct virtio_net_hdr)];
523 static __u8 vnet_buf[2][MAX_NET_PKT_SIZE] __aligned(64); 523 static __u8 vnet_buf[2][MAX_NET_PKT_SIZE] __attribute__ ((aligned(64)));
524 struct iovec vnet_iov[2][2] = { 524 struct iovec vnet_iov[2][2] = {
525 { { .iov_base = vnet_hdr[0], .iov_len = sizeof(vnet_hdr[0]) }, 525 { { .iov_base = vnet_hdr[0], .iov_len = sizeof(vnet_hdr[0]) },
526 { .iov_base = vnet_buf[0], .iov_len = sizeof(vnet_buf[0]) } }, 526 { .iov_base = vnet_buf[0], .iov_len = sizeof(vnet_buf[0]) } },
@@ -1412,6 +1412,12 @@ mic_config(void *arg)
1412 } 1412 }
1413 1413
1414 do { 1414 do {
1415 ret = lseek(fd, 0, SEEK_SET);
1416 if (ret < 0) {
1417 mpsslog("%s: Failed to seek to file start '%s': %s\n",
1418 mic->name, pathname, strerror(errno));
1419 goto close_error1;
1420 }
1415 ret = read(fd, value, sizeof(value)); 1421 ret = read(fd, value, sizeof(value));
1416 if (ret < 0) { 1422 if (ret < 0) {
1417 mpsslog("%s: Failed to read sysfs entry '%s': %s\n", 1423 mpsslog("%s: Failed to read sysfs entry '%s': %s\n",
diff --git a/Documentation/networking/packet_mmap.txt b/Documentation/networking/packet_mmap.txt
index c01223628a87..8e48e3b14227 100644
--- a/Documentation/networking/packet_mmap.txt
+++ b/Documentation/networking/packet_mmap.txt
@@ -123,6 +123,16 @@ Transmission process is similar to capture as shown below.
123[shutdown] close() --------> destruction of the transmission socket and 123[shutdown] close() --------> destruction of the transmission socket and
124 deallocation of all associated resources. 124 deallocation of all associated resources.
125 125
126Socket creation and destruction is also straight forward, and is done
127the same way as in capturing described in the previous paragraph:
128
129 int fd = socket(PF_PACKET, mode, 0);
130
131The protocol can optionally be 0 in case we only want to transmit
132via this socket, which avoids an expensive call to packet_rcv().
133In this case, you also need to bind(2) the TX_RING with sll_protocol = 0
134set. Otherwise, htons(ETH_P_ALL) or any other protocol, for example.
135
126Binding the socket to your network interface is mandatory (with zero copy) to 136Binding the socket to your network interface is mandatory (with zero copy) to
127know the header size of frames used in the circular buffer. 137know the header size of frames used in the circular buffer.
128 138
diff --git a/MAINTAINERS b/MAINTAINERS
index 13c15c83a46e..6ea1fb247a8c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -867,6 +867,12 @@ S: Maintained
867F: arch/arm/mach-ebsa110/ 867F: arch/arm/mach-ebsa110/
868F: drivers/net/ethernet/amd/am79c961a.* 868F: drivers/net/ethernet/amd/am79c961a.*
869 869
870ARM/ENERGY MICRO (SILICON LABS) EFM32 SUPPORT
871M: Uwe Kleine-König <kernel@pengutronix.de>
872L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
873S: Maintained
874N: efm32
875
870ARM/EZX SMARTPHONES (A780, A910, A1200, E680, ROKR E2 and ROKR E6) 876ARM/EZX SMARTPHONES (A780, A910, A1200, E680, ROKR E2 and ROKR E6)
871M: Daniel Ribeiro <drwyrm@gmail.com> 877M: Daniel Ribeiro <drwyrm@gmail.com>
872M: Stefan Schmidt <stefan@openezx.org> 878M: Stefan Schmidt <stefan@openezx.org>
@@ -893,20 +899,15 @@ F: arch/arm/include/asm/hardware/dec21285.h
893F: arch/arm/mach-footbridge/ 899F: arch/arm/mach-footbridge/
894 900
895ARM/FREESCALE IMX / MXC ARM ARCHITECTURE 901ARM/FREESCALE IMX / MXC ARM ARCHITECTURE
902M: Shawn Guo <shawn.guo@linaro.org>
896M: Sascha Hauer <kernel@pengutronix.de> 903M: Sascha Hauer <kernel@pengutronix.de>
897L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 904L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
898S: Maintained 905S: Maintained
899T: git git://git.pengutronix.de/git/imx/linux-2.6.git 906T: git git://git.linaro.org/people/shawnguo/linux-2.6.git
900F: arch/arm/mach-imx/ 907F: arch/arm/mach-imx/
908F: arch/arm/boot/dts/imx*
901F: arch/arm/configs/imx*_defconfig 909F: arch/arm/configs/imx*_defconfig
902 910
903ARM/FREESCALE IMX6
904M: Shawn Guo <shawn.guo@linaro.org>
905L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
906S: Maintained
907T: git git://git.linaro.org/people/shawnguo/linux-2.6.git
908F: arch/arm/mach-imx/*imx6*
909
910ARM/FREESCALE MXS ARM ARCHITECTURE 911ARM/FREESCALE MXS ARM ARCHITECTURE
911M: Shawn Guo <shawn.guo@linaro.org> 912M: Shawn Guo <shawn.guo@linaro.org>
912L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 913L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
@@ -1032,6 +1033,12 @@ L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
1032S: Maintained 1033S: Maintained
1033F: arch/arm/mach-mvebu/ 1034F: arch/arm/mach-mvebu/
1034 1035
1036ARM/Marvell Berlin SoC support
1037M: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
1038L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
1039S: Maintained
1040F: arch/arm/mach-berlin/
1041
1035ARM/Marvell Dove/Kirkwood/MV78xx0/Orion SOC support 1042ARM/Marvell Dove/Kirkwood/MV78xx0/Orion SOC support
1036M: Jason Cooper <jason@lakedaemon.net> 1043M: Jason Cooper <jason@lakedaemon.net>
1037M: Andrew Lunn <andrew@lunn.ch> 1044M: Andrew Lunn <andrew@lunn.ch>
@@ -2138,7 +2145,8 @@ S: Maintained
2138F: Documentation/zh_CN/ 2145F: Documentation/zh_CN/
2139 2146
2140CHIPIDEA USB HIGH SPEED DUAL ROLE CONTROLLER 2147CHIPIDEA USB HIGH SPEED DUAL ROLE CONTROLLER
2141M: Alexander Shishkin <alexander.shishkin@linux.intel.com> 2148M: Peter Chen <Peter.Chen@freescale.com>
2149T: git://github.com/hzpeterchen/linux-usb.git
2142L: linux-usb@vger.kernel.org 2150L: linux-usb@vger.kernel.org
2143S: Maintained 2151S: Maintained
2144F: drivers/usb/chipidea/ 2152F: drivers/usb/chipidea/
@@ -4044,6 +4052,14 @@ W: http://artax.karlin.mff.cuni.cz/~mikulas/vyplody/hpfs/index-e.cgi
4044S: Maintained 4052S: Maintained
4045F: fs/hpfs/ 4053F: fs/hpfs/
4046 4054
4055HSI SUBSYSTEM
4056M: Sebastian Reichel <sre@debian.org>
4057S: Maintained
4058F: Documentation/ABI/testing/sysfs-bus-hsi
4059F: drivers/hsi/
4060F: include/linux/hsi/
4061F: include/uapi/linux/hsi/
4062
4047HSO 3G MODEM DRIVER 4063HSO 3G MODEM DRIVER
4048M: Jan Dumon <j.dumon@option.com> 4064M: Jan Dumon <j.dumon@option.com>
4049W: http://www.pharscape.org 4065W: http://www.pharscape.org
@@ -4462,10 +4478,8 @@ M: Bruce Allan <bruce.w.allan@intel.com>
4462M: Carolyn Wyborny <carolyn.wyborny@intel.com> 4478M: Carolyn Wyborny <carolyn.wyborny@intel.com>
4463M: Don Skidmore <donald.c.skidmore@intel.com> 4479M: Don Skidmore <donald.c.skidmore@intel.com>
4464M: Greg Rose <gregory.v.rose@intel.com> 4480M: Greg Rose <gregory.v.rose@intel.com>
4465M: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com>
4466M: Alex Duyck <alexander.h.duyck@intel.com> 4481M: Alex Duyck <alexander.h.duyck@intel.com>
4467M: John Ronciak <john.ronciak@intel.com> 4482M: John Ronciak <john.ronciak@intel.com>
4468M: Tushar Dave <tushar.n.dave@intel.com>
4469L: e1000-devel@lists.sourceforge.net 4483L: e1000-devel@lists.sourceforge.net
4470W: http://www.intel.com/support/feedback.htm 4484W: http://www.intel.com/support/feedback.htm
4471W: http://e1000.sourceforge.net/ 4485W: http://e1000.sourceforge.net/
@@ -6461,19 +6475,52 @@ F: drivers/pci/
6461F: include/linux/pci* 6475F: include/linux/pci*
6462F: arch/x86/pci/ 6476F: arch/x86/pci/
6463 6477
6478PCI DRIVER FOR IMX6
6479M: Richard Zhu <r65037@freescale.com>
6480M: Shawn Guo <shawn.guo@linaro.org>
6481L: linux-pci@vger.kernel.org
6482L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
6483S: Maintained
6484F: drivers/pci/host/*imx6*
6485
6486PCI DRIVER FOR MVEBU (Marvell Armada 370 and Armada XP SOC support)
6487M: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
6488M: Jason Cooper <jason@lakedaemon.net>
6489L: linux-pci@vger.kernel.org
6490L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
6491S: Maintained
6492F: drivers/pci/host/*mvebu*
6493
6464PCI DRIVER FOR NVIDIA TEGRA 6494PCI DRIVER FOR NVIDIA TEGRA
6465M: Thierry Reding <thierry.reding@gmail.com> 6495M: Thierry Reding <thierry.reding@gmail.com>
6466L: linux-tegra@vger.kernel.org 6496L: linux-tegra@vger.kernel.org
6497L: linux-pci@vger.kernel.org
6467S: Supported 6498S: Supported
6468F: Documentation/devicetree/bindings/pci/nvidia,tegra20-pcie.txt 6499F: Documentation/devicetree/bindings/pci/nvidia,tegra20-pcie.txt
6469F: drivers/pci/host/pci-tegra.c 6500F: drivers/pci/host/pci-tegra.c
6470 6501
6502PCI DRIVER FOR RENESAS R-CAR
6503M: Simon Horman <horms@verge.net.au>
6504L: linux-pci@vger.kernel.org
6505L: linux-sh@vger.kernel.org
6506S: Maintained
6507F: drivers/pci/host/*rcar*
6508
6471PCI DRIVER FOR SAMSUNG EXYNOS 6509PCI DRIVER FOR SAMSUNG EXYNOS
6472M: Jingoo Han <jg1.han@samsung.com> 6510M: Jingoo Han <jg1.han@samsung.com>
6473L: linux-pci@vger.kernel.org 6511L: linux-pci@vger.kernel.org
6512L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
6513L: linux-samsung-soc@vger.kernel.org (moderated for non-subscribers)
6474S: Maintained 6514S: Maintained
6475F: drivers/pci/host/pci-exynos.c 6515F: drivers/pci/host/pci-exynos.c
6476 6516
6517PCI DRIVER FOR SYNOPSIS DESIGNWARE
6518M: Mohit Kumar <mohit.kumar@st.com>
6519M: Jingoo Han <jg1.han@samsung.com>
6520L: linux-pci@vger.kernel.org
6521S: Maintained
6522F: drivers/pci/host/*designware*
6523
6477PCMCIA SUBSYSTEM 6524PCMCIA SUBSYSTEM
6478P: Linux PCMCIA Team 6525P: Linux PCMCIA Team
6479L: linux-pcmcia@lists.infradead.org 6526L: linux-pcmcia@lists.infradead.org
diff --git a/Makefile b/Makefile
index 890392f1c7c0..858a147fd836 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 3 1VERSION = 3
2PATCHLEVEL = 13 2PATCHLEVEL = 13
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc3 4EXTRAVERSION = -rc4
5NAME = One Giant Leap for Frogkind 5NAME = One Giant Leap for Frogkind
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index 2ee0c9bfd032..9063ae6553cc 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -8,6 +8,7 @@
8 8
9config ARC 9config ARC
10 def_bool y 10 def_bool y
11 select BUILDTIME_EXTABLE_SORT
11 select CLONE_BACKWARDS 12 select CLONE_BACKWARDS
12 # ARC Busybox based initramfs absolutely relies on DEVTMPFS for /dev 13 # ARC Busybox based initramfs absolutely relies on DEVTMPFS for /dev
13 select DEVTMPFS if !INITRAMFS_SOURCE="" 14 select DEVTMPFS if !INITRAMFS_SOURCE=""
diff --git a/arch/arc/include/uapi/asm/unistd.h b/arch/arc/include/uapi/asm/unistd.h
index 6f30484f34b7..68125dd766c6 100644
--- a/arch/arc/include/uapi/asm/unistd.h
+++ b/arch/arc/include/uapi/asm/unistd.h
@@ -8,6 +8,9 @@
8 8
9/******** no-legacy-syscalls-ABI *******/ 9/******** no-legacy-syscalls-ABI *******/
10 10
11#ifndef _UAPI_ASM_ARC_UNISTD_H
12#define _UAPI_ASM_ARC_UNISTD_H
13
11#define __ARCH_WANT_SYS_EXECVE 14#define __ARCH_WANT_SYS_EXECVE
12#define __ARCH_WANT_SYS_CLONE 15#define __ARCH_WANT_SYS_CLONE
13#define __ARCH_WANT_SYS_VFORK 16#define __ARCH_WANT_SYS_VFORK
@@ -32,3 +35,5 @@ __SYSCALL(__NR_arc_gettls, sys_arc_gettls)
32/* Generic syscall (fs/filesystems.c - lost in asm-generic/unistd.h */ 35/* Generic syscall (fs/filesystems.c - lost in asm-generic/unistd.h */
33#define __NR_sysfs (__NR_arch_specific_syscall + 3) 36#define __NR_sysfs (__NR_arch_specific_syscall + 3)
34__SYSCALL(__NR_sysfs, sys_sysfs) 37__SYSCALL(__NR_sysfs, sys_sysfs)
38
39#endif
diff --git a/arch/arc/kernel/perf_event.c b/arch/arc/kernel/perf_event.c
index e46d81f70979..63177e4cb66d 100644
--- a/arch/arc/kernel/perf_event.c
+++ b/arch/arc/kernel/perf_event.c
@@ -79,9 +79,9 @@ static int arc_pmu_cache_event(u64 config)
79 cache_result = (config >> 16) & 0xff; 79 cache_result = (config >> 16) & 0xff;
80 if (cache_type >= PERF_COUNT_HW_CACHE_MAX) 80 if (cache_type >= PERF_COUNT_HW_CACHE_MAX)
81 return -EINVAL; 81 return -EINVAL;
82 if (cache_type >= PERF_COUNT_HW_CACHE_OP_MAX) 82 if (cache_op >= PERF_COUNT_HW_CACHE_OP_MAX)
83 return -EINVAL; 83 return -EINVAL;
84 if (cache_type >= PERF_COUNT_HW_CACHE_RESULT_MAX) 84 if (cache_result >= PERF_COUNT_HW_CACHE_RESULT_MAX)
85 return -EINVAL; 85 return -EINVAL;
86 86
87 ret = arc_pmu_cache_map[cache_type][cache_op][cache_result]; 87 ret = arc_pmu_cache_map[cache_type][cache_op][cache_result];
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index c1f1a7eee953..5f7f8d59124a 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -410,6 +410,26 @@ config ARCH_EBSA110
410 Ethernet interface, two PCMCIA sockets, two serial ports and a 410 Ethernet interface, two PCMCIA sockets, two serial ports and a
411 parallel port. 411 parallel port.
412 412
413config ARCH_EFM32
414 bool "Energy Micro efm32"
415 depends on !MMU
416 select ARCH_REQUIRE_GPIOLIB
417 select ARM_NVIC
418 # CLKSRC_MMIO is wrong here, but needed until a proper fix is merged,
419 # i.e. CLKSRC_EFM32 selecting CLKSRC_MMIO
420 select CLKSRC_MMIO
421 select CLKSRC_OF
422 select COMMON_CLK
423 select CPU_V7M
424 select GENERIC_CLOCKEVENTS
425 select NO_DMA
426 select NO_IOPORT
427 select SPARSE_IRQ
428 select USE_OF
429 help
430 Support for Energy Micro's (now Silicon Labs) efm32 Giant Gecko
431 processors.
432
413config ARCH_EP93XX 433config ARCH_EP93XX
414 bool "EP93xx-based" 434 bool "EP93xx-based"
415 select ARCH_HAS_HOLES_MEMORYMODEL 435 select ARCH_HAS_HOLES_MEMORYMODEL
@@ -644,8 +664,9 @@ config ARCH_MSM
644 stack and controls some vital subsystems 664 stack and controls some vital subsystems
645 (clock and power control, etc). 665 (clock and power control, etc).
646 666
647config ARCH_SHMOBILE 667config ARCH_SHMOBILE_LEGACY
648 bool "Renesas SH-Mobile / R-Mobile" 668 bool "Renesas SH-Mobile / R-Mobile (non-multiplatform)"
669 select ARCH_SHMOBILE
649 select ARM_PATCH_PHYS_VIRT 670 select ARM_PATCH_PHYS_VIRT
650 select CLKDEV_LOOKUP 671 select CLKDEV_LOOKUP
651 select GENERIC_CLOCKEVENTS 672 select GENERIC_CLOCKEVENTS
@@ -660,7 +681,8 @@ config ARCH_SHMOBILE
660 select PM_GENERIC_DOMAINS if PM 681 select PM_GENERIC_DOMAINS if PM
661 select SPARSE_IRQ 682 select SPARSE_IRQ
662 help 683 help
663 Support for Renesas's SH-Mobile and R-Mobile ARM platforms. 684 Support for Renesas's SH-Mobile and R-Mobile ARM platforms using
685 a non-multiplatform kernel.
664 686
665config ARCH_RPC 687config ARCH_RPC
666 bool "RiscPC" 688 bool "RiscPC"
@@ -727,7 +749,7 @@ config ARCH_S3C64XX
727 select CLKDEV_LOOKUP 749 select CLKDEV_LOOKUP
728 select CLKSRC_SAMSUNG_PWM 750 select CLKSRC_SAMSUNG_PWM
729 select COMMON_CLK 751 select COMMON_CLK
730 select CPU_V6 752 select CPU_V6K
731 select GENERIC_CLOCKEVENTS 753 select GENERIC_CLOCKEVENTS
732 select GPIO_SAMSUNG 754 select GPIO_SAMSUNG
733 select HAVE_S3C2410_I2C if I2C 755 select HAVE_S3C2410_I2C if I2C
@@ -911,6 +933,8 @@ source "arch/arm/mach-bcm/Kconfig"
911 933
912source "arch/arm/mach-bcm2835/Kconfig" 934source "arch/arm/mach-bcm2835/Kconfig"
913 935
936source "arch/arm/mach-berlin/Kconfig"
937
914source "arch/arm/mach-clps711x/Kconfig" 938source "arch/arm/mach-clps711x/Kconfig"
915 939
916source "arch/arm/mach-cns3xxx/Kconfig" 940source "arch/arm/mach-cns3xxx/Kconfig"
@@ -945,6 +969,8 @@ source "arch/arm/mach-ks8695/Kconfig"
945 969
946source "arch/arm/mach-msm/Kconfig" 970source "arch/arm/mach-msm/Kconfig"
947 971
972source "arch/arm/mach-moxart/Kconfig"
973
948source "arch/arm/mach-mv78xx0/Kconfig" 974source "arch/arm/mach-mv78xx0/Kconfig"
949 975
950source "arch/arm/mach-imx/Kconfig" 976source "arch/arm/mach-imx/Kconfig"
@@ -1611,7 +1637,7 @@ config HZ_FIXED
1611 default 200 if ARCH_EBSA110 || ARCH_S3C24XX || ARCH_S5P64X0 || \ 1637 default 200 if ARCH_EBSA110 || ARCH_S3C24XX || ARCH_S5P64X0 || \
1612 ARCH_S5PV210 || ARCH_EXYNOS4 1638 ARCH_S5PV210 || ARCH_EXYNOS4
1613 default AT91_TIMER_HZ if ARCH_AT91 1639 default AT91_TIMER_HZ if ARCH_AT91
1614 default SHMOBILE_TIMER_HZ if ARCH_SHMOBILE 1640 default SHMOBILE_TIMER_HZ if ARCH_SHMOBILE_LEGACY
1615 default 0 1641 default 0
1616 1642
1617choice 1643choice
@@ -1796,10 +1822,10 @@ config ARCH_WANT_GENERAL_HUGETLB
1796source "mm/Kconfig" 1822source "mm/Kconfig"
1797 1823
1798config FORCE_MAX_ZONEORDER 1824config FORCE_MAX_ZONEORDER
1799 int "Maximum zone order" if ARCH_SHMOBILE 1825 int "Maximum zone order" if ARCH_SHMOBILE_LEGACY
1800 range 11 64 if ARCH_SHMOBILE 1826 range 11 64 if ARCH_SHMOBILE_LEGACY
1801 default "12" if SOC_AM33XX 1827 default "12" if SOC_AM33XX
1802 default "9" if SA1111 1828 default "9" if SA1111 || ARCH_EFM32
1803 default "11" 1829 default "11"
1804 help 1830 help
1805 The kernel memory allocator divides physically contiguous memory 1831 The kernel memory allocator divides physically contiguous memory
diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
index df56c7e65a6d..bda94e46e8d6 100644
--- a/arch/arm/Kconfig.debug
+++ b/arch/arm/Kconfig.debug
@@ -94,6 +94,14 @@ choice
94 depends on ARCH_BCM2835 94 depends on ARCH_BCM2835
95 select DEBUG_UART_PL01X 95 select DEBUG_UART_PL01X
96 96
97 config DEBUG_BERLIN_UART
98 bool "Marvell Berlin SoC Debug UART"
99 depends on ARCH_BERLIN
100 select DEBUG_UART_8250
101 help
102 Say Y here if you want kernel low-level debugging support
103 on Marvell Berlin SoC based platforms.
104
97 config DEBUG_CLPS711X_UART1 105 config DEBUG_CLPS711X_UART1
98 bool "Kernel low-level debugging messages via UART1" 106 bool "Kernel low-level debugging messages via UART1"
99 depends on ARCH_CLPS711X 107 depends on ARCH_CLPS711X
@@ -1020,6 +1028,7 @@ config DEBUG_UART_PHYS
1020 default 0xf1012000 if DEBUG_MVEBU_UART_ALTERNATE 1028 default 0xf1012000 if DEBUG_MVEBU_UART_ALTERNATE
1021 default 0xf1012000 if ARCH_DOVE || ARCH_KIRKWOOD || ARCH_MV78XX0 || \ 1029 default 0xf1012000 if ARCH_DOVE || ARCH_KIRKWOOD || ARCH_MV78XX0 || \
1022 ARCH_ORION5X 1030 ARCH_ORION5X
1031 default 0xf7fc9000 if DEBUG_BERLIN_UART
1023 default 0xf8b00000 if DEBUG_HI3716_UART 1032 default 0xf8b00000 if DEBUG_HI3716_UART
1024 default 0xfcb00000 if DEBUG_HI3620_UART 1033 default 0xfcb00000 if DEBUG_HI3620_UART
1025 default 0xfe800000 if ARCH_IOP32X 1034 default 0xfe800000 if ARCH_IOP32X
@@ -1045,6 +1054,7 @@ config DEBUG_UART_VIRT
1045 default 0xf2100000 if DEBUG_PXA_UART1 1054 default 0xf2100000 if DEBUG_PXA_UART1
1046 default 0xf4090000 if ARCH_LPC32XX 1055 default 0xf4090000 if ARCH_LPC32XX
1047 default 0xf4200000 if ARCH_GEMINI 1056 default 0xf4200000 if ARCH_GEMINI
1057 default 0xf7fc9000 if DEBUG_BERLIN_UART
1048 default 0xf8009000 if DEBUG_VEXPRESS_UART0_CA9 1058 default 0xf8009000 if DEBUG_VEXPRESS_UART0_CA9
1049 default 0xf8090000 if DEBUG_VEXPRESS_UART0_RS1 1059 default 0xf8090000 if DEBUG_VEXPRESS_UART0_RS1
1050 default 0xfb009000 if DEBUG_REALVIEW_STD_PORT 1060 default 0xfb009000 if DEBUG_REALVIEW_STD_PORT
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index c99b1086d83d..91b16ce35a6c 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -148,11 +148,13 @@ textofs-$(CONFIG_ARCH_MSM8960) := 0x00208000
148machine-$(CONFIG_ARCH_AT91) += at91 148machine-$(CONFIG_ARCH_AT91) += at91
149machine-$(CONFIG_ARCH_BCM) += bcm 149machine-$(CONFIG_ARCH_BCM) += bcm
150machine-$(CONFIG_ARCH_BCM2835) += bcm2835 150machine-$(CONFIG_ARCH_BCM2835) += bcm2835
151machine-$(CONFIG_ARCH_BERLIN) += berlin
151machine-$(CONFIG_ARCH_CLPS711X) += clps711x 152machine-$(CONFIG_ARCH_CLPS711X) += clps711x
152machine-$(CONFIG_ARCH_CNS3XXX) += cns3xxx 153machine-$(CONFIG_ARCH_CNS3XXX) += cns3xxx
153machine-$(CONFIG_ARCH_DAVINCI) += davinci 154machine-$(CONFIG_ARCH_DAVINCI) += davinci
154machine-$(CONFIG_ARCH_DOVE) += dove 155machine-$(CONFIG_ARCH_DOVE) += dove
155machine-$(CONFIG_ARCH_EBSA110) += ebsa110 156machine-$(CONFIG_ARCH_EBSA110) += ebsa110
157machine-$(CONFIG_ARCH_EFM32) += efm32
156machine-$(CONFIG_ARCH_EP93XX) += ep93xx 158machine-$(CONFIG_ARCH_EP93XX) += ep93xx
157machine-$(CONFIG_ARCH_EXYNOS) += exynos 159machine-$(CONFIG_ARCH_EXYNOS) += exynos
158machine-$(CONFIG_ARCH_GEMINI) += gemini 160machine-$(CONFIG_ARCH_GEMINI) += gemini
@@ -167,6 +169,7 @@ machine-$(CONFIG_ARCH_KIRKWOOD) += kirkwood
167machine-$(CONFIG_ARCH_KS8695) += ks8695 169machine-$(CONFIG_ARCH_KS8695) += ks8695
168machine-$(CONFIG_ARCH_LPC32XX) += lpc32xx 170machine-$(CONFIG_ARCH_LPC32XX) += lpc32xx
169machine-$(CONFIG_ARCH_MMP) += mmp 171machine-$(CONFIG_ARCH_MMP) += mmp
172machine-$(CONFIG_ARCH_MOXART) += moxart
170machine-$(CONFIG_ARCH_MSM) += msm 173machine-$(CONFIG_ARCH_MSM) += msm
171machine-$(CONFIG_ARCH_MV78XX0) += mv78xx0 174machine-$(CONFIG_ARCH_MV78XX0) += mv78xx0
172machine-$(CONFIG_ARCH_MVEBU) += mvebu 175machine-$(CONFIG_ARCH_MVEBU) += mvebu
@@ -190,7 +193,6 @@ machine-$(CONFIG_ARCH_S5PC100) += s5pc100
190machine-$(CONFIG_ARCH_S5PV210) += s5pv210 193machine-$(CONFIG_ARCH_S5PV210) += s5pv210
191machine-$(CONFIG_ARCH_SA1100) += sa1100 194machine-$(CONFIG_ARCH_SA1100) += sa1100
192machine-$(CONFIG_ARCH_SHMOBILE) += shmobile 195machine-$(CONFIG_ARCH_SHMOBILE) += shmobile
193machine-$(CONFIG_ARCH_SHMOBILE_MULTI) += shmobile
194machine-$(CONFIG_ARCH_SIRF) += prima2 196machine-$(CONFIG_ARCH_SIRF) += prima2
195machine-$(CONFIG_ARCH_SOCFPGA) += socfpga 197machine-$(CONFIG_ARCH_SOCFPGA) += socfpga
196machine-$(CONFIG_ARCH_STI) += sti 198machine-$(CONFIG_ARCH_STI) += sti
diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
index e7190bb5998e..f54d5a25c7ee 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -64,7 +64,7 @@ else
64endif 64endif
65endif 65endif
66 66
67ifeq ($(CONFIG_ARCH_SHMOBILE),y) 67ifeq ($(CONFIG_ARCH_SHMOBILE_LEGACY),y)
68OBJS += head-shmobile.o 68OBJS += head-shmobile.o
69endif 69endif
70 70
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index d57c1a65b24f..b44dd26b951d 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -45,6 +45,9 @@ dtb-$(CONFIG_ARCH_BCM2835) += bcm2835-rpi-b.dtb
45dtb-$(CONFIG_ARCH_BCM_MOBILE) += bcm11351-brt.dtb \ 45dtb-$(CONFIG_ARCH_BCM_MOBILE) += bcm11351-brt.dtb \
46 bcm28155-ap.dtb 46 bcm28155-ap.dtb
47dtb-$(CONFIG_ARCH_BCM2835) += bcm2835-rpi-b.dtb 47dtb-$(CONFIG_ARCH_BCM2835) += bcm2835-rpi-b.dtb
48dtb-$(CONFIG_ARCH_BERLIN) += \
49 berlin2-sony-nsz-gs7.dtb \
50 berlin2cd-google-chromecast.dtb
48dtb-$(CONFIG_ARCH_DAVINCI) += da850-enbw-cmc.dtb \ 51dtb-$(CONFIG_ARCH_DAVINCI) += da850-enbw-cmc.dtb \
49 da850-evm.dtb 52 da850-evm.dtb
50dtb-$(CONFIG_ARCH_DOVE) += dove-cm-a510.dtb \ 53dtb-$(CONFIG_ARCH_DOVE) += dove-cm-a510.dtb \
@@ -52,6 +55,7 @@ dtb-$(CONFIG_ARCH_DOVE) += dove-cm-a510.dtb \
52 dove-d2plug.dtb \ 55 dove-d2plug.dtb \
53 dove-d3plug.dtb \ 56 dove-d3plug.dtb \
54 dove-dove-db.dtb 57 dove-dove-db.dtb
58dtb-$(CONFIG_ARCH_EFM32) += efm32gg-dk3750.dtb
55dtb-$(CONFIG_ARCH_EXYNOS) += exynos4210-origen.dtb \ 59dtb-$(CONFIG_ARCH_EXYNOS) += exynos4210-origen.dtb \
56 exynos4210-smdkv310.dtb \ 60 exynos4210-smdkv310.dtb \
57 exynos4210-trats.dtb \ 61 exynos4210-trats.dtb \
@@ -216,7 +220,7 @@ dtb-$(CONFIG_ARCH_U8500) += ste-snowball.dtb \
216dtb-$(CONFIG_ARCH_S3C24XX) += s3c2416-smdk2416.dtb 220dtb-$(CONFIG_ARCH_S3C24XX) += s3c2416-smdk2416.dtb
217dtb-$(CONFIG_ARCH_S3C64XX) += s3c6410-mini6410.dtb \ 221dtb-$(CONFIG_ARCH_S3C64XX) += s3c6410-mini6410.dtb \
218 s3c6410-smdk6410.dtb 222 s3c6410-smdk6410.dtb
219dtb-$(CONFIG_ARCH_SHMOBILE) += emev2-kzm9d.dtb \ 223dtb-$(CONFIG_ARCH_SHMOBILE_LEGACY) += emev2-kzm9d.dtb \
220 r7s72100-genmai.dtb \ 224 r7s72100-genmai.dtb \
221 r8a7740-armadillo800eva.dtb \ 225 r8a7740-armadillo800eva.dtb \
222 r8a7778-bockw.dtb \ 226 r8a7778-bockw.dtb \
diff --git a/arch/arm/boot/dts/am3517-evm.dts b/arch/arm/boot/dts/am3517-evm.dts
index e99dfaf70052..03fcbf0a88a8 100644
--- a/arch/arm/boot/dts/am3517-evm.dts
+++ b/arch/arm/boot/dts/am3517-evm.dts
@@ -7,11 +7,11 @@
7 */ 7 */
8/dts-v1/; 8/dts-v1/;
9 9
10#include "omap34xx.dtsi" 10#include "am3517.dtsi"
11 11
12/ { 12/ {
13 model = "TI AM3517 EVM (AM3517/05)"; 13 model = "TI AM3517 EVM (AM3517/05 TMDSEVM3517)";
14 compatible = "ti,am3517-evm", "ti,omap3"; 14 compatible = "ti,am3517-evm", "ti,am3517", "ti,omap3";
15 15
16 memory { 16 memory {
17 device_type = "memory"; 17 device_type = "memory";
diff --git a/arch/arm/boot/dts/am3517.dtsi b/arch/arm/boot/dts/am3517.dtsi
new file mode 100644
index 000000000000..2fbe02faa8b1
--- /dev/null
+++ b/arch/arm/boot/dts/am3517.dtsi
@@ -0,0 +1,63 @@
1/*
2 * Device Tree Source for am3517 SoC
3 *
4 * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
5 *
6 * This file is licensed under the terms of the GNU General Public License
7 * version 2. This program is licensed "as is" without any warranty of any
8 * kind, whether express or implied.
9 */
10
11#include "omap3.dtsi"
12
13/ {
14 aliases {
15 serial3 = &uart4;
16 };
17
18 ocp {
19 am35x_otg_hs: am35x_otg_hs@5c040000 {
20 compatible = "ti,omap3-musb";
21 ti,hwmods = "am35x_otg_hs";
22 status = "disabled";
23 reg = <0x5c040000 0x1000>;
24 interrupts = <71>;
25 interrupt-names = "mc";
26 };
27
28 davinci_emac: ethernet@0x5c000000 {
29 compatible = "ti,am3517-emac";
30 ti,hwmods = "davinci_emac";
31 status = "disabled";
32 reg = <0x5c000000 0x30000>;
33 interrupts = <67 68 69 70>;
34 ti,davinci-ctrl-reg-offset = <0x10000>;
35 ti,davinci-ctrl-mod-reg-offset = <0>;
36 ti,davinci-ctrl-ram-offset = <0x20000>;
37 ti,davinci-ctrl-ram-size = <0x2000>;
38 ti,davinci-rmii-en = /bits/ 8 <1>;
39 local-mac-address = [ 00 00 00 00 00 00 ];
40 };
41
42 davinci_mdio: ethernet@0x5c030000 {
43 compatible = "ti,davinci_mdio";
44 ti,hwmods = "davinci_mdio";
45 status = "disabled";
46 reg = <0x5c030000 0x1000>;
47 bus_freq = <1000000>;
48 #address-cells = <1>;
49 #size-cells = <0>;
50 };
51
52 uart4: serial@4809e000 {
53 compatible = "ti,omap3-uart";
54 ti,hwmods = "uart4";
55 status = "disabled";
56 reg = <0x4809e000 0x400>;
57 interrupts = <84>;
58 dmas = <&sdma 55 &sdma 54>;
59 dma-names = "tx", "rx";
60 clock-frequency = <48000000>;
61 };
62 };
63};
diff --git a/arch/arm/boot/dts/armv7-m.dtsi b/arch/arm/boot/dts/armv7-m.dtsi
new file mode 100644
index 000000000000..5a660d0faf42
--- /dev/null
+++ b/arch/arm/boot/dts/armv7-m.dtsi
@@ -0,0 +1,18 @@
1#include "skeleton.dtsi"
2
3/ {
4 nvic: nv-interrupt-controller {
5 compatible = "arm,armv7m-nvic";
6 interrupt-controller;
7 #interrupt-cells = <1>;
8 reg = <0xe000e100 0xc00>;
9 };
10
11 soc {
12 #address-cells = <1>;
13 #size-cells = <1>;
14 compatible = "simple-bus";
15 interrupt-parent = <&nvic>;
16 ranges;
17 };
18};
diff --git a/arch/arm/boot/dts/berlin2-sony-nsz-gs7.dts b/arch/arm/boot/dts/berlin2-sony-nsz-gs7.dts
new file mode 100644
index 000000000000..c72bfd468d10
--- /dev/null
+++ b/arch/arm/boot/dts/berlin2-sony-nsz-gs7.dts
@@ -0,0 +1,29 @@
1/*
2 * Device Tree file for Sony NSZ-GS7
3 *
4 * Sebastian Hesselbarth <sebastian.hesselbarth@gmail.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/dts-v1/;
12
13#include "berlin2.dtsi"
14
15/ {
16 model = "Sony NSZ-GS7";
17 compatible = "sony,nsz-gs7", "marvell,berlin2", "marvell,berlin";
18
19 chosen {
20 bootargs = "console=ttyS0,115200 earlyprintk";
21 };
22
23 memory {
24 device_type = "memory";
25 reg = <0x00000000 0x40000000>; /* 1 GB */
26 };
27};
28
29&uart0 { status = "okay"; };
diff --git a/arch/arm/boot/dts/berlin2.dtsi b/arch/arm/boot/dts/berlin2.dtsi
new file mode 100644
index 000000000000..56a1af2f1052
--- /dev/null
+++ b/arch/arm/boot/dts/berlin2.dtsi
@@ -0,0 +1,227 @@
1/*
2 * Device Tree Include file for Marvell Armada 1500 (Berlin BG2) SoC
3 *
4 * Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
5 *
6 * based on GPL'ed 2.6 kernel sources
7 * (c) Marvell International Ltd.
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 "skeleton.dtsi"
15#include <dt-bindings/interrupt-controller/arm-gic.h>
16
17/ {
18 model = "Marvell Armada 1500 (BG2) SoC";
19 compatible = "marvell,berlin2", "marvell,berlin";
20
21 cpus {
22 #address-cells = <1>;
23 #size-cells = <0>;
24
25 cpu@0 {
26 compatible = "marvell,pj4b";
27 device_type = "cpu";
28 next-level-cache = <&l2>;
29 reg = <0>;
30 };
31
32 cpu@1 {
33 compatible = "marvell,pj4b";
34 device_type = "cpu";
35 next-level-cache = <&l2>;
36 reg = <1>;
37 };
38 };
39
40 clocks {
41 smclk: sysmgr-clock {
42 compatible = "fixed-clock";
43 #clock-cells = <0>;
44 clock-frequency = <25000000>;
45 };
46
47 cfgclk: cfg-clock {
48 compatible = "fixed-clock";
49 #clock-cells = <0>;
50 clock-frequency = <100000000>;
51 };
52
53 sysclk: system-clock {
54 compatible = "fixed-clock";
55 #clock-cells = <0>;
56 clock-frequency = <400000000>;
57 };
58 };
59
60 soc {
61 compatible = "simple-bus";
62 #address-cells = <1>;
63 #size-cells = <1>;
64 interrupt-parent = <&gic>;
65
66 ranges = <0 0xf7000000 0x1000000>;
67
68 l2: l2-cache-controller@ac0000 {
69 compatible = "marvell,tauros3-cache", "arm,pl310-cache";
70 reg = <0xac0000 0x1000>;
71 cache-unified;
72 cache-level = <2>;
73 };
74
75 gic: interrupt-controller@ad1000 {
76 compatible = "arm,cortex-a9-gic";
77 reg = <0xad1000 0x1000>, <0xad0100 0x0100>;
78 interrupt-controller;
79 #interrupt-cells = <3>;
80 };
81
82 local-timer@ad0600 {
83 compatible = "arm,cortex-a9-twd-timer";
84 reg = <0xad0600 0x20>;
85 interrupts = <GIC_PPI 13 IRQ_TYPE_LEVEL_HIGH>;
86 clocks = <&sysclk>;
87 };
88
89 apb@e80000 {
90 compatible = "simple-bus";
91 #address-cells = <1>;
92 #size-cells = <1>;
93
94 ranges = <0 0xe80000 0x10000>;
95 interrupt-parent = <&aic>;
96
97 timer0: timer@2c00 {
98 compatible = "snps,dw-apb-timer";
99 reg = <0x2c00 0x14>;
100 interrupts = <8>;
101 clocks = <&cfgclk>;
102 clock-names = "timer";
103 status = "okay";
104 };
105
106 timer1: timer@2c14 {
107 compatible = "snps,dw-apb-timer";
108 reg = <0x2c14 0x14>;
109 interrupts = <9>;
110 clocks = <&cfgclk>;
111 clock-names = "timer";
112 status = "okay";
113 };
114
115 timer2: timer@2c28 {
116 compatible = "snps,dw-apb-timer";
117 reg = <0x2c28 0x14>;
118 interrupts = <10>;
119 clocks = <&cfgclk>;
120 clock-names = "timer";
121 status = "disabled";
122 };
123
124 timer3: timer@2c3c {
125 compatible = "snps,dw-apb-timer";
126 reg = <0x2c3c 0x14>;
127 interrupts = <11>;
128 clocks = <&cfgclk>;
129 clock-names = "timer";
130 status = "disabled";
131 };
132
133 timer4: timer@2c50 {
134 compatible = "snps,dw-apb-timer";
135 reg = <0x2c50 0x14>;
136 interrupts = <12>;
137 clocks = <&cfgclk>;
138 clock-names = "timer";
139 status = "disabled";
140 };
141
142 timer5: timer@2c64 {
143 compatible = "snps,dw-apb-timer";
144 reg = <0x2c64 0x14>;
145 interrupts = <13>;
146 clocks = <&cfgclk>;
147 clock-names = "timer";
148 status = "disabled";
149 };
150
151 timer6: timer@2c78 {
152 compatible = "snps,dw-apb-timer";
153 reg = <0x2c78 0x14>;
154 interrupts = <14>;
155 clocks = <&cfgclk>;
156 clock-names = "timer";
157 status = "disabled";
158 };
159
160 timer7: timer@2c8c {
161 compatible = "snps,dw-apb-timer";
162 reg = <0x2c8c 0x14>;
163 interrupts = <15>;
164 clocks = <&cfgclk>;
165 clock-names = "timer";
166 status = "disabled";
167 };
168
169 aic: interrupt-controller@3000 {
170 compatible = "snps,dw-apb-ictl";
171 reg = <0x3000 0xc00>;
172 interrupt-controller;
173 #interrupt-cells = <1>;
174 interrupt-parent = <&gic>;
175 interrupts = <GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>;
176 };
177 };
178
179 apb@fc0000 {
180 compatible = "simple-bus";
181 #address-cells = <1>;
182 #size-cells = <1>;
183
184 ranges = <0 0xfc0000 0x10000>;
185 interrupt-parent = <&sic>;
186
187 uart0: serial@9000 {
188 compatible = "snps,dw-apb-uart";
189 reg = <0x9000 0x100>;
190 reg-shift = <2>;
191 reg-io-width = <1>;
192 interrupts = <8>;
193 clocks = <&smclk>;
194 status = "disabled";
195 };
196
197 uart1: serial@a000 {
198 compatible = "snps,dw-apb-uart";
199 reg = <0xa000 0x100>;
200 reg-shift = <2>;
201 reg-io-width = <1>;
202 interrupts = <9>;
203 clocks = <&smclk>;
204 status = "disabled";
205 };
206
207 uart2: serial@b000 {
208 compatible = "snps,dw-apb-uart";
209 reg = <0xb000 0x100>;
210 reg-shift = <2>;
211 reg-io-width = <1>;
212 interrupts = <10>;
213 clocks = <&smclk>;
214 status = "disabled";
215 };
216
217 sic: interrupt-controller@e000 {
218 compatible = "snps,dw-apb-ictl";
219 reg = <0xe000 0x400>;
220 interrupt-controller;
221 #interrupt-cells = <1>;
222 interrupt-parent = <&gic>;
223 interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>;
224 };
225 };
226 };
227};
diff --git a/arch/arm/boot/dts/berlin2cd-google-chromecast.dts b/arch/arm/boot/dts/berlin2cd-google-chromecast.dts
new file mode 100644
index 000000000000..bcd81ffc495d
--- /dev/null
+++ b/arch/arm/boot/dts/berlin2cd-google-chromecast.dts
@@ -0,0 +1,29 @@
1/*
2 * Device Tree file for Google Chromecast
3 *
4 * Sebastian Hesselbarth <sebastian.hesselbarth@gmail.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/dts-v1/;
12
13#include "berlin2cd.dtsi"
14
15/ {
16 model = "Google Chromecast";
17 compatible = "google,chromecast", "marvell,berlin2cd", "marvell,berlin";
18
19 chosen {
20 bootargs = "console=ttyS0,115200 earlyprintk";
21 };
22
23 memory {
24 device_type = "memory";
25 reg = <0x00000000 0x20000000>; /* 512 MB */
26 };
27};
28
29&uart0 { status = "okay"; };
diff --git a/arch/arm/boot/dts/berlin2cd.dtsi b/arch/arm/boot/dts/berlin2cd.dtsi
new file mode 100644
index 000000000000..094968c27533
--- /dev/null
+++ b/arch/arm/boot/dts/berlin2cd.dtsi
@@ -0,0 +1,210 @@
1/*
2 * Device Tree Include file for Marvell Armada 1500-mini (Berlin BG2CD) SoC
3 *
4 * Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
5 *
6 * based on GPL'ed 2.6 kernel sources
7 * (c) Marvell International Ltd.
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 "skeleton.dtsi"
15#include <dt-bindings/interrupt-controller/arm-gic.h>
16
17/ {
18 model = "Marvell Armada 1500-mini (BG2CD) SoC";
19 compatible = "marvell,berlin2cd", "marvell,berlin";
20
21 cpus {
22 #address-cells = <1>;
23 #size-cells = <0>;
24
25 cpu@0 {
26 compatible = "arm,cortex-a9";
27 device_type = "cpu";
28 next-level-cache = <&l2>;
29 reg = <0>;
30 };
31 };
32
33 clocks {
34 smclk: sysmgr-clock {
35 compatible = "fixed-clock";
36 #clock-cells = <0>;
37 clock-frequency = <25000000>;
38 };
39
40 cfgclk: cfg-clock {
41 compatible = "fixed-clock";
42 #clock-cells = <0>;
43 clock-frequency = <75000000>;
44 };
45
46 sysclk: system-clock {
47 compatible = "fixed-clock";
48 #clock-cells = <0>;
49 clock-frequency = <300000000>;
50 };
51 };
52
53 soc {
54 compatible = "simple-bus";
55 #address-cells = <1>;
56 #size-cells = <1>;
57 interrupt-parent = <&gic>;
58
59 ranges = <0 0xf7000000 0x1000000>;
60
61 l2: l2-cache-controller@ac0000 {
62 compatible = "arm,pl310-cache";
63 reg = <0xac0000 0x1000>;
64 cache-unified;
65 cache-level = <2>;
66 };
67
68 gic: interrupt-controller@ad1000 {
69 compatible = "arm,cortex-a9-gic";
70 reg = <0xad1000 0x1000>, <0xad0100 0x0100>;
71 interrupt-controller;
72 #interrupt-cells = <3>;
73 };
74
75 local-timer@ad0600 {
76 compatible = "arm,cortex-a9-twd-timer";
77 reg = <0xad0600 0x20>;
78 interrupts = <GIC_PPI 13 IRQ_TYPE_LEVEL_HIGH>;
79 clocks = <&sysclk>;
80 };
81
82 apb@e80000 {
83 compatible = "simple-bus";
84 #address-cells = <1>;
85 #size-cells = <1>;
86
87 ranges = <0 0xe80000 0x10000>;
88 interrupt-parent = <&aic>;
89
90 timer0: timer@2c00 {
91 compatible = "snps,dw-apb-timer";
92 reg = <0x2c00 0x14>;
93 interrupts = <8>;
94 clocks = <&cfgclk>;
95 clock-names = "timer";
96 status = "okay";
97 };
98
99 timer1: timer@2c14 {
100 compatible = "snps,dw-apb-timer";
101 reg = <0x2c14 0x14>;
102 interrupts = <9>;
103 clocks = <&cfgclk>;
104 clock-names = "timer";
105 status = "okay";
106 };
107
108 timer2: timer@2c28 {
109 compatible = "snps,dw-apb-timer";
110 reg = <0x2c28 0x14>;
111 interrupts = <10>;
112 clocks = <&cfgclk>;
113 clock-names = "timer";
114 status = "disabled";
115 };
116
117 timer3: timer@2c3c {
118 compatible = "snps,dw-apb-timer";
119 reg = <0x2c3c 0x14>;
120 interrupts = <11>;
121 clocks = <&cfgclk>;
122 clock-names = "timer";
123 status = "disabled";
124 };
125
126 timer4: timer@2c50 {
127 compatible = "snps,dw-apb-timer";
128 reg = <0x2c50 0x14>;
129 interrupts = <12>;
130 clocks = <&cfgclk>;
131 clock-names = "timer";
132 status = "disabled";
133 };
134
135 timer5: timer@2c64 {
136 compatible = "snps,dw-apb-timer";
137 reg = <0x2c64 0x14>;
138 interrupts = <13>;
139 clocks = <&cfgclk>;
140 clock-names = "timer";
141 status = "disabled";
142 };
143
144 timer6: timer@2c78 {
145 compatible = "snps,dw-apb-timer";
146 reg = <0x2c78 0x14>;
147 interrupts = <14>;
148 clocks = <&cfgclk>;
149 clock-names = "timer";
150 status = "disabled";
151 };
152
153 timer7: timer@2c8c {
154 compatible = "snps,dw-apb-timer";
155 reg = <0x2c8c 0x14>;
156 interrupts = <15>;
157 clocks = <&cfgclk>;
158 clock-names = "timer";
159 status = "disabled";
160 };
161
162 aic: interrupt-controller@3000 {
163 compatible = "snps,dw-apb-ictl";
164 reg = <0x3000 0xc00>;
165 interrupt-controller;
166 #interrupt-cells = <1>;
167 interrupt-parent = <&gic>;
168 interrupts = <GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>;
169 };
170 };
171
172 apb@fc0000 {
173 compatible = "simple-bus";
174 #address-cells = <1>;
175 #size-cells = <1>;
176
177 ranges = <0 0xfc0000 0x10000>;
178 interrupt-parent = <&sic>;
179
180 uart0: serial@9000 {
181 compatible = "snps,dw-apb-uart";
182 reg = <0x9000 0x100>;
183 reg-shift = <2>;
184 reg-io-width = <1>;
185 interrupts = <8>;
186 clocks = <&smclk>;
187 status = "disabled";
188 };
189
190 uart1: serial@a000 {
191 compatible = "snps,dw-apb-uart";
192 reg = <0xa000 0x100>;
193 reg-shift = <2>;
194 reg-io-width = <1>;
195 interrupts = <9>;
196 clocks = <&smclk>;
197 status = "disabled";
198 };
199
200 sic: interrupt-controller@e000 {
201 compatible = "snps,dw-apb-ictl";
202 reg = <0xe000 0x400>;
203 interrupt-controller;
204 #interrupt-cells = <1>;
205 interrupt-parent = <&gic>;
206 interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>;
207 };
208 };
209 };
210};
diff --git a/arch/arm/boot/dts/efm32gg-dk3750.dts b/arch/arm/boot/dts/efm32gg-dk3750.dts
new file mode 100644
index 000000000000..aa5c0f6363d6
--- /dev/null
+++ b/arch/arm/boot/dts/efm32gg-dk3750.dts
@@ -0,0 +1,86 @@
1/*
2 * Device tree for EFM32GG-DK3750 development board.
3 *
4 * Documentation available from
5 * http://www.silabs.com/Support%20Documents/TechnicalDocs/efm32gg-dk3750-ug.pdf
6 */
7
8/dts-v1/;
9#include "efm32gg.dtsi"
10
11/ {
12 model = "Energy Micro Giant Gecko Development Kit";
13 compatible = "efm32,dk3750";
14
15 chosen {
16 bootargs = "console=ttyefm4,115200 init=/linuxrc ignore_loglevel ihash_entries=64 dhash_entries=64 earlyprintk uclinux.physaddr=0x8c400000 root=/dev/mtdblock0";
17 };
18
19 memory {
20 reg = <0x88000000 0x400000>;
21 };
22
23 soc {
24 adc@40002000 {
25 status = "ok";
26 };
27
28 i2c@4000a000 {
29 location = <3>;
30 status = "ok";
31
32 temp@48 {
33 compatible = "st,stds75";
34 reg = <0x48>;
35 };
36
37 eeprom@50 {
38 compatible = "microchip,24c02";
39 reg = <0x50>;
40 pagesize = <16>;
41 };
42 };
43
44 spi0: spi@4000c000 { /* USART0 */
45 cs-gpios = <&gpio 68 1>; // E4
46 location = <1>;
47 status = "ok";
48
49 microsd@0 {
50 compatible = "mmc-spi-slot";
51 spi-max-frequency = <100000>;
52 voltage-ranges = <3200 3400>;
53 broken-cd;
54 reg = <0>;
55 };
56 };
57
58 spi1: spi@4000c400 { /* USART1 */
59 cs-gpios = <&gpio 51 1>; // D3
60 location = <1>;
61 status = "ok";
62
63 ks8851@0 {
64 compatible = "ks8851";
65 spi-max-frequency = <6000000>;
66 reg = <0>;
67 interrupt-parent = <&boardfpga>;
68 interrupts = <4>;
69 };
70 };
71
72 uart4: uart@4000e400 { /* UART1 */
73 location = <2>;
74 status = "ok";
75 };
76
77 boardfpga: boardfpga {
78 compatible = "efm32board";
79 reg = <0x80000000 0x400>;
80 irq-gpios = <&gpio 64 1>;
81 interrupt-controller;
82 #interrupt-cells = <1>;
83 status = "ok";
84 };
85 };
86};
diff --git a/arch/arm/boot/dts/efm32gg.dtsi b/arch/arm/boot/dts/efm32gg.dtsi
new file mode 100644
index 000000000000..a342ab0e6e4f
--- /dev/null
+++ b/arch/arm/boot/dts/efm32gg.dtsi
@@ -0,0 +1,172 @@
1/*
2 * Device tree for Energy Micro EFM32 Giant Gecko SoC.
3 *
4 * Documentation available from
5 * http://www.silabs.com/Support%20Documents/TechnicalDocs/EFM32GG-RM.pdf
6 */
7#include "armv7-m.dtsi"
8#include "dt-bindings/clock/efm32-cmu.h"
9
10/ {
11 aliases {
12 i2c0 = &i2c0;
13 i2c1 = &i2c1;
14 serial0 = &uart0;
15 serial1 = &uart1;
16 serial2 = &uart2;
17 serial3 = &uart3;
18 serial4 = &uart4;
19 spi0 = &spi0;
20 spi1 = &spi1;
21 spi2 = &spi2;
22 };
23
24 soc {
25 adc: adc@40002000 {
26 compatible = "efm32,adc";
27 reg = <0x40002000 0x400>;
28 interrupts = <7>;
29 clocks = <&cmu clk_HFPERCLKADC0>;
30 status = "disabled";
31 };
32
33 gpio: gpio@40006000 {
34 compatible = "efm32,gpio";
35 reg = <0x40006000 0x1000>;
36 interrupts = <1 11>;
37 gpio-controller;
38 #gpio-cells = <2>;
39 interrupt-controller;
40 #interrupt-cells = <1>;
41 clocks = <&cmu clk_HFPERCLKGPIO>;
42 status = "ok";
43 };
44
45 i2c0: i2c@4000a000 {
46 #address-cells = <1>;
47 #size-cells = <0>;
48 compatible = "efm32,i2c";
49 reg = <0x4000a000 0x400>;
50 interrupts = <9>;
51 clocks = <&cmu clk_HFPERCLKI2C0>;
52 clock-frequency = <100000>;
53 status = "disabled";
54 };
55
56 i2c1: i2c@4000a400 {
57 #address-cells = <1>;
58 #size-cells = <0>;
59 compatible = "efm32,i2c";
60 reg = <0x4000a400 0x400>;
61 interrupts = <10>;
62 clocks = <&cmu clk_HFPERCLKI2C1>;
63 clock-frequency = <100000>;
64 status = "disabled";
65 };
66
67 spi0: spi@4000c000 { /* USART0 */
68 #address-cells = <1>;
69 #size-cells = <0>;
70 compatible = "efm32,spi";
71 reg = <0x4000c000 0x400>;
72 interrupts = <3 4>;
73 clocks = <&cmu clk_HFPERCLKUSART0>;
74 status = "disabled";
75 };
76
77 spi1: spi@4000c400 { /* USART1 */
78 #address-cells = <1>;
79 #size-cells = <0>;
80 compatible = "efm32,spi";
81 reg = <0x4000c400 0x400>;
82 interrupts = <15 16>;
83 clocks = <&cmu clk_HFPERCLKUSART1>;
84 status = "disabled";
85 };
86
87 spi2: spi@40x4000c800 { /* USART2 */
88 #address-cells = <1>;
89 #size-cells = <0>;
90 compatible = "efm32,spi";
91 reg = <0x4000c800 0x400>;
92 interrupts = <18 19>;
93 clocks = <&cmu clk_HFPERCLKUSART2>;
94 status = "disabled";
95 };
96
97 uart0: uart@4000c000 { /* USART0 */
98 compatible = "efm32,uart";
99 reg = <0x4000c000 0x400>;
100 interrupts = <3 4>;
101 clocks = <&cmu clk_HFPERCLKUSART0>;
102 status = "disabled";
103 };
104
105 uart1: uart@4000c400 { /* USART1 */
106 compatible = "efm32,uart";
107 reg = <0x4000c400 0x400>;
108 interrupts = <15 16>;
109 clocks = <&cmu clk_HFPERCLKUSART1>;
110 status = "disabled";
111 };
112
113 uart2: uart@40x4000c800 { /* USART2 */
114 compatible = "efm32,uart";
115 reg = <0x4000c800 0x400>;
116 interrupts = <18 19>;
117 clocks = <&cmu clk_HFPERCLKUSART2>;
118 status = "disabled";
119 };
120
121 uart3: uart@4000e000 { /* UART0 */
122 compatible = "efm32,uart";
123 reg = <0x4000e000 0x400>;
124 interrupts = <20 21>;
125 clocks = <&cmu clk_HFPERCLKUART0>;
126 status = "disabled";
127 };
128
129 uart4: uart@4000e400 { /* UART1 */
130 compatible = "efm32,uart";
131 reg = <0x4000e400 0x400>;
132 interrupts = <22 23>;
133 clocks = <&cmu clk_HFPERCLKUART1>;
134 status = "disabled";
135 };
136
137 timer0: timer@40010000 {
138 compatible = "efm32,timer";
139 reg = <0x40010000 0x400>;
140 interrupts = <2>;
141 clocks = <&cmu clk_HFPERCLKTIMER0>;
142 };
143
144 timer1: timer@40010400 {
145 compatible = "efm32,timer";
146 reg = <0x40010400 0x400>;
147 interrupts = <12>;
148 clocks = <&cmu clk_HFPERCLKTIMER1>;
149 };
150
151 timer2: timer@40010800 {
152 compatible = "efm32,timer";
153 reg = <0x40010800 0x400>;
154 interrupts = <13>;
155 clocks = <&cmu clk_HFPERCLKTIMER2>;
156 };
157
158 timer3: timer@40010c00 {
159 compatible = "efm32,timer";
160 reg = <0x40010c00 0x400>;
161 interrupts = <14>;
162 clocks = <&cmu clk_HFPERCLKTIMER3>;
163 };
164
165 cmu: cmu@400c8000 {
166 compatible = "efm32gg,cmu";
167 reg = <0x400c8000 0x400>;
168 interrupts = <32>;
169 #clock-cells = <1>;
170 };
171 };
172};
diff --git a/arch/arm/boot/dts/omap3-n900.dts b/arch/arm/boot/dts/omap3-n900.dts
index c2c306d13b87..6fc85f963530 100644
--- a/arch/arm/boot/dts/omap3-n900.dts
+++ b/arch/arm/boot/dts/omap3-n900.dts
@@ -9,7 +9,7 @@
9 9
10/dts-v1/; 10/dts-v1/;
11 11
12#include "omap34xx.dtsi" 12#include "omap34xx-hs.dtsi"
13 13
14/ { 14/ {
15 model = "Nokia N900"; 15 model = "Nokia N900";
diff --git a/arch/arm/boot/dts/omap3-n950-n9.dtsi b/arch/arm/boot/dts/omap3-n950-n9.dtsi
index 94eb77d3b9dd..5c26c184f2c1 100644
--- a/arch/arm/boot/dts/omap3-n950-n9.dtsi
+++ b/arch/arm/boot/dts/omap3-n950-n9.dtsi
@@ -8,7 +8,7 @@
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 */ 9 */
10 10
11#include "omap36xx.dtsi" 11#include "omap36xx-hs.dtsi"
12 12
13/ { 13/ {
14 cpus { 14 cpus {
diff --git a/arch/arm/boot/dts/omap34xx-hs.dtsi b/arch/arm/boot/dts/omap34xx-hs.dtsi
new file mode 100644
index 000000000000..1ff626489546
--- /dev/null
+++ b/arch/arm/boot/dts/omap34xx-hs.dtsi
@@ -0,0 +1,16 @@
1/* Disabled modules for secure omaps */
2
3#include "omap34xx.dtsi"
4
5/* Secure omaps have some devices inaccessible depending on the firmware */
6&aes {
7 status = "disabled";
8};
9
10&sham {
11 status = "disabled";
12};
13
14&timer12 {
15 status = "disabled";
16};
diff --git a/arch/arm/boot/dts/omap36xx-hs.dtsi b/arch/arm/boot/dts/omap36xx-hs.dtsi
new file mode 100644
index 000000000000..2c7febb0e016
--- /dev/null
+++ b/arch/arm/boot/dts/omap36xx-hs.dtsi
@@ -0,0 +1,16 @@
1/* Disabled modules for secure omaps */
2
3#include "omap36xx.dtsi"
4
5/* Secure omaps have some devices inaccessible depending on the firmware */
6&aes {
7 status = "disabled";
8};
9
10&sham {
11 status = "disabled";
12};
13
14&timer12 {
15 status = "disabled";
16};
diff --git a/arch/arm/boot/dts/qcom-msm8974.dtsi b/arch/arm/boot/dts/qcom-msm8974.dtsi
new file mode 100644
index 000000000000..2ebb4f09a9b6
--- /dev/null
+++ b/arch/arm/boot/dts/qcom-msm8974.dtsi
@@ -0,0 +1,33 @@
1/dts-v1/;
2
3#include "skeleton.dtsi"
4
5/ {
6 model = "Qualcomm MSM8974";
7 compatible = "qcom,msm8974";
8 interrupt-parent = <&intc>;
9
10 soc: soc {
11 #address-cells = <1>;
12 #size-cells = <1>;
13 ranges;
14 compatible = "simple-bus";
15
16 intc: interrupt-controller@f9000000 {
17 compatible = "qcom,msm-qgic2";
18 interrupt-controller;
19 #interrupt-cells = <3>;
20 reg = <0xf9000000 0x1000>,
21 <0xf9002000 0x1000>;
22 };
23
24 timer {
25 compatible = "arm,armv7-timer";
26 interrupts = <1 2 0xf08>,
27 <1 3 0xf08>,
28 <1 4 0xf08>,
29 <1 1 0xf08>;
30 clock-frequency = <19200000>;
31 };
32 };
33};
diff --git a/arch/arm/boot/dts/sun6i-a31.dtsi b/arch/arm/boot/dts/sun6i-a31.dtsi
index c1751a64889a..7f5878c2784a 100644
--- a/arch/arm/boot/dts/sun6i-a31.dtsi
+++ b/arch/arm/boot/dts/sun6i-a31.dtsi
@@ -193,7 +193,10 @@
193 pio: pinctrl@01c20800 { 193 pio: pinctrl@01c20800 {
194 compatible = "allwinner,sun6i-a31-pinctrl"; 194 compatible = "allwinner,sun6i-a31-pinctrl";
195 reg = <0x01c20800 0x400>; 195 reg = <0x01c20800 0x400>;
196 interrupts = <0 11 1>, <0 15 1>, <0 16 1>, <0 17 1>; 196 interrupts = <0 11 4>,
197 <0 15 4>,
198 <0 16 4>,
199 <0 17 4>;
197 clocks = <&apb1_gates 5>; 200 clocks = <&apb1_gates 5>;
198 gpio-controller; 201 gpio-controller;
199 interrupt-controller; 202 interrupt-controller;
@@ -212,11 +215,11 @@
212 timer@01c20c00 { 215 timer@01c20c00 {
213 compatible = "allwinner,sun4i-timer"; 216 compatible = "allwinner,sun4i-timer";
214 reg = <0x01c20c00 0xa0>; 217 reg = <0x01c20c00 0xa0>;
215 interrupts = <0 18 1>, 218 interrupts = <0 18 4>,
216 <0 19 1>, 219 <0 19 4>,
217 <0 20 1>, 220 <0 20 4>,
218 <0 21 1>, 221 <0 21 4>,
219 <0 22 1>; 222 <0 22 4>;
220 clocks = <&osc24M>; 223 clocks = <&osc24M>;
221 }; 224 };
222 225
@@ -228,7 +231,7 @@
228 uart0: serial@01c28000 { 231 uart0: serial@01c28000 {
229 compatible = "snps,dw-apb-uart"; 232 compatible = "snps,dw-apb-uart";
230 reg = <0x01c28000 0x400>; 233 reg = <0x01c28000 0x400>;
231 interrupts = <0 0 1>; 234 interrupts = <0 0 4>;
232 reg-shift = <2>; 235 reg-shift = <2>;
233 reg-io-width = <4>; 236 reg-io-width = <4>;
234 clocks = <&apb2_gates 16>; 237 clocks = <&apb2_gates 16>;
@@ -238,7 +241,7 @@
238 uart1: serial@01c28400 { 241 uart1: serial@01c28400 {
239 compatible = "snps,dw-apb-uart"; 242 compatible = "snps,dw-apb-uart";
240 reg = <0x01c28400 0x400>; 243 reg = <0x01c28400 0x400>;
241 interrupts = <0 1 1>; 244 interrupts = <0 1 4>;
242 reg-shift = <2>; 245 reg-shift = <2>;
243 reg-io-width = <4>; 246 reg-io-width = <4>;
244 clocks = <&apb2_gates 17>; 247 clocks = <&apb2_gates 17>;
@@ -248,7 +251,7 @@
248 uart2: serial@01c28800 { 251 uart2: serial@01c28800 {
249 compatible = "snps,dw-apb-uart"; 252 compatible = "snps,dw-apb-uart";
250 reg = <0x01c28800 0x400>; 253 reg = <0x01c28800 0x400>;
251 interrupts = <0 2 1>; 254 interrupts = <0 2 4>;
252 reg-shift = <2>; 255 reg-shift = <2>;
253 reg-io-width = <4>; 256 reg-io-width = <4>;
254 clocks = <&apb2_gates 18>; 257 clocks = <&apb2_gates 18>;
@@ -258,7 +261,7 @@
258 uart3: serial@01c28c00 { 261 uart3: serial@01c28c00 {
259 compatible = "snps,dw-apb-uart"; 262 compatible = "snps,dw-apb-uart";
260 reg = <0x01c28c00 0x400>; 263 reg = <0x01c28c00 0x400>;
261 interrupts = <0 3 1>; 264 interrupts = <0 3 4>;
262 reg-shift = <2>; 265 reg-shift = <2>;
263 reg-io-width = <4>; 266 reg-io-width = <4>;
264 clocks = <&apb2_gates 19>; 267 clocks = <&apb2_gates 19>;
@@ -268,7 +271,7 @@
268 uart4: serial@01c29000 { 271 uart4: serial@01c29000 {
269 compatible = "snps,dw-apb-uart"; 272 compatible = "snps,dw-apb-uart";
270 reg = <0x01c29000 0x400>; 273 reg = <0x01c29000 0x400>;
271 interrupts = <0 4 1>; 274 interrupts = <0 4 4>;
272 reg-shift = <2>; 275 reg-shift = <2>;
273 reg-io-width = <4>; 276 reg-io-width = <4>;
274 clocks = <&apb2_gates 20>; 277 clocks = <&apb2_gates 20>;
@@ -278,7 +281,7 @@
278 uart5: serial@01c29400 { 281 uart5: serial@01c29400 {
279 compatible = "snps,dw-apb-uart"; 282 compatible = "snps,dw-apb-uart";
280 reg = <0x01c29400 0x400>; 283 reg = <0x01c29400 0x400>;
281 interrupts = <0 5 1>; 284 interrupts = <0 5 4>;
282 reg-shift = <2>; 285 reg-shift = <2>;
283 reg-io-width = <4>; 286 reg-io-width = <4>;
284 clocks = <&apb2_gates 21>; 287 clocks = <&apb2_gates 21>;
diff --git a/arch/arm/boot/dts/sun7i-a20.dtsi b/arch/arm/boot/dts/sun7i-a20.dtsi
index e46cfedde74c..367611a0730b 100644
--- a/arch/arm/boot/dts/sun7i-a20.dtsi
+++ b/arch/arm/boot/dts/sun7i-a20.dtsi
@@ -170,7 +170,7 @@
170 emac: ethernet@01c0b000 { 170 emac: ethernet@01c0b000 {
171 compatible = "allwinner,sun4i-emac"; 171 compatible = "allwinner,sun4i-emac";
172 reg = <0x01c0b000 0x1000>; 172 reg = <0x01c0b000 0x1000>;
173 interrupts = <0 55 1>; 173 interrupts = <0 55 4>;
174 clocks = <&ahb_gates 17>; 174 clocks = <&ahb_gates 17>;
175 status = "disabled"; 175 status = "disabled";
176 }; 176 };
@@ -186,7 +186,7 @@
186 pio: pinctrl@01c20800 { 186 pio: pinctrl@01c20800 {
187 compatible = "allwinner,sun7i-a20-pinctrl"; 187 compatible = "allwinner,sun7i-a20-pinctrl";
188 reg = <0x01c20800 0x400>; 188 reg = <0x01c20800 0x400>;
189 interrupts = <0 28 1>; 189 interrupts = <0 28 4>;
190 clocks = <&apb0_gates 5>; 190 clocks = <&apb0_gates 5>;
191 gpio-controller; 191 gpio-controller;
192 interrupt-controller; 192 interrupt-controller;
@@ -251,12 +251,12 @@
251 timer@01c20c00 { 251 timer@01c20c00 {
252 compatible = "allwinner,sun4i-timer"; 252 compatible = "allwinner,sun4i-timer";
253 reg = <0x01c20c00 0x90>; 253 reg = <0x01c20c00 0x90>;
254 interrupts = <0 22 1>, 254 interrupts = <0 22 4>,
255 <0 23 1>, 255 <0 23 4>,
256 <0 24 1>, 256 <0 24 4>,
257 <0 25 1>, 257 <0 25 4>,
258 <0 67 1>, 258 <0 67 4>,
259 <0 68 1>; 259 <0 68 4>;
260 clocks = <&osc24M>; 260 clocks = <&osc24M>;
261 }; 261 };
262 262
@@ -273,7 +273,7 @@
273 uart0: serial@01c28000 { 273 uart0: serial@01c28000 {
274 compatible = "snps,dw-apb-uart"; 274 compatible = "snps,dw-apb-uart";
275 reg = <0x01c28000 0x400>; 275 reg = <0x01c28000 0x400>;
276 interrupts = <0 1 1>; 276 interrupts = <0 1 4>;
277 reg-shift = <2>; 277 reg-shift = <2>;
278 reg-io-width = <4>; 278 reg-io-width = <4>;
279 clocks = <&apb1_gates 16>; 279 clocks = <&apb1_gates 16>;
@@ -283,7 +283,7 @@
283 uart1: serial@01c28400 { 283 uart1: serial@01c28400 {
284 compatible = "snps,dw-apb-uart"; 284 compatible = "snps,dw-apb-uart";
285 reg = <0x01c28400 0x400>; 285 reg = <0x01c28400 0x400>;
286 interrupts = <0 2 1>; 286 interrupts = <0 2 4>;
287 reg-shift = <2>; 287 reg-shift = <2>;
288 reg-io-width = <4>; 288 reg-io-width = <4>;
289 clocks = <&apb1_gates 17>; 289 clocks = <&apb1_gates 17>;
@@ -293,7 +293,7 @@
293 uart2: serial@01c28800 { 293 uart2: serial@01c28800 {
294 compatible = "snps,dw-apb-uart"; 294 compatible = "snps,dw-apb-uart";
295 reg = <0x01c28800 0x400>; 295 reg = <0x01c28800 0x400>;
296 interrupts = <0 3 1>; 296 interrupts = <0 3 4>;
297 reg-shift = <2>; 297 reg-shift = <2>;
298 reg-io-width = <4>; 298 reg-io-width = <4>;
299 clocks = <&apb1_gates 18>; 299 clocks = <&apb1_gates 18>;
@@ -303,7 +303,7 @@
303 uart3: serial@01c28c00 { 303 uart3: serial@01c28c00 {
304 compatible = "snps,dw-apb-uart"; 304 compatible = "snps,dw-apb-uart";
305 reg = <0x01c28c00 0x400>; 305 reg = <0x01c28c00 0x400>;
306 interrupts = <0 4 1>; 306 interrupts = <0 4 4>;
307 reg-shift = <2>; 307 reg-shift = <2>;
308 reg-io-width = <4>; 308 reg-io-width = <4>;
309 clocks = <&apb1_gates 19>; 309 clocks = <&apb1_gates 19>;
@@ -313,7 +313,7 @@
313 uart4: serial@01c29000 { 313 uart4: serial@01c29000 {
314 compatible = "snps,dw-apb-uart"; 314 compatible = "snps,dw-apb-uart";
315 reg = <0x01c29000 0x400>; 315 reg = <0x01c29000 0x400>;
316 interrupts = <0 17 1>; 316 interrupts = <0 17 4>;
317 reg-shift = <2>; 317 reg-shift = <2>;
318 reg-io-width = <4>; 318 reg-io-width = <4>;
319 clocks = <&apb1_gates 20>; 319 clocks = <&apb1_gates 20>;
@@ -323,7 +323,7 @@
323 uart5: serial@01c29400 { 323 uart5: serial@01c29400 {
324 compatible = "snps,dw-apb-uart"; 324 compatible = "snps,dw-apb-uart";
325 reg = <0x01c29400 0x400>; 325 reg = <0x01c29400 0x400>;
326 interrupts = <0 18 1>; 326 interrupts = <0 18 4>;
327 reg-shift = <2>; 327 reg-shift = <2>;
328 reg-io-width = <4>; 328 reg-io-width = <4>;
329 clocks = <&apb1_gates 21>; 329 clocks = <&apb1_gates 21>;
@@ -333,7 +333,7 @@
333 uart6: serial@01c29800 { 333 uart6: serial@01c29800 {
334 compatible = "snps,dw-apb-uart"; 334 compatible = "snps,dw-apb-uart";
335 reg = <0x01c29800 0x400>; 335 reg = <0x01c29800 0x400>;
336 interrupts = <0 19 1>; 336 interrupts = <0 19 4>;
337 reg-shift = <2>; 337 reg-shift = <2>;
338 reg-io-width = <4>; 338 reg-io-width = <4>;
339 clocks = <&apb1_gates 22>; 339 clocks = <&apb1_gates 22>;
@@ -343,7 +343,7 @@
343 uart7: serial@01c29c00 { 343 uart7: serial@01c29c00 {
344 compatible = "snps,dw-apb-uart"; 344 compatible = "snps,dw-apb-uart";
345 reg = <0x01c29c00 0x400>; 345 reg = <0x01c29c00 0x400>;
346 interrupts = <0 20 1>; 346 interrupts = <0 20 4>;
347 reg-shift = <2>; 347 reg-shift = <2>;
348 reg-io-width = <4>; 348 reg-io-width = <4>;
349 clocks = <&apb1_gates 23>; 349 clocks = <&apb1_gates 23>;
@@ -353,7 +353,7 @@
353 i2c0: i2c@01c2ac00 { 353 i2c0: i2c@01c2ac00 {
354 compatible = "allwinner,sun4i-i2c"; 354 compatible = "allwinner,sun4i-i2c";
355 reg = <0x01c2ac00 0x400>; 355 reg = <0x01c2ac00 0x400>;
356 interrupts = <0 7 1>; 356 interrupts = <0 7 4>;
357 clocks = <&apb1_gates 0>; 357 clocks = <&apb1_gates 0>;
358 clock-frequency = <100000>; 358 clock-frequency = <100000>;
359 status = "disabled"; 359 status = "disabled";
@@ -362,7 +362,7 @@
362 i2c1: i2c@01c2b000 { 362 i2c1: i2c@01c2b000 {
363 compatible = "allwinner,sun4i-i2c"; 363 compatible = "allwinner,sun4i-i2c";
364 reg = <0x01c2b000 0x400>; 364 reg = <0x01c2b000 0x400>;
365 interrupts = <0 8 1>; 365 interrupts = <0 8 4>;
366 clocks = <&apb1_gates 1>; 366 clocks = <&apb1_gates 1>;
367 clock-frequency = <100000>; 367 clock-frequency = <100000>;
368 status = "disabled"; 368 status = "disabled";
@@ -371,7 +371,7 @@
371 i2c2: i2c@01c2b400 { 371 i2c2: i2c@01c2b400 {
372 compatible = "allwinner,sun4i-i2c"; 372 compatible = "allwinner,sun4i-i2c";
373 reg = <0x01c2b400 0x400>; 373 reg = <0x01c2b400 0x400>;
374 interrupts = <0 9 1>; 374 interrupts = <0 9 4>;
375 clocks = <&apb1_gates 2>; 375 clocks = <&apb1_gates 2>;
376 clock-frequency = <100000>; 376 clock-frequency = <100000>;
377 status = "disabled"; 377 status = "disabled";
@@ -380,7 +380,7 @@
380 i2c3: i2c@01c2b800 { 380 i2c3: i2c@01c2b800 {
381 compatible = "allwinner,sun4i-i2c"; 381 compatible = "allwinner,sun4i-i2c";
382 reg = <0x01c2b800 0x400>; 382 reg = <0x01c2b800 0x400>;
383 interrupts = <0 88 1>; 383 interrupts = <0 88 4>;
384 clocks = <&apb1_gates 3>; 384 clocks = <&apb1_gates 3>;
385 clock-frequency = <100000>; 385 clock-frequency = <100000>;
386 status = "disabled"; 386 status = "disabled";
@@ -389,7 +389,7 @@
389 i2c4: i2c@01c2bc00 { 389 i2c4: i2c@01c2bc00 {
390 compatible = "allwinner,sun4i-i2c"; 390 compatible = "allwinner,sun4i-i2c";
391 reg = <0x01c2bc00 0x400>; 391 reg = <0x01c2bc00 0x400>;
392 interrupts = <0 89 1>; 392 interrupts = <0 89 4>;
393 clocks = <&apb1_gates 15>; 393 clocks = <&apb1_gates 15>;
394 clock-frequency = <100000>; 394 clock-frequency = <100000>;
395 status = "disabled"; 395 status = "disabled";
diff --git a/arch/arm/boot/dts/tegra114.dtsi b/arch/arm/boot/dts/tegra114.dtsi
index 8d42787c8ff1..731249fbe206 100644
--- a/arch/arm/boot/dts/tegra114.dtsi
+++ b/arch/arm/boot/dts/tegra114.dtsi
@@ -43,6 +43,7 @@
43 compatible = "nvidia,tegra114-car"; 43 compatible = "nvidia,tegra114-car";
44 reg = <0x60006000 0x1000>; 44 reg = <0x60006000 0x1000>;
45 #clock-cells = <1>; 45 #clock-cells = <1>;
46 #reset-cells = <1>;
46 }; 47 };
47 48
48 apbdma: dma { 49 apbdma: dma {
@@ -81,6 +82,9 @@
81 <GIC_SPI 142 IRQ_TYPE_LEVEL_HIGH>, 82 <GIC_SPI 142 IRQ_TYPE_LEVEL_HIGH>,
82 <GIC_SPI 143 IRQ_TYPE_LEVEL_HIGH>; 83 <GIC_SPI 143 IRQ_TYPE_LEVEL_HIGH>;
83 clocks = <&tegra_car TEGRA114_CLK_APBDMA>; 84 clocks = <&tegra_car TEGRA114_CLK_APBDMA>;
85 resets = <&tegra_car 34>;
86 reset-names = "dma";
87 #dma-cells = <1>;
84 }; 88 };
85 89
86 ahb: ahb { 90 ahb: ahb {
@@ -124,9 +128,12 @@
124 reg = <0x70006000 0x40>; 128 reg = <0x70006000 0x40>;
125 reg-shift = <2>; 129 reg-shift = <2>;
126 interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>; 130 interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>;
127 nvidia,dma-request-selector = <&apbdma 8>;
128 status = "disabled";
129 clocks = <&tegra_car TEGRA114_CLK_UARTA>; 131 clocks = <&tegra_car TEGRA114_CLK_UARTA>;
132 resets = <&tegra_car 6>;
133 reset-names = "serial";
134 dmas = <&apbdma 8>, <&apbdma 8>;
135 dma-names = "rx", "tx";
136 status = "disabled";
130 }; 137 };
131 138
132 uartb: serial@70006040 { 139 uartb: serial@70006040 {
@@ -134,9 +141,12 @@
134 reg = <0x70006040 0x40>; 141 reg = <0x70006040 0x40>;
135 reg-shift = <2>; 142 reg-shift = <2>;
136 interrupts = <GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>; 143 interrupts = <GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>;
137 nvidia,dma-request-selector = <&apbdma 9>;
138 status = "disabled";
139 clocks = <&tegra_car TEGRA114_CLK_UARTB>; 144 clocks = <&tegra_car TEGRA114_CLK_UARTB>;
145 resets = <&tegra_car 7>;
146 reset-names = "serial";
147 dmas = <&apbdma 9>, <&apbdma 9>;
148 dma-names = "rx", "tx";
149 status = "disabled";
140 }; 150 };
141 151
142 uartc: serial@70006200 { 152 uartc: serial@70006200 {
@@ -144,9 +154,12 @@
144 reg = <0x70006200 0x100>; 154 reg = <0x70006200 0x100>;
145 reg-shift = <2>; 155 reg-shift = <2>;
146 interrupts = <GIC_SPI 46 IRQ_TYPE_LEVEL_HIGH>; 156 interrupts = <GIC_SPI 46 IRQ_TYPE_LEVEL_HIGH>;
147 nvidia,dma-request-selector = <&apbdma 10>;
148 status = "disabled";
149 clocks = <&tegra_car TEGRA114_CLK_UARTC>; 157 clocks = <&tegra_car TEGRA114_CLK_UARTC>;
158 resets = <&tegra_car 55>;
159 reset-names = "serial";
160 dmas = <&apbdma 10>, <&apbdma 10>;
161 dma-names = "rx", "tx";
162 status = "disabled";
150 }; 163 };
151 164
152 uartd: serial@70006300 { 165 uartd: serial@70006300 {
@@ -154,9 +167,12 @@
154 reg = <0x70006300 0x100>; 167 reg = <0x70006300 0x100>;
155 reg-shift = <2>; 168 reg-shift = <2>;
156 interrupts = <GIC_SPI 90 IRQ_TYPE_LEVEL_HIGH>; 169 interrupts = <GIC_SPI 90 IRQ_TYPE_LEVEL_HIGH>;
157 nvidia,dma-request-selector = <&apbdma 19>;
158 status = "disabled";
159 clocks = <&tegra_car TEGRA114_CLK_UARTD>; 170 clocks = <&tegra_car TEGRA114_CLK_UARTD>;
171 resets = <&tegra_car 65>;
172 reset-names = "serial";
173 dmas = <&apbdma 19>, <&apbdma 19>;
174 dma-names = "rx", "tx";
175 status = "disabled";
160 }; 176 };
161 177
162 pwm: pwm { 178 pwm: pwm {
@@ -164,6 +180,8 @@
164 reg = <0x7000a000 0x100>; 180 reg = <0x7000a000 0x100>;
165 #pwm-cells = <2>; 181 #pwm-cells = <2>;
166 clocks = <&tegra_car TEGRA114_CLK_PWM>; 182 clocks = <&tegra_car TEGRA114_CLK_PWM>;
183 resets = <&tegra_car 17>;
184 reset-names = "pwm";
167 status = "disabled"; 185 status = "disabled";
168 }; 186 };
169 187
@@ -175,6 +193,10 @@
175 #size-cells = <0>; 193 #size-cells = <0>;
176 clocks = <&tegra_car TEGRA114_CLK_I2C1>; 194 clocks = <&tegra_car TEGRA114_CLK_I2C1>;
177 clock-names = "div-clk"; 195 clock-names = "div-clk";
196 resets = <&tegra_car 12>;
197 reset-names = "i2c";
198 dmas = <&apbdma 21>, <&apbdma 21>;
199 dma-names = "rx", "tx";
178 status = "disabled"; 200 status = "disabled";
179 }; 201 };
180 202
@@ -186,6 +208,10 @@
186 #size-cells = <0>; 208 #size-cells = <0>;
187 clocks = <&tegra_car TEGRA114_CLK_I2C2>; 209 clocks = <&tegra_car TEGRA114_CLK_I2C2>;
188 clock-names = "div-clk"; 210 clock-names = "div-clk";
211 resets = <&tegra_car 54>;
212 reset-names = "i2c";
213 dmas = <&apbdma 22>, <&apbdma 22>;
214 dma-names = "rx", "tx";
189 status = "disabled"; 215 status = "disabled";
190 }; 216 };
191 217
@@ -197,6 +223,10 @@
197 #size-cells = <0>; 223 #size-cells = <0>;
198 clocks = <&tegra_car TEGRA114_CLK_I2C3>; 224 clocks = <&tegra_car TEGRA114_CLK_I2C3>;
199 clock-names = "div-clk"; 225 clock-names = "div-clk";
226 resets = <&tegra_car 67>;
227 reset-names = "i2c";
228 dmas = <&apbdma 23>, <&apbdma 23>;
229 dma-names = "rx", "tx";
200 status = "disabled"; 230 status = "disabled";
201 }; 231 };
202 232
@@ -208,6 +238,10 @@
208 #size-cells = <0>; 238 #size-cells = <0>;
209 clocks = <&tegra_car TEGRA114_CLK_I2C4>; 239 clocks = <&tegra_car TEGRA114_CLK_I2C4>;
210 clock-names = "div-clk"; 240 clock-names = "div-clk";
241 resets = <&tegra_car 103>;
242 reset-names = "i2c";
243 dmas = <&apbdma 26>, <&apbdma 26>;
244 dma-names = "rx", "tx";
211 status = "disabled"; 245 status = "disabled";
212 }; 246 };
213 247
@@ -219,6 +253,10 @@
219 #size-cells = <0>; 253 #size-cells = <0>;
220 clocks = <&tegra_car TEGRA114_CLK_I2C5>; 254 clocks = <&tegra_car TEGRA114_CLK_I2C5>;
221 clock-names = "div-clk"; 255 clock-names = "div-clk";
256 resets = <&tegra_car 47>;
257 reset-names = "i2c";
258 dmas = <&apbdma 24>, <&apbdma 24>;
259 dma-names = "rx", "tx";
222 status = "disabled"; 260 status = "disabled";
223 }; 261 };
224 262
@@ -226,11 +264,14 @@
226 compatible = "nvidia,tegra114-spi"; 264 compatible = "nvidia,tegra114-spi";
227 reg = <0x7000d400 0x200>; 265 reg = <0x7000d400 0x200>;
228 interrupts = <GIC_SPI 59 IRQ_TYPE_LEVEL_HIGH>; 266 interrupts = <GIC_SPI 59 IRQ_TYPE_LEVEL_HIGH>;
229 nvidia,dma-request-selector = <&apbdma 15>;
230 #address-cells = <1>; 267 #address-cells = <1>;
231 #size-cells = <0>; 268 #size-cells = <0>;
232 clocks = <&tegra_car TEGRA114_CLK_SBC1>; 269 clocks = <&tegra_car TEGRA114_CLK_SBC1>;
233 clock-names = "spi"; 270 clock-names = "spi";
271 resets = <&tegra_car 41>;
272 reset-names = "spi";
273 dmas = <&apbdma 15>, <&apbdma 15>;
274 dma-names = "rx", "tx";
234 status = "disabled"; 275 status = "disabled";
235 }; 276 };
236 277
@@ -238,11 +279,14 @@
238 compatible = "nvidia,tegra114-spi"; 279 compatible = "nvidia,tegra114-spi";
239 reg = <0x7000d600 0x200>; 280 reg = <0x7000d600 0x200>;
240 interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>; 281 interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>;
241 nvidia,dma-request-selector = <&apbdma 16>;
242 #address-cells = <1>; 282 #address-cells = <1>;
243 #size-cells = <0>; 283 #size-cells = <0>;
244 clocks = <&tegra_car TEGRA114_CLK_SBC2>; 284 clocks = <&tegra_car TEGRA114_CLK_SBC2>;
245 clock-names = "spi"; 285 clock-names = "spi";
286 resets = <&tegra_car 44>;
287 reset-names = "spi";
288 dmas = <&apbdma 16>, <&apbdma 16>;
289 dma-names = "rx", "tx";
246 status = "disabled"; 290 status = "disabled";
247 }; 291 };
248 292
@@ -250,11 +294,14 @@
250 compatible = "nvidia,tegra114-spi"; 294 compatible = "nvidia,tegra114-spi";
251 reg = <0x7000d800 0x200>; 295 reg = <0x7000d800 0x200>;
252 interrupts = <GIC_SPI 83 IRQ_TYPE_LEVEL_HIGH>; 296 interrupts = <GIC_SPI 83 IRQ_TYPE_LEVEL_HIGH>;
253 nvidia,dma-request-selector = <&apbdma 17>;
254 #address-cells = <1>; 297 #address-cells = <1>;
255 #size-cells = <0>; 298 #size-cells = <0>;
256 clocks = <&tegra_car TEGRA114_CLK_SBC3>; 299 clocks = <&tegra_car TEGRA114_CLK_SBC3>;
257 clock-names = "spi"; 300 clock-names = "spi";
301 resets = <&tegra_car 46>;
302 reset-names = "spi";
303 dmas = <&apbdma 17>, <&apbdma 17>;
304 dma-names = "rx", "tx";
258 status = "disabled"; 305 status = "disabled";
259 }; 306 };
260 307
@@ -262,11 +309,14 @@
262 compatible = "nvidia,tegra114-spi"; 309 compatible = "nvidia,tegra114-spi";
263 reg = <0x7000da00 0x200>; 310 reg = <0x7000da00 0x200>;
264 interrupts = <GIC_SPI 93 IRQ_TYPE_LEVEL_HIGH>; 311 interrupts = <GIC_SPI 93 IRQ_TYPE_LEVEL_HIGH>;
265 nvidia,dma-request-selector = <&apbdma 18>;
266 #address-cells = <1>; 312 #address-cells = <1>;
267 #size-cells = <0>; 313 #size-cells = <0>;
268 clocks = <&tegra_car TEGRA114_CLK_SBC4>; 314 clocks = <&tegra_car TEGRA114_CLK_SBC4>;
269 clock-names = "spi"; 315 clock-names = "spi";
316 resets = <&tegra_car 68>;
317 reset-names = "spi";
318 dmas = <&apbdma 18>, <&apbdma 18>;
319 dma-names = "rx", "tx";
270 status = "disabled"; 320 status = "disabled";
271 }; 321 };
272 322
@@ -274,11 +324,14 @@
274 compatible = "nvidia,tegra114-spi"; 324 compatible = "nvidia,tegra114-spi";
275 reg = <0x7000dc00 0x200>; 325 reg = <0x7000dc00 0x200>;
276 interrupts = <GIC_SPI 94 IRQ_TYPE_LEVEL_HIGH>; 326 interrupts = <GIC_SPI 94 IRQ_TYPE_LEVEL_HIGH>;
277 nvidia,dma-request-selector = <&apbdma 27>;
278 #address-cells = <1>; 327 #address-cells = <1>;
279 #size-cells = <0>; 328 #size-cells = <0>;
280 clocks = <&tegra_car TEGRA114_CLK_SBC5>; 329 clocks = <&tegra_car TEGRA114_CLK_SBC5>;
281 clock-names = "spi"; 330 clock-names = "spi";
331 resets = <&tegra_car 104>;
332 reset-names = "spi";
333 dmas = <&apbdma 27>, <&apbdma 27>;
334 dma-names = "rx", "tx";
282 status = "disabled"; 335 status = "disabled";
283 }; 336 };
284 337
@@ -286,11 +339,14 @@
286 compatible = "nvidia,tegra114-spi"; 339 compatible = "nvidia,tegra114-spi";
287 reg = <0x7000de00 0x200>; 340 reg = <0x7000de00 0x200>;
288 interrupts = <GIC_SPI 79 IRQ_TYPE_LEVEL_HIGH>; 341 interrupts = <GIC_SPI 79 IRQ_TYPE_LEVEL_HIGH>;
289 nvidia,dma-request-selector = <&apbdma 28>;
290 #address-cells = <1>; 342 #address-cells = <1>;
291 #size-cells = <0>; 343 #size-cells = <0>;
292 clocks = <&tegra_car TEGRA114_CLK_SBC6>; 344 clocks = <&tegra_car TEGRA114_CLK_SBC6>;
293 clock-names = "spi"; 345 clock-names = "spi";
346 resets = <&tegra_car 105>;
347 reset-names = "spi";
348 dmas = <&apbdma 28>, <&apbdma 28>;
349 dma-names = "rx", "tx";
294 status = "disabled"; 350 status = "disabled";
295 }; 351 };
296 352
@@ -306,6 +362,8 @@
306 reg = <0x7000e200 0x100>; 362 reg = <0x7000e200 0x100>;
307 interrupts = <GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>; 363 interrupts = <GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>;
308 clocks = <&tegra_car TEGRA114_CLK_KBC>; 364 clocks = <&tegra_car TEGRA114_CLK_KBC>;
365 resets = <&tegra_car 36>;
366 reset-names = "kbc";
309 status = "disabled"; 367 status = "disabled";
310 }; 368 };
311 369
@@ -333,26 +391,39 @@
333 <0x70080200 0x100>, 391 <0x70080200 0x100>,
334 <0x70081000 0x200>; 392 <0x70081000 0x200>;
335 interrupts = <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>; 393 interrupts = <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>;
336 nvidia,dma-request-selector = <&apbdma 1>, <&apbdma 2>,
337 <&apbdma 3>, <&apbdma 4>, <&apbdma 6>, <&apbdma 7>,
338 <&apbdma 12>, <&apbdma 13>, <&apbdma 14>,
339 <&apbdma 29>;
340 clocks = <&tegra_car TEGRA114_CLK_D_AUDIO>, 394 clocks = <&tegra_car TEGRA114_CLK_D_AUDIO>,
341 <&tegra_car TEGRA114_CLK_APBIF>, 395 <&tegra_car TEGRA114_CLK_APBIF>;
342 <&tegra_car TEGRA114_CLK_I2S0>, 396 clock-names = "d_audio", "apbif";
343 <&tegra_car TEGRA114_CLK_I2S1>, 397 resets = <&tegra_car 106>, /* d_audio */
344 <&tegra_car TEGRA114_CLK_I2S2>, 398 <&tegra_car 107>, /* apbif */
345 <&tegra_car TEGRA114_CLK_I2S3>, 399 <&tegra_car 30>, /* i2s0 */
346 <&tegra_car TEGRA114_CLK_I2S4>, 400 <&tegra_car 11>, /* i2s1 */
347 <&tegra_car TEGRA114_CLK_DAM0>, 401 <&tegra_car 18>, /* i2s2 */
348 <&tegra_car TEGRA114_CLK_DAM1>, 402 <&tegra_car 101>, /* i2s3 */
349 <&tegra_car TEGRA114_CLK_DAM2>, 403 <&tegra_car 102>, /* i2s4 */
350 <&tegra_car TEGRA114_CLK_SPDIF_IN>, 404 <&tegra_car 108>, /* dam0 */
351 <&tegra_car TEGRA114_CLK_AMX>, 405 <&tegra_car 109>, /* dam1 */
352 <&tegra_car TEGRA114_CLK_ADX>; 406 <&tegra_car 110>, /* dam2 */
353 clock-names = "d_audio", "apbif", "i2s0", "i2s1", "i2s2", 407 <&tegra_car 10>, /* spdif */
408 <&tegra_car 153>, /* amx */
409 <&tegra_car 154>; /* adx */
410 reset-names = "d_audio", "apbif", "i2s0", "i2s1", "i2s2",
354 "i2s3", "i2s4", "dam0", "dam1", "dam2", 411 "i2s3", "i2s4", "dam0", "dam1", "dam2",
355 "spdif_in", "amx", "adx"; 412 "spdif", "amx", "adx";
413 dmas = <&apbdma 1>, <&apbdma 1>,
414 <&apbdma 2>, <&apbdma 2>,
415 <&apbdma 3>, <&apbdma 3>,
416 <&apbdma 4>, <&apbdma 4>,
417 <&apbdma 6>, <&apbdma 6>,
418 <&apbdma 7>, <&apbdma 7>,
419 <&apbdma 12>, <&apbdma 12>,
420 <&apbdma 13>, <&apbdma 13>,
421 <&apbdma 14>, <&apbdma 14>,
422 <&apbdma 29>, <&apbdma 29>;
423 dma-names = "rx0", "tx0", "rx1", "tx1", "rx2", "tx2",
424 "rx3", "tx3", "rx4", "tx4", "rx5", "tx5",
425 "rx6", "tx6", "rx7", "tx7", "rx8", "tx8",
426 "rx9", "tx9";
356 ranges; 427 ranges;
357 #address-cells = <1>; 428 #address-cells = <1>;
358 #size-cells = <1>; 429 #size-cells = <1>;
@@ -362,6 +433,8 @@
362 reg = <0x70080300 0x100>; 433 reg = <0x70080300 0x100>;
363 nvidia,ahub-cif-ids = <4 4>; 434 nvidia,ahub-cif-ids = <4 4>;
364 clocks = <&tegra_car TEGRA114_CLK_I2S0>; 435 clocks = <&tegra_car TEGRA114_CLK_I2S0>;
436 resets = <&tegra_car 30>;
437 reset-names = "i2s";
365 status = "disabled"; 438 status = "disabled";
366 }; 439 };
367 440
@@ -370,6 +443,8 @@
370 reg = <0x70080400 0x100>; 443 reg = <0x70080400 0x100>;
371 nvidia,ahub-cif-ids = <5 5>; 444 nvidia,ahub-cif-ids = <5 5>;
372 clocks = <&tegra_car TEGRA114_CLK_I2S1>; 445 clocks = <&tegra_car TEGRA114_CLK_I2S1>;
446 resets = <&tegra_car 11>;
447 reset-names = "i2s";
373 status = "disabled"; 448 status = "disabled";
374 }; 449 };
375 450
@@ -378,6 +453,8 @@
378 reg = <0x70080500 0x100>; 453 reg = <0x70080500 0x100>;
379 nvidia,ahub-cif-ids = <6 6>; 454 nvidia,ahub-cif-ids = <6 6>;
380 clocks = <&tegra_car TEGRA114_CLK_I2S2>; 455 clocks = <&tegra_car TEGRA114_CLK_I2S2>;
456 resets = <&tegra_car 18>;
457 reset-names = "i2s";
381 status = "disabled"; 458 status = "disabled";
382 }; 459 };
383 460
@@ -386,6 +463,8 @@
386 reg = <0x70080600 0x100>; 463 reg = <0x70080600 0x100>;
387 nvidia,ahub-cif-ids = <7 7>; 464 nvidia,ahub-cif-ids = <7 7>;
388 clocks = <&tegra_car TEGRA114_CLK_I2S3>; 465 clocks = <&tegra_car TEGRA114_CLK_I2S3>;
466 resets = <&tegra_car 101>;
467 reset-names = "i2s";
389 status = "disabled"; 468 status = "disabled";
390 }; 469 };
391 470
@@ -394,6 +473,8 @@
394 reg = <0x70080700 0x100>; 473 reg = <0x70080700 0x100>;
395 nvidia,ahub-cif-ids = <8 8>; 474 nvidia,ahub-cif-ids = <8 8>;
396 clocks = <&tegra_car TEGRA114_CLK_I2S4>; 475 clocks = <&tegra_car TEGRA114_CLK_I2S4>;
476 resets = <&tegra_car 102>;
477 reset-names = "i2s";
397 status = "disabled"; 478 status = "disabled";
398 }; 479 };
399 }; 480 };
@@ -403,6 +484,8 @@
403 reg = <0x78000000 0x200>; 484 reg = <0x78000000 0x200>;
404 interrupts = <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>; 485 interrupts = <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>;
405 clocks = <&tegra_car TEGRA114_CLK_SDMMC1>; 486 clocks = <&tegra_car TEGRA114_CLK_SDMMC1>;
487 resets = <&tegra_car 14>;
488 reset-names = "sdhci";
406 status = "disable"; 489 status = "disable";
407 }; 490 };
408 491
@@ -411,6 +494,8 @@
411 reg = <0x78000200 0x200>; 494 reg = <0x78000200 0x200>;
412 interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>; 495 interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>;
413 clocks = <&tegra_car TEGRA114_CLK_SDMMC2>; 496 clocks = <&tegra_car TEGRA114_CLK_SDMMC2>;
497 resets = <&tegra_car 9>;
498 reset-names = "sdhci";
414 status = "disable"; 499 status = "disable";
415 }; 500 };
416 501
@@ -419,6 +504,8 @@
419 reg = <0x78000400 0x200>; 504 reg = <0x78000400 0x200>;
420 interrupts = <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>; 505 interrupts = <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>;
421 clocks = <&tegra_car TEGRA114_CLK_SDMMC3>; 506 clocks = <&tegra_car TEGRA114_CLK_SDMMC3>;
507 resets = <&tegra_car 69>;
508 reset-names = "sdhci";
422 status = "disable"; 509 status = "disable";
423 }; 510 };
424 511
@@ -427,6 +514,8 @@
427 reg = <0x78000600 0x200>; 514 reg = <0x78000600 0x200>;
428 interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>; 515 interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
429 clocks = <&tegra_car TEGRA114_CLK_SDMMC4>; 516 clocks = <&tegra_car TEGRA114_CLK_SDMMC4>;
517 resets = <&tegra_car 15>;
518 reset-names = "sdhci";
430 status = "disable"; 519 status = "disable";
431 }; 520 };
432 521
@@ -436,6 +525,8 @@
436 interrupts = <GIC_SPI 20 IRQ_TYPE_LEVEL_HIGH>; 525 interrupts = <GIC_SPI 20 IRQ_TYPE_LEVEL_HIGH>;
437 phy_type = "utmi"; 526 phy_type = "utmi";
438 clocks = <&tegra_car TEGRA114_CLK_USBD>; 527 clocks = <&tegra_car TEGRA114_CLK_USBD>;
528 resets = <&tegra_car 22>;
529 reset-names = "usb";
439 nvidia,phy = <&phy1>; 530 nvidia,phy = <&phy1>;
440 status = "disabled"; 531 status = "disabled";
441 }; 532 };
@@ -467,6 +558,8 @@
467 interrupts = <GIC_SPI 97 IRQ_TYPE_LEVEL_HIGH>; 558 interrupts = <GIC_SPI 97 IRQ_TYPE_LEVEL_HIGH>;
468 phy_type = "utmi"; 559 phy_type = "utmi";
469 clocks = <&tegra_car TEGRA114_CLK_USB3>; 560 clocks = <&tegra_car TEGRA114_CLK_USB3>;
561 resets = <&tegra_car 59>;
562 reset-names = "usb";
470 nvidia,phy = <&phy3>; 563 nvidia,phy = <&phy3>;
471 status = "disabled"; 564 status = "disabled";
472 }; 565 };
diff --git a/arch/arm/boot/dts/tegra20-paz00.dts b/arch/arm/boot/dts/tegra20-paz00.dts
index 8d71fc9d8a2f..e57fb3aefc2a 100644
--- a/arch/arm/boot/dts/tegra20-paz00.dts
+++ b/arch/arm/boot/dts/tegra20-paz00.dts
@@ -280,6 +280,8 @@
280 clocks = <&tegra_car TEGRA20_CLK_I2C3>, 280 clocks = <&tegra_car TEGRA20_CLK_I2C3>,
281 <&tegra_car TEGRA20_CLK_PLL_P_OUT3>; 281 <&tegra_car TEGRA20_CLK_PLL_P_OUT3>;
282 clock-names = "div-clk", "fast-clk"; 282 clock-names = "div-clk", "fast-clk";
283 resets = <&tegra_car 67>;
284 reset-names = "i2c";
283 }; 285 };
284 286
285 i2c@7000d000 { 287 i2c@7000d000 {
diff --git a/arch/arm/boot/dts/tegra20.dtsi b/arch/arm/boot/dts/tegra20.dtsi
index df40b54fd8bc..c90d0aac3afe 100644
--- a/arch/arm/boot/dts/tegra20.dtsi
+++ b/arch/arm/boot/dts/tegra20.dtsi
@@ -22,6 +22,8 @@
22 interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>, /* syncpt */ 22 interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>, /* syncpt */
23 <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>; /* general */ 23 <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>; /* general */
24 clocks = <&tegra_car TEGRA20_CLK_HOST1X>; 24 clocks = <&tegra_car TEGRA20_CLK_HOST1X>;
25 resets = <&tegra_car 28>;
26 reset-names = "host1x";
25 27
26 #address-cells = <1>; 28 #address-cells = <1>;
27 #size-cells = <1>; 29 #size-cells = <1>;
@@ -33,6 +35,8 @@
33 reg = <0x54040000 0x00040000>; 35 reg = <0x54040000 0x00040000>;
34 interrupts = <GIC_SPI 68 IRQ_TYPE_LEVEL_HIGH>; 36 interrupts = <GIC_SPI 68 IRQ_TYPE_LEVEL_HIGH>;
35 clocks = <&tegra_car TEGRA20_CLK_MPE>; 37 clocks = <&tegra_car TEGRA20_CLK_MPE>;
38 resets = <&tegra_car 60>;
39 reset-names = "mpe";
36 }; 40 };
37 41
38 vi { 42 vi {
@@ -40,6 +44,8 @@
40 reg = <0x54080000 0x00040000>; 44 reg = <0x54080000 0x00040000>;
41 interrupts = <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>; 45 interrupts = <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>;
42 clocks = <&tegra_car TEGRA20_CLK_VI>; 46 clocks = <&tegra_car TEGRA20_CLK_VI>;
47 resets = <&tegra_car 20>;
48 reset-names = "vi";
43 }; 49 };
44 50
45 epp { 51 epp {
@@ -47,6 +53,8 @@
47 reg = <0x540c0000 0x00040000>; 53 reg = <0x540c0000 0x00040000>;
48 interrupts = <GIC_SPI 70 IRQ_TYPE_LEVEL_HIGH>; 54 interrupts = <GIC_SPI 70 IRQ_TYPE_LEVEL_HIGH>;
49 clocks = <&tegra_car TEGRA20_CLK_EPP>; 55 clocks = <&tegra_car TEGRA20_CLK_EPP>;
56 resets = <&tegra_car 19>;
57 reset-names = "epp";
50 }; 58 };
51 59
52 isp { 60 isp {
@@ -54,6 +62,8 @@
54 reg = <0x54100000 0x00040000>; 62 reg = <0x54100000 0x00040000>;
55 interrupts = <GIC_SPI 71 IRQ_TYPE_LEVEL_HIGH>; 63 interrupts = <GIC_SPI 71 IRQ_TYPE_LEVEL_HIGH>;
56 clocks = <&tegra_car TEGRA20_CLK_ISP>; 64 clocks = <&tegra_car TEGRA20_CLK_ISP>;
65 resets = <&tegra_car 23>;
66 reset-names = "isp";
57 }; 67 };
58 68
59 gr2d { 69 gr2d {
@@ -61,12 +71,16 @@
61 reg = <0x54140000 0x00040000>; 71 reg = <0x54140000 0x00040000>;
62 interrupts = <GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH>; 72 interrupts = <GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH>;
63 clocks = <&tegra_car TEGRA20_CLK_GR2D>; 73 clocks = <&tegra_car TEGRA20_CLK_GR2D>;
74 resets = <&tegra_car 21>;
75 reset-names = "2d";
64 }; 76 };
65 77
66 gr3d { 78 gr3d {
67 compatible = "nvidia,tegra20-gr3d"; 79 compatible = "nvidia,tegra20-gr3d";
68 reg = <0x54180000 0x00040000>; 80 reg = <0x54180000 0x00040000>;
69 clocks = <&tegra_car TEGRA20_CLK_GR3D>; 81 clocks = <&tegra_car TEGRA20_CLK_GR3D>;
82 resets = <&tegra_car 24>;
83 reset-names = "3d";
70 }; 84 };
71 85
72 dc@54200000 { 86 dc@54200000 {
@@ -75,7 +89,9 @@
75 interrupts = <GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>; 89 interrupts = <GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>;
76 clocks = <&tegra_car TEGRA20_CLK_DISP1>, 90 clocks = <&tegra_car TEGRA20_CLK_DISP1>,
77 <&tegra_car TEGRA20_CLK_PLL_P>; 91 <&tegra_car TEGRA20_CLK_PLL_P>;
78 clock-names = "disp1", "parent"; 92 clock-names = "dc", "parent";
93 resets = <&tegra_car 27>;
94 reset-names = "dc";
79 95
80 rgb { 96 rgb {
81 status = "disabled"; 97 status = "disabled";
@@ -88,7 +104,9 @@
88 interrupts = <GIC_SPI 74 IRQ_TYPE_LEVEL_HIGH>; 104 interrupts = <GIC_SPI 74 IRQ_TYPE_LEVEL_HIGH>;
89 clocks = <&tegra_car TEGRA20_CLK_DISP2>, 105 clocks = <&tegra_car TEGRA20_CLK_DISP2>,
90 <&tegra_car TEGRA20_CLK_PLL_P>; 106 <&tegra_car TEGRA20_CLK_PLL_P>;
91 clock-names = "disp2", "parent"; 107 clock-names = "dc", "parent";
108 resets = <&tegra_car 26>;
109 reset-names = "dc";
92 110
93 rgb { 111 rgb {
94 status = "disabled"; 112 status = "disabled";
@@ -102,6 +120,8 @@
102 clocks = <&tegra_car TEGRA20_CLK_HDMI>, 120 clocks = <&tegra_car TEGRA20_CLK_HDMI>,
103 <&tegra_car TEGRA20_CLK_PLL_D_OUT0>; 121 <&tegra_car TEGRA20_CLK_PLL_D_OUT0>;
104 clock-names = "hdmi", "parent"; 122 clock-names = "hdmi", "parent";
123 resets = <&tegra_car 51>;
124 reset-names = "hdmi";
105 status = "disabled"; 125 status = "disabled";
106 }; 126 };
107 127
@@ -117,6 +137,8 @@
117 compatible = "nvidia,tegra20-dsi"; 137 compatible = "nvidia,tegra20-dsi";
118 reg = <0x54300000 0x00040000>; 138 reg = <0x54300000 0x00040000>;
119 clocks = <&tegra_car TEGRA20_CLK_DSI>; 139 clocks = <&tegra_car TEGRA20_CLK_DSI>;
140 resets = <&tegra_car 48>;
141 reset-names = "dsi";
120 status = "disabled"; 142 status = "disabled";
121 }; 143 };
122 }; 144 };
@@ -160,6 +182,7 @@
160 compatible = "nvidia,tegra20-car"; 182 compatible = "nvidia,tegra20-car";
161 reg = <0x60006000 0x1000>; 183 reg = <0x60006000 0x1000>;
162 #clock-cells = <1>; 184 #clock-cells = <1>;
185 #reset-cells = <1>;
163 }; 186 };
164 187
165 apbdma: dma { 188 apbdma: dma {
@@ -182,6 +205,9 @@
182 <GIC_SPI 118 IRQ_TYPE_LEVEL_HIGH>, 205 <GIC_SPI 118 IRQ_TYPE_LEVEL_HIGH>,
183 <GIC_SPI 119 IRQ_TYPE_LEVEL_HIGH>; 206 <GIC_SPI 119 IRQ_TYPE_LEVEL_HIGH>;
184 clocks = <&tegra_car TEGRA20_CLK_APBDMA>; 207 clocks = <&tegra_car TEGRA20_CLK_APBDMA>;
208 resets = <&tegra_car 34>;
209 reset-names = "dma";
210 #dma-cells = <1>;
185 }; 211 };
186 212
187 ahb { 213 ahb {
@@ -222,8 +248,11 @@
222 compatible = "nvidia,tegra20-ac97"; 248 compatible = "nvidia,tegra20-ac97";
223 reg = <0x70002000 0x200>; 249 reg = <0x70002000 0x200>;
224 interrupts = <GIC_SPI 81 IRQ_TYPE_LEVEL_HIGH>; 250 interrupts = <GIC_SPI 81 IRQ_TYPE_LEVEL_HIGH>;
225 nvidia,dma-request-selector = <&apbdma 12>;
226 clocks = <&tegra_car TEGRA20_CLK_AC97>; 251 clocks = <&tegra_car TEGRA20_CLK_AC97>;
252 resets = <&tegra_car 3>;
253 reset-names = "ac97";
254 dmas = <&apbdma 12>, <&apbdma 12>;
255 dma-names = "rx", "tx";
227 status = "disabled"; 256 status = "disabled";
228 }; 257 };
229 258
@@ -231,8 +260,11 @@
231 compatible = "nvidia,tegra20-i2s"; 260 compatible = "nvidia,tegra20-i2s";
232 reg = <0x70002800 0x200>; 261 reg = <0x70002800 0x200>;
233 interrupts = <GIC_SPI 13 IRQ_TYPE_LEVEL_HIGH>; 262 interrupts = <GIC_SPI 13 IRQ_TYPE_LEVEL_HIGH>;
234 nvidia,dma-request-selector = <&apbdma 2>;
235 clocks = <&tegra_car TEGRA20_CLK_I2S1>; 263 clocks = <&tegra_car TEGRA20_CLK_I2S1>;
264 resets = <&tegra_car 11>;
265 reset-names = "i2s";
266 dmas = <&apbdma 2>, <&apbdma 2>;
267 dma-names = "rx", "tx";
236 status = "disabled"; 268 status = "disabled";
237 }; 269 };
238 270
@@ -240,8 +272,11 @@
240 compatible = "nvidia,tegra20-i2s"; 272 compatible = "nvidia,tegra20-i2s";
241 reg = <0x70002a00 0x200>; 273 reg = <0x70002a00 0x200>;
242 interrupts = <GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>; 274 interrupts = <GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>;
243 nvidia,dma-request-selector = <&apbdma 1>;
244 clocks = <&tegra_car TEGRA20_CLK_I2S2>; 275 clocks = <&tegra_car TEGRA20_CLK_I2S2>;
276 resets = <&tegra_car 18>;
277 reset-names = "i2s";
278 dmas = <&apbdma 1>, <&apbdma 1>;
279 dma-names = "rx", "tx";
245 status = "disabled"; 280 status = "disabled";
246 }; 281 };
247 282
@@ -257,8 +292,11 @@
257 reg = <0x70006000 0x40>; 292 reg = <0x70006000 0x40>;
258 reg-shift = <2>; 293 reg-shift = <2>;
259 interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>; 294 interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>;
260 nvidia,dma-request-selector = <&apbdma 8>;
261 clocks = <&tegra_car TEGRA20_CLK_UARTA>; 295 clocks = <&tegra_car TEGRA20_CLK_UARTA>;
296 resets = <&tegra_car 6>;
297 reset-names = "serial";
298 dmas = <&apbdma 8>, <&apbdma 8>;
299 dma-names = "rx", "tx";
262 status = "disabled"; 300 status = "disabled";
263 }; 301 };
264 302
@@ -267,8 +305,11 @@
267 reg = <0x70006040 0x40>; 305 reg = <0x70006040 0x40>;
268 reg-shift = <2>; 306 reg-shift = <2>;
269 interrupts = <GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>; 307 interrupts = <GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>;
270 nvidia,dma-request-selector = <&apbdma 9>;
271 clocks = <&tegra_car TEGRA20_CLK_UARTB>; 308 clocks = <&tegra_car TEGRA20_CLK_UARTB>;
309 resets = <&tegra_car 7>;
310 reset-names = "serial";
311 dmas = <&apbdma 9>, <&apbdma 9>;
312 dma-names = "rx", "tx";
272 status = "disabled"; 313 status = "disabled";
273 }; 314 };
274 315
@@ -277,8 +318,11 @@
277 reg = <0x70006200 0x100>; 318 reg = <0x70006200 0x100>;
278 reg-shift = <2>; 319 reg-shift = <2>;
279 interrupts = <GIC_SPI 46 IRQ_TYPE_LEVEL_HIGH>; 320 interrupts = <GIC_SPI 46 IRQ_TYPE_LEVEL_HIGH>;
280 nvidia,dma-request-selector = <&apbdma 10>;
281 clocks = <&tegra_car TEGRA20_CLK_UARTC>; 321 clocks = <&tegra_car TEGRA20_CLK_UARTC>;
322 resets = <&tegra_car 55>;
323 reset-names = "serial";
324 dmas = <&apbdma 10>, <&apbdma 10>;
325 dma-names = "rx", "tx";
282 status = "disabled"; 326 status = "disabled";
283 }; 327 };
284 328
@@ -287,8 +331,11 @@
287 reg = <0x70006300 0x100>; 331 reg = <0x70006300 0x100>;
288 reg-shift = <2>; 332 reg-shift = <2>;
289 interrupts = <GIC_SPI 90 IRQ_TYPE_LEVEL_HIGH>; 333 interrupts = <GIC_SPI 90 IRQ_TYPE_LEVEL_HIGH>;
290 nvidia,dma-request-selector = <&apbdma 19>;
291 clocks = <&tegra_car TEGRA20_CLK_UARTD>; 334 clocks = <&tegra_car TEGRA20_CLK_UARTD>;
335 resets = <&tegra_car 65>;
336 reset-names = "serial";
337 dmas = <&apbdma 19>, <&apbdma 19>;
338 dma-names = "rx", "tx";
292 status = "disabled"; 339 status = "disabled";
293 }; 340 };
294 341
@@ -297,8 +344,11 @@
297 reg = <0x70006400 0x100>; 344 reg = <0x70006400 0x100>;
298 reg-shift = <2>; 345 reg-shift = <2>;
299 interrupts = <GIC_SPI 91 IRQ_TYPE_LEVEL_HIGH>; 346 interrupts = <GIC_SPI 91 IRQ_TYPE_LEVEL_HIGH>;
300 nvidia,dma-request-selector = <&apbdma 20>;
301 clocks = <&tegra_car TEGRA20_CLK_UARTE>; 347 clocks = <&tegra_car TEGRA20_CLK_UARTE>;
348 resets = <&tegra_car 66>;
349 reset-names = "serial";
350 dmas = <&apbdma 20>, <&apbdma 20>;
351 dma-names = "rx", "tx";
302 status = "disabled"; 352 status = "disabled";
303 }; 353 };
304 354
@@ -307,6 +357,8 @@
307 reg = <0x7000a000 0x100>; 357 reg = <0x7000a000 0x100>;
308 #pwm-cells = <2>; 358 #pwm-cells = <2>;
309 clocks = <&tegra_car TEGRA20_CLK_PWM>; 359 clocks = <&tegra_car TEGRA20_CLK_PWM>;
360 resets = <&tegra_car 17>;
361 reset-names = "pwm";
310 status = "disabled"; 362 status = "disabled";
311 }; 363 };
312 364
@@ -326,6 +378,10 @@
326 clocks = <&tegra_car TEGRA20_CLK_I2C1>, 378 clocks = <&tegra_car TEGRA20_CLK_I2C1>,
327 <&tegra_car TEGRA20_CLK_PLL_P_OUT3>; 379 <&tegra_car TEGRA20_CLK_PLL_P_OUT3>;
328 clock-names = "div-clk", "fast-clk"; 380 clock-names = "div-clk", "fast-clk";
381 resets = <&tegra_car 12>;
382 reset-names = "i2c";
383 dmas = <&apbdma 21>, <&apbdma 21>;
384 dma-names = "rx", "tx";
329 status = "disabled"; 385 status = "disabled";
330 }; 386 };
331 387
@@ -333,10 +389,13 @@
333 compatible = "nvidia,tegra20-sflash"; 389 compatible = "nvidia,tegra20-sflash";
334 reg = <0x7000c380 0x80>; 390 reg = <0x7000c380 0x80>;
335 interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>; 391 interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>;
336 nvidia,dma-request-selector = <&apbdma 11>;
337 #address-cells = <1>; 392 #address-cells = <1>;
338 #size-cells = <0>; 393 #size-cells = <0>;
339 clocks = <&tegra_car TEGRA20_CLK_SPI>; 394 clocks = <&tegra_car TEGRA20_CLK_SPI>;
395 resets = <&tegra_car 43>;
396 reset-names = "spi";
397 dmas = <&apbdma 11>, <&apbdma 11>;
398 dma-names = "rx", "tx";
340 status = "disabled"; 399 status = "disabled";
341 }; 400 };
342 401
@@ -349,6 +408,10 @@
349 clocks = <&tegra_car TEGRA20_CLK_I2C2>, 408 clocks = <&tegra_car TEGRA20_CLK_I2C2>,
350 <&tegra_car TEGRA20_CLK_PLL_P_OUT3>; 409 <&tegra_car TEGRA20_CLK_PLL_P_OUT3>;
351 clock-names = "div-clk", "fast-clk"; 410 clock-names = "div-clk", "fast-clk";
411 resets = <&tegra_car 54>;
412 reset-names = "i2c";
413 dmas = <&apbdma 22>, <&apbdma 22>;
414 dma-names = "rx", "tx";
352 status = "disabled"; 415 status = "disabled";
353 }; 416 };
354 417
@@ -361,6 +424,10 @@
361 clocks = <&tegra_car TEGRA20_CLK_I2C3>, 424 clocks = <&tegra_car TEGRA20_CLK_I2C3>,
362 <&tegra_car TEGRA20_CLK_PLL_P_OUT3>; 425 <&tegra_car TEGRA20_CLK_PLL_P_OUT3>;
363 clock-names = "div-clk", "fast-clk"; 426 clock-names = "div-clk", "fast-clk";
427 resets = <&tegra_car 67>;
428 reset-names = "i2c";
429 dmas = <&apbdma 23>, <&apbdma 23>;
430 dma-names = "rx", "tx";
364 status = "disabled"; 431 status = "disabled";
365 }; 432 };
366 433
@@ -373,6 +440,10 @@
373 clocks = <&tegra_car TEGRA20_CLK_DVC>, 440 clocks = <&tegra_car TEGRA20_CLK_DVC>,
374 <&tegra_car TEGRA20_CLK_PLL_P_OUT3>; 441 <&tegra_car TEGRA20_CLK_PLL_P_OUT3>;
375 clock-names = "div-clk", "fast-clk"; 442 clock-names = "div-clk", "fast-clk";
443 resets = <&tegra_car 47>;
444 reset-names = "i2c";
445 dmas = <&apbdma 24>, <&apbdma 24>;
446 dma-names = "rx", "tx";
376 status = "disabled"; 447 status = "disabled";
377 }; 448 };
378 449
@@ -380,10 +451,13 @@
380 compatible = "nvidia,tegra20-slink"; 451 compatible = "nvidia,tegra20-slink";
381 reg = <0x7000d400 0x200>; 452 reg = <0x7000d400 0x200>;
382 interrupts = <GIC_SPI 59 IRQ_TYPE_LEVEL_HIGH>; 453 interrupts = <GIC_SPI 59 IRQ_TYPE_LEVEL_HIGH>;
383 nvidia,dma-request-selector = <&apbdma 15>;
384 #address-cells = <1>; 454 #address-cells = <1>;
385 #size-cells = <0>; 455 #size-cells = <0>;
386 clocks = <&tegra_car TEGRA20_CLK_SBC1>; 456 clocks = <&tegra_car TEGRA20_CLK_SBC1>;
457 resets = <&tegra_car 41>;
458 reset-names = "spi";
459 dmas = <&apbdma 15>, <&apbdma 15>;
460 dma-names = "rx", "tx";
387 status = "disabled"; 461 status = "disabled";
388 }; 462 };
389 463
@@ -391,10 +465,13 @@
391 compatible = "nvidia,tegra20-slink"; 465 compatible = "nvidia,tegra20-slink";
392 reg = <0x7000d600 0x200>; 466 reg = <0x7000d600 0x200>;
393 interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>; 467 interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>;
394 nvidia,dma-request-selector = <&apbdma 16>;
395 #address-cells = <1>; 468 #address-cells = <1>;
396 #size-cells = <0>; 469 #size-cells = <0>;
397 clocks = <&tegra_car TEGRA20_CLK_SBC2>; 470 clocks = <&tegra_car TEGRA20_CLK_SBC2>;
471 resets = <&tegra_car 44>;
472 reset-names = "spi";
473 dmas = <&apbdma 16>, <&apbdma 16>;
474 dma-names = "rx", "tx";
398 status = "disabled"; 475 status = "disabled";
399 }; 476 };
400 477
@@ -402,10 +479,13 @@
402 compatible = "nvidia,tegra20-slink"; 479 compatible = "nvidia,tegra20-slink";
403 reg = <0x7000d800 0x200>; 480 reg = <0x7000d800 0x200>;
404 interrupts = <GIC_SPI 83 IRQ_TYPE_LEVEL_HIGH>; 481 interrupts = <GIC_SPI 83 IRQ_TYPE_LEVEL_HIGH>;
405 nvidia,dma-request-selector = <&apbdma 17>;
406 #address-cells = <1>; 482 #address-cells = <1>;
407 #size-cells = <0>; 483 #size-cells = <0>;
408 clocks = <&tegra_car TEGRA20_CLK_SBC3>; 484 clocks = <&tegra_car TEGRA20_CLK_SBC3>;
485 resets = <&tegra_car 46>;
486 reset-names = "spi";
487 dmas = <&apbdma 17>, <&apbdma 17>;
488 dma-names = "rx", "tx";
409 status = "disabled"; 489 status = "disabled";
410 }; 490 };
411 491
@@ -413,10 +493,13 @@
413 compatible = "nvidia,tegra20-slink"; 493 compatible = "nvidia,tegra20-slink";
414 reg = <0x7000da00 0x200>; 494 reg = <0x7000da00 0x200>;
415 interrupts = <GIC_SPI 93 IRQ_TYPE_LEVEL_HIGH>; 495 interrupts = <GIC_SPI 93 IRQ_TYPE_LEVEL_HIGH>;
416 nvidia,dma-request-selector = <&apbdma 18>;
417 #address-cells = <1>; 496 #address-cells = <1>;
418 #size-cells = <0>; 497 #size-cells = <0>;
419 clocks = <&tegra_car TEGRA20_CLK_SBC4>; 498 clocks = <&tegra_car TEGRA20_CLK_SBC4>;
499 resets = <&tegra_car 68>;
500 reset-names = "spi";
501 dmas = <&apbdma 18>, <&apbdma 18>;
502 dma-names = "rx", "tx";
420 status = "disabled"; 503 status = "disabled";
421 }; 504 };
422 505
@@ -425,6 +508,8 @@
425 reg = <0x7000e200 0x100>; 508 reg = <0x7000e200 0x100>;
426 interrupts = <GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>; 509 interrupts = <GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>;
427 clocks = <&tegra_car TEGRA20_CLK_KBC>; 510 clocks = <&tegra_car TEGRA20_CLK_KBC>;
511 resets = <&tegra_car 36>;
512 reset-names = "kbc";
428 status = "disabled"; 513 status = "disabled";
429 }; 514 };
430 515
@@ -478,9 +563,12 @@
478 563
479 clocks = <&tegra_car TEGRA20_CLK_PEX>, 564 clocks = <&tegra_car TEGRA20_CLK_PEX>,
480 <&tegra_car TEGRA20_CLK_AFI>, 565 <&tegra_car TEGRA20_CLK_AFI>,
481 <&tegra_car TEGRA20_CLK_PCIE_XCLK>,
482 <&tegra_car TEGRA20_CLK_PLL_E>; 566 <&tegra_car TEGRA20_CLK_PLL_E>;
483 clock-names = "pex", "afi", "pcie_xclk", "pll_e"; 567 clock-names = "pex", "afi", "pll_e";
568 resets = <&tegra_car 70>,
569 <&tegra_car 72>,
570 <&tegra_car 74>;
571 reset-names = "pex", "afi", "pcie_x";
484 status = "disabled"; 572 status = "disabled";
485 573
486 pci@1,0 { 574 pci@1,0 {
@@ -517,6 +605,8 @@
517 phy_type = "utmi"; 605 phy_type = "utmi";
518 nvidia,has-legacy-mode; 606 nvidia,has-legacy-mode;
519 clocks = <&tegra_car TEGRA20_CLK_USBD>; 607 clocks = <&tegra_car TEGRA20_CLK_USBD>;
608 resets = <&tegra_car 22>;
609 reset-names = "usb";
520 nvidia,needs-double-reset; 610 nvidia,needs-double-reset;
521 nvidia,phy = <&phy1>; 611 nvidia,phy = <&phy1>;
522 status = "disabled"; 612 status = "disabled";
@@ -548,6 +638,8 @@
548 interrupts = <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>; 638 interrupts = <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>;
549 phy_type = "ulpi"; 639 phy_type = "ulpi";
550 clocks = <&tegra_car TEGRA20_CLK_USB2>; 640 clocks = <&tegra_car TEGRA20_CLK_USB2>;
641 resets = <&tegra_car 58>;
642 reset-names = "usb";
551 nvidia,phy = <&phy2>; 643 nvidia,phy = <&phy2>;
552 status = "disabled"; 644 status = "disabled";
553 }; 645 };
@@ -569,6 +661,8 @@
569 interrupts = <GIC_SPI 97 IRQ_TYPE_LEVEL_HIGH>; 661 interrupts = <GIC_SPI 97 IRQ_TYPE_LEVEL_HIGH>;
570 phy_type = "utmi"; 662 phy_type = "utmi";
571 clocks = <&tegra_car TEGRA20_CLK_USB3>; 663 clocks = <&tegra_car TEGRA20_CLK_USB3>;
664 resets = <&tegra_car 59>;
665 reset-names = "usb";
572 nvidia,phy = <&phy3>; 666 nvidia,phy = <&phy3>;
573 status = "disabled"; 667 status = "disabled";
574 }; 668 };
@@ -597,6 +691,8 @@
597 reg = <0xc8000000 0x200>; 691 reg = <0xc8000000 0x200>;
598 interrupts = <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>; 692 interrupts = <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>;
599 clocks = <&tegra_car TEGRA20_CLK_SDMMC1>; 693 clocks = <&tegra_car TEGRA20_CLK_SDMMC1>;
694 resets = <&tegra_car 14>;
695 reset-names = "sdhci";
600 status = "disabled"; 696 status = "disabled";
601 }; 697 };
602 698
@@ -605,6 +701,8 @@
605 reg = <0xc8000200 0x200>; 701 reg = <0xc8000200 0x200>;
606 interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>; 702 interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>;
607 clocks = <&tegra_car TEGRA20_CLK_SDMMC2>; 703 clocks = <&tegra_car TEGRA20_CLK_SDMMC2>;
704 resets = <&tegra_car 9>;
705 reset-names = "sdhci";
608 status = "disabled"; 706 status = "disabled";
609 }; 707 };
610 708
@@ -613,6 +711,8 @@
613 reg = <0xc8000400 0x200>; 711 reg = <0xc8000400 0x200>;
614 interrupts = <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>; 712 interrupts = <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>;
615 clocks = <&tegra_car TEGRA20_CLK_SDMMC3>; 713 clocks = <&tegra_car TEGRA20_CLK_SDMMC3>;
714 resets = <&tegra_car 69>;
715 reset-names = "sdhci";
616 status = "disabled"; 716 status = "disabled";
617 }; 717 };
618 718
@@ -621,6 +721,8 @@
621 reg = <0xc8000600 0x200>; 721 reg = <0xc8000600 0x200>;
622 interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>; 722 interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
623 clocks = <&tegra_car TEGRA20_CLK_SDMMC4>; 723 clocks = <&tegra_car TEGRA20_CLK_SDMMC4>;
724 resets = <&tegra_car 15>;
725 reset-names = "sdhci";
624 status = "disabled"; 726 status = "disabled";
625 }; 727 };
626 728
diff --git a/arch/arm/boot/dts/tegra30.dtsi b/arch/arm/boot/dts/tegra30.dtsi
index 2bd55cfd88ad..31259b09e7cc 100644
--- a/arch/arm/boot/dts/tegra30.dtsi
+++ b/arch/arm/boot/dts/tegra30.dtsi
@@ -40,10 +40,13 @@
40 40
41 clocks = <&tegra_car TEGRA30_CLK_PCIE>, 41 clocks = <&tegra_car TEGRA30_CLK_PCIE>,
42 <&tegra_car TEGRA30_CLK_AFI>, 42 <&tegra_car TEGRA30_CLK_AFI>,
43 <&tegra_car TEGRA30_CLK_PCIEX>,
44 <&tegra_car TEGRA30_CLK_PLL_E>, 43 <&tegra_car TEGRA30_CLK_PLL_E>,
45 <&tegra_car TEGRA30_CLK_CML0>; 44 <&tegra_car TEGRA30_CLK_CML0>;
46 clock-names = "pex", "afi", "pcie_xclk", "pll_e", "cml"; 45 clock-names = "pex", "afi", "pll_e", "cml";
46 resets = <&tegra_car 70>,
47 <&tegra_car 72>,
48 <&tegra_car 74>;
49 reset-names = "pex", "afi", "pcie_x";
47 status = "disabled"; 50 status = "disabled";
48 51
49 pci@1,0 { 52 pci@1,0 {
@@ -92,6 +95,8 @@
92 interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>, /* syncpt */ 95 interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>, /* syncpt */
93 <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>; /* general */ 96 <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>; /* general */
94 clocks = <&tegra_car TEGRA30_CLK_HOST1X>; 97 clocks = <&tegra_car TEGRA30_CLK_HOST1X>;
98 resets = <&tegra_car 28>;
99 reset-names = "host1x";
95 100
96 #address-cells = <1>; 101 #address-cells = <1>;
97 #size-cells = <1>; 102 #size-cells = <1>;
@@ -103,6 +108,8 @@
103 reg = <0x54040000 0x00040000>; 108 reg = <0x54040000 0x00040000>;
104 interrupts = <GIC_SPI 68 IRQ_TYPE_LEVEL_HIGH>; 109 interrupts = <GIC_SPI 68 IRQ_TYPE_LEVEL_HIGH>;
105 clocks = <&tegra_car TEGRA30_CLK_MPE>; 110 clocks = <&tegra_car TEGRA30_CLK_MPE>;
111 resets = <&tegra_car 60>;
112 reset-names = "mpe";
106 }; 113 };
107 114
108 vi { 115 vi {
@@ -110,6 +117,8 @@
110 reg = <0x54080000 0x00040000>; 117 reg = <0x54080000 0x00040000>;
111 interrupts = <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>; 118 interrupts = <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>;
112 clocks = <&tegra_car TEGRA30_CLK_VI>; 119 clocks = <&tegra_car TEGRA30_CLK_VI>;
120 resets = <&tegra_car 20>;
121 reset-names = "vi";
113 }; 122 };
114 123
115 epp { 124 epp {
@@ -117,6 +126,8 @@
117 reg = <0x540c0000 0x00040000>; 126 reg = <0x540c0000 0x00040000>;
118 interrupts = <GIC_SPI 70 IRQ_TYPE_LEVEL_HIGH>; 127 interrupts = <GIC_SPI 70 IRQ_TYPE_LEVEL_HIGH>;
119 clocks = <&tegra_car TEGRA30_CLK_EPP>; 128 clocks = <&tegra_car TEGRA30_CLK_EPP>;
129 resets = <&tegra_car 19>;
130 reset-names = "epp";
120 }; 131 };
121 132
122 isp { 133 isp {
@@ -124,12 +135,16 @@
124 reg = <0x54100000 0x00040000>; 135 reg = <0x54100000 0x00040000>;
125 interrupts = <GIC_SPI 71 IRQ_TYPE_LEVEL_HIGH>; 136 interrupts = <GIC_SPI 71 IRQ_TYPE_LEVEL_HIGH>;
126 clocks = <&tegra_car TEGRA30_CLK_ISP>; 137 clocks = <&tegra_car TEGRA30_CLK_ISP>;
138 resets = <&tegra_car 23>;
139 reset-names = "isp";
127 }; 140 };
128 141
129 gr2d { 142 gr2d {
130 compatible = "nvidia,tegra30-gr2d"; 143 compatible = "nvidia,tegra30-gr2d";
131 reg = <0x54140000 0x00040000>; 144 reg = <0x54140000 0x00040000>;
132 interrupts = <GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH>; 145 interrupts = <GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH>;
146 resets = <&tegra_car 21>;
147 reset-names = "2d";
133 clocks = <&tegra_car TEGRA30_CLK_GR2D>; 148 clocks = <&tegra_car TEGRA30_CLK_GR2D>;
134 }; 149 };
135 150
@@ -139,6 +154,9 @@
139 clocks = <&tegra_car TEGRA30_CLK_GR3D 154 clocks = <&tegra_car TEGRA30_CLK_GR3D
140 &tegra_car TEGRA30_CLK_GR3D2>; 155 &tegra_car TEGRA30_CLK_GR3D2>;
141 clock-names = "3d", "3d2"; 156 clock-names = "3d", "3d2";
157 resets = <&tegra_car 24>,
158 <&tegra_car 98>;
159 reset-names = "3d", "3d2";
142 }; 160 };
143 161
144 dc@54200000 { 162 dc@54200000 {
@@ -147,7 +165,9 @@
147 interrupts = <GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>; 165 interrupts = <GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>;
148 clocks = <&tegra_car TEGRA30_CLK_DISP1>, 166 clocks = <&tegra_car TEGRA30_CLK_DISP1>,
149 <&tegra_car TEGRA30_CLK_PLL_P>; 167 <&tegra_car TEGRA30_CLK_PLL_P>;
150 clock-names = "disp1", "parent"; 168 clock-names = "dc", "parent";
169 resets = <&tegra_car 27>;
170 reset-names = "dc";
151 171
152 rgb { 172 rgb {
153 status = "disabled"; 173 status = "disabled";
@@ -160,7 +180,9 @@
160 interrupts = <GIC_SPI 74 IRQ_TYPE_LEVEL_HIGH>; 180 interrupts = <GIC_SPI 74 IRQ_TYPE_LEVEL_HIGH>;
161 clocks = <&tegra_car TEGRA30_CLK_DISP2>, 181 clocks = <&tegra_car TEGRA30_CLK_DISP2>,
162 <&tegra_car TEGRA30_CLK_PLL_P>; 182 <&tegra_car TEGRA30_CLK_PLL_P>;
163 clock-names = "disp2", "parent"; 183 clock-names = "dc", "parent";
184 resets = <&tegra_car 26>;
185 reset-names = "dc";
164 186
165 rgb { 187 rgb {
166 status = "disabled"; 188 status = "disabled";
@@ -174,6 +196,8 @@
174 clocks = <&tegra_car TEGRA30_CLK_HDMI>, 196 clocks = <&tegra_car TEGRA30_CLK_HDMI>,
175 <&tegra_car TEGRA30_CLK_PLL_D2_OUT0>; 197 <&tegra_car TEGRA30_CLK_PLL_D2_OUT0>;
176 clock-names = "hdmi", "parent"; 198 clock-names = "hdmi", "parent";
199 resets = <&tegra_car 51>;
200 reset-names = "hdmi";
177 status = "disabled"; 201 status = "disabled";
178 }; 202 };
179 203
@@ -189,6 +213,8 @@
189 compatible = "nvidia,tegra30-dsi"; 213 compatible = "nvidia,tegra30-dsi";
190 reg = <0x54300000 0x00040000>; 214 reg = <0x54300000 0x00040000>;
191 clocks = <&tegra_car TEGRA30_CLK_DSIA>; 215 clocks = <&tegra_car TEGRA30_CLK_DSIA>;
216 resets = <&tegra_car 48>;
217 reset-names = "dsi";
192 status = "disabled"; 218 status = "disabled";
193 }; 219 };
194 }; 220 };
@@ -234,6 +260,7 @@
234 compatible = "nvidia,tegra30-car"; 260 compatible = "nvidia,tegra30-car";
235 reg = <0x60006000 0x1000>; 261 reg = <0x60006000 0x1000>;
236 #clock-cells = <1>; 262 #clock-cells = <1>;
263 #reset-cells = <1>;
237 }; 264 };
238 265
239 apbdma: dma { 266 apbdma: dma {
@@ -272,6 +299,9 @@
272 <GIC_SPI 142 IRQ_TYPE_LEVEL_HIGH>, 299 <GIC_SPI 142 IRQ_TYPE_LEVEL_HIGH>,
273 <GIC_SPI 143 IRQ_TYPE_LEVEL_HIGH>; 300 <GIC_SPI 143 IRQ_TYPE_LEVEL_HIGH>;
274 clocks = <&tegra_car TEGRA30_CLK_APBDMA>; 301 clocks = <&tegra_car TEGRA30_CLK_APBDMA>;
302 resets = <&tegra_car 34>;
303 reset-names = "dma";
304 #dma-cells = <1>;
275 }; 305 };
276 306
277 ahb: ahb { 307 ahb: ahb {
@@ -315,8 +345,11 @@
315 reg = <0x70006000 0x40>; 345 reg = <0x70006000 0x40>;
316 reg-shift = <2>; 346 reg-shift = <2>;
317 interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>; 347 interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>;
318 nvidia,dma-request-selector = <&apbdma 8>;
319 clocks = <&tegra_car TEGRA30_CLK_UARTA>; 348 clocks = <&tegra_car TEGRA30_CLK_UARTA>;
349 resets = <&tegra_car 6>;
350 reset-names = "serial";
351 dmas = <&apbdma 8>, <&apbdma 8>;
352 dma-names = "rx", "tx";
320 status = "disabled"; 353 status = "disabled";
321 }; 354 };
322 355
@@ -325,8 +358,11 @@
325 reg = <0x70006040 0x40>; 358 reg = <0x70006040 0x40>;
326 reg-shift = <2>; 359 reg-shift = <2>;
327 interrupts = <GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>; 360 interrupts = <GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>;
328 nvidia,dma-request-selector = <&apbdma 9>;
329 clocks = <&tegra_car TEGRA30_CLK_UARTB>; 361 clocks = <&tegra_car TEGRA30_CLK_UARTB>;
362 resets = <&tegra_car 7>;
363 reset-names = "serial";
364 dmas = <&apbdma 9>, <&apbdma 9>;
365 dma-names = "rx", "tx";
330 status = "disabled"; 366 status = "disabled";
331 }; 367 };
332 368
@@ -335,8 +371,11 @@
335 reg = <0x70006200 0x100>; 371 reg = <0x70006200 0x100>;
336 reg-shift = <2>; 372 reg-shift = <2>;
337 interrupts = <GIC_SPI 46 IRQ_TYPE_LEVEL_HIGH>; 373 interrupts = <GIC_SPI 46 IRQ_TYPE_LEVEL_HIGH>;
338 nvidia,dma-request-selector = <&apbdma 10>;
339 clocks = <&tegra_car TEGRA30_CLK_UARTC>; 374 clocks = <&tegra_car TEGRA30_CLK_UARTC>;
375 resets = <&tegra_car 55>;
376 reset-names = "serial";
377 dmas = <&apbdma 10>, <&apbdma 10>;
378 dma-names = "rx", "tx";
340 status = "disabled"; 379 status = "disabled";
341 }; 380 };
342 381
@@ -345,8 +384,11 @@
345 reg = <0x70006300 0x100>; 384 reg = <0x70006300 0x100>;
346 reg-shift = <2>; 385 reg-shift = <2>;
347 interrupts = <GIC_SPI 90 IRQ_TYPE_LEVEL_HIGH>; 386 interrupts = <GIC_SPI 90 IRQ_TYPE_LEVEL_HIGH>;
348 nvidia,dma-request-selector = <&apbdma 19>;
349 clocks = <&tegra_car TEGRA30_CLK_UARTD>; 387 clocks = <&tegra_car TEGRA30_CLK_UARTD>;
388 resets = <&tegra_car 65>;
389 reset-names = "serial";
390 dmas = <&apbdma 19>, <&apbdma 19>;
391 dma-names = "rx", "tx";
350 status = "disabled"; 392 status = "disabled";
351 }; 393 };
352 394
@@ -355,8 +397,11 @@
355 reg = <0x70006400 0x100>; 397 reg = <0x70006400 0x100>;
356 reg-shift = <2>; 398 reg-shift = <2>;
357 interrupts = <GIC_SPI 91 IRQ_TYPE_LEVEL_HIGH>; 399 interrupts = <GIC_SPI 91 IRQ_TYPE_LEVEL_HIGH>;
358 nvidia,dma-request-selector = <&apbdma 20>;
359 clocks = <&tegra_car TEGRA30_CLK_UARTE>; 400 clocks = <&tegra_car TEGRA30_CLK_UARTE>;
401 resets = <&tegra_car 66>;
402 reset-names = "serial";
403 dmas = <&apbdma 20>, <&apbdma 20>;
404 dma-names = "rx", "tx";
360 status = "disabled"; 405 status = "disabled";
361 }; 406 };
362 407
@@ -365,6 +410,8 @@
365 reg = <0x7000a000 0x100>; 410 reg = <0x7000a000 0x100>;
366 #pwm-cells = <2>; 411 #pwm-cells = <2>;
367 clocks = <&tegra_car TEGRA30_CLK_PWM>; 412 clocks = <&tegra_car TEGRA30_CLK_PWM>;
413 resets = <&tegra_car 17>;
414 reset-names = "pwm";
368 status = "disabled"; 415 status = "disabled";
369 }; 416 };
370 417
@@ -384,6 +431,10 @@
384 clocks = <&tegra_car TEGRA30_CLK_I2C1>, 431 clocks = <&tegra_car TEGRA30_CLK_I2C1>,
385 <&tegra_car TEGRA30_CLK_PLL_P_OUT3>; 432 <&tegra_car TEGRA30_CLK_PLL_P_OUT3>;
386 clock-names = "div-clk", "fast-clk"; 433 clock-names = "div-clk", "fast-clk";
434 resets = <&tegra_car 12>;
435 reset-names = "i2c";
436 dmas = <&apbdma 21>, <&apbdma 21>;
437 dma-names = "rx", "tx";
387 status = "disabled"; 438 status = "disabled";
388 }; 439 };
389 440
@@ -396,6 +447,10 @@
396 clocks = <&tegra_car TEGRA30_CLK_I2C2>, 447 clocks = <&tegra_car TEGRA30_CLK_I2C2>,
397 <&tegra_car TEGRA30_CLK_PLL_P_OUT3>; 448 <&tegra_car TEGRA30_CLK_PLL_P_OUT3>;
398 clock-names = "div-clk", "fast-clk"; 449 clock-names = "div-clk", "fast-clk";
450 resets = <&tegra_car 54>;
451 reset-names = "i2c";
452 dmas = <&apbdma 22>, <&apbdma 22>;
453 dma-names = "rx", "tx";
399 status = "disabled"; 454 status = "disabled";
400 }; 455 };
401 456
@@ -408,6 +463,10 @@
408 clocks = <&tegra_car TEGRA30_CLK_I2C3>, 463 clocks = <&tegra_car TEGRA30_CLK_I2C3>,
409 <&tegra_car TEGRA30_CLK_PLL_P_OUT3>; 464 <&tegra_car TEGRA30_CLK_PLL_P_OUT3>;
410 clock-names = "div-clk", "fast-clk"; 465 clock-names = "div-clk", "fast-clk";
466 resets = <&tegra_car 67>;
467 reset-names = "i2c";
468 dmas = <&apbdma 23>, <&apbdma 23>;
469 dma-names = "rx", "tx";
411 status = "disabled"; 470 status = "disabled";
412 }; 471 };
413 472
@@ -419,7 +478,11 @@
419 #size-cells = <0>; 478 #size-cells = <0>;
420 clocks = <&tegra_car TEGRA30_CLK_I2C4>, 479 clocks = <&tegra_car TEGRA30_CLK_I2C4>,
421 <&tegra_car TEGRA30_CLK_PLL_P_OUT3>; 480 <&tegra_car TEGRA30_CLK_PLL_P_OUT3>;
481 resets = <&tegra_car 103>;
482 reset-names = "i2c";
422 clock-names = "div-clk", "fast-clk"; 483 clock-names = "div-clk", "fast-clk";
484 dmas = <&apbdma 26>, <&apbdma 26>;
485 dma-names = "rx", "tx";
423 status = "disabled"; 486 status = "disabled";
424 }; 487 };
425 488
@@ -432,6 +495,10 @@
432 clocks = <&tegra_car TEGRA30_CLK_I2C5>, 495 clocks = <&tegra_car TEGRA30_CLK_I2C5>,
433 <&tegra_car TEGRA30_CLK_PLL_P_OUT3>; 496 <&tegra_car TEGRA30_CLK_PLL_P_OUT3>;
434 clock-names = "div-clk", "fast-clk"; 497 clock-names = "div-clk", "fast-clk";
498 resets = <&tegra_car 47>;
499 reset-names = "i2c";
500 dmas = <&apbdma 24>, <&apbdma 24>;
501 dma-names = "rx", "tx";
435 status = "disabled"; 502 status = "disabled";
436 }; 503 };
437 504
@@ -439,10 +506,13 @@
439 compatible = "nvidia,tegra30-slink", "nvidia,tegra20-slink"; 506 compatible = "nvidia,tegra30-slink", "nvidia,tegra20-slink";
440 reg = <0x7000d400 0x200>; 507 reg = <0x7000d400 0x200>;
441 interrupts = <GIC_SPI 59 IRQ_TYPE_LEVEL_HIGH>; 508 interrupts = <GIC_SPI 59 IRQ_TYPE_LEVEL_HIGH>;
442 nvidia,dma-request-selector = <&apbdma 15>;
443 #address-cells = <1>; 509 #address-cells = <1>;
444 #size-cells = <0>; 510 #size-cells = <0>;
445 clocks = <&tegra_car TEGRA30_CLK_SBC1>; 511 clocks = <&tegra_car TEGRA30_CLK_SBC1>;
512 resets = <&tegra_car 41>;
513 reset-names = "spi";
514 dmas = <&apbdma 15>, <&apbdma 15>;
515 dma-names = "rx", "tx";
446 status = "disabled"; 516 status = "disabled";
447 }; 517 };
448 518
@@ -450,10 +520,13 @@
450 compatible = "nvidia,tegra30-slink", "nvidia,tegra20-slink"; 520 compatible = "nvidia,tegra30-slink", "nvidia,tegra20-slink";
451 reg = <0x7000d600 0x200>; 521 reg = <0x7000d600 0x200>;
452 interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>; 522 interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>;
453 nvidia,dma-request-selector = <&apbdma 16>;
454 #address-cells = <1>; 523 #address-cells = <1>;
455 #size-cells = <0>; 524 #size-cells = <0>;
456 clocks = <&tegra_car TEGRA30_CLK_SBC2>; 525 clocks = <&tegra_car TEGRA30_CLK_SBC2>;
526 resets = <&tegra_car 44>;
527 reset-names = "spi";
528 dmas = <&apbdma 16>, <&apbdma 16>;
529 dma-names = "rx", "tx";
457 status = "disabled"; 530 status = "disabled";
458 }; 531 };
459 532
@@ -461,10 +534,13 @@
461 compatible = "nvidia,tegra30-slink", "nvidia,tegra20-slink"; 534 compatible = "nvidia,tegra30-slink", "nvidia,tegra20-slink";
462 reg = <0x7000d800 0x200>; 535 reg = <0x7000d800 0x200>;
463 interrupts = <GIC_SPI 83 IRQ_TYPE_LEVEL_HIGH>; 536 interrupts = <GIC_SPI 83 IRQ_TYPE_LEVEL_HIGH>;
464 nvidia,dma-request-selector = <&apbdma 17>;
465 #address-cells = <1>; 537 #address-cells = <1>;
466 #size-cells = <0>; 538 #size-cells = <0>;
467 clocks = <&tegra_car TEGRA30_CLK_SBC3>; 539 clocks = <&tegra_car TEGRA30_CLK_SBC3>;
540 resets = <&tegra_car 46>;
541 reset-names = "spi";
542 dmas = <&apbdma 17>, <&apbdma 17>;
543 dma-names = "rx", "tx";
468 status = "disabled"; 544 status = "disabled";
469 }; 545 };
470 546
@@ -472,10 +548,13 @@
472 compatible = "nvidia,tegra30-slink", "nvidia,tegra20-slink"; 548 compatible = "nvidia,tegra30-slink", "nvidia,tegra20-slink";
473 reg = <0x7000da00 0x200>; 549 reg = <0x7000da00 0x200>;
474 interrupts = <GIC_SPI 93 IRQ_TYPE_LEVEL_HIGH>; 550 interrupts = <GIC_SPI 93 IRQ_TYPE_LEVEL_HIGH>;
475 nvidia,dma-request-selector = <&apbdma 18>;
476 #address-cells = <1>; 551 #address-cells = <1>;
477 #size-cells = <0>; 552 #size-cells = <0>;
478 clocks = <&tegra_car TEGRA30_CLK_SBC4>; 553 clocks = <&tegra_car TEGRA30_CLK_SBC4>;
554 resets = <&tegra_car 68>;
555 reset-names = "spi";
556 dmas = <&apbdma 18>, <&apbdma 18>;
557 dma-names = "rx", "tx";
479 status = "disabled"; 558 status = "disabled";
480 }; 559 };
481 560
@@ -483,10 +562,13 @@
483 compatible = "nvidia,tegra30-slink", "nvidia,tegra20-slink"; 562 compatible = "nvidia,tegra30-slink", "nvidia,tegra20-slink";
484 reg = <0x7000dc00 0x200>; 563 reg = <0x7000dc00 0x200>;
485 interrupts = <GIC_SPI 94 IRQ_TYPE_LEVEL_HIGH>; 564 interrupts = <GIC_SPI 94 IRQ_TYPE_LEVEL_HIGH>;
486 nvidia,dma-request-selector = <&apbdma 27>;
487 #address-cells = <1>; 565 #address-cells = <1>;
488 #size-cells = <0>; 566 #size-cells = <0>;
489 clocks = <&tegra_car TEGRA30_CLK_SBC5>; 567 clocks = <&tegra_car TEGRA30_CLK_SBC5>;
568 resets = <&tegra_car 104>;
569 reset-names = "spi";
570 dmas = <&apbdma 27>, <&apbdma 27>;
571 dma-names = "rx", "tx";
490 status = "disabled"; 572 status = "disabled";
491 }; 573 };
492 574
@@ -494,10 +576,13 @@
494 compatible = "nvidia,tegra30-slink", "nvidia,tegra20-slink"; 576 compatible = "nvidia,tegra30-slink", "nvidia,tegra20-slink";
495 reg = <0x7000de00 0x200>; 577 reg = <0x7000de00 0x200>;
496 interrupts = <GIC_SPI 79 IRQ_TYPE_LEVEL_HIGH>; 578 interrupts = <GIC_SPI 79 IRQ_TYPE_LEVEL_HIGH>;
497 nvidia,dma-request-selector = <&apbdma 28>;
498 #address-cells = <1>; 579 #address-cells = <1>;
499 #size-cells = <0>; 580 #size-cells = <0>;
500 clocks = <&tegra_car TEGRA30_CLK_SBC6>; 581 clocks = <&tegra_car TEGRA30_CLK_SBC6>;
582 resets = <&tegra_car 106>;
583 reset-names = "spi";
584 dmas = <&apbdma 28>, <&apbdma 28>;
585 dma-names = "rx", "tx";
501 status = "disabled"; 586 status = "disabled";
502 }; 587 };
503 588
@@ -506,6 +591,8 @@
506 reg = <0x7000e200 0x100>; 591 reg = <0x7000e200 0x100>;
507 interrupts = <GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>; 592 interrupts = <GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>;
508 clocks = <&tegra_car TEGRA30_CLK_KBC>; 593 clocks = <&tegra_car TEGRA30_CLK_KBC>;
594 resets = <&tegra_car 36>;
595 reset-names = "kbc";
509 status = "disabled"; 596 status = "disabled";
510 }; 597 };
511 598
@@ -540,21 +627,29 @@
540 reg = <0x70080000 0x200 627 reg = <0x70080000 0x200
541 0x70080200 0x100>; 628 0x70080200 0x100>;
542 interrupts = <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>; 629 interrupts = <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>;
543 nvidia,dma-request-selector = <&apbdma 1>;
544 clocks = <&tegra_car TEGRA30_CLK_D_AUDIO>, 630 clocks = <&tegra_car TEGRA30_CLK_D_AUDIO>,
545 <&tegra_car TEGRA30_CLK_APBIF>, 631 <&tegra_car TEGRA30_CLK_APBIF>;
546 <&tegra_car TEGRA30_CLK_I2S0>, 632 clock-names = "d_audio", "apbif";
547 <&tegra_car TEGRA30_CLK_I2S1>, 633 resets = <&tegra_car 106>, /* d_audio */
548 <&tegra_car TEGRA30_CLK_I2S2>, 634 <&tegra_car 107>, /* apbif */
549 <&tegra_car TEGRA30_CLK_I2S3>, 635 <&tegra_car 30>, /* i2s0 */
550 <&tegra_car TEGRA30_CLK_I2S4>, 636 <&tegra_car 11>, /* i2s1 */
551 <&tegra_car TEGRA30_CLK_DAM0>, 637 <&tegra_car 18>, /* i2s2 */
552 <&tegra_car TEGRA30_CLK_DAM1>, 638 <&tegra_car 101>, /* i2s3 */
553 <&tegra_car TEGRA30_CLK_DAM2>, 639 <&tegra_car 102>, /* i2s4 */
554 <&tegra_car TEGRA30_CLK_SPDIF_IN>; 640 <&tegra_car 108>, /* dam0 */
555 clock-names = "d_audio", "apbif", "i2s0", "i2s1", "i2s2", 641 <&tegra_car 109>, /* dam1 */
642 <&tegra_car 110>, /* dam2 */
643 <&tegra_car 10>; /* spdif */
644 reset-names = "d_audio", "apbif", "i2s0", "i2s1", "i2s2",
556 "i2s3", "i2s4", "dam0", "dam1", "dam2", 645 "i2s3", "i2s4", "dam0", "dam1", "dam2",
557 "spdif_in"; 646 "spdif";
647 dmas = <&apbdma 1>, <&apbdma 1>,
648 <&apbdma 2>, <&apbdma 2>,
649 <&apbdma 3>, <&apbdma 3>,
650 <&apbdma 4>, <&apbdma 4>;
651 dma-names = "rx0", "tx0", "rx1", "tx1", "rx2", "tx2",
652 "rx3", "tx3";
558 ranges; 653 ranges;
559 #address-cells = <1>; 654 #address-cells = <1>;
560 #size-cells = <1>; 655 #size-cells = <1>;
@@ -564,6 +659,8 @@
564 reg = <0x70080300 0x100>; 659 reg = <0x70080300 0x100>;
565 nvidia,ahub-cif-ids = <4 4>; 660 nvidia,ahub-cif-ids = <4 4>;
566 clocks = <&tegra_car TEGRA30_CLK_I2S0>; 661 clocks = <&tegra_car TEGRA30_CLK_I2S0>;
662 resets = <&tegra_car 30>;
663 reset-names = "i2s";
567 status = "disabled"; 664 status = "disabled";
568 }; 665 };
569 666
@@ -572,6 +669,8 @@
572 reg = <0x70080400 0x100>; 669 reg = <0x70080400 0x100>;
573 nvidia,ahub-cif-ids = <5 5>; 670 nvidia,ahub-cif-ids = <5 5>;
574 clocks = <&tegra_car TEGRA30_CLK_I2S1>; 671 clocks = <&tegra_car TEGRA30_CLK_I2S1>;
672 resets = <&tegra_car 11>;
673 reset-names = "i2s";
575 status = "disabled"; 674 status = "disabled";
576 }; 675 };
577 676
@@ -580,6 +679,8 @@
580 reg = <0x70080500 0x100>; 679 reg = <0x70080500 0x100>;
581 nvidia,ahub-cif-ids = <6 6>; 680 nvidia,ahub-cif-ids = <6 6>;
582 clocks = <&tegra_car TEGRA30_CLK_I2S2>; 681 clocks = <&tegra_car TEGRA30_CLK_I2S2>;
682 resets = <&tegra_car 18>;
683 reset-names = "i2s";
583 status = "disabled"; 684 status = "disabled";
584 }; 685 };
585 686
@@ -588,6 +689,8 @@
588 reg = <0x70080600 0x100>; 689 reg = <0x70080600 0x100>;
589 nvidia,ahub-cif-ids = <7 7>; 690 nvidia,ahub-cif-ids = <7 7>;
590 clocks = <&tegra_car TEGRA30_CLK_I2S3>; 691 clocks = <&tegra_car TEGRA30_CLK_I2S3>;
692 resets = <&tegra_car 101>;
693 reset-names = "i2s";
591 status = "disabled"; 694 status = "disabled";
592 }; 695 };
593 696
@@ -596,6 +699,8 @@
596 reg = <0x70080700 0x100>; 699 reg = <0x70080700 0x100>;
597 nvidia,ahub-cif-ids = <8 8>; 700 nvidia,ahub-cif-ids = <8 8>;
598 clocks = <&tegra_car TEGRA30_CLK_I2S4>; 701 clocks = <&tegra_car TEGRA30_CLK_I2S4>;
702 resets = <&tegra_car 102>;
703 reset-names = "i2s";
599 status = "disabled"; 704 status = "disabled";
600 }; 705 };
601 }; 706 };
@@ -605,6 +710,8 @@
605 reg = <0x78000000 0x200>; 710 reg = <0x78000000 0x200>;
606 interrupts = <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>; 711 interrupts = <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>;
607 clocks = <&tegra_car TEGRA30_CLK_SDMMC1>; 712 clocks = <&tegra_car TEGRA30_CLK_SDMMC1>;
713 resets = <&tegra_car 14>;
714 reset-names = "sdhci";
608 status = "disabled"; 715 status = "disabled";
609 }; 716 };
610 717
@@ -613,6 +720,8 @@
613 reg = <0x78000200 0x200>; 720 reg = <0x78000200 0x200>;
614 interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>; 721 interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>;
615 clocks = <&tegra_car TEGRA30_CLK_SDMMC2>; 722 clocks = <&tegra_car TEGRA30_CLK_SDMMC2>;
723 resets = <&tegra_car 9>;
724 reset-names = "sdhci";
616 status = "disabled"; 725 status = "disabled";
617 }; 726 };
618 727
@@ -621,6 +730,8 @@
621 reg = <0x78000400 0x200>; 730 reg = <0x78000400 0x200>;
622 interrupts = <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>; 731 interrupts = <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>;
623 clocks = <&tegra_car TEGRA30_CLK_SDMMC3>; 732 clocks = <&tegra_car TEGRA30_CLK_SDMMC3>;
733 resets = <&tegra_car 69>;
734 reset-names = "sdhci";
624 status = "disabled"; 735 status = "disabled";
625 }; 736 };
626 737
@@ -629,6 +740,8 @@
629 reg = <0x78000600 0x200>; 740 reg = <0x78000600 0x200>;
630 interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>; 741 interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
631 clocks = <&tegra_car TEGRA30_CLK_SDMMC4>; 742 clocks = <&tegra_car TEGRA30_CLK_SDMMC4>;
743 resets = <&tegra_car 15>;
744 reset-names = "sdhci";
632 status = "disabled"; 745 status = "disabled";
633 }; 746 };
634 747
@@ -638,6 +751,8 @@
638 interrupts = <GIC_SPI 20 IRQ_TYPE_LEVEL_HIGH>; 751 interrupts = <GIC_SPI 20 IRQ_TYPE_LEVEL_HIGH>;
639 phy_type = "utmi"; 752 phy_type = "utmi";
640 clocks = <&tegra_car TEGRA30_CLK_USBD>; 753 clocks = <&tegra_car TEGRA30_CLK_USBD>;
754 resets = <&tegra_car 22>;
755 reset-names = "usb";
641 nvidia,needs-double-reset; 756 nvidia,needs-double-reset;
642 nvidia,phy = <&phy1>; 757 nvidia,phy = <&phy1>;
643 status = "disabled"; 758 status = "disabled";
@@ -671,6 +786,8 @@
671 interrupts = <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>; 786 interrupts = <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>;
672 phy_type = "ulpi"; 787 phy_type = "ulpi";
673 clocks = <&tegra_car TEGRA30_CLK_USB2>; 788 clocks = <&tegra_car TEGRA30_CLK_USB2>;
789 resets = <&tegra_car 58>;
790 reset-names = "usb";
674 nvidia,phy = <&phy2>; 791 nvidia,phy = <&phy2>;
675 status = "disabled"; 792 status = "disabled";
676 }; 793 };
@@ -692,6 +809,8 @@
692 interrupts = <GIC_SPI 97 IRQ_TYPE_LEVEL_HIGH>; 809 interrupts = <GIC_SPI 97 IRQ_TYPE_LEVEL_HIGH>;
693 phy_type = "utmi"; 810 phy_type = "utmi";
694 clocks = <&tegra_car TEGRA30_CLK_USB3>; 811 clocks = <&tegra_car TEGRA30_CLK_USB3>;
812 resets = <&tegra_car 59>;
813 reset-names = "usb";
695 nvidia,phy = <&phy3>; 814 nvidia,phy = <&phy3>;
696 status = "disabled"; 815 status = "disabled";
697 }; 816 };
diff --git a/arch/arm/common/timer-sp.c b/arch/arm/common/timer-sp.c
index ce922d0ea7aa..53c6a26b633d 100644
--- a/arch/arm/common/timer-sp.c
+++ b/arch/arm/common/timer-sp.c
@@ -66,7 +66,7 @@ static long __init sp804_get_clock_rate(struct clk *clk)
66 66
67static void __iomem *sched_clock_base; 67static void __iomem *sched_clock_base;
68 68
69static u32 sp804_read(void) 69static u64 notrace sp804_read(void)
70{ 70{
71 return ~readl_relaxed(sched_clock_base + TIMER_VALUE); 71 return ~readl_relaxed(sched_clock_base + TIMER_VALUE);
72} 72}
@@ -104,7 +104,7 @@ void __init __sp804_clocksource_and_sched_clock_init(void __iomem *base,
104 104
105 if (use_sched_clock) { 105 if (use_sched_clock) {
106 sched_clock_base = base; 106 sched_clock_base = base;
107 setup_sched_clock(sp804_read, 32, rate); 107 sched_clock_register(sp804_read, 32, rate);
108 } 108 }
109} 109}
110 110
diff --git a/arch/arm/configs/ape6evm_defconfig b/arch/arm/configs/ape6evm_defconfig
index 1ce39940795d..cb26c62dc722 100644
--- a/arch/arm/configs/ape6evm_defconfig
+++ b/arch/arm/configs/ape6evm_defconfig
@@ -13,7 +13,7 @@ CONFIG_EMBEDDED=y
13CONFIG_PERF_EVENTS=y 13CONFIG_PERF_EVENTS=y
14CONFIG_SLAB=y 14CONFIG_SLAB=y
15# CONFIG_BLOCK is not set 15# CONFIG_BLOCK is not set
16CONFIG_ARCH_SHMOBILE=y 16CONFIG_ARCH_SHMOBILE_LEGACY=y
17CONFIG_ARCH_R8A73A4=y 17CONFIG_ARCH_R8A73A4=y
18CONFIG_MACH_APE6EVM=y 18CONFIG_MACH_APE6EVM=y
19# CONFIG_ARM_THUMB is not set 19# CONFIG_ARM_THUMB is not set
diff --git a/arch/arm/configs/armadillo800eva_defconfig b/arch/arm/configs/armadillo800eva_defconfig
index fae939d3d7f0..5abf1a2e3160 100644
--- a/arch/arm/configs/armadillo800eva_defconfig
+++ b/arch/arm/configs/armadillo800eva_defconfig
@@ -15,7 +15,7 @@ CONFIG_MODULE_FORCE_UNLOAD=y
15# CONFIG_BLK_DEV_BSG is not set 15# CONFIG_BLK_DEV_BSG is not set
16# CONFIG_IOSCHED_DEADLINE is not set 16# CONFIG_IOSCHED_DEADLINE is not set
17# CONFIG_IOSCHED_CFQ is not set 17# CONFIG_IOSCHED_CFQ is not set
18CONFIG_ARCH_SHMOBILE=y 18CONFIG_ARCH_SHMOBILE_LEGACY=y
19CONFIG_ARCH_R8A7740=y 19CONFIG_ARCH_R8A7740=y
20CONFIG_MACH_ARMADILLO800EVA=y 20CONFIG_MACH_ARMADILLO800EVA=y
21# CONFIG_SH_TIMER_TMU is not set 21# CONFIG_SH_TIMER_TMU is not set
diff --git a/arch/arm/configs/bockw_defconfig b/arch/arm/configs/bockw_defconfig
index b38cd107f82d..1dd39716d7cb 100644
--- a/arch/arm/configs/bockw_defconfig
+++ b/arch/arm/configs/bockw_defconfig
@@ -8,7 +8,7 @@ CONFIG_SYSCTL_SYSCALL=y
8CONFIG_EMBEDDED=y 8CONFIG_EMBEDDED=y
9CONFIG_SLAB=y 9CONFIG_SLAB=y
10# CONFIG_IOSCHED_CFQ is not set 10# CONFIG_IOSCHED_CFQ is not set
11CONFIG_ARCH_SHMOBILE=y 11CONFIG_ARCH_SHMOBILE_LEGACY=y
12CONFIG_ARCH_R8A7778=y 12CONFIG_ARCH_R8A7778=y
13CONFIG_MACH_BOCKW=y 13CONFIG_MACH_BOCKW=y
14CONFIG_MEMORY_START=0x60000000 14CONFIG_MEMORY_START=0x60000000
diff --git a/arch/arm/configs/efm32_defconfig b/arch/arm/configs/efm32_defconfig
new file mode 100644
index 000000000000..f59fffb3d0c6
--- /dev/null
+++ b/arch/arm/configs/efm32_defconfig
@@ -0,0 +1,102 @@
1CONFIG_HIGH_RES_TIMERS=y
2CONFIG_LOG_BUF_SHIFT=12
3CONFIG_CC_OPTIMIZE_FOR_SIZE=y
4# CONFIG_UID16 is not set
5# CONFIG_BASE_FULL is not set
6# CONFIG_FUTEX is not set
7# CONFIG_EPOLL is not set
8# CONFIG_SIGNALFD is not set
9# CONFIG_EVENTFD is not set
10# CONFIG_AIO is not set
11CONFIG_EMBEDDED=y
12# CONFIG_VM_EVENT_COUNTERS is not set
13# CONFIG_SLUB_DEBUG is not set
14# CONFIG_LBDAF is not set
15# CONFIG_BLK_DEV_BSG is not set
16# CONFIG_IOSCHED_DEADLINE is not set
17# CONFIG_IOSCHED_CFQ is not set
18# CONFIG_MMU is not set
19CONFIG_ARCH_EFM32=y
20# CONFIG_KUSER_HELPERS is not set
21CONFIG_SET_MEM_PARAM=y
22CONFIG_DRAM_BASE=0x88000000
23CONFIG_DRAM_SIZE=0x00400000
24CONFIG_FLASH_MEM_BASE=0x8c000000
25CONFIG_FLASH_SIZE=0x01000000
26CONFIG_PREEMPT=y
27CONFIG_ZBOOT_ROM_TEXT=0x0
28CONFIG_ZBOOT_ROM_BSS=0x0
29CONFIG_XIP_KERNEL=y
30CONFIG_XIP_PHYS_ADDR=0x8c000000
31CONFIG_BINFMT_FLAT=y
32CONFIG_BINFMT_SHARED_FLAT=y
33# CONFIG_COREDUMP is not set
34CONFIG_NET=y
35CONFIG_PACKET=y
36CONFIG_UNIX=y
37CONFIG_INET=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_DEVTMPFS=y
46CONFIG_DEVTMPFS_MOUNT=y
47# CONFIG_FW_LOADER is not set
48CONFIG_MTD=y
49CONFIG_MTD_BLOCK_RO=y
50CONFIG_MTD_ROM=y
51CONFIG_MTD_UCLINUX=y
52CONFIG_PROC_DEVICETREE=y
53# CONFIG_BLK_DEV is not set
54CONFIG_NETDEVICES=y
55# CONFIG_NET_VENDOR_ARC is not set
56# CONFIG_NET_CADENCE is not set
57# CONFIG_NET_VENDOR_BROADCOM is not set
58# CONFIG_NET_VENDOR_CIRRUS is not set
59# CONFIG_NET_VENDOR_FARADAY is not set
60# CONFIG_NET_VENDOR_INTEL is not set
61# CONFIG_NET_VENDOR_MARVELL is not set
62CONFIG_KS8851=y
63# CONFIG_NET_VENDOR_MICROCHIP is not set
64# CONFIG_NET_VENDOR_NATSEMI is not set
65# CONFIG_NET_VENDOR_SEEQ is not set
66# CONFIG_NET_VENDOR_SMSC is not set
67# CONFIG_NET_VENDOR_STMICRO is not set
68# CONFIG_NET_VENDOR_VIA is not set
69# CONFIG_NET_VENDOR_WIZNET is not set
70# CONFIG_WLAN is not set
71# CONFIG_INPUT is not set
72# CONFIG_SERIO is not set
73# CONFIG_VT is not set
74# CONFIG_UNIX98_PTYS is not set
75# CONFIG_LEGACY_PTYS is not set
76CONFIG_SERIAL_NONSTANDARD=y
77# CONFIG_DEVKMEM is not set
78CONFIG_SERIAL_EFM32_UART=y
79CONFIG_SERIAL_EFM32_UART_CONSOLE=y
80# CONFIG_HW_RANDOM is not set
81CONFIG_SPI=y
82CONFIG_SPI_EFM32=y
83CONFIG_GPIO_SYSFS=y
84# CONFIG_USB_SUPPORT is not set
85CONFIG_MMC=y
86CONFIG_MMC_SPI=y
87# CONFIG_IOMMU_SUPPORT is not set
88CONFIG_EXT2_FS=y
89# CONFIG_FILE_LOCKING is not set
90# CONFIG_DNOTIFY is not set
91# CONFIG_INOTIFY_USER is not set
92CONFIG_ROMFS_FS=y
93CONFIG_ROMFS_BACKED_BY_MTD=y
94# CONFIG_NETWORK_FILESYSTEMS is not set
95CONFIG_PRINTK_TIME=y
96CONFIG_DEBUG_INFO=y
97# CONFIG_ENABLE_WARN_DEPRECATED is not set
98# CONFIG_ENABLE_MUST_CHECK is not set
99CONFIG_MAGIC_SYSRQ=y
100# CONFIG_SCHED_DEBUG is not set
101# CONFIG_DEBUG_BUGVERBOSE is not set
102# CONFIG_FTRACE is not set
diff --git a/arch/arm/configs/keystone_defconfig b/arch/arm/configs/keystone_defconfig
index 9943e5da74f1..a0182447d133 100644
--- a/arch/arm/configs/keystone_defconfig
+++ b/arch/arm/configs/keystone_defconfig
@@ -115,6 +115,8 @@ CONFIG_MTD_UBI=y
115CONFIG_PROC_DEVICETREE=y 115CONFIG_PROC_DEVICETREE=y
116CONFIG_BLK_DEV_LOOP=y 116CONFIG_BLK_DEV_LOOP=y
117CONFIG_EEPROM_AT24=y 117CONFIG_EEPROM_AT24=y
118CONFIG_SCSI=y
119CONFIG_BLK_DEV_SD=y
118CONFIG_NETDEVICES=y 120CONFIG_NETDEVICES=y
119CONFIG_SERIAL_8250=y 121CONFIG_SERIAL_8250=y
120CONFIG_SERIAL_8250_CONSOLE=y 122CONFIG_SERIAL_8250_CONSOLE=y
@@ -129,10 +131,24 @@ CONFIG_SPI_DAVINCI=y
129CONFIG_SPI_SPIDEV=y 131CONFIG_SPI_SPIDEV=y
130# CONFIG_HWMON is not set 132# CONFIG_HWMON is not set
131CONFIG_WATCHDOG=y 133CONFIG_WATCHDOG=y
132# CONFIG_USB_SUPPORT is not set 134CONFIG_USB=y
135CONFIG_USB_DEBUG=y
136CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
137CONFIG_USB_MON=y
138CONFIG_USB_XHCI_HCD=y
139CONFIG_USB_STORAGE=y
140CONFIG_USB_DWC3=y
141CONFIG_USB_DWC3_DEBUG=y
142CONFIG_USB_DWC3_VERBOSE=y
143CONFIG_KEYSTONE_USB_PHY=y
133CONFIG_DMADEVICES=y 144CONFIG_DMADEVICES=y
134CONFIG_COMMON_CLK_DEBUG=y 145CONFIG_COMMON_CLK_DEBUG=y
135CONFIG_MEMORY=y 146CONFIG_MEMORY=y
147CONFIG_EXT4_FS=y
148CONFIG_EXT4_FS_POSIX_ACL=y
149CONFIG_MSDOS_FS=y
150CONFIG_VFAT_FS=y
151CONFIG_NTFS_FS=y
136CONFIG_TMPFS=y 152CONFIG_TMPFS=y
137CONFIG_JFFS2_FS=y 153CONFIG_JFFS2_FS=y
138CONFIG_JFFS2_FS_WBUF_VERIFY=y 154CONFIG_JFFS2_FS_WBUF_VERIFY=y
@@ -144,6 +160,8 @@ CONFIG_ROOT_NFS=y
144CONFIG_NFSD=y 160CONFIG_NFSD=y
145CONFIG_NFSD_V3=y 161CONFIG_NFSD_V3=y
146CONFIG_NFSD_V3_ACL=y 162CONFIG_NFSD_V3_ACL=y
163CONFIG_NLS_CODEPAGE_437=y
164CONFIG_NLS_ISO8859_1=y
147CONFIG_PRINTK_TIME=y 165CONFIG_PRINTK_TIME=y
148CONFIG_DEBUG_SHIRQ=y 166CONFIG_DEBUG_SHIRQ=y
149CONFIG_DEBUG_INFO=y 167CONFIG_DEBUG_INFO=y
diff --git a/arch/arm/configs/koelsch_defconfig b/arch/arm/configs/koelsch_defconfig
index 825c16dee8a0..7fd65a01ec7e 100644
--- a/arch/arm/configs/koelsch_defconfig
+++ b/arch/arm/configs/koelsch_defconfig
@@ -9,7 +9,7 @@ CONFIG_EMBEDDED=y
9CONFIG_PERF_EVENTS=y 9CONFIG_PERF_EVENTS=y
10CONFIG_SLAB=y 10CONFIG_SLAB=y
11# CONFIG_BLOCK is not set 11# CONFIG_BLOCK is not set
12CONFIG_ARCH_SHMOBILE=y 12CONFIG_ARCH_SHMOBILE_LEGACY=y
13CONFIG_ARCH_R8A7791=y 13CONFIG_ARCH_R8A7791=y
14CONFIG_MACH_KOELSCH=y 14CONFIG_MACH_KOELSCH=y
15# CONFIG_SWP_EMULATE is not set 15# CONFIG_SWP_EMULATE is not set
diff --git a/arch/arm/configs/kzm9d_defconfig b/arch/arm/configs/kzm9d_defconfig
index 6c37f4a98eb8..217f1dda2965 100644
--- a/arch/arm/configs/kzm9d_defconfig
+++ b/arch/arm/configs/kzm9d_defconfig
@@ -13,7 +13,7 @@ CONFIG_SLAB=y
13# CONFIG_BLK_DEV_BSG is not set 13# CONFIG_BLK_DEV_BSG is not set
14# CONFIG_IOSCHED_DEADLINE is not set 14# CONFIG_IOSCHED_DEADLINE is not set
15# CONFIG_IOSCHED_CFQ is not set 15# CONFIG_IOSCHED_CFQ is not set
16CONFIG_ARCH_SHMOBILE=y 16CONFIG_ARCH_SHMOBILE_LEGACY=y
17CONFIG_ARCH_EMEV2=y 17CONFIG_ARCH_EMEV2=y
18CONFIG_MACH_KZM9D=y 18CONFIG_MACH_KZM9D=y
19CONFIG_MEMORY_START=0x40000000 19CONFIG_MEMORY_START=0x40000000
diff --git a/arch/arm/configs/kzm9g_defconfig b/arch/arm/configs/kzm9g_defconfig
index 1ad028023a64..9934dbc23d64 100644
--- a/arch/arm/configs/kzm9g_defconfig
+++ b/arch/arm/configs/kzm9g_defconfig
@@ -22,7 +22,7 @@ CONFIG_MODULE_UNLOAD=y
22# CONFIG_BLK_DEV_BSG is not set 22# CONFIG_BLK_DEV_BSG is not set
23# CONFIG_IOSCHED_DEADLINE is not set 23# CONFIG_IOSCHED_DEADLINE is not set
24# CONFIG_IOSCHED_CFQ is not set 24# CONFIG_IOSCHED_CFQ is not set
25CONFIG_ARCH_SHMOBILE=y 25CONFIG_ARCH_SHMOBILE_LEGACY=y
26CONFIG_ARCH_SH73A0=y 26CONFIG_ARCH_SH73A0=y
27CONFIG_MACH_KZM9G=y 27CONFIG_MACH_KZM9G=y
28CONFIG_MEMORY_START=0x41000000 28CONFIG_MEMORY_START=0x41000000
diff --git a/arch/arm/configs/lager_defconfig b/arch/arm/configs/lager_defconfig
index 35bff5e0d57a..35dc8b2be47f 100644
--- a/arch/arm/configs/lager_defconfig
+++ b/arch/arm/configs/lager_defconfig
@@ -12,7 +12,7 @@ CONFIG_SLAB=y
12# CONFIG_BLK_DEV_BSG is not set 12# CONFIG_BLK_DEV_BSG is not set
13# CONFIG_IOSCHED_DEADLINE is not set 13# CONFIG_IOSCHED_DEADLINE is not set
14# CONFIG_IOSCHED_CFQ is not set 14# CONFIG_IOSCHED_CFQ is not set
15CONFIG_ARCH_SHMOBILE=y 15CONFIG_ARCH_SHMOBILE_LEGACY=y
16CONFIG_ARCH_R8A7790=y 16CONFIG_ARCH_R8A7790=y
17CONFIG_MACH_LAGER=y 17CONFIG_MACH_LAGER=y
18# CONFIG_SH_TIMER_TMU is not set 18# CONFIG_SH_TIMER_TMU is not set
diff --git a/arch/arm/configs/mackerel_defconfig b/arch/arm/configs/mackerel_defconfig
index 9fb11895b2e2..a61e1653fc5e 100644
--- a/arch/arm/configs/mackerel_defconfig
+++ b/arch/arm/configs/mackerel_defconfig
@@ -14,7 +14,7 @@ CONFIG_MODULE_UNLOAD=y
14# CONFIG_BLK_DEV_BSG is not set 14# CONFIG_BLK_DEV_BSG is not set
15# CONFIG_IOSCHED_DEADLINE is not set 15# CONFIG_IOSCHED_DEADLINE is not set
16# CONFIG_IOSCHED_CFQ is not set 16# CONFIG_IOSCHED_CFQ is not set
17CONFIG_ARCH_SHMOBILE=y 17CONFIG_ARCH_SHMOBILE_LEGACY=y
18CONFIG_ARCH_SH7372=y 18CONFIG_ARCH_SH7372=y
19CONFIG_MACH_MACKEREL=y 19CONFIG_MACH_MACKEREL=y
20CONFIG_MEMORY_SIZE=0x10000000 20CONFIG_MEMORY_SIZE=0x10000000
diff --git a/arch/arm/configs/marzen_defconfig b/arch/arm/configs/marzen_defconfig
index 5cc6360340b1..6981338cd08d 100644
--- a/arch/arm/configs/marzen_defconfig
+++ b/arch/arm/configs/marzen_defconfig
@@ -9,7 +9,7 @@ CONFIG_SYSCTL_SYSCALL=y
9CONFIG_EMBEDDED=y 9CONFIG_EMBEDDED=y
10CONFIG_SLAB=y 10CONFIG_SLAB=y
11# CONFIG_IOSCHED_CFQ is not set 11# CONFIG_IOSCHED_CFQ is not set
12CONFIG_ARCH_SHMOBILE=y 12CONFIG_ARCH_SHMOBILE_LEGACY=y
13CONFIG_ARCH_R8A7779=y 13CONFIG_ARCH_R8A7779=y
14CONFIG_MACH_MARZEN=y 14CONFIG_MACH_MARZEN=y
15CONFIG_MEMORY_START=0x60000000 15CONFIG_MEMORY_START=0x60000000
diff --git a/arch/arm/configs/moxart_defconfig b/arch/arm/configs/moxart_defconfig
new file mode 100644
index 000000000000..a3cb76cfb828
--- /dev/null
+++ b/arch/arm/configs/moxart_defconfig
@@ -0,0 +1,149 @@
1# CONFIG_LOCALVERSION_AUTO is not set
2# CONFIG_SWAP is not set
3CONFIG_SYSVIPC=y
4CONFIG_NO_HZ=y
5CONFIG_IKCONFIG=y
6CONFIG_IKCONFIG_PROC=y
7CONFIG_SYSCTL_SYSCALL=y
8# CONFIG_ELF_CORE is not set
9# CONFIG_BASE_FULL is not set
10# CONFIG_SIGNALFD is not set
11# CONFIG_TIMERFD is not set
12# CONFIG_EVENTFD is not set
13# CONFIG_AIO is not set
14CONFIG_EMBEDDED=y
15# CONFIG_VM_EVENT_COUNTERS is not set
16# CONFIG_SLUB_DEBUG is not set
17# CONFIG_COMPAT_BRK is not set
18# CONFIG_LBDAF is not set
19# CONFIG_BLK_DEV_BSG is not set
20# CONFIG_IOSCHED_DEADLINE is not set
21CONFIG_ARCH_MULTI_V4T=y
22# CONFIG_ARCH_MULTI_V7 is not set
23CONFIG_KEYBOARD_GPIO_POLLED=y
24CONFIG_ARCH_MOXART=y
25CONFIG_MACH_UC7112LX=y
26CONFIG_PREEMPT=y
27CONFIG_AEABI=y
28# CONFIG_ATAGS is not set
29CONFIG_ARM_APPENDED_DTB=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
37# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
38# CONFIG_INET_XFRM_MODE_TUNNEL is not set
39# CONFIG_INET_XFRM_MODE_BEET is not set
40# CONFIG_INET_LRO is not set
41# CONFIG_INET_DIAG is not set
42# CONFIG_IPV6 is not set
43# CONFIG_WIRELESS is not set
44CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
45CONFIG_DEVTMPFS=y
46CONFIG_DEVTMPFS_MOUNT=y
47# CONFIG_PREVENT_FIRMWARE_BUILD is not set
48# CONFIG_FW_LOADER is not set
49CONFIG_MTD=y
50CONFIG_MTD_BLOCK=y
51CONFIG_MTD_CFI=y
52CONFIG_MTD_CFI_ADV_OPTIONS=y
53CONFIG_MTD_CFI_GEOMETRY=y
54CONFIG_MTD_CFI_INTELEXT=y
55CONFIG_MTD_COMPLEX_MAPPINGS=y
56CONFIG_MTD_PHYSMAP=y
57CONFIG_MTD_PHYSMAP_OF=y
58CONFIG_PROC_DEVICETREE=y
59CONFIG_NETDEVICES=y
60CONFIG_NETCONSOLE=y
61CONFIG_NETCONSOLE_DYNAMIC=y
62# CONFIG_NET_VENDOR_ARC is not set
63# CONFIG_NET_CADENCE is not set
64# CONFIG_NET_VENDOR_BROADCOM is not set
65# CONFIG_NET_VENDOR_CIRRUS is not set
66# CONFIG_NET_VENDOR_FARADAY is not set
67# CONFIG_NET_VENDOR_INTEL is not set
68# CONFIG_NET_VENDOR_MARVELL is not set
69# CONFIG_NET_VENDOR_MICREL is not set
70CONFIG_ARM_MOXART_ETHER=y
71# CONFIG_NET_VENDOR_NATSEMI is not set
72# CONFIG_NET_VENDOR_SEEQ is not set
73# CONFIG_NET_VENDOR_SMSC is not set
74# CONFIG_NET_VENDOR_STMICRO is not set
75# CONFIG_NET_VENDOR_VIA is not set
76# CONFIG_NET_VENDOR_WIZNET is not set
77CONFIG_REALTEK_PHY=y
78CONFIG_MDIO_MOXART=y
79# CONFIG_WLAN is not set
80# CONFIG_INPUT_MOUSEDEV is not set
81CONFIG_INPUT_EVDEV=y
82CONFIG_INPUT_EVBUG=y
83# CONFIG_KEYBOARD_ATKBD is not set
84# CONFIG_INPUT_MOUSE is not set
85# CONFIG_SERIO is not set
86# CONFIG_VT is not set
87# CONFIG_LEGACY_PTYS is not set
88# CONFIG_DEVKMEM is not set
89CONFIG_SERIAL_8250=y
90CONFIG_SERIAL_8250_CONSOLE=y
91CONFIG_SERIAL_8250_NR_UARTS=1
92CONFIG_SERIAL_8250_RUNTIME_UARTS=1
93CONFIG_SERIAL_8250_EXTENDED=y
94CONFIG_SERIAL_8250_SHARE_IRQ=y
95CONFIG_SERIAL_OF_PLATFORM=y
96# CONFIG_HW_RANDOM is not set
97CONFIG_DEBUG_GPIO=y
98CONFIG_GPIO_SYSFS=y
99CONFIG_GPIO_MOXART=y
100CONFIG_POWER_SUPPLY=y
101CONFIG_POWER_RESET=y
102CONFIG_POWER_RESET_GPIO=y
103# CONFIG_HWMON is not set
104CONFIG_WATCHDOG=y
105CONFIG_WATCHDOG_CORE=y
106CONFIG_WATCHDOG_NOWAYOUT=y
107CONFIG_MOXART_WDT=y
108# CONFIG_USB_SUPPORT is not set
109CONFIG_MMC=y
110CONFIG_MMC_SDHCI_MOXART=y
111CONFIG_NEW_LEDS=y
112CONFIG_LEDS_CLASS=y
113CONFIG_LEDS_GPIO=y
114CONFIG_LEDS_TRIGGER_TIMER=y
115CONFIG_LEDS_TRIGGER_ONESHOT=y
116CONFIG_LEDS_TRIGGER_HEARTBEAT=y
117CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
118CONFIG_RTC_CLASS=y
119CONFIG_RTC_DRV_MOXART=y
120CONFIG_DMADEVICES=y
121CONFIG_MOXART_DMA=y
122# CONFIG_IOMMU_SUPPORT is not set
123CONFIG_EXT3_FS=y
124CONFIG_TMPFS=y
125CONFIG_CONFIGFS_FS=y
126CONFIG_JFFS2_FS=y
127CONFIG_PRINTK_TIME=y
128CONFIG_DEBUG_INFO=y
129# CONFIG_ENABLE_WARN_DEPRECATED is not set
130# CONFIG_ENABLE_MUST_CHECK is not set
131CONFIG_DEBUG_PAGEALLOC=y
132CONFIG_DEBUG_OBJECTS=y
133CONFIG_DEBUG_KMEMLEAK=y
134CONFIG_DEBUG_STACK_USAGE=y
135CONFIG_DEBUG_MEMORY_INIT=y
136CONFIG_DEBUG_SHIRQ=y
137CONFIG_DETECT_HUNG_TASK=y
138# CONFIG_SCHED_DEBUG is not set
139# CONFIG_DEBUG_PREEMPT is not set
140CONFIG_PROVE_LOCKING=y
141CONFIG_DMA_API_DEBUG=y
142CONFIG_KGDB=y
143CONFIG_DEBUG_LL=y
144CONFIG_DEBUG_LL_UART_8250=y
145CONFIG_DEBUG_UART_PHYS=0x98200000
146CONFIG_DEBUG_UART_VIRT=0xf9820000
147CONFIG_EARLY_PRINTK=y
148CONFIG_KEYS=y
149CONFIG_CRC32_BIT=y
diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig
index c1df4e9db140..7e3f5cba7cfd 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -7,6 +7,9 @@ CONFIG_MACH_ARMADA_370=y
7CONFIG_MACH_ARMADA_XP=y 7CONFIG_MACH_ARMADA_XP=y
8CONFIG_ARCH_BCM=y 8CONFIG_ARCH_BCM=y
9CONFIG_ARCH_BCM_MOBILE=y 9CONFIG_ARCH_BCM_MOBILE=y
10CONFIG_ARCH_BERLIN=y
11CONFIG_MACH_BERLIN_BG2=y
12CONFIG_MACH_BERLIN_BG2CD=y
10CONFIG_GPIO_PCA953X=y 13CONFIG_GPIO_PCA953X=y
11CONFIG_ARCH_HIGHBANK=y 14CONFIG_ARCH_HIGHBANK=y
12CONFIG_ARCH_KEYSTONE=y 15CONFIG_ARCH_KEYSTONE=y
diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
index 9ecccc865046..6976b03e5213 100644
--- a/arch/arm/include/asm/memory.h
+++ b/arch/arm/include/asm/memory.h
@@ -100,23 +100,19 @@
100#define TASK_UNMAPPED_BASE UL(0x00000000) 100#define TASK_UNMAPPED_BASE UL(0x00000000)
101#endif 101#endif
102 102
103#ifndef PHYS_OFFSET
104#define PHYS_OFFSET UL(CONFIG_DRAM_BASE)
105#endif
106
107#ifndef END_MEM 103#ifndef END_MEM
108#define END_MEM (UL(CONFIG_DRAM_BASE) + CONFIG_DRAM_SIZE) 104#define END_MEM (UL(CONFIG_DRAM_BASE) + CONFIG_DRAM_SIZE)
109#endif 105#endif
110 106
111#ifndef PAGE_OFFSET 107#ifndef PAGE_OFFSET
112#define PAGE_OFFSET (PHYS_OFFSET) 108#define PAGE_OFFSET PLAT_PHYS_OFFSET
113#endif 109#endif
114 110
115/* 111/*
116 * The module can be at any place in ram in nommu mode. 112 * The module can be at any place in ram in nommu mode.
117 */ 113 */
118#define MODULES_END (END_MEM) 114#define MODULES_END (END_MEM)
119#define MODULES_VADDR (PHYS_OFFSET) 115#define MODULES_VADDR PAGE_OFFSET
120 116
121#define XIP_VIRT_ADDR(physaddr) (physaddr) 117#define XIP_VIRT_ADDR(physaddr) (physaddr)
122 118
@@ -157,6 +153,16 @@
157#endif 153#endif
158#define ARCH_PGD_MASK ((1 << ARCH_PGD_SHIFT) - 1) 154#define ARCH_PGD_MASK ((1 << ARCH_PGD_SHIFT) - 1)
159 155
156/*
157 * PLAT_PHYS_OFFSET is the offset (from zero) of the start of physical
158 * memory. This is used for XIP and NoMMU kernels, or by kernels which
159 * have their own mach/memory.h. Assembly code must always use
160 * PLAT_PHYS_OFFSET and not PHYS_OFFSET.
161 */
162#ifndef PLAT_PHYS_OFFSET
163#define PLAT_PHYS_OFFSET UL(CONFIG_PHYS_OFFSET)
164#endif
165
160#ifndef __ASSEMBLY__ 166#ifndef __ASSEMBLY__
161 167
162/* 168/*
@@ -239,6 +245,8 @@ static inline unsigned long __phys_to_virt(phys_addr_t x)
239 245
240#else 246#else
241 247
248#define PHYS_OFFSET PLAT_PHYS_OFFSET
249
242static inline phys_addr_t __virt_to_phys(unsigned long x) 250static inline phys_addr_t __virt_to_phys(unsigned long x)
243{ 251{
244 return (phys_addr_t)x - PAGE_OFFSET + PHYS_OFFSET; 252 return (phys_addr_t)x - PAGE_OFFSET + PHYS_OFFSET;
@@ -251,17 +259,6 @@ static inline unsigned long __phys_to_virt(phys_addr_t x)
251 259
252#endif 260#endif
253#endif 261#endif
254#endif /* __ASSEMBLY__ */
255
256#ifndef PHYS_OFFSET
257#ifdef PLAT_PHYS_OFFSET
258#define PHYS_OFFSET PLAT_PHYS_OFFSET
259#else
260#define PHYS_OFFSET UL(CONFIG_PHYS_OFFSET)
261#endif
262#endif
263
264#ifndef __ASSEMBLY__
265 262
266/* 263/*
267 * PFNs are used to describe any physical page; this means 264 * PFNs are used to describe any physical page; this means
diff --git a/arch/arm/include/debug/tegra.S b/arch/arm/include/debug/tegra.S
index be6a720dd183..f98763f0bc17 100644
--- a/arch/arm/include/debug/tegra.S
+++ b/arch/arm/include/debug/tegra.S
@@ -46,10 +46,10 @@
46#define TEGRA_APB_MISC_GP_HIDREV (TEGRA_APB_MISC_BASE + 0x804) 46#define TEGRA_APB_MISC_GP_HIDREV (TEGRA_APB_MISC_BASE + 0x804)
47 47
48/* 48/*
49 * Must be 1MB-aligned since a 1MB mapping is used early on. 49 * Must be section-aligned since a section mapping is used early on.
50 * Must not overlap with regions in mach-tegra/io.c:tegra_io_desc[]. 50 * Must not overlap with regions in mach-tegra/io.c:tegra_io_desc[].
51 */ 51 */
52#define UART_VIRTUAL_BASE 0xfe100000 52#define UART_VIRTUAL_BASE 0xfe800000
53 53
54#define checkuart(rp, rv, lhu, bit, uart) \ 54#define checkuart(rp, rv, lhu, bit, uart) \
55 /* Load address of CLK_RST register */ \ 55 /* Load address of CLK_RST register */ \
@@ -156,28 +156,6 @@
15692: and \rv, \rp, #0xffffff @ offset within 1MB section 15692: and \rv, \rp, #0xffffff @ offset within 1MB section
157 add \rv, \rv, #UART_VIRTUAL_BASE 157 add \rv, \rv, #UART_VIRTUAL_BASE
158 str \rv, [\tmp, #8] @ Store in tegra_uart_virt 158 str \rv, [\tmp, #8] @ Store in tegra_uart_virt
159 movw \rv, #TEGRA_APB_MISC_GP_HIDREV & 0xffff
160 movt \rv, #TEGRA_APB_MISC_GP_HIDREV >> 16
161 ldr \rv, [\rv, #0] @ Load HIDREV
162 ubfx \rv, \rv, #8, #8 @ 15:8 are SoC version
163 cmp \rv, #0x20 @ Tegra20?
164 moveq \rv, #0x75 @ Tegra20 divisor
165 movne \rv, #0xdd @ Tegra30 divisor
166 str \rv, [\tmp, #12] @ Save divisor to scratch
167 /* uart[UART_LCR] = UART_LCR_WLEN8 | UART_LCR_DLAB; */
168 mov \rv, #UART_LCR_WLEN8 | UART_LCR_DLAB
169 str \rv, [\rp, #UART_LCR << UART_SHIFT]
170 /* uart[UART_DLL] = div & 0xff; */
171 ldr \rv, [\tmp, #12]
172 and \rv, \rv, #0xff
173 str \rv, [\rp, #UART_DLL << UART_SHIFT]
174 /* uart[UART_DLM] = div >> 8; */
175 ldr \rv, [\tmp, #12]
176 lsr \rv, \rv, #8
177 str \rv, [\rp, #UART_DLM << UART_SHIFT]
178 /* uart[UART_LCR] = UART_LCR_WLEN8; */
179 mov \rv, #UART_LCR_WLEN8
180 str \rv, [\rp, #UART_LCR << UART_SHIFT]
181 b 100f 159 b 100f
182 160
183 .align 161 .align
@@ -205,8 +183,8 @@
205 cmp \rx, #0 183 cmp \rx, #0
206 beq 1002f 184 beq 1002f
2071001: ldrb \rd, [\rx, #UART_LSR << UART_SHIFT] 1851001: ldrb \rd, [\rx, #UART_LSR << UART_SHIFT]
208 and \rd, \rd, #UART_LSR_TEMT | UART_LSR_THRE 186 and \rd, \rd, #UART_LSR_THRE
209 teq \rd, #UART_LSR_TEMT | UART_LSR_THRE 187 teq \rd, #UART_LSR_THRE
210 bne 1001b 188 bne 1001b
2111002: 1891002:
212 .endm 190 .endm
@@ -225,7 +203,7 @@
225/* 203/*
226 * Storage for the state maintained by the macros above. 204 * Storage for the state maintained by the macros above.
227 * 205 *
228 * In the kernel proper, this data is located in arch/arm/mach-tegra/common.c. 206 * In the kernel proper, this data is located in arch/arm/mach-tegra/tegra.c.
229 * That's because this header is included from multiple files, and we only 207 * That's because this header is included from multiple files, and we only
230 * want a single copy of the data. In particular, the UART probing code above 208 * want a single copy of the data. In particular, the UART probing code above
231 * assumes it's running using physical addresses. This is true when this file 209 * assumes it's running using physical addresses. This is true when this file
@@ -247,6 +225,4 @@ tegra_uart_config:
247 .word 0 225 .word 0
248 /* Debug UART virtual address */ 226 /* Debug UART virtual address */
249 .word 0 227 .word 0
250 /* Scratch space for debug macro */
251 .word 0
252#endif 228#endif
diff --git a/arch/arm/kernel/head-nommu.S b/arch/arm/kernel/head-nommu.S
index 14235ba64a90..716249cc2ee1 100644
--- a/arch/arm/kernel/head-nommu.S
+++ b/arch/arm/kernel/head-nommu.S
@@ -68,7 +68,7 @@ ENTRY(stext)
68 68
69#ifdef CONFIG_ARM_MPU 69#ifdef CONFIG_ARM_MPU
70 /* Calculate the size of a region covering just the kernel */ 70 /* Calculate the size of a region covering just the kernel */
71 ldr r5, =PHYS_OFFSET @ Region start: PHYS_OFFSET 71 ldr r5, =PLAT_PHYS_OFFSET @ Region start: PHYS_OFFSET
72 ldr r6, =(_end) @ Cover whole kernel 72 ldr r6, =(_end) @ Cover whole kernel
73 sub r6, r6, r5 @ Minimum size of region to map 73 sub r6, r6, r5 @ Minimum size of region to map
74 clz r6, r6 @ Region size must be 2^N... 74 clz r6, r6 @ Region size must be 2^N...
@@ -213,7 +213,7 @@ ENTRY(__setup_mpu)
213 set_region_nr r0, #MPU_RAM_REGION 213 set_region_nr r0, #MPU_RAM_REGION
214 isb 214 isb
215 /* Full access from PL0, PL1, shared for CONFIG_SMP, cacheable */ 215 /* Full access from PL0, PL1, shared for CONFIG_SMP, cacheable */
216 ldr r0, =PHYS_OFFSET @ RAM starts at PHYS_OFFSET 216 ldr r0, =PLAT_PHYS_OFFSET @ RAM starts at PHYS_OFFSET
217 ldr r5,=(MPU_AP_PL1RW_PL0RW | MPU_RGN_NORMAL) 217 ldr r5,=(MPU_AP_PL1RW_PL0RW | MPU_RGN_NORMAL)
218 218
219 setup_region r0, r5, r6, MPU_DATA_SIDE @ PHYS_OFFSET, shared, enabled 219 setup_region r0, r5, r6, MPU_DATA_SIDE @ PHYS_OFFSET, shared, enabled
diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
index 11d59b32fb8d..32f317e5828a 100644
--- a/arch/arm/kernel/head.S
+++ b/arch/arm/kernel/head.S
@@ -110,7 +110,7 @@ ENTRY(stext)
110 sub r4, r3, r4 @ (PHYS_OFFSET - PAGE_OFFSET) 110 sub r4, r3, r4 @ (PHYS_OFFSET - PAGE_OFFSET)
111 add r8, r8, r4 @ PHYS_OFFSET 111 add r8, r8, r4 @ PHYS_OFFSET
112#else 112#else
113 ldr r8, =PHYS_OFFSET @ always constant in this case 113 ldr r8, =PLAT_PHYS_OFFSET @ always constant in this case
114#endif 114#endif
115 115
116 /* 116 /*
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index 94f6b05f9e24..92f7b15dd221 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -404,6 +404,7 @@ EXPORT_SYMBOL(dump_fpu);
404unsigned long get_wchan(struct task_struct *p) 404unsigned long get_wchan(struct task_struct *p)
405{ 405{
406 struct stackframe frame; 406 struct stackframe frame;
407 unsigned long stack_page;
407 int count = 0; 408 int count = 0;
408 if (!p || p == current || p->state == TASK_RUNNING) 409 if (!p || p == current || p->state == TASK_RUNNING)
409 return 0; 410 return 0;
@@ -412,9 +413,11 @@ unsigned long get_wchan(struct task_struct *p)
412 frame.sp = thread_saved_sp(p); 413 frame.sp = thread_saved_sp(p);
413 frame.lr = 0; /* recovered from the stack */ 414 frame.lr = 0; /* recovered from the stack */
414 frame.pc = thread_saved_pc(p); 415 frame.pc = thread_saved_pc(p);
416 stack_page = (unsigned long)task_stack_page(p);
415 do { 417 do {
416 int ret = unwind_frame(&frame); 418 if (frame.sp < stack_page ||
417 if (ret < 0) 419 frame.sp >= stack_page + THREAD_SIZE ||
420 unwind_frame(&frame) < 0)
418 return 0; 421 return 0;
419 if (!in_sched_functions(frame.pc)) 422 if (!in_sched_functions(frame.pc))
420 return frame.pc; 423 return frame.pc;
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 6a1b8a81b1ae..987a7f5bce5f 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -873,8 +873,6 @@ void __init setup_arch(char **cmdline_p)
873 machine_desc = mdesc; 873 machine_desc = mdesc;
874 machine_name = mdesc->name; 874 machine_name = mdesc->name;
875 875
876 setup_dma_zone(mdesc);
877
878 if (mdesc->reboot_mode != REBOOT_HARD) 876 if (mdesc->reboot_mode != REBOOT_HARD)
879 reboot_mode = mdesc->reboot_mode; 877 reboot_mode = mdesc->reboot_mode;
880 878
@@ -892,6 +890,7 @@ void __init setup_arch(char **cmdline_p)
892 sort(&meminfo.bank, meminfo.nr_banks, sizeof(meminfo.bank[0]), meminfo_cmp, NULL); 890 sort(&meminfo.bank, meminfo.nr_banks, sizeof(meminfo.bank[0]), meminfo_cmp, NULL);
893 891
894 early_paging_init(mdesc, lookup_processor_type(read_cpuid_id())); 892 early_paging_init(mdesc, lookup_processor_type(read_cpuid_id()));
893 setup_dma_zone(mdesc);
895 sanity_check_meminfo(); 894 sanity_check_meminfo();
896 arm_memblock_init(&meminfo, mdesc); 895 arm_memblock_init(&meminfo, mdesc);
897 896
diff --git a/arch/arm/kernel/stacktrace.c b/arch/arm/kernel/stacktrace.c
index 00f79e59985b..af4e8c8a5422 100644
--- a/arch/arm/kernel/stacktrace.c
+++ b/arch/arm/kernel/stacktrace.c
@@ -31,7 +31,7 @@ int notrace unwind_frame(struct stackframe *frame)
31 high = ALIGN(low, THREAD_SIZE); 31 high = ALIGN(low, THREAD_SIZE);
32 32
33 /* check current frame pointer is within bounds */ 33 /* check current frame pointer is within bounds */
34 if (fp < (low + 12) || fp + 4 >= high) 34 if (fp < low + 12 || fp > high - 4)
35 return -EINVAL; 35 return -EINVAL;
36 36
37 /* restore the registers from the stack frame */ 37 /* restore the registers from the stack frame */
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index dbf0923e8d76..7940241f0576 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -509,9 +509,10 @@ static inline int
509__do_cache_op(unsigned long start, unsigned long end) 509__do_cache_op(unsigned long start, unsigned long end)
510{ 510{
511 int ret; 511 int ret;
512 unsigned long chunk = PAGE_SIZE;
513 512
514 do { 513 do {
514 unsigned long chunk = min(PAGE_SIZE, end - start);
515
515 if (signal_pending(current)) { 516 if (signal_pending(current)) {
516 struct thread_info *ti = current_thread_info(); 517 struct thread_info *ti = current_thread_info();
517 518
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 699b71e7f7ec..44eacdd7468b 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -67,7 +67,7 @@ config SOC_SAMA5D3
67 select HAVE_AT91_DBGU1 67 select HAVE_AT91_DBGU1
68 help 68 help
69 Select this if you are using one of Atmel's SAMA5D3 family SoC. 69 Select this if you are using one of Atmel's SAMA5D3 family SoC.
70 This support covers SAMA5D31, SAMA5D33, SAMA5D34, SAMA5D35. 70 This support covers SAMA5D31, SAMA5D33, SAMA5D34, SAMA5D35, SAMA5D36.
71endif 71endif
72 72
73if SOC_SAM_V4_V5 73if SOC_SAM_V4_V5
diff --git a/arch/arm/mach-at91/include/mach/cpu.h b/arch/arm/mach-at91/include/mach/cpu.h
index d3d7b993846b..86c71debab5b 100644
--- a/arch/arm/mach-at91/include/mach/cpu.h
+++ b/arch/arm/mach-at91/include/mach/cpu.h
@@ -53,6 +53,7 @@
53#define ARCH_EXID_SAMA5D33 0x00414300 53#define ARCH_EXID_SAMA5D33 0x00414300
54#define ARCH_EXID_SAMA5D34 0x00414301 54#define ARCH_EXID_SAMA5D34 0x00414301
55#define ARCH_EXID_SAMA5D35 0x00584300 55#define ARCH_EXID_SAMA5D35 0x00584300
56#define ARCH_EXID_SAMA5D36 0x00004301
56 57
57#define ARCH_FAMILY_AT91X92 0x09200000 58#define ARCH_FAMILY_AT91X92 0x09200000
58#define ARCH_FAMILY_AT91SAM9 0x01900000 59#define ARCH_FAMILY_AT91SAM9 0x01900000
@@ -105,7 +106,7 @@ enum at91_soc_subtype {
105 106
106 /* SAMA5D3 */ 107 /* SAMA5D3 */
107 AT91_SOC_SAMA5D31, AT91_SOC_SAMA5D33, AT91_SOC_SAMA5D34, 108 AT91_SOC_SAMA5D31, AT91_SOC_SAMA5D33, AT91_SOC_SAMA5D34,
108 AT91_SOC_SAMA5D35, 109 AT91_SOC_SAMA5D35, AT91_SOC_SAMA5D36,
109 110
110 /* No subtype for this SoC */ 111 /* No subtype for this SoC */
111 AT91_SOC_SUBTYPE_NONE, 112 AT91_SOC_SUBTYPE_NONE,
diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c
index 094b3459c288..eb6468dc60d5 100644
--- a/arch/arm/mach-at91/setup.c
+++ b/arch/arm/mach-at91/setup.c
@@ -233,6 +233,9 @@ static void __init soc_detect(u32 dbgu_base)
233 case ARCH_EXID_SAMA5D35: 233 case ARCH_EXID_SAMA5D35:
234 at91_soc_initdata.subtype = AT91_SOC_SAMA5D35; 234 at91_soc_initdata.subtype = AT91_SOC_SAMA5D35;
235 break; 235 break;
236 case ARCH_EXID_SAMA5D36:
237 at91_soc_initdata.subtype = AT91_SOC_SAMA5D36;
238 break;
236 } 239 }
237 } 240 }
238} 241}
@@ -275,6 +278,7 @@ static const char *soc_subtype_name[] = {
275 [AT91_SOC_SAMA5D33] = "sama5d33", 278 [AT91_SOC_SAMA5D33] = "sama5d33",
276 [AT91_SOC_SAMA5D34] = "sama5d34", 279 [AT91_SOC_SAMA5D34] = "sama5d34",
277 [AT91_SOC_SAMA5D35] = "sama5d35", 280 [AT91_SOC_SAMA5D35] = "sama5d35",
281 [AT91_SOC_SAMA5D36] = "sama5d36",
278 [AT91_SOC_SUBTYPE_NONE] = "None", 282 [AT91_SOC_SUBTYPE_NONE] = "None",
279 [AT91_SOC_SUBTYPE_UNKNOWN] = "Unknown", 283 [AT91_SOC_SUBTYPE_UNKNOWN] = "Unknown",
280}; 284};
diff --git a/arch/arm/mach-berlin/Kconfig b/arch/arm/mach-berlin/Kconfig
new file mode 100644
index 000000000000..7a02d222c378
--- /dev/null
+++ b/arch/arm/mach-berlin/Kconfig
@@ -0,0 +1,29 @@
1config ARCH_BERLIN
2 bool "Marvell Berlin SoCs" if ARCH_MULTI_V7
3 select ARM_GIC
4 select GENERIC_CLOCKEVENTS
5 select GENERIC_IRQ_CHIP
6 select COMMON_CLK
7 select DW_APB_ICTL
8 select DW_APB_TIMER_OF
9
10if ARCH_BERLIN
11
12menu "Marvell Berlin SoC variants"
13
14config MACH_BERLIN_BG2
15 bool "Marvell Armada 1500 (BG2)"
16 select CACHE_L2X0
17 select CPU_PJ4B
18 select HAVE_ARM_TWD if SMP
19 select HAVE_SMP
20
21config MACH_BERLIN_BG2CD
22 bool "Marvell Armada 1500-mini (BG2CD)"
23 select CACHE_L2X0
24 select CPU_V7
25 select HAVE_ARM_TWD if SMP
26
27endmenu
28
29endif
diff --git a/arch/arm/mach-berlin/Makefile b/arch/arm/mach-berlin/Makefile
new file mode 100644
index 000000000000..ab69fe956f49
--- /dev/null
+++ b/arch/arm/mach-berlin/Makefile
@@ -0,0 +1 @@
obj-y += berlin.o
diff --git a/arch/arm/mach-berlin/berlin.c b/arch/arm/mach-berlin/berlin.c
new file mode 100644
index 000000000000..025bcb5473eb
--- /dev/null
+++ b/arch/arm/mach-berlin/berlin.c
@@ -0,0 +1,39 @@
1/*
2 * Device Tree support for Marvell Berlin SoCs.
3 *
4 * Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
5 *
6 * based on GPL'ed 2.6 kernel sources
7 * (c) Marvell International Ltd.
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/init.h>
15#include <linux/io.h>
16#include <linux/kernel.h>
17#include <linux/of_platform.h>
18#include <asm/hardware/cache-l2x0.h>
19#include <asm/mach/arch.h>
20
21static void __init berlin_init_machine(void)
22{
23 /*
24 * with DT probing for L2CCs, berlin_init_machine can be removed.
25 * Note: 88DE3005 (Armada 1500-mini) uses pl310 l2cc
26 */
27 l2x0_of_init(0x70c00000, 0xfeffffff);
28 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
29}
30
31static const char * const berlin_dt_compat[] = {
32 "marvell,berlin",
33 NULL,
34};
35
36DT_MACHINE_START(BERLIN_DT, "Marvell Berlin")
37 .dt_compat = berlin_dt_compat,
38 .init_machine = berlin_init_machine,
39MACHINE_END
diff --git a/arch/arm/mach-clps711x/common.c b/arch/arm/mach-clps711x/common.c
index 134641d688bb..a1935911e4f1 100644
--- a/arch/arm/mach-clps711x/common.c
+++ b/arch/arm/mach-clps711x/common.c
@@ -259,7 +259,7 @@ asmlinkage void __exception_irq_entry clps711x_handle_irq(struct pt_regs *regs)
259 } while (1); 259 } while (1);
260} 260}
261 261
262static u32 notrace clps711x_sched_clock_read(void) 262static u64 notrace clps711x_sched_clock_read(void)
263{ 263{
264 return ~readw_relaxed(CLPS711X_VIRT_BASE + TC1D); 264 return ~readw_relaxed(CLPS711X_VIRT_BASE + TC1D);
265} 265}
@@ -366,7 +366,7 @@ void __init clps711x_timer_init(void)
366 tmp = clps_readl(SYSCON1) & ~(SYSCON1_TC1S | SYSCON1_TC1M); 366 tmp = clps_readl(SYSCON1) & ~(SYSCON1_TC1S | SYSCON1_TC1M);
367 clps_writel(tmp, SYSCON1); 367 clps_writel(tmp, SYSCON1);
368 368
369 setup_sched_clock(clps711x_sched_clock_read, 16, timl); 369 sched_clock_register(clps711x_sched_clock_read, 16, timl);
370 370
371 clocksource_mmio_init(CLPS711X_VIRT_BASE + TC1D, 371 clocksource_mmio_init(CLPS711X_VIRT_BASE + TC1D,
372 "clps711x_clocksource", timl, 300, 16, 372 "clps711x_clocksource", timl, 300, 16,
diff --git a/arch/arm/mach-davinci/devices-da8xx.c b/arch/arm/mach-davinci/devices-da8xx.c
index c46eccbbd512..78829c513fdc 100644
--- a/arch/arm/mach-davinci/devices-da8xx.c
+++ b/arch/arm/mach-davinci/devices-da8xx.c
@@ -487,7 +487,7 @@ int __init da8xx_register_emac(void)
487 487
488static struct resource da830_mcasp1_resources[] = { 488static struct resource da830_mcasp1_resources[] = {
489 { 489 {
490 .name = "mcasp1", 490 .name = "mpu",
491 .start = DAVINCI_DA830_MCASP1_REG_BASE, 491 .start = DAVINCI_DA830_MCASP1_REG_BASE,
492 .end = DAVINCI_DA830_MCASP1_REG_BASE + (SZ_1K * 12) - 1, 492 .end = DAVINCI_DA830_MCASP1_REG_BASE + (SZ_1K * 12) - 1,
493 .flags = IORESOURCE_MEM, 493 .flags = IORESOURCE_MEM,
@@ -515,7 +515,7 @@ static struct platform_device da830_mcasp1_device = {
515 515
516static struct resource da850_mcasp_resources[] = { 516static struct resource da850_mcasp_resources[] = {
517 { 517 {
518 .name = "mcasp", 518 .name = "mpu",
519 .start = DAVINCI_DA8XX_MCASP0_REG_BASE, 519 .start = DAVINCI_DA8XX_MCASP0_REG_BASE,
520 .end = DAVINCI_DA8XX_MCASP0_REG_BASE + (SZ_1K * 12) - 1, 520 .end = DAVINCI_DA8XX_MCASP0_REG_BASE + (SZ_1K * 12) - 1,
521 .flags = IORESOURCE_MEM, 521 .flags = IORESOURCE_MEM,
diff --git a/arch/arm/mach-davinci/dm355.c b/arch/arm/mach-davinci/dm355.c
index ef9ff1fb6f52..6117fc644188 100644
--- a/arch/arm/mach-davinci/dm355.c
+++ b/arch/arm/mach-davinci/dm355.c
@@ -641,6 +641,7 @@ static struct platform_device dm355_edma_device = {
641 641
642static struct resource dm355_asp1_resources[] = { 642static struct resource dm355_asp1_resources[] = {
643 { 643 {
644 .name = "mpu",
644 .start = DAVINCI_ASP1_BASE, 645 .start = DAVINCI_ASP1_BASE,
645 .end = DAVINCI_ASP1_BASE + SZ_8K - 1, 646 .end = DAVINCI_ASP1_BASE + SZ_8K - 1,
646 .flags = IORESOURCE_MEM, 647 .flags = IORESOURCE_MEM,
@@ -906,7 +907,7 @@ static struct davinci_gpio_platform_data dm355_gpio_platform_data = {
906int __init dm355_gpio_register(void) 907int __init dm355_gpio_register(void)
907{ 908{
908 return davinci_gpio_register(dm355_gpio_resources, 909 return davinci_gpio_register(dm355_gpio_resources,
909 sizeof(dm355_gpio_resources), 910 ARRAY_SIZE(dm355_gpio_resources),
910 &dm355_gpio_platform_data); 911 &dm355_gpio_platform_data);
911} 912}
912/*----------------------------------------------------------------------*/ 913/*----------------------------------------------------------------------*/
diff --git a/arch/arm/mach-davinci/dm365.c b/arch/arm/mach-davinci/dm365.c
index 1511a0680f9a..d7c6f85d3fc9 100644
--- a/arch/arm/mach-davinci/dm365.c
+++ b/arch/arm/mach-davinci/dm365.c
@@ -720,7 +720,7 @@ static struct davinci_gpio_platform_data dm365_gpio_platform_data = {
720int __init dm365_gpio_register(void) 720int __init dm365_gpio_register(void)
721{ 721{
722 return davinci_gpio_register(dm365_gpio_resources, 722 return davinci_gpio_register(dm365_gpio_resources,
723 sizeof(dm365_gpio_resources), 723 ARRAY_SIZE(dm365_gpio_resources),
724 &dm365_gpio_platform_data); 724 &dm365_gpio_platform_data);
725} 725}
726 726
@@ -942,6 +942,7 @@ static struct platform_device dm365_edma_device = {
942 942
943static struct resource dm365_asp_resources[] = { 943static struct resource dm365_asp_resources[] = {
944 { 944 {
945 .name = "mpu",
945 .start = DAVINCI_DM365_ASP0_BASE, 946 .start = DAVINCI_DM365_ASP0_BASE,
946 .end = DAVINCI_DM365_ASP0_BASE + SZ_8K - 1, 947 .end = DAVINCI_DM365_ASP0_BASE + SZ_8K - 1,
947 .flags = IORESOURCE_MEM, 948 .flags = IORESOURCE_MEM,
diff --git a/arch/arm/mach-davinci/dm644x.c b/arch/arm/mach-davinci/dm644x.c
index 143a3217e8ef..3ce47997bb46 100644
--- a/arch/arm/mach-davinci/dm644x.c
+++ b/arch/arm/mach-davinci/dm644x.c
@@ -572,6 +572,7 @@ static struct platform_device dm644x_edma_device = {
572/* DM6446 EVM uses ASP0; line-out is a pair of RCA jacks */ 572/* DM6446 EVM uses ASP0; line-out is a pair of RCA jacks */
573static struct resource dm644x_asp_resources[] = { 573static struct resource dm644x_asp_resources[] = {
574 { 574 {
575 .name = "mpu",
575 .start = DAVINCI_ASP0_BASE, 576 .start = DAVINCI_ASP0_BASE,
576 .end = DAVINCI_ASP0_BASE + SZ_8K - 1, 577 .end = DAVINCI_ASP0_BASE + SZ_8K - 1,
577 .flags = IORESOURCE_MEM, 578 .flags = IORESOURCE_MEM,
@@ -792,7 +793,7 @@ static struct davinci_gpio_platform_data dm644_gpio_platform_data = {
792int __init dm644x_gpio_register(void) 793int __init dm644x_gpio_register(void)
793{ 794{
794 return davinci_gpio_register(dm644_gpio_resources, 795 return davinci_gpio_register(dm644_gpio_resources,
795 sizeof(dm644_gpio_resources), 796 ARRAY_SIZE(dm644_gpio_resources),
796 &dm644_gpio_platform_data); 797 &dm644_gpio_platform_data);
797} 798}
798/*----------------------------------------------------------------------*/ 799/*----------------------------------------------------------------------*/
diff --git a/arch/arm/mach-davinci/dm646x.c b/arch/arm/mach-davinci/dm646x.c
index 2a73f299c1d0..0e81fea65e7f 100644
--- a/arch/arm/mach-davinci/dm646x.c
+++ b/arch/arm/mach-davinci/dm646x.c
@@ -621,7 +621,7 @@ static struct platform_device dm646x_edma_device = {
621 621
622static struct resource dm646x_mcasp0_resources[] = { 622static struct resource dm646x_mcasp0_resources[] = {
623 { 623 {
624 .name = "mcasp0", 624 .name = "mpu",
625 .start = DAVINCI_DM646X_MCASP0_REG_BASE, 625 .start = DAVINCI_DM646X_MCASP0_REG_BASE,
626 .end = DAVINCI_DM646X_MCASP0_REG_BASE + (SZ_1K << 1) - 1, 626 .end = DAVINCI_DM646X_MCASP0_REG_BASE + (SZ_1K << 1) - 1,
627 .flags = IORESOURCE_MEM, 627 .flags = IORESOURCE_MEM,
@@ -641,7 +641,7 @@ static struct resource dm646x_mcasp0_resources[] = {
641 641
642static struct resource dm646x_mcasp1_resources[] = { 642static struct resource dm646x_mcasp1_resources[] = {
643 { 643 {
644 .name = "mcasp1", 644 .name = "mpu",
645 .start = DAVINCI_DM646X_MCASP1_REG_BASE, 645 .start = DAVINCI_DM646X_MCASP1_REG_BASE,
646 .end = DAVINCI_DM646X_MCASP1_REG_BASE + (SZ_1K << 1) - 1, 646 .end = DAVINCI_DM646X_MCASP1_REG_BASE + (SZ_1K << 1) - 1,
647 .flags = IORESOURCE_MEM, 647 .flags = IORESOURCE_MEM,
@@ -769,7 +769,7 @@ static struct davinci_gpio_platform_data dm646x_gpio_platform_data = {
769int __init dm646x_gpio_register(void) 769int __init dm646x_gpio_register(void)
770{ 770{
771 return davinci_gpio_register(dm646x_gpio_resources, 771 return davinci_gpio_register(dm646x_gpio_resources,
772 sizeof(dm646x_gpio_resources), 772 ARRAY_SIZE(dm646x_gpio_resources),
773 &dm646x_gpio_platform_data); 773 &dm646x_gpio_platform_data);
774} 774}
775/*----------------------------------------------------------------------*/ 775/*----------------------------------------------------------------------*/
diff --git a/arch/arm/mach-davinci/time.c b/arch/arm/mach-davinci/time.c
index 56c6eb5266ad..24ad30f32ae3 100644
--- a/arch/arm/mach-davinci/time.c
+++ b/arch/arm/mach-davinci/time.c
@@ -285,7 +285,7 @@ static struct clocksource clocksource_davinci = {
285/* 285/*
286 * Overwrite weak default sched_clock with something more precise 286 * Overwrite weak default sched_clock with something more precise
287 */ 287 */
288static u32 notrace davinci_read_sched_clock(void) 288static u64 notrace davinci_read_sched_clock(void)
289{ 289{
290 return timer32_read(&timers[TID_CLOCKSOURCE]); 290 return timer32_read(&timers[TID_CLOCKSOURCE]);
291} 291}
@@ -391,7 +391,7 @@ void __init davinci_timer_init(void)
391 davinci_clock_tick_rate)) 391 davinci_clock_tick_rate))
392 printk(err, clocksource_davinci.name); 392 printk(err, clocksource_davinci.name);
393 393
394 setup_sched_clock(davinci_read_sched_clock, 32, 394 sched_clock_register(davinci_read_sched_clock, 32,
395 davinci_clock_tick_rate); 395 davinci_clock_tick_rate);
396 396
397 /* setup clockevent */ 397 /* setup clockevent */
diff --git a/arch/arm/mach-efm32/Makefile b/arch/arm/mach-efm32/Makefile
new file mode 100644
index 000000000000..3a74af7413e8
--- /dev/null
+++ b/arch/arm/mach-efm32/Makefile
@@ -0,0 +1 @@
obj-y += dtmachine.o
diff --git a/arch/arm/mach-efm32/Makefile.boot b/arch/arm/mach-efm32/Makefile.boot
new file mode 100644
index 000000000000..eacfc3f5c33e
--- /dev/null
+++ b/arch/arm/mach-efm32/Makefile.boot
@@ -0,0 +1,3 @@
1# Empty file waiting for deletion once Makefile.boot isn't needed any more.
2# Patch waits for application at
3# http://www.arm.linux.org.uk/developer/patches/viewpatch.php?id=7889/1 .
diff --git a/arch/arm/mach-efm32/dtmachine.c b/arch/arm/mach-efm32/dtmachine.c
new file mode 100644
index 000000000000..2367495193c1
--- /dev/null
+++ b/arch/arm/mach-efm32/dtmachine.c
@@ -0,0 +1,15 @@
1#include <linux/kernel.h>
2
3#include <asm/v7m.h>
4
5#include <asm/mach/arch.h>
6
7static const char *const efm32gg_compat[] __initconst = {
8 "efm32,dk3750",
9 NULL
10};
11
12DT_MACHINE_START(EFM32DT, "EFM32 (Device Tree Support)")
13 .dt_compat = efm32gg_compat,
14 .restart = armv7m_restart,
15MACHINE_END
diff --git a/arch/arm/mach-efm32/include/mach/entry-macro.S b/arch/arm/mach-efm32/include/mach/entry-macro.S
new file mode 100644
index 000000000000..322159d5ed91
--- /dev/null
+++ b/arch/arm/mach-efm32/include/mach/entry-macro.S
@@ -0,0 +1,4 @@
1/*
2 * Empty file waiting for deletion once <mach/entry-macro.S> isn't needed any
3 * more. Patch "ARM: v7-M: drop using mach/entry-macro.S" sitting in next.
4 */
diff --git a/arch/arm/mach-efm32/include/mach/timex.h b/arch/arm/mach-efm32/include/mach/timex.h
new file mode 100644
index 000000000000..7a8b26da6599
--- /dev/null
+++ b/arch/arm/mach-efm32/include/mach/timex.h
@@ -0,0 +1,3 @@
1/*
2 * Empty file waiting for deletion once <mach/timex.h> isn't needed any more.
3 */
diff --git a/arch/arm/mach-ep93xx/Kconfig b/arch/arm/mach-ep93xx/Kconfig
index 93e54fd4e3d5..bec570ae6494 100644
--- a/arch/arm/mach-ep93xx/Kconfig
+++ b/arch/arm/mach-ep93xx/Kconfig
@@ -5,6 +5,7 @@ menu "Cirrus EP93xx Implementation Options"
5config EP93XX_SOC_COMMON 5config EP93XX_SOC_COMMON
6 bool 6 bool
7 default y 7 default y
8 select SOC_BUS
8 select LEDS_GPIO_REGISTER 9 select LEDS_GPIO_REGISTER
9 10
10config CRUNCH 11config CRUNCH
diff --git a/arch/arm/mach-ep93xx/core.c b/arch/arm/mach-ep93xx/core.c
index d95ee28a616a..157ba88433c9 100644
--- a/arch/arm/mach-ep93xx/core.c
+++ b/arch/arm/mach-ep93xx/core.c
@@ -21,6 +21,7 @@
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/interrupt.h> 22#include <linux/interrupt.h>
23#include <linux/dma-mapping.h> 23#include <linux/dma-mapping.h>
24#include <linux/sys_soc.h>
24#include <linux/timex.h> 25#include <linux/timex.h>
25#include <linux/irq.h> 26#include <linux/irq.h>
26#include <linux/io.h> 27#include <linux/io.h>
@@ -44,6 +45,7 @@
44#include <linux/platform_data/spi-ep93xx.h> 45#include <linux/platform_data/spi-ep93xx.h>
45#include <mach/gpio-ep93xx.h> 46#include <mach/gpio-ep93xx.h>
46 47
48#include <asm/mach/arch.h>
47#include <asm/mach/map.h> 49#include <asm/mach/map.h>
48#include <asm/mach/time.h> 50#include <asm/mach/time.h>
49 51
@@ -137,7 +139,7 @@ static irqreturn_t ep93xx_timer_interrupt(int irq, void *dev_id)
137 139
138static struct irqaction ep93xx_timer_irq = { 140static struct irqaction ep93xx_timer_irq = {
139 .name = "ep93xx timer", 141 .name = "ep93xx timer",
140 .flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL, 142 .flags = IRQF_TIMER | IRQF_IRQPOLL,
141 .handler = ep93xx_timer_interrupt, 143 .handler = ep93xx_timer_interrupt,
142}; 144};
143 145
@@ -925,8 +927,108 @@ void ep93xx_ide_release_gpio(struct platform_device *pdev)
925} 927}
926EXPORT_SYMBOL(ep93xx_ide_release_gpio); 928EXPORT_SYMBOL(ep93xx_ide_release_gpio);
927 929
928void __init ep93xx_init_devices(void) 930/*************************************************************************
931 * EP93xx Security peripheral
932 *************************************************************************/
933
934/*
935 * The Maverick Key is 256 bits of micro fuses blown at the factory during
936 * manufacturing to uniquely identify a part.
937 *
938 * See: http://arm.cirrus.com/forum/viewtopic.php?t=486&highlight=maverick+key
939 */
940#define EP93XX_SECURITY_REG(x) (EP93XX_SECURITY_BASE + (x))
941#define EP93XX_SECURITY_SECFLG EP93XX_SECURITY_REG(0x2400)
942#define EP93XX_SECURITY_FUSEFLG EP93XX_SECURITY_REG(0x2410)
943#define EP93XX_SECURITY_UNIQID EP93XX_SECURITY_REG(0x2440)
944#define EP93XX_SECURITY_UNIQCHK EP93XX_SECURITY_REG(0x2450)
945#define EP93XX_SECURITY_UNIQVAL EP93XX_SECURITY_REG(0x2460)
946#define EP93XX_SECURITY_SECID1 EP93XX_SECURITY_REG(0x2500)
947#define EP93XX_SECURITY_SECID2 EP93XX_SECURITY_REG(0x2504)
948#define EP93XX_SECURITY_SECCHK1 EP93XX_SECURITY_REG(0x2520)
949#define EP93XX_SECURITY_SECCHK2 EP93XX_SECURITY_REG(0x2524)
950#define EP93XX_SECURITY_UNIQID2 EP93XX_SECURITY_REG(0x2700)
951#define EP93XX_SECURITY_UNIQID3 EP93XX_SECURITY_REG(0x2704)
952#define EP93XX_SECURITY_UNIQID4 EP93XX_SECURITY_REG(0x2708)
953#define EP93XX_SECURITY_UNIQID5 EP93XX_SECURITY_REG(0x270c)
954
955static char ep93xx_soc_id[33];
956
957static const char __init *ep93xx_get_soc_id(void)
929{ 958{
959 unsigned int id, id2, id3, id4, id5;
960
961 if (__raw_readl(EP93XX_SECURITY_UNIQVAL) != 1)
962 return "bad Hamming code";
963
964 id = __raw_readl(EP93XX_SECURITY_UNIQID);
965 id2 = __raw_readl(EP93XX_SECURITY_UNIQID2);
966 id3 = __raw_readl(EP93XX_SECURITY_UNIQID3);
967 id4 = __raw_readl(EP93XX_SECURITY_UNIQID4);
968 id5 = __raw_readl(EP93XX_SECURITY_UNIQID5);
969
970 if (id != id2)
971 return "invalid";
972
973 snprintf(ep93xx_soc_id, sizeof(ep93xx_soc_id),
974 "%08x%08x%08x%08x", id2, id3, id4, id5);
975
976 return ep93xx_soc_id;
977}
978
979static const char __init *ep93xx_get_soc_rev(void)
980{
981 int rev = ep93xx_chip_revision();
982
983 switch (rev) {
984 case EP93XX_CHIP_REV_D0:
985 return "D0";
986 case EP93XX_CHIP_REV_D1:
987 return "D1";
988 case EP93XX_CHIP_REV_E0:
989 return "E0";
990 case EP93XX_CHIP_REV_E1:
991 return "E1";
992 case EP93XX_CHIP_REV_E2:
993 return "E2";
994 default:
995 return "unknown";
996 }
997}
998
999static const char __init *ep93xx_get_machine_name(void)
1000{
1001 return kasprintf(GFP_KERNEL,"%s", machine_desc->name);
1002}
1003
1004static struct device __init *ep93xx_init_soc(void)
1005{
1006 struct soc_device_attribute *soc_dev_attr;
1007 struct soc_device *soc_dev;
1008
1009 soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
1010 if (!soc_dev_attr)
1011 return NULL;
1012
1013 soc_dev_attr->machine = ep93xx_get_machine_name();
1014 soc_dev_attr->family = "Cirrus Logic EP93xx";
1015 soc_dev_attr->revision = ep93xx_get_soc_rev();
1016 soc_dev_attr->soc_id = ep93xx_get_soc_id();
1017
1018 soc_dev = soc_device_register(soc_dev_attr);
1019 if (IS_ERR(soc_dev)) {
1020 kfree(soc_dev_attr->machine);
1021 kfree(soc_dev_attr);
1022 return NULL;
1023 }
1024
1025 return soc_device_to_device(soc_dev);
1026}
1027
1028struct device __init *ep93xx_init_devices(void)
1029{
1030 struct device *parent;
1031
930 /* Disallow access to MaverickCrunch initially */ 1032 /* Disallow access to MaverickCrunch initially */
931 ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_CPENA); 1033 ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_CPENA);
932 1034
@@ -937,6 +1039,8 @@ void __init ep93xx_init_devices(void)
937 EP93XX_SYSCON_DEVCFG_GONIDE | 1039 EP93XX_SYSCON_DEVCFG_GONIDE |
938 EP93XX_SYSCON_DEVCFG_HONIDE); 1040 EP93XX_SYSCON_DEVCFG_HONIDE);
939 1041
1042 parent = ep93xx_init_soc();
1043
940 /* Get the GPIO working early, other devices need it */ 1044 /* Get the GPIO working early, other devices need it */
941 platform_device_register(&ep93xx_gpio_device); 1045 platform_device_register(&ep93xx_gpio_device);
942 1046
@@ -949,6 +1053,8 @@ void __init ep93xx_init_devices(void)
949 platform_device_register(&ep93xx_wdt_device); 1053 platform_device_register(&ep93xx_wdt_device);
950 1054
951 gpio_led_register_device(-1, &ep93xx_led_data); 1055 gpio_led_register_device(-1, &ep93xx_led_data);
1056
1057 return parent;
952} 1058}
953 1059
954void ep93xx_restart(enum reboot_mode mode, const char *cmd) 1060void ep93xx_restart(enum reboot_mode mode, const char *cmd)
diff --git a/arch/arm/mach-ep93xx/include/mach/platform.h b/arch/arm/mach-ep93xx/include/mach/platform.h
index e256e0baec2e..4c0bbd97f741 100644
--- a/arch/arm/mach-ep93xx/include/mach/platform.h
+++ b/arch/arm/mach-ep93xx/include/mach/platform.h
@@ -6,6 +6,7 @@
6 6
7#include <linux/reboot.h> 7#include <linux/reboot.h>
8 8
9struct device;
9struct i2c_gpio_platform_data; 10struct i2c_gpio_platform_data;
10struct i2c_board_info; 11struct i2c_board_info;
11struct spi_board_info; 12struct spi_board_info;
@@ -54,7 +55,7 @@ void ep93xx_register_ide(void);
54int ep93xx_ide_acquire_gpio(struct platform_device *pdev); 55int ep93xx_ide_acquire_gpio(struct platform_device *pdev);
55void ep93xx_ide_release_gpio(struct platform_device *pdev); 56void ep93xx_ide_release_gpio(struct platform_device *pdev);
56 57
57void ep93xx_init_devices(void); 58struct device *ep93xx_init_devices(void);
58extern void ep93xx_timer_init(void); 59extern void ep93xx_timer_init(void);
59 60
60void ep93xx_restart(enum reboot_mode, const char *); 61void ep93xx_restart(enum reboot_mode, const char *);
diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c
index b3d7e5634b83..bd3bf66ce344 100644
--- a/arch/arm/mach-highbank/highbank.c
+++ b/arch/arm/mach-highbank/highbank.c
@@ -17,12 +17,15 @@
17#include <linux/clkdev.h> 17#include <linux/clkdev.h>
18#include <linux/clocksource.h> 18#include <linux/clocksource.h>
19#include <linux/dma-mapping.h> 19#include <linux/dma-mapping.h>
20#include <linux/input.h>
20#include <linux/io.h> 21#include <linux/io.h>
21#include <linux/irqchip.h> 22#include <linux/irqchip.h>
23#include <linux/mailbox.h>
22#include <linux/of.h> 24#include <linux/of.h>
23#include <linux/of_irq.h> 25#include <linux/of_irq.h>
24#include <linux/of_platform.h> 26#include <linux/of_platform.h>
25#include <linux/of_address.h> 27#include <linux/of_address.h>
28#include <linux/reboot.h>
26#include <linux/amba/bus.h> 29#include <linux/amba/bus.h>
27#include <linux/platform_device.h> 30#include <linux/platform_device.h>
28 31
@@ -130,6 +133,24 @@ static struct platform_device highbank_cpuidle_device = {
130 .name = "cpuidle-calxeda", 133 .name = "cpuidle-calxeda",
131}; 134};
132 135
136static int hb_keys_notifier(struct notifier_block *nb, unsigned long event, void *data)
137{
138 u32 key = *(u32 *)data;
139
140 if (event != 0x1000)
141 return 0;
142
143 if (key == KEY_POWER)
144 orderly_poweroff(false);
145 else if (key == 0xffff)
146 ctrl_alt_del();
147
148 return 0;
149}
150static struct notifier_block hb_keys_nb = {
151 .notifier_call = hb_keys_notifier,
152};
153
133static void __init highbank_init(void) 154static void __init highbank_init(void)
134{ 155{
135 struct device_node *np; 156 struct device_node *np;
@@ -145,6 +166,8 @@ static void __init highbank_init(void)
145 bus_register_notifier(&platform_bus_type, &highbank_platform_nb); 166 bus_register_notifier(&platform_bus_type, &highbank_platform_nb);
146 bus_register_notifier(&amba_bustype, &highbank_amba_nb); 167 bus_register_notifier(&amba_bustype, &highbank_amba_nb);
147 168
169 pl320_ipc_register_notifier(&hb_keys_nb);
170
148 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); 171 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
149 172
150 if (psci_ops.cpu_suspend) 173 if (psci_ops.cpu_suspend)
diff --git a/arch/arm/mach-imx/time.c b/arch/arm/mach-imx/time.c
index 9b6638aadeaa..1a3a5f615770 100644
--- a/arch/arm/mach-imx/time.c
+++ b/arch/arm/mach-imx/time.c
@@ -111,7 +111,7 @@ static void gpt_irq_acknowledge(void)
111 111
112static void __iomem *sched_clock_reg; 112static void __iomem *sched_clock_reg;
113 113
114static u32 notrace mxc_read_sched_clock(void) 114static u64 notrace mxc_read_sched_clock(void)
115{ 115{
116 return sched_clock_reg ? __raw_readl(sched_clock_reg) : 0; 116 return sched_clock_reg ? __raw_readl(sched_clock_reg) : 0;
117} 117}
@@ -123,7 +123,7 @@ static int __init mxc_clocksource_init(struct clk *timer_clk)
123 123
124 sched_clock_reg = reg; 124 sched_clock_reg = reg;
125 125
126 setup_sched_clock(mxc_read_sched_clock, 32, c); 126 sched_clock_register(mxc_read_sched_clock, 32, c);
127 return clocksource_mmio_init(reg, "mxc_timer1", c, 200, 32, 127 return clocksource_mmio_init(reg, "mxc_timer1", c, 200, 32,
128 clocksource_mmio_readl_up); 128 clocksource_mmio_readl_up);
129} 129}
diff --git a/arch/arm/mach-integrator/integrator_ap.c b/arch/arm/mach-integrator/integrator_ap.c
index d50dc2dbfd89..473e21b87364 100644
--- a/arch/arm/mach-integrator/integrator_ap.c
+++ b/arch/arm/mach-integrator/integrator_ap.c
@@ -277,7 +277,7 @@ struct amba_pl010_data ap_uart_data = {
277 277
278static unsigned long timer_reload; 278static unsigned long timer_reload;
279 279
280static u32 notrace integrator_read_sched_clock(void) 280static u64 notrace integrator_read_sched_clock(void)
281{ 281{
282 return -readl((void __iomem *) TIMER2_VA_BASE + TIMER_VALUE); 282 return -readl((void __iomem *) TIMER2_VA_BASE + TIMER_VALUE);
283} 283}
@@ -298,7 +298,7 @@ static void integrator_clocksource_init(unsigned long inrate,
298 298
299 clocksource_mmio_init(base + TIMER_VALUE, "timer2", 299 clocksource_mmio_init(base + TIMER_VALUE, "timer2",
300 rate, 200, 16, clocksource_mmio_readl_down); 300 rate, 200, 16, clocksource_mmio_readl_down);
301 setup_sched_clock(integrator_read_sched_clock, 16, rate); 301 sched_clock_register(integrator_read_sched_clock, 16, rate);
302} 302}
303 303
304static void __iomem * clkevt_base; 304static void __iomem * clkevt_base;
diff --git a/arch/arm/mach-ixp4xx/common.c b/arch/arm/mach-ixp4xx/common.c
index 9edaf4734fa8..bc9d8ec2918e 100644
--- a/arch/arm/mach-ixp4xx/common.c
+++ b/arch/arm/mach-ixp4xx/common.c
@@ -475,7 +475,7 @@ void __init ixp4xx_sys_init(void)
475/* 475/*
476 * sched_clock() 476 * sched_clock()
477 */ 477 */
478static u32 notrace ixp4xx_read_sched_clock(void) 478static u64 notrace ixp4xx_read_sched_clock(void)
479{ 479{
480 return *IXP4XX_OSTS; 480 return *IXP4XX_OSTS;
481} 481}
@@ -493,7 +493,7 @@ unsigned long ixp4xx_timer_freq = IXP4XX_TIMER_FREQ;
493EXPORT_SYMBOL(ixp4xx_timer_freq); 493EXPORT_SYMBOL(ixp4xx_timer_freq);
494static void __init ixp4xx_clocksource_init(void) 494static void __init ixp4xx_clocksource_init(void)
495{ 495{
496 setup_sched_clock(ixp4xx_read_sched_clock, 32, ixp4xx_timer_freq); 496 sched_clock_register(ixp4xx_read_sched_clock, 32, ixp4xx_timer_freq);
497 497
498 clocksource_mmio_init(NULL, "OSTS", ixp4xx_timer_freq, 200, 32, 498 clocksource_mmio_init(NULL, "OSTS", ixp4xx_timer_freq, 200, 32,
499 ixp4xx_clocksource_read); 499 ixp4xx_clocksource_read);
diff --git a/arch/arm/mach-keystone/Kconfig b/arch/arm/mach-keystone/Kconfig
index f20c53e75ed9..dabc5eee52e7 100644
--- a/arch/arm/mach-keystone/Kconfig
+++ b/arch/arm/mach-keystone/Kconfig
@@ -11,6 +11,8 @@ config ARCH_KEYSTONE
11 select ARM_ERRATA_798181 if SMP 11 select ARM_ERRATA_798181 if SMP
12 select COMMON_CLK_KEYSTONE 12 select COMMON_CLK_KEYSTONE
13 select TI_EDMA 13 select TI_EDMA
14 select ARCH_SUPPORTS_BIG_ENDIAN
15 select ZONE_DMA if ARM_LPAE
14 help 16 help
15 Support for boards based on the Texas Instruments Keystone family of 17 Support for boards based on the Texas Instruments Keystone family of
16 SoCs. 18 SoCs.
diff --git a/arch/arm/mach-keystone/keystone.c b/arch/arm/mach-keystone/keystone.c
index b661c5c2870a..6e6bb7d5ea30 100644
--- a/arch/arm/mach-keystone/keystone.c
+++ b/arch/arm/mach-keystone/keystone.c
@@ -41,6 +41,7 @@ static void __init keystone_init(void)
41 if (WARN_ON(!keystone_rstctrl)) 41 if (WARN_ON(!keystone_rstctrl))
42 pr_warn("ti,keystone-reset iomap error\n"); 42 pr_warn("ti,keystone-reset iomap error\n");
43 43
44 keystone_pm_runtime_init();
44 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); 45 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
45} 46}
46 47
@@ -68,6 +69,9 @@ void keystone_restart(enum reboot_mode mode, const char *cmd)
68} 69}
69 70
70DT_MACHINE_START(KEYSTONE, "Keystone") 71DT_MACHINE_START(KEYSTONE, "Keystone")
72#if defined(CONFIG_ZONE_DMA) && defined(CONFIG_ARM_LPAE)
73 .dma_zone_size = SZ_2G,
74#endif
71 .smp = smp_ops(keystone_smp_ops), 75 .smp = smp_ops(keystone_smp_ops),
72 .init_machine = keystone_init, 76 .init_machine = keystone_init,
73 .dt_compat = keystone_match, 77 .dt_compat = keystone_match,
diff --git a/arch/arm/mach-keystone/keystone.h b/arch/arm/mach-keystone/keystone.h
index 60bef9dedb12..cd04a1c14de8 100644
--- a/arch/arm/mach-keystone/keystone.h
+++ b/arch/arm/mach-keystone/keystone.h
@@ -18,6 +18,7 @@
18extern struct smp_operations keystone_smp_ops; 18extern struct smp_operations keystone_smp_ops;
19extern void secondary_startup(void); 19extern void secondary_startup(void);
20extern u32 keystone_cpu_smc(u32 command, u32 cpu, u32 addr); 20extern u32 keystone_cpu_smc(u32 command, u32 cpu, u32 addr);
21extern int keystone_pm_runtime_init(void);
21 22
22#endif /* __ASSEMBLER__ */ 23#endif /* __ASSEMBLER__ */
23#endif /* __KEYSTONE_H__ */ 24#endif /* __KEYSTONE_H__ */
diff --git a/arch/arm/mach-keystone/pm_domain.c b/arch/arm/mach-keystone/pm_domain.c
index 29625232e954..ca79ddac38bc 100644
--- a/arch/arm/mach-keystone/pm_domain.c
+++ b/arch/arm/mach-keystone/pm_domain.c
@@ -74,9 +74,7 @@ int __init keystone_pm_runtime_init(void)
74 if (!np) 74 if (!np)
75 return 0; 75 return 0;
76 76
77 of_clk_init(NULL);
78 pm_clk_add_notifier(&platform_bus_type, &platform_domain_notifier); 77 pm_clk_add_notifier(&platform_bus_type, &platform_domain_notifier);
79 78
80 return 0; 79 return 0;
81} 80}
82subsys_initcall(keystone_pm_runtime_init);
diff --git a/arch/arm/mach-mmp/time.c b/arch/arm/mach-mmp/time.c
index 7ac41e83cfef..024022d91fe3 100644
--- a/arch/arm/mach-mmp/time.c
+++ b/arch/arm/mach-mmp/time.c
@@ -61,7 +61,7 @@ static inline uint32_t timer_read(void)
61 return __raw_readl(mmp_timer_base + TMR_CVWR(1)); 61 return __raw_readl(mmp_timer_base + TMR_CVWR(1));
62} 62}
63 63
64static u32 notrace mmp_read_sched_clock(void) 64static u64 notrace mmp_read_sched_clock(void)
65{ 65{
66 return timer_read(); 66 return timer_read();
67} 67}
@@ -195,7 +195,7 @@ void __init timer_init(int irq)
195{ 195{
196 timer_config(); 196 timer_config();
197 197
198 setup_sched_clock(mmp_read_sched_clock, 32, CLOCK_TICK_RATE); 198 sched_clock_register(mmp_read_sched_clock, 32, CLOCK_TICK_RATE);
199 199
200 ckevt.cpumask = cpumask_of(0); 200 ckevt.cpumask = cpumask_of(0);
201 201
diff --git a/arch/arm/mach-moxart/Kconfig b/arch/arm/mach-moxart/Kconfig
new file mode 100644
index 000000000000..ba470d64493b
--- /dev/null
+++ b/arch/arm/mach-moxart/Kconfig
@@ -0,0 +1,31 @@
1config ARCH_MOXART
2 bool "MOXA ART SoC" if ARCH_MULTI_V4T
3 select CPU_FA526
4 select ARM_DMA_MEM_BUFFERABLE
5 select DMA_OF
6 select USE_OF
7 select CLKSRC_OF
8 select CLKSRC_MMIO
9 select HAVE_CLK
10 select COMMON_CLK
11 select GENERIC_IRQ_CHIP
12 select ARCH_REQUIRE_GPIOLIB
13 select GENERIC_CLOCKEVENTS
14 select PHYLIB if NETDEVICES
15 help
16 Say Y here if you want to run your kernel on hardware with a
17 MOXA ART SoC.
18 The MOXA ART SoC is based on a Faraday FA526 ARMv4 32-bit
19 192 MHz CPU with MMU and 16KB/8KB D/I-cache (UC-7112-LX).
20 Used on models UC-7101, UC-7112/UC-7110, IA240/IA241, IA3341.
21
22if ARCH_MOXART
23
24config MACH_UC7112LX
25 bool "MOXA UC-7112-LX"
26 depends on ARCH_MOXART
27 help
28 Say Y here if you intend to run this kernel on a MOXA
29 UC-7112-LX embedded computer.
30
31endif
diff --git a/arch/arm/mach-moxart/Makefile b/arch/arm/mach-moxart/Makefile
new file mode 100644
index 000000000000..fa022eb10ca1
--- /dev/null
+++ b/arch/arm/mach-moxart/Makefile
@@ -0,0 +1,3 @@
1# Object file lists.
2
3obj-$(CONFIG_MACH_UC7112LX) += moxart.o
diff --git a/arch/arm/mach-moxart/moxart.c b/arch/arm/mach-moxart/moxart.c
new file mode 100644
index 000000000000..86b6d9b57c54
--- /dev/null
+++ b/arch/arm/mach-moxart/moxart.c
@@ -0,0 +1,15 @@
1/*
2 * arch/arm/mach-moxart/moxart.c
3 *
4 * (C) Copyright 2013, Jonas Jensen <jonas.jensen@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; 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 */
diff --git a/arch/arm/mach-msm/Kconfig b/arch/arm/mach-msm/Kconfig
index 2586c2865874..702553b96137 100644
--- a/arch/arm/mach-msm/Kconfig
+++ b/arch/arm/mach-msm/Kconfig
@@ -44,6 +44,7 @@ endchoice
44 44
45config ARCH_MSM8X60 45config ARCH_MSM8X60
46 bool "MSM8X60" 46 bool "MSM8X60"
47 select ARCH_MSM_DT
47 select ARM_GIC 48 select ARM_GIC
48 select CPU_V7 49 select CPU_V7
49 select GPIO_MSM_V2 50 select GPIO_MSM_V2
@@ -52,15 +53,25 @@ config ARCH_MSM8X60
52 53
53config ARCH_MSM8960 54config ARCH_MSM8960
54 bool "MSM8960" 55 bool "MSM8960"
56 select ARCH_MSM_DT
55 select ARM_GIC 57 select ARM_GIC
56 select CPU_V7 58 select CPU_V7
57 select HAVE_SMP 59 select HAVE_SMP
58 select GPIO_MSM_V2 60 select GPIO_MSM_V2
59 select MSM_SCM if SMP 61 select MSM_SCM if SMP
60 62
63config ARCH_MSM8974
64 bool "MSM8974"
65 select ARCH_MSM_DT
66 select ARM_GIC
67 select CPU_V7
68 select HAVE_ARM_ARCH_TIMER
69 select HAVE_SMP
70 select MSM_SCM if SMP
71 select USE_OF
72
61config ARCH_MSM_DT 73config ARCH_MSM_DT
62 def_bool y 74 bool
63 depends on (ARCH_MSM8X60 || ARCH_MSM8960)
64 select SPARSE_IRQ 75 select SPARSE_IRQ
65 select USE_OF 76 select USE_OF
66 77
diff --git a/arch/arm/mach-msm/board-trout.c b/arch/arm/mach-msm/board-trout.c
index ccf6621bc664..015d544aa017 100644
--- a/arch/arm/mach-msm/board-trout.c
+++ b/arch/arm/mach-msm/board-trout.c
@@ -13,6 +13,7 @@
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 */ 15 */
16#define pr_fmt(fmt) "%s: " fmt, __func__
16 17
17#include <linux/kernel.h> 18#include <linux/kernel.h>
18#include <linux/init.h> 19#include <linux/init.h>
@@ -68,12 +69,11 @@ static void __init trout_init(void)
68 69
69 platform_add_devices(devices, ARRAY_SIZE(devices)); 70 platform_add_devices(devices, ARRAY_SIZE(devices));
70 71
71#ifdef CONFIG_MMC 72 if (IS_ENABLED(CONFIG_MMC)) {
72 rc = trout_init_mmc(system_rev); 73 rc = trout_init_mmc(system_rev);
73 if (rc) 74 if (rc)
74 printk(KERN_CRIT "%s: MMC init failure (%d)\n", __func__, rc); 75 pr_crit("MMC init failure (%d)\n", rc);
75#endif 76 }
76
77} 77}
78 78
79static struct map_desc trout_io_desc[] __initdata = { 79static struct map_desc trout_io_desc[] __initdata = {
diff --git a/arch/arm/mach-msm/timer.c b/arch/arm/mach-msm/timer.c
index 1e9c3383daba..fd1644987534 100644
--- a/arch/arm/mach-msm/timer.c
+++ b/arch/arm/mach-msm/timer.c
@@ -187,7 +187,7 @@ static struct notifier_block msm_timer_cpu_nb = {
187 .notifier_call = msm_timer_cpu_notify, 187 .notifier_call = msm_timer_cpu_notify,
188}; 188};
189 189
190static notrace u32 msm_sched_clock_read(void) 190static u64 notrace msm_sched_clock_read(void)
191{ 191{
192 return msm_clocksource.read(&msm_clocksource); 192 return msm_clocksource.read(&msm_clocksource);
193} 193}
@@ -229,7 +229,7 @@ err:
229 res = clocksource_register_hz(cs, dgt_hz); 229 res = clocksource_register_hz(cs, dgt_hz);
230 if (res) 230 if (res)
231 pr_err("clocksource_register failed\n"); 231 pr_err("clocksource_register failed\n");
232 setup_sched_clock(msm_sched_clock_read, sched_bits, dgt_hz); 232 sched_clock_register(msm_sched_clock_read, sched_bits, dgt_hz);
233} 233}
234 234
235#ifdef CONFIG_OF 235#ifdef CONFIG_OF
diff --git a/arch/arm/mach-omap1/time.c b/arch/arm/mach-omap1/time.c
index 6b5f298d6638..a7588cfd0286 100644
--- a/arch/arm/mach-omap1/time.c
+++ b/arch/arm/mach-omap1/time.c
@@ -181,7 +181,7 @@ static __init void omap_init_mpu_timer(unsigned long rate)
181 * --------------------------------------------------------------------------- 181 * ---------------------------------------------------------------------------
182 */ 182 */
183 183
184static u32 notrace omap_mpu_read_sched_clock(void) 184static u64 notrace omap_mpu_read_sched_clock(void)
185{ 185{
186 return ~omap_mpu_timer_read(1); 186 return ~omap_mpu_timer_read(1);
187} 187}
@@ -193,7 +193,7 @@ static void __init omap_init_clocksource(unsigned long rate)
193 "%s: can't register clocksource!\n"; 193 "%s: can't register clocksource!\n";
194 194
195 omap_mpu_timer_start(1, ~0, 1); 195 omap_mpu_timer_start(1, ~0, 1);
196 setup_sched_clock(omap_mpu_read_sched_clock, 32, rate); 196 sched_clock_register(omap_mpu_read_sched_clock, 32, rate);
197 197
198 if (clocksource_mmio_init(&timer->read_tim, "mpu_timer2", rate, 198 if (clocksource_mmio_init(&timer->read_tim, "mpu_timer2", rate,
199 300, 32, clocksource_mmio_readl_down)) 199 300, 32, clocksource_mmio_readl_down))
diff --git a/arch/arm/mach-omap2/board-generic.c b/arch/arm/mach-omap2/board-generic.c
index 19f1652e94cf..8d972ff18c56 100644
--- a/arch/arm/mach-omap2/board-generic.c
+++ b/arch/arm/mach-omap2/board-generic.c
@@ -131,6 +131,24 @@ DT_MACHINE_START(OMAP3_GP_DT, "Generic OMAP3-GP (Flattened Device Tree)")
131 .dt_compat = omap3_gp_boards_compat, 131 .dt_compat = omap3_gp_boards_compat,
132 .restart = omap3xxx_restart, 132 .restart = omap3xxx_restart,
133MACHINE_END 133MACHINE_END
134
135static const char *am3517_boards_compat[] __initdata = {
136 "ti,am3517",
137 NULL,
138};
139
140DT_MACHINE_START(AM3517_DT, "Generic AM3517 (Flattened Device Tree)")
141 .reserve = omap_reserve,
142 .map_io = omap3_map_io,
143 .init_early = am35xx_init_early,
144 .init_irq = omap_intc_of_init,
145 .handle_irq = omap3_intc_handle_irq,
146 .init_machine = omap_generic_init,
147 .init_late = omap3_init_late,
148 .init_time = omap3_gptimer_timer_init,
149 .dt_compat = am3517_boards_compat,
150 .restart = omap3xxx_restart,
151MACHINE_END
134#endif 152#endif
135 153
136#ifdef CONFIG_SOC_AM33XX 154#ifdef CONFIG_SOC_AM33XX
diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
index 53f0735817bb..e0a398cf28d8 100644
--- a/arch/arm/mach-omap2/omap_device.c
+++ b/arch/arm/mach-omap2/omap_device.c
@@ -183,6 +183,10 @@ static int omap_device_build_from_dt(struct platform_device *pdev)
183odbfd_exit1: 183odbfd_exit1:
184 kfree(hwmods); 184 kfree(hwmods);
185odbfd_exit: 185odbfd_exit:
186 /* if data/we are at fault.. load up a fail handler */
187 if (ret)
188 pdev->dev.pm_domain = &omap_device_fail_pm_domain;
189
186 return ret; 190 return ret;
187} 191}
188 192
@@ -604,6 +608,19 @@ static int _od_runtime_resume(struct device *dev)
604 608
605 return pm_generic_runtime_resume(dev); 609 return pm_generic_runtime_resume(dev);
606} 610}
611
612static int _od_fail_runtime_suspend(struct device *dev)
613{
614 dev_warn(dev, "%s: FIXME: missing hwmod/omap_dev info\n", __func__);
615 return -ENODEV;
616}
617
618static int _od_fail_runtime_resume(struct device *dev)
619{
620 dev_warn(dev, "%s: FIXME: missing hwmod/omap_dev info\n", __func__);
621 return -ENODEV;
622}
623
607#endif 624#endif
608 625
609#ifdef CONFIG_SUSPEND 626#ifdef CONFIG_SUSPEND
@@ -657,6 +674,13 @@ static int _od_resume_noirq(struct device *dev)
657#define _od_resume_noirq NULL 674#define _od_resume_noirq NULL
658#endif 675#endif
659 676
677struct dev_pm_domain omap_device_fail_pm_domain = {
678 .ops = {
679 SET_RUNTIME_PM_OPS(_od_fail_runtime_suspend,
680 _od_fail_runtime_resume, NULL)
681 }
682};
683
660struct dev_pm_domain omap_device_pm_domain = { 684struct dev_pm_domain omap_device_pm_domain = {
661 .ops = { 685 .ops = {
662 SET_RUNTIME_PM_OPS(_od_runtime_suspend, _od_runtime_resume, 686 SET_RUNTIME_PM_OPS(_od_runtime_suspend, _od_runtime_resume,
diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
index 17ca1aec2710..78c02b355179 100644
--- a/arch/arm/mach-omap2/omap_device.h
+++ b/arch/arm/mach-omap2/omap_device.h
@@ -29,6 +29,7 @@
29#include "omap_hwmod.h" 29#include "omap_hwmod.h"
30 30
31extern struct dev_pm_domain omap_device_pm_domain; 31extern struct dev_pm_domain omap_device_pm_domain;
32extern struct dev_pm_domain omap_device_fail_pm_domain;
32 33
33/* omap_device._state values */ 34/* omap_device._state values */
34#define OMAP_DEVICE_STATE_UNKNOWN 0 35#define OMAP_DEVICE_STATE_UNKNOWN 0
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index e3f0ecaf87dd..8a1b5e0bad40 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -399,7 +399,7 @@ static int _set_clockactivity(struct omap_hwmod *oh, u8 clockact, u32 *v)
399} 399}
400 400
401/** 401/**
402 * _set_softreset: set OCP_SYSCONFIG.CLOCKACTIVITY bits in @v 402 * _set_softreset: set OCP_SYSCONFIG.SOFTRESET bit in @v
403 * @oh: struct omap_hwmod * 403 * @oh: struct omap_hwmod *
404 * @v: pointer to register contents to modify 404 * @v: pointer to register contents to modify
405 * 405 *
@@ -427,6 +427,36 @@ static int _set_softreset(struct omap_hwmod *oh, u32 *v)
427} 427}
428 428
429/** 429/**
430 * _clear_softreset: clear OCP_SYSCONFIG.SOFTRESET bit in @v
431 * @oh: struct omap_hwmod *
432 * @v: pointer to register contents to modify
433 *
434 * Clear the SOFTRESET bit in @v for hwmod @oh. Returns -EINVAL upon
435 * error or 0 upon success.
436 */
437static int _clear_softreset(struct omap_hwmod *oh, u32 *v)
438{
439 u32 softrst_mask;
440
441 if (!oh->class->sysc ||
442 !(oh->class->sysc->sysc_flags & SYSC_HAS_SOFTRESET))
443 return -EINVAL;
444
445 if (!oh->class->sysc->sysc_fields) {
446 WARN(1,
447 "omap_hwmod: %s: sysc_fields absent for sysconfig class\n",
448 oh->name);
449 return -EINVAL;
450 }
451
452 softrst_mask = (0x1 << oh->class->sysc->sysc_fields->srst_shift);
453
454 *v &= ~softrst_mask;
455
456 return 0;
457}
458
459/**
430 * _wait_softreset_complete - wait for an OCP softreset to complete 460 * _wait_softreset_complete - wait for an OCP softreset to complete
431 * @oh: struct omap_hwmod * to wait on 461 * @oh: struct omap_hwmod * to wait on
432 * 462 *
@@ -785,6 +815,7 @@ static int _init_interface_clks(struct omap_hwmod *oh)
785 pr_warning("omap_hwmod: %s: cannot clk_get interface_clk %s\n", 815 pr_warning("omap_hwmod: %s: cannot clk_get interface_clk %s\n",
786 oh->name, os->clk); 816 oh->name, os->clk);
787 ret = -EINVAL; 817 ret = -EINVAL;
818 continue;
788 } 819 }
789 os->_clk = c; 820 os->_clk = c;
790 /* 821 /*
@@ -821,6 +852,7 @@ static int _init_opt_clks(struct omap_hwmod *oh)
821 pr_warning("omap_hwmod: %s: cannot clk_get opt_clk %s\n", 852 pr_warning("omap_hwmod: %s: cannot clk_get opt_clk %s\n",
822 oh->name, oc->clk); 853 oh->name, oc->clk);
823 ret = -EINVAL; 854 ret = -EINVAL;
855 continue;
824 } 856 }
825 oc->_clk = c; 857 oc->_clk = c;
826 /* 858 /*
@@ -1911,6 +1943,12 @@ static int _ocp_softreset(struct omap_hwmod *oh)
1911 ret = _set_softreset(oh, &v); 1943 ret = _set_softreset(oh, &v);
1912 if (ret) 1944 if (ret)
1913 goto dis_opt_clks; 1945 goto dis_opt_clks;
1946
1947 _write_sysconfig(v, oh);
1948 ret = _clear_softreset(oh, &v);
1949 if (ret)
1950 goto dis_opt_clks;
1951
1914 _write_sysconfig(v, oh); 1952 _write_sysconfig(v, oh);
1915 1953
1916 if (oh->class->sysc->srst_udelay) 1954 if (oh->class->sysc->srst_udelay)
@@ -2326,38 +2364,80 @@ static int _shutdown(struct omap_hwmod *oh)
2326 return 0; 2364 return 0;
2327} 2365}
2328 2366
2367static int of_dev_find_hwmod(struct device_node *np,
2368 struct omap_hwmod *oh)
2369{
2370 int count, i, res;
2371 const char *p;
2372
2373 count = of_property_count_strings(np, "ti,hwmods");
2374 if (count < 1)
2375 return -ENODEV;
2376
2377 for (i = 0; i < count; i++) {
2378 res = of_property_read_string_index(np, "ti,hwmods",
2379 i, &p);
2380 if (res)
2381 continue;
2382 if (!strcmp(p, oh->name)) {
2383 pr_debug("omap_hwmod: dt %s[%i] uses hwmod %s\n",
2384 np->name, i, oh->name);
2385 return i;
2386 }
2387 }
2388
2389 return -ENODEV;
2390}
2391
2329/** 2392/**
2330 * of_dev_hwmod_lookup - look up needed hwmod from dt blob 2393 * of_dev_hwmod_lookup - look up needed hwmod from dt blob
2331 * @np: struct device_node * 2394 * @np: struct device_node *
2332 * @oh: struct omap_hwmod * 2395 * @oh: struct omap_hwmod *
2396 * @index: index of the entry found
2397 * @found: struct device_node * found or NULL
2333 * 2398 *
2334 * Parse the dt blob and find out needed hwmod. Recursive function is 2399 * Parse the dt blob and find out needed hwmod. Recursive function is
2335 * implemented to take care hierarchical dt blob parsing. 2400 * implemented to take care hierarchical dt blob parsing.
2336 * Return: The device node on success or NULL on failure. 2401 * Return: Returns 0 on success, -ENODEV when not found.
2337 */ 2402 */
2338static struct device_node *of_dev_hwmod_lookup(struct device_node *np, 2403static int of_dev_hwmod_lookup(struct device_node *np,
2339 struct omap_hwmod *oh) 2404 struct omap_hwmod *oh,
2405 int *index,
2406 struct device_node **found)
2340{ 2407{
2341 struct device_node *np0 = NULL, *np1 = NULL; 2408 struct device_node *np0 = NULL;
2342 const char *p; 2409 int res;
2410
2411 res = of_dev_find_hwmod(np, oh);
2412 if (res >= 0) {
2413 *found = np;
2414 *index = res;
2415 return 0;
2416 }
2343 2417
2344 for_each_child_of_node(np, np0) { 2418 for_each_child_of_node(np, np0) {
2345 if (of_find_property(np0, "ti,hwmods", NULL)) { 2419 struct device_node *fc;
2346 p = of_get_property(np0, "ti,hwmods", NULL); 2420 int i;
2347 if (!strcmp(p, oh->name)) 2421
2348 return np0; 2422 res = of_dev_hwmod_lookup(np0, oh, &i, &fc);
2349 np1 = of_dev_hwmod_lookup(np0, oh); 2423 if (res == 0) {
2350 if (np1) 2424 *found = fc;
2351 return np1; 2425 *index = i;
2426 return 0;
2352 } 2427 }
2353 } 2428 }
2354 return NULL; 2429
2430 *found = NULL;
2431 *index = 0;
2432
2433 return -ENODEV;
2355} 2434}
2356 2435
2357/** 2436/**
2358 * _init_mpu_rt_base - populate the virtual address for a hwmod 2437 * _init_mpu_rt_base - populate the virtual address for a hwmod
2359 * @oh: struct omap_hwmod * to locate the virtual address 2438 * @oh: struct omap_hwmod * to locate the virtual address
2360 * @data: (unused, caller should pass NULL) 2439 * @data: (unused, caller should pass NULL)
2440 * @index: index of the reg entry iospace in device tree
2361 * @np: struct device_node * of the IP block's device node in the DT data 2441 * @np: struct device_node * of the IP block's device node in the DT data
2362 * 2442 *
2363 * Cache the virtual address used by the MPU to access this IP block's 2443 * Cache the virtual address used by the MPU to access this IP block's
@@ -2368,7 +2448,7 @@ static struct device_node *of_dev_hwmod_lookup(struct device_node *np,
2368 * -ENXIO on absent or invalid register target address space. 2448 * -ENXIO on absent or invalid register target address space.
2369 */ 2449 */
2370static int __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data, 2450static int __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data,
2371 struct device_node *np) 2451 int index, struct device_node *np)
2372{ 2452{
2373 struct omap_hwmod_addr_space *mem; 2453 struct omap_hwmod_addr_space *mem;
2374 void __iomem *va_start = NULL; 2454 void __iomem *va_start = NULL;
@@ -2390,13 +2470,17 @@ static int __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data,
2390 if (!np) 2470 if (!np)
2391 return -ENXIO; 2471 return -ENXIO;
2392 2472
2393 va_start = of_iomap(np, oh->mpu_rt_idx); 2473 va_start = of_iomap(np, index + oh->mpu_rt_idx);
2394 } else { 2474 } else {
2395 va_start = ioremap(mem->pa_start, mem->pa_end - mem->pa_start); 2475 va_start = ioremap(mem->pa_start, mem->pa_end - mem->pa_start);
2396 } 2476 }
2397 2477
2398 if (!va_start) { 2478 if (!va_start) {
2399 pr_err("omap_hwmod: %s: Could not ioremap\n", oh->name); 2479 if (mem)
2480 pr_err("omap_hwmod: %s: Could not ioremap\n", oh->name);
2481 else
2482 pr_err("omap_hwmod: %s: Missing dt reg%i for %s\n",
2483 oh->name, index, np->full_name);
2400 return -ENXIO; 2484 return -ENXIO;
2401 } 2485 }
2402 2486
@@ -2422,17 +2506,29 @@ static int __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data,
2422 */ 2506 */
2423static int __init _init(struct omap_hwmod *oh, void *data) 2507static int __init _init(struct omap_hwmod *oh, void *data)
2424{ 2508{
2425 int r; 2509 int r, index;
2426 struct device_node *np = NULL; 2510 struct device_node *np = NULL;
2427 2511
2428 if (oh->_state != _HWMOD_STATE_REGISTERED) 2512 if (oh->_state != _HWMOD_STATE_REGISTERED)
2429 return 0; 2513 return 0;
2430 2514
2431 if (of_have_populated_dt()) 2515 if (of_have_populated_dt()) {
2432 np = of_dev_hwmod_lookup(of_find_node_by_name(NULL, "ocp"), oh); 2516 struct device_node *bus;
2517
2518 bus = of_find_node_by_name(NULL, "ocp");
2519 if (!bus)
2520 return -ENODEV;
2521
2522 r = of_dev_hwmod_lookup(bus, oh, &index, &np);
2523 if (r)
2524 pr_debug("omap_hwmod: %s missing dt data\n", oh->name);
2525 else if (np && index)
2526 pr_warn("omap_hwmod: %s using broken dt data from %s\n",
2527 oh->name, np->name);
2528 }
2433 2529
2434 if (oh->class->sysc) { 2530 if (oh->class->sysc) {
2435 r = _init_mpu_rt_base(oh, NULL, np); 2531 r = _init_mpu_rt_base(oh, NULL, index, np);
2436 if (r < 0) { 2532 if (r < 0) {
2437 WARN(1, "omap_hwmod: %s: doesn't have mpu register target base\n", 2533 WARN(1, "omap_hwmod: %s: doesn't have mpu register target base\n",
2438 oh->name); 2534 oh->name);
@@ -3169,6 +3265,11 @@ int omap_hwmod_softreset(struct omap_hwmod *oh)
3169 goto error; 3265 goto error;
3170 _write_sysconfig(v, oh); 3266 _write_sysconfig(v, oh);
3171 3267
3268 ret = _clear_softreset(oh, &v);
3269 if (ret)
3270 goto error;
3271 _write_sysconfig(v, oh);
3272
3172error: 3273error:
3173 return ret; 3274 return ret;
3174} 3275}
diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
index 9e56fabd7fa3..d33742908f97 100644
--- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
@@ -1943,7 +1943,8 @@ static struct omap_hwmod_class_sysconfig omap3xxx_usb_host_hs_sysc = {
1943 .syss_offs = 0x0014, 1943 .syss_offs = 0x0014,
1944 .sysc_flags = (SYSC_HAS_MIDLEMODE | SYSC_HAS_CLOCKACTIVITY | 1944 .sysc_flags = (SYSC_HAS_MIDLEMODE | SYSC_HAS_CLOCKACTIVITY |
1945 SYSC_HAS_SIDLEMODE | SYSC_HAS_ENAWAKEUP | 1945 SYSC_HAS_SIDLEMODE | SYSC_HAS_ENAWAKEUP |
1946 SYSC_HAS_SOFTRESET | SYSC_HAS_AUTOIDLE), 1946 SYSC_HAS_SOFTRESET | SYSC_HAS_AUTOIDLE |
1947 SYSS_HAS_RESET_STATUS),
1947 .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART | 1948 .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
1948 MSTANDBY_FORCE | MSTANDBY_NO | MSTANDBY_SMART), 1949 MSTANDBY_FORCE | MSTANDBY_NO | MSTANDBY_SMART),
1949 .sysc_fields = &omap_hwmod_sysc_type1, 1950 .sysc_fields = &omap_hwmod_sysc_type1,
@@ -2021,15 +2022,7 @@ static struct omap_hwmod omap3xxx_usb_host_hs_hwmod = {
2021 * hence HWMOD_SWSUP_MSTANDBY 2022 * hence HWMOD_SWSUP_MSTANDBY
2022 */ 2023 */
2023 2024
2024 /* 2025 .flags = HWMOD_SWSUP_SIDLE | HWMOD_SWSUP_MSTANDBY,
2025 * During system boot; If the hwmod framework resets the module
2026 * the module will have smart idle settings; which can lead to deadlock
2027 * (above Errata Id:i660); so, dont reset the module during boot;
2028 * Use HWMOD_INIT_NO_RESET.
2029 */
2030
2031 .flags = HWMOD_SWSUP_SIDLE | HWMOD_SWSUP_MSTANDBY |
2032 HWMOD_INIT_NO_RESET,
2033}; 2026};
2034 2027
2035/* 2028/*
diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
index 1e5b12cb8246..3318cae96e7d 100644
--- a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
@@ -2937,7 +2937,7 @@ static struct omap_hwmod_class_sysconfig omap44xx_usb_host_hs_sysc = {
2937 .sysc_offs = 0x0010, 2937 .sysc_offs = 0x0010,
2938 .syss_offs = 0x0014, 2938 .syss_offs = 0x0014,
2939 .sysc_flags = (SYSC_HAS_MIDLEMODE | SYSC_HAS_SIDLEMODE | 2939 .sysc_flags = (SYSC_HAS_MIDLEMODE | SYSC_HAS_SIDLEMODE |
2940 SYSC_HAS_SOFTRESET), 2940 SYSC_HAS_SOFTRESET | SYSC_HAS_RESET_STATUS),
2941 .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART | 2941 .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
2942 SIDLE_SMART_WKUP | MSTANDBY_FORCE | MSTANDBY_NO | 2942 SIDLE_SMART_WKUP | MSTANDBY_FORCE | MSTANDBY_NO |
2943 MSTANDBY_SMART | MSTANDBY_SMART_WKUP), 2943 MSTANDBY_SMART | MSTANDBY_SMART_WKUP),
@@ -3001,15 +3001,7 @@ static struct omap_hwmod omap44xx_usb_host_hs_hwmod = {
3001 * hence HWMOD_SWSUP_MSTANDBY 3001 * hence HWMOD_SWSUP_MSTANDBY
3002 */ 3002 */
3003 3003
3004 /* 3004 .flags = HWMOD_SWSUP_SIDLE | HWMOD_SWSUP_MSTANDBY,
3005 * During system boot; If the hwmod framework resets the module
3006 * the module will have smart idle settings; which can lead to deadlock
3007 * (above Errata Id:i660); so, dont reset the module during boot;
3008 * Use HWMOD_INIT_NO_RESET.
3009 */
3010
3011 .flags = HWMOD_SWSUP_SIDLE | HWMOD_SWSUP_MSTANDBY |
3012 HWMOD_INIT_NO_RESET,
3013}; 3005};
3014 3006
3015/* 3007/*
diff --git a/arch/arm/mach-omap2/omap_hwmod_54xx_data.c b/arch/arm/mach-omap2/omap_hwmod_54xx_data.c
index 9e08d6994a0b..e297d6231c3a 100644
--- a/arch/arm/mach-omap2/omap_hwmod_54xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_54xx_data.c
@@ -1544,7 +1544,8 @@ static struct omap_hwmod_class_sysconfig omap54xx_usb_host_hs_sysc = {
1544 .rev_offs = 0x0000, 1544 .rev_offs = 0x0000,
1545 .sysc_offs = 0x0010, 1545 .sysc_offs = 0x0010,
1546 .sysc_flags = (SYSC_HAS_MIDLEMODE | SYSC_HAS_RESET_STATUS | 1546 .sysc_flags = (SYSC_HAS_MIDLEMODE | SYSC_HAS_RESET_STATUS |
1547 SYSC_HAS_SIDLEMODE | SYSC_HAS_SOFTRESET), 1547 SYSC_HAS_SIDLEMODE | SYSC_HAS_SOFTRESET |
1548 SYSC_HAS_RESET_STATUS),
1548 .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART | 1549 .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
1549 SIDLE_SMART_WKUP | MSTANDBY_FORCE | MSTANDBY_NO | 1550 SIDLE_SMART_WKUP | MSTANDBY_FORCE | MSTANDBY_NO |
1550 MSTANDBY_SMART | MSTANDBY_SMART_WKUP), 1551 MSTANDBY_SMART | MSTANDBY_SMART_WKUP),
@@ -1598,15 +1599,7 @@ static struct omap_hwmod omap54xx_usb_host_hs_hwmod = {
1598 * hence HWMOD_SWSUP_MSTANDBY 1599 * hence HWMOD_SWSUP_MSTANDBY
1599 */ 1600 */
1600 1601
1601 /* 1602 .flags = HWMOD_SWSUP_SIDLE | HWMOD_SWSUP_MSTANDBY,
1602 * During system boot; If the hwmod framework resets the module
1603 * the module will have smart idle settings; which can lead to deadlock
1604 * (above Errata Id:i660); so, dont reset the module during boot;
1605 * Use HWMOD_INIT_NO_RESET.
1606 */
1607
1608 .flags = HWMOD_SWSUP_SIDLE | HWMOD_SWSUP_MSTANDBY |
1609 HWMOD_INIT_NO_RESET,
1610 .main_clk = "l3init_60m_fclk", 1603 .main_clk = "l3init_60m_fclk",
1611 .prcm = { 1604 .prcm = {
1612 .omap4 = { 1605 .omap4 = {
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index 3ca81e0ada5e..ec084d158f64 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -379,7 +379,7 @@ static struct clocksource clocksource_gpt = {
379 .flags = CLOCK_SOURCE_IS_CONTINUOUS, 379 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
380}; 380};
381 381
382static u32 notrace dmtimer_read_sched_clock(void) 382static u64 notrace dmtimer_read_sched_clock(void)
383{ 383{
384 if (clksrc.reserved) 384 if (clksrc.reserved)
385 return __omap_dm_timer_read_counter(&clksrc, 385 return __omap_dm_timer_read_counter(&clksrc,
@@ -471,7 +471,7 @@ static void __init omap2_gptimer_clocksource_init(int gptimer_id,
471 __omap_dm_timer_load_start(&clksrc, 471 __omap_dm_timer_load_start(&clksrc,
472 OMAP_TIMER_CTRL_ST | OMAP_TIMER_CTRL_AR, 0, 472 OMAP_TIMER_CTRL_ST | OMAP_TIMER_CTRL_AR, 0,
473 OMAP_TIMER_NONPOSTED); 473 OMAP_TIMER_NONPOSTED);
474 setup_sched_clock(dmtimer_read_sched_clock, 32, clksrc.rate); 474 sched_clock_register(dmtimer_read_sched_clock, 32, clksrc.rate);
475 475
476 if (clocksource_register_hz(&clocksource_gpt, clksrc.rate)) 476 if (clocksource_register_hz(&clocksource_gpt, clksrc.rate))
477 pr_err("Could not register clocksource %s\n", 477 pr_err("Could not register clocksource %s\n",
diff --git a/arch/arm/mach-pxa/reset.c b/arch/arm/mach-pxa/reset.c
index 0d5dd646f61f..263b15249b5b 100644
--- a/arch/arm/mach-pxa/reset.c
+++ b/arch/arm/mach-pxa/reset.c
@@ -13,6 +13,7 @@
13 13
14#include <mach/regs-ost.h> 14#include <mach/regs-ost.h>
15#include <mach/reset.h> 15#include <mach/reset.h>
16#include <mach/smemc.h>
16 17
17unsigned int reset_status; 18unsigned int reset_status;
18EXPORT_SYMBOL(reset_status); 19EXPORT_SYMBOL(reset_status);
@@ -81,6 +82,12 @@ static void do_hw_reset(void)
81 writel_relaxed(OSSR_M3, OSSR); 82 writel_relaxed(OSSR_M3, OSSR);
82 /* ... in 100 ms */ 83 /* ... in 100 ms */
83 writel_relaxed(readl_relaxed(OSCR) + 368640, OSMR3); 84 writel_relaxed(readl_relaxed(OSCR) + 368640, OSMR3);
85 /*
86 * SDRAM hangs on watchdog reset on Marvell PXA270 (erratum 71)
87 * we put SDRAM into self-refresh to prevent that
88 */
89 while (1)
90 writel_relaxed(MDREFR_SLFRSH, MDREFR);
84} 91}
85 92
86void pxa_restart(enum reboot_mode mode, const char *cmd) 93void pxa_restart(enum reboot_mode mode, const char *cmd)
@@ -104,4 +111,3 @@ void pxa_restart(enum reboot_mode mode, const char *cmd)
104 break; 111 break;
105 } 112 }
106} 113}
107
diff --git a/arch/arm/mach-pxa/time.c b/arch/arm/mach-pxa/time.c
index 9aa852a8fab9..d1bfaa73b1c9 100644
--- a/arch/arm/mach-pxa/time.c
+++ b/arch/arm/mach-pxa/time.c
@@ -33,7 +33,7 @@
33 * calls to sched_clock() which should always be the case in practice. 33 * calls to sched_clock() which should always be the case in practice.
34 */ 34 */
35 35
36static u32 notrace pxa_read_sched_clock(void) 36static u64 notrace pxa_read_sched_clock(void)
37{ 37{
38 return readl_relaxed(OSCR); 38 return readl_relaxed(OSCR);
39} 39}
@@ -149,7 +149,7 @@ void __init pxa_timer_init(void)
149 writel_relaxed(0, OIER); 149 writel_relaxed(0, OIER);
150 writel_relaxed(OSSR_M0 | OSSR_M1 | OSSR_M2 | OSSR_M3, OSSR); 150 writel_relaxed(OSSR_M0 | OSSR_M1 | OSSR_M2 | OSSR_M3, OSSR);
151 151
152 setup_sched_clock(pxa_read_sched_clock, 32, clock_tick_rate); 152 sched_clock_register(pxa_read_sched_clock, 32, clock_tick_rate);
153 153
154 ckevt_pxa_osmr0.cpumask = cpumask_of(0); 154 ckevt_pxa_osmr0.cpumask = cpumask_of(0);
155 155
diff --git a/arch/arm/mach-pxa/tosa.c b/arch/arm/mach-pxa/tosa.c
index 0206b915a6f6..ef5557b807ed 100644
--- a/arch/arm/mach-pxa/tosa.c
+++ b/arch/arm/mach-pxa/tosa.c
@@ -425,57 +425,57 @@ static struct platform_device tosa_power_device = {
425 * Tosa Keyboard 425 * Tosa Keyboard
426 */ 426 */
427static const uint32_t tosakbd_keymap[] = { 427static const uint32_t tosakbd_keymap[] = {
428 KEY(0, 2, KEY_W), 428 KEY(0, 1, KEY_W),
429 KEY(0, 6, KEY_K), 429 KEY(0, 5, KEY_K),
430 KEY(0, 7, KEY_BACKSPACE), 430 KEY(0, 6, KEY_BACKSPACE),
431 KEY(0, 8, KEY_P), 431 KEY(0, 7, KEY_P),
432 KEY(1, 1, KEY_Q), 432 KEY(1, 0, KEY_Q),
433 KEY(1, 2, KEY_E), 433 KEY(1, 1, KEY_E),
434 KEY(1, 3, KEY_T), 434 KEY(1, 2, KEY_T),
435 KEY(1, 4, KEY_Y), 435 KEY(1, 3, KEY_Y),
436 KEY(1, 6, KEY_O), 436 KEY(1, 5, KEY_O),
437 KEY(1, 7, KEY_I), 437 KEY(1, 6, KEY_I),
438 KEY(1, 8, KEY_COMMA), 438 KEY(1, 7, KEY_COMMA),
439 KEY(2, 1, KEY_A), 439 KEY(2, 0, KEY_A),
440 KEY(2, 2, KEY_D), 440 KEY(2, 1, KEY_D),
441 KEY(2, 3, KEY_G), 441 KEY(2, 2, KEY_G),
442 KEY(2, 4, KEY_U), 442 KEY(2, 3, KEY_U),
443 KEY(2, 6, KEY_L), 443 KEY(2, 5, KEY_L),
444 KEY(2, 7, KEY_ENTER), 444 KEY(2, 6, KEY_ENTER),
445 KEY(2, 8, KEY_DOT), 445 KEY(2, 7, KEY_DOT),
446 KEY(3, 1, KEY_Z), 446 KEY(3, 0, KEY_Z),
447 KEY(3, 2, KEY_C), 447 KEY(3, 1, KEY_C),
448 KEY(3, 3, KEY_V), 448 KEY(3, 2, KEY_V),
449 KEY(3, 4, KEY_J), 449 KEY(3, 3, KEY_J),
450 KEY(3, 5, TOSA_KEY_ADDRESSBOOK), 450 KEY(3, 4, TOSA_KEY_ADDRESSBOOK),
451 KEY(3, 6, TOSA_KEY_CANCEL), 451 KEY(3, 5, TOSA_KEY_CANCEL),
452 KEY(3, 7, TOSA_KEY_CENTER), 452 KEY(3, 6, TOSA_KEY_CENTER),
453 KEY(3, 8, TOSA_KEY_OK), 453 KEY(3, 7, TOSA_KEY_OK),
454 KEY(3, 9, KEY_LEFTSHIFT), 454 KEY(3, 8, KEY_LEFTSHIFT),
455 KEY(4, 1, KEY_S), 455 KEY(4, 0, KEY_S),
456 KEY(4, 2, KEY_R), 456 KEY(4, 1, KEY_R),
457 KEY(4, 3, KEY_B), 457 KEY(4, 2, KEY_B),
458 KEY(4, 4, KEY_N), 458 KEY(4, 3, KEY_N),
459 KEY(4, 5, TOSA_KEY_CALENDAR), 459 KEY(4, 4, TOSA_KEY_CALENDAR),
460 KEY(4, 6, TOSA_KEY_HOMEPAGE), 460 KEY(4, 5, TOSA_KEY_HOMEPAGE),
461 KEY(4, 7, KEY_LEFTCTRL), 461 KEY(4, 6, KEY_LEFTCTRL),
462 KEY(4, 8, TOSA_KEY_LIGHT), 462 KEY(4, 7, TOSA_KEY_LIGHT),
463 KEY(4, 10, KEY_RIGHTSHIFT), 463 KEY(4, 9, KEY_RIGHTSHIFT),
464 KEY(5, 1, KEY_TAB), 464 KEY(5, 0, KEY_TAB),
465 KEY(5, 2, KEY_SLASH), 465 KEY(5, 1, KEY_SLASH),
466 KEY(5, 3, KEY_H), 466 KEY(5, 2, KEY_H),
467 KEY(5, 4, KEY_M), 467 KEY(5, 3, KEY_M),
468 KEY(5, 5, TOSA_KEY_MENU), 468 KEY(5, 4, TOSA_KEY_MENU),
469 KEY(5, 7, KEY_UP), 469 KEY(5, 6, KEY_UP),
470 KEY(5, 11, TOSA_KEY_FN), 470 KEY(5, 10, TOSA_KEY_FN),
471 KEY(6, 1, KEY_X), 471 KEY(6, 0, KEY_X),
472 KEY(6, 2, KEY_F), 472 KEY(6, 1, KEY_F),
473 KEY(6, 3, KEY_SPACE), 473 KEY(6, 2, KEY_SPACE),
474 KEY(6, 4, KEY_APOSTROPHE), 474 KEY(6, 3, KEY_APOSTROPHE),
475 KEY(6, 5, TOSA_KEY_MAIL), 475 KEY(6, 4, TOSA_KEY_MAIL),
476 KEY(6, 6, KEY_LEFT), 476 KEY(6, 5, KEY_LEFT),
477 KEY(6, 7, KEY_DOWN), 477 KEY(6, 6, KEY_DOWN),
478 KEY(6, 8, KEY_RIGHT), 478 KEY(6, 7, KEY_RIGHT),
479}; 479};
480 480
481static struct matrix_keymap_data tosakbd_keymap_data = { 481static struct matrix_keymap_data tosakbd_keymap_data = {
diff --git a/arch/arm/mach-sa1100/time.c b/arch/arm/mach-sa1100/time.c
index 713c86cd3d64..6fd4acb8f187 100644
--- a/arch/arm/mach-sa1100/time.c
+++ b/arch/arm/mach-sa1100/time.c
@@ -20,7 +20,7 @@
20#include <mach/hardware.h> 20#include <mach/hardware.h>
21#include <mach/irqs.h> 21#include <mach/irqs.h>
22 22
23static u32 notrace sa1100_read_sched_clock(void) 23static u64 notrace sa1100_read_sched_clock(void)
24{ 24{
25 return readl_relaxed(OSCR); 25 return readl_relaxed(OSCR);
26} 26}
@@ -122,7 +122,7 @@ void __init sa1100_timer_init(void)
122 writel_relaxed(0, OIER); 122 writel_relaxed(0, OIER);
123 writel_relaxed(OSSR_M0 | OSSR_M1 | OSSR_M2 | OSSR_M3, OSSR); 123 writel_relaxed(OSSR_M0 | OSSR_M1 | OSSR_M2 | OSSR_M3, OSSR);
124 124
125 setup_sched_clock(sa1100_read_sched_clock, 32, 3686400); 125 sched_clock_register(sa1100_read_sched_clock, 32, 3686400);
126 126
127 ckevt_sa1100_osmr0.cpumask = cpumask_of(0); 127 ckevt_sa1100_osmr0.cpumask = cpumask_of(0);
128 128
diff --git a/arch/arm/mach-shmobile/Kconfig b/arch/arm/mach-shmobile/Kconfig
index a4a4b75109b2..8c8889211f6d 100644
--- a/arch/arm/mach-shmobile/Kconfig
+++ b/arch/arm/mach-shmobile/Kconfig
@@ -1,6 +1,10 @@
1config ARCH_SHMOBILE
2 bool
3
1config ARCH_SHMOBILE_MULTI 4config ARCH_SHMOBILE_MULTI
2 bool "SH-Mobile Series" if ARCH_MULTI_V7 5 bool "SH-Mobile Series" if ARCH_MULTI_V7
3 depends on MMU 6 depends on MMU
7 select ARCH_SHMOBILE
4 select CPU_V7 8 select CPU_V7
5 select GENERIC_CLOCKEVENTS 9 select GENERIC_CLOCKEVENTS
6 select HAVE_ARM_SCU if SMP 10 select HAVE_ARM_SCU if SMP
@@ -8,6 +12,7 @@ config ARCH_SHMOBILE_MULTI
8 select HAVE_SMP 12 select HAVE_SMP
9 select ARM_GIC 13 select ARM_GIC
10 select MIGHT_HAVE_CACHE_L2X0 14 select MIGHT_HAVE_CACHE_L2X0
15 select MIGHT_HAVE_PCI
11 select NO_IOPORT 16 select NO_IOPORT
12 select PINCTRL 17 select PINCTRL
13 select ARCH_REQUIRE_GPIOLIB 18 select ARCH_REQUIRE_GPIOLIB
@@ -30,7 +35,7 @@ config MACH_KZM9D
30comment "SH-Mobile System Configuration" 35comment "SH-Mobile System Configuration"
31endif 36endif
32 37
33if ARCH_SHMOBILE 38if ARCH_SHMOBILE_LEGACY
34 39
35comment "SH-Mobile System Type" 40comment "SH-Mobile System Type"
36 41
@@ -92,23 +97,31 @@ config ARCH_R8A7790
92 select ARCH_WANT_OPTIONAL_GPIOLIB 97 select ARCH_WANT_OPTIONAL_GPIOLIB
93 select ARM_GIC 98 select ARM_GIC
94 select CPU_V7 99 select CPU_V7
100 select MIGHT_HAVE_PCI
95 select SH_CLK_CPG 101 select SH_CLK_CPG
96 select RENESAS_IRQC 102 select RENESAS_IRQC
97 103
98config ARCH_R8A7791 104config ARCH_R8A7791
99 bool "R-Car M2 (R8A77910)" 105 bool "R-Car M2 (R8A77910)"
106 select ARCH_WANT_OPTIONAL_GPIOLIB
100 select ARM_GIC 107 select ARM_GIC
101 select CPU_V7 108 select CPU_V7
109 select MIGHT_HAVE_PCI
102 select SH_CLK_CPG 110 select SH_CLK_CPG
111 select RENESAS_IRQC
103 112
104config ARCH_EMEV2 113config ARCH_EMEV2
105 bool "Emma Mobile EV2" 114 bool "Emma Mobile EV2"
106 select ARCH_WANT_OPTIONAL_GPIOLIB 115 select ARCH_WANT_OPTIONAL_GPIOLIB
107 select ARM_GIC 116 select ARM_GIC
108 select CPU_V7 117 select CPU_V7
118 select MIGHT_HAVE_PCI
119 select USE_OF
120 select AUTO_ZRELADDR
109 121
110config ARCH_R7S72100 122config ARCH_R7S72100
111 bool "RZ/A1H (R7S72100)" 123 bool "RZ/A1H (R7S72100)"
124 select ARCH_WANT_OPTIONAL_GPIOLIB
112 select ARM_GIC 125 select ARM_GIC
113 select CPU_V7 126 select CPU_V7
114 select SH_CLK_CPG 127 select SH_CLK_CPG
@@ -230,12 +243,7 @@ config MACH_KOELSCH
230 bool "Koelsch board" 243 bool "Koelsch board"
231 depends on ARCH_R8A7791 244 depends on ARCH_R8A7791
232 select USE_OF 245 select USE_OF
233 246 select MICREL_PHY if SH_ETH
234config MACH_KZM9D
235 bool "KZM9D board"
236 depends on ARCH_EMEV2
237 select REGULATOR_FIXED_VOLTAGE if REGULATOR
238 select USE_OF
239 247
240config MACH_KZM9G 248config MACH_KZM9G
241 bool "KZM-A9-GT board" 249 bool "KZM-A9-GT board"
@@ -274,7 +282,7 @@ source "drivers/sh/Kconfig"
274 282
275endif 283endif
276 284
277if ARCH_SHMOBILE || ARCH_SHMOBILE_MULTI 285if ARCH_SHMOBILE
278 286
279menu "Timer and clock configuration" 287menu "Timer and clock configuration"
280 288
diff --git a/arch/arm/mach-shmobile/Makefile b/arch/arm/mach-shmobile/Makefile
index 51db2bcafabf..c7e877499dc2 100644
--- a/arch/arm/mach-shmobile/Makefile
+++ b/arch/arm/mach-shmobile/Makefile
@@ -71,7 +71,6 @@ obj-$(CONFIG_MACH_LAGER_REFERENCE) += board-lager-reference.o
71obj-$(CONFIG_MACH_ARMADILLO800EVA) += board-armadillo800eva.o 71obj-$(CONFIG_MACH_ARMADILLO800EVA) += board-armadillo800eva.o
72obj-$(CONFIG_MACH_ARMADILLO800EVA_REFERENCE) += board-armadillo800eva-reference.o 72obj-$(CONFIG_MACH_ARMADILLO800EVA_REFERENCE) += board-armadillo800eva-reference.o
73obj-$(CONFIG_MACH_KOELSCH) += board-koelsch.o 73obj-$(CONFIG_MACH_KOELSCH) += board-koelsch.o
74obj-$(CONFIG_MACH_KZM9D) += board-kzm9d.o
75obj-$(CONFIG_MACH_KZM9G) += board-kzm9g.o 74obj-$(CONFIG_MACH_KZM9G) += board-kzm9g.o
76obj-$(CONFIG_MACH_KZM9G_REFERENCE) += board-kzm9g-reference.o 75obj-$(CONFIG_MACH_KZM9G_REFERENCE) += board-kzm9g-reference.o
77endif 76endif
diff --git a/arch/arm/mach-shmobile/Makefile.boot b/arch/arm/mach-shmobile/Makefile.boot
index 391d72a5536c..4f30e3dc0919 100644
--- a/arch/arm/mach-shmobile/Makefile.boot
+++ b/arch/arm/mach-shmobile/Makefile.boot
@@ -8,7 +8,6 @@ loadaddr-$(CONFIG_MACH_BOCKW) += 0x60008000
8loadaddr-$(CONFIG_MACH_BOCKW_REFERENCE) += 0x60008000 8loadaddr-$(CONFIG_MACH_BOCKW_REFERENCE) += 0x60008000
9loadaddr-$(CONFIG_MACH_GENMAI) += 0x8008000 9loadaddr-$(CONFIG_MACH_GENMAI) += 0x8008000
10loadaddr-$(CONFIG_MACH_KOELSCH) += 0x40008000 10loadaddr-$(CONFIG_MACH_KOELSCH) += 0x40008000
11loadaddr-$(CONFIG_MACH_KZM9D) += 0x40008000
12loadaddr-$(CONFIG_MACH_KZM9G) += 0x41008000 11loadaddr-$(CONFIG_MACH_KZM9G) += 0x41008000
13loadaddr-$(CONFIG_MACH_KZM9G_REFERENCE) += 0x41008000 12loadaddr-$(CONFIG_MACH_KZM9G_REFERENCE) += 0x41008000
14loadaddr-$(CONFIG_MACH_LAGER) += 0x40008000 13loadaddr-$(CONFIG_MACH_LAGER) += 0x40008000
diff --git a/arch/arm/mach-shmobile/board-bockw.c b/arch/arm/mach-shmobile/board-bockw.c
index 38611526fe9a..44b55ef8857e 100644
--- a/arch/arm/mach-shmobile/board-bockw.c
+++ b/arch/arm/mach-shmobile/board-bockw.c
@@ -25,6 +25,7 @@
25#include <linux/mmc/sh_mmcif.h> 25#include <linux/mmc/sh_mmcif.h>
26#include <linux/mtd/partitions.h> 26#include <linux/mtd/partitions.h>
27#include <linux/pinctrl/machine.h> 27#include <linux/pinctrl/machine.h>
28#include <linux/platform_data/camera-rcar.h>
28#include <linux/platform_data/usb-rcar-phy.h> 29#include <linux/platform_data/usb-rcar-phy.h>
29#include <linux/platform_device.h> 30#include <linux/platform_device.h>
30#include <linux/regulator/fixed.h> 31#include <linux/regulator/fixed.h>
diff --git a/arch/arm/mach-shmobile/board-kzm9d.c b/arch/arm/mach-shmobile/board-kzm9d.c
deleted file mode 100644
index 30c2cc695b12..000000000000
--- a/arch/arm/mach-shmobile/board-kzm9d.c
+++ /dev/null
@@ -1,92 +0,0 @@
1/*
2 * kzm9d board support
3 *
4 * Copyright (C) 2012 Renesas Solutions Corp.
5 * Copyright (C) 2012 Magnus Damm
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; version 2 of the License.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include <linux/kernel.h>
22#include <linux/interrupt.h>
23#include <linux/platform_device.h>
24#include <linux/regulator/fixed.h>
25#include <linux/regulator/machine.h>
26#include <linux/smsc911x.h>
27#include <mach/common.h>
28#include <mach/emev2.h>
29#include <asm/mach-types.h>
30#include <asm/mach/arch.h>
31
32/* Dummy supplies, where voltage doesn't matter */
33static struct regulator_consumer_supply dummy_supplies[] = {
34 REGULATOR_SUPPLY("vddvario", "smsc911x"),
35 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
36};
37
38/* Ether */
39static struct resource smsc911x_resources[] = {
40 [0] = {
41 .start = 0x20000000,
42 .end = 0x2000ffff,
43 .flags = IORESOURCE_MEM,
44 },
45 [1] = {
46 .start = EMEV2_GPIO_IRQ(1),
47 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_HIGH,
48 },
49};
50
51static struct smsc911x_platform_config smsc911x_platdata = {
52 .flags = SMSC911X_USE_32BIT,
53 .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
54 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH,
55};
56
57static struct platform_device smsc91x_device = {
58 .name = "smsc911x",
59 .id = -1,
60 .dev = {
61 .platform_data = &smsc911x_platdata,
62 },
63 .num_resources = ARRAY_SIZE(smsc911x_resources),
64 .resource = smsc911x_resources,
65};
66
67static struct platform_device *kzm9d_devices[] __initdata = {
68 &smsc91x_device,
69};
70
71void __init kzm9d_add_standard_devices(void)
72{
73 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
74
75 emev2_add_standard_devices();
76
77 platform_add_devices(kzm9d_devices, ARRAY_SIZE(kzm9d_devices));
78}
79
80static const char *kzm9d_boards_compat_dt[] __initdata = {
81 "renesas,kzm9d",
82 NULL,
83};
84
85DT_MACHINE_START(KZM9D_DT, "kzm9d")
86 .smp = smp_ops(emev2_smp_ops),
87 .map_io = emev2_map_io,
88 .init_early = emev2_init_delay,
89 .init_machine = kzm9d_add_standard_devices,
90 .init_late = shmobile_init_late,
91 .dt_compat = kzm9d_boards_compat_dt,
92MACHINE_END
diff --git a/arch/arm/mach-shmobile/clock-r7s72100.c b/arch/arm/mach-shmobile/clock-r7s72100.c
index 4aba20ca127e..850a8a371b43 100644
--- a/arch/arm/mach-shmobile/clock-r7s72100.c
+++ b/arch/arm/mach-shmobile/clock-r7s72100.c
@@ -27,6 +27,7 @@
27#define FRQCR2 0xfcfe0014 27#define FRQCR2 0xfcfe0014
28#define STBCR3 0xfcfe0420 28#define STBCR3 0xfcfe0420
29#define STBCR4 0xfcfe0424 29#define STBCR4 0xfcfe0424
30#define STBCR9 0xfcfe0438
30 31
31#define PLL_RATE 30 32#define PLL_RATE 30
32 33
@@ -144,10 +145,15 @@ struct clk div4_clks[DIV4_NR] = {
144 | CLK_ENABLE_ON_INIT), 145 | CLK_ENABLE_ON_INIT),
145}; 146};
146 147
147enum { MSTP47, MSTP46, MSTP45, MSTP44, MSTP43, MSTP42, MSTP41, MSTP40, 148enum { MSTP97, MSTP96, MSTP95, MSTP94,
149 MSTP47, MSTP46, MSTP45, MSTP44, MSTP43, MSTP42, MSTP41, MSTP40,
148 MSTP33, MSTP_NR }; 150 MSTP33, MSTP_NR };
149 151
150static struct clk mstp_clks[MSTP_NR] = { 152static struct clk mstp_clks[MSTP_NR] = {
153 [MSTP97] = SH_CLK_MSTP8(&peripheral0_clk, STBCR9, 7, 0), /* RIIC0 */
154 [MSTP96] = SH_CLK_MSTP8(&peripheral0_clk, STBCR9, 6, 0), /* RIIC1 */
155 [MSTP95] = SH_CLK_MSTP8(&peripheral0_clk, STBCR9, 5, 0), /* RIIC2 */
156 [MSTP94] = SH_CLK_MSTP8(&peripheral0_clk, STBCR9, 4, 0), /* RIIC3 */
151 [MSTP47] = SH_CLK_MSTP8(&peripheral1_clk, STBCR4, 7, 0), /* SCIF0 */ 157 [MSTP47] = SH_CLK_MSTP8(&peripheral1_clk, STBCR4, 7, 0), /* SCIF0 */
152 [MSTP46] = SH_CLK_MSTP8(&peripheral1_clk, STBCR4, 6, 0), /* SCIF1 */ 158 [MSTP46] = SH_CLK_MSTP8(&peripheral1_clk, STBCR4, 6, 0), /* SCIF1 */
153 [MSTP45] = SH_CLK_MSTP8(&peripheral1_clk, STBCR4, 5, 0), /* SCIF2 */ 159 [MSTP45] = SH_CLK_MSTP8(&peripheral1_clk, STBCR4, 5, 0), /* SCIF2 */
diff --git a/arch/arm/mach-shmobile/clock-r8a7740.c b/arch/arm/mach-shmobile/clock-r8a7740.c
index c826bca4024e..e9a3c6401845 100644
--- a/arch/arm/mach-shmobile/clock-r8a7740.c
+++ b/arch/arm/mach-shmobile/clock-r8a7740.c
@@ -585,6 +585,7 @@ static struct clk_lookup lookups[] = {
585 585
586 CLKDEV_DEV_ID("sh_cmt.10", &mstp_clks[MSTP329]), 586 CLKDEV_DEV_ID("sh_cmt.10", &mstp_clks[MSTP329]),
587 CLKDEV_DEV_ID("sh_fsi2", &mstp_clks[MSTP328]), 587 CLKDEV_DEV_ID("sh_fsi2", &mstp_clks[MSTP328]),
588 CLKDEV_DEV_ID("fe1f0000.sound", &mstp_clks[MSTP328]),
588 CLKDEV_DEV_ID("i2c-sh_mobile.1", &mstp_clks[MSTP323]), 589 CLKDEV_DEV_ID("i2c-sh_mobile.1", &mstp_clks[MSTP323]),
589 CLKDEV_DEV_ID("e6c20000.i2c", &mstp_clks[MSTP323]), 590 CLKDEV_DEV_ID("e6c20000.i2c", &mstp_clks[MSTP323]),
590 CLKDEV_DEV_ID("renesas_usbhs", &mstp_clks[MSTP320]), 591 CLKDEV_DEV_ID("renesas_usbhs", &mstp_clks[MSTP320]),
diff --git a/arch/arm/mach-shmobile/clock-r8a7778.c b/arch/arm/mach-shmobile/clock-r8a7778.c
index fb6af83858e3..dfb0fff4d24c 100644
--- a/arch/arm/mach-shmobile/clock-r8a7778.c
+++ b/arch/arm/mach-shmobile/clock-r8a7778.c
@@ -115,6 +115,8 @@ static struct clk *main_clks[] = {
115}; 115};
116 116
117enum { 117enum {
118 MSTP531, MSTP530,
119 MSTP529, MSTP528, MSTP527, MSTP526, MSTP525, MSTP524, MSTP523,
118 MSTP331, 120 MSTP331,
119 MSTP323, MSTP322, MSTP321, 121 MSTP323, MSTP322, MSTP321,
120 MSTP311, MSTP310, 122 MSTP311, MSTP310,
@@ -129,6 +131,15 @@ enum {
129 MSTP_NR }; 131 MSTP_NR };
130 132
131static struct clk mstp_clks[MSTP_NR] = { 133static struct clk mstp_clks[MSTP_NR] = {
134 [MSTP531] = SH_CLK_MSTP32(&p_clk, MSTPCR5, 31, 0), /* SCU0 */
135 [MSTP530] = SH_CLK_MSTP32(&p_clk, MSTPCR5, 30, 0), /* SCU1 */
136 [MSTP529] = SH_CLK_MSTP32(&p_clk, MSTPCR5, 29, 0), /* SCU2 */
137 [MSTP528] = SH_CLK_MSTP32(&p_clk, MSTPCR5, 28, 0), /* SCU3 */
138 [MSTP527] = SH_CLK_MSTP32(&p_clk, MSTPCR5, 27, 0), /* SCU4 */
139 [MSTP526] = SH_CLK_MSTP32(&p_clk, MSTPCR5, 26, 0), /* SCU5 */
140 [MSTP525] = SH_CLK_MSTP32(&p_clk, MSTPCR5, 25, 0), /* SCU6 */
141 [MSTP524] = SH_CLK_MSTP32(&p_clk, MSTPCR5, 24, 0), /* SCU7 */
142 [MSTP523] = SH_CLK_MSTP32(&p_clk, MSTPCR5, 23, 0), /* SCU8 */
132 [MSTP331] = SH_CLK_MSTP32(&s4_clk, MSTPCR3, 31, 0), /* MMC */ 143 [MSTP331] = SH_CLK_MSTP32(&s4_clk, MSTPCR3, 31, 0), /* MMC */
133 [MSTP323] = SH_CLK_MSTP32(&p_clk, MSTPCR3, 23, 0), /* SDHI0 */ 144 [MSTP323] = SH_CLK_MSTP32(&p_clk, MSTPCR3, 23, 0), /* SDHI0 */
134 [MSTP322] = SH_CLK_MSTP32(&p_clk, MSTPCR3, 22, 0), /* SDHI1 */ 145 [MSTP322] = SH_CLK_MSTP32(&p_clk, MSTPCR3, 22, 0), /* SDHI1 */
@@ -173,9 +184,13 @@ static struct clk_lookup lookups[] = {
173 184
174 /* MSTP32 clocks */ 185 /* MSTP32 clocks */
175 CLKDEV_DEV_ID("sh_mmcif", &mstp_clks[MSTP331]), /* MMC */ 186 CLKDEV_DEV_ID("sh_mmcif", &mstp_clks[MSTP331]), /* MMC */
187 CLKDEV_DEV_ID("ffe4e000.mmcif", &mstp_clks[MSTP331]), /* MMC */
176 CLKDEV_DEV_ID("sh_mobile_sdhi.0", &mstp_clks[MSTP323]), /* SDHI0 */ 188 CLKDEV_DEV_ID("sh_mobile_sdhi.0", &mstp_clks[MSTP323]), /* SDHI0 */
189 CLKDEV_DEV_ID("ffe4c000.sdhi", &mstp_clks[MSTP323]), /* SDHI0 */
177 CLKDEV_DEV_ID("sh_mobile_sdhi.1", &mstp_clks[MSTP322]), /* SDHI1 */ 190 CLKDEV_DEV_ID("sh_mobile_sdhi.1", &mstp_clks[MSTP322]), /* SDHI1 */
191 CLKDEV_DEV_ID("ffe4d000.sdhi", &mstp_clks[MSTP322]), /* SDHI1 */
178 CLKDEV_DEV_ID("sh_mobile_sdhi.2", &mstp_clks[MSTP321]), /* SDHI2 */ 192 CLKDEV_DEV_ID("sh_mobile_sdhi.2", &mstp_clks[MSTP321]), /* SDHI2 */
193 CLKDEV_DEV_ID("ffe4f000.sdhi", &mstp_clks[MSTP321]), /* SDHI2 */
179 CLKDEV_DEV_ID("r8a777x-ether", &mstp_clks[MSTP114]), /* Ether */ 194 CLKDEV_DEV_ID("r8a777x-ether", &mstp_clks[MSTP114]), /* Ether */
180 CLKDEV_DEV_ID("r8a7778-vin.0", &mstp_clks[MSTP110]), /* VIN0 */ 195 CLKDEV_DEV_ID("r8a7778-vin.0", &mstp_clks[MSTP110]), /* VIN0 */
181 CLKDEV_DEV_ID("r8a7778-vin.1", &mstp_clks[MSTP109]), /* VIN1 */ 196 CLKDEV_DEV_ID("r8a7778-vin.1", &mstp_clks[MSTP109]), /* VIN1 */
@@ -183,9 +198,13 @@ static struct clk_lookup lookups[] = {
183 CLKDEV_DEV_ID("ohci-platform", &mstp_clks[MSTP100]), /* USB OHCI port0/1 */ 198 CLKDEV_DEV_ID("ohci-platform", &mstp_clks[MSTP100]), /* USB OHCI port0/1 */
184 CLKDEV_DEV_ID("renesas_usbhs", &mstp_clks[MSTP100]), /* USB FUNC */ 199 CLKDEV_DEV_ID("renesas_usbhs", &mstp_clks[MSTP100]), /* USB FUNC */
185 CLKDEV_DEV_ID("i2c-rcar.0", &mstp_clks[MSTP030]), /* I2C0 */ 200 CLKDEV_DEV_ID("i2c-rcar.0", &mstp_clks[MSTP030]), /* I2C0 */
201 CLKDEV_DEV_ID("ffc70000.i2c", &mstp_clks[MSTP030]), /* I2C0 */
186 CLKDEV_DEV_ID("i2c-rcar.1", &mstp_clks[MSTP029]), /* I2C1 */ 202 CLKDEV_DEV_ID("i2c-rcar.1", &mstp_clks[MSTP029]), /* I2C1 */
203 CLKDEV_DEV_ID("ffc71000.i2c", &mstp_clks[MSTP029]), /* I2C1 */
187 CLKDEV_DEV_ID("i2c-rcar.2", &mstp_clks[MSTP028]), /* I2C2 */ 204 CLKDEV_DEV_ID("i2c-rcar.2", &mstp_clks[MSTP028]), /* I2C2 */
205 CLKDEV_DEV_ID("ffc72000.i2c", &mstp_clks[MSTP028]), /* I2C2 */
188 CLKDEV_DEV_ID("i2c-rcar.3", &mstp_clks[MSTP027]), /* I2C3 */ 206 CLKDEV_DEV_ID("i2c-rcar.3", &mstp_clks[MSTP027]), /* I2C3 */
207 CLKDEV_DEV_ID("ffc73000.i2c", &mstp_clks[MSTP027]), /* I2C3 */
189 CLKDEV_DEV_ID("sh-sci.0", &mstp_clks[MSTP026]), /* SCIF0 */ 208 CLKDEV_DEV_ID("sh-sci.0", &mstp_clks[MSTP026]), /* SCIF0 */
190 CLKDEV_DEV_ID("sh-sci.1", &mstp_clks[MSTP025]), /* SCIF1 */ 209 CLKDEV_DEV_ID("sh-sci.1", &mstp_clks[MSTP025]), /* SCIF1 */
191 CLKDEV_DEV_ID("sh-sci.2", &mstp_clks[MSTP024]), /* SCIF2 */ 210 CLKDEV_DEV_ID("sh-sci.2", &mstp_clks[MSTP024]), /* SCIF2 */
@@ -195,8 +214,11 @@ static struct clk_lookup lookups[] = {
195 CLKDEV_DEV_ID("sh_tmu.0", &mstp_clks[MSTP016]), /* TMU00 */ 214 CLKDEV_DEV_ID("sh_tmu.0", &mstp_clks[MSTP016]), /* TMU00 */
196 CLKDEV_DEV_ID("sh_tmu.1", &mstp_clks[MSTP015]), /* TMU01 */ 215 CLKDEV_DEV_ID("sh_tmu.1", &mstp_clks[MSTP015]), /* TMU01 */
197 CLKDEV_DEV_ID("sh-hspi.0", &mstp_clks[MSTP007]), /* HSPI0 */ 216 CLKDEV_DEV_ID("sh-hspi.0", &mstp_clks[MSTP007]), /* HSPI0 */
217 CLKDEV_DEV_ID("fffc7000.spi", &mstp_clks[MSTP007]), /* HSPI0 */
198 CLKDEV_DEV_ID("sh-hspi.1", &mstp_clks[MSTP007]), /* HSPI1 */ 218 CLKDEV_DEV_ID("sh-hspi.1", &mstp_clks[MSTP007]), /* HSPI1 */
219 CLKDEV_DEV_ID("fffc8000.spi", &mstp_clks[MSTP007]), /* HSPI1 */
199 CLKDEV_DEV_ID("sh-hspi.2", &mstp_clks[MSTP007]), /* HSPI2 */ 220 CLKDEV_DEV_ID("sh-hspi.2", &mstp_clks[MSTP007]), /* HSPI2 */
221 CLKDEV_DEV_ID("fffc6000.spi", &mstp_clks[MSTP007]), /* HSPI2 */
200 CLKDEV_DEV_ID("rcar_sound", &mstp_clks[MSTP008]), /* SRU */ 222 CLKDEV_DEV_ID("rcar_sound", &mstp_clks[MSTP008]), /* SRU */
201 223
202 CLKDEV_ICK_ID("ssi.0", "rcar_sound", &mstp_clks[MSTP012]), 224 CLKDEV_ICK_ID("ssi.0", "rcar_sound", &mstp_clks[MSTP012]),
@@ -208,6 +230,15 @@ static struct clk_lookup lookups[] = {
208 CLKDEV_ICK_ID("ssi.6", "rcar_sound", &mstp_clks[MSTP309]), 230 CLKDEV_ICK_ID("ssi.6", "rcar_sound", &mstp_clks[MSTP309]),
209 CLKDEV_ICK_ID("ssi.7", "rcar_sound", &mstp_clks[MSTP308]), 231 CLKDEV_ICK_ID("ssi.7", "rcar_sound", &mstp_clks[MSTP308]),
210 CLKDEV_ICK_ID("ssi.8", "rcar_sound", &mstp_clks[MSTP307]), 232 CLKDEV_ICK_ID("ssi.8", "rcar_sound", &mstp_clks[MSTP307]),
233 CLKDEV_ICK_ID("scu.0", "rcar_sound", &mstp_clks[MSTP531]),
234 CLKDEV_ICK_ID("scu.1", "rcar_sound", &mstp_clks[MSTP530]),
235 CLKDEV_ICK_ID("scu.2", "rcar_sound", &mstp_clks[MSTP529]),
236 CLKDEV_ICK_ID("scu.3", "rcar_sound", &mstp_clks[MSTP528]),
237 CLKDEV_ICK_ID("scu.4", "rcar_sound", &mstp_clks[MSTP527]),
238 CLKDEV_ICK_ID("scu.5", "rcar_sound", &mstp_clks[MSTP526]),
239 CLKDEV_ICK_ID("scu.6", "rcar_sound", &mstp_clks[MSTP525]),
240 CLKDEV_ICK_ID("scu.7", "rcar_sound", &mstp_clks[MSTP524]),
241 CLKDEV_ICK_ID("scu.8", "rcar_sound", &mstp_clks[MSTP523]),
211}; 242};
212 243
213void __init r8a7778_clock_init(void) 244void __init r8a7778_clock_init(void)
diff --git a/arch/arm/mach-shmobile/clock-r8a7779.c b/arch/arm/mach-shmobile/clock-r8a7779.c
index 1f7080fab0a5..b545c8dbb818 100644
--- a/arch/arm/mach-shmobile/clock-r8a7779.c
+++ b/arch/arm/mach-shmobile/clock-r8a7779.c
@@ -184,9 +184,13 @@ static struct clk_lookup lookups[] = {
184 CLKDEV_DEV_ID("sh_tmu.1", &mstp_clks[MSTP016]), /* TMU01 */ 184 CLKDEV_DEV_ID("sh_tmu.1", &mstp_clks[MSTP016]), /* TMU01 */
185 CLKDEV_DEV_ID("sh_tmu.2", &mstp_clks[MSTP016]), /* TMU02 */ 185 CLKDEV_DEV_ID("sh_tmu.2", &mstp_clks[MSTP016]), /* TMU02 */
186 CLKDEV_DEV_ID("i2c-rcar.0", &mstp_clks[MSTP030]), /* I2C0 */ 186 CLKDEV_DEV_ID("i2c-rcar.0", &mstp_clks[MSTP030]), /* I2C0 */
187 CLKDEV_DEV_ID("ffc70000.i2c", &mstp_clks[MSTP030]), /* I2C0 */
187 CLKDEV_DEV_ID("i2c-rcar.1", &mstp_clks[MSTP029]), /* I2C1 */ 188 CLKDEV_DEV_ID("i2c-rcar.1", &mstp_clks[MSTP029]), /* I2C1 */
189 CLKDEV_DEV_ID("ffc71000.i2c", &mstp_clks[MSTP029]), /* I2C1 */
188 CLKDEV_DEV_ID("i2c-rcar.2", &mstp_clks[MSTP028]), /* I2C2 */ 190 CLKDEV_DEV_ID("i2c-rcar.2", &mstp_clks[MSTP028]), /* I2C2 */
191 CLKDEV_DEV_ID("ffc72000.i2c", &mstp_clks[MSTP028]), /* I2C2 */
189 CLKDEV_DEV_ID("i2c-rcar.3", &mstp_clks[MSTP027]), /* I2C3 */ 192 CLKDEV_DEV_ID("i2c-rcar.3", &mstp_clks[MSTP027]), /* I2C3 */
193 CLKDEV_DEV_ID("ffc73000.i2c", &mstp_clks[MSTP027]), /* I2C3 */
190 CLKDEV_DEV_ID("sh-sci.0", &mstp_clks[MSTP026]), /* SCIF0 */ 194 CLKDEV_DEV_ID("sh-sci.0", &mstp_clks[MSTP026]), /* SCIF0 */
191 CLKDEV_DEV_ID("sh-sci.1", &mstp_clks[MSTP025]), /* SCIF1 */ 195 CLKDEV_DEV_ID("sh-sci.1", &mstp_clks[MSTP025]), /* SCIF1 */
192 CLKDEV_DEV_ID("sh-sci.2", &mstp_clks[MSTP024]), /* SCIF2 */ 196 CLKDEV_DEV_ID("sh-sci.2", &mstp_clks[MSTP024]), /* SCIF2 */
@@ -194,12 +198,19 @@ static struct clk_lookup lookups[] = {
194 CLKDEV_DEV_ID("sh-sci.4", &mstp_clks[MSTP022]), /* SCIF4 */ 198 CLKDEV_DEV_ID("sh-sci.4", &mstp_clks[MSTP022]), /* SCIF4 */
195 CLKDEV_DEV_ID("sh-sci.5", &mstp_clks[MSTP021]), /* SCIF6 */ 199 CLKDEV_DEV_ID("sh-sci.5", &mstp_clks[MSTP021]), /* SCIF6 */
196 CLKDEV_DEV_ID("sh-hspi.0", &mstp_clks[MSTP007]), /* HSPI0 */ 200 CLKDEV_DEV_ID("sh-hspi.0", &mstp_clks[MSTP007]), /* HSPI0 */
201 CLKDEV_DEV_ID("fffc7000.spi", &mstp_clks[MSTP007]), /* HSPI0 */
197 CLKDEV_DEV_ID("sh-hspi.1", &mstp_clks[MSTP007]), /* HSPI1 */ 202 CLKDEV_DEV_ID("sh-hspi.1", &mstp_clks[MSTP007]), /* HSPI1 */
203 CLKDEV_DEV_ID("fffc8000.spi", &mstp_clks[MSTP007]), /* HSPI1 */
198 CLKDEV_DEV_ID("sh-hspi.2", &mstp_clks[MSTP007]), /* HSPI2 */ 204 CLKDEV_DEV_ID("sh-hspi.2", &mstp_clks[MSTP007]), /* HSPI2 */
205 CLKDEV_DEV_ID("fffc6000.spi", &mstp_clks[MSTP007]), /* HSPI2 */
199 CLKDEV_DEV_ID("sh_mobile_sdhi.0", &mstp_clks[MSTP323]), /* SDHI0 */ 206 CLKDEV_DEV_ID("sh_mobile_sdhi.0", &mstp_clks[MSTP323]), /* SDHI0 */
207 CLKDEV_DEV_ID("ffe4c000.sdhi", &mstp_clks[MSTP323]), /* SDHI0 */
200 CLKDEV_DEV_ID("sh_mobile_sdhi.1", &mstp_clks[MSTP322]), /* SDHI1 */ 208 CLKDEV_DEV_ID("sh_mobile_sdhi.1", &mstp_clks[MSTP322]), /* SDHI1 */
209 CLKDEV_DEV_ID("ffe4d000.sdhi", &mstp_clks[MSTP322]), /* SDHI1 */
201 CLKDEV_DEV_ID("sh_mobile_sdhi.2", &mstp_clks[MSTP321]), /* SDHI2 */ 210 CLKDEV_DEV_ID("sh_mobile_sdhi.2", &mstp_clks[MSTP321]), /* SDHI2 */
211 CLKDEV_DEV_ID("ffe4e000.sdhi", &mstp_clks[MSTP321]), /* SDHI2 */
202 CLKDEV_DEV_ID("sh_mobile_sdhi.3", &mstp_clks[MSTP320]), /* SDHI3 */ 212 CLKDEV_DEV_ID("sh_mobile_sdhi.3", &mstp_clks[MSTP320]), /* SDHI3 */
213 CLKDEV_DEV_ID("ffe4f000.sdhi", &mstp_clks[MSTP320]), /* SDHI3 */
203 CLKDEV_DEV_ID("rcar-du-r8a7779", &mstp_clks[MSTP103]), /* DU */ 214 CLKDEV_DEV_ID("rcar-du-r8a7779", &mstp_clks[MSTP103]), /* DU */
204}; 215};
205 216
diff --git a/arch/arm/mach-shmobile/clock-r8a7790.c b/arch/arm/mach-shmobile/clock-r8a7790.c
index a64f965c7da1..b6ecea3ec7d5 100644
--- a/arch/arm/mach-shmobile/clock-r8a7790.c
+++ b/arch/arm/mach-shmobile/clock-r8a7790.c
@@ -53,6 +53,7 @@
53#define SMSTPCR7 0xe615014c 53#define SMSTPCR7 0xe615014c
54#define SMSTPCR8 0xe6150990 54#define SMSTPCR8 0xe6150990
55#define SMSTPCR9 0xe6150994 55#define SMSTPCR9 0xe6150994
56#define SMSTPCR10 0xe6150998
56 57
57#define SDCKCR 0xE6150074 58#define SDCKCR 0xE6150074
58#define SD2CKCR 0xE6150078 59#define SD2CKCR 0xE6150078
@@ -182,10 +183,14 @@ static struct clk div6_clks[DIV6_NR] = {
182 183
183/* MSTP */ 184/* MSTP */
184enum { 185enum {
186 MSTP1015, MSTP1014, MSTP1013, MSTP1012, MSTP1011, MSTP1010,
187 MSTP1009, MSTP1008, MSTP1007, MSTP1006, MSTP1005,
185 MSTP931, MSTP930, MSTP929, MSTP928, 188 MSTP931, MSTP930, MSTP929, MSTP928,
189 MSTP917,
186 MSTP813, 190 MSTP813,
187 MSTP726, MSTP725, MSTP724, MSTP723, MSTP722, MSTP721, MSTP720, 191 MSTP726, MSTP725, MSTP724, MSTP723, MSTP722, MSTP721, MSTP720,
188 MSTP717, MSTP716, 192 MSTP717, MSTP716,
193 MSTP704,
189 MSTP522, 194 MSTP522,
190 MSTP315, MSTP314, MSTP313, MSTP312, MSTP311, MSTP305, MSTP304, 195 MSTP315, MSTP314, MSTP313, MSTP312, MSTP311, MSTP305, MSTP304,
191 MSTP216, MSTP207, MSTP206, MSTP204, MSTP203, MSTP202, 196 MSTP216, MSTP207, MSTP206, MSTP204, MSTP203, MSTP202,
@@ -194,10 +199,22 @@ enum {
194}; 199};
195 200
196static struct clk mstp_clks[MSTP_NR] = { 201static struct clk mstp_clks[MSTP_NR] = {
197 [MSTP931] = SH_CLK_MSTP32(&hp_clk, SMSTPCR9, 31, 0), /* I2C0 */ 202 [MSTP1015] = SH_CLK_MSTP32(&p_clk, SMSTPCR10, 15, 0), /* SSI0 */
198 [MSTP930] = SH_CLK_MSTP32(&hp_clk, SMSTPCR9, 30, 0), /* I2C1 */ 203 [MSTP1014] = SH_CLK_MSTP32(&p_clk, SMSTPCR10, 14, 0), /* SSI1 */
199 [MSTP929] = SH_CLK_MSTP32(&hp_clk, SMSTPCR9, 29, 0), /* I2C2 */ 204 [MSTP1013] = SH_CLK_MSTP32(&p_clk, SMSTPCR10, 13, 0), /* SSI2 */
200 [MSTP928] = SH_CLK_MSTP32(&hp_clk, SMSTPCR9, 28, 0), /* I2C3 */ 205 [MSTP1012] = SH_CLK_MSTP32(&p_clk, SMSTPCR10, 12, 0), /* SSI3 */
206 [MSTP1011] = SH_CLK_MSTP32(&p_clk, SMSTPCR10, 11, 0), /* SSI4 */
207 [MSTP1010] = SH_CLK_MSTP32(&p_clk, SMSTPCR10, 10, 0), /* SSI5 */
208 [MSTP1009] = SH_CLK_MSTP32(&p_clk, SMSTPCR10, 9, 0), /* SSI6 */
209 [MSTP1008] = SH_CLK_MSTP32(&p_clk, SMSTPCR10, 8, 0), /* SSI7 */
210 [MSTP1007] = SH_CLK_MSTP32(&p_clk, SMSTPCR10, 7, 0), /* SSI8 */
211 [MSTP1006] = SH_CLK_MSTP32(&p_clk, SMSTPCR10, 6, 0), /* SSI9 */
212 [MSTP1005] = SH_CLK_MSTP32(&p_clk, SMSTPCR10, 5, 0), /* SSI ALL */
213 [MSTP931] = SH_CLK_MSTP32(&p_clk, SMSTPCR9, 31, 0), /* I2C0 */
214 [MSTP930] = SH_CLK_MSTP32(&p_clk, SMSTPCR9, 30, 0), /* I2C1 */
215 [MSTP929] = SH_CLK_MSTP32(&p_clk, SMSTPCR9, 29, 0), /* I2C2 */
216 [MSTP928] = SH_CLK_MSTP32(&p_clk, SMSTPCR9, 28, 0), /* I2C3 */
217 [MSTP917] = SH_CLK_MSTP32(&qspi_clk, SMSTPCR9, 17, 0), /* QSPI */
201 [MSTP813] = SH_CLK_MSTP32(&p_clk, SMSTPCR8, 13, 0), /* Ether */ 218 [MSTP813] = SH_CLK_MSTP32(&p_clk, SMSTPCR8, 13, 0), /* Ether */
202 [MSTP726] = SH_CLK_MSTP32(&zx_clk, SMSTPCR7, 26, 0), /* LVDS0 */ 219 [MSTP726] = SH_CLK_MSTP32(&zx_clk, SMSTPCR7, 26, 0), /* LVDS0 */
203 [MSTP725] = SH_CLK_MSTP32(&zx_clk, SMSTPCR7, 25, 0), /* LVDS1 */ 220 [MSTP725] = SH_CLK_MSTP32(&zx_clk, SMSTPCR7, 25, 0), /* LVDS1 */
@@ -208,6 +225,7 @@ static struct clk mstp_clks[MSTP_NR] = {
208 [MSTP720] = SH_CLK_MSTP32(&p_clk, SMSTPCR7, 20, 0), /* SCIF1 */ 225 [MSTP720] = SH_CLK_MSTP32(&p_clk, SMSTPCR7, 20, 0), /* SCIF1 */
209 [MSTP717] = SH_CLK_MSTP32(&zs_clk, SMSTPCR7, 17, 0), /* HSCIF0 */ 226 [MSTP717] = SH_CLK_MSTP32(&zs_clk, SMSTPCR7, 17, 0), /* HSCIF0 */
210 [MSTP716] = SH_CLK_MSTP32(&zs_clk, SMSTPCR7, 16, 0), /* HSCIF1 */ 227 [MSTP716] = SH_CLK_MSTP32(&zs_clk, SMSTPCR7, 16, 0), /* HSCIF1 */
228 [MSTP704] = SH_CLK_MSTP32(&mp_clk, SMSTPCR7, 4, 0), /* HSUSB */
211 [MSTP522] = SH_CLK_MSTP32(&extal_clk, SMSTPCR5, 22, 0), /* Thermal */ 229 [MSTP522] = SH_CLK_MSTP32(&extal_clk, SMSTPCR5, 22, 0), /* Thermal */
212 [MSTP315] = SH_CLK_MSTP32(&div6_clks[DIV6_MMC0], SMSTPCR3, 15, 0), /* MMC0 */ 230 [MSTP315] = SH_CLK_MSTP32(&div6_clks[DIV6_MMC0], SMSTPCR3, 15, 0), /* MMC0 */
213 [MSTP314] = SH_CLK_MSTP32(&div4_clks[DIV4_SD0], SMSTPCR3, 14, 0), /* SDHI0 */ 231 [MSTP314] = SH_CLK_MSTP32(&div4_clks[DIV4_SD0], SMSTPCR3, 14, 0), /* SDHI0 */
@@ -262,11 +280,7 @@ static struct clk_lookup lookups[] = {
262 CLKDEV_CON_ID("ssprs", &div6_clks[DIV6_SSPRS]), 280 CLKDEV_CON_ID("ssprs", &div6_clks[DIV6_SSPRS]),
263 281
264 /* MSTP */ 282 /* MSTP */
265 CLKDEV_ICK_ID("lvds.0", "rcar-du-r8a7790", &mstp_clks[MSTP726]), 283 CLKDEV_DEV_ID("rcar_sound", &mstp_clks[MSTP1005]),
266 CLKDEV_ICK_ID("lvds.1", "rcar-du-r8a7790", &mstp_clks[MSTP725]),
267 CLKDEV_ICK_ID("du.0", "rcar-du-r8a7790", &mstp_clks[MSTP724]),
268 CLKDEV_ICK_ID("du.1", "rcar-du-r8a7790", &mstp_clks[MSTP723]),
269 CLKDEV_ICK_ID("du.2", "rcar-du-r8a7790", &mstp_clks[MSTP722]),
270 CLKDEV_DEV_ID("sh-sci.0", &mstp_clks[MSTP204]), 284 CLKDEV_DEV_ID("sh-sci.0", &mstp_clks[MSTP204]),
271 CLKDEV_DEV_ID("sh-sci.1", &mstp_clks[MSTP203]), 285 CLKDEV_DEV_ID("sh-sci.1", &mstp_clks[MSTP203]),
272 CLKDEV_DEV_ID("sh-sci.2", &mstp_clks[MSTP206]), 286 CLKDEV_DEV_ID("sh-sci.2", &mstp_clks[MSTP206]),
@@ -278,10 +292,15 @@ static struct clk_lookup lookups[] = {
278 CLKDEV_DEV_ID("sh-sci.8", &mstp_clks[MSTP717]), 292 CLKDEV_DEV_ID("sh-sci.8", &mstp_clks[MSTP717]),
279 CLKDEV_DEV_ID("sh-sci.9", &mstp_clks[MSTP716]), 293 CLKDEV_DEV_ID("sh-sci.9", &mstp_clks[MSTP716]),
280 CLKDEV_DEV_ID("e6508000.i2c", &mstp_clks[MSTP931]), 294 CLKDEV_DEV_ID("e6508000.i2c", &mstp_clks[MSTP931]),
295 CLKDEV_DEV_ID("i2c-rcar.0", &mstp_clks[MSTP931]),
281 CLKDEV_DEV_ID("e6518000.i2c", &mstp_clks[MSTP930]), 296 CLKDEV_DEV_ID("e6518000.i2c", &mstp_clks[MSTP930]),
297 CLKDEV_DEV_ID("i2c-rcar.1", &mstp_clks[MSTP930]),
282 CLKDEV_DEV_ID("e6530000.i2c", &mstp_clks[MSTP929]), 298 CLKDEV_DEV_ID("e6530000.i2c", &mstp_clks[MSTP929]),
299 CLKDEV_DEV_ID("i2c-rcar.2", &mstp_clks[MSTP929]),
283 CLKDEV_DEV_ID("e6540000.i2c", &mstp_clks[MSTP928]), 300 CLKDEV_DEV_ID("e6540000.i2c", &mstp_clks[MSTP928]),
301 CLKDEV_DEV_ID("i2c-rcar.3", &mstp_clks[MSTP928]),
284 CLKDEV_DEV_ID("r8a7790-ether", &mstp_clks[MSTP813]), 302 CLKDEV_DEV_ID("r8a7790-ether", &mstp_clks[MSTP813]),
303 CLKDEV_DEV_ID("e61f0000.thermal", &mstp_clks[MSTP522]),
285 CLKDEV_DEV_ID("rcar_thermal", &mstp_clks[MSTP522]), 304 CLKDEV_DEV_ID("rcar_thermal", &mstp_clks[MSTP522]),
286 CLKDEV_DEV_ID("ee200000.mmcif", &mstp_clks[MSTP315]), 305 CLKDEV_DEV_ID("ee200000.mmcif", &mstp_clks[MSTP315]),
287 CLKDEV_DEV_ID("sh_mmcif.0", &mstp_clks[MSTP315]), 306 CLKDEV_DEV_ID("sh_mmcif.0", &mstp_clks[MSTP315]),
@@ -296,6 +315,27 @@ static struct clk_lookup lookups[] = {
296 CLKDEV_DEV_ID("ee220000.mmcif", &mstp_clks[MSTP305]), 315 CLKDEV_DEV_ID("ee220000.mmcif", &mstp_clks[MSTP305]),
297 CLKDEV_DEV_ID("sh_mmcif.1", &mstp_clks[MSTP305]), 316 CLKDEV_DEV_ID("sh_mmcif.1", &mstp_clks[MSTP305]),
298 CLKDEV_DEV_ID("sh_cmt.0", &mstp_clks[MSTP124]), 317 CLKDEV_DEV_ID("sh_cmt.0", &mstp_clks[MSTP124]),
318 CLKDEV_DEV_ID("qspi.0", &mstp_clks[MSTP917]),
319 CLKDEV_DEV_ID("renesas_usbhs", &mstp_clks[MSTP704]),
320
321 /* ICK */
322 CLKDEV_ICK_ID("usbhs", "usb_phy_rcar_gen2", &mstp_clks[MSTP704]),
323 CLKDEV_ICK_ID("lvds.0", "rcar-du-r8a7790", &mstp_clks[MSTP726]),
324 CLKDEV_ICK_ID("lvds.1", "rcar-du-r8a7790", &mstp_clks[MSTP725]),
325 CLKDEV_ICK_ID("du.0", "rcar-du-r8a7790", &mstp_clks[MSTP724]),
326 CLKDEV_ICK_ID("du.1", "rcar-du-r8a7790", &mstp_clks[MSTP723]),
327 CLKDEV_ICK_ID("du.2", "rcar-du-r8a7790", &mstp_clks[MSTP722]),
328 CLKDEV_ICK_ID("ssi.0", "rcar_sound", &mstp_clks[MSTP1015]),
329 CLKDEV_ICK_ID("ssi.1", "rcar_sound", &mstp_clks[MSTP1014]),
330 CLKDEV_ICK_ID("ssi.2", "rcar_sound", &mstp_clks[MSTP1013]),
331 CLKDEV_ICK_ID("ssi.3", "rcar_sound", &mstp_clks[MSTP1012]),
332 CLKDEV_ICK_ID("ssi.4", "rcar_sound", &mstp_clks[MSTP1011]),
333 CLKDEV_ICK_ID("ssi.5", "rcar_sound", &mstp_clks[MSTP1010]),
334 CLKDEV_ICK_ID("ssi.6", "rcar_sound", &mstp_clks[MSTP1009]),
335 CLKDEV_ICK_ID("ssi.7", "rcar_sound", &mstp_clks[MSTP1008]),
336 CLKDEV_ICK_ID("ssi.8", "rcar_sound", &mstp_clks[MSTP1007]),
337 CLKDEV_ICK_ID("ssi.9", "rcar_sound", &mstp_clks[MSTP1006]),
338
299}; 339};
300 340
301#define R8A7790_CLOCK_ROOT(e, m, p0, p1, p30, p31) \ 341#define R8A7790_CLOCK_ROOT(e, m, p0, p1, p30, p31) \
@@ -321,10 +361,10 @@ void __init r8a7790_clock_init(void)
321 R8A7790_CLOCK_ROOT(20, &extal_clk, 130, 156, 80, 66); 361 R8A7790_CLOCK_ROOT(20, &extal_clk, 130, 156, 80, 66);
322 break; 362 break;
323 case MD(14): 363 case MD(14):
324 R8A7790_CLOCK_ROOT(26, &extal_div2_clk, 200, 240, 122, 102); 364 R8A7790_CLOCK_ROOT(26 / 2, &extal_div2_clk, 200, 240, 122, 102);
325 break; 365 break;
326 case MD(13) | MD(14): 366 case MD(13) | MD(14):
327 R8A7790_CLOCK_ROOT(30, &extal_div2_clk, 172, 208, 106, 88); 367 R8A7790_CLOCK_ROOT(30 / 2, &extal_div2_clk, 172, 208, 106, 88);
328 break; 368 break;
329 } 369 }
330 370
diff --git a/arch/arm/mach-shmobile/clock-r8a7791.c b/arch/arm/mach-shmobile/clock-r8a7791.c
index c9a26f16ce5b..f5461262ee25 100644
--- a/arch/arm/mach-shmobile/clock-r8a7791.c
+++ b/arch/arm/mach-shmobile/clock-r8a7791.c
@@ -103,6 +103,7 @@ SH_FIXED_RATIO_CLK_SET(hp_clk, pll1_clk, 1, 12);
103SH_FIXED_RATIO_CLK_SET(p_clk, pll1_clk, 1, 24); 103SH_FIXED_RATIO_CLK_SET(p_clk, pll1_clk, 1, 24);
104SH_FIXED_RATIO_CLK_SET(rclk_clk, pll1_clk, 1, (48 * 1024)); 104SH_FIXED_RATIO_CLK_SET(rclk_clk, pll1_clk, 1, (48 * 1024));
105SH_FIXED_RATIO_CLK_SET(mp_clk, pll1_div2_clk, 1, 15); 105SH_FIXED_RATIO_CLK_SET(mp_clk, pll1_div2_clk, 1, 15);
106SH_FIXED_RATIO_CLK_SET(zx_clk, pll1_clk, 1, 3);
106 107
107static struct clk *main_clks[] = { 108static struct clk *main_clks[] = {
108 &extal_clk, 109 &extal_clk,
@@ -116,12 +117,15 @@ static struct clk *main_clks[] = {
116 &rclk_clk, 117 &rclk_clk,
117 &mp_clk, 118 &mp_clk,
118 &cp_clk, 119 &cp_clk,
120 &zx_clk,
119}; 121};
120 122
121/* MSTP */ 123/* MSTP */
122enum { 124enum {
123 MSTP721, MSTP720, 125 MSTP813,
126 MSTP726, MSTP724, MSTP723, MSTP721, MSTP720,
124 MSTP719, MSTP718, MSTP715, MSTP714, 127 MSTP719, MSTP718, MSTP715, MSTP714,
128 MSTP522,
125 MSTP216, MSTP207, MSTP206, 129 MSTP216, MSTP207, MSTP206,
126 MSTP204, MSTP203, MSTP202, MSTP1105, MSTP1106, MSTP1107, 130 MSTP204, MSTP203, MSTP202, MSTP1105, MSTP1106, MSTP1107,
127 MSTP124, 131 MSTP124,
@@ -129,12 +133,17 @@ enum {
129}; 133};
130 134
131static struct clk mstp_clks[MSTP_NR] = { 135static struct clk mstp_clks[MSTP_NR] = {
136 [MSTP813] = SH_CLK_MSTP32(&p_clk, SMSTPCR8, 13, 0), /* Ether */
137 [MSTP726] = SH_CLK_MSTP32(&zx_clk, SMSTPCR7, 26, 0), /* LVDS0 */
138 [MSTP724] = SH_CLK_MSTP32(&zx_clk, SMSTPCR7, 24, 0), /* DU0 */
139 [MSTP723] = SH_CLK_MSTP32(&zx_clk, SMSTPCR7, 23, 0), /* DU1 */
132 [MSTP721] = SH_CLK_MSTP32(&p_clk, SMSTPCR7, 21, 0), /* SCIF0 */ 140 [MSTP721] = SH_CLK_MSTP32(&p_clk, SMSTPCR7, 21, 0), /* SCIF0 */
133 [MSTP720] = SH_CLK_MSTP32(&p_clk, SMSTPCR7, 20, 0), /* SCIF1 */ 141 [MSTP720] = SH_CLK_MSTP32(&p_clk, SMSTPCR7, 20, 0), /* SCIF1 */
134 [MSTP719] = SH_CLK_MSTP32(&p_clk, SMSTPCR7, 19, 0), /* SCIF2 */ 142 [MSTP719] = SH_CLK_MSTP32(&p_clk, SMSTPCR7, 19, 0), /* SCIF2 */
135 [MSTP718] = SH_CLK_MSTP32(&p_clk, SMSTPCR7, 18, 0), /* SCIF3 */ 143 [MSTP718] = SH_CLK_MSTP32(&p_clk, SMSTPCR7, 18, 0), /* SCIF3 */
136 [MSTP715] = SH_CLK_MSTP32(&p_clk, SMSTPCR7, 15, 0), /* SCIF4 */ 144 [MSTP715] = SH_CLK_MSTP32(&p_clk, SMSTPCR7, 15, 0), /* SCIF4 */
137 [MSTP714] = SH_CLK_MSTP32(&p_clk, SMSTPCR7, 14, 0), /* SCIF5 */ 145 [MSTP714] = SH_CLK_MSTP32(&p_clk, SMSTPCR7, 14, 0), /* SCIF5 */
146 [MSTP522] = SH_CLK_MSTP32(&extal_clk, SMSTPCR5, 22, 0), /* Thermal */
138 [MSTP216] = SH_CLK_MSTP32(&mp_clk, SMSTPCR2, 16, 0), /* SCIFB2 */ 147 [MSTP216] = SH_CLK_MSTP32(&mp_clk, SMSTPCR2, 16, 0), /* SCIFB2 */
139 [MSTP207] = SH_CLK_MSTP32(&mp_clk, SMSTPCR2, 7, 0), /* SCIFB1 */ 148 [MSTP207] = SH_CLK_MSTP32(&mp_clk, SMSTPCR2, 7, 0), /* SCIFB1 */
140 [MSTP206] = SH_CLK_MSTP32(&mp_clk, SMSTPCR2, 6, 0), /* SCIFB0 */ 149 [MSTP206] = SH_CLK_MSTP32(&mp_clk, SMSTPCR2, 6, 0), /* SCIFB0 */
@@ -164,6 +173,9 @@ static struct clk_lookup lookups[] = {
164 CLKDEV_CON_ID("peripheral_clk", &hp_clk), 173 CLKDEV_CON_ID("peripheral_clk", &hp_clk),
165 174
166 /* MSTP */ 175 /* MSTP */
176 CLKDEV_ICK_ID("lvds.0", "rcar-du-r8a7791", &mstp_clks[MSTP726]),
177 CLKDEV_ICK_ID("du.0", "rcar-du-r8a7791", &mstp_clks[MSTP724]),
178 CLKDEV_ICK_ID("du.1", "rcar-du-r8a7791", &mstp_clks[MSTP723]),
167 CLKDEV_DEV_ID("sh-sci.0", &mstp_clks[MSTP204]), /* SCIFA0 */ 179 CLKDEV_DEV_ID("sh-sci.0", &mstp_clks[MSTP204]), /* SCIFA0 */
168 CLKDEV_DEV_ID("sh-sci.1", &mstp_clks[MSTP203]), /* SCIFA1 */ 180 CLKDEV_DEV_ID("sh-sci.1", &mstp_clks[MSTP203]), /* SCIFA1 */
169 CLKDEV_DEV_ID("sh-sci.2", &mstp_clks[MSTP206]), /* SCIFB0 */ 181 CLKDEV_DEV_ID("sh-sci.2", &mstp_clks[MSTP206]), /* SCIFB0 */
@@ -180,6 +192,9 @@ static struct clk_lookup lookups[] = {
180 CLKDEV_DEV_ID("sh-sci.13", &mstp_clks[MSTP1106]), /* SCIFA4 */ 192 CLKDEV_DEV_ID("sh-sci.13", &mstp_clks[MSTP1106]), /* SCIFA4 */
181 CLKDEV_DEV_ID("sh-sci.14", &mstp_clks[MSTP1107]), /* SCIFA5 */ 193 CLKDEV_DEV_ID("sh-sci.14", &mstp_clks[MSTP1107]), /* SCIFA5 */
182 CLKDEV_DEV_ID("sh_cmt.0", &mstp_clks[MSTP124]), 194 CLKDEV_DEV_ID("sh_cmt.0", &mstp_clks[MSTP124]),
195 CLKDEV_DEV_ID("e61f0000.thermal", &mstp_clks[MSTP522]),
196 CLKDEV_DEV_ID("rcar_thermal", &mstp_clks[MSTP522]),
197 CLKDEV_DEV_ID("r8a7791-ether", &mstp_clks[MSTP813]), /* Ether */
183}; 198};
184 199
185#define R8A7791_CLOCK_ROOT(e, m, p0, p1, p30, p31) \ 200#define R8A7791_CLOCK_ROOT(e, m, p0, p1, p30, p31) \
diff --git a/arch/arm/mach-shmobile/clock-sh73a0.c b/arch/arm/mach-shmobile/clock-sh73a0.c
index c92c023f0d27..5e6a0566f3c6 100644
--- a/arch/arm/mach-shmobile/clock-sh73a0.c
+++ b/arch/arm/mach-shmobile/clock-sh73a0.c
@@ -658,6 +658,7 @@ static struct clk_lookup lookups[] = {
658 CLKDEV_DEV_ID("sh-sci.6", &mstp_clks[MSTP331]), /* SCIFA6 */ 658 CLKDEV_DEV_ID("sh-sci.6", &mstp_clks[MSTP331]), /* SCIFA6 */
659 CLKDEV_DEV_ID("sh_cmt.10", &mstp_clks[MSTP329]), /* CMT10 */ 659 CLKDEV_DEV_ID("sh_cmt.10", &mstp_clks[MSTP329]), /* CMT10 */
660 CLKDEV_DEV_ID("sh_fsi2", &mstp_clks[MSTP328]), /* FSI */ 660 CLKDEV_DEV_ID("sh_fsi2", &mstp_clks[MSTP328]), /* FSI */
661 CLKDEV_DEV_ID("ec230000.sound", &mstp_clks[MSTP328]), /* FSI */
661 CLKDEV_DEV_ID("sh_irda.0", &mstp_clks[MSTP325]), /* IrDA */ 662 CLKDEV_DEV_ID("sh_irda.0", &mstp_clks[MSTP325]), /* IrDA */
662 CLKDEV_DEV_ID("i2c-sh_mobile.1", &mstp_clks[MSTP323]), /* I2C1 */ 663 CLKDEV_DEV_ID("i2c-sh_mobile.1", &mstp_clks[MSTP323]), /* I2C1 */
663 CLKDEV_DEV_ID("e6822000.i2c", &mstp_clks[MSTP323]), /* I2C1 */ 664 CLKDEV_DEV_ID("e6822000.i2c", &mstp_clks[MSTP323]), /* I2C1 */
diff --git a/arch/arm/mach-shmobile/include/mach/emev2.h b/arch/arm/mach-shmobile/include/mach/emev2.h
index c2eb7568d9be..fcb142a14e07 100644
--- a/arch/arm/mach-shmobile/include/mach/emev2.h
+++ b/arch/arm/mach-shmobile/include/mach/emev2.h
@@ -3,12 +3,7 @@
3 3
4extern void emev2_map_io(void); 4extern void emev2_map_io(void);
5extern void emev2_init_delay(void); 5extern void emev2_init_delay(void);
6extern void emev2_add_standard_devices(void);
7extern void emev2_clock_init(void); 6extern void emev2_clock_init(void);
8
9#define EMEV2_GPIO_BASE 200
10#define EMEV2_GPIO_IRQ(n) (EMEV2_GPIO_BASE + (n))
11
12extern struct smp_operations emev2_smp_ops; 7extern struct smp_operations emev2_smp_ops;
13 8
14#endif /* __ASM_EMEV2_H__ */ 9#endif /* __ASM_EMEV2_H__ */
diff --git a/arch/arm/mach-shmobile/include/mach/r8a7778.h b/arch/arm/mach-shmobile/include/mach/r8a7778.h
index 441886c9714b..f4076a50e970 100644
--- a/arch/arm/mach-shmobile/include/mach/r8a7778.h
+++ b/arch/arm/mach-shmobile/include/mach/r8a7778.h
@@ -20,13 +20,50 @@
20#define __ASM_R8A7778_H__ 20#define __ASM_R8A7778_H__
21 21
22#include <linux/sh_eth.h> 22#include <linux/sh_eth.h>
23#include <linux/platform_data/camera-rcar.h>
24 23
25/* HPB-DMA slave IDs */ 24/* HPB-DMA slave IDs */
26enum { 25enum {
27 HPBDMA_SLAVE_DUMMY, 26 HPBDMA_SLAVE_DUMMY,
28 HPBDMA_SLAVE_SDHI0_TX, 27 HPBDMA_SLAVE_SDHI0_TX,
29 HPBDMA_SLAVE_SDHI0_RX, 28 HPBDMA_SLAVE_SDHI0_RX,
29 HPBDMA_SLAVE_SSI0_TX,
30 HPBDMA_SLAVE_SSI0_RX,
31 HPBDMA_SLAVE_SSI1_TX,
32 HPBDMA_SLAVE_SSI1_RX,
33 HPBDMA_SLAVE_SSI2_TX,
34 HPBDMA_SLAVE_SSI2_RX,
35 HPBDMA_SLAVE_SSI3_TX,
36 HPBDMA_SLAVE_SSI3_RX,
37 HPBDMA_SLAVE_SSI4_TX,
38 HPBDMA_SLAVE_SSI4_RX,
39 HPBDMA_SLAVE_SSI5_TX,
40 HPBDMA_SLAVE_SSI5_RX,
41 HPBDMA_SLAVE_SSI6_TX,
42 HPBDMA_SLAVE_SSI6_RX,
43 HPBDMA_SLAVE_SSI7_TX,
44 HPBDMA_SLAVE_SSI7_RX,
45 HPBDMA_SLAVE_SSI8_TX,
46 HPBDMA_SLAVE_SSI8_RX,
47 HPBDMA_SLAVE_HPBIF0_TX,
48 HPBDMA_SLAVE_HPBIF0_RX,
49 HPBDMA_SLAVE_HPBIF1_TX,
50 HPBDMA_SLAVE_HPBIF1_RX,
51 HPBDMA_SLAVE_HPBIF2_TX,
52 HPBDMA_SLAVE_HPBIF2_RX,
53 HPBDMA_SLAVE_HPBIF3_TX,
54 HPBDMA_SLAVE_HPBIF3_RX,
55 HPBDMA_SLAVE_HPBIF4_TX,
56 HPBDMA_SLAVE_HPBIF4_RX,
57 HPBDMA_SLAVE_HPBIF5_TX,
58 HPBDMA_SLAVE_HPBIF5_RX,
59 HPBDMA_SLAVE_HPBIF6_TX,
60 HPBDMA_SLAVE_HPBIF6_RX,
61 HPBDMA_SLAVE_HPBIF7_TX,
62 HPBDMA_SLAVE_HPBIF7_RX,
63 HPBDMA_SLAVE_HPBIF8_TX,
64 HPBDMA_SLAVE_HPBIF8_RX,
65 HPBDMA_SLAVE_USBFUNC_TX,
66 HPBDMA_SLAVE_USBFUNC_RX,
30}; 67};
31 68
32extern void r8a7778_add_standard_devices(void); 69extern void r8a7778_add_standard_devices(void);
diff --git a/arch/arm/mach-shmobile/include/mach/r8a7791.h b/arch/arm/mach-shmobile/include/mach/r8a7791.h
index 051ead3c286e..200fa699f730 100644
--- a/arch/arm/mach-shmobile/include/mach/r8a7791.h
+++ b/arch/arm/mach-shmobile/include/mach/r8a7791.h
@@ -4,6 +4,7 @@
4void r8a7791_add_standard_devices(void); 4void r8a7791_add_standard_devices(void);
5void r8a7791_add_dt_devices(void); 5void r8a7791_add_dt_devices(void);
6void r8a7791_clock_init(void); 6void r8a7791_clock_init(void);
7void r8a7791_pinmux_init(void);
7void r8a7791_init_early(void); 8void r8a7791_init_early(void);
8extern struct smp_operations r8a7791_smp_ops; 9extern struct smp_operations r8a7791_smp_ops;
9 10
diff --git a/arch/arm/mach-shmobile/setup-emev2.c b/arch/arm/mach-shmobile/setup-emev2.c
index 3ad531caf4f0..c8f2a1a69a52 100644
--- a/arch/arm/mach-shmobile/setup-emev2.c
+++ b/arch/arm/mach-shmobile/setup-emev2.c
@@ -16,24 +16,15 @@
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */ 18 */
19#include <linux/clk-provider.h>
19#include <linux/kernel.h> 20#include <linux/kernel.h>
20#include <linux/init.h> 21#include <linux/init.h>
21#include <linux/interrupt.h>
22#include <linux/irq.h>
23#include <linux/platform_device.h>
24#include <linux/platform_data/gpio-em.h>
25#include <linux/of_platform.h> 22#include <linux/of_platform.h>
26#include <linux/delay.h>
27#include <linux/input.h>
28#include <linux/io.h>
29#include <linux/irqchip/arm-gic.h>
30#include <mach/common.h> 23#include <mach/common.h>
31#include <mach/emev2.h> 24#include <mach/emev2.h>
32#include <mach/irqs.h>
33#include <asm/mach-types.h> 25#include <asm/mach-types.h>
34#include <asm/mach/arch.h> 26#include <asm/mach/arch.h>
35#include <asm/mach/map.h> 27#include <asm/mach/map.h>
36#include <asm/mach/time.h>
37 28
38static struct map_desc emev2_io_desc[] __initdata = { 29static struct map_desc emev2_io_desc[] __initdata = {
39#ifdef CONFIG_SMP 30#ifdef CONFIG_SMP
@@ -52,150 +43,20 @@ void __init emev2_map_io(void)
52 iotable_init(emev2_io_desc, ARRAY_SIZE(emev2_io_desc)); 43 iotable_init(emev2_io_desc, ARRAY_SIZE(emev2_io_desc));
53} 44}
54 45
55/* UART */
56static struct resource uart0_resources[] = {
57 DEFINE_RES_MEM(0xe1020000, 0x38),
58 DEFINE_RES_IRQ(40),
59};
60
61static struct resource uart1_resources[] = {
62 DEFINE_RES_MEM(0xe1030000, 0x38),
63 DEFINE_RES_IRQ(41),
64};
65
66static struct resource uart2_resources[] = {
67 DEFINE_RES_MEM(0xe1040000, 0x38),
68 DEFINE_RES_IRQ(42),
69};
70
71static struct resource uart3_resources[] = {
72 DEFINE_RES_MEM(0xe1050000, 0x38),
73 DEFINE_RES_IRQ(43),
74};
75
76#define emev2_register_uart(idx) \
77 platform_device_register_simple("serial8250-em", idx, \
78 uart##idx##_resources, \
79 ARRAY_SIZE(uart##idx##_resources))
80
81/* STI */
82static struct resource sti_resources[] = {
83 DEFINE_RES_MEM(0xe0180000, 0x54),
84 DEFINE_RES_IRQ(157),
85};
86
87#define emev2_register_sti() \
88 platform_device_register_simple("em_sti", 0, \
89 sti_resources, \
90 ARRAY_SIZE(sti_resources))
91
92/* GIO */
93static struct gpio_em_config gio0_config = {
94 .gpio_base = 0,
95 .irq_base = EMEV2_GPIO_IRQ(0),
96 .number_of_pins = 32,
97};
98
99static struct resource gio0_resources[] = {
100 DEFINE_RES_MEM(0xe0050000, 0x2c),
101 DEFINE_RES_MEM(0xe0050040, 0x20),
102 DEFINE_RES_IRQ(99),
103 DEFINE_RES_IRQ(100),
104};
105
106static struct gpio_em_config gio1_config = {
107 .gpio_base = 32,
108 .irq_base = EMEV2_GPIO_IRQ(32),
109 .number_of_pins = 32,
110};
111
112static struct resource gio1_resources[] = {
113 DEFINE_RES_MEM(0xe0050080, 0x2c),
114 DEFINE_RES_MEM(0xe00500c0, 0x20),
115 DEFINE_RES_IRQ(101),
116 DEFINE_RES_IRQ(102),
117};
118
119static struct gpio_em_config gio2_config = {
120 .gpio_base = 64,
121 .irq_base = EMEV2_GPIO_IRQ(64),
122 .number_of_pins = 32,
123};
124
125static struct resource gio2_resources[] = {
126 DEFINE_RES_MEM(0xe0050100, 0x2c),
127 DEFINE_RES_MEM(0xe0050140, 0x20),
128 DEFINE_RES_IRQ(103),
129 DEFINE_RES_IRQ(104),
130};
131
132static struct gpio_em_config gio3_config = {
133 .gpio_base = 96,
134 .irq_base = EMEV2_GPIO_IRQ(96),
135 .number_of_pins = 32,
136};
137
138static struct resource gio3_resources[] = {
139 DEFINE_RES_MEM(0xe0050180, 0x2c),
140 DEFINE_RES_MEM(0xe00501c0, 0x20),
141 DEFINE_RES_IRQ(105),
142 DEFINE_RES_IRQ(106),
143};
144
145static struct gpio_em_config gio4_config = {
146 .gpio_base = 128,
147 .irq_base = EMEV2_GPIO_IRQ(128),
148 .number_of_pins = 31,
149};
150
151static struct resource gio4_resources[] = {
152 DEFINE_RES_MEM(0xe0050200, 0x2c),
153 DEFINE_RES_MEM(0xe0050240, 0x20),
154 DEFINE_RES_IRQ(107),
155 DEFINE_RES_IRQ(108),
156};
157
158#define emev2_register_gio(idx) \
159 platform_device_register_resndata(&platform_bus, "em_gio", \
160 idx, gio##idx##_resources, \
161 ARRAY_SIZE(gio##idx##_resources), \
162 &gio##idx##_config, \
163 sizeof(struct gpio_em_config))
164
165static struct resource pmu_resources[] = {
166 DEFINE_RES_IRQ(152),
167 DEFINE_RES_IRQ(153),
168};
169
170#define emev2_register_pmu() \
171 platform_device_register_simple("arm-pmu", -1, \
172 pmu_resources, \
173 ARRAY_SIZE(pmu_resources))
174
175void __init emev2_add_standard_devices(void)
176{
177 if (!IS_ENABLED(CONFIG_COMMON_CLK))
178 emev2_clock_init();
179
180 emev2_register_uart(0);
181 emev2_register_uart(1);
182 emev2_register_uart(2);
183 emev2_register_uart(3);
184 emev2_register_sti();
185 emev2_register_gio(0);
186 emev2_register_gio(1);
187 emev2_register_gio(2);
188 emev2_register_gio(3);
189 emev2_register_gio(4);
190 emev2_register_pmu();
191}
192
193void __init emev2_init_delay(void) 46void __init emev2_init_delay(void)
194{ 47{
195 shmobile_setup_delay(533, 1, 3); /* Cortex-A9 @ 533MHz */ 48 shmobile_setup_delay(533, 1, 3); /* Cortex-A9 @ 533MHz */
196} 49}
197 50
198#ifdef CONFIG_USE_OF 51static void __init emev2_add_standard_devices_dt(void)
52{
53#ifdef CONFIG_COMMON_CLK
54 of_clk_init(NULL);
55#else
56 emev2_clock_init();
57#endif
58 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
59}
199 60
200static const char *emev2_boards_compat_dt[] __initdata = { 61static const char *emev2_boards_compat_dt[] __initdata = {
201 "renesas,emev2", 62 "renesas,emev2",
@@ -206,7 +67,7 @@ DT_MACHINE_START(EMEV2_DT, "Generic Emma Mobile EV2 (Flattened Device Tree)")
206 .smp = smp_ops(emev2_smp_ops), 67 .smp = smp_ops(emev2_smp_ops),
207 .map_io = emev2_map_io, 68 .map_io = emev2_map_io,
208 .init_early = emev2_init_delay, 69 .init_early = emev2_init_delay,
70 .init_machine = emev2_add_standard_devices_dt,
71 .init_late = shmobile_init_late,
209 .dt_compat = emev2_boards_compat_dt, 72 .dt_compat = emev2_boards_compat_dt,
210MACHINE_END 73MACHINE_END
211
212#endif /* CONFIG_USE_OF */
diff --git a/arch/arm/mach-shmobile/setup-r7s72100.c b/arch/arm/mach-shmobile/setup-r7s72100.c
index d4eb509a1c87..9c0b3a9d5f7a 100644
--- a/arch/arm/mach-shmobile/setup-r7s72100.c
+++ b/arch/arm/mach-shmobile/setup-r7s72100.c
@@ -22,52 +22,76 @@
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/of_platform.h> 23#include <linux/of_platform.h>
24#include <linux/serial_sci.h> 24#include <linux/serial_sci.h>
25#include <linux/sh_timer.h>
25#include <mach/common.h> 26#include <mach/common.h>
26#include <mach/irqs.h> 27#include <mach/irqs.h>
27#include <mach/r7s72100.h> 28#include <mach/r7s72100.h>
28#include <asm/mach/arch.h> 29#include <asm/mach/arch.h>
29 30
30#define SCIF_DATA(index, baseaddr, irq) \ 31#define R7S72100_SCIF(index, baseaddr, irq) \
31[index] = { \ 32static const struct plat_sci_port scif##index##_platform_data = { \
32 .type = PORT_SCIF, \ 33 .type = PORT_SCIF, \
33 .regtype = SCIx_SH2_SCIF_FIFODATA_REGTYPE, \ 34 .regtype = SCIx_SH2_SCIF_FIFODATA_REGTYPE, \
34 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \ 35 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \
35 .scbrr_algo_id = SCBRR_ALGO_2, \
36 .scscr = SCSCR_RIE | SCSCR_TIE | SCSCR_RE | SCSCR_TE | \ 36 .scscr = SCSCR_RIE | SCSCR_TIE | SCSCR_RE | SCSCR_TE | \
37 SCSCR_REIE, \ 37 SCSCR_REIE, \
38 .mapbase = baseaddr, \ 38}; \
39 .irqs = { irq + 1, irq + 2, irq + 3, irq }, \ 39 \
40} 40static struct resource scif##index##_resources[] = { \
41 DEFINE_RES_MEM(baseaddr, 0x100), \
42 DEFINE_RES_IRQ(irq + 1), \
43 DEFINE_RES_IRQ(irq + 2), \
44 DEFINE_RES_IRQ(irq + 3), \
45 DEFINE_RES_IRQ(irq), \
46} \
47
48R7S72100_SCIF(0, 0xe8007000, gic_iid(221));
49R7S72100_SCIF(1, 0xe8007800, gic_iid(225));
50R7S72100_SCIF(2, 0xe8008000, gic_iid(229));
51R7S72100_SCIF(3, 0xe8008800, gic_iid(233));
52R7S72100_SCIF(4, 0xe8009000, gic_iid(237));
53R7S72100_SCIF(5, 0xe8009800, gic_iid(241));
54R7S72100_SCIF(6, 0xe800a000, gic_iid(245));
55R7S72100_SCIF(7, 0xe800a800, gic_iid(249));
41 56
42enum { SCIF0, SCIF1, SCIF2, SCIF3, SCIF4, SCIF5, SCIF6, SCIF7 }; 57#define r7s72100_register_scif(index) \
58 platform_device_register_resndata(&platform_bus, "sh-sci", index, \
59 scif##index##_resources, \
60 ARRAY_SIZE(scif##index##_resources), \
61 &scif##index##_platform_data, \
62 sizeof(scif##index##_platform_data))
43 63
44static const struct plat_sci_port scif[] __initconst = { 64
45 SCIF_DATA(SCIF0, 0xe8007000, gic_iid(221)), /* SCIF0 */ 65static struct sh_timer_config mtu2_0_platform_data __initdata = {
46 SCIF_DATA(SCIF1, 0xe8007800, gic_iid(225)), /* SCIF1 */ 66 .name = "MTU2_0",
47 SCIF_DATA(SCIF2, 0xe8008000, gic_iid(229)), /* SCIF2 */ 67 .timer_bit = 0,
48 SCIF_DATA(SCIF3, 0xe8008800, gic_iid(233)), /* SCIF3 */ 68 .channel_offset = -0x80,
49 SCIF_DATA(SCIF4, 0xe8009000, gic_iid(237)), /* SCIF4 */ 69 .clockevent_rating = 200,
50 SCIF_DATA(SCIF5, 0xe8009800, gic_iid(241)), /* SCIF5 */
51 SCIF_DATA(SCIF6, 0xe800a000, gic_iid(245)), /* SCIF6 */
52 SCIF_DATA(SCIF7, 0xe800a800, gic_iid(249)), /* SCIF7 */
53}; 70};
54 71
55static inline void r7s72100_register_scif(int idx) 72static struct resource mtu2_0_resources[] __initdata = {
56{ 73 DEFINE_RES_MEM(0xfcff0300, 0x27),
57 platform_device_register_data(&platform_bus, "sh-sci", idx, &scif[idx], 74 DEFINE_RES_IRQ(gic_iid(139)), /* MTU2 TGI0A */
58 sizeof(struct plat_sci_port)); 75};
59} 76
77#define r7s72100_register_mtu2(idx) \
78 platform_device_register_resndata(&platform_bus, "sh_mtu2", \
79 idx, mtu2_##idx##_resources, \
80 ARRAY_SIZE(mtu2_##idx##_resources), \
81 &mtu2_##idx##_platform_data, \
82 sizeof(struct sh_timer_config))
60 83
61void __init r7s72100_add_dt_devices(void) 84void __init r7s72100_add_dt_devices(void)
62{ 85{
63 r7s72100_register_scif(SCIF0); 86 r7s72100_register_scif(0);
64 r7s72100_register_scif(SCIF1); 87 r7s72100_register_scif(1);
65 r7s72100_register_scif(SCIF2); 88 r7s72100_register_scif(2);
66 r7s72100_register_scif(SCIF3); 89 r7s72100_register_scif(3);
67 r7s72100_register_scif(SCIF4); 90 r7s72100_register_scif(4);
68 r7s72100_register_scif(SCIF5); 91 r7s72100_register_scif(5);
69 r7s72100_register_scif(SCIF6); 92 r7s72100_register_scif(6);
70 r7s72100_register_scif(SCIF7); 93 r7s72100_register_scif(7);
94 r7s72100_register_mtu2(0);
71} 95}
72 96
73void __init r7s72100_init_early(void) 97void __init r7s72100_init_early(void)
diff --git a/arch/arm/mach-shmobile/setup-r8a73a4.c b/arch/arm/mach-shmobile/setup-r8a73a4.c
index b0f2749071be..cd36f8078325 100644
--- a/arch/arm/mach-shmobile/setup-r8a73a4.c
+++ b/arch/arm/mach-shmobile/setup-r8a73a4.c
@@ -40,41 +40,39 @@ void __init r8a73a4_pinmux_init(void)
40 ARRAY_SIZE(pfc_resources)); 40 ARRAY_SIZE(pfc_resources));
41} 41}
42 42
43#define SCIF_COMMON(scif_type, baseaddr, irq) \ 43#define R8A73A4_SCIF(scif_type, _scscr, index, baseaddr, irq) \
44static struct plat_sci_port scif##index##_platform_data = { \
44 .type = scif_type, \ 45 .type = scif_type, \
45 .mapbase = baseaddr, \
46 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \ 46 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \
47 .scbrr_algo_id = SCBRR_ALGO_4, \ 47 .scscr = _scscr, \
48 .irqs = SCIx_IRQ_MUXED(irq) 48}; \
49 49 \
50#define SCIFA_DATA(index, baseaddr, irq) \ 50static struct resource scif##index##_resources[] = { \
51[index] = { \ 51 DEFINE_RES_MEM(baseaddr, 0x100), \
52 SCIF_COMMON(PORT_SCIFA, baseaddr, irq), \ 52 DEFINE_RES_IRQ(irq), \
53 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE0, \
54} 53}
55 54
56#define SCIFB_DATA(index, baseaddr, irq) \ 55#define R8A73A4_SCIFA(index, baseaddr, irq) \
57[index] = { \ 56 R8A73A4_SCIF(PORT_SCIFA, SCSCR_RE | SCSCR_TE | SCSCR_CKE0, \
58 SCIF_COMMON(PORT_SCIFB, baseaddr, irq), \ 57 index, baseaddr, irq)
59 .scscr = SCSCR_RE | SCSCR_TE, \
60}
61 58
62enum { SCIFA0, SCIFA1, SCIFB0, SCIFB1, SCIFB2, SCIFB3 }; 59#define R8A73A4_SCIFB(index, baseaddr, irq) \
60 R8A73A4_SCIF(PORT_SCIFB, SCSCR_RE | SCSCR_TE, \
61 index, baseaddr, irq)
63 62
64static const struct plat_sci_port scif[] = { 63R8A73A4_SCIFA(0, 0xe6c40000, gic_spi(144)); /* SCIFA0 */
65 SCIFA_DATA(SCIFA0, 0xe6c40000, gic_spi(144)), /* SCIFA0 */ 64R8A73A4_SCIFA(1, 0xe6c50000, gic_spi(145)); /* SCIFA1 */
66 SCIFA_DATA(SCIFA1, 0xe6c50000, gic_spi(145)), /* SCIFA1 */ 65R8A73A4_SCIFB(2, 0xe6c20000, gic_spi(148)); /* SCIFB0 */
67 SCIFB_DATA(SCIFB0, 0xe6c20000, gic_spi(148)), /* SCIFB0 */ 66R8A73A4_SCIFB(3, 0xe6c30000, gic_spi(149)); /* SCIFB1 */
68 SCIFB_DATA(SCIFB1, 0xe6c30000, gic_spi(149)), /* SCIFB1 */ 67R8A73A4_SCIFB(4, 0xe6ce0000, gic_spi(150)); /* SCIFB2 */
69 SCIFB_DATA(SCIFB2, 0xe6ce0000, gic_spi(150)), /* SCIFB2 */ 68R8A73A4_SCIFB(5, 0xe6cf0000, gic_spi(151)); /* SCIFB3 */
70 SCIFB_DATA(SCIFB3, 0xe6cf0000, gic_spi(151)), /* SCIFB3 */
71};
72 69
73static inline void r8a73a4_register_scif(int idx) 70#define r8a73a4_register_scif(index) \
74{ 71 platform_device_register_resndata(&platform_bus, "sh-sci", index, \
75 platform_device_register_data(&platform_bus, "sh-sci", idx, &scif[idx], 72 scif##index##_resources, \
76 sizeof(struct plat_sci_port)); 73 ARRAY_SIZE(scif##index##_resources), \
77} 74 &scif##index##_platform_data, \
75 sizeof(scif##index##_platform_data))
78 76
79static const struct renesas_irqc_config irqc0_data = { 77static const struct renesas_irqc_config irqc0_data = {
80 .irq_base = irq_pin(0), /* IRQ0 -> IRQ31 */ 78 .irq_base = irq_pin(0), /* IRQ0 -> IRQ31 */
@@ -192,12 +190,12 @@ static struct resource cmt10_resources[] = {
192 190
193void __init r8a73a4_add_dt_devices(void) 191void __init r8a73a4_add_dt_devices(void)
194{ 192{
195 r8a73a4_register_scif(SCIFA0); 193 r8a73a4_register_scif(0);
196 r8a73a4_register_scif(SCIFA1); 194 r8a73a4_register_scif(1);
197 r8a73a4_register_scif(SCIFB0); 195 r8a73a4_register_scif(2);
198 r8a73a4_register_scif(SCIFB1); 196 r8a73a4_register_scif(3);
199 r8a73a4_register_scif(SCIFB2); 197 r8a73a4_register_scif(4);
200 r8a73a4_register_scif(SCIFB3); 198 r8a73a4_register_scif(5);
201 r8a7790_register_cmt(10); 199 r8a7790_register_cmt(10);
202} 200}
203 201
@@ -275,7 +273,7 @@ static const struct sh_dmae_pdata dma_pdata = {
275 273
276static struct resource dma_resources[] = { 274static struct resource dma_resources[] = {
277 DEFINE_RES_MEM(0xe6700020, 0x89e0), 275 DEFINE_RES_MEM(0xe6700020, 0x89e0),
278 DEFINE_RES_IRQ_NAMED(gic_spi(220), "error_irq"), 276 DEFINE_RES_IRQ(gic_spi(220)),
279 { 277 {
280 /* IRQ for channels 0-19 */ 278 /* IRQ for channels 0-19 */
281 .start = gic_spi(200), 279 .start = gic_spi(200),
diff --git a/arch/arm/mach-shmobile/setup-r8a7740.c b/arch/arm/mach-shmobile/setup-r8a7740.c
index b7d4b2c3bc29..8f3c68101d59 100644
--- a/arch/arm/mach-shmobile/setup-r8a7740.c
+++ b/arch/arm/mach-shmobile/setup-r8a7740.c
@@ -203,167 +203,38 @@ static struct platform_device irqpin3_device = {
203 }, 203 },
204}; 204};
205 205
206/* SCIFA0 */ 206/* SCIF */
207static struct plat_sci_port scif0_platform_data = { 207#define R8A7740_SCIF(scif_type, index, baseaddr, irq) \
208 .mapbase = 0xe6c40000, 208static struct plat_sci_port scif##index##_platform_data = { \
209 .flags = UPF_BOOT_AUTOCONF, 209 .type = scif_type, \
210 .scscr = SCSCR_RE | SCSCR_TE, 210 .flags = UPF_BOOT_AUTOCONF, \
211 .scbrr_algo_id = SCBRR_ALGO_4, 211 .scscr = SCSCR_RE | SCSCR_TE, \
212 .type = PORT_SCIFA, 212}; \
213 .irqs = SCIx_IRQ_MUXED(gic_spi(100)), 213 \
214}; 214static struct resource scif##index##_resources[] = { \
215 215 DEFINE_RES_MEM(baseaddr, 0x100), \
216static struct platform_device scif0_device = { 216 DEFINE_RES_IRQ(irq), \
217 .name = "sh-sci", 217}; \
218 .id = 0, 218 \
219 .dev = { 219static struct platform_device scif##index##_device = { \
220 .platform_data = &scif0_platform_data, 220 .name = "sh-sci", \
221 }, 221 .id = index, \
222}; 222 .resource = scif##index##_resources, \
223 223 .num_resources = ARRAY_SIZE(scif##index##_resources), \
224/* SCIFA1 */ 224 .dev = { \
225static struct plat_sci_port scif1_platform_data = { 225 .platform_data = &scif##index##_platform_data, \
226 .mapbase = 0xe6c50000, 226 }, \
227 .flags = UPF_BOOT_AUTOCONF, 227}
228 .scscr = SCSCR_RE | SCSCR_TE,
229 .scbrr_algo_id = SCBRR_ALGO_4,
230 .type = PORT_SCIFA,
231 .irqs = SCIx_IRQ_MUXED(gic_spi(101)),
232};
233
234static struct platform_device scif1_device = {
235 .name = "sh-sci",
236 .id = 1,
237 .dev = {
238 .platform_data = &scif1_platform_data,
239 },
240};
241
242/* SCIFA2 */
243static struct plat_sci_port scif2_platform_data = {
244 .mapbase = 0xe6c60000,
245 .flags = UPF_BOOT_AUTOCONF,
246 .scscr = SCSCR_RE | SCSCR_TE,
247 .scbrr_algo_id = SCBRR_ALGO_4,
248 .type = PORT_SCIFA,
249 .irqs = SCIx_IRQ_MUXED(gic_spi(102)),
250};
251
252static struct platform_device scif2_device = {
253 .name = "sh-sci",
254 .id = 2,
255 .dev = {
256 .platform_data = &scif2_platform_data,
257 },
258};
259
260/* SCIFA3 */
261static struct plat_sci_port scif3_platform_data = {
262 .mapbase = 0xe6c70000,
263 .flags = UPF_BOOT_AUTOCONF,
264 .scscr = SCSCR_RE | SCSCR_TE,
265 .scbrr_algo_id = SCBRR_ALGO_4,
266 .type = PORT_SCIFA,
267 .irqs = SCIx_IRQ_MUXED(gic_spi(103)),
268};
269
270static struct platform_device scif3_device = {
271 .name = "sh-sci",
272 .id = 3,
273 .dev = {
274 .platform_data = &scif3_platform_data,
275 },
276};
277
278/* SCIFA4 */
279static struct plat_sci_port scif4_platform_data = {
280 .mapbase = 0xe6c80000,
281 .flags = UPF_BOOT_AUTOCONF,
282 .scscr = SCSCR_RE | SCSCR_TE,
283 .scbrr_algo_id = SCBRR_ALGO_4,
284 .type = PORT_SCIFA,
285 .irqs = SCIx_IRQ_MUXED(gic_spi(104)),
286};
287
288static struct platform_device scif4_device = {
289 .name = "sh-sci",
290 .id = 4,
291 .dev = {
292 .platform_data = &scif4_platform_data,
293 },
294};
295
296/* SCIFA5 */
297static struct plat_sci_port scif5_platform_data = {
298 .mapbase = 0xe6cb0000,
299 .flags = UPF_BOOT_AUTOCONF,
300 .scscr = SCSCR_RE | SCSCR_TE,
301 .scbrr_algo_id = SCBRR_ALGO_4,
302 .type = PORT_SCIFA,
303 .irqs = SCIx_IRQ_MUXED(gic_spi(105)),
304};
305
306static struct platform_device scif5_device = {
307 .name = "sh-sci",
308 .id = 5,
309 .dev = {
310 .platform_data = &scif5_platform_data,
311 },
312};
313
314/* SCIFA6 */
315static struct plat_sci_port scif6_platform_data = {
316 .mapbase = 0xe6cc0000,
317 .flags = UPF_BOOT_AUTOCONF,
318 .scscr = SCSCR_RE | SCSCR_TE,
319 .scbrr_algo_id = SCBRR_ALGO_4,
320 .type = PORT_SCIFA,
321 .irqs = SCIx_IRQ_MUXED(gic_spi(106)),
322};
323
324static struct platform_device scif6_device = {
325 .name = "sh-sci",
326 .id = 6,
327 .dev = {
328 .platform_data = &scif6_platform_data,
329 },
330};
331
332/* SCIFA7 */
333static struct plat_sci_port scif7_platform_data = {
334 .mapbase = 0xe6cd0000,
335 .flags = UPF_BOOT_AUTOCONF,
336 .scscr = SCSCR_RE | SCSCR_TE,
337 .scbrr_algo_id = SCBRR_ALGO_4,
338 .type = PORT_SCIFA,
339 .irqs = SCIx_IRQ_MUXED(gic_spi(107)),
340};
341
342static struct platform_device scif7_device = {
343 .name = "sh-sci",
344 .id = 7,
345 .dev = {
346 .platform_data = &scif7_platform_data,
347 },
348};
349
350/* SCIFB */
351static struct plat_sci_port scifb_platform_data = {
352 .mapbase = 0xe6c30000,
353 .flags = UPF_BOOT_AUTOCONF,
354 .scscr = SCSCR_RE | SCSCR_TE,
355 .scbrr_algo_id = SCBRR_ALGO_4,
356 .type = PORT_SCIFB,
357 .irqs = SCIx_IRQ_MUXED(gic_spi(108)),
358};
359 228
360static struct platform_device scifb_device = { 229R8A7740_SCIF(PORT_SCIFA, 0, 0xe6c40000, gic_spi(100));
361 .name = "sh-sci", 230R8A7740_SCIF(PORT_SCIFA, 1, 0xe6c50000, gic_spi(101));
362 .id = 8, 231R8A7740_SCIF(PORT_SCIFA, 2, 0xe6c60000, gic_spi(102));
363 .dev = { 232R8A7740_SCIF(PORT_SCIFA, 3, 0xe6c70000, gic_spi(103));
364 .platform_data = &scifb_platform_data, 233R8A7740_SCIF(PORT_SCIFA, 4, 0xe6c80000, gic_spi(104));
365 }, 234R8A7740_SCIF(PORT_SCIFA, 5, 0xe6cb0000, gic_spi(105));
366}; 235R8A7740_SCIF(PORT_SCIFA, 6, 0xe6cc0000, gic_spi(106));
236R8A7740_SCIF(PORT_SCIFA, 7, 0xe6cd0000, gic_spi(107));
237R8A7740_SCIF(PORT_SCIFB, 8, 0xe6c30000, gic_spi(108));
367 238
368/* CMT */ 239/* CMT */
369static struct sh_timer_config cmt10_platform_data = { 240static struct sh_timer_config cmt10_platform_data = {
@@ -528,7 +399,7 @@ static struct platform_device *r8a7740_devices_dt[] __initdata = {
528 &scif5_device, 399 &scif5_device,
529 &scif6_device, 400 &scif6_device,
530 &scif7_device, 401 &scif7_device,
531 &scifb_device, 402 &scif8_device,
532 &cmt10_device, 403 &cmt10_device,
533}; 404};
534 405
@@ -981,7 +852,7 @@ void __init r8a7740_add_standard_devices(void)
981 rmobile_add_device_to_domain("A3SP", &scif5_device); 852 rmobile_add_device_to_domain("A3SP", &scif5_device);
982 rmobile_add_device_to_domain("A3SP", &scif6_device); 853 rmobile_add_device_to_domain("A3SP", &scif6_device);
983 rmobile_add_device_to_domain("A3SP", &scif7_device); 854 rmobile_add_device_to_domain("A3SP", &scif7_device);
984 rmobile_add_device_to_domain("A3SP", &scifb_device); 855 rmobile_add_device_to_domain("A3SP", &scif8_device);
985 rmobile_add_device_to_domain("A3SP", &i2c1_device); 856 rmobile_add_device_to_domain("A3SP", &i2c1_device);
986} 857}
987 858
diff --git a/arch/arm/mach-shmobile/setup-r8a7778.c b/arch/arm/mach-shmobile/setup-r8a7778.c
index 03fcc5974ef9..6d694526e4ca 100644
--- a/arch/arm/mach-shmobile/setup-r8a7778.c
+++ b/arch/arm/mach-shmobile/setup-r8a7778.c
@@ -44,24 +44,31 @@
44#include <asm/hardware/cache-l2x0.h> 44#include <asm/hardware/cache-l2x0.h>
45 45
46/* SCIF */ 46/* SCIF */
47#define SCIF_INFO(baseaddr, irq) \ 47#define R8A7778_SCIF(index, baseaddr, irq) \
48{ \ 48static struct plat_sci_port scif##index##_platform_data = { \
49 .mapbase = baseaddr, \
50 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \ 49 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \
51 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1, \ 50 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1, \
52 .scbrr_algo_id = SCBRR_ALGO_2, \
53 .type = PORT_SCIF, \ 51 .type = PORT_SCIF, \
54 .irqs = SCIx_IRQ_MUXED(irq), \ 52}; \
53 \
54static struct resource scif##index##_resources[] = { \
55 DEFINE_RES_MEM(baseaddr, 0x100), \
56 DEFINE_RES_IRQ(irq), \
55} 57}
56 58
57static struct plat_sci_port scif_platform_data[] __initdata = { 59R8A7778_SCIF(0, 0xffe40000, gic_iid(0x66));
58 SCIF_INFO(0xffe40000, gic_iid(0x66)), 60R8A7778_SCIF(1, 0xffe41000, gic_iid(0x67));
59 SCIF_INFO(0xffe41000, gic_iid(0x67)), 61R8A7778_SCIF(2, 0xffe42000, gic_iid(0x68));
60 SCIF_INFO(0xffe42000, gic_iid(0x68)), 62R8A7778_SCIF(3, 0xffe43000, gic_iid(0x69));
61 SCIF_INFO(0xffe43000, gic_iid(0x69)), 63R8A7778_SCIF(4, 0xffe44000, gic_iid(0x6a));
62 SCIF_INFO(0xffe44000, gic_iid(0x6a)), 64R8A7778_SCIF(5, 0xffe45000, gic_iid(0x6b));
63 SCIF_INFO(0xffe45000, gic_iid(0x6b)), 65
64}; 66#define r8a7778_register_scif(index) \
67 platform_device_register_resndata(&platform_bus, "sh-sci", index, \
68 scif##index##_resources, \
69 ARRAY_SIZE(scif##index##_resources), \
70 &scif##index##_platform_data, \
71 sizeof(scif##index##_platform_data))
65 72
66/* TMU */ 73/* TMU */
67static struct resource sh_tmu0_resources[] __initdata = { 74static struct resource sh_tmu0_resources[] __initdata = {
@@ -287,8 +294,6 @@ static void __init r8a7778_register_hspi(int id)
287 294
288void __init r8a7778_add_dt_devices(void) 295void __init r8a7778_add_dt_devices(void)
289{ 296{
290 int i;
291
292#ifdef CONFIG_CACHE_L2X0 297#ifdef CONFIG_CACHE_L2X0
293 void __iomem *base = ioremap_nocache(0xf0100000, 0x1000); 298 void __iomem *base = ioremap_nocache(0xf0100000, 0x1000);
294 if (base) { 299 if (base) {
@@ -300,11 +305,12 @@ void __init r8a7778_add_dt_devices(void)
300 } 305 }
301#endif 306#endif
302 307
303 for (i = 0; i < ARRAY_SIZE(scif_platform_data); i++) 308 r8a7778_register_scif(0);
304 platform_device_register_data(&platform_bus, "sh-sci", i, 309 r8a7778_register_scif(1);
305 &scif_platform_data[i], 310 r8a7778_register_scif(2);
306 sizeof(struct plat_sci_port)); 311 r8a7778_register_scif(3);
307 312 r8a7778_register_scif(4);
313 r8a7778_register_scif(5);
308 r8a7778_register_tmu(0); 314 r8a7778_register_tmu(0);
309 r8a7778_register_tmu(1); 315 r8a7778_register_tmu(1);
310} 316}
@@ -319,6 +325,52 @@ void __init r8a7778_add_dt_devices(void)
319#define HPB_DMAE_ASYNCMDR_ASMD21_SINGLE BIT(1) /* SDHI0 */ 325#define HPB_DMAE_ASYNCMDR_ASMD21_SINGLE BIT(1) /* SDHI0 */
320#define HPB_DMAE_ASYNCMDR_ASMD21_MULTI 0 /* SDHI0 */ 326#define HPB_DMAE_ASYNCMDR_ASMD21_MULTI 0 /* SDHI0 */
321 327
328#define HPBDMA_SSI(_id) \
329{ \
330 .id = HPBDMA_SLAVE_SSI## _id ##_TX, \
331 .addr = 0xffd91008 + (_id * 0x40), \
332 .dcr = HPB_DMAE_DCR_CT | \
333 HPB_DMAE_DCR_DIP | \
334 HPB_DMAE_DCR_SPDS_32BIT | \
335 HPB_DMAE_DCR_DMDL | \
336 HPB_DMAE_DCR_DPDS_32BIT, \
337 .port = _id + (_id << 8), \
338 .dma_ch = (28 + _id), \
339}, { \
340 .id = HPBDMA_SLAVE_SSI## _id ##_RX, \
341 .addr = 0xffd9100c + (_id * 0x40), \
342 .dcr = HPB_DMAE_DCR_CT | \
343 HPB_DMAE_DCR_DIP | \
344 HPB_DMAE_DCR_SMDL | \
345 HPB_DMAE_DCR_SPDS_32BIT | \
346 HPB_DMAE_DCR_DPDS_32BIT, \
347 .port = _id + (_id << 8), \
348 .dma_ch = (28 + _id), \
349}
350
351#define HPBDMA_HPBIF(_id) \
352{ \
353 .id = HPBDMA_SLAVE_HPBIF## _id ##_TX, \
354 .addr = 0xffda0000 + (_id * 0x1000), \
355 .dcr = HPB_DMAE_DCR_CT | \
356 HPB_DMAE_DCR_DIP | \
357 HPB_DMAE_DCR_SPDS_32BIT | \
358 HPB_DMAE_DCR_DMDL | \
359 HPB_DMAE_DCR_DPDS_32BIT, \
360 .port = 0x1111, \
361 .dma_ch = (28 + _id), \
362}, { \
363 .id = HPBDMA_SLAVE_HPBIF## _id ##_RX, \
364 .addr = 0xffda0000 + (_id * 0x1000), \
365 .dcr = HPB_DMAE_DCR_CT | \
366 HPB_DMAE_DCR_DIP | \
367 HPB_DMAE_DCR_SMDL | \
368 HPB_DMAE_DCR_SPDS_32BIT | \
369 HPB_DMAE_DCR_DPDS_32BIT, \
370 .port = 0x1111, \
371 .dma_ch = (28 + _id), \
372}
373
322static const struct hpb_dmae_slave_config hpb_dmae_slaves[] = { 374static const struct hpb_dmae_slave_config hpb_dmae_slaves[] = {
323 { 375 {
324 .id = HPBDMA_SLAVE_SDHI0_TX, 376 .id = HPBDMA_SLAVE_SDHI0_TX,
@@ -348,12 +400,86 @@ static const struct hpb_dmae_slave_config hpb_dmae_slaves[] = {
348 .port = 0x0D0C, 400 .port = 0x0D0C,
349 .flags = HPB_DMAE_SET_ASYNC_RESET | HPB_DMAE_SET_ASYNC_MODE, 401 .flags = HPB_DMAE_SET_ASYNC_RESET | HPB_DMAE_SET_ASYNC_MODE,
350 .dma_ch = 22, 402 .dma_ch = 22,
403 }, {
404 .id = HPBDMA_SLAVE_USBFUNC_TX, /* for D0 */
405 .addr = 0xffe60018,
406 .dcr = HPB_DMAE_DCR_SPDS_32BIT |
407 HPB_DMAE_DCR_DMDL |
408 HPB_DMAE_DCR_DPDS_32BIT,
409 .port = 0x0000,
410 .dma_ch = 14,
411 }, {
412 .id = HPBDMA_SLAVE_USBFUNC_RX, /* for D1 */
413 .addr = 0xffe6001c,
414 .dcr = HPB_DMAE_DCR_SMDL |
415 HPB_DMAE_DCR_SPDS_32BIT |
416 HPB_DMAE_DCR_DPDS_32BIT,
417 .port = 0x0101,
418 .dma_ch = 15,
351 }, 419 },
420
421 HPBDMA_SSI(0),
422 HPBDMA_SSI(1),
423 HPBDMA_SSI(2),
424 HPBDMA_SSI(3),
425 HPBDMA_SSI(4),
426 HPBDMA_SSI(5),
427 HPBDMA_SSI(6),
428 HPBDMA_SSI(7),
429 HPBDMA_SSI(8),
430
431 HPBDMA_HPBIF(0),
432 HPBDMA_HPBIF(1),
433 HPBDMA_HPBIF(2),
434 HPBDMA_HPBIF(3),
435 HPBDMA_HPBIF(4),
436 HPBDMA_HPBIF(5),
437 HPBDMA_HPBIF(6),
438 HPBDMA_HPBIF(7),
439 HPBDMA_HPBIF(8),
352}; 440};
353 441
354static const struct hpb_dmae_channel hpb_dmae_channels[] = { 442static const struct hpb_dmae_channel hpb_dmae_channels[] = {
443 HPB_DMAE_CHANNEL(0x7c, HPBDMA_SLAVE_USBFUNC_TX), /* ch. 14 */
444 HPB_DMAE_CHANNEL(0x7c, HPBDMA_SLAVE_USBFUNC_RX), /* ch. 15 */
355 HPB_DMAE_CHANNEL(0x7e, HPBDMA_SLAVE_SDHI0_TX), /* ch. 21 */ 445 HPB_DMAE_CHANNEL(0x7e, HPBDMA_SLAVE_SDHI0_TX), /* ch. 21 */
356 HPB_DMAE_CHANNEL(0x7e, HPBDMA_SLAVE_SDHI0_RX), /* ch. 22 */ 446 HPB_DMAE_CHANNEL(0x7e, HPBDMA_SLAVE_SDHI0_RX), /* ch. 22 */
447 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI0_TX), /* ch. 28 */
448 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI0_RX), /* ch. 28 */
449 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF0_TX), /* ch. 28 */
450 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF0_RX), /* ch. 28 */
451 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI1_TX), /* ch. 29 */
452 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI1_RX), /* ch. 29 */
453 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF1_TX), /* ch. 29 */
454 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF1_RX), /* ch. 29 */
455 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI2_TX), /* ch. 30 */
456 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI2_RX), /* ch. 30 */
457 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF2_TX), /* ch. 30 */
458 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF2_RX), /* ch. 30 */
459 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI3_TX), /* ch. 31 */
460 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI3_RX), /* ch. 31 */
461 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF3_TX), /* ch. 31 */
462 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF3_RX), /* ch. 31 */
463 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI4_TX), /* ch. 32 */
464 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI4_RX), /* ch. 32 */
465 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF4_TX), /* ch. 32 */
466 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF4_RX), /* ch. 32 */
467 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI5_TX), /* ch. 33 */
468 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI5_RX), /* ch. 33 */
469 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF5_TX), /* ch. 33 */
470 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF5_RX), /* ch. 33 */
471 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI6_TX), /* ch. 34 */
472 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI6_RX), /* ch. 34 */
473 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF6_TX), /* ch. 34 */
474 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF6_RX), /* ch. 34 */
475 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI7_TX), /* ch. 35 */
476 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI7_RX), /* ch. 35 */
477 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF7_TX), /* ch. 35 */
478 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF7_RX), /* ch. 35 */
479 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI8_TX), /* ch. 36 */
480 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_SSI8_RX), /* ch. 36 */
481 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF8_TX), /* ch. 36 */
482 HPB_DMAE_CHANNEL(0x7f, HPBDMA_SLAVE_HPBIF8_RX), /* ch. 36 */
357}; 483};
358 484
359static struct hpb_dmae_pdata dma_platform_data __initdata = { 485static struct hpb_dmae_pdata dma_platform_data __initdata = {
diff --git a/arch/arm/mach-shmobile/setup-r8a7779.c b/arch/arm/mach-shmobile/setup-r8a7779.c
index 13049e9d691c..339292e85838 100644
--- a/arch/arm/mach-shmobile/setup-r8a7779.c
+++ b/arch/arm/mach-shmobile/setup-r8a7779.c
@@ -188,107 +188,35 @@ void __init r8a7779_pinmux_init(void)
188 ARRAY_SIZE(r8a7779_pinctrl_devices)); 188 ARRAY_SIZE(r8a7779_pinctrl_devices));
189} 189}
190 190
191static struct plat_sci_port scif0_platform_data = { 191/* SCIF */
192 .mapbase = 0xffe40000, 192#define R8A7779_SCIF(index, baseaddr, irq) \
193 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, 193static struct plat_sci_port scif##index##_platform_data = { \
194 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1, 194 .type = PORT_SCIF, \
195 .scbrr_algo_id = SCBRR_ALGO_2, 195 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \
196 .type = PORT_SCIF, 196 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1, \
197 .irqs = SCIx_IRQ_MUXED(gic_iid(0x78)), 197}; \
198}; 198 \
199 199static struct resource scif##index##_resources[] = { \
200static struct platform_device scif0_device = { 200 DEFINE_RES_MEM(baseaddr, 0x100), \
201 .name = "sh-sci", 201 DEFINE_RES_IRQ(irq), \
202 .id = 0, 202}; \
203 .dev = { 203 \
204 .platform_data = &scif0_platform_data, 204static struct platform_device scif##index##_device = { \
205 }, 205 .name = "sh-sci", \
206}; 206 .id = index, \
207 207 .resource = scif##index##_resources, \
208static struct plat_sci_port scif1_platform_data = { 208 .num_resources = ARRAY_SIZE(scif##index##_resources), \
209 .mapbase = 0xffe41000, 209 .dev = { \
210 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, 210 .platform_data = &scif##index##_platform_data, \
211 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1, 211 }, \
212 .scbrr_algo_id = SCBRR_ALGO_2, 212}
213 .type = PORT_SCIF,
214 .irqs = SCIx_IRQ_MUXED(gic_iid(0x79)),
215};
216
217static struct platform_device scif1_device = {
218 .name = "sh-sci",
219 .id = 1,
220 .dev = {
221 .platform_data = &scif1_platform_data,
222 },
223};
224
225static struct plat_sci_port scif2_platform_data = {
226 .mapbase = 0xffe42000,
227 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
228 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
229 .scbrr_algo_id = SCBRR_ALGO_2,
230 .type = PORT_SCIF,
231 .irqs = SCIx_IRQ_MUXED(gic_iid(0x7a)),
232};
233
234static struct platform_device scif2_device = {
235 .name = "sh-sci",
236 .id = 2,
237 .dev = {
238 .platform_data = &scif2_platform_data,
239 },
240};
241
242static struct plat_sci_port scif3_platform_data = {
243 .mapbase = 0xffe43000,
244 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
245 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
246 .scbrr_algo_id = SCBRR_ALGO_2,
247 .type = PORT_SCIF,
248 .irqs = SCIx_IRQ_MUXED(gic_iid(0x7b)),
249};
250
251static struct platform_device scif3_device = {
252 .name = "sh-sci",
253 .id = 3,
254 .dev = {
255 .platform_data = &scif3_platform_data,
256 },
257};
258
259static struct plat_sci_port scif4_platform_data = {
260 .mapbase = 0xffe44000,
261 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
262 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
263 .scbrr_algo_id = SCBRR_ALGO_2,
264 .type = PORT_SCIF,
265 .irqs = SCIx_IRQ_MUXED(gic_iid(0x7c)),
266};
267
268static struct platform_device scif4_device = {
269 .name = "sh-sci",
270 .id = 4,
271 .dev = {
272 .platform_data = &scif4_platform_data,
273 },
274};
275
276static struct plat_sci_port scif5_platform_data = {
277 .mapbase = 0xffe45000,
278 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
279 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE1,
280 .scbrr_algo_id = SCBRR_ALGO_2,
281 .type = PORT_SCIF,
282 .irqs = SCIx_IRQ_MUXED(gic_iid(0x7d)),
283};
284 213
285static struct platform_device scif5_device = { 214R8A7779_SCIF(0, 0xffe40000, gic_iid(0x78));
286 .name = "sh-sci", 215R8A7779_SCIF(1, 0xffe41000, gic_iid(0x79));
287 .id = 5, 216R8A7779_SCIF(2, 0xffe42000, gic_iid(0x7a));
288 .dev = { 217R8A7779_SCIF(3, 0xffe43000, gic_iid(0x7b));
289 .platform_data = &scif5_platform_data, 218R8A7779_SCIF(4, 0xffe44000, gic_iid(0x7c));
290 }, 219R8A7779_SCIF(5, 0xffe45000, gic_iid(0x7d));
291};
292 220
293/* TMU */ 221/* TMU */
294static struct sh_timer_config tmu00_platform_data = { 222static struct sh_timer_config tmu00_platform_data = {
diff --git a/arch/arm/mach-shmobile/setup-r8a7790.c b/arch/arm/mach-shmobile/setup-r8a7790.c
index c47bcebbcb00..66476d21544d 100644
--- a/arch/arm/mach-shmobile/setup-r8a7790.c
+++ b/arch/arm/mach-shmobile/setup-r8a7790.c
@@ -63,6 +63,27 @@ R8A7790_GPIO(5);
63 &r8a7790_gpio##idx##_platform_data, \ 63 &r8a7790_gpio##idx##_platform_data, \
64 sizeof(r8a7790_gpio##idx##_platform_data)) 64 sizeof(r8a7790_gpio##idx##_platform_data))
65 65
66static struct resource i2c_resources[] __initdata = {
67 /* I2C0 */
68 DEFINE_RES_MEM(0xE6508000, 0x40),
69 DEFINE_RES_IRQ(gic_spi(287)),
70 /* I2C1 */
71 DEFINE_RES_MEM(0xE6518000, 0x40),
72 DEFINE_RES_IRQ(gic_spi(288)),
73 /* I2C2 */
74 DEFINE_RES_MEM(0xE6530000, 0x40),
75 DEFINE_RES_IRQ(gic_spi(286)),
76 /* I2C3 */
77 DEFINE_RES_MEM(0xE6540000, 0x40),
78 DEFINE_RES_IRQ(gic_spi(290)),
79
80};
81
82#define r8a7790_register_i2c(idx) \
83 platform_device_register_simple( \
84 "i2c-rcar", idx, \
85 i2c_resources + (2 * idx), 2); \
86
66void __init r8a7790_pinmux_init(void) 87void __init r8a7790_pinmux_init(void)
67{ 88{
68 platform_device_register_simple("pfc-r8a7790", -1, pfc_resources, 89 platform_device_register_simple("pfc-r8a7790", -1, pfc_resources,
@@ -73,63 +94,57 @@ void __init r8a7790_pinmux_init(void)
73 r8a7790_register_gpio(3); 94 r8a7790_register_gpio(3);
74 r8a7790_register_gpio(4); 95 r8a7790_register_gpio(4);
75 r8a7790_register_gpio(5); 96 r8a7790_register_gpio(5);
97 r8a7790_register_i2c(0);
98 r8a7790_register_i2c(1);
99 r8a7790_register_i2c(2);
100 r8a7790_register_i2c(3);
76} 101}
77 102
78#define SCIF_COMMON(scif_type, baseaddr, irq) \ 103#define __R8A7790_SCIF(scif_type, _scscr, index, baseaddr, irq) \
79 .type = scif_type, \ 104static struct plat_sci_port scif##index##_platform_data = { \
80 .mapbase = baseaddr, \ 105 .type = scif_type, \
81 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \ 106 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \
82 .irqs = SCIx_IRQ_MUXED(irq) 107 .scscr = _scscr, \
83 108}; \
84#define SCIFA_DATA(index, baseaddr, irq) \ 109 \
85[index] = { \ 110static struct resource scif##index##_resources[] = { \
86 SCIF_COMMON(PORT_SCIFA, baseaddr, irq), \ 111 DEFINE_RES_MEM(baseaddr, 0x100), \
87 .scbrr_algo_id = SCBRR_ALGO_4, \ 112 DEFINE_RES_IRQ(irq), \
88 .scscr = SCSCR_RE | SCSCR_TE | SCSCR_CKE0, \
89}
90
91#define SCIFB_DATA(index, baseaddr, irq) \
92[index] = { \
93 SCIF_COMMON(PORT_SCIFB, baseaddr, irq), \
94 .scbrr_algo_id = SCBRR_ALGO_4, \
95 .scscr = SCSCR_RE | SCSCR_TE, \
96}
97
98#define SCIF_DATA(index, baseaddr, irq) \
99[index] = { \
100 SCIF_COMMON(PORT_SCIF, baseaddr, irq), \
101 .scbrr_algo_id = SCBRR_ALGO_2, \
102 .scscr = SCSCR_RE | SCSCR_TE, \
103}
104
105#define HSCIF_DATA(index, baseaddr, irq) \
106[index] = { \
107 SCIF_COMMON(PORT_HSCIF, baseaddr, irq), \
108 .scbrr_algo_id = SCBRR_ALGO_6, \
109 .scscr = SCSCR_RE | SCSCR_TE, \
110} 113}
111 114
112enum { SCIFA0, SCIFA1, SCIFB0, SCIFB1, SCIFB2, SCIFA2, SCIF0, SCIF1, 115#define R8A7790_SCIF(index, baseaddr, irq) \
113 HSCIF0, HSCIF1 }; 116 __R8A7790_SCIF(PORT_SCIF, SCSCR_RE | SCSCR_TE, \
114 117 index, baseaddr, irq)
115static const struct plat_sci_port scif[] __initconst = { 118
116 SCIFA_DATA(SCIFA0, 0xe6c40000, gic_spi(144)), /* SCIFA0 */ 119#define R8A7790_SCIFA(index, baseaddr, irq) \
117 SCIFA_DATA(SCIFA1, 0xe6c50000, gic_spi(145)), /* SCIFA1 */ 120 __R8A7790_SCIF(PORT_SCIFA, SCSCR_RE | SCSCR_TE | SCSCR_CKE0, \
118 SCIFB_DATA(SCIFB0, 0xe6c20000, gic_spi(148)), /* SCIFB0 */ 121 index, baseaddr, irq)
119 SCIFB_DATA(SCIFB1, 0xe6c30000, gic_spi(149)), /* SCIFB1 */ 122
120 SCIFB_DATA(SCIFB2, 0xe6ce0000, gic_spi(150)), /* SCIFB2 */ 123#define R8A7790_SCIFB(index, baseaddr, irq) \
121 SCIFA_DATA(SCIFA2, 0xe6c60000, gic_spi(151)), /* SCIFA2 */ 124 __R8A7790_SCIF(PORT_SCIFB, SCSCR_RE | SCSCR_TE, \
122 SCIF_DATA(SCIF0, 0xe6e60000, gic_spi(152)), /* SCIF0 */ 125 index, baseaddr, irq)
123 SCIF_DATA(SCIF1, 0xe6e68000, gic_spi(153)), /* SCIF1 */ 126
124 HSCIF_DATA(HSCIF0, 0xe62c0000, gic_spi(154)), /* HSCIF0 */ 127#define R8A7790_HSCIF(index, baseaddr, irq) \
125 HSCIF_DATA(HSCIF1, 0xe62c8000, gic_spi(155)), /* HSCIF1 */ 128 __R8A7790_SCIF(PORT_HSCIF, SCSCR_RE | SCSCR_TE, \
126}; 129 index, baseaddr, irq)
127 130
128static inline void r8a7790_register_scif(int idx) 131R8A7790_SCIFA(0, 0xe6c40000, gic_spi(144)); /* SCIFA0 */
129{ 132R8A7790_SCIFA(1, 0xe6c50000, gic_spi(145)); /* SCIFA1 */
130 platform_device_register_data(&platform_bus, "sh-sci", idx, &scif[idx], 133R8A7790_SCIFB(2, 0xe6c20000, gic_spi(148)); /* SCIFB0 */
131 sizeof(struct plat_sci_port)); 134R8A7790_SCIFB(3, 0xe6c30000, gic_spi(149)); /* SCIFB1 */
132} 135R8A7790_SCIFB(4, 0xe6ce0000, gic_spi(150)); /* SCIFB2 */
136R8A7790_SCIFA(5, 0xe6c60000, gic_spi(151)); /* SCIFA2 */
137R8A7790_SCIF(6, 0xe6e60000, gic_spi(152)); /* SCIF0 */
138R8A7790_SCIF(7, 0xe6e68000, gic_spi(153)); /* SCIF1 */
139R8A7790_HSCIF(8, 0xe62c0000, gic_spi(154)); /* HSCIF0 */
140R8A7790_HSCIF(9, 0xe62c8000, gic_spi(155)); /* HSCIF1 */
141
142#define r8a7790_register_scif(index) \
143 platform_device_register_resndata(&platform_bus, "sh-sci", index, \
144 scif##index##_resources, \
145 ARRAY_SIZE(scif##index##_resources), \
146 &scif##index##_platform_data, \
147 sizeof(scif##index##_platform_data))
133 148
134static const struct renesas_irqc_config irqc0_data __initconst = { 149static const struct renesas_irqc_config irqc0_data __initconst = {
135 .irq_base = irq_pin(0), /* IRQ0 -> IRQ3 */ 150 .irq_base = irq_pin(0), /* IRQ0 -> IRQ3 */
@@ -182,16 +197,16 @@ static const struct resource cmt00_resources[] __initconst = {
182 197
183void __init r8a7790_add_dt_devices(void) 198void __init r8a7790_add_dt_devices(void)
184{ 199{
185 r8a7790_register_scif(SCIFA0); 200 r8a7790_register_scif(0);
186 r8a7790_register_scif(SCIFA1); 201 r8a7790_register_scif(1);
187 r8a7790_register_scif(SCIFB0); 202 r8a7790_register_scif(2);
188 r8a7790_register_scif(SCIFB1); 203 r8a7790_register_scif(3);
189 r8a7790_register_scif(SCIFB2); 204 r8a7790_register_scif(4);
190 r8a7790_register_scif(SCIFA2); 205 r8a7790_register_scif(5);
191 r8a7790_register_scif(SCIF0); 206 r8a7790_register_scif(6);
192 r8a7790_register_scif(SCIF1); 207 r8a7790_register_scif(7);
193 r8a7790_register_scif(HSCIF0); 208 r8a7790_register_scif(8);
194 r8a7790_register_scif(HSCIF1); 209 r8a7790_register_scif(9);
195 r8a7790_register_cmt(00); 210 r8a7790_register_cmt(00);
196} 211}
197 212
diff --git a/arch/arm/mach-shmobile/setup-r8a7791.c b/arch/arm/mach-shmobile/setup-r8a7791.c
index d9393d61ee27..e28404e43860 100644
--- a/arch/arm/mach-shmobile/setup-r8a7791.c
+++ b/arch/arm/mach-shmobile/setup-r8a7791.c
@@ -22,6 +22,7 @@
22#include <linux/irq.h> 22#include <linux/irq.h>
23#include <linux/kernel.h> 23#include <linux/kernel.h>
24#include <linux/of_platform.h> 24#include <linux/of_platform.h>
25#include <linux/platform_data/gpio-rcar.h>
25#include <linux/platform_data/irq-renesas-irqc.h> 26#include <linux/platform_data/irq-renesas-irqc.h>
26#include <linux/serial_sci.h> 27#include <linux/serial_sci.h>
27#include <linux/sh_timer.h> 28#include <linux/sh_timer.h>
@@ -31,66 +32,101 @@
31#include <mach/rcar-gen2.h> 32#include <mach/rcar-gen2.h>
32#include <asm/mach/arch.h> 33#include <asm/mach/arch.h>
33 34
34#define SCIF_COMMON(scif_type, baseaddr, irq) \ 35static const struct resource pfc_resources[] __initconst = {
35 .type = scif_type, \ 36 DEFINE_RES_MEM(0xe6060000, 0x250),
36 .mapbase = baseaddr, \ 37};
37 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \
38 .irqs = SCIx_IRQ_MUXED(irq)
39
40#define SCIFA_DATA(index, baseaddr, irq) \
41[index] = { \
42 SCIF_COMMON(PORT_SCIFA, baseaddr, irq), \
43 .scbrr_algo_id = SCBRR_ALGO_4, \
44 .scscr = SCSCR_RE | SCSCR_TE, \
45}
46
47#define SCIFB_DATA(index, baseaddr, irq) \
48[index] = { \
49 SCIF_COMMON(PORT_SCIFB, baseaddr, irq), \
50 .scbrr_algo_id = SCBRR_ALGO_4, \
51 .scscr = SCSCR_RE | SCSCR_TE, \
52}
53 38
54#define SCIF_DATA(index, baseaddr, irq) \ 39#define r8a7791_register_pfc() \
55[index] = { \ 40 platform_device_register_simple("pfc-r8a7791", -1, pfc_resources, \
56 SCIF_COMMON(PORT_SCIF, baseaddr, irq), \ 41 ARRAY_SIZE(pfc_resources))
57 .scbrr_algo_id = SCBRR_ALGO_2, \ 42
58 .scscr = SCSCR_RE | SCSCR_TE, \ 43#define R8A7791_GPIO(idx, base, nr) \
44static const struct resource r8a7791_gpio##idx##_resources[] __initconst = { \
45 DEFINE_RES_MEM((base), 0x50), \
46 DEFINE_RES_IRQ(gic_spi(4 + (idx))), \
47}; \
48 \
49static const struct gpio_rcar_config \
50r8a7791_gpio##idx##_platform_data __initconst = { \
51 .gpio_base = 32 * (idx), \
52 .irq_base = 0, \
53 .number_of_pins = (nr), \
54 .pctl_name = "pfc-r8a7791", \
55 .has_both_edge_trigger = 1, \
56}; \
57
58R8A7791_GPIO(0, 0xe6050000, 32);
59R8A7791_GPIO(1, 0xe6051000, 32);
60R8A7791_GPIO(2, 0xe6052000, 32);
61R8A7791_GPIO(3, 0xe6053000, 32);
62R8A7791_GPIO(4, 0xe6054000, 32);
63R8A7791_GPIO(5, 0xe6055000, 32);
64R8A7791_GPIO(6, 0xe6055400, 32);
65R8A7791_GPIO(7, 0xe6055800, 26);
66
67#define r8a7791_register_gpio(idx) \
68 platform_device_register_resndata(&platform_bus, "gpio_rcar", idx, \
69 r8a7791_gpio##idx##_resources, \
70 ARRAY_SIZE(r8a7791_gpio##idx##_resources), \
71 &r8a7791_gpio##idx##_platform_data, \
72 sizeof(r8a7791_gpio##idx##_platform_data))
73
74void __init r8a7791_pinmux_init(void)
75{
76 r8a7791_register_pfc();
77 r8a7791_register_gpio(0);
78 r8a7791_register_gpio(1);
79 r8a7791_register_gpio(2);
80 r8a7791_register_gpio(3);
81 r8a7791_register_gpio(4);
82 r8a7791_register_gpio(5);
83 r8a7791_register_gpio(6);
84 r8a7791_register_gpio(7);
59} 85}
60 86
61#define HSCIF_DATA(index, baseaddr, irq) \ 87#define __R8A7791_SCIF(scif_type, index, baseaddr, irq) \
62[index] = { \ 88static struct plat_sci_port scif##index##_platform_data = { \
63 SCIF_COMMON(PORT_HSCIF, baseaddr, irq), \ 89 .type = scif_type, \
64 .scbrr_algo_id = SCBRR_ALGO_6, \ 90 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \
65 .scscr = SCSCR_RE | SCSCR_TE, \ 91 .scscr = SCSCR_RE | SCSCR_TE, \
92}; \
93 \
94static struct resource scif##index##_resources[] = { \
95 DEFINE_RES_MEM(baseaddr, 0x100), \
96 DEFINE_RES_IRQ(irq), \
66} 97}
67 98
68enum { SCIFA0, SCIFA1, SCIFB0, SCIFB1, SCIFB2, SCIFA2, SCIF0, SCIF1, 99#define R8A7791_SCIF(index, baseaddr, irq) \
69 SCIF2, SCIF3, SCIF4, SCIF5, SCIFA3, SCIFA4, SCIFA5 }; 100 __R8A7791_SCIF(PORT_SCIF, index, baseaddr, irq)
70 101
71static const struct plat_sci_port scif[] __initconst = { 102#define R8A7791_SCIFA(index, baseaddr, irq) \
72 SCIFA_DATA(SCIFA0, 0xe6c40000, gic_spi(144)), /* SCIFA0 */ 103 __R8A7791_SCIF(PORT_SCIFA, index, baseaddr, irq)
73 SCIFA_DATA(SCIFA1, 0xe6c50000, gic_spi(145)), /* SCIFA1 */ 104
74 SCIFB_DATA(SCIFB0, 0xe6c20000, gic_spi(148)), /* SCIFB0 */ 105#define R8A7791_SCIFB(index, baseaddr, irq) \
75 SCIFB_DATA(SCIFB1, 0xe6c30000, gic_spi(149)), /* SCIFB1 */ 106 __R8A7791_SCIF(PORT_SCIFB, index, baseaddr, irq)
76 SCIFB_DATA(SCIFB2, 0xe6ce0000, gic_spi(150)), /* SCIFB2 */ 107
77 SCIFA_DATA(SCIFA2, 0xe6c60000, gic_spi(151)), /* SCIFA2 */ 108R8A7791_SCIFA(0, 0xe6c40000, gic_spi(144)); /* SCIFA0 */
78 SCIF_DATA(SCIF0, 0xe6e60000, gic_spi(152)), /* SCIF0 */ 109R8A7791_SCIFA(1, 0xe6c50000, gic_spi(145)); /* SCIFA1 */
79 SCIF_DATA(SCIF1, 0xe6e68000, gic_spi(153)), /* SCIF1 */ 110R8A7791_SCIFB(2, 0xe6c20000, gic_spi(148)); /* SCIFB0 */
80 SCIF_DATA(SCIF2, 0xe6e58000, gic_spi(22)), /* SCIF2 */ 111R8A7791_SCIFB(3, 0xe6c30000, gic_spi(149)); /* SCIFB1 */
81 SCIF_DATA(SCIF3, 0xe6ea8000, gic_spi(23)), /* SCIF3 */ 112R8A7791_SCIFB(4, 0xe6ce0000, gic_spi(150)); /* SCIFB2 */
82 SCIF_DATA(SCIF4, 0xe6ee0000, gic_spi(24)), /* SCIF4 */ 113R8A7791_SCIFA(5, 0xe6c60000, gic_spi(151)); /* SCIFA2 */
83 SCIF_DATA(SCIF5, 0xe6ee8000, gic_spi(25)), /* SCIF5 */ 114R8A7791_SCIF(6, 0xe6e60000, gic_spi(152)); /* SCIF0 */
84 SCIFA_DATA(SCIFA3, 0xe6c70000, gic_spi(29)), /* SCIFA3 */ 115R8A7791_SCIF(7, 0xe6e68000, gic_spi(153)); /* SCIF1 */
85 SCIFA_DATA(SCIFA4, 0xe6c78000, gic_spi(30)), /* SCIFA4 */ 116R8A7791_SCIF(8, 0xe6e58000, gic_spi(22)); /* SCIF2 */
86 SCIFA_DATA(SCIFA5, 0xe6c80000, gic_spi(31)), /* SCIFA5 */ 117R8A7791_SCIF(9, 0xe6ea8000, gic_spi(23)); /* SCIF3 */
87}; 118R8A7791_SCIF(10, 0xe6ee0000, gic_spi(24)); /* SCIF4 */
88 119R8A7791_SCIF(11, 0xe6ee8000, gic_spi(25)); /* SCIF5 */
89static inline void r8a7791_register_scif(int idx) 120R8A7791_SCIFA(12, 0xe6c70000, gic_spi(29)); /* SCIFA3 */
90{ 121R8A7791_SCIFA(13, 0xe6c78000, gic_spi(30)); /* SCIFA4 */
91 platform_device_register_data(&platform_bus, "sh-sci", idx, &scif[idx], 122R8A7791_SCIFA(14, 0xe6c80000, gic_spi(31)); /* SCIFA5 */
92 sizeof(struct plat_sci_port)); 123
93} 124#define r8a7791_register_scif(index) \
125 platform_device_register_resndata(&platform_bus, "sh-sci", index, \
126 scif##index##_resources, \
127 ARRAY_SIZE(scif##index##_resources), \
128 &scif##index##_platform_data, \
129 sizeof(scif##index##_platform_data))
94 130
95static const struct sh_timer_config cmt00_platform_data __initconst = { 131static const struct sh_timer_config cmt00_platform_data __initconst = {
96 .name = "CMT00", 132 .name = "CMT00",
@@ -136,23 +172,34 @@ static struct resource irqc0_resources[] = {
136 &irqc##idx##_data, \ 172 &irqc##idx##_data, \
137 sizeof(struct renesas_irqc_config)) 173 sizeof(struct renesas_irqc_config))
138 174
175static const struct resource thermal_resources[] __initconst = {
176 DEFINE_RES_MEM(0xe61f0000, 0x14),
177 DEFINE_RES_MEM(0xe61f0100, 0x38),
178 DEFINE_RES_IRQ(gic_spi(69)),
179};
180
181#define r8a7791_register_thermal() \
182 platform_device_register_simple("rcar_thermal", -1, \
183 thermal_resources, \
184 ARRAY_SIZE(thermal_resources))
185
139void __init r8a7791_add_dt_devices(void) 186void __init r8a7791_add_dt_devices(void)
140{ 187{
141 r8a7791_register_scif(SCIFA0); 188 r8a7791_register_scif(0);
142 r8a7791_register_scif(SCIFA1); 189 r8a7791_register_scif(1);
143 r8a7791_register_scif(SCIFB0); 190 r8a7791_register_scif(2);
144 r8a7791_register_scif(SCIFB1); 191 r8a7791_register_scif(3);
145 r8a7791_register_scif(SCIFB2); 192 r8a7791_register_scif(4);
146 r8a7791_register_scif(SCIFA2); 193 r8a7791_register_scif(5);
147 r8a7791_register_scif(SCIF0); 194 r8a7791_register_scif(6);
148 r8a7791_register_scif(SCIF1); 195 r8a7791_register_scif(7);
149 r8a7791_register_scif(SCIF2); 196 r8a7791_register_scif(8);
150 r8a7791_register_scif(SCIF3); 197 r8a7791_register_scif(9);
151 r8a7791_register_scif(SCIF4); 198 r8a7791_register_scif(10);
152 r8a7791_register_scif(SCIF5); 199 r8a7791_register_scif(11);
153 r8a7791_register_scif(SCIFA3); 200 r8a7791_register_scif(12);
154 r8a7791_register_scif(SCIFA4); 201 r8a7791_register_scif(13);
155 r8a7791_register_scif(SCIFA5); 202 r8a7791_register_scif(14);
156 r8a7791_register_cmt(00); 203 r8a7791_register_cmt(00);
157} 204}
158 205
@@ -160,6 +207,7 @@ void __init r8a7791_add_standard_devices(void)
160{ 207{
161 r8a7791_add_dt_devices(); 208 r8a7791_add_dt_devices();
162 r8a7791_register_irqc(0); 209 r8a7791_register_irqc(0);
210 r8a7791_register_thermal();
163} 211}
164 212
165void __init r8a7791_init_early(void) 213void __init r8a7791_init_early(void)
diff --git a/arch/arm/mach-shmobile/setup-rcar-gen2.c b/arch/arm/mach-shmobile/setup-rcar-gen2.c
index 5734c24bf6c7..69ccc6c6fd33 100644
--- a/arch/arm/mach-shmobile/setup-rcar-gen2.c
+++ b/arch/arm/mach-shmobile/setup-rcar-gen2.c
@@ -18,6 +18,7 @@
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */ 19 */
20 20
21#include <linux/clk/shmobile.h>
21#include <linux/clocksource.h> 22#include <linux/clocksource.h>
22#include <linux/io.h> 23#include <linux/io.h>
23#include <linux/kernel.h> 24#include <linux/kernel.h>
@@ -44,8 +45,10 @@ u32 __init rcar_gen2_read_mode_pins(void)
44 45
45void __init rcar_gen2_timer_init(void) 46void __init rcar_gen2_timer_init(void)
46{ 47{
47#ifdef CONFIG_ARM_ARCH_TIMER 48#if defined(CONFIG_ARM_ARCH_TIMER) || defined(CONFIG_COMMON_CLK)
48 u32 mode = rcar_gen2_read_mode_pins(); 49 u32 mode = rcar_gen2_read_mode_pins();
50#endif
51#ifdef CONFIG_ARM_ARCH_TIMER
49 void __iomem *base; 52 void __iomem *base;
50 int extal_mhz = 0; 53 int extal_mhz = 0;
51 u32 freq; 54 u32 freq;
@@ -78,14 +81,28 @@ void __init rcar_gen2_timer_init(void)
78 /* Remap "armgcnt address map" space */ 81 /* Remap "armgcnt address map" space */
79 base = ioremap(0xe6080000, PAGE_SIZE); 82 base = ioremap(0xe6080000, PAGE_SIZE);
80 83
81 /* Update registers with correct frequency */ 84 /*
82 iowrite32(freq, base + CNTFID0); 85 * Update the timer if it is either not running, or is not at the
83 asm volatile("mcr p15, 0, %0, c14, c0, 0" : : "r" (freq)); 86 * right frequency. The timer is only configurable in secure mode
87 * so this avoids an abort if the loader started the timer and
88 * entered the kernel in non-secure mode.
89 */
90
91 if ((ioread32(base + CNTCR) & 1) == 0 ||
92 ioread32(base + CNTFID0) != freq) {
93 /* Update registers with correct frequency */
94 iowrite32(freq, base + CNTFID0);
95 asm volatile("mcr p15, 0, %0, c14, c0, 0" : : "r" (freq));
96
97 /* make sure arch timer is started by setting bit 0 of CNTCR */
98 iowrite32(1, base + CNTCR);
99 }
84 100
85 /* make sure arch timer is started by setting bit 0 of CNTCR */
86 iowrite32(1, base + CNTCR);
87 iounmap(base); 101 iounmap(base);
88#endif /* CONFIG_ARM_ARCH_TIMER */ 102#endif /* CONFIG_ARM_ARCH_TIMER */
89 103
104#ifdef CONFIG_COMMON_CLK
105 rcar_gen2_clocks_init(mode);
106#endif
90 clocksource_of_init(); 107 clocksource_of_init();
91} 108}
diff --git a/arch/arm/mach-shmobile/setup-sh7372.c b/arch/arm/mach-shmobile/setup-sh7372.c
index 311878391e18..27301278c208 100644
--- a/arch/arm/mach-shmobile/setup-sh7372.c
+++ b/arch/arm/mach-shmobile/setup-sh7372.c
@@ -86,138 +86,36 @@ void __init sh7372_pinmux_init(void)
86 platform_device_register(&sh7372_pfc_device); 86 platform_device_register(&sh7372_pfc_device);
87} 87}
88 88
89/* SCIFA0 */ 89/* SCIF */
90static struct plat_sci_port scif0_platform_data = { 90#define SH7372_SCIF(scif_type, index, baseaddr, irq) \
91 .mapbase = 0xe6c40000, 91static struct plat_sci_port scif##index##_platform_data = { \
92 .flags = UPF_BOOT_AUTOCONF, 92 .type = scif_type, \
93 .scscr = SCSCR_RE | SCSCR_TE, 93 .flags = UPF_BOOT_AUTOCONF, \
94 .scbrr_algo_id = SCBRR_ALGO_4, 94 .scscr = SCSCR_RE | SCSCR_TE, \
95 .type = PORT_SCIFA, 95}; \
96 .irqs = { evt2irq(0x0c00), evt2irq(0x0c00), 96 \
97 evt2irq(0x0c00), evt2irq(0x0c00) }, 97static struct resource scif##index##_resources[] = { \
98}; 98 DEFINE_RES_MEM(baseaddr, 0x100), \
99 99 DEFINE_RES_IRQ(irq), \
100static struct platform_device scif0_device = { 100}; \
101 .name = "sh-sci", 101 \
102 .id = 0, 102static struct platform_device scif##index##_device = { \
103 .dev = { 103 .name = "sh-sci", \
104 .platform_data = &scif0_platform_data, 104 .id = index, \
105 }, 105 .resource = scif##index##_resources, \
106}; 106 .num_resources = ARRAY_SIZE(scif##index##_resources), \
107 107 .dev = { \
108/* SCIFA1 */ 108 .platform_data = &scif##index##_platform_data, \
109static struct plat_sci_port scif1_platform_data = { 109 }, \
110 .mapbase = 0xe6c50000, 110}
111 .flags = UPF_BOOT_AUTOCONF,
112 .scscr = SCSCR_RE | SCSCR_TE,
113 .scbrr_algo_id = SCBRR_ALGO_4,
114 .type = PORT_SCIFA,
115 .irqs = { evt2irq(0x0c20), evt2irq(0x0c20),
116 evt2irq(0x0c20), evt2irq(0x0c20) },
117};
118
119static struct platform_device scif1_device = {
120 .name = "sh-sci",
121 .id = 1,
122 .dev = {
123 .platform_data = &scif1_platform_data,
124 },
125};
126
127/* SCIFA2 */
128static struct plat_sci_port scif2_platform_data = {
129 .mapbase = 0xe6c60000,
130 .flags = UPF_BOOT_AUTOCONF,
131 .scscr = SCSCR_RE | SCSCR_TE,
132 .scbrr_algo_id = SCBRR_ALGO_4,
133 .type = PORT_SCIFA,
134 .irqs = { evt2irq(0x0c40), evt2irq(0x0c40),
135 evt2irq(0x0c40), evt2irq(0x0c40) },
136};
137
138static struct platform_device scif2_device = {
139 .name = "sh-sci",
140 .id = 2,
141 .dev = {
142 .platform_data = &scif2_platform_data,
143 },
144};
145
146/* SCIFA3 */
147static struct plat_sci_port scif3_platform_data = {
148 .mapbase = 0xe6c70000,
149 .flags = UPF_BOOT_AUTOCONF,
150 .scscr = SCSCR_RE | SCSCR_TE,
151 .scbrr_algo_id = SCBRR_ALGO_4,
152 .type = PORT_SCIFA,
153 .irqs = { evt2irq(0x0c60), evt2irq(0x0c60),
154 evt2irq(0x0c60), evt2irq(0x0c60) },
155};
156
157static struct platform_device scif3_device = {
158 .name = "sh-sci",
159 .id = 3,
160 .dev = {
161 .platform_data = &scif3_platform_data,
162 },
163};
164
165/* SCIFA4 */
166static struct plat_sci_port scif4_platform_data = {
167 .mapbase = 0xe6c80000,
168 .flags = UPF_BOOT_AUTOCONF,
169 .scscr = SCSCR_RE | SCSCR_TE,
170 .scbrr_algo_id = SCBRR_ALGO_4,
171 .type = PORT_SCIFA,
172 .irqs = { evt2irq(0x0d20), evt2irq(0x0d20),
173 evt2irq(0x0d20), evt2irq(0x0d20) },
174};
175
176static struct platform_device scif4_device = {
177 .name = "sh-sci",
178 .id = 4,
179 .dev = {
180 .platform_data = &scif4_platform_data,
181 },
182};
183
184/* SCIFA5 */
185static struct plat_sci_port scif5_platform_data = {
186 .mapbase = 0xe6cb0000,
187 .flags = UPF_BOOT_AUTOCONF,
188 .scscr = SCSCR_RE | SCSCR_TE,
189 .scbrr_algo_id = SCBRR_ALGO_4,
190 .type = PORT_SCIFA,
191 .irqs = { evt2irq(0x0d40), evt2irq(0x0d40),
192 evt2irq(0x0d40), evt2irq(0x0d40) },
193};
194
195static struct platform_device scif5_device = {
196 .name = "sh-sci",
197 .id = 5,
198 .dev = {
199 .platform_data = &scif5_platform_data,
200 },
201};
202
203/* SCIFB */
204static struct plat_sci_port scif6_platform_data = {
205 .mapbase = 0xe6c30000,
206 .flags = UPF_BOOT_AUTOCONF,
207 .scscr = SCSCR_RE | SCSCR_TE,
208 .scbrr_algo_id = SCBRR_ALGO_4,
209 .type = PORT_SCIFB,
210 .irqs = { evt2irq(0x0d60), evt2irq(0x0d60),
211 evt2irq(0x0d60), evt2irq(0x0d60) },
212};
213 111
214static struct platform_device scif6_device = { 112SH7372_SCIF(PORT_SCIFA, 0, 0xe6c40000, evt2irq(0x0c00));
215 .name = "sh-sci", 113SH7372_SCIF(PORT_SCIFA, 1, 0xe6c50000, evt2irq(0x0c20));
216 .id = 6, 114SH7372_SCIF(PORT_SCIFA, 2, 0xe6c60000, evt2irq(0x0c40));
217 .dev = { 115SH7372_SCIF(PORT_SCIFA, 3, 0xe6c70000, evt2irq(0x0c60));
218 .platform_data = &scif6_platform_data, 116SH7372_SCIF(PORT_SCIFA, 4, 0xe6c80000, evt2irq(0x0d20));
219 }, 117SH7372_SCIF(PORT_SCIFA, 5, 0xe6cb0000, evt2irq(0x0d40));
220}; 118SH7372_SCIF(PORT_SCIFB, 6, 0xe6c30000, evt2irq(0x0d60));
221 119
222/* CMT */ 120/* CMT */
223static struct sh_timer_config cmt2_platform_data = { 121static struct sh_timer_config cmt2_platform_data = {
diff --git a/arch/arm/mach-shmobile/setup-sh73a0.c b/arch/arm/mach-shmobile/setup-sh73a0.c
index 22de17417fd7..00b348ec48b8 100644
--- a/arch/arm/mach-shmobile/setup-sh73a0.c
+++ b/arch/arm/mach-shmobile/setup-sh73a0.c
@@ -71,167 +71,38 @@ void __init sh73a0_pinmux_init(void)
71 ARRAY_SIZE(pfc_resources)); 71 ARRAY_SIZE(pfc_resources));
72} 72}
73 73
74static struct plat_sci_port scif0_platform_data = { 74/* SCIF */
75 .mapbase = 0xe6c40000, 75#define SH73A0_SCIF(scif_type, index, baseaddr, irq) \
76 .flags = UPF_BOOT_AUTOCONF, 76static struct plat_sci_port scif##index##_platform_data = { \
77 .scscr = SCSCR_RE | SCSCR_TE, 77 .type = scif_type, \
78 .scbrr_algo_id = SCBRR_ALGO_4, 78 .flags = UPF_BOOT_AUTOCONF, \
79 .type = PORT_SCIFA, 79 .scscr = SCSCR_RE | SCSCR_TE, \
80 .irqs = { gic_spi(72), gic_spi(72), 80}; \
81 gic_spi(72), gic_spi(72) }, 81 \
82}; 82static struct resource scif##index##_resources[] = { \
83 83 DEFINE_RES_MEM(baseaddr, 0x100), \
84static struct platform_device scif0_device = { 84 DEFINE_RES_IRQ(irq), \
85 .name = "sh-sci", 85}; \
86 .id = 0, 86 \
87 .dev = { 87static struct platform_device scif##index##_device = { \
88 .platform_data = &scif0_platform_data, 88 .name = "sh-sci", \
89 }, 89 .id = index, \
90}; 90 .resource = scif##index##_resources, \
91 91 .num_resources = ARRAY_SIZE(scif##index##_resources), \
92static struct plat_sci_port scif1_platform_data = { 92 .dev = { \
93 .mapbase = 0xe6c50000, 93 .platform_data = &scif##index##_platform_data, \
94 .flags = UPF_BOOT_AUTOCONF, 94 }, \
95 .scscr = SCSCR_RE | SCSCR_TE, 95}
96 .scbrr_algo_id = SCBRR_ALGO_4,
97 .type = PORT_SCIFA,
98 .irqs = { gic_spi(73), gic_spi(73),
99 gic_spi(73), gic_spi(73) },
100};
101
102static struct platform_device scif1_device = {
103 .name = "sh-sci",
104 .id = 1,
105 .dev = {
106 .platform_data = &scif1_platform_data,
107 },
108};
109
110static struct plat_sci_port scif2_platform_data = {
111 .mapbase = 0xe6c60000,
112 .flags = UPF_BOOT_AUTOCONF,
113 .scscr = SCSCR_RE | SCSCR_TE,
114 .scbrr_algo_id = SCBRR_ALGO_4,
115 .type = PORT_SCIFA,
116 .irqs = { gic_spi(74), gic_spi(74),
117 gic_spi(74), gic_spi(74) },
118};
119
120static struct platform_device scif2_device = {
121 .name = "sh-sci",
122 .id = 2,
123 .dev = {
124 .platform_data = &scif2_platform_data,
125 },
126};
127
128static struct plat_sci_port scif3_platform_data = {
129 .mapbase = 0xe6c70000,
130 .flags = UPF_BOOT_AUTOCONF,
131 .scscr = SCSCR_RE | SCSCR_TE,
132 .scbrr_algo_id = SCBRR_ALGO_4,
133 .type = PORT_SCIFA,
134 .irqs = { gic_spi(75), gic_spi(75),
135 gic_spi(75), gic_spi(75) },
136};
137
138static struct platform_device scif3_device = {
139 .name = "sh-sci",
140 .id = 3,
141 .dev = {
142 .platform_data = &scif3_platform_data,
143 },
144};
145
146static struct plat_sci_port scif4_platform_data = {
147 .mapbase = 0xe6c80000,
148 .flags = UPF_BOOT_AUTOCONF,
149 .scscr = SCSCR_RE | SCSCR_TE,
150 .scbrr_algo_id = SCBRR_ALGO_4,
151 .type = PORT_SCIFA,
152 .irqs = { gic_spi(78), gic_spi(78),
153 gic_spi(78), gic_spi(78) },
154};
155
156static struct platform_device scif4_device = {
157 .name = "sh-sci",
158 .id = 4,
159 .dev = {
160 .platform_data = &scif4_platform_data,
161 },
162};
163
164static struct plat_sci_port scif5_platform_data = {
165 .mapbase = 0xe6cb0000,
166 .flags = UPF_BOOT_AUTOCONF,
167 .scscr = SCSCR_RE | SCSCR_TE,
168 .scbrr_algo_id = SCBRR_ALGO_4,
169 .type = PORT_SCIFA,
170 .irqs = { gic_spi(79), gic_spi(79),
171 gic_spi(79), gic_spi(79) },
172};
173
174static struct platform_device scif5_device = {
175 .name = "sh-sci",
176 .id = 5,
177 .dev = {
178 .platform_data = &scif5_platform_data,
179 },
180};
181
182static struct plat_sci_port scif6_platform_data = {
183 .mapbase = 0xe6cc0000,
184 .flags = UPF_BOOT_AUTOCONF,
185 .scscr = SCSCR_RE | SCSCR_TE,
186 .scbrr_algo_id = SCBRR_ALGO_4,
187 .type = PORT_SCIFA,
188 .irqs = { gic_spi(156), gic_spi(156),
189 gic_spi(156), gic_spi(156) },
190};
191
192static struct platform_device scif6_device = {
193 .name = "sh-sci",
194 .id = 6,
195 .dev = {
196 .platform_data = &scif6_platform_data,
197 },
198};
199
200static struct plat_sci_port scif7_platform_data = {
201 .mapbase = 0xe6cd0000,
202 .flags = UPF_BOOT_AUTOCONF,
203 .scscr = SCSCR_RE | SCSCR_TE,
204 .scbrr_algo_id = SCBRR_ALGO_4,
205 .type = PORT_SCIFA,
206 .irqs = { gic_spi(143), gic_spi(143),
207 gic_spi(143), gic_spi(143) },
208};
209
210static struct platform_device scif7_device = {
211 .name = "sh-sci",
212 .id = 7,
213 .dev = {
214 .platform_data = &scif7_platform_data,
215 },
216};
217
218static struct plat_sci_port scif8_platform_data = {
219 .mapbase = 0xe6c30000,
220 .flags = UPF_BOOT_AUTOCONF,
221 .scscr = SCSCR_RE | SCSCR_TE,
222 .scbrr_algo_id = SCBRR_ALGO_4,
223 .type = PORT_SCIFB,
224 .irqs = { gic_spi(80), gic_spi(80),
225 gic_spi(80), gic_spi(80) },
226};
227 96
228static struct platform_device scif8_device = { 97SH73A0_SCIF(PORT_SCIFA, 0, 0xe6c40000, gic_spi(72));
229 .name = "sh-sci", 98SH73A0_SCIF(PORT_SCIFA, 1, 0xe6c50000, gic_spi(73));
230 .id = 8, 99SH73A0_SCIF(PORT_SCIFA, 2, 0xe6c60000, gic_spi(74));
231 .dev = { 100SH73A0_SCIF(PORT_SCIFA, 3, 0xe6c70000, gic_spi(75));
232 .platform_data = &scif8_platform_data, 101SH73A0_SCIF(PORT_SCIFA, 4, 0xe6c80000, gic_spi(78));
233 }, 102SH73A0_SCIF(PORT_SCIFA, 5, 0xe6cb0000, gic_spi(79));
234}; 103SH73A0_SCIF(PORT_SCIFA, 6, 0xe6cc0000, gic_spi(156));
104SH73A0_SCIF(PORT_SCIFA, 7, 0xe6cd0000, gic_spi(143));
105SH73A0_SCIF(PORT_SCIFB, 8, 0xe6c30000, gic_spi(80));
235 106
236static struct sh_timer_config cmt10_platform_data = { 107static struct sh_timer_config cmt10_platform_data = {
237 .name = "CMT10", 108 .name = "CMT10",
diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig
index 09e740f58b27..d1a12a496525 100644
--- a/arch/arm/mach-tegra/Kconfig
+++ b/arch/arm/mach-tegra/Kconfig
@@ -14,6 +14,8 @@ config ARCH_TEGRA
14 select MIGHT_HAVE_CACHE_L2X0 14 select MIGHT_HAVE_CACHE_L2X0
15 select MIGHT_HAVE_PCI 15 select MIGHT_HAVE_PCI
16 select PINCTRL 16 select PINCTRL
17 select ARCH_HAS_RESET_CONTROLLER
18 select RESET_CONTROLLER
17 select SOC_BUS 19 select SOC_BUS
18 select SPARSE_IRQ 20 select SPARSE_IRQ
19 select USB_ARCH_HAS_EHCI if USB_SUPPORT 21 select USB_ARCH_HAS_EHCI if USB_SUPPORT
@@ -63,6 +65,7 @@ config ARCH_TEGRA_124_SOC
63 bool "Enable support for Tegra124 family" 65 bool "Enable support for Tegra124 family"
64 select ARM_L1_CACHE_SHIFT_6 66 select ARM_L1_CACHE_SHIFT_6
65 select HAVE_ARM_ARCH_TIMER 67 select HAVE_ARM_ARCH_TIMER
68 select PINCTRL_TEGRA124
66 help 69 help
67 Support for NVIDIA Tegra T124 processor family, based on the 70 Support for NVIDIA Tegra T124 processor family, based on the
68 ARM CortexA15MP CPU 71 ARM CortexA15MP CPU
diff --git a/arch/arm/mach-tegra/fuse.c b/arch/arm/mach-tegra/fuse.c
index 9a4e910c3796..c9ac23b385be 100644
--- a/arch/arm/mach-tegra/fuse.c
+++ b/arch/arm/mach-tegra/fuse.c
@@ -22,6 +22,7 @@
22#include <linux/io.h> 22#include <linux/io.h>
23#include <linux/export.h> 23#include <linux/export.h>
24#include <linux/random.h> 24#include <linux/random.h>
25#include <linux/clk.h>
25#include <linux/tegra-soc.h> 26#include <linux/tegra-soc.h>
26 27
27#include "fuse.h" 28#include "fuse.h"
@@ -54,6 +55,7 @@ int tegra_cpu_speedo_id; /* only exist in Tegra30 and later */
54int tegra_soc_speedo_id; 55int tegra_soc_speedo_id;
55enum tegra_revision tegra_revision; 56enum tegra_revision tegra_revision;
56 57
58static struct clk *fuse_clk;
57static int tegra_fuse_spare_bit; 59static int tegra_fuse_spare_bit;
58static void (*tegra_init_speedo_data)(void); 60static void (*tegra_init_speedo_data)(void);
59 61
@@ -77,6 +79,22 @@ static const char *tegra_revision_name[TEGRA_REVISION_MAX] = {
77 [TEGRA_REVISION_A04] = "A04", 79 [TEGRA_REVISION_A04] = "A04",
78}; 80};
79 81
82static void tegra_fuse_enable_clk(void)
83{
84 if (IS_ERR(fuse_clk))
85 fuse_clk = clk_get_sys(NULL, "fuse");
86 if (IS_ERR(fuse_clk))
87 return;
88 clk_prepare_enable(fuse_clk);
89}
90
91static void tegra_fuse_disable_clk(void)
92{
93 if (IS_ERR(fuse_clk))
94 return;
95 clk_disable_unprepare(fuse_clk);
96}
97
80u32 tegra_fuse_readl(unsigned long offset) 98u32 tegra_fuse_readl(unsigned long offset)
81{ 99{
82 return tegra_apb_readl(TEGRA_FUSE_BASE + offset); 100 return tegra_apb_readl(TEGRA_FUSE_BASE + offset);
@@ -84,7 +102,15 @@ u32 tegra_fuse_readl(unsigned long offset)
84 102
85bool tegra_spare_fuse(int bit) 103bool tegra_spare_fuse(int bit)
86{ 104{
87 return tegra_fuse_readl(tegra_fuse_spare_bit + bit * 4); 105 bool ret;
106
107 tegra_fuse_enable_clk();
108
109 ret = tegra_fuse_readl(tegra_fuse_spare_bit + bit * 4);
110
111 tegra_fuse_disable_clk();
112
113 return ret;
88} 114}
89 115
90static enum tegra_revision tegra_get_revision(u32 id) 116static enum tegra_revision tegra_get_revision(u32 id)
@@ -113,10 +139,14 @@ static void tegra_get_process_id(void)
113{ 139{
114 u32 reg; 140 u32 reg;
115 141
142 tegra_fuse_enable_clk();
143
116 reg = tegra_fuse_readl(tegra_fuse_spare_bit); 144 reg = tegra_fuse_readl(tegra_fuse_spare_bit);
117 tegra_cpu_process_id = (reg >> 6) & 3; 145 tegra_cpu_process_id = (reg >> 6) & 3;
118 reg = tegra_fuse_readl(tegra_fuse_spare_bit); 146 reg = tegra_fuse_readl(tegra_fuse_spare_bit);
119 tegra_core_process_id = (reg >> 12) & 3; 147 tegra_core_process_id = (reg >> 12) & 3;
148
149 tegra_fuse_disable_clk();
120} 150}
121 151
122u32 tegra_read_chipid(void) 152u32 tegra_read_chipid(void)
@@ -159,6 +189,15 @@ void __init tegra_init_fuse(void)
159 reg |= 1 << 28; 189 reg |= 1 << 28;
160 writel(reg, IO_ADDRESS(TEGRA_CLK_RESET_BASE + 0x48)); 190 writel(reg, IO_ADDRESS(TEGRA_CLK_RESET_BASE + 0x48));
161 191
192 /*
193 * Enable FUSE clock. This needs to be hardcoded because the clock
194 * subsystem is not active during early boot.
195 */
196 reg = readl(IO_ADDRESS(TEGRA_CLK_RESET_BASE + 0x14));
197 reg |= 1 << 7;
198 writel(reg, IO_ADDRESS(TEGRA_CLK_RESET_BASE + 0x14));
199 fuse_clk = ERR_PTR(-EINVAL);
200
162 reg = tegra_fuse_readl(FUSE_SKU_INFO); 201 reg = tegra_fuse_readl(FUSE_SKU_INFO);
163 randomness[0] = reg; 202 randomness[0] = reg;
164 tegra_sku_id = reg & 0xFF; 203 tegra_sku_id = reg & 0xFF;
@@ -198,10 +237,12 @@ void __init tegra_init_fuse(void)
198 switch (tegra_chip_id) { 237 switch (tegra_chip_id) {
199 case TEGRA20: 238 case TEGRA20:
200 tegra20_fuse_init_randomness(); 239 tegra20_fuse_init_randomness();
240 break;
201 case TEGRA30: 241 case TEGRA30:
202 case TEGRA114: 242 case TEGRA114:
203 default: 243 default:
204 tegra30_fuse_init_randomness(); 244 tegra30_fuse_init_randomness();
245 break;
205 } 246 }
206 247
207 pr_info("Tegra Revision: %s SKU: %d CPU Process: %d Core Process: %d\n", 248 pr_info("Tegra Revision: %s SKU: %d CPU Process: %d Core Process: %d\n",
diff --git a/arch/arm/mach-tegra/iomap.h b/arch/arm/mach-tegra/iomap.h
index 26b1c2ad0ceb..ee79808e93a3 100644
--- a/arch/arm/mach-tegra/iomap.h
+++ b/arch/arm/mach-tegra/iomap.h
@@ -19,6 +19,7 @@
19#ifndef __MACH_TEGRA_IOMAP_H 19#ifndef __MACH_TEGRA_IOMAP_H
20#define __MACH_TEGRA_IOMAP_H 20#define __MACH_TEGRA_IOMAP_H
21 21
22#include <asm/pgtable.h>
22#include <asm/sizes.h> 23#include <asm/sizes.h>
23 24
24#define TEGRA_IRAM_BASE 0x40000000 25#define TEGRA_IRAM_BASE 0x40000000
@@ -115,27 +116,26 @@
115 * two 256MB io windows (that actually only use about 64KB 116 * two 256MB io windows (that actually only use about 64KB
116 * at the start of each). 117 * at the start of each).
117 * 118 *
118 * We will just map the first 1MB of each window (to minimize 119 * We will just map the first MMU section of each window (to minimize
119 * pt entries needed) and provide a macro to transform physical 120 * pt entries needed) and provide a macro to transform physical
120 * io addresses to an appropriate void __iomem *. 121 * io addresses to an appropriate void __iomem *.
121 *
122 */ 122 */
123 123
124#define IO_IRAM_PHYS 0x40000000 124#define IO_IRAM_PHYS 0x40000000
125#define IO_IRAM_VIRT IOMEM(0xFE400000) 125#define IO_IRAM_VIRT IOMEM(0xFE400000)
126#define IO_IRAM_SIZE SZ_256K 126#define IO_IRAM_SIZE SZ_256K
127 127
128#define IO_CPU_PHYS 0x50040000 128#define IO_CPU_PHYS 0x50040000
129#define IO_CPU_VIRT IOMEM(0xFE000000) 129#define IO_CPU_VIRT IOMEM(0xFE440000)
130#define IO_CPU_SIZE SZ_16K 130#define IO_CPU_SIZE SZ_16K
131 131
132#define IO_PPSB_PHYS 0x60000000 132#define IO_PPSB_PHYS 0x60000000
133#define IO_PPSB_VIRT IOMEM(0xFE200000) 133#define IO_PPSB_VIRT IOMEM(0xFE200000)
134#define IO_PPSB_SIZE SZ_1M 134#define IO_PPSB_SIZE SECTION_SIZE
135 135
136#define IO_APB_PHYS 0x70000000 136#define IO_APB_PHYS 0x70000000
137#define IO_APB_VIRT IOMEM(0xFE300000) 137#define IO_APB_VIRT IOMEM(0xFE000000)
138#define IO_APB_SIZE SZ_1M 138#define IO_APB_SIZE SECTION_SIZE
139 139
140#define IO_TO_VIRT_BETWEEN(p, st, sz) ((p) >= (st) && (p) < ((st) + (sz))) 140#define IO_TO_VIRT_BETWEEN(p, st, sz) ((p) >= (st) && (p) < ((st) + (sz)))
141#define IO_TO_VIRT_XLATE(p, pst, vst) (((p) - (pst) + (vst))) 141#define IO_TO_VIRT_XLATE(p, pst, vst) (((p) - (pst) + (vst)))
diff --git a/arch/arm/mach-tegra/powergate.c b/arch/arm/mach-tegra/powergate.c
index 85d28e756bb7..3d0c537d9b94 100644
--- a/arch/arm/mach-tegra/powergate.c
+++ b/arch/arm/mach-tegra/powergate.c
@@ -25,6 +25,7 @@
25#include <linux/export.h> 25#include <linux/export.h>
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/io.h> 27#include <linux/io.h>
28#include <linux/reset.h>
28#include <linux/seq_file.h> 29#include <linux/seq_file.h>
29#include <linux/spinlock.h> 30#include <linux/spinlock.h>
30#include <linux/clk/tegra.h> 31#include <linux/clk/tegra.h>
@@ -33,6 +34,10 @@
33#include "fuse.h" 34#include "fuse.h"
34#include "iomap.h" 35#include "iomap.h"
35 36
37#define DPD_SAMPLE 0x020
38#define DPD_SAMPLE_ENABLE (1 << 0)
39#define DPD_SAMPLE_DISABLE (0 << 0)
40
36#define PWRGATE_TOGGLE 0x30 41#define PWRGATE_TOGGLE 0x30
37#define PWRGATE_TOGGLE_START (1 << 8) 42#define PWRGATE_TOGGLE_START (1 << 8)
38 43
@@ -40,6 +45,19 @@
40 45
41#define PWRGATE_STATUS 0x38 46#define PWRGATE_STATUS 0x38
42 47
48#define IO_DPD_REQ 0x1b8
49#define IO_DPD_REQ_CODE_IDLE (0 << 30)
50#define IO_DPD_REQ_CODE_OFF (1 << 30)
51#define IO_DPD_REQ_CODE_ON (2 << 30)
52#define IO_DPD_REQ_CODE_MASK (3 << 30)
53
54#define IO_DPD_STATUS 0x1bc
55#define IO_DPD2_REQ 0x1c0
56#define IO_DPD2_STATUS 0x1c4
57#define SEL_DPD_TIM 0x1c8
58
59#define GPU_RG_CNTRL 0x2d4
60
43static int tegra_num_powerdomains; 61static int tegra_num_powerdomains;
44static int tegra_num_cpu_domains; 62static int tegra_num_cpu_domains;
45static const u8 *tegra_cpu_domains; 63static const u8 *tegra_cpu_domains;
@@ -58,6 +76,13 @@ static const u8 tegra114_cpu_domains[] = {
58 TEGRA_POWERGATE_CPU3, 76 TEGRA_POWERGATE_CPU3,
59}; 77};
60 78
79static const u8 tegra124_cpu_domains[] = {
80 TEGRA_POWERGATE_CPU0,
81 TEGRA_POWERGATE_CPU1,
82 TEGRA_POWERGATE_CPU2,
83 TEGRA_POWERGATE_CPU3,
84};
85
61static DEFINE_SPINLOCK(tegra_powergate_lock); 86static DEFINE_SPINLOCK(tegra_powergate_lock);
62 87
63static void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE); 88static void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE);
@@ -108,6 +133,7 @@ int tegra_powergate_power_off(int id)
108 133
109 return tegra_powergate_set(id, false); 134 return tegra_powergate_set(id, false);
110} 135}
136EXPORT_SYMBOL(tegra_powergate_power_off);
111 137
112int tegra_powergate_is_powered(int id) 138int tegra_powergate_is_powered(int id)
113{ 139{
@@ -128,12 +154,23 @@ int tegra_powergate_remove_clamping(int id)
128 return -EINVAL; 154 return -EINVAL;
129 155
130 /* 156 /*
157 * The Tegra124 GPU has a separate register (with different semantics)
158 * to remove clamps.
159 */
160 if (tegra_chip_id == TEGRA124) {
161 if (id == TEGRA_POWERGATE_3D) {
162 pmc_write(0, GPU_RG_CNTRL);
163 return 0;
164 }
165 }
166
167 /*
131 * Tegra 2 has a bug where PCIE and VDE clamping masks are 168 * Tegra 2 has a bug where PCIE and VDE clamping masks are
132 * swapped relatively to the partition ids 169 * swapped relatively to the partition ids
133 */ 170 */
134 if (id == TEGRA_POWERGATE_VDEC) 171 if (id == TEGRA_POWERGATE_VDEC)
135 mask = (1 << TEGRA_POWERGATE_PCIE); 172 mask = (1 << TEGRA_POWERGATE_PCIE);
136 else if (id == TEGRA_POWERGATE_PCIE) 173 else if (id == TEGRA_POWERGATE_PCIE)
137 mask = (1 << TEGRA_POWERGATE_VDEC); 174 mask = (1 << TEGRA_POWERGATE_VDEC);
138 else 175 else
139 mask = (1 << id); 176 mask = (1 << id);
@@ -142,13 +179,15 @@ int tegra_powergate_remove_clamping(int id)
142 179
143 return 0; 180 return 0;
144} 181}
182EXPORT_SYMBOL(tegra_powergate_remove_clamping);
145 183
146/* Must be called with clk disabled, and returns with clk enabled */ 184/* Must be called with clk disabled, and returns with clk enabled */
147int tegra_powergate_sequence_power_up(int id, struct clk *clk) 185int tegra_powergate_sequence_power_up(int id, struct clk *clk,
186 struct reset_control *rst)
148{ 187{
149 int ret; 188 int ret;
150 189
151 tegra_periph_reset_assert(clk); 190 reset_control_assert(rst);
152 191
153 ret = tegra_powergate_power_on(id); 192 ret = tegra_powergate_power_on(id);
154 if (ret) 193 if (ret)
@@ -165,7 +204,7 @@ int tegra_powergate_sequence_power_up(int id, struct clk *clk)
165 goto err_clamp; 204 goto err_clamp;
166 205
167 udelay(10); 206 udelay(10);
168 tegra_periph_reset_deassert(clk); 207 reset_control_deassert(rst);
169 208
170 return 0; 209 return 0;
171 210
@@ -202,6 +241,11 @@ int __init tegra_powergate_init(void)
202 tegra_num_cpu_domains = 4; 241 tegra_num_cpu_domains = 4;
203 tegra_cpu_domains = tegra114_cpu_domains; 242 tegra_cpu_domains = tegra114_cpu_domains;
204 break; 243 break;
244 case TEGRA124:
245 tegra_num_powerdomains = 25;
246 tegra_num_cpu_domains = 4;
247 tegra_cpu_domains = tegra124_cpu_domains;
248 break;
205 default: 249 default:
206 /* Unknown Tegra variant. Disable powergating */ 250 /* Unknown Tegra variant. Disable powergating */
207 tegra_num_powerdomains = 0; 251 tegra_num_powerdomains = 0;
@@ -243,12 +287,36 @@ static const char * const powergate_name_t30[] = {
243}; 287};
244 288
245static const char * const powergate_name_t114[] = { 289static const char * const powergate_name_t114[] = {
246 [TEGRA_POWERGATE_CPU] = "cpu0", 290 [TEGRA_POWERGATE_CPU] = "crail",
291 [TEGRA_POWERGATE_3D] = "3d",
292 [TEGRA_POWERGATE_VENC] = "venc",
293 [TEGRA_POWERGATE_VDEC] = "vdec",
294 [TEGRA_POWERGATE_MPE] = "mpe",
295 [TEGRA_POWERGATE_HEG] = "heg",
296 [TEGRA_POWERGATE_CPU1] = "cpu1",
297 [TEGRA_POWERGATE_CPU2] = "cpu2",
298 [TEGRA_POWERGATE_CPU3] = "cpu3",
299 [TEGRA_POWERGATE_CELP] = "celp",
300 [TEGRA_POWERGATE_CPU0] = "cpu0",
301 [TEGRA_POWERGATE_C0NC] = "c0nc",
302 [TEGRA_POWERGATE_C1NC] = "c1nc",
303 [TEGRA_POWERGATE_DIS] = "dis",
304 [TEGRA_POWERGATE_DISB] = "disb",
305 [TEGRA_POWERGATE_XUSBA] = "xusba",
306 [TEGRA_POWERGATE_XUSBB] = "xusbb",
307 [TEGRA_POWERGATE_XUSBC] = "xusbc",
308};
309
310static const char * const powergate_name_t124[] = {
311 [TEGRA_POWERGATE_CPU] = "crail",
247 [TEGRA_POWERGATE_3D] = "3d", 312 [TEGRA_POWERGATE_3D] = "3d",
248 [TEGRA_POWERGATE_VENC] = "venc", 313 [TEGRA_POWERGATE_VENC] = "venc",
314 [TEGRA_POWERGATE_PCIE] = "pcie",
249 [TEGRA_POWERGATE_VDEC] = "vdec", 315 [TEGRA_POWERGATE_VDEC] = "vdec",
316 [TEGRA_POWERGATE_L2] = "l2",
250 [TEGRA_POWERGATE_MPE] = "mpe", 317 [TEGRA_POWERGATE_MPE] = "mpe",
251 [TEGRA_POWERGATE_HEG] = "heg", 318 [TEGRA_POWERGATE_HEG] = "heg",
319 [TEGRA_POWERGATE_SATA] = "sata",
252 [TEGRA_POWERGATE_CPU1] = "cpu1", 320 [TEGRA_POWERGATE_CPU1] = "cpu1",
253 [TEGRA_POWERGATE_CPU2] = "cpu2", 321 [TEGRA_POWERGATE_CPU2] = "cpu2",
254 [TEGRA_POWERGATE_CPU3] = "cpu3", 322 [TEGRA_POWERGATE_CPU3] = "cpu3",
@@ -256,11 +324,14 @@ static const char * const powergate_name_t114[] = {
256 [TEGRA_POWERGATE_CPU0] = "cpu0", 324 [TEGRA_POWERGATE_CPU0] = "cpu0",
257 [TEGRA_POWERGATE_C0NC] = "c0nc", 325 [TEGRA_POWERGATE_C0NC] = "c0nc",
258 [TEGRA_POWERGATE_C1NC] = "c1nc", 326 [TEGRA_POWERGATE_C1NC] = "c1nc",
327 [TEGRA_POWERGATE_SOR] = "sor",
259 [TEGRA_POWERGATE_DIS] = "dis", 328 [TEGRA_POWERGATE_DIS] = "dis",
260 [TEGRA_POWERGATE_DISB] = "disb", 329 [TEGRA_POWERGATE_DISB] = "disb",
261 [TEGRA_POWERGATE_XUSBA] = "xusba", 330 [TEGRA_POWERGATE_XUSBA] = "xusba",
262 [TEGRA_POWERGATE_XUSBB] = "xusbb", 331 [TEGRA_POWERGATE_XUSBB] = "xusbb",
263 [TEGRA_POWERGATE_XUSBC] = "xusbc", 332 [TEGRA_POWERGATE_XUSBC] = "xusbc",
333 [TEGRA_POWERGATE_VIC] = "vic",
334 [TEGRA_POWERGATE_IRAM] = "iram",
264}; 335};
265 336
266static int powergate_show(struct seq_file *s, void *data) 337static int powergate_show(struct seq_file *s, void *data)
@@ -307,6 +378,9 @@ int __init tegra_powergate_debugfs_init(void)
307 case TEGRA114: 378 case TEGRA114:
308 powergate_name = powergate_name_t114; 379 powergate_name = powergate_name_t114;
309 break; 380 break;
381 case TEGRA124:
382 powergate_name = powergate_name_t124;
383 break;
310 } 384 }
311 385
312 if (powergate_name) { 386 if (powergate_name) {
@@ -320,3 +394,120 @@ int __init tegra_powergate_debugfs_init(void)
320} 394}
321 395
322#endif 396#endif
397
398static int tegra_io_rail_prepare(int id, unsigned long *request,
399 unsigned long *status, unsigned int *bit)
400{
401 unsigned long rate, value;
402 struct clk *clk;
403
404 *bit = id % 32;
405
406 /*
407 * There are two sets of 30 bits to select IO rails, but bits 30 and
408 * 31 are control bits rather than IO rail selection bits.
409 */
410 if (id > 63 || *bit == 30 || *bit == 31)
411 return -EINVAL;
412
413 if (id < 32) {
414 *status = IO_DPD_STATUS;
415 *request = IO_DPD_REQ;
416 } else {
417 *status = IO_DPD2_STATUS;
418 *request = IO_DPD2_REQ;
419 }
420
421 clk = clk_get_sys(NULL, "pclk");
422 if (IS_ERR(clk))
423 return PTR_ERR(clk);
424
425 rate = clk_get_rate(clk);
426 clk_put(clk);
427
428 pmc_write(DPD_SAMPLE_ENABLE, DPD_SAMPLE);
429
430 /* must be at least 200 ns, in APB (PCLK) clock cycles */
431 value = DIV_ROUND_UP(1000000000, rate);
432 value = DIV_ROUND_UP(200, value);
433 pmc_write(value, SEL_DPD_TIM);
434
435 return 0;
436}
437
438static int tegra_io_rail_poll(unsigned long offset, unsigned long mask,
439 unsigned long val, unsigned long timeout)
440{
441 unsigned long value;
442
443 timeout = jiffies + msecs_to_jiffies(timeout);
444
445 while (time_after(timeout, jiffies)) {
446 value = pmc_read(offset);
447 if ((value & mask) == val)
448 return 0;
449
450 usleep_range(250, 1000);
451 }
452
453 return -ETIMEDOUT;
454}
455
456static void tegra_io_rail_unprepare(void)
457{
458 pmc_write(DPD_SAMPLE_DISABLE, DPD_SAMPLE);
459}
460
461int tegra_io_rail_power_on(int id)
462{
463 unsigned long request, status, value;
464 unsigned int bit, mask;
465 int err;
466
467 err = tegra_io_rail_prepare(id, &request, &status, &bit);
468 if (err < 0)
469 return err;
470
471 mask = 1 << bit;
472
473 value = pmc_read(request);
474 value |= mask;
475 value &= ~IO_DPD_REQ_CODE_MASK;
476 value |= IO_DPD_REQ_CODE_OFF;
477 pmc_write(value, request);
478
479 err = tegra_io_rail_poll(status, mask, 0, 250);
480 if (err < 0)
481 return err;
482
483 tegra_io_rail_unprepare();
484
485 return 0;
486}
487
488int tegra_io_rail_power_off(int id)
489{
490 unsigned long request, status, value;
491 unsigned int bit, mask;
492 int err;
493
494 err = tegra_io_rail_prepare(id, &request, &status, &bit);
495 if (err < 0)
496 return err;
497
498 mask = 1 << bit;
499
500 value = pmc_read(request);
501 value |= mask;
502 value &= ~IO_DPD_REQ_CODE_MASK;
503 value |= IO_DPD_REQ_CODE_ON;
504 pmc_write(value, request);
505
506 err = tegra_io_rail_poll(status, mask, mask, 250);
507 if (err < 0)
508 return err;
509
510 tegra_io_rail_unprepare();
511
512 return 0;
513}
diff --git a/arch/arm/mach-tegra/tegra.c b/arch/arm/mach-tegra/tegra.c
index 73368176c6e8..ea14d380fc0c 100644
--- a/arch/arm/mach-tegra/tegra.c
+++ b/arch/arm/mach-tegra/tegra.c
@@ -60,15 +60,13 @@
60 * kernel is loaded. The data is declared here rather than debug-macro.S so 60 * kernel is loaded. The data is declared here rather than debug-macro.S so
61 * that multiple inclusions of debug-macro.S point at the same data. 61 * that multiple inclusions of debug-macro.S point at the same data.
62 */ 62 */
63u32 tegra_uart_config[4] = { 63u32 tegra_uart_config[3] = {
64 /* Debug UART initialization required */ 64 /* Debug UART initialization required */
65 1, 65 1,
66 /* Debug UART physical address */ 66 /* Debug UART physical address */
67 0, 67 0,
68 /* Debug UART virtual address */ 68 /* Debug UART virtual address */
69 0, 69 0,
70 /* Scratch space for debug macro */
71 0,
72}; 70};
73 71
74static void __init tegra_init_cache(void) 72static void __init tegra_init_cache(void)
diff --git a/arch/arm/mach-u300/timer.c b/arch/arm/mach-u300/timer.c
index 9a5f9fb352ce..9724e4e7cc93 100644
--- a/arch/arm/mach-u300/timer.c
+++ b/arch/arm/mach-u300/timer.c
@@ -341,7 +341,7 @@ static struct irqaction u300_timer_irq = {
341 * stamp. (Inspired by OMAP implementation.) 341 * stamp. (Inspired by OMAP implementation.)
342 */ 342 */
343 343
344static u32 notrace u300_read_sched_clock(void) 344static u64 notrace u300_read_sched_clock(void)
345{ 345{
346 return readl(u300_timer_base + U300_TIMER_APP_GPT2CC); 346 return readl(u300_timer_base + U300_TIMER_APP_GPT2CC);
347} 347}
@@ -379,7 +379,7 @@ static void __init u300_timer_init_of(struct device_node *np)
379 clk_prepare_enable(clk); 379 clk_prepare_enable(clk);
380 rate = clk_get_rate(clk); 380 rate = clk_get_rate(clk);
381 381
382 setup_sched_clock(u300_read_sched_clock, 32, rate); 382 sched_clock_register(u300_read_sched_clock, 32, rate);
383 383
384 u300_delay_timer.read_current_timer = &u300_read_current_timer; 384 u300_delay_timer.read_current_timer = &u300_read_current_timer;
385 u300_delay_timer.freq = rate; 385 u300_delay_timer.freq = rate;
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index f6b6bfa88ecf..f61a5707823a 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -158,13 +158,49 @@ struct dma_map_ops arm_coherent_dma_ops = {
158}; 158};
159EXPORT_SYMBOL(arm_coherent_dma_ops); 159EXPORT_SYMBOL(arm_coherent_dma_ops);
160 160
161static int __dma_supported(struct device *dev, u64 mask, bool warn)
162{
163 unsigned long max_dma_pfn;
164
165 /*
166 * If the mask allows for more memory than we can address,
167 * and we actually have that much memory, then we must
168 * indicate that DMA to this device is not supported.
169 */
170 if (sizeof(mask) != sizeof(dma_addr_t) &&
171 mask > (dma_addr_t)~0 &&
172 dma_to_pfn(dev, ~0) < max_pfn) {
173 if (warn) {
174 dev_warn(dev, "Coherent DMA mask %#llx is larger than dma_addr_t allows\n",
175 mask);
176 dev_warn(dev, "Driver did not use or check the return value from dma_set_coherent_mask()?\n");
177 }
178 return 0;
179 }
180
181 max_dma_pfn = min(max_pfn, arm_dma_pfn_limit);
182
183 /*
184 * Translate the device's DMA mask to a PFN limit. This
185 * PFN number includes the page which we can DMA to.
186 */
187 if (dma_to_pfn(dev, mask) < max_dma_pfn) {
188 if (warn)
189 dev_warn(dev, "Coherent DMA mask %#llx (pfn %#lx-%#lx) covers a smaller range of system memory than the DMA zone pfn 0x0-%#lx\n",
190 mask,
191 dma_to_pfn(dev, 0), dma_to_pfn(dev, mask) + 1,
192 max_dma_pfn + 1);
193 return 0;
194 }
195
196 return 1;
197}
198
161static u64 get_coherent_dma_mask(struct device *dev) 199static u64 get_coherent_dma_mask(struct device *dev)
162{ 200{
163 u64 mask = (u64)DMA_BIT_MASK(32); 201 u64 mask = (u64)DMA_BIT_MASK(32);
164 202
165 if (dev) { 203 if (dev) {
166 unsigned long max_dma_pfn;
167
168 mask = dev->coherent_dma_mask; 204 mask = dev->coherent_dma_mask;
169 205
170 /* 206 /*
@@ -176,34 +212,8 @@ static u64 get_coherent_dma_mask(struct device *dev)
176 return 0; 212 return 0;
177 } 213 }
178 214
179 max_dma_pfn = min(max_pfn, arm_dma_pfn_limit); 215 if (!__dma_supported(dev, mask, true))
180
181 /*
182 * If the mask allows for more memory than we can address,
183 * and we actually have that much memory, then fail the
184 * allocation.
185 */
186 if (sizeof(mask) != sizeof(dma_addr_t) &&
187 mask > (dma_addr_t)~0 &&
188 dma_to_pfn(dev, ~0) > max_dma_pfn) {
189 dev_warn(dev, "Coherent DMA mask %#llx is larger than dma_addr_t allows\n",
190 mask);
191 dev_warn(dev, "Driver did not use or check the return value from dma_set_coherent_mask()?\n");
192 return 0;
193 }
194
195 /*
196 * Now check that the mask, when translated to a PFN,
197 * fits within the allowable addresses which we can
198 * allocate.
199 */
200 if (dma_to_pfn(dev, mask) < max_dma_pfn) {
201 dev_warn(dev, "Coherent DMA mask %#llx (pfn %#lx-%#lx) covers a smaller range of system memory than the DMA zone pfn 0x0-%#lx\n",
202 mask,
203 dma_to_pfn(dev, 0), dma_to_pfn(dev, mask) + 1,
204 arm_dma_pfn_limit + 1);
205 return 0; 216 return 0;
206 }
207 } 217 }
208 218
209 return mask; 219 return mask;
@@ -1032,28 +1042,7 @@ void arm_dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
1032 */ 1042 */
1033int dma_supported(struct device *dev, u64 mask) 1043int dma_supported(struct device *dev, u64 mask)
1034{ 1044{
1035 unsigned long limit; 1045 return __dma_supported(dev, mask, false);
1036
1037 /*
1038 * If the mask allows for more memory than we can address,
1039 * and we actually have that much memory, then we must
1040 * indicate that DMA to this device is not supported.
1041 */
1042 if (sizeof(mask) != sizeof(dma_addr_t) &&
1043 mask > (dma_addr_t)~0 &&
1044 dma_to_pfn(dev, ~0) > arm_dma_pfn_limit)
1045 return 0;
1046
1047 /*
1048 * Translate the device's DMA mask to a PFN limit. This
1049 * PFN number includes the page which we can DMA to.
1050 */
1051 limit = dma_to_pfn(dev, mask);
1052
1053 if (limit < arm_dma_pfn_limit)
1054 return 0;
1055
1056 return 1;
1057} 1046}
1058EXPORT_SYMBOL(dma_supported); 1047EXPORT_SYMBOL(dma_supported);
1059 1048
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 3e8f106ee5fe..1f7b19a47060 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -229,7 +229,7 @@ void __init setup_dma_zone(const struct machine_desc *mdesc)
229#ifdef CONFIG_ZONE_DMA 229#ifdef CONFIG_ZONE_DMA
230 if (mdesc->dma_zone_size) { 230 if (mdesc->dma_zone_size) {
231 arm_dma_zone_size = mdesc->dma_zone_size; 231 arm_dma_zone_size = mdesc->dma_zone_size;
232 arm_dma_limit = PHYS_OFFSET + arm_dma_zone_size - 1; 232 arm_dma_limit = __pv_phys_offset + arm_dma_zone_size - 1;
233 } else 233 } else
234 arm_dma_limit = 0xffffffff; 234 arm_dma_limit = 0xffffffff;
235 arm_dma_pfn_limit = arm_dma_limit >> PAGE_SHIFT; 235 arm_dma_pfn_limit = arm_dma_limit >> PAGE_SHIFT;
diff --git a/arch/arm/plat-iop/time.c b/arch/arm/plat-iop/time.c
index 29606bd75f3f..d70b73364a3f 100644
--- a/arch/arm/plat-iop/time.c
+++ b/arch/arm/plat-iop/time.c
@@ -54,7 +54,7 @@ static struct clocksource iop_clocksource = {
54/* 54/*
55 * IOP sched_clock() implementation via its clocksource. 55 * IOP sched_clock() implementation via its clocksource.
56 */ 56 */
57static u32 notrace iop_read_sched_clock(void) 57static u64 notrace iop_read_sched_clock(void)
58{ 58{
59 return 0xffffffffu - read_tcr1(); 59 return 0xffffffffu - read_tcr1();
60} 60}
@@ -142,7 +142,7 @@ void __init iop_init_time(unsigned long tick_rate)
142{ 142{
143 u32 timer_ctl; 143 u32 timer_ctl;
144 144
145 setup_sched_clock(iop_read_sched_clock, 32, tick_rate); 145 sched_clock_register(iop_read_sched_clock, 32, tick_rate);
146 146
147 ticks_per_jiffy = DIV_ROUND_CLOSEST(tick_rate, HZ); 147 ticks_per_jiffy = DIV_ROUND_CLOSEST(tick_rate, HZ);
148 iop_tick_rate = tick_rate; 148 iop_tick_rate = tick_rate;
diff --git a/arch/arm/plat-omap/counter_32k.c b/arch/arm/plat-omap/counter_32k.c
index d9bc98eb2a6b..384a776d8eb2 100644
--- a/arch/arm/plat-omap/counter_32k.c
+++ b/arch/arm/plat-omap/counter_32k.c
@@ -38,7 +38,7 @@
38 */ 38 */
39static void __iomem *sync32k_cnt_reg; 39static void __iomem *sync32k_cnt_reg;
40 40
41static u32 notrace omap_32k_read_sched_clock(void) 41static u64 notrace omap_32k_read_sched_clock(void)
42{ 42{
43 return sync32k_cnt_reg ? __raw_readl(sync32k_cnt_reg) : 0; 43 return sync32k_cnt_reg ? __raw_readl(sync32k_cnt_reg) : 0;
44} 44}
@@ -115,7 +115,7 @@ int __init omap_init_clocksource_32k(void __iomem *vbase)
115 return ret; 115 return ret;
116 } 116 }
117 117
118 setup_sched_clock(omap_32k_read_sched_clock, 32, 32768); 118 sched_clock_register(omap_32k_read_sched_clock, 32, 32768);
119 register_persistent_clock(NULL, omap_read_persistent_clock); 119 register_persistent_clock(NULL, omap_read_persistent_clock);
120 pr_info("OMAP clocksource: 32k_counter at 32768 Hz\n"); 120 pr_info("OMAP clocksource: 32k_counter at 32768 Hz\n");
121 121
diff --git a/arch/arm/plat-orion/time.c b/arch/arm/plat-orion/time.c
index 9d2b2ac74938..dade2920e9a6 100644
--- a/arch/arm/plat-orion/time.c
+++ b/arch/arm/plat-orion/time.c
@@ -60,7 +60,7 @@ static u32 ticks_per_jiffy;
60 * at least 7.5ns (133MHz TCLK). 60 * at least 7.5ns (133MHz TCLK).
61 */ 61 */
62 62
63static u32 notrace orion_read_sched_clock(void) 63static u64 notrace orion_read_sched_clock(void)
64{ 64{
65 return ~readl(timer_base + TIMER0_VAL_OFF); 65 return ~readl(timer_base + TIMER0_VAL_OFF);
66} 66}
@@ -201,7 +201,7 @@ orion_time_init(void __iomem *_bridge_base, u32 _bridge_timer1_clr_mask,
201 /* 201 /*
202 * Set scale and timer for sched_clock. 202 * Set scale and timer for sched_clock.
203 */ 203 */
204 setup_sched_clock(orion_read_sched_clock, 32, tclk); 204 sched_clock_register(orion_read_sched_clock, 32, tclk);
205 205
206 /* 206 /*
207 * Setup free-running clocksource timer (interrupts 207 * Setup free-running clocksource timer (interrupts
diff --git a/arch/arm/plat-samsung/s5p-irq-eint.c b/arch/arm/plat-samsung/s5p-irq-eint.c
index faa651602780..ebee4dc11a94 100644
--- a/arch/arm/plat-samsung/s5p-irq-eint.c
+++ b/arch/arm/plat-samsung/s5p-irq-eint.c
@@ -16,6 +16,7 @@
16#include <linux/device.h> 16#include <linux/device.h>
17#include <linux/gpio.h> 17#include <linux/gpio.h>
18#include <linux/irqchip/arm-vic.h> 18#include <linux/irqchip/arm-vic.h>
19#include <linux/of.h>
19 20
20#include <plat/regs-irqtype.h> 21#include <plat/regs-irqtype.h>
21 22
@@ -202,6 +203,9 @@ static int __init s5p_init_irq_eint(void)
202{ 203{
203 int irq; 204 int irq;
204 205
206 if (of_have_populated_dt())
207 return -ENODEV;
208
205 for (irq = IRQ_EINT(0); irq <= IRQ_EINT(15); irq++) 209 for (irq = IRQ_EINT(0); irq <= IRQ_EINT(15); irq++)
206 irq_set_chip(irq, &s5p_irq_vic_eint); 210 irq_set_chip(irq, &s5p_irq_vic_eint);
207 211
diff --git a/arch/arm/plat-versatile/sched-clock.c b/arch/arm/plat-versatile/sched-clock.c
index 51b109e3b6c3..c966ae90f4a0 100644
--- a/arch/arm/plat-versatile/sched-clock.c
+++ b/arch/arm/plat-versatile/sched-clock.c
@@ -26,7 +26,7 @@
26 26
27static void __iomem *ctr; 27static void __iomem *ctr;
28 28
29static u32 notrace versatile_read_sched_clock(void) 29static u64 notrace versatile_read_sched_clock(void)
30{ 30{
31 if (ctr) 31 if (ctr)
32 return readl(ctr); 32 return readl(ctr);
@@ -37,5 +37,5 @@ static u32 notrace versatile_read_sched_clock(void)
37void __init versatile_sched_clock_init(void __iomem *reg, unsigned long rate) 37void __init versatile_sched_clock_init(void __iomem *reg, unsigned long rate)
38{ 38{
39 ctr = reg; 39 ctr = reg;
40 setup_sched_clock(versatile_read_sched_clock, 32, rate); 40 sched_clock_register(versatile_read_sched_clock, 32, rate);
41} 41}
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 88c8b6c1341a..6d4dd22ee4b7 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -159,8 +159,7 @@ config NR_CPUS
159 range 2 32 159 range 2 32
160 depends on SMP 160 depends on SMP
161 # These have to remain sorted largest to smallest 161 # These have to remain sorted largest to smallest
162 default "8" if ARCH_XGENE 162 default "8"
163 default "4"
164 163
165config HOTPLUG_CPU 164config HOTPLUG_CPU
166 bool "Support for hot-pluggable CPUs" 165 bool "Support for hot-pluggable CPUs"
diff --git a/arch/arm64/include/asm/io.h b/arch/arm64/include/asm/io.h
index 4cc813eddacb..572769727227 100644
--- a/arch/arm64/include/asm/io.h
+++ b/arch/arm64/include/asm/io.h
@@ -229,7 +229,7 @@ extern void __iomem *__ioremap(phys_addr_t phys_addr, size_t size, pgprot_t prot
229extern void __iounmap(volatile void __iomem *addr); 229extern void __iounmap(volatile void __iomem *addr);
230extern void __iomem *ioremap_cache(phys_addr_t phys_addr, size_t size); 230extern void __iomem *ioremap_cache(phys_addr_t phys_addr, size_t size);
231 231
232#define PROT_DEFAULT (PTE_TYPE_PAGE | PTE_AF | PTE_DIRTY) 232#define PROT_DEFAULT (pgprot_default | PTE_DIRTY)
233#define PROT_DEVICE_nGnRE (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_ATTRINDX(MT_DEVICE_nGnRE)) 233#define PROT_DEVICE_nGnRE (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_ATTRINDX(MT_DEVICE_nGnRE))
234#define PROT_NORMAL_NC (PROT_DEFAULT | PTE_ATTRINDX(MT_NORMAL_NC)) 234#define PROT_NORMAL_NC (PROT_DEFAULT | PTE_ATTRINDX(MT_NORMAL_NC))
235#define PROT_NORMAL (PROT_DEFAULT | PTE_ATTRINDX(MT_NORMAL)) 235#define PROT_NORMAL (PROT_DEFAULT | PTE_ATTRINDX(MT_NORMAL))
diff --git a/arch/arm64/include/asm/pgtable-hwdef.h b/arch/arm64/include/asm/pgtable-hwdef.h
index 755f86143320..b1d2e26c3c88 100644
--- a/arch/arm64/include/asm/pgtable-hwdef.h
+++ b/arch/arm64/include/asm/pgtable-hwdef.h
@@ -43,7 +43,7 @@
43 * Section 43 * Section
44 */ 44 */
45#define PMD_SECT_VALID (_AT(pmdval_t, 1) << 0) 45#define PMD_SECT_VALID (_AT(pmdval_t, 1) << 0)
46#define PMD_SECT_PROT_NONE (_AT(pmdval_t, 1) << 2) 46#define PMD_SECT_PROT_NONE (_AT(pmdval_t, 1) << 58)
47#define PMD_SECT_USER (_AT(pmdval_t, 1) << 6) /* AP[1] */ 47#define PMD_SECT_USER (_AT(pmdval_t, 1) << 6) /* AP[1] */
48#define PMD_SECT_RDONLY (_AT(pmdval_t, 1) << 7) /* AP[2] */ 48#define PMD_SECT_RDONLY (_AT(pmdval_t, 1) << 7) /* AP[2] */
49#define PMD_SECT_S (_AT(pmdval_t, 3) << 8) 49#define PMD_SECT_S (_AT(pmdval_t, 3) << 8)
diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
index 7009387348b7..c68cca5c3523 100644
--- a/arch/arm64/kernel/head.S
+++ b/arch/arm64/kernel/head.S
@@ -282,8 +282,9 @@ ENDPROC(secondary_holding_pen)
282 * be used where CPUs are brought online dynamically by the kernel. 282 * be used where CPUs are brought online dynamically by the kernel.
283 */ 283 */
284ENTRY(secondary_entry) 284ENTRY(secondary_entry)
285 bl __calc_phys_offset // x2=phys offset
286 bl el2_setup // Drop to EL1 285 bl el2_setup // Drop to EL1
286 bl __calc_phys_offset // x24=PHYS_OFFSET, x28=PHYS_OFFSET-PAGE_OFFSET
287 bl set_cpu_boot_mode_flag
287 b secondary_startup 288 b secondary_startup
288ENDPROC(secondary_entry) 289ENDPROC(secondary_entry)
289 290
diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S
index 421b99fd635d..0f7fec52c7f8 100644
--- a/arch/arm64/mm/proc.S
+++ b/arch/arm64/mm/proc.S
@@ -111,12 +111,12 @@ ENTRY(__cpu_setup)
111 bl __flush_dcache_all 111 bl __flush_dcache_all
112 mov lr, x28 112 mov lr, x28
113 ic iallu // I+BTB cache invalidate 113 ic iallu // I+BTB cache invalidate
114 tlbi vmalle1is // invalidate I + D TLBs
114 dsb sy 115 dsb sy
115 116
116 mov x0, #3 << 20 117 mov x0, #3 << 20
117 msr cpacr_el1, x0 // Enable FP/ASIMD 118 msr cpacr_el1, x0 // Enable FP/ASIMD
118 msr mdscr_el1, xzr // Reset mdscr_el1 119 msr mdscr_el1, xzr // Reset mdscr_el1
119 tlbi vmalle1is // invalidate I + D TLBs
120 /* 120 /*
121 * Memory region attributes for LPAE: 121 * Memory region attributes for LPAE:
122 * 122 *
diff --git a/arch/avr32/boards/favr-32/setup.c b/arch/avr32/boards/favr-32/setup.c
index 7b1f2cd85400..1f121497b517 100644
--- a/arch/avr32/boards/favr-32/setup.c
+++ b/arch/avr32/boards/favr-32/setup.c
@@ -298,8 +298,10 @@ static int __init set_abdac_rate(struct platform_device *pdev)
298 */ 298 */
299 retval = clk_round_rate(pll1, 299 retval = clk_round_rate(pll1,
300 CONFIG_BOARD_FAVR32_ABDAC_RATE * 256 * 16); 300 CONFIG_BOARD_FAVR32_ABDAC_RATE * 256 * 16);
301 if (retval < 0) 301 if (retval <= 0) {
302 retval = -EINVAL;
302 goto out_abdac; 303 goto out_abdac;
304 }
303 305
304 retval = clk_set_rate(pll1, retval); 306 retval = clk_set_rate(pll1, retval);
305 if (retval != 0) 307 if (retval != 0)
diff --git a/arch/avr32/configs/atngw100_defconfig b/arch/avr32/configs/atngw100_defconfig
index d5aff36ade92..4733e38e7ae6 100644
--- a/arch/avr32/configs/atngw100_defconfig
+++ b/arch/avr32/configs/atngw100_defconfig
@@ -59,7 +59,6 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
59# CONFIG_PREVENT_FIRMWARE_BUILD is not set 59# CONFIG_PREVENT_FIRMWARE_BUILD is not set
60# CONFIG_FW_LOADER is not set 60# CONFIG_FW_LOADER is not set
61CONFIG_MTD=y 61CONFIG_MTD=y
62CONFIG_MTD_PARTITIONS=y
63CONFIG_MTD_CMDLINE_PARTS=y 62CONFIG_MTD_CMDLINE_PARTS=y
64CONFIG_MTD_CHAR=y 63CONFIG_MTD_CHAR=y
65CONFIG_MTD_BLOCK=y 64CONFIG_MTD_BLOCK=y
diff --git a/arch/avr32/configs/atngw100_evklcd100_defconfig b/arch/avr32/configs/atngw100_evklcd100_defconfig
index 4abcf435d599..1be0ee31bd91 100644
--- a/arch/avr32/configs/atngw100_evklcd100_defconfig
+++ b/arch/avr32/configs/atngw100_evklcd100_defconfig
@@ -61,7 +61,6 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
61# CONFIG_PREVENT_FIRMWARE_BUILD is not set 61# CONFIG_PREVENT_FIRMWARE_BUILD is not set
62# CONFIG_FW_LOADER is not set 62# CONFIG_FW_LOADER is not set
63CONFIG_MTD=y 63CONFIG_MTD=y
64CONFIG_MTD_PARTITIONS=y
65CONFIG_MTD_CMDLINE_PARTS=y 64CONFIG_MTD_CMDLINE_PARTS=y
66CONFIG_MTD_CHAR=y 65CONFIG_MTD_CHAR=y
67CONFIG_MTD_BLOCK=y 66CONFIG_MTD_BLOCK=y
diff --git a/arch/avr32/configs/atngw100_evklcd101_defconfig b/arch/avr32/configs/atngw100_evklcd101_defconfig
index 18f3fa0470ff..796e536f7bc4 100644
--- a/arch/avr32/configs/atngw100_evklcd101_defconfig
+++ b/arch/avr32/configs/atngw100_evklcd101_defconfig
@@ -60,7 +60,6 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
60# CONFIG_PREVENT_FIRMWARE_BUILD is not set 60# CONFIG_PREVENT_FIRMWARE_BUILD is not set
61# CONFIG_FW_LOADER is not set 61# CONFIG_FW_LOADER is not set
62CONFIG_MTD=y 62CONFIG_MTD=y
63CONFIG_MTD_PARTITIONS=y
64CONFIG_MTD_CMDLINE_PARTS=y 63CONFIG_MTD_CMDLINE_PARTS=y
65CONFIG_MTD_CHAR=y 64CONFIG_MTD_CHAR=y
66CONFIG_MTD_BLOCK=y 65CONFIG_MTD_BLOCK=y
diff --git a/arch/avr32/configs/atngw100_mrmt_defconfig b/arch/avr32/configs/atngw100_mrmt_defconfig
index 06e389cfcd12..9a57da44eb6f 100644
--- a/arch/avr32/configs/atngw100_mrmt_defconfig
+++ b/arch/avr32/configs/atngw100_mrmt_defconfig
@@ -48,7 +48,6 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
48# CONFIG_PREVENT_FIRMWARE_BUILD is not set 48# CONFIG_PREVENT_FIRMWARE_BUILD is not set
49# CONFIG_FW_LOADER is not set 49# CONFIG_FW_LOADER is not set
50CONFIG_MTD=y 50CONFIG_MTD=y
51CONFIG_MTD_PARTITIONS=y
52CONFIG_MTD_CMDLINE_PARTS=y 51CONFIG_MTD_CMDLINE_PARTS=y
53CONFIG_MTD_CHAR=y 52CONFIG_MTD_CHAR=y
54CONFIG_MTD_BLOCK=y 53CONFIG_MTD_BLOCK=y
diff --git a/arch/avr32/configs/atngw100mkii_defconfig b/arch/avr32/configs/atngw100mkii_defconfig
index 2518a1368d7c..97fe1b399b06 100644
--- a/arch/avr32/configs/atngw100mkii_defconfig
+++ b/arch/avr32/configs/atngw100mkii_defconfig
@@ -59,7 +59,6 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
59# CONFIG_PREVENT_FIRMWARE_BUILD is not set 59# CONFIG_PREVENT_FIRMWARE_BUILD is not set
60# CONFIG_FW_LOADER is not set 60# CONFIG_FW_LOADER is not set
61CONFIG_MTD=y 61CONFIG_MTD=y
62CONFIG_MTD_PARTITIONS=y
63CONFIG_MTD_CMDLINE_PARTS=y 62CONFIG_MTD_CMDLINE_PARTS=y
64CONFIG_MTD_CHAR=y 63CONFIG_MTD_CHAR=y
65CONFIG_MTD_BLOCK=y 64CONFIG_MTD_BLOCK=y
diff --git a/arch/avr32/configs/atngw100mkii_evklcd100_defconfig b/arch/avr32/configs/atngw100mkii_evklcd100_defconfig
index 245ef6bd0fa6..a176d24467e9 100644
--- a/arch/avr32/configs/atngw100mkii_evklcd100_defconfig
+++ b/arch/avr32/configs/atngw100mkii_evklcd100_defconfig
@@ -62,7 +62,6 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
62# CONFIG_PREVENT_FIRMWARE_BUILD is not set 62# CONFIG_PREVENT_FIRMWARE_BUILD is not set
63# CONFIG_FW_LOADER is not set 63# CONFIG_FW_LOADER is not set
64CONFIG_MTD=y 64CONFIG_MTD=y
65CONFIG_MTD_PARTITIONS=y
66CONFIG_MTD_CMDLINE_PARTS=y 65CONFIG_MTD_CMDLINE_PARTS=y
67CONFIG_MTD_CHAR=y 66CONFIG_MTD_CHAR=y
68CONFIG_MTD_BLOCK=y 67CONFIG_MTD_BLOCK=y
diff --git a/arch/avr32/configs/atngw100mkii_evklcd101_defconfig b/arch/avr32/configs/atngw100mkii_evklcd101_defconfig
index fa6cbac6e418..d1bf6dcfc47d 100644
--- a/arch/avr32/configs/atngw100mkii_evklcd101_defconfig
+++ b/arch/avr32/configs/atngw100mkii_evklcd101_defconfig
@@ -61,7 +61,6 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
61# CONFIG_PREVENT_FIRMWARE_BUILD is not set 61# CONFIG_PREVENT_FIRMWARE_BUILD is not set
62# CONFIG_FW_LOADER is not set 62# CONFIG_FW_LOADER is not set
63CONFIG_MTD=y 63CONFIG_MTD=y
64CONFIG_MTD_PARTITIONS=y
65CONFIG_MTD_CMDLINE_PARTS=y 64CONFIG_MTD_CMDLINE_PARTS=y
66CONFIG_MTD_CHAR=y 65CONFIG_MTD_CHAR=y
67CONFIG_MTD_BLOCK=y 66CONFIG_MTD_BLOCK=y
diff --git a/arch/avr32/configs/atstk1002_defconfig b/arch/avr32/configs/atstk1002_defconfig
index bbd5131021a5..2813dd2b9138 100644
--- a/arch/avr32/configs/atstk1002_defconfig
+++ b/arch/avr32/configs/atstk1002_defconfig
@@ -53,7 +53,6 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
53# CONFIG_PREVENT_FIRMWARE_BUILD is not set 53# CONFIG_PREVENT_FIRMWARE_BUILD is not set
54# CONFIG_FW_LOADER is not set 54# CONFIG_FW_LOADER is not set
55CONFIG_MTD=y 55CONFIG_MTD=y
56CONFIG_MTD_PARTITIONS=y
57CONFIG_MTD_CMDLINE_PARTS=y 56CONFIG_MTD_CMDLINE_PARTS=y
58CONFIG_MTD_CHAR=y 57CONFIG_MTD_CHAR=y
59CONFIG_MTD_BLOCK=y 58CONFIG_MTD_BLOCK=y
diff --git a/arch/avr32/configs/atstk1003_defconfig b/arch/avr32/configs/atstk1003_defconfig
index c1cd726f9012..f8ff3a3baad4 100644
--- a/arch/avr32/configs/atstk1003_defconfig
+++ b/arch/avr32/configs/atstk1003_defconfig
@@ -42,7 +42,6 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
42# CONFIG_PREVENT_FIRMWARE_BUILD is not set 42# CONFIG_PREVENT_FIRMWARE_BUILD is not set
43# CONFIG_FW_LOADER is not set 43# CONFIG_FW_LOADER is not set
44CONFIG_MTD=y 44CONFIG_MTD=y
45CONFIG_MTD_PARTITIONS=y
46CONFIG_MTD_CMDLINE_PARTS=y 45CONFIG_MTD_CMDLINE_PARTS=y
47CONFIG_MTD_CHAR=y 46CONFIG_MTD_CHAR=y
48CONFIG_MTD_BLOCK=y 47CONFIG_MTD_BLOCK=y
diff --git a/arch/avr32/configs/atstk1004_defconfig b/arch/avr32/configs/atstk1004_defconfig
index 754ae56b2767..992228e54e38 100644
--- a/arch/avr32/configs/atstk1004_defconfig
+++ b/arch/avr32/configs/atstk1004_defconfig
@@ -42,7 +42,6 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
42# CONFIG_PREVENT_FIRMWARE_BUILD is not set 42# CONFIG_PREVENT_FIRMWARE_BUILD is not set
43# CONFIG_FW_LOADER is not set 43# CONFIG_FW_LOADER is not set
44CONFIG_MTD=y 44CONFIG_MTD=y
45CONFIG_MTD_PARTITIONS=y
46CONFIG_MTD_CMDLINE_PARTS=y 45CONFIG_MTD_CMDLINE_PARTS=y
47CONFIG_MTD_CHAR=y 46CONFIG_MTD_CHAR=y
48CONFIG_MTD_BLOCK=y 47CONFIG_MTD_BLOCK=y
diff --git a/arch/avr32/configs/atstk1006_defconfig b/arch/avr32/configs/atstk1006_defconfig
index 58589d8cc0ac..b8e698b0d1fa 100644
--- a/arch/avr32/configs/atstk1006_defconfig
+++ b/arch/avr32/configs/atstk1006_defconfig
@@ -54,7 +54,6 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
54# CONFIG_PREVENT_FIRMWARE_BUILD is not set 54# CONFIG_PREVENT_FIRMWARE_BUILD is not set
55# CONFIG_FW_LOADER is not set 55# CONFIG_FW_LOADER is not set
56CONFIG_MTD=y 56CONFIG_MTD=y
57CONFIG_MTD_PARTITIONS=y
58CONFIG_MTD_CMDLINE_PARTS=y 57CONFIG_MTD_CMDLINE_PARTS=y
59CONFIG_MTD_CHAR=y 58CONFIG_MTD_CHAR=y
60CONFIG_MTD_BLOCK=y 59CONFIG_MTD_BLOCK=y
diff --git a/arch/avr32/configs/favr-32_defconfig b/arch/avr32/configs/favr-32_defconfig
index c90fbf6d35bc..07bed3f7eb5e 100644
--- a/arch/avr32/configs/favr-32_defconfig
+++ b/arch/avr32/configs/favr-32_defconfig
@@ -58,7 +58,6 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
58# CONFIG_PREVENT_FIRMWARE_BUILD is not set 58# CONFIG_PREVENT_FIRMWARE_BUILD is not set
59# CONFIG_FW_LOADER is not set 59# CONFIG_FW_LOADER is not set
60CONFIG_MTD=y 60CONFIG_MTD=y
61CONFIG_MTD_PARTITIONS=y
62CONFIG_MTD_CMDLINE_PARTS=y 61CONFIG_MTD_CMDLINE_PARTS=y
63CONFIG_MTD_CHAR=y 62CONFIG_MTD_CHAR=y
64CONFIG_MTD_BLOCK=y 63CONFIG_MTD_BLOCK=y
diff --git a/arch/avr32/configs/hammerhead_defconfig b/arch/avr32/configs/hammerhead_defconfig
index ba7c31e269cb..18db853386c8 100644
--- a/arch/avr32/configs/hammerhead_defconfig
+++ b/arch/avr32/configs/hammerhead_defconfig
@@ -58,7 +58,6 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
58# CONFIG_PREVENT_FIRMWARE_BUILD is not set 58# CONFIG_PREVENT_FIRMWARE_BUILD is not set
59# CONFIG_FW_LOADER is not set 59# CONFIG_FW_LOADER is not set
60CONFIG_MTD=y 60CONFIG_MTD=y
61CONFIG_MTD_PARTITIONS=y
62CONFIG_MTD_CMDLINE_PARTS=y 61CONFIG_MTD_CMDLINE_PARTS=y
63CONFIG_MTD_CHAR=y 62CONFIG_MTD_CHAR=y
64CONFIG_MTD_BLOCK=y 63CONFIG_MTD_BLOCK=y
diff --git a/arch/avr32/configs/merisc_defconfig b/arch/avr32/configs/merisc_defconfig
index 65de4431108c..91df6b2986be 100644
--- a/arch/avr32/configs/merisc_defconfig
+++ b/arch/avr32/configs/merisc_defconfig
@@ -46,7 +46,6 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
46# CONFIG_FW_LOADER is not set 46# CONFIG_FW_LOADER is not set
47CONFIG_MTD=y 47CONFIG_MTD=y
48CONFIG_MTD_CONCAT=y 48CONFIG_MTD_CONCAT=y
49CONFIG_MTD_PARTITIONS=y
50CONFIG_MTD_CHAR=y 49CONFIG_MTD_CHAR=y
51CONFIG_MTD_BLOCK=y 50CONFIG_MTD_BLOCK=y
52CONFIG_MTD_CFI=y 51CONFIG_MTD_CFI=y
diff --git a/arch/avr32/configs/mimc200_defconfig b/arch/avr32/configs/mimc200_defconfig
index 0a8bfdc420e0..d630e089dd32 100644
--- a/arch/avr32/configs/mimc200_defconfig
+++ b/arch/avr32/configs/mimc200_defconfig
@@ -49,7 +49,6 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
49# CONFIG_PREVENT_FIRMWARE_BUILD is not set 49# CONFIG_PREVENT_FIRMWARE_BUILD is not set
50# CONFIG_FW_LOADER is not set 50# CONFIG_FW_LOADER is not set
51CONFIG_MTD=y 51CONFIG_MTD=y
52CONFIG_MTD_PARTITIONS=y
53CONFIG_MTD_CMDLINE_PARTS=y 52CONFIG_MTD_CMDLINE_PARTS=y
54CONFIG_MTD_CHAR=y 53CONFIG_MTD_CHAR=y
55CONFIG_MTD_BLOCK=y 54CONFIG_MTD_BLOCK=y
diff --git a/arch/avr32/kernel/time.c b/arch/avr32/kernel/time.c
index 12f828ad5058..d0f771be9e96 100644
--- a/arch/avr32/kernel/time.c
+++ b/arch/avr32/kernel/time.c
@@ -59,7 +59,7 @@ static irqreturn_t timer_interrupt(int irq, void *dev_id)
59static struct irqaction timer_irqaction = { 59static struct irqaction timer_irqaction = {
60 .handler = timer_interrupt, 60 .handler = timer_interrupt,
61 /* Oprofile uses the same irq as the timer, so allow it to be shared */ 61 /* Oprofile uses the same irq as the timer, so allow it to be shared */
62 .flags = IRQF_TIMER | IRQF_DISABLED | IRQF_SHARED, 62 .flags = IRQF_TIMER | IRQF_SHARED,
63 .name = "avr32_comparator", 63 .name = "avr32_comparator",
64}; 64};
65 65
diff --git a/arch/avr32/mach-at32ap/pm.c b/arch/avr32/mach-at32ap/pm.c
index 32d680eb6f48..db190842b80c 100644
--- a/arch/avr32/mach-at32ap/pm.c
+++ b/arch/avr32/mach-at32ap/pm.c
@@ -181,7 +181,7 @@ static const struct platform_suspend_ops avr32_pm_ops = {
181 .enter = avr32_pm_enter, 181 .enter = avr32_pm_enter,
182}; 182};
183 183
184static unsigned long avr32_pm_offset(void *symbol) 184static unsigned long __init avr32_pm_offset(void *symbol)
185{ 185{
186 extern u8 pm_exception[]; 186 extern u8 pm_exception[];
187 187
diff --git a/arch/powerpc/boot/dts/mpc5121.dtsi b/arch/powerpc/boot/dts/mpc5121.dtsi
index bd14c00e5146..2d7cb04ac962 100644
--- a/arch/powerpc/boot/dts/mpc5121.dtsi
+++ b/arch/powerpc/boot/dts/mpc5121.dtsi
@@ -77,7 +77,6 @@
77 compatible = "fsl,mpc5121-immr"; 77 compatible = "fsl,mpc5121-immr";
78 #address-cells = <1>; 78 #address-cells = <1>;
79 #size-cells = <1>; 79 #size-cells = <1>;
80 #interrupt-cells = <2>;
81 ranges = <0x0 0x80000000 0x400000>; 80 ranges = <0x0 0x80000000 0x400000>;
82 reg = <0x80000000 0x400000>; 81 reg = <0x80000000 0x400000>;
83 bus-frequency = <66000000>; /* 66 MHz ips bus */ 82 bus-frequency = <66000000>; /* 66 MHz ips bus */
diff --git a/arch/powerpc/configs/52xx/cm5200_defconfig b/arch/powerpc/configs/52xx/cm5200_defconfig
index 69b57daf402e..0b88c7b30bb9 100644
--- a/arch/powerpc/configs/52xx/cm5200_defconfig
+++ b/arch/powerpc/configs/52xx/cm5200_defconfig
@@ -12,7 +12,6 @@ CONFIG_EXPERT=y
12CONFIG_PPC_MPC52xx=y 12CONFIG_PPC_MPC52xx=y
13CONFIG_PPC_MPC5200_SIMPLE=y 13CONFIG_PPC_MPC5200_SIMPLE=y
14# CONFIG_PPC_PMAC is not set 14# CONFIG_PPC_PMAC is not set
15CONFIG_PPC_BESTCOMM=y
16CONFIG_SPARSE_IRQ=y 15CONFIG_SPARSE_IRQ=y
17CONFIG_PM=y 16CONFIG_PM=y
18# CONFIG_PCI is not set 17# CONFIG_PCI is not set
@@ -71,6 +70,8 @@ CONFIG_USB_DEVICEFS=y
71CONFIG_USB_OHCI_HCD=y 70CONFIG_USB_OHCI_HCD=y
72CONFIG_USB_OHCI_HCD_PPC_OF_BE=y 71CONFIG_USB_OHCI_HCD_PPC_OF_BE=y
73CONFIG_USB_STORAGE=y 72CONFIG_USB_STORAGE=y
73CONFIG_DMADEVICES=y
74CONFIG_PPC_BESTCOMM=y
74CONFIG_EXT2_FS=y 75CONFIG_EXT2_FS=y
75CONFIG_EXT3_FS=y 76CONFIG_EXT3_FS=y
76# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set 77# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
diff --git a/arch/powerpc/configs/52xx/lite5200b_defconfig b/arch/powerpc/configs/52xx/lite5200b_defconfig
index f3638ae0a627..104a332e79ab 100644
--- a/arch/powerpc/configs/52xx/lite5200b_defconfig
+++ b/arch/powerpc/configs/52xx/lite5200b_defconfig
@@ -15,7 +15,6 @@ CONFIG_PPC_MPC52xx=y
15CONFIG_PPC_MPC5200_SIMPLE=y 15CONFIG_PPC_MPC5200_SIMPLE=y
16CONFIG_PPC_LITE5200=y 16CONFIG_PPC_LITE5200=y
17# CONFIG_PPC_PMAC is not set 17# CONFIG_PPC_PMAC is not set
18CONFIG_PPC_BESTCOMM=y
19CONFIG_NO_HZ=y 18CONFIG_NO_HZ=y
20CONFIG_HIGH_RES_TIMERS=y 19CONFIG_HIGH_RES_TIMERS=y
21CONFIG_SPARSE_IRQ=y 20CONFIG_SPARSE_IRQ=y
@@ -59,6 +58,8 @@ CONFIG_I2C_CHARDEV=y
59CONFIG_I2C_MPC=y 58CONFIG_I2C_MPC=y
60# CONFIG_HWMON is not set 59# CONFIG_HWMON is not set
61CONFIG_VIDEO_OUTPUT_CONTROL=m 60CONFIG_VIDEO_OUTPUT_CONTROL=m
61CONFIG_DMADEVICES=y
62CONFIG_PPC_BESTCOMM=y
62CONFIG_EXT2_FS=y 63CONFIG_EXT2_FS=y
63CONFIG_EXT3_FS=y 64CONFIG_EXT3_FS=y
64# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set 65# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
diff --git a/arch/powerpc/configs/52xx/motionpro_defconfig b/arch/powerpc/configs/52xx/motionpro_defconfig
index 0c7de9620ea6..0d13ad7e4478 100644
--- a/arch/powerpc/configs/52xx/motionpro_defconfig
+++ b/arch/powerpc/configs/52xx/motionpro_defconfig
@@ -12,7 +12,6 @@ CONFIG_EXPERT=y
12CONFIG_PPC_MPC52xx=y 12CONFIG_PPC_MPC52xx=y
13CONFIG_PPC_MPC5200_SIMPLE=y 13CONFIG_PPC_MPC5200_SIMPLE=y
14# CONFIG_PPC_PMAC is not set 14# CONFIG_PPC_PMAC is not set
15CONFIG_PPC_BESTCOMM=y
16CONFIG_SPARSE_IRQ=y 15CONFIG_SPARSE_IRQ=y
17CONFIG_PM=y 16CONFIG_PM=y
18# CONFIG_PCI is not set 17# CONFIG_PCI is not set
@@ -84,6 +83,8 @@ CONFIG_LEDS_TRIGGERS=y
84CONFIG_LEDS_TRIGGER_TIMER=y 83CONFIG_LEDS_TRIGGER_TIMER=y
85CONFIG_RTC_CLASS=y 84CONFIG_RTC_CLASS=y
86CONFIG_RTC_DRV_DS1307=y 85CONFIG_RTC_DRV_DS1307=y
86CONFIG_DMADEVICES=y
87CONFIG_PPC_BESTCOMM=y
87CONFIG_EXT2_FS=y 88CONFIG_EXT2_FS=y
88CONFIG_EXT3_FS=y 89CONFIG_EXT3_FS=y
89# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set 90# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
diff --git a/arch/powerpc/configs/52xx/pcm030_defconfig b/arch/powerpc/configs/52xx/pcm030_defconfig
index 22e719575c60..430aa182fa1c 100644
--- a/arch/powerpc/configs/52xx/pcm030_defconfig
+++ b/arch/powerpc/configs/52xx/pcm030_defconfig
@@ -21,7 +21,6 @@ CONFIG_MODULE_UNLOAD=y
21CONFIG_PPC_MPC52xx=y 21CONFIG_PPC_MPC52xx=y
22CONFIG_PPC_MPC5200_SIMPLE=y 22CONFIG_PPC_MPC5200_SIMPLE=y
23# CONFIG_PPC_PMAC is not set 23# CONFIG_PPC_PMAC is not set
24CONFIG_PPC_BESTCOMM=y
25CONFIG_NO_HZ=y 24CONFIG_NO_HZ=y
26CONFIG_HIGH_RES_TIMERS=y 25CONFIG_HIGH_RES_TIMERS=y
27CONFIG_HZ_100=y 26CONFIG_HZ_100=y
@@ -87,6 +86,8 @@ CONFIG_USB_OHCI_HCD_PPC_OF_BE=y
87CONFIG_USB_STORAGE=m 86CONFIG_USB_STORAGE=m
88CONFIG_RTC_CLASS=y 87CONFIG_RTC_CLASS=y
89CONFIG_RTC_DRV_PCF8563=m 88CONFIG_RTC_DRV_PCF8563=m
89CONFIG_DMADEVICES=y
90CONFIG_PPC_BESTCOMM=y
90CONFIG_EXT2_FS=m 91CONFIG_EXT2_FS=m
91CONFIG_EXT3_FS=m 92CONFIG_EXT3_FS=m
92# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set 93# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
diff --git a/arch/powerpc/configs/52xx/tqm5200_defconfig b/arch/powerpc/configs/52xx/tqm5200_defconfig
index 716a37be16e3..7af4c5bb7c63 100644
--- a/arch/powerpc/configs/52xx/tqm5200_defconfig
+++ b/arch/powerpc/configs/52xx/tqm5200_defconfig
@@ -17,7 +17,6 @@ CONFIG_PPC_MPC52xx=y
17CONFIG_PPC_MPC5200_SIMPLE=y 17CONFIG_PPC_MPC5200_SIMPLE=y
18CONFIG_PPC_MPC5200_BUGFIX=y 18CONFIG_PPC_MPC5200_BUGFIX=y
19# CONFIG_PPC_PMAC is not set 19# CONFIG_PPC_PMAC is not set
20CONFIG_PPC_BESTCOMM=y
21CONFIG_PM=y 20CONFIG_PM=y
22# CONFIG_PCI is not set 21# CONFIG_PCI is not set
23CONFIG_NET=y 22CONFIG_NET=y
@@ -86,6 +85,8 @@ CONFIG_USB_STORAGE=y
86CONFIG_RTC_CLASS=y 85CONFIG_RTC_CLASS=y
87CONFIG_RTC_DRV_DS1307=y 86CONFIG_RTC_DRV_DS1307=y
88CONFIG_RTC_DRV_DS1374=y 87CONFIG_RTC_DRV_DS1374=y
88CONFIG_DMADEVICES=y
89CONFIG_PPC_BESTCOMM=y
89CONFIG_EXT2_FS=y 90CONFIG_EXT2_FS=y
90CONFIG_EXT3_FS=y 91CONFIG_EXT3_FS=y
91# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set 92# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
diff --git a/arch/powerpc/configs/mpc5200_defconfig b/arch/powerpc/configs/mpc5200_defconfig
index 6640a35bebb7..8b682d1cf4d6 100644
--- a/arch/powerpc/configs/mpc5200_defconfig
+++ b/arch/powerpc/configs/mpc5200_defconfig
@@ -15,7 +15,6 @@ CONFIG_PPC_MEDIA5200=y
15CONFIG_PPC_MPC5200_BUGFIX=y 15CONFIG_PPC_MPC5200_BUGFIX=y
16CONFIG_PPC_MPC5200_LPBFIFO=m 16CONFIG_PPC_MPC5200_LPBFIFO=m
17# CONFIG_PPC_PMAC is not set 17# CONFIG_PPC_PMAC is not set
18CONFIG_PPC_BESTCOMM=y
19CONFIG_SIMPLE_GPIO=y 18CONFIG_SIMPLE_GPIO=y
20CONFIG_NO_HZ=y 19CONFIG_NO_HZ=y
21CONFIG_HIGH_RES_TIMERS=y 20CONFIG_HIGH_RES_TIMERS=y
@@ -125,6 +124,8 @@ CONFIG_RTC_CLASS=y
125CONFIG_RTC_DRV_DS1307=y 124CONFIG_RTC_DRV_DS1307=y
126CONFIG_RTC_DRV_DS1374=y 125CONFIG_RTC_DRV_DS1374=y
127CONFIG_RTC_DRV_PCF8563=m 126CONFIG_RTC_DRV_PCF8563=m
127CONFIG_DMADEVICES=y
128CONFIG_PPC_BESTCOMM=y
128CONFIG_EXT2_FS=y 129CONFIG_EXT2_FS=y
129CONFIG_EXT3_FS=y 130CONFIG_EXT3_FS=y
130# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set 131# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
diff --git a/arch/powerpc/configs/pasemi_defconfig b/arch/powerpc/configs/pasemi_defconfig
index bd8a6f71944f..cec044a3ff69 100644
--- a/arch/powerpc/configs/pasemi_defconfig
+++ b/arch/powerpc/configs/pasemi_defconfig
@@ -2,7 +2,6 @@ CONFIG_PPC64=y
2CONFIG_ALTIVEC=y 2CONFIG_ALTIVEC=y
3CONFIG_SMP=y 3CONFIG_SMP=y
4CONFIG_NR_CPUS=2 4CONFIG_NR_CPUS=2
5CONFIG_EXPERIMENTAL=y
6CONFIG_SYSVIPC=y 5CONFIG_SYSVIPC=y
7CONFIG_NO_HZ=y 6CONFIG_NO_HZ=y
8CONFIG_HIGH_RES_TIMERS=y 7CONFIG_HIGH_RES_TIMERS=y
@@ -45,8 +44,9 @@ CONFIG_INET_AH=y
45CONFIG_INET_ESP=y 44CONFIG_INET_ESP=y
46# CONFIG_IPV6 is not set 45# CONFIG_IPV6 is not set
47CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 46CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
47CONFIG_DEVTMPFS=y
48CONFIG_DEVTMPFS_MOUNT=y
48CONFIG_MTD=y 49CONFIG_MTD=y
49CONFIG_MTD_CHAR=y
50CONFIG_MTD_BLOCK=y 50CONFIG_MTD_BLOCK=y
51CONFIG_MTD_SLRAM=y 51CONFIG_MTD_SLRAM=y
52CONFIG_MTD_PHRAM=y 52CONFIG_MTD_PHRAM=y
@@ -88,7 +88,6 @@ CONFIG_BLK_DEV_DM=y
88CONFIG_DM_CRYPT=y 88CONFIG_DM_CRYPT=y
89CONFIG_NETDEVICES=y 89CONFIG_NETDEVICES=y
90CONFIG_DUMMY=y 90CONFIG_DUMMY=y
91CONFIG_MII=y
92CONFIG_TIGON3=y 91CONFIG_TIGON3=y
93CONFIG_E1000=y 92CONFIG_E1000=y
94CONFIG_PASEMI_MAC=y 93CONFIG_PASEMI_MAC=y
@@ -174,8 +173,8 @@ CONFIG_NLS_CODEPAGE_437=y
174CONFIG_NLS_ISO8859_1=y 173CONFIG_NLS_ISO8859_1=y
175CONFIG_CRC_CCITT=y 174CONFIG_CRC_CCITT=y
176CONFIG_PRINTK_TIME=y 175CONFIG_PRINTK_TIME=y
177CONFIG_MAGIC_SYSRQ=y
178CONFIG_DEBUG_FS=y 176CONFIG_DEBUG_FS=y
177CONFIG_MAGIC_SYSRQ=y
179CONFIG_DEBUG_KERNEL=y 178CONFIG_DEBUG_KERNEL=y
180CONFIG_DETECT_HUNG_TASK=y 179CONFIG_DETECT_HUNG_TASK=y
181# CONFIG_SCHED_DEBUG is not set 180# CONFIG_SCHED_DEBUG is not set
diff --git a/arch/powerpc/include/asm/pgalloc-32.h b/arch/powerpc/include/asm/pgalloc-32.h
index 27b2386f738a..842846c1b711 100644
--- a/arch/powerpc/include/asm/pgalloc-32.h
+++ b/arch/powerpc/include/asm/pgalloc-32.h
@@ -84,10 +84,8 @@ static inline void pgtable_free_tlb(struct mmu_gather *tlb,
84static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t table, 84static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t table,
85 unsigned long address) 85 unsigned long address)
86{ 86{
87 struct page *page = page_address(table);
88
89 tlb_flush_pgtable(tlb, address); 87 tlb_flush_pgtable(tlb, address);
90 pgtable_page_dtor(page); 88 pgtable_page_dtor(table);
91 pgtable_free_tlb(tlb, page, 0); 89 pgtable_free_tlb(tlb, page_address(table), 0);
92} 90}
93#endif /* _ASM_POWERPC_PGALLOC_32_H */ 91#endif /* _ASM_POWERPC_PGALLOC_32_H */
diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
index 694012877bf7..4b0be20fcbfd 100644
--- a/arch/powerpc/include/asm/pgalloc-64.h
+++ b/arch/powerpc/include/asm/pgalloc-64.h
@@ -148,11 +148,9 @@ static inline void pgtable_free_tlb(struct mmu_gather *tlb,
148static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t table, 148static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t table,
149 unsigned long address) 149 unsigned long address)
150{ 150{
151 struct page *page = page_address(table);
152
153 tlb_flush_pgtable(tlb, address); 151 tlb_flush_pgtable(tlb, address);
154 pgtable_page_dtor(page); 152 pgtable_page_dtor(table);
155 pgtable_free_tlb(tlb, page, 0); 153 pgtable_free_tlb(tlb, page_address(table), 0);
156} 154}
157 155
158#else /* if CONFIG_PPC_64K_PAGES */ 156#else /* if CONFIG_PPC_64K_PAGES */
diff --git a/arch/powerpc/kernel/machine_kexec.c b/arch/powerpc/kernel/machine_kexec.c
index 88a7fb458dfd..75d4f7340da8 100644
--- a/arch/powerpc/kernel/machine_kexec.c
+++ b/arch/powerpc/kernel/machine_kexec.c
@@ -148,7 +148,7 @@ void __init reserve_crashkernel(void)
148 * a small SLB (128MB) since the crash kernel needs to place 148 * a small SLB (128MB) since the crash kernel needs to place
149 * itself and some stacks to be in the first segment. 149 * itself and some stacks to be in the first segment.
150 */ 150 */
151 crashk_res.start = min(0x80000000ULL, (ppc64_rma_size / 2)); 151 crashk_res.start = min(0x8000000ULL, (ppc64_rma_size / 2));
152#else 152#else
153 crashk_res.start = KDUMP_KERNELBASE; 153 crashk_res.start = KDUMP_KERNELBASE;
154#endif 154#endif
diff --git a/arch/powerpc/kernel/misc_64.S b/arch/powerpc/kernel/misc_64.S
index e59caf874d05..64bf8db12b15 100644
--- a/arch/powerpc/kernel/misc_64.S
+++ b/arch/powerpc/kernel/misc_64.S
@@ -246,8 +246,8 @@ _GLOBAL(__bswapdi2)
246 or r3,r7,r9 246 or r3,r7,r9
247 blr 247 blr
248 248
249#if defined(CONFIG_PPC_PMAC) || defined(CONFIG_PPC_MAPLE)
250 249
250#ifdef CONFIG_PPC_EARLY_DEBUG_BOOTX
251_GLOBAL(rmci_on) 251_GLOBAL(rmci_on)
252 sync 252 sync
253 isync 253 isync
@@ -277,6 +277,9 @@ _GLOBAL(rmci_off)
277 isync 277 isync
278 sync 278 sync
279 blr 279 blr
280#endif /* CONFIG_PPC_EARLY_DEBUG_BOOTX */
281
282#if defined(CONFIG_PPC_PMAC) || defined(CONFIG_PPC_MAPLE)
280 283
281/* 284/*
282 * Do an IO access in real mode 285 * Do an IO access in real mode
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index 084cdfa40682..2c6d173842b2 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -720,6 +720,7 @@ static void pnv_pci_ioda2_setup_dma_pe(struct pnv_phb *phb,
720 tbl->it_type = TCE_PCI_SWINV_CREATE | TCE_PCI_SWINV_FREE; 720 tbl->it_type = TCE_PCI_SWINV_CREATE | TCE_PCI_SWINV_FREE;
721 } 721 }
722 iommu_init_table(tbl, phb->hose->node); 722 iommu_init_table(tbl, phb->hose->node);
723 iommu_register_group(tbl, pci_domain_nr(pe->pbus), pe->pe_number);
723 724
724 if (pe->pdev) 725 if (pe->pdev)
725 set_iommu_table_base(&pe->pdev->dev, tbl); 726 set_iommu_table_base(&pe->pdev->dev, tbl);
diff --git a/arch/powerpc/sysdev/ppc4xx_ocm.c b/arch/powerpc/sysdev/ppc4xx_ocm.c
index b7c43453236d..85d9e37f5ccb 100644
--- a/arch/powerpc/sysdev/ppc4xx_ocm.c
+++ b/arch/powerpc/sysdev/ppc4xx_ocm.c
@@ -339,7 +339,7 @@ void *ppc4xx_ocm_alloc(phys_addr_t *phys, int size, int align,
339 if (IS_ERR_VALUE(offset)) 339 if (IS_ERR_VALUE(offset))
340 continue; 340 continue;
341 341
342 ocm_blk = kzalloc(sizeof(struct ocm_block *), GFP_KERNEL); 342 ocm_blk = kzalloc(sizeof(struct ocm_block), GFP_KERNEL);
343 if (!ocm_blk) { 343 if (!ocm_blk) {
344 printk(KERN_ERR "PPC4XX OCM: could not allocate ocm block"); 344 printk(KERN_ERR "PPC4XX OCM: could not allocate ocm block");
345 rh_free(ocm_reg->rh, offset); 345 rh_free(ocm_reg->rh, offset);
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 5877e71901b3..1e1a03d2d19f 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -347,14 +347,14 @@ config SMP
347 Even if you don't know what to do here, say Y. 347 Even if you don't know what to do here, say Y.
348 348
349config NR_CPUS 349config NR_CPUS
350 int "Maximum number of CPUs (2-64)" 350 int "Maximum number of CPUs (2-256)"
351 range 2 64 351 range 2 256
352 depends on SMP 352 depends on SMP
353 default "32" if !64BIT 353 default "32" if !64BIT
354 default "64" if 64BIT 354 default "64" if 64BIT
355 help 355 help
356 This allows you to specify the maximum number of CPUs which this 356 This allows you to specify the maximum number of CPUs which this
357 kernel will support. The maximum supported value is 64 and the 357 kernel will support. The maximum supported value is 256 and the
358 minimum value which makes sense is 2. 358 minimum value which makes sense is 2.
359 359
360 This is purely to save memory - each supported CPU adds 360 This is purely to save memory - each supported CPU adds
diff --git a/arch/s390/include/asm/sclp.h b/arch/s390/include/asm/sclp.h
index 30ef748bc161..2f390956c7c1 100644
--- a/arch/s390/include/asm/sclp.h
+++ b/arch/s390/include/asm/sclp.h
@@ -8,6 +8,7 @@
8 8
9#include <linux/types.h> 9#include <linux/types.h>
10#include <asm/chpid.h> 10#include <asm/chpid.h>
11#include <asm/cpu.h>
11 12
12#define SCLP_CHP_INFO_MASK_SIZE 32 13#define SCLP_CHP_INFO_MASK_SIZE 32
13 14
@@ -37,7 +38,7 @@ struct sclp_cpu_info {
37 unsigned int standby; 38 unsigned int standby;
38 unsigned int combined; 39 unsigned int combined;
39 int has_cpu_type; 40 int has_cpu_type;
40 struct sclp_cpu_entry cpu[255]; 41 struct sclp_cpu_entry cpu[MAX_CPU_ADDRESS + 1];
41}; 42};
42 43
43int sclp_get_cpu_info(struct sclp_cpu_info *info); 44int sclp_get_cpu_info(struct sclp_cpu_info *info);
diff --git a/arch/s390/kernel/asm-offsets.c b/arch/s390/kernel/asm-offsets.c
index 496116cd65ec..e4c99a183651 100644
--- a/arch/s390/kernel/asm-offsets.c
+++ b/arch/s390/kernel/asm-offsets.c
@@ -72,6 +72,7 @@ int main(void)
72 /* constants used by the vdso */ 72 /* constants used by the vdso */
73 DEFINE(__CLOCK_REALTIME, CLOCK_REALTIME); 73 DEFINE(__CLOCK_REALTIME, CLOCK_REALTIME);
74 DEFINE(__CLOCK_MONOTONIC, CLOCK_MONOTONIC); 74 DEFINE(__CLOCK_MONOTONIC, CLOCK_MONOTONIC);
75 DEFINE(__CLOCK_THREAD_CPUTIME_ID, CLOCK_THREAD_CPUTIME_ID);
75 DEFINE(__CLOCK_REALTIME_RES, MONOTONIC_RES_NSEC); 76 DEFINE(__CLOCK_REALTIME_RES, MONOTONIC_RES_NSEC);
76 BLANK(); 77 BLANK();
77 /* idle data offsets */ 78 /* idle data offsets */
diff --git a/arch/s390/kernel/vdso.c b/arch/s390/kernel/vdso.c
index a84476f2a9bb..613649096783 100644
--- a/arch/s390/kernel/vdso.c
+++ b/arch/s390/kernel/vdso.c
@@ -125,7 +125,7 @@ int vdso_alloc_per_cpu(struct _lowcore *lowcore)
125 psal[i] = 0x80000000; 125 psal[i] = 0x80000000;
126 126
127 lowcore->paste[4] = (u32)(addr_t) psal; 127 lowcore->paste[4] = (u32)(addr_t) psal;
128 psal[0] = 0x20000000; 128 psal[0] = 0x02000000;
129 psal[2] = (u32)(addr_t) aste; 129 psal[2] = (u32)(addr_t) aste;
130 *(unsigned long *) (aste + 2) = segment_table + 130 *(unsigned long *) (aste + 2) = segment_table +
131 _ASCE_TABLE_LENGTH + _ASCE_USER_BITS + _ASCE_TYPE_SEGMENT; 131 _ASCE_TABLE_LENGTH + _ASCE_USER_BITS + _ASCE_TYPE_SEGMENT;
diff --git a/arch/s390/kernel/vdso32/clock_gettime.S b/arch/s390/kernel/vdso32/clock_gettime.S
index 5be8e472f57d..65fc3979c2f1 100644
--- a/arch/s390/kernel/vdso32/clock_gettime.S
+++ b/arch/s390/kernel/vdso32/clock_gettime.S
@@ -46,18 +46,13 @@ __kernel_clock_gettime:
46 jnm 3f 46 jnm 3f
47 a %r0,__VDSO_TK_MULT(%r5) 47 a %r0,__VDSO_TK_MULT(%r5)
483: alr %r0,%r2 483: alr %r0,%r2
49 al %r0,__VDSO_XTIME_NSEC(%r5) /* + tk->xtime_nsec */ 49 al %r0,__VDSO_WTOM_NSEC(%r5)
50 al %r1,__VDSO_XTIME_NSEC+4(%r5)
51 brc 12,4f
52 ahi %r0,1
534: al %r0,__VDSO_WTOM_NSEC(%r5) /* + wall_to_monotonic.nsec */
54 al %r1,__VDSO_WTOM_NSEC+4(%r5) 50 al %r1,__VDSO_WTOM_NSEC+4(%r5)
55 brc 12,5f 51 brc 12,5f
56 ahi %r0,1 52 ahi %r0,1
575: l %r2,__VDSO_TK_SHIFT(%r5) /* Timekeeper shift */ 535: l %r2,__VDSO_TK_SHIFT(%r5) /* Timekeeper shift */
58 srdl %r0,0(%r2) /* >> tk->shift */ 54 srdl %r0,0(%r2) /* >> tk->shift */
59 l %r2,__VDSO_XTIME_SEC+4(%r5) 55 l %r2,__VDSO_WTOM_SEC+4(%r5)
60 al %r2,__VDSO_WTOM_SEC+4(%r5)
61 cl %r4,__VDSO_UPD_COUNT+4(%r5) /* check update counter */ 56 cl %r4,__VDSO_UPD_COUNT+4(%r5) /* check update counter */
62 jne 1b 57 jne 1b
63 basr %r5,0 58 basr %r5,0
diff --git a/arch/s390/kernel/vdso64/clock_getres.S b/arch/s390/kernel/vdso64/clock_getres.S
index 176e1f75f9aa..34deba7c7ed1 100644
--- a/arch/s390/kernel/vdso64/clock_getres.S
+++ b/arch/s390/kernel/vdso64/clock_getres.S
@@ -23,7 +23,9 @@ __kernel_clock_getres:
23 je 0f 23 je 0f
24 cghi %r2,__CLOCK_MONOTONIC 24 cghi %r2,__CLOCK_MONOTONIC
25 je 0f 25 je 0f
26 cghi %r2,-2 /* CLOCK_THREAD_CPUTIME_ID for this thread */ 26 cghi %r2,__CLOCK_THREAD_CPUTIME_ID
27 je 0f
28 cghi %r2,-2 /* Per-thread CPUCLOCK with PID=0, VIRT=1 */
27 jne 2f 29 jne 2f
28 larl %r5,_vdso_data 30 larl %r5,_vdso_data
29 icm %r0,15,__LC_ECTG_OK(%r5) 31 icm %r0,15,__LC_ECTG_OK(%r5)
diff --git a/arch/s390/kernel/vdso64/clock_gettime.S b/arch/s390/kernel/vdso64/clock_gettime.S
index 0add1072ba30..91940ed33a4a 100644
--- a/arch/s390/kernel/vdso64/clock_gettime.S
+++ b/arch/s390/kernel/vdso64/clock_gettime.S
@@ -22,7 +22,9 @@ __kernel_clock_gettime:
22 larl %r5,_vdso_data 22 larl %r5,_vdso_data
23 cghi %r2,__CLOCK_REALTIME 23 cghi %r2,__CLOCK_REALTIME
24 je 4f 24 je 4f
25 cghi %r2,-2 /* CLOCK_THREAD_CPUTIME_ID for this thread */ 25 cghi %r2,__CLOCK_THREAD_CPUTIME_ID
26 je 9f
27 cghi %r2,-2 /* Per-thread CPUCLOCK with PID=0, VIRT=1 */
26 je 9f 28 je 9f
27 cghi %r2,__CLOCK_MONOTONIC 29 cghi %r2,__CLOCK_MONOTONIC
28 jne 12f 30 jne 12f
@@ -35,13 +37,11 @@ __kernel_clock_gettime:
35 jnz 0b 37 jnz 0b
36 stck 48(%r15) /* Store TOD clock */ 38 stck 48(%r15) /* Store TOD clock */
37 lgf %r2,__VDSO_TK_SHIFT(%r5) /* Timekeeper shift */ 39 lgf %r2,__VDSO_TK_SHIFT(%r5) /* Timekeeper shift */
38 lg %r0,__VDSO_XTIME_SEC(%r5) /* tk->xtime_sec */ 40 lg %r0,__VDSO_WTOM_SEC(%r5)
39 alg %r0,__VDSO_WTOM_SEC(%r5) /* + wall_to_monotonic.sec */
40 lg %r1,48(%r15) 41 lg %r1,48(%r15)
41 sg %r1,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */ 42 sg %r1,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */
42 msgf %r1,__VDSO_TK_MULT(%r5) /* * tk->mult */ 43 msgf %r1,__VDSO_TK_MULT(%r5) /* * tk->mult */
43 alg %r1,__VDSO_XTIME_NSEC(%r5) /* + tk->xtime_nsec */ 44 alg %r1,__VDSO_WTOM_NSEC(%r5)
44 alg %r1,__VDSO_WTOM_NSEC(%r5) /* + wall_to_monotonic.nsec */
45 srlg %r1,%r1,0(%r2) /* >> tk->shift */ 45 srlg %r1,%r1,0(%r2) /* >> tk->shift */
46 clg %r4,__VDSO_UPD_COUNT(%r5) /* check update counter */ 46 clg %r4,__VDSO_UPD_COUNT(%r5) /* check update counter */
47 jne 0b 47 jne 0b
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index eda00f9be0cf..57d021507120 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -31,8 +31,8 @@ ifeq ($(CONFIG_X86_32),y)
31 31
32 KBUILD_CFLAGS += -msoft-float -mregparm=3 -freg-struct-return 32 KBUILD_CFLAGS += -msoft-float -mregparm=3 -freg-struct-return
33 33
34 # Don't autogenerate SSE instructions 34 # Don't autogenerate MMX or SSE instructions
35 KBUILD_CFLAGS += -mno-sse 35 KBUILD_CFLAGS += -mno-mmx -mno-sse
36 36
37 # Never want PIC in a 32-bit kernel, prevent breakage with GCC built 37 # Never want PIC in a 32-bit kernel, prevent breakage with GCC built
38 # with nonstandard options 38 # with nonstandard options
@@ -60,8 +60,8 @@ else
60 KBUILD_AFLAGS += -m64 60 KBUILD_AFLAGS += -m64
61 KBUILD_CFLAGS += -m64 61 KBUILD_CFLAGS += -m64
62 62
63 # Don't autogenerate SSE instructions 63 # Don't autogenerate MMX or SSE instructions
64 KBUILD_CFLAGS += -mno-sse 64 KBUILD_CFLAGS += -mno-mmx -mno-sse
65 65
66 # Use -mpreferred-stack-boundary=3 if supported. 66 # Use -mpreferred-stack-boundary=3 if supported.
67 KBUILD_CFLAGS += $(call cc-option,-mpreferred-stack-boundary=3) 67 KBUILD_CFLAGS += $(call cc-option,-mpreferred-stack-boundary=3)
diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
index dce69a256896..d9c11956fce0 100644
--- a/arch/x86/boot/Makefile
+++ b/arch/x86/boot/Makefile
@@ -53,18 +53,18 @@ $(obj)/cpustr.h: $(obj)/mkcpustr FORCE
53 53
54# How to compile the 16-bit code. Note we always compile for -march=i386, 54# How to compile the 16-bit code. Note we always compile for -march=i386,
55# that way we can complain to the user if the CPU is insufficient. 55# that way we can complain to the user if the CPU is insufficient.
56KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \ 56KBUILD_CFLAGS := $(USERINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ \
57 -DDISABLE_BRANCH_PROFILING \ 57 -DDISABLE_BRANCH_PROFILING \
58 -Wall -Wstrict-prototypes \ 58 -Wall -Wstrict-prototypes \
59 -march=i386 -mregparm=3 \ 59 -march=i386 -mregparm=3 \
60 -include $(srctree)/$(src)/code16gcc.h \ 60 -include $(srctree)/$(src)/code16gcc.h \
61 -fno-strict-aliasing -fomit-frame-pointer -fno-pic \ 61 -fno-strict-aliasing -fomit-frame-pointer -fno-pic \
62 -mno-mmx -mno-sse \
62 $(call cc-option, -ffreestanding) \ 63 $(call cc-option, -ffreestanding) \
63 $(call cc-option, -fno-toplevel-reorder,\ 64 $(call cc-option, -fno-toplevel-reorder,\
64 $(call cc-option, -fno-unit-at-a-time)) \ 65 $(call cc-option, -fno-unit-at-a-time)) \
65 $(call cc-option, -fno-stack-protector) \ 66 $(call cc-option, -fno-stack-protector) \
66 $(call cc-option, -mpreferred-stack-boundary=2) 67 $(call cc-option, -mpreferred-stack-boundary=2)
67KBUILD_CFLAGS += $(call cc-option, -m32)
68KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__ 68KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
69GCOV_PROFILE := n 69GCOV_PROFILE := n
70 70
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index dcd90df10ab4..c8a6792e7842 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -13,6 +13,7 @@ KBUILD_CFLAGS += -DDISABLE_BRANCH_PROFILING
13cflags-$(CONFIG_X86_32) := -march=i386 13cflags-$(CONFIG_X86_32) := -march=i386
14cflags-$(CONFIG_X86_64) := -mcmodel=small 14cflags-$(CONFIG_X86_64) := -mcmodel=small
15KBUILD_CFLAGS += $(cflags-y) 15KBUILD_CFLAGS += $(cflags-y)
16KBUILD_CFLAGS += -mno-mmx -mno-sse
16KBUILD_CFLAGS += $(call cc-option,-ffreestanding) 17KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
17KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector) 18KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
18 19
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index 5439117d5c4c..dec48bfaddb8 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -143,6 +143,8 @@ static inline int kvm_apic_id(struct kvm_lapic *apic)
143 return (kvm_apic_get_reg(apic, APIC_ID) >> 24) & 0xff; 143 return (kvm_apic_get_reg(apic, APIC_ID) >> 24) & 0xff;
144} 144}
145 145
146#define KVM_X2APIC_CID_BITS 0
147
146static void recalculate_apic_map(struct kvm *kvm) 148static void recalculate_apic_map(struct kvm *kvm)
147{ 149{
148 struct kvm_apic_map *new, *old = NULL; 150 struct kvm_apic_map *new, *old = NULL;
@@ -180,7 +182,8 @@ static void recalculate_apic_map(struct kvm *kvm)
180 if (apic_x2apic_mode(apic)) { 182 if (apic_x2apic_mode(apic)) {
181 new->ldr_bits = 32; 183 new->ldr_bits = 32;
182 new->cid_shift = 16; 184 new->cid_shift = 16;
183 new->cid_mask = new->lid_mask = 0xffff; 185 new->cid_mask = (1 << KVM_X2APIC_CID_BITS) - 1;
186 new->lid_mask = 0xffff;
184 } else if (kvm_apic_sw_enabled(apic) && 187 } else if (kvm_apic_sw_enabled(apic) &&
185 !new->cid_mask /* flat mode */ && 188 !new->cid_mask /* flat mode */ &&
186 kvm_apic_get_reg(apic, APIC_DFR) == APIC_DFR_CLUSTER) { 189 kvm_apic_get_reg(apic, APIC_DFR) == APIC_DFR_CLUSTER) {
@@ -841,7 +844,8 @@ static u32 apic_get_tmcct(struct kvm_lapic *apic)
841 ASSERT(apic != NULL); 844 ASSERT(apic != NULL);
842 845
843 /* if initial count is 0, current count should also be 0 */ 846 /* if initial count is 0, current count should also be 0 */
844 if (kvm_apic_get_reg(apic, APIC_TMICT) == 0) 847 if (kvm_apic_get_reg(apic, APIC_TMICT) == 0 ||
848 apic->lapic_timer.period == 0)
845 return 0; 849 return 0;
846 850
847 remaining = hrtimer_get_remaining(&apic->lapic_timer.timer); 851 remaining = hrtimer_get_remaining(&apic->lapic_timer.timer);
@@ -1691,7 +1695,6 @@ static void apic_sync_pv_eoi_from_guest(struct kvm_vcpu *vcpu,
1691void kvm_lapic_sync_from_vapic(struct kvm_vcpu *vcpu) 1695void kvm_lapic_sync_from_vapic(struct kvm_vcpu *vcpu)
1692{ 1696{
1693 u32 data; 1697 u32 data;
1694 void *vapic;
1695 1698
1696 if (test_bit(KVM_APIC_PV_EOI_PENDING, &vcpu->arch.apic_attention)) 1699 if (test_bit(KVM_APIC_PV_EOI_PENDING, &vcpu->arch.apic_attention))
1697 apic_sync_pv_eoi_from_guest(vcpu, vcpu->arch.apic); 1700 apic_sync_pv_eoi_from_guest(vcpu, vcpu->arch.apic);
@@ -1699,9 +1702,8 @@ void kvm_lapic_sync_from_vapic(struct kvm_vcpu *vcpu)
1699 if (!test_bit(KVM_APIC_CHECK_VAPIC, &vcpu->arch.apic_attention)) 1702 if (!test_bit(KVM_APIC_CHECK_VAPIC, &vcpu->arch.apic_attention))
1700 return; 1703 return;
1701 1704
1702 vapic = kmap_atomic(vcpu->arch.apic->vapic_page); 1705 kvm_read_guest_cached(vcpu->kvm, &vcpu->arch.apic->vapic_cache, &data,
1703 data = *(u32 *)(vapic + offset_in_page(vcpu->arch.apic->vapic_addr)); 1706 sizeof(u32));
1704 kunmap_atomic(vapic);
1705 1707
1706 apic_set_tpr(vcpu->arch.apic, data & 0xff); 1708 apic_set_tpr(vcpu->arch.apic, data & 0xff);
1707} 1709}
@@ -1737,7 +1739,6 @@ void kvm_lapic_sync_to_vapic(struct kvm_vcpu *vcpu)
1737 u32 data, tpr; 1739 u32 data, tpr;
1738 int max_irr, max_isr; 1740 int max_irr, max_isr;
1739 struct kvm_lapic *apic = vcpu->arch.apic; 1741 struct kvm_lapic *apic = vcpu->arch.apic;
1740 void *vapic;
1741 1742
1742 apic_sync_pv_eoi_to_guest(vcpu, apic); 1743 apic_sync_pv_eoi_to_guest(vcpu, apic);
1743 1744
@@ -1753,18 +1754,24 @@ void kvm_lapic_sync_to_vapic(struct kvm_vcpu *vcpu)
1753 max_isr = 0; 1754 max_isr = 0;
1754 data = (tpr & 0xff) | ((max_isr & 0xf0) << 8) | (max_irr << 24); 1755 data = (tpr & 0xff) | ((max_isr & 0xf0) << 8) | (max_irr << 24);
1755 1756
1756 vapic = kmap_atomic(vcpu->arch.apic->vapic_page); 1757 kvm_write_guest_cached(vcpu->kvm, &vcpu->arch.apic->vapic_cache, &data,
1757 *(u32 *)(vapic + offset_in_page(vcpu->arch.apic->vapic_addr)) = data; 1758 sizeof(u32));
1758 kunmap_atomic(vapic);
1759} 1759}
1760 1760
1761void kvm_lapic_set_vapic_addr(struct kvm_vcpu *vcpu, gpa_t vapic_addr) 1761int kvm_lapic_set_vapic_addr(struct kvm_vcpu *vcpu, gpa_t vapic_addr)
1762{ 1762{
1763 vcpu->arch.apic->vapic_addr = vapic_addr; 1763 if (vapic_addr) {
1764 if (vapic_addr) 1764 if (kvm_gfn_to_hva_cache_init(vcpu->kvm,
1765 &vcpu->arch.apic->vapic_cache,
1766 vapic_addr, sizeof(u32)))
1767 return -EINVAL;
1765 __set_bit(KVM_APIC_CHECK_VAPIC, &vcpu->arch.apic_attention); 1768 __set_bit(KVM_APIC_CHECK_VAPIC, &vcpu->arch.apic_attention);
1766 else 1769 } else {
1767 __clear_bit(KVM_APIC_CHECK_VAPIC, &vcpu->arch.apic_attention); 1770 __clear_bit(KVM_APIC_CHECK_VAPIC, &vcpu->arch.apic_attention);
1771 }
1772
1773 vcpu->arch.apic->vapic_addr = vapic_addr;
1774 return 0;
1768} 1775}
1769 1776
1770int kvm_x2apic_msr_write(struct kvm_vcpu *vcpu, u32 msr, u64 data) 1777int kvm_x2apic_msr_write(struct kvm_vcpu *vcpu, u32 msr, u64 data)
diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h
index c730ac9fe801..c8b0d0d2da5c 100644
--- a/arch/x86/kvm/lapic.h
+++ b/arch/x86/kvm/lapic.h
@@ -34,7 +34,7 @@ struct kvm_lapic {
34 */ 34 */
35 void *regs; 35 void *regs;
36 gpa_t vapic_addr; 36 gpa_t vapic_addr;
37 struct page *vapic_page; 37 struct gfn_to_hva_cache vapic_cache;
38 unsigned long pending_events; 38 unsigned long pending_events;
39 unsigned int sipi_vector; 39 unsigned int sipi_vector;
40}; 40};
@@ -76,7 +76,7 @@ void kvm_set_lapic_tscdeadline_msr(struct kvm_vcpu *vcpu, u64 data);
76void kvm_apic_write_nodecode(struct kvm_vcpu *vcpu, u32 offset); 76void kvm_apic_write_nodecode(struct kvm_vcpu *vcpu, u32 offset);
77void kvm_apic_set_eoi_accelerated(struct kvm_vcpu *vcpu, int vector); 77void kvm_apic_set_eoi_accelerated(struct kvm_vcpu *vcpu, int vector);
78 78
79void kvm_lapic_set_vapic_addr(struct kvm_vcpu *vcpu, gpa_t vapic_addr); 79int kvm_lapic_set_vapic_addr(struct kvm_vcpu *vcpu, gpa_t vapic_addr);
80void kvm_lapic_sync_from_vapic(struct kvm_vcpu *vcpu); 80void kvm_lapic_sync_from_vapic(struct kvm_vcpu *vcpu);
81void kvm_lapic_sync_to_vapic(struct kvm_vcpu *vcpu); 81void kvm_lapic_sync_to_vapic(struct kvm_vcpu *vcpu);
82 82
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 21ef1ba184ae..5d004da1e35d 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3214,8 +3214,7 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
3214 r = -EFAULT; 3214 r = -EFAULT;
3215 if (copy_from_user(&va, argp, sizeof va)) 3215 if (copy_from_user(&va, argp, sizeof va))
3216 goto out; 3216 goto out;
3217 r = 0; 3217 r = kvm_lapic_set_vapic_addr(vcpu, va.vapic_addr);
3218 kvm_lapic_set_vapic_addr(vcpu, va.vapic_addr);
3219 break; 3218 break;
3220 } 3219 }
3221 case KVM_X86_SETUP_MCE: { 3220 case KVM_X86_SETUP_MCE: {
@@ -5739,36 +5738,6 @@ static void post_kvm_run_save(struct kvm_vcpu *vcpu)
5739 !kvm_event_needs_reinjection(vcpu); 5738 !kvm_event_needs_reinjection(vcpu);
5740} 5739}
5741 5740
5742static int vapic_enter(struct kvm_vcpu *vcpu)
5743{
5744 struct kvm_lapic *apic = vcpu->arch.apic;
5745 struct page *page;
5746
5747 if (!apic || !apic->vapic_addr)
5748 return 0;
5749
5750 page = gfn_to_page(vcpu->kvm, apic->vapic_addr >> PAGE_SHIFT);
5751 if (is_error_page(page))
5752 return -EFAULT;
5753
5754 vcpu->arch.apic->vapic_page = page;
5755 return 0;
5756}
5757
5758static void vapic_exit(struct kvm_vcpu *vcpu)
5759{
5760 struct kvm_lapic *apic = vcpu->arch.apic;
5761 int idx;
5762
5763 if (!apic || !apic->vapic_addr)
5764 return;
5765
5766 idx = srcu_read_lock(&vcpu->kvm->srcu);
5767 kvm_release_page_dirty(apic->vapic_page);
5768 mark_page_dirty(vcpu->kvm, apic->vapic_addr >> PAGE_SHIFT);
5769 srcu_read_unlock(&vcpu->kvm->srcu, idx);
5770}
5771
5772static void update_cr8_intercept(struct kvm_vcpu *vcpu) 5741static void update_cr8_intercept(struct kvm_vcpu *vcpu)
5773{ 5742{
5774 int max_irr, tpr; 5743 int max_irr, tpr;
@@ -6069,11 +6038,6 @@ static int __vcpu_run(struct kvm_vcpu *vcpu)
6069 struct kvm *kvm = vcpu->kvm; 6038 struct kvm *kvm = vcpu->kvm;
6070 6039
6071 vcpu->srcu_idx = srcu_read_lock(&kvm->srcu); 6040 vcpu->srcu_idx = srcu_read_lock(&kvm->srcu);
6072 r = vapic_enter(vcpu);
6073 if (r) {
6074 srcu_read_unlock(&kvm->srcu, vcpu->srcu_idx);
6075 return r;
6076 }
6077 6041
6078 r = 1; 6042 r = 1;
6079 while (r > 0) { 6043 while (r > 0) {
@@ -6132,8 +6096,6 @@ static int __vcpu_run(struct kvm_vcpu *vcpu)
6132 6096
6133 srcu_read_unlock(&kvm->srcu, vcpu->srcu_idx); 6097 srcu_read_unlock(&kvm->srcu, vcpu->srcu_idx);
6134 6098
6135 vapic_exit(vcpu);
6136
6137 return r; 6099 return r;
6138} 6100}
6139 6101
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 92c02344a060..cceb813044ef 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -690,13 +690,6 @@ void __init efi_init(void)
690 690
691 set_bit(EFI_MEMMAP, &x86_efi_facility); 691 set_bit(EFI_MEMMAP, &x86_efi_facility);
692 692
693#ifdef CONFIG_X86_32
694 if (efi_is_native()) {
695 x86_platform.get_wallclock = efi_get_time;
696 x86_platform.set_wallclock = efi_set_rtc_mmss;
697 }
698#endif
699
700#if EFI_DEBUG 693#if EFI_DEBUG
701 print_efi_memmap(); 694 print_efi_memmap();
702#endif 695#endif
diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index 0f92173a12b6..efe4d7220397 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -1070,12 +1070,13 @@ const struct cpumask *uv_flush_tlb_others(const struct cpumask *cpumask,
1070 unsigned long status; 1070 unsigned long status;
1071 1071
1072 bcp = &per_cpu(bau_control, cpu); 1072 bcp = &per_cpu(bau_control, cpu);
1073 stat = bcp->statp;
1074 stat->s_enters++;
1075 1073
1076 if (bcp->nobau) 1074 if (bcp->nobau)
1077 return cpumask; 1075 return cpumask;
1078 1076
1077 stat = bcp->statp;
1078 stat->s_enters++;
1079
1079 if (bcp->busy) { 1080 if (bcp->busy) {
1080 descriptor_status = 1081 descriptor_status =
1081 read_lmmr(UVH_LB_BAU_SB_ACTIVATION_STATUS_0); 1082 read_lmmr(UVH_LB_BAU_SB_ACTIVATION_STATUS_0);
diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
index 88692871823f..9cac82588cbc 100644
--- a/arch/x86/realmode/rm/Makefile
+++ b/arch/x86/realmode/rm/Makefile
@@ -73,9 +73,10 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
73 -march=i386 -mregparm=3 \ 73 -march=i386 -mregparm=3 \
74 -include $(srctree)/$(src)/../../boot/code16gcc.h \ 74 -include $(srctree)/$(src)/../../boot/code16gcc.h \
75 -fno-strict-aliasing -fomit-frame-pointer -fno-pic \ 75 -fno-strict-aliasing -fomit-frame-pointer -fno-pic \
76 -mno-mmx -mno-sse \
76 $(call cc-option, -ffreestanding) \ 77 $(call cc-option, -ffreestanding) \
77 $(call cc-option, -fno-toplevel-reorder,\ 78 $(call cc-option, -fno-toplevel-reorder,\
78 $(call cc-option, -fno-unit-at-a-time)) \ 79 $(call cc-option, -fno-unit-at-a-time)) \
79 $(call cc-option, -fno-stack-protector) \ 80 $(call cc-option, -fno-stack-protector) \
80 $(call cc-option, -mpreferred-stack-boundary=2) 81 $(call cc-option, -mpreferred-stack-boundary=2)
81KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__ 82KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
diff --git a/drivers/Makefile b/drivers/Makefile
index 3cc8214f9b26..8e3b8b06c0b2 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -118,7 +118,7 @@ obj-$(CONFIG_SGI_SN) += sn/
118obj-y += firmware/ 118obj-y += firmware/
119obj-$(CONFIG_CRYPTO) += crypto/ 119obj-$(CONFIG_CRYPTO) += crypto/
120obj-$(CONFIG_SUPERH) += sh/ 120obj-$(CONFIG_SUPERH) += sh/
121obj-$(CONFIG_ARCH_SHMOBILE) += sh/ 121obj-$(CONFIG_ARCH_SHMOBILE_LEGACY) += sh/
122ifndef CONFIG_ARCH_USES_GETTIMEOFFSET 122ifndef CONFIG_ARCH_USES_GETTIMEOFFSET
123obj-y += clocksource/ 123obj-y += clocksource/
124endif 124endif
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index e3219dfd736c..1b41fca3d65a 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -29,7 +29,6 @@
29#include <linux/async.h> 29#include <linux/async.h>
30#include <linux/suspend.h> 30#include <linux/suspend.h>
31#include <trace/events/power.h> 31#include <trace/events/power.h>
32#include <linux/cpufreq.h>
33#include <linux/cpuidle.h> 32#include <linux/cpuidle.h>
34#include <linux/timer.h> 33#include <linux/timer.h>
35 34
@@ -541,7 +540,6 @@ static void dpm_resume_noirq(pm_message_t state)
541 dpm_show_time(starttime, state, "noirq"); 540 dpm_show_time(starttime, state, "noirq");
542 resume_device_irqs(); 541 resume_device_irqs();
543 cpuidle_resume(); 542 cpuidle_resume();
544 cpufreq_resume();
545} 543}
546 544
547/** 545/**
@@ -957,7 +955,6 @@ static int dpm_suspend_noirq(pm_message_t state)
957 ktime_t starttime = ktime_get(); 955 ktime_t starttime = ktime_get();
958 int error = 0; 956 int error = 0;
959 957
960 cpufreq_suspend();
961 cpuidle_pause(); 958 cpuidle_pause();
962 suspend_device_irqs(); 959 suspend_device_irqs();
963 mutex_lock(&dpm_list_mtx); 960 mutex_lock(&dpm_list_mtx);
diff --git a/drivers/base/regmap/regmap-mmio.c b/drivers/base/regmap/regmap-mmio.c
index 98745dd77e8c..81f977510775 100644
--- a/drivers/base/regmap/regmap-mmio.c
+++ b/drivers/base/regmap/regmap-mmio.c
@@ -40,7 +40,7 @@ static int regmap_mmio_gather_write(void *context,
40 40
41 BUG_ON(reg_size != 4); 41 BUG_ON(reg_size != 4);
42 42
43 if (ctx->clk) { 43 if (!IS_ERR(ctx->clk)) {
44 ret = clk_enable(ctx->clk); 44 ret = clk_enable(ctx->clk);
45 if (ret < 0) 45 if (ret < 0)
46 return ret; 46 return ret;
@@ -73,7 +73,7 @@ static int regmap_mmio_gather_write(void *context,
73 offset += ctx->val_bytes; 73 offset += ctx->val_bytes;
74 } 74 }
75 75
76 if (ctx->clk) 76 if (!IS_ERR(ctx->clk))
77 clk_disable(ctx->clk); 77 clk_disable(ctx->clk);
78 78
79 return 0; 79 return 0;
@@ -96,7 +96,7 @@ static int regmap_mmio_read(void *context,
96 96
97 BUG_ON(reg_size != 4); 97 BUG_ON(reg_size != 4);
98 98
99 if (ctx->clk) { 99 if (!IS_ERR(ctx->clk)) {
100 ret = clk_enable(ctx->clk); 100 ret = clk_enable(ctx->clk);
101 if (ret < 0) 101 if (ret < 0)
102 return ret; 102 return ret;
@@ -129,7 +129,7 @@ static int regmap_mmio_read(void *context,
129 offset += ctx->val_bytes; 129 offset += ctx->val_bytes;
130 } 130 }
131 131
132 if (ctx->clk) 132 if (!IS_ERR(ctx->clk))
133 clk_disable(ctx->clk); 133 clk_disable(ctx->clk);
134 134
135 return 0; 135 return 0;
@@ -139,7 +139,7 @@ static void regmap_mmio_free_context(void *context)
139{ 139{
140 struct regmap_mmio_context *ctx = context; 140 struct regmap_mmio_context *ctx = context;
141 141
142 if (ctx->clk) { 142 if (!IS_ERR(ctx->clk)) {
143 clk_unprepare(ctx->clk); 143 clk_unprepare(ctx->clk);
144 clk_put(ctx->clk); 144 clk_put(ctx->clk);
145 } 145 }
@@ -209,6 +209,7 @@ static struct regmap_mmio_context *regmap_mmio_gen_context(struct device *dev,
209 209
210 ctx->regs = regs; 210 ctx->regs = regs;
211 ctx->val_bytes = config->val_bits / 8; 211 ctx->val_bytes = config->val_bits / 8;
212 ctx->clk = ERR_PTR(-ENODEV);
212 213
213 if (clk_id == NULL) 214 if (clk_id == NULL)
214 return ctx; 215 return ctx;
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 9c021d9cace0..c2e002100949 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -1549,7 +1549,7 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val,
1549 val + (i * val_bytes), 1549 val + (i * val_bytes),
1550 val_bytes); 1550 val_bytes);
1551 if (ret != 0) 1551 if (ret != 0)
1552 return ret; 1552 goto out;
1553 } 1553 }
1554 } else { 1554 } else {
1555 ret = _regmap_raw_write(map, reg, wval, val_bytes * val_count); 1555 ret = _regmap_raw_write(map, reg, wval, val_bytes * val_count);
@@ -1743,7 +1743,7 @@ static int _regmap_read(struct regmap *map, unsigned int reg,
1743/** 1743/**
1744 * regmap_read(): Read a value from a single register 1744 * regmap_read(): Read a value from a single register
1745 * 1745 *
1746 * @map: Register map to write to 1746 * @map: Register map to read from
1747 * @reg: Register to be read from 1747 * @reg: Register to be read from
1748 * @val: Pointer to store read value 1748 * @val: Pointer to store read value
1749 * 1749 *
@@ -1770,7 +1770,7 @@ EXPORT_SYMBOL_GPL(regmap_read);
1770/** 1770/**
1771 * regmap_raw_read(): Read raw data from the device 1771 * regmap_raw_read(): Read raw data from the device
1772 * 1772 *
1773 * @map: Register map to write to 1773 * @map: Register map to read from
1774 * @reg: First register to be read from 1774 * @reg: First register to be read from
1775 * @val: Pointer to store read value 1775 * @val: Pointer to store read value
1776 * @val_len: Size of data to read 1776 * @val_len: Size of data to read
@@ -1882,7 +1882,7 @@ EXPORT_SYMBOL_GPL(regmap_fields_read);
1882/** 1882/**
1883 * regmap_bulk_read(): Read multiple registers from the device 1883 * regmap_bulk_read(): Read multiple registers from the device
1884 * 1884 *
1885 * @map: Register map to write to 1885 * @map: Register map to read from
1886 * @reg: First register to be read from 1886 * @reg: First register to be read from
1887 * @val: Pointer to store read value, in native register size for device 1887 * @val: Pointer to store read value, in native register size for device
1888 * @val_count: Number of registers to read 1888 * @val_count: Number of registers to read
diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index ea192ec029c4..f370fc13aea5 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -495,23 +495,23 @@ static int null_add_dev(void)
495 495
496 spin_lock_init(&nullb->lock); 496 spin_lock_init(&nullb->lock);
497 497
498 if (queue_mode == NULL_Q_MQ && use_per_node_hctx)
499 submit_queues = nr_online_nodes;
500
498 if (setup_queues(nullb)) 501 if (setup_queues(nullb))
499 goto err; 502 goto err;
500 503
501 if (queue_mode == NULL_Q_MQ) { 504 if (queue_mode == NULL_Q_MQ) {
502 null_mq_reg.numa_node = home_node; 505 null_mq_reg.numa_node = home_node;
503 null_mq_reg.queue_depth = hw_queue_depth; 506 null_mq_reg.queue_depth = hw_queue_depth;
507 null_mq_reg.nr_hw_queues = submit_queues;
504 508
505 if (use_per_node_hctx) { 509 if (use_per_node_hctx) {
506 null_mq_reg.ops->alloc_hctx = null_alloc_hctx; 510 null_mq_reg.ops->alloc_hctx = null_alloc_hctx;
507 null_mq_reg.ops->free_hctx = null_free_hctx; 511 null_mq_reg.ops->free_hctx = null_free_hctx;
508
509 null_mq_reg.nr_hw_queues = nr_online_nodes;
510 } else { 512 } else {
511 null_mq_reg.ops->alloc_hctx = blk_mq_alloc_single_hw_queue; 513 null_mq_reg.ops->alloc_hctx = blk_mq_alloc_single_hw_queue;
512 null_mq_reg.ops->free_hctx = blk_mq_free_single_hw_queue; 514 null_mq_reg.ops->free_hctx = blk_mq_free_single_hw_queue;
513
514 null_mq_reg.nr_hw_queues = submit_queues;
515 } 515 }
516 516
517 nullb->q = blk_mq_init_queue(&null_mq_reg, nullb); 517 nullb->q = blk_mq_init_queue(&null_mq_reg, nullb);
diff --git a/drivers/char/i8k.c b/drivers/char/i8k.c
index 40cc0cf2ded6..e6939e13e338 100644
--- a/drivers/char/i8k.c
+++ b/drivers/char/i8k.c
@@ -664,6 +664,13 @@ static struct dmi_system_id __initdata i8k_dmi_table[] = {
664 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro"), 664 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro"),
665 }, 665 },
666 }, 666 },
667 {
668 .ident = "Dell XPS421",
669 .matches = {
670 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
671 DMI_MATCH(DMI_PRODUCT_NAME, "XPS L421X"),
672 },
673 },
667 { } 674 { }
668}; 675};
669 676
diff --git a/drivers/clk/tegra/Makefile b/drivers/clk/tegra/Makefile
index f49fac2d193a..f7dfb72884a4 100644
--- a/drivers/clk/tegra/Makefile
+++ b/drivers/clk/tegra/Makefile
@@ -6,7 +6,12 @@ obj-y += clk-periph-gate.o
6obj-y += clk-pll.o 6obj-y += clk-pll.o
7obj-y += clk-pll-out.o 7obj-y += clk-pll-out.o
8obj-y += clk-super.o 8obj-y += clk-super.o
9 9obj-y += clk-tegra-audio.o
10obj-y += clk-tegra-periph.o
11obj-y += clk-tegra-pmc.o
12obj-y += clk-tegra-fixed.o
13obj-y += clk-tegra-super-gen4.o
10obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += clk-tegra20.o 14obj-$(CONFIG_ARCH_TEGRA_2x_SOC) += clk-tegra20.o
11obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += clk-tegra30.o 15obj-$(CONFIG_ARCH_TEGRA_3x_SOC) += clk-tegra30.o
12obj-$(CONFIG_ARCH_TEGRA_114_SOC) += clk-tegra114.o 16obj-$(CONFIG_ARCH_TEGRA_114_SOC) += clk-tegra114.o
17obj-$(CONFIG_ARCH_TEGRA_124_SOC) += clk-tegra124.o
diff --git a/drivers/clk/tegra/clk-id.h b/drivers/clk/tegra/clk-id.h
new file mode 100644
index 000000000000..cf0c323f2c36
--- /dev/null
+++ b/drivers/clk/tegra/clk-id.h
@@ -0,0 +1,235 @@
1/*
2 * This header provides IDs for clocks common between several Tegra SoCs
3 */
4#ifndef _TEGRA_CLK_ID_H
5#define _TEGRA_CLK_ID_H
6
7enum clk_id {
8 tegra_clk_actmon,
9 tegra_clk_adx,
10 tegra_clk_adx1,
11 tegra_clk_afi,
12 tegra_clk_amx,
13 tegra_clk_amx1,
14 tegra_clk_apbdma,
15 tegra_clk_apbif,
16 tegra_clk_audio0,
17 tegra_clk_audio0_2x,
18 tegra_clk_audio0_mux,
19 tegra_clk_audio1,
20 tegra_clk_audio1_2x,
21 tegra_clk_audio1_mux,
22 tegra_clk_audio2,
23 tegra_clk_audio2_2x,
24 tegra_clk_audio2_mux,
25 tegra_clk_audio3,
26 tegra_clk_audio3_2x,
27 tegra_clk_audio3_mux,
28 tegra_clk_audio4,
29 tegra_clk_audio4_2x,
30 tegra_clk_audio4_mux,
31 tegra_clk_blink,
32 tegra_clk_bsea,
33 tegra_clk_bsev,
34 tegra_clk_cclk_g,
35 tegra_clk_cclk_lp,
36 tegra_clk_cilab,
37 tegra_clk_cilcd,
38 tegra_clk_cile,
39 tegra_clk_clk_32k,
40 tegra_clk_clk72Mhz,
41 tegra_clk_clk_m,
42 tegra_clk_clk_m_div2,
43 tegra_clk_clk_m_div4,
44 tegra_clk_clk_out_1,
45 tegra_clk_clk_out_1_mux,
46 tegra_clk_clk_out_2,
47 tegra_clk_clk_out_2_mux,
48 tegra_clk_clk_out_3,
49 tegra_clk_clk_out_3_mux,
50 tegra_clk_cml0,
51 tegra_clk_cml1,
52 tegra_clk_csi,
53 tegra_clk_csite,
54 tegra_clk_csus,
55 tegra_clk_cve,
56 tegra_clk_dam0,
57 tegra_clk_dam1,
58 tegra_clk_dam2,
59 tegra_clk_d_audio,
60 tegra_clk_dds,
61 tegra_clk_dfll_ref,
62 tegra_clk_dfll_soc,
63 tegra_clk_disp1,
64 tegra_clk_disp2,
65 tegra_clk_dp2,
66 tegra_clk_dpaux,
67 tegra_clk_dsia,
68 tegra_clk_dsialp,
69 tegra_clk_dsia_mux,
70 tegra_clk_dsib,
71 tegra_clk_dsiblp,
72 tegra_clk_dsib_mux,
73 tegra_clk_dtv,
74 tegra_clk_emc,
75 tegra_clk_entropy,
76 tegra_clk_epp,
77 tegra_clk_epp_8,
78 tegra_clk_extern1,
79 tegra_clk_extern2,
80 tegra_clk_extern3,
81 tegra_clk_fuse,
82 tegra_clk_fuse_burn,
83 tegra_clk_gpu,
84 tegra_clk_gr2d,
85 tegra_clk_gr2d_8,
86 tegra_clk_gr3d,
87 tegra_clk_gr3d_8,
88 tegra_clk_hclk,
89 tegra_clk_hda,
90 tegra_clk_hda2codec_2x,
91 tegra_clk_hda2hdmi,
92 tegra_clk_hdmi,
93 tegra_clk_hdmi_audio,
94 tegra_clk_host1x,
95 tegra_clk_host1x_8,
96 tegra_clk_i2c1,
97 tegra_clk_i2c2,
98 tegra_clk_i2c3,
99 tegra_clk_i2c4,
100 tegra_clk_i2c5,
101 tegra_clk_i2c6,
102 tegra_clk_i2cslow,
103 tegra_clk_i2s0,
104 tegra_clk_i2s0_sync,
105 tegra_clk_i2s1,
106 tegra_clk_i2s1_sync,
107 tegra_clk_i2s2,
108 tegra_clk_i2s2_sync,
109 tegra_clk_i2s3,
110 tegra_clk_i2s3_sync,
111 tegra_clk_i2s4,
112 tegra_clk_i2s4_sync,
113 tegra_clk_isp,
114 tegra_clk_isp_8,
115 tegra_clk_ispb,
116 tegra_clk_kbc,
117 tegra_clk_kfuse,
118 tegra_clk_la,
119 tegra_clk_mipi,
120 tegra_clk_mipi_cal,
121 tegra_clk_mpe,
122 tegra_clk_mselect,
123 tegra_clk_msenc,
124 tegra_clk_ndflash,
125 tegra_clk_ndflash_8,
126 tegra_clk_ndspeed,
127 tegra_clk_ndspeed_8,
128 tegra_clk_nor,
129 tegra_clk_owr,
130 tegra_clk_pcie,
131 tegra_clk_pclk,
132 tegra_clk_pll_a,
133 tegra_clk_pll_a_out0,
134 tegra_clk_pll_c,
135 tegra_clk_pll_c2,
136 tegra_clk_pll_c3,
137 tegra_clk_pll_c4,
138 tegra_clk_pll_c_out1,
139 tegra_clk_pll_d,
140 tegra_clk_pll_d2,
141 tegra_clk_pll_d2_out0,
142 tegra_clk_pll_d_out0,
143 tegra_clk_pll_dp,
144 tegra_clk_pll_e_out0,
145 tegra_clk_pll_m,
146 tegra_clk_pll_m_out1,
147 tegra_clk_pll_p,
148 tegra_clk_pll_p_out1,
149 tegra_clk_pll_p_out2,
150 tegra_clk_pll_p_out2_int,
151 tegra_clk_pll_p_out3,
152 tegra_clk_pll_p_out4,
153 tegra_clk_pll_p_out5,
154 tegra_clk_pll_ref,
155 tegra_clk_pll_re_out,
156 tegra_clk_pll_re_vco,
157 tegra_clk_pll_u,
158 tegra_clk_pll_u_12m,
159 tegra_clk_pll_u_480m,
160 tegra_clk_pll_u_48m,
161 tegra_clk_pll_u_60m,
162 tegra_clk_pll_x,
163 tegra_clk_pll_x_out0,
164 tegra_clk_pwm,
165 tegra_clk_rtc,
166 tegra_clk_sata,
167 tegra_clk_sata_cold,
168 tegra_clk_sata_oob,
169 tegra_clk_sbc1,
170 tegra_clk_sbc1_8,
171 tegra_clk_sbc2,
172 tegra_clk_sbc2_8,
173 tegra_clk_sbc3,
174 tegra_clk_sbc3_8,
175 tegra_clk_sbc4,
176 tegra_clk_sbc4_8,
177 tegra_clk_sbc5,
178 tegra_clk_sbc5_8,
179 tegra_clk_sbc6,
180 tegra_clk_sbc6_8,
181 tegra_clk_sclk,
182 tegra_clk_sdmmc1,
183 tegra_clk_sdmmc2,
184 tegra_clk_sdmmc3,
185 tegra_clk_sdmmc4,
186 tegra_clk_se,
187 tegra_clk_soc_therm,
188 tegra_clk_sor0,
189 tegra_clk_sor0_lvds,
190 tegra_clk_spdif,
191 tegra_clk_spdif_2x,
192 tegra_clk_spdif_in,
193 tegra_clk_spdif_in_sync,
194 tegra_clk_spdif_mux,
195 tegra_clk_spdif_out,
196 tegra_clk_timer,
197 tegra_clk_trace,
198 tegra_clk_tsec,
199 tegra_clk_tsensor,
200 tegra_clk_tvdac,
201 tegra_clk_tvo,
202 tegra_clk_uarta,
203 tegra_clk_uartb,
204 tegra_clk_uartc,
205 tegra_clk_uartd,
206 tegra_clk_uarte,
207 tegra_clk_usb2,
208 tegra_clk_usb3,
209 tegra_clk_usbd,
210 tegra_clk_vcp,
211 tegra_clk_vde,
212 tegra_clk_vde_8,
213 tegra_clk_vfir,
214 tegra_clk_vi,
215 tegra_clk_vi_8,
216 tegra_clk_vi_9,
217 tegra_clk_vic03,
218 tegra_clk_vim2_clk,
219 tegra_clk_vimclk_sync,
220 tegra_clk_vi_sensor,
221 tegra_clk_vi_sensor2,
222 tegra_clk_vi_sensor_8,
223 tegra_clk_xusb_dev,
224 tegra_clk_xusb_dev_src,
225 tegra_clk_xusb_falcon_src,
226 tegra_clk_xusb_fs_src,
227 tegra_clk_xusb_host,
228 tegra_clk_xusb_host_src,
229 tegra_clk_xusb_hs_src,
230 tegra_clk_xusb_ss,
231 tegra_clk_xusb_ss_src,
232 tegra_clk_max,
233};
234
235#endif /* _TEGRA_CLK_ID_H */
diff --git a/drivers/clk/tegra/clk-periph-gate.c b/drivers/clk/tegra/clk-periph-gate.c
index bafee9895a24..507015314827 100644
--- a/drivers/clk/tegra/clk-periph-gate.c
+++ b/drivers/clk/tegra/clk-periph-gate.c
@@ -36,8 +36,6 @@ static DEFINE_SPINLOCK(periph_ref_lock);
36 36
37#define read_rst(gate) \ 37#define read_rst(gate) \
38 readl_relaxed(gate->clk_base + (gate->regs->rst_reg)) 38 readl_relaxed(gate->clk_base + (gate->regs->rst_reg))
39#define write_rst_set(val, gate) \
40 writel_relaxed(val, gate->clk_base + (gate->regs->rst_set_reg))
41#define write_rst_clr(val, gate) \ 39#define write_rst_clr(val, gate) \
42 writel_relaxed(val, gate->clk_base + (gate->regs->rst_clr_reg)) 40 writel_relaxed(val, gate->clk_base + (gate->regs->rst_clr_reg))
43 41
@@ -123,26 +121,6 @@ static void clk_periph_disable(struct clk_hw *hw)
123 spin_unlock_irqrestore(&periph_ref_lock, flags); 121 spin_unlock_irqrestore(&periph_ref_lock, flags);
124} 122}
125 123
126void tegra_periph_reset(struct tegra_clk_periph_gate *gate, bool assert)
127{
128 if (gate->flags & TEGRA_PERIPH_NO_RESET)
129 return;
130
131 if (assert) {
132 /*
133 * If peripheral is in the APB bus then read the APB bus to
134 * flush the write operation in apb bus. This will avoid the
135 * peripheral access after disabling clock
136 */
137 if (gate->flags & TEGRA_PERIPH_ON_APB)
138 tegra_read_chipid();
139
140 write_rst_set(periph_clk_to_bit(gate), gate);
141 } else {
142 write_rst_clr(periph_clk_to_bit(gate), gate);
143 }
144}
145
146const struct clk_ops tegra_clk_periph_gate_ops = { 124const struct clk_ops tegra_clk_periph_gate_ops = {
147 .is_enabled = clk_periph_is_enabled, 125 .is_enabled = clk_periph_is_enabled,
148 .enable = clk_periph_enable, 126 .enable = clk_periph_enable,
@@ -151,12 +129,16 @@ const struct clk_ops tegra_clk_periph_gate_ops = {
151 129
152struct clk *tegra_clk_register_periph_gate(const char *name, 130struct clk *tegra_clk_register_periph_gate(const char *name,
153 const char *parent_name, u8 gate_flags, void __iomem *clk_base, 131 const char *parent_name, u8 gate_flags, void __iomem *clk_base,
154 unsigned long flags, int clk_num, 132 unsigned long flags, int clk_num, int *enable_refcnt)
155 struct tegra_clk_periph_regs *pregs, int *enable_refcnt)
156{ 133{
157 struct tegra_clk_periph_gate *gate; 134 struct tegra_clk_periph_gate *gate;
158 struct clk *clk; 135 struct clk *clk;
159 struct clk_init_data init; 136 struct clk_init_data init;
137 struct tegra_clk_periph_regs *pregs;
138
139 pregs = get_reg_bank(clk_num);
140 if (!pregs)
141 return ERR_PTR(-EINVAL);
160 142
161 gate = kzalloc(sizeof(*gate), GFP_KERNEL); 143 gate = kzalloc(sizeof(*gate), GFP_KERNEL);
162 if (!gate) { 144 if (!gate) {
diff --git a/drivers/clk/tegra/clk-periph.c b/drivers/clk/tegra/clk-periph.c
index b2309d37a963..c534043c0481 100644
--- a/drivers/clk/tegra/clk-periph.c
+++ b/drivers/clk/tegra/clk-periph.c
@@ -111,46 +111,6 @@ static void clk_periph_disable(struct clk_hw *hw)
111 gate_ops->disable(gate_hw); 111 gate_ops->disable(gate_hw);
112} 112}
113 113
114void tegra_periph_reset_deassert(struct clk *c)
115{
116 struct clk_hw *hw = __clk_get_hw(c);
117 struct tegra_clk_periph *periph = to_clk_periph(hw);
118 struct tegra_clk_periph_gate *gate;
119
120 if (periph->magic != TEGRA_CLK_PERIPH_MAGIC) {
121 gate = to_clk_periph_gate(hw);
122 if (gate->magic != TEGRA_CLK_PERIPH_GATE_MAGIC) {
123 WARN_ON(1);
124 return;
125 }
126 } else {
127 gate = &periph->gate;
128 }
129
130 tegra_periph_reset(gate, 0);
131}
132EXPORT_SYMBOL(tegra_periph_reset_deassert);
133
134void tegra_periph_reset_assert(struct clk *c)
135{
136 struct clk_hw *hw = __clk_get_hw(c);
137 struct tegra_clk_periph *periph = to_clk_periph(hw);
138 struct tegra_clk_periph_gate *gate;
139
140 if (periph->magic != TEGRA_CLK_PERIPH_MAGIC) {
141 gate = to_clk_periph_gate(hw);
142 if (gate->magic != TEGRA_CLK_PERIPH_GATE_MAGIC) {
143 WARN_ON(1);
144 return;
145 }
146 } else {
147 gate = &periph->gate;
148 }
149
150 tegra_periph_reset(gate, 1);
151}
152EXPORT_SYMBOL(tegra_periph_reset_assert);
153
154const struct clk_ops tegra_clk_periph_ops = { 114const struct clk_ops tegra_clk_periph_ops = {
155 .get_parent = clk_periph_get_parent, 115 .get_parent = clk_periph_get_parent,
156 .set_parent = clk_periph_set_parent, 116 .set_parent = clk_periph_set_parent,
@@ -170,27 +130,50 @@ const struct clk_ops tegra_clk_periph_nodiv_ops = {
170 .disable = clk_periph_disable, 130 .disable = clk_periph_disable,
171}; 131};
172 132
133const struct clk_ops tegra_clk_periph_no_gate_ops = {
134 .get_parent = clk_periph_get_parent,
135 .set_parent = clk_periph_set_parent,
136 .recalc_rate = clk_periph_recalc_rate,
137 .round_rate = clk_periph_round_rate,
138 .set_rate = clk_periph_set_rate,
139};
140
173static struct clk *_tegra_clk_register_periph(const char *name, 141static struct clk *_tegra_clk_register_periph(const char *name,
174 const char **parent_names, int num_parents, 142 const char **parent_names, int num_parents,
175 struct tegra_clk_periph *periph, 143 struct tegra_clk_periph *periph,
176 void __iomem *clk_base, u32 offset, bool div, 144 void __iomem *clk_base, u32 offset,
177 unsigned long flags) 145 unsigned long flags)
178{ 146{
179 struct clk *clk; 147 struct clk *clk;
180 struct clk_init_data init; 148 struct clk_init_data init;
149 struct tegra_clk_periph_regs *bank;
150 bool div = !(periph->gate.flags & TEGRA_PERIPH_NO_DIV);
151
152 if (periph->gate.flags & TEGRA_PERIPH_NO_DIV) {
153 flags |= CLK_SET_RATE_PARENT;
154 init.ops = &tegra_clk_periph_nodiv_ops;
155 } else if (periph->gate.flags & TEGRA_PERIPH_NO_GATE)
156 init.ops = &tegra_clk_periph_no_gate_ops;
157 else
158 init.ops = &tegra_clk_periph_ops;
181 159
182 init.name = name; 160 init.name = name;
183 init.ops = div ? &tegra_clk_periph_ops : &tegra_clk_periph_nodiv_ops;
184 init.flags = flags; 161 init.flags = flags;
185 init.parent_names = parent_names; 162 init.parent_names = parent_names;
186 init.num_parents = num_parents; 163 init.num_parents = num_parents;
187 164
165 bank = get_reg_bank(periph->gate.clk_num);
166 if (!bank)
167 return ERR_PTR(-EINVAL);
168
188 /* Data in .init is copied by clk_register(), so stack variable OK */ 169 /* Data in .init is copied by clk_register(), so stack variable OK */
189 periph->hw.init = &init; 170 periph->hw.init = &init;
190 periph->magic = TEGRA_CLK_PERIPH_MAGIC; 171 periph->magic = TEGRA_CLK_PERIPH_MAGIC;
191 periph->mux.reg = clk_base + offset; 172 periph->mux.reg = clk_base + offset;
192 periph->divider.reg = div ? (clk_base + offset) : NULL; 173 periph->divider.reg = div ? (clk_base + offset) : NULL;
193 periph->gate.clk_base = clk_base; 174 periph->gate.clk_base = clk_base;
175 periph->gate.regs = bank;
176 periph->gate.enable_refcnt = periph_clk_enb_refcnt;
194 177
195 clk = clk_register(NULL, &periph->hw); 178 clk = clk_register(NULL, &periph->hw);
196 if (IS_ERR(clk)) 179 if (IS_ERR(clk))
@@ -209,7 +192,7 @@ struct clk *tegra_clk_register_periph(const char *name,
209 u32 offset, unsigned long flags) 192 u32 offset, unsigned long flags)
210{ 193{
211 return _tegra_clk_register_periph(name, parent_names, num_parents, 194 return _tegra_clk_register_periph(name, parent_names, num_parents,
212 periph, clk_base, offset, true, flags); 195 periph, clk_base, offset, flags);
213} 196}
214 197
215struct clk *tegra_clk_register_periph_nodiv(const char *name, 198struct clk *tegra_clk_register_periph_nodiv(const char *name,
@@ -217,6 +200,7 @@ struct clk *tegra_clk_register_periph_nodiv(const char *name,
217 struct tegra_clk_periph *periph, void __iomem *clk_base, 200 struct tegra_clk_periph *periph, void __iomem *clk_base,
218 u32 offset) 201 u32 offset)
219{ 202{
203 periph->gate.flags |= TEGRA_PERIPH_NO_DIV;
220 return _tegra_clk_register_periph(name, parent_names, num_parents, 204 return _tegra_clk_register_periph(name, parent_names, num_parents,
221 periph, clk_base, offset, false, CLK_SET_RATE_PARENT); 205 periph, clk_base, offset, CLK_SET_RATE_PARENT);
222} 206}
diff --git a/drivers/clk/tegra/clk-pll.c b/drivers/clk/tegra/clk-pll.c
index 197074a57754..2dd432266ef6 100644
--- a/drivers/clk/tegra/clk-pll.c
+++ b/drivers/clk/tegra/clk-pll.c
@@ -77,7 +77,23 @@
77#define PLLE_MISC_SETUP_VALUE (7 << PLLE_MISC_SETUP_BASE_SHIFT) 77#define PLLE_MISC_SETUP_VALUE (7 << PLLE_MISC_SETUP_BASE_SHIFT)
78 78
79#define PLLE_SS_CTRL 0x68 79#define PLLE_SS_CTRL 0x68
80#define PLLE_SS_DISABLE (7 << 10) 80#define PLLE_SS_CNTL_BYPASS_SS BIT(10)
81#define PLLE_SS_CNTL_INTERP_RESET BIT(11)
82#define PLLE_SS_CNTL_SSC_BYP BIT(12)
83#define PLLE_SS_CNTL_CENTER BIT(14)
84#define PLLE_SS_CNTL_INVERT BIT(15)
85#define PLLE_SS_DISABLE (PLLE_SS_CNTL_BYPASS_SS | PLLE_SS_CNTL_INTERP_RESET |\
86 PLLE_SS_CNTL_SSC_BYP)
87#define PLLE_SS_MAX_MASK 0x1ff
88#define PLLE_SS_MAX_VAL 0x25
89#define PLLE_SS_INC_MASK (0xff << 16)
90#define PLLE_SS_INC_VAL (0x1 << 16)
91#define PLLE_SS_INCINTRV_MASK (0x3f << 24)
92#define PLLE_SS_INCINTRV_VAL (0x20 << 24)
93#define PLLE_SS_COEFFICIENTS_MASK \
94 (PLLE_SS_MAX_MASK | PLLE_SS_INC_MASK | PLLE_SS_INCINTRV_MASK)
95#define PLLE_SS_COEFFICIENTS_VAL \
96 (PLLE_SS_MAX_VAL | PLLE_SS_INC_VAL | PLLE_SS_INCINTRV_VAL)
81 97
82#define PLLE_AUX_PLLP_SEL BIT(2) 98#define PLLE_AUX_PLLP_SEL BIT(2)
83#define PLLE_AUX_ENABLE_SWCTL BIT(4) 99#define PLLE_AUX_ENABLE_SWCTL BIT(4)
@@ -121,6 +137,36 @@
121#define PMC_SATA_PWRGT_PLLE_IDDQ_VALUE BIT(5) 137#define PMC_SATA_PWRGT_PLLE_IDDQ_VALUE BIT(5)
122#define PMC_SATA_PWRGT_PLLE_IDDQ_SWCTL BIT(4) 138#define PMC_SATA_PWRGT_PLLE_IDDQ_SWCTL BIT(4)
123 139
140#define PLLSS_MISC_KCP 0
141#define PLLSS_MISC_KVCO 0
142#define PLLSS_MISC_SETUP 0
143#define PLLSS_EN_SDM 0
144#define PLLSS_EN_SSC 0
145#define PLLSS_EN_DITHER2 0
146#define PLLSS_EN_DITHER 1
147#define PLLSS_SDM_RESET 0
148#define PLLSS_CLAMP 0
149#define PLLSS_SDM_SSC_MAX 0
150#define PLLSS_SDM_SSC_MIN 0
151#define PLLSS_SDM_SSC_STEP 0
152#define PLLSS_SDM_DIN 0
153#define PLLSS_MISC_DEFAULT ((PLLSS_MISC_KCP << 25) | \
154 (PLLSS_MISC_KVCO << 24) | \
155 PLLSS_MISC_SETUP)
156#define PLLSS_CFG_DEFAULT ((PLLSS_EN_SDM << 31) | \
157 (PLLSS_EN_SSC << 30) | \
158 (PLLSS_EN_DITHER2 << 29) | \
159 (PLLSS_EN_DITHER << 28) | \
160 (PLLSS_SDM_RESET) << 27 | \
161 (PLLSS_CLAMP << 22))
162#define PLLSS_CTRL1_DEFAULT \
163 ((PLLSS_SDM_SSC_MAX << 16) | PLLSS_SDM_SSC_MIN)
164#define PLLSS_CTRL2_DEFAULT \
165 ((PLLSS_SDM_SSC_STEP << 16) | PLLSS_SDM_DIN)
166#define PLLSS_LOCK_OVERRIDE BIT(24)
167#define PLLSS_REF_SRC_SEL_SHIFT 25
168#define PLLSS_REF_SRC_SEL_MASK (3 << PLLSS_REF_SRC_SEL_SHIFT)
169
124#define pll_readl(offset, p) readl_relaxed(p->clk_base + offset) 170#define pll_readl(offset, p) readl_relaxed(p->clk_base + offset)
125#define pll_readl_base(p) pll_readl(p->params->base_reg, p) 171#define pll_readl_base(p) pll_readl(p->params->base_reg, p)
126#define pll_readl_misc(p) pll_readl(p->params->misc_reg, p) 172#define pll_readl_misc(p) pll_readl(p->params->misc_reg, p)
@@ -134,7 +180,7 @@
134#define mask(w) ((1 << (w)) - 1) 180#define mask(w) ((1 << (w)) - 1)
135#define divm_mask(p) mask(p->params->div_nmp->divm_width) 181#define divm_mask(p) mask(p->params->div_nmp->divm_width)
136#define divn_mask(p) mask(p->params->div_nmp->divn_width) 182#define divn_mask(p) mask(p->params->div_nmp->divn_width)
137#define divp_mask(p) (p->flags & TEGRA_PLLU ? PLLU_POST_DIVP_MASK : \ 183#define divp_mask(p) (p->params->flags & TEGRA_PLLU ? PLLU_POST_DIVP_MASK :\
138 mask(p->params->div_nmp->divp_width)) 184 mask(p->params->div_nmp->divp_width))
139 185
140#define divm_max(p) (divm_mask(p)) 186#define divm_max(p) (divm_mask(p))
@@ -154,10 +200,10 @@ static void clk_pll_enable_lock(struct tegra_clk_pll *pll)
154{ 200{
155 u32 val; 201 u32 val;
156 202
157 if (!(pll->flags & TEGRA_PLL_USE_LOCK)) 203 if (!(pll->params->flags & TEGRA_PLL_USE_LOCK))
158 return; 204 return;
159 205
160 if (!(pll->flags & TEGRA_PLL_HAS_LOCK_ENABLE)) 206 if (!(pll->params->flags & TEGRA_PLL_HAS_LOCK_ENABLE))
161 return; 207 return;
162 208
163 val = pll_readl_misc(pll); 209 val = pll_readl_misc(pll);
@@ -171,13 +217,13 @@ static int clk_pll_wait_for_lock(struct tegra_clk_pll *pll)
171 u32 val, lock_mask; 217 u32 val, lock_mask;
172 void __iomem *lock_addr; 218 void __iomem *lock_addr;
173 219
174 if (!(pll->flags & TEGRA_PLL_USE_LOCK)) { 220 if (!(pll->params->flags & TEGRA_PLL_USE_LOCK)) {
175 udelay(pll->params->lock_delay); 221 udelay(pll->params->lock_delay);
176 return 0; 222 return 0;
177 } 223 }
178 224
179 lock_addr = pll->clk_base; 225 lock_addr = pll->clk_base;
180 if (pll->flags & TEGRA_PLL_LOCK_MISC) 226 if (pll->params->flags & TEGRA_PLL_LOCK_MISC)
181 lock_addr += pll->params->misc_reg; 227 lock_addr += pll->params->misc_reg;
182 else 228 else
183 lock_addr += pll->params->base_reg; 229 lock_addr += pll->params->base_reg;
@@ -204,7 +250,7 @@ static int clk_pll_is_enabled(struct clk_hw *hw)
204 struct tegra_clk_pll *pll = to_clk_pll(hw); 250 struct tegra_clk_pll *pll = to_clk_pll(hw);
205 u32 val; 251 u32 val;
206 252
207 if (pll->flags & TEGRA_PLLM) { 253 if (pll->params->flags & TEGRA_PLLM) {
208 val = readl_relaxed(pll->pmc + PMC_PLLP_WB0_OVERRIDE); 254 val = readl_relaxed(pll->pmc + PMC_PLLP_WB0_OVERRIDE);
209 if (val & PMC_PLLP_WB0_OVERRIDE_PLLM_OVERRIDE) 255 if (val & PMC_PLLP_WB0_OVERRIDE_PLLM_OVERRIDE)
210 return val & PMC_PLLP_WB0_OVERRIDE_PLLM_ENABLE ? 1 : 0; 256 return val & PMC_PLLP_WB0_OVERRIDE_PLLM_ENABLE ? 1 : 0;
@@ -223,12 +269,12 @@ static void _clk_pll_enable(struct clk_hw *hw)
223 clk_pll_enable_lock(pll); 269 clk_pll_enable_lock(pll);
224 270
225 val = pll_readl_base(pll); 271 val = pll_readl_base(pll);
226 if (pll->flags & TEGRA_PLL_BYPASS) 272 if (pll->params->flags & TEGRA_PLL_BYPASS)
227 val &= ~PLL_BASE_BYPASS; 273 val &= ~PLL_BASE_BYPASS;
228 val |= PLL_BASE_ENABLE; 274 val |= PLL_BASE_ENABLE;
229 pll_writel_base(val, pll); 275 pll_writel_base(val, pll);
230 276
231 if (pll->flags & TEGRA_PLLM) { 277 if (pll->params->flags & TEGRA_PLLM) {
232 val = readl_relaxed(pll->pmc + PMC_PLLP_WB0_OVERRIDE); 278 val = readl_relaxed(pll->pmc + PMC_PLLP_WB0_OVERRIDE);
233 val |= PMC_PLLP_WB0_OVERRIDE_PLLM_ENABLE; 279 val |= PMC_PLLP_WB0_OVERRIDE_PLLM_ENABLE;
234 writel_relaxed(val, pll->pmc + PMC_PLLP_WB0_OVERRIDE); 280 writel_relaxed(val, pll->pmc + PMC_PLLP_WB0_OVERRIDE);
@@ -241,12 +287,12 @@ static void _clk_pll_disable(struct clk_hw *hw)
241 u32 val; 287 u32 val;
242 288
243 val = pll_readl_base(pll); 289 val = pll_readl_base(pll);
244 if (pll->flags & TEGRA_PLL_BYPASS) 290 if (pll->params->flags & TEGRA_PLL_BYPASS)
245 val &= ~PLL_BASE_BYPASS; 291 val &= ~PLL_BASE_BYPASS;
246 val &= ~PLL_BASE_ENABLE; 292 val &= ~PLL_BASE_ENABLE;
247 pll_writel_base(val, pll); 293 pll_writel_base(val, pll);
248 294
249 if (pll->flags & TEGRA_PLLM) { 295 if (pll->params->flags & TEGRA_PLLM) {
250 val = readl_relaxed(pll->pmc + PMC_PLLP_WB0_OVERRIDE); 296 val = readl_relaxed(pll->pmc + PMC_PLLP_WB0_OVERRIDE);
251 val &= ~PMC_PLLP_WB0_OVERRIDE_PLLM_ENABLE; 297 val &= ~PMC_PLLP_WB0_OVERRIDE_PLLM_ENABLE;
252 writel_relaxed(val, pll->pmc + PMC_PLLP_WB0_OVERRIDE); 298 writel_relaxed(val, pll->pmc + PMC_PLLP_WB0_OVERRIDE);
@@ -326,7 +372,7 @@ static int _get_table_rate(struct clk_hw *hw,
326 struct tegra_clk_pll *pll = to_clk_pll(hw); 372 struct tegra_clk_pll *pll = to_clk_pll(hw);
327 struct tegra_clk_pll_freq_table *sel; 373 struct tegra_clk_pll_freq_table *sel;
328 374
329 for (sel = pll->freq_table; sel->input_rate != 0; sel++) 375 for (sel = pll->params->freq_table; sel->input_rate != 0; sel++)
330 if (sel->input_rate == parent_rate && 376 if (sel->input_rate == parent_rate &&
331 sel->output_rate == rate) 377 sel->output_rate == rate)
332 break; 378 break;
@@ -389,12 +435,11 @@ static int _calc_rate(struct clk_hw *hw, struct tegra_clk_pll_freq_table *cfg,
389 if (cfg->m > divm_max(pll) || cfg->n > divn_max(pll) || 435 if (cfg->m > divm_max(pll) || cfg->n > divn_max(pll) ||
390 (1 << p_div) > divp_max(pll) 436 (1 << p_div) > divp_max(pll)
391 || cfg->output_rate > pll->params->vco_max) { 437 || cfg->output_rate > pll->params->vco_max) {
392 pr_err("%s: Failed to set %s rate %lu\n",
393 __func__, __clk_get_name(hw->clk), rate);
394 WARN_ON(1);
395 return -EINVAL; 438 return -EINVAL;
396 } 439 }
397 440
441 cfg->output_rate >>= p_div;
442
398 if (pll->params->pdiv_tohw) { 443 if (pll->params->pdiv_tohw) {
399 ret = _p_div_to_hw(hw, 1 << p_div); 444 ret = _p_div_to_hw(hw, 1 << p_div);
400 if (ret < 0) 445 if (ret < 0)
@@ -414,7 +459,7 @@ static void _update_pll_mnp(struct tegra_clk_pll *pll,
414 struct tegra_clk_pll_params *params = pll->params; 459 struct tegra_clk_pll_params *params = pll->params;
415 struct div_nmp *div_nmp = params->div_nmp; 460 struct div_nmp *div_nmp = params->div_nmp;
416 461
417 if ((pll->flags & TEGRA_PLLM) && 462 if ((params->flags & TEGRA_PLLM) &&
418 (pll_override_readl(PMC_PLLP_WB0_OVERRIDE, pll) & 463 (pll_override_readl(PMC_PLLP_WB0_OVERRIDE, pll) &
419 PMC_PLLP_WB0_OVERRIDE_PLLM_OVERRIDE)) { 464 PMC_PLLP_WB0_OVERRIDE_PLLM_OVERRIDE)) {
420 val = pll_override_readl(params->pmc_divp_reg, pll); 465 val = pll_override_readl(params->pmc_divp_reg, pll);
@@ -450,7 +495,7 @@ static void _get_pll_mnp(struct tegra_clk_pll *pll,
450 struct tegra_clk_pll_params *params = pll->params; 495 struct tegra_clk_pll_params *params = pll->params;
451 struct div_nmp *div_nmp = params->div_nmp; 496 struct div_nmp *div_nmp = params->div_nmp;
452 497
453 if ((pll->flags & TEGRA_PLLM) && 498 if ((params->flags & TEGRA_PLLM) &&
454 (pll_override_readl(PMC_PLLP_WB0_OVERRIDE, pll) & 499 (pll_override_readl(PMC_PLLP_WB0_OVERRIDE, pll) &
455 PMC_PLLP_WB0_OVERRIDE_PLLM_OVERRIDE)) { 500 PMC_PLLP_WB0_OVERRIDE_PLLM_OVERRIDE)) {
456 val = pll_override_readl(params->pmc_divp_reg, pll); 501 val = pll_override_readl(params->pmc_divp_reg, pll);
@@ -479,11 +524,11 @@ static void _update_pll_cpcon(struct tegra_clk_pll *pll,
479 val &= ~(PLL_MISC_CPCON_MASK << PLL_MISC_CPCON_SHIFT); 524 val &= ~(PLL_MISC_CPCON_MASK << PLL_MISC_CPCON_SHIFT);
480 val |= cfg->cpcon << PLL_MISC_CPCON_SHIFT; 525 val |= cfg->cpcon << PLL_MISC_CPCON_SHIFT;
481 526
482 if (pll->flags & TEGRA_PLL_SET_LFCON) { 527 if (pll->params->flags & TEGRA_PLL_SET_LFCON) {
483 val &= ~(PLL_MISC_LFCON_MASK << PLL_MISC_LFCON_SHIFT); 528 val &= ~(PLL_MISC_LFCON_MASK << PLL_MISC_LFCON_SHIFT);
484 if (cfg->n >= PLLDU_LFCON_SET_DIVN) 529 if (cfg->n >= PLLDU_LFCON_SET_DIVN)
485 val |= 1 << PLL_MISC_LFCON_SHIFT; 530 val |= 1 << PLL_MISC_LFCON_SHIFT;
486 } else if (pll->flags & TEGRA_PLL_SET_DCCON) { 531 } else if (pll->params->flags & TEGRA_PLL_SET_DCCON) {
487 val &= ~(1 << PLL_MISC_DCCON_SHIFT); 532 val &= ~(1 << PLL_MISC_DCCON_SHIFT);
488 if (rate >= (pll->params->vco_max >> 1)) 533 if (rate >= (pll->params->vco_max >> 1))
489 val |= 1 << PLL_MISC_DCCON_SHIFT; 534 val |= 1 << PLL_MISC_DCCON_SHIFT;
@@ -505,7 +550,7 @@ static int _program_pll(struct clk_hw *hw, struct tegra_clk_pll_freq_table *cfg,
505 550
506 _update_pll_mnp(pll, cfg); 551 _update_pll_mnp(pll, cfg);
507 552
508 if (pll->flags & TEGRA_PLL_HAS_CPCON) 553 if (pll->params->flags & TEGRA_PLL_HAS_CPCON)
509 _update_pll_cpcon(pll, cfg, rate); 554 _update_pll_cpcon(pll, cfg, rate);
510 555
511 if (state) { 556 if (state) {
@@ -524,11 +569,11 @@ static int clk_pll_set_rate(struct clk_hw *hw, unsigned long rate,
524 unsigned long flags = 0; 569 unsigned long flags = 0;
525 int ret = 0; 570 int ret = 0;
526 571
527 if (pll->flags & TEGRA_PLL_FIXED) { 572 if (pll->params->flags & TEGRA_PLL_FIXED) {
528 if (rate != pll->fixed_rate) { 573 if (rate != pll->params->fixed_rate) {
529 pr_err("%s: Can not change %s fixed rate %lu to %lu\n", 574 pr_err("%s: Can not change %s fixed rate %lu to %lu\n",
530 __func__, __clk_get_name(hw->clk), 575 __func__, __clk_get_name(hw->clk),
531 pll->fixed_rate, rate); 576 pll->params->fixed_rate, rate);
532 return -EINVAL; 577 return -EINVAL;
533 } 578 }
534 return 0; 579 return 0;
@@ -536,6 +581,8 @@ static int clk_pll_set_rate(struct clk_hw *hw, unsigned long rate,
536 581
537 if (_get_table_rate(hw, &cfg, rate, parent_rate) && 582 if (_get_table_rate(hw, &cfg, rate, parent_rate) &&
538 _calc_rate(hw, &cfg, rate, parent_rate)) { 583 _calc_rate(hw, &cfg, rate, parent_rate)) {
584 pr_err("%s: Failed to set %s rate %lu\n", __func__,
585 __clk_get_name(hw->clk), rate);
539 WARN_ON(1); 586 WARN_ON(1);
540 return -EINVAL; 587 return -EINVAL;
541 } 588 }
@@ -559,18 +606,16 @@ static long clk_pll_round_rate(struct clk_hw *hw, unsigned long rate,
559 struct tegra_clk_pll *pll = to_clk_pll(hw); 606 struct tegra_clk_pll *pll = to_clk_pll(hw);
560 struct tegra_clk_pll_freq_table cfg; 607 struct tegra_clk_pll_freq_table cfg;
561 608
562 if (pll->flags & TEGRA_PLL_FIXED) 609 if (pll->params->flags & TEGRA_PLL_FIXED)
563 return pll->fixed_rate; 610 return pll->params->fixed_rate;
564 611
565 /* PLLM is used for memory; we do not change rate */ 612 /* PLLM is used for memory; we do not change rate */
566 if (pll->flags & TEGRA_PLLM) 613 if (pll->params->flags & TEGRA_PLLM)
567 return __clk_get_rate(hw->clk); 614 return __clk_get_rate(hw->clk);
568 615
569 if (_get_table_rate(hw, &cfg, rate, *prate) && 616 if (_get_table_rate(hw, &cfg, rate, *prate) &&
570 _calc_rate(hw, &cfg, rate, *prate)) { 617 _calc_rate(hw, &cfg, rate, *prate))
571 WARN_ON(1);
572 return -EINVAL; 618 return -EINVAL;
573 }
574 619
575 return cfg.output_rate; 620 return cfg.output_rate;
576} 621}
@@ -586,17 +631,19 @@ static unsigned long clk_pll_recalc_rate(struct clk_hw *hw,
586 631
587 val = pll_readl_base(pll); 632 val = pll_readl_base(pll);
588 633
589 if ((pll->flags & TEGRA_PLL_BYPASS) && (val & PLL_BASE_BYPASS)) 634 if ((pll->params->flags & TEGRA_PLL_BYPASS) && (val & PLL_BASE_BYPASS))
590 return parent_rate; 635 return parent_rate;
591 636
592 if ((pll->flags & TEGRA_PLL_FIXED) && !(val & PLL_BASE_OVERRIDE)) { 637 if ((pll->params->flags & TEGRA_PLL_FIXED) &&
638 !(val & PLL_BASE_OVERRIDE)) {
593 struct tegra_clk_pll_freq_table sel; 639 struct tegra_clk_pll_freq_table sel;
594 if (_get_table_rate(hw, &sel, pll->fixed_rate, parent_rate)) { 640 if (_get_table_rate(hw, &sel, pll->params->fixed_rate,
641 parent_rate)) {
595 pr_err("Clock %s has unknown fixed frequency\n", 642 pr_err("Clock %s has unknown fixed frequency\n",
596 __clk_get_name(hw->clk)); 643 __clk_get_name(hw->clk));
597 BUG(); 644 BUG();
598 } 645 }
599 return pll->fixed_rate; 646 return pll->params->fixed_rate;
600 } 647 }
601 648
602 _get_pll_mnp(pll, &cfg); 649 _get_pll_mnp(pll, &cfg);
@@ -664,7 +711,7 @@ static int clk_plle_enable(struct clk_hw *hw)
664 u32 val; 711 u32 val;
665 int err; 712 int err;
666 713
667 if (_get_table_rate(hw, &sel, pll->fixed_rate, input_rate)) 714 if (_get_table_rate(hw, &sel, pll->params->fixed_rate, input_rate))
668 return -EINVAL; 715 return -EINVAL;
669 716
670 clk_pll_disable(hw); 717 clk_pll_disable(hw);
@@ -680,7 +727,7 @@ static int clk_plle_enable(struct clk_hw *hw)
680 return err; 727 return err;
681 } 728 }
682 729
683 if (pll->flags & TEGRA_PLLE_CONFIGURE) { 730 if (pll->params->flags & TEGRA_PLLE_CONFIGURE) {
684 /* configure dividers */ 731 /* configure dividers */
685 val = pll_readl_base(pll); 732 val = pll_readl_base(pll);
686 val &= ~(divm_mask(pll) | divn_mask(pll) | divp_mask(pll)); 733 val &= ~(divm_mask(pll) | divn_mask(pll) | divp_mask(pll));
@@ -744,7 +791,7 @@ const struct clk_ops tegra_clk_plle_ops = {
744 .enable = clk_plle_enable, 791 .enable = clk_plle_enable,
745}; 792};
746 793
747#ifdef CONFIG_ARCH_TEGRA_114_SOC 794#if defined(CONFIG_ARCH_TEGRA_114_SOC) || defined(CONFIG_ARCH_TEGRA_124_SOC)
748 795
749static int _pll_fixed_mdiv(struct tegra_clk_pll_params *pll_params, 796static int _pll_fixed_mdiv(struct tegra_clk_pll_params *pll_params,
750 unsigned long parent_rate) 797 unsigned long parent_rate)
@@ -755,6 +802,48 @@ static int _pll_fixed_mdiv(struct tegra_clk_pll_params *pll_params,
755 return 1; 802 return 1;
756} 803}
757 804
805static unsigned long _clip_vco_min(unsigned long vco_min,
806 unsigned long parent_rate)
807{
808 return DIV_ROUND_UP(vco_min, parent_rate) * parent_rate;
809}
810
811static int _setup_dynamic_ramp(struct tegra_clk_pll_params *pll_params,
812 void __iomem *clk_base,
813 unsigned long parent_rate)
814{
815 u32 val;
816 u32 step_a, step_b;
817
818 switch (parent_rate) {
819 case 12000000:
820 case 13000000:
821 case 26000000:
822 step_a = 0x2B;
823 step_b = 0x0B;
824 break;
825 case 16800000:
826 step_a = 0x1A;
827 step_b = 0x09;
828 break;
829 case 19200000:
830 step_a = 0x12;
831 step_b = 0x08;
832 break;
833 default:
834 pr_err("%s: Unexpected reference rate %lu\n",
835 __func__, parent_rate);
836 WARN_ON(1);
837 return -EINVAL;
838 }
839
840 val = step_a << pll_params->stepa_shift;
841 val |= step_b << pll_params->stepb_shift;
842 writel_relaxed(val, clk_base + pll_params->dyn_ramp_reg);
843
844 return 0;
845}
846
758static int clk_pll_iddq_enable(struct clk_hw *hw) 847static int clk_pll_iddq_enable(struct clk_hw *hw)
759{ 848{
760 struct tegra_clk_pll *pll = to_clk_pll(hw); 849 struct tegra_clk_pll *pll = to_clk_pll(hw);
@@ -1173,7 +1262,7 @@ static int clk_plle_tegra114_enable(struct clk_hw *hw)
1173 unsigned long flags = 0; 1262 unsigned long flags = 0;
1174 unsigned long input_rate = clk_get_rate(clk_get_parent(hw->clk)); 1263 unsigned long input_rate = clk_get_rate(clk_get_parent(hw->clk));
1175 1264
1176 if (_get_table_rate(hw, &sel, pll->fixed_rate, input_rate)) 1265 if (_get_table_rate(hw, &sel, pll->params->fixed_rate, input_rate))
1177 return -EINVAL; 1266 return -EINVAL;
1178 1267
1179 if (pll->lock) 1268 if (pll->lock)
@@ -1217,6 +1306,18 @@ static int clk_plle_tegra114_enable(struct clk_hw *hw)
1217 if (ret < 0) 1306 if (ret < 0)
1218 goto out; 1307 goto out;
1219 1308
1309 val = pll_readl(PLLE_SS_CTRL, pll);
1310 val &= ~(PLLE_SS_CNTL_CENTER | PLLE_SS_CNTL_INVERT);
1311 val &= ~PLLE_SS_COEFFICIENTS_MASK;
1312 val |= PLLE_SS_COEFFICIENTS_VAL;
1313 pll_writel(val, PLLE_SS_CTRL, pll);
1314 val &= ~(PLLE_SS_CNTL_SSC_BYP | PLLE_SS_CNTL_BYPASS_SS);
1315 pll_writel(val, PLLE_SS_CTRL, pll);
1316 udelay(1);
1317 val &= ~PLLE_SS_CNTL_INTERP_RESET;
1318 pll_writel(val, PLLE_SS_CTRL, pll);
1319 udelay(1);
1320
1220 /* TODO: enable hw control of xusb brick pll */ 1321 /* TODO: enable hw control of xusb brick pll */
1221 1322
1222out: 1323out:
@@ -1248,9 +1349,8 @@ static void clk_plle_tegra114_disable(struct clk_hw *hw)
1248#endif 1349#endif
1249 1350
1250static struct tegra_clk_pll *_tegra_init_pll(void __iomem *clk_base, 1351static struct tegra_clk_pll *_tegra_init_pll(void __iomem *clk_base,
1251 void __iomem *pmc, unsigned long fixed_rate, 1352 void __iomem *pmc, struct tegra_clk_pll_params *pll_params,
1252 struct tegra_clk_pll_params *pll_params, u32 pll_flags, 1353 spinlock_t *lock)
1253 struct tegra_clk_pll_freq_table *freq_table, spinlock_t *lock)
1254{ 1354{
1255 struct tegra_clk_pll *pll; 1355 struct tegra_clk_pll *pll;
1256 1356
@@ -1261,10 +1361,7 @@ static struct tegra_clk_pll *_tegra_init_pll(void __iomem *clk_base,
1261 pll->clk_base = clk_base; 1361 pll->clk_base = clk_base;
1262 pll->pmc = pmc; 1362 pll->pmc = pmc;
1263 1363
1264 pll->freq_table = freq_table;
1265 pll->params = pll_params; 1364 pll->params = pll_params;
1266 pll->fixed_rate = fixed_rate;
1267 pll->flags = pll_flags;
1268 pll->lock = lock; 1365 pll->lock = lock;
1269 1366
1270 if (!pll_params->div_nmp) 1367 if (!pll_params->div_nmp)
@@ -1293,17 +1390,15 @@ static struct clk *_tegra_clk_register_pll(struct tegra_clk_pll *pll,
1293 1390
1294struct clk *tegra_clk_register_pll(const char *name, const char *parent_name, 1391struct clk *tegra_clk_register_pll(const char *name, const char *parent_name,
1295 void __iomem *clk_base, void __iomem *pmc, 1392 void __iomem *clk_base, void __iomem *pmc,
1296 unsigned long flags, unsigned long fixed_rate, 1393 unsigned long flags, struct tegra_clk_pll_params *pll_params,
1297 struct tegra_clk_pll_params *pll_params, u32 pll_flags, 1394 spinlock_t *lock)
1298 struct tegra_clk_pll_freq_table *freq_table, spinlock_t *lock)
1299{ 1395{
1300 struct tegra_clk_pll *pll; 1396 struct tegra_clk_pll *pll;
1301 struct clk *clk; 1397 struct clk *clk;
1302 1398
1303 pll_flags |= TEGRA_PLL_BYPASS; 1399 pll_params->flags |= TEGRA_PLL_BYPASS;
1304 pll_flags |= TEGRA_PLL_HAS_LOCK_ENABLE; 1400 pll_params->flags |= TEGRA_PLL_HAS_LOCK_ENABLE;
1305 pll = _tegra_init_pll(clk_base, pmc, fixed_rate, pll_params, pll_flags, 1401 pll = _tegra_init_pll(clk_base, pmc, pll_params, lock);
1306 freq_table, lock);
1307 if (IS_ERR(pll)) 1402 if (IS_ERR(pll))
1308 return ERR_CAST(pll); 1403 return ERR_CAST(pll);
1309 1404
@@ -1317,17 +1412,15 @@ struct clk *tegra_clk_register_pll(const char *name, const char *parent_name,
1317 1412
1318struct clk *tegra_clk_register_plle(const char *name, const char *parent_name, 1413struct clk *tegra_clk_register_plle(const char *name, const char *parent_name,
1319 void __iomem *clk_base, void __iomem *pmc, 1414 void __iomem *clk_base, void __iomem *pmc,
1320 unsigned long flags, unsigned long fixed_rate, 1415 unsigned long flags, struct tegra_clk_pll_params *pll_params,
1321 struct tegra_clk_pll_params *pll_params, u32 pll_flags, 1416 spinlock_t *lock)
1322 struct tegra_clk_pll_freq_table *freq_table, spinlock_t *lock)
1323{ 1417{
1324 struct tegra_clk_pll *pll; 1418 struct tegra_clk_pll *pll;
1325 struct clk *clk; 1419 struct clk *clk;
1326 1420
1327 pll_flags |= TEGRA_PLL_LOCK_MISC | TEGRA_PLL_BYPASS; 1421 pll_params->flags |= TEGRA_PLL_LOCK_MISC | TEGRA_PLL_BYPASS;
1328 pll_flags |= TEGRA_PLL_HAS_LOCK_ENABLE; 1422 pll_params->flags |= TEGRA_PLL_HAS_LOCK_ENABLE;
1329 pll = _tegra_init_pll(clk_base, pmc, fixed_rate, pll_params, pll_flags, 1423 pll = _tegra_init_pll(clk_base, pmc, pll_params, lock);
1330 freq_table, lock);
1331 if (IS_ERR(pll)) 1424 if (IS_ERR(pll))
1332 return ERR_CAST(pll); 1425 return ERR_CAST(pll);
1333 1426
@@ -1339,7 +1432,7 @@ struct clk *tegra_clk_register_plle(const char *name, const char *parent_name,
1339 return clk; 1432 return clk;
1340} 1433}
1341 1434
1342#ifdef CONFIG_ARCH_TEGRA_114_SOC 1435#if defined(CONFIG_ARCH_TEGRA_114_SOC) || defined(CONFIG_ARCH_TEGRA_124_SOC)
1343const struct clk_ops tegra_clk_pllxc_ops = { 1436const struct clk_ops tegra_clk_pllxc_ops = {
1344 .is_enabled = clk_pll_is_enabled, 1437 .is_enabled = clk_pll_is_enabled,
1345 .enable = clk_pll_iddq_enable, 1438 .enable = clk_pll_iddq_enable,
@@ -1386,21 +1479,46 @@ const struct clk_ops tegra_clk_plle_tegra114_ops = {
1386 1479
1387struct clk *tegra_clk_register_pllxc(const char *name, const char *parent_name, 1480struct clk *tegra_clk_register_pllxc(const char *name, const char *parent_name,
1388 void __iomem *clk_base, void __iomem *pmc, 1481 void __iomem *clk_base, void __iomem *pmc,
1389 unsigned long flags, unsigned long fixed_rate, 1482 unsigned long flags,
1390 struct tegra_clk_pll_params *pll_params, 1483 struct tegra_clk_pll_params *pll_params,
1391 u32 pll_flags,
1392 struct tegra_clk_pll_freq_table *freq_table,
1393 spinlock_t *lock) 1484 spinlock_t *lock)
1394{ 1485{
1395 struct tegra_clk_pll *pll; 1486 struct tegra_clk_pll *pll;
1396 struct clk *clk; 1487 struct clk *clk, *parent;
1488 unsigned long parent_rate;
1489 int err;
1490 u32 val, val_iddq;
1491
1492 parent = __clk_lookup(parent_name);
1493 if (!parent) {
1494 WARN(1, "parent clk %s of %s must be registered first\n",
1495 name, parent_name);
1496 return ERR_PTR(-EINVAL);
1497 }
1397 1498
1398 if (!pll_params->pdiv_tohw) 1499 if (!pll_params->pdiv_tohw)
1399 return ERR_PTR(-EINVAL); 1500 return ERR_PTR(-EINVAL);
1400 1501
1401 pll_flags |= TEGRA_PLL_HAS_LOCK_ENABLE; 1502 parent_rate = __clk_get_rate(parent);
1402 pll = _tegra_init_pll(clk_base, pmc, fixed_rate, pll_params, pll_flags, 1503
1403 freq_table, lock); 1504 pll_params->vco_min = _clip_vco_min(pll_params->vco_min, parent_rate);
1505
1506 err = _setup_dynamic_ramp(pll_params, clk_base, parent_rate);
1507 if (err)
1508 return ERR_PTR(err);
1509
1510 val = readl_relaxed(clk_base + pll_params->base_reg);
1511 val_iddq = readl_relaxed(clk_base + pll_params->iddq_reg);
1512
1513 if (val & PLL_BASE_ENABLE)
1514 WARN_ON(val_iddq & BIT(pll_params->iddq_bit_idx));
1515 else {
1516 val_iddq |= BIT(pll_params->iddq_bit_idx);
1517 writel_relaxed(val_iddq, clk_base + pll_params->iddq_reg);
1518 }
1519
1520 pll_params->flags |= TEGRA_PLL_HAS_LOCK_ENABLE;
1521 pll = _tegra_init_pll(clk_base, pmc, pll_params, lock);
1404 if (IS_ERR(pll)) 1522 if (IS_ERR(pll))
1405 return ERR_CAST(pll); 1523 return ERR_CAST(pll);
1406 1524
@@ -1414,19 +1532,19 @@ struct clk *tegra_clk_register_pllxc(const char *name, const char *parent_name,
1414 1532
1415struct clk *tegra_clk_register_pllre(const char *name, const char *parent_name, 1533struct clk *tegra_clk_register_pllre(const char *name, const char *parent_name,
1416 void __iomem *clk_base, void __iomem *pmc, 1534 void __iomem *clk_base, void __iomem *pmc,
1417 unsigned long flags, unsigned long fixed_rate, 1535 unsigned long flags,
1418 struct tegra_clk_pll_params *pll_params, 1536 struct tegra_clk_pll_params *pll_params,
1419 u32 pll_flags,
1420 struct tegra_clk_pll_freq_table *freq_table,
1421 spinlock_t *lock, unsigned long parent_rate) 1537 spinlock_t *lock, unsigned long parent_rate)
1422{ 1538{
1423 u32 val; 1539 u32 val;
1424 struct tegra_clk_pll *pll; 1540 struct tegra_clk_pll *pll;
1425 struct clk *clk; 1541 struct clk *clk;
1426 1542
1427 pll_flags |= TEGRA_PLL_HAS_LOCK_ENABLE | TEGRA_PLL_LOCK_MISC; 1543 pll_params->flags |= TEGRA_PLL_HAS_LOCK_ENABLE | TEGRA_PLL_LOCK_MISC;
1428 pll = _tegra_init_pll(clk_base, pmc, fixed_rate, pll_params, pll_flags, 1544
1429 freq_table, lock); 1545 pll_params->vco_min = _clip_vco_min(pll_params->vco_min, parent_rate);
1546
1547 pll = _tegra_init_pll(clk_base, pmc, pll_params, lock);
1430 if (IS_ERR(pll)) 1548 if (IS_ERR(pll))
1431 return ERR_CAST(pll); 1549 return ERR_CAST(pll);
1432 1550
@@ -1461,23 +1579,32 @@ struct clk *tegra_clk_register_pllre(const char *name, const char *parent_name,
1461 1579
1462struct clk *tegra_clk_register_pllm(const char *name, const char *parent_name, 1580struct clk *tegra_clk_register_pllm(const char *name, const char *parent_name,
1463 void __iomem *clk_base, void __iomem *pmc, 1581 void __iomem *clk_base, void __iomem *pmc,
1464 unsigned long flags, unsigned long fixed_rate, 1582 unsigned long flags,
1465 struct tegra_clk_pll_params *pll_params, 1583 struct tegra_clk_pll_params *pll_params,
1466 u32 pll_flags,
1467 struct tegra_clk_pll_freq_table *freq_table,
1468 spinlock_t *lock) 1584 spinlock_t *lock)
1469{ 1585{
1470 struct tegra_clk_pll *pll; 1586 struct tegra_clk_pll *pll;
1471 struct clk *clk; 1587 struct clk *clk, *parent;
1588 unsigned long parent_rate;
1472 1589
1473 if (!pll_params->pdiv_tohw) 1590 if (!pll_params->pdiv_tohw)
1474 return ERR_PTR(-EINVAL); 1591 return ERR_PTR(-EINVAL);
1475 1592
1476 pll_flags |= TEGRA_PLL_BYPASS; 1593 parent = __clk_lookup(parent_name);
1477 pll_flags |= TEGRA_PLL_HAS_LOCK_ENABLE; 1594 if (!parent) {
1478 pll_flags |= TEGRA_PLLM; 1595 WARN(1, "parent clk %s of %s must be registered first\n",
1479 pll = _tegra_init_pll(clk_base, pmc, fixed_rate, pll_params, pll_flags, 1596 name, parent_name);
1480 freq_table, lock); 1597 return ERR_PTR(-EINVAL);
1598 }
1599
1600 parent_rate = __clk_get_rate(parent);
1601
1602 pll_params->vco_min = _clip_vco_min(pll_params->vco_min, parent_rate);
1603
1604 pll_params->flags |= TEGRA_PLL_BYPASS;
1605 pll_params->flags |= TEGRA_PLL_HAS_LOCK_ENABLE;
1606 pll_params->flags |= TEGRA_PLLM;
1607 pll = _tegra_init_pll(clk_base, pmc, pll_params, lock);
1481 if (IS_ERR(pll)) 1608 if (IS_ERR(pll))
1482 return ERR_CAST(pll); 1609 return ERR_CAST(pll);
1483 1610
@@ -1491,10 +1618,8 @@ struct clk *tegra_clk_register_pllm(const char *name, const char *parent_name,
1491 1618
1492struct clk *tegra_clk_register_pllc(const char *name, const char *parent_name, 1619struct clk *tegra_clk_register_pllc(const char *name, const char *parent_name,
1493 void __iomem *clk_base, void __iomem *pmc, 1620 void __iomem *clk_base, void __iomem *pmc,
1494 unsigned long flags, unsigned long fixed_rate, 1621 unsigned long flags,
1495 struct tegra_clk_pll_params *pll_params, 1622 struct tegra_clk_pll_params *pll_params,
1496 u32 pll_flags,
1497 struct tegra_clk_pll_freq_table *freq_table,
1498 spinlock_t *lock) 1623 spinlock_t *lock)
1499{ 1624{
1500 struct clk *parent, *clk; 1625 struct clk *parent, *clk;
@@ -1507,20 +1632,21 @@ struct clk *tegra_clk_register_pllc(const char *name, const char *parent_name,
1507 return ERR_PTR(-EINVAL); 1632 return ERR_PTR(-EINVAL);
1508 1633
1509 parent = __clk_lookup(parent_name); 1634 parent = __clk_lookup(parent_name);
1510 if (IS_ERR(parent)) { 1635 if (!parent) {
1511 WARN(1, "parent clk %s of %s must be registered first\n", 1636 WARN(1, "parent clk %s of %s must be registered first\n",
1512 name, parent_name); 1637 name, parent_name);
1513 return ERR_PTR(-EINVAL); 1638 return ERR_PTR(-EINVAL);
1514 } 1639 }
1515 1640
1516 pll_flags |= TEGRA_PLL_BYPASS; 1641 parent_rate = __clk_get_rate(parent);
1517 pll = _tegra_init_pll(clk_base, pmc, fixed_rate, pll_params, pll_flags, 1642
1518 freq_table, lock); 1643 pll_params->vco_min = _clip_vco_min(pll_params->vco_min, parent_rate);
1644
1645 pll_params->flags |= TEGRA_PLL_BYPASS;
1646 pll = _tegra_init_pll(clk_base, pmc, pll_params, lock);
1519 if (IS_ERR(pll)) 1647 if (IS_ERR(pll))
1520 return ERR_CAST(pll); 1648 return ERR_CAST(pll);
1521 1649
1522 parent_rate = __clk_get_rate(parent);
1523
1524 /* 1650 /*
1525 * Most of PLLC register fields are shadowed, and can not be read 1651 * Most of PLLC register fields are shadowed, and can not be read
1526 * directly from PLL h/w. Hence, actual PLLC boot state is unknown. 1652 * directly from PLL h/w. Hence, actual PLLC boot state is unknown.
@@ -1567,17 +1693,15 @@ struct clk *tegra_clk_register_pllc(const char *name, const char *parent_name,
1567struct clk *tegra_clk_register_plle_tegra114(const char *name, 1693struct clk *tegra_clk_register_plle_tegra114(const char *name,
1568 const char *parent_name, 1694 const char *parent_name,
1569 void __iomem *clk_base, unsigned long flags, 1695 void __iomem *clk_base, unsigned long flags,
1570 unsigned long fixed_rate,
1571 struct tegra_clk_pll_params *pll_params, 1696 struct tegra_clk_pll_params *pll_params,
1572 struct tegra_clk_pll_freq_table *freq_table,
1573 spinlock_t *lock) 1697 spinlock_t *lock)
1574{ 1698{
1575 struct tegra_clk_pll *pll; 1699 struct tegra_clk_pll *pll;
1576 struct clk *clk; 1700 struct clk *clk;
1577 u32 val, val_aux; 1701 u32 val, val_aux;
1578 1702
1579 pll = _tegra_init_pll(clk_base, NULL, fixed_rate, pll_params, 1703 pll_params->flags |= TEGRA_PLL_HAS_LOCK_ENABLE;
1580 TEGRA_PLL_HAS_LOCK_ENABLE, freq_table, lock); 1704 pll = _tegra_init_pll(clk_base, NULL, pll_params, lock);
1581 if (IS_ERR(pll)) 1705 if (IS_ERR(pll))
1582 return ERR_CAST(pll); 1706 return ERR_CAST(pll);
1583 1707
@@ -1587,11 +1711,13 @@ struct clk *tegra_clk_register_plle_tegra114(const char *name,
1587 val_aux = pll_readl(pll_params->aux_reg, pll); 1711 val_aux = pll_readl(pll_params->aux_reg, pll);
1588 1712
1589 if (val & PLL_BASE_ENABLE) { 1713 if (val & PLL_BASE_ENABLE) {
1590 if (!(val_aux & PLLE_AUX_PLLRE_SEL)) 1714 if ((val_aux & PLLE_AUX_PLLRE_SEL) ||
1715 (val_aux & PLLE_AUX_PLLP_SEL))
1591 WARN(1, "pll_e enabled with unsupported parent %s\n", 1716 WARN(1, "pll_e enabled with unsupported parent %s\n",
1592 (val & PLLE_AUX_PLLP_SEL) ? "pllp_out0" : "pll_ref"); 1717 (val_aux & PLLE_AUX_PLLP_SEL) ? "pllp_out0" :
1718 "pll_re_vco");
1593 } else { 1719 } else {
1594 val_aux |= PLLE_AUX_PLLRE_SEL; 1720 val_aux &= ~(PLLE_AUX_PLLRE_SEL | PLLE_AUX_PLLP_SEL);
1595 pll_writel(val, pll_params->aux_reg, pll); 1721 pll_writel(val, pll_params->aux_reg, pll);
1596 } 1722 }
1597 1723
@@ -1603,3 +1729,92 @@ struct clk *tegra_clk_register_plle_tegra114(const char *name,
1603 return clk; 1729 return clk;
1604} 1730}
1605#endif 1731#endif
1732
1733#ifdef CONFIG_ARCH_TEGRA_124_SOC
1734const struct clk_ops tegra_clk_pllss_ops = {
1735 .is_enabled = clk_pll_is_enabled,
1736 .enable = clk_pll_iddq_enable,
1737 .disable = clk_pll_iddq_disable,
1738 .recalc_rate = clk_pll_recalc_rate,
1739 .round_rate = clk_pll_ramp_round_rate,
1740 .set_rate = clk_pllxc_set_rate,
1741};
1742
1743struct clk *tegra_clk_register_pllss(const char *name, const char *parent_name,
1744 void __iomem *clk_base, unsigned long flags,
1745 struct tegra_clk_pll_params *pll_params,
1746 spinlock_t *lock)
1747{
1748 struct tegra_clk_pll *pll;
1749 struct clk *clk, *parent;
1750 struct tegra_clk_pll_freq_table cfg;
1751 unsigned long parent_rate;
1752 u32 val;
1753 int i;
1754
1755 if (!pll_params->div_nmp)
1756 return ERR_PTR(-EINVAL);
1757
1758 parent = __clk_lookup(parent_name);
1759 if (!parent) {
1760 WARN(1, "parent clk %s of %s must be registered first\n",
1761 name, parent_name);
1762 return ERR_PTR(-EINVAL);
1763 }
1764
1765 pll_params->flags = TEGRA_PLL_HAS_LOCK_ENABLE | TEGRA_PLL_USE_LOCK;
1766 pll = _tegra_init_pll(clk_base, NULL, pll_params, lock);
1767 if (IS_ERR(pll))
1768 return ERR_CAST(pll);
1769
1770 val = pll_readl_base(pll);
1771 val &= ~PLLSS_REF_SRC_SEL_MASK;
1772 pll_writel_base(val, pll);
1773
1774 parent_rate = __clk_get_rate(parent);
1775
1776 pll_params->vco_min = _clip_vco_min(pll_params->vco_min, parent_rate);
1777
1778 /* initialize PLL to minimum rate */
1779
1780 cfg.m = _pll_fixed_mdiv(pll_params, parent_rate);
1781 cfg.n = cfg.m * pll_params->vco_min / parent_rate;
1782
1783 for (i = 0; pll_params->pdiv_tohw[i].pdiv; i++)
1784 ;
1785 if (!i) {
1786 kfree(pll);
1787 return ERR_PTR(-EINVAL);
1788 }
1789
1790 cfg.p = pll_params->pdiv_tohw[i-1].hw_val;
1791
1792 _update_pll_mnp(pll, &cfg);
1793
1794 pll_writel_misc(PLLSS_MISC_DEFAULT, pll);
1795 pll_writel(PLLSS_CFG_DEFAULT, pll_params->ext_misc_reg[0], pll);
1796 pll_writel(PLLSS_CTRL1_DEFAULT, pll_params->ext_misc_reg[1], pll);
1797 pll_writel(PLLSS_CTRL1_DEFAULT, pll_params->ext_misc_reg[2], pll);
1798
1799 val = pll_readl_base(pll);
1800 if (val & PLL_BASE_ENABLE) {
1801 if (val & BIT(pll_params->iddq_bit_idx)) {
1802 WARN(1, "%s is on but IDDQ set\n", name);
1803 kfree(pll);
1804 return ERR_PTR(-EINVAL);
1805 }
1806 } else
1807 val |= BIT(pll_params->iddq_bit_idx);
1808
1809 val &= ~PLLSS_LOCK_OVERRIDE;
1810 pll_writel_base(val, pll);
1811
1812 clk = _tegra_clk_register_pll(pll, name, parent_name, flags,
1813 &tegra_clk_pllss_ops);
1814
1815 if (IS_ERR(clk))
1816 kfree(pll);
1817
1818 return clk;
1819}
1820#endif
diff --git a/drivers/clk/tegra/clk-tegra-audio.c b/drivers/clk/tegra/clk-tegra-audio.c
new file mode 100644
index 000000000000..5c38aab2c5b8
--- /dev/null
+++ b/drivers/clk/tegra/clk-tegra-audio.c
@@ -0,0 +1,215 @@
1/*
2 * Copyright (c) 2012, 2013, 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#include <linux/io.h>
18#include <linux/clk.h>
19#include <linux/clk-provider.h>
20#include <linux/of.h>
21#include <linux/of_address.h>
22#include <linux/delay.h>
23#include <linux/export.h>
24#include <linux/clk/tegra.h>
25
26#include "clk.h"
27#include "clk-id.h"
28
29#define AUDIO_SYNC_CLK_I2S0 0x4a0
30#define AUDIO_SYNC_CLK_I2S1 0x4a4
31#define AUDIO_SYNC_CLK_I2S2 0x4a8
32#define AUDIO_SYNC_CLK_I2S3 0x4ac
33#define AUDIO_SYNC_CLK_I2S4 0x4b0
34#define AUDIO_SYNC_CLK_SPDIF 0x4b4
35
36#define AUDIO_SYNC_DOUBLER 0x49c
37
38#define PLLA_OUT 0xb4
39
40struct tegra_sync_source_initdata {
41 char *name;
42 unsigned long rate;
43 unsigned long max_rate;
44 int clk_id;
45};
46
47#define SYNC(_name) \
48 {\
49 .name = #_name,\
50 .rate = 24000000,\
51 .max_rate = 24000000,\
52 .clk_id = tegra_clk_ ## _name,\
53 }
54
55struct tegra_audio_clk_initdata {
56 char *gate_name;
57 char *mux_name;
58 u32 offset;
59 int gate_clk_id;
60 int mux_clk_id;
61};
62
63#define AUDIO(_name, _offset) \
64 {\
65 .gate_name = #_name,\
66 .mux_name = #_name"_mux",\
67 .offset = _offset,\
68 .gate_clk_id = tegra_clk_ ## _name,\
69 .mux_clk_id = tegra_clk_ ## _name ## _mux,\
70 }
71
72struct tegra_audio2x_clk_initdata {
73 char *parent;
74 char *gate_name;
75 char *name_2x;
76 char *div_name;
77 int clk_id;
78 int clk_num;
79 u8 div_offset;
80};
81
82#define AUDIO2X(_name, _num, _offset) \
83 {\
84 .parent = #_name,\
85 .gate_name = #_name"_2x",\
86 .name_2x = #_name"_doubler",\
87 .div_name = #_name"_div",\
88 .clk_id = tegra_clk_ ## _name ## _2x,\
89 .clk_num = _num,\
90 .div_offset = _offset,\
91 }
92
93static DEFINE_SPINLOCK(clk_doubler_lock);
94
95static const char *mux_audio_sync_clk[] = { "spdif_in_sync", "i2s0_sync",
96 "i2s1_sync", "i2s2_sync", "i2s3_sync", "i2s4_sync", "vimclk_sync",
97};
98
99static struct tegra_sync_source_initdata sync_source_clks[] __initdata = {
100 SYNC(spdif_in_sync),
101 SYNC(i2s0_sync),
102 SYNC(i2s1_sync),
103 SYNC(i2s2_sync),
104 SYNC(i2s3_sync),
105 SYNC(i2s4_sync),
106 SYNC(vimclk_sync),
107};
108
109static struct tegra_audio_clk_initdata audio_clks[] = {
110 AUDIO(audio0, AUDIO_SYNC_CLK_I2S0),
111 AUDIO(audio1, AUDIO_SYNC_CLK_I2S1),
112 AUDIO(audio2, AUDIO_SYNC_CLK_I2S2),
113 AUDIO(audio3, AUDIO_SYNC_CLK_I2S3),
114 AUDIO(audio4, AUDIO_SYNC_CLK_I2S4),
115 AUDIO(spdif, AUDIO_SYNC_CLK_SPDIF),
116};
117
118static struct tegra_audio2x_clk_initdata audio2x_clks[] = {
119 AUDIO2X(audio0, 113, 24),
120 AUDIO2X(audio1, 114, 25),
121 AUDIO2X(audio2, 115, 26),
122 AUDIO2X(audio3, 116, 27),
123 AUDIO2X(audio4, 117, 28),
124 AUDIO2X(spdif, 118, 29),
125};
126
127void __init tegra_audio_clk_init(void __iomem *clk_base,
128 void __iomem *pmc_base, struct tegra_clk *tegra_clks,
129 struct tegra_clk_pll_params *pll_a_params)
130{
131 struct clk *clk;
132 struct clk **dt_clk;
133 int i;
134
135 /* PLLA */
136 dt_clk = tegra_lookup_dt_id(tegra_clk_pll_a, tegra_clks);
137 if (dt_clk) {
138 clk = tegra_clk_register_pll("pll_a", "pll_p_out1", clk_base,
139 pmc_base, 0, pll_a_params, NULL);
140 *dt_clk = clk;
141 }
142
143 /* PLLA_OUT0 */
144 dt_clk = tegra_lookup_dt_id(tegra_clk_pll_a_out0, tegra_clks);
145 if (dt_clk) {
146 clk = tegra_clk_register_divider("pll_a_out0_div", "pll_a",
147 clk_base + PLLA_OUT, 0, TEGRA_DIVIDER_ROUND_UP,
148 8, 8, 1, NULL);
149 clk = tegra_clk_register_pll_out("pll_a_out0", "pll_a_out0_div",
150 clk_base + PLLA_OUT, 1, 0, CLK_IGNORE_UNUSED |
151 CLK_SET_RATE_PARENT, 0, NULL);
152 *dt_clk = clk;
153 }
154
155 for (i = 0; i < ARRAY_SIZE(sync_source_clks); i++) {
156 struct tegra_sync_source_initdata *data;
157
158 data = &sync_source_clks[i];
159
160 dt_clk = tegra_lookup_dt_id(data->clk_id, tegra_clks);
161 if (!dt_clk)
162 continue;
163
164 clk = tegra_clk_register_sync_source(data->name,
165 data->rate, data->max_rate);
166 *dt_clk = clk;
167 }
168
169 for (i = 0; i < ARRAY_SIZE(audio_clks); i++) {
170 struct tegra_audio_clk_initdata *data;
171
172 data = &audio_clks[i];
173 dt_clk = tegra_lookup_dt_id(data->mux_clk_id, tegra_clks);
174
175 if (!dt_clk)
176 continue;
177 clk = clk_register_mux(NULL, data->mux_name, mux_audio_sync_clk,
178 ARRAY_SIZE(mux_audio_sync_clk),
179 CLK_SET_RATE_NO_REPARENT,
180 clk_base + data->offset, 0, 3, 0,
181 NULL);
182 *dt_clk = clk;
183
184 dt_clk = tegra_lookup_dt_id(data->gate_clk_id, tegra_clks);
185 if (!dt_clk)
186 continue;
187
188 clk = clk_register_gate(NULL, data->gate_name, data->mux_name,
189 0, clk_base + data->offset, 4,
190 CLK_GATE_SET_TO_DISABLE, NULL);
191 *dt_clk = clk;
192 }
193
194 for (i = 0; i < ARRAY_SIZE(audio2x_clks); i++) {
195 struct tegra_audio2x_clk_initdata *data;
196
197 data = &audio2x_clks[i];
198 dt_clk = tegra_lookup_dt_id(data->clk_id, tegra_clks);
199 if (!dt_clk)
200 continue;
201
202 clk = clk_register_fixed_factor(NULL, data->name_2x,
203 data->parent, CLK_SET_RATE_PARENT, 2, 1);
204 clk = tegra_clk_register_divider(data->div_name,
205 data->name_2x, clk_base + AUDIO_SYNC_DOUBLER,
206 0, 0, data->div_offset, 1, 0,
207 &clk_doubler_lock);
208 clk = tegra_clk_register_periph_gate(data->gate_name,
209 data->div_name, TEGRA_PERIPH_NO_RESET,
210 clk_base, CLK_SET_RATE_PARENT, data->clk_num,
211 periph_clk_enb_refcnt);
212 *dt_clk = clk;
213 }
214}
215
diff --git a/drivers/clk/tegra/clk-tegra-fixed.c b/drivers/clk/tegra/clk-tegra-fixed.c
new file mode 100644
index 000000000000..f3b773833429
--- /dev/null
+++ b/drivers/clk/tegra/clk-tegra-fixed.c
@@ -0,0 +1,111 @@
1/*
2 * Copyright (c) 2012, 2013, 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#include <linux/io.h>
18#include <linux/clk.h>
19#include <linux/clk-provider.h>
20#include <linux/of.h>
21#include <linux/of_address.h>
22#include <linux/delay.h>
23#include <linux/export.h>
24#include <linux/clk/tegra.h>
25
26#include "clk.h"
27#include "clk-id.h"
28
29#define OSC_CTRL 0x50
30#define OSC_CTRL_OSC_FREQ_SHIFT 28
31#define OSC_CTRL_PLL_REF_DIV_SHIFT 26
32
33int __init tegra_osc_clk_init(void __iomem *clk_base,
34 struct tegra_clk *tegra_clks,
35 unsigned long *input_freqs, int num,
36 unsigned long *osc_freq,
37 unsigned long *pll_ref_freq)
38{
39 struct clk *clk;
40 struct clk **dt_clk;
41 u32 val, pll_ref_div;
42 unsigned osc_idx;
43
44 val = readl_relaxed(clk_base + OSC_CTRL);
45 osc_idx = val >> OSC_CTRL_OSC_FREQ_SHIFT;
46
47 if (osc_idx < num)
48 *osc_freq = input_freqs[osc_idx];
49 else
50 *osc_freq = 0;
51
52 if (!*osc_freq) {
53 WARN_ON(1);
54 return -EINVAL;
55 }
56
57 dt_clk = tegra_lookup_dt_id(tegra_clk_clk_m, tegra_clks);
58 if (!dt_clk)
59 return 0;
60
61 clk = clk_register_fixed_rate(NULL, "clk_m", NULL, CLK_IS_ROOT,
62 *osc_freq);
63 *dt_clk = clk;
64
65 /* pll_ref */
66 val = (val >> OSC_CTRL_PLL_REF_DIV_SHIFT) & 3;
67 pll_ref_div = 1 << val;
68 dt_clk = tegra_lookup_dt_id(tegra_clk_pll_ref, tegra_clks);
69 if (!dt_clk)
70 return 0;
71
72 clk = clk_register_fixed_factor(NULL, "pll_ref", "clk_m",
73 0, 1, pll_ref_div);
74 *dt_clk = clk;
75
76 if (pll_ref_freq)
77 *pll_ref_freq = *osc_freq / pll_ref_div;
78
79 return 0;
80}
81
82void __init tegra_fixed_clk_init(struct tegra_clk *tegra_clks)
83{
84 struct clk *clk;
85 struct clk **dt_clk;
86
87 /* clk_32k */
88 dt_clk = tegra_lookup_dt_id(tegra_clk_clk_32k, tegra_clks);
89 if (dt_clk) {
90 clk = clk_register_fixed_rate(NULL, "clk_32k", NULL,
91 CLK_IS_ROOT, 32768);
92 *dt_clk = clk;
93 }
94
95 /* clk_m_div2 */
96 dt_clk = tegra_lookup_dt_id(tegra_clk_clk_m_div2, tegra_clks);
97 if (dt_clk) {
98 clk = clk_register_fixed_factor(NULL, "clk_m_div2", "clk_m",
99 CLK_SET_RATE_PARENT, 1, 2);
100 *dt_clk = clk;
101 }
102
103 /* clk_m_div4 */
104 dt_clk = tegra_lookup_dt_id(tegra_clk_clk_m_div4, tegra_clks);
105 if (dt_clk) {
106 clk = clk_register_fixed_factor(NULL, "clk_m_div4", "clk_m",
107 CLK_SET_RATE_PARENT, 1, 4);
108 *dt_clk = clk;
109 }
110}
111
diff --git a/drivers/clk/tegra/clk-tegra-periph.c b/drivers/clk/tegra/clk-tegra-periph.c
new file mode 100644
index 000000000000..5c35885f4a7c
--- /dev/null
+++ b/drivers/clk/tegra/clk-tegra-periph.c
@@ -0,0 +1,674 @@
1/*
2 * Copyright (c) 2012, 2013, 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#include <linux/io.h>
18#include <linux/clk.h>
19#include <linux/clk-provider.h>
20#include <linux/clkdev.h>
21#include <linux/of.h>
22#include <linux/of_address.h>
23#include <linux/delay.h>
24#include <linux/export.h>
25#include <linux/clk/tegra.h>
26
27#include "clk.h"
28#include "clk-id.h"
29
30#define CLK_SOURCE_I2S0 0x1d8
31#define CLK_SOURCE_I2S1 0x100
32#define CLK_SOURCE_I2S2 0x104
33#define CLK_SOURCE_NDFLASH 0x160
34#define CLK_SOURCE_I2S3 0x3bc
35#define CLK_SOURCE_I2S4 0x3c0
36#define CLK_SOURCE_SPDIF_OUT 0x108
37#define CLK_SOURCE_SPDIF_IN 0x10c
38#define CLK_SOURCE_PWM 0x110
39#define CLK_SOURCE_ADX 0x638
40#define CLK_SOURCE_ADX1 0x670
41#define CLK_SOURCE_AMX 0x63c
42#define CLK_SOURCE_AMX1 0x674
43#define CLK_SOURCE_HDA 0x428
44#define CLK_SOURCE_HDA2CODEC_2X 0x3e4
45#define CLK_SOURCE_SBC1 0x134
46#define CLK_SOURCE_SBC2 0x118
47#define CLK_SOURCE_SBC3 0x11c
48#define CLK_SOURCE_SBC4 0x1b4
49#define CLK_SOURCE_SBC5 0x3c8
50#define CLK_SOURCE_SBC6 0x3cc
51#define CLK_SOURCE_SATA_OOB 0x420
52#define CLK_SOURCE_SATA 0x424
53#define CLK_SOURCE_NDSPEED 0x3f8
54#define CLK_SOURCE_VFIR 0x168
55#define CLK_SOURCE_SDMMC1 0x150
56#define CLK_SOURCE_SDMMC2 0x154
57#define CLK_SOURCE_SDMMC3 0x1bc
58#define CLK_SOURCE_SDMMC4 0x164
59#define CLK_SOURCE_CVE 0x140
60#define CLK_SOURCE_TVO 0x188
61#define CLK_SOURCE_TVDAC 0x194
62#define CLK_SOURCE_VDE 0x1c8
63#define CLK_SOURCE_CSITE 0x1d4
64#define CLK_SOURCE_LA 0x1f8
65#define CLK_SOURCE_TRACE 0x634
66#define CLK_SOURCE_OWR 0x1cc
67#define CLK_SOURCE_NOR 0x1d0
68#define CLK_SOURCE_MIPI 0x174
69#define CLK_SOURCE_I2C1 0x124
70#define CLK_SOURCE_I2C2 0x198
71#define CLK_SOURCE_I2C3 0x1b8
72#define CLK_SOURCE_I2C4 0x3c4
73#define CLK_SOURCE_I2C5 0x128
74#define CLK_SOURCE_I2C6 0x65c
75#define CLK_SOURCE_UARTA 0x178
76#define CLK_SOURCE_UARTB 0x17c
77#define CLK_SOURCE_UARTC 0x1a0
78#define CLK_SOURCE_UARTD 0x1c0
79#define CLK_SOURCE_UARTE 0x1c4
80#define CLK_SOURCE_3D 0x158
81#define CLK_SOURCE_2D 0x15c
82#define CLK_SOURCE_MPE 0x170
83#define CLK_SOURCE_UARTE 0x1c4
84#define CLK_SOURCE_VI_SENSOR 0x1a8
85#define CLK_SOURCE_VI 0x148
86#define CLK_SOURCE_EPP 0x16c
87#define CLK_SOURCE_MSENC 0x1f0
88#define CLK_SOURCE_TSEC 0x1f4
89#define CLK_SOURCE_HOST1X 0x180
90#define CLK_SOURCE_HDMI 0x18c
91#define CLK_SOURCE_DISP1 0x138
92#define CLK_SOURCE_DISP2 0x13c
93#define CLK_SOURCE_CILAB 0x614
94#define CLK_SOURCE_CILCD 0x618
95#define CLK_SOURCE_CILE 0x61c
96#define CLK_SOURCE_DSIALP 0x620
97#define CLK_SOURCE_DSIBLP 0x624
98#define CLK_SOURCE_TSENSOR 0x3b8
99#define CLK_SOURCE_D_AUDIO 0x3d0
100#define CLK_SOURCE_DAM0 0x3d8
101#define CLK_SOURCE_DAM1 0x3dc
102#define CLK_SOURCE_DAM2 0x3e0
103#define CLK_SOURCE_ACTMON 0x3e8
104#define CLK_SOURCE_EXTERN1 0x3ec
105#define CLK_SOURCE_EXTERN2 0x3f0
106#define CLK_SOURCE_EXTERN3 0x3f4
107#define CLK_SOURCE_I2CSLOW 0x3fc
108#define CLK_SOURCE_SE 0x42c
109#define CLK_SOURCE_MSELECT 0x3b4
110#define CLK_SOURCE_DFLL_REF 0x62c
111#define CLK_SOURCE_DFLL_SOC 0x630
112#define CLK_SOURCE_SOC_THERM 0x644
113#define CLK_SOURCE_XUSB_HOST_SRC 0x600
114#define CLK_SOURCE_XUSB_FALCON_SRC 0x604
115#define CLK_SOURCE_XUSB_FS_SRC 0x608
116#define CLK_SOURCE_XUSB_SS_SRC 0x610
117#define CLK_SOURCE_XUSB_DEV_SRC 0x60c
118#define CLK_SOURCE_ISP 0x144
119#define CLK_SOURCE_SOR0 0x414
120#define CLK_SOURCE_DPAUX 0x418
121#define CLK_SOURCE_SATA_OOB 0x420
122#define CLK_SOURCE_SATA 0x424
123#define CLK_SOURCE_ENTROPY 0x628
124#define CLK_SOURCE_VI_SENSOR2 0x658
125#define CLK_SOURCE_HDMI_AUDIO 0x668
126#define CLK_SOURCE_VIC03 0x678
127#define CLK_SOURCE_CLK72MHZ 0x66c
128
129#define MASK(x) (BIT(x) - 1)
130
131#define MUX(_name, _parents, _offset, \
132 _clk_num, _gate_flags, _clk_id) \
133 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\
134 30, MASK(2), 0, 0, 8, 1, TEGRA_DIVIDER_ROUND_UP, \
135 _clk_num, _gate_flags, _clk_id, _parents##_idx, 0,\
136 NULL)
137
138#define MUX_FLAGS(_name, _parents, _offset,\
139 _clk_num, _gate_flags, _clk_id, flags)\
140 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\
141 30, MASK(2), 0, 0, 8, 1, TEGRA_DIVIDER_ROUND_UP,\
142 _clk_num, _gate_flags, _clk_id, _parents##_idx, flags,\
143 NULL)
144
145#define MUX8(_name, _parents, _offset, \
146 _clk_num, _gate_flags, _clk_id) \
147 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\
148 29, MASK(3), 0, 0, 8, 1, TEGRA_DIVIDER_ROUND_UP,\
149 _clk_num, _gate_flags, _clk_id, _parents##_idx, 0,\
150 NULL)
151
152#define MUX8_NOGATE_LOCK(_name, _parents, _offset, _clk_id, _lock) \
153 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset, \
154 29, MASK(3), 0, 0, 8, 1, TEGRA_DIVIDER_ROUND_UP,\
155 0, TEGRA_PERIPH_NO_GATE, _clk_id,\
156 _parents##_idx, 0, _lock)
157
158#define INT(_name, _parents, _offset, \
159 _clk_num, _gate_flags, _clk_id) \
160 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\
161 30, MASK(2), 0, 0, 8, 1, TEGRA_DIVIDER_INT| \
162 TEGRA_DIVIDER_ROUND_UP, _clk_num, _gate_flags,\
163 _clk_id, _parents##_idx, 0, NULL)
164
165#define INT_FLAGS(_name, _parents, _offset,\
166 _clk_num, _gate_flags, _clk_id, flags)\
167 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\
168 30, MASK(2), 0, 0, 8, 1, TEGRA_DIVIDER_INT| \
169 TEGRA_DIVIDER_ROUND_UP, _clk_num, _gate_flags,\
170 _clk_id, _parents##_idx, flags, NULL)
171
172#define INT8(_name, _parents, _offset,\
173 _clk_num, _gate_flags, _clk_id) \
174 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\
175 29, MASK(3), 0, 0, 8, 1, TEGRA_DIVIDER_INT| \
176 TEGRA_DIVIDER_ROUND_UP, _clk_num, _gate_flags,\
177 _clk_id, _parents##_idx, 0, NULL)
178
179#define UART(_name, _parents, _offset,\
180 _clk_num, _clk_id) \
181 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\
182 30, MASK(2), 0, 0, 16, 1, TEGRA_DIVIDER_UART| \
183 TEGRA_DIVIDER_ROUND_UP, _clk_num, 0, _clk_id,\
184 _parents##_idx, 0, NULL)
185
186#define I2C(_name, _parents, _offset,\
187 _clk_num, _clk_id) \
188 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\
189 30, MASK(2), 0, 0, 16, 0, TEGRA_DIVIDER_ROUND_UP,\
190 _clk_num, 0, _clk_id, _parents##_idx, 0, NULL)
191
192#define XUSB(_name, _parents, _offset, \
193 _clk_num, _gate_flags, _clk_id) \
194 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset, \
195 29, MASK(3), 0, 0, 8, 1, TEGRA_DIVIDER_INT| \
196 TEGRA_DIVIDER_ROUND_UP, _clk_num, _gate_flags,\
197 _clk_id, _parents##_idx, 0, NULL)
198
199#define AUDIO(_name, _offset, _clk_num,\
200 _gate_flags, _clk_id) \
201 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, mux_d_audio_clk, \
202 _offset, 16, 0xE01F, 0, 0, 8, 1, \
203 TEGRA_DIVIDER_ROUND_UP, _clk_num, _gate_flags, \
204 _clk_id, mux_d_audio_clk_idx, 0, NULL)
205
206#define NODIV(_name, _parents, _offset, \
207 _mux_shift, _mux_mask, _clk_num, \
208 _gate_flags, _clk_id, _lock) \
209 TEGRA_INIT_DATA_TABLE(_name, NULL, NULL, _parents, _offset,\
210 _mux_shift, _mux_mask, 0, 0, 0, 0, 0,\
211 _clk_num, (_gate_flags) | TEGRA_PERIPH_NO_DIV,\
212 _clk_id, _parents##_idx, 0, _lock)
213
214#define GATE(_name, _parent_name, \
215 _clk_num, _gate_flags, _clk_id, _flags) \
216 { \
217 .name = _name, \
218 .clk_id = _clk_id, \
219 .p.parent_name = _parent_name, \
220 .periph = TEGRA_CLK_PERIPH(0, 0, 0, 0, 0, 0, 0, \
221 _clk_num, _gate_flags, 0, NULL), \
222 .flags = _flags \
223 }
224
225#define PLLP_BASE 0xa0
226#define PLLP_MISC 0xac
227#define PLLP_OUTA 0xa4
228#define PLLP_OUTB 0xa8
229#define PLLP_OUTC 0x67c
230
231#define PLL_BASE_LOCK BIT(27)
232#define PLL_MISC_LOCK_ENABLE 18
233
234static DEFINE_SPINLOCK(PLLP_OUTA_lock);
235static DEFINE_SPINLOCK(PLLP_OUTB_lock);
236static DEFINE_SPINLOCK(PLLP_OUTC_lock);
237static DEFINE_SPINLOCK(sor0_lock);
238
239#define MUX_I2S_SPDIF(_id) \
240static const char *mux_pllaout0_##_id##_2x_pllp_clkm[] = { "pll_a_out0", \
241 #_id, "pll_p",\
242 "clk_m"};
243MUX_I2S_SPDIF(audio0)
244MUX_I2S_SPDIF(audio1)
245MUX_I2S_SPDIF(audio2)
246MUX_I2S_SPDIF(audio3)
247MUX_I2S_SPDIF(audio4)
248MUX_I2S_SPDIF(audio)
249
250#define mux_pllaout0_audio0_2x_pllp_clkm_idx NULL
251#define mux_pllaout0_audio1_2x_pllp_clkm_idx NULL
252#define mux_pllaout0_audio2_2x_pllp_clkm_idx NULL
253#define mux_pllaout0_audio3_2x_pllp_clkm_idx NULL
254#define mux_pllaout0_audio4_2x_pllp_clkm_idx NULL
255#define mux_pllaout0_audio_2x_pllp_clkm_idx NULL
256
257static const char *mux_pllp_pllc_pllm_clkm[] = {
258 "pll_p", "pll_c", "pll_m", "clk_m"
259};
260#define mux_pllp_pllc_pllm_clkm_idx NULL
261
262static const char *mux_pllp_pllc_pllm[] = { "pll_p", "pll_c", "pll_m" };
263#define mux_pllp_pllc_pllm_idx NULL
264
265static const char *mux_pllp_pllc_clk32_clkm[] = {
266 "pll_p", "pll_c", "clk_32k", "clk_m"
267};
268#define mux_pllp_pllc_clk32_clkm_idx NULL
269
270static const char *mux_plla_pllc_pllp_clkm[] = {
271 "pll_a_out0", "pll_c", "pll_p", "clk_m"
272};
273#define mux_plla_pllc_pllp_clkm_idx mux_pllp_pllc_pllm_clkm_idx
274
275static const char *mux_pllp_pllc2_c_c3_pllm_clkm[] = {
276 "pll_p", "pll_c2", "pll_c", "pll_c3", "pll_m", "clk_m"
277};
278static u32 mux_pllp_pllc2_c_c3_pllm_clkm_idx[] = {
279 [0] = 0, [1] = 1, [2] = 2, [3] = 3, [4] = 4, [5] = 6,
280};
281
282static const char *mux_pllp_clkm[] = {
283 "pll_p", "clk_m"
284};
285static u32 mux_pllp_clkm_idx[] = {
286 [0] = 0, [1] = 3,
287};
288
289static const char *mux_pllm_pllc2_c_c3_pllp_plla[] = {
290 "pll_m", "pll_c2", "pll_c", "pll_c3", "pll_p", "pll_a_out0"
291};
292#define mux_pllm_pllc2_c_c3_pllp_plla_idx mux_pllp_pllc2_c_c3_pllm_clkm_idx
293
294static const char *mux_pllp_pllm_plld_plla_pllc_plld2_clkm[] = {
295 "pll_p", "pll_m", "pll_d_out0", "pll_a_out0", "pll_c",
296 "pll_d2_out0", "clk_m"
297};
298#define mux_pllp_pllm_plld_plla_pllc_plld2_clkm_idx NULL
299
300static const char *mux_pllm_pllc_pllp_plla[] = {
301 "pll_m", "pll_c", "pll_p", "pll_a_out0"
302};
303#define mux_pllm_pllc_pllp_plla_idx mux_pllp_pllc_pllm_clkm_idx
304
305static const char *mux_pllp_pllc_clkm[] = {
306 "pll_p", "pll_c", "pll_m"
307};
308static u32 mux_pllp_pllc_clkm_idx[] = {
309 [0] = 0, [1] = 1, [2] = 3,
310};
311
312static const char *mux_pllp_pllc_clkm_clk32[] = {
313 "pll_p", "pll_c", "clk_m", "clk_32k"
314};
315#define mux_pllp_pllc_clkm_clk32_idx NULL
316
317static const char *mux_plla_clk32_pllp_clkm_plle[] = {
318 "pll_a_out0", "clk_32k", "pll_p", "clk_m", "pll_e_out0"
319};
320#define mux_plla_clk32_pllp_clkm_plle_idx NULL
321
322static const char *mux_clkm_pllp_pllc_pllre[] = {
323 "clk_m", "pll_p", "pll_c", "pll_re_out"
324};
325static u32 mux_clkm_pllp_pllc_pllre_idx[] = {
326 [0] = 0, [1] = 1, [2] = 3, [3] = 5,
327};
328
329static const char *mux_clkm_48M_pllp_480M[] = {
330 "clk_m", "pll_u_48M", "pll_p", "pll_u_480M"
331};
332#define mux_clkm_48M_pllp_480M_idx NULL
333
334static const char *mux_clkm_pllre_clk32_480M_pllc_ref[] = {
335 "clk_m", "pll_re_out", "clk_32k", "pll_u_480M", "pll_c", "pll_ref"
336};
337static u32 mux_clkm_pllre_clk32_480M_pllc_ref_idx[] = {
338 [0] = 0, [1] = 1, [2] = 3, [3] = 3, [4] = 4, [5] = 7,
339};
340
341static const char *mux_d_audio_clk[] = {
342 "pll_a_out0", "pll_p", "clk_m", "spdif_in_sync", "i2s0_sync",
343 "i2s1_sync", "i2s2_sync", "i2s3_sync", "i2s4_sync", "vimclk_sync",
344};
345static u32 mux_d_audio_clk_idx[] = {
346 [0] = 0, [1] = 0x8000, [2] = 0xc000, [3] = 0xE000, [4] = 0xE001,
347 [5] = 0xE002, [6] = 0xE003, [7] = 0xE004, [8] = 0xE005, [9] = 0xE007,
348};
349
350static const char *mux_pllp_plld_pllc_clkm[] = {
351 "pll_p", "pll_d_out0", "pll_c", "clk_m"
352};
353#define mux_pllp_plld_pllc_clkm_idx NULL
354static const char *mux_pllm_pllc_pllp_plla_clkm_pllc4[] = {
355 "pll_m", "pll_c", "pll_p", "pll_a_out0", "clk_m", "pll_c4",
356};
357static u32 mux_pllm_pllc_pllp_plla_clkm_pllc4_idx[] = {
358 [0] = 0, [1] = 1, [2] = 3, [3] = 3, [4] = 6, [5] = 7,
359};
360
361static const char *mux_pllp_clkm1[] = {
362 "pll_p", "clk_m",
363};
364#define mux_pllp_clkm1_idx NULL
365
366static const char *mux_pllp3_pllc_clkm[] = {
367 "pll_p_out3", "pll_c", "pll_c2", "clk_m",
368};
369#define mux_pllp3_pllc_clkm_idx NULL
370
371static const char *mux_pllm_pllc_pllp_plla_pllc2_c3_clkm[] = {
372 "pll_m", "pll_c", "pll_p", "pll_a", "pll_c2", "pll_c3", "clk_m"
373};
374static u32 mux_pllm_pllc_pllp_plla_pllc2_c3_clkm_idx[] = {
375 [0] = 0, [1] = 1, [2] = 2, [3] = 3, [4] = 4, [5] = 6,
376};
377
378static const char *mux_pllm_pllc2_c_c3_pllp_plla_pllc4[] = {
379 "pll_m", "pll_c2", "pll_c", "pll_c3", "pll_p", "pll_a_out0", "pll_c4",
380};
381static u32 mux_pllm_pllc2_c_c3_pllp_plla_pllc4_idx[] = {
382 [0] = 0, [1] = 1, [2] = 2, [3] = 3, [4] = 4, [5] = 6, [6] = 7,
383};
384
385static const char *mux_clkm_plldp_sor0lvds[] = {
386 "clk_m", "pll_dp", "sor0_lvds",
387};
388#define mux_clkm_plldp_sor0lvds_idx NULL
389
390static struct tegra_periph_init_data periph_clks[] = {
391 AUDIO("d_audio", CLK_SOURCE_D_AUDIO, 106, TEGRA_PERIPH_ON_APB, tegra_clk_d_audio),
392 AUDIO("dam0", CLK_SOURCE_DAM0, 108, TEGRA_PERIPH_ON_APB, tegra_clk_dam0),
393 AUDIO("dam1", CLK_SOURCE_DAM1, 109, TEGRA_PERIPH_ON_APB, tegra_clk_dam1),
394 AUDIO("dam2", CLK_SOURCE_DAM2, 110, TEGRA_PERIPH_ON_APB, tegra_clk_dam2),
395 I2C("i2c1", mux_pllp_clkm, CLK_SOURCE_I2C1, 12, tegra_clk_i2c1),
396 I2C("i2c2", mux_pllp_clkm, CLK_SOURCE_I2C2, 54, tegra_clk_i2c2),
397 I2C("i2c3", mux_pllp_clkm, CLK_SOURCE_I2C3, 67, tegra_clk_i2c3),
398 I2C("i2c4", mux_pllp_clkm, CLK_SOURCE_I2C4, 103, tegra_clk_i2c4),
399 I2C("i2c5", mux_pllp_clkm, CLK_SOURCE_I2C5, 47, tegra_clk_i2c5),
400 INT("vde", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_VDE, 61, 0, tegra_clk_vde),
401 INT("vi", mux_pllm_pllc_pllp_plla, CLK_SOURCE_VI, 20, 0, tegra_clk_vi),
402 INT("epp", mux_pllm_pllc_pllp_plla, CLK_SOURCE_EPP, 19, 0, tegra_clk_epp),
403 INT("host1x", mux_pllm_pllc_pllp_plla, CLK_SOURCE_HOST1X, 28, 0, tegra_clk_host1x),
404 INT("mpe", mux_pllm_pllc_pllp_plla, CLK_SOURCE_MPE, 60, 0, tegra_clk_mpe),
405 INT("2d", mux_pllm_pllc_pllp_plla, CLK_SOURCE_2D, 21, 0, tegra_clk_gr2d),
406 INT("3d", mux_pllm_pllc_pllp_plla, CLK_SOURCE_3D, 24, 0, tegra_clk_gr3d),
407 INT8("vde", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_VDE, 61, 0, tegra_clk_vde_8),
408 INT8("vi", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_VI, 20, 0, tegra_clk_vi_8),
409 INT8("vi", mux_pllm_pllc2_c_c3_pllp_plla_pllc4, CLK_SOURCE_VI, 20, 0, tegra_clk_vi_9),
410 INT8("epp", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_EPP, 19, 0, tegra_clk_epp_8),
411 INT8("msenc", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_MSENC, 91, TEGRA_PERIPH_WAR_1005168, tegra_clk_msenc),
412 INT8("tsec", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_TSEC, 83, 0, tegra_clk_tsec),
413 INT8("host1x", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_HOST1X, 28, 0, tegra_clk_host1x_8),
414 INT8("se", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_SE, 127, TEGRA_PERIPH_ON_APB, tegra_clk_se),
415 INT8("2d", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_2D, 21, 0, tegra_clk_gr2d_8),
416 INT8("3d", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_3D, 24, 0, tegra_clk_gr3d_8),
417 INT8("vic03", mux_pllm_pllc_pllp_plla_pllc2_c3_clkm, CLK_SOURCE_VIC03, 178, 0, tegra_clk_vic03),
418 INT_FLAGS("mselect", mux_pllp_clkm, CLK_SOURCE_MSELECT, 99, 0, tegra_clk_mselect, CLK_IGNORE_UNUSED),
419 MUX("i2s0", mux_pllaout0_audio0_2x_pllp_clkm, CLK_SOURCE_I2S0, 30, TEGRA_PERIPH_ON_APB, tegra_clk_i2s0),
420 MUX("i2s1", mux_pllaout0_audio1_2x_pllp_clkm, CLK_SOURCE_I2S1, 11, TEGRA_PERIPH_ON_APB, tegra_clk_i2s1),
421 MUX("i2s2", mux_pllaout0_audio2_2x_pllp_clkm, CLK_SOURCE_I2S2, 18, TEGRA_PERIPH_ON_APB, tegra_clk_i2s2),
422 MUX("i2s3", mux_pllaout0_audio3_2x_pllp_clkm, CLK_SOURCE_I2S3, 101, TEGRA_PERIPH_ON_APB, tegra_clk_i2s3),
423 MUX("i2s4", mux_pllaout0_audio4_2x_pllp_clkm, CLK_SOURCE_I2S4, 102, TEGRA_PERIPH_ON_APB, tegra_clk_i2s4),
424 MUX("spdif_out", mux_pllaout0_audio_2x_pllp_clkm, CLK_SOURCE_SPDIF_OUT, 10, TEGRA_PERIPH_ON_APB, tegra_clk_spdif_out),
425 MUX("spdif_in", mux_pllp_pllc_pllm, CLK_SOURCE_SPDIF_IN, 10, TEGRA_PERIPH_ON_APB, tegra_clk_spdif_in),
426 MUX("pwm", mux_pllp_pllc_clk32_clkm, CLK_SOURCE_PWM, 17, TEGRA_PERIPH_ON_APB, tegra_clk_pwm),
427 MUX("adx", mux_plla_pllc_pllp_clkm, CLK_SOURCE_ADX, 154, TEGRA_PERIPH_ON_APB, tegra_clk_adx),
428 MUX("amx", mux_plla_pllc_pllp_clkm, CLK_SOURCE_AMX, 153, TEGRA_PERIPH_ON_APB, tegra_clk_amx),
429 MUX("hda", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_HDA, 125, TEGRA_PERIPH_ON_APB, tegra_clk_hda),
430 MUX("hda2codec_2x", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_HDA2CODEC_2X, 111, TEGRA_PERIPH_ON_APB, tegra_clk_hda2codec_2x),
431 MUX("vfir", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_VFIR, 7, TEGRA_PERIPH_ON_APB, tegra_clk_vfir),
432 MUX("sdmmc1", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SDMMC1, 14, 0, tegra_clk_sdmmc1),
433 MUX("sdmmc2", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SDMMC2, 9, 0, tegra_clk_sdmmc2),
434 MUX("sdmmc3", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SDMMC3, 69, 0, tegra_clk_sdmmc3),
435 MUX("sdmmc4", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SDMMC4, 15, 0, tegra_clk_sdmmc4),
436 MUX("la", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_LA, 76, TEGRA_PERIPH_ON_APB, tegra_clk_la),
437 MUX("trace", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_TRACE, 77, TEGRA_PERIPH_ON_APB, tegra_clk_trace),
438 MUX("owr", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_OWR, 71, TEGRA_PERIPH_ON_APB, tegra_clk_owr),
439 MUX("nor", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_NOR, 42, 0, tegra_clk_nor),
440 MUX("mipi", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_MIPI, 50, TEGRA_PERIPH_ON_APB, tegra_clk_mipi),
441 MUX("vi_sensor", mux_pllm_pllc_pllp_plla, CLK_SOURCE_VI_SENSOR, 20, TEGRA_PERIPH_NO_RESET, tegra_clk_vi_sensor),
442 MUX("cilab", mux_pllp_pllc_clkm, CLK_SOURCE_CILAB, 144, 0, tegra_clk_cilab),
443 MUX("cilcd", mux_pllp_pllc_clkm, CLK_SOURCE_CILCD, 145, 0, tegra_clk_cilcd),
444 MUX("cile", mux_pllp_pllc_clkm, CLK_SOURCE_CILE, 146, 0, tegra_clk_cile),
445 MUX("dsialp", mux_pllp_pllc_clkm, CLK_SOURCE_DSIALP, 147, 0, tegra_clk_dsialp),
446 MUX("dsiblp", mux_pllp_pllc_clkm, CLK_SOURCE_DSIBLP, 148, 0, tegra_clk_dsiblp),
447 MUX("tsensor", mux_pllp_pllc_clkm_clk32, CLK_SOURCE_TSENSOR, 100, TEGRA_PERIPH_ON_APB, tegra_clk_tsensor),
448 MUX("actmon", mux_pllp_pllc_clk32_clkm, CLK_SOURCE_ACTMON, 119, 0, tegra_clk_actmon),
449 MUX("dfll_ref", mux_pllp_clkm, CLK_SOURCE_DFLL_REF, 155, TEGRA_PERIPH_ON_APB, tegra_clk_dfll_ref),
450 MUX("dfll_soc", mux_pllp_clkm, CLK_SOURCE_DFLL_SOC, 155, TEGRA_PERIPH_ON_APB, tegra_clk_dfll_soc),
451 MUX("i2cslow", mux_pllp_pllc_clk32_clkm, CLK_SOURCE_I2CSLOW, 81, TEGRA_PERIPH_ON_APB, tegra_clk_i2cslow),
452 MUX("sbc1", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SBC1, 41, TEGRA_PERIPH_ON_APB, tegra_clk_sbc1),
453 MUX("sbc2", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SBC2, 44, TEGRA_PERIPH_ON_APB, tegra_clk_sbc2),
454 MUX("sbc3", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SBC3, 46, TEGRA_PERIPH_ON_APB, tegra_clk_sbc3),
455 MUX("sbc4", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SBC4, 68, TEGRA_PERIPH_ON_APB, tegra_clk_sbc4),
456 MUX("sbc5", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SBC5, 104, TEGRA_PERIPH_ON_APB, tegra_clk_sbc5),
457 MUX("sbc6", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SBC6, 105, TEGRA_PERIPH_ON_APB, tegra_clk_sbc6),
458 MUX("cve", mux_pllp_plld_pllc_clkm, CLK_SOURCE_CVE, 49, 0, tegra_clk_cve),
459 MUX("tvo", mux_pllp_plld_pllc_clkm, CLK_SOURCE_TVO, 49, 0, tegra_clk_tvo),
460 MUX("tvdac", mux_pllp_plld_pllc_clkm, CLK_SOURCE_TVDAC, 53, 0, tegra_clk_tvdac),
461 MUX("ndflash", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_NDFLASH, 13, TEGRA_PERIPH_ON_APB, tegra_clk_ndflash),
462 MUX("ndspeed", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_NDSPEED, 80, TEGRA_PERIPH_ON_APB, tegra_clk_ndspeed),
463 MUX("sata_oob", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SATA_OOB, 123, TEGRA_PERIPH_ON_APB, tegra_clk_sata_oob),
464 MUX("sata", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SATA, 124, TEGRA_PERIPH_ON_APB, tegra_clk_sata),
465 MUX("adx1", mux_plla_pllc_pllp_clkm, CLK_SOURCE_ADX1, 180, TEGRA_PERIPH_ON_APB, tegra_clk_adx1),
466 MUX("amx1", mux_plla_pllc_pllp_clkm, CLK_SOURCE_AMX1, 185, TEGRA_PERIPH_ON_APB, tegra_clk_amx1),
467 MUX("vi_sensor2", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_VI_SENSOR2, 20, TEGRA_PERIPH_NO_RESET, tegra_clk_vi_sensor2),
468 MUX8("sbc1", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_SBC1, 41, TEGRA_PERIPH_ON_APB, tegra_clk_sbc1_8),
469 MUX8("sbc2", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_SBC2, 44, TEGRA_PERIPH_ON_APB, tegra_clk_sbc2_8),
470 MUX8("sbc3", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_SBC3, 46, TEGRA_PERIPH_ON_APB, tegra_clk_sbc3_8),
471 MUX8("sbc4", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_SBC4, 68, TEGRA_PERIPH_ON_APB, tegra_clk_sbc4_8),
472 MUX8("sbc5", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_SBC5, 104, TEGRA_PERIPH_ON_APB, tegra_clk_sbc5_8),
473 MUX8("sbc6", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_SBC6, 105, TEGRA_PERIPH_ON_APB, tegra_clk_sbc6_8),
474 MUX8("ndflash", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_NDFLASH, 13, TEGRA_PERIPH_ON_APB, tegra_clk_ndflash_8),
475 MUX8("ndspeed", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_NDSPEED, 80, TEGRA_PERIPH_ON_APB, tegra_clk_ndspeed_8),
476 MUX8("hdmi", mux_pllp_pllm_plld_plla_pllc_plld2_clkm, CLK_SOURCE_HDMI, 51, 0, tegra_clk_hdmi),
477 MUX8("extern1", mux_plla_clk32_pllp_clkm_plle, CLK_SOURCE_EXTERN1, 120, 0, tegra_clk_extern1),
478 MUX8("extern2", mux_plla_clk32_pllp_clkm_plle, CLK_SOURCE_EXTERN2, 121, 0, tegra_clk_extern2),
479 MUX8("extern3", mux_plla_clk32_pllp_clkm_plle, CLK_SOURCE_EXTERN3, 122, 0, tegra_clk_extern3),
480 MUX8("soc_therm", mux_pllm_pllc_pllp_plla, CLK_SOURCE_SOC_THERM, 78, TEGRA_PERIPH_ON_APB, tegra_clk_soc_therm),
481 MUX8("vi_sensor", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_VI_SENSOR, 20, TEGRA_PERIPH_NO_RESET, tegra_clk_vi_sensor_8),
482 MUX8("isp", mux_pllm_pllc_pllp_plla_clkm_pllc4, CLK_SOURCE_ISP, 23, TEGRA_PERIPH_ON_APB, tegra_clk_isp_8),
483 MUX8("entropy", mux_pllp_clkm1, CLK_SOURCE_ENTROPY, 149, 0, tegra_clk_entropy),
484 MUX8("hdmi_audio", mux_pllp3_pllc_clkm, CLK_SOURCE_HDMI_AUDIO, 176, TEGRA_PERIPH_NO_RESET, tegra_clk_hdmi_audio),
485 MUX8("clk72mhz", mux_pllp3_pllc_clkm, CLK_SOURCE_CLK72MHZ, 177, TEGRA_PERIPH_NO_RESET, tegra_clk_clk72Mhz),
486 MUX8_NOGATE_LOCK("sor0_lvds", mux_pllp_pllm_plld_plla_pllc_plld2_clkm, CLK_SOURCE_SOR0, tegra_clk_sor0_lvds, &sor0_lock),
487 MUX_FLAGS("csite", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_CSITE, 73, TEGRA_PERIPH_ON_APB, tegra_clk_csite, CLK_IGNORE_UNUSED),
488 NODIV("disp1", mux_pllp_pllm_plld_plla_pllc_plld2_clkm, CLK_SOURCE_DISP1, 29, 7, 27, 0, tegra_clk_disp1, NULL),
489 NODIV("disp2", mux_pllp_pllm_plld_plla_pllc_plld2_clkm, CLK_SOURCE_DISP2, 29, 7, 26, 0, tegra_clk_disp2, NULL),
490 NODIV("sor0", mux_clkm_plldp_sor0lvds, CLK_SOURCE_SOR0, 14, 3, 182, 0, tegra_clk_sor0, &sor0_lock),
491 UART("uarta", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTA, 6, tegra_clk_uarta),
492 UART("uartb", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTB, 7, tegra_clk_uartb),
493 UART("uartc", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTC, 55, tegra_clk_uartc),
494 UART("uartd", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTD, 65, tegra_clk_uartd),
495 UART("uarte", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTE, 65, tegra_clk_uarte),
496 XUSB("xusb_host_src", mux_clkm_pllp_pllc_pllre, CLK_SOURCE_XUSB_HOST_SRC, 143, TEGRA_PERIPH_ON_APB | TEGRA_PERIPH_NO_RESET, tegra_clk_xusb_host_src),
497 XUSB("xusb_falcon_src", mux_clkm_pllp_pllc_pllre, CLK_SOURCE_XUSB_FALCON_SRC, 143, TEGRA_PERIPH_NO_RESET, tegra_clk_xusb_falcon_src),
498 XUSB("xusb_fs_src", mux_clkm_48M_pllp_480M, CLK_SOURCE_XUSB_FS_SRC, 143, TEGRA_PERIPH_NO_RESET, tegra_clk_xusb_fs_src),
499 XUSB("xusb_ss_src", mux_clkm_pllre_clk32_480M_pllc_ref, CLK_SOURCE_XUSB_SS_SRC, 143, TEGRA_PERIPH_NO_RESET, tegra_clk_xusb_ss_src),
500 XUSB("xusb_dev_src", mux_clkm_pllp_pllc_pllre, CLK_SOURCE_XUSB_DEV_SRC, 95, TEGRA_PERIPH_ON_APB | TEGRA_PERIPH_NO_RESET, tegra_clk_xusb_dev_src),
501};
502
503static struct tegra_periph_init_data gate_clks[] = {
504 GATE("rtc", "clk_32k", 4, TEGRA_PERIPH_ON_APB | TEGRA_PERIPH_NO_RESET, tegra_clk_rtc, 0),
505 GATE("timer", "clk_m", 5, 0, tegra_clk_timer, 0),
506 GATE("isp", "clk_m", 23, 0, tegra_clk_isp, 0),
507 GATE("vcp", "clk_m", 29, 0, tegra_clk_vcp, 0),
508 GATE("apbdma", "clk_m", 34, 0, tegra_clk_apbdma, 0),
509 GATE("kbc", "clk_32k", 36, TEGRA_PERIPH_ON_APB | TEGRA_PERIPH_NO_RESET, tegra_clk_kbc, 0),
510 GATE("fuse", "clk_m", 39, TEGRA_PERIPH_ON_APB, tegra_clk_fuse, 0),
511 GATE("fuse_burn", "clk_m", 39, TEGRA_PERIPH_ON_APB, tegra_clk_fuse_burn, 0),
512 GATE("kfuse", "clk_m", 40, TEGRA_PERIPH_ON_APB, tegra_clk_kfuse, 0),
513 GATE("apbif", "clk_m", 107, TEGRA_PERIPH_ON_APB, tegra_clk_apbif, 0),
514 GATE("hda2hdmi", "clk_m", 128, TEGRA_PERIPH_ON_APB, tegra_clk_hda2hdmi, 0),
515 GATE("bsea", "clk_m", 62, 0, tegra_clk_bsea, 0),
516 GATE("bsev", "clk_m", 63, 0, tegra_clk_bsev, 0),
517 GATE("mipi-cal", "clk_m", 56, 0, tegra_clk_mipi_cal, 0),
518 GATE("usbd", "clk_m", 22, 0, tegra_clk_usbd, 0),
519 GATE("usb2", "clk_m", 58, 0, tegra_clk_usb2, 0),
520 GATE("usb3", "clk_m", 59, 0, tegra_clk_usb3, 0),
521 GATE("csi", "pll_p_out3", 52, 0, tegra_clk_csi, 0),
522 GATE("afi", "clk_m", 72, 0, tegra_clk_afi, 0),
523 GATE("csus", "clk_m", 92, TEGRA_PERIPH_NO_RESET, tegra_clk_csus, 0),
524 GATE("dds", "clk_m", 150, TEGRA_PERIPH_ON_APB, tegra_clk_dds, 0),
525 GATE("dp2", "clk_m", 152, TEGRA_PERIPH_ON_APB, tegra_clk_dp2, 0),
526 GATE("dtv", "clk_m", 79, TEGRA_PERIPH_ON_APB, tegra_clk_dtv, 0),
527 GATE("xusb_host", "xusb_host_src", 89, 0, tegra_clk_xusb_host, 0),
528 GATE("xusb_ss", "xusb_ss_src", 156, 0, tegra_clk_xusb_ss, 0),
529 GATE("xusb_dev", "xusb_dev_src", 95, 0, tegra_clk_xusb_dev, 0),
530 GATE("dsia", "dsia_mux", 48, 0, tegra_clk_dsia, 0),
531 GATE("dsib", "dsib_mux", 82, 0, tegra_clk_dsib, 0),
532 GATE("emc", "emc_mux", 57, 0, tegra_clk_emc, CLK_IGNORE_UNUSED),
533 GATE("sata_cold", "clk_m", 129, TEGRA_PERIPH_ON_APB, tegra_clk_sata_cold, 0),
534 GATE("ispb", "clk_m", 3, 0, tegra_clk_ispb, 0),
535 GATE("vim2_clk", "clk_m", 11, 0, tegra_clk_vim2_clk, 0),
536 GATE("pcie", "clk_m", 70, 0, tegra_clk_pcie, 0),
537 GATE("dpaux", "clk_m", 181, 0, tegra_clk_dpaux, 0),
538 GATE("gpu", "pll_ref", 184, 0, tegra_clk_gpu, 0),
539};
540
541struct pll_out_data {
542 char *div_name;
543 char *pll_out_name;
544 u32 offset;
545 int clk_id;
546 u8 div_shift;
547 u8 div_flags;
548 u8 rst_shift;
549 spinlock_t *lock;
550};
551
552#define PLL_OUT(_num, _offset, _div_shift, _div_flags, _rst_shift, _id) \
553 {\
554 .div_name = "pll_p_out" #_num "_div",\
555 .pll_out_name = "pll_p_out" #_num,\
556 .offset = _offset,\
557 .div_shift = _div_shift,\
558 .div_flags = _div_flags | TEGRA_DIVIDER_FIXED |\
559 TEGRA_DIVIDER_ROUND_UP,\
560 .rst_shift = _rst_shift,\
561 .clk_id = tegra_clk_ ## _id,\
562 .lock = &_offset ##_lock,\
563 }
564
565static struct pll_out_data pllp_out_clks[] = {
566 PLL_OUT(1, PLLP_OUTA, 8, 0, 0, pll_p_out1),
567 PLL_OUT(2, PLLP_OUTA, 24, 0, 16, pll_p_out2),
568 PLL_OUT(2, PLLP_OUTA, 24, TEGRA_DIVIDER_INT, 16, pll_p_out2_int),
569 PLL_OUT(3, PLLP_OUTB, 8, 0, 0, pll_p_out3),
570 PLL_OUT(4, PLLP_OUTB, 24, 0, 16, pll_p_out4),
571 PLL_OUT(5, PLLP_OUTC, 24, 0, 16, pll_p_out5),
572};
573
574static void __init periph_clk_init(void __iomem *clk_base,
575 struct tegra_clk *tegra_clks)
576{
577 int i;
578 struct clk *clk;
579 struct clk **dt_clk;
580
581 for (i = 0; i < ARRAY_SIZE(periph_clks); i++) {
582 struct tegra_clk_periph_regs *bank;
583 struct tegra_periph_init_data *data;
584
585 data = periph_clks + i;
586
587 dt_clk = tegra_lookup_dt_id(data->clk_id, tegra_clks);
588 if (!dt_clk)
589 continue;
590
591 bank = get_reg_bank(data->periph.gate.clk_num);
592 if (!bank)
593 continue;
594
595 data->periph.gate.regs = bank;
596 clk = tegra_clk_register_periph(data->name,
597 data->p.parent_names, data->num_parents,
598 &data->periph, clk_base, data->offset,
599 data->flags);
600 *dt_clk = clk;
601 }
602}
603
604static void __init gate_clk_init(void __iomem *clk_base,
605 struct tegra_clk *tegra_clks)
606{
607 int i;
608 struct clk *clk;
609 struct clk **dt_clk;
610
611 for (i = 0; i < ARRAY_SIZE(gate_clks); i++) {
612 struct tegra_periph_init_data *data;
613
614 data = gate_clks + i;
615
616 dt_clk = tegra_lookup_dt_id(data->clk_id, tegra_clks);
617 if (!dt_clk)
618 continue;
619
620 clk = tegra_clk_register_periph_gate(data->name,
621 data->p.parent_name, data->periph.gate.flags,
622 clk_base, data->flags,
623 data->periph.gate.clk_num,
624 periph_clk_enb_refcnt);
625 *dt_clk = clk;
626 }
627}
628
629static void __init init_pllp(void __iomem *clk_base, void __iomem *pmc_base,
630 struct tegra_clk *tegra_clks,
631 struct tegra_clk_pll_params *pll_params)
632{
633 struct clk *clk;
634 struct clk **dt_clk;
635 int i;
636
637 dt_clk = tegra_lookup_dt_id(tegra_clk_pll_p, tegra_clks);
638 if (dt_clk) {
639 /* PLLP */
640 clk = tegra_clk_register_pll("pll_p", "pll_ref", clk_base,
641 pmc_base, 0, pll_params, NULL);
642 clk_register_clkdev(clk, "pll_p", NULL);
643 *dt_clk = clk;
644 }
645
646 for (i = 0; i < ARRAY_SIZE(pllp_out_clks); i++) {
647 struct pll_out_data *data;
648
649 data = pllp_out_clks + i;
650
651 dt_clk = tegra_lookup_dt_id(data->clk_id, tegra_clks);
652 if (!dt_clk)
653 continue;
654
655 clk = tegra_clk_register_divider(data->div_name, "pll_p",
656 clk_base + data->offset, 0, data->div_flags,
657 data->div_shift, 8, 1, data->lock);
658 clk = tegra_clk_register_pll_out(data->pll_out_name,
659 data->div_name, clk_base + data->offset,
660 data->rst_shift + 1, data->rst_shift,
661 CLK_IGNORE_UNUSED | CLK_SET_RATE_PARENT, 0,
662 data->lock);
663 *dt_clk = clk;
664 }
665}
666
667void __init tegra_periph_clk_init(void __iomem *clk_base,
668 void __iomem *pmc_base, struct tegra_clk *tegra_clks,
669 struct tegra_clk_pll_params *pll_params)
670{
671 init_pllp(clk_base, pmc_base, tegra_clks, pll_params);
672 periph_clk_init(clk_base, tegra_clks);
673 gate_clk_init(clk_base, tegra_clks);
674}
diff --git a/drivers/clk/tegra/clk-tegra-pmc.c b/drivers/clk/tegra/clk-tegra-pmc.c
new file mode 100644
index 000000000000..08b21c1ee867
--- /dev/null
+++ b/drivers/clk/tegra/clk-tegra-pmc.c
@@ -0,0 +1,132 @@
1/*
2 * Copyright (c) 2012, 2013, 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#include <linux/io.h>
18#include <linux/clk.h>
19#include <linux/clk-provider.h>
20#include <linux/clkdev.h>
21#include <linux/of.h>
22#include <linux/of_address.h>
23#include <linux/delay.h>
24#include <linux/export.h>
25#include <linux/clk/tegra.h>
26
27#include "clk.h"
28#include "clk-id.h"
29
30#define PMC_CLK_OUT_CNTRL 0x1a8
31#define PMC_DPD_PADS_ORIDE 0x1c
32#define PMC_DPD_PADS_ORIDE_BLINK_ENB 20
33#define PMC_CTRL 0
34#define PMC_CTRL_BLINK_ENB 7
35#define PMC_BLINK_TIMER 0x40
36
37struct pmc_clk_init_data {
38 char *mux_name;
39 char *gate_name;
40 const char **parents;
41 int num_parents;
42 int mux_id;
43 int gate_id;
44 char *dev_name;
45 u8 mux_shift;
46 u8 gate_shift;
47};
48
49#define PMC_CLK(_num, _mux_shift, _gate_shift)\
50 {\
51 .mux_name = "clk_out_" #_num "_mux",\
52 .gate_name = "clk_out_" #_num,\
53 .parents = clk_out ##_num ##_parents,\
54 .num_parents = ARRAY_SIZE(clk_out ##_num ##_parents),\
55 .mux_id = tegra_clk_clk_out_ ##_num ##_mux,\
56 .gate_id = tegra_clk_clk_out_ ##_num,\
57 .dev_name = "extern" #_num,\
58 .mux_shift = _mux_shift,\
59 .gate_shift = _gate_shift,\
60 }
61
62static DEFINE_SPINLOCK(clk_out_lock);
63
64static const char *clk_out1_parents[] = { "clk_m", "clk_m_div2",
65 "clk_m_div4", "extern1",
66};
67
68static const char *clk_out2_parents[] = { "clk_m", "clk_m_div2",
69 "clk_m_div4", "extern2",
70};
71
72static const char *clk_out3_parents[] = { "clk_m", "clk_m_div2",
73 "clk_m_div4", "extern3",
74};
75
76static struct pmc_clk_init_data pmc_clks[] = {
77 PMC_CLK(1, 6, 2),
78 PMC_CLK(2, 14, 10),
79 PMC_CLK(3, 22, 18),
80};
81
82void __init tegra_pmc_clk_init(void __iomem *pmc_base,
83 struct tegra_clk *tegra_clks)
84{
85 struct clk *clk;
86 struct clk **dt_clk;
87 int i;
88
89 for (i = 0; i < ARRAY_SIZE(pmc_clks); i++) {
90 struct pmc_clk_init_data *data;
91
92 data = pmc_clks + i;
93
94 dt_clk = tegra_lookup_dt_id(data->mux_id, tegra_clks);
95 if (!dt_clk)
96 continue;
97
98 clk = clk_register_mux(NULL, data->mux_name, data->parents,
99 data->num_parents, CLK_SET_RATE_NO_REPARENT,
100 pmc_base + PMC_CLK_OUT_CNTRL, data->mux_shift,
101 3, 0, &clk_out_lock);
102 *dt_clk = clk;
103
104
105 dt_clk = tegra_lookup_dt_id(data->gate_id, tegra_clks);
106 if (!dt_clk)
107 continue;
108
109 clk = clk_register_gate(NULL, data->gate_name, data->mux_name,
110 0, pmc_base + PMC_CLK_OUT_CNTRL,
111 data->gate_shift, 0, &clk_out_lock);
112 *dt_clk = clk;
113 clk_register_clkdev(clk, data->dev_name, data->gate_name);
114 }
115
116 /* blink */
117 writel_relaxed(0, pmc_base + PMC_BLINK_TIMER);
118 clk = clk_register_gate(NULL, "blink_override", "clk_32k", 0,
119 pmc_base + PMC_DPD_PADS_ORIDE,
120 PMC_DPD_PADS_ORIDE_BLINK_ENB, 0, NULL);
121
122 dt_clk = tegra_lookup_dt_id(tegra_clk_blink, tegra_clks);
123 if (!dt_clk)
124 return;
125
126 clk = clk_register_gate(NULL, "blink", "blink_override", 0,
127 pmc_base + PMC_CTRL,
128 PMC_CTRL_BLINK_ENB, 0, NULL);
129 clk_register_clkdev(clk, "blink", NULL);
130 *dt_clk = clk;
131}
132
diff --git a/drivers/clk/tegra/clk-tegra-super-gen4.c b/drivers/clk/tegra/clk-tegra-super-gen4.c
new file mode 100644
index 000000000000..05dce4aa2c11
--- /dev/null
+++ b/drivers/clk/tegra/clk-tegra-super-gen4.c
@@ -0,0 +1,149 @@
1/*
2 * Copyright (c) 2012, 2013, 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#include <linux/io.h>
18#include <linux/clk.h>
19#include <linux/clk-provider.h>
20#include <linux/of.h>
21#include <linux/of_address.h>
22#include <linux/delay.h>
23#include <linux/export.h>
24#include <linux/clk/tegra.h>
25
26#include "clk.h"
27#include "clk-id.h"
28
29#define PLLX_BASE 0xe0
30#define PLLX_MISC 0xe4
31#define PLLX_MISC2 0x514
32#define PLLX_MISC3 0x518
33
34#define CCLKG_BURST_POLICY 0x368
35#define CCLKLP_BURST_POLICY 0x370
36#define SCLK_BURST_POLICY 0x028
37#define SYSTEM_CLK_RATE 0x030
38
39static DEFINE_SPINLOCK(sysrate_lock);
40
41static const char *sclk_parents[] = { "clk_m", "pll_c_out1", "pll_p_out4",
42 "pll_p", "pll_p_out2", "unused",
43 "clk_32k", "pll_m_out1" };
44
45static const char *cclk_g_parents[] = { "clk_m", "pll_c", "clk_32k", "pll_m",
46 "pll_p", "pll_p_out4", "unused",
47 "unused", "pll_x" };
48
49static const char *cclk_lp_parents[] = { "clk_m", "pll_c", "clk_32k", "pll_m",
50 "pll_p", "pll_p_out4", "unused",
51 "unused", "pll_x", "pll_x_out0" };
52
53static void __init tegra_sclk_init(void __iomem *clk_base,
54 struct tegra_clk *tegra_clks)
55{
56 struct clk *clk;
57 struct clk **dt_clk;
58
59 /* SCLK */
60 dt_clk = tegra_lookup_dt_id(tegra_clk_sclk, tegra_clks);
61 if (dt_clk) {
62 clk = tegra_clk_register_super_mux("sclk", sclk_parents,
63 ARRAY_SIZE(sclk_parents),
64 CLK_SET_RATE_PARENT,
65 clk_base + SCLK_BURST_POLICY,
66 0, 4, 0, 0, NULL);
67 *dt_clk = clk;
68 }
69
70 /* HCLK */
71 dt_clk = tegra_lookup_dt_id(tegra_clk_hclk, tegra_clks);
72 if (dt_clk) {
73 clk = clk_register_divider(NULL, "hclk_div", "sclk", 0,
74 clk_base + SYSTEM_CLK_RATE, 4, 2, 0,
75 &sysrate_lock);
76 clk = clk_register_gate(NULL, "hclk", "hclk_div",
77 CLK_SET_RATE_PARENT | CLK_IGNORE_UNUSED,
78 clk_base + SYSTEM_CLK_RATE,
79 7, CLK_GATE_SET_TO_DISABLE, &sysrate_lock);
80 *dt_clk = clk;
81 }
82
83 /* PCLK */
84 dt_clk = tegra_lookup_dt_id(tegra_clk_pclk, tegra_clks);
85 if (!dt_clk)
86 return;
87
88 clk = clk_register_divider(NULL, "pclk_div", "hclk", 0,
89 clk_base + SYSTEM_CLK_RATE, 0, 2, 0,
90 &sysrate_lock);
91 clk = clk_register_gate(NULL, "pclk", "pclk_div", CLK_SET_RATE_PARENT |
92 CLK_IGNORE_UNUSED, clk_base + SYSTEM_CLK_RATE,
93 3, CLK_GATE_SET_TO_DISABLE, &sysrate_lock);
94 *dt_clk = clk;
95}
96
97void __init tegra_super_clk_gen4_init(void __iomem *clk_base,
98 void __iomem *pmc_base,
99 struct tegra_clk *tegra_clks,
100 struct tegra_clk_pll_params *params)
101{
102 struct clk *clk;
103 struct clk **dt_clk;
104
105 /* CCLKG */
106 dt_clk = tegra_lookup_dt_id(tegra_clk_cclk_g, tegra_clks);
107 if (dt_clk) {
108 clk = tegra_clk_register_super_mux("cclk_g", cclk_g_parents,
109 ARRAY_SIZE(cclk_g_parents),
110 CLK_SET_RATE_PARENT,
111 clk_base + CCLKG_BURST_POLICY,
112 0, 4, 0, 0, NULL);
113 *dt_clk = clk;
114 }
115
116 /* CCLKLP */
117 dt_clk = tegra_lookup_dt_id(tegra_clk_cclk_lp, tegra_clks);
118 if (dt_clk) {
119 clk = tegra_clk_register_super_mux("cclk_lp", cclk_lp_parents,
120 ARRAY_SIZE(cclk_lp_parents),
121 CLK_SET_RATE_PARENT,
122 clk_base + CCLKLP_BURST_POLICY,
123 0, 4, 8, 9, NULL);
124 *dt_clk = clk;
125 }
126
127 tegra_sclk_init(clk_base, tegra_clks);
128
129#if defined(CONFIG_ARCH_TEGRA_114_SOC) || defined(CONFIG_ARCH_TEGRA_124_SOC)
130 /* PLLX */
131 dt_clk = tegra_lookup_dt_id(tegra_clk_pll_x, tegra_clks);
132 if (!dt_clk)
133 return;
134
135 clk = tegra_clk_register_pllxc("pll_x", "pll_ref", clk_base,
136 pmc_base, CLK_IGNORE_UNUSED, params, NULL);
137 *dt_clk = clk;
138
139 /* PLLX_OUT0 */
140
141 dt_clk = tegra_lookup_dt_id(tegra_clk_pll_x_out0, tegra_clks);
142 if (!dt_clk)
143 return;
144 clk = clk_register_fixed_factor(NULL, "pll_x_out0", "pll_x",
145 CLK_SET_RATE_PARENT, 1, 2);
146 *dt_clk = clk;
147#endif
148}
149
diff --git a/drivers/clk/tegra/clk-tegra114.c b/drivers/clk/tegra/clk-tegra114.c
index 9467da7dee49..90d9d25f2228 100644
--- a/drivers/clk/tegra/clk-tegra114.c
+++ b/drivers/clk/tegra/clk-tegra114.c
@@ -23,30 +23,15 @@
23#include <linux/delay.h> 23#include <linux/delay.h>
24#include <linux/export.h> 24#include <linux/export.h>
25#include <linux/clk/tegra.h> 25#include <linux/clk/tegra.h>
26#include <dt-bindings/clock/tegra114-car.h>
26 27
27#include "clk.h" 28#include "clk.h"
29#include "clk-id.h"
28 30
29#define RST_DEVICES_L 0x004
30#define RST_DEVICES_H 0x008
31#define RST_DEVICES_U 0x00C
32#define RST_DFLL_DVCO 0x2F4 31#define RST_DFLL_DVCO 0x2F4
33#define RST_DEVICES_V 0x358
34#define RST_DEVICES_W 0x35C
35#define RST_DEVICES_X 0x28C
36#define RST_DEVICES_SET_L 0x300
37#define RST_DEVICES_CLR_L 0x304
38#define RST_DEVICES_SET_H 0x308
39#define RST_DEVICES_CLR_H 0x30c
40#define RST_DEVICES_SET_U 0x310
41#define RST_DEVICES_CLR_U 0x314
42#define RST_DEVICES_SET_V 0x430
43#define RST_DEVICES_CLR_V 0x434
44#define RST_DEVICES_SET_W 0x438
45#define RST_DEVICES_CLR_W 0x43c
46#define CPU_FINETRIM_SELECT 0x4d4 /* override default prop dlys */ 32#define CPU_FINETRIM_SELECT 0x4d4 /* override default prop dlys */
47#define CPU_FINETRIM_DR 0x4d8 /* rise->rise prop dly A */ 33#define CPU_FINETRIM_DR 0x4d8 /* rise->rise prop dly A */
48#define CPU_FINETRIM_R 0x4e4 /* rise->rise prop dly inc A */ 34#define CPU_FINETRIM_R 0x4e4 /* rise->rise prop dly inc A */
49#define RST_DEVICES_NUM 5
50 35
51/* RST_DFLL_DVCO bitfields */ 36/* RST_DFLL_DVCO bitfields */
52#define DVFS_DFLL_RESET_SHIFT 0 37#define DVFS_DFLL_RESET_SHIFT 0
@@ -73,25 +58,7 @@
73#define CPU_FINETRIM_R_FCPU_6_SHIFT 10 /* ftop */ 58#define CPU_FINETRIM_R_FCPU_6_SHIFT 10 /* ftop */
74#define CPU_FINETRIM_R_FCPU_6_MASK (0x3 << CPU_FINETRIM_R_FCPU_6_SHIFT) 59#define CPU_FINETRIM_R_FCPU_6_MASK (0x3 << CPU_FINETRIM_R_FCPU_6_SHIFT)
75 60
76#define CLK_OUT_ENB_L 0x010 61#define TEGRA114_CLK_PERIPH_BANKS 5
77#define CLK_OUT_ENB_H 0x014
78#define CLK_OUT_ENB_U 0x018
79#define CLK_OUT_ENB_V 0x360
80#define CLK_OUT_ENB_W 0x364
81#define CLK_OUT_ENB_X 0x280
82#define CLK_OUT_ENB_SET_L 0x320
83#define CLK_OUT_ENB_CLR_L 0x324
84#define CLK_OUT_ENB_SET_H 0x328
85#define CLK_OUT_ENB_CLR_H 0x32c
86#define CLK_OUT_ENB_SET_U 0x330
87#define CLK_OUT_ENB_CLR_U 0x334
88#define CLK_OUT_ENB_SET_V 0x440
89#define CLK_OUT_ENB_CLR_V 0x444
90#define CLK_OUT_ENB_SET_W 0x448
91#define CLK_OUT_ENB_CLR_W 0x44c
92#define CLK_OUT_ENB_SET_X 0x284
93#define CLK_OUT_ENB_CLR_X 0x288
94#define CLK_OUT_ENB_NUM 6
95 62
96#define PLLC_BASE 0x80 63#define PLLC_BASE 0x80
97#define PLLC_MISC2 0x88 64#define PLLC_MISC2 0x88
@@ -139,25 +106,6 @@
139#define PLLE_AUX 0x48c 106#define PLLE_AUX 0x48c
140#define PLLC_OUT 0x84 107#define PLLC_OUT 0x84
141#define PLLM_OUT 0x94 108#define PLLM_OUT 0x94
142#define PLLP_OUTA 0xa4
143#define PLLP_OUTB 0xa8
144#define PLLA_OUT 0xb4
145
146#define AUDIO_SYNC_CLK_I2S0 0x4a0
147#define AUDIO_SYNC_CLK_I2S1 0x4a4
148#define AUDIO_SYNC_CLK_I2S2 0x4a8
149#define AUDIO_SYNC_CLK_I2S3 0x4ac
150#define AUDIO_SYNC_CLK_I2S4 0x4b0
151#define AUDIO_SYNC_CLK_SPDIF 0x4b4
152
153#define AUDIO_SYNC_DOUBLER 0x49c
154
155#define PMC_CLK_OUT_CNTRL 0x1a8
156#define PMC_DPD_PADS_ORIDE 0x1c
157#define PMC_DPD_PADS_ORIDE_BLINK_ENB 20
158#define PMC_CTRL 0
159#define PMC_CTRL_BLINK_ENB 7
160#define PMC_BLINK_TIMER 0x40
161 109
162#define OSC_CTRL 0x50 110#define OSC_CTRL 0x50
163#define OSC_CTRL_OSC_FREQ_SHIFT 28 111#define OSC_CTRL_OSC_FREQ_SHIFT 28
@@ -166,9 +114,6 @@
166#define PLLXC_SW_MAX_P 6 114#define PLLXC_SW_MAX_P 6
167 115
168#define CCLKG_BURST_POLICY 0x368 116#define CCLKG_BURST_POLICY 0x368
169#define CCLKLP_BURST_POLICY 0x370
170#define SCLK_BURST_POLICY 0x028
171#define SYSTEM_CLK_RATE 0x030
172 117
173#define UTMIP_PLL_CFG2 0x488 118#define UTMIP_PLL_CFG2 0x488
174#define UTMIP_PLL_CFG2_STABLE_COUNT(x) (((x) & 0xffff) << 6) 119#define UTMIP_PLL_CFG2_STABLE_COUNT(x) (((x) & 0xffff) << 6)
@@ -196,91 +141,8 @@
196#define UTMIPLL_HW_PWRDN_CFG0_IDDQ_OVERRIDE BIT(1) 141#define UTMIPLL_HW_PWRDN_CFG0_IDDQ_OVERRIDE BIT(1)
197#define UTMIPLL_HW_PWRDN_CFG0_IDDQ_SWCTL BIT(0) 142#define UTMIPLL_HW_PWRDN_CFG0_IDDQ_SWCTL BIT(0)
198 143
199#define CLK_SOURCE_I2S0 0x1d8
200#define CLK_SOURCE_I2S1 0x100
201#define CLK_SOURCE_I2S2 0x104
202#define CLK_SOURCE_NDFLASH 0x160
203#define CLK_SOURCE_I2S3 0x3bc
204#define CLK_SOURCE_I2S4 0x3c0
205#define CLK_SOURCE_SPDIF_OUT 0x108
206#define CLK_SOURCE_SPDIF_IN 0x10c
207#define CLK_SOURCE_PWM 0x110
208#define CLK_SOURCE_ADX 0x638
209#define CLK_SOURCE_AMX 0x63c
210#define CLK_SOURCE_HDA 0x428
211#define CLK_SOURCE_HDA2CODEC_2X 0x3e4
212#define CLK_SOURCE_SBC1 0x134
213#define CLK_SOURCE_SBC2 0x118
214#define CLK_SOURCE_SBC3 0x11c
215#define CLK_SOURCE_SBC4 0x1b4
216#define CLK_SOURCE_SBC5 0x3c8
217#define CLK_SOURCE_SBC6 0x3cc
218#define CLK_SOURCE_SATA_OOB 0x420
219#define CLK_SOURCE_SATA 0x424
220#define CLK_SOURCE_NDSPEED 0x3f8
221#define CLK_SOURCE_VFIR 0x168
222#define CLK_SOURCE_SDMMC1 0x150
223#define CLK_SOURCE_SDMMC2 0x154
224#define CLK_SOURCE_SDMMC3 0x1bc
225#define CLK_SOURCE_SDMMC4 0x164
226#define CLK_SOURCE_VDE 0x1c8
227#define CLK_SOURCE_CSITE 0x1d4 144#define CLK_SOURCE_CSITE 0x1d4
228#define CLK_SOURCE_LA 0x1f8
229#define CLK_SOURCE_TRACE 0x634
230#define CLK_SOURCE_OWR 0x1cc
231#define CLK_SOURCE_NOR 0x1d0
232#define CLK_SOURCE_MIPI 0x174
233#define CLK_SOURCE_I2C1 0x124
234#define CLK_SOURCE_I2C2 0x198
235#define CLK_SOURCE_I2C3 0x1b8
236#define CLK_SOURCE_I2C4 0x3c4
237#define CLK_SOURCE_I2C5 0x128
238#define CLK_SOURCE_UARTA 0x178
239#define CLK_SOURCE_UARTB 0x17c
240#define CLK_SOURCE_UARTC 0x1a0
241#define CLK_SOURCE_UARTD 0x1c0
242#define CLK_SOURCE_UARTE 0x1c4
243#define CLK_SOURCE_UARTA_DBG 0x178
244#define CLK_SOURCE_UARTB_DBG 0x17c
245#define CLK_SOURCE_UARTC_DBG 0x1a0
246#define CLK_SOURCE_UARTD_DBG 0x1c0
247#define CLK_SOURCE_UARTE_DBG 0x1c4
248#define CLK_SOURCE_3D 0x158
249#define CLK_SOURCE_2D 0x15c
250#define CLK_SOURCE_VI_SENSOR 0x1a8
251#define CLK_SOURCE_VI 0x148
252#define CLK_SOURCE_EPP 0x16c
253#define CLK_SOURCE_MSENC 0x1f0
254#define CLK_SOURCE_TSEC 0x1f4
255#define CLK_SOURCE_HOST1X 0x180
256#define CLK_SOURCE_HDMI 0x18c
257#define CLK_SOURCE_DISP1 0x138
258#define CLK_SOURCE_DISP2 0x13c
259#define CLK_SOURCE_CILAB 0x614
260#define CLK_SOURCE_CILCD 0x618
261#define CLK_SOURCE_CILE 0x61c
262#define CLK_SOURCE_DSIALP 0x620
263#define CLK_SOURCE_DSIBLP 0x624
264#define CLK_SOURCE_TSENSOR 0x3b8
265#define CLK_SOURCE_D_AUDIO 0x3d0
266#define CLK_SOURCE_DAM0 0x3d8
267#define CLK_SOURCE_DAM1 0x3dc
268#define CLK_SOURCE_DAM2 0x3e0
269#define CLK_SOURCE_ACTMON 0x3e8
270#define CLK_SOURCE_EXTERN1 0x3ec
271#define CLK_SOURCE_EXTERN2 0x3f0
272#define CLK_SOURCE_EXTERN3 0x3f4
273#define CLK_SOURCE_I2CSLOW 0x3fc
274#define CLK_SOURCE_SE 0x42c
275#define CLK_SOURCE_MSELECT 0x3b4
276#define CLK_SOURCE_DFLL_REF 0x62c
277#define CLK_SOURCE_DFLL_SOC 0x630
278#define CLK_SOURCE_SOC_THERM 0x644
279#define CLK_SOURCE_XUSB_HOST_SRC 0x600
280#define CLK_SOURCE_XUSB_FALCON_SRC 0x604
281#define CLK_SOURCE_XUSB_FS_SRC 0x608
282#define CLK_SOURCE_XUSB_SS_SRC 0x610 145#define CLK_SOURCE_XUSB_SS_SRC 0x610
283#define CLK_SOURCE_XUSB_DEV_SRC 0x60c
284#define CLK_SOURCE_EMC 0x19c 146#define CLK_SOURCE_EMC 0x19c
285 147
286/* PLLM override registers */ 148/* PLLM override registers */
@@ -298,19 +160,13 @@ static struct cpu_clk_suspend_context {
298} tegra114_cpu_clk_sctx; 160} tegra114_cpu_clk_sctx;
299#endif 161#endif
300 162
301static int periph_clk_enb_refcnt[CLK_OUT_ENB_NUM * 32];
302
303static void __iomem *clk_base; 163static void __iomem *clk_base;
304static void __iomem *pmc_base; 164static void __iomem *pmc_base;
305 165
306static DEFINE_SPINLOCK(pll_d_lock); 166static DEFINE_SPINLOCK(pll_d_lock);
307static DEFINE_SPINLOCK(pll_d2_lock); 167static DEFINE_SPINLOCK(pll_d2_lock);
308static DEFINE_SPINLOCK(pll_u_lock); 168static DEFINE_SPINLOCK(pll_u_lock);
309static DEFINE_SPINLOCK(pll_div_lock);
310static DEFINE_SPINLOCK(pll_re_lock); 169static DEFINE_SPINLOCK(pll_re_lock);
311static DEFINE_SPINLOCK(clk_doubler_lock);
312static DEFINE_SPINLOCK(clk_out_lock);
313static DEFINE_SPINLOCK(sysrate_lock);
314 170
315static struct div_nmp pllxc_nmp = { 171static struct div_nmp pllxc_nmp = {
316 .divm_shift = 0, 172 .divm_shift = 0,
@@ -370,6 +226,8 @@ static struct tegra_clk_pll_params pll_c_params = {
370 .stepb_shift = 9, 226 .stepb_shift = 9,
371 .pdiv_tohw = pllxc_p, 227 .pdiv_tohw = pllxc_p,
372 .div_nmp = &pllxc_nmp, 228 .div_nmp = &pllxc_nmp,
229 .freq_table = pll_c_freq_table,
230 .flags = TEGRA_PLL_USE_LOCK,
373}; 231};
374 232
375static struct div_nmp pllcx_nmp = { 233static struct div_nmp pllcx_nmp = {
@@ -417,6 +275,8 @@ static struct tegra_clk_pll_params pll_c2_params = {
417 .ext_misc_reg[0] = 0x4f0, 275 .ext_misc_reg[0] = 0x4f0,
418 .ext_misc_reg[1] = 0x4f4, 276 .ext_misc_reg[1] = 0x4f4,
419 .ext_misc_reg[2] = 0x4f8, 277 .ext_misc_reg[2] = 0x4f8,
278 .freq_table = pll_cx_freq_table,
279 .flags = TEGRA_PLL_USE_LOCK,
420}; 280};
421 281
422static struct tegra_clk_pll_params pll_c3_params = { 282static struct tegra_clk_pll_params pll_c3_params = {
@@ -437,6 +297,8 @@ static struct tegra_clk_pll_params pll_c3_params = {
437 .ext_misc_reg[0] = 0x504, 297 .ext_misc_reg[0] = 0x504,
438 .ext_misc_reg[1] = 0x508, 298 .ext_misc_reg[1] = 0x508,
439 .ext_misc_reg[2] = 0x50c, 299 .ext_misc_reg[2] = 0x50c,
300 .freq_table = pll_cx_freq_table,
301 .flags = TEGRA_PLL_USE_LOCK,
440}; 302};
441 303
442static struct div_nmp pllm_nmp = { 304static struct div_nmp pllm_nmp = {
@@ -483,6 +345,8 @@ static struct tegra_clk_pll_params pll_m_params = {
483 .div_nmp = &pllm_nmp, 345 .div_nmp = &pllm_nmp,
484 .pmc_divnm_reg = PMC_PLLM_WB0_OVERRIDE, 346 .pmc_divnm_reg = PMC_PLLM_WB0_OVERRIDE,
485 .pmc_divp_reg = PMC_PLLM_WB0_OVERRIDE_2, 347 .pmc_divp_reg = PMC_PLLM_WB0_OVERRIDE_2,
348 .freq_table = pll_m_freq_table,
349 .flags = TEGRA_PLL_USE_LOCK,
486}; 350};
487 351
488static struct div_nmp pllp_nmp = { 352static struct div_nmp pllp_nmp = {
@@ -516,6 +380,9 @@ static struct tegra_clk_pll_params pll_p_params = {
516 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE, 380 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
517 .lock_delay = 300, 381 .lock_delay = 300,
518 .div_nmp = &pllp_nmp, 382 .div_nmp = &pllp_nmp,
383 .freq_table = pll_p_freq_table,
384 .flags = TEGRA_PLL_FIXED | TEGRA_PLL_USE_LOCK,
385 .fixed_rate = 408000000,
519}; 386};
520 387
521static struct tegra_clk_pll_freq_table pll_a_freq_table[] = { 388static struct tegra_clk_pll_freq_table pll_a_freq_table[] = {
@@ -543,6 +410,8 @@ static struct tegra_clk_pll_params pll_a_params = {
543 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE, 410 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
544 .lock_delay = 300, 411 .lock_delay = 300,
545 .div_nmp = &pllp_nmp, 412 .div_nmp = &pllp_nmp,
413 .freq_table = pll_a_freq_table,
414 .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_USE_LOCK,
546}; 415};
547 416
548static struct tegra_clk_pll_freq_table pll_d_freq_table[] = { 417static struct tegra_clk_pll_freq_table pll_d_freq_table[] = {
@@ -579,6 +448,9 @@ static struct tegra_clk_pll_params pll_d_params = {
579 .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE, 448 .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE,
580 .lock_delay = 1000, 449 .lock_delay = 1000,
581 .div_nmp = &pllp_nmp, 450 .div_nmp = &pllp_nmp,
451 .freq_table = pll_d_freq_table,
452 .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON |
453 TEGRA_PLL_USE_LOCK,
582}; 454};
583 455
584static struct tegra_clk_pll_params pll_d2_params = { 456static struct tegra_clk_pll_params pll_d2_params = {
@@ -594,6 +466,9 @@ static struct tegra_clk_pll_params pll_d2_params = {
594 .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE, 466 .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE,
595 .lock_delay = 1000, 467 .lock_delay = 1000,
596 .div_nmp = &pllp_nmp, 468 .div_nmp = &pllp_nmp,
469 .freq_table = pll_d_freq_table,
470 .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON |
471 TEGRA_PLL_USE_LOCK,
597}; 472};
598 473
599static struct pdiv_map pllu_p[] = { 474static struct pdiv_map pllu_p[] = {
@@ -634,6 +509,9 @@ static struct tegra_clk_pll_params pll_u_params = {
634 .lock_delay = 1000, 509 .lock_delay = 1000,
635 .pdiv_tohw = pllu_p, 510 .pdiv_tohw = pllu_p,
636 .div_nmp = &pllu_nmp, 511 .div_nmp = &pllu_nmp,
512 .freq_table = pll_u_freq_table,
513 .flags = TEGRA_PLLU | TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON |
514 TEGRA_PLL_USE_LOCK,
637}; 515};
638 516
639static struct tegra_clk_pll_freq_table pll_x_freq_table[] = { 517static struct tegra_clk_pll_freq_table pll_x_freq_table[] = {
@@ -667,12 +545,15 @@ static struct tegra_clk_pll_params pll_x_params = {
667 .stepb_shift = 24, 545 .stepb_shift = 24,
668 .pdiv_tohw = pllxc_p, 546 .pdiv_tohw = pllxc_p,
669 .div_nmp = &pllxc_nmp, 547 .div_nmp = &pllxc_nmp,
548 .freq_table = pll_x_freq_table,
549 .flags = TEGRA_PLL_USE_LOCK,
670}; 550};
671 551
672static struct tegra_clk_pll_freq_table pll_e_freq_table[] = { 552static struct tegra_clk_pll_freq_table pll_e_freq_table[] = {
673 /* PLLE special case: use cpcon field to store cml divider value */ 553 /* PLLE special case: use cpcon field to store cml divider value */
674 {336000000, 100000000, 100, 21, 16, 11}, 554 {336000000, 100000000, 100, 21, 16, 11},
675 {312000000, 100000000, 200, 26, 24, 13}, 555 {312000000, 100000000, 200, 26, 24, 13},
556 {12000000, 100000000, 200, 1, 24, 13},
676 {0, 0, 0, 0, 0, 0}, 557 {0, 0, 0, 0, 0, 0},
677}; 558};
678 559
@@ -699,6 +580,9 @@ static struct tegra_clk_pll_params pll_e_params = {
699 .lock_enable_bit_idx = PLLE_MISC_LOCK_ENABLE, 580 .lock_enable_bit_idx = PLLE_MISC_LOCK_ENABLE,
700 .lock_delay = 300, 581 .lock_delay = 300,
701 .div_nmp = &plle_nmp, 582 .div_nmp = &plle_nmp,
583 .freq_table = pll_e_freq_table,
584 .flags = TEGRA_PLL_FIXED,
585 .fixed_rate = 100000000,
702}; 586};
703 587
704static struct div_nmp pllre_nmp = { 588static struct div_nmp pllre_nmp = {
@@ -725,53 +609,7 @@ static struct tegra_clk_pll_params pll_re_vco_params = {
725 .iddq_reg = PLLRE_MISC, 609 .iddq_reg = PLLRE_MISC,
726 .iddq_bit_idx = PLLRE_IDDQ_BIT, 610 .iddq_bit_idx = PLLRE_IDDQ_BIT,
727 .div_nmp = &pllre_nmp, 611 .div_nmp = &pllre_nmp,
728}; 612 .flags = TEGRA_PLL_USE_LOCK,
729
730/* Peripheral clock registers */
731
732static struct tegra_clk_periph_regs periph_l_regs = {
733 .enb_reg = CLK_OUT_ENB_L,
734 .enb_set_reg = CLK_OUT_ENB_SET_L,
735 .enb_clr_reg = CLK_OUT_ENB_CLR_L,
736 .rst_reg = RST_DEVICES_L,
737 .rst_set_reg = RST_DEVICES_SET_L,
738 .rst_clr_reg = RST_DEVICES_CLR_L,
739};
740
741static struct tegra_clk_periph_regs periph_h_regs = {
742 .enb_reg = CLK_OUT_ENB_H,
743 .enb_set_reg = CLK_OUT_ENB_SET_H,
744 .enb_clr_reg = CLK_OUT_ENB_CLR_H,
745 .rst_reg = RST_DEVICES_H,
746 .rst_set_reg = RST_DEVICES_SET_H,
747 .rst_clr_reg = RST_DEVICES_CLR_H,
748};
749
750static struct tegra_clk_periph_regs periph_u_regs = {
751 .enb_reg = CLK_OUT_ENB_U,
752 .enb_set_reg = CLK_OUT_ENB_SET_U,
753 .enb_clr_reg = CLK_OUT_ENB_CLR_U,
754 .rst_reg = RST_DEVICES_U,
755 .rst_set_reg = RST_DEVICES_SET_U,
756 .rst_clr_reg = RST_DEVICES_CLR_U,
757};
758
759static struct tegra_clk_periph_regs periph_v_regs = {
760 .enb_reg = CLK_OUT_ENB_V,
761 .enb_set_reg = CLK_OUT_ENB_SET_V,
762 .enb_clr_reg = CLK_OUT_ENB_CLR_V,
763 .rst_reg = RST_DEVICES_V,
764 .rst_set_reg = RST_DEVICES_SET_V,
765 .rst_clr_reg = RST_DEVICES_CLR_V,
766};
767
768static struct tegra_clk_periph_regs periph_w_regs = {
769 .enb_reg = CLK_OUT_ENB_W,
770 .enb_set_reg = CLK_OUT_ENB_SET_W,
771 .enb_clr_reg = CLK_OUT_ENB_CLR_W,
772 .rst_reg = RST_DEVICES_W,
773 .rst_set_reg = RST_DEVICES_SET_W,
774 .rst_clr_reg = RST_DEVICES_CLR_W,
775}; 613};
776 614
777/* possible OSC frequencies in Hz */ 615/* possible OSC frequencies in Hz */
@@ -787,120 +625,6 @@ static unsigned long tegra114_input_freq[] = {
787 625
788#define MASK(x) (BIT(x) - 1) 626#define MASK(x) (BIT(x) - 1)
789 627
790#define TEGRA_INIT_DATA_MUX(_name, _con_id, _dev_id, _parents, _offset, \
791 _clk_num, _regs, _gate_flags, _clk_id) \
792 TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parents, _offset,\
793 30, MASK(2), 0, 0, 8, 1, 0, _regs, _clk_num, \
794 periph_clk_enb_refcnt, _gate_flags, _clk_id, \
795 _parents##_idx, 0)
796
797#define TEGRA_INIT_DATA_MUX_FLAGS(_name, _con_id, _dev_id, _parents, _offset,\
798 _clk_num, _regs, _gate_flags, _clk_id, flags)\
799 TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parents, _offset,\
800 30, MASK(2), 0, 0, 8, 1, 0, _regs, _clk_num, \
801 periph_clk_enb_refcnt, _gate_flags, _clk_id, \
802 _parents##_idx, flags)
803
804#define TEGRA_INIT_DATA_MUX8(_name, _con_id, _dev_id, _parents, _offset, \
805 _clk_num, _regs, _gate_flags, _clk_id) \
806 TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parents, _offset,\
807 29, MASK(3), 0, 0, 8, 1, 0, _regs, _clk_num, \
808 periph_clk_enb_refcnt, _gate_flags, _clk_id, \
809 _parents##_idx, 0)
810
811#define TEGRA_INIT_DATA_INT(_name, _con_id, _dev_id, _parents, _offset, \
812 _clk_num, _regs, _gate_flags, _clk_id) \
813 TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parents, _offset,\
814 30, MASK(2), 0, 0, 8, 1, TEGRA_DIVIDER_INT, _regs,\
815 _clk_num, periph_clk_enb_refcnt, _gate_flags, \
816 _clk_id, _parents##_idx, 0)
817
818#define TEGRA_INIT_DATA_INT_FLAGS(_name, _con_id, _dev_id, _parents, _offset,\
819 _clk_num, _regs, _gate_flags, _clk_id, flags)\
820 TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parents, _offset,\
821 30, MASK(2), 0, 0, 8, 1, TEGRA_DIVIDER_INT, _regs,\
822 _clk_num, periph_clk_enb_refcnt, _gate_flags, \
823 _clk_id, _parents##_idx, flags)
824
825#define TEGRA_INIT_DATA_INT8(_name, _con_id, _dev_id, _parents, _offset,\
826 _clk_num, _regs, _gate_flags, _clk_id) \
827 TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parents, _offset,\
828 29, MASK(3), 0, 0, 8, 1, TEGRA_DIVIDER_INT, _regs,\
829 _clk_num, periph_clk_enb_refcnt, _gate_flags, \
830 _clk_id, _parents##_idx, 0)
831
832#define TEGRA_INIT_DATA_UART(_name, _con_id, _dev_id, _parents, _offset,\
833 _clk_num, _regs, _clk_id) \
834 TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parents, _offset,\
835 30, MASK(2), 0, 0, 16, 1, TEGRA_DIVIDER_UART, _regs,\
836 _clk_num, periph_clk_enb_refcnt, 0, _clk_id, \
837 _parents##_idx, 0)
838
839#define TEGRA_INIT_DATA_I2C(_name, _con_id, _dev_id, _parents, _offset,\
840 _clk_num, _regs, _clk_id) \
841 TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parents, _offset,\
842 30, MASK(2), 0, 0, 16, 0, 0, _regs, _clk_num, \
843 periph_clk_enb_refcnt, 0, _clk_id, _parents##_idx, 0)
844
845#define TEGRA_INIT_DATA_NODIV(_name, _con_id, _dev_id, _parents, _offset, \
846 _mux_shift, _mux_mask, _clk_num, _regs, \
847 _gate_flags, _clk_id) \
848 TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parents, _offset,\
849 _mux_shift, _mux_mask, 0, 0, 0, 0, 0, _regs, \
850 _clk_num, periph_clk_enb_refcnt, _gate_flags, \
851 _clk_id, _parents##_idx, 0)
852
853#define TEGRA_INIT_DATA_XUSB(_name, _con_id, _dev_id, _parents, _offset, \
854 _clk_num, _regs, _gate_flags, _clk_id) \
855 TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parents, _offset, \
856 29, MASK(3), 0, 0, 8, 1, TEGRA_DIVIDER_INT, _regs, \
857 _clk_num, periph_clk_enb_refcnt, _gate_flags, \
858 _clk_id, _parents##_idx, 0)
859
860#define TEGRA_INIT_DATA_AUDIO(_name, _con_id, _dev_id, _offset, _clk_num,\
861 _regs, _gate_flags, _clk_id) \
862 TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, mux_d_audio_clk, \
863 _offset, 16, 0xE01F, 0, 0, 8, 1, 0, _regs, _clk_num, \
864 periph_clk_enb_refcnt, _gate_flags , _clk_id, \
865 mux_d_audio_clk_idx, 0)
866
867enum tegra114_clk {
868 rtc = 4, timer = 5, uarta = 6, sdmmc2 = 9, i2s1 = 11, i2c1 = 12,
869 ndflash = 13, sdmmc1 = 14, sdmmc4 = 15, pwm = 17, i2s2 = 18, epp = 19,
870 gr_2d = 21, usbd = 22, isp = 23, gr_3d = 24, disp2 = 26, disp1 = 27,
871 host1x = 28, vcp = 29, i2s0 = 30, apbdma = 34, kbc = 36, kfuse = 40,
872 sbc1 = 41, nor = 42, sbc2 = 44, sbc3 = 46, i2c5 = 47, dsia = 48,
873 mipi = 50, hdmi = 51, csi = 52, i2c2 = 54, uartc = 55, mipi_cal = 56,
874 emc, usb2, usb3, vde = 61, bsea = 62, bsev = 63, uartd = 65,
875 i2c3 = 67, sbc4 = 68, sdmmc3 = 69, owr = 71, csite = 73,
876 la = 76, trace = 77, soc_therm = 78, dtv = 79, ndspeed = 80,
877 i2cslow = 81, dsib = 82, tsec = 83, xusb_host = 89, msenc = 91,
878 csus = 92, mselect = 99, tsensor = 100, i2s3 = 101, i2s4 = 102,
879 i2c4 = 103, sbc5 = 104, sbc6 = 105, d_audio, apbif = 107, dam0, dam1,
880 dam2, hda2codec_2x = 111, audio0_2x = 113, audio1_2x, audio2_2x,
881 audio3_2x, audio4_2x, spdif_2x, actmon = 119, extern1 = 120,
882 extern2 = 121, extern3 = 122, hda = 125, se = 127, hda2hdmi = 128,
883 cilab = 144, cilcd = 145, cile = 146, dsialp = 147, dsiblp = 148,
884 dds = 150, dp2 = 152, amx = 153, adx = 154, xusb_ss = 156, uartb = 192,
885 vfir, spdif_in, spdif_out, vi, vi_sensor, fuse, fuse_burn, clk_32k,
886 clk_m, clk_m_div2, clk_m_div4, pll_ref, pll_c, pll_c_out1, pll_c2,
887 pll_c3, pll_m, pll_m_out1, pll_p, pll_p_out1, pll_p_out2, pll_p_out3,
888 pll_p_out4, pll_a, pll_a_out0, pll_d, pll_d_out0, pll_d2, pll_d2_out0,
889 pll_u, pll_u_480M, pll_u_60M, pll_u_48M, pll_u_12M, pll_x, pll_x_out0,
890 pll_re_vco, pll_re_out, pll_e_out0, spdif_in_sync, i2s0_sync,
891 i2s1_sync, i2s2_sync, i2s3_sync, i2s4_sync, vimclk_sync, audio0,
892 audio1, audio2, audio3, audio4, spdif, clk_out_1, clk_out_2, clk_out_3,
893 blink, xusb_host_src = 252, xusb_falcon_src, xusb_fs_src, xusb_ss_src,
894 xusb_dev_src, xusb_dev, xusb_hs_src, sclk, hclk, pclk, cclk_g, cclk_lp,
895 dfll_ref = 264, dfll_soc,
896
897 /* Mux clocks */
898
899 audio0_mux = 300, audio1_mux, audio2_mux, audio3_mux, audio4_mux,
900 spdif_mux, clk_out_1_mux, clk_out_2_mux, clk_out_3_mux, dsia_mux,
901 dsib_mux, clk_max,
902};
903
904struct utmi_clk_param { 628struct utmi_clk_param {
905 /* Oscillator Frequency in KHz */ 629 /* Oscillator Frequency in KHz */
906 u32 osc_frequency; 630 u32 osc_frequency;
@@ -934,122 +658,11 @@ static const struct utmi_clk_param utmi_parameters[] = {
934 658
935/* peripheral mux definitions */ 659/* peripheral mux definitions */
936 660
937#define MUX_I2S_SPDIF(_id) \
938static const char *mux_pllaout0_##_id##_2x_pllp_clkm[] = { "pll_a_out0", \
939 #_id, "pll_p",\
940 "clk_m"};
941MUX_I2S_SPDIF(audio0)
942MUX_I2S_SPDIF(audio1)
943MUX_I2S_SPDIF(audio2)
944MUX_I2S_SPDIF(audio3)
945MUX_I2S_SPDIF(audio4)
946MUX_I2S_SPDIF(audio)
947
948#define mux_pllaout0_audio0_2x_pllp_clkm_idx NULL
949#define mux_pllaout0_audio1_2x_pllp_clkm_idx NULL
950#define mux_pllaout0_audio2_2x_pllp_clkm_idx NULL
951#define mux_pllaout0_audio3_2x_pllp_clkm_idx NULL
952#define mux_pllaout0_audio4_2x_pllp_clkm_idx NULL
953#define mux_pllaout0_audio_2x_pllp_clkm_idx NULL
954
955static const char *mux_pllp_pllc_pllm_clkm[] = {
956 "pll_p", "pll_c", "pll_m", "clk_m"
957};
958#define mux_pllp_pllc_pllm_clkm_idx NULL
959
960static const char *mux_pllp_pllc_pllm[] = { "pll_p", "pll_c", "pll_m" };
961#define mux_pllp_pllc_pllm_idx NULL
962
963static const char *mux_pllp_pllc_clk32_clkm[] = {
964 "pll_p", "pll_c", "clk_32k", "clk_m"
965};
966#define mux_pllp_pllc_clk32_clkm_idx NULL
967
968static const char *mux_plla_pllc_pllp_clkm[] = {
969 "pll_a_out0", "pll_c", "pll_p", "clk_m"
970};
971#define mux_plla_pllc_pllp_clkm_idx mux_pllp_pllc_pllm_clkm_idx
972
973static const char *mux_pllp_pllc2_c_c3_pllm_clkm[] = {
974 "pll_p", "pll_c2", "pll_c", "pll_c3", "pll_m", "clk_m"
975};
976static u32 mux_pllp_pllc2_c_c3_pllm_clkm_idx[] = {
977 [0] = 0, [1] = 1, [2] = 2, [3] = 3, [4] = 4, [5] = 6,
978};
979
980static const char *mux_pllp_clkm[] = {
981 "pll_p", "clk_m"
982};
983static u32 mux_pllp_clkm_idx[] = {
984 [0] = 0, [1] = 3,
985};
986
987static const char *mux_pllm_pllc2_c_c3_pllp_plla[] = {
988 "pll_m", "pll_c2", "pll_c", "pll_c3", "pll_p", "pll_a_out0"
989};
990#define mux_pllm_pllc2_c_c3_pllp_plla_idx mux_pllp_pllc2_c_c3_pllm_clkm_idx
991
992static const char *mux_pllp_pllm_plld_plla_pllc_plld2_clkm[] = {
993 "pll_p", "pll_m", "pll_d_out0", "pll_a_out0", "pll_c",
994 "pll_d2_out0", "clk_m"
995};
996#define mux_pllp_pllm_plld_plla_pllc_plld2_clkm_idx NULL
997
998static const char *mux_pllm_pllc_pllp_plla[] = {
999 "pll_m", "pll_c", "pll_p", "pll_a_out0"
1000};
1001#define mux_pllm_pllc_pllp_plla_idx mux_pllp_pllc_pllm_clkm_idx
1002
1003static const char *mux_pllp_pllc_clkm[] = {
1004 "pll_p", "pll_c", "pll_m"
1005};
1006static u32 mux_pllp_pllc_clkm_idx[] = {
1007 [0] = 0, [1] = 1, [2] = 3,
1008};
1009
1010static const char *mux_pllp_pllc_clkm_clk32[] = {
1011 "pll_p", "pll_c", "clk_m", "clk_32k"
1012};
1013#define mux_pllp_pllc_clkm_clk32_idx NULL
1014
1015static const char *mux_plla_clk32_pllp_clkm_plle[] = {
1016 "pll_a_out0", "clk_32k", "pll_p", "clk_m", "pll_e_out0"
1017};
1018#define mux_plla_clk32_pllp_clkm_plle_idx NULL
1019
1020static const char *mux_clkm_pllp_pllc_pllre[] = {
1021 "clk_m", "pll_p", "pll_c", "pll_re_out"
1022};
1023static u32 mux_clkm_pllp_pllc_pllre_idx[] = {
1024 [0] = 0, [1] = 1, [2] = 3, [3] = 5,
1025};
1026
1027static const char *mux_clkm_48M_pllp_480M[] = {
1028 "clk_m", "pll_u_48M", "pll_p", "pll_u_480M"
1029};
1030#define mux_clkm_48M_pllp_480M_idx NULL
1031
1032static const char *mux_clkm_pllre_clk32_480M_pllc_ref[] = {
1033 "clk_m", "pll_re_out", "clk_32k", "pll_u_480M", "pll_c", "pll_ref"
1034};
1035static u32 mux_clkm_pllre_clk32_480M_pllc_ref_idx[] = {
1036 [0] = 0, [1] = 1, [2] = 3, [3] = 3, [4] = 4, [5] = 7,
1037};
1038
1039static const char *mux_plld_out0_plld2_out0[] = { 661static const char *mux_plld_out0_plld2_out0[] = {
1040 "pll_d_out0", "pll_d2_out0", 662 "pll_d_out0", "pll_d2_out0",
1041}; 663};
1042#define mux_plld_out0_plld2_out0_idx NULL 664#define mux_plld_out0_plld2_out0_idx NULL
1043 665
1044static const char *mux_d_audio_clk[] = {
1045 "pll_a_out0", "pll_p", "clk_m", "spdif_in_sync", "i2s0_sync",
1046 "i2s1_sync", "i2s2_sync", "i2s3_sync", "i2s4_sync", "vimclk_sync",
1047};
1048static u32 mux_d_audio_clk_idx[] = {
1049 [0] = 0, [1] = 0x8000, [2] = 0xc000, [3] = 0xE000, [4] = 0xE001,
1050 [5] = 0xE002, [6] = 0xE003, [7] = 0xE004, [8] = 0xE005, [9] = 0xE007,
1051};
1052
1053static const char *mux_pllmcp_clkm[] = { 666static const char *mux_pllmcp_clkm[] = {
1054 "pll_m_out0", "pll_c_out0", "pll_p_out0", "clk_m", "pll_m_ud", 667 "pll_m_out0", "pll_c_out0", "pll_p_out0", "clk_m", "pll_m_ud",
1055}; 668};
@@ -1064,8 +677,253 @@ static const struct clk_div_table pll_re_div_table[] = {
1064 { .val = 0, .div = 0 }, 677 { .val = 0, .div = 0 },
1065}; 678};
1066 679
1067static struct clk *clks[clk_max]; 680static struct tegra_clk tegra114_clks[tegra_clk_max] __initdata = {
1068static struct clk_onecell_data clk_data; 681 [tegra_clk_rtc] = { .dt_id = TEGRA114_CLK_RTC, .present = true },
682 [tegra_clk_timer] = { .dt_id = TEGRA114_CLK_TIMER, .present = true },
683 [tegra_clk_uarta] = { .dt_id = TEGRA114_CLK_UARTA, .present = true },
684 [tegra_clk_uartd] = { .dt_id = TEGRA114_CLK_UARTD, .present = true },
685 [tegra_clk_sdmmc2] = { .dt_id = TEGRA114_CLK_SDMMC2, .present = true },
686 [tegra_clk_i2s1] = { .dt_id = TEGRA114_CLK_I2S1, .present = true },
687 [tegra_clk_i2c1] = { .dt_id = TEGRA114_CLK_I2C1, .present = true },
688 [tegra_clk_ndflash] = { .dt_id = TEGRA114_CLK_NDFLASH, .present = true },
689 [tegra_clk_sdmmc1] = { .dt_id = TEGRA114_CLK_SDMMC1, .present = true },
690 [tegra_clk_sdmmc4] = { .dt_id = TEGRA114_CLK_SDMMC4, .present = true },
691 [tegra_clk_pwm] = { .dt_id = TEGRA114_CLK_PWM, .present = true },
692 [tegra_clk_i2s0] = { .dt_id = TEGRA114_CLK_I2S0, .present = true },
693 [tegra_clk_i2s2] = { .dt_id = TEGRA114_CLK_I2S2, .present = true },
694 [tegra_clk_epp_8] = { .dt_id = TEGRA114_CLK_EPP, .present = true },
695 [tegra_clk_gr2d_8] = { .dt_id = TEGRA114_CLK_GR2D, .present = true },
696 [tegra_clk_usbd] = { .dt_id = TEGRA114_CLK_USBD, .present = true },
697 [tegra_clk_isp] = { .dt_id = TEGRA114_CLK_ISP, .present = true },
698 [tegra_clk_gr3d_8] = { .dt_id = TEGRA114_CLK_GR3D, .present = true },
699 [tegra_clk_disp2] = { .dt_id = TEGRA114_CLK_DISP2, .present = true },
700 [tegra_clk_disp1] = { .dt_id = TEGRA114_CLK_DISP1, .present = true },
701 [tegra_clk_host1x_8] = { .dt_id = TEGRA114_CLK_HOST1X, .present = true },
702 [tegra_clk_vcp] = { .dt_id = TEGRA114_CLK_VCP, .present = true },
703 [tegra_clk_apbdma] = { .dt_id = TEGRA114_CLK_APBDMA, .present = true },
704 [tegra_clk_kbc] = { .dt_id = TEGRA114_CLK_KBC, .present = true },
705 [tegra_clk_kfuse] = { .dt_id = TEGRA114_CLK_KFUSE, .present = true },
706 [tegra_clk_sbc1_8] = { .dt_id = TEGRA114_CLK_SBC1, .present = true },
707 [tegra_clk_nor] = { .dt_id = TEGRA114_CLK_NOR, .present = true },
708 [tegra_clk_sbc2_8] = { .dt_id = TEGRA114_CLK_SBC2, .present = true },
709 [tegra_clk_sbc3_8] = { .dt_id = TEGRA114_CLK_SBC3, .present = true },
710 [tegra_clk_i2c5] = { .dt_id = TEGRA114_CLK_I2C5, .present = true },
711 [tegra_clk_dsia] = { .dt_id = TEGRA114_CLK_DSIA, .present = true },
712 [tegra_clk_mipi] = { .dt_id = TEGRA114_CLK_MIPI, .present = true },
713 [tegra_clk_hdmi] = { .dt_id = TEGRA114_CLK_HDMI, .present = true },
714 [tegra_clk_csi] = { .dt_id = TEGRA114_CLK_CSI, .present = true },
715 [tegra_clk_i2c2] = { .dt_id = TEGRA114_CLK_I2C2, .present = true },
716 [tegra_clk_uartc] = { .dt_id = TEGRA114_CLK_UARTC, .present = true },
717 [tegra_clk_mipi_cal] = { .dt_id = TEGRA114_CLK_MIPI_CAL, .present = true },
718 [tegra_clk_emc] = { .dt_id = TEGRA114_CLK_EMC, .present = true },
719 [tegra_clk_usb2] = { .dt_id = TEGRA114_CLK_USB2, .present = true },
720 [tegra_clk_usb3] = { .dt_id = TEGRA114_CLK_USB3, .present = true },
721 [tegra_clk_vde_8] = { .dt_id = TEGRA114_CLK_VDE, .present = true },
722 [tegra_clk_bsea] = { .dt_id = TEGRA114_CLK_BSEA, .present = true },
723 [tegra_clk_bsev] = { .dt_id = TEGRA114_CLK_BSEV, .present = true },
724 [tegra_clk_i2c3] = { .dt_id = TEGRA114_CLK_I2C3, .present = true },
725 [tegra_clk_sbc4_8] = { .dt_id = TEGRA114_CLK_SBC4, .present = true },
726 [tegra_clk_sdmmc3] = { .dt_id = TEGRA114_CLK_SDMMC3, .present = true },
727 [tegra_clk_owr] = { .dt_id = TEGRA114_CLK_OWR, .present = true },
728 [tegra_clk_csite] = { .dt_id = TEGRA114_CLK_CSITE, .present = true },
729 [tegra_clk_la] = { .dt_id = TEGRA114_CLK_LA, .present = true },
730 [tegra_clk_trace] = { .dt_id = TEGRA114_CLK_TRACE, .present = true },
731 [tegra_clk_soc_therm] = { .dt_id = TEGRA114_CLK_SOC_THERM, .present = true },
732 [tegra_clk_dtv] = { .dt_id = TEGRA114_CLK_DTV, .present = true },
733 [tegra_clk_ndspeed] = { .dt_id = TEGRA114_CLK_NDSPEED, .present = true },
734 [tegra_clk_i2cslow] = { .dt_id = TEGRA114_CLK_I2CSLOW, .present = true },
735 [tegra_clk_dsib] = { .dt_id = TEGRA114_CLK_DSIB, .present = true },
736 [tegra_clk_tsec] = { .dt_id = TEGRA114_CLK_TSEC, .present = true },
737 [tegra_clk_xusb_host] = { .dt_id = TEGRA114_CLK_XUSB_HOST, .present = true },
738 [tegra_clk_msenc] = { .dt_id = TEGRA114_CLK_MSENC, .present = true },
739 [tegra_clk_csus] = { .dt_id = TEGRA114_CLK_CSUS, .present = true },
740 [tegra_clk_mselect] = { .dt_id = TEGRA114_CLK_MSELECT, .present = true },
741 [tegra_clk_tsensor] = { .dt_id = TEGRA114_CLK_TSENSOR, .present = true },
742 [tegra_clk_i2s3] = { .dt_id = TEGRA114_CLK_I2S3, .present = true },
743 [tegra_clk_i2s4] = { .dt_id = TEGRA114_CLK_I2S4, .present = true },
744 [tegra_clk_i2c4] = { .dt_id = TEGRA114_CLK_I2C4, .present = true },
745 [tegra_clk_sbc5_8] = { .dt_id = TEGRA114_CLK_SBC5, .present = true },
746 [tegra_clk_sbc6_8] = { .dt_id = TEGRA114_CLK_SBC6, .present = true },
747 [tegra_clk_d_audio] = { .dt_id = TEGRA114_CLK_D_AUDIO, .present = true },
748 [tegra_clk_apbif] = { .dt_id = TEGRA114_CLK_APBIF, .present = true },
749 [tegra_clk_dam0] = { .dt_id = TEGRA114_CLK_DAM0, .present = true },
750 [tegra_clk_dam1] = { .dt_id = TEGRA114_CLK_DAM1, .present = true },
751 [tegra_clk_dam2] = { .dt_id = TEGRA114_CLK_DAM2, .present = true },
752 [tegra_clk_hda2codec_2x] = { .dt_id = TEGRA114_CLK_HDA2CODEC_2X, .present = true },
753 [tegra_clk_audio0_2x] = { .dt_id = TEGRA114_CLK_AUDIO0_2X, .present = true },
754 [tegra_clk_audio1_2x] = { .dt_id = TEGRA114_CLK_AUDIO1_2X, .present = true },
755 [tegra_clk_audio2_2x] = { .dt_id = TEGRA114_CLK_AUDIO2_2X, .present = true },
756 [tegra_clk_audio3_2x] = { .dt_id = TEGRA114_CLK_AUDIO3_2X, .present = true },
757 [tegra_clk_audio4_2x] = { .dt_id = TEGRA114_CLK_AUDIO4_2X, .present = true },
758 [tegra_clk_spdif_2x] = { .dt_id = TEGRA114_CLK_SPDIF_2X, .present = true },
759 [tegra_clk_actmon] = { .dt_id = TEGRA114_CLK_ACTMON, .present = true },
760 [tegra_clk_extern1] = { .dt_id = TEGRA114_CLK_EXTERN1, .present = true },
761 [tegra_clk_extern2] = { .dt_id = TEGRA114_CLK_EXTERN2, .present = true },
762 [tegra_clk_extern3] = { .dt_id = TEGRA114_CLK_EXTERN3, .present = true },
763 [tegra_clk_hda] = { .dt_id = TEGRA114_CLK_HDA, .present = true },
764 [tegra_clk_se] = { .dt_id = TEGRA114_CLK_SE, .present = true },
765 [tegra_clk_hda2hdmi] = { .dt_id = TEGRA114_CLK_HDA2HDMI, .present = true },
766 [tegra_clk_cilab] = { .dt_id = TEGRA114_CLK_CILAB, .present = true },
767 [tegra_clk_cilcd] = { .dt_id = TEGRA114_CLK_CILCD, .present = true },
768 [tegra_clk_cile] = { .dt_id = TEGRA114_CLK_CILE, .present = true },
769 [tegra_clk_dsialp] = { .dt_id = TEGRA114_CLK_DSIALP, .present = true },
770 [tegra_clk_dsiblp] = { .dt_id = TEGRA114_CLK_DSIBLP, .present = true },
771 [tegra_clk_dds] = { .dt_id = TEGRA114_CLK_DDS, .present = true },
772 [tegra_clk_dp2] = { .dt_id = TEGRA114_CLK_DP2, .present = true },
773 [tegra_clk_amx] = { .dt_id = TEGRA114_CLK_AMX, .present = true },
774 [tegra_clk_adx] = { .dt_id = TEGRA114_CLK_ADX, .present = true },
775 [tegra_clk_xusb_ss] = { .dt_id = TEGRA114_CLK_XUSB_SS, .present = true },
776 [tegra_clk_uartb] = { .dt_id = TEGRA114_CLK_UARTB, .present = true },
777 [tegra_clk_vfir] = { .dt_id = TEGRA114_CLK_VFIR, .present = true },
778 [tegra_clk_spdif_in] = { .dt_id = TEGRA114_CLK_SPDIF_IN, .present = true },
779 [tegra_clk_spdif_out] = { .dt_id = TEGRA114_CLK_SPDIF_OUT, .present = true },
780 [tegra_clk_vi_8] = { .dt_id = TEGRA114_CLK_VI, .present = true },
781 [tegra_clk_vi_sensor_8] = { .dt_id = TEGRA114_CLK_VI_SENSOR, .present = true },
782 [tegra_clk_fuse] = { .dt_id = TEGRA114_CLK_FUSE, .present = true },
783 [tegra_clk_fuse_burn] = { .dt_id = TEGRA114_CLK_FUSE_BURN, .present = true },
784 [tegra_clk_clk_32k] = { .dt_id = TEGRA114_CLK_CLK_32K, .present = true },
785 [tegra_clk_clk_m] = { .dt_id = TEGRA114_CLK_CLK_M, .present = true },
786 [tegra_clk_clk_m_div2] = { .dt_id = TEGRA114_CLK_CLK_M_DIV2, .present = true },
787 [tegra_clk_clk_m_div4] = { .dt_id = TEGRA114_CLK_CLK_M_DIV4, .present = true },
788 [tegra_clk_pll_ref] = { .dt_id = TEGRA114_CLK_PLL_REF, .present = true },
789 [tegra_clk_pll_c] = { .dt_id = TEGRA114_CLK_PLL_C, .present = true },
790 [tegra_clk_pll_c_out1] = { .dt_id = TEGRA114_CLK_PLL_C_OUT1, .present = true },
791 [tegra_clk_pll_c2] = { .dt_id = TEGRA114_CLK_PLL_C2, .present = true },
792 [tegra_clk_pll_c3] = { .dt_id = TEGRA114_CLK_PLL_C3, .present = true },
793 [tegra_clk_pll_m] = { .dt_id = TEGRA114_CLK_PLL_M, .present = true },
794 [tegra_clk_pll_m_out1] = { .dt_id = TEGRA114_CLK_PLL_M_OUT1, .present = true },
795 [tegra_clk_pll_p] = { .dt_id = TEGRA114_CLK_PLL_P, .present = true },
796 [tegra_clk_pll_p_out1] = { .dt_id = TEGRA114_CLK_PLL_P_OUT1, .present = true },
797 [tegra_clk_pll_p_out2_int] = { .dt_id = TEGRA114_CLK_PLL_P_OUT2, .present = true },
798 [tegra_clk_pll_p_out3] = { .dt_id = TEGRA114_CLK_PLL_P_OUT3, .present = true },
799 [tegra_clk_pll_p_out4] = { .dt_id = TEGRA114_CLK_PLL_P_OUT4, .present = true },
800 [tegra_clk_pll_a] = { .dt_id = TEGRA114_CLK_PLL_A, .present = true },
801 [tegra_clk_pll_a_out0] = { .dt_id = TEGRA114_CLK_PLL_A_OUT0, .present = true },
802 [tegra_clk_pll_d] = { .dt_id = TEGRA114_CLK_PLL_D, .present = true },
803 [tegra_clk_pll_d_out0] = { .dt_id = TEGRA114_CLK_PLL_D_OUT0, .present = true },
804 [tegra_clk_pll_d2] = { .dt_id = TEGRA114_CLK_PLL_D2, .present = true },
805 [tegra_clk_pll_d2_out0] = { .dt_id = TEGRA114_CLK_PLL_D2_OUT0, .present = true },
806 [tegra_clk_pll_u] = { .dt_id = TEGRA114_CLK_PLL_U, .present = true },
807 [tegra_clk_pll_u_480m] = { .dt_id = TEGRA114_CLK_PLL_U_480M, .present = true },
808 [tegra_clk_pll_u_60m] = { .dt_id = TEGRA114_CLK_PLL_U_60M, .present = true },
809 [tegra_clk_pll_u_48m] = { .dt_id = TEGRA114_CLK_PLL_U_48M, .present = true },
810 [tegra_clk_pll_u_12m] = { .dt_id = TEGRA114_CLK_PLL_U_12M, .present = true },
811 [tegra_clk_pll_x] = { .dt_id = TEGRA114_CLK_PLL_X, .present = true },
812 [tegra_clk_pll_x_out0] = { .dt_id = TEGRA114_CLK_PLL_X_OUT0, .present = true },
813 [tegra_clk_pll_re_vco] = { .dt_id = TEGRA114_CLK_PLL_RE_VCO, .present = true },
814 [tegra_clk_pll_re_out] = { .dt_id = TEGRA114_CLK_PLL_RE_OUT, .present = true },
815 [tegra_clk_pll_e_out0] = { .dt_id = TEGRA114_CLK_PLL_E_OUT0, .present = true },
816 [tegra_clk_spdif_in_sync] = { .dt_id = TEGRA114_CLK_SPDIF_IN_SYNC, .present = true },
817 [tegra_clk_i2s0_sync] = { .dt_id = TEGRA114_CLK_I2S0_SYNC, .present = true },
818 [tegra_clk_i2s1_sync] = { .dt_id = TEGRA114_CLK_I2S1_SYNC, .present = true },
819 [tegra_clk_i2s2_sync] = { .dt_id = TEGRA114_CLK_I2S2_SYNC, .present = true },
820 [tegra_clk_i2s3_sync] = { .dt_id = TEGRA114_CLK_I2S3_SYNC, .present = true },
821 [tegra_clk_i2s4_sync] = { .dt_id = TEGRA114_CLK_I2S4_SYNC, .present = true },
822 [tegra_clk_vimclk_sync] = { .dt_id = TEGRA114_CLK_VIMCLK_SYNC, .present = true },
823 [tegra_clk_audio0] = { .dt_id = TEGRA114_CLK_AUDIO0, .present = true },
824 [tegra_clk_audio1] = { .dt_id = TEGRA114_CLK_AUDIO1, .present = true },
825 [tegra_clk_audio2] = { .dt_id = TEGRA114_CLK_AUDIO2, .present = true },
826 [tegra_clk_audio3] = { .dt_id = TEGRA114_CLK_AUDIO3, .present = true },
827 [tegra_clk_audio4] = { .dt_id = TEGRA114_CLK_AUDIO4, .present = true },
828 [tegra_clk_spdif] = { .dt_id = TEGRA114_CLK_SPDIF, .present = true },
829 [tegra_clk_clk_out_1] = { .dt_id = TEGRA114_CLK_CLK_OUT_1, .present = true },
830 [tegra_clk_clk_out_2] = { .dt_id = TEGRA114_CLK_CLK_OUT_2, .present = true },
831 [tegra_clk_clk_out_3] = { .dt_id = TEGRA114_CLK_CLK_OUT_3, .present = true },
832 [tegra_clk_blink] = { .dt_id = TEGRA114_CLK_BLINK, .present = true },
833 [tegra_clk_xusb_host_src] = { .dt_id = TEGRA114_CLK_XUSB_HOST_SRC, .present = true },
834 [tegra_clk_xusb_falcon_src] = { .dt_id = TEGRA114_CLK_XUSB_FALCON_SRC, .present = true },
835 [tegra_clk_xusb_fs_src] = { .dt_id = TEGRA114_CLK_XUSB_FS_SRC, .present = true },
836 [tegra_clk_xusb_ss_src] = { .dt_id = TEGRA114_CLK_XUSB_SS_SRC, .present = true },
837 [tegra_clk_xusb_dev_src] = { .dt_id = TEGRA114_CLK_XUSB_DEV_SRC, .present = true },
838 [tegra_clk_xusb_dev] = { .dt_id = TEGRA114_CLK_XUSB_DEV, .present = true },
839 [tegra_clk_xusb_hs_src] = { .dt_id = TEGRA114_CLK_XUSB_HS_SRC, .present = true },
840 [tegra_clk_sclk] = { .dt_id = TEGRA114_CLK_SCLK, .present = true },
841 [tegra_clk_hclk] = { .dt_id = TEGRA114_CLK_HCLK, .present = true },
842 [tegra_clk_pclk] = { .dt_id = TEGRA114_CLK_PCLK, .present = true },
843 [tegra_clk_cclk_g] = { .dt_id = TEGRA114_CLK_CCLK_G, .present = true },
844 [tegra_clk_cclk_lp] = { .dt_id = TEGRA114_CLK_CCLK_LP, .present = true },
845 [tegra_clk_dfll_ref] = { .dt_id = TEGRA114_CLK_DFLL_REF, .present = true },
846 [tegra_clk_dfll_soc] = { .dt_id = TEGRA114_CLK_DFLL_SOC, .present = true },
847 [tegra_clk_audio0_mux] = { .dt_id = TEGRA114_CLK_AUDIO0_MUX, .present = true },
848 [tegra_clk_audio1_mux] = { .dt_id = TEGRA114_CLK_AUDIO1_MUX, .present = true },
849 [tegra_clk_audio2_mux] = { .dt_id = TEGRA114_CLK_AUDIO2_MUX, .present = true },
850 [tegra_clk_audio3_mux] = { .dt_id = TEGRA114_CLK_AUDIO3_MUX, .present = true },
851 [tegra_clk_audio4_mux] = { .dt_id = TEGRA114_CLK_AUDIO4_MUX, .present = true },
852 [tegra_clk_spdif_mux] = { .dt_id = TEGRA114_CLK_SPDIF_MUX, .present = true },
853 [tegra_clk_clk_out_1_mux] = { .dt_id = TEGRA114_CLK_CLK_OUT_1_MUX, .present = true },
854 [tegra_clk_clk_out_2_mux] = { .dt_id = TEGRA114_CLK_CLK_OUT_2_MUX, .present = true },
855 [tegra_clk_clk_out_3_mux] = { .dt_id = TEGRA114_CLK_CLK_OUT_3_MUX, .present = true },
856 [tegra_clk_dsia_mux] = { .dt_id = TEGRA114_CLK_DSIA_MUX, .present = true },
857 [tegra_clk_dsib_mux] = { .dt_id = TEGRA114_CLK_DSIB_MUX, .present = true },
858};
859
860static struct tegra_devclk devclks[] __initdata = {
861 { .con_id = "clk_m", .dt_id = TEGRA114_CLK_CLK_M },
862 { .con_id = "pll_ref", .dt_id = TEGRA114_CLK_PLL_REF },
863 { .con_id = "clk_32k", .dt_id = TEGRA114_CLK_CLK_32K },
864 { .con_id = "clk_m_div2", .dt_id = TEGRA114_CLK_CLK_M_DIV2 },
865 { .con_id = "clk_m_div4", .dt_id = TEGRA114_CLK_CLK_M_DIV4 },
866 { .con_id = "pll_c", .dt_id = TEGRA114_CLK_PLL_C },
867 { .con_id = "pll_c_out1", .dt_id = TEGRA114_CLK_PLL_C_OUT1 },
868 { .con_id = "pll_c2", .dt_id = TEGRA114_CLK_PLL_C2 },
869 { .con_id = "pll_c3", .dt_id = TEGRA114_CLK_PLL_C3 },
870 { .con_id = "pll_p", .dt_id = TEGRA114_CLK_PLL_P },
871 { .con_id = "pll_p_out1", .dt_id = TEGRA114_CLK_PLL_P_OUT1 },
872 { .con_id = "pll_p_out2", .dt_id = TEGRA114_CLK_PLL_P_OUT2 },
873 { .con_id = "pll_p_out3", .dt_id = TEGRA114_CLK_PLL_P_OUT3 },
874 { .con_id = "pll_p_out4", .dt_id = TEGRA114_CLK_PLL_P_OUT4 },
875 { .con_id = "pll_m", .dt_id = TEGRA114_CLK_PLL_M },
876 { .con_id = "pll_m_out1", .dt_id = TEGRA114_CLK_PLL_M_OUT1 },
877 { .con_id = "pll_x", .dt_id = TEGRA114_CLK_PLL_X },
878 { .con_id = "pll_x_out0", .dt_id = TEGRA114_CLK_PLL_X_OUT0 },
879 { .con_id = "pll_u", .dt_id = TEGRA114_CLK_PLL_U },
880 { .con_id = "pll_u_480M", .dt_id = TEGRA114_CLK_PLL_U_480M },
881 { .con_id = "pll_u_60M", .dt_id = TEGRA114_CLK_PLL_U_60M },
882 { .con_id = "pll_u_48M", .dt_id = TEGRA114_CLK_PLL_U_48M },
883 { .con_id = "pll_u_12M", .dt_id = TEGRA114_CLK_PLL_U_12M },
884 { .con_id = "pll_d", .dt_id = TEGRA114_CLK_PLL_D },
885 { .con_id = "pll_d_out0", .dt_id = TEGRA114_CLK_PLL_D_OUT0 },
886 { .con_id = "pll_d2", .dt_id = TEGRA114_CLK_PLL_D2 },
887 { .con_id = "pll_d2_out0", .dt_id = TEGRA114_CLK_PLL_D2_OUT0 },
888 { .con_id = "pll_a", .dt_id = TEGRA114_CLK_PLL_A },
889 { .con_id = "pll_a_out0", .dt_id = TEGRA114_CLK_PLL_A_OUT0 },
890 { .con_id = "pll_re_vco", .dt_id = TEGRA114_CLK_PLL_RE_VCO },
891 { .con_id = "pll_re_out", .dt_id = TEGRA114_CLK_PLL_RE_OUT },
892 { .con_id = "pll_e_out0", .dt_id = TEGRA114_CLK_PLL_E_OUT0 },
893 { .con_id = "spdif_in_sync", .dt_id = TEGRA114_CLK_SPDIF_IN_SYNC },
894 { .con_id = "i2s0_sync", .dt_id = TEGRA114_CLK_I2S0_SYNC },
895 { .con_id = "i2s1_sync", .dt_id = TEGRA114_CLK_I2S1_SYNC },
896 { .con_id = "i2s2_sync", .dt_id = TEGRA114_CLK_I2S2_SYNC },
897 { .con_id = "i2s3_sync", .dt_id = TEGRA114_CLK_I2S3_SYNC },
898 { .con_id = "i2s4_sync", .dt_id = TEGRA114_CLK_I2S4_SYNC },
899 { .con_id = "vimclk_sync", .dt_id = TEGRA114_CLK_VIMCLK_SYNC },
900 { .con_id = "audio0", .dt_id = TEGRA114_CLK_AUDIO0 },
901 { .con_id = "audio1", .dt_id = TEGRA114_CLK_AUDIO1 },
902 { .con_id = "audio2", .dt_id = TEGRA114_CLK_AUDIO2 },
903 { .con_id = "audio3", .dt_id = TEGRA114_CLK_AUDIO3 },
904 { .con_id = "audio4", .dt_id = TEGRA114_CLK_AUDIO4 },
905 { .con_id = "spdif", .dt_id = TEGRA114_CLK_SPDIF },
906 { .con_id = "audio0_2x", .dt_id = TEGRA114_CLK_AUDIO0_2X },
907 { .con_id = "audio1_2x", .dt_id = TEGRA114_CLK_AUDIO1_2X },
908 { .con_id = "audio2_2x", .dt_id = TEGRA114_CLK_AUDIO2_2X },
909 { .con_id = "audio3_2x", .dt_id = TEGRA114_CLK_AUDIO3_2X },
910 { .con_id = "audio4_2x", .dt_id = TEGRA114_CLK_AUDIO4_2X },
911 { .con_id = "spdif_2x", .dt_id = TEGRA114_CLK_SPDIF_2X },
912 { .con_id = "extern1", .dev_id = "clk_out_1", .dt_id = TEGRA114_CLK_EXTERN1 },
913 { .con_id = "extern2", .dev_id = "clk_out_2", .dt_id = TEGRA114_CLK_EXTERN2 },
914 { .con_id = "extern3", .dev_id = "clk_out_3", .dt_id = TEGRA114_CLK_EXTERN3 },
915 { .con_id = "blink", .dt_id = TEGRA114_CLK_BLINK },
916 { .con_id = "cclk_g", .dt_id = TEGRA114_CLK_CCLK_G },
917 { .con_id = "cclk_lp", .dt_id = TEGRA114_CLK_CCLK_LP },
918 { .con_id = "sclk", .dt_id = TEGRA114_CLK_SCLK },
919 { .con_id = "hclk", .dt_id = TEGRA114_CLK_HCLK },
920 { .con_id = "pclk", .dt_id = TEGRA114_CLK_PCLK },
921 { .con_id = "fuse", .dt_id = TEGRA114_CLK_FUSE },
922 { .dev_id = "rtc-tegra", .dt_id = TEGRA114_CLK_RTC },
923 { .dev_id = "timer", .dt_id = TEGRA114_CLK_TIMER },
924};
925
926static struct clk **clks;
1069 927
1070static unsigned long osc_freq; 928static unsigned long osc_freq;
1071static unsigned long pll_ref_freq; 929static unsigned long pll_ref_freq;
@@ -1086,16 +944,14 @@ static int __init tegra114_osc_clk_init(void __iomem *clk_base)
1086 /* clk_m */ 944 /* clk_m */
1087 clk = clk_register_fixed_rate(NULL, "clk_m", NULL, CLK_IS_ROOT, 945 clk = clk_register_fixed_rate(NULL, "clk_m", NULL, CLK_IS_ROOT,
1088 osc_freq); 946 osc_freq);
1089 clk_register_clkdev(clk, "clk_m", NULL); 947 clks[TEGRA114_CLK_CLK_M] = clk;
1090 clks[clk_m] = clk;
1091 948
1092 /* pll_ref */ 949 /* pll_ref */
1093 val = (val >> OSC_CTRL_PLL_REF_DIV_SHIFT) & 3; 950 val = (val >> OSC_CTRL_PLL_REF_DIV_SHIFT) & 3;
1094 pll_ref_div = 1 << val; 951 pll_ref_div = 1 << val;
1095 clk = clk_register_fixed_factor(NULL, "pll_ref", "clk_m", 952 clk = clk_register_fixed_factor(NULL, "pll_ref", "clk_m",
1096 CLK_SET_RATE_PARENT, 1, pll_ref_div); 953 CLK_SET_RATE_PARENT, 1, pll_ref_div);
1097 clk_register_clkdev(clk, "pll_ref", NULL); 954 clks[TEGRA114_CLK_PLL_REF] = clk;
1098 clks[pll_ref] = clk;
1099 955
1100 pll_ref_freq = osc_freq / pll_ref_div; 956 pll_ref_freq = osc_freq / pll_ref_div;
1101 957
@@ -1109,20 +965,17 @@ static void __init tegra114_fixed_clk_init(void __iomem *clk_base)
1109 /* clk_32k */ 965 /* clk_32k */
1110 clk = clk_register_fixed_rate(NULL, "clk_32k", NULL, CLK_IS_ROOT, 966 clk = clk_register_fixed_rate(NULL, "clk_32k", NULL, CLK_IS_ROOT,
1111 32768); 967 32768);
1112 clk_register_clkdev(clk, "clk_32k", NULL); 968 clks[TEGRA114_CLK_CLK_32K] = clk;
1113 clks[clk_32k] = clk;
1114 969
1115 /* clk_m_div2 */ 970 /* clk_m_div2 */
1116 clk = clk_register_fixed_factor(NULL, "clk_m_div2", "clk_m", 971 clk = clk_register_fixed_factor(NULL, "clk_m_div2", "clk_m",
1117 CLK_SET_RATE_PARENT, 1, 2); 972 CLK_SET_RATE_PARENT, 1, 2);
1118 clk_register_clkdev(clk, "clk_m_div2", NULL); 973 clks[TEGRA114_CLK_CLK_M_DIV2] = clk;
1119 clks[clk_m_div2] = clk;
1120 974
1121 /* clk_m_div4 */ 975 /* clk_m_div4 */
1122 clk = clk_register_fixed_factor(NULL, "clk_m_div4", "clk_m", 976 clk = clk_register_fixed_factor(NULL, "clk_m_div4", "clk_m",
1123 CLK_SET_RATE_PARENT, 1, 4); 977 CLK_SET_RATE_PARENT, 1, 4);
1124 clk_register_clkdev(clk, "clk_m_div4", NULL); 978 clks[TEGRA114_CLK_CLK_M_DIV4] = clk;
1125 clks[clk_m_div4] = clk;
1126 979
1127} 980}
1128 981
@@ -1208,63 +1061,6 @@ static __init void tegra114_utmi_param_configure(void __iomem *clk_base)
1208 writel_relaxed(reg, clk_base + UTMIPLL_HW_PWRDN_CFG0); 1061 writel_relaxed(reg, clk_base + UTMIPLL_HW_PWRDN_CFG0);
1209} 1062}
1210 1063
1211static void __init _clip_vco_min(struct tegra_clk_pll_params *pll_params)
1212{
1213 pll_params->vco_min =
1214 DIV_ROUND_UP(pll_params->vco_min, pll_ref_freq) * pll_ref_freq;
1215}
1216
1217static int __init _setup_dynamic_ramp(struct tegra_clk_pll_params *pll_params,
1218 void __iomem *clk_base)
1219{
1220 u32 val;
1221 u32 step_a, step_b;
1222
1223 switch (pll_ref_freq) {
1224 case 12000000:
1225 case 13000000:
1226 case 26000000:
1227 step_a = 0x2B;
1228 step_b = 0x0B;
1229 break;
1230 case 16800000:
1231 step_a = 0x1A;
1232 step_b = 0x09;
1233 break;
1234 case 19200000:
1235 step_a = 0x12;
1236 step_b = 0x08;
1237 break;
1238 default:
1239 pr_err("%s: Unexpected reference rate %lu\n",
1240 __func__, pll_ref_freq);
1241 WARN_ON(1);
1242 return -EINVAL;
1243 }
1244
1245 val = step_a << pll_params->stepa_shift;
1246 val |= step_b << pll_params->stepb_shift;
1247 writel_relaxed(val, clk_base + pll_params->dyn_ramp_reg);
1248
1249 return 0;
1250}
1251
1252static void __init _init_iddq(struct tegra_clk_pll_params *pll_params,
1253 void __iomem *clk_base)
1254{
1255 u32 val, val_iddq;
1256
1257 val = readl_relaxed(clk_base + pll_params->base_reg);
1258 val_iddq = readl_relaxed(clk_base + pll_params->iddq_reg);
1259
1260 if (val & BIT(30))
1261 WARN_ON(val_iddq & BIT(pll_params->iddq_bit_idx));
1262 else {
1263 val_iddq |= BIT(pll_params->iddq_bit_idx);
1264 writel_relaxed(val_iddq, clk_base + pll_params->iddq_reg);
1265 }
1266}
1267
1268static void __init tegra114_pll_init(void __iomem *clk_base, 1064static void __init tegra114_pll_init(void __iomem *clk_base,
1269 void __iomem *pmc) 1065 void __iomem *pmc)
1270{ 1066{
@@ -1272,104 +1068,34 @@ static void __init tegra114_pll_init(void __iomem *clk_base,
1272 struct clk *clk; 1068 struct clk *clk;
1273 1069
1274 /* PLLC */ 1070 /* PLLC */
1275 _clip_vco_min(&pll_c_params); 1071 clk = tegra_clk_register_pllxc("pll_c", "pll_ref", clk_base,
1276 if (_setup_dynamic_ramp(&pll_c_params, clk_base) >= 0) { 1072 pmc, 0, &pll_c_params, NULL);
1277 _init_iddq(&pll_c_params, clk_base); 1073 clks[TEGRA114_CLK_PLL_C] = clk;
1278 clk = tegra_clk_register_pllxc("pll_c", "pll_ref", clk_base, 1074
1279 pmc, 0, 0, &pll_c_params, TEGRA_PLL_USE_LOCK, 1075 /* PLLC_OUT1 */
1280 pll_c_freq_table, NULL); 1076 clk = tegra_clk_register_divider("pll_c_out1_div", "pll_c",
1281 clk_register_clkdev(clk, "pll_c", NULL); 1077 clk_base + PLLC_OUT, 0, TEGRA_DIVIDER_ROUND_UP,
1282 clks[pll_c] = clk; 1078 8, 8, 1, NULL);
1283 1079 clk = tegra_clk_register_pll_out("pll_c_out1", "pll_c_out1_div",
1284 /* PLLC_OUT1 */ 1080 clk_base + PLLC_OUT, 1, 0,
1285 clk = tegra_clk_register_divider("pll_c_out1_div", "pll_c", 1081 CLK_SET_RATE_PARENT, 0, NULL);
1286 clk_base + PLLC_OUT, 0, TEGRA_DIVIDER_ROUND_UP, 1082 clks[TEGRA114_CLK_PLL_C_OUT1] = clk;
1287 8, 8, 1, NULL);
1288 clk = tegra_clk_register_pll_out("pll_c_out1", "pll_c_out1_div",
1289 clk_base + PLLC_OUT, 1, 0,
1290 CLK_SET_RATE_PARENT, 0, NULL);
1291 clk_register_clkdev(clk, "pll_c_out1", NULL);
1292 clks[pll_c_out1] = clk;
1293 }
1294 1083
1295 /* PLLC2 */ 1084 /* PLLC2 */
1296 _clip_vco_min(&pll_c2_params); 1085 clk = tegra_clk_register_pllc("pll_c2", "pll_ref", clk_base, pmc, 0,
1297 clk = tegra_clk_register_pllc("pll_c2", "pll_ref", clk_base, pmc, 0, 0, 1086 &pll_c2_params, NULL);
1298 &pll_c2_params, TEGRA_PLL_USE_LOCK, 1087 clks[TEGRA114_CLK_PLL_C2] = clk;
1299 pll_cx_freq_table, NULL);
1300 clk_register_clkdev(clk, "pll_c2", NULL);
1301 clks[pll_c2] = clk;
1302 1088
1303 /* PLLC3 */ 1089 /* PLLC3 */
1304 _clip_vco_min(&pll_c3_params); 1090 clk = tegra_clk_register_pllc("pll_c3", "pll_ref", clk_base, pmc, 0,
1305 clk = tegra_clk_register_pllc("pll_c3", "pll_ref", clk_base, pmc, 0, 0, 1091 &pll_c3_params, NULL);
1306 &pll_c3_params, TEGRA_PLL_USE_LOCK, 1092 clks[TEGRA114_CLK_PLL_C3] = clk;
1307 pll_cx_freq_table, NULL);
1308 clk_register_clkdev(clk, "pll_c3", NULL);
1309 clks[pll_c3] = clk;
1310
1311 /* PLLP */
1312 clk = tegra_clk_register_pll("pll_p", "pll_ref", clk_base, pmc, 0,
1313 408000000, &pll_p_params,
1314 TEGRA_PLL_FIXED | TEGRA_PLL_USE_LOCK,
1315 pll_p_freq_table, NULL);
1316 clk_register_clkdev(clk, "pll_p", NULL);
1317 clks[pll_p] = clk;
1318
1319 /* PLLP_OUT1 */
1320 clk = tegra_clk_register_divider("pll_p_out1_div", "pll_p",
1321 clk_base + PLLP_OUTA, 0, TEGRA_DIVIDER_FIXED |
1322 TEGRA_DIVIDER_ROUND_UP, 8, 8, 1, &pll_div_lock);
1323 clk = tegra_clk_register_pll_out("pll_p_out1", "pll_p_out1_div",
1324 clk_base + PLLP_OUTA, 1, 0,
1325 CLK_IGNORE_UNUSED | CLK_SET_RATE_PARENT, 0,
1326 &pll_div_lock);
1327 clk_register_clkdev(clk, "pll_p_out1", NULL);
1328 clks[pll_p_out1] = clk;
1329
1330 /* PLLP_OUT2 */
1331 clk = tegra_clk_register_divider("pll_p_out2_div", "pll_p",
1332 clk_base + PLLP_OUTA, 0, TEGRA_DIVIDER_FIXED |
1333 TEGRA_DIVIDER_ROUND_UP | TEGRA_DIVIDER_INT, 24,
1334 8, 1, &pll_div_lock);
1335 clk = tegra_clk_register_pll_out("pll_p_out2", "pll_p_out2_div",
1336 clk_base + PLLP_OUTA, 17, 16,
1337 CLK_IGNORE_UNUSED | CLK_SET_RATE_PARENT, 0,
1338 &pll_div_lock);
1339 clk_register_clkdev(clk, "pll_p_out2", NULL);
1340 clks[pll_p_out2] = clk;
1341
1342 /* PLLP_OUT3 */
1343 clk = tegra_clk_register_divider("pll_p_out3_div", "pll_p",
1344 clk_base + PLLP_OUTB, 0, TEGRA_DIVIDER_FIXED |
1345 TEGRA_DIVIDER_ROUND_UP, 8, 8, 1, &pll_div_lock);
1346 clk = tegra_clk_register_pll_out("pll_p_out3", "pll_p_out3_div",
1347 clk_base + PLLP_OUTB, 1, 0,
1348 CLK_IGNORE_UNUSED | CLK_SET_RATE_PARENT, 0,
1349 &pll_div_lock);
1350 clk_register_clkdev(clk, "pll_p_out3", NULL);
1351 clks[pll_p_out3] = clk;
1352
1353 /* PLLP_OUT4 */
1354 clk = tegra_clk_register_divider("pll_p_out4_div", "pll_p",
1355 clk_base + PLLP_OUTB, 0, TEGRA_DIVIDER_FIXED |
1356 TEGRA_DIVIDER_ROUND_UP, 24, 8, 1,
1357 &pll_div_lock);
1358 clk = tegra_clk_register_pll_out("pll_p_out4", "pll_p_out4_div",
1359 clk_base + PLLP_OUTB, 17, 16,
1360 CLK_IGNORE_UNUSED | CLK_SET_RATE_PARENT, 0,
1361 &pll_div_lock);
1362 clk_register_clkdev(clk, "pll_p_out4", NULL);
1363 clks[pll_p_out4] = clk;
1364 1093
1365 /* PLLM */ 1094 /* PLLM */
1366 _clip_vco_min(&pll_m_params);
1367 clk = tegra_clk_register_pllm("pll_m", "pll_ref", clk_base, pmc, 1095 clk = tegra_clk_register_pllm("pll_m", "pll_ref", clk_base, pmc,
1368 CLK_IGNORE_UNUSED | CLK_SET_RATE_GATE, 0, 1096 CLK_IGNORE_UNUSED | CLK_SET_RATE_GATE,
1369 &pll_m_params, TEGRA_PLL_USE_LOCK, 1097 &pll_m_params, NULL);
1370 pll_m_freq_table, NULL); 1098 clks[TEGRA114_CLK_PLL_M] = clk;
1371 clk_register_clkdev(clk, "pll_m", NULL);
1372 clks[pll_m] = clk;
1373 1099
1374 /* PLLM_OUT1 */ 1100 /* PLLM_OUT1 */
1375 clk = tegra_clk_register_divider("pll_m_out1_div", "pll_m", 1101 clk = tegra_clk_register_divider("pll_m_out1_div", "pll_m",
@@ -1378,41 +1104,20 @@ static void __init tegra114_pll_init(void __iomem *clk_base,
1378 clk = tegra_clk_register_pll_out("pll_m_out1", "pll_m_out1_div", 1104 clk = tegra_clk_register_pll_out("pll_m_out1", "pll_m_out1_div",
1379 clk_base + PLLM_OUT, 1, 0, CLK_IGNORE_UNUSED | 1105 clk_base + PLLM_OUT, 1, 0, CLK_IGNORE_UNUSED |
1380 CLK_SET_RATE_PARENT, 0, NULL); 1106 CLK_SET_RATE_PARENT, 0, NULL);
1381 clk_register_clkdev(clk, "pll_m_out1", NULL); 1107 clks[TEGRA114_CLK_PLL_M_OUT1] = clk;
1382 clks[pll_m_out1] = clk;
1383 1108
1384 /* PLLM_UD */ 1109 /* PLLM_UD */
1385 clk = clk_register_fixed_factor(NULL, "pll_m_ud", "pll_m", 1110 clk = clk_register_fixed_factor(NULL, "pll_m_ud", "pll_m",
1386 CLK_SET_RATE_PARENT, 1, 1); 1111 CLK_SET_RATE_PARENT, 1, 1);
1387 1112
1388 /* PLLX */
1389 _clip_vco_min(&pll_x_params);
1390 if (_setup_dynamic_ramp(&pll_x_params, clk_base) >= 0) {
1391 _init_iddq(&pll_x_params, clk_base);
1392 clk = tegra_clk_register_pllxc("pll_x", "pll_ref", clk_base,
1393 pmc, CLK_IGNORE_UNUSED, 0, &pll_x_params,
1394 TEGRA_PLL_USE_LOCK, pll_x_freq_table, NULL);
1395 clk_register_clkdev(clk, "pll_x", NULL);
1396 clks[pll_x] = clk;
1397 }
1398
1399 /* PLLX_OUT0 */
1400 clk = clk_register_fixed_factor(NULL, "pll_x_out0", "pll_x",
1401 CLK_SET_RATE_PARENT, 1, 2);
1402 clk_register_clkdev(clk, "pll_x_out0", NULL);
1403 clks[pll_x_out0] = clk;
1404
1405 /* PLLU */ 1113 /* PLLU */
1406 val = readl(clk_base + pll_u_params.base_reg); 1114 val = readl(clk_base + pll_u_params.base_reg);
1407 val &= ~BIT(24); /* disable PLLU_OVERRIDE */ 1115 val &= ~BIT(24); /* disable PLLU_OVERRIDE */
1408 writel(val, clk_base + pll_u_params.base_reg); 1116 writel(val, clk_base + pll_u_params.base_reg);
1409 1117
1410 clk = tegra_clk_register_pll("pll_u", "pll_ref", clk_base, pmc, 0, 1118 clk = tegra_clk_register_pll("pll_u", "pll_ref", clk_base, pmc, 0,
1411 0, &pll_u_params, TEGRA_PLLU | 1119 &pll_u_params, &pll_u_lock);
1412 TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON | 1120 clks[TEGRA114_CLK_PLL_U] = clk;
1413 TEGRA_PLL_USE_LOCK, pll_u_freq_table, &pll_u_lock);
1414 clk_register_clkdev(clk, "pll_u", NULL);
1415 clks[pll_u] = clk;
1416 1121
1417 tegra114_utmi_param_configure(clk_base); 1122 tegra114_utmi_param_configure(clk_base);
1418 1123
@@ -1420,731 +1125,97 @@ static void __init tegra114_pll_init(void __iomem *clk_base,
1420 clk = clk_register_gate(NULL, "pll_u_480M", "pll_u", 1125 clk = clk_register_gate(NULL, "pll_u_480M", "pll_u",
1421 CLK_SET_RATE_PARENT, clk_base + PLLU_BASE, 1126 CLK_SET_RATE_PARENT, clk_base + PLLU_BASE,
1422 22, 0, &pll_u_lock); 1127 22, 0, &pll_u_lock);
1423 clk_register_clkdev(clk, "pll_u_480M", NULL); 1128 clks[TEGRA114_CLK_PLL_U_480M] = clk;
1424 clks[pll_u_480M] = clk;
1425 1129
1426 /* PLLU_60M */ 1130 /* PLLU_60M */
1427 clk = clk_register_fixed_factor(NULL, "pll_u_60M", "pll_u", 1131 clk = clk_register_fixed_factor(NULL, "pll_u_60M", "pll_u",
1428 CLK_SET_RATE_PARENT, 1, 8); 1132 CLK_SET_RATE_PARENT, 1, 8);
1429 clk_register_clkdev(clk, "pll_u_60M", NULL); 1133 clks[TEGRA114_CLK_PLL_U_60M] = clk;
1430 clks[pll_u_60M] = clk;
1431 1134
1432 /* PLLU_48M */ 1135 /* PLLU_48M */
1433 clk = clk_register_fixed_factor(NULL, "pll_u_48M", "pll_u", 1136 clk = clk_register_fixed_factor(NULL, "pll_u_48M", "pll_u",
1434 CLK_SET_RATE_PARENT, 1, 10); 1137 CLK_SET_RATE_PARENT, 1, 10);
1435 clk_register_clkdev(clk, "pll_u_48M", NULL); 1138 clks[TEGRA114_CLK_PLL_U_48M] = clk;
1436 clks[pll_u_48M] = clk;
1437 1139
1438 /* PLLU_12M */ 1140 /* PLLU_12M */
1439 clk = clk_register_fixed_factor(NULL, "pll_u_12M", "pll_u", 1141 clk = clk_register_fixed_factor(NULL, "pll_u_12M", "pll_u",
1440 CLK_SET_RATE_PARENT, 1, 40); 1142 CLK_SET_RATE_PARENT, 1, 40);
1441 clk_register_clkdev(clk, "pll_u_12M", NULL); 1143 clks[TEGRA114_CLK_PLL_U_12M] = clk;
1442 clks[pll_u_12M] = clk;
1443 1144
1444 /* PLLD */ 1145 /* PLLD */
1445 clk = tegra_clk_register_pll("pll_d", "pll_ref", clk_base, pmc, 0, 1146 clk = tegra_clk_register_pll("pll_d", "pll_ref", clk_base, pmc, 0,
1446 0, &pll_d_params, 1147 &pll_d_params, &pll_d_lock);
1447 TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON | 1148 clks[TEGRA114_CLK_PLL_D] = clk;
1448 TEGRA_PLL_USE_LOCK, pll_d_freq_table, &pll_d_lock);
1449 clk_register_clkdev(clk, "pll_d", NULL);
1450 clks[pll_d] = clk;
1451 1149
1452 /* PLLD_OUT0 */ 1150 /* PLLD_OUT0 */
1453 clk = clk_register_fixed_factor(NULL, "pll_d_out0", "pll_d", 1151 clk = clk_register_fixed_factor(NULL, "pll_d_out0", "pll_d",
1454 CLK_SET_RATE_PARENT, 1, 2); 1152 CLK_SET_RATE_PARENT, 1, 2);
1455 clk_register_clkdev(clk, "pll_d_out0", NULL); 1153 clks[TEGRA114_CLK_PLL_D_OUT0] = clk;
1456 clks[pll_d_out0] = clk;
1457 1154
1458 /* PLLD2 */ 1155 /* PLLD2 */
1459 clk = tegra_clk_register_pll("pll_d2", "pll_ref", clk_base, pmc, 0, 1156 clk = tegra_clk_register_pll("pll_d2", "pll_ref", clk_base, pmc, 0,
1460 0, &pll_d2_params, 1157 &pll_d2_params, &pll_d2_lock);
1461 TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON | 1158 clks[TEGRA114_CLK_PLL_D2] = clk;
1462 TEGRA_PLL_USE_LOCK, pll_d_freq_table, &pll_d2_lock);
1463 clk_register_clkdev(clk, "pll_d2", NULL);
1464 clks[pll_d2] = clk;
1465 1159
1466 /* PLLD2_OUT0 */ 1160 /* PLLD2_OUT0 */
1467 clk = clk_register_fixed_factor(NULL, "pll_d2_out0", "pll_d2", 1161 clk = clk_register_fixed_factor(NULL, "pll_d2_out0", "pll_d2",
1468 CLK_SET_RATE_PARENT, 1, 2); 1162 CLK_SET_RATE_PARENT, 1, 2);
1469 clk_register_clkdev(clk, "pll_d2_out0", NULL); 1163 clks[TEGRA114_CLK_PLL_D2_OUT0] = clk;
1470 clks[pll_d2_out0] = clk;
1471
1472 /* PLLA */
1473 clk = tegra_clk_register_pll("pll_a", "pll_p_out1", clk_base, pmc, 0,
1474 0, &pll_a_params, TEGRA_PLL_HAS_CPCON |
1475 TEGRA_PLL_USE_LOCK, pll_a_freq_table, NULL);
1476 clk_register_clkdev(clk, "pll_a", NULL);
1477 clks[pll_a] = clk;
1478
1479 /* PLLA_OUT0 */
1480 clk = tegra_clk_register_divider("pll_a_out0_div", "pll_a",
1481 clk_base + PLLA_OUT, 0, TEGRA_DIVIDER_ROUND_UP,
1482 8, 8, 1, NULL);
1483 clk = tegra_clk_register_pll_out("pll_a_out0", "pll_a_out0_div",
1484 clk_base + PLLA_OUT, 1, 0, CLK_IGNORE_UNUSED |
1485 CLK_SET_RATE_PARENT, 0, NULL);
1486 clk_register_clkdev(clk, "pll_a_out0", NULL);
1487 clks[pll_a_out0] = clk;
1488 1164
1489 /* PLLRE */ 1165 /* PLLRE */
1490 _clip_vco_min(&pll_re_vco_params);
1491 clk = tegra_clk_register_pllre("pll_re_vco", "pll_ref", clk_base, pmc, 1166 clk = tegra_clk_register_pllre("pll_re_vco", "pll_ref", clk_base, pmc,
1492 0, 0, &pll_re_vco_params, TEGRA_PLL_USE_LOCK, 1167 0, &pll_re_vco_params, &pll_re_lock, pll_ref_freq);
1493 NULL, &pll_re_lock, pll_ref_freq); 1168 clks[TEGRA114_CLK_PLL_RE_VCO] = clk;
1494 clk_register_clkdev(clk, "pll_re_vco", NULL);
1495 clks[pll_re_vco] = clk;
1496 1169
1497 clk = clk_register_divider_table(NULL, "pll_re_out", "pll_re_vco", 0, 1170 clk = clk_register_divider_table(NULL, "pll_re_out", "pll_re_vco", 0,
1498 clk_base + PLLRE_BASE, 16, 4, 0, 1171 clk_base + PLLRE_BASE, 16, 4, 0,
1499 pll_re_div_table, &pll_re_lock); 1172 pll_re_div_table, &pll_re_lock);
1500 clk_register_clkdev(clk, "pll_re_out", NULL); 1173 clks[TEGRA114_CLK_PLL_RE_OUT] = clk;
1501 clks[pll_re_out] = clk;
1502 1174
1503 /* PLLE */ 1175 /* PLLE */
1504 clk = tegra_clk_register_plle_tegra114("pll_e_out0", "pll_re_vco", 1176 clk = tegra_clk_register_plle_tegra114("pll_e_out0", "pll_ref",
1505 clk_base, 0, 100000000, &pll_e_params, 1177 clk_base, 0, &pll_e_params, NULL);
1506 pll_e_freq_table, NULL); 1178 clks[TEGRA114_CLK_PLL_E_OUT0] = clk;
1507 clk_register_clkdev(clk, "pll_e_out0", NULL);
1508 clks[pll_e_out0] = clk;
1509}
1510
1511static const char *mux_audio_sync_clk[] = { "spdif_in_sync", "i2s0_sync",
1512 "i2s1_sync", "i2s2_sync", "i2s3_sync", "i2s4_sync", "vimclk_sync",
1513};
1514
1515static const char *clk_out1_parents[] = { "clk_m", "clk_m_div2",
1516 "clk_m_div4", "extern1",
1517};
1518
1519static const char *clk_out2_parents[] = { "clk_m", "clk_m_div2",
1520 "clk_m_div4", "extern2",
1521};
1522
1523static const char *clk_out3_parents[] = { "clk_m", "clk_m_div2",
1524 "clk_m_div4", "extern3",
1525};
1526
1527static void __init tegra114_audio_clk_init(void __iomem *clk_base)
1528{
1529 struct clk *clk;
1530
1531 /* spdif_in_sync */
1532 clk = tegra_clk_register_sync_source("spdif_in_sync", 24000000,
1533 24000000);
1534 clk_register_clkdev(clk, "spdif_in_sync", NULL);
1535 clks[spdif_in_sync] = clk;
1536
1537 /* i2s0_sync */
1538 clk = tegra_clk_register_sync_source("i2s0_sync", 24000000, 24000000);
1539 clk_register_clkdev(clk, "i2s0_sync", NULL);
1540 clks[i2s0_sync] = clk;
1541
1542 /* i2s1_sync */
1543 clk = tegra_clk_register_sync_source("i2s1_sync", 24000000, 24000000);
1544 clk_register_clkdev(clk, "i2s1_sync", NULL);
1545 clks[i2s1_sync] = clk;
1546
1547 /* i2s2_sync */
1548 clk = tegra_clk_register_sync_source("i2s2_sync", 24000000, 24000000);
1549 clk_register_clkdev(clk, "i2s2_sync", NULL);
1550 clks[i2s2_sync] = clk;
1551
1552 /* i2s3_sync */
1553 clk = tegra_clk_register_sync_source("i2s3_sync", 24000000, 24000000);
1554 clk_register_clkdev(clk, "i2s3_sync", NULL);
1555 clks[i2s3_sync] = clk;
1556
1557 /* i2s4_sync */
1558 clk = tegra_clk_register_sync_source("i2s4_sync", 24000000, 24000000);
1559 clk_register_clkdev(clk, "i2s4_sync", NULL);
1560 clks[i2s4_sync] = clk;
1561
1562 /* vimclk_sync */
1563 clk = tegra_clk_register_sync_source("vimclk_sync", 24000000, 24000000);
1564 clk_register_clkdev(clk, "vimclk_sync", NULL);
1565 clks[vimclk_sync] = clk;
1566
1567 /* audio0 */
1568 clk = clk_register_mux(NULL, "audio0_mux", mux_audio_sync_clk,
1569 ARRAY_SIZE(mux_audio_sync_clk),
1570 CLK_SET_RATE_NO_REPARENT,
1571 clk_base + AUDIO_SYNC_CLK_I2S0, 0, 3, 0,
1572 NULL);
1573 clks[audio0_mux] = clk;
1574 clk = clk_register_gate(NULL, "audio0", "audio0_mux", 0,
1575 clk_base + AUDIO_SYNC_CLK_I2S0, 4,
1576 CLK_GATE_SET_TO_DISABLE, NULL);
1577 clk_register_clkdev(clk, "audio0", NULL);
1578 clks[audio0] = clk;
1579
1580 /* audio1 */
1581 clk = clk_register_mux(NULL, "audio1_mux", mux_audio_sync_clk,
1582 ARRAY_SIZE(mux_audio_sync_clk),
1583 CLK_SET_RATE_NO_REPARENT,
1584 clk_base + AUDIO_SYNC_CLK_I2S1, 0, 3, 0,
1585 NULL);
1586 clks[audio1_mux] = clk;
1587 clk = clk_register_gate(NULL, "audio1", "audio1_mux", 0,
1588 clk_base + AUDIO_SYNC_CLK_I2S1, 4,
1589 CLK_GATE_SET_TO_DISABLE, NULL);
1590 clk_register_clkdev(clk, "audio1", NULL);
1591 clks[audio1] = clk;
1592
1593 /* audio2 */
1594 clk = clk_register_mux(NULL, "audio2_mux", mux_audio_sync_clk,
1595 ARRAY_SIZE(mux_audio_sync_clk),
1596 CLK_SET_RATE_NO_REPARENT,
1597 clk_base + AUDIO_SYNC_CLK_I2S2, 0, 3, 0,
1598 NULL);
1599 clks[audio2_mux] = clk;
1600 clk = clk_register_gate(NULL, "audio2", "audio2_mux", 0,
1601 clk_base + AUDIO_SYNC_CLK_I2S2, 4,
1602 CLK_GATE_SET_TO_DISABLE, NULL);
1603 clk_register_clkdev(clk, "audio2", NULL);
1604 clks[audio2] = clk;
1605
1606 /* audio3 */
1607 clk = clk_register_mux(NULL, "audio3_mux", mux_audio_sync_clk,
1608 ARRAY_SIZE(mux_audio_sync_clk),
1609 CLK_SET_RATE_NO_REPARENT,
1610 clk_base + AUDIO_SYNC_CLK_I2S3, 0, 3, 0,
1611 NULL);
1612 clks[audio3_mux] = clk;
1613 clk = clk_register_gate(NULL, "audio3", "audio3_mux", 0,
1614 clk_base + AUDIO_SYNC_CLK_I2S3, 4,
1615 CLK_GATE_SET_TO_DISABLE, NULL);
1616 clk_register_clkdev(clk, "audio3", NULL);
1617 clks[audio3] = clk;
1618
1619 /* audio4 */
1620 clk = clk_register_mux(NULL, "audio4_mux", mux_audio_sync_clk,
1621 ARRAY_SIZE(mux_audio_sync_clk),
1622 CLK_SET_RATE_NO_REPARENT,
1623 clk_base + AUDIO_SYNC_CLK_I2S4, 0, 3, 0,
1624 NULL);
1625 clks[audio4_mux] = clk;
1626 clk = clk_register_gate(NULL, "audio4", "audio4_mux", 0,
1627 clk_base + AUDIO_SYNC_CLK_I2S4, 4,
1628 CLK_GATE_SET_TO_DISABLE, NULL);
1629 clk_register_clkdev(clk, "audio4", NULL);
1630 clks[audio4] = clk;
1631
1632 /* spdif */
1633 clk = clk_register_mux(NULL, "spdif_mux", mux_audio_sync_clk,
1634 ARRAY_SIZE(mux_audio_sync_clk),
1635 CLK_SET_RATE_NO_REPARENT,
1636 clk_base + AUDIO_SYNC_CLK_SPDIF, 0, 3, 0,
1637 NULL);
1638 clks[spdif_mux] = clk;
1639 clk = clk_register_gate(NULL, "spdif", "spdif_mux", 0,
1640 clk_base + AUDIO_SYNC_CLK_SPDIF, 4,
1641 CLK_GATE_SET_TO_DISABLE, NULL);
1642 clk_register_clkdev(clk, "spdif", NULL);
1643 clks[spdif] = clk;
1644
1645 /* audio0_2x */
1646 clk = clk_register_fixed_factor(NULL, "audio0_doubler", "audio0",
1647 CLK_SET_RATE_PARENT, 2, 1);
1648 clk = tegra_clk_register_divider("audio0_div", "audio0_doubler",
1649 clk_base + AUDIO_SYNC_DOUBLER, 0, 0, 24, 1,
1650 0, &clk_doubler_lock);
1651 clk = tegra_clk_register_periph_gate("audio0_2x", "audio0_div",
1652 TEGRA_PERIPH_NO_RESET, clk_base,
1653 CLK_SET_RATE_PARENT, 113, &periph_v_regs,
1654 periph_clk_enb_refcnt);
1655 clk_register_clkdev(clk, "audio0_2x", NULL);
1656 clks[audio0_2x] = clk;
1657
1658 /* audio1_2x */
1659 clk = clk_register_fixed_factor(NULL, "audio1_doubler", "audio1",
1660 CLK_SET_RATE_PARENT, 2, 1);
1661 clk = tegra_clk_register_divider("audio1_div", "audio1_doubler",
1662 clk_base + AUDIO_SYNC_DOUBLER, 0, 0, 25, 1,
1663 0, &clk_doubler_lock);
1664 clk = tegra_clk_register_periph_gate("audio1_2x", "audio1_div",
1665 TEGRA_PERIPH_NO_RESET, clk_base,
1666 CLK_SET_RATE_PARENT, 114, &periph_v_regs,
1667 periph_clk_enb_refcnt);
1668 clk_register_clkdev(clk, "audio1_2x", NULL);
1669 clks[audio1_2x] = clk;
1670
1671 /* audio2_2x */
1672 clk = clk_register_fixed_factor(NULL, "audio2_doubler", "audio2",
1673 CLK_SET_RATE_PARENT, 2, 1);
1674 clk = tegra_clk_register_divider("audio2_div", "audio2_doubler",
1675 clk_base + AUDIO_SYNC_DOUBLER, 0, 0, 26, 1,
1676 0, &clk_doubler_lock);
1677 clk = tegra_clk_register_periph_gate("audio2_2x", "audio2_div",
1678 TEGRA_PERIPH_NO_RESET, clk_base,
1679 CLK_SET_RATE_PARENT, 115, &periph_v_regs,
1680 periph_clk_enb_refcnt);
1681 clk_register_clkdev(clk, "audio2_2x", NULL);
1682 clks[audio2_2x] = clk;
1683
1684 /* audio3_2x */
1685 clk = clk_register_fixed_factor(NULL, "audio3_doubler", "audio3",
1686 CLK_SET_RATE_PARENT, 2, 1);
1687 clk = tegra_clk_register_divider("audio3_div", "audio3_doubler",
1688 clk_base + AUDIO_SYNC_DOUBLER, 0, 0, 27, 1,
1689 0, &clk_doubler_lock);
1690 clk = tegra_clk_register_periph_gate("audio3_2x", "audio3_div",
1691 TEGRA_PERIPH_NO_RESET, clk_base,
1692 CLK_SET_RATE_PARENT, 116, &periph_v_regs,
1693 periph_clk_enb_refcnt);
1694 clk_register_clkdev(clk, "audio3_2x", NULL);
1695 clks[audio3_2x] = clk;
1696
1697 /* audio4_2x */
1698 clk = clk_register_fixed_factor(NULL, "audio4_doubler", "audio4",
1699 CLK_SET_RATE_PARENT, 2, 1);
1700 clk = tegra_clk_register_divider("audio4_div", "audio4_doubler",
1701 clk_base + AUDIO_SYNC_DOUBLER, 0, 0, 28, 1,
1702 0, &clk_doubler_lock);
1703 clk = tegra_clk_register_periph_gate("audio4_2x", "audio4_div",
1704 TEGRA_PERIPH_NO_RESET, clk_base,
1705 CLK_SET_RATE_PARENT, 117, &periph_v_regs,
1706 periph_clk_enb_refcnt);
1707 clk_register_clkdev(clk, "audio4_2x", NULL);
1708 clks[audio4_2x] = clk;
1709
1710 /* spdif_2x */
1711 clk = clk_register_fixed_factor(NULL, "spdif_doubler", "spdif",
1712 CLK_SET_RATE_PARENT, 2, 1);
1713 clk = tegra_clk_register_divider("spdif_div", "spdif_doubler",
1714 clk_base + AUDIO_SYNC_DOUBLER, 0, 0, 29, 1,
1715 0, &clk_doubler_lock);
1716 clk = tegra_clk_register_periph_gate("spdif_2x", "spdif_div",
1717 TEGRA_PERIPH_NO_RESET, clk_base,
1718 CLK_SET_RATE_PARENT, 118,
1719 &periph_v_regs, periph_clk_enb_refcnt);
1720 clk_register_clkdev(clk, "spdif_2x", NULL);
1721 clks[spdif_2x] = clk;
1722}
1723
1724static void __init tegra114_pmc_clk_init(void __iomem *pmc_base)
1725{
1726 struct clk *clk;
1727
1728 /* clk_out_1 */
1729 clk = clk_register_mux(NULL, "clk_out_1_mux", clk_out1_parents,
1730 ARRAY_SIZE(clk_out1_parents),
1731 CLK_SET_RATE_NO_REPARENT,
1732 pmc_base + PMC_CLK_OUT_CNTRL, 6, 3, 0,
1733 &clk_out_lock);
1734 clks[clk_out_1_mux] = clk;
1735 clk = clk_register_gate(NULL, "clk_out_1", "clk_out_1_mux", 0,
1736 pmc_base + PMC_CLK_OUT_CNTRL, 2, 0,
1737 &clk_out_lock);
1738 clk_register_clkdev(clk, "extern1", "clk_out_1");
1739 clks[clk_out_1] = clk;
1740
1741 /* clk_out_2 */
1742 clk = clk_register_mux(NULL, "clk_out_2_mux", clk_out2_parents,
1743 ARRAY_SIZE(clk_out2_parents),
1744 CLK_SET_RATE_NO_REPARENT,
1745 pmc_base + PMC_CLK_OUT_CNTRL, 14, 3, 0,
1746 &clk_out_lock);
1747 clks[clk_out_2_mux] = clk;
1748 clk = clk_register_gate(NULL, "clk_out_2", "clk_out_2_mux", 0,
1749 pmc_base + PMC_CLK_OUT_CNTRL, 10, 0,
1750 &clk_out_lock);
1751 clk_register_clkdev(clk, "extern2", "clk_out_2");
1752 clks[clk_out_2] = clk;
1753
1754 /* clk_out_3 */
1755 clk = clk_register_mux(NULL, "clk_out_3_mux", clk_out3_parents,
1756 ARRAY_SIZE(clk_out3_parents),
1757 CLK_SET_RATE_NO_REPARENT,
1758 pmc_base + PMC_CLK_OUT_CNTRL, 22, 3, 0,
1759 &clk_out_lock);
1760 clks[clk_out_3_mux] = clk;
1761 clk = clk_register_gate(NULL, "clk_out_3", "clk_out_3_mux", 0,
1762 pmc_base + PMC_CLK_OUT_CNTRL, 18, 0,
1763 &clk_out_lock);
1764 clk_register_clkdev(clk, "extern3", "clk_out_3");
1765 clks[clk_out_3] = clk;
1766
1767 /* blink */
1768 /* clear the blink timer register to directly output clk_32k */
1769 writel_relaxed(0, pmc_base + PMC_BLINK_TIMER);
1770 clk = clk_register_gate(NULL, "blink_override", "clk_32k", 0,
1771 pmc_base + PMC_DPD_PADS_ORIDE,
1772 PMC_DPD_PADS_ORIDE_BLINK_ENB, 0, NULL);
1773 clk = clk_register_gate(NULL, "blink", "blink_override", 0,
1774 pmc_base + PMC_CTRL,
1775 PMC_CTRL_BLINK_ENB, 0, NULL);
1776 clk_register_clkdev(clk, "blink", NULL);
1777 clks[blink] = clk;
1778
1779} 1179}
1780 1180
1781static const char *sclk_parents[] = { "clk_m", "pll_c_out1", "pll_p_out4", 1181static __init void tegra114_periph_clk_init(void __iomem *clk_base,
1782 "pll_p", "pll_p_out2", "unused", 1182 void __iomem *pmc_base)
1783 "clk_32k", "pll_m_out1" };
1784
1785static const char *cclk_g_parents[] = { "clk_m", "pll_c", "clk_32k", "pll_m",
1786 "pll_p", "pll_p_out4", "unused",
1787 "unused", "pll_x" };
1788
1789static const char *cclk_lp_parents[] = { "clk_m", "pll_c", "clk_32k", "pll_m",
1790 "pll_p", "pll_p_out4", "unused",
1791 "unused", "pll_x", "pll_x_out0" };
1792
1793static void __init tegra114_super_clk_init(void __iomem *clk_base)
1794{ 1183{
1795 struct clk *clk; 1184 struct clk *clk;
1185 u32 val;
1796 1186
1797 /* CCLKG */ 1187 /* xusb_hs_src */
1798 clk = tegra_clk_register_super_mux("cclk_g", cclk_g_parents, 1188 val = readl(clk_base + CLK_SOURCE_XUSB_SS_SRC);
1799 ARRAY_SIZE(cclk_g_parents), 1189 val |= BIT(25); /* always select PLLU_60M */
1800 CLK_SET_RATE_PARENT, 1190 writel(val, clk_base + CLK_SOURCE_XUSB_SS_SRC);
1801 clk_base + CCLKG_BURST_POLICY,
1802 0, 4, 0, 0, NULL);
1803 clk_register_clkdev(clk, "cclk_g", NULL);
1804 clks[cclk_g] = clk;
1805
1806 /* CCLKLP */
1807 clk = tegra_clk_register_super_mux("cclk_lp", cclk_lp_parents,
1808 ARRAY_SIZE(cclk_lp_parents),
1809 CLK_SET_RATE_PARENT,
1810 clk_base + CCLKLP_BURST_POLICY,
1811 0, 4, 8, 9, NULL);
1812 clk_register_clkdev(clk, "cclk_lp", NULL);
1813 clks[cclk_lp] = clk;
1814
1815 /* SCLK */
1816 clk = tegra_clk_register_super_mux("sclk", sclk_parents,
1817 ARRAY_SIZE(sclk_parents),
1818 CLK_SET_RATE_PARENT,
1819 clk_base + SCLK_BURST_POLICY,
1820 0, 4, 0, 0, NULL);
1821 clk_register_clkdev(clk, "sclk", NULL);
1822 clks[sclk] = clk;
1823
1824 /* HCLK */
1825 clk = clk_register_divider(NULL, "hclk_div", "sclk", 0,
1826 clk_base + SYSTEM_CLK_RATE, 4, 2, 0,
1827 &sysrate_lock);
1828 clk = clk_register_gate(NULL, "hclk", "hclk_div", CLK_SET_RATE_PARENT |
1829 CLK_IGNORE_UNUSED, clk_base + SYSTEM_CLK_RATE,
1830 7, CLK_GATE_SET_TO_DISABLE, &sysrate_lock);
1831 clk_register_clkdev(clk, "hclk", NULL);
1832 clks[hclk] = clk;
1833
1834 /* PCLK */
1835 clk = clk_register_divider(NULL, "pclk_div", "hclk", 0,
1836 clk_base + SYSTEM_CLK_RATE, 0, 2, 0,
1837 &sysrate_lock);
1838 clk = clk_register_gate(NULL, "pclk", "pclk_div", CLK_SET_RATE_PARENT |
1839 CLK_IGNORE_UNUSED, clk_base + SYSTEM_CLK_RATE,
1840 3, CLK_GATE_SET_TO_DISABLE, &sysrate_lock);
1841 clk_register_clkdev(clk, "pclk", NULL);
1842 clks[pclk] = clk;
1843}
1844
1845static struct tegra_periph_init_data tegra_periph_clk_list[] = {
1846 TEGRA_INIT_DATA_MUX("i2s0", NULL, "tegra30-i2s.0", mux_pllaout0_audio0_2x_pllp_clkm, CLK_SOURCE_I2S0, 30, &periph_l_regs, TEGRA_PERIPH_ON_APB, i2s0),
1847 TEGRA_INIT_DATA_MUX("i2s1", NULL, "tegra30-i2s.1", mux_pllaout0_audio1_2x_pllp_clkm, CLK_SOURCE_I2S1, 11, &periph_l_regs, TEGRA_PERIPH_ON_APB, i2s1),
1848 TEGRA_INIT_DATA_MUX("i2s2", NULL, "tegra30-i2s.2", mux_pllaout0_audio2_2x_pllp_clkm, CLK_SOURCE_I2S2, 18, &periph_l_regs, TEGRA_PERIPH_ON_APB, i2s2),
1849 TEGRA_INIT_DATA_MUX("i2s3", NULL, "tegra30-i2s.3", mux_pllaout0_audio3_2x_pllp_clkm, CLK_SOURCE_I2S3, 101, &periph_v_regs, TEGRA_PERIPH_ON_APB, i2s3),
1850 TEGRA_INIT_DATA_MUX("i2s4", NULL, "tegra30-i2s.4", mux_pllaout0_audio4_2x_pllp_clkm, CLK_SOURCE_I2S4, 102, &periph_v_regs, TEGRA_PERIPH_ON_APB, i2s4),
1851 TEGRA_INIT_DATA_MUX("spdif_out", "spdif_out", "tegra30-spdif", mux_pllaout0_audio_2x_pllp_clkm, CLK_SOURCE_SPDIF_OUT, 10, &periph_l_regs, TEGRA_PERIPH_ON_APB, spdif_out),
1852 TEGRA_INIT_DATA_MUX("spdif_in", "spdif_in", "tegra30-spdif", mux_pllp_pllc_pllm, CLK_SOURCE_SPDIF_IN, 10, &periph_l_regs, TEGRA_PERIPH_ON_APB, spdif_in),
1853 TEGRA_INIT_DATA_MUX("pwm", NULL, "pwm", mux_pllp_pllc_clk32_clkm, CLK_SOURCE_PWM, 17, &periph_l_regs, TEGRA_PERIPH_ON_APB, pwm),
1854 TEGRA_INIT_DATA_MUX("adx", NULL, "adx", mux_plla_pllc_pllp_clkm, CLK_SOURCE_ADX, 154, &periph_w_regs, TEGRA_PERIPH_ON_APB, adx),
1855 TEGRA_INIT_DATA_MUX("amx", NULL, "amx", mux_plla_pllc_pllp_clkm, CLK_SOURCE_AMX, 153, &periph_w_regs, TEGRA_PERIPH_ON_APB, amx),
1856 TEGRA_INIT_DATA_MUX("hda", "hda", "tegra30-hda", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_HDA, 125, &periph_v_regs, TEGRA_PERIPH_ON_APB, hda),
1857 TEGRA_INIT_DATA_MUX("hda2codec_2x", "hda2codec", "tegra30-hda", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_HDA2CODEC_2X, 111, &periph_v_regs, TEGRA_PERIPH_ON_APB, hda2codec_2x),
1858 TEGRA_INIT_DATA_MUX("sbc1", NULL, "tegra11-spi.0", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SBC1, 41, &periph_h_regs, TEGRA_PERIPH_ON_APB, sbc1),
1859 TEGRA_INIT_DATA_MUX("sbc2", NULL, "tegra11-spi.1", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SBC2, 44, &periph_h_regs, TEGRA_PERIPH_ON_APB, sbc2),
1860 TEGRA_INIT_DATA_MUX("sbc3", NULL, "tegra11-spi.2", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SBC3, 46, &periph_h_regs, TEGRA_PERIPH_ON_APB, sbc3),
1861 TEGRA_INIT_DATA_MUX("sbc4", NULL, "tegra11-spi.3", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SBC4, 68, &periph_u_regs, TEGRA_PERIPH_ON_APB, sbc4),
1862 TEGRA_INIT_DATA_MUX("sbc5", NULL, "tegra11-spi.4", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SBC5, 104, &periph_v_regs, TEGRA_PERIPH_ON_APB, sbc5),
1863 TEGRA_INIT_DATA_MUX("sbc6", NULL, "tegra11-spi.5", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SBC6, 105, &periph_v_regs, TEGRA_PERIPH_ON_APB, sbc6),
1864 TEGRA_INIT_DATA_MUX8("ndflash", NULL, "tegra_nand", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_NDFLASH, 13, &periph_u_regs, TEGRA_PERIPH_ON_APB, ndspeed),
1865 TEGRA_INIT_DATA_MUX8("ndspeed", NULL, "tegra_nand_speed", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_NDSPEED, 80, &periph_u_regs, TEGRA_PERIPH_ON_APB, ndspeed),
1866 TEGRA_INIT_DATA_MUX("vfir", NULL, "vfir", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_VFIR, 7, &periph_l_regs, TEGRA_PERIPH_ON_APB, vfir),
1867 TEGRA_INIT_DATA_MUX("sdmmc1", NULL, "sdhci-tegra.0", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SDMMC1, 14, &periph_l_regs, 0, sdmmc1),
1868 TEGRA_INIT_DATA_MUX("sdmmc2", NULL, "sdhci-tegra.1", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SDMMC2, 9, &periph_l_regs, 0, sdmmc2),
1869 TEGRA_INIT_DATA_MUX("sdmmc3", NULL, "sdhci-tegra.2", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SDMMC3, 69, &periph_u_regs, 0, sdmmc3),
1870 TEGRA_INIT_DATA_MUX("sdmmc4", NULL, "sdhci-tegra.3", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SDMMC4, 15, &periph_l_regs, 0, sdmmc4),
1871 TEGRA_INIT_DATA_INT("vde", NULL, "vde", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_VDE, 61, &periph_h_regs, 0, vde),
1872 TEGRA_INIT_DATA_MUX_FLAGS("csite", NULL, "csite", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_CSITE, 73, &periph_u_regs, TEGRA_PERIPH_ON_APB, csite, CLK_IGNORE_UNUSED),
1873 TEGRA_INIT_DATA_MUX("la", NULL, "la", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_LA, 76, &periph_u_regs, TEGRA_PERIPH_ON_APB, la),
1874 TEGRA_INIT_DATA_MUX("trace", NULL, "trace", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_TRACE, 77, &periph_u_regs, TEGRA_PERIPH_ON_APB, trace),
1875 TEGRA_INIT_DATA_MUX("owr", NULL, "tegra_w1", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_OWR, 71, &periph_u_regs, TEGRA_PERIPH_ON_APB, owr),
1876 TEGRA_INIT_DATA_MUX("nor", NULL, "tegra-nor", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_NOR, 42, &periph_h_regs, 0, nor),
1877 TEGRA_INIT_DATA_MUX("mipi", NULL, "mipi", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_MIPI, 50, &periph_h_regs, TEGRA_PERIPH_ON_APB, mipi),
1878 TEGRA_INIT_DATA_I2C("i2c1", "div-clk", "tegra11-i2c.0", mux_pllp_clkm, CLK_SOURCE_I2C1, 12, &periph_l_regs, i2c1),
1879 TEGRA_INIT_DATA_I2C("i2c2", "div-clk", "tegra11-i2c.1", mux_pllp_clkm, CLK_SOURCE_I2C2, 54, &periph_h_regs, i2c2),
1880 TEGRA_INIT_DATA_I2C("i2c3", "div-clk", "tegra11-i2c.2", mux_pllp_clkm, CLK_SOURCE_I2C3, 67, &periph_u_regs, i2c3),
1881 TEGRA_INIT_DATA_I2C("i2c4", "div-clk", "tegra11-i2c.3", mux_pllp_clkm, CLK_SOURCE_I2C4, 103, &periph_v_regs, i2c4),
1882 TEGRA_INIT_DATA_I2C("i2c5", "div-clk", "tegra11-i2c.4", mux_pllp_clkm, CLK_SOURCE_I2C5, 47, &periph_h_regs, i2c5),
1883 TEGRA_INIT_DATA_UART("uarta", NULL, "tegra_uart.0", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTA, 6, &periph_l_regs, uarta),
1884 TEGRA_INIT_DATA_UART("uartb", NULL, "tegra_uart.1", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTB, 7, &periph_l_regs, uartb),
1885 TEGRA_INIT_DATA_UART("uartc", NULL, "tegra_uart.2", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTC, 55, &periph_h_regs, uartc),
1886 TEGRA_INIT_DATA_UART("uartd", NULL, "tegra_uart.3", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTD, 65, &periph_u_regs, uartd),
1887 TEGRA_INIT_DATA_INT("3d", NULL, "3d", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_3D, 24, &periph_l_regs, 0, gr_3d),
1888 TEGRA_INIT_DATA_INT("2d", NULL, "2d", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_2D, 21, &periph_l_regs, 0, gr_2d),
1889 TEGRA_INIT_DATA_MUX("vi_sensor", "vi_sensor", "tegra_camera", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_VI_SENSOR, 20, &periph_l_regs, TEGRA_PERIPH_NO_RESET, vi_sensor),
1890 TEGRA_INIT_DATA_INT8("vi", "vi", "tegra_camera", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_VI, 20, &periph_l_regs, 0, vi),
1891 TEGRA_INIT_DATA_INT8("epp", NULL, "epp", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_EPP, 19, &periph_l_regs, 0, epp),
1892 TEGRA_INIT_DATA_INT8("msenc", NULL, "msenc", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_MSENC, 91, &periph_u_regs, TEGRA_PERIPH_WAR_1005168, msenc),
1893 TEGRA_INIT_DATA_INT8("tsec", NULL, "tsec", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_TSEC, 83, &periph_u_regs, 0, tsec),
1894 TEGRA_INIT_DATA_INT8("host1x", NULL, "host1x", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_HOST1X, 28, &periph_l_regs, 0, host1x),
1895 TEGRA_INIT_DATA_MUX8("hdmi", NULL, "hdmi", mux_pllp_pllm_plld_plla_pllc_plld2_clkm, CLK_SOURCE_HDMI, 51, &periph_h_regs, 0, hdmi),
1896 TEGRA_INIT_DATA_MUX("cilab", "cilab", "tegra_camera", mux_pllp_pllc_clkm, CLK_SOURCE_CILAB, 144, &periph_w_regs, 0, cilab),
1897 TEGRA_INIT_DATA_MUX("cilcd", "cilcd", "tegra_camera", mux_pllp_pllc_clkm, CLK_SOURCE_CILCD, 145, &periph_w_regs, 0, cilcd),
1898 TEGRA_INIT_DATA_MUX("cile", "cile", "tegra_camera", mux_pllp_pllc_clkm, CLK_SOURCE_CILE, 146, &periph_w_regs, 0, cile),
1899 TEGRA_INIT_DATA_MUX("dsialp", "dsialp", "tegradc.0", mux_pllp_pllc_clkm, CLK_SOURCE_DSIALP, 147, &periph_w_regs, 0, dsialp),
1900 TEGRA_INIT_DATA_MUX("dsiblp", "dsiblp", "tegradc.1", mux_pllp_pllc_clkm, CLK_SOURCE_DSIBLP, 148, &periph_w_regs, 0, dsiblp),
1901 TEGRA_INIT_DATA_MUX("tsensor", NULL, "tegra-tsensor", mux_pllp_pllc_clkm_clk32, CLK_SOURCE_TSENSOR, 100, &periph_v_regs, TEGRA_PERIPH_ON_APB, tsensor),
1902 TEGRA_INIT_DATA_MUX("actmon", NULL, "actmon", mux_pllp_pllc_clk32_clkm, CLK_SOURCE_ACTMON, 119, &periph_v_regs, 0, actmon),
1903 TEGRA_INIT_DATA_MUX8("extern1", NULL, "extern1", mux_plla_clk32_pllp_clkm_plle, CLK_SOURCE_EXTERN1, 120, &periph_v_regs, 0, extern1),
1904 TEGRA_INIT_DATA_MUX8("extern2", NULL, "extern2", mux_plla_clk32_pllp_clkm_plle, CLK_SOURCE_EXTERN2, 121, &periph_v_regs, 0, extern2),
1905 TEGRA_INIT_DATA_MUX8("extern3", NULL, "extern3", mux_plla_clk32_pllp_clkm_plle, CLK_SOURCE_EXTERN3, 122, &periph_v_regs, 0, extern3),
1906 TEGRA_INIT_DATA_MUX("i2cslow", NULL, "i2cslow", mux_pllp_pllc_clk32_clkm, CLK_SOURCE_I2CSLOW, 81, &periph_u_regs, TEGRA_PERIPH_ON_APB, i2cslow),
1907 TEGRA_INIT_DATA_INT8("se", NULL, "se", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_SE, 127, &periph_v_regs, TEGRA_PERIPH_ON_APB, se),
1908 TEGRA_INIT_DATA_INT_FLAGS("mselect", NULL, "mselect", mux_pllp_clkm, CLK_SOURCE_MSELECT, 99, &periph_v_regs, 0, mselect, CLK_IGNORE_UNUSED),
1909 TEGRA_INIT_DATA_MUX("dfll_ref", "ref", "t114_dfll", mux_pllp_clkm, CLK_SOURCE_DFLL_REF, 155, &periph_w_regs, TEGRA_PERIPH_ON_APB, dfll_ref),
1910 TEGRA_INIT_DATA_MUX("dfll_soc", "soc", "t114_dfll", mux_pllp_clkm, CLK_SOURCE_DFLL_SOC, 155, &periph_w_regs, TEGRA_PERIPH_ON_APB, dfll_soc),
1911 TEGRA_INIT_DATA_MUX8("soc_therm", NULL, "soc_therm", mux_pllm_pllc_pllp_plla, CLK_SOURCE_SOC_THERM, 78, &periph_u_regs, TEGRA_PERIPH_ON_APB, soc_therm),
1912 TEGRA_INIT_DATA_XUSB("xusb_host_src", "host_src", "tegra_xhci", mux_clkm_pllp_pllc_pllre, CLK_SOURCE_XUSB_HOST_SRC, 143, &periph_w_regs, TEGRA_PERIPH_ON_APB | TEGRA_PERIPH_NO_RESET, xusb_host_src),
1913 TEGRA_INIT_DATA_XUSB("xusb_falcon_src", "falcon_src", "tegra_xhci", mux_clkm_pllp_pllc_pllre, CLK_SOURCE_XUSB_FALCON_SRC, 143, &periph_w_regs, TEGRA_PERIPH_NO_RESET, xusb_falcon_src),
1914 TEGRA_INIT_DATA_XUSB("xusb_fs_src", "fs_src", "tegra_xhci", mux_clkm_48M_pllp_480M, CLK_SOURCE_XUSB_FS_SRC, 143, &periph_w_regs, TEGRA_PERIPH_NO_RESET, xusb_fs_src),
1915 TEGRA_INIT_DATA_XUSB("xusb_ss_src", "ss_src", "tegra_xhci", mux_clkm_pllre_clk32_480M_pllc_ref, CLK_SOURCE_XUSB_SS_SRC, 143, &periph_w_regs, TEGRA_PERIPH_NO_RESET, xusb_ss_src),
1916 TEGRA_INIT_DATA_XUSB("xusb_dev_src", "dev_src", "tegra_xhci", mux_clkm_pllp_pllc_pllre, CLK_SOURCE_XUSB_DEV_SRC, 95, &periph_u_regs, TEGRA_PERIPH_ON_APB | TEGRA_PERIPH_NO_RESET, xusb_dev_src),
1917 TEGRA_INIT_DATA_AUDIO("d_audio", "d_audio", "tegra30-ahub", CLK_SOURCE_D_AUDIO, 106, &periph_v_regs, TEGRA_PERIPH_ON_APB, d_audio),
1918 TEGRA_INIT_DATA_AUDIO("dam0", NULL, "tegra30-dam.0", CLK_SOURCE_DAM0, 108, &periph_v_regs, TEGRA_PERIPH_ON_APB, dam0),
1919 TEGRA_INIT_DATA_AUDIO("dam1", NULL, "tegra30-dam.1", CLK_SOURCE_DAM1, 109, &periph_v_regs, TEGRA_PERIPH_ON_APB, dam1),
1920 TEGRA_INIT_DATA_AUDIO("dam2", NULL, "tegra30-dam.2", CLK_SOURCE_DAM2, 110, &periph_v_regs, TEGRA_PERIPH_ON_APB, dam2),
1921};
1922
1923static struct tegra_periph_init_data tegra_periph_nodiv_clk_list[] = {
1924 TEGRA_INIT_DATA_NODIV("disp1", NULL, "tegradc.0", mux_pllp_pllm_plld_plla_pllc_plld2_clkm, CLK_SOURCE_DISP1, 29, 7, 27, &periph_l_regs, 0, disp1),
1925 TEGRA_INIT_DATA_NODIV("disp2", NULL, "tegradc.1", mux_pllp_pllm_plld_plla_pllc_plld2_clkm, CLK_SOURCE_DISP2, 29, 7, 26, &periph_l_regs, 0, disp2),
1926};
1927 1191
1928static __init void tegra114_periph_clk_init(void __iomem *clk_base) 1192 clk = clk_register_fixed_factor(NULL, "xusb_hs_src", "pll_u_60M", 0,
1929{ 1193 1, 1);
1930 struct tegra_periph_init_data *data; 1194 clks[TEGRA114_CLK_XUSB_HS_SRC] = clk;
1931 struct clk *clk;
1932 int i;
1933 u32 val;
1934 1195
1935 /* apbdma */ 1196 /* dsia mux */
1936 clk = tegra_clk_register_periph_gate("apbdma", "clk_m", 0, clk_base,
1937 0, 34, &periph_h_regs,
1938 periph_clk_enb_refcnt);
1939 clks[apbdma] = clk;
1940
1941 /* rtc */
1942 clk = tegra_clk_register_periph_gate("rtc", "clk_32k",
1943 TEGRA_PERIPH_ON_APB |
1944 TEGRA_PERIPH_NO_RESET, clk_base,
1945 0, 4, &periph_l_regs,
1946 periph_clk_enb_refcnt);
1947 clk_register_clkdev(clk, NULL, "rtc-tegra");
1948 clks[rtc] = clk;
1949
1950 /* kbc */
1951 clk = tegra_clk_register_periph_gate("kbc", "clk_32k",
1952 TEGRA_PERIPH_ON_APB |
1953 TEGRA_PERIPH_NO_RESET, clk_base,
1954 0, 36, &periph_h_regs,
1955 periph_clk_enb_refcnt);
1956 clks[kbc] = clk;
1957
1958 /* timer */
1959 clk = tegra_clk_register_periph_gate("timer", "clk_m", 0, clk_base,
1960 0, 5, &periph_l_regs,
1961 periph_clk_enb_refcnt);
1962 clk_register_clkdev(clk, NULL, "timer");
1963 clks[timer] = clk;
1964
1965 /* kfuse */
1966 clk = tegra_clk_register_periph_gate("kfuse", "clk_m",
1967 TEGRA_PERIPH_ON_APB, clk_base, 0, 40,
1968 &periph_h_regs, periph_clk_enb_refcnt);
1969 clks[kfuse] = clk;
1970
1971 /* fuse */
1972 clk = tegra_clk_register_periph_gate("fuse", "clk_m",
1973 TEGRA_PERIPH_ON_APB, clk_base, 0, 39,
1974 &periph_h_regs, periph_clk_enb_refcnt);
1975 clks[fuse] = clk;
1976
1977 /* fuse_burn */
1978 clk = tegra_clk_register_periph_gate("fuse_burn", "clk_m",
1979 TEGRA_PERIPH_ON_APB, clk_base, 0, 39,
1980 &periph_h_regs, periph_clk_enb_refcnt);
1981 clks[fuse_burn] = clk;
1982
1983 /* apbif */
1984 clk = tegra_clk_register_periph_gate("apbif", "clk_m",
1985 TEGRA_PERIPH_ON_APB, clk_base, 0, 107,
1986 &periph_v_regs, periph_clk_enb_refcnt);
1987 clks[apbif] = clk;
1988
1989 /* hda2hdmi */
1990 clk = tegra_clk_register_periph_gate("hda2hdmi", "clk_m",
1991 TEGRA_PERIPH_ON_APB, clk_base, 0, 128,
1992 &periph_w_regs, periph_clk_enb_refcnt);
1993 clks[hda2hdmi] = clk;
1994
1995 /* vcp */
1996 clk = tegra_clk_register_periph_gate("vcp", "clk_m", 0, clk_base, 0,
1997 29, &periph_l_regs,
1998 periph_clk_enb_refcnt);
1999 clks[vcp] = clk;
2000
2001 /* bsea */
2002 clk = tegra_clk_register_periph_gate("bsea", "clk_m", 0, clk_base,
2003 0, 62, &periph_h_regs,
2004 periph_clk_enb_refcnt);
2005 clks[bsea] = clk;
2006
2007 /* bsev */
2008 clk = tegra_clk_register_periph_gate("bsev", "clk_m", 0, clk_base,
2009 0, 63, &periph_h_regs,
2010 periph_clk_enb_refcnt);
2011 clks[bsev] = clk;
2012
2013 /* mipi-cal */
2014 clk = tegra_clk_register_periph_gate("mipi-cal", "clk_m", 0, clk_base,
2015 0, 56, &periph_h_regs,
2016 periph_clk_enb_refcnt);
2017 clks[mipi_cal] = clk;
2018
2019 /* usbd */
2020 clk = tegra_clk_register_periph_gate("usbd", "clk_m", 0, clk_base,
2021 0, 22, &periph_l_regs,
2022 periph_clk_enb_refcnt);
2023 clks[usbd] = clk;
2024
2025 /* usb2 */
2026 clk = tegra_clk_register_periph_gate("usb2", "clk_m", 0, clk_base,
2027 0, 58, &periph_h_regs,
2028 periph_clk_enb_refcnt);
2029 clks[usb2] = clk;
2030
2031 /* usb3 */
2032 clk = tegra_clk_register_periph_gate("usb3", "clk_m", 0, clk_base,
2033 0, 59, &periph_h_regs,
2034 periph_clk_enb_refcnt);
2035 clks[usb3] = clk;
2036
2037 /* csi */
2038 clk = tegra_clk_register_periph_gate("csi", "pll_p_out3", 0, clk_base,
2039 0, 52, &periph_h_regs,
2040 periph_clk_enb_refcnt);
2041 clks[csi] = clk;
2042
2043 /* isp */
2044 clk = tegra_clk_register_periph_gate("isp", "clk_m", 0, clk_base, 0,
2045 23, &periph_l_regs,
2046 periph_clk_enb_refcnt);
2047 clks[isp] = clk;
2048
2049 /* csus */
2050 clk = tegra_clk_register_periph_gate("csus", "clk_m",
2051 TEGRA_PERIPH_NO_RESET, clk_base, 0, 92,
2052 &periph_u_regs, periph_clk_enb_refcnt);
2053 clks[csus] = clk;
2054
2055 /* dds */
2056 clk = tegra_clk_register_periph_gate("dds", "clk_m",
2057 TEGRA_PERIPH_ON_APB, clk_base, 0, 150,
2058 &periph_w_regs, periph_clk_enb_refcnt);
2059 clks[dds] = clk;
2060
2061 /* dp2 */
2062 clk = tegra_clk_register_periph_gate("dp2", "clk_m",
2063 TEGRA_PERIPH_ON_APB, clk_base, 0, 152,
2064 &periph_w_regs, periph_clk_enb_refcnt);
2065 clks[dp2] = clk;
2066
2067 /* dtv */
2068 clk = tegra_clk_register_periph_gate("dtv", "clk_m",
2069 TEGRA_PERIPH_ON_APB, clk_base, 0, 79,
2070 &periph_u_regs, periph_clk_enb_refcnt);
2071 clks[dtv] = clk;
2072
2073 /* dsia */
2074 clk = clk_register_mux(NULL, "dsia_mux", mux_plld_out0_plld2_out0, 1197 clk = clk_register_mux(NULL, "dsia_mux", mux_plld_out0_plld2_out0,
2075 ARRAY_SIZE(mux_plld_out0_plld2_out0), 1198 ARRAY_SIZE(mux_plld_out0_plld2_out0),
2076 CLK_SET_RATE_NO_REPARENT, 1199 CLK_SET_RATE_NO_REPARENT,
2077 clk_base + PLLD_BASE, 25, 1, 0, &pll_d_lock); 1200 clk_base + PLLD_BASE, 25, 1, 0, &pll_d_lock);
2078 clks[dsia_mux] = clk; 1201 clks[TEGRA114_CLK_DSIA_MUX] = clk;
2079 clk = tegra_clk_register_periph_gate("dsia", "dsia_mux", 0, clk_base,
2080 0, 48, &periph_h_regs,
2081 periph_clk_enb_refcnt);
2082 clks[dsia] = clk;
2083 1202
2084 /* dsib */ 1203 /* dsib mux */
2085 clk = clk_register_mux(NULL, "dsib_mux", mux_plld_out0_plld2_out0, 1204 clk = clk_register_mux(NULL, "dsib_mux", mux_plld_out0_plld2_out0,
2086 ARRAY_SIZE(mux_plld_out0_plld2_out0), 1205 ARRAY_SIZE(mux_plld_out0_plld2_out0),
2087 CLK_SET_RATE_NO_REPARENT, 1206 CLK_SET_RATE_NO_REPARENT,
2088 clk_base + PLLD2_BASE, 25, 1, 0, &pll_d2_lock); 1207 clk_base + PLLD2_BASE, 25, 1, 0, &pll_d2_lock);
2089 clks[dsib_mux] = clk; 1208 clks[TEGRA114_CLK_DSIB_MUX] = clk;
2090 clk = tegra_clk_register_periph_gate("dsib", "dsib_mux", 0, clk_base,
2091 0, 82, &periph_u_regs,
2092 periph_clk_enb_refcnt);
2093 clks[dsib] = clk;
2094 1209
2095 /* xusb_hs_src */ 1210 /* emc mux */
2096 val = readl(clk_base + CLK_SOURCE_XUSB_SS_SRC);
2097 val |= BIT(25); /* always select PLLU_60M */
2098 writel(val, clk_base + CLK_SOURCE_XUSB_SS_SRC);
2099
2100 clk = clk_register_fixed_factor(NULL, "xusb_hs_src", "pll_u_60M", 0,
2101 1, 1);
2102 clks[xusb_hs_src] = clk;
2103
2104 /* xusb_host */
2105 clk = tegra_clk_register_periph_gate("xusb_host", "xusb_host_src", 0,
2106 clk_base, 0, 89, &periph_u_regs,
2107 periph_clk_enb_refcnt);
2108 clks[xusb_host] = clk;
2109
2110 /* xusb_ss */
2111 clk = tegra_clk_register_periph_gate("xusb_ss", "xusb_ss_src", 0,
2112 clk_base, 0, 156, &periph_w_regs,
2113 periph_clk_enb_refcnt);
2114 clks[xusb_host] = clk;
2115
2116 /* xusb_dev */
2117 clk = tegra_clk_register_periph_gate("xusb_dev", "xusb_dev_src", 0,
2118 clk_base, 0, 95, &periph_u_regs,
2119 periph_clk_enb_refcnt);
2120 clks[xusb_dev] = clk;
2121
2122 /* emc */
2123 clk = clk_register_mux(NULL, "emc_mux", mux_pllmcp_clkm, 1211 clk = clk_register_mux(NULL, "emc_mux", mux_pllmcp_clkm,
2124 ARRAY_SIZE(mux_pllmcp_clkm), 1212 ARRAY_SIZE(mux_pllmcp_clkm),
2125 CLK_SET_RATE_NO_REPARENT, 1213 CLK_SET_RATE_NO_REPARENT,
2126 clk_base + CLK_SOURCE_EMC, 1214 clk_base + CLK_SOURCE_EMC,
2127 29, 3, 0, NULL); 1215 29, 3, 0, NULL);
2128 clk = tegra_clk_register_periph_gate("emc", "emc_mux", 0, clk_base,
2129 CLK_IGNORE_UNUSED, 57, &periph_h_regs,
2130 periph_clk_enb_refcnt);
2131 clks[emc] = clk;
2132
2133 for (i = 0; i < ARRAY_SIZE(tegra_periph_clk_list); i++) {
2134 data = &tegra_periph_clk_list[i];
2135 clk = tegra_clk_register_periph(data->name, data->parent_names,
2136 data->num_parents, &data->periph,
2137 clk_base, data->offset, data->flags);
2138 clks[data->clk_id] = clk;
2139 }
2140 1216
2141 for (i = 0; i < ARRAY_SIZE(tegra_periph_nodiv_clk_list); i++) { 1217 tegra_periph_clk_init(clk_base, pmc_base, tegra114_clks,
2142 data = &tegra_periph_nodiv_clk_list[i]; 1218 &pll_p_params);
2143 clk = tegra_clk_register_periph_nodiv(data->name,
2144 data->parent_names, data->num_parents,
2145 &data->periph, clk_base, data->offset);
2146 clks[data->clk_id] = clk;
2147 }
2148} 1219}
2149 1220
2150/* Tegra114 CPU clock and reset control functions */ 1221/* Tegra114 CPU clock and reset control functions */
@@ -2207,28 +1278,37 @@ static const struct of_device_id pmc_match[] __initconst = {
2207 * breaks 1278 * breaks
2208 */ 1279 */
2209static struct tegra_clk_init_table init_table[] __initdata = { 1280static struct tegra_clk_init_table init_table[] __initdata = {
2210 {uarta, pll_p, 408000000, 0}, 1281 {TEGRA114_CLK_UARTA, TEGRA114_CLK_PLL_P, 408000000, 0},
2211 {uartb, pll_p, 408000000, 0}, 1282 {TEGRA114_CLK_UARTB, TEGRA114_CLK_PLL_P, 408000000, 0},
2212 {uartc, pll_p, 408000000, 0}, 1283 {TEGRA114_CLK_UARTC, TEGRA114_CLK_PLL_P, 408000000, 0},
2213 {uartd, pll_p, 408000000, 0}, 1284 {TEGRA114_CLK_UARTD, TEGRA114_CLK_PLL_P, 408000000, 0},
2214 {pll_a, clk_max, 564480000, 1}, 1285 {TEGRA114_CLK_PLL_A, TEGRA114_CLK_CLK_MAX, 564480000, 1},
2215 {pll_a_out0, clk_max, 11289600, 1}, 1286 {TEGRA114_CLK_PLL_A_OUT0, TEGRA114_CLK_CLK_MAX, 11289600, 1},
2216 {extern1, pll_a_out0, 0, 1}, 1287 {TEGRA114_CLK_EXTERN1, TEGRA114_CLK_PLL_A_OUT0, 0, 1},
2217 {clk_out_1_mux, extern1, 0, 1}, 1288 {TEGRA114_CLK_CLK_OUT_1_MUX, TEGRA114_CLK_EXTERN1, 0, 1},
2218 {clk_out_1, clk_max, 0, 1}, 1289 {TEGRA114_CLK_CLK_OUT_1, TEGRA114_CLK_CLK_MAX, 0, 1},
2219 {i2s0, pll_a_out0, 11289600, 0}, 1290 {TEGRA114_CLK_I2S0, TEGRA114_CLK_PLL_A_OUT0, 11289600, 0},
2220 {i2s1, pll_a_out0, 11289600, 0}, 1291 {TEGRA114_CLK_I2S1, TEGRA114_CLK_PLL_A_OUT0, 11289600, 0},
2221 {i2s2, pll_a_out0, 11289600, 0}, 1292 {TEGRA114_CLK_I2S2, TEGRA114_CLK_PLL_A_OUT0, 11289600, 0},
2222 {i2s3, pll_a_out0, 11289600, 0}, 1293 {TEGRA114_CLK_I2S3, TEGRA114_CLK_PLL_A_OUT0, 11289600, 0},
2223 {i2s4, pll_a_out0, 11289600, 0}, 1294 {TEGRA114_CLK_I2S4, TEGRA114_CLK_PLL_A_OUT0, 11289600, 0},
2224 {dfll_soc, pll_p, 51000000, 1}, 1295 {TEGRA114_CLK_HOST1X, TEGRA114_CLK_PLL_P, 136000000, 0},
2225 {dfll_ref, pll_p, 51000000, 1}, 1296 {TEGRA114_CLK_DFLL_SOC, TEGRA114_CLK_PLL_P, 51000000, 1},
2226 {clk_max, clk_max, 0, 0}, /* This MUST be the last entry. */ 1297 {TEGRA114_CLK_DFLL_REF, TEGRA114_CLK_PLL_P, 51000000, 1},
1298 {TEGRA114_CLK_DISP1, TEGRA114_CLK_PLL_P, 0, 0},
1299 {TEGRA114_CLK_DISP2, TEGRA114_CLK_PLL_P, 0, 0},
1300 {TEGRA114_CLK_GR2D, TEGRA114_CLK_PLL_C2, 300000000, 0},
1301 {TEGRA114_CLK_GR3D, TEGRA114_CLK_PLL_C2, 300000000, 0},
1302 {TEGRA114_CLK_DSIALP, TEGRA114_CLK_PLL_P, 68000000, 0},
1303 {TEGRA114_CLK_DSIBLP, TEGRA114_CLK_PLL_P, 68000000, 0},
1304
1305 /* This MUST be the last entry. */
1306 {TEGRA114_CLK_CLK_MAX, TEGRA114_CLK_CLK_MAX, 0, 0},
2227}; 1307};
2228 1308
2229static void __init tegra114_clock_apply_init_table(void) 1309static void __init tegra114_clock_apply_init_table(void)
2230{ 1310{
2231 tegra_init_from_table(init_table, clks, clk_max); 1311 tegra_init_from_table(init_table, clks, TEGRA114_CLK_CLK_MAX);
2232} 1312}
2233 1313
2234 1314
@@ -2359,7 +1439,6 @@ EXPORT_SYMBOL(tegra114_clock_deassert_dfll_dvco_reset);
2359static void __init tegra114_clock_init(struct device_node *np) 1439static void __init tegra114_clock_init(struct device_node *np)
2360{ 1440{
2361 struct device_node *node; 1441 struct device_node *node;
2362 int i;
2363 1442
2364 clk_base = of_iomap(np, 0); 1443 clk_base = of_iomap(np, 0);
2365 if (!clk_base) { 1444 if (!clk_base) {
@@ -2381,29 +1460,24 @@ static void __init tegra114_clock_init(struct device_node *np)
2381 return; 1460 return;
2382 } 1461 }
2383 1462
1463 clks = tegra_clk_init(clk_base, TEGRA114_CLK_CLK_MAX,
1464 TEGRA114_CLK_PERIPH_BANKS);
1465 if (!clks)
1466 return;
1467
2384 if (tegra114_osc_clk_init(clk_base) < 0) 1468 if (tegra114_osc_clk_init(clk_base) < 0)
2385 return; 1469 return;
2386 1470
2387 tegra114_fixed_clk_init(clk_base); 1471 tegra114_fixed_clk_init(clk_base);
2388 tegra114_pll_init(clk_base, pmc_base); 1472 tegra114_pll_init(clk_base, pmc_base);
2389 tegra114_periph_clk_init(clk_base); 1473 tegra114_periph_clk_init(clk_base, pmc_base);
2390 tegra114_audio_clk_init(clk_base); 1474 tegra_audio_clk_init(clk_base, pmc_base, tegra114_clks, &pll_a_params);
2391 tegra114_pmc_clk_init(pmc_base); 1475 tegra_pmc_clk_init(pmc_base, tegra114_clks);
2392 tegra114_super_clk_init(clk_base); 1476 tegra_super_clk_gen4_init(clk_base, pmc_base, tegra114_clks,
2393 1477 &pll_x_params);
2394 for (i = 0; i < ARRAY_SIZE(clks); i++) { 1478
2395 if (IS_ERR(clks[i])) { 1479 tegra_add_of_provider(np);
2396 pr_err 1480 tegra_register_devclks(devclks, ARRAY_SIZE(devclks));
2397 ("Tegra114 clk %d: register failed with %ld\n",
2398 i, PTR_ERR(clks[i]));
2399 }
2400 if (!clks[i])
2401 clks[i] = ERR_PTR(-EINVAL);
2402 }
2403
2404 clk_data.clks = clks;
2405 clk_data.clk_num = ARRAY_SIZE(clks);
2406 of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);
2407 1481
2408 tegra_clk_apply_init_table = tegra114_clock_apply_init_table; 1482 tegra_clk_apply_init_table = tegra114_clock_apply_init_table;
2409 1483
diff --git a/drivers/clk/tegra/clk-tegra124.c b/drivers/clk/tegra/clk-tegra124.c
new file mode 100644
index 000000000000..aff86b5bc745
--- /dev/null
+++ b/drivers/clk/tegra/clk-tegra124.c
@@ -0,0 +1,1424 @@
1/*
2 * Copyright (c) 2012, 2013, 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#include <linux/io.h>
18#include <linux/clk.h>
19#include <linux/clk-provider.h>
20#include <linux/clkdev.h>
21#include <linux/of.h>
22#include <linux/of_address.h>
23#include <linux/delay.h>
24#include <linux/export.h>
25#include <linux/clk/tegra.h>
26#include <dt-bindings/clock/tegra124-car.h>
27
28#include "clk.h"
29#include "clk-id.h"
30
31#define CLK_SOURCE_CSITE 0x1d4
32#define CLK_SOURCE_EMC 0x19c
33#define CLK_SOURCE_XUSB_SS_SRC 0x610
34
35#define PLLC_BASE 0x80
36#define PLLC_OUT 0x84
37#define PLLC_MISC2 0x88
38#define PLLC_MISC 0x8c
39#define PLLC2_BASE 0x4e8
40#define PLLC2_MISC 0x4ec
41#define PLLC3_BASE 0x4fc
42#define PLLC3_MISC 0x500
43#define PLLM_BASE 0x90
44#define PLLM_OUT 0x94
45#define PLLM_MISC 0x9c
46#define PLLP_BASE 0xa0
47#define PLLP_MISC 0xac
48#define PLLA_BASE 0xb0
49#define PLLA_MISC 0xbc
50#define PLLD_BASE 0xd0
51#define PLLD_MISC 0xdc
52#define PLLU_BASE 0xc0
53#define PLLU_MISC 0xcc
54#define PLLX_BASE 0xe0
55#define PLLX_MISC 0xe4
56#define PLLX_MISC2 0x514
57#define PLLX_MISC3 0x518
58#define PLLE_BASE 0xe8
59#define PLLE_MISC 0xec
60#define PLLD2_BASE 0x4b8
61#define PLLD2_MISC 0x4bc
62#define PLLE_AUX 0x48c
63#define PLLRE_BASE 0x4c4
64#define PLLRE_MISC 0x4c8
65#define PLLDP_BASE 0x590
66#define PLLDP_MISC 0x594
67#define PLLC4_BASE 0x5a4
68#define PLLC4_MISC 0x5a8
69
70#define PLLC_IDDQ_BIT 26
71#define PLLRE_IDDQ_BIT 16
72#define PLLSS_IDDQ_BIT 19
73
74#define PLL_BASE_LOCK BIT(27)
75#define PLLE_MISC_LOCK BIT(11)
76#define PLLRE_MISC_LOCK BIT(24)
77
78#define PLL_MISC_LOCK_ENABLE 18
79#define PLLC_MISC_LOCK_ENABLE 24
80#define PLLDU_MISC_LOCK_ENABLE 22
81#define PLLE_MISC_LOCK_ENABLE 9
82#define PLLRE_MISC_LOCK_ENABLE 30
83#define PLLSS_MISC_LOCK_ENABLE 30
84
85#define PLLXC_SW_MAX_P 6
86
87#define PMC_PLLM_WB0_OVERRIDE 0x1dc
88#define PMC_PLLM_WB0_OVERRIDE_2 0x2b0
89
90#define UTMIP_PLL_CFG2 0x488
91#define UTMIP_PLL_CFG2_STABLE_COUNT(x) (((x) & 0xffff) << 6)
92#define UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(x) (((x) & 0x3f) << 18)
93#define UTMIP_PLL_CFG2_FORCE_PD_SAMP_A_POWERDOWN BIT(0)
94#define UTMIP_PLL_CFG2_FORCE_PD_SAMP_B_POWERDOWN BIT(2)
95#define UTMIP_PLL_CFG2_FORCE_PD_SAMP_C_POWERDOWN BIT(4)
96
97#define UTMIP_PLL_CFG1 0x484
98#define UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(x) (((x) & 0x1f) << 6)
99#define UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(x) (((x) & 0xfff) << 0)
100#define UTMIP_PLL_CFG1_FORCE_PLLU_POWERUP BIT(17)
101#define UTMIP_PLL_CFG1_FORCE_PLLU_POWERDOWN BIT(16)
102#define UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERUP BIT(15)
103#define UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN BIT(14)
104#define UTMIP_PLL_CFG1_FORCE_PLL_ACTIVE_POWERDOWN BIT(12)
105
106#define UTMIPLL_HW_PWRDN_CFG0 0x52c
107#define UTMIPLL_HW_PWRDN_CFG0_SEQ_START_STATE BIT(25)
108#define UTMIPLL_HW_PWRDN_CFG0_SEQ_ENABLE BIT(24)
109#define UTMIPLL_HW_PWRDN_CFG0_USE_LOCKDET BIT(6)
110#define UTMIPLL_HW_PWRDN_CFG0_SEQ_RESET_INPUT_VALUE BIT(5)
111#define UTMIPLL_HW_PWRDN_CFG0_SEQ_IN_SWCTL BIT(4)
112#define UTMIPLL_HW_PWRDN_CFG0_CLK_ENABLE_SWCTL BIT(2)
113#define UTMIPLL_HW_PWRDN_CFG0_IDDQ_OVERRIDE BIT(1)
114#define UTMIPLL_HW_PWRDN_CFG0_IDDQ_SWCTL BIT(0)
115
116/* Tegra CPU clock and reset control regs */
117#define CLK_RST_CONTROLLER_CPU_CMPLX_STATUS 0x470
118
119#ifdef CONFIG_PM_SLEEP
120static struct cpu_clk_suspend_context {
121 u32 clk_csite_src;
122} tegra124_cpu_clk_sctx;
123#endif
124
125static void __iomem *clk_base;
126static void __iomem *pmc_base;
127
128static unsigned long osc_freq;
129static unsigned long pll_ref_freq;
130
131static DEFINE_SPINLOCK(pll_d_lock);
132static DEFINE_SPINLOCK(pll_d2_lock);
133static DEFINE_SPINLOCK(pll_e_lock);
134static DEFINE_SPINLOCK(pll_re_lock);
135static DEFINE_SPINLOCK(pll_u_lock);
136
137/* possible OSC frequencies in Hz */
138static unsigned long tegra124_input_freq[] = {
139 [0] = 13000000,
140 [1] = 16800000,
141 [4] = 19200000,
142 [5] = 38400000,
143 [8] = 12000000,
144 [9] = 48000000,
145 [12] = 260000000,
146};
147
148static const char *mux_plld_out0_plld2_out0[] = {
149 "pll_d_out0", "pll_d2_out0",
150};
151#define mux_plld_out0_plld2_out0_idx NULL
152
153static const char *mux_pllmcp_clkm[] = {
154 "pll_m", "pll_c", "pll_p", "clk_m", "pll_m_ud", "pll_c2", "pll_c3",
155};
156#define mux_pllmcp_clkm_idx NULL
157
158static struct div_nmp pllxc_nmp = {
159 .divm_shift = 0,
160 .divm_width = 8,
161 .divn_shift = 8,
162 .divn_width = 8,
163 .divp_shift = 20,
164 .divp_width = 4,
165};
166
167static struct pdiv_map pllxc_p[] = {
168 { .pdiv = 1, .hw_val = 0 },
169 { .pdiv = 2, .hw_val = 1 },
170 { .pdiv = 3, .hw_val = 2 },
171 { .pdiv = 4, .hw_val = 3 },
172 { .pdiv = 5, .hw_val = 4 },
173 { .pdiv = 6, .hw_val = 5 },
174 { .pdiv = 8, .hw_val = 6 },
175 { .pdiv = 10, .hw_val = 7 },
176 { .pdiv = 12, .hw_val = 8 },
177 { .pdiv = 16, .hw_val = 9 },
178 { .pdiv = 12, .hw_val = 10 },
179 { .pdiv = 16, .hw_val = 11 },
180 { .pdiv = 20, .hw_val = 12 },
181 { .pdiv = 24, .hw_val = 13 },
182 { .pdiv = 32, .hw_val = 14 },
183 { .pdiv = 0, .hw_val = 0 },
184};
185
186static struct tegra_clk_pll_freq_table pll_x_freq_table[] = {
187 /* 1 GHz */
188 {12000000, 1000000000, 83, 0, 1}, /* actual: 996.0 MHz */
189 {13000000, 1000000000, 76, 0, 1}, /* actual: 988.0 MHz */
190 {16800000, 1000000000, 59, 0, 1}, /* actual: 991.2 MHz */
191 {19200000, 1000000000, 52, 0, 1}, /* actual: 998.4 MHz */
192 {26000000, 1000000000, 76, 1, 1}, /* actual: 988.0 MHz */
193 {0, 0, 0, 0, 0, 0},
194};
195
196static struct tegra_clk_pll_params pll_x_params = {
197 .input_min = 12000000,
198 .input_max = 800000000,
199 .cf_min = 12000000,
200 .cf_max = 19200000, /* s/w policy, h/w capability 50 MHz */
201 .vco_min = 700000000,
202 .vco_max = 3000000000UL,
203 .base_reg = PLLX_BASE,
204 .misc_reg = PLLX_MISC,
205 .lock_mask = PLL_BASE_LOCK,
206 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
207 .lock_delay = 300,
208 .iddq_reg = PLLX_MISC3,
209 .iddq_bit_idx = 3,
210 .max_p = 6,
211 .dyn_ramp_reg = PLLX_MISC2,
212 .stepa_shift = 16,
213 .stepb_shift = 24,
214 .pdiv_tohw = pllxc_p,
215 .div_nmp = &pllxc_nmp,
216 .freq_table = pll_x_freq_table,
217 .flags = TEGRA_PLL_USE_LOCK,
218};
219
220static struct tegra_clk_pll_freq_table pll_c_freq_table[] = {
221 { 12000000, 624000000, 104, 1, 2},
222 { 12000000, 600000000, 100, 1, 2},
223 { 13000000, 600000000, 92, 1, 2}, /* actual: 598.0 MHz */
224 { 16800000, 600000000, 71, 1, 2}, /* actual: 596.4 MHz */
225 { 19200000, 600000000, 62, 1, 2}, /* actual: 595.2 MHz */
226 { 26000000, 600000000, 92, 2, 2}, /* actual: 598.0 MHz */
227 { 0, 0, 0, 0, 0, 0 },
228};
229
230static struct tegra_clk_pll_params pll_c_params = {
231 .input_min = 12000000,
232 .input_max = 800000000,
233 .cf_min = 12000000,
234 .cf_max = 19200000, /* s/w policy, h/w capability 50 MHz */
235 .vco_min = 600000000,
236 .vco_max = 1400000000,
237 .base_reg = PLLC_BASE,
238 .misc_reg = PLLC_MISC,
239 .lock_mask = PLL_BASE_LOCK,
240 .lock_enable_bit_idx = PLLC_MISC_LOCK_ENABLE,
241 .lock_delay = 300,
242 .iddq_reg = PLLC_MISC,
243 .iddq_bit_idx = PLLC_IDDQ_BIT,
244 .max_p = PLLXC_SW_MAX_P,
245 .dyn_ramp_reg = PLLC_MISC2,
246 .stepa_shift = 17,
247 .stepb_shift = 9,
248 .pdiv_tohw = pllxc_p,
249 .div_nmp = &pllxc_nmp,
250 .freq_table = pll_c_freq_table,
251 .flags = TEGRA_PLL_USE_LOCK,
252};
253
254static struct div_nmp pllcx_nmp = {
255 .divm_shift = 0,
256 .divm_width = 2,
257 .divn_shift = 8,
258 .divn_width = 8,
259 .divp_shift = 20,
260 .divp_width = 3,
261};
262
263static struct pdiv_map pllc_p[] = {
264 { .pdiv = 1, .hw_val = 0 },
265 { .pdiv = 2, .hw_val = 1 },
266 { .pdiv = 3, .hw_val = 2 },
267 { .pdiv = 4, .hw_val = 3 },
268 { .pdiv = 6, .hw_val = 4 },
269 { .pdiv = 8, .hw_val = 5 },
270 { .pdiv = 12, .hw_val = 6 },
271 { .pdiv = 16, .hw_val = 7 },
272 { .pdiv = 0, .hw_val = 0 },
273};
274
275static struct tegra_clk_pll_freq_table pll_cx_freq_table[] = {
276 {12000000, 600000000, 100, 1, 2},
277 {13000000, 600000000, 92, 1, 2}, /* actual: 598.0 MHz */
278 {16800000, 600000000, 71, 1, 2}, /* actual: 596.4 MHz */
279 {19200000, 600000000, 62, 1, 2}, /* actual: 595.2 MHz */
280 {26000000, 600000000, 92, 2, 2}, /* actual: 598.0 MHz */
281 {0, 0, 0, 0, 0, 0},
282};
283
284static struct tegra_clk_pll_params pll_c2_params = {
285 .input_min = 12000000,
286 .input_max = 48000000,
287 .cf_min = 12000000,
288 .cf_max = 19200000,
289 .vco_min = 600000000,
290 .vco_max = 1200000000,
291 .base_reg = PLLC2_BASE,
292 .misc_reg = PLLC2_MISC,
293 .lock_mask = PLL_BASE_LOCK,
294 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
295 .lock_delay = 300,
296 .pdiv_tohw = pllc_p,
297 .div_nmp = &pllcx_nmp,
298 .max_p = 7,
299 .ext_misc_reg[0] = 0x4f0,
300 .ext_misc_reg[1] = 0x4f4,
301 .ext_misc_reg[2] = 0x4f8,
302 .freq_table = pll_cx_freq_table,
303 .flags = TEGRA_PLL_USE_LOCK,
304};
305
306static struct tegra_clk_pll_params pll_c3_params = {
307 .input_min = 12000000,
308 .input_max = 48000000,
309 .cf_min = 12000000,
310 .cf_max = 19200000,
311 .vco_min = 600000000,
312 .vco_max = 1200000000,
313 .base_reg = PLLC3_BASE,
314 .misc_reg = PLLC3_MISC,
315 .lock_mask = PLL_BASE_LOCK,
316 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
317 .lock_delay = 300,
318 .pdiv_tohw = pllc_p,
319 .div_nmp = &pllcx_nmp,
320 .max_p = 7,
321 .ext_misc_reg[0] = 0x504,
322 .ext_misc_reg[1] = 0x508,
323 .ext_misc_reg[2] = 0x50c,
324 .freq_table = pll_cx_freq_table,
325 .flags = TEGRA_PLL_USE_LOCK,
326};
327
328static struct div_nmp pllss_nmp = {
329 .divm_shift = 0,
330 .divm_width = 8,
331 .divn_shift = 8,
332 .divn_width = 8,
333 .divp_shift = 20,
334 .divp_width = 4,
335};
336
337static struct pdiv_map pll12g_ssd_esd_p[] = {
338 { .pdiv = 1, .hw_val = 0 },
339 { .pdiv = 2, .hw_val = 1 },
340 { .pdiv = 3, .hw_val = 2 },
341 { .pdiv = 4, .hw_val = 3 },
342 { .pdiv = 5, .hw_val = 4 },
343 { .pdiv = 6, .hw_val = 5 },
344 { .pdiv = 8, .hw_val = 6 },
345 { .pdiv = 10, .hw_val = 7 },
346 { .pdiv = 12, .hw_val = 8 },
347 { .pdiv = 16, .hw_val = 9 },
348 { .pdiv = 12, .hw_val = 10 },
349 { .pdiv = 16, .hw_val = 11 },
350 { .pdiv = 20, .hw_val = 12 },
351 { .pdiv = 24, .hw_val = 13 },
352 { .pdiv = 32, .hw_val = 14 },
353 { .pdiv = 0, .hw_val = 0 },
354};
355
356static struct tegra_clk_pll_freq_table pll_c4_freq_table[] = {
357 { 12000000, 600000000, 100, 1, 1},
358 { 13000000, 600000000, 92, 1, 1}, /* actual: 598.0 MHz */
359 { 16800000, 600000000, 71, 1, 1}, /* actual: 596.4 MHz */
360 { 19200000, 600000000, 62, 1, 1}, /* actual: 595.2 MHz */
361 { 26000000, 600000000, 92, 2, 1}, /* actual: 598.0 MHz */
362 { 0, 0, 0, 0, 0, 0 },
363};
364
365static struct tegra_clk_pll_params pll_c4_params = {
366 .input_min = 12000000,
367 .input_max = 1000000000,
368 .cf_min = 12000000,
369 .cf_max = 19200000, /* s/w policy, h/w capability 38 MHz */
370 .vco_min = 600000000,
371 .vco_max = 1200000000,
372 .base_reg = PLLC4_BASE,
373 .misc_reg = PLLC4_MISC,
374 .lock_mask = PLL_BASE_LOCK,
375 .lock_enable_bit_idx = PLLSS_MISC_LOCK_ENABLE,
376 .lock_delay = 300,
377 .iddq_reg = PLLC4_BASE,
378 .iddq_bit_idx = PLLSS_IDDQ_BIT,
379 .pdiv_tohw = pll12g_ssd_esd_p,
380 .div_nmp = &pllss_nmp,
381 .ext_misc_reg[0] = 0x5ac,
382 .ext_misc_reg[1] = 0x5b0,
383 .ext_misc_reg[2] = 0x5b4,
384 .freq_table = pll_c4_freq_table,
385};
386
387static struct pdiv_map pllm_p[] = {
388 { .pdiv = 1, .hw_val = 0 },
389 { .pdiv = 2, .hw_val = 1 },
390 { .pdiv = 0, .hw_val = 0 },
391};
392
393static struct tegra_clk_pll_freq_table pll_m_freq_table[] = {
394 {12000000, 800000000, 66, 1, 1}, /* actual: 792.0 MHz */
395 {13000000, 800000000, 61, 1, 1}, /* actual: 793.0 MHz */
396 {16800000, 800000000, 47, 1, 1}, /* actual: 789.6 MHz */
397 {19200000, 800000000, 41, 1, 1}, /* actual: 787.2 MHz */
398 {26000000, 800000000, 61, 2, 1}, /* actual: 793.0 MHz */
399 {0, 0, 0, 0, 0, 0},
400};
401
402static struct div_nmp pllm_nmp = {
403 .divm_shift = 0,
404 .divm_width = 8,
405 .override_divm_shift = 0,
406 .divn_shift = 8,
407 .divn_width = 8,
408 .override_divn_shift = 8,
409 .divp_shift = 20,
410 .divp_width = 1,
411 .override_divp_shift = 27,
412};
413
414static struct tegra_clk_pll_params pll_m_params = {
415 .input_min = 12000000,
416 .input_max = 500000000,
417 .cf_min = 12000000,
418 .cf_max = 19200000, /* s/w policy, h/w capability 50 MHz */
419 .vco_min = 400000000,
420 .vco_max = 1066000000,
421 .base_reg = PLLM_BASE,
422 .misc_reg = PLLM_MISC,
423 .lock_mask = PLL_BASE_LOCK,
424 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
425 .lock_delay = 300,
426 .max_p = 2,
427 .pdiv_tohw = pllm_p,
428 .div_nmp = &pllm_nmp,
429 .pmc_divnm_reg = PMC_PLLM_WB0_OVERRIDE,
430 .pmc_divp_reg = PMC_PLLM_WB0_OVERRIDE_2,
431 .freq_table = pll_m_freq_table,
432 .flags = TEGRA_PLL_USE_LOCK,
433};
434
435static struct tegra_clk_pll_freq_table pll_e_freq_table[] = {
436 /* PLLE special case: use cpcon field to store cml divider value */
437 {336000000, 100000000, 100, 21, 16, 11},
438 {312000000, 100000000, 200, 26, 24, 13},
439 {13000000, 100000000, 200, 1, 26, 13},
440 {12000000, 100000000, 200, 1, 24, 13},
441 {0, 0, 0, 0, 0, 0},
442};
443
444static struct div_nmp plle_nmp = {
445 .divm_shift = 0,
446 .divm_width = 8,
447 .divn_shift = 8,
448 .divn_width = 8,
449 .divp_shift = 24,
450 .divp_width = 4,
451};
452
453static struct tegra_clk_pll_params pll_e_params = {
454 .input_min = 12000000,
455 .input_max = 1000000000,
456 .cf_min = 12000000,
457 .cf_max = 75000000,
458 .vco_min = 1600000000,
459 .vco_max = 2400000000U,
460 .base_reg = PLLE_BASE,
461 .misc_reg = PLLE_MISC,
462 .aux_reg = PLLE_AUX,
463 .lock_mask = PLLE_MISC_LOCK,
464 .lock_enable_bit_idx = PLLE_MISC_LOCK_ENABLE,
465 .lock_delay = 300,
466 .div_nmp = &plle_nmp,
467 .freq_table = pll_e_freq_table,
468 .flags = TEGRA_PLL_FIXED,
469 .fixed_rate = 100000000,
470};
471
472static const struct clk_div_table pll_re_div_table[] = {
473 { .val = 0, .div = 1 },
474 { .val = 1, .div = 2 },
475 { .val = 2, .div = 3 },
476 { .val = 3, .div = 4 },
477 { .val = 4, .div = 5 },
478 { .val = 5, .div = 6 },
479 { .val = 0, .div = 0 },
480};
481
482static struct div_nmp pllre_nmp = {
483 .divm_shift = 0,
484 .divm_width = 8,
485 .divn_shift = 8,
486 .divn_width = 8,
487 .divp_shift = 16,
488 .divp_width = 4,
489};
490
491static struct tegra_clk_pll_params pll_re_vco_params = {
492 .input_min = 12000000,
493 .input_max = 1000000000,
494 .cf_min = 12000000,
495 .cf_max = 19200000, /* s/w policy, h/w capability 38 MHz */
496 .vco_min = 300000000,
497 .vco_max = 600000000,
498 .base_reg = PLLRE_BASE,
499 .misc_reg = PLLRE_MISC,
500 .lock_mask = PLLRE_MISC_LOCK,
501 .lock_enable_bit_idx = PLLRE_MISC_LOCK_ENABLE,
502 .lock_delay = 300,
503 .iddq_reg = PLLRE_MISC,
504 .iddq_bit_idx = PLLRE_IDDQ_BIT,
505 .div_nmp = &pllre_nmp,
506 .flags = TEGRA_PLL_USE_LOCK,
507};
508
509static struct div_nmp pllp_nmp = {
510 .divm_shift = 0,
511 .divm_width = 5,
512 .divn_shift = 8,
513 .divn_width = 10,
514 .divp_shift = 20,
515 .divp_width = 3,
516};
517
518static struct tegra_clk_pll_freq_table pll_p_freq_table[] = {
519 {12000000, 216000000, 432, 12, 1, 8},
520 {13000000, 216000000, 432, 13, 1, 8},
521 {16800000, 216000000, 360, 14, 1, 8},
522 {19200000, 216000000, 360, 16, 1, 8},
523 {26000000, 216000000, 432, 26, 1, 8},
524 {0, 0, 0, 0, 0, 0},
525};
526
527static struct tegra_clk_pll_params pll_p_params = {
528 .input_min = 2000000,
529 .input_max = 31000000,
530 .cf_min = 1000000,
531 .cf_max = 6000000,
532 .vco_min = 200000000,
533 .vco_max = 700000000,
534 .base_reg = PLLP_BASE,
535 .misc_reg = PLLP_MISC,
536 .lock_mask = PLL_BASE_LOCK,
537 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
538 .lock_delay = 300,
539 .div_nmp = &pllp_nmp,
540 .freq_table = pll_p_freq_table,
541 .fixed_rate = 408000000,
542 .flags = TEGRA_PLL_FIXED | TEGRA_PLL_USE_LOCK,
543};
544
545static struct tegra_clk_pll_freq_table pll_a_freq_table[] = {
546 {9600000, 282240000, 147, 5, 0, 4},
547 {9600000, 368640000, 192, 5, 0, 4},
548 {9600000, 240000000, 200, 8, 0, 8},
549
550 {28800000, 282240000, 245, 25, 0, 8},
551 {28800000, 368640000, 320, 25, 0, 8},
552 {28800000, 240000000, 200, 24, 0, 8},
553 {0, 0, 0, 0, 0, 0},
554};
555
556static struct tegra_clk_pll_params pll_a_params = {
557 .input_min = 2000000,
558 .input_max = 31000000,
559 .cf_min = 1000000,
560 .cf_max = 6000000,
561 .vco_min = 200000000,
562 .vco_max = 700000000,
563 .base_reg = PLLA_BASE,
564 .misc_reg = PLLA_MISC,
565 .lock_mask = PLL_BASE_LOCK,
566 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
567 .lock_delay = 300,
568 .div_nmp = &pllp_nmp,
569 .freq_table = pll_a_freq_table,
570 .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_USE_LOCK,
571};
572
573static struct tegra_clk_pll_freq_table pll_d_freq_table[] = {
574 {12000000, 216000000, 864, 12, 4, 12},
575 {13000000, 216000000, 864, 13, 4, 12},
576 {16800000, 216000000, 720, 14, 4, 12},
577 {19200000, 216000000, 720, 16, 4, 12},
578 {26000000, 216000000, 864, 26, 4, 12},
579
580 {12000000, 594000000, 594, 12, 1, 12},
581 {13000000, 594000000, 594, 13, 1, 12},
582 {16800000, 594000000, 495, 14, 1, 12},
583 {19200000, 594000000, 495, 16, 1, 12},
584 {26000000, 594000000, 594, 26, 1, 12},
585
586 {12000000, 1000000000, 1000, 12, 1, 12},
587 {13000000, 1000000000, 1000, 13, 1, 12},
588 {19200000, 1000000000, 625, 12, 1, 12},
589 {26000000, 1000000000, 1000, 26, 1, 12},
590
591 {0, 0, 0, 0, 0, 0},
592};
593
594static struct tegra_clk_pll_params pll_d_params = {
595 .input_min = 2000000,
596 .input_max = 40000000,
597 .cf_min = 1000000,
598 .cf_max = 6000000,
599 .vco_min = 500000000,
600 .vco_max = 1000000000,
601 .base_reg = PLLD_BASE,
602 .misc_reg = PLLD_MISC,
603 .lock_mask = PLL_BASE_LOCK,
604 .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE,
605 .lock_delay = 1000,
606 .div_nmp = &pllp_nmp,
607 .freq_table = pll_d_freq_table,
608 .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON |
609 TEGRA_PLL_USE_LOCK,
610};
611
612static struct tegra_clk_pll_freq_table tegra124_pll_d2_freq_table[] = {
613 { 12000000, 148500000, 99, 1, 8},
614 { 12000000, 594000000, 99, 1, 1},
615 { 13000000, 594000000, 91, 1, 1}, /* actual: 591.5 MHz */
616 { 16800000, 594000000, 71, 1, 1}, /* actual: 596.4 MHz */
617 { 19200000, 594000000, 62, 1, 1}, /* actual: 595.2 MHz */
618 { 26000000, 594000000, 91, 2, 1}, /* actual: 591.5 MHz */
619 { 0, 0, 0, 0, 0, 0 },
620};
621
622static struct tegra_clk_pll_params tegra124_pll_d2_params = {
623 .input_min = 12000000,
624 .input_max = 1000000000,
625 .cf_min = 12000000,
626 .cf_max = 19200000, /* s/w policy, h/w capability 38 MHz */
627 .vco_min = 600000000,
628 .vco_max = 1200000000,
629 .base_reg = PLLD2_BASE,
630 .misc_reg = PLLD2_MISC,
631 .lock_mask = PLL_BASE_LOCK,
632 .lock_enable_bit_idx = PLLSS_MISC_LOCK_ENABLE,
633 .lock_delay = 300,
634 .iddq_reg = PLLD2_BASE,
635 .iddq_bit_idx = PLLSS_IDDQ_BIT,
636 .pdiv_tohw = pll12g_ssd_esd_p,
637 .div_nmp = &pllss_nmp,
638 .ext_misc_reg[0] = 0x570,
639 .ext_misc_reg[1] = 0x574,
640 .ext_misc_reg[2] = 0x578,
641 .max_p = 15,
642 .freq_table = tegra124_pll_d2_freq_table,
643};
644
645static struct tegra_clk_pll_freq_table pll_dp_freq_table[] = {
646 { 12000000, 600000000, 100, 1, 1},
647 { 13000000, 600000000, 92, 1, 1}, /* actual: 598.0 MHz */
648 { 16800000, 600000000, 71, 1, 1}, /* actual: 596.4 MHz */
649 { 19200000, 600000000, 62, 1, 1}, /* actual: 595.2 MHz */
650 { 26000000, 600000000, 92, 2, 1}, /* actual: 598.0 MHz */
651 { 0, 0, 0, 0, 0, 0 },
652};
653
654static struct tegra_clk_pll_params pll_dp_params = {
655 .input_min = 12000000,
656 .input_max = 1000000000,
657 .cf_min = 12000000,
658 .cf_max = 19200000, /* s/w policy, h/w capability 38 MHz */
659 .vco_min = 600000000,
660 .vco_max = 1200000000,
661 .base_reg = PLLDP_BASE,
662 .misc_reg = PLLDP_MISC,
663 .lock_mask = PLL_BASE_LOCK,
664 .lock_enable_bit_idx = PLLSS_MISC_LOCK_ENABLE,
665 .lock_delay = 300,
666 .iddq_reg = PLLDP_BASE,
667 .iddq_bit_idx = PLLSS_IDDQ_BIT,
668 .pdiv_tohw = pll12g_ssd_esd_p,
669 .div_nmp = &pllss_nmp,
670 .ext_misc_reg[0] = 0x598,
671 .ext_misc_reg[1] = 0x59c,
672 .ext_misc_reg[2] = 0x5a0,
673 .max_p = 5,
674 .freq_table = pll_dp_freq_table,
675};
676
677static struct pdiv_map pllu_p[] = {
678 { .pdiv = 1, .hw_val = 1 },
679 { .pdiv = 2, .hw_val = 0 },
680 { .pdiv = 0, .hw_val = 0 },
681};
682
683static struct div_nmp pllu_nmp = {
684 .divm_shift = 0,
685 .divm_width = 5,
686 .divn_shift = 8,
687 .divn_width = 10,
688 .divp_shift = 20,
689 .divp_width = 1,
690};
691
692static struct tegra_clk_pll_freq_table pll_u_freq_table[] = {
693 {12000000, 480000000, 960, 12, 2, 12},
694 {13000000, 480000000, 960, 13, 2, 12},
695 {16800000, 480000000, 400, 7, 2, 5},
696 {19200000, 480000000, 200, 4, 2, 3},
697 {26000000, 480000000, 960, 26, 2, 12},
698 {0, 0, 0, 0, 0, 0},
699};
700
701static struct tegra_clk_pll_params pll_u_params = {
702 .input_min = 2000000,
703 .input_max = 40000000,
704 .cf_min = 1000000,
705 .cf_max = 6000000,
706 .vco_min = 480000000,
707 .vco_max = 960000000,
708 .base_reg = PLLU_BASE,
709 .misc_reg = PLLU_MISC,
710 .lock_mask = PLL_BASE_LOCK,
711 .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE,
712 .lock_delay = 1000,
713 .pdiv_tohw = pllu_p,
714 .div_nmp = &pllu_nmp,
715 .freq_table = pll_u_freq_table,
716 .flags = TEGRA_PLLU | TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON |
717 TEGRA_PLL_USE_LOCK,
718};
719
720struct utmi_clk_param {
721 /* Oscillator Frequency in KHz */
722 u32 osc_frequency;
723 /* UTMIP PLL Enable Delay Count */
724 u8 enable_delay_count;
725 /* UTMIP PLL Stable count */
726 u8 stable_count;
727 /* UTMIP PLL Active delay count */
728 u8 active_delay_count;
729 /* UTMIP PLL Xtal frequency count */
730 u8 xtal_freq_count;
731};
732
733static const struct utmi_clk_param utmi_parameters[] = {
734 {.osc_frequency = 13000000, .enable_delay_count = 0x02,
735 .stable_count = 0x33, .active_delay_count = 0x05,
736 .xtal_freq_count = 0x7F},
737 {.osc_frequency = 19200000, .enable_delay_count = 0x03,
738 .stable_count = 0x4B, .active_delay_count = 0x06,
739 .xtal_freq_count = 0xBB},
740 {.osc_frequency = 12000000, .enable_delay_count = 0x02,
741 .stable_count = 0x2F, .active_delay_count = 0x04,
742 .xtal_freq_count = 0x76},
743 {.osc_frequency = 26000000, .enable_delay_count = 0x04,
744 .stable_count = 0x66, .active_delay_count = 0x09,
745 .xtal_freq_count = 0xFE},
746 {.osc_frequency = 16800000, .enable_delay_count = 0x03,
747 .stable_count = 0x41, .active_delay_count = 0x0A,
748 .xtal_freq_count = 0xA4},
749};
750
751static struct tegra_clk tegra124_clks[tegra_clk_max] __initdata = {
752 [tegra_clk_ispb] = { .dt_id = TEGRA124_CLK_ISPB, .present = true },
753 [tegra_clk_rtc] = { .dt_id = TEGRA124_CLK_RTC, .present = true },
754 [tegra_clk_timer] = { .dt_id = TEGRA124_CLK_TIMER, .present = true },
755 [tegra_clk_uarta] = { .dt_id = TEGRA124_CLK_UARTA, .present = true },
756 [tegra_clk_sdmmc2] = { .dt_id = TEGRA124_CLK_SDMMC2, .present = true },
757 [tegra_clk_i2s1] = { .dt_id = TEGRA124_CLK_I2S1, .present = true },
758 [tegra_clk_i2c1] = { .dt_id = TEGRA124_CLK_I2C1, .present = true },
759 [tegra_clk_ndflash] = { .dt_id = TEGRA124_CLK_NDFLASH, .present = true },
760 [tegra_clk_sdmmc1] = { .dt_id = TEGRA124_CLK_SDMMC1, .present = true },
761 [tegra_clk_sdmmc4] = { .dt_id = TEGRA124_CLK_SDMMC4, .present = true },
762 [tegra_clk_pwm] = { .dt_id = TEGRA124_CLK_PWM, .present = true },
763 [tegra_clk_i2s2] = { .dt_id = TEGRA124_CLK_I2S2, .present = true },
764 [tegra_clk_gr2d] = { .dt_id = TEGRA124_CLK_GR_2D, .present = true },
765 [tegra_clk_usbd] = { .dt_id = TEGRA124_CLK_USBD, .present = true },
766 [tegra_clk_isp_8] = { .dt_id = TEGRA124_CLK_ISP, .present = true },
767 [tegra_clk_gr3d] = { .dt_id = TEGRA124_CLK_GR_3D, .present = true },
768 [tegra_clk_disp2] = { .dt_id = TEGRA124_CLK_DISP2, .present = true },
769 [tegra_clk_disp1] = { .dt_id = TEGRA124_CLK_DISP1, .present = true },
770 [tegra_clk_host1x] = { .dt_id = TEGRA124_CLK_HOST1X, .present = true },
771 [tegra_clk_vcp] = { .dt_id = TEGRA124_CLK_VCP, .present = true },
772 [tegra_clk_i2s0] = { .dt_id = TEGRA124_CLK_I2S0, .present = true },
773 [tegra_clk_apbdma] = { .dt_id = TEGRA124_CLK_APBDMA, .present = true },
774 [tegra_clk_kbc] = { .dt_id = TEGRA124_CLK_KBC, .present = true },
775 [tegra_clk_kfuse] = { .dt_id = TEGRA124_CLK_KFUSE, .present = true },
776 [tegra_clk_sbc1] = { .dt_id = TEGRA124_CLK_SBC1, .present = true },
777 [tegra_clk_nor] = { .dt_id = TEGRA124_CLK_NOR, .present = true },
778 [tegra_clk_sbc2] = { .dt_id = TEGRA124_CLK_SBC2, .present = true },
779 [tegra_clk_sbc3] = { .dt_id = TEGRA124_CLK_SBC3, .present = true },
780 [tegra_clk_i2c5] = { .dt_id = TEGRA124_CLK_I2C5, .present = true },
781 [tegra_clk_dsia] = { .dt_id = TEGRA124_CLK_DSIA, .present = true },
782 [tegra_clk_mipi] = { .dt_id = TEGRA124_CLK_MIPI, .present = true },
783 [tegra_clk_hdmi] = { .dt_id = TEGRA124_CLK_HDMI, .present = true },
784 [tegra_clk_csi] = { .dt_id = TEGRA124_CLK_CSI, .present = true },
785 [tegra_clk_i2c2] = { .dt_id = TEGRA124_CLK_I2C2, .present = true },
786 [tegra_clk_uartc] = { .dt_id = TEGRA124_CLK_UARTC, .present = true },
787 [tegra_clk_mipi_cal] = { .dt_id = TEGRA124_CLK_MIPI_CAL, .present = true },
788 [tegra_clk_emc] = { .dt_id = TEGRA124_CLK_EMC, .present = true },
789 [tegra_clk_usb2] = { .dt_id = TEGRA124_CLK_USB2, .present = true },
790 [tegra_clk_usb3] = { .dt_id = TEGRA124_CLK_USB3, .present = true },
791 [tegra_clk_vde_8] = { .dt_id = TEGRA124_CLK_VDE, .present = true },
792 [tegra_clk_bsea] = { .dt_id = TEGRA124_CLK_BSEA, .present = true },
793 [tegra_clk_bsev] = { .dt_id = TEGRA124_CLK_BSEV, .present = true },
794 [tegra_clk_uartd] = { .dt_id = TEGRA124_CLK_UARTD, .present = true },
795 [tegra_clk_i2c3] = { .dt_id = TEGRA124_CLK_I2C3, .present = true },
796 [tegra_clk_sbc4] = { .dt_id = TEGRA124_CLK_SBC4, .present = true },
797 [tegra_clk_sdmmc3] = { .dt_id = TEGRA124_CLK_SDMMC3, .present = true },
798 [tegra_clk_pcie] = { .dt_id = TEGRA124_CLK_PCIE, .present = true },
799 [tegra_clk_owr] = { .dt_id = TEGRA124_CLK_OWR, .present = true },
800 [tegra_clk_afi] = { .dt_id = TEGRA124_CLK_AFI, .present = true },
801 [tegra_clk_csite] = { .dt_id = TEGRA124_CLK_CSITE, .present = true },
802 [tegra_clk_la] = { .dt_id = TEGRA124_CLK_LA, .present = true },
803 [tegra_clk_trace] = { .dt_id = TEGRA124_CLK_TRACE, .present = true },
804 [tegra_clk_soc_therm] = { .dt_id = TEGRA124_CLK_SOC_THERM, .present = true },
805 [tegra_clk_dtv] = { .dt_id = TEGRA124_CLK_DTV, .present = true },
806 [tegra_clk_ndspeed] = { .dt_id = TEGRA124_CLK_NDSPEED, .present = true },
807 [tegra_clk_i2cslow] = { .dt_id = TEGRA124_CLK_I2CSLOW, .present = true },
808 [tegra_clk_dsib] = { .dt_id = TEGRA124_CLK_DSIB, .present = true },
809 [tegra_clk_tsec] = { .dt_id = TEGRA124_CLK_TSEC, .present = true },
810 [tegra_clk_xusb_host] = { .dt_id = TEGRA124_CLK_XUSB_HOST, .present = true },
811 [tegra_clk_msenc] = { .dt_id = TEGRA124_CLK_MSENC, .present = true },
812 [tegra_clk_csus] = { .dt_id = TEGRA124_CLK_CSUS, .present = true },
813 [tegra_clk_mselect] = { .dt_id = TEGRA124_CLK_MSELECT, .present = true },
814 [tegra_clk_tsensor] = { .dt_id = TEGRA124_CLK_TSENSOR, .present = true },
815 [tegra_clk_i2s3] = { .dt_id = TEGRA124_CLK_I2S3, .present = true },
816 [tegra_clk_i2s4] = { .dt_id = TEGRA124_CLK_I2S4, .present = true },
817 [tegra_clk_i2c4] = { .dt_id = TEGRA124_CLK_I2C4, .present = true },
818 [tegra_clk_sbc5] = { .dt_id = TEGRA124_CLK_SBC5, .present = true },
819 [tegra_clk_sbc6] = { .dt_id = TEGRA124_CLK_SBC6, .present = true },
820 [tegra_clk_d_audio] = { .dt_id = TEGRA124_CLK_D_AUDIO, .present = true },
821 [tegra_clk_apbif] = { .dt_id = TEGRA124_CLK_APBIF, .present = true },
822 [tegra_clk_dam0] = { .dt_id = TEGRA124_CLK_DAM0, .present = true },
823 [tegra_clk_dam1] = { .dt_id = TEGRA124_CLK_DAM1, .present = true },
824 [tegra_clk_dam2] = { .dt_id = TEGRA124_CLK_DAM2, .present = true },
825 [tegra_clk_hda2codec_2x] = { .dt_id = TEGRA124_CLK_HDA2CODEC_2X, .present = true },
826 [tegra_clk_audio0_2x] = { .dt_id = TEGRA124_CLK_AUDIO0_2X, .present = true },
827 [tegra_clk_audio1_2x] = { .dt_id = TEGRA124_CLK_AUDIO1_2X, .present = true },
828 [tegra_clk_audio2_2x] = { .dt_id = TEGRA124_CLK_AUDIO2_2X, .present = true },
829 [tegra_clk_audio3_2x] = { .dt_id = TEGRA124_CLK_AUDIO3_2X, .present = true },
830 [tegra_clk_audio4_2x] = { .dt_id = TEGRA124_CLK_AUDIO4_2X, .present = true },
831 [tegra_clk_spdif_2x] = { .dt_id = TEGRA124_CLK_SPDIF_2X, .present = true },
832 [tegra_clk_actmon] = { .dt_id = TEGRA124_CLK_ACTMON, .present = true },
833 [tegra_clk_extern1] = { .dt_id = TEGRA124_CLK_EXTERN1, .present = true },
834 [tegra_clk_extern2] = { .dt_id = TEGRA124_CLK_EXTERN2, .present = true },
835 [tegra_clk_extern3] = { .dt_id = TEGRA124_CLK_EXTERN3, .present = true },
836 [tegra_clk_sata_oob] = { .dt_id = TEGRA124_CLK_SATA_OOB, .present = true },
837 [tegra_clk_sata] = { .dt_id = TEGRA124_CLK_SATA, .present = true },
838 [tegra_clk_hda] = { .dt_id = TEGRA124_CLK_HDA, .present = true },
839 [tegra_clk_se] = { .dt_id = TEGRA124_CLK_SE, .present = true },
840 [tegra_clk_hda2hdmi] = { .dt_id = TEGRA124_CLK_HDA2HDMI, .present = true },
841 [tegra_clk_sata_cold] = { .dt_id = TEGRA124_CLK_SATA_COLD, .present = true },
842 [tegra_clk_cilab] = { .dt_id = TEGRA124_CLK_CILAB, .present = true },
843 [tegra_clk_cilcd] = { .dt_id = TEGRA124_CLK_CILCD, .present = true },
844 [tegra_clk_cile] = { .dt_id = TEGRA124_CLK_CILE, .present = true },
845 [tegra_clk_dsialp] = { .dt_id = TEGRA124_CLK_DSIALP, .present = true },
846 [tegra_clk_dsiblp] = { .dt_id = TEGRA124_CLK_DSIBLP, .present = true },
847 [tegra_clk_entropy] = { .dt_id = TEGRA124_CLK_ENTROPY, .present = true },
848 [tegra_clk_dds] = { .dt_id = TEGRA124_CLK_DDS, .present = true },
849 [tegra_clk_dp2] = { .dt_id = TEGRA124_CLK_DP2, .present = true },
850 [tegra_clk_amx] = { .dt_id = TEGRA124_CLK_AMX, .present = true },
851 [tegra_clk_adx] = { .dt_id = TEGRA124_CLK_ADX, .present = true },
852 [tegra_clk_xusb_ss] = { .dt_id = TEGRA124_CLK_XUSB_SS, .present = true },
853 [tegra_clk_i2c6] = { .dt_id = TEGRA124_CLK_I2C6, .present = true },
854 [tegra_clk_vim2_clk] = { .dt_id = TEGRA124_CLK_VIM2_CLK, .present = true },
855 [tegra_clk_hdmi_audio] = { .dt_id = TEGRA124_CLK_HDMI_AUDIO, .present = true },
856 [tegra_clk_clk72Mhz] = { .dt_id = TEGRA124_CLK_CLK72MHZ, .present = true },
857 [tegra_clk_vic03] = { .dt_id = TEGRA124_CLK_VIC03, .present = true },
858 [tegra_clk_adx1] = { .dt_id = TEGRA124_CLK_ADX1, .present = true },
859 [tegra_clk_dpaux] = { .dt_id = TEGRA124_CLK_DPAUX, .present = true },
860 [tegra_clk_sor0] = { .dt_id = TEGRA124_CLK_SOR0, .present = true },
861 [tegra_clk_sor0_lvds] = { .dt_id = TEGRA124_CLK_SOR0_LVDS, .present = true },
862 [tegra_clk_gpu] = { .dt_id = TEGRA124_CLK_GPU, .present = true },
863 [tegra_clk_amx1] = { .dt_id = TEGRA124_CLK_AMX1, .present = true },
864 [tegra_clk_uartb] = { .dt_id = TEGRA124_CLK_UARTB, .present = true },
865 [tegra_clk_vfir] = { .dt_id = TEGRA124_CLK_VFIR, .present = true },
866 [tegra_clk_spdif_in] = { .dt_id = TEGRA124_CLK_SPDIF_IN, .present = true },
867 [tegra_clk_spdif_out] = { .dt_id = TEGRA124_CLK_SPDIF_OUT, .present = true },
868 [tegra_clk_vi_9] = { .dt_id = TEGRA124_CLK_VI, .present = true },
869 [tegra_clk_vi_sensor] = { .dt_id = TEGRA124_CLK_VI_SENSOR, .present = true },
870 [tegra_clk_fuse] = { .dt_id = TEGRA124_CLK_FUSE, .present = true },
871 [tegra_clk_fuse_burn] = { .dt_id = TEGRA124_CLK_FUSE_BURN, .present = true },
872 [tegra_clk_clk_32k] = { .dt_id = TEGRA124_CLK_CLK_32K, .present = true },
873 [tegra_clk_clk_m] = { .dt_id = TEGRA124_CLK_CLK_M, .present = true },
874 [tegra_clk_clk_m_div2] = { .dt_id = TEGRA124_CLK_CLK_M_DIV2, .present = true },
875 [tegra_clk_clk_m_div4] = { .dt_id = TEGRA124_CLK_CLK_M_DIV4, .present = true },
876 [tegra_clk_pll_ref] = { .dt_id = TEGRA124_CLK_PLL_REF, .present = true },
877 [tegra_clk_pll_c] = { .dt_id = TEGRA124_CLK_PLL_C, .present = true },
878 [tegra_clk_pll_c_out1] = { .dt_id = TEGRA124_CLK_PLL_C_OUT1, .present = true },
879 [tegra_clk_pll_c2] = { .dt_id = TEGRA124_CLK_PLL_C2, .present = true },
880 [tegra_clk_pll_c3] = { .dt_id = TEGRA124_CLK_PLL_C3, .present = true },
881 [tegra_clk_pll_m] = { .dt_id = TEGRA124_CLK_PLL_M, .present = true },
882 [tegra_clk_pll_m_out1] = { .dt_id = TEGRA124_CLK_PLL_M_OUT1, .present = true },
883 [tegra_clk_pll_p] = { .dt_id = TEGRA124_CLK_PLL_P, .present = true },
884 [tegra_clk_pll_p_out1] = { .dt_id = TEGRA124_CLK_PLL_P_OUT1, .present = true },
885 [tegra_clk_pll_p_out2] = { .dt_id = TEGRA124_CLK_PLL_P_OUT2, .present = true },
886 [tegra_clk_pll_p_out3] = { .dt_id = TEGRA124_CLK_PLL_P_OUT3, .present = true },
887 [tegra_clk_pll_p_out4] = { .dt_id = TEGRA124_CLK_PLL_P_OUT4, .present = true },
888 [tegra_clk_pll_a] = { .dt_id = TEGRA124_CLK_PLL_A, .present = true },
889 [tegra_clk_pll_a_out0] = { .dt_id = TEGRA124_CLK_PLL_A_OUT0, .present = true },
890 [tegra_clk_pll_d] = { .dt_id = TEGRA124_CLK_PLL_D, .present = true },
891 [tegra_clk_pll_d_out0] = { .dt_id = TEGRA124_CLK_PLL_D_OUT0, .present = true },
892 [tegra_clk_pll_d2] = { .dt_id = TEGRA124_CLK_PLL_D2, .present = true },
893 [tegra_clk_pll_d2_out0] = { .dt_id = TEGRA124_CLK_PLL_D2_OUT0, .present = true },
894 [tegra_clk_pll_u] = { .dt_id = TEGRA124_CLK_PLL_U, .present = true },
895 [tegra_clk_pll_u_480m] = { .dt_id = TEGRA124_CLK_PLL_U_480M, .present = true },
896 [tegra_clk_pll_u_60m] = { .dt_id = TEGRA124_CLK_PLL_U_60M, .present = true },
897 [tegra_clk_pll_u_48m] = { .dt_id = TEGRA124_CLK_PLL_U_48M, .present = true },
898 [tegra_clk_pll_u_12m] = { .dt_id = TEGRA124_CLK_PLL_U_12M, .present = true },
899 [tegra_clk_pll_x] = { .dt_id = TEGRA124_CLK_PLL_X, .present = true },
900 [tegra_clk_pll_x_out0] = { .dt_id = TEGRA124_CLK_PLL_X_OUT0, .present = true },
901 [tegra_clk_pll_re_vco] = { .dt_id = TEGRA124_CLK_PLL_RE_VCO, .present = true },
902 [tegra_clk_pll_re_out] = { .dt_id = TEGRA124_CLK_PLL_RE_OUT, .present = true },
903 [tegra_clk_spdif_in_sync] = { .dt_id = TEGRA124_CLK_SPDIF_IN_SYNC, .present = true },
904 [tegra_clk_i2s0_sync] = { .dt_id = TEGRA124_CLK_I2S0_SYNC, .present = true },
905 [tegra_clk_i2s1_sync] = { .dt_id = TEGRA124_CLK_I2S1_SYNC, .present = true },
906 [tegra_clk_i2s2_sync] = { .dt_id = TEGRA124_CLK_I2S2_SYNC, .present = true },
907 [tegra_clk_i2s3_sync] = { .dt_id = TEGRA124_CLK_I2S3_SYNC, .present = true },
908 [tegra_clk_i2s4_sync] = { .dt_id = TEGRA124_CLK_I2S4_SYNC, .present = true },
909 [tegra_clk_vimclk_sync] = { .dt_id = TEGRA124_CLK_VIMCLK_SYNC, .present = true },
910 [tegra_clk_audio0] = { .dt_id = TEGRA124_CLK_AUDIO0, .present = true },
911 [tegra_clk_audio1] = { .dt_id = TEGRA124_CLK_AUDIO1, .present = true },
912 [tegra_clk_audio2] = { .dt_id = TEGRA124_CLK_AUDIO2, .present = true },
913 [tegra_clk_audio3] = { .dt_id = TEGRA124_CLK_AUDIO3, .present = true },
914 [tegra_clk_audio4] = { .dt_id = TEGRA124_CLK_AUDIO4, .present = true },
915 [tegra_clk_spdif] = { .dt_id = TEGRA124_CLK_SPDIF, .present = true },
916 [tegra_clk_clk_out_1] = { .dt_id = TEGRA124_CLK_CLK_OUT_1, .present = true },
917 [tegra_clk_clk_out_2] = { .dt_id = TEGRA124_CLK_CLK_OUT_2, .present = true },
918 [tegra_clk_clk_out_3] = { .dt_id = TEGRA124_CLK_CLK_OUT_3, .present = true },
919 [tegra_clk_blink] = { .dt_id = TEGRA124_CLK_BLINK, .present = true },
920 [tegra_clk_xusb_host_src] = { .dt_id = TEGRA124_CLK_XUSB_HOST_SRC, .present = true },
921 [tegra_clk_xusb_falcon_src] = { .dt_id = TEGRA124_CLK_XUSB_FALCON_SRC, .present = true },
922 [tegra_clk_xusb_fs_src] = { .dt_id = TEGRA124_CLK_XUSB_FS_SRC, .present = true },
923 [tegra_clk_xusb_ss_src] = { .dt_id = TEGRA124_CLK_XUSB_SS_SRC, .present = true },
924 [tegra_clk_xusb_dev_src] = { .dt_id = TEGRA124_CLK_XUSB_DEV_SRC, .present = true },
925 [tegra_clk_xusb_dev] = { .dt_id = TEGRA124_CLK_XUSB_DEV, .present = true },
926 [tegra_clk_xusb_hs_src] = { .dt_id = TEGRA124_CLK_XUSB_HS_SRC, .present = true },
927 [tegra_clk_sclk] = { .dt_id = TEGRA124_CLK_SCLK, .present = true },
928 [tegra_clk_hclk] = { .dt_id = TEGRA124_CLK_HCLK, .present = true },
929 [tegra_clk_pclk] = { .dt_id = TEGRA124_CLK_PCLK, .present = true },
930 [tegra_clk_cclk_g] = { .dt_id = TEGRA124_CLK_CCLK_G, .present = true },
931 [tegra_clk_cclk_lp] = { .dt_id = TEGRA124_CLK_CCLK_LP, .present = true },
932 [tegra_clk_dfll_ref] = { .dt_id = TEGRA124_CLK_DFLL_REF, .present = true },
933 [tegra_clk_dfll_soc] = { .dt_id = TEGRA124_CLK_DFLL_SOC, .present = true },
934 [tegra_clk_vi_sensor2] = { .dt_id = TEGRA124_CLK_VI_SENSOR2, .present = true },
935 [tegra_clk_pll_p_out5] = { .dt_id = TEGRA124_CLK_PLL_P_OUT5, .present = true },
936 [tegra_clk_pll_c4] = { .dt_id = TEGRA124_CLK_PLL_C4, .present = true },
937 [tegra_clk_pll_dp] = { .dt_id = TEGRA124_CLK_PLL_DP, .present = true },
938 [tegra_clk_audio0_mux] = { .dt_id = TEGRA124_CLK_AUDIO0_MUX, .present = true },
939 [tegra_clk_audio1_mux] = { .dt_id = TEGRA124_CLK_AUDIO1_MUX, .present = true },
940 [tegra_clk_audio2_mux] = { .dt_id = TEGRA124_CLK_AUDIO2_MUX, .present = true },
941 [tegra_clk_audio3_mux] = { .dt_id = TEGRA124_CLK_AUDIO3_MUX, .present = true },
942 [tegra_clk_audio4_mux] = { .dt_id = TEGRA124_CLK_AUDIO4_MUX, .present = true },
943 [tegra_clk_spdif_mux] = { .dt_id = TEGRA124_CLK_SPDIF_MUX, .present = true },
944 [tegra_clk_clk_out_1_mux] = { .dt_id = TEGRA124_CLK_CLK_OUT_1_MUX, .present = true },
945 [tegra_clk_clk_out_2_mux] = { .dt_id = TEGRA124_CLK_CLK_OUT_2_MUX, .present = true },
946 [tegra_clk_clk_out_3_mux] = { .dt_id = TEGRA124_CLK_CLK_OUT_3_MUX, .present = true },
947 [tegra_clk_dsia_mux] = { .dt_id = TEGRA124_CLK_DSIA_MUX, .present = true },
948 [tegra_clk_dsib_mux] = { .dt_id = TEGRA124_CLK_DSIB_MUX, .present = true },
949 [tegra_clk_uarte] = { .dt_id = TEGRA124_CLK_UARTE, .present = true },
950};
951
952static struct tegra_devclk devclks[] __initdata = {
953 { .con_id = "clk_m", .dt_id = TEGRA124_CLK_CLK_M },
954 { .con_id = "pll_ref", .dt_id = TEGRA124_CLK_PLL_REF },
955 { .con_id = "clk_32k", .dt_id = TEGRA124_CLK_CLK_32K },
956 { .con_id = "clk_m_div2", .dt_id = TEGRA124_CLK_CLK_M_DIV2 },
957 { .con_id = "clk_m_div4", .dt_id = TEGRA124_CLK_CLK_M_DIV4 },
958 { .con_id = "pll_c", .dt_id = TEGRA124_CLK_PLL_C },
959 { .con_id = "pll_c_out1", .dt_id = TEGRA124_CLK_PLL_C_OUT1 },
960 { .con_id = "pll_c2", .dt_id = TEGRA124_CLK_PLL_C2 },
961 { .con_id = "pll_c3", .dt_id = TEGRA124_CLK_PLL_C3 },
962 { .con_id = "pll_p", .dt_id = TEGRA124_CLK_PLL_P },
963 { .con_id = "pll_p_out1", .dt_id = TEGRA124_CLK_PLL_P_OUT1 },
964 { .con_id = "pll_p_out2", .dt_id = TEGRA124_CLK_PLL_P_OUT2 },
965 { .con_id = "pll_p_out3", .dt_id = TEGRA124_CLK_PLL_P_OUT3 },
966 { .con_id = "pll_p_out4", .dt_id = TEGRA124_CLK_PLL_P_OUT4 },
967 { .con_id = "pll_m", .dt_id = TEGRA124_CLK_PLL_M },
968 { .con_id = "pll_m_out1", .dt_id = TEGRA124_CLK_PLL_M_OUT1 },
969 { .con_id = "pll_x", .dt_id = TEGRA124_CLK_PLL_X },
970 { .con_id = "pll_x_out0", .dt_id = TEGRA124_CLK_PLL_X_OUT0 },
971 { .con_id = "pll_u", .dt_id = TEGRA124_CLK_PLL_U },
972 { .con_id = "pll_u_480M", .dt_id = TEGRA124_CLK_PLL_U_480M },
973 { .con_id = "pll_u_60M", .dt_id = TEGRA124_CLK_PLL_U_60M },
974 { .con_id = "pll_u_48M", .dt_id = TEGRA124_CLK_PLL_U_48M },
975 { .con_id = "pll_u_12M", .dt_id = TEGRA124_CLK_PLL_U_12M },
976 { .con_id = "pll_d", .dt_id = TEGRA124_CLK_PLL_D },
977 { .con_id = "pll_d_out0", .dt_id = TEGRA124_CLK_PLL_D_OUT0 },
978 { .con_id = "pll_d2", .dt_id = TEGRA124_CLK_PLL_D2 },
979 { .con_id = "pll_d2_out0", .dt_id = TEGRA124_CLK_PLL_D2_OUT0 },
980 { .con_id = "pll_a", .dt_id = TEGRA124_CLK_PLL_A },
981 { .con_id = "pll_a_out0", .dt_id = TEGRA124_CLK_PLL_A_OUT0 },
982 { .con_id = "pll_re_vco", .dt_id = TEGRA124_CLK_PLL_RE_VCO },
983 { .con_id = "pll_re_out", .dt_id = TEGRA124_CLK_PLL_RE_OUT },
984 { .con_id = "spdif_in_sync", .dt_id = TEGRA124_CLK_SPDIF_IN_SYNC },
985 { .con_id = "i2s0_sync", .dt_id = TEGRA124_CLK_I2S0_SYNC },
986 { .con_id = "i2s1_sync", .dt_id = TEGRA124_CLK_I2S1_SYNC },
987 { .con_id = "i2s2_sync", .dt_id = TEGRA124_CLK_I2S2_SYNC },
988 { .con_id = "i2s3_sync", .dt_id = TEGRA124_CLK_I2S3_SYNC },
989 { .con_id = "i2s4_sync", .dt_id = TEGRA124_CLK_I2S4_SYNC },
990 { .con_id = "vimclk_sync", .dt_id = TEGRA124_CLK_VIMCLK_SYNC },
991 { .con_id = "audio0", .dt_id = TEGRA124_CLK_AUDIO0 },
992 { .con_id = "audio1", .dt_id = TEGRA124_CLK_AUDIO1 },
993 { .con_id = "audio2", .dt_id = TEGRA124_CLK_AUDIO2 },
994 { .con_id = "audio3", .dt_id = TEGRA124_CLK_AUDIO3 },
995 { .con_id = "audio4", .dt_id = TEGRA124_CLK_AUDIO4 },
996 { .con_id = "spdif", .dt_id = TEGRA124_CLK_SPDIF },
997 { .con_id = "audio0_2x", .dt_id = TEGRA124_CLK_AUDIO0_2X },
998 { .con_id = "audio1_2x", .dt_id = TEGRA124_CLK_AUDIO1_2X },
999 { .con_id = "audio2_2x", .dt_id = TEGRA124_CLK_AUDIO2_2X },
1000 { .con_id = "audio3_2x", .dt_id = TEGRA124_CLK_AUDIO3_2X },
1001 { .con_id = "audio4_2x", .dt_id = TEGRA124_CLK_AUDIO4_2X },
1002 { .con_id = "spdif_2x", .dt_id = TEGRA124_CLK_SPDIF_2X },
1003 { .con_id = "extern1", .dev_id = "clk_out_1", .dt_id = TEGRA124_CLK_EXTERN1 },
1004 { .con_id = "extern2", .dev_id = "clk_out_2", .dt_id = TEGRA124_CLK_EXTERN2 },
1005 { .con_id = "extern3", .dev_id = "clk_out_3", .dt_id = TEGRA124_CLK_EXTERN3 },
1006 { .con_id = "blink", .dt_id = TEGRA124_CLK_BLINK },
1007 { .con_id = "cclk_g", .dt_id = TEGRA124_CLK_CCLK_G },
1008 { .con_id = "cclk_lp", .dt_id = TEGRA124_CLK_CCLK_LP },
1009 { .con_id = "sclk", .dt_id = TEGRA124_CLK_SCLK },
1010 { .con_id = "hclk", .dt_id = TEGRA124_CLK_HCLK },
1011 { .con_id = "pclk", .dt_id = TEGRA124_CLK_PCLK },
1012 { .con_id = "fuse", .dt_id = TEGRA124_CLK_FUSE },
1013 { .dev_id = "rtc-tegra", .dt_id = TEGRA124_CLK_RTC },
1014 { .dev_id = "timer", .dt_id = TEGRA124_CLK_TIMER },
1015};
1016
1017static struct clk **clks;
1018
1019static void tegra124_utmi_param_configure(void __iomem *clk_base)
1020{
1021 u32 reg;
1022 int i;
1023
1024 for (i = 0; i < ARRAY_SIZE(utmi_parameters); i++) {
1025 if (osc_freq == utmi_parameters[i].osc_frequency)
1026 break;
1027 }
1028
1029 if (i >= ARRAY_SIZE(utmi_parameters)) {
1030 pr_err("%s: Unexpected oscillator freq %lu\n", __func__,
1031 osc_freq);
1032 return;
1033 }
1034
1035 reg = readl_relaxed(clk_base + UTMIP_PLL_CFG2);
1036
1037 /* Program UTMIP PLL stable and active counts */
1038 /* [FIXME] arclk_rst.h says WRONG! This should be 1ms -> 0x50 Check! */
1039 reg &= ~UTMIP_PLL_CFG2_STABLE_COUNT(~0);
1040 reg |= UTMIP_PLL_CFG2_STABLE_COUNT(utmi_parameters[i].stable_count);
1041
1042 reg &= ~UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(~0);
1043
1044 reg |= UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(utmi_parameters[i].
1045 active_delay_count);
1046
1047 /* Remove power downs from UTMIP PLL control bits */
1048 reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_A_POWERDOWN;
1049 reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_B_POWERDOWN;
1050 reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_C_POWERDOWN;
1051
1052 writel_relaxed(reg, clk_base + UTMIP_PLL_CFG2);
1053
1054 /* Program UTMIP PLL delay and oscillator frequency counts */
1055 reg = readl_relaxed(clk_base + UTMIP_PLL_CFG1);
1056 reg &= ~UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(~0);
1057
1058 reg |= UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(utmi_parameters[i].
1059 enable_delay_count);
1060
1061 reg &= ~UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(~0);
1062 reg |= UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(utmi_parameters[i].
1063 xtal_freq_count);
1064
1065 /* Remove power downs from UTMIP PLL control bits */
1066 reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN;
1067 reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ACTIVE_POWERDOWN;
1068 reg &= ~UTMIP_PLL_CFG1_FORCE_PLLU_POWERUP;
1069 reg &= ~UTMIP_PLL_CFG1_FORCE_PLLU_POWERDOWN;
1070 writel_relaxed(reg, clk_base + UTMIP_PLL_CFG1);
1071
1072 /* Setup HW control of UTMIPLL */
1073 reg = readl_relaxed(clk_base + UTMIPLL_HW_PWRDN_CFG0);
1074 reg |= UTMIPLL_HW_PWRDN_CFG0_USE_LOCKDET;
1075 reg &= ~UTMIPLL_HW_PWRDN_CFG0_CLK_ENABLE_SWCTL;
1076 reg |= UTMIPLL_HW_PWRDN_CFG0_SEQ_START_STATE;
1077 writel_relaxed(reg, clk_base + UTMIPLL_HW_PWRDN_CFG0);
1078
1079 reg = readl_relaxed(clk_base + UTMIP_PLL_CFG1);
1080 reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERUP;
1081 reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN;
1082 writel_relaxed(reg, clk_base + UTMIP_PLL_CFG1);
1083
1084 udelay(1);
1085
1086 /* Setup SW override of UTMIPLL assuming USB2.0
1087 ports are assigned to USB2 */
1088 reg = readl_relaxed(clk_base + UTMIPLL_HW_PWRDN_CFG0);
1089 reg |= UTMIPLL_HW_PWRDN_CFG0_IDDQ_SWCTL;
1090 reg &= ~UTMIPLL_HW_PWRDN_CFG0_IDDQ_OVERRIDE;
1091 writel_relaxed(reg, clk_base + UTMIPLL_HW_PWRDN_CFG0);
1092
1093 udelay(1);
1094
1095 /* Enable HW control UTMIPLL */
1096 reg = readl_relaxed(clk_base + UTMIPLL_HW_PWRDN_CFG0);
1097 reg |= UTMIPLL_HW_PWRDN_CFG0_SEQ_ENABLE;
1098 writel_relaxed(reg, clk_base + UTMIPLL_HW_PWRDN_CFG0);
1099}
1100
1101static __init void tegra124_periph_clk_init(void __iomem *clk_base,
1102 void __iomem *pmc_base)
1103{
1104 struct clk *clk;
1105 u32 val;
1106
1107 /* xusb_hs_src */
1108 val = readl(clk_base + CLK_SOURCE_XUSB_SS_SRC);
1109 val |= BIT(25); /* always select PLLU_60M */
1110 writel(val, clk_base + CLK_SOURCE_XUSB_SS_SRC);
1111
1112 clk = clk_register_fixed_factor(NULL, "xusb_hs_src", "pll_u_60M", 0,
1113 1, 1);
1114 clks[TEGRA124_CLK_XUSB_HS_SRC] = clk;
1115
1116 /* dsia mux */
1117 clk = clk_register_mux(NULL, "dsia_mux", mux_plld_out0_plld2_out0,
1118 ARRAY_SIZE(mux_plld_out0_plld2_out0), 0,
1119 clk_base + PLLD_BASE, 25, 1, 0, &pll_d_lock);
1120 clks[TEGRA124_CLK_DSIA_MUX] = clk;
1121
1122 /* dsib mux */
1123 clk = clk_register_mux(NULL, "dsib_mux", mux_plld_out0_plld2_out0,
1124 ARRAY_SIZE(mux_plld_out0_plld2_out0), 0,
1125 clk_base + PLLD2_BASE, 25, 1, 0, &pll_d2_lock);
1126 clks[TEGRA124_CLK_DSIB_MUX] = clk;
1127
1128 /* emc mux */
1129 clk = clk_register_mux(NULL, "emc_mux", mux_pllmcp_clkm,
1130 ARRAY_SIZE(mux_pllmcp_clkm), 0,
1131 clk_base + CLK_SOURCE_EMC,
1132 29, 3, 0, NULL);
1133
1134 /* cml0 */
1135 clk = clk_register_gate(NULL, "cml0", "pll_e", 0, clk_base + PLLE_AUX,
1136 0, 0, &pll_e_lock);
1137 clk_register_clkdev(clk, "cml0", NULL);
1138 clks[TEGRA124_CLK_CML0] = clk;
1139
1140 /* cml1 */
1141 clk = clk_register_gate(NULL, "cml1", "pll_e", 0, clk_base + PLLE_AUX,
1142 1, 0, &pll_e_lock);
1143 clk_register_clkdev(clk, "cml1", NULL);
1144 clks[TEGRA124_CLK_CML1] = clk;
1145
1146 tegra_periph_clk_init(clk_base, pmc_base, tegra124_clks, &pll_p_params);
1147}
1148
1149static void __init tegra124_pll_init(void __iomem *clk_base,
1150 void __iomem *pmc)
1151{
1152 u32 val;
1153 struct clk *clk;
1154
1155 /* PLLC */
1156 clk = tegra_clk_register_pllxc("pll_c", "pll_ref", clk_base,
1157 pmc, 0, &pll_c_params, NULL);
1158 clk_register_clkdev(clk, "pll_c", NULL);
1159 clks[TEGRA124_CLK_PLL_C] = clk;
1160
1161 /* PLLC_OUT1 */
1162 clk = tegra_clk_register_divider("pll_c_out1_div", "pll_c",
1163 clk_base + PLLC_OUT, 0, TEGRA_DIVIDER_ROUND_UP,
1164 8, 8, 1, NULL);
1165 clk = tegra_clk_register_pll_out("pll_c_out1", "pll_c_out1_div",
1166 clk_base + PLLC_OUT, 1, 0,
1167 CLK_SET_RATE_PARENT, 0, NULL);
1168 clk_register_clkdev(clk, "pll_c_out1", NULL);
1169 clks[TEGRA124_CLK_PLL_C_OUT1] = clk;
1170
1171 /* PLLC2 */
1172 clk = tegra_clk_register_pllc("pll_c2", "pll_ref", clk_base, pmc, 0,
1173 &pll_c2_params, NULL);
1174 clk_register_clkdev(clk, "pll_c2", NULL);
1175 clks[TEGRA124_CLK_PLL_C2] = clk;
1176
1177 /* PLLC3 */
1178 clk = tegra_clk_register_pllc("pll_c3", "pll_ref", clk_base, pmc, 0,
1179 &pll_c3_params, NULL);
1180 clk_register_clkdev(clk, "pll_c3", NULL);
1181 clks[TEGRA124_CLK_PLL_C3] = clk;
1182
1183 /* PLLM */
1184 clk = tegra_clk_register_pllm("pll_m", "pll_ref", clk_base, pmc,
1185 CLK_IGNORE_UNUSED | CLK_SET_RATE_GATE,
1186 &pll_m_params, NULL);
1187 clk_register_clkdev(clk, "pll_m", NULL);
1188 clks[TEGRA124_CLK_PLL_M] = clk;
1189
1190 /* PLLM_OUT1 */
1191 clk = tegra_clk_register_divider("pll_m_out1_div", "pll_m",
1192 clk_base + PLLM_OUT, 0, TEGRA_DIVIDER_ROUND_UP,
1193 8, 8, 1, NULL);
1194 clk = tegra_clk_register_pll_out("pll_m_out1", "pll_m_out1_div",
1195 clk_base + PLLM_OUT, 1, 0, CLK_IGNORE_UNUSED |
1196 CLK_SET_RATE_PARENT, 0, NULL);
1197 clk_register_clkdev(clk, "pll_m_out1", NULL);
1198 clks[TEGRA124_CLK_PLL_M_OUT1] = clk;
1199
1200 /* PLLM_UD */
1201 clk = clk_register_fixed_factor(NULL, "pll_m_ud", "pll_m",
1202 CLK_SET_RATE_PARENT, 1, 1);
1203
1204 /* PLLU */
1205 val = readl(clk_base + pll_u_params.base_reg);
1206 val &= ~BIT(24); /* disable PLLU_OVERRIDE */
1207 writel(val, clk_base + pll_u_params.base_reg);
1208
1209 clk = tegra_clk_register_pll("pll_u", "pll_ref", clk_base, pmc, 0,
1210 &pll_u_params, &pll_u_lock);
1211 clk_register_clkdev(clk, "pll_u", NULL);
1212 clks[TEGRA124_CLK_PLL_U] = clk;
1213
1214 tegra124_utmi_param_configure(clk_base);
1215
1216 /* PLLU_480M */
1217 clk = clk_register_gate(NULL, "pll_u_480M", "pll_u",
1218 CLK_SET_RATE_PARENT, clk_base + PLLU_BASE,
1219 22, 0, &pll_u_lock);
1220 clk_register_clkdev(clk, "pll_u_480M", NULL);
1221 clks[TEGRA124_CLK_PLL_U_480M] = clk;
1222
1223 /* PLLU_60M */
1224 clk = clk_register_fixed_factor(NULL, "pll_u_60M", "pll_u",
1225 CLK_SET_RATE_PARENT, 1, 8);
1226 clk_register_clkdev(clk, "pll_u_60M", NULL);
1227 clks[TEGRA124_CLK_PLL_U_60M] = clk;
1228
1229 /* PLLU_48M */
1230 clk = clk_register_fixed_factor(NULL, "pll_u_48M", "pll_u",
1231 CLK_SET_RATE_PARENT, 1, 10);
1232 clk_register_clkdev(clk, "pll_u_48M", NULL);
1233 clks[TEGRA124_CLK_PLL_U_48M] = clk;
1234
1235 /* PLLU_12M */
1236 clk = clk_register_fixed_factor(NULL, "pll_u_12M", "pll_u",
1237 CLK_SET_RATE_PARENT, 1, 40);
1238 clk_register_clkdev(clk, "pll_u_12M", NULL);
1239 clks[TEGRA124_CLK_PLL_U_12M] = clk;
1240
1241 /* PLLD */
1242 clk = tegra_clk_register_pll("pll_d", "pll_ref", clk_base, pmc, 0,
1243 &pll_d_params, &pll_d_lock);
1244 clk_register_clkdev(clk, "pll_d", NULL);
1245 clks[TEGRA124_CLK_PLL_D] = clk;
1246
1247 /* PLLD_OUT0 */
1248 clk = clk_register_fixed_factor(NULL, "pll_d_out0", "pll_d",
1249 CLK_SET_RATE_PARENT, 1, 2);
1250 clk_register_clkdev(clk, "pll_d_out0", NULL);
1251 clks[TEGRA124_CLK_PLL_D_OUT0] = clk;
1252
1253 /* PLLRE */
1254 clk = tegra_clk_register_pllre("pll_re_vco", "pll_ref", clk_base, pmc,
1255 0, &pll_re_vco_params, &pll_re_lock, pll_ref_freq);
1256 clk_register_clkdev(clk, "pll_re_vco", NULL);
1257 clks[TEGRA124_CLK_PLL_RE_VCO] = clk;
1258
1259 clk = clk_register_divider_table(NULL, "pll_re_out", "pll_re_vco", 0,
1260 clk_base + PLLRE_BASE, 16, 4, 0,
1261 pll_re_div_table, &pll_re_lock);
1262 clk_register_clkdev(clk, "pll_re_out", NULL);
1263 clks[TEGRA124_CLK_PLL_RE_OUT] = clk;
1264
1265 /* PLLE */
1266 clk = tegra_clk_register_plle_tegra114("pll_e", "pll_ref",
1267 clk_base, 0, &pll_e_params, NULL);
1268 clk_register_clkdev(clk, "pll_e", NULL);
1269 clks[TEGRA124_CLK_PLL_E] = clk;
1270
1271 /* PLLC4 */
1272 clk = tegra_clk_register_pllss("pll_c4", "pll_ref", clk_base, 0,
1273 &pll_c4_params, NULL);
1274 clk_register_clkdev(clk, "pll_c4", NULL);
1275 clks[TEGRA124_CLK_PLL_C4] = clk;
1276
1277 /* PLLDP */
1278 clk = tegra_clk_register_pllss("pll_dp", "pll_ref", clk_base, 0,
1279 &pll_dp_params, NULL);
1280 clk_register_clkdev(clk, "pll_dp", NULL);
1281 clks[TEGRA124_CLK_PLL_DP] = clk;
1282
1283 /* PLLD2 */
1284 clk = tegra_clk_register_pllss("pll_d2", "pll_ref", clk_base, 0,
1285 &tegra124_pll_d2_params, NULL);
1286 clk_register_clkdev(clk, "pll_d2", NULL);
1287 clks[TEGRA124_CLK_PLL_D2] = clk;
1288
1289 /* PLLD2_OUT0 ?? */
1290 clk = clk_register_fixed_factor(NULL, "pll_d2_out0", "pll_d2",
1291 CLK_SET_RATE_PARENT, 1, 2);
1292 clk_register_clkdev(clk, "pll_d2_out0", NULL);
1293 clks[TEGRA124_CLK_PLL_D2_OUT0] = clk;
1294
1295}
1296
1297/* Tegra124 CPU clock and reset control functions */
1298static void tegra124_wait_cpu_in_reset(u32 cpu)
1299{
1300 unsigned int reg;
1301
1302 do {
1303 reg = readl(clk_base + CLK_RST_CONTROLLER_CPU_CMPLX_STATUS);
1304 cpu_relax();
1305 } while (!(reg & (1 << cpu))); /* check CPU been reset or not */
1306}
1307
1308static void tegra124_disable_cpu_clock(u32 cpu)
1309{
1310 /* flow controller would take care in the power sequence. */
1311}
1312
1313#ifdef CONFIG_PM_SLEEP
1314static void tegra124_cpu_clock_suspend(void)
1315{
1316 /* switch coresite to clk_m, save off original source */
1317 tegra124_cpu_clk_sctx.clk_csite_src =
1318 readl(clk_base + CLK_SOURCE_CSITE);
1319 writel(3 << 30, clk_base + CLK_SOURCE_CSITE);
1320}
1321
1322static void tegra124_cpu_clock_resume(void)
1323{
1324 writel(tegra124_cpu_clk_sctx.clk_csite_src,
1325 clk_base + CLK_SOURCE_CSITE);
1326}
1327#endif
1328
1329static struct tegra_cpu_car_ops tegra124_cpu_car_ops = {
1330 .wait_for_reset = tegra124_wait_cpu_in_reset,
1331 .disable_clock = tegra124_disable_cpu_clock,
1332#ifdef CONFIG_PM_SLEEP
1333 .suspend = tegra124_cpu_clock_suspend,
1334 .resume = tegra124_cpu_clock_resume,
1335#endif
1336};
1337
1338static const struct of_device_id pmc_match[] __initconst = {
1339 { .compatible = "nvidia,tegra124-pmc" },
1340 {},
1341};
1342
1343static struct tegra_clk_init_table init_table[] __initdata = {
1344 {TEGRA124_CLK_UARTA, TEGRA124_CLK_PLL_P, 408000000, 0},
1345 {TEGRA124_CLK_UARTB, TEGRA124_CLK_PLL_P, 408000000, 0},
1346 {TEGRA124_CLK_UARTC, TEGRA124_CLK_PLL_P, 408000000, 0},
1347 {TEGRA124_CLK_UARTD, TEGRA124_CLK_PLL_P, 408000000, 0},
1348 {TEGRA124_CLK_PLL_A, TEGRA124_CLK_CLK_MAX, 564480000, 1},
1349 {TEGRA124_CLK_PLL_A_OUT0, TEGRA124_CLK_CLK_MAX, 11289600, 1},
1350 {TEGRA124_CLK_EXTERN1, TEGRA124_CLK_PLL_A_OUT0, 0, 1},
1351 {TEGRA124_CLK_CLK_OUT_1_MUX, TEGRA124_CLK_EXTERN1, 0, 1},
1352 {TEGRA124_CLK_CLK_OUT_1, TEGRA124_CLK_CLK_MAX, 0, 1},
1353 {TEGRA124_CLK_I2S0, TEGRA124_CLK_PLL_A_OUT0, 11289600, 0},
1354 {TEGRA124_CLK_I2S1, TEGRA124_CLK_PLL_A_OUT0, 11289600, 0},
1355 {TEGRA124_CLK_I2S2, TEGRA124_CLK_PLL_A_OUT0, 11289600, 0},
1356 {TEGRA124_CLK_I2S3, TEGRA124_CLK_PLL_A_OUT0, 11289600, 0},
1357 {TEGRA124_CLK_I2S4, TEGRA124_CLK_PLL_A_OUT0, 11289600, 0},
1358 {TEGRA124_CLK_VDE, TEGRA124_CLK_PLL_P, 0, 0},
1359 {TEGRA124_CLK_HOST1X, TEGRA124_CLK_PLL_P, 136000000, 1},
1360 {TEGRA124_CLK_SCLK, TEGRA124_CLK_PLL_P_OUT2, 102000000, 1},
1361 {TEGRA124_CLK_DFLL_SOC, TEGRA124_CLK_PLL_P, 51000000, 1},
1362 {TEGRA124_CLK_DFLL_REF, TEGRA124_CLK_PLL_P, 51000000, 1},
1363 {TEGRA124_CLK_PLL_C, TEGRA124_CLK_CLK_MAX, 768000000, 0},
1364 {TEGRA124_CLK_PLL_C_OUT1, TEGRA124_CLK_CLK_MAX, 100000000, 0},
1365 {TEGRA124_CLK_SBC4, TEGRA124_CLK_PLL_P, 12000000, 1},
1366 {TEGRA124_CLK_TSEC, TEGRA124_CLK_PLL_C3, 0, 0},
1367 {TEGRA124_CLK_MSENC, TEGRA124_CLK_PLL_C3, 0, 0},
1368 /* This MUST be the last entry. */
1369 {TEGRA124_CLK_CLK_MAX, TEGRA124_CLK_CLK_MAX, 0, 0},
1370};
1371
1372static void __init tegra124_clock_apply_init_table(void)
1373{
1374 tegra_init_from_table(init_table, clks, TEGRA124_CLK_CLK_MAX);
1375}
1376
1377static void __init tegra124_clock_init(struct device_node *np)
1378{
1379 struct device_node *node;
1380
1381 clk_base = of_iomap(np, 0);
1382 if (!clk_base) {
1383 pr_err("ioremap tegra124 CAR failed\n");
1384 return;
1385 }
1386
1387 node = of_find_matching_node(NULL, pmc_match);
1388 if (!node) {
1389 pr_err("Failed to find pmc node\n");
1390 WARN_ON(1);
1391 return;
1392 }
1393
1394 pmc_base = of_iomap(node, 0);
1395 if (!pmc_base) {
1396 pr_err("Can't map pmc registers\n");
1397 WARN_ON(1);
1398 return;
1399 }
1400
1401 clks = tegra_clk_init(clk_base, TEGRA124_CLK_CLK_MAX, 6);
1402 if (!clks)
1403 return;
1404
1405 if (tegra_osc_clk_init(clk_base, tegra124_clks, tegra124_input_freq,
1406 ARRAY_SIZE(tegra124_input_freq), &osc_freq, &pll_ref_freq) < 0)
1407 return;
1408
1409 tegra_fixed_clk_init(tegra124_clks);
1410 tegra124_pll_init(clk_base, pmc_base);
1411 tegra124_periph_clk_init(clk_base, pmc_base);
1412 tegra_audio_clk_init(clk_base, pmc_base, tegra124_clks, &pll_a_params);
1413 tegra_pmc_clk_init(pmc_base, tegra124_clks);
1414
1415 tegra_super_clk_gen4_init(clk_base, pmc_base, tegra124_clks,
1416 &pll_x_params);
1417 tegra_add_of_provider(np);
1418 tegra_register_devclks(devclks, ARRAY_SIZE(devclks));
1419
1420 tegra_clk_apply_init_table = tegra124_clock_apply_init_table;
1421
1422 tegra_cpu_car_ops = &tegra124_cpu_car_ops;
1423}
1424CLK_OF_DECLARE(tegra124, "nvidia,tegra124-car", tegra124_clock_init);
diff --git a/drivers/clk/tegra/clk-tegra20.c b/drivers/clk/tegra/clk-tegra20.c
index 056f649d0d89..dbace152b2fa 100644
--- a/drivers/clk/tegra/clk-tegra20.c
+++ b/drivers/clk/tegra/clk-tegra20.c
@@ -22,30 +22,10 @@
22#include <linux/of_address.h> 22#include <linux/of_address.h>
23#include <linux/clk/tegra.h> 23#include <linux/clk/tegra.h>
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <dt-bindings/clock/tegra20-car.h>
25 26
26#include "clk.h" 27#include "clk.h"
27 28#include "clk-id.h"
28#define RST_DEVICES_L 0x004
29#define RST_DEVICES_H 0x008
30#define RST_DEVICES_U 0x00c
31#define RST_DEVICES_SET_L 0x300
32#define RST_DEVICES_CLR_L 0x304
33#define RST_DEVICES_SET_H 0x308
34#define RST_DEVICES_CLR_H 0x30c
35#define RST_DEVICES_SET_U 0x310
36#define RST_DEVICES_CLR_U 0x314
37#define RST_DEVICES_NUM 3
38
39#define CLK_OUT_ENB_L 0x010
40#define CLK_OUT_ENB_H 0x014
41#define CLK_OUT_ENB_U 0x018
42#define CLK_OUT_ENB_SET_L 0x320
43#define CLK_OUT_ENB_CLR_L 0x324
44#define CLK_OUT_ENB_SET_H 0x328
45#define CLK_OUT_ENB_CLR_H 0x32c
46#define CLK_OUT_ENB_SET_U 0x330
47#define CLK_OUT_ENB_CLR_U 0x334
48#define CLK_OUT_ENB_NUM 3
49 29
50#define OSC_CTRL 0x50 30#define OSC_CTRL 0x50
51#define OSC_CTRL_OSC_FREQ_MASK (3<<30) 31#define OSC_CTRL_OSC_FREQ_MASK (3<<30)
@@ -67,6 +47,8 @@
67#define OSC_FREQ_DET_BUSY (1<<31) 47#define OSC_FREQ_DET_BUSY (1<<31)
68#define OSC_FREQ_DET_CNT_MASK 0xFFFF 48#define OSC_FREQ_DET_CNT_MASK 0xFFFF
69 49
50#define TEGRA20_CLK_PERIPH_BANKS 3
51
70#define PLLS_BASE 0xf0 52#define PLLS_BASE 0xf0
71#define PLLS_MISC 0xf4 53#define PLLS_MISC 0xf4
72#define PLLC_BASE 0x80 54#define PLLC_BASE 0x80
@@ -114,34 +96,15 @@
114 96
115#define CLK_SOURCE_I2S1 0x100 97#define CLK_SOURCE_I2S1 0x100
116#define CLK_SOURCE_I2S2 0x104 98#define CLK_SOURCE_I2S2 0x104
117#define CLK_SOURCE_SPDIF_OUT 0x108
118#define CLK_SOURCE_SPDIF_IN 0x10c
119#define CLK_SOURCE_PWM 0x110 99#define CLK_SOURCE_PWM 0x110
120#define CLK_SOURCE_SPI 0x114 100#define CLK_SOURCE_SPI 0x114
121#define CLK_SOURCE_SBC1 0x134
122#define CLK_SOURCE_SBC2 0x118
123#define CLK_SOURCE_SBC3 0x11c
124#define CLK_SOURCE_SBC4 0x1b4
125#define CLK_SOURCE_XIO 0x120 101#define CLK_SOURCE_XIO 0x120
126#define CLK_SOURCE_TWC 0x12c 102#define CLK_SOURCE_TWC 0x12c
127#define CLK_SOURCE_IDE 0x144 103#define CLK_SOURCE_IDE 0x144
128#define CLK_SOURCE_NDFLASH 0x160
129#define CLK_SOURCE_VFIR 0x168
130#define CLK_SOURCE_SDMMC1 0x150
131#define CLK_SOURCE_SDMMC2 0x154
132#define CLK_SOURCE_SDMMC3 0x1bc
133#define CLK_SOURCE_SDMMC4 0x164
134#define CLK_SOURCE_CVE 0x140
135#define CLK_SOURCE_TVO 0x188
136#define CLK_SOURCE_TVDAC 0x194
137#define CLK_SOURCE_HDMI 0x18c 104#define CLK_SOURCE_HDMI 0x18c
138#define CLK_SOURCE_DISP1 0x138 105#define CLK_SOURCE_DISP1 0x138
139#define CLK_SOURCE_DISP2 0x13c 106#define CLK_SOURCE_DISP2 0x13c
140#define CLK_SOURCE_CSITE 0x1d4 107#define CLK_SOURCE_CSITE 0x1d4
141#define CLK_SOURCE_LA 0x1f8
142#define CLK_SOURCE_OWR 0x1cc
143#define CLK_SOURCE_NOR 0x1d0
144#define CLK_SOURCE_MIPI 0x174
145#define CLK_SOURCE_I2C1 0x124 108#define CLK_SOURCE_I2C1 0x124
146#define CLK_SOURCE_I2C2 0x198 109#define CLK_SOURCE_I2C2 0x198
147#define CLK_SOURCE_I2C3 0x1b8 110#define CLK_SOURCE_I2C3 0x1b8
@@ -151,24 +114,10 @@
151#define CLK_SOURCE_UARTC 0x1a0 114#define CLK_SOURCE_UARTC 0x1a0
152#define CLK_SOURCE_UARTD 0x1c0 115#define CLK_SOURCE_UARTD 0x1c0
153#define CLK_SOURCE_UARTE 0x1c4 116#define CLK_SOURCE_UARTE 0x1c4
154#define CLK_SOURCE_3D 0x158
155#define CLK_SOURCE_2D 0x15c
156#define CLK_SOURCE_MPE 0x170
157#define CLK_SOURCE_EPP 0x16c
158#define CLK_SOURCE_HOST1X 0x180
159#define CLK_SOURCE_VDE 0x1c8
160#define CLK_SOURCE_VI 0x148
161#define CLK_SOURCE_VI_SENSOR 0x1a8
162#define CLK_SOURCE_EMC 0x19c 117#define CLK_SOURCE_EMC 0x19c
163 118
164#define AUDIO_SYNC_CLK 0x38 119#define AUDIO_SYNC_CLK 0x38
165 120
166#define PMC_CTRL 0x0
167#define PMC_CTRL_BLINK_ENB 7
168#define PMC_DPD_PADS_ORIDE 0x1c
169#define PMC_DPD_PADS_ORIDE_BLINK_ENB 20
170#define PMC_BLINK_TIMER 0x40
171
172/* Tegra CPU clock and reset control regs */ 121/* Tegra CPU clock and reset control regs */
173#define TEGRA_CLK_RST_CONTROLLER_CLK_CPU_CMPLX 0x4c 122#define TEGRA_CLK_RST_CONTROLLER_CLK_CPU_CMPLX 0x4c
174#define TEGRA_CLK_RST_CONTROLLER_RST_CPU_CMPLX_SET 0x340 123#define TEGRA_CLK_RST_CONTROLLER_RST_CPU_CMPLX_SET 0x340
@@ -188,64 +137,32 @@ static struct cpu_clk_suspend_context {
188} tegra20_cpu_clk_sctx; 137} tegra20_cpu_clk_sctx;
189#endif 138#endif
190 139
191static int periph_clk_enb_refcnt[CLK_OUT_ENB_NUM * 32];
192
193static void __iomem *clk_base; 140static void __iomem *clk_base;
194static void __iomem *pmc_base; 141static void __iomem *pmc_base;
195 142
196static DEFINE_SPINLOCK(pll_div_lock); 143#define TEGRA_INIT_DATA_MUX(_name, _parents, _offset, \
197static DEFINE_SPINLOCK(sysrate_lock); 144 _clk_num, _gate_flags, _clk_id) \
198 145 TEGRA_INIT_DATA(_name, NULL, NULL, _parents, _offset, \
199#define TEGRA_INIT_DATA_MUX(_name, _con_id, _dev_id, _parents, _offset, \
200 _clk_num, _regs, _gate_flags, _clk_id) \
201 TEGRA_INIT_DATA(_name, _con_id, _dev_id, _parents, _offset, \
202 30, 2, 0, 0, 8, 1, TEGRA_DIVIDER_ROUND_UP, \ 146 30, 2, 0, 0, 8, 1, TEGRA_DIVIDER_ROUND_UP, \
203 _regs, _clk_num, periph_clk_enb_refcnt, \ 147 _clk_num, \
204 _gate_flags, _clk_id) 148 _gate_flags, _clk_id)
205 149
206#define TEGRA_INIT_DATA_INT(_name, _con_id, _dev_id, _parents, _offset, \ 150#define TEGRA_INIT_DATA_DIV16(_name, _parents, _offset, \
207 _clk_num, _regs, _gate_flags, _clk_id) \ 151 _clk_num, _gate_flags, _clk_id) \
208 TEGRA_INIT_DATA(_name, _con_id, _dev_id, _parents, _offset, \ 152 TEGRA_INIT_DATA(_name, NULL, NULL, _parents, _offset, \
209 30, 2, 0, 0, 8, 1, TEGRA_DIVIDER_INT, _regs, \ 153 30, 2, 0, 0, 16, 0, TEGRA_DIVIDER_ROUND_UP, \
210 _clk_num, periph_clk_enb_refcnt, _gate_flags, \ 154 _clk_num, _gate_flags, \
211 _clk_id)
212
213#define TEGRA_INIT_DATA_DIV16(_name, _con_id, _dev_id, _parents, _offset, \
214 _clk_num, _regs, _gate_flags, _clk_id) \
215 TEGRA_INIT_DATA(_name, _con_id, _dev_id, _parents, _offset, \
216 30, 2, 0, 0, 16, 0, TEGRA_DIVIDER_ROUND_UP, _regs, \
217 _clk_num, periph_clk_enb_refcnt, _gate_flags, \
218 _clk_id) 155 _clk_id)
219 156
220#define TEGRA_INIT_DATA_NODIV(_name, _con_id, _dev_id, _parents, _offset, \ 157#define TEGRA_INIT_DATA_NODIV(_name, _parents, _offset, \
221 _mux_shift, _mux_width, _clk_num, _regs, \ 158 _mux_shift, _mux_width, _clk_num, \
222 _gate_flags, _clk_id) \ 159 _gate_flags, _clk_id) \
223 TEGRA_INIT_DATA(_name, _con_id, _dev_id, _parents, _offset, \ 160 TEGRA_INIT_DATA(_name, NULL, NULL, _parents, _offset, \
224 _mux_shift, _mux_width, 0, 0, 0, 0, 0, _regs, \ 161 _mux_shift, _mux_width, 0, 0, 0, 0, 0, \
225 _clk_num, periph_clk_enb_refcnt, _gate_flags, \ 162 _clk_num, _gate_flags, \
226 _clk_id) 163 _clk_id)
227 164
228/* IDs assigned here must be in sync with DT bindings definition 165static struct clk **clks;
229 * for Tegra20 clocks .
230 */
231enum tegra20_clk {
232 cpu, ac97 = 3, rtc, timer, uarta, gpio = 8, sdmmc2, i2s1 = 11, i2c1,
233 ndflash, sdmmc1, sdmmc4, twc, pwm, i2s2, epp, gr2d = 21, usbd, isp,
234 gr3d, ide, disp2, disp1, host1x, vcp, cache2 = 31, mem, ahbdma, apbdma,
235 kbc = 36, stat_mon, pmc, fuse, kfuse, sbc1, nor, spi, sbc2, xio, sbc3,
236 dvc, dsi, mipi = 50, hdmi, csi, tvdac, i2c2, uartc, emc = 57, usb2,
237 usb3, mpe, vde, bsea, bsev, speedo, uartd, uarte, i2c3, sbc4, sdmmc3,
238 pex, owr, afi, csite, pcie_xclk, avpucq = 75, la, irama = 84, iramb,
239 iramc, iramd, cram2, audio_2x, clk_d, csus = 92, cdev2, cdev1,
240 uartb = 96, vfir, spdif_in, spdif_out, vi, vi_sensor, tvo, cve,
241 osc, clk_32k, clk_m, sclk, cclk, hclk, pclk, blink, pll_a, pll_a_out0,
242 pll_c, pll_c_out1, pll_d, pll_d_out0, pll_e, pll_m, pll_m_out1,
243 pll_p, pll_p_out1, pll_p_out2, pll_p_out3, pll_p_out4, pll_s, pll_u,
244 pll_x, cop, audio, pll_ref, twd, clk_max,
245};
246
247static struct clk *clks[clk_max];
248static struct clk_onecell_data clk_data;
249 166
250static struct tegra_clk_pll_freq_table pll_c_freq_table[] = { 167static struct tegra_clk_pll_freq_table pll_c_freq_table[] = {
251 { 12000000, 600000000, 600, 12, 0, 8 }, 168 { 12000000, 600000000, 600, 12, 0, 8 },
@@ -383,6 +300,8 @@ static struct tegra_clk_pll_params pll_c_params = {
383 .lock_mask = PLL_BASE_LOCK, 300 .lock_mask = PLL_BASE_LOCK,
384 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE, 301 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
385 .lock_delay = 300, 302 .lock_delay = 300,
303 .freq_table = pll_c_freq_table,
304 .flags = TEGRA_PLL_HAS_CPCON,
386}; 305};
387 306
388static struct tegra_clk_pll_params pll_m_params = { 307static struct tegra_clk_pll_params pll_m_params = {
@@ -397,6 +316,8 @@ static struct tegra_clk_pll_params pll_m_params = {
397 .lock_mask = PLL_BASE_LOCK, 316 .lock_mask = PLL_BASE_LOCK,
398 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE, 317 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
399 .lock_delay = 300, 318 .lock_delay = 300,
319 .freq_table = pll_m_freq_table,
320 .flags = TEGRA_PLL_HAS_CPCON,
400}; 321};
401 322
402static struct tegra_clk_pll_params pll_p_params = { 323static struct tegra_clk_pll_params pll_p_params = {
@@ -411,6 +332,9 @@ static struct tegra_clk_pll_params pll_p_params = {
411 .lock_mask = PLL_BASE_LOCK, 332 .lock_mask = PLL_BASE_LOCK,
412 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE, 333 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
413 .lock_delay = 300, 334 .lock_delay = 300,
335 .freq_table = pll_p_freq_table,
336 .flags = TEGRA_PLL_FIXED | TEGRA_PLL_HAS_CPCON,
337 .fixed_rate = 216000000,
414}; 338};
415 339
416static struct tegra_clk_pll_params pll_a_params = { 340static struct tegra_clk_pll_params pll_a_params = {
@@ -425,6 +349,8 @@ static struct tegra_clk_pll_params pll_a_params = {
425 .lock_mask = PLL_BASE_LOCK, 349 .lock_mask = PLL_BASE_LOCK,
426 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE, 350 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
427 .lock_delay = 300, 351 .lock_delay = 300,
352 .freq_table = pll_a_freq_table,
353 .flags = TEGRA_PLL_HAS_CPCON,
428}; 354};
429 355
430static struct tegra_clk_pll_params pll_d_params = { 356static struct tegra_clk_pll_params pll_d_params = {
@@ -439,6 +365,8 @@ static struct tegra_clk_pll_params pll_d_params = {
439 .lock_mask = PLL_BASE_LOCK, 365 .lock_mask = PLL_BASE_LOCK,
440 .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE, 366 .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE,
441 .lock_delay = 1000, 367 .lock_delay = 1000,
368 .freq_table = pll_d_freq_table,
369 .flags = TEGRA_PLL_HAS_CPCON,
442}; 370};
443 371
444static struct pdiv_map pllu_p[] = { 372static struct pdiv_map pllu_p[] = {
@@ -460,6 +388,8 @@ static struct tegra_clk_pll_params pll_u_params = {
460 .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE, 388 .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE,
461 .lock_delay = 1000, 389 .lock_delay = 1000,
462 .pdiv_tohw = pllu_p, 390 .pdiv_tohw = pllu_p,
391 .freq_table = pll_u_freq_table,
392 .flags = TEGRA_PLLU | TEGRA_PLL_HAS_CPCON,
463}; 393};
464 394
465static struct tegra_clk_pll_params pll_x_params = { 395static struct tegra_clk_pll_params pll_x_params = {
@@ -474,6 +404,8 @@ static struct tegra_clk_pll_params pll_x_params = {
474 .lock_mask = PLL_BASE_LOCK, 404 .lock_mask = PLL_BASE_LOCK,
475 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE, 405 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
476 .lock_delay = 300, 406 .lock_delay = 300,
407 .freq_table = pll_x_freq_table,
408 .flags = TEGRA_PLL_HAS_CPCON,
477}; 409};
478 410
479static struct tegra_clk_pll_params pll_e_params = { 411static struct tegra_clk_pll_params pll_e_params = {
@@ -488,34 +420,160 @@ static struct tegra_clk_pll_params pll_e_params = {
488 .lock_mask = PLLE_MISC_LOCK, 420 .lock_mask = PLLE_MISC_LOCK,
489 .lock_enable_bit_idx = PLLE_MISC_LOCK_ENABLE, 421 .lock_enable_bit_idx = PLLE_MISC_LOCK_ENABLE,
490 .lock_delay = 0, 422 .lock_delay = 0,
423 .freq_table = pll_e_freq_table,
424 .flags = TEGRA_PLL_FIXED,
425 .fixed_rate = 100000000,
491}; 426};
492 427
493/* Peripheral clock registers */ 428static struct tegra_devclk devclks[] __initdata = {
494static struct tegra_clk_periph_regs periph_l_regs = { 429 { .con_id = "pll_c", .dt_id = TEGRA20_CLK_PLL_C },
495 .enb_reg = CLK_OUT_ENB_L, 430 { .con_id = "pll_c_out1", .dt_id = TEGRA20_CLK_PLL_C_OUT1 },
496 .enb_set_reg = CLK_OUT_ENB_SET_L, 431 { .con_id = "pll_p", .dt_id = TEGRA20_CLK_PLL_P },
497 .enb_clr_reg = CLK_OUT_ENB_CLR_L, 432 { .con_id = "pll_p_out1", .dt_id = TEGRA20_CLK_PLL_P_OUT1 },
498 .rst_reg = RST_DEVICES_L, 433 { .con_id = "pll_p_out2", .dt_id = TEGRA20_CLK_PLL_P_OUT2 },
499 .rst_set_reg = RST_DEVICES_SET_L, 434 { .con_id = "pll_p_out3", .dt_id = TEGRA20_CLK_PLL_P_OUT3 },
500 .rst_clr_reg = RST_DEVICES_CLR_L, 435 { .con_id = "pll_p_out4", .dt_id = TEGRA20_CLK_PLL_P_OUT4 },
501}; 436 { .con_id = "pll_m", .dt_id = TEGRA20_CLK_PLL_M },
502 437 { .con_id = "pll_m_out1", .dt_id = TEGRA20_CLK_PLL_M_OUT1 },
503static struct tegra_clk_periph_regs periph_h_regs = { 438 { .con_id = "pll_x", .dt_id = TEGRA20_CLK_PLL_X },
504 .enb_reg = CLK_OUT_ENB_H, 439 { .con_id = "pll_u", .dt_id = TEGRA20_CLK_PLL_U },
505 .enb_set_reg = CLK_OUT_ENB_SET_H, 440 { .con_id = "pll_d", .dt_id = TEGRA20_CLK_PLL_D },
506 .enb_clr_reg = CLK_OUT_ENB_CLR_H, 441 { .con_id = "pll_d_out0", .dt_id = TEGRA20_CLK_PLL_D_OUT0 },
507 .rst_reg = RST_DEVICES_H, 442 { .con_id = "pll_a", .dt_id = TEGRA20_CLK_PLL_A },
508 .rst_set_reg = RST_DEVICES_SET_H, 443 { .con_id = "pll_a_out0", .dt_id = TEGRA20_CLK_PLL_A_OUT0 },
509 .rst_clr_reg = RST_DEVICES_CLR_H, 444 { .con_id = "pll_e", .dt_id = TEGRA20_CLK_PLL_E },
445 { .con_id = "cclk", .dt_id = TEGRA20_CLK_CCLK },
446 { .con_id = "sclk", .dt_id = TEGRA20_CLK_SCLK },
447 { .con_id = "hclk", .dt_id = TEGRA20_CLK_HCLK },
448 { .con_id = "pclk", .dt_id = TEGRA20_CLK_PCLK },
449 { .con_id = "fuse", .dt_id = TEGRA20_CLK_FUSE },
450 { .con_id = "twd", .dt_id = TEGRA20_CLK_TWD },
451 { .con_id = "audio", .dt_id = TEGRA20_CLK_AUDIO },
452 { .con_id = "audio_2x", .dt_id = TEGRA20_CLK_AUDIO_2X },
453 { .dev_id = "tegra20-ac97", .dt_id = TEGRA20_CLK_AC97 },
454 { .dev_id = "tegra-apbdma", .dt_id = TEGRA20_CLK_APBDMA },
455 { .dev_id = "rtc-tegra", .dt_id = TEGRA20_CLK_RTC },
456 { .dev_id = "timer", .dt_id = TEGRA20_CLK_TIMER },
457 { .dev_id = "tegra-kbc", .dt_id = TEGRA20_CLK_KBC },
458 { .con_id = "csus", .dev_id = "tegra_camera", .dt_id = TEGRA20_CLK_CSUS },
459 { .con_id = "vcp", .dev_id = "tegra-avp", .dt_id = TEGRA20_CLK_VCP },
460 { .con_id = "bsea", .dev_id = "tegra-avp", .dt_id = TEGRA20_CLK_BSEA },
461 { .con_id = "bsev", .dev_id = "tegra-aes", .dt_id = TEGRA20_CLK_BSEV },
462 { .con_id = "emc", .dt_id = TEGRA20_CLK_EMC },
463 { .dev_id = "fsl-tegra-udc", .dt_id = TEGRA20_CLK_USBD },
464 { .dev_id = "tegra-ehci.1", .dt_id = TEGRA20_CLK_USB2 },
465 { .dev_id = "tegra-ehci.2", .dt_id = TEGRA20_CLK_USB3 },
466 { .dev_id = "dsi", .dt_id = TEGRA20_CLK_DSI },
467 { .con_id = "csi", .dev_id = "tegra_camera", .dt_id = TEGRA20_CLK_CSI },
468 { .con_id = "isp", .dev_id = "tegra_camera", .dt_id = TEGRA20_CLK_ISP },
469 { .con_id = "pex", .dt_id = TEGRA20_CLK_PEX },
470 { .con_id = "afi", .dt_id = TEGRA20_CLK_AFI },
471 { .con_id = "cdev1", .dt_id = TEGRA20_CLK_CDEV1 },
472 { .con_id = "cdev2", .dt_id = TEGRA20_CLK_CDEV2 },
473 { .con_id = "clk_32k", .dt_id = TEGRA20_CLK_CLK_32K },
474 { .con_id = "blink", .dt_id = TEGRA20_CLK_BLINK },
475 { .con_id = "clk_m", .dt_id = TEGRA20_CLK_CLK_M },
476 { .con_id = "pll_ref", .dt_id = TEGRA20_CLK_PLL_REF },
477 { .dev_id = "tegra20-i2s.0", .dt_id = TEGRA20_CLK_I2S1 },
478 { .dev_id = "tegra20-i2s.1", .dt_id = TEGRA20_CLK_I2S2 },
479 { .con_id = "spdif_out", .dev_id = "tegra20-spdif", .dt_id = TEGRA20_CLK_SPDIF_OUT },
480 { .con_id = "spdif_in", .dev_id = "tegra20-spdif", .dt_id = TEGRA20_CLK_SPDIF_IN },
481 { .dev_id = "spi_tegra.0", .dt_id = TEGRA20_CLK_SBC1 },
482 { .dev_id = "spi_tegra.1", .dt_id = TEGRA20_CLK_SBC2 },
483 { .dev_id = "spi_tegra.2", .dt_id = TEGRA20_CLK_SBC3 },
484 { .dev_id = "spi_tegra.3", .dt_id = TEGRA20_CLK_SBC4 },
485 { .dev_id = "spi", .dt_id = TEGRA20_CLK_SPI },
486 { .dev_id = "xio", .dt_id = TEGRA20_CLK_XIO },
487 { .dev_id = "twc", .dt_id = TEGRA20_CLK_TWC },
488 { .dev_id = "ide", .dt_id = TEGRA20_CLK_IDE },
489 { .dev_id = "tegra_nand", .dt_id = TEGRA20_CLK_NDFLASH },
490 { .dev_id = "vfir", .dt_id = TEGRA20_CLK_VFIR },
491 { .dev_id = "csite", .dt_id = TEGRA20_CLK_CSITE },
492 { .dev_id = "la", .dt_id = TEGRA20_CLK_LA },
493 { .dev_id = "tegra_w1", .dt_id = TEGRA20_CLK_OWR },
494 { .dev_id = "mipi", .dt_id = TEGRA20_CLK_MIPI },
495 { .dev_id = "vde", .dt_id = TEGRA20_CLK_VDE },
496 { .con_id = "vi", .dev_id = "tegra_camera", .dt_id = TEGRA20_CLK_VI },
497 { .dev_id = "epp", .dt_id = TEGRA20_CLK_EPP },
498 { .dev_id = "mpe", .dt_id = TEGRA20_CLK_MPE },
499 { .dev_id = "host1x", .dt_id = TEGRA20_CLK_HOST1X },
500 { .dev_id = "3d", .dt_id = TEGRA20_CLK_GR3D },
501 { .dev_id = "2d", .dt_id = TEGRA20_CLK_GR2D },
502 { .dev_id = "tegra-nor", .dt_id = TEGRA20_CLK_NOR },
503 { .dev_id = "sdhci-tegra.0", .dt_id = TEGRA20_CLK_SDMMC1 },
504 { .dev_id = "sdhci-tegra.1", .dt_id = TEGRA20_CLK_SDMMC2 },
505 { .dev_id = "sdhci-tegra.2", .dt_id = TEGRA20_CLK_SDMMC3 },
506 { .dev_id = "sdhci-tegra.3", .dt_id = TEGRA20_CLK_SDMMC4 },
507 { .dev_id = "cve", .dt_id = TEGRA20_CLK_CVE },
508 { .dev_id = "tvo", .dt_id = TEGRA20_CLK_TVO },
509 { .dev_id = "tvdac", .dt_id = TEGRA20_CLK_TVDAC },
510 { .con_id = "vi_sensor", .dev_id = "tegra_camera", .dt_id = TEGRA20_CLK_VI_SENSOR },
511 { .dev_id = "hdmi", .dt_id = TEGRA20_CLK_HDMI },
512 { .con_id = "div-clk", .dev_id = "tegra-i2c.0", .dt_id = TEGRA20_CLK_I2C1 },
513 { .con_id = "div-clk", .dev_id = "tegra-i2c.1", .dt_id = TEGRA20_CLK_I2C2 },
514 { .con_id = "div-clk", .dev_id = "tegra-i2c.2", .dt_id = TEGRA20_CLK_I2C3 },
515 { .con_id = "div-clk", .dev_id = "tegra-i2c.3", .dt_id = TEGRA20_CLK_DVC },
516 { .dev_id = "tegra-pwm", .dt_id = TEGRA20_CLK_PWM },
517 { .dev_id = "tegra_uart.0", .dt_id = TEGRA20_CLK_UARTA },
518 { .dev_id = "tegra_uart.1", .dt_id = TEGRA20_CLK_UARTB },
519 { .dev_id = "tegra_uart.2", .dt_id = TEGRA20_CLK_UARTC },
520 { .dev_id = "tegra_uart.3", .dt_id = TEGRA20_CLK_UARTD },
521 { .dev_id = "tegra_uart.4", .dt_id = TEGRA20_CLK_UARTE },
522 { .dev_id = "tegradc.0", .dt_id = TEGRA20_CLK_DISP1 },
523 { .dev_id = "tegradc.1", .dt_id = TEGRA20_CLK_DISP2 },
510}; 524};
511 525
512static struct tegra_clk_periph_regs periph_u_regs = { 526static struct tegra_clk tegra20_clks[tegra_clk_max] __initdata = {
513 .enb_reg = CLK_OUT_ENB_U, 527 [tegra_clk_spdif_out] = { .dt_id = TEGRA20_CLK_SPDIF_OUT, .present = true },
514 .enb_set_reg = CLK_OUT_ENB_SET_U, 528 [tegra_clk_spdif_in] = { .dt_id = TEGRA20_CLK_SPDIF_IN, .present = true },
515 .enb_clr_reg = CLK_OUT_ENB_CLR_U, 529 [tegra_clk_sdmmc1] = { .dt_id = TEGRA20_CLK_SDMMC1, .present = true },
516 .rst_reg = RST_DEVICES_U, 530 [tegra_clk_sdmmc2] = { .dt_id = TEGRA20_CLK_SDMMC2, .present = true },
517 .rst_set_reg = RST_DEVICES_SET_U, 531 [tegra_clk_sdmmc3] = { .dt_id = TEGRA20_CLK_SDMMC3, .present = true },
518 .rst_clr_reg = RST_DEVICES_CLR_U, 532 [tegra_clk_sdmmc4] = { .dt_id = TEGRA20_CLK_SDMMC4, .present = true },
533 [tegra_clk_la] = { .dt_id = TEGRA20_CLK_LA, .present = true },
534 [tegra_clk_csite] = { .dt_id = TEGRA20_CLK_CSITE, .present = true },
535 [tegra_clk_vfir] = { .dt_id = TEGRA20_CLK_VFIR, .present = true },
536 [tegra_clk_mipi] = { .dt_id = TEGRA20_CLK_MIPI, .present = true },
537 [tegra_clk_nor] = { .dt_id = TEGRA20_CLK_NOR, .present = true },
538 [tegra_clk_rtc] = { .dt_id = TEGRA20_CLK_RTC, .present = true },
539 [tegra_clk_timer] = { .dt_id = TEGRA20_CLK_TIMER, .present = true },
540 [tegra_clk_kbc] = { .dt_id = TEGRA20_CLK_KBC, .present = true },
541 [tegra_clk_csus] = { .dt_id = TEGRA20_CLK_CSUS, .present = true },
542 [tegra_clk_vcp] = { .dt_id = TEGRA20_CLK_VCP, .present = true },
543 [tegra_clk_bsea] = { .dt_id = TEGRA20_CLK_BSEA, .present = true },
544 [tegra_clk_bsev] = { .dt_id = TEGRA20_CLK_BSEV, .present = true },
545 [tegra_clk_usbd] = { .dt_id = TEGRA20_CLK_USBD, .present = true },
546 [tegra_clk_usb2] = { .dt_id = TEGRA20_CLK_USB2, .present = true },
547 [tegra_clk_usb3] = { .dt_id = TEGRA20_CLK_USB3, .present = true },
548 [tegra_clk_csi] = { .dt_id = TEGRA20_CLK_CSI, .present = true },
549 [tegra_clk_isp] = { .dt_id = TEGRA20_CLK_ISP, .present = true },
550 [tegra_clk_clk_32k] = { .dt_id = TEGRA20_CLK_CLK_32K, .present = true },
551 [tegra_clk_blink] = { .dt_id = TEGRA20_CLK_BLINK, .present = true },
552 [tegra_clk_hclk] = { .dt_id = TEGRA20_CLK_HCLK, .present = true },
553 [tegra_clk_pclk] = { .dt_id = TEGRA20_CLK_PCLK, .present = true },
554 [tegra_clk_pll_p_out1] = { .dt_id = TEGRA20_CLK_PLL_P_OUT1, .present = true },
555 [tegra_clk_pll_p_out2] = { .dt_id = TEGRA20_CLK_PLL_P_OUT2, .present = true },
556 [tegra_clk_pll_p_out3] = { .dt_id = TEGRA20_CLK_PLL_P_OUT3, .present = true },
557 [tegra_clk_pll_p_out4] = { .dt_id = TEGRA20_CLK_PLL_P_OUT4, .present = true },
558 [tegra_clk_pll_p] = { .dt_id = TEGRA20_CLK_PLL_P, .present = true },
559 [tegra_clk_owr] = { .dt_id = TEGRA20_CLK_OWR, .present = true },
560 [tegra_clk_sbc1] = { .dt_id = TEGRA20_CLK_SBC1, .present = true },
561 [tegra_clk_sbc2] = { .dt_id = TEGRA20_CLK_SBC2, .present = true },
562 [tegra_clk_sbc3] = { .dt_id = TEGRA20_CLK_SBC3, .present = true },
563 [tegra_clk_sbc4] = { .dt_id = TEGRA20_CLK_SBC4, .present = true },
564 [tegra_clk_vde] = { .dt_id = TEGRA20_CLK_VDE, .present = true },
565 [tegra_clk_vi] = { .dt_id = TEGRA20_CLK_VI, .present = true },
566 [tegra_clk_epp] = { .dt_id = TEGRA20_CLK_EPP, .present = true },
567 [tegra_clk_mpe] = { .dt_id = TEGRA20_CLK_MPE, .present = true },
568 [tegra_clk_host1x] = { .dt_id = TEGRA20_CLK_HOST1X, .present = true },
569 [tegra_clk_gr2d] = { .dt_id = TEGRA20_CLK_GR2D, .present = true },
570 [tegra_clk_gr3d] = { .dt_id = TEGRA20_CLK_GR3D, .present = true },
571 [tegra_clk_ndflash] = { .dt_id = TEGRA20_CLK_NDFLASH, .present = true },
572 [tegra_clk_cve] = { .dt_id = TEGRA20_CLK_CVE, .present = true },
573 [tegra_clk_tvo] = { .dt_id = TEGRA20_CLK_TVO, .present = true },
574 [tegra_clk_tvdac] = { .dt_id = TEGRA20_CLK_TVDAC, .present = true },
575 [tegra_clk_vi_sensor] = { .dt_id = TEGRA20_CLK_VI_SENSOR, .present = true },
576 [tegra_clk_afi] = { .dt_id = TEGRA20_CLK_AFI, .present = true },
519}; 577};
520 578
521static unsigned long tegra20_clk_measure_input_freq(void) 579static unsigned long tegra20_clk_measure_input_freq(void)
@@ -577,10 +635,8 @@ static void tegra20_pll_init(void)
577 635
578 /* PLLC */ 636 /* PLLC */
579 clk = tegra_clk_register_pll("pll_c", "pll_ref", clk_base, NULL, 0, 637 clk = tegra_clk_register_pll("pll_c", "pll_ref", clk_base, NULL, 0,
580 0, &pll_c_params, TEGRA_PLL_HAS_CPCON, 638 &pll_c_params, NULL);
581 pll_c_freq_table, NULL); 639 clks[TEGRA20_CLK_PLL_C] = clk;
582 clk_register_clkdev(clk, "pll_c", NULL);
583 clks[pll_c] = clk;
584 640
585 /* PLLC_OUT1 */ 641 /* PLLC_OUT1 */
586 clk = tegra_clk_register_divider("pll_c_out1_div", "pll_c", 642 clk = tegra_clk_register_divider("pll_c_out1_div", "pll_c",
@@ -589,71 +645,13 @@ static void tegra20_pll_init(void)
589 clk = tegra_clk_register_pll_out("pll_c_out1", "pll_c_out1_div", 645 clk = tegra_clk_register_pll_out("pll_c_out1", "pll_c_out1_div",
590 clk_base + PLLC_OUT, 1, 0, CLK_SET_RATE_PARENT, 646 clk_base + PLLC_OUT, 1, 0, CLK_SET_RATE_PARENT,
591 0, NULL); 647 0, NULL);
592 clk_register_clkdev(clk, "pll_c_out1", NULL); 648 clks[TEGRA20_CLK_PLL_C_OUT1] = clk;
593 clks[pll_c_out1] = clk;
594
595 /* PLLP */
596 clk = tegra_clk_register_pll("pll_p", "pll_ref", clk_base, NULL, 0,
597 216000000, &pll_p_params, TEGRA_PLL_FIXED |
598 TEGRA_PLL_HAS_CPCON, pll_p_freq_table, NULL);
599 clk_register_clkdev(clk, "pll_p", NULL);
600 clks[pll_p] = clk;
601
602 /* PLLP_OUT1 */
603 clk = tegra_clk_register_divider("pll_p_out1_div", "pll_p",
604 clk_base + PLLP_OUTA, 0,
605 TEGRA_DIVIDER_FIXED | TEGRA_DIVIDER_ROUND_UP,
606 8, 8, 1, &pll_div_lock);
607 clk = tegra_clk_register_pll_out("pll_p_out1", "pll_p_out1_div",
608 clk_base + PLLP_OUTA, 1, 0,
609 CLK_IGNORE_UNUSED | CLK_SET_RATE_PARENT, 0,
610 &pll_div_lock);
611 clk_register_clkdev(clk, "pll_p_out1", NULL);
612 clks[pll_p_out1] = clk;
613
614 /* PLLP_OUT2 */
615 clk = tegra_clk_register_divider("pll_p_out2_div", "pll_p",
616 clk_base + PLLP_OUTA, 0,
617 TEGRA_DIVIDER_FIXED | TEGRA_DIVIDER_ROUND_UP,
618 24, 8, 1, &pll_div_lock);
619 clk = tegra_clk_register_pll_out("pll_p_out2", "pll_p_out2_div",
620 clk_base + PLLP_OUTA, 17, 16,
621 CLK_IGNORE_UNUSED | CLK_SET_RATE_PARENT, 0,
622 &pll_div_lock);
623 clk_register_clkdev(clk, "pll_p_out2", NULL);
624 clks[pll_p_out2] = clk;
625
626 /* PLLP_OUT3 */
627 clk = tegra_clk_register_divider("pll_p_out3_div", "pll_p",
628 clk_base + PLLP_OUTB, 0,
629 TEGRA_DIVIDER_FIXED | TEGRA_DIVIDER_ROUND_UP,
630 8, 8, 1, &pll_div_lock);
631 clk = tegra_clk_register_pll_out("pll_p_out3", "pll_p_out3_div",
632 clk_base + PLLP_OUTB, 1, 0,
633 CLK_IGNORE_UNUSED | CLK_SET_RATE_PARENT, 0,
634 &pll_div_lock);
635 clk_register_clkdev(clk, "pll_p_out3", NULL);
636 clks[pll_p_out3] = clk;
637
638 /* PLLP_OUT4 */
639 clk = tegra_clk_register_divider("pll_p_out4_div", "pll_p",
640 clk_base + PLLP_OUTB, 0,
641 TEGRA_DIVIDER_FIXED | TEGRA_DIVIDER_ROUND_UP,
642 24, 8, 1, &pll_div_lock);
643 clk = tegra_clk_register_pll_out("pll_p_out4", "pll_p_out4_div",
644 clk_base + PLLP_OUTB, 17, 16,
645 CLK_IGNORE_UNUSED | CLK_SET_RATE_PARENT, 0,
646 &pll_div_lock);
647 clk_register_clkdev(clk, "pll_p_out4", NULL);
648 clks[pll_p_out4] = clk;
649 649
650 /* PLLM */ 650 /* PLLM */
651 clk = tegra_clk_register_pll("pll_m", "pll_ref", clk_base, NULL, 651 clk = tegra_clk_register_pll("pll_m", "pll_ref", clk_base, NULL,
652 CLK_IGNORE_UNUSED | CLK_SET_RATE_GATE, 0, 652 CLK_IGNORE_UNUSED | CLK_SET_RATE_GATE,
653 &pll_m_params, TEGRA_PLL_HAS_CPCON, 653 &pll_m_params, NULL);
654 pll_m_freq_table, NULL); 654 clks[TEGRA20_CLK_PLL_M] = clk;
655 clk_register_clkdev(clk, "pll_m", NULL);
656 clks[pll_m] = clk;
657 655
658 /* PLLM_OUT1 */ 656 /* PLLM_OUT1 */
659 clk = tegra_clk_register_divider("pll_m_out1_div", "pll_m", 657 clk = tegra_clk_register_divider("pll_m_out1_div", "pll_m",
@@ -662,42 +660,32 @@ static void tegra20_pll_init(void)
662 clk = tegra_clk_register_pll_out("pll_m_out1", "pll_m_out1_div", 660 clk = tegra_clk_register_pll_out("pll_m_out1", "pll_m_out1_div",
663 clk_base + PLLM_OUT, 1, 0, CLK_IGNORE_UNUSED | 661 clk_base + PLLM_OUT, 1, 0, CLK_IGNORE_UNUSED |
664 CLK_SET_RATE_PARENT, 0, NULL); 662 CLK_SET_RATE_PARENT, 0, NULL);
665 clk_register_clkdev(clk, "pll_m_out1", NULL); 663 clks[TEGRA20_CLK_PLL_M_OUT1] = clk;
666 clks[pll_m_out1] = clk;
667 664
668 /* PLLX */ 665 /* PLLX */
669 clk = tegra_clk_register_pll("pll_x", "pll_ref", clk_base, NULL, 0, 666 clk = tegra_clk_register_pll("pll_x", "pll_ref", clk_base, NULL, 0,
670 0, &pll_x_params, TEGRA_PLL_HAS_CPCON, 667 &pll_x_params, NULL);
671 pll_x_freq_table, NULL); 668 clks[TEGRA20_CLK_PLL_X] = clk;
672 clk_register_clkdev(clk, "pll_x", NULL);
673 clks[pll_x] = clk;
674 669
675 /* PLLU */ 670 /* PLLU */
676 clk = tegra_clk_register_pll("pll_u", "pll_ref", clk_base, NULL, 0, 671 clk = tegra_clk_register_pll("pll_u", "pll_ref", clk_base, NULL, 0,
677 0, &pll_u_params, TEGRA_PLLU | TEGRA_PLL_HAS_CPCON, 672 &pll_u_params, NULL);
678 pll_u_freq_table, NULL); 673 clks[TEGRA20_CLK_PLL_U] = clk;
679 clk_register_clkdev(clk, "pll_u", NULL);
680 clks[pll_u] = clk;
681 674
682 /* PLLD */ 675 /* PLLD */
683 clk = tegra_clk_register_pll("pll_d", "pll_ref", clk_base, NULL, 0, 676 clk = tegra_clk_register_pll("pll_d", "pll_ref", clk_base, NULL, 0,
684 0, &pll_d_params, TEGRA_PLL_HAS_CPCON, 677 &pll_d_params, NULL);
685 pll_d_freq_table, NULL); 678 clks[TEGRA20_CLK_PLL_D] = clk;
686 clk_register_clkdev(clk, "pll_d", NULL);
687 clks[pll_d] = clk;
688 679
689 /* PLLD_OUT0 */ 680 /* PLLD_OUT0 */
690 clk = clk_register_fixed_factor(NULL, "pll_d_out0", "pll_d", 681 clk = clk_register_fixed_factor(NULL, "pll_d_out0", "pll_d",
691 CLK_SET_RATE_PARENT, 1, 2); 682 CLK_SET_RATE_PARENT, 1, 2);
692 clk_register_clkdev(clk, "pll_d_out0", NULL); 683 clks[TEGRA20_CLK_PLL_D_OUT0] = clk;
693 clks[pll_d_out0] = clk;
694 684
695 /* PLLA */ 685 /* PLLA */
696 clk = tegra_clk_register_pll("pll_a", "pll_p_out1", clk_base, NULL, 0, 686 clk = tegra_clk_register_pll("pll_a", "pll_p_out1", clk_base, NULL, 0,
697 0, &pll_a_params, TEGRA_PLL_HAS_CPCON, 687 &pll_a_params, NULL);
698 pll_a_freq_table, NULL); 688 clks[TEGRA20_CLK_PLL_A] = clk;
699 clk_register_clkdev(clk, "pll_a", NULL);
700 clks[pll_a] = clk;
701 689
702 /* PLLA_OUT0 */ 690 /* PLLA_OUT0 */
703 clk = tegra_clk_register_divider("pll_a_out0_div", "pll_a", 691 clk = tegra_clk_register_divider("pll_a_out0_div", "pll_a",
@@ -706,15 +694,12 @@ static void tegra20_pll_init(void)
706 clk = tegra_clk_register_pll_out("pll_a_out0", "pll_a_out0_div", 694 clk = tegra_clk_register_pll_out("pll_a_out0", "pll_a_out0_div",
707 clk_base + PLLA_OUT, 1, 0, CLK_IGNORE_UNUSED | 695 clk_base + PLLA_OUT, 1, 0, CLK_IGNORE_UNUSED |
708 CLK_SET_RATE_PARENT, 0, NULL); 696 CLK_SET_RATE_PARENT, 0, NULL);
709 clk_register_clkdev(clk, "pll_a_out0", NULL); 697 clks[TEGRA20_CLK_PLL_A_OUT0] = clk;
710 clks[pll_a_out0] = clk;
711 698
712 /* PLLE */ 699 /* PLLE */
713 clk = tegra_clk_register_plle("pll_e", "pll_ref", clk_base, pmc_base, 700 clk = tegra_clk_register_plle("pll_e", "pll_ref", clk_base, pmc_base,
714 0, 100000000, &pll_e_params, 701 0, &pll_e_params, NULL);
715 0, pll_e_freq_table, NULL); 702 clks[TEGRA20_CLK_PLL_E] = clk;
716 clk_register_clkdev(clk, "pll_e", NULL);
717 clks[pll_e] = clk;
718} 703}
719 704
720static const char *cclk_parents[] = { "clk_m", "pll_c", "clk_32k", "pll_m", 705static const char *cclk_parents[] = { "clk_m", "pll_c", "clk_32k", "pll_m",
@@ -732,40 +717,17 @@ static void tegra20_super_clk_init(void)
732 clk = tegra_clk_register_super_mux("cclk", cclk_parents, 717 clk = tegra_clk_register_super_mux("cclk", cclk_parents,
733 ARRAY_SIZE(cclk_parents), CLK_SET_RATE_PARENT, 718 ARRAY_SIZE(cclk_parents), CLK_SET_RATE_PARENT,
734 clk_base + CCLK_BURST_POLICY, 0, 4, 0, 0, NULL); 719 clk_base + CCLK_BURST_POLICY, 0, 4, 0, 0, NULL);
735 clk_register_clkdev(clk, "cclk", NULL); 720 clks[TEGRA20_CLK_CCLK] = clk;
736 clks[cclk] = clk;
737 721
738 /* SCLK */ 722 /* SCLK */
739 clk = tegra_clk_register_super_mux("sclk", sclk_parents, 723 clk = tegra_clk_register_super_mux("sclk", sclk_parents,
740 ARRAY_SIZE(sclk_parents), CLK_SET_RATE_PARENT, 724 ARRAY_SIZE(sclk_parents), CLK_SET_RATE_PARENT,
741 clk_base + SCLK_BURST_POLICY, 0, 4, 0, 0, NULL); 725 clk_base + SCLK_BURST_POLICY, 0, 4, 0, 0, NULL);
742 clk_register_clkdev(clk, "sclk", NULL); 726 clks[TEGRA20_CLK_SCLK] = clk;
743 clks[sclk] = clk;
744
745 /* HCLK */
746 clk = clk_register_divider(NULL, "hclk_div", "sclk", 0,
747 clk_base + CLK_SYSTEM_RATE, 4, 2, 0,
748 &sysrate_lock);
749 clk = clk_register_gate(NULL, "hclk", "hclk_div", CLK_SET_RATE_PARENT,
750 clk_base + CLK_SYSTEM_RATE, 7,
751 CLK_GATE_SET_TO_DISABLE, &sysrate_lock);
752 clk_register_clkdev(clk, "hclk", NULL);
753 clks[hclk] = clk;
754
755 /* PCLK */
756 clk = clk_register_divider(NULL, "pclk_div", "hclk", 0,
757 clk_base + CLK_SYSTEM_RATE, 0, 2, 0,
758 &sysrate_lock);
759 clk = clk_register_gate(NULL, "pclk", "pclk_div", CLK_SET_RATE_PARENT,
760 clk_base + CLK_SYSTEM_RATE, 3,
761 CLK_GATE_SET_TO_DISABLE, &sysrate_lock);
762 clk_register_clkdev(clk, "pclk", NULL);
763 clks[pclk] = clk;
764 727
765 /* twd */ 728 /* twd */
766 clk = clk_register_fixed_factor(NULL, "twd", "cclk", 0, 1, 4); 729 clk = clk_register_fixed_factor(NULL, "twd", "cclk", 0, 1, 4);
767 clk_register_clkdev(clk, "twd", NULL); 730 clks[TEGRA20_CLK_TWD] = clk;
768 clks[twd] = clk;
769} 731}
770 732
771static const char *audio_parents[] = {"spdif_in", "i2s1", "i2s2", "unused", 733static const char *audio_parents[] = {"spdif_in", "i2s1", "i2s2", "unused",
@@ -784,18 +746,16 @@ static void __init tegra20_audio_clk_init(void)
784 clk = clk_register_gate(NULL, "audio", "audio_mux", 0, 746 clk = clk_register_gate(NULL, "audio", "audio_mux", 0,
785 clk_base + AUDIO_SYNC_CLK, 4, 747 clk_base + AUDIO_SYNC_CLK, 4,
786 CLK_GATE_SET_TO_DISABLE, NULL); 748 CLK_GATE_SET_TO_DISABLE, NULL);
787 clk_register_clkdev(clk, "audio", NULL); 749 clks[TEGRA20_CLK_AUDIO] = clk;
788 clks[audio] = clk;
789 750
790 /* audio_2x */ 751 /* audio_2x */
791 clk = clk_register_fixed_factor(NULL, "audio_doubler", "audio", 752 clk = clk_register_fixed_factor(NULL, "audio_doubler", "audio",
792 CLK_SET_RATE_PARENT, 2, 1); 753 CLK_SET_RATE_PARENT, 2, 1);
793 clk = tegra_clk_register_periph_gate("audio_2x", "audio_doubler", 754 clk = tegra_clk_register_periph_gate("audio_2x", "audio_doubler",
794 TEGRA_PERIPH_NO_RESET, clk_base, 755 TEGRA_PERIPH_NO_RESET, clk_base,
795 CLK_SET_RATE_PARENT, 89, &periph_u_regs, 756 CLK_SET_RATE_PARENT, 89,
796 periph_clk_enb_refcnt); 757 periph_clk_enb_refcnt);
797 clk_register_clkdev(clk, "audio_2x", NULL); 758 clks[TEGRA20_CLK_AUDIO_2X] = clk;
798 clks[audio_2x] = clk;
799 759
800} 760}
801 761
@@ -803,68 +763,36 @@ static const char *i2s1_parents[] = {"pll_a_out0", "audio_2x", "pll_p",
803 "clk_m"}; 763 "clk_m"};
804static const char *i2s2_parents[] = {"pll_a_out0", "audio_2x", "pll_p", 764static const char *i2s2_parents[] = {"pll_a_out0", "audio_2x", "pll_p",
805 "clk_m"}; 765 "clk_m"};
806static const char *spdif_out_parents[] = {"pll_a_out0", "audio_2x", "pll_p",
807 "clk_m"};
808static const char *spdif_in_parents[] = {"pll_p", "pll_c", "pll_m"};
809static const char *pwm_parents[] = {"pll_p", "pll_c", "audio", "clk_m", 766static const char *pwm_parents[] = {"pll_p", "pll_c", "audio", "clk_m",
810 "clk_32k"}; 767 "clk_32k"};
811static const char *mux_pllpcm_clkm[] = {"pll_p", "pll_c", "pll_m", "clk_m"}; 768static const char *mux_pllpcm_clkm[] = {"pll_p", "pll_c", "pll_m", "clk_m"};
812static const char *mux_pllmcpa[] = {"pll_m", "pll_c", "pll_c", "pll_a"};
813static const char *mux_pllpdc_clkm[] = {"pll_p", "pll_d_out0", "pll_c", 769static const char *mux_pllpdc_clkm[] = {"pll_p", "pll_d_out0", "pll_c",
814 "clk_m"}; 770 "clk_m"};
815static const char *mux_pllmcp_clkm[] = {"pll_m", "pll_c", "pll_p", "clk_m"}; 771static const char *mux_pllmcp_clkm[] = {"pll_m", "pll_c", "pll_p", "clk_m"};
816 772
817static struct tegra_periph_init_data tegra_periph_clk_list[] = { 773static struct tegra_periph_init_data tegra_periph_clk_list[] = {
818 TEGRA_INIT_DATA_MUX("i2s1", NULL, "tegra20-i2s.0", i2s1_parents, CLK_SOURCE_I2S1, 11, &periph_l_regs, TEGRA_PERIPH_ON_APB, i2s1), 774 TEGRA_INIT_DATA_MUX("i2s1", i2s1_parents, CLK_SOURCE_I2S1, 11, TEGRA_PERIPH_ON_APB, TEGRA20_CLK_I2S1),
819 TEGRA_INIT_DATA_MUX("i2s2", NULL, "tegra20-i2s.1", i2s2_parents, CLK_SOURCE_I2S2, 18, &periph_l_regs, TEGRA_PERIPH_ON_APB, i2s2), 775 TEGRA_INIT_DATA_MUX("i2s2", i2s2_parents, CLK_SOURCE_I2S2, 18, TEGRA_PERIPH_ON_APB, TEGRA20_CLK_I2S2),
820 TEGRA_INIT_DATA_MUX("spdif_out", "spdif_out", "tegra20-spdif", spdif_out_parents, CLK_SOURCE_SPDIF_OUT, 10, &periph_l_regs, TEGRA_PERIPH_ON_APB, spdif_out), 776 TEGRA_INIT_DATA_MUX("spi", mux_pllpcm_clkm, CLK_SOURCE_SPI, 43, TEGRA_PERIPH_ON_APB, TEGRA20_CLK_SPI),
821 TEGRA_INIT_DATA_MUX("spdif_in", "spdif_in", "tegra20-spdif", spdif_in_parents, CLK_SOURCE_SPDIF_IN, 10, &periph_l_regs, TEGRA_PERIPH_ON_APB, spdif_in), 777 TEGRA_INIT_DATA_MUX("xio", mux_pllpcm_clkm, CLK_SOURCE_XIO, 45, 0, TEGRA20_CLK_XIO),
822 TEGRA_INIT_DATA_MUX("sbc1", NULL, "spi_tegra.0", mux_pllpcm_clkm, CLK_SOURCE_SBC1, 41, &periph_h_regs, TEGRA_PERIPH_ON_APB, sbc1), 778 TEGRA_INIT_DATA_MUX("twc", mux_pllpcm_clkm, CLK_SOURCE_TWC, 16, TEGRA_PERIPH_ON_APB, TEGRA20_CLK_TWC),
823 TEGRA_INIT_DATA_MUX("sbc2", NULL, "spi_tegra.1", mux_pllpcm_clkm, CLK_SOURCE_SBC2, 44, &periph_h_regs, TEGRA_PERIPH_ON_APB, sbc2), 779 TEGRA_INIT_DATA_MUX("ide", mux_pllpcm_clkm, CLK_SOURCE_XIO, 25, 0, TEGRA20_CLK_IDE),
824 TEGRA_INIT_DATA_MUX("sbc3", NULL, "spi_tegra.2", mux_pllpcm_clkm, CLK_SOURCE_SBC3, 46, &periph_h_regs, TEGRA_PERIPH_ON_APB, sbc3), 780 TEGRA_INIT_DATA_DIV16("dvc", mux_pllpcm_clkm, CLK_SOURCE_DVC, 47, TEGRA_PERIPH_ON_APB, TEGRA20_CLK_DVC),
825 TEGRA_INIT_DATA_MUX("sbc4", NULL, "spi_tegra.3", mux_pllpcm_clkm, CLK_SOURCE_SBC4, 68, &periph_u_regs, TEGRA_PERIPH_ON_APB, sbc4), 781 TEGRA_INIT_DATA_DIV16("i2c1", mux_pllpcm_clkm, CLK_SOURCE_I2C1, 12, TEGRA_PERIPH_ON_APB, TEGRA20_CLK_I2C1),
826 TEGRA_INIT_DATA_MUX("spi", NULL, "spi", mux_pllpcm_clkm, CLK_SOURCE_SPI, 43, &periph_h_regs, TEGRA_PERIPH_ON_APB, spi), 782 TEGRA_INIT_DATA_DIV16("i2c2", mux_pllpcm_clkm, CLK_SOURCE_I2C2, 54, TEGRA_PERIPH_ON_APB, TEGRA20_CLK_I2C2),
827 TEGRA_INIT_DATA_MUX("xio", NULL, "xio", mux_pllpcm_clkm, CLK_SOURCE_XIO, 45, &periph_h_regs, 0, xio), 783 TEGRA_INIT_DATA_DIV16("i2c3", mux_pllpcm_clkm, CLK_SOURCE_I2C3, 67, TEGRA_PERIPH_ON_APB, TEGRA20_CLK_I2C3),
828 TEGRA_INIT_DATA_MUX("twc", NULL, "twc", mux_pllpcm_clkm, CLK_SOURCE_TWC, 16, &periph_l_regs, TEGRA_PERIPH_ON_APB, twc), 784 TEGRA_INIT_DATA_MUX("hdmi", mux_pllpdc_clkm, CLK_SOURCE_HDMI, 51, 0, TEGRA20_CLK_HDMI),
829 TEGRA_INIT_DATA_MUX("ide", NULL, "ide", mux_pllpcm_clkm, CLK_SOURCE_XIO, 25, &periph_l_regs, 0, ide), 785 TEGRA_INIT_DATA("pwm", NULL, NULL, pwm_parents, CLK_SOURCE_PWM, 28, 3, 0, 0, 8, 1, 0, 17, TEGRA_PERIPH_ON_APB, TEGRA20_CLK_PWM),
830 TEGRA_INIT_DATA_MUX("ndflash", NULL, "tegra_nand", mux_pllpcm_clkm, CLK_SOURCE_NDFLASH, 13, &periph_l_regs, 0, ndflash),
831 TEGRA_INIT_DATA_MUX("vfir", NULL, "vfir", mux_pllpcm_clkm, CLK_SOURCE_VFIR, 7, &periph_l_regs, TEGRA_PERIPH_ON_APB, vfir),
832 TEGRA_INIT_DATA_MUX("csite", NULL, "csite", mux_pllpcm_clkm, CLK_SOURCE_CSITE, 73, &periph_u_regs, 0, csite),
833 TEGRA_INIT_DATA_MUX("la", NULL, "la", mux_pllpcm_clkm, CLK_SOURCE_LA, 76, &periph_u_regs, 0, la),
834 TEGRA_INIT_DATA_MUX("owr", NULL, "tegra_w1", mux_pllpcm_clkm, CLK_SOURCE_OWR, 71, &periph_u_regs, TEGRA_PERIPH_ON_APB, owr),
835 TEGRA_INIT_DATA_MUX("mipi", NULL, "mipi", mux_pllpcm_clkm, CLK_SOURCE_MIPI, 50, &periph_h_regs, TEGRA_PERIPH_ON_APB, mipi),
836 TEGRA_INIT_DATA_MUX("vde", NULL, "vde", mux_pllpcm_clkm, CLK_SOURCE_VDE, 61, &periph_h_regs, 0, vde),
837 TEGRA_INIT_DATA_MUX("vi", "vi", "tegra_camera", mux_pllmcpa, CLK_SOURCE_VI, 20, &periph_l_regs, 0, vi),
838 TEGRA_INIT_DATA_MUX("epp", NULL, "epp", mux_pllmcpa, CLK_SOURCE_EPP, 19, &periph_l_regs, 0, epp),
839 TEGRA_INIT_DATA_MUX("mpe", NULL, "mpe", mux_pllmcpa, CLK_SOURCE_MPE, 60, &periph_h_regs, 0, mpe),
840 TEGRA_INIT_DATA_MUX("host1x", NULL, "host1x", mux_pllmcpa, CLK_SOURCE_HOST1X, 28, &periph_l_regs, 0, host1x),
841 TEGRA_INIT_DATA_MUX("3d", NULL, "3d", mux_pllmcpa, CLK_SOURCE_3D, 24, &periph_l_regs, TEGRA_PERIPH_MANUAL_RESET, gr3d),
842 TEGRA_INIT_DATA_MUX("2d", NULL, "2d", mux_pllmcpa, CLK_SOURCE_2D, 21, &periph_l_regs, 0, gr2d),
843 TEGRA_INIT_DATA_MUX("nor", NULL, "tegra-nor", mux_pllpcm_clkm, CLK_SOURCE_NOR, 42, &periph_h_regs, 0, nor),
844 TEGRA_INIT_DATA_MUX("sdmmc1", NULL, "sdhci-tegra.0", mux_pllpcm_clkm, CLK_SOURCE_SDMMC1, 14, &periph_l_regs, 0, sdmmc1),
845 TEGRA_INIT_DATA_MUX("sdmmc2", NULL, "sdhci-tegra.1", mux_pllpcm_clkm, CLK_SOURCE_SDMMC2, 9, &periph_l_regs, 0, sdmmc2),
846 TEGRA_INIT_DATA_MUX("sdmmc3", NULL, "sdhci-tegra.2", mux_pllpcm_clkm, CLK_SOURCE_SDMMC3, 69, &periph_u_regs, 0, sdmmc3),
847 TEGRA_INIT_DATA_MUX("sdmmc4", NULL, "sdhci-tegra.3", mux_pllpcm_clkm, CLK_SOURCE_SDMMC4, 15, &periph_l_regs, 0, sdmmc4),
848 TEGRA_INIT_DATA_MUX("cve", NULL, "cve", mux_pllpdc_clkm, CLK_SOURCE_CVE, 49, &periph_h_regs, 0, cve),
849 TEGRA_INIT_DATA_MUX("tvo", NULL, "tvo", mux_pllpdc_clkm, CLK_SOURCE_TVO, 49, &periph_h_regs, 0, tvo),
850 TEGRA_INIT_DATA_MUX("tvdac", NULL, "tvdac", mux_pllpdc_clkm, CLK_SOURCE_TVDAC, 53, &periph_h_regs, 0, tvdac),
851 TEGRA_INIT_DATA_MUX("vi_sensor", "vi_sensor", "tegra_camera", mux_pllmcpa, CLK_SOURCE_VI_SENSOR, 20, &periph_l_regs, TEGRA_PERIPH_NO_RESET, vi_sensor),
852 TEGRA_INIT_DATA_DIV16("i2c1", "div-clk", "tegra-i2c.0", mux_pllpcm_clkm, CLK_SOURCE_I2C1, 12, &periph_l_regs, TEGRA_PERIPH_ON_APB, i2c1),
853 TEGRA_INIT_DATA_DIV16("i2c2", "div-clk", "tegra-i2c.1", mux_pllpcm_clkm, CLK_SOURCE_I2C2, 54, &periph_h_regs, TEGRA_PERIPH_ON_APB, i2c2),
854 TEGRA_INIT_DATA_DIV16("i2c3", "div-clk", "tegra-i2c.2", mux_pllpcm_clkm, CLK_SOURCE_I2C3, 67, &periph_u_regs, TEGRA_PERIPH_ON_APB, i2c3),
855 TEGRA_INIT_DATA_DIV16("dvc", "div-clk", "tegra-i2c.3", mux_pllpcm_clkm, CLK_SOURCE_DVC, 47, &periph_h_regs, TEGRA_PERIPH_ON_APB, dvc),
856 TEGRA_INIT_DATA_MUX("hdmi", NULL, "hdmi", mux_pllpdc_clkm, CLK_SOURCE_HDMI, 51, &periph_h_regs, 0, hdmi),
857 TEGRA_INIT_DATA("pwm", NULL, "tegra-pwm", pwm_parents, CLK_SOURCE_PWM, 28, 3, 0, 0, 8, 1, 0, &periph_l_regs, 17, periph_clk_enb_refcnt, TEGRA_PERIPH_ON_APB, pwm),
858}; 786};
859 787
860static struct tegra_periph_init_data tegra_periph_nodiv_clk_list[] = { 788static struct tegra_periph_init_data tegra_periph_nodiv_clk_list[] = {
861 TEGRA_INIT_DATA_NODIV("uarta", NULL, "tegra_uart.0", mux_pllpcm_clkm, CLK_SOURCE_UARTA, 30, 2, 6, &periph_l_regs, TEGRA_PERIPH_ON_APB, uarta), 789 TEGRA_INIT_DATA_NODIV("uarta", mux_pllpcm_clkm, CLK_SOURCE_UARTA, 30, 2, 6, TEGRA_PERIPH_ON_APB, TEGRA20_CLK_UARTA),
862 TEGRA_INIT_DATA_NODIV("uartb", NULL, "tegra_uart.1", mux_pllpcm_clkm, CLK_SOURCE_UARTB, 30, 2, 7, &periph_l_regs, TEGRA_PERIPH_ON_APB, uartb), 790 TEGRA_INIT_DATA_NODIV("uartb", mux_pllpcm_clkm, CLK_SOURCE_UARTB, 30, 2, 7, TEGRA_PERIPH_ON_APB, TEGRA20_CLK_UARTB),
863 TEGRA_INIT_DATA_NODIV("uartc", NULL, "tegra_uart.2", mux_pllpcm_clkm, CLK_SOURCE_UARTC, 30, 2, 55, &periph_h_regs, TEGRA_PERIPH_ON_APB, uartc), 791 TEGRA_INIT_DATA_NODIV("uartc", mux_pllpcm_clkm, CLK_SOURCE_UARTC, 30, 2, 55, TEGRA_PERIPH_ON_APB, TEGRA20_CLK_UARTC),
864 TEGRA_INIT_DATA_NODIV("uartd", NULL, "tegra_uart.3", mux_pllpcm_clkm, CLK_SOURCE_UARTD, 30, 2, 65, &periph_u_regs, TEGRA_PERIPH_ON_APB, uartd), 792 TEGRA_INIT_DATA_NODIV("uartd", mux_pllpcm_clkm, CLK_SOURCE_UARTD, 30, 2, 65, TEGRA_PERIPH_ON_APB, TEGRA20_CLK_UARTD),
865 TEGRA_INIT_DATA_NODIV("uarte", NULL, "tegra_uart.4", mux_pllpcm_clkm, CLK_SOURCE_UARTE, 30, 2, 66, &periph_u_regs, TEGRA_PERIPH_ON_APB, uarte), 793 TEGRA_INIT_DATA_NODIV("uarte", mux_pllpcm_clkm, CLK_SOURCE_UARTE, 30, 2, 66, TEGRA_PERIPH_ON_APB, TEGRA20_CLK_UARTE),
866 TEGRA_INIT_DATA_NODIV("disp1", NULL, "tegradc.0", mux_pllpdc_clkm, CLK_SOURCE_DISP1, 30, 2, 27, &periph_l_regs, 0, disp1), 794 TEGRA_INIT_DATA_NODIV("disp1", mux_pllpdc_clkm, CLK_SOURCE_DISP1, 30, 2, 27, 0, TEGRA20_CLK_DISP1),
867 TEGRA_INIT_DATA_NODIV("disp2", NULL, "tegradc.1", mux_pllpdc_clkm, CLK_SOURCE_DISP2, 30, 2, 26, &periph_l_regs, 0, disp2), 795 TEGRA_INIT_DATA_NODIV("disp2", mux_pllpdc_clkm, CLK_SOURCE_DISP2, 30, 2, 26, 0, TEGRA20_CLK_DISP2),
868}; 796};
869 797
870static void __init tegra20_periph_clk_init(void) 798static void __init tegra20_periph_clk_init(void)
@@ -876,69 +804,13 @@ static void __init tegra20_periph_clk_init(void)
876 /* ac97 */ 804 /* ac97 */
877 clk = tegra_clk_register_periph_gate("ac97", "pll_a_out0", 805 clk = tegra_clk_register_periph_gate("ac97", "pll_a_out0",
878 TEGRA_PERIPH_ON_APB, 806 TEGRA_PERIPH_ON_APB,
879 clk_base, 0, 3, &periph_l_regs, 807 clk_base, 0, 3, periph_clk_enb_refcnt);
880 periph_clk_enb_refcnt); 808 clks[TEGRA20_CLK_AC97] = clk;
881 clk_register_clkdev(clk, NULL, "tegra20-ac97");
882 clks[ac97] = clk;
883 809
884 /* apbdma */ 810 /* apbdma */
885 clk = tegra_clk_register_periph_gate("apbdma", "pclk", 0, clk_base, 811 clk = tegra_clk_register_periph_gate("apbdma", "pclk", 0, clk_base,
886 0, 34, &periph_h_regs, 812 0, 34, periph_clk_enb_refcnt);
887 periph_clk_enb_refcnt); 813 clks[TEGRA20_CLK_APBDMA] = clk;
888 clk_register_clkdev(clk, NULL, "tegra-apbdma");
889 clks[apbdma] = clk;
890
891 /* rtc */
892 clk = tegra_clk_register_periph_gate("rtc", "clk_32k",
893 TEGRA_PERIPH_NO_RESET,
894 clk_base, 0, 4, &periph_l_regs,
895 periph_clk_enb_refcnt);
896 clk_register_clkdev(clk, NULL, "rtc-tegra");
897 clks[rtc] = clk;
898
899 /* timer */
900 clk = tegra_clk_register_periph_gate("timer", "clk_m", 0, clk_base,
901 0, 5, &periph_l_regs,
902 periph_clk_enb_refcnt);
903 clk_register_clkdev(clk, NULL, "timer");
904 clks[timer] = clk;
905
906 /* kbc */
907 clk = tegra_clk_register_periph_gate("kbc", "clk_32k",
908 TEGRA_PERIPH_NO_RESET | TEGRA_PERIPH_ON_APB,
909 clk_base, 0, 36, &periph_h_regs,
910 periph_clk_enb_refcnt);
911 clk_register_clkdev(clk, NULL, "tegra-kbc");
912 clks[kbc] = clk;
913
914 /* csus */
915 clk = tegra_clk_register_periph_gate("csus", "clk_m",
916 TEGRA_PERIPH_NO_RESET,
917 clk_base, 0, 92, &periph_u_regs,
918 periph_clk_enb_refcnt);
919 clk_register_clkdev(clk, "csus", "tengra_camera");
920 clks[csus] = clk;
921
922 /* vcp */
923 clk = tegra_clk_register_periph_gate("vcp", "clk_m", 0,
924 clk_base, 0, 29, &periph_l_regs,
925 periph_clk_enb_refcnt);
926 clk_register_clkdev(clk, "vcp", "tegra-avp");
927 clks[vcp] = clk;
928
929 /* bsea */
930 clk = tegra_clk_register_periph_gate("bsea", "clk_m", 0,
931 clk_base, 0, 62, &periph_h_regs,
932 periph_clk_enb_refcnt);
933 clk_register_clkdev(clk, "bsea", "tegra-avp");
934 clks[bsea] = clk;
935
936 /* bsev */
937 clk = tegra_clk_register_periph_gate("bsev", "clk_m", 0,
938 clk_base, 0, 63, &periph_h_regs,
939 periph_clk_enb_refcnt);
940 clk_register_clkdev(clk, "bsev", "tegra-aes");
941 clks[bsev] = clk;
942 814
943 /* emc */ 815 /* emc */
944 clk = clk_register_mux(NULL, "emc_mux", mux_pllmcp_clkm, 816 clk = clk_register_mux(NULL, "emc_mux", mux_pllmcp_clkm,
@@ -947,130 +819,52 @@ static void __init tegra20_periph_clk_init(void)
947 clk_base + CLK_SOURCE_EMC, 819 clk_base + CLK_SOURCE_EMC,
948 30, 2, 0, NULL); 820 30, 2, 0, NULL);
949 clk = tegra_clk_register_periph_gate("emc", "emc_mux", 0, clk_base, 0, 821 clk = tegra_clk_register_periph_gate("emc", "emc_mux", 0, clk_base, 0,
950 57, &periph_h_regs, periph_clk_enb_refcnt); 822 57, periph_clk_enb_refcnt);
951 clk_register_clkdev(clk, "emc", NULL); 823 clks[TEGRA20_CLK_EMC] = clk;
952 clks[emc] = clk;
953
954 /* usbd */
955 clk = tegra_clk_register_periph_gate("usbd", "clk_m", 0, clk_base, 0,
956 22, &periph_l_regs, periph_clk_enb_refcnt);
957 clk_register_clkdev(clk, NULL, "fsl-tegra-udc");
958 clks[usbd] = clk;
959
960 /* usb2 */
961 clk = tegra_clk_register_periph_gate("usb2", "clk_m", 0, clk_base, 0,
962 58, &periph_h_regs, periph_clk_enb_refcnt);
963 clk_register_clkdev(clk, NULL, "tegra-ehci.1");
964 clks[usb2] = clk;
965
966 /* usb3 */
967 clk = tegra_clk_register_periph_gate("usb3", "clk_m", 0, clk_base, 0,
968 59, &periph_h_regs, periph_clk_enb_refcnt);
969 clk_register_clkdev(clk, NULL, "tegra-ehci.2");
970 clks[usb3] = clk;
971 824
972 /* dsi */ 825 /* dsi */
973 clk = tegra_clk_register_periph_gate("dsi", "pll_d", 0, clk_base, 0, 826 clk = tegra_clk_register_periph_gate("dsi", "pll_d", 0, clk_base, 0,
974 48, &periph_h_regs, periph_clk_enb_refcnt); 827 48, periph_clk_enb_refcnt);
975 clk_register_clkdev(clk, NULL, "dsi"); 828 clk_register_clkdev(clk, NULL, "dsi");
976 clks[dsi] = clk; 829 clks[TEGRA20_CLK_DSI] = clk;
977
978 /* csi */
979 clk = tegra_clk_register_periph_gate("csi", "pll_p_out3", 0, clk_base,
980 0, 52, &periph_h_regs,
981 periph_clk_enb_refcnt);
982 clk_register_clkdev(clk, "csi", "tegra_camera");
983 clks[csi] = clk;
984
985 /* isp */
986 clk = tegra_clk_register_periph_gate("isp", "clk_m", 0, clk_base, 0, 23,
987 &periph_l_regs, periph_clk_enb_refcnt);
988 clk_register_clkdev(clk, "isp", "tegra_camera");
989 clks[isp] = clk;
990 830
991 /* pex */ 831 /* pex */
992 clk = tegra_clk_register_periph_gate("pex", "clk_m", 0, clk_base, 0, 70, 832 clk = tegra_clk_register_periph_gate("pex", "clk_m", 0, clk_base, 0, 70,
993 &periph_u_regs, periph_clk_enb_refcnt);
994 clk_register_clkdev(clk, "pex", NULL);
995 clks[pex] = clk;
996
997 /* afi */
998 clk = tegra_clk_register_periph_gate("afi", "clk_m", 0, clk_base, 0, 72,
999 &periph_u_regs, periph_clk_enb_refcnt);
1000 clk_register_clkdev(clk, "afi", NULL);
1001 clks[afi] = clk;
1002
1003 /* pcie_xclk */
1004 clk = tegra_clk_register_periph_gate("pcie_xclk", "clk_m", 0, clk_base,
1005 0, 74, &periph_u_regs,
1006 periph_clk_enb_refcnt); 833 periph_clk_enb_refcnt);
1007 clk_register_clkdev(clk, "pcie_xclk", NULL); 834 clks[TEGRA20_CLK_PEX] = clk;
1008 clks[pcie_xclk] = clk;
1009 835
1010 /* cdev1 */ 836 /* cdev1 */
1011 clk = clk_register_fixed_rate(NULL, "cdev1_fixed", NULL, CLK_IS_ROOT, 837 clk = clk_register_fixed_rate(NULL, "cdev1_fixed", NULL, CLK_IS_ROOT,
1012 26000000); 838 26000000);
1013 clk = tegra_clk_register_periph_gate("cdev1", "cdev1_fixed", 0, 839 clk = tegra_clk_register_periph_gate("cdev1", "cdev1_fixed", 0,
1014 clk_base, 0, 94, &periph_u_regs, 840 clk_base, 0, 94, periph_clk_enb_refcnt);
1015 periph_clk_enb_refcnt); 841 clks[TEGRA20_CLK_CDEV1] = clk;
1016 clk_register_clkdev(clk, "cdev1", NULL);
1017 clks[cdev1] = clk;
1018 842
1019 /* cdev2 */ 843 /* cdev2 */
1020 clk = clk_register_fixed_rate(NULL, "cdev2_fixed", NULL, CLK_IS_ROOT, 844 clk = clk_register_fixed_rate(NULL, "cdev2_fixed", NULL, CLK_IS_ROOT,
1021 26000000); 845 26000000);
1022 clk = tegra_clk_register_periph_gate("cdev2", "cdev2_fixed", 0, 846 clk = tegra_clk_register_periph_gate("cdev2", "cdev2_fixed", 0,
1023 clk_base, 0, 93, &periph_u_regs, 847 clk_base, 0, 93, periph_clk_enb_refcnt);
1024 periph_clk_enb_refcnt); 848 clks[TEGRA20_CLK_CDEV2] = clk;
1025 clk_register_clkdev(clk, "cdev2", NULL);
1026 clks[cdev2] = clk;
1027 849
1028 for (i = 0; i < ARRAY_SIZE(tegra_periph_clk_list); i++) { 850 for (i = 0; i < ARRAY_SIZE(tegra_periph_clk_list); i++) {
1029 data = &tegra_periph_clk_list[i]; 851 data = &tegra_periph_clk_list[i];
1030 clk = tegra_clk_register_periph(data->name, data->parent_names, 852 clk = tegra_clk_register_periph(data->name, data->p.parent_names,
1031 data->num_parents, &data->periph, 853 data->num_parents, &data->periph,
1032 clk_base, data->offset, data->flags); 854 clk_base, data->offset, data->flags);
1033 clk_register_clkdev(clk, data->con_id, data->dev_id);
1034 clks[data->clk_id] = clk; 855 clks[data->clk_id] = clk;
1035 } 856 }
1036 857
1037 for (i = 0; i < ARRAY_SIZE(tegra_periph_nodiv_clk_list); i++) { 858 for (i = 0; i < ARRAY_SIZE(tegra_periph_nodiv_clk_list); i++) {
1038 data = &tegra_periph_nodiv_clk_list[i]; 859 data = &tegra_periph_nodiv_clk_list[i];
1039 clk = tegra_clk_register_periph_nodiv(data->name, 860 clk = tegra_clk_register_periph_nodiv(data->name,
1040 data->parent_names, 861 data->p.parent_names,
1041 data->num_parents, &data->periph, 862 data->num_parents, &data->periph,
1042 clk_base, data->offset); 863 clk_base, data->offset);
1043 clk_register_clkdev(clk, data->con_id, data->dev_id);
1044 clks[data->clk_id] = clk; 864 clks[data->clk_id] = clk;
1045 } 865 }
1046}
1047
1048
1049static void __init tegra20_fixed_clk_init(void)
1050{
1051 struct clk *clk;
1052
1053 /* clk_32k */
1054 clk = clk_register_fixed_rate(NULL, "clk_32k", NULL, CLK_IS_ROOT,
1055 32768);
1056 clk_register_clkdev(clk, "clk_32k", NULL);
1057 clks[clk_32k] = clk;
1058}
1059
1060static void __init tegra20_pmc_clk_init(void)
1061{
1062 struct clk *clk;
1063 866
1064 /* blink */ 867 tegra_periph_clk_init(clk_base, pmc_base, tegra20_clks, &pll_p_params);
1065 writel_relaxed(0, pmc_base + PMC_BLINK_TIMER);
1066 clk = clk_register_gate(NULL, "blink_override", "clk_32k", 0,
1067 pmc_base + PMC_DPD_PADS_ORIDE,
1068 PMC_DPD_PADS_ORIDE_BLINK_ENB, 0, NULL);
1069 clk = clk_register_gate(NULL, "blink", "blink_override", 0,
1070 pmc_base + PMC_CTRL,
1071 PMC_CTRL_BLINK_ENB, 0, NULL);
1072 clk_register_clkdev(clk, "blink", NULL);
1073 clks[blink] = clk;
1074} 868}
1075 869
1076static void __init tegra20_osc_clk_init(void) 870static void __init tegra20_osc_clk_init(void)
@@ -1084,15 +878,13 @@ static void __init tegra20_osc_clk_init(void)
1084 /* clk_m */ 878 /* clk_m */
1085 clk = clk_register_fixed_rate(NULL, "clk_m", NULL, CLK_IS_ROOT | 879 clk = clk_register_fixed_rate(NULL, "clk_m", NULL, CLK_IS_ROOT |
1086 CLK_IGNORE_UNUSED, input_freq); 880 CLK_IGNORE_UNUSED, input_freq);
1087 clk_register_clkdev(clk, "clk_m", NULL); 881 clks[TEGRA20_CLK_CLK_M] = clk;
1088 clks[clk_m] = clk;
1089 882
1090 /* pll_ref */ 883 /* pll_ref */
1091 pll_ref_div = tegra20_get_pll_ref_div(); 884 pll_ref_div = tegra20_get_pll_ref_div();
1092 clk = clk_register_fixed_factor(NULL, "pll_ref", "clk_m", 885 clk = clk_register_fixed_factor(NULL, "pll_ref", "clk_m",
1093 CLK_SET_RATE_PARENT, 1, pll_ref_div); 886 CLK_SET_RATE_PARENT, 1, pll_ref_div);
1094 clk_register_clkdev(clk, "pll_ref", NULL); 887 clks[TEGRA20_CLK_PLL_REF] = clk;
1095 clks[pll_ref] = clk;
1096} 888}
1097 889
1098/* Tegra20 CPU clock and reset control functions */ 890/* Tegra20 CPU clock and reset control functions */
@@ -1226,49 +1018,49 @@ static struct tegra_cpu_car_ops tegra20_cpu_car_ops = {
1226}; 1018};
1227 1019
1228static struct tegra_clk_init_table init_table[] __initdata = { 1020static struct tegra_clk_init_table init_table[] __initdata = {
1229 {pll_p, clk_max, 216000000, 1}, 1021 {TEGRA20_CLK_PLL_P, TEGRA20_CLK_CLK_MAX, 216000000, 1},
1230 {pll_p_out1, clk_max, 28800000, 1}, 1022 {TEGRA20_CLK_PLL_P_OUT1, TEGRA20_CLK_CLK_MAX, 28800000, 1},
1231 {pll_p_out2, clk_max, 48000000, 1}, 1023 {TEGRA20_CLK_PLL_P_OUT2, TEGRA20_CLK_CLK_MAX, 48000000, 1},
1232 {pll_p_out3, clk_max, 72000000, 1}, 1024 {TEGRA20_CLK_PLL_P_OUT3, TEGRA20_CLK_CLK_MAX, 72000000, 1},
1233 {pll_p_out4, clk_max, 24000000, 1}, 1025 {TEGRA20_CLK_PLL_P_OUT4, TEGRA20_CLK_CLK_MAX, 24000000, 1},
1234 {pll_c, clk_max, 600000000, 1}, 1026 {TEGRA20_CLK_PLL_C, TEGRA20_CLK_CLK_MAX, 600000000, 1},
1235 {pll_c_out1, clk_max, 120000000, 1}, 1027 {TEGRA20_CLK_PLL_C_OUT1, TEGRA20_CLK_CLK_MAX, 120000000, 1},
1236 {sclk, pll_c_out1, 0, 1}, 1028 {TEGRA20_CLK_SCLK, TEGRA20_CLK_PLL_C_OUT1, 0, 1},
1237 {hclk, clk_max, 0, 1}, 1029 {TEGRA20_CLK_HCLK, TEGRA20_CLK_CLK_MAX, 0, 1},
1238 {pclk, clk_max, 60000000, 1}, 1030 {TEGRA20_CLK_PCLK, TEGRA20_CLK_CLK_MAX, 60000000, 1},
1239 {csite, clk_max, 0, 1}, 1031 {TEGRA20_CLK_CSITE, TEGRA20_CLK_CLK_MAX, 0, 1},
1240 {emc, clk_max, 0, 1}, 1032 {TEGRA20_CLK_EMC, TEGRA20_CLK_CLK_MAX, 0, 1},
1241 {cclk, clk_max, 0, 1}, 1033 {TEGRA20_CLK_CCLK, TEGRA20_CLK_CLK_MAX, 0, 1},
1242 {uarta, pll_p, 0, 0}, 1034 {TEGRA20_CLK_UARTA, TEGRA20_CLK_PLL_P, 0, 0},
1243 {uartb, pll_p, 0, 0}, 1035 {TEGRA20_CLK_UARTB, TEGRA20_CLK_PLL_P, 0, 0},
1244 {uartc, pll_p, 0, 0}, 1036 {TEGRA20_CLK_UARTC, TEGRA20_CLK_PLL_P, 0, 0},
1245 {uartd, pll_p, 0, 0}, 1037 {TEGRA20_CLK_UARTD, TEGRA20_CLK_PLL_P, 0, 0},
1246 {uarte, pll_p, 0, 0}, 1038 {TEGRA20_CLK_UARTE, TEGRA20_CLK_PLL_P, 0, 0},
1247 {pll_a, clk_max, 56448000, 1}, 1039 {TEGRA20_CLK_PLL_A, TEGRA20_CLK_CLK_MAX, 56448000, 1},
1248 {pll_a_out0, clk_max, 11289600, 1}, 1040 {TEGRA20_CLK_PLL_A_OUT0, TEGRA20_CLK_CLK_MAX, 11289600, 1},
1249 {cdev1, clk_max, 0, 1}, 1041 {TEGRA20_CLK_CDEV1, TEGRA20_CLK_CLK_MAX, 0, 1},
1250 {blink, clk_max, 32768, 1}, 1042 {TEGRA20_CLK_BLINK, TEGRA20_CLK_CLK_MAX, 32768, 1},
1251 {i2s1, pll_a_out0, 11289600, 0}, 1043 {TEGRA20_CLK_I2S1, TEGRA20_CLK_PLL_A_OUT0, 11289600, 0},
1252 {i2s2, pll_a_out0, 11289600, 0}, 1044 {TEGRA20_CLK_I2S2, TEGRA20_CLK_PLL_A_OUT0, 11289600, 0},
1253 {sdmmc1, pll_p, 48000000, 0}, 1045 {TEGRA20_CLK_SDMMC1, TEGRA20_CLK_PLL_P, 48000000, 0},
1254 {sdmmc3, pll_p, 48000000, 0}, 1046 {TEGRA20_CLK_SDMMC3, TEGRA20_CLK_PLL_P, 48000000, 0},
1255 {sdmmc4, pll_p, 48000000, 0}, 1047 {TEGRA20_CLK_SDMMC4, TEGRA20_CLK_PLL_P, 48000000, 0},
1256 {spi, pll_p, 20000000, 0}, 1048 {TEGRA20_CLK_SPI, TEGRA20_CLK_PLL_P, 20000000, 0},
1257 {sbc1, pll_p, 100000000, 0}, 1049 {TEGRA20_CLK_SBC1, TEGRA20_CLK_PLL_P, 100000000, 0},
1258 {sbc2, pll_p, 100000000, 0}, 1050 {TEGRA20_CLK_SBC2, TEGRA20_CLK_PLL_P, 100000000, 0},
1259 {sbc3, pll_p, 100000000, 0}, 1051 {TEGRA20_CLK_SBC3, TEGRA20_CLK_PLL_P, 100000000, 0},
1260 {sbc4, pll_p, 100000000, 0}, 1052 {TEGRA20_CLK_SBC4, TEGRA20_CLK_PLL_P, 100000000, 0},
1261 {host1x, pll_c, 150000000, 0}, 1053 {TEGRA20_CLK_HOST1X, TEGRA20_CLK_PLL_C, 150000000, 0},
1262 {disp1, pll_p, 600000000, 0}, 1054 {TEGRA20_CLK_DISP1, TEGRA20_CLK_PLL_P, 600000000, 0},
1263 {disp2, pll_p, 600000000, 0}, 1055 {TEGRA20_CLK_DISP2, TEGRA20_CLK_PLL_P, 600000000, 0},
1264 {gr2d, pll_c, 300000000, 0}, 1056 {TEGRA20_CLK_GR2D, TEGRA20_CLK_PLL_C, 300000000, 0},
1265 {gr3d, pll_c, 300000000, 0}, 1057 {TEGRA20_CLK_GR3D, TEGRA20_CLK_PLL_C, 300000000, 0},
1266 {clk_max, clk_max, 0, 0}, /* This MUST be the last entry */ 1058 {TEGRA20_CLK_CLK_MAX, TEGRA20_CLK_CLK_MAX, 0, 0}, /* This MUST be the last entry */
1267}; 1059};
1268 1060
1269static void __init tegra20_clock_apply_init_table(void) 1061static void __init tegra20_clock_apply_init_table(void)
1270{ 1062{
1271 tegra_init_from_table(init_table, clks, clk_max); 1063 tegra_init_from_table(init_table, clks, TEGRA20_CLK_CLK_MAX);
1272} 1064}
1273 1065
1274/* 1066/*
@@ -1277,11 +1069,11 @@ static void __init tegra20_clock_apply_init_table(void)
1277 * table under two names. 1069 * table under two names.
1278 */ 1070 */
1279static struct tegra_clk_duplicate tegra_clk_duplicates[] = { 1071static struct tegra_clk_duplicate tegra_clk_duplicates[] = {
1280 TEGRA_CLK_DUPLICATE(usbd, "utmip-pad", NULL), 1072 TEGRA_CLK_DUPLICATE(TEGRA20_CLK_USBD, "utmip-pad", NULL),
1281 TEGRA_CLK_DUPLICATE(usbd, "tegra-ehci.0", NULL), 1073 TEGRA_CLK_DUPLICATE(TEGRA20_CLK_USBD, "tegra-ehci.0", NULL),
1282 TEGRA_CLK_DUPLICATE(usbd, "tegra-otg", NULL), 1074 TEGRA_CLK_DUPLICATE(TEGRA20_CLK_USBD, "tegra-otg", NULL),
1283 TEGRA_CLK_DUPLICATE(cclk, NULL, "cpu"), 1075 TEGRA_CLK_DUPLICATE(TEGRA20_CLK_CCLK, NULL, "cpu"),
1284 TEGRA_CLK_DUPLICATE(clk_max, NULL, NULL), /* Must be the last entry */ 1076 TEGRA_CLK_DUPLICATE(TEGRA20_CLK_CLK_MAX, NULL, NULL), /* Must be the last entry */
1285}; 1077};
1286 1078
1287static const struct of_device_id pmc_match[] __initconst = { 1079static const struct of_device_id pmc_match[] __initconst = {
@@ -1291,7 +1083,6 @@ static const struct of_device_id pmc_match[] __initconst = {
1291 1083
1292static void __init tegra20_clock_init(struct device_node *np) 1084static void __init tegra20_clock_init(struct device_node *np)
1293{ 1085{
1294 int i;
1295 struct device_node *node; 1086 struct device_node *node;
1296 1087
1297 clk_base = of_iomap(np, 0); 1088 clk_base = of_iomap(np, 0);
@@ -1312,30 +1103,24 @@ static void __init tegra20_clock_init(struct device_node *np)
1312 BUG(); 1103 BUG();
1313 } 1104 }
1314 1105
1106 clks = tegra_clk_init(clk_base, TEGRA20_CLK_CLK_MAX,
1107 TEGRA20_CLK_PERIPH_BANKS);
1108 if (!clks)
1109 return;
1110
1315 tegra20_osc_clk_init(); 1111 tegra20_osc_clk_init();
1316 tegra20_pmc_clk_init(); 1112 tegra_fixed_clk_init(tegra20_clks);
1317 tegra20_fixed_clk_init();
1318 tegra20_pll_init(); 1113 tegra20_pll_init();
1319 tegra20_super_clk_init(); 1114 tegra20_super_clk_init();
1115 tegra_super_clk_gen4_init(clk_base, pmc_base, tegra20_clks, NULL);
1320 tegra20_periph_clk_init(); 1116 tegra20_periph_clk_init();
1321 tegra20_audio_clk_init(); 1117 tegra20_audio_clk_init();
1118 tegra_pmc_clk_init(pmc_base, tegra20_clks);
1322 1119
1120 tegra_init_dup_clks(tegra_clk_duplicates, clks, TEGRA20_CLK_CLK_MAX);
1323 1121
1324 for (i = 0; i < ARRAY_SIZE(clks); i++) { 1122 tegra_add_of_provider(np);
1325 if (IS_ERR(clks[i])) { 1123 tegra_register_devclks(devclks, ARRAY_SIZE(devclks));
1326 pr_err("Tegra20 clk %d: register failed with %ld\n",
1327 i, PTR_ERR(clks[i]));
1328 BUG();
1329 }
1330 if (!clks[i])
1331 clks[i] = ERR_PTR(-EINVAL);
1332 }
1333
1334 tegra_init_dup_clks(tegra_clk_duplicates, clks, clk_max);
1335
1336 clk_data.clks = clks;
1337 clk_data.clk_num = ARRAY_SIZE(clks);
1338 of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);
1339 1124
1340 tegra_clk_apply_init_table = tegra20_clock_apply_init_table; 1125 tegra_clk_apply_init_table = tegra20_clock_apply_init_table;
1341 1126
diff --git a/drivers/clk/tegra/clk-tegra30.c b/drivers/clk/tegra/clk-tegra30.c
index dbe7c8003c5c..8b10c38b6e3c 100644
--- a/drivers/clk/tegra/clk-tegra30.c
+++ b/drivers/clk/tegra/clk-tegra30.c
@@ -23,42 +23,9 @@
23#include <linux/of_address.h> 23#include <linux/of_address.h>
24#include <linux/clk/tegra.h> 24#include <linux/clk/tegra.h>
25#include <linux/tegra-powergate.h> 25#include <linux/tegra-powergate.h>
26 26#include <dt-bindings/clock/tegra30-car.h>
27#include "clk.h" 27#include "clk.h"
28 28#include "clk-id.h"
29#define RST_DEVICES_L 0x004
30#define RST_DEVICES_H 0x008
31#define RST_DEVICES_U 0x00c
32#define RST_DEVICES_V 0x358
33#define RST_DEVICES_W 0x35c
34#define RST_DEVICES_SET_L 0x300
35#define RST_DEVICES_CLR_L 0x304
36#define RST_DEVICES_SET_H 0x308
37#define RST_DEVICES_CLR_H 0x30c
38#define RST_DEVICES_SET_U 0x310
39#define RST_DEVICES_CLR_U 0x314
40#define RST_DEVICES_SET_V 0x430
41#define RST_DEVICES_CLR_V 0x434
42#define RST_DEVICES_SET_W 0x438
43#define RST_DEVICES_CLR_W 0x43c
44#define RST_DEVICES_NUM 5
45
46#define CLK_OUT_ENB_L 0x010
47#define CLK_OUT_ENB_H 0x014
48#define CLK_OUT_ENB_U 0x018
49#define CLK_OUT_ENB_V 0x360
50#define CLK_OUT_ENB_W 0x364
51#define CLK_OUT_ENB_SET_L 0x320
52#define CLK_OUT_ENB_CLR_L 0x324
53#define CLK_OUT_ENB_SET_H 0x328
54#define CLK_OUT_ENB_CLR_H 0x32c
55#define CLK_OUT_ENB_SET_U 0x330
56#define CLK_OUT_ENB_CLR_U 0x334
57#define CLK_OUT_ENB_SET_V 0x440
58#define CLK_OUT_ENB_CLR_V 0x444
59#define CLK_OUT_ENB_SET_W 0x448
60#define CLK_OUT_ENB_CLR_W 0x44c
61#define CLK_OUT_ENB_NUM 5
62 29
63#define OSC_CTRL 0x50 30#define OSC_CTRL 0x50
64#define OSC_CTRL_OSC_FREQ_MASK (0xF<<28) 31#define OSC_CTRL_OSC_FREQ_MASK (0xF<<28)
@@ -92,6 +59,8 @@
92 59
93#define SYSTEM_CLK_RATE 0x030 60#define SYSTEM_CLK_RATE 0x030
94 61
62#define TEGRA30_CLK_PERIPH_BANKS 5
63
95#define PLLC_BASE 0x80 64#define PLLC_BASE 0x80
96#define PLLC_MISC 0x8c 65#define PLLC_MISC 0x8c
97#define PLLM_BASE 0x90 66#define PLLM_BASE 0x90
@@ -132,88 +101,21 @@
132#define AUDIO_SYNC_CLK_I2S4 0x4b0 101#define AUDIO_SYNC_CLK_I2S4 0x4b0
133#define AUDIO_SYNC_CLK_SPDIF 0x4b4 102#define AUDIO_SYNC_CLK_SPDIF 0x4b4
134 103
135#define PMC_CLK_OUT_CNTRL 0x1a8
136
137#define CLK_SOURCE_I2S0 0x1d8
138#define CLK_SOURCE_I2S1 0x100
139#define CLK_SOURCE_I2S2 0x104
140#define CLK_SOURCE_I2S3 0x3bc
141#define CLK_SOURCE_I2S4 0x3c0
142#define CLK_SOURCE_SPDIF_OUT 0x108 104#define CLK_SOURCE_SPDIF_OUT 0x108
143#define CLK_SOURCE_SPDIF_IN 0x10c
144#define CLK_SOURCE_PWM 0x110 105#define CLK_SOURCE_PWM 0x110
145#define CLK_SOURCE_D_AUDIO 0x3d0 106#define CLK_SOURCE_D_AUDIO 0x3d0
146#define CLK_SOURCE_DAM0 0x3d8 107#define CLK_SOURCE_DAM0 0x3d8
147#define CLK_SOURCE_DAM1 0x3dc 108#define CLK_SOURCE_DAM1 0x3dc
148#define CLK_SOURCE_DAM2 0x3e0 109#define CLK_SOURCE_DAM2 0x3e0
149#define CLK_SOURCE_HDA 0x428
150#define CLK_SOURCE_HDA2CODEC_2X 0x3e4
151#define CLK_SOURCE_SBC1 0x134
152#define CLK_SOURCE_SBC2 0x118
153#define CLK_SOURCE_SBC3 0x11c
154#define CLK_SOURCE_SBC4 0x1b4
155#define CLK_SOURCE_SBC5 0x3c8
156#define CLK_SOURCE_SBC6 0x3cc
157#define CLK_SOURCE_SATA_OOB 0x420
158#define CLK_SOURCE_SATA 0x424
159#define CLK_SOURCE_NDFLASH 0x160
160#define CLK_SOURCE_NDSPEED 0x3f8
161#define CLK_SOURCE_VFIR 0x168
162#define CLK_SOURCE_SDMMC1 0x150
163#define CLK_SOURCE_SDMMC2 0x154
164#define CLK_SOURCE_SDMMC3 0x1bc
165#define CLK_SOURCE_SDMMC4 0x164
166#define CLK_SOURCE_VDE 0x1c8
167#define CLK_SOURCE_CSITE 0x1d4
168#define CLK_SOURCE_LA 0x1f8
169#define CLK_SOURCE_OWR 0x1cc
170#define CLK_SOURCE_NOR 0x1d0
171#define CLK_SOURCE_MIPI 0x174
172#define CLK_SOURCE_I2C1 0x124
173#define CLK_SOURCE_I2C2 0x198
174#define CLK_SOURCE_I2C3 0x1b8
175#define CLK_SOURCE_I2C4 0x3c4
176#define CLK_SOURCE_I2C5 0x128
177#define CLK_SOURCE_UARTA 0x178
178#define CLK_SOURCE_UARTB 0x17c
179#define CLK_SOURCE_UARTC 0x1a0
180#define CLK_SOURCE_UARTD 0x1c0
181#define CLK_SOURCE_UARTE 0x1c4
182#define CLK_SOURCE_VI 0x148
183#define CLK_SOURCE_VI_SENSOR 0x1a8
184#define CLK_SOURCE_3D 0x158
185#define CLK_SOURCE_3D2 0x3b0 110#define CLK_SOURCE_3D2 0x3b0
186#define CLK_SOURCE_2D 0x15c 111#define CLK_SOURCE_2D 0x15c
187#define CLK_SOURCE_EPP 0x16c
188#define CLK_SOURCE_MPE 0x170
189#define CLK_SOURCE_HOST1X 0x180
190#define CLK_SOURCE_CVE 0x140
191#define CLK_SOURCE_TVO 0x188
192#define CLK_SOURCE_DTV 0x1dc
193#define CLK_SOURCE_HDMI 0x18c 112#define CLK_SOURCE_HDMI 0x18c
194#define CLK_SOURCE_TVDAC 0x194
195#define CLK_SOURCE_DISP1 0x138
196#define CLK_SOURCE_DISP2 0x13c
197#define CLK_SOURCE_DSIB 0xd0 113#define CLK_SOURCE_DSIB 0xd0
198#define CLK_SOURCE_TSENSOR 0x3b8
199#define CLK_SOURCE_ACTMON 0x3e8
200#define CLK_SOURCE_EXTERN1 0x3ec
201#define CLK_SOURCE_EXTERN2 0x3f0
202#define CLK_SOURCE_EXTERN3 0x3f4
203#define CLK_SOURCE_I2CSLOW 0x3fc
204#define CLK_SOURCE_SE 0x42c 114#define CLK_SOURCE_SE 0x42c
205#define CLK_SOURCE_MSELECT 0x3b4
206#define CLK_SOURCE_EMC 0x19c 115#define CLK_SOURCE_EMC 0x19c
207 116
208#define AUDIO_SYNC_DOUBLER 0x49c 117#define AUDIO_SYNC_DOUBLER 0x49c
209 118
210#define PMC_CTRL 0
211#define PMC_CTRL_BLINK_ENB 7
212
213#define PMC_DPD_PADS_ORIDE 0x1c
214#define PMC_DPD_PADS_ORIDE_BLINK_ENB 20
215#define PMC_BLINK_TIMER 0x40
216
217#define UTMIP_PLL_CFG2 0x488 119#define UTMIP_PLL_CFG2 0x488
218#define UTMIP_PLL_CFG2_STABLE_COUNT(x) (((x) & 0xffff) << 6) 120#define UTMIP_PLL_CFG2_STABLE_COUNT(x) (((x) & 0xffff) << 6)
219#define UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(x) (((x) & 0x3f) << 18) 121#define UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(x) (((x) & 0x3f) << 18)
@@ -266,89 +168,41 @@ static struct cpu_clk_suspend_context {
266} tegra30_cpu_clk_sctx; 168} tegra30_cpu_clk_sctx;
267#endif 169#endif
268 170
269static int periph_clk_enb_refcnt[CLK_OUT_ENB_NUM * 32];
270
271static void __iomem *clk_base; 171static void __iomem *clk_base;
272static void __iomem *pmc_base; 172static void __iomem *pmc_base;
273static unsigned long input_freq; 173static unsigned long input_freq;
274 174
275static DEFINE_SPINLOCK(clk_doubler_lock);
276static DEFINE_SPINLOCK(clk_out_lock);
277static DEFINE_SPINLOCK(pll_div_lock);
278static DEFINE_SPINLOCK(cml_lock); 175static DEFINE_SPINLOCK(cml_lock);
279static DEFINE_SPINLOCK(pll_d_lock); 176static DEFINE_SPINLOCK(pll_d_lock);
280static DEFINE_SPINLOCK(sysrate_lock);
281
282#define TEGRA_INIT_DATA_MUX(_name, _con_id, _dev_id, _parents, _offset, \
283 _clk_num, _regs, _gate_flags, _clk_id) \
284 TEGRA_INIT_DATA(_name, _con_id, _dev_id, _parents, _offset, \
285 30, 2, 0, 0, 8, 1, 0, _regs, _clk_num, \
286 periph_clk_enb_refcnt, _gate_flags, _clk_id)
287
288#define TEGRA_INIT_DATA_DIV16(_name, _con_id, _dev_id, _parents, _offset, \
289 _clk_num, _regs, _gate_flags, _clk_id) \
290 TEGRA_INIT_DATA(_name, _con_id, _dev_id, _parents, _offset, \
291 30, 2, 0, 0, 16, 0, TEGRA_DIVIDER_ROUND_UP, \
292 _regs, _clk_num, periph_clk_enb_refcnt, \
293 _gate_flags, _clk_id)
294
295#define TEGRA_INIT_DATA_MUX8(_name, _con_id, _dev_id, _parents, _offset, \
296 _clk_num, _regs, _gate_flags, _clk_id) \
297 TEGRA_INIT_DATA(_name, _con_id, _dev_id, _parents, _offset, \
298 29, 3, 0, 0, 8, 1, 0, _regs, _clk_num, \
299 periph_clk_enb_refcnt, _gate_flags, _clk_id)
300
301#define TEGRA_INIT_DATA_INT(_name, _con_id, _dev_id, _parents, _offset, \
302 _clk_num, _regs, _gate_flags, _clk_id) \
303 TEGRA_INIT_DATA(_name, _con_id, _dev_id, _parents, _offset, \
304 30, 2, 0, 0, 8, 1, TEGRA_DIVIDER_INT, _regs, \
305 _clk_num, periph_clk_enb_refcnt, _gate_flags, \
306 _clk_id)
307 177
308#define TEGRA_INIT_DATA_UART(_name, _con_id, _dev_id, _parents, _offset,\ 178#define TEGRA_INIT_DATA_MUX(_name, _parents, _offset, \
309 _clk_num, _regs, _clk_id) \ 179 _clk_num, _gate_flags, _clk_id) \
310 TEGRA_INIT_DATA(_name, _con_id, _dev_id, _parents, _offset, \ 180 TEGRA_INIT_DATA(_name, NULL, NULL, _parents, _offset, \
311 30, 2, 0, 0, 16, 1, TEGRA_DIVIDER_UART, _regs, \ 181 30, 2, 0, 0, 8, 1, TEGRA_DIVIDER_ROUND_UP, \
312 _clk_num, periph_clk_enb_refcnt, 0, _clk_id) 182 _clk_num, _gate_flags, _clk_id)
183
184#define TEGRA_INIT_DATA_MUX8(_name, _parents, _offset, \
185 _clk_num, _gate_flags, _clk_id) \
186 TEGRA_INIT_DATA(_name, NULL, NULL, _parents, _offset, \
187 29, 3, 0, 0, 8, 1, TEGRA_DIVIDER_ROUND_UP, \
188 _clk_num, _gate_flags, _clk_id)
189
190#define TEGRA_INIT_DATA_INT(_name, _parents, _offset, \
191 _clk_num, _gate_flags, _clk_id) \
192 TEGRA_INIT_DATA(_name, NULL, NULL, _parents, _offset, \
193 30, 2, 0, 0, 8, 1, TEGRA_DIVIDER_INT | \
194 TEGRA_DIVIDER_ROUND_UP, _clk_num, \
195 _gate_flags, _clk_id)
313 196
314#define TEGRA_INIT_DATA_NODIV(_name, _con_id, _dev_id, _parents, _offset, \ 197#define TEGRA_INIT_DATA_NODIV(_name, _parents, _offset, \
315 _mux_shift, _mux_width, _clk_num, _regs, \ 198 _mux_shift, _mux_width, _clk_num, \
316 _gate_flags, _clk_id) \ 199 _gate_flags, _clk_id) \
317 TEGRA_INIT_DATA(_name, _con_id, _dev_id, _parents, _offset, \ 200 TEGRA_INIT_DATA(_name, NULL, NULL, _parents, _offset, \
318 _mux_shift, _mux_width, 0, 0, 0, 0, 0, _regs, \ 201 _mux_shift, _mux_width, 0, 0, 0, 0, 0,\
319 _clk_num, periph_clk_enb_refcnt, _gate_flags, \ 202 _clk_num, _gate_flags, \
320 _clk_id) 203 _clk_id)
321 204
322/* 205static struct clk **clks;
323 * IDs assigned here must be in sync with DT bindings definition
324 * for Tegra30 clocks.
325 */
326enum tegra30_clk {
327 cpu, rtc = 4, timer, uarta, gpio = 8, sdmmc2, i2s1 = 11, i2c1, ndflash,
328 sdmmc1, sdmmc4, pwm = 17, i2s2, epp, gr2d = 21, usbd, isp, gr3d,
329 disp2 = 26, disp1, host1x, vcp, i2s0, cop_cache, mc, ahbdma, apbdma,
330 kbc = 36, statmon, pmc, kfuse = 40, sbc1, nor, sbc2 = 44, sbc3 = 46,
331 i2c5, dsia, mipi = 50, hdmi, csi, tvdac, i2c2, uartc, emc = 57, usb2,
332 usb3, mpe, vde, bsea, bsev, speedo, uartd, uarte, i2c3, sbc4, sdmmc3,
333 pcie, owr, afi, csite, pciex, avpucq, la, dtv = 79, ndspeed, i2cslow,
334 dsib, irama = 84, iramb, iramc, iramd, cram2, audio_2x = 90, csus = 92,
335 cdev2, cdev1, cpu_g = 96, cpu_lp, gr3d2, mselect, tsensor, i2s3, i2s4,
336 i2c4, sbc5, sbc6, d_audio, apbif, dam0, dam1, dam2, hda2codec_2x,
337 atomics, audio0_2x, audio1_2x, audio2_2x, audio3_2x, audio4_2x,
338 spdif_2x, actmon, extern1, extern2, extern3, sata_oob, sata, hda,
339 se = 127, hda2hdmi, sata_cold, uartb = 160, vfir, spdif_in, spdif_out,
340 vi, vi_sensor, fuse, fuse_burn, cve, tvo, clk_32k, clk_m, clk_m_div2,
341 clk_m_div4, pll_ref, pll_c, pll_c_out1, pll_m, pll_m_out1, pll_p,
342 pll_p_out1, pll_p_out2, pll_p_out3, pll_p_out4, pll_a, pll_a_out0,
343 pll_d, pll_d_out0, pll_d2, pll_d2_out0, pll_u, pll_x, pll_x_out0, pll_e,
344 spdif_in_sync, i2s0_sync, i2s1_sync, i2s2_sync, i2s3_sync, i2s4_sync,
345 vimclk_sync, audio0, audio1, audio2, audio3, audio4, spdif, clk_out_1,
346 clk_out_2, clk_out_3, sclk, blink, cclk_g, cclk_lp, twd, cml0, cml1,
347 hclk, pclk, clk_out_1_mux = 300, clk_max
348};
349
350static struct clk *clks[clk_max];
351static struct clk_onecell_data clk_data;
352 206
353/* 207/*
354 * Structure defining the fields for USB UTMI clocks Parameters. 208 * Structure defining the fields for USB UTMI clocks Parameters.
@@ -564,6 +418,8 @@ static struct tegra_clk_pll_params pll_c_params = {
564 .lock_mask = PLL_BASE_LOCK, 418 .lock_mask = PLL_BASE_LOCK,
565 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE, 419 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
566 .lock_delay = 300, 420 .lock_delay = 300,
421 .freq_table = pll_c_freq_table,
422 .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_USE_LOCK,
567}; 423};
568 424
569static struct div_nmp pllm_nmp = { 425static struct div_nmp pllm_nmp = {
@@ -593,6 +449,9 @@ static struct tegra_clk_pll_params pll_m_params = {
593 .div_nmp = &pllm_nmp, 449 .div_nmp = &pllm_nmp,
594 .pmc_divnm_reg = PMC_PLLM_WB0_OVERRIDE, 450 .pmc_divnm_reg = PMC_PLLM_WB0_OVERRIDE,
595 .pmc_divp_reg = PMC_PLLM_WB0_OVERRIDE, 451 .pmc_divp_reg = PMC_PLLM_WB0_OVERRIDE,
452 .freq_table = pll_m_freq_table,
453 .flags = TEGRA_PLLM | TEGRA_PLL_HAS_CPCON |
454 TEGRA_PLL_SET_DCCON | TEGRA_PLL_USE_LOCK,
596}; 455};
597 456
598static struct tegra_clk_pll_params pll_p_params = { 457static struct tegra_clk_pll_params pll_p_params = {
@@ -607,6 +466,9 @@ static struct tegra_clk_pll_params pll_p_params = {
607 .lock_mask = PLL_BASE_LOCK, 466 .lock_mask = PLL_BASE_LOCK,
608 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE, 467 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
609 .lock_delay = 300, 468 .lock_delay = 300,
469 .freq_table = pll_p_freq_table,
470 .flags = TEGRA_PLL_FIXED | TEGRA_PLL_HAS_CPCON | TEGRA_PLL_USE_LOCK,
471 .fixed_rate = 408000000,
610}; 472};
611 473
612static struct tegra_clk_pll_params pll_a_params = { 474static struct tegra_clk_pll_params pll_a_params = {
@@ -621,6 +483,8 @@ static struct tegra_clk_pll_params pll_a_params = {
621 .lock_mask = PLL_BASE_LOCK, 483 .lock_mask = PLL_BASE_LOCK,
622 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE, 484 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
623 .lock_delay = 300, 485 .lock_delay = 300,
486 .freq_table = pll_a_freq_table,
487 .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_USE_LOCK,
624}; 488};
625 489
626static struct tegra_clk_pll_params pll_d_params = { 490static struct tegra_clk_pll_params pll_d_params = {
@@ -635,6 +499,10 @@ static struct tegra_clk_pll_params pll_d_params = {
635 .lock_mask = PLL_BASE_LOCK, 499 .lock_mask = PLL_BASE_LOCK,
636 .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE, 500 .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE,
637 .lock_delay = 1000, 501 .lock_delay = 1000,
502 .freq_table = pll_d_freq_table,
503 .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON |
504 TEGRA_PLL_USE_LOCK,
505
638}; 506};
639 507
640static struct tegra_clk_pll_params pll_d2_params = { 508static struct tegra_clk_pll_params pll_d2_params = {
@@ -649,6 +517,9 @@ static struct tegra_clk_pll_params pll_d2_params = {
649 .lock_mask = PLL_BASE_LOCK, 517 .lock_mask = PLL_BASE_LOCK,
650 .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE, 518 .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE,
651 .lock_delay = 1000, 519 .lock_delay = 1000,
520 .freq_table = pll_d_freq_table,
521 .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON |
522 TEGRA_PLL_USE_LOCK,
652}; 523};
653 524
654static struct tegra_clk_pll_params pll_u_params = { 525static struct tegra_clk_pll_params pll_u_params = {
@@ -664,6 +535,8 @@ static struct tegra_clk_pll_params pll_u_params = {
664 .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE, 535 .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE,
665 .lock_delay = 1000, 536 .lock_delay = 1000,
666 .pdiv_tohw = pllu_p, 537 .pdiv_tohw = pllu_p,
538 .freq_table = pll_u_freq_table,
539 .flags = TEGRA_PLLU | TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON,
667}; 540};
668 541
669static struct tegra_clk_pll_params pll_x_params = { 542static struct tegra_clk_pll_params pll_x_params = {
@@ -678,6 +551,9 @@ static struct tegra_clk_pll_params pll_x_params = {
678 .lock_mask = PLL_BASE_LOCK, 551 .lock_mask = PLL_BASE_LOCK,
679 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE, 552 .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE,
680 .lock_delay = 300, 553 .lock_delay = 300,
554 .freq_table = pll_x_freq_table,
555 .flags = TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_DCCON |
556 TEGRA_PLL_USE_LOCK,
681}; 557};
682 558
683static struct tegra_clk_pll_params pll_e_params = { 559static struct tegra_clk_pll_params pll_e_params = {
@@ -692,116 +568,299 @@ static struct tegra_clk_pll_params pll_e_params = {
692 .lock_mask = PLLE_MISC_LOCK, 568 .lock_mask = PLLE_MISC_LOCK,
693 .lock_enable_bit_idx = PLLE_MISC_LOCK_ENABLE, 569 .lock_enable_bit_idx = PLLE_MISC_LOCK_ENABLE,
694 .lock_delay = 300, 570 .lock_delay = 300,
571 .freq_table = pll_e_freq_table,
572 .flags = TEGRA_PLLE_CONFIGURE | TEGRA_PLL_FIXED,
573 .fixed_rate = 100000000,
695}; 574};
696 575
697/* Peripheral clock registers */ 576static unsigned long tegra30_input_freq[] = {
698static struct tegra_clk_periph_regs periph_l_regs = { 577 [0] = 13000000,
699 .enb_reg = CLK_OUT_ENB_L, 578 [1] = 16800000,
700 .enb_set_reg = CLK_OUT_ENB_SET_L, 579 [4] = 19200000,
701 .enb_clr_reg = CLK_OUT_ENB_CLR_L, 580 [5] = 38400000,
702 .rst_reg = RST_DEVICES_L, 581 [8] = 12000000,
703 .rst_set_reg = RST_DEVICES_SET_L, 582 [9] = 48000000,
704 .rst_clr_reg = RST_DEVICES_CLR_L, 583 [12] = 260000000,
705}; 584};
706 585
707static struct tegra_clk_periph_regs periph_h_regs = { 586static struct tegra_devclk devclks[] __initdata = {
708 .enb_reg = CLK_OUT_ENB_H, 587 { .con_id = "pll_c", .dt_id = TEGRA30_CLK_PLL_C },
709 .enb_set_reg = CLK_OUT_ENB_SET_H, 588 { .con_id = "pll_c_out1", .dt_id = TEGRA30_CLK_PLL_C_OUT1 },
710 .enb_clr_reg = CLK_OUT_ENB_CLR_H, 589 { .con_id = "pll_p", .dt_id = TEGRA30_CLK_PLL_P },
711 .rst_reg = RST_DEVICES_H, 590 { .con_id = "pll_p_out1", .dt_id = TEGRA30_CLK_PLL_P_OUT1 },
712 .rst_set_reg = RST_DEVICES_SET_H, 591 { .con_id = "pll_p_out2", .dt_id = TEGRA30_CLK_PLL_P_OUT2 },
713 .rst_clr_reg = RST_DEVICES_CLR_H, 592 { .con_id = "pll_p_out3", .dt_id = TEGRA30_CLK_PLL_P_OUT3 },
593 { .con_id = "pll_p_out4", .dt_id = TEGRA30_CLK_PLL_P_OUT4 },
594 { .con_id = "pll_m", .dt_id = TEGRA30_CLK_PLL_M },
595 { .con_id = "pll_m_out1", .dt_id = TEGRA30_CLK_PLL_M_OUT1 },
596 { .con_id = "pll_x", .dt_id = TEGRA30_CLK_PLL_X },
597 { .con_id = "pll_x_out0", .dt_id = TEGRA30_CLK_PLL_X_OUT0 },
598 { .con_id = "pll_u", .dt_id = TEGRA30_CLK_PLL_U },
599 { .con_id = "pll_d", .dt_id = TEGRA30_CLK_PLL_D },
600 { .con_id = "pll_d_out0", .dt_id = TEGRA30_CLK_PLL_D_OUT0 },
601 { .con_id = "pll_d2", .dt_id = TEGRA30_CLK_PLL_D2 },
602 { .con_id = "pll_d2_out0", .dt_id = TEGRA30_CLK_PLL_D2_OUT0 },
603 { .con_id = "pll_a", .dt_id = TEGRA30_CLK_PLL_A },
604 { .con_id = "pll_a_out0", .dt_id = TEGRA30_CLK_PLL_A_OUT0 },
605 { .con_id = "pll_e", .dt_id = TEGRA30_CLK_PLL_E },
606 { .con_id = "spdif_in_sync", .dt_id = TEGRA30_CLK_SPDIF_IN_SYNC },
607 { .con_id = "i2s0_sync", .dt_id = TEGRA30_CLK_I2S0_SYNC },
608 { .con_id = "i2s1_sync", .dt_id = TEGRA30_CLK_I2S1_SYNC },
609 { .con_id = "i2s2_sync", .dt_id = TEGRA30_CLK_I2S2_SYNC },
610 { .con_id = "i2s3_sync", .dt_id = TEGRA30_CLK_I2S3_SYNC },
611 { .con_id = "i2s4_sync", .dt_id = TEGRA30_CLK_I2S4_SYNC },
612 { .con_id = "vimclk_sync", .dt_id = TEGRA30_CLK_VIMCLK_SYNC },
613 { .con_id = "audio0", .dt_id = TEGRA30_CLK_AUDIO0 },
614 { .con_id = "audio1", .dt_id = TEGRA30_CLK_AUDIO1 },
615 { .con_id = "audio2", .dt_id = TEGRA30_CLK_AUDIO2 },
616 { .con_id = "audio3", .dt_id = TEGRA30_CLK_AUDIO3 },
617 { .con_id = "audio4", .dt_id = TEGRA30_CLK_AUDIO4 },
618 { .con_id = "spdif", .dt_id = TEGRA30_CLK_SPDIF },
619 { .con_id = "audio0_2x", .dt_id = TEGRA30_CLK_AUDIO0_2X },
620 { .con_id = "audio1_2x", .dt_id = TEGRA30_CLK_AUDIO1_2X },
621 { .con_id = "audio2_2x", .dt_id = TEGRA30_CLK_AUDIO2_2X },
622 { .con_id = "audio3_2x", .dt_id = TEGRA30_CLK_AUDIO3_2X },
623 { .con_id = "audio4_2x", .dt_id = TEGRA30_CLK_AUDIO4_2X },
624 { .con_id = "spdif_2x", .dt_id = TEGRA30_CLK_SPDIF_2X },
625 { .con_id = "extern1", .dev_id = "clk_out_1", .dt_id = TEGRA30_CLK_EXTERN1 },
626 { .con_id = "extern2", .dev_id = "clk_out_2", .dt_id = TEGRA30_CLK_EXTERN2 },
627 { .con_id = "extern3", .dev_id = "clk_out_3", .dt_id = TEGRA30_CLK_EXTERN3 },
628 { .con_id = "blink", .dt_id = TEGRA30_CLK_BLINK },
629 { .con_id = "cclk_g", .dt_id = TEGRA30_CLK_CCLK_G },
630 { .con_id = "cclk_lp", .dt_id = TEGRA30_CLK_CCLK_LP },
631 { .con_id = "sclk", .dt_id = TEGRA30_CLK_SCLK },
632 { .con_id = "hclk", .dt_id = TEGRA30_CLK_HCLK },
633 { .con_id = "pclk", .dt_id = TEGRA30_CLK_PCLK },
634 { .con_id = "twd", .dt_id = TEGRA30_CLK_TWD },
635 { .con_id = "emc", .dt_id = TEGRA30_CLK_EMC },
636 { .con_id = "clk_32k", .dt_id = TEGRA30_CLK_CLK_32K },
637 { .con_id = "clk_m_div2", .dt_id = TEGRA30_CLK_CLK_M_DIV2 },
638 { .con_id = "clk_m_div4", .dt_id = TEGRA30_CLK_CLK_M_DIV4 },
639 { .con_id = "cml0", .dt_id = TEGRA30_CLK_CML0 },
640 { .con_id = "cml1", .dt_id = TEGRA30_CLK_CML1 },
641 { .con_id = "clk_m", .dt_id = TEGRA30_CLK_CLK_M },
642 { .con_id = "pll_ref", .dt_id = TEGRA30_CLK_PLL_REF },
643 { .con_id = "csus", .dev_id = "tengra_camera", .dt_id = TEGRA30_CLK_CSUS },
644 { .con_id = "vcp", .dev_id = "tegra-avp", .dt_id = TEGRA30_CLK_VCP },
645 { .con_id = "bsea", .dev_id = "tegra-avp", .dt_id = TEGRA30_CLK_BSEA },
646 { .con_id = "bsev", .dev_id = "tegra-aes", .dt_id = TEGRA30_CLK_BSEV },
647 { .con_id = "dsia", .dev_id = "tegradc.0", .dt_id = TEGRA30_CLK_DSIA },
648 { .con_id = "csi", .dev_id = "tegra_camera", .dt_id = TEGRA30_CLK_CSI },
649 { .con_id = "isp", .dev_id = "tegra_camera", .dt_id = TEGRA30_CLK_ISP },
650 { .con_id = "pcie", .dev_id = "tegra-pcie", .dt_id = TEGRA30_CLK_PCIE },
651 { .con_id = "afi", .dev_id = "tegra-pcie", .dt_id = TEGRA30_CLK_AFI },
652 { .con_id = "fuse", .dt_id = TEGRA30_CLK_FUSE },
653 { .con_id = "fuse_burn", .dev_id = "fuse-tegra", .dt_id = TEGRA30_CLK_FUSE_BURN },
654 { .con_id = "apbif", .dev_id = "tegra30-ahub", .dt_id = TEGRA30_CLK_APBIF },
655 { .con_id = "hda2hdmi", .dev_id = "tegra30-hda", .dt_id = TEGRA30_CLK_HDA2HDMI },
656 { .dev_id = "tegra-apbdma", .dt_id = TEGRA30_CLK_APBDMA },
657 { .dev_id = "rtc-tegra", .dt_id = TEGRA30_CLK_RTC },
658 { .dev_id = "timer", .dt_id = TEGRA30_CLK_TIMER },
659 { .dev_id = "tegra-kbc", .dt_id = TEGRA30_CLK_KBC },
660 { .dev_id = "fsl-tegra-udc", .dt_id = TEGRA30_CLK_USBD },
661 { .dev_id = "tegra-ehci.1", .dt_id = TEGRA30_CLK_USB2 },
662 { .dev_id = "tegra-ehci.2", .dt_id = TEGRA30_CLK_USB2 },
663 { .dev_id = "kfuse-tegra", .dt_id = TEGRA30_CLK_KFUSE },
664 { .dev_id = "tegra_sata_cold", .dt_id = TEGRA30_CLK_SATA_COLD },
665 { .dev_id = "dtv", .dt_id = TEGRA30_CLK_DTV },
666 { .dev_id = "tegra30-i2s.0", .dt_id = TEGRA30_CLK_I2S0 },
667 { .dev_id = "tegra30-i2s.1", .dt_id = TEGRA30_CLK_I2S1 },
668 { .dev_id = "tegra30-i2s.2", .dt_id = TEGRA30_CLK_I2S2 },
669 { .dev_id = "tegra30-i2s.3", .dt_id = TEGRA30_CLK_I2S3 },
670 { .dev_id = "tegra30-i2s.4", .dt_id = TEGRA30_CLK_I2S4 },
671 { .con_id = "spdif_out", .dev_id = "tegra30-spdif", .dt_id = TEGRA30_CLK_SPDIF_OUT },
672 { .con_id = "spdif_in", .dev_id = "tegra30-spdif", .dt_id = TEGRA30_CLK_SPDIF_IN },
673 { .con_id = "d_audio", .dev_id = "tegra30-ahub", .dt_id = TEGRA30_CLK_D_AUDIO },
674 { .dev_id = "tegra30-dam.0", .dt_id = TEGRA30_CLK_DAM0 },
675 { .dev_id = "tegra30-dam.1", .dt_id = TEGRA30_CLK_DAM1 },
676 { .dev_id = "tegra30-dam.2", .dt_id = TEGRA30_CLK_DAM2 },
677 { .con_id = "hda", .dev_id = "tegra30-hda", .dt_id = TEGRA30_CLK_HDA },
678 { .con_id = "hda2codec", .dev_id = "tegra30-hda", .dt_id = TEGRA30_CLK_HDA2CODEC_2X },
679 { .dev_id = "spi_tegra.0", .dt_id = TEGRA30_CLK_SBC1 },
680 { .dev_id = "spi_tegra.1", .dt_id = TEGRA30_CLK_SBC2 },
681 { .dev_id = "spi_tegra.2", .dt_id = TEGRA30_CLK_SBC3 },
682 { .dev_id = "spi_tegra.3", .dt_id = TEGRA30_CLK_SBC4 },
683 { .dev_id = "spi_tegra.4", .dt_id = TEGRA30_CLK_SBC5 },
684 { .dev_id = "spi_tegra.5", .dt_id = TEGRA30_CLK_SBC6 },
685 { .dev_id = "tegra_sata_oob", .dt_id = TEGRA30_CLK_SATA_OOB },
686 { .dev_id = "tegra_sata", .dt_id = TEGRA30_CLK_SATA },
687 { .dev_id = "tegra_nand", .dt_id = TEGRA30_CLK_NDFLASH },
688 { .dev_id = "tegra_nand_speed", .dt_id = TEGRA30_CLK_NDSPEED },
689 { .dev_id = "vfir", .dt_id = TEGRA30_CLK_VFIR },
690 { .dev_id = "csite", .dt_id = TEGRA30_CLK_CSITE },
691 { .dev_id = "la", .dt_id = TEGRA30_CLK_LA },
692 { .dev_id = "tegra_w1", .dt_id = TEGRA30_CLK_OWR },
693 { .dev_id = "mipi", .dt_id = TEGRA30_CLK_MIPI },
694 { .dev_id = "tegra-tsensor", .dt_id = TEGRA30_CLK_TSENSOR },
695 { .dev_id = "i2cslow", .dt_id = TEGRA30_CLK_I2CSLOW },
696 { .dev_id = "vde", .dt_id = TEGRA30_CLK_VDE },
697 { .con_id = "vi", .dev_id = "tegra_camera", .dt_id = TEGRA30_CLK_VI },
698 { .dev_id = "epp", .dt_id = TEGRA30_CLK_EPP },
699 { .dev_id = "mpe", .dt_id = TEGRA30_CLK_MPE },
700 { .dev_id = "host1x", .dt_id = TEGRA30_CLK_HOST1X },
701 { .dev_id = "3d", .dt_id = TEGRA30_CLK_GR3D },
702 { .dev_id = "3d2", .dt_id = TEGRA30_CLK_GR3D2 },
703 { .dev_id = "2d", .dt_id = TEGRA30_CLK_GR2D },
704 { .dev_id = "se", .dt_id = TEGRA30_CLK_SE },
705 { .dev_id = "mselect", .dt_id = TEGRA30_CLK_MSELECT },
706 { .dev_id = "tegra-nor", .dt_id = TEGRA30_CLK_NOR },
707 { .dev_id = "sdhci-tegra.0", .dt_id = TEGRA30_CLK_SDMMC1 },
708 { .dev_id = "sdhci-tegra.1", .dt_id = TEGRA30_CLK_SDMMC2 },
709 { .dev_id = "sdhci-tegra.2", .dt_id = TEGRA30_CLK_SDMMC3 },
710 { .dev_id = "sdhci-tegra.3", .dt_id = TEGRA30_CLK_SDMMC4 },
711 { .dev_id = "cve", .dt_id = TEGRA30_CLK_CVE },
712 { .dev_id = "tvo", .dt_id = TEGRA30_CLK_TVO },
713 { .dev_id = "tvdac", .dt_id = TEGRA30_CLK_TVDAC },
714 { .dev_id = "actmon", .dt_id = TEGRA30_CLK_ACTMON },
715 { .con_id = "vi_sensor", .dev_id = "tegra_camera", .dt_id = TEGRA30_CLK_VI_SENSOR },
716 { .con_id = "div-clk", .dev_id = "tegra-i2c.0", .dt_id = TEGRA30_CLK_I2C1 },
717 { .con_id = "div-clk", .dev_id = "tegra-i2c.1", .dt_id = TEGRA30_CLK_I2C2 },
718 { .con_id = "div-clk", .dev_id = "tegra-i2c.2", .dt_id = TEGRA30_CLK_I2C3 },
719 { .con_id = "div-clk", .dev_id = "tegra-i2c.3", .dt_id = TEGRA30_CLK_I2C4 },
720 { .con_id = "div-clk", .dev_id = "tegra-i2c.4", .dt_id = TEGRA30_CLK_I2C5 },
721 { .dev_id = "tegra_uart.0", .dt_id = TEGRA30_CLK_UARTA },
722 { .dev_id = "tegra_uart.1", .dt_id = TEGRA30_CLK_UARTB },
723 { .dev_id = "tegra_uart.2", .dt_id = TEGRA30_CLK_UARTC },
724 { .dev_id = "tegra_uart.3", .dt_id = TEGRA30_CLK_UARTD },
725 { .dev_id = "tegra_uart.4", .dt_id = TEGRA30_CLK_UARTE },
726 { .dev_id = "hdmi", .dt_id = TEGRA30_CLK_HDMI },
727 { .dev_id = "extern1", .dt_id = TEGRA30_CLK_EXTERN1 },
728 { .dev_id = "extern2", .dt_id = TEGRA30_CLK_EXTERN2 },
729 { .dev_id = "extern3", .dt_id = TEGRA30_CLK_EXTERN3 },
730 { .dev_id = "pwm", .dt_id = TEGRA30_CLK_PWM },
731 { .dev_id = "tegradc.0", .dt_id = TEGRA30_CLK_DISP1 },
732 { .dev_id = "tegradc.1", .dt_id = TEGRA30_CLK_DISP2 },
733 { .dev_id = "tegradc.1", .dt_id = TEGRA30_CLK_DSIB },
714}; 734};
715 735
716static struct tegra_clk_periph_regs periph_u_regs = { 736static struct tegra_clk tegra30_clks[tegra_clk_max] __initdata = {
717 .enb_reg = CLK_OUT_ENB_U, 737 [tegra_clk_clk_32k] = { .dt_id = TEGRA30_CLK_CLK_32K, .present = true },
718 .enb_set_reg = CLK_OUT_ENB_SET_U, 738 [tegra_clk_clk_m] = { .dt_id = TEGRA30_CLK_CLK_M, .present = true },
719 .enb_clr_reg = CLK_OUT_ENB_CLR_U, 739 [tegra_clk_clk_m_div2] = { .dt_id = TEGRA30_CLK_CLK_M_DIV2, .present = true },
720 .rst_reg = RST_DEVICES_U, 740 [tegra_clk_clk_m_div4] = { .dt_id = TEGRA30_CLK_CLK_M_DIV4, .present = true },
721 .rst_set_reg = RST_DEVICES_SET_U, 741 [tegra_clk_pll_ref] = { .dt_id = TEGRA30_CLK_PLL_REF, .present = true },
722 .rst_clr_reg = RST_DEVICES_CLR_U, 742 [tegra_clk_spdif_in_sync] = { .dt_id = TEGRA30_CLK_SPDIF_IN_SYNC, .present = true },
723}; 743 [tegra_clk_i2s0_sync] = { .dt_id = TEGRA30_CLK_I2S0_SYNC, .present = true },
744 [tegra_clk_i2s1_sync] = { .dt_id = TEGRA30_CLK_I2S1_SYNC, .present = true },
745 [tegra_clk_i2s2_sync] = { .dt_id = TEGRA30_CLK_I2S2_SYNC, .present = true },
746 [tegra_clk_i2s3_sync] = { .dt_id = TEGRA30_CLK_I2S3_SYNC, .present = true },
747 [tegra_clk_i2s4_sync] = { .dt_id = TEGRA30_CLK_I2S4_SYNC, .present = true },
748 [tegra_clk_vimclk_sync] = { .dt_id = TEGRA30_CLK_VIMCLK_SYNC, .present = true },
749 [tegra_clk_audio0] = { .dt_id = TEGRA30_CLK_AUDIO0, .present = true },
750 [tegra_clk_audio1] = { .dt_id = TEGRA30_CLK_AUDIO1, .present = true },
751 [tegra_clk_audio2] = { .dt_id = TEGRA30_CLK_AUDIO2, .present = true },
752 [tegra_clk_audio3] = { .dt_id = TEGRA30_CLK_AUDIO3, .present = true },
753 [tegra_clk_audio4] = { .dt_id = TEGRA30_CLK_AUDIO4, .present = true },
754 [tegra_clk_spdif] = { .dt_id = TEGRA30_CLK_SPDIF, .present = true },
755 [tegra_clk_audio0_mux] = { .dt_id = TEGRA30_CLK_AUDIO0_MUX, .present = true },
756 [tegra_clk_audio1_mux] = { .dt_id = TEGRA30_CLK_AUDIO1_MUX, .present = true },
757 [tegra_clk_audio2_mux] = { .dt_id = TEGRA30_CLK_AUDIO2_MUX, .present = true },
758 [tegra_clk_audio3_mux] = { .dt_id = TEGRA30_CLK_AUDIO3_MUX, .present = true },
759 [tegra_clk_audio4_mux] = { .dt_id = TEGRA30_CLK_AUDIO4_MUX, .present = true },
760 [tegra_clk_spdif_mux] = { .dt_id = TEGRA30_CLK_SPDIF_MUX, .present = true },
761 [tegra_clk_audio0_2x] = { .dt_id = TEGRA30_CLK_AUDIO0_2X, .present = true },
762 [tegra_clk_audio1_2x] = { .dt_id = TEGRA30_CLK_AUDIO1_2X, .present = true },
763 [tegra_clk_audio2_2x] = { .dt_id = TEGRA30_CLK_AUDIO2_2X, .present = true },
764 [tegra_clk_audio3_2x] = { .dt_id = TEGRA30_CLK_AUDIO3_2X, .present = true },
765 [tegra_clk_audio4_2x] = { .dt_id = TEGRA30_CLK_AUDIO4_2X, .present = true },
766 [tegra_clk_spdif_2x] = { .dt_id = TEGRA30_CLK_SPDIF_2X, .present = true },
767 [tegra_clk_clk_out_1] = { .dt_id = TEGRA30_CLK_CLK_OUT_1, .present = true },
768 [tegra_clk_clk_out_2] = { .dt_id = TEGRA30_CLK_CLK_OUT_2, .present = true },
769 [tegra_clk_clk_out_3] = { .dt_id = TEGRA30_CLK_CLK_OUT_3, .present = true },
770 [tegra_clk_blink] = { .dt_id = TEGRA30_CLK_BLINK, .present = true },
771 [tegra_clk_clk_out_1_mux] = { .dt_id = TEGRA30_CLK_CLK_OUT_1_MUX, .present = true },
772 [tegra_clk_clk_out_2_mux] = { .dt_id = TEGRA30_CLK_CLK_OUT_2_MUX, .present = true },
773 [tegra_clk_clk_out_3_mux] = { .dt_id = TEGRA30_CLK_CLK_OUT_3_MUX, .present = true },
774 [tegra_clk_hclk] = { .dt_id = TEGRA30_CLK_HCLK, .present = true },
775 [tegra_clk_pclk] = { .dt_id = TEGRA30_CLK_PCLK, .present = true },
776 [tegra_clk_i2s0] = { .dt_id = TEGRA30_CLK_I2S0, .present = true },
777 [tegra_clk_i2s1] = { .dt_id = TEGRA30_CLK_I2S1, .present = true },
778 [tegra_clk_i2s2] = { .dt_id = TEGRA30_CLK_I2S2, .present = true },
779 [tegra_clk_i2s3] = { .dt_id = TEGRA30_CLK_I2S3, .present = true },
780 [tegra_clk_i2s4] = { .dt_id = TEGRA30_CLK_I2S4, .present = true },
781 [tegra_clk_spdif_in] = { .dt_id = TEGRA30_CLK_SPDIF_IN, .present = true },
782 [tegra_clk_hda] = { .dt_id = TEGRA30_CLK_HDA, .present = true },
783 [tegra_clk_hda2codec_2x] = { .dt_id = TEGRA30_CLK_HDA2CODEC_2X, .present = true },
784 [tegra_clk_sbc1] = { .dt_id = TEGRA30_CLK_SBC1, .present = true },
785 [tegra_clk_sbc2] = { .dt_id = TEGRA30_CLK_SBC2, .present = true },
786 [tegra_clk_sbc3] = { .dt_id = TEGRA30_CLK_SBC3, .present = true },
787 [tegra_clk_sbc4] = { .dt_id = TEGRA30_CLK_SBC4, .present = true },
788 [tegra_clk_sbc5] = { .dt_id = TEGRA30_CLK_SBC5, .present = true },
789 [tegra_clk_sbc6] = { .dt_id = TEGRA30_CLK_SBC6, .present = true },
790 [tegra_clk_ndflash] = { .dt_id = TEGRA30_CLK_NDFLASH, .present = true },
791 [tegra_clk_ndspeed] = { .dt_id = TEGRA30_CLK_NDSPEED, .present = true },
792 [tegra_clk_vfir] = { .dt_id = TEGRA30_CLK_VFIR, .present = true },
793 [tegra_clk_la] = { .dt_id = TEGRA30_CLK_LA, .present = true },
794 [tegra_clk_csite] = { .dt_id = TEGRA30_CLK_CSITE, .present = true },
795 [tegra_clk_owr] = { .dt_id = TEGRA30_CLK_OWR, .present = true },
796 [tegra_clk_mipi] = { .dt_id = TEGRA30_CLK_MIPI, .present = true },
797 [tegra_clk_tsensor] = { .dt_id = TEGRA30_CLK_TSENSOR, .present = true },
798 [tegra_clk_i2cslow] = { .dt_id = TEGRA30_CLK_I2CSLOW, .present = true },
799 [tegra_clk_vde] = { .dt_id = TEGRA30_CLK_VDE, .present = true },
800 [tegra_clk_vi] = { .dt_id = TEGRA30_CLK_VI, .present = true },
801 [tegra_clk_epp] = { .dt_id = TEGRA30_CLK_EPP, .present = true },
802 [tegra_clk_mpe] = { .dt_id = TEGRA30_CLK_MPE, .present = true },
803 [tegra_clk_host1x] = { .dt_id = TEGRA30_CLK_HOST1X, .present = true },
804 [tegra_clk_gr2d] = { .dt_id = TEGRA30_CLK_GR2D, .present = true },
805 [tegra_clk_gr3d] = { .dt_id = TEGRA30_CLK_GR3D, .present = true },
806 [tegra_clk_mselect] = { .dt_id = TEGRA30_CLK_MSELECT, .present = true },
807 [tegra_clk_nor] = { .dt_id = TEGRA30_CLK_NOR, .present = true },
808 [tegra_clk_sdmmc1] = { .dt_id = TEGRA30_CLK_SDMMC1, .present = true },
809 [tegra_clk_sdmmc2] = { .dt_id = TEGRA30_CLK_SDMMC2, .present = true },
810 [tegra_clk_sdmmc3] = { .dt_id = TEGRA30_CLK_SDMMC3, .present = true },
811 [tegra_clk_sdmmc4] = { .dt_id = TEGRA30_CLK_SDMMC4, .present = true },
812 [tegra_clk_cve] = { .dt_id = TEGRA30_CLK_CVE, .present = true },
813 [tegra_clk_tvo] = { .dt_id = TEGRA30_CLK_TVO, .present = true },
814 [tegra_clk_tvdac] = { .dt_id = TEGRA30_CLK_TVDAC, .present = true },
815 [tegra_clk_actmon] = { .dt_id = TEGRA30_CLK_ACTMON, .present = true },
816 [tegra_clk_vi_sensor] = { .dt_id = TEGRA30_CLK_VI_SENSOR, .present = true },
817 [tegra_clk_i2c1] = { .dt_id = TEGRA30_CLK_I2C1, .present = true },
818 [tegra_clk_i2c2] = { .dt_id = TEGRA30_CLK_I2C2, .present = true },
819 [tegra_clk_i2c3] = { .dt_id = TEGRA30_CLK_I2C3, .present = true },
820 [tegra_clk_i2c4] = { .dt_id = TEGRA30_CLK_I2C4, .present = true },
821 [tegra_clk_i2c5] = { .dt_id = TEGRA30_CLK_I2C5, .present = true },
822 [tegra_clk_uarta] = { .dt_id = TEGRA30_CLK_UARTA, .present = true },
823 [tegra_clk_uartb] = { .dt_id = TEGRA30_CLK_UARTB, .present = true },
824 [tegra_clk_uartc] = { .dt_id = TEGRA30_CLK_UARTC, .present = true },
825 [tegra_clk_uartd] = { .dt_id = TEGRA30_CLK_UARTD, .present = true },
826 [tegra_clk_uarte] = { .dt_id = TEGRA30_CLK_UARTE, .present = true },
827 [tegra_clk_extern1] = { .dt_id = TEGRA30_CLK_EXTERN1, .present = true },
828 [tegra_clk_extern2] = { .dt_id = TEGRA30_CLK_EXTERN2, .present = true },
829 [tegra_clk_extern3] = { .dt_id = TEGRA30_CLK_EXTERN3, .present = true },
830 [tegra_clk_disp1] = { .dt_id = TEGRA30_CLK_DISP1, .present = true },
831 [tegra_clk_disp2] = { .dt_id = TEGRA30_CLK_DISP2, .present = true },
832 [tegra_clk_apbdma] = { .dt_id = TEGRA30_CLK_APBDMA, .present = true },
833 [tegra_clk_rtc] = { .dt_id = TEGRA30_CLK_RTC, .present = true },
834 [tegra_clk_timer] = { .dt_id = TEGRA30_CLK_TIMER, .present = true },
835 [tegra_clk_kbc] = { .dt_id = TEGRA30_CLK_KBC, .present = true },
836 [tegra_clk_csus] = { .dt_id = TEGRA30_CLK_CSUS, .present = true },
837 [tegra_clk_vcp] = { .dt_id = TEGRA30_CLK_VCP, .present = true },
838 [tegra_clk_bsea] = { .dt_id = TEGRA30_CLK_BSEA, .present = true },
839 [tegra_clk_bsev] = { .dt_id = TEGRA30_CLK_BSEV, .present = true },
840 [tegra_clk_usbd] = { .dt_id = TEGRA30_CLK_USBD, .present = true },
841 [tegra_clk_usb2] = { .dt_id = TEGRA30_CLK_USB2, .present = true },
842 [tegra_clk_usb3] = { .dt_id = TEGRA30_CLK_USB3, .present = true },
843 [tegra_clk_csi] = { .dt_id = TEGRA30_CLK_CSI, .present = true },
844 [tegra_clk_isp] = { .dt_id = TEGRA30_CLK_ISP, .present = true },
845 [tegra_clk_kfuse] = { .dt_id = TEGRA30_CLK_KFUSE, .present = true },
846 [tegra_clk_fuse] = { .dt_id = TEGRA30_CLK_FUSE, .present = true },
847 [tegra_clk_fuse_burn] = { .dt_id = TEGRA30_CLK_FUSE_BURN, .present = true },
848 [tegra_clk_apbif] = { .dt_id = TEGRA30_CLK_APBIF, .present = true },
849 [tegra_clk_hda2hdmi] = { .dt_id = TEGRA30_CLK_HDA2HDMI, .present = true },
850 [tegra_clk_sata_cold] = { .dt_id = TEGRA30_CLK_SATA_COLD, .present = true },
851 [tegra_clk_sata_oob] = { .dt_id = TEGRA30_CLK_SATA_OOB, .present = true },
852 [tegra_clk_sata] = { .dt_id = TEGRA30_CLK_SATA, .present = true },
853 [tegra_clk_dtv] = { .dt_id = TEGRA30_CLK_DTV, .present = true },
854 [tegra_clk_pll_p] = { .dt_id = TEGRA30_CLK_PLL_P, .present = true },
855 [tegra_clk_pll_p_out1] = { .dt_id = TEGRA30_CLK_PLL_P_OUT1, .present = true },
856 [tegra_clk_pll_p_out2] = { .dt_id = TEGRA30_CLK_PLL_P_OUT2, .present = true },
857 [tegra_clk_pll_p_out3] = { .dt_id = TEGRA30_CLK_PLL_P_OUT3, .present = true },
858 [tegra_clk_pll_p_out4] = { .dt_id = TEGRA30_CLK_PLL_P_OUT4, .present = true },
859 [tegra_clk_pll_a] = { .dt_id = TEGRA30_CLK_PLL_A, .present = true },
860 [tegra_clk_pll_a_out0] = { .dt_id = TEGRA30_CLK_PLL_A_OUT0, .present = true },
724 861
725static struct tegra_clk_periph_regs periph_v_regs = {
726 .enb_reg = CLK_OUT_ENB_V,
727 .enb_set_reg = CLK_OUT_ENB_SET_V,
728 .enb_clr_reg = CLK_OUT_ENB_CLR_V,
729 .rst_reg = RST_DEVICES_V,
730 .rst_set_reg = RST_DEVICES_SET_V,
731 .rst_clr_reg = RST_DEVICES_CLR_V,
732}; 862};
733 863
734static struct tegra_clk_periph_regs periph_w_regs = {
735 .enb_reg = CLK_OUT_ENB_W,
736 .enb_set_reg = CLK_OUT_ENB_SET_W,
737 .enb_clr_reg = CLK_OUT_ENB_CLR_W,
738 .rst_reg = RST_DEVICES_W,
739 .rst_set_reg = RST_DEVICES_SET_W,
740 .rst_clr_reg = RST_DEVICES_CLR_W,
741};
742
743static void tegra30_clk_measure_input_freq(void)
744{
745 u32 osc_ctrl = readl_relaxed(clk_base + OSC_CTRL);
746 u32 auto_clk_control = osc_ctrl & OSC_CTRL_OSC_FREQ_MASK;
747 u32 pll_ref_div = osc_ctrl & OSC_CTRL_PLL_REF_DIV_MASK;
748
749 switch (auto_clk_control) {
750 case OSC_CTRL_OSC_FREQ_12MHZ:
751 BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_1);
752 input_freq = 12000000;
753 break;
754 case OSC_CTRL_OSC_FREQ_13MHZ:
755 BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_1);
756 input_freq = 13000000;
757 break;
758 case OSC_CTRL_OSC_FREQ_19_2MHZ:
759 BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_1);
760 input_freq = 19200000;
761 break;
762 case OSC_CTRL_OSC_FREQ_26MHZ:
763 BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_1);
764 input_freq = 26000000;
765 break;
766 case OSC_CTRL_OSC_FREQ_16_8MHZ:
767 BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_1);
768 input_freq = 16800000;
769 break;
770 case OSC_CTRL_OSC_FREQ_38_4MHZ:
771 BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_2);
772 input_freq = 38400000;
773 break;
774 case OSC_CTRL_OSC_FREQ_48MHZ:
775 BUG_ON(pll_ref_div != OSC_CTRL_PLL_REF_DIV_4);
776 input_freq = 48000000;
777 break;
778 default:
779 pr_err("Unexpected auto clock control value %d",
780 auto_clk_control);
781 BUG();
782 return;
783 }
784}
785
786static unsigned int tegra30_get_pll_ref_div(void)
787{
788 u32 pll_ref_div = readl_relaxed(clk_base + OSC_CTRL) &
789 OSC_CTRL_PLL_REF_DIV_MASK;
790
791 switch (pll_ref_div) {
792 case OSC_CTRL_PLL_REF_DIV_1:
793 return 1;
794 case OSC_CTRL_PLL_REF_DIV_2:
795 return 2;
796 case OSC_CTRL_PLL_REF_DIV_4:
797 return 4;
798 default:
799 pr_err("Invalid pll ref divider %d", pll_ref_div);
800 BUG();
801 }
802 return 0;
803}
804
805static void tegra30_utmi_param_configure(void) 864static void tegra30_utmi_param_configure(void)
806{ 865{
807 u32 reg; 866 u32 reg;
@@ -863,11 +922,8 @@ static void __init tegra30_pll_init(void)
863 922
864 /* PLLC */ 923 /* PLLC */
865 clk = tegra_clk_register_pll("pll_c", "pll_ref", clk_base, pmc_base, 0, 924 clk = tegra_clk_register_pll("pll_c", "pll_ref", clk_base, pmc_base, 0,
866 0, &pll_c_params, 925 &pll_c_params, NULL);
867 TEGRA_PLL_HAS_CPCON | TEGRA_PLL_USE_LOCK, 926 clks[TEGRA30_CLK_PLL_C] = clk;
868 pll_c_freq_table, NULL);
869 clk_register_clkdev(clk, "pll_c", NULL);
870 clks[pll_c] = clk;
871 927
872 /* PLLC_OUT1 */ 928 /* PLLC_OUT1 */
873 clk = tegra_clk_register_divider("pll_c_out1_div", "pll_c", 929 clk = tegra_clk_register_divider("pll_c_out1_div", "pll_c",
@@ -876,73 +932,13 @@ static void __init tegra30_pll_init(void)
876 clk = tegra_clk_register_pll_out("pll_c_out1", "pll_c_out1_div", 932 clk = tegra_clk_register_pll_out("pll_c_out1", "pll_c_out1_div",
877 clk_base + PLLC_OUT, 1, 0, CLK_SET_RATE_PARENT, 933 clk_base + PLLC_OUT, 1, 0, CLK_SET_RATE_PARENT,
878 0, NULL); 934 0, NULL);
879 clk_register_clkdev(clk, "pll_c_out1", NULL); 935 clks[TEGRA30_CLK_PLL_C_OUT1] = clk;
880 clks[pll_c_out1] = clk;
881
882 /* PLLP */
883 clk = tegra_clk_register_pll("pll_p", "pll_ref", clk_base, pmc_base, 0,
884 408000000, &pll_p_params,
885 TEGRA_PLL_FIXED | TEGRA_PLL_HAS_CPCON |
886 TEGRA_PLL_USE_LOCK, pll_p_freq_table, NULL);
887 clk_register_clkdev(clk, "pll_p", NULL);
888 clks[pll_p] = clk;
889
890 /* PLLP_OUT1 */
891 clk = tegra_clk_register_divider("pll_p_out1_div", "pll_p",
892 clk_base + PLLP_OUTA, 0, TEGRA_DIVIDER_FIXED |
893 TEGRA_DIVIDER_ROUND_UP, 8, 8, 1,
894 &pll_div_lock);
895 clk = tegra_clk_register_pll_out("pll_p_out1", "pll_p_out1_div",
896 clk_base + PLLP_OUTA, 1, 0,
897 CLK_IGNORE_UNUSED | CLK_SET_RATE_PARENT, 0,
898 &pll_div_lock);
899 clk_register_clkdev(clk, "pll_p_out1", NULL);
900 clks[pll_p_out1] = clk;
901
902 /* PLLP_OUT2 */
903 clk = tegra_clk_register_divider("pll_p_out2_div", "pll_p",
904 clk_base + PLLP_OUTA, 0, TEGRA_DIVIDER_FIXED |
905 TEGRA_DIVIDER_ROUND_UP, 24, 8, 1,
906 &pll_div_lock);
907 clk = tegra_clk_register_pll_out("pll_p_out2", "pll_p_out2_div",
908 clk_base + PLLP_OUTA, 17, 16,
909 CLK_IGNORE_UNUSED | CLK_SET_RATE_PARENT, 0,
910 &pll_div_lock);
911 clk_register_clkdev(clk, "pll_p_out2", NULL);
912 clks[pll_p_out2] = clk;
913
914 /* PLLP_OUT3 */
915 clk = tegra_clk_register_divider("pll_p_out3_div", "pll_p",
916 clk_base + PLLP_OUTB, 0, TEGRA_DIVIDER_FIXED |
917 TEGRA_DIVIDER_ROUND_UP, 8, 8, 1,
918 &pll_div_lock);
919 clk = tegra_clk_register_pll_out("pll_p_out3", "pll_p_out3_div",
920 clk_base + PLLP_OUTB, 1, 0,
921 CLK_IGNORE_UNUSED | CLK_SET_RATE_PARENT, 0,
922 &pll_div_lock);
923 clk_register_clkdev(clk, "pll_p_out3", NULL);
924 clks[pll_p_out3] = clk;
925
926 /* PLLP_OUT4 */
927 clk = tegra_clk_register_divider("pll_p_out4_div", "pll_p",
928 clk_base + PLLP_OUTB, 0, TEGRA_DIVIDER_FIXED |
929 TEGRA_DIVIDER_ROUND_UP, 24, 8, 1,
930 &pll_div_lock);
931 clk = tegra_clk_register_pll_out("pll_p_out4", "pll_p_out4_div",
932 clk_base + PLLP_OUTB, 17, 16,
933 CLK_IGNORE_UNUSED | CLK_SET_RATE_PARENT, 0,
934 &pll_div_lock);
935 clk_register_clkdev(clk, "pll_p_out4", NULL);
936 clks[pll_p_out4] = clk;
937 936
938 /* PLLM */ 937 /* PLLM */
939 clk = tegra_clk_register_pll("pll_m", "pll_ref", clk_base, pmc_base, 938 clk = tegra_clk_register_pll("pll_m", "pll_ref", clk_base, pmc_base,
940 CLK_IGNORE_UNUSED | CLK_SET_RATE_GATE, 0, 939 CLK_IGNORE_UNUSED | CLK_SET_RATE_GATE,
941 &pll_m_params, TEGRA_PLLM | TEGRA_PLL_HAS_CPCON | 940 &pll_m_params, NULL);
942 TEGRA_PLL_SET_DCCON | TEGRA_PLL_USE_LOCK, 941 clks[TEGRA30_CLK_PLL_M] = clk;
943 pll_m_freq_table, NULL);
944 clk_register_clkdev(clk, "pll_m", NULL);
945 clks[pll_m] = clk;
946 942
947 /* PLLM_OUT1 */ 943 /* PLLM_OUT1 */
948 clk = tegra_clk_register_divider("pll_m_out1_div", "pll_m", 944 clk = tegra_clk_register_divider("pll_m_out1_div", "pll_m",
@@ -951,78 +947,44 @@ static void __init tegra30_pll_init(void)
951 clk = tegra_clk_register_pll_out("pll_m_out1", "pll_m_out1_div", 947 clk = tegra_clk_register_pll_out("pll_m_out1", "pll_m_out1_div",
952 clk_base + PLLM_OUT, 1, 0, CLK_IGNORE_UNUSED | 948 clk_base + PLLM_OUT, 1, 0, CLK_IGNORE_UNUSED |
953 CLK_SET_RATE_PARENT, 0, NULL); 949 CLK_SET_RATE_PARENT, 0, NULL);
954 clk_register_clkdev(clk, "pll_m_out1", NULL); 950 clks[TEGRA30_CLK_PLL_M_OUT1] = clk;
955 clks[pll_m_out1] = clk;
956 951
957 /* PLLX */ 952 /* PLLX */
958 clk = tegra_clk_register_pll("pll_x", "pll_ref", clk_base, pmc_base, 0, 953 clk = tegra_clk_register_pll("pll_x", "pll_ref", clk_base, pmc_base, 0,
959 0, &pll_x_params, TEGRA_PLL_HAS_CPCON | 954 &pll_x_params, NULL);
960 TEGRA_PLL_SET_DCCON | TEGRA_PLL_USE_LOCK, 955 clks[TEGRA30_CLK_PLL_X] = clk;
961 pll_x_freq_table, NULL);
962 clk_register_clkdev(clk, "pll_x", NULL);
963 clks[pll_x] = clk;
964 956
965 /* PLLX_OUT0 */ 957 /* PLLX_OUT0 */
966 clk = clk_register_fixed_factor(NULL, "pll_x_out0", "pll_x", 958 clk = clk_register_fixed_factor(NULL, "pll_x_out0", "pll_x",
967 CLK_SET_RATE_PARENT, 1, 2); 959 CLK_SET_RATE_PARENT, 1, 2);
968 clk_register_clkdev(clk, "pll_x_out0", NULL); 960 clks[TEGRA30_CLK_PLL_X_OUT0] = clk;
969 clks[pll_x_out0] = clk;
970 961
971 /* PLLU */ 962 /* PLLU */
972 clk = tegra_clk_register_pll("pll_u", "pll_ref", clk_base, pmc_base, 0, 963 clk = tegra_clk_register_pll("pll_u", "pll_ref", clk_base, pmc_base, 0,
973 0, &pll_u_params, TEGRA_PLLU | TEGRA_PLL_HAS_CPCON | 964 &pll_u_params, NULL);
974 TEGRA_PLL_SET_LFCON, 965 clks[TEGRA30_CLK_PLL_U] = clk;
975 pll_u_freq_table,
976 NULL);
977 clk_register_clkdev(clk, "pll_u", NULL);
978 clks[pll_u] = clk;
979 966
980 tegra30_utmi_param_configure(); 967 tegra30_utmi_param_configure();
981 968
982 /* PLLD */ 969 /* PLLD */
983 clk = tegra_clk_register_pll("pll_d", "pll_ref", clk_base, pmc_base, 0, 970 clk = tegra_clk_register_pll("pll_d", "pll_ref", clk_base, pmc_base, 0,
984 0, &pll_d_params, TEGRA_PLL_HAS_CPCON | 971 &pll_d_params, &pll_d_lock);
985 TEGRA_PLL_SET_LFCON | TEGRA_PLL_USE_LOCK, 972 clks[TEGRA30_CLK_PLL_D] = clk;
986 pll_d_freq_table, &pll_d_lock);
987 clk_register_clkdev(clk, "pll_d", NULL);
988 clks[pll_d] = clk;
989 973
990 /* PLLD_OUT0 */ 974 /* PLLD_OUT0 */
991 clk = clk_register_fixed_factor(NULL, "pll_d_out0", "pll_d", 975 clk = clk_register_fixed_factor(NULL, "pll_d_out0", "pll_d",
992 CLK_SET_RATE_PARENT, 1, 2); 976 CLK_SET_RATE_PARENT, 1, 2);
993 clk_register_clkdev(clk, "pll_d_out0", NULL); 977 clks[TEGRA30_CLK_PLL_D_OUT0] = clk;
994 clks[pll_d_out0] = clk;
995 978
996 /* PLLD2 */ 979 /* PLLD2 */
997 clk = tegra_clk_register_pll("pll_d2", "pll_ref", clk_base, pmc_base, 0, 980 clk = tegra_clk_register_pll("pll_d2", "pll_ref", clk_base, pmc_base, 0,
998 0, &pll_d2_params, TEGRA_PLL_HAS_CPCON | 981 &pll_d2_params, NULL);
999 TEGRA_PLL_SET_LFCON | TEGRA_PLL_USE_LOCK, 982 clks[TEGRA30_CLK_PLL_D2] = clk;
1000 pll_d_freq_table, NULL);
1001 clk_register_clkdev(clk, "pll_d2", NULL);
1002 clks[pll_d2] = clk;
1003 983
1004 /* PLLD2_OUT0 */ 984 /* PLLD2_OUT0 */
1005 clk = clk_register_fixed_factor(NULL, "pll_d2_out0", "pll_d2", 985 clk = clk_register_fixed_factor(NULL, "pll_d2_out0", "pll_d2",
1006 CLK_SET_RATE_PARENT, 1, 2); 986 CLK_SET_RATE_PARENT, 1, 2);
1007 clk_register_clkdev(clk, "pll_d2_out0", NULL); 987 clks[TEGRA30_CLK_PLL_D2_OUT0] = clk;
1008 clks[pll_d2_out0] = clk;
1009
1010 /* PLLA */
1011 clk = tegra_clk_register_pll("pll_a", "pll_p_out1", clk_base, pmc_base,
1012 0, 0, &pll_a_params, TEGRA_PLL_HAS_CPCON |
1013 TEGRA_PLL_USE_LOCK, pll_a_freq_table, NULL);
1014 clk_register_clkdev(clk, "pll_a", NULL);
1015 clks[pll_a] = clk;
1016
1017 /* PLLA_OUT0 */
1018 clk = tegra_clk_register_divider("pll_a_out0_div", "pll_a",
1019 clk_base + PLLA_OUT, 0, TEGRA_DIVIDER_ROUND_UP,
1020 8, 8, 1, NULL);
1021 clk = tegra_clk_register_pll_out("pll_a_out0", "pll_a_out0_div",
1022 clk_base + PLLA_OUT, 1, 0, CLK_IGNORE_UNUSED |
1023 CLK_SET_RATE_PARENT, 0, NULL);
1024 clk_register_clkdev(clk, "pll_a_out0", NULL);
1025 clks[pll_a_out0] = clk;
1026 988
1027 /* PLLE */ 989 /* PLLE */
1028 clk = clk_register_mux(NULL, "pll_e_mux", pll_e_parents, 990 clk = clk_register_mux(NULL, "pll_e_mux", pll_e_parents,
@@ -1030,258 +992,8 @@ static void __init tegra30_pll_init(void)
1030 CLK_SET_RATE_NO_REPARENT, 992 CLK_SET_RATE_NO_REPARENT,
1031 clk_base + PLLE_AUX, 2, 1, 0, NULL); 993 clk_base + PLLE_AUX, 2, 1, 0, NULL);
1032 clk = tegra_clk_register_plle("pll_e", "pll_e_mux", clk_base, pmc_base, 994 clk = tegra_clk_register_plle("pll_e", "pll_e_mux", clk_base, pmc_base,
1033 CLK_GET_RATE_NOCACHE, 100000000, &pll_e_params, 995 CLK_GET_RATE_NOCACHE, &pll_e_params, NULL);
1034 TEGRA_PLLE_CONFIGURE, pll_e_freq_table, NULL); 996 clks[TEGRA30_CLK_PLL_E] = clk;
1035 clk_register_clkdev(clk, "pll_e", NULL);
1036 clks[pll_e] = clk;
1037}
1038
1039static const char *mux_audio_sync_clk[] = { "spdif_in_sync", "i2s0_sync",
1040 "i2s1_sync", "i2s2_sync", "i2s3_sync", "i2s4_sync", "vimclk_sync",};
1041static const char *clk_out1_parents[] = { "clk_m", "clk_m_div2",
1042 "clk_m_div4", "extern1", };
1043static const char *clk_out2_parents[] = { "clk_m", "clk_m_div2",
1044 "clk_m_div4", "extern2", };
1045static const char *clk_out3_parents[] = { "clk_m", "clk_m_div2",
1046 "clk_m_div4", "extern3", };
1047
1048static void __init tegra30_audio_clk_init(void)
1049{
1050 struct clk *clk;
1051
1052 /* spdif_in_sync */
1053 clk = tegra_clk_register_sync_source("spdif_in_sync", 24000000,
1054 24000000);
1055 clk_register_clkdev(clk, "spdif_in_sync", NULL);
1056 clks[spdif_in_sync] = clk;
1057
1058 /* i2s0_sync */
1059 clk = tegra_clk_register_sync_source("i2s0_sync", 24000000, 24000000);
1060 clk_register_clkdev(clk, "i2s0_sync", NULL);
1061 clks[i2s0_sync] = clk;
1062
1063 /* i2s1_sync */
1064 clk = tegra_clk_register_sync_source("i2s1_sync", 24000000, 24000000);
1065 clk_register_clkdev(clk, "i2s1_sync", NULL);
1066 clks[i2s1_sync] = clk;
1067
1068 /* i2s2_sync */
1069 clk = tegra_clk_register_sync_source("i2s2_sync", 24000000, 24000000);
1070 clk_register_clkdev(clk, "i2s2_sync", NULL);
1071 clks[i2s2_sync] = clk;
1072
1073 /* i2s3_sync */
1074 clk = tegra_clk_register_sync_source("i2s3_sync", 24000000, 24000000);
1075 clk_register_clkdev(clk, "i2s3_sync", NULL);
1076 clks[i2s3_sync] = clk;
1077
1078 /* i2s4_sync */
1079 clk = tegra_clk_register_sync_source("i2s4_sync", 24000000, 24000000);
1080 clk_register_clkdev(clk, "i2s4_sync", NULL);
1081 clks[i2s4_sync] = clk;
1082
1083 /* vimclk_sync */
1084 clk = tegra_clk_register_sync_source("vimclk_sync", 24000000, 24000000);
1085 clk_register_clkdev(clk, "vimclk_sync", NULL);
1086 clks[vimclk_sync] = clk;
1087
1088 /* audio0 */
1089 clk = clk_register_mux(NULL, "audio0_mux", mux_audio_sync_clk,
1090 ARRAY_SIZE(mux_audio_sync_clk),
1091 CLK_SET_RATE_NO_REPARENT,
1092 clk_base + AUDIO_SYNC_CLK_I2S0, 0, 3, 0, NULL);
1093 clk = clk_register_gate(NULL, "audio0", "audio0_mux", 0,
1094 clk_base + AUDIO_SYNC_CLK_I2S0, 4,
1095 CLK_GATE_SET_TO_DISABLE, NULL);
1096 clk_register_clkdev(clk, "audio0", NULL);
1097 clks[audio0] = clk;
1098
1099 /* audio1 */
1100 clk = clk_register_mux(NULL, "audio1_mux", mux_audio_sync_clk,
1101 ARRAY_SIZE(mux_audio_sync_clk),
1102 CLK_SET_RATE_NO_REPARENT,
1103 clk_base + AUDIO_SYNC_CLK_I2S1, 0, 3, 0, NULL);
1104 clk = clk_register_gate(NULL, "audio1", "audio1_mux", 0,
1105 clk_base + AUDIO_SYNC_CLK_I2S1, 4,
1106 CLK_GATE_SET_TO_DISABLE, NULL);
1107 clk_register_clkdev(clk, "audio1", NULL);
1108 clks[audio1] = clk;
1109
1110 /* audio2 */
1111 clk = clk_register_mux(NULL, "audio2_mux", mux_audio_sync_clk,
1112 ARRAY_SIZE(mux_audio_sync_clk),
1113 CLK_SET_RATE_NO_REPARENT,
1114 clk_base + AUDIO_SYNC_CLK_I2S2, 0, 3, 0, NULL);
1115 clk = clk_register_gate(NULL, "audio2", "audio2_mux", 0,
1116 clk_base + AUDIO_SYNC_CLK_I2S2, 4,
1117 CLK_GATE_SET_TO_DISABLE, NULL);
1118 clk_register_clkdev(clk, "audio2", NULL);
1119 clks[audio2] = clk;
1120
1121 /* audio3 */
1122 clk = clk_register_mux(NULL, "audio3_mux", mux_audio_sync_clk,
1123 ARRAY_SIZE(mux_audio_sync_clk),
1124 CLK_SET_RATE_NO_REPARENT,
1125 clk_base + AUDIO_SYNC_CLK_I2S3, 0, 3, 0, NULL);
1126 clk = clk_register_gate(NULL, "audio3", "audio3_mux", 0,
1127 clk_base + AUDIO_SYNC_CLK_I2S3, 4,
1128 CLK_GATE_SET_TO_DISABLE, NULL);
1129 clk_register_clkdev(clk, "audio3", NULL);
1130 clks[audio3] = clk;
1131
1132 /* audio4 */
1133 clk = clk_register_mux(NULL, "audio4_mux", mux_audio_sync_clk,
1134 ARRAY_SIZE(mux_audio_sync_clk),
1135 CLK_SET_RATE_NO_REPARENT,
1136 clk_base + AUDIO_SYNC_CLK_I2S4, 0, 3, 0, NULL);
1137 clk = clk_register_gate(NULL, "audio4", "audio4_mux", 0,
1138 clk_base + AUDIO_SYNC_CLK_I2S4, 4,
1139 CLK_GATE_SET_TO_DISABLE, NULL);
1140 clk_register_clkdev(clk, "audio4", NULL);
1141 clks[audio4] = clk;
1142
1143 /* spdif */
1144 clk = clk_register_mux(NULL, "spdif_mux", mux_audio_sync_clk,
1145 ARRAY_SIZE(mux_audio_sync_clk),
1146 CLK_SET_RATE_NO_REPARENT,
1147 clk_base + AUDIO_SYNC_CLK_SPDIF, 0, 3, 0, NULL);
1148 clk = clk_register_gate(NULL, "spdif", "spdif_mux", 0,
1149 clk_base + AUDIO_SYNC_CLK_SPDIF, 4,
1150 CLK_GATE_SET_TO_DISABLE, NULL);
1151 clk_register_clkdev(clk, "spdif", NULL);
1152 clks[spdif] = clk;
1153
1154 /* audio0_2x */
1155 clk = clk_register_fixed_factor(NULL, "audio0_doubler", "audio0",
1156 CLK_SET_RATE_PARENT, 2, 1);
1157 clk = tegra_clk_register_divider("audio0_div", "audio0_doubler",
1158 clk_base + AUDIO_SYNC_DOUBLER, 0, 0, 24, 1, 0,
1159 &clk_doubler_lock);
1160 clk = tegra_clk_register_periph_gate("audio0_2x", "audio0_div",
1161 TEGRA_PERIPH_NO_RESET, clk_base,
1162 CLK_SET_RATE_PARENT, 113, &periph_v_regs,
1163 periph_clk_enb_refcnt);
1164 clk_register_clkdev(clk, "audio0_2x", NULL);
1165 clks[audio0_2x] = clk;
1166
1167 /* audio1_2x */
1168 clk = clk_register_fixed_factor(NULL, "audio1_doubler", "audio1",
1169 CLK_SET_RATE_PARENT, 2, 1);
1170 clk = tegra_clk_register_divider("audio1_div", "audio1_doubler",
1171 clk_base + AUDIO_SYNC_DOUBLER, 0, 0, 25, 1, 0,
1172 &clk_doubler_lock);
1173 clk = tegra_clk_register_periph_gate("audio1_2x", "audio1_div",
1174 TEGRA_PERIPH_NO_RESET, clk_base,
1175 CLK_SET_RATE_PARENT, 114, &periph_v_regs,
1176 periph_clk_enb_refcnt);
1177 clk_register_clkdev(clk, "audio1_2x", NULL);
1178 clks[audio1_2x] = clk;
1179
1180 /* audio2_2x */
1181 clk = clk_register_fixed_factor(NULL, "audio2_doubler", "audio2",
1182 CLK_SET_RATE_PARENT, 2, 1);
1183 clk = tegra_clk_register_divider("audio2_div", "audio2_doubler",
1184 clk_base + AUDIO_SYNC_DOUBLER, 0, 0, 26, 1, 0,
1185 &clk_doubler_lock);
1186 clk = tegra_clk_register_periph_gate("audio2_2x", "audio2_div",
1187 TEGRA_PERIPH_NO_RESET, clk_base,
1188 CLK_SET_RATE_PARENT, 115, &periph_v_regs,
1189 periph_clk_enb_refcnt);
1190 clk_register_clkdev(clk, "audio2_2x", NULL);
1191 clks[audio2_2x] = clk;
1192
1193 /* audio3_2x */
1194 clk = clk_register_fixed_factor(NULL, "audio3_doubler", "audio3",
1195 CLK_SET_RATE_PARENT, 2, 1);
1196 clk = tegra_clk_register_divider("audio3_div", "audio3_doubler",
1197 clk_base + AUDIO_SYNC_DOUBLER, 0, 0, 27, 1, 0,
1198 &clk_doubler_lock);
1199 clk = tegra_clk_register_periph_gate("audio3_2x", "audio3_div",
1200 TEGRA_PERIPH_NO_RESET, clk_base,
1201 CLK_SET_RATE_PARENT, 116, &periph_v_regs,
1202 periph_clk_enb_refcnt);
1203 clk_register_clkdev(clk, "audio3_2x", NULL);
1204 clks[audio3_2x] = clk;
1205
1206 /* audio4_2x */
1207 clk = clk_register_fixed_factor(NULL, "audio4_doubler", "audio4",
1208 CLK_SET_RATE_PARENT, 2, 1);
1209 clk = tegra_clk_register_divider("audio4_div", "audio4_doubler",
1210 clk_base + AUDIO_SYNC_DOUBLER, 0, 0, 28, 1, 0,
1211 &clk_doubler_lock);
1212 clk = tegra_clk_register_periph_gate("audio4_2x", "audio4_div",
1213 TEGRA_PERIPH_NO_RESET, clk_base,
1214 CLK_SET_RATE_PARENT, 117, &periph_v_regs,
1215 periph_clk_enb_refcnt);
1216 clk_register_clkdev(clk, "audio4_2x", NULL);
1217 clks[audio4_2x] = clk;
1218
1219 /* spdif_2x */
1220 clk = clk_register_fixed_factor(NULL, "spdif_doubler", "spdif",
1221 CLK_SET_RATE_PARENT, 2, 1);
1222 clk = tegra_clk_register_divider("spdif_div", "spdif_doubler",
1223 clk_base + AUDIO_SYNC_DOUBLER, 0, 0, 29, 1, 0,
1224 &clk_doubler_lock);
1225 clk = tegra_clk_register_periph_gate("spdif_2x", "spdif_div",
1226 TEGRA_PERIPH_NO_RESET, clk_base,
1227 CLK_SET_RATE_PARENT, 118, &periph_v_regs,
1228 periph_clk_enb_refcnt);
1229 clk_register_clkdev(clk, "spdif_2x", NULL);
1230 clks[spdif_2x] = clk;
1231}
1232
1233static void __init tegra30_pmc_clk_init(void)
1234{
1235 struct clk *clk;
1236
1237 /* clk_out_1 */
1238 clk = clk_register_mux(NULL, "clk_out_1_mux", clk_out1_parents,
1239 ARRAY_SIZE(clk_out1_parents),
1240 CLK_SET_RATE_NO_REPARENT,
1241 pmc_base + PMC_CLK_OUT_CNTRL, 6, 3, 0,
1242 &clk_out_lock);
1243 clks[clk_out_1_mux] = clk;
1244 clk = clk_register_gate(NULL, "clk_out_1", "clk_out_1_mux", 0,
1245 pmc_base + PMC_CLK_OUT_CNTRL, 2, 0,
1246 &clk_out_lock);
1247 clk_register_clkdev(clk, "extern1", "clk_out_1");
1248 clks[clk_out_1] = clk;
1249
1250 /* clk_out_2 */
1251 clk = clk_register_mux(NULL, "clk_out_2_mux", clk_out2_parents,
1252 ARRAY_SIZE(clk_out2_parents),
1253 CLK_SET_RATE_NO_REPARENT,
1254 pmc_base + PMC_CLK_OUT_CNTRL, 14, 3, 0,
1255 &clk_out_lock);
1256 clk = clk_register_gate(NULL, "clk_out_2", "clk_out_2_mux", 0,
1257 pmc_base + PMC_CLK_OUT_CNTRL, 10, 0,
1258 &clk_out_lock);
1259 clk_register_clkdev(clk, "extern2", "clk_out_2");
1260 clks[clk_out_2] = clk;
1261
1262 /* clk_out_3 */
1263 clk = clk_register_mux(NULL, "clk_out_3_mux", clk_out3_parents,
1264 ARRAY_SIZE(clk_out3_parents),
1265 CLK_SET_RATE_NO_REPARENT,
1266 pmc_base + PMC_CLK_OUT_CNTRL, 22, 3, 0,
1267 &clk_out_lock);
1268 clk = clk_register_gate(NULL, "clk_out_3", "clk_out_3_mux", 0,
1269 pmc_base + PMC_CLK_OUT_CNTRL, 18, 0,
1270 &clk_out_lock);
1271 clk_register_clkdev(clk, "extern3", "clk_out_3");
1272 clks[clk_out_3] = clk;
1273
1274 /* blink */
1275 writel_relaxed(0, pmc_base + PMC_BLINK_TIMER);
1276 clk = clk_register_gate(NULL, "blink_override", "clk_32k", 0,
1277 pmc_base + PMC_DPD_PADS_ORIDE,
1278 PMC_DPD_PADS_ORIDE_BLINK_ENB, 0, NULL);
1279 clk = clk_register_gate(NULL, "blink", "blink_override", 0,
1280 pmc_base + PMC_CTRL,
1281 PMC_CTRL_BLINK_ENB, 0, NULL);
1282 clk_register_clkdev(clk, "blink", NULL);
1283 clks[blink] = clk;
1284
1285} 997}
1286 998
1287static const char *cclk_g_parents[] = { "clk_m", "pll_c", "clk_32k", "pll_m", 999static const char *cclk_g_parents[] = { "clk_m", "pll_c", "clk_32k", "pll_m",
@@ -1332,8 +1044,7 @@ static void __init tegra30_super_clk_init(void)
1332 CLK_SET_RATE_PARENT, 1044 CLK_SET_RATE_PARENT,
1333 clk_base + CCLKG_BURST_POLICY, 1045 clk_base + CCLKG_BURST_POLICY,
1334 0, 4, 0, 0, NULL); 1046 0, 4, 0, 0, NULL);
1335 clk_register_clkdev(clk, "cclk_g", NULL); 1047 clks[TEGRA30_CLK_CCLK_G] = clk;
1336 clks[cclk_g] = clk;
1337 1048
1338 /* 1049 /*
1339 * Clock input to cclk_lp divided from pll_p using 1050 * Clock input to cclk_lp divided from pll_p using
@@ -1369,8 +1080,7 @@ static void __init tegra30_super_clk_init(void)
1369 clk_base + CCLKLP_BURST_POLICY, 1080 clk_base + CCLKLP_BURST_POLICY,
1370 TEGRA_DIVIDER_2, 4, 8, 9, 1081 TEGRA_DIVIDER_2, 4, 8, 9,
1371 NULL); 1082 NULL);
1372 clk_register_clkdev(clk, "cclk_lp", NULL); 1083 clks[TEGRA30_CLK_CCLK_LP] = clk;
1373 clks[cclk_lp] = clk;
1374 1084
1375 /* SCLK */ 1085 /* SCLK */
1376 clk = tegra_clk_register_super_mux("sclk", sclk_parents, 1086 clk = tegra_clk_register_super_mux("sclk", sclk_parents,
@@ -1378,142 +1088,44 @@ static void __init tegra30_super_clk_init(void)
1378 CLK_SET_RATE_PARENT, 1088 CLK_SET_RATE_PARENT,
1379 clk_base + SCLK_BURST_POLICY, 1089 clk_base + SCLK_BURST_POLICY,
1380 0, 4, 0, 0, NULL); 1090 0, 4, 0, 0, NULL);
1381 clk_register_clkdev(clk, "sclk", NULL); 1091 clks[TEGRA30_CLK_SCLK] = clk;
1382 clks[sclk] = clk;
1383
1384 /* HCLK */
1385 clk = clk_register_divider(NULL, "hclk_div", "sclk", 0,
1386 clk_base + SYSTEM_CLK_RATE, 4, 2, 0,
1387 &sysrate_lock);
1388 clk = clk_register_gate(NULL, "hclk", "hclk_div", CLK_SET_RATE_PARENT,
1389 clk_base + SYSTEM_CLK_RATE, 7,
1390 CLK_GATE_SET_TO_DISABLE, &sysrate_lock);
1391 clk_register_clkdev(clk, "hclk", NULL);
1392 clks[hclk] = clk;
1393
1394 /* PCLK */
1395 clk = clk_register_divider(NULL, "pclk_div", "hclk", 0,
1396 clk_base + SYSTEM_CLK_RATE, 0, 2, 0,
1397 &sysrate_lock);
1398 clk = clk_register_gate(NULL, "pclk", "pclk_div", CLK_SET_RATE_PARENT,
1399 clk_base + SYSTEM_CLK_RATE, 3,
1400 CLK_GATE_SET_TO_DISABLE, &sysrate_lock);
1401 clk_register_clkdev(clk, "pclk", NULL);
1402 clks[pclk] = clk;
1403 1092
1404 /* twd */ 1093 /* twd */
1405 clk = clk_register_fixed_factor(NULL, "twd", "cclk_g", 1094 clk = clk_register_fixed_factor(NULL, "twd", "cclk_g",
1406 CLK_SET_RATE_PARENT, 1, 2); 1095 CLK_SET_RATE_PARENT, 1, 2);
1407 clk_register_clkdev(clk, "twd", NULL); 1096 clks[TEGRA30_CLK_TWD] = clk;
1408 clks[twd] = clk; 1097
1098 tegra_super_clk_gen4_init(clk_base, pmc_base, tegra30_clks, NULL);
1409} 1099}
1410 1100
1411static const char *mux_pllacp_clkm[] = { "pll_a_out0", "unused", "pll_p", 1101static const char *mux_pllacp_clkm[] = { "pll_a_out0", "unused", "pll_p",
1412 "clk_m" }; 1102 "clk_m" };
1413static const char *mux_pllpcm_clkm[] = { "pll_p", "pll_c", "pll_m", "clk_m" }; 1103static const char *mux_pllpcm_clkm[] = { "pll_p", "pll_c", "pll_m", "clk_m" };
1414static const char *mux_pllmcp_clkm[] = { "pll_m", "pll_c", "pll_p", "clk_m" }; 1104static const char *mux_pllmcp_clkm[] = { "pll_m", "pll_c", "pll_p", "clk_m" };
1415static const char *i2s0_parents[] = { "pll_a_out0", "audio0_2x", "pll_p",
1416 "clk_m" };
1417static const char *i2s1_parents[] = { "pll_a_out0", "audio1_2x", "pll_p",
1418 "clk_m" };
1419static const char *i2s2_parents[] = { "pll_a_out0", "audio2_2x", "pll_p",
1420 "clk_m" };
1421static const char *i2s3_parents[] = { "pll_a_out0", "audio3_2x", "pll_p",
1422 "clk_m" };
1423static const char *i2s4_parents[] = { "pll_a_out0", "audio4_2x", "pll_p",
1424 "clk_m" };
1425static const char *spdif_out_parents[] = { "pll_a_out0", "spdif_2x", "pll_p", 1105static const char *spdif_out_parents[] = { "pll_a_out0", "spdif_2x", "pll_p",
1426 "clk_m" }; 1106 "clk_m" };
1427static const char *spdif_in_parents[] = { "pll_p", "pll_c", "pll_m" };
1428static const char *mux_pllpc_clk32k_clkm[] = { "pll_p", "pll_c", "clk_32k",
1429 "clk_m" };
1430static const char *mux_pllpc_clkm_clk32k[] = { "pll_p", "pll_c", "clk_m",
1431 "clk_32k" };
1432static const char *mux_pllmcpa[] = { "pll_m", "pll_c", "pll_p", "pll_a_out0" }; 1107static const char *mux_pllmcpa[] = { "pll_m", "pll_c", "pll_p", "pll_a_out0" };
1433static const char *mux_pllpdc_clkm[] = { "pll_p", "pll_d_out0", "pll_c",
1434 "clk_m" };
1435static const char *mux_pllp_clkm[] = { "pll_p", "unused", "unused", "clk_m" };
1436static const char *mux_pllpmdacd2_clkm[] = { "pll_p", "pll_m", "pll_d_out0", 1108static const char *mux_pllpmdacd2_clkm[] = { "pll_p", "pll_m", "pll_d_out0",
1437 "pll_a_out0", "pll_c", 1109 "pll_a_out0", "pll_c",
1438 "pll_d2_out0", "clk_m" }; 1110 "pll_d2_out0", "clk_m" };
1439static const char *mux_plla_clk32k_pllp_clkm_plle[] = { "pll_a_out0",
1440 "clk_32k", "pll_p",
1441 "clk_m", "pll_e" };
1442static const char *mux_plld_out0_plld2_out0[] = { "pll_d_out0", 1111static const char *mux_plld_out0_plld2_out0[] = { "pll_d_out0",
1443 "pll_d2_out0" }; 1112 "pll_d2_out0" };
1113static const char *pwm_parents[] = { "pll_p", "pll_c", "clk_32k", "clk_m" };
1444 1114
1445static struct tegra_periph_init_data tegra_periph_clk_list[] = { 1115static struct tegra_periph_init_data tegra_periph_clk_list[] = {
1446 TEGRA_INIT_DATA_MUX("i2s0", NULL, "tegra30-i2s.0", i2s0_parents, CLK_SOURCE_I2S0, 30, &periph_l_regs, TEGRA_PERIPH_ON_APB, i2s0), 1116 TEGRA_INIT_DATA_MUX("spdif_out", spdif_out_parents, CLK_SOURCE_SPDIF_OUT, 10, TEGRA_PERIPH_ON_APB, TEGRA30_CLK_SPDIF_OUT),
1447 TEGRA_INIT_DATA_MUX("i2s1", NULL, "tegra30-i2s.1", i2s1_parents, CLK_SOURCE_I2S1, 11, &periph_l_regs, TEGRA_PERIPH_ON_APB, i2s1), 1117 TEGRA_INIT_DATA_MUX("d_audio", mux_pllacp_clkm, CLK_SOURCE_D_AUDIO, 106, 0, TEGRA30_CLK_D_AUDIO),
1448 TEGRA_INIT_DATA_MUX("i2s2", NULL, "tegra30-i2s.2", i2s2_parents, CLK_SOURCE_I2S2, 18, &periph_l_regs, TEGRA_PERIPH_ON_APB, i2s2), 1118 TEGRA_INIT_DATA_MUX("dam0", mux_pllacp_clkm, CLK_SOURCE_DAM0, 108, 0, TEGRA30_CLK_DAM0),
1449 TEGRA_INIT_DATA_MUX("i2s3", NULL, "tegra30-i2s.3", i2s3_parents, CLK_SOURCE_I2S3, 101, &periph_v_regs, TEGRA_PERIPH_ON_APB, i2s3), 1119 TEGRA_INIT_DATA_MUX("dam1", mux_pllacp_clkm, CLK_SOURCE_DAM1, 109, 0, TEGRA30_CLK_DAM1),
1450 TEGRA_INIT_DATA_MUX("i2s4", NULL, "tegra30-i2s.4", i2s4_parents, CLK_SOURCE_I2S4, 102, &periph_v_regs, TEGRA_PERIPH_ON_APB, i2s4), 1120 TEGRA_INIT_DATA_MUX("dam2", mux_pllacp_clkm, CLK_SOURCE_DAM2, 110, 0, TEGRA30_CLK_DAM2),
1451 TEGRA_INIT_DATA_MUX("spdif_out", "spdif_out", "tegra30-spdif", spdif_out_parents, CLK_SOURCE_SPDIF_OUT, 10, &periph_l_regs, TEGRA_PERIPH_ON_APB, spdif_out), 1121 TEGRA_INIT_DATA_INT("3d2", mux_pllmcpa, CLK_SOURCE_3D2, 98, TEGRA_PERIPH_MANUAL_RESET, TEGRA30_CLK_GR3D2),
1452 TEGRA_INIT_DATA_MUX("spdif_in", "spdif_in", "tegra30-spdif", spdif_in_parents, CLK_SOURCE_SPDIF_IN, 10, &periph_l_regs, TEGRA_PERIPH_ON_APB, spdif_in), 1122 TEGRA_INIT_DATA_INT("se", mux_pllpcm_clkm, CLK_SOURCE_SE, 127, 0, TEGRA30_CLK_SE),
1453 TEGRA_INIT_DATA_MUX("d_audio", "d_audio", "tegra30-ahub", mux_pllacp_clkm, CLK_SOURCE_D_AUDIO, 106, &periph_v_regs, 0, d_audio), 1123 TEGRA_INIT_DATA_MUX8("hdmi", mux_pllpmdacd2_clkm, CLK_SOURCE_HDMI, 51, 0, TEGRA30_CLK_HDMI),
1454 TEGRA_INIT_DATA_MUX("dam0", NULL, "tegra30-dam.0", mux_pllacp_clkm, CLK_SOURCE_DAM0, 108, &periph_v_regs, 0, dam0), 1124 TEGRA_INIT_DATA("pwm", NULL, NULL, pwm_parents, CLK_SOURCE_PWM, 28, 2, 0, 0, 8, 1, 0, 17, TEGRA_PERIPH_ON_APB, TEGRA30_CLK_PWM),
1455 TEGRA_INIT_DATA_MUX("dam1", NULL, "tegra30-dam.1", mux_pllacp_clkm, CLK_SOURCE_DAM1, 109, &periph_v_regs, 0, dam1),
1456 TEGRA_INIT_DATA_MUX("dam2", NULL, "tegra30-dam.2", mux_pllacp_clkm, CLK_SOURCE_DAM2, 110, &periph_v_regs, 0, dam2),
1457 TEGRA_INIT_DATA_MUX("hda", "hda", "tegra30-hda", mux_pllpcm_clkm, CLK_SOURCE_HDA, 125, &periph_v_regs, 0, hda),
1458 TEGRA_INIT_DATA_MUX("hda2codec_2x", "hda2codec", "tegra30-hda", mux_pllpcm_clkm, CLK_SOURCE_HDA2CODEC_2X, 111, &periph_v_regs, 0, hda2codec_2x),
1459 TEGRA_INIT_DATA_MUX("sbc1", NULL, "spi_tegra.0", mux_pllpcm_clkm, CLK_SOURCE_SBC1, 41, &periph_h_regs, TEGRA_PERIPH_ON_APB, sbc1),
1460 TEGRA_INIT_DATA_MUX("sbc2", NULL, "spi_tegra.1", mux_pllpcm_clkm, CLK_SOURCE_SBC2, 44, &periph_h_regs, TEGRA_PERIPH_ON_APB, sbc2),
1461 TEGRA_INIT_DATA_MUX("sbc3", NULL, "spi_tegra.2", mux_pllpcm_clkm, CLK_SOURCE_SBC3, 46, &periph_h_regs, TEGRA_PERIPH_ON_APB, sbc3),
1462 TEGRA_INIT_DATA_MUX("sbc4", NULL, "spi_tegra.3", mux_pllpcm_clkm, CLK_SOURCE_SBC4, 68, &periph_u_regs, TEGRA_PERIPH_ON_APB, sbc4),
1463 TEGRA_INIT_DATA_MUX("sbc5", NULL, "spi_tegra.4", mux_pllpcm_clkm, CLK_SOURCE_SBC5, 104, &periph_v_regs, TEGRA_PERIPH_ON_APB, sbc5),
1464 TEGRA_INIT_DATA_MUX("sbc6", NULL, "spi_tegra.5", mux_pllpcm_clkm, CLK_SOURCE_SBC6, 105, &periph_v_regs, TEGRA_PERIPH_ON_APB, sbc6),
1465 TEGRA_INIT_DATA_MUX("sata_oob", NULL, "tegra_sata_oob", mux_pllpcm_clkm, CLK_SOURCE_SATA_OOB, 123, &periph_v_regs, TEGRA_PERIPH_ON_APB, sata_oob),
1466 TEGRA_INIT_DATA_MUX("sata", NULL, "tegra_sata", mux_pllpcm_clkm, CLK_SOURCE_SATA, 124, &periph_v_regs, TEGRA_PERIPH_ON_APB, sata),
1467 TEGRA_INIT_DATA_MUX("ndflash", NULL, "tegra_nand", mux_pllpcm_clkm, CLK_SOURCE_NDFLASH, 13, &periph_l_regs, TEGRA_PERIPH_ON_APB, ndflash),
1468 TEGRA_INIT_DATA_MUX("ndspeed", NULL, "tegra_nand_speed", mux_pllpcm_clkm, CLK_SOURCE_NDSPEED, 80, &periph_u_regs, TEGRA_PERIPH_ON_APB, ndspeed),
1469 TEGRA_INIT_DATA_MUX("vfir", NULL, "vfir", mux_pllpcm_clkm, CLK_SOURCE_VFIR, 7, &periph_l_regs, TEGRA_PERIPH_ON_APB, vfir),
1470 TEGRA_INIT_DATA_MUX("csite", NULL, "csite", mux_pllpcm_clkm, CLK_SOURCE_CSITE, 73, &periph_u_regs, TEGRA_PERIPH_ON_APB, csite),
1471 TEGRA_INIT_DATA_MUX("la", NULL, "la", mux_pllpcm_clkm, CLK_SOURCE_LA, 76, &periph_u_regs, TEGRA_PERIPH_ON_APB, la),
1472 TEGRA_INIT_DATA_MUX("owr", NULL, "tegra_w1", mux_pllpcm_clkm, CLK_SOURCE_OWR, 71, &periph_u_regs, TEGRA_PERIPH_ON_APB, owr),
1473 TEGRA_INIT_DATA_MUX("mipi", NULL, "mipi", mux_pllpcm_clkm, CLK_SOURCE_MIPI, 50, &periph_h_regs, TEGRA_PERIPH_ON_APB, mipi),
1474 TEGRA_INIT_DATA_MUX("tsensor", NULL, "tegra-tsensor", mux_pllpc_clkm_clk32k, CLK_SOURCE_TSENSOR, 100, &periph_v_regs, TEGRA_PERIPH_ON_APB, tsensor),
1475 TEGRA_INIT_DATA_MUX("i2cslow", NULL, "i2cslow", mux_pllpc_clk32k_clkm, CLK_SOURCE_I2CSLOW, 81, &periph_u_regs, TEGRA_PERIPH_ON_APB, i2cslow),
1476 TEGRA_INIT_DATA_INT("vde", NULL, "vde", mux_pllpcm_clkm, CLK_SOURCE_VDE, 61, &periph_h_regs, 0, vde),
1477 TEGRA_INIT_DATA_INT("vi", "vi", "tegra_camera", mux_pllmcpa, CLK_SOURCE_VI, 20, &periph_l_regs, 0, vi),
1478 TEGRA_INIT_DATA_INT("epp", NULL, "epp", mux_pllmcpa, CLK_SOURCE_EPP, 19, &periph_l_regs, 0, epp),
1479 TEGRA_INIT_DATA_INT("mpe", NULL, "mpe", mux_pllmcpa, CLK_SOURCE_MPE, 60, &periph_h_regs, 0, mpe),
1480 TEGRA_INIT_DATA_INT("host1x", NULL, "host1x", mux_pllmcpa, CLK_SOURCE_HOST1X, 28, &periph_l_regs, 0, host1x),
1481 TEGRA_INIT_DATA_INT("3d", NULL, "3d", mux_pllmcpa, CLK_SOURCE_3D, 24, &periph_l_regs, TEGRA_PERIPH_MANUAL_RESET, gr3d),
1482 TEGRA_INIT_DATA_INT("3d2", NULL, "3d2", mux_pllmcpa, CLK_SOURCE_3D2, 98, &periph_v_regs, TEGRA_PERIPH_MANUAL_RESET, gr3d2),
1483 TEGRA_INIT_DATA_INT("2d", NULL, "2d", mux_pllmcpa, CLK_SOURCE_2D, 21, &periph_l_regs, 0, gr2d),
1484 TEGRA_INIT_DATA_INT("se", NULL, "se", mux_pllpcm_clkm, CLK_SOURCE_SE, 127, &periph_v_regs, 0, se),
1485 TEGRA_INIT_DATA_MUX("mselect", NULL, "mselect", mux_pllp_clkm, CLK_SOURCE_MSELECT, 99, &periph_v_regs, 0, mselect),
1486 TEGRA_INIT_DATA_MUX("nor", NULL, "tegra-nor", mux_pllpcm_clkm, CLK_SOURCE_NOR, 42, &periph_h_regs, 0, nor),
1487 TEGRA_INIT_DATA_MUX("sdmmc1", NULL, "sdhci-tegra.0", mux_pllpcm_clkm, CLK_SOURCE_SDMMC1, 14, &periph_l_regs, 0, sdmmc1),
1488 TEGRA_INIT_DATA_MUX("sdmmc2", NULL, "sdhci-tegra.1", mux_pllpcm_clkm, CLK_SOURCE_SDMMC2, 9, &periph_l_regs, 0, sdmmc2),
1489 TEGRA_INIT_DATA_MUX("sdmmc3", NULL, "sdhci-tegra.2", mux_pllpcm_clkm, CLK_SOURCE_SDMMC3, 69, &periph_u_regs, 0, sdmmc3),
1490 TEGRA_INIT_DATA_MUX("sdmmc4", NULL, "sdhci-tegra.3", mux_pllpcm_clkm, CLK_SOURCE_SDMMC4, 15, &periph_l_regs, 0, sdmmc4),
1491 TEGRA_INIT_DATA_MUX("cve", NULL, "cve", mux_pllpdc_clkm, CLK_SOURCE_CVE, 49, &periph_h_regs, 0, cve),
1492 TEGRA_INIT_DATA_MUX("tvo", NULL, "tvo", mux_pllpdc_clkm, CLK_SOURCE_TVO, 49, &periph_h_regs, 0, tvo),
1493 TEGRA_INIT_DATA_MUX("tvdac", NULL, "tvdac", mux_pllpdc_clkm, CLK_SOURCE_TVDAC, 53, &periph_h_regs, 0, tvdac),
1494 TEGRA_INIT_DATA_MUX("actmon", NULL, "actmon", mux_pllpc_clk32k_clkm, CLK_SOURCE_ACTMON, 119, &periph_v_regs, 0, actmon),
1495 TEGRA_INIT_DATA_MUX("vi_sensor", "vi_sensor", "tegra_camera", mux_pllmcpa, CLK_SOURCE_VI_SENSOR, 20, &periph_l_regs, TEGRA_PERIPH_NO_RESET, vi_sensor),
1496 TEGRA_INIT_DATA_DIV16("i2c1", "div-clk", "tegra-i2c.0", mux_pllp_clkm, CLK_SOURCE_I2C1, 12, &periph_l_regs, TEGRA_PERIPH_ON_APB, i2c1),
1497 TEGRA_INIT_DATA_DIV16("i2c2", "div-clk", "tegra-i2c.1", mux_pllp_clkm, CLK_SOURCE_I2C2, 54, &periph_h_regs, TEGRA_PERIPH_ON_APB, i2c2),
1498 TEGRA_INIT_DATA_DIV16("i2c3", "div-clk", "tegra-i2c.2", mux_pllp_clkm, CLK_SOURCE_I2C3, 67, &periph_u_regs, TEGRA_PERIPH_ON_APB, i2c3),
1499 TEGRA_INIT_DATA_DIV16("i2c4", "div-clk", "tegra-i2c.3", mux_pllp_clkm, CLK_SOURCE_I2C4, 103, &periph_v_regs, TEGRA_PERIPH_ON_APB, i2c4),
1500 TEGRA_INIT_DATA_DIV16("i2c5", "div-clk", "tegra-i2c.4", mux_pllp_clkm, CLK_SOURCE_I2C5, 47, &periph_h_regs, TEGRA_PERIPH_ON_APB, i2c5),
1501 TEGRA_INIT_DATA_UART("uarta", NULL, "tegra_uart.0", mux_pllpcm_clkm, CLK_SOURCE_UARTA, 6, &periph_l_regs, uarta),
1502 TEGRA_INIT_DATA_UART("uartb", NULL, "tegra_uart.1", mux_pllpcm_clkm, CLK_SOURCE_UARTB, 7, &periph_l_regs, uartb),
1503 TEGRA_INIT_DATA_UART("uartc", NULL, "tegra_uart.2", mux_pllpcm_clkm, CLK_SOURCE_UARTC, 55, &periph_h_regs, uartc),
1504 TEGRA_INIT_DATA_UART("uartd", NULL, "tegra_uart.3", mux_pllpcm_clkm, CLK_SOURCE_UARTD, 65, &periph_u_regs, uartd),
1505 TEGRA_INIT_DATA_UART("uarte", NULL, "tegra_uart.4", mux_pllpcm_clkm, CLK_SOURCE_UARTE, 66, &periph_u_regs, uarte),
1506 TEGRA_INIT_DATA_MUX8("hdmi", NULL, "hdmi", mux_pllpmdacd2_clkm, CLK_SOURCE_HDMI, 51, &periph_h_regs, 0, hdmi),
1507 TEGRA_INIT_DATA_MUX8("extern1", NULL, "extern1", mux_plla_clk32k_pllp_clkm_plle, CLK_SOURCE_EXTERN1, 120, &periph_v_regs, 0, extern1),
1508 TEGRA_INIT_DATA_MUX8("extern2", NULL, "extern2", mux_plla_clk32k_pllp_clkm_plle, CLK_SOURCE_EXTERN2, 121, &periph_v_regs, 0, extern2),
1509 TEGRA_INIT_DATA_MUX8("extern3", NULL, "extern3", mux_plla_clk32k_pllp_clkm_plle, CLK_SOURCE_EXTERN3, 122, &periph_v_regs, 0, extern3),
1510 TEGRA_INIT_DATA("pwm", NULL, "pwm", mux_pllpc_clk32k_clkm, CLK_SOURCE_PWM, 28, 2, 0, 0, 8, 1, 0, &periph_l_regs, 17, periph_clk_enb_refcnt, 0, pwm),
1511}; 1125};
1512 1126
1513static struct tegra_periph_init_data tegra_periph_nodiv_clk_list[] = { 1127static struct tegra_periph_init_data tegra_periph_nodiv_clk_list[] = {
1514 TEGRA_INIT_DATA_NODIV("disp1", NULL, "tegradc.0", mux_pllpmdacd2_clkm, CLK_SOURCE_DISP1, 29, 3, 27, &periph_l_regs, 0, disp1), 1128 TEGRA_INIT_DATA_NODIV("dsib", mux_plld_out0_plld2_out0, CLK_SOURCE_DSIB, 25, 1, 82, 0, TEGRA30_CLK_DSIB),
1515 TEGRA_INIT_DATA_NODIV("disp2", NULL, "tegradc.1", mux_pllpmdacd2_clkm, CLK_SOURCE_DISP2, 29, 3, 26, &periph_l_regs, 0, disp2),
1516 TEGRA_INIT_DATA_NODIV("dsib", NULL, "tegradc.1", mux_plld_out0_plld2_out0, CLK_SOURCE_DSIB, 25, 1, 82, &periph_u_regs, 0, dsib),
1517}; 1129};
1518 1130
1519static void __init tegra30_periph_clk_init(void) 1131static void __init tegra30_periph_clk_init(void)
@@ -1522,170 +1134,20 @@ static void __init tegra30_periph_clk_init(void)
1522 struct clk *clk; 1134 struct clk *clk;
1523 int i; 1135 int i;
1524 1136
1525 /* apbdma */
1526 clk = tegra_clk_register_periph_gate("apbdma", "clk_m", 0, clk_base, 0, 34,
1527 &periph_h_regs, periph_clk_enb_refcnt);
1528 clk_register_clkdev(clk, NULL, "tegra-apbdma");
1529 clks[apbdma] = clk;
1530
1531 /* rtc */
1532 clk = tegra_clk_register_periph_gate("rtc", "clk_32k",
1533 TEGRA_PERIPH_NO_RESET | TEGRA_PERIPH_ON_APB,
1534 clk_base, 0, 4, &periph_l_regs,
1535 periph_clk_enb_refcnt);
1536 clk_register_clkdev(clk, NULL, "rtc-tegra");
1537 clks[rtc] = clk;
1538
1539 /* timer */
1540 clk = tegra_clk_register_periph_gate("timer", "clk_m", 0, clk_base, 0,
1541 5, &periph_l_regs, periph_clk_enb_refcnt);
1542 clk_register_clkdev(clk, NULL, "timer");
1543 clks[timer] = clk;
1544
1545 /* kbc */
1546 clk = tegra_clk_register_periph_gate("kbc", "clk_32k",
1547 TEGRA_PERIPH_NO_RESET | TEGRA_PERIPH_ON_APB,
1548 clk_base, 0, 36, &periph_h_regs,
1549 periph_clk_enb_refcnt);
1550 clk_register_clkdev(clk, NULL, "tegra-kbc");
1551 clks[kbc] = clk;
1552
1553 /* csus */
1554 clk = tegra_clk_register_periph_gate("csus", "clk_m",
1555 TEGRA_PERIPH_NO_RESET | TEGRA_PERIPH_ON_APB,
1556 clk_base, 0, 92, &periph_u_regs,
1557 periph_clk_enb_refcnt);
1558 clk_register_clkdev(clk, "csus", "tengra_camera");
1559 clks[csus] = clk;
1560
1561 /* vcp */
1562 clk = tegra_clk_register_periph_gate("vcp", "clk_m", 0, clk_base, 0, 29,
1563 &periph_l_regs, periph_clk_enb_refcnt);
1564 clk_register_clkdev(clk, "vcp", "tegra-avp");
1565 clks[vcp] = clk;
1566
1567 /* bsea */
1568 clk = tegra_clk_register_periph_gate("bsea", "clk_m", 0, clk_base, 0,
1569 62, &periph_h_regs, periph_clk_enb_refcnt);
1570 clk_register_clkdev(clk, "bsea", "tegra-avp");
1571 clks[bsea] = clk;
1572
1573 /* bsev */
1574 clk = tegra_clk_register_periph_gate("bsev", "clk_m", 0, clk_base, 0,
1575 63, &periph_h_regs, periph_clk_enb_refcnt);
1576 clk_register_clkdev(clk, "bsev", "tegra-aes");
1577 clks[bsev] = clk;
1578
1579 /* usbd */
1580 clk = tegra_clk_register_periph_gate("usbd", "clk_m", 0, clk_base, 0,
1581 22, &periph_l_regs, periph_clk_enb_refcnt);
1582 clk_register_clkdev(clk, NULL, "fsl-tegra-udc");
1583 clks[usbd] = clk;
1584
1585 /* usb2 */
1586 clk = tegra_clk_register_periph_gate("usb2", "clk_m", 0, clk_base, 0,
1587 58, &periph_h_regs, periph_clk_enb_refcnt);
1588 clk_register_clkdev(clk, NULL, "tegra-ehci.1");
1589 clks[usb2] = clk;
1590
1591 /* usb3 */
1592 clk = tegra_clk_register_periph_gate("usb3", "clk_m", 0, clk_base, 0,
1593 59, &periph_h_regs, periph_clk_enb_refcnt);
1594 clk_register_clkdev(clk, NULL, "tegra-ehci.2");
1595 clks[usb3] = clk;
1596
1597 /* dsia */ 1137 /* dsia */
1598 clk = tegra_clk_register_periph_gate("dsia", "pll_d_out0", 0, clk_base, 1138 clk = tegra_clk_register_periph_gate("dsia", "pll_d_out0", 0, clk_base,
1599 0, 48, &periph_h_regs, 1139 0, 48, periph_clk_enb_refcnt);
1600 periph_clk_enb_refcnt); 1140 clks[TEGRA30_CLK_DSIA] = clk;
1601 clk_register_clkdev(clk, "dsia", "tegradc.0");
1602 clks[dsia] = clk;
1603
1604 /* csi */
1605 clk = tegra_clk_register_periph_gate("csi", "pll_p_out3", 0, clk_base,
1606 0, 52, &periph_h_regs,
1607 periph_clk_enb_refcnt);
1608 clk_register_clkdev(clk, "csi", "tegra_camera");
1609 clks[csi] = clk;
1610
1611 /* isp */
1612 clk = tegra_clk_register_periph_gate("isp", "clk_m", 0, clk_base, 0, 23,
1613 &periph_l_regs, periph_clk_enb_refcnt);
1614 clk_register_clkdev(clk, "isp", "tegra_camera");
1615 clks[isp] = clk;
1616 1141
1617 /* pcie */ 1142 /* pcie */
1618 clk = tegra_clk_register_periph_gate("pcie", "clk_m", 0, clk_base, 0, 1143 clk = tegra_clk_register_periph_gate("pcie", "clk_m", 0, clk_base, 0,
1619 70, &periph_u_regs, periph_clk_enb_refcnt); 1144 70, periph_clk_enb_refcnt);
1620 clk_register_clkdev(clk, "pcie", "tegra-pcie"); 1145 clks[TEGRA30_CLK_PCIE] = clk;
1621 clks[pcie] = clk;
1622 1146
1623 /* afi */ 1147 /* afi */
1624 clk = tegra_clk_register_periph_gate("afi", "clk_m", 0, clk_base, 0, 72, 1148 clk = tegra_clk_register_periph_gate("afi", "clk_m", 0, clk_base, 0, 72,
1625 &periph_u_regs, periph_clk_enb_refcnt);
1626 clk_register_clkdev(clk, "afi", "tegra-pcie");
1627 clks[afi] = clk;
1628
1629 /* pciex */
1630 clk = tegra_clk_register_periph_gate("pciex", "pll_e", 0, clk_base, 0,
1631 74, &periph_u_regs, periph_clk_enb_refcnt);
1632 clk_register_clkdev(clk, "pciex", "tegra-pcie");
1633 clks[pciex] = clk;
1634
1635 /* kfuse */
1636 clk = tegra_clk_register_periph_gate("kfuse", "clk_m",
1637 TEGRA_PERIPH_ON_APB,
1638 clk_base, 0, 40, &periph_h_regs,
1639 periph_clk_enb_refcnt);
1640 clk_register_clkdev(clk, NULL, "kfuse-tegra");
1641 clks[kfuse] = clk;
1642
1643 /* fuse */
1644 clk = tegra_clk_register_periph_gate("fuse", "clk_m",
1645 TEGRA_PERIPH_ON_APB,
1646 clk_base, 0, 39, &periph_h_regs,
1647 periph_clk_enb_refcnt);
1648 clk_register_clkdev(clk, "fuse", "fuse-tegra");
1649 clks[fuse] = clk;
1650
1651 /* fuse_burn */
1652 clk = tegra_clk_register_periph_gate("fuse_burn", "clk_m",
1653 TEGRA_PERIPH_ON_APB,
1654 clk_base, 0, 39, &periph_h_regs,
1655 periph_clk_enb_refcnt); 1149 periph_clk_enb_refcnt);
1656 clk_register_clkdev(clk, "fuse_burn", "fuse-tegra"); 1150 clks[TEGRA30_CLK_AFI] = clk;
1657 clks[fuse_burn] = clk;
1658
1659 /* apbif */
1660 clk = tegra_clk_register_periph_gate("apbif", "clk_m", 0,
1661 clk_base, 0, 107, &periph_v_regs,
1662 periph_clk_enb_refcnt);
1663 clk_register_clkdev(clk, "apbif", "tegra30-ahub");
1664 clks[apbif] = clk;
1665
1666 /* hda2hdmi */
1667 clk = tegra_clk_register_periph_gate("hda2hdmi", "clk_m",
1668 TEGRA_PERIPH_ON_APB,
1669 clk_base, 0, 128, &periph_w_regs,
1670 periph_clk_enb_refcnt);
1671 clk_register_clkdev(clk, "hda2hdmi", "tegra30-hda");
1672 clks[hda2hdmi] = clk;
1673
1674 /* sata_cold */
1675 clk = tegra_clk_register_periph_gate("sata_cold", "clk_m",
1676 TEGRA_PERIPH_ON_APB,
1677 clk_base, 0, 129, &periph_w_regs,
1678 periph_clk_enb_refcnt);
1679 clk_register_clkdev(clk, NULL, "tegra_sata_cold");
1680 clks[sata_cold] = clk;
1681
1682 /* dtv */
1683 clk = tegra_clk_register_periph_gate("dtv", "clk_m",
1684 TEGRA_PERIPH_ON_APB,
1685 clk_base, 0, 79, &periph_u_regs,
1686 periph_clk_enb_refcnt);
1687 clk_register_clkdev(clk, NULL, "dtv");
1688 clks[dtv] = clk;
1689 1151
1690 /* emc */ 1152 /* emc */
1691 clk = clk_register_mux(NULL, "emc_mux", mux_pllmcp_clkm, 1153 clk = clk_register_mux(NULL, "emc_mux", mux_pllmcp_clkm,
@@ -1694,84 +1156,37 @@ static void __init tegra30_periph_clk_init(void)
1694 clk_base + CLK_SOURCE_EMC, 1156 clk_base + CLK_SOURCE_EMC,
1695 30, 2, 0, NULL); 1157 30, 2, 0, NULL);
1696 clk = tegra_clk_register_periph_gate("emc", "emc_mux", 0, clk_base, 0, 1158 clk = tegra_clk_register_periph_gate("emc", "emc_mux", 0, clk_base, 0,
1697 57, &periph_h_regs, periph_clk_enb_refcnt); 1159 57, periph_clk_enb_refcnt);
1698 clk_register_clkdev(clk, "emc", NULL); 1160 clks[TEGRA30_CLK_EMC] = clk;
1699 clks[emc] = clk; 1161
1162 /* cml0 */
1163 clk = clk_register_gate(NULL, "cml0", "pll_e", 0, clk_base + PLLE_AUX,
1164 0, 0, &cml_lock);
1165 clks[TEGRA30_CLK_CML0] = clk;
1166
1167 /* cml1 */
1168 clk = clk_register_gate(NULL, "cml1", "pll_e", 0, clk_base + PLLE_AUX,
1169 1, 0, &cml_lock);
1170 clks[TEGRA30_CLK_CML1] = clk;
1700 1171
1701 for (i = 0; i < ARRAY_SIZE(tegra_periph_clk_list); i++) { 1172 for (i = 0; i < ARRAY_SIZE(tegra_periph_clk_list); i++) {
1702 data = &tegra_periph_clk_list[i]; 1173 data = &tegra_periph_clk_list[i];
1703 clk = tegra_clk_register_periph(data->name, data->parent_names, 1174 clk = tegra_clk_register_periph(data->name, data->p.parent_names,
1704 data->num_parents, &data->periph, 1175 data->num_parents, &data->periph,
1705 clk_base, data->offset, data->flags); 1176 clk_base, data->offset, data->flags);
1706 clk_register_clkdev(clk, data->con_id, data->dev_id);
1707 clks[data->clk_id] = clk; 1177 clks[data->clk_id] = clk;
1708 } 1178 }
1709 1179
1710 for (i = 0; i < ARRAY_SIZE(tegra_periph_nodiv_clk_list); i++) { 1180 for (i = 0; i < ARRAY_SIZE(tegra_periph_nodiv_clk_list); i++) {
1711 data = &tegra_periph_nodiv_clk_list[i]; 1181 data = &tegra_periph_nodiv_clk_list[i];
1712 clk = tegra_clk_register_periph_nodiv(data->name, 1182 clk = tegra_clk_register_periph_nodiv(data->name,
1713 data->parent_names, 1183 data->p.parent_names,
1714 data->num_parents, &data->periph, 1184 data->num_parents, &data->periph,
1715 clk_base, data->offset); 1185 clk_base, data->offset);
1716 clk_register_clkdev(clk, data->con_id, data->dev_id);
1717 clks[data->clk_id] = clk; 1186 clks[data->clk_id] = clk;
1718 } 1187 }
1719}
1720
1721static void __init tegra30_fixed_clk_init(void)
1722{
1723 struct clk *clk;
1724
1725 /* clk_32k */
1726 clk = clk_register_fixed_rate(NULL, "clk_32k", NULL, CLK_IS_ROOT,
1727 32768);
1728 clk_register_clkdev(clk, "clk_32k", NULL);
1729 clks[clk_32k] = clk;
1730 1188
1731 /* clk_m_div2 */ 1189 tegra_periph_clk_init(clk_base, pmc_base, tegra30_clks, &pll_p_params);
1732 clk = clk_register_fixed_factor(NULL, "clk_m_div2", "clk_m",
1733 CLK_SET_RATE_PARENT, 1, 2);
1734 clk_register_clkdev(clk, "clk_m_div2", NULL);
1735 clks[clk_m_div2] = clk;
1736
1737 /* clk_m_div4 */
1738 clk = clk_register_fixed_factor(NULL, "clk_m_div4", "clk_m",
1739 CLK_SET_RATE_PARENT, 1, 4);
1740 clk_register_clkdev(clk, "clk_m_div4", NULL);
1741 clks[clk_m_div4] = clk;
1742
1743 /* cml0 */
1744 clk = clk_register_gate(NULL, "cml0", "pll_e", 0, clk_base + PLLE_AUX,
1745 0, 0, &cml_lock);
1746 clk_register_clkdev(clk, "cml0", NULL);
1747 clks[cml0] = clk;
1748
1749 /* cml1 */
1750 clk = clk_register_gate(NULL, "cml1", "pll_e", 0, clk_base + PLLE_AUX,
1751 1, 0, &cml_lock);
1752 clk_register_clkdev(clk, "cml1", NULL);
1753 clks[cml1] = clk;
1754}
1755
1756static void __init tegra30_osc_clk_init(void)
1757{
1758 struct clk *clk;
1759 unsigned int pll_ref_div;
1760
1761 tegra30_clk_measure_input_freq();
1762
1763 /* clk_m */
1764 clk = clk_register_fixed_rate(NULL, "clk_m", NULL, CLK_IS_ROOT,
1765 input_freq);
1766 clk_register_clkdev(clk, "clk_m", NULL);
1767 clks[clk_m] = clk;
1768
1769 /* pll_ref */
1770 pll_ref_div = tegra30_get_pll_ref_div();
1771 clk = clk_register_fixed_factor(NULL, "pll_ref", "clk_m",
1772 CLK_SET_RATE_PARENT, 1, pll_ref_div);
1773 clk_register_clkdev(clk, "pll_ref", NULL);
1774 clks[pll_ref] = clk;
1775} 1190}
1776 1191
1777/* Tegra30 CPU clock and reset control functions */ 1192/* Tegra30 CPU clock and reset control functions */
@@ -1913,48 +1328,49 @@ static struct tegra_cpu_car_ops tegra30_cpu_car_ops = {
1913}; 1328};
1914 1329
1915static struct tegra_clk_init_table init_table[] __initdata = { 1330static struct tegra_clk_init_table init_table[] __initdata = {
1916 {uarta, pll_p, 408000000, 0}, 1331 {TEGRA30_CLK_UARTA, TEGRA30_CLK_PLL_P, 408000000, 0},
1917 {uartb, pll_p, 408000000, 0}, 1332 {TEGRA30_CLK_UARTB, TEGRA30_CLK_PLL_P, 408000000, 0},
1918 {uartc, pll_p, 408000000, 0}, 1333 {TEGRA30_CLK_UARTC, TEGRA30_CLK_PLL_P, 408000000, 0},
1919 {uartd, pll_p, 408000000, 0}, 1334 {TEGRA30_CLK_UARTD, TEGRA30_CLK_PLL_P, 408000000, 0},
1920 {uarte, pll_p, 408000000, 0}, 1335 {TEGRA30_CLK_UARTE, TEGRA30_CLK_PLL_P, 408000000, 0},
1921 {pll_a, clk_max, 564480000, 1}, 1336 {TEGRA30_CLK_PLL_A, TEGRA30_CLK_CLK_MAX, 564480000, 1},
1922 {pll_a_out0, clk_max, 11289600, 1}, 1337 {TEGRA30_CLK_PLL_A_OUT0, TEGRA30_CLK_CLK_MAX, 11289600, 1},
1923 {extern1, pll_a_out0, 0, 1}, 1338 {TEGRA30_CLK_EXTERN1, TEGRA30_CLK_PLL_A_OUT0, 0, 1},
1924 {clk_out_1_mux, extern1, 0, 0}, 1339 {TEGRA30_CLK_CLK_OUT_1_MUX, TEGRA30_CLK_EXTERN1, 0, 0},
1925 {clk_out_1, clk_max, 0, 1}, 1340 {TEGRA30_CLK_CLK_OUT_1, TEGRA30_CLK_CLK_MAX, 0, 1},
1926 {blink, clk_max, 0, 1}, 1341 {TEGRA30_CLK_BLINK, TEGRA30_CLK_CLK_MAX, 0, 1},
1927 {i2s0, pll_a_out0, 11289600, 0}, 1342 {TEGRA30_CLK_I2S0, TEGRA30_CLK_PLL_A_OUT0, 11289600, 0},
1928 {i2s1, pll_a_out0, 11289600, 0}, 1343 {TEGRA30_CLK_I2S1, TEGRA30_CLK_PLL_A_OUT0, 11289600, 0},
1929 {i2s2, pll_a_out0, 11289600, 0}, 1344 {TEGRA30_CLK_I2S2, TEGRA30_CLK_PLL_A_OUT0, 11289600, 0},
1930 {i2s3, pll_a_out0, 11289600, 0}, 1345 {TEGRA30_CLK_I2S3, TEGRA30_CLK_PLL_A_OUT0, 11289600, 0},
1931 {i2s4, pll_a_out0, 11289600, 0}, 1346 {TEGRA30_CLK_I2S4, TEGRA30_CLK_PLL_A_OUT0, 11289600, 0},
1932 {sdmmc1, pll_p, 48000000, 0}, 1347 {TEGRA30_CLK_SDMMC1, TEGRA30_CLK_PLL_P, 48000000, 0},
1933 {sdmmc2, pll_p, 48000000, 0}, 1348 {TEGRA30_CLK_SDMMC2, TEGRA30_CLK_PLL_P, 48000000, 0},
1934 {sdmmc3, pll_p, 48000000, 0}, 1349 {TEGRA30_CLK_SDMMC3, TEGRA30_CLK_PLL_P, 48000000, 0},
1935 {pll_m, clk_max, 0, 1}, 1350 {TEGRA30_CLK_PLL_M, TEGRA30_CLK_CLK_MAX, 0, 1},
1936 {pclk, clk_max, 0, 1}, 1351 {TEGRA30_CLK_PCLK, TEGRA30_CLK_CLK_MAX, 0, 1},
1937 {csite, clk_max, 0, 1}, 1352 {TEGRA30_CLK_CSITE, TEGRA30_CLK_CLK_MAX, 0, 1},
1938 {emc, clk_max, 0, 1}, 1353 {TEGRA30_CLK_EMC, TEGRA30_CLK_CLK_MAX, 0, 1},
1939 {mselect, clk_max, 0, 1}, 1354 {TEGRA30_CLK_MSELECT, TEGRA30_CLK_CLK_MAX, 0, 1},
1940 {sbc1, pll_p, 100000000, 0}, 1355 {TEGRA30_CLK_SBC1, TEGRA30_CLK_PLL_P, 100000000, 0},
1941 {sbc2, pll_p, 100000000, 0}, 1356 {TEGRA30_CLK_SBC2, TEGRA30_CLK_PLL_P, 100000000, 0},
1942 {sbc3, pll_p, 100000000, 0}, 1357 {TEGRA30_CLK_SBC3, TEGRA30_CLK_PLL_P, 100000000, 0},
1943 {sbc4, pll_p, 100000000, 0}, 1358 {TEGRA30_CLK_SBC4, TEGRA30_CLK_PLL_P, 100000000, 0},
1944 {sbc5, pll_p, 100000000, 0}, 1359 {TEGRA30_CLK_SBC5, TEGRA30_CLK_PLL_P, 100000000, 0},
1945 {sbc6, pll_p, 100000000, 0}, 1360 {TEGRA30_CLK_SBC6, TEGRA30_CLK_PLL_P, 100000000, 0},
1946 {host1x, pll_c, 150000000, 0}, 1361 {TEGRA30_CLK_HOST1X, TEGRA30_CLK_PLL_C, 150000000, 0},
1947 {disp1, pll_p, 600000000, 0}, 1362 {TEGRA30_CLK_DISP1, TEGRA30_CLK_PLL_P, 600000000, 0},
1948 {disp2, pll_p, 600000000, 0}, 1363 {TEGRA30_CLK_DISP2, TEGRA30_CLK_PLL_P, 600000000, 0},
1949 {twd, clk_max, 0, 1}, 1364 {TEGRA30_CLK_TWD, TEGRA30_CLK_CLK_MAX, 0, 1},
1950 {gr2d, pll_c, 300000000, 0}, 1365 {TEGRA30_CLK_GR2D, TEGRA30_CLK_PLL_C, 300000000, 0},
1951 {gr3d, pll_c, 300000000, 0}, 1366 {TEGRA30_CLK_GR3D, TEGRA30_CLK_PLL_C, 300000000, 0},
1952 {clk_max, clk_max, 0, 0}, /* This MUST be the last entry. */ 1367 {TEGRA30_CLK_GR3D2, TEGRA30_CLK_PLL_C, 300000000, 0},
1368 {TEGRA30_CLK_CLK_MAX, TEGRA30_CLK_CLK_MAX, 0, 0}, /* This MUST be the last entry. */
1953}; 1369};
1954 1370
1955static void __init tegra30_clock_apply_init_table(void) 1371static void __init tegra30_clock_apply_init_table(void)
1956{ 1372{
1957 tegra_init_from_table(init_table, clks, clk_max); 1373 tegra_init_from_table(init_table, clks, TEGRA30_CLK_CLK_MAX);
1958} 1374}
1959 1375
1960/* 1376/*
@@ -1963,19 +1379,18 @@ static void __init tegra30_clock_apply_init_table(void)
1963 * table under two names. 1379 * table under two names.
1964 */ 1380 */
1965static struct tegra_clk_duplicate tegra_clk_duplicates[] = { 1381static struct tegra_clk_duplicate tegra_clk_duplicates[] = {
1966 TEGRA_CLK_DUPLICATE(usbd, "utmip-pad", NULL), 1382 TEGRA_CLK_DUPLICATE(TEGRA30_CLK_USBD, "utmip-pad", NULL),
1967 TEGRA_CLK_DUPLICATE(usbd, "tegra-ehci.0", NULL), 1383 TEGRA_CLK_DUPLICATE(TEGRA30_CLK_USBD, "tegra-ehci.0", NULL),
1968 TEGRA_CLK_DUPLICATE(usbd, "tegra-otg", NULL), 1384 TEGRA_CLK_DUPLICATE(TEGRA30_CLK_USBD, "tegra-otg", NULL),
1969 TEGRA_CLK_DUPLICATE(bsev, "tegra-avp", "bsev"), 1385 TEGRA_CLK_DUPLICATE(TEGRA30_CLK_BSEV, "tegra-avp", "bsev"),
1970 TEGRA_CLK_DUPLICATE(bsev, "nvavp", "bsev"), 1386 TEGRA_CLK_DUPLICATE(TEGRA30_CLK_BSEV, "nvavp", "bsev"),
1971 TEGRA_CLK_DUPLICATE(vde, "tegra-aes", "vde"), 1387 TEGRA_CLK_DUPLICATE(TEGRA30_CLK_VDE, "tegra-aes", "vde"),
1972 TEGRA_CLK_DUPLICATE(bsea, "tegra-aes", "bsea"), 1388 TEGRA_CLK_DUPLICATE(TEGRA30_CLK_BSEA, "tegra-aes", "bsea"),
1973 TEGRA_CLK_DUPLICATE(bsea, "nvavp", "bsea"), 1389 TEGRA_CLK_DUPLICATE(TEGRA30_CLK_BSEA, "nvavp", "bsea"),
1974 TEGRA_CLK_DUPLICATE(cml1, "tegra_sata_cml", NULL), 1390 TEGRA_CLK_DUPLICATE(TEGRA30_CLK_CML1, "tegra_sata_cml", NULL),
1975 TEGRA_CLK_DUPLICATE(cml0, "tegra_pcie", "cml"), 1391 TEGRA_CLK_DUPLICATE(TEGRA30_CLK_CML0, "tegra_pcie", "cml"),
1976 TEGRA_CLK_DUPLICATE(pciex, "tegra_pcie", "pciex"), 1392 TEGRA_CLK_DUPLICATE(TEGRA30_CLK_VCP, "nvavp", "vcp"),
1977 TEGRA_CLK_DUPLICATE(vcp, "nvavp", "vcp"), 1393 TEGRA_CLK_DUPLICATE(TEGRA30_CLK_CLK_MAX, NULL, NULL), /* MUST be the last entry */
1978 TEGRA_CLK_DUPLICATE(clk_max, NULL, NULL), /* MUST be the last entry */
1979}; 1394};
1980 1395
1981static const struct of_device_id pmc_match[] __initconst = { 1396static const struct of_device_id pmc_match[] __initconst = {
@@ -1986,7 +1401,6 @@ static const struct of_device_id pmc_match[] __initconst = {
1986static void __init tegra30_clock_init(struct device_node *np) 1401static void __init tegra30_clock_init(struct device_node *np)
1987{ 1402{
1988 struct device_node *node; 1403 struct device_node *node;
1989 int i;
1990 1404
1991 clk_base = of_iomap(np, 0); 1405 clk_base = of_iomap(np, 0);
1992 if (!clk_base) { 1406 if (!clk_base) {
@@ -2006,29 +1420,27 @@ static void __init tegra30_clock_init(struct device_node *np)
2006 BUG(); 1420 BUG();
2007 } 1421 }
2008 1422
2009 tegra30_osc_clk_init(); 1423 clks = tegra_clk_init(clk_base, TEGRA30_CLK_CLK_MAX,
2010 tegra30_fixed_clk_init(); 1424 TEGRA30_CLK_PERIPH_BANKS);
1425 if (!clks)
1426 return;
1427
1428 if (tegra_osc_clk_init(clk_base, tegra30_clks, tegra30_input_freq,
1429 ARRAY_SIZE(tegra30_input_freq), &input_freq, NULL) < 0)
1430 return;
1431
1432
1433 tegra_fixed_clk_init(tegra30_clks);
2011 tegra30_pll_init(); 1434 tegra30_pll_init();
2012 tegra30_super_clk_init(); 1435 tegra30_super_clk_init();
2013 tegra30_periph_clk_init(); 1436 tegra30_periph_clk_init();
2014 tegra30_audio_clk_init(); 1437 tegra_audio_clk_init(clk_base, pmc_base, tegra30_clks, &pll_a_params);
2015 tegra30_pmc_clk_init(); 1438 tegra_pmc_clk_init(pmc_base, tegra30_clks);
2016
2017 for (i = 0; i < ARRAY_SIZE(clks); i++) {
2018 if (IS_ERR(clks[i])) {
2019 pr_err("Tegra30 clk %d: register failed with %ld\n",
2020 i, PTR_ERR(clks[i]));
2021 BUG();
2022 }
2023 if (!clks[i])
2024 clks[i] = ERR_PTR(-EINVAL);
2025 }
2026 1439
2027 tegra_init_dup_clks(tegra_clk_duplicates, clks, clk_max); 1440 tegra_init_dup_clks(tegra_clk_duplicates, clks, TEGRA30_CLK_CLK_MAX);
2028 1441
2029 clk_data.clks = clks; 1442 tegra_add_of_provider(np);
2030 clk_data.clk_num = ARRAY_SIZE(clks); 1443 tegra_register_devclks(devclks, ARRAY_SIZE(devclks));
2031 of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);
2032 1444
2033 tegra_clk_apply_init_table = tegra30_clock_apply_init_table; 1445 tegra_clk_apply_init_table = tegra30_clock_apply_init_table;
2034 1446
diff --git a/drivers/clk/tegra/clk.c b/drivers/clk/tegra/clk.c
index 86581ac1fd69..c0a7d7723510 100644
--- a/drivers/clk/tegra/clk.c
+++ b/drivers/clk/tegra/clk.c
@@ -18,13 +18,175 @@
18#include <linux/clk-provider.h> 18#include <linux/clk-provider.h>
19#include <linux/of.h> 19#include <linux/of.h>
20#include <linux/clk/tegra.h> 20#include <linux/clk/tegra.h>
21#include <linux/reset-controller.h>
22#include <linux/tegra-soc.h>
21 23
22#include "clk.h" 24#include "clk.h"
23 25
26#define CLK_OUT_ENB_L 0x010
27#define CLK_OUT_ENB_H 0x014
28#define CLK_OUT_ENB_U 0x018
29#define CLK_OUT_ENB_V 0x360
30#define CLK_OUT_ENB_W 0x364
31#define CLK_OUT_ENB_X 0x280
32#define CLK_OUT_ENB_SET_L 0x320
33#define CLK_OUT_ENB_CLR_L 0x324
34#define CLK_OUT_ENB_SET_H 0x328
35#define CLK_OUT_ENB_CLR_H 0x32c
36#define CLK_OUT_ENB_SET_U 0x330
37#define CLK_OUT_ENB_CLR_U 0x334
38#define CLK_OUT_ENB_SET_V 0x440
39#define CLK_OUT_ENB_CLR_V 0x444
40#define CLK_OUT_ENB_SET_W 0x448
41#define CLK_OUT_ENB_CLR_W 0x44c
42#define CLK_OUT_ENB_SET_X 0x284
43#define CLK_OUT_ENB_CLR_X 0x288
44
45#define RST_DEVICES_L 0x004
46#define RST_DEVICES_H 0x008
47#define RST_DEVICES_U 0x00C
48#define RST_DFLL_DVCO 0x2F4
49#define RST_DEVICES_V 0x358
50#define RST_DEVICES_W 0x35C
51#define RST_DEVICES_X 0x28C
52#define RST_DEVICES_SET_L 0x300
53#define RST_DEVICES_CLR_L 0x304
54#define RST_DEVICES_SET_H 0x308
55#define RST_DEVICES_CLR_H 0x30c
56#define RST_DEVICES_SET_U 0x310
57#define RST_DEVICES_CLR_U 0x314
58#define RST_DEVICES_SET_V 0x430
59#define RST_DEVICES_CLR_V 0x434
60#define RST_DEVICES_SET_W 0x438
61#define RST_DEVICES_CLR_W 0x43c
62#define RST_DEVICES_SET_X 0x290
63#define RST_DEVICES_CLR_X 0x294
64
24/* Global data of Tegra CPU CAR ops */ 65/* Global data of Tegra CPU CAR ops */
25static struct tegra_cpu_car_ops dummy_car_ops; 66static struct tegra_cpu_car_ops dummy_car_ops;
26struct tegra_cpu_car_ops *tegra_cpu_car_ops = &dummy_car_ops; 67struct tegra_cpu_car_ops *tegra_cpu_car_ops = &dummy_car_ops;
27 68
69int *periph_clk_enb_refcnt;
70static int periph_banks;
71static struct clk **clks;
72static int clk_num;
73static struct clk_onecell_data clk_data;
74
75static struct tegra_clk_periph_regs periph_regs[] = {
76 [0] = {
77 .enb_reg = CLK_OUT_ENB_L,
78 .enb_set_reg = CLK_OUT_ENB_SET_L,
79 .enb_clr_reg = CLK_OUT_ENB_CLR_L,
80 .rst_reg = RST_DEVICES_L,
81 .rst_set_reg = RST_DEVICES_SET_L,
82 .rst_clr_reg = RST_DEVICES_CLR_L,
83 },
84 [1] = {
85 .enb_reg = CLK_OUT_ENB_H,
86 .enb_set_reg = CLK_OUT_ENB_SET_H,
87 .enb_clr_reg = CLK_OUT_ENB_CLR_H,
88 .rst_reg = RST_DEVICES_H,
89 .rst_set_reg = RST_DEVICES_SET_H,
90 .rst_clr_reg = RST_DEVICES_CLR_H,
91 },
92 [2] = {
93 .enb_reg = CLK_OUT_ENB_U,
94 .enb_set_reg = CLK_OUT_ENB_SET_U,
95 .enb_clr_reg = CLK_OUT_ENB_CLR_U,
96 .rst_reg = RST_DEVICES_U,
97 .rst_set_reg = RST_DEVICES_SET_U,
98 .rst_clr_reg = RST_DEVICES_CLR_U,
99 },
100 [3] = {
101 .enb_reg = CLK_OUT_ENB_V,
102 .enb_set_reg = CLK_OUT_ENB_SET_V,
103 .enb_clr_reg = CLK_OUT_ENB_CLR_V,
104 .rst_reg = RST_DEVICES_V,
105 .rst_set_reg = RST_DEVICES_SET_V,
106 .rst_clr_reg = RST_DEVICES_CLR_V,
107 },
108 [4] = {
109 .enb_reg = CLK_OUT_ENB_W,
110 .enb_set_reg = CLK_OUT_ENB_SET_W,
111 .enb_clr_reg = CLK_OUT_ENB_CLR_W,
112 .rst_reg = RST_DEVICES_W,
113 .rst_set_reg = RST_DEVICES_SET_W,
114 .rst_clr_reg = RST_DEVICES_CLR_W,
115 },
116 [5] = {
117 .enb_reg = CLK_OUT_ENB_X,
118 .enb_set_reg = CLK_OUT_ENB_SET_X,
119 .enb_clr_reg = CLK_OUT_ENB_CLR_X,
120 .rst_reg = RST_DEVICES_X,
121 .rst_set_reg = RST_DEVICES_SET_X,
122 .rst_clr_reg = RST_DEVICES_CLR_X,
123 },
124};
125
126static void __iomem *clk_base;
127
128static int tegra_clk_rst_assert(struct reset_controller_dev *rcdev,
129 unsigned long id)
130{
131 /*
132 * If peripheral is on the APB bus then we must read the APB bus to
133 * flush the write operation in apb bus. This will avoid peripheral
134 * access after disabling clock. Since the reset driver has no
135 * knowledge of which reset IDs represent which devices, simply do
136 * this all the time.
137 */
138 tegra_read_chipid();
139
140 writel_relaxed(BIT(id % 32),
141 clk_base + periph_regs[id / 32].rst_set_reg);
142
143 return 0;
144}
145
146static int tegra_clk_rst_deassert(struct reset_controller_dev *rcdev,
147 unsigned long id)
148{
149 writel_relaxed(BIT(id % 32),
150 clk_base + periph_regs[id / 32].rst_clr_reg);
151
152 return 0;
153}
154
155struct tegra_clk_periph_regs *get_reg_bank(int clkid)
156{
157 int reg_bank = clkid / 32;
158
159 if (reg_bank < periph_banks)
160 return &periph_regs[reg_bank];
161 else {
162 WARN_ON(1);
163 return NULL;
164 }
165}
166
167struct clk ** __init tegra_clk_init(void __iomem *regs, int num, int banks)
168{
169 clk_base = regs;
170
171 if (WARN_ON(banks > ARRAY_SIZE(periph_regs)))
172 return NULL;
173
174 periph_clk_enb_refcnt = kzalloc(32 * banks *
175 sizeof(*periph_clk_enb_refcnt), GFP_KERNEL);
176 if (!periph_clk_enb_refcnt)
177 return NULL;
178
179 periph_banks = banks;
180
181 clks = kzalloc(num * sizeof(struct clk *), GFP_KERNEL);
182 if (!clks)
183 kfree(periph_clk_enb_refcnt);
184
185 clk_num = num;
186
187 return clks;
188}
189
28void __init tegra_init_dup_clks(struct tegra_clk_duplicate *dup_list, 190void __init tegra_init_dup_clks(struct tegra_clk_duplicate *dup_list,
29 struct clk *clks[], int clk_max) 191 struct clk *clks[], int clk_max)
30{ 192{
@@ -74,6 +236,58 @@ void __init tegra_init_from_table(struct tegra_clk_init_table *tbl,
74 } 236 }
75} 237}
76 238
239static struct reset_control_ops rst_ops = {
240 .assert = tegra_clk_rst_assert,
241 .deassert = tegra_clk_rst_deassert,
242};
243
244static struct reset_controller_dev rst_ctlr = {
245 .ops = &rst_ops,
246 .owner = THIS_MODULE,
247 .of_reset_n_cells = 1,
248};
249
250void __init tegra_add_of_provider(struct device_node *np)
251{
252 int i;
253
254 for (i = 0; i < clk_num; i++) {
255 if (IS_ERR(clks[i])) {
256 pr_err
257 ("Tegra clk %d: register failed with %ld\n",
258 i, PTR_ERR(clks[i]));
259 }
260 if (!clks[i])
261 clks[i] = ERR_PTR(-EINVAL);
262 }
263
264 clk_data.clks = clks;
265 clk_data.clk_num = clk_num;
266 of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);
267
268 rst_ctlr.of_node = np;
269 rst_ctlr.nr_resets = clk_num * 32;
270 reset_controller_register(&rst_ctlr);
271}
272
273void __init tegra_register_devclks(struct tegra_devclk *dev_clks, int num)
274{
275 int i;
276
277 for (i = 0; i < num; i++, dev_clks++)
278 clk_register_clkdev(clks[dev_clks->dt_id], dev_clks->con_id,
279 dev_clks->dev_id);
280}
281
282struct clk ** __init tegra_lookup_dt_id(int clk_id,
283 struct tegra_clk *tegra_clk)
284{
285 if (tegra_clk[clk_id].present)
286 return &clks[tegra_clk[clk_id].dt_id];
287 else
288 return NULL;
289}
290
77tegra_clk_apply_init_table_func tegra_clk_apply_init_table; 291tegra_clk_apply_init_table_func tegra_clk_apply_init_table;
78 292
79void __init tegra_clocks_apply_init_table(void) 293void __init tegra_clocks_apply_init_table(void)
diff --git a/drivers/clk/tegra/clk.h b/drivers/clk/tegra/clk.h
index 07cfacd91686..16ec8d6bb87f 100644
--- a/drivers/clk/tegra/clk.h
+++ b/drivers/clk/tegra/clk.h
@@ -37,6 +37,8 @@ struct tegra_clk_sync_source {
37 container_of(_hw, struct tegra_clk_sync_source, hw) 37 container_of(_hw, struct tegra_clk_sync_source, hw)
38 38
39extern const struct clk_ops tegra_clk_sync_source_ops; 39extern const struct clk_ops tegra_clk_sync_source_ops;
40extern int *periph_clk_enb_refcnt;
41
40struct clk *tegra_clk_register_sync_source(const char *name, 42struct clk *tegra_clk_register_sync_source(const char *name,
41 unsigned long fixed_rate, unsigned long max_rate); 43 unsigned long fixed_rate, unsigned long max_rate);
42 44
@@ -188,12 +190,15 @@ struct tegra_clk_pll_params {
188 u32 ext_misc_reg[3]; 190 u32 ext_misc_reg[3];
189 u32 pmc_divnm_reg; 191 u32 pmc_divnm_reg;
190 u32 pmc_divp_reg; 192 u32 pmc_divp_reg;
193 u32 flags;
191 int stepa_shift; 194 int stepa_shift;
192 int stepb_shift; 195 int stepb_shift;
193 int lock_delay; 196 int lock_delay;
194 int max_p; 197 int max_p;
195 struct pdiv_map *pdiv_tohw; 198 struct pdiv_map *pdiv_tohw;
196 struct div_nmp *div_nmp; 199 struct div_nmp *div_nmp;
200 struct tegra_clk_pll_freq_table *freq_table;
201 unsigned long fixed_rate;
197}; 202};
198 203
199/** 204/**
@@ -233,10 +238,7 @@ struct tegra_clk_pll {
233 struct clk_hw hw; 238 struct clk_hw hw;
234 void __iomem *clk_base; 239 void __iomem *clk_base;
235 void __iomem *pmc; 240 void __iomem *pmc;
236 u32 flags;
237 unsigned long fixed_rate;
238 spinlock_t *lock; 241 spinlock_t *lock;
239 struct tegra_clk_pll_freq_table *freq_table;
240 struct tegra_clk_pll_params *params; 242 struct tegra_clk_pll_params *params;
241}; 243};
242 244
@@ -258,56 +260,49 @@ extern const struct clk_ops tegra_clk_pll_ops;
258extern const struct clk_ops tegra_clk_plle_ops; 260extern const struct clk_ops tegra_clk_plle_ops;
259struct clk *tegra_clk_register_pll(const char *name, const char *parent_name, 261struct clk *tegra_clk_register_pll(const char *name, const char *parent_name,
260 void __iomem *clk_base, void __iomem *pmc, 262 void __iomem *clk_base, void __iomem *pmc,
261 unsigned long flags, unsigned long fixed_rate, 263 unsigned long flags, struct tegra_clk_pll_params *pll_params,
262 struct tegra_clk_pll_params *pll_params, u32 pll_flags, 264 spinlock_t *lock);
263 struct tegra_clk_pll_freq_table *freq_table, spinlock_t *lock);
264 265
265struct clk *tegra_clk_register_plle(const char *name, const char *parent_name, 266struct clk *tegra_clk_register_plle(const char *name, const char *parent_name,
266 void __iomem *clk_base, void __iomem *pmc, 267 void __iomem *clk_base, void __iomem *pmc,
267 unsigned long flags, unsigned long fixed_rate, 268 unsigned long flags, struct tegra_clk_pll_params *pll_params,
268 struct tegra_clk_pll_params *pll_params, u32 pll_flags, 269 spinlock_t *lock);
269 struct tegra_clk_pll_freq_table *freq_table, spinlock_t *lock);
270 270
271struct clk *tegra_clk_register_pllxc(const char *name, const char *parent_name, 271struct clk *tegra_clk_register_pllxc(const char *name, const char *parent_name,
272 void __iomem *clk_base, void __iomem *pmc, 272 void __iomem *clk_base, void __iomem *pmc,
273 unsigned long flags, unsigned long fixed_rate, 273 unsigned long flags,
274 struct tegra_clk_pll_params *pll_params, 274 struct tegra_clk_pll_params *pll_params,
275 u32 pll_flags,
276 struct tegra_clk_pll_freq_table *freq_table,
277 spinlock_t *lock); 275 spinlock_t *lock);
278 276
279struct clk *tegra_clk_register_pllm(const char *name, const char *parent_name, 277struct clk *tegra_clk_register_pllm(const char *name, const char *parent_name,
280 void __iomem *clk_base, void __iomem *pmc, 278 void __iomem *clk_base, void __iomem *pmc,
281 unsigned long flags, unsigned long fixed_rate, 279 unsigned long flags,
282 struct tegra_clk_pll_params *pll_params, 280 struct tegra_clk_pll_params *pll_params,
283 u32 pll_flags,
284 struct tegra_clk_pll_freq_table *freq_table,
285 spinlock_t *lock); 281 spinlock_t *lock);
286 282
287struct clk *tegra_clk_register_pllc(const char *name, const char *parent_name, 283struct clk *tegra_clk_register_pllc(const char *name, const char *parent_name,
288 void __iomem *clk_base, void __iomem *pmc, 284 void __iomem *clk_base, void __iomem *pmc,
289 unsigned long flags, unsigned long fixed_rate, 285 unsigned long flags,
290 struct tegra_clk_pll_params *pll_params, 286 struct tegra_clk_pll_params *pll_params,
291 u32 pll_flags,
292 struct tegra_clk_pll_freq_table *freq_table,
293 spinlock_t *lock); 287 spinlock_t *lock);
294 288
295struct clk *tegra_clk_register_pllre(const char *name, const char *parent_name, 289struct clk *tegra_clk_register_pllre(const char *name, const char *parent_name,
296 void __iomem *clk_base, void __iomem *pmc, 290 void __iomem *clk_base, void __iomem *pmc,
297 unsigned long flags, unsigned long fixed_rate, 291 unsigned long flags,
298 struct tegra_clk_pll_params *pll_params, 292 struct tegra_clk_pll_params *pll_params,
299 u32 pll_flags,
300 struct tegra_clk_pll_freq_table *freq_table,
301 spinlock_t *lock, unsigned long parent_rate); 293 spinlock_t *lock, unsigned long parent_rate);
302 294
303struct clk *tegra_clk_register_plle_tegra114(const char *name, 295struct clk *tegra_clk_register_plle_tegra114(const char *name,
304 const char *parent_name, 296 const char *parent_name,
305 void __iomem *clk_base, unsigned long flags, 297 void __iomem *clk_base, unsigned long flags,
306 unsigned long fixed_rate,
307 struct tegra_clk_pll_params *pll_params, 298 struct tegra_clk_pll_params *pll_params,
308 struct tegra_clk_pll_freq_table *freq_table,
309 spinlock_t *lock); 299 spinlock_t *lock);
310 300
301struct clk *tegra_clk_register_pllss(const char *name, const char *parent_name,
302 void __iomem *clk_base, unsigned long flags,
303 struct tegra_clk_pll_params *pll_params,
304 spinlock_t *lock);
305
311/** 306/**
312 * struct tegra_clk_pll_out - PLL divider down clock 307 * struct tegra_clk_pll_out - PLL divider down clock
313 * 308 *
@@ -395,13 +390,13 @@ struct tegra_clk_periph_gate {
395#define TEGRA_PERIPH_MANUAL_RESET BIT(1) 390#define TEGRA_PERIPH_MANUAL_RESET BIT(1)
396#define TEGRA_PERIPH_ON_APB BIT(2) 391#define TEGRA_PERIPH_ON_APB BIT(2)
397#define TEGRA_PERIPH_WAR_1005168 BIT(3) 392#define TEGRA_PERIPH_WAR_1005168 BIT(3)
393#define TEGRA_PERIPH_NO_DIV BIT(4)
394#define TEGRA_PERIPH_NO_GATE BIT(5)
398 395
399void tegra_periph_reset(struct tegra_clk_periph_gate *gate, bool assert);
400extern const struct clk_ops tegra_clk_periph_gate_ops; 396extern const struct clk_ops tegra_clk_periph_gate_ops;
401struct clk *tegra_clk_register_periph_gate(const char *name, 397struct clk *tegra_clk_register_periph_gate(const char *name,
402 const char *parent_name, u8 gate_flags, void __iomem *clk_base, 398 const char *parent_name, u8 gate_flags, void __iomem *clk_base,
403 unsigned long flags, int clk_num, 399 unsigned long flags, int clk_num, int *enable_refcnt);
404 struct tegra_clk_periph_regs *pregs, int *enable_refcnt);
405 400
406/** 401/**
407 * struct clk-periph - peripheral clock 402 * struct clk-periph - peripheral clock
@@ -443,26 +438,26 @@ struct clk *tegra_clk_register_periph_nodiv(const char *name,
443 438
444#define TEGRA_CLK_PERIPH(_mux_shift, _mux_mask, _mux_flags, \ 439#define TEGRA_CLK_PERIPH(_mux_shift, _mux_mask, _mux_flags, \
445 _div_shift, _div_width, _div_frac_width, \ 440 _div_shift, _div_width, _div_frac_width, \
446 _div_flags, _clk_num, _enb_refcnt, _regs, \ 441 _div_flags, _clk_num,\
447 _gate_flags, _table) \ 442 _gate_flags, _table, _lock) \
448 { \ 443 { \
449 .mux = { \ 444 .mux = { \
450 .flags = _mux_flags, \ 445 .flags = _mux_flags, \
451 .shift = _mux_shift, \ 446 .shift = _mux_shift, \
452 .mask = _mux_mask, \ 447 .mask = _mux_mask, \
453 .table = _table, \ 448 .table = _table, \
449 .lock = _lock, \
454 }, \ 450 }, \
455 .divider = { \ 451 .divider = { \
456 .flags = _div_flags, \ 452 .flags = _div_flags, \
457 .shift = _div_shift, \ 453 .shift = _div_shift, \
458 .width = _div_width, \ 454 .width = _div_width, \
459 .frac_width = _div_frac_width, \ 455 .frac_width = _div_frac_width, \
456 .lock = _lock, \
460 }, \ 457 }, \
461 .gate = { \ 458 .gate = { \
462 .flags = _gate_flags, \ 459 .flags = _gate_flags, \
463 .clk_num = _clk_num, \ 460 .clk_num = _clk_num, \
464 .enable_refcnt = _enb_refcnt, \
465 .regs = _regs, \
466 }, \ 461 }, \
467 .mux_ops = &clk_mux_ops, \ 462 .mux_ops = &clk_mux_ops, \
468 .div_ops = &tegra_clk_frac_div_ops, \ 463 .div_ops = &tegra_clk_frac_div_ops, \
@@ -472,7 +467,10 @@ struct clk *tegra_clk_register_periph_nodiv(const char *name,
472struct tegra_periph_init_data { 467struct tegra_periph_init_data {
473 const char *name; 468 const char *name;
474 int clk_id; 469 int clk_id;
475 const char **parent_names; 470 union {
471 const char **parent_names;
472 const char *parent_name;
473 } p;
476 int num_parents; 474 int num_parents;
477 struct tegra_clk_periph periph; 475 struct tegra_clk_periph periph;
478 u32 offset; 476 u32 offset;
@@ -483,20 +481,19 @@ struct tegra_periph_init_data {
483 481
484#define TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parent_names, _offset,\ 482#define TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parent_names, _offset,\
485 _mux_shift, _mux_mask, _mux_flags, _div_shift, \ 483 _mux_shift, _mux_mask, _mux_flags, _div_shift, \
486 _div_width, _div_frac_width, _div_flags, _regs, \ 484 _div_width, _div_frac_width, _div_flags, \
487 _clk_num, _enb_refcnt, _gate_flags, _clk_id, _table,\ 485 _clk_num, _gate_flags, _clk_id, _table, \
488 _flags) \ 486 _flags, _lock) \
489 { \ 487 { \
490 .name = _name, \ 488 .name = _name, \
491 .clk_id = _clk_id, \ 489 .clk_id = _clk_id, \
492 .parent_names = _parent_names, \ 490 .p.parent_names = _parent_names, \
493 .num_parents = ARRAY_SIZE(_parent_names), \ 491 .num_parents = ARRAY_SIZE(_parent_names), \
494 .periph = TEGRA_CLK_PERIPH(_mux_shift, _mux_mask, \ 492 .periph = TEGRA_CLK_PERIPH(_mux_shift, _mux_mask, \
495 _mux_flags, _div_shift, \ 493 _mux_flags, _div_shift, \
496 _div_width, _div_frac_width, \ 494 _div_width, _div_frac_width, \
497 _div_flags, _clk_num, \ 495 _div_flags, _clk_num, \
498 _enb_refcnt, _regs, \ 496 _gate_flags, _table, _lock), \
499 _gate_flags, _table), \
500 .offset = _offset, \ 497 .offset = _offset, \
501 .con_id = _con_id, \ 498 .con_id = _con_id, \
502 .dev_id = _dev_id, \ 499 .dev_id = _dev_id, \
@@ -505,13 +502,13 @@ struct tegra_periph_init_data {
505 502
506#define TEGRA_INIT_DATA(_name, _con_id, _dev_id, _parent_names, _offset,\ 503#define TEGRA_INIT_DATA(_name, _con_id, _dev_id, _parent_names, _offset,\
507 _mux_shift, _mux_width, _mux_flags, _div_shift, \ 504 _mux_shift, _mux_width, _mux_flags, _div_shift, \
508 _div_width, _div_frac_width, _div_flags, _regs, \ 505 _div_width, _div_frac_width, _div_flags, \
509 _clk_num, _enb_refcnt, _gate_flags, _clk_id) \ 506 _clk_num, _gate_flags, _clk_id) \
510 TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parent_names, _offset,\ 507 TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parent_names, _offset,\
511 _mux_shift, BIT(_mux_width) - 1, _mux_flags, \ 508 _mux_shift, BIT(_mux_width) - 1, _mux_flags, \
512 _div_shift, _div_width, _div_frac_width, _div_flags, \ 509 _div_shift, _div_width, _div_frac_width, _div_flags, \
513 _regs, _clk_num, _enb_refcnt, _gate_flags, _clk_id,\ 510 _clk_num, _gate_flags, _clk_id,\
514 NULL, 0) 511 NULL, 0, NULL)
515 512
516/** 513/**
517 * struct clk_super_mux - super clock 514 * struct clk_super_mux - super clock
@@ -581,12 +578,49 @@ struct tegra_clk_duplicate {
581 }, \ 578 }, \
582 } 579 }
583 580
581struct tegra_clk {
582 int dt_id;
583 bool present;
584};
585
586struct tegra_devclk {
587 int dt_id;
588 char *dev_id;
589 char *con_id;
590};
591
584void tegra_init_from_table(struct tegra_clk_init_table *tbl, 592void tegra_init_from_table(struct tegra_clk_init_table *tbl,
585 struct clk *clks[], int clk_max); 593 struct clk *clks[], int clk_max);
586 594
587void tegra_init_dup_clks(struct tegra_clk_duplicate *dup_list, 595void tegra_init_dup_clks(struct tegra_clk_duplicate *dup_list,
588 struct clk *clks[], int clk_max); 596 struct clk *clks[], int clk_max);
589 597
598struct tegra_clk_periph_regs *get_reg_bank(int clkid);
599struct clk **tegra_clk_init(void __iomem *clk_base, int num, int periph_banks);
600
601struct clk **tegra_lookup_dt_id(int clk_id, struct tegra_clk *tegra_clk);
602
603void tegra_add_of_provider(struct device_node *np);
604void tegra_register_devclks(struct tegra_devclk *dev_clks, int num);
605
606void tegra_audio_clk_init(void __iomem *clk_base,
607 void __iomem *pmc_base, struct tegra_clk *tegra_clks,
608 struct tegra_clk_pll_params *pll_params);
609
610void tegra_periph_clk_init(void __iomem *clk_base, void __iomem *pmc_base,
611 struct tegra_clk *tegra_clks,
612 struct tegra_clk_pll_params *pll_params);
613
614void tegra_pmc_clk_init(void __iomem *pmc_base, struct tegra_clk *tegra_clks);
615void tegra_fixed_clk_init(struct tegra_clk *tegra_clks);
616int tegra_osc_clk_init(void __iomem *clk_base, struct tegra_clk *tegra_clks,
617 unsigned long *input_freqs, int num,
618 unsigned long *osc_freq,
619 unsigned long *pll_ref_freq);
620void tegra_super_clk_gen4_init(void __iomem *clk_base,
621 void __iomem *pmc_base, struct tegra_clk *tegra_clks,
622 struct tegra_clk_pll_params *pll_params);
623
590void tegra114_clock_tune_cpu_trimmers_high(void); 624void tegra114_clock_tune_cpu_trimmers_high(void);
591void tegra114_clock_tune_cpu_trimmers_low(void); 625void tegra114_clock_tune_cpu_trimmers_low(void);
592void tegra114_clock_tune_cpu_trimmers_init(void); 626void tegra114_clock_tune_cpu_trimmers_init(void);
diff --git a/drivers/cpufreq/at32ap-cpufreq.c b/drivers/cpufreq/at32ap-cpufreq.c
index 856ad80418ae..7c03dd84f66a 100644
--- a/drivers/cpufreq/at32ap-cpufreq.c
+++ b/drivers/cpufreq/at32ap-cpufreq.c
@@ -58,7 +58,7 @@ static int at32_set_target(struct cpufreq_policy *policy, unsigned int index)
58 return 0; 58 return 0;
59} 59}
60 60
61static int __init at32_cpufreq_driver_init(struct cpufreq_policy *policy) 61static int at32_cpufreq_driver_init(struct cpufreq_policy *policy)
62{ 62{
63 unsigned int frequency, rate, min_freq; 63 unsigned int frequency, rate, min_freq;
64 int retval, steps, i; 64 int retval, steps, i;
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 81e9d4412db8..02d534da22dd 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -26,7 +26,6 @@
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/mutex.h> 27#include <linux/mutex.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/suspend.h>
30#include <linux/syscore_ops.h> 29#include <linux/syscore_ops.h>
31#include <linux/tick.h> 30#include <linux/tick.h>
32#include <trace/events/power.h> 31#include <trace/events/power.h>
@@ -48,9 +47,6 @@ static LIST_HEAD(cpufreq_policy_list);
48static DEFINE_PER_CPU(char[CPUFREQ_NAME_LEN], cpufreq_cpu_governor); 47static DEFINE_PER_CPU(char[CPUFREQ_NAME_LEN], cpufreq_cpu_governor);
49#endif 48#endif
50 49
51/* Flag to suspend/resume CPUFreq governors */
52static bool cpufreq_suspended;
53
54static inline bool has_target(void) 50static inline bool has_target(void)
55{ 51{
56 return cpufreq_driver->target_index || cpufreq_driver->target; 52 return cpufreq_driver->target_index || cpufreq_driver->target;
@@ -1466,41 +1462,6 @@ static struct subsys_interface cpufreq_interface = {
1466 .remove_dev = cpufreq_remove_dev, 1462 .remove_dev = cpufreq_remove_dev,
1467}; 1463};
1468 1464
1469void cpufreq_suspend(void)
1470{
1471 struct cpufreq_policy *policy;
1472
1473 if (!has_target())
1474 return;
1475
1476 pr_debug("%s: Suspending Governors\n", __func__);
1477
1478 list_for_each_entry(policy, &cpufreq_policy_list, policy_list)
1479 if (__cpufreq_governor(policy, CPUFREQ_GOV_STOP))
1480 pr_err("%s: Failed to stop governor for policy: %p\n",
1481 __func__, policy);
1482
1483 cpufreq_suspended = true;
1484}
1485
1486void cpufreq_resume(void)
1487{
1488 struct cpufreq_policy *policy;
1489
1490 if (!has_target())
1491 return;
1492
1493 pr_debug("%s: Resuming Governors\n", __func__);
1494
1495 cpufreq_suspended = false;
1496
1497 list_for_each_entry(policy, &cpufreq_policy_list, policy_list)
1498 if (__cpufreq_governor(policy, CPUFREQ_GOV_START)
1499 || __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS))
1500 pr_err("%s: Failed to start governor for policy: %p\n",
1501 __func__, policy);
1502}
1503
1504/** 1465/**
1505 * cpufreq_bp_suspend - Prepare the boot CPU for system suspend. 1466 * cpufreq_bp_suspend - Prepare the boot CPU for system suspend.
1506 * 1467 *
@@ -1803,10 +1764,6 @@ static int __cpufreq_governor(struct cpufreq_policy *policy,
1803 struct cpufreq_governor *gov = NULL; 1764 struct cpufreq_governor *gov = NULL;
1804#endif 1765#endif
1805 1766
1806 /* Don't start any governor operations if we are entering suspend */
1807 if (cpufreq_suspended)
1808 return 0;
1809
1810 if (policy->governor->max_transition_latency && 1767 if (policy->governor->max_transition_latency &&
1811 policy->cpuinfo.transition_latency > 1768 policy->cpuinfo.transition_latency >
1812 policy->governor->max_transition_latency) { 1769 policy->governor->max_transition_latency) {
@@ -2119,6 +2076,9 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb,
2119 dev = get_cpu_device(cpu); 2076 dev = get_cpu_device(cpu);
2120 if (dev) { 2077 if (dev) {
2121 2078
2079 if (action & CPU_TASKS_FROZEN)
2080 frozen = true;
2081
2122 switch (action & ~CPU_TASKS_FROZEN) { 2082 switch (action & ~CPU_TASKS_FROZEN) {
2123 case CPU_ONLINE: 2083 case CPU_ONLINE:
2124 __cpufreq_add_dev(dev, NULL, frozen); 2084 __cpufreq_add_dev(dev, NULL, frozen);
diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c
index 16a2aa28f856..ec4ee5c1fe9d 100644
--- a/drivers/dma/amba-pl08x.c
+++ b/drivers/dma/amba-pl08x.c
@@ -1169,7 +1169,7 @@ static void pl08x_desc_free(struct virt_dma_desc *vd)
1169 struct pl08x_txd *txd = to_pl08x_txd(&vd->tx); 1169 struct pl08x_txd *txd = to_pl08x_txd(&vd->tx);
1170 struct pl08x_dma_chan *plchan = to_pl08x_chan(vd->tx.chan); 1170 struct pl08x_dma_chan *plchan = to_pl08x_chan(vd->tx.chan);
1171 1171
1172 dma_descriptor_unmap(txd); 1172 dma_descriptor_unmap(&vd->tx);
1173 if (!txd->done) 1173 if (!txd->done)
1174 pl08x_release_mux(plchan); 1174 pl08x_release_mux(plchan);
1175 1175
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index ea806bdc12ef..24095ff8a93b 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -535,11 +535,41 @@ struct dma_chan *dma_get_slave_channel(struct dma_chan *chan)
535} 535}
536EXPORT_SYMBOL_GPL(dma_get_slave_channel); 536EXPORT_SYMBOL_GPL(dma_get_slave_channel);
537 537
538struct dma_chan *dma_get_any_slave_channel(struct dma_device *device)
539{
540 dma_cap_mask_t mask;
541 struct dma_chan *chan;
542 int err;
543
544 dma_cap_zero(mask);
545 dma_cap_set(DMA_SLAVE, mask);
546
547 /* lock against __dma_request_channel */
548 mutex_lock(&dma_list_mutex);
549
550 chan = private_candidate(&mask, device, NULL, NULL);
551 if (chan) {
552 err = dma_chan_get(chan);
553 if (err) {
554 pr_debug("%s: failed to get %s: (%d)\n",
555 __func__, dma_chan_name(chan), err);
556 chan = NULL;
557 }
558 }
559
560 mutex_unlock(&dma_list_mutex);
561
562 return chan;
563}
564EXPORT_SYMBOL_GPL(dma_get_any_slave_channel);
565
538/** 566/**
539 * __dma_request_channel - try to allocate an exclusive channel 567 * __dma_request_channel - try to allocate an exclusive channel
540 * @mask: capabilities that the channel must satisfy 568 * @mask: capabilities that the channel must satisfy
541 * @fn: optional callback to disposition available channels 569 * @fn: optional callback to disposition available channels
542 * @fn_param: opaque parameter to pass to dma_filter_fn 570 * @fn_param: opaque parameter to pass to dma_filter_fn
571 *
572 * Returns pointer to appropriate DMA channel on success or NULL.
543 */ 573 */
544struct dma_chan *__dma_request_channel(const dma_cap_mask_t *mask, 574struct dma_chan *__dma_request_channel(const dma_cap_mask_t *mask,
545 dma_filter_fn fn, void *fn_param) 575 dma_filter_fn fn, void *fn_param)
@@ -591,18 +621,43 @@ EXPORT_SYMBOL_GPL(__dma_request_channel);
591 * dma_request_slave_channel - try to allocate an exclusive slave channel 621 * dma_request_slave_channel - try to allocate an exclusive slave channel
592 * @dev: pointer to client device structure 622 * @dev: pointer to client device structure
593 * @name: slave channel name 623 * @name: slave channel name
624 *
625 * Returns pointer to appropriate DMA channel on success or an error pointer.
594 */ 626 */
595struct dma_chan *dma_request_slave_channel(struct device *dev, const char *name) 627struct dma_chan *dma_request_slave_channel_reason(struct device *dev,
628 const char *name)
596{ 629{
630 struct dma_chan *chan;
631
597 /* If device-tree is present get slave info from here */ 632 /* If device-tree is present get slave info from here */
598 if (dev->of_node) 633 if (dev->of_node)
599 return of_dma_request_slave_channel(dev->of_node, name); 634 return of_dma_request_slave_channel(dev->of_node, name);
600 635
601 /* If device was enumerated by ACPI get slave info from here */ 636 /* If device was enumerated by ACPI get slave info from here */
602 if (ACPI_HANDLE(dev)) 637 if (ACPI_HANDLE(dev)) {
603 return acpi_dma_request_slave_chan_by_name(dev, name); 638 chan = acpi_dma_request_slave_chan_by_name(dev, name);
639 if (chan)
640 return chan;
641 }
604 642
605 return NULL; 643 return ERR_PTR(-ENODEV);
644}
645EXPORT_SYMBOL_GPL(dma_request_slave_channel_reason);
646
647/**
648 * dma_request_slave_channel - try to allocate an exclusive slave channel
649 * @dev: pointer to client device structure
650 * @name: slave channel name
651 *
652 * Returns pointer to appropriate DMA channel on success or NULL.
653 */
654struct dma_chan *dma_request_slave_channel(struct device *dev,
655 const char *name)
656{
657 struct dma_chan *ch = dma_request_slave_channel_reason(dev, name);
658 if (IS_ERR(ch))
659 return NULL;
660 return ch;
606} 661}
607EXPORT_SYMBOL_GPL(dma_request_slave_channel); 662EXPORT_SYMBOL_GPL(dma_request_slave_channel);
608 663
diff --git a/drivers/dma/mmp_pdma.c b/drivers/dma/mmp_pdma.c
index dcb1e05149a7..c6a01ea8bc59 100644
--- a/drivers/dma/mmp_pdma.c
+++ b/drivers/dma/mmp_pdma.c
@@ -893,33 +893,17 @@ static struct dma_chan *mmp_pdma_dma_xlate(struct of_phandle_args *dma_spec,
893 struct of_dma *ofdma) 893 struct of_dma *ofdma)
894{ 894{
895 struct mmp_pdma_device *d = ofdma->of_dma_data; 895 struct mmp_pdma_device *d = ofdma->of_dma_data;
896 struct dma_chan *chan, *candidate; 896 struct dma_chan *chan;
897 struct mmp_pdma_chan *c;
897 898
898retry: 899 chan = dma_get_any_slave_channel(&d->device);
899 candidate = NULL; 900 if (!chan)
900
901 /* walk the list of channels registered with the current instance and
902 * find one that is currently unused */
903 list_for_each_entry(chan, &d->device.channels, device_node)
904 if (chan->client_count == 0) {
905 candidate = chan;
906 break;
907 }
908
909 if (!candidate)
910 return NULL; 901 return NULL;
911 902
912 /* dma_get_slave_channel will return NULL if we lost a race between 903 c = to_mmp_pdma_chan(chan);
913 * the lookup and the reservation */ 904 c->drcmr = dma_spec->args[0];
914 chan = dma_get_slave_channel(candidate);
915
916 if (chan) {
917 struct mmp_pdma_chan *c = to_mmp_pdma_chan(chan);
918 c->drcmr = dma_spec->args[0];
919 return chan;
920 }
921 905
922 goto retry; 906 return chan;
923} 907}
924 908
925static int mmp_pdma_probe(struct platform_device *op) 909static int mmp_pdma_probe(struct platform_device *op)
@@ -1017,6 +1001,7 @@ static int mmp_pdma_probe(struct platform_device *op)
1017 } 1001 }
1018 } 1002 }
1019 1003
1004 platform_set_drvdata(op, pdev);
1020 dev_info(pdev->device.dev, "initialized %d channels\n", dma_channels); 1005 dev_info(pdev->device.dev, "initialized %d channels\n", dma_channels);
1021 return 0; 1006 return 0;
1022} 1007}
diff --git a/drivers/dma/of-dma.c b/drivers/dma/of-dma.c
index 0b88dd3d05f4..e8fe9dc455f4 100644
--- a/drivers/dma/of-dma.c
+++ b/drivers/dma/of-dma.c
@@ -143,7 +143,7 @@ static int of_dma_match_channel(struct device_node *np, const char *name,
143 * @np: device node to get DMA request from 143 * @np: device node to get DMA request from
144 * @name: name of desired channel 144 * @name: name of desired channel
145 * 145 *
146 * Returns pointer to appropriate dma channel on success or NULL on error. 146 * Returns pointer to appropriate DMA channel on success or an error pointer.
147 */ 147 */
148struct dma_chan *of_dma_request_slave_channel(struct device_node *np, 148struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
149 const char *name) 149 const char *name)
@@ -152,17 +152,18 @@ struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
152 struct of_dma *ofdma; 152 struct of_dma *ofdma;
153 struct dma_chan *chan; 153 struct dma_chan *chan;
154 int count, i; 154 int count, i;
155 int ret_no_channel = -ENODEV;
155 156
156 if (!np || !name) { 157 if (!np || !name) {
157 pr_err("%s: not enough information provided\n", __func__); 158 pr_err("%s: not enough information provided\n", __func__);
158 return NULL; 159 return ERR_PTR(-ENODEV);
159 } 160 }
160 161
161 count = of_property_count_strings(np, "dma-names"); 162 count = of_property_count_strings(np, "dma-names");
162 if (count < 0) { 163 if (count < 0) {
163 pr_err("%s: dma-names property of node '%s' missing or empty\n", 164 pr_err("%s: dma-names property of node '%s' missing or empty\n",
164 __func__, np->full_name); 165 __func__, np->full_name);
165 return NULL; 166 return ERR_PTR(-ENODEV);
166 } 167 }
167 168
168 for (i = 0; i < count; i++) { 169 for (i = 0; i < count; i++) {
@@ -172,10 +173,12 @@ struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
172 mutex_lock(&of_dma_lock); 173 mutex_lock(&of_dma_lock);
173 ofdma = of_dma_find_controller(&dma_spec); 174 ofdma = of_dma_find_controller(&dma_spec);
174 175
175 if (ofdma) 176 if (ofdma) {
176 chan = ofdma->of_dma_xlate(&dma_spec, ofdma); 177 chan = ofdma->of_dma_xlate(&dma_spec, ofdma);
177 else 178 } else {
179 ret_no_channel = -EPROBE_DEFER;
178 chan = NULL; 180 chan = NULL;
181 }
179 182
180 mutex_unlock(&of_dma_lock); 183 mutex_unlock(&of_dma_lock);
181 184
@@ -185,7 +188,7 @@ struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
185 return chan; 188 return chan;
186 } 189 }
187 190
188 return NULL; 191 return ERR_PTR(ret_no_channel);
189} 192}
190 193
191/** 194/**
diff --git a/drivers/dma/s3c24xx-dma.c b/drivers/dma/s3c24xx-dma.c
index 4cb127978636..4eddedb6eb7d 100644
--- a/drivers/dma/s3c24xx-dma.c
+++ b/drivers/dma/s3c24xx-dma.c
@@ -628,42 +628,13 @@ retry:
628 s3cchan->state = S3C24XX_DMA_CHAN_IDLE; 628 s3cchan->state = S3C24XX_DMA_CHAN_IDLE;
629} 629}
630 630
631static void s3c24xx_dma_unmap_buffers(struct s3c24xx_txd *txd)
632{
633 struct device *dev = txd->vd.tx.chan->device->dev;
634 struct s3c24xx_sg *dsg;
635
636 if (!(txd->vd.tx.flags & DMA_COMPL_SKIP_SRC_UNMAP)) {
637 if (txd->vd.tx.flags & DMA_COMPL_SRC_UNMAP_SINGLE)
638 list_for_each_entry(dsg, &txd->dsg_list, node)
639 dma_unmap_single(dev, dsg->src_addr, dsg->len,
640 DMA_TO_DEVICE);
641 else {
642 list_for_each_entry(dsg, &txd->dsg_list, node)
643 dma_unmap_page(dev, dsg->src_addr, dsg->len,
644 DMA_TO_DEVICE);
645 }
646 }
647
648 if (!(txd->vd.tx.flags & DMA_COMPL_SKIP_DEST_UNMAP)) {
649 if (txd->vd.tx.flags & DMA_COMPL_DEST_UNMAP_SINGLE)
650 list_for_each_entry(dsg, &txd->dsg_list, node)
651 dma_unmap_single(dev, dsg->dst_addr, dsg->len,
652 DMA_FROM_DEVICE);
653 else
654 list_for_each_entry(dsg, &txd->dsg_list, node)
655 dma_unmap_page(dev, dsg->dst_addr, dsg->len,
656 DMA_FROM_DEVICE);
657 }
658}
659
660static void s3c24xx_dma_desc_free(struct virt_dma_desc *vd) 631static void s3c24xx_dma_desc_free(struct virt_dma_desc *vd)
661{ 632{
662 struct s3c24xx_txd *txd = to_s3c24xx_txd(&vd->tx); 633 struct s3c24xx_txd *txd = to_s3c24xx_txd(&vd->tx);
663 struct s3c24xx_dma_chan *s3cchan = to_s3c24xx_dma_chan(vd->tx.chan); 634 struct s3c24xx_dma_chan *s3cchan = to_s3c24xx_dma_chan(vd->tx.chan);
664 635
665 if (!s3cchan->slave) 636 if (!s3cchan->slave)
666 s3c24xx_dma_unmap_buffers(txd); 637 dma_descriptor_unmap(&vd->tx);
667 638
668 s3c24xx_dma_free_txd(txd); 639 s3c24xx_dma_free_txd(txd);
669} 640}
@@ -795,7 +766,7 @@ static enum dma_status s3c24xx_dma_tx_status(struct dma_chan *chan,
795 766
796 spin_lock_irqsave(&s3cchan->vc.lock, flags); 767 spin_lock_irqsave(&s3cchan->vc.lock, flags);
797 ret = dma_cookie_status(chan, cookie, txstate); 768 ret = dma_cookie_status(chan, cookie, txstate);
798 if (ret == DMA_SUCCESS) { 769 if (ret == DMA_COMPLETE) {
799 spin_unlock_irqrestore(&s3cchan->vc.lock, flags); 770 spin_unlock_irqrestore(&s3cchan->vc.lock, flags);
800 return ret; 771 return ret;
801 } 772 }
diff --git a/drivers/dma/sh/rcar-hpbdma.c b/drivers/dma/sh/rcar-hpbdma.c
index ebad84591a6e..3083d901a414 100644
--- a/drivers/dma/sh/rcar-hpbdma.c
+++ b/drivers/dma/sh/rcar-hpbdma.c
@@ -60,6 +60,7 @@
60#define HPB_DMAE_DSTPR_DMSTP BIT(0) 60#define HPB_DMAE_DSTPR_DMSTP BIT(0)
61 61
62/* DMA status register (DSTSR) bits */ 62/* DMA status register (DSTSR) bits */
63#define HPB_DMAE_DSTSR_DQSTS BIT(2)
63#define HPB_DMAE_DSTSR_DMSTS BIT(0) 64#define HPB_DMAE_DSTSR_DMSTS BIT(0)
64 65
65/* DMA common registers */ 66/* DMA common registers */
@@ -286,6 +287,9 @@ static void hpb_dmae_halt(struct shdma_chan *schan)
286 287
287 ch_reg_write(chan, HPB_DMAE_DCMDR_DQEND, HPB_DMAE_DCMDR); 288 ch_reg_write(chan, HPB_DMAE_DCMDR_DQEND, HPB_DMAE_DCMDR);
288 ch_reg_write(chan, HPB_DMAE_DSTPR_DMSTP, HPB_DMAE_DSTPR); 289 ch_reg_write(chan, HPB_DMAE_DSTPR_DMSTP, HPB_DMAE_DSTPR);
290
291 chan->plane_idx = 0;
292 chan->first_desc = true;
289} 293}
290 294
291static const struct hpb_dmae_slave_config * 295static const struct hpb_dmae_slave_config *
@@ -385,7 +389,10 @@ static bool hpb_dmae_channel_busy(struct shdma_chan *schan)
385 struct hpb_dmae_chan *chan = to_chan(schan); 389 struct hpb_dmae_chan *chan = to_chan(schan);
386 u32 dstsr = ch_reg_read(chan, HPB_DMAE_DSTSR); 390 u32 dstsr = ch_reg_read(chan, HPB_DMAE_DSTSR);
387 391
388 return (dstsr & HPB_DMAE_DSTSR_DMSTS) == HPB_DMAE_DSTSR_DMSTS; 392 if (chan->xfer_mode == XFER_DOUBLE)
393 return dstsr & HPB_DMAE_DSTSR_DQSTS;
394 else
395 return dstsr & HPB_DMAE_DSTSR_DMSTS;
389} 396}
390 397
391static int 398static int
@@ -510,6 +517,8 @@ static int hpb_dmae_chan_probe(struct hpb_dmae_device *hpbdev, int id)
510 } 517 }
511 518
512 schan = &new_hpb_chan->shdma_chan; 519 schan = &new_hpb_chan->shdma_chan;
520 schan->max_xfer_len = HPB_DMA_TCR_MAX;
521
513 shdma_chan_probe(sdev, schan, id); 522 shdma_chan_probe(sdev, schan, id);
514 523
515 if (pdev->id >= 0) 524 if (pdev->id >= 0)
diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c
index 73654e33f13b..d11bb3620f27 100644
--- a/drivers/dma/tegra20-apb-dma.c
+++ b/drivers/dma/tegra20-apb-dma.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * DMA driver for Nvidia's Tegra20 APB DMA controller. 2 * DMA driver for Nvidia's Tegra20 APB DMA controller.
3 * 3 *
4 * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. 4 * Copyright (c) 2012-2013, NVIDIA CORPORATION. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License, 7 * under the terms and conditions of the GNU General Public License,
@@ -29,11 +29,12 @@
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/of.h> 30#include <linux/of.h>
31#include <linux/of_device.h> 31#include <linux/of_device.h>
32#include <linux/of_dma.h>
32#include <linux/platform_device.h> 33#include <linux/platform_device.h>
33#include <linux/pm.h> 34#include <linux/pm.h>
34#include <linux/pm_runtime.h> 35#include <linux/pm_runtime.h>
36#include <linux/reset.h>
35#include <linux/slab.h> 37#include <linux/slab.h>
36#include <linux/clk/tegra.h>
37 38
38#include "dmaengine.h" 39#include "dmaengine.h"
39 40
@@ -199,6 +200,7 @@ struct tegra_dma_channel {
199 void *callback_param; 200 void *callback_param;
200 201
201 /* Channel-slave specific configuration */ 202 /* Channel-slave specific configuration */
203 unsigned int slave_id;
202 struct dma_slave_config dma_sconfig; 204 struct dma_slave_config dma_sconfig;
203 struct tegra_dma_channel_regs channel_reg; 205 struct tegra_dma_channel_regs channel_reg;
204}; 206};
@@ -208,6 +210,7 @@ struct tegra_dma {
208 struct dma_device dma_dev; 210 struct dma_device dma_dev;
209 struct device *dev; 211 struct device *dev;
210 struct clk *dma_clk; 212 struct clk *dma_clk;
213 struct reset_control *rst;
211 spinlock_t global_lock; 214 spinlock_t global_lock;
212 void __iomem *base_addr; 215 void __iomem *base_addr;
213 const struct tegra_dma_chip_data *chip_data; 216 const struct tegra_dma_chip_data *chip_data;
@@ -339,6 +342,8 @@ static int tegra_dma_slave_config(struct dma_chan *dc,
339 } 342 }
340 343
341 memcpy(&tdc->dma_sconfig, sconfig, sizeof(*sconfig)); 344 memcpy(&tdc->dma_sconfig, sconfig, sizeof(*sconfig));
345 if (!tdc->slave_id)
346 tdc->slave_id = sconfig->slave_id;
342 tdc->config_init = true; 347 tdc->config_init = true;
343 return 0; 348 return 0;
344} 349}
@@ -941,7 +946,7 @@ static struct dma_async_tx_descriptor *tegra_dma_prep_slave_sg(
941 ahb_seq |= TEGRA_APBDMA_AHBSEQ_BUS_WIDTH_32; 946 ahb_seq |= TEGRA_APBDMA_AHBSEQ_BUS_WIDTH_32;
942 947
943 csr |= TEGRA_APBDMA_CSR_ONCE | TEGRA_APBDMA_CSR_FLOW; 948 csr |= TEGRA_APBDMA_CSR_ONCE | TEGRA_APBDMA_CSR_FLOW;
944 csr |= tdc->dma_sconfig.slave_id << TEGRA_APBDMA_CSR_REQ_SEL_SHIFT; 949 csr |= tdc->slave_id << TEGRA_APBDMA_CSR_REQ_SEL_SHIFT;
945 if (flags & DMA_PREP_INTERRUPT) 950 if (flags & DMA_PREP_INTERRUPT)
946 csr |= TEGRA_APBDMA_CSR_IE_EOC; 951 csr |= TEGRA_APBDMA_CSR_IE_EOC;
947 952
@@ -1085,7 +1090,7 @@ static struct dma_async_tx_descriptor *tegra_dma_prep_dma_cyclic(
1085 csr |= TEGRA_APBDMA_CSR_FLOW; 1090 csr |= TEGRA_APBDMA_CSR_FLOW;
1086 if (flags & DMA_PREP_INTERRUPT) 1091 if (flags & DMA_PREP_INTERRUPT)
1087 csr |= TEGRA_APBDMA_CSR_IE_EOC; 1092 csr |= TEGRA_APBDMA_CSR_IE_EOC;
1088 csr |= tdc->dma_sconfig.slave_id << TEGRA_APBDMA_CSR_REQ_SEL_SHIFT; 1093 csr |= tdc->slave_id << TEGRA_APBDMA_CSR_REQ_SEL_SHIFT;
1089 1094
1090 apb_seq |= TEGRA_APBDMA_APBSEQ_WRAP_WORD_1; 1095 apb_seq |= TEGRA_APBDMA_APBSEQ_WRAP_WORD_1;
1091 1096
@@ -1205,6 +1210,25 @@ static void tegra_dma_free_chan_resources(struct dma_chan *dc)
1205 kfree(sg_req); 1210 kfree(sg_req);
1206 } 1211 }
1207 clk_disable_unprepare(tdma->dma_clk); 1212 clk_disable_unprepare(tdma->dma_clk);
1213
1214 tdc->slave_id = 0;
1215}
1216
1217static struct dma_chan *tegra_dma_of_xlate(struct of_phandle_args *dma_spec,
1218 struct of_dma *ofdma)
1219{
1220 struct tegra_dma *tdma = ofdma->of_dma_data;
1221 struct dma_chan *chan;
1222 struct tegra_dma_channel *tdc;
1223
1224 chan = dma_get_any_slave_channel(&tdma->dma_dev);
1225 if (!chan)
1226 return NULL;
1227
1228 tdc = to_tegra_dma_chan(chan);
1229 tdc->slave_id = dma_spec->args[0];
1230
1231 return chan;
1208} 1232}
1209 1233
1210/* Tegra20 specific DMA controller information */ 1234/* Tegra20 specific DMA controller information */
@@ -1282,6 +1306,12 @@ static int tegra_dma_probe(struct platform_device *pdev)
1282 return PTR_ERR(tdma->dma_clk); 1306 return PTR_ERR(tdma->dma_clk);
1283 } 1307 }
1284 1308
1309 tdma->rst = devm_reset_control_get(&pdev->dev, "dma");
1310 if (IS_ERR(tdma->rst)) {
1311 dev_err(&pdev->dev, "Error: Missing reset\n");
1312 return PTR_ERR(tdma->rst);
1313 }
1314
1285 spin_lock_init(&tdma->global_lock); 1315 spin_lock_init(&tdma->global_lock);
1286 1316
1287 pm_runtime_enable(&pdev->dev); 1317 pm_runtime_enable(&pdev->dev);
@@ -1302,9 +1332,9 @@ static int tegra_dma_probe(struct platform_device *pdev)
1302 } 1332 }
1303 1333
1304 /* Reset DMA controller */ 1334 /* Reset DMA controller */
1305 tegra_periph_reset_assert(tdma->dma_clk); 1335 reset_control_assert(tdma->rst);
1306 udelay(2); 1336 udelay(2);
1307 tegra_periph_reset_deassert(tdma->dma_clk); 1337 reset_control_deassert(tdma->rst);
1308 1338
1309 /* Enable global DMA registers */ 1339 /* Enable global DMA registers */
1310 tdma_write(tdma, TEGRA_APBDMA_GENERAL, TEGRA_APBDMA_GENERAL_ENABLE); 1340 tdma_write(tdma, TEGRA_APBDMA_GENERAL, TEGRA_APBDMA_GENERAL_ENABLE);
@@ -1376,10 +1406,20 @@ static int tegra_dma_probe(struct platform_device *pdev)
1376 goto err_irq; 1406 goto err_irq;
1377 } 1407 }
1378 1408
1409 ret = of_dma_controller_register(pdev->dev.of_node,
1410 tegra_dma_of_xlate, tdma);
1411 if (ret < 0) {
1412 dev_err(&pdev->dev,
1413 "Tegra20 APB DMA OF registration failed %d\n", ret);
1414 goto err_unregister_dma_dev;
1415 }
1416
1379 dev_info(&pdev->dev, "Tegra20 APB DMA driver register %d channels\n", 1417 dev_info(&pdev->dev, "Tegra20 APB DMA driver register %d channels\n",
1380 cdata->nr_channels); 1418 cdata->nr_channels);
1381 return 0; 1419 return 0;
1382 1420
1421err_unregister_dma_dev:
1422 dma_async_device_unregister(&tdma->dma_dev);
1383err_irq: 1423err_irq:
1384 while (--i >= 0) { 1424 while (--i >= 0) {
1385 struct tegra_dma_channel *tdc = &tdma->channels[i]; 1425 struct tegra_dma_channel *tdc = &tdma->channels[i];
diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
index 8472405c5586..d7f1b57bd3be 100644
--- a/drivers/edac/sb_edac.c
+++ b/drivers/edac/sb_edac.c
@@ -945,7 +945,7 @@ static int get_memory_error_data(struct mem_ctl_info *mci,
945 u32 tad_offset; 945 u32 tad_offset;
946 u32 rir_way; 946 u32 rir_way;
947 u32 mb, kb; 947 u32 mb, kb;
948 u64 ch_addr, offset, limit, prv = 0; 948 u64 ch_addr, offset, limit = 0, prv = 0;
949 949
950 950
951 /* 951 /*
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index 3c55ec856e39..a287cece0593 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -1082,7 +1082,7 @@ static void arizona_micd_set_level(struct arizona *arizona, int index,
1082static int arizona_extcon_probe(struct platform_device *pdev) 1082static int arizona_extcon_probe(struct platform_device *pdev)
1083{ 1083{
1084 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); 1084 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
1085 struct arizona_pdata *pdata; 1085 struct arizona_pdata *pdata = &arizona->pdata;
1086 struct arizona_extcon_info *info; 1086 struct arizona_extcon_info *info;
1087 unsigned int val; 1087 unsigned int val;
1088 int jack_irq_fall, jack_irq_rise; 1088 int jack_irq_fall, jack_irq_rise;
@@ -1091,8 +1091,6 @@ static int arizona_extcon_probe(struct platform_device *pdev)
1091 if (!arizona->dapm || !arizona->dapm->card) 1091 if (!arizona->dapm || !arizona->dapm->card)
1092 return -EPROBE_DEFER; 1092 return -EPROBE_DEFER;
1093 1093
1094 pdata = dev_get_platdata(arizona->dev);
1095
1096 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); 1094 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
1097 if (!info) { 1095 if (!info) {
1098 dev_err(&pdev->dev, "Failed to allocate memory\n"); 1096 dev_err(&pdev->dev, "Failed to allocate memory\n");
diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c
index 15443d3b6be1..76322330cbd7 100644
--- a/drivers/extcon/extcon-class.c
+++ b/drivers/extcon/extcon-class.c
@@ -792,6 +792,8 @@ void extcon_dev_unregister(struct extcon_dev *edev)
792 return; 792 return;
793 } 793 }
794 794
795 device_unregister(&edev->dev);
796
795 if (edev->mutually_exclusive && edev->max_supported) { 797 if (edev->mutually_exclusive && edev->max_supported) {
796 for (index = 0; edev->mutually_exclusive[index]; 798 for (index = 0; edev->mutually_exclusive[index];
797 index++) 799 index++)
@@ -812,7 +814,6 @@ void extcon_dev_unregister(struct extcon_dev *edev)
812 if (switch_class) 814 if (switch_class)
813 class_compat_remove_link(switch_class, &edev->dev, NULL); 815 class_compat_remove_link(switch_class, &edev->dev, NULL);
814#endif 816#endif
815 device_unregister(&edev->dev);
816 put_device(&edev->dev); 817 put_device(&edev->dev);
817} 818}
818EXPORT_SYMBOL_GPL(extcon_dev_unregister); 819EXPORT_SYMBOL_GPL(extcon_dev_unregister);
diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c
index 8847adf392b7..84be70157ad6 100644
--- a/drivers/gpio/gpio-davinci.c
+++ b/drivers/gpio/gpio-davinci.c
@@ -327,7 +327,7 @@ static int gpio_to_irq_unbanked(struct gpio_chip *chip, unsigned offset)
327 * NOTE: we assume for now that only irqs in the first gpio_chip 327 * NOTE: we assume for now that only irqs in the first gpio_chip
328 * can provide direct-mapped IRQs to AINTC (up to 32 GPIOs). 328 * can provide direct-mapped IRQs to AINTC (up to 32 GPIOs).
329 */ 329 */
330 if (offset < d->irq_base) 330 if (offset < d->gpio_unbanked)
331 return d->gpio_irq + offset; 331 return d->gpio_irq + offset;
332 else 332 else
333 return -ENODEV; 333 return -ENODEV;
@@ -419,6 +419,8 @@ static int davinci_gpio_irq_setup(struct platform_device *pdev)
419 419
420 /* pass "bank 0" GPIO IRQs to AINTC */ 420 /* pass "bank 0" GPIO IRQs to AINTC */
421 chips[0].chip.to_irq = gpio_to_irq_unbanked; 421 chips[0].chip.to_irq = gpio_to_irq_unbanked;
422 chips[0].gpio_irq = bank_irq;
423 chips[0].gpio_unbanked = pdata->gpio_unbanked;
422 binten = BIT(0); 424 binten = BIT(0);
423 425
424 /* AINTC handles mask/unmask; GPIO handles triggering */ 426 /* AINTC handles mask/unmask; GPIO handles triggering */
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index fb7cf0e796f6..0a1e4a5f4234 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -2674,7 +2674,7 @@ static int add_3d_struct_modes(struct drm_connector *connector, u16 structure,
2674 int modes = 0; 2674 int modes = 0;
2675 u8 cea_mode; 2675 u8 cea_mode;
2676 2676
2677 if (video_db == NULL || video_index > video_len) 2677 if (video_db == NULL || video_index >= video_len)
2678 return 0; 2678 return 0;
2679 2679
2680 /* CEA modes are numbered 1..127 */ 2680 /* CEA modes are numbered 1..127 */
@@ -2701,7 +2701,7 @@ static int add_3d_struct_modes(struct drm_connector *connector, u16 structure,
2701 if (structure & (1 << 8)) { 2701 if (structure & (1 << 8)) {
2702 newmode = drm_mode_duplicate(dev, &edid_cea_modes[cea_mode]); 2702 newmode = drm_mode_duplicate(dev, &edid_cea_modes[cea_mode]);
2703 if (newmode) { 2703 if (newmode) {
2704 newmode->flags = DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF; 2704 newmode->flags |= DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF;
2705 drm_mode_probed_add(connector, newmode); 2705 drm_mode_probed_add(connector, newmode);
2706 modes++; 2706 modes++;
2707 } 2707 }
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index b676006a95a0..22b8f5eced80 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -173,28 +173,37 @@ static int exynos_drm_open(struct drm_device *dev, struct drm_file *file)
173static void exynos_drm_preclose(struct drm_device *dev, 173static void exynos_drm_preclose(struct drm_device *dev,
174 struct drm_file *file) 174 struct drm_file *file)
175{ 175{
176 exynos_drm_subdrv_close(dev, file);
177}
178
179static void exynos_drm_postclose(struct drm_device *dev, struct drm_file *file)
180{
176 struct exynos_drm_private *private = dev->dev_private; 181 struct exynos_drm_private *private = dev->dev_private;
177 struct drm_pending_vblank_event *e, *t; 182 struct drm_pending_vblank_event *v, *vt;
183 struct drm_pending_event *e, *et;
178 unsigned long flags; 184 unsigned long flags;
179 185
180 /* release events of current file */ 186 if (!file->driver_priv)
187 return;
188
189 /* Release all events not unhandled by page flip handler. */
181 spin_lock_irqsave(&dev->event_lock, flags); 190 spin_lock_irqsave(&dev->event_lock, flags);
182 list_for_each_entry_safe(e, t, &private->pageflip_event_list, 191 list_for_each_entry_safe(v, vt, &private->pageflip_event_list,
183 base.link) { 192 base.link) {
184 if (e->base.file_priv == file) { 193 if (v->base.file_priv == file) {
185 list_del(&e->base.link); 194 list_del(&v->base.link);
186 e->base.destroy(&e->base); 195 drm_vblank_put(dev, v->pipe);
196 v->base.destroy(&v->base);
187 } 197 }
188 } 198 }
189 spin_unlock_irqrestore(&dev->event_lock, flags);
190 199
191 exynos_drm_subdrv_close(dev, file); 200 /* Release all events handled by page flip handler but not freed. */
192} 201 list_for_each_entry_safe(e, et, &file->event_list, link) {
202 list_del(&e->link);
203 e->destroy(e);
204 }
205 spin_unlock_irqrestore(&dev->event_lock, flags);
193 206
194static void exynos_drm_postclose(struct drm_device *dev, struct drm_file *file)
195{
196 if (!file->driver_priv)
197 return;
198 207
199 kfree(file->driver_priv); 208 kfree(file->driver_priv);
200 file->driver_priv = NULL; 209 file->driver_priv = NULL;
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index 23da72b5eae9..a61878bf5dcd 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -31,7 +31,7 @@
31#include "exynos_drm_iommu.h" 31#include "exynos_drm_iommu.h"
32 32
33/* 33/*
34 * FIMD is stand for Fully Interactive Mobile Display and 34 * FIMD stands for Fully Interactive Mobile Display and
35 * as a display controller, it transfers contents drawn on memory 35 * as a display controller, it transfers contents drawn on memory
36 * to a LCD Panel through Display Interfaces such as RGB or 36 * to a LCD Panel through Display Interfaces such as RGB or
37 * CPU Interface. 37 * CPU Interface.
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 989be12cdd6e..2e367a1c6a64 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -534,8 +534,10 @@ static int i915_drm_freeze(struct drm_device *dev)
534 * Disable CRTCs directly since we want to preserve sw state 534 * Disable CRTCs directly since we want to preserve sw state
535 * for _thaw. 535 * for _thaw.
536 */ 536 */
537 mutex_lock(&dev->mode_config.mutex);
537 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) 538 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
538 dev_priv->display.crtc_disable(crtc); 539 dev_priv->display.crtc_disable(crtc);
540 mutex_unlock(&dev->mode_config.mutex);
539 541
540 intel_modeset_suspend_hw(dev); 542 intel_modeset_suspend_hw(dev);
541 } 543 }
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 12bbd5eac70d..621c7c67a643 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -4442,10 +4442,9 @@ i915_gem_init_hw(struct drm_device *dev)
4442 if (dev_priv->ellc_size) 4442 if (dev_priv->ellc_size)
4443 I915_WRITE(HSW_IDICR, I915_READ(HSW_IDICR) | IDIHASHMSK(0xf)); 4443 I915_WRITE(HSW_IDICR, I915_READ(HSW_IDICR) | IDIHASHMSK(0xf));
4444 4444
4445 if (IS_HSW_GT3(dev)) 4445 if (IS_HASWELL(dev))
4446 I915_WRITE(MI_PREDICATE_RESULT_2, LOWER_SLICE_ENABLED); 4446 I915_WRITE(MI_PREDICATE_RESULT_2, IS_HSW_GT3(dev) ?
4447 else 4447 LOWER_SLICE_ENABLED : LOWER_SLICE_DISABLED);
4448 I915_WRITE(MI_PREDICATE_RESULT_2, LOWER_SLICE_DISABLED);
4449 4448
4450 if (HAS_PCH_NOP(dev)) { 4449 if (HAS_PCH_NOP(dev)) {
4451 u32 temp = I915_READ(GEN7_MSG_CTL); 4450 u32 temp = I915_READ(GEN7_MSG_CTL);
diff --git a/drivers/gpu/drm/i915/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/i915_gem_dmabuf.c
index 7d5752fda5f1..9bb533e0d762 100644
--- a/drivers/gpu/drm/i915/i915_gem_dmabuf.c
+++ b/drivers/gpu/drm/i915/i915_gem_dmabuf.c
@@ -125,13 +125,15 @@ static void *i915_gem_dmabuf_vmap(struct dma_buf *dma_buf)
125 125
126 ret = i915_gem_object_get_pages(obj); 126 ret = i915_gem_object_get_pages(obj);
127 if (ret) 127 if (ret)
128 goto error; 128 goto err;
129
130 i915_gem_object_pin_pages(obj);
129 131
130 ret = -ENOMEM; 132 ret = -ENOMEM;
131 133
132 pages = drm_malloc_ab(obj->base.size >> PAGE_SHIFT, sizeof(*pages)); 134 pages = drm_malloc_ab(obj->base.size >> PAGE_SHIFT, sizeof(*pages));
133 if (pages == NULL) 135 if (pages == NULL)
134 goto error; 136 goto err_unpin;
135 137
136 i = 0; 138 i = 0;
137 for_each_sg_page(obj->pages->sgl, &sg_iter, obj->pages->nents, 0) 139 for_each_sg_page(obj->pages->sgl, &sg_iter, obj->pages->nents, 0)
@@ -141,15 +143,16 @@ static void *i915_gem_dmabuf_vmap(struct dma_buf *dma_buf)
141 drm_free_large(pages); 143 drm_free_large(pages);
142 144
143 if (!obj->dma_buf_vmapping) 145 if (!obj->dma_buf_vmapping)
144 goto error; 146 goto err_unpin;
145 147
146 obj->vmapping_count = 1; 148 obj->vmapping_count = 1;
147 i915_gem_object_pin_pages(obj);
148out_unlock: 149out_unlock:
149 mutex_unlock(&dev->struct_mutex); 150 mutex_unlock(&dev->struct_mutex);
150 return obj->dma_buf_vmapping; 151 return obj->dma_buf_vmapping;
151 152
152error: 153err_unpin:
154 i915_gem_object_unpin_pages(obj);
155err:
153 mutex_unlock(&dev->struct_mutex); 156 mutex_unlock(&dev->struct_mutex);
154 return ERR_PTR(ret); 157 return ERR_PTR(ret);
155} 158}
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index 885d595e0e02..b7e787fb4649 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -33,6 +33,9 @@
33#include "intel_drv.h" 33#include "intel_drv.h"
34#include <linux/dma_remapping.h> 34#include <linux/dma_remapping.h>
35 35
36#define __EXEC_OBJECT_HAS_PIN (1<<31)
37#define __EXEC_OBJECT_HAS_FENCE (1<<30)
38
36struct eb_vmas { 39struct eb_vmas {
37 struct list_head vmas; 40 struct list_head vmas;
38 int and; 41 int and;
@@ -187,7 +190,28 @@ static struct i915_vma *eb_get_vma(struct eb_vmas *eb, unsigned long handle)
187 } 190 }
188} 191}
189 192
190static void eb_destroy(struct eb_vmas *eb) { 193static void
194i915_gem_execbuffer_unreserve_vma(struct i915_vma *vma)
195{
196 struct drm_i915_gem_exec_object2 *entry;
197 struct drm_i915_gem_object *obj = vma->obj;
198
199 if (!drm_mm_node_allocated(&vma->node))
200 return;
201
202 entry = vma->exec_entry;
203
204 if (entry->flags & __EXEC_OBJECT_HAS_FENCE)
205 i915_gem_object_unpin_fence(obj);
206
207 if (entry->flags & __EXEC_OBJECT_HAS_PIN)
208 i915_gem_object_unpin(obj);
209
210 entry->flags &= ~(__EXEC_OBJECT_HAS_FENCE | __EXEC_OBJECT_HAS_PIN);
211}
212
213static void eb_destroy(struct eb_vmas *eb)
214{
191 while (!list_empty(&eb->vmas)) { 215 while (!list_empty(&eb->vmas)) {
192 struct i915_vma *vma; 216 struct i915_vma *vma;
193 217
@@ -195,6 +219,7 @@ static void eb_destroy(struct eb_vmas *eb) {
195 struct i915_vma, 219 struct i915_vma,
196 exec_list); 220 exec_list);
197 list_del_init(&vma->exec_list); 221 list_del_init(&vma->exec_list);
222 i915_gem_execbuffer_unreserve_vma(vma);
198 drm_gem_object_unreference(&vma->obj->base); 223 drm_gem_object_unreference(&vma->obj->base);
199 } 224 }
200 kfree(eb); 225 kfree(eb);
@@ -478,9 +503,6 @@ i915_gem_execbuffer_relocate(struct eb_vmas *eb,
478 return ret; 503 return ret;
479} 504}
480 505
481#define __EXEC_OBJECT_HAS_PIN (1<<31)
482#define __EXEC_OBJECT_HAS_FENCE (1<<30)
483
484static int 506static int
485need_reloc_mappable(struct i915_vma *vma) 507need_reloc_mappable(struct i915_vma *vma)
486{ 508{
@@ -552,26 +574,6 @@ i915_gem_execbuffer_reserve_vma(struct i915_vma *vma,
552 return 0; 574 return 0;
553} 575}
554 576
555static void
556i915_gem_execbuffer_unreserve_vma(struct i915_vma *vma)
557{
558 struct drm_i915_gem_exec_object2 *entry;
559 struct drm_i915_gem_object *obj = vma->obj;
560
561 if (!drm_mm_node_allocated(&vma->node))
562 return;
563
564 entry = vma->exec_entry;
565
566 if (entry->flags & __EXEC_OBJECT_HAS_FENCE)
567 i915_gem_object_unpin_fence(obj);
568
569 if (entry->flags & __EXEC_OBJECT_HAS_PIN)
570 i915_gem_object_unpin(obj);
571
572 entry->flags &= ~(__EXEC_OBJECT_HAS_FENCE | __EXEC_OBJECT_HAS_PIN);
573}
574
575static int 577static int
576i915_gem_execbuffer_reserve(struct intel_ring_buffer *ring, 578i915_gem_execbuffer_reserve(struct intel_ring_buffer *ring,
577 struct list_head *vmas, 579 struct list_head *vmas,
@@ -670,13 +672,14 @@ i915_gem_execbuffer_reserve(struct intel_ring_buffer *ring,
670 goto err; 672 goto err;
671 } 673 }
672 674
673err: /* Decrement pin count for bound objects */ 675err:
674 list_for_each_entry(vma, vmas, exec_list)
675 i915_gem_execbuffer_unreserve_vma(vma);
676
677 if (ret != -ENOSPC || retry++) 676 if (ret != -ENOSPC || retry++)
678 return ret; 677 return ret;
679 678
679 /* Decrement pin count for bound objects */
680 list_for_each_entry(vma, vmas, exec_list)
681 i915_gem_execbuffer_unreserve_vma(vma);
682
680 ret = i915_gem_evict_vm(vm, true); 683 ret = i915_gem_evict_vm(vm, true);
681 if (ret) 684 if (ret)
682 return ret; 685 return ret;
@@ -708,6 +711,7 @@ i915_gem_execbuffer_relocate_slow(struct drm_device *dev,
708 while (!list_empty(&eb->vmas)) { 711 while (!list_empty(&eb->vmas)) {
709 vma = list_first_entry(&eb->vmas, struct i915_vma, exec_list); 712 vma = list_first_entry(&eb->vmas, struct i915_vma, exec_list);
710 list_del_init(&vma->exec_list); 713 list_del_init(&vma->exec_list);
714 i915_gem_execbuffer_unreserve_vma(vma);
711 drm_gem_object_unreference(&vma->obj->base); 715 drm_gem_object_unreference(&vma->obj->base);
712 } 716 }
713 717
diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 3620a1b0a73c..38cb8d44a013 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -57,7 +57,9 @@ typedef gen8_gtt_pte_t gen8_ppgtt_pde_t;
57#define HSW_WB_LLC_AGE3 HSW_CACHEABILITY_CONTROL(0x2) 57#define HSW_WB_LLC_AGE3 HSW_CACHEABILITY_CONTROL(0x2)
58#define HSW_WB_LLC_AGE0 HSW_CACHEABILITY_CONTROL(0x3) 58#define HSW_WB_LLC_AGE0 HSW_CACHEABILITY_CONTROL(0x3)
59#define HSW_WB_ELLC_LLC_AGE0 HSW_CACHEABILITY_CONTROL(0xb) 59#define HSW_WB_ELLC_LLC_AGE0 HSW_CACHEABILITY_CONTROL(0xb)
60#define HSW_WB_ELLC_LLC_AGE3 HSW_CACHEABILITY_CONTROL(0x8)
60#define HSW_WT_ELLC_LLC_AGE0 HSW_CACHEABILITY_CONTROL(0x6) 61#define HSW_WT_ELLC_LLC_AGE0 HSW_CACHEABILITY_CONTROL(0x6)
62#define HSW_WT_ELLC_LLC_AGE3 HSW_CACHEABILITY_CONTROL(0x7)
61 63
62#define GEN8_PTES_PER_PAGE (PAGE_SIZE / sizeof(gen8_gtt_pte_t)) 64#define GEN8_PTES_PER_PAGE (PAGE_SIZE / sizeof(gen8_gtt_pte_t))
63#define GEN8_PDES_PER_PAGE (PAGE_SIZE / sizeof(gen8_ppgtt_pde_t)) 65#define GEN8_PDES_PER_PAGE (PAGE_SIZE / sizeof(gen8_ppgtt_pde_t))
@@ -185,10 +187,10 @@ static gen6_gtt_pte_t iris_pte_encode(dma_addr_t addr,
185 case I915_CACHE_NONE: 187 case I915_CACHE_NONE:
186 break; 188 break;
187 case I915_CACHE_WT: 189 case I915_CACHE_WT:
188 pte |= HSW_WT_ELLC_LLC_AGE0; 190 pte |= HSW_WT_ELLC_LLC_AGE3;
189 break; 191 break;
190 default: 192 default:
191 pte |= HSW_WB_ELLC_LLC_AGE0; 193 pte |= HSW_WB_ELLC_LLC_AGE3;
192 break; 194 break;
193 } 195 }
194 196
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index f9eafb6ed523..ee2742122a02 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -235,6 +235,7 @@
235 */ 235 */
236#define MI_LOAD_REGISTER_IMM(x) MI_INSTR(0x22, 2*x-1) 236#define MI_LOAD_REGISTER_IMM(x) MI_INSTR(0x22, 2*x-1)
237#define MI_STORE_REGISTER_MEM(x) MI_INSTR(0x24, 2*x-1) 237#define MI_STORE_REGISTER_MEM(x) MI_INSTR(0x24, 2*x-1)
238#define MI_SRM_LRM_GLOBAL_GTT (1<<22)
238#define MI_FLUSH_DW MI_INSTR(0x26, 1) /* for GEN6 */ 239#define MI_FLUSH_DW MI_INSTR(0x26, 1) /* for GEN6 */
239#define MI_FLUSH_DW_STORE_INDEX (1<<21) 240#define MI_FLUSH_DW_STORE_INDEX (1<<21)
240#define MI_INVALIDATE_TLB (1<<18) 241#define MI_INVALIDATE_TLB (1<<18)
diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index 330077bcd0bd..526c8ded16b0 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -173,7 +173,7 @@ static void intel_prepare_ddi_buffers(struct drm_device *dev, enum port port)
173 ddi_translations = ddi_translations_dp; 173 ddi_translations = ddi_translations_dp;
174 break; 174 break;
175 case PORT_D: 175 case PORT_D:
176 if (intel_dpd_is_edp(dev)) 176 if (intel_dp_is_edp(dev, PORT_D))
177 ddi_translations = ddi_translations_edp; 177 ddi_translations = ddi_translations_edp;
178 else 178 else
179 ddi_translations = ddi_translations_dp; 179 ddi_translations = ddi_translations_dp;
@@ -1158,9 +1158,10 @@ static void intel_ddi_post_disable(struct intel_encoder *intel_encoder)
1158 if (wait) 1158 if (wait)
1159 intel_wait_ddi_buf_idle(dev_priv, port); 1159 intel_wait_ddi_buf_idle(dev_priv, port);
1160 1160
1161 if (type == INTEL_OUTPUT_EDP) { 1161 if (type == INTEL_OUTPUT_DISPLAYPORT || type == INTEL_OUTPUT_EDP) {
1162 struct intel_dp *intel_dp = enc_to_intel_dp(encoder); 1162 struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
1163 ironlake_edp_panel_vdd_on(intel_dp); 1163 ironlake_edp_panel_vdd_on(intel_dp);
1164 intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);
1164 ironlake_edp_panel_off(intel_dp); 1165 ironlake_edp_panel_off(intel_dp);
1165 } 1166 }
1166 1167
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 7ec8b488bb1d..080f6fd4e839 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -5815,7 +5815,7 @@ static void intel_set_pipe_csc(struct drm_crtc *crtc)
5815 uint16_t postoff = 0; 5815 uint16_t postoff = 0;
5816 5816
5817 if (intel_crtc->config.limited_color_range) 5817 if (intel_crtc->config.limited_color_range)
5818 postoff = (16 * (1 << 13) / 255) & 0x1fff; 5818 postoff = (16 * (1 << 12) / 255) & 0x1fff;
5819 5819
5820 I915_WRITE(PIPE_CSC_POSTOFF_HI(pipe), postoff); 5820 I915_WRITE(PIPE_CSC_POSTOFF_HI(pipe), postoff);
5821 I915_WRITE(PIPE_CSC_POSTOFF_ME(pipe), postoff); 5821 I915_WRITE(PIPE_CSC_POSTOFF_ME(pipe), postoff);
@@ -6402,7 +6402,7 @@ static void hsw_restore_lcpll(struct drm_i915_private *dev_priv)
6402 6402
6403 /* Make sure we're not on PC8 state before disabling PC8, otherwise 6403 /* Make sure we're not on PC8 state before disabling PC8, otherwise
6404 * we'll hang the machine! */ 6404 * we'll hang the machine! */
6405 dev_priv->uncore.funcs.force_wake_get(dev_priv); 6405 gen6_gt_force_wake_get(dev_priv);
6406 6406
6407 if (val & LCPLL_POWER_DOWN_ALLOW) { 6407 if (val & LCPLL_POWER_DOWN_ALLOW) {
6408 val &= ~LCPLL_POWER_DOWN_ALLOW; 6408 val &= ~LCPLL_POWER_DOWN_ALLOW;
@@ -6436,7 +6436,7 @@ static void hsw_restore_lcpll(struct drm_i915_private *dev_priv)
6436 DRM_ERROR("Switching back to LCPLL failed\n"); 6436 DRM_ERROR("Switching back to LCPLL failed\n");
6437 } 6437 }
6438 6438
6439 dev_priv->uncore.funcs.force_wake_put(dev_priv); 6439 gen6_gt_force_wake_put(dev_priv);
6440} 6440}
6441 6441
6442void hsw_enable_pc8_work(struct work_struct *__work) 6442void hsw_enable_pc8_work(struct work_struct *__work)
@@ -8354,7 +8354,8 @@ static int intel_gen7_queue_flip(struct drm_device *dev,
8354 intel_ring_emit(ring, ~(DERRMR_PIPEA_PRI_FLIP_DONE | 8354 intel_ring_emit(ring, ~(DERRMR_PIPEA_PRI_FLIP_DONE |
8355 DERRMR_PIPEB_PRI_FLIP_DONE | 8355 DERRMR_PIPEB_PRI_FLIP_DONE |
8356 DERRMR_PIPEC_PRI_FLIP_DONE)); 8356 DERRMR_PIPEC_PRI_FLIP_DONE));
8357 intel_ring_emit(ring, MI_STORE_REGISTER_MEM(1)); 8357 intel_ring_emit(ring, MI_STORE_REGISTER_MEM(1) |
8358 MI_SRM_LRM_GLOBAL_GTT);
8358 intel_ring_emit(ring, DERRMR); 8359 intel_ring_emit(ring, DERRMR);
8359 intel_ring_emit(ring, ring->scratch.gtt_offset + 256); 8360 intel_ring_emit(ring, ring->scratch.gtt_offset + 256);
8360 } 8361 }
@@ -10049,7 +10050,7 @@ static void intel_setup_outputs(struct drm_device *dev)
10049 intel_ddi_init(dev, PORT_D); 10050 intel_ddi_init(dev, PORT_D);
10050 } else if (HAS_PCH_SPLIT(dev)) { 10051 } else if (HAS_PCH_SPLIT(dev)) {
10051 int found; 10052 int found;
10052 dpd_is_edp = intel_dpd_is_edp(dev); 10053 dpd_is_edp = intel_dp_is_edp(dev, PORT_D);
10053 10054
10054 if (has_edp_a(dev)) 10055 if (has_edp_a(dev))
10055 intel_dp_init(dev, DP_A, PORT_A); 10056 intel_dp_init(dev, DP_A, PORT_A);
@@ -10086,8 +10087,7 @@ static void intel_setup_outputs(struct drm_device *dev)
10086 intel_hdmi_init(dev, VLV_DISPLAY_BASE + GEN4_HDMIC, 10087 intel_hdmi_init(dev, VLV_DISPLAY_BASE + GEN4_HDMIC,
10087 PORT_C); 10088 PORT_C);
10088 if (I915_READ(VLV_DISPLAY_BASE + DP_C) & DP_DETECTED) 10089 if (I915_READ(VLV_DISPLAY_BASE + DP_C) & DP_DETECTED)
10089 intel_dp_init(dev, VLV_DISPLAY_BASE + DP_C, 10090 intel_dp_init(dev, VLV_DISPLAY_BASE + DP_C, PORT_C);
10090 PORT_C);
10091 } 10091 }
10092 10092
10093 intel_dsi_init(dev); 10093 intel_dsi_init(dev);
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 0b2e842fef01..30c627c7b7ba 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -3326,11 +3326,19 @@ intel_trans_dp_port_sel(struct drm_crtc *crtc)
3326} 3326}
3327 3327
3328/* check the VBT to see whether the eDP is on DP-D port */ 3328/* check the VBT to see whether the eDP is on DP-D port */
3329bool intel_dpd_is_edp(struct drm_device *dev) 3329bool intel_dp_is_edp(struct drm_device *dev, enum port port)
3330{ 3330{
3331 struct drm_i915_private *dev_priv = dev->dev_private; 3331 struct drm_i915_private *dev_priv = dev->dev_private;
3332 union child_device_config *p_child; 3332 union child_device_config *p_child;
3333 int i; 3333 int i;
3334 static const short port_mapping[] = {
3335 [PORT_B] = PORT_IDPB,
3336 [PORT_C] = PORT_IDPC,
3337 [PORT_D] = PORT_IDPD,
3338 };
3339
3340 if (port == PORT_A)
3341 return true;
3334 3342
3335 if (!dev_priv->vbt.child_dev_num) 3343 if (!dev_priv->vbt.child_dev_num)
3336 return false; 3344 return false;
@@ -3338,7 +3346,7 @@ bool intel_dpd_is_edp(struct drm_device *dev)
3338 for (i = 0; i < dev_priv->vbt.child_dev_num; i++) { 3346 for (i = 0; i < dev_priv->vbt.child_dev_num; i++) {
3339 p_child = dev_priv->vbt.child_dev + i; 3347 p_child = dev_priv->vbt.child_dev + i;
3340 3348
3341 if (p_child->common.dvo_port == PORT_IDPD && 3349 if (p_child->common.dvo_port == port_mapping[port] &&
3342 (p_child->common.device_type & DEVICE_TYPE_eDP_BITS) == 3350 (p_child->common.device_type & DEVICE_TYPE_eDP_BITS) ==
3343 (DEVICE_TYPE_eDP & DEVICE_TYPE_eDP_BITS)) 3351 (DEVICE_TYPE_eDP & DEVICE_TYPE_eDP_BITS))
3344 return true; 3352 return true;
@@ -3616,26 +3624,10 @@ intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
3616 intel_dp->DP = I915_READ(intel_dp->output_reg); 3624 intel_dp->DP = I915_READ(intel_dp->output_reg);
3617 intel_dp->attached_connector = intel_connector; 3625 intel_dp->attached_connector = intel_connector;
3618 3626
3619 type = DRM_MODE_CONNECTOR_DisplayPort; 3627 if (intel_dp_is_edp(dev, port))
3620 /*
3621 * FIXME : We need to initialize built-in panels before external panels.
3622 * For X0, DP_C is fixed as eDP. Revisit this as part of VLV eDP cleanup
3623 */
3624 switch (port) {
3625 case PORT_A:
3626 type = DRM_MODE_CONNECTOR_eDP; 3628 type = DRM_MODE_CONNECTOR_eDP;
3627 break; 3629 else
3628 case PORT_C: 3630 type = DRM_MODE_CONNECTOR_DisplayPort;
3629 if (IS_VALLEYVIEW(dev))
3630 type = DRM_MODE_CONNECTOR_eDP;
3631 break;
3632 case PORT_D:
3633 if (HAS_PCH_SPLIT(dev) && intel_dpd_is_edp(dev))
3634 type = DRM_MODE_CONNECTOR_eDP;
3635 break;
3636 default: /* silence GCC warning */
3637 break;
3638 }
3639 3631
3640 /* 3632 /*
3641 * For eDP we always set the encoder type to INTEL_OUTPUT_EDP, but 3633 * For eDP we always set the encoder type to INTEL_OUTPUT_EDP, but
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 1e49aa8f5377..a18e88b3e425 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -708,7 +708,7 @@ void intel_dp_encoder_destroy(struct drm_encoder *encoder);
708void intel_dp_check_link_status(struct intel_dp *intel_dp); 708void intel_dp_check_link_status(struct intel_dp *intel_dp);
709bool intel_dp_compute_config(struct intel_encoder *encoder, 709bool intel_dp_compute_config(struct intel_encoder *encoder,
710 struct intel_crtc_config *pipe_config); 710 struct intel_crtc_config *pipe_config);
711bool intel_dpd_is_edp(struct drm_device *dev); 711bool intel_dp_is_edp(struct drm_device *dev, enum port port);
712void ironlake_edp_backlight_on(struct intel_dp *intel_dp); 712void ironlake_edp_backlight_on(struct intel_dp *intel_dp);
713void ironlake_edp_backlight_off(struct intel_dp *intel_dp); 713void ironlake_edp_backlight_off(struct intel_dp *intel_dp);
714void ironlake_edp_panel_on(struct intel_dp *intel_dp); 714void ironlake_edp_panel_on(struct intel_dp *intel_dp);
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index caf2ee4e5441..6e0d5e075b15 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -1180,7 +1180,7 @@ static bool g4x_compute_wm0(struct drm_device *dev,
1180 1180
1181 adjusted_mode = &to_intel_crtc(crtc)->config.adjusted_mode; 1181 adjusted_mode = &to_intel_crtc(crtc)->config.adjusted_mode;
1182 clock = adjusted_mode->crtc_clock; 1182 clock = adjusted_mode->crtc_clock;
1183 htotal = adjusted_mode->htotal; 1183 htotal = adjusted_mode->crtc_htotal;
1184 hdisplay = to_intel_crtc(crtc)->config.pipe_src_w; 1184 hdisplay = to_intel_crtc(crtc)->config.pipe_src_w;
1185 pixel_size = crtc->fb->bits_per_pixel / 8; 1185 pixel_size = crtc->fb->bits_per_pixel / 8;
1186 1186
@@ -1267,7 +1267,7 @@ static bool g4x_compute_srwm(struct drm_device *dev,
1267 crtc = intel_get_crtc_for_plane(dev, plane); 1267 crtc = intel_get_crtc_for_plane(dev, plane);
1268 adjusted_mode = &to_intel_crtc(crtc)->config.adjusted_mode; 1268 adjusted_mode = &to_intel_crtc(crtc)->config.adjusted_mode;
1269 clock = adjusted_mode->crtc_clock; 1269 clock = adjusted_mode->crtc_clock;
1270 htotal = adjusted_mode->htotal; 1270 htotal = adjusted_mode->crtc_htotal;
1271 hdisplay = to_intel_crtc(crtc)->config.pipe_src_w; 1271 hdisplay = to_intel_crtc(crtc)->config.pipe_src_w;
1272 pixel_size = crtc->fb->bits_per_pixel / 8; 1272 pixel_size = crtc->fb->bits_per_pixel / 8;
1273 1273
@@ -1498,7 +1498,7 @@ static void i965_update_wm(struct drm_crtc *unused_crtc)
1498 const struct drm_display_mode *adjusted_mode = 1498 const struct drm_display_mode *adjusted_mode =
1499 &to_intel_crtc(crtc)->config.adjusted_mode; 1499 &to_intel_crtc(crtc)->config.adjusted_mode;
1500 int clock = adjusted_mode->crtc_clock; 1500 int clock = adjusted_mode->crtc_clock;
1501 int htotal = adjusted_mode->htotal; 1501 int htotal = adjusted_mode->crtc_htotal;
1502 int hdisplay = to_intel_crtc(crtc)->config.pipe_src_w; 1502 int hdisplay = to_intel_crtc(crtc)->config.pipe_src_w;
1503 int pixel_size = crtc->fb->bits_per_pixel / 8; 1503 int pixel_size = crtc->fb->bits_per_pixel / 8;
1504 unsigned long line_time_us; 1504 unsigned long line_time_us;
@@ -1624,7 +1624,7 @@ static void i9xx_update_wm(struct drm_crtc *unused_crtc)
1624 const struct drm_display_mode *adjusted_mode = 1624 const struct drm_display_mode *adjusted_mode =
1625 &to_intel_crtc(enabled)->config.adjusted_mode; 1625 &to_intel_crtc(enabled)->config.adjusted_mode;
1626 int clock = adjusted_mode->crtc_clock; 1626 int clock = adjusted_mode->crtc_clock;
1627 int htotal = adjusted_mode->htotal; 1627 int htotal = adjusted_mode->crtc_htotal;
1628 int hdisplay = to_intel_crtc(enabled)->config.pipe_src_w; 1628 int hdisplay = to_intel_crtc(enabled)->config.pipe_src_w;
1629 int pixel_size = enabled->fb->bits_per_pixel / 8; 1629 int pixel_size = enabled->fb->bits_per_pixel / 8;
1630 unsigned long line_time_us; 1630 unsigned long line_time_us;
@@ -1776,7 +1776,7 @@ static bool ironlake_compute_srwm(struct drm_device *dev, int level, int plane,
1776 crtc = intel_get_crtc_for_plane(dev, plane); 1776 crtc = intel_get_crtc_for_plane(dev, plane);
1777 adjusted_mode = &to_intel_crtc(crtc)->config.adjusted_mode; 1777 adjusted_mode = &to_intel_crtc(crtc)->config.adjusted_mode;
1778 clock = adjusted_mode->crtc_clock; 1778 clock = adjusted_mode->crtc_clock;
1779 htotal = adjusted_mode->htotal; 1779 htotal = adjusted_mode->crtc_htotal;
1780 hdisplay = to_intel_crtc(crtc)->config.pipe_src_w; 1780 hdisplay = to_intel_crtc(crtc)->config.pipe_src_w;
1781 pixel_size = crtc->fb->bits_per_pixel / 8; 1781 pixel_size = crtc->fb->bits_per_pixel / 8;
1782 1782
@@ -2469,8 +2469,9 @@ hsw_compute_linetime_wm(struct drm_device *dev, struct drm_crtc *crtc)
2469 /* The WM are computed with base on how long it takes to fill a single 2469 /* The WM are computed with base on how long it takes to fill a single
2470 * row at the given clock rate, multiplied by 8. 2470 * row at the given clock rate, multiplied by 8.
2471 * */ 2471 * */
2472 linetime = DIV_ROUND_CLOSEST(mode->htotal * 1000 * 8, mode->clock); 2472 linetime = DIV_ROUND_CLOSEST(mode->crtc_htotal * 1000 * 8,
2473 ips_linetime = DIV_ROUND_CLOSEST(mode->htotal * 1000 * 8, 2473 mode->crtc_clock);
2474 ips_linetime = DIV_ROUND_CLOSEST(mode->crtc_htotal * 1000 * 8,
2474 intel_ddi_get_cdclk_freq(dev_priv)); 2475 intel_ddi_get_cdclk_freq(dev_priv));
2475 2476
2476 return PIPE_WM_LINETIME_IPS_LINETIME(ips_linetime) | 2477 return PIPE_WM_LINETIME_IPS_LINETIME(ips_linetime) |
diff --git a/drivers/gpu/drm/nouveau/Makefile b/drivers/gpu/drm/nouveau/Makefile
index edcf801613e6..b3fa1ba191b7 100644
--- a/drivers/gpu/drm/nouveau/Makefile
+++ b/drivers/gpu/drm/nouveau/Makefile
@@ -59,6 +59,7 @@ nouveau-y += core/subdev/clock/nv40.o
59nouveau-y += core/subdev/clock/nv50.o 59nouveau-y += core/subdev/clock/nv50.o
60nouveau-y += core/subdev/clock/nv84.o 60nouveau-y += core/subdev/clock/nv84.o
61nouveau-y += core/subdev/clock/nva3.o 61nouveau-y += core/subdev/clock/nva3.o
62nouveau-y += core/subdev/clock/nvaa.o
62nouveau-y += core/subdev/clock/nvc0.o 63nouveau-y += core/subdev/clock/nvc0.o
63nouveau-y += core/subdev/clock/nve0.o 64nouveau-y += core/subdev/clock/nve0.o
64nouveau-y += core/subdev/clock/pllnv04.o 65nouveau-y += core/subdev/clock/pllnv04.o
diff --git a/drivers/gpu/drm/nouveau/core/engine/device/nv50.c b/drivers/gpu/drm/nouveau/core/engine/device/nv50.c
index db139827047c..db3fc7be856a 100644
--- a/drivers/gpu/drm/nouveau/core/engine/device/nv50.c
+++ b/drivers/gpu/drm/nouveau/core/engine/device/nv50.c
@@ -283,7 +283,7 @@ nv50_identify(struct nouveau_device *device)
283 device->oclass[NVDEV_SUBDEV_VBIOS ] = &nouveau_bios_oclass; 283 device->oclass[NVDEV_SUBDEV_VBIOS ] = &nouveau_bios_oclass;
284 device->oclass[NVDEV_SUBDEV_GPIO ] = &nv50_gpio_oclass; 284 device->oclass[NVDEV_SUBDEV_GPIO ] = &nv50_gpio_oclass;
285 device->oclass[NVDEV_SUBDEV_I2C ] = &nv94_i2c_oclass; 285 device->oclass[NVDEV_SUBDEV_I2C ] = &nv94_i2c_oclass;
286 device->oclass[NVDEV_SUBDEV_CLOCK ] = nv84_clock_oclass; 286 device->oclass[NVDEV_SUBDEV_CLOCK ] = nvaa_clock_oclass;
287 device->oclass[NVDEV_SUBDEV_THERM ] = &nv84_therm_oclass; 287 device->oclass[NVDEV_SUBDEV_THERM ] = &nv84_therm_oclass;
288 device->oclass[NVDEV_SUBDEV_MXM ] = &nv50_mxm_oclass; 288 device->oclass[NVDEV_SUBDEV_MXM ] = &nv50_mxm_oclass;
289 device->oclass[NVDEV_SUBDEV_DEVINIT] = &nv50_devinit_oclass; 289 device->oclass[NVDEV_SUBDEV_DEVINIT] = &nv50_devinit_oclass;
@@ -311,7 +311,7 @@ nv50_identify(struct nouveau_device *device)
311 device->oclass[NVDEV_SUBDEV_VBIOS ] = &nouveau_bios_oclass; 311 device->oclass[NVDEV_SUBDEV_VBIOS ] = &nouveau_bios_oclass;
312 device->oclass[NVDEV_SUBDEV_GPIO ] = &nv50_gpio_oclass; 312 device->oclass[NVDEV_SUBDEV_GPIO ] = &nv50_gpio_oclass;
313 device->oclass[NVDEV_SUBDEV_I2C ] = &nv94_i2c_oclass; 313 device->oclass[NVDEV_SUBDEV_I2C ] = &nv94_i2c_oclass;
314 device->oclass[NVDEV_SUBDEV_CLOCK ] = nv84_clock_oclass; 314 device->oclass[NVDEV_SUBDEV_CLOCK ] = nvaa_clock_oclass;
315 device->oclass[NVDEV_SUBDEV_THERM ] = &nv84_therm_oclass; 315 device->oclass[NVDEV_SUBDEV_THERM ] = &nv84_therm_oclass;
316 device->oclass[NVDEV_SUBDEV_MXM ] = &nv50_mxm_oclass; 316 device->oclass[NVDEV_SUBDEV_MXM ] = &nv50_mxm_oclass;
317 device->oclass[NVDEV_SUBDEV_DEVINIT] = &nv50_devinit_oclass; 317 device->oclass[NVDEV_SUBDEV_DEVINIT] = &nv50_devinit_oclass;
diff --git a/drivers/gpu/drm/nouveau/core/engine/fifo/nv50.c b/drivers/gpu/drm/nouveau/core/engine/fifo/nv50.c
index 5f555788121c..e6352bd5b4ff 100644
--- a/drivers/gpu/drm/nouveau/core/engine/fifo/nv50.c
+++ b/drivers/gpu/drm/nouveau/core/engine/fifo/nv50.c
@@ -33,6 +33,7 @@
33#include <engine/dmaobj.h> 33#include <engine/dmaobj.h>
34#include <engine/fifo.h> 34#include <engine/fifo.h>
35 35
36#include "nv04.h"
36#include "nv50.h" 37#include "nv50.h"
37 38
38/******************************************************************************* 39/*******************************************************************************
@@ -460,6 +461,8 @@ nv50_fifo_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
460 nv_subdev(priv)->intr = nv04_fifo_intr; 461 nv_subdev(priv)->intr = nv04_fifo_intr;
461 nv_engine(priv)->cclass = &nv50_fifo_cclass; 462 nv_engine(priv)->cclass = &nv50_fifo_cclass;
462 nv_engine(priv)->sclass = nv50_fifo_sclass; 463 nv_engine(priv)->sclass = nv50_fifo_sclass;
464 priv->base.pause = nv04_fifo_pause;
465 priv->base.start = nv04_fifo_start;
463 return 0; 466 return 0;
464} 467}
465 468
diff --git a/drivers/gpu/drm/nouveau/core/engine/fifo/nv84.c b/drivers/gpu/drm/nouveau/core/engine/fifo/nv84.c
index 0908dc834c84..fe0f41e65d9b 100644
--- a/drivers/gpu/drm/nouveau/core/engine/fifo/nv84.c
+++ b/drivers/gpu/drm/nouveau/core/engine/fifo/nv84.c
@@ -35,6 +35,7 @@
35#include <engine/dmaobj.h> 35#include <engine/dmaobj.h>
36#include <engine/fifo.h> 36#include <engine/fifo.h>
37 37
38#include "nv04.h"
38#include "nv50.h" 39#include "nv50.h"
39 40
40/******************************************************************************* 41/*******************************************************************************
@@ -432,6 +433,8 @@ nv84_fifo_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
432 nv_subdev(priv)->intr = nv04_fifo_intr; 433 nv_subdev(priv)->intr = nv04_fifo_intr;
433 nv_engine(priv)->cclass = &nv84_fifo_cclass; 434 nv_engine(priv)->cclass = &nv84_fifo_cclass;
434 nv_engine(priv)->sclass = nv84_fifo_sclass; 435 nv_engine(priv)->sclass = nv84_fifo_sclass;
436 priv->base.pause = nv04_fifo_pause;
437 priv->base.start = nv04_fifo_start;
435 return 0; 438 return 0;
436} 439}
437 440
diff --git a/drivers/gpu/drm/nouveau/core/engine/software/nv50.c b/drivers/gpu/drm/nouveau/core/engine/software/nv50.c
index b574dd4bb828..5ce686ee729e 100644
--- a/drivers/gpu/drm/nouveau/core/engine/software/nv50.c
+++ b/drivers/gpu/drm/nouveau/core/engine/software/nv50.c
@@ -176,7 +176,7 @@ nv50_software_context_ctor(struct nouveau_object *parent,
176 if (ret) 176 if (ret)
177 return ret; 177 return ret;
178 178
179 chan->vblank.nr_event = pdisp->vblank->index_nr; 179 chan->vblank.nr_event = pdisp ? pdisp->vblank->index_nr : 0;
180 chan->vblank.event = kzalloc(chan->vblank.nr_event * 180 chan->vblank.event = kzalloc(chan->vblank.nr_event *
181 sizeof(*chan->vblank.event), GFP_KERNEL); 181 sizeof(*chan->vblank.event), GFP_KERNEL);
182 if (!chan->vblank.event) 182 if (!chan->vblank.event)
diff --git a/drivers/gpu/drm/nouveau/core/include/subdev/clock.h b/drivers/gpu/drm/nouveau/core/include/subdev/clock.h
index e2675bc0edba..8f4ced75444a 100644
--- a/drivers/gpu/drm/nouveau/core/include/subdev/clock.h
+++ b/drivers/gpu/drm/nouveau/core/include/subdev/clock.h
@@ -14,6 +14,9 @@ enum nv_clk_src {
14 nv_clk_src_hclk, 14 nv_clk_src_hclk,
15 nv_clk_src_hclkm3, 15 nv_clk_src_hclkm3,
16 nv_clk_src_hclkm3d2, 16 nv_clk_src_hclkm3d2,
17 nv_clk_src_hclkm2d3, /* NVAA */
18 nv_clk_src_hclkm4, /* NVAA */
19 nv_clk_src_cclk, /* NVAA */
17 20
18 nv_clk_src_host, 21 nv_clk_src_host,
19 22
@@ -127,6 +130,7 @@ extern struct nouveau_oclass nv04_clock_oclass;
127extern struct nouveau_oclass nv40_clock_oclass; 130extern struct nouveau_oclass nv40_clock_oclass;
128extern struct nouveau_oclass *nv50_clock_oclass; 131extern struct nouveau_oclass *nv50_clock_oclass;
129extern struct nouveau_oclass *nv84_clock_oclass; 132extern struct nouveau_oclass *nv84_clock_oclass;
133extern struct nouveau_oclass *nvaa_clock_oclass;
130extern struct nouveau_oclass nva3_clock_oclass; 134extern struct nouveau_oclass nva3_clock_oclass;
131extern struct nouveau_oclass nvc0_clock_oclass; 135extern struct nouveau_oclass nvc0_clock_oclass;
132extern struct nouveau_oclass nve0_clock_oclass; 136extern struct nouveau_oclass nve0_clock_oclass;
diff --git a/drivers/gpu/drm/nouveau/core/subdev/clock/nv04.c b/drivers/gpu/drm/nouveau/core/subdev/clock/nv04.c
index da50c1b12928..30c1f3a4158e 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/clock/nv04.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/clock/nv04.c
@@ -69,6 +69,11 @@ nv04_clock_pll_prog(struct nouveau_clock *clk, u32 reg1,
69 return 0; 69 return 0;
70} 70}
71 71
72static struct nouveau_clocks
73nv04_domain[] = {
74 { nv_clk_src_max }
75};
76
72static int 77static int
73nv04_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine, 78nv04_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
74 struct nouveau_oclass *oclass, void *data, u32 size, 79 struct nouveau_oclass *oclass, void *data, u32 size,
@@ -77,7 +82,7 @@ nv04_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
77 struct nv04_clock_priv *priv; 82 struct nv04_clock_priv *priv;
78 int ret; 83 int ret;
79 84
80 ret = nouveau_clock_create(parent, engine, oclass, NULL, &priv); 85 ret = nouveau_clock_create(parent, engine, oclass, nv04_domain, &priv);
81 *pobject = nv_object(priv); 86 *pobject = nv_object(priv);
82 if (ret) 87 if (ret)
83 return ret; 88 return ret;
diff --git a/drivers/gpu/drm/nouveau/core/subdev/clock/nvaa.c b/drivers/gpu/drm/nouveau/core/subdev/clock/nvaa.c
new file mode 100644
index 000000000000..7a723b4f564d
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/core/subdev/clock/nvaa.c
@@ -0,0 +1,445 @@
1/*
2 * Copyright 2012 Red Hat Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * Authors: Ben Skeggs
23 */
24
25#include <engine/fifo.h>
26#include <subdev/bios.h>
27#include <subdev/bios/pll.h>
28#include <subdev/timer.h>
29#include <subdev/clock.h>
30
31#include "pll.h"
32
33struct nvaa_clock_priv {
34 struct nouveau_clock base;
35 enum nv_clk_src csrc, ssrc, vsrc;
36 u32 cctrl, sctrl;
37 u32 ccoef, scoef;
38 u32 cpost, spost;
39 u32 vdiv;
40};
41
42static u32
43read_div(struct nouveau_clock *clk)
44{
45 return nv_rd32(clk, 0x004600);
46}
47
48static u32
49read_pll(struct nouveau_clock *clk, u32 base)
50{
51 u32 ctrl = nv_rd32(clk, base + 0);
52 u32 coef = nv_rd32(clk, base + 4);
53 u32 ref = clk->read(clk, nv_clk_src_href);
54 u32 post_div = 0;
55 u32 clock = 0;
56 int N1, M1;
57
58 switch (base){
59 case 0x4020:
60 post_div = 1 << ((nv_rd32(clk, 0x4070) & 0x000f0000) >> 16);
61 break;
62 case 0x4028:
63 post_div = (nv_rd32(clk, 0x4040) & 0x000f0000) >> 16;
64 break;
65 default:
66 break;
67 }
68
69 N1 = (coef & 0x0000ff00) >> 8;
70 M1 = (coef & 0x000000ff);
71 if ((ctrl & 0x80000000) && M1) {
72 clock = ref * N1 / M1;
73 clock = clock / post_div;
74 }
75
76 return clock;
77}
78
79static int
80nvaa_clock_read(struct nouveau_clock *clk, enum nv_clk_src src)
81{
82 struct nvaa_clock_priv *priv = (void *)clk;
83 u32 mast = nv_rd32(clk, 0x00c054);
84 u32 P = 0;
85
86 switch (src) {
87 case nv_clk_src_crystal:
88 return nv_device(priv)->crystal;
89 case nv_clk_src_href:
90 return 100000; /* PCIE reference clock */
91 case nv_clk_src_hclkm4:
92 return clk->read(clk, nv_clk_src_href) * 4;
93 case nv_clk_src_hclkm2d3:
94 return clk->read(clk, nv_clk_src_href) * 2 / 3;
95 case nv_clk_src_host:
96 switch (mast & 0x000c0000) {
97 case 0x00000000: return clk->read(clk, nv_clk_src_hclkm2d3);
98 case 0x00040000: break;
99 case 0x00080000: return clk->read(clk, nv_clk_src_hclkm4);
100 case 0x000c0000: return clk->read(clk, nv_clk_src_cclk);
101 }
102 break;
103 case nv_clk_src_core:
104 P = (nv_rd32(clk, 0x004028) & 0x00070000) >> 16;
105
106 switch (mast & 0x00000003) {
107 case 0x00000000: return clk->read(clk, nv_clk_src_crystal) >> P;
108 case 0x00000001: return 0;
109 case 0x00000002: return clk->read(clk, nv_clk_src_hclkm4) >> P;
110 case 0x00000003: return read_pll(clk, 0x004028) >> P;
111 }
112 break;
113 case nv_clk_src_cclk:
114 if ((mast & 0x03000000) != 0x03000000)
115 return clk->read(clk, nv_clk_src_core);
116
117 if ((mast & 0x00000200) == 0x00000000)
118 return clk->read(clk, nv_clk_src_core);
119
120 switch (mast & 0x00000c00) {
121 case 0x00000000: return clk->read(clk, nv_clk_src_href);
122 case 0x00000400: return clk->read(clk, nv_clk_src_hclkm4);
123 case 0x00000800: return clk->read(clk, nv_clk_src_hclkm2d3);
124 default: return 0;
125 }
126 case nv_clk_src_shader:
127 P = (nv_rd32(clk, 0x004020) & 0x00070000) >> 16;
128 switch (mast & 0x00000030) {
129 case 0x00000000:
130 if (mast & 0x00000040)
131 return clk->read(clk, nv_clk_src_href) >> P;
132 return clk->read(clk, nv_clk_src_crystal) >> P;
133 case 0x00000010: break;
134 case 0x00000020: return read_pll(clk, 0x004028) >> P;
135 case 0x00000030: return read_pll(clk, 0x004020) >> P;
136 }
137 break;
138 case nv_clk_src_mem:
139 return 0;
140 break;
141 case nv_clk_src_vdec:
142 P = (read_div(clk) & 0x00000700) >> 8;
143
144 switch (mast & 0x00400000) {
145 case 0x00400000:
146 return clk->read(clk, nv_clk_src_core) >> P;
147 break;
148 default:
149 return 500000 >> P;
150 break;
151 }
152 break;
153 default:
154 break;
155 }
156
157 nv_debug(priv, "unknown clock source %d 0x%08x\n", src, mast);
158 return 0;
159}
160
161static u32
162calc_pll(struct nvaa_clock_priv *priv, u32 reg,
163 u32 clock, int *N, int *M, int *P)
164{
165 struct nouveau_bios *bios = nouveau_bios(priv);
166 struct nvbios_pll pll;
167 struct nouveau_clock *clk = &priv->base;
168 int ret;
169
170 ret = nvbios_pll_parse(bios, reg, &pll);
171 if (ret)
172 return 0;
173
174 pll.vco2.max_freq = 0;
175 pll.refclk = clk->read(clk, nv_clk_src_href);
176 if (!pll.refclk)
177 return 0;
178
179 return nv04_pll_calc(nv_subdev(priv), &pll, clock, N, M, NULL, NULL, P);
180}
181
182static inline u32
183calc_P(u32 src, u32 target, int *div)
184{
185 u32 clk0 = src, clk1 = src;
186 for (*div = 0; *div <= 7; (*div)++) {
187 if (clk0 <= target) {
188 clk1 = clk0 << (*div ? 1 : 0);
189 break;
190 }
191 clk0 >>= 1;
192 }
193
194 if (target - clk0 <= clk1 - target)
195 return clk0;
196 (*div)--;
197 return clk1;
198}
199
200static int
201nvaa_clock_calc(struct nouveau_clock *clk, struct nouveau_cstate *cstate)
202{
203 struct nvaa_clock_priv *priv = (void *)clk;
204 const int shader = cstate->domain[nv_clk_src_shader];
205 const int core = cstate->domain[nv_clk_src_core];
206 const int vdec = cstate->domain[nv_clk_src_vdec];
207 u32 out = 0, clock = 0;
208 int N, M, P1, P2 = 0;
209 int divs = 0;
210
211 /* cclk: find suitable source, disable PLL if we can */
212 if (core < clk->read(clk, nv_clk_src_hclkm4))
213 out = calc_P(clk->read(clk, nv_clk_src_hclkm4), core, &divs);
214
215 /* Calculate clock * 2, so shader clock can use it too */
216 clock = calc_pll(priv, 0x4028, (core << 1), &N, &M, &P1);
217
218 if (abs(core - out) <=
219 abs(core - (clock >> 1))) {
220 priv->csrc = nv_clk_src_hclkm4;
221 priv->cctrl = divs << 16;
222 } else {
223 /* NVCTRL is actually used _after_ NVPOST, and after what we
224 * call NVPLL. To make matters worse, NVPOST is an integer
225 * divider instead of a right-shift number. */
226 if(P1 > 2) {
227 P2 = P1 - 2;
228 P1 = 2;
229 }
230
231 priv->csrc = nv_clk_src_core;
232 priv->ccoef = (N << 8) | M;
233
234 priv->cctrl = (P2 + 1) << 16;
235 priv->cpost = (1 << P1) << 16;
236 }
237
238 /* sclk: nvpll + divisor, href or spll */
239 out = 0;
240 if (shader == clk->read(clk, nv_clk_src_href)) {
241 priv->ssrc = nv_clk_src_href;
242 } else {
243 clock = calc_pll(priv, 0x4020, shader, &N, &M, &P1);
244 if (priv->csrc == nv_clk_src_core) {
245 out = calc_P((core << 1), shader, &divs);
246 }
247
248 if (abs(shader - out) <=
249 abs(shader - clock) &&
250 (divs + P2) <= 7) {
251 priv->ssrc = nv_clk_src_core;
252 priv->sctrl = (divs + P2) << 16;
253 } else {
254 priv->ssrc = nv_clk_src_shader;
255 priv->scoef = (N << 8) | M;
256 priv->sctrl = P1 << 16;
257 }
258 }
259
260 /* vclk */
261 out = calc_P(core, vdec, &divs);
262 clock = calc_P(500000, vdec, &P1);
263 if(abs(vdec - out) <=
264 abs(vdec - clock)) {
265 priv->vsrc = nv_clk_src_cclk;
266 priv->vdiv = divs << 16;
267 } else {
268 priv->vsrc = nv_clk_src_vdec;
269 priv->vdiv = P1 << 16;
270 }
271
272 /* Print strategy! */
273 nv_debug(priv, "nvpll: %08x %08x %08x\n",
274 priv->ccoef, priv->cpost, priv->cctrl);
275 nv_debug(priv, " spll: %08x %08x %08x\n",
276 priv->scoef, priv->spost, priv->sctrl);
277 nv_debug(priv, " vdiv: %08x\n", priv->vdiv);
278 if (priv->csrc == nv_clk_src_hclkm4)
279 nv_debug(priv, "core: hrefm4\n");
280 else
281 nv_debug(priv, "core: nvpll\n");
282
283 if (priv->ssrc == nv_clk_src_hclkm4)
284 nv_debug(priv, "shader: hrefm4\n");
285 else if (priv->ssrc == nv_clk_src_core)
286 nv_debug(priv, "shader: nvpll\n");
287 else
288 nv_debug(priv, "shader: spll\n");
289
290 if (priv->vsrc == nv_clk_src_hclkm4)
291 nv_debug(priv, "vdec: 500MHz\n");
292 else
293 nv_debug(priv, "vdec: core\n");
294
295 return 0;
296}
297
298static int
299nvaa_clock_prog(struct nouveau_clock *clk)
300{
301 struct nvaa_clock_priv *priv = (void *)clk;
302 struct nouveau_fifo *pfifo = nouveau_fifo(clk);
303 unsigned long flags;
304 u32 pllmask = 0, mast, ptherm_gate;
305 int ret = -EBUSY;
306
307 /* halt and idle execution engines */
308 ptherm_gate = nv_mask(clk, 0x020060, 0x00070000, 0x00000000);
309 nv_mask(clk, 0x002504, 0x00000001, 0x00000001);
310 /* Wait until the interrupt handler is finished */
311 if (!nv_wait(clk, 0x000100, 0xffffffff, 0x00000000))
312 goto resume;
313
314 if (pfifo)
315 pfifo->pause(pfifo, &flags);
316
317 if (!nv_wait(clk, 0x002504, 0x00000010, 0x00000010))
318 goto resume;
319 if (!nv_wait(clk, 0x00251c, 0x0000003f, 0x0000003f))
320 goto resume;
321
322 /* First switch to safe clocks: href */
323 mast = nv_mask(clk, 0xc054, 0x03400e70, 0x03400640);
324 mast &= ~0x00400e73;
325 mast |= 0x03000000;
326
327 switch (priv->csrc) {
328 case nv_clk_src_hclkm4:
329 nv_mask(clk, 0x4028, 0x00070000, priv->cctrl);
330 mast |= 0x00000002;
331 break;
332 case nv_clk_src_core:
333 nv_wr32(clk, 0x402c, priv->ccoef);
334 nv_wr32(clk, 0x4028, 0x80000000 | priv->cctrl);
335 nv_wr32(clk, 0x4040, priv->cpost);
336 pllmask |= (0x3 << 8);
337 mast |= 0x00000003;
338 break;
339 default:
340 nv_warn(priv,"Reclocking failed: unknown core clock\n");
341 goto resume;
342 }
343
344 switch (priv->ssrc) {
345 case nv_clk_src_href:
346 nv_mask(clk, 0x4020, 0x00070000, 0x00000000);
347 /* mast |= 0x00000000; */
348 break;
349 case nv_clk_src_core:
350 nv_mask(clk, 0x4020, 0x00070000, priv->sctrl);
351 mast |= 0x00000020;
352 break;
353 case nv_clk_src_shader:
354 nv_wr32(clk, 0x4024, priv->scoef);
355 nv_wr32(clk, 0x4020, 0x80000000 | priv->sctrl);
356 nv_wr32(clk, 0x4070, priv->spost);
357 pllmask |= (0x3 << 12);
358 mast |= 0x00000030;
359 break;
360 default:
361 nv_warn(priv,"Reclocking failed: unknown sclk clock\n");
362 goto resume;
363 }
364
365 if (!nv_wait(clk, 0x004080, pllmask, pllmask)) {
366 nv_warn(priv,"Reclocking failed: unstable PLLs\n");
367 goto resume;
368 }
369
370 switch (priv->vsrc) {
371 case nv_clk_src_cclk:
372 mast |= 0x00400000;
373 default:
374 nv_wr32(clk, 0x4600, priv->vdiv);
375 }
376
377 nv_wr32(clk, 0xc054, mast);
378 ret = 0;
379
380resume:
381 if (pfifo)
382 pfifo->start(pfifo, &flags);
383
384 nv_mask(clk, 0x002504, 0x00000001, 0x00000000);
385 nv_wr32(clk, 0x020060, ptherm_gate);
386
387 /* Disable some PLLs and dividers when unused */
388 if (priv->csrc != nv_clk_src_core) {
389 nv_wr32(clk, 0x4040, 0x00000000);
390 nv_mask(clk, 0x4028, 0x80000000, 0x00000000);
391 }
392
393 if (priv->ssrc != nv_clk_src_shader) {
394 nv_wr32(clk, 0x4070, 0x00000000);
395 nv_mask(clk, 0x4020, 0x80000000, 0x00000000);
396 }
397
398 return ret;
399}
400
401static void
402nvaa_clock_tidy(struct nouveau_clock *clk)
403{
404}
405
406static struct nouveau_clocks
407nvaa_domains[] = {
408 { nv_clk_src_crystal, 0xff },
409 { nv_clk_src_href , 0xff },
410 { nv_clk_src_core , 0xff, 0, "core", 1000 },
411 { nv_clk_src_shader , 0xff, 0, "shader", 1000 },
412 { nv_clk_src_vdec , 0xff, 0, "vdec", 1000 },
413 { nv_clk_src_max }
414};
415
416static int
417nvaa_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
418 struct nouveau_oclass *oclass, void *data, u32 size,
419 struct nouveau_object **pobject)
420{
421 struct nvaa_clock_priv *priv;
422 int ret;
423
424 ret = nouveau_clock_create(parent, engine, oclass, nvaa_domains, &priv);
425 *pobject = nv_object(priv);
426 if (ret)
427 return ret;
428
429 priv->base.read = nvaa_clock_read;
430 priv->base.calc = nvaa_clock_calc;
431 priv->base.prog = nvaa_clock_prog;
432 priv->base.tidy = nvaa_clock_tidy;
433 return 0;
434}
435
436struct nouveau_oclass *
437nvaa_clock_oclass = &(struct nouveau_oclass) {
438 .handle = NV_SUBDEV(CLOCK, 0xaa),
439 .ofuncs = &(struct nouveau_ofuncs) {
440 .ctor = nvaa_clock_ctor,
441 .dtor = _nouveau_clock_dtor,
442 .init = _nouveau_clock_init,
443 .fini = _nouveau_clock_fini,
444 },
445};
diff --git a/drivers/gpu/drm/nouveau/dispnv04/overlay.c b/drivers/gpu/drm/nouveau/dispnv04/overlay.c
index 3618ac6b6316..32e7064b819b 100644
--- a/drivers/gpu/drm/nouveau/dispnv04/overlay.c
+++ b/drivers/gpu/drm/nouveau/dispnv04/overlay.c
@@ -58,8 +58,8 @@ struct nouveau_plane {
58}; 58};
59 59
60static uint32_t formats[] = { 60static uint32_t formats[] = {
61 DRM_FORMAT_NV12,
62 DRM_FORMAT_UYVY, 61 DRM_FORMAT_UYVY,
62 DRM_FORMAT_NV12,
63}; 63};
64 64
65/* Sine can be approximated with 65/* Sine can be approximated with
@@ -99,13 +99,28 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
99 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); 99 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
100 struct nouveau_bo *cur = nv_plane->cur; 100 struct nouveau_bo *cur = nv_plane->cur;
101 bool flip = nv_plane->flip; 101 bool flip = nv_plane->flip;
102 int format = ALIGN(src_w * 4, 0x100);
103 int soff = NV_PCRTC0_SIZE * nv_crtc->index; 102 int soff = NV_PCRTC0_SIZE * nv_crtc->index;
104 int soff2 = NV_PCRTC0_SIZE * !nv_crtc->index; 103 int soff2 = NV_PCRTC0_SIZE * !nv_crtc->index;
105 int ret; 104 int format, ret;
105
106 /* Source parameters given in 16.16 fixed point, ignore fractional. */
107 src_x >>= 16;
108 src_y >>= 16;
109 src_w >>= 16;
110 src_h >>= 16;
111
112 format = ALIGN(src_w * 4, 0x100);
106 113
107 if (format > 0xffff) 114 if (format > 0xffff)
108 return -EINVAL; 115 return -ERANGE;
116
117 if (dev->chipset >= 0x30) {
118 if (crtc_w < (src_w >> 1) || crtc_h < (src_h >> 1))
119 return -ERANGE;
120 } else {
121 if (crtc_w < (src_w >> 3) || crtc_h < (src_h >> 3))
122 return -ERANGE;
123 }
109 124
110 ret = nouveau_bo_pin(nv_fb->nvbo, TTM_PL_FLAG_VRAM); 125 ret = nouveau_bo_pin(nv_fb->nvbo, TTM_PL_FLAG_VRAM);
111 if (ret) 126 if (ret)
@@ -113,12 +128,6 @@ nv10_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
113 128
114 nv_plane->cur = nv_fb->nvbo; 129 nv_plane->cur = nv_fb->nvbo;
115 130
116 /* Source parameters given in 16.16 fixed point, ignore fractional. */
117 src_x = src_x >> 16;
118 src_y = src_y >> 16;
119 src_w = src_w >> 16;
120 src_h = src_h >> 16;
121
122 nv_mask(dev, NV_PCRTC_ENGINE_CTRL + soff, NV_CRTC_FSEL_OVERLAY, NV_CRTC_FSEL_OVERLAY); 131 nv_mask(dev, NV_PCRTC_ENGINE_CTRL + soff, NV_CRTC_FSEL_OVERLAY, NV_CRTC_FSEL_OVERLAY);
123 nv_mask(dev, NV_PCRTC_ENGINE_CTRL + soff2, NV_CRTC_FSEL_OVERLAY, 0); 132 nv_mask(dev, NV_PCRTC_ENGINE_CTRL + soff2, NV_CRTC_FSEL_OVERLAY, 0);
124 133
@@ -245,14 +254,25 @@ nv10_overlay_init(struct drm_device *device)
245{ 254{
246 struct nouveau_device *dev = nouveau_dev(device); 255 struct nouveau_device *dev = nouveau_dev(device);
247 struct nouveau_plane *plane = kzalloc(sizeof(struct nouveau_plane), GFP_KERNEL); 256 struct nouveau_plane *plane = kzalloc(sizeof(struct nouveau_plane), GFP_KERNEL);
257 int num_formats = ARRAY_SIZE(formats);
248 int ret; 258 int ret;
249 259
250 if (!plane) 260 if (!plane)
251 return; 261 return;
252 262
263 switch (dev->chipset) {
264 case 0x10:
265 case 0x11:
266 case 0x15:
267 case 0x1a:
268 case 0x20:
269 num_formats = 1;
270 break;
271 }
272
253 ret = drm_plane_init(device, &plane->base, 3 /* both crtc's */, 273 ret = drm_plane_init(device, &plane->base, 3 /* both crtc's */,
254 &nv10_plane_funcs, 274 &nv10_plane_funcs,
255 formats, ARRAY_SIZE(formats), false); 275 formats, num_formats, false);
256 if (ret) 276 if (ret)
257 goto err; 277 goto err;
258 278
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 7809d92183c4..29c3efdfc7dd 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -608,6 +608,7 @@ nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
608 fence = nouveau_fence_ref(new_bo->bo.sync_obj); 608 fence = nouveau_fence_ref(new_bo->bo.sync_obj);
609 spin_unlock(&new_bo->bo.bdev->fence_lock); 609 spin_unlock(&new_bo->bo.bdev->fence_lock);
610 ret = nouveau_fence_sync(fence, chan); 610 ret = nouveau_fence_sync(fence, chan);
611 nouveau_fence_unref(&fence);
611 if (ret) 612 if (ret)
612 return ret; 613 return ret;
613 614
@@ -701,7 +702,7 @@ nouveau_finish_page_flip(struct nouveau_channel *chan,
701 702
702 s = list_first_entry(&fctx->flip, struct nouveau_page_flip_state, head); 703 s = list_first_entry(&fctx->flip, struct nouveau_page_flip_state, head);
703 if (s->event) 704 if (s->event)
704 drm_send_vblank_event(dev, -1, s->event); 705 drm_send_vblank_event(dev, s->crtc, s->event);
705 706
706 list_del(&s->head); 707 list_del(&s->head);
707 if (ps) 708 if (ps)
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c
index f8e66c08b11a..4e384a2f99c3 100644
--- a/drivers/gpu/drm/nouveau/nv50_display.c
+++ b/drivers/gpu/drm/nouveau/nv50_display.c
@@ -1265,7 +1265,7 @@ nv50_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
1265 uint32_t start, uint32_t size) 1265 uint32_t start, uint32_t size)
1266{ 1266{
1267 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); 1267 struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
1268 u32 end = max(start + size, (u32)256); 1268 u32 end = min_t(u32, start + size, 256);
1269 u32 i; 1269 u32 i;
1270 1270
1271 for (i = start; i < end; i++) { 1271 for (i = start; i < end; i++) {
diff --git a/drivers/gpu/drm/radeon/atombios_i2c.c b/drivers/gpu/drm/radeon/atombios_i2c.c
index 0652ee0a2098..f685035dbe39 100644
--- a/drivers/gpu/drm/radeon/atombios_i2c.c
+++ b/drivers/gpu/drm/radeon/atombios_i2c.c
@@ -44,7 +44,7 @@ static int radeon_process_i2c_ch(struct radeon_i2c_chan *chan,
44 PROCESS_I2C_CHANNEL_TRANSACTION_PS_ALLOCATION args; 44 PROCESS_I2C_CHANNEL_TRANSACTION_PS_ALLOCATION args;
45 int index = GetIndexIntoMasterTable(COMMAND, ProcessI2cChannelTransaction); 45 int index = GetIndexIntoMasterTable(COMMAND, ProcessI2cChannelTransaction);
46 unsigned char *base; 46 unsigned char *base;
47 u16 out; 47 u16 out = cpu_to_le16(0);
48 48
49 memset(&args, 0, sizeof(args)); 49 memset(&args, 0, sizeof(args));
50 50
@@ -55,11 +55,14 @@ static int radeon_process_i2c_ch(struct radeon_i2c_chan *chan,
55 DRM_ERROR("hw i2c: tried to write too many bytes (%d vs 3)\n", num); 55 DRM_ERROR("hw i2c: tried to write too many bytes (%d vs 3)\n", num);
56 return -EINVAL; 56 return -EINVAL;
57 } 57 }
58 args.ucRegIndex = buf[0]; 58 if (buf == NULL)
59 if (num > 1) { 59 args.ucRegIndex = 0;
60 else
61 args.ucRegIndex = buf[0];
62 if (num)
60 num--; 63 num--;
64 if (num)
61 memcpy(&out, &buf[1], num); 65 memcpy(&out, &buf[1], num);
62 }
63 args.lpI2CDataOut = cpu_to_le16(out); 66 args.lpI2CDataOut = cpu_to_le16(out);
64 } else { 67 } else {
65 if (num > ATOM_MAX_HW_I2C_READ) { 68 if (num > ATOM_MAX_HW_I2C_READ) {
@@ -96,14 +99,14 @@ int radeon_atom_hw_i2c_xfer(struct i2c_adapter *i2c_adap,
96 struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap); 99 struct radeon_i2c_chan *i2c = i2c_get_adapdata(i2c_adap);
97 struct i2c_msg *p; 100 struct i2c_msg *p;
98 int i, remaining, current_count, buffer_offset, max_bytes, ret; 101 int i, remaining, current_count, buffer_offset, max_bytes, ret;
99 u8 buf = 0, flags; 102 u8 flags;
100 103
101 /* check for bus probe */ 104 /* check for bus probe */
102 p = &msgs[0]; 105 p = &msgs[0];
103 if ((num == 1) && (p->len == 0)) { 106 if ((num == 1) && (p->len == 0)) {
104 ret = radeon_process_i2c_ch(i2c, 107 ret = radeon_process_i2c_ch(i2c,
105 p->addr, HW_I2C_WRITE, 108 p->addr, HW_I2C_WRITE,
106 &buf, 1); 109 NULL, 0);
107 if (ret) 110 if (ret)
108 return ret; 111 return ret;
109 else 112 else
diff --git a/drivers/gpu/drm/radeon/dce6_afmt.c b/drivers/gpu/drm/radeon/dce6_afmt.c
index 009f46e0ce72..de86493cbc44 100644
--- a/drivers/gpu/drm/radeon/dce6_afmt.c
+++ b/drivers/gpu/drm/radeon/dce6_afmt.c
@@ -93,11 +93,13 @@ void dce6_afmt_select_pin(struct drm_encoder *encoder)
93 struct radeon_device *rdev = encoder->dev->dev_private; 93 struct radeon_device *rdev = encoder->dev->dev_private;
94 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 94 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
95 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv; 95 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
96 u32 offset = dig->afmt->offset; 96 u32 offset;
97 97
98 if (!dig->afmt->pin) 98 if (!dig || !dig->afmt || !dig->afmt->pin)
99 return; 99 return;
100 100
101 offset = dig->afmt->offset;
102
101 WREG32(AFMT_AUDIO_SRC_CONTROL + offset, 103 WREG32(AFMT_AUDIO_SRC_CONTROL + offset,
102 AFMT_AUDIO_SRC_SELECT(dig->afmt->pin->id)); 104 AFMT_AUDIO_SRC_SELECT(dig->afmt->pin->id));
103} 105}
@@ -112,7 +114,7 @@ void dce6_afmt_write_latency_fields(struct drm_encoder *encoder,
112 struct radeon_connector *radeon_connector = NULL; 114 struct radeon_connector *radeon_connector = NULL;
113 u32 tmp = 0, offset; 115 u32 tmp = 0, offset;
114 116
115 if (!dig->afmt->pin) 117 if (!dig || !dig->afmt || !dig->afmt->pin)
116 return; 118 return;
117 119
118 offset = dig->afmt->pin->offset; 120 offset = dig->afmt->pin->offset;
@@ -156,7 +158,7 @@ void dce6_afmt_write_speaker_allocation(struct drm_encoder *encoder)
156 u8 *sadb; 158 u8 *sadb;
157 int sad_count; 159 int sad_count;
158 160
159 if (!dig->afmt->pin) 161 if (!dig || !dig->afmt || !dig->afmt->pin)
160 return; 162 return;
161 163
162 offset = dig->afmt->pin->offset; 164 offset = dig->afmt->pin->offset;
@@ -217,7 +219,7 @@ void dce6_afmt_write_sad_regs(struct drm_encoder *encoder)
217 { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR13, HDMI_AUDIO_CODING_TYPE_WMA_PRO }, 219 { AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR13, HDMI_AUDIO_CODING_TYPE_WMA_PRO },
218 }; 220 };
219 221
220 if (!dig->afmt->pin) 222 if (!dig || !dig->afmt || !dig->afmt->pin)
221 return; 223 return;
222 224
223 offset = dig->afmt->pin->offset; 225 offset = dig->afmt->pin->offset;
diff --git a/drivers/gpu/drm/radeon/ni_dpm.c b/drivers/gpu/drm/radeon/ni_dpm.c
index cdc003085a76..49c4d48f54d6 100644
--- a/drivers/gpu/drm/radeon/ni_dpm.c
+++ b/drivers/gpu/drm/radeon/ni_dpm.c
@@ -785,8 +785,8 @@ static void ni_apply_state_adjust_rules(struct radeon_device *rdev,
785 struct ni_ps *ps = ni_get_ps(rps); 785 struct ni_ps *ps = ni_get_ps(rps);
786 struct radeon_clock_and_voltage_limits *max_limits; 786 struct radeon_clock_and_voltage_limits *max_limits;
787 bool disable_mclk_switching; 787 bool disable_mclk_switching;
788 u32 mclk, sclk; 788 u32 mclk;
789 u16 vddc, vddci; 789 u16 vddci;
790 u32 max_sclk_vddc, max_mclk_vddci, max_mclk_vddc; 790 u32 max_sclk_vddc, max_mclk_vddci, max_mclk_vddc;
791 int i; 791 int i;
792 792
@@ -839,24 +839,14 @@ static void ni_apply_state_adjust_rules(struct radeon_device *rdev,
839 839
840 /* XXX validate the min clocks required for display */ 840 /* XXX validate the min clocks required for display */
841 841
842 /* adjust low state */
842 if (disable_mclk_switching) { 843 if (disable_mclk_switching) {
843 mclk = ps->performance_levels[ps->performance_level_count - 1].mclk; 844 ps->performance_levels[0].mclk =
844 sclk = ps->performance_levels[0].sclk; 845 ps->performance_levels[ps->performance_level_count - 1].mclk;
845 vddc = ps->performance_levels[0].vddc; 846 ps->performance_levels[0].vddci =
846 vddci = ps->performance_levels[ps->performance_level_count - 1].vddci; 847 ps->performance_levels[ps->performance_level_count - 1].vddci;
847 } else {
848 sclk = ps->performance_levels[0].sclk;
849 mclk = ps->performance_levels[0].mclk;
850 vddc = ps->performance_levels[0].vddc;
851 vddci = ps->performance_levels[0].vddci;
852 } 848 }
853 849
854 /* adjusted low state */
855 ps->performance_levels[0].sclk = sclk;
856 ps->performance_levels[0].mclk = mclk;
857 ps->performance_levels[0].vddc = vddc;
858 ps->performance_levels[0].vddci = vddci;
859
860 btc_skip_blacklist_clocks(rdev, max_limits->sclk, max_limits->mclk, 850 btc_skip_blacklist_clocks(rdev, max_limits->sclk, max_limits->mclk,
861 &ps->performance_levels[0].sclk, 851 &ps->performance_levels[0].sclk,
862 &ps->performance_levels[0].mclk); 852 &ps->performance_levels[0].mclk);
@@ -868,11 +858,15 @@ static void ni_apply_state_adjust_rules(struct radeon_device *rdev,
868 ps->performance_levels[i].vddc = ps->performance_levels[i - 1].vddc; 858 ps->performance_levels[i].vddc = ps->performance_levels[i - 1].vddc;
869 } 859 }
870 860
861 /* adjust remaining states */
871 if (disable_mclk_switching) { 862 if (disable_mclk_switching) {
872 mclk = ps->performance_levels[0].mclk; 863 mclk = ps->performance_levels[0].mclk;
864 vddci = ps->performance_levels[0].vddci;
873 for (i = 1; i < ps->performance_level_count; i++) { 865 for (i = 1; i < ps->performance_level_count; i++) {
874 if (mclk < ps->performance_levels[i].mclk) 866 if (mclk < ps->performance_levels[i].mclk)
875 mclk = ps->performance_levels[i].mclk; 867 mclk = ps->performance_levels[i].mclk;
868 if (vddci < ps->performance_levels[i].vddci)
869 vddci = ps->performance_levels[i].vddci;
876 } 870 }
877 for (i = 0; i < ps->performance_level_count; i++) { 871 for (i = 0; i < ps->performance_level_count; i++) {
878 ps->performance_levels[i].mclk = mclk; 872 ps->performance_levels[i].mclk = mclk;
diff --git a/drivers/gpu/drm/radeon/r600_hdmi.c b/drivers/gpu/drm/radeon/r600_hdmi.c
index 4b89262f3f0e..b7d3ecba43e3 100644
--- a/drivers/gpu/drm/radeon/r600_hdmi.c
+++ b/drivers/gpu/drm/radeon/r600_hdmi.c
@@ -304,9 +304,9 @@ void r600_audio_set_dto(struct drm_encoder *encoder, u32 clock)
304 WREG32(DCCG_AUDIO_DTO1_MODULE, dto_modulo); 304 WREG32(DCCG_AUDIO_DTO1_MODULE, dto_modulo);
305 WREG32(DCCG_AUDIO_DTO_SELECT, 1); /* select DTO1 */ 305 WREG32(DCCG_AUDIO_DTO_SELECT, 1); /* select DTO1 */
306 } 306 }
307 } else if (ASIC_IS_DCE3(rdev)) { 307 } else {
308 /* according to the reg specs, this should DCE3.2 only, but in 308 /* according to the reg specs, this should DCE3.2 only, but in
309 * practice it seems to cover DCE3.0/3.1 as well. 309 * practice it seems to cover DCE2.0/3.0/3.1 as well.
310 */ 310 */
311 if (dig->dig_encoder == 0) { 311 if (dig->dig_encoder == 0) {
312 WREG32(DCCG_AUDIO_DTO0_PHASE, base_rate * 100); 312 WREG32(DCCG_AUDIO_DTO0_PHASE, base_rate * 100);
@@ -317,10 +317,6 @@ void r600_audio_set_dto(struct drm_encoder *encoder, u32 clock)
317 WREG32(DCCG_AUDIO_DTO1_MODULE, clock * 100); 317 WREG32(DCCG_AUDIO_DTO1_MODULE, clock * 100);
318 WREG32(DCCG_AUDIO_DTO_SELECT, 1); /* select DTO1 */ 318 WREG32(DCCG_AUDIO_DTO_SELECT, 1); /* select DTO1 */
319 } 319 }
320 } else {
321 /* according to the reg specs, this should be DCE2.0 and DCE3.0/3.1 */
322 WREG32(AUDIO_DTO, AUDIO_DTO_PHASE(base_rate / 10) |
323 AUDIO_DTO_MODULE(clock / 10));
324 } 320 }
325} 321}
326 322
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index ecf2a3960c07..b1f990d0eaa1 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -2710,10 +2710,10 @@ void radeon_vm_fence(struct radeon_device *rdev,
2710 struct radeon_vm *vm, 2710 struct radeon_vm *vm,
2711 struct radeon_fence *fence); 2711 struct radeon_fence *fence);
2712uint64_t radeon_vm_map_gart(struct radeon_device *rdev, uint64_t addr); 2712uint64_t radeon_vm_map_gart(struct radeon_device *rdev, uint64_t addr);
2713int radeon_vm_bo_update_pte(struct radeon_device *rdev, 2713int radeon_vm_bo_update(struct radeon_device *rdev,
2714 struct radeon_vm *vm, 2714 struct radeon_vm *vm,
2715 struct radeon_bo *bo, 2715 struct radeon_bo *bo,
2716 struct ttm_mem_reg *mem); 2716 struct ttm_mem_reg *mem);
2717void radeon_vm_bo_invalidate(struct radeon_device *rdev, 2717void radeon_vm_bo_invalidate(struct radeon_device *rdev,
2718 struct radeon_bo *bo); 2718 struct radeon_bo *bo);
2719struct radeon_bo_va *radeon_vm_bo_find(struct radeon_vm *vm, 2719struct radeon_bo_va *radeon_vm_bo_find(struct radeon_vm *vm,
diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c
index f79ee184ffd5..5c39bf7c3d88 100644
--- a/drivers/gpu/drm/radeon/radeon_atombios.c
+++ b/drivers/gpu/drm/radeon/radeon_atombios.c
@@ -2918,7 +2918,7 @@ int radeon_atom_get_memory_pll_dividers(struct radeon_device *rdev,
2918 mpll_param->dll_speed = args.ucDllSpeed; 2918 mpll_param->dll_speed = args.ucDllSpeed;
2919 mpll_param->bwcntl = args.ucBWCntl; 2919 mpll_param->bwcntl = args.ucBWCntl;
2920 mpll_param->vco_mode = 2920 mpll_param->vco_mode =
2921 (args.ucPllCntlFlag & MPLL_CNTL_FLAG_VCO_MODE_MASK) ? 1 : 0; 2921 (args.ucPllCntlFlag & MPLL_CNTL_FLAG_VCO_MODE_MASK);
2922 mpll_param->yclk_sel = 2922 mpll_param->yclk_sel =
2923 (args.ucPllCntlFlag & MPLL_CNTL_FLAG_BYPASS_DQ_PLL) ? 1 : 0; 2923 (args.ucPllCntlFlag & MPLL_CNTL_FLAG_BYPASS_DQ_PLL) ? 1 : 0;
2924 mpll_param->qdr = 2924 mpll_param->qdr =
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c
index f41594b2eeac..0b366169d64d 100644
--- a/drivers/gpu/drm/radeon/radeon_cs.c
+++ b/drivers/gpu/drm/radeon/radeon_cs.c
@@ -360,13 +360,13 @@ static int radeon_bo_vm_update_pte(struct radeon_cs_parser *parser,
360 struct radeon_bo *bo; 360 struct radeon_bo *bo;
361 int r; 361 int r;
362 362
363 r = radeon_vm_bo_update_pte(rdev, vm, rdev->ring_tmp_bo.bo, &rdev->ring_tmp_bo.bo->tbo.mem); 363 r = radeon_vm_bo_update(rdev, vm, rdev->ring_tmp_bo.bo, &rdev->ring_tmp_bo.bo->tbo.mem);
364 if (r) { 364 if (r) {
365 return r; 365 return r;
366 } 366 }
367 list_for_each_entry(lobj, &parser->validated, tv.head) { 367 list_for_each_entry(lobj, &parser->validated, tv.head) {
368 bo = lobj->bo; 368 bo = lobj->bo;
369 r = radeon_vm_bo_update_pte(parser->rdev, vm, bo, &bo->tbo.mem); 369 r = radeon_vm_bo_update(parser->rdev, vm, bo, &bo->tbo.mem);
370 if (r) { 370 if (r) {
371 return r; 371 return r;
372 } 372 }
diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
index 543dcfae7e6f..00e0d449021c 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.h
+++ b/drivers/gpu/drm/radeon/radeon_drv.h
@@ -108,9 +108,10 @@
108 * 1.31- Add support for num Z pipes from GET_PARAM 108 * 1.31- Add support for num Z pipes from GET_PARAM
109 * 1.32- fixes for rv740 setup 109 * 1.32- fixes for rv740 setup
110 * 1.33- Add r6xx/r7xx const buffer support 110 * 1.33- Add r6xx/r7xx const buffer support
111 * 1.34- fix evergreen/cayman GS register
111 */ 112 */
112#define DRIVER_MAJOR 1 113#define DRIVER_MAJOR 1
113#define DRIVER_MINOR 33 114#define DRIVER_MINOR 34
114#define DRIVER_PATCHLEVEL 0 115#define DRIVER_PATCHLEVEL 0
115 116
116long radeon_drm_ioctl(struct file *filp, 117long radeon_drm_ioctl(struct file *filp,
diff --git a/drivers/gpu/drm/radeon/radeon_gart.c b/drivers/gpu/drm/radeon/radeon_gart.c
index 3044e504f4ec..96e440061bdb 100644
--- a/drivers/gpu/drm/radeon/radeon_gart.c
+++ b/drivers/gpu/drm/radeon/radeon_gart.c
@@ -29,6 +29,7 @@
29#include <drm/radeon_drm.h> 29#include <drm/radeon_drm.h>
30#include "radeon.h" 30#include "radeon.h"
31#include "radeon_reg.h" 31#include "radeon_reg.h"
32#include "radeon_trace.h"
32 33
33/* 34/*
34 * GART 35 * GART
@@ -737,6 +738,7 @@ struct radeon_fence *radeon_vm_grab_id(struct radeon_device *rdev,
737 for (i = 0; i < 2; ++i) { 738 for (i = 0; i < 2; ++i) {
738 if (choices[i]) { 739 if (choices[i]) {
739 vm->id = choices[i]; 740 vm->id = choices[i];
741 trace_radeon_vm_grab_id(vm->id, ring);
740 return rdev->vm_manager.active[choices[i]]; 742 return rdev->vm_manager.active[choices[i]];
741 } 743 }
742 } 744 }
@@ -1116,7 +1118,7 @@ static void radeon_vm_update_ptes(struct radeon_device *rdev,
1116} 1118}
1117 1119
1118/** 1120/**
1119 * radeon_vm_bo_update_pte - map a bo into the vm page table 1121 * radeon_vm_bo_update - map a bo into the vm page table
1120 * 1122 *
1121 * @rdev: radeon_device pointer 1123 * @rdev: radeon_device pointer
1122 * @vm: requested vm 1124 * @vm: requested vm
@@ -1128,10 +1130,10 @@ static void radeon_vm_update_ptes(struct radeon_device *rdev,
1128 * 1130 *
1129 * Object have to be reserved & global and local mutex must be locked! 1131 * Object have to be reserved & global and local mutex must be locked!
1130 */ 1132 */
1131int radeon_vm_bo_update_pte(struct radeon_device *rdev, 1133int radeon_vm_bo_update(struct radeon_device *rdev,
1132 struct radeon_vm *vm, 1134 struct radeon_vm *vm,
1133 struct radeon_bo *bo, 1135 struct radeon_bo *bo,
1134 struct ttm_mem_reg *mem) 1136 struct ttm_mem_reg *mem)
1135{ 1137{
1136 struct radeon_ib ib; 1138 struct radeon_ib ib;
1137 struct radeon_bo_va *bo_va; 1139 struct radeon_bo_va *bo_va;
@@ -1176,6 +1178,8 @@ int radeon_vm_bo_update_pte(struct radeon_device *rdev,
1176 bo_va->valid = false; 1178 bo_va->valid = false;
1177 } 1179 }
1178 1180
1181 trace_radeon_vm_bo_update(bo_va);
1182
1179 nptes = radeon_bo_ngpu_pages(bo); 1183 nptes = radeon_bo_ngpu_pages(bo);
1180 1184
1181 /* assume two extra pdes in case the mapping overlaps the borders */ 1185 /* assume two extra pdes in case the mapping overlaps the borders */
@@ -1257,7 +1261,7 @@ int radeon_vm_bo_rmv(struct radeon_device *rdev,
1257 mutex_lock(&rdev->vm_manager.lock); 1261 mutex_lock(&rdev->vm_manager.lock);
1258 mutex_lock(&bo_va->vm->mutex); 1262 mutex_lock(&bo_va->vm->mutex);
1259 if (bo_va->soffset) { 1263 if (bo_va->soffset) {
1260 r = radeon_vm_bo_update_pte(rdev, bo_va->vm, bo_va->bo, NULL); 1264 r = radeon_vm_bo_update(rdev, bo_va->vm, bo_va->bo, NULL);
1261 } 1265 }
1262 mutex_unlock(&rdev->vm_manager.lock); 1266 mutex_unlock(&rdev->vm_manager.lock);
1263 list_del(&bo_va->vm_list); 1267 list_del(&bo_va->vm_list);
diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c
index d1385ccc672c..984097b907ef 100644
--- a/drivers/gpu/drm/radeon/radeon_pm.c
+++ b/drivers/gpu/drm/radeon/radeon_pm.c
@@ -537,8 +537,7 @@ static ssize_t radeon_hwmon_show_temp(struct device *dev,
537 struct device_attribute *attr, 537 struct device_attribute *attr,
538 char *buf) 538 char *buf)
539{ 539{
540 struct drm_device *ddev = dev_get_drvdata(dev); 540 struct radeon_device *rdev = dev_get_drvdata(dev);
541 struct radeon_device *rdev = ddev->dev_private;
542 int temp; 541 int temp;
543 542
544 if (rdev->asic->pm.get_temperature) 543 if (rdev->asic->pm.get_temperature)
@@ -553,8 +552,7 @@ static ssize_t radeon_hwmon_show_temp_thresh(struct device *dev,
553 struct device_attribute *attr, 552 struct device_attribute *attr,
554 char *buf) 553 char *buf)
555{ 554{
556 struct drm_device *ddev = dev_get_drvdata(dev); 555 struct radeon_device *rdev = dev_get_drvdata(dev);
557 struct radeon_device *rdev = ddev->dev_private;
558 int hyst = to_sensor_dev_attr(attr)->index; 556 int hyst = to_sensor_dev_attr(attr)->index;
559 int temp; 557 int temp;
560 558
@@ -566,23 +564,14 @@ static ssize_t radeon_hwmon_show_temp_thresh(struct device *dev,
566 return snprintf(buf, PAGE_SIZE, "%d\n", temp); 564 return snprintf(buf, PAGE_SIZE, "%d\n", temp);
567} 565}
568 566
569static ssize_t radeon_hwmon_show_name(struct device *dev,
570 struct device_attribute *attr,
571 char *buf)
572{
573 return sprintf(buf, "radeon\n");
574}
575
576static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, radeon_hwmon_show_temp, NULL, 0); 567static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, radeon_hwmon_show_temp, NULL, 0);
577static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, radeon_hwmon_show_temp_thresh, NULL, 0); 568static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, radeon_hwmon_show_temp_thresh, NULL, 0);
578static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO, radeon_hwmon_show_temp_thresh, NULL, 1); 569static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO, radeon_hwmon_show_temp_thresh, NULL, 1);
579static SENSOR_DEVICE_ATTR(name, S_IRUGO, radeon_hwmon_show_name, NULL, 0);
580 570
581static struct attribute *hwmon_attributes[] = { 571static struct attribute *hwmon_attributes[] = {
582 &sensor_dev_attr_temp1_input.dev_attr.attr, 572 &sensor_dev_attr_temp1_input.dev_attr.attr,
583 &sensor_dev_attr_temp1_crit.dev_attr.attr, 573 &sensor_dev_attr_temp1_crit.dev_attr.attr,
584 &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr, 574 &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr,
585 &sensor_dev_attr_name.dev_attr.attr,
586 NULL 575 NULL
587}; 576};
588 577
@@ -590,8 +579,7 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,
590 struct attribute *attr, int index) 579 struct attribute *attr, int index)
591{ 580{
592 struct device *dev = container_of(kobj, struct device, kobj); 581 struct device *dev = container_of(kobj, struct device, kobj);
593 struct drm_device *ddev = dev_get_drvdata(dev); 582 struct radeon_device *rdev = dev_get_drvdata(dev);
594 struct radeon_device *rdev = ddev->dev_private;
595 583
596 /* Skip limit attributes if DPM is not enabled */ 584 /* Skip limit attributes if DPM is not enabled */
597 if (rdev->pm.pm_method != PM_METHOD_DPM && 585 if (rdev->pm.pm_method != PM_METHOD_DPM &&
@@ -607,11 +595,15 @@ static const struct attribute_group hwmon_attrgroup = {
607 .is_visible = hwmon_attributes_visible, 595 .is_visible = hwmon_attributes_visible,
608}; 596};
609 597
598static const struct attribute_group *hwmon_groups[] = {
599 &hwmon_attrgroup,
600 NULL
601};
602
610static int radeon_hwmon_init(struct radeon_device *rdev) 603static int radeon_hwmon_init(struct radeon_device *rdev)
611{ 604{
612 int err = 0; 605 int err = 0;
613 606 struct device *hwmon_dev;
614 rdev->pm.int_hwmon_dev = NULL;
615 607
616 switch (rdev->pm.int_thermal_type) { 608 switch (rdev->pm.int_thermal_type) {
617 case THERMAL_TYPE_RV6XX: 609 case THERMAL_TYPE_RV6XX:
@@ -624,20 +616,13 @@ static int radeon_hwmon_init(struct radeon_device *rdev)
624 case THERMAL_TYPE_KV: 616 case THERMAL_TYPE_KV:
625 if (rdev->asic->pm.get_temperature == NULL) 617 if (rdev->asic->pm.get_temperature == NULL)
626 return err; 618 return err;
627 rdev->pm.int_hwmon_dev = hwmon_device_register(rdev->dev); 619 hwmon_dev = hwmon_device_register_with_groups(rdev->dev,
628 if (IS_ERR(rdev->pm.int_hwmon_dev)) { 620 "radeon", rdev,
629 err = PTR_ERR(rdev->pm.int_hwmon_dev); 621 hwmon_groups);
622 if (IS_ERR(hwmon_dev)) {
623 err = PTR_ERR(hwmon_dev);
630 dev_err(rdev->dev, 624 dev_err(rdev->dev,
631 "Unable to register hwmon device: %d\n", err); 625 "Unable to register hwmon device: %d\n", err);
632 break;
633 }
634 dev_set_drvdata(rdev->pm.int_hwmon_dev, rdev->ddev);
635 err = sysfs_create_group(&rdev->pm.int_hwmon_dev->kobj,
636 &hwmon_attrgroup);
637 if (err) {
638 dev_err(rdev->dev,
639 "Unable to create hwmon sysfs file: %d\n", err);
640 hwmon_device_unregister(rdev->dev);
641 } 626 }
642 break; 627 break;
643 default: 628 default:
@@ -647,14 +632,6 @@ static int radeon_hwmon_init(struct radeon_device *rdev)
647 return err; 632 return err;
648} 633}
649 634
650static void radeon_hwmon_fini(struct radeon_device *rdev)
651{
652 if (rdev->pm.int_hwmon_dev) {
653 sysfs_remove_group(&rdev->pm.int_hwmon_dev->kobj, &hwmon_attrgroup);
654 hwmon_device_unregister(rdev->pm.int_hwmon_dev);
655 }
656}
657
658static void radeon_dpm_thermal_work_handler(struct work_struct *work) 635static void radeon_dpm_thermal_work_handler(struct work_struct *work)
659{ 636{
660 struct radeon_device *rdev = 637 struct radeon_device *rdev =
@@ -1337,8 +1314,6 @@ static void radeon_pm_fini_old(struct radeon_device *rdev)
1337 1314
1338 if (rdev->pm.power_state) 1315 if (rdev->pm.power_state)
1339 kfree(rdev->pm.power_state); 1316 kfree(rdev->pm.power_state);
1340
1341 radeon_hwmon_fini(rdev);
1342} 1317}
1343 1318
1344static void radeon_pm_fini_dpm(struct radeon_device *rdev) 1319static void radeon_pm_fini_dpm(struct radeon_device *rdev)
@@ -1358,8 +1333,6 @@ static void radeon_pm_fini_dpm(struct radeon_device *rdev)
1358 1333
1359 if (rdev->pm.power_state) 1334 if (rdev->pm.power_state)
1360 kfree(rdev->pm.power_state); 1335 kfree(rdev->pm.power_state);
1361
1362 radeon_hwmon_fini(rdev);
1363} 1336}
1364 1337
1365void radeon_pm_fini(struct radeon_device *rdev) 1338void radeon_pm_fini(struct radeon_device *rdev)
diff --git a/drivers/gpu/drm/radeon/radeon_trace.h b/drivers/gpu/drm/radeon/radeon_trace.h
index 9f0e18172b6e..0473257d4078 100644
--- a/drivers/gpu/drm/radeon/radeon_trace.h
+++ b/drivers/gpu/drm/radeon/radeon_trace.h
@@ -47,6 +47,39 @@ TRACE_EVENT(radeon_cs,
47 __entry->fences) 47 __entry->fences)
48); 48);
49 49
50TRACE_EVENT(radeon_vm_grab_id,
51 TP_PROTO(unsigned vmid, int ring),
52 TP_ARGS(vmid, ring),
53 TP_STRUCT__entry(
54 __field(u32, vmid)
55 __field(u32, ring)
56 ),
57
58 TP_fast_assign(
59 __entry->vmid = vmid;
60 __entry->ring = ring;
61 ),
62 TP_printk("vmid=%u, ring=%u", __entry->vmid, __entry->ring)
63);
64
65TRACE_EVENT(radeon_vm_bo_update,
66 TP_PROTO(struct radeon_bo_va *bo_va),
67 TP_ARGS(bo_va),
68 TP_STRUCT__entry(
69 __field(u64, soffset)
70 __field(u64, eoffset)
71 __field(u32, flags)
72 ),
73
74 TP_fast_assign(
75 __entry->soffset = bo_va->soffset;
76 __entry->eoffset = bo_va->eoffset;
77 __entry->flags = bo_va->flags;
78 ),
79 TP_printk("soffs=%010llx, eoffs=%010llx, flags=%08x",
80 __entry->soffset, __entry->eoffset, __entry->flags)
81);
82
50TRACE_EVENT(radeon_vm_set_page, 83TRACE_EVENT(radeon_vm_set_page,
51 TP_PROTO(uint64_t pe, uint64_t addr, unsigned count, 84 TP_PROTO(uint64_t pe, uint64_t addr, unsigned count,
52 uint32_t incr, uint32_t flags), 85 uint32_t incr, uint32_t flags),
diff --git a/drivers/gpu/drm/radeon/reg_srcs/cayman b/drivers/gpu/drm/radeon/reg_srcs/cayman
index a072fa8c46b0..d46b58d078aa 100644
--- a/drivers/gpu/drm/radeon/reg_srcs/cayman
+++ b/drivers/gpu/drm/radeon/reg_srcs/cayman
@@ -21,7 +21,7 @@ cayman 0x9400
210x000089AC VGT_COMPUTE_THREAD_GOURP_SIZE 210x000089AC VGT_COMPUTE_THREAD_GOURP_SIZE
220x000089B0 VGT_HS_OFFCHIP_PARAM 220x000089B0 VGT_HS_OFFCHIP_PARAM
230x00008A14 PA_CL_ENHANCE 230x00008A14 PA_CL_ENHANCE
240x00008A60 PA_SC_LINE_STIPPLE_VALUE 240x00008A60 PA_SU_LINE_STIPPLE_VALUE
250x00008B10 PA_SC_LINE_STIPPLE_STATE 250x00008B10 PA_SC_LINE_STIPPLE_STATE
260x00008BF0 PA_SC_ENHANCE 260x00008BF0 PA_SC_ENHANCE
270x00008D8C SQ_DYN_GPR_CNTL_PS_FLUSH_REQ 270x00008D8C SQ_DYN_GPR_CNTL_PS_FLUSH_REQ
@@ -532,7 +532,7 @@ cayman 0x9400
5320x00028B84 PA_SU_POLY_OFFSET_FRONT_OFFSET 5320x00028B84 PA_SU_POLY_OFFSET_FRONT_OFFSET
5330x00028B88 PA_SU_POLY_OFFSET_BACK_SCALE 5330x00028B88 PA_SU_POLY_OFFSET_BACK_SCALE
5340x00028B8C PA_SU_POLY_OFFSET_BACK_OFFSET 5340x00028B8C PA_SU_POLY_OFFSET_BACK_OFFSET
5350x00028B74 VGT_GS_INSTANCE_CNT 5350x00028B90 VGT_GS_INSTANCE_CNT
5360x00028BD4 PA_SC_CENTROID_PRIORITY_0 5360x00028BD4 PA_SC_CENTROID_PRIORITY_0
5370x00028BD8 PA_SC_CENTROID_PRIORITY_1 5370x00028BD8 PA_SC_CENTROID_PRIORITY_1
5380x00028BDC PA_SC_LINE_CNTL 5380x00028BDC PA_SC_LINE_CNTL
diff --git a/drivers/gpu/drm/radeon/reg_srcs/evergreen b/drivers/gpu/drm/radeon/reg_srcs/evergreen
index b912a37689bf..57745c8761c8 100644
--- a/drivers/gpu/drm/radeon/reg_srcs/evergreen
+++ b/drivers/gpu/drm/radeon/reg_srcs/evergreen
@@ -22,7 +22,7 @@ evergreen 0x9400
220x000089A4 VGT_COMPUTE_START_Z 220x000089A4 VGT_COMPUTE_START_Z
230x000089AC VGT_COMPUTE_THREAD_GOURP_SIZE 230x000089AC VGT_COMPUTE_THREAD_GOURP_SIZE
240x00008A14 PA_CL_ENHANCE 240x00008A14 PA_CL_ENHANCE
250x00008A60 PA_SC_LINE_STIPPLE_VALUE 250x00008A60 PA_SU_LINE_STIPPLE_VALUE
260x00008B10 PA_SC_LINE_STIPPLE_STATE 260x00008B10 PA_SC_LINE_STIPPLE_STATE
270x00008BF0 PA_SC_ENHANCE 270x00008BF0 PA_SC_ENHANCE
280x00008D8C SQ_DYN_GPR_CNTL_PS_FLUSH_REQ 280x00008D8C SQ_DYN_GPR_CNTL_PS_FLUSH_REQ
@@ -545,7 +545,7 @@ evergreen 0x9400
5450x00028B84 PA_SU_POLY_OFFSET_FRONT_OFFSET 5450x00028B84 PA_SU_POLY_OFFSET_FRONT_OFFSET
5460x00028B88 PA_SU_POLY_OFFSET_BACK_SCALE 5460x00028B88 PA_SU_POLY_OFFSET_BACK_SCALE
5470x00028B8C PA_SU_POLY_OFFSET_BACK_OFFSET 5470x00028B8C PA_SU_POLY_OFFSET_BACK_OFFSET
5480x00028B74 VGT_GS_INSTANCE_CNT 5480x00028B90 VGT_GS_INSTANCE_CNT
5490x00028C00 PA_SC_LINE_CNTL 5490x00028C00 PA_SC_LINE_CNTL
5500x00028C08 PA_SU_VTX_CNTL 5500x00028C08 PA_SU_VTX_CNTL
5510x00028C0C PA_CL_GB_VERT_CLIP_ADJ 5510x00028C0C PA_CL_GB_VERT_CLIP_ADJ
diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
index 6a64ccaa0695..a36736dab5e0 100644
--- a/drivers/gpu/drm/radeon/si.c
+++ b/drivers/gpu/drm/radeon/si.c
@@ -3882,8 +3882,15 @@ static int si_mc_init(struct radeon_device *rdev)
3882 rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0); 3882 rdev->mc.aper_base = pci_resource_start(rdev->pdev, 0);
3883 rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0); 3883 rdev->mc.aper_size = pci_resource_len(rdev->pdev, 0);
3884 /* size in MB on si */ 3884 /* size in MB on si */
3885 rdev->mc.mc_vram_size = RREG32(CONFIG_MEMSIZE) * 1024ULL * 1024ULL; 3885 tmp = RREG32(CONFIG_MEMSIZE);
3886 rdev->mc.real_vram_size = RREG32(CONFIG_MEMSIZE) * 1024ULL * 1024ULL; 3886 /* some boards may have garbage in the upper 16 bits */
3887 if (tmp & 0xffff0000) {
3888 DRM_INFO("Probable bad vram size: 0x%08x\n", tmp);
3889 if (tmp & 0xffff)
3890 tmp &= 0xffff;
3891 }
3892 rdev->mc.mc_vram_size = tmp * 1024ULL * 1024ULL;
3893 rdev->mc.real_vram_size = rdev->mc.mc_vram_size;
3887 rdev->mc.visible_vram_size = rdev->mc.aper_size; 3894 rdev->mc.visible_vram_size = rdev->mc.aper_size;
3888 si_vram_gtt_location(rdev, &rdev->mc); 3895 si_vram_gtt_location(rdev, &rdev->mc);
3889 radeon_update_bandwidth_info(rdev); 3896 radeon_update_bandwidth_info(rdev);
diff --git a/drivers/gpu/drm/tegra/Kconfig b/drivers/gpu/drm/tegra/Kconfig
index 8961ba6a34b8..8db9b3bce001 100644
--- a/drivers/gpu/drm/tegra/Kconfig
+++ b/drivers/gpu/drm/tegra/Kconfig
@@ -2,6 +2,7 @@ config DRM_TEGRA
2 bool "NVIDIA Tegra DRM" 2 bool "NVIDIA Tegra DRM"
3 depends on ARCH_TEGRA || ARCH_MULTIPLATFORM 3 depends on ARCH_TEGRA || ARCH_MULTIPLATFORM
4 depends on DRM 4 depends on DRM
5 depends on RESET_CONTROLLER
5 select TEGRA_HOST1X 6 select TEGRA_HOST1X
6 select DRM_KMS_HELPER 7 select DRM_KMS_HELPER
7 select DRM_KMS_FB_HELPER 8 select DRM_KMS_FB_HELPER
diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index ae1cb31ead7e..cd7f1e499616 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -8,8 +8,8 @@
8 */ 8 */
9 9
10#include <linux/clk.h> 10#include <linux/clk.h>
11#include <linux/clk/tegra.h>
12#include <linux/debugfs.h> 11#include <linux/debugfs.h>
12#include <linux/reset.h>
13 13
14#include "dc.h" 14#include "dc.h"
15#include "drm.h" 15#include "drm.h"
@@ -712,7 +712,7 @@ static void tegra_crtc_prepare(struct drm_crtc *crtc)
712 unsigned long value; 712 unsigned long value;
713 713
714 /* hardware initialization */ 714 /* hardware initialization */
715 tegra_periph_reset_deassert(dc->clk); 715 reset_control_deassert(dc->rst);
716 usleep_range(10000, 20000); 716 usleep_range(10000, 20000);
717 717
718 if (dc->pipe) 718 if (dc->pipe)
@@ -1187,6 +1187,12 @@ static int tegra_dc_probe(struct platform_device *pdev)
1187 return PTR_ERR(dc->clk); 1187 return PTR_ERR(dc->clk);
1188 } 1188 }
1189 1189
1190 dc->rst = devm_reset_control_get(&pdev->dev, "dc");
1191 if (IS_ERR(dc->rst)) {
1192 dev_err(&pdev->dev, "failed to get reset\n");
1193 return PTR_ERR(dc->rst);
1194 }
1195
1190 err = clk_prepare_enable(dc->clk); 1196 err = clk_prepare_enable(dc->clk);
1191 if (err < 0) 1197 if (err < 0)
1192 return err; 1198 return err;
diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index 28e178137718..07eba596d458 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -135,11 +135,11 @@ int tegra_drm_submit(struct tegra_drm_context *context,
135 unsigned int num_relocs = args->num_relocs; 135 unsigned int num_relocs = args->num_relocs;
136 unsigned int num_waitchks = args->num_waitchks; 136 unsigned int num_waitchks = args->num_waitchks;
137 struct drm_tegra_cmdbuf __user *cmdbufs = 137 struct drm_tegra_cmdbuf __user *cmdbufs =
138 (void * __user)(uintptr_t)args->cmdbufs; 138 (void __user *)(uintptr_t)args->cmdbufs;
139 struct drm_tegra_reloc __user *relocs = 139 struct drm_tegra_reloc __user *relocs =
140 (void * __user)(uintptr_t)args->relocs; 140 (void __user *)(uintptr_t)args->relocs;
141 struct drm_tegra_waitchk __user *waitchks = 141 struct drm_tegra_waitchk __user *waitchks =
142 (void * __user)(uintptr_t)args->waitchks; 142 (void __user *)(uintptr_t)args->waitchks;
143 struct drm_tegra_syncpt syncpt; 143 struct drm_tegra_syncpt syncpt;
144 struct host1x_job *job; 144 struct host1x_job *job;
145 int err; 145 int err;
@@ -163,9 +163,10 @@ int tegra_drm_submit(struct tegra_drm_context *context,
163 struct drm_tegra_cmdbuf cmdbuf; 163 struct drm_tegra_cmdbuf cmdbuf;
164 struct host1x_bo *bo; 164 struct host1x_bo *bo;
165 165
166 err = copy_from_user(&cmdbuf, cmdbufs, sizeof(cmdbuf)); 166 if (copy_from_user(&cmdbuf, cmdbufs, sizeof(cmdbuf))) {
167 if (err) 167 err = -EFAULT;
168 goto fail; 168 goto fail;
169 }
169 170
170 bo = host1x_bo_lookup(drm, file, cmdbuf.handle); 171 bo = host1x_bo_lookup(drm, file, cmdbuf.handle);
171 if (!bo) { 172 if (!bo) {
@@ -178,10 +179,11 @@ int tegra_drm_submit(struct tegra_drm_context *context,
178 cmdbufs++; 179 cmdbufs++;
179 } 180 }
180 181
181 err = copy_from_user(job->relocarray, relocs, 182 if (copy_from_user(job->relocarray, relocs,
182 sizeof(*relocs) * num_relocs); 183 sizeof(*relocs) * num_relocs)) {
183 if (err) 184 err = -EFAULT;
184 goto fail; 185 goto fail;
186 }
185 187
186 while (num_relocs--) { 188 while (num_relocs--) {
187 struct host1x_reloc *reloc = &job->relocarray[num_relocs]; 189 struct host1x_reloc *reloc = &job->relocarray[num_relocs];
@@ -199,15 +201,17 @@ int tegra_drm_submit(struct tegra_drm_context *context,
199 } 201 }
200 } 202 }
201 203
202 err = copy_from_user(job->waitchk, waitchks, 204 if (copy_from_user(job->waitchk, waitchks,
203 sizeof(*waitchks) * num_waitchks); 205 sizeof(*waitchks) * num_waitchks)) {
204 if (err) 206 err = -EFAULT;
205 goto fail; 207 goto fail;
208 }
206 209
207 err = copy_from_user(&syncpt, (void * __user)(uintptr_t)args->syncpts, 210 if (copy_from_user(&syncpt, (void __user *)(uintptr_t)args->syncpts,
208 sizeof(syncpt)); 211 sizeof(syncpt))) {
209 if (err) 212 err = -EFAULT;
210 goto fail; 213 goto fail;
214 }
211 215
212 job->is_addr_reg = context->client->ops->is_addr_reg; 216 job->is_addr_reg = context->client->ops->is_addr_reg;
213 job->syncpt_incrs = syncpt.incrs; 217 job->syncpt_incrs = syncpt.incrs;
@@ -573,7 +577,7 @@ static void tegra_debugfs_cleanup(struct drm_minor *minor)
573} 577}
574#endif 578#endif
575 579
576struct drm_driver tegra_drm_driver = { 580static struct drm_driver tegra_drm_driver = {
577 .driver_features = DRIVER_MODESET | DRIVER_GEM, 581 .driver_features = DRIVER_MODESET | DRIVER_GEM,
578 .load = tegra_drm_load, 582 .load = tegra_drm_load,
579 .unload = tegra_drm_unload, 583 .unload = tegra_drm_unload,
diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h
index fdfe259ed7f8..266aae08a3bd 100644
--- a/drivers/gpu/drm/tegra/drm.h
+++ b/drivers/gpu/drm/tegra/drm.h
@@ -19,6 +19,8 @@
19#include <drm/drm_fb_helper.h> 19#include <drm/drm_fb_helper.h>
20#include <drm/drm_fixed.h> 20#include <drm/drm_fixed.h>
21 21
22struct reset_control;
23
22struct tegra_fb { 24struct tegra_fb {
23 struct drm_framebuffer base; 25 struct drm_framebuffer base;
24 struct tegra_bo **planes; 26 struct tegra_bo **planes;
@@ -93,6 +95,7 @@ struct tegra_dc {
93 int pipe; 95 int pipe;
94 96
95 struct clk *clk; 97 struct clk *clk;
98 struct reset_control *rst;
96 void __iomem *regs; 99 void __iomem *regs;
97 int irq; 100 int irq;
98 101
@@ -116,7 +119,7 @@ host1x_client_to_dc(struct host1x_client *client)
116 119
117static inline struct tegra_dc *to_tegra_dc(struct drm_crtc *crtc) 120static inline struct tegra_dc *to_tegra_dc(struct drm_crtc *crtc)
118{ 121{
119 return container_of(crtc, struct tegra_dc, base); 122 return crtc ? container_of(crtc, struct tegra_dc, base) : NULL;
120} 123}
121 124
122static inline void tegra_dc_writel(struct tegra_dc *dc, unsigned long value, 125static inline void tegra_dc_writel(struct tegra_dc *dc, unsigned long value,
diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c
index 490f7719e317..a3835e7de184 100644
--- a/drivers/gpu/drm/tegra/fb.c
+++ b/drivers/gpu/drm/tegra/fb.c
@@ -247,7 +247,7 @@ static int tegra_fbdev_probe(struct drm_fb_helper *helper,
247 info->var.yoffset * fb->pitches[0]; 247 info->var.yoffset * fb->pitches[0];
248 248
249 drm->mode_config.fb_base = (resource_size_t)bo->paddr; 249 drm->mode_config.fb_base = (resource_size_t)bo->paddr;
250 info->screen_base = bo->vaddr + offset; 250 info->screen_base = (void __iomem *)bo->vaddr + offset;
251 info->screen_size = size; 251 info->screen_size = size;
252 info->fix.smem_start = (unsigned long)(bo->paddr + offset); 252 info->fix.smem_start = (unsigned long)(bo->paddr + offset);
253 info->fix.smem_len = size; 253 info->fix.smem_len = size;
diff --git a/drivers/gpu/drm/tegra/gr3d.c b/drivers/gpu/drm/tegra/gr3d.c
index 4cec8f526af7..0cbb24b1ae04 100644
--- a/drivers/gpu/drm/tegra/gr3d.c
+++ b/drivers/gpu/drm/tegra/gr3d.c
@@ -11,6 +11,7 @@
11#include <linux/host1x.h> 11#include <linux/host1x.h>
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <linux/reset.h>
14#include <linux/tegra-powergate.h> 15#include <linux/tegra-powergate.h>
15 16
16#include "drm.h" 17#include "drm.h"
@@ -22,6 +23,8 @@ struct gr3d {
22 struct host1x_channel *channel; 23 struct host1x_channel *channel;
23 struct clk *clk_secondary; 24 struct clk *clk_secondary;
24 struct clk *clk; 25 struct clk *clk;
26 struct reset_control *rst_secondary;
27 struct reset_control *rst;
25 28
26 DECLARE_BITMAP(addr_regs, GR3D_NUM_REGS); 29 DECLARE_BITMAP(addr_regs, GR3D_NUM_REGS);
27}; 30};
@@ -255,15 +258,29 @@ static int gr3d_probe(struct platform_device *pdev)
255 return PTR_ERR(gr3d->clk); 258 return PTR_ERR(gr3d->clk);
256 } 259 }
257 260
261 gr3d->rst = devm_reset_control_get(&pdev->dev, "3d");
262 if (IS_ERR(gr3d->rst)) {
263 dev_err(&pdev->dev, "cannot get reset\n");
264 return PTR_ERR(gr3d->rst);
265 }
266
258 if (of_device_is_compatible(np, "nvidia,tegra30-gr3d")) { 267 if (of_device_is_compatible(np, "nvidia,tegra30-gr3d")) {
259 gr3d->clk_secondary = devm_clk_get(&pdev->dev, "3d2"); 268 gr3d->clk_secondary = devm_clk_get(&pdev->dev, "3d2");
260 if (IS_ERR(gr3d->clk)) { 269 if (IS_ERR(gr3d->clk)) {
261 dev_err(&pdev->dev, "cannot get secondary clock\n"); 270 dev_err(&pdev->dev, "cannot get secondary clock\n");
262 return PTR_ERR(gr3d->clk); 271 return PTR_ERR(gr3d->clk);
263 } 272 }
273
274 gr3d->rst_secondary = devm_reset_control_get(&pdev->dev,
275 "3d2");
276 if (IS_ERR(gr3d->rst_secondary)) {
277 dev_err(&pdev->dev, "cannot get secondary reset\n");
278 return PTR_ERR(gr3d->rst_secondary);
279 }
264 } 280 }
265 281
266 err = tegra_powergate_sequence_power_up(TEGRA_POWERGATE_3D, gr3d->clk); 282 err = tegra_powergate_sequence_power_up(TEGRA_POWERGATE_3D, gr3d->clk,
283 gr3d->rst);
267 if (err < 0) { 284 if (err < 0) {
268 dev_err(&pdev->dev, "failed to power up 3D unit\n"); 285 dev_err(&pdev->dev, "failed to power up 3D unit\n");
269 return err; 286 return err;
@@ -271,7 +288,8 @@ static int gr3d_probe(struct platform_device *pdev)
271 288
272 if (gr3d->clk_secondary) { 289 if (gr3d->clk_secondary) {
273 err = tegra_powergate_sequence_power_up(TEGRA_POWERGATE_3D1, 290 err = tegra_powergate_sequence_power_up(TEGRA_POWERGATE_3D1,
274 gr3d->clk_secondary); 291 gr3d->clk_secondary,
292 gr3d->rst_secondary);
275 if (err < 0) { 293 if (err < 0) {
276 dev_err(&pdev->dev, 294 dev_err(&pdev->dev,
277 "failed to power up secondary 3D unit\n"); 295 "failed to power up secondary 3D unit\n");
diff --git a/drivers/gpu/drm/tegra/hdmi.c b/drivers/gpu/drm/tegra/hdmi.c
index 0cd9bc2056e8..7f6253ea5cb5 100644
--- a/drivers/gpu/drm/tegra/hdmi.c
+++ b/drivers/gpu/drm/tegra/hdmi.c
@@ -8,10 +8,10 @@
8 */ 8 */
9 9
10#include <linux/clk.h> 10#include <linux/clk.h>
11#include <linux/clk/tegra.h>
12#include <linux/debugfs.h> 11#include <linux/debugfs.h>
13#include <linux/hdmi.h> 12#include <linux/hdmi.h>
14#include <linux/regulator/consumer.h> 13#include <linux/regulator/consumer.h>
14#include <linux/reset.h>
15 15
16#include "hdmi.h" 16#include "hdmi.h"
17#include "drm.h" 17#include "drm.h"
@@ -49,6 +49,7 @@ struct tegra_hdmi {
49 49
50 struct clk *clk_parent; 50 struct clk *clk_parent;
51 struct clk *clk; 51 struct clk *clk;
52 struct reset_control *rst;
52 53
53 const struct tegra_hdmi_config *config; 54 const struct tegra_hdmi_config *config;
54 55
@@ -731,9 +732,9 @@ static int tegra_output_hdmi_enable(struct tegra_output *output)
731 return err; 732 return err;
732 } 733 }
733 734
734 tegra_periph_reset_assert(hdmi->clk); 735 reset_control_assert(hdmi->rst);
735 usleep_range(1000, 2000); 736 usleep_range(1000, 2000);
736 tegra_periph_reset_deassert(hdmi->clk); 737 reset_control_deassert(hdmi->rst);
737 738
738 tegra_dc_writel(dc, VSYNC_H_POSITION(1), 739 tegra_dc_writel(dc, VSYNC_H_POSITION(1),
739 DC_DISP_DISP_TIMING_OPTIONS); 740 DC_DISP_DISP_TIMING_OPTIONS);
@@ -912,7 +913,7 @@ static int tegra_output_hdmi_disable(struct tegra_output *output)
912{ 913{
913 struct tegra_hdmi *hdmi = to_hdmi(output); 914 struct tegra_hdmi *hdmi = to_hdmi(output);
914 915
915 tegra_periph_reset_assert(hdmi->clk); 916 reset_control_assert(hdmi->rst);
916 clk_disable(hdmi->clk); 917 clk_disable(hdmi->clk);
917 regulator_disable(hdmi->pll); 918 regulator_disable(hdmi->pll);
918 919
@@ -1338,6 +1339,12 @@ static int tegra_hdmi_probe(struct platform_device *pdev)
1338 return PTR_ERR(hdmi->clk); 1339 return PTR_ERR(hdmi->clk);
1339 } 1340 }
1340 1341
1342 hdmi->rst = devm_reset_control_get(&pdev->dev, "hdmi");
1343 if (IS_ERR(hdmi->rst)) {
1344 dev_err(&pdev->dev, "failed to get reset\n");
1345 return PTR_ERR(hdmi->rst);
1346 }
1347
1341 err = clk_prepare(hdmi->clk); 1348 err = clk_prepare(hdmi->clk);
1342 if (err < 0) 1349 if (err < 0)
1343 return err; 1350 return err;
diff --git a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c
index ba47ca4fb880..3b29018913a5 100644
--- a/drivers/gpu/drm/tegra/rgb.c
+++ b/drivers/gpu/drm/tegra/rgb.c
@@ -14,6 +14,8 @@
14 14
15struct tegra_rgb { 15struct tegra_rgb {
16 struct tegra_output output; 16 struct tegra_output output;
17 struct tegra_dc *dc;
18
17 struct clk *clk_parent; 19 struct clk *clk_parent;
18 struct clk *clk; 20 struct clk *clk;
19}; 21};
@@ -84,18 +86,18 @@ static void tegra_dc_write_regs(struct tegra_dc *dc,
84 86
85static int tegra_output_rgb_enable(struct tegra_output *output) 87static int tegra_output_rgb_enable(struct tegra_output *output)
86{ 88{
87 struct tegra_dc *dc = to_tegra_dc(output->encoder.crtc); 89 struct tegra_rgb *rgb = to_rgb(output);
88 90
89 tegra_dc_write_regs(dc, rgb_enable, ARRAY_SIZE(rgb_enable)); 91 tegra_dc_write_regs(rgb->dc, rgb_enable, ARRAY_SIZE(rgb_enable));
90 92
91 return 0; 93 return 0;
92} 94}
93 95
94static int tegra_output_rgb_disable(struct tegra_output *output) 96static int tegra_output_rgb_disable(struct tegra_output *output)
95{ 97{
96 struct tegra_dc *dc = to_tegra_dc(output->encoder.crtc); 98 struct tegra_rgb *rgb = to_rgb(output);
97 99
98 tegra_dc_write_regs(dc, rgb_disable, ARRAY_SIZE(rgb_disable)); 100 tegra_dc_write_regs(rgb->dc, rgb_disable, ARRAY_SIZE(rgb_disable));
99 101
100 return 0; 102 return 0;
101} 103}
@@ -146,6 +148,7 @@ int tegra_dc_rgb_probe(struct tegra_dc *dc)
146 148
147 rgb->output.dev = dc->dev; 149 rgb->output.dev = dc->dev;
148 rgb->output.of_node = np; 150 rgb->output.of_node = np;
151 rgb->dc = dc;
149 152
150 err = tegra_output_probe(&rgb->output); 153 err = tegra_output_probe(&rgb->output);
151 if (err < 0) 154 if (err < 0)
diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c
index 24ffbe990736..8d67b943ac05 100644
--- a/drivers/gpu/drm/udl/udl_gem.c
+++ b/drivers/gpu/drm/udl/udl_gem.c
@@ -125,6 +125,12 @@ static int udl_gem_get_pages(struct udl_gem_object *obj, gfp_t gfpmask)
125 125
126static void udl_gem_put_pages(struct udl_gem_object *obj) 126static void udl_gem_put_pages(struct udl_gem_object *obj)
127{ 127{
128 if (obj->base.import_attach) {
129 drm_free_large(obj->pages);
130 obj->pages = NULL;
131 return;
132 }
133
128 drm_gem_put_pages(&obj->base, obj->pages, false, false); 134 drm_gem_put_pages(&obj->base, obj->pages, false, false);
129 obj->pages = NULL; 135 obj->pages = NULL;
130} 136}
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c
index 7776e6f0aef6..0489c6152482 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c
@@ -150,6 +150,8 @@ struct vmw_ttm_tt {
150 bool mapped; 150 bool mapped;
151}; 151};
152 152
153const size_t vmw_tt_size = sizeof(struct vmw_ttm_tt);
154
153/** 155/**
154 * Helper functions to advance a struct vmw_piter iterator. 156 * Helper functions to advance a struct vmw_piter iterator.
155 * 157 *
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index db85985c7086..20890ad8408b 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -615,6 +615,7 @@ extern int vmw_mmap(struct file *filp, struct vm_area_struct *vma);
615 * TTM buffer object driver - vmwgfx_buffer.c 615 * TTM buffer object driver - vmwgfx_buffer.c
616 */ 616 */
617 617
618extern const size_t vmw_tt_size;
618extern struct ttm_placement vmw_vram_placement; 619extern struct ttm_placement vmw_vram_placement;
619extern struct ttm_placement vmw_vram_ne_placement; 620extern struct ttm_placement vmw_vram_ne_placement;
620extern struct ttm_placement vmw_vram_sys_placement; 621extern struct ttm_placement vmw_vram_sys_placement;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index ecb3d867b426..03f1c2038631 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -75,6 +75,7 @@ void vmw_display_unit_cleanup(struct vmw_display_unit *du)
75 vmw_surface_unreference(&du->cursor_surface); 75 vmw_surface_unreference(&du->cursor_surface);
76 if (du->cursor_dmabuf) 76 if (du->cursor_dmabuf)
77 vmw_dmabuf_unreference(&du->cursor_dmabuf); 77 vmw_dmabuf_unreference(&du->cursor_dmabuf);
78 drm_sysfs_connector_remove(&du->connector);
78 drm_crtc_cleanup(&du->crtc); 79 drm_crtc_cleanup(&du->crtc);
79 drm_encoder_cleanup(&du->encoder); 80 drm_encoder_cleanup(&du->encoder);
80 drm_connector_cleanup(&du->connector); 81 drm_connector_cleanup(&du->connector);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
index 79f7e8e60529..a055a26819c2 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
@@ -260,6 +260,7 @@ static int vmw_ldu_crtc_set_config(struct drm_mode_set *set)
260 connector->encoder = NULL; 260 connector->encoder = NULL;
261 encoder->crtc = NULL; 261 encoder->crtc = NULL;
262 crtc->fb = NULL; 262 crtc->fb = NULL;
263 crtc->enabled = false;
263 264
264 vmw_ldu_del_active(dev_priv, ldu); 265 vmw_ldu_del_active(dev_priv, ldu);
265 266
@@ -285,6 +286,7 @@ static int vmw_ldu_crtc_set_config(struct drm_mode_set *set)
285 crtc->x = set->x; 286 crtc->x = set->x;
286 crtc->y = set->y; 287 crtc->y = set->y;
287 crtc->mode = *mode; 288 crtc->mode = *mode;
289 crtc->enabled = true;
288 290
289 vmw_ldu_add_active(dev_priv, ldu, vfb); 291 vmw_ldu_add_active(dev_priv, ldu, vfb);
290 292
@@ -369,6 +371,8 @@ static int vmw_ldu_init(struct vmw_private *dev_priv, unsigned unit)
369 encoder->possible_crtcs = (1 << unit); 371 encoder->possible_crtcs = (1 << unit);
370 encoder->possible_clones = 0; 372 encoder->possible_clones = 0;
371 373
374 (void) drm_sysfs_connector_add(connector);
375
372 drm_crtc_init(dev, crtc, &vmw_legacy_crtc_funcs); 376 drm_crtc_init(dev, crtc, &vmw_legacy_crtc_funcs);
373 377
374 drm_mode_crtc_set_gamma_size(crtc, 256); 378 drm_mode_crtc_set_gamma_size(crtc, 256);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
index efe2b74c5eb1..9b5ea2ac7ddf 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
@@ -352,6 +352,38 @@ int vmw_user_lookup_handle(struct vmw_private *dev_priv,
352/** 352/**
353 * Buffer management. 353 * Buffer management.
354 */ 354 */
355
356/**
357 * vmw_dmabuf_acc_size - Calculate the pinned memory usage of buffers
358 *
359 * @dev_priv: Pointer to a struct vmw_private identifying the device.
360 * @size: The requested buffer size.
361 * @user: Whether this is an ordinary dma buffer or a user dma buffer.
362 */
363static size_t vmw_dmabuf_acc_size(struct vmw_private *dev_priv, size_t size,
364 bool user)
365{
366 static size_t struct_size, user_struct_size;
367 size_t num_pages = PAGE_ALIGN(size) >> PAGE_SHIFT;
368 size_t page_array_size = ttm_round_pot(num_pages * sizeof(void *));
369
370 if (unlikely(struct_size == 0)) {
371 size_t backend_size = ttm_round_pot(vmw_tt_size);
372
373 struct_size = backend_size +
374 ttm_round_pot(sizeof(struct vmw_dma_buffer));
375 user_struct_size = backend_size +
376 ttm_round_pot(sizeof(struct vmw_user_dma_buffer));
377 }
378
379 if (dev_priv->map_mode == vmw_dma_alloc_coherent)
380 page_array_size +=
381 ttm_round_pot(num_pages * sizeof(dma_addr_t));
382
383 return ((user) ? user_struct_size : struct_size) +
384 page_array_size;
385}
386
355void vmw_dmabuf_bo_free(struct ttm_buffer_object *bo) 387void vmw_dmabuf_bo_free(struct ttm_buffer_object *bo)
356{ 388{
357 struct vmw_dma_buffer *vmw_bo = vmw_dma_buffer(bo); 389 struct vmw_dma_buffer *vmw_bo = vmw_dma_buffer(bo);
@@ -359,6 +391,13 @@ void vmw_dmabuf_bo_free(struct ttm_buffer_object *bo)
359 kfree(vmw_bo); 391 kfree(vmw_bo);
360} 392}
361 393
394static void vmw_user_dmabuf_destroy(struct ttm_buffer_object *bo)
395{
396 struct vmw_user_dma_buffer *vmw_user_bo = vmw_user_dma_buffer(bo);
397
398 ttm_prime_object_kfree(vmw_user_bo, prime);
399}
400
362int vmw_dmabuf_init(struct vmw_private *dev_priv, 401int vmw_dmabuf_init(struct vmw_private *dev_priv,
363 struct vmw_dma_buffer *vmw_bo, 402 struct vmw_dma_buffer *vmw_bo,
364 size_t size, struct ttm_placement *placement, 403 size_t size, struct ttm_placement *placement,
@@ -368,28 +407,23 @@ int vmw_dmabuf_init(struct vmw_private *dev_priv,
368 struct ttm_bo_device *bdev = &dev_priv->bdev; 407 struct ttm_bo_device *bdev = &dev_priv->bdev;
369 size_t acc_size; 408 size_t acc_size;
370 int ret; 409 int ret;
410 bool user = (bo_free == &vmw_user_dmabuf_destroy);
371 411
372 BUG_ON(!bo_free); 412 BUG_ON(!bo_free && (!user && (bo_free != vmw_dmabuf_bo_free)));
373 413
374 acc_size = ttm_bo_acc_size(bdev, size, sizeof(struct vmw_dma_buffer)); 414 acc_size = vmw_dmabuf_acc_size(dev_priv, size, user);
375 memset(vmw_bo, 0, sizeof(*vmw_bo)); 415 memset(vmw_bo, 0, sizeof(*vmw_bo));
376 416
377 INIT_LIST_HEAD(&vmw_bo->res_list); 417 INIT_LIST_HEAD(&vmw_bo->res_list);
378 418
379 ret = ttm_bo_init(bdev, &vmw_bo->base, size, 419 ret = ttm_bo_init(bdev, &vmw_bo->base, size,
380 ttm_bo_type_device, placement, 420 (user) ? ttm_bo_type_device :
421 ttm_bo_type_kernel, placement,
381 0, interruptible, 422 0, interruptible,
382 NULL, acc_size, NULL, bo_free); 423 NULL, acc_size, NULL, bo_free);
383 return ret; 424 return ret;
384} 425}
385 426
386static void vmw_user_dmabuf_destroy(struct ttm_buffer_object *bo)
387{
388 struct vmw_user_dma_buffer *vmw_user_bo = vmw_user_dma_buffer(bo);
389
390 ttm_prime_object_kfree(vmw_user_bo, prime);
391}
392
393static void vmw_user_dmabuf_release(struct ttm_base_object **p_base) 427static void vmw_user_dmabuf_release(struct ttm_base_object **p_base)
394{ 428{
395 struct vmw_user_dma_buffer *vmw_user_bo; 429 struct vmw_user_dma_buffer *vmw_user_bo;
@@ -781,54 +815,55 @@ err_ref:
781} 815}
782 816
783 817
818/**
819 * vmw_dumb_create - Create a dumb kms buffer
820 *
821 * @file_priv: Pointer to a struct drm_file identifying the caller.
822 * @dev: Pointer to the drm device.
823 * @args: Pointer to a struct drm_mode_create_dumb structure
824 *
825 * This is a driver callback for the core drm create_dumb functionality.
826 * Note that this is very similar to the vmw_dmabuf_alloc ioctl, except
827 * that the arguments have a different format.
828 */
784int vmw_dumb_create(struct drm_file *file_priv, 829int vmw_dumb_create(struct drm_file *file_priv,
785 struct drm_device *dev, 830 struct drm_device *dev,
786 struct drm_mode_create_dumb *args) 831 struct drm_mode_create_dumb *args)
787{ 832{
788 struct vmw_private *dev_priv = vmw_priv(dev); 833 struct vmw_private *dev_priv = vmw_priv(dev);
789 struct vmw_master *vmaster = vmw_master(file_priv->master); 834 struct vmw_master *vmaster = vmw_master(file_priv->master);
790 struct vmw_user_dma_buffer *vmw_user_bo; 835 struct vmw_dma_buffer *dma_buf;
791 struct ttm_buffer_object *tmp;
792 int ret; 836 int ret;
793 837
794 args->pitch = args->width * ((args->bpp + 7) / 8); 838 args->pitch = args->width * ((args->bpp + 7) / 8);
795 args->size = args->pitch * args->height; 839 args->size = args->pitch * args->height;
796 840
797 vmw_user_bo = kzalloc(sizeof(*vmw_user_bo), GFP_KERNEL);
798 if (vmw_user_bo == NULL)
799 return -ENOMEM;
800
801 ret = ttm_read_lock(&vmaster->lock, true); 841 ret = ttm_read_lock(&vmaster->lock, true);
802 if (ret != 0) { 842 if (unlikely(ret != 0))
803 kfree(vmw_user_bo);
804 return ret; 843 return ret;
805 }
806 844
807 ret = vmw_dmabuf_init(dev_priv, &vmw_user_bo->dma, args->size, 845 ret = vmw_user_dmabuf_alloc(dev_priv, vmw_fpriv(file_priv)->tfile,
808 &vmw_vram_sys_placement, true, 846 args->size, false, &args->handle,
809 &vmw_user_dmabuf_destroy); 847 &dma_buf);
810 if (ret != 0)
811 goto out_no_dmabuf;
812
813 tmp = ttm_bo_reference(&vmw_user_bo->dma.base);
814 ret = ttm_prime_object_init(vmw_fpriv(file_priv)->tfile,
815 args->size,
816 &vmw_user_bo->prime,
817 false,
818 ttm_buffer_type,
819 &vmw_user_dmabuf_release, NULL);
820 if (unlikely(ret != 0)) 848 if (unlikely(ret != 0))
821 goto out_no_base_object; 849 goto out_no_dmabuf;
822
823 args->handle = vmw_user_bo->prime.base.hash.key;
824 850
825out_no_base_object: 851 vmw_dmabuf_unreference(&dma_buf);
826 ttm_bo_unref(&tmp);
827out_no_dmabuf: 852out_no_dmabuf:
828 ttm_read_unlock(&vmaster->lock); 853 ttm_read_unlock(&vmaster->lock);
829 return ret; 854 return ret;
830} 855}
831 856
857/**
858 * vmw_dumb_map_offset - Return the address space offset of a dumb buffer
859 *
860 * @file_priv: Pointer to a struct drm_file identifying the caller.
861 * @dev: Pointer to the drm device.
862 * @handle: Handle identifying the dumb buffer.
863 * @offset: The address space offset returned.
864 *
865 * This is a driver callback for the core drm dumb_map_offset functionality.
866 */
832int vmw_dumb_map_offset(struct drm_file *file_priv, 867int vmw_dumb_map_offset(struct drm_file *file_priv,
833 struct drm_device *dev, uint32_t handle, 868 struct drm_device *dev, uint32_t handle,
834 uint64_t *offset) 869 uint64_t *offset)
@@ -846,6 +881,15 @@ int vmw_dumb_map_offset(struct drm_file *file_priv,
846 return 0; 881 return 0;
847} 882}
848 883
884/**
885 * vmw_dumb_destroy - Destroy a dumb boffer
886 *
887 * @file_priv: Pointer to a struct drm_file identifying the caller.
888 * @dev: Pointer to the drm device.
889 * @handle: Handle identifying the dumb buffer.
890 *
891 * This is a driver callback for the core drm dumb_destroy functionality.
892 */
849int vmw_dumb_destroy(struct drm_file *file_priv, 893int vmw_dumb_destroy(struct drm_file *file_priv,
850 struct drm_device *dev, 894 struct drm_device *dev,
851 uint32_t handle) 895 uint32_t handle)
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
index 26387c3d5a21..22406c8651ea 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
@@ -310,6 +310,7 @@ static int vmw_sou_crtc_set_config(struct drm_mode_set *set)
310 crtc->fb = NULL; 310 crtc->fb = NULL;
311 crtc->x = 0; 311 crtc->x = 0;
312 crtc->y = 0; 312 crtc->y = 0;
313 crtc->enabled = false;
313 314
314 vmw_sou_del_active(dev_priv, sou); 315 vmw_sou_del_active(dev_priv, sou);
315 316
@@ -370,6 +371,7 @@ static int vmw_sou_crtc_set_config(struct drm_mode_set *set)
370 crtc->fb = NULL; 371 crtc->fb = NULL;
371 crtc->x = 0; 372 crtc->x = 0;
372 crtc->y = 0; 373 crtc->y = 0;
374 crtc->enabled = false;
373 375
374 return ret; 376 return ret;
375 } 377 }
@@ -382,6 +384,7 @@ static int vmw_sou_crtc_set_config(struct drm_mode_set *set)
382 crtc->fb = fb; 384 crtc->fb = fb;
383 crtc->x = set->x; 385 crtc->x = set->x;
384 crtc->y = set->y; 386 crtc->y = set->y;
387 crtc->enabled = true;
385 388
386 return 0; 389 return 0;
387} 390}
@@ -464,6 +467,8 @@ static int vmw_sou_init(struct vmw_private *dev_priv, unsigned unit)
464 encoder->possible_crtcs = (1 << unit); 467 encoder->possible_crtcs = (1 << unit);
465 encoder->possible_clones = 0; 468 encoder->possible_clones = 0;
466 469
470 (void) drm_sysfs_connector_add(connector);
471
467 drm_crtc_init(dev, crtc, &vmw_screen_object_crtc_funcs); 472 drm_crtc_init(dev, crtc, &vmw_screen_object_crtc_funcs);
468 473
469 drm_mode_crtc_set_gamma_size(crtc, 256); 474 drm_mode_crtc_set_gamma_size(crtc, 256);
diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c
index 509383f8be03..6a929591aa73 100644
--- a/drivers/gpu/host1x/bus.c
+++ b/drivers/gpu/host1x/bus.c
@@ -19,6 +19,7 @@
19#include <linux/of.h> 19#include <linux/of.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
21 21
22#include "bus.h"
22#include "dev.h" 23#include "dev.h"
23 24
24static DEFINE_MUTEX(clients_lock); 25static DEFINE_MUTEX(clients_lock);
@@ -257,7 +258,7 @@ static int host1x_unregister_client(struct host1x *host1x,
257 return -ENODEV; 258 return -ENODEV;
258} 259}
259 260
260struct bus_type host1x_bus_type = { 261static struct bus_type host1x_bus_type = {
261 .name = "host1x", 262 .name = "host1x",
262}; 263};
263 264
@@ -301,7 +302,7 @@ static int host1x_device_add(struct host1x *host1x,
301 device->dev.coherent_dma_mask = host1x->dev->coherent_dma_mask; 302 device->dev.coherent_dma_mask = host1x->dev->coherent_dma_mask;
302 device->dev.dma_mask = &device->dev.coherent_dma_mask; 303 device->dev.dma_mask = &device->dev.coherent_dma_mask;
303 device->dev.release = host1x_device_release; 304 device->dev.release = host1x_device_release;
304 dev_set_name(&device->dev, driver->name); 305 dev_set_name(&device->dev, "%s", driver->name);
305 device->dev.bus = &host1x_bus_type; 306 device->dev.bus = &host1x_bus_type;
306 device->dev.parent = host1x->dev; 307 device->dev.parent = host1x->dev;
307 308
diff --git a/drivers/gpu/host1x/hw/cdma_hw.c b/drivers/gpu/host1x/hw/cdma_hw.c
index 37e2a63241a9..6b09b71940c2 100644
--- a/drivers/gpu/host1x/hw/cdma_hw.c
+++ b/drivers/gpu/host1x/hw/cdma_hw.c
@@ -54,8 +54,8 @@ static void cdma_timeout_cpu_incr(struct host1x_cdma *cdma, u32 getptr,
54 u32 *p = (u32 *)((u32)pb->mapped + getptr); 54 u32 *p = (u32 *)((u32)pb->mapped + getptr);
55 *(p++) = HOST1X_OPCODE_NOP; 55 *(p++) = HOST1X_OPCODE_NOP;
56 *(p++) = HOST1X_OPCODE_NOP; 56 *(p++) = HOST1X_OPCODE_NOP;
57 dev_dbg(host1x->dev, "%s: NOP at 0x%x\n", __func__, 57 dev_dbg(host1x->dev, "%s: NOP at %#llx\n", __func__,
58 pb->phys + getptr); 58 (u64)pb->phys + getptr);
59 getptr = (getptr + 8) & (pb->size_bytes - 1); 59 getptr = (getptr + 8) & (pb->size_bytes - 1);
60 } 60 }
61 wmb(); 61 wmb();
diff --git a/drivers/gpu/host1x/hw/debug_hw.c b/drivers/gpu/host1x/hw/debug_hw.c
index 640c75ca5a8b..f72c873eff81 100644
--- a/drivers/gpu/host1x/hw/debug_hw.c
+++ b/drivers/gpu/host1x/hw/debug_hw.c
@@ -163,8 +163,8 @@ static void show_channel_gathers(struct output *o, struct host1x_cdma *cdma)
163 continue; 163 continue;
164 } 164 }
165 165
166 host1x_debug_output(o, " GATHER at %08x+%04x, %d words\n", 166 host1x_debug_output(o, " GATHER at %#llx+%04x, %d words\n",
167 g->base, g->offset, g->words); 167 (u64)g->base, g->offset, g->words);
168 168
169 show_gather(o, g->base + g->offset, g->words, cdma, 169 show_gather(o, g->base + g->offset, g->words, cdma,
170 g->base, mapped); 170 g->base, mapped);
diff --git a/drivers/hid/hid-kye.c b/drivers/hid/hid-kye.c
index ecb5ca669e97..e77696367591 100644
--- a/drivers/hid/hid-kye.c
+++ b/drivers/hid/hid-kye.c
@@ -341,6 +341,7 @@ static __u8 *kye_report_fixup(struct hid_device *hdev, __u8 *rdesc,
341 case USB_DEVICE_ID_GENIUS_GX_IMPERATOR: 341 case USB_DEVICE_ID_GENIUS_GX_IMPERATOR:
342 rdesc = kye_consumer_control_fixup(hdev, rdesc, rsize, 83, 342 rdesc = kye_consumer_control_fixup(hdev, rdesc, rsize, 83,
343 "Genius Gx Imperator Keyboard"); 343 "Genius Gx Imperator Keyboard");
344 break;
344 case USB_DEVICE_ID_GENIUS_MANTICORE: 345 case USB_DEVICE_ID_GENIUS_MANTICORE:
345 rdesc = kye_consumer_control_fixup(hdev, rdesc, rsize, 104, 346 rdesc = kye_consumer_control_fixup(hdev, rdesc, rsize, 104,
346 "Genius Manticore Keyboard"); 347 "Genius Manticore Keyboard");
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index a184e1921c11..8fab82829f8b 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -112,13 +112,15 @@ static int sensor_hub_get_physical_device_count(
112 112
113static void sensor_hub_fill_attr_info( 113static void sensor_hub_fill_attr_info(
114 struct hid_sensor_hub_attribute_info *info, 114 struct hid_sensor_hub_attribute_info *info,
115 s32 index, s32 report_id, s32 units, s32 unit_expo, s32 size) 115 s32 index, s32 report_id, struct hid_field *field)
116{ 116{
117 info->index = index; 117 info->index = index;
118 info->report_id = report_id; 118 info->report_id = report_id;
119 info->units = units; 119 info->units = field->unit;
120 info->unit_expo = unit_expo; 120 info->unit_expo = field->unit_exponent;
121 info->size = size/8; 121 info->size = (field->report_size * field->report_count)/8;
122 info->logical_minimum = field->logical_minimum;
123 info->logical_maximum = field->logical_maximum;
122} 124}
123 125
124static struct hid_sensor_hub_callbacks *sensor_hub_get_callback( 126static struct hid_sensor_hub_callbacks *sensor_hub_get_callback(
@@ -325,9 +327,7 @@ int sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev,
325 if (field->physical == usage_id && 327 if (field->physical == usage_id &&
326 field->logical == attr_usage_id) { 328 field->logical == attr_usage_id) {
327 sensor_hub_fill_attr_info(info, i, report->id, 329 sensor_hub_fill_attr_info(info, i, report->id,
328 field->unit, field->unit_exponent, 330 field);
329 field->report_size *
330 field->report_count);
331 ret = 0; 331 ret = 0;
332 } else { 332 } else {
333 for (j = 0; j < field->maxusage; ++j) { 333 for (j = 0; j < field->maxusage; ++j) {
@@ -336,11 +336,7 @@ int sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev,
336 field->usage[j].collection_index == 336 field->usage[j].collection_index ==
337 collection_index) { 337 collection_index) {
338 sensor_hub_fill_attr_info(info, 338 sensor_hub_fill_attr_info(info,
339 i, report->id, 339 i, report->id, field);
340 field->unit,
341 field->unit_exponent,
342 field->report_size *
343 field->report_count);
344 ret = 0; 340 ret = 0;
345 break; 341 break;
346 } 342 }
@@ -573,6 +569,8 @@ static int sensor_hub_probe(struct hid_device *hdev,
573 goto err_free_names; 569 goto err_free_names;
574 } 570 }
575 sd->hid_sensor_hub_client_devs[ 571 sd->hid_sensor_hub_client_devs[
572 sd->hid_sensor_client_cnt].id = PLATFORM_DEVID_AUTO;
573 sd->hid_sensor_hub_client_devs[
576 sd->hid_sensor_client_cnt].name = name; 574 sd->hid_sensor_client_cnt].name = name;
577 sd->hid_sensor_hub_client_devs[ 575 sd->hid_sensor_hub_client_devs[
578 sd->hid_sensor_client_cnt].platform_data = 576 sd->hid_sensor_client_cnt].platform_data =
diff --git a/drivers/hwmon/hih6130.c b/drivers/hwmon/hih6130.c
index 2dc37c7c6947..7d68a08baaa8 100644
--- a/drivers/hwmon/hih6130.c
+++ b/drivers/hwmon/hih6130.c
@@ -43,6 +43,7 @@
43 * @last_update: time of last update (jiffies) 43 * @last_update: time of last update (jiffies)
44 * @temperature: cached temperature measurement value 44 * @temperature: cached temperature measurement value
45 * @humidity: cached humidity measurement value 45 * @humidity: cached humidity measurement value
46 * @write_length: length for I2C measurement request
46 */ 47 */
47struct hih6130 { 48struct hih6130 {
48 struct device *hwmon_dev; 49 struct device *hwmon_dev;
@@ -51,6 +52,7 @@ struct hih6130 {
51 unsigned long last_update; 52 unsigned long last_update;
52 int temperature; 53 int temperature;
53 int humidity; 54 int humidity;
55 size_t write_length;
54}; 56};
55 57
56/** 58/**
@@ -121,8 +123,15 @@ static int hih6130_update_measurements(struct i2c_client *client)
121 */ 123 */
122 if (time_after(jiffies, hih6130->last_update + HZ) || !hih6130->valid) { 124 if (time_after(jiffies, hih6130->last_update + HZ) || !hih6130->valid) {
123 125
124 /* write to slave address, no data, to request a measurement */ 126 /*
125 ret = i2c_master_send(client, tmp, 0); 127 * Write to slave address to request a measurement.
128 * According with the datasheet it should be with no data, but
129 * for systems with I2C bus drivers that do not allow zero
130 * length packets we write one dummy byte to allow sensor
131 * measurements on them.
132 */
133 tmp[0] = 0;
134 ret = i2c_master_send(client, tmp, hih6130->write_length);
126 if (ret < 0) 135 if (ret < 0)
127 goto out; 136 goto out;
128 137
@@ -252,6 +261,9 @@ static int hih6130_probe(struct i2c_client *client,
252 goto fail_remove_sysfs; 261 goto fail_remove_sysfs;
253 } 262 }
254 263
264 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_QUICK))
265 hih6130->write_length = 1;
266
255 return 0; 267 return 0;
256 268
257fail_remove_sysfs: 269fail_remove_sysfs:
diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c
index 6cf6bff79003..a2f3b4a365e4 100644
--- a/drivers/hwmon/lm78.c
+++ b/drivers/hwmon/lm78.c
@@ -94,6 +94,8 @@ static inline u8 FAN_TO_REG(long rpm, int div)
94{ 94{
95 if (rpm <= 0) 95 if (rpm <= 0)
96 return 255; 96 return 255;
97 if (rpm > 1350000)
98 return 1;
97 return clamp_val((1350000 + rpm * div / 2) / (rpm * div), 1, 254); 99 return clamp_val((1350000 + rpm * div / 2) / (rpm * div), 1, 254);
98} 100}
99 101
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index 4c4c1421bf28..8b8f3aa49726 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -1610,12 +1610,14 @@ static int lm90_probe(struct i2c_client *client,
1610 "lm90", client); 1610 "lm90", client);
1611 if (err < 0) { 1611 if (err < 0) {
1612 dev_err(dev, "cannot request IRQ %d\n", client->irq); 1612 dev_err(dev, "cannot request IRQ %d\n", client->irq);
1613 goto exit_remove_files; 1613 goto exit_unregister;
1614 } 1614 }
1615 } 1615 }
1616 1616
1617 return 0; 1617 return 0;
1618 1618
1619exit_unregister:
1620 hwmon_device_unregister(data->hwmon_dev);
1619exit_remove_files: 1621exit_remove_files:
1620 lm90_remove_files(client, data); 1622 lm90_remove_files(client, data);
1621exit_restore: 1623exit_restore:
diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c
index 1404e6319deb..72a889702f0d 100644
--- a/drivers/hwmon/sis5595.c
+++ b/drivers/hwmon/sis5595.c
@@ -141,6 +141,8 @@ static inline u8 FAN_TO_REG(long rpm, int div)
141{ 141{
142 if (rpm <= 0) 142 if (rpm <= 0)
143 return 255; 143 return 255;
144 if (rpm > 1350000)
145 return 1;
144 return clamp_val((1350000 + rpm * div / 2) / (rpm * div), 1, 254); 146 return clamp_val((1350000 + rpm * div / 2) / (rpm * div), 1, 254);
145} 147}
146 148
diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c
index 0e7017841f7d..aee14e2192f8 100644
--- a/drivers/hwmon/vt8231.c
+++ b/drivers/hwmon/vt8231.c
@@ -145,7 +145,7 @@ static const u8 regtempmin[] = { 0x3a, 0x3e, 0x2c, 0x2e, 0x30, 0x32 };
145 */ 145 */
146static inline u8 FAN_TO_REG(long rpm, int div) 146static inline u8 FAN_TO_REG(long rpm, int div)
147{ 147{
148 if (rpm == 0) 148 if (rpm <= 0 || rpm > 1310720)
149 return 0; 149 return 0;
150 return clamp_val(1310720 / (rpm * div), 1, 255); 150 return clamp_val(1310720 / (rpm * div), 1, 255);
151} 151}
diff --git a/drivers/hwmon/w83l786ng.c b/drivers/hwmon/w83l786ng.c
index edb06cda5a68..6ed76ceb9270 100644
--- a/drivers/hwmon/w83l786ng.c
+++ b/drivers/hwmon/w83l786ng.c
@@ -481,9 +481,11 @@ store_pwm(struct device *dev, struct device_attribute *attr,
481 if (err) 481 if (err)
482 return err; 482 return err;
483 val = clamp_val(val, 0, 255); 483 val = clamp_val(val, 0, 255);
484 val = DIV_ROUND_CLOSEST(val, 0x11);
484 485
485 mutex_lock(&data->update_lock); 486 mutex_lock(&data->update_lock);
486 data->pwm[nr] = val; 487 data->pwm[nr] = val * 0x11;
488 val |= w83l786ng_read_value(client, W83L786NG_REG_PWM[nr]) & 0xf0;
487 w83l786ng_write_value(client, W83L786NG_REG_PWM[nr], val); 489 w83l786ng_write_value(client, W83L786NG_REG_PWM[nr], val);
488 mutex_unlock(&data->update_lock); 490 mutex_unlock(&data->update_lock);
489 return count; 491 return count;
@@ -510,7 +512,7 @@ store_pwm_enable(struct device *dev, struct device_attribute *attr,
510 mutex_lock(&data->update_lock); 512 mutex_lock(&data->update_lock);
511 reg = w83l786ng_read_value(client, W83L786NG_REG_FAN_CFG); 513 reg = w83l786ng_read_value(client, W83L786NG_REG_FAN_CFG);
512 data->pwm_enable[nr] = val; 514 data->pwm_enable[nr] = val;
513 reg &= ~(0x02 << W83L786NG_PWM_ENABLE_SHIFT[nr]); 515 reg &= ~(0x03 << W83L786NG_PWM_ENABLE_SHIFT[nr]);
514 reg |= (val - 1) << W83L786NG_PWM_ENABLE_SHIFT[nr]; 516 reg |= (val - 1) << W83L786NG_PWM_ENABLE_SHIFT[nr];
515 w83l786ng_write_value(client, W83L786NG_REG_FAN_CFG, reg); 517 w83l786ng_write_value(client, W83L786NG_REG_FAN_CFG, reg);
516 mutex_unlock(&data->update_lock); 518 mutex_unlock(&data->update_lock);
@@ -776,9 +778,10 @@ static struct w83l786ng_data *w83l786ng_update_device(struct device *dev)
776 ((pwmcfg >> W83L786NG_PWM_MODE_SHIFT[i]) & 1) 778 ((pwmcfg >> W83L786NG_PWM_MODE_SHIFT[i]) & 1)
777 ? 0 : 1; 779 ? 0 : 1;
778 data->pwm_enable[i] = 780 data->pwm_enable[i] =
779 ((pwmcfg >> W83L786NG_PWM_ENABLE_SHIFT[i]) & 2) + 1; 781 ((pwmcfg >> W83L786NG_PWM_ENABLE_SHIFT[i]) & 3) + 1;
780 data->pwm[i] = w83l786ng_read_value(client, 782 data->pwm[i] =
781 W83L786NG_REG_PWM[i]); 783 (w83l786ng_read_value(client, W83L786NG_REG_PWM[i])
784 & 0x0f) * 0x11;
782 } 785 }
783 786
784 787
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 1d7efa3169cd..d0cfbb4cb964 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -312,7 +312,9 @@ static int i2c_imx_start(struct imx_i2c_struct *i2c_imx)
312 312
313 dev_dbg(&i2c_imx->adapter.dev, "<%s>\n", __func__); 313 dev_dbg(&i2c_imx->adapter.dev, "<%s>\n", __func__);
314 314
315 clk_prepare_enable(i2c_imx->clk); 315 result = clk_prepare_enable(i2c_imx->clk);
316 if (result)
317 return result;
316 imx_i2c_write_reg(i2c_imx->ifdr, i2c_imx, IMX_I2C_IFDR); 318 imx_i2c_write_reg(i2c_imx->ifdr, i2c_imx, IMX_I2C_IFDR);
317 /* Enable I2C controller */ 319 /* Enable I2C controller */
318 imx_i2c_write_reg(i2c_imx->hwdata->i2sr_clr_opcode, i2c_imx, IMX_I2C_I2SR); 320 imx_i2c_write_reg(i2c_imx->hwdata->i2sr_clr_opcode, i2c_imx, IMX_I2C_I2SR);
diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index e661edee4d0c..9704537aee3c 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -27,7 +27,7 @@
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/of_device.h> 28#include <linux/of_device.h>
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/clk/tegra.h> 30#include <linux/reset.h>
31 31
32#include <asm/unaligned.h> 32#include <asm/unaligned.h>
33 33
@@ -160,6 +160,7 @@ struct tegra_i2c_dev {
160 struct i2c_adapter adapter; 160 struct i2c_adapter adapter;
161 struct clk *div_clk; 161 struct clk *div_clk;
162 struct clk *fast_clk; 162 struct clk *fast_clk;
163 struct reset_control *rst;
163 void __iomem *base; 164 void __iomem *base;
164 int cont_id; 165 int cont_id;
165 int irq; 166 int irq;
@@ -415,9 +416,9 @@ static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev)
415 return err; 416 return err;
416 } 417 }
417 418
418 tegra_periph_reset_assert(i2c_dev->div_clk); 419 reset_control_assert(i2c_dev->rst);
419 udelay(2); 420 udelay(2);
420 tegra_periph_reset_deassert(i2c_dev->div_clk); 421 reset_control_deassert(i2c_dev->rst);
421 422
422 if (i2c_dev->is_dvc) 423 if (i2c_dev->is_dvc)
423 tegra_dvc_init(i2c_dev); 424 tegra_dvc_init(i2c_dev);
@@ -743,6 +744,12 @@ static int tegra_i2c_probe(struct platform_device *pdev)
743 i2c_dev->cont_id = pdev->id; 744 i2c_dev->cont_id = pdev->id;
744 i2c_dev->dev = &pdev->dev; 745 i2c_dev->dev = &pdev->dev;
745 746
747 i2c_dev->rst = devm_reset_control_get(&pdev->dev, "i2c");
748 if (IS_ERR(i2c_dev->rst)) {
749 dev_err(&pdev->dev, "missing controller reset");
750 return PTR_ERR(i2c_dev->rst);
751 }
752
746 ret = of_property_read_u32(i2c_dev->dev->of_node, "clock-frequency", 753 ret = of_property_read_u32(i2c_dev->dev->of_node, "clock-frequency",
747 &i2c_dev->bus_clk_rate); 754 &i2c_dev->bus_clk_rate);
748 if (ret) 755 if (ret)
diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c
index 797e3117bef7..2d0847b6be62 100644
--- a/drivers/i2c/i2c-mux.c
+++ b/drivers/i2c/i2c-mux.c
@@ -139,6 +139,8 @@ struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent,
139 priv->adap.algo = &priv->algo; 139 priv->adap.algo = &priv->algo;
140 priv->adap.algo_data = priv; 140 priv->adap.algo_data = priv;
141 priv->adap.dev.parent = &parent->dev; 141 priv->adap.dev.parent = &parent->dev;
142 priv->adap.retries = parent->retries;
143 priv->adap.timeout = parent->timeout;
142 144
143 /* Sanity check on class */ 145 /* Sanity check on class */
144 if (i2c_mux_parent_classes(parent) & class) 146 if (i2c_mux_parent_classes(parent) & class)
diff --git a/drivers/iio/common/hid-sensors/Kconfig b/drivers/iio/common/hid-sensors/Kconfig
index 1178121b55b0..39188b72cd3b 100644
--- a/drivers/iio/common/hid-sensors/Kconfig
+++ b/drivers/iio/common/hid-sensors/Kconfig
@@ -25,13 +25,4 @@ config HID_SENSOR_IIO_TRIGGER
25 If this driver is compiled as a module, it will be named 25 If this driver is compiled as a module, it will be named
26 hid-sensor-trigger. 26 hid-sensor-trigger.
27 27
28config HID_SENSOR_ENUM_BASE_QUIRKS
29 bool "ENUM base quirks for HID Sensor IIO drivers"
30 depends on HID_SENSOR_IIO_COMMON
31 help
32 Say yes here to build support for sensor hub FW using
33 enumeration, which is using 1 as base instead of 0.
34 Since logical minimum is still set 0 instead of 1,
35 there is no easy way to differentiate.
36
37endmenu 28endmenu
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
index bbd6426c9726..7dcf83998e6f 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
@@ -33,24 +33,34 @@ static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig,
33{ 33{
34 struct hid_sensor_common *st = iio_trigger_get_drvdata(trig); 34 struct hid_sensor_common *st = iio_trigger_get_drvdata(trig);
35 int state_val; 35 int state_val;
36 int report_val;
36 37
37 if (state) { 38 if (state) {
38 if (sensor_hub_device_open(st->hsdev)) 39 if (sensor_hub_device_open(st->hsdev))
39 return -EIO; 40 return -EIO;
40 } else 41 state_val =
42 HID_USAGE_SENSOR_PROP_POWER_STATE_D0_FULL_POWER_ENUM;
43 report_val =
44 HID_USAGE_SENSOR_PROP_REPORTING_STATE_ALL_EVENTS_ENUM;
45
46 } else {
41 sensor_hub_device_close(st->hsdev); 47 sensor_hub_device_close(st->hsdev);
48 state_val =
49 HID_USAGE_SENSOR_PROP_POWER_STATE_D4_POWER_OFF_ENUM;
50 report_val =
51 HID_USAGE_SENSOR_PROP_REPORTING_STATE_NO_EVENTS_ENUM;
52 }
42 53
43 state_val = state ? 1 : 0;
44 if (IS_ENABLED(CONFIG_HID_SENSOR_ENUM_BASE_QUIRKS))
45 ++state_val;
46 st->data_ready = state; 54 st->data_ready = state;
55 state_val += st->power_state.logical_minimum;
56 report_val += st->report_state.logical_minimum;
47 sensor_hub_set_feature(st->hsdev, st->power_state.report_id, 57 sensor_hub_set_feature(st->hsdev, st->power_state.report_id,
48 st->power_state.index, 58 st->power_state.index,
49 (s32)state_val); 59 (s32)state_val);
50 60
51 sensor_hub_set_feature(st->hsdev, st->report_state.report_id, 61 sensor_hub_set_feature(st->hsdev, st->report_state.report_id,
52 st->report_state.index, 62 st->report_state.index,
53 (s32)state_val); 63 (s32)report_val);
54 64
55 return 0; 65 return 0;
56} 66}
diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig
index b0d65df3ede2..a022f27c6690 100644
--- a/drivers/iio/light/Kconfig
+++ b/drivers/iio/light/Kconfig
@@ -43,6 +43,7 @@ config GP2AP020A00F
43 depends on I2C 43 depends on I2C
44 select IIO_BUFFER 44 select IIO_BUFFER
45 select IIO_TRIGGERED_BUFFER 45 select IIO_TRIGGERED_BUFFER
46 select IRQ_WORK
46 help 47 help
47 Say Y here if you have a Sharp GP2AP020A00F proximity/ALS combo-chip 48 Say Y here if you have a Sharp GP2AP020A00F proximity/ALS combo-chip
48 hooked to an I2C bus. 49 hooked to an I2C bus.
diff --git a/drivers/input/keyboard/adp5588-keys.c b/drivers/input/keyboard/adp5588-keys.c
index dbd2047f1641..3ed23513d881 100644
--- a/drivers/input/keyboard/adp5588-keys.c
+++ b/drivers/input/keyboard/adp5588-keys.c
@@ -536,7 +536,8 @@ static int adp5588_probe(struct i2c_client *client,
536 __set_bit(EV_REP, input->evbit); 536 __set_bit(EV_REP, input->evbit);
537 537
538 for (i = 0; i < input->keycodemax; i++) 538 for (i = 0; i < input->keycodemax; i++)
539 __set_bit(kpad->keycode[i] & KEY_MAX, input->keybit); 539 if (kpad->keycode[i] <= KEY_MAX)
540 __set_bit(kpad->keycode[i], input->keybit);
540 __clear_bit(KEY_RESERVED, input->keybit); 541 __clear_bit(KEY_RESERVED, input->keybit);
541 542
542 if (kpad->gpimapsize) 543 if (kpad->gpimapsize)
diff --git a/drivers/input/keyboard/adp5589-keys.c b/drivers/input/keyboard/adp5589-keys.c
index 67d12b3427c9..60dafd4fa692 100644
--- a/drivers/input/keyboard/adp5589-keys.c
+++ b/drivers/input/keyboard/adp5589-keys.c
@@ -992,7 +992,8 @@ static int adp5589_probe(struct i2c_client *client,
992 __set_bit(EV_REP, input->evbit); 992 __set_bit(EV_REP, input->evbit);
993 993
994 for (i = 0; i < input->keycodemax; i++) 994 for (i = 0; i < input->keycodemax; i++)
995 __set_bit(kpad->keycode[i] & KEY_MAX, input->keybit); 995 if (kpad->keycode[i] <= KEY_MAX)
996 __set_bit(kpad->keycode[i], input->keybit);
996 __clear_bit(KEY_RESERVED, input->keybit); 997 __clear_bit(KEY_RESERVED, input->keybit);
997 998
998 if (kpad->gpimapsize) 999 if (kpad->gpimapsize)
diff --git a/drivers/input/keyboard/bf54x-keys.c b/drivers/input/keyboard/bf54x-keys.c
index fc88fb48d70d..09b91d093087 100644
--- a/drivers/input/keyboard/bf54x-keys.c
+++ b/drivers/input/keyboard/bf54x-keys.c
@@ -289,7 +289,8 @@ static int bfin_kpad_probe(struct platform_device *pdev)
289 __set_bit(EV_REP, input->evbit); 289 __set_bit(EV_REP, input->evbit);
290 290
291 for (i = 0; i < input->keycodemax; i++) 291 for (i = 0; i < input->keycodemax; i++)
292 __set_bit(bf54x_kpad->keycode[i] & KEY_MAX, input->keybit); 292 if (bf54x_kpad->keycode[i] <= KEY_MAX)
293 __set_bit(bf54x_kpad->keycode[i], input->keybit);
293 __clear_bit(KEY_RESERVED, input->keybit); 294 __clear_bit(KEY_RESERVED, input->keybit);
294 295
295 error = input_register_device(input); 296 error = input_register_device(input);
diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c
index 8508879f6faf..9757a58bc897 100644
--- a/drivers/input/keyboard/tegra-kbc.c
+++ b/drivers/input/keyboard/tegra-kbc.c
@@ -31,7 +31,7 @@
31#include <linux/clk.h> 31#include <linux/clk.h>
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/input/matrix_keypad.h> 33#include <linux/input/matrix_keypad.h>
34#include <linux/clk/tegra.h> 34#include <linux/reset.h>
35#include <linux/err.h> 35#include <linux/err.h>
36 36
37#define KBC_MAX_KPENT 8 37#define KBC_MAX_KPENT 8
@@ -116,6 +116,7 @@ struct tegra_kbc {
116 u32 wakeup_key; 116 u32 wakeup_key;
117 struct timer_list timer; 117 struct timer_list timer;
118 struct clk *clk; 118 struct clk *clk;
119 struct reset_control *rst;
119 const struct tegra_kbc_hw_support *hw_support; 120 const struct tegra_kbc_hw_support *hw_support;
120 int max_keys; 121 int max_keys;
121 int num_rows_and_columns; 122 int num_rows_and_columns;
@@ -373,9 +374,9 @@ static int tegra_kbc_start(struct tegra_kbc *kbc)
373 clk_prepare_enable(kbc->clk); 374 clk_prepare_enable(kbc->clk);
374 375
375 /* Reset the KBC controller to clear all previous status.*/ 376 /* Reset the KBC controller to clear all previous status.*/
376 tegra_periph_reset_assert(kbc->clk); 377 reset_control_assert(kbc->rst);
377 udelay(100); 378 udelay(100);
378 tegra_periph_reset_deassert(kbc->clk); 379 reset_control_assert(kbc->rst);
379 udelay(100); 380 udelay(100);
380 381
381 tegra_kbc_config_pins(kbc); 382 tegra_kbc_config_pins(kbc);
@@ -663,6 +664,12 @@ static int tegra_kbc_probe(struct platform_device *pdev)
663 return PTR_ERR(kbc->clk); 664 return PTR_ERR(kbc->clk);
664 } 665 }
665 666
667 kbc->rst = devm_reset_control_get(&pdev->dev, "kbc");
668 if (IS_ERR(kbc->rst)) {
669 dev_err(&pdev->dev, "failed to get keyboard reset\n");
670 return PTR_ERR(kbc->rst);
671 }
672
666 /* 673 /*
667 * The time delay between two consecutive reads of the FIFO is 674 * The time delay between two consecutive reads of the FIFO is
668 * the sum of the repeat time and the time taken for scanning 675 * the sum of the repeat time and the time taken for scanning
diff --git a/drivers/input/misc/adxl34x.c b/drivers/input/misc/adxl34x.c
index 0735de3a6468..1cb1da294419 100644
--- a/drivers/input/misc/adxl34x.c
+++ b/drivers/input/misc/adxl34x.c
@@ -158,7 +158,7 @@
158 158
159/* ORIENT ADXL346 only */ 159/* ORIENT ADXL346 only */
160#define ADXL346_2D_VALID (1 << 6) 160#define ADXL346_2D_VALID (1 << 6)
161#define ADXL346_2D_ORIENT(x) (((x) & 0x3) >> 4) 161#define ADXL346_2D_ORIENT(x) (((x) & 0x30) >> 4)
162#define ADXL346_3D_VALID (1 << 3) 162#define ADXL346_3D_VALID (1 << 3)
163#define ADXL346_3D_ORIENT(x) ((x) & 0x7) 163#define ADXL346_3D_ORIENT(x) ((x) & 0x7)
164#define ADXL346_2D_PORTRAIT_POS 0 /* +X */ 164#define ADXL346_2D_PORTRAIT_POS 0 /* +X */
diff --git a/drivers/input/misc/pcf8574_keypad.c b/drivers/input/misc/pcf8574_keypad.c
index e37392976fdd..0deca5a3c87f 100644
--- a/drivers/input/misc/pcf8574_keypad.c
+++ b/drivers/input/misc/pcf8574_keypad.c
@@ -113,9 +113,12 @@ static int pcf8574_kp_probe(struct i2c_client *client, const struct i2c_device_i
113 idev->keycodemax = ARRAY_SIZE(lp->btncode); 113 idev->keycodemax = ARRAY_SIZE(lp->btncode);
114 114
115 for (i = 0; i < ARRAY_SIZE(pcf8574_kp_btncode); i++) { 115 for (i = 0; i < ARRAY_SIZE(pcf8574_kp_btncode); i++) {
116 lp->btncode[i] = pcf8574_kp_btncode[i]; 116 if (lp->btncode[i] <= KEY_MAX) {
117 __set_bit(lp->btncode[i] & KEY_MAX, idev->keybit); 117 lp->btncode[i] = pcf8574_kp_btncode[i];
118 __set_bit(lp->btncode[i], idev->keybit);
119 }
118 } 120 }
121 __clear_bit(KEY_RESERVED, idev->keybit);
119 122
120 sprintf(lp->name, DRV_NAME); 123 sprintf(lp->name, DRV_NAME);
121 sprintf(lp->phys, "kp_data/input0"); 124 sprintf(lp->phys, "kp_data/input0");
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
index ca7a26f1dce8..5cf62e315218 100644
--- a/drivers/input/mouse/alps.c
+++ b/drivers/input/mouse/alps.c
@@ -70,6 +70,25 @@ static const struct alps_nibble_commands alps_v4_nibble_commands[] = {
70 { PSMOUSE_CMD_SETSCALE11, 0x00 }, /* f */ 70 { PSMOUSE_CMD_SETSCALE11, 0x00 }, /* f */
71}; 71};
72 72
73static const struct alps_nibble_commands alps_v6_nibble_commands[] = {
74 { PSMOUSE_CMD_ENABLE, 0x00 }, /* 0 */
75 { PSMOUSE_CMD_SETRATE, 0x0a }, /* 1 */
76 { PSMOUSE_CMD_SETRATE, 0x14 }, /* 2 */
77 { PSMOUSE_CMD_SETRATE, 0x28 }, /* 3 */
78 { PSMOUSE_CMD_SETRATE, 0x3c }, /* 4 */
79 { PSMOUSE_CMD_SETRATE, 0x50 }, /* 5 */
80 { PSMOUSE_CMD_SETRATE, 0x64 }, /* 6 */
81 { PSMOUSE_CMD_SETRATE, 0xc8 }, /* 7 */
82 { PSMOUSE_CMD_GETID, 0x00 }, /* 8 */
83 { PSMOUSE_CMD_GETINFO, 0x00 }, /* 9 */
84 { PSMOUSE_CMD_SETRES, 0x00 }, /* a */
85 { PSMOUSE_CMD_SETRES, 0x01 }, /* b */
86 { PSMOUSE_CMD_SETRES, 0x02 }, /* c */
87 { PSMOUSE_CMD_SETRES, 0x03 }, /* d */
88 { PSMOUSE_CMD_SETSCALE21, 0x00 }, /* e */
89 { PSMOUSE_CMD_SETSCALE11, 0x00 }, /* f */
90};
91
73 92
74#define ALPS_DUALPOINT 0x02 /* touchpad has trackstick */ 93#define ALPS_DUALPOINT 0x02 /* touchpad has trackstick */
75#define ALPS_PASS 0x04 /* device has a pass-through port */ 94#define ALPS_PASS 0x04 /* device has a pass-through port */
@@ -103,6 +122,7 @@ static const struct alps_model_info alps_model_data[] = {
103 /* Dell Latitude E5500, E6400, E6500, Precision M4400 */ 122 /* Dell Latitude E5500, E6400, E6500, Precision M4400 */
104 { { 0x62, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xcf, 0xcf, 123 { { 0x62, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xcf, 0xcf,
105 ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED }, 124 ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED },
125 { { 0x73, 0x00, 0x14 }, 0x00, ALPS_PROTO_V6, 0xff, 0xff, ALPS_DUALPOINT }, /* Dell XT2 */
106 { { 0x73, 0x02, 0x50 }, 0x00, ALPS_PROTO_V2, 0xcf, 0xcf, ALPS_FOUR_BUTTONS }, /* Dell Vostro 1400 */ 126 { { 0x73, 0x02, 0x50 }, 0x00, ALPS_PROTO_V2, 0xcf, 0xcf, ALPS_FOUR_BUTTONS }, /* Dell Vostro 1400 */
107 { { 0x52, 0x01, 0x14 }, 0x00, ALPS_PROTO_V2, 0xff, 0xff, 127 { { 0x52, 0x01, 0x14 }, 0x00, ALPS_PROTO_V2, 0xff, 0xff,
108 ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED }, /* Toshiba Tecra A11-11L */ 128 ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED }, /* Toshiba Tecra A11-11L */
@@ -645,6 +665,76 @@ static void alps_process_packet_v3(struct psmouse *psmouse)
645 alps_process_touchpad_packet_v3(psmouse); 665 alps_process_touchpad_packet_v3(psmouse);
646} 666}
647 667
668static void alps_process_packet_v6(struct psmouse *psmouse)
669{
670 struct alps_data *priv = psmouse->private;
671 unsigned char *packet = psmouse->packet;
672 struct input_dev *dev = psmouse->dev;
673 struct input_dev *dev2 = priv->dev2;
674 int x, y, z, left, right, middle;
675
676 /*
677 * We can use Byte5 to distinguish if the packet is from Touchpad
678 * or Trackpoint.
679 * Touchpad: 0 - 0x7E
680 * Trackpoint: 0x7F
681 */
682 if (packet[5] == 0x7F) {
683 /* It should be a DualPoint when received Trackpoint packet */
684 if (!(priv->flags & ALPS_DUALPOINT))
685 return;
686
687 /* Trackpoint packet */
688 x = packet[1] | ((packet[3] & 0x20) << 2);
689 y = packet[2] | ((packet[3] & 0x40) << 1);
690 z = packet[4];
691 left = packet[3] & 0x01;
692 right = packet[3] & 0x02;
693 middle = packet[3] & 0x04;
694
695 /* To prevent the cursor jump when finger lifted */
696 if (x == 0x7F && y == 0x7F && z == 0x7F)
697 x = y = z = 0;
698
699 /* Divide 4 since trackpoint's speed is too fast */
700 input_report_rel(dev2, REL_X, (char)x / 4);
701 input_report_rel(dev2, REL_Y, -((char)y / 4));
702
703 input_report_key(dev2, BTN_LEFT, left);
704 input_report_key(dev2, BTN_RIGHT, right);
705 input_report_key(dev2, BTN_MIDDLE, middle);
706
707 input_sync(dev2);
708 return;
709 }
710
711 /* Touchpad packet */
712 x = packet[1] | ((packet[3] & 0x78) << 4);
713 y = packet[2] | ((packet[4] & 0x78) << 4);
714 z = packet[5];
715 left = packet[3] & 0x01;
716 right = packet[3] & 0x02;
717
718 if (z > 30)
719 input_report_key(dev, BTN_TOUCH, 1);
720 if (z < 25)
721 input_report_key(dev, BTN_TOUCH, 0);
722
723 if (z > 0) {
724 input_report_abs(dev, ABS_X, x);
725 input_report_abs(dev, ABS_Y, y);
726 }
727
728 input_report_abs(dev, ABS_PRESSURE, z);
729 input_report_key(dev, BTN_TOOL_FINGER, z > 0);
730
731 /* v6 touchpad does not have middle button */
732 input_report_key(dev, BTN_LEFT, left);
733 input_report_key(dev, BTN_RIGHT, right);
734
735 input_sync(dev);
736}
737
648static void alps_process_packet_v4(struct psmouse *psmouse) 738static void alps_process_packet_v4(struct psmouse *psmouse)
649{ 739{
650 struct alps_data *priv = psmouse->private; 740 struct alps_data *priv = psmouse->private;
@@ -897,7 +987,7 @@ static psmouse_ret_t alps_process_byte(struct psmouse *psmouse)
897 } 987 }
898 988
899 /* Bytes 2 - pktsize should have 0 in the highest bit */ 989 /* Bytes 2 - pktsize should have 0 in the highest bit */
900 if (priv->proto_version != ALPS_PROTO_V5 && 990 if ((priv->proto_version < ALPS_PROTO_V5) &&
901 psmouse->pktcnt >= 2 && psmouse->pktcnt <= psmouse->pktsize && 991 psmouse->pktcnt >= 2 && psmouse->pktcnt <= psmouse->pktsize &&
902 (psmouse->packet[psmouse->pktcnt - 1] & 0x80)) { 992 (psmouse->packet[psmouse->pktcnt - 1] & 0x80)) {
903 psmouse_dbg(psmouse, "refusing packet[%i] = %x\n", 993 psmouse_dbg(psmouse, "refusing packet[%i] = %x\n",
@@ -1085,6 +1175,80 @@ static int alps_absolute_mode_v1_v2(struct psmouse *psmouse)
1085 return ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETPOLL); 1175 return ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETPOLL);
1086} 1176}
1087 1177
1178static int alps_monitor_mode_send_word(struct psmouse *psmouse, u16 word)
1179{
1180 int i, nibble;
1181
1182 /*
1183 * b0-b11 are valid bits, send sequence is inverse.
1184 * e.g. when word = 0x0123, nibble send sequence is 3, 2, 1
1185 */
1186 for (i = 0; i <= 8; i += 4) {
1187 nibble = (word >> i) & 0xf;
1188 if (alps_command_mode_send_nibble(psmouse, nibble))
1189 return -1;
1190 }
1191
1192 return 0;
1193}
1194
1195static int alps_monitor_mode_write_reg(struct psmouse *psmouse,
1196 u16 addr, u16 value)
1197{
1198 struct ps2dev *ps2dev = &psmouse->ps2dev;
1199
1200 /* 0x0A0 is the command to write the word */
1201 if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_ENABLE) ||
1202 alps_monitor_mode_send_word(psmouse, 0x0A0) ||
1203 alps_monitor_mode_send_word(psmouse, addr) ||
1204 alps_monitor_mode_send_word(psmouse, value) ||
1205 ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE))
1206 return -1;
1207
1208 return 0;
1209}
1210
1211static int alps_monitor_mode(struct psmouse *psmouse, bool enable)
1212{
1213 struct ps2dev *ps2dev = &psmouse->ps2dev;
1214
1215 if (enable) {
1216 /* EC E9 F5 F5 E7 E6 E7 E9 to enter monitor mode */
1217 if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_RESET_WRAP) ||
1218 ps2_command(ps2dev, NULL, PSMOUSE_CMD_GETINFO) ||
1219 ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) ||
1220 ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) ||
1221 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) ||
1222 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) ||
1223 ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) ||
1224 ps2_command(ps2dev, NULL, PSMOUSE_CMD_GETINFO))
1225 return -1;
1226 } else {
1227 /* EC to exit monitor mode */
1228 if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_RESET_WRAP))
1229 return -1;
1230 }
1231
1232 return 0;
1233}
1234
1235static int alps_absolute_mode_v6(struct psmouse *psmouse)
1236{
1237 u16 reg_val = 0x181;
1238 int ret = -1;
1239
1240 /* enter monitor mode, to write the register */
1241 if (alps_monitor_mode(psmouse, true))
1242 return -1;
1243
1244 ret = alps_monitor_mode_write_reg(psmouse, 0x000, reg_val);
1245
1246 if (alps_monitor_mode(psmouse, false))
1247 ret = -1;
1248
1249 return ret;
1250}
1251
1088static int alps_get_status(struct psmouse *psmouse, char *param) 1252static int alps_get_status(struct psmouse *psmouse, char *param)
1089{ 1253{
1090 /* Get status: 0xF5 0xF5 0xF5 0xE9 */ 1254 /* Get status: 0xF5 0xF5 0xF5 0xE9 */
@@ -1189,6 +1353,32 @@ static int alps_hw_init_v1_v2(struct psmouse *psmouse)
1189 return 0; 1353 return 0;
1190} 1354}
1191 1355
1356static int alps_hw_init_v6(struct psmouse *psmouse)
1357{
1358 unsigned char param[2] = {0xC8, 0x14};
1359
1360 /* Enter passthrough mode to let trackpoint enter 6byte raw mode */
1361 if (alps_passthrough_mode_v2(psmouse, true))
1362 return -1;
1363
1364 if (ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) ||
1365 ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) ||
1366 ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) ||
1367 ps2_command(&psmouse->ps2dev, &param[0], PSMOUSE_CMD_SETRATE) ||
1368 ps2_command(&psmouse->ps2dev, &param[1], PSMOUSE_CMD_SETRATE))
1369 return -1;
1370
1371 if (alps_passthrough_mode_v2(psmouse, false))
1372 return -1;
1373
1374 if (alps_absolute_mode_v6(psmouse)) {
1375 psmouse_err(psmouse, "Failed to enable absolute mode\n");
1376 return -1;
1377 }
1378
1379 return 0;
1380}
1381
1192/* 1382/*
1193 * Enable or disable passthrough mode to the trackstick. 1383 * Enable or disable passthrough mode to the trackstick.
1194 */ 1384 */
@@ -1553,6 +1743,8 @@ static void alps_set_defaults(struct alps_data *priv)
1553 priv->hw_init = alps_hw_init_v1_v2; 1743 priv->hw_init = alps_hw_init_v1_v2;
1554 priv->process_packet = alps_process_packet_v1_v2; 1744 priv->process_packet = alps_process_packet_v1_v2;
1555 priv->set_abs_params = alps_set_abs_params_st; 1745 priv->set_abs_params = alps_set_abs_params_st;
1746 priv->x_max = 1023;
1747 priv->y_max = 767;
1556 break; 1748 break;
1557 case ALPS_PROTO_V3: 1749 case ALPS_PROTO_V3:
1558 priv->hw_init = alps_hw_init_v3; 1750 priv->hw_init = alps_hw_init_v3;
@@ -1584,6 +1776,14 @@ static void alps_set_defaults(struct alps_data *priv)
1584 priv->x_bits = 23; 1776 priv->x_bits = 23;
1585 priv->y_bits = 12; 1777 priv->y_bits = 12;
1586 break; 1778 break;
1779 case ALPS_PROTO_V6:
1780 priv->hw_init = alps_hw_init_v6;
1781 priv->process_packet = alps_process_packet_v6;
1782 priv->set_abs_params = alps_set_abs_params_st;
1783 priv->nibble_commands = alps_v6_nibble_commands;
1784 priv->x_max = 2047;
1785 priv->y_max = 1535;
1786 break;
1587 } 1787 }
1588} 1788}
1589 1789
@@ -1705,8 +1905,8 @@ static void alps_disconnect(struct psmouse *psmouse)
1705static void alps_set_abs_params_st(struct alps_data *priv, 1905static void alps_set_abs_params_st(struct alps_data *priv,
1706 struct input_dev *dev1) 1906 struct input_dev *dev1)
1707{ 1907{
1708 input_set_abs_params(dev1, ABS_X, 0, 1023, 0, 0); 1908 input_set_abs_params(dev1, ABS_X, 0, priv->x_max, 0, 0);
1709 input_set_abs_params(dev1, ABS_Y, 0, 767, 0, 0); 1909 input_set_abs_params(dev1, ABS_Y, 0, priv->y_max, 0, 0);
1710} 1910}
1711 1911
1712static void alps_set_abs_params_mt(struct alps_data *priv, 1912static void alps_set_abs_params_mt(struct alps_data *priv,
diff --git a/drivers/input/mouse/alps.h b/drivers/input/mouse/alps.h
index eee59853b9ce..704f0f924307 100644
--- a/drivers/input/mouse/alps.h
+++ b/drivers/input/mouse/alps.h
@@ -17,6 +17,7 @@
17#define ALPS_PROTO_V3 3 17#define ALPS_PROTO_V3 3
18#define ALPS_PROTO_V4 4 18#define ALPS_PROTO_V4 4
19#define ALPS_PROTO_V5 5 19#define ALPS_PROTO_V5 5
20#define ALPS_PROTO_V6 6
20 21
21/** 22/**
22 * struct alps_model_info - touchpad ID table 23 * struct alps_model_info - touchpad ID table
diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index 8551dcaf24db..597e9b8fc18d 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -1313,6 +1313,7 @@ static int elantech_set_properties(struct elantech_data *etd)
1313 break; 1313 break;
1314 case 6: 1314 case 6:
1315 case 7: 1315 case 7:
1316 case 8:
1316 etd->hw_version = 4; 1317 etd->hw_version = 4;
1317 break; 1318 break;
1318 default: 1319 default:
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index 98707fb2cb5d..8f4c4ab04bc2 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -455,16 +455,26 @@ static DEVICE_ATTR_RO(type);
455static DEVICE_ATTR_RO(proto); 455static DEVICE_ATTR_RO(proto);
456static DEVICE_ATTR_RO(id); 456static DEVICE_ATTR_RO(id);
457static DEVICE_ATTR_RO(extra); 457static DEVICE_ATTR_RO(extra);
458static DEVICE_ATTR_RO(modalias);
459static DEVICE_ATTR_WO(drvctl);
460static DEVICE_ATTR(description, S_IRUGO, serio_show_description, NULL);
461static DEVICE_ATTR(bind_mode, S_IWUSR | S_IRUGO, serio_show_bind_mode, serio_set_bind_mode);
462 458
463static struct attribute *serio_device_id_attrs[] = { 459static struct attribute *serio_device_id_attrs[] = {
464 &dev_attr_type.attr, 460 &dev_attr_type.attr,
465 &dev_attr_proto.attr, 461 &dev_attr_proto.attr,
466 &dev_attr_id.attr, 462 &dev_attr_id.attr,
467 &dev_attr_extra.attr, 463 &dev_attr_extra.attr,
464 NULL
465};
466
467static struct attribute_group serio_id_attr_group = {
468 .name = "id",
469 .attrs = serio_device_id_attrs,
470};
471
472static DEVICE_ATTR_RO(modalias);
473static DEVICE_ATTR_WO(drvctl);
474static DEVICE_ATTR(description, S_IRUGO, serio_show_description, NULL);
475static DEVICE_ATTR(bind_mode, S_IWUSR | S_IRUGO, serio_show_bind_mode, serio_set_bind_mode);
476
477static struct attribute *serio_device_attrs[] = {
468 &dev_attr_modalias.attr, 478 &dev_attr_modalias.attr,
469 &dev_attr_description.attr, 479 &dev_attr_description.attr,
470 &dev_attr_drvctl.attr, 480 &dev_attr_drvctl.attr,
@@ -472,13 +482,13 @@ static struct attribute *serio_device_id_attrs[] = {
472 NULL 482 NULL
473}; 483};
474 484
475static struct attribute_group serio_id_attr_group = { 485static struct attribute_group serio_device_attr_group = {
476 .name = "id", 486 .attrs = serio_device_attrs,
477 .attrs = serio_device_id_attrs,
478}; 487};
479 488
480static const struct attribute_group *serio_device_attr_groups[] = { 489static const struct attribute_group *serio_device_attr_groups[] = {
481 &serio_id_attr_group, 490 &serio_id_attr_group,
491 &serio_device_attr_group,
482 NULL 492 NULL
483}; 493};
484 494
diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c
index cfd1b7e8c001..f1cb05148b46 100644
--- a/drivers/input/touchscreen/sur40.c
+++ b/drivers/input/touchscreen/sur40.c
@@ -251,7 +251,7 @@ static void sur40_poll(struct input_polled_dev *polldev)
251 struct sur40_state *sur40 = polldev->private; 251 struct sur40_state *sur40 = polldev->private;
252 struct input_dev *input = polldev->input; 252 struct input_dev *input = polldev->input;
253 int result, bulk_read, need_blobs, packet_blobs, i; 253 int result, bulk_read, need_blobs, packet_blobs, i;
254 u32 packet_id; 254 u32 uninitialized_var(packet_id);
255 255
256 struct sur40_header *header = &sur40->bulk_in_buffer->header; 256 struct sur40_header *header = &sur40->bulk_in_buffer->header;
257 struct sur40_blob *inblob = &sur40->bulk_in_buffer->blobs[0]; 257 struct sur40_blob *inblob = &sur40->bulk_in_buffer->blobs[0];
@@ -286,7 +286,7 @@ static void sur40_poll(struct input_polled_dev *polldev)
286 if (need_blobs == -1) { 286 if (need_blobs == -1) {
287 need_blobs = le16_to_cpu(header->count); 287 need_blobs = le16_to_cpu(header->count);
288 dev_dbg(sur40->dev, "need %d blobs\n", need_blobs); 288 dev_dbg(sur40->dev, "need %d blobs\n", need_blobs);
289 packet_id = header->packet_id; 289 packet_id = le32_to_cpu(header->packet_id);
290 } 290 }
291 291
292 /* 292 /*
diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c
index ae4b6b903629..5f87bed05467 100644
--- a/drivers/input/touchscreen/usbtouchscreen.c
+++ b/drivers/input/touchscreen/usbtouchscreen.c
@@ -106,6 +106,7 @@ struct usbtouch_device_info {
106struct usbtouch_usb { 106struct usbtouch_usb {
107 unsigned char *data; 107 unsigned char *data;
108 dma_addr_t data_dma; 108 dma_addr_t data_dma;
109 int data_size;
109 unsigned char *buffer; 110 unsigned char *buffer;
110 int buf_len; 111 int buf_len;
111 struct urb *irq; 112 struct urb *irq;
@@ -1521,7 +1522,7 @@ static int usbtouch_reset_resume(struct usb_interface *intf)
1521static void usbtouch_free_buffers(struct usb_device *udev, 1522static void usbtouch_free_buffers(struct usb_device *udev,
1522 struct usbtouch_usb *usbtouch) 1523 struct usbtouch_usb *usbtouch)
1523{ 1524{
1524 usb_free_coherent(udev, usbtouch->type->rept_size, 1525 usb_free_coherent(udev, usbtouch->data_size,
1525 usbtouch->data, usbtouch->data_dma); 1526 usbtouch->data, usbtouch->data_dma);
1526 kfree(usbtouch->buffer); 1527 kfree(usbtouch->buffer);
1527} 1528}
@@ -1566,7 +1567,20 @@ static int usbtouch_probe(struct usb_interface *intf,
1566 if (!type->process_pkt) 1567 if (!type->process_pkt)
1567 type->process_pkt = usbtouch_process_pkt; 1568 type->process_pkt = usbtouch_process_pkt;
1568 1569
1569 usbtouch->data = usb_alloc_coherent(udev, type->rept_size, 1570 usbtouch->data_size = type->rept_size;
1571 if (type->get_pkt_len) {
1572 /*
1573 * When dealing with variable-length packets we should
1574 * not request more than wMaxPacketSize bytes at once
1575 * as we do not know if there is more data coming or
1576 * we filled exactly wMaxPacketSize bytes and there is
1577 * nothing else.
1578 */
1579 usbtouch->data_size = min(usbtouch->data_size,
1580 usb_endpoint_maxp(endpoint));
1581 }
1582
1583 usbtouch->data = usb_alloc_coherent(udev, usbtouch->data_size,
1570 GFP_KERNEL, &usbtouch->data_dma); 1584 GFP_KERNEL, &usbtouch->data_dma);
1571 if (!usbtouch->data) 1585 if (!usbtouch->data)
1572 goto out_free; 1586 goto out_free;
@@ -1626,12 +1640,12 @@ static int usbtouch_probe(struct usb_interface *intf,
1626 if (usb_endpoint_type(endpoint) == USB_ENDPOINT_XFER_INT) 1640 if (usb_endpoint_type(endpoint) == USB_ENDPOINT_XFER_INT)
1627 usb_fill_int_urb(usbtouch->irq, udev, 1641 usb_fill_int_urb(usbtouch->irq, udev,
1628 usb_rcvintpipe(udev, endpoint->bEndpointAddress), 1642 usb_rcvintpipe(udev, endpoint->bEndpointAddress),
1629 usbtouch->data, type->rept_size, 1643 usbtouch->data, usbtouch->data_size,
1630 usbtouch_irq, usbtouch, endpoint->bInterval); 1644 usbtouch_irq, usbtouch, endpoint->bInterval);
1631 else 1645 else
1632 usb_fill_bulk_urb(usbtouch->irq, udev, 1646 usb_fill_bulk_urb(usbtouch->irq, udev,
1633 usb_rcvbulkpipe(udev, endpoint->bEndpointAddress), 1647 usb_rcvbulkpipe(udev, endpoint->bEndpointAddress),
1634 usbtouch->data, type->rept_size, 1648 usbtouch->data, usbtouch->data_size,
1635 usbtouch_irq, usbtouch); 1649 usbtouch_irq, usbtouch);
1636 1650
1637 usbtouch->irq->dev = udev; 1651 usbtouch->irq->dev = udev;
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index 1abfb5684ab7..e46a88700b68 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -392,7 +392,7 @@ struct arm_smmu_domain {
392 struct arm_smmu_cfg root_cfg; 392 struct arm_smmu_cfg root_cfg;
393 phys_addr_t output_mask; 393 phys_addr_t output_mask;
394 394
395 spinlock_t lock; 395 struct mutex lock;
396}; 396};
397 397
398static DEFINE_SPINLOCK(arm_smmu_devices_lock); 398static DEFINE_SPINLOCK(arm_smmu_devices_lock);
@@ -900,7 +900,7 @@ static int arm_smmu_domain_init(struct iommu_domain *domain)
900 goto out_free_domain; 900 goto out_free_domain;
901 smmu_domain->root_cfg.pgd = pgd; 901 smmu_domain->root_cfg.pgd = pgd;
902 902
903 spin_lock_init(&smmu_domain->lock); 903 mutex_init(&smmu_domain->lock);
904 domain->priv = smmu_domain; 904 domain->priv = smmu_domain;
905 return 0; 905 return 0;
906 906
@@ -1137,7 +1137,7 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
1137 * Sanity check the domain. We don't currently support domains 1137 * Sanity check the domain. We don't currently support domains
1138 * that cross between different SMMU chains. 1138 * that cross between different SMMU chains.
1139 */ 1139 */
1140 spin_lock(&smmu_domain->lock); 1140 mutex_lock(&smmu_domain->lock);
1141 if (!smmu_domain->leaf_smmu) { 1141 if (!smmu_domain->leaf_smmu) {
1142 /* Now that we have a master, we can finalise the domain */ 1142 /* Now that we have a master, we can finalise the domain */
1143 ret = arm_smmu_init_domain_context(domain, dev); 1143 ret = arm_smmu_init_domain_context(domain, dev);
@@ -1152,7 +1152,7 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
1152 dev_name(device_smmu->dev)); 1152 dev_name(device_smmu->dev));
1153 goto err_unlock; 1153 goto err_unlock;
1154 } 1154 }
1155 spin_unlock(&smmu_domain->lock); 1155 mutex_unlock(&smmu_domain->lock);
1156 1156
1157 /* Looks ok, so add the device to the domain */ 1157 /* Looks ok, so add the device to the domain */
1158 master = find_smmu_master(smmu_domain->leaf_smmu, dev->of_node); 1158 master = find_smmu_master(smmu_domain->leaf_smmu, dev->of_node);
@@ -1162,7 +1162,7 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev)
1162 return arm_smmu_domain_add_master(smmu_domain, master); 1162 return arm_smmu_domain_add_master(smmu_domain, master);
1163 1163
1164err_unlock: 1164err_unlock:
1165 spin_unlock(&smmu_domain->lock); 1165 mutex_unlock(&smmu_domain->lock);
1166 return ret; 1166 return ret;
1167} 1167}
1168 1168
@@ -1394,7 +1394,7 @@ static int arm_smmu_handle_mapping(struct arm_smmu_domain *smmu_domain,
1394 if (paddr & ~output_mask) 1394 if (paddr & ~output_mask)
1395 return -ERANGE; 1395 return -ERANGE;
1396 1396
1397 spin_lock(&smmu_domain->lock); 1397 mutex_lock(&smmu_domain->lock);
1398 pgd += pgd_index(iova); 1398 pgd += pgd_index(iova);
1399 end = iova + size; 1399 end = iova + size;
1400 do { 1400 do {
@@ -1410,7 +1410,7 @@ static int arm_smmu_handle_mapping(struct arm_smmu_domain *smmu_domain,
1410 } while (pgd++, iova != end); 1410 } while (pgd++, iova != end);
1411 1411
1412out_unlock: 1412out_unlock:
1413 spin_unlock(&smmu_domain->lock); 1413 mutex_unlock(&smmu_domain->lock);
1414 1414
1415 /* Ensure new page tables are visible to the hardware walker */ 1415 /* Ensure new page tables are visible to the hardware walker */
1416 if (smmu->features & ARM_SMMU_FEAT_COHERENT_WALK) 1416 if (smmu->features & ARM_SMMU_FEAT_COHERENT_WALK)
@@ -1423,9 +1423,8 @@ static int arm_smmu_map(struct iommu_domain *domain, unsigned long iova,
1423 phys_addr_t paddr, size_t size, int flags) 1423 phys_addr_t paddr, size_t size, int flags)
1424{ 1424{
1425 struct arm_smmu_domain *smmu_domain = domain->priv; 1425 struct arm_smmu_domain *smmu_domain = domain->priv;
1426 struct arm_smmu_device *smmu = smmu_domain->leaf_smmu;
1427 1426
1428 if (!smmu_domain || !smmu) 1427 if (!smmu_domain)
1429 return -ENODEV; 1428 return -ENODEV;
1430 1429
1431 /* Check for silent address truncation up the SMMU chain. */ 1430 /* Check for silent address truncation up the SMMU chain. */
@@ -1449,44 +1448,34 @@ static size_t arm_smmu_unmap(struct iommu_domain *domain, unsigned long iova,
1449static phys_addr_t arm_smmu_iova_to_phys(struct iommu_domain *domain, 1448static phys_addr_t arm_smmu_iova_to_phys(struct iommu_domain *domain,
1450 dma_addr_t iova) 1449 dma_addr_t iova)
1451{ 1450{
1452 pgd_t *pgd; 1451 pgd_t *pgdp, pgd;
1453 pud_t *pud; 1452 pud_t pud;
1454 pmd_t *pmd; 1453 pmd_t pmd;
1455 pte_t *pte; 1454 pte_t pte;
1456 struct arm_smmu_domain *smmu_domain = domain->priv; 1455 struct arm_smmu_domain *smmu_domain = domain->priv;
1457 struct arm_smmu_cfg *root_cfg = &smmu_domain->root_cfg; 1456 struct arm_smmu_cfg *root_cfg = &smmu_domain->root_cfg;
1458 struct arm_smmu_device *smmu = root_cfg->smmu;
1459 1457
1460 spin_lock(&smmu_domain->lock); 1458 pgdp = root_cfg->pgd;
1461 pgd = root_cfg->pgd; 1459 if (!pgdp)
1462 if (!pgd) 1460 return 0;
1463 goto err_unlock;
1464 1461
1465 pgd += pgd_index(iova); 1462 pgd = *(pgdp + pgd_index(iova));
1466 if (pgd_none_or_clear_bad(pgd)) 1463 if (pgd_none(pgd))
1467 goto err_unlock; 1464 return 0;
1468 1465
1469 pud = pud_offset(pgd, iova); 1466 pud = *pud_offset(&pgd, iova);
1470 if (pud_none_or_clear_bad(pud)) 1467 if (pud_none(pud))
1471 goto err_unlock; 1468 return 0;
1472 1469
1473 pmd = pmd_offset(pud, iova); 1470 pmd = *pmd_offset(&pud, iova);
1474 if (pmd_none_or_clear_bad(pmd)) 1471 if (pmd_none(pmd))
1475 goto err_unlock; 1472 return 0;
1476 1473
1477 pte = pmd_page_vaddr(*pmd) + pte_index(iova); 1474 pte = *(pmd_page_vaddr(pmd) + pte_index(iova));
1478 if (pte_none(pte)) 1475 if (pte_none(pte))
1479 goto err_unlock; 1476 return 0;
1480
1481 spin_unlock(&smmu_domain->lock);
1482 return __pfn_to_phys(pte_pfn(*pte)) | (iova & ~PAGE_MASK);
1483 1477
1484err_unlock: 1478 return __pfn_to_phys(pte_pfn(pte)) | (iova & ~PAGE_MASK);
1485 spin_unlock(&smmu_domain->lock);
1486 dev_warn(smmu->dev,
1487 "invalid (corrupt?) page tables detected for iova 0x%llx\n",
1488 (unsigned long long)iova);
1489 return -EINVAL;
1490} 1479}
1491 1480
1492static int arm_smmu_domain_has_cap(struct iommu_domain *domain, 1481static int arm_smmu_domain_has_cap(struct iommu_domain *domain,
@@ -1863,6 +1852,7 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev)
1863 dev_err(dev, 1852 dev_err(dev,
1864 "found only %d context interrupt(s) but %d required\n", 1853 "found only %d context interrupt(s) but %d required\n",
1865 smmu->num_context_irqs, smmu->num_context_banks); 1854 smmu->num_context_irqs, smmu->num_context_banks);
1855 err = -ENODEV;
1866 goto out_put_parent; 1856 goto out_put_parent;
1867 } 1857 }
1868 1858
diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index 3792a1aa52b8..940638ddc982 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -30,6 +30,10 @@ config ARM_VIC_NR
30 The maximum number of VICs available in the system, for 30 The maximum number of VICs available in the system, for
31 power management. 31 power management.
32 32
33config DW_APB_ICTL
34 bool
35 select IRQ_DOMAIN
36
33config IMGPDC_IRQ 37config IMGPDC_IRQ
34 bool 38 bool
35 select GENERIC_IRQ_CHIP 39 select GENERIC_IRQ_CHIP
diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
index c60b9010b152..6427323af4c3 100644
--- a/drivers/irqchip/Makefile
+++ b/drivers/irqchip/Makefile
@@ -6,6 +6,7 @@ obj-$(CONFIG_ARCH_MMP) += irq-mmp.o
6obj-$(CONFIG_ARCH_MVEBU) += irq-armada-370-xp.o 6obj-$(CONFIG_ARCH_MVEBU) += irq-armada-370-xp.o
7obj-$(CONFIG_ARCH_MXS) += irq-mxs.o 7obj-$(CONFIG_ARCH_MXS) += irq-mxs.o
8obj-$(CONFIG_ARCH_S3C24XX) += irq-s3c24xx.o 8obj-$(CONFIG_ARCH_S3C24XX) += irq-s3c24xx.o
9obj-$(CONFIG_DW_APB_ICTL) += irq-dw-apb-ictl.o
9obj-$(CONFIG_METAG) += irq-metag-ext.o 10obj-$(CONFIG_METAG) += irq-metag-ext.o
10obj-$(CONFIG_METAG_PERFCOUNTER_IRQS) += irq-metag.o 11obj-$(CONFIG_METAG_PERFCOUNTER_IRQS) += irq-metag.o
11obj-$(CONFIG_ARCH_MOXART) += irq-moxart.o 12obj-$(CONFIG_ARCH_MOXART) += irq-moxart.o
diff --git a/drivers/irqchip/irq-dw-apb-ictl.c b/drivers/irqchip/irq-dw-apb-ictl.c
new file mode 100644
index 000000000000..31e231e1f566
--- /dev/null
+++ b/drivers/irqchip/irq-dw-apb-ictl.c
@@ -0,0 +1,150 @@
1/*
2 * Synopsys DW APB ICTL irqchip driver.
3 *
4 * Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
5 *
6 * based on GPL'ed 2.6 kernel sources
7 * (c) Marvell International Ltd.
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/io.h>
15#include <linux/irq.h>
16#include <linux/irqchip/chained_irq.h>
17#include <linux/of_address.h>
18#include <linux/of_irq.h>
19
20#include "irqchip.h"
21
22#define APB_INT_ENABLE_L 0x00
23#define APB_INT_ENABLE_H 0x04
24#define APB_INT_MASK_L 0x08
25#define APB_INT_MASK_H 0x0c
26#define APB_INT_FINALSTATUS_L 0x30
27#define APB_INT_FINALSTATUS_H 0x34
28
29static void dw_apb_ictl_handler(unsigned int irq, struct irq_desc *desc)
30{
31 struct irq_chip *chip = irq_get_chip(irq);
32 struct irq_chip_generic *gc = irq_get_handler_data(irq);
33 struct irq_domain *d = gc->private;
34 u32 stat;
35 int n;
36
37 chained_irq_enter(chip, desc);
38
39 for (n = 0; n < gc->num_ct; n++) {
40 stat = readl_relaxed(gc->reg_base +
41 APB_INT_FINALSTATUS_L + 4 * n);
42 while (stat) {
43 u32 hwirq = ffs(stat) - 1;
44 generic_handle_irq(irq_find_mapping(d,
45 gc->irq_base + hwirq + 32 * n));
46 stat &= ~(1 << hwirq);
47 }
48 }
49
50 chained_irq_exit(chip, desc);
51}
52
53static int __init dw_apb_ictl_init(struct device_node *np,
54 struct device_node *parent)
55{
56 unsigned int clr = IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_NOAUTOEN;
57 struct resource r;
58 struct irq_domain *domain;
59 struct irq_chip_generic *gc;
60 void __iomem *iobase;
61 int ret, nrirqs, irq;
62 u32 reg;
63
64 /* Map the parent interrupt for the chained handler */
65 irq = irq_of_parse_and_map(np, 0);
66 if (irq <= 0) {
67 pr_err("%s: unable to parse irq\n", np->full_name);
68 return -EINVAL;
69 }
70
71 ret = of_address_to_resource(np, 0, &r);
72 if (ret) {
73 pr_err("%s: unable to get resource\n", np->full_name);
74 return ret;
75 }
76
77 if (!request_mem_region(r.start, resource_size(&r), np->full_name)) {
78 pr_err("%s: unable to request mem region\n", np->full_name);
79 return -ENOMEM;
80 }
81
82 iobase = ioremap(r.start, resource_size(&r));
83 if (!iobase) {
84 pr_err("%s: unable to map resource\n", np->full_name);
85 ret = -ENOMEM;
86 goto err_release;
87 }
88
89 /*
90 * DW IP can be configured to allow 2-64 irqs. We can determine
91 * the number of irqs supported by writing into enable register
92 * and look for bits not set, as corresponding flip-flops will
93 * have been removed by sythesis tool.
94 */
95
96 /* mask and enable all interrupts */
97 writel(~0, iobase + APB_INT_MASK_L);
98 writel(~0, iobase + APB_INT_MASK_H);
99 writel(~0, iobase + APB_INT_ENABLE_L);
100 writel(~0, iobase + APB_INT_ENABLE_H);
101
102 reg = readl(iobase + APB_INT_ENABLE_H);
103 if (reg)
104 nrirqs = 32 + fls(reg);
105 else
106 nrirqs = fls(readl(iobase + APB_INT_ENABLE_L));
107
108 domain = irq_domain_add_linear(np, nrirqs,
109 &irq_generic_chip_ops, NULL);
110 if (!domain) {
111 pr_err("%s: unable to add irq domain\n", np->full_name);
112 ret = -ENOMEM;
113 goto err_unmap;
114 }
115
116 ret = irq_alloc_domain_generic_chips(domain, 32, (nrirqs > 32) ? 2 : 1,
117 np->name, handle_level_irq, clr, 0,
118 IRQ_GC_INIT_MASK_CACHE);
119 if (ret) {
120 pr_err("%s: unable to alloc irq domain gc\n", np->full_name);
121 goto err_unmap;
122 }
123
124 gc = irq_get_domain_generic_chip(domain, 0);
125 gc->private = domain;
126 gc->reg_base = iobase;
127
128 gc->chip_types[0].regs.mask = APB_INT_MASK_L;
129 gc->chip_types[0].chip.irq_mask = irq_gc_mask_set_bit;
130 gc->chip_types[0].chip.irq_unmask = irq_gc_mask_clr_bit;
131
132 if (nrirqs > 32) {
133 gc->chip_types[1].regs.mask = APB_INT_MASK_H;
134 gc->chip_types[1].chip.irq_mask = irq_gc_mask_set_bit;
135 gc->chip_types[1].chip.irq_unmask = irq_gc_mask_clr_bit;
136 }
137
138 irq_set_handler_data(irq, gc);
139 irq_set_chained_handler(irq, dw_apb_ictl_handler);
140
141 return 0;
142
143err_unmap:
144 iounmap(iobase);
145err_release:
146 release_mem_region(r.start, resource_size(&r));
147 return ret;
148}
149IRQCHIP_DECLARE(dw_apb_ictl,
150 "snps,dw-apb-ictl", dw_apb_ictl_init);
diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
index 173cbb20d104..54bdd923316f 100644
--- a/drivers/md/dm-bufio.c
+++ b/drivers/md/dm-bufio.c
@@ -1717,6 +1717,11 @@ static int __init dm_bufio_init(void)
1717{ 1717{
1718 __u64 mem; 1718 __u64 mem;
1719 1719
1720 dm_bufio_allocated_kmem_cache = 0;
1721 dm_bufio_allocated_get_free_pages = 0;
1722 dm_bufio_allocated_vmalloc = 0;
1723 dm_bufio_current_allocated = 0;
1724
1720 memset(&dm_bufio_caches, 0, sizeof dm_bufio_caches); 1725 memset(&dm_bufio_caches, 0, sizeof dm_bufio_caches);
1721 memset(&dm_bufio_cache_names, 0, sizeof dm_bufio_cache_names); 1726 memset(&dm_bufio_cache_names, 0, sizeof dm_bufio_cache_names);
1722 1727
diff --git a/drivers/md/dm-cache-policy-mq.c b/drivers/md/dm-cache-policy-mq.c
index 416b7b752a6e..64780ad73bb0 100644
--- a/drivers/md/dm-cache-policy-mq.c
+++ b/drivers/md/dm-cache-policy-mq.c
@@ -730,15 +730,18 @@ static int pre_cache_entry_found(struct mq_policy *mq, struct entry *e,
730 int r = 0; 730 int r = 0;
731 bool updated = updated_this_tick(mq, e); 731 bool updated = updated_this_tick(mq, e);
732 732
733 requeue_and_update_tick(mq, e);
734
735 if ((!discarded_oblock && updated) || 733 if ((!discarded_oblock && updated) ||
736 !should_promote(mq, e, discarded_oblock, data_dir)) 734 !should_promote(mq, e, discarded_oblock, data_dir)) {
735 requeue_and_update_tick(mq, e);
737 result->op = POLICY_MISS; 736 result->op = POLICY_MISS;
738 else if (!can_migrate) 737
738 } else if (!can_migrate)
739 r = -EWOULDBLOCK; 739 r = -EWOULDBLOCK;
740 else 740
741 else {
742 requeue_and_update_tick(mq, e);
741 r = pre_cache_to_cache(mq, e, result); 743 r = pre_cache_to_cache(mq, e, result);
744 }
742 745
743 return r; 746 return r;
744} 747}
diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c
index 9efcf1059b99..1b1469ebe5cb 100644
--- a/drivers/md/dm-cache-target.c
+++ b/drivers/md/dm-cache-target.c
@@ -2755,7 +2755,7 @@ static int resize_cache_dev(struct cache *cache, dm_cblock_t new_size)
2755{ 2755{
2756 int r; 2756 int r;
2757 2757
2758 r = dm_cache_resize(cache->cmd, cache->cache_size); 2758 r = dm_cache_resize(cache->cmd, new_size);
2759 if (r) { 2759 if (r) {
2760 DMERR("could not resize cache metadata"); 2760 DMERR("could not resize cache metadata");
2761 return r; 2761 return r;
diff --git a/drivers/md/dm-delay.c b/drivers/md/dm-delay.c
index 496d5f3646a5..2f91d6d4a2cc 100644
--- a/drivers/md/dm-delay.c
+++ b/drivers/md/dm-delay.c
@@ -20,6 +20,7 @@
20struct delay_c { 20struct delay_c {
21 struct timer_list delay_timer; 21 struct timer_list delay_timer;
22 struct mutex timer_lock; 22 struct mutex timer_lock;
23 struct workqueue_struct *kdelayd_wq;
23 struct work_struct flush_expired_bios; 24 struct work_struct flush_expired_bios;
24 struct list_head delayed_bios; 25 struct list_head delayed_bios;
25 atomic_t may_delay; 26 atomic_t may_delay;
@@ -45,14 +46,13 @@ struct dm_delay_info {
45 46
46static DEFINE_MUTEX(delayed_bios_lock); 47static DEFINE_MUTEX(delayed_bios_lock);
47 48
48static struct workqueue_struct *kdelayd_wq;
49static struct kmem_cache *delayed_cache; 49static struct kmem_cache *delayed_cache;
50 50
51static void handle_delayed_timer(unsigned long data) 51static void handle_delayed_timer(unsigned long data)
52{ 52{
53 struct delay_c *dc = (struct delay_c *)data; 53 struct delay_c *dc = (struct delay_c *)data;
54 54
55 queue_work(kdelayd_wq, &dc->flush_expired_bios); 55 queue_work(dc->kdelayd_wq, &dc->flush_expired_bios);
56} 56}
57 57
58static void queue_timeout(struct delay_c *dc, unsigned long expires) 58static void queue_timeout(struct delay_c *dc, unsigned long expires)
@@ -191,6 +191,12 @@ out:
191 goto bad_dev_write; 191 goto bad_dev_write;
192 } 192 }
193 193
194 dc->kdelayd_wq = alloc_workqueue("kdelayd", WQ_MEM_RECLAIM, 0);
195 if (!dc->kdelayd_wq) {
196 DMERR("Couldn't start kdelayd");
197 goto bad_queue;
198 }
199
194 setup_timer(&dc->delay_timer, handle_delayed_timer, (unsigned long)dc); 200 setup_timer(&dc->delay_timer, handle_delayed_timer, (unsigned long)dc);
195 201
196 INIT_WORK(&dc->flush_expired_bios, flush_expired_bios); 202 INIT_WORK(&dc->flush_expired_bios, flush_expired_bios);
@@ -203,6 +209,8 @@ out:
203 ti->private = dc; 209 ti->private = dc;
204 return 0; 210 return 0;
205 211
212bad_queue:
213 mempool_destroy(dc->delayed_pool);
206bad_dev_write: 214bad_dev_write:
207 if (dc->dev_write) 215 if (dc->dev_write)
208 dm_put_device(ti, dc->dev_write); 216 dm_put_device(ti, dc->dev_write);
@@ -217,7 +225,7 @@ static void delay_dtr(struct dm_target *ti)
217{ 225{
218 struct delay_c *dc = ti->private; 226 struct delay_c *dc = ti->private;
219 227
220 flush_workqueue(kdelayd_wq); 228 destroy_workqueue(dc->kdelayd_wq);
221 229
222 dm_put_device(ti, dc->dev_read); 230 dm_put_device(ti, dc->dev_read);
223 231
@@ -350,12 +358,6 @@ static int __init dm_delay_init(void)
350{ 358{
351 int r = -ENOMEM; 359 int r = -ENOMEM;
352 360
353 kdelayd_wq = alloc_workqueue("kdelayd", WQ_MEM_RECLAIM, 0);
354 if (!kdelayd_wq) {
355 DMERR("Couldn't start kdelayd");
356 goto bad_queue;
357 }
358
359 delayed_cache = KMEM_CACHE(dm_delay_info, 0); 361 delayed_cache = KMEM_CACHE(dm_delay_info, 0);
360 if (!delayed_cache) { 362 if (!delayed_cache) {
361 DMERR("Couldn't create delayed bio cache."); 363 DMERR("Couldn't create delayed bio cache.");
@@ -373,8 +375,6 @@ static int __init dm_delay_init(void)
373bad_register: 375bad_register:
374 kmem_cache_destroy(delayed_cache); 376 kmem_cache_destroy(delayed_cache);
375bad_memcache: 377bad_memcache:
376 destroy_workqueue(kdelayd_wq);
377bad_queue:
378 return r; 378 return r;
379} 379}
380 380
@@ -382,7 +382,6 @@ static void __exit dm_delay_exit(void)
382{ 382{
383 dm_unregister_target(&delay_target); 383 dm_unregister_target(&delay_target);
384 kmem_cache_destroy(delayed_cache); 384 kmem_cache_destroy(delayed_cache);
385 destroy_workqueue(kdelayd_wq);
386} 385}
387 386
388/* Module hooks */ 387/* Module hooks */
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index aec57d76db5d..944690bafd93 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -66,6 +66,18 @@ struct dm_snapshot {
66 66
67 atomic_t pending_exceptions_count; 67 atomic_t pending_exceptions_count;
68 68
69 /* Protected by "lock" */
70 sector_t exception_start_sequence;
71
72 /* Protected by kcopyd single-threaded callback */
73 sector_t exception_complete_sequence;
74
75 /*
76 * A list of pending exceptions that completed out of order.
77 * Protected by kcopyd single-threaded callback.
78 */
79 struct list_head out_of_order_list;
80
69 mempool_t *pending_pool; 81 mempool_t *pending_pool;
70 82
71 struct dm_exception_table pending; 83 struct dm_exception_table pending;
@@ -173,6 +185,14 @@ struct dm_snap_pending_exception {
173 */ 185 */
174 int started; 186 int started;
175 187
188 /* There was copying error. */
189 int copy_error;
190
191 /* A sequence number, it is used for in-order completion. */
192 sector_t exception_sequence;
193
194 struct list_head out_of_order_entry;
195
176 /* 196 /*
177 * For writing a complete chunk, bypassing the copy. 197 * For writing a complete chunk, bypassing the copy.
178 */ 198 */
@@ -1094,6 +1114,9 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
1094 s->valid = 1; 1114 s->valid = 1;
1095 s->active = 0; 1115 s->active = 0;
1096 atomic_set(&s->pending_exceptions_count, 0); 1116 atomic_set(&s->pending_exceptions_count, 0);
1117 s->exception_start_sequence = 0;
1118 s->exception_complete_sequence = 0;
1119 INIT_LIST_HEAD(&s->out_of_order_list);
1097 init_rwsem(&s->lock); 1120 init_rwsem(&s->lock);
1098 INIT_LIST_HEAD(&s->list); 1121 INIT_LIST_HEAD(&s->list);
1099 spin_lock_init(&s->pe_lock); 1122 spin_lock_init(&s->pe_lock);
@@ -1443,6 +1466,19 @@ static void commit_callback(void *context, int success)
1443 pending_complete(pe, success); 1466 pending_complete(pe, success);
1444} 1467}
1445 1468
1469static void complete_exception(struct dm_snap_pending_exception *pe)
1470{
1471 struct dm_snapshot *s = pe->snap;
1472
1473 if (unlikely(pe->copy_error))
1474 pending_complete(pe, 0);
1475
1476 else
1477 /* Update the metadata if we are persistent */
1478 s->store->type->commit_exception(s->store, &pe->e,
1479 commit_callback, pe);
1480}
1481
1446/* 1482/*
1447 * Called when the copy I/O has finished. kcopyd actually runs 1483 * Called when the copy I/O has finished. kcopyd actually runs
1448 * this code so don't block. 1484 * this code so don't block.
@@ -1452,13 +1488,32 @@ static void copy_callback(int read_err, unsigned long write_err, void *context)
1452 struct dm_snap_pending_exception *pe = context; 1488 struct dm_snap_pending_exception *pe = context;
1453 struct dm_snapshot *s = pe->snap; 1489 struct dm_snapshot *s = pe->snap;
1454 1490
1455 if (read_err || write_err) 1491 pe->copy_error = read_err || write_err;
1456 pending_complete(pe, 0);
1457 1492
1458 else 1493 if (pe->exception_sequence == s->exception_complete_sequence) {
1459 /* Update the metadata if we are persistent */ 1494 s->exception_complete_sequence++;
1460 s->store->type->commit_exception(s->store, &pe->e, 1495 complete_exception(pe);
1461 commit_callback, pe); 1496
1497 while (!list_empty(&s->out_of_order_list)) {
1498 pe = list_entry(s->out_of_order_list.next,
1499 struct dm_snap_pending_exception, out_of_order_entry);
1500 if (pe->exception_sequence != s->exception_complete_sequence)
1501 break;
1502 s->exception_complete_sequence++;
1503 list_del(&pe->out_of_order_entry);
1504 complete_exception(pe);
1505 }
1506 } else {
1507 struct list_head *lh;
1508 struct dm_snap_pending_exception *pe2;
1509
1510 list_for_each_prev(lh, &s->out_of_order_list) {
1511 pe2 = list_entry(lh, struct dm_snap_pending_exception, out_of_order_entry);
1512 if (pe2->exception_sequence < pe->exception_sequence)
1513 break;
1514 }
1515 list_add(&pe->out_of_order_entry, lh);
1516 }
1462} 1517}
1463 1518
1464/* 1519/*
@@ -1553,6 +1608,8 @@ __find_pending_exception(struct dm_snapshot *s,
1553 return NULL; 1608 return NULL;
1554 } 1609 }
1555 1610
1611 pe->exception_sequence = s->exception_start_sequence++;
1612
1556 dm_insert_exception(&s->pending, &pe->e); 1613 dm_insert_exception(&s->pending, &pe->e);
1557 1614
1558 return pe; 1615 return pe;
@@ -2192,7 +2249,7 @@ static struct target_type origin_target = {
2192 2249
2193static struct target_type snapshot_target = { 2250static struct target_type snapshot_target = {
2194 .name = "snapshot", 2251 .name = "snapshot",
2195 .version = {1, 11, 1}, 2252 .version = {1, 12, 0},
2196 .module = THIS_MODULE, 2253 .module = THIS_MODULE,
2197 .ctr = snapshot_ctr, 2254 .ctr = snapshot_ctr,
2198 .dtr = snapshot_dtr, 2255 .dtr = snapshot_dtr,
diff --git a/drivers/md/dm-stats.c b/drivers/md/dm-stats.c
index 3d404c1371ed..28a90122a5a8 100644
--- a/drivers/md/dm-stats.c
+++ b/drivers/md/dm-stats.c
@@ -964,6 +964,7 @@ int dm_stats_message(struct mapped_device *md, unsigned argc, char **argv,
964 964
965int __init dm_statistics_init(void) 965int __init dm_statistics_init(void)
966{ 966{
967 shared_memory_amount = 0;
967 dm_stat_need_rcu_barrier = 0; 968 dm_stat_need_rcu_barrier = 0;
968 return 0; 969 return 0;
969} 970}
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 465f08ca62b1..3ba6a3859ce3 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -200,6 +200,11 @@ int dm_table_create(struct dm_table **result, fmode_t mode,
200 200
201 num_targets = dm_round_up(num_targets, KEYS_PER_NODE); 201 num_targets = dm_round_up(num_targets, KEYS_PER_NODE);
202 202
203 if (!num_targets) {
204 kfree(t);
205 return -ENOMEM;
206 }
207
203 if (alloc_targets(t, num_targets)) { 208 if (alloc_targets(t, num_targets)) {
204 kfree(t); 209 kfree(t);
205 return -ENOMEM; 210 return -ENOMEM;
diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
index 60bce435f4fa..8a30ad54bd46 100644
--- a/drivers/md/dm-thin-metadata.c
+++ b/drivers/md/dm-thin-metadata.c
@@ -1697,6 +1697,14 @@ void dm_pool_metadata_read_only(struct dm_pool_metadata *pmd)
1697 up_write(&pmd->root_lock); 1697 up_write(&pmd->root_lock);
1698} 1698}
1699 1699
1700void dm_pool_metadata_read_write(struct dm_pool_metadata *pmd)
1701{
1702 down_write(&pmd->root_lock);
1703 pmd->read_only = false;
1704 dm_bm_set_read_write(pmd->bm);
1705 up_write(&pmd->root_lock);
1706}
1707
1700int dm_pool_register_metadata_threshold(struct dm_pool_metadata *pmd, 1708int dm_pool_register_metadata_threshold(struct dm_pool_metadata *pmd,
1701 dm_block_t threshold, 1709 dm_block_t threshold,
1702 dm_sm_threshold_fn fn, 1710 dm_sm_threshold_fn fn,
diff --git a/drivers/md/dm-thin-metadata.h b/drivers/md/dm-thin-metadata.h
index 845ebbe589a9..7bcc0e1d6238 100644
--- a/drivers/md/dm-thin-metadata.h
+++ b/drivers/md/dm-thin-metadata.h
@@ -193,6 +193,7 @@ int dm_pool_resize_metadata_dev(struct dm_pool_metadata *pmd, dm_block_t new_siz
193 * that nothing is changing. 193 * that nothing is changing.
194 */ 194 */
195void dm_pool_metadata_read_only(struct dm_pool_metadata *pmd); 195void dm_pool_metadata_read_only(struct dm_pool_metadata *pmd);
196void dm_pool_metadata_read_write(struct dm_pool_metadata *pmd);
196 197
197int dm_pool_register_metadata_threshold(struct dm_pool_metadata *pmd, 198int dm_pool_register_metadata_threshold(struct dm_pool_metadata *pmd,
198 dm_block_t threshold, 199 dm_block_t threshold,
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index 2c0cf511ec23..ee29037ffc2e 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -640,7 +640,9 @@ static void process_prepared_mapping(struct dm_thin_new_mapping *m)
640 */ 640 */
641 r = dm_thin_insert_block(tc->td, m->virt_block, m->data_block); 641 r = dm_thin_insert_block(tc->td, m->virt_block, m->data_block);
642 if (r) { 642 if (r) {
643 DMERR_LIMIT("dm_thin_insert_block() failed"); 643 DMERR_LIMIT("%s: dm_thin_insert_block() failed: error = %d",
644 dm_device_name(pool->pool_md), r);
645 set_pool_mode(pool, PM_READ_ONLY);
644 cell_error(pool, m->cell); 646 cell_error(pool, m->cell);
645 goto out; 647 goto out;
646 } 648 }
@@ -881,32 +883,23 @@ static void schedule_zero(struct thin_c *tc, dm_block_t virt_block,
881 } 883 }
882} 884}
883 885
884static int commit(struct pool *pool)
885{
886 int r;
887
888 r = dm_pool_commit_metadata(pool->pmd);
889 if (r)
890 DMERR_LIMIT("%s: commit failed: error = %d",
891 dm_device_name(pool->pool_md), r);
892
893 return r;
894}
895
896/* 886/*
897 * A non-zero return indicates read_only or fail_io mode. 887 * A non-zero return indicates read_only or fail_io mode.
898 * Many callers don't care about the return value. 888 * Many callers don't care about the return value.
899 */ 889 */
900static int commit_or_fallback(struct pool *pool) 890static int commit(struct pool *pool)
901{ 891{
902 int r; 892 int r;
903 893
904 if (get_pool_mode(pool) != PM_WRITE) 894 if (get_pool_mode(pool) != PM_WRITE)
905 return -EINVAL; 895 return -EINVAL;
906 896
907 r = commit(pool); 897 r = dm_pool_commit_metadata(pool->pmd);
908 if (r) 898 if (r) {
899 DMERR_LIMIT("%s: dm_pool_commit_metadata failed: error = %d",
900 dm_device_name(pool->pool_md), r);
909 set_pool_mode(pool, PM_READ_ONLY); 901 set_pool_mode(pool, PM_READ_ONLY);
902 }
910 903
911 return r; 904 return r;
912} 905}
@@ -943,7 +936,9 @@ static int alloc_data_block(struct thin_c *tc, dm_block_t *result)
943 * Try to commit to see if that will free up some 936 * Try to commit to see if that will free up some
944 * more space. 937 * more space.
945 */ 938 */
946 (void) commit_or_fallback(pool); 939 r = commit(pool);
940 if (r)
941 return r;
947 942
948 r = dm_pool_get_free_block_count(pool->pmd, &free_blocks); 943 r = dm_pool_get_free_block_count(pool->pmd, &free_blocks);
949 if (r) 944 if (r)
@@ -957,7 +952,7 @@ static int alloc_data_block(struct thin_c *tc, dm_block_t *result)
957 * table reload). 952 * table reload).
958 */ 953 */
959 if (!free_blocks) { 954 if (!free_blocks) {
960 DMWARN("%s: no free space available.", 955 DMWARN("%s: no free data space available.",
961 dm_device_name(pool->pool_md)); 956 dm_device_name(pool->pool_md));
962 spin_lock_irqsave(&pool->lock, flags); 957 spin_lock_irqsave(&pool->lock, flags);
963 pool->no_free_space = 1; 958 pool->no_free_space = 1;
@@ -967,8 +962,16 @@ static int alloc_data_block(struct thin_c *tc, dm_block_t *result)
967 } 962 }
968 963
969 r = dm_pool_alloc_data_block(pool->pmd, result); 964 r = dm_pool_alloc_data_block(pool->pmd, result);
970 if (r) 965 if (r) {
966 if (r == -ENOSPC &&
967 !dm_pool_get_free_metadata_block_count(pool->pmd, &free_blocks) &&
968 !free_blocks) {
969 DMWARN("%s: no free metadata space available.",
970 dm_device_name(pool->pool_md));
971 set_pool_mode(pool, PM_READ_ONLY);
972 }
971 return r; 973 return r;
974 }
972 975
973 return 0; 976 return 0;
974} 977}
@@ -1349,7 +1352,7 @@ static void process_deferred_bios(struct pool *pool)
1349 if (bio_list_empty(&bios) && !need_commit_due_to_time(pool)) 1352 if (bio_list_empty(&bios) && !need_commit_due_to_time(pool))
1350 return; 1353 return;
1351 1354
1352 if (commit_or_fallback(pool)) { 1355 if (commit(pool)) {
1353 while ((bio = bio_list_pop(&bios))) 1356 while ((bio = bio_list_pop(&bios)))
1354 bio_io_error(bio); 1357 bio_io_error(bio);
1355 return; 1358 return;
@@ -1397,6 +1400,7 @@ static void set_pool_mode(struct pool *pool, enum pool_mode mode)
1397 case PM_FAIL: 1400 case PM_FAIL:
1398 DMERR("%s: switching pool to failure mode", 1401 DMERR("%s: switching pool to failure mode",
1399 dm_device_name(pool->pool_md)); 1402 dm_device_name(pool->pool_md));
1403 dm_pool_metadata_read_only(pool->pmd);
1400 pool->process_bio = process_bio_fail; 1404 pool->process_bio = process_bio_fail;
1401 pool->process_discard = process_bio_fail; 1405 pool->process_discard = process_bio_fail;
1402 pool->process_prepared_mapping = process_prepared_mapping_fail; 1406 pool->process_prepared_mapping = process_prepared_mapping_fail;
@@ -1421,6 +1425,7 @@ static void set_pool_mode(struct pool *pool, enum pool_mode mode)
1421 break; 1425 break;
1422 1426
1423 case PM_WRITE: 1427 case PM_WRITE:
1428 dm_pool_metadata_read_write(pool->pmd);
1424 pool->process_bio = process_bio; 1429 pool->process_bio = process_bio;
1425 pool->process_discard = process_discard; 1430 pool->process_discard = process_discard;
1426 pool->process_prepared_mapping = process_prepared_mapping; 1431 pool->process_prepared_mapping = process_prepared_mapping;
@@ -1637,12 +1642,19 @@ static int bind_control_target(struct pool *pool, struct dm_target *ti)
1637 struct pool_c *pt = ti->private; 1642 struct pool_c *pt = ti->private;
1638 1643
1639 /* 1644 /*
1640 * We want to make sure that degraded pools are never upgraded. 1645 * We want to make sure that a pool in PM_FAIL mode is never upgraded.
1641 */ 1646 */
1642 enum pool_mode old_mode = pool->pf.mode; 1647 enum pool_mode old_mode = pool->pf.mode;
1643 enum pool_mode new_mode = pt->adjusted_pf.mode; 1648 enum pool_mode new_mode = pt->adjusted_pf.mode;
1644 1649
1645 if (old_mode > new_mode) 1650 /*
1651 * If we were in PM_FAIL mode, rollback of metadata failed. We're
1652 * not going to recover without a thin_repair. So we never let the
1653 * pool move out of the old mode. On the other hand a PM_READ_ONLY
1654 * may have been due to a lack of metadata or data space, and may
1655 * now work (ie. if the underlying devices have been resized).
1656 */
1657 if (old_mode == PM_FAIL)
1646 new_mode = old_mode; 1658 new_mode = old_mode;
1647 1659
1648 pool->ti = ti; 1660 pool->ti = ti;
@@ -2266,7 +2278,7 @@ static int pool_preresume(struct dm_target *ti)
2266 return r; 2278 return r;
2267 2279
2268 if (need_commit1 || need_commit2) 2280 if (need_commit1 || need_commit2)
2269 (void) commit_or_fallback(pool); 2281 (void) commit(pool);
2270 2282
2271 return 0; 2283 return 0;
2272} 2284}
@@ -2293,7 +2305,7 @@ static void pool_postsuspend(struct dm_target *ti)
2293 2305
2294 cancel_delayed_work(&pool->waker); 2306 cancel_delayed_work(&pool->waker);
2295 flush_workqueue(pool->wq); 2307 flush_workqueue(pool->wq);
2296 (void) commit_or_fallback(pool); 2308 (void) commit(pool);
2297} 2309}
2298 2310
2299static int check_arg_count(unsigned argc, unsigned args_required) 2311static int check_arg_count(unsigned argc, unsigned args_required)
@@ -2427,7 +2439,7 @@ static int process_reserve_metadata_snap_mesg(unsigned argc, char **argv, struct
2427 if (r) 2439 if (r)
2428 return r; 2440 return r;
2429 2441
2430 (void) commit_or_fallback(pool); 2442 (void) commit(pool);
2431 2443
2432 r = dm_pool_reserve_metadata_snap(pool->pmd); 2444 r = dm_pool_reserve_metadata_snap(pool->pmd);
2433 if (r) 2445 if (r)
@@ -2489,7 +2501,7 @@ static int pool_message(struct dm_target *ti, unsigned argc, char **argv)
2489 DMWARN("Unrecognised thin pool target message received: %s", argv[0]); 2501 DMWARN("Unrecognised thin pool target message received: %s", argv[0]);
2490 2502
2491 if (!r) 2503 if (!r)
2492 (void) commit_or_fallback(pool); 2504 (void) commit(pool);
2493 2505
2494 return r; 2506 return r;
2495} 2507}
@@ -2544,7 +2556,7 @@ static void pool_status(struct dm_target *ti, status_type_t type,
2544 2556
2545 /* Commit to ensure statistics aren't out-of-date */ 2557 /* Commit to ensure statistics aren't out-of-date */
2546 if (!(status_flags & DM_STATUS_NOFLUSH_FLAG) && !dm_suspended(ti)) 2558 if (!(status_flags & DM_STATUS_NOFLUSH_FLAG) && !dm_suspended(ti))
2547 (void) commit_or_fallback(pool); 2559 (void) commit(pool);
2548 2560
2549 r = dm_pool_get_metadata_transaction_id(pool->pmd, &transaction_id); 2561 r = dm_pool_get_metadata_transaction_id(pool->pmd, &transaction_id);
2550 if (r) { 2562 if (r) {
diff --git a/drivers/md/persistent-data/dm-array.c b/drivers/md/persistent-data/dm-array.c
index af96e24ec328..1d75b1dc1e2e 100644
--- a/drivers/md/persistent-data/dm-array.c
+++ b/drivers/md/persistent-data/dm-array.c
@@ -317,8 +317,16 @@ static int shadow_ablock(struct dm_array_info *info, dm_block_t *root,
317 * The shadow op will often be a noop. Only insert if it really 317 * The shadow op will often be a noop. Only insert if it really
318 * copied data. 318 * copied data.
319 */ 319 */
320 if (dm_block_location(*block) != b) 320 if (dm_block_location(*block) != b) {
321 /*
322 * dm_tm_shadow_block will have already decremented the old
323 * block, but it is still referenced by the btree. We
324 * increment to stop the insert decrementing it below zero
325 * when overwriting the old value.
326 */
327 dm_tm_inc(info->btree_info.tm, b);
321 r = insert_ablock(info, index, *block, root); 328 r = insert_ablock(info, index, *block, root);
329 }
322 330
323 return r; 331 return r;
324} 332}
diff --git a/drivers/md/persistent-data/dm-block-manager.c b/drivers/md/persistent-data/dm-block-manager.c
index a7e8bf296388..064a3c271baa 100644
--- a/drivers/md/persistent-data/dm-block-manager.c
+++ b/drivers/md/persistent-data/dm-block-manager.c
@@ -626,6 +626,12 @@ void dm_bm_set_read_only(struct dm_block_manager *bm)
626} 626}
627EXPORT_SYMBOL_GPL(dm_bm_set_read_only); 627EXPORT_SYMBOL_GPL(dm_bm_set_read_only);
628 628
629void dm_bm_set_read_write(struct dm_block_manager *bm)
630{
631 bm->read_only = false;
632}
633EXPORT_SYMBOL_GPL(dm_bm_set_read_write);
634
629u32 dm_bm_checksum(const void *data, size_t len, u32 init_xor) 635u32 dm_bm_checksum(const void *data, size_t len, u32 init_xor)
630{ 636{
631 return crc32c(~(u32) 0, data, len) ^ init_xor; 637 return crc32c(~(u32) 0, data, len) ^ init_xor;
diff --git a/drivers/md/persistent-data/dm-block-manager.h b/drivers/md/persistent-data/dm-block-manager.h
index 9a82083a66b6..13cd58e1fe69 100644
--- a/drivers/md/persistent-data/dm-block-manager.h
+++ b/drivers/md/persistent-data/dm-block-manager.h
@@ -108,9 +108,9 @@ int dm_bm_unlock(struct dm_block *b);
108int dm_bm_flush_and_unlock(struct dm_block_manager *bm, 108int dm_bm_flush_and_unlock(struct dm_block_manager *bm,
109 struct dm_block *superblock); 109 struct dm_block *superblock);
110 110
111 /* 111/*
112 * Request data be prefetched into the cache. 112 * Request data is prefetched into the cache.
113 */ 113 */
114void dm_bm_prefetch(struct dm_block_manager *bm, dm_block_t b); 114void dm_bm_prefetch(struct dm_block_manager *bm, dm_block_t b);
115 115
116/* 116/*
@@ -125,6 +125,7 @@ void dm_bm_prefetch(struct dm_block_manager *bm, dm_block_t b);
125 * be returned if you do. 125 * be returned if you do.
126 */ 126 */
127void dm_bm_set_read_only(struct dm_block_manager *bm); 127void dm_bm_set_read_only(struct dm_block_manager *bm);
128void dm_bm_set_read_write(struct dm_block_manager *bm);
128 129
129u32 dm_bm_checksum(const void *data, size_t len, u32 init_xor); 130u32 dm_bm_checksum(const void *data, size_t len, u32 init_xor);
130 131
diff --git a/drivers/md/persistent-data/dm-space-map-common.c b/drivers/md/persistent-data/dm-space-map-common.c
index 6058569fe86c..466a60bbd716 100644
--- a/drivers/md/persistent-data/dm-space-map-common.c
+++ b/drivers/md/persistent-data/dm-space-map-common.c
@@ -381,7 +381,7 @@ int sm_ll_find_free_block(struct ll_disk *ll, dm_block_t begin,
381} 381}
382 382
383static int sm_ll_mutate(struct ll_disk *ll, dm_block_t b, 383static int sm_ll_mutate(struct ll_disk *ll, dm_block_t b,
384 uint32_t (*mutator)(void *context, uint32_t old), 384 int (*mutator)(void *context, uint32_t old, uint32_t *new),
385 void *context, enum allocation_event *ev) 385 void *context, enum allocation_event *ev)
386{ 386{
387 int r; 387 int r;
@@ -410,11 +410,17 @@ static int sm_ll_mutate(struct ll_disk *ll, dm_block_t b,
410 410
411 if (old > 2) { 411 if (old > 2) {
412 r = sm_ll_lookup_big_ref_count(ll, b, &old); 412 r = sm_ll_lookup_big_ref_count(ll, b, &old);
413 if (r < 0) 413 if (r < 0) {
414 dm_tm_unlock(ll->tm, nb);
414 return r; 415 return r;
416 }
415 } 417 }
416 418
417 ref_count = mutator(context, old); 419 r = mutator(context, old, &ref_count);
420 if (r) {
421 dm_tm_unlock(ll->tm, nb);
422 return r;
423 }
418 424
419 if (ref_count <= 2) { 425 if (ref_count <= 2) {
420 sm_set_bitmap(bm_le, bit, ref_count); 426 sm_set_bitmap(bm_le, bit, ref_count);
@@ -465,9 +471,10 @@ static int sm_ll_mutate(struct ll_disk *ll, dm_block_t b,
465 return ll->save_ie(ll, index, &ie_disk); 471 return ll->save_ie(ll, index, &ie_disk);
466} 472}
467 473
468static uint32_t set_ref_count(void *context, uint32_t old) 474static int set_ref_count(void *context, uint32_t old, uint32_t *new)
469{ 475{
470 return *((uint32_t *) context); 476 *new = *((uint32_t *) context);
477 return 0;
471} 478}
472 479
473int sm_ll_insert(struct ll_disk *ll, dm_block_t b, 480int sm_ll_insert(struct ll_disk *ll, dm_block_t b,
@@ -476,9 +483,10 @@ int sm_ll_insert(struct ll_disk *ll, dm_block_t b,
476 return sm_ll_mutate(ll, b, set_ref_count, &ref_count, ev); 483 return sm_ll_mutate(ll, b, set_ref_count, &ref_count, ev);
477} 484}
478 485
479static uint32_t inc_ref_count(void *context, uint32_t old) 486static int inc_ref_count(void *context, uint32_t old, uint32_t *new)
480{ 487{
481 return old + 1; 488 *new = old + 1;
489 return 0;
482} 490}
483 491
484int sm_ll_inc(struct ll_disk *ll, dm_block_t b, enum allocation_event *ev) 492int sm_ll_inc(struct ll_disk *ll, dm_block_t b, enum allocation_event *ev)
@@ -486,9 +494,15 @@ int sm_ll_inc(struct ll_disk *ll, dm_block_t b, enum allocation_event *ev)
486 return sm_ll_mutate(ll, b, inc_ref_count, NULL, ev); 494 return sm_ll_mutate(ll, b, inc_ref_count, NULL, ev);
487} 495}
488 496
489static uint32_t dec_ref_count(void *context, uint32_t old) 497static int dec_ref_count(void *context, uint32_t old, uint32_t *new)
490{ 498{
491 return old - 1; 499 if (!old) {
500 DMERR_LIMIT("unable to decrement a reference count below 0");
501 return -EINVAL;
502 }
503
504 *new = old - 1;
505 return 0;
492} 506}
493 507
494int sm_ll_dec(struct ll_disk *ll, dm_block_t b, enum allocation_event *ev) 508int sm_ll_dec(struct ll_disk *ll, dm_block_t b, enum allocation_event *ev)
diff --git a/drivers/md/persistent-data/dm-space-map-metadata.c b/drivers/md/persistent-data/dm-space-map-metadata.c
index 1c959684caef..58fc1eef7499 100644
--- a/drivers/md/persistent-data/dm-space-map-metadata.c
+++ b/drivers/md/persistent-data/dm-space-map-metadata.c
@@ -384,12 +384,16 @@ static int sm_metadata_new_block(struct dm_space_map *sm, dm_block_t *b)
384 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm); 384 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
385 385
386 int r = sm_metadata_new_block_(sm, b); 386 int r = sm_metadata_new_block_(sm, b);
387 if (r) 387 if (r) {
388 DMERR("unable to allocate new metadata block"); 388 DMERR("unable to allocate new metadata block");
389 return r;
390 }
389 391
390 r = sm_metadata_get_nr_free(sm, &count); 392 r = sm_metadata_get_nr_free(sm, &count);
391 if (r) 393 if (r) {
392 DMERR("couldn't get free block count"); 394 DMERR("couldn't get free block count");
395 return r;
396 }
393 397
394 check_threshold(&smm->threshold, count); 398 check_threshold(&smm->threshold, count);
395 399
diff --git a/drivers/media/common/siano/smscoreapi.h b/drivers/media/common/siano/smscoreapi.h
index d0799e323364..9c9063cd3208 100644
--- a/drivers/media/common/siano/smscoreapi.h
+++ b/drivers/media/common/siano/smscoreapi.h
@@ -955,7 +955,7 @@ struct sms_rx_stats {
955 u32 modem_state; /* from SMSHOSTLIB_DVB_MODEM_STATE_ET */ 955 u32 modem_state; /* from SMSHOSTLIB_DVB_MODEM_STATE_ET */
956 s32 SNR; /* dB */ 956 s32 SNR; /* dB */
957 u32 ber; /* Post Viterbi ber [1E-5] */ 957 u32 ber; /* Post Viterbi ber [1E-5] */
958 u32 ber_error_count; /* Number of erronous SYNC bits. */ 958 u32 ber_error_count; /* Number of erroneous SYNC bits. */
959 u32 ber_bit_count; /* Total number of SYNC bits. */ 959 u32 ber_bit_count; /* Total number of SYNC bits. */
960 u32 ts_per; /* Transport stream PER, 960 u32 ts_per; /* Transport stream PER,
961 0xFFFFFFFF indicate N/A */ 961 0xFFFFFFFF indicate N/A */
@@ -981,7 +981,7 @@ struct sms_rx_stats_ex {
981 u32 modem_state; /* from SMSHOSTLIB_DVB_MODEM_STATE_ET */ 981 u32 modem_state; /* from SMSHOSTLIB_DVB_MODEM_STATE_ET */
982 s32 SNR; /* dB */ 982 s32 SNR; /* dB */
983 u32 ber; /* Post Viterbi ber [1E-5] */ 983 u32 ber; /* Post Viterbi ber [1E-5] */
984 u32 ber_error_count; /* Number of erronous SYNC bits. */ 984 u32 ber_error_count; /* Number of erroneous SYNC bits. */
985 u32 ber_bit_count; /* Total number of SYNC bits. */ 985 u32 ber_bit_count; /* Total number of SYNC bits. */
986 u32 ts_per; /* Transport stream PER, 986 u32 ts_per; /* Transport stream PER,
987 0xFFFFFFFF indicate N/A */ 987 0xFFFFFFFF indicate N/A */
diff --git a/drivers/media/common/siano/smsdvb.h b/drivers/media/common/siano/smsdvb.h
index 92c413ba0c79..ae36d0ae0fb1 100644
--- a/drivers/media/common/siano/smsdvb.h
+++ b/drivers/media/common/siano/smsdvb.h
@@ -95,7 +95,7 @@ struct RECEPTION_STATISTICS_PER_SLICES_S {
95 u32 is_demod_locked; /* 0 - not locked, 1 - locked */ 95 u32 is_demod_locked; /* 0 - not locked, 1 - locked */
96 96
97 u32 ber_bit_count; /* Total number of SYNC bits. */ 97 u32 ber_bit_count; /* Total number of SYNC bits. */
98 u32 ber_error_count; /* Number of erronous SYNC bits. */ 98 u32 ber_error_count; /* Number of erroneous SYNC bits. */
99 99
100 s32 MRC_SNR; /* dB */ 100 s32 MRC_SNR; /* dB */
101 s32 mrc_in_band_pwr; /* In band power in dBM */ 101 s32 mrc_in_band_pwr; /* In band power in dBM */
diff --git a/drivers/media/dvb-core/dvb_demux.c b/drivers/media/dvb-core/dvb_demux.c
index 58de4410c525..6c7ff0cdcd32 100644
--- a/drivers/media/dvb-core/dvb_demux.c
+++ b/drivers/media/dvb-core/dvb_demux.c
@@ -435,7 +435,7 @@ static void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf)
435 dprintk_tscheck("TEI detected. " 435 dprintk_tscheck("TEI detected. "
436 "PID=0x%x data1=0x%x\n", 436 "PID=0x%x data1=0x%x\n",
437 pid, buf[1]); 437 pid, buf[1]);
438 /* data in this packet cant be trusted - drop it unless 438 /* data in this packet can't be trusted - drop it unless
439 * module option dvb_demux_feed_err_pkts is set */ 439 * module option dvb_demux_feed_err_pkts is set */
440 if (!dvb_demux_feed_err_pkts) 440 if (!dvb_demux_feed_err_pkts)
441 return; 441 return;
@@ -1032,8 +1032,13 @@ static int dmx_section_feed_release_filter(struct dmx_section_feed *feed,
1032 return -EINVAL; 1032 return -EINVAL;
1033 } 1033 }
1034 1034
1035 if (feed->is_filtering) 1035 if (feed->is_filtering) {
1036 /* release dvbdmx->mutex as far as it is
1037 acquired by stop_filtering() itself */
1038 mutex_unlock(&dvbdmx->mutex);
1036 feed->stop_filtering(feed); 1039 feed->stop_filtering(feed);
1040 mutex_lock(&dvbdmx->mutex);
1041 }
1037 1042
1038 spin_lock_irq(&dvbdmx->lock); 1043 spin_lock_irq(&dvbdmx->lock);
1039 f = dvbdmxfeed->filter; 1044 f = dvbdmxfeed->filter;
diff --git a/drivers/media/dvb-frontends/af9033.c b/drivers/media/dvb-frontends/af9033.c
index 30ee59052157..65728c25ea05 100644
--- a/drivers/media/dvb-frontends/af9033.c
+++ b/drivers/media/dvb-frontends/af9033.c
@@ -170,18 +170,18 @@ static int af9033_rd_reg_mask(struct af9033_state *state, u32 reg, u8 *val,
170static int af9033_wr_reg_val_tab(struct af9033_state *state, 170static int af9033_wr_reg_val_tab(struct af9033_state *state,
171 const struct reg_val *tab, int tab_len) 171 const struct reg_val *tab, int tab_len)
172{ 172{
173#define MAX_TAB_LEN 212
173 int ret, i, j; 174 int ret, i, j;
174 u8 buf[MAX_XFER_SIZE]; 175 u8 buf[1 + MAX_TAB_LEN];
176
177 dev_dbg(&state->i2c->dev, "%s: tab_len=%d\n", __func__, tab_len);
175 178
176 if (tab_len > sizeof(buf)) { 179 if (tab_len > sizeof(buf)) {
177 dev_warn(&state->i2c->dev, 180 dev_warn(&state->i2c->dev, "%s: tab len %d is too big\n",
178 "%s: i2c wr len=%d is too big!\n", 181 KBUILD_MODNAME, tab_len);
179 KBUILD_MODNAME, tab_len);
180 return -EINVAL; 182 return -EINVAL;
181 } 183 }
182 184
183 dev_dbg(&state->i2c->dev, "%s: tab_len=%d\n", __func__, tab_len);
184
185 for (i = 0, j = 0; i < tab_len; i++) { 185 for (i = 0, j = 0; i < tab_len; i++) {
186 buf[j] = tab[i].val; 186 buf[j] = tab[i].val;
187 187
diff --git a/drivers/media/dvb-frontends/cxd2820r_c.c b/drivers/media/dvb-frontends/cxd2820r_c.c
index 125a44041011..5c6ab4921bf1 100644
--- a/drivers/media/dvb-frontends/cxd2820r_c.c
+++ b/drivers/media/dvb-frontends/cxd2820r_c.c
@@ -78,7 +78,7 @@ int cxd2820r_set_frontend_c(struct dvb_frontend *fe)
78 78
79 num = if_freq / 1000; /* Hz => kHz */ 79 num = if_freq / 1000; /* Hz => kHz */
80 num *= 0x4000; 80 num *= 0x4000;
81 if_ctl = cxd2820r_div_u64_round_closest(num, 41000); 81 if_ctl = 0x4000 - cxd2820r_div_u64_round_closest(num, 41000);
82 buf[0] = (if_ctl >> 8) & 0x3f; 82 buf[0] = (if_ctl >> 8) & 0x3f;
83 buf[1] = (if_ctl >> 0) & 0xff; 83 buf[1] = (if_ctl >> 0) & 0xff;
84 84
diff --git a/drivers/media/dvb-frontends/dib8000.c b/drivers/media/dvb-frontends/dib8000.c
index 90536147bf04..6dbbee453ee1 100644
--- a/drivers/media/dvb-frontends/dib8000.c
+++ b/drivers/media/dvb-frontends/dib8000.c
@@ -3048,7 +3048,7 @@ static int dib8000_tune(struct dvb_frontend *fe)
3048 dib8000_set_diversity_in(state->fe[0], state->diversity_onoff); 3048 dib8000_set_diversity_in(state->fe[0], state->diversity_onoff);
3049 3049
3050 locks = (dib8000_read_word(state, 180) >> 6) & 0x3f; /* P_coff_winlen ? */ 3050 locks = (dib8000_read_word(state, 180) >> 6) & 0x3f; /* P_coff_winlen ? */
3051 /* coff should lock over P_coff_winlen ofdm symbols : give 3 times this lenght to lock */ 3051 /* coff should lock over P_coff_winlen ofdm symbols : give 3 times this length to lock */
3052 *timeout = dib8000_get_timeout(state, 2 * locks, SYMBOL_DEPENDENT_ON); 3052 *timeout = dib8000_get_timeout(state, 2 * locks, SYMBOL_DEPENDENT_ON);
3053 *tune_state = CT_DEMOD_STEP_5; 3053 *tune_state = CT_DEMOD_STEP_5;
3054 break; 3054 break;
@@ -3115,7 +3115,7 @@ static int dib8000_tune(struct dvb_frontend *fe)
3115 3115
3116 case CT_DEMOD_STEP_9: /* 39 */ 3116 case CT_DEMOD_STEP_9: /* 39 */
3117 if ((state->revision == 0x8090) || ((dib8000_read_word(state, 1291) >> 9) & 0x1)) { /* fe capable of deinterleaving : esram */ 3117 if ((state->revision == 0x8090) || ((dib8000_read_word(state, 1291) >> 9) & 0x1)) { /* fe capable of deinterleaving : esram */
3118 /* defines timeout for mpeg lock depending on interleaver lenght of longest layer */ 3118 /* defines timeout for mpeg lock depending on interleaver length of longest layer */
3119 for (i = 0; i < 3; i++) { 3119 for (i = 0; i < 3; i++) {
3120 if (c->layer[i].interleaving >= deeper_interleaver) { 3120 if (c->layer[i].interleaving >= deeper_interleaver) {
3121 dprintk("layer%i: time interleaver = %d ", i, c->layer[i].interleaving); 3121 dprintk("layer%i: time interleaver = %d ", i, c->layer[i].interleaving);
diff --git a/drivers/media/dvb-frontends/drxk_hard.c b/drivers/media/dvb-frontends/drxk_hard.c
index d416c15691da..bf29a3f0e6f0 100644
--- a/drivers/media/dvb-frontends/drxk_hard.c
+++ b/drivers/media/dvb-frontends/drxk_hard.c
@@ -1191,7 +1191,7 @@ static int mpegts_configure_pins(struct drxk_state *state, bool mpeg_enable)
1191 goto error; 1191 goto error;
1192 1192
1193 if (state->m_enable_parallel == true) { 1193 if (state->m_enable_parallel == true) {
1194 /* paralel -> enable MD1 to MD7 */ 1194 /* parallel -> enable MD1 to MD7 */
1195 status = write16(state, SIO_PDR_MD1_CFG__A, 1195 status = write16(state, SIO_PDR_MD1_CFG__A,
1196 sio_pdr_mdx_cfg); 1196 sio_pdr_mdx_cfg);
1197 if (status < 0) 1197 if (status < 0)
@@ -1428,7 +1428,7 @@ static int mpegts_stop(struct drxk_state *state)
1428 1428
1429 dprintk(1, "\n"); 1429 dprintk(1, "\n");
1430 1430
1431 /* Gracefull shutdown (byte boundaries) */ 1431 /* Graceful shutdown (byte boundaries) */
1432 status = read16(state, FEC_OC_SNC_MODE__A, &fec_oc_snc_mode); 1432 status = read16(state, FEC_OC_SNC_MODE__A, &fec_oc_snc_mode);
1433 if (status < 0) 1433 if (status < 0)
1434 goto error; 1434 goto error;
@@ -2021,7 +2021,7 @@ static int mpegts_dto_setup(struct drxk_state *state,
2021 fec_oc_dto_burst_len = 204; 2021 fec_oc_dto_burst_len = 204;
2022 } 2022 }
2023 2023
2024 /* Check serial or parrallel output */ 2024 /* Check serial or parallel output */
2025 fec_oc_reg_ipr_mode &= (~(FEC_OC_IPR_MODE_SERIAL__M)); 2025 fec_oc_reg_ipr_mode &= (~(FEC_OC_IPR_MODE_SERIAL__M));
2026 if (state->m_enable_parallel == false) { 2026 if (state->m_enable_parallel == false) {
2027 /* MPEG data output is serial -> set ipr_mode[0] */ 2027 /* MPEG data output is serial -> set ipr_mode[0] */
@@ -2908,7 +2908,7 @@ static int adc_synchronization(struct drxk_state *state)
2908 goto error; 2908 goto error;
2909 2909
2910 if (count == 1) { 2910 if (count == 1) {
2911 /* Try sampling on a diffrent edge */ 2911 /* Try sampling on a different edge */
2912 u16 clk_neg = 0; 2912 u16 clk_neg = 0;
2913 2913
2914 status = read16(state, IQM_AF_CLKNEG__A, &clk_neg); 2914 status = read16(state, IQM_AF_CLKNEG__A, &clk_neg);
@@ -3306,7 +3306,7 @@ static int dvbt_sc_command(struct drxk_state *state,
3306 if (status < 0) 3306 if (status < 0)
3307 goto error; 3307 goto error;
3308 3308
3309 /* Retreive results parameters from SC */ 3309 /* Retrieve results parameters from SC */
3310 switch (cmd) { 3310 switch (cmd) {
3311 /* All commands yielding 5 results */ 3311 /* All commands yielding 5 results */
3312 /* All commands yielding 4 results */ 3312 /* All commands yielding 4 results */
@@ -3849,7 +3849,7 @@ static int set_dvbt(struct drxk_state *state, u16 intermediate_freqk_hz,
3849 break; 3849 break;
3850 } 3850 }
3851#if 0 3851#if 0
3852 /* No hierachical channels support in BDA */ 3852 /* No hierarchical channels support in BDA */
3853 /* Priority (only for hierarchical channels) */ 3853 /* Priority (only for hierarchical channels) */
3854 switch (channel->priority) { 3854 switch (channel->priority) {
3855 case DRX_PRIORITY_LOW: 3855 case DRX_PRIORITY_LOW:
@@ -4081,7 +4081,7 @@ error:
4081/*============================================================================*/ 4081/*============================================================================*/
4082 4082
4083/** 4083/**
4084* \brief Retreive lock status . 4084* \brief Retrieve lock status .
4085* \param demod Pointer to demodulator instance. 4085* \param demod Pointer to demodulator instance.
4086* \param lockStat Pointer to lock status structure. 4086* \param lockStat Pointer to lock status structure.
4087* \return DRXStatus_t. 4087* \return DRXStatus_t.
@@ -6174,7 +6174,7 @@ static int init_drxk(struct drxk_state *state)
6174 goto error; 6174 goto error;
6175 6175
6176 /* Stamp driver version number in SCU data RAM in BCD code 6176 /* Stamp driver version number in SCU data RAM in BCD code
6177 Done to enable field application engineers to retreive drxdriver version 6177 Done to enable field application engineers to retrieve drxdriver version
6178 via I2C from SCU RAM. 6178 via I2C from SCU RAM.
6179 Not using SCU command interface for SCU register access since no 6179 Not using SCU command interface for SCU register access since no
6180 microcode may be present. 6180 microcode may be present.
@@ -6399,7 +6399,7 @@ static int drxk_set_parameters(struct dvb_frontend *fe)
6399 fe->ops.tuner_ops.get_if_frequency(fe, &IF); 6399 fe->ops.tuner_ops.get_if_frequency(fe, &IF);
6400 start(state, 0, IF); 6400 start(state, 0, IF);
6401 6401
6402 /* After set_frontend, stats aren't avaliable */ 6402 /* After set_frontend, stats aren't available */
6403 p->strength.stat[0].scale = FE_SCALE_RELATIVE; 6403 p->strength.stat[0].scale = FE_SCALE_RELATIVE;
6404 p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; 6404 p->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
6405 p->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; 6405 p->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE;
diff --git a/drivers/media/dvb-frontends/rtl2830.c b/drivers/media/dvb-frontends/rtl2830.c
index 7efb796c472c..50e8b63e5169 100644
--- a/drivers/media/dvb-frontends/rtl2830.c
+++ b/drivers/media/dvb-frontends/rtl2830.c
@@ -710,6 +710,7 @@ struct dvb_frontend *rtl2830_attach(const struct rtl2830_config *cfg,
710 sizeof(priv->tuner_i2c_adapter.name)); 710 sizeof(priv->tuner_i2c_adapter.name));
711 priv->tuner_i2c_adapter.algo = &rtl2830_tuner_i2c_algo; 711 priv->tuner_i2c_adapter.algo = &rtl2830_tuner_i2c_algo;
712 priv->tuner_i2c_adapter.algo_data = NULL; 712 priv->tuner_i2c_adapter.algo_data = NULL;
713 priv->tuner_i2c_adapter.dev.parent = &i2c->dev;
713 i2c_set_adapdata(&priv->tuner_i2c_adapter, priv); 714 i2c_set_adapdata(&priv->tuner_i2c_adapter, priv);
714 if (i2c_add_adapter(&priv->tuner_i2c_adapter) < 0) { 715 if (i2c_add_adapter(&priv->tuner_i2c_adapter) < 0) {
715 dev_err(&i2c->dev, 716 dev_err(&i2c->dev,
diff --git a/drivers/media/i2c/adv7183_regs.h b/drivers/media/i2c/adv7183_regs.h
index 4a5b7d211d2f..b253d400e817 100644
--- a/drivers/media/i2c/adv7183_regs.h
+++ b/drivers/media/i2c/adv7183_regs.h
@@ -52,9 +52,9 @@
52#define ADV7183_VS_FIELD_CTRL_1 0x31 /* Vsync field control 1 */ 52#define ADV7183_VS_FIELD_CTRL_1 0x31 /* Vsync field control 1 */
53#define ADV7183_VS_FIELD_CTRL_2 0x32 /* Vsync field control 2 */ 53#define ADV7183_VS_FIELD_CTRL_2 0x32 /* Vsync field control 2 */
54#define ADV7183_VS_FIELD_CTRL_3 0x33 /* Vsync field control 3 */ 54#define ADV7183_VS_FIELD_CTRL_3 0x33 /* Vsync field control 3 */
55#define ADV7183_HS_POS_CTRL_1 0x34 /* Hsync positon control 1 */ 55#define ADV7183_HS_POS_CTRL_1 0x34 /* Hsync position control 1 */
56#define ADV7183_HS_POS_CTRL_2 0x35 /* Hsync positon control 2 */ 56#define ADV7183_HS_POS_CTRL_2 0x35 /* Hsync position control 2 */
57#define ADV7183_HS_POS_CTRL_3 0x36 /* Hsync positon control 3 */ 57#define ADV7183_HS_POS_CTRL_3 0x36 /* Hsync position control 3 */
58#define ADV7183_POLARITY 0x37 /* Polarity */ 58#define ADV7183_POLARITY 0x37 /* Polarity */
59#define ADV7183_NTSC_COMB_CTRL 0x38 /* NTSC comb control */ 59#define ADV7183_NTSC_COMB_CTRL 0x38 /* NTSC comb control */
60#define ADV7183_PAL_COMB_CTRL 0x39 /* PAL comb control */ 60#define ADV7183_PAL_COMB_CTRL 0x39 /* PAL comb control */
diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
index fbfdd2fc2a36..a324106b9f11 100644
--- a/drivers/media/i2c/adv7604.c
+++ b/drivers/media/i2c/adv7604.c
@@ -877,7 +877,7 @@ static void configure_custom_video_timings(struct v4l2_subdev *sd,
877 break; 877 break;
878 case ADV7604_MODE_HDMI: 878 case ADV7604_MODE_HDMI:
879 /* set default prim_mode/vid_std for HDMI 879 /* set default prim_mode/vid_std for HDMI
880 accoring to [REF_03, c. 4.2] */ 880 according to [REF_03, c. 4.2] */
881 io_write(sd, 0x00, 0x02); /* video std */ 881 io_write(sd, 0x00, 0x02); /* video std */
882 io_write(sd, 0x01, 0x06); /* prim mode */ 882 io_write(sd, 0x01, 0x06); /* prim mode */
883 break; 883 break;
diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
index 22f729d66a96..b154f36740b4 100644
--- a/drivers/media/i2c/adv7842.c
+++ b/drivers/media/i2c/adv7842.c
@@ -1013,7 +1013,7 @@ static void configure_custom_video_timings(struct v4l2_subdev *sd,
1013 break; 1013 break;
1014 case ADV7842_MODE_HDMI: 1014 case ADV7842_MODE_HDMI:
1015 /* set default prim_mode/vid_std for HDMI 1015 /* set default prim_mode/vid_std for HDMI
1016 accoring to [REF_03, c. 4.2] */ 1016 according to [REF_03, c. 4.2] */
1017 io_write(sd, 0x00, 0x02); /* video std */ 1017 io_write(sd, 0x00, 0x02); /* video std */
1018 io_write(sd, 0x01, 0x06); /* prim mode */ 1018 io_write(sd, 0x01, 0x06); /* prim mode */
1019 break; 1019 break;
diff --git a/drivers/media/i2c/ir-kbd-i2c.c b/drivers/media/i2c/ir-kbd-i2c.c
index 82bf5679da30..99ee456700f4 100644
--- a/drivers/media/i2c/ir-kbd-i2c.c
+++ b/drivers/media/i2c/ir-kbd-i2c.c
@@ -394,7 +394,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
394 394
395 if (!rc) { 395 if (!rc) {
396 /* 396 /*
397 * If platform_data doesn't specify rc_dev, initilize it 397 * If platform_data doesn't specify rc_dev, initialize it
398 * internally 398 * internally
399 */ 399 */
400 rc = rc_allocate_device(); 400 rc = rc_allocate_device();
diff --git a/drivers/media/i2c/m5mols/m5mols_controls.c b/drivers/media/i2c/m5mols/m5mols_controls.c
index f34429e452ab..a60931e66312 100644
--- a/drivers/media/i2c/m5mols/m5mols_controls.c
+++ b/drivers/media/i2c/m5mols/m5mols_controls.c
@@ -544,7 +544,7 @@ int m5mols_init_controls(struct v4l2_subdev *sd)
544 u16 zoom_step; 544 u16 zoom_step;
545 int ret; 545 int ret;
546 546
547 /* Determine the firmware dependant control range and step values */ 547 /* Determine the firmware dependent control range and step values */
548 ret = m5mols_read_u16(sd, AE_MAX_GAIN_MON, &exposure_max); 548 ret = m5mols_read_u16(sd, AE_MAX_GAIN_MON, &exposure_max);
549 if (ret < 0) 549 if (ret < 0)
550 return ret; 550 return ret;
diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
index 4734836fe5a4..1c2303d18bf4 100644
--- a/drivers/media/i2c/mt9p031.c
+++ b/drivers/media/i2c/mt9p031.c
@@ -19,6 +19,7 @@
19#include <linux/i2c.h> 19#include <linux/i2c.h>
20#include <linux/log2.h> 20#include <linux/log2.h>
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/of.h>
22#include <linux/of_gpio.h> 23#include <linux/of_gpio.h>
23#include <linux/pm.h> 24#include <linux/pm.h>
24#include <linux/regulator/consumer.h> 25#include <linux/regulator/consumer.h>
diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
index 6fec9384d86e..e7f555cc827a 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
+++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
@@ -1460,7 +1460,7 @@ static int s5c73m3_oif_registered(struct v4l2_subdev *sd)
1460 mutex_unlock(&state->lock); 1460 mutex_unlock(&state->lock);
1461 1461
1462 v4l2_dbg(1, s5c73m3_dbg, sd, "%s: Booting %s (%d)\n", 1462 v4l2_dbg(1, s5c73m3_dbg, sd, "%s: Booting %s (%d)\n",
1463 __func__, ret ? "failed" : "succeded", ret); 1463 __func__, ret ? "failed" : "succeeded", ret);
1464 1464
1465 return ret; 1465 return ret;
1466} 1466}
diff --git a/drivers/media/i2c/s5c73m3/s5c73m3.h b/drivers/media/i2c/s5c73m3/s5c73m3.h
index 9d2c08652246..9dfa516f6944 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3.h
+++ b/drivers/media/i2c/s5c73m3/s5c73m3.h
@@ -393,7 +393,7 @@ struct s5c73m3 {
393 393
394 /* External master clock frequency */ 394 /* External master clock frequency */
395 u32 mclk_frequency; 395 u32 mclk_frequency;
396 /* Video bus type - MIPI-CSI2/paralell */ 396 /* Video bus type - MIPI-CSI2/parallel */
397 enum v4l2_mbus_type bus_type; 397 enum v4l2_mbus_type bus_type;
398 398
399 const struct s5c73m3_frame_size *sensor_pix_size[2]; 399 const struct s5c73m3_frame_size *sensor_pix_size[2];
diff --git a/drivers/media/i2c/saa7115.c b/drivers/media/i2c/saa7115.c
index 637d02634527..afdbcb045cee 100644
--- a/drivers/media/i2c/saa7115.c
+++ b/drivers/media/i2c/saa7115.c
@@ -1699,7 +1699,7 @@ static void saa711x_write_platform_data(struct saa711x_state *state,
1699 * the analog demod. 1699 * the analog demod.
1700 * If the tuner is not found, it returns -ENODEV. 1700 * If the tuner is not found, it returns -ENODEV.
1701 * If auto-detection is disabled and the tuner doesn't match what it was 1701 * If auto-detection is disabled and the tuner doesn't match what it was
1702 * requred, it returns -EINVAL and fills 'name'. 1702 * required, it returns -EINVAL and fills 'name'.
1703 * If the chip is found, it returns the chip ID and fills 'name'. 1703 * If the chip is found, it returns the chip ID and fills 'name'.
1704 */ 1704 */
1705static int saa711x_detect_chip(struct i2c_client *client, 1705static int saa711x_detect_chip(struct i2c_client *client,
diff --git a/drivers/media/i2c/soc_camera/ov5642.c b/drivers/media/i2c/soc_camera/ov5642.c
index 0a5c5d4fedd6..d2daa6a8f272 100644
--- a/drivers/media/i2c/soc_camera/ov5642.c
+++ b/drivers/media/i2c/soc_camera/ov5642.c
@@ -642,7 +642,7 @@ static const struct ov5642_datafmt
642static int reg_read(struct i2c_client *client, u16 reg, u8 *val) 642static int reg_read(struct i2c_client *client, u16 reg, u8 *val)
643{ 643{
644 int ret; 644 int ret;
645 /* We have 16-bit i2c addresses - care for endianess */ 645 /* We have 16-bit i2c addresses - care for endianness */
646 unsigned char data[2] = { reg >> 8, reg & 0xff }; 646 unsigned char data[2] = { reg >> 8, reg & 0xff };
647 647
648 ret = i2c_master_send(client, data, 2); 648 ret = i2c_master_send(client, data, 2);
diff --git a/drivers/media/i2c/ths7303.c b/drivers/media/i2c/ths7303.c
index 42276d93624c..ed9ae8875348 100644
--- a/drivers/media/i2c/ths7303.c
+++ b/drivers/media/i2c/ths7303.c
@@ -83,7 +83,8 @@ static int ths7303_write(struct v4l2_subdev *sd, u8 reg, u8 val)
83} 83}
84 84
85/* following function is used to set ths7303 */ 85/* following function is used to set ths7303 */
86int ths7303_setval(struct v4l2_subdev *sd, enum ths7303_filter_mode mode) 86static int ths7303_setval(struct v4l2_subdev *sd,
87 enum ths7303_filter_mode mode)
87{ 88{
88 struct i2c_client *client = v4l2_get_subdevdata(sd); 89 struct i2c_client *client = v4l2_get_subdevdata(sd);
89 struct ths7303_state *state = to_state(sd); 90 struct ths7303_state *state = to_state(sd);
diff --git a/drivers/media/i2c/wm8775.c b/drivers/media/i2c/wm8775.c
index 3f584a7d0781..bee7946faa7c 100644
--- a/drivers/media/i2c/wm8775.c
+++ b/drivers/media/i2c/wm8775.c
@@ -130,12 +130,10 @@ static int wm8775_s_routing(struct v4l2_subdev *sd,
130 return -EINVAL; 130 return -EINVAL;
131 } 131 }
132 state->input = input; 132 state->input = input;
133 if (!v4l2_ctrl_g_ctrl(state->mute)) 133 if (v4l2_ctrl_g_ctrl(state->mute))
134 return 0; 134 return 0;
135 if (!v4l2_ctrl_g_ctrl(state->vol)) 135 if (!v4l2_ctrl_g_ctrl(state->vol))
136 return 0; 136 return 0;
137 if (!v4l2_ctrl_g_ctrl(state->bal))
138 return 0;
139 wm8775_set_audio(sd, 1); 137 wm8775_set_audio(sd, 1);
140 return 0; 138 return 0;
141} 139}
diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index a3b1ee9c00d7..92a06fd85865 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -4182,7 +4182,8 @@ static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)
4182 } 4182 }
4183 btv->std = V4L2_STD_PAL; 4183 btv->std = V4L2_STD_PAL;
4184 init_irqreg(btv); 4184 init_irqreg(btv);
4185 v4l2_ctrl_handler_setup(hdl); 4185 if (!bttv_tvcards[btv->c.type].no_video)
4186 v4l2_ctrl_handler_setup(hdl);
4186 if (hdl->error) { 4187 if (hdl->error) {
4187 result = hdl->error; 4188 result = hdl->error;
4188 goto fail2; 4189 goto fail2;
diff --git a/drivers/media/pci/cx18/cx18-driver.h b/drivers/media/pci/cx18/cx18-driver.h
index 2767c64df0c8..57f4688ea55b 100644
--- a/drivers/media/pci/cx18/cx18-driver.h
+++ b/drivers/media/pci/cx18/cx18-driver.h
@@ -262,7 +262,7 @@ struct cx18_options {
262}; 262};
263 263
264/* per-mdl bit flags */ 264/* per-mdl bit flags */
265#define CX18_F_M_NEED_SWAP 0 /* mdl buffer data must be endianess swapped */ 265#define CX18_F_M_NEED_SWAP 0 /* mdl buffer data must be endianness swapped */
266 266
267/* per-stream, s_flags */ 267/* per-stream, s_flags */
268#define CX18_F_S_CLAIMED 3 /* this stream is claimed */ 268#define CX18_F_S_CLAIMED 3 /* this stream is claimed */
diff --git a/drivers/media/pci/cx23885/cx23885-417.c b/drivers/media/pci/cx23885/cx23885-417.c
index e3fc2c71808a..95666eee7b27 100644
--- a/drivers/media/pci/cx23885/cx23885-417.c
+++ b/drivers/media/pci/cx23885/cx23885-417.c
@@ -427,7 +427,7 @@ int mc417_register_read(struct cx23885_dev *dev, u16 address, u32 *value)
427 cx_write(MC417_RWD, regval); 427 cx_write(MC417_RWD, regval);
428 428
429 /* Transition RD to effect read transaction across bus. 429 /* Transition RD to effect read transaction across bus.
430 * Transtion 0x5000 -> 0x9000 correct (RD/RDY -> WR/RDY)? 430 * Transition 0x5000 -> 0x9000 correct (RD/RDY -> WR/RDY)?
431 * Should it be 0x9000 -> 0xF000 (also why is RDY being set, its 431 * Should it be 0x9000 -> 0xF000 (also why is RDY being set, its
432 * input only...) 432 * input only...)
433 */ 433 */
diff --git a/drivers/media/pci/pluto2/pluto2.c b/drivers/media/pci/pluto2/pluto2.c
index 8164d74b46a4..655d6854a8d7 100644
--- a/drivers/media/pci/pluto2/pluto2.c
+++ b/drivers/media/pci/pluto2/pluto2.c
@@ -401,7 +401,7 @@ static int pluto_hw_init(struct pluto *pluto)
401 /* set automatic LED control by FPGA */ 401 /* set automatic LED control by FPGA */
402 pluto_rw(pluto, REG_MISC, MISC_ALED, MISC_ALED); 402 pluto_rw(pluto, REG_MISC, MISC_ALED, MISC_ALED);
403 403
404 /* set data endianess */ 404 /* set data endianness */
405#ifdef __LITTLE_ENDIAN 405#ifdef __LITTLE_ENDIAN
406 pluto_rw(pluto, REG_PIDn(0), PID0_END, PID0_END); 406 pluto_rw(pluto, REG_PIDn(0), PID0_END, PID0_END);
407#else 407#else
diff --git a/drivers/media/pci/saa7164/saa7164-core.c b/drivers/media/pci/saa7164/saa7164-core.c
index 57ef5456f1e8..1bf06970ca3e 100644
--- a/drivers/media/pci/saa7164/saa7164-core.c
+++ b/drivers/media/pci/saa7164/saa7164-core.c
@@ -1354,9 +1354,11 @@ static int saa7164_initdev(struct pci_dev *pci_dev,
1354 if (fw_debug) { 1354 if (fw_debug) {
1355 dev->kthread = kthread_run(saa7164_thread_function, dev, 1355 dev->kthread = kthread_run(saa7164_thread_function, dev,
1356 "saa7164 debug"); 1356 "saa7164 debug");
1357 if (!dev->kthread) 1357 if (IS_ERR(dev->kthread)) {
1358 dev->kthread = NULL;
1358 printk(KERN_ERR "%s() Failed to create " 1359 printk(KERN_ERR "%s() Failed to create "
1359 "debug kernel thread\n", __func__); 1360 "debug kernel thread\n", __func__);
1361 }
1360 } 1362 }
1361 1363
1362 } /* != BOARD_UNKNOWN */ 1364 } /* != BOARD_UNKNOWN */
diff --git a/drivers/media/platform/coda.c b/drivers/media/platform/coda.c
index bd72fb97fea5..61f3dbcc259f 100644
--- a/drivers/media/platform/coda.c
+++ b/drivers/media/platform/coda.c
@@ -1434,7 +1434,7 @@ static void coda_buf_queue(struct vb2_buffer *vb)
1434 if (q_data->fourcc == V4L2_PIX_FMT_H264 && 1434 if (q_data->fourcc == V4L2_PIX_FMT_H264 &&
1435 vb->vb2_queue->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { 1435 vb->vb2_queue->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
1436 /* 1436 /*
1437 * For backwards compatiblity, queuing an empty buffer marks 1437 * For backwards compatibility, queuing an empty buffer marks
1438 * the stream end 1438 * the stream end
1439 */ 1439 */
1440 if (vb2_get_plane_payload(vb, 0) == 0) 1440 if (vb2_get_plane_payload(vb, 0) == 0)
diff --git a/drivers/media/platform/exynos4-is/fimc-core.c b/drivers/media/platform/exynos4-is/fimc-core.c
index 3d66d88ea3a1..f7915695c907 100644
--- a/drivers/media/platform/exynos4-is/fimc-core.c
+++ b/drivers/media/platform/exynos4-is/fimc-core.c
@@ -1039,7 +1039,7 @@ static int fimc_runtime_resume(struct device *dev)
1039 1039
1040 dbg("fimc%d: state: 0x%lx", fimc->id, fimc->state); 1040 dbg("fimc%d: state: 0x%lx", fimc->id, fimc->state);
1041 1041
1042 /* Enable clocks and perform basic initalization */ 1042 /* Enable clocks and perform basic initialization */
1043 clk_enable(fimc->clock[CLK_GATE]); 1043 clk_enable(fimc->clock[CLK_GATE]);
1044 fimc_hw_reset(fimc); 1044 fimc_hw_reset(fimc);
1045 1045
diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
index 7a4ee4c0449d..c1bce170df6f 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -759,7 +759,7 @@ static int fimc_md_register_platform_entity(struct fimc_md *fmd,
759 goto dev_unlock; 759 goto dev_unlock;
760 760
761 drvdata = dev_get_drvdata(dev); 761 drvdata = dev_get_drvdata(dev);
762 /* Some subdev didn't probe succesfully id drvdata is NULL */ 762 /* Some subdev didn't probe successfully id drvdata is NULL */
763 if (drvdata) { 763 if (drvdata) {
764 switch (plat_entity) { 764 switch (plat_entity) {
765 case IDX_FIMC: 765 case IDX_FIMC:
diff --git a/drivers/media/platform/marvell-ccic/mmp-driver.c b/drivers/media/platform/marvell-ccic/mmp-driver.c
index 3458fa0e2fd5..054507f16734 100644
--- a/drivers/media/platform/marvell-ccic/mmp-driver.c
+++ b/drivers/media/platform/marvell-ccic/mmp-driver.c
@@ -142,12 +142,6 @@ static int mmpcam_power_up(struct mcam_camera *mcam)
142 struct mmp_camera *cam = mcam_to_cam(mcam); 142 struct mmp_camera *cam = mcam_to_cam(mcam);
143 struct mmp_camera_platform_data *pdata; 143 struct mmp_camera_platform_data *pdata;
144 144
145 if (mcam->bus_type == V4L2_MBUS_CSI2) {
146 cam->mipi_clk = devm_clk_get(mcam->dev, "mipi");
147 if ((IS_ERR(cam->mipi_clk) && mcam->dphy[2] == 0))
148 return PTR_ERR(cam->mipi_clk);
149 }
150
151/* 145/*
152 * Turn on power and clocks to the controller. 146 * Turn on power and clocks to the controller.
153 */ 147 */
@@ -186,12 +180,6 @@ static void mmpcam_power_down(struct mcam_camera *mcam)
186 gpio_set_value(pdata->sensor_power_gpio, 0); 180 gpio_set_value(pdata->sensor_power_gpio, 0);
187 gpio_set_value(pdata->sensor_reset_gpio, 0); 181 gpio_set_value(pdata->sensor_reset_gpio, 0);
188 182
189 if (mcam->bus_type == V4L2_MBUS_CSI2 && !IS_ERR(cam->mipi_clk)) {
190 if (cam->mipi_clk)
191 devm_clk_put(mcam->dev, cam->mipi_clk);
192 cam->mipi_clk = NULL;
193 }
194
195 mcam_clk_disable(mcam); 183 mcam_clk_disable(mcam);
196} 184}
197 185
@@ -292,8 +280,9 @@ void mmpcam_calc_dphy(struct mcam_camera *mcam)
292 return; 280 return;
293 281
294 /* get the escape clk, this is hard coded */ 282 /* get the escape clk, this is hard coded */
283 clk_prepare_enable(cam->mipi_clk);
295 tx_clk_esc = (clk_get_rate(cam->mipi_clk) / 1000000) / 12; 284 tx_clk_esc = (clk_get_rate(cam->mipi_clk) / 1000000) / 12;
296 285 clk_disable_unprepare(cam->mipi_clk);
297 /* 286 /*
298 * dphy[2] - CSI2_DPHY6: 287 * dphy[2] - CSI2_DPHY6:
299 * bit 0 ~ bit 7: CK Term Enable 288 * bit 0 ~ bit 7: CK Term Enable
@@ -325,19 +314,6 @@ static irqreturn_t mmpcam_irq(int irq, void *data)
325 return IRQ_RETVAL(handled); 314 return IRQ_RETVAL(handled);
326} 315}
327 316
328static void mcam_deinit_clk(struct mcam_camera *mcam)
329{
330 unsigned int i;
331
332 for (i = 0; i < NR_MCAM_CLK; i++) {
333 if (!IS_ERR(mcam->clk[i])) {
334 if (mcam->clk[i])
335 devm_clk_put(mcam->dev, mcam->clk[i]);
336 }
337 mcam->clk[i] = NULL;
338 }
339}
340
341static void mcam_init_clk(struct mcam_camera *mcam) 317static void mcam_init_clk(struct mcam_camera *mcam)
342{ 318{
343 unsigned int i; 319 unsigned int i;
@@ -371,7 +347,6 @@ static int mmpcam_probe(struct platform_device *pdev)
371 if (cam == NULL) 347 if (cam == NULL)
372 return -ENOMEM; 348 return -ENOMEM;
373 cam->pdev = pdev; 349 cam->pdev = pdev;
374 cam->mipi_clk = NULL;
375 INIT_LIST_HEAD(&cam->devlist); 350 INIT_LIST_HEAD(&cam->devlist);
376 351
377 mcam = &cam->mcam; 352 mcam = &cam->mcam;
@@ -387,6 +362,11 @@ static int mmpcam_probe(struct platform_device *pdev)
387 mcam->mclk_div = pdata->mclk_div; 362 mcam->mclk_div = pdata->mclk_div;
388 mcam->bus_type = pdata->bus_type; 363 mcam->bus_type = pdata->bus_type;
389 mcam->dphy = pdata->dphy; 364 mcam->dphy = pdata->dphy;
365 if (mcam->bus_type == V4L2_MBUS_CSI2) {
366 cam->mipi_clk = devm_clk_get(mcam->dev, "mipi");
367 if ((IS_ERR(cam->mipi_clk) && mcam->dphy[2] == 0))
368 return PTR_ERR(cam->mipi_clk);
369 }
390 mcam->mipi_enabled = false; 370 mcam->mipi_enabled = false;
391 mcam->lane = pdata->lane; 371 mcam->lane = pdata->lane;
392 mcam->chip_id = MCAM_ARMADA610; 372 mcam->chip_id = MCAM_ARMADA610;
@@ -444,7 +424,7 @@ static int mmpcam_probe(struct platform_device *pdev)
444 */ 424 */
445 ret = mmpcam_power_up(mcam); 425 ret = mmpcam_power_up(mcam);
446 if (ret) 426 if (ret)
447 goto out_deinit_clk; 427 return ret;
448 ret = mccic_register(mcam); 428 ret = mccic_register(mcam);
449 if (ret) 429 if (ret)
450 goto out_power_down; 430 goto out_power_down;
@@ -469,8 +449,6 @@ out_unregister:
469 mccic_shutdown(mcam); 449 mccic_shutdown(mcam);
470out_power_down: 450out_power_down:
471 mmpcam_power_down(mcam); 451 mmpcam_power_down(mcam);
472out_deinit_clk:
473 mcam_deinit_clk(mcam);
474 return ret; 452 return ret;
475} 453}
476 454
@@ -478,18 +456,10 @@ out_deinit_clk:
478static int mmpcam_remove(struct mmp_camera *cam) 456static int mmpcam_remove(struct mmp_camera *cam)
479{ 457{
480 struct mcam_camera *mcam = &cam->mcam; 458 struct mcam_camera *mcam = &cam->mcam;
481 struct mmp_camera_platform_data *pdata;
482 459
483 mmpcam_remove_device(cam); 460 mmpcam_remove_device(cam);
484 mccic_shutdown(mcam); 461 mccic_shutdown(mcam);
485 mmpcam_power_down(mcam); 462 mmpcam_power_down(mcam);
486 pdata = cam->pdev->dev.platform_data;
487 gpio_free(pdata->sensor_reset_gpio);
488 gpio_free(pdata->sensor_power_gpio);
489 mcam_deinit_clk(mcam);
490 iounmap(cam->power_regs);
491 iounmap(mcam->regs);
492 kfree(cam);
493 return 0; 463 return 0;
494} 464}
495 465
diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c
index 1c3608039663..561bce8ffb1b 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -1673,7 +1673,7 @@ void omap3isp_print_status(struct isp_device *isp)
1673 * ISP clocks get disabled in suspend(). Similarly, the clocks are reenabled in 1673 * ISP clocks get disabled in suspend(). Similarly, the clocks are reenabled in
1674 * resume(), and the the pipelines are restarted in complete(). 1674 * resume(), and the the pipelines are restarted in complete().
1675 * 1675 *
1676 * TODO: PM dependencies between the ISP and sensors are not modeled explicitly 1676 * TODO: PM dependencies between the ISP and sensors are not modelled explicitly
1677 * yet. 1677 * yet.
1678 */ 1678 */
1679static int isp_pm_prepare(struct device *dev) 1679static int isp_pm_prepare(struct device *dev)
diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c
index a908d006f527..f6304bb074f5 100644
--- a/drivers/media/platform/omap3isp/ispvideo.c
+++ b/drivers/media/platform/omap3isp/ispvideo.c
@@ -339,14 +339,11 @@ __isp_video_get_format(struct isp_video *video, struct v4l2_format *format)
339 if (subdev == NULL) 339 if (subdev == NULL)
340 return -EINVAL; 340 return -EINVAL;
341 341
342 mutex_lock(&video->mutex);
343
344 fmt.pad = pad; 342 fmt.pad = pad;
345 fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; 343 fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
346 ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &fmt);
347 if (ret == -ENOIOCTLCMD)
348 ret = -EINVAL;
349 344
345 mutex_lock(&video->mutex);
346 ret = v4l2_subdev_call(subdev, pad, get_fmt, NULL, &fmt);
350 mutex_unlock(&video->mutex); 347 mutex_unlock(&video->mutex);
351 348
352 if (ret) 349 if (ret)
diff --git a/drivers/media/platform/s5p-mfc/regs-mfc.h b/drivers/media/platform/s5p-mfc/regs-mfc.h
index 9319e93599ae..6ccc3f8c122a 100644
--- a/drivers/media/platform/s5p-mfc/regs-mfc.h
+++ b/drivers/media/platform/s5p-mfc/regs-mfc.h
@@ -382,7 +382,7 @@
382#define S5P_FIMV_R2H_CMD_EDFU_INIT_RET 16 382#define S5P_FIMV_R2H_CMD_EDFU_INIT_RET 16
383#define S5P_FIMV_R2H_CMD_ERR_RET 32 383#define S5P_FIMV_R2H_CMD_ERR_RET 32
384 384
385/* Dummy definition for MFCv6 compatibilty */ 385/* Dummy definition for MFCv6 compatibility */
386#define S5P_FIMV_CODEC_H264_MVC_DEC -1 386#define S5P_FIMV_CODEC_H264_MVC_DEC -1
387#define S5P_FIMV_R2H_CMD_FIELD_DONE_RET -1 387#define S5P_FIMV_R2H_CMD_FIELD_DONE_RET -1
388#define S5P_FIMV_MFC_RESET -1 388#define S5P_FIMV_MFC_RESET -1
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 5f2c4ad6c2cb..e46067a57853 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -239,7 +239,7 @@ static void s5p_mfc_handle_frame_copy_time(struct s5p_mfc_ctx *ctx)
239 frame_type = s5p_mfc_hw_call(dev->mfc_ops, get_dec_frame_type, dev); 239 frame_type = s5p_mfc_hw_call(dev->mfc_ops, get_dec_frame_type, dev);
240 240
241 /* Copy timestamp / timecode from decoded src to dst and set 241 /* Copy timestamp / timecode from decoded src to dst and set
242 appropraite flags */ 242 appropriate flags */
243 src_buf = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list); 243 src_buf = list_entry(ctx->src_queue.next, struct s5p_mfc_buf, list);
244 list_for_each_entry(dst_buf, &ctx->dst_queue, list) { 244 list_for_each_entry(dst_buf, &ctx->dst_queue, list) {
245 if (vb2_dma_contig_plane_dma_addr(dst_buf->b, 0) == dec_y_addr) { 245 if (vb2_dma_contig_plane_dma_addr(dst_buf->b, 0) == dec_y_addr) {
@@ -428,7 +428,7 @@ static void s5p_mfc_handle_error(struct s5p_mfc_dev *dev,
428 case MFCINST_FINISHING: 428 case MFCINST_FINISHING:
429 case MFCINST_FINISHED: 429 case MFCINST_FINISHED:
430 case MFCINST_RUNNING: 430 case MFCINST_RUNNING:
431 /* It is higly probable that an error occured 431 /* It is highly probable that an error occurred
432 * while decoding a frame */ 432 * while decoding a frame */
433 clear_work_bit(ctx); 433 clear_work_bit(ctx);
434 ctx->state = MFCINST_ERROR; 434 ctx->state = MFCINST_ERROR;
@@ -611,7 +611,7 @@ static irqreturn_t s5p_mfc_irq(int irq, void *priv)
611 mfc_debug(1, "Int reason: %d (err: %08x)\n", reason, err); 611 mfc_debug(1, "Int reason: %d (err: %08x)\n", reason, err);
612 switch (reason) { 612 switch (reason) {
613 case S5P_MFC_R2H_CMD_ERR_RET: 613 case S5P_MFC_R2H_CMD_ERR_RET:
614 /* An error has occured */ 614 /* An error has occurred */
615 if (ctx->state == MFCINST_RUNNING && 615 if (ctx->state == MFCINST_RUNNING &&
616 s5p_mfc_hw_call(dev->mfc_ops, err_dec, err) >= 616 s5p_mfc_hw_call(dev->mfc_ops, err_dec, err) >=
617 dev->warn_start) 617 dev->warn_start)
@@ -840,7 +840,7 @@ static int s5p_mfc_open(struct file *file)
840 mutex_unlock(&dev->mfc_mutex); 840 mutex_unlock(&dev->mfc_mutex);
841 mfc_debug_leave(); 841 mfc_debug_leave();
842 return ret; 842 return ret;
843 /* Deinit when failure occured */ 843 /* Deinit when failure occurred */
844err_queue_init: 844err_queue_init:
845 if (dev->num_inst == 1) 845 if (dev->num_inst == 1)
846 s5p_mfc_deinit_hw(dev); 846 s5p_mfc_deinit_hw(dev);
@@ -881,14 +881,14 @@ static int s5p_mfc_release(struct file *file)
881 /* Mark context as idle */ 881 /* Mark context as idle */
882 clear_work_bit_irqsave(ctx); 882 clear_work_bit_irqsave(ctx);
883 /* If instance was initialised then 883 /* If instance was initialised then
884 * return instance and free reosurces */ 884 * return instance and free resources */
885 if (ctx->inst_no != MFC_NO_INSTANCE_SET) { 885 if (ctx->inst_no != MFC_NO_INSTANCE_SET) {
886 mfc_debug(2, "Has to free instance\n"); 886 mfc_debug(2, "Has to free instance\n");
887 ctx->state = MFCINST_RETURN_INST; 887 ctx->state = MFCINST_RETURN_INST;
888 set_work_bit_irqsave(ctx); 888 set_work_bit_irqsave(ctx);
889 s5p_mfc_clean_ctx_int_flags(ctx); 889 s5p_mfc_clean_ctx_int_flags(ctx);
890 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev); 890 s5p_mfc_hw_call(dev->mfc_ops, try_run, dev);
891 /* Wait until instance is returned or timeout occured */ 891 /* Wait until instance is returned or timeout occurred */
892 if (s5p_mfc_wait_for_done_ctx 892 if (s5p_mfc_wait_for_done_ctx
893 (ctx, S5P_MFC_R2H_CMD_CLOSE_INSTANCE_RET, 0)) { 893 (ctx, S5P_MFC_R2H_CMD_CLOSE_INSTANCE_RET, 0)) {
894 s5p_mfc_clock_off(); 894 s5p_mfc_clock_off();
diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
index 7cab6849fb5b..2475a3c9a0a6 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c
@@ -69,7 +69,7 @@ int s5p_mfc_alloc_firmware(struct s5p_mfc_dev *dev)
69 69
70 } else { 70 } else {
71 /* In this case bank2 can point to the same address as bank1. 71 /* In this case bank2 can point to the same address as bank1.
72 * Firmware will always occupy the beggining of this area so it is 72 * Firmware will always occupy the beginning of this area so it is
73 * impossible having a video frame buffer with zero address. */ 73 * impossible having a video frame buffer with zero address. */
74 dev->bank2 = dev->bank1; 74 dev->bank2 = dev->bank1;
75 } 75 }
diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
index 04e6490a45be..fb2acc53112a 100644
--- a/drivers/media/platform/s5p-tv/mixer.h
+++ b/drivers/media/platform/s5p-tv/mixer.h
@@ -65,7 +65,7 @@ struct mxr_format {
65 int num_subframes; 65 int num_subframes;
66 /** specifies to which subframe belong given plane */ 66 /** specifies to which subframe belong given plane */
67 int plane2subframe[MXR_MAX_PLANES]; 67 int plane2subframe[MXR_MAX_PLANES];
68 /** internal code, driver dependant */ 68 /** internal code, driver dependent */
69 unsigned long cookie; 69 unsigned long cookie;
70}; 70};
71 71
diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
index 641b1f071e06..81b97db111d8 100644
--- a/drivers/media/platform/s5p-tv/mixer_video.c
+++ b/drivers/media/platform/s5p-tv/mixer_video.c
@@ -528,7 +528,7 @@ static int mxr_s_dv_timings(struct file *file, void *fh,
528 mutex_lock(&mdev->mutex); 528 mutex_lock(&mdev->mutex);
529 529
530 /* timings change cannot be done while there is an entity 530 /* timings change cannot be done while there is an entity
531 * dependant on output configuration 531 * dependent on output configuration
532 */ 532 */
533 if (mdev->n_output > 0) { 533 if (mdev->n_output > 0) {
534 mutex_unlock(&mdev->mutex); 534 mutex_unlock(&mdev->mutex);
@@ -585,7 +585,7 @@ static int mxr_s_std(struct file *file, void *fh, v4l2_std_id norm)
585 mutex_lock(&mdev->mutex); 585 mutex_lock(&mdev->mutex);
586 586
587 /* standard change cannot be done while there is an entity 587 /* standard change cannot be done while there is an entity
588 * dependant on output configuration 588 * dependent on output configuration
589 */ 589 */
590 if (mdev->n_output > 0) { 590 if (mdev->n_output > 0) {
591 mutex_unlock(&mdev->mutex); 591 mutex_unlock(&mdev->mutex);
diff --git a/drivers/media/platform/soc_camera/omap1_camera.c b/drivers/media/platform/soc_camera/omap1_camera.c
index 6769193c7c7b..74ce8b6b79fa 100644
--- a/drivers/media/platform/soc_camera/omap1_camera.c
+++ b/drivers/media/platform/soc_camera/omap1_camera.c
@@ -1495,7 +1495,7 @@ static int omap1_cam_set_bus_param(struct soc_camera_device *icd)
1495 if (ctrlclock & LCLK_EN) 1495 if (ctrlclock & LCLK_EN)
1496 CAM_WRITE(pcdev, CTRLCLOCK, ctrlclock); 1496 CAM_WRITE(pcdev, CTRLCLOCK, ctrlclock);
1497 1497
1498 /* select bus endianess */ 1498 /* select bus endianness */
1499 xlate = soc_camera_xlate_by_fourcc(icd, pixfmt); 1499 xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
1500 fmt = xlate->host_fmt; 1500 fmt = xlate->host_fmt;
1501 1501
diff --git a/drivers/media/platform/vivi.c b/drivers/media/platform/vivi.c
index 1d3f11965196..2d4e73b45c5e 100644
--- a/drivers/media/platform/vivi.c
+++ b/drivers/media/platform/vivi.c
@@ -1108,7 +1108,7 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
1108 return 0; 1108 return 0;
1109} 1109}
1110 1110
1111/* timeperframe is arbitrary and continous */ 1111/* timeperframe is arbitrary and continuous */
1112static int vidioc_enum_frameintervals(struct file *file, void *priv, 1112static int vidioc_enum_frameintervals(struct file *file, void *priv,
1113 struct v4l2_frmivalenum *fival) 1113 struct v4l2_frmivalenum *fival)
1114{ 1114{
@@ -1125,7 +1125,7 @@ static int vidioc_enum_frameintervals(struct file *file, void *priv,
1125 1125
1126 fival->type = V4L2_FRMIVAL_TYPE_CONTINUOUS; 1126 fival->type = V4L2_FRMIVAL_TYPE_CONTINUOUS;
1127 1127
1128 /* fill in stepwise (step=1.0 is requred by V4L2 spec) */ 1128 /* fill in stepwise (step=1.0 is required by V4L2 spec) */
1129 fival->stepwise.min = tpf_min; 1129 fival->stepwise.min = tpf_min;
1130 fival->stepwise.max = tpf_max; 1130 fival->stepwise.max = tpf_max;
1131 fival->stepwise.step = (struct v4l2_fract) {1, 1}; 1131 fival->stepwise.step = (struct v4l2_fract) {1, 1};
diff --git a/drivers/media/platform/vsp1/vsp1_drv.c b/drivers/media/platform/vsp1/vsp1_drv.c
index 1c9e771aa15c..d16bf0f41e24 100644
--- a/drivers/media/platform/vsp1/vsp1_drv.c
+++ b/drivers/media/platform/vsp1/vsp1_drv.c
@@ -323,7 +323,7 @@ static void vsp1_clocks_disable(struct vsp1_device *vsp1)
323 * Increment the VSP1 reference count and initialize the device if the first 323 * Increment the VSP1 reference count and initialize the device if the first
324 * reference is taken. 324 * reference is taken.
325 * 325 *
326 * Return a pointer to the VSP1 device or NULL if an error occured. 326 * Return a pointer to the VSP1 device or NULL if an error occurred.
327 */ 327 */
328struct vsp1_device *vsp1_device_get(struct vsp1_device *vsp1) 328struct vsp1_device *vsp1_device_get(struct vsp1_device *vsp1)
329{ 329{
diff --git a/drivers/media/platform/vsp1/vsp1_video.c b/drivers/media/platform/vsp1/vsp1_video.c
index 714c53ef6c11..4b0ac07af662 100644
--- a/drivers/media/platform/vsp1/vsp1_video.c
+++ b/drivers/media/platform/vsp1/vsp1_video.c
@@ -1026,8 +1026,10 @@ int vsp1_video_init(struct vsp1_video *video, struct vsp1_entity *rwpf)
1026 1026
1027 /* ... and the buffers queue... */ 1027 /* ... and the buffers queue... */
1028 video->alloc_ctx = vb2_dma_contig_init_ctx(video->vsp1->dev); 1028 video->alloc_ctx = vb2_dma_contig_init_ctx(video->vsp1->dev);
1029 if (IS_ERR(video->alloc_ctx)) 1029 if (IS_ERR(video->alloc_ctx)) {
1030 ret = PTR_ERR(video->alloc_ctx);
1030 goto error; 1031 goto error;
1032 }
1031 1033
1032 video->queue.type = video->type; 1034 video->queue.type = video->type;
1033 video->queue.io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF; 1035 video->queue.io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
index 3db8a8cfe1a8..050b3bb96fec 100644
--- a/drivers/media/radio/radio-shark.c
+++ b/drivers/media/radio/radio-shark.c
@@ -271,8 +271,7 @@ static void shark_unregister_leds(struct shark_device *shark)
271 cancel_work_sync(&shark->led_work); 271 cancel_work_sync(&shark->led_work);
272} 272}
273 273
274#ifdef CONFIG_PM 274static inline void shark_resume_leds(struct shark_device *shark)
275static void shark_resume_leds(struct shark_device *shark)
276{ 275{
277 if (test_bit(BLUE_IS_PULSE, &shark->brightness_new)) 276 if (test_bit(BLUE_IS_PULSE, &shark->brightness_new))
278 set_bit(BLUE_PULSE_LED, &shark->brightness_new); 277 set_bit(BLUE_PULSE_LED, &shark->brightness_new);
@@ -281,7 +280,6 @@ static void shark_resume_leds(struct shark_device *shark)
281 set_bit(RED_LED, &shark->brightness_new); 280 set_bit(RED_LED, &shark->brightness_new);
282 schedule_work(&shark->led_work); 281 schedule_work(&shark->led_work);
283} 282}
284#endif
285#else 283#else
286static int shark_register_leds(struct shark_device *shark, struct device *dev) 284static int shark_register_leds(struct shark_device *shark, struct device *dev)
287{ 285{
diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c
index d86d90dab8bf..8654e0dc5c95 100644
--- a/drivers/media/radio/radio-shark2.c
+++ b/drivers/media/radio/radio-shark2.c
@@ -237,8 +237,7 @@ static void shark_unregister_leds(struct shark_device *shark)
237 cancel_work_sync(&shark->led_work); 237 cancel_work_sync(&shark->led_work);
238} 238}
239 239
240#ifdef CONFIG_PM 240static inline void shark_resume_leds(struct shark_device *shark)
241static void shark_resume_leds(struct shark_device *shark)
242{ 241{
243 int i; 242 int i;
244 243
@@ -247,7 +246,6 @@ static void shark_resume_leds(struct shark_device *shark)
247 246
248 schedule_work(&shark->led_work); 247 schedule_work(&shark->led_work);
249} 248}
250#endif
251#else 249#else
252static int shark_register_leds(struct shark_device *shark, struct device *dev) 250static int shark_register_leds(struct shark_device *shark, struct device *dev)
253{ 251{
diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c
index 9c9084cb99f7..2fd9009f8663 100644
--- a/drivers/media/radio/radio-si476x.c
+++ b/drivers/media/radio/radio-si476x.c
@@ -268,8 +268,8 @@ struct si476x_radio;
268 * 268 *
269 * @tune_freq: Tune chip to a specific frequency 269 * @tune_freq: Tune chip to a specific frequency
270 * @seek_start: Star station seeking 270 * @seek_start: Star station seeking
271 * @rsq_status: Get Recieved Signal Quality(RSQ) status 271 * @rsq_status: Get Received Signal Quality(RSQ) status
272 * @rds_blckcnt: Get recived RDS blocks count 272 * @rds_blckcnt: Get received RDS blocks count
273 * @phase_diversity: Change phase diversity mode of the tuner 273 * @phase_diversity: Change phase diversity mode of the tuner
274 * @phase_div_status: Get phase diversity mode status 274 * @phase_div_status: Get phase diversity mode status
275 * @acf_status: Get the status of Automatically Controlled 275 * @acf_status: Get the status of Automatically Controlled
diff --git a/drivers/media/radio/radio-tea5764.c b/drivers/media/radio/radio-tea5764.c
index 036e2f54f4db..3ed1f5669f79 100644
--- a/drivers/media/radio/radio-tea5764.c
+++ b/drivers/media/radio/radio-tea5764.c
@@ -356,7 +356,7 @@ static int vidioc_s_frequency(struct file *file, void *priv,
356 So we keep it as-is. */ 356 So we keep it as-is. */
357 return -EINVAL; 357 return -EINVAL;
358 } 358 }
359 clamp(freq, FREQ_MIN * FREQ_MUL, FREQ_MAX * FREQ_MUL); 359 freq = clamp(freq, FREQ_MIN * FREQ_MUL, FREQ_MAX * FREQ_MUL);
360 tea5764_power_up(radio); 360 tea5764_power_up(radio);
361 tea5764_tune(radio, (freq * 125) / 2); 361 tea5764_tune(radio, (freq * 125) / 2);
362 return 0; 362 return 0;
diff --git a/drivers/media/radio/tef6862.c b/drivers/media/radio/tef6862.c
index 69e3245a58a0..a9319a24c7ef 100644
--- a/drivers/media/radio/tef6862.c
+++ b/drivers/media/radio/tef6862.c
@@ -112,7 +112,7 @@ static int tef6862_s_frequency(struct v4l2_subdev *sd, const struct v4l2_frequen
112 if (f->tuner != 0) 112 if (f->tuner != 0)
113 return -EINVAL; 113 return -EINVAL;
114 114
115 clamp(freq, TEF6862_LO_FREQ, TEF6862_HI_FREQ); 115 freq = clamp(freq, TEF6862_LO_FREQ, TEF6862_HI_FREQ);
116 pll = 1964 + ((freq - TEF6862_LO_FREQ) * 20) / FREQ_MUL; 116 pll = 1964 + ((freq - TEF6862_LO_FREQ) * 20) / FREQ_MUL;
117 i2cmsg[0] = (MSA_MODE_PRESET << MSA_MODE_SHIFT) | WM_SUB_PLLM; 117 i2cmsg[0] = (MSA_MODE_PRESET << MSA_MODE_SHIFT) | WM_SUB_PLLM;
118 i2cmsg[1] = (pll >> 8) & 0xff; 118 i2cmsg[1] = (pll >> 8) & 0xff;
diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
index 72e3fa652481..f329485c6629 100644
--- a/drivers/media/rc/imon.c
+++ b/drivers/media/rc/imon.c
@@ -1370,7 +1370,7 @@ static void imon_pad_to_keys(struct imon_context *ictx, unsigned char *buf)
1370 * 0x68nnnnB7 to 0x6AnnnnB7, the left mouse button generates 1370 * 0x68nnnnB7 to 0x6AnnnnB7, the left mouse button generates
1371 * 0x688301b7 and the right one 0x688481b7. All other keys generate 1371 * 0x688301b7 and the right one 0x688481b7. All other keys generate
1372 * 0x2nnnnnnn. Position coordinate is encoded in buf[1] and buf[2] with 1372 * 0x2nnnnnnn. Position coordinate is encoded in buf[1] and buf[2] with
1373 * reversed endianess. Extract direction from buffer, rotate endianess, 1373 * reversed endianness. Extract direction from buffer, rotate endianness,
1374 * adjust sign and feed the values into stabilize(). The resulting codes 1374 * adjust sign and feed the values into stabilize(). The resulting codes
1375 * will be 0x01008000, 0x01007F00, which match the newer devices. 1375 * will be 0x01008000, 0x01007F00, which match the newer devices.
1376 */ 1376 */
diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c
index 094484fac94c..a5d4f883d053 100644
--- a/drivers/media/rc/redrat3.c
+++ b/drivers/media/rc/redrat3.c
@@ -118,7 +118,7 @@ static int debug;
118#define RR3_IR_IO_LENGTH_FUZZ 0x04 118#define RR3_IR_IO_LENGTH_FUZZ 0x04
119/* Timeout for end of signal detection */ 119/* Timeout for end of signal detection */
120#define RR3_IR_IO_SIG_TIMEOUT 0x05 120#define RR3_IR_IO_SIG_TIMEOUT 0x05
121/* Minumum value for pause recognition. */ 121/* Minimum value for pause recognition. */
122#define RR3_IR_IO_MIN_PAUSE 0x06 122#define RR3_IR_IO_MIN_PAUSE 0x06
123 123
124/* Clock freq. of EZ-USB chip */ 124/* Clock freq. of EZ-USB chip */
diff --git a/drivers/media/tuners/mt2063.c b/drivers/media/tuners/mt2063.c
index 2e1a02e360ff..20cca405bf45 100644
--- a/drivers/media/tuners/mt2063.c
+++ b/drivers/media/tuners/mt2063.c
@@ -1195,7 +1195,7 @@ static u32 mt2063_set_dnc_output_enable(struct mt2063_state *state,
1195 * DNC Output is selected, the other is always off) 1195 * DNC Output is selected, the other is always off)
1196 * 1196 *
1197 * @state: ptr to mt2063_state structure 1197 * @state: ptr to mt2063_state structure
1198 * @Mode: desired reciever delivery system 1198 * @Mode: desired receiver delivery system
1199 * 1199 *
1200 * Note: Register cache must be valid for it to work 1200 * Note: Register cache must be valid for it to work
1201 */ 1201 */
@@ -2119,7 +2119,7 @@ static int mt2063_set_analog_params(struct dvb_frontend *fe,
2119 2119
2120/* 2120/*
2121 * As defined on EN 300 429, the DVB-C roll-off factor is 0.15. 2121 * As defined on EN 300 429, the DVB-C roll-off factor is 0.15.
2122 * So, the amount of the needed bandwith is given by: 2122 * So, the amount of the needed bandwidth is given by:
2123 * Bw = Symbol_rate * (1 + 0.15) 2123 * Bw = Symbol_rate * (1 + 0.15)
2124 * As such, the maximum symbol rate supported by 6 MHz is given by: 2124 * As such, the maximum symbol rate supported by 6 MHz is given by:
2125 * max_symbol_rate = 6 MHz / 1.15 = 5217391 Bauds 2125 * max_symbol_rate = 6 MHz / 1.15 = 5217391 Bauds
diff --git a/drivers/media/tuners/tuner-xc2028-types.h b/drivers/media/tuners/tuner-xc2028-types.h
index 74dc46a71f64..7e4798783db7 100644
--- a/drivers/media/tuners/tuner-xc2028-types.h
+++ b/drivers/media/tuners/tuner-xc2028-types.h
@@ -119,7 +119,7 @@
119#define V4L2_STD_A2 (V4L2_STD_A2_A | V4L2_STD_A2_B) 119#define V4L2_STD_A2 (V4L2_STD_A2_A | V4L2_STD_A2_B)
120#define V4L2_STD_NICAM (V4L2_STD_NICAM_A | V4L2_STD_NICAM_B) 120#define V4L2_STD_NICAM (V4L2_STD_NICAM_A | V4L2_STD_NICAM_B)
121 121
122/* To preserve backward compatibilty, 122/* To preserve backward compatibility,
123 (std & V4L2_STD_AUDIO) = 0 means that ALL audio stds are supported 123 (std & V4L2_STD_AUDIO) = 0 means that ALL audio stds are supported
124 */ 124 */
125 125
diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
index e9d017bea377..528cce958a82 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -1412,8 +1412,8 @@ err_v4l2:
1412 usb_set_intfdata(interface, NULL); 1412 usb_set_intfdata(interface, NULL);
1413err_if: 1413err_if:
1414 usb_put_dev(udev); 1414 usb_put_dev(udev);
1415 kfree(dev);
1416 clear_bit(dev->devno, &cx231xx_devused); 1415 clear_bit(dev->devno, &cx231xx_devused);
1416 kfree(dev);
1417 return retval; 1417 return retval;
1418} 1418}
1419 1419
diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c
index c8fcd78425bd..8f9b2cea88f0 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -131,7 +131,7 @@ static int af9035_wr_regs(struct dvb_usb_device *d, u32 reg, u8 *val, int len)
131{ 131{
132 u8 wbuf[MAX_XFER_SIZE]; 132 u8 wbuf[MAX_XFER_SIZE];
133 u8 mbox = (reg >> 16) & 0xff; 133 u8 mbox = (reg >> 16) & 0xff;
134 struct usb_req req = { CMD_MEM_WR, mbox, sizeof(wbuf), wbuf, 0, NULL }; 134 struct usb_req req = { CMD_MEM_WR, mbox, 6 + len, wbuf, 0, NULL };
135 135
136 if (6 + len > sizeof(wbuf)) { 136 if (6 + len > sizeof(wbuf)) {
137 dev_warn(&d->udev->dev, "%s: i2c wr: len=%d is too big!\n", 137 dev_warn(&d->udev->dev, "%s: i2c wr: len=%d is too big!\n",
@@ -238,14 +238,15 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
238 } else { 238 } else {
239 /* I2C */ 239 /* I2C */
240 u8 buf[MAX_XFER_SIZE]; 240 u8 buf[MAX_XFER_SIZE];
241 struct usb_req req = { CMD_I2C_RD, 0, sizeof(buf), 241 struct usb_req req = { CMD_I2C_RD, 0, 5 + msg[0].len,
242 buf, msg[1].len, msg[1].buf }; 242 buf, msg[1].len, msg[1].buf };
243 243
244 if (5 + msg[0].len > sizeof(buf)) { 244 if (5 + msg[0].len > sizeof(buf)) {
245 dev_warn(&d->udev->dev, 245 dev_warn(&d->udev->dev,
246 "%s: i2c xfer: len=%d is too big!\n", 246 "%s: i2c xfer: len=%d is too big!\n",
247 KBUILD_MODNAME, msg[0].len); 247 KBUILD_MODNAME, msg[0].len);
248 return -EOPNOTSUPP; 248 ret = -EOPNOTSUPP;
249 goto unlock;
249 } 250 }
250 req.mbox |= ((msg[0].addr & 0x80) >> 3); 251 req.mbox |= ((msg[0].addr & 0x80) >> 3);
251 buf[0] = msg[1].len; 252 buf[0] = msg[1].len;
@@ -274,14 +275,15 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
274 } else { 275 } else {
275 /* I2C */ 276 /* I2C */
276 u8 buf[MAX_XFER_SIZE]; 277 u8 buf[MAX_XFER_SIZE];
277 struct usb_req req = { CMD_I2C_WR, 0, sizeof(buf), buf, 278 struct usb_req req = { CMD_I2C_WR, 0, 5 + msg[0].len,
278 0, NULL }; 279 buf, 0, NULL };
279 280
280 if (5 + msg[0].len > sizeof(buf)) { 281 if (5 + msg[0].len > sizeof(buf)) {
281 dev_warn(&d->udev->dev, 282 dev_warn(&d->udev->dev,
282 "%s: i2c xfer: len=%d is too big!\n", 283 "%s: i2c xfer: len=%d is too big!\n",
283 KBUILD_MODNAME, msg[0].len); 284 KBUILD_MODNAME, msg[0].len);
284 return -EOPNOTSUPP; 285 ret = -EOPNOTSUPP;
286 goto unlock;
285 } 287 }
286 req.mbox |= ((msg[0].addr & 0x80) >> 3); 288 req.mbox |= ((msg[0].addr & 0x80) >> 3);
287 buf[0] = msg[0].len; 289 buf[0] = msg[0].len;
@@ -319,6 +321,7 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
319 ret = -EOPNOTSUPP; 321 ret = -EOPNOTSUPP;
320 } 322 }
321 323
324unlock:
322 mutex_unlock(&d->i2c_mutex); 325 mutex_unlock(&d->i2c_mutex);
323 326
324 if (ret < 0) 327 if (ret < 0)
@@ -1534,6 +1537,8 @@ static const struct usb_device_id af9035_id_table[] = {
1534 /* XXX: that same ID [0ccd:0099] is used by af9015 driver too */ 1537 /* XXX: that same ID [0ccd:0099] is used by af9015 driver too */
1535 { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x0099, 1538 { DVB_USB_DEVICE(USB_VID_TERRATEC, 0x0099,
1536 &af9035_props, "TerraTec Cinergy T Stick Dual RC (rev. 2)", NULL) }, 1539 &af9035_props, "TerraTec Cinergy T Stick Dual RC (rev. 2)", NULL) },
1540 { DVB_USB_DEVICE(USB_VID_LEADTEK, 0x6a05,
1541 &af9035_props, "Leadtek WinFast DTV Dongle Dual", NULL) },
1537 { } 1542 { }
1538}; 1543};
1539MODULE_DEVICE_TABLE(usb, af9035_id_table); 1544MODULE_DEVICE_TABLE(usb, af9035_id_table);
diff --git a/drivers/media/usb/dvb-usb-v2/mxl111sf.c b/drivers/media/usb/dvb-usb-v2/mxl111sf.c
index 2627553f7de1..08240e498451 100644
--- a/drivers/media/usb/dvb-usb-v2/mxl111sf.c
+++ b/drivers/media/usb/dvb-usb-v2/mxl111sf.c
@@ -266,7 +266,7 @@ static int mxl111sf_adap_fe_init(struct dvb_frontend *fe)
266 struct mxl111sf_adap_state *adap_state = &state->adap_state[fe->id]; 266 struct mxl111sf_adap_state *adap_state = &state->adap_state[fe->id];
267 int err; 267 int err;
268 268
269 /* exit if we didnt initialize the driver yet */ 269 /* exit if we didn't initialize the driver yet */
270 if (!state->chip_id) { 270 if (!state->chip_id) {
271 mxl_debug("driver not yet initialized, exit."); 271 mxl_debug("driver not yet initialized, exit.");
272 goto fail; 272 goto fail;
@@ -322,7 +322,7 @@ static int mxl111sf_adap_fe_sleep(struct dvb_frontend *fe)
322 struct mxl111sf_adap_state *adap_state = &state->adap_state[fe->id]; 322 struct mxl111sf_adap_state *adap_state = &state->adap_state[fe->id];
323 int err; 323 int err;
324 324
325 /* exit if we didnt initialize the driver yet */ 325 /* exit if we didn't initialize the driver yet */
326 if (!state->chip_id) { 326 if (!state->chip_id) {
327 mxl_debug("driver not yet initialized, exit."); 327 mxl_debug("driver not yet initialized, exit.");
328 goto fail; 328 goto fail;
diff --git a/drivers/media/usb/dvb-usb/technisat-usb2.c b/drivers/media/usb/dvb-usb/technisat-usb2.c
index 40832a1aef6c..98d24aefb640 100644
--- a/drivers/media/usb/dvb-usb/technisat-usb2.c
+++ b/drivers/media/usb/dvb-usb/technisat-usb2.c
@@ -102,7 +102,7 @@ static int technisat_usb2_i2c_access(struct usb_device *udev,
102 if (rxlen > 62) { 102 if (rxlen > 62) {
103 err("i2c RX buffer can't exceed 62 bytes (dev 0x%02x)", 103 err("i2c RX buffer can't exceed 62 bytes (dev 0x%02x)",
104 device_addr); 104 device_addr);
105 txlen = 62; 105 rxlen = 62;
106 } 106 }
107 107
108 b[0] = I2C_SPEED_100KHZ_BIT; 108 b[0] = I2C_SPEED_100KHZ_BIT;
diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
index fc5d60efd4ab..dd19c9ff76e0 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -1664,8 +1664,8 @@ static int em28xx_v4l2_close(struct file *filp)
1664 1664
1665 em28xx_videodbg("users=%d\n", dev->users); 1665 em28xx_videodbg("users=%d\n", dev->users);
1666 1666
1667 mutex_lock(&dev->lock);
1668 vb2_fop_release(filp); 1667 vb2_fop_release(filp);
1668 mutex_lock(&dev->lock);
1669 1669
1670 if (dev->users == 1) { 1670 if (dev->users == 1) {
1671 /* the device is already disconnect, 1671 /* the device is already disconnect,
diff --git a/drivers/media/usb/gspca/gl860/gl860.c b/drivers/media/usb/gspca/gl860/gl860.c
index cb1e64ca59c9..cea8d7f51c3c 100644
--- a/drivers/media/usb/gspca/gl860/gl860.c
+++ b/drivers/media/usb/gspca/gl860/gl860.c
@@ -438,7 +438,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
438 s32 nToSkip = 438 s32 nToSkip =
439 sd->swapRB * (gspca_dev->cam.cam_mode[mode].bytesperline + 1); 439 sd->swapRB * (gspca_dev->cam.cam_mode[mode].bytesperline + 1);
440 440
441 /* Test only against 0202h, so endianess does not matter */ 441 /* Test only against 0202h, so endianness does not matter */
442 switch (*(s16 *) data) { 442 switch (*(s16 *) data) {
443 case 0x0202: /* End of frame, start a new one */ 443 case 0x0202: /* End of frame, start a new one */
444 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0); 444 gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
diff --git a/drivers/media/usb/gspca/pac207.c b/drivers/media/usb/gspca/pac207.c
index cd79c180f67b..07529e5a0c56 100644
--- a/drivers/media/usb/gspca/pac207.c
+++ b/drivers/media/usb/gspca/pac207.c
@@ -416,7 +416,7 @@ static void sd_pkt_scan(struct gspca_dev *gspca_dev,
416#if IS_ENABLED(CONFIG_INPUT) 416#if IS_ENABLED(CONFIG_INPUT)
417static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, 417static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
418 u8 *data, /* interrupt packet data */ 418 u8 *data, /* interrupt packet data */
419 int len) /* interrput packet length */ 419 int len) /* interrupt packet length */
420{ 420{
421 int ret = -EINVAL; 421 int ret = -EINVAL;
422 422
diff --git a/drivers/media/usb/gspca/pac7302.c b/drivers/media/usb/gspca/pac7302.c
index a91509643563..2fd1c5e31a0f 100644
--- a/drivers/media/usb/gspca/pac7302.c
+++ b/drivers/media/usb/gspca/pac7302.c
@@ -874,7 +874,7 @@ static int sd_dbg_s_register(struct gspca_dev *gspca_dev,
874#if IS_ENABLED(CONFIG_INPUT) 874#if IS_ENABLED(CONFIG_INPUT)
875static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, 875static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
876 u8 *data, /* interrupt packet data */ 876 u8 *data, /* interrupt packet data */
877 int len) /* interrput packet length */ 877 int len) /* interrupt packet length */
878{ 878{
879 int ret = -EINVAL; 879 int ret = -EINVAL;
880 u8 data0, data1; 880 u8 data0, data1;
diff --git a/drivers/media/usb/gspca/stk1135.c b/drivers/media/usb/gspca/stk1135.c
index 1fc80af2a189..48234c9a8b6c 100644
--- a/drivers/media/usb/gspca/stk1135.c
+++ b/drivers/media/usb/gspca/stk1135.c
@@ -361,6 +361,9 @@ static void stk1135_configure_clock(struct gspca_dev *gspca_dev)
361 361
362 /* set serial interface clock divider (30MHz/0x1f*16+2) = 60240 kHz) */ 362 /* set serial interface clock divider (30MHz/0x1f*16+2) = 60240 kHz) */
363 reg_w(gspca_dev, STK1135_REG_SICTL + 2, 0x1f); 363 reg_w(gspca_dev, STK1135_REG_SICTL + 2, 0x1f);
364
365 /* wait a while for sensor to catch up */
366 udelay(1000);
364} 367}
365 368
366static void stk1135_camera_disable(struct gspca_dev *gspca_dev) 369static void stk1135_camera_disable(struct gspca_dev *gspca_dev)
diff --git a/drivers/media/usb/gspca/stv0680.c b/drivers/media/usb/gspca/stv0680.c
index 9c0827631b9c..7f94ec74282e 100644
--- a/drivers/media/usb/gspca/stv0680.c
+++ b/drivers/media/usb/gspca/stv0680.c
@@ -139,7 +139,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
139 struct sd *sd = (struct sd *) gspca_dev; 139 struct sd *sd = (struct sd *) gspca_dev;
140 struct cam *cam = &gspca_dev->cam; 140 struct cam *cam = &gspca_dev->cam;
141 141
142 /* Give the camera some time to settle, otherwise initalization will 142 /* Give the camera some time to settle, otherwise initialization will
143 fail on hotplug, and yes it really needs a full second. */ 143 fail on hotplug, and yes it really needs a full second. */
144 msleep(1000); 144 msleep(1000);
145 145
diff --git a/drivers/media/usb/gspca/sunplus.c b/drivers/media/usb/gspca/sunplus.c
index a517d185febe..46c9f2229a18 100644
--- a/drivers/media/usb/gspca/sunplus.c
+++ b/drivers/media/usb/gspca/sunplus.c
@@ -1027,6 +1027,7 @@ static const struct usb_device_id device_table[] = {
1027 {USB_DEVICE(0x055f, 0xc650), BS(SPCA533, 0)}, 1027 {USB_DEVICE(0x055f, 0xc650), BS(SPCA533, 0)},
1028 {USB_DEVICE(0x05da, 0x1018), BS(SPCA504B, 0)}, 1028 {USB_DEVICE(0x05da, 0x1018), BS(SPCA504B, 0)},
1029 {USB_DEVICE(0x06d6, 0x0031), BS(SPCA533, 0)}, 1029 {USB_DEVICE(0x06d6, 0x0031), BS(SPCA533, 0)},
1030 {USB_DEVICE(0x06d6, 0x0041), BS(SPCA504B, 0)},
1030 {USB_DEVICE(0x0733, 0x1311), BS(SPCA533, 0)}, 1031 {USB_DEVICE(0x0733, 0x1311), BS(SPCA533, 0)},
1031 {USB_DEVICE(0x0733, 0x1314), BS(SPCA533, 0)}, 1032 {USB_DEVICE(0x0733, 0x1314), BS(SPCA533, 0)},
1032 {USB_DEVICE(0x0733, 0x2211), BS(SPCA533, 0)}, 1033 {USB_DEVICE(0x0733, 0x2211), BS(SPCA533, 0)},
diff --git a/drivers/media/usb/gspca/zc3xx.c b/drivers/media/usb/gspca/zc3xx.c
index 7b95d8e88a20..d3e1b6d8bf49 100644
--- a/drivers/media/usb/gspca/zc3xx.c
+++ b/drivers/media/usb/gspca/zc3xx.c
@@ -6905,7 +6905,7 @@ static int sd_get_jcomp(struct gspca_dev *gspca_dev,
6905#if IS_ENABLED(CONFIG_INPUT) 6905#if IS_ENABLED(CONFIG_INPUT)
6906static int sd_int_pkt_scan(struct gspca_dev *gspca_dev, 6906static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
6907 u8 *data, /* interrupt packet data */ 6907 u8 *data, /* interrupt packet data */
6908 int len) /* interrput packet length */ 6908 int len) /* interrupt packet length */
6909{ 6909{
6910 if (len == 8 && data[4] == 1) { 6910 if (len == 8 && data[4] == 1) {
6911 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1); 6911 input_report_key(gspca_dev->input_dev, KEY_CAMERA, 1);
diff --git a/drivers/media/usb/pwc/pwc-if.c b/drivers/media/usb/pwc/pwc-if.c
index 77bbf7889659..78c9bc8e7f56 100644
--- a/drivers/media/usb/pwc/pwc-if.c
+++ b/drivers/media/usb/pwc/pwc-if.c
@@ -1039,7 +1039,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
1039 /* Set the leds off */ 1039 /* Set the leds off */
1040 pwc_set_leds(pdev, 0, 0); 1040 pwc_set_leds(pdev, 0, 0);
1041 1041
1042 /* Setup intial videomode */ 1042 /* Setup initial videomode */
1043 rc = pwc_set_video_mode(pdev, MAX_WIDTH, MAX_HEIGHT, 1043 rc = pwc_set_video_mode(pdev, MAX_WIDTH, MAX_HEIGHT,
1044 V4L2_PIX_FMT_YUV420, 30, &compression, 1); 1044 V4L2_PIX_FMT_YUV420, 30, &compression, 1);
1045 if (rc) 1045 if (rc)
diff --git a/drivers/media/usb/usbtv/usbtv.c b/drivers/media/usb/usbtv/usbtv.c
index 8a505a90d318..6222a4ab1e00 100644
--- a/drivers/media/usb/usbtv/usbtv.c
+++ b/drivers/media/usb/usbtv/usbtv.c
@@ -50,13 +50,8 @@
50#define USBTV_ISOC_TRANSFERS 16 50#define USBTV_ISOC_TRANSFERS 16
51#define USBTV_ISOC_PACKETS 8 51#define USBTV_ISOC_PACKETS 8
52 52
53#define USBTV_WIDTH 720
54#define USBTV_HEIGHT 480
55
56#define USBTV_CHUNK_SIZE 256 53#define USBTV_CHUNK_SIZE 256
57#define USBTV_CHUNK 240 54#define USBTV_CHUNK 240
58#define USBTV_CHUNKS (USBTV_WIDTH * USBTV_HEIGHT \
59 / 4 / USBTV_CHUNK)
60 55
61/* Chunk header. */ 56/* Chunk header. */
62#define USBTV_MAGIC_OK(chunk) ((be32_to_cpu(chunk[0]) & 0xff000000) \ 57#define USBTV_MAGIC_OK(chunk) ((be32_to_cpu(chunk[0]) & 0xff000000) \
@@ -65,6 +60,27 @@
65#define USBTV_ODD(chunk) ((be32_to_cpu(chunk[0]) & 0x0000f000) >> 15) 60#define USBTV_ODD(chunk) ((be32_to_cpu(chunk[0]) & 0x0000f000) >> 15)
66#define USBTV_CHUNK_NO(chunk) (be32_to_cpu(chunk[0]) & 0x00000fff) 61#define USBTV_CHUNK_NO(chunk) (be32_to_cpu(chunk[0]) & 0x00000fff)
67 62
63#define USBTV_TV_STD (V4L2_STD_525_60 | V4L2_STD_PAL)
64
65/* parameters for supported TV norms */
66struct usbtv_norm_params {
67 v4l2_std_id norm;
68 int cap_width, cap_height;
69};
70
71static struct usbtv_norm_params norm_params[] = {
72 {
73 .norm = V4L2_STD_525_60,
74 .cap_width = 720,
75 .cap_height = 480,
76 },
77 {
78 .norm = V4L2_STD_PAL,
79 .cap_width = 720,
80 .cap_height = 576,
81 }
82};
83
68/* A single videobuf2 frame buffer. */ 84/* A single videobuf2 frame buffer. */
69struct usbtv_buf { 85struct usbtv_buf {
70 struct vb2_buffer vb; 86 struct vb2_buffer vb;
@@ -94,11 +110,38 @@ struct usbtv {
94 USBTV_COMPOSITE_INPUT, 110 USBTV_COMPOSITE_INPUT,
95 USBTV_SVIDEO_INPUT, 111 USBTV_SVIDEO_INPUT,
96 } input; 112 } input;
113 v4l2_std_id norm;
114 int width, height;
115 int n_chunks;
97 int iso_size; 116 int iso_size;
98 unsigned int sequence; 117 unsigned int sequence;
99 struct urb *isoc_urbs[USBTV_ISOC_TRANSFERS]; 118 struct urb *isoc_urbs[USBTV_ISOC_TRANSFERS];
100}; 119};
101 120
121static int usbtv_configure_for_norm(struct usbtv *usbtv, v4l2_std_id norm)
122{
123 int i, ret = 0;
124 struct usbtv_norm_params *params = NULL;
125
126 for (i = 0; i < ARRAY_SIZE(norm_params); i++) {
127 if (norm_params[i].norm & norm) {
128 params = &norm_params[i];
129 break;
130 }
131 }
132
133 if (params) {
134 usbtv->width = params->cap_width;
135 usbtv->height = params->cap_height;
136 usbtv->n_chunks = usbtv->width * usbtv->height
137 / 4 / USBTV_CHUNK;
138 usbtv->norm = params->norm;
139 } else
140 ret = -EINVAL;
141
142 return ret;
143}
144
102static int usbtv_set_regs(struct usbtv *usbtv, const u16 regs[][2], int size) 145static int usbtv_set_regs(struct usbtv *usbtv, const u16 regs[][2], int size)
103{ 146{
104 int ret; 147 int ret;
@@ -158,6 +201,57 @@ static int usbtv_select_input(struct usbtv *usbtv, int input)
158 return ret; 201 return ret;
159} 202}
160 203
204static int usbtv_select_norm(struct usbtv *usbtv, v4l2_std_id norm)
205{
206 int ret;
207 static const u16 pal[][2] = {
208 { USBTV_BASE + 0x001a, 0x0068 },
209 { USBTV_BASE + 0x010e, 0x0072 },
210 { USBTV_BASE + 0x010f, 0x00a2 },
211 { USBTV_BASE + 0x0112, 0x00b0 },
212 { USBTV_BASE + 0x0117, 0x0001 },
213 { USBTV_BASE + 0x0118, 0x002c },
214 { USBTV_BASE + 0x012d, 0x0010 },
215 { USBTV_BASE + 0x012f, 0x0020 },
216 { USBTV_BASE + 0x024f, 0x0002 },
217 { USBTV_BASE + 0x0254, 0x0059 },
218 { USBTV_BASE + 0x025a, 0x0016 },
219 { USBTV_BASE + 0x025b, 0x0035 },
220 { USBTV_BASE + 0x0263, 0x0017 },
221 { USBTV_BASE + 0x0266, 0x0016 },
222 { USBTV_BASE + 0x0267, 0x0036 }
223 };
224
225 static const u16 ntsc[][2] = {
226 { USBTV_BASE + 0x001a, 0x0079 },
227 { USBTV_BASE + 0x010e, 0x0068 },
228 { USBTV_BASE + 0x010f, 0x009c },
229 { USBTV_BASE + 0x0112, 0x00f0 },
230 { USBTV_BASE + 0x0117, 0x0000 },
231 { USBTV_BASE + 0x0118, 0x00fc },
232 { USBTV_BASE + 0x012d, 0x0004 },
233 { USBTV_BASE + 0x012f, 0x0008 },
234 { USBTV_BASE + 0x024f, 0x0001 },
235 { USBTV_BASE + 0x0254, 0x005f },
236 { USBTV_BASE + 0x025a, 0x0012 },
237 { USBTV_BASE + 0x025b, 0x0001 },
238 { USBTV_BASE + 0x0263, 0x001c },
239 { USBTV_BASE + 0x0266, 0x0011 },
240 { USBTV_BASE + 0x0267, 0x0005 }
241 };
242
243 ret = usbtv_configure_for_norm(usbtv, norm);
244
245 if (!ret) {
246 if (norm & V4L2_STD_525_60)
247 ret = usbtv_set_regs(usbtv, ntsc, ARRAY_SIZE(ntsc));
248 else if (norm & V4L2_STD_PAL)
249 ret = usbtv_set_regs(usbtv, pal, ARRAY_SIZE(pal));
250 }
251
252 return ret;
253}
254
161static int usbtv_setup_capture(struct usbtv *usbtv) 255static int usbtv_setup_capture(struct usbtv *usbtv)
162{ 256{
163 int ret; 257 int ret;
@@ -225,26 +319,11 @@ static int usbtv_setup_capture(struct usbtv *usbtv)
225 319
226 { USBTV_BASE + 0x0284, 0x0088 }, 320 { USBTV_BASE + 0x0284, 0x0088 },
227 { USBTV_BASE + 0x0003, 0x0004 }, 321 { USBTV_BASE + 0x0003, 0x0004 },
228 { USBTV_BASE + 0x001a, 0x0079 },
229 { USBTV_BASE + 0x0100, 0x00d3 }, 322 { USBTV_BASE + 0x0100, 0x00d3 },
230 { USBTV_BASE + 0x010e, 0x0068 },
231 { USBTV_BASE + 0x010f, 0x009c },
232 { USBTV_BASE + 0x0112, 0x00f0 },
233 { USBTV_BASE + 0x0115, 0x0015 }, 323 { USBTV_BASE + 0x0115, 0x0015 },
234 { USBTV_BASE + 0x0117, 0x0000 },
235 { USBTV_BASE + 0x0118, 0x00fc },
236 { USBTV_BASE + 0x012d, 0x0004 },
237 { USBTV_BASE + 0x012f, 0x0008 },
238 { USBTV_BASE + 0x0220, 0x002e }, 324 { USBTV_BASE + 0x0220, 0x002e },
239 { USBTV_BASE + 0x0225, 0x0008 }, 325 { USBTV_BASE + 0x0225, 0x0008 },
240 { USBTV_BASE + 0x024e, 0x0002 }, 326 { USBTV_BASE + 0x024e, 0x0002 },
241 { USBTV_BASE + 0x024f, 0x0001 },
242 { USBTV_BASE + 0x0254, 0x005f },
243 { USBTV_BASE + 0x025a, 0x0012 },
244 { USBTV_BASE + 0x025b, 0x0001 },
245 { USBTV_BASE + 0x0263, 0x001c },
246 { USBTV_BASE + 0x0266, 0x0011 },
247 { USBTV_BASE + 0x0267, 0x0005 },
248 { USBTV_BASE + 0x024e, 0x0002 }, 327 { USBTV_BASE + 0x024e, 0x0002 },
249 { USBTV_BASE + 0x024f, 0x0002 }, 328 { USBTV_BASE + 0x024f, 0x0002 },
250 }; 329 };
@@ -253,6 +332,10 @@ static int usbtv_setup_capture(struct usbtv *usbtv)
253 if (ret) 332 if (ret)
254 return ret; 333 return ret;
255 334
335 ret = usbtv_select_norm(usbtv, usbtv->norm);
336 if (ret)
337 return ret;
338
256 ret = usbtv_select_input(usbtv, usbtv->input); 339 ret = usbtv_select_input(usbtv, usbtv->input);
257 if (ret) 340 if (ret)
258 return ret; 341 return ret;
@@ -296,7 +379,7 @@ static void usbtv_image_chunk(struct usbtv *usbtv, u32 *chunk)
296 frame_id = USBTV_FRAME_ID(chunk); 379 frame_id = USBTV_FRAME_ID(chunk);
297 odd = USBTV_ODD(chunk); 380 odd = USBTV_ODD(chunk);
298 chunk_no = USBTV_CHUNK_NO(chunk); 381 chunk_no = USBTV_CHUNK_NO(chunk);
299 if (chunk_no >= USBTV_CHUNKS) 382 if (chunk_no >= usbtv->n_chunks)
300 return; 383 return;
301 384
302 /* Beginning of a frame. */ 385 /* Beginning of a frame. */
@@ -324,10 +407,10 @@ static void usbtv_image_chunk(struct usbtv *usbtv, u32 *chunk)
324 usbtv->chunks_done++; 407 usbtv->chunks_done++;
325 408
326 /* Last chunk in a frame, signalling an end */ 409 /* Last chunk in a frame, signalling an end */
327 if (odd && chunk_no == USBTV_CHUNKS-1) { 410 if (odd && chunk_no == usbtv->n_chunks-1) {
328 int size = vb2_plane_size(&buf->vb, 0); 411 int size = vb2_plane_size(&buf->vb, 0);
329 enum vb2_buffer_state state = usbtv->chunks_done == 412 enum vb2_buffer_state state = usbtv->chunks_done ==
330 USBTV_CHUNKS ? 413 usbtv->n_chunks ?
331 VB2_BUF_STATE_DONE : 414 VB2_BUF_STATE_DONE :
332 VB2_BUF_STATE_ERROR; 415 VB2_BUF_STATE_ERROR;
333 416
@@ -500,6 +583,8 @@ static int usbtv_querycap(struct file *file, void *priv,
500static int usbtv_enum_input(struct file *file, void *priv, 583static int usbtv_enum_input(struct file *file, void *priv,
501 struct v4l2_input *i) 584 struct v4l2_input *i)
502{ 585{
586 struct usbtv *dev = video_drvdata(file);
587
503 switch (i->index) { 588 switch (i->index) {
504 case USBTV_COMPOSITE_INPUT: 589 case USBTV_COMPOSITE_INPUT:
505 strlcpy(i->name, "Composite", sizeof(i->name)); 590 strlcpy(i->name, "Composite", sizeof(i->name));
@@ -512,7 +597,7 @@ static int usbtv_enum_input(struct file *file, void *priv,
512 } 597 }
513 598
514 i->type = V4L2_INPUT_TYPE_CAMERA; 599 i->type = V4L2_INPUT_TYPE_CAMERA;
515 i->std = V4L2_STD_525_60; 600 i->std = dev->vdev.tvnorms;
516 return 0; 601 return 0;
517} 602}
518 603
@@ -531,23 +616,37 @@ static int usbtv_enum_fmt_vid_cap(struct file *file, void *priv,
531static int usbtv_fmt_vid_cap(struct file *file, void *priv, 616static int usbtv_fmt_vid_cap(struct file *file, void *priv,
532 struct v4l2_format *f) 617 struct v4l2_format *f)
533{ 618{
534 f->fmt.pix.width = USBTV_WIDTH; 619 struct usbtv *usbtv = video_drvdata(file);
535 f->fmt.pix.height = USBTV_HEIGHT; 620
621 f->fmt.pix.width = usbtv->width;
622 f->fmt.pix.height = usbtv->height;
536 f->fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV; 623 f->fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
537 f->fmt.pix.field = V4L2_FIELD_INTERLACED; 624 f->fmt.pix.field = V4L2_FIELD_INTERLACED;
538 f->fmt.pix.bytesperline = USBTV_WIDTH * 2; 625 f->fmt.pix.bytesperline = usbtv->width * 2;
539 f->fmt.pix.sizeimage = (f->fmt.pix.bytesperline * f->fmt.pix.height); 626 f->fmt.pix.sizeimage = (f->fmt.pix.bytesperline * f->fmt.pix.height);
540 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 627 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
541 f->fmt.pix.priv = 0; 628
542 return 0; 629 return 0;
543} 630}
544 631
545static int usbtv_g_std(struct file *file, void *priv, v4l2_std_id *norm) 632static int usbtv_g_std(struct file *file, void *priv, v4l2_std_id *norm)
546{ 633{
547 *norm = V4L2_STD_525_60; 634 struct usbtv *usbtv = video_drvdata(file);
635 *norm = usbtv->norm;
548 return 0; 636 return 0;
549} 637}
550 638
639static int usbtv_s_std(struct file *file, void *priv, v4l2_std_id norm)
640{
641 int ret = -EINVAL;
642 struct usbtv *usbtv = video_drvdata(file);
643
644 if ((norm & V4L2_STD_525_60) || (norm & V4L2_STD_PAL))
645 ret = usbtv_select_norm(usbtv, norm);
646
647 return ret;
648}
649
551static int usbtv_g_input(struct file *file, void *priv, unsigned int *i) 650static int usbtv_g_input(struct file *file, void *priv, unsigned int *i)
552{ 651{
553 struct usbtv *usbtv = video_drvdata(file); 652 struct usbtv *usbtv = video_drvdata(file);
@@ -561,13 +660,6 @@ static int usbtv_s_input(struct file *file, void *priv, unsigned int i)
561 return usbtv_select_input(usbtv, i); 660 return usbtv_select_input(usbtv, i);
562} 661}
563 662
564static int usbtv_s_std(struct file *file, void *priv, v4l2_std_id norm)
565{
566 if (norm & V4L2_STD_525_60)
567 return 0;
568 return -EINVAL;
569}
570
571struct v4l2_ioctl_ops usbtv_ioctl_ops = { 663struct v4l2_ioctl_ops usbtv_ioctl_ops = {
572 .vidioc_querycap = usbtv_querycap, 664 .vidioc_querycap = usbtv_querycap,
573 .vidioc_enum_input = usbtv_enum_input, 665 .vidioc_enum_input = usbtv_enum_input,
@@ -604,10 +696,12 @@ static int usbtv_queue_setup(struct vb2_queue *vq,
604 const struct v4l2_format *v4l_fmt, unsigned int *nbuffers, 696 const struct v4l2_format *v4l_fmt, unsigned int *nbuffers,
605 unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[]) 697 unsigned int *nplanes, unsigned int sizes[], void *alloc_ctxs[])
606{ 698{
699 struct usbtv *usbtv = vb2_get_drv_priv(vq);
700
607 if (*nbuffers < 2) 701 if (*nbuffers < 2)
608 *nbuffers = 2; 702 *nbuffers = 2;
609 *nplanes = 1; 703 *nplanes = 1;
610 sizes[0] = USBTV_WIDTH * USBTV_HEIGHT / 2 * sizeof(u32); 704 sizes[0] = USBTV_CHUNK * usbtv->n_chunks * 2 * sizeof(u32);
611 705
612 return 0; 706 return 0;
613} 707}
@@ -690,7 +784,11 @@ static int usbtv_probe(struct usb_interface *intf,
690 return -ENOMEM; 784 return -ENOMEM;
691 usbtv->dev = dev; 785 usbtv->dev = dev;
692 usbtv->udev = usb_get_dev(interface_to_usbdev(intf)); 786 usbtv->udev = usb_get_dev(interface_to_usbdev(intf));
787
693 usbtv->iso_size = size; 788 usbtv->iso_size = size;
789
790 (void)usbtv_configure_for_norm(usbtv, V4L2_STD_525_60);
791
694 spin_lock_init(&usbtv->buflock); 792 spin_lock_init(&usbtv->buflock);
695 mutex_init(&usbtv->v4l2_lock); 793 mutex_init(&usbtv->v4l2_lock);
696 mutex_init(&usbtv->vb2q_lock); 794 mutex_init(&usbtv->vb2q_lock);
@@ -727,7 +825,7 @@ static int usbtv_probe(struct usb_interface *intf,
727 usbtv->vdev.release = video_device_release_empty; 825 usbtv->vdev.release = video_device_release_empty;
728 usbtv->vdev.fops = &usbtv_fops; 826 usbtv->vdev.fops = &usbtv_fops;
729 usbtv->vdev.ioctl_ops = &usbtv_ioctl_ops; 827 usbtv->vdev.ioctl_ops = &usbtv_ioctl_ops;
730 usbtv->vdev.tvnorms = V4L2_STD_525_60; 828 usbtv->vdev.tvnorms = USBTV_TV_STD;
731 usbtv->vdev.queue = &usbtv->vb2q; 829 usbtv->vdev.queue = &usbtv->vb2q;
732 usbtv->vdev.lock = &usbtv->v4l2_lock; 830 usbtv->vdev.lock = &usbtv->v4l2_lock;
733 set_bit(V4L2_FL_USE_FH_PRIO, &usbtv->vdev.flags); 831 set_bit(V4L2_FL_USE_FH_PRIO, &usbtv->vdev.flags);
diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
index 899cb6d1c4a4..898c208889cd 100644
--- a/drivers/media/usb/uvc/uvc_video.c
+++ b/drivers/media/usb/uvc/uvc_video.c
@@ -556,7 +556,7 @@ static u16 uvc_video_clock_host_sof(const struct uvc_clock_sample *sample)
556 * 556 *
557 * SOF = ((SOF2 - SOF1) * PTS + SOF1 * STC2 - SOF2 * STC1) / (STC2 - STC1) (1) 557 * SOF = ((SOF2 - SOF1) * PTS + SOF1 * STC2 - SOF2 * STC1) / (STC2 - STC1) (1)
558 * 558 *
559 * to avoid loosing precision in the division. Similarly, the host timestamp is 559 * to avoid losing precision in the division. Similarly, the host timestamp is
560 * computed with 560 * computed with
561 * 561 *
562 * TS = ((TS2 - TS1) * PTS + TS1 * SOF2 - TS2 * SOF1) / (SOF2 - SOF1) (2) 562 * TS = ((TS2 - TS1) * PTS + TS1 * SOF2 - TS2 * SOF1) / (SOF2 - SOF1) (2)
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
index 60dcc0f3b32e..fb46790d0eca 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -420,7 +420,7 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
420 "Advanced Simple", 420 "Advanced Simple",
421 "Core", 421 "Core",
422 "Simple Scalable", 422 "Simple Scalable",
423 "Advanced Coding Efficency", 423 "Advanced Coding Efficiency",
424 NULL, 424 NULL,
425 }; 425 };
426 426
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index b19b306c8f7f..0edc165f418d 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -145,6 +145,25 @@ static void __vb2_buf_dmabuf_put(struct vb2_buffer *vb)
145} 145}
146 146
147/** 147/**
148 * __setup_lengths() - setup initial lengths for every plane in
149 * every buffer on the queue
150 */
151static void __setup_lengths(struct vb2_queue *q, unsigned int n)
152{
153 unsigned int buffer, plane;
154 struct vb2_buffer *vb;
155
156 for (buffer = q->num_buffers; buffer < q->num_buffers + n; ++buffer) {
157 vb = q->bufs[buffer];
158 if (!vb)
159 continue;
160
161 for (plane = 0; plane < vb->num_planes; ++plane)
162 vb->v4l2_planes[plane].length = q->plane_sizes[plane];
163 }
164}
165
166/**
148 * __setup_offsets() - setup unique offsets ("cookies") for every plane in 167 * __setup_offsets() - setup unique offsets ("cookies") for every plane in
149 * every buffer on the queue 168 * every buffer on the queue
150 */ 169 */
@@ -169,7 +188,6 @@ static void __setup_offsets(struct vb2_queue *q, unsigned int n)
169 continue; 188 continue;
170 189
171 for (plane = 0; plane < vb->num_planes; ++plane) { 190 for (plane = 0; plane < vb->num_planes; ++plane) {
172 vb->v4l2_planes[plane].length = q->plane_sizes[plane];
173 vb->v4l2_planes[plane].m.mem_offset = off; 191 vb->v4l2_planes[plane].m.mem_offset = off;
174 192
175 dprintk(3, "Buffer %d, plane %d offset 0x%08lx\n", 193 dprintk(3, "Buffer %d, plane %d offset 0x%08lx\n",
@@ -241,6 +259,7 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum v4l2_memory memory,
241 q->bufs[q->num_buffers + buffer] = vb; 259 q->bufs[q->num_buffers + buffer] = vb;
242 } 260 }
243 261
262 __setup_lengths(q, buffer);
244 if (memory == V4L2_MEMORY_MMAP) 263 if (memory == V4L2_MEMORY_MMAP)
245 __setup_offsets(q, buffer); 264 __setup_offsets(q, buffer);
246 265
@@ -1824,8 +1843,8 @@ int vb2_expbuf(struct vb2_queue *q, struct v4l2_exportbuffer *eb)
1824 return -EINVAL; 1843 return -EINVAL;
1825 } 1844 }
1826 1845
1827 if (eb->flags & ~O_CLOEXEC) { 1846 if (eb->flags & ~(O_CLOEXEC | O_ACCMODE)) {
1828 dprintk(1, "Queue does support only O_CLOEXEC flag\n"); 1847 dprintk(1, "Queue does support only O_CLOEXEC and access mode flags\n");
1829 return -EINVAL; 1848 return -EINVAL;
1830 } 1849 }
1831 1850
@@ -1848,14 +1867,14 @@ int vb2_expbuf(struct vb2_queue *q, struct v4l2_exportbuffer *eb)
1848 1867
1849 vb_plane = &vb->planes[eb->plane]; 1868 vb_plane = &vb->planes[eb->plane];
1850 1869
1851 dbuf = call_memop(q, get_dmabuf, vb_plane->mem_priv); 1870 dbuf = call_memop(q, get_dmabuf, vb_plane->mem_priv, eb->flags & O_ACCMODE);
1852 if (IS_ERR_OR_NULL(dbuf)) { 1871 if (IS_ERR_OR_NULL(dbuf)) {
1853 dprintk(1, "Failed to export buffer %d, plane %d\n", 1872 dprintk(1, "Failed to export buffer %d, plane %d\n",
1854 eb->index, eb->plane); 1873 eb->index, eb->plane);
1855 return -EINVAL; 1874 return -EINVAL;
1856 } 1875 }
1857 1876
1858 ret = dma_buf_fd(dbuf, eb->flags); 1877 ret = dma_buf_fd(dbuf, eb->flags & ~O_ACCMODE);
1859 if (ret < 0) { 1878 if (ret < 0) {
1860 dprintk(3, "buffer %d, plane %d failed to export (%d)\n", 1879 dprintk(3, "buffer %d, plane %d failed to export (%d)\n",
1861 eb->index, eb->plane, ret); 1880 eb->index, eb->plane, ret);
diff --git a/drivers/media/v4l2-core/videobuf2-dma-contig.c b/drivers/media/v4l2-core/videobuf2-dma-contig.c
index 646f08f4f504..33d3871d1e13 100644
--- a/drivers/media/v4l2-core/videobuf2-dma-contig.c
+++ b/drivers/media/v4l2-core/videobuf2-dma-contig.c
@@ -393,7 +393,7 @@ static struct sg_table *vb2_dc_get_base_sgt(struct vb2_dc_buf *buf)
393 return sgt; 393 return sgt;
394} 394}
395 395
396static struct dma_buf *vb2_dc_get_dmabuf(void *buf_priv) 396static struct dma_buf *vb2_dc_get_dmabuf(void *buf_priv, unsigned long flags)
397{ 397{
398 struct vb2_dc_buf *buf = buf_priv; 398 struct vb2_dc_buf *buf = buf_priv;
399 struct dma_buf *dbuf; 399 struct dma_buf *dbuf;
@@ -404,7 +404,7 @@ static struct dma_buf *vb2_dc_get_dmabuf(void *buf_priv)
404 if (WARN_ON(!buf->sgt_base)) 404 if (WARN_ON(!buf->sgt_base))
405 return NULL; 405 return NULL;
406 406
407 dbuf = dma_buf_export(buf, &vb2_dc_dmabuf_ops, buf->size, 0); 407 dbuf = dma_buf_export(buf, &vb2_dc_dmabuf_ops, buf->size, flags);
408 if (IS_ERR(dbuf)) 408 if (IS_ERR(dbuf))
409 return NULL; 409 return NULL;
410 410
diff --git a/drivers/media/v4l2-core/videobuf2-dma-sg.c b/drivers/media/v4l2-core/videobuf2-dma-sg.c
index 2f860543912c..0d3a8ffe47a3 100644
--- a/drivers/media/v4l2-core/videobuf2-dma-sg.c
+++ b/drivers/media/v4l2-core/videobuf2-dma-sg.c
@@ -178,7 +178,7 @@ static void *vb2_dma_sg_get_userptr(void *alloc_ctx, unsigned long vaddr,
178 buf->pages = kzalloc(buf->num_pages * sizeof(struct page *), 178 buf->pages = kzalloc(buf->num_pages * sizeof(struct page *),
179 GFP_KERNEL); 179 GFP_KERNEL);
180 if (!buf->pages) 180 if (!buf->pages)
181 return NULL; 181 goto userptr_fail_alloc_pages;
182 182
183 num_pages_from_user = get_user_pages(current, current->mm, 183 num_pages_from_user = get_user_pages(current, current->mm,
184 vaddr & PAGE_MASK, 184 vaddr & PAGE_MASK,
@@ -204,6 +204,7 @@ userptr_fail_get_user_pages:
204 while (--num_pages_from_user >= 0) 204 while (--num_pages_from_user >= 0)
205 put_page(buf->pages[num_pages_from_user]); 205 put_page(buf->pages[num_pages_from_user]);
206 kfree(buf->pages); 206 kfree(buf->pages);
207userptr_fail_alloc_pages:
207 kfree(buf); 208 kfree(buf);
208 return NULL; 209 return NULL;
209} 210}
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 62a60caa5d1f..dd671582c9a1 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -32,7 +32,7 @@ config MFD_AS3722
32 select MFD_CORE 32 select MFD_CORE
33 select REGMAP_I2C 33 select REGMAP_I2C
34 select REGMAP_IRQ 34 select REGMAP_IRQ
35 depends on I2C && OF 35 depends on I2C=y && OF
36 help 36 help
37 The ams AS3722 is a compact system PMU suitable for mobile phones, 37 The ams AS3722 is a compact system PMU suitable for mobile phones,
38 tablets etc. It has 4 DC/DC step-down regulators, 3 DC/DC step-down 38 tablets etc. It has 4 DC/DC step-down regulators, 3 DC/DC step-down
diff --git a/drivers/mfd/lpc_ich.c b/drivers/mfd/lpc_ich.c
index da1c6566d93d..37edf9e989b0 100644
--- a/drivers/mfd/lpc_ich.c
+++ b/drivers/mfd/lpc_ich.c
@@ -506,7 +506,7 @@ static struct lpc_ich_info lpc_chipset_info[] = {
506 .iTCO_version = 2, 506 .iTCO_version = 2,
507 }, 507 },
508 [LPC_WPT_LP] = { 508 [LPC_WPT_LP] = {
509 .name = "Lynx Point_LP", 509 .name = "Wildcat Point_LP",
510 .iTCO_version = 2, 510 .iTCO_version = 2,
511 }, 511 },
512}; 512};
diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c
index 34c18fb8c089..54cc25546592 100644
--- a/drivers/mfd/sec-core.c
+++ b/drivers/mfd/sec-core.c
@@ -81,31 +81,31 @@ static struct of_device_id sec_dt_match[] = {
81 81
82int sec_reg_read(struct sec_pmic_dev *sec_pmic, u8 reg, void *dest) 82int sec_reg_read(struct sec_pmic_dev *sec_pmic, u8 reg, void *dest)
83{ 83{
84 return regmap_read(sec_pmic->regmap, reg, dest); 84 return regmap_read(sec_pmic->regmap_pmic, reg, dest);
85} 85}
86EXPORT_SYMBOL_GPL(sec_reg_read); 86EXPORT_SYMBOL_GPL(sec_reg_read);
87 87
88int sec_bulk_read(struct sec_pmic_dev *sec_pmic, u8 reg, int count, u8 *buf) 88int sec_bulk_read(struct sec_pmic_dev *sec_pmic, u8 reg, int count, u8 *buf)
89{ 89{
90 return regmap_bulk_read(sec_pmic->regmap, reg, buf, count); 90 return regmap_bulk_read(sec_pmic->regmap_pmic, reg, buf, count);
91} 91}
92EXPORT_SYMBOL_GPL(sec_bulk_read); 92EXPORT_SYMBOL_GPL(sec_bulk_read);
93 93
94int sec_reg_write(struct sec_pmic_dev *sec_pmic, u8 reg, u8 value) 94int sec_reg_write(struct sec_pmic_dev *sec_pmic, u8 reg, u8 value)
95{ 95{
96 return regmap_write(sec_pmic->regmap, reg, value); 96 return regmap_write(sec_pmic->regmap_pmic, reg, value);
97} 97}
98EXPORT_SYMBOL_GPL(sec_reg_write); 98EXPORT_SYMBOL_GPL(sec_reg_write);
99 99
100int sec_bulk_write(struct sec_pmic_dev *sec_pmic, u8 reg, int count, u8 *buf) 100int sec_bulk_write(struct sec_pmic_dev *sec_pmic, u8 reg, int count, u8 *buf)
101{ 101{
102 return regmap_raw_write(sec_pmic->regmap, reg, buf, count); 102 return regmap_raw_write(sec_pmic->regmap_pmic, reg, buf, count);
103} 103}
104EXPORT_SYMBOL_GPL(sec_bulk_write); 104EXPORT_SYMBOL_GPL(sec_bulk_write);
105 105
106int sec_reg_update(struct sec_pmic_dev *sec_pmic, u8 reg, u8 val, u8 mask) 106int sec_reg_update(struct sec_pmic_dev *sec_pmic, u8 reg, u8 val, u8 mask)
107{ 107{
108 return regmap_update_bits(sec_pmic->regmap, reg, mask, val); 108 return regmap_update_bits(sec_pmic->regmap_pmic, reg, mask, val);
109} 109}
110EXPORT_SYMBOL_GPL(sec_reg_update); 110EXPORT_SYMBOL_GPL(sec_reg_update);
111 111
@@ -166,6 +166,11 @@ static struct regmap_config s5m8767_regmap_config = {
166 .cache_type = REGCACHE_FLAT, 166 .cache_type = REGCACHE_FLAT,
167}; 167};
168 168
169static const struct regmap_config sec_rtc_regmap_config = {
170 .reg_bits = 8,
171 .val_bits = 8,
172};
173
169#ifdef CONFIG_OF 174#ifdef CONFIG_OF
170/* 175/*
171 * Only the common platform data elements for s5m8767 are parsed here from the 176 * Only the common platform data elements for s5m8767 are parsed here from the
@@ -266,9 +271,9 @@ static int sec_pmic_probe(struct i2c_client *i2c,
266 break; 271 break;
267 } 272 }
268 273
269 sec_pmic->regmap = devm_regmap_init_i2c(i2c, regmap); 274 sec_pmic->regmap_pmic = devm_regmap_init_i2c(i2c, regmap);
270 if (IS_ERR(sec_pmic->regmap)) { 275 if (IS_ERR(sec_pmic->regmap_pmic)) {
271 ret = PTR_ERR(sec_pmic->regmap); 276 ret = PTR_ERR(sec_pmic->regmap_pmic);
272 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", 277 dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
273 ret); 278 ret);
274 return ret; 279 return ret;
@@ -277,6 +282,15 @@ static int sec_pmic_probe(struct i2c_client *i2c,
277 sec_pmic->rtc = i2c_new_dummy(i2c->adapter, RTC_I2C_ADDR); 282 sec_pmic->rtc = i2c_new_dummy(i2c->adapter, RTC_I2C_ADDR);
278 i2c_set_clientdata(sec_pmic->rtc, sec_pmic); 283 i2c_set_clientdata(sec_pmic->rtc, sec_pmic);
279 284
285 sec_pmic->regmap_rtc = devm_regmap_init_i2c(sec_pmic->rtc,
286 &sec_rtc_regmap_config);
287 if (IS_ERR(sec_pmic->regmap_rtc)) {
288 ret = PTR_ERR(sec_pmic->regmap_rtc);
289 dev_err(&i2c->dev, "Failed to allocate RTC register map: %d\n",
290 ret);
291 return ret;
292 }
293
280 if (pdata && pdata->cfg_pmic_irq) 294 if (pdata && pdata->cfg_pmic_irq)
281 pdata->cfg_pmic_irq(); 295 pdata->cfg_pmic_irq();
282 296
diff --git a/drivers/mfd/sec-irq.c b/drivers/mfd/sec-irq.c
index 0dd84e99081e..b441b1be27cb 100644
--- a/drivers/mfd/sec-irq.c
+++ b/drivers/mfd/sec-irq.c
@@ -280,19 +280,19 @@ int sec_irq_init(struct sec_pmic_dev *sec_pmic)
280 280
281 switch (type) { 281 switch (type) {
282 case S5M8763X: 282 case S5M8763X:
283 ret = regmap_add_irq_chip(sec_pmic->regmap, sec_pmic->irq, 283 ret = regmap_add_irq_chip(sec_pmic->regmap_pmic, sec_pmic->irq,
284 IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 284 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
285 sec_pmic->irq_base, &s5m8763_irq_chip, 285 sec_pmic->irq_base, &s5m8763_irq_chip,
286 &sec_pmic->irq_data); 286 &sec_pmic->irq_data);
287 break; 287 break;
288 case S5M8767X: 288 case S5M8767X:
289 ret = regmap_add_irq_chip(sec_pmic->regmap, sec_pmic->irq, 289 ret = regmap_add_irq_chip(sec_pmic->regmap_pmic, sec_pmic->irq,
290 IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 290 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
291 sec_pmic->irq_base, &s5m8767_irq_chip, 291 sec_pmic->irq_base, &s5m8767_irq_chip,
292 &sec_pmic->irq_data); 292 &sec_pmic->irq_data);
293 break; 293 break;
294 case S2MPS11X: 294 case S2MPS11X:
295 ret = regmap_add_irq_chip(sec_pmic->regmap, sec_pmic->irq, 295 ret = regmap_add_irq_chip(sec_pmic->regmap_pmic, sec_pmic->irq,
296 IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 296 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
297 sec_pmic->irq_base, &s2mps11_irq_chip, 297 sec_pmic->irq_base, &s2mps11_irq_chip,
298 &sec_pmic->irq_data); 298 &sec_pmic->irq_data);
diff --git a/drivers/mfd/ti-ssp.c b/drivers/mfd/ti-ssp.c
index 71e3e0c5bf73..a5424579679c 100644
--- a/drivers/mfd/ti-ssp.c
+++ b/drivers/mfd/ti-ssp.c
@@ -32,6 +32,7 @@
32#include <linux/platform_device.h> 32#include <linux/platform_device.h>
33#include <linux/delay.h> 33#include <linux/delay.h>
34#include <linux/io.h> 34#include <linux/io.h>
35#include <linux/sched.h>
35#include <linux/mfd/core.h> 36#include <linux/mfd/core.h>
36#include <linux/mfd/ti_ssp.h> 37#include <linux/mfd/ti_ssp.h>
37 38
@@ -409,7 +410,6 @@ static int ti_ssp_probe(struct platform_device *pdev)
409 cells[id].id = id; 410 cells[id].id = id;
410 cells[id].name = data->dev_name; 411 cells[id].name = data->dev_name;
411 cells[id].platform_data = data->pdata; 412 cells[id].platform_data = data->pdata;
412 cells[id].data_size = data->pdata_size;
413 } 413 }
414 414
415 error = mfd_add_devices(dev, 0, cells, 2, NULL, 0, NULL); 415 error = mfd_add_devices(dev, 0, cells, 2, NULL, 0, NULL);
diff --git a/drivers/misc/mei/hw-me-regs.h b/drivers/misc/mei/hw-me-regs.h
index 6c0fde55270d..66f411a6e8ea 100644
--- a/drivers/misc/mei/hw-me-regs.h
+++ b/drivers/misc/mei/hw-me-regs.h
@@ -109,9 +109,12 @@
109#define MEI_DEV_ID_PPT_2 0x1CBA /* Panther Point */ 109#define MEI_DEV_ID_PPT_2 0x1CBA /* Panther Point */
110#define MEI_DEV_ID_PPT_3 0x1DBA /* Panther Point */ 110#define MEI_DEV_ID_PPT_3 0x1DBA /* Panther Point */
111 111
112#define MEI_DEV_ID_LPT 0x8C3A /* Lynx Point */ 112#define MEI_DEV_ID_LPT_H 0x8C3A /* Lynx Point H */
113#define MEI_DEV_ID_LPT_W 0x8D3A /* Lynx Point - Wellsburg */ 113#define MEI_DEV_ID_LPT_W 0x8D3A /* Lynx Point - Wellsburg */
114#define MEI_DEV_ID_LPT_LP 0x9C3A /* Lynx Point LP */ 114#define MEI_DEV_ID_LPT_LP 0x9C3A /* Lynx Point LP */
115#define MEI_DEV_ID_LPT_HR 0x8CBA /* Lynx Point H Refresh */
116
117#define MEI_DEV_ID_WPT_LP 0x9CBA /* Wildcat Point LP */
115/* 118/*
116 * MEI HW Section 119 * MEI HW Section
117 */ 120 */
diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c
index b96205aece0c..2cab3c0a6805 100644
--- a/drivers/misc/mei/pci-me.c
+++ b/drivers/misc/mei/pci-me.c
@@ -76,9 +76,11 @@ static DEFINE_PCI_DEVICE_TABLE(mei_me_pci_tbl) = {
76 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PPT_1)}, 76 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PPT_1)},
77 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PPT_2)}, 77 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PPT_2)},
78 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PPT_3)}, 78 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_PPT_3)},
79 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_LPT)}, 79 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_LPT_H)},
80 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_LPT_W)}, 80 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_LPT_W)},
81 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_LPT_LP)}, 81 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_LPT_LP)},
82 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_LPT_HR)},
83 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, MEI_DEV_ID_WPT_LP)},
82 84
83 /* required last entry */ 85 /* required last entry */
84 {0, } 86 {0, }
diff --git a/drivers/misc/mic/card/mic_virtio.c b/drivers/misc/mic/card/mic_virtio.c
index 8aa42e738acc..653799b96bfa 100644
--- a/drivers/misc/mic/card/mic_virtio.c
+++ b/drivers/misc/mic/card/mic_virtio.c
@@ -154,14 +154,14 @@ static void mic_reset_inform_host(struct virtio_device *vdev)
154{ 154{
155 struct mic_vdev *mvdev = to_micvdev(vdev); 155 struct mic_vdev *mvdev = to_micvdev(vdev);
156 struct mic_device_ctrl __iomem *dc = mvdev->dc; 156 struct mic_device_ctrl __iomem *dc = mvdev->dc;
157 int retry = 100, i; 157 int retry;
158 158
159 iowrite8(0, &dc->host_ack); 159 iowrite8(0, &dc->host_ack);
160 iowrite8(1, &dc->vdev_reset); 160 iowrite8(1, &dc->vdev_reset);
161 mic_send_intr(mvdev->mdev, mvdev->c2h_vdev_db); 161 mic_send_intr(mvdev->mdev, mvdev->c2h_vdev_db);
162 162
163 /* Wait till host completes all card accesses and acks the reset */ 163 /* Wait till host completes all card accesses and acks the reset */
164 for (i = retry; i--;) { 164 for (retry = 100; retry--;) {
165 if (ioread8(&dc->host_ack)) 165 if (ioread8(&dc->host_ack))
166 break; 166 break;
167 msleep(100); 167 msleep(100);
@@ -187,11 +187,12 @@ static void mic_reset(struct virtio_device *vdev)
187/* 187/*
188 * The virtio_ring code calls this API when it wants to notify the Host. 188 * The virtio_ring code calls this API when it wants to notify the Host.
189 */ 189 */
190static void mic_notify(struct virtqueue *vq) 190static bool mic_notify(struct virtqueue *vq)
191{ 191{
192 struct mic_vdev *mvdev = vq->priv; 192 struct mic_vdev *mvdev = vq->priv;
193 193
194 mic_send_intr(mvdev->mdev, mvdev->c2h_vdev_db); 194 mic_send_intr(mvdev->mdev, mvdev->c2h_vdev_db);
195 return true;
195} 196}
196 197
197static void mic_del_vq(struct virtqueue *vq, int n) 198static void mic_del_vq(struct virtqueue *vq, int n)
@@ -247,17 +248,17 @@ static struct virtqueue *mic_find_vq(struct virtio_device *vdev,
247 /* First assign the vring's allocated in host memory */ 248 /* First assign the vring's allocated in host memory */
248 vqconfig = mic_vq_config(mvdev->desc) + index; 249 vqconfig = mic_vq_config(mvdev->desc) + index;
249 memcpy_fromio(&config, vqconfig, sizeof(config)); 250 memcpy_fromio(&config, vqconfig, sizeof(config));
250 _vr_size = vring_size(config.num, MIC_VIRTIO_RING_ALIGN); 251 _vr_size = vring_size(le16_to_cpu(config.num), MIC_VIRTIO_RING_ALIGN);
251 vr_size = PAGE_ALIGN(_vr_size + sizeof(struct _mic_vring_info)); 252 vr_size = PAGE_ALIGN(_vr_size + sizeof(struct _mic_vring_info));
252 va = mic_card_map(mvdev->mdev, config.address, vr_size); 253 va = mic_card_map(mvdev->mdev, le64_to_cpu(config.address), vr_size);
253 if (!va) 254 if (!va)
254 return ERR_PTR(-ENOMEM); 255 return ERR_PTR(-ENOMEM);
255 mvdev->vr[index] = va; 256 mvdev->vr[index] = va;
256 memset_io(va, 0x0, _vr_size); 257 memset_io(va, 0x0, _vr_size);
257 vq = vring_new_virtqueue(index, 258 vq = vring_new_virtqueue(index, le16_to_cpu(config.num),
258 config.num, MIC_VIRTIO_RING_ALIGN, vdev, 259 MIC_VIRTIO_RING_ALIGN, vdev, false,
259 false, 260 (void __force *)va, mic_notify, callback,
260 va, mic_notify, callback, name); 261 name);
261 if (!vq) { 262 if (!vq) {
262 err = -ENOMEM; 263 err = -ENOMEM;
263 goto unmap; 264 goto unmap;
@@ -272,7 +273,8 @@ static struct virtqueue *mic_find_vq(struct virtio_device *vdev,
272 273
273 /* Allocate and reassign used ring now */ 274 /* Allocate and reassign used ring now */
274 mvdev->used_size[index] = PAGE_ALIGN(sizeof(__u16) * 3 + 275 mvdev->used_size[index] = PAGE_ALIGN(sizeof(__u16) * 3 +
275 sizeof(struct vring_used_elem) * config.num); 276 sizeof(struct vring_used_elem) *
277 le16_to_cpu(config.num));
276 used = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, 278 used = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
277 get_order(mvdev->used_size[index])); 279 get_order(mvdev->used_size[index]));
278 if (!used) { 280 if (!used) {
@@ -309,7 +311,7 @@ static int mic_find_vqs(struct virtio_device *vdev, unsigned nvqs,
309{ 311{
310 struct mic_vdev *mvdev = to_micvdev(vdev); 312 struct mic_vdev *mvdev = to_micvdev(vdev);
311 struct mic_device_ctrl __iomem *dc = mvdev->dc; 313 struct mic_device_ctrl __iomem *dc = mvdev->dc;
312 int i, err, retry = 100; 314 int i, err, retry;
313 315
314 /* We must have this many virtqueues. */ 316 /* We must have this many virtqueues. */
315 if (nvqs > ioread8(&mvdev->desc->num_vq)) 317 if (nvqs > ioread8(&mvdev->desc->num_vq))
@@ -331,7 +333,7 @@ static int mic_find_vqs(struct virtio_device *vdev, unsigned nvqs,
331 * rings have been re-assigned. 333 * rings have been re-assigned.
332 */ 334 */
333 mic_send_intr(mvdev->mdev, mvdev->c2h_vdev_db); 335 mic_send_intr(mvdev->mdev, mvdev->c2h_vdev_db);
334 for (i = retry; i--;) { 336 for (retry = 100; retry--;) {
335 if (!ioread8(&dc->used_address_updated)) 337 if (!ioread8(&dc->used_address_updated))
336 break; 338 break;
337 msleep(100); 339 msleep(100);
@@ -519,8 +521,8 @@ static void mic_scan_devices(struct mic_driver *mdrv, bool remove)
519 struct device *dev; 521 struct device *dev;
520 int ret; 522 int ret;
521 523
522 for (i = mic_aligned_size(struct mic_bootparam); 524 for (i = sizeof(struct mic_bootparam); i < MIC_DP_SIZE;
523 i < MIC_DP_SIZE; i += mic_total_desc_size(d)) { 525 i += mic_total_desc_size(d)) {
524 d = mdrv->dp + i; 526 d = mdrv->dp + i;
525 dc = (void __iomem *)d + mic_aligned_desc_size(d); 527 dc = (void __iomem *)d + mic_aligned_desc_size(d);
526 /* 528 /*
@@ -539,7 +541,8 @@ static void mic_scan_devices(struct mic_driver *mdrv, bool remove)
539 continue; 541 continue;
540 542
541 /* device already exists */ 543 /* device already exists */
542 dev = device_find_child(mdrv->dev, d, mic_match_desc); 544 dev = device_find_child(mdrv->dev, (void __force *)d,
545 mic_match_desc);
543 if (dev) { 546 if (dev) {
544 if (remove) 547 if (remove)
545 iowrite8(MIC_VIRTIO_PARAM_DEV_REMOVE, 548 iowrite8(MIC_VIRTIO_PARAM_DEV_REMOVE,
diff --git a/drivers/misc/mic/card/mic_virtio.h b/drivers/misc/mic/card/mic_virtio.h
index 2c5c22c93ba8..d0407ba53bb7 100644
--- a/drivers/misc/mic/card/mic_virtio.h
+++ b/drivers/misc/mic/card/mic_virtio.h
@@ -42,8 +42,8 @@
42 42
43static inline unsigned mic_desc_size(struct mic_device_desc __iomem *desc) 43static inline unsigned mic_desc_size(struct mic_device_desc __iomem *desc)
44{ 44{
45 return mic_aligned_size(*desc) 45 return sizeof(*desc)
46 + ioread8(&desc->num_vq) * mic_aligned_size(struct mic_vqconfig) 46 + ioread8(&desc->num_vq) * sizeof(struct mic_vqconfig)
47 + ioread8(&desc->feature_len) * 2 47 + ioread8(&desc->feature_len) * 2
48 + ioread8(&desc->config_len); 48 + ioread8(&desc->config_len);
49} 49}
@@ -67,8 +67,7 @@ mic_vq_configspace(struct mic_device_desc __iomem *desc)
67} 67}
68static inline unsigned mic_total_desc_size(struct mic_device_desc __iomem *desc) 68static inline unsigned mic_total_desc_size(struct mic_device_desc __iomem *desc)
69{ 69{
70 return mic_aligned_desc_size(desc) + 70 return mic_aligned_desc_size(desc) + sizeof(struct mic_device_ctrl);
71 mic_aligned_size(struct mic_device_ctrl);
72} 71}
73 72
74int mic_devices_init(struct mic_driver *mdrv); 73int mic_devices_init(struct mic_driver *mdrv);
diff --git a/drivers/misc/mic/host/mic_boot.c b/drivers/misc/mic/host/mic_boot.c
index 7558d9186438..b75c6b5cc20f 100644
--- a/drivers/misc/mic/host/mic_boot.c
+++ b/drivers/misc/mic/host/mic_boot.c
@@ -62,7 +62,7 @@ void mic_bootparam_init(struct mic_device *mdev)
62{ 62{
63 struct mic_bootparam *bootparam = mdev->dp; 63 struct mic_bootparam *bootparam = mdev->dp;
64 64
65 bootparam->magic = MIC_MAGIC; 65 bootparam->magic = cpu_to_le32(MIC_MAGIC);
66 bootparam->c2h_shutdown_db = mdev->shutdown_db; 66 bootparam->c2h_shutdown_db = mdev->shutdown_db;
67 bootparam->h2c_shutdown_db = -1; 67 bootparam->h2c_shutdown_db = -1;
68 bootparam->h2c_config_db = -1; 68 bootparam->h2c_config_db = -1;
diff --git a/drivers/misc/mic/host/mic_virtio.c b/drivers/misc/mic/host/mic_virtio.c
index 5b8494bd1e00..e04bb4fe6823 100644
--- a/drivers/misc/mic/host/mic_virtio.c
+++ b/drivers/misc/mic/host/mic_virtio.c
@@ -41,7 +41,7 @@ static int mic_virtio_copy_to_user(struct mic_vdev *mvdev,
41 * We are copying from IO below an should ideally use something 41 * We are copying from IO below an should ideally use something
42 * like copy_to_user_fromio(..) if it existed. 42 * like copy_to_user_fromio(..) if it existed.
43 */ 43 */
44 if (copy_to_user(ubuf, dbuf, len)) { 44 if (copy_to_user(ubuf, (void __force *)dbuf, len)) {
45 err = -EFAULT; 45 err = -EFAULT;
46 dev_err(mic_dev(mvdev), "%s %d err %d\n", 46 dev_err(mic_dev(mvdev), "%s %d err %d\n",
47 __func__, __LINE__, err); 47 __func__, __LINE__, err);
@@ -66,7 +66,7 @@ static int mic_virtio_copy_from_user(struct mic_vdev *mvdev,
66 * We are copying to IO below and should ideally use something 66 * We are copying to IO below and should ideally use something
67 * like copy_from_user_toio(..) if it existed. 67 * like copy_from_user_toio(..) if it existed.
68 */ 68 */
69 if (copy_from_user(dbuf, ubuf, len)) { 69 if (copy_from_user((void __force *)dbuf, ubuf, len)) {
70 err = -EFAULT; 70 err = -EFAULT;
71 dev_err(mic_dev(mvdev), "%s %d err %d\n", 71 dev_err(mic_dev(mvdev), "%s %d err %d\n",
72 __func__, __LINE__, err); 72 __func__, __LINE__, err);
@@ -293,7 +293,7 @@ static void mic_virtio_init_post(struct mic_vdev *mvdev)
293 continue; 293 continue;
294 } 294 }
295 mvdev->mvr[i].vrh.vring.used = 295 mvdev->mvr[i].vrh.vring.used =
296 mvdev->mdev->aper.va + 296 (void __force *)mvdev->mdev->aper.va +
297 le64_to_cpu(vqconfig[i].used_address); 297 le64_to_cpu(vqconfig[i].used_address);
298 } 298 }
299 299
@@ -378,7 +378,7 @@ int mic_virtio_config_change(struct mic_vdev *mvdev,
378 void __user *argp) 378 void __user *argp)
379{ 379{
380 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wake); 380 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wake);
381 int ret = 0, retry = 100, i; 381 int ret = 0, retry, i;
382 struct mic_bootparam *bootparam = mvdev->mdev->dp; 382 struct mic_bootparam *bootparam = mvdev->mdev->dp;
383 s8 db = bootparam->h2c_config_db; 383 s8 db = bootparam->h2c_config_db;
384 384
@@ -401,7 +401,7 @@ int mic_virtio_config_change(struct mic_vdev *mvdev,
401 mvdev->dc->config_change = MIC_VIRTIO_PARAM_CONFIG_CHANGED; 401 mvdev->dc->config_change = MIC_VIRTIO_PARAM_CONFIG_CHANGED;
402 mvdev->mdev->ops->send_intr(mvdev->mdev, db); 402 mvdev->mdev->ops->send_intr(mvdev->mdev, db);
403 403
404 for (i = retry; i--;) { 404 for (retry = 100; retry--;) {
405 ret = wait_event_timeout(wake, 405 ret = wait_event_timeout(wake,
406 mvdev->dc->guest_ack, msecs_to_jiffies(100)); 406 mvdev->dc->guest_ack, msecs_to_jiffies(100));
407 if (ret) 407 if (ret)
@@ -467,7 +467,7 @@ static int mic_copy_dp_entry(struct mic_vdev *mvdev,
467 } 467 }
468 468
469 /* Find the first free device page entry */ 469 /* Find the first free device page entry */
470 for (i = mic_aligned_size(struct mic_bootparam); 470 for (i = sizeof(struct mic_bootparam);
471 i < MIC_DP_SIZE - mic_total_desc_size(dd_config); 471 i < MIC_DP_SIZE - mic_total_desc_size(dd_config);
472 i += mic_total_desc_size(devp)) { 472 i += mic_total_desc_size(devp)) {
473 devp = mdev->dp + i; 473 devp = mdev->dp + i;
@@ -525,6 +525,7 @@ int mic_virtio_add_device(struct mic_vdev *mvdev,
525 char irqname[10]; 525 char irqname[10];
526 struct mic_bootparam *bootparam = mdev->dp; 526 struct mic_bootparam *bootparam = mdev->dp;
527 u16 num; 527 u16 num;
528 dma_addr_t vr_addr;
528 529
529 mutex_lock(&mdev->mic_mutex); 530 mutex_lock(&mdev->mic_mutex);
530 531
@@ -559,17 +560,16 @@ int mic_virtio_add_device(struct mic_vdev *mvdev,
559 } 560 }
560 vr->len = vr_size; 561 vr->len = vr_size;
561 vr->info = vr->va + vring_size(num, MIC_VIRTIO_RING_ALIGN); 562 vr->info = vr->va + vring_size(num, MIC_VIRTIO_RING_ALIGN);
562 vr->info->magic = MIC_MAGIC + mvdev->virtio_id + i; 563 vr->info->magic = cpu_to_le32(MIC_MAGIC + mvdev->virtio_id + i);
563 vqconfig[i].address = mic_map_single(mdev, 564 vr_addr = mic_map_single(mdev, vr->va, vr_size);
564 vr->va, vr_size); 565 if (mic_map_error(vr_addr)) {
565 if (mic_map_error(vqconfig[i].address)) {
566 free_pages((unsigned long)vr->va, get_order(vr_size)); 566 free_pages((unsigned long)vr->va, get_order(vr_size));
567 ret = -ENOMEM; 567 ret = -ENOMEM;
568 dev_err(mic_dev(mvdev), "%s %d err %d\n", 568 dev_err(mic_dev(mvdev), "%s %d err %d\n",
569 __func__, __LINE__, ret); 569 __func__, __LINE__, ret);
570 goto err; 570 goto err;
571 } 571 }
572 vqconfig[i].address = cpu_to_le64(vqconfig[i].address); 572 vqconfig[i].address = cpu_to_le64(vr_addr);
573 573
574 vring_init(&vr->vr, num, vr->va, MIC_VIRTIO_RING_ALIGN); 574 vring_init(&vr->vr, num, vr->va, MIC_VIRTIO_RING_ALIGN);
575 ret = vringh_init_kern(&mvr->vrh, 575 ret = vringh_init_kern(&mvr->vrh,
@@ -639,7 +639,7 @@ void mic_virtio_del_device(struct mic_vdev *mvdev)
639 struct mic_vdev *tmp_mvdev; 639 struct mic_vdev *tmp_mvdev;
640 struct mic_device *mdev = mvdev->mdev; 640 struct mic_device *mdev = mvdev->mdev;
641 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wake); 641 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wake);
642 int i, ret, retry = 100; 642 int i, ret, retry;
643 struct mic_vqconfig *vqconfig; 643 struct mic_vqconfig *vqconfig;
644 struct mic_bootparam *bootparam = mdev->dp; 644 struct mic_bootparam *bootparam = mdev->dp;
645 s8 db; 645 s8 db;
@@ -652,16 +652,16 @@ void mic_virtio_del_device(struct mic_vdev *mvdev)
652 "Requesting hot remove id %d\n", mvdev->virtio_id); 652 "Requesting hot remove id %d\n", mvdev->virtio_id);
653 mvdev->dc->config_change = MIC_VIRTIO_PARAM_DEV_REMOVE; 653 mvdev->dc->config_change = MIC_VIRTIO_PARAM_DEV_REMOVE;
654 mdev->ops->send_intr(mdev, db); 654 mdev->ops->send_intr(mdev, db);
655 for (i = retry; i--;) { 655 for (retry = 100; retry--;) {
656 ret = wait_event_timeout(wake, 656 ret = wait_event_timeout(wake,
657 mvdev->dc->guest_ack, msecs_to_jiffies(100)); 657 mvdev->dc->guest_ack, msecs_to_jiffies(100));
658 if (ret) 658 if (ret)
659 break; 659 break;
660 } 660 }
661 dev_dbg(mdev->sdev->parent, 661 dev_dbg(mdev->sdev->parent,
662 "Device id %d config_change %d guest_ack %d\n", 662 "Device id %d config_change %d guest_ack %d retry %d\n",
663 mvdev->virtio_id, mvdev->dc->config_change, 663 mvdev->virtio_id, mvdev->dc->config_change,
664 mvdev->dc->guest_ack); 664 mvdev->dc->guest_ack, retry);
665 mvdev->dc->config_change = 0; 665 mvdev->dc->config_change = 0;
666 mvdev->dc->guest_ack = 0; 666 mvdev->dc->guest_ack = 0;
667skip_hot_remove: 667skip_hot_remove:
diff --git a/drivers/misc/mic/host/mic_x100.c b/drivers/misc/mic/host/mic_x100.c
index 81e9541b784c..0dfa8a81436e 100644
--- a/drivers/misc/mic/host/mic_x100.c
+++ b/drivers/misc/mic/host/mic_x100.c
@@ -397,8 +397,8 @@ mic_x100_load_ramdisk(struct mic_device *mdev)
397 * so copy over the ramdisk @ 128M. 397 * so copy over the ramdisk @ 128M.
398 */ 398 */
399 memcpy_toio(mdev->aper.va + (mdev->bootaddr << 1), fw->data, fw->size); 399 memcpy_toio(mdev->aper.va + (mdev->bootaddr << 1), fw->data, fw->size);
400 iowrite32(cpu_to_le32(mdev->bootaddr << 1), &bp->hdr.ramdisk_image); 400 iowrite32(mdev->bootaddr << 1, &bp->hdr.ramdisk_image);
401 iowrite32(cpu_to_le32(fw->size), &bp->hdr.ramdisk_size); 401 iowrite32(fw->size, &bp->hdr.ramdisk_size);
402 release_firmware(fw); 402 release_firmware(fw);
403error: 403error:
404 return rc; 404 return rc;
diff --git a/drivers/mtd/nand/pxa3xx_nand.c b/drivers/mtd/nand/pxa3xx_nand.c
index 4cabdc9fda90..4b3aaa898a8b 100644
--- a/drivers/mtd/nand/pxa3xx_nand.c
+++ b/drivers/mtd/nand/pxa3xx_nand.c
@@ -962,7 +962,7 @@ static int pxa3xx_nand_init_buff(struct pxa3xx_nand_info *info)
962static void pxa3xx_nand_free_buff(struct pxa3xx_nand_info *info) 962static void pxa3xx_nand_free_buff(struct pxa3xx_nand_info *info)
963{ 963{
964 struct platform_device *pdev = info->pdev; 964 struct platform_device *pdev = info->pdev;
965 if (use_dma) { 965 if (info->use_dma) {
966 pxa_free_dma(info->data_dma_ch); 966 pxa_free_dma(info->data_dma_ch);
967 dma_free_coherent(&pdev->dev, info->buf_size, 967 dma_free_coherent(&pdev->dev, info->buf_size,
968 info->data_buff, info->data_buff_phys); 968 info->data_buff, info->data_buff_phys);
@@ -1259,10 +1259,6 @@ static struct of_device_id pxa3xx_nand_dt_ids[] = {
1259 .compatible = "marvell,pxa3xx-nand", 1259 .compatible = "marvell,pxa3xx-nand",
1260 .data = (void *)PXA3XX_NAND_VARIANT_PXA, 1260 .data = (void *)PXA3XX_NAND_VARIANT_PXA,
1261 }, 1261 },
1262 {
1263 .compatible = "marvell,armada370-nand",
1264 .data = (void *)PXA3XX_NAND_VARIANT_ARMADA370,
1265 },
1266 {} 1262 {}
1267}; 1263};
1268MODULE_DEVICE_TABLE(of, pxa3xx_nand_dt_ids); 1264MODULE_DEVICE_TABLE(of, pxa3xx_nand_dt_ids);
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 36eab0c4fb33..398e299ee1bd 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -4199,9 +4199,9 @@ static int bond_check_params(struct bond_params *params)
4199 (arp_ip_count < BOND_MAX_ARP_TARGETS) && arp_ip_target[i]; i++) { 4199 (arp_ip_count < BOND_MAX_ARP_TARGETS) && arp_ip_target[i]; i++) {
4200 /* not complete check, but should be good enough to 4200 /* not complete check, but should be good enough to
4201 catch mistakes */ 4201 catch mistakes */
4202 __be32 ip = in_aton(arp_ip_target[i]); 4202 __be32 ip;
4203 if (!isdigit(arp_ip_target[i][0]) || ip == 0 || 4203 if (!in4_pton(arp_ip_target[i], -1, (u8 *)&ip, -1, NULL) ||
4204 ip == htonl(INADDR_BROADCAST)) { 4204 IS_IP_TARGET_UNUSABLE_ADDRESS(ip)) {
4205 pr_warning("Warning: bad arp_ip_target module parameter (%s), ARP monitoring will not be performed\n", 4205 pr_warning("Warning: bad arp_ip_target module parameter (%s), ARP monitoring will not be performed\n",
4206 arp_ip_target[i]); 4206 arp_ip_target[i]);
4207 arp_interval = 0; 4207 arp_interval = 0;
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index abf5e106edc5..0ae580bbc5db 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -1635,12 +1635,12 @@ static ssize_t bonding_show_packets_per_slave(struct device *d,
1635 char *buf) 1635 char *buf)
1636{ 1636{
1637 struct bonding *bond = to_bond(d); 1637 struct bonding *bond = to_bond(d);
1638 int packets_per_slave = bond->params.packets_per_slave; 1638 unsigned int packets_per_slave = bond->params.packets_per_slave;
1639 1639
1640 if (packets_per_slave > 1) 1640 if (packets_per_slave > 1)
1641 packets_per_slave = reciprocal_value(packets_per_slave); 1641 packets_per_slave = reciprocal_value(packets_per_slave);
1642 1642
1643 return sprintf(buf, "%d\n", packets_per_slave); 1643 return sprintf(buf, "%u\n", packets_per_slave);
1644} 1644}
1645 1645
1646static ssize_t bonding_store_packets_per_slave(struct device *d, 1646static ssize_t bonding_store_packets_per_slave(struct device *d,
diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c
index 50b853a79d77..46dfb1378c17 100644
--- a/drivers/net/ethernet/allwinner/sun4i-emac.c
+++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
@@ -717,8 +717,7 @@ static int emac_open(struct net_device *dev)
717 if (netif_msg_ifup(db)) 717 if (netif_msg_ifup(db))
718 dev_dbg(db->dev, "enabling %s\n", dev->name); 718 dev_dbg(db->dev, "enabling %s\n", dev->name);
719 719
720 if (devm_request_irq(db->dev, dev->irq, &emac_interrupt, 720 if (request_irq(dev->irq, &emac_interrupt, 0, dev->name, dev))
721 0, dev->name, dev))
722 return -EAGAIN; 721 return -EAGAIN;
723 722
724 /* Initialize EMAC board */ 723 /* Initialize EMAC board */
@@ -774,6 +773,8 @@ static int emac_stop(struct net_device *ndev)
774 773
775 emac_shutdown(ndev); 774 emac_shutdown(ndev);
776 775
776 free_irq(ndev->irq, ndev);
777
777 return 0; 778 return 0;
778} 779}
779 780
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
index 0216d592d0ce..2e46c28fc601 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
@@ -3114,6 +3114,11 @@ int bnx2x_sriov_configure(struct pci_dev *dev, int num_vfs_param)
3114{ 3114{
3115 struct bnx2x *bp = netdev_priv(pci_get_drvdata(dev)); 3115 struct bnx2x *bp = netdev_priv(pci_get_drvdata(dev));
3116 3116
3117 if (!IS_SRIOV(bp)) {
3118 BNX2X_ERR("failed to configure SR-IOV since vfdb was not allocated. Check dmesg for errors in probe stage\n");
3119 return -EINVAL;
3120 }
3121
3117 DP(BNX2X_MSG_IOV, "bnx2x_sriov_configure called with %d, BNX2X_NR_VIRTFN(bp) was %d\n", 3122 DP(BNX2X_MSG_IOV, "bnx2x_sriov_configure called with %d, BNX2X_NR_VIRTFN(bp) was %d\n",
3118 num_vfs_param, BNX2X_NR_VIRTFN(bp)); 3123 num_vfs_param, BNX2X_NR_VIRTFN(bp));
3119 3124
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index 369b736dde05..f3dd93b4aeaa 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -8932,6 +8932,9 @@ static int tg3_chip_reset(struct tg3 *tp)
8932 void (*write_op)(struct tg3 *, u32, u32); 8932 void (*write_op)(struct tg3 *, u32, u32);
8933 int i, err; 8933 int i, err;
8934 8934
8935 if (!pci_device_is_present(tp->pdev))
8936 return -ENODEV;
8937
8935 tg3_nvram_lock(tp); 8938 tg3_nvram_lock(tp);
8936 8939
8937 tg3_ape_lock(tp, TG3_APE_LOCK_GRC); 8940 tg3_ape_lock(tp, TG3_APE_LOCK_GRC);
@@ -11581,10 +11584,11 @@ static int tg3_close(struct net_device *dev)
11581 memset(&tp->net_stats_prev, 0, sizeof(tp->net_stats_prev)); 11584 memset(&tp->net_stats_prev, 0, sizeof(tp->net_stats_prev));
11582 memset(&tp->estats_prev, 0, sizeof(tp->estats_prev)); 11585 memset(&tp->estats_prev, 0, sizeof(tp->estats_prev));
11583 11586
11584 tg3_power_down_prepare(tp); 11587 if (pci_device_is_present(tp->pdev)) {
11585 11588 tg3_power_down_prepare(tp);
11586 tg3_carrier_off(tp);
11587 11589
11590 tg3_carrier_off(tp);
11591 }
11588 return 0; 11592 return 0;
11589} 11593}
11590 11594
@@ -16499,6 +16503,9 @@ static int tg3_get_invariants(struct tg3 *tp, const struct pci_device_id *ent)
16499 /* Clear this out for sanity. */ 16503 /* Clear this out for sanity. */
16500 tw32(TG3PCI_MEM_WIN_BASE_ADDR, 0); 16504 tw32(TG3PCI_MEM_WIN_BASE_ADDR, 0);
16501 16505
16506 /* Clear TG3PCI_REG_BASE_ADDR to prevent hangs. */
16507 tw32(TG3PCI_REG_BASE_ADDR, 0);
16508
16502 pci_read_config_dword(tp->pdev, TG3PCI_PCISTATE, 16509 pci_read_config_dword(tp->pdev, TG3PCI_PCISTATE,
16503 &pci_state_reg); 16510 &pci_state_reg);
16504 if ((pci_state_reg & PCISTATE_CONV_PCI_MODE) == 0 && 16511 if ((pci_state_reg & PCISTATE_CONV_PCI_MODE) == 0 &&
@@ -17726,10 +17733,12 @@ static int tg3_suspend(struct device *device)
17726 struct pci_dev *pdev = to_pci_dev(device); 17733 struct pci_dev *pdev = to_pci_dev(device);
17727 struct net_device *dev = pci_get_drvdata(pdev); 17734 struct net_device *dev = pci_get_drvdata(pdev);
17728 struct tg3 *tp = netdev_priv(dev); 17735 struct tg3 *tp = netdev_priv(dev);
17729 int err; 17736 int err = 0;
17737
17738 rtnl_lock();
17730 17739
17731 if (!netif_running(dev)) 17740 if (!netif_running(dev))
17732 return 0; 17741 goto unlock;
17733 17742
17734 tg3_reset_task_cancel(tp); 17743 tg3_reset_task_cancel(tp);
17735 tg3_phy_stop(tp); 17744 tg3_phy_stop(tp);
@@ -17771,6 +17780,8 @@ out:
17771 tg3_phy_start(tp); 17780 tg3_phy_start(tp);
17772 } 17781 }
17773 17782
17783unlock:
17784 rtnl_unlock();
17774 return err; 17785 return err;
17775} 17786}
17776 17787
@@ -17779,10 +17790,12 @@ static int tg3_resume(struct device *device)
17779 struct pci_dev *pdev = to_pci_dev(device); 17790 struct pci_dev *pdev = to_pci_dev(device);
17780 struct net_device *dev = pci_get_drvdata(pdev); 17791 struct net_device *dev = pci_get_drvdata(pdev);
17781 struct tg3 *tp = netdev_priv(dev); 17792 struct tg3 *tp = netdev_priv(dev);
17782 int err; 17793 int err = 0;
17794
17795 rtnl_lock();
17783 17796
17784 if (!netif_running(dev)) 17797 if (!netif_running(dev))
17785 return 0; 17798 goto unlock;
17786 17799
17787 netif_device_attach(dev); 17800 netif_device_attach(dev);
17788 17801
@@ -17806,6 +17819,8 @@ out:
17806 if (!err) 17819 if (!err)
17807 tg3_phy_start(tp); 17820 tg3_phy_start(tp);
17808 17821
17822unlock:
17823 rtnl_unlock();
17809 return err; 17824 return err;
17810} 17825}
17811#endif /* CONFIG_PM_SLEEP */ 17826#endif /* CONFIG_PM_SLEEP */
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index ecd2fb3ef695..6c9308850453 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -49,13 +49,15 @@
49#include <asm/io.h> 49#include <asm/io.h>
50#include "cxgb4_uld.h" 50#include "cxgb4_uld.h"
51 51
52#define FW_VERSION_MAJOR 1 52#define T4FW_VERSION_MAJOR 0x01
53#define FW_VERSION_MINOR 4 53#define T4FW_VERSION_MINOR 0x06
54#define FW_VERSION_MICRO 0 54#define T4FW_VERSION_MICRO 0x18
55#define T4FW_VERSION_BUILD 0x00
55 56
56#define FW_VERSION_MAJOR_T5 0 57#define T5FW_VERSION_MAJOR 0x01
57#define FW_VERSION_MINOR_T5 0 58#define T5FW_VERSION_MINOR 0x08
58#define FW_VERSION_MICRO_T5 0 59#define T5FW_VERSION_MICRO 0x1C
60#define T5FW_VERSION_BUILD 0x00
59 61
60#define CH_WARN(adap, fmt, ...) dev_warn(adap->pdev_dev, fmt, ## __VA_ARGS__) 62#define CH_WARN(adap, fmt, ...) dev_warn(adap->pdev_dev, fmt, ## __VA_ARGS__)
61 63
@@ -240,6 +242,26 @@ struct pci_params {
240 unsigned char width; 242 unsigned char width;
241}; 243};
242 244
245#define CHELSIO_CHIP_CODE(version, revision) (((version) << 4) | (revision))
246#define CHELSIO_CHIP_FPGA 0x100
247#define CHELSIO_CHIP_VERSION(code) (((code) >> 4) & 0xf)
248#define CHELSIO_CHIP_RELEASE(code) ((code) & 0xf)
249
250#define CHELSIO_T4 0x4
251#define CHELSIO_T5 0x5
252
253enum chip_type {
254 T4_A1 = CHELSIO_CHIP_CODE(CHELSIO_T4, 1),
255 T4_A2 = CHELSIO_CHIP_CODE(CHELSIO_T4, 2),
256 T4_FIRST_REV = T4_A1,
257 T4_LAST_REV = T4_A2,
258
259 T5_A0 = CHELSIO_CHIP_CODE(CHELSIO_T5, 0),
260 T5_A1 = CHELSIO_CHIP_CODE(CHELSIO_T5, 1),
261 T5_FIRST_REV = T5_A0,
262 T5_LAST_REV = T5_A1,
263};
264
243struct adapter_params { 265struct adapter_params {
244 struct tp_params tp; 266 struct tp_params tp;
245 struct vpd_params vpd; 267 struct vpd_params vpd;
@@ -259,7 +281,7 @@ struct adapter_params {
259 281
260 unsigned char nports; /* # of ethernet ports */ 282 unsigned char nports; /* # of ethernet ports */
261 unsigned char portvec; 283 unsigned char portvec;
262 unsigned char rev; /* chip revision */ 284 enum chip_type chip; /* chip code */
263 unsigned char offload; 285 unsigned char offload;
264 286
265 unsigned char bypass; 287 unsigned char bypass;
@@ -267,6 +289,23 @@ struct adapter_params {
267 unsigned int ofldq_wr_cred; 289 unsigned int ofldq_wr_cred;
268}; 290};
269 291
292#include "t4fw_api.h"
293
294#define FW_VERSION(chip) ( \
295 FW_HDR_FW_VER_MAJOR_GET(chip##FW_VERSION_MAJOR) | \
296 FW_HDR_FW_VER_MINOR_GET(chip##FW_VERSION_MINOR) | \
297 FW_HDR_FW_VER_MICRO_GET(chip##FW_VERSION_MICRO) | \
298 FW_HDR_FW_VER_BUILD_GET(chip##FW_VERSION_BUILD))
299#define FW_INTFVER(chip, intf) (FW_HDR_INTFVER_##intf)
300
301struct fw_info {
302 u8 chip;
303 char *fs_name;
304 char *fw_mod_name;
305 struct fw_hdr fw_hdr;
306};
307
308
270struct trace_params { 309struct trace_params {
271 u32 data[TRACE_LEN / 4]; 310 u32 data[TRACE_LEN / 4];
272 u32 mask[TRACE_LEN / 4]; 311 u32 mask[TRACE_LEN / 4];
@@ -512,25 +551,6 @@ struct sge {
512 551
513struct l2t_data; 552struct l2t_data;
514 553
515#define CHELSIO_CHIP_CODE(version, revision) (((version) << 4) | (revision))
516#define CHELSIO_CHIP_VERSION(code) ((code) >> 4)
517#define CHELSIO_CHIP_RELEASE(code) ((code) & 0xf)
518
519#define CHELSIO_T4 0x4
520#define CHELSIO_T5 0x5
521
522enum chip_type {
523 T4_A1 = CHELSIO_CHIP_CODE(CHELSIO_T4, 0),
524 T4_A2 = CHELSIO_CHIP_CODE(CHELSIO_T4, 1),
525 T4_A3 = CHELSIO_CHIP_CODE(CHELSIO_T4, 2),
526 T4_FIRST_REV = T4_A1,
527 T4_LAST_REV = T4_A3,
528
529 T5_A1 = CHELSIO_CHIP_CODE(CHELSIO_T5, 0),
530 T5_FIRST_REV = T5_A1,
531 T5_LAST_REV = T5_A1,
532};
533
534#ifdef CONFIG_PCI_IOV 554#ifdef CONFIG_PCI_IOV
535 555
536/* T4 supports SRIOV on PF0-3 and T5 on PF0-7. However, the Serial 556/* T4 supports SRIOV on PF0-3 and T5 on PF0-7. However, the Serial
@@ -715,12 +735,12 @@ enum {
715 735
716static inline int is_t5(enum chip_type chip) 736static inline int is_t5(enum chip_type chip)
717{ 737{
718 return (chip >= T5_FIRST_REV && chip <= T5_LAST_REV); 738 return CHELSIO_CHIP_VERSION(chip) == CHELSIO_T5;
719} 739}
720 740
721static inline int is_t4(enum chip_type chip) 741static inline int is_t4(enum chip_type chip)
722{ 742{
723 return (chip >= T4_FIRST_REV && chip <= T4_LAST_REV); 743 return CHELSIO_CHIP_VERSION(chip) == CHELSIO_T4;
724} 744}
725 745
726static inline u32 t4_read_reg(struct adapter *adap, u32 reg_addr) 746static inline u32 t4_read_reg(struct adapter *adap, u32 reg_addr)
@@ -900,7 +920,11 @@ int get_vpd_params(struct adapter *adapter, struct vpd_params *p);
900int t4_load_fw(struct adapter *adapter, const u8 *fw_data, unsigned int size); 920int t4_load_fw(struct adapter *adapter, const u8 *fw_data, unsigned int size);
901unsigned int t4_flash_cfg_addr(struct adapter *adapter); 921unsigned int t4_flash_cfg_addr(struct adapter *adapter);
902int t4_load_cfg(struct adapter *adapter, const u8 *cfg_data, unsigned int size); 922int t4_load_cfg(struct adapter *adapter, const u8 *cfg_data, unsigned int size);
903int t4_check_fw_version(struct adapter *adapter); 923int t4_get_fw_version(struct adapter *adapter, u32 *vers);
924int t4_get_tp_version(struct adapter *adapter, u32 *vers);
925int t4_prep_fw(struct adapter *adap, struct fw_info *fw_info,
926 const u8 *fw_data, unsigned int fw_size,
927 struct fw_hdr *card_fw, enum dev_state state, int *reset);
904int t4_prep_adapter(struct adapter *adapter); 928int t4_prep_adapter(struct adapter *adapter);
905int t4_port_init(struct adapter *adap, int mbox, int pf, int vf); 929int t4_port_init(struct adapter *adap, int mbox, int pf, int vf);
906void t4_fatal_err(struct adapter *adapter); 930void t4_fatal_err(struct adapter *adapter);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 8b929eeecd2d..d6b12e035a7d 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -276,9 +276,9 @@ static DEFINE_PCI_DEVICE_TABLE(cxgb4_pci_tbl) = {
276 { 0, } 276 { 0, }
277}; 277};
278 278
279#define FW_FNAME "cxgb4/t4fw.bin" 279#define FW4_FNAME "cxgb4/t4fw.bin"
280#define FW5_FNAME "cxgb4/t5fw.bin" 280#define FW5_FNAME "cxgb4/t5fw.bin"
281#define FW_CFNAME "cxgb4/t4-config.txt" 281#define FW4_CFNAME "cxgb4/t4-config.txt"
282#define FW5_CFNAME "cxgb4/t5-config.txt" 282#define FW5_CFNAME "cxgb4/t5-config.txt"
283 283
284MODULE_DESCRIPTION(DRV_DESC); 284MODULE_DESCRIPTION(DRV_DESC);
@@ -286,7 +286,7 @@ MODULE_AUTHOR("Chelsio Communications");
286MODULE_LICENSE("Dual BSD/GPL"); 286MODULE_LICENSE("Dual BSD/GPL");
287MODULE_VERSION(DRV_VERSION); 287MODULE_VERSION(DRV_VERSION);
288MODULE_DEVICE_TABLE(pci, cxgb4_pci_tbl); 288MODULE_DEVICE_TABLE(pci, cxgb4_pci_tbl);
289MODULE_FIRMWARE(FW_FNAME); 289MODULE_FIRMWARE(FW4_FNAME);
290MODULE_FIRMWARE(FW5_FNAME); 290MODULE_FIRMWARE(FW5_FNAME);
291 291
292/* 292/*
@@ -1071,72 +1071,6 @@ freeout: t4_free_sge_resources(adap);
1071} 1071}
1072 1072
1073/* 1073/*
1074 * Returns 0 if new FW was successfully loaded, a positive errno if a load was
1075 * started but failed, and a negative errno if flash load couldn't start.
1076 */
1077static int upgrade_fw(struct adapter *adap)
1078{
1079 int ret;
1080 u32 vers, exp_major;
1081 const struct fw_hdr *hdr;
1082 const struct firmware *fw;
1083 struct device *dev = adap->pdev_dev;
1084 char *fw_file_name;
1085
1086 switch (CHELSIO_CHIP_VERSION(adap->chip)) {
1087 case CHELSIO_T4:
1088 fw_file_name = FW_FNAME;
1089 exp_major = FW_VERSION_MAJOR;
1090 break;
1091 case CHELSIO_T5:
1092 fw_file_name = FW5_FNAME;
1093 exp_major = FW_VERSION_MAJOR_T5;
1094 break;
1095 default:
1096 dev_err(dev, "Unsupported chip type, %x\n", adap->chip);
1097 return -EINVAL;
1098 }
1099
1100 ret = request_firmware(&fw, fw_file_name, dev);
1101 if (ret < 0) {
1102 dev_err(dev, "unable to load firmware image %s, error %d\n",
1103 fw_file_name, ret);
1104 return ret;
1105 }
1106
1107 hdr = (const struct fw_hdr *)fw->data;
1108 vers = ntohl(hdr->fw_ver);
1109 if (FW_HDR_FW_VER_MAJOR_GET(vers) != exp_major) {
1110 ret = -EINVAL; /* wrong major version, won't do */
1111 goto out;
1112 }
1113
1114 /*
1115 * If the flash FW is unusable or we found something newer, load it.
1116 */
1117 if (FW_HDR_FW_VER_MAJOR_GET(adap->params.fw_vers) != exp_major ||
1118 vers > adap->params.fw_vers) {
1119 dev_info(dev, "upgrading firmware ...\n");
1120 ret = t4_fw_upgrade(adap, adap->mbox, fw->data, fw->size,
1121 /*force=*/false);
1122 if (!ret)
1123 dev_info(dev,
1124 "firmware upgraded to version %pI4 from %s\n",
1125 &hdr->fw_ver, fw_file_name);
1126 else
1127 dev_err(dev, "firmware upgrade failed! err=%d\n", -ret);
1128 } else {
1129 /*
1130 * Tell our caller that we didn't upgrade the firmware.
1131 */
1132 ret = -EINVAL;
1133 }
1134
1135out: release_firmware(fw);
1136 return ret;
1137}
1138
1139/*
1140 * Allocate a chunk of memory using kmalloc or, if that fails, vmalloc. 1074 * Allocate a chunk of memory using kmalloc or, if that fails, vmalloc.
1141 * The allocated memory is cleared. 1075 * The allocated memory is cleared.
1142 */ 1076 */
@@ -1415,7 +1349,7 @@ static int get_sset_count(struct net_device *dev, int sset)
1415static int get_regs_len(struct net_device *dev) 1349static int get_regs_len(struct net_device *dev)
1416{ 1350{
1417 struct adapter *adap = netdev2adap(dev); 1351 struct adapter *adap = netdev2adap(dev);
1418 if (is_t4(adap->chip)) 1352 if (is_t4(adap->params.chip))
1419 return T4_REGMAP_SIZE; 1353 return T4_REGMAP_SIZE;
1420 else 1354 else
1421 return T5_REGMAP_SIZE; 1355 return T5_REGMAP_SIZE;
@@ -1499,7 +1433,7 @@ static void get_stats(struct net_device *dev, struct ethtool_stats *stats,
1499 data += sizeof(struct port_stats) / sizeof(u64); 1433 data += sizeof(struct port_stats) / sizeof(u64);
1500 collect_sge_port_stats(adapter, pi, (struct queue_port_stats *)data); 1434 collect_sge_port_stats(adapter, pi, (struct queue_port_stats *)data);
1501 data += sizeof(struct queue_port_stats) / sizeof(u64); 1435 data += sizeof(struct queue_port_stats) / sizeof(u64);
1502 if (!is_t4(adapter->chip)) { 1436 if (!is_t4(adapter->params.chip)) {
1503 t4_write_reg(adapter, SGE_STAT_CFG, STATSOURCE_T5(7)); 1437 t4_write_reg(adapter, SGE_STAT_CFG, STATSOURCE_T5(7));
1504 val1 = t4_read_reg(adapter, SGE_STAT_TOTAL); 1438 val1 = t4_read_reg(adapter, SGE_STAT_TOTAL);
1505 val2 = t4_read_reg(adapter, SGE_STAT_MATCH); 1439 val2 = t4_read_reg(adapter, SGE_STAT_MATCH);
@@ -1521,8 +1455,8 @@ static void get_stats(struct net_device *dev, struct ethtool_stats *stats,
1521 */ 1455 */
1522static inline unsigned int mk_adap_vers(const struct adapter *ap) 1456static inline unsigned int mk_adap_vers(const struct adapter *ap)
1523{ 1457{
1524 return CHELSIO_CHIP_VERSION(ap->chip) | 1458 return CHELSIO_CHIP_VERSION(ap->params.chip) |
1525 (CHELSIO_CHIP_RELEASE(ap->chip) << 10) | (1 << 16); 1459 (CHELSIO_CHIP_RELEASE(ap->params.chip) << 10) | (1 << 16);
1526} 1460}
1527 1461
1528static void reg_block_dump(struct adapter *ap, void *buf, unsigned int start, 1462static void reg_block_dump(struct adapter *ap, void *buf, unsigned int start,
@@ -2189,7 +2123,7 @@ static void get_regs(struct net_device *dev, struct ethtool_regs *regs,
2189 static const unsigned int *reg_ranges; 2123 static const unsigned int *reg_ranges;
2190 int arr_size = 0, buf_size = 0; 2124 int arr_size = 0, buf_size = 0;
2191 2125
2192 if (is_t4(ap->chip)) { 2126 if (is_t4(ap->params.chip)) {
2193 reg_ranges = &t4_reg_ranges[0]; 2127 reg_ranges = &t4_reg_ranges[0];
2194 arr_size = ARRAY_SIZE(t4_reg_ranges); 2128 arr_size = ARRAY_SIZE(t4_reg_ranges);
2195 buf_size = T4_REGMAP_SIZE; 2129 buf_size = T4_REGMAP_SIZE;
@@ -2967,7 +2901,7 @@ static int setup_debugfs(struct adapter *adap)
2967 size = t4_read_reg(adap, MA_EDRAM1_BAR); 2901 size = t4_read_reg(adap, MA_EDRAM1_BAR);
2968 add_debugfs_mem(adap, "edc1", MEM_EDC1, EDRAM_SIZE_GET(size)); 2902 add_debugfs_mem(adap, "edc1", MEM_EDC1, EDRAM_SIZE_GET(size));
2969 } 2903 }
2970 if (is_t4(adap->chip)) { 2904 if (is_t4(adap->params.chip)) {
2971 size = t4_read_reg(adap, MA_EXT_MEMORY_BAR); 2905 size = t4_read_reg(adap, MA_EXT_MEMORY_BAR);
2972 if (i & EXT_MEM_ENABLE) 2906 if (i & EXT_MEM_ENABLE)
2973 add_debugfs_mem(adap, "mc", MEM_MC, 2907 add_debugfs_mem(adap, "mc", MEM_MC,
@@ -3419,7 +3353,7 @@ unsigned int cxgb4_dbfifo_count(const struct net_device *dev, int lpfifo)
3419 3353
3420 v1 = t4_read_reg(adap, A_SGE_DBFIFO_STATUS); 3354 v1 = t4_read_reg(adap, A_SGE_DBFIFO_STATUS);
3421 v2 = t4_read_reg(adap, SGE_DBFIFO_STATUS2); 3355 v2 = t4_read_reg(adap, SGE_DBFIFO_STATUS2);
3422 if (is_t4(adap->chip)) { 3356 if (is_t4(adap->params.chip)) {
3423 lp_count = G_LP_COUNT(v1); 3357 lp_count = G_LP_COUNT(v1);
3424 hp_count = G_HP_COUNT(v1); 3358 hp_count = G_HP_COUNT(v1);
3425 } else { 3359 } else {
@@ -3588,7 +3522,7 @@ static void drain_db_fifo(struct adapter *adap, int usecs)
3588 do { 3522 do {
3589 v1 = t4_read_reg(adap, A_SGE_DBFIFO_STATUS); 3523 v1 = t4_read_reg(adap, A_SGE_DBFIFO_STATUS);
3590 v2 = t4_read_reg(adap, SGE_DBFIFO_STATUS2); 3524 v2 = t4_read_reg(adap, SGE_DBFIFO_STATUS2);
3591 if (is_t4(adap->chip)) { 3525 if (is_t4(adap->params.chip)) {
3592 lp_count = G_LP_COUNT(v1); 3526 lp_count = G_LP_COUNT(v1);
3593 hp_count = G_HP_COUNT(v1); 3527 hp_count = G_HP_COUNT(v1);
3594 } else { 3528 } else {
@@ -3708,7 +3642,7 @@ static void process_db_drop(struct work_struct *work)
3708 3642
3709 adap = container_of(work, struct adapter, db_drop_task); 3643 adap = container_of(work, struct adapter, db_drop_task);
3710 3644
3711 if (is_t4(adap->chip)) { 3645 if (is_t4(adap->params.chip)) {
3712 disable_dbs(adap); 3646 disable_dbs(adap);
3713 notify_rdma_uld(adap, CXGB4_CONTROL_DB_DROP); 3647 notify_rdma_uld(adap, CXGB4_CONTROL_DB_DROP);
3714 drain_db_fifo(adap, 1); 3648 drain_db_fifo(adap, 1);
@@ -3753,7 +3687,7 @@ static void process_db_drop(struct work_struct *work)
3753 3687
3754void t4_db_full(struct adapter *adap) 3688void t4_db_full(struct adapter *adap)
3755{ 3689{
3756 if (is_t4(adap->chip)) { 3690 if (is_t4(adap->params.chip)) {
3757 t4_set_reg_field(adap, SGE_INT_ENABLE3, 3691 t4_set_reg_field(adap, SGE_INT_ENABLE3,
3758 DBFIFO_HP_INT | DBFIFO_LP_INT, 0); 3692 DBFIFO_HP_INT | DBFIFO_LP_INT, 0);
3759 queue_work(workq, &adap->db_full_task); 3693 queue_work(workq, &adap->db_full_task);
@@ -3762,7 +3696,7 @@ void t4_db_full(struct adapter *adap)
3762 3696
3763void t4_db_dropped(struct adapter *adap) 3697void t4_db_dropped(struct adapter *adap)
3764{ 3698{
3765 if (is_t4(adap->chip)) 3699 if (is_t4(adap->params.chip))
3766 queue_work(workq, &adap->db_drop_task); 3700 queue_work(workq, &adap->db_drop_task);
3767} 3701}
3768 3702
@@ -3789,7 +3723,7 @@ static void uld_attach(struct adapter *adap, unsigned int uld)
3789 lli.nchan = adap->params.nports; 3723 lli.nchan = adap->params.nports;
3790 lli.nports = adap->params.nports; 3724 lli.nports = adap->params.nports;
3791 lli.wr_cred = adap->params.ofldq_wr_cred; 3725 lli.wr_cred = adap->params.ofldq_wr_cred;
3792 lli.adapter_type = adap->params.rev; 3726 lli.adapter_type = adap->params.chip;
3793 lli.iscsi_iolen = MAXRXDATA_GET(t4_read_reg(adap, TP_PARA_REG2)); 3727 lli.iscsi_iolen = MAXRXDATA_GET(t4_read_reg(adap, TP_PARA_REG2));
3794 lli.udb_density = 1 << QUEUESPERPAGEPF0_GET( 3728 lli.udb_density = 1 << QUEUESPERPAGEPF0_GET(
3795 t4_read_reg(adap, SGE_EGRESS_QUEUES_PER_PAGE_PF) >> 3729 t4_read_reg(adap, SGE_EGRESS_QUEUES_PER_PAGE_PF) >>
@@ -4483,7 +4417,7 @@ static void setup_memwin(struct adapter *adap)
4483 u32 bar0, mem_win0_base, mem_win1_base, mem_win2_base; 4417 u32 bar0, mem_win0_base, mem_win1_base, mem_win2_base;
4484 4418
4485 bar0 = pci_resource_start(adap->pdev, 0); /* truncation intentional */ 4419 bar0 = pci_resource_start(adap->pdev, 0); /* truncation intentional */
4486 if (is_t4(adap->chip)) { 4420 if (is_t4(adap->params.chip)) {
4487 mem_win0_base = bar0 + MEMWIN0_BASE; 4421 mem_win0_base = bar0 + MEMWIN0_BASE;
4488 mem_win1_base = bar0 + MEMWIN1_BASE; 4422 mem_win1_base = bar0 + MEMWIN1_BASE;
4489 mem_win2_base = bar0 + MEMWIN2_BASE; 4423 mem_win2_base = bar0 + MEMWIN2_BASE;
@@ -4668,8 +4602,10 @@ static int adap_init0_config(struct adapter *adapter, int reset)
4668 const struct firmware *cf; 4602 const struct firmware *cf;
4669 unsigned long mtype = 0, maddr = 0; 4603 unsigned long mtype = 0, maddr = 0;
4670 u32 finiver, finicsum, cfcsum; 4604 u32 finiver, finicsum, cfcsum;
4671 int ret, using_flash; 4605 int ret;
4606 int config_issued = 0;
4672 char *fw_config_file, fw_config_file_path[256]; 4607 char *fw_config_file, fw_config_file_path[256];
4608 char *config_name = NULL;
4673 4609
4674 /* 4610 /*
4675 * Reset device if necessary. 4611 * Reset device if necessary.
@@ -4686,9 +4622,9 @@ static int adap_init0_config(struct adapter *adapter, int reset)
4686 * then use that. Otherwise, use the configuration file stored 4622 * then use that. Otherwise, use the configuration file stored
4687 * in the adapter flash ... 4623 * in the adapter flash ...
4688 */ 4624 */
4689 switch (CHELSIO_CHIP_VERSION(adapter->chip)) { 4625 switch (CHELSIO_CHIP_VERSION(adapter->params.chip)) {
4690 case CHELSIO_T4: 4626 case CHELSIO_T4:
4691 fw_config_file = FW_CFNAME; 4627 fw_config_file = FW4_CFNAME;
4692 break; 4628 break;
4693 case CHELSIO_T5: 4629 case CHELSIO_T5:
4694 fw_config_file = FW5_CFNAME; 4630 fw_config_file = FW5_CFNAME;
@@ -4702,13 +4638,16 @@ static int adap_init0_config(struct adapter *adapter, int reset)
4702 4638
4703 ret = request_firmware(&cf, fw_config_file, adapter->pdev_dev); 4639 ret = request_firmware(&cf, fw_config_file, adapter->pdev_dev);
4704 if (ret < 0) { 4640 if (ret < 0) {
4705 using_flash = 1; 4641 config_name = "On FLASH";
4706 mtype = FW_MEMTYPE_CF_FLASH; 4642 mtype = FW_MEMTYPE_CF_FLASH;
4707 maddr = t4_flash_cfg_addr(adapter); 4643 maddr = t4_flash_cfg_addr(adapter);
4708 } else { 4644 } else {
4709 u32 params[7], val[7]; 4645 u32 params[7], val[7];
4710 4646
4711 using_flash = 0; 4647 sprintf(fw_config_file_path,
4648 "/lib/firmware/%s", fw_config_file);
4649 config_name = fw_config_file_path;
4650
4712 if (cf->size >= FLASH_CFG_MAX_SIZE) 4651 if (cf->size >= FLASH_CFG_MAX_SIZE)
4713 ret = -ENOMEM; 4652 ret = -ENOMEM;
4714 else { 4653 else {
@@ -4776,6 +4715,26 @@ static int adap_init0_config(struct adapter *adapter, int reset)
4776 FW_LEN16(caps_cmd)); 4715 FW_LEN16(caps_cmd));
4777 ret = t4_wr_mbox(adapter, adapter->mbox, &caps_cmd, sizeof(caps_cmd), 4716 ret = t4_wr_mbox(adapter, adapter->mbox, &caps_cmd, sizeof(caps_cmd),
4778 &caps_cmd); 4717 &caps_cmd);
4718
4719 /* If the CAPS_CONFIG failed with an ENOENT (for a Firmware
4720 * Configuration File in FLASH), our last gasp effort is to use the
4721 * Firmware Configuration File which is embedded in the firmware. A
4722 * very few early versions of the firmware didn't have one embedded
4723 * but we can ignore those.
4724 */
4725 if (ret == -ENOENT) {
4726 memset(&caps_cmd, 0, sizeof(caps_cmd));
4727 caps_cmd.op_to_write =
4728 htonl(FW_CMD_OP(FW_CAPS_CONFIG_CMD) |
4729 FW_CMD_REQUEST |
4730 FW_CMD_READ);
4731 caps_cmd.cfvalid_to_len16 = htonl(FW_LEN16(caps_cmd));
4732 ret = t4_wr_mbox(adapter, adapter->mbox, &caps_cmd,
4733 sizeof(caps_cmd), &caps_cmd);
4734 config_name = "Firmware Default";
4735 }
4736
4737 config_issued = 1;
4779 if (ret < 0) 4738 if (ret < 0)
4780 goto bye; 4739 goto bye;
4781 4740
@@ -4816,7 +4775,6 @@ static int adap_init0_config(struct adapter *adapter, int reset)
4816 if (ret < 0) 4775 if (ret < 0)
4817 goto bye; 4776 goto bye;
4818 4777
4819 sprintf(fw_config_file_path, "/lib/firmware/%s", fw_config_file);
4820 /* 4778 /*
4821 * Return successfully and note that we're operating with parameters 4779 * Return successfully and note that we're operating with parameters
4822 * not supplied by the driver, rather than from hard-wired 4780 * not supplied by the driver, rather than from hard-wired
@@ -4824,11 +4782,8 @@ static int adap_init0_config(struct adapter *adapter, int reset)
4824 */ 4782 */
4825 adapter->flags |= USING_SOFT_PARAMS; 4783 adapter->flags |= USING_SOFT_PARAMS;
4826 dev_info(adapter->pdev_dev, "Successfully configured using Firmware "\ 4784 dev_info(adapter->pdev_dev, "Successfully configured using Firmware "\
4827 "Configuration File %s, version %#x, computed checksum %#x\n", 4785 "Configuration File \"%s\", version %#x, computed checksum %#x\n",
4828 (using_flash 4786 config_name, finiver, cfcsum);
4829 ? "in device FLASH"
4830 : fw_config_file_path),
4831 finiver, cfcsum);
4832 return 0; 4787 return 0;
4833 4788
4834 /* 4789 /*
@@ -4837,9 +4792,9 @@ static int adap_init0_config(struct adapter *adapter, int reset)
4837 * want to issue a warning since this is fairly common.) 4792 * want to issue a warning since this is fairly common.)
4838 */ 4793 */
4839bye: 4794bye:
4840 if (ret != -ENOENT) 4795 if (config_issued && ret != -ENOENT)
4841 dev_warn(adapter->pdev_dev, "Configuration file error %d\n", 4796 dev_warn(adapter->pdev_dev, "\"%s\" configuration file error %d\n",
4842 -ret); 4797 config_name, -ret);
4843 return ret; 4798 return ret;
4844} 4799}
4845 4800
@@ -5086,6 +5041,47 @@ bye:
5086 return ret; 5041 return ret;
5087} 5042}
5088 5043
5044static struct fw_info fw_info_array[] = {
5045 {
5046 .chip = CHELSIO_T4,
5047 .fs_name = FW4_CFNAME,
5048 .fw_mod_name = FW4_FNAME,
5049 .fw_hdr = {
5050 .chip = FW_HDR_CHIP_T4,
5051 .fw_ver = __cpu_to_be32(FW_VERSION(T4)),
5052 .intfver_nic = FW_INTFVER(T4, NIC),
5053 .intfver_vnic = FW_INTFVER(T4, VNIC),
5054 .intfver_ri = FW_INTFVER(T4, RI),
5055 .intfver_iscsi = FW_INTFVER(T4, ISCSI),
5056 .intfver_fcoe = FW_INTFVER(T4, FCOE),
5057 },
5058 }, {
5059 .chip = CHELSIO_T5,
5060 .fs_name = FW5_CFNAME,
5061 .fw_mod_name = FW5_FNAME,
5062 .fw_hdr = {
5063 .chip = FW_HDR_CHIP_T5,
5064 .fw_ver = __cpu_to_be32(FW_VERSION(T5)),
5065 .intfver_nic = FW_INTFVER(T5, NIC),
5066 .intfver_vnic = FW_INTFVER(T5, VNIC),
5067 .intfver_ri = FW_INTFVER(T5, RI),
5068 .intfver_iscsi = FW_INTFVER(T5, ISCSI),
5069 .intfver_fcoe = FW_INTFVER(T5, FCOE),
5070 },
5071 }
5072};
5073
5074static struct fw_info *find_fw_info(int chip)
5075{
5076 int i;
5077
5078 for (i = 0; i < ARRAY_SIZE(fw_info_array); i++) {
5079 if (fw_info_array[i].chip == chip)
5080 return &fw_info_array[i];
5081 }
5082 return NULL;
5083}
5084
5089/* 5085/*
5090 * Phase 0 of initialization: contact FW, obtain config, perform basic init. 5086 * Phase 0 of initialization: contact FW, obtain config, perform basic init.
5091 */ 5087 */
@@ -5123,44 +5119,54 @@ static int adap_init0(struct adapter *adap)
5123 * later reporting and B. to warn if the currently loaded firmware 5119 * later reporting and B. to warn if the currently loaded firmware
5124 * is excessively mismatched relative to the driver.) 5120 * is excessively mismatched relative to the driver.)
5125 */ 5121 */
5126 ret = t4_check_fw_version(adap); 5122 t4_get_fw_version(adap, &adap->params.fw_vers);
5127 5123 t4_get_tp_version(adap, &adap->params.tp_vers);
5128 /* The error code -EFAULT is returned by t4_check_fw_version() if
5129 * firmware on adapter < supported firmware. If firmware on adapter
5130 * is too old (not supported by driver) and we're the MASTER_PF set
5131 * adapter state to DEV_STATE_UNINIT to force firmware upgrade
5132 * and reinitialization.
5133 */
5134 if ((adap->flags & MASTER_PF) && ret == -EFAULT)
5135 state = DEV_STATE_UNINIT;
5136 if ((adap->flags & MASTER_PF) && state != DEV_STATE_INIT) { 5124 if ((adap->flags & MASTER_PF) && state != DEV_STATE_INIT) {
5137 if (ret == -EINVAL || ret == -EFAULT || ret > 0) { 5125 struct fw_info *fw_info;
5138 if (upgrade_fw(adap) >= 0) { 5126 struct fw_hdr *card_fw;
5139 /* 5127 const struct firmware *fw;
5140 * Note that the chip was reset as part of the 5128 const u8 *fw_data = NULL;
5141 * firmware upgrade so we don't reset it again 5129 unsigned int fw_size = 0;
5142 * below and grab the new firmware version. 5130
5143 */ 5131 /* This is the firmware whose headers the driver was compiled
5144 reset = 0; 5132 * against
5145 ret = t4_check_fw_version(adap); 5133 */
5146 } else 5134 fw_info = find_fw_info(CHELSIO_CHIP_VERSION(adap->params.chip));
5147 if (ret == -EFAULT) { 5135 if (fw_info == NULL) {
5148 /* 5136 dev_err(adap->pdev_dev,
5149 * Firmware is old but still might 5137 "unable to get firmware info for chip %d.\n",
5150 * work if we force reinitialization 5138 CHELSIO_CHIP_VERSION(adap->params.chip));
5151 * of the adapter. Ignoring FW upgrade 5139 return -EINVAL;
5152 * failure.
5153 */
5154 dev_warn(adap->pdev_dev,
5155 "Ignoring firmware upgrade "
5156 "failure, and forcing driver "
5157 "to reinitialize the "
5158 "adapter.\n");
5159 ret = 0;
5160 }
5161 } 5140 }
5141
5142 /* allocate memory to read the header of the firmware on the
5143 * card
5144 */
5145 card_fw = t4_alloc_mem(sizeof(*card_fw));
5146
5147 /* Get FW from from /lib/firmware/ */
5148 ret = request_firmware(&fw, fw_info->fw_mod_name,
5149 adap->pdev_dev);
5150 if (ret < 0) {
5151 dev_err(adap->pdev_dev,
5152 "unable to load firmware image %s, error %d\n",
5153 fw_info->fw_mod_name, ret);
5154 } else {
5155 fw_data = fw->data;
5156 fw_size = fw->size;
5157 }
5158
5159 /* upgrade FW logic */
5160 ret = t4_prep_fw(adap, fw_info, fw_data, fw_size, card_fw,
5161 state, &reset);
5162
5163 /* Cleaning up */
5164 if (fw != NULL)
5165 release_firmware(fw);
5166 t4_free_mem(card_fw);
5167
5162 if (ret < 0) 5168 if (ret < 0)
5163 return ret; 5169 goto bye;
5164 } 5170 }
5165 5171
5166 /* 5172 /*
@@ -5245,7 +5251,7 @@ static int adap_init0(struct adapter *adap)
5245 if (ret == -ENOENT) { 5251 if (ret == -ENOENT) {
5246 dev_info(adap->pdev_dev, 5252 dev_info(adap->pdev_dev,
5247 "No Configuration File present " 5253 "No Configuration File present "
5248 "on adapter. Using hard-wired " 5254 "on adapter. Using hard-wired "
5249 "configuration parameters.\n"); 5255 "configuration parameters.\n");
5250 ret = adap_init0_no_config(adap, reset); 5256 ret = adap_init0_no_config(adap, reset);
5251 } 5257 }
@@ -5787,7 +5793,7 @@ static void print_port_info(const struct net_device *dev)
5787 5793
5788 netdev_info(dev, "Chelsio %s rev %d %s %sNIC PCIe x%d%s%s\n", 5794 netdev_info(dev, "Chelsio %s rev %d %s %sNIC PCIe x%d%s%s\n",
5789 adap->params.vpd.id, 5795 adap->params.vpd.id,
5790 CHELSIO_CHIP_RELEASE(adap->params.rev), buf, 5796 CHELSIO_CHIP_RELEASE(adap->params.chip), buf,
5791 is_offload(adap) ? "R" : "", adap->params.pci.width, spd, 5797 is_offload(adap) ? "R" : "", adap->params.pci.width, spd,
5792 (adap->flags & USING_MSIX) ? " MSI-X" : 5798 (adap->flags & USING_MSIX) ? " MSI-X" :
5793 (adap->flags & USING_MSI) ? " MSI" : ""); 5799 (adap->flags & USING_MSI) ? " MSI" : "");
@@ -5910,7 +5916,7 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
5910 if (err) 5916 if (err)
5911 goto out_unmap_bar0; 5917 goto out_unmap_bar0;
5912 5918
5913 if (!is_t4(adapter->chip)) { 5919 if (!is_t4(adapter->params.chip)) {
5914 s_qpp = QUEUESPERPAGEPF1 * adapter->fn; 5920 s_qpp = QUEUESPERPAGEPF1 * adapter->fn;
5915 qpp = 1 << QUEUESPERPAGEPF0_GET(t4_read_reg(adapter, 5921 qpp = 1 << QUEUESPERPAGEPF0_GET(t4_read_reg(adapter,
5916 SGE_EGRESS_QUEUES_PER_PAGE_PF) >> s_qpp); 5922 SGE_EGRESS_QUEUES_PER_PAGE_PF) >> s_qpp);
@@ -6064,7 +6070,7 @@ sriov:
6064 out_free_dev: 6070 out_free_dev:
6065 free_some_resources(adapter); 6071 free_some_resources(adapter);
6066 out_unmap_bar: 6072 out_unmap_bar:
6067 if (!is_t4(adapter->chip)) 6073 if (!is_t4(adapter->params.chip))
6068 iounmap(adapter->bar2); 6074 iounmap(adapter->bar2);
6069 out_unmap_bar0: 6075 out_unmap_bar0:
6070 iounmap(adapter->regs); 6076 iounmap(adapter->regs);
@@ -6116,7 +6122,7 @@ static void remove_one(struct pci_dev *pdev)
6116 6122
6117 free_some_resources(adapter); 6123 free_some_resources(adapter);
6118 iounmap(adapter->regs); 6124 iounmap(adapter->regs);
6119 if (!is_t4(adapter->chip)) 6125 if (!is_t4(adapter->params.chip))
6120 iounmap(adapter->bar2); 6126 iounmap(adapter->bar2);
6121 kfree(adapter); 6127 kfree(adapter);
6122 pci_disable_pcie_error_reporting(pdev); 6128 pci_disable_pcie_error_reporting(pdev);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c b/drivers/net/ethernet/chelsio/cxgb4/sge.c
index ac311f5f3eb9..cc380c36e1a8 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c
@@ -509,7 +509,7 @@ static inline void ring_fl_db(struct adapter *adap, struct sge_fl *q)
509 u32 val; 509 u32 val;
510 if (q->pend_cred >= 8) { 510 if (q->pend_cred >= 8) {
511 val = PIDX(q->pend_cred / 8); 511 val = PIDX(q->pend_cred / 8);
512 if (!is_t4(adap->chip)) 512 if (!is_t4(adap->params.chip))
513 val |= DBTYPE(1); 513 val |= DBTYPE(1);
514 wmb(); 514 wmb();
515 t4_write_reg(adap, MYPF_REG(SGE_PF_KDOORBELL), DBPRIO(1) | 515 t4_write_reg(adap, MYPF_REG(SGE_PF_KDOORBELL), DBPRIO(1) |
@@ -847,7 +847,7 @@ static inline void ring_tx_db(struct adapter *adap, struct sge_txq *q, int n)
847 wmb(); /* write descriptors before telling HW */ 847 wmb(); /* write descriptors before telling HW */
848 spin_lock(&q->db_lock); 848 spin_lock(&q->db_lock);
849 if (!q->db_disabled) { 849 if (!q->db_disabled) {
850 if (is_t4(adap->chip)) { 850 if (is_t4(adap->params.chip)) {
851 t4_write_reg(adap, MYPF_REG(SGE_PF_KDOORBELL), 851 t4_write_reg(adap, MYPF_REG(SGE_PF_KDOORBELL),
852 QID(q->cntxt_id) | PIDX(n)); 852 QID(q->cntxt_id) | PIDX(n));
853 } else { 853 } else {
@@ -1596,7 +1596,7 @@ static noinline int handle_trace_pkt(struct adapter *adap,
1596 return 0; 1596 return 0;
1597 } 1597 }
1598 1598
1599 if (is_t4(adap->chip)) 1599 if (is_t4(adap->params.chip))
1600 __skb_pull(skb, sizeof(struct cpl_trace_pkt)); 1600 __skb_pull(skb, sizeof(struct cpl_trace_pkt));
1601 else 1601 else
1602 __skb_pull(skb, sizeof(struct cpl_t5_trace_pkt)); 1602 __skb_pull(skb, sizeof(struct cpl_t5_trace_pkt));
@@ -1661,7 +1661,7 @@ int t4_ethrx_handler(struct sge_rspq *q, const __be64 *rsp,
1661 const struct cpl_rx_pkt *pkt; 1661 const struct cpl_rx_pkt *pkt;
1662 struct sge_eth_rxq *rxq = container_of(q, struct sge_eth_rxq, rspq); 1662 struct sge_eth_rxq *rxq = container_of(q, struct sge_eth_rxq, rspq);
1663 struct sge *s = &q->adap->sge; 1663 struct sge *s = &q->adap->sge;
1664 int cpl_trace_pkt = is_t4(q->adap->chip) ? 1664 int cpl_trace_pkt = is_t4(q->adap->params.chip) ?
1665 CPL_TRACE_PKT : CPL_TRACE_PKT_T5; 1665 CPL_TRACE_PKT : CPL_TRACE_PKT_T5;
1666 1666
1667 if (unlikely(*(u8 *)rsp == cpl_trace_pkt)) 1667 if (unlikely(*(u8 *)rsp == cpl_trace_pkt))
@@ -2182,7 +2182,7 @@ err:
2182static void init_txq(struct adapter *adap, struct sge_txq *q, unsigned int id) 2182static void init_txq(struct adapter *adap, struct sge_txq *q, unsigned int id)
2183{ 2183{
2184 q->cntxt_id = id; 2184 q->cntxt_id = id;
2185 if (!is_t4(adap->chip)) { 2185 if (!is_t4(adap->params.chip)) {
2186 unsigned int s_qpp; 2186 unsigned int s_qpp;
2187 unsigned short udb_density; 2187 unsigned short udb_density;
2188 unsigned long qpshift; 2188 unsigned long qpshift;
@@ -2641,7 +2641,7 @@ static int t4_sge_init_hard(struct adapter *adap)
2641 * Set up to drop DOORBELL writes when the DOORBELL FIFO overflows 2641 * Set up to drop DOORBELL writes when the DOORBELL FIFO overflows
2642 * and generate an interrupt when this occurs so we can recover. 2642 * and generate an interrupt when this occurs so we can recover.
2643 */ 2643 */
2644 if (is_t4(adap->chip)) { 2644 if (is_t4(adap->params.chip)) {
2645 t4_set_reg_field(adap, A_SGE_DBFIFO_STATUS, 2645 t4_set_reg_field(adap, A_SGE_DBFIFO_STATUS,
2646 V_HP_INT_THRESH(M_HP_INT_THRESH) | 2646 V_HP_INT_THRESH(M_HP_INT_THRESH) |
2647 V_LP_INT_THRESH(M_LP_INT_THRESH), 2647 V_LP_INT_THRESH(M_LP_INT_THRESH),
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index 4cbb2f9850be..74a6fce5a15a 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -296,7 +296,7 @@ int t4_mc_read(struct adapter *adap, int idx, u32 addr, __be32 *data, u64 *ecc)
296 u32 mc_bist_cmd, mc_bist_cmd_addr, mc_bist_cmd_len; 296 u32 mc_bist_cmd, mc_bist_cmd_addr, mc_bist_cmd_len;
297 u32 mc_bist_status_rdata, mc_bist_data_pattern; 297 u32 mc_bist_status_rdata, mc_bist_data_pattern;
298 298
299 if (is_t4(adap->chip)) { 299 if (is_t4(adap->params.chip)) {
300 mc_bist_cmd = MC_BIST_CMD; 300 mc_bist_cmd = MC_BIST_CMD;
301 mc_bist_cmd_addr = MC_BIST_CMD_ADDR; 301 mc_bist_cmd_addr = MC_BIST_CMD_ADDR;
302 mc_bist_cmd_len = MC_BIST_CMD_LEN; 302 mc_bist_cmd_len = MC_BIST_CMD_LEN;
@@ -349,7 +349,7 @@ int t4_edc_read(struct adapter *adap, int idx, u32 addr, __be32 *data, u64 *ecc)
349 u32 edc_bist_cmd, edc_bist_cmd_addr, edc_bist_cmd_len; 349 u32 edc_bist_cmd, edc_bist_cmd_addr, edc_bist_cmd_len;
350 u32 edc_bist_cmd_data_pattern, edc_bist_status_rdata; 350 u32 edc_bist_cmd_data_pattern, edc_bist_status_rdata;
351 351
352 if (is_t4(adap->chip)) { 352 if (is_t4(adap->params.chip)) {
353 edc_bist_cmd = EDC_REG(EDC_BIST_CMD, idx); 353 edc_bist_cmd = EDC_REG(EDC_BIST_CMD, idx);
354 edc_bist_cmd_addr = EDC_REG(EDC_BIST_CMD_ADDR, idx); 354 edc_bist_cmd_addr = EDC_REG(EDC_BIST_CMD_ADDR, idx);
355 edc_bist_cmd_len = EDC_REG(EDC_BIST_CMD_LEN, idx); 355 edc_bist_cmd_len = EDC_REG(EDC_BIST_CMD_LEN, idx);
@@ -402,7 +402,7 @@ int t4_edc_read(struct adapter *adap, int idx, u32 addr, __be32 *data, u64 *ecc)
402static int t4_mem_win_rw(struct adapter *adap, u32 addr, __be32 *data, int dir) 402static int t4_mem_win_rw(struct adapter *adap, u32 addr, __be32 *data, int dir)
403{ 403{
404 int i; 404 int i;
405 u32 win_pf = is_t4(adap->chip) ? 0 : V_PFNUM(adap->fn); 405 u32 win_pf = is_t4(adap->params.chip) ? 0 : V_PFNUM(adap->fn);
406 406
407 /* 407 /*
408 * Setup offset into PCIE memory window. Address must be a 408 * Setup offset into PCIE memory window. Address must be a
@@ -863,104 +863,169 @@ unlock:
863} 863}
864 864
865/** 865/**
866 * get_fw_version - read the firmware version 866 * t4_get_fw_version - read the firmware version
867 * @adapter: the adapter 867 * @adapter: the adapter
868 * @vers: where to place the version 868 * @vers: where to place the version
869 * 869 *
870 * Reads the FW version from flash. 870 * Reads the FW version from flash.
871 */ 871 */
872static int get_fw_version(struct adapter *adapter, u32 *vers) 872int t4_get_fw_version(struct adapter *adapter, u32 *vers)
873{ 873{
874 return t4_read_flash(adapter, adapter->params.sf_fw_start + 874 return t4_read_flash(adapter, FLASH_FW_START +
875 offsetof(struct fw_hdr, fw_ver), 1, vers, 0); 875 offsetof(struct fw_hdr, fw_ver), 1,
876 vers, 0);
876} 877}
877 878
878/** 879/**
879 * get_tp_version - read the TP microcode version 880 * t4_get_tp_version - read the TP microcode version
880 * @adapter: the adapter 881 * @adapter: the adapter
881 * @vers: where to place the version 882 * @vers: where to place the version
882 * 883 *
883 * Reads the TP microcode version from flash. 884 * Reads the TP microcode version from flash.
884 */ 885 */
885static int get_tp_version(struct adapter *adapter, u32 *vers) 886int t4_get_tp_version(struct adapter *adapter, u32 *vers)
886{ 887{
887 return t4_read_flash(adapter, adapter->params.sf_fw_start + 888 return t4_read_flash(adapter, FLASH_FW_START +
888 offsetof(struct fw_hdr, tp_microcode_ver), 889 offsetof(struct fw_hdr, tp_microcode_ver),
889 1, vers, 0); 890 1, vers, 0);
890} 891}
891 892
892/** 893/* Is the given firmware API compatible with the one the driver was compiled
893 * t4_check_fw_version - check if the FW is compatible with this driver 894 * with?
894 * @adapter: the adapter
895 *
896 * Checks if an adapter's FW is compatible with the driver. Returns 0
897 * if there's exact match, a negative error if the version could not be
898 * read or there's a major version mismatch, and a positive value if the
899 * expected major version is found but there's a minor version mismatch.
900 */ 895 */
901int t4_check_fw_version(struct adapter *adapter) 896static int fw_compatible(const struct fw_hdr *hdr1, const struct fw_hdr *hdr2)
902{ 897{
903 u32 api_vers[2];
904 int ret, major, minor, micro;
905 int exp_major, exp_minor, exp_micro;
906 898
907 ret = get_fw_version(adapter, &adapter->params.fw_vers); 899 /* short circuit if it's the exact same firmware version */
908 if (!ret) 900 if (hdr1->chip == hdr2->chip && hdr1->fw_ver == hdr2->fw_ver)
909 ret = get_tp_version(adapter, &adapter->params.tp_vers); 901 return 1;
910 if (!ret)
911 ret = t4_read_flash(adapter, adapter->params.sf_fw_start +
912 offsetof(struct fw_hdr, intfver_nic),
913 2, api_vers, 1);
914 if (ret)
915 return ret;
916 902
917 major = FW_HDR_FW_VER_MAJOR_GET(adapter->params.fw_vers); 903#define SAME_INTF(x) (hdr1->intfver_##x == hdr2->intfver_##x)
918 minor = FW_HDR_FW_VER_MINOR_GET(adapter->params.fw_vers); 904 if (hdr1->chip == hdr2->chip && SAME_INTF(nic) && SAME_INTF(vnic) &&
919 micro = FW_HDR_FW_VER_MICRO_GET(adapter->params.fw_vers); 905 SAME_INTF(ri) && SAME_INTF(iscsi) && SAME_INTF(fcoe))
906 return 1;
907#undef SAME_INTF
920 908
921 switch (CHELSIO_CHIP_VERSION(adapter->chip)) { 909 return 0;
922 case CHELSIO_T4: 910}
923 exp_major = FW_VERSION_MAJOR;
924 exp_minor = FW_VERSION_MINOR;
925 exp_micro = FW_VERSION_MICRO;
926 break;
927 case CHELSIO_T5:
928 exp_major = FW_VERSION_MAJOR_T5;
929 exp_minor = FW_VERSION_MINOR_T5;
930 exp_micro = FW_VERSION_MICRO_T5;
931 break;
932 default:
933 dev_err(adapter->pdev_dev, "Unsupported chip type, %x\n",
934 adapter->chip);
935 return -EINVAL;
936 }
937 911
938 memcpy(adapter->params.api_vers, api_vers, 912/* The firmware in the filesystem is usable, but should it be installed?
939 sizeof(adapter->params.api_vers)); 913 * This routine explains itself in detail if it indicates the filesystem
914 * firmware should be installed.
915 */
916static int should_install_fs_fw(struct adapter *adap, int card_fw_usable,
917 int k, int c)
918{
919 const char *reason;
940 920
941 if (major < exp_major || (major == exp_major && minor < exp_minor) || 921 if (!card_fw_usable) {
942 (major == exp_major && minor == exp_minor && micro < exp_micro)) { 922 reason = "incompatible or unusable";
943 dev_err(adapter->pdev_dev, 923 goto install;
944 "Card has firmware version %u.%u.%u, minimum "
945 "supported firmware is %u.%u.%u.\n", major, minor,
946 micro, exp_major, exp_minor, exp_micro);
947 return -EFAULT;
948 } 924 }
949 925
950 if (major != exp_major) { /* major mismatch - fail */ 926 if (k > c) {
951 dev_err(adapter->pdev_dev, 927 reason = "older than the version supported with this driver";
952 "card FW has major version %u, driver wants %u\n", 928 goto install;
953 major, exp_major);
954 return -EINVAL;
955 } 929 }
956 930
957 if (minor == exp_minor && micro == exp_micro) 931 return 0;
958 return 0; /* perfect match */ 932
933install:
934 dev_err(adap->pdev_dev, "firmware on card (%u.%u.%u.%u) is %s, "
935 "installing firmware %u.%u.%u.%u on card.\n",
936 FW_HDR_FW_VER_MAJOR_GET(c), FW_HDR_FW_VER_MINOR_GET(c),
937 FW_HDR_FW_VER_MICRO_GET(c), FW_HDR_FW_VER_BUILD_GET(c), reason,
938 FW_HDR_FW_VER_MAJOR_GET(k), FW_HDR_FW_VER_MINOR_GET(k),
939 FW_HDR_FW_VER_MICRO_GET(k), FW_HDR_FW_VER_BUILD_GET(k));
959 940
960 /* Minor/micro version mismatch. Report it but often it's OK. */
961 return 1; 941 return 1;
962} 942}
963 943
944int t4_prep_fw(struct adapter *adap, struct fw_info *fw_info,
945 const u8 *fw_data, unsigned int fw_size,
946 struct fw_hdr *card_fw, enum dev_state state,
947 int *reset)
948{
949 int ret, card_fw_usable, fs_fw_usable;
950 const struct fw_hdr *fs_fw;
951 const struct fw_hdr *drv_fw;
952
953 drv_fw = &fw_info->fw_hdr;
954
955 /* Read the header of the firmware on the card */
956 ret = -t4_read_flash(adap, FLASH_FW_START,
957 sizeof(*card_fw) / sizeof(uint32_t),
958 (uint32_t *)card_fw, 1);
959 if (ret == 0) {
960 card_fw_usable = fw_compatible(drv_fw, (const void *)card_fw);
961 } else {
962 dev_err(adap->pdev_dev,
963 "Unable to read card's firmware header: %d\n", ret);
964 card_fw_usable = 0;
965 }
966
967 if (fw_data != NULL) {
968 fs_fw = (const void *)fw_data;
969 fs_fw_usable = fw_compatible(drv_fw, fs_fw);
970 } else {
971 fs_fw = NULL;
972 fs_fw_usable = 0;
973 }
974
975 if (card_fw_usable && card_fw->fw_ver == drv_fw->fw_ver &&
976 (!fs_fw_usable || fs_fw->fw_ver == drv_fw->fw_ver)) {
977 /* Common case: the firmware on the card is an exact match and
978 * the filesystem one is an exact match too, or the filesystem
979 * one is absent/incompatible.
980 */
981 } else if (fs_fw_usable && state == DEV_STATE_UNINIT &&
982 should_install_fs_fw(adap, card_fw_usable,
983 be32_to_cpu(fs_fw->fw_ver),
984 be32_to_cpu(card_fw->fw_ver))) {
985 ret = -t4_fw_upgrade(adap, adap->mbox, fw_data,
986 fw_size, 0);
987 if (ret != 0) {
988 dev_err(adap->pdev_dev,
989 "failed to install firmware: %d\n", ret);
990 goto bye;
991 }
992
993 /* Installed successfully, update the cached header too. */
994 memcpy(card_fw, fs_fw, sizeof(*card_fw));
995 card_fw_usable = 1;
996 *reset = 0; /* already reset as part of load_fw */
997 }
998
999 if (!card_fw_usable) {
1000 uint32_t d, c, k;
1001
1002 d = be32_to_cpu(drv_fw->fw_ver);
1003 c = be32_to_cpu(card_fw->fw_ver);
1004 k = fs_fw ? be32_to_cpu(fs_fw->fw_ver) : 0;
1005
1006 dev_err(adap->pdev_dev, "Cannot find a usable firmware: "
1007 "chip state %d, "
1008 "driver compiled with %d.%d.%d.%d, "
1009 "card has %d.%d.%d.%d, filesystem has %d.%d.%d.%d\n",
1010 state,
1011 FW_HDR_FW_VER_MAJOR_GET(d), FW_HDR_FW_VER_MINOR_GET(d),
1012 FW_HDR_FW_VER_MICRO_GET(d), FW_HDR_FW_VER_BUILD_GET(d),
1013 FW_HDR_FW_VER_MAJOR_GET(c), FW_HDR_FW_VER_MINOR_GET(c),
1014 FW_HDR_FW_VER_MICRO_GET(c), FW_HDR_FW_VER_BUILD_GET(c),
1015 FW_HDR_FW_VER_MAJOR_GET(k), FW_HDR_FW_VER_MINOR_GET(k),
1016 FW_HDR_FW_VER_MICRO_GET(k), FW_HDR_FW_VER_BUILD_GET(k));
1017 ret = EINVAL;
1018 goto bye;
1019 }
1020
1021 /* We're using whatever's on the card and it's known to be good. */
1022 adap->params.fw_vers = be32_to_cpu(card_fw->fw_ver);
1023 adap->params.tp_vers = be32_to_cpu(card_fw->tp_microcode_ver);
1024
1025bye:
1026 return ret;
1027}
1028
964/** 1029/**
965 * t4_flash_erase_sectors - erase a range of flash sectors 1030 * t4_flash_erase_sectors - erase a range of flash sectors
966 * @adapter: the adapter 1031 * @adapter: the adapter
@@ -1368,7 +1433,7 @@ static void pcie_intr_handler(struct adapter *adapter)
1368 PCIE_CORE_UTL_PCI_EXPRESS_PORT_STATUS, 1433 PCIE_CORE_UTL_PCI_EXPRESS_PORT_STATUS,
1369 pcie_port_intr_info) + 1434 pcie_port_intr_info) +
1370 t4_handle_intr_status(adapter, PCIE_INT_CAUSE, 1435 t4_handle_intr_status(adapter, PCIE_INT_CAUSE,
1371 is_t4(adapter->chip) ? 1436 is_t4(adapter->params.chip) ?
1372 pcie_intr_info : t5_pcie_intr_info); 1437 pcie_intr_info : t5_pcie_intr_info);
1373 1438
1374 if (fat) 1439 if (fat)
@@ -1782,7 +1847,7 @@ static void xgmac_intr_handler(struct adapter *adap, int port)
1782{ 1847{
1783 u32 v, int_cause_reg; 1848 u32 v, int_cause_reg;
1784 1849
1785 if (is_t4(adap->chip)) 1850 if (is_t4(adap->params.chip))
1786 int_cause_reg = PORT_REG(port, XGMAC_PORT_INT_CAUSE); 1851 int_cause_reg = PORT_REG(port, XGMAC_PORT_INT_CAUSE);
1787 else 1852 else
1788 int_cause_reg = T5_PORT_REG(port, MAC_PORT_INT_CAUSE); 1853 int_cause_reg = T5_PORT_REG(port, MAC_PORT_INT_CAUSE);
@@ -2250,7 +2315,7 @@ void t4_get_port_stats(struct adapter *adap, int idx, struct port_stats *p)
2250 2315
2251#define GET_STAT(name) \ 2316#define GET_STAT(name) \
2252 t4_read_reg64(adap, \ 2317 t4_read_reg64(adap, \
2253 (is_t4(adap->chip) ? PORT_REG(idx, MPS_PORT_STAT_##name##_L) : \ 2318 (is_t4(adap->params.chip) ? PORT_REG(idx, MPS_PORT_STAT_##name##_L) : \
2254 T5_PORT_REG(idx, MPS_PORT_STAT_##name##_L))) 2319 T5_PORT_REG(idx, MPS_PORT_STAT_##name##_L)))
2255#define GET_STAT_COM(name) t4_read_reg64(adap, MPS_STAT_##name##_L) 2320#define GET_STAT_COM(name) t4_read_reg64(adap, MPS_STAT_##name##_L)
2256 2321
@@ -2332,7 +2397,7 @@ void t4_wol_magic_enable(struct adapter *adap, unsigned int port,
2332{ 2397{
2333 u32 mag_id_reg_l, mag_id_reg_h, port_cfg_reg; 2398 u32 mag_id_reg_l, mag_id_reg_h, port_cfg_reg;
2334 2399
2335 if (is_t4(adap->chip)) { 2400 if (is_t4(adap->params.chip)) {
2336 mag_id_reg_l = PORT_REG(port, XGMAC_PORT_MAGIC_MACID_LO); 2401 mag_id_reg_l = PORT_REG(port, XGMAC_PORT_MAGIC_MACID_LO);
2337 mag_id_reg_h = PORT_REG(port, XGMAC_PORT_MAGIC_MACID_HI); 2402 mag_id_reg_h = PORT_REG(port, XGMAC_PORT_MAGIC_MACID_HI);
2338 port_cfg_reg = PORT_REG(port, XGMAC_PORT_CFG2); 2403 port_cfg_reg = PORT_REG(port, XGMAC_PORT_CFG2);
@@ -2374,7 +2439,7 @@ int t4_wol_pat_enable(struct adapter *adap, unsigned int port, unsigned int map,
2374 int i; 2439 int i;
2375 u32 port_cfg_reg; 2440 u32 port_cfg_reg;
2376 2441
2377 if (is_t4(adap->chip)) 2442 if (is_t4(adap->params.chip))
2378 port_cfg_reg = PORT_REG(port, XGMAC_PORT_CFG2); 2443 port_cfg_reg = PORT_REG(port, XGMAC_PORT_CFG2);
2379 else 2444 else
2380 port_cfg_reg = T5_PORT_REG(port, MAC_PORT_CFG2); 2445 port_cfg_reg = T5_PORT_REG(port, MAC_PORT_CFG2);
@@ -2387,7 +2452,7 @@ int t4_wol_pat_enable(struct adapter *adap, unsigned int port, unsigned int map,
2387 return -EINVAL; 2452 return -EINVAL;
2388 2453
2389#define EPIO_REG(name) \ 2454#define EPIO_REG(name) \
2390 (is_t4(adap->chip) ? PORT_REG(port, XGMAC_PORT_EPIO_##name) : \ 2455 (is_t4(adap->params.chip) ? PORT_REG(port, XGMAC_PORT_EPIO_##name) : \
2391 T5_PORT_REG(port, MAC_PORT_EPIO_##name)) 2456 T5_PORT_REG(port, MAC_PORT_EPIO_##name))
2392 2457
2393 t4_write_reg(adap, EPIO_REG(DATA1), mask0 >> 32); 2458 t4_write_reg(adap, EPIO_REG(DATA1), mask0 >> 32);
@@ -2474,7 +2539,7 @@ int t4_fwaddrspace_write(struct adapter *adap, unsigned int mbox,
2474int t4_mem_win_read_len(struct adapter *adap, u32 addr, __be32 *data, int len) 2539int t4_mem_win_read_len(struct adapter *adap, u32 addr, __be32 *data, int len)
2475{ 2540{
2476 int i, off; 2541 int i, off;
2477 u32 win_pf = is_t4(adap->chip) ? 0 : V_PFNUM(adap->fn); 2542 u32 win_pf = is_t4(adap->params.chip) ? 0 : V_PFNUM(adap->fn);
2478 2543
2479 /* Align on a 2KB boundary. 2544 /* Align on a 2KB boundary.
2480 */ 2545 */
@@ -3306,7 +3371,7 @@ int t4_alloc_mac_filt(struct adapter *adap, unsigned int mbox,
3306 int i, ret; 3371 int i, ret;
3307 struct fw_vi_mac_cmd c; 3372 struct fw_vi_mac_cmd c;
3308 struct fw_vi_mac_exact *p; 3373 struct fw_vi_mac_exact *p;
3309 unsigned int max_naddr = is_t4(adap->chip) ? 3374 unsigned int max_naddr = is_t4(adap->params.chip) ?
3310 NUM_MPS_CLS_SRAM_L_INSTANCES : 3375 NUM_MPS_CLS_SRAM_L_INSTANCES :
3311 NUM_MPS_T5_CLS_SRAM_L_INSTANCES; 3376 NUM_MPS_T5_CLS_SRAM_L_INSTANCES;
3312 3377
@@ -3368,7 +3433,7 @@ int t4_change_mac(struct adapter *adap, unsigned int mbox, unsigned int viid,
3368 int ret, mode; 3433 int ret, mode;
3369 struct fw_vi_mac_cmd c; 3434 struct fw_vi_mac_cmd c;
3370 struct fw_vi_mac_exact *p = c.u.exact; 3435 struct fw_vi_mac_exact *p = c.u.exact;
3371 unsigned int max_mac_addr = is_t4(adap->chip) ? 3436 unsigned int max_mac_addr = is_t4(adap->params.chip) ?
3372 NUM_MPS_CLS_SRAM_L_INSTANCES : 3437 NUM_MPS_CLS_SRAM_L_INSTANCES :
3373 NUM_MPS_T5_CLS_SRAM_L_INSTANCES; 3438 NUM_MPS_T5_CLS_SRAM_L_INSTANCES;
3374 3439
@@ -3699,13 +3764,14 @@ int t4_prep_adapter(struct adapter *adapter)
3699{ 3764{
3700 int ret, ver; 3765 int ret, ver;
3701 uint16_t device_id; 3766 uint16_t device_id;
3767 u32 pl_rev;
3702 3768
3703 ret = t4_wait_dev_ready(adapter); 3769 ret = t4_wait_dev_ready(adapter);
3704 if (ret < 0) 3770 if (ret < 0)
3705 return ret; 3771 return ret;
3706 3772
3707 get_pci_mode(adapter, &adapter->params.pci); 3773 get_pci_mode(adapter, &adapter->params.pci);
3708 adapter->params.rev = t4_read_reg(adapter, PL_REV); 3774 pl_rev = G_REV(t4_read_reg(adapter, PL_REV));
3709 3775
3710 ret = get_flash_params(adapter); 3776 ret = get_flash_params(adapter);
3711 if (ret < 0) { 3777 if (ret < 0) {
@@ -3717,14 +3783,13 @@ int t4_prep_adapter(struct adapter *adapter)
3717 */ 3783 */
3718 pci_read_config_word(adapter->pdev, PCI_DEVICE_ID, &device_id); 3784 pci_read_config_word(adapter->pdev, PCI_DEVICE_ID, &device_id);
3719 ver = device_id >> 12; 3785 ver = device_id >> 12;
3786 adapter->params.chip = 0;
3720 switch (ver) { 3787 switch (ver) {
3721 case CHELSIO_T4: 3788 case CHELSIO_T4:
3722 adapter->chip = CHELSIO_CHIP_CODE(CHELSIO_T4, 3789 adapter->params.chip |= CHELSIO_CHIP_CODE(CHELSIO_T4, pl_rev);
3723 adapter->params.rev);
3724 break; 3790 break;
3725 case CHELSIO_T5: 3791 case CHELSIO_T5:
3726 adapter->chip = CHELSIO_CHIP_CODE(CHELSIO_T5, 3792 adapter->params.chip |= CHELSIO_CHIP_CODE(CHELSIO_T5, pl_rev);
3727 adapter->params.rev);
3728 break; 3793 break;
3729 default: 3794 default:
3730 dev_err(adapter->pdev_dev, "Device %d is not supported\n", 3795 dev_err(adapter->pdev_dev, "Device %d is not supported\n",
@@ -3732,9 +3797,6 @@ int t4_prep_adapter(struct adapter *adapter)
3732 return -EINVAL; 3797 return -EINVAL;
3733 } 3798 }
3734 3799
3735 /* Reassign the updated revision field */
3736 adapter->params.rev = adapter->chip;
3737
3738 init_cong_ctrl(adapter->params.a_wnd, adapter->params.b_wnd); 3800 init_cong_ctrl(adapter->params.a_wnd, adapter->params.b_wnd);
3739 3801
3740 /* 3802 /*
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h b/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h
index ef146c0ba481..0a8205d69d2c 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_regs.h
@@ -1092,6 +1092,11 @@
1092 1092
1093#define PL_REV 0x1943c 1093#define PL_REV 0x1943c
1094 1094
1095#define S_REV 0
1096#define M_REV 0xfU
1097#define V_REV(x) ((x) << S_REV)
1098#define G_REV(x) (((x) >> S_REV) & M_REV)
1099
1095#define LE_DB_CONFIG 0x19c04 1100#define LE_DB_CONFIG 0x19c04
1096#define HASHEN 0x00100000U 1101#define HASHEN 0x00100000U
1097 1102
@@ -1199,4 +1204,13 @@
1199#define EDC_STRIDE_T5 (EDC_T51_BASE_ADDR - EDC_T50_BASE_ADDR) 1204#define EDC_STRIDE_T5 (EDC_T51_BASE_ADDR - EDC_T50_BASE_ADDR)
1200#define EDC_REG_T5(reg, idx) (reg + EDC_STRIDE_T5 * idx) 1205#define EDC_REG_T5(reg, idx) (reg + EDC_STRIDE_T5 * idx)
1201 1206
1207#define A_PL_VF_REV 0x4
1208#define A_PL_VF_WHOAMI 0x0
1209#define A_PL_VF_REVISION 0x8
1210
1211#define S_CHIPID 4
1212#define M_CHIPID 0xfU
1213#define V_CHIPID(x) ((x) << S_CHIPID)
1214#define G_CHIPID(x) (((x) >> S_CHIPID) & M_CHIPID)
1215
1202#endif /* __T4_REGS_H */ 1216#endif /* __T4_REGS_H */
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
index 6f77ac487743..74fea74ce0aa 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
@@ -2157,7 +2157,7 @@ struct fw_debug_cmd {
2157 2157
2158struct fw_hdr { 2158struct fw_hdr {
2159 u8 ver; 2159 u8 ver;
2160 u8 reserved1; 2160 u8 chip; /* terminator chip type */
2161 __be16 len512; /* bin length in units of 512-bytes */ 2161 __be16 len512; /* bin length in units of 512-bytes */
2162 __be32 fw_ver; /* firmware version */ 2162 __be32 fw_ver; /* firmware version */
2163 __be32 tp_microcode_ver; 2163 __be32 tp_microcode_ver;
@@ -2176,6 +2176,11 @@ struct fw_hdr {
2176 __be32 reserved6[23]; 2176 __be32 reserved6[23];
2177}; 2177};
2178 2178
2179enum fw_hdr_chip {
2180 FW_HDR_CHIP_T4,
2181 FW_HDR_CHIP_T5
2182};
2183
2179#define FW_HDR_FW_VER_MAJOR_GET(x) (((x) >> 24) & 0xff) 2184#define FW_HDR_FW_VER_MAJOR_GET(x) (((x) >> 24) & 0xff)
2180#define FW_HDR_FW_VER_MINOR_GET(x) (((x) >> 16) & 0xff) 2185#define FW_HDR_FW_VER_MINOR_GET(x) (((x) >> 16) & 0xff)
2181#define FW_HDR_FW_VER_MICRO_GET(x) (((x) >> 8) & 0xff) 2186#define FW_HDR_FW_VER_MICRO_GET(x) (((x) >> 8) & 0xff)
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/adapter.h b/drivers/net/ethernet/chelsio/cxgb4vf/adapter.h
index be5c7ef6ca93..68eaa9c88c7d 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/adapter.h
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/adapter.h
@@ -344,7 +344,6 @@ struct adapter {
344 unsigned long registered_device_map; 344 unsigned long registered_device_map;
345 unsigned long open_device_map; 345 unsigned long open_device_map;
346 unsigned long flags; 346 unsigned long flags;
347 enum chip_type chip;
348 struct adapter_params params; 347 struct adapter_params params;
349 348
350 /* queue and interrupt resources */ 349 /* queue and interrupt resources */
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
index 5f90ec5f7519..0899c0983594 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
@@ -1064,7 +1064,7 @@ static inline unsigned int mk_adap_vers(const struct adapter *adapter)
1064 /* 1064 /*
1065 * Chip version 4, revision 0x3f (cxgb4vf). 1065 * Chip version 4, revision 0x3f (cxgb4vf).
1066 */ 1066 */
1067 return CHELSIO_CHIP_VERSION(adapter->chip) | (0x3f << 10); 1067 return CHELSIO_CHIP_VERSION(adapter->params.chip) | (0x3f << 10);
1068} 1068}
1069 1069
1070/* 1070/*
@@ -1551,9 +1551,13 @@ static void cxgb4vf_get_regs(struct net_device *dev,
1551 reg_block_dump(adapter, regbuf, 1551 reg_block_dump(adapter, regbuf,
1552 T4VF_MPS_BASE_ADDR + T4VF_MOD_MAP_MPS_FIRST, 1552 T4VF_MPS_BASE_ADDR + T4VF_MOD_MAP_MPS_FIRST,
1553 T4VF_MPS_BASE_ADDR + T4VF_MOD_MAP_MPS_LAST); 1553 T4VF_MPS_BASE_ADDR + T4VF_MOD_MAP_MPS_LAST);
1554
1555 /* T5 adds new registers in the PL Register map.
1556 */
1554 reg_block_dump(adapter, regbuf, 1557 reg_block_dump(adapter, regbuf,
1555 T4VF_PL_BASE_ADDR + T4VF_MOD_MAP_PL_FIRST, 1558 T4VF_PL_BASE_ADDR + T4VF_MOD_MAP_PL_FIRST,
1556 T4VF_PL_BASE_ADDR + T4VF_MOD_MAP_PL_LAST); 1559 T4VF_PL_BASE_ADDR + (is_t4(adapter->params.chip)
1560 ? A_PL_VF_WHOAMI : A_PL_VF_REVISION));
1557 reg_block_dump(adapter, regbuf, 1561 reg_block_dump(adapter, regbuf,
1558 T4VF_CIM_BASE_ADDR + T4VF_MOD_MAP_CIM_FIRST, 1562 T4VF_CIM_BASE_ADDR + T4VF_MOD_MAP_CIM_FIRST,
1559 T4VF_CIM_BASE_ADDR + T4VF_MOD_MAP_CIM_LAST); 1563 T4VF_CIM_BASE_ADDR + T4VF_MOD_MAP_CIM_LAST);
@@ -2087,6 +2091,7 @@ static int adap_init0(struct adapter *adapter)
2087 unsigned int ethqsets; 2091 unsigned int ethqsets;
2088 int err; 2092 int err;
2089 u32 param, val = 0; 2093 u32 param, val = 0;
2094 unsigned int chipid;
2090 2095
2091 /* 2096 /*
2092 * Wait for the device to become ready before proceeding ... 2097 * Wait for the device to become ready before proceeding ...
@@ -2114,12 +2119,14 @@ static int adap_init0(struct adapter *adapter)
2114 return err; 2119 return err;
2115 } 2120 }
2116 2121
2122 adapter->params.chip = 0;
2117 switch (adapter->pdev->device >> 12) { 2123 switch (adapter->pdev->device >> 12) {
2118 case CHELSIO_T4: 2124 case CHELSIO_T4:
2119 adapter->chip = CHELSIO_CHIP_CODE(CHELSIO_T4, 0); 2125 adapter->params.chip = CHELSIO_CHIP_CODE(CHELSIO_T4, 0);
2120 break; 2126 break;
2121 case CHELSIO_T5: 2127 case CHELSIO_T5:
2122 adapter->chip = CHELSIO_CHIP_CODE(CHELSIO_T5, 0); 2128 chipid = G_REV(t4_read_reg(adapter, A_PL_VF_REV));
2129 adapter->params.chip |= CHELSIO_CHIP_CODE(CHELSIO_T5, chipid);
2123 break; 2130 break;
2124 } 2131 }
2125 2132
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/sge.c b/drivers/net/ethernet/chelsio/cxgb4vf/sge.c
index 8475c4cda9e4..0a89963c48ce 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/sge.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/sge.c
@@ -537,7 +537,7 @@ static inline void ring_fl_db(struct adapter *adapter, struct sge_fl *fl)
537 */ 537 */
538 if (fl->pend_cred >= FL_PER_EQ_UNIT) { 538 if (fl->pend_cred >= FL_PER_EQ_UNIT) {
539 val = PIDX(fl->pend_cred / FL_PER_EQ_UNIT); 539 val = PIDX(fl->pend_cred / FL_PER_EQ_UNIT);
540 if (!is_t4(adapter->chip)) 540 if (!is_t4(adapter->params.chip))
541 val |= DBTYPE(1); 541 val |= DBTYPE(1);
542 wmb(); 542 wmb();
543 t4_write_reg(adapter, T4VF_SGE_BASE_ADDR + SGE_VF_KDOORBELL, 543 t4_write_reg(adapter, T4VF_SGE_BASE_ADDR + SGE_VF_KDOORBELL,
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h b/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h
index 53cbfed21d0b..61362450d05b 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h
@@ -39,21 +39,28 @@
39#include "../cxgb4/t4fw_api.h" 39#include "../cxgb4/t4fw_api.h"
40 40
41#define CHELSIO_CHIP_CODE(version, revision) (((version) << 4) | (revision)) 41#define CHELSIO_CHIP_CODE(version, revision) (((version) << 4) | (revision))
42#define CHELSIO_CHIP_VERSION(code) ((code) >> 4) 42#define CHELSIO_CHIP_VERSION(code) (((code) >> 4) & 0xf)
43#define CHELSIO_CHIP_RELEASE(code) ((code) & 0xf) 43#define CHELSIO_CHIP_RELEASE(code) ((code) & 0xf)
44 44
45/* All T4 and later chips have their PCI-E Device IDs encoded as 0xVFPP where:
46 *
47 * V = "4" for T4; "5" for T5, etc. or
48 * = "a" for T4 FPGA; "b" for T4 FPGA, etc.
49 * F = "0" for PF 0..3; "4".."7" for PF4..7; and "8" for VFs
50 * PP = adapter product designation
51 */
45#define CHELSIO_T4 0x4 52#define CHELSIO_T4 0x4
46#define CHELSIO_T5 0x5 53#define CHELSIO_T5 0x5
47 54
48enum chip_type { 55enum chip_type {
49 T4_A1 = CHELSIO_CHIP_CODE(CHELSIO_T4, 0), 56 T4_A1 = CHELSIO_CHIP_CODE(CHELSIO_T4, 1),
50 T4_A2 = CHELSIO_CHIP_CODE(CHELSIO_T4, 1), 57 T4_A2 = CHELSIO_CHIP_CODE(CHELSIO_T4, 2),
51 T4_A3 = CHELSIO_CHIP_CODE(CHELSIO_T4, 2),
52 T4_FIRST_REV = T4_A1, 58 T4_FIRST_REV = T4_A1,
53 T4_LAST_REV = T4_A3, 59 T4_LAST_REV = T4_A2,
54 60
55 T5_A1 = CHELSIO_CHIP_CODE(CHELSIO_T5, 0), 61 T5_A0 = CHELSIO_CHIP_CODE(CHELSIO_T5, 0),
56 T5_FIRST_REV = T5_A1, 62 T5_A1 = CHELSIO_CHIP_CODE(CHELSIO_T5, 1),
63 T5_FIRST_REV = T5_A0,
57 T5_LAST_REV = T5_A1, 64 T5_LAST_REV = T5_A1,
58}; 65};
59 66
@@ -203,6 +210,7 @@ struct adapter_params {
203 struct vpd_params vpd; /* Vital Product Data */ 210 struct vpd_params vpd; /* Vital Product Data */
204 struct rss_params rss; /* Receive Side Scaling */ 211 struct rss_params rss; /* Receive Side Scaling */
205 struct vf_resources vfres; /* Virtual Function Resource limits */ 212 struct vf_resources vfres; /* Virtual Function Resource limits */
213 enum chip_type chip; /* chip code */
206 u8 nports; /* # of Ethernet "ports" */ 214 u8 nports; /* # of Ethernet "ports" */
207}; 215};
208 216
@@ -253,7 +261,7 @@ static inline int t4vf_wr_mbox_ns(struct adapter *adapter, const void *cmd,
253 261
254static inline int is_t4(enum chip_type chip) 262static inline int is_t4(enum chip_type chip)
255{ 263{
256 return (chip >= T4_FIRST_REV && chip <= T4_LAST_REV); 264 return CHELSIO_CHIP_VERSION(chip) == CHELSIO_T4;
257} 265}
258 266
259int t4vf_wait_dev_ready(struct adapter *); 267int t4vf_wait_dev_ready(struct adapter *);
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c b/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c
index 9f96dc3bb112..d958c44341b5 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c
@@ -1027,7 +1027,7 @@ int t4vf_alloc_mac_filt(struct adapter *adapter, unsigned int viid, bool free,
1027 unsigned nfilters = 0; 1027 unsigned nfilters = 0;
1028 unsigned int rem = naddr; 1028 unsigned int rem = naddr;
1029 struct fw_vi_mac_cmd cmd, rpl; 1029 struct fw_vi_mac_cmd cmd, rpl;
1030 unsigned int max_naddr = is_t4(adapter->chip) ? 1030 unsigned int max_naddr = is_t4(adapter->params.chip) ?
1031 NUM_MPS_CLS_SRAM_L_INSTANCES : 1031 NUM_MPS_CLS_SRAM_L_INSTANCES :
1032 NUM_MPS_T5_CLS_SRAM_L_INSTANCES; 1032 NUM_MPS_T5_CLS_SRAM_L_INSTANCES;
1033 1033
@@ -1121,7 +1121,7 @@ int t4vf_change_mac(struct adapter *adapter, unsigned int viid,
1121 struct fw_vi_mac_exact *p = &cmd.u.exact[0]; 1121 struct fw_vi_mac_exact *p = &cmd.u.exact[0];
1122 size_t len16 = DIV_ROUND_UP(offsetof(struct fw_vi_mac_cmd, 1122 size_t len16 = DIV_ROUND_UP(offsetof(struct fw_vi_mac_cmd,
1123 u.exact[1]), 16); 1123 u.exact[1]), 16);
1124 unsigned int max_naddr = is_t4(adapter->chip) ? 1124 unsigned int max_naddr = is_t4(adapter->params.chip) ?
1125 NUM_MPS_CLS_SRAM_L_INSTANCES : 1125 NUM_MPS_CLS_SRAM_L_INSTANCES :
1126 NUM_MPS_T5_CLS_SRAM_L_INSTANCES; 1126 NUM_MPS_T5_CLS_SRAM_L_INSTANCES;
1127 1127
diff --git a/drivers/net/ethernet/emulex/benet/be_hw.h b/drivers/net/ethernet/emulex/benet/be_hw.h
index 3e2162121601..dc88782185f2 100644
--- a/drivers/net/ethernet/emulex/benet/be_hw.h
+++ b/drivers/net/ethernet/emulex/benet/be_hw.h
@@ -64,6 +64,9 @@
64#define SLIPORT_ERROR_NO_RESOURCE1 0x2 64#define SLIPORT_ERROR_NO_RESOURCE1 0x2
65#define SLIPORT_ERROR_NO_RESOURCE2 0x9 65#define SLIPORT_ERROR_NO_RESOURCE2 0x9
66 66
67#define SLIPORT_ERROR_FW_RESET1 0x2
68#define SLIPORT_ERROR_FW_RESET2 0x0
69
67/********* Memory BAR register ************/ 70/********* Memory BAR register ************/
68#define PCICFG_MEMBAR_CTRL_INT_CTRL_OFFSET 0xfc 71#define PCICFG_MEMBAR_CTRL_INT_CTRL_OFFSET 0xfc
69/* Host Interrupt Enable, if set interrupts are enabled although "PCI Interrupt 72/* Host Interrupt Enable, if set interrupts are enabled although "PCI Interrupt
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index fee64bf10446..0fde69d5cb6a 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -2464,8 +2464,16 @@ void be_detect_error(struct be_adapter *adapter)
2464 */ 2464 */
2465 if (sliport_status & SLIPORT_STATUS_ERR_MASK) { 2465 if (sliport_status & SLIPORT_STATUS_ERR_MASK) {
2466 adapter->hw_error = true; 2466 adapter->hw_error = true;
2467 dev_err(&adapter->pdev->dev, 2467 /* Do not log error messages if its a FW reset */
2468 "Error detected in the card\n"); 2468 if (sliport_err1 == SLIPORT_ERROR_FW_RESET1 &&
2469 sliport_err2 == SLIPORT_ERROR_FW_RESET2) {
2470 dev_info(&adapter->pdev->dev,
2471 "Firmware update in progress\n");
2472 return;
2473 } else {
2474 dev_err(&adapter->pdev->dev,
2475 "Error detected in the card\n");
2476 }
2469 } 2477 }
2470 2478
2471 if (sliport_status & SLIPORT_STATUS_ERR_MASK) { 2479 if (sliport_status & SLIPORT_STATUS_ERR_MASK) {
@@ -2932,28 +2940,35 @@ static void be_cancel_worker(struct be_adapter *adapter)
2932 } 2940 }
2933} 2941}
2934 2942
2935static int be_clear(struct be_adapter *adapter) 2943static void be_mac_clear(struct be_adapter *adapter)
2936{ 2944{
2937 int i; 2945 int i;
2938 2946
2947 if (adapter->pmac_id) {
2948 for (i = 0; i < (adapter->uc_macs + 1); i++)
2949 be_cmd_pmac_del(adapter, adapter->if_handle,
2950 adapter->pmac_id[i], 0);
2951 adapter->uc_macs = 0;
2952
2953 kfree(adapter->pmac_id);
2954 adapter->pmac_id = NULL;
2955 }
2956}
2957
2958static int be_clear(struct be_adapter *adapter)
2959{
2939 be_cancel_worker(adapter); 2960 be_cancel_worker(adapter);
2940 2961
2941 if (sriov_enabled(adapter)) 2962 if (sriov_enabled(adapter))
2942 be_vf_clear(adapter); 2963 be_vf_clear(adapter);
2943 2964
2944 /* delete the primary mac along with the uc-mac list */ 2965 /* delete the primary mac along with the uc-mac list */
2945 for (i = 0; i < (adapter->uc_macs + 1); i++) 2966 be_mac_clear(adapter);
2946 be_cmd_pmac_del(adapter, adapter->if_handle,
2947 adapter->pmac_id[i], 0);
2948 adapter->uc_macs = 0;
2949 2967
2950 be_cmd_if_destroy(adapter, adapter->if_handle, 0); 2968 be_cmd_if_destroy(adapter, adapter->if_handle, 0);
2951 2969
2952 be_clear_queues(adapter); 2970 be_clear_queues(adapter);
2953 2971
2954 kfree(adapter->pmac_id);
2955 adapter->pmac_id = NULL;
2956
2957 be_msix_disable(adapter); 2972 be_msix_disable(adapter);
2958 return 0; 2973 return 0;
2959} 2974}
@@ -3812,6 +3827,8 @@ static int lancer_fw_download(struct be_adapter *adapter,
3812 } 3827 }
3813 3828
3814 if (change_status == LANCER_FW_RESET_NEEDED) { 3829 if (change_status == LANCER_FW_RESET_NEEDED) {
3830 dev_info(&adapter->pdev->dev,
3831 "Resetting adapter to activate new FW\n");
3815 status = lancer_physdev_ctrl(adapter, 3832 status = lancer_physdev_ctrl(adapter,
3816 PHYSDEV_CONTROL_FW_RESET_MASK); 3833 PHYSDEV_CONTROL_FW_RESET_MASK);
3817 if (status) { 3834 if (status) {
@@ -4363,13 +4380,13 @@ static int lancer_recover_func(struct be_adapter *adapter)
4363 goto err; 4380 goto err;
4364 } 4381 }
4365 4382
4366 dev_err(dev, "Error recovery successful\n"); 4383 dev_err(dev, "Adapter recovery successful\n");
4367 return 0; 4384 return 0;
4368err: 4385err:
4369 if (status == -EAGAIN) 4386 if (status == -EAGAIN)
4370 dev_err(dev, "Waiting for resource provisioning\n"); 4387 dev_err(dev, "Waiting for resource provisioning\n");
4371 else 4388 else
4372 dev_err(dev, "Error recovery failed\n"); 4389 dev_err(dev, "Adapter recovery failed\n");
4373 4390
4374 return status; 4391 return status;
4375} 4392}
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 4cbebf3d80eb..e7c8b749c5a5 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -98,10 +98,6 @@ static void set_multicast_list(struct net_device *ndev);
98 * detected as not set during a prior frame transmission, then the 98 * detected as not set during a prior frame transmission, then the
99 * ENET_TDAR[TDAR] bit is cleared at a later time, even if additional TxBDs 99 * ENET_TDAR[TDAR] bit is cleared at a later time, even if additional TxBDs
100 * were added to the ring and the ENET_TDAR[TDAR] bit is set. This results in 100 * were added to the ring and the ENET_TDAR[TDAR] bit is set. This results in
101 * If the ready bit in the transmit buffer descriptor (TxBD[R]) is previously
102 * detected as not set during a prior frame transmission, then the
103 * ENET_TDAR[TDAR] bit is cleared at a later time, even if additional TxBDs
104 * were added to the ring and the ENET_TDAR[TDAR] bit is set. This results in
105 * frames not being transmitted until there is a 0-to-1 transition on 101 * frames not being transmitted until there is a 0-to-1 transition on
106 * ENET_TDAR[TDAR]. 102 * ENET_TDAR[TDAR].
107 */ 103 */
@@ -385,7 +381,7 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
385 * data. 381 * data.
386 */ 382 */
387 bdp->cbd_bufaddr = dma_map_single(&fep->pdev->dev, bufaddr, 383 bdp->cbd_bufaddr = dma_map_single(&fep->pdev->dev, bufaddr,
388 FEC_ENET_TX_FRSIZE, DMA_TO_DEVICE); 384 skb->len, DMA_TO_DEVICE);
389 if (dma_mapping_error(&fep->pdev->dev, bdp->cbd_bufaddr)) { 385 if (dma_mapping_error(&fep->pdev->dev, bdp->cbd_bufaddr)) {
390 bdp->cbd_bufaddr = 0; 386 bdp->cbd_bufaddr = 0;
391 fep->tx_skbuff[index] = NULL; 387 fep->tx_skbuff[index] = NULL;
@@ -779,11 +775,10 @@ fec_enet_tx(struct net_device *ndev)
779 else 775 else
780 index = bdp - fep->tx_bd_base; 776 index = bdp - fep->tx_bd_base;
781 777
782 dma_unmap_single(&fep->pdev->dev, bdp->cbd_bufaddr,
783 FEC_ENET_TX_FRSIZE, DMA_TO_DEVICE);
784 bdp->cbd_bufaddr = 0;
785
786 skb = fep->tx_skbuff[index]; 778 skb = fep->tx_skbuff[index];
779 dma_unmap_single(&fep->pdev->dev, bdp->cbd_bufaddr, skb->len,
780 DMA_TO_DEVICE);
781 bdp->cbd_bufaddr = 0;
787 782
788 /* Check for errors. */ 783 /* Check for errors. */
789 if (status & (BD_ENET_TX_HB | BD_ENET_TX_LC | 784 if (status & (BD_ENET_TX_HB | BD_ENET_TX_LC |
diff --git a/drivers/net/ethernet/ibm/ehea/ehea_main.c b/drivers/net/ethernet/ibm/ehea/ehea_main.c
index 2d1c6bdd3618..7628e0fd8455 100644
--- a/drivers/net/ethernet/ibm/ehea/ehea_main.c
+++ b/drivers/net/ethernet/ibm/ehea/ehea_main.c
@@ -3033,7 +3033,7 @@ static struct ehea_port *ehea_setup_single_port(struct ehea_adapter *adapter,
3033 3033
3034 dev->hw_features = NETIF_F_SG | NETIF_F_TSO | 3034 dev->hw_features = NETIF_F_SG | NETIF_F_TSO |
3035 NETIF_F_IP_CSUM | NETIF_F_HW_VLAN_CTAG_TX; 3035 NETIF_F_IP_CSUM | NETIF_F_HW_VLAN_CTAG_TX;
3036 dev->features = NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_TSO | 3036 dev->features = NETIF_F_SG | NETIF_F_TSO |
3037 NETIF_F_HIGHDMA | NETIF_F_IP_CSUM | 3037 NETIF_F_HIGHDMA | NETIF_F_IP_CSUM |
3038 NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX | 3038 NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX |
3039 NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_RXCSUM; 3039 NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_RXCSUM;
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index be15938ba213..12b0932204ba 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -354,6 +354,9 @@ static struct rtnl_link_stats64 *i40e_get_netdev_stats_struct(
354 struct rtnl_link_stats64 *vsi_stats = i40e_get_vsi_stats_struct(vsi); 354 struct rtnl_link_stats64 *vsi_stats = i40e_get_vsi_stats_struct(vsi);
355 int i; 355 int i;
356 356
357 if (!vsi->tx_rings)
358 return stats;
359
357 rcu_read_lock(); 360 rcu_read_lock();
358 for (i = 0; i < vsi->num_queue_pairs; i++) { 361 for (i = 0; i < vsi->num_queue_pairs; i++) {
359 struct i40e_ring *tx_ring, *rx_ring; 362 struct i40e_ring *tx_ring, *rx_ring;
diff --git a/drivers/net/ethernet/intel/igb/e1000_phy.c b/drivers/net/ethernet/intel/igb/e1000_phy.c
index c4c4fe332c7e..ad2b74d95138 100644
--- a/drivers/net/ethernet/intel/igb/e1000_phy.c
+++ b/drivers/net/ethernet/intel/igb/e1000_phy.c
@@ -1728,7 +1728,10 @@ s32 igb_phy_has_link(struct e1000_hw *hw, u32 iterations,
1728 * ownership of the resources, wait and try again to 1728 * ownership of the resources, wait and try again to
1729 * see if they have relinquished the resources yet. 1729 * see if they have relinquished the resources yet.
1730 */ 1730 */
1731 udelay(usec_interval); 1731 if (usec_interval >= 1000)
1732 mdelay(usec_interval/1000);
1733 else
1734 udelay(usec_interval);
1732 } 1735 }
1733 ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &phy_status); 1736 ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &phy_status);
1734 if (ret_val) 1737 if (ret_val)
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index b8e232b4ea2d..d5f0d72e5e33 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -1378,7 +1378,7 @@ static void mvneta_rxq_drop_pkts(struct mvneta_port *pp,
1378 1378
1379 dev_kfree_skb_any(skb); 1379 dev_kfree_skb_any(skb);
1380 dma_unmap_single(pp->dev->dev.parent, rx_desc->buf_phys_addr, 1380 dma_unmap_single(pp->dev->dev.parent, rx_desc->buf_phys_addr,
1381 rx_desc->data_size, DMA_FROM_DEVICE); 1381 MVNETA_RX_BUF_SIZE(pp->pkt_size), DMA_FROM_DEVICE);
1382 } 1382 }
1383 1383
1384 if (rx_done) 1384 if (rx_done)
@@ -1424,7 +1424,7 @@ static int mvneta_rx(struct mvneta_port *pp, int rx_todo,
1424 } 1424 }
1425 1425
1426 dma_unmap_single(pp->dev->dev.parent, rx_desc->buf_phys_addr, 1426 dma_unmap_single(pp->dev->dev.parent, rx_desc->buf_phys_addr,
1427 rx_desc->data_size, DMA_FROM_DEVICE); 1427 MVNETA_RX_BUF_SIZE(pp->pkt_size), DMA_FROM_DEVICE);
1428 1428
1429 rx_bytes = rx_desc->data_size - 1429 rx_bytes = rx_desc->data_size -
1430 (ETH_FCS_LEN + MVNETA_MH_SIZE); 1430 (ETH_FCS_LEN + MVNETA_MH_SIZE);
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 5789ea2c934d..01fc6515384d 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -2635,6 +2635,8 @@ static int __init mlx4_init(void)
2635 return -ENOMEM; 2635 return -ENOMEM;
2636 2636
2637 ret = pci_register_driver(&mlx4_driver); 2637 ret = pci_register_driver(&mlx4_driver);
2638 if (ret < 0)
2639 destroy_workqueue(mlx4_wq);
2638 return ret < 0 ? ret : 0; 2640 return ret < 0 ? ret : 0;
2639} 2641}
2640 2642
diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c
index 2d045be4b5cf..1e8b9514718b 100644
--- a/drivers/net/ethernet/nvidia/forcedeth.c
+++ b/drivers/net/ethernet/nvidia/forcedeth.c
@@ -5150,8 +5150,10 @@ static void nv_self_test(struct net_device *dev, struct ethtool_test *test, u64
5150{ 5150{
5151 struct fe_priv *np = netdev_priv(dev); 5151 struct fe_priv *np = netdev_priv(dev);
5152 u8 __iomem *base = get_hwbase(dev); 5152 u8 __iomem *base = get_hwbase(dev);
5153 int result; 5153 int result, count;
5154 memset(buffer, 0, nv_get_sset_count(dev, ETH_SS_TEST)*sizeof(u64)); 5154
5155 count = nv_get_sset_count(dev, ETH_SS_TEST);
5156 memset(buffer, 0, count * sizeof(u64));
5155 5157
5156 if (!nv_link_test(dev)) { 5158 if (!nv_link_test(dev)) {
5157 test->flags |= ETH_TEST_FL_FAILED; 5159 test->flags |= ETH_TEST_FL_FAILED;
@@ -5195,7 +5197,7 @@ static void nv_self_test(struct net_device *dev, struct ethtool_test *test, u64
5195 return; 5197 return;
5196 } 5198 }
5197 5199
5198 if (!nv_loopback_test(dev)) { 5200 if (count > NV_TEST_COUNT_BASE && !nv_loopback_test(dev)) {
5199 test->flags |= ETH_TEST_FL_FAILED; 5201 test->flags |= ETH_TEST_FL_FAILED;
5200 buffer[3] = 1; 5202 buffer[3] = 1;
5201 } 5203 }
diff --git a/drivers/net/ethernet/qlogic/qlge/qlge.h b/drivers/net/ethernet/qlogic/qlge/qlge.h
index 0c9c4e895595..03517478e589 100644
--- a/drivers/net/ethernet/qlogic/qlge/qlge.h
+++ b/drivers/net/ethernet/qlogic/qlge/qlge.h
@@ -18,7 +18,7 @@
18 */ 18 */
19#define DRV_NAME "qlge" 19#define DRV_NAME "qlge"
20#define DRV_STRING "QLogic 10 Gigabit PCI-E Ethernet Driver " 20#define DRV_STRING "QLogic 10 Gigabit PCI-E Ethernet Driver "
21#define DRV_VERSION "1.00.00.33" 21#define DRV_VERSION "1.00.00.34"
22 22
23#define WQ_ADDR_ALIGN 0x3 /* 4 byte alignment */ 23#define WQ_ADDR_ALIGN 0x3 /* 4 byte alignment */
24 24
diff --git a/drivers/net/ethernet/qlogic/qlge/qlge_ethtool.c b/drivers/net/ethernet/qlogic/qlge/qlge_ethtool.c
index 0780e039b271..8dee1beb9854 100644
--- a/drivers/net/ethernet/qlogic/qlge/qlge_ethtool.c
+++ b/drivers/net/ethernet/qlogic/qlge/qlge_ethtool.c
@@ -181,6 +181,7 @@ static const char ql_gstrings_test[][ETH_GSTRING_LEN] = {
181}; 181};
182#define QLGE_TEST_LEN (sizeof(ql_gstrings_test) / ETH_GSTRING_LEN) 182#define QLGE_TEST_LEN (sizeof(ql_gstrings_test) / ETH_GSTRING_LEN)
183#define QLGE_STATS_LEN ARRAY_SIZE(ql_gstrings_stats) 183#define QLGE_STATS_LEN ARRAY_SIZE(ql_gstrings_stats)
184#define QLGE_RCV_MAC_ERR_STATS 7
184 185
185static int ql_update_ring_coalescing(struct ql_adapter *qdev) 186static int ql_update_ring_coalescing(struct ql_adapter *qdev)
186{ 187{
@@ -280,6 +281,9 @@ static void ql_update_stats(struct ql_adapter *qdev)
280 iter++; 281 iter++;
281 } 282 }
282 283
284 /* Update receive mac error statistics */
285 iter += QLGE_RCV_MAC_ERR_STATS;
286
283 /* 287 /*
284 * Get Per-priority TX pause frame counter statistics. 288 * Get Per-priority TX pause frame counter statistics.
285 */ 289 */
diff --git a/drivers/net/ethernet/qlogic/qlge/qlge_main.c b/drivers/net/ethernet/qlogic/qlge/qlge_main.c
index a245dc18d769..449f506d2e8f 100644
--- a/drivers/net/ethernet/qlogic/qlge/qlge_main.c
+++ b/drivers/net/ethernet/qlogic/qlge/qlge_main.c
@@ -2376,14 +2376,6 @@ static netdev_features_t qlge_fix_features(struct net_device *ndev,
2376 netdev_features_t features) 2376 netdev_features_t features)
2377{ 2377{
2378 int err; 2378 int err;
2379 /*
2380 * Since there is no support for separate rx/tx vlan accel
2381 * enable/disable make sure tx flag is always in same state as rx.
2382 */
2383 if (features & NETIF_F_HW_VLAN_CTAG_RX)
2384 features |= NETIF_F_HW_VLAN_CTAG_TX;
2385 else
2386 features &= ~NETIF_F_HW_VLAN_CTAG_TX;
2387 2379
2388 /* Update the behavior of vlan accel in the adapter */ 2380 /* Update the behavior of vlan accel in the adapter */
2389 err = qlge_update_hw_vlan_features(ndev, features); 2381 err = qlge_update_hw_vlan_features(ndev, features);
diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c
index 2e27837ce6a2..fd844b53e385 100644
--- a/drivers/net/ethernet/sfc/efx.c
+++ b/drivers/net/ethernet/sfc/efx.c
@@ -585,7 +585,7 @@ static void efx_start_datapath(struct efx_nic *efx)
585 EFX_MAX_FRAME_LEN(efx->net_dev->mtu) + 585 EFX_MAX_FRAME_LEN(efx->net_dev->mtu) +
586 efx->type->rx_buffer_padding); 586 efx->type->rx_buffer_padding);
587 rx_buf_len = (sizeof(struct efx_rx_page_state) + 587 rx_buf_len = (sizeof(struct efx_rx_page_state) +
588 NET_IP_ALIGN + efx->rx_dma_len); 588 efx->rx_ip_align + efx->rx_dma_len);
589 if (rx_buf_len <= PAGE_SIZE) { 589 if (rx_buf_len <= PAGE_SIZE) {
590 efx->rx_scatter = efx->type->always_rx_scatter; 590 efx->rx_scatter = efx->type->always_rx_scatter;
591 efx->rx_buffer_order = 0; 591 efx->rx_buffer_order = 0;
@@ -645,6 +645,8 @@ static void efx_start_datapath(struct efx_nic *efx)
645 WARN_ON(channel->rx_pkt_n_frags); 645 WARN_ON(channel->rx_pkt_n_frags);
646 } 646 }
647 647
648 efx_ptp_start_datapath(efx);
649
648 if (netif_device_present(efx->net_dev)) 650 if (netif_device_present(efx->net_dev))
649 netif_tx_wake_all_queues(efx->net_dev); 651 netif_tx_wake_all_queues(efx->net_dev);
650} 652}
@@ -659,6 +661,8 @@ static void efx_stop_datapath(struct efx_nic *efx)
659 EFX_ASSERT_RESET_SERIALISED(efx); 661 EFX_ASSERT_RESET_SERIALISED(efx);
660 BUG_ON(efx->port_enabled); 662 BUG_ON(efx->port_enabled);
661 663
664 efx_ptp_stop_datapath(efx);
665
662 /* Stop RX refill */ 666 /* Stop RX refill */
663 efx_for_each_channel(channel, efx) { 667 efx_for_each_channel(channel, efx) {
664 efx_for_each_channel_rx_queue(rx_queue, channel) 668 efx_for_each_channel_rx_queue(rx_queue, channel)
@@ -2540,6 +2544,8 @@ static int efx_init_struct(struct efx_nic *efx,
2540 2544
2541 efx->net_dev = net_dev; 2545 efx->net_dev = net_dev;
2542 efx->rx_prefix_size = efx->type->rx_prefix_size; 2546 efx->rx_prefix_size = efx->type->rx_prefix_size;
2547 efx->rx_ip_align =
2548 NET_IP_ALIGN ? (efx->rx_prefix_size + NET_IP_ALIGN) % 4 : 0;
2543 efx->rx_packet_hash_offset = 2549 efx->rx_packet_hash_offset =
2544 efx->type->rx_hash_offset - efx->type->rx_prefix_size; 2550 efx->type->rx_hash_offset - efx->type->rx_prefix_size;
2545 spin_lock_init(&efx->stats_lock); 2551 spin_lock_init(&efx->stats_lock);
diff --git a/drivers/net/ethernet/sfc/mcdi.c b/drivers/net/ethernet/sfc/mcdi.c
index 366c8e3e3784..4b0bd8a1514d 100644
--- a/drivers/net/ethernet/sfc/mcdi.c
+++ b/drivers/net/ethernet/sfc/mcdi.c
@@ -50,6 +50,7 @@ struct efx_mcdi_async_param {
50static void efx_mcdi_timeout_async(unsigned long context); 50static void efx_mcdi_timeout_async(unsigned long context);
51static int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating, 51static int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating,
52 bool *was_attached_out); 52 bool *was_attached_out);
53static bool efx_mcdi_poll_once(struct efx_nic *efx);
53 54
54static inline struct efx_mcdi_iface *efx_mcdi(struct efx_nic *efx) 55static inline struct efx_mcdi_iface *efx_mcdi(struct efx_nic *efx)
55{ 56{
@@ -237,6 +238,21 @@ static void efx_mcdi_read_response_header(struct efx_nic *efx)
237 } 238 }
238} 239}
239 240
241static bool efx_mcdi_poll_once(struct efx_nic *efx)
242{
243 struct efx_mcdi_iface *mcdi = efx_mcdi(efx);
244
245 rmb();
246 if (!efx->type->mcdi_poll_response(efx))
247 return false;
248
249 spin_lock_bh(&mcdi->iface_lock);
250 efx_mcdi_read_response_header(efx);
251 spin_unlock_bh(&mcdi->iface_lock);
252
253 return true;
254}
255
240static int efx_mcdi_poll(struct efx_nic *efx) 256static int efx_mcdi_poll(struct efx_nic *efx)
241{ 257{
242 struct efx_mcdi_iface *mcdi = efx_mcdi(efx); 258 struct efx_mcdi_iface *mcdi = efx_mcdi(efx);
@@ -272,18 +288,13 @@ static int efx_mcdi_poll(struct efx_nic *efx)
272 288
273 time = jiffies; 289 time = jiffies;
274 290
275 rmb(); 291 if (efx_mcdi_poll_once(efx))
276 if (efx->type->mcdi_poll_response(efx))
277 break; 292 break;
278 293
279 if (time_after(time, finish)) 294 if (time_after(time, finish))
280 return -ETIMEDOUT; 295 return -ETIMEDOUT;
281 } 296 }
282 297
283 spin_lock_bh(&mcdi->iface_lock);
284 efx_mcdi_read_response_header(efx);
285 spin_unlock_bh(&mcdi->iface_lock);
286
287 /* Return rc=0 like wait_event_timeout() */ 298 /* Return rc=0 like wait_event_timeout() */
288 return 0; 299 return 0;
289} 300}
@@ -619,6 +630,16 @@ int efx_mcdi_rpc_finish(struct efx_nic *efx, unsigned cmd, size_t inlen,
619 rc = efx_mcdi_await_completion(efx); 630 rc = efx_mcdi_await_completion(efx);
620 631
621 if (rc != 0) { 632 if (rc != 0) {
633 netif_err(efx, hw, efx->net_dev,
634 "MC command 0x%x inlen %d mode %d timed out\n",
635 cmd, (int)inlen, mcdi->mode);
636
637 if (mcdi->mode == MCDI_MODE_EVENTS && efx_mcdi_poll_once(efx)) {
638 netif_err(efx, hw, efx->net_dev,
639 "MCDI request was completed without an event\n");
640 rc = 0;
641 }
642
622 /* Close the race with efx_mcdi_ev_cpl() executing just too late 643 /* Close the race with efx_mcdi_ev_cpl() executing just too late
623 * and completing a request we've just cancelled, by ensuring 644 * and completing a request we've just cancelled, by ensuring
624 * that the seqno check therein fails. 645 * that the seqno check therein fails.
@@ -627,11 +648,9 @@ int efx_mcdi_rpc_finish(struct efx_nic *efx, unsigned cmd, size_t inlen,
627 ++mcdi->seqno; 648 ++mcdi->seqno;
628 ++mcdi->credits; 649 ++mcdi->credits;
629 spin_unlock_bh(&mcdi->iface_lock); 650 spin_unlock_bh(&mcdi->iface_lock);
651 }
630 652
631 netif_err(efx, hw, efx->net_dev, 653 if (rc == 0) {
632 "MC command 0x%x inlen %d mode %d timed out\n",
633 cmd, (int)inlen, mcdi->mode);
634 } else {
635 size_t hdr_len, data_len; 654 size_t hdr_len, data_len;
636 655
637 /* At the very least we need a memory barrier here to ensure 656 /* At the very least we need a memory barrier here to ensure
diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h
index b14a717ac3e8..542a0d252ae0 100644
--- a/drivers/net/ethernet/sfc/net_driver.h
+++ b/drivers/net/ethernet/sfc/net_driver.h
@@ -683,6 +683,8 @@ struct vfdi_status;
683 * @n_channels: Number of channels in use 683 * @n_channels: Number of channels in use
684 * @n_rx_channels: Number of channels used for RX (= number of RX queues) 684 * @n_rx_channels: Number of channels used for RX (= number of RX queues)
685 * @n_tx_channels: Number of channels used for TX 685 * @n_tx_channels: Number of channels used for TX
686 * @rx_ip_align: RX DMA address offset to have IP header aligned in
687 * in accordance with NET_IP_ALIGN
686 * @rx_dma_len: Current maximum RX DMA length 688 * @rx_dma_len: Current maximum RX DMA length
687 * @rx_buffer_order: Order (log2) of number of pages for each RX buffer 689 * @rx_buffer_order: Order (log2) of number of pages for each RX buffer
688 * @rx_buffer_truesize: Amortised allocation size of an RX buffer, 690 * @rx_buffer_truesize: Amortised allocation size of an RX buffer,
@@ -816,6 +818,7 @@ struct efx_nic {
816 unsigned rss_spread; 818 unsigned rss_spread;
817 unsigned tx_channel_offset; 819 unsigned tx_channel_offset;
818 unsigned n_tx_channels; 820 unsigned n_tx_channels;
821 unsigned int rx_ip_align;
819 unsigned int rx_dma_len; 822 unsigned int rx_dma_len;
820 unsigned int rx_buffer_order; 823 unsigned int rx_buffer_order;
821 unsigned int rx_buffer_truesize; 824 unsigned int rx_buffer_truesize;
diff --git a/drivers/net/ethernet/sfc/nic.h b/drivers/net/ethernet/sfc/nic.h
index 11b6112d9249..91c63ec79c5f 100644
--- a/drivers/net/ethernet/sfc/nic.h
+++ b/drivers/net/ethernet/sfc/nic.h
@@ -560,6 +560,8 @@ void efx_ptp_get_ts_info(struct efx_nic *efx, struct ethtool_ts_info *ts_info);
560bool efx_ptp_is_ptp_tx(struct efx_nic *efx, struct sk_buff *skb); 560bool efx_ptp_is_ptp_tx(struct efx_nic *efx, struct sk_buff *skb);
561int efx_ptp_tx(struct efx_nic *efx, struct sk_buff *skb); 561int efx_ptp_tx(struct efx_nic *efx, struct sk_buff *skb);
562void efx_ptp_event(struct efx_nic *efx, efx_qword_t *ev); 562void efx_ptp_event(struct efx_nic *efx, efx_qword_t *ev);
563void efx_ptp_start_datapath(struct efx_nic *efx);
564void efx_ptp_stop_datapath(struct efx_nic *efx);
563 565
564extern const struct efx_nic_type falcon_a1_nic_type; 566extern const struct efx_nic_type falcon_a1_nic_type;
565extern const struct efx_nic_type falcon_b0_nic_type; 567extern const struct efx_nic_type falcon_b0_nic_type;
diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
index 03acf57df045..3dd39dcfe36b 100644
--- a/drivers/net/ethernet/sfc/ptp.c
+++ b/drivers/net/ethernet/sfc/ptp.c
@@ -220,6 +220,7 @@ struct efx_ptp_timeset {
220 * @evt_list: List of MC receive events awaiting packets 220 * @evt_list: List of MC receive events awaiting packets
221 * @evt_free_list: List of free events 221 * @evt_free_list: List of free events
222 * @evt_lock: Lock for manipulating evt_list and evt_free_list 222 * @evt_lock: Lock for manipulating evt_list and evt_free_list
223 * @evt_overflow: Boolean indicating that event list has overflowed
223 * @rx_evts: Instantiated events (on evt_list and evt_free_list) 224 * @rx_evts: Instantiated events (on evt_list and evt_free_list)
224 * @workwq: Work queue for processing pending PTP operations 225 * @workwq: Work queue for processing pending PTP operations
225 * @work: Work task 226 * @work: Work task
@@ -270,6 +271,7 @@ struct efx_ptp_data {
270 struct list_head evt_list; 271 struct list_head evt_list;
271 struct list_head evt_free_list; 272 struct list_head evt_free_list;
272 spinlock_t evt_lock; 273 spinlock_t evt_lock;
274 bool evt_overflow;
273 struct efx_ptp_event_rx rx_evts[MAX_RECEIVE_EVENTS]; 275 struct efx_ptp_event_rx rx_evts[MAX_RECEIVE_EVENTS];
274 struct workqueue_struct *workwq; 276 struct workqueue_struct *workwq;
275 struct work_struct work; 277 struct work_struct work;
@@ -635,6 +637,11 @@ static void efx_ptp_drop_time_expired_events(struct efx_nic *efx)
635 } 637 }
636 } 638 }
637 } 639 }
640 /* If the event overflow flag is set and the event list is now empty
641 * clear the flag to re-enable the overflow warning message.
642 */
643 if (ptp->evt_overflow && list_empty(&ptp->evt_list))
644 ptp->evt_overflow = false;
638 spin_unlock_bh(&ptp->evt_lock); 645 spin_unlock_bh(&ptp->evt_lock);
639} 646}
640 647
@@ -676,6 +683,11 @@ static enum ptp_packet_state efx_ptp_match_rx(struct efx_nic *efx,
676 break; 683 break;
677 } 684 }
678 } 685 }
686 /* If the event overflow flag is set and the event list is now empty
687 * clear the flag to re-enable the overflow warning message.
688 */
689 if (ptp->evt_overflow && list_empty(&ptp->evt_list))
690 ptp->evt_overflow = false;
679 spin_unlock_bh(&ptp->evt_lock); 691 spin_unlock_bh(&ptp->evt_lock);
680 692
681 return rc; 693 return rc;
@@ -705,8 +717,9 @@ static bool efx_ptp_process_events(struct efx_nic *efx, struct sk_buff_head *q)
705 __skb_queue_tail(q, skb); 717 __skb_queue_tail(q, skb);
706 } else if (time_after(jiffies, match->expiry)) { 718 } else if (time_after(jiffies, match->expiry)) {
707 match->state = PTP_PACKET_STATE_TIMED_OUT; 719 match->state = PTP_PACKET_STATE_TIMED_OUT;
708 netif_warn(efx, rx_err, efx->net_dev, 720 if (net_ratelimit())
709 "PTP packet - no timestamp seen\n"); 721 netif_warn(efx, rx_err, efx->net_dev,
722 "PTP packet - no timestamp seen\n");
710 __skb_queue_tail(q, skb); 723 __skb_queue_tail(q, skb);
711 } else { 724 } else {
712 /* Replace unprocessed entry and stop */ 725 /* Replace unprocessed entry and stop */
@@ -788,9 +801,14 @@ fail:
788static int efx_ptp_stop(struct efx_nic *efx) 801static int efx_ptp_stop(struct efx_nic *efx)
789{ 802{
790 struct efx_ptp_data *ptp = efx->ptp_data; 803 struct efx_ptp_data *ptp = efx->ptp_data;
791 int rc = efx_ptp_disable(efx);
792 struct list_head *cursor; 804 struct list_head *cursor;
793 struct list_head *next; 805 struct list_head *next;
806 int rc;
807
808 if (ptp == NULL)
809 return 0;
810
811 rc = efx_ptp_disable(efx);
794 812
795 if (ptp->rxfilter_installed) { 813 if (ptp->rxfilter_installed) {
796 efx_filter_remove_id_safe(efx, EFX_FILTER_PRI_REQUIRED, 814 efx_filter_remove_id_safe(efx, EFX_FILTER_PRI_REQUIRED,
@@ -809,11 +827,19 @@ static int efx_ptp_stop(struct efx_nic *efx)
809 list_for_each_safe(cursor, next, &efx->ptp_data->evt_list) { 827 list_for_each_safe(cursor, next, &efx->ptp_data->evt_list) {
810 list_move(cursor, &efx->ptp_data->evt_free_list); 828 list_move(cursor, &efx->ptp_data->evt_free_list);
811 } 829 }
830 ptp->evt_overflow = false;
812 spin_unlock_bh(&efx->ptp_data->evt_lock); 831 spin_unlock_bh(&efx->ptp_data->evt_lock);
813 832
814 return rc; 833 return rc;
815} 834}
816 835
836static int efx_ptp_restart(struct efx_nic *efx)
837{
838 if (efx->ptp_data && efx->ptp_data->enabled)
839 return efx_ptp_start(efx);
840 return 0;
841}
842
817static void efx_ptp_pps_worker(struct work_struct *work) 843static void efx_ptp_pps_worker(struct work_struct *work)
818{ 844{
819 struct efx_ptp_data *ptp = 845 struct efx_ptp_data *ptp =
@@ -901,6 +927,7 @@ static int efx_ptp_probe_channel(struct efx_channel *channel)
901 spin_lock_init(&ptp->evt_lock); 927 spin_lock_init(&ptp->evt_lock);
902 for (pos = 0; pos < MAX_RECEIVE_EVENTS; pos++) 928 for (pos = 0; pos < MAX_RECEIVE_EVENTS; pos++)
903 list_add(&ptp->rx_evts[pos].link, &ptp->evt_free_list); 929 list_add(&ptp->rx_evts[pos].link, &ptp->evt_free_list);
930 ptp->evt_overflow = false;
904 931
905 ptp->phc_clock_info.owner = THIS_MODULE; 932 ptp->phc_clock_info.owner = THIS_MODULE;
906 snprintf(ptp->phc_clock_info.name, 933 snprintf(ptp->phc_clock_info.name,
@@ -989,7 +1016,11 @@ bool efx_ptp_is_ptp_tx(struct efx_nic *efx, struct sk_buff *skb)
989 skb->len >= PTP_MIN_LENGTH && 1016 skb->len >= PTP_MIN_LENGTH &&
990 skb->len <= MC_CMD_PTP_IN_TRANSMIT_PACKET_MAXNUM && 1017 skb->len <= MC_CMD_PTP_IN_TRANSMIT_PACKET_MAXNUM &&
991 likely(skb->protocol == htons(ETH_P_IP)) && 1018 likely(skb->protocol == htons(ETH_P_IP)) &&
1019 skb_transport_header_was_set(skb) &&
1020 skb_network_header_len(skb) >= sizeof(struct iphdr) &&
992 ip_hdr(skb)->protocol == IPPROTO_UDP && 1021 ip_hdr(skb)->protocol == IPPROTO_UDP &&
1022 skb_headlen(skb) >=
1023 skb_transport_offset(skb) + sizeof(struct udphdr) &&
993 udp_hdr(skb)->dest == htons(PTP_EVENT_PORT); 1024 udp_hdr(skb)->dest == htons(PTP_EVENT_PORT);
994} 1025}
995 1026
@@ -1106,7 +1137,7 @@ static int efx_ptp_change_mode(struct efx_nic *efx, bool enable_wanted,
1106{ 1137{
1107 if ((enable_wanted != efx->ptp_data->enabled) || 1138 if ((enable_wanted != efx->ptp_data->enabled) ||
1108 (enable_wanted && (efx->ptp_data->mode != new_mode))) { 1139 (enable_wanted && (efx->ptp_data->mode != new_mode))) {
1109 int rc; 1140 int rc = 0;
1110 1141
1111 if (enable_wanted) { 1142 if (enable_wanted) {
1112 /* Change of mode requires disable */ 1143 /* Change of mode requires disable */
@@ -1123,7 +1154,8 @@ static int efx_ptp_change_mode(struct efx_nic *efx, bool enable_wanted,
1123 * succeed. 1154 * succeed.
1124 */ 1155 */
1125 efx->ptp_data->mode = new_mode; 1156 efx->ptp_data->mode = new_mode;
1126 rc = efx_ptp_start(efx); 1157 if (netif_running(efx->net_dev))
1158 rc = efx_ptp_start(efx);
1127 if (rc == 0) { 1159 if (rc == 0) {
1128 rc = efx_ptp_synchronize(efx, 1160 rc = efx_ptp_synchronize(efx,
1129 PTP_SYNC_ATTEMPTS * 2); 1161 PTP_SYNC_ATTEMPTS * 2);
@@ -1295,8 +1327,13 @@ static void ptp_event_rx(struct efx_nic *efx, struct efx_ptp_data *ptp)
1295 list_add_tail(&evt->link, &ptp->evt_list); 1327 list_add_tail(&evt->link, &ptp->evt_list);
1296 1328
1297 queue_work(ptp->workwq, &ptp->work); 1329 queue_work(ptp->workwq, &ptp->work);
1298 } else { 1330 } else if (!ptp->evt_overflow) {
1299 netif_err(efx, rx_err, efx->net_dev, "No free PTP event"); 1331 /* Log a warning message and set the event overflow flag.
1332 * The message won't be logged again until the event queue
1333 * becomes empty.
1334 */
1335 netif_err(efx, rx_err, efx->net_dev, "PTP event queue overflow\n");
1336 ptp->evt_overflow = true;
1300 } 1337 }
1301 spin_unlock_bh(&ptp->evt_lock); 1338 spin_unlock_bh(&ptp->evt_lock);
1302} 1339}
@@ -1389,7 +1426,7 @@ static int efx_phc_adjfreq(struct ptp_clock_info *ptp, s32 delta)
1389 if (rc != 0) 1426 if (rc != 0)
1390 return rc; 1427 return rc;
1391 1428
1392 ptp_data->current_adjfreq = delta; 1429 ptp_data->current_adjfreq = adjustment_ns;
1393 return 0; 1430 return 0;
1394} 1431}
1395 1432
@@ -1404,7 +1441,7 @@ static int efx_phc_adjtime(struct ptp_clock_info *ptp, s64 delta)
1404 1441
1405 MCDI_SET_DWORD(inbuf, PTP_IN_OP, MC_CMD_PTP_OP_ADJUST); 1442 MCDI_SET_DWORD(inbuf, PTP_IN_OP, MC_CMD_PTP_OP_ADJUST);
1406 MCDI_SET_DWORD(inbuf, PTP_IN_PERIPH_ID, 0); 1443 MCDI_SET_DWORD(inbuf, PTP_IN_PERIPH_ID, 0);
1407 MCDI_SET_QWORD(inbuf, PTP_IN_ADJUST_FREQ, 0); 1444 MCDI_SET_QWORD(inbuf, PTP_IN_ADJUST_FREQ, ptp_data->current_adjfreq);
1408 MCDI_SET_DWORD(inbuf, PTP_IN_ADJUST_SECONDS, (u32)delta_ts.tv_sec); 1445 MCDI_SET_DWORD(inbuf, PTP_IN_ADJUST_SECONDS, (u32)delta_ts.tv_sec);
1409 MCDI_SET_DWORD(inbuf, PTP_IN_ADJUST_NANOSECONDS, (u32)delta_ts.tv_nsec); 1446 MCDI_SET_DWORD(inbuf, PTP_IN_ADJUST_NANOSECONDS, (u32)delta_ts.tv_nsec);
1410 return efx_mcdi_rpc(efx, MC_CMD_PTP, inbuf, sizeof(inbuf), 1447 return efx_mcdi_rpc(efx, MC_CMD_PTP, inbuf, sizeof(inbuf),
@@ -1491,3 +1528,14 @@ void efx_ptp_probe(struct efx_nic *efx)
1491 efx->extra_channel_type[EFX_EXTRA_CHANNEL_PTP] = 1528 efx->extra_channel_type[EFX_EXTRA_CHANNEL_PTP] =
1492 &efx_ptp_channel_type; 1529 &efx_ptp_channel_type;
1493} 1530}
1531
1532void efx_ptp_start_datapath(struct efx_nic *efx)
1533{
1534 if (efx_ptp_restart(efx))
1535 netif_err(efx, drv, efx->net_dev, "Failed to restart PTP.\n");
1536}
1537
1538void efx_ptp_stop_datapath(struct efx_nic *efx)
1539{
1540 efx_ptp_stop(efx);
1541}
diff --git a/drivers/net/ethernet/sfc/rx.c b/drivers/net/ethernet/sfc/rx.c
index 8f09e686fc23..42488df1f4ec 100644
--- a/drivers/net/ethernet/sfc/rx.c
+++ b/drivers/net/ethernet/sfc/rx.c
@@ -94,7 +94,7 @@ static inline void efx_sync_rx_buffer(struct efx_nic *efx,
94 94
95void efx_rx_config_page_split(struct efx_nic *efx) 95void efx_rx_config_page_split(struct efx_nic *efx)
96{ 96{
97 efx->rx_page_buf_step = ALIGN(efx->rx_dma_len + NET_IP_ALIGN, 97 efx->rx_page_buf_step = ALIGN(efx->rx_dma_len + efx->rx_ip_align,
98 EFX_RX_BUF_ALIGNMENT); 98 EFX_RX_BUF_ALIGNMENT);
99 efx->rx_bufs_per_page = efx->rx_buffer_order ? 1 : 99 efx->rx_bufs_per_page = efx->rx_buffer_order ? 1 :
100 ((PAGE_SIZE - sizeof(struct efx_rx_page_state)) / 100 ((PAGE_SIZE - sizeof(struct efx_rx_page_state)) /
@@ -189,9 +189,9 @@ static int efx_init_rx_buffers(struct efx_rx_queue *rx_queue)
189 do { 189 do {
190 index = rx_queue->added_count & rx_queue->ptr_mask; 190 index = rx_queue->added_count & rx_queue->ptr_mask;
191 rx_buf = efx_rx_buffer(rx_queue, index); 191 rx_buf = efx_rx_buffer(rx_queue, index);
192 rx_buf->dma_addr = dma_addr + NET_IP_ALIGN; 192 rx_buf->dma_addr = dma_addr + efx->rx_ip_align;
193 rx_buf->page = page; 193 rx_buf->page = page;
194 rx_buf->page_offset = page_offset + NET_IP_ALIGN; 194 rx_buf->page_offset = page_offset + efx->rx_ip_align;
195 rx_buf->len = efx->rx_dma_len; 195 rx_buf->len = efx->rx_dma_len;
196 rx_buf->flags = 0; 196 rx_buf->flags = 0;
197 ++rx_queue->added_count; 197 ++rx_queue->added_count;
diff --git a/drivers/net/ethernet/smsc/smc91x.c b/drivers/net/ethernet/smsc/smc91x.c
index 0c9b5d94154f..8bf29eb4a5a0 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -82,6 +82,7 @@ static const char version[] =
82#include <linux/mii.h> 82#include <linux/mii.h>
83#include <linux/workqueue.h> 83#include <linux/workqueue.h>
84#include <linux/of.h> 84#include <linux/of.h>
85#include <linux/of_device.h>
85 86
86#include <linux/netdevice.h> 87#include <linux/netdevice.h>
87#include <linux/etherdevice.h> 88#include <linux/etherdevice.h>
@@ -2184,6 +2185,15 @@ static void smc_release_datacs(struct platform_device *pdev, struct net_device *
2184 } 2185 }
2185} 2186}
2186 2187
2188#if IS_BUILTIN(CONFIG_OF)
2189static const struct of_device_id smc91x_match[] = {
2190 { .compatible = "smsc,lan91c94", },
2191 { .compatible = "smsc,lan91c111", },
2192 {},
2193};
2194MODULE_DEVICE_TABLE(of, smc91x_match);
2195#endif
2196
2187/* 2197/*
2188 * smc_init(void) 2198 * smc_init(void)
2189 * Input parameters: 2199 * Input parameters:
@@ -2198,6 +2208,7 @@ static void smc_release_datacs(struct platform_device *pdev, struct net_device *
2198static int smc_drv_probe(struct platform_device *pdev) 2208static int smc_drv_probe(struct platform_device *pdev)
2199{ 2209{
2200 struct smc91x_platdata *pd = dev_get_platdata(&pdev->dev); 2210 struct smc91x_platdata *pd = dev_get_platdata(&pdev->dev);
2211 const struct of_device_id *match = NULL;
2201 struct smc_local *lp; 2212 struct smc_local *lp;
2202 struct net_device *ndev; 2213 struct net_device *ndev;
2203 struct resource *res, *ires; 2214 struct resource *res, *ires;
@@ -2217,11 +2228,34 @@ static int smc_drv_probe(struct platform_device *pdev)
2217 */ 2228 */
2218 2229
2219 lp = netdev_priv(ndev); 2230 lp = netdev_priv(ndev);
2231 lp->cfg.flags = 0;
2220 2232
2221 if (pd) { 2233 if (pd) {
2222 memcpy(&lp->cfg, pd, sizeof(lp->cfg)); 2234 memcpy(&lp->cfg, pd, sizeof(lp->cfg));
2223 lp->io_shift = SMC91X_IO_SHIFT(lp->cfg.flags); 2235 lp->io_shift = SMC91X_IO_SHIFT(lp->cfg.flags);
2224 } else { 2236 }
2237
2238#if IS_BUILTIN(CONFIG_OF)
2239 match = of_match_device(of_match_ptr(smc91x_match), &pdev->dev);
2240 if (match) {
2241 struct device_node *np = pdev->dev.of_node;
2242 u32 val;
2243
2244 /* Combination of IO widths supported, default to 16-bit */
2245 if (!of_property_read_u32(np, "reg-io-width", &val)) {
2246 if (val & 1)
2247 lp->cfg.flags |= SMC91X_USE_8BIT;
2248 if ((val == 0) || (val & 2))
2249 lp->cfg.flags |= SMC91X_USE_16BIT;
2250 if (val & 4)
2251 lp->cfg.flags |= SMC91X_USE_32BIT;
2252 } else {
2253 lp->cfg.flags |= SMC91X_USE_16BIT;
2254 }
2255 }
2256#endif
2257
2258 if (!pd && !match) {
2225 lp->cfg.flags |= (SMC_CAN_USE_8BIT) ? SMC91X_USE_8BIT : 0; 2259 lp->cfg.flags |= (SMC_CAN_USE_8BIT) ? SMC91X_USE_8BIT : 0;
2226 lp->cfg.flags |= (SMC_CAN_USE_16BIT) ? SMC91X_USE_16BIT : 0; 2260 lp->cfg.flags |= (SMC_CAN_USE_16BIT) ? SMC91X_USE_16BIT : 0;
2227 lp->cfg.flags |= (SMC_CAN_USE_32BIT) ? SMC91X_USE_32BIT : 0; 2261 lp->cfg.flags |= (SMC_CAN_USE_32BIT) ? SMC91X_USE_32BIT : 0;
@@ -2370,15 +2404,6 @@ static int smc_drv_resume(struct device *dev)
2370 return 0; 2404 return 0;
2371} 2405}
2372 2406
2373#ifdef CONFIG_OF
2374static const struct of_device_id smc91x_match[] = {
2375 { .compatible = "smsc,lan91c94", },
2376 { .compatible = "smsc,lan91c111", },
2377 {},
2378};
2379MODULE_DEVICE_TABLE(of, smc91x_match);
2380#endif
2381
2382static struct dev_pm_ops smc_drv_pm_ops = { 2407static struct dev_pm_ops smc_drv_pm_ops = {
2383 .suspend = smc_drv_suspend, 2408 .suspend = smc_drv_suspend,
2384 .resume = smc_drv_resume, 2409 .resume = smc_drv_resume,
diff --git a/drivers/net/ethernet/tehuti/tehuti.c b/drivers/net/ethernet/tehuti/tehuti.c
index dd0dd6279b4e..4f1d2549130e 100644
--- a/drivers/net/ethernet/tehuti/tehuti.c
+++ b/drivers/net/ethernet/tehuti/tehuti.c
@@ -2019,7 +2019,6 @@ bdx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
2019 ndev->features = NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_TSO 2019 ndev->features = NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_TSO
2020 | NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX | 2020 | NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX |
2021 NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_RXCSUM 2021 NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_RXCSUM
2022 /*| NETIF_F_FRAGLIST */
2023 ; 2022 ;
2024 ndev->hw_features = NETIF_F_IP_CSUM | NETIF_F_SG | 2023 ndev->hw_features = NETIF_F_IP_CSUM | NETIF_F_SG |
2025 NETIF_F_TSO | NETIF_F_HW_VLAN_CTAG_TX; 2024 NETIF_F_TSO | NETIF_F_HW_VLAN_CTAG_TX;
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 7536a4c01293..5120d9ce1dd4 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -1151,6 +1151,12 @@ static int cpsw_ndo_open(struct net_device *ndev)
1151 * receive descs 1151 * receive descs
1152 */ 1152 */
1153 cpsw_info(priv, ifup, "submitted %d rx descriptors\n", i); 1153 cpsw_info(priv, ifup, "submitted %d rx descriptors\n", i);
1154
1155 if (cpts_register(&priv->pdev->dev, priv->cpts,
1156 priv->data.cpts_clock_mult,
1157 priv->data.cpts_clock_shift))
1158 dev_err(priv->dev, "error registering cpts device\n");
1159
1154 } 1160 }
1155 1161
1156 /* Enable Interrupt pacing if configured */ 1162 /* Enable Interrupt pacing if configured */
@@ -1197,6 +1203,7 @@ static int cpsw_ndo_stop(struct net_device *ndev)
1197 netif_carrier_off(priv->ndev); 1203 netif_carrier_off(priv->ndev);
1198 1204
1199 if (cpsw_common_res_usage_state(priv) <= 1) { 1205 if (cpsw_common_res_usage_state(priv) <= 1) {
1206 cpts_unregister(priv->cpts);
1200 cpsw_intr_disable(priv); 1207 cpsw_intr_disable(priv);
1201 cpdma_ctlr_int_ctrl(priv->dma, false); 1208 cpdma_ctlr_int_ctrl(priv->dma, false);
1202 cpdma_ctlr_stop(priv->dma); 1209 cpdma_ctlr_stop(priv->dma);
@@ -1816,6 +1823,8 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
1816 } 1823 }
1817 1824
1818 i++; 1825 i++;
1826 if (i == data->slaves)
1827 break;
1819 } 1828 }
1820 1829
1821 return 0; 1830 return 0;
@@ -1983,9 +1992,15 @@ static int cpsw_probe(struct platform_device *pdev)
1983 goto clean_runtime_disable_ret; 1992 goto clean_runtime_disable_ret;
1984 } 1993 }
1985 priv->regs = ss_regs; 1994 priv->regs = ss_regs;
1986 priv->version = __raw_readl(&priv->regs->id_ver);
1987 priv->host_port = HOST_PORT_NUM; 1995 priv->host_port = HOST_PORT_NUM;
1988 1996
1997 /* Need to enable clocks with runtime PM api to access module
1998 * registers
1999 */
2000 pm_runtime_get_sync(&pdev->dev);
2001 priv->version = readl(&priv->regs->id_ver);
2002 pm_runtime_put_sync(&pdev->dev);
2003
1989 res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 2004 res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
1990 priv->wr_regs = devm_ioremap_resource(&pdev->dev, res); 2005 priv->wr_regs = devm_ioremap_resource(&pdev->dev, res);
1991 if (IS_ERR(priv->wr_regs)) { 2006 if (IS_ERR(priv->wr_regs)) {
@@ -2155,8 +2170,6 @@ static int cpsw_remove(struct platform_device *pdev)
2155 unregister_netdev(cpsw_get_slave_ndev(priv, 1)); 2170 unregister_netdev(cpsw_get_slave_ndev(priv, 1));
2156 unregister_netdev(ndev); 2171 unregister_netdev(ndev);
2157 2172
2158 cpts_unregister(priv->cpts);
2159
2160 cpsw_ale_destroy(priv->ale); 2173 cpsw_ale_destroy(priv->ale);
2161 cpdma_chan_destroy(priv->txch); 2174 cpdma_chan_destroy(priv->txch);
2162 cpdma_chan_destroy(priv->rxch); 2175 cpdma_chan_destroy(priv->rxch);
diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
index 41ba974bf37c..cd9b164a0434 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -61,6 +61,7 @@
61#include <linux/davinci_emac.h> 61#include <linux/davinci_emac.h>
62#include <linux/of.h> 62#include <linux/of.h>
63#include <linux/of_address.h> 63#include <linux/of_address.h>
64#include <linux/of_device.h>
64#include <linux/of_irq.h> 65#include <linux/of_irq.h>
65#include <linux/of_net.h> 66#include <linux/of_net.h>
66 67
@@ -1752,10 +1753,14 @@ static const struct net_device_ops emac_netdev_ops = {
1752#endif 1753#endif
1753}; 1754};
1754 1755
1756static const struct of_device_id davinci_emac_of_match[];
1757
1755static struct emac_platform_data * 1758static struct emac_platform_data *
1756davinci_emac_of_get_pdata(struct platform_device *pdev, struct emac_priv *priv) 1759davinci_emac_of_get_pdata(struct platform_device *pdev, struct emac_priv *priv)
1757{ 1760{
1758 struct device_node *np; 1761 struct device_node *np;
1762 const struct of_device_id *match;
1763 const struct emac_platform_data *auxdata;
1759 struct emac_platform_data *pdata = NULL; 1764 struct emac_platform_data *pdata = NULL;
1760 const u8 *mac_addr; 1765 const u8 *mac_addr;
1761 1766
@@ -1793,7 +1798,20 @@ davinci_emac_of_get_pdata(struct platform_device *pdev, struct emac_priv *priv)
1793 1798
1794 priv->phy_node = of_parse_phandle(np, "phy-handle", 0); 1799 priv->phy_node = of_parse_phandle(np, "phy-handle", 0);
1795 if (!priv->phy_node) 1800 if (!priv->phy_node)
1796 pdata->phy_id = ""; 1801 pdata->phy_id = NULL;
1802
1803 auxdata = pdev->dev.platform_data;
1804 if (auxdata) {
1805 pdata->interrupt_enable = auxdata->interrupt_enable;
1806 pdata->interrupt_disable = auxdata->interrupt_disable;
1807 }
1808
1809 match = of_match_device(davinci_emac_of_match, &pdev->dev);
1810 if (match && match->data) {
1811 auxdata = match->data;
1812 pdata->version = auxdata->version;
1813 pdata->hw_ram_addr = auxdata->hw_ram_addr;
1814 }
1797 1815
1798 pdev->dev.platform_data = pdata; 1816 pdev->dev.platform_data = pdata;
1799 1817
@@ -2020,8 +2038,14 @@ static const struct dev_pm_ops davinci_emac_pm_ops = {
2020}; 2038};
2021 2039
2022#if IS_ENABLED(CONFIG_OF) 2040#if IS_ENABLED(CONFIG_OF)
2041static const struct emac_platform_data am3517_emac_data = {
2042 .version = EMAC_VERSION_2,
2043 .hw_ram_addr = 0x01e20000,
2044};
2045
2023static const struct of_device_id davinci_emac_of_match[] = { 2046static const struct of_device_id davinci_emac_of_match[] = {
2024 {.compatible = "ti,davinci-dm6467-emac", }, 2047 {.compatible = "ti,davinci-dm6467-emac", },
2048 {.compatible = "ti,am3517-emac", .data = &am3517_emac_data, },
2025 {}, 2049 {},
2026}; 2050};
2027MODULE_DEVICE_TABLE(of, davinci_emac_of_match); 2051MODULE_DEVICE_TABLE(of, davinci_emac_of_match);
diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
index 1f2364126323..2166e879a096 100644
--- a/drivers/net/ethernet/xilinx/ll_temac_main.c
+++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
@@ -1017,7 +1017,7 @@ static int temac_of_probe(struct platform_device *op)
1017 platform_set_drvdata(op, ndev); 1017 platform_set_drvdata(op, ndev);
1018 SET_NETDEV_DEV(ndev, &op->dev); 1018 SET_NETDEV_DEV(ndev, &op->dev);
1019 ndev->flags &= ~IFF_MULTICAST; /* clear multicast */ 1019 ndev->flags &= ~IFF_MULTICAST; /* clear multicast */
1020 ndev->features = NETIF_F_SG | NETIF_F_FRAGLIST; 1020 ndev->features = NETIF_F_SG;
1021 ndev->netdev_ops = &temac_netdev_ops; 1021 ndev->netdev_ops = &temac_netdev_ops;
1022 ndev->ethtool_ops = &temac_ethtool_ops; 1022 ndev->ethtool_ops = &temac_ethtool_ops;
1023#if 0 1023#if 0
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index b2ff038d6d20..f9293da19e26 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -1486,7 +1486,7 @@ static int axienet_of_probe(struct platform_device *op)
1486 1486
1487 SET_NETDEV_DEV(ndev, &op->dev); 1487 SET_NETDEV_DEV(ndev, &op->dev);
1488 ndev->flags &= ~IFF_MULTICAST; /* clear multicast */ 1488 ndev->flags &= ~IFF_MULTICAST; /* clear multicast */
1489 ndev->features = NETIF_F_SG | NETIF_F_FRAGLIST; 1489 ndev->features = NETIF_F_SG;
1490 ndev->netdev_ops = &axienet_netdev_ops; 1490 ndev->netdev_ops = &axienet_netdev_ops;
1491 ndev->ethtool_ops = &axienet_ethtool_ops; 1491 ndev->ethtool_ops = &axienet_ethtool_ops;
1492 1492
diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
index 74234a51c851..fefb8cd5eb65 100644
--- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c
+++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
@@ -163,26 +163,9 @@ static void xemaclite_enable_interrupts(struct net_local *drvdata)
163 __raw_writel(reg_data | XEL_TSR_XMIT_IE_MASK, 163 __raw_writel(reg_data | XEL_TSR_XMIT_IE_MASK,
164 drvdata->base_addr + XEL_TSR_OFFSET); 164 drvdata->base_addr + XEL_TSR_OFFSET);
165 165
166 /* Enable the Tx interrupts for the second Buffer if
167 * configured in HW */
168 if (drvdata->tx_ping_pong != 0) {
169 reg_data = __raw_readl(drvdata->base_addr +
170 XEL_BUFFER_OFFSET + XEL_TSR_OFFSET);
171 __raw_writel(reg_data | XEL_TSR_XMIT_IE_MASK,
172 drvdata->base_addr + XEL_BUFFER_OFFSET +
173 XEL_TSR_OFFSET);
174 }
175
176 /* Enable the Rx interrupts for the first buffer */ 166 /* Enable the Rx interrupts for the first buffer */
177 __raw_writel(XEL_RSR_RECV_IE_MASK, drvdata->base_addr + XEL_RSR_OFFSET); 167 __raw_writel(XEL_RSR_RECV_IE_MASK, drvdata->base_addr + XEL_RSR_OFFSET);
178 168
179 /* Enable the Rx interrupts for the second Buffer if
180 * configured in HW */
181 if (drvdata->rx_ping_pong != 0) {
182 __raw_writel(XEL_RSR_RECV_IE_MASK, drvdata->base_addr +
183 XEL_BUFFER_OFFSET + XEL_RSR_OFFSET);
184 }
185
186 /* Enable the Global Interrupt Enable */ 169 /* Enable the Global Interrupt Enable */
187 __raw_writel(XEL_GIER_GIE_MASK, drvdata->base_addr + XEL_GIER_OFFSET); 170 __raw_writel(XEL_GIER_GIE_MASK, drvdata->base_addr + XEL_GIER_OFFSET);
188} 171}
@@ -206,31 +189,10 @@ static void xemaclite_disable_interrupts(struct net_local *drvdata)
206 __raw_writel(reg_data & (~XEL_TSR_XMIT_IE_MASK), 189 __raw_writel(reg_data & (~XEL_TSR_XMIT_IE_MASK),
207 drvdata->base_addr + XEL_TSR_OFFSET); 190 drvdata->base_addr + XEL_TSR_OFFSET);
208 191
209 /* Disable the Tx interrupts for the second Buffer
210 * if configured in HW */
211 if (drvdata->tx_ping_pong != 0) {
212 reg_data = __raw_readl(drvdata->base_addr + XEL_BUFFER_OFFSET +
213 XEL_TSR_OFFSET);
214 __raw_writel(reg_data & (~XEL_TSR_XMIT_IE_MASK),
215 drvdata->base_addr + XEL_BUFFER_OFFSET +
216 XEL_TSR_OFFSET);
217 }
218
219 /* Disable the Rx interrupts for the first buffer */ 192 /* Disable the Rx interrupts for the first buffer */
220 reg_data = __raw_readl(drvdata->base_addr + XEL_RSR_OFFSET); 193 reg_data = __raw_readl(drvdata->base_addr + XEL_RSR_OFFSET);
221 __raw_writel(reg_data & (~XEL_RSR_RECV_IE_MASK), 194 __raw_writel(reg_data & (~XEL_RSR_RECV_IE_MASK),
222 drvdata->base_addr + XEL_RSR_OFFSET); 195 drvdata->base_addr + XEL_RSR_OFFSET);
223
224 /* Disable the Rx interrupts for the second buffer
225 * if configured in HW */
226 if (drvdata->rx_ping_pong != 0) {
227
228 reg_data = __raw_readl(drvdata->base_addr + XEL_BUFFER_OFFSET +
229 XEL_RSR_OFFSET);
230 __raw_writel(reg_data & (~XEL_RSR_RECV_IE_MASK),
231 drvdata->base_addr + XEL_BUFFER_OFFSET +
232 XEL_RSR_OFFSET);
233 }
234} 196}
235 197
236/** 198/**
@@ -258,6 +220,13 @@ static void xemaclite_aligned_write(void *src_ptr, u32 *dest_ptr,
258 *to_u16_ptr++ = *from_u16_ptr++; 220 *to_u16_ptr++ = *from_u16_ptr++;
259 *to_u16_ptr++ = *from_u16_ptr++; 221 *to_u16_ptr++ = *from_u16_ptr++;
260 222
223 /* This barrier resolves occasional issues seen around
224 * cases where the data is not properly flushed out
225 * from the processor store buffers to the destination
226 * memory locations.
227 */
228 wmb();
229
261 /* Output a word */ 230 /* Output a word */
262 *to_u32_ptr++ = align_buffer; 231 *to_u32_ptr++ = align_buffer;
263 } 232 }
@@ -273,6 +242,12 @@ static void xemaclite_aligned_write(void *src_ptr, u32 *dest_ptr,
273 for (; length > 0; length--) 242 for (; length > 0; length--)
274 *to_u8_ptr++ = *from_u8_ptr++; 243 *to_u8_ptr++ = *from_u8_ptr++;
275 244
245 /* This barrier resolves occasional issues seen around
246 * cases where the data is not properly flushed out
247 * from the processor store buffers to the destination
248 * memory locations.
249 */
250 wmb();
276 *to_u32_ptr = align_buffer; 251 *to_u32_ptr = align_buffer;
277 } 252 }
278} 253}
diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
index 9093004f9b63..2a89da080317 100644
--- a/drivers/net/macvtap.c
+++ b/drivers/net/macvtap.c
@@ -770,7 +770,7 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,
770 int ret; 770 int ret;
771 int vnet_hdr_len = 0; 771 int vnet_hdr_len = 0;
772 int vlan_offset = 0; 772 int vlan_offset = 0;
773 int copied; 773 int copied, total;
774 774
775 if (q->flags & IFF_VNET_HDR) { 775 if (q->flags & IFF_VNET_HDR) {
776 struct virtio_net_hdr vnet_hdr; 776 struct virtio_net_hdr vnet_hdr;
@@ -785,7 +785,8 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,
785 if (memcpy_toiovecend(iv, (void *)&vnet_hdr, 0, sizeof(vnet_hdr))) 785 if (memcpy_toiovecend(iv, (void *)&vnet_hdr, 0, sizeof(vnet_hdr)))
786 return -EFAULT; 786 return -EFAULT;
787 } 787 }
788 copied = vnet_hdr_len; 788 total = copied = vnet_hdr_len;
789 total += skb->len;
789 790
790 if (!vlan_tx_tag_present(skb)) 791 if (!vlan_tx_tag_present(skb))
791 len = min_t(int, skb->len, len); 792 len = min_t(int, skb->len, len);
@@ -800,6 +801,7 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,
800 801
801 vlan_offset = offsetof(struct vlan_ethhdr, h_vlan_proto); 802 vlan_offset = offsetof(struct vlan_ethhdr, h_vlan_proto);
802 len = min_t(int, skb->len + VLAN_HLEN, len); 803 len = min_t(int, skb->len + VLAN_HLEN, len);
804 total += VLAN_HLEN;
803 805
804 copy = min_t(int, vlan_offset, len); 806 copy = min_t(int, vlan_offset, len);
805 ret = skb_copy_datagram_const_iovec(skb, 0, iv, copied, copy); 807 ret = skb_copy_datagram_const_iovec(skb, 0, iv, copied, copy);
@@ -817,10 +819,9 @@ static ssize_t macvtap_put_user(struct macvtap_queue *q,
817 } 819 }
818 820
819 ret = skb_copy_datagram_const_iovec(skb, vlan_offset, iv, copied, len); 821 ret = skb_copy_datagram_const_iovec(skb, vlan_offset, iv, copied, len);
820 copied += len;
821 822
822done: 823done:
823 return ret ? ret : copied; 824 return ret ? ret : total;
824} 825}
825 826
826static ssize_t macvtap_do_read(struct macvtap_queue *q, struct kiocb *iocb, 827static ssize_t macvtap_do_read(struct macvtap_queue *q, struct kiocb *iocb,
@@ -875,7 +876,9 @@ static ssize_t macvtap_aio_read(struct kiocb *iocb, const struct iovec *iv,
875 } 876 }
876 877
877 ret = macvtap_do_read(q, iocb, iv, len, file->f_flags & O_NONBLOCK); 878 ret = macvtap_do_read(q, iocb, iv, len, file->f_flags & O_NONBLOCK);
878 ret = min_t(ssize_t, ret, len); /* XXX copied from tun.c. Why? */ 879 ret = min_t(ssize_t, ret, len);
880 if (ret > 0)
881 iocb->ki_pos = ret;
879out: 882out:
880 return ret; 883 return ret;
881} 884}
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 3ae28f420868..26fa05a472b4 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -336,6 +336,21 @@ static struct phy_driver ksphy_driver[] = {
336 .resume = genphy_resume, 336 .resume = genphy_resume,
337 .driver = { .owner = THIS_MODULE,}, 337 .driver = { .owner = THIS_MODULE,},
338}, { 338}, {
339 .phy_id = PHY_ID_KSZ8041RNLI,
340 .phy_id_mask = 0x00fffff0,
341 .name = "Micrel KSZ8041RNLI",
342 .features = PHY_BASIC_FEATURES |
343 SUPPORTED_Pause | SUPPORTED_Asym_Pause,
344 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
345 .config_init = kszphy_config_init,
346 .config_aneg = genphy_config_aneg,
347 .read_status = genphy_read_status,
348 .ack_interrupt = kszphy_ack_interrupt,
349 .config_intr = kszphy_config_intr,
350 .suspend = genphy_suspend,
351 .resume = genphy_resume,
352 .driver = { .owner = THIS_MODULE,},
353}, {
339 .phy_id = PHY_ID_KSZ8051, 354 .phy_id = PHY_ID_KSZ8051,
340 .phy_id_mask = 0x00fffff0, 355 .phy_id_mask = 0x00fffff0,
341 .name = "Micrel KSZ8051", 356 .name = "Micrel KSZ8051",
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 782e38bfc1ee..7c8343a4f918 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1184,7 +1184,7 @@ static ssize_t tun_put_user(struct tun_struct *tun,
1184{ 1184{
1185 struct tun_pi pi = { 0, skb->protocol }; 1185 struct tun_pi pi = { 0, skb->protocol };
1186 ssize_t total = 0; 1186 ssize_t total = 0;
1187 int vlan_offset = 0; 1187 int vlan_offset = 0, copied;
1188 1188
1189 if (!(tun->flags & TUN_NO_PI)) { 1189 if (!(tun->flags & TUN_NO_PI)) {
1190 if ((len -= sizeof(pi)) < 0) 1190 if ((len -= sizeof(pi)) < 0)
@@ -1248,6 +1248,8 @@ static ssize_t tun_put_user(struct tun_struct *tun,
1248 total += tun->vnet_hdr_sz; 1248 total += tun->vnet_hdr_sz;
1249 } 1249 }
1250 1250
1251 copied = total;
1252 total += skb->len;
1251 if (!vlan_tx_tag_present(skb)) { 1253 if (!vlan_tx_tag_present(skb)) {
1252 len = min_t(int, skb->len, len); 1254 len = min_t(int, skb->len, len);
1253 } else { 1255 } else {
@@ -1262,24 +1264,24 @@ static ssize_t tun_put_user(struct tun_struct *tun,
1262 1264
1263 vlan_offset = offsetof(struct vlan_ethhdr, h_vlan_proto); 1265 vlan_offset = offsetof(struct vlan_ethhdr, h_vlan_proto);
1264 len = min_t(int, skb->len + VLAN_HLEN, len); 1266 len = min_t(int, skb->len + VLAN_HLEN, len);
1267 total += VLAN_HLEN;
1265 1268
1266 copy = min_t(int, vlan_offset, len); 1269 copy = min_t(int, vlan_offset, len);
1267 ret = skb_copy_datagram_const_iovec(skb, 0, iv, total, copy); 1270 ret = skb_copy_datagram_const_iovec(skb, 0, iv, copied, copy);
1268 len -= copy; 1271 len -= copy;
1269 total += copy; 1272 copied += copy;
1270 if (ret || !len) 1273 if (ret || !len)
1271 goto done; 1274 goto done;
1272 1275
1273 copy = min_t(int, sizeof(veth), len); 1276 copy = min_t(int, sizeof(veth), len);
1274 ret = memcpy_toiovecend(iv, (void *)&veth, total, copy); 1277 ret = memcpy_toiovecend(iv, (void *)&veth, copied, copy);
1275 len -= copy; 1278 len -= copy;
1276 total += copy; 1279 copied += copy;
1277 if (ret || !len) 1280 if (ret || !len)
1278 goto done; 1281 goto done;
1279 } 1282 }
1280 1283
1281 skb_copy_datagram_const_iovec(skb, vlan_offset, iv, total, len); 1284 skb_copy_datagram_const_iovec(skb, vlan_offset, iv, copied, len);
1282 total += len;
1283 1285
1284done: 1286done:
1285 tun->dev->stats.tx_packets++; 1287 tun->dev->stats.tx_packets++;
@@ -1356,6 +1358,8 @@ static ssize_t tun_chr_aio_read(struct kiocb *iocb, const struct iovec *iv,
1356 ret = tun_do_read(tun, tfile, iocb, iv, len, 1358 ret = tun_do_read(tun, tfile, iocb, iv, len,
1357 file->f_flags & O_NONBLOCK); 1359 file->f_flags & O_NONBLOCK);
1358 ret = min_t(ssize_t, ret, len); 1360 ret = min_t(ssize_t, ret, len);
1361 if (ret > 0)
1362 iocb->ki_pos = ret;
1359out: 1363out:
1360 tun_put(tun); 1364 tun_put(tun);
1361 return ret; 1365 return ret;
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 916241d16c67..d208f8604981 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -426,10 +426,10 @@ static void receive_buf(struct receive_queue *rq, void *buf, unsigned int len)
426 if (unlikely(len < sizeof(struct virtio_net_hdr) + ETH_HLEN)) { 426 if (unlikely(len < sizeof(struct virtio_net_hdr) + ETH_HLEN)) {
427 pr_debug("%s: short packet %i\n", dev->name, len); 427 pr_debug("%s: short packet %i\n", dev->name, len);
428 dev->stats.rx_length_errors++; 428 dev->stats.rx_length_errors++;
429 if (vi->big_packets) 429 if (vi->mergeable_rx_bufs)
430 give_pages(rq, buf);
431 else if (vi->mergeable_rx_bufs)
432 put_page(virt_to_head_page(buf)); 430 put_page(virt_to_head_page(buf));
431 else if (vi->big_packets)
432 give_pages(rq, buf);
433 else 433 else
434 dev_kfree_skb(buf); 434 dev_kfree_skb(buf);
435 return; 435 return;
@@ -1367,6 +1367,11 @@ static void virtnet_config_changed(struct virtio_device *vdev)
1367 1367
1368static void virtnet_free_queues(struct virtnet_info *vi) 1368static void virtnet_free_queues(struct virtnet_info *vi)
1369{ 1369{
1370 int i;
1371
1372 for (i = 0; i < vi->max_queue_pairs; i++)
1373 netif_napi_del(&vi->rq[i].napi);
1374
1370 kfree(vi->rq); 1375 kfree(vi->rq);
1371 kfree(vi->sq); 1376 kfree(vi->sq);
1372} 1377}
@@ -1396,10 +1401,10 @@ static void free_unused_bufs(struct virtnet_info *vi)
1396 struct virtqueue *vq = vi->rq[i].vq; 1401 struct virtqueue *vq = vi->rq[i].vq;
1397 1402
1398 while ((buf = virtqueue_detach_unused_buf(vq)) != NULL) { 1403 while ((buf = virtqueue_detach_unused_buf(vq)) != NULL) {
1399 if (vi->big_packets) 1404 if (vi->mergeable_rx_bufs)
1400 give_pages(&vi->rq[i], buf);
1401 else if (vi->mergeable_rx_bufs)
1402 put_page(virt_to_head_page(buf)); 1405 put_page(virt_to_head_page(buf));
1406 else if (vi->big_packets)
1407 give_pages(&vi->rq[i], buf);
1403 else 1408 else
1404 dev_kfree_skb(buf); 1409 dev_kfree_skb(buf);
1405 --vi->rq[i].num; 1410 --vi->rq[i].num;
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 0358c07f7669..249e01c5600c 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -1668,7 +1668,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
1668 netdev_dbg(dev, "circular route to %pI4\n", 1668 netdev_dbg(dev, "circular route to %pI4\n",
1669 &dst->sin.sin_addr.s_addr); 1669 &dst->sin.sin_addr.s_addr);
1670 dev->stats.collisions++; 1670 dev->stats.collisions++;
1671 goto tx_error; 1671 goto rt_tx_error;
1672 } 1672 }
1673 1673
1674 /* Bypass encapsulation if the destination is local */ 1674 /* Bypass encapsulation if the destination is local */
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
index 1ec52356b5a1..130657db5c43 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
@@ -3984,18 +3984,20 @@ static void ar9003_hw_quick_drop_apply(struct ath_hw *ah, u16 freq)
3984 int quick_drop; 3984 int quick_drop;
3985 s32 t[3], f[3] = {5180, 5500, 5785}; 3985 s32 t[3], f[3] = {5180, 5500, 5785};
3986 3986
3987 if (!(pBase->miscConfiguration & BIT(1))) 3987 if (!(pBase->miscConfiguration & BIT(4)))
3988 return; 3988 return;
3989 3989
3990 if (freq < 4000) 3990 if (AR_SREV_9300(ah) || AR_SREV_9580(ah) || AR_SREV_9340(ah)) {
3991 quick_drop = eep->modalHeader2G.quick_drop; 3991 if (freq < 4000) {
3992 else { 3992 quick_drop = eep->modalHeader2G.quick_drop;
3993 t[0] = eep->base_ext1.quick_drop_low; 3993 } else {
3994 t[1] = eep->modalHeader5G.quick_drop; 3994 t[0] = eep->base_ext1.quick_drop_low;
3995 t[2] = eep->base_ext1.quick_drop_high; 3995 t[1] = eep->modalHeader5G.quick_drop;
3996 quick_drop = ar9003_hw_power_interpolate(freq, f, t, 3); 3996 t[2] = eep->base_ext1.quick_drop_high;
3997 quick_drop = ar9003_hw_power_interpolate(freq, f, t, 3);
3998 }
3999 REG_RMW_FIELD(ah, AR_PHY_AGC, AR_PHY_AGC_QUICK_DROP, quick_drop);
3997 } 4000 }
3998 REG_RMW_FIELD(ah, AR_PHY_AGC, AR_PHY_AGC_QUICK_DROP, quick_drop);
3999} 4001}
4000 4002
4001static void ar9003_hw_txend_to_xpa_off_apply(struct ath_hw *ah, bool is2ghz) 4003static void ar9003_hw_txend_to_xpa_off_apply(struct ath_hw *ah, bool is2ghz)
@@ -4035,7 +4037,7 @@ static void ar9003_hw_xlna_bias_strength_apply(struct ath_hw *ah, bool is2ghz)
4035 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; 4037 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
4036 u8 bias; 4038 u8 bias;
4037 4039
4038 if (!(eep->baseEepHeader.featureEnable & 0x40)) 4040 if (!(eep->baseEepHeader.miscConfiguration & 0x40))
4039 return; 4041 return;
4040 4042
4041 if (!AR_SREV_9300(ah)) 4043 if (!AR_SREV_9300(ah))
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 54b04155e43b..8918035da3a3 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -146,10 +146,9 @@ static void ath9k_hw_set_clockrate(struct ath_hw *ah)
146 else 146 else
147 clockrate = ATH9K_CLOCK_RATE_5GHZ_OFDM; 147 clockrate = ATH9K_CLOCK_RATE_5GHZ_OFDM;
148 148
149 if (IS_CHAN_HT40(chan)) 149 if (chan) {
150 clockrate *= 2; 150 if (IS_CHAN_HT40(chan))
151 151 clockrate *= 2;
152 if (ah->curchan) {
153 if (IS_CHAN_HALF_RATE(chan)) 152 if (IS_CHAN_HALF_RATE(chan))
154 clockrate /= 2; 153 clockrate /= 2;
155 if (IS_CHAN_QUARTER_RATE(chan)) 154 if (IS_CHAN_QUARTER_RATE(chan))
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index 09cdbcd09739..b5a19e098f2d 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -1276,6 +1276,10 @@ static void ath_tx_fill_desc(struct ath_softc *sc, struct ath_buf *bf,
1276 if (!rts_thresh || (len > rts_thresh)) 1276 if (!rts_thresh || (len > rts_thresh))
1277 rts = true; 1277 rts = true;
1278 } 1278 }
1279
1280 if (!aggr)
1281 len = fi->framelen;
1282
1279 ath_buf_set_rate(sc, bf, &info, len, rts); 1283 ath_buf_set_rate(sc, bf, &info, len, rts);
1280 } 1284 }
1281 1285
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c b/drivers/net/wireless/ath/wcn36xx/smd.c
index de9eb2cfbf4b..366339421d4f 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.c
+++ b/drivers/net/wireless/ath/wcn36xx/smd.c
@@ -2041,13 +2041,20 @@ static void wcn36xx_smd_rsp_process(struct wcn36xx *wcn, void *buf, size_t len)
2041 case WCN36XX_HAL_DELETE_STA_CONTEXT_IND: 2041 case WCN36XX_HAL_DELETE_STA_CONTEXT_IND:
2042 mutex_lock(&wcn->hal_ind_mutex); 2042 mutex_lock(&wcn->hal_ind_mutex);
2043 msg_ind = kmalloc(sizeof(*msg_ind), GFP_KERNEL); 2043 msg_ind = kmalloc(sizeof(*msg_ind), GFP_KERNEL);
2044 msg_ind->msg_len = len; 2044 if (msg_ind) {
2045 msg_ind->msg = kmalloc(len, GFP_KERNEL); 2045 msg_ind->msg_len = len;
2046 memcpy(msg_ind->msg, buf, len); 2046 msg_ind->msg = kmalloc(len, GFP_KERNEL);
2047 list_add_tail(&msg_ind->list, &wcn->hal_ind_queue); 2047 memcpy(msg_ind->msg, buf, len);
2048 queue_work(wcn->hal_ind_wq, &wcn->hal_ind_work); 2048 list_add_tail(&msg_ind->list, &wcn->hal_ind_queue);
2049 wcn36xx_dbg(WCN36XX_DBG_HAL, "indication arrived\n"); 2049 queue_work(wcn->hal_ind_wq, &wcn->hal_ind_work);
2050 wcn36xx_dbg(WCN36XX_DBG_HAL, "indication arrived\n");
2051 }
2050 mutex_unlock(&wcn->hal_ind_mutex); 2052 mutex_unlock(&wcn->hal_ind_mutex);
2053 if (msg_ind)
2054 break;
2055 /* FIXME: Do something smarter then just printing an error. */
2056 wcn36xx_err("Run out of memory while handling SMD_EVENT (%d)\n",
2057 msg_header->msg_type);
2051 break; 2058 break;
2052 default: 2059 default:
2053 wcn36xx_err("SMD_EVENT (%d) not supported\n", 2060 wcn36xx_err("SMD_EVENT (%d) not supported\n",
diff --git a/drivers/net/wireless/brcm80211/Kconfig b/drivers/net/wireless/brcm80211/Kconfig
index b00a7e92225f..54e36fcb3954 100644
--- a/drivers/net/wireless/brcm80211/Kconfig
+++ b/drivers/net/wireless/brcm80211/Kconfig
@@ -5,6 +5,8 @@ config BRCMSMAC
5 tristate "Broadcom IEEE802.11n PCIe SoftMAC WLAN driver" 5 tristate "Broadcom IEEE802.11n PCIe SoftMAC WLAN driver"
6 depends on MAC80211 6 depends on MAC80211
7 depends on BCMA 7 depends on BCMA
8 select NEW_LEDS if BCMA_DRIVER_GPIO
9 select LEDS_CLASS if BCMA_DRIVER_GPIO
8 select BRCMUTIL 10 select BRCMUTIL
9 select FW_LOADER 11 select FW_LOADER
10 select CRC_CCITT 12 select CRC_CCITT
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c
index 905704e335d7..abc9ceca70f3 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c
@@ -109,6 +109,8 @@ static inline int brcmf_sdioh_f0_write_byte(struct brcmf_sdio_dev *sdiodev,
109 brcmf_err("Disable F2 failed:%d\n", 109 brcmf_err("Disable F2 failed:%d\n",
110 err_ret); 110 err_ret);
111 } 111 }
112 } else {
113 err_ret = -ENOENT;
112 } 114 }
113 } else if ((regaddr == SDIO_CCCR_ABORT) || 115 } else if ((regaddr == SDIO_CCCR_ABORT) ||
114 (regaddr == SDIO_CCCR_IENx)) { 116 (regaddr == SDIO_CCCR_IENx)) {
diff --git a/drivers/net/wireless/iwlwifi/iwl-7000.c b/drivers/net/wireless/iwlwifi/iwl-7000.c
index 85879dbaa402..3c34a72a5d64 100644
--- a/drivers/net/wireless/iwlwifi/iwl-7000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-7000.c
@@ -67,8 +67,8 @@
67#include "iwl-agn-hw.h" 67#include "iwl-agn-hw.h"
68 68
69/* Highest firmware API version supported */ 69/* Highest firmware API version supported */
70#define IWL7260_UCODE_API_MAX 7 70#define IWL7260_UCODE_API_MAX 8
71#define IWL3160_UCODE_API_MAX 7 71#define IWL3160_UCODE_API_MAX 8
72 72
73/* Oldest version we won't warn about */ 73/* Oldest version we won't warn about */
74#define IWL7260_UCODE_API_OK 7 74#define IWL7260_UCODE_API_OK 7
@@ -130,6 +130,7 @@ const struct iwl_cfg iwl7260_2ac_cfg = {
130 .ht_params = &iwl7000_ht_params, 130 .ht_params = &iwl7000_ht_params,
131 .nvm_ver = IWL7260_NVM_VERSION, 131 .nvm_ver = IWL7260_NVM_VERSION,
132 .nvm_calib_ver = IWL7260_TX_POWER_VERSION, 132 .nvm_calib_ver = IWL7260_TX_POWER_VERSION,
133 .host_interrupt_operation_mode = true,
133}; 134};
134 135
135const struct iwl_cfg iwl7260_2ac_cfg_high_temp = { 136const struct iwl_cfg iwl7260_2ac_cfg_high_temp = {
@@ -140,6 +141,7 @@ const struct iwl_cfg iwl7260_2ac_cfg_high_temp = {
140 .nvm_ver = IWL7260_NVM_VERSION, 141 .nvm_ver = IWL7260_NVM_VERSION,
141 .nvm_calib_ver = IWL7260_TX_POWER_VERSION, 142 .nvm_calib_ver = IWL7260_TX_POWER_VERSION,
142 .high_temp = true, 143 .high_temp = true,
144 .host_interrupt_operation_mode = true,
143}; 145};
144 146
145const struct iwl_cfg iwl7260_2n_cfg = { 147const struct iwl_cfg iwl7260_2n_cfg = {
@@ -149,6 +151,7 @@ const struct iwl_cfg iwl7260_2n_cfg = {
149 .ht_params = &iwl7000_ht_params, 151 .ht_params = &iwl7000_ht_params,
150 .nvm_ver = IWL7260_NVM_VERSION, 152 .nvm_ver = IWL7260_NVM_VERSION,
151 .nvm_calib_ver = IWL7260_TX_POWER_VERSION, 153 .nvm_calib_ver = IWL7260_TX_POWER_VERSION,
154 .host_interrupt_operation_mode = true,
152}; 155};
153 156
154const struct iwl_cfg iwl7260_n_cfg = { 157const struct iwl_cfg iwl7260_n_cfg = {
@@ -158,6 +161,7 @@ const struct iwl_cfg iwl7260_n_cfg = {
158 .ht_params = &iwl7000_ht_params, 161 .ht_params = &iwl7000_ht_params,
159 .nvm_ver = IWL7260_NVM_VERSION, 162 .nvm_ver = IWL7260_NVM_VERSION,
160 .nvm_calib_ver = IWL7260_TX_POWER_VERSION, 163 .nvm_calib_ver = IWL7260_TX_POWER_VERSION,
164 .host_interrupt_operation_mode = true,
161}; 165};
162 166
163const struct iwl_cfg iwl3160_2ac_cfg = { 167const struct iwl_cfg iwl3160_2ac_cfg = {
@@ -167,6 +171,7 @@ const struct iwl_cfg iwl3160_2ac_cfg = {
167 .ht_params = &iwl7000_ht_params, 171 .ht_params = &iwl7000_ht_params,
168 .nvm_ver = IWL3160_NVM_VERSION, 172 .nvm_ver = IWL3160_NVM_VERSION,
169 .nvm_calib_ver = IWL3160_TX_POWER_VERSION, 173 .nvm_calib_ver = IWL3160_TX_POWER_VERSION,
174 .host_interrupt_operation_mode = true,
170}; 175};
171 176
172const struct iwl_cfg iwl3160_2n_cfg = { 177const struct iwl_cfg iwl3160_2n_cfg = {
@@ -176,6 +181,7 @@ const struct iwl_cfg iwl3160_2n_cfg = {
176 .ht_params = &iwl7000_ht_params, 181 .ht_params = &iwl7000_ht_params,
177 .nvm_ver = IWL3160_NVM_VERSION, 182 .nvm_ver = IWL3160_NVM_VERSION,
178 .nvm_calib_ver = IWL3160_TX_POWER_VERSION, 183 .nvm_calib_ver = IWL3160_TX_POWER_VERSION,
184 .host_interrupt_operation_mode = true,
179}; 185};
180 186
181const struct iwl_cfg iwl3160_n_cfg = { 187const struct iwl_cfg iwl3160_n_cfg = {
@@ -185,6 +191,7 @@ const struct iwl_cfg iwl3160_n_cfg = {
185 .ht_params = &iwl7000_ht_params, 191 .ht_params = &iwl7000_ht_params,
186 .nvm_ver = IWL3160_NVM_VERSION, 192 .nvm_ver = IWL3160_NVM_VERSION,
187 .nvm_calib_ver = IWL3160_TX_POWER_VERSION, 193 .nvm_calib_ver = IWL3160_TX_POWER_VERSION,
194 .host_interrupt_operation_mode = true,
188}; 195};
189 196
190const struct iwl_cfg iwl7265_2ac_cfg = { 197const struct iwl_cfg iwl7265_2ac_cfg = {
@@ -196,5 +203,23 @@ const struct iwl_cfg iwl7265_2ac_cfg = {
196 .nvm_calib_ver = IWL7265_TX_POWER_VERSION, 203 .nvm_calib_ver = IWL7265_TX_POWER_VERSION,
197}; 204};
198 205
206const struct iwl_cfg iwl7265_2n_cfg = {
207 .name = "Intel(R) Dual Band Wireless N 7265",
208 .fw_name_pre = IWL7265_FW_PRE,
209 IWL_DEVICE_7000,
210 .ht_params = &iwl7000_ht_params,
211 .nvm_ver = IWL7265_NVM_VERSION,
212 .nvm_calib_ver = IWL7265_TX_POWER_VERSION,
213};
214
215const struct iwl_cfg iwl7265_n_cfg = {
216 .name = "Intel(R) Wireless N 7265",
217 .fw_name_pre = IWL7265_FW_PRE,
218 IWL_DEVICE_7000,
219 .ht_params = &iwl7000_ht_params,
220 .nvm_ver = IWL7265_NVM_VERSION,
221 .nvm_calib_ver = IWL7265_TX_POWER_VERSION,
222};
223
199MODULE_FIRMWARE(IWL7260_MODULE_FIRMWARE(IWL7260_UCODE_API_OK)); 224MODULE_FIRMWARE(IWL7260_MODULE_FIRMWARE(IWL7260_UCODE_API_OK));
200MODULE_FIRMWARE(IWL3160_MODULE_FIRMWARE(IWL3160_UCODE_API_OK)); 225MODULE_FIRMWARE(IWL3160_MODULE_FIRMWARE(IWL3160_UCODE_API_OK));
diff --git a/drivers/net/wireless/iwlwifi/iwl-config.h b/drivers/net/wireless/iwlwifi/iwl-config.h
index 18f232e8e812..03fd9aa8bfda 100644
--- a/drivers/net/wireless/iwlwifi/iwl-config.h
+++ b/drivers/net/wireless/iwlwifi/iwl-config.h
@@ -207,6 +207,8 @@ struct iwl_eeprom_params {
207 * @rx_with_siso_diversity: 1x1 device with rx antenna diversity 207 * @rx_with_siso_diversity: 1x1 device with rx antenna diversity
208 * @internal_wimax_coex: internal wifi/wimax combo device 208 * @internal_wimax_coex: internal wifi/wimax combo device
209 * @high_temp: Is this NIC is designated to be in high temperature. 209 * @high_temp: Is this NIC is designated to be in high temperature.
210 * @host_interrupt_operation_mode: device needs host interrupt operation
211 * mode set
210 * 212 *
211 * We enable the driver to be backward compatible wrt. hardware features. 213 * We enable the driver to be backward compatible wrt. hardware features.
212 * API differences in uCode shouldn't be handled here but through TLVs 214 * API differences in uCode shouldn't be handled here but through TLVs
@@ -235,6 +237,7 @@ struct iwl_cfg {
235 enum iwl_led_mode led_mode; 237 enum iwl_led_mode led_mode;
236 const bool rx_with_siso_diversity; 238 const bool rx_with_siso_diversity;
237 const bool internal_wimax_coex; 239 const bool internal_wimax_coex;
240 const bool host_interrupt_operation_mode;
238 bool high_temp; 241 bool high_temp;
239}; 242};
240 243
@@ -294,6 +297,8 @@ extern const struct iwl_cfg iwl3160_2ac_cfg;
294extern const struct iwl_cfg iwl3160_2n_cfg; 297extern const struct iwl_cfg iwl3160_2n_cfg;
295extern const struct iwl_cfg iwl3160_n_cfg; 298extern const struct iwl_cfg iwl3160_n_cfg;
296extern const struct iwl_cfg iwl7265_2ac_cfg; 299extern const struct iwl_cfg iwl7265_2ac_cfg;
300extern const struct iwl_cfg iwl7265_2n_cfg;
301extern const struct iwl_cfg iwl7265_n_cfg;
297#endif /* CONFIG_IWLMVM */ 302#endif /* CONFIG_IWLMVM */
298 303
299#endif /* __IWL_CONFIG_H__ */ 304#endif /* __IWL_CONFIG_H__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-csr.h b/drivers/net/wireless/iwlwifi/iwl-csr.h
index 54a4fdc631b7..da4eca8b3007 100644
--- a/drivers/net/wireless/iwlwifi/iwl-csr.h
+++ b/drivers/net/wireless/iwlwifi/iwl-csr.h
@@ -495,14 +495,11 @@ enum secure_load_status_reg {
495 * the CSR_INT_COALESCING is an 8 bit register in 32-usec unit 495 * the CSR_INT_COALESCING is an 8 bit register in 32-usec unit
496 * 496 *
497 * default interrupt coalescing timer is 64 x 32 = 2048 usecs 497 * default interrupt coalescing timer is 64 x 32 = 2048 usecs
498 * default interrupt coalescing calibration timer is 16 x 32 = 512 usecs
499 */ 498 */
500#define IWL_HOST_INT_TIMEOUT_MAX (0xFF) 499#define IWL_HOST_INT_TIMEOUT_MAX (0xFF)
501#define IWL_HOST_INT_TIMEOUT_DEF (0x40) 500#define IWL_HOST_INT_TIMEOUT_DEF (0x40)
502#define IWL_HOST_INT_TIMEOUT_MIN (0x0) 501#define IWL_HOST_INT_TIMEOUT_MIN (0x0)
503#define IWL_HOST_INT_CALIB_TIMEOUT_MAX (0xFF) 502#define IWL_HOST_INT_OPER_MODE BIT(31)
504#define IWL_HOST_INT_CALIB_TIMEOUT_DEF (0x10)
505#define IWL_HOST_INT_CALIB_TIMEOUT_MIN (0x0)
506 503
507/***************************************************************************** 504/*****************************************************************************
508 * 7000/3000 series SHR DTS addresses * 505 * 7000/3000 series SHR DTS addresses *
diff --git a/drivers/net/wireless/iwlwifi/mvm/bt-coex.c b/drivers/net/wireless/iwlwifi/mvm/bt-coex.c
index 5d066cbc5ac7..75b72a956552 100644
--- a/drivers/net/wireless/iwlwifi/mvm/bt-coex.c
+++ b/drivers/net/wireless/iwlwifi/mvm/bt-coex.c
@@ -391,7 +391,6 @@ int iwl_send_bt_init_conf(struct iwl_mvm *mvm)
391 BT_VALID_LUT | 391 BT_VALID_LUT |
392 BT_VALID_WIFI_RX_SW_PRIO_BOOST | 392 BT_VALID_WIFI_RX_SW_PRIO_BOOST |
393 BT_VALID_WIFI_TX_SW_PRIO_BOOST | 393 BT_VALID_WIFI_TX_SW_PRIO_BOOST |
394 BT_VALID_MULTI_PRIO_LUT |
395 BT_VALID_CORUN_LUT_20 | 394 BT_VALID_CORUN_LUT_20 |
396 BT_VALID_CORUN_LUT_40 | 395 BT_VALID_CORUN_LUT_40 |
397 BT_VALID_ANT_ISOLATION | 396 BT_VALID_ANT_ISOLATION |
@@ -842,6 +841,11 @@ static void iwl_mvm_bt_rssi_iterator(void *_data, u8 *mac,
842 841
843 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[mvmvif->ap_sta_id], 842 sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[mvmvif->ap_sta_id],
844 lockdep_is_held(&mvm->mutex)); 843 lockdep_is_held(&mvm->mutex));
844
845 /* This can happen if the station has been removed right now */
846 if (IS_ERR_OR_NULL(sta))
847 return;
848
845 mvmsta = (void *)sta->drv_priv; 849 mvmsta = (void *)sta->drv_priv;
846 850
847 data->num_bss_ifaces++; 851 data->num_bss_ifaces++;
diff --git a/drivers/net/wireless/iwlwifi/mvm/d3.c b/drivers/net/wireless/iwlwifi/mvm/d3.c
index 6f45966817bb..b9b81e881dd0 100644
--- a/drivers/net/wireless/iwlwifi/mvm/d3.c
+++ b/drivers/net/wireless/iwlwifi/mvm/d3.c
@@ -895,7 +895,7 @@ static int iwl_mvm_get_last_nonqos_seq(struct iwl_mvm *mvm,
895 /* new API returns next, not last-used seqno */ 895 /* new API returns next, not last-used seqno */
896 if (mvm->fw->ucode_capa.flags & 896 if (mvm->fw->ucode_capa.flags &
897 IWL_UCODE_TLV_FLAGS_D3_CONTINUITY_API) 897 IWL_UCODE_TLV_FLAGS_D3_CONTINUITY_API)
898 err -= 0x10; 898 err = (u16) (err - 0x10);
899 } 899 }
900 900
901 iwl_free_resp(&cmd); 901 iwl_free_resp(&cmd);
@@ -1549,7 +1549,7 @@ static bool iwl_mvm_setup_connection_keep(struct iwl_mvm *mvm,
1549 if (gtkdata.unhandled_cipher) 1549 if (gtkdata.unhandled_cipher)
1550 return false; 1550 return false;
1551 if (!gtkdata.num_keys) 1551 if (!gtkdata.num_keys)
1552 return true; 1552 goto out;
1553 if (!gtkdata.last_gtk) 1553 if (!gtkdata.last_gtk)
1554 return false; 1554 return false;
1555 1555
@@ -1600,6 +1600,7 @@ static bool iwl_mvm_setup_connection_keep(struct iwl_mvm *mvm,
1600 (void *)&replay_ctr, GFP_KERNEL); 1600 (void *)&replay_ctr, GFP_KERNEL);
1601 } 1601 }
1602 1602
1603out:
1603 mvmvif->seqno_valid = true; 1604 mvmvif->seqno_valid = true;
1604 /* +0x10 because the set API expects next-to-use, not last-used */ 1605 /* +0x10 because the set API expects next-to-use, not last-used */
1605 mvmvif->seqno = le16_to_cpu(status->non_qos_seq_ctr) + 0x10; 1606 mvmvif->seqno = le16_to_cpu(status->non_qos_seq_ctr) + 0x10;
diff --git a/drivers/net/wireless/iwlwifi/mvm/debugfs.c b/drivers/net/wireless/iwlwifi/mvm/debugfs.c
index 9864d713eb2c..a8fe6b41f9a3 100644
--- a/drivers/net/wireless/iwlwifi/mvm/debugfs.c
+++ b/drivers/net/wireless/iwlwifi/mvm/debugfs.c
@@ -119,6 +119,10 @@ static ssize_t iwl_dbgfs_sta_drain_write(struct file *file,
119 119
120 if (sscanf(buf, "%d %d", &sta_id, &drain) != 2) 120 if (sscanf(buf, "%d %d", &sta_id, &drain) != 2)
121 return -EINVAL; 121 return -EINVAL;
122 if (sta_id < 0 || sta_id >= IWL_MVM_STATION_COUNT)
123 return -EINVAL;
124 if (drain < 0 || drain > 1)
125 return -EINVAL;
122 126
123 mutex_lock(&mvm->mutex); 127 mutex_lock(&mvm->mutex);
124 128
diff --git a/drivers/net/wireless/iwlwifi/mvm/time-event.c b/drivers/net/wireless/iwlwifi/mvm/time-event.c
index 33cf56fdfc41..95ce4b601fef 100644
--- a/drivers/net/wireless/iwlwifi/mvm/time-event.c
+++ b/drivers/net/wireless/iwlwifi/mvm/time-event.c
@@ -176,8 +176,11 @@ static void iwl_mvm_te_handle_notif(struct iwl_mvm *mvm,
176 * P2P Device discoveribility, while there are other higher priority 176 * P2P Device discoveribility, while there are other higher priority
177 * events in the system). 177 * events in the system).
178 */ 178 */
179 if (WARN_ONCE(!le32_to_cpu(notif->status), 179 if (!le32_to_cpu(notif->status)) {
180 "Failed to schedule time event\n")) { 180 bool start = le32_to_cpu(notif->action) &
181 TE_V2_NOTIF_HOST_EVENT_START;
182 IWL_WARN(mvm, "Time Event %s notification failure\n",
183 start ? "start" : "end");
181 if (iwl_mvm_te_check_disconnect(mvm, te_data->vif, NULL)) { 184 if (iwl_mvm_te_check_disconnect(mvm, te_data->vif, NULL)) {
182 iwl_mvm_te_clear_data(mvm, te_data); 185 iwl_mvm_te_clear_data(mvm, te_data);
183 return; 186 return;
diff --git a/drivers/net/wireless/iwlwifi/pcie/drv.c b/drivers/net/wireless/iwlwifi/pcie/drv.c
index 941c0c88f982..86605027c41d 100644
--- a/drivers/net/wireless/iwlwifi/pcie/drv.c
+++ b/drivers/net/wireless/iwlwifi/pcie/drv.c
@@ -353,6 +353,27 @@ static DEFINE_PCI_DEVICE_TABLE(iwl_hw_card_ids) = {
353 353
354/* 7265 Series */ 354/* 7265 Series */
355 {IWL_PCI_DEVICE(0x095A, 0x5010, iwl7265_2ac_cfg)}, 355 {IWL_PCI_DEVICE(0x095A, 0x5010, iwl7265_2ac_cfg)},
356 {IWL_PCI_DEVICE(0x095A, 0x5110, iwl7265_2ac_cfg)},
357 {IWL_PCI_DEVICE(0x095B, 0x5310, iwl7265_2ac_cfg)},
358 {IWL_PCI_DEVICE(0x095B, 0x5302, iwl7265_2ac_cfg)},
359 {IWL_PCI_DEVICE(0x095B, 0x5210, iwl7265_2ac_cfg)},
360 {IWL_PCI_DEVICE(0x095B, 0x5012, iwl7265_2ac_cfg)},
361 {IWL_PCI_DEVICE(0x095B, 0x500A, iwl7265_2ac_cfg)},
362 {IWL_PCI_DEVICE(0x095A, 0x5410, iwl7265_2ac_cfg)},
363 {IWL_PCI_DEVICE(0x095A, 0x1010, iwl7265_2ac_cfg)},
364 {IWL_PCI_DEVICE(0x095A, 0x5000, iwl7265_2n_cfg)},
365 {IWL_PCI_DEVICE(0x095B, 0x5200, iwl7265_2n_cfg)},
366 {IWL_PCI_DEVICE(0x095A, 0x5002, iwl7265_n_cfg)},
367 {IWL_PCI_DEVICE(0x095B, 0x5202, iwl7265_n_cfg)},
368 {IWL_PCI_DEVICE(0x095A, 0x9010, iwl7265_2ac_cfg)},
369 {IWL_PCI_DEVICE(0x095A, 0x9210, iwl7265_2ac_cfg)},
370 {IWL_PCI_DEVICE(0x095A, 0x9410, iwl7265_2ac_cfg)},
371 {IWL_PCI_DEVICE(0x095A, 0x5020, iwl7265_2n_cfg)},
372 {IWL_PCI_DEVICE(0x095A, 0x502A, iwl7265_2n_cfg)},
373 {IWL_PCI_DEVICE(0x095A, 0x5420, iwl7265_2n_cfg)},
374 {IWL_PCI_DEVICE(0x095A, 0x5090, iwl7265_2ac_cfg)},
375 {IWL_PCI_DEVICE(0x095B, 0x5290, iwl7265_2ac_cfg)},
376 {IWL_PCI_DEVICE(0x095A, 0x5490, iwl7265_2ac_cfg)},
356#endif /* CONFIG_IWLMVM */ 377#endif /* CONFIG_IWLMVM */
357 378
358 {0} 379 {0}
diff --git a/drivers/net/wireless/iwlwifi/pcie/internal.h b/drivers/net/wireless/iwlwifi/pcie/internal.h
index fa22639b63c9..051268c037b1 100644
--- a/drivers/net/wireless/iwlwifi/pcie/internal.h
+++ b/drivers/net/wireless/iwlwifi/pcie/internal.h
@@ -477,4 +477,12 @@ static inline bool iwl_is_rfkill_set(struct iwl_trans *trans)
477 CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW); 477 CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW);
478} 478}
479 479
480static inline void iwl_nic_error(struct iwl_trans *trans)
481{
482 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
483
484 set_bit(STATUS_FW_ERROR, &trans_pcie->status);
485 iwl_op_mode_nic_error(trans->op_mode);
486}
487
480#endif /* __iwl_trans_int_pcie_h__ */ 488#endif /* __iwl_trans_int_pcie_h__ */
diff --git a/drivers/net/wireless/iwlwifi/pcie/rx.c b/drivers/net/wireless/iwlwifi/pcie/rx.c
index 3f237b42eb36..be3995afa9d0 100644
--- a/drivers/net/wireless/iwlwifi/pcie/rx.c
+++ b/drivers/net/wireless/iwlwifi/pcie/rx.c
@@ -489,6 +489,10 @@ static void iwl_pcie_rx_hw_init(struct iwl_trans *trans, struct iwl_rxq *rxq)
489 489
490 /* Set interrupt coalescing timer to default (2048 usecs) */ 490 /* Set interrupt coalescing timer to default (2048 usecs) */
491 iwl_write8(trans, CSR_INT_COALESCING, IWL_HOST_INT_TIMEOUT_DEF); 491 iwl_write8(trans, CSR_INT_COALESCING, IWL_HOST_INT_TIMEOUT_DEF);
492
493 /* W/A for interrupt coalescing bug in 7260 and 3160 */
494 if (trans->cfg->host_interrupt_operation_mode)
495 iwl_set_bit(trans, CSR_INT_COALESCING, IWL_HOST_INT_OPER_MODE);
492} 496}
493 497
494static void iwl_pcie_rx_init_rxb_lists(struct iwl_rxq *rxq) 498static void iwl_pcie_rx_init_rxb_lists(struct iwl_rxq *rxq)
@@ -796,12 +800,13 @@ static void iwl_pcie_irq_handle_error(struct iwl_trans *trans)
796 iwl_pcie_dump_csr(trans); 800 iwl_pcie_dump_csr(trans);
797 iwl_dump_fh(trans, NULL); 801 iwl_dump_fh(trans, NULL);
798 802
803 /* set the ERROR bit before we wake up the caller */
799 set_bit(STATUS_FW_ERROR, &trans_pcie->status); 804 set_bit(STATUS_FW_ERROR, &trans_pcie->status);
800 clear_bit(STATUS_HCMD_ACTIVE, &trans_pcie->status); 805 clear_bit(STATUS_HCMD_ACTIVE, &trans_pcie->status);
801 wake_up(&trans_pcie->wait_command_queue); 806 wake_up(&trans_pcie->wait_command_queue);
802 807
803 local_bh_disable(); 808 local_bh_disable();
804 iwl_op_mode_nic_error(trans->op_mode); 809 iwl_nic_error(trans);
805 local_bh_enable(); 810 local_bh_enable();
806} 811}
807 812
diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
index 5d9337bec67a..cde9c16f6e4f 100644
--- a/drivers/net/wireless/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
@@ -279,9 +279,6 @@ static int iwl_pcie_nic_init(struct iwl_trans *trans)
279 spin_lock_irqsave(&trans_pcie->irq_lock, flags); 279 spin_lock_irqsave(&trans_pcie->irq_lock, flags);
280 iwl_pcie_apm_init(trans); 280 iwl_pcie_apm_init(trans);
281 281
282 /* Set interrupt coalescing calibration timer to default (512 usecs) */
283 iwl_write8(trans, CSR_INT_COALESCING, IWL_HOST_INT_CALIB_TIMEOUT_DEF);
284
285 spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); 282 spin_unlock_irqrestore(&trans_pcie->irq_lock, flags);
286 283
287 iwl_pcie_set_pwr(trans, false); 284 iwl_pcie_set_pwr(trans, false);
diff --git a/drivers/net/wireless/iwlwifi/pcie/tx.c b/drivers/net/wireless/iwlwifi/pcie/tx.c
index 059c5acad3a0..0adde919a258 100644
--- a/drivers/net/wireless/iwlwifi/pcie/tx.c
+++ b/drivers/net/wireless/iwlwifi/pcie/tx.c
@@ -207,7 +207,7 @@ static void iwl_pcie_txq_stuck_timer(unsigned long data)
207 IWL_ERR(trans, "scratch %d = 0x%08x\n", i, 207 IWL_ERR(trans, "scratch %d = 0x%08x\n", i,
208 le32_to_cpu(txq->scratchbufs[i].scratch)); 208 le32_to_cpu(txq->scratchbufs[i].scratch));
209 209
210 iwl_op_mode_nic_error(trans->op_mode); 210 iwl_nic_error(trans);
211} 211}
212 212
213/* 213/*
@@ -1023,7 +1023,7 @@ static void iwl_pcie_cmdq_reclaim(struct iwl_trans *trans, int txq_id, int idx)
1023 if (nfreed++ > 0) { 1023 if (nfreed++ > 0) {
1024 IWL_ERR(trans, "HCMD skipped: index (%d) %d %d\n", 1024 IWL_ERR(trans, "HCMD skipped: index (%d) %d %d\n",
1025 idx, q->write_ptr, q->read_ptr); 1025 idx, q->write_ptr, q->read_ptr);
1026 iwl_op_mode_nic_error(trans->op_mode); 1026 iwl_nic_error(trans);
1027 } 1027 }
1028 } 1028 }
1029 1029
@@ -1562,7 +1562,7 @@ static int iwl_pcie_send_hcmd_sync(struct iwl_trans *trans,
1562 get_cmd_string(trans_pcie, cmd->id)); 1562 get_cmd_string(trans_pcie, cmd->id));
1563 ret = -ETIMEDOUT; 1563 ret = -ETIMEDOUT;
1564 1564
1565 iwl_op_mode_nic_error(trans->op_mode); 1565 iwl_nic_error(trans);
1566 1566
1567 goto cancel; 1567 goto cancel;
1568 } 1568 }
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index 9df7bc91a26f..c72438bb2faf 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -383,6 +383,14 @@ struct hwsim_radiotap_hdr {
383 __le16 rt_chbitmask; 383 __le16 rt_chbitmask;
384} __packed; 384} __packed;
385 385
386struct hwsim_radiotap_ack_hdr {
387 struct ieee80211_radiotap_header hdr;
388 u8 rt_flags;
389 u8 pad;
390 __le16 rt_channel;
391 __le16 rt_chbitmask;
392} __packed;
393
386/* MAC80211_HWSIM netlinf family */ 394/* MAC80211_HWSIM netlinf family */
387static struct genl_family hwsim_genl_family = { 395static struct genl_family hwsim_genl_family = {
388 .id = GENL_ID_GENERATE, 396 .id = GENL_ID_GENERATE,
@@ -500,7 +508,7 @@ static void mac80211_hwsim_monitor_ack(struct ieee80211_channel *chan,
500 const u8 *addr) 508 const u8 *addr)
501{ 509{
502 struct sk_buff *skb; 510 struct sk_buff *skb;
503 struct hwsim_radiotap_hdr *hdr; 511 struct hwsim_radiotap_ack_hdr *hdr;
504 u16 flags; 512 u16 flags;
505 struct ieee80211_hdr *hdr11; 513 struct ieee80211_hdr *hdr11;
506 514
@@ -511,14 +519,14 @@ static void mac80211_hwsim_monitor_ack(struct ieee80211_channel *chan,
511 if (skb == NULL) 519 if (skb == NULL)
512 return; 520 return;
513 521
514 hdr = (struct hwsim_radiotap_hdr *) skb_put(skb, sizeof(*hdr)); 522 hdr = (struct hwsim_radiotap_ack_hdr *) skb_put(skb, sizeof(*hdr));
515 hdr->hdr.it_version = PKTHDR_RADIOTAP_VERSION; 523 hdr->hdr.it_version = PKTHDR_RADIOTAP_VERSION;
516 hdr->hdr.it_pad = 0; 524 hdr->hdr.it_pad = 0;
517 hdr->hdr.it_len = cpu_to_le16(sizeof(*hdr)); 525 hdr->hdr.it_len = cpu_to_le16(sizeof(*hdr));
518 hdr->hdr.it_present = cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) | 526 hdr->hdr.it_present = cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) |
519 (1 << IEEE80211_RADIOTAP_CHANNEL)); 527 (1 << IEEE80211_RADIOTAP_CHANNEL));
520 hdr->rt_flags = 0; 528 hdr->rt_flags = 0;
521 hdr->rt_rate = 0; 529 hdr->pad = 0;
522 hdr->rt_channel = cpu_to_le16(chan->center_freq); 530 hdr->rt_channel = cpu_to_le16(chan->center_freq);
523 flags = IEEE80211_CHAN_2GHZ; 531 flags = IEEE80211_CHAN_2GHZ;
524 hdr->rt_chbitmask = cpu_to_le16(flags); 532 hdr->rt_chbitmask = cpu_to_le16(flags);
@@ -1230,7 +1238,7 @@ static void mac80211_hwsim_bss_info_changed(struct ieee80211_hw *hw,
1230 HRTIMER_MODE_REL); 1238 HRTIMER_MODE_REL);
1231 } else if (!info->enable_beacon) { 1239 } else if (!info->enable_beacon) {
1232 unsigned int count = 0; 1240 unsigned int count = 0;
1233 ieee80211_iterate_active_interfaces( 1241 ieee80211_iterate_active_interfaces_atomic(
1234 data->hw, IEEE80211_IFACE_ITER_NORMAL, 1242 data->hw, IEEE80211_IFACE_ITER_NORMAL,
1235 mac80211_hwsim_bcn_en_iter, &count); 1243 mac80211_hwsim_bcn_en_iter, &count);
1236 wiphy_debug(hw->wiphy, " beaconing vifs remaining: %u", 1244 wiphy_debug(hw->wiphy, " beaconing vifs remaining: %u",
diff --git a/drivers/net/wireless/mwifiex/sta_ioctl.c b/drivers/net/wireless/mwifiex/sta_ioctl.c
index c8e029df770e..a09398fe9e2a 100644
--- a/drivers/net/wireless/mwifiex/sta_ioctl.c
+++ b/drivers/net/wireless/mwifiex/sta_ioctl.c
@@ -319,8 +319,8 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
319 if (bss_desc && bss_desc->ssid.ssid_len && 319 if (bss_desc && bss_desc->ssid.ssid_len &&
320 (!mwifiex_ssid_cmp(&priv->curr_bss_params.bss_descriptor. 320 (!mwifiex_ssid_cmp(&priv->curr_bss_params.bss_descriptor.
321 ssid, &bss_desc->ssid))) { 321 ssid, &bss_desc->ssid))) {
322 kfree(bss_desc); 322 ret = 0;
323 return 0; 323 goto done;
324 } 324 }
325 325
326 /* Exit Adhoc mode first */ 326 /* Exit Adhoc mode first */
diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
index 2329cccf1fa6..870f1fa58370 100644
--- a/drivers/net/xen-netback/interface.c
+++ b/drivers/net/xen-netback/interface.c
@@ -368,11 +368,11 @@ int xenvif_connect(struct xenvif *vif, unsigned long tx_ring_ref,
368 unsigned long rx_ring_ref, unsigned int tx_evtchn, 368 unsigned long rx_ring_ref, unsigned int tx_evtchn,
369 unsigned int rx_evtchn) 369 unsigned int rx_evtchn)
370{ 370{
371 struct task_struct *task;
371 int err = -ENOMEM; 372 int err = -ENOMEM;
372 373
373 /* Already connected through? */ 374 BUG_ON(vif->tx_irq);
374 if (vif->tx_irq) 375 BUG_ON(vif->task);
375 return 0;
376 376
377 err = xenvif_map_frontend_rings(vif, tx_ring_ref, rx_ring_ref); 377 err = xenvif_map_frontend_rings(vif, tx_ring_ref, rx_ring_ref);
378 if (err < 0) 378 if (err < 0)
@@ -411,14 +411,16 @@ int xenvif_connect(struct xenvif *vif, unsigned long tx_ring_ref,
411 } 411 }
412 412
413 init_waitqueue_head(&vif->wq); 413 init_waitqueue_head(&vif->wq);
414 vif->task = kthread_create(xenvif_kthread, 414 task = kthread_create(xenvif_kthread,
415 (void *)vif, "%s", vif->dev->name); 415 (void *)vif, "%s", vif->dev->name);
416 if (IS_ERR(vif->task)) { 416 if (IS_ERR(task)) {
417 pr_warn("Could not allocate kthread for %s\n", vif->dev->name); 417 pr_warn("Could not allocate kthread for %s\n", vif->dev->name);
418 err = PTR_ERR(vif->task); 418 err = PTR_ERR(task);
419 goto err_rx_unbind; 419 goto err_rx_unbind;
420 } 420 }
421 421
422 vif->task = task;
423
422 rtnl_lock(); 424 rtnl_lock();
423 if (!vif->can_sg && vif->dev->mtu > ETH_DATA_LEN) 425 if (!vif->can_sg && vif->dev->mtu > ETH_DATA_LEN)
424 dev_set_mtu(vif->dev, ETH_DATA_LEN); 426 dev_set_mtu(vif->dev, ETH_DATA_LEN);
@@ -461,8 +463,10 @@ void xenvif_disconnect(struct xenvif *vif)
461 if (netif_carrier_ok(vif->dev)) 463 if (netif_carrier_ok(vif->dev))
462 xenvif_carrier_off(vif); 464 xenvif_carrier_off(vif);
463 465
464 if (vif->task) 466 if (vif->task) {
465 kthread_stop(vif->task); 467 kthread_stop(vif->task);
468 vif->task = NULL;
469 }
466 470
467 if (vif->tx_irq) { 471 if (vif->tx_irq) {
468 if (vif->tx_irq == vif->rx_irq) 472 if (vif->tx_irq == vif->rx_irq)
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
index 64f0e0d18b81..e884ee1fe7ed 100644
--- a/drivers/net/xen-netback/netback.c
+++ b/drivers/net/xen-netback/netback.c
@@ -452,7 +452,7 @@ static int xenvif_gop_skb(struct sk_buff *skb,
452 } 452 }
453 453
454 /* Set up a GSO prefix descriptor, if necessary */ 454 /* Set up a GSO prefix descriptor, if necessary */
455 if ((1 << skb_shinfo(skb)->gso_type) & vif->gso_prefix_mask) { 455 if ((1 << gso_type) & vif->gso_prefix_mask) {
456 req = RING_GET_REQUEST(&vif->rx, vif->rx.req_cons++); 456 req = RING_GET_REQUEST(&vif->rx, vif->rx.req_cons++);
457 meta = npo->meta + npo->meta_prod++; 457 meta = npo->meta + npo->meta_prod++;
458 meta->gso_type = gso_type; 458 meta->gso_type = gso_type;
@@ -1149,75 +1149,92 @@ static int xenvif_set_skb_gso(struct xenvif *vif,
1149 return 0; 1149 return 0;
1150} 1150}
1151 1151
1152static inline void maybe_pull_tail(struct sk_buff *skb, unsigned int len) 1152static inline int maybe_pull_tail(struct sk_buff *skb, unsigned int len,
1153 unsigned int max)
1153{ 1154{
1154 if (skb_is_nonlinear(skb) && skb_headlen(skb) < len) { 1155 if (skb_headlen(skb) >= len)
1155 /* If we need to pullup then pullup to the max, so we 1156 return 0;
1156 * won't need to do it again. 1157
1157 */ 1158 /* If we need to pullup then pullup to the max, so we
1158 int target = min_t(int, skb->len, MAX_TCP_HEADER); 1159 * won't need to do it again.
1159 __pskb_pull_tail(skb, target - skb_headlen(skb)); 1160 */
1160 } 1161 if (max > skb->len)
1162 max = skb->len;
1163
1164 if (__pskb_pull_tail(skb, max - skb_headlen(skb)) == NULL)
1165 return -ENOMEM;
1166
1167 if (skb_headlen(skb) < len)
1168 return -EPROTO;
1169
1170 return 0;
1161} 1171}
1162 1172
1173/* This value should be large enough to cover a tagged ethernet header plus
1174 * maximally sized IP and TCP or UDP headers.
1175 */
1176#define MAX_IP_HDR_LEN 128
1177
1163static int checksum_setup_ip(struct xenvif *vif, struct sk_buff *skb, 1178static int checksum_setup_ip(struct xenvif *vif, struct sk_buff *skb,
1164 int recalculate_partial_csum) 1179 int recalculate_partial_csum)
1165{ 1180{
1166 struct iphdr *iph = (void *)skb->data;
1167 unsigned int header_size;
1168 unsigned int off; 1181 unsigned int off;
1169 int err = -EPROTO; 1182 bool fragment;
1183 int err;
1170 1184
1171 off = sizeof(struct iphdr); 1185 fragment = false;
1172 1186
1173 header_size = skb->network_header + off + MAX_IPOPTLEN; 1187 err = maybe_pull_tail(skb,
1174 maybe_pull_tail(skb, header_size); 1188 sizeof(struct iphdr),
1189 MAX_IP_HDR_LEN);
1190 if (err < 0)
1191 goto out;
1175 1192
1176 off = iph->ihl * 4; 1193 if (ip_hdr(skb)->frag_off & htons(IP_OFFSET | IP_MF))
1194 fragment = true;
1177 1195
1178 switch (iph->protocol) { 1196 off = ip_hdrlen(skb);
1197
1198 err = -EPROTO;
1199
1200 switch (ip_hdr(skb)->protocol) {
1179 case IPPROTO_TCP: 1201 case IPPROTO_TCP:
1202 err = maybe_pull_tail(skb,
1203 off + sizeof(struct tcphdr),
1204 MAX_IP_HDR_LEN);
1205 if (err < 0)
1206 goto out;
1207
1180 if (!skb_partial_csum_set(skb, off, 1208 if (!skb_partial_csum_set(skb, off,
1181 offsetof(struct tcphdr, check))) 1209 offsetof(struct tcphdr, check)))
1182 goto out; 1210 goto out;
1183 1211
1184 if (recalculate_partial_csum) { 1212 if (recalculate_partial_csum)
1185 struct tcphdr *tcph = tcp_hdr(skb); 1213 tcp_hdr(skb)->check =
1186 1214 ~csum_tcpudp_magic(ip_hdr(skb)->saddr,
1187 header_size = skb->network_header + 1215 ip_hdr(skb)->daddr,
1188 off + 1216 skb->len - off,
1189 sizeof(struct tcphdr); 1217 IPPROTO_TCP, 0);
1190 maybe_pull_tail(skb, header_size);
1191
1192 tcph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr,
1193 skb->len - off,
1194 IPPROTO_TCP, 0);
1195 }
1196 break; 1218 break;
1197 case IPPROTO_UDP: 1219 case IPPROTO_UDP:
1220 err = maybe_pull_tail(skb,
1221 off + sizeof(struct udphdr),
1222 MAX_IP_HDR_LEN);
1223 if (err < 0)
1224 goto out;
1225
1198 if (!skb_partial_csum_set(skb, off, 1226 if (!skb_partial_csum_set(skb, off,
1199 offsetof(struct udphdr, check))) 1227 offsetof(struct udphdr, check)))
1200 goto out; 1228 goto out;
1201 1229
1202 if (recalculate_partial_csum) { 1230 if (recalculate_partial_csum)
1203 struct udphdr *udph = udp_hdr(skb); 1231 udp_hdr(skb)->check =
1204 1232 ~csum_tcpudp_magic(ip_hdr(skb)->saddr,
1205 header_size = skb->network_header + 1233 ip_hdr(skb)->daddr,
1206 off + 1234 skb->len - off,
1207 sizeof(struct udphdr); 1235 IPPROTO_UDP, 0);
1208 maybe_pull_tail(skb, header_size);
1209
1210 udph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr,
1211 skb->len - off,
1212 IPPROTO_UDP, 0);
1213 }
1214 break; 1236 break;
1215 default: 1237 default:
1216 if (net_ratelimit())
1217 netdev_err(vif->dev,
1218 "Attempting to checksum a non-TCP/UDP packet, "
1219 "dropping a protocol %d packet\n",
1220 iph->protocol);
1221 goto out; 1238 goto out;
1222 } 1239 }
1223 1240
@@ -1227,121 +1244,138 @@ out:
1227 return err; 1244 return err;
1228} 1245}
1229 1246
1247/* This value should be large enough to cover a tagged ethernet header plus
1248 * an IPv6 header, all options, and a maximal TCP or UDP header.
1249 */
1250#define MAX_IPV6_HDR_LEN 256
1251
1252#define OPT_HDR(type, skb, off) \
1253 (type *)(skb_network_header(skb) + (off))
1254
1230static int checksum_setup_ipv6(struct xenvif *vif, struct sk_buff *skb, 1255static int checksum_setup_ipv6(struct xenvif *vif, struct sk_buff *skb,
1231 int recalculate_partial_csum) 1256 int recalculate_partial_csum)
1232{ 1257{
1233 int err = -EPROTO; 1258 int err;
1234 struct ipv6hdr *ipv6h = (void *)skb->data;
1235 u8 nexthdr; 1259 u8 nexthdr;
1236 unsigned int header_size;
1237 unsigned int off; 1260 unsigned int off;
1261 unsigned int len;
1238 bool fragment; 1262 bool fragment;
1239 bool done; 1263 bool done;
1240 1264
1265 fragment = false;
1241 done = false; 1266 done = false;
1242 1267
1243 off = sizeof(struct ipv6hdr); 1268 off = sizeof(struct ipv6hdr);
1244 1269
1245 header_size = skb->network_header + off; 1270 err = maybe_pull_tail(skb, off, MAX_IPV6_HDR_LEN);
1246 maybe_pull_tail(skb, header_size); 1271 if (err < 0)
1272 goto out;
1247 1273
1248 nexthdr = ipv6h->nexthdr; 1274 nexthdr = ipv6_hdr(skb)->nexthdr;
1249 1275
1250 while ((off <= sizeof(struct ipv6hdr) + ntohs(ipv6h->payload_len)) && 1276 len = sizeof(struct ipv6hdr) + ntohs(ipv6_hdr(skb)->payload_len);
1251 !done) { 1277 while (off <= len && !done) {
1252 switch (nexthdr) { 1278 switch (nexthdr) {
1253 case IPPROTO_DSTOPTS: 1279 case IPPROTO_DSTOPTS:
1254 case IPPROTO_HOPOPTS: 1280 case IPPROTO_HOPOPTS:
1255 case IPPROTO_ROUTING: { 1281 case IPPROTO_ROUTING: {
1256 struct ipv6_opt_hdr *hp = (void *)(skb->data + off); 1282 struct ipv6_opt_hdr *hp;
1257 1283
1258 header_size = skb->network_header + 1284 err = maybe_pull_tail(skb,
1259 off + 1285 off +
1260 sizeof(struct ipv6_opt_hdr); 1286 sizeof(struct ipv6_opt_hdr),
1261 maybe_pull_tail(skb, header_size); 1287 MAX_IPV6_HDR_LEN);
1288 if (err < 0)
1289 goto out;
1262 1290
1291 hp = OPT_HDR(struct ipv6_opt_hdr, skb, off);
1263 nexthdr = hp->nexthdr; 1292 nexthdr = hp->nexthdr;
1264 off += ipv6_optlen(hp); 1293 off += ipv6_optlen(hp);
1265 break; 1294 break;
1266 } 1295 }
1267 case IPPROTO_AH: { 1296 case IPPROTO_AH: {
1268 struct ip_auth_hdr *hp = (void *)(skb->data + off); 1297 struct ip_auth_hdr *hp;
1269 1298
1270 header_size = skb->network_header + 1299 err = maybe_pull_tail(skb,
1271 off + 1300 off +
1272 sizeof(struct ip_auth_hdr); 1301 sizeof(struct ip_auth_hdr),
1273 maybe_pull_tail(skb, header_size); 1302 MAX_IPV6_HDR_LEN);
1303 if (err < 0)
1304 goto out;
1274 1305
1306 hp = OPT_HDR(struct ip_auth_hdr, skb, off);
1275 nexthdr = hp->nexthdr; 1307 nexthdr = hp->nexthdr;
1276 off += (hp->hdrlen+2)<<2; 1308 off += ipv6_authlen(hp);
1309 break;
1310 }
1311 case IPPROTO_FRAGMENT: {
1312 struct frag_hdr *hp;
1313
1314 err = maybe_pull_tail(skb,
1315 off +
1316 sizeof(struct frag_hdr),
1317 MAX_IPV6_HDR_LEN);
1318 if (err < 0)
1319 goto out;
1320
1321 hp = OPT_HDR(struct frag_hdr, skb, off);
1322
1323 if (hp->frag_off & htons(IP6_OFFSET | IP6_MF))
1324 fragment = true;
1325
1326 nexthdr = hp->nexthdr;
1327 off += sizeof(struct frag_hdr);
1277 break; 1328 break;
1278 } 1329 }
1279 case IPPROTO_FRAGMENT:
1280 fragment = true;
1281 /* fall through */
1282 default: 1330 default:
1283 done = true; 1331 done = true;
1284 break; 1332 break;
1285 } 1333 }
1286 } 1334 }
1287 1335
1288 if (!done) { 1336 err = -EPROTO;
1289 if (net_ratelimit())
1290 netdev_err(vif->dev, "Failed to parse packet header\n");
1291 goto out;
1292 }
1293 1337
1294 if (fragment) { 1338 if (!done || fragment)
1295 if (net_ratelimit())
1296 netdev_err(vif->dev, "Packet is a fragment!\n");
1297 goto out; 1339 goto out;
1298 }
1299 1340
1300 switch (nexthdr) { 1341 switch (nexthdr) {
1301 case IPPROTO_TCP: 1342 case IPPROTO_TCP:
1343 err = maybe_pull_tail(skb,
1344 off + sizeof(struct tcphdr),
1345 MAX_IPV6_HDR_LEN);
1346 if (err < 0)
1347 goto out;
1348
1302 if (!skb_partial_csum_set(skb, off, 1349 if (!skb_partial_csum_set(skb, off,
1303 offsetof(struct tcphdr, check))) 1350 offsetof(struct tcphdr, check)))
1304 goto out; 1351 goto out;
1305 1352
1306 if (recalculate_partial_csum) { 1353 if (recalculate_partial_csum)
1307 struct tcphdr *tcph = tcp_hdr(skb); 1354 tcp_hdr(skb)->check =
1308 1355 ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
1309 header_size = skb->network_header + 1356 &ipv6_hdr(skb)->daddr,
1310 off + 1357 skb->len - off,
1311 sizeof(struct tcphdr); 1358 IPPROTO_TCP, 0);
1312 maybe_pull_tail(skb, header_size);
1313
1314 tcph->check = ~csum_ipv6_magic(&ipv6h->saddr,
1315 &ipv6h->daddr,
1316 skb->len - off,
1317 IPPROTO_TCP, 0);
1318 }
1319 break; 1359 break;
1320 case IPPROTO_UDP: 1360 case IPPROTO_UDP:
1361 err = maybe_pull_tail(skb,
1362 off + sizeof(struct udphdr),
1363 MAX_IPV6_HDR_LEN);
1364 if (err < 0)
1365 goto out;
1366
1321 if (!skb_partial_csum_set(skb, off, 1367 if (!skb_partial_csum_set(skb, off,
1322 offsetof(struct udphdr, check))) 1368 offsetof(struct udphdr, check)))
1323 goto out; 1369 goto out;
1324 1370
1325 if (recalculate_partial_csum) { 1371 if (recalculate_partial_csum)
1326 struct udphdr *udph = udp_hdr(skb); 1372 udp_hdr(skb)->check =
1327 1373 ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
1328 header_size = skb->network_header + 1374 &ipv6_hdr(skb)->daddr,
1329 off + 1375 skb->len - off,
1330 sizeof(struct udphdr); 1376 IPPROTO_UDP, 0);
1331 maybe_pull_tail(skb, header_size);
1332
1333 udph->check = ~csum_ipv6_magic(&ipv6h->saddr,
1334 &ipv6h->daddr,
1335 skb->len - off,
1336 IPPROTO_UDP, 0);
1337 }
1338 break; 1377 break;
1339 default: 1378 default:
1340 if (net_ratelimit())
1341 netdev_err(vif->dev,
1342 "Attempting to checksum a non-TCP/UDP packet, "
1343 "dropping a protocol %d packet\n",
1344 nexthdr);
1345 goto out; 1379 goto out;
1346 } 1380 }
1347 1381
@@ -1411,14 +1445,15 @@ static bool tx_credit_exceeded(struct xenvif *vif, unsigned size)
1411 return false; 1445 return false;
1412} 1446}
1413 1447
1414static unsigned xenvif_tx_build_gops(struct xenvif *vif) 1448static unsigned xenvif_tx_build_gops(struct xenvif *vif, int budget)
1415{ 1449{
1416 struct gnttab_copy *gop = vif->tx_copy_ops, *request_gop; 1450 struct gnttab_copy *gop = vif->tx_copy_ops, *request_gop;
1417 struct sk_buff *skb; 1451 struct sk_buff *skb;
1418 int ret; 1452 int ret;
1419 1453
1420 while ((nr_pending_reqs(vif) + XEN_NETBK_LEGACY_SLOTS_MAX 1454 while ((nr_pending_reqs(vif) + XEN_NETBK_LEGACY_SLOTS_MAX
1421 < MAX_PENDING_REQS)) { 1455 < MAX_PENDING_REQS) &&
1456 (skb_queue_len(&vif->tx_queue) < budget)) {
1422 struct xen_netif_tx_request txreq; 1457 struct xen_netif_tx_request txreq;
1423 struct xen_netif_tx_request txfrags[XEN_NETBK_LEGACY_SLOTS_MAX]; 1458 struct xen_netif_tx_request txfrags[XEN_NETBK_LEGACY_SLOTS_MAX];
1424 struct page *page; 1459 struct page *page;
@@ -1440,7 +1475,7 @@ static unsigned xenvif_tx_build_gops(struct xenvif *vif)
1440 continue; 1475 continue;
1441 } 1476 }
1442 1477
1443 RING_FINAL_CHECK_FOR_REQUESTS(&vif->tx, work_to_do); 1478 work_to_do = RING_HAS_UNCONSUMED_REQUESTS(&vif->tx);
1444 if (!work_to_do) 1479 if (!work_to_do)
1445 break; 1480 break;
1446 1481
@@ -1580,14 +1615,13 @@ static unsigned xenvif_tx_build_gops(struct xenvif *vif)
1580} 1615}
1581 1616
1582 1617
1583static int xenvif_tx_submit(struct xenvif *vif, int budget) 1618static int xenvif_tx_submit(struct xenvif *vif)
1584{ 1619{
1585 struct gnttab_copy *gop = vif->tx_copy_ops; 1620 struct gnttab_copy *gop = vif->tx_copy_ops;
1586 struct sk_buff *skb; 1621 struct sk_buff *skb;
1587 int work_done = 0; 1622 int work_done = 0;
1588 1623
1589 while (work_done < budget && 1624 while ((skb = __skb_dequeue(&vif->tx_queue)) != NULL) {
1590 (skb = __skb_dequeue(&vif->tx_queue)) != NULL) {
1591 struct xen_netif_tx_request *txp; 1625 struct xen_netif_tx_request *txp;
1592 u16 pending_idx; 1626 u16 pending_idx;
1593 unsigned data_len; 1627 unsigned data_len;
@@ -1662,14 +1696,14 @@ int xenvif_tx_action(struct xenvif *vif, int budget)
1662 if (unlikely(!tx_work_todo(vif))) 1696 if (unlikely(!tx_work_todo(vif)))
1663 return 0; 1697 return 0;
1664 1698
1665 nr_gops = xenvif_tx_build_gops(vif); 1699 nr_gops = xenvif_tx_build_gops(vif, budget);
1666 1700
1667 if (nr_gops == 0) 1701 if (nr_gops == 0)
1668 return 0; 1702 return 0;
1669 1703
1670 gnttab_batch_copy(vif->tx_copy_ops, nr_gops); 1704 gnttab_batch_copy(vif->tx_copy_ops, nr_gops);
1671 1705
1672 work_done = xenvif_tx_submit(vif, nr_gops); 1706 work_done = xenvif_tx_submit(vif);
1673 1707
1674 return work_done; 1708 return work_done;
1675} 1709}
diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
index c269e430c760..2aa7b77c7c88 100644
--- a/drivers/pci/host/pci-mvebu.c
+++ b/drivers/pci/host/pci-mvebu.c
@@ -447,6 +447,11 @@ static int mvebu_sw_pci_bridge_read(struct mvebu_pcie_port *port,
447 *value = 0; 447 *value = 0;
448 break; 448 break;
449 449
450 case PCI_INTERRUPT_LINE:
451 /* LINE PIN MIN_GNT MAX_LAT */
452 *value = 0;
453 break;
454
450 default: 455 default:
451 *value = 0xffffffff; 456 *value = 0xffffffff;
452 return PCIBIOS_BAD_REGISTER_NUMBER; 457 return PCIBIOS_BAD_REGISTER_NUMBER;
diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c
index 0afbbbc55c81..0175041ab728 100644
--- a/drivers/pci/host/pci-tegra.c
+++ b/drivers/pci/host/pci-tegra.c
@@ -25,7 +25,6 @@
25 */ 25 */
26 26
27#include <linux/clk.h> 27#include <linux/clk.h>
28#include <linux/clk/tegra.h>
29#include <linux/delay.h> 28#include <linux/delay.h>
30#include <linux/export.h> 29#include <linux/export.h>
31#include <linux/interrupt.h> 30#include <linux/interrupt.h>
@@ -39,6 +38,7 @@
39#include <linux/of_platform.h> 38#include <linux/of_platform.h>
40#include <linux/pci.h> 39#include <linux/pci.h>
41#include <linux/platform_device.h> 40#include <linux/platform_device.h>
41#include <linux/reset.h>
42#include <linux/sizes.h> 42#include <linux/sizes.h>
43#include <linux/slab.h> 43#include <linux/slab.h>
44#include <linux/tegra-cpuidle.h> 44#include <linux/tegra-cpuidle.h>
@@ -259,10 +259,13 @@ struct tegra_pcie {
259 259
260 struct clk *pex_clk; 260 struct clk *pex_clk;
261 struct clk *afi_clk; 261 struct clk *afi_clk;
262 struct clk *pcie_xclk;
263 struct clk *pll_e; 262 struct clk *pll_e;
264 struct clk *cml_clk; 263 struct clk *cml_clk;
265 264
265 struct reset_control *pex_rst;
266 struct reset_control *afi_rst;
267 struct reset_control *pcie_xrst;
268
266 struct tegra_msi msi; 269 struct tegra_msi msi;
267 270
268 struct list_head ports; 271 struct list_head ports;
@@ -858,7 +861,7 @@ static int tegra_pcie_enable_controller(struct tegra_pcie *pcie)
858 pads_writel(pcie, value, PADS_CTL); 861 pads_writel(pcie, value, PADS_CTL);
859 862
860 /* take the PCIe interface module out of reset */ 863 /* take the PCIe interface module out of reset */
861 tegra_periph_reset_deassert(pcie->pcie_xclk); 864 reset_control_deassert(pcie->pcie_xrst);
862 865
863 /* finally enable PCIe */ 866 /* finally enable PCIe */
864 value = afi_readl(pcie, AFI_CONFIGURATION); 867 value = afi_readl(pcie, AFI_CONFIGURATION);
@@ -891,9 +894,9 @@ static void tegra_pcie_power_off(struct tegra_pcie *pcie)
891 894
892 /* TODO: disable and unprepare clocks? */ 895 /* TODO: disable and unprepare clocks? */
893 896
894 tegra_periph_reset_assert(pcie->pcie_xclk); 897 reset_control_assert(pcie->pcie_xrst);
895 tegra_periph_reset_assert(pcie->afi_clk); 898 reset_control_assert(pcie->afi_rst);
896 tegra_periph_reset_assert(pcie->pex_clk); 899 reset_control_assert(pcie->pex_rst);
897 900
898 tegra_powergate_power_off(TEGRA_POWERGATE_PCIE); 901 tegra_powergate_power_off(TEGRA_POWERGATE_PCIE);
899 902
@@ -921,9 +924,9 @@ static int tegra_pcie_power_on(struct tegra_pcie *pcie)
921 const struct tegra_pcie_soc_data *soc = pcie->soc_data; 924 const struct tegra_pcie_soc_data *soc = pcie->soc_data;
922 int err; 925 int err;
923 926
924 tegra_periph_reset_assert(pcie->pcie_xclk); 927 reset_control_assert(pcie->pcie_xrst);
925 tegra_periph_reset_assert(pcie->afi_clk); 928 reset_control_assert(pcie->afi_rst);
926 tegra_periph_reset_assert(pcie->pex_clk); 929 reset_control_assert(pcie->pex_rst);
927 930
928 tegra_powergate_power_off(TEGRA_POWERGATE_PCIE); 931 tegra_powergate_power_off(TEGRA_POWERGATE_PCIE);
929 932
@@ -952,13 +955,14 @@ static int tegra_pcie_power_on(struct tegra_pcie *pcie)
952 } 955 }
953 956
954 err = tegra_powergate_sequence_power_up(TEGRA_POWERGATE_PCIE, 957 err = tegra_powergate_sequence_power_up(TEGRA_POWERGATE_PCIE,
955 pcie->pex_clk); 958 pcie->pex_clk,
959 pcie->pex_rst);
956 if (err) { 960 if (err) {
957 dev_err(pcie->dev, "powerup sequence failed: %d\n", err); 961 dev_err(pcie->dev, "powerup sequence failed: %d\n", err);
958 return err; 962 return err;
959 } 963 }
960 964
961 tegra_periph_reset_deassert(pcie->afi_clk); 965 reset_control_deassert(pcie->afi_rst);
962 966
963 err = clk_prepare_enable(pcie->afi_clk); 967 err = clk_prepare_enable(pcie->afi_clk);
964 if (err < 0) { 968 if (err < 0) {
@@ -996,10 +1000,6 @@ static int tegra_pcie_clocks_get(struct tegra_pcie *pcie)
996 if (IS_ERR(pcie->afi_clk)) 1000 if (IS_ERR(pcie->afi_clk))
997 return PTR_ERR(pcie->afi_clk); 1001 return PTR_ERR(pcie->afi_clk);
998 1002
999 pcie->pcie_xclk = devm_clk_get(pcie->dev, "pcie_xclk");
1000 if (IS_ERR(pcie->pcie_xclk))
1001 return PTR_ERR(pcie->pcie_xclk);
1002
1003 pcie->pll_e = devm_clk_get(pcie->dev, "pll_e"); 1003 pcie->pll_e = devm_clk_get(pcie->dev, "pll_e");
1004 if (IS_ERR(pcie->pll_e)) 1004 if (IS_ERR(pcie->pll_e))
1005 return PTR_ERR(pcie->pll_e); 1005 return PTR_ERR(pcie->pll_e);
@@ -1013,6 +1013,23 @@ static int tegra_pcie_clocks_get(struct tegra_pcie *pcie)
1013 return 0; 1013 return 0;
1014} 1014}
1015 1015
1016static int tegra_pcie_resets_get(struct tegra_pcie *pcie)
1017{
1018 pcie->pex_rst = devm_reset_control_get(pcie->dev, "pex");
1019 if (IS_ERR(pcie->pex_rst))
1020 return PTR_ERR(pcie->pex_rst);
1021
1022 pcie->afi_rst = devm_reset_control_get(pcie->dev, "afi");
1023 if (IS_ERR(pcie->afi_rst))
1024 return PTR_ERR(pcie->afi_rst);
1025
1026 pcie->pcie_xrst = devm_reset_control_get(pcie->dev, "pcie_x");
1027 if (IS_ERR(pcie->pcie_xrst))
1028 return PTR_ERR(pcie->pcie_xrst);
1029
1030 return 0;
1031}
1032
1016static int tegra_pcie_get_resources(struct tegra_pcie *pcie) 1033static int tegra_pcie_get_resources(struct tegra_pcie *pcie)
1017{ 1034{
1018 struct platform_device *pdev = to_platform_device(pcie->dev); 1035 struct platform_device *pdev = to_platform_device(pcie->dev);
@@ -1025,6 +1042,12 @@ static int tegra_pcie_get_resources(struct tegra_pcie *pcie)
1025 return err; 1042 return err;
1026 } 1043 }
1027 1044
1045 err = tegra_pcie_resets_get(pcie);
1046 if (err) {
1047 dev_err(&pdev->dev, "failed to get resets: %d\n", err);
1048 return err;
1049 }
1050
1028 err = tegra_pcie_power_on(pcie); 1051 err = tegra_pcie_power_on(pcie);
1029 if (err) { 1052 if (err) {
1030 dev_err(&pdev->dev, "failed to power up: %d\n", err); 1053 dev_err(&pdev->dev, "failed to power up: %d\n", err);
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 9042fdbd7244..25f0bc659164 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -19,6 +19,7 @@
19#include <linux/cpu.h> 19#include <linux/cpu.h>
20#include <linux/pm_runtime.h> 20#include <linux/pm_runtime.h>
21#include <linux/suspend.h> 21#include <linux/suspend.h>
22#include <linux/kexec.h>
22#include "pci.h" 23#include "pci.h"
23 24
24struct pci_dynid { 25struct pci_dynid {
@@ -288,12 +289,27 @@ static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev,
288 int error, node; 289 int error, node;
289 struct drv_dev_and_id ddi = { drv, dev, id }; 290 struct drv_dev_and_id ddi = { drv, dev, id };
290 291
291 /* Execute driver initialization on node where the device's 292 /*
292 bus is attached to. This way the driver likely allocates 293 * Execute driver initialization on node where the device is
293 its local memory on the right node without any need to 294 * attached. This way the driver likely allocates its local memory
294 change it. */ 295 * on the right node.
296 */
295 node = dev_to_node(&dev->dev); 297 node = dev_to_node(&dev->dev);
296 if (node >= 0) { 298
299 /*
300 * On NUMA systems, we are likely to call a PF probe function using
301 * work_on_cpu(). If that probe calls pci_enable_sriov() (which
302 * adds the VF devices via pci_bus_add_device()), we may re-enter
303 * this function to call the VF probe function. Calling
304 * work_on_cpu() again will cause a lockdep warning. Since VFs are
305 * always on the same node as the PF, we can work around this by
306 * avoiding work_on_cpu() when we're already on the correct node.
307 *
308 * Preemption is enabled, so it's theoretically unsafe to use
309 * numa_node_id(), but even if we run the probe function on the
310 * wrong node, it should be functionally correct.
311 */
312 if (node >= 0 && node != numa_node_id()) {
297 int cpu; 313 int cpu;
298 314
299 get_online_cpus(); 315 get_online_cpus();
@@ -305,6 +321,7 @@ static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev,
305 put_online_cpus(); 321 put_online_cpus();
306 } else 322 } else
307 error = local_pci_probe(&ddi); 323 error = local_pci_probe(&ddi);
324
308 return error; 325 return error;
309} 326}
310 327
@@ -399,12 +416,17 @@ static void pci_device_shutdown(struct device *dev)
399 pci_msi_shutdown(pci_dev); 416 pci_msi_shutdown(pci_dev);
400 pci_msix_shutdown(pci_dev); 417 pci_msix_shutdown(pci_dev);
401 418
419#ifdef CONFIG_KEXEC
402 /* 420 /*
403 * Turn off Bus Master bit on the device to tell it to not 421 * If this is a kexec reboot, turn off Bus Master bit on the
404 * continue to do DMA. Don't touch devices in D3cold or unknown states. 422 * device to tell it to not continue to do DMA. Don't touch
423 * devices in D3cold or unknown states.
424 * If it is not a kexec reboot, firmware will hit the PCI
425 * devices with big hammer and stop their DMA any way.
405 */ 426 */
406 if (pci_dev->current_state <= PCI_D3hot) 427 if (kexec_in_progress && (pci_dev->current_state <= PCI_D3hot))
407 pci_clear_master(pci_dev); 428 pci_clear_master(pci_dev);
429#endif
408} 430}
409 431
410#ifdef CONFIG_PM 432#ifdef CONFIG_PM
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 33120d156668..07369f32e8bb 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4165,6 +4165,14 @@ int pci_set_vga_state(struct pci_dev *dev, bool decode,
4165 return 0; 4165 return 0;
4166} 4166}
4167 4167
4168bool pci_device_is_present(struct pci_dev *pdev)
4169{
4170 u32 v;
4171
4172 return pci_bus_read_dev_vendor_id(pdev->bus, pdev->devfn, &v, 0);
4173}
4174EXPORT_SYMBOL_GPL(pci_device_is_present);
4175
4168#define RESOURCE_ALIGNMENT_PARAM_SIZE COMMAND_LINE_SIZE 4176#define RESOURCE_ALIGNMENT_PARAM_SIZE COMMAND_LINE_SIZE
4169static char resource_alignment_param[RESOURCE_ALIGNMENT_PARAM_SIZE] = {0}; 4177static char resource_alignment_param[RESOURCE_ALIGNMENT_PARAM_SIZE] = {0};
4170static DEFINE_SPINLOCK(resource_alignment_lock); 4178static DEFINE_SPINLOCK(resource_alignment_lock);
diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c
index 1576851028db..cc9337a71529 100644
--- a/drivers/pci/remove.c
+++ b/drivers/pci/remove.c
@@ -24,7 +24,7 @@ static void pci_stop_dev(struct pci_dev *dev)
24 if (dev->is_added) { 24 if (dev->is_added) {
25 pci_proc_detach_device(dev); 25 pci_proc_detach_device(dev);
26 pci_remove_sysfs_dev_files(dev); 26 pci_remove_sysfs_dev_files(dev);
27 device_del(&dev->dev); 27 device_release_driver(&dev->dev);
28 dev->is_added = 0; 28 dev->is_added = 0;
29 } 29 }
30 30
@@ -34,6 +34,8 @@ static void pci_stop_dev(struct pci_dev *dev)
34 34
35static void pci_destroy_dev(struct pci_dev *dev) 35static void pci_destroy_dev(struct pci_dev *dev)
36{ 36{
37 device_del(&dev->dev);
38
37 down_write(&pci_bus_sem); 39 down_write(&pci_bus_sem);
38 list_del(&dev->bus_list); 40 list_del(&dev->bus_list);
39 up_write(&pci_bus_sem); 41 up_write(&pci_bus_sem);
diff --git a/drivers/regulator/as3722-regulator.c b/drivers/regulator/as3722-regulator.c
index 5917fe3dc983..b9f1d24c6812 100644
--- a/drivers/regulator/as3722-regulator.c
+++ b/drivers/regulator/as3722-regulator.c
@@ -590,8 +590,8 @@ static int as3722_sd016_set_current_limit(struct regulator_dev *rdev,
590 default: 590 default:
591 return -EINVAL; 591 return -EINVAL;
592 } 592 }
593 ret <<= ffs(mask) - 1;
593 val = ret & mask; 594 val = ret & mask;
594 val <<= ffs(mask) - 1;
595 return as3722_update_bits(as3722, reg, mask, val); 595 return as3722_update_bits(as3722, reg, mask, val);
596} 596}
597 597
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 3fe13130baec..d85f31385b24 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -119,6 +119,11 @@ static const char *rdev_get_name(struct regulator_dev *rdev)
119 return ""; 119 return "";
120} 120}
121 121
122static bool have_full_constraints(void)
123{
124 return has_full_constraints || of_have_populated_dt();
125}
126
122/** 127/**
123 * of_get_regulator - get a regulator device node based on supply name 128 * of_get_regulator - get a regulator device node based on supply name
124 * @dev: Device pointer for the consumer (of regulator) device 129 * @dev: Device pointer for the consumer (of regulator) device
@@ -1340,7 +1345,7 @@ static struct regulator *_regulator_get(struct device *dev, const char *id,
1340 * Assume that a regulator is physically present and enabled 1345 * Assume that a regulator is physically present and enabled
1341 * even if it isn't hooked up and just provide a dummy. 1346 * even if it isn't hooked up and just provide a dummy.
1342 */ 1347 */
1343 if (has_full_constraints && allow_dummy) { 1348 if (have_full_constraints() && allow_dummy) {
1344 pr_warn("%s supply %s not found, using dummy regulator\n", 1349 pr_warn("%s supply %s not found, using dummy regulator\n",
1345 devname, id); 1350 devname, id);
1346 1351
@@ -3627,7 +3632,7 @@ int regulator_suspend_finish(void)
3627 if (error) 3632 if (error)
3628 ret = error; 3633 ret = error;
3629 } else { 3634 } else {
3630 if (!has_full_constraints) 3635 if (!have_full_constraints())
3631 goto unlock; 3636 goto unlock;
3632 if (!ops->disable) 3637 if (!ops->disable)
3633 goto unlock; 3638 goto unlock;
@@ -3825,7 +3830,7 @@ static int __init regulator_init_complete(void)
3825 if (!enabled) 3830 if (!enabled)
3826 goto unlock; 3831 goto unlock;
3827 3832
3828 if (has_full_constraints) { 3833 if (have_full_constraints()) {
3829 /* We log since this may kill the system if it 3834 /* We log since this may kill the system if it
3830 * goes wrong. */ 3835 * goes wrong. */
3831 rdev_info(rdev, "disabling\n"); 3836 rdev_info(rdev, "disabling\n");
diff --git a/drivers/regulator/pfuze100-regulator.c b/drivers/regulator/pfuze100-regulator.c
index 032df3799efb..8b5e4c712a01 100644
--- a/drivers/regulator/pfuze100-regulator.c
+++ b/drivers/regulator/pfuze100-regulator.c
@@ -38,7 +38,7 @@
38 38
39#define PFUZE100_DEVICEID 0x0 39#define PFUZE100_DEVICEID 0x0
40#define PFUZE100_REVID 0x3 40#define PFUZE100_REVID 0x3
41#define PFUZE100_FABID 0x3 41#define PFUZE100_FABID 0x4
42 42
43#define PFUZE100_SW1ABVOL 0x20 43#define PFUZE100_SW1ABVOL 0x20
44#define PFUZE100_SW1CVOL 0x2e 44#define PFUZE100_SW1CVOL 0x2e
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c
index cbf91e25cf7f..aeb40aad0ae7 100644
--- a/drivers/regulator/s5m8767.c
+++ b/drivers/regulator/s5m8767.c
@@ -925,7 +925,7 @@ static int s5m8767_pmic_probe(struct platform_device *pdev)
925 config.dev = s5m8767->dev; 925 config.dev = s5m8767->dev;
926 config.init_data = pdata->regulators[i].initdata; 926 config.init_data = pdata->regulators[i].initdata;
927 config.driver_data = s5m8767; 927 config.driver_data = s5m8767;
928 config.regmap = iodev->regmap; 928 config.regmap = iodev->regmap_pmic;
929 config.of_node = pdata->regulators[i].reg_node; 929 config.of_node = pdata->regulators[i].reg_node;
930 930
931 rdev[i] = devm_regulator_register(&pdev->dev, &regulators[id], 931 rdev[i] = devm_regulator_register(&pdev->dev, &regulators[id],
diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c
index c0da95e95702..3281c90691c3 100644
--- a/drivers/rtc/rtc-at91rm9200.c
+++ b/drivers/rtc/rtc-at91rm9200.c
@@ -220,6 +220,8 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
220 220
221 at91_alarm_year = tm.tm_year; 221 at91_alarm_year = tm.tm_year;
222 222
223 tm.tm_mon = alrm->time.tm_mon;
224 tm.tm_mday = alrm->time.tm_mday;
223 tm.tm_hour = alrm->time.tm_hour; 225 tm.tm_hour = alrm->time.tm_hour;
224 tm.tm_min = alrm->time.tm_min; 226 tm.tm_min = alrm->time.tm_min;
225 tm.tm_sec = alrm->time.tm_sec; 227 tm.tm_sec = alrm->time.tm_sec;
diff --git a/drivers/rtc/rtc-s5m.c b/drivers/rtc/rtc-s5m.c
index b7fd02bc0a14..ae8119dc2846 100644
--- a/drivers/rtc/rtc-s5m.c
+++ b/drivers/rtc/rtc-s5m.c
@@ -28,10 +28,20 @@
28#include <linux/mfd/samsung/irq.h> 28#include <linux/mfd/samsung/irq.h>
29#include <linux/mfd/samsung/rtc.h> 29#include <linux/mfd/samsung/rtc.h>
30 30
31/*
32 * Maximum number of retries for checking changes in UDR field
33 * of SEC_RTC_UDR_CON register (to limit possible endless loop).
34 *
35 * After writing to RTC registers (setting time or alarm) read the UDR field
36 * in SEC_RTC_UDR_CON register. UDR is auto-cleared when data have
37 * been transferred.
38 */
39#define UDR_READ_RETRY_CNT 5
40
31struct s5m_rtc_info { 41struct s5m_rtc_info {
32 struct device *dev; 42 struct device *dev;
33 struct sec_pmic_dev *s5m87xx; 43 struct sec_pmic_dev *s5m87xx;
34 struct regmap *rtc; 44 struct regmap *regmap;
35 struct rtc_device *rtc_dev; 45 struct rtc_device *rtc_dev;
36 int irq; 46 int irq;
37 int device_type; 47 int device_type;
@@ -84,12 +94,31 @@ static int s5m8767_tm_to_data(struct rtc_time *tm, u8 *data)
84 } 94 }
85} 95}
86 96
97/*
98 * Read RTC_UDR_CON register and wait till UDR field is cleared.
99 * This indicates that time/alarm update ended.
100 */
101static inline int s5m8767_wait_for_udr_update(struct s5m_rtc_info *info)
102{
103 int ret, retry = UDR_READ_RETRY_CNT;
104 unsigned int data;
105
106 do {
107 ret = regmap_read(info->regmap, SEC_RTC_UDR_CON, &data);
108 } while (--retry && (data & RTC_UDR_MASK) && !ret);
109
110 if (!retry)
111 dev_err(info->dev, "waiting for UDR update, reached max number of retries\n");
112
113 return ret;
114}
115
87static inline int s5m8767_rtc_set_time_reg(struct s5m_rtc_info *info) 116static inline int s5m8767_rtc_set_time_reg(struct s5m_rtc_info *info)
88{ 117{
89 int ret; 118 int ret;
90 unsigned int data; 119 unsigned int data;
91 120
92 ret = regmap_read(info->rtc, SEC_RTC_UDR_CON, &data); 121 ret = regmap_read(info->regmap, SEC_RTC_UDR_CON, &data);
93 if (ret < 0) { 122 if (ret < 0) {
94 dev_err(info->dev, "failed to read update reg(%d)\n", ret); 123 dev_err(info->dev, "failed to read update reg(%d)\n", ret);
95 return ret; 124 return ret;
@@ -98,15 +127,13 @@ static inline int s5m8767_rtc_set_time_reg(struct s5m_rtc_info *info)
98 data |= RTC_TIME_EN_MASK; 127 data |= RTC_TIME_EN_MASK;
99 data |= RTC_UDR_MASK; 128 data |= RTC_UDR_MASK;
100 129
101 ret = regmap_write(info->rtc, SEC_RTC_UDR_CON, data); 130 ret = regmap_write(info->regmap, SEC_RTC_UDR_CON, data);
102 if (ret < 0) { 131 if (ret < 0) {
103 dev_err(info->dev, "failed to write update reg(%d)\n", ret); 132 dev_err(info->dev, "failed to write update reg(%d)\n", ret);
104 return ret; 133 return ret;
105 } 134 }
106 135
107 do { 136 ret = s5m8767_wait_for_udr_update(info);
108 ret = regmap_read(info->rtc, SEC_RTC_UDR_CON, &data);
109 } while ((data & RTC_UDR_MASK) && !ret);
110 137
111 return ret; 138 return ret;
112} 139}
@@ -116,7 +143,7 @@ static inline int s5m8767_rtc_set_alarm_reg(struct s5m_rtc_info *info)
116 int ret; 143 int ret;
117 unsigned int data; 144 unsigned int data;
118 145
119 ret = regmap_read(info->rtc, SEC_RTC_UDR_CON, &data); 146 ret = regmap_read(info->regmap, SEC_RTC_UDR_CON, &data);
120 if (ret < 0) { 147 if (ret < 0) {
121 dev_err(info->dev, "%s: fail to read update reg(%d)\n", 148 dev_err(info->dev, "%s: fail to read update reg(%d)\n",
122 __func__, ret); 149 __func__, ret);
@@ -126,16 +153,14 @@ static inline int s5m8767_rtc_set_alarm_reg(struct s5m_rtc_info *info)
126 data &= ~RTC_TIME_EN_MASK; 153 data &= ~RTC_TIME_EN_MASK;
127 data |= RTC_UDR_MASK; 154 data |= RTC_UDR_MASK;
128 155
129 ret = regmap_write(info->rtc, SEC_RTC_UDR_CON, data); 156 ret = regmap_write(info->regmap, SEC_RTC_UDR_CON, data);
130 if (ret < 0) { 157 if (ret < 0) {
131 dev_err(info->dev, "%s: fail to write update reg(%d)\n", 158 dev_err(info->dev, "%s: fail to write update reg(%d)\n",
132 __func__, ret); 159 __func__, ret);
133 return ret; 160 return ret;
134 } 161 }
135 162
136 do { 163 ret = s5m8767_wait_for_udr_update(info);
137 ret = regmap_read(info->rtc, SEC_RTC_UDR_CON, &data);
138 } while ((data & RTC_UDR_MASK) && !ret);
139 164
140 return ret; 165 return ret;
141} 166}
@@ -178,7 +203,7 @@ static int s5m_rtc_read_time(struct device *dev, struct rtc_time *tm)
178 u8 data[8]; 203 u8 data[8];
179 int ret; 204 int ret;
180 205
181 ret = regmap_bulk_read(info->rtc, SEC_RTC_SEC, data, 8); 206 ret = regmap_bulk_read(info->regmap, SEC_RTC_SEC, data, 8);
182 if (ret < 0) 207 if (ret < 0)
183 return ret; 208 return ret;
184 209
@@ -226,7 +251,7 @@ static int s5m_rtc_set_time(struct device *dev, struct rtc_time *tm)
226 1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, 251 1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday,
227 tm->tm_hour, tm->tm_min, tm->tm_sec, tm->tm_wday); 252 tm->tm_hour, tm->tm_min, tm->tm_sec, tm->tm_wday);
228 253
229 ret = regmap_raw_write(info->rtc, SEC_RTC_SEC, data, 8); 254 ret = regmap_raw_write(info->regmap, SEC_RTC_SEC, data, 8);
230 if (ret < 0) 255 if (ret < 0)
231 return ret; 256 return ret;
232 257
@@ -242,20 +267,20 @@ static int s5m_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
242 unsigned int val; 267 unsigned int val;
243 int ret, i; 268 int ret, i;
244 269
245 ret = regmap_bulk_read(info->rtc, SEC_ALARM0_SEC, data, 8); 270 ret = regmap_bulk_read(info->regmap, SEC_ALARM0_SEC, data, 8);
246 if (ret < 0) 271 if (ret < 0)
247 return ret; 272 return ret;
248 273
249 switch (info->device_type) { 274 switch (info->device_type) {
250 case S5M8763X: 275 case S5M8763X:
251 s5m8763_data_to_tm(data, &alrm->time); 276 s5m8763_data_to_tm(data, &alrm->time);
252 ret = regmap_read(info->rtc, SEC_ALARM0_CONF, &val); 277 ret = regmap_read(info->regmap, SEC_ALARM0_CONF, &val);
253 if (ret < 0) 278 if (ret < 0)
254 return ret; 279 return ret;
255 280
256 alrm->enabled = !!val; 281 alrm->enabled = !!val;
257 282
258 ret = regmap_read(info->rtc, SEC_RTC_STATUS, &val); 283 ret = regmap_read(info->regmap, SEC_RTC_STATUS, &val);
259 if (ret < 0) 284 if (ret < 0)
260 return ret; 285 return ret;
261 286
@@ -278,7 +303,7 @@ static int s5m_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
278 } 303 }
279 304
280 alrm->pending = 0; 305 alrm->pending = 0;
281 ret = regmap_read(info->rtc, SEC_RTC_STATUS, &val); 306 ret = regmap_read(info->regmap, SEC_RTC_STATUS, &val);
282 if (ret < 0) 307 if (ret < 0)
283 return ret; 308 return ret;
284 break; 309 break;
@@ -301,7 +326,7 @@ static int s5m_rtc_stop_alarm(struct s5m_rtc_info *info)
301 int ret, i; 326 int ret, i;
302 struct rtc_time tm; 327 struct rtc_time tm;
303 328
304 ret = regmap_bulk_read(info->rtc, SEC_ALARM0_SEC, data, 8); 329 ret = regmap_bulk_read(info->regmap, SEC_ALARM0_SEC, data, 8);
305 if (ret < 0) 330 if (ret < 0)
306 return ret; 331 return ret;
307 332
@@ -312,14 +337,14 @@ static int s5m_rtc_stop_alarm(struct s5m_rtc_info *info)
312 337
313 switch (info->device_type) { 338 switch (info->device_type) {
314 case S5M8763X: 339 case S5M8763X:
315 ret = regmap_write(info->rtc, SEC_ALARM0_CONF, 0); 340 ret = regmap_write(info->regmap, SEC_ALARM0_CONF, 0);
316 break; 341 break;
317 342
318 case S5M8767X: 343 case S5M8767X:
319 for (i = 0; i < 7; i++) 344 for (i = 0; i < 7; i++)
320 data[i] &= ~ALARM_ENABLE_MASK; 345 data[i] &= ~ALARM_ENABLE_MASK;
321 346
322 ret = regmap_raw_write(info->rtc, SEC_ALARM0_SEC, data, 8); 347 ret = regmap_raw_write(info->regmap, SEC_ALARM0_SEC, data, 8);
323 if (ret < 0) 348 if (ret < 0)
324 return ret; 349 return ret;
325 350
@@ -341,7 +366,7 @@ static int s5m_rtc_start_alarm(struct s5m_rtc_info *info)
341 u8 alarm0_conf; 366 u8 alarm0_conf;
342 struct rtc_time tm; 367 struct rtc_time tm;
343 368
344 ret = regmap_bulk_read(info->rtc, SEC_ALARM0_SEC, data, 8); 369 ret = regmap_bulk_read(info->regmap, SEC_ALARM0_SEC, data, 8);
345 if (ret < 0) 370 if (ret < 0)
346 return ret; 371 return ret;
347 372
@@ -353,7 +378,7 @@ static int s5m_rtc_start_alarm(struct s5m_rtc_info *info)
353 switch (info->device_type) { 378 switch (info->device_type) {
354 case S5M8763X: 379 case S5M8763X:
355 alarm0_conf = 0x77; 380 alarm0_conf = 0x77;
356 ret = regmap_write(info->rtc, SEC_ALARM0_CONF, alarm0_conf); 381 ret = regmap_write(info->regmap, SEC_ALARM0_CONF, alarm0_conf);
357 break; 382 break;
358 383
359 case S5M8767X: 384 case S5M8767X:
@@ -368,7 +393,7 @@ static int s5m_rtc_start_alarm(struct s5m_rtc_info *info)
368 if (data[RTC_YEAR1] & 0x7f) 393 if (data[RTC_YEAR1] & 0x7f)
369 data[RTC_YEAR1] |= ALARM_ENABLE_MASK; 394 data[RTC_YEAR1] |= ALARM_ENABLE_MASK;
370 395
371 ret = regmap_raw_write(info->rtc, SEC_ALARM0_SEC, data, 8); 396 ret = regmap_raw_write(info->regmap, SEC_ALARM0_SEC, data, 8);
372 if (ret < 0) 397 if (ret < 0)
373 return ret; 398 return ret;
374 ret = s5m8767_rtc_set_alarm_reg(info); 399 ret = s5m8767_rtc_set_alarm_reg(info);
@@ -410,7 +435,7 @@ static int s5m_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
410 if (ret < 0) 435 if (ret < 0)
411 return ret; 436 return ret;
412 437
413 ret = regmap_raw_write(info->rtc, SEC_ALARM0_SEC, data, 8); 438 ret = regmap_raw_write(info->regmap, SEC_ALARM0_SEC, data, 8);
414 if (ret < 0) 439 if (ret < 0)
415 return ret; 440 return ret;
416 441
@@ -455,7 +480,7 @@ static const struct rtc_class_ops s5m_rtc_ops = {
455static void s5m_rtc_enable_wtsr(struct s5m_rtc_info *info, bool enable) 480static void s5m_rtc_enable_wtsr(struct s5m_rtc_info *info, bool enable)
456{ 481{
457 int ret; 482 int ret;
458 ret = regmap_update_bits(info->rtc, SEC_WTSR_SMPL_CNTL, 483 ret = regmap_update_bits(info->regmap, SEC_WTSR_SMPL_CNTL,
459 WTSR_ENABLE_MASK, 484 WTSR_ENABLE_MASK,
460 enable ? WTSR_ENABLE_MASK : 0); 485 enable ? WTSR_ENABLE_MASK : 0);
461 if (ret < 0) 486 if (ret < 0)
@@ -466,7 +491,7 @@ static void s5m_rtc_enable_wtsr(struct s5m_rtc_info *info, bool enable)
466static void s5m_rtc_enable_smpl(struct s5m_rtc_info *info, bool enable) 491static void s5m_rtc_enable_smpl(struct s5m_rtc_info *info, bool enable)
467{ 492{
468 int ret; 493 int ret;
469 ret = regmap_update_bits(info->rtc, SEC_WTSR_SMPL_CNTL, 494 ret = regmap_update_bits(info->regmap, SEC_WTSR_SMPL_CNTL,
470 SMPL_ENABLE_MASK, 495 SMPL_ENABLE_MASK,
471 enable ? SMPL_ENABLE_MASK : 0); 496 enable ? SMPL_ENABLE_MASK : 0);
472 if (ret < 0) 497 if (ret < 0)
@@ -481,7 +506,7 @@ static int s5m8767_rtc_init_reg(struct s5m_rtc_info *info)
481 int ret; 506 int ret;
482 struct rtc_time tm; 507 struct rtc_time tm;
483 508
484 ret = regmap_read(info->rtc, SEC_RTC_UDR_CON, &tp_read); 509 ret = regmap_read(info->regmap, SEC_RTC_UDR_CON, &tp_read);
485 if (ret < 0) { 510 if (ret < 0) {
486 dev_err(info->dev, "%s: fail to read control reg(%d)\n", 511 dev_err(info->dev, "%s: fail to read control reg(%d)\n",
487 __func__, ret); 512 __func__, ret);
@@ -493,7 +518,7 @@ static int s5m8767_rtc_init_reg(struct s5m_rtc_info *info)
493 data[1] = (0 << BCD_EN_SHIFT) | (1 << MODEL24_SHIFT); 518 data[1] = (0 << BCD_EN_SHIFT) | (1 << MODEL24_SHIFT);
494 519
495 info->rtc_24hr_mode = 1; 520 info->rtc_24hr_mode = 1;
496 ret = regmap_raw_write(info->rtc, SEC_ALARM0_CONF, data, 2); 521 ret = regmap_raw_write(info->regmap, SEC_ALARM0_CONF, data, 2);
497 if (ret < 0) { 522 if (ret < 0) {
498 dev_err(info->dev, "%s: fail to write controlm reg(%d)\n", 523 dev_err(info->dev, "%s: fail to write controlm reg(%d)\n",
499 __func__, ret); 524 __func__, ret);
@@ -515,7 +540,7 @@ static int s5m8767_rtc_init_reg(struct s5m_rtc_info *info)
515 ret = s5m_rtc_set_time(info->dev, &tm); 540 ret = s5m_rtc_set_time(info->dev, &tm);
516 } 541 }
517 542
518 ret = regmap_update_bits(info->rtc, SEC_RTC_UDR_CON, 543 ret = regmap_update_bits(info->regmap, SEC_RTC_UDR_CON,
519 RTC_TCON_MASK, tp_read | RTC_TCON_MASK); 544 RTC_TCON_MASK, tp_read | RTC_TCON_MASK);
520 if (ret < 0) 545 if (ret < 0)
521 dev_err(info->dev, "%s: fail to update TCON reg(%d)\n", 546 dev_err(info->dev, "%s: fail to update TCON reg(%d)\n",
@@ -542,17 +567,19 @@ static int s5m_rtc_probe(struct platform_device *pdev)
542 567
543 info->dev = &pdev->dev; 568 info->dev = &pdev->dev;
544 info->s5m87xx = s5m87xx; 569 info->s5m87xx = s5m87xx;
545 info->rtc = s5m87xx->rtc; 570 info->regmap = s5m87xx->regmap_rtc;
546 info->device_type = s5m87xx->device_type; 571 info->device_type = s5m87xx->device_type;
547 info->wtsr_smpl = s5m87xx->wtsr_smpl; 572 info->wtsr_smpl = s5m87xx->wtsr_smpl;
548 573
549 switch (pdata->device_type) { 574 switch (pdata->device_type) {
550 case S5M8763X: 575 case S5M8763X:
551 info->irq = s5m87xx->irq_base + S5M8763_IRQ_ALARM0; 576 info->irq = regmap_irq_get_virq(s5m87xx->irq_data,
577 S5M8763_IRQ_ALARM0);
552 break; 578 break;
553 579
554 case S5M8767X: 580 case S5M8767X:
555 info->irq = s5m87xx->irq_base + S5M8767_IRQ_RTCA1; 581 info->irq = regmap_irq_get_virq(s5m87xx->irq_data,
582 S5M8767_IRQ_RTCA1);
556 break; 583 break;
557 584
558 default: 585 default:
@@ -596,7 +623,7 @@ static void s5m_rtc_shutdown(struct platform_device *pdev)
596 if (info->wtsr_smpl) { 623 if (info->wtsr_smpl) {
597 for (i = 0; i < 3; i++) { 624 for (i = 0; i < 3; i++) {
598 s5m_rtc_enable_wtsr(info, false); 625 s5m_rtc_enable_wtsr(info, false);
599 regmap_read(info->rtc, SEC_WTSR_SMPL_CNTL, &val); 626 regmap_read(info->regmap, SEC_WTSR_SMPL_CNTL, &val);
600 pr_debug("%s: WTSR_SMPL reg(0x%02x)\n", __func__, val); 627 pr_debug("%s: WTSR_SMPL reg(0x%02x)\n", __func__, val);
601 if (val & WTSR_ENABLE_MASK) 628 if (val & WTSR_ENABLE_MASK)
602 pr_emerg("%s: fail to disable WTSR\n", 629 pr_emerg("%s: fail to disable WTSR\n",
@@ -612,6 +639,30 @@ static void s5m_rtc_shutdown(struct platform_device *pdev)
612 s5m_rtc_enable_smpl(info, false); 639 s5m_rtc_enable_smpl(info, false);
613} 640}
614 641
642static int s5m_rtc_resume(struct device *dev)
643{
644 struct s5m_rtc_info *info = dev_get_drvdata(dev);
645 int ret = 0;
646
647 if (device_may_wakeup(dev))
648 ret = disable_irq_wake(info->irq);
649
650 return ret;
651}
652
653static int s5m_rtc_suspend(struct device *dev)
654{
655 struct s5m_rtc_info *info = dev_get_drvdata(dev);
656 int ret = 0;
657
658 if (device_may_wakeup(dev))
659 ret = enable_irq_wake(info->irq);
660
661 return ret;
662}
663
664static SIMPLE_DEV_PM_OPS(s5m_rtc_pm_ops, s5m_rtc_suspend, s5m_rtc_resume);
665
615static const struct platform_device_id s5m_rtc_id[] = { 666static const struct platform_device_id s5m_rtc_id[] = {
616 { "s5m-rtc", 0 }, 667 { "s5m-rtc", 0 },
617}; 668};
@@ -620,6 +671,7 @@ static struct platform_driver s5m_rtc_driver = {
620 .driver = { 671 .driver = {
621 .name = "s5m-rtc", 672 .name = "s5m-rtc",
622 .owner = THIS_MODULE, 673 .owner = THIS_MODULE,
674 .pm = &s5m_rtc_pm_ops,
623 }, 675 },
624 .probe = s5m_rtc_probe, 676 .probe = s5m_rtc_probe,
625 .shutdown = s5m_rtc_shutdown, 677 .shutdown = s5m_rtc_shutdown,
diff --git a/drivers/s390/block/dasd_genhd.c b/drivers/s390/block/dasd_genhd.c
index f64921756ad6..f224d59c4b6b 100644
--- a/drivers/s390/block/dasd_genhd.c
+++ b/drivers/s390/block/dasd_genhd.c
@@ -87,7 +87,6 @@ void dasd_gendisk_free(struct dasd_block *block)
87{ 87{
88 if (block->gdp) { 88 if (block->gdp) {
89 del_gendisk(block->gdp); 89 del_gendisk(block->gdp);
90 block->gdp->queue = NULL;
91 block->gdp->private_data = NULL; 90 block->gdp->private_data = NULL;
92 put_disk(block->gdp); 91 put_disk(block->gdp);
93 block->gdp = NULL; 92 block->gdp = NULL;
diff --git a/drivers/s390/char/sclp_early.c b/drivers/s390/char/sclp_early.c
index f7aa080e9b28..1465e9563101 100644
--- a/drivers/s390/char/sclp_early.c
+++ b/drivers/s390/char/sclp_early.c
@@ -35,7 +35,6 @@ struct read_info_sccb {
35 u8 _reserved5[4096 - 112]; /* 112-4095 */ 35 u8 _reserved5[4096 - 112]; /* 112-4095 */
36} __packed __aligned(PAGE_SIZE); 36} __packed __aligned(PAGE_SIZE);
37 37
38static __initdata struct init_sccb early_event_mask_sccb __aligned(PAGE_SIZE);
39static __initdata struct read_info_sccb early_read_info_sccb; 38static __initdata struct read_info_sccb early_read_info_sccb;
40static __initdata char sccb_early[PAGE_SIZE] __aligned(PAGE_SIZE); 39static __initdata char sccb_early[PAGE_SIZE] __aligned(PAGE_SIZE);
41static unsigned long sclp_hsa_size; 40static unsigned long sclp_hsa_size;
@@ -113,7 +112,7 @@ static void __init sclp_facilities_detect(void)
113 112
114bool __init sclp_has_linemode(void) 113bool __init sclp_has_linemode(void)
115{ 114{
116 struct init_sccb *sccb = &early_event_mask_sccb; 115 struct init_sccb *sccb = (void *) &sccb_early;
117 116
118 if (sccb->header.response_code != 0x20) 117 if (sccb->header.response_code != 0x20)
119 return 0; 118 return 0;
@@ -126,7 +125,7 @@ bool __init sclp_has_linemode(void)
126 125
127bool __init sclp_has_vt220(void) 126bool __init sclp_has_vt220(void)
128{ 127{
129 struct init_sccb *sccb = &early_event_mask_sccb; 128 struct init_sccb *sccb = (void *) &sccb_early;
130 129
131 if (sccb->header.response_code != 0x20) 130 if (sccb->header.response_code != 0x20)
132 return 0; 131 return 0;
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index eb1f1ef5fa2e..9fc66e83c1a7 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -448,6 +448,7 @@ config SPI_MXS
448config SPI_TEGRA114 448config SPI_TEGRA114
449 tristate "NVIDIA Tegra114 SPI Controller" 449 tristate "NVIDIA Tegra114 SPI Controller"
450 depends on (ARCH_TEGRA && TEGRA20_APB_DMA) || COMPILE_TEST 450 depends on (ARCH_TEGRA && TEGRA20_APB_DMA) || COMPILE_TEST
451 depends on RESET_CONTROLLER
451 help 452 help
452 SPI driver for NVIDIA Tegra114 SPI Controller interface. This controller 453 SPI driver for NVIDIA Tegra114 SPI Controller interface. This controller
453 is different than the older SoCs SPI controller and also register interface 454 is different than the older SoCs SPI controller and also register interface
@@ -456,6 +457,7 @@ config SPI_TEGRA114
456config SPI_TEGRA20_SFLASH 457config SPI_TEGRA20_SFLASH
457 tristate "Nvidia Tegra20 Serial flash Controller" 458 tristate "Nvidia Tegra20 Serial flash Controller"
458 depends on ARCH_TEGRA || COMPILE_TEST 459 depends on ARCH_TEGRA || COMPILE_TEST
460 depends on RESET_CONTROLLER
459 help 461 help
460 SPI driver for Nvidia Tegra20 Serial flash Controller interface. 462 SPI driver for Nvidia Tegra20 Serial flash Controller interface.
461 The main usecase of this controller is to use spi flash as boot 463 The main usecase of this controller is to use spi flash as boot
@@ -464,6 +466,7 @@ config SPI_TEGRA20_SFLASH
464config SPI_TEGRA20_SLINK 466config SPI_TEGRA20_SLINK
465 tristate "Nvidia Tegra20/Tegra30 SLINK Controller" 467 tristate "Nvidia Tegra20/Tegra30 SLINK Controller"
466 depends on (ARCH_TEGRA && TEGRA20_APB_DMA) || COMPILE_TEST 468 depends on (ARCH_TEGRA && TEGRA20_APB_DMA) || COMPILE_TEST
469 depends on RESET_CONTROLLER
467 help 470 help
468 SPI driver for Nvidia Tegra20/Tegra30 SLINK Controller interface. 471 SPI driver for Nvidia Tegra20/Tegra30 SLINK Controller interface.
469 472
diff --git a/drivers/spi/spi-tegra114.c b/drivers/spi/spi-tegra114.c
index aaecfb3ebf58..c8604981a058 100644
--- a/drivers/spi/spi-tegra114.c
+++ b/drivers/spi/spi-tegra114.c
@@ -17,7 +17,6 @@
17 */ 17 */
18 18
19#include <linux/clk.h> 19#include <linux/clk.h>
20#include <linux/clk/tegra.h>
21#include <linux/completion.h> 20#include <linux/completion.h>
22#include <linux/delay.h> 21#include <linux/delay.h>
23#include <linux/dmaengine.h> 22#include <linux/dmaengine.h>
@@ -34,6 +33,7 @@
34#include <linux/pm_runtime.h> 33#include <linux/pm_runtime.h>
35#include <linux/of.h> 34#include <linux/of.h>
36#include <linux/of_device.h> 35#include <linux/of_device.h>
36#include <linux/reset.h>
37#include <linux/spi/spi.h> 37#include <linux/spi/spi.h>
38 38
39#define SPI_COMMAND1 0x000 39#define SPI_COMMAND1 0x000
@@ -174,10 +174,10 @@ struct tegra_spi_data {
174 spinlock_t lock; 174 spinlock_t lock;
175 175
176 struct clk *clk; 176 struct clk *clk;
177 struct reset_control *rst;
177 void __iomem *base; 178 void __iomem *base;
178 phys_addr_t phys; 179 phys_addr_t phys;
179 unsigned irq; 180 unsigned irq;
180 int dma_req_sel;
181 u32 spi_max_frequency; 181 u32 spi_max_frequency;
182 u32 cur_speed; 182 u32 cur_speed;
183 183
@@ -600,15 +600,15 @@ static int tegra_spi_init_dma_param(struct tegra_spi_data *tspi,
600 dma_addr_t dma_phys; 600 dma_addr_t dma_phys;
601 int ret; 601 int ret;
602 struct dma_slave_config dma_sconfig; 602 struct dma_slave_config dma_sconfig;
603 dma_cap_mask_t mask;
604 603
605 dma_cap_zero(mask); 604 dma_chan = dma_request_slave_channel_reason(tspi->dev,
606 dma_cap_set(DMA_SLAVE, mask); 605 dma_to_memory ? "rx" : "tx");
607 dma_chan = dma_request_channel(mask, NULL, NULL); 606 if (IS_ERR(dma_chan)) {
608 if (!dma_chan) { 607 ret = PTR_ERR(dma_chan);
609 dev_err(tspi->dev, 608 if (ret != -EPROBE_DEFER)
610 "Dma channel is not available, will try later\n"); 609 dev_err(tspi->dev,
611 return -EPROBE_DEFER; 610 "Dma channel is not available: %d\n", ret);
611 return ret;
612 } 612 }
613 613
614 dma_buf = dma_alloc_coherent(tspi->dev, tspi->dma_buf_size, 614 dma_buf = dma_alloc_coherent(tspi->dev, tspi->dma_buf_size,
@@ -619,7 +619,6 @@ static int tegra_spi_init_dma_param(struct tegra_spi_data *tspi,
619 return -ENOMEM; 619 return -ENOMEM;
620 } 620 }
621 621
622 dma_sconfig.slave_id = tspi->dma_req_sel;
623 if (dma_to_memory) { 622 if (dma_to_memory) {
624 dma_sconfig.src_addr = tspi->phys + SPI_RX_FIFO; 623 dma_sconfig.src_addr = tspi->phys + SPI_RX_FIFO;
625 dma_sconfig.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 624 dma_sconfig.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
@@ -918,9 +917,9 @@ static irqreturn_t handle_cpu_based_xfer(struct tegra_spi_data *tspi)
918 tspi->status_reg); 917 tspi->status_reg);
919 dev_err(tspi->dev, "CpuXfer 0x%08x:0x%08x\n", 918 dev_err(tspi->dev, "CpuXfer 0x%08x:0x%08x\n",
920 tspi->command1_reg, tspi->dma_control_reg); 919 tspi->command1_reg, tspi->dma_control_reg);
921 tegra_periph_reset_assert(tspi->clk); 920 reset_control_assert(tspi->rst);
922 udelay(2); 921 udelay(2);
923 tegra_periph_reset_deassert(tspi->clk); 922 reset_control_deassert(tspi->rst);
924 complete(&tspi->xfer_completion); 923 complete(&tspi->xfer_completion);
925 goto exit; 924 goto exit;
926 } 925 }
@@ -990,9 +989,9 @@ static irqreturn_t handle_dma_based_xfer(struct tegra_spi_data *tspi)
990 tspi->status_reg); 989 tspi->status_reg);
991 dev_err(tspi->dev, "DmaXfer 0x%08x:0x%08x\n", 990 dev_err(tspi->dev, "DmaXfer 0x%08x:0x%08x\n",
992 tspi->command1_reg, tspi->dma_control_reg); 991 tspi->command1_reg, tspi->dma_control_reg);
993 tegra_periph_reset_assert(tspi->clk); 992 reset_control_assert(tspi->rst);
994 udelay(2); 993 udelay(2);
995 tegra_periph_reset_deassert(tspi->clk); 994 reset_control_deassert(tspi->rst);
996 complete(&tspi->xfer_completion); 995 complete(&tspi->xfer_completion);
997 spin_unlock_irqrestore(&tspi->lock, flags); 996 spin_unlock_irqrestore(&tspi->lock, flags);
998 return IRQ_HANDLED; 997 return IRQ_HANDLED;
@@ -1054,11 +1053,6 @@ static void tegra_spi_parse_dt(struct platform_device *pdev,
1054 struct tegra_spi_data *tspi) 1053 struct tegra_spi_data *tspi)
1055{ 1054{
1056 struct device_node *np = pdev->dev.of_node; 1055 struct device_node *np = pdev->dev.of_node;
1057 u32 of_dma[2];
1058
1059 if (of_property_read_u32_array(np, "nvidia,dma-request-selector",
1060 of_dma, 2) >= 0)
1061 tspi->dma_req_sel = of_dma[1];
1062 1056
1063 if (of_property_read_u32(np, "spi-max-frequency", 1057 if (of_property_read_u32(np, "spi-max-frequency",
1064 &tspi->spi_max_frequency)) 1058 &tspi->spi_max_frequency))
@@ -1127,25 +1121,25 @@ static int tegra_spi_probe(struct platform_device *pdev)
1127 goto exit_free_irq; 1121 goto exit_free_irq;
1128 } 1122 }
1129 1123
1124 tspi->rst = devm_reset_control_get(&pdev->dev, "spi");
1125 if (IS_ERR(tspi->rst)) {
1126 dev_err(&pdev->dev, "can not get reset\n");
1127 ret = PTR_ERR(tspi->rst);
1128 goto exit_free_irq;
1129 }
1130
1130 tspi->max_buf_size = SPI_FIFO_DEPTH << 2; 1131 tspi->max_buf_size = SPI_FIFO_DEPTH << 2;
1131 tspi->dma_buf_size = DEFAULT_SPI_DMA_BUF_LEN; 1132 tspi->dma_buf_size = DEFAULT_SPI_DMA_BUF_LEN;
1132 1133
1133 if (tspi->dma_req_sel) { 1134 ret = tegra_spi_init_dma_param(tspi, true);
1134 ret = tegra_spi_init_dma_param(tspi, true); 1135 if (ret < 0)
1135 if (ret < 0) { 1136 goto exit_free_irq;
1136 dev_err(&pdev->dev, "RxDma Init failed, err %d\n", ret); 1137 ret = tegra_spi_init_dma_param(tspi, false);
1137 goto exit_free_irq; 1138 if (ret < 0)
1138 } 1139 goto exit_rx_dma_free;
1139 1140 tspi->max_buf_size = tspi->dma_buf_size;
1140 ret = tegra_spi_init_dma_param(tspi, false); 1141 init_completion(&tspi->tx_dma_complete);
1141 if (ret < 0) { 1142 init_completion(&tspi->rx_dma_complete);
1142 dev_err(&pdev->dev, "TxDma Init failed, err %d\n", ret);
1143 goto exit_rx_dma_free;
1144 }
1145 tspi->max_buf_size = tspi->dma_buf_size;
1146 init_completion(&tspi->tx_dma_complete);
1147 init_completion(&tspi->rx_dma_complete);
1148 }
1149 1143
1150 init_completion(&tspi->xfer_completion); 1144 init_completion(&tspi->xfer_completion);
1151 1145
diff --git a/drivers/spi/spi-tegra20-sflash.c b/drivers/spi/spi-tegra20-sflash.c
index 4dc8e8129459..e6f382b33818 100644
--- a/drivers/spi/spi-tegra20-sflash.c
+++ b/drivers/spi/spi-tegra20-sflash.c
@@ -32,8 +32,8 @@
32#include <linux/pm_runtime.h> 32#include <linux/pm_runtime.h>
33#include <linux/of.h> 33#include <linux/of.h>
34#include <linux/of_device.h> 34#include <linux/of_device.h>
35#include <linux/reset.h>
35#include <linux/spi/spi.h> 36#include <linux/spi/spi.h>
36#include <linux/clk/tegra.h>
37 37
38#define SPI_COMMAND 0x000 38#define SPI_COMMAND 0x000
39#define SPI_GO BIT(30) 39#define SPI_GO BIT(30)
@@ -118,6 +118,7 @@ struct tegra_sflash_data {
118 spinlock_t lock; 118 spinlock_t lock;
119 119
120 struct clk *clk; 120 struct clk *clk;
121 struct reset_control *rst;
121 void __iomem *base; 122 void __iomem *base;
122 unsigned irq; 123 unsigned irq;
123 u32 spi_max_frequency; 124 u32 spi_max_frequency;
@@ -389,9 +390,9 @@ static irqreturn_t handle_cpu_based_xfer(struct tegra_sflash_data *tsd)
389 dev_err(tsd->dev, 390 dev_err(tsd->dev,
390 "CpuXfer 0x%08x:0x%08x\n", tsd->command_reg, 391 "CpuXfer 0x%08x:0x%08x\n", tsd->command_reg,
391 tsd->dma_control_reg); 392 tsd->dma_control_reg);
392 tegra_periph_reset_assert(tsd->clk); 393 reset_control_assert(tsd->rst);
393 udelay(2); 394 udelay(2);
394 tegra_periph_reset_deassert(tsd->clk); 395 reset_control_deassert(tsd->rst);
395 complete(&tsd->xfer_completion); 396 complete(&tsd->xfer_completion);
396 goto exit; 397 goto exit;
397 } 398 }
@@ -505,6 +506,13 @@ static int tegra_sflash_probe(struct platform_device *pdev)
505 goto exit_free_irq; 506 goto exit_free_irq;
506 } 507 }
507 508
509 tsd->rst = devm_reset_control_get(&pdev->dev, "spi");
510 if (IS_ERR(tsd->rst)) {
511 dev_err(&pdev->dev, "can not get reset\n");
512 ret = PTR_ERR(tsd->rst);
513 goto exit_free_irq;
514 }
515
508 init_completion(&tsd->xfer_completion); 516 init_completion(&tsd->xfer_completion);
509 pm_runtime_enable(&pdev->dev); 517 pm_runtime_enable(&pdev->dev);
510 if (!pm_runtime_enabled(&pdev->dev)) { 518 if (!pm_runtime_enabled(&pdev->dev)) {
@@ -520,9 +528,9 @@ static int tegra_sflash_probe(struct platform_device *pdev)
520 } 528 }
521 529
522 /* Reset controller */ 530 /* Reset controller */
523 tegra_periph_reset_assert(tsd->clk); 531 reset_control_assert(tsd->rst);
524 udelay(2); 532 udelay(2);
525 tegra_periph_reset_deassert(tsd->clk); 533 reset_control_deassert(tsd->rst);
526 534
527 tsd->def_command_reg = SPI_M_S | SPI_CS_SW; 535 tsd->def_command_reg = SPI_M_S | SPI_CS_SW;
528 tegra_sflash_writel(tsd, tsd->def_command_reg, SPI_COMMAND); 536 tegra_sflash_writel(tsd, tsd->def_command_reg, SPI_COMMAND);
diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slink.c
index e66715ba37ed..a728bb82090f 100644
--- a/drivers/spi/spi-tegra20-slink.c
+++ b/drivers/spi/spi-tegra20-slink.c
@@ -33,8 +33,8 @@
33#include <linux/pm_runtime.h> 33#include <linux/pm_runtime.h>
34#include <linux/of.h> 34#include <linux/of.h>
35#include <linux/of_device.h> 35#include <linux/of_device.h>
36#include <linux/reset.h>
36#include <linux/spi/spi.h> 37#include <linux/spi/spi.h>
37#include <linux/clk/tegra.h>
38 38
39#define SLINK_COMMAND 0x000 39#define SLINK_COMMAND 0x000
40#define SLINK_BIT_LENGTH(x) (((x) & 0x1f) << 0) 40#define SLINK_BIT_LENGTH(x) (((x) & 0x1f) << 0)
@@ -167,10 +167,10 @@ struct tegra_slink_data {
167 spinlock_t lock; 167 spinlock_t lock;
168 168
169 struct clk *clk; 169 struct clk *clk;
170 struct reset_control *rst;
170 void __iomem *base; 171 void __iomem *base;
171 phys_addr_t phys; 172 phys_addr_t phys;
172 unsigned irq; 173 unsigned irq;
173 int dma_req_sel;
174 u32 spi_max_frequency; 174 u32 spi_max_frequency;
175 u32 cur_speed; 175 u32 cur_speed;
176 176
@@ -629,15 +629,15 @@ static int tegra_slink_init_dma_param(struct tegra_slink_data *tspi,
629 dma_addr_t dma_phys; 629 dma_addr_t dma_phys;
630 int ret; 630 int ret;
631 struct dma_slave_config dma_sconfig; 631 struct dma_slave_config dma_sconfig;
632 dma_cap_mask_t mask;
633 632
634 dma_cap_zero(mask); 633 dma_chan = dma_request_slave_channel_reason(tspi->dev,
635 dma_cap_set(DMA_SLAVE, mask); 634 dma_to_memory ? "rx" : "tx");
636 dma_chan = dma_request_channel(mask, NULL, NULL); 635 if (IS_ERR(dma_chan)) {
637 if (!dma_chan) { 636 ret = PTR_ERR(dma_chan);
638 dev_err(tspi->dev, 637 if (ret != -EPROBE_DEFER)
639 "Dma channel is not available, will try later\n"); 638 dev_err(tspi->dev,
640 return -EPROBE_DEFER; 639 "Dma channel is not available: %d\n", ret);
640 return ret;
641 } 641 }
642 642
643 dma_buf = dma_alloc_coherent(tspi->dev, tspi->dma_buf_size, 643 dma_buf = dma_alloc_coherent(tspi->dev, tspi->dma_buf_size,
@@ -648,7 +648,6 @@ static int tegra_slink_init_dma_param(struct tegra_slink_data *tspi,
648 return -ENOMEM; 648 return -ENOMEM;
649 } 649 }
650 650
651 dma_sconfig.slave_id = tspi->dma_req_sel;
652 if (dma_to_memory) { 651 if (dma_to_memory) {
653 dma_sconfig.src_addr = tspi->phys + SLINK_RX_FIFO; 652 dma_sconfig.src_addr = tspi->phys + SLINK_RX_FIFO;
654 dma_sconfig.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 653 dma_sconfig.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
@@ -884,9 +883,9 @@ static irqreturn_t handle_cpu_based_xfer(struct tegra_slink_data *tspi)
884 dev_err(tspi->dev, 883 dev_err(tspi->dev,
885 "CpuXfer 0x%08x:0x%08x:0x%08x\n", tspi->command_reg, 884 "CpuXfer 0x%08x:0x%08x:0x%08x\n", tspi->command_reg,
886 tspi->command2_reg, tspi->dma_control_reg); 885 tspi->command2_reg, tspi->dma_control_reg);
887 tegra_periph_reset_assert(tspi->clk); 886 reset_control_assert(tspi->rst);
888 udelay(2); 887 udelay(2);
889 tegra_periph_reset_deassert(tspi->clk); 888 reset_control_deassert(tspi->rst);
890 complete(&tspi->xfer_completion); 889 complete(&tspi->xfer_completion);
891 goto exit; 890 goto exit;
892 } 891 }
@@ -957,9 +956,9 @@ static irqreturn_t handle_dma_based_xfer(struct tegra_slink_data *tspi)
957 dev_err(tspi->dev, 956 dev_err(tspi->dev,
958 "DmaXfer 0x%08x:0x%08x:0x%08x\n", tspi->command_reg, 957 "DmaXfer 0x%08x:0x%08x:0x%08x\n", tspi->command_reg,
959 tspi->command2_reg, tspi->dma_control_reg); 958 tspi->command2_reg, tspi->dma_control_reg);
960 tegra_periph_reset_assert(tspi->clk); 959 reset_control_assert(tspi->rst);
961 udelay(2); 960 udelay(2);
962 tegra_periph_reset_deassert(tspi->clk); 961 reset_control_assert(tspi->rst);
963 complete(&tspi->xfer_completion); 962 complete(&tspi->xfer_completion);
964 spin_unlock_irqrestore(&tspi->lock, flags); 963 spin_unlock_irqrestore(&tspi->lock, flags);
965 return IRQ_HANDLED; 964 return IRQ_HANDLED;
@@ -1020,11 +1019,6 @@ static irqreturn_t tegra_slink_isr(int irq, void *context_data)
1020static void tegra_slink_parse_dt(struct tegra_slink_data *tspi) 1019static void tegra_slink_parse_dt(struct tegra_slink_data *tspi)
1021{ 1020{
1022 struct device_node *np = tspi->dev->of_node; 1021 struct device_node *np = tspi->dev->of_node;
1023 u32 of_dma[2];
1024
1025 if (of_property_read_u32_array(np, "nvidia,dma-request-selector",
1026 of_dma, 2) >= 0)
1027 tspi->dma_req_sel = of_dma[1];
1028 1022
1029 if (of_property_read_u32(np, "spi-max-frequency", 1023 if (of_property_read_u32(np, "spi-max-frequency",
1030 &tspi->spi_max_frequency)) 1024 &tspi->spi_max_frequency))
@@ -1118,25 +1112,25 @@ static int tegra_slink_probe(struct platform_device *pdev)
1118 goto exit_free_irq; 1112 goto exit_free_irq;
1119 } 1113 }
1120 1114
1115 tspi->rst = devm_reset_control_get(&pdev->dev, "spi");
1116 if (IS_ERR(tspi->rst)) {
1117 dev_err(&pdev->dev, "can not get reset\n");
1118 ret = PTR_ERR(tspi->rst);
1119 goto exit_free_irq;
1120 }
1121
1121 tspi->max_buf_size = SLINK_FIFO_DEPTH << 2; 1122 tspi->max_buf_size = SLINK_FIFO_DEPTH << 2;
1122 tspi->dma_buf_size = DEFAULT_SPI_DMA_BUF_LEN; 1123 tspi->dma_buf_size = DEFAULT_SPI_DMA_BUF_LEN;
1123 1124
1124 if (tspi->dma_req_sel) { 1125 ret = tegra_slink_init_dma_param(tspi, true);
1125 ret = tegra_slink_init_dma_param(tspi, true); 1126 if (ret < 0)
1126 if (ret < 0) { 1127 goto exit_free_irq;
1127 dev_err(&pdev->dev, "RxDma Init failed, err %d\n", ret); 1128 ret = tegra_slink_init_dma_param(tspi, false);
1128 goto exit_free_irq; 1129 if (ret < 0)
1129 } 1130 goto exit_rx_dma_free;
1130 1131 tspi->max_buf_size = tspi->dma_buf_size;
1131 ret = tegra_slink_init_dma_param(tspi, false); 1132 init_completion(&tspi->tx_dma_complete);
1132 if (ret < 0) { 1133 init_completion(&tspi->rx_dma_complete);
1133 dev_err(&pdev->dev, "TxDma Init failed, err %d\n", ret);
1134 goto exit_rx_dma_free;
1135 }
1136 tspi->max_buf_size = tspi->dma_buf_size;
1137 init_completion(&tspi->tx_dma_complete);
1138 init_completion(&tspi->rx_dma_complete);
1139 }
1140 1134
1141 init_completion(&tspi->xfer_completion); 1135 init_completion(&tspi->xfer_completion);
1142 1136
diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
index 49ea76b3435d..986870593b0c 100644
--- a/drivers/staging/nvec/nvec.c
+++ b/drivers/staging/nvec/nvec.c
@@ -36,7 +36,6 @@
36#include <linux/slab.h> 36#include <linux/slab.h>
37#include <linux/spinlock.h> 37#include <linux/spinlock.h>
38#include <linux/workqueue.h> 38#include <linux/workqueue.h>
39#include <linux/clk/tegra.h>
40 39
41#include "nvec.h" 40#include "nvec.h"
42 41
@@ -734,9 +733,9 @@ static void tegra_init_i2c_slave(struct nvec_chip *nvec)
734 733
735 clk_prepare_enable(nvec->i2c_clk); 734 clk_prepare_enable(nvec->i2c_clk);
736 735
737 tegra_periph_reset_assert(nvec->i2c_clk); 736 reset_control_assert(nvec->rst);
738 udelay(2); 737 udelay(2);
739 tegra_periph_reset_deassert(nvec->i2c_clk); 738 reset_control_deassert(nvec->rst);
740 739
741 val = I2C_CNFG_NEW_MASTER_SFM | I2C_CNFG_PACKET_MODE_EN | 740 val = I2C_CNFG_NEW_MASTER_SFM | I2C_CNFG_PACKET_MODE_EN |
742 (0x2 << I2C_CNFG_DEBOUNCE_CNT_SHIFT); 741 (0x2 << I2C_CNFG_DEBOUNCE_CNT_SHIFT);
@@ -837,6 +836,12 @@ static int tegra_nvec_probe(struct platform_device *pdev)
837 return -ENODEV; 836 return -ENODEV;
838 } 837 }
839 838
839 nvec->rst = devm_reset_control_get(&pdev->dev, "i2c");
840 if (IS_ERR(nvec->rst)) {
841 dev_err(nvec->dev, "failed to get controller reset\n");
842 return PTR_ERR(nvec->rst);
843 }
844
840 nvec->base = base; 845 nvec->base = base;
841 nvec->irq = res->start; 846 nvec->irq = res->start;
842 nvec->i2c_clk = i2c_clk; 847 nvec->i2c_clk = i2c_clk;
diff --git a/drivers/staging/nvec/nvec.h b/drivers/staging/nvec/nvec.h
index e880518935fb..e271375053fa 100644
--- a/drivers/staging/nvec/nvec.h
+++ b/drivers/staging/nvec/nvec.h
@@ -23,6 +23,7 @@
23#include <linux/list.h> 23#include <linux/list.h>
24#include <linux/mutex.h> 24#include <linux/mutex.h>
25#include <linux/notifier.h> 25#include <linux/notifier.h>
26#include <linux/reset.h>
26#include <linux/spinlock.h> 27#include <linux/spinlock.h>
27#include <linux/workqueue.h> 28#include <linux/workqueue.h>
28 29
@@ -109,7 +110,8 @@ struct nvec_msg {
109 * @irq: The IRQ of the I2C device 110 * @irq: The IRQ of the I2C device
110 * @i2c_addr: The address of the I2C slave 111 * @i2c_addr: The address of the I2C slave
111 * @base: The base of the memory mapped region of the I2C device 112 * @base: The base of the memory mapped region of the I2C device
112 * @clk: The clock of the I2C device 113 * @i2c_clk: The clock of the I2C device
114 * @rst: The reset of the I2C device
113 * @notifier_list: Notifiers to be called on received messages, see 115 * @notifier_list: Notifiers to be called on received messages, see
114 * nvec_register_notifier() 116 * nvec_register_notifier()
115 * @rx_data: Received messages that have to be processed 117 * @rx_data: Received messages that have to be processed
@@ -139,6 +141,7 @@ struct nvec_chip {
139 int i2c_addr; 141 int i2c_addr;
140 void __iomem *base; 142 void __iomem *base;
141 struct clk *i2c_clk; 143 struct clk *i2c_clk;
144 struct reset_control *rst;
142 struct atomic_notifier_head notifier_list; 145 struct atomic_notifier_head notifier_list;
143 struct list_head rx_data, tx_data; 146 struct list_head rx_data, tx_data;
144 struct notifier_block nvec_status_notifier; 147 struct notifier_block nvec_status_notifier;
diff --git a/drivers/staging/tidspbridge/rmgr/drv_interface.c b/drivers/staging/tidspbridge/rmgr/drv_interface.c
index 1aa4a3fd0f1b..56e355b3e7fa 100644
--- a/drivers/staging/tidspbridge/rmgr/drv_interface.c
+++ b/drivers/staging/tidspbridge/rmgr/drv_interface.c
@@ -258,7 +258,8 @@ err:
258/* This function maps kernel space memory to user space memory. */ 258/* This function maps kernel space memory to user space memory. */
259static int bridge_mmap(struct file *filp, struct vm_area_struct *vma) 259static int bridge_mmap(struct file *filp, struct vm_area_struct *vma)
260{ 260{
261 u32 status; 261 struct omap_dsp_platform_data *pdata =
262 omap_dspbridge_dev->dev.platform_data;
262 263
263 /* VM_IO | VM_DONTEXPAND | VM_DONTDUMP are set by remap_pfn_range() */ 264 /* VM_IO | VM_DONTEXPAND | VM_DONTDUMP are set by remap_pfn_range() */
264 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 265 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
@@ -268,13 +269,9 @@ static int bridge_mmap(struct file *filp, struct vm_area_struct *vma)
268 vma->vm_start, vma->vm_end, vma->vm_page_prot, 269 vma->vm_start, vma->vm_end, vma->vm_page_prot,
269 vma->vm_flags); 270 vma->vm_flags);
270 271
271 status = remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff, 272 return vm_iomap_memory(vma,
272 vma->vm_end - vma->vm_start, 273 pdata->phys_mempool_base,
273 vma->vm_page_prot); 274 pdata->phys_mempool_size);
274 if (status != 0)
275 status = -EAGAIN;
276
277 return status;
278} 275}
279 276
280static const struct file_operations bridge_fops = { 277static const struct file_operations bridge_fops = {
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 0f74945af624..268b62768f2b 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -810,7 +810,8 @@ static void process_echoes(struct tty_struct *tty)
810 struct n_tty_data *ldata = tty->disc_data; 810 struct n_tty_data *ldata = tty->disc_data;
811 size_t echoed; 811 size_t echoed;
812 812
813 if (!L_ECHO(tty) || ldata->echo_commit == ldata->echo_tail) 813 if ((!L_ECHO(tty) && !L_ECHONL(tty)) ||
814 ldata->echo_commit == ldata->echo_tail)
814 return; 815 return;
815 816
816 mutex_lock(&ldata->output_lock); 817 mutex_lock(&ldata->output_lock);
@@ -825,7 +826,8 @@ static void flush_echoes(struct tty_struct *tty)
825{ 826{
826 struct n_tty_data *ldata = tty->disc_data; 827 struct n_tty_data *ldata = tty->disc_data;
827 828
828 if (!L_ECHO(tty) || ldata->echo_commit == ldata->echo_head) 829 if ((!L_ECHO(tty) && !L_ECHONL(tty)) ||
830 ldata->echo_commit == ldata->echo_head)
829 return; 831 return;
830 832
831 mutex_lock(&ldata->output_lock); 833 mutex_lock(&ldata->output_lock);
diff --git a/drivers/tty/serial/serial-tegra.c b/drivers/tty/serial/serial-tegra.c
index dfe79ccc4fb3..d5c2a287b7e7 100644
--- a/drivers/tty/serial/serial-tegra.c
+++ b/drivers/tty/serial/serial-tegra.c
@@ -34,6 +34,7 @@
34#include <linux/of_device.h> 34#include <linux/of_device.h>
35#include <linux/pagemap.h> 35#include <linux/pagemap.h>
36#include <linux/platform_device.h> 36#include <linux/platform_device.h>
37#include <linux/reset.h>
37#include <linux/serial.h> 38#include <linux/serial.h>
38#include <linux/serial_8250.h> 39#include <linux/serial_8250.h>
39#include <linux/serial_core.h> 40#include <linux/serial_core.h>
@@ -44,8 +45,6 @@
44#include <linux/tty.h> 45#include <linux/tty.h>
45#include <linux/tty_flip.h> 46#include <linux/tty_flip.h>
46 47
47#include <linux/clk/tegra.h>
48
49#define TEGRA_UART_TYPE "TEGRA_UART" 48#define TEGRA_UART_TYPE "TEGRA_UART"
50#define TX_EMPTY_STATUS (UART_LSR_TEMT | UART_LSR_THRE) 49#define TX_EMPTY_STATUS (UART_LSR_TEMT | UART_LSR_THRE)
51#define BYTES_TO_ALIGN(x) ((unsigned long)(x) & 0x3) 50#define BYTES_TO_ALIGN(x) ((unsigned long)(x) & 0x3)
@@ -103,6 +102,7 @@ struct tegra_uart_port {
103 const struct tegra_uart_chip_data *cdata; 102 const struct tegra_uart_chip_data *cdata;
104 103
105 struct clk *uart_clk; 104 struct clk *uart_clk;
105 struct reset_control *rst;
106 unsigned int current_baud; 106 unsigned int current_baud;
107 107
108 /* Register shadow */ 108 /* Register shadow */
@@ -120,7 +120,6 @@ struct tegra_uart_port {
120 bool rx_timeout; 120 bool rx_timeout;
121 int rx_in_progress; 121 int rx_in_progress;
122 int symb_bit; 122 int symb_bit;
123 int dma_req_sel;
124 123
125 struct dma_chan *rx_dma_chan; 124 struct dma_chan *rx_dma_chan;
126 struct dma_chan *tx_dma_chan; 125 struct dma_chan *tx_dma_chan;
@@ -832,9 +831,9 @@ static int tegra_uart_hw_init(struct tegra_uart_port *tup)
832 clk_prepare_enable(tup->uart_clk); 831 clk_prepare_enable(tup->uart_clk);
833 832
834 /* Reset the UART controller to clear all previous status.*/ 833 /* Reset the UART controller to clear all previous status.*/
835 tegra_periph_reset_assert(tup->uart_clk); 834 reset_control_assert(tup->rst);
836 udelay(10); 835 udelay(10);
837 tegra_periph_reset_deassert(tup->uart_clk); 836 reset_control_deassert(tup->rst);
838 837
839 tup->rx_in_progress = 0; 838 tup->rx_in_progress = 0;
840 tup->tx_in_progress = 0; 839 tup->tx_in_progress = 0;
@@ -910,15 +909,14 @@ static int tegra_uart_dma_channel_allocate(struct tegra_uart_port *tup,
910 dma_addr_t dma_phys; 909 dma_addr_t dma_phys;
911 int ret; 910 int ret;
912 struct dma_slave_config dma_sconfig; 911 struct dma_slave_config dma_sconfig;
913 dma_cap_mask_t mask;
914 912
915 dma_cap_zero(mask); 913 dma_chan = dma_request_slave_channel_reason(tup->uport.dev,
916 dma_cap_set(DMA_SLAVE, mask); 914 dma_to_memory ? "rx" : "tx");
917 dma_chan = dma_request_channel(mask, NULL, NULL); 915 if (IS_ERR(dma_chan)) {
918 if (!dma_chan) { 916 ret = PTR_ERR(dma_chan);
919 dev_err(tup->uport.dev, 917 dev_err(tup->uport.dev,
920 "Dma channel is not available, will try later\n"); 918 "DMA channel alloc failed: %d\n", ret);
921 return -EPROBE_DEFER; 919 return ret;
922 } 920 }
923 921
924 if (dma_to_memory) { 922 if (dma_to_memory) {
@@ -938,7 +936,6 @@ static int tegra_uart_dma_channel_allocate(struct tegra_uart_port *tup,
938 dma_buf = tup->uport.state->xmit.buf; 936 dma_buf = tup->uport.state->xmit.buf;
939 } 937 }
940 938
941 dma_sconfig.slave_id = tup->dma_req_sel;
942 if (dma_to_memory) { 939 if (dma_to_memory) {
943 dma_sconfig.src_addr = tup->uport.mapbase; 940 dma_sconfig.src_addr = tup->uport.mapbase;
944 dma_sconfig.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE; 941 dma_sconfig.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
@@ -1222,17 +1219,8 @@ static int tegra_uart_parse_dt(struct platform_device *pdev,
1222 struct tegra_uart_port *tup) 1219 struct tegra_uart_port *tup)
1223{ 1220{
1224 struct device_node *np = pdev->dev.of_node; 1221 struct device_node *np = pdev->dev.of_node;
1225 u32 of_dma[2];
1226 int port; 1222 int port;
1227 1223
1228 if (of_property_read_u32_array(np, "nvidia,dma-request-selector",
1229 of_dma, 2) >= 0) {
1230 tup->dma_req_sel = of_dma[1];
1231 } else {
1232 dev_err(&pdev->dev, "missing dma requestor in device tree\n");
1233 return -EINVAL;
1234 }
1235
1236 port = of_alias_get_id(np, "serial"); 1224 port = of_alias_get_id(np, "serial");
1237 if (port < 0) { 1225 if (port < 0) {
1238 dev_err(&pdev->dev, "failed to get alias id, errno %d\n", port); 1226 dev_err(&pdev->dev, "failed to get alias id, errno %d\n", port);
@@ -1320,6 +1308,12 @@ static int tegra_uart_probe(struct platform_device *pdev)
1320 return PTR_ERR(tup->uart_clk); 1308 return PTR_ERR(tup->uart_clk);
1321 } 1309 }
1322 1310
1311 tup->rst = devm_reset_control_get(&pdev->dev, "serial");
1312 if (IS_ERR(tup->rst)) {
1313 dev_err(&pdev->dev, "Couldn't get the reset\n");
1314 return PTR_ERR(tup->rst);
1315 }
1316
1323 u->iotype = UPIO_MEM32; 1317 u->iotype = UPIO_MEM32;
1324 u->irq = platform_get_irq(pdev, 0); 1318 u->irq = platform_get_irq(pdev, 0);
1325 u->regshift = 2; 1319 u->regshift = 2;
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 7d8103cd3e2e..e4bf0e435af6 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -23,35 +23,34 @@
23 23
24#undef DEBUG 24#undef DEBUG
25 25
26#include <linux/module.h> 26#include <linux/clk.h>
27#include <linux/console.h>
28#include <linux/ctype.h>
29#include <linux/cpufreq.h>
30#include <linux/delay.h>
31#include <linux/dmaengine.h>
32#include <linux/dma-mapping.h>
33#include <linux/err.h>
27#include <linux/errno.h> 34#include <linux/errno.h>
28#include <linux/sh_dma.h> 35#include <linux/init.h>
29#include <linux/timer.h>
30#include <linux/interrupt.h> 36#include <linux/interrupt.h>
31#include <linux/tty.h>
32#include <linux/tty_flip.h>
33#include <linux/serial.h>
34#include <linux/major.h>
35#include <linux/string.h>
36#include <linux/sysrq.h>
37#include <linux/ioport.h> 37#include <linux/ioport.h>
38#include <linux/major.h>
39#include <linux/module.h>
38#include <linux/mm.h> 40#include <linux/mm.h>
39#include <linux/init.h>
40#include <linux/delay.h>
41#include <linux/console.h>
42#include <linux/platform_device.h>
43#include <linux/serial_sci.h>
44#include <linux/notifier.h> 41#include <linux/notifier.h>
42#include <linux/platform_device.h>
45#include <linux/pm_runtime.h> 43#include <linux/pm_runtime.h>
46#include <linux/cpufreq.h>
47#include <linux/clk.h>
48#include <linux/ctype.h>
49#include <linux/err.h>
50#include <linux/dmaengine.h>
51#include <linux/dma-mapping.h>
52#include <linux/scatterlist.h> 44#include <linux/scatterlist.h>
45#include <linux/serial.h>
46#include <linux/serial_sci.h>
47#include <linux/sh_dma.h>
53#include <linux/slab.h> 48#include <linux/slab.h>
54#include <linux/gpio.h> 49#include <linux/string.h>
50#include <linux/sysrq.h>
51#include <linux/timer.h>
52#include <linux/tty.h>
53#include <linux/tty_flip.h>
55 54
56#ifdef CONFIG_SUPERH 55#ifdef CONFIG_SUPERH
57#include <asm/sh_bios.h> 56#include <asm/sh_bios.h>
@@ -64,6 +63,10 @@ struct sci_port {
64 63
65 /* Platform configuration */ 64 /* Platform configuration */
66 struct plat_sci_port *cfg; 65 struct plat_sci_port *cfg;
66 int overrun_bit;
67 unsigned int error_mask;
68 unsigned int sampling_rate;
69
67 70
68 /* Break timer */ 71 /* Break timer */
69 struct timer_list break_timer; 72 struct timer_list break_timer;
@@ -74,8 +77,8 @@ struct sci_port {
74 /* Function clock */ 77 /* Function clock */
75 struct clk *fclk; 78 struct clk *fclk;
76 79
80 int irqs[SCIx_NR_IRQS];
77 char *irqstr[SCIx_NR_IRQS]; 81 char *irqstr[SCIx_NR_IRQS];
78 char *gpiostr[SCIx_NR_FNS];
79 82
80 struct dma_chan *chan_tx; 83 struct dma_chan *chan_tx;
81 struct dma_chan *chan_rx; 84 struct dma_chan *chan_rx;
@@ -421,9 +424,9 @@ static void sci_port_enable(struct sci_port *sci_port)
421 424
422 pm_runtime_get_sync(sci_port->port.dev); 425 pm_runtime_get_sync(sci_port->port.dev);
423 426
424 clk_enable(sci_port->iclk); 427 clk_prepare_enable(sci_port->iclk);
425 sci_port->port.uartclk = clk_get_rate(sci_port->iclk); 428 sci_port->port.uartclk = clk_get_rate(sci_port->iclk);
426 clk_enable(sci_port->fclk); 429 clk_prepare_enable(sci_port->fclk);
427} 430}
428 431
429static void sci_port_disable(struct sci_port *sci_port) 432static void sci_port_disable(struct sci_port *sci_port)
@@ -431,8 +434,16 @@ static void sci_port_disable(struct sci_port *sci_port)
431 if (!sci_port->port.dev) 434 if (!sci_port->port.dev)
432 return; 435 return;
433 436
434 clk_disable(sci_port->fclk); 437 /* Cancel the break timer to ensure that the timer handler will not try
435 clk_disable(sci_port->iclk); 438 * to access the hardware with clocks and power disabled. Reset the
439 * break flag to make the break debouncing state machine ready for the
440 * next break.
441 */
442 del_timer_sync(&sci_port->break_timer);
443 sci_port->break_flag = 0;
444
445 clk_disable_unprepare(sci_port->fclk);
446 clk_disable_unprepare(sci_port->iclk);
436 447
437 pm_runtime_put_sync(sci_port->port.dev); 448 pm_runtime_put_sync(sci_port->port.dev);
438} 449}
@@ -557,7 +568,7 @@ static inline int sci_rxd_in(struct uart_port *port)
557 return 1; 568 return 1;
558 569
559 /* Cast for ARM damage */ 570 /* Cast for ARM damage */
560 return !!__raw_readb((void __iomem *)s->cfg->port_reg); 571 return !!__raw_readb((void __iomem *)(uintptr_t)s->cfg->port_reg);
561} 572}
562 573
563/* ********************************************************************** * 574/* ********************************************************************** *
@@ -733,8 +744,6 @@ static void sci_break_timer(unsigned long data)
733{ 744{
734 struct sci_port *port = (struct sci_port *)data; 745 struct sci_port *port = (struct sci_port *)data;
735 746
736 sci_port_enable(port);
737
738 if (sci_rxd_in(&port->port) == 0) { 747 if (sci_rxd_in(&port->port) == 0) {
739 port->break_flag = 1; 748 port->break_flag = 1;
740 sci_schedule_break_timer(port); 749 sci_schedule_break_timer(port);
@@ -744,8 +753,6 @@ static void sci_break_timer(unsigned long data)
744 sci_schedule_break_timer(port); 753 sci_schedule_break_timer(port);
745 } else 754 } else
746 port->break_flag = 0; 755 port->break_flag = 0;
747
748 sci_port_disable(port);
749} 756}
750 757
751static int sci_handle_errors(struct uart_port *port) 758static int sci_handle_errors(struct uart_port *port)
@@ -755,19 +762,15 @@ static int sci_handle_errors(struct uart_port *port)
755 struct tty_port *tport = &port->state->port; 762 struct tty_port *tport = &port->state->port;
756 struct sci_port *s = to_sci_port(port); 763 struct sci_port *s = to_sci_port(port);
757 764
758 /* 765 /* Handle overruns */
759 * Handle overruns, if supported. 766 if (status & (1 << s->overrun_bit)) {
760 */ 767 port->icount.overrun++;
761 if (s->cfg->overrun_bit != SCIx_NOT_SUPPORTED) {
762 if (status & (1 << s->cfg->overrun_bit)) {
763 port->icount.overrun++;
764 768
765 /* overrun error */ 769 /* overrun error */
766 if (tty_insert_flip_char(tport, 0, TTY_OVERRUN)) 770 if (tty_insert_flip_char(tport, 0, TTY_OVERRUN))
767 copied++; 771 copied++;
768 772
769 dev_notice(port->dev, "overrun error"); 773 dev_notice(port->dev, "overrun error");
770 }
771 } 774 }
772 775
773 if (status & SCxSR_FER(port)) { 776 if (status & SCxSR_FER(port)) {
@@ -829,7 +832,7 @@ static int sci_handle_fifo_overrun(struct uart_port *port)
829 if (!reg->size) 832 if (!reg->size)
830 return 0; 833 return 0;
831 834
832 if ((serial_port_in(port, SCLSR) & (1 << s->cfg->overrun_bit))) { 835 if ((serial_port_in(port, SCLSR) & (1 << s->overrun_bit))) {
833 serial_port_out(port, SCLSR, 0); 836 serial_port_out(port, SCLSR, 0);
834 837
835 port->icount.overrun++; 838 port->icount.overrun++;
@@ -1075,19 +1078,19 @@ static int sci_request_irq(struct sci_port *port)
1075 1078
1076 for (i = j = 0; i < SCIx_NR_IRQS; i++, j++) { 1079 for (i = j = 0; i < SCIx_NR_IRQS; i++, j++) {
1077 struct sci_irq_desc *desc; 1080 struct sci_irq_desc *desc;
1078 unsigned int irq; 1081 int irq;
1079 1082
1080 if (SCIx_IRQ_IS_MUXED(port)) { 1083 if (SCIx_IRQ_IS_MUXED(port)) {
1081 i = SCIx_MUX_IRQ; 1084 i = SCIx_MUX_IRQ;
1082 irq = up->irq; 1085 irq = up->irq;
1083 } else { 1086 } else {
1084 irq = port->cfg->irqs[i]; 1087 irq = port->irqs[i];
1085 1088
1086 /* 1089 /*
1087 * Certain port types won't support all of the 1090 * Certain port types won't support all of the
1088 * available interrupt sources. 1091 * available interrupt sources.
1089 */ 1092 */
1090 if (unlikely(!irq)) 1093 if (unlikely(irq < 0))
1091 continue; 1094 continue;
1092 } 1095 }
1093 1096
@@ -1112,7 +1115,7 @@ static int sci_request_irq(struct sci_port *port)
1112 1115
1113out_noirq: 1116out_noirq:
1114 while (--i >= 0) 1117 while (--i >= 0)
1115 free_irq(port->cfg->irqs[i], port); 1118 free_irq(port->irqs[i], port);
1116 1119
1117out_nomem: 1120out_nomem:
1118 while (--j >= 0) 1121 while (--j >= 0)
@@ -1130,16 +1133,16 @@ static void sci_free_irq(struct sci_port *port)
1130 * IRQ first. 1133 * IRQ first.
1131 */ 1134 */
1132 for (i = 0; i < SCIx_NR_IRQS; i++) { 1135 for (i = 0; i < SCIx_NR_IRQS; i++) {
1133 unsigned int irq = port->cfg->irqs[i]; 1136 int irq = port->irqs[i];
1134 1137
1135 /* 1138 /*
1136 * Certain port types won't support all of the available 1139 * Certain port types won't support all of the available
1137 * interrupt sources. 1140 * interrupt sources.
1138 */ 1141 */
1139 if (unlikely(!irq)) 1142 if (unlikely(irq < 0))
1140 continue; 1143 continue;
1141 1144
1142 free_irq(port->cfg->irqs[i], port); 1145 free_irq(port->irqs[i], port);
1143 kfree(port->irqstr[i]); 1146 kfree(port->irqstr[i]);
1144 1147
1145 if (SCIx_IRQ_IS_MUXED(port)) { 1148 if (SCIx_IRQ_IS_MUXED(port)) {
@@ -1149,67 +1152,6 @@ static void sci_free_irq(struct sci_port *port)
1149 } 1152 }
1150} 1153}
1151 1154
1152static const char *sci_gpio_names[SCIx_NR_FNS] = {
1153 "sck", "rxd", "txd", "cts", "rts",
1154};
1155
1156static const char *sci_gpio_str(unsigned int index)
1157{
1158 return sci_gpio_names[index];
1159}
1160
1161static void sci_init_gpios(struct sci_port *port)
1162{
1163 struct uart_port *up = &port->port;
1164 int i;
1165
1166 if (!port->cfg)
1167 return;
1168
1169 for (i = 0; i < SCIx_NR_FNS; i++) {
1170 const char *desc;
1171 int ret;
1172
1173 if (!port->cfg->gpios[i])
1174 continue;
1175
1176 desc = sci_gpio_str(i);
1177
1178 port->gpiostr[i] = kasprintf(GFP_KERNEL, "%s:%s",
1179 dev_name(up->dev), desc);
1180
1181 /*
1182 * If we've failed the allocation, we can still continue
1183 * on with a NULL string.
1184 */
1185 if (!port->gpiostr[i])
1186 dev_notice(up->dev, "%s string allocation failure\n",
1187 desc);
1188
1189 ret = gpio_request(port->cfg->gpios[i], port->gpiostr[i]);
1190 if (unlikely(ret != 0)) {
1191 dev_notice(up->dev, "failed %s gpio request\n", desc);
1192
1193 /*
1194 * If we can't get the GPIO for whatever reason,
1195 * no point in keeping the verbose string around.
1196 */
1197 kfree(port->gpiostr[i]);
1198 }
1199 }
1200}
1201
1202static void sci_free_gpios(struct sci_port *port)
1203{
1204 int i;
1205
1206 for (i = 0; i < SCIx_NR_FNS; i++)
1207 if (port->cfg->gpios[i]) {
1208 gpio_free(port->cfg->gpios[i]);
1209 kfree(port->gpiostr[i]);
1210 }
1211}
1212
1213static unsigned int sci_tx_empty(struct uart_port *port) 1155static unsigned int sci_tx_empty(struct uart_port *port)
1214{ 1156{
1215 unsigned short status = serial_port_in(port, SCxSR); 1157 unsigned short status = serial_port_in(port, SCxSR);
@@ -1309,7 +1251,7 @@ static int sci_dma_rx_push(struct sci_port *s, size_t count)
1309 } 1251 }
1310 1252
1311 if (room < count) 1253 if (room < count)
1312 dev_warn(port->dev, "Rx overrun: dropping %u bytes\n", 1254 dev_warn(port->dev, "Rx overrun: dropping %zu bytes\n",
1313 count - room); 1255 count - room);
1314 if (!room) 1256 if (!room)
1315 return room; 1257 return room;
@@ -1442,7 +1384,7 @@ static void work_fn_rx(struct work_struct *work)
1442 int count; 1384 int count;
1443 1385
1444 chan->device->device_control(chan, DMA_TERMINATE_ALL, 0); 1386 chan->device->device_control(chan, DMA_TERMINATE_ALL, 0);
1445 dev_dbg(port->dev, "Read %u bytes with cookie %d\n", 1387 dev_dbg(port->dev, "Read %zu bytes with cookie %d\n",
1446 sh_desc->partial, sh_desc->cookie); 1388 sh_desc->partial, sh_desc->cookie);
1447 1389
1448 spin_lock_irqsave(&port->lock, flags); 1390 spin_lock_irqsave(&port->lock, flags);
@@ -1655,7 +1597,7 @@ static void rx_timer_fn(unsigned long arg)
1655 1597
1656 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) { 1598 if (port->type == PORT_SCIFA || port->type == PORT_SCIFB) {
1657 scr &= ~0x4000; 1599 scr &= ~0x4000;
1658 enable_irq(s->cfg->irqs[1]); 1600 enable_irq(s->irqs[SCIx_RXI_IRQ]);
1659 } 1601 }
1660 serial_port_out(port, SCSCR, scr | SCSCR_RIE); 1602 serial_port_out(port, SCSCR, scr | SCSCR_RIE);
1661 dev_dbg(port->dev, "DMA Rx timed out\n"); 1603 dev_dbg(port->dev, "DMA Rx timed out\n");
@@ -1691,16 +1633,17 @@ static void sci_request_dma(struct uart_port *port)
1691 s->chan_tx = chan; 1633 s->chan_tx = chan;
1692 sg_init_table(&s->sg_tx, 1); 1634 sg_init_table(&s->sg_tx, 1);
1693 /* UART circular tx buffer is an aligned page. */ 1635 /* UART circular tx buffer is an aligned page. */
1694 BUG_ON((int)port->state->xmit.buf & ~PAGE_MASK); 1636 BUG_ON((uintptr_t)port->state->xmit.buf & ~PAGE_MASK);
1695 sg_set_page(&s->sg_tx, virt_to_page(port->state->xmit.buf), 1637 sg_set_page(&s->sg_tx, virt_to_page(port->state->xmit.buf),
1696 UART_XMIT_SIZE, (int)port->state->xmit.buf & ~PAGE_MASK); 1638 UART_XMIT_SIZE,
1639 (uintptr_t)port->state->xmit.buf & ~PAGE_MASK);
1697 nent = dma_map_sg(port->dev, &s->sg_tx, 1, DMA_TO_DEVICE); 1640 nent = dma_map_sg(port->dev, &s->sg_tx, 1, DMA_TO_DEVICE);
1698 if (!nent) 1641 if (!nent)
1699 sci_tx_dma_release(s, false); 1642 sci_tx_dma_release(s, false);
1700 else 1643 else
1701 dev_dbg(port->dev, "%s: mapped %d@%p to %x\n", __func__, 1644 dev_dbg(port->dev, "%s: mapped %d@%p to %pad\n", __func__,
1702 sg_dma_len(&s->sg_tx), 1645 sg_dma_len(&s->sg_tx), port->state->xmit.buf,
1703 port->state->xmit.buf, sg_dma_address(&s->sg_tx)); 1646 &sg_dma_address(&s->sg_tx));
1704 1647
1705 s->sg_len_tx = nent; 1648 s->sg_len_tx = nent;
1706 1649
@@ -1740,7 +1683,7 @@ static void sci_request_dma(struct uart_port *port)
1740 1683
1741 sg_init_table(sg, 1); 1684 sg_init_table(sg, 1);
1742 sg_set_page(sg, virt_to_page(buf[i]), s->buf_len_rx, 1685 sg_set_page(sg, virt_to_page(buf[i]), s->buf_len_rx,
1743 (int)buf[i] & ~PAGE_MASK); 1686 (uintptr_t)buf[i] & ~PAGE_MASK);
1744 sg_dma_address(sg) = dma[i]; 1687 sg_dma_address(sg) = dma[i];
1745 } 1688 }
1746 1689
@@ -1808,20 +1751,21 @@ static void sci_shutdown(struct uart_port *port)
1808 sci_free_irq(s); 1751 sci_free_irq(s);
1809} 1752}
1810 1753
1811static unsigned int sci_scbrr_calc(unsigned int algo_id, unsigned int bps, 1754static unsigned int sci_scbrr_calc(struct sci_port *s, unsigned int bps,
1812 unsigned long freq) 1755 unsigned long freq)
1813{ 1756{
1814 switch (algo_id) { 1757 if (s->sampling_rate)
1758 return DIV_ROUND_CLOSEST(freq, s->sampling_rate * bps) - 1;
1759
1760 switch (s->cfg->scbrr_algo_id) {
1815 case SCBRR_ALGO_1: 1761 case SCBRR_ALGO_1:
1816 return ((freq + 16 * bps) / (16 * bps) - 1); 1762 return freq / (16 * bps);
1817 case SCBRR_ALGO_2: 1763 case SCBRR_ALGO_2:
1818 return ((freq + 16 * bps) / (32 * bps) - 1); 1764 return DIV_ROUND_CLOSEST(freq, 32 * bps) - 1;
1819 case SCBRR_ALGO_3: 1765 case SCBRR_ALGO_3:
1820 return (((freq * 2) + 16 * bps) / (16 * bps) - 1); 1766 return freq / (8 * bps);
1821 case SCBRR_ALGO_4: 1767 case SCBRR_ALGO_4:
1822 return (((freq * 2) + 16 * bps) / (32 * bps) - 1); 1768 return DIV_ROUND_CLOSEST(freq, 16 * bps) - 1;
1823 case SCBRR_ALGO_5:
1824 return (((freq * 1000 / 32) / bps) - 1);
1825 } 1769 }
1826 1770
1827 /* Warn, but use a safe default */ 1771 /* Warn, but use a safe default */
@@ -1903,12 +1847,11 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
1903 1847
1904 baud = uart_get_baud_rate(port, termios, old, 0, max_baud); 1848 baud = uart_get_baud_rate(port, termios, old, 0, max_baud);
1905 if (likely(baud && port->uartclk)) { 1849 if (likely(baud && port->uartclk)) {
1906 if (s->cfg->scbrr_algo_id == SCBRR_ALGO_6) { 1850 if (s->cfg->type == PORT_HSCIF) {
1907 sci_baud_calc_hscif(baud, port->uartclk, &t, &srr, 1851 sci_baud_calc_hscif(baud, port->uartclk, &t, &srr,
1908 &cks); 1852 &cks);
1909 } else { 1853 } else {
1910 t = sci_scbrr_calc(s->cfg->scbrr_algo_id, baud, 1854 t = sci_scbrr_calc(s, baud, port->uartclk);
1911 port->uartclk);
1912 for (cks = 0; t >= 256 && cks <= 3; cks++) 1855 for (cks = 0; t >= 256 && cks <= 3; cks++)
1913 t >>= 2; 1856 t >>= 2;
1914 } 1857 }
@@ -2115,10 +2058,6 @@ static void sci_config_port(struct uart_port *port, int flags)
2115 2058
2116static int sci_verify_port(struct uart_port *port, struct serial_struct *ser) 2059static int sci_verify_port(struct uart_port *port, struct serial_struct *ser)
2117{ 2060{
2118 struct sci_port *s = to_sci_port(port);
2119
2120 if (ser->irq != s->cfg->irqs[SCIx_TXI_IRQ] || ser->irq > nr_irqs)
2121 return -EINVAL;
2122 if (ser->baud_base < 2400) 2061 if (ser->baud_base < 2400)
2123 /* No paper tape reader for Mitch.. */ 2062 /* No paper tape reader for Mitch.. */
2124 return -EINVAL; 2063 return -EINVAL;
@@ -2151,11 +2090,13 @@ static struct uart_ops sci_uart_ops = {
2151}; 2090};
2152 2091
2153static int sci_init_single(struct platform_device *dev, 2092static int sci_init_single(struct platform_device *dev,
2154 struct sci_port *sci_port, 2093 struct sci_port *sci_port, unsigned int index,
2155 unsigned int index, 2094 struct plat_sci_port *p, bool early)
2156 struct plat_sci_port *p)
2157{ 2095{
2158 struct uart_port *port = &sci_port->port; 2096 struct uart_port *port = &sci_port->port;
2097 const struct resource *res;
2098 unsigned int sampling_rate;
2099 unsigned int i;
2159 int ret; 2100 int ret;
2160 2101
2161 sci_port->cfg = p; 2102 sci_port->cfg = p;
@@ -2164,31 +2105,90 @@ static int sci_init_single(struct platform_device *dev,
2164 port->iotype = UPIO_MEM; 2105 port->iotype = UPIO_MEM;
2165 port->line = index; 2106 port->line = index;
2166 2107
2108 if (dev->num_resources) {
2109 /* Device has resources, use them. */
2110 res = platform_get_resource(dev, IORESOURCE_MEM, 0);
2111 if (res == NULL)
2112 return -ENOMEM;
2113
2114 port->mapbase = res->start;
2115
2116 for (i = 0; i < ARRAY_SIZE(sci_port->irqs); ++i)
2117 sci_port->irqs[i] = platform_get_irq(dev, i);
2118
2119 /* The SCI generates several interrupts. They can be muxed
2120 * together or connected to different interrupt lines. In the
2121 * muxed case only one interrupt resource is specified. In the
2122 * non-muxed case three or four interrupt resources are
2123 * specified, as the BRI interrupt is optional.
2124 */
2125 if (sci_port->irqs[0] < 0)
2126 return -ENXIO;
2127
2128 if (sci_port->irqs[1] < 0) {
2129 sci_port->irqs[1] = sci_port->irqs[0];
2130 sci_port->irqs[2] = sci_port->irqs[0];
2131 sci_port->irqs[3] = sci_port->irqs[0];
2132 }
2133 } else {
2134 /* No resources, use old-style platform data. */
2135 port->mapbase = p->mapbase;
2136 for (i = 0; i < ARRAY_SIZE(sci_port->irqs); ++i)
2137 sci_port->irqs[i] = p->irqs[i] ? p->irqs[i] : -ENXIO;
2138 }
2139
2140 if (p->regtype == SCIx_PROBE_REGTYPE) {
2141 ret = sci_probe_regmap(p);
2142 if (unlikely(ret))
2143 return ret;
2144 }
2145
2167 switch (p->type) { 2146 switch (p->type) {
2168 case PORT_SCIFB: 2147 case PORT_SCIFB:
2169 port->fifosize = 256; 2148 port->fifosize = 256;
2149 sci_port->overrun_bit = 9;
2150 sampling_rate = 16;
2170 break; 2151 break;
2171 case PORT_HSCIF: 2152 case PORT_HSCIF:
2172 port->fifosize = 128; 2153 port->fifosize = 128;
2154 sampling_rate = 0;
2155 sci_port->overrun_bit = 0;
2173 break; 2156 break;
2174 case PORT_SCIFA: 2157 case PORT_SCIFA:
2175 port->fifosize = 64; 2158 port->fifosize = 64;
2159 sci_port->overrun_bit = 9;
2160 sampling_rate = 16;
2176 break; 2161 break;
2177 case PORT_SCIF: 2162 case PORT_SCIF:
2178 port->fifosize = 16; 2163 port->fifosize = 16;
2164 if (p->regtype == SCIx_SH7705_SCIF_REGTYPE) {
2165 sci_port->overrun_bit = 9;
2166 sampling_rate = 16;
2167 } else {
2168 sci_port->overrun_bit = 0;
2169 sampling_rate = 32;
2170 }
2179 break; 2171 break;
2180 default: 2172 default:
2181 port->fifosize = 1; 2173 port->fifosize = 1;
2174 sci_port->overrun_bit = 5;
2175 sampling_rate = 32;
2182 break; 2176 break;
2183 } 2177 }
2184 2178
2185 if (p->regtype == SCIx_PROBE_REGTYPE) { 2179 /* Set the sampling rate if the baud rate calculation algorithm isn't
2186 ret = sci_probe_regmap(p); 2180 * specified.
2187 if (unlikely(ret)) 2181 */
2188 return ret; 2182 if (p->scbrr_algo_id == SCBRR_ALGO_NONE) {
2183 /* SCIFA on sh7723 and sh7724 need a custom sampling rate that
2184 * doesn't match the SoC datasheet, this should be investigated.
2185 * Let platform data override the sampling rate for now.
2186 */
2187 sci_port->sampling_rate = p->sampling_rate ? p->sampling_rate
2188 : sampling_rate;
2189 } 2189 }
2190 2190
2191 if (dev) { 2191 if (!early) {
2192 sci_port->iclk = clk_get(&dev->dev, "sci_ick"); 2192 sci_port->iclk = clk_get(&dev->dev, "sci_ick");
2193 if (IS_ERR(sci_port->iclk)) { 2193 if (IS_ERR(sci_port->iclk)) {
2194 sci_port->iclk = clk_get(&dev->dev, "peripheral_clk"); 2194 sci_port->iclk = clk_get(&dev->dev, "peripheral_clk");
@@ -2208,8 +2208,6 @@ static int sci_init_single(struct platform_device *dev,
2208 2208
2209 port->dev = &dev->dev; 2209 port->dev = &dev->dev;
2210 2210
2211 sci_init_gpios(sci_port);
2212
2213 pm_runtime_enable(&dev->dev); 2211 pm_runtime_enable(&dev->dev);
2214 } 2212 }
2215 2213
@@ -2220,32 +2218,22 @@ static int sci_init_single(struct platform_device *dev,
2220 /* 2218 /*
2221 * Establish some sensible defaults for the error detection. 2219 * Establish some sensible defaults for the error detection.
2222 */ 2220 */
2223 if (!p->error_mask) 2221 sci_port->error_mask = (p->type == PORT_SCI) ?
2224 p->error_mask = (p->type == PORT_SCI) ?
2225 SCI_DEFAULT_ERROR_MASK : SCIF_DEFAULT_ERROR_MASK; 2222 SCI_DEFAULT_ERROR_MASK : SCIF_DEFAULT_ERROR_MASK;
2226 2223
2227 /* 2224 /*
2228 * Establish sensible defaults for the overrun detection, unless 2225 * Establish sensible defaults for the overrun detection, unless
2229 * the part has explicitly disabled support for it. 2226 * the part has explicitly disabled support for it.
2230 */ 2227 */
2231 if (p->overrun_bit != SCIx_NOT_SUPPORTED) {
2232 if (p->type == PORT_SCI)
2233 p->overrun_bit = 5;
2234 else if (p->scbrr_algo_id == SCBRR_ALGO_4)
2235 p->overrun_bit = 9;
2236 else
2237 p->overrun_bit = 0;
2238 2228
2239 /* 2229 /*
2240 * Make the error mask inclusive of overrun detection, if 2230 * Make the error mask inclusive of overrun detection, if
2241 * supported. 2231 * supported.
2242 */ 2232 */
2243 p->error_mask |= (1 << p->overrun_bit); 2233 sci_port->error_mask |= 1 << sci_port->overrun_bit;
2244 }
2245 2234
2246 port->mapbase = p->mapbase;
2247 port->type = p->type; 2235 port->type = p->type;
2248 port->flags = p->flags; 2236 port->flags = UPF_FIXED_PORT | p->flags;
2249 port->regshift = p->regshift; 2237 port->regshift = p->regshift;
2250 2238
2251 /* 2239 /*
@@ -2255,7 +2243,7 @@ static int sci_init_single(struct platform_device *dev,
2255 * 2243 *
2256 * For the muxed case there's nothing more to do. 2244 * For the muxed case there's nothing more to do.
2257 */ 2245 */
2258 port->irq = p->irqs[SCIx_RXI_IRQ]; 2246 port->irq = sci_port->irqs[SCIx_RXI_IRQ];
2259 port->irqflags = 0; 2247 port->irqflags = 0;
2260 2248
2261 port->serial_in = sci_serial_in; 2249 port->serial_in = sci_serial_in;
@@ -2270,8 +2258,6 @@ static int sci_init_single(struct platform_device *dev,
2270 2258
2271static void sci_cleanup_single(struct sci_port *port) 2259static void sci_cleanup_single(struct sci_port *port)
2272{ 2260{
2273 sci_free_gpios(port);
2274
2275 clk_put(port->iclk); 2261 clk_put(port->iclk);
2276 clk_put(port->fclk); 2262 clk_put(port->fclk);
2277 2263
@@ -2387,7 +2373,7 @@ static int sci_probe_earlyprintk(struct platform_device *pdev)
2387 2373
2388 early_serial_console.index = pdev->id; 2374 early_serial_console.index = pdev->id;
2389 2375
2390 sci_init_single(NULL, &sci_ports[pdev->id], pdev->id, cfg); 2376 sci_init_single(pdev, &sci_ports[pdev->id], pdev->id, cfg, true);
2391 2377
2392 serial_console_setup(&early_serial_console, early_serial_buf); 2378 serial_console_setup(&early_serial_console, early_serial_buf);
2393 2379
@@ -2454,7 +2440,7 @@ static int sci_probe_single(struct platform_device *dev,
2454 return -EINVAL; 2440 return -EINVAL;
2455 } 2441 }
2456 2442
2457 ret = sci_init_single(dev, sciport, index, p); 2443 ret = sci_init_single(dev, sciport, index, p, false);
2458 if (ret) 2444 if (ret)
2459 return ret; 2445 return ret;
2460 2446
diff --git a/drivers/tty/serial/sh-sci.h b/drivers/tty/serial/sh-sci.h
index 5aca7364634c..d5db81a0a430 100644
--- a/drivers/tty/serial/sh-sci.h
+++ b/drivers/tty/serial/sh-sci.h
@@ -9,7 +9,7 @@
9#define SCxSR_PER(port) (((port)->type == PORT_SCI) ? SCI_PER : SCIF_PER) 9#define SCxSR_PER(port) (((port)->type == PORT_SCI) ? SCI_PER : SCIF_PER)
10#define SCxSR_BRK(port) (((port)->type == PORT_SCI) ? 0x00 : SCIF_BRK) 10#define SCxSR_BRK(port) (((port)->type == PORT_SCI) ? 0x00 : SCIF_BRK)
11 11
12#define SCxSR_ERRORS(port) (to_sci_port(port)->cfg->error_mask) 12#define SCxSR_ERRORS(port) (to_sci_port(port)->error_mask)
13 13
14#if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ 14#if defined(CONFIG_CPU_SUBTYPE_SH7705) || \
15 defined(CONFIG_CPU_SUBTYPE_SH7720) || \ 15 defined(CONFIG_CPU_SUBTYPE_SH7720) || \
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 3e7560f004f8..e8404319ca68 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1515,6 +1515,8 @@ static int acm_reset_resume(struct usb_interface *intf)
1515 1515
1516static const struct usb_device_id acm_ids[] = { 1516static const struct usb_device_id acm_ids[] = {
1517 /* quirky and broken devices */ 1517 /* quirky and broken devices */
1518 { USB_DEVICE(0x17ef, 0x7000), /* Lenovo USB modem */
1519 .driver_info = NO_UNION_NORMAL, },/* has no union descriptor */
1518 { USB_DEVICE(0x0870, 0x0001), /* Metricom GS Modem */ 1520 { USB_DEVICE(0x0870, 0x0001), /* Metricom GS Modem */
1519 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ 1521 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1520 }, 1522 },
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index a7c04e24ca48..bd9dc3504b51 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -4832,8 +4832,9 @@ static void hub_events(void)
4832 hub->ports[i - 1]->child; 4832 hub->ports[i - 1]->child;
4833 4833
4834 dev_dbg(hub_dev, "warm reset port %d\n", i); 4834 dev_dbg(hub_dev, "warm reset port %d\n", i);
4835 if (!udev || !(portstatus & 4835 if (!udev ||
4836 USB_PORT_STAT_CONNECTION)) { 4836 !(portstatus & USB_PORT_STAT_CONNECTION) ||
4837 udev->state == USB_STATE_NOTATTACHED) {
4837 status = hub_port_reset(hub, i, 4838 status = hub_port_reset(hub, i,
4838 NULL, HUB_BH_RESET_TIME, 4839 NULL, HUB_BH_RESET_TIME,
4839 true); 4840 true);
diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c
index 95f7649c71a7..21a352079bc2 100644
--- a/drivers/usb/dwc3/ep0.c
+++ b/drivers/usb/dwc3/ep0.c
@@ -459,6 +459,8 @@ static int dwc3_ep0_handle_feature(struct dwc3 *dwc,
459 dep = dwc3_wIndex_to_dep(dwc, wIndex); 459 dep = dwc3_wIndex_to_dep(dwc, wIndex);
460 if (!dep) 460 if (!dep)
461 return -EINVAL; 461 return -EINVAL;
462 if (set == 0 && (dep->flags & DWC3_EP_WEDGE))
463 break;
462 ret = __dwc3_gadget_ep_set_halt(dep, set); 464 ret = __dwc3_gadget_ep_set_halt(dep, set);
463 if (ret) 465 if (ret)
464 return -EINVAL; 466 return -EINVAL;
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 5452c0fce360..02e44fcaf205 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1200,9 +1200,6 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value)
1200 else 1200 else
1201 dep->flags |= DWC3_EP_STALL; 1201 dep->flags |= DWC3_EP_STALL;
1202 } else { 1202 } else {
1203 if (dep->flags & DWC3_EP_WEDGE)
1204 return 0;
1205
1206 ret = dwc3_send_gadget_ep_cmd(dwc, dep->number, 1203 ret = dwc3_send_gadget_ep_cmd(dwc, dep->number,
1207 DWC3_DEPCMD_CLEARSTALL, &params); 1204 DWC3_DEPCMD_CLEARSTALL, &params);
1208 if (ret) 1205 if (ret)
@@ -1210,7 +1207,7 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value)
1210 value ? "set" : "clear", 1207 value ? "set" : "clear",
1211 dep->name); 1208 dep->name);
1212 else 1209 else
1213 dep->flags &= ~DWC3_EP_STALL; 1210 dep->flags &= ~(DWC3_EP_STALL | DWC3_EP_WEDGE);
1214 } 1211 }
1215 1212
1216 return ret; 1213 return ret;
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index a91e6422f930..f66d96ad1f51 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -682,6 +682,7 @@ config USB_CONFIGFS_PHONET
682config USB_CONFIGFS_MASS_STORAGE 682config USB_CONFIGFS_MASS_STORAGE
683 boolean "Mass storage" 683 boolean "Mass storage"
684 depends on USB_CONFIGFS 684 depends on USB_CONFIGFS
685 depends on BLOCK
685 select USB_F_MASS_STORAGE 686 select USB_F_MASS_STORAGE
686 help 687 help
687 The Mass Storage Gadget acts as a USB Mass Storage disk drive. 688 The Mass Storage Gadget acts as a USB Mass Storage disk drive.
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 3e7ae707f691..2018ba1a2172 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -593,6 +593,7 @@ static void reset_config(struct usb_composite_dev *cdev)
593 bitmap_zero(f->endpoints, 32); 593 bitmap_zero(f->endpoints, 32);
594 } 594 }
595 cdev->config = NULL; 595 cdev->config = NULL;
596 cdev->delayed_status = 0;
596} 597}
597 598
598static int set_config(struct usb_composite_dev *cdev, 599static int set_config(struct usb_composite_dev *cdev,
diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index 774e8b89cdb5..241fc873ffa4 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -1304,7 +1304,7 @@ static struct ffs_data *ffs_data_new(void)
1304{ 1304{
1305 struct ffs_data *ffs = kzalloc(sizeof *ffs, GFP_KERNEL); 1305 struct ffs_data *ffs = kzalloc(sizeof *ffs, GFP_KERNEL);
1306 if (unlikely(!ffs)) 1306 if (unlikely(!ffs))
1307 return 0; 1307 return NULL;
1308 1308
1309 ENTER(); 1309 ENTER();
1310 1310
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index a03ba2c83589..b96393908860 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -523,7 +523,7 @@ static int fsg_setup(struct usb_function *f,
523 */ 523 */
524 DBG(fsg, "bulk reset request\n"); 524 DBG(fsg, "bulk reset request\n");
525 raise_exception(fsg->common, FSG_STATE_RESET); 525 raise_exception(fsg->common, FSG_STATE_RESET);
526 return DELAYED_STATUS; 526 return USB_GADGET_DELAYED_STATUS;
527 527
528 case US_BULK_GET_MAX_LUN: 528 case US_BULK_GET_MAX_LUN:
529 if (ctrl->bRequestType != 529 if (ctrl->bRequestType !=
@@ -602,13 +602,14 @@ static bool start_out_transfer(struct fsg_common *common, struct fsg_buffhd *bh)
602 return true; 602 return true;
603} 603}
604 604
605static int sleep_thread(struct fsg_common *common) 605static int sleep_thread(struct fsg_common *common, bool can_freeze)
606{ 606{
607 int rc = 0; 607 int rc = 0;
608 608
609 /* Wait until a signal arrives or we are woken up */ 609 /* Wait until a signal arrives or we are woken up */
610 for (;;) { 610 for (;;) {
611 try_to_freeze(); 611 if (can_freeze)
612 try_to_freeze();
612 set_current_state(TASK_INTERRUPTIBLE); 613 set_current_state(TASK_INTERRUPTIBLE);
613 if (signal_pending(current)) { 614 if (signal_pending(current)) {
614 rc = -EINTR; 615 rc = -EINTR;
@@ -682,7 +683,7 @@ static int do_read(struct fsg_common *common)
682 /* Wait for the next buffer to become available */ 683 /* Wait for the next buffer to become available */
683 bh = common->next_buffhd_to_fill; 684 bh = common->next_buffhd_to_fill;
684 while (bh->state != BUF_STATE_EMPTY) { 685 while (bh->state != BUF_STATE_EMPTY) {
685 rc = sleep_thread(common); 686 rc = sleep_thread(common, false);
686 if (rc) 687 if (rc)
687 return rc; 688 return rc;
688 } 689 }
@@ -937,7 +938,7 @@ static int do_write(struct fsg_common *common)
937 } 938 }
938 939
939 /* Wait for something to happen */ 940 /* Wait for something to happen */
940 rc = sleep_thread(common); 941 rc = sleep_thread(common, false);
941 if (rc) 942 if (rc)
942 return rc; 943 return rc;
943 } 944 }
@@ -1504,7 +1505,7 @@ static int throw_away_data(struct fsg_common *common)
1504 } 1505 }
1505 1506
1506 /* Otherwise wait for something to happen */ 1507 /* Otherwise wait for something to happen */
1507 rc = sleep_thread(common); 1508 rc = sleep_thread(common, true);
1508 if (rc) 1509 if (rc)
1509 return rc; 1510 return rc;
1510 } 1511 }
@@ -1625,7 +1626,7 @@ static int send_status(struct fsg_common *common)
1625 /* Wait for the next buffer to become available */ 1626 /* Wait for the next buffer to become available */
1626 bh = common->next_buffhd_to_fill; 1627 bh = common->next_buffhd_to_fill;
1627 while (bh->state != BUF_STATE_EMPTY) { 1628 while (bh->state != BUF_STATE_EMPTY) {
1628 rc = sleep_thread(common); 1629 rc = sleep_thread(common, true);
1629 if (rc) 1630 if (rc)
1630 return rc; 1631 return rc;
1631 } 1632 }
@@ -1828,7 +1829,7 @@ static int do_scsi_command(struct fsg_common *common)
1828 bh = common->next_buffhd_to_fill; 1829 bh = common->next_buffhd_to_fill;
1829 common->next_buffhd_to_drain = bh; 1830 common->next_buffhd_to_drain = bh;
1830 while (bh->state != BUF_STATE_EMPTY) { 1831 while (bh->state != BUF_STATE_EMPTY) {
1831 rc = sleep_thread(common); 1832 rc = sleep_thread(common, true);
1832 if (rc) 1833 if (rc)
1833 return rc; 1834 return rc;
1834 } 1835 }
@@ -2174,7 +2175,7 @@ static int get_next_command(struct fsg_common *common)
2174 /* Wait for the next buffer to become available */ 2175 /* Wait for the next buffer to become available */
2175 bh = common->next_buffhd_to_fill; 2176 bh = common->next_buffhd_to_fill;
2176 while (bh->state != BUF_STATE_EMPTY) { 2177 while (bh->state != BUF_STATE_EMPTY) {
2177 rc = sleep_thread(common); 2178 rc = sleep_thread(common, true);
2178 if (rc) 2179 if (rc)
2179 return rc; 2180 return rc;
2180 } 2181 }
@@ -2193,7 +2194,7 @@ static int get_next_command(struct fsg_common *common)
2193 2194
2194 /* Wait for the CBW to arrive */ 2195 /* Wait for the CBW to arrive */
2195 while (bh->state != BUF_STATE_FULL) { 2196 while (bh->state != BUF_STATE_FULL) {
2196 rc = sleep_thread(common); 2197 rc = sleep_thread(common, true);
2197 if (rc) 2198 if (rc)
2198 return rc; 2199 return rc;
2199 } 2200 }
@@ -2379,7 +2380,7 @@ static void handle_exception(struct fsg_common *common)
2379 } 2380 }
2380 if (num_active == 0) 2381 if (num_active == 0)
2381 break; 2382 break;
2382 if (sleep_thread(common)) 2383 if (sleep_thread(common, true))
2383 return; 2384 return;
2384 } 2385 }
2385 2386
@@ -2516,7 +2517,7 @@ static int fsg_main_thread(void *common_)
2516 } 2517 }
2517 2518
2518 if (!common->running) { 2519 if (!common->running) {
2519 sleep_thread(common); 2520 sleep_thread(common, true);
2520 continue; 2521 continue;
2521 } 2522 }
2522 2523
@@ -3111,7 +3112,7 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f)
3111 fsg->common->can_stall); 3112 fsg->common->can_stall);
3112 if (ret) 3113 if (ret)
3113 return ret; 3114 return ret;
3114 fsg_common_set_inquiry_string(fsg->common, 0, 0); 3115 fsg_common_set_inquiry_string(fsg->common, NULL, NULL);
3115 ret = fsg_common_run_thread(fsg->common); 3116 ret = fsg_common_run_thread(fsg->common);
3116 if (ret) 3117 if (ret)
3117 return ret; 3118 return ret;
diff --git a/drivers/usb/gadget/pxa25x_udc.c b/drivers/usb/gadget/pxa25x_udc.c
index 0ac6064aa3b8..409a3c45a36a 100644
--- a/drivers/usb/gadget/pxa25x_udc.c
+++ b/drivers/usb/gadget/pxa25x_udc.c
@@ -54,6 +54,7 @@
54 */ 54 */
55#ifdef CONFIG_ARCH_PXA 55#ifdef CONFIG_ARCH_PXA
56#include <mach/pxa25x-udc.h> 56#include <mach/pxa25x-udc.h>
57#include <mach/hardware.h>
57#endif 58#endif
58 59
59#ifdef CONFIG_ARCH_LUBBOCK 60#ifdef CONFIG_ARCH_LUBBOCK
diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c
index 9875d9c0823f..e20bc109fdd7 100644
--- a/drivers/usb/gadget/s3c-hsotg.c
+++ b/drivers/usb/gadget/s3c-hsotg.c
@@ -1180,6 +1180,7 @@ static int s3c_hsotg_process_req_feature(struct s3c_hsotg *hsotg,
1180} 1180}
1181 1181
1182static void s3c_hsotg_enqueue_setup(struct s3c_hsotg *hsotg); 1182static void s3c_hsotg_enqueue_setup(struct s3c_hsotg *hsotg);
1183static void s3c_hsotg_disconnect(struct s3c_hsotg *hsotg);
1183 1184
1184/** 1185/**
1185 * s3c_hsotg_process_control - process a control request 1186 * s3c_hsotg_process_control - process a control request
@@ -1221,6 +1222,7 @@ static void s3c_hsotg_process_control(struct s3c_hsotg *hsotg,
1221 if ((ctrl->bRequestType & USB_TYPE_MASK) == USB_TYPE_STANDARD) { 1222 if ((ctrl->bRequestType & USB_TYPE_MASK) == USB_TYPE_STANDARD) {
1222 switch (ctrl->bRequest) { 1223 switch (ctrl->bRequest) {
1223 case USB_REQ_SET_ADDRESS: 1224 case USB_REQ_SET_ADDRESS:
1225 s3c_hsotg_disconnect(hsotg);
1224 dcfg = readl(hsotg->regs + DCFG); 1226 dcfg = readl(hsotg->regs + DCFG);
1225 dcfg &= ~DCFG_DevAddr_MASK; 1227 dcfg &= ~DCFG_DevAddr_MASK;
1226 dcfg |= ctrl->wValue << DCFG_DevAddr_SHIFT; 1228 dcfg |= ctrl->wValue << DCFG_DevAddr_SHIFT;
@@ -1245,7 +1247,9 @@ static void s3c_hsotg_process_control(struct s3c_hsotg *hsotg,
1245 /* as a fallback, try delivering it to the driver to deal with */ 1247 /* as a fallback, try delivering it to the driver to deal with */
1246 1248
1247 if (ret == 0 && hsotg->driver) { 1249 if (ret == 0 && hsotg->driver) {
1250 spin_unlock(&hsotg->lock);
1248 ret = hsotg->driver->setup(&hsotg->gadget, ctrl); 1251 ret = hsotg->driver->setup(&hsotg->gadget, ctrl);
1252 spin_lock(&hsotg->lock);
1249 if (ret < 0) 1253 if (ret < 0)
1250 dev_dbg(hsotg->dev, "driver->setup() ret %d\n", ret); 1254 dev_dbg(hsotg->dev, "driver->setup() ret %d\n", ret);
1251 } 1255 }
@@ -1308,10 +1312,12 @@ static void s3c_hsotg_complete_setup(struct usb_ep *ep,
1308 return; 1312 return;
1309 } 1313 }
1310 1314
1315 spin_lock(&hsotg->lock);
1311 if (req->actual == 0) 1316 if (req->actual == 0)
1312 s3c_hsotg_enqueue_setup(hsotg); 1317 s3c_hsotg_enqueue_setup(hsotg);
1313 else 1318 else
1314 s3c_hsotg_process_control(hsotg, req->buf); 1319 s3c_hsotg_process_control(hsotg, req->buf);
1320 spin_unlock(&hsotg->lock);
1315} 1321}
1316 1322
1317/** 1323/**
@@ -2533,7 +2539,6 @@ irq_retry:
2533 writel(GINTSTS_USBSusp, hsotg->regs + GINTSTS); 2539 writel(GINTSTS_USBSusp, hsotg->regs + GINTSTS);
2534 2540
2535 call_gadget(hsotg, suspend); 2541 call_gadget(hsotg, suspend);
2536 s3c_hsotg_disconnect(hsotg);
2537 } 2542 }
2538 2543
2539 if (gintsts & GINTSTS_WkUpInt) { 2544 if (gintsts & GINTSTS_WkUpInt) {
diff --git a/drivers/usb/gadget/storage_common.h b/drivers/usb/gadget/storage_common.h
index c74c2fdbd56e..70c891469f57 100644
--- a/drivers/usb/gadget/storage_common.h
+++ b/drivers/usb/gadget/storage_common.h
@@ -119,10 +119,6 @@ static inline bool fsg_lun_is_open(struct fsg_lun *curlun)
119 return curlun->filp != NULL; 119 return curlun->filp != NULL;
120} 120}
121 121
122/* Big enough to hold our biggest descriptor */
123#define EP0_BUFSIZE 256
124#define DELAYED_STATUS (EP0_BUFSIZE + 999) /* An impossibly large value */
125
126/* Default size of buffer length. */ 122/* Default size of buffer length. */
127#define FSG_BUFLEN ((u32)16384) 123#define FSG_BUFLEN ((u32)16384)
128 124
diff --git a/drivers/usb/gadget/tcm_usb_gadget.c b/drivers/usb/gadget/tcm_usb_gadget.c
index 6c3d7950d2a9..0f8aad78b54f 100644
--- a/drivers/usb/gadget/tcm_usb_gadget.c
+++ b/drivers/usb/gadget/tcm_usb_gadget.c
@@ -370,7 +370,7 @@ err:
370 return -ENOMEM; 370 return -ENOMEM;
371} 371}
372 372
373void bot_cleanup_old_alt(struct f_uas *fu) 373static void bot_cleanup_old_alt(struct f_uas *fu)
374{ 374{
375 if (!(fu->flags & USBG_ENABLED)) 375 if (!(fu->flags & USBG_ENABLED))
376 return; 376 return;
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c
index 0dd07ae1555d..f49b0b61ecc8 100644
--- a/drivers/usb/gadget/zero.c
+++ b/drivers/usb/gadget/zero.c
@@ -91,17 +91,17 @@ static struct usb_zero_options gzero_options = {
91 * functional coverage for the "USBCV" test harness from USB-IF. 91 * functional coverage for the "USBCV" test harness from USB-IF.
92 * It's always set if OTG mode is enabled. 92 * It's always set if OTG mode is enabled.
93 */ 93 */
94unsigned autoresume = DEFAULT_AUTORESUME; 94static unsigned autoresume = DEFAULT_AUTORESUME;
95module_param(autoresume, uint, S_IRUGO); 95module_param(autoresume, uint, S_IRUGO);
96MODULE_PARM_DESC(autoresume, "zero, or seconds before remote wakeup"); 96MODULE_PARM_DESC(autoresume, "zero, or seconds before remote wakeup");
97 97
98/* Maximum Autoresume time */ 98/* Maximum Autoresume time */
99unsigned max_autoresume; 99static unsigned max_autoresume;
100module_param(max_autoresume, uint, S_IRUGO); 100module_param(max_autoresume, uint, S_IRUGO);
101MODULE_PARM_DESC(max_autoresume, "maximum seconds before remote wakeup"); 101MODULE_PARM_DESC(max_autoresume, "maximum seconds before remote wakeup");
102 102
103/* Interval between two remote wakeups */ 103/* Interval between two remote wakeups */
104unsigned autoresume_interval_ms; 104static unsigned autoresume_interval_ms;
105module_param(autoresume_interval_ms, uint, S_IRUGO); 105module_param(autoresume_interval_ms, uint, S_IRUGO);
106MODULE_PARM_DESC(autoresume_interval_ms, 106MODULE_PARM_DESC(autoresume_interval_ms,
107 "milliseconds to increase successive wakeup delays"); 107 "milliseconds to increase successive wakeup delays");
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index b9fd0396011e..6f7e23dd1417 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -17,7 +17,6 @@
17 */ 17 */
18 18
19#include <linux/clk.h> 19#include <linux/clk.h>
20#include <linux/clk/tegra.h>
21#include <linux/dma-mapping.h> 20#include <linux/dma-mapping.h>
22#include <linux/err.h> 21#include <linux/err.h>
23#include <linux/gpio.h> 22#include <linux/gpio.h>
@@ -29,6 +28,7 @@
29#include <linux/of_gpio.h> 28#include <linux/of_gpio.h>
30#include <linux/platform_device.h> 29#include <linux/platform_device.h>
31#include <linux/pm_runtime.h> 30#include <linux/pm_runtime.h>
31#include <linux/reset.h>
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/usb/ehci_def.h> 33#include <linux/usb/ehci_def.h>
34#include <linux/usb/tegra_usb_phy.h> 34#include <linux/usb/tegra_usb_phy.h>
@@ -62,6 +62,7 @@ static int (*orig_hub_control)(struct usb_hcd *hcd,
62struct tegra_ehci_hcd { 62struct tegra_ehci_hcd {
63 struct tegra_usb_phy *phy; 63 struct tegra_usb_phy *phy;
64 struct clk *clk; 64 struct clk *clk;
65 struct reset_control *rst;
65 int port_resuming; 66 int port_resuming;
66 bool needs_double_reset; 67 bool needs_double_reset;
67 enum tegra_usb_phy_port_speed port_speed; 68 enum tegra_usb_phy_port_speed port_speed;
@@ -385,13 +386,20 @@ static int tegra_ehci_probe(struct platform_device *pdev)
385 goto cleanup_hcd_create; 386 goto cleanup_hcd_create;
386 } 387 }
387 388
389 tegra->rst = devm_reset_control_get(&pdev->dev, "usb");
390 if (IS_ERR(tegra->rst)) {
391 dev_err(&pdev->dev, "Can't get ehci reset\n");
392 err = PTR_ERR(tegra->rst);
393 goto cleanup_hcd_create;
394 }
395
388 err = clk_prepare_enable(tegra->clk); 396 err = clk_prepare_enable(tegra->clk);
389 if (err) 397 if (err)
390 goto cleanup_hcd_create; 398 goto cleanup_hcd_create;
391 399
392 tegra_periph_reset_assert(tegra->clk); 400 reset_control_assert(tegra->rst);
393 udelay(1); 401 udelay(1);
394 tegra_periph_reset_deassert(tegra->clk); 402 reset_control_deassert(tegra->rst);
395 403
396 u_phy = devm_usb_get_phy_by_phandle(&pdev->dev, "nvidia,phy", 0); 404 u_phy = devm_usb_get_phy_by_phandle(&pdev->dev, "nvidia,phy", 0);
397 if (IS_ERR(u_phy)) { 405 if (IS_ERR(u_phy)) {
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c
index e89ac4d4b87e..9b7435f0dcd6 100644
--- a/drivers/usb/host/ohci-pxa27x.c
+++ b/drivers/usb/host/ohci-pxa27x.c
@@ -21,6 +21,7 @@
21 21
22#include <linux/clk.h> 22#include <linux/clk.h>
23#include <linux/device.h> 23#include <linux/device.h>
24#include <linux/dma-mapping.h>
24#include <linux/io.h> 25#include <linux/io.h>
25#include <linux/kernel.h> 26#include <linux/kernel.h>
26#include <linux/module.h> 27#include <linux/module.h>
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 1e2f3f495843..53c2e296467f 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -2973,8 +2973,58 @@ static int prepare_ring(struct xhci_hcd *xhci, struct xhci_ring *ep_ring,
2973 } 2973 }
2974 2974
2975 while (1) { 2975 while (1) {
2976 if (room_on_ring(xhci, ep_ring, num_trbs)) 2976 if (room_on_ring(xhci, ep_ring, num_trbs)) {
2977 break; 2977 union xhci_trb *trb = ep_ring->enqueue;
2978 unsigned int usable = ep_ring->enq_seg->trbs +
2979 TRBS_PER_SEGMENT - 1 - trb;
2980 u32 nop_cmd;
2981
2982 /*
2983 * Section 4.11.7.1 TD Fragments states that a link
2984 * TRB must only occur at the boundary between
2985 * data bursts (eg 512 bytes for 480M).
2986 * While it is possible to split a large fragment
2987 * we don't know the size yet.
2988 * Simplest solution is to fill the trb before the
2989 * LINK with nop commands.
2990 */
2991 if (num_trbs == 1 || num_trbs <= usable || usable == 0)
2992 break;
2993
2994 if (ep_ring->type != TYPE_BULK)
2995 /*
2996 * While isoc transfers might have a buffer that
2997 * crosses a 64k boundary it is unlikely.
2998 * Since we can't add NOPs without generating
2999 * gaps in the traffic just hope it never
3000 * happens at the end of the ring.
3001 * This could be fixed by writing a LINK TRB
3002 * instead of the first NOP - however the
3003 * TRB_TYPE_LINK_LE32() calls would all need
3004 * changing to check the ring length.
3005 */
3006 break;
3007
3008 if (num_trbs >= TRBS_PER_SEGMENT) {
3009 xhci_err(xhci, "Too many fragments %d, max %d\n",
3010 num_trbs, TRBS_PER_SEGMENT - 1);
3011 return -ENOMEM;
3012 }
3013
3014 nop_cmd = cpu_to_le32(TRB_TYPE(TRB_TR_NOOP) |
3015 ep_ring->cycle_state);
3016 ep_ring->num_trbs_free -= usable;
3017 do {
3018 trb->generic.field[0] = 0;
3019 trb->generic.field[1] = 0;
3020 trb->generic.field[2] = 0;
3021 trb->generic.field[3] = nop_cmd;
3022 trb++;
3023 } while (--usable);
3024 ep_ring->enqueue = trb;
3025 if (room_on_ring(xhci, ep_ring, num_trbs))
3026 break;
3027 }
2978 3028
2979 if (ep_ring == xhci->cmd_ring) { 3029 if (ep_ring == xhci->cmd_ring) {
2980 xhci_err(xhci, "Do not support expand command ring\n"); 3030 xhci_err(xhci, "Do not support expand command ring\n");
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 0a43329569d1..4d4499b80449 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -1809,7 +1809,6 @@ static void musb_free(struct musb *musb)
1809 disable_irq_wake(musb->nIrq); 1809 disable_irq_wake(musb->nIrq);
1810 free_irq(musb->nIrq, musb); 1810 free_irq(musb->nIrq, musb);
1811 } 1811 }
1812 cancel_work_sync(&musb->irq_work);
1813 1812
1814 musb_host_free(musb); 1813 musb_host_free(musb);
1815} 1814}
@@ -1896,6 +1895,9 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
1896 musb_platform_disable(musb); 1895 musb_platform_disable(musb);
1897 musb_generic_disable(musb); 1896 musb_generic_disable(musb);
1898 1897
1898 /* Init IRQ workqueue before request_irq */
1899 INIT_WORK(&musb->irq_work, musb_irq_work);
1900
1899 /* setup musb parts of the core (especially endpoints) */ 1901 /* setup musb parts of the core (especially endpoints) */
1900 status = musb_core_init(plat->config->multipoint 1902 status = musb_core_init(plat->config->multipoint
1901 ? MUSB_CONTROLLER_MHDRC 1903 ? MUSB_CONTROLLER_MHDRC
@@ -1905,9 +1907,6 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)
1905 1907
1906 setup_timer(&musb->otg_timer, musb_otg_timer_func, (unsigned long) musb); 1908 setup_timer(&musb->otg_timer, musb_otg_timer_func, (unsigned long) musb);
1907 1909
1908 /* Init IRQ workqueue before request_irq */
1909 INIT_WORK(&musb->irq_work, musb_irq_work);
1910
1911 /* attach to the IRQ */ 1910 /* attach to the IRQ */
1912 if (request_irq(nIrq, musb->isr, 0, dev_name(dev), musb)) { 1911 if (request_irq(nIrq, musb->isr, 0, dev_name(dev), musb)) {
1913 dev_err(dev, "request_irq %d failed!\n", nIrq); 1912 dev_err(dev, "request_irq %d failed!\n", nIrq);
@@ -1981,6 +1980,7 @@ fail4:
1981 musb_host_cleanup(musb); 1980 musb_host_cleanup(musb);
1982 1981
1983fail3: 1982fail3:
1983 cancel_work_sync(&musb->irq_work);
1984 if (musb->dma_controller) 1984 if (musb->dma_controller)
1985 dma_controller_destroy(musb->dma_controller); 1985 dma_controller_destroy(musb->dma_controller);
1986fail2_5: 1986fail2_5:
@@ -2043,6 +2043,7 @@ static int musb_remove(struct platform_device *pdev)
2043 if (musb->dma_controller) 2043 if (musb->dma_controller)
2044 dma_controller_destroy(musb->dma_controller); 2044 dma_controller_destroy(musb->dma_controller);
2045 2045
2046 cancel_work_sync(&musb->irq_work);
2046 musb_free(musb); 2047 musb_free(musb);
2047 device_init_wakeup(dev, 0); 2048 device_init_wakeup(dev, 0);
2048 return 0; 2049 return 0;
diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index ff9d6de2b746..a12bd30401e0 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -38,6 +38,7 @@ struct cppi41_dma_channel {
38 u32 prog_len; 38 u32 prog_len;
39 u32 transferred; 39 u32 transferred;
40 u32 packet_sz; 40 u32 packet_sz;
41 struct list_head tx_check;
41}; 42};
42 43
43#define MUSB_DMA_NUM_CHANNELS 15 44#define MUSB_DMA_NUM_CHANNELS 15
@@ -47,6 +48,8 @@ struct cppi41_dma_controller {
47 struct cppi41_dma_channel rx_channel[MUSB_DMA_NUM_CHANNELS]; 48 struct cppi41_dma_channel rx_channel[MUSB_DMA_NUM_CHANNELS];
48 struct cppi41_dma_channel tx_channel[MUSB_DMA_NUM_CHANNELS]; 49 struct cppi41_dma_channel tx_channel[MUSB_DMA_NUM_CHANNELS];
49 struct musb *musb; 50 struct musb *musb;
51 struct hrtimer early_tx;
52 struct list_head early_tx_list;
50 u32 rx_mode; 53 u32 rx_mode;
51 u32 tx_mode; 54 u32 tx_mode;
52 u32 auto_req; 55 u32 auto_req;
@@ -96,31 +99,27 @@ static void update_rx_toggle(struct cppi41_dma_channel *cppi41_channel)
96 cppi41_channel->usb_toggle = toggle; 99 cppi41_channel->usb_toggle = toggle;
97} 100}
98 101
99static void cppi41_dma_callback(void *private_data) 102static bool musb_is_tx_fifo_empty(struct musb_hw_ep *hw_ep)
100{ 103{
101 struct dma_channel *channel = private_data; 104 u8 epnum = hw_ep->epnum;
102 struct cppi41_dma_channel *cppi41_channel = channel->private_data; 105 struct musb *musb = hw_ep->musb;
103 struct musb_hw_ep *hw_ep = cppi41_channel->hw_ep; 106 void __iomem *epio = musb->endpoints[epnum].regs;
104 struct musb *musb = hw_ep->musb; 107 u16 csr;
105 unsigned long flags;
106 struct dma_tx_state txstate;
107 u32 transferred;
108 108
109 spin_lock_irqsave(&musb->lock, flags); 109 csr = musb_readw(epio, MUSB_TXCSR);
110 if (csr & MUSB_TXCSR_TXPKTRDY)
111 return false;
112 return true;
113}
110 114
111 dmaengine_tx_status(cppi41_channel->dc, cppi41_channel->cookie, 115static void cppi41_dma_callback(void *private_data);
112 &txstate);
113 transferred = cppi41_channel->prog_len - txstate.residue;
114 cppi41_channel->transferred += transferred;
115 116
116 dev_dbg(musb->controller, "DMA transfer done on hw_ep=%d bytes=%d/%d\n", 117static void cppi41_trans_done(struct cppi41_dma_channel *cppi41_channel)
117 hw_ep->epnum, cppi41_channel->transferred, 118{
118 cppi41_channel->total_len); 119 struct musb_hw_ep *hw_ep = cppi41_channel->hw_ep;
120 struct musb *musb = hw_ep->musb;
119 121
120 update_rx_toggle(cppi41_channel); 122 if (!cppi41_channel->prog_len) {
121
122 if (cppi41_channel->transferred == cppi41_channel->total_len ||
123 transferred < cppi41_channel->packet_sz) {
124 123
125 /* done, complete */ 124 /* done, complete */
126 cppi41_channel->channel.actual_len = 125 cppi41_channel->channel.actual_len =
@@ -150,13 +149,11 @@ static void cppi41_dma_callback(void *private_data)
150 remain_bytes, 149 remain_bytes,
151 direction, 150 direction,
152 DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 151 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
153 if (WARN_ON(!dma_desc)) { 152 if (WARN_ON(!dma_desc))
154 spin_unlock_irqrestore(&musb->lock, flags);
155 return; 153 return;
156 }
157 154
158 dma_desc->callback = cppi41_dma_callback; 155 dma_desc->callback = cppi41_dma_callback;
159 dma_desc->callback_param = channel; 156 dma_desc->callback_param = &cppi41_channel->channel;
160 cppi41_channel->cookie = dma_desc->tx_submit(dma_desc); 157 cppi41_channel->cookie = dma_desc->tx_submit(dma_desc);
161 dma_async_issue_pending(dc); 158 dma_async_issue_pending(dc);
162 159
@@ -166,6 +163,117 @@ static void cppi41_dma_callback(void *private_data)
166 musb_writew(epio, MUSB_RXCSR, csr); 163 musb_writew(epio, MUSB_RXCSR, csr);
167 } 164 }
168 } 165 }
166}
167
168static enum hrtimer_restart cppi41_recheck_tx_req(struct hrtimer *timer)
169{
170 struct cppi41_dma_controller *controller;
171 struct cppi41_dma_channel *cppi41_channel, *n;
172 struct musb *musb;
173 unsigned long flags;
174 enum hrtimer_restart ret = HRTIMER_NORESTART;
175
176 controller = container_of(timer, struct cppi41_dma_controller,
177 early_tx);
178 musb = controller->musb;
179
180 spin_lock_irqsave(&musb->lock, flags);
181 list_for_each_entry_safe(cppi41_channel, n, &controller->early_tx_list,
182 tx_check) {
183 bool empty;
184 struct musb_hw_ep *hw_ep = cppi41_channel->hw_ep;
185
186 empty = musb_is_tx_fifo_empty(hw_ep);
187 if (empty) {
188 list_del_init(&cppi41_channel->tx_check);
189 cppi41_trans_done(cppi41_channel);
190 }
191 }
192
193 if (!list_empty(&controller->early_tx_list)) {
194 ret = HRTIMER_RESTART;
195 hrtimer_forward_now(&controller->early_tx,
196 ktime_set(0, 150 * NSEC_PER_USEC));
197 }
198
199 spin_unlock_irqrestore(&musb->lock, flags);
200 return ret;
201}
202
203static void cppi41_dma_callback(void *private_data)
204{
205 struct dma_channel *channel = private_data;
206 struct cppi41_dma_channel *cppi41_channel = channel->private_data;
207 struct musb_hw_ep *hw_ep = cppi41_channel->hw_ep;
208 struct musb *musb = hw_ep->musb;
209 unsigned long flags;
210 struct dma_tx_state txstate;
211 u32 transferred;
212 bool empty;
213
214 spin_lock_irqsave(&musb->lock, flags);
215
216 dmaengine_tx_status(cppi41_channel->dc, cppi41_channel->cookie,
217 &txstate);
218 transferred = cppi41_channel->prog_len - txstate.residue;
219 cppi41_channel->transferred += transferred;
220
221 dev_dbg(musb->controller, "DMA transfer done on hw_ep=%d bytes=%d/%d\n",
222 hw_ep->epnum, cppi41_channel->transferred,
223 cppi41_channel->total_len);
224
225 update_rx_toggle(cppi41_channel);
226
227 if (cppi41_channel->transferred == cppi41_channel->total_len ||
228 transferred < cppi41_channel->packet_sz)
229 cppi41_channel->prog_len = 0;
230
231 empty = musb_is_tx_fifo_empty(hw_ep);
232 if (empty) {
233 cppi41_trans_done(cppi41_channel);
234 } else {
235 struct cppi41_dma_controller *controller;
236 /*
237 * On AM335x it has been observed that the TX interrupt fires
238 * too early that means the TXFIFO is not yet empty but the DMA
239 * engine says that it is done with the transfer. We don't
240 * receive a FIFO empty interrupt so the only thing we can do is
241 * to poll for the bit. On HS it usually takes 2us, on FS around
242 * 110us - 150us depending on the transfer size.
243 * We spin on HS (no longer than than 25us and setup a timer on
244 * FS to check for the bit and complete the transfer.
245 */
246 controller = cppi41_channel->controller;
247
248 if (musb->g.speed == USB_SPEED_HIGH) {
249 unsigned wait = 25;
250
251 do {
252 empty = musb_is_tx_fifo_empty(hw_ep);
253 if (empty)
254 break;
255 wait--;
256 if (!wait)
257 break;
258 udelay(1);
259 } while (1);
260
261 empty = musb_is_tx_fifo_empty(hw_ep);
262 if (empty) {
263 cppi41_trans_done(cppi41_channel);
264 goto out;
265 }
266 }
267 list_add_tail(&cppi41_channel->tx_check,
268 &controller->early_tx_list);
269 if (!hrtimer_active(&controller->early_tx)) {
270 hrtimer_start_range_ns(&controller->early_tx,
271 ktime_set(0, 140 * NSEC_PER_USEC),
272 40 * NSEC_PER_USEC,
273 HRTIMER_MODE_REL);
274 }
275 }
276out:
169 spin_unlock_irqrestore(&musb->lock, flags); 277 spin_unlock_irqrestore(&musb->lock, flags);
170} 278}
171 279
@@ -364,6 +472,8 @@ static int cppi41_is_compatible(struct dma_channel *channel, u16 maxpacket,
364 WARN_ON(1); 472 WARN_ON(1);
365 return 1; 473 return 1;
366 } 474 }
475 if (cppi41_channel->hw_ep->ep_in.type != USB_ENDPOINT_XFER_BULK)
476 return 0;
367 if (cppi41_channel->is_tx) 477 if (cppi41_channel->is_tx)
368 return 1; 478 return 1;
369 /* AM335x Advisory 1.0.13. No workaround for device RX mode */ 479 /* AM335x Advisory 1.0.13. No workaround for device RX mode */
@@ -388,6 +498,7 @@ static int cppi41_dma_channel_abort(struct dma_channel *channel)
388 if (cppi41_channel->channel.status == MUSB_DMA_STATUS_FREE) 498 if (cppi41_channel->channel.status == MUSB_DMA_STATUS_FREE)
389 return 0; 499 return 0;
390 500
501 list_del_init(&cppi41_channel->tx_check);
391 if (is_tx) { 502 if (is_tx) {
392 csr = musb_readw(epio, MUSB_TXCSR); 503 csr = musb_readw(epio, MUSB_TXCSR);
393 csr &= ~MUSB_TXCSR_DMAENAB; 504 csr &= ~MUSB_TXCSR_DMAENAB;
@@ -495,6 +606,7 @@ static int cppi41_dma_controller_start(struct cppi41_dma_controller *controller)
495 cppi41_channel->controller = controller; 606 cppi41_channel->controller = controller;
496 cppi41_channel->port_num = port; 607 cppi41_channel->port_num = port;
497 cppi41_channel->is_tx = is_tx; 608 cppi41_channel->is_tx = is_tx;
609 INIT_LIST_HEAD(&cppi41_channel->tx_check);
498 610
499 musb_dma = &cppi41_channel->channel; 611 musb_dma = &cppi41_channel->channel;
500 musb_dma->private_data = cppi41_channel; 612 musb_dma->private_data = cppi41_channel;
@@ -520,6 +632,7 @@ void dma_controller_destroy(struct dma_controller *c)
520 struct cppi41_dma_controller *controller = container_of(c, 632 struct cppi41_dma_controller *controller = container_of(c,
521 struct cppi41_dma_controller, controller); 633 struct cppi41_dma_controller, controller);
522 634
635 hrtimer_cancel(&controller->early_tx);
523 cppi41_dma_controller_stop(controller); 636 cppi41_dma_controller_stop(controller);
524 kfree(controller); 637 kfree(controller);
525} 638}
@@ -539,6 +652,9 @@ struct dma_controller *dma_controller_create(struct musb *musb,
539 if (!controller) 652 if (!controller)
540 goto kzalloc_fail; 653 goto kzalloc_fail;
541 654
655 hrtimer_init(&controller->early_tx, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
656 controller->early_tx.function = cppi41_recheck_tx_req;
657 INIT_LIST_HEAD(&controller->early_tx_list);
542 controller->musb = musb; 658 controller->musb = musb;
543 659
544 controller->controller.channel_alloc = cppi41_dma_channel_allocate; 660 controller->controller.channel_alloc = cppi41_dma_channel_allocate;
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index d2d3a173b315..32fb057c03f5 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -1796,7 +1796,11 @@ int musb_gadget_setup(struct musb *musb)
1796 1796
1797 /* this "gadget" abstracts/virtualizes the controller */ 1797 /* this "gadget" abstracts/virtualizes the controller */
1798 musb->g.name = musb_driver_name; 1798 musb->g.name = musb_driver_name;
1799#if IS_ENABLED(CONFIG_USB_MUSB_DUAL_ROLE)
1799 musb->g.is_otg = 1; 1800 musb->g.is_otg = 1;
1801#elif IS_ENABLED(CONFIG_USB_MUSB_GADGET)
1802 musb->g.is_otg = 0;
1803#endif
1800 1804
1801 musb_g_init_endpoints(musb); 1805 musb_g_init_endpoints(musb);
1802 1806
diff --git a/drivers/usb/phy/phy-am335x.c b/drivers/usb/phy/phy-am335x.c
index 6370e50649d7..0e3c60cb669a 100644
--- a/drivers/usb/phy/phy-am335x.c
+++ b/drivers/usb/phy/phy-am335x.c
@@ -52,8 +52,7 @@ static int am335x_phy_probe(struct platform_device *pdev)
52 return am_phy->id; 52 return am_phy->id;
53 } 53 }
54 54
55 ret = usb_phy_gen_create_phy(dev, &am_phy->usb_phy_gen, 55 ret = usb_phy_gen_create_phy(dev, &am_phy->usb_phy_gen, NULL);
56 USB_PHY_TYPE_USB2, 0, false);
57 if (ret) 56 if (ret)
58 return ret; 57 return ret;
59 58
@@ -66,8 +65,6 @@ static int am335x_phy_probe(struct platform_device *pdev)
66 platform_set_drvdata(pdev, am_phy); 65 platform_set_drvdata(pdev, am_phy);
67 66
68 return 0; 67 return 0;
69
70 return ret;
71} 68}
72 69
73static int am335x_phy_remove(struct platform_device *pdev) 70static int am335x_phy_remove(struct platform_device *pdev)
diff --git a/drivers/usb/phy/phy-generic.c b/drivers/usb/phy/phy-generic.c
index fce3a9e9bb5d..aa6d37b3378a 100644
--- a/drivers/usb/phy/phy-generic.c
+++ b/drivers/usb/phy/phy-generic.c
@@ -48,8 +48,9 @@ void usb_nop_xceiv_register(void)
48 if (pd) 48 if (pd)
49 return; 49 return;
50 pd = platform_device_register_simple("usb_phy_gen_xceiv", -1, NULL, 0); 50 pd = platform_device_register_simple("usb_phy_gen_xceiv", -1, NULL, 0);
51 if (!pd) { 51 if (IS_ERR(pd)) {
52 pr_err("Unable to register generic usb transceiver\n"); 52 pr_err("Unable to register generic usb transceiver\n");
53 pd = NULL;
53 return; 54 return;
54 } 55 }
55} 56}
@@ -150,10 +151,40 @@ static int nop_set_host(struct usb_otg *otg, struct usb_bus *host)
150} 151}
151 152
152int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_gen_xceiv *nop, 153int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_gen_xceiv *nop,
153 enum usb_phy_type type, u32 clk_rate, bool needs_vcc) 154 struct usb_phy_gen_xceiv_platform_data *pdata)
154{ 155{
156 enum usb_phy_type type = USB_PHY_TYPE_USB2;
155 int err; 157 int err;
156 158
159 u32 clk_rate = 0;
160 bool needs_vcc = false;
161
162 nop->reset_active_low = true; /* default behaviour */
163
164 if (dev->of_node) {
165 struct device_node *node = dev->of_node;
166 enum of_gpio_flags flags = 0;
167
168 if (of_property_read_u32(node, "clock-frequency", &clk_rate))
169 clk_rate = 0;
170
171 needs_vcc = of_property_read_bool(node, "vcc-supply");
172 nop->gpio_reset = of_get_named_gpio_flags(node, "reset-gpios",
173 0, &flags);
174 if (nop->gpio_reset == -EPROBE_DEFER)
175 return -EPROBE_DEFER;
176
177 nop->reset_active_low = flags & OF_GPIO_ACTIVE_LOW;
178
179 } else if (pdata) {
180 type = pdata->type;
181 clk_rate = pdata->clk_rate;
182 needs_vcc = pdata->needs_vcc;
183 nop->gpio_reset = pdata->gpio_reset;
184 } else {
185 nop->gpio_reset = -1;
186 }
187
157 nop->phy.otg = devm_kzalloc(dev, sizeof(*nop->phy.otg), 188 nop->phy.otg = devm_kzalloc(dev, sizeof(*nop->phy.otg),
158 GFP_KERNEL); 189 GFP_KERNEL);
159 if (!nop->phy.otg) 190 if (!nop->phy.otg)
@@ -218,43 +249,14 @@ EXPORT_SYMBOL_GPL(usb_phy_gen_create_phy);
218static int usb_phy_gen_xceiv_probe(struct platform_device *pdev) 249static int usb_phy_gen_xceiv_probe(struct platform_device *pdev)
219{ 250{
220 struct device *dev = &pdev->dev; 251 struct device *dev = &pdev->dev;
221 struct usb_phy_gen_xceiv_platform_data *pdata =
222 dev_get_platdata(&pdev->dev);
223 struct usb_phy_gen_xceiv *nop; 252 struct usb_phy_gen_xceiv *nop;
224 enum usb_phy_type type = USB_PHY_TYPE_USB2;
225 int err; 253 int err;
226 u32 clk_rate = 0;
227 bool needs_vcc = false;
228 254
229 nop = devm_kzalloc(dev, sizeof(*nop), GFP_KERNEL); 255 nop = devm_kzalloc(dev, sizeof(*nop), GFP_KERNEL);
230 if (!nop) 256 if (!nop)
231 return -ENOMEM; 257 return -ENOMEM;
232 258
233 nop->reset_active_low = true; /* default behaviour */ 259 err = usb_phy_gen_create_phy(dev, nop, dev_get_platdata(&pdev->dev));
234
235 if (dev->of_node) {
236 struct device_node *node = dev->of_node;
237 enum of_gpio_flags flags;
238
239 if (of_property_read_u32(node, "clock-frequency", &clk_rate))
240 clk_rate = 0;
241
242 needs_vcc = of_property_read_bool(node, "vcc-supply");
243 nop->gpio_reset = of_get_named_gpio_flags(node, "reset-gpios",
244 0, &flags);
245 if (nop->gpio_reset == -EPROBE_DEFER)
246 return -EPROBE_DEFER;
247
248 nop->reset_active_low = flags & OF_GPIO_ACTIVE_LOW;
249
250 } else if (pdata) {
251 type = pdata->type;
252 clk_rate = pdata->clk_rate;
253 needs_vcc = pdata->needs_vcc;
254 nop->gpio_reset = pdata->gpio_reset;
255 }
256
257 err = usb_phy_gen_create_phy(dev, nop, type, clk_rate, needs_vcc);
258 if (err) 260 if (err)
259 return err; 261 return err;
260 262
@@ -271,8 +273,6 @@ static int usb_phy_gen_xceiv_probe(struct platform_device *pdev)
271 platform_set_drvdata(pdev, nop); 273 platform_set_drvdata(pdev, nop);
272 274
273 return 0; 275 return 0;
274
275 return err;
276} 276}
277 277
278static int usb_phy_gen_xceiv_remove(struct platform_device *pdev) 278static int usb_phy_gen_xceiv_remove(struct platform_device *pdev)
diff --git a/drivers/usb/phy/phy-generic.h b/drivers/usb/phy/phy-generic.h
index d2a220d81734..38a81f307b82 100644
--- a/drivers/usb/phy/phy-generic.h
+++ b/drivers/usb/phy/phy-generic.h
@@ -1,6 +1,8 @@
1#ifndef _PHY_GENERIC_H_ 1#ifndef _PHY_GENERIC_H_
2#define _PHY_GENERIC_H_ 2#define _PHY_GENERIC_H_
3 3
4#include <linux/usb/usb_phy_gen_xceiv.h>
5
4struct usb_phy_gen_xceiv { 6struct usb_phy_gen_xceiv {
5 struct usb_phy phy; 7 struct usb_phy phy;
6 struct device *dev; 8 struct device *dev;
@@ -14,6 +16,6 @@ int usb_gen_phy_init(struct usb_phy *phy);
14void usb_gen_phy_shutdown(struct usb_phy *phy); 16void usb_gen_phy_shutdown(struct usb_phy *phy);
15 17
16int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_gen_xceiv *nop, 18int usb_phy_gen_create_phy(struct device *dev, struct usb_phy_gen_xceiv *nop,
17 enum usb_phy_type type, u32 clk_rate, bool needs_vcc); 19 struct usb_phy_gen_xceiv_platform_data *pdata);
18 20
19#endif 21#endif
diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index fdd33b44dbd3..545844b7e796 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -164,7 +164,7 @@ static int mxs_phy_probe(struct platform_device *pdev)
164 164
165 mxs_phy->clk = clk; 165 mxs_phy->clk = clk;
166 166
167 platform_set_drvdata(pdev, &mxs_phy->phy); 167 platform_set_drvdata(pdev, mxs_phy);
168 168
169 ret = usb_add_phy_dev(&mxs_phy->phy); 169 ret = usb_add_phy_dev(&mxs_phy->phy);
170 if (ret) 170 if (ret)
diff --git a/drivers/usb/phy/phy-rcar-gen2-usb.c b/drivers/usb/phy/phy-rcar-gen2-usb.c
index a99a6953f11c..db3ab34cddb4 100644
--- a/drivers/usb/phy/phy-rcar-gen2-usb.c
+++ b/drivers/usb/phy/phy-rcar-gen2-usb.c
@@ -107,10 +107,10 @@ static void __rcar_gen2_usb_phy_init(struct rcar_gen2_usb_phy_priv *priv)
107 clk_prepare_enable(priv->clk); 107 clk_prepare_enable(priv->clk);
108 108
109 /* Set USB channels in the USBHS UGCTRL2 register */ 109 /* Set USB channels in the USBHS UGCTRL2 register */
110 val = ioread32(priv->base); 110 val = ioread32(priv->base + USBHS_UGCTRL2_REG);
111 val &= ~(USBHS_UGCTRL2_USB0_HS | USBHS_UGCTRL2_USB2_SS); 111 val &= ~(USBHS_UGCTRL2_USB0_HS | USBHS_UGCTRL2_USB2_SS);
112 val |= priv->ugctrl2; 112 val |= priv->ugctrl2;
113 iowrite32(val, priv->base); 113 iowrite32(val, priv->base + USBHS_UGCTRL2_REG);
114} 114}
115 115
116/* Shutdown USB channels */ 116/* Shutdown USB channels */
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 9ced8937a8f3..fb0d537435eb 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -2123,6 +2123,20 @@ static void ftdi_set_termios(struct tty_struct *tty,
2123 termios->c_cflag |= CRTSCTS; 2123 termios->c_cflag |= CRTSCTS;
2124 } 2124 }
2125 2125
2126 /*
2127 * All FTDI UART chips are limited to CS7/8. We won't pretend to
2128 * support CS5/6 and revert the CSIZE setting instead.
2129 */
2130 if ((C_CSIZE(tty) != CS8) && (C_CSIZE(tty) != CS7)) {
2131 dev_warn(ddev, "requested CSIZE setting not supported\n");
2132
2133 termios->c_cflag &= ~CSIZE;
2134 if (old_termios)
2135 termios->c_cflag |= old_termios->c_cflag & CSIZE;
2136 else
2137 termios->c_cflag |= CS8;
2138 }
2139
2126 cflag = termios->c_cflag; 2140 cflag = termios->c_cflag;
2127 2141
2128 if (!old_termios) 2142 if (!old_termios)
@@ -2159,19 +2173,16 @@ no_skip:
2159 } else { 2173 } else {
2160 urb_value |= FTDI_SIO_SET_DATA_PARITY_NONE; 2174 urb_value |= FTDI_SIO_SET_DATA_PARITY_NONE;
2161 } 2175 }
2162 if (cflag & CSIZE) { 2176 switch (cflag & CSIZE) {
2163 switch (cflag & CSIZE) { 2177 case CS7:
2164 case CS7: 2178 urb_value |= 7;
2165 urb_value |= 7; 2179 dev_dbg(ddev, "Setting CS7\n");
2166 dev_dbg(ddev, "Setting CS7\n"); 2180 break;
2167 break; 2181 default:
2168 case CS8: 2182 case CS8:
2169 urb_value |= 8; 2183 urb_value |= 8;
2170 dev_dbg(ddev, "Setting CS8\n"); 2184 dev_dbg(ddev, "Setting CS8\n");
2171 break; 2185 break;
2172 default:
2173 dev_err(ddev, "CSIZE was set but not CS7-CS8\n");
2174 }
2175 } 2186 }
2176 2187
2177 /* This is needed by the break command since it uses the same command 2188 /* This is needed by the break command since it uses the same command
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 2b01ec8651c2..b63ce023f96f 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -173,16 +173,8 @@ retry:
173 clear_bit_unlock(USB_SERIAL_WRITE_BUSY, &port->flags); 173 clear_bit_unlock(USB_SERIAL_WRITE_BUSY, &port->flags);
174 return result; 174 return result;
175 } 175 }
176 /*
177 * Try sending off another urb, unless called from completion handler
178 * (in which case there will be no free urb or no data).
179 */
180 if (mem_flags != GFP_ATOMIC)
181 goto retry;
182 176
183 clear_bit_unlock(USB_SERIAL_WRITE_BUSY, &port->flags); 177 goto retry; /* try sending off another urb */
184
185 return 0;
186} 178}
187EXPORT_SYMBOL_GPL(usb_serial_generic_write_start); 179EXPORT_SYMBOL_GPL(usb_serial_generic_write_start);
188 180
@@ -208,7 +200,7 @@ int usb_serial_generic_write(struct tty_struct *tty,
208 return 0; 200 return 0;
209 201
210 count = kfifo_in_locked(&port->write_fifo, buf, count, &port->lock); 202 count = kfifo_in_locked(&port->write_fifo, buf, count, &port->lock);
211 result = usb_serial_generic_write_start(port, GFP_KERNEL); 203 result = usb_serial_generic_write_start(port, GFP_ATOMIC);
212 if (result) 204 if (result)
213 return result; 205 return result;
214 206
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index e5bdd987b9e8..a69da83604c0 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -1813,25 +1813,25 @@ static void mos7840_change_port_settings(struct tty_struct *tty,
1813 iflag = tty->termios.c_iflag; 1813 iflag = tty->termios.c_iflag;
1814 1814
1815 /* Change the number of bits */ 1815 /* Change the number of bits */
1816 if (cflag & CSIZE) { 1816 switch (cflag & CSIZE) {
1817 switch (cflag & CSIZE) { 1817 case CS5:
1818 case CS5: 1818 lData = LCR_BITS_5;
1819 lData = LCR_BITS_5; 1819 break;
1820 break;
1821 1820
1822 case CS6: 1821 case CS6:
1823 lData = LCR_BITS_6; 1822 lData = LCR_BITS_6;
1824 break; 1823 break;
1825 1824
1826 case CS7: 1825 case CS7:
1827 lData = LCR_BITS_7; 1826 lData = LCR_BITS_7;
1828 break; 1827 break;
1829 default: 1828
1830 case CS8: 1829 default:
1831 lData = LCR_BITS_8; 1830 case CS8:
1832 break; 1831 lData = LCR_BITS_8;
1833 } 1832 break;
1834 } 1833 }
1834
1835 /* Change the Parity bit */ 1835 /* Change the Parity bit */
1836 if (cflag & PARENB) { 1836 if (cflag & PARENB) {
1837 if (cflag & PARODD) { 1837 if (cflag & PARODD) {
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index c3d94853b4ab..496b7e39d5be 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -85,6 +85,7 @@ static void option_instat_callback(struct urb *urb);
85#define HUAWEI_PRODUCT_K4505 0x1464 85#define HUAWEI_PRODUCT_K4505 0x1464
86#define HUAWEI_PRODUCT_K3765 0x1465 86#define HUAWEI_PRODUCT_K3765 0x1465
87#define HUAWEI_PRODUCT_K4605 0x14C6 87#define HUAWEI_PRODUCT_K4605 0x14C6
88#define HUAWEI_PRODUCT_E173S6 0x1C07
88 89
89#define QUANTA_VENDOR_ID 0x0408 90#define QUANTA_VENDOR_ID 0x0408
90#define QUANTA_PRODUCT_Q101 0xEA02 91#define QUANTA_PRODUCT_Q101 0xEA02
@@ -572,6 +573,8 @@ static const struct usb_device_id option_ids[] = {
572 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1c23, USB_CLASS_COMM, 0x02, 0xff) }, 573 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1c23, USB_CLASS_COMM, 0x02, 0xff) },
573 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E173, 0xff, 0xff, 0xff), 574 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E173, 0xff, 0xff, 0xff),
574 .driver_info = (kernel_ulong_t) &net_intf1_blacklist }, 575 .driver_info = (kernel_ulong_t) &net_intf1_blacklist },
576 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E173S6, 0xff, 0xff, 0xff),
577 .driver_info = (kernel_ulong_t) &net_intf1_blacklist },
575 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1750, 0xff, 0xff, 0xff), 578 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E1750, 0xff, 0xff, 0xff),
576 .driver_info = (kernel_ulong_t) &net_intf2_blacklist }, 579 .driver_info = (kernel_ulong_t) &net_intf2_blacklist },
577 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1441, USB_CLASS_COMM, 0x02, 0xff) }, 580 { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0x1441, USB_CLASS_COMM, 0x02, 0xff) },
@@ -634,6 +637,10 @@ static const struct usb_device_id option_ids[] = {
634 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x6D) }, 637 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x6D) },
635 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x6E) }, 638 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x6E) },
636 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x6F) }, 639 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x6F) },
640 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x72) },
641 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x73) },
642 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x74) },
643 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x75) },
637 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x78) }, 644 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x78) },
638 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x79) }, 645 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x79) },
639 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x7A) }, 646 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x01, 0x7A) },
@@ -688,6 +695,10 @@ static const struct usb_device_id option_ids[] = {
688 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x6D) }, 695 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x6D) },
689 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x6E) }, 696 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x6E) },
690 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x6F) }, 697 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x6F) },
698 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x72) },
699 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x73) },
700 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x74) },
701 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x75) },
691 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x78) }, 702 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x78) },
692 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x79) }, 703 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x79) },
693 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x7A) }, 704 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x7A) },
@@ -742,6 +753,10 @@ static const struct usb_device_id option_ids[] = {
742 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6D) }, 753 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6D) },
743 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6E) }, 754 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6E) },
744 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6F) }, 755 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6F) },
756 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x72) },
757 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x73) },
758 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x74) },
759 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x75) },
745 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x78) }, 760 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x78) },
746 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x79) }, 761 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x79) },
747 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x7A) }, 762 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x7A) },
@@ -796,6 +811,10 @@ static const struct usb_device_id option_ids[] = {
796 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6D) }, 811 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6D) },
797 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6E) }, 812 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6E) },
798 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6F) }, 813 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6F) },
814 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x72) },
815 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x73) },
816 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x74) },
817 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x75) },
799 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x78) }, 818 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x78) },
800 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x79) }, 819 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x79) },
801 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x7A) }, 820 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x7A) },
@@ -850,6 +869,10 @@ static const struct usb_device_id option_ids[] = {
850 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6D) }, 869 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6D) },
851 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6E) }, 870 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6E) },
852 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6F) }, 871 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6F) },
872 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x72) },
873 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x73) },
874 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x74) },
875 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x75) },
853 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x78) }, 876 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x78) },
854 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x79) }, 877 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x79) },
855 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x7A) }, 878 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x7A) },
@@ -904,6 +927,10 @@ static const struct usb_device_id option_ids[] = {
904 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6D) }, 927 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6D) },
905 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6E) }, 928 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6E) },
906 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6F) }, 929 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6F) },
930 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x72) },
931 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x73) },
932 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x74) },
933 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x75) },
907 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x78) }, 934 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x78) },
908 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x79) }, 935 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x79) },
909 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x7A) }, 936 { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x7A) },
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 1e6de4cd079d..1e3318dfa1cb 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -361,23 +361,21 @@ static void pl2303_set_termios(struct tty_struct *tty,
361 0, 0, buf, 7, 100); 361 0, 0, buf, 7, 100);
362 dev_dbg(&port->dev, "0xa1:0x21:0:0 %d - %7ph\n", i, buf); 362 dev_dbg(&port->dev, "0xa1:0x21:0:0 %d - %7ph\n", i, buf);
363 363
364 if (C_CSIZE(tty)) { 364 switch (C_CSIZE(tty)) {
365 switch (C_CSIZE(tty)) { 365 case CS5:
366 case CS5: 366 buf[6] = 5;
367 buf[6] = 5; 367 break;
368 break; 368 case CS6:
369 case CS6: 369 buf[6] = 6;
370 buf[6] = 6; 370 break;
371 break; 371 case CS7:
372 case CS7: 372 buf[6] = 7;
373 buf[6] = 7; 373 break;
374 break; 374 default:
375 default: 375 case CS8:
376 case CS8: 376 buf[6] = 8;
377 buf[6] = 8;
378 }
379 dev_dbg(&port->dev, "data bits = %d\n", buf[6]);
380 } 377 }
378 dev_dbg(&port->dev, "data bits = %d\n", buf[6]);
381 379
382 /* For reference buf[0]:buf[3] baud rate value */ 380 /* For reference buf[0]:buf[3] baud rate value */
383 pl2303_encode_baudrate(tty, port, &buf[0]); 381 pl2303_encode_baudrate(tty, port, &buf[0]);
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c
index 4abac28b5992..5b793c352267 100644
--- a/drivers/usb/serial/spcp8x5.c
+++ b/drivers/usb/serial/spcp8x5.c
@@ -348,22 +348,20 @@ static void spcp8x5_set_termios(struct tty_struct *tty,
348 } 348 }
349 349
350 /* Set Data Length : 00:5bit, 01:6bit, 10:7bit, 11:8bit */ 350 /* Set Data Length : 00:5bit, 01:6bit, 10:7bit, 11:8bit */
351 if (cflag & CSIZE) { 351 switch (cflag & CSIZE) {
352 switch (cflag & CSIZE) { 352 case CS5:
353 case CS5: 353 buf[1] |= SET_UART_FORMAT_SIZE_5;
354 buf[1] |= SET_UART_FORMAT_SIZE_5; 354 break;
355 break; 355 case CS6:
356 case CS6: 356 buf[1] |= SET_UART_FORMAT_SIZE_6;
357 buf[1] |= SET_UART_FORMAT_SIZE_6; 357 break;
358 break; 358 case CS7:
359 case CS7: 359 buf[1] |= SET_UART_FORMAT_SIZE_7;
360 buf[1] |= SET_UART_FORMAT_SIZE_7; 360 break;
361 break; 361 default:
362 default: 362 case CS8:
363 case CS8: 363 buf[1] |= SET_UART_FORMAT_SIZE_8;
364 buf[1] |= SET_UART_FORMAT_SIZE_8; 364 break;
365 break;
366 }
367 } 365 }
368 366
369 /* Set Stop bit2 : 0:1bit 1:2bit */ 367 /* Set Stop bit2 : 0:1bit 1:2bit */
diff --git a/drivers/usb/wusbcore/devconnect.c b/drivers/usb/wusbcore/devconnect.c
index e538b72c4e3a..f14e7929ba22 100644
--- a/drivers/usb/wusbcore/devconnect.c
+++ b/drivers/usb/wusbcore/devconnect.c
@@ -97,18 +97,12 @@ static void wusbhc_devconnect_acked_work(struct work_struct *work);
97 97
98static void wusb_dev_free(struct wusb_dev *wusb_dev) 98static void wusb_dev_free(struct wusb_dev *wusb_dev)
99{ 99{
100 if (wusb_dev) { 100 kfree(wusb_dev);
101 kfree(wusb_dev->set_gtk_req);
102 usb_free_urb(wusb_dev->set_gtk_urb);
103 kfree(wusb_dev);
104 }
105} 101}
106 102
107static struct wusb_dev *wusb_dev_alloc(struct wusbhc *wusbhc) 103static struct wusb_dev *wusb_dev_alloc(struct wusbhc *wusbhc)
108{ 104{
109 struct wusb_dev *wusb_dev; 105 struct wusb_dev *wusb_dev;
110 struct urb *urb;
111 struct usb_ctrlrequest *req;
112 106
113 wusb_dev = kzalloc(sizeof(*wusb_dev), GFP_KERNEL); 107 wusb_dev = kzalloc(sizeof(*wusb_dev), GFP_KERNEL);
114 if (wusb_dev == NULL) 108 if (wusb_dev == NULL)
@@ -118,22 +112,6 @@ static struct wusb_dev *wusb_dev_alloc(struct wusbhc *wusbhc)
118 112
119 INIT_WORK(&wusb_dev->devconnect_acked_work, wusbhc_devconnect_acked_work); 113 INIT_WORK(&wusb_dev->devconnect_acked_work, wusbhc_devconnect_acked_work);
120 114
121 urb = usb_alloc_urb(0, GFP_KERNEL);
122 if (urb == NULL)
123 goto err;
124 wusb_dev->set_gtk_urb = urb;
125
126 req = kmalloc(sizeof(*req), GFP_KERNEL);
127 if (req == NULL)
128 goto err;
129 wusb_dev->set_gtk_req = req;
130
131 req->bRequestType = USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE;
132 req->bRequest = USB_REQ_SET_DESCRIPTOR;
133 req->wValue = cpu_to_le16(USB_DT_KEY << 8 | wusbhc->gtk_index);
134 req->wIndex = 0;
135 req->wLength = cpu_to_le16(wusbhc->gtk.descr.bLength);
136
137 return wusb_dev; 115 return wusb_dev;
138err: 116err:
139 wusb_dev_free(wusb_dev); 117 wusb_dev_free(wusb_dev);
@@ -411,9 +389,6 @@ static void __wusbhc_dev_disconnect(struct wusbhc *wusbhc,
411/* 389/*
412 * Refresh the list of keep alives to emit in the MMC 390 * Refresh the list of keep alives to emit in the MMC
413 * 391 *
414 * Some devices don't respond to keep alives unless they've been
415 * authenticated, so skip unauthenticated devices.
416 *
417 * We only publish the first four devices that have a coming timeout 392 * We only publish the first four devices that have a coming timeout
418 * condition. Then when we are done processing those, we go for the 393 * condition. Then when we are done processing those, we go for the
419 * next ones. We ignore the ones that have timed out already (they'll 394 * next ones. We ignore the ones that have timed out already (they'll
@@ -448,7 +423,7 @@ static void __wusbhc_keep_alive(struct wusbhc *wusbhc)
448 423
449 if (wusb_dev == NULL) 424 if (wusb_dev == NULL)
450 continue; 425 continue;
451 if (wusb_dev->usb_dev == NULL || !wusb_dev->usb_dev->authenticated) 426 if (wusb_dev->usb_dev == NULL)
452 continue; 427 continue;
453 428
454 if (time_after(jiffies, wusb_dev->entry_ts + tt)) { 429 if (time_after(jiffies, wusb_dev->entry_ts + tt)) {
@@ -524,11 +499,19 @@ static struct wusb_dev *wusbhc_find_dev_by_addr(struct wusbhc *wusbhc, u8 addr)
524 * 499 *
525 * @wusbhc shall be referenced and unlocked 500 * @wusbhc shall be referenced and unlocked
526 */ 501 */
527static void wusbhc_handle_dn_alive(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev) 502static void wusbhc_handle_dn_alive(struct wusbhc *wusbhc, u8 srcaddr)
528{ 503{
504 struct wusb_dev *wusb_dev;
505
529 mutex_lock(&wusbhc->mutex); 506 mutex_lock(&wusbhc->mutex);
530 wusb_dev->entry_ts = jiffies; 507 wusb_dev = wusbhc_find_dev_by_addr(wusbhc, srcaddr);
531 __wusbhc_keep_alive(wusbhc); 508 if (wusb_dev == NULL) {
509 dev_dbg(wusbhc->dev, "ignoring DN_Alive from unconnected device %02x\n",
510 srcaddr);
511 } else {
512 wusb_dev->entry_ts = jiffies;
513 __wusbhc_keep_alive(wusbhc);
514 }
532 mutex_unlock(&wusbhc->mutex); 515 mutex_unlock(&wusbhc->mutex);
533} 516}
534 517
@@ -582,14 +565,22 @@ static void wusbhc_handle_dn_connect(struct wusbhc *wusbhc,
582 * 565 *
583 * @wusbhc shall be referenced and unlocked 566 * @wusbhc shall be referenced and unlocked
584 */ 567 */
585static void wusbhc_handle_dn_disconnect(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev) 568static void wusbhc_handle_dn_disconnect(struct wusbhc *wusbhc, u8 srcaddr)
586{ 569{
587 struct device *dev = wusbhc->dev; 570 struct device *dev = wusbhc->dev;
588 571 struct wusb_dev *wusb_dev;
589 dev_info(dev, "DN DISCONNECT: device 0x%02x going down\n", wusb_dev->addr);
590 572
591 mutex_lock(&wusbhc->mutex); 573 mutex_lock(&wusbhc->mutex);
592 __wusbhc_dev_disconnect(wusbhc, wusb_port_by_idx(wusbhc, wusb_dev->port_idx)); 574 wusb_dev = wusbhc_find_dev_by_addr(wusbhc, srcaddr);
575 if (wusb_dev == NULL) {
576 dev_dbg(dev, "ignoring DN DISCONNECT from unconnected device %02x\n",
577 srcaddr);
578 } else {
579 dev_info(dev, "DN DISCONNECT: device 0x%02x going down\n",
580 wusb_dev->addr);
581 __wusbhc_dev_disconnect(wusbhc, wusb_port_by_idx(wusbhc,
582 wusb_dev->port_idx));
583 }
593 mutex_unlock(&wusbhc->mutex); 584 mutex_unlock(&wusbhc->mutex);
594} 585}
595 586
@@ -611,30 +602,21 @@ void wusbhc_handle_dn(struct wusbhc *wusbhc, u8 srcaddr,
611 struct wusb_dn_hdr *dn_hdr, size_t size) 602 struct wusb_dn_hdr *dn_hdr, size_t size)
612{ 603{
613 struct device *dev = wusbhc->dev; 604 struct device *dev = wusbhc->dev;
614 struct wusb_dev *wusb_dev;
615 605
616 if (size < sizeof(struct wusb_dn_hdr)) { 606 if (size < sizeof(struct wusb_dn_hdr)) {
617 dev_err(dev, "DN data shorter than DN header (%d < %d)\n", 607 dev_err(dev, "DN data shorter than DN header (%d < %d)\n",
618 (int)size, (int)sizeof(struct wusb_dn_hdr)); 608 (int)size, (int)sizeof(struct wusb_dn_hdr));
619 return; 609 return;
620 } 610 }
621
622 wusb_dev = wusbhc_find_dev_by_addr(wusbhc, srcaddr);
623 if (wusb_dev == NULL && dn_hdr->bType != WUSB_DN_CONNECT) {
624 dev_dbg(dev, "ignoring DN %d from unconnected device %02x\n",
625 dn_hdr->bType, srcaddr);
626 return;
627 }
628
629 switch (dn_hdr->bType) { 611 switch (dn_hdr->bType) {
630 case WUSB_DN_CONNECT: 612 case WUSB_DN_CONNECT:
631 wusbhc_handle_dn_connect(wusbhc, dn_hdr, size); 613 wusbhc_handle_dn_connect(wusbhc, dn_hdr, size);
632 break; 614 break;
633 case WUSB_DN_ALIVE: 615 case WUSB_DN_ALIVE:
634 wusbhc_handle_dn_alive(wusbhc, wusb_dev); 616 wusbhc_handle_dn_alive(wusbhc, srcaddr);
635 break; 617 break;
636 case WUSB_DN_DISCONNECT: 618 case WUSB_DN_DISCONNECT:
637 wusbhc_handle_dn_disconnect(wusbhc, wusb_dev); 619 wusbhc_handle_dn_disconnect(wusbhc, srcaddr);
638 break; 620 break;
639 case WUSB_DN_MASAVAILCHANGED: 621 case WUSB_DN_MASAVAILCHANGED:
640 case WUSB_DN_RWAKE: 622 case WUSB_DN_RWAKE:
diff --git a/drivers/usb/wusbcore/security.c b/drivers/usb/wusbcore/security.c
index dd88441c8f78..4c40d0dbf53d 100644
--- a/drivers/usb/wusbcore/security.c
+++ b/drivers/usb/wusbcore/security.c
@@ -29,19 +29,16 @@
29#include <linux/export.h> 29#include <linux/export.h>
30#include "wusbhc.h" 30#include "wusbhc.h"
31 31
32static void wusbhc_set_gtk_callback(struct urb *urb); 32static void wusbhc_gtk_rekey_work(struct work_struct *work);
33static void wusbhc_gtk_rekey_done_work(struct work_struct *work);
34 33
35int wusbhc_sec_create(struct wusbhc *wusbhc) 34int wusbhc_sec_create(struct wusbhc *wusbhc)
36{ 35{
37 wusbhc->gtk.descr.bLength = sizeof(wusbhc->gtk.descr) + sizeof(wusbhc->gtk.data); 36 wusbhc->gtk.descr.bLength = sizeof(wusbhc->gtk.descr) + sizeof(wusbhc->gtk.data);
38 wusbhc->gtk.descr.bDescriptorType = USB_DT_KEY; 37 wusbhc->gtk.descr.bDescriptorType = USB_DT_KEY;
39 wusbhc->gtk.descr.bReserved = 0; 38 wusbhc->gtk.descr.bReserved = 0;
39 wusbhc->gtk_index = 0;
40 40
41 wusbhc->gtk_index = wusb_key_index(0, WUSB_KEY_INDEX_TYPE_GTK, 41 INIT_WORK(&wusbhc->gtk_rekey_work, wusbhc_gtk_rekey_work);
42 WUSB_KEY_INDEX_ORIGINATOR_HOST);
43
44 INIT_WORK(&wusbhc->gtk_rekey_done_work, wusbhc_gtk_rekey_done_work);
45 42
46 return 0; 43 return 0;
47} 44}
@@ -113,7 +110,7 @@ int wusbhc_sec_start(struct wusbhc *wusbhc)
113 wusbhc_generate_gtk(wusbhc); 110 wusbhc_generate_gtk(wusbhc);
114 111
115 result = wusbhc->set_gtk(wusbhc, wusbhc->gtk_tkid, 112 result = wusbhc->set_gtk(wusbhc, wusbhc->gtk_tkid,
116 &wusbhc->gtk.descr.bKeyData, key_size); 113 &wusbhc->gtk.descr.bKeyData, key_size);
117 if (result < 0) 114 if (result < 0)
118 dev_err(wusbhc->dev, "cannot set GTK for the host: %d\n", 115 dev_err(wusbhc->dev, "cannot set GTK for the host: %d\n",
119 result); 116 result);
@@ -129,7 +126,7 @@ int wusbhc_sec_start(struct wusbhc *wusbhc)
129 */ 126 */
130void wusbhc_sec_stop(struct wusbhc *wusbhc) 127void wusbhc_sec_stop(struct wusbhc *wusbhc)
131{ 128{
132 cancel_work_sync(&wusbhc->gtk_rekey_done_work); 129 cancel_work_sync(&wusbhc->gtk_rekey_work);
133} 130}
134 131
135 132
@@ -185,12 +182,14 @@ static int wusb_dev_set_encryption(struct usb_device *usb_dev, int value)
185static int wusb_dev_set_gtk(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev) 182static int wusb_dev_set_gtk(struct wusbhc *wusbhc, struct wusb_dev *wusb_dev)
186{ 183{
187 struct usb_device *usb_dev = wusb_dev->usb_dev; 184 struct usb_device *usb_dev = wusb_dev->usb_dev;
185 u8 key_index = wusb_key_index(wusbhc->gtk_index,
186 WUSB_KEY_INDEX_TYPE_GTK, WUSB_KEY_INDEX_ORIGINATOR_HOST);
188 187
189 return usb_control_msg( 188 return usb_control_msg(
190 usb_dev, usb_sndctrlpipe(usb_dev, 0), 189 usb_dev, usb_sndctrlpipe(usb_dev, 0),
191 USB_REQ_SET_DESCRIPTOR, 190 USB_REQ_SET_DESCRIPTOR,
192 USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE, 191 USB_DIR_OUT | USB_TYPE_STANDARD | USB_RECIP_DEVICE,
193 USB_DT_KEY << 8 | wusbhc->gtk_index, 0, 192 USB_DT_KEY << 8 | key_index, 0,
194 &wusbhc->gtk.descr, wusbhc->gtk.descr.bLength, 193 &wusbhc->gtk.descr, wusbhc->gtk.descr.bLength,
195 1000); 194 1000);
196} 195}
@@ -520,24 +519,55 @@ error_kzalloc:
520 * Once all connected and authenticated devices have received the new 519 * Once all connected and authenticated devices have received the new
521 * GTK, switch the host to using it. 520 * GTK, switch the host to using it.
522 */ 521 */
523static void wusbhc_gtk_rekey_done_work(struct work_struct *work) 522static void wusbhc_gtk_rekey_work(struct work_struct *work)
524{ 523{
525 struct wusbhc *wusbhc = container_of(work, struct wusbhc, gtk_rekey_done_work); 524 struct wusbhc *wusbhc = container_of(work,
525 struct wusbhc, gtk_rekey_work);
526 size_t key_size = sizeof(wusbhc->gtk.data); 526 size_t key_size = sizeof(wusbhc->gtk.data);
527 int port_idx;
528 struct wusb_dev *wusb_dev, *wusb_dev_next;
529 LIST_HEAD(rekey_list);
527 530
528 mutex_lock(&wusbhc->mutex); 531 mutex_lock(&wusbhc->mutex);
532 /* generate the new key */
533 wusbhc_generate_gtk(wusbhc);
534 /* roll the gtk index. */
535 wusbhc->gtk_index = (wusbhc->gtk_index + 1) % (WUSB_KEY_INDEX_MAX + 1);
536 /*
537 * Save all connected devices on a list while holding wusbhc->mutex and
538 * take a reference to each one. Then submit the set key request to
539 * them after releasing the lock in order to avoid a deadlock.
540 */
541 for (port_idx = 0; port_idx < wusbhc->ports_max; port_idx++) {
542 wusb_dev = wusbhc->port[port_idx].wusb_dev;
543 if (!wusb_dev || !wusb_dev->usb_dev
544 || !wusb_dev->usb_dev->authenticated)
545 continue;
529 546
530 if (--wusbhc->pending_set_gtks == 0) 547 wusb_dev_get(wusb_dev);
531 wusbhc->set_gtk(wusbhc, wusbhc->gtk_tkid, &wusbhc->gtk.descr.bKeyData, key_size); 548 list_add_tail(&wusb_dev->rekey_node, &rekey_list);
532 549 }
533 mutex_unlock(&wusbhc->mutex); 550 mutex_unlock(&wusbhc->mutex);
534}
535 551
536static void wusbhc_set_gtk_callback(struct urb *urb) 552 /* Submit the rekey requests without holding wusbhc->mutex. */
537{ 553 list_for_each_entry_safe(wusb_dev, wusb_dev_next, &rekey_list,
538 struct wusbhc *wusbhc = urb->context; 554 rekey_node) {
555 list_del_init(&wusb_dev->rekey_node);
556 dev_dbg(&wusb_dev->usb_dev->dev, "%s: rekey device at port %d\n",
557 __func__, wusb_dev->port_idx);
558
559 if (wusb_dev_set_gtk(wusbhc, wusb_dev) < 0) {
560 dev_err(&wusb_dev->usb_dev->dev, "%s: rekey device at port %d failed\n",
561 __func__, wusb_dev->port_idx);
562 }
563 wusb_dev_put(wusb_dev);
564 }
539 565
540 queue_work(wusbd, &wusbhc->gtk_rekey_done_work); 566 /* Switch the host controller to use the new GTK. */
567 mutex_lock(&wusbhc->mutex);
568 wusbhc->set_gtk(wusbhc, wusbhc->gtk_tkid,
569 &wusbhc->gtk.descr.bKeyData, key_size);
570 mutex_unlock(&wusbhc->mutex);
541} 571}
542 572
543/** 573/**
@@ -553,26 +583,12 @@ static void wusbhc_set_gtk_callback(struct urb *urb)
553 */ 583 */
554void wusbhc_gtk_rekey(struct wusbhc *wusbhc) 584void wusbhc_gtk_rekey(struct wusbhc *wusbhc)
555{ 585{
556 static const size_t key_size = sizeof(wusbhc->gtk.data); 586 /*
557 int p; 587 * We need to submit a URB to the downstream WUSB devices in order to
558 588 * change the group key. This can't be done while holding the
559 wusbhc_generate_gtk(wusbhc); 589 * wusbhc->mutex since that is also taken in the urb_enqueue routine
560 590 * and will cause a deadlock. Instead, queue a work item to do
561 for (p = 0; p < wusbhc->ports_max; p++) { 591 * it when the lock is not held
562 struct wusb_dev *wusb_dev; 592 */
563 593 queue_work(wusbd, &wusbhc->gtk_rekey_work);
564 wusb_dev = wusbhc->port[p].wusb_dev;
565 if (!wusb_dev || !wusb_dev->usb_dev || !wusb_dev->usb_dev->authenticated)
566 continue;
567
568 usb_fill_control_urb(wusb_dev->set_gtk_urb, wusb_dev->usb_dev,
569 usb_sndctrlpipe(wusb_dev->usb_dev, 0),
570 (void *)wusb_dev->set_gtk_req,
571 &wusbhc->gtk.descr, wusbhc->gtk.descr.bLength,
572 wusbhc_set_gtk_callback, wusbhc);
573 if (usb_submit_urb(wusb_dev->set_gtk_urb, GFP_KERNEL) == 0)
574 wusbhc->pending_set_gtks++;
575 }
576 if (wusbhc->pending_set_gtks == 0)
577 wusbhc->set_gtk(wusbhc, wusbhc->gtk_tkid, &wusbhc->gtk.descr.bKeyData, key_size);
578} 594}
diff --git a/drivers/usb/wusbcore/wusbhc.h b/drivers/usb/wusbcore/wusbhc.h
index 711b1952b114..6bd3b819a6b5 100644
--- a/drivers/usb/wusbcore/wusbhc.h
+++ b/drivers/usb/wusbcore/wusbhc.h
@@ -97,6 +97,7 @@ struct wusb_dev {
97 struct kref refcnt; 97 struct kref refcnt;
98 struct wusbhc *wusbhc; 98 struct wusbhc *wusbhc;
99 struct list_head cack_node; /* Connect-Ack list */ 99 struct list_head cack_node; /* Connect-Ack list */
100 struct list_head rekey_node; /* GTK rekey list */
100 u8 port_idx; 101 u8 port_idx;
101 u8 addr; 102 u8 addr;
102 u8 beacon_type:4; 103 u8 beacon_type:4;
@@ -107,8 +108,6 @@ struct wusb_dev {
107 struct usb_wireless_cap_descriptor *wusb_cap_descr; 108 struct usb_wireless_cap_descriptor *wusb_cap_descr;
108 struct uwb_mas_bm availability; 109 struct uwb_mas_bm availability;
109 struct work_struct devconnect_acked_work; 110 struct work_struct devconnect_acked_work;
110 struct urb *set_gtk_urb;
111 struct usb_ctrlrequest *set_gtk_req;
112 struct usb_device *usb_dev; 111 struct usb_device *usb_dev;
113}; 112};
114 113
@@ -296,8 +295,7 @@ struct wusbhc {
296 } __attribute__((packed)) gtk; 295 } __attribute__((packed)) gtk;
297 u8 gtk_index; 296 u8 gtk_index;
298 u32 gtk_tkid; 297 u32 gtk_tkid;
299 struct work_struct gtk_rekey_done_work; 298 struct work_struct gtk_rekey_work;
300 int pending_set_gtks;
301 299
302 struct usb_encryption_descriptor *ccm1_etd; 300 struct usb_encryption_descriptor *ccm1_etd;
303}; 301};
diff --git a/drivers/video/offb.c b/drivers/video/offb.c
index 9dbea2223401..7d44d669d5b6 100644
--- a/drivers/video/offb.c
+++ b/drivers/video/offb.c
@@ -91,6 +91,15 @@ extern boot_infos_t *boot_infos;
91#define AVIVO_DC_LUTB_WHITE_OFFSET_GREEN 0x6cd4 91#define AVIVO_DC_LUTB_WHITE_OFFSET_GREEN 0x6cd4
92#define AVIVO_DC_LUTB_WHITE_OFFSET_RED 0x6cd8 92#define AVIVO_DC_LUTB_WHITE_OFFSET_RED 0x6cd8
93 93
94#define FB_RIGHT_POS(p, bpp) (fb_be_math(p) ? 0 : (32 - (bpp)))
95
96static inline u32 offb_cmap_byteswap(struct fb_info *info, u32 value)
97{
98 u32 bpp = info->var.bits_per_pixel;
99
100 return cpu_to_be32(value) >> FB_RIGHT_POS(info, bpp);
101}
102
94 /* 103 /*
95 * Set a single color register. The values supplied are already 104 * Set a single color register. The values supplied are already
96 * rounded down to the hardware's capabilities (according to the 105 * rounded down to the hardware's capabilities (according to the
@@ -120,7 +129,7 @@ static int offb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
120 mask <<= info->var.transp.offset; 129 mask <<= info->var.transp.offset;
121 value |= mask; 130 value |= mask;
122 } 131 }
123 pal[regno] = value; 132 pal[regno] = offb_cmap_byteswap(info, value);
124 return 0; 133 return 0;
125 } 134 }
126 135
@@ -301,7 +310,7 @@ static struct fb_ops offb_ops = {
301static void __iomem *offb_map_reg(struct device_node *np, int index, 310static void __iomem *offb_map_reg(struct device_node *np, int index,
302 unsigned long offset, unsigned long size) 311 unsigned long offset, unsigned long size)
303{ 312{
304 const u32 *addrp; 313 const __be32 *addrp;
305 u64 asize, taddr; 314 u64 asize, taddr;
306 unsigned int flags; 315 unsigned int flags;
307 316
@@ -369,7 +378,11 @@ static void offb_init_palette_hacks(struct fb_info *info, struct device_node *dp
369 } 378 }
370 of_node_put(pciparent); 379 of_node_put(pciparent);
371 } else if (dp && of_device_is_compatible(dp, "qemu,std-vga")) { 380 } else if (dp && of_device_is_compatible(dp, "qemu,std-vga")) {
372 const u32 io_of_addr[3] = { 0x01000000, 0x0, 0x0 }; 381#ifdef __BIG_ENDIAN
382 const __be32 io_of_addr[3] = { 0x01000000, 0x0, 0x0 };
383#else
384 const __be32 io_of_addr[3] = { 0x00000001, 0x0, 0x0 };
385#endif
373 u64 io_addr = of_translate_address(dp, io_of_addr); 386 u64 io_addr = of_translate_address(dp, io_of_addr);
374 if (io_addr != OF_BAD_ADDR) { 387 if (io_addr != OF_BAD_ADDR) {
375 par->cmap_adr = ioremap(io_addr + 0x3c8, 2); 388 par->cmap_adr = ioremap(io_addr + 0x3c8, 2);
@@ -535,7 +548,7 @@ static void __init offb_init_nodriver(struct device_node *dp, int no_real_node)
535 unsigned int flags, rsize, addr_prop = 0; 548 unsigned int flags, rsize, addr_prop = 0;
536 unsigned long max_size = 0; 549 unsigned long max_size = 0;
537 u64 rstart, address = OF_BAD_ADDR; 550 u64 rstart, address = OF_BAD_ADDR;
538 const u32 *pp, *addrp, *up; 551 const __be32 *pp, *addrp, *up;
539 u64 asize; 552 u64 asize;
540 int foreign_endian = 0; 553 int foreign_endian = 0;
541 554
@@ -551,25 +564,25 @@ static void __init offb_init_nodriver(struct device_node *dp, int no_real_node)
551 if (pp == NULL) 564 if (pp == NULL)
552 pp = of_get_property(dp, "depth", &len); 565 pp = of_get_property(dp, "depth", &len);
553 if (pp && len == sizeof(u32)) 566 if (pp && len == sizeof(u32))
554 depth = *pp; 567 depth = be32_to_cpup(pp);
555 568
556 pp = of_get_property(dp, "linux,bootx-width", &len); 569 pp = of_get_property(dp, "linux,bootx-width", &len);
557 if (pp == NULL) 570 if (pp == NULL)
558 pp = of_get_property(dp, "width", &len); 571 pp = of_get_property(dp, "width", &len);
559 if (pp && len == sizeof(u32)) 572 if (pp && len == sizeof(u32))
560 width = *pp; 573 width = be32_to_cpup(pp);
561 574
562 pp = of_get_property(dp, "linux,bootx-height", &len); 575 pp = of_get_property(dp, "linux,bootx-height", &len);
563 if (pp == NULL) 576 if (pp == NULL)
564 pp = of_get_property(dp, "height", &len); 577 pp = of_get_property(dp, "height", &len);
565 if (pp && len == sizeof(u32)) 578 if (pp && len == sizeof(u32))
566 height = *pp; 579 height = be32_to_cpup(pp);
567 580
568 pp = of_get_property(dp, "linux,bootx-linebytes", &len); 581 pp = of_get_property(dp, "linux,bootx-linebytes", &len);
569 if (pp == NULL) 582 if (pp == NULL)
570 pp = of_get_property(dp, "linebytes", &len); 583 pp = of_get_property(dp, "linebytes", &len);
571 if (pp && len == sizeof(u32) && (*pp != 0xffffffffu)) 584 if (pp && len == sizeof(u32) && (*pp != 0xffffffffu))
572 pitch = *pp; 585 pitch = be32_to_cpup(pp);
573 else 586 else
574 pitch = width * ((depth + 7) / 8); 587 pitch = width * ((depth + 7) / 8);
575 588
diff --git a/drivers/watchdog/bcm2835_wdt.c b/drivers/watchdog/bcm2835_wdt.c
index a6a2cebb2587..cafa973c43be 100644
--- a/drivers/watchdog/bcm2835_wdt.c
+++ b/drivers/watchdog/bcm2835_wdt.c
@@ -19,7 +19,6 @@
19#include <linux/watchdog.h> 19#include <linux/watchdog.h>
20#include <linux/platform_device.h> 20#include <linux/platform_device.h>
21#include <linux/of_address.h> 21#include <linux/of_address.h>
22#include <linux/miscdevice.h>
23 22
24#define PM_RSTC 0x1c 23#define PM_RSTC 0x1c
25#define PM_WDOG 0x24 24#define PM_WDOG 0x24
diff --git a/drivers/watchdog/ep93xx_wdt.c b/drivers/watchdog/ep93xx_wdt.c
index 833e81311848..d1d07f2f69df 100644
--- a/drivers/watchdog/ep93xx_wdt.c
+++ b/drivers/watchdog/ep93xx_wdt.c
@@ -28,7 +28,6 @@
28 28
29#include <linux/platform_device.h> 29#include <linux/platform_device.h>
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/miscdevice.h>
32#include <linux/watchdog.h> 31#include <linux/watchdog.h>
33#include <linux/timer.h> 32#include <linux/timer.h>
34#include <linux/io.h> 33#include <linux/io.h>
diff --git a/drivers/watchdog/ie6xx_wdt.c b/drivers/watchdog/ie6xx_wdt.c
index 70a240297c6d..07f88f54e5c0 100644
--- a/drivers/watchdog/ie6xx_wdt.c
+++ b/drivers/watchdog/ie6xx_wdt.c
@@ -28,7 +28,6 @@
28#include <linux/kernel.h> 28#include <linux/kernel.h>
29#include <linux/types.h> 29#include <linux/types.h>
30#include <linux/watchdog.h> 30#include <linux/watchdog.h>
31#include <linux/miscdevice.h>
32#include <linux/seq_file.h> 31#include <linux/seq_file.h>
33#include <linux/debugfs.h> 32#include <linux/debugfs.h>
34#include <linux/uaccess.h> 33#include <linux/uaccess.h>
diff --git a/drivers/watchdog/jz4740_wdt.c b/drivers/watchdog/jz4740_wdt.c
index 2de486a7eea1..3aa50cfa335f 100644
--- a/drivers/watchdog/jz4740_wdt.c
+++ b/drivers/watchdog/jz4740_wdt.c
@@ -17,7 +17,6 @@
17#include <linux/moduleparam.h> 17#include <linux/moduleparam.h>
18#include <linux/types.h> 18#include <linux/types.h>
19#include <linux/kernel.h> 19#include <linux/kernel.h>
20#include <linux/miscdevice.h>
21#include <linux/watchdog.h> 20#include <linux/watchdog.h>
22#include <linux/init.h> 21#include <linux/init.h>
23#include <linux/platform_device.h> 22#include <linux/platform_device.h>
diff --git a/drivers/watchdog/kempld_wdt.c b/drivers/watchdog/kempld_wdt.c
index a1a3638c579c..20dc73844737 100644
--- a/drivers/watchdog/kempld_wdt.c
+++ b/drivers/watchdog/kempld_wdt.c
@@ -26,7 +26,6 @@
26 26
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/moduleparam.h> 28#include <linux/moduleparam.h>
29#include <linux/miscdevice.h>
30#include <linux/uaccess.h> 29#include <linux/uaccess.h>
31#include <linux/watchdog.h> 30#include <linux/watchdog.h>
32#include <linux/platform_device.h> 31#include <linux/platform_device.h>
diff --git a/drivers/watchdog/max63xx_wdt.c b/drivers/watchdog/max63xx_wdt.c
index 6d4f3998e1f6..bdb3f4a5b27c 100644
--- a/drivers/watchdog/max63xx_wdt.c
+++ b/drivers/watchdog/max63xx_wdt.c
@@ -19,7 +19,6 @@
19#include <linux/moduleparam.h> 19#include <linux/moduleparam.h>
20#include <linux/types.h> 20#include <linux/types.h>
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/miscdevice.h>
23#include <linux/watchdog.h> 22#include <linux/watchdog.h>
24#include <linux/init.h> 23#include <linux/init.h>
25#include <linux/bitops.h> 24#include <linux/bitops.h>
diff --git a/drivers/watchdog/orion_wdt.c b/drivers/watchdog/orion_wdt.c
index 44edca66d564..f7722a424676 100644
--- a/drivers/watchdog/orion_wdt.c
+++ b/drivers/watchdog/orion_wdt.c
@@ -16,7 +16,6 @@
16#include <linux/moduleparam.h> 16#include <linux/moduleparam.h>
17#include <linux/types.h> 17#include <linux/types.h>
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/miscdevice.h>
20#include <linux/platform_device.h> 19#include <linux/platform_device.h>
21#include <linux/watchdog.h> 20#include <linux/watchdog.h>
22#include <linux/init.h> 21#include <linux/init.h>
diff --git a/drivers/watchdog/pnx4008_wdt.c b/drivers/watchdog/pnx4008_wdt.c
index 1bdcc313e1d9..5bec20f5dc2d 100644
--- a/drivers/watchdog/pnx4008_wdt.c
+++ b/drivers/watchdog/pnx4008_wdt.c
@@ -23,7 +23,6 @@
23#include <linux/moduleparam.h> 23#include <linux/moduleparam.h>
24#include <linux/types.h> 24#include <linux/types.h>
25#include <linux/kernel.h> 25#include <linux/kernel.h>
26#include <linux/miscdevice.h>
27#include <linux/watchdog.h> 26#include <linux/watchdog.h>
28#include <linux/init.h> 27#include <linux/init.h>
29#include <linux/platform_device.h> 28#include <linux/platform_device.h>
diff --git a/drivers/watchdog/rt2880_wdt.c b/drivers/watchdog/rt2880_wdt.c
index 53d37fea183e..d92c2d5859ce 100644
--- a/drivers/watchdog/rt2880_wdt.c
+++ b/drivers/watchdog/rt2880_wdt.c
@@ -16,7 +16,6 @@
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/kernel.h> 17#include <linux/kernel.h>
18#include <linux/watchdog.h> 18#include <linux/watchdog.h>
19#include <linux/miscdevice.h>
20#include <linux/moduleparam.h> 19#include <linux/moduleparam.h>
21#include <linux/platform_device.h> 20#include <linux/platform_device.h>
22 21
diff --git a/drivers/watchdog/sc1200wdt.c b/drivers/watchdog/sc1200wdt.c
index 3b9fff9dcf65..131193a7acdf 100644
--- a/drivers/watchdog/sc1200wdt.c
+++ b/drivers/watchdog/sc1200wdt.c
@@ -409,8 +409,9 @@ static int __init sc1200wdt_init(void)
409#if defined CONFIG_PNP 409#if defined CONFIG_PNP
410 /* now that the user has specified an IO port and we haven't detected 410 /* now that the user has specified an IO port and we haven't detected
411 * any devices, disable pnp support */ 411 * any devices, disable pnp support */
412 if (isapnp)
413 pnp_unregister_driver(&scl200wdt_pnp_driver);
412 isapnp = 0; 414 isapnp = 0;
413 pnp_unregister_driver(&scl200wdt_pnp_driver);
414#endif 415#endif
415 416
416 if (!request_region(io, io_len, SC1200_MODULE_NAME)) { 417 if (!request_region(io, io_len, SC1200_MODULE_NAME)) {
diff --git a/drivers/watchdog/shwdt.c b/drivers/watchdog/shwdt.c
index f9b8e06f3558..af3528f84d65 100644
--- a/drivers/watchdog/shwdt.c
+++ b/drivers/watchdog/shwdt.c
@@ -26,7 +26,6 @@
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/types.h> 27#include <linux/types.h>
28#include <linux/spinlock.h> 28#include <linux/spinlock.h>
29#include <linux/miscdevice.h>
30#include <linux/watchdog.h> 29#include <linux/watchdog.h>
31#include <linux/pm_runtime.h> 30#include <linux/pm_runtime.h>
32#include <linux/fs.h> 31#include <linux/fs.h>
diff --git a/drivers/watchdog/softdog.c b/drivers/watchdog/softdog.c
index ef2638fee4a8..c04a1aa158e2 100644
--- a/drivers/watchdog/softdog.c
+++ b/drivers/watchdog/softdog.c
@@ -42,7 +42,6 @@
42#include <linux/moduleparam.h> 42#include <linux/moduleparam.h>
43#include <linux/types.h> 43#include <linux/types.h>
44#include <linux/timer.h> 44#include <linux/timer.h>
45#include <linux/miscdevice.h>
46#include <linux/watchdog.h> 45#include <linux/watchdog.h>
47#include <linux/notifier.h> 46#include <linux/notifier.h>
48#include <linux/reboot.h> 47#include <linux/reboot.h>
diff --git a/drivers/watchdog/stmp3xxx_rtc_wdt.c b/drivers/watchdog/stmp3xxx_rtc_wdt.c
index d667f6b51d35..bb64ae3f47da 100644
--- a/drivers/watchdog/stmp3xxx_rtc_wdt.c
+++ b/drivers/watchdog/stmp3xxx_rtc_wdt.c
@@ -12,7 +12,6 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/miscdevice.h>
16#include <linux/watchdog.h> 15#include <linux/watchdog.h>
17#include <linux/platform_device.h> 16#include <linux/platform_device.h>
18#include <linux/stmp3xxx_rtc_wdt.h> 17#include <linux/stmp3xxx_rtc_wdt.h>
diff --git a/drivers/watchdog/txx9wdt.c b/drivers/watchdog/txx9wdt.c
index 0fd0e8ae62a8..6a447e321dd0 100644
--- a/drivers/watchdog/txx9wdt.c
+++ b/drivers/watchdog/txx9wdt.c
@@ -13,7 +13,6 @@
13#include <linux/module.h> 13#include <linux/module.h>
14#include <linux/moduleparam.h> 14#include <linux/moduleparam.h>
15#include <linux/types.h> 15#include <linux/types.h>
16#include <linux/miscdevice.h>
17#include <linux/watchdog.h> 16#include <linux/watchdog.h>
18#include <linux/init.h> 17#include <linux/init.h>
19#include <linux/platform_device.h> 18#include <linux/platform_device.h>
diff --git a/drivers/watchdog/ux500_wdt.c b/drivers/watchdog/ux500_wdt.c
index e029b5768f2c..5aed9d7ad47e 100644
--- a/drivers/watchdog/ux500_wdt.c
+++ b/drivers/watchdog/ux500_wdt.c
@@ -12,7 +12,6 @@
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/moduleparam.h> 14#include <linux/moduleparam.h>
15#include <linux/miscdevice.h>
16#include <linux/err.h> 15#include <linux/err.h>
17#include <linux/uaccess.h> 16#include <linux/uaccess.h>
18#include <linux/watchdog.h> 17#include <linux/watchdog.h>
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 45d98d01028f..9c01509dd8ab 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -767,20 +767,19 @@ int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
767 if (!path) 767 if (!path)
768 return -ENOMEM; 768 return -ENOMEM;
769 769
770 if (metadata) {
771 key.objectid = bytenr;
772 key.type = BTRFS_METADATA_ITEM_KEY;
773 key.offset = offset;
774 } else {
775 key.objectid = bytenr;
776 key.type = BTRFS_EXTENT_ITEM_KEY;
777 key.offset = offset;
778 }
779
780 if (!trans) { 770 if (!trans) {
781 path->skip_locking = 1; 771 path->skip_locking = 1;
782 path->search_commit_root = 1; 772 path->search_commit_root = 1;
783 } 773 }
774
775search_again:
776 key.objectid = bytenr;
777 key.offset = offset;
778 if (metadata)
779 key.type = BTRFS_METADATA_ITEM_KEY;
780 else
781 key.type = BTRFS_EXTENT_ITEM_KEY;
782
784again: 783again:
785 ret = btrfs_search_slot(trans, root->fs_info->extent_root, 784 ret = btrfs_search_slot(trans, root->fs_info->extent_root,
786 &key, path, 0, 0); 785 &key, path, 0, 0);
@@ -788,7 +787,6 @@ again:
788 goto out_free; 787 goto out_free;
789 788
790 if (ret > 0 && metadata && key.type == BTRFS_METADATA_ITEM_KEY) { 789 if (ret > 0 && metadata && key.type == BTRFS_METADATA_ITEM_KEY) {
791 metadata = 0;
792 if (path->slots[0]) { 790 if (path->slots[0]) {
793 path->slots[0]--; 791 path->slots[0]--;
794 btrfs_item_key_to_cpu(path->nodes[0], &key, 792 btrfs_item_key_to_cpu(path->nodes[0], &key,
@@ -855,7 +853,7 @@ again:
855 mutex_lock(&head->mutex); 853 mutex_lock(&head->mutex);
856 mutex_unlock(&head->mutex); 854 mutex_unlock(&head->mutex);
857 btrfs_put_delayed_ref(&head->node); 855 btrfs_put_delayed_ref(&head->node);
858 goto again; 856 goto search_again;
859 } 857 }
860 if (head->extent_op && head->extent_op->update_flags) 858 if (head->extent_op && head->extent_op->update_flags)
861 extent_flags |= head->extent_op->flags_to_set; 859 extent_flags |= head->extent_op->flags_to_set;
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index a111622598b0..21da5762b0b1 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2121,7 +2121,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
2121 2121
2122 err = mutex_lock_killable_nested(&dir->i_mutex, I_MUTEX_PARENT); 2122 err = mutex_lock_killable_nested(&dir->i_mutex, I_MUTEX_PARENT);
2123 if (err == -EINTR) 2123 if (err == -EINTR)
2124 goto out; 2124 goto out_drop_write;
2125 dentry = lookup_one_len(vol_args->name, parent, namelen); 2125 dentry = lookup_one_len(vol_args->name, parent, namelen);
2126 if (IS_ERR(dentry)) { 2126 if (IS_ERR(dentry)) {
2127 err = PTR_ERR(dentry); 2127 err = PTR_ERR(dentry);
@@ -2284,6 +2284,7 @@ out_dput:
2284 dput(dentry); 2284 dput(dentry);
2285out_unlock_dir: 2285out_unlock_dir:
2286 mutex_unlock(&dir->i_mutex); 2286 mutex_unlock(&dir->i_mutex);
2287out_drop_write:
2287 mnt_drop_write_file(file); 2288 mnt_drop_write_file(file);
2288out: 2289out:
2289 kfree(vol_args); 2290 kfree(vol_args);
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index ce459a7cb16d..429c73c374b8 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -571,7 +571,9 @@ static int is_cowonly_root(u64 root_objectid)
571 root_objectid == BTRFS_CHUNK_TREE_OBJECTID || 571 root_objectid == BTRFS_CHUNK_TREE_OBJECTID ||
572 root_objectid == BTRFS_DEV_TREE_OBJECTID || 572 root_objectid == BTRFS_DEV_TREE_OBJECTID ||
573 root_objectid == BTRFS_TREE_LOG_OBJECTID || 573 root_objectid == BTRFS_TREE_LOG_OBJECTID ||
574 root_objectid == BTRFS_CSUM_TREE_OBJECTID) 574 root_objectid == BTRFS_CSUM_TREE_OBJECTID ||
575 root_objectid == BTRFS_UUID_TREE_OBJECTID ||
576 root_objectid == BTRFS_QUOTA_TREE_OBJECTID)
575 return 1; 577 return 1;
576 return 0; 578 return 0;
577} 579}
@@ -1264,10 +1266,10 @@ static int __must_check __add_reloc_root(struct btrfs_root *root)
1264} 1266}
1265 1267
1266/* 1268/*
1267 * helper to update/delete the 'address of tree root -> reloc tree' 1269 * helper to delete the 'address of tree root -> reloc tree'
1268 * mapping 1270 * mapping
1269 */ 1271 */
1270static int __update_reloc_root(struct btrfs_root *root, int del) 1272static void __del_reloc_root(struct btrfs_root *root)
1271{ 1273{
1272 struct rb_node *rb_node; 1274 struct rb_node *rb_node;
1273 struct mapping_node *node = NULL; 1275 struct mapping_node *node = NULL;
@@ -1275,7 +1277,7 @@ static int __update_reloc_root(struct btrfs_root *root, int del)
1275 1277
1276 spin_lock(&rc->reloc_root_tree.lock); 1278 spin_lock(&rc->reloc_root_tree.lock);
1277 rb_node = tree_search(&rc->reloc_root_tree.rb_root, 1279 rb_node = tree_search(&rc->reloc_root_tree.rb_root,
1278 root->commit_root->start); 1280 root->node->start);
1279 if (rb_node) { 1281 if (rb_node) {
1280 node = rb_entry(rb_node, struct mapping_node, rb_node); 1282 node = rb_entry(rb_node, struct mapping_node, rb_node);
1281 rb_erase(&node->rb_node, &rc->reloc_root_tree.rb_root); 1283 rb_erase(&node->rb_node, &rc->reloc_root_tree.rb_root);
@@ -1283,23 +1285,45 @@ static int __update_reloc_root(struct btrfs_root *root, int del)
1283 spin_unlock(&rc->reloc_root_tree.lock); 1285 spin_unlock(&rc->reloc_root_tree.lock);
1284 1286
1285 if (!node) 1287 if (!node)
1286 return 0; 1288 return;
1287 BUG_ON((struct btrfs_root *)node->data != root); 1289 BUG_ON((struct btrfs_root *)node->data != root);
1288 1290
1289 if (!del) { 1291 spin_lock(&root->fs_info->trans_lock);
1290 spin_lock(&rc->reloc_root_tree.lock); 1292 list_del_init(&root->root_list);
1291 node->bytenr = root->node->start; 1293 spin_unlock(&root->fs_info->trans_lock);
1292 rb_node = tree_insert(&rc->reloc_root_tree.rb_root, 1294 kfree(node);
1293 node->bytenr, &node->rb_node); 1295}
1294 spin_unlock(&rc->reloc_root_tree.lock); 1296
1295 if (rb_node) 1297/*
1296 backref_tree_panic(rb_node, -EEXIST, node->bytenr); 1298 * helper to update the 'address of tree root -> reloc tree'
1297 } else { 1299 * mapping
1298 spin_lock(&root->fs_info->trans_lock); 1300 */
1299 list_del_init(&root->root_list); 1301static int __update_reloc_root(struct btrfs_root *root, u64 new_bytenr)
1300 spin_unlock(&root->fs_info->trans_lock); 1302{
1301 kfree(node); 1303 struct rb_node *rb_node;
1304 struct mapping_node *node = NULL;
1305 struct reloc_control *rc = root->fs_info->reloc_ctl;
1306
1307 spin_lock(&rc->reloc_root_tree.lock);
1308 rb_node = tree_search(&rc->reloc_root_tree.rb_root,
1309 root->node->start);
1310 if (rb_node) {
1311 node = rb_entry(rb_node, struct mapping_node, rb_node);
1312 rb_erase(&node->rb_node, &rc->reloc_root_tree.rb_root);
1302 } 1313 }
1314 spin_unlock(&rc->reloc_root_tree.lock);
1315
1316 if (!node)
1317 return 0;
1318 BUG_ON((struct btrfs_root *)node->data != root);
1319
1320 spin_lock(&rc->reloc_root_tree.lock);
1321 node->bytenr = new_bytenr;
1322 rb_node = tree_insert(&rc->reloc_root_tree.rb_root,
1323 node->bytenr, &node->rb_node);
1324 spin_unlock(&rc->reloc_root_tree.lock);
1325 if (rb_node)
1326 backref_tree_panic(rb_node, -EEXIST, node->bytenr);
1303 return 0; 1327 return 0;
1304} 1328}
1305 1329
@@ -1420,7 +1444,6 @@ int btrfs_update_reloc_root(struct btrfs_trans_handle *trans,
1420{ 1444{
1421 struct btrfs_root *reloc_root; 1445 struct btrfs_root *reloc_root;
1422 struct btrfs_root_item *root_item; 1446 struct btrfs_root_item *root_item;
1423 int del = 0;
1424 int ret; 1447 int ret;
1425 1448
1426 if (!root->reloc_root) 1449 if (!root->reloc_root)
@@ -1432,11 +1455,9 @@ int btrfs_update_reloc_root(struct btrfs_trans_handle *trans,
1432 if (root->fs_info->reloc_ctl->merge_reloc_tree && 1455 if (root->fs_info->reloc_ctl->merge_reloc_tree &&
1433 btrfs_root_refs(root_item) == 0) { 1456 btrfs_root_refs(root_item) == 0) {
1434 root->reloc_root = NULL; 1457 root->reloc_root = NULL;
1435 del = 1; 1458 __del_reloc_root(reloc_root);
1436 } 1459 }
1437 1460
1438 __update_reloc_root(reloc_root, del);
1439
1440 if (reloc_root->commit_root != reloc_root->node) { 1461 if (reloc_root->commit_root != reloc_root->node) {
1441 btrfs_set_root_node(root_item, reloc_root->node); 1462 btrfs_set_root_node(root_item, reloc_root->node);
1442 free_extent_buffer(reloc_root->commit_root); 1463 free_extent_buffer(reloc_root->commit_root);
@@ -2287,7 +2308,7 @@ void free_reloc_roots(struct list_head *list)
2287 while (!list_empty(list)) { 2308 while (!list_empty(list)) {
2288 reloc_root = list_entry(list->next, struct btrfs_root, 2309 reloc_root = list_entry(list->next, struct btrfs_root,
2289 root_list); 2310 root_list);
2290 __update_reloc_root(reloc_root, 1); 2311 __del_reloc_root(reloc_root);
2291 free_extent_buffer(reloc_root->node); 2312 free_extent_buffer(reloc_root->node);
2292 free_extent_buffer(reloc_root->commit_root); 2313 free_extent_buffer(reloc_root->commit_root);
2293 kfree(reloc_root); 2314 kfree(reloc_root);
@@ -2332,7 +2353,7 @@ again:
2332 2353
2333 ret = merge_reloc_root(rc, root); 2354 ret = merge_reloc_root(rc, root);
2334 if (ret) { 2355 if (ret) {
2335 __update_reloc_root(reloc_root, 1); 2356 __del_reloc_root(reloc_root);
2336 free_extent_buffer(reloc_root->node); 2357 free_extent_buffer(reloc_root->node);
2337 free_extent_buffer(reloc_root->commit_root); 2358 free_extent_buffer(reloc_root->commit_root);
2338 kfree(reloc_root); 2359 kfree(reloc_root);
@@ -2388,6 +2409,13 @@ out:
2388 btrfs_std_error(root->fs_info, ret); 2409 btrfs_std_error(root->fs_info, ret);
2389 if (!list_empty(&reloc_roots)) 2410 if (!list_empty(&reloc_roots))
2390 free_reloc_roots(&reloc_roots); 2411 free_reloc_roots(&reloc_roots);
2412
2413 /* new reloc root may be added */
2414 mutex_lock(&root->fs_info->reloc_mutex);
2415 list_splice_init(&rc->reloc_roots, &reloc_roots);
2416 mutex_unlock(&root->fs_info->reloc_mutex);
2417 if (!list_empty(&reloc_roots))
2418 free_reloc_roots(&reloc_roots);
2391 } 2419 }
2392 2420
2393 BUG_ON(!RB_EMPTY_ROOT(&rc->reloc_root_tree.rb_root)); 2421 BUG_ON(!RB_EMPTY_ROOT(&rc->reloc_root_tree.rb_root));
@@ -4522,6 +4550,11 @@ int btrfs_reloc_cow_block(struct btrfs_trans_handle *trans,
4522 BUG_ON(rc->stage == UPDATE_DATA_PTRS && 4550 BUG_ON(rc->stage == UPDATE_DATA_PTRS &&
4523 root->root_key.objectid == BTRFS_DATA_RELOC_TREE_OBJECTID); 4551 root->root_key.objectid == BTRFS_DATA_RELOC_TREE_OBJECTID);
4524 4552
4553 if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
4554 if (buf == root->node)
4555 __update_reloc_root(root, cow->start);
4556 }
4557
4525 level = btrfs_header_level(buf); 4558 level = btrfs_header_level(buf);
4526 if (btrfs_header_generation(buf) <= 4559 if (btrfs_header_generation(buf) <=
4527 btrfs_root_last_snapshot(&root->root_item)) 4560 btrfs_root_last_snapshot(&root->root_item))
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 6837fe87f3a6..945d1db98f26 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -4723,8 +4723,8 @@ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_)
4723 } 4723 }
4724 4724
4725 if (!access_ok(VERIFY_READ, arg->clone_sources, 4725 if (!access_ok(VERIFY_READ, arg->clone_sources,
4726 sizeof(*arg->clone_sources * 4726 sizeof(*arg->clone_sources) *
4727 arg->clone_sources_count))) { 4727 arg->clone_sources_count)) {
4728 ret = -EFAULT; 4728 ret = -EFAULT;
4729 goto out; 4729 goto out;
4730 } 4730 }
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 2d8ac1bf0cf9..d71a11d13dfa 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -432,7 +432,6 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
432 } else { 432 } else {
433 printk(KERN_INFO "btrfs: setting nodatacow\n"); 433 printk(KERN_INFO "btrfs: setting nodatacow\n");
434 } 434 }
435 info->compress_type = BTRFS_COMPRESS_NONE;
436 btrfs_clear_opt(info->mount_opt, COMPRESS); 435 btrfs_clear_opt(info->mount_opt, COMPRESS);
437 btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS); 436 btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS);
438 btrfs_set_opt(info->mount_opt, NODATACOW); 437 btrfs_set_opt(info->mount_opt, NODATACOW);
@@ -461,7 +460,6 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
461 btrfs_set_fs_incompat(info, COMPRESS_LZO); 460 btrfs_set_fs_incompat(info, COMPRESS_LZO);
462 } else if (strncmp(args[0].from, "no", 2) == 0) { 461 } else if (strncmp(args[0].from, "no", 2) == 0) {
463 compress_type = "no"; 462 compress_type = "no";
464 info->compress_type = BTRFS_COMPRESS_NONE;
465 btrfs_clear_opt(info->mount_opt, COMPRESS); 463 btrfs_clear_opt(info->mount_opt, COMPRESS);
466 btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS); 464 btrfs_clear_opt(info->mount_opt, FORCE_COMPRESS);
467 compress_force = false; 465 compress_force = false;
@@ -474,9 +472,10 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
474 btrfs_set_opt(info->mount_opt, FORCE_COMPRESS); 472 btrfs_set_opt(info->mount_opt, FORCE_COMPRESS);
475 pr_info("btrfs: force %s compression\n", 473 pr_info("btrfs: force %s compression\n",
476 compress_type); 474 compress_type);
477 } else 475 } else if (btrfs_test_opt(root, COMPRESS)) {
478 pr_info("btrfs: use %s compression\n", 476 pr_info("btrfs: use %s compression\n",
479 compress_type); 477 compress_type);
478 }
480 break; 479 break;
481 case Opt_ssd: 480 case Opt_ssd:
482 printk(KERN_INFO "btrfs: use ssd allocation scheme\n"); 481 printk(KERN_INFO "btrfs: use ssd allocation scheme\n");
diff --git a/fs/dcache.c b/fs/dcache.c
index 4bdb300b16e2..6055d61811d3 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -192,7 +192,7 @@ static inline int dentry_string_cmp(const unsigned char *cs, const unsigned char
192 if (!tcount) 192 if (!tcount)
193 return 0; 193 return 0;
194 } 194 }
195 mask = ~(~0ul << tcount*8); 195 mask = bytemask_from_count(tcount);
196 return unlikely(!!((a ^ b) & mask)); 196 return unlikely(!!((a ^ b) & mask));
197} 197}
198 198
diff --git a/fs/namei.c b/fs/namei.c
index c53d3a9547f9..3531deebad30 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1598,11 +1598,6 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
1598 * do a "get_unaligned()" if this helps and is sufficiently 1598 * do a "get_unaligned()" if this helps and is sufficiently
1599 * fast. 1599 * fast.
1600 * 1600 *
1601 * - Little-endian machines (so that we can generate the mask
1602 * of low bytes efficiently). Again, we *could* do a byte
1603 * swapping load on big-endian architectures if that is not
1604 * expensive enough to make the optimization worthless.
1605 *
1606 * - non-CONFIG_DEBUG_PAGEALLOC configurations (so that we 1601 * - non-CONFIG_DEBUG_PAGEALLOC configurations (so that we
1607 * do not trap on the (extremely unlikely) case of a page 1602 * do not trap on the (extremely unlikely) case of a page
1608 * crossing operation. 1603 * crossing operation.
@@ -1646,7 +1641,7 @@ unsigned int full_name_hash(const unsigned char *name, unsigned int len)
1646 if (!len) 1641 if (!len)
1647 goto done; 1642 goto done;
1648 } 1643 }
1649 mask = ~(~0ul << len*8); 1644 mask = bytemask_from_count(len);
1650 hash += mask & a; 1645 hash += mask & a;
1651done: 1646done:
1652 return fold_hash(hash); 1647 return fold_hash(hash);
diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
index 9186c7ce0b14..b6af150c96b8 100644
--- a/fs/nfsd/nfscache.c
+++ b/fs/nfsd/nfscache.c
@@ -132,6 +132,13 @@ nfsd_reply_cache_alloc(void)
132} 132}
133 133
134static void 134static void
135nfsd_reply_cache_unhash(struct svc_cacherep *rp)
136{
137 hlist_del_init(&rp->c_hash);
138 list_del_init(&rp->c_lru);
139}
140
141static void
135nfsd_reply_cache_free_locked(struct svc_cacherep *rp) 142nfsd_reply_cache_free_locked(struct svc_cacherep *rp)
136{ 143{
137 if (rp->c_type == RC_REPLBUFF && rp->c_replvec.iov_base) { 144 if (rp->c_type == RC_REPLBUFF && rp->c_replvec.iov_base) {
@@ -417,7 +424,7 @@ nfsd_cache_lookup(struct svc_rqst *rqstp)
417 rp = list_first_entry(&lru_head, struct svc_cacherep, c_lru); 424 rp = list_first_entry(&lru_head, struct svc_cacherep, c_lru);
418 if (nfsd_cache_entry_expired(rp) || 425 if (nfsd_cache_entry_expired(rp) ||
419 num_drc_entries >= max_drc_entries) { 426 num_drc_entries >= max_drc_entries) {
420 lru_put_end(rp); 427 nfsd_reply_cache_unhash(rp);
421 prune_cache_entries(); 428 prune_cache_entries();
422 goto search_cache; 429 goto search_cache;
423 } 430 }
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index 28955d4b7218..124fc43c7090 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -292,16 +292,20 @@ proc_reg_get_unmapped_area(struct file *file, unsigned long orig_addr,
292{ 292{
293 struct proc_dir_entry *pde = PDE(file_inode(file)); 293 struct proc_dir_entry *pde = PDE(file_inode(file));
294 unsigned long rv = -EIO; 294 unsigned long rv = -EIO;
295 unsigned long (*get_area)(struct file *, unsigned long, unsigned long, 295
296 unsigned long, unsigned long) = NULL;
297 if (use_pde(pde)) { 296 if (use_pde(pde)) {
297 typeof(proc_reg_get_unmapped_area) *get_area;
298
299 get_area = pde->proc_fops->get_unmapped_area;
298#ifdef CONFIG_MMU 300#ifdef CONFIG_MMU
299 get_area = current->mm->get_unmapped_area; 301 if (!get_area)
302 get_area = current->mm->get_unmapped_area;
300#endif 303#endif
301 if (pde->proc_fops->get_unmapped_area) 304
302 get_area = pde->proc_fops->get_unmapped_area;
303 if (get_area) 305 if (get_area)
304 rv = get_area(file, orig_addr, len, pgoff, flags); 306 rv = get_area(file, orig_addr, len, pgoff, flags);
307 else
308 rv = orig_addr;
305 unuse_pde(pde); 309 unuse_pde(pde);
306 } 310 }
307 return rv; 311 return rv;
diff --git a/fs/xfs/xfs_discard.c b/fs/xfs/xfs_discard.c
index 8367d6dc18c9..4f11ef011139 100644
--- a/fs/xfs/xfs_discard.c
+++ b/fs/xfs/xfs_discard.c
@@ -157,7 +157,7 @@ xfs_ioc_trim(
157 struct xfs_mount *mp, 157 struct xfs_mount *mp,
158 struct fstrim_range __user *urange) 158 struct fstrim_range __user *urange)
159{ 159{
160 struct request_queue *q = mp->m_ddev_targp->bt_bdev->bd_disk->queue; 160 struct request_queue *q = bdev_get_queue(mp->m_ddev_targp->bt_bdev);
161 unsigned int granularity = q->limits.discard_granularity; 161 unsigned int granularity = q->limits.discard_granularity;
162 struct fstrim_range range; 162 struct fstrim_range range;
163 xfs_daddr_t start, end, minlen; 163 xfs_daddr_t start, end, minlen;
@@ -180,7 +180,8 @@ xfs_ioc_trim(
180 * matter as trimming blocks is an advisory interface. 180 * matter as trimming blocks is an advisory interface.
181 */ 181 */
182 if (range.start >= XFS_FSB_TO_B(mp, mp->m_sb.sb_dblocks) || 182 if (range.start >= XFS_FSB_TO_B(mp, mp->m_sb.sb_dblocks) ||
183 range.minlen > XFS_FSB_TO_B(mp, XFS_ALLOC_AG_MAX_USABLE(mp))) 183 range.minlen > XFS_FSB_TO_B(mp, XFS_ALLOC_AG_MAX_USABLE(mp)) ||
184 range.len < mp->m_sb.sb_blocksize)
184 return -XFS_ERROR(EINVAL); 185 return -XFS_ERROR(EINVAL);
185 186
186 start = BTOBB(range.start); 187 start = BTOBB(range.start);
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index a6e54b3319bd..02fb943cbf22 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -220,6 +220,8 @@ xfs_growfs_data_private(
220 */ 220 */
221 nfree = 0; 221 nfree = 0;
222 for (agno = nagcount - 1; agno >= oagcount; agno--, new -= agsize) { 222 for (agno = nagcount - 1; agno >= oagcount; agno--, new -= agsize) {
223 __be32 *agfl_bno;
224
223 /* 225 /*
224 * AG freespace header block 226 * AG freespace header block
225 */ 227 */
@@ -279,8 +281,10 @@ xfs_growfs_data_private(
279 agfl->agfl_seqno = cpu_to_be32(agno); 281 agfl->agfl_seqno = cpu_to_be32(agno);
280 uuid_copy(&agfl->agfl_uuid, &mp->m_sb.sb_uuid); 282 uuid_copy(&agfl->agfl_uuid, &mp->m_sb.sb_uuid);
281 } 283 }
284
285 agfl_bno = XFS_BUF_TO_AGFL_BNO(mp, bp);
282 for (bucket = 0; bucket < XFS_AGFL_SIZE(mp); bucket++) 286 for (bucket = 0; bucket < XFS_AGFL_SIZE(mp); bucket++)
283 agfl->agfl_bno[bucket] = cpu_to_be32(NULLAGBLOCK); 287 agfl_bno[bucket] = cpu_to_be32(NULLAGBLOCK);
284 288
285 error = xfs_bwrite(bp); 289 error = xfs_bwrite(bp);
286 xfs_buf_relse(bp); 290 xfs_buf_relse(bp);
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 4d613401a5e0..33ad9a77791f 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -442,7 +442,8 @@ xfs_attrlist_by_handle(
442 return -XFS_ERROR(EPERM); 442 return -XFS_ERROR(EPERM);
443 if (copy_from_user(&al_hreq, arg, sizeof(xfs_fsop_attrlist_handlereq_t))) 443 if (copy_from_user(&al_hreq, arg, sizeof(xfs_fsop_attrlist_handlereq_t)))
444 return -XFS_ERROR(EFAULT); 444 return -XFS_ERROR(EFAULT);
445 if (al_hreq.buflen > XATTR_LIST_MAX) 445 if (al_hreq.buflen < sizeof(struct attrlist) ||
446 al_hreq.buflen > XATTR_LIST_MAX)
446 return -XFS_ERROR(EINVAL); 447 return -XFS_ERROR(EINVAL);
447 448
448 /* 449 /*
diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c
index e8fb1231db81..a7992f8de9d3 100644
--- a/fs/xfs/xfs_ioctl32.c
+++ b/fs/xfs/xfs_ioctl32.c
@@ -356,7 +356,8 @@ xfs_compat_attrlist_by_handle(
356 if (copy_from_user(&al_hreq, arg, 356 if (copy_from_user(&al_hreq, arg,
357 sizeof(compat_xfs_fsop_attrlist_handlereq_t))) 357 sizeof(compat_xfs_fsop_attrlist_handlereq_t)))
358 return -XFS_ERROR(EFAULT); 358 return -XFS_ERROR(EFAULT);
359 if (al_hreq.buflen > XATTR_LIST_MAX) 359 if (al_hreq.buflen < sizeof(struct attrlist) ||
360 al_hreq.buflen > XATTR_LIST_MAX)
360 return -XFS_ERROR(EINVAL); 361 return -XFS_ERROR(EINVAL);
361 362
362 /* 363 /*
diff --git a/include/asm-generic/word-at-a-time.h b/include/asm-generic/word-at-a-time.h
index 3f21f1b72e45..d3909effd725 100644
--- a/include/asm-generic/word-at-a-time.h
+++ b/include/asm-generic/word-at-a-time.h
@@ -49,4 +49,12 @@ static inline bool has_zero(unsigned long val, unsigned long *data, const struct
49 return (val + c->high_bits) & ~rhs; 49 return (val + c->high_bits) & ~rhs;
50} 50}
51 51
52#ifndef zero_bytemask
53#ifdef CONFIG_64BIT
54#define zero_bytemask(mask) (~0ul << fls64(mask))
55#else
56#define zero_bytemask(mask) (~0ul << fls(mask))
57#endif /* CONFIG_64BIT */
58#endif /* zero_bytemask */
59
52#endif /* _ASM_WORD_AT_A_TIME_H */ 60#endif /* _ASM_WORD_AT_A_TIME_H */
diff --git a/include/crypto/scatterwalk.h b/include/crypto/scatterwalk.h
index 64ebede184f1..6a626a507b8c 100644
--- a/include/crypto/scatterwalk.h
+++ b/include/crypto/scatterwalk.h
@@ -44,7 +44,7 @@ static inline struct scatterlist *scatterwalk_sg_next(struct scatterlist *sg)
44 if (sg_is_last(sg)) 44 if (sg_is_last(sg))
45 return NULL; 45 return NULL;
46 46
47 return (++sg)->length ? sg : (void *)sg_page(sg); 47 return (++sg)->length ? sg : sg_chain_ptr(sg);
48} 48}
49 49
50static inline void scatterwalk_crypto_chain(struct scatterlist *head, 50static inline void scatterwalk_crypto_chain(struct scatterlist *head,
diff --git a/include/dt-bindings/clock/r8a7790-clock.h b/include/dt-bindings/clock/r8a7790-clock.h
new file mode 100644
index 000000000000..420f0b00ae1e
--- /dev/null
+++ b/include/dt-bindings/clock/r8a7790-clock.h
@@ -0,0 +1,100 @@
1/*
2 * Copyright 2013 Ideas On Board SPRL
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
10#ifndef __DT_BINDINGS_CLOCK_R8A7790_H__
11#define __DT_BINDINGS_CLOCK_R8A7790_H__
12
13/* CPG */
14#define R8A7790_CLK_MAIN 0
15#define R8A7790_CLK_PLL0 1
16#define R8A7790_CLK_PLL1 2
17#define R8A7790_CLK_PLL3 3
18#define R8A7790_CLK_LB 4
19#define R8A7790_CLK_QSPI 5
20#define R8A7790_CLK_SDH 6
21#define R8A7790_CLK_SD0 7
22#define R8A7790_CLK_SD1 8
23#define R8A7790_CLK_Z 9
24
25/* MSTP1 */
26#define R8A7790_CLK_TMU1 11
27#define R8A7790_CLK_TMU3 21
28#define R8A7790_CLK_TMU2 22
29#define R8A7790_CLK_CMT0 24
30#define R8A7790_CLK_TMU0 25
31#define R8A7790_CLK_VSP1_DU1 27
32#define R8A7790_CLK_VSP1_DU0 28
33#define R8A7790_CLK_VSP1_RT 30
34#define R8A7790_CLK_VSP1_SY 31
35
36/* MSTP2 */
37#define R8A7790_CLK_SCIFA2 2
38#define R8A7790_CLK_SCIFA1 3
39#define R8A7790_CLK_SCIFA0 4
40#define R8A7790_CLK_SCIFB0 6
41#define R8A7790_CLK_SCIFB1 7
42#define R8A7790_CLK_SCIFB2 16
43#define R8A7790_CLK_SYS_DMAC0 18
44#define R8A7790_CLK_SYS_DMAC1 19
45
46/* MSTP3 */
47#define R8A7790_CLK_TPU0 4
48#define R8A7790_CLK_MMCIF1 5
49#define R8A7790_CLK_SDHI3 11
50#define R8A7790_CLK_SDHI2 12
51#define R8A7790_CLK_SDHI1 13
52#define R8A7790_CLK_SDHI0 14
53#define R8A7790_CLK_MMCIF0 15
54#define R8A7790_CLK_SSUSB 28
55#define R8A7790_CLK_CMT1 29
56#define R8A7790_CLK_USBDMAC0 30
57#define R8A7790_CLK_USBDMAC1 31
58
59/* MSTP5 */
60#define R8A7790_CLK_THERMAL 22
61#define R8A7790_CLK_PWM 23
62
63/* MSTP7 */
64#define R8A7790_CLK_EHCI 3
65#define R8A7790_CLK_HSUSB 4
66#define R8A7790_CLK_HSCIF1 16
67#define R8A7790_CLK_HSCIF0 17
68#define R8A7790_CLK_SCIF1 20
69#define R8A7790_CLK_SCIF0 21
70#define R8A7790_CLK_DU2 22
71#define R8A7790_CLK_DU1 23
72#define R8A7790_CLK_DU0 24
73#define R8A7790_CLK_LVDS1 25
74#define R8A7790_CLK_LVDS0 26
75
76/* MSTP8 */
77#define R8A7790_CLK_VIN3 8
78#define R8A7790_CLK_VIN2 9
79#define R8A7790_CLK_VIN1 10
80#define R8A7790_CLK_VIN0 11
81#define R8A7790_CLK_ETHER 13
82#define R8A7790_CLK_SATA1 14
83#define R8A7790_CLK_SATA0 15
84
85/* MSTP9 */
86#define R8A7790_CLK_GPIO5 7
87#define R8A7790_CLK_GPIO4 8
88#define R8A7790_CLK_GPIO3 9
89#define R8A7790_CLK_GPIO2 10
90#define R8A7790_CLK_GPIO1 11
91#define R8A7790_CLK_GPIO0 12
92#define R8A7790_CLK_RCAN1 15
93#define R8A7790_CLK_RCAN0 16
94#define R8A7790_CLK_IICDVFS 26
95#define R8A7790_CLK_I2C3 28
96#define R8A7790_CLK_I2C2 29
97#define R8A7790_CLK_I2C1 30
98#define R8A7790_CLK_I2C0 31
99
100#endif /* __DT_BINDINGS_CLOCK_R8A7790_H__ */
diff --git a/include/dt-bindings/clock/r8a7791-clock.h b/include/dt-bindings/clock/r8a7791-clock.h
new file mode 100644
index 000000000000..df1715b77f96
--- /dev/null
+++ b/include/dt-bindings/clock/r8a7791-clock.h
@@ -0,0 +1,105 @@
1/*
2 * Copyright 2013 Ideas On Board SPRL
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
10#ifndef __DT_BINDINGS_CLOCK_R8A7791_H__
11#define __DT_BINDINGS_CLOCK_R8A7791_H__
12
13/* CPG */
14#define R8A7791_CLK_MAIN 0
15#define R8A7791_CLK_PLL0 1
16#define R8A7791_CLK_PLL1 2
17#define R8A7791_CLK_PLL3 3
18#define R8A7791_CLK_LB 4
19#define R8A7791_CLK_QSPI 5
20#define R8A7791_CLK_SDH 6
21#define R8A7791_CLK_SD0 7
22#define R8A7791_CLK_Z 8
23
24/* MSTP1 */
25#define R8A7791_CLK_TMU1 11
26#define R8A7791_CLK_TMU3 21
27#define R8A7791_CLK_TMU2 22
28#define R8A7791_CLK_CMT0 24
29#define R8A7791_CLK_TMU0 25
30#define R8A7791_CLK_VSP1_DU1 27
31#define R8A7791_CLK_VSP1_DU0 28
32#define R8A7791_CLK_VSP1_SY 31
33
34/* MSTP2 */
35#define R8A7791_CLK_SCIFA2 2
36#define R8A7791_CLK_SCIFA1 3
37#define R8A7791_CLK_SCIFA0 4
38#define R8A7791_CLK_SCIFB0 6
39#define R8A7791_CLK_SCIFB1 7
40#define R8A7791_CLK_SCIFB2 16
41#define R8A7791_CLK_DMAC 18
42
43/* MSTP3 */
44#define R8A7791_CLK_TPU0 4
45#define R8A7791_CLK_SDHI2 11
46#define R8A7791_CLK_SDHI1 12
47#define R8A7791_CLK_SDHI0 14
48#define R8A7791_CLK_MMCIF0 15
49#define R8A7791_CLK_SSUSB 28
50#define R8A7791_CLK_CMT1 29
51#define R8A7791_CLK_USBDMAC0 30
52#define R8A7791_CLK_USBDMAC1 31
53
54/* MSTP5 */
55#define R8A7791_CLK_THERMAL 22
56#define R8A7791_CLK_PWM 23
57
58/* MSTP7 */
59#define R8A7791_CLK_HSUSB 4
60#define R8A7791_CLK_HSCIF2 13
61#define R8A7791_CLK_SCIF5 14
62#define R8A7791_CLK_SCIF4 15
63#define R8A7791_CLK_HSCIF1 16
64#define R8A7791_CLK_HSCIF0 17
65#define R8A7791_CLK_SCIF3 18
66#define R8A7791_CLK_SCIF2 19
67#define R8A7791_CLK_SCIF1 20
68#define R8A7791_CLK_SCIF0 21
69#define R8A7791_CLK_DU1 23
70#define R8A7791_CLK_DU0 24
71#define R8A7791_CLK_LVDS0 26
72
73/* MSTP8 */
74#define R8A7791_CLK_VIN2 9
75#define R8A7791_CLK_VIN1 10
76#define R8A7791_CLK_VIN0 11
77#define R8A7791_CLK_ETHER 13
78#define R8A7791_CLK_SATA1 14
79#define R8A7791_CLK_SATA0 15
80
81/* MSTP9 */
82#define R8A7791_CLK_GPIO7 4
83#define R8A7791_CLK_GPIO6 5
84#define R8A7791_CLK_GPIO5 7
85#define R8A7791_CLK_GPIO4 8
86#define R8A7791_CLK_GPIO3 9
87#define R8A7791_CLK_GPIO2 10
88#define R8A7791_CLK_GPIO1 11
89#define R8A7791_CLK_GPIO0 12
90#define R8A7791_CLK_RCAN1 15
91#define R8A7791_CLK_RCAN0 16
92#define R8A7791_CLK_I2C5 25
93#define R8A7791_CLK_IICDVFS 26
94#define R8A7791_CLK_I2C4 27
95#define R8A7791_CLK_I2C3 28
96#define R8A7791_CLK_I2C2 29
97#define R8A7791_CLK_I2C1 30
98#define R8A7791_CLK_I2C0 31
99
100/* MSTP11 */
101#define R8A7791_CLK_SCIFA3 6
102#define R8A7791_CLK_SCIFA4 7
103#define R8A7791_CLK_SCIFA5 8
104
105#endif /* __DT_BINDINGS_CLOCK_R8A7791_H__ */
diff --git a/include/dt-bindings/clock/tegra114-car.h b/include/dt-bindings/clock/tegra114-car.h
index 614aec417902..6d0d8d8ef31e 100644
--- a/include/dt-bindings/clock/tegra114-car.h
+++ b/include/dt-bindings/clock/tegra114-car.h
@@ -37,10 +37,10 @@
37#define TEGRA114_CLK_I2S2 18 37#define TEGRA114_CLK_I2S2 18
38#define TEGRA114_CLK_EPP 19 38#define TEGRA114_CLK_EPP 19
39/* 20 (register bit affects vi and vi_sensor) */ 39/* 20 (register bit affects vi and vi_sensor) */
40#define TEGRA114_CLK_GR_2D 21 40#define TEGRA114_CLK_GR2D 21
41#define TEGRA114_CLK_USBD 22 41#define TEGRA114_CLK_USBD 22
42#define TEGRA114_CLK_ISP 23 42#define TEGRA114_CLK_ISP 23
43#define TEGRA114_CLK_GR_3D 24 43#define TEGRA114_CLK_GR3D 24
44/* 25 */ 44/* 25 */
45#define TEGRA114_CLK_DISP2 26 45#define TEGRA114_CLK_DISP2 26
46#define TEGRA114_CLK_DISP1 27 46#define TEGRA114_CLK_DISP1 27
@@ -289,8 +289,8 @@
289#define TEGRA114_CLK_PCLK 261 289#define TEGRA114_CLK_PCLK 261
290#define TEGRA114_CLK_CCLK_G 262 290#define TEGRA114_CLK_CCLK_G 262
291#define TEGRA114_CLK_CCLK_LP 263 291#define TEGRA114_CLK_CCLK_LP 263
292/* 264 */ 292#define TEGRA114_CLK_DFLL_REF 264
293/* 265 */ 293#define TEGRA114_CLK_DFLL_SOC 265
294/* 266 */ 294/* 266 */
295/* 267 */ 295/* 267 */
296/* 268 */ 296/* 268 */
diff --git a/include/dt-bindings/clock/tegra124-car.h b/include/dt-bindings/clock/tegra124-car.h
new file mode 100644
index 000000000000..a1116a3b54ef
--- /dev/null
+++ b/include/dt-bindings/clock/tegra124-car.h
@@ -0,0 +1,341 @@
1/*
2 * This header provides constants for binding nvidia,tegra124-car.
3 *
4 * The first 192 clocks are numbered to match the bits in the CAR's CLK_OUT_ENB
5 * registers. These IDs often match those in the CAR's RST_DEVICES registers,
6 * but not in all cases. Some bits in CLK_OUT_ENB affect multiple clocks. In
7 * this case, those clocks are assigned IDs above 185 in order to highlight
8 * this issue. Implementations that interpret these clock IDs as bit values
9 * within the CLK_OUT_ENB or RST_DEVICES registers should be careful to
10 * explicitly handle these special cases.
11 *
12 * The balance of the clocks controlled by the CAR are assigned IDs of 185 and
13 * above.
14 */
15
16#ifndef _DT_BINDINGS_CLOCK_TEGRA124_CAR_H
17#define _DT_BINDINGS_CLOCK_TEGRA124_CAR_H
18
19/* 0 */
20/* 1 */
21/* 2 */
22#define TEGRA124_CLK_ISPB 3
23#define TEGRA124_CLK_RTC 4
24#define TEGRA124_CLK_TIMER 5
25#define TEGRA124_CLK_UARTA 6
26/* 7 (register bit affects uartb and vfir) */
27/* 8 */
28#define TEGRA124_CLK_SDMMC2 9
29/* 10 (register bit affects spdif_in and spdif_out) */
30#define TEGRA124_CLK_I2S1 11
31#define TEGRA124_CLK_I2C1 12
32#define TEGRA124_CLK_NDFLASH 13
33#define TEGRA124_CLK_SDMMC1 14
34#define TEGRA124_CLK_SDMMC4 15
35/* 16 */
36#define TEGRA124_CLK_PWM 17
37#define TEGRA124_CLK_I2S2 18
38/* 20 (register bit affects vi and vi_sensor) */
39#define TEGRA124_CLK_GR_2D 21
40#define TEGRA124_CLK_USBD 22
41#define TEGRA124_CLK_ISP 23
42#define TEGRA124_CLK_GR_3D 24
43/* 25 */
44#define TEGRA124_CLK_DISP2 26
45#define TEGRA124_CLK_DISP1 27
46#define TEGRA124_CLK_HOST1X 28
47#define TEGRA124_CLK_VCP 29
48#define TEGRA124_CLK_I2S0 30
49/* 31 */
50
51/* 32 */
52/* 33 */
53#define TEGRA124_CLK_APBDMA 34
54/* 35 */
55#define TEGRA124_CLK_KBC 36
56/* 37 */
57/* 38 */
58/* 39 (register bit affects fuse and fuse_burn) */
59#define TEGRA124_CLK_KFUSE 40
60#define TEGRA124_CLK_SBC1 41
61#define TEGRA124_CLK_NOR 42
62/* 43 */
63#define TEGRA124_CLK_SBC2 44
64/* 45 */
65#define TEGRA124_CLK_SBC3 46
66#define TEGRA124_CLK_I2C5 47
67#define TEGRA124_CLK_DSIA 48
68/* 49 */
69#define TEGRA124_CLK_MIPI 50
70#define TEGRA124_CLK_HDMI 51
71#define TEGRA124_CLK_CSI 52
72/* 53 */
73#define TEGRA124_CLK_I2C2 54
74#define TEGRA124_CLK_UARTC 55
75#define TEGRA124_CLK_MIPI_CAL 56
76#define TEGRA124_CLK_EMC 57
77#define TEGRA124_CLK_USB2 58
78#define TEGRA124_CLK_USB3 59
79/* 60 */
80#define TEGRA124_CLK_VDE 61
81#define TEGRA124_CLK_BSEA 62
82#define TEGRA124_CLK_BSEV 63
83
84/* 64 */
85#define TEGRA124_CLK_UARTD 65
86#define TEGRA124_CLK_UARTE 66
87#define TEGRA124_CLK_I2C3 67
88#define TEGRA124_CLK_SBC4 68
89#define TEGRA124_CLK_SDMMC3 69
90#define TEGRA124_CLK_PCIE 70
91#define TEGRA124_CLK_OWR 71
92#define TEGRA124_CLK_AFI 72
93#define TEGRA124_CLK_CSITE 73
94/* 74 */
95/* 75 */
96#define TEGRA124_CLK_LA 76
97#define TEGRA124_CLK_TRACE 77
98#define TEGRA124_CLK_SOC_THERM 78
99#define TEGRA124_CLK_DTV 79
100#define TEGRA124_CLK_NDSPEED 80
101#define TEGRA124_CLK_I2CSLOW 81
102#define TEGRA124_CLK_DSIB 82
103#define TEGRA124_CLK_TSEC 83
104/* 84 */
105/* 85 */
106/* 86 */
107/* 87 */
108/* 88 */
109#define TEGRA124_CLK_XUSB_HOST 89
110/* 90 */
111#define TEGRA124_CLK_MSENC 91
112#define TEGRA124_CLK_CSUS 92
113/* 93 */
114/* 94 */
115/* 95 (bit affects xusb_dev and xusb_dev_src) */
116
117/* 96 */
118/* 97 */
119/* 98 */
120#define TEGRA124_CLK_MSELECT 99
121#define TEGRA124_CLK_TSENSOR 100
122#define TEGRA124_CLK_I2S3 101
123#define TEGRA124_CLK_I2S4 102
124#define TEGRA124_CLK_I2C4 103
125#define TEGRA124_CLK_SBC5 104
126#define TEGRA124_CLK_SBC6 105
127#define TEGRA124_CLK_D_AUDIO 106
128#define TEGRA124_CLK_APBIF 107
129#define TEGRA124_CLK_DAM0 108
130#define TEGRA124_CLK_DAM1 109
131#define TEGRA124_CLK_DAM2 110
132#define TEGRA124_CLK_HDA2CODEC_2X 111
133/* 112 */
134#define TEGRA124_CLK_AUDIO0_2X 113
135#define TEGRA124_CLK_AUDIO1_2X 114
136#define TEGRA124_CLK_AUDIO2_2X 115
137#define TEGRA124_CLK_AUDIO3_2X 116
138#define TEGRA124_CLK_AUDIO4_2X 117
139#define TEGRA124_CLK_SPDIF_2X 118
140#define TEGRA124_CLK_ACTMON 119
141#define TEGRA124_CLK_EXTERN1 120
142#define TEGRA124_CLK_EXTERN2 121
143#define TEGRA124_CLK_EXTERN3 122
144#define TEGRA124_CLK_SATA_OOB 123
145#define TEGRA124_CLK_SATA 124
146#define TEGRA124_CLK_HDA 125
147/* 126 */
148#define TEGRA124_CLK_SE 127
149
150#define TEGRA124_CLK_HDA2HDMI 128
151#define TEGRA124_CLK_SATA_COLD 129
152/* 130 */
153/* 131 */
154/* 132 */
155/* 133 */
156/* 134 */
157/* 135 */
158/* 136 */
159/* 137 */
160/* 138 */
161/* 139 */
162/* 140 */
163/* 141 */
164/* 142 */
165/* 143 (bit affects xusb_falcon_src, xusb_fs_src, */
166/* xusb_host_src and xusb_ss_src) */
167#define TEGRA124_CLK_CILAB 144
168#define TEGRA124_CLK_CILCD 145
169#define TEGRA124_CLK_CILE 146
170#define TEGRA124_CLK_DSIALP 147
171#define TEGRA124_CLK_DSIBLP 148
172#define TEGRA124_CLK_ENTROPY 149
173#define TEGRA124_CLK_DDS 150
174/* 151 */
175#define TEGRA124_CLK_DP2 152
176#define TEGRA124_CLK_AMX 153
177#define TEGRA124_CLK_ADX 154
178/* 155 (bit affects dfll_ref and dfll_soc) */
179#define TEGRA124_CLK_XUSB_SS 156
180/* 157 */
181/* 158 */
182/* 159 */
183
184/* 160 */
185/* 161 */
186/* 162 */
187/* 163 */
188/* 164 */
189/* 165 */
190#define TEGRA124_CLK_I2C6 166
191/* 167 */
192/* 168 */
193/* 169 */
194/* 170 */
195#define TEGRA124_CLK_VIM2_CLK 171
196/* 172 */
197/* 173 */
198/* 174 */
199/* 175 */
200#define TEGRA124_CLK_HDMI_AUDIO 176
201#define TEGRA124_CLK_CLK72MHZ 177
202#define TEGRA124_CLK_VIC03 178
203/* 179 */
204#define TEGRA124_CLK_ADX1 180
205#define TEGRA124_CLK_DPAUX 181
206#define TEGRA124_CLK_SOR0 182
207/* 183 */
208#define TEGRA124_CLK_GPU 184
209#define TEGRA124_CLK_AMX1 185
210/* 186 */
211/* 187 */
212/* 188 */
213/* 189 */
214/* 190 */
215/* 191 */
216#define TEGRA124_CLK_UARTB 192
217#define TEGRA124_CLK_VFIR 193
218#define TEGRA124_CLK_SPDIF_IN 194
219#define TEGRA124_CLK_SPDIF_OUT 195
220#define TEGRA124_CLK_VI 196
221#define TEGRA124_CLK_VI_SENSOR 197
222#define TEGRA124_CLK_FUSE 198
223#define TEGRA124_CLK_FUSE_BURN 199
224#define TEGRA124_CLK_CLK_32K 200
225#define TEGRA124_CLK_CLK_M 201
226#define TEGRA124_CLK_CLK_M_DIV2 202
227#define TEGRA124_CLK_CLK_M_DIV4 203
228#define TEGRA124_CLK_PLL_REF 204
229#define TEGRA124_CLK_PLL_C 205
230#define TEGRA124_CLK_PLL_C_OUT1 206
231#define TEGRA124_CLK_PLL_C2 207
232#define TEGRA124_CLK_PLL_C3 208
233#define TEGRA124_CLK_PLL_M 209
234#define TEGRA124_CLK_PLL_M_OUT1 210
235#define TEGRA124_CLK_PLL_P 211
236#define TEGRA124_CLK_PLL_P_OUT1 212
237#define TEGRA124_CLK_PLL_P_OUT2 213
238#define TEGRA124_CLK_PLL_P_OUT3 214
239#define TEGRA124_CLK_PLL_P_OUT4 215
240#define TEGRA124_CLK_PLL_A 216
241#define TEGRA124_CLK_PLL_A_OUT0 217
242#define TEGRA124_CLK_PLL_D 218
243#define TEGRA124_CLK_PLL_D_OUT0 219
244#define TEGRA124_CLK_PLL_D2 220
245#define TEGRA124_CLK_PLL_D2_OUT0 221
246#define TEGRA124_CLK_PLL_U 222
247#define TEGRA124_CLK_PLL_U_480M 223
248
249#define TEGRA124_CLK_PLL_U_60M 224
250#define TEGRA124_CLK_PLL_U_48M 225
251#define TEGRA124_CLK_PLL_U_12M 226
252#define TEGRA124_CLK_PLL_X 227
253#define TEGRA124_CLK_PLL_X_OUT0 228
254#define TEGRA124_CLK_PLL_RE_VCO 229
255#define TEGRA124_CLK_PLL_RE_OUT 230
256#define TEGRA124_CLK_PLL_E 231
257#define TEGRA124_CLK_SPDIF_IN_SYNC 232
258#define TEGRA124_CLK_I2S0_SYNC 233
259#define TEGRA124_CLK_I2S1_SYNC 234
260#define TEGRA124_CLK_I2S2_SYNC 235
261#define TEGRA124_CLK_I2S3_SYNC 236
262#define TEGRA124_CLK_I2S4_SYNC 237
263#define TEGRA124_CLK_VIMCLK_SYNC 238
264#define TEGRA124_CLK_AUDIO0 239
265#define TEGRA124_CLK_AUDIO1 240
266#define TEGRA124_CLK_AUDIO2 241
267#define TEGRA124_CLK_AUDIO3 242
268#define TEGRA124_CLK_AUDIO4 243
269#define TEGRA124_CLK_SPDIF 244
270#define TEGRA124_CLK_CLK_OUT_1 245
271#define TEGRA124_CLK_CLK_OUT_2 246
272#define TEGRA124_CLK_CLK_OUT_3 247
273#define TEGRA124_CLK_BLINK 248
274/* 249 */
275/* 250 */
276/* 251 */
277#define TEGRA124_CLK_XUSB_HOST_SRC 252
278#define TEGRA124_CLK_XUSB_FALCON_SRC 253
279#define TEGRA124_CLK_XUSB_FS_SRC 254
280#define TEGRA124_CLK_XUSB_SS_SRC 255
281
282#define TEGRA124_CLK_XUSB_DEV_SRC 256
283#define TEGRA124_CLK_XUSB_DEV 257
284#define TEGRA124_CLK_XUSB_HS_SRC 258
285#define TEGRA124_CLK_SCLK 259
286#define TEGRA124_CLK_HCLK 260
287#define TEGRA124_CLK_PCLK 261
288#define TEGRA124_CLK_CCLK_G 262
289#define TEGRA124_CLK_CCLK_LP 263
290#define TEGRA124_CLK_DFLL_REF 264
291#define TEGRA124_CLK_DFLL_SOC 265
292#define TEGRA124_CLK_VI_SENSOR2 266
293#define TEGRA124_CLK_PLL_P_OUT5 267
294#define TEGRA124_CLK_CML0 268
295#define TEGRA124_CLK_CML1 269
296#define TEGRA124_CLK_PLL_C4 270
297#define TEGRA124_CLK_PLL_DP 271
298#define TEGRA124_CLK_PLL_E_MUX 272
299/* 273 */
300/* 274 */
301/* 275 */
302/* 276 */
303/* 277 */
304/* 278 */
305/* 279 */
306/* 280 */
307/* 281 */
308/* 282 */
309/* 283 */
310/* 284 */
311/* 285 */
312/* 286 */
313/* 287 */
314
315/* 288 */
316/* 289 */
317/* 290 */
318/* 291 */
319/* 292 */
320/* 293 */
321/* 294 */
322/* 295 */
323/* 296 */
324/* 297 */
325/* 298 */
326/* 299 */
327#define TEGRA124_CLK_AUDIO0_MUX 300
328#define TEGRA124_CLK_AUDIO1_MUX 301
329#define TEGRA124_CLK_AUDIO2_MUX 302
330#define TEGRA124_CLK_AUDIO3_MUX 303
331#define TEGRA124_CLK_AUDIO4_MUX 304
332#define TEGRA124_CLK_SPDIF_MUX 305
333#define TEGRA124_CLK_CLK_OUT_1_MUX 306
334#define TEGRA124_CLK_CLK_OUT_2_MUX 307
335#define TEGRA124_CLK_CLK_OUT_3_MUX 308
336#define TEGRA124_CLK_DSIA_MUX 309
337#define TEGRA124_CLK_DSIB_MUX 310
338#define TEGRA124_CLK_SOR0_LVDS 311
339#define TEGRA124_CLK_CLK_MAX 312
340
341#endif /* _DT_BINDINGS_CLOCK_TEGRA124_CAR_H */
diff --git a/include/dt-bindings/clock/tegra20-car.h b/include/dt-bindings/clock/tegra20-car.h
index a1ae9a8fdd6c..9406207cfac8 100644
--- a/include/dt-bindings/clock/tegra20-car.h
+++ b/include/dt-bindings/clock/tegra20-car.h
@@ -92,7 +92,7 @@
92#define TEGRA20_CLK_OWR 71 92#define TEGRA20_CLK_OWR 71
93#define TEGRA20_CLK_AFI 72 93#define TEGRA20_CLK_AFI 72
94#define TEGRA20_CLK_CSITE 73 94#define TEGRA20_CLK_CSITE 73
95#define TEGRA20_CLK_PCIE_XCLK 74 95/* 74 */
96#define TEGRA20_CLK_AVPUCQ 75 96#define TEGRA20_CLK_AVPUCQ 75
97#define TEGRA20_CLK_LA 76 97#define TEGRA20_CLK_LA 76
98/* 77 */ 98/* 77 */
diff --git a/include/dt-bindings/clock/tegra30-car.h b/include/dt-bindings/clock/tegra30-car.h
index e40fae8f9a8d..889e49ba0aa3 100644
--- a/include/dt-bindings/clock/tegra30-car.h
+++ b/include/dt-bindings/clock/tegra30-car.h
@@ -92,7 +92,7 @@
92#define TEGRA30_CLK_OWR 71 92#define TEGRA30_CLK_OWR 71
93#define TEGRA30_CLK_AFI 72 93#define TEGRA30_CLK_AFI 72
94#define TEGRA30_CLK_CSITE 73 94#define TEGRA30_CLK_CSITE 73
95#define TEGRA30_CLK_PCIEX 74 95/* 74 */
96#define TEGRA30_CLK_AVPUCQ 75 96#define TEGRA30_CLK_AVPUCQ 75
97#define TEGRA30_CLK_LA 76 97#define TEGRA30_CLK_LA 76
98/* 77 */ 98/* 77 */
@@ -260,6 +260,14 @@
260/* 298 */ 260/* 298 */
261/* 299 */ 261/* 299 */
262#define TEGRA30_CLK_CLK_OUT_1_MUX 300 262#define TEGRA30_CLK_CLK_OUT_1_MUX 300
263#define TEGRA30_CLK_CLK_MAX 301 263#define TEGRA30_CLK_CLK_OUT_2_MUX 301
264#define TEGRA30_CLK_CLK_OUT_3_MUX 302
265#define TEGRA30_CLK_AUDIO0_MUX 303
266#define TEGRA30_CLK_AUDIO1_MUX 304
267#define TEGRA30_CLK_AUDIO2_MUX 305
268#define TEGRA30_CLK_AUDIO3_MUX 306
269#define TEGRA30_CLK_AUDIO4_MUX 307
270#define TEGRA30_CLK_SPDIF_MUX 308
271#define TEGRA30_CLK_CLK_MAX 309
264 272
265#endif /* _DT_BINDINGS_CLOCK_TEGRA30_CAR_H */ 273#endif /* _DT_BINDINGS_CLOCK_TEGRA30_CAR_H */
diff --git a/include/linux/assoc_array.h b/include/linux/assoc_array.h
index 9a193b84238a..a89df3be1686 100644
--- a/include/linux/assoc_array.h
+++ b/include/linux/assoc_array.h
@@ -41,10 +41,10 @@ struct assoc_array_ops {
41 /* Is this the object we're looking for? */ 41 /* Is this the object we're looking for? */
42 bool (*compare_object)(const void *object, const void *index_key); 42 bool (*compare_object)(const void *object, const void *index_key);
43 43
44 /* How different are two objects, to a bit position in their keys? (or 44 /* How different is an object from an index key, to a bit position in
45 * -1 if they're the same) 45 * their keys? (or -1 if they're the same)
46 */ 46 */
47 int (*diff_objects)(const void *a, const void *b); 47 int (*diff_objects)(const void *object, const void *index_key);
48 48
49 /* Method to free an object. */ 49 /* Method to free an object. */
50 void (*free_object)(void *object); 50 void (*free_object)(void *object);
diff --git a/include/linux/clk/tegra.h b/include/linux/clk/tegra.h
index 23a0ceee831f..3ca9fca827a2 100644
--- a/include/linux/clk/tegra.h
+++ b/include/linux/clk/tegra.h
@@ -120,13 +120,6 @@ static inline void tegra_cpu_clock_resume(void)
120} 120}
121#endif 121#endif
122 122
123#ifdef CONFIG_ARCH_TEGRA
124void tegra_periph_reset_deassert(struct clk *c);
125void tegra_periph_reset_assert(struct clk *c);
126#else
127static inline void tegra_periph_reset_deassert(struct clk *c) {}
128static inline void tegra_periph_reset_assert(struct clk *c) {}
129#endif
130void tegra_clocks_apply_init_table(void); 123void tegra_clocks_apply_init_table(void);
131 124
132#endif /* __LINUX_CLK_TEGRA_H_ */ 125#endif /* __LINUX_CLK_TEGRA_H_ */
diff --git a/include/linux/compiler-intel.h b/include/linux/compiler-intel.h
index 973ce10c40b6..dc1bd3dcf11f 100644
--- a/include/linux/compiler-intel.h
+++ b/include/linux/compiler-intel.h
@@ -28,8 +28,6 @@
28 28
29#endif 29#endif
30 30
31#define uninitialized_var(x) x
32
33#ifndef __HAVE_BUILTIN_BSWAP16__ 31#ifndef __HAVE_BUILTIN_BSWAP16__
34/* icc has this, but it's called _bswap16 */ 32/* icc has this, but it's called _bswap16 */
35#define __HAVE_BUILTIN_BSWAP16__ 33#define __HAVE_BUILTIN_BSWAP16__
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index ee5fe9d77ae8..dc196bbcf227 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -280,14 +280,6 @@ cpufreq_verify_within_cpu_limits(struct cpufreq_policy *policy)
280 policy->cpuinfo.max_freq); 280 policy->cpuinfo.max_freq);
281} 281}
282 282
283#ifdef CONFIG_CPU_FREQ
284void cpufreq_suspend(void);
285void cpufreq_resume(void);
286#else
287static inline void cpufreq_suspend(void) {}
288static inline void cpufreq_resume(void) {}
289#endif
290
291/********************************************************************* 283/*********************************************************************
292 * CPUFREQ NOTIFIER INTERFACE * 284 * CPUFREQ NOTIFIER INTERFACE *
293 *********************************************************************/ 285 *********************************************************************/
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index 57e87e749a48..bf72e9ac6de0 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -29,8 +29,10 @@ struct vfsmount;
29/* The hash is always the low bits of hash_len */ 29/* The hash is always the low bits of hash_len */
30#ifdef __LITTLE_ENDIAN 30#ifdef __LITTLE_ENDIAN
31 #define HASH_LEN_DECLARE u32 hash; u32 len; 31 #define HASH_LEN_DECLARE u32 hash; u32 len;
32 #define bytemask_from_count(cnt) (~(~0ul << (cnt)*8))
32#else 33#else
33 #define HASH_LEN_DECLARE u32 len; u32 hash; 34 #define HASH_LEN_DECLARE u32 len; u32 hash;
35 #define bytemask_from_count(cnt) (~(~0ul >> (cnt)*8))
34#endif 36#endif
35 37
36/* 38/*
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index 41cf0c399288..bae1568416f8 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -22,6 +22,7 @@
22#define LINUX_DMAENGINE_H 22#define LINUX_DMAENGINE_H
23 23
24#include <linux/device.h> 24#include <linux/device.h>
25#include <linux/err.h>
25#include <linux/uio.h> 26#include <linux/uio.h>
26#include <linux/bug.h> 27#include <linux/bug.h>
27#include <linux/scatterlist.h> 28#include <linux/scatterlist.h>
@@ -1040,6 +1041,8 @@ enum dma_status dma_wait_for_async_tx(struct dma_async_tx_descriptor *tx);
1040void dma_issue_pending_all(void); 1041void dma_issue_pending_all(void);
1041struct dma_chan *__dma_request_channel(const dma_cap_mask_t *mask, 1042struct dma_chan *__dma_request_channel(const dma_cap_mask_t *mask,
1042 dma_filter_fn fn, void *fn_param); 1043 dma_filter_fn fn, void *fn_param);
1044struct dma_chan *dma_request_slave_channel_reason(struct device *dev,
1045 const char *name);
1043struct dma_chan *dma_request_slave_channel(struct device *dev, const char *name); 1046struct dma_chan *dma_request_slave_channel(struct device *dev, const char *name);
1044void dma_release_channel(struct dma_chan *chan); 1047void dma_release_channel(struct dma_chan *chan);
1045#else 1048#else
@@ -1063,6 +1066,11 @@ static inline struct dma_chan *__dma_request_channel(const dma_cap_mask_t *mask,
1063{ 1066{
1064 return NULL; 1067 return NULL;
1065} 1068}
1069static inline struct dma_chan *dma_request_slave_channel_reason(
1070 struct device *dev, const char *name)
1071{
1072 return ERR_PTR(-ENODEV);
1073}
1066static inline struct dma_chan *dma_request_slave_channel(struct device *dev, 1074static inline struct dma_chan *dma_request_slave_channel(struct device *dev,
1067 const char *name) 1075 const char *name)
1068{ 1076{
@@ -1079,6 +1087,7 @@ int dma_async_device_register(struct dma_device *device);
1079void dma_async_device_unregister(struct dma_device *device); 1087void dma_async_device_unregister(struct dma_device *device);
1080void dma_run_dependencies(struct dma_async_tx_descriptor *tx); 1088void dma_run_dependencies(struct dma_async_tx_descriptor *tx);
1081struct dma_chan *dma_get_slave_channel(struct dma_chan *chan); 1089struct dma_chan *dma_get_slave_channel(struct dma_chan *chan);
1090struct dma_chan *dma_get_any_slave_channel(struct dma_device *device);
1082struct dma_chan *net_dma_find_channel(void); 1091struct dma_chan *net_dma_find_channel(void);
1083#define dma_request_channel(mask, x, y) __dma_request_channel(&(mask), x, y) 1092#define dma_request_channel(mask, x, y) __dma_request_channel(&(mask), x, y)
1084#define dma_request_slave_channel_compat(mask, x, y, dev, name) \ 1093#define dma_request_slave_channel_compat(mask, x, y, dev, name) \
diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h
index 206a2af6b62b..b914ca3f57ba 100644
--- a/include/linux/hid-sensor-hub.h
+++ b/include/linux/hid-sensor-hub.h
@@ -42,6 +42,8 @@ struct hid_sensor_hub_attribute_info {
42 s32 units; 42 s32 units;
43 s32 unit_expo; 43 s32 unit_expo;
44 s32 size; 44 s32 size;
45 s32 logical_minimum;
46 s32 logical_maximum;
45}; 47};
46 48
47/** 49/**
diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-sensor-ids.h
index 4f945d3ed49f..8323775ac21d 100644
--- a/include/linux/hid-sensor-ids.h
+++ b/include/linux/hid-sensor-ids.h
@@ -117,4 +117,16 @@
117#define HID_USAGE_SENSOR_PROP_REPORT_STATE 0x200316 117#define HID_USAGE_SENSOR_PROP_REPORT_STATE 0x200316
118#define HID_USAGE_SENSOR_PROY_POWER_STATE 0x200319 118#define HID_USAGE_SENSOR_PROY_POWER_STATE 0x200319
119 119
120/* Power state enumerations */
121#define HID_USAGE_SENSOR_PROP_POWER_STATE_UNDEFINED_ENUM 0x00
122#define HID_USAGE_SENSOR_PROP_POWER_STATE_D0_FULL_POWER_ENUM 0x01
123#define HID_USAGE_SENSOR_PROP_POWER_STATE_D1_LOW_POWER_ENUM 0x02
124#define HID_USAGE_SENSOR_PROP_POWER_STATE_D2_STANDBY_WITH_WAKE_ENUM 0x03
125#define HID_USAGE_SENSOR_PROP_POWER_STATE_D3_SLEEP_WITH_WAKE_ENUM 0x04
126#define HID_USAGE_SENSOR_PROP_POWER_STATE_D4_POWER_OFF_ENUM 0x05
127
128/* Report State enumerations */
129#define HID_USAGE_SENSOR_PROP_REPORTING_STATE_NO_EVENTS_ENUM 0x00
130#define HID_USAGE_SENSOR_PROP_REPORTING_STATE_ALL_EVENTS_ENUM 0x01
131
120#endif 132#endif
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 9649ff0c63f8..bd7e98752222 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -142,7 +142,10 @@ static inline int dequeue_hwpoisoned_huge_page(struct page *page)
142 return 0; 142 return 0;
143} 143}
144 144
145#define isolate_huge_page(p, l) false 145static inline bool isolate_huge_page(struct page *page, struct list_head *list)
146{
147 return false;
148}
146#define putback_active_hugepage(p) do {} while (0) 149#define putback_active_hugepage(p) do {} while (0)
147#define is_hugepage_active(x) false 150#define is_hugepage_active(x) false
148 151
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index 5d89d1b808a6..c56c350324e4 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -4,6 +4,7 @@
4#include <uapi/linux/ipv6.h> 4#include <uapi/linux/ipv6.h>
5 5
6#define ipv6_optlen(p) (((p)->hdrlen+1) << 3) 6#define ipv6_optlen(p) (((p)->hdrlen+1) << 3)
7#define ipv6_authlen(p) (((p)->hdrlen+2) << 2)
7/* 8/*
8 * This structure contains configuration options per IPv6 link. 9 * This structure contains configuration options per IPv6 link.
9 */ 10 */
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index d4e98d13eff4..ecb87544cc5d 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -193,7 +193,8 @@ extern int _cond_resched(void);
193 (__x < 0) ? -__x : __x; \ 193 (__x < 0) ? -__x : __x; \
194 }) 194 })
195 195
196#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_DEBUG_ATOMIC_SLEEP) 196#if defined(CONFIG_MMU) && \
197 (defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_DEBUG_ATOMIC_SLEEP))
197void might_fault(void); 198void might_fault(void);
198#else 199#else
199static inline void might_fault(void) { } 200static inline void might_fault(void) { }
diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index d78d28a733b1..5fd33dc1fe3a 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -198,6 +198,9 @@ extern u32 vmcoreinfo_note[VMCOREINFO_NOTE_SIZE/4];
198extern size_t vmcoreinfo_size; 198extern size_t vmcoreinfo_size;
199extern size_t vmcoreinfo_max_size; 199extern size_t vmcoreinfo_max_size;
200 200
201/* flag to track if kexec reboot is in progress */
202extern bool kexec_in_progress;
203
201int __init parse_crashkernel(char *cmdline, unsigned long long system_ram, 204int __init parse_crashkernel(char *cmdline, unsigned long long system_ram,
202 unsigned long long *crash_size, unsigned long long *crash_base); 205 unsigned long long *crash_size, unsigned long long *crash_base);
203int parse_crashkernel_high(char *cmdline, unsigned long long system_ram, 206int parse_crashkernel_high(char *cmdline, unsigned long long system_ram,
diff --git a/include/linux/mfd/samsung/core.h b/include/linux/mfd/samsung/core.h
index 2d0c9071bcfb..cab2dd279076 100644
--- a/include/linux/mfd/samsung/core.h
+++ b/include/linux/mfd/samsung/core.h
@@ -39,7 +39,8 @@ enum sec_device_type {
39struct sec_pmic_dev { 39struct sec_pmic_dev {
40 struct device *dev; 40 struct device *dev;
41 struct sec_platform_data *pdata; 41 struct sec_platform_data *pdata;
42 struct regmap *regmap; 42 struct regmap *regmap_pmic;
43 struct regmap *regmap_rtc;
43 struct i2c_client *i2c; 44 struct i2c_client *i2c;
44 struct i2c_client *rtc; 45 struct i2c_client *rtc;
45 46
diff --git a/include/linux/micrel_phy.h b/include/linux/micrel_phy.h
index ad05ce60c1c9..2e5b194b9b19 100644
--- a/include/linux/micrel_phy.h
+++ b/include/linux/micrel_phy.h
@@ -22,6 +22,8 @@
22#define PHY_ID_KSZ8021 0x00221555 22#define PHY_ID_KSZ8021 0x00221555
23#define PHY_ID_KSZ8031 0x00221556 23#define PHY_ID_KSZ8031 0x00221556
24#define PHY_ID_KSZ8041 0x00221510 24#define PHY_ID_KSZ8041 0x00221510
25/* undocumented */
26#define PHY_ID_KSZ8041RNLI 0x00221537
25#define PHY_ID_KSZ8051 0x00221550 27#define PHY_ID_KSZ8051 0x00221550
26/* same id: ks8001 Rev. A/B, and ks8721 Rev 3. */ 28/* same id: ks8001 Rev. A/B, and ks8721 Rev 3. */
27#define PHY_ID_KSZ8001 0x0022161A 29#define PHY_ID_KSZ8001 0x0022161A
diff --git a/include/linux/net.h b/include/linux/net.h
index 4bcee94cef93..69be3e6079c8 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -181,7 +181,7 @@ struct proto_ops {
181 int offset, size_t size, int flags); 181 int offset, size_t size, int flags);
182 ssize_t (*splice_read)(struct socket *sock, loff_t *ppos, 182 ssize_t (*splice_read)(struct socket *sock, loff_t *ppos,
183 struct pipe_inode_info *pipe, size_t len, unsigned int flags); 183 struct pipe_inode_info *pipe, size_t len, unsigned int flags);
184 void (*set_peek_off)(struct sock *sk, int val); 184 int (*set_peek_off)(struct sock *sk, int val);
185}; 185};
186 186
187#define DECLARE_SOCKADDR(type, dst, src) \ 187#define DECLARE_SOCKADDR(type, dst, src) \
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 7f0ed423a360..d9a550bf3e8e 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1255,7 +1255,7 @@ struct net_device {
1255 unsigned char perm_addr[MAX_ADDR_LEN]; /* permanent hw address */ 1255 unsigned char perm_addr[MAX_ADDR_LEN]; /* permanent hw address */
1256 unsigned char addr_assign_type; /* hw address assignment type */ 1256 unsigned char addr_assign_type; /* hw address assignment type */
1257 unsigned char addr_len; /* hardware address length */ 1257 unsigned char addr_len; /* hardware address length */
1258 unsigned char neigh_priv_len; 1258 unsigned short neigh_priv_len;
1259 unsigned short dev_id; /* Used to differentiate devices 1259 unsigned short dev_id; /* Used to differentiate devices
1260 * that share the same link 1260 * that share the same link
1261 * layer address 1261 * layer address
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 1084a15175e0..a13d6825e586 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -960,6 +960,7 @@ void pci_update_resource(struct pci_dev *dev, int resno);
960int __must_check pci_assign_resource(struct pci_dev *dev, int i); 960int __must_check pci_assign_resource(struct pci_dev *dev, int i);
961int __must_check pci_reassign_resource(struct pci_dev *dev, int i, resource_size_t add_size, resource_size_t align); 961int __must_check pci_reassign_resource(struct pci_dev *dev, int i, resource_size_t add_size, resource_size_t align);
962int pci_select_bars(struct pci_dev *dev, unsigned long flags); 962int pci_select_bars(struct pci_dev *dev, unsigned long flags);
963bool pci_device_is_present(struct pci_dev *pdev);
963 964
964/* ROM control related routines */ 965/* ROM control related routines */
965int pci_enable_rom(struct pci_dev *pdev); 966int pci_enable_rom(struct pci_dev *pdev);
@@ -1567,65 +1568,65 @@ enum pci_fixup_pass {
1567/* Anonymous variables would be nice... */ 1568/* Anonymous variables would be nice... */
1568#define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, class, \ 1569#define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, class, \
1569 class_shift, hook) \ 1570 class_shift, hook) \
1570 static const struct pci_fixup __pci_fixup_##name __used \ 1571 static const struct pci_fixup __PASTE(__pci_fixup_##name,__LINE__) __used \
1571 __attribute__((__section__(#section), aligned((sizeof(void *))))) \ 1572 __attribute__((__section__(#section), aligned((sizeof(void *))))) \
1572 = { vendor, device, class, class_shift, hook }; 1573 = { vendor, device, class, class_shift, hook };
1573 1574
1574#define DECLARE_PCI_FIXUP_CLASS_EARLY(vendor, device, class, \ 1575#define DECLARE_PCI_FIXUP_CLASS_EARLY(vendor, device, class, \
1575 class_shift, hook) \ 1576 class_shift, hook) \
1576 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early, \ 1577 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early, \
1577 vendor##device##hook, vendor, device, class, class_shift, hook) 1578 hook, vendor, device, class, class_shift, hook)
1578#define DECLARE_PCI_FIXUP_CLASS_HEADER(vendor, device, class, \ 1579#define DECLARE_PCI_FIXUP_CLASS_HEADER(vendor, device, class, \
1579 class_shift, hook) \ 1580 class_shift, hook) \
1580 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_header, \ 1581 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_header, \
1581 vendor##device##hook, vendor, device, class, class_shift, hook) 1582 hook, vendor, device, class, class_shift, hook)
1582#define DECLARE_PCI_FIXUP_CLASS_FINAL(vendor, device, class, \ 1583#define DECLARE_PCI_FIXUP_CLASS_FINAL(vendor, device, class, \
1583 class_shift, hook) \ 1584 class_shift, hook) \
1584 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_final, \ 1585 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_final, \
1585 vendor##device##hook, vendor, device, class, class_shift, hook) 1586 hook, vendor, device, class, class_shift, hook)
1586#define DECLARE_PCI_FIXUP_CLASS_ENABLE(vendor, device, class, \ 1587#define DECLARE_PCI_FIXUP_CLASS_ENABLE(vendor, device, class, \
1587 class_shift, hook) \ 1588 class_shift, hook) \
1588 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_enable, \ 1589 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_enable, \
1589 vendor##device##hook, vendor, device, class, class_shift, hook) 1590 hook, vendor, device, class, class_shift, hook)
1590#define DECLARE_PCI_FIXUP_CLASS_RESUME(vendor, device, class, \ 1591#define DECLARE_PCI_FIXUP_CLASS_RESUME(vendor, device, class, \
1591 class_shift, hook) \ 1592 class_shift, hook) \
1592 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume, \ 1593 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume, \
1593 resume##vendor##device##hook, vendor, device, class, \ 1594 resume##hook, vendor, device, class, \
1594 class_shift, hook) 1595 class_shift, hook)
1595#define DECLARE_PCI_FIXUP_CLASS_RESUME_EARLY(vendor, device, class, \ 1596#define DECLARE_PCI_FIXUP_CLASS_RESUME_EARLY(vendor, device, class, \
1596 class_shift, hook) \ 1597 class_shift, hook) \
1597 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume_early, \ 1598 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume_early, \
1598 resume_early##vendor##device##hook, vendor, device, \ 1599 resume_early##hook, vendor, device, \
1599 class, class_shift, hook) 1600 class, class_shift, hook)
1600#define DECLARE_PCI_FIXUP_CLASS_SUSPEND(vendor, device, class, \ 1601#define DECLARE_PCI_FIXUP_CLASS_SUSPEND(vendor, device, class, \
1601 class_shift, hook) \ 1602 class_shift, hook) \
1602 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend, \ 1603 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend, \
1603 suspend##vendor##device##hook, vendor, device, class, \ 1604 suspend##hook, vendor, device, class, \
1604 class_shift, hook) 1605 class_shift, hook)
1605 1606
1606#define DECLARE_PCI_FIXUP_EARLY(vendor, device, hook) \ 1607#define DECLARE_PCI_FIXUP_EARLY(vendor, device, hook) \
1607 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early, \ 1608 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early, \
1608 vendor##device##hook, vendor, device, PCI_ANY_ID, 0, hook) 1609 hook, vendor, device, PCI_ANY_ID, 0, hook)
1609#define DECLARE_PCI_FIXUP_HEADER(vendor, device, hook) \ 1610#define DECLARE_PCI_FIXUP_HEADER(vendor, device, hook) \
1610 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_header, \ 1611 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_header, \
1611 vendor##device##hook, vendor, device, PCI_ANY_ID, 0, hook) 1612 hook, vendor, device, PCI_ANY_ID, 0, hook)
1612#define DECLARE_PCI_FIXUP_FINAL(vendor, device, hook) \ 1613#define DECLARE_PCI_FIXUP_FINAL(vendor, device, hook) \
1613 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_final, \ 1614 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_final, \
1614 vendor##device##hook, vendor, device, PCI_ANY_ID, 0, hook) 1615 hook, vendor, device, PCI_ANY_ID, 0, hook)
1615#define DECLARE_PCI_FIXUP_ENABLE(vendor, device, hook) \ 1616#define DECLARE_PCI_FIXUP_ENABLE(vendor, device, hook) \
1616 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_enable, \ 1617 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_enable, \
1617 vendor##device##hook, vendor, device, PCI_ANY_ID, 0, hook) 1618 hook, vendor, device, PCI_ANY_ID, 0, hook)
1618#define DECLARE_PCI_FIXUP_RESUME(vendor, device, hook) \ 1619#define DECLARE_PCI_FIXUP_RESUME(vendor, device, hook) \
1619 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume, \ 1620 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume, \
1620 resume##vendor##device##hook, vendor, device, \ 1621 resume##hook, vendor, device, \
1621 PCI_ANY_ID, 0, hook) 1622 PCI_ANY_ID, 0, hook)
1622#define DECLARE_PCI_FIXUP_RESUME_EARLY(vendor, device, hook) \ 1623#define DECLARE_PCI_FIXUP_RESUME_EARLY(vendor, device, hook) \
1623 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume_early, \ 1624 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_resume_early, \
1624 resume_early##vendor##device##hook, vendor, device, \ 1625 resume_early##hook, vendor, device, \
1625 PCI_ANY_ID, 0, hook) 1626 PCI_ANY_ID, 0, hook)
1626#define DECLARE_PCI_FIXUP_SUSPEND(vendor, device, hook) \ 1627#define DECLARE_PCI_FIXUP_SUSPEND(vendor, device, hook) \
1627 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend, \ 1628 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_suspend, \
1628 suspend##vendor##device##hook, vendor, device, \ 1629 suspend##hook, vendor, device, \
1629 PCI_ANY_ID, 0, hook) 1630 PCI_ANY_ID, 0, hook)
1630 1631
1631#ifdef CONFIG_PCI_QUIRKS 1632#ifdef CONFIG_PCI_QUIRKS
diff --git a/include/linux/serial_sci.h b/include/linux/serial_sci.h
index 50fe651da965..af414e1895a5 100644
--- a/include/linux/serial_sci.h
+++ b/include/linux/serial_sci.h
@@ -11,11 +11,11 @@
11#define SCIx_NOT_SUPPORTED (-1) 11#define SCIx_NOT_SUPPORTED (-1)
12 12
13enum { 13enum {
14 SCBRR_ALGO_1, /* ((clk + 16 * bps) / (16 * bps) - 1) */ 14 SCBRR_ALGO_NONE, /* Compute sampling rate in the driver */
15 SCBRR_ALGO_2, /* ((clk + 16 * bps) / (32 * bps) - 1) */ 15 SCBRR_ALGO_1, /* clk / (16 * bps) */
16 SCBRR_ALGO_3, /* (((clk * 2) + 16 * bps) / (16 * bps) - 1) */ 16 SCBRR_ALGO_2, /* DIV_ROUND_CLOSEST(clk, 32 * bps) - 1 */
17 SCBRR_ALGO_4, /* (((clk * 2) + 16 * bps) / (32 * bps) - 1) */ 17 SCBRR_ALGO_3, /* clk / (8 * bps) */
18 SCBRR_ALGO_5, /* (((clk * 1000 / 32) / bps) - 1) */ 18 SCBRR_ALGO_4, /* DIV_ROUND_CLOSEST(clk, 16 * bps) - 1 */
19 SCBRR_ALGO_6, /* HSCIF variable sample rate algorithm */ 19 SCBRR_ALGO_6, /* HSCIF variable sample rate algorithm */
20}; 20};
21 21
@@ -70,17 +70,6 @@ enum {
70 SCIx_MUX_IRQ = SCIx_NR_IRQS, /* special case */ 70 SCIx_MUX_IRQ = SCIx_NR_IRQS, /* special case */
71}; 71};
72 72
73/* Offsets into the sci_port->gpios array */
74enum {
75 SCIx_SCK,
76 SCIx_RXD,
77 SCIx_TXD,
78 SCIx_CTS,
79 SCIx_RTS,
80
81 SCIx_NR_FNS,
82};
83
84enum { 73enum {
85 SCIx_PROBE_REGTYPE, 74 SCIx_PROBE_REGTYPE,
86 75
@@ -108,10 +97,10 @@ enum {
108} 97}
109 98
110#define SCIx_IRQ_IS_MUXED(port) \ 99#define SCIx_IRQ_IS_MUXED(port) \
111 ((port)->cfg->irqs[SCIx_ERI_IRQ] == \ 100 ((port)->irqs[SCIx_ERI_IRQ] == \
112 (port)->cfg->irqs[SCIx_RXI_IRQ]) || \ 101 (port)->irqs[SCIx_RXI_IRQ]) || \
113 ((port)->cfg->irqs[SCIx_ERI_IRQ] && \ 102 ((port)->irqs[SCIx_ERI_IRQ] && \
114 !(port)->cfg->irqs[SCIx_RXI_IRQ]) 103 ((port)->irqs[SCIx_RXI_IRQ] < 0))
115/* 104/*
116 * SCI register subset common for all port types. 105 * SCI register subset common for all port types.
117 * Not all registers will exist on all parts. 106 * Not all registers will exist on all parts.
@@ -142,20 +131,17 @@ struct plat_sci_port_ops {
142struct plat_sci_port { 131struct plat_sci_port {
143 unsigned long mapbase; /* resource base */ 132 unsigned long mapbase; /* resource base */
144 unsigned int irqs[SCIx_NR_IRQS]; /* ERI, RXI, TXI, BRI */ 133 unsigned int irqs[SCIx_NR_IRQS]; /* ERI, RXI, TXI, BRI */
145 unsigned int gpios[SCIx_NR_FNS]; /* SCK, RXD, TXD, CTS, RTS */
146 unsigned int type; /* SCI / SCIF / IRDA / HSCIF */ 134 unsigned int type; /* SCI / SCIF / IRDA / HSCIF */
147 upf_t flags; /* UPF_* flags */ 135 upf_t flags; /* UPF_* flags */
148 unsigned long capabilities; /* Port features/capabilities */ 136 unsigned long capabilities; /* Port features/capabilities */
149 137
138 unsigned int sampling_rate;
150 unsigned int scbrr_algo_id; /* SCBRR calculation algo */ 139 unsigned int scbrr_algo_id; /* SCBRR calculation algo */
151 unsigned int scscr; /* SCSCR initialization */ 140 unsigned int scscr; /* SCSCR initialization */
152 141
153 /* 142 /*
154 * Platform overrides if necessary, defaults otherwise. 143 * Platform overrides if necessary, defaults otherwise.
155 */ 144 */
156 int overrun_bit;
157 unsigned int error_mask;
158
159 int port_reg; 145 int port_reg;
160 unsigned char regshift; 146 unsigned char regshift;
161 unsigned char regtype; 147 unsigned char regtype;
diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
index 30aa0dc60d75..9d55438bc4ad 100644
--- a/include/linux/shmem_fs.h
+++ b/include/linux/shmem_fs.h
@@ -47,6 +47,8 @@ extern int shmem_init(void);
47extern int shmem_fill_super(struct super_block *sb, void *data, int silent); 47extern int shmem_fill_super(struct super_block *sb, void *data, int silent);
48extern struct file *shmem_file_setup(const char *name, 48extern struct file *shmem_file_setup(const char *name,
49 loff_t size, unsigned long flags); 49 loff_t size, unsigned long flags);
50extern struct file *shmem_kernel_file_setup(const char *name, loff_t size,
51 unsigned long flags);
50extern int shmem_zero_setup(struct vm_area_struct *); 52extern int shmem_zero_setup(struct vm_area_struct *);
51extern int shmem_lock(struct file *file, int lock, struct user_struct *user); 53extern int shmem_lock(struct file *file, int lock, struct user_struct *user);
52extern void shmem_unlock_mapping(struct address_space *mapping); 54extern void shmem_unlock_mapping(struct address_space *mapping);
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index bec1cc7d5e3c..215b5ea1cb30 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2263,6 +2263,24 @@ static inline void skb_postpull_rcsum(struct sk_buff *skb,
2263 2263
2264unsigned char *skb_pull_rcsum(struct sk_buff *skb, unsigned int len); 2264unsigned char *skb_pull_rcsum(struct sk_buff *skb, unsigned int len);
2265 2265
2266/**
2267 * pskb_trim_rcsum - trim received skb and update checksum
2268 * @skb: buffer to trim
2269 * @len: new length
2270 *
2271 * This is exactly the same as pskb_trim except that it ensures the
2272 * checksum of received packets are still valid after the operation.
2273 */
2274
2275static inline int pskb_trim_rcsum(struct sk_buff *skb, unsigned int len)
2276{
2277 if (likely(len >= skb->len))
2278 return 0;
2279 if (skb->ip_summed == CHECKSUM_COMPLETE)
2280 skb->ip_summed = CHECKSUM_NONE;
2281 return __pskb_trim(skb, len);
2282}
2283
2266#define skb_queue_walk(queue, skb) \ 2284#define skb_queue_walk(queue, skb) \
2267 for (skb = (queue)->next; \ 2285 for (skb = (queue)->next; \
2268 skb != (struct sk_buff *)(queue); \ 2286 skb != (struct sk_buff *)(queue); \
@@ -2360,27 +2378,6 @@ __wsum __skb_checksum(const struct sk_buff *skb, int offset, int len,
2360__wsum skb_checksum(const struct sk_buff *skb, int offset, int len, 2378__wsum skb_checksum(const struct sk_buff *skb, int offset, int len,
2361 __wsum csum); 2379 __wsum csum);
2362 2380
2363/**
2364 * pskb_trim_rcsum - trim received skb and update checksum
2365 * @skb: buffer to trim
2366 * @len: new length
2367 *
2368 * This is exactly the same as pskb_trim except that it ensures the
2369 * checksum of received packets are still valid after the operation.
2370 */
2371
2372static inline int pskb_trim_rcsum(struct sk_buff *skb, unsigned int len)
2373{
2374 if (likely(len >= skb->len))
2375 return 0;
2376 if (skb->ip_summed == CHECKSUM_COMPLETE) {
2377 __wsum adj = skb_checksum(skb, len, skb->len - len, 0);
2378
2379 skb->csum = csum_sub(skb->csum, adj);
2380 }
2381 return __pskb_trim(skb, len);
2382}
2383
2384static inline void *skb_header_pointer(const struct sk_buff *skb, int offset, 2381static inline void *skb_header_pointer(const struct sk_buff *skb, int offset,
2385 int len, void *buffer) 2382 int len, void *buffer)
2386{ 2383{
diff --git a/include/linux/tegra-powergate.h b/include/linux/tegra-powergate.h
index fd4498329c7c..e6f2ab3014a7 100644
--- a/include/linux/tegra-powergate.h
+++ b/include/linux/tegra-powergate.h
@@ -19,6 +19,7 @@
19#define _MACH_TEGRA_POWERGATE_H_ 19#define _MACH_TEGRA_POWERGATE_H_
20 20
21struct clk; 21struct clk;
22struct reset_control;
22 23
23#define TEGRA_POWERGATE_CPU 0 24#define TEGRA_POWERGATE_CPU 0
24#define TEGRA_POWERGATE_3D 1 25#define TEGRA_POWERGATE_3D 1
@@ -37,14 +38,49 @@ struct clk;
37#define TEGRA_POWERGATE_CPU0 14 38#define TEGRA_POWERGATE_CPU0 14
38#define TEGRA_POWERGATE_C0NC 15 39#define TEGRA_POWERGATE_C0NC 15
39#define TEGRA_POWERGATE_C1NC 16 40#define TEGRA_POWERGATE_C1NC 16
41#define TEGRA_POWERGATE_SOR 17
40#define TEGRA_POWERGATE_DIS 18 42#define TEGRA_POWERGATE_DIS 18
41#define TEGRA_POWERGATE_DISB 19 43#define TEGRA_POWERGATE_DISB 19
42#define TEGRA_POWERGATE_XUSBA 20 44#define TEGRA_POWERGATE_XUSBA 20
43#define TEGRA_POWERGATE_XUSBB 21 45#define TEGRA_POWERGATE_XUSBB 21
44#define TEGRA_POWERGATE_XUSBC 22 46#define TEGRA_POWERGATE_XUSBC 22
47#define TEGRA_POWERGATE_VIC 23
48#define TEGRA_POWERGATE_IRAM 24
45 49
46#define TEGRA_POWERGATE_3D0 TEGRA_POWERGATE_3D 50#define TEGRA_POWERGATE_3D0 TEGRA_POWERGATE_3D
47 51
52#define TEGRA_IO_RAIL_CSIA 0
53#define TEGRA_IO_RAIL_CSIB 1
54#define TEGRA_IO_RAIL_DSI 2
55#define TEGRA_IO_RAIL_MIPI_BIAS 3
56#define TEGRA_IO_RAIL_PEX_BIAS 4
57#define TEGRA_IO_RAIL_PEX_CLK1 5
58#define TEGRA_IO_RAIL_PEX_CLK2 6
59#define TEGRA_IO_RAIL_USB0 9
60#define TEGRA_IO_RAIL_USB1 10
61#define TEGRA_IO_RAIL_USB2 11
62#define TEGRA_IO_RAIL_USB_BIAS 12
63#define TEGRA_IO_RAIL_NAND 13
64#define TEGRA_IO_RAIL_UART 14
65#define TEGRA_IO_RAIL_BB 15
66#define TEGRA_IO_RAIL_AUDIO 17
67#define TEGRA_IO_RAIL_HSIC 19
68#define TEGRA_IO_RAIL_COMP 22
69#define TEGRA_IO_RAIL_HDMI 28
70#define TEGRA_IO_RAIL_PEX_CNTRL 32
71#define TEGRA_IO_RAIL_SDMMC1 33
72#define TEGRA_IO_RAIL_SDMMC3 34
73#define TEGRA_IO_RAIL_SDMMC4 35
74#define TEGRA_IO_RAIL_CAM 36
75#define TEGRA_IO_RAIL_RES 37
76#define TEGRA_IO_RAIL_HV 38
77#define TEGRA_IO_RAIL_DSIB 39
78#define TEGRA_IO_RAIL_DSIC 40
79#define TEGRA_IO_RAIL_DSID 41
80#define TEGRA_IO_RAIL_CSIE 44
81#define TEGRA_IO_RAIL_LVDS 57
82#define TEGRA_IO_RAIL_SYS_DDC 58
83
48#ifdef CONFIG_ARCH_TEGRA 84#ifdef CONFIG_ARCH_TEGRA
49int tegra_powergate_is_powered(int id); 85int tegra_powergate_is_powered(int id);
50int tegra_powergate_power_on(int id); 86int tegra_powergate_power_on(int id);
@@ -52,7 +88,11 @@ int tegra_powergate_power_off(int id);
52int tegra_powergate_remove_clamping(int id); 88int tegra_powergate_remove_clamping(int id);
53 89
54/* Must be called with clk disabled, and returns with clk enabled */ 90/* Must be called with clk disabled, and returns with clk enabled */
55int tegra_powergate_sequence_power_up(int id, struct clk *clk); 91int tegra_powergate_sequence_power_up(int id, struct clk *clk,
92 struct reset_control *rst);
93
94int tegra_io_rail_power_on(int id);
95int tegra_io_rail_power_off(int id);
56#else 96#else
57static inline int tegra_powergate_is_powered(int id) 97static inline int tegra_powergate_is_powered(int id)
58{ 98{
@@ -74,7 +114,18 @@ static inline int tegra_powergate_remove_clamping(int id)
74 return -ENOSYS; 114 return -ENOSYS;
75} 115}
76 116
77static inline int tegra_powergate_sequence_power_up(int id, struct clk *clk) 117static inline int tegra_powergate_sequence_power_up(int id, struct clk *clk,
118 struct reset_control *rst);
119{
120 return -ENOSYS;
121}
122
123static inline int tegra_io_rail_power_on(int id)
124{
125 return -ENOSYS;
126}
127
128static inline int tegra_io_rail_power_off(int id)
78{ 129{
79 return -ENOSYS; 130 return -ENOSYS;
80} 131}
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 7454865ad148..512ab162832c 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -1264,6 +1264,8 @@ typedef void (*usb_complete_t)(struct urb *);
1264 * @sg: scatter gather buffer list, the buffer size of each element in 1264 * @sg: scatter gather buffer list, the buffer size of each element in
1265 * the list (except the last) must be divisible by the endpoint's 1265 * the list (except the last) must be divisible by the endpoint's
1266 * max packet size if no_sg_constraint isn't set in 'struct usb_bus' 1266 * max packet size if no_sg_constraint isn't set in 'struct usb_bus'
1267 * (FIXME: scatter-gather under xHCI is broken for periodic transfers.
1268 * Do not use urb->sg for interrupt endpoints for now, only bulk.)
1267 * @num_mapped_sgs: (internal) number of mapped sg entries 1269 * @num_mapped_sgs: (internal) number of mapped sg entries
1268 * @num_sgs: number of entries in the sg list 1270 * @num_sgs: number of entries in the sg list
1269 * @transfer_buffer_length: How big is transfer_buffer. The transfer may 1271 * @transfer_buffer_length: How big is transfer_buffer. The transfer may
diff --git a/include/linux/usb/wusb.h b/include/linux/usb/wusb.h
index 0c4d4ca370ec..eeb28329fa3c 100644
--- a/include/linux/usb/wusb.h
+++ b/include/linux/usb/wusb.h
@@ -271,6 +271,8 @@ static inline u8 wusb_key_index(int index, int type, int originator)
271#define WUSB_KEY_INDEX_TYPE_GTK 2 271#define WUSB_KEY_INDEX_TYPE_GTK 2
272#define WUSB_KEY_INDEX_ORIGINATOR_HOST 0 272#define WUSB_KEY_INDEX_ORIGINATOR_HOST 0
273#define WUSB_KEY_INDEX_ORIGINATOR_DEVICE 1 273#define WUSB_KEY_INDEX_ORIGINATOR_DEVICE 1
274/* bits 0-3 used for the key index. */
275#define WUSB_KEY_INDEX_MAX 15
274 276
275/* A CCM Nonce, defined in WUSB1.0[6.4.1] */ 277/* A CCM Nonce, defined in WUSB1.0[6.4.1] */
276struct aes_ccm_nonce { 278struct aes_ccm_nonce {
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
index bd8218b15009..941055e9d125 100644
--- a/include/media/videobuf2-core.h
+++ b/include/media/videobuf2-core.h
@@ -83,7 +83,7 @@ struct vb2_fileio_data;
83struct vb2_mem_ops { 83struct vb2_mem_ops {
84 void *(*alloc)(void *alloc_ctx, unsigned long size, gfp_t gfp_flags); 84 void *(*alloc)(void *alloc_ctx, unsigned long size, gfp_t gfp_flags);
85 void (*put)(void *buf_priv); 85 void (*put)(void *buf_priv);
86 struct dma_buf *(*get_dmabuf)(void *buf_priv); 86 struct dma_buf *(*get_dmabuf)(void *buf_priv, unsigned long flags);
87 87
88 void *(*get_userptr)(void *alloc_ctx, unsigned long vaddr, 88 void *(*get_userptr)(void *alloc_ctx, unsigned long vaddr,
89 unsigned long size, int write); 89 unsigned long size, int write);
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index eb198acaac1d..488316e339a1 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -110,7 +110,8 @@ struct frag_hdr {
110 __be32 identification; 110 __be32 identification;
111}; 111};
112 112
113#define IP6_MF 0x0001 113#define IP6_MF 0x0001
114#define IP6_OFFSET 0xFFF8
114 115
115#include <net/sock.h> 116#include <net/sock.h>
116 117
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index ea0ca5f6e629..67b5d0068273 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -1726,12 +1726,6 @@ struct sctp_association {
1726 /* How many duplicated TSNs have we seen? */ 1726 /* How many duplicated TSNs have we seen? */
1727 int numduptsns; 1727 int numduptsns;
1728 1728
1729 /* Number of seconds of idle time before an association is closed.
1730 * In the association context, this is really used as a boolean
1731 * since the real timeout is stored in the timeouts array
1732 */
1733 __u32 autoclose;
1734
1735 /* These are to support 1729 /* These are to support
1736 * "SCTP Extensions for Dynamic Reconfiguration of IP Addresses 1730 * "SCTP Extensions for Dynamic Reconfiguration of IP Addresses
1737 * and Enforcement of Flow and Message Limits" 1731 * and Enforcement of Flow and Message Limits"
diff --git a/include/net/sock.h b/include/net/sock.h
index e3a18ff0c38b..2ef3c3eca47a 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1035,7 +1035,6 @@ enum cg_proto_flags {
1035}; 1035};
1036 1036
1037struct cg_proto { 1037struct cg_proto {
1038 void (*enter_memory_pressure)(struct sock *sk);
1039 struct res_counter memory_allocated; /* Current allocated memory. */ 1038 struct res_counter memory_allocated; /* Current allocated memory. */
1040 struct percpu_counter sockets_allocated; /* Current number of sockets. */ 1039 struct percpu_counter sockets_allocated; /* Current number of sockets. */
1041 int memory_pressure; 1040 int memory_pressure;
@@ -1155,8 +1154,7 @@ static inline void sk_leave_memory_pressure(struct sock *sk)
1155 struct proto *prot = sk->sk_prot; 1154 struct proto *prot = sk->sk_prot;
1156 1155
1157 for (; cg_proto; cg_proto = parent_cg_proto(prot, cg_proto)) 1156 for (; cg_proto; cg_proto = parent_cg_proto(prot, cg_proto))
1158 if (cg_proto->memory_pressure) 1157 cg_proto->memory_pressure = 0;
1159 cg_proto->memory_pressure = 0;
1160 } 1158 }
1161 1159
1162} 1160}
@@ -1171,7 +1169,7 @@ static inline void sk_enter_memory_pressure(struct sock *sk)
1171 struct proto *prot = sk->sk_prot; 1169 struct proto *prot = sk->sk_prot;
1172 1170
1173 for (; cg_proto; cg_proto = parent_cg_proto(prot, cg_proto)) 1171 for (; cg_proto; cg_proto = parent_cg_proto(prot, cg_proto))
1174 cg_proto->enter_memory_pressure(sk); 1172 cg_proto->memory_pressure = 1;
1175 } 1173 }
1176 1174
1177 sk->sk_prot->enter_memory_pressure(sk); 1175 sk->sk_prot->enter_memory_pressure(sk);
diff --git a/include/sound/dmaengine_pcm.h b/include/sound/dmaengine_pcm.h
index 15017311f2e9..eb73a3a39ec2 100644
--- a/include/sound/dmaengine_pcm.h
+++ b/include/sound/dmaengine_pcm.h
@@ -114,6 +114,10 @@ void snd_dmaengine_pcm_set_config_from_dai_data(
114 * @compat_filter_fn: Will be used as the filter function when requesting a 114 * @compat_filter_fn: Will be used as the filter function when requesting a
115 * channel for platforms which do not use devicetree. The filter parameter 115 * channel for platforms which do not use devicetree. The filter parameter
116 * will be the DAI's DMA data. 116 * will be the DAI's DMA data.
117 * @dma_dev: If set, request DMA channel on this device rather than the DAI
118 * device.
119 * @chan_names: If set, these custom DMA channel names will be requested at
120 * registration time.
117 * @pcm_hardware: snd_pcm_hardware struct to be used for the PCM. 121 * @pcm_hardware: snd_pcm_hardware struct to be used for the PCM.
118 * @prealloc_buffer_size: Size of the preallocated audio buffer. 122 * @prealloc_buffer_size: Size of the preallocated audio buffer.
119 * 123 *
@@ -130,6 +134,8 @@ struct snd_dmaengine_pcm_config {
130 struct snd_soc_pcm_runtime *rtd, 134 struct snd_soc_pcm_runtime *rtd,
131 struct snd_pcm_substream *substream); 135 struct snd_pcm_substream *substream);
132 dma_filter_fn compat_filter_fn; 136 dma_filter_fn compat_filter_fn;
137 struct device *dma_dev;
138 const char *chan_names[SNDRV_PCM_STREAM_LAST + 1];
133 139
134 const struct snd_pcm_hardware *pcm_hardware; 140 const struct snd_pcm_hardware *pcm_hardware;
135 unsigned int prealloc_buffer_size; 141 unsigned int prealloc_buffer_size;
@@ -140,6 +146,10 @@ int snd_dmaengine_pcm_register(struct device *dev,
140 unsigned int flags); 146 unsigned int flags);
141void snd_dmaengine_pcm_unregister(struct device *dev); 147void snd_dmaengine_pcm_unregister(struct device *dev);
142 148
149int devm_snd_dmaengine_pcm_register(struct device *dev,
150 const struct snd_dmaengine_pcm_config *config,
151 unsigned int flags);
152
143int snd_dmaengine_pcm_prepare_slave_config(struct snd_pcm_substream *substream, 153int snd_dmaengine_pcm_prepare_slave_config(struct snd_pcm_substream *substream,
144 struct snd_pcm_hw_params *params, 154 struct snd_pcm_hw_params *params,
145 struct dma_slave_config *slave_config); 155 struct dma_slave_config *slave_config);
diff --git a/include/sound/memalloc.h b/include/sound/memalloc.h
index af9983970417..5f73785f5977 100644
--- a/include/sound/memalloc.h
+++ b/include/sound/memalloc.h
@@ -108,7 +108,7 @@ static inline dma_addr_t snd_sgbuf_get_addr(struct snd_dma_buffer *dmab,
108{ 108{
109 struct snd_sg_buf *sgbuf = dmab->private_data; 109 struct snd_sg_buf *sgbuf = dmab->private_data;
110 dma_addr_t addr = sgbuf->table[offset >> PAGE_SHIFT].addr; 110 dma_addr_t addr = sgbuf->table[offset >> PAGE_SHIFT].addr;
111 addr &= PAGE_MASK; 111 addr &= ~((dma_addr_t)PAGE_SIZE - 1);
112 return addr + offset % PAGE_SIZE; 112 return addr + offset % PAGE_SIZE;
113} 113}
114 114
diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h
index a3726275876d..ecc88592ecbe 100644
--- a/include/uapi/linux/input.h
+++ b/include/uapi/linux/input.h
@@ -719,6 +719,8 @@ struct input_keymap_entry {
719#define BTN_DPAD_LEFT 0x222 719#define BTN_DPAD_LEFT 0x222
720#define BTN_DPAD_RIGHT 0x223 720#define BTN_DPAD_RIGHT 0x223
721 721
722#define KEY_ALS_TOGGLE 0x230 /* Ambient light sensor */
723
722#define BTN_TRIGGER_HAPPY 0x2c0 724#define BTN_TRIGGER_HAPPY 0x2c0
723#define BTN_TRIGGER_HAPPY1 0x2c0 725#define BTN_TRIGGER_HAPPY1 0x2c0
724#define BTN_TRIGGER_HAPPY2 0x2c1 726#define BTN_TRIGGER_HAPPY2 0x2c1
@@ -856,6 +858,7 @@ struct input_keymap_entry {
856#define SW_FRONT_PROXIMITY 0x0b /* set = front proximity sensor active */ 858#define SW_FRONT_PROXIMITY 0x0b /* set = front proximity sensor active */
857#define SW_ROTATE_LOCK 0x0c /* set = rotate locked/disabled */ 859#define SW_ROTATE_LOCK 0x0c /* set = rotate locked/disabled */
858#define SW_LINEIN_INSERT 0x0d /* set = inserted */ 860#define SW_LINEIN_INSERT 0x0d /* set = inserted */
861#define SW_MUTE_DEVICE 0x0e /* set = device disabled */
859#define SW_MAX 0x0f 862#define SW_MAX 0x0f
860#define SW_CNT (SW_MAX+1) 863#define SW_CNT (SW_MAX+1)
861 864
diff --git a/include/uapi/linux/mic_common.h b/include/uapi/linux/mic_common.h
index 17e7d95e4f53..6eb40244e019 100644
--- a/include/uapi/linux/mic_common.h
+++ b/include/uapi/linux/mic_common.h
@@ -23,12 +23,7 @@
23 23
24#include <linux/virtio_ring.h> 24#include <linux/virtio_ring.h>
25 25
26#ifndef __KERNEL__ 26#define __mic_align(a, x) (((a) + (x) - 1) & ~((x) - 1))
27#define ALIGN(a, x) (((a) + (x) - 1) & ~((x) - 1))
28#define __aligned(x) __attribute__ ((aligned(x)))
29#endif
30
31#define mic_aligned_size(x) ALIGN(sizeof(x), 8)
32 27
33/** 28/**
34 * struct mic_device_desc: Virtio device information shared between the 29 * struct mic_device_desc: Virtio device information shared between the
@@ -48,8 +43,8 @@ struct mic_device_desc {
48 __u8 feature_len; 43 __u8 feature_len;
49 __u8 config_len; 44 __u8 config_len;
50 __u8 status; 45 __u8 status;
51 __u64 config[0]; 46 __le64 config[0];
52} __aligned(8); 47} __attribute__ ((aligned(8)));
53 48
54/** 49/**
55 * struct mic_device_ctrl: Per virtio device information in the device page 50 * struct mic_device_ctrl: Per virtio device information in the device page
@@ -66,7 +61,7 @@ struct mic_device_desc {
66 * @h2c_vdev_db: The doorbell number to be used by host. Set by guest. 61 * @h2c_vdev_db: The doorbell number to be used by host. Set by guest.
67 */ 62 */
68struct mic_device_ctrl { 63struct mic_device_ctrl {
69 __u64 vdev; 64 __le64 vdev;
70 __u8 config_change; 65 __u8 config_change;
71 __u8 vdev_reset; 66 __u8 vdev_reset;
72 __u8 guest_ack; 67 __u8 guest_ack;
@@ -74,7 +69,7 @@ struct mic_device_ctrl {
74 __u8 used_address_updated; 69 __u8 used_address_updated;
75 __s8 c2h_vdev_db; 70 __s8 c2h_vdev_db;
76 __s8 h2c_vdev_db; 71 __s8 h2c_vdev_db;
77} __aligned(8); 72} __attribute__ ((aligned(8)));
78 73
79/** 74/**
80 * struct mic_bootparam: Virtio device independent information in device page 75 * struct mic_bootparam: Virtio device independent information in device page
@@ -87,13 +82,13 @@ struct mic_device_ctrl {
87 * @shutdown_card: Set to 1 by the host when a card shutdown is initiated 82 * @shutdown_card: Set to 1 by the host when a card shutdown is initiated
88 */ 83 */
89struct mic_bootparam { 84struct mic_bootparam {
90 __u32 magic; 85 __le32 magic;
91 __s8 c2h_shutdown_db; 86 __s8 c2h_shutdown_db;
92 __s8 h2c_shutdown_db; 87 __s8 h2c_shutdown_db;
93 __s8 h2c_config_db; 88 __s8 h2c_config_db;
94 __u8 shutdown_status; 89 __u8 shutdown_status;
95 __u8 shutdown_card; 90 __u8 shutdown_card;
96} __aligned(8); 91} __attribute__ ((aligned(8)));
97 92
98/** 93/**
99 * struct mic_device_page: High level representation of the device page 94 * struct mic_device_page: High level representation of the device page
@@ -116,10 +111,10 @@ struct mic_device_page {
116 * @num: The number of entries in the virtio_ring 111 * @num: The number of entries in the virtio_ring
117 */ 112 */
118struct mic_vqconfig { 113struct mic_vqconfig {
119 __u64 address; 114 __le64 address;
120 __u64 used_address; 115 __le64 used_address;
121 __u16 num; 116 __le16 num;
122} __aligned(8); 117} __attribute__ ((aligned(8)));
123 118
124/* 119/*
125 * The alignment to use between consumer and producer parts of vring. 120 * The alignment to use between consumer and producer parts of vring.
@@ -154,7 +149,7 @@ struct mic_vqconfig {
154 */ 149 */
155struct _mic_vring_info { 150struct _mic_vring_info {
156 __u16 avail_idx; 151 __u16 avail_idx;
157 int magic; 152 __le32 magic;
158}; 153};
159 154
160/** 155/**
@@ -173,15 +168,13 @@ struct mic_vring {
173 int len; 168 int len;
174}; 169};
175 170
176#define mic_aligned_desc_size(d) ALIGN(mic_desc_size(d), 8) 171#define mic_aligned_desc_size(d) __mic_align(mic_desc_size(d), 8)
177 172
178#ifndef INTEL_MIC_CARD 173#ifndef INTEL_MIC_CARD
179static inline unsigned mic_desc_size(const struct mic_device_desc *desc) 174static inline unsigned mic_desc_size(const struct mic_device_desc *desc)
180{ 175{
181 return mic_aligned_size(*desc) 176 return sizeof(*desc) + desc->num_vq * sizeof(struct mic_vqconfig)
182 + desc->num_vq * mic_aligned_size(struct mic_vqconfig) 177 + desc->feature_len * 2 + desc->config_len;
183 + desc->feature_len * 2
184 + desc->config_len;
185} 178}
186 179
187static inline struct mic_vqconfig * 180static inline struct mic_vqconfig *
@@ -201,8 +194,7 @@ static inline __u8 *mic_vq_configspace(const struct mic_device_desc *desc)
201} 194}
202static inline unsigned mic_total_desc_size(struct mic_device_desc *desc) 195static inline unsigned mic_total_desc_size(struct mic_device_desc *desc)
203{ 196{
204 return mic_aligned_desc_size(desc) + 197 return mic_aligned_desc_size(desc) + sizeof(struct mic_device_ctrl);
205 mic_aligned_size(struct mic_device_ctrl);
206} 198}
207#endif 199#endif
208 200
diff --git a/include/uapi/sound/compress_offload.h b/include/uapi/sound/compress_offload.h
index d630163b9a2e..5759810e1c1b 100644
--- a/include/uapi/sound/compress_offload.h
+++ b/include/uapi/sound/compress_offload.h
@@ -30,7 +30,7 @@
30#include <sound/compress_params.h> 30#include <sound/compress_params.h>
31 31
32 32
33#define SNDRV_COMPRESS_VERSION SNDRV_PROTOCOL_VERSION(0, 1, 1) 33#define SNDRV_COMPRESS_VERSION SNDRV_PROTOCOL_VERSION(0, 1, 2)
34/** 34/**
35 * struct snd_compressed_buffer: compressed buffer 35 * struct snd_compressed_buffer: compressed buffer
36 * @fragment_size: size of buffer fragment in bytes 36 * @fragment_size: size of buffer fragment in bytes
@@ -67,8 +67,8 @@ struct snd_compr_params {
67struct snd_compr_tstamp { 67struct snd_compr_tstamp {
68 __u32 byte_offset; 68 __u32 byte_offset;
69 __u32 copied_total; 69 __u32 copied_total;
70 snd_pcm_uframes_t pcm_frames; 70 __u32 pcm_frames;
71 snd_pcm_uframes_t pcm_io_frames; 71 __u32 pcm_io_frames;
72 __u32 sampling_rate; 72 __u32 sampling_rate;
73}; 73};
74 74
diff --git a/kernel/.gitignore b/kernel/.gitignore
index b3097bde4e9c..790d83c7d160 100644
--- a/kernel/.gitignore
+++ b/kernel/.gitignore
@@ -5,3 +5,4 @@ config_data.h
5config_data.gz 5config_data.gz
6timeconst.h 6timeconst.h
7hz.bc 7hz.bc
8x509_certificate_list
diff --git a/kernel/futex.c b/kernel/futex.c
index 80ba086f021d..f6ff0191ecf7 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -251,6 +251,9 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
251 return -EINVAL; 251 return -EINVAL;
252 address -= key->both.offset; 252 address -= key->both.offset;
253 253
254 if (unlikely(!access_ok(rw, uaddr, sizeof(u32))))
255 return -EFAULT;
256
254 /* 257 /*
255 * PROCESS_PRIVATE futexes are fast. 258 * PROCESS_PRIVATE futexes are fast.
256 * As the mm cannot disappear under us and the 'key' only needs 259 * As the mm cannot disappear under us and the 'key' only needs
@@ -259,8 +262,6 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
259 * but access_ok() should be faster than find_vma() 262 * but access_ok() should be faster than find_vma()
260 */ 263 */
261 if (!fshared) { 264 if (!fshared) {
262 if (unlikely(!access_ok(VERIFY_WRITE, uaddr, sizeof(u32))))
263 return -EFAULT;
264 key->private.mm = mm; 265 key->private.mm = mm;
265 key->private.address = address; 266 key->private.address = address;
266 get_futex_key_refs(key); 267 get_futex_key_refs(key);
@@ -288,7 +289,7 @@ again:
288 put_page(page); 289 put_page(page);
289 /* serialize against __split_huge_page_splitting() */ 290 /* serialize against __split_huge_page_splitting() */
290 local_irq_disable(); 291 local_irq_disable();
291 if (likely(__get_user_pages_fast(address, 1, 1, &page) == 1)) { 292 if (likely(__get_user_pages_fast(address, 1, !ro, &page) == 1)) {
292 page_head = compound_head(page); 293 page_head = compound_head(page);
293 /* 294 /*
294 * page_head is valid pointer but we must pin 295 * page_head is valid pointer but we must pin
diff --git a/kernel/kexec.c b/kernel/kexec.c
index 490afc03627e..d0d8fca54065 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -47,6 +47,9 @@ u32 vmcoreinfo_note[VMCOREINFO_NOTE_SIZE/4];
47size_t vmcoreinfo_size; 47size_t vmcoreinfo_size;
48size_t vmcoreinfo_max_size = sizeof(vmcoreinfo_data); 48size_t vmcoreinfo_max_size = sizeof(vmcoreinfo_data);
49 49
50/* Flag to indicate we are going to kexec a new kernel */
51bool kexec_in_progress = false;
52
50/* Location of the reserved area for the crash kernel */ 53/* Location of the reserved area for the crash kernel */
51struct resource crashk_res = { 54struct resource crashk_res = {
52 .name = "Crash kernel", 55 .name = "Crash kernel",
@@ -1675,6 +1678,7 @@ int kernel_kexec(void)
1675 } else 1678 } else
1676#endif 1679#endif
1677 { 1680 {
1681 kexec_in_progress = true;
1678 kernel_restart_prepare(NULL); 1682 kernel_restart_prepare(NULL);
1679 printk(KERN_EMERG "Starting new kernel\n"); 1683 printk(KERN_EMERG "Starting new kernel\n");
1680 machine_shutdown(); 1684 machine_shutdown();
diff --git a/kernel/system_certificates.S b/kernel/system_certificates.S
index 4aef390671cb..3e9868d47535 100644
--- a/kernel/system_certificates.S
+++ b/kernel/system_certificates.S
@@ -3,8 +3,18 @@
3 3
4 __INITRODATA 4 __INITRODATA
5 5
6 .align 8
6 .globl VMLINUX_SYMBOL(system_certificate_list) 7 .globl VMLINUX_SYMBOL(system_certificate_list)
7VMLINUX_SYMBOL(system_certificate_list): 8VMLINUX_SYMBOL(system_certificate_list):
9__cert_list_start:
8 .incbin "kernel/x509_certificate_list" 10 .incbin "kernel/x509_certificate_list"
9 .globl VMLINUX_SYMBOL(system_certificate_list_end) 11__cert_list_end:
10VMLINUX_SYMBOL(system_certificate_list_end): 12
13 .align 8
14 .globl VMLINUX_SYMBOL(system_certificate_list_size)
15VMLINUX_SYMBOL(system_certificate_list_size):
16#ifdef CONFIG_64BIT
17 .quad __cert_list_end - __cert_list_start
18#else
19 .long __cert_list_end - __cert_list_start
20#endif
diff --git a/kernel/system_keyring.c b/kernel/system_keyring.c
index 564dd93430a2..52ebc70263f4 100644
--- a/kernel/system_keyring.c
+++ b/kernel/system_keyring.c
@@ -22,7 +22,7 @@ struct key *system_trusted_keyring;
22EXPORT_SYMBOL_GPL(system_trusted_keyring); 22EXPORT_SYMBOL_GPL(system_trusted_keyring);
23 23
24extern __initconst const u8 system_certificate_list[]; 24extern __initconst const u8 system_certificate_list[];
25extern __initconst const u8 system_certificate_list_end[]; 25extern __initconst const unsigned long system_certificate_list_size;
26 26
27/* 27/*
28 * Load the compiled-in keys 28 * Load the compiled-in keys
@@ -60,8 +60,8 @@ static __init int load_system_certificate_list(void)
60 60
61 pr_notice("Loading compiled-in X.509 certificates\n"); 61 pr_notice("Loading compiled-in X.509 certificates\n");
62 62
63 end = system_certificate_list_end;
64 p = system_certificate_list; 63 p = system_certificate_list;
64 end = p + system_certificate_list_size;
65 while (p < end) { 65 while (p < end) {
66 /* Each cert begins with an ASN.1 SEQUENCE tag and must be more 66 /* Each cert begins with an ASN.1 SEQUENCE tag and must be more
67 * than 256 bytes in size. 67 * than 256 bytes in size.
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index c66912be990f..b010eac595d2 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -2851,19 +2851,6 @@ already_gone:
2851 return false; 2851 return false;
2852} 2852}
2853 2853
2854static bool __flush_work(struct work_struct *work)
2855{
2856 struct wq_barrier barr;
2857
2858 if (start_flush_work(work, &barr)) {
2859 wait_for_completion(&barr.done);
2860 destroy_work_on_stack(&barr.work);
2861 return true;
2862 } else {
2863 return false;
2864 }
2865}
2866
2867/** 2854/**
2868 * flush_work - wait for a work to finish executing the last queueing instance 2855 * flush_work - wait for a work to finish executing the last queueing instance
2869 * @work: the work to flush 2856 * @work: the work to flush
@@ -2877,10 +2864,18 @@ static bool __flush_work(struct work_struct *work)
2877 */ 2864 */
2878bool flush_work(struct work_struct *work) 2865bool flush_work(struct work_struct *work)
2879{ 2866{
2867 struct wq_barrier barr;
2868
2880 lock_map_acquire(&work->lockdep_map); 2869 lock_map_acquire(&work->lockdep_map);
2881 lock_map_release(&work->lockdep_map); 2870 lock_map_release(&work->lockdep_map);
2882 2871
2883 return __flush_work(work); 2872 if (start_flush_work(work, &barr)) {
2873 wait_for_completion(&barr.done);
2874 destroy_work_on_stack(&barr.work);
2875 return true;
2876 } else {
2877 return false;
2878 }
2884} 2879}
2885EXPORT_SYMBOL_GPL(flush_work); 2880EXPORT_SYMBOL_GPL(flush_work);
2886 2881
@@ -4832,14 +4827,7 @@ long work_on_cpu(int cpu, long (*fn)(void *), void *arg)
4832 4827
4833 INIT_WORK_ONSTACK(&wfc.work, work_for_cpu_fn); 4828 INIT_WORK_ONSTACK(&wfc.work, work_for_cpu_fn);
4834 schedule_work_on(cpu, &wfc.work); 4829 schedule_work_on(cpu, &wfc.work);
4835 4830 flush_work(&wfc.work);
4836 /*
4837 * The work item is on-stack and can't lead to deadlock through
4838 * flushing. Use __flush_work() to avoid spurious lockdep warnings
4839 * when work_on_cpu()s are nested.
4840 */
4841 __flush_work(&wfc.work);
4842
4843 return wfc.ret; 4831 return wfc.ret;
4844} 4832}
4845EXPORT_SYMBOL_GPL(work_on_cpu); 4833EXPORT_SYMBOL_GPL(work_on_cpu);
diff --git a/lib/assoc_array.c b/lib/assoc_array.c
index 17edeaf19180..1b6a44f1ec3e 100644
--- a/lib/assoc_array.c
+++ b/lib/assoc_array.c
@@ -759,8 +759,8 @@ all_leaves_cluster_together:
759 pr_devel("all leaves cluster together\n"); 759 pr_devel("all leaves cluster together\n");
760 diff = INT_MAX; 760 diff = INT_MAX;
761 for (i = 0; i < ASSOC_ARRAY_FAN_OUT; i++) { 761 for (i = 0; i < ASSOC_ARRAY_FAN_OUT; i++) {
762 int x = ops->diff_objects(assoc_array_ptr_to_leaf(edit->leaf), 762 int x = ops->diff_objects(assoc_array_ptr_to_leaf(node->slots[i]),
763 assoc_array_ptr_to_leaf(node->slots[i])); 763 index_key);
764 if (x < diff) { 764 if (x < diff) {
765 BUG_ON(x < 0); 765 BUG_ON(x < 0);
766 diff = x; 766 diff = x;
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index bccd5a628ea6..33a5dc492810 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1481,8 +1481,18 @@ int move_huge_pmd(struct vm_area_struct *vma, struct vm_area_struct *new_vma,
1481 pmd = pmdp_get_and_clear(mm, old_addr, old_pmd); 1481 pmd = pmdp_get_and_clear(mm, old_addr, old_pmd);
1482 VM_BUG_ON(!pmd_none(*new_pmd)); 1482 VM_BUG_ON(!pmd_none(*new_pmd));
1483 set_pmd_at(mm, new_addr, new_pmd, pmd_mksoft_dirty(pmd)); 1483 set_pmd_at(mm, new_addr, new_pmd, pmd_mksoft_dirty(pmd));
1484 if (new_ptl != old_ptl) 1484 if (new_ptl != old_ptl) {
1485 pgtable_t pgtable;
1486
1487 /*
1488 * Move preallocated PTE page table if new_pmd is on
1489 * different PMD page table.
1490 */
1491 pgtable = pgtable_trans_huge_withdraw(mm, old_pmd);
1492 pgtable_trans_huge_deposit(mm, new_pmd, pgtable);
1493
1485 spin_unlock(new_ptl); 1494 spin_unlock(new_ptl);
1495 }
1486 spin_unlock(old_ptl); 1496 spin_unlock(old_ptl);
1487 } 1497 }
1488out: 1498out:
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index f1a0ae6e11b8..bf5e89457149 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2694,7 +2694,10 @@ static int __mem_cgroup_try_charge(struct mm_struct *mm,
2694 goto bypass; 2694 goto bypass;
2695 2695
2696 if (unlikely(task_in_memcg_oom(current))) 2696 if (unlikely(task_in_memcg_oom(current)))
2697 goto bypass; 2697 goto nomem;
2698
2699 if (gfp_mask & __GFP_NOFAIL)
2700 oom = false;
2698 2701
2699 /* 2702 /*
2700 * We always charge the cgroup the mm_struct belongs to. 2703 * We always charge the cgroup the mm_struct belongs to.
@@ -6352,6 +6355,42 @@ static void mem_cgroup_css_offline(struct cgroup_subsys_state *css)
6352static void mem_cgroup_css_free(struct cgroup_subsys_state *css) 6355static void mem_cgroup_css_free(struct cgroup_subsys_state *css)
6353{ 6356{
6354 struct mem_cgroup *memcg = mem_cgroup_from_css(css); 6357 struct mem_cgroup *memcg = mem_cgroup_from_css(css);
6358 /*
6359 * XXX: css_offline() would be where we should reparent all
6360 * memory to prepare the cgroup for destruction. However,
6361 * memcg does not do css_tryget() and res_counter charging
6362 * under the same RCU lock region, which means that charging
6363 * could race with offlining. Offlining only happens to
6364 * cgroups with no tasks in them but charges can show up
6365 * without any tasks from the swapin path when the target
6366 * memcg is looked up from the swapout record and not from the
6367 * current task as it usually is. A race like this can leak
6368 * charges and put pages with stale cgroup pointers into
6369 * circulation:
6370 *
6371 * #0 #1
6372 * lookup_swap_cgroup_id()
6373 * rcu_read_lock()
6374 * mem_cgroup_lookup()
6375 * css_tryget()
6376 * rcu_read_unlock()
6377 * disable css_tryget()
6378 * call_rcu()
6379 * offline_css()
6380 * reparent_charges()
6381 * res_counter_charge()
6382 * css_put()
6383 * css_free()
6384 * pc->mem_cgroup = dead memcg
6385 * add page to lru
6386 *
6387 * The bulk of the charges are still moved in offline_css() to
6388 * avoid pinning a lot of pages in case a long-term reference
6389 * like a swapout record is deferring the css_free() to long
6390 * after offlining. But this makes sure we catch any charges
6391 * made after offlining:
6392 */
6393 mem_cgroup_reparent_charges(memcg);
6355 6394
6356 memcg_destroy_kmem(memcg); 6395 memcg_destroy_kmem(memcg);
6357 __mem_cgroup_free(memcg); 6396 __mem_cgroup_free(memcg);
diff --git a/mm/shmem.c b/mm/shmem.c
index 8297623fcaed..902a14842b74 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2918,13 +2918,8 @@ static struct dentry_operations anon_ops = {
2918 .d_dname = simple_dname 2918 .d_dname = simple_dname
2919}; 2919};
2920 2920
2921/** 2921static struct file *__shmem_file_setup(const char *name, loff_t size,
2922 * shmem_file_setup - get an unlinked file living in tmpfs 2922 unsigned long flags, unsigned int i_flags)
2923 * @name: name for dentry (to be seen in /proc/<pid>/maps
2924 * @size: size to be set for the file
2925 * @flags: VM_NORESERVE suppresses pre-accounting of the entire object size
2926 */
2927struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags)
2928{ 2923{
2929 struct file *res; 2924 struct file *res;
2930 struct inode *inode; 2925 struct inode *inode;
@@ -2957,6 +2952,7 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags
2957 if (!inode) 2952 if (!inode)
2958 goto put_dentry; 2953 goto put_dentry;
2959 2954
2955 inode->i_flags |= i_flags;
2960 d_instantiate(path.dentry, inode); 2956 d_instantiate(path.dentry, inode);
2961 inode->i_size = size; 2957 inode->i_size = size;
2962 clear_nlink(inode); /* It is unlinked */ 2958 clear_nlink(inode); /* It is unlinked */
@@ -2977,6 +2973,32 @@ put_memory:
2977 shmem_unacct_size(flags, size); 2973 shmem_unacct_size(flags, size);
2978 return res; 2974 return res;
2979} 2975}
2976
2977/**
2978 * shmem_kernel_file_setup - get an unlinked file living in tmpfs which must be
2979 * kernel internal. There will be NO LSM permission checks against the
2980 * underlying inode. So users of this interface must do LSM checks at a
2981 * higher layer. The one user is the big_key implementation. LSM checks
2982 * are provided at the key level rather than the inode level.
2983 * @name: name for dentry (to be seen in /proc/<pid>/maps
2984 * @size: size to be set for the file
2985 * @flags: VM_NORESERVE suppresses pre-accounting of the entire object size
2986 */
2987struct file *shmem_kernel_file_setup(const char *name, loff_t size, unsigned long flags)
2988{
2989 return __shmem_file_setup(name, size, flags, S_PRIVATE);
2990}
2991
2992/**
2993 * shmem_file_setup - get an unlinked file living in tmpfs
2994 * @name: name for dentry (to be seen in /proc/<pid>/maps
2995 * @size: size to be set for the file
2996 * @flags: VM_NORESERVE suppresses pre-accounting of the entire object size
2997 */
2998struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags)
2999{
3000 return __shmem_file_setup(name, size, flags, 0);
3001}
2980EXPORT_SYMBOL_GPL(shmem_file_setup); 3002EXPORT_SYMBOL_GPL(shmem_file_setup);
2981 3003
2982/** 3004/**
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 229d820bdf0b..045d56eaeca2 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -426,6 +426,16 @@ netdev_features_t br_features_recompute(struct net_bridge *br,
426int br_handle_frame_finish(struct sk_buff *skb); 426int br_handle_frame_finish(struct sk_buff *skb);
427rx_handler_result_t br_handle_frame(struct sk_buff **pskb); 427rx_handler_result_t br_handle_frame(struct sk_buff **pskb);
428 428
429static inline bool br_rx_handler_check_rcu(const struct net_device *dev)
430{
431 return rcu_dereference(dev->rx_handler) == br_handle_frame;
432}
433
434static inline struct net_bridge_port *br_port_get_check_rcu(const struct net_device *dev)
435{
436 return br_rx_handler_check_rcu(dev) ? br_port_get_rcu(dev) : NULL;
437}
438
429/* br_ioctl.c */ 439/* br_ioctl.c */
430int br_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); 440int br_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
431int br_ioctl_deviceless_stub(struct net *net, unsigned int cmd, 441int br_ioctl_deviceless_stub(struct net *net, unsigned int cmd,
diff --git a/net/bridge/br_stp_bpdu.c b/net/bridge/br_stp_bpdu.c
index 8660ea3be705..bdb459d21ad8 100644
--- a/net/bridge/br_stp_bpdu.c
+++ b/net/bridge/br_stp_bpdu.c
@@ -153,7 +153,7 @@ void br_stp_rcv(const struct stp_proto *proto, struct sk_buff *skb,
153 if (buf[0] != 0 || buf[1] != 0 || buf[2] != 0) 153 if (buf[0] != 0 || buf[1] != 0 || buf[2] != 0)
154 goto err; 154 goto err;
155 155
156 p = br_port_get_rcu(dev); 156 p = br_port_get_check_rcu(dev);
157 if (!p) 157 if (!p)
158 goto err; 158 goto err;
159 159
diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c
index 95897183226e..e70301eb7a4a 100644
--- a/net/core/drop_monitor.c
+++ b/net/core/drop_monitor.c
@@ -64,7 +64,6 @@ static struct genl_family net_drop_monitor_family = {
64 .hdrsize = 0, 64 .hdrsize = 0,
65 .name = "NET_DM", 65 .name = "NET_DM",
66 .version = 2, 66 .version = 2,
67 .maxattr = NET_DM_CMD_MAX,
68}; 67};
69 68
70static DEFINE_PER_CPU(struct per_cpu_dm_data, dm_cpu_data); 69static DEFINE_PER_CPU(struct per_cpu_dm_data, dm_cpu_data);
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 2718fed53d8c..06e72d3cdf60 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -3584,6 +3584,7 @@ void skb_scrub_packet(struct sk_buff *skb, bool xnet)
3584 skb->tstamp.tv64 = 0; 3584 skb->tstamp.tv64 = 0;
3585 skb->pkt_type = PACKET_HOST; 3585 skb->pkt_type = PACKET_HOST;
3586 skb->skb_iif = 0; 3586 skb->skb_iif = 0;
3587 skb->local_df = 0;
3587 skb_dst_drop(skb); 3588 skb_dst_drop(skb);
3588 skb->mark = 0; 3589 skb->mark = 0;
3589 secpath_reset(skb); 3590 secpath_reset(skb);
diff --git a/net/core/sock.c b/net/core/sock.c
index ab20ed9b0f31..5393b4b719d7 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -882,7 +882,7 @@ set_rcvbuf:
882 882
883 case SO_PEEK_OFF: 883 case SO_PEEK_OFF:
884 if (sock->ops->set_peek_off) 884 if (sock->ops->set_peek_off)
885 sock->ops->set_peek_off(sk, val); 885 ret = sock->ops->set_peek_off(sk, val);
886 else 886 else
887 ret = -EOPNOTSUPP; 887 ret = -EOPNOTSUPP;
888 break; 888 break;
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index 4ac71ff7c2e4..2b90a786e475 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -851,7 +851,6 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
851 flowlabel = fl6_sock_lookup(sk, fl6.flowlabel); 851 flowlabel = fl6_sock_lookup(sk, fl6.flowlabel);
852 if (flowlabel == NULL) 852 if (flowlabel == NULL)
853 return -EINVAL; 853 return -EINVAL;
854 usin->sin6_addr = flowlabel->dst;
855 fl6_sock_release(flowlabel); 854 fl6_sock_release(flowlabel);
856 } 855 }
857 } 856 }
diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c
index 523be38e37de..f2e15738534d 100644
--- a/net/ipv4/fib_rules.c
+++ b/net/ipv4/fib_rules.c
@@ -104,7 +104,10 @@ errout:
104static bool fib4_rule_suppress(struct fib_rule *rule, struct fib_lookup_arg *arg) 104static bool fib4_rule_suppress(struct fib_rule *rule, struct fib_lookup_arg *arg)
105{ 105{
106 struct fib_result *result = (struct fib_result *) arg->result; 106 struct fib_result *result = (struct fib_result *) arg->result;
107 struct net_device *dev = result->fi->fib_dev; 107 struct net_device *dev = NULL;
108
109 if (result->fi)
110 dev = result->fi->fib_dev;
108 111
109 /* do not accept result if the route does 112 /* do not accept result if the route does
110 * not meet the required prefix length 113 * not meet the required prefix length
diff --git a/net/ipv4/tcp_memcontrol.c b/net/ipv4/tcp_memcontrol.c
index 269a89ecd2f4..f7e522c558ba 100644
--- a/net/ipv4/tcp_memcontrol.c
+++ b/net/ipv4/tcp_memcontrol.c
@@ -6,13 +6,6 @@
6#include <linux/memcontrol.h> 6#include <linux/memcontrol.h>
7#include <linux/module.h> 7#include <linux/module.h>
8 8
9static void memcg_tcp_enter_memory_pressure(struct sock *sk)
10{
11 if (sk->sk_cgrp->memory_pressure)
12 sk->sk_cgrp->memory_pressure = 1;
13}
14EXPORT_SYMBOL(memcg_tcp_enter_memory_pressure);
15
16int tcp_init_cgroup(struct mem_cgroup *memcg, struct cgroup_subsys *ss) 9int tcp_init_cgroup(struct mem_cgroup *memcg, struct cgroup_subsys *ss)
17{ 10{
18 /* 11 /*
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 44f6a20fa29d..62c19fdd102d 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -560,15 +560,11 @@ static inline struct sock *__udp4_lib_lookup_skb(struct sk_buff *skb,
560 __be16 sport, __be16 dport, 560 __be16 sport, __be16 dport,
561 struct udp_table *udptable) 561 struct udp_table *udptable)
562{ 562{
563 struct sock *sk;
564 const struct iphdr *iph = ip_hdr(skb); 563 const struct iphdr *iph = ip_hdr(skb);
565 564
566 if (unlikely(sk = skb_steal_sock(skb))) 565 return __udp4_lib_lookup(dev_net(skb_dst(skb)->dev), iph->saddr, sport,
567 return sk; 566 iph->daddr, dport, inet_iif(skb),
568 else 567 udptable);
569 return __udp4_lib_lookup(dev_net(skb_dst(skb)->dev), iph->saddr, sport,
570 iph->daddr, dport, inet_iif(skb),
571 udptable);
572} 568}
573 569
574struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport, 570struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport,
@@ -1603,12 +1599,21 @@ static void flush_stack(struct sock **stack, unsigned int count,
1603 kfree_skb(skb1); 1599 kfree_skb(skb1);
1604} 1600}
1605 1601
1606static void udp_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb) 1602/* For TCP sockets, sk_rx_dst is protected by socket lock
1603 * For UDP, we use sk_dst_lock to guard against concurrent changes.
1604 */
1605static void udp_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst)
1607{ 1606{
1608 struct dst_entry *dst = skb_dst(skb); 1607 struct dst_entry *old;
1609 1608
1610 dst_hold(dst); 1609 spin_lock(&sk->sk_dst_lock);
1611 sk->sk_rx_dst = dst; 1610 old = sk->sk_rx_dst;
1611 if (likely(old != dst)) {
1612 dst_hold(dst);
1613 sk->sk_rx_dst = dst;
1614 dst_release(old);
1615 }
1616 spin_unlock(&sk->sk_dst_lock);
1612} 1617}
1613 1618
1614/* 1619/*
@@ -1739,15 +1744,16 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
1739 if (udp4_csum_init(skb, uh, proto)) 1744 if (udp4_csum_init(skb, uh, proto))
1740 goto csum_error; 1745 goto csum_error;
1741 1746
1742 if (skb->sk) { 1747 sk = skb_steal_sock(skb);
1748 if (sk) {
1749 struct dst_entry *dst = skb_dst(skb);
1743 int ret; 1750 int ret;
1744 sk = skb->sk;
1745 1751
1746 if (unlikely(sk->sk_rx_dst == NULL)) 1752 if (unlikely(sk->sk_rx_dst != dst))
1747 udp_sk_rx_dst_set(sk, skb); 1753 udp_sk_rx_dst_set(sk, dst);
1748 1754
1749 ret = udp_queue_rcv_skb(sk, skb); 1755 ret = udp_queue_rcv_skb(sk, skb);
1750 1756 sock_put(sk);
1751 /* a return value > 0 means to resubmit the input, but 1757 /* a return value > 0 means to resubmit the input, but
1752 * it wants the return to be -protocol, or 0 1758 * it wants the return to be -protocol, or 0
1753 */ 1759 */
@@ -1913,17 +1919,20 @@ static struct sock *__udp4_lib_demux_lookup(struct net *net,
1913 1919
1914void udp_v4_early_demux(struct sk_buff *skb) 1920void udp_v4_early_demux(struct sk_buff *skb)
1915{ 1921{
1916 const struct iphdr *iph = ip_hdr(skb); 1922 struct net *net = dev_net(skb->dev);
1917 const struct udphdr *uh = udp_hdr(skb); 1923 const struct iphdr *iph;
1924 const struct udphdr *uh;
1918 struct sock *sk; 1925 struct sock *sk;
1919 struct dst_entry *dst; 1926 struct dst_entry *dst;
1920 struct net *net = dev_net(skb->dev);
1921 int dif = skb->dev->ifindex; 1927 int dif = skb->dev->ifindex;
1922 1928
1923 /* validate the packet */ 1929 /* validate the packet */
1924 if (!pskb_may_pull(skb, skb_transport_offset(skb) + sizeof(struct udphdr))) 1930 if (!pskb_may_pull(skb, skb_transport_offset(skb) + sizeof(struct udphdr)))
1925 return; 1931 return;
1926 1932
1933 iph = ip_hdr(skb);
1934 uh = udp_hdr(skb);
1935
1927 if (skb->pkt_type == PACKET_BROADCAST || 1936 if (skb->pkt_type == PACKET_BROADCAST ||
1928 skb->pkt_type == PACKET_MULTICAST) 1937 skb->pkt_type == PACKET_MULTICAST)
1929 sk = __udp4_lib_mcast_demux_lookup(net, uh->dest, iph->daddr, 1938 sk = __udp4_lib_mcast_demux_lookup(net, uh->dest, iph->daddr,
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 12c97d8aa6bb..d5fa5b8c443e 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -2613,7 +2613,7 @@ static void init_loopback(struct net_device *dev)
2613 if (sp_ifa->rt) 2613 if (sp_ifa->rt)
2614 continue; 2614 continue;
2615 2615
2616 sp_rt = addrconf_dst_alloc(idev, &sp_ifa->addr, 0); 2616 sp_rt = addrconf_dst_alloc(idev, &sp_ifa->addr, false);
2617 2617
2618 /* Failure cases are ignored */ 2618 /* Failure cases are ignored */
2619 if (!IS_ERR(sp_rt)) { 2619 if (!IS_ERR(sp_rt)) {
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
index 8dfe1f4d3c1a..93b1aa34c432 100644
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -73,7 +73,6 @@ int ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
73 flowlabel = fl6_sock_lookup(sk, fl6.flowlabel); 73 flowlabel = fl6_sock_lookup(sk, fl6.flowlabel);
74 if (flowlabel == NULL) 74 if (flowlabel == NULL)
75 return -EINVAL; 75 return -EINVAL;
76 usin->sin6_addr = flowlabel->dst;
77 } 76 }
78 } 77 }
79 78
diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c
index e27591635f92..3fd0a578329e 100644
--- a/net/ipv6/fib6_rules.c
+++ b/net/ipv6/fib6_rules.c
@@ -122,7 +122,11 @@ out:
122static bool fib6_rule_suppress(struct fib_rule *rule, struct fib_lookup_arg *arg) 122static bool fib6_rule_suppress(struct fib_rule *rule, struct fib_lookup_arg *arg)
123{ 123{
124 struct rt6_info *rt = (struct rt6_info *) arg->result; 124 struct rt6_info *rt = (struct rt6_info *) arg->result;
125 struct net_device *dev = rt->rt6i_idev->dev; 125 struct net_device *dev = NULL;
126
127 if (rt->rt6i_idev)
128 dev = rt->rt6i_idev->dev;
129
126 /* do not accept result if the route does 130 /* do not accept result if the route does
127 * not meet the required prefix length 131 * not meet the required prefix length
128 */ 132 */
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 3512177deb4d..300865171394 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1277,6 +1277,9 @@ skip_linkparms:
1277 ri->prefix_len == 0) 1277 ri->prefix_len == 0)
1278 continue; 1278 continue;
1279#endif 1279#endif
1280 if (ri->prefix_len == 0 &&
1281 !in6_dev->cnf.accept_ra_defrtr)
1282 continue;
1280 if (ri->prefix_len > in6_dev->cnf.accept_ra_rt_info_max_plen) 1283 if (ri->prefix_len > in6_dev->cnf.accept_ra_rt_info_max_plen)
1281 continue; 1284 continue;
1282 rt6_route_rcv(skb->dev, (u8*)p, (p->nd_opt_len) << 3, 1285 rt6_route_rcv(skb->dev, (u8*)p, (p->nd_opt_len) << 3,
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index 7fb4e14c467f..b6bb87e55805 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -792,7 +792,6 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
792 flowlabel = fl6_sock_lookup(sk, fl6.flowlabel); 792 flowlabel = fl6_sock_lookup(sk, fl6.flowlabel);
793 if (flowlabel == NULL) 793 if (flowlabel == NULL)
794 return -EINVAL; 794 return -EINVAL;
795 daddr = &flowlabel->dst;
796 } 795 }
797 } 796 }
798 797
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 7faa9d5e1503..a0a48ac3403f 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -84,6 +84,8 @@ static int ip6_dst_gc(struct dst_ops *ops);
84 84
85static int ip6_pkt_discard(struct sk_buff *skb); 85static int ip6_pkt_discard(struct sk_buff *skb);
86static int ip6_pkt_discard_out(struct sk_buff *skb); 86static int ip6_pkt_discard_out(struct sk_buff *skb);
87static int ip6_pkt_prohibit(struct sk_buff *skb);
88static int ip6_pkt_prohibit_out(struct sk_buff *skb);
87static void ip6_link_failure(struct sk_buff *skb); 89static void ip6_link_failure(struct sk_buff *skb);
88static void ip6_rt_update_pmtu(struct dst_entry *dst, struct sock *sk, 90static void ip6_rt_update_pmtu(struct dst_entry *dst, struct sock *sk,
89 struct sk_buff *skb, u32 mtu); 91 struct sk_buff *skb, u32 mtu);
@@ -234,9 +236,6 @@ static const struct rt6_info ip6_null_entry_template = {
234 236
235#ifdef CONFIG_IPV6_MULTIPLE_TABLES 237#ifdef CONFIG_IPV6_MULTIPLE_TABLES
236 238
237static int ip6_pkt_prohibit(struct sk_buff *skb);
238static int ip6_pkt_prohibit_out(struct sk_buff *skb);
239
240static const struct rt6_info ip6_prohibit_entry_template = { 239static const struct rt6_info ip6_prohibit_entry_template = {
241 .dst = { 240 .dst = {
242 .__refcnt = ATOMIC_INIT(1), 241 .__refcnt = ATOMIC_INIT(1),
@@ -1565,21 +1564,24 @@ int ip6_route_add(struct fib6_config *cfg)
1565 goto out; 1564 goto out;
1566 } 1565 }
1567 } 1566 }
1568 rt->dst.output = ip6_pkt_discard_out;
1569 rt->dst.input = ip6_pkt_discard;
1570 rt->rt6i_flags = RTF_REJECT|RTF_NONEXTHOP; 1567 rt->rt6i_flags = RTF_REJECT|RTF_NONEXTHOP;
1571 switch (cfg->fc_type) { 1568 switch (cfg->fc_type) {
1572 case RTN_BLACKHOLE: 1569 case RTN_BLACKHOLE:
1573 rt->dst.error = -EINVAL; 1570 rt->dst.error = -EINVAL;
1571 rt->dst.output = dst_discard;
1572 rt->dst.input = dst_discard;
1574 break; 1573 break;
1575 case RTN_PROHIBIT: 1574 case RTN_PROHIBIT:
1576 rt->dst.error = -EACCES; 1575 rt->dst.error = -EACCES;
1576 rt->dst.output = ip6_pkt_prohibit_out;
1577 rt->dst.input = ip6_pkt_prohibit;
1577 break; 1578 break;
1578 case RTN_THROW: 1579 case RTN_THROW:
1579 rt->dst.error = -EAGAIN;
1580 break;
1581 default: 1580 default:
1582 rt->dst.error = -ENETUNREACH; 1581 rt->dst.error = (cfg->fc_type == RTN_THROW) ? -EAGAIN
1582 : -ENETUNREACH;
1583 rt->dst.output = ip6_pkt_discard_out;
1584 rt->dst.input = ip6_pkt_discard;
1583 break; 1585 break;
1584 } 1586 }
1585 goto install_route; 1587 goto install_route;
@@ -2144,8 +2146,6 @@ static int ip6_pkt_discard_out(struct sk_buff *skb)
2144 return ip6_pkt_drop(skb, ICMPV6_NOROUTE, IPSTATS_MIB_OUTNOROUTES); 2146 return ip6_pkt_drop(skb, ICMPV6_NOROUTE, IPSTATS_MIB_OUTNOROUTES);
2145} 2147}
2146 2148
2147#ifdef CONFIG_IPV6_MULTIPLE_TABLES
2148
2149static int ip6_pkt_prohibit(struct sk_buff *skb) 2149static int ip6_pkt_prohibit(struct sk_buff *skb)
2150{ 2150{
2151 return ip6_pkt_drop(skb, ICMPV6_ADM_PROHIBITED, IPSTATS_MIB_INNOROUTES); 2151 return ip6_pkt_drop(skb, ICMPV6_ADM_PROHIBITED, IPSTATS_MIB_INNOROUTES);
@@ -2157,8 +2157,6 @@ static int ip6_pkt_prohibit_out(struct sk_buff *skb)
2157 return ip6_pkt_drop(skb, ICMPV6_ADM_PROHIBITED, IPSTATS_MIB_OUTNOROUTES); 2157 return ip6_pkt_drop(skb, ICMPV6_ADM_PROHIBITED, IPSTATS_MIB_OUTNOROUTES);
2158} 2158}
2159 2159
2160#endif
2161
2162/* 2160/*
2163 * Allocate a dst for local (unicast / anycast) address. 2161 * Allocate a dst for local (unicast / anycast) address.
2164 */ 2162 */
@@ -2168,12 +2166,10 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev,
2168 bool anycast) 2166 bool anycast)
2169{ 2167{
2170 struct net *net = dev_net(idev->dev); 2168 struct net *net = dev_net(idev->dev);
2171 struct rt6_info *rt = ip6_dst_alloc(net, net->loopback_dev, 0, NULL); 2169 struct rt6_info *rt = ip6_dst_alloc(net, net->loopback_dev,
2172 2170 DST_NOCOUNT, NULL);
2173 if (!rt) { 2171 if (!rt)
2174 net_warn_ratelimited("Maximum number of routes reached, consider increasing route/max_size\n");
2175 return ERR_PTR(-ENOMEM); 2172 return ERR_PTR(-ENOMEM);
2176 }
2177 2173
2178 in6_dev_hold(idev); 2174 in6_dev_hold(idev);
2179 2175
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 0740f93a114a..f67033b4bb66 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -156,7 +156,6 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
156 flowlabel = fl6_sock_lookup(sk, fl6.flowlabel); 156 flowlabel = fl6_sock_lookup(sk, fl6.flowlabel);
157 if (flowlabel == NULL) 157 if (flowlabel == NULL)
158 return -EINVAL; 158 return -EINVAL;
159 usin->sin6_addr = flowlabel->dst;
160 fl6_sock_release(flowlabel); 159 fl6_sock_release(flowlabel);
161 } 160 }
162 } 161 }
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index bcd5699313c3..089c741a3992 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -1140,7 +1140,6 @@ do_udp_sendmsg:
1140 flowlabel = fl6_sock_lookup(sk, fl6.flowlabel); 1140 flowlabel = fl6_sock_lookup(sk, fl6.flowlabel);
1141 if (flowlabel == NULL) 1141 if (flowlabel == NULL)
1142 return -EINVAL; 1142 return -EINVAL;
1143 daddr = &flowlabel->dst;
1144 } 1143 }
1145 } 1144 }
1146 1145
diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c
index d9b437e55007..bb6e206ea70b 100644
--- a/net/l2tp/l2tp_ip6.c
+++ b/net/l2tp/l2tp_ip6.c
@@ -528,7 +528,6 @@ static int l2tp_ip6_sendmsg(struct kiocb *iocb, struct sock *sk,
528 flowlabel = fl6_sock_lookup(sk, fl6.flowlabel); 528 flowlabel = fl6_sock_lookup(sk, fl6.flowlabel);
529 if (flowlabel == NULL) 529 if (flowlabel == NULL)
530 return -EINVAL; 530 return -EINVAL;
531 daddr = &flowlabel->dst;
532 } 531 }
533 } 532 }
534 533
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 95667b088c5b..364ce0c5962f 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -1368,7 +1368,7 @@ static int sta_apply_parameters(struct ieee80211_local *local,
1368 changed |= 1368 changed |=
1369 ieee80211_mps_set_sta_local_pm(sta, 1369 ieee80211_mps_set_sta_local_pm(sta,
1370 params->local_pm); 1370 params->local_pm);
1371 ieee80211_bss_info_change_notify(sdata, changed); 1371 ieee80211_mbss_info_change_notify(sdata, changed);
1372#endif 1372#endif
1373 } 1373 }
1374 1374
@@ -2488,8 +2488,7 @@ static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
2488 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 2488 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
2489 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 2489 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
2490 2490
2491 if (sdata->vif.type != NL80211_IFTYPE_STATION && 2491 if (sdata->vif.type != NL80211_IFTYPE_STATION)
2492 sdata->vif.type != NL80211_IFTYPE_MESH_POINT)
2493 return -EOPNOTSUPP; 2492 return -EOPNOTSUPP;
2494 2493
2495 if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS)) 2494 if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS))
@@ -3120,9 +3119,17 @@ static int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
3120 params->chandef.chan->band) 3119 params->chandef.chan->band)
3121 return -EINVAL; 3120 return -EINVAL;
3122 3121
3122 ifmsh->chsw_init = true;
3123 if (!ifmsh->pre_value)
3124 ifmsh->pre_value = 1;
3125 else
3126 ifmsh->pre_value++;
3127
3123 err = ieee80211_mesh_csa_beacon(sdata, params, true); 3128 err = ieee80211_mesh_csa_beacon(sdata, params, true);
3124 if (err < 0) 3129 if (err < 0) {
3130 ifmsh->chsw_init = false;
3125 return err; 3131 return err;
3132 }
3126 break; 3133 break;
3127#endif 3134#endif
3128 default: 3135 default:
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index 531be040b9ae..27a39de89679 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -823,6 +823,10 @@ ieee80211_ibss_process_chanswitch(struct ieee80211_sub_if_data *sdata,
823 if (err) 823 if (err)
824 return false; 824 return false;
825 825
826 /* channel switch is not supported, disconnect */
827 if (!(sdata->local->hw.wiphy->flags & WIPHY_FLAG_HAS_CHANNEL_SWITCH))
828 goto disconnect;
829
826 params.count = csa_ie.count; 830 params.count = csa_ie.count;
827 params.chandef = csa_ie.chandef; 831 params.chandef = csa_ie.chandef;
828 832
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 29dc505be125..4aea4e791113 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1228,6 +1228,7 @@ struct ieee80211_csa_ie {
1228 u8 mode; 1228 u8 mode;
1229 u8 count; 1229 u8 count;
1230 u8 ttl; 1230 u8 ttl;
1231 u16 pre_value;
1231}; 1232};
1232 1233
1233/* Parsed Information Elements */ 1234/* Parsed Information Elements */
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index ff101ea1d9ae..36c3a4cbcabf 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -1325,7 +1325,6 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata,
1325 sdata->vif.bss_conf.bssid = NULL; 1325 sdata->vif.bss_conf.bssid = NULL;
1326 break; 1326 break;
1327 case NL80211_IFTYPE_AP_VLAN: 1327 case NL80211_IFTYPE_AP_VLAN:
1328 break;
1329 case NL80211_IFTYPE_P2P_DEVICE: 1328 case NL80211_IFTYPE_P2P_DEVICE:
1330 sdata->vif.bss_conf.bssid = sdata->vif.addr; 1329 sdata->vif.bss_conf.bssid = sdata->vif.addr;
1331 break; 1330 break;
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index 21d5d44444d0..7d1c3ac48ed9 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -940,6 +940,8 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
940 wiphy_debug(local->hw.wiphy, "Failed to initialize wep: %d\n", 940 wiphy_debug(local->hw.wiphy, "Failed to initialize wep: %d\n",
941 result); 941 result);
942 942
943 local->hw.conf.flags = IEEE80211_CONF_IDLE;
944
943 ieee80211_led_init(local); 945 ieee80211_led_init(local);
944 946
945 rtnl_lock(); 947 rtnl_lock();
@@ -1047,6 +1049,7 @@ void ieee80211_unregister_hw(struct ieee80211_hw *hw)
1047 1049
1048 cancel_work_sync(&local->restart_work); 1050 cancel_work_sync(&local->restart_work);
1049 cancel_work_sync(&local->reconfig_filter); 1051 cancel_work_sync(&local->reconfig_filter);
1052 flush_work(&local->sched_scan_stopped_work);
1050 1053
1051 ieee80211_clear_tx_pending(local); 1054 ieee80211_clear_tx_pending(local);
1052 rate_control_deinitialize(local); 1055 rate_control_deinitialize(local);
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 896fe3bd599e..ba105257d03f 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -943,14 +943,19 @@ ieee80211_mesh_process_chnswitch(struct ieee80211_sub_if_data *sdata,
943 params.chandef.chan->center_freq); 943 params.chandef.chan->center_freq);
944 944
945 params.block_tx = csa_ie.mode & WLAN_EID_CHAN_SWITCH_PARAM_TX_RESTRICT; 945 params.block_tx = csa_ie.mode & WLAN_EID_CHAN_SWITCH_PARAM_TX_RESTRICT;
946 if (beacon) 946 if (beacon) {
947 ifmsh->chsw_ttl = csa_ie.ttl - 1; 947 ifmsh->chsw_ttl = csa_ie.ttl - 1;
948 else 948 if (ifmsh->pre_value >= csa_ie.pre_value)
949 ifmsh->chsw_ttl = 0; 949 return false;
950 ifmsh->pre_value = csa_ie.pre_value;
951 }
950 952
951 if (ifmsh->chsw_ttl > 0) 953 if (ifmsh->chsw_ttl < ifmsh->mshcfg.dot11MeshTTL) {
952 if (ieee80211_mesh_csa_beacon(sdata, &params, false) < 0) 954 if (ieee80211_mesh_csa_beacon(sdata, &params, false) < 0)
953 return false; 955 return false;
956 } else {
957 return false;
958 }
954 959
955 sdata->csa_radar_required = params.radar_required; 960 sdata->csa_radar_required = params.radar_required;
956 961
@@ -1163,7 +1168,6 @@ static int mesh_fwd_csa_frame(struct ieee80211_sub_if_data *sdata,
1163 offset_ttl = (len < 42) ? 7 : 10; 1168 offset_ttl = (len < 42) ? 7 : 10;
1164 *(pos + offset_ttl) -= 1; 1169 *(pos + offset_ttl) -= 1;
1165 *(pos + offset_ttl + 1) &= ~WLAN_EID_CHAN_SWITCH_PARAM_INITIATOR; 1170 *(pos + offset_ttl + 1) &= ~WLAN_EID_CHAN_SWITCH_PARAM_INITIATOR;
1166 sdata->u.mesh.chsw_ttl = *(pos + offset_ttl);
1167 1171
1168 memcpy(mgmt_fwd, mgmt, len); 1172 memcpy(mgmt_fwd, mgmt, len);
1169 eth_broadcast_addr(mgmt_fwd->da); 1173 eth_broadcast_addr(mgmt_fwd->da);
@@ -1182,7 +1186,7 @@ static void mesh_rx_csa_frame(struct ieee80211_sub_if_data *sdata,
1182 u16 pre_value; 1186 u16 pre_value;
1183 bool fwd_csa = true; 1187 bool fwd_csa = true;
1184 size_t baselen; 1188 size_t baselen;
1185 u8 *pos, ttl; 1189 u8 *pos;
1186 1190
1187 if (mgmt->u.action.u.measurement.action_code != 1191 if (mgmt->u.action.u.measurement.action_code !=
1188 WLAN_ACTION_SPCT_CHL_SWITCH) 1192 WLAN_ACTION_SPCT_CHL_SWITCH)
@@ -1193,8 +1197,8 @@ static void mesh_rx_csa_frame(struct ieee80211_sub_if_data *sdata,
1193 u.action.u.chan_switch.variable); 1197 u.action.u.chan_switch.variable);
1194 ieee802_11_parse_elems(pos, len - baselen, false, &elems); 1198 ieee802_11_parse_elems(pos, len - baselen, false, &elems);
1195 1199
1196 ttl = elems.mesh_chansw_params_ie->mesh_ttl; 1200 ifmsh->chsw_ttl = elems.mesh_chansw_params_ie->mesh_ttl;
1197 if (!--ttl) 1201 if (!--ifmsh->chsw_ttl)
1198 fwd_csa = false; 1202 fwd_csa = false;
1199 1203
1200 pre_value = le16_to_cpu(elems.mesh_chansw_params_ie->mesh_pre_value); 1204 pre_value = le16_to_cpu(elems.mesh_chansw_params_ie->mesh_pre_value);
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index d7504ab61a34..b3a3ce316656 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -1910,6 +1910,8 @@ static void ieee80211_mgd_probe_ap(struct ieee80211_sub_if_data *sdata,
1910 if (ifmgd->flags & IEEE80211_STA_CONNECTION_POLL) 1910 if (ifmgd->flags & IEEE80211_STA_CONNECTION_POLL)
1911 already = true; 1911 already = true;
1912 1912
1913 ifmgd->flags |= IEEE80211_STA_CONNECTION_POLL;
1914
1913 mutex_unlock(&sdata->local->mtx); 1915 mutex_unlock(&sdata->local->mtx);
1914 1916
1915 if (already) 1917 if (already)
diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c
index 5d60779a0c1b..4096ff6cc24f 100644
--- a/net/mac80211/rc80211_minstrel_ht.c
+++ b/net/mac80211/rc80211_minstrel_ht.c
@@ -226,7 +226,7 @@ minstrel_ht_calc_tp(struct minstrel_ht_sta *mi, int group, int rate)
226 nsecs = 1000 * mi->overhead / MINSTREL_TRUNC(mi->avg_ampdu_len); 226 nsecs = 1000 * mi->overhead / MINSTREL_TRUNC(mi->avg_ampdu_len);
227 227
228 nsecs += minstrel_mcs_groups[group].duration[rate]; 228 nsecs += minstrel_mcs_groups[group].duration[rate];
229 tp = 1000000 * ((mr->probability * 1000) / nsecs); 229 tp = 1000000 * ((prob * 1000) / nsecs);
230 230
231 mr->cur_tp = MINSTREL_TRUNC(tp); 231 mr->cur_tp = MINSTREL_TRUNC(tp);
232} 232}
@@ -277,13 +277,15 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
277 if (!(mg->supported & BIT(i))) 277 if (!(mg->supported & BIT(i)))
278 continue; 278 continue;
279 279
280 index = MCS_GROUP_RATES * group + i;
281
280 /* initialize rates selections starting indexes */ 282 /* initialize rates selections starting indexes */
281 if (!mg_rates_valid) { 283 if (!mg_rates_valid) {
282 mg->max_tp_rate = mg->max_tp_rate2 = 284 mg->max_tp_rate = mg->max_tp_rate2 =
283 mg->max_prob_rate = i; 285 mg->max_prob_rate = i;
284 if (!mi_rates_valid) { 286 if (!mi_rates_valid) {
285 mi->max_tp_rate = mi->max_tp_rate2 = 287 mi->max_tp_rate = mi->max_tp_rate2 =
286 mi->max_prob_rate = i; 288 mi->max_prob_rate = index;
287 mi_rates_valid = true; 289 mi_rates_valid = true;
288 } 290 }
289 mg_rates_valid = true; 291 mg_rates_valid = true;
@@ -291,7 +293,6 @@ minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
291 293
292 mr = &mg->rates[i]; 294 mr = &mg->rates[i];
293 mr->retry_updated = false; 295 mr->retry_updated = false;
294 index = MCS_GROUP_RATES * group + i;
295 minstrel_calc_rate_ewma(mr); 296 minstrel_calc_rate_ewma(mr);
296 minstrel_ht_calc_tp(mi, group, i); 297 minstrel_ht_calc_tp(mi, group, i);
297 298
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index caecef870c0e..2b0debb0422b 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -911,7 +911,8 @@ static void ieee80211_rx_reorder_ampdu(struct ieee80211_rx_data *rx,
911 u16 sc; 911 u16 sc;
912 u8 tid, ack_policy; 912 u8 tid, ack_policy;
913 913
914 if (!ieee80211_is_data_qos(hdr->frame_control)) 914 if (!ieee80211_is_data_qos(hdr->frame_control) ||
915 is_multicast_ether_addr(hdr->addr1))
915 goto dont_reorder; 916 goto dont_reorder;
916 917
917 /* 918 /*
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index 5ad66a83ef7f..bcc4833d7542 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -1088,6 +1088,6 @@ void ieee80211_sched_scan_stopped(struct ieee80211_hw *hw)
1088 1088
1089 trace_api_sched_scan_stopped(local); 1089 trace_api_sched_scan_stopped(local);
1090 1090
1091 ieee80211_queue_work(&local->hw, &local->sched_scan_stopped_work); 1091 schedule_work(&local->sched_scan_stopped_work);
1092} 1092}
1093EXPORT_SYMBOL(ieee80211_sched_scan_stopped); 1093EXPORT_SYMBOL(ieee80211_sched_scan_stopped);
diff --git a/net/mac80211/spectmgmt.c b/net/mac80211/spectmgmt.c
index a40da20b32e0..6ab009070084 100644
--- a/net/mac80211/spectmgmt.c
+++ b/net/mac80211/spectmgmt.c
@@ -78,6 +78,8 @@ int ieee80211_parse_ch_switch_ie(struct ieee80211_sub_if_data *sdata,
78 if (elems->mesh_chansw_params_ie) { 78 if (elems->mesh_chansw_params_ie) {
79 csa_ie->ttl = elems->mesh_chansw_params_ie->mesh_ttl; 79 csa_ie->ttl = elems->mesh_chansw_params_ie->mesh_ttl;
80 csa_ie->mode = elems->mesh_chansw_params_ie->mesh_flags; 80 csa_ie->mode = elems->mesh_chansw_params_ie->mesh_flags;
81 csa_ie->pre_value = le16_to_cpu(
82 elems->mesh_chansw_params_ie->mesh_pre_value);
81 } 83 }
82 84
83 new_freq = ieee80211_channel_to_frequency(new_chan_no, new_band); 85 new_freq = ieee80211_channel_to_frequency(new_chan_no, new_band);
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 592a18171f95..9f9b9bd3fd44 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -2278,17 +2278,15 @@ void ieee80211_dfs_radar_detected_work(struct work_struct *work)
2278{ 2278{
2279 struct ieee80211_local *local = 2279 struct ieee80211_local *local =
2280 container_of(work, struct ieee80211_local, radar_detected_work); 2280 container_of(work, struct ieee80211_local, radar_detected_work);
2281 struct cfg80211_chan_def chandef; 2281 struct cfg80211_chan_def chandef = local->hw.conf.chandef;
2282 2282
2283 ieee80211_dfs_cac_cancel(local); 2283 ieee80211_dfs_cac_cancel(local);
2284 2284
2285 if (local->use_chanctx) 2285 if (local->use_chanctx)
2286 /* currently not handled */ 2286 /* currently not handled */
2287 WARN_ON(1); 2287 WARN_ON(1);
2288 else { 2288 else
2289 chandef = local->hw.conf.chandef;
2290 cfg80211_radar_event(local->hw.wiphy, &chandef, GFP_KERNEL); 2289 cfg80211_radar_event(local->hw.wiphy, &chandef, GFP_KERNEL);
2291 }
2292} 2290}
2293 2291
2294void ieee80211_radar_detected(struct ieee80211_hw *hw) 2292void ieee80211_radar_detected(struct ieee80211_hw *hw)
@@ -2459,14 +2457,9 @@ int ieee80211_send_action_csa(struct ieee80211_sub_if_data *sdata,
2459 WLAN_EID_CHAN_SWITCH_PARAM_TX_RESTRICT : 0x00; 2457 WLAN_EID_CHAN_SWITCH_PARAM_TX_RESTRICT : 0x00;
2460 put_unaligned_le16(WLAN_REASON_MESH_CHAN, pos); /* Reason Cd */ 2458 put_unaligned_le16(WLAN_REASON_MESH_CHAN, pos); /* Reason Cd */
2461 pos += 2; 2459 pos += 2;
2462 if (!ifmsh->pre_value)
2463 ifmsh->pre_value = 1;
2464 else
2465 ifmsh->pre_value++;
2466 pre_value = cpu_to_le16(ifmsh->pre_value); 2460 pre_value = cpu_to_le16(ifmsh->pre_value);
2467 memcpy(pos, &pre_value, 2); /* Precedence Value */ 2461 memcpy(pos, &pre_value, 2); /* Precedence Value */
2468 pos += 2; 2462 pos += 2;
2469 ifmsh->chsw_init = true;
2470 } 2463 }
2471 2464
2472 ieee80211_tx_skb(sdata, skb); 2465 ieee80211_tx_skb(sdata, skb);
diff --git a/net/netfilter/ipset/ip_set_hash_netnet.c b/net/netfilter/ipset/ip_set_hash_netnet.c
index 2bc2dec20b00..6226803fc490 100644
--- a/net/netfilter/ipset/ip_set_hash_netnet.c
+++ b/net/netfilter/ipset/ip_set_hash_netnet.c
@@ -59,7 +59,7 @@ hash_netnet4_data_equal(const struct hash_netnet4_elem *ip1,
59 u32 *multi) 59 u32 *multi)
60{ 60{
61 return ip1->ipcmp == ip2->ipcmp && 61 return ip1->ipcmp == ip2->ipcmp &&
62 ip2->ccmp == ip2->ccmp; 62 ip1->ccmp == ip2->ccmp;
63} 63}
64 64
65static inline int 65static inline int
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index dcddc49c0e08..f93b7d06f4be 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -1717,6 +1717,19 @@ nf_tables_delrule_one(struct nft_ctx *ctx, struct nft_rule *rule)
1717 return -ENOENT; 1717 return -ENOENT;
1718} 1718}
1719 1719
1720static int nf_table_delrule_by_chain(struct nft_ctx *ctx)
1721{
1722 struct nft_rule *rule;
1723 int err;
1724
1725 list_for_each_entry(rule, &ctx->chain->rules, list) {
1726 err = nf_tables_delrule_one(ctx, rule);
1727 if (err < 0)
1728 return err;
1729 }
1730 return 0;
1731}
1732
1720static int nf_tables_delrule(struct sock *nlsk, struct sk_buff *skb, 1733static int nf_tables_delrule(struct sock *nlsk, struct sk_buff *skb,
1721 const struct nlmsghdr *nlh, 1734 const struct nlmsghdr *nlh,
1722 const struct nlattr * const nla[]) 1735 const struct nlattr * const nla[])
@@ -1725,8 +1738,8 @@ static int nf_tables_delrule(struct sock *nlsk, struct sk_buff *skb,
1725 const struct nft_af_info *afi; 1738 const struct nft_af_info *afi;
1726 struct net *net = sock_net(skb->sk); 1739 struct net *net = sock_net(skb->sk);
1727 const struct nft_table *table; 1740 const struct nft_table *table;
1728 struct nft_chain *chain; 1741 struct nft_chain *chain = NULL;
1729 struct nft_rule *rule, *tmp; 1742 struct nft_rule *rule;
1730 int family = nfmsg->nfgen_family, err = 0; 1743 int family = nfmsg->nfgen_family, err = 0;
1731 struct nft_ctx ctx; 1744 struct nft_ctx ctx;
1732 1745
@@ -1738,22 +1751,29 @@ static int nf_tables_delrule(struct sock *nlsk, struct sk_buff *skb,
1738 if (IS_ERR(table)) 1751 if (IS_ERR(table))
1739 return PTR_ERR(table); 1752 return PTR_ERR(table);
1740 1753
1741 chain = nf_tables_chain_lookup(table, nla[NFTA_RULE_CHAIN]); 1754 if (nla[NFTA_RULE_CHAIN]) {
1742 if (IS_ERR(chain)) 1755 chain = nf_tables_chain_lookup(table, nla[NFTA_RULE_CHAIN]);
1743 return PTR_ERR(chain); 1756 if (IS_ERR(chain))
1757 return PTR_ERR(chain);
1758 }
1744 1759
1745 nft_ctx_init(&ctx, skb, nlh, afi, table, chain, nla); 1760 nft_ctx_init(&ctx, skb, nlh, afi, table, chain, nla);
1746 1761
1747 if (nla[NFTA_RULE_HANDLE]) { 1762 if (chain) {
1748 rule = nf_tables_rule_lookup(chain, nla[NFTA_RULE_HANDLE]); 1763 if (nla[NFTA_RULE_HANDLE]) {
1749 if (IS_ERR(rule)) 1764 rule = nf_tables_rule_lookup(chain,
1750 return PTR_ERR(rule); 1765 nla[NFTA_RULE_HANDLE]);
1766 if (IS_ERR(rule))
1767 return PTR_ERR(rule);
1751 1768
1752 err = nf_tables_delrule_one(&ctx, rule);
1753 } else {
1754 /* Remove all rules in this chain */
1755 list_for_each_entry_safe(rule, tmp, &chain->rules, list) {
1756 err = nf_tables_delrule_one(&ctx, rule); 1769 err = nf_tables_delrule_one(&ctx, rule);
1770 } else {
1771 err = nf_table_delrule_by_chain(&ctx);
1772 }
1773 } else {
1774 list_for_each_entry(chain, &table->chains, list) {
1775 ctx.chain = chain;
1776 err = nf_table_delrule_by_chain(&ctx);
1757 if (err < 0) 1777 if (err < 0)
1758 break; 1778 break;
1759 } 1779 }
diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
index 9ff035c71403..a3910fc2122b 100644
--- a/net/netfilter/xt_hashlimit.c
+++ b/net/netfilter/xt_hashlimit.c
@@ -325,21 +325,24 @@ static void htable_gc(unsigned long htlong)
325 add_timer(&ht->timer); 325 add_timer(&ht->timer);
326} 326}
327 327
328static void htable_destroy(struct xt_hashlimit_htable *hinfo) 328static void htable_remove_proc_entry(struct xt_hashlimit_htable *hinfo)
329{ 329{
330 struct hashlimit_net *hashlimit_net = hashlimit_pernet(hinfo->net); 330 struct hashlimit_net *hashlimit_net = hashlimit_pernet(hinfo->net);
331 struct proc_dir_entry *parent; 331 struct proc_dir_entry *parent;
332 332
333 del_timer_sync(&hinfo->timer);
334
335 if (hinfo->family == NFPROTO_IPV4) 333 if (hinfo->family == NFPROTO_IPV4)
336 parent = hashlimit_net->ipt_hashlimit; 334 parent = hashlimit_net->ipt_hashlimit;
337 else 335 else
338 parent = hashlimit_net->ip6t_hashlimit; 336 parent = hashlimit_net->ip6t_hashlimit;
339 337
340 if(parent != NULL) 338 if (parent != NULL)
341 remove_proc_entry(hinfo->name, parent); 339 remove_proc_entry(hinfo->name, parent);
340}
342 341
342static void htable_destroy(struct xt_hashlimit_htable *hinfo)
343{
344 del_timer_sync(&hinfo->timer);
345 htable_remove_proc_entry(hinfo);
343 htable_selective_cleanup(hinfo, select_all); 346 htable_selective_cleanup(hinfo, select_all);
344 kfree(hinfo->name); 347 kfree(hinfo->name);
345 vfree(hinfo); 348 vfree(hinfo);
@@ -883,21 +886,15 @@ static int __net_init hashlimit_proc_net_init(struct net *net)
883static void __net_exit hashlimit_proc_net_exit(struct net *net) 886static void __net_exit hashlimit_proc_net_exit(struct net *net)
884{ 887{
885 struct xt_hashlimit_htable *hinfo; 888 struct xt_hashlimit_htable *hinfo;
886 struct proc_dir_entry *pde;
887 struct hashlimit_net *hashlimit_net = hashlimit_pernet(net); 889 struct hashlimit_net *hashlimit_net = hashlimit_pernet(net);
888 890
889 /* recent_net_exit() is called before recent_mt_destroy(). Make sure 891 /* hashlimit_net_exit() is called before hashlimit_mt_destroy().
890 * that the parent xt_recent proc entry is is empty before trying to 892 * Make sure that the parent ipt_hashlimit and ip6t_hashlimit proc
891 * remove it. 893 * entries is empty before trying to remove it.
892 */ 894 */
893 mutex_lock(&hashlimit_mutex); 895 mutex_lock(&hashlimit_mutex);
894 pde = hashlimit_net->ipt_hashlimit;
895 if (pde == NULL)
896 pde = hashlimit_net->ip6t_hashlimit;
897
898 hlist_for_each_entry(hinfo, &hashlimit_net->htables, node) 896 hlist_for_each_entry(hinfo, &hashlimit_net->htables, node)
899 remove_proc_entry(hinfo->name, pde); 897 htable_remove_proc_entry(hinfo);
900
901 hashlimit_net->ipt_hashlimit = NULL; 898 hashlimit_net->ipt_hashlimit = NULL;
902 hashlimit_net->ip6t_hashlimit = NULL; 899 hashlimit_net->ip6t_hashlimit = NULL;
903 mutex_unlock(&hashlimit_mutex); 900 mutex_unlock(&hashlimit_mutex);
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index ba2548bd85bf..88cfbc189558 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -237,6 +237,30 @@ struct packet_skb_cb {
237static void __fanout_unlink(struct sock *sk, struct packet_sock *po); 237static void __fanout_unlink(struct sock *sk, struct packet_sock *po);
238static void __fanout_link(struct sock *sk, struct packet_sock *po); 238static void __fanout_link(struct sock *sk, struct packet_sock *po);
239 239
240static struct net_device *packet_cached_dev_get(struct packet_sock *po)
241{
242 struct net_device *dev;
243
244 rcu_read_lock();
245 dev = rcu_dereference(po->cached_dev);
246 if (likely(dev))
247 dev_hold(dev);
248 rcu_read_unlock();
249
250 return dev;
251}
252
253static void packet_cached_dev_assign(struct packet_sock *po,
254 struct net_device *dev)
255{
256 rcu_assign_pointer(po->cached_dev, dev);
257}
258
259static void packet_cached_dev_reset(struct packet_sock *po)
260{
261 RCU_INIT_POINTER(po->cached_dev, NULL);
262}
263
240/* register_prot_hook must be invoked with the po->bind_lock held, 264/* register_prot_hook must be invoked with the po->bind_lock held,
241 * or from a context in which asynchronous accesses to the packet 265 * or from a context in which asynchronous accesses to the packet
242 * socket is not possible (packet_create()). 266 * socket is not possible (packet_create()).
@@ -246,12 +270,10 @@ static void register_prot_hook(struct sock *sk)
246 struct packet_sock *po = pkt_sk(sk); 270 struct packet_sock *po = pkt_sk(sk);
247 271
248 if (!po->running) { 272 if (!po->running) {
249 if (po->fanout) { 273 if (po->fanout)
250 __fanout_link(sk, po); 274 __fanout_link(sk, po);
251 } else { 275 else
252 dev_add_pack(&po->prot_hook); 276 dev_add_pack(&po->prot_hook);
253 rcu_assign_pointer(po->cached_dev, po->prot_hook.dev);
254 }
255 277
256 sock_hold(sk); 278 sock_hold(sk);
257 po->running = 1; 279 po->running = 1;
@@ -270,12 +292,11 @@ static void __unregister_prot_hook(struct sock *sk, bool sync)
270 struct packet_sock *po = pkt_sk(sk); 292 struct packet_sock *po = pkt_sk(sk);
271 293
272 po->running = 0; 294 po->running = 0;
273 if (po->fanout) { 295
296 if (po->fanout)
274 __fanout_unlink(sk, po); 297 __fanout_unlink(sk, po);
275 } else { 298 else
276 __dev_remove_pack(&po->prot_hook); 299 __dev_remove_pack(&po->prot_hook);
277 RCU_INIT_POINTER(po->cached_dev, NULL);
278 }
279 300
280 __sock_put(sk); 301 __sock_put(sk);
281 302
@@ -2059,19 +2080,6 @@ static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb,
2059 return tp_len; 2080 return tp_len;
2060} 2081}
2061 2082
2062static struct net_device *packet_cached_dev_get(struct packet_sock *po)
2063{
2064 struct net_device *dev;
2065
2066 rcu_read_lock();
2067 dev = rcu_dereference(po->cached_dev);
2068 if (dev)
2069 dev_hold(dev);
2070 rcu_read_unlock();
2071
2072 return dev;
2073}
2074
2075static int tpacket_snd(struct packet_sock *po, struct msghdr *msg) 2083static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
2076{ 2084{
2077 struct sk_buff *skb; 2085 struct sk_buff *skb;
@@ -2088,7 +2096,7 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
2088 2096
2089 mutex_lock(&po->pg_vec_lock); 2097 mutex_lock(&po->pg_vec_lock);
2090 2098
2091 if (saddr == NULL) { 2099 if (likely(saddr == NULL)) {
2092 dev = packet_cached_dev_get(po); 2100 dev = packet_cached_dev_get(po);
2093 proto = po->num; 2101 proto = po->num;
2094 addr = NULL; 2102 addr = NULL;
@@ -2242,7 +2250,7 @@ static int packet_snd(struct socket *sock,
2242 * Get and verify the address. 2250 * Get and verify the address.
2243 */ 2251 */
2244 2252
2245 if (saddr == NULL) { 2253 if (likely(saddr == NULL)) {
2246 dev = packet_cached_dev_get(po); 2254 dev = packet_cached_dev_get(po);
2247 proto = po->num; 2255 proto = po->num;
2248 addr = NULL; 2256 addr = NULL;
@@ -2451,6 +2459,8 @@ static int packet_release(struct socket *sock)
2451 2459
2452 spin_lock(&po->bind_lock); 2460 spin_lock(&po->bind_lock);
2453 unregister_prot_hook(sk, false); 2461 unregister_prot_hook(sk, false);
2462 packet_cached_dev_reset(po);
2463
2454 if (po->prot_hook.dev) { 2464 if (po->prot_hook.dev) {
2455 dev_put(po->prot_hook.dev); 2465 dev_put(po->prot_hook.dev);
2456 po->prot_hook.dev = NULL; 2466 po->prot_hook.dev = NULL;
@@ -2506,14 +2516,17 @@ static int packet_do_bind(struct sock *sk, struct net_device *dev, __be16 protoc
2506 2516
2507 spin_lock(&po->bind_lock); 2517 spin_lock(&po->bind_lock);
2508 unregister_prot_hook(sk, true); 2518 unregister_prot_hook(sk, true);
2519
2509 po->num = protocol; 2520 po->num = protocol;
2510 po->prot_hook.type = protocol; 2521 po->prot_hook.type = protocol;
2511 if (po->prot_hook.dev) 2522 if (po->prot_hook.dev)
2512 dev_put(po->prot_hook.dev); 2523 dev_put(po->prot_hook.dev);
2513 po->prot_hook.dev = dev;
2514 2524
2525 po->prot_hook.dev = dev;
2515 po->ifindex = dev ? dev->ifindex : 0; 2526 po->ifindex = dev ? dev->ifindex : 0;
2516 2527
2528 packet_cached_dev_assign(po, dev);
2529
2517 if (protocol == 0) 2530 if (protocol == 0)
2518 goto out_unlock; 2531 goto out_unlock;
2519 2532
@@ -2626,7 +2639,8 @@ static int packet_create(struct net *net, struct socket *sock, int protocol,
2626 po = pkt_sk(sk); 2639 po = pkt_sk(sk);
2627 sk->sk_family = PF_PACKET; 2640 sk->sk_family = PF_PACKET;
2628 po->num = proto; 2641 po->num = proto;
2629 RCU_INIT_POINTER(po->cached_dev, NULL); 2642
2643 packet_cached_dev_reset(po);
2630 2644
2631 sk->sk_destruct = packet_sock_destruct; 2645 sk->sk_destruct = packet_sock_destruct;
2632 sk_refcnt_debug_inc(sk); 2646 sk_refcnt_debug_inc(sk);
@@ -3337,6 +3351,7 @@ static int packet_notifier(struct notifier_block *this,
3337 sk->sk_error_report(sk); 3351 sk->sk_error_report(sk);
3338 } 3352 }
3339 if (msg == NETDEV_UNREGISTER) { 3353 if (msg == NETDEV_UNREGISTER) {
3354 packet_cached_dev_reset(po);
3340 po->ifindex = -1; 3355 po->ifindex = -1;
3341 if (po->prot_hook.dev) 3356 if (po->prot_hook.dev)
3342 dev_put(po->prot_hook.dev); 3357 dev_put(po->prot_hook.dev);
diff --git a/net/rds/ib_send.c b/net/rds/ib_send.c
index e59094981175..37be6e226d1b 100644
--- a/net/rds/ib_send.c
+++ b/net/rds/ib_send.c
@@ -552,9 +552,8 @@ int rds_ib_xmit(struct rds_connection *conn, struct rds_message *rm,
552 && rm->m_inc.i_hdr.h_flags & RDS_FLAG_CONG_BITMAP) { 552 && rm->m_inc.i_hdr.h_flags & RDS_FLAG_CONG_BITMAP) {
553 rds_cong_map_updated(conn->c_fcong, ~(u64) 0); 553 rds_cong_map_updated(conn->c_fcong, ~(u64) 0);
554 scat = &rm->data.op_sg[sg]; 554 scat = &rm->data.op_sg[sg];
555 ret = sizeof(struct rds_header) + RDS_CONG_MAP_BYTES; 555 ret = max_t(int, RDS_CONG_MAP_BYTES, scat->length);
556 ret = min_t(int, ret, scat->length - conn->c_xmit_data_off); 556 return sizeof(struct rds_header) + ret;
557 return ret;
558 } 557 }
559 558
560 /* FIXME we may overallocate here */ 559 /* FIXME we may overallocate here */
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index fd7072827a40..69cb848e8345 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -270,6 +270,16 @@ int tcf_register_action(struct tc_action_ops *act)
270{ 270{
271 struct tc_action_ops *a, **ap; 271 struct tc_action_ops *a, **ap;
272 272
273 /* Must supply act, dump, cleanup and init */
274 if (!act->act || !act->dump || !act->cleanup || !act->init)
275 return -EINVAL;
276
277 /* Supply defaults */
278 if (!act->lookup)
279 act->lookup = tcf_hash_search;
280 if (!act->walk)
281 act->walk = tcf_generic_walker;
282
273 write_lock(&act_mod_lock); 283 write_lock(&act_mod_lock);
274 for (ap = &act_base; (a = *ap) != NULL; ap = &a->next) { 284 for (ap = &act_base; (a = *ap) != NULL; ap = &a->next) {
275 if (act->type == a->type || (strcmp(act->kind, a->kind) == 0)) { 285 if (act->type == a->type || (strcmp(act->kind, a->kind) == 0)) {
@@ -381,7 +391,7 @@ int tcf_action_exec(struct sk_buff *skb, const struct tc_action *act,
381 } 391 }
382 while ((a = act) != NULL) { 392 while ((a = act) != NULL) {
383repeat: 393repeat:
384 if (a->ops && a->ops->act) { 394 if (a->ops) {
385 ret = a->ops->act(skb, a, res); 395 ret = a->ops->act(skb, a, res);
386 if (TC_MUNGED & skb->tc_verd) { 396 if (TC_MUNGED & skb->tc_verd) {
387 /* copied already, allow trampling */ 397 /* copied already, allow trampling */
@@ -405,7 +415,7 @@ void tcf_action_destroy(struct tc_action *act, int bind)
405 struct tc_action *a; 415 struct tc_action *a;
406 416
407 for (a = act; a; a = act) { 417 for (a = act; a; a = act) {
408 if (a->ops && a->ops->cleanup) { 418 if (a->ops) {
409 if (a->ops->cleanup(a, bind) == ACT_P_DELETED) 419 if (a->ops->cleanup(a, bind) == ACT_P_DELETED)
410 module_put(a->ops->owner); 420 module_put(a->ops->owner);
411 act = act->next; 421 act = act->next;
@@ -424,7 +434,7 @@ tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
424{ 434{
425 int err = -EINVAL; 435 int err = -EINVAL;
426 436
427 if (a->ops == NULL || a->ops->dump == NULL) 437 if (a->ops == NULL)
428 return err; 438 return err;
429 return a->ops->dump(skb, a, bind, ref); 439 return a->ops->dump(skb, a, bind, ref);
430} 440}
@@ -436,7 +446,7 @@ tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
436 unsigned char *b = skb_tail_pointer(skb); 446 unsigned char *b = skb_tail_pointer(skb);
437 struct nlattr *nest; 447 struct nlattr *nest;
438 448
439 if (a->ops == NULL || a->ops->dump == NULL) 449 if (a->ops == NULL)
440 return err; 450 return err;
441 451
442 if (nla_put_string(skb, TCA_KIND, a->ops->kind)) 452 if (nla_put_string(skb, TCA_KIND, a->ops->kind))
@@ -723,8 +733,6 @@ tcf_action_get_1(struct nlattr *nla, struct nlmsghdr *n, u32 portid)
723 a->ops = tc_lookup_action(tb[TCA_ACT_KIND]); 733 a->ops = tc_lookup_action(tb[TCA_ACT_KIND]);
724 if (a->ops == NULL) 734 if (a->ops == NULL)
725 goto err_free; 735 goto err_free;
726 if (a->ops->lookup == NULL)
727 goto err_mod;
728 err = -ENOENT; 736 err = -ENOENT;
729 if (a->ops->lookup(a, index) == 0) 737 if (a->ops->lookup(a, index) == 0)
730 goto err_mod; 738 goto err_mod;
@@ -1084,12 +1092,6 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
1084 memset(&a, 0, sizeof(struct tc_action)); 1092 memset(&a, 0, sizeof(struct tc_action));
1085 a.ops = a_o; 1093 a.ops = a_o;
1086 1094
1087 if (a_o->walk == NULL) {
1088 WARN(1, "tc_dump_action: %s !capable of dumping table\n",
1089 a_o->kind);
1090 goto out_module_put;
1091 }
1092
1093 nlh = nlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, 1095 nlh = nlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq,
1094 cb->nlh->nlmsg_type, sizeof(*t), 0); 1096 cb->nlh->nlmsg_type, sizeof(*t), 0);
1095 if (!nlh) 1097 if (!nlh)
diff --git a/net/sched/act_csum.c b/net/sched/act_csum.c
index 3a4c0caa1f7d..5c5edf56adbd 100644
--- a/net/sched/act_csum.c
+++ b/net/sched/act_csum.c
@@ -585,9 +585,7 @@ static struct tc_action_ops act_csum_ops = {
585 .act = tcf_csum, 585 .act = tcf_csum,
586 .dump = tcf_csum_dump, 586 .dump = tcf_csum_dump,
587 .cleanup = tcf_csum_cleanup, 587 .cleanup = tcf_csum_cleanup,
588 .lookup = tcf_hash_search,
589 .init = tcf_csum_init, 588 .init = tcf_csum_init,
590 .walk = tcf_generic_walker
591}; 589};
592 590
593MODULE_DESCRIPTION("Checksum updating actions"); 591MODULE_DESCRIPTION("Checksum updating actions");
diff --git a/net/sched/act_gact.c b/net/sched/act_gact.c
index fd2b3cff5fa2..5645a4d32abd 100644
--- a/net/sched/act_gact.c
+++ b/net/sched/act_gact.c
@@ -206,9 +206,7 @@ static struct tc_action_ops act_gact_ops = {
206 .act = tcf_gact, 206 .act = tcf_gact,
207 .dump = tcf_gact_dump, 207 .dump = tcf_gact_dump,
208 .cleanup = tcf_gact_cleanup, 208 .cleanup = tcf_gact_cleanup,
209 .lookup = tcf_hash_search,
210 .init = tcf_gact_init, 209 .init = tcf_gact_init,
211 .walk = tcf_generic_walker
212}; 210};
213 211
214MODULE_AUTHOR("Jamal Hadi Salim(2002-4)"); 212MODULE_AUTHOR("Jamal Hadi Salim(2002-4)");
diff --git a/net/sched/act_ipt.c b/net/sched/act_ipt.c
index 60d88b6b9560..882a89762f77 100644
--- a/net/sched/act_ipt.c
+++ b/net/sched/act_ipt.c
@@ -298,9 +298,7 @@ static struct tc_action_ops act_ipt_ops = {
298 .act = tcf_ipt, 298 .act = tcf_ipt,
299 .dump = tcf_ipt_dump, 299 .dump = tcf_ipt_dump,
300 .cleanup = tcf_ipt_cleanup, 300 .cleanup = tcf_ipt_cleanup,
301 .lookup = tcf_hash_search,
302 .init = tcf_ipt_init, 301 .init = tcf_ipt_init,
303 .walk = tcf_generic_walker
304}; 302};
305 303
306static struct tc_action_ops act_xt_ops = { 304static struct tc_action_ops act_xt_ops = {
@@ -312,9 +310,7 @@ static struct tc_action_ops act_xt_ops = {
312 .act = tcf_ipt, 310 .act = tcf_ipt,
313 .dump = tcf_ipt_dump, 311 .dump = tcf_ipt_dump,
314 .cleanup = tcf_ipt_cleanup, 312 .cleanup = tcf_ipt_cleanup,
315 .lookup = tcf_hash_search,
316 .init = tcf_ipt_init, 313 .init = tcf_ipt_init,
317 .walk = tcf_generic_walker
318}; 314};
319 315
320MODULE_AUTHOR("Jamal Hadi Salim(2002-13)"); 316MODULE_AUTHOR("Jamal Hadi Salim(2002-13)");
diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
index 977c10e0631b..252378121ce7 100644
--- a/net/sched/act_mirred.c
+++ b/net/sched/act_mirred.c
@@ -271,9 +271,7 @@ static struct tc_action_ops act_mirred_ops = {
271 .act = tcf_mirred, 271 .act = tcf_mirred,
272 .dump = tcf_mirred_dump, 272 .dump = tcf_mirred_dump,
273 .cleanup = tcf_mirred_cleanup, 273 .cleanup = tcf_mirred_cleanup,
274 .lookup = tcf_hash_search,
275 .init = tcf_mirred_init, 274 .init = tcf_mirred_init,
276 .walk = tcf_generic_walker
277}; 275};
278 276
279MODULE_AUTHOR("Jamal Hadi Salim(2002)"); 277MODULE_AUTHOR("Jamal Hadi Salim(2002)");
diff --git a/net/sched/act_nat.c b/net/sched/act_nat.c
index 876f0ef29694..6a15ace00241 100644
--- a/net/sched/act_nat.c
+++ b/net/sched/act_nat.c
@@ -308,9 +308,7 @@ static struct tc_action_ops act_nat_ops = {
308 .act = tcf_nat, 308 .act = tcf_nat,
309 .dump = tcf_nat_dump, 309 .dump = tcf_nat_dump,
310 .cleanup = tcf_nat_cleanup, 310 .cleanup = tcf_nat_cleanup,
311 .lookup = tcf_hash_search,
312 .init = tcf_nat_init, 311 .init = tcf_nat_init,
313 .walk = tcf_generic_walker
314}; 312};
315 313
316MODULE_DESCRIPTION("Stateless NAT actions"); 314MODULE_DESCRIPTION("Stateless NAT actions");
diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c
index 7ed78c9e505c..03b67674169c 100644
--- a/net/sched/act_pedit.c
+++ b/net/sched/act_pedit.c
@@ -243,9 +243,7 @@ static struct tc_action_ops act_pedit_ops = {
243 .act = tcf_pedit, 243 .act = tcf_pedit,
244 .dump = tcf_pedit_dump, 244 .dump = tcf_pedit_dump,
245 .cleanup = tcf_pedit_cleanup, 245 .cleanup = tcf_pedit_cleanup,
246 .lookup = tcf_hash_search,
247 .init = tcf_pedit_init, 246 .init = tcf_pedit_init,
248 .walk = tcf_generic_walker
249}; 247};
250 248
251MODULE_AUTHOR("Jamal Hadi Salim(2002-4)"); 249MODULE_AUTHOR("Jamal Hadi Salim(2002-4)");
diff --git a/net/sched/act_police.c b/net/sched/act_police.c
index 272d8e924cf6..16a62c36928a 100644
--- a/net/sched/act_police.c
+++ b/net/sched/act_police.c
@@ -407,7 +407,6 @@ static struct tc_action_ops act_police_ops = {
407 .act = tcf_act_police, 407 .act = tcf_act_police,
408 .dump = tcf_act_police_dump, 408 .dump = tcf_act_police_dump,
409 .cleanup = tcf_act_police_cleanup, 409 .cleanup = tcf_act_police_cleanup,
410 .lookup = tcf_hash_search,
411 .init = tcf_act_police_locate, 410 .init = tcf_act_police_locate,
412 .walk = tcf_act_police_walker 411 .walk = tcf_act_police_walker
413}; 412};
diff --git a/net/sched/act_simple.c b/net/sched/act_simple.c
index 7725eb4ab756..31157d3e729c 100644
--- a/net/sched/act_simple.c
+++ b/net/sched/act_simple.c
@@ -201,7 +201,6 @@ static struct tc_action_ops act_simp_ops = {
201 .dump = tcf_simp_dump, 201 .dump = tcf_simp_dump,
202 .cleanup = tcf_simp_cleanup, 202 .cleanup = tcf_simp_cleanup,
203 .init = tcf_simp_init, 203 .init = tcf_simp_init,
204 .walk = tcf_generic_walker,
205}; 204};
206 205
207MODULE_AUTHOR("Jamal Hadi Salim(2005)"); 206MODULE_AUTHOR("Jamal Hadi Salim(2005)");
diff --git a/net/sched/act_skbedit.c b/net/sched/act_skbedit.c
index cb4221171f93..35ea643b4325 100644
--- a/net/sched/act_skbedit.c
+++ b/net/sched/act_skbedit.c
@@ -203,7 +203,6 @@ static struct tc_action_ops act_skbedit_ops = {
203 .dump = tcf_skbedit_dump, 203 .dump = tcf_skbedit_dump,
204 .cleanup = tcf_skbedit_cleanup, 204 .cleanup = tcf_skbedit_cleanup,
205 .init = tcf_skbedit_init, 205 .init = tcf_skbedit_init,
206 .walk = tcf_generic_walker,
207}; 206};
208 207
209MODULE_AUTHOR("Alexander Duyck, <alexander.h.duyck@intel.com>"); 208MODULE_AUTHOR("Alexander Duyck, <alexander.h.duyck@intel.com>");
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 0e1e38b40025..717b2108f852 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -1477,11 +1477,22 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
1477 sch_tree_lock(sch); 1477 sch_tree_lock(sch);
1478 } 1478 }
1479 1479
1480 rate64 = tb[TCA_HTB_RATE64] ? nla_get_u64(tb[TCA_HTB_RATE64]) : 0;
1481
1482 ceil64 = tb[TCA_HTB_CEIL64] ? nla_get_u64(tb[TCA_HTB_CEIL64]) : 0;
1483
1484 psched_ratecfg_precompute(&cl->rate, &hopt->rate, rate64);
1485 psched_ratecfg_precompute(&cl->ceil, &hopt->ceil, ceil64);
1486
1480 /* it used to be a nasty bug here, we have to check that node 1487 /* it used to be a nasty bug here, we have to check that node
1481 * is really leaf before changing cl->un.leaf ! 1488 * is really leaf before changing cl->un.leaf !
1482 */ 1489 */
1483 if (!cl->level) { 1490 if (!cl->level) {
1484 cl->quantum = hopt->rate.rate / q->rate2quantum; 1491 u64 quantum = cl->rate.rate_bytes_ps;
1492
1493 do_div(quantum, q->rate2quantum);
1494 cl->quantum = min_t(u64, quantum, INT_MAX);
1495
1485 if (!hopt->quantum && cl->quantum < 1000) { 1496 if (!hopt->quantum && cl->quantum < 1000) {
1486 pr_warning( 1497 pr_warning(
1487 "HTB: quantum of class %X is small. Consider r2q change.\n", 1498 "HTB: quantum of class %X is small. Consider r2q change.\n",
@@ -1500,13 +1511,6 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
1500 cl->prio = TC_HTB_NUMPRIO - 1; 1511 cl->prio = TC_HTB_NUMPRIO - 1;
1501 } 1512 }
1502 1513
1503 rate64 = tb[TCA_HTB_RATE64] ? nla_get_u64(tb[TCA_HTB_RATE64]) : 0;
1504
1505 ceil64 = tb[TCA_HTB_CEIL64] ? nla_get_u64(tb[TCA_HTB_CEIL64]) : 0;
1506
1507 psched_ratecfg_precompute(&cl->rate, &hopt->rate, rate64);
1508 psched_ratecfg_precompute(&cl->ceil, &hopt->ceil, ceil64);
1509
1510 cl->buffer = PSCHED_TICKS2NS(hopt->buffer); 1514 cl->buffer = PSCHED_TICKS2NS(hopt->buffer);
1511 cl->cbuffer = PSCHED_TICKS2NS(hopt->cbuffer); 1515 cl->cbuffer = PSCHED_TICKS2NS(hopt->cbuffer);
1512 1516
diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
index a6090051c5db..887e672f9d7d 100644
--- a/net/sched/sch_tbf.c
+++ b/net/sched/sch_tbf.c
@@ -118,6 +118,32 @@ struct tbf_sched_data {
118}; 118};
119 119
120 120
121/* Time to Length, convert time in ns to length in bytes
122 * to determinate how many bytes can be sent in given time.
123 */
124static u64 psched_ns_t2l(const struct psched_ratecfg *r,
125 u64 time_in_ns)
126{
127 /* The formula is :
128 * len = (time_in_ns * r->rate_bytes_ps) / NSEC_PER_SEC
129 */
130 u64 len = time_in_ns * r->rate_bytes_ps;
131
132 do_div(len, NSEC_PER_SEC);
133
134 if (unlikely(r->linklayer == TC_LINKLAYER_ATM)) {
135 do_div(len, 53);
136 len = len * 48;
137 }
138
139 if (len > r->overhead)
140 len -= r->overhead;
141 else
142 len = 0;
143
144 return len;
145}
146
121/* 147/*
122 * Return length of individual segments of a gso packet, 148 * Return length of individual segments of a gso packet,
123 * including all headers (MAC, IP, TCP/UDP) 149 * including all headers (MAC, IP, TCP/UDP)
@@ -289,10 +315,11 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt)
289 struct tbf_sched_data *q = qdisc_priv(sch); 315 struct tbf_sched_data *q = qdisc_priv(sch);
290 struct nlattr *tb[TCA_TBF_MAX + 1]; 316 struct nlattr *tb[TCA_TBF_MAX + 1];
291 struct tc_tbf_qopt *qopt; 317 struct tc_tbf_qopt *qopt;
292 struct qdisc_rate_table *rtab = NULL;
293 struct qdisc_rate_table *ptab = NULL;
294 struct Qdisc *child = NULL; 318 struct Qdisc *child = NULL;
295 int max_size, n; 319 struct psched_ratecfg rate;
320 struct psched_ratecfg peak;
321 u64 max_size;
322 s64 buffer, mtu;
296 u64 rate64 = 0, prate64 = 0; 323 u64 rate64 = 0, prate64 = 0;
297 324
298 err = nla_parse_nested(tb, TCA_TBF_MAX, opt, tbf_policy); 325 err = nla_parse_nested(tb, TCA_TBF_MAX, opt, tbf_policy);
@@ -304,38 +331,13 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt)
304 goto done; 331 goto done;
305 332
306 qopt = nla_data(tb[TCA_TBF_PARMS]); 333 qopt = nla_data(tb[TCA_TBF_PARMS]);
307 rtab = qdisc_get_rtab(&qopt->rate, tb[TCA_TBF_RTAB]); 334 if (qopt->rate.linklayer == TC_LINKLAYER_UNAWARE)
308 if (rtab == NULL) 335 qdisc_put_rtab(qdisc_get_rtab(&qopt->rate,
309 goto done; 336 tb[TCA_TBF_RTAB]));
310
311 if (qopt->peakrate.rate) {
312 if (qopt->peakrate.rate > qopt->rate.rate)
313 ptab = qdisc_get_rtab(&qopt->peakrate, tb[TCA_TBF_PTAB]);
314 if (ptab == NULL)
315 goto done;
316 }
317
318 for (n = 0; n < 256; n++)
319 if (rtab->data[n] > qopt->buffer)
320 break;
321 max_size = (n << qopt->rate.cell_log) - 1;
322 if (ptab) {
323 int size;
324
325 for (n = 0; n < 256; n++)
326 if (ptab->data[n] > qopt->mtu)
327 break;
328 size = (n << qopt->peakrate.cell_log) - 1;
329 if (size < max_size)
330 max_size = size;
331 }
332 if (max_size < 0)
333 goto done;
334 337
335 if (max_size < psched_mtu(qdisc_dev(sch))) 338 if (qopt->peakrate.linklayer == TC_LINKLAYER_UNAWARE)
336 pr_warn_ratelimited("sch_tbf: burst %u is lower than device %s mtu (%u) !\n", 339 qdisc_put_rtab(qdisc_get_rtab(&qopt->peakrate,
337 max_size, qdisc_dev(sch)->name, 340 tb[TCA_TBF_PTAB]));
338 psched_mtu(qdisc_dev(sch)));
339 341
340 if (q->qdisc != &noop_qdisc) { 342 if (q->qdisc != &noop_qdisc) {
341 err = fifo_set_limit(q->qdisc, qopt->limit); 343 err = fifo_set_limit(q->qdisc, qopt->limit);
@@ -349,6 +351,39 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt)
349 } 351 }
350 } 352 }
351 353
354 buffer = min_t(u64, PSCHED_TICKS2NS(qopt->buffer), ~0U);
355 mtu = min_t(u64, PSCHED_TICKS2NS(qopt->mtu), ~0U);
356
357 if (tb[TCA_TBF_RATE64])
358 rate64 = nla_get_u64(tb[TCA_TBF_RATE64]);
359 psched_ratecfg_precompute(&rate, &qopt->rate, rate64);
360
361 max_size = min_t(u64, psched_ns_t2l(&rate, buffer), ~0U);
362
363 if (qopt->peakrate.rate) {
364 if (tb[TCA_TBF_PRATE64])
365 prate64 = nla_get_u64(tb[TCA_TBF_PRATE64]);
366 psched_ratecfg_precompute(&peak, &qopt->peakrate, prate64);
367 if (peak.rate_bytes_ps <= rate.rate_bytes_ps) {
368 pr_warn_ratelimited("sch_tbf: peakrate %llu is lower than or equals to rate %llu !\n",
369 peak.rate_bytes_ps, rate.rate_bytes_ps);
370 err = -EINVAL;
371 goto done;
372 }
373
374 max_size = min_t(u64, max_size, psched_ns_t2l(&peak, mtu));
375 }
376
377 if (max_size < psched_mtu(qdisc_dev(sch)))
378 pr_warn_ratelimited("sch_tbf: burst %llu is lower than device %s mtu (%u) !\n",
379 max_size, qdisc_dev(sch)->name,
380 psched_mtu(qdisc_dev(sch)));
381
382 if (!max_size) {
383 err = -EINVAL;
384 goto done;
385 }
386
352 sch_tree_lock(sch); 387 sch_tree_lock(sch);
353 if (child) { 388 if (child) {
354 qdisc_tree_decrease_qlen(q->qdisc, q->qdisc->q.qlen); 389 qdisc_tree_decrease_qlen(q->qdisc, q->qdisc->q.qlen);
@@ -362,13 +397,9 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt)
362 q->tokens = q->buffer; 397 q->tokens = q->buffer;
363 q->ptokens = q->mtu; 398 q->ptokens = q->mtu;
364 399
365 if (tb[TCA_TBF_RATE64]) 400 memcpy(&q->rate, &rate, sizeof(struct psched_ratecfg));
366 rate64 = nla_get_u64(tb[TCA_TBF_RATE64]); 401 if (qopt->peakrate.rate) {
367 psched_ratecfg_precompute(&q->rate, &rtab->rate, rate64); 402 memcpy(&q->peak, &peak, sizeof(struct psched_ratecfg));
368 if (ptab) {
369 if (tb[TCA_TBF_PRATE64])
370 prate64 = nla_get_u64(tb[TCA_TBF_PRATE64]);
371 psched_ratecfg_precompute(&q->peak, &ptab->rate, prate64);
372 q->peak_present = true; 403 q->peak_present = true;
373 } else { 404 } else {
374 q->peak_present = false; 405 q->peak_present = false;
@@ -377,10 +408,6 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt)
377 sch_tree_unlock(sch); 408 sch_tree_unlock(sch);
378 err = 0; 409 err = 0;
379done: 410done:
380 if (rtab)
381 qdisc_put_rtab(rtab);
382 if (ptab)
383 qdisc_put_rtab(ptab);
384 return err; 411 return err;
385} 412}
386 413
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index 68a27f9796d2..31ed008c8e13 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -154,8 +154,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a
154 154
155 asoc->timeouts[SCTP_EVENT_TIMEOUT_HEARTBEAT] = 0; 155 asoc->timeouts[SCTP_EVENT_TIMEOUT_HEARTBEAT] = 0;
156 asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] = asoc->sackdelay; 156 asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] = asoc->sackdelay;
157 asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE] = 157 asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE] = sp->autoclose * HZ;
158 min_t(unsigned long, sp->autoclose, net->sctp.max_autoclose) * HZ;
159 158
160 /* Initializes the timers */ 159 /* Initializes the timers */
161 for (i = SCTP_EVENT_TIMEOUT_NONE; i < SCTP_NUM_TIMEOUT_TYPES; ++i) 160 for (i = SCTP_EVENT_TIMEOUT_NONE; i < SCTP_NUM_TIMEOUT_TYPES; ++i)
@@ -291,8 +290,6 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a
291 asoc->peer.ipv6_address = 1; 290 asoc->peer.ipv6_address = 1;
292 INIT_LIST_HEAD(&asoc->asocs); 291 INIT_LIST_HEAD(&asoc->asocs);
293 292
294 asoc->autoclose = sp->autoclose;
295
296 asoc->default_stream = sp->default_stream; 293 asoc->default_stream = sp->default_stream;
297 asoc->default_ppid = sp->default_ppid; 294 asoc->default_ppid = sp->default_ppid;
298 asoc->default_flags = sp->default_flags; 295 asoc->default_flags = sp->default_flags;
diff --git a/net/sctp/output.c b/net/sctp/output.c
index 0e2644d0a773..0fb140f8f088 100644
--- a/net/sctp/output.c
+++ b/net/sctp/output.c
@@ -581,7 +581,8 @@ int sctp_packet_transmit(struct sctp_packet *packet)
581 unsigned long timeout; 581 unsigned long timeout;
582 582
583 /* Restart the AUTOCLOSE timer when sending data. */ 583 /* Restart the AUTOCLOSE timer when sending data. */
584 if (sctp_state(asoc, ESTABLISHED) && asoc->autoclose) { 584 if (sctp_state(asoc, ESTABLISHED) &&
585 asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) {
585 timer = &asoc->timers[SCTP_EVENT_TIMEOUT_AUTOCLOSE]; 586 timer = &asoc->timers[SCTP_EVENT_TIMEOUT_AUTOCLOSE];
586 timeout = asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]; 587 timeout = asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE];
587 588
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
index dfe3f36ff2aa..a26065be7289 100644
--- a/net/sctp/sm_statefuns.c
+++ b/net/sctp/sm_statefuns.c
@@ -820,7 +820,7 @@ sctp_disposition_t sctp_sf_do_5_1D_ce(struct net *net,
820 SCTP_INC_STATS(net, SCTP_MIB_PASSIVEESTABS); 820 SCTP_INC_STATS(net, SCTP_MIB_PASSIVEESTABS);
821 sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, SCTP_NULL()); 821 sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, SCTP_NULL());
822 822
823 if (new_asoc->autoclose) 823 if (new_asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE])
824 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_START, 824 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_START,
825 SCTP_TO(SCTP_EVENT_TIMEOUT_AUTOCLOSE)); 825 SCTP_TO(SCTP_EVENT_TIMEOUT_AUTOCLOSE));
826 826
@@ -908,7 +908,7 @@ sctp_disposition_t sctp_sf_do_5_1E_ca(struct net *net,
908 SCTP_INC_STATS(net, SCTP_MIB_CURRESTAB); 908 SCTP_INC_STATS(net, SCTP_MIB_CURRESTAB);
909 SCTP_INC_STATS(net, SCTP_MIB_ACTIVEESTABS); 909 SCTP_INC_STATS(net, SCTP_MIB_ACTIVEESTABS);
910 sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, SCTP_NULL()); 910 sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, SCTP_NULL());
911 if (asoc->autoclose) 911 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE])
912 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_START, 912 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_START,
913 SCTP_TO(SCTP_EVENT_TIMEOUT_AUTOCLOSE)); 913 SCTP_TO(SCTP_EVENT_TIMEOUT_AUTOCLOSE));
914 914
@@ -2970,7 +2970,7 @@ sctp_disposition_t sctp_sf_eat_data_6_2(struct net *net,
2970 if (chunk->chunk_hdr->flags & SCTP_DATA_SACK_IMM) 2970 if (chunk->chunk_hdr->flags & SCTP_DATA_SACK_IMM)
2971 force = SCTP_FORCE(); 2971 force = SCTP_FORCE();
2972 2972
2973 if (asoc->autoclose) { 2973 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) {
2974 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_RESTART, 2974 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_RESTART,
2975 SCTP_TO(SCTP_EVENT_TIMEOUT_AUTOCLOSE)); 2975 SCTP_TO(SCTP_EVENT_TIMEOUT_AUTOCLOSE));
2976 } 2976 }
@@ -3878,7 +3878,7 @@ sctp_disposition_t sctp_sf_eat_fwd_tsn(struct net *net,
3878 SCTP_CHUNK(chunk)); 3878 SCTP_CHUNK(chunk));
3879 3879
3880 /* Count this as receiving DATA. */ 3880 /* Count this as receiving DATA. */
3881 if (asoc->autoclose) { 3881 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE]) {
3882 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_RESTART, 3882 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_RESTART,
3883 SCTP_TO(SCTP_EVENT_TIMEOUT_AUTOCLOSE)); 3883 SCTP_TO(SCTP_EVENT_TIMEOUT_AUTOCLOSE));
3884 } 3884 }
@@ -5267,7 +5267,7 @@ sctp_disposition_t sctp_sf_do_9_2_start_shutdown(
5267 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_RESTART, 5267 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_RESTART,
5268 SCTP_TO(SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD)); 5268 SCTP_TO(SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD));
5269 5269
5270 if (asoc->autoclose) 5270 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE])
5271 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, 5271 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP,
5272 SCTP_TO(SCTP_EVENT_TIMEOUT_AUTOCLOSE)); 5272 SCTP_TO(SCTP_EVENT_TIMEOUT_AUTOCLOSE));
5273 5273
@@ -5346,7 +5346,7 @@ sctp_disposition_t sctp_sf_do_9_2_shutdown_ack(
5346 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_RESTART, 5346 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_RESTART,
5347 SCTP_TO(SCTP_EVENT_TIMEOUT_T2_SHUTDOWN)); 5347 SCTP_TO(SCTP_EVENT_TIMEOUT_T2_SHUTDOWN));
5348 5348
5349 if (asoc->autoclose) 5349 if (asoc->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE])
5350 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, 5350 sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP,
5351 SCTP_TO(SCTP_EVENT_TIMEOUT_AUTOCLOSE)); 5351 SCTP_TO(SCTP_EVENT_TIMEOUT_AUTOCLOSE));
5352 5352
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 72046b9729a8..42b709c95cf3 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -2196,6 +2196,7 @@ static int sctp_setsockopt_autoclose(struct sock *sk, char __user *optval,
2196 unsigned int optlen) 2196 unsigned int optlen)
2197{ 2197{
2198 struct sctp_sock *sp = sctp_sk(sk); 2198 struct sctp_sock *sp = sctp_sk(sk);
2199 struct net *net = sock_net(sk);
2199 2200
2200 /* Applicable to UDP-style socket only */ 2201 /* Applicable to UDP-style socket only */
2201 if (sctp_style(sk, TCP)) 2202 if (sctp_style(sk, TCP))
@@ -2205,6 +2206,9 @@ static int sctp_setsockopt_autoclose(struct sock *sk, char __user *optval,
2205 if (copy_from_user(&sp->autoclose, optval, optlen)) 2206 if (copy_from_user(&sp->autoclose, optval, optlen))
2206 return -EFAULT; 2207 return -EFAULT;
2207 2208
2209 if (sp->autoclose > net->sctp.max_autoclose)
2210 sp->autoclose = net->sctp.max_autoclose;
2211
2208 return 0; 2212 return 0;
2209} 2213}
2210 2214
@@ -2811,6 +2815,8 @@ static int sctp_setsockopt_rtoinfo(struct sock *sk, char __user *optval, unsigne
2811{ 2815{
2812 struct sctp_rtoinfo rtoinfo; 2816 struct sctp_rtoinfo rtoinfo;
2813 struct sctp_association *asoc; 2817 struct sctp_association *asoc;
2818 unsigned long rto_min, rto_max;
2819 struct sctp_sock *sp = sctp_sk(sk);
2814 2820
2815 if (optlen != sizeof (struct sctp_rtoinfo)) 2821 if (optlen != sizeof (struct sctp_rtoinfo))
2816 return -EINVAL; 2822 return -EINVAL;
@@ -2824,26 +2830,36 @@ static int sctp_setsockopt_rtoinfo(struct sock *sk, char __user *optval, unsigne
2824 if (!asoc && rtoinfo.srto_assoc_id && sctp_style(sk, UDP)) 2830 if (!asoc && rtoinfo.srto_assoc_id && sctp_style(sk, UDP))
2825 return -EINVAL; 2831 return -EINVAL;
2826 2832
2833 rto_max = rtoinfo.srto_max;
2834 rto_min = rtoinfo.srto_min;
2835
2836 if (rto_max)
2837 rto_max = asoc ? msecs_to_jiffies(rto_max) : rto_max;
2838 else
2839 rto_max = asoc ? asoc->rto_max : sp->rtoinfo.srto_max;
2840
2841 if (rto_min)
2842 rto_min = asoc ? msecs_to_jiffies(rto_min) : rto_min;
2843 else
2844 rto_min = asoc ? asoc->rto_min : sp->rtoinfo.srto_min;
2845
2846 if (rto_min > rto_max)
2847 return -EINVAL;
2848
2827 if (asoc) { 2849 if (asoc) {
2828 if (rtoinfo.srto_initial != 0) 2850 if (rtoinfo.srto_initial != 0)
2829 asoc->rto_initial = 2851 asoc->rto_initial =
2830 msecs_to_jiffies(rtoinfo.srto_initial); 2852 msecs_to_jiffies(rtoinfo.srto_initial);
2831 if (rtoinfo.srto_max != 0) 2853 asoc->rto_max = rto_max;
2832 asoc->rto_max = msecs_to_jiffies(rtoinfo.srto_max); 2854 asoc->rto_min = rto_min;
2833 if (rtoinfo.srto_min != 0)
2834 asoc->rto_min = msecs_to_jiffies(rtoinfo.srto_min);
2835 } else { 2855 } else {
2836 /* If there is no association or the association-id = 0 2856 /* If there is no association or the association-id = 0
2837 * set the values to the endpoint. 2857 * set the values to the endpoint.
2838 */ 2858 */
2839 struct sctp_sock *sp = sctp_sk(sk);
2840
2841 if (rtoinfo.srto_initial != 0) 2859 if (rtoinfo.srto_initial != 0)
2842 sp->rtoinfo.srto_initial = rtoinfo.srto_initial; 2860 sp->rtoinfo.srto_initial = rtoinfo.srto_initial;
2843 if (rtoinfo.srto_max != 0) 2861 sp->rtoinfo.srto_max = rto_max;
2844 sp->rtoinfo.srto_max = rtoinfo.srto_max; 2862 sp->rtoinfo.srto_min = rto_min;
2845 if (rtoinfo.srto_min != 0)
2846 sp->rtoinfo.srto_min = rtoinfo.srto_min;
2847 } 2863 }
2848 2864
2849 return 0; 2865 return 0;
diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
index 6b36561a1b3b..b0565afb61c7 100644
--- a/net/sctp/sysctl.c
+++ b/net/sctp/sysctl.c
@@ -56,11 +56,16 @@ extern long sysctl_sctp_mem[3];
56extern int sysctl_sctp_rmem[3]; 56extern int sysctl_sctp_rmem[3];
57extern int sysctl_sctp_wmem[3]; 57extern int sysctl_sctp_wmem[3];
58 58
59static int proc_sctp_do_hmac_alg(struct ctl_table *ctl, 59static int proc_sctp_do_hmac_alg(struct ctl_table *ctl, int write,
60 int write, 60 void __user *buffer, size_t *lenp,
61 loff_t *ppos);
62static int proc_sctp_do_rto_min(struct ctl_table *ctl, int write,
63 void __user *buffer, size_t *lenp,
64 loff_t *ppos);
65static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write,
61 void __user *buffer, size_t *lenp, 66 void __user *buffer, size_t *lenp,
62
63 loff_t *ppos); 67 loff_t *ppos);
68
64static struct ctl_table sctp_table[] = { 69static struct ctl_table sctp_table[] = {
65 { 70 {
66 .procname = "sctp_mem", 71 .procname = "sctp_mem",
@@ -102,17 +107,17 @@ static struct ctl_table sctp_net_table[] = {
102 .data = &init_net.sctp.rto_min, 107 .data = &init_net.sctp.rto_min,
103 .maxlen = sizeof(unsigned int), 108 .maxlen = sizeof(unsigned int),
104 .mode = 0644, 109 .mode = 0644,
105 .proc_handler = proc_dointvec_minmax, 110 .proc_handler = proc_sctp_do_rto_min,
106 .extra1 = &one, 111 .extra1 = &one,
107 .extra2 = &timer_max 112 .extra2 = &init_net.sctp.rto_max
108 }, 113 },
109 { 114 {
110 .procname = "rto_max", 115 .procname = "rto_max",
111 .data = &init_net.sctp.rto_max, 116 .data = &init_net.sctp.rto_max,
112 .maxlen = sizeof(unsigned int), 117 .maxlen = sizeof(unsigned int),
113 .mode = 0644, 118 .mode = 0644,
114 .proc_handler = proc_dointvec_minmax, 119 .proc_handler = proc_sctp_do_rto_max,
115 .extra1 = &one, 120 .extra1 = &init_net.sctp.rto_min,
116 .extra2 = &timer_max 121 .extra2 = &timer_max
117 }, 122 },
118 { 123 {
@@ -294,8 +299,7 @@ static struct ctl_table sctp_net_table[] = {
294 { /* sentinel */ } 299 { /* sentinel */ }
295}; 300};
296 301
297static int proc_sctp_do_hmac_alg(struct ctl_table *ctl, 302static int proc_sctp_do_hmac_alg(struct ctl_table *ctl, int write,
298 int write,
299 void __user *buffer, size_t *lenp, 303 void __user *buffer, size_t *lenp,
300 loff_t *ppos) 304 loff_t *ppos)
301{ 305{
@@ -342,6 +346,60 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
342 return ret; 346 return ret;
343} 347}
344 348
349static int proc_sctp_do_rto_min(struct ctl_table *ctl, int write,
350 void __user *buffer, size_t *lenp,
351 loff_t *ppos)
352{
353 struct net *net = current->nsproxy->net_ns;
354 int new_value;
355 struct ctl_table tbl;
356 unsigned int min = *(unsigned int *) ctl->extra1;
357 unsigned int max = *(unsigned int *) ctl->extra2;
358 int ret;
359
360 memset(&tbl, 0, sizeof(struct ctl_table));
361 tbl.maxlen = sizeof(unsigned int);
362
363 if (write)
364 tbl.data = &new_value;
365 else
366 tbl.data = &net->sctp.rto_min;
367 ret = proc_dointvec(&tbl, write, buffer, lenp, ppos);
368 if (write) {
369 if (ret || new_value > max || new_value < min)
370 return -EINVAL;
371 net->sctp.rto_min = new_value;
372 }
373 return ret;
374}
375
376static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write,
377 void __user *buffer, size_t *lenp,
378 loff_t *ppos)
379{
380 struct net *net = current->nsproxy->net_ns;
381 int new_value;
382 struct ctl_table tbl;
383 unsigned int min = *(unsigned int *) ctl->extra1;
384 unsigned int max = *(unsigned int *) ctl->extra2;
385 int ret;
386
387 memset(&tbl, 0, sizeof(struct ctl_table));
388 tbl.maxlen = sizeof(unsigned int);
389
390 if (write)
391 tbl.data = &new_value;
392 else
393 tbl.data = &net->sctp.rto_max;
394 ret = proc_dointvec(&tbl, write, buffer, lenp, ppos);
395 if (write) {
396 if (ret || new_value > max || new_value < min)
397 return -EINVAL;
398 net->sctp.rto_max = new_value;
399 }
400 return ret;
401}
402
345int sctp_sysctl_net_register(struct net *net) 403int sctp_sysctl_net_register(struct net *net)
346{ 404{
347 struct ctl_table *table; 405 struct ctl_table *table;
diff --git a/net/sctp/transport.c b/net/sctp/transport.c
index e332efb124cc..efc46ffed1fd 100644
--- a/net/sctp/transport.c
+++ b/net/sctp/transport.c
@@ -573,7 +573,7 @@ void sctp_transport_burst_limited(struct sctp_transport *t)
573 u32 old_cwnd = t->cwnd; 573 u32 old_cwnd = t->cwnd;
574 u32 max_burst_bytes; 574 u32 max_burst_bytes;
575 575
576 if (t->burst_limited) 576 if (t->burst_limited || asoc->max_burst == 0)
577 return; 577 return;
578 578
579 max_burst_bytes = t->flight_size + (asoc->max_burst * asoc->pathmtu); 579 max_burst_bytes = t->flight_size + (asoc->max_burst * asoc->pathmtu);
diff --git a/net/tipc/core.c b/net/tipc/core.c
index fd4eeeaa972a..c6d3f75a9e1b 100644
--- a/net/tipc/core.c
+++ b/net/tipc/core.c
@@ -113,7 +113,6 @@ err:
113static void tipc_core_stop(void) 113static void tipc_core_stop(void)
114{ 114{
115 tipc_netlink_stop(); 115 tipc_netlink_stop();
116 tipc_handler_stop();
117 tipc_cfg_stop(); 116 tipc_cfg_stop();
118 tipc_subscr_stop(); 117 tipc_subscr_stop();
119 tipc_nametbl_stop(); 118 tipc_nametbl_stop();
@@ -146,9 +145,10 @@ static int tipc_core_start(void)
146 res = tipc_subscr_start(); 145 res = tipc_subscr_start();
147 if (!res) 146 if (!res)
148 res = tipc_cfg_init(); 147 res = tipc_cfg_init();
149 if (res) 148 if (res) {
149 tipc_handler_stop();
150 tipc_core_stop(); 150 tipc_core_stop();
151 151 }
152 return res; 152 return res;
153} 153}
154 154
@@ -178,6 +178,7 @@ static int __init tipc_init(void)
178 178
179static void __exit tipc_exit(void) 179static void __exit tipc_exit(void)
180{ 180{
181 tipc_handler_stop();
181 tipc_core_stop_net(); 182 tipc_core_stop_net();
182 tipc_core_stop(); 183 tipc_core_stop();
183 pr_info("Deactivated\n"); 184 pr_info("Deactivated\n");
diff --git a/net/tipc/handler.c b/net/tipc/handler.c
index b36f0fcd9bdf..e4bc8a296744 100644
--- a/net/tipc/handler.c
+++ b/net/tipc/handler.c
@@ -56,12 +56,13 @@ unsigned int tipc_k_signal(Handler routine, unsigned long argument)
56{ 56{
57 struct queue_item *item; 57 struct queue_item *item;
58 58
59 spin_lock_bh(&qitem_lock);
59 if (!handler_enabled) { 60 if (!handler_enabled) {
60 pr_err("Signal request ignored by handler\n"); 61 pr_err("Signal request ignored by handler\n");
62 spin_unlock_bh(&qitem_lock);
61 return -ENOPROTOOPT; 63 return -ENOPROTOOPT;
62 } 64 }
63 65
64 spin_lock_bh(&qitem_lock);
65 item = kmem_cache_alloc(tipc_queue_item_cache, GFP_ATOMIC); 66 item = kmem_cache_alloc(tipc_queue_item_cache, GFP_ATOMIC);
66 if (!item) { 67 if (!item) {
67 pr_err("Signal queue out of memory\n"); 68 pr_err("Signal queue out of memory\n");
@@ -112,10 +113,14 @@ void tipc_handler_stop(void)
112 struct list_head *l, *n; 113 struct list_head *l, *n;
113 struct queue_item *item; 114 struct queue_item *item;
114 115
115 if (!handler_enabled) 116 spin_lock_bh(&qitem_lock);
117 if (!handler_enabled) {
118 spin_unlock_bh(&qitem_lock);
116 return; 119 return;
117 120 }
118 handler_enabled = 0; 121 handler_enabled = 0;
122 spin_unlock_bh(&qitem_lock);
123
119 tasklet_kill(&tipc_tasklet); 124 tasklet_kill(&tipc_tasklet);
120 125
121 spin_lock_bh(&qitem_lock); 126 spin_lock_bh(&qitem_lock);
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 01625ccc3ae6..a0ca162e5bd5 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -530,13 +530,17 @@ static int unix_seqpacket_sendmsg(struct kiocb *, struct socket *,
530static int unix_seqpacket_recvmsg(struct kiocb *, struct socket *, 530static int unix_seqpacket_recvmsg(struct kiocb *, struct socket *,
531 struct msghdr *, size_t, int); 531 struct msghdr *, size_t, int);
532 532
533static void unix_set_peek_off(struct sock *sk, int val) 533static int unix_set_peek_off(struct sock *sk, int val)
534{ 534{
535 struct unix_sock *u = unix_sk(sk); 535 struct unix_sock *u = unix_sk(sk);
536 536
537 mutex_lock(&u->readlock); 537 if (mutex_lock_interruptible(&u->readlock))
538 return -EINTR;
539
538 sk->sk_peek_off = val; 540 sk->sk_peek_off = val;
539 mutex_unlock(&u->readlock); 541 mutex_unlock(&u->readlock);
542
543 return 0;
540} 544}
541 545
542 546
diff --git a/net/wireless/core.c b/net/wireless/core.c
index aff959e5a1b3..52b865fb7351 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -451,6 +451,15 @@ int wiphy_register(struct wiphy *wiphy)
451 int i; 451 int i;
452 u16 ifmodes = wiphy->interface_modes; 452 u16 ifmodes = wiphy->interface_modes;
453 453
454 /* support for 5/10 MHz is broken due to nl80211 API mess - disable */
455 wiphy->flags &= ~WIPHY_FLAG_SUPPORTS_5_10_MHZ;
456
457 /*
458 * There are major locking problems in nl80211/mac80211 for CSA,
459 * disable for all drivers until this has been reworked.
460 */
461 wiphy->flags &= ~WIPHY_FLAG_HAS_CHANNEL_SWITCH;
462
454#ifdef CONFIG_PM 463#ifdef CONFIG_PM
455 if (WARN_ON(wiphy->wowlan && 464 if (WARN_ON(wiphy->wowlan &&
456 (wiphy->wowlan->flags & WIPHY_WOWLAN_GTK_REKEY_FAILURE) && 465 (wiphy->wowlan->flags & WIPHY_WOWLAN_GTK_REKEY_FAILURE) &&
diff --git a/net/wireless/ibss.c b/net/wireless/ibss.c
index 9d797df56649..89737ee2669a 100644
--- a/net/wireless/ibss.c
+++ b/net/wireless/ibss.c
@@ -262,7 +262,7 @@ int cfg80211_ibss_wext_join(struct cfg80211_registered_device *rdev,
262 262
263 /* try to find an IBSS channel if none requested ... */ 263 /* try to find an IBSS channel if none requested ... */
264 if (!wdev->wext.ibss.chandef.chan) { 264 if (!wdev->wext.ibss.chandef.chan) {
265 wdev->wext.ibss.chandef.width = NL80211_CHAN_WIDTH_20_NOHT; 265 struct ieee80211_channel *new_chan = NULL;
266 266
267 for (band = 0; band < IEEE80211_NUM_BANDS; band++) { 267 for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
268 struct ieee80211_supported_band *sband; 268 struct ieee80211_supported_band *sband;
@@ -278,18 +278,19 @@ int cfg80211_ibss_wext_join(struct cfg80211_registered_device *rdev,
278 continue; 278 continue;
279 if (chan->flags & IEEE80211_CHAN_DISABLED) 279 if (chan->flags & IEEE80211_CHAN_DISABLED)
280 continue; 280 continue;
281 wdev->wext.ibss.chandef.chan = chan; 281 new_chan = chan;
282 wdev->wext.ibss.chandef.center_freq1 =
283 chan->center_freq;
284 break; 282 break;
285 } 283 }
286 284
287 if (wdev->wext.ibss.chandef.chan) 285 if (new_chan)
288 break; 286 break;
289 } 287 }
290 288
291 if (!wdev->wext.ibss.chandef.chan) 289 if (!new_chan)
292 return -EINVAL; 290 return -EINVAL;
291
292 cfg80211_chandef_create(&wdev->wext.ibss.chandef, new_chan,
293 NL80211_CHAN_NO_HT);
293 } 294 }
294 295
295 /* don't join -- SSID is not there */ 296 /* don't join -- SSID is not there */
@@ -363,9 +364,8 @@ int cfg80211_ibss_wext_siwfreq(struct net_device *dev,
363 return err; 364 return err;
364 365
365 if (chan) { 366 if (chan) {
366 wdev->wext.ibss.chandef.chan = chan; 367 cfg80211_chandef_create(&wdev->wext.ibss.chandef, chan,
367 wdev->wext.ibss.chandef.width = NL80211_CHAN_WIDTH_20_NOHT; 368 NL80211_CHAN_NO_HT);
368 wdev->wext.ibss.chandef.center_freq1 = freq;
369 wdev->wext.ibss.channel_fixed = true; 369 wdev->wext.ibss.channel_fixed = true;
370 } else { 370 } else {
371 /* cfg80211_ibss_wext_join will pick one if needed */ 371 /* cfg80211_ibss_wext_join will pick one if needed */
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index a1eb21073176..138dc3bb8b67 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -2687,7 +2687,7 @@ static int nl80211_get_key(struct sk_buff *skb, struct genl_info *info)
2687 hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0, 2687 hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
2688 NL80211_CMD_NEW_KEY); 2688 NL80211_CMD_NEW_KEY);
2689 if (!hdr) 2689 if (!hdr)
2690 return -ENOBUFS; 2690 goto nla_put_failure;
2691 2691
2692 cookie.msg = msg; 2692 cookie.msg = msg;
2693 cookie.idx = key_idx; 2693 cookie.idx = key_idx;
@@ -5349,6 +5349,10 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
5349 err = -EINVAL; 5349 err = -EINVAL;
5350 goto out_free; 5350 goto out_free;
5351 } 5351 }
5352
5353 if (!wiphy->bands[band])
5354 continue;
5355
5352 err = ieee80211_get_ratemask(wiphy->bands[band], 5356 err = ieee80211_get_ratemask(wiphy->bands[band],
5353 nla_data(attr), 5357 nla_data(attr),
5354 nla_len(attr), 5358 nla_len(attr),
@@ -9633,8 +9637,9 @@ static int nl80211_add_scan_req(struct sk_buff *msg,
9633 nla_put(msg, NL80211_ATTR_IE, req->ie_len, req->ie)) 9637 nla_put(msg, NL80211_ATTR_IE, req->ie_len, req->ie))
9634 goto nla_put_failure; 9638 goto nla_put_failure;
9635 9639
9636 if (req->flags) 9640 if (req->flags &&
9637 nla_put_u32(msg, NL80211_ATTR_SCAN_FLAGS, req->flags); 9641 nla_put_u32(msg, NL80211_ATTR_SCAN_FLAGS, req->flags))
9642 goto nla_put_failure;
9638 9643
9639 return 0; 9644 return 0;
9640 nla_put_failure: 9645 nla_put_failure:
@@ -11093,6 +11098,8 @@ void cfg80211_report_wowlan_wakeup(struct wireless_dev *wdev,
11093 struct nlattr *reasons; 11098 struct nlattr *reasons;
11094 11099
11095 reasons = nla_nest_start(msg, NL80211_ATTR_WOWLAN_TRIGGERS); 11100 reasons = nla_nest_start(msg, NL80211_ATTR_WOWLAN_TRIGGERS);
11101 if (!reasons)
11102 goto free_msg;
11096 11103
11097 if (wakeup->disconnect && 11104 if (wakeup->disconnect &&
11098 nla_put_flag(msg, NL80211_WOWLAN_TRIG_DISCONNECT)) 11105 nla_put_flag(msg, NL80211_WOWLAN_TRIG_DISCONNECT))
@@ -11118,16 +11125,18 @@ void cfg80211_report_wowlan_wakeup(struct wireless_dev *wdev,
11118 wakeup->pattern_idx)) 11125 wakeup->pattern_idx))
11119 goto free_msg; 11126 goto free_msg;
11120 11127
11121 if (wakeup->tcp_match) 11128 if (wakeup->tcp_match &&
11122 nla_put_flag(msg, NL80211_WOWLAN_TRIG_WAKEUP_TCP_MATCH); 11129 nla_put_flag(msg, NL80211_WOWLAN_TRIG_WAKEUP_TCP_MATCH))
11130 goto free_msg;
11123 11131
11124 if (wakeup->tcp_connlost) 11132 if (wakeup->tcp_connlost &&
11125 nla_put_flag(msg, 11133 nla_put_flag(msg, NL80211_WOWLAN_TRIG_WAKEUP_TCP_CONNLOST))
11126 NL80211_WOWLAN_TRIG_WAKEUP_TCP_CONNLOST); 11134 goto free_msg;
11127 11135
11128 if (wakeup->tcp_nomoretokens) 11136 if (wakeup->tcp_nomoretokens &&
11129 nla_put_flag(msg, 11137 nla_put_flag(msg,
11130 NL80211_WOWLAN_TRIG_WAKEUP_TCP_NOMORETOKENS); 11138 NL80211_WOWLAN_TRIG_WAKEUP_TCP_NOMORETOKENS))
11139 goto free_msg;
11131 11140
11132 if (wakeup->packet) { 11141 if (wakeup->packet) {
11133 u32 pkt_attr = NL80211_WOWLAN_TRIG_WAKEUP_PKT_80211; 11142 u32 pkt_attr = NL80211_WOWLAN_TRIG_WAKEUP_PKT_80211;
@@ -11263,24 +11272,29 @@ void cfg80211_ft_event(struct net_device *netdev,
11263 return; 11272 return;
11264 11273
11265 hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_FT_EVENT); 11274 hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_FT_EVENT);
11266 if (!hdr) { 11275 if (!hdr)
11267 nlmsg_free(msg); 11276 goto out;
11268 return;
11269 }
11270 11277
11271 nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); 11278 if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
11272 nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); 11279 nla_put_u32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex) ||
11273 nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, ft_event->target_ap); 11280 nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, ft_event->target_ap))
11274 if (ft_event->ies) 11281 goto out;
11275 nla_put(msg, NL80211_ATTR_IE, ft_event->ies_len, ft_event->ies); 11282
11276 if (ft_event->ric_ies) 11283 if (ft_event->ies &&
11277 nla_put(msg, NL80211_ATTR_IE_RIC, ft_event->ric_ies_len, 11284 nla_put(msg, NL80211_ATTR_IE, ft_event->ies_len, ft_event->ies))
11278 ft_event->ric_ies); 11285 goto out;
11286 if (ft_event->ric_ies &&
11287 nla_put(msg, NL80211_ATTR_IE_RIC, ft_event->ric_ies_len,
11288 ft_event->ric_ies))
11289 goto out;
11279 11290
11280 genlmsg_end(msg, hdr); 11291 genlmsg_end(msg, hdr);
11281 11292
11282 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0, 11293 genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy), msg, 0,
11283 NL80211_MCGRP_MLME, GFP_KERNEL); 11294 NL80211_MCGRP_MLME, GFP_KERNEL);
11295 return;
11296 out:
11297 nlmsg_free(msg);
11284} 11298}
11285EXPORT_SYMBOL(cfg80211_ft_event); 11299EXPORT_SYMBOL(cfg80211_ft_event);
11286 11300
diff --git a/scripts/sortextable.c b/scripts/sortextable.c
index 5f7a8b663cb9..7941fbdfb050 100644
--- a/scripts/sortextable.c
+++ b/scripts/sortextable.c
@@ -31,6 +31,10 @@
31#include <tools/be_byteshift.h> 31#include <tools/be_byteshift.h>
32#include <tools/le_byteshift.h> 32#include <tools/le_byteshift.h>
33 33
34#ifndef EM_ARCOMPACT
35#define EM_ARCOMPACT 93
36#endif
37
34#ifndef EM_AARCH64 38#ifndef EM_AARCH64
35#define EM_AARCH64 183 39#define EM_AARCH64 183
36#endif 40#endif
@@ -268,6 +272,7 @@ do_file(char const *const fname)
268 case EM_S390: 272 case EM_S390:
269 custom_sort = sort_relative_table; 273 custom_sort = sort_relative_table;
270 break; 274 break;
275 case EM_ARCOMPACT:
271 case EM_ARM: 276 case EM_ARM:
272 case EM_AARCH64: 277 case EM_AARCH64:
273 case EM_MIPS: 278 case EM_MIPS:
diff --git a/security/keys/big_key.c b/security/keys/big_key.c
index 7f44c3207a9b..8137b27d641d 100644
--- a/security/keys/big_key.c
+++ b/security/keys/big_key.c
@@ -70,7 +70,7 @@ int big_key_instantiate(struct key *key, struct key_preparsed_payload *prep)
70 * 70 *
71 * TODO: Encrypt the stored data with a temporary key. 71 * TODO: Encrypt the stored data with a temporary key.
72 */ 72 */
73 file = shmem_file_setup("", datalen, 0); 73 file = shmem_kernel_file_setup("", datalen, 0);
74 if (IS_ERR(file)) { 74 if (IS_ERR(file)) {
75 ret = PTR_ERR(file); 75 ret = PTR_ERR(file);
76 goto err_quota; 76 goto err_quota;
diff --git a/security/keys/key.c b/security/keys/key.c
index 55d110f0aced..6e21c11e48bc 100644
--- a/security/keys/key.c
+++ b/security/keys/key.c
@@ -272,7 +272,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
272 } 272 }
273 273
274 /* allocate and initialise the key and its description */ 274 /* allocate and initialise the key and its description */
275 key = kmem_cache_alloc(key_jar, GFP_KERNEL); 275 key = kmem_cache_zalloc(key_jar, GFP_KERNEL);
276 if (!key) 276 if (!key)
277 goto no_memory_2; 277 goto no_memory_2;
278 278
@@ -293,18 +293,12 @@ struct key *key_alloc(struct key_type *type, const char *desc,
293 key->uid = uid; 293 key->uid = uid;
294 key->gid = gid; 294 key->gid = gid;
295 key->perm = perm; 295 key->perm = perm;
296 key->flags = 0;
297 key->expiry = 0;
298 key->payload.data = NULL;
299 key->security = NULL;
300 296
301 if (!(flags & KEY_ALLOC_NOT_IN_QUOTA)) 297 if (!(flags & KEY_ALLOC_NOT_IN_QUOTA))
302 key->flags |= 1 << KEY_FLAG_IN_QUOTA; 298 key->flags |= 1 << KEY_FLAG_IN_QUOTA;
303 if (flags & KEY_ALLOC_TRUSTED) 299 if (flags & KEY_ALLOC_TRUSTED)
304 key->flags |= 1 << KEY_FLAG_TRUSTED; 300 key->flags |= 1 << KEY_FLAG_TRUSTED;
305 301
306 memset(&key->type_data, 0, sizeof(key->type_data));
307
308#ifdef KEY_DEBUGGING 302#ifdef KEY_DEBUGGING
309 key->magic = KEY_DEBUG_MAGIC; 303 key->magic = KEY_DEBUG_MAGIC;
310#endif 304#endif
diff --git a/security/keys/keyring.c b/security/keys/keyring.c
index 69f0cb7bab7e..d46cbc5e335e 100644
--- a/security/keys/keyring.c
+++ b/security/keys/keyring.c
@@ -160,7 +160,7 @@ static u64 mult_64x32_and_fold(u64 x, u32 y)
160static unsigned long hash_key_type_and_desc(const struct keyring_index_key *index_key) 160static unsigned long hash_key_type_and_desc(const struct keyring_index_key *index_key)
161{ 161{
162 const unsigned level_shift = ASSOC_ARRAY_LEVEL_STEP; 162 const unsigned level_shift = ASSOC_ARRAY_LEVEL_STEP;
163 const unsigned long level_mask = ASSOC_ARRAY_LEVEL_STEP_MASK; 163 const unsigned long fan_mask = ASSOC_ARRAY_FAN_MASK;
164 const char *description = index_key->description; 164 const char *description = index_key->description;
165 unsigned long hash, type; 165 unsigned long hash, type;
166 u32 piece; 166 u32 piece;
@@ -194,10 +194,10 @@ static unsigned long hash_key_type_and_desc(const struct keyring_index_key *inde
194 * ordinary keys by making sure the lowest level segment in the hash is 194 * ordinary keys by making sure the lowest level segment in the hash is
195 * zero for keyrings and non-zero otherwise. 195 * zero for keyrings and non-zero otherwise.
196 */ 196 */
197 if (index_key->type != &key_type_keyring && (hash & level_mask) == 0) 197 if (index_key->type != &key_type_keyring && (hash & fan_mask) == 0)
198 return hash | (hash >> (ASSOC_ARRAY_KEY_CHUNK_SIZE - level_shift)) | 1; 198 return hash | (hash >> (ASSOC_ARRAY_KEY_CHUNK_SIZE - level_shift)) | 1;
199 if (index_key->type == &key_type_keyring && (hash & level_mask) != 0) 199 if (index_key->type == &key_type_keyring && (hash & fan_mask) != 0)
200 return (hash + (hash << level_shift)) & ~level_mask; 200 return (hash + (hash << level_shift)) & ~fan_mask;
201 return hash; 201 return hash;
202} 202}
203 203
@@ -279,12 +279,11 @@ static bool keyring_compare_object(const void *object, const void *data)
279 * Compare the index keys of a pair of objects and determine the bit position 279 * Compare the index keys of a pair of objects and determine the bit position
280 * at which they differ - if they differ. 280 * at which they differ - if they differ.
281 */ 281 */
282static int keyring_diff_objects(const void *_a, const void *_b) 282static int keyring_diff_objects(const void *object, const void *data)
283{ 283{
284 const struct key *key_a = keyring_ptr_to_key(_a); 284 const struct key *key_a = keyring_ptr_to_key(object);
285 const struct key *key_b = keyring_ptr_to_key(_b);
286 const struct keyring_index_key *a = &key_a->index_key; 285 const struct keyring_index_key *a = &key_a->index_key;
287 const struct keyring_index_key *b = &key_b->index_key; 286 const struct keyring_index_key *b = data;
288 unsigned long seg_a, seg_b; 287 unsigned long seg_a, seg_b;
289 int level, i; 288 int level, i;
290 289
@@ -691,8 +690,8 @@ descend_to_node:
691 smp_read_barrier_depends(); 690 smp_read_barrier_depends();
692 ptr = ACCESS_ONCE(shortcut->next_node); 691 ptr = ACCESS_ONCE(shortcut->next_node);
693 BUG_ON(!assoc_array_ptr_is_node(ptr)); 692 BUG_ON(!assoc_array_ptr_is_node(ptr));
694 node = assoc_array_ptr_to_node(ptr);
695 } 693 }
694 node = assoc_array_ptr_to_node(ptr);
696 695
697begin_node: 696begin_node:
698 kdebug("begin_node"); 697 kdebug("begin_node");
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 794c3ca49eac..419491d8e7d2 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -53,6 +53,7 @@
53#include <net/ip.h> /* for local_port_range[] */ 53#include <net/ip.h> /* for local_port_range[] */
54#include <net/sock.h> 54#include <net/sock.h>
55#include <net/tcp.h> /* struct or_callable used in sock_rcv_skb */ 55#include <net/tcp.h> /* struct or_callable used in sock_rcv_skb */
56#include <net/inet_connection_sock.h>
56#include <net/net_namespace.h> 57#include <net/net_namespace.h>
57#include <net/netlabel.h> 58#include <net/netlabel.h>
58#include <linux/uaccess.h> 59#include <linux/uaccess.h>
@@ -95,10 +96,6 @@
95#include "audit.h" 96#include "audit.h"
96#include "avc_ss.h" 97#include "avc_ss.h"
97 98
98#define SB_TYPE_FMT "%s%s%s"
99#define SB_SUBTYPE(sb) (sb->s_subtype && sb->s_subtype[0])
100#define SB_TYPE_ARGS(sb) sb->s_type->name, SB_SUBTYPE(sb) ? "." : "", SB_SUBTYPE(sb) ? sb->s_subtype : ""
101
102extern struct security_operations *security_ops; 99extern struct security_operations *security_ops;
103 100
104/* SECMARK reference count */ 101/* SECMARK reference count */
@@ -413,8 +410,8 @@ static int sb_finish_set_opts(struct super_block *sb)
413 the first boot of the SELinux kernel before we have 410 the first boot of the SELinux kernel before we have
414 assigned xattr values to the filesystem. */ 411 assigned xattr values to the filesystem. */
415 if (!root_inode->i_op->getxattr) { 412 if (!root_inode->i_op->getxattr) {
416 printk(KERN_WARNING "SELinux: (dev %s, type "SB_TYPE_FMT") has no " 413 printk(KERN_WARNING "SELinux: (dev %s, type %s) has no "
417 "xattr support\n", sb->s_id, SB_TYPE_ARGS(sb)); 414 "xattr support\n", sb->s_id, sb->s_type->name);
418 rc = -EOPNOTSUPP; 415 rc = -EOPNOTSUPP;
419 goto out; 416 goto out;
420 } 417 }
@@ -422,22 +419,22 @@ static int sb_finish_set_opts(struct super_block *sb)
422 if (rc < 0 && rc != -ENODATA) { 419 if (rc < 0 && rc != -ENODATA) {
423 if (rc == -EOPNOTSUPP) 420 if (rc == -EOPNOTSUPP)
424 printk(KERN_WARNING "SELinux: (dev %s, type " 421 printk(KERN_WARNING "SELinux: (dev %s, type "
425 SB_TYPE_FMT") has no security xattr handler\n", 422 "%s) has no security xattr handler\n",
426 sb->s_id, SB_TYPE_ARGS(sb)); 423 sb->s_id, sb->s_type->name);
427 else 424 else
428 printk(KERN_WARNING "SELinux: (dev %s, type " 425 printk(KERN_WARNING "SELinux: (dev %s, type "
429 SB_TYPE_FMT") getxattr errno %d\n", sb->s_id, 426 "%s) getxattr errno %d\n", sb->s_id,
430 SB_TYPE_ARGS(sb), -rc); 427 sb->s_type->name, -rc);
431 goto out; 428 goto out;
432 } 429 }
433 } 430 }
434 431
435 if (sbsec->behavior > ARRAY_SIZE(labeling_behaviors)) 432 if (sbsec->behavior > ARRAY_SIZE(labeling_behaviors))
436 printk(KERN_ERR "SELinux: initialized (dev %s, type "SB_TYPE_FMT"), unknown behavior\n", 433 printk(KERN_ERR "SELinux: initialized (dev %s, type %s), unknown behavior\n",
437 sb->s_id, SB_TYPE_ARGS(sb)); 434 sb->s_id, sb->s_type->name);
438 else 435 else
439 printk(KERN_DEBUG "SELinux: initialized (dev %s, type "SB_TYPE_FMT"), %s\n", 436 printk(KERN_DEBUG "SELinux: initialized (dev %s, type %s), %s\n",
440 sb->s_id, SB_TYPE_ARGS(sb), 437 sb->s_id, sb->s_type->name,
441 labeling_behaviors[sbsec->behavior-1]); 438 labeling_behaviors[sbsec->behavior-1]);
442 439
443 sbsec->flags |= SE_SBINITIALIZED; 440 sbsec->flags |= SE_SBINITIALIZED;
@@ -600,6 +597,7 @@ static int selinux_set_mnt_opts(struct super_block *sb,
600 const struct cred *cred = current_cred(); 597 const struct cred *cred = current_cred();
601 int rc = 0, i; 598 int rc = 0, i;
602 struct superblock_security_struct *sbsec = sb->s_security; 599 struct superblock_security_struct *sbsec = sb->s_security;
600 const char *name = sb->s_type->name;
603 struct inode *inode = sbsec->sb->s_root->d_inode; 601 struct inode *inode = sbsec->sb->s_root->d_inode;
604 struct inode_security_struct *root_isec = inode->i_security; 602 struct inode_security_struct *root_isec = inode->i_security;
605 u32 fscontext_sid = 0, context_sid = 0, rootcontext_sid = 0; 603 u32 fscontext_sid = 0, context_sid = 0, rootcontext_sid = 0;
@@ -658,8 +656,8 @@ static int selinux_set_mnt_opts(struct super_block *sb,
658 strlen(mount_options[i]), &sid); 656 strlen(mount_options[i]), &sid);
659 if (rc) { 657 if (rc) {
660 printk(KERN_WARNING "SELinux: security_context_to_sid" 658 printk(KERN_WARNING "SELinux: security_context_to_sid"
661 "(%s) failed for (dev %s, type "SB_TYPE_FMT") errno=%d\n", 659 "(%s) failed for (dev %s, type %s) errno=%d\n",
662 mount_options[i], sb->s_id, SB_TYPE_ARGS(sb), rc); 660 mount_options[i], sb->s_id, name, rc);
663 goto out; 661 goto out;
664 } 662 }
665 switch (flags[i]) { 663 switch (flags[i]) {
@@ -806,8 +804,7 @@ out:
806out_double_mount: 804out_double_mount:
807 rc = -EINVAL; 805 rc = -EINVAL;
808 printk(KERN_WARNING "SELinux: mount invalid. Same superblock, different " 806 printk(KERN_WARNING "SELinux: mount invalid. Same superblock, different "
809 "security settings for (dev %s, type "SB_TYPE_FMT")\n", sb->s_id, 807 "security settings for (dev %s, type %s)\n", sb->s_id, name);
810 SB_TYPE_ARGS(sb));
811 goto out; 808 goto out;
812} 809}
813 810
@@ -2480,8 +2477,8 @@ static int selinux_sb_remount(struct super_block *sb, void *data)
2480 rc = security_context_to_sid(mount_options[i], len, &sid); 2477 rc = security_context_to_sid(mount_options[i], len, &sid);
2481 if (rc) { 2478 if (rc) {
2482 printk(KERN_WARNING "SELinux: security_context_to_sid" 2479 printk(KERN_WARNING "SELinux: security_context_to_sid"
2483 "(%s) failed for (dev %s, type "SB_TYPE_FMT") errno=%d\n", 2480 "(%s) failed for (dev %s, type %s) errno=%d\n",
2484 mount_options[i], sb->s_id, SB_TYPE_ARGS(sb), rc); 2481 mount_options[i], sb->s_id, sb->s_type->name, rc);
2485 goto out_free_opts; 2482 goto out_free_opts;
2486 } 2483 }
2487 rc = -EINVAL; 2484 rc = -EINVAL;
@@ -2519,8 +2516,8 @@ out_free_secdata:
2519 return rc; 2516 return rc;
2520out_bad_option: 2517out_bad_option:
2521 printk(KERN_WARNING "SELinux: unable to change security options " 2518 printk(KERN_WARNING "SELinux: unable to change security options "
2522 "during remount (dev %s, type "SB_TYPE_FMT")\n", sb->s_id, 2519 "during remount (dev %s, type=%s)\n", sb->s_id,
2523 SB_TYPE_ARGS(sb)); 2520 sb->s_type->name);
2524 goto out_free_opts; 2521 goto out_free_opts;
2525} 2522}
2526 2523
@@ -3828,7 +3825,7 @@ static int selinux_skb_peerlbl_sid(struct sk_buff *skb, u16 family, u32 *sid)
3828 u32 nlbl_sid; 3825 u32 nlbl_sid;
3829 u32 nlbl_type; 3826 u32 nlbl_type;
3830 3827
3831 err = selinux_skb_xfrm_sid(skb, &xfrm_sid); 3828 err = selinux_xfrm_skb_sid(skb, &xfrm_sid);
3832 if (unlikely(err)) 3829 if (unlikely(err))
3833 return -EACCES; 3830 return -EACCES;
3834 err = selinux_netlbl_skbuff_getsid(skb, family, &nlbl_type, &nlbl_sid); 3831 err = selinux_netlbl_skbuff_getsid(skb, family, &nlbl_type, &nlbl_sid);
@@ -3846,6 +3843,30 @@ static int selinux_skb_peerlbl_sid(struct sk_buff *skb, u16 family, u32 *sid)
3846 return 0; 3843 return 0;
3847} 3844}
3848 3845
3846/**
3847 * selinux_conn_sid - Determine the child socket label for a connection
3848 * @sk_sid: the parent socket's SID
3849 * @skb_sid: the packet's SID
3850 * @conn_sid: the resulting connection SID
3851 *
3852 * If @skb_sid is valid then the user:role:type information from @sk_sid is
3853 * combined with the MLS information from @skb_sid in order to create
3854 * @conn_sid. If @skb_sid is not valid then then @conn_sid is simply a copy
3855 * of @sk_sid. Returns zero on success, negative values on failure.
3856 *
3857 */
3858static int selinux_conn_sid(u32 sk_sid, u32 skb_sid, u32 *conn_sid)
3859{
3860 int err = 0;
3861
3862 if (skb_sid != SECSID_NULL)
3863 err = security_sid_mls_copy(sk_sid, skb_sid, conn_sid);
3864 else
3865 *conn_sid = sk_sid;
3866
3867 return err;
3868}
3869
3849/* socket security operations */ 3870/* socket security operations */
3850 3871
3851static int socket_sockcreate_sid(const struct task_security_struct *tsec, 3872static int socket_sockcreate_sid(const struct task_security_struct *tsec,
@@ -4452,7 +4473,7 @@ static int selinux_inet_conn_request(struct sock *sk, struct sk_buff *skb,
4452 struct sk_security_struct *sksec = sk->sk_security; 4473 struct sk_security_struct *sksec = sk->sk_security;
4453 int err; 4474 int err;
4454 u16 family = sk->sk_family; 4475 u16 family = sk->sk_family;
4455 u32 newsid; 4476 u32 connsid;
4456 u32 peersid; 4477 u32 peersid;
4457 4478
4458 /* handle mapped IPv4 packets arriving via IPv6 sockets */ 4479 /* handle mapped IPv4 packets arriving via IPv6 sockets */
@@ -4462,16 +4483,11 @@ static int selinux_inet_conn_request(struct sock *sk, struct sk_buff *skb,
4462 err = selinux_skb_peerlbl_sid(skb, family, &peersid); 4483 err = selinux_skb_peerlbl_sid(skb, family, &peersid);
4463 if (err) 4484 if (err)
4464 return err; 4485 return err;
4465 if (peersid == SECSID_NULL) { 4486 err = selinux_conn_sid(sksec->sid, peersid, &connsid);
4466 req->secid = sksec->sid; 4487 if (err)
4467 req->peer_secid = SECSID_NULL; 4488 return err;
4468 } else { 4489 req->secid = connsid;
4469 err = security_sid_mls_copy(sksec->sid, peersid, &newsid); 4490 req->peer_secid = peersid;
4470 if (err)
4471 return err;
4472 req->secid = newsid;
4473 req->peer_secid = peersid;
4474 }
4475 4491
4476 return selinux_netlbl_inet_conn_request(req, family); 4492 return selinux_netlbl_inet_conn_request(req, family);
4477} 4493}
@@ -4731,6 +4747,7 @@ static unsigned int selinux_ipv6_forward(const struct nf_hook_ops *ops,
4731static unsigned int selinux_ip_output(struct sk_buff *skb, 4747static unsigned int selinux_ip_output(struct sk_buff *skb,
4732 u16 family) 4748 u16 family)
4733{ 4749{
4750 struct sock *sk;
4734 u32 sid; 4751 u32 sid;
4735 4752
4736 if (!netlbl_enabled()) 4753 if (!netlbl_enabled())
@@ -4739,8 +4756,27 @@ static unsigned int selinux_ip_output(struct sk_buff *skb,
4739 /* we do this in the LOCAL_OUT path and not the POST_ROUTING path 4756 /* we do this in the LOCAL_OUT path and not the POST_ROUTING path
4740 * because we want to make sure we apply the necessary labeling 4757 * because we want to make sure we apply the necessary labeling
4741 * before IPsec is applied so we can leverage AH protection */ 4758 * before IPsec is applied so we can leverage AH protection */
4742 if (skb->sk) { 4759 sk = skb->sk;
4743 struct sk_security_struct *sksec = skb->sk->sk_security; 4760 if (sk) {
4761 struct sk_security_struct *sksec;
4762
4763 if (sk->sk_state == TCP_LISTEN)
4764 /* if the socket is the listening state then this
4765 * packet is a SYN-ACK packet which means it needs to
4766 * be labeled based on the connection/request_sock and
4767 * not the parent socket. unfortunately, we can't
4768 * lookup the request_sock yet as it isn't queued on
4769 * the parent socket until after the SYN-ACK is sent.
4770 * the "solution" is to simply pass the packet as-is
4771 * as any IP option based labeling should be copied
4772 * from the initial connection request (in the IP
4773 * layer). it is far from ideal, but until we get a
4774 * security label in the packet itself this is the
4775 * best we can do. */
4776 return NF_ACCEPT;
4777
4778 /* standard practice, label using the parent socket */
4779 sksec = sk->sk_security;
4744 sid = sksec->sid; 4780 sid = sksec->sid;
4745 } else 4781 } else
4746 sid = SECINITSID_KERNEL; 4782 sid = SECINITSID_KERNEL;
@@ -4810,27 +4846,36 @@ static unsigned int selinux_ip_postroute(struct sk_buff *skb, int ifindex,
4810 * as fast and as clean as possible. */ 4846 * as fast and as clean as possible. */
4811 if (!selinux_policycap_netpeer) 4847 if (!selinux_policycap_netpeer)
4812 return selinux_ip_postroute_compat(skb, ifindex, family); 4848 return selinux_ip_postroute_compat(skb, ifindex, family);
4849
4850 secmark_active = selinux_secmark_enabled();
4851 peerlbl_active = selinux_peerlbl_enabled();
4852 if (!secmark_active && !peerlbl_active)
4853 return NF_ACCEPT;
4854
4855 sk = skb->sk;
4856
4813#ifdef CONFIG_XFRM 4857#ifdef CONFIG_XFRM
4814 /* If skb->dst->xfrm is non-NULL then the packet is undergoing an IPsec 4858 /* If skb->dst->xfrm is non-NULL then the packet is undergoing an IPsec
4815 * packet transformation so allow the packet to pass without any checks 4859 * packet transformation so allow the packet to pass without any checks
4816 * since we'll have another chance to perform access control checks 4860 * since we'll have another chance to perform access control checks
4817 * when the packet is on it's final way out. 4861 * when the packet is on it's final way out.
4818 * NOTE: there appear to be some IPv6 multicast cases where skb->dst 4862 * NOTE: there appear to be some IPv6 multicast cases where skb->dst
4819 * is NULL, in this case go ahead and apply access control. */ 4863 * is NULL, in this case go ahead and apply access control.
4820 if (skb_dst(skb) != NULL && skb_dst(skb)->xfrm != NULL) 4864 * NOTE: if this is a local socket (skb->sk != NULL) that is in the
4865 * TCP listening state we cannot wait until the XFRM processing
4866 * is done as we will miss out on the SA label if we do;
4867 * unfortunately, this means more work, but it is only once per
4868 * connection. */
4869 if (skb_dst(skb) != NULL && skb_dst(skb)->xfrm != NULL &&
4870 !(sk != NULL && sk->sk_state == TCP_LISTEN))
4821 return NF_ACCEPT; 4871 return NF_ACCEPT;
4822#endif 4872#endif
4823 secmark_active = selinux_secmark_enabled();
4824 peerlbl_active = selinux_peerlbl_enabled();
4825 if (!secmark_active && !peerlbl_active)
4826 return NF_ACCEPT;
4827 4873
4828 /* if the packet is being forwarded then get the peer label from the
4829 * packet itself; otherwise check to see if it is from a local
4830 * application or the kernel, if from an application get the peer label
4831 * from the sending socket, otherwise use the kernel's sid */
4832 sk = skb->sk;
4833 if (sk == NULL) { 4874 if (sk == NULL) {
4875 /* Without an associated socket the packet is either coming
4876 * from the kernel or it is being forwarded; check the packet
4877 * to determine which and if the packet is being forwarded
4878 * query the packet directly to determine the security label. */
4834 if (skb->skb_iif) { 4879 if (skb->skb_iif) {
4835 secmark_perm = PACKET__FORWARD_OUT; 4880 secmark_perm = PACKET__FORWARD_OUT;
4836 if (selinux_skb_peerlbl_sid(skb, family, &peer_sid)) 4881 if (selinux_skb_peerlbl_sid(skb, family, &peer_sid))
@@ -4839,7 +4884,45 @@ static unsigned int selinux_ip_postroute(struct sk_buff *skb, int ifindex,
4839 secmark_perm = PACKET__SEND; 4884 secmark_perm = PACKET__SEND;
4840 peer_sid = SECINITSID_KERNEL; 4885 peer_sid = SECINITSID_KERNEL;
4841 } 4886 }
4887 } else if (sk->sk_state == TCP_LISTEN) {
4888 /* Locally generated packet but the associated socket is in the
4889 * listening state which means this is a SYN-ACK packet. In
4890 * this particular case the correct security label is assigned
4891 * to the connection/request_sock but unfortunately we can't
4892 * query the request_sock as it isn't queued on the parent
4893 * socket until after the SYN-ACK packet is sent; the only
4894 * viable choice is to regenerate the label like we do in
4895 * selinux_inet_conn_request(). See also selinux_ip_output()
4896 * for similar problems. */
4897 u32 skb_sid;
4898 struct sk_security_struct *sksec = sk->sk_security;
4899 if (selinux_skb_peerlbl_sid(skb, family, &skb_sid))
4900 return NF_DROP;
4901 /* At this point, if the returned skb peerlbl is SECSID_NULL
4902 * and the packet has been through at least one XFRM
4903 * transformation then we must be dealing with the "final"
4904 * form of labeled IPsec packet; since we've already applied
4905 * all of our access controls on this packet we can safely
4906 * pass the packet. */
4907 if (skb_sid == SECSID_NULL) {
4908 switch (family) {
4909 case PF_INET:
4910 if (IPCB(skb)->flags & IPSKB_XFRM_TRANSFORMED)
4911 return NF_ACCEPT;
4912 break;
4913 case PF_INET6:
4914 if (IP6CB(skb)->flags & IP6SKB_XFRM_TRANSFORMED)
4915 return NF_ACCEPT;
4916 default:
4917 return NF_DROP_ERR(-ECONNREFUSED);
4918 }
4919 }
4920 if (selinux_conn_sid(sksec->sid, skb_sid, &peer_sid))
4921 return NF_DROP;
4922 secmark_perm = PACKET__SEND;
4842 } else { 4923 } else {
4924 /* Locally generated packet, fetch the security label from the
4925 * associated socket. */
4843 struct sk_security_struct *sksec = sk->sk_security; 4926 struct sk_security_struct *sksec = sk->sk_security;
4844 peer_sid = sksec->sid; 4927 peer_sid = sksec->sid;
4845 secmark_perm = PACKET__SEND; 4928 secmark_perm = PACKET__SEND;
diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
index 0dec76c64cf5..48c3cc94c168 100644
--- a/security/selinux/include/xfrm.h
+++ b/security/selinux/include/xfrm.h
@@ -39,6 +39,7 @@ int selinux_xfrm_sock_rcv_skb(u32 sk_sid, struct sk_buff *skb,
39int selinux_xfrm_postroute_last(u32 sk_sid, struct sk_buff *skb, 39int selinux_xfrm_postroute_last(u32 sk_sid, struct sk_buff *skb,
40 struct common_audit_data *ad, u8 proto); 40 struct common_audit_data *ad, u8 proto);
41int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall); 41int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
42int selinux_xfrm_skb_sid(struct sk_buff *skb, u32 *sid);
42 43
43static inline void selinux_xfrm_notify_policyload(void) 44static inline void selinux_xfrm_notify_policyload(void)
44{ 45{
@@ -79,11 +80,12 @@ static inline int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid,
79static inline void selinux_xfrm_notify_policyload(void) 80static inline void selinux_xfrm_notify_policyload(void)
80{ 81{
81} 82}
82#endif
83 83
84static inline int selinux_skb_xfrm_sid(struct sk_buff *skb, u32 *sid) 84static inline int selinux_xfrm_skb_sid(struct sk_buff *skb, u32 *sid)
85{ 85{
86 return selinux_xfrm_decode_session(skb, sid, 0); 86 *sid = SECSID_NULL;
87 return 0;
87} 88}
89#endif
88 90
89#endif /* _SELINUX_XFRM_H_ */ 91#endif /* _SELINUX_XFRM_H_ */
diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
index ee470a0b5c27..d106733ad987 100644
--- a/security/selinux/ss/services.c
+++ b/security/selinux/ss/services.c
@@ -2334,50 +2334,16 @@ int security_fs_use(struct super_block *sb)
2334 struct ocontext *c; 2334 struct ocontext *c;
2335 struct superblock_security_struct *sbsec = sb->s_security; 2335 struct superblock_security_struct *sbsec = sb->s_security;
2336 const char *fstype = sb->s_type->name; 2336 const char *fstype = sb->s_type->name;
2337 const char *subtype = (sb->s_subtype && sb->s_subtype[0]) ? sb->s_subtype : NULL;
2338 struct ocontext *base = NULL;
2339 2337
2340 read_lock(&policy_rwlock); 2338 read_lock(&policy_rwlock);
2341 2339
2342 for (c = policydb.ocontexts[OCON_FSUSE]; c; c = c->next) { 2340 c = policydb.ocontexts[OCON_FSUSE];
2343 char *sub; 2341 while (c) {
2344 int baselen; 2342 if (strcmp(fstype, c->u.name) == 0)
2345
2346 baselen = strlen(fstype);
2347
2348 /* if base does not match, this is not the one */
2349 if (strncmp(fstype, c->u.name, baselen))
2350 continue;
2351
2352 /* if there is no subtype, this is the one! */
2353 if (!subtype)
2354 break;
2355
2356 /* skip past the base in this entry */
2357 sub = c->u.name + baselen;
2358
2359 /* entry is only a base. save it. keep looking for subtype */
2360 if (sub[0] == '\0') {
2361 base = c;
2362 continue;
2363 }
2364
2365 /* entry is not followed by a subtype, so it is not a match */
2366 if (sub[0] != '.')
2367 continue;
2368
2369 /* whew, we found a subtype of this fstype */
2370 sub++; /* move past '.' */
2371
2372 /* exact match of fstype AND subtype */
2373 if (!strcmp(subtype, sub))
2374 break; 2343 break;
2344 c = c->next;
2375 } 2345 }
2376 2346
2377 /* in case we had found an fstype match but no subtype match */
2378 if (!c)
2379 c = base;
2380
2381 if (c) { 2347 if (c) {
2382 sbsec->behavior = c->v.behavior; 2348 sbsec->behavior = c->v.behavior;
2383 if (!c->sid[0]) { 2349 if (!c->sid[0]) {
diff --git a/security/selinux/xfrm.c b/security/selinux/xfrm.c
index a91d205ec0c6..0462cb3ff0a7 100644
--- a/security/selinux/xfrm.c
+++ b/security/selinux/xfrm.c
@@ -209,19 +209,26 @@ int selinux_xfrm_state_pol_flow_match(struct xfrm_state *x,
209 NULL) ? 0 : 1); 209 NULL) ? 0 : 1);
210} 210}
211 211
212/* 212static u32 selinux_xfrm_skb_sid_egress(struct sk_buff *skb)
213 * LSM hook implementation that checks and/or returns the xfrm sid for the
214 * incoming packet.
215 */
216int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall)
217{ 213{
218 u32 sid_session = SECSID_NULL; 214 struct dst_entry *dst = skb_dst(skb);
219 struct sec_path *sp; 215 struct xfrm_state *x;
220 216
221 if (skb == NULL) 217 if (dst == NULL)
222 goto out; 218 return SECSID_NULL;
219 x = dst->xfrm;
220 if (x == NULL || !selinux_authorizable_xfrm(x))
221 return SECSID_NULL;
222
223 return x->security->ctx_sid;
224}
225
226static int selinux_xfrm_skb_sid_ingress(struct sk_buff *skb,
227 u32 *sid, int ckall)
228{
229 u32 sid_session = SECSID_NULL;
230 struct sec_path *sp = skb->sp;
223 231
224 sp = skb->sp;
225 if (sp) { 232 if (sp) {
226 int i; 233 int i;
227 234
@@ -248,6 +255,30 @@ out:
248} 255}
249 256
250/* 257/*
258 * LSM hook implementation that checks and/or returns the xfrm sid for the
259 * incoming packet.
260 */
261int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall)
262{
263 if (skb == NULL) {
264 *sid = SECSID_NULL;
265 return 0;
266 }
267 return selinux_xfrm_skb_sid_ingress(skb, sid, ckall);
268}
269
270int selinux_xfrm_skb_sid(struct sk_buff *skb, u32 *sid)
271{
272 int rc;
273
274 rc = selinux_xfrm_skb_sid_ingress(skb, sid, 0);
275 if (rc == 0 && *sid == SECSID_NULL)
276 *sid = selinux_xfrm_skb_sid_egress(skb);
277
278 return rc;
279}
280
281/*
251 * LSM hook implementation that allocs and transfers uctx spec to xfrm_policy. 282 * LSM hook implementation that allocs and transfers uctx spec to xfrm_policy.
252 */ 283 */
253int selinux_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp, 284int selinux_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
@@ -327,19 +358,22 @@ int selinux_xfrm_state_alloc_acquire(struct xfrm_state *x,
327 return rc; 358 return rc;
328 359
329 ctx = kmalloc(sizeof(*ctx) + str_len, GFP_ATOMIC); 360 ctx = kmalloc(sizeof(*ctx) + str_len, GFP_ATOMIC);
330 if (!ctx) 361 if (!ctx) {
331 return -ENOMEM; 362 rc = -ENOMEM;
363 goto out;
364 }
332 365
333 ctx->ctx_doi = XFRM_SC_DOI_LSM; 366 ctx->ctx_doi = XFRM_SC_DOI_LSM;
334 ctx->ctx_alg = XFRM_SC_ALG_SELINUX; 367 ctx->ctx_alg = XFRM_SC_ALG_SELINUX;
335 ctx->ctx_sid = secid; 368 ctx->ctx_sid = secid;
336 ctx->ctx_len = str_len; 369 ctx->ctx_len = str_len;
337 memcpy(ctx->ctx_str, ctx_str, str_len); 370 memcpy(ctx->ctx_str, ctx_str, str_len);
338 kfree(ctx_str);
339 371
340 x->security = ctx; 372 x->security = ctx;
341 atomic_inc(&selinux_xfrm_refcount); 373 atomic_inc(&selinux_xfrm_refcount);
342 return 0; 374out:
375 kfree(ctx_str);
376 return rc;
343} 377}
344 378
345/* 379/*
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index c4671d00babd..c7f6d1cab606 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -474,6 +474,20 @@ static void invalidate_nid_path(struct hda_codec *codec, int idx)
474 memset(path, 0, sizeof(*path)); 474 memset(path, 0, sizeof(*path));
475} 475}
476 476
477/* return a DAC if paired to the given pin by codec driver */
478static hda_nid_t get_preferred_dac(struct hda_codec *codec, hda_nid_t pin)
479{
480 struct hda_gen_spec *spec = codec->spec;
481 const hda_nid_t *list = spec->preferred_dacs;
482
483 if (!list)
484 return 0;
485 for (; *list; list += 2)
486 if (*list == pin)
487 return list[1];
488 return 0;
489}
490
477/* look for an empty DAC slot */ 491/* look for an empty DAC slot */
478static hda_nid_t look_for_dac(struct hda_codec *codec, hda_nid_t pin, 492static hda_nid_t look_for_dac(struct hda_codec *codec, hda_nid_t pin,
479 bool is_digital) 493 bool is_digital)
@@ -1192,7 +1206,14 @@ static int try_assign_dacs(struct hda_codec *codec, int num_outs,
1192 continue; 1206 continue;
1193 } 1207 }
1194 1208
1195 dacs[i] = look_for_dac(codec, pin, false); 1209 dacs[i] = get_preferred_dac(codec, pin);
1210 if (dacs[i]) {
1211 if (is_dac_already_used(codec, dacs[i]))
1212 badness += bad->shared_primary;
1213 }
1214
1215 if (!dacs[i])
1216 dacs[i] = look_for_dac(codec, pin, false);
1196 if (!dacs[i] && !i) { 1217 if (!dacs[i] && !i) {
1197 /* try to steal the DAC of surrounds for the front */ 1218 /* try to steal the DAC of surrounds for the front */
1198 for (j = 1; j < num_outs; j++) { 1219 for (j = 1; j < num_outs; j++) {
@@ -4297,6 +4318,26 @@ static unsigned int snd_hda_gen_path_power_filter(struct hda_codec *codec,
4297 return AC_PWRST_D3; 4318 return AC_PWRST_D3;
4298} 4319}
4299 4320
4321/* mute all aamix inputs initially; parse up to the first leaves */
4322static void mute_all_mixer_nid(struct hda_codec *codec, hda_nid_t mix)
4323{
4324 int i, nums;
4325 const hda_nid_t *conn;
4326 bool has_amp;
4327
4328 nums = snd_hda_get_conn_list(codec, mix, &conn);
4329 has_amp = nid_has_mute(codec, mix, HDA_INPUT);
4330 for (i = 0; i < nums; i++) {
4331 if (has_amp)
4332 snd_hda_codec_amp_stereo(codec, mix,
4333 HDA_INPUT, i,
4334 0xff, HDA_AMP_MUTE);
4335 else if (nid_has_volume(codec, conn[i], HDA_OUTPUT))
4336 snd_hda_codec_amp_stereo(codec, conn[i],
4337 HDA_OUTPUT, 0,
4338 0xff, HDA_AMP_MUTE);
4339 }
4340}
4300 4341
4301/* 4342/*
4302 * Parse the given BIOS configuration and set up the hda_gen_spec 4343 * Parse the given BIOS configuration and set up the hda_gen_spec
@@ -4435,6 +4476,10 @@ int snd_hda_gen_parse_auto_config(struct hda_codec *codec,
4435 } 4476 }
4436 } 4477 }
4437 4478
4479 /* mute all aamix input initially */
4480 if (spec->mixer_nid)
4481 mute_all_mixer_nid(codec, spec->mixer_nid);
4482
4438 dig_only: 4483 dig_only:
4439 parse_digital(codec); 4484 parse_digital(codec);
4440 4485
diff --git a/sound/pci/hda/hda_generic.h b/sound/pci/hda/hda_generic.h
index 7e45cb44d151..0929a06df812 100644
--- a/sound/pci/hda/hda_generic.h
+++ b/sound/pci/hda/hda_generic.h
@@ -249,6 +249,9 @@ struct hda_gen_spec {
249 const struct badness_table *main_out_badness; 249 const struct badness_table *main_out_badness;
250 const struct badness_table *extra_out_badness; 250 const struct badness_table *extra_out_badness;
251 251
252 /* preferred pin/DAC pairs; an array of paired NIDs */
253 const hda_nid_t *preferred_dacs;
254
252 /* loopback mixing mode */ 255 /* loopback mixing mode */
253 bool aamix_mode; 256 bool aamix_mode;
254 257
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index cac015be3325..699262a3e07a 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -340,6 +340,14 @@ static int patch_ad1986a(struct hda_codec *codec)
340{ 340{
341 int err; 341 int err;
342 struct ad198x_spec *spec; 342 struct ad198x_spec *spec;
343 static hda_nid_t preferred_pairs[] = {
344 0x1a, 0x03,
345 0x1b, 0x03,
346 0x1c, 0x04,
347 0x1d, 0x05,
348 0x1e, 0x03,
349 0
350 };
343 351
344 err = alloc_ad_spec(codec); 352 err = alloc_ad_spec(codec);
345 if (err < 0) 353 if (err < 0)
@@ -360,6 +368,8 @@ static int patch_ad1986a(struct hda_codec *codec)
360 * So, let's disable the shared stream. 368 * So, let's disable the shared stream.
361 */ 369 */
362 spec->gen.multiout.no_share_stream = 1; 370 spec->gen.multiout.no_share_stream = 1;
371 /* give fixed DAC/pin pairs */
372 spec->gen.preferred_dacs = preferred_pairs;
363 373
364 /* AD1986A can't manage the dynamic pin on/off smoothly */ 374 /* AD1986A can't manage the dynamic pin on/off smoothly */
365 spec->gen.auto_mute_via_amp = 1; 375 spec->gen.auto_mute_via_amp = 1;
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
index 1f2717f817a0..3fbf2883e06e 100644
--- a/sound/pci/hda/patch_conexant.c
+++ b/sound/pci/hda/patch_conexant.c
@@ -2936,7 +2936,6 @@ static const struct snd_pci_quirk cxt5066_cfg_tbl[] = {
2936 SND_PCI_QUIRK(0x1028, 0x0401, "Dell Vostro 1014", CXT5066_DELL_VOSTRO), 2936 SND_PCI_QUIRK(0x1028, 0x0401, "Dell Vostro 1014", CXT5066_DELL_VOSTRO),
2937 SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD), 2937 SND_PCI_QUIRK(0x1028, 0x0408, "Dell Inspiron One 19T", CXT5066_IDEAPAD),
2938 SND_PCI_QUIRK(0x1028, 0x050f, "Dell Inspiron", CXT5066_IDEAPAD), 2938 SND_PCI_QUIRK(0x1028, 0x050f, "Dell Inspiron", CXT5066_IDEAPAD),
2939 SND_PCI_QUIRK(0x1028, 0x0510, "Dell Vostro", CXT5066_IDEAPAD),
2940 SND_PCI_QUIRK(0x103c, 0x360b, "HP G60", CXT5066_HP_LAPTOP), 2939 SND_PCI_QUIRK(0x103c, 0x360b, "HP G60", CXT5066_HP_LAPTOP),
2941 SND_PCI_QUIRK(0x1043, 0x13f3, "Asus A52J", CXT5066_ASUS), 2940 SND_PCI_QUIRK(0x1043, 0x13f3, "Asus A52J", CXT5066_ASUS),
2942 SND_PCI_QUIRK(0x1043, 0x1643, "Asus K52JU", CXT5066_ASUS), 2941 SND_PCI_QUIRK(0x1043, 0x1643, "Asus K52JU", CXT5066_ASUS),
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index c4a66ef6cf6f..f281c8068557 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -2337,8 +2337,9 @@ static int simple_playback_build_controls(struct hda_codec *codec)
2337 int err; 2337 int err;
2338 2338
2339 per_cvt = get_cvt(spec, 0); 2339 per_cvt = get_cvt(spec, 0);
2340 err = snd_hda_create_spdif_out_ctls(codec, per_cvt->cvt_nid, 2340 err = snd_hda_create_dig_out_ctls(codec, per_cvt->cvt_nid,
2341 per_cvt->cvt_nid); 2341 per_cvt->cvt_nid,
2342 HDA_PCM_TYPE_HDMI);
2342 if (err < 0) 2343 if (err < 0)
2343 return err; 2344 return err;
2344 return simple_hdmi_build_jack(codec, 0); 2345 return simple_hdmi_build_jack(codec, 0);
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index c5ea483d7559..34de5dc2fe9b 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -3849,6 +3849,7 @@ enum {
3849 ALC269_FIXUP_ASUS_X101, 3849 ALC269_FIXUP_ASUS_X101,
3850 ALC271_FIXUP_AMIC_MIC2, 3850 ALC271_FIXUP_AMIC_MIC2,
3851 ALC271_FIXUP_HP_GATE_MIC_JACK, 3851 ALC271_FIXUP_HP_GATE_MIC_JACK,
3852 ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572,
3852 ALC269_FIXUP_ACER_AC700, 3853 ALC269_FIXUP_ACER_AC700,
3853 ALC269_FIXUP_LIMIT_INT_MIC_BOOST, 3854 ALC269_FIXUP_LIMIT_INT_MIC_BOOST,
3854 ALC269VB_FIXUP_ASUS_ZENBOOK, 3855 ALC269VB_FIXUP_ASUS_ZENBOOK,
@@ -4111,6 +4112,12 @@ static const struct hda_fixup alc269_fixups[] = {
4111 .chained = true, 4112 .chained = true,
4112 .chain_id = ALC271_FIXUP_AMIC_MIC2, 4113 .chain_id = ALC271_FIXUP_AMIC_MIC2,
4113 }, 4114 },
4115 [ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572] = {
4116 .type = HDA_FIXUP_FUNC,
4117 .v.func = alc269_fixup_limit_int_mic_boost,
4118 .chained = true,
4119 .chain_id = ALC271_FIXUP_HP_GATE_MIC_JACK,
4120 },
4114 [ALC269_FIXUP_ACER_AC700] = { 4121 [ALC269_FIXUP_ACER_AC700] = {
4115 .type = HDA_FIXUP_PINS, 4122 .type = HDA_FIXUP_PINS,
4116 .v.pins = (const struct hda_pintbl[]) { 4123 .v.pins = (const struct hda_pintbl[]) {
@@ -4208,6 +4215,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
4208 SND_PCI_QUIRK(0x1025, 0x0740, "Acer AO725", ALC271_FIXUP_HP_GATE_MIC_JACK), 4215 SND_PCI_QUIRK(0x1025, 0x0740, "Acer AO725", ALC271_FIXUP_HP_GATE_MIC_JACK),
4209 SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK), 4216 SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK),
4210 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC), 4217 SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC),
4218 SND_PCI_QUIRK(0x1025, 0x0775, "Acer Aspire E1-572", ALC271_FIXUP_HP_GATE_MIC_JACK_E1_572),
4211 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), 4219 SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
4212 SND_PCI_QUIRK(0x1028, 0x05bd, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), 4220 SND_PCI_QUIRK(0x1028, 0x05bd, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
4213 SND_PCI_QUIRK(0x1028, 0x05be, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE), 4221 SND_PCI_QUIRK(0x1028, 0x05be, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
@@ -5034,8 +5042,11 @@ static const struct snd_pci_quirk alc662_fixup_tbl[] = {
5034 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE), 5042 SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
5035 SND_PCI_QUIRK(0x1028, 0x05d8, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), 5043 SND_PCI_QUIRK(0x1028, 0x05d8, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
5036 SND_PCI_QUIRK(0x1028, 0x05db, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), 5044 SND_PCI_QUIRK(0x1028, 0x05db, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
5045 SND_PCI_QUIRK(0x1028, 0x0623, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
5046 SND_PCI_QUIRK(0x1028, 0x0624, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
5037 SND_PCI_QUIRK(0x1028, 0x0625, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), 5047 SND_PCI_QUIRK(0x1028, 0x0625, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
5038 SND_PCI_QUIRK(0x1028, 0x0626, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE), 5048 SND_PCI_QUIRK(0x1028, 0x0626, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
5049 SND_PCI_QUIRK(0x1028, 0x0628, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
5039 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800), 5050 SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
5040 SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_BASS_1A_CHMAP), 5051 SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_BASS_1A_CHMAP),
5041 SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_CHMAP), 5052 SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_CHMAP),
diff --git a/sound/soc/soc-devres.c b/sound/soc/soc-devres.c
index 3449c1e909ae..7ac745df1412 100644
--- a/sound/soc/soc-devres.c
+++ b/sound/soc/soc-devres.c
@@ -12,6 +12,7 @@
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/moduleparam.h> 13#include <linux/moduleparam.h>
14#include <sound/soc.h> 14#include <sound/soc.h>
15#include <sound/dmaengine_pcm.h>
15 16
16static void devm_component_release(struct device *dev, void *res) 17static void devm_component_release(struct device *dev, void *res)
17{ 18{
@@ -84,3 +85,43 @@ int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card)
84 return ret; 85 return ret;
85} 86}
86EXPORT_SYMBOL_GPL(devm_snd_soc_register_card); 87EXPORT_SYMBOL_GPL(devm_snd_soc_register_card);
88
89#ifdef CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM
90
91static void devm_dmaengine_pcm_release(struct device *dev, void *res)
92{
93 snd_dmaengine_pcm_unregister(*(struct device **)res);
94}
95
96/**
97 * devm_snd_dmaengine_pcm_register - resource managed dmaengine PCM registration
98 * @dev: The parent device for the PCM device
99 * @config: Platform specific PCM configuration
100 * @flags: Platform specific quirks
101 *
102 * Register a dmaengine based PCM device with automatic unregistration when the
103 * device is unregistered.
104 */
105int devm_snd_dmaengine_pcm_register(struct device *dev,
106 const struct snd_dmaengine_pcm_config *config, unsigned int flags)
107{
108 struct device **ptr;
109 int ret;
110
111 ptr = devres_alloc(devm_dmaengine_pcm_release, sizeof(*ptr), GFP_KERNEL);
112 if (!ptr)
113 return -ENOMEM;
114
115 ret = snd_dmaengine_pcm_register(dev, config, flags);
116 if (ret == 0) {
117 *ptr = dev;
118 devres_add(dev, ptr);
119 } else {
120 devres_free(ptr);
121 }
122
123 return ret;
124}
125EXPORT_SYMBOL_GPL(devm_snd_dmaengine_pcm_register);
126
127#endif
diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c
index cbc9c96ce1f4..7483922f6ee3 100644
--- a/sound/soc/soc-generic-dmaengine-pcm.c
+++ b/sound/soc/soc-generic-dmaengine-pcm.c
@@ -137,6 +137,9 @@ static int dmaengine_pcm_set_runtime_hwparams(struct snd_pcm_substream *substrea
137 hw.buffer_bytes_max = SIZE_MAX; 137 hw.buffer_bytes_max = SIZE_MAX;
138 hw.fifo_size = dma_data->fifo_size; 138 hw.fifo_size = dma_data->fifo_size;
139 139
140 if (pcm->flags & SND_DMAENGINE_PCM_FLAG_NO_RESIDUE)
141 hw.info |= SNDRV_PCM_INFO_BATCH;
142
140 ret = dma_get_slave_caps(chan, &dma_caps); 143 ret = dma_get_slave_caps(chan, &dma_caps);
141 if (ret == 0) { 144 if (ret == 0) {
142 if (dma_caps.cmd_pause) 145 if (dma_caps.cmd_pause)
@@ -284,24 +287,67 @@ static const char * const dmaengine_pcm_dma_channel_names[] = {
284 [SNDRV_PCM_STREAM_CAPTURE] = "rx", 287 [SNDRV_PCM_STREAM_CAPTURE] = "rx",
285}; 288};
286 289
287static void dmaengine_pcm_request_chan_of(struct dmaengine_pcm *pcm, 290static int dmaengine_pcm_request_chan_of(struct dmaengine_pcm *pcm,
288 struct device *dev) 291 struct device *dev, const struct snd_dmaengine_pcm_config *config)
289{ 292{
290 unsigned int i; 293 unsigned int i;
294 const char *name;
295 struct dma_chan *chan;
291 296
292 if ((pcm->flags & (SND_DMAENGINE_PCM_FLAG_NO_DT | 297 if ((pcm->flags & (SND_DMAENGINE_PCM_FLAG_NO_DT |
293 SND_DMAENGINE_PCM_FLAG_CUSTOM_CHANNEL_NAME)) || 298 SND_DMAENGINE_PCM_FLAG_CUSTOM_CHANNEL_NAME)) ||
294 !dev->of_node) 299 !dev->of_node)
295 return; 300 return 0;
301
302 if (config->dma_dev) {
303 /*
304 * If this warning is seen, it probably means that your Linux
305 * device structure does not match your HW device structure.
306 * It would be best to refactor the Linux device structure to
307 * correctly match the HW structure.
308 */
309 dev_warn(dev, "DMA channels sourced from device %s",
310 dev_name(config->dma_dev));
311 dev = config->dma_dev;
312 }
296 313
297 if (pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX) { 314 for (i = SNDRV_PCM_STREAM_PLAYBACK; i <= SNDRV_PCM_STREAM_CAPTURE;
298 pcm->chan[0] = dma_request_slave_channel(dev, "rx-tx"); 315 i++) {
299 pcm->chan[1] = pcm->chan[0]; 316 if (pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX)
300 } else { 317 name = "rx-tx";
301 for (i = SNDRV_PCM_STREAM_PLAYBACK; i <= SNDRV_PCM_STREAM_CAPTURE; i++) { 318 else
302 pcm->chan[i] = dma_request_slave_channel(dev, 319 name = dmaengine_pcm_dma_channel_names[i];
303 dmaengine_pcm_dma_channel_names[i]); 320 if (config->chan_names[i])
321 name = config->chan_names[i];
322 chan = dma_request_slave_channel_reason(dev, name);
323 if (IS_ERR(chan)) {
324 if (PTR_ERR(chan) == -EPROBE_DEFER)
325 return -EPROBE_DEFER;
326 pcm->chan[i] = NULL;
327 } else {
328 pcm->chan[i] = chan;
304 } 329 }
330 if (pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX)
331 break;
332 }
333
334 if (pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX)
335 pcm->chan[1] = pcm->chan[0];
336
337 return 0;
338}
339
340static void dmaengine_pcm_release_chan(struct dmaengine_pcm *pcm)
341{
342 unsigned int i;
343
344 for (i = SNDRV_PCM_STREAM_PLAYBACK; i <= SNDRV_PCM_STREAM_CAPTURE;
345 i++) {
346 if (!pcm->chan[i])
347 continue;
348 dma_release_channel(pcm->chan[i]);
349 if (pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX)
350 break;
305 } 351 }
306} 352}
307 353
@@ -315,6 +361,7 @@ int snd_dmaengine_pcm_register(struct device *dev,
315 const struct snd_dmaengine_pcm_config *config, unsigned int flags) 361 const struct snd_dmaengine_pcm_config *config, unsigned int flags)
316{ 362{
317 struct dmaengine_pcm *pcm; 363 struct dmaengine_pcm *pcm;
364 int ret;
318 365
319 pcm = kzalloc(sizeof(*pcm), GFP_KERNEL); 366 pcm = kzalloc(sizeof(*pcm), GFP_KERNEL);
320 if (!pcm) 367 if (!pcm)
@@ -323,14 +370,25 @@ int snd_dmaengine_pcm_register(struct device *dev,
323 pcm->config = config; 370 pcm->config = config;
324 pcm->flags = flags; 371 pcm->flags = flags;
325 372
326 dmaengine_pcm_request_chan_of(pcm, dev); 373 ret = dmaengine_pcm_request_chan_of(pcm, dev, config);
374 if (ret)
375 goto err_free_dma;
327 376
328 if (flags & SND_DMAENGINE_PCM_FLAG_NO_RESIDUE) 377 if (flags & SND_DMAENGINE_PCM_FLAG_NO_RESIDUE)
329 return snd_soc_add_platform(dev, &pcm->platform, 378 ret = snd_soc_add_platform(dev, &pcm->platform,
330 &dmaengine_no_residue_pcm_platform); 379 &dmaengine_no_residue_pcm_platform);
331 else 380 else
332 return snd_soc_add_platform(dev, &pcm->platform, 381 ret = snd_soc_add_platform(dev, &pcm->platform,
333 &dmaengine_pcm_platform); 382 &dmaengine_pcm_platform);
383 if (ret)
384 goto err_free_dma;
385
386 return 0;
387
388err_free_dma:
389 dmaengine_pcm_release_chan(pcm);
390 kfree(pcm);
391 return ret;
334} 392}
335EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_register); 393EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_register);
336 394
@@ -345,7 +403,6 @@ void snd_dmaengine_pcm_unregister(struct device *dev)
345{ 403{
346 struct snd_soc_platform *platform; 404 struct snd_soc_platform *platform;
347 struct dmaengine_pcm *pcm; 405 struct dmaengine_pcm *pcm;
348 unsigned int i;
349 406
350 platform = snd_soc_lookup_platform(dev); 407 platform = snd_soc_lookup_platform(dev);
351 if (!platform) 408 if (!platform)
@@ -353,15 +410,8 @@ void snd_dmaengine_pcm_unregister(struct device *dev)
353 410
354 pcm = soc_platform_to_pcm(platform); 411 pcm = soc_platform_to_pcm(platform);
355 412
356 for (i = SNDRV_PCM_STREAM_PLAYBACK; i <= SNDRV_PCM_STREAM_CAPTURE; i++) {
357 if (pcm->chan[i]) {
358 dma_release_channel(pcm->chan[i]);
359 if (pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX)
360 break;
361 }
362 }
363
364 snd_soc_remove_platform(platform); 413 snd_soc_remove_platform(platform);
414 dmaengine_pcm_release_chan(pcm);
365 kfree(pcm); 415 kfree(pcm);
366} 416}
367EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_unregister); 417EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_unregister);
diff --git a/sound/soc/tegra/Kconfig b/sound/soc/tegra/Kconfig
index 8fc653ca3ab4..896292bb853f 100644
--- a/sound/soc/tegra/Kconfig
+++ b/sound/soc/tegra/Kconfig
@@ -1,6 +1,8 @@
1config SND_SOC_TEGRA 1config SND_SOC_TEGRA
2 tristate "SoC Audio for the Tegra System-on-Chip" 2 tristate "SoC Audio for the Tegra System-on-Chip"
3 depends on (ARCH_TEGRA && TEGRA20_APB_DMA) || COMPILE_TEST 3 depends on (ARCH_TEGRA && TEGRA20_APB_DMA) || COMPILE_TEST
4 depends on COMMON_CLK
5 depends on RESET_CONTROLLER
4 select REGMAP_MMIO 6 select REGMAP_MMIO
5 select SND_SOC_GENERIC_DMAENGINE_PCM 7 select SND_SOC_GENERIC_DMAENGINE_PCM
6 help 8 help
diff --git a/sound/soc/tegra/tegra20_ac97.c b/sound/soc/tegra/tegra20_ac97.c
index ae27bcd586d2..d8b98d70ff41 100644
--- a/sound/soc/tegra/tegra20_ac97.c
+++ b/sound/soc/tegra/tegra20_ac97.c
@@ -313,7 +313,6 @@ static int tegra20_ac97_platform_probe(struct platform_device *pdev)
313{ 313{
314 struct tegra20_ac97 *ac97; 314 struct tegra20_ac97 *ac97;
315 struct resource *mem; 315 struct resource *mem;
316 u32 of_dma[2];
317 void __iomem *regs; 316 void __iomem *regs;
318 int ret = 0; 317 int ret = 0;
319 318
@@ -348,14 +347,6 @@ static int tegra20_ac97_platform_probe(struct platform_device *pdev)
348 goto err_clk_put; 347 goto err_clk_put;
349 } 348 }
350 349
351 if (of_property_read_u32_array(pdev->dev.of_node,
352 "nvidia,dma-request-selector",
353 of_dma, 2) < 0) {
354 dev_err(&pdev->dev, "No DMA resource\n");
355 ret = -ENODEV;
356 goto err_clk_put;
357 }
358
359 ac97->reset_gpio = of_get_named_gpio(pdev->dev.of_node, 350 ac97->reset_gpio = of_get_named_gpio(pdev->dev.of_node,
360 "nvidia,codec-reset-gpio", 0); 351 "nvidia,codec-reset-gpio", 0);
361 if (gpio_is_valid(ac97->reset_gpio)) { 352 if (gpio_is_valid(ac97->reset_gpio)) {
@@ -380,12 +371,10 @@ static int tegra20_ac97_platform_probe(struct platform_device *pdev)
380 ac97->capture_dma_data.addr = mem->start + TEGRA20_AC97_FIFO_RX1; 371 ac97->capture_dma_data.addr = mem->start + TEGRA20_AC97_FIFO_RX1;
381 ac97->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 372 ac97->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
382 ac97->capture_dma_data.maxburst = 4; 373 ac97->capture_dma_data.maxburst = 4;
383 ac97->capture_dma_data.slave_id = of_dma[1];
384 374
385 ac97->playback_dma_data.addr = mem->start + TEGRA20_AC97_FIFO_TX1; 375 ac97->playback_dma_data.addr = mem->start + TEGRA20_AC97_FIFO_TX1;
386 ac97->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 376 ac97->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
387 ac97->playback_dma_data.maxburst = 4; 377 ac97->playback_dma_data.maxburst = 4;
388 ac97->playback_dma_data.slave_id = of_dma[1];
389 378
390 ret = tegra_asoc_utils_init(&ac97->util_data, &pdev->dev); 379 ret = tegra_asoc_utils_init(&ac97->util_data, &pdev->dev);
391 if (ret) 380 if (ret)
diff --git a/sound/soc/tegra/tegra20_i2s.c b/sound/soc/tegra/tegra20_i2s.c
index 364bf6a907e1..1dc869c475e7 100644
--- a/sound/soc/tegra/tegra20_i2s.c
+++ b/sound/soc/tegra/tegra20_i2s.c
@@ -339,9 +339,7 @@ static const struct regmap_config tegra20_i2s_regmap_config = {
339static int tegra20_i2s_platform_probe(struct platform_device *pdev) 339static int tegra20_i2s_platform_probe(struct platform_device *pdev)
340{ 340{
341 struct tegra20_i2s *i2s; 341 struct tegra20_i2s *i2s;
342 struct resource *mem, *memregion, *dmareq; 342 struct resource *mem, *memregion;
343 u32 of_dma[2];
344 u32 dma_ch;
345 void __iomem *regs; 343 void __iomem *regs;
346 int ret; 344 int ret;
347 345
@@ -370,20 +368,6 @@ static int tegra20_i2s_platform_probe(struct platform_device *pdev)
370 goto err_clk_put; 368 goto err_clk_put;
371 } 369 }
372 370
373 dmareq = platform_get_resource(pdev, IORESOURCE_DMA, 0);
374 if (!dmareq) {
375 if (of_property_read_u32_array(pdev->dev.of_node,
376 "nvidia,dma-request-selector",
377 of_dma, 2) < 0) {
378 dev_err(&pdev->dev, "No DMA resource\n");
379 ret = -ENODEV;
380 goto err_clk_put;
381 }
382 dma_ch = of_dma[1];
383 } else {
384 dma_ch = dmareq->start;
385 }
386
387 memregion = devm_request_mem_region(&pdev->dev, mem->start, 371 memregion = devm_request_mem_region(&pdev->dev, mem->start,
388 resource_size(mem), DRV_NAME); 372 resource_size(mem), DRV_NAME);
389 if (!memregion) { 373 if (!memregion) {
@@ -410,12 +394,10 @@ static int tegra20_i2s_platform_probe(struct platform_device *pdev)
410 i2s->capture_dma_data.addr = mem->start + TEGRA20_I2S_FIFO2; 394 i2s->capture_dma_data.addr = mem->start + TEGRA20_I2S_FIFO2;
411 i2s->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 395 i2s->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
412 i2s->capture_dma_data.maxburst = 4; 396 i2s->capture_dma_data.maxburst = 4;
413 i2s->capture_dma_data.slave_id = dma_ch;
414 397
415 i2s->playback_dma_data.addr = mem->start + TEGRA20_I2S_FIFO1; 398 i2s->playback_dma_data.addr = mem->start + TEGRA20_I2S_FIFO1;
416 i2s->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 399 i2s->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
417 i2s->playback_dma_data.maxburst = 4; 400 i2s->playback_dma_data.maxburst = 4;
418 i2s->playback_dma_data.slave_id = dma_ch;
419 401
420 pm_runtime_enable(&pdev->dev); 402 pm_runtime_enable(&pdev->dev);
421 if (!pm_runtime_enabled(&pdev->dev)) { 403 if (!pm_runtime_enabled(&pdev->dev)) {
diff --git a/sound/soc/tegra/tegra30_ahub.c b/sound/soc/tegra/tegra30_ahub.c
index 31154338c1eb..d6f4c9940e0c 100644
--- a/sound/soc/tegra/tegra30_ahub.c
+++ b/sound/soc/tegra/tegra30_ahub.c
@@ -24,8 +24,8 @@
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/pm_runtime.h> 25#include <linux/pm_runtime.h>
26#include <linux/regmap.h> 26#include <linux/regmap.h>
27#include <linux/reset.h>
27#include <linux/slab.h> 28#include <linux/slab.h>
28#include <linux/clk/tegra.h>
29#include <sound/soc.h> 29#include <sound/soc.h>
30#include "tegra30_ahub.h" 30#include "tegra30_ahub.h"
31 31
@@ -95,8 +95,8 @@ static int tegra30_ahub_runtime_resume(struct device *dev)
95} 95}
96 96
97int tegra30_ahub_allocate_rx_fifo(enum tegra30_ahub_rxcif *rxcif, 97int tegra30_ahub_allocate_rx_fifo(enum tegra30_ahub_rxcif *rxcif,
98 dma_addr_t *fiforeg, 98 char *dmachan, int dmachan_len,
99 unsigned int *reqsel) 99 dma_addr_t *fiforeg)
100{ 100{
101 int channel; 101 int channel;
102 u32 reg, val; 102 u32 reg, val;
@@ -110,9 +110,11 @@ int tegra30_ahub_allocate_rx_fifo(enum tegra30_ahub_rxcif *rxcif,
110 __set_bit(channel, ahub->rx_usage); 110 __set_bit(channel, ahub->rx_usage);
111 111
112 *rxcif = TEGRA30_AHUB_RXCIF_APBIF_RX0 + channel; 112 *rxcif = TEGRA30_AHUB_RXCIF_APBIF_RX0 + channel;
113 snprintf(dmachan, dmachan_len, "rx%d", channel);
113 *fiforeg = ahub->apbif_addr + TEGRA30_AHUB_CHANNEL_RXFIFO + 114 *fiforeg = ahub->apbif_addr + TEGRA30_AHUB_CHANNEL_RXFIFO +
114 (channel * TEGRA30_AHUB_CHANNEL_RXFIFO_STRIDE); 115 (channel * TEGRA30_AHUB_CHANNEL_RXFIFO_STRIDE);
115 *reqsel = ahub->dma_sel + channel; 116
117 pm_runtime_get_sync(ahub->dev);
116 118
117 reg = TEGRA30_AHUB_CHANNEL_CTRL + 119 reg = TEGRA30_AHUB_CHANNEL_CTRL +
118 (channel * TEGRA30_AHUB_CHANNEL_CTRL_STRIDE); 120 (channel * TEGRA30_AHUB_CHANNEL_CTRL_STRIDE);
@@ -140,6 +142,8 @@ int tegra30_ahub_allocate_rx_fifo(enum tegra30_ahub_rxcif *rxcif,
140 (channel * TEGRA30_AHUB_CIF_RX_CTRL_STRIDE); 142 (channel * TEGRA30_AHUB_CIF_RX_CTRL_STRIDE);
141 ahub->soc_data->set_audio_cif(ahub->regmap_apbif, reg, &cif_conf); 143 ahub->soc_data->set_audio_cif(ahub->regmap_apbif, reg, &cif_conf);
142 144
145 pm_runtime_put(ahub->dev);
146
143 return 0; 147 return 0;
144} 148}
145EXPORT_SYMBOL_GPL(tegra30_ahub_allocate_rx_fifo); 149EXPORT_SYMBOL_GPL(tegra30_ahub_allocate_rx_fifo);
@@ -149,12 +153,16 @@ int tegra30_ahub_enable_rx_fifo(enum tegra30_ahub_rxcif rxcif)
149 int channel = rxcif - TEGRA30_AHUB_RXCIF_APBIF_RX0; 153 int channel = rxcif - TEGRA30_AHUB_RXCIF_APBIF_RX0;
150 int reg, val; 154 int reg, val;
151 155
156 pm_runtime_get_sync(ahub->dev);
157
152 reg = TEGRA30_AHUB_CHANNEL_CTRL + 158 reg = TEGRA30_AHUB_CHANNEL_CTRL +
153 (channel * TEGRA30_AHUB_CHANNEL_CTRL_STRIDE); 159 (channel * TEGRA30_AHUB_CHANNEL_CTRL_STRIDE);
154 val = tegra30_apbif_read(reg); 160 val = tegra30_apbif_read(reg);
155 val |= TEGRA30_AHUB_CHANNEL_CTRL_RX_EN; 161 val |= TEGRA30_AHUB_CHANNEL_CTRL_RX_EN;
156 tegra30_apbif_write(reg, val); 162 tegra30_apbif_write(reg, val);
157 163
164 pm_runtime_put(ahub->dev);
165
158 return 0; 166 return 0;
159} 167}
160EXPORT_SYMBOL_GPL(tegra30_ahub_enable_rx_fifo); 168EXPORT_SYMBOL_GPL(tegra30_ahub_enable_rx_fifo);
@@ -164,12 +172,16 @@ int tegra30_ahub_disable_rx_fifo(enum tegra30_ahub_rxcif rxcif)
164 int channel = rxcif - TEGRA30_AHUB_RXCIF_APBIF_RX0; 172 int channel = rxcif - TEGRA30_AHUB_RXCIF_APBIF_RX0;
165 int reg, val; 173 int reg, val;
166 174
175 pm_runtime_get_sync(ahub->dev);
176
167 reg = TEGRA30_AHUB_CHANNEL_CTRL + 177 reg = TEGRA30_AHUB_CHANNEL_CTRL +
168 (channel * TEGRA30_AHUB_CHANNEL_CTRL_STRIDE); 178 (channel * TEGRA30_AHUB_CHANNEL_CTRL_STRIDE);
169 val = tegra30_apbif_read(reg); 179 val = tegra30_apbif_read(reg);
170 val &= ~TEGRA30_AHUB_CHANNEL_CTRL_RX_EN; 180 val &= ~TEGRA30_AHUB_CHANNEL_CTRL_RX_EN;
171 tegra30_apbif_write(reg, val); 181 tegra30_apbif_write(reg, val);
172 182
183 pm_runtime_put(ahub->dev);
184
173 return 0; 185 return 0;
174} 186}
175EXPORT_SYMBOL_GPL(tegra30_ahub_disable_rx_fifo); 187EXPORT_SYMBOL_GPL(tegra30_ahub_disable_rx_fifo);
@@ -185,8 +197,8 @@ int tegra30_ahub_free_rx_fifo(enum tegra30_ahub_rxcif rxcif)
185EXPORT_SYMBOL_GPL(tegra30_ahub_free_rx_fifo); 197EXPORT_SYMBOL_GPL(tegra30_ahub_free_rx_fifo);
186 198
187int tegra30_ahub_allocate_tx_fifo(enum tegra30_ahub_txcif *txcif, 199int tegra30_ahub_allocate_tx_fifo(enum tegra30_ahub_txcif *txcif,
188 dma_addr_t *fiforeg, 200 char *dmachan, int dmachan_len,
189 unsigned int *reqsel) 201 dma_addr_t *fiforeg)
190{ 202{
191 int channel; 203 int channel;
192 u32 reg, val; 204 u32 reg, val;
@@ -200,9 +212,11 @@ int tegra30_ahub_allocate_tx_fifo(enum tegra30_ahub_txcif *txcif,
200 __set_bit(channel, ahub->tx_usage); 212 __set_bit(channel, ahub->tx_usage);
201 213
202 *txcif = TEGRA30_AHUB_TXCIF_APBIF_TX0 + channel; 214 *txcif = TEGRA30_AHUB_TXCIF_APBIF_TX0 + channel;
215 snprintf(dmachan, dmachan_len, "tx%d", channel);
203 *fiforeg = ahub->apbif_addr + TEGRA30_AHUB_CHANNEL_TXFIFO + 216 *fiforeg = ahub->apbif_addr + TEGRA30_AHUB_CHANNEL_TXFIFO +
204 (channel * TEGRA30_AHUB_CHANNEL_TXFIFO_STRIDE); 217 (channel * TEGRA30_AHUB_CHANNEL_TXFIFO_STRIDE);
205 *reqsel = ahub->dma_sel + channel; 218
219 pm_runtime_get_sync(ahub->dev);
206 220
207 reg = TEGRA30_AHUB_CHANNEL_CTRL + 221 reg = TEGRA30_AHUB_CHANNEL_CTRL +
208 (channel * TEGRA30_AHUB_CHANNEL_CTRL_STRIDE); 222 (channel * TEGRA30_AHUB_CHANNEL_CTRL_STRIDE);
@@ -230,6 +244,8 @@ int tegra30_ahub_allocate_tx_fifo(enum tegra30_ahub_txcif *txcif,
230 (channel * TEGRA30_AHUB_CIF_TX_CTRL_STRIDE); 244 (channel * TEGRA30_AHUB_CIF_TX_CTRL_STRIDE);
231 ahub->soc_data->set_audio_cif(ahub->regmap_apbif, reg, &cif_conf); 245 ahub->soc_data->set_audio_cif(ahub->regmap_apbif, reg, &cif_conf);
232 246
247 pm_runtime_put(ahub->dev);
248
233 return 0; 249 return 0;
234} 250}
235EXPORT_SYMBOL_GPL(tegra30_ahub_allocate_tx_fifo); 251EXPORT_SYMBOL_GPL(tegra30_ahub_allocate_tx_fifo);
@@ -239,12 +255,16 @@ int tegra30_ahub_enable_tx_fifo(enum tegra30_ahub_txcif txcif)
239 int channel = txcif - TEGRA30_AHUB_TXCIF_APBIF_TX0; 255 int channel = txcif - TEGRA30_AHUB_TXCIF_APBIF_TX0;
240 int reg, val; 256 int reg, val;
241 257
258 pm_runtime_get_sync(ahub->dev);
259
242 reg = TEGRA30_AHUB_CHANNEL_CTRL + 260 reg = TEGRA30_AHUB_CHANNEL_CTRL +
243 (channel * TEGRA30_AHUB_CHANNEL_CTRL_STRIDE); 261 (channel * TEGRA30_AHUB_CHANNEL_CTRL_STRIDE);
244 val = tegra30_apbif_read(reg); 262 val = tegra30_apbif_read(reg);
245 val |= TEGRA30_AHUB_CHANNEL_CTRL_TX_EN; 263 val |= TEGRA30_AHUB_CHANNEL_CTRL_TX_EN;
246 tegra30_apbif_write(reg, val); 264 tegra30_apbif_write(reg, val);
247 265
266 pm_runtime_put(ahub->dev);
267
248 return 0; 268 return 0;
249} 269}
250EXPORT_SYMBOL_GPL(tegra30_ahub_enable_tx_fifo); 270EXPORT_SYMBOL_GPL(tegra30_ahub_enable_tx_fifo);
@@ -254,12 +274,16 @@ int tegra30_ahub_disable_tx_fifo(enum tegra30_ahub_txcif txcif)
254 int channel = txcif - TEGRA30_AHUB_TXCIF_APBIF_TX0; 274 int channel = txcif - TEGRA30_AHUB_TXCIF_APBIF_TX0;
255 int reg, val; 275 int reg, val;
256 276
277 pm_runtime_get_sync(ahub->dev);
278
257 reg = TEGRA30_AHUB_CHANNEL_CTRL + 279 reg = TEGRA30_AHUB_CHANNEL_CTRL +
258 (channel * TEGRA30_AHUB_CHANNEL_CTRL_STRIDE); 280 (channel * TEGRA30_AHUB_CHANNEL_CTRL_STRIDE);
259 val = tegra30_apbif_read(reg); 281 val = tegra30_apbif_read(reg);
260 val &= ~TEGRA30_AHUB_CHANNEL_CTRL_TX_EN; 282 val &= ~TEGRA30_AHUB_CHANNEL_CTRL_TX_EN;
261 tegra30_apbif_write(reg, val); 283 tegra30_apbif_write(reg, val);
262 284
285 pm_runtime_put(ahub->dev);
286
263 return 0; 287 return 0;
264} 288}
265EXPORT_SYMBOL_GPL(tegra30_ahub_disable_tx_fifo); 289EXPORT_SYMBOL_GPL(tegra30_ahub_disable_tx_fifo);
@@ -280,10 +304,14 @@ int tegra30_ahub_set_rx_cif_source(enum tegra30_ahub_rxcif rxcif,
280 int channel = rxcif - TEGRA30_AHUB_RXCIF_APBIF_RX0; 304 int channel = rxcif - TEGRA30_AHUB_RXCIF_APBIF_RX0;
281 int reg; 305 int reg;
282 306
307 pm_runtime_get_sync(ahub->dev);
308
283 reg = TEGRA30_AHUB_AUDIO_RX + 309 reg = TEGRA30_AHUB_AUDIO_RX +
284 (channel * TEGRA30_AHUB_AUDIO_RX_STRIDE); 310 (channel * TEGRA30_AHUB_AUDIO_RX_STRIDE);
285 tegra30_audio_write(reg, 1 << txcif); 311 tegra30_audio_write(reg, 1 << txcif);
286 312
313 pm_runtime_put(ahub->dev);
314
287 return 0; 315 return 0;
288} 316}
289EXPORT_SYMBOL_GPL(tegra30_ahub_set_rx_cif_source); 317EXPORT_SYMBOL_GPL(tegra30_ahub_set_rx_cif_source);
@@ -293,35 +321,51 @@ int tegra30_ahub_unset_rx_cif_source(enum tegra30_ahub_rxcif rxcif)
293 int channel = rxcif - TEGRA30_AHUB_RXCIF_APBIF_RX0; 321 int channel = rxcif - TEGRA30_AHUB_RXCIF_APBIF_RX0;
294 int reg; 322 int reg;
295 323
324 pm_runtime_get_sync(ahub->dev);
325
296 reg = TEGRA30_AHUB_AUDIO_RX + 326 reg = TEGRA30_AHUB_AUDIO_RX +
297 (channel * TEGRA30_AHUB_AUDIO_RX_STRIDE); 327 (channel * TEGRA30_AHUB_AUDIO_RX_STRIDE);
298 tegra30_audio_write(reg, 0); 328 tegra30_audio_write(reg, 0);
299 329
330 pm_runtime_put(ahub->dev);
331
300 return 0; 332 return 0;
301} 333}
302EXPORT_SYMBOL_GPL(tegra30_ahub_unset_rx_cif_source); 334EXPORT_SYMBOL_GPL(tegra30_ahub_unset_rx_cif_source);
303 335
304#define CLK_LIST_MASK_TEGRA30 BIT(0) 336#define MOD_LIST_MASK_TEGRA30 BIT(0)
305#define CLK_LIST_MASK_TEGRA114 BIT(1) 337#define MOD_LIST_MASK_TEGRA114 BIT(1)
338#define MOD_LIST_MASK_TEGRA124 BIT(2)
306 339
307#define CLK_LIST_MASK_TEGRA30_OR_LATER \ 340#define MOD_LIST_MASK_TEGRA30_OR_LATER \
308 (CLK_LIST_MASK_TEGRA30 | CLK_LIST_MASK_TEGRA114) 341 (MOD_LIST_MASK_TEGRA30 | MOD_LIST_MASK_TEGRA114 | \
342 MOD_LIST_MASK_TEGRA124)
343#define MOD_LIST_MASK_TEGRA114_OR_LATER \
344 (MOD_LIST_MASK_TEGRA114 | MOD_LIST_MASK_TEGRA124)
309 345
310static const struct { 346static const struct {
311 const char *clk_name; 347 const char *rst_name;
312 u32 clk_list_mask; 348 u32 mod_list_mask;
313} configlink_clocks[] = { 349} configlink_mods[] = {
314 { "i2s0", CLK_LIST_MASK_TEGRA30_OR_LATER }, 350 { "i2s0", MOD_LIST_MASK_TEGRA30_OR_LATER },
315 { "i2s1", CLK_LIST_MASK_TEGRA30_OR_LATER }, 351 { "i2s1", MOD_LIST_MASK_TEGRA30_OR_LATER },
316 { "i2s2", CLK_LIST_MASK_TEGRA30_OR_LATER }, 352 { "i2s2", MOD_LIST_MASK_TEGRA30_OR_LATER },
317 { "i2s3", CLK_LIST_MASK_TEGRA30_OR_LATER }, 353 { "i2s3", MOD_LIST_MASK_TEGRA30_OR_LATER },
318 { "i2s4", CLK_LIST_MASK_TEGRA30_OR_LATER }, 354 { "i2s4", MOD_LIST_MASK_TEGRA30_OR_LATER },
319 { "dam0", CLK_LIST_MASK_TEGRA30_OR_LATER }, 355 { "dam0", MOD_LIST_MASK_TEGRA30_OR_LATER },
320 { "dam1", CLK_LIST_MASK_TEGRA30_OR_LATER }, 356 { "dam1", MOD_LIST_MASK_TEGRA30_OR_LATER },
321 { "dam2", CLK_LIST_MASK_TEGRA30_OR_LATER }, 357 { "dam2", MOD_LIST_MASK_TEGRA30_OR_LATER },
322 { "spdif_in", CLK_LIST_MASK_TEGRA30_OR_LATER }, 358 { "spdif", MOD_LIST_MASK_TEGRA30_OR_LATER },
323 { "amx", CLK_LIST_MASK_TEGRA114 }, 359 { "amx", MOD_LIST_MASK_TEGRA114_OR_LATER },
324 { "adx", CLK_LIST_MASK_TEGRA114 }, 360 { "adx", MOD_LIST_MASK_TEGRA114_OR_LATER },
361 { "amx1", MOD_LIST_MASK_TEGRA124 },
362 { "adx1", MOD_LIST_MASK_TEGRA124 },
363 { "afc0", MOD_LIST_MASK_TEGRA124 },
364 { "afc1", MOD_LIST_MASK_TEGRA124 },
365 { "afc2", MOD_LIST_MASK_TEGRA124 },
366 { "afc3", MOD_LIST_MASK_TEGRA124 },
367 { "afc4", MOD_LIST_MASK_TEGRA124 },
368 { "afc5", MOD_LIST_MASK_TEGRA124 },
325}; 369};
326 370
327#define LAST_REG(name) \ 371#define LAST_REG(name) \
@@ -450,17 +494,17 @@ static const struct regmap_config tegra30_ahub_ahub_regmap_config = {
450}; 494};
451 495
452static struct tegra30_ahub_soc_data soc_data_tegra30 = { 496static struct tegra30_ahub_soc_data soc_data_tegra30 = {
453 .clk_list_mask = CLK_LIST_MASK_TEGRA30, 497 .mod_list_mask = MOD_LIST_MASK_TEGRA30,
454 .set_audio_cif = tegra30_ahub_set_cif, 498 .set_audio_cif = tegra30_ahub_set_cif,
455}; 499};
456 500
457static struct tegra30_ahub_soc_data soc_data_tegra114 = { 501static struct tegra30_ahub_soc_data soc_data_tegra114 = {
458 .clk_list_mask = CLK_LIST_MASK_TEGRA114, 502 .mod_list_mask = MOD_LIST_MASK_TEGRA114,
459 .set_audio_cif = tegra30_ahub_set_cif, 503 .set_audio_cif = tegra30_ahub_set_cif,
460}; 504};
461 505
462static struct tegra30_ahub_soc_data soc_data_tegra124 = { 506static struct tegra30_ahub_soc_data soc_data_tegra124 = {
463 .clk_list_mask = CLK_LIST_MASK_TEGRA114, 507 .mod_list_mask = MOD_LIST_MASK_TEGRA124,
464 .set_audio_cif = tegra124_ahub_set_cif, 508 .set_audio_cif = tegra124_ahub_set_cif,
465}; 509};
466 510
@@ -475,10 +519,9 @@ static int tegra30_ahub_probe(struct platform_device *pdev)
475{ 519{
476 const struct of_device_id *match; 520 const struct of_device_id *match;
477 const struct tegra30_ahub_soc_data *soc_data; 521 const struct tegra30_ahub_soc_data *soc_data;
478 struct clk *clk; 522 struct reset_control *rst;
479 int i; 523 int i;
480 struct resource *res0, *res1, *region; 524 struct resource *res0, *res1, *region;
481 u32 of_dma[2];
482 void __iomem *regs_apbif, *regs_ahub; 525 void __iomem *regs_apbif, *regs_ahub;
483 int ret = 0; 526 int ret = 0;
484 527
@@ -495,19 +538,24 @@ static int tegra30_ahub_probe(struct platform_device *pdev)
495 * operate correctly, all devices on this bus must be out of reset. 538 * operate correctly, all devices on this bus must be out of reset.
496 * Ensure that here. 539 * Ensure that here.
497 */ 540 */
498 for (i = 0; i < ARRAY_SIZE(configlink_clocks); i++) { 541 for (i = 0; i < ARRAY_SIZE(configlink_mods); i++) {
499 if (!(configlink_clocks[i].clk_list_mask & 542 if (!(configlink_mods[i].mod_list_mask &
500 soc_data->clk_list_mask)) 543 soc_data->mod_list_mask))
501 continue; 544 continue;
502 clk = clk_get(&pdev->dev, configlink_clocks[i].clk_name); 545
503 if (IS_ERR(clk)) { 546 rst = reset_control_get(&pdev->dev,
504 dev_err(&pdev->dev, "Can't get clock %s\n", 547 configlink_mods[i].rst_name);
505 configlink_clocks[i].clk_name); 548 if (IS_ERR(rst)) {
506 ret = PTR_ERR(clk); 549 dev_err(&pdev->dev, "Can't get reset %s\n",
550 configlink_mods[i].rst_name);
551 ret = PTR_ERR(rst);
507 goto err; 552 goto err;
508 } 553 }
509 tegra_periph_reset_deassert(clk); 554
510 clk_put(clk); 555 ret = reset_control_deassert(rst);
556 reset_control_put(rst);
557 if (ret)
558 goto err;
511 } 559 }
512 560
513 ahub = devm_kzalloc(&pdev->dev, sizeof(struct tegra30_ahub), 561 ahub = devm_kzalloc(&pdev->dev, sizeof(struct tegra30_ahub),
@@ -536,16 +584,6 @@ static int tegra30_ahub_probe(struct platform_device *pdev)
536 goto err_clk_put_d_audio; 584 goto err_clk_put_d_audio;
537 } 585 }
538 586
539 if (of_property_read_u32_array(pdev->dev.of_node,
540 "nvidia,dma-request-selector",
541 of_dma, 2) < 0) {
542 dev_err(&pdev->dev,
543 "Missing property nvidia,dma-request-selector\n");
544 ret = -ENODEV;
545 goto err_clk_put_d_audio;
546 }
547 ahub->dma_sel = of_dma[1];
548
549 res0 = platform_get_resource(pdev, IORESOURCE_MEM, 0); 587 res0 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
550 if (!res0) { 588 if (!res0) {
551 dev_err(&pdev->dev, "No apbif memory resource\n"); 589 dev_err(&pdev->dev, "No apbif memory resource\n");
diff --git a/sound/soc/tegra/tegra30_ahub.h b/sound/soc/tegra/tegra30_ahub.h
index d67321d90faa..fd7ba75ed814 100644
--- a/sound/soc/tegra/tegra30_ahub.h
+++ b/sound/soc/tegra/tegra30_ahub.h
@@ -465,15 +465,15 @@ enum tegra30_ahub_rxcif {
465}; 465};
466 466
467extern int tegra30_ahub_allocate_rx_fifo(enum tegra30_ahub_rxcif *rxcif, 467extern int tegra30_ahub_allocate_rx_fifo(enum tegra30_ahub_rxcif *rxcif,
468 dma_addr_t *fiforeg, 468 char *dmachan, int dmachan_len,
469 unsigned int *reqsel); 469 dma_addr_t *fiforeg);
470extern int tegra30_ahub_enable_rx_fifo(enum tegra30_ahub_rxcif rxcif); 470extern int tegra30_ahub_enable_rx_fifo(enum tegra30_ahub_rxcif rxcif);
471extern int tegra30_ahub_disable_rx_fifo(enum tegra30_ahub_rxcif rxcif); 471extern int tegra30_ahub_disable_rx_fifo(enum tegra30_ahub_rxcif rxcif);
472extern int tegra30_ahub_free_rx_fifo(enum tegra30_ahub_rxcif rxcif); 472extern int tegra30_ahub_free_rx_fifo(enum tegra30_ahub_rxcif rxcif);
473 473
474extern int tegra30_ahub_allocate_tx_fifo(enum tegra30_ahub_txcif *txcif, 474extern int tegra30_ahub_allocate_tx_fifo(enum tegra30_ahub_txcif *txcif,
475 dma_addr_t *fiforeg, 475 char *dmachan, int dmachan_len,
476 unsigned int *reqsel); 476 dma_addr_t *fiforeg);
477extern int tegra30_ahub_enable_tx_fifo(enum tegra30_ahub_txcif txcif); 477extern int tegra30_ahub_enable_tx_fifo(enum tegra30_ahub_txcif txcif);
478extern int tegra30_ahub_disable_tx_fifo(enum tegra30_ahub_txcif txcif); 478extern int tegra30_ahub_disable_tx_fifo(enum tegra30_ahub_txcif txcif);
479extern int tegra30_ahub_free_tx_fifo(enum tegra30_ahub_txcif txcif); 479extern int tegra30_ahub_free_tx_fifo(enum tegra30_ahub_txcif txcif);
@@ -502,7 +502,7 @@ void tegra124_ahub_set_cif(struct regmap *regmap, unsigned int reg,
502 struct tegra30_ahub_cif_conf *conf); 502 struct tegra30_ahub_cif_conf *conf);
503 503
504struct tegra30_ahub_soc_data { 504struct tegra30_ahub_soc_data {
505 u32 clk_list_mask; 505 u32 mod_list_mask;
506 void (*set_audio_cif)(struct regmap *regmap, 506 void (*set_audio_cif)(struct regmap *regmap,
507 unsigned int reg, 507 unsigned int reg,
508 struct tegra30_ahub_cif_conf *conf); 508 struct tegra30_ahub_cif_conf *conf);
@@ -524,7 +524,6 @@ struct tegra30_ahub {
524 struct device *dev; 524 struct device *dev;
525 struct clk *clk_d_audio; 525 struct clk *clk_d_audio;
526 struct clk *clk_apbif; 526 struct clk *clk_apbif;
527 int dma_sel;
528 resource_size_t apbif_addr; 527 resource_size_t apbif_addr;
529 struct regmap *regmap_apbif; 528 struct regmap *regmap_apbif;
530 struct regmap *regmap_ahub; 529 struct regmap *regmap_ahub;
diff --git a/sound/soc/tegra/tegra30_i2s.c b/sound/soc/tegra/tegra30_i2s.c
index 231a785b3921..362e8f728ddf 100644
--- a/sound/soc/tegra/tegra30_i2s.c
+++ b/sound/soc/tegra/tegra30_i2s.c
@@ -73,47 +73,6 @@ static int tegra30_i2s_runtime_resume(struct device *dev)
73 return 0; 73 return 0;
74} 74}
75 75
76static int tegra30_i2s_startup(struct snd_pcm_substream *substream,
77 struct snd_soc_dai *dai)
78{
79 struct tegra30_i2s *i2s = snd_soc_dai_get_drvdata(dai);
80 int ret;
81
82 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
83 ret = tegra30_ahub_allocate_tx_fifo(&i2s->playback_fifo_cif,
84 &i2s->playback_dma_data.addr,
85 &i2s->playback_dma_data.slave_id);
86 i2s->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
87 i2s->playback_dma_data.maxburst = 4;
88 tegra30_ahub_set_rx_cif_source(i2s->playback_i2s_cif,
89 i2s->playback_fifo_cif);
90 } else {
91 ret = tegra30_ahub_allocate_rx_fifo(&i2s->capture_fifo_cif,
92 &i2s->capture_dma_data.addr,
93 &i2s->capture_dma_data.slave_id);
94 i2s->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
95 i2s->capture_dma_data.maxburst = 4;
96 tegra30_ahub_set_rx_cif_source(i2s->capture_fifo_cif,
97 i2s->capture_i2s_cif);
98 }
99
100 return ret;
101}
102
103static void tegra30_i2s_shutdown(struct snd_pcm_substream *substream,
104 struct snd_soc_dai *dai)
105{
106 struct tegra30_i2s *i2s = snd_soc_dai_get_drvdata(dai);
107
108 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
109 tegra30_ahub_unset_rx_cif_source(i2s->playback_i2s_cif);
110 tegra30_ahub_free_tx_fifo(i2s->playback_fifo_cif);
111 } else {
112 tegra30_ahub_unset_rx_cif_source(i2s->capture_fifo_cif);
113 tegra30_ahub_free_rx_fifo(i2s->capture_fifo_cif);
114 }
115}
116
117static int tegra30_i2s_set_fmt(struct snd_soc_dai *dai, 76static int tegra30_i2s_set_fmt(struct snd_soc_dai *dai,
118 unsigned int fmt) 77 unsigned int fmt)
119{ 78{
@@ -317,8 +276,6 @@ static int tegra30_i2s_probe(struct snd_soc_dai *dai)
317} 276}
318 277
319static struct snd_soc_dai_ops tegra30_i2s_dai_ops = { 278static struct snd_soc_dai_ops tegra30_i2s_dai_ops = {
320 .startup = tegra30_i2s_startup,
321 .shutdown = tegra30_i2s_shutdown,
322 .set_fmt = tegra30_i2s_set_fmt, 279 .set_fmt = tegra30_i2s_set_fmt,
323 .hw_params = tegra30_i2s_hw_params, 280 .hw_params = tegra30_i2s_hw_params,
324 .trigger = tegra30_i2s_trigger, 281 .trigger = tegra30_i2s_trigger,
@@ -499,15 +456,51 @@ static int tegra30_i2s_platform_probe(struct platform_device *pdev)
499 goto err_pm_disable; 456 goto err_pm_disable;
500 } 457 }
501 458
459 i2s->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
460 i2s->playback_dma_data.maxburst = 4;
461 ret = tegra30_ahub_allocate_tx_fifo(&i2s->playback_fifo_cif,
462 i2s->playback_dma_chan,
463 sizeof(i2s->playback_dma_chan),
464 &i2s->playback_dma_data.addr);
465 if (ret) {
466 dev_err(&pdev->dev, "Could not alloc TX FIFO: %d\n", ret);
467 goto err_suspend;
468 }
469 ret = tegra30_ahub_set_rx_cif_source(i2s->playback_i2s_cif,
470 i2s->playback_fifo_cif);
471 if (ret) {
472 dev_err(&pdev->dev, "Could not route TX FIFO: %d\n", ret);
473 goto err_free_tx_fifo;
474 }
475
476 i2s->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
477 i2s->capture_dma_data.maxburst = 4;
478 ret = tegra30_ahub_allocate_rx_fifo(&i2s->capture_fifo_cif,
479 i2s->capture_dma_chan,
480 sizeof(i2s->capture_dma_chan),
481 &i2s->capture_dma_data.addr);
482 if (ret) {
483 dev_err(&pdev->dev, "Could not alloc RX FIFO: %d\n", ret);
484 goto err_unroute_tx_fifo;
485 }
486 ret = tegra30_ahub_set_rx_cif_source(i2s->capture_fifo_cif,
487 i2s->capture_i2s_cif);
488 if (ret) {
489 dev_err(&pdev->dev, "Could not route TX FIFO: %d\n", ret);
490 goto err_free_rx_fifo;
491 }
492
502 ret = snd_soc_register_component(&pdev->dev, &tegra30_i2s_component, 493 ret = snd_soc_register_component(&pdev->dev, &tegra30_i2s_component,
503 &i2s->dai, 1); 494 &i2s->dai, 1);
504 if (ret) { 495 if (ret) {
505 dev_err(&pdev->dev, "Could not register DAI: %d\n", ret); 496 dev_err(&pdev->dev, "Could not register DAI: %d\n", ret);
506 ret = -ENOMEM; 497 ret = -ENOMEM;
507 goto err_suspend; 498 goto err_unroute_rx_fifo;
508 } 499 }
509 500
510 ret = tegra_pcm_platform_register(&pdev->dev); 501 ret = tegra_pcm_platform_register_with_chan_names(&pdev->dev,
502 &i2s->dma_config, i2s->playback_dma_chan,
503 i2s->capture_dma_chan);
511 if (ret) { 504 if (ret) {
512 dev_err(&pdev->dev, "Could not register PCM: %d\n", ret); 505 dev_err(&pdev->dev, "Could not register PCM: %d\n", ret);
513 goto err_unregister_component; 506 goto err_unregister_component;
@@ -517,6 +510,14 @@ static int tegra30_i2s_platform_probe(struct platform_device *pdev)
517 510
518err_unregister_component: 511err_unregister_component:
519 snd_soc_unregister_component(&pdev->dev); 512 snd_soc_unregister_component(&pdev->dev);
513err_unroute_rx_fifo:
514 tegra30_ahub_unset_rx_cif_source(i2s->capture_fifo_cif);
515err_free_rx_fifo:
516 tegra30_ahub_free_rx_fifo(i2s->capture_fifo_cif);
517err_unroute_tx_fifo:
518 tegra30_ahub_unset_rx_cif_source(i2s->playback_i2s_cif);
519err_free_tx_fifo:
520 tegra30_ahub_free_tx_fifo(i2s->playback_fifo_cif);
520err_suspend: 521err_suspend:
521 if (!pm_runtime_status_suspended(&pdev->dev)) 522 if (!pm_runtime_status_suspended(&pdev->dev))
522 tegra30_i2s_runtime_suspend(&pdev->dev); 523 tegra30_i2s_runtime_suspend(&pdev->dev);
@@ -539,6 +540,12 @@ static int tegra30_i2s_platform_remove(struct platform_device *pdev)
539 tegra_pcm_platform_unregister(&pdev->dev); 540 tegra_pcm_platform_unregister(&pdev->dev);
540 snd_soc_unregister_component(&pdev->dev); 541 snd_soc_unregister_component(&pdev->dev);
541 542
543 tegra30_ahub_unset_rx_cif_source(i2s->capture_fifo_cif);
544 tegra30_ahub_free_rx_fifo(i2s->capture_fifo_cif);
545
546 tegra30_ahub_unset_rx_cif_source(i2s->playback_i2s_cif);
547 tegra30_ahub_free_tx_fifo(i2s->playback_fifo_cif);
548
542 clk_put(i2s->clk_i2s); 549 clk_put(i2s->clk_i2s);
543 550
544 return 0; 551 return 0;
diff --git a/sound/soc/tegra/tegra30_i2s.h b/sound/soc/tegra/tegra30_i2s.h
index 4d0b0a30dbfb..774fc6ad2026 100644
--- a/sound/soc/tegra/tegra30_i2s.h
+++ b/sound/soc/tegra/tegra30_i2s.h
@@ -238,11 +238,14 @@ struct tegra30_i2s {
238 struct clk *clk_i2s; 238 struct clk *clk_i2s;
239 enum tegra30_ahub_txcif capture_i2s_cif; 239 enum tegra30_ahub_txcif capture_i2s_cif;
240 enum tegra30_ahub_rxcif capture_fifo_cif; 240 enum tegra30_ahub_rxcif capture_fifo_cif;
241 char capture_dma_chan[8];
241 struct snd_dmaengine_dai_dma_data capture_dma_data; 242 struct snd_dmaengine_dai_dma_data capture_dma_data;
242 enum tegra30_ahub_rxcif playback_i2s_cif; 243 enum tegra30_ahub_rxcif playback_i2s_cif;
243 enum tegra30_ahub_txcif playback_fifo_cif; 244 enum tegra30_ahub_txcif playback_fifo_cif;
245 char playback_dma_chan[8];
244 struct snd_dmaengine_dai_dma_data playback_dma_data; 246 struct snd_dmaengine_dai_dma_data playback_dma_data;
245 struct regmap *regmap; 247 struct regmap *regmap;
248 struct snd_dmaengine_pcm_config dma_config;
246}; 249};
247 250
248#endif 251#endif
diff --git a/sound/soc/tegra/tegra_pcm.c b/sound/soc/tegra/tegra_pcm.c
index 7b2d23ba69b3..7ce5c334a660 100644
--- a/sound/soc/tegra/tegra_pcm.c
+++ b/sound/soc/tegra/tegra_pcm.c
@@ -61,12 +61,23 @@ static const struct snd_dmaengine_pcm_config tegra_dmaengine_pcm_config = {
61 61
62int tegra_pcm_platform_register(struct device *dev) 62int tegra_pcm_platform_register(struct device *dev)
63{ 63{
64 return snd_dmaengine_pcm_register(dev, &tegra_dmaengine_pcm_config, 64 return snd_dmaengine_pcm_register(dev, &tegra_dmaengine_pcm_config, 0);
65 SND_DMAENGINE_PCM_FLAG_NO_DT |
66 SND_DMAENGINE_PCM_FLAG_COMPAT);
67} 65}
68EXPORT_SYMBOL_GPL(tegra_pcm_platform_register); 66EXPORT_SYMBOL_GPL(tegra_pcm_platform_register);
69 67
68int tegra_pcm_platform_register_with_chan_names(struct device *dev,
69 struct snd_dmaengine_pcm_config *config,
70 char *txdmachan, char *rxdmachan)
71{
72 *config = tegra_dmaengine_pcm_config;
73 config->dma_dev = dev->parent;
74 config->chan_names[0] = txdmachan;
75 config->chan_names[1] = rxdmachan;
76
77 return snd_dmaengine_pcm_register(dev, config, 0);
78}
79EXPORT_SYMBOL_GPL(tegra_pcm_platform_register_with_chan_names);
80
70void tegra_pcm_platform_unregister(struct device *dev) 81void tegra_pcm_platform_unregister(struct device *dev)
71{ 82{
72 return snd_dmaengine_pcm_unregister(dev); 83 return snd_dmaengine_pcm_unregister(dev);
diff --git a/sound/soc/tegra/tegra_pcm.h b/sound/soc/tegra/tegra_pcm.h
index 68ad901714a9..7883dec748a3 100644
--- a/sound/soc/tegra/tegra_pcm.h
+++ b/sound/soc/tegra/tegra_pcm.h
@@ -31,7 +31,12 @@
31#ifndef __TEGRA_PCM_H__ 31#ifndef __TEGRA_PCM_H__
32#define __TEGRA_PCM_H__ 32#define __TEGRA_PCM_H__
33 33
34struct snd_dmaengine_pcm_config;
35
34int tegra_pcm_platform_register(struct device *dev); 36int tegra_pcm_platform_register(struct device *dev);
37int tegra_pcm_platform_register_with_chan_names(struct device *dev,
38 struct snd_dmaengine_pcm_config *config,
39 char *txdmachan, char *rxdmachan);
35void tegra_pcm_platform_unregister(struct device *dev); 40void tegra_pcm_platform_unregister(struct device *dev);
36 41
37#endif 42#endif
diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
index 3454262358b3..f4b12c216f1c 100644
--- a/sound/usb/mixer_quirks.c
+++ b/sound/usb/mixer_quirks.c
@@ -1603,7 +1603,7 @@ static int snd_microii_controls_create(struct usb_mixer_interface *mixer)
1603 return err; 1603 return err;
1604 } 1604 }
1605 1605
1606 return err; 1606 return 0;
1607} 1607}
1608 1608
1609int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer) 1609int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer)
diff --git a/tools/usb/Makefile b/tools/usb/Makefile
index 396d6c44e9d7..acf2165c04e6 100644
--- a/tools/usb/Makefile
+++ b/tools/usb/Makefile
@@ -3,11 +3,12 @@
3CC = $(CROSS_COMPILE)gcc 3CC = $(CROSS_COMPILE)gcc
4PTHREAD_LIBS = -lpthread 4PTHREAD_LIBS = -lpthread
5WARNINGS = -Wall -Wextra 5WARNINGS = -Wall -Wextra
6CFLAGS = $(WARNINGS) -g $(PTHREAD_LIBS) -I../include 6CFLAGS = $(WARNINGS) -g -I../include
7LDFLAGS = $(PTHREAD_LIBS)
7 8
8all: testusb ffs-test 9all: testusb ffs-test
9%: %.c 10%: %.c
10 $(CC) $(CFLAGS) -o $@ $^ 11 $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
11 12
12clean: 13clean:
13 $(RM) testusb ffs-test 14 $(RM) testusb ffs-test
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index a0aa84b5941a..4f588bc94186 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1898,6 +1898,9 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, u32 id)
1898 int r; 1898 int r;
1899 struct kvm_vcpu *vcpu, *v; 1899 struct kvm_vcpu *vcpu, *v;
1900 1900
1901 if (id >= KVM_MAX_VCPUS)
1902 return -EINVAL;
1903
1901 vcpu = kvm_arch_vcpu_create(kvm, id); 1904 vcpu = kvm_arch_vcpu_create(kvm, id);
1902 if (IS_ERR(vcpu)) 1905 if (IS_ERR(vcpu))
1903 return PTR_ERR(vcpu); 1906 return PTR_ERR(vcpu);