aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-03-06 08:25:27 -0500
committerTakashi Iwai <tiwai@suse.de>2015-03-06 08:25:27 -0500
commita52afea68f94d2501b7fe1fa18cc6acf84e35a76 (patch)
tree977eb066b9de1bea4e7ce7ea9a5583d00279061f
parent8b28c93fe5a55873ce22b7126e84eb59290f8603 (diff)
parentd7e3281b52fea8917fb4a7a5b09df5e6a9d2850c (diff)
Merge tag 'asoc-v4.1' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-next
ASoC: Changes for v4.1 A selection of changes for v4.1 so far. The main things are: - Move of jack registration to the card where it belongs. - Support for DAPM routes specified by both the machine driver and DT.
-rw-r--r--Documentation/cgroups/unified-hierarchy.txt4
-rw-r--r--Documentation/devicetree/bindings/sound/nvidia,tegra-audio-max98090.txt1
-rw-r--r--Documentation/filesystems/dlmfs.txt4
-rw-r--r--Documentation/filesystems/ocfs2.txt4
-rw-r--r--MAINTAINERS3
-rw-r--r--Makefile2
-rw-r--r--arch/arm/boot/dts/am335x-bone-common.dtsi1
-rw-r--r--arch/arm/boot/dts/am437x-idk-evm.dts25
-rw-r--r--arch/arm/boot/dts/am57xx-beagle-x15.dts8
-rw-r--r--arch/arm/boot/dts/dm8168-evm.dts25
-rw-r--r--arch/arm/boot/dts/dm816x.dtsi34
-rw-r--r--arch/arm/boot/dts/dra7-evm.dts8
-rw-r--r--arch/arm/boot/dts/dra7.dtsi8
-rw-r--r--arch/arm/boot/dts/dra72-evm.dts8
-rw-r--r--arch/arm/boot/dts/omap2.dtsi4
-rw-r--r--arch/arm/boot/dts/omap3-n900.dts9
-rw-r--r--arch/arm/boot/dts/omap3.dtsi4
-rw-r--r--arch/arm/boot/dts/omap4.dtsi4
-rw-r--r--arch/arm/boot/dts/omap5.dtsi8
-rw-r--r--arch/arm/configs/multi_v7_defconfig82
-rw-r--r--arch/arm/configs/omap2plus_defconfig4
-rw-r--r--arch/arm/mach-asm9260/Kconfig2
-rw-r--r--arch/arm64/boot/dts/arm/foundation-v8.dts8
-rw-r--r--arch/arm64/boot/dts/arm/juno.dts14
-rw-r--r--arch/arm64/boot/dts/arm/rtsm_ve-aemv8a.dts8
-rw-r--r--arch/arm64/crypto/Makefile2
-rw-r--r--arch/arm64/include/asm/assembler.h5
-rw-r--r--arch/arm64/include/asm/cpuidle.h2
-rw-r--r--arch/arm64/include/asm/insn.h6
-rw-r--r--arch/arm64/include/asm/pgtable.h2
-rw-r--r--arch/arm64/include/asm/processor.h3
-rw-r--r--arch/arm64/include/asm/tlbflush.h5
-rw-r--r--arch/arm64/kernel/Makefile5
-rw-r--r--arch/arm64/kernel/ftrace.c2
-rw-r--r--arch/arm64/kernel/insn.c4
-rw-r--r--arch/arm64/kernel/psci-call.S28
-rw-r--r--arch/arm64/kernel/psci.c37
-rw-r--r--arch/arm64/kernel/signal32.c5
-rw-r--r--arch/arm64/kernel/vdso/gettimeofday.S3
-rw-r--r--arch/arm64/mm/dma-mapping.c16
-rw-r--r--arch/arm64/mm/init.c14
-rw-r--r--arch/frv/include/asm/pgtable.h2
-rw-r--r--arch/m32r/include/asm/pgtable-2level.h1
-rw-r--r--arch/m68k/include/asm/pgtable_mm.h2
-rw-r--r--arch/metag/include/asm/processor.h4
-rw-r--r--arch/mn10300/include/asm/pgtable.h2
-rw-r--r--arch/parisc/include/asm/pgtable.h1
-rw-r--r--arch/s390/include/asm/pgtable.h2
-rw-r--r--arch/x86/kernel/cpu/common.c6
-rw-r--r--arch/x86/kernel/cpu/intel.c4
-rw-r--r--arch/x86/kernel/entry_32.S3
-rw-r--r--arch/x86/kernel/entry_64.S3
-rw-r--r--arch/x86/kernel/kprobes/core.c54
-rw-r--r--arch/x86/kernel/kprobes/opt.c2
-rw-r--r--arch/x86/lguest/Kconfig4
-rw-r--r--arch/x86/platform/intel-mid/intel-mid.c2
-rw-r--r--arch/x86/xen/enlighten.c20
-rw-r--r--drivers/block/nvme-core.c99
-rw-r--r--drivers/block/zram/zram_drv.c2
-rw-r--r--drivers/clocksource/Kconfig16
-rw-r--r--drivers/clocksource/mtk_timer.c9
-rw-r--r--drivers/clocksource/pxa_timer.c2
-rw-r--r--drivers/gpio/gpio-tps65912.c14
-rw-r--r--drivers/gpio/gpiolib-of.c9
-rw-r--r--drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c10
-rw-r--r--drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h8
-rw-r--r--drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_cik.c2
-rw-r--r--drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c2
-rw-r--r--drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c2
-rw-r--r--drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_layer.c3
-rw-r--r--drivers/gpu/drm/drm_crtc.c3
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h15
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c3
-rw-r--r--drivers/gpu/drm/i915/i915_gem_stolen.c6
-rw-r--r--drivers/gpu/drm/i915/i915_gem_tiling.c7
-rw-r--r--drivers/gpu/drm/i915/i915_irq.c22
-rw-r--r--drivers/gpu/drm/i915/intel_display.c34
-rw-r--r--drivers/gpu/drm/i915/intel_lrc.c8
-rw-r--r--drivers/gpu/drm/radeon/atombios_dp.c7
-rw-r--r--drivers/gpu/drm/radeon/atombios_encoders.c21
-rw-r--r--drivers/gpu/drm/radeon/cik.c8
-rw-r--r--drivers/gpu/drm/radeon/cikd.h4
-rw-r--r--drivers/gpu/drm/radeon/evergreen.c7
-rw-r--r--drivers/gpu/drm/radeon/evergreend.h4
-rw-r--r--drivers/gpu/drm/radeon/ni.c10
-rw-r--r--drivers/gpu/drm/radeon/nid.h4
-rw-r--r--drivers/gpu/drm/radeon/r600_dpm.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_cs.c16
-rw-r--r--drivers/gpu/drm/radeon/radeon_encoders.c3
-rw-r--r--drivers/gpu/drm/radeon/radeon_pm.c6
-rw-r--r--drivers/gpu/drm/radeon/si.c22
-rw-r--r--drivers/gpu/drm/radeon/sid.h4
-rw-r--r--drivers/gpu/drm/tegra/dc.c79
-rw-r--r--drivers/gpu/drm/tegra/hdmi.c8
-rw-r--r--drivers/hid/hid-core.c2
-rw-r--r--drivers/hid/hid-ids.h2
-rw-r--r--drivers/hid/hid-microsoft.c2
-rw-r--r--drivers/hid/hid-saitek.c2
-rw-r--r--drivers/hid/hid-sensor-hub.c8
-rw-r--r--drivers/hid/hid-sony.c6
-rw-r--r--drivers/hid/i2c-hid/i2c-hid.c7
-rw-r--r--drivers/hid/wacom_wac.c11
-rw-r--r--drivers/hwmon/ads7828.c3
-rw-r--r--drivers/md/md.c14
-rw-r--r--drivers/md/raid1.c5
-rw-r--r--drivers/md/raid5.c13
-rw-r--r--drivers/rtc/rtc-ds1685.c18
-rw-r--r--drivers/sh/pm_runtime.c2
-rw-r--r--drivers/thermal/int340x_thermal/int3400_thermal.c10
-rw-r--r--drivers/thermal/intel_powerclamp.c1
-rw-r--r--drivers/thermal/rcar_thermal.c26
-rw-r--r--drivers/thermal/samsung/exynos_tmu.c38
-rw-r--r--drivers/thermal/ti-soc-thermal/ti-bandgap.c2
-rw-r--r--drivers/thermal/ti-soc-thermal/ti-thermal-common.c2
-rw-r--r--drivers/xen/Makefile2
-rw-r--r--drivers/xen/preempt.c44
-rw-r--r--drivers/xen/privcmd.c2
-rw-r--r--drivers/xen/xen-scsiback.c14
-rw-r--r--fs/btrfs/volumes.c9
-rw-r--r--fs/nilfs2/btree.c47
-rw-r--r--fs/xfs/xfs_file.c14
-rw-r--r--fs/xfs/xfs_inode.c4
-rw-r--r--fs/xfs/xfs_inode.h9
-rw-r--r--fs/xfs/xfs_iops.c36
-rw-r--r--fs/xfs/xfs_pnfs.c4
-rw-r--r--fs/xfs/xfs_qm.c5
-rw-r--r--include/drm/i915_pciids.h4
-rw-r--r--include/linux/hid-sensor-hub.h5
-rw-r--r--include/linux/thermal.h56
-rw-r--r--include/sound/pcm_params.h7
-rw-r--r--include/sound/soc.h16
-rw-r--r--include/xen/xen-ops.h26
-rw-r--r--kernel/livepatch/core.c10
-rw-r--r--kernel/locking/rtmutex.c1
-rw-r--r--kernel/sys.c3
-rw-r--r--mm/memcontrol.c16
-rw-r--r--mm/nommu.c4
-rw-r--r--mm/page_alloc.c9
-rw-r--r--mm/shmem.c3
-rw-r--r--scripts/gdb/linux/__init__.py1
-rw-r--r--sound/core/pcm_native.c2
-rw-r--r--sound/pci/hda/hda_controller.c5
-rw-r--r--sound/pci/hda/hda_intel.c2
-rw-r--r--sound/soc/atmel/atmel_ssc_dai.c111
-rw-r--r--sound/soc/atmel/atmel_ssc_dai.h1
-rw-r--r--sound/soc/atmel/sam9g20_wm8731.c68
-rw-r--r--sound/soc/cirrus/Kconfig2
-rw-r--r--sound/soc/codecs/Kconfig20
-rw-r--r--sound/soc/codecs/Makefile4
-rw-r--r--sound/soc/codecs/adau1977.c17
-rw-r--r--sound/soc/codecs/cs35l32.c19
-rw-r--r--sound/soc/codecs/cs4265.c19
-rw-r--r--sound/soc/codecs/max98357a.c23
-rw-r--r--sound/soc/codecs/pcm512x.c178
-rw-r--r--sound/soc/codecs/rt286.c17
-rw-r--r--sound/soc/codecs/rt5670.c7
-rw-r--r--sound/soc/codecs/rt5670.h3
-rw-r--r--sound/soc/codecs/rt5677.c76
-rw-r--r--sound/soc/codecs/rt5677.h6
-rw-r--r--sound/soc/codecs/sn95031.c14
-rw-r--r--sound/soc/codecs/sn95031.h3
-rw-r--r--sound/soc/codecs/sta32x.c6
-rw-r--r--sound/soc/codecs/sta350.c30
-rw-r--r--sound/soc/codecs/tas2552.c13
-rw-r--r--sound/soc/codecs/wm8804-i2c.c64
-rw-r--r--sound/soc/codecs/wm8804-spi.c56
-rw-r--r--sound/soc/codecs/wm8804.c281
-rw-r--r--sound/soc/codecs/wm8804.h7
-rw-r--r--sound/soc/codecs/wm_adsp.c13
-rw-r--r--sound/soc/davinci/Kconfig18
-rw-r--r--sound/soc/davinci/Makefile2
-rw-r--r--sound/soc/davinci/davinci-i2s.c67
-rw-r--r--sound/soc/davinci/davinci-mcasp.c99
-rw-r--r--sound/soc/davinci/davinci-pcm.c861
-rw-r--r--sound/soc/davinci/davinci-pcm.h41
-rw-r--r--sound/soc/davinci/davinci-vcif.c55
-rw-r--r--sound/soc/fsl/fsl-asoc-card.c6
-rw-r--r--sound/soc/fsl/fsl_ssi.c11
-rw-r--r--sound/soc/fsl/imx-es8328.c6
-rw-r--r--sound/soc/fsl/wm1133-ev1.c12
-rw-r--r--sound/soc/generic/simple-card.c25
-rw-r--r--sound/soc/intel/broadwell.c16
-rw-r--r--sound/soc/intel/byt-max98090.c11
-rw-r--r--sound/soc/intel/bytcr_dpcm_rt5640.c4
-rw-r--r--sound/soc/intel/cht_bsw_rt5645.c16
-rw-r--r--sound/soc/intel/cht_bsw_rt5672.c9
-rw-r--r--sound/soc/intel/haswell.c4
-rw-r--r--sound/soc/intel/mfld_machine.c24
-rw-r--r--sound/soc/intel/sst-atom-controls.h2
-rw-r--r--sound/soc/intel/sst-mfld-platform-pcm.c60
-rw-r--r--sound/soc/intel/sst-mfld-platform.h1
-rw-r--r--sound/soc/intel/sst/sst.c138
-rw-r--r--sound/soc/intel/sst/sst.h12
-rw-r--r--sound/soc/intel/sst/sst_drv_interface.c65
-rw-r--r--sound/soc/intel/sst/sst_loader.c10
-rw-r--r--sound/soc/omap/Kconfig4
-rw-r--r--sound/soc/omap/ams-delta.c4
-rw-r--r--sound/soc/omap/omap-abe-twl6040.c10
-rw-r--r--sound/soc/omap/omap-hdmi-audio.c3
-rw-r--r--sound/soc/omap/omap-mcbsp.c11
-rw-r--r--sound/soc/omap/omap-pcm.c23
-rw-r--r--sound/soc/omap/omap-twl4030.c12
-rw-r--r--sound/soc/omap/rx51.c6
-rw-r--r--sound/soc/pxa/hx4700.c11
-rw-r--r--sound/soc/pxa/palm27x.c11
-rw-r--r--sound/soc/pxa/ttc-dkb.c15
-rw-r--r--sound/soc/pxa/z2.c10
-rw-r--r--sound/soc/samsung/Kconfig10
-rw-r--r--sound/soc/samsung/h1940_uda1380.c9
-rw-r--r--sound/soc/samsung/littlemill.c12
-rw-r--r--sound/soc/samsung/lowland.c14
-rw-r--r--sound/soc/samsung/rx1950_uda1380.c9
-rw-r--r--sound/soc/samsung/smartq_wm8987.c11
-rw-r--r--sound/soc/samsung/speyside.c14
-rw-r--r--sound/soc/samsung/tobermory.c13
-rw-r--r--sound/soc/sh/rcar/core.c4
-rw-r--r--sound/soc/soc-core.c16
-rw-r--r--sound/soc/soc-jack.c42
-rw-r--r--sound/soc/soc-pcm.c1
-rw-r--r--sound/soc/tegra/tegra_alc5632.c9
-rw-r--r--sound/soc/tegra/tegra_max98090.c26
-rw-r--r--sound/soc/tegra/tegra_rt5640.c10
-rw-r--r--sound/soc/tegra/tegra_rt5677.c14
-rw-r--r--sound/soc/tegra/tegra_wm8903.c18
-rw-r--r--tools/perf/bench/mem-memcpy.c4
-rw-r--r--tools/perf/config/Makefile.arch4
-rw-r--r--tools/perf/config/feature-checks/Makefile2
-rw-r--r--tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c3
-rw-r--r--tools/perf/util/cloexec.c18
-rw-r--r--tools/perf/util/evlist.h2
-rw-r--r--tools/perf/util/symbol-elf.c5
-rw-r--r--tools/thermal/tmon/.gitignore1
-rw-r--r--tools/thermal/tmon/Makefile15
-rw-r--r--tools/thermal/tmon/tmon.82
-rw-r--r--tools/thermal/tmon/tmon.c14
-rw-r--r--tools/thermal/tmon/tui.c45
236 files changed, 2408 insertions, 2240 deletions
diff --git a/Documentation/cgroups/unified-hierarchy.txt b/Documentation/cgroups/unified-hierarchy.txt
index 71daa35ec2d9..eb102fb72213 100644
--- a/Documentation/cgroups/unified-hierarchy.txt
+++ b/Documentation/cgroups/unified-hierarchy.txt
@@ -404,8 +404,8 @@ supported and the interface files "release_agent" and
404 be understood as an underflow into the highest possible value, -2 or 404 be understood as an underflow into the highest possible value, -2 or
405 -10M etc. do not work, so it's not consistent. 405 -10M etc. do not work, so it's not consistent.
406 406
407 memory.low, memory.high, and memory.max will use the string 407 memory.low, memory.high, and memory.max will use the string "max" to
408 "infinity" to indicate and set the highest possible value. 408 indicate and set the highest possible value.
409 409
4105. Planned Changes 4105. Planned Changes
411 411
diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-max98090.txt b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-max98090.txt
index c949abc2992f..c3495beba358 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-max98090.txt
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-max98090.txt
@@ -18,6 +18,7 @@ Required properties:
18 * Headphones 18 * Headphones
19 * Speakers 19 * Speakers
20 * Mic Jack 20 * Mic Jack
21 * Int Mic
21 22
22- nvidia,i2s-controller : The phandle of the Tegra I2S controller that's 23- nvidia,i2s-controller : The phandle of the Tegra I2S controller that's
23 connected to the CODEC. 24 connected to the CODEC.
diff --git a/Documentation/filesystems/dlmfs.txt b/Documentation/filesystems/dlmfs.txt
index 1b528b2ad809..fcf4d509d118 100644
--- a/Documentation/filesystems/dlmfs.txt
+++ b/Documentation/filesystems/dlmfs.txt
@@ -5,8 +5,8 @@ system.
5 5
6dlmfs is built with OCFS2 as it requires most of its infrastructure. 6dlmfs is built with OCFS2 as it requires most of its infrastructure.
7 7
8Project web page: http://oss.oracle.com/projects/ocfs2 8Project web page: http://ocfs2.wiki.kernel.org
9Tools web page: http://oss.oracle.com/projects/ocfs2-tools 9Tools web page: https://github.com/markfasheh/ocfs2-tools
10OCFS2 mailing lists: http://oss.oracle.com/projects/ocfs2/mailman/ 10OCFS2 mailing lists: http://oss.oracle.com/projects/ocfs2/mailman/
11 11
12All code copyright 2005 Oracle except when otherwise noted. 12All code copyright 2005 Oracle except when otherwise noted.
diff --git a/Documentation/filesystems/ocfs2.txt b/Documentation/filesystems/ocfs2.txt
index 28f8c08201e2..4c49e5410595 100644
--- a/Documentation/filesystems/ocfs2.txt
+++ b/Documentation/filesystems/ocfs2.txt
@@ -8,8 +8,8 @@ also make it attractive for non-clustered use.
8You'll want to install the ocfs2-tools package in order to at least 8You'll want to install the ocfs2-tools package in order to at least
9get "mount.ocfs2" and "ocfs2_hb_ctl". 9get "mount.ocfs2" and "ocfs2_hb_ctl".
10 10
11Project web page: http://oss.oracle.com/projects/ocfs2 11Project web page: http://ocfs2.wiki.kernel.org
12Tools web page: http://oss.oracle.com/projects/ocfs2-tools 12Tools git tree: https://github.com/markfasheh/ocfs2-tools
13OCFS2 mailing lists: http://oss.oracle.com/projects/ocfs2/mailman/ 13OCFS2 mailing lists: http://oss.oracle.com/projects/ocfs2/mailman/
14 14
15All code copyright 2005 Oracle except when otherwise noted. 15All code copyright 2005 Oracle except when otherwise noted.
diff --git a/MAINTAINERS b/MAINTAINERS
index ddc5a8cf9a8a..eaf999638a65 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7213,8 +7213,7 @@ ORACLE CLUSTER FILESYSTEM 2 (OCFS2)
7213M: Mark Fasheh <mfasheh@suse.com> 7213M: Mark Fasheh <mfasheh@suse.com>
7214M: Joel Becker <jlbec@evilplan.org> 7214M: Joel Becker <jlbec@evilplan.org>
7215L: ocfs2-devel@oss.oracle.com (moderated for non-subscribers) 7215L: ocfs2-devel@oss.oracle.com (moderated for non-subscribers)
7216W: http://oss.oracle.com/projects/ocfs2/ 7216W: http://ocfs2.wiki.kernel.org
7217T: git git://git.kernel.org/pub/scm/linux/kernel/git/jlbec/ocfs2.git
7218S: Supported 7217S: Supported
7219F: Documentation/filesystems/ocfs2.txt 7218F: Documentation/filesystems/ocfs2.txt
7220F: Documentation/filesystems/dlmfs.txt 7219F: Documentation/filesystems/dlmfs.txt
diff --git a/Makefile b/Makefile
index 9fab639727c7..e6a9b1b94656 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 4 1VERSION = 4
2PATCHLEVEL = 0 2PATCHLEVEL = 0
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc1 4EXTRAVERSION = -rc2
5NAME = Hurr durr I'ma sheep 5NAME = Hurr durr I'ma sheep
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/arm/boot/dts/am335x-bone-common.dtsi b/arch/arm/boot/dts/am335x-bone-common.dtsi
index 6cc25ed912ee..2c6248d9a9ef 100644
--- a/arch/arm/boot/dts/am335x-bone-common.dtsi
+++ b/arch/arm/boot/dts/am335x-bone-common.dtsi
@@ -195,6 +195,7 @@
195 195
196&usb0 { 196&usb0 {
197 status = "okay"; 197 status = "okay";
198 dr_mode = "peripheral";
198}; 199};
199 200
200&usb1 { 201&usb1 {
diff --git a/arch/arm/boot/dts/am437x-idk-evm.dts b/arch/arm/boot/dts/am437x-idk-evm.dts
index f9a17e2ca8cb..0198f5a62b96 100644
--- a/arch/arm/boot/dts/am437x-idk-evm.dts
+++ b/arch/arm/boot/dts/am437x-idk-evm.dts
@@ -133,20 +133,6 @@
133 >; 133 >;
134 }; 134 };
135 135
136 i2c1_pins_default: i2c1_pins_default {
137 pinctrl-single,pins = <
138 0x15c (PIN_INPUT | SLEWCTRL_FAST | MUX_MODE2) /* spi0_cs0.i2c1_scl */
139 0x158 (PIN_INPUT | SLEWCTRL_FAST | MUX_MODE2) /* spi0_d1.i2c1_sda */
140 >;
141 };
142
143 i2c1_pins_sleep: i2c1_pins_sleep {
144 pinctrl-single,pins = <
145 0x15c (PIN_INPUT_PULLDOWN | MUX_MODE7) /* spi0_cs0.i2c1_scl */
146 0x158 (PIN_INPUT_PULLDOWN | MUX_MODE7) /* spi0_d1.i2c1_sda */
147 >;
148 };
149
150 mmc1_pins_default: pinmux_mmc1_pins_default { 136 mmc1_pins_default: pinmux_mmc1_pins_default {
151 pinctrl-single,pins = < 137 pinctrl-single,pins = <
152 0x100 (PIN_INPUT | MUX_MODE0) /* mmc0_clk.mmc0_clk */ 138 0x100 (PIN_INPUT | MUX_MODE0) /* mmc0_clk.mmc0_clk */
@@ -254,7 +240,7 @@
254 status = "okay"; 240 status = "okay";
255 pinctrl-names = "default", "sleep"; 241 pinctrl-names = "default", "sleep";
256 pinctrl-0 = <&i2c0_pins_default>; 242 pinctrl-0 = <&i2c0_pins_default>;
257 pinctrl-1 = <&i2c0_pins_default>; 243 pinctrl-1 = <&i2c0_pins_sleep>;
258 clock-frequency = <400000>; 244 clock-frequency = <400000>;
259 245
260 at24@50 { 246 at24@50 {
@@ -262,17 +248,10 @@
262 pagesize = <64>; 248 pagesize = <64>;
263 reg = <0x50>; 249 reg = <0x50>;
264 }; 250 };
265};
266
267&i2c1 {
268 status = "okay";
269 pinctrl-names = "default", "sleep";
270 pinctrl-0 = <&i2c1_pins_default>;
271 pinctrl-1 = <&i2c1_pins_default>;
272 clock-frequency = <400000>;
273 251
274 tps: tps62362@60 { 252 tps: tps62362@60 {
275 compatible = "ti,tps62362"; 253 compatible = "ti,tps62362";
254 reg = <0x60>;
276 regulator-name = "VDD_MPU"; 255 regulator-name = "VDD_MPU";
277 regulator-min-microvolt = <950000>; 256 regulator-min-microvolt = <950000>;
278 regulator-max-microvolt = <1330000>; 257 regulator-max-microvolt = <1330000>;
diff --git a/arch/arm/boot/dts/am57xx-beagle-x15.dts b/arch/arm/boot/dts/am57xx-beagle-x15.dts
index 03750af3b49a..6463f9ef2b54 100644
--- a/arch/arm/boot/dts/am57xx-beagle-x15.dts
+++ b/arch/arm/boot/dts/am57xx-beagle-x15.dts
@@ -549,14 +549,6 @@
549 pinctrl-0 = <&usb1_pins>; 549 pinctrl-0 = <&usb1_pins>;
550}; 550};
551 551
552&omap_dwc3_1 {
553 extcon = <&extcon_usb1>;
554};
555
556&omap_dwc3_2 {
557 extcon = <&extcon_usb2>;
558};
559
560&usb2 { 552&usb2 {
561 dr_mode = "peripheral"; 553 dr_mode = "peripheral";
562}; 554};
diff --git a/arch/arm/boot/dts/dm8168-evm.dts b/arch/arm/boot/dts/dm8168-evm.dts
index 857d0289ad4d..d3a29c1b8417 100644
--- a/arch/arm/boot/dts/dm8168-evm.dts
+++ b/arch/arm/boot/dts/dm8168-evm.dts
@@ -35,6 +35,18 @@
35 DM816X_IOPAD(0x0aac, PIN_INPUT | MUX_MODE0) /* SPI_D1 */ 35 DM816X_IOPAD(0x0aac, PIN_INPUT | MUX_MODE0) /* SPI_D1 */
36 >; 36 >;
37 }; 37 };
38
39 usb0_pins: pinmux_usb0_pins {
40 pinctrl-single,pins = <
41 DM816X_IOPAD(0x0d00, MUX_MODE0) /* USB0_DRVVBUS */
42 >;
43 };
44
45 usb1_pins: pinmux_usb0_pins {
46 pinctrl-single,pins = <
47 DM816X_IOPAD(0x0d04, MUX_MODE0) /* USB1_DRVVBUS */
48 >;
49 };
38}; 50};
39 51
40&i2c1 { 52&i2c1 {
@@ -127,3 +139,16 @@
127&mmc1 { 139&mmc1 {
128 vmmc-supply = <&vmmcsd_fixed>; 140 vmmc-supply = <&vmmcsd_fixed>;
129}; 141};
142
143/* At least dm8168-evm rev c won't support multipoint, later may */
144&usb0 {
145 pinctrl-names = "default";
146 pinctrl-0 = <&usb0_pins>;
147 mentor,multipoint = <0>;
148};
149
150&usb1 {
151 pinctrl-names = "default";
152 pinctrl-0 = <&usb1_pins>;
153 mentor,multipoint = <0>;
154};
diff --git a/arch/arm/boot/dts/dm816x.dtsi b/arch/arm/boot/dts/dm816x.dtsi
index d98d0f7de380..3c97b5f2addc 100644
--- a/arch/arm/boot/dts/dm816x.dtsi
+++ b/arch/arm/boot/dts/dm816x.dtsi
@@ -97,10 +97,31 @@
97 97
98 /* Device Configuration Registers */ 98 /* Device Configuration Registers */
99 scm_conf: syscon@600 { 99 scm_conf: syscon@600 {
100 compatible = "syscon"; 100 compatible = "syscon", "simple-bus";
101 reg = <0x600 0x110>; 101 reg = <0x600 0x110>;
102 #address-cells = <1>; 102 #address-cells = <1>;
103 #size-cells = <1>; 103 #size-cells = <1>;
104 ranges = <0 0x600 0x110>;
105
106 usb_phy0: usb-phy@20 {
107 compatible = "ti,dm8168-usb-phy";
108 reg = <0x20 0x8>;
109 reg-names = "phy";
110 clocks = <&main_fapll 6>;
111 clock-names = "refclk";
112 #phy-cells = <0>;
113 syscon = <&scm_conf>;
114 };
115
116 usb_phy1: usb-phy@28 {
117 compatible = "ti,dm8168-usb-phy";
118 reg = <0x28 0x8>;
119 reg-names = "phy";
120 clocks = <&main_fapll 6>;
121 clock-names = "refclk";
122 #phy-cells = <0>;
123 syscon = <&scm_conf>;
124 };
104 }; 125 };
105 126
106 scrm_clocks: clocks { 127 scrm_clocks: clocks {
@@ -357,7 +378,10 @@
357 reg-names = "mc", "control"; 378 reg-names = "mc", "control";
358 interrupts = <18>; 379 interrupts = <18>;
359 interrupt-names = "mc"; 380 interrupt-names = "mc";
360 dr_mode = "otg"; 381 dr_mode = "host";
382 interface-type = <0>;
383 phys = <&usb_phy0>;
384 phy-names = "usb2-phy";
361 mentor,multipoint = <1>; 385 mentor,multipoint = <1>;
362 mentor,num-eps = <16>; 386 mentor,num-eps = <16>;
363 mentor,ram-bits = <12>; 387 mentor,ram-bits = <12>;
@@ -366,13 +390,15 @@
366 390
367 usb1: usb@47401800 { 391 usb1: usb@47401800 {
368 compatible = "ti,musb-am33xx"; 392 compatible = "ti,musb-am33xx";
369 status = "disabled";
370 reg = <0x47401c00 0x400 393 reg = <0x47401c00 0x400
371 0x47401800 0x200>; 394 0x47401800 0x200>;
372 reg-names = "mc", "control"; 395 reg-names = "mc", "control";
373 interrupts = <19>; 396 interrupts = <19>;
374 interrupt-names = "mc"; 397 interrupt-names = "mc";
375 dr_mode = "otg"; 398 dr_mode = "host";
399 interface-type = <0>;
400 phys = <&usb_phy1>;
401 phy-names = "usb2-phy";
376 mentor,multipoint = <1>; 402 mentor,multipoint = <1>;
377 mentor,num-eps = <16>; 403 mentor,num-eps = <16>;
378 mentor,ram-bits = <12>; 404 mentor,ram-bits = <12>;
diff --git a/arch/arm/boot/dts/dra7-evm.dts b/arch/arm/boot/dts/dra7-evm.dts
index 746cddb1b8f5..3290a96ba586 100644
--- a/arch/arm/boot/dts/dra7-evm.dts
+++ b/arch/arm/boot/dts/dra7-evm.dts
@@ -543,14 +543,6 @@
543 }; 543 };
544}; 544};
545 545
546&omap_dwc3_1 {
547 extcon = <&extcon_usb1>;
548};
549
550&omap_dwc3_2 {
551 extcon = <&extcon_usb2>;
552};
553
554&usb1 { 546&usb1 {
555 dr_mode = "peripheral"; 547 dr_mode = "peripheral";
556 pinctrl-names = "default"; 548 pinctrl-names = "default";
diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
index 5827fedafd43..127608d79033 100644
--- a/arch/arm/boot/dts/dra7.dtsi
+++ b/arch/arm/boot/dts/dra7.dtsi
@@ -249,8 +249,8 @@
249 <GIC_SPI 9 IRQ_TYPE_LEVEL_HIGH>, 249 <GIC_SPI 9 IRQ_TYPE_LEVEL_HIGH>,
250 <GIC_SPI 10 IRQ_TYPE_LEVEL_HIGH>; 250 <GIC_SPI 10 IRQ_TYPE_LEVEL_HIGH>;
251 #dma-cells = <1>; 251 #dma-cells = <1>;
252 #dma-channels = <32>; 252 dma-channels = <32>;
253 #dma-requests = <127>; 253 dma-requests = <127>;
254 }; 254 };
255 255
256 gpio1: gpio@4ae10000 { 256 gpio1: gpio@4ae10000 {
@@ -1090,8 +1090,8 @@
1090 <0x4A096800 0x40>; /* pll_ctrl */ 1090 <0x4A096800 0x40>; /* pll_ctrl */
1091 reg-names = "phy_rx", "phy_tx", "pll_ctrl"; 1091 reg-names = "phy_rx", "phy_tx", "pll_ctrl";
1092 ctrl-module = <&omap_control_sata>; 1092 ctrl-module = <&omap_control_sata>;
1093 clocks = <&sys_clkin1>; 1093 clocks = <&sys_clkin1>, <&sata_ref_clk>;
1094 clock-names = "sysclk"; 1094 clock-names = "sysclk", "refclk";
1095 #phy-cells = <0>; 1095 #phy-cells = <0>;
1096 }; 1096 };
1097 1097
diff --git a/arch/arm/boot/dts/dra72-evm.dts b/arch/arm/boot/dts/dra72-evm.dts
index 4d8711713610..e0264d0bf7b9 100644
--- a/arch/arm/boot/dts/dra72-evm.dts
+++ b/arch/arm/boot/dts/dra72-evm.dts
@@ -380,14 +380,6 @@
380 phy-supply = <&ldo4_reg>; 380 phy-supply = <&ldo4_reg>;
381}; 381};
382 382
383&omap_dwc3_1 {
384 extcon = <&extcon_usb1>;
385};
386
387&omap_dwc3_2 {
388 extcon = <&extcon_usb2>;
389};
390
391&usb1 { 383&usb1 {
392 dr_mode = "peripheral"; 384 dr_mode = "peripheral";
393 pinctrl-names = "default"; 385 pinctrl-names = "default";
diff --git a/arch/arm/boot/dts/omap2.dtsi b/arch/arm/boot/dts/omap2.dtsi
index 59d1c297bb30..578fa2a54dce 100644
--- a/arch/arm/boot/dts/omap2.dtsi
+++ b/arch/arm/boot/dts/omap2.dtsi
@@ -87,8 +87,8 @@
87 <14>, 87 <14>,
88 <15>; 88 <15>;
89 #dma-cells = <1>; 89 #dma-cells = <1>;
90 #dma-channels = <32>; 90 dma-channels = <32>;
91 #dma-requests = <64>; 91 dma-requests = <64>;
92 }; 92 };
93 93
94 i2c1: i2c@48070000 { 94 i2c1: i2c@48070000 {
diff --git a/arch/arm/boot/dts/omap3-n900.dts b/arch/arm/boot/dts/omap3-n900.dts
index 60403273f83e..db80f9d376fa 100644
--- a/arch/arm/boot/dts/omap3-n900.dts
+++ b/arch/arm/boot/dts/omap3-n900.dts
@@ -16,6 +16,13 @@
16 model = "Nokia N900"; 16 model = "Nokia N900";
17 compatible = "nokia,omap3-n900", "ti,omap3430", "ti,omap3"; 17 compatible = "nokia,omap3-n900", "ti,omap3430", "ti,omap3";
18 18
19 aliases {
20 i2c0;
21 i2c1 = &i2c1;
22 i2c2 = &i2c2;
23 i2c3 = &i2c3;
24 };
25
19 cpus { 26 cpus {
20 cpu@0 { 27 cpu@0 {
21 cpu0-supply = <&vcc>; 28 cpu0-supply = <&vcc>;
@@ -704,7 +711,7 @@
704 compatible = "smsc,lan91c94"; 711 compatible = "smsc,lan91c94";
705 interrupt-parent = <&gpio2>; 712 interrupt-parent = <&gpio2>;
706 interrupts = <22 IRQ_TYPE_LEVEL_HIGH>; /* gpio54 */ 713 interrupts = <22 IRQ_TYPE_LEVEL_HIGH>; /* gpio54 */
707 reg = <1 0x300 0xf>; /* 16 byte IO range at offset 0x300 */ 714 reg = <1 0 0xf>; /* 16 byte IO range */
708 bank-width = <2>; 715 bank-width = <2>;
709 pinctrl-names = "default"; 716 pinctrl-names = "default";
710 pinctrl-0 = <&ethernet_pins>; 717 pinctrl-0 = <&ethernet_pins>;
diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
index 01b71111bd55..f4f78c40b564 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -155,8 +155,8 @@
155 <14>, 155 <14>,
156 <15>; 156 <15>;
157 #dma-cells = <1>; 157 #dma-cells = <1>;
158 #dma-channels = <32>; 158 dma-channels = <32>;
159 #dma-requests = <96>; 159 dma-requests = <96>;
160 }; 160 };
161 161
162 omap3_pmx_core: pinmux@48002030 { 162 omap3_pmx_core: pinmux@48002030 {
diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index 074147cebae4..87401d9f4d8b 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -223,8 +223,8 @@
223 <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>, 223 <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>,
224 <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>; 224 <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>;
225 #dma-cells = <1>; 225 #dma-cells = <1>;
226 #dma-channels = <32>; 226 dma-channels = <32>;
227 #dma-requests = <127>; 227 dma-requests = <127>;
228 }; 228 };
229 229
230 gpio1: gpio@4a310000 { 230 gpio1: gpio@4a310000 {
diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
index b321fdf42c9f..ddff674bd05e 100644
--- a/arch/arm/boot/dts/omap5.dtsi
+++ b/arch/arm/boot/dts/omap5.dtsi
@@ -238,8 +238,8 @@
238 <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>, 238 <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>,
239 <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>; 239 <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>;
240 #dma-cells = <1>; 240 #dma-cells = <1>;
241 #dma-channels = <32>; 241 dma-channels = <32>;
242 #dma-requests = <127>; 242 dma-requests = <127>;
243 }; 243 };
244 244
245 gpio1: gpio@4ae10000 { 245 gpio1: gpio@4ae10000 {
@@ -929,8 +929,8 @@
929 <0x4A096800 0x40>; /* pll_ctrl */ 929 <0x4A096800 0x40>; /* pll_ctrl */
930 reg-names = "phy_rx", "phy_tx", "pll_ctrl"; 930 reg-names = "phy_rx", "phy_tx", "pll_ctrl";
931 ctrl-module = <&omap_control_sata>; 931 ctrl-module = <&omap_control_sata>;
932 clocks = <&sys_clkin>; 932 clocks = <&sys_clkin>, <&sata_ref_clk>;
933 clock-names = "sysclk"; 933 clock-names = "sysclk", "refclk";
934 #phy-cells = <0>; 934 #phy-cells = <0>;
935 }; 935 };
936 }; 936 };
diff --git a/arch/arm/configs/multi_v7_defconfig b/arch/arm/configs/multi_v7_defconfig
index e8a4c955241b..b7e6b6fba5e0 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -62,6 +62,17 @@ CONFIG_MACH_SPEAR1340=y
62CONFIG_ARCH_STI=y 62CONFIG_ARCH_STI=y
63CONFIG_ARCH_EXYNOS=y 63CONFIG_ARCH_EXYNOS=y
64CONFIG_EXYNOS5420_MCPM=y 64CONFIG_EXYNOS5420_MCPM=y
65CONFIG_ARCH_SHMOBILE_MULTI=y
66CONFIG_ARCH_EMEV2=y
67CONFIG_ARCH_R7S72100=y
68CONFIG_ARCH_R8A73A4=y
69CONFIG_ARCH_R8A7740=y
70CONFIG_ARCH_R8A7779=y
71CONFIG_ARCH_R8A7790=y
72CONFIG_ARCH_R8A7791=y
73CONFIG_ARCH_R8A7794=y
74CONFIG_ARCH_SH73A0=y
75CONFIG_MACH_MARZEN=y
65CONFIG_ARCH_SUNXI=y 76CONFIG_ARCH_SUNXI=y
66CONFIG_ARCH_SIRF=y 77CONFIG_ARCH_SIRF=y
67CONFIG_ARCH_TEGRA=y 78CONFIG_ARCH_TEGRA=y
@@ -84,6 +95,8 @@ CONFIG_PCI_KEYSTONE=y
84CONFIG_PCI_MSI=y 95CONFIG_PCI_MSI=y
85CONFIG_PCI_MVEBU=y 96CONFIG_PCI_MVEBU=y
86CONFIG_PCI_TEGRA=y 97CONFIG_PCI_TEGRA=y
98CONFIG_PCI_RCAR_GEN2=y
99CONFIG_PCI_RCAR_GEN2_PCIE=y
87CONFIG_PCIEPORTBUS=y 100CONFIG_PCIEPORTBUS=y
88CONFIG_SMP=y 101CONFIG_SMP=y
89CONFIG_NR_CPUS=8 102CONFIG_NR_CPUS=8
@@ -130,6 +143,7 @@ CONFIG_DEVTMPFS_MOUNT=y
130CONFIG_DMA_CMA=y 143CONFIG_DMA_CMA=y
131CONFIG_CMA_SIZE_MBYTES=64 144CONFIG_CMA_SIZE_MBYTES=64
132CONFIG_OMAP_OCP2SCP=y 145CONFIG_OMAP_OCP2SCP=y
146CONFIG_SIMPLE_PM_BUS=y
133CONFIG_MTD=y 147CONFIG_MTD=y
134CONFIG_MTD_CMDLINE_PARTS=y 148CONFIG_MTD_CMDLINE_PARTS=y
135CONFIG_MTD_BLOCK=y 149CONFIG_MTD_BLOCK=y
@@ -157,6 +171,7 @@ CONFIG_AHCI_SUNXI=y
157CONFIG_AHCI_TEGRA=y 171CONFIG_AHCI_TEGRA=y
158CONFIG_SATA_HIGHBANK=y 172CONFIG_SATA_HIGHBANK=y
159CONFIG_SATA_MV=y 173CONFIG_SATA_MV=y
174CONFIG_SATA_RCAR=y
160CONFIG_NETDEVICES=y 175CONFIG_NETDEVICES=y
161CONFIG_HIX5HD2_GMAC=y 176CONFIG_HIX5HD2_GMAC=y
162CONFIG_SUN4I_EMAC=y 177CONFIG_SUN4I_EMAC=y
@@ -167,14 +182,17 @@ CONFIG_MV643XX_ETH=y
167CONFIG_MVNETA=y 182CONFIG_MVNETA=y
168CONFIG_KS8851=y 183CONFIG_KS8851=y
169CONFIG_R8169=y 184CONFIG_R8169=y
185CONFIG_SH_ETH=y
170CONFIG_SMSC911X=y 186CONFIG_SMSC911X=y
171CONFIG_STMMAC_ETH=y 187CONFIG_STMMAC_ETH=y
172CONFIG_TI_CPSW=y 188CONFIG_TI_CPSW=y
173CONFIG_XILINX_EMACLITE=y 189CONFIG_XILINX_EMACLITE=y
174CONFIG_AT803X_PHY=y 190CONFIG_AT803X_PHY=y
175CONFIG_MARVELL_PHY=y 191CONFIG_MARVELL_PHY=y
192CONFIG_SMSC_PHY=y
176CONFIG_BROADCOM_PHY=y 193CONFIG_BROADCOM_PHY=y
177CONFIG_ICPLUS_PHY=y 194CONFIG_ICPLUS_PHY=y
195CONFIG_MICREL_PHY=y
178CONFIG_USB_PEGASUS=y 196CONFIG_USB_PEGASUS=y
179CONFIG_USB_USBNET=y 197CONFIG_USB_USBNET=y
180CONFIG_USB_NET_SMSC75XX=y 198CONFIG_USB_NET_SMSC75XX=y
@@ -192,15 +210,18 @@ CONFIG_KEYBOARD_CROS_EC=y
192CONFIG_MOUSE_PS2_ELANTECH=y 210CONFIG_MOUSE_PS2_ELANTECH=y
193CONFIG_INPUT_TOUCHSCREEN=y 211CONFIG_INPUT_TOUCHSCREEN=y
194CONFIG_TOUCHSCREEN_ATMEL_MXT=y 212CONFIG_TOUCHSCREEN_ATMEL_MXT=y
213CONFIG_TOUCHSCREEN_ST1232=m
195CONFIG_TOUCHSCREEN_STMPE=y 214CONFIG_TOUCHSCREEN_STMPE=y
196CONFIG_TOUCHSCREEN_SUN4I=y 215CONFIG_TOUCHSCREEN_SUN4I=y
197CONFIG_INPUT_MISC=y 216CONFIG_INPUT_MISC=y
198CONFIG_INPUT_MPU3050=y 217CONFIG_INPUT_MPU3050=y
199CONFIG_INPUT_AXP20X_PEK=y 218CONFIG_INPUT_AXP20X_PEK=y
219CONFIG_INPUT_ADXL34X=m
200CONFIG_SERIO_AMBAKMI=y 220CONFIG_SERIO_AMBAKMI=y
201CONFIG_SERIAL_8250=y 221CONFIG_SERIAL_8250=y
202CONFIG_SERIAL_8250_CONSOLE=y 222CONFIG_SERIAL_8250_CONSOLE=y
203CONFIG_SERIAL_8250_DW=y 223CONFIG_SERIAL_8250_DW=y
224CONFIG_SERIAL_8250_EM=y
204CONFIG_SERIAL_8250_MT6577=y 225CONFIG_SERIAL_8250_MT6577=y
205CONFIG_SERIAL_AMBA_PL011=y 226CONFIG_SERIAL_AMBA_PL011=y
206CONFIG_SERIAL_AMBA_PL011_CONSOLE=y 227CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
@@ -213,6 +234,9 @@ CONFIG_SERIAL_SIRFSOC_CONSOLE=y
213CONFIG_SERIAL_TEGRA=y 234CONFIG_SERIAL_TEGRA=y
214CONFIG_SERIAL_IMX=y 235CONFIG_SERIAL_IMX=y
215CONFIG_SERIAL_IMX_CONSOLE=y 236CONFIG_SERIAL_IMX_CONSOLE=y
237CONFIG_SERIAL_SH_SCI=y
238CONFIG_SERIAL_SH_SCI_NR_UARTS=20
239CONFIG_SERIAL_SH_SCI_CONSOLE=y
216CONFIG_SERIAL_MSM=y 240CONFIG_SERIAL_MSM=y
217CONFIG_SERIAL_MSM_CONSOLE=y 241CONFIG_SERIAL_MSM_CONSOLE=y
218CONFIG_SERIAL_VT8500=y 242CONFIG_SERIAL_VT8500=y
@@ -233,19 +257,26 @@ CONFIG_I2C_MUX_PCA954x=y
233CONFIG_I2C_MUX_PINCTRL=y 257CONFIG_I2C_MUX_PINCTRL=y
234CONFIG_I2C_CADENCE=y 258CONFIG_I2C_CADENCE=y
235CONFIG_I2C_DESIGNWARE_PLATFORM=y 259CONFIG_I2C_DESIGNWARE_PLATFORM=y
260CONFIG_I2C_GPIO=m
236CONFIG_I2C_EXYNOS5=y 261CONFIG_I2C_EXYNOS5=y
237CONFIG_I2C_MV64XXX=y 262CONFIG_I2C_MV64XXX=y
263CONFIG_I2C_RIIC=y
238CONFIG_I2C_S3C2410=y 264CONFIG_I2C_S3C2410=y
265CONFIG_I2C_SH_MOBILE=y
239CONFIG_I2C_SIRF=y 266CONFIG_I2C_SIRF=y
240CONFIG_I2C_TEGRA=y
241CONFIG_I2C_ST=y 267CONFIG_I2C_ST=y
242CONFIG_SPI=y 268CONFIG_I2C_TEGRA=y
243CONFIG_I2C_XILINX=y 269CONFIG_I2C_XILINX=y
244CONFIG_SPI_DAVINCI=y 270CONFIG_I2C_RCAR=y
271CONFIG_SPI=y
245CONFIG_SPI_CADENCE=y 272CONFIG_SPI_CADENCE=y
273CONFIG_SPI_DAVINCI=y
246CONFIG_SPI_OMAP24XX=y 274CONFIG_SPI_OMAP24XX=y
247CONFIG_SPI_ORION=y 275CONFIG_SPI_ORION=y
248CONFIG_SPI_PL022=y 276CONFIG_SPI_PL022=y
277CONFIG_SPI_RSPI=y
278CONFIG_SPI_SH_MSIOF=m
279CONFIG_SPI_SH_HSPI=y
249CONFIG_SPI_SIRF=y 280CONFIG_SPI_SIRF=y
250CONFIG_SPI_SUN4I=y 281CONFIG_SPI_SUN4I=y
251CONFIG_SPI_SUN6I=y 282CONFIG_SPI_SUN6I=y
@@ -259,12 +290,15 @@ CONFIG_PINCTRL_PALMAS=y
259CONFIG_PINCTRL_APQ8084=y 290CONFIG_PINCTRL_APQ8084=y
260CONFIG_GPIO_SYSFS=y 291CONFIG_GPIO_SYSFS=y
261CONFIG_GPIO_GENERIC_PLATFORM=y 292CONFIG_GPIO_GENERIC_PLATFORM=y
262CONFIG_GPIO_DWAPB=y
263CONFIG_GPIO_DAVINCI=y 293CONFIG_GPIO_DAVINCI=y
294CONFIG_GPIO_DWAPB=y
295CONFIG_GPIO_EM=y
296CONFIG_GPIO_RCAR=y
264CONFIG_GPIO_XILINX=y 297CONFIG_GPIO_XILINX=y
265CONFIG_GPIO_ZYNQ=y 298CONFIG_GPIO_ZYNQ=y
266CONFIG_GPIO_PCA953X=y 299CONFIG_GPIO_PCA953X=y
267CONFIG_GPIO_PCA953X_IRQ=y 300CONFIG_GPIO_PCA953X_IRQ=y
301CONFIG_GPIO_PCF857X=y
268CONFIG_GPIO_TWL4030=y 302CONFIG_GPIO_TWL4030=y
269CONFIG_GPIO_PALMAS=y 303CONFIG_GPIO_PALMAS=y
270CONFIG_GPIO_SYSCON=y 304CONFIG_GPIO_SYSCON=y
@@ -276,10 +310,12 @@ CONFIG_POWER_RESET_AS3722=y
276CONFIG_POWER_RESET_GPIO=y 310CONFIG_POWER_RESET_GPIO=y
277CONFIG_POWER_RESET_KEYSTONE=y 311CONFIG_POWER_RESET_KEYSTONE=y
278CONFIG_POWER_RESET_SUN6I=y 312CONFIG_POWER_RESET_SUN6I=y
313CONFIG_POWER_RESET_RMOBILE=y
279CONFIG_SENSORS_LM90=y 314CONFIG_SENSORS_LM90=y
280CONFIG_SENSORS_LM95245=y 315CONFIG_SENSORS_LM95245=y
281CONFIG_THERMAL=y 316CONFIG_THERMAL=y
282CONFIG_CPU_THERMAL=y 317CONFIG_CPU_THERMAL=y
318CONFIG_RCAR_THERMAL=y
283CONFIG_ARMADA_THERMAL=y 319CONFIG_ARMADA_THERMAL=y
284CONFIG_DAVINCI_WATCHDOG 320CONFIG_DAVINCI_WATCHDOG
285CONFIG_ST_THERMAL_SYSCFG=y 321CONFIG_ST_THERMAL_SYSCFG=y
@@ -290,6 +326,7 @@ CONFIG_ARM_SP805_WATCHDOG=y
290CONFIG_ORION_WATCHDOG=y 326CONFIG_ORION_WATCHDOG=y
291CONFIG_SUNXI_WATCHDOG=y 327CONFIG_SUNXI_WATCHDOG=y
292CONFIG_MESON_WATCHDOG=y 328CONFIG_MESON_WATCHDOG=y
329CONFIG_MFD_AS3711=y
293CONFIG_MFD_AS3722=y 330CONFIG_MFD_AS3722=y
294CONFIG_MFD_BCM590XX=y 331CONFIG_MFD_BCM590XX=y
295CONFIG_MFD_AXP20X=y 332CONFIG_MFD_AXP20X=y
@@ -304,13 +341,16 @@ CONFIG_MFD_TPS65090=y
304CONFIG_MFD_TPS6586X=y 341CONFIG_MFD_TPS6586X=y
305CONFIG_MFD_TPS65910=y 342CONFIG_MFD_TPS65910=y
306CONFIG_REGULATOR_AB8500=y 343CONFIG_REGULATOR_AB8500=y
344CONFIG_REGULATOR_AS3711=y
307CONFIG_REGULATOR_AS3722=y 345CONFIG_REGULATOR_AS3722=y
308CONFIG_REGULATOR_AXP20X=y 346CONFIG_REGULATOR_AXP20X=y
309CONFIG_REGULATOR_BCM590XX=y 347CONFIG_REGULATOR_BCM590XX=y
348CONFIG_REGULATOR_DA9210=y
310CONFIG_REGULATOR_GPIO=y 349CONFIG_REGULATOR_GPIO=y
311CONFIG_MFD_SYSCON=y 350CONFIG_MFD_SYSCON=y
312CONFIG_POWER_RESET_SYSCON=y 351CONFIG_POWER_RESET_SYSCON=y
313CONFIG_REGULATOR_MAX8907=y 352CONFIG_REGULATOR_MAX8907=y
353CONFIG_REGULATOR_MAX8973=y
314CONFIG_REGULATOR_MAX77686=y 354CONFIG_REGULATOR_MAX77686=y
315CONFIG_REGULATOR_PALMAS=y 355CONFIG_REGULATOR_PALMAS=y
316CONFIG_REGULATOR_S2MPS11=y 356CONFIG_REGULATOR_S2MPS11=y
@@ -324,18 +364,32 @@ CONFIG_REGULATOR_TWL4030=y
324CONFIG_REGULATOR_VEXPRESS=y 364CONFIG_REGULATOR_VEXPRESS=y
325CONFIG_MEDIA_SUPPORT=y 365CONFIG_MEDIA_SUPPORT=y
326CONFIG_MEDIA_CAMERA_SUPPORT=y 366CONFIG_MEDIA_CAMERA_SUPPORT=y
367CONFIG_MEDIA_CONTROLLER=y
368CONFIG_VIDEO_V4L2_SUBDEV_API=y
327CONFIG_MEDIA_USB_SUPPORT=y 369CONFIG_MEDIA_USB_SUPPORT=y
328CONFIG_USB_VIDEO_CLASS=y 370CONFIG_USB_VIDEO_CLASS=y
329CONFIG_USB_GSPCA=y 371CONFIG_USB_GSPCA=y
372CONFIG_V4L_PLATFORM_DRIVERS=y
373CONFIG_SOC_CAMERA=m
374CONFIG_SOC_CAMERA_PLATFORM=m
375CONFIG_VIDEO_RCAR_VIN=m
376CONFIG_V4L_MEM2MEM_DRIVERS=y
377CONFIG_VIDEO_RENESAS_VSP1=m
378# CONFIG_MEDIA_SUBDRV_AUTOSELECT is not set
379CONFIG_VIDEO_ADV7180=m
330CONFIG_DRM=y 380CONFIG_DRM=y
381CONFIG_DRM_RCAR_DU=m
331CONFIG_DRM_TEGRA=y 382CONFIG_DRM_TEGRA=y
332CONFIG_DRM_PANEL_SIMPLE=y 383CONFIG_DRM_PANEL_SIMPLE=y
333CONFIG_FB_ARMCLCD=y 384CONFIG_FB_ARMCLCD=y
334CONFIG_FB_WM8505=y 385CONFIG_FB_WM8505=y
386CONFIG_FB_SH_MOBILE_LCDC=y
335CONFIG_FB_SIMPLE=y 387CONFIG_FB_SIMPLE=y
388CONFIG_FB_SH_MOBILE_MERAM=y
336CONFIG_BACKLIGHT_LCD_SUPPORT=y 389CONFIG_BACKLIGHT_LCD_SUPPORT=y
337CONFIG_BACKLIGHT_CLASS_DEVICE=y 390CONFIG_BACKLIGHT_CLASS_DEVICE=y
338CONFIG_BACKLIGHT_PWM=y 391CONFIG_BACKLIGHT_PWM=y
392CONFIG_BACKLIGHT_AS3711=y
339CONFIG_FRAMEBUFFER_CONSOLE=y 393CONFIG_FRAMEBUFFER_CONSOLE=y
340CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y 394CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
341CONFIG_SOUND=y 395CONFIG_SOUND=y
@@ -343,6 +397,8 @@ CONFIG_SND=y
343CONFIG_SND_DYNAMIC_MINORS=y 397CONFIG_SND_DYNAMIC_MINORS=y
344CONFIG_SND_USB_AUDIO=y 398CONFIG_SND_USB_AUDIO=y
345CONFIG_SND_SOC=y 399CONFIG_SND_SOC=y
400CONFIG_SND_SOC_SH4_FSI=m
401CONFIG_SND_SOC_RCAR=m
346CONFIG_SND_SOC_TEGRA=y 402CONFIG_SND_SOC_TEGRA=y
347CONFIG_SND_SOC_TEGRA_RT5640=y 403CONFIG_SND_SOC_TEGRA_RT5640=y
348CONFIG_SND_SOC_TEGRA_WM8753=y 404CONFIG_SND_SOC_TEGRA_WM8753=y
@@ -350,6 +406,8 @@ CONFIG_SND_SOC_TEGRA_WM8903=y
350CONFIG_SND_SOC_TEGRA_TRIMSLICE=y 406CONFIG_SND_SOC_TEGRA_TRIMSLICE=y
351CONFIG_SND_SOC_TEGRA_ALC5632=y 407CONFIG_SND_SOC_TEGRA_ALC5632=y
352CONFIG_SND_SOC_TEGRA_MAX98090=y 408CONFIG_SND_SOC_TEGRA_MAX98090=y
409CONFIG_SND_SOC_AK4642=m
410CONFIG_SND_SOC_WM8978=m
353CONFIG_USB=y 411CONFIG_USB=y
354CONFIG_USB_XHCI_HCD=y 412CONFIG_USB_XHCI_HCD=y
355CONFIG_USB_XHCI_MVEBU=y 413CONFIG_USB_XHCI_MVEBU=y
@@ -362,6 +420,8 @@ CONFIG_USB_ISP1760_HCD=y
362CONFIG_USB_OHCI_HCD=y 420CONFIG_USB_OHCI_HCD=y
363CONFIG_USB_OHCI_HCD_STI=y 421CONFIG_USB_OHCI_HCD_STI=y
364CONFIG_USB_OHCI_HCD_PLATFORM=y 422CONFIG_USB_OHCI_HCD_PLATFORM=y
423CONFIG_USB_R8A66597_HCD=m
424CONFIG_USB_RENESAS_USBHS=m
365CONFIG_USB_STORAGE=y 425CONFIG_USB_STORAGE=y
366CONFIG_USB_DWC3=y 426CONFIG_USB_DWC3=y
367CONFIG_USB_CHIPIDEA=y 427CONFIG_USB_CHIPIDEA=y
@@ -374,6 +434,10 @@ CONFIG_SAMSUNG_USB3PHY=y
374CONFIG_USB_GPIO_VBUS=y 434CONFIG_USB_GPIO_VBUS=y
375CONFIG_USB_ISP1301=y 435CONFIG_USB_ISP1301=y
376CONFIG_USB_MXS_PHY=y 436CONFIG_USB_MXS_PHY=y
437CONFIG_USB_RCAR_PHY=m
438CONFIG_USB_RCAR_GEN2_PHY=m
439CONFIG_USB_GADGET=y
440CONFIG_USB_RENESAS_USBHS_UDC=m
377CONFIG_MMC=y 441CONFIG_MMC=y
378CONFIG_MMC_BLOCK_MINORS=16 442CONFIG_MMC_BLOCK_MINORS=16
379CONFIG_MMC_ARMMMCI=y 443CONFIG_MMC_ARMMMCI=y
@@ -392,12 +456,14 @@ CONFIG_MMC_SDHCI_ST=y
392CONFIG_MMC_OMAP=y 456CONFIG_MMC_OMAP=y
393CONFIG_MMC_OMAP_HS=y 457CONFIG_MMC_OMAP_HS=y
394CONFIG_MMC_MVSDIO=y 458CONFIG_MMC_MVSDIO=y
395CONFIG_MMC_SUNXI=y 459CONFIG_MMC_SDHI=y
396CONFIG_MMC_DW=y 460CONFIG_MMC_DW=y
397CONFIG_MMC_DW_IDMAC=y 461CONFIG_MMC_DW_IDMAC=y
398CONFIG_MMC_DW_PLTFM=y 462CONFIG_MMC_DW_PLTFM=y
399CONFIG_MMC_DW_EXYNOS=y 463CONFIG_MMC_DW_EXYNOS=y
400CONFIG_MMC_DW_ROCKCHIP=y 464CONFIG_MMC_DW_ROCKCHIP=y
465CONFIG_MMC_SH_MMCIF=y
466CONFIG_MMC_SUNXI=y
401CONFIG_NEW_LEDS=y 467CONFIG_NEW_LEDS=y
402CONFIG_LEDS_CLASS=y 468CONFIG_LEDS_CLASS=y
403CONFIG_LEDS_GPIO=y 469CONFIG_LEDS_GPIO=y
@@ -421,10 +487,12 @@ CONFIG_RTC_DRV_AS3722=y
421CONFIG_RTC_DRV_DS1307=y 487CONFIG_RTC_DRV_DS1307=y
422CONFIG_RTC_DRV_MAX8907=y 488CONFIG_RTC_DRV_MAX8907=y
423CONFIG_RTC_DRV_MAX77686=y 489CONFIG_RTC_DRV_MAX77686=y
490CONFIG_RTC_DRV_RS5C372=m
424CONFIG_RTC_DRV_PALMAS=y 491CONFIG_RTC_DRV_PALMAS=y
425CONFIG_RTC_DRV_TWL4030=y 492CONFIG_RTC_DRV_TWL4030=y
426CONFIG_RTC_DRV_TPS6586X=y 493CONFIG_RTC_DRV_TPS6586X=y
427CONFIG_RTC_DRV_TPS65910=y 494CONFIG_RTC_DRV_TPS65910=y
495CONFIG_RTC_DRV_S35390A=m
428CONFIG_RTC_DRV_EM3027=y 496CONFIG_RTC_DRV_EM3027=y
429CONFIG_RTC_DRV_PL031=y 497CONFIG_RTC_DRV_PL031=y
430CONFIG_RTC_DRV_VT8500=y 498CONFIG_RTC_DRV_VT8500=y
@@ -436,6 +504,9 @@ CONFIG_DMADEVICES=y
436CONFIG_DW_DMAC=y 504CONFIG_DW_DMAC=y
437CONFIG_MV_XOR=y 505CONFIG_MV_XOR=y
438CONFIG_TEGRA20_APB_DMA=y 506CONFIG_TEGRA20_APB_DMA=y
507CONFIG_SH_DMAE=y
508CONFIG_RCAR_AUDMAC_PP=m
509CONFIG_RCAR_DMAC=y
439CONFIG_STE_DMA40=y 510CONFIG_STE_DMA40=y
440CONFIG_SIRF_DMA=y 511CONFIG_SIRF_DMA=y
441CONFIG_TI_EDMA=y 512CONFIG_TI_EDMA=y
@@ -468,6 +539,7 @@ CONFIG_IIO=y
468CONFIG_XILINX_XADC=y 539CONFIG_XILINX_XADC=y
469CONFIG_AK8975=y 540CONFIG_AK8975=y
470CONFIG_PWM=y 541CONFIG_PWM=y
542CONFIG_PWM_RENESAS_TPU=y
471CONFIG_PWM_TEGRA=y 543CONFIG_PWM_TEGRA=y
472CONFIG_PWM_VT8500=y 544CONFIG_PWM_VT8500=y
473CONFIG_PHY_HIX5HD2_SATA=y 545CONFIG_PHY_HIX5HD2_SATA=y
diff --git a/arch/arm/configs/omap2plus_defconfig b/arch/arm/configs/omap2plus_defconfig
index b7386524c356..a097cffa1231 100644
--- a/arch/arm/configs/omap2plus_defconfig
+++ b/arch/arm/configs/omap2plus_defconfig
@@ -114,6 +114,7 @@ CONFIG_MTD_PHYSMAP_OF=y
114CONFIG_MTD_NAND=y 114CONFIG_MTD_NAND=y
115CONFIG_MTD_NAND_ECC_BCH=y 115CONFIG_MTD_NAND_ECC_BCH=y
116CONFIG_MTD_NAND_OMAP2=y 116CONFIG_MTD_NAND_OMAP2=y
117CONFIG_MTD_NAND_OMAP_BCH=y
117CONFIG_MTD_ONENAND=y 118CONFIG_MTD_ONENAND=y
118CONFIG_MTD_ONENAND_VERIFY_WRITE=y 119CONFIG_MTD_ONENAND_VERIFY_WRITE=y
119CONFIG_MTD_ONENAND_OMAP2=y 120CONFIG_MTD_ONENAND_OMAP2=y
@@ -248,6 +249,7 @@ CONFIG_TWL6040_CORE=y
248CONFIG_REGULATOR_PALMAS=y 249CONFIG_REGULATOR_PALMAS=y
249CONFIG_REGULATOR_PBIAS=y 250CONFIG_REGULATOR_PBIAS=y
250CONFIG_REGULATOR_TI_ABB=y 251CONFIG_REGULATOR_TI_ABB=y
252CONFIG_REGULATOR_TPS62360=m
251CONFIG_REGULATOR_TPS65023=y 253CONFIG_REGULATOR_TPS65023=y
252CONFIG_REGULATOR_TPS6507X=y 254CONFIG_REGULATOR_TPS6507X=y
253CONFIG_REGULATOR_TPS65217=y 255CONFIG_REGULATOR_TPS65217=y
@@ -374,7 +376,7 @@ CONFIG_PWM_TIEHRPWM=m
374CONFIG_PWM_TWL=m 376CONFIG_PWM_TWL=m
375CONFIG_PWM_TWL_LED=m 377CONFIG_PWM_TWL_LED=m
376CONFIG_OMAP_USB2=m 378CONFIG_OMAP_USB2=m
377CONFIG_TI_PIPE3=m 379CONFIG_TI_PIPE3=y
378CONFIG_EXT2_FS=y 380CONFIG_EXT2_FS=y
379CONFIG_EXT3_FS=y 381CONFIG_EXT3_FS=y
380# CONFIG_EXT3_FS_XATTR is not set 382# CONFIG_EXT3_FS_XATTR is not set
diff --git a/arch/arm/mach-asm9260/Kconfig b/arch/arm/mach-asm9260/Kconfig
index 8423be76080e..52241207a82a 100644
--- a/arch/arm/mach-asm9260/Kconfig
+++ b/arch/arm/mach-asm9260/Kconfig
@@ -2,5 +2,7 @@ config MACH_ASM9260
2 bool "Alphascale ASM9260" 2 bool "Alphascale ASM9260"
3 depends on ARCH_MULTI_V5 3 depends on ARCH_MULTI_V5
4 select CPU_ARM926T 4 select CPU_ARM926T
5 select ASM9260_TIMER
6 select GENERIC_CLOCKEVENTS
5 help 7 help
6 Support for Alphascale ASM9260 based platform. 8 Support for Alphascale ASM9260 based platform.
diff --git a/arch/arm64/boot/dts/arm/foundation-v8.dts b/arch/arm64/boot/dts/arm/foundation-v8.dts
index 27f32962e55c..4eac8dcea423 100644
--- a/arch/arm64/boot/dts/arm/foundation-v8.dts
+++ b/arch/arm64/boot/dts/arm/foundation-v8.dts
@@ -34,6 +34,7 @@
34 reg = <0x0 0x0>; 34 reg = <0x0 0x0>;
35 enable-method = "spin-table"; 35 enable-method = "spin-table";
36 cpu-release-addr = <0x0 0x8000fff8>; 36 cpu-release-addr = <0x0 0x8000fff8>;
37 next-level-cache = <&L2_0>;
37 }; 38 };
38 cpu@1 { 39 cpu@1 {
39 device_type = "cpu"; 40 device_type = "cpu";
@@ -41,6 +42,7 @@
41 reg = <0x0 0x1>; 42 reg = <0x0 0x1>;
42 enable-method = "spin-table"; 43 enable-method = "spin-table";
43 cpu-release-addr = <0x0 0x8000fff8>; 44 cpu-release-addr = <0x0 0x8000fff8>;
45 next-level-cache = <&L2_0>;
44 }; 46 };
45 cpu@2 { 47 cpu@2 {
46 device_type = "cpu"; 48 device_type = "cpu";
@@ -48,6 +50,7 @@
48 reg = <0x0 0x2>; 50 reg = <0x0 0x2>;
49 enable-method = "spin-table"; 51 enable-method = "spin-table";
50 cpu-release-addr = <0x0 0x8000fff8>; 52 cpu-release-addr = <0x0 0x8000fff8>;
53 next-level-cache = <&L2_0>;
51 }; 54 };
52 cpu@3 { 55 cpu@3 {
53 device_type = "cpu"; 56 device_type = "cpu";
@@ -55,6 +58,11 @@
55 reg = <0x0 0x3>; 58 reg = <0x0 0x3>;
56 enable-method = "spin-table"; 59 enable-method = "spin-table";
57 cpu-release-addr = <0x0 0x8000fff8>; 60 cpu-release-addr = <0x0 0x8000fff8>;
61 next-level-cache = <&L2_0>;
62 };
63
64 L2_0: l2-cache0 {
65 compatible = "cache";
58 }; 66 };
59 }; 67 };
60 68
diff --git a/arch/arm64/boot/dts/arm/juno.dts b/arch/arm64/boot/dts/arm/juno.dts
index d429129ecb3d..133ee59de2d7 100644
--- a/arch/arm64/boot/dts/arm/juno.dts
+++ b/arch/arm64/boot/dts/arm/juno.dts
@@ -39,6 +39,7 @@
39 reg = <0x0 0x0>; 39 reg = <0x0 0x0>;
40 device_type = "cpu"; 40 device_type = "cpu";
41 enable-method = "psci"; 41 enable-method = "psci";
42 next-level-cache = <&A57_L2>;
42 }; 43 };
43 44
44 A57_1: cpu@1 { 45 A57_1: cpu@1 {
@@ -46,6 +47,7 @@
46 reg = <0x0 0x1>; 47 reg = <0x0 0x1>;
47 device_type = "cpu"; 48 device_type = "cpu";
48 enable-method = "psci"; 49 enable-method = "psci";
50 next-level-cache = <&A57_L2>;
49 }; 51 };
50 52
51 A53_0: cpu@100 { 53 A53_0: cpu@100 {
@@ -53,6 +55,7 @@
53 reg = <0x0 0x100>; 55 reg = <0x0 0x100>;
54 device_type = "cpu"; 56 device_type = "cpu";
55 enable-method = "psci"; 57 enable-method = "psci";
58 next-level-cache = <&A53_L2>;
56 }; 59 };
57 60
58 A53_1: cpu@101 { 61 A53_1: cpu@101 {
@@ -60,6 +63,7 @@
60 reg = <0x0 0x101>; 63 reg = <0x0 0x101>;
61 device_type = "cpu"; 64 device_type = "cpu";
62 enable-method = "psci"; 65 enable-method = "psci";
66 next-level-cache = <&A53_L2>;
63 }; 67 };
64 68
65 A53_2: cpu@102 { 69 A53_2: cpu@102 {
@@ -67,6 +71,7 @@
67 reg = <0x0 0x102>; 71 reg = <0x0 0x102>;
68 device_type = "cpu"; 72 device_type = "cpu";
69 enable-method = "psci"; 73 enable-method = "psci";
74 next-level-cache = <&A53_L2>;
70 }; 75 };
71 76
72 A53_3: cpu@103 { 77 A53_3: cpu@103 {
@@ -74,6 +79,15 @@
74 reg = <0x0 0x103>; 79 reg = <0x0 0x103>;
75 device_type = "cpu"; 80 device_type = "cpu";
76 enable-method = "psci"; 81 enable-method = "psci";
82 next-level-cache = <&A53_L2>;
83 };
84
85 A57_L2: l2-cache0 {
86 compatible = "cache";
87 };
88
89 A53_L2: l2-cache1 {
90 compatible = "cache";
77 }; 91 };
78 }; 92 };
79 93
diff --git a/arch/arm64/boot/dts/arm/rtsm_ve-aemv8a.dts b/arch/arm64/boot/dts/arm/rtsm_ve-aemv8a.dts
index efc59b3baf63..20addabbd127 100644
--- a/arch/arm64/boot/dts/arm/rtsm_ve-aemv8a.dts
+++ b/arch/arm64/boot/dts/arm/rtsm_ve-aemv8a.dts
@@ -37,6 +37,7 @@
37 reg = <0x0 0x0>; 37 reg = <0x0 0x0>;
38 enable-method = "spin-table"; 38 enable-method = "spin-table";
39 cpu-release-addr = <0x0 0x8000fff8>; 39 cpu-release-addr = <0x0 0x8000fff8>;
40 next-level-cache = <&L2_0>;
40 }; 41 };
41 cpu@1 { 42 cpu@1 {
42 device_type = "cpu"; 43 device_type = "cpu";
@@ -44,6 +45,7 @@
44 reg = <0x0 0x1>; 45 reg = <0x0 0x1>;
45 enable-method = "spin-table"; 46 enable-method = "spin-table";
46 cpu-release-addr = <0x0 0x8000fff8>; 47 cpu-release-addr = <0x0 0x8000fff8>;
48 next-level-cache = <&L2_0>;
47 }; 49 };
48 cpu@2 { 50 cpu@2 {
49 device_type = "cpu"; 51 device_type = "cpu";
@@ -51,6 +53,7 @@
51 reg = <0x0 0x2>; 53 reg = <0x0 0x2>;
52 enable-method = "spin-table"; 54 enable-method = "spin-table";
53 cpu-release-addr = <0x0 0x8000fff8>; 55 cpu-release-addr = <0x0 0x8000fff8>;
56 next-level-cache = <&L2_0>;
54 }; 57 };
55 cpu@3 { 58 cpu@3 {
56 device_type = "cpu"; 59 device_type = "cpu";
@@ -58,6 +61,11 @@
58 reg = <0x0 0x3>; 61 reg = <0x0 0x3>;
59 enable-method = "spin-table"; 62 enable-method = "spin-table";
60 cpu-release-addr = <0x0 0x8000fff8>; 63 cpu-release-addr = <0x0 0x8000fff8>;
64 next-level-cache = <&L2_0>;
65 };
66
67 L2_0: l2-cache0 {
68 compatible = "cache";
61 }; 69 };
62 }; 70 };
63 71
diff --git a/arch/arm64/crypto/Makefile b/arch/arm64/crypto/Makefile
index 5720608c50b1..abb79b3cfcfe 100644
--- a/arch/arm64/crypto/Makefile
+++ b/arch/arm64/crypto/Makefile
@@ -29,7 +29,7 @@ aes-ce-blk-y := aes-glue-ce.o aes-ce.o
29obj-$(CONFIG_CRYPTO_AES_ARM64_NEON_BLK) += aes-neon-blk.o 29obj-$(CONFIG_CRYPTO_AES_ARM64_NEON_BLK) += aes-neon-blk.o
30aes-neon-blk-y := aes-glue-neon.o aes-neon.o 30aes-neon-blk-y := aes-glue-neon.o aes-neon.o
31 31
32AFLAGS_aes-ce.o := -DINTERLEAVE=2 -DINTERLEAVE_INLINE 32AFLAGS_aes-ce.o := -DINTERLEAVE=4
33AFLAGS_aes-neon.o := -DINTERLEAVE=4 33AFLAGS_aes-neon.o := -DINTERLEAVE=4
34 34
35CFLAGS_aes-glue-ce.o := -DUSE_V8_CRYPTO_EXTENSIONS 35CFLAGS_aes-glue-ce.o := -DUSE_V8_CRYPTO_EXTENSIONS
diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h
index 5901480bfdca..750bac4e637e 100644
--- a/arch/arm64/include/asm/assembler.h
+++ b/arch/arm64/include/asm/assembler.h
@@ -20,6 +20,9 @@
20#error "Only include this from assembly code" 20#error "Only include this from assembly code"
21#endif 21#endif
22 22
23#ifndef __ASM_ASSEMBLER_H
24#define __ASM_ASSEMBLER_H
25
23#include <asm/ptrace.h> 26#include <asm/ptrace.h>
24#include <asm/thread_info.h> 27#include <asm/thread_info.h>
25 28
@@ -155,3 +158,5 @@ lr .req x30 // link register
155#endif 158#endif
156 orr \rd, \lbits, \hbits, lsl #32 159 orr \rd, \lbits, \hbits, lsl #32
157 .endm 160 .endm
161
162#endif /* __ASM_ASSEMBLER_H */
diff --git a/arch/arm64/include/asm/cpuidle.h b/arch/arm64/include/asm/cpuidle.h
index 0710654631e7..c60643f14cda 100644
--- a/arch/arm64/include/asm/cpuidle.h
+++ b/arch/arm64/include/asm/cpuidle.h
@@ -1,6 +1,8 @@
1#ifndef __ASM_CPUIDLE_H 1#ifndef __ASM_CPUIDLE_H
2#define __ASM_CPUIDLE_H 2#define __ASM_CPUIDLE_H
3 3
4#include <asm/proc-fns.h>
5
4#ifdef CONFIG_CPU_IDLE 6#ifdef CONFIG_CPU_IDLE
5extern int cpu_init_idle(unsigned int cpu); 7extern int cpu_init_idle(unsigned int cpu);
6extern int cpu_suspend(unsigned long arg); 8extern int cpu_suspend(unsigned long arg);
diff --git a/arch/arm64/include/asm/insn.h b/arch/arm64/include/asm/insn.h
index e2ff32a93b5c..d2f49423c5dc 100644
--- a/arch/arm64/include/asm/insn.h
+++ b/arch/arm64/include/asm/insn.h
@@ -264,8 +264,10 @@ __AARCH64_INSN_FUNCS(ands, 0x7F200000, 0x6A000000)
264__AARCH64_INSN_FUNCS(bics, 0x7F200000, 0x6A200000) 264__AARCH64_INSN_FUNCS(bics, 0x7F200000, 0x6A200000)
265__AARCH64_INSN_FUNCS(b, 0xFC000000, 0x14000000) 265__AARCH64_INSN_FUNCS(b, 0xFC000000, 0x14000000)
266__AARCH64_INSN_FUNCS(bl, 0xFC000000, 0x94000000) 266__AARCH64_INSN_FUNCS(bl, 0xFC000000, 0x94000000)
267__AARCH64_INSN_FUNCS(cbz, 0xFE000000, 0x34000000) 267__AARCH64_INSN_FUNCS(cbz, 0x7F000000, 0x34000000)
268__AARCH64_INSN_FUNCS(cbnz, 0xFE000000, 0x35000000) 268__AARCH64_INSN_FUNCS(cbnz, 0x7F000000, 0x35000000)
269__AARCH64_INSN_FUNCS(tbz, 0x7F000000, 0x36000000)
270__AARCH64_INSN_FUNCS(tbnz, 0x7F000000, 0x37000000)
269__AARCH64_INSN_FUNCS(bcond, 0xFF000010, 0x54000000) 271__AARCH64_INSN_FUNCS(bcond, 0xFF000010, 0x54000000)
270__AARCH64_INSN_FUNCS(svc, 0xFFE0001F, 0xD4000001) 272__AARCH64_INSN_FUNCS(svc, 0xFFE0001F, 0xD4000001)
271__AARCH64_INSN_FUNCS(hvc, 0xFFE0001F, 0xD4000002) 273__AARCH64_INSN_FUNCS(hvc, 0xFFE0001F, 0xD4000002)
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index 16449c535e50..800ec0e87ed9 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -460,7 +460,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long addr)
460static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) 460static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
461{ 461{
462 const pteval_t mask = PTE_USER | PTE_PXN | PTE_UXN | PTE_RDONLY | 462 const pteval_t mask = PTE_USER | PTE_PXN | PTE_UXN | PTE_RDONLY |
463 PTE_PROT_NONE | PTE_VALID | PTE_WRITE; 463 PTE_PROT_NONE | PTE_WRITE | PTE_TYPE_MASK;
464 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask); 464 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
465 return pte; 465 return pte;
466} 466}
diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
index f9be30ea1cbd..20e9591a60cf 100644
--- a/arch/arm64/include/asm/processor.h
+++ b/arch/arm64/include/asm/processor.h
@@ -45,7 +45,8 @@
45#define STACK_TOP STACK_TOP_MAX 45#define STACK_TOP STACK_TOP_MAX
46#endif /* CONFIG_COMPAT */ 46#endif /* CONFIG_COMPAT */
47 47
48#define ARCH_LOW_ADDRESS_LIMIT PHYS_MASK 48extern phys_addr_t arm64_dma_phys_limit;
49#define ARCH_LOW_ADDRESS_LIMIT (arm64_dma_phys_limit - 1)
49#endif /* __KERNEL__ */ 50#endif /* __KERNEL__ */
50 51
51struct debug_info { 52struct debug_info {
diff --git a/arch/arm64/include/asm/tlbflush.h b/arch/arm64/include/asm/tlbflush.h
index 73f0ce570fb3..4abe9b945f77 100644
--- a/arch/arm64/include/asm/tlbflush.h
+++ b/arch/arm64/include/asm/tlbflush.h
@@ -24,11 +24,6 @@
24#include <linux/sched.h> 24#include <linux/sched.h>
25#include <asm/cputype.h> 25#include <asm/cputype.h>
26 26
27extern void __cpu_flush_user_tlb_range(unsigned long, unsigned long, struct vm_area_struct *);
28extern void __cpu_flush_kern_tlb_range(unsigned long, unsigned long);
29
30extern struct cpu_tlb_fns cpu_tlb;
31
32/* 27/*
33 * TLB Management 28 * TLB Management
34 * ============== 29 * ==============
diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
index bef04afd6031..5ee07eee80c2 100644
--- a/arch/arm64/kernel/Makefile
+++ b/arch/arm64/kernel/Makefile
@@ -15,8 +15,9 @@ CFLAGS_REMOVE_return_address.o = -pg
15arm64-obj-y := cputable.o debug-monitors.o entry.o irq.o fpsimd.o \ 15arm64-obj-y := cputable.o debug-monitors.o entry.o irq.o fpsimd.o \
16 entry-fpsimd.o process.o ptrace.o setup.o signal.o \ 16 entry-fpsimd.o process.o ptrace.o setup.o signal.o \
17 sys.o stacktrace.o time.o traps.o io.o vdso.o \ 17 sys.o stacktrace.o time.o traps.o io.o vdso.o \
18 hyp-stub.o psci.o cpu_ops.o insn.o return_address.o \ 18 hyp-stub.o psci.o psci-call.o cpu_ops.o insn.o \
19 cpuinfo.o cpu_errata.o alternative.o cacheinfo.o 19 return_address.o cpuinfo.o cpu_errata.o \
20 alternative.o cacheinfo.o
20 21
21arm64-obj-$(CONFIG_COMPAT) += sys32.o kuser32.o signal32.o \ 22arm64-obj-$(CONFIG_COMPAT) += sys32.o kuser32.o signal32.o \
22 sys_compat.o entry32.o \ 23 sys_compat.o entry32.o \
diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c
index cf8556ae09d0..c851be795080 100644
--- a/arch/arm64/kernel/ftrace.c
+++ b/arch/arm64/kernel/ftrace.c
@@ -156,7 +156,7 @@ static int ftrace_modify_graph_caller(bool enable)
156 156
157 branch = aarch64_insn_gen_branch_imm(pc, 157 branch = aarch64_insn_gen_branch_imm(pc,
158 (unsigned long)ftrace_graph_caller, 158 (unsigned long)ftrace_graph_caller,
159 AARCH64_INSN_BRANCH_LINK); 159 AARCH64_INSN_BRANCH_NOLINK);
160 nop = aarch64_insn_gen_nop(); 160 nop = aarch64_insn_gen_nop();
161 161
162 if (enable) 162 if (enable)
diff --git a/arch/arm64/kernel/insn.c b/arch/arm64/kernel/insn.c
index 27d4864577e5..c8eca88f12e6 100644
--- a/arch/arm64/kernel/insn.c
+++ b/arch/arm64/kernel/insn.c
@@ -87,8 +87,10 @@ static void __kprobes *patch_map(void *addr, int fixmap)
87 87
88 if (module && IS_ENABLED(CONFIG_DEBUG_SET_MODULE_RONX)) 88 if (module && IS_ENABLED(CONFIG_DEBUG_SET_MODULE_RONX))
89 page = vmalloc_to_page(addr); 89 page = vmalloc_to_page(addr);
90 else 90 else if (!module && IS_ENABLED(CONFIG_DEBUG_RODATA))
91 page = virt_to_page(addr); 91 page = virt_to_page(addr);
92 else
93 return addr;
92 94
93 BUG_ON(!page); 95 BUG_ON(!page);
94 set_fixmap(fixmap, page_to_phys(page)); 96 set_fixmap(fixmap, page_to_phys(page));
diff --git a/arch/arm64/kernel/psci-call.S b/arch/arm64/kernel/psci-call.S
new file mode 100644
index 000000000000..cf83e61cd3b5
--- /dev/null
+++ b/arch/arm64/kernel/psci-call.S
@@ -0,0 +1,28 @@
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License version 2 as
4 * published by the Free Software Foundation.
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 * Copyright (C) 2015 ARM Limited
12 *
13 * Author: Will Deacon <will.deacon@arm.com>
14 */
15
16#include <linux/linkage.h>
17
18/* int __invoke_psci_fn_hvc(u64 function_id, u64 arg0, u64 arg1, u64 arg2) */
19ENTRY(__invoke_psci_fn_hvc)
20 hvc #0
21 ret
22ENDPROC(__invoke_psci_fn_hvc)
23
24/* int __invoke_psci_fn_smc(u64 function_id, u64 arg0, u64 arg1, u64 arg2) */
25ENTRY(__invoke_psci_fn_smc)
26 smc #0
27 ret
28ENDPROC(__invoke_psci_fn_smc)
diff --git a/arch/arm64/kernel/psci.c b/arch/arm64/kernel/psci.c
index 3425f311c49e..9b8a70ae64a1 100644
--- a/arch/arm64/kernel/psci.c
+++ b/arch/arm64/kernel/psci.c
@@ -57,6 +57,9 @@ static struct psci_operations psci_ops;
57static int (*invoke_psci_fn)(u64, u64, u64, u64); 57static int (*invoke_psci_fn)(u64, u64, u64, u64);
58typedef int (*psci_initcall_t)(const struct device_node *); 58typedef int (*psci_initcall_t)(const struct device_node *);
59 59
60asmlinkage int __invoke_psci_fn_hvc(u64, u64, u64, u64);
61asmlinkage int __invoke_psci_fn_smc(u64, u64, u64, u64);
62
60enum psci_function { 63enum psci_function {
61 PSCI_FN_CPU_SUSPEND, 64 PSCI_FN_CPU_SUSPEND,
62 PSCI_FN_CPU_ON, 65 PSCI_FN_CPU_ON,
@@ -109,40 +112,6 @@ static void psci_power_state_unpack(u32 power_state,
109 PSCI_0_2_POWER_STATE_AFFL_SHIFT; 112 PSCI_0_2_POWER_STATE_AFFL_SHIFT;
110} 113}
111 114
112/*
113 * The following two functions are invoked via the invoke_psci_fn pointer
114 * and will not be inlined, allowing us to piggyback on the AAPCS.
115 */
116static noinline int __invoke_psci_fn_hvc(u64 function_id, u64 arg0, u64 arg1,
117 u64 arg2)
118{
119 asm volatile(
120 __asmeq("%0", "x0")
121 __asmeq("%1", "x1")
122 __asmeq("%2", "x2")
123 __asmeq("%3", "x3")
124 "hvc #0\n"
125 : "+r" (function_id)
126 : "r" (arg0), "r" (arg1), "r" (arg2));
127
128 return function_id;
129}
130
131static noinline int __invoke_psci_fn_smc(u64 function_id, u64 arg0, u64 arg1,
132 u64 arg2)
133{
134 asm volatile(
135 __asmeq("%0", "x0")
136 __asmeq("%1", "x1")
137 __asmeq("%2", "x2")
138 __asmeq("%3", "x3")
139 "smc #0\n"
140 : "+r" (function_id)
141 : "r" (arg0), "r" (arg1), "r" (arg2));
142
143 return function_id;
144}
145
146static int psci_get_version(void) 115static int psci_get_version(void)
147{ 116{
148 int err; 117 int err;
diff --git a/arch/arm64/kernel/signal32.c b/arch/arm64/kernel/signal32.c
index c20a300e2213..d26fcd4cd6e6 100644
--- a/arch/arm64/kernel/signal32.c
+++ b/arch/arm64/kernel/signal32.c
@@ -154,8 +154,7 @@ int copy_siginfo_to_user32(compat_siginfo_t __user *to, const siginfo_t *from)
154 case __SI_TIMER: 154 case __SI_TIMER:
155 err |= __put_user(from->si_tid, &to->si_tid); 155 err |= __put_user(from->si_tid, &to->si_tid);
156 err |= __put_user(from->si_overrun, &to->si_overrun); 156 err |= __put_user(from->si_overrun, &to->si_overrun);
157 err |= __put_user((compat_uptr_t)(unsigned long)from->si_ptr, 157 err |= __put_user(from->si_int, &to->si_int);
158 &to->si_ptr);
159 break; 158 break;
160 case __SI_POLL: 159 case __SI_POLL:
161 err |= __put_user(from->si_band, &to->si_band); 160 err |= __put_user(from->si_band, &to->si_band);
@@ -184,7 +183,7 @@ int copy_siginfo_to_user32(compat_siginfo_t __user *to, const siginfo_t *from)
184 case __SI_MESGQ: /* But this is */ 183 case __SI_MESGQ: /* But this is */
185 err |= __put_user(from->si_pid, &to->si_pid); 184 err |= __put_user(from->si_pid, &to->si_pid);
186 err |= __put_user(from->si_uid, &to->si_uid); 185 err |= __put_user(from->si_uid, &to->si_uid);
187 err |= __put_user((compat_uptr_t)(unsigned long)from->si_ptr, &to->si_ptr); 186 err |= __put_user(from->si_int, &to->si_int);
188 break; 187 break;
189 case __SI_SYS: 188 case __SI_SYS:
190 err |= __put_user((compat_uptr_t)(unsigned long) 189 err |= __put_user((compat_uptr_t)(unsigned long)
diff --git a/arch/arm64/kernel/vdso/gettimeofday.S b/arch/arm64/kernel/vdso/gettimeofday.S
index fe652ffd34c2..efa79e8d4196 100644
--- a/arch/arm64/kernel/vdso/gettimeofday.S
+++ b/arch/arm64/kernel/vdso/gettimeofday.S
@@ -174,8 +174,6 @@ ENDPROC(__kernel_clock_gettime)
174/* int __kernel_clock_getres(clockid_t clock_id, struct timespec *res); */ 174/* int __kernel_clock_getres(clockid_t clock_id, struct timespec *res); */
175ENTRY(__kernel_clock_getres) 175ENTRY(__kernel_clock_getres)
176 .cfi_startproc 176 .cfi_startproc
177 cbz w1, 3f
178
179 cmp w0, #CLOCK_REALTIME 177 cmp w0, #CLOCK_REALTIME
180 ccmp w0, #CLOCK_MONOTONIC, #0x4, ne 178 ccmp w0, #CLOCK_MONOTONIC, #0x4, ne
181 b.ne 1f 179 b.ne 1f
@@ -188,6 +186,7 @@ ENTRY(__kernel_clock_getres)
188 b.ne 4f 186 b.ne 4f
189 ldr x2, 6f 187 ldr x2, 6f
1902: 1882:
189 cbz w1, 3f
191 stp xzr, x2, [x1] 190 stp xzr, x2, [x1]
192 191
1933: /* res == NULL. */ 1923: /* res == NULL. */
diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c
index 0a24b9b8c698..58e0c2bdde04 100644
--- a/arch/arm64/mm/dma-mapping.c
+++ b/arch/arm64/mm/dma-mapping.c
@@ -348,8 +348,6 @@ static struct dma_map_ops swiotlb_dma_ops = {
348 .mapping_error = swiotlb_dma_mapping_error, 348 .mapping_error = swiotlb_dma_mapping_error,
349}; 349};
350 350
351extern int swiotlb_late_init_with_default_size(size_t default_size);
352
353static int __init atomic_pool_init(void) 351static int __init atomic_pool_init(void)
354{ 352{
355 pgprot_t prot = __pgprot(PROT_NORMAL_NC); 353 pgprot_t prot = __pgprot(PROT_NORMAL_NC);
@@ -411,21 +409,13 @@ out:
411 return -ENOMEM; 409 return -ENOMEM;
412} 410}
413 411
414static int __init swiotlb_late_init(void) 412static int __init arm64_dma_init(void)
415{ 413{
416 size_t swiotlb_size = min(SZ_64M, MAX_ORDER_NR_PAGES << PAGE_SHIFT); 414 int ret;
417 415
418 dma_ops = &swiotlb_dma_ops; 416 dma_ops = &swiotlb_dma_ops;
419 417
420 return swiotlb_late_init_with_default_size(swiotlb_size); 418 ret = atomic_pool_init();
421}
422
423static int __init arm64_dma_init(void)
424{
425 int ret = 0;
426
427 ret |= swiotlb_late_init();
428 ret |= atomic_pool_init();
429 419
430 return ret; 420 return ret;
431} 421}
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 71145f952070..ae85da6307bb 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -33,6 +33,7 @@
33#include <linux/dma-mapping.h> 33#include <linux/dma-mapping.h>
34#include <linux/dma-contiguous.h> 34#include <linux/dma-contiguous.h>
35#include <linux/efi.h> 35#include <linux/efi.h>
36#include <linux/swiotlb.h>
36 37
37#include <asm/fixmap.h> 38#include <asm/fixmap.h>
38#include <asm/memory.h> 39#include <asm/memory.h>
@@ -45,6 +46,7 @@
45#include "mm.h" 46#include "mm.h"
46 47
47phys_addr_t memstart_addr __read_mostly = 0; 48phys_addr_t memstart_addr __read_mostly = 0;
49phys_addr_t arm64_dma_phys_limit __read_mostly;
48 50
49#ifdef CONFIG_BLK_DEV_INITRD 51#ifdef CONFIG_BLK_DEV_INITRD
50static int __init early_initrd(char *p) 52static int __init early_initrd(char *p)
@@ -85,7 +87,7 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max)
85 87
86 /* 4GB maximum for 32-bit only capable devices */ 88 /* 4GB maximum for 32-bit only capable devices */
87 if (IS_ENABLED(CONFIG_ZONE_DMA)) { 89 if (IS_ENABLED(CONFIG_ZONE_DMA)) {
88 max_dma = PFN_DOWN(max_zone_dma_phys()); 90 max_dma = PFN_DOWN(arm64_dma_phys_limit);
89 zone_size[ZONE_DMA] = max_dma - min; 91 zone_size[ZONE_DMA] = max_dma - min;
90 } 92 }
91 zone_size[ZONE_NORMAL] = max - max_dma; 93 zone_size[ZONE_NORMAL] = max - max_dma;
@@ -156,8 +158,6 @@ early_param("mem", early_mem);
156 158
157void __init arm64_memblock_init(void) 159void __init arm64_memblock_init(void)
158{ 160{
159 phys_addr_t dma_phys_limit = 0;
160
161 memblock_enforce_memory_limit(memory_limit); 161 memblock_enforce_memory_limit(memory_limit);
162 162
163 /* 163 /*
@@ -174,8 +174,10 @@ void __init arm64_memblock_init(void)
174 174
175 /* 4GB maximum for 32-bit only capable devices */ 175 /* 4GB maximum for 32-bit only capable devices */
176 if (IS_ENABLED(CONFIG_ZONE_DMA)) 176 if (IS_ENABLED(CONFIG_ZONE_DMA))
177 dma_phys_limit = max_zone_dma_phys(); 177 arm64_dma_phys_limit = max_zone_dma_phys();
178 dma_contiguous_reserve(dma_phys_limit); 178 else
179 arm64_dma_phys_limit = PHYS_MASK + 1;
180 dma_contiguous_reserve(arm64_dma_phys_limit);
179 181
180 memblock_allow_resize(); 182 memblock_allow_resize();
181 memblock_dump_all(); 183 memblock_dump_all();
@@ -276,6 +278,8 @@ static void __init free_unused_memmap(void)
276 */ 278 */
277void __init mem_init(void) 279void __init mem_init(void)
278{ 280{
281 swiotlb_init(1);
282
279 set_max_mapnr(pfn_to_page(max_pfn) - mem_map); 283 set_max_mapnr(pfn_to_page(max_pfn) - mem_map);
280 284
281#ifndef CONFIG_SPARSEMEM_VMEMMAP 285#ifndef CONFIG_SPARSEMEM_VMEMMAP
diff --git a/arch/frv/include/asm/pgtable.h b/arch/frv/include/asm/pgtable.h
index 93bcf2abd1a1..07d7a7ef8bd5 100644
--- a/arch/frv/include/asm/pgtable.h
+++ b/arch/frv/include/asm/pgtable.h
@@ -123,12 +123,14 @@ extern unsigned long empty_zero_page;
123#define PGDIR_MASK (~(PGDIR_SIZE - 1)) 123#define PGDIR_MASK (~(PGDIR_SIZE - 1))
124#define PTRS_PER_PGD 64 124#define PTRS_PER_PGD 64
125 125
126#define __PAGETABLE_PUD_FOLDED
126#define PUD_SHIFT 26 127#define PUD_SHIFT 26
127#define PTRS_PER_PUD 1 128#define PTRS_PER_PUD 1
128#define PUD_SIZE (1UL << PUD_SHIFT) 129#define PUD_SIZE (1UL << PUD_SHIFT)
129#define PUD_MASK (~(PUD_SIZE - 1)) 130#define PUD_MASK (~(PUD_SIZE - 1))
130#define PUE_SIZE 256 131#define PUE_SIZE 256
131 132
133#define __PAGETABLE_PMD_FOLDED
132#define PMD_SHIFT 26 134#define PMD_SHIFT 26
133#define PMD_SIZE (1UL << PMD_SHIFT) 135#define PMD_SIZE (1UL << PMD_SHIFT)
134#define PMD_MASK (~(PMD_SIZE - 1)) 136#define PMD_MASK (~(PMD_SIZE - 1))
diff --git a/arch/m32r/include/asm/pgtable-2level.h b/arch/m32r/include/asm/pgtable-2level.h
index 8fd8ee70266a..421e6ba3a173 100644
--- a/arch/m32r/include/asm/pgtable-2level.h
+++ b/arch/m32r/include/asm/pgtable-2level.h
@@ -13,6 +13,7 @@
13 * the M32R is two-level, so we don't really have any 13 * the M32R is two-level, so we don't really have any
14 * PMD directory physically. 14 * PMD directory physically.
15 */ 15 */
16#define __PAGETABLE_PMD_FOLDED
16#define PMD_SHIFT 22 17#define PMD_SHIFT 22
17#define PTRS_PER_PMD 1 18#define PTRS_PER_PMD 1
18 19
diff --git a/arch/m68k/include/asm/pgtable_mm.h b/arch/m68k/include/asm/pgtable_mm.h
index 28a145bfbb71..35ed4a9981ae 100644
--- a/arch/m68k/include/asm/pgtable_mm.h
+++ b/arch/m68k/include/asm/pgtable_mm.h
@@ -54,10 +54,12 @@
54 */ 54 */
55#ifdef CONFIG_SUN3 55#ifdef CONFIG_SUN3
56#define PTRS_PER_PTE 16 56#define PTRS_PER_PTE 16
57#define __PAGETABLE_PMD_FOLDED
57#define PTRS_PER_PMD 1 58#define PTRS_PER_PMD 1
58#define PTRS_PER_PGD 2048 59#define PTRS_PER_PGD 2048
59#elif defined(CONFIG_COLDFIRE) 60#elif defined(CONFIG_COLDFIRE)
60#define PTRS_PER_PTE 512 61#define PTRS_PER_PTE 512
62#define __PAGETABLE_PMD_FOLDED
61#define PTRS_PER_PMD 1 63#define PTRS_PER_PMD 1
62#define PTRS_PER_PGD 1024 64#define PTRS_PER_PGD 1024
63#else 65#else
diff --git a/arch/metag/include/asm/processor.h b/arch/metag/include/asm/processor.h
index 881071c07942..13272fd5a5ba 100644
--- a/arch/metag/include/asm/processor.h
+++ b/arch/metag/include/asm/processor.h
@@ -149,8 +149,8 @@ extern void exit_thread(void);
149 149
150unsigned long get_wchan(struct task_struct *p); 150unsigned long get_wchan(struct task_struct *p);
151 151
152#define KSTK_EIP(tsk) ((tsk)->thread.kernel_context->CurrPC) 152#define KSTK_EIP(tsk) (task_pt_regs(tsk)->ctx.CurrPC)
153#define KSTK_ESP(tsk) ((tsk)->thread.kernel_context->AX[0].U0) 153#define KSTK_ESP(tsk) (task_pt_regs(tsk)->ctx.AX[0].U0)
154 154
155#define user_stack_pointer(regs) ((regs)->ctx.AX[0].U0) 155#define user_stack_pointer(regs) ((regs)->ctx.AX[0].U0)
156 156
diff --git a/arch/mn10300/include/asm/pgtable.h b/arch/mn10300/include/asm/pgtable.h
index afab728ab65e..96d3f9deb59c 100644
--- a/arch/mn10300/include/asm/pgtable.h
+++ b/arch/mn10300/include/asm/pgtable.h
@@ -56,7 +56,9 @@ extern void paging_init(void);
56#define PGDIR_SHIFT 22 56#define PGDIR_SHIFT 22
57#define PTRS_PER_PGD 1024 57#define PTRS_PER_PGD 1024
58#define PTRS_PER_PUD 1 /* we don't really have any PUD physically */ 58#define PTRS_PER_PUD 1 /* we don't really have any PUD physically */
59#define __PAGETABLE_PUD_FOLDED
59#define PTRS_PER_PMD 1 /* we don't really have any PMD physically */ 60#define PTRS_PER_PMD 1 /* we don't really have any PMD physically */
61#define __PAGETABLE_PMD_FOLDED
60#define PTRS_PER_PTE 1024 62#define PTRS_PER_PTE 1024
61 63
62#define PGD_SIZE PAGE_SIZE 64#define PGD_SIZE PAGE_SIZE
diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
index 8c966b2270aa..15207b9362bf 100644
--- a/arch/parisc/include/asm/pgtable.h
+++ b/arch/parisc/include/asm/pgtable.h
@@ -96,6 +96,7 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
96#if PT_NLEVELS == 3 96#if PT_NLEVELS == 3
97#define BITS_PER_PMD (PAGE_SHIFT + PMD_ORDER - BITS_PER_PMD_ENTRY) 97#define BITS_PER_PMD (PAGE_SHIFT + PMD_ORDER - BITS_PER_PMD_ENTRY)
98#else 98#else
99#define __PAGETABLE_PMD_FOLDED
99#define BITS_PER_PMD 0 100#define BITS_PER_PMD 0
100#endif 101#endif
101#define PTRS_PER_PMD (1UL << BITS_PER_PMD) 102#define PTRS_PER_PMD (1UL << BITS_PER_PMD)
diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
index fbb5ee3ae57c..e08ec38f8c6e 100644
--- a/arch/s390/include/asm/pgtable.h
+++ b/arch/s390/include/asm/pgtable.h
@@ -91,7 +91,9 @@ extern unsigned long zero_page_mask;
91 */ 91 */
92#define PTRS_PER_PTE 256 92#define PTRS_PER_PTE 256
93#ifndef CONFIG_64BIT 93#ifndef CONFIG_64BIT
94#define __PAGETABLE_PUD_FOLDED
94#define PTRS_PER_PMD 1 95#define PTRS_PER_PMD 1
96#define __PAGETABLE_PMD_FOLDED
95#define PTRS_PER_PUD 1 97#define PTRS_PER_PUD 1
96#else /* CONFIG_64BIT */ 98#else /* CONFIG_64BIT */
97#define PTRS_PER_PMD 2048 99#define PTRS_PER_PMD 2048
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index b5c8ff5e9dfc..2346c95c6ab1 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1396,6 +1396,12 @@ void cpu_init(void)
1396 1396
1397 wait_for_master_cpu(cpu); 1397 wait_for_master_cpu(cpu);
1398 1398
1399 /*
1400 * Initialize the CR4 shadow before doing anything that could
1401 * try to read it.
1402 */
1403 cr4_init_shadow();
1404
1399 show_ucode_info_early(); 1405 show_ucode_info_early();
1400 1406
1401 printk(KERN_INFO "Initializing CPU#%d\n", cpu); 1407 printk(KERN_INFO "Initializing CPU#%d\n", cpu);
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 94d7dcb12145..50163fa9034f 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -565,8 +565,8 @@ static const struct _tlb_table intel_tlb_table[] = {
565 { 0xb2, TLB_INST_4K, 64, " TLB_INST 4KByte pages, 4-way set associative" }, 565 { 0xb2, TLB_INST_4K, 64, " TLB_INST 4KByte pages, 4-way set associative" },
566 { 0xb3, TLB_DATA_4K, 128, " TLB_DATA 4 KByte pages, 4-way set associative" }, 566 { 0xb3, TLB_DATA_4K, 128, " TLB_DATA 4 KByte pages, 4-way set associative" },
567 { 0xb4, TLB_DATA_4K, 256, " TLB_DATA 4 KByte pages, 4-way associative" }, 567 { 0xb4, TLB_DATA_4K, 256, " TLB_DATA 4 KByte pages, 4-way associative" },
568 { 0xb5, TLB_INST_4K, 64, " TLB_INST 4 KByte pages, 8-way set ssociative" }, 568 { 0xb5, TLB_INST_4K, 64, " TLB_INST 4 KByte pages, 8-way set associative" },
569 { 0xb6, TLB_INST_4K, 128, " TLB_INST 4 KByte pages, 8-way set ssociative" }, 569 { 0xb6, TLB_INST_4K, 128, " TLB_INST 4 KByte pages, 8-way set associative" },
570 { 0xba, TLB_DATA_4K, 64, " TLB_DATA 4 KByte pages, 4-way associative" }, 570 { 0xba, TLB_DATA_4K, 64, " TLB_DATA 4 KByte pages, 4-way associative" },
571 { 0xc0, TLB_DATA_4K_4M, 8, " TLB_DATA 4 KByte and 4 MByte pages, 4-way associative" }, 571 { 0xc0, TLB_DATA_4K_4M, 8, " TLB_DATA 4 KByte and 4 MByte pages, 4-way associative" },
572 { 0xc1, STLB_4K_2M, 1024, " STLB 4 KByte and 2 MByte pages, 8-way associative" }, 572 { 0xc1, STLB_4K_2M, 1024, " STLB 4 KByte and 2 MByte pages, 8-way associative" },
diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index 000d4199b03e..31e2d5bf3e38 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -982,6 +982,9 @@ ENTRY(xen_hypervisor_callback)
982ENTRY(xen_do_upcall) 982ENTRY(xen_do_upcall)
9831: mov %esp, %eax 9831: mov %esp, %eax
984 call xen_evtchn_do_upcall 984 call xen_evtchn_do_upcall
985#ifndef CONFIG_PREEMPT
986 call xen_maybe_preempt_hcall
987#endif
985 jmp ret_from_intr 988 jmp ret_from_intr
986 CFI_ENDPROC 989 CFI_ENDPROC
987ENDPROC(xen_hypervisor_callback) 990ENDPROC(xen_hypervisor_callback)
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index db13655c3a2a..10074ad9ebf8 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -1208,6 +1208,9 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
1208 popq %rsp 1208 popq %rsp
1209 CFI_DEF_CFA_REGISTER rsp 1209 CFI_DEF_CFA_REGISTER rsp
1210 decl PER_CPU_VAR(irq_count) 1210 decl PER_CPU_VAR(irq_count)
1211#ifndef CONFIG_PREEMPT
1212 call xen_maybe_preempt_hcall
1213#endif
1211 jmp error_exit 1214 jmp error_exit
1212 CFI_ENDPROC 1215 CFI_ENDPROC
1213END(xen_do_hypervisor_callback) 1216END(xen_do_hypervisor_callback)
diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
index 6a1146ea4d4d..4e3d5a9621fe 100644
--- a/arch/x86/kernel/kprobes/core.c
+++ b/arch/x86/kernel/kprobes/core.c
@@ -223,27 +223,48 @@ static unsigned long
223__recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr) 223__recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
224{ 224{
225 struct kprobe *kp; 225 struct kprobe *kp;
226 unsigned long faddr;
226 227
227 kp = get_kprobe((void *)addr); 228 kp = get_kprobe((void *)addr);
228 /* There is no probe, return original address */ 229 faddr = ftrace_location(addr);
229 if (!kp) 230 /*
231 * Addresses inside the ftrace location are refused by
232 * arch_check_ftrace_location(). Something went terribly wrong
233 * if such an address is checked here.
234 */
235 if (WARN_ON(faddr && faddr != addr))
236 return 0UL;
237 /*
238 * Use the current code if it is not modified by Kprobe
239 * and it cannot be modified by ftrace.
240 */
241 if (!kp && !faddr)
230 return addr; 242 return addr;
231 243
232 /* 244 /*
233 * Basically, kp->ainsn.insn has an original instruction. 245 * Basically, kp->ainsn.insn has an original instruction.
234 * However, RIP-relative instruction can not do single-stepping 246 * However, RIP-relative instruction can not do single-stepping
235 * at different place, __copy_instruction() tweaks the displacement of 247 * at different place, __copy_instruction() tweaks the displacement of
236 * that instruction. In that case, we can't recover the instruction 248 * that instruction. In that case, we can't recover the instruction
237 * from the kp->ainsn.insn. 249 * from the kp->ainsn.insn.
238 * 250 *
239 * On the other hand, kp->opcode has a copy of the first byte of 251 * On the other hand, in case on normal Kprobe, kp->opcode has a copy
240 * the probed instruction, which is overwritten by int3. And 252 * of the first byte of the probed instruction, which is overwritten
241 * the instruction at kp->addr is not modified by kprobes except 253 * by int3. And the instruction at kp->addr is not modified by kprobes
242 * for the first byte, we can recover the original instruction 254 * except for the first byte, we can recover the original instruction
243 * from it and kp->opcode. 255 * from it and kp->opcode.
256 *
257 * In case of Kprobes using ftrace, we do not have a copy of
258 * the original instruction. In fact, the ftrace location might
259 * be modified at anytime and even could be in an inconsistent state.
260 * Fortunately, we know that the original code is the ideal 5-byte
261 * long NOP.
244 */ 262 */
245 memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t)); 263 memcpy(buf, (void *)addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
246 buf[0] = kp->opcode; 264 if (faddr)
265 memcpy(buf, ideal_nops[NOP_ATOMIC5], 5);
266 else
267 buf[0] = kp->opcode;
247 return (unsigned long)buf; 268 return (unsigned long)buf;
248} 269}
249 270
@@ -251,6 +272,7 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
251 * Recover the probed instruction at addr for further analysis. 272 * Recover the probed instruction at addr for further analysis.
252 * Caller must lock kprobes by kprobe_mutex, or disable preemption 273 * Caller must lock kprobes by kprobe_mutex, or disable preemption
253 * for preventing to release referencing kprobes. 274 * for preventing to release referencing kprobes.
275 * Returns zero if the instruction can not get recovered.
254 */ 276 */
255unsigned long recover_probed_instruction(kprobe_opcode_t *buf, unsigned long addr) 277unsigned long recover_probed_instruction(kprobe_opcode_t *buf, unsigned long addr)
256{ 278{
@@ -285,6 +307,8 @@ static int can_probe(unsigned long paddr)
285 * normally used, we just go through if there is no kprobe. 307 * normally used, we just go through if there is no kprobe.
286 */ 308 */
287 __addr = recover_probed_instruction(buf, addr); 309 __addr = recover_probed_instruction(buf, addr);
310 if (!__addr)
311 return 0;
288 kernel_insn_init(&insn, (void *)__addr, MAX_INSN_SIZE); 312 kernel_insn_init(&insn, (void *)__addr, MAX_INSN_SIZE);
289 insn_get_length(&insn); 313 insn_get_length(&insn);
290 314
@@ -333,6 +357,8 @@ int __copy_instruction(u8 *dest, u8 *src)
333 unsigned long recovered_insn = 357 unsigned long recovered_insn =
334 recover_probed_instruction(buf, (unsigned long)src); 358 recover_probed_instruction(buf, (unsigned long)src);
335 359
360 if (!recovered_insn)
361 return 0;
336 kernel_insn_init(&insn, (void *)recovered_insn, MAX_INSN_SIZE); 362 kernel_insn_init(&insn, (void *)recovered_insn, MAX_INSN_SIZE);
337 insn_get_length(&insn); 363 insn_get_length(&insn);
338 /* Another subsystem puts a breakpoint, failed to recover */ 364 /* Another subsystem puts a breakpoint, failed to recover */
diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
index 0dd8d089c315..7b3b9d15c47a 100644
--- a/arch/x86/kernel/kprobes/opt.c
+++ b/arch/x86/kernel/kprobes/opt.c
@@ -259,6 +259,8 @@ static int can_optimize(unsigned long paddr)
259 */ 259 */
260 return 0; 260 return 0;
261 recovered_insn = recover_probed_instruction(buf, addr); 261 recovered_insn = recover_probed_instruction(buf, addr);
262 if (!recovered_insn)
263 return 0;
262 kernel_insn_init(&insn, (void *)recovered_insn, MAX_INSN_SIZE); 264 kernel_insn_init(&insn, (void *)recovered_insn, MAX_INSN_SIZE);
263 insn_get_length(&insn); 265 insn_get_length(&insn);
264 /* Another subsystem puts a breakpoint */ 266 /* Another subsystem puts a breakpoint */
diff --git a/arch/x86/lguest/Kconfig b/arch/x86/lguest/Kconfig
index 4a0890f815c4..08f41caada45 100644
--- a/arch/x86/lguest/Kconfig
+++ b/arch/x86/lguest/Kconfig
@@ -1,6 +1,6 @@
1config LGUEST_GUEST 1config LGUEST_GUEST
2 bool "Lguest guest support" 2 bool "Lguest guest support"
3 depends on X86_32 && PARAVIRT 3 depends on X86_32 && PARAVIRT && PCI
4 select TTY 4 select TTY
5 select VIRTUALIZATION 5 select VIRTUALIZATION
6 select VIRTIO 6 select VIRTIO
@@ -8,7 +8,7 @@ config LGUEST_GUEST
8 help 8 help
9 Lguest is a tiny in-kernel hypervisor. Selecting this will 9 Lguest is a tiny in-kernel hypervisor. Selecting this will
10 allow your kernel to boot under lguest. This option will increase 10 allow your kernel to boot under lguest. This option will increase
11 your kernel size by about 6k. If in doubt, say N. 11 your kernel size by about 10k. If in doubt, say N.
12 12
13 If you say Y here, make sure you say Y (or M) to the virtio block 13 If you say Y here, make sure you say Y (or M) to the virtio block
14 and net drivers which lguest needs. 14 and net drivers which lguest needs.
diff --git a/arch/x86/platform/intel-mid/intel-mid.c b/arch/x86/platform/intel-mid/intel-mid.c
index 1bbedc4b0f88..3005f0c89f2e 100644
--- a/arch/x86/platform/intel-mid/intel-mid.c
+++ b/arch/x86/platform/intel-mid/intel-mid.c
@@ -130,7 +130,7 @@ static void intel_mid_arch_setup(void)
130 intel_mid_ops = get_intel_mid_ops[__intel_mid_cpu_chip](); 130 intel_mid_ops = get_intel_mid_ops[__intel_mid_cpu_chip]();
131 else { 131 else {
132 intel_mid_ops = get_intel_mid_ops[INTEL_MID_CPU_CHIP_PENWELL](); 132 intel_mid_ops = get_intel_mid_ops[INTEL_MID_CPU_CHIP_PENWELL]();
133 pr_info("ARCH: Uknown SoC, assuming PENWELL!\n"); 133 pr_info("ARCH: Unknown SoC, assuming PENWELL!\n");
134 } 134 }
135 135
136out: 136out:
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index bd8b8459c3d0..5240f563076d 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -1070,6 +1070,23 @@ static inline void xen_write_cr8(unsigned long val)
1070 BUG_ON(val); 1070 BUG_ON(val);
1071} 1071}
1072#endif 1072#endif
1073
1074static u64 xen_read_msr_safe(unsigned int msr, int *err)
1075{
1076 u64 val;
1077
1078 val = native_read_msr_safe(msr, err);
1079 switch (msr) {
1080 case MSR_IA32_APICBASE:
1081#ifdef CONFIG_X86_X2APIC
1082 if (!(cpuid_ecx(1) & (1 << (X86_FEATURE_X2APIC & 31))))
1083#endif
1084 val &= ~X2APIC_ENABLE;
1085 break;
1086 }
1087 return val;
1088}
1089
1073static int xen_write_msr_safe(unsigned int msr, unsigned low, unsigned high) 1090static int xen_write_msr_safe(unsigned int msr, unsigned low, unsigned high)
1074{ 1091{
1075 int ret; 1092 int ret;
@@ -1240,7 +1257,7 @@ static const struct pv_cpu_ops xen_cpu_ops __initconst = {
1240 1257
1241 .wbinvd = native_wbinvd, 1258 .wbinvd = native_wbinvd,
1242 1259
1243 .read_msr = native_read_msr_safe, 1260 .read_msr = xen_read_msr_safe,
1244 .write_msr = xen_write_msr_safe, 1261 .write_msr = xen_write_msr_safe,
1245 1262
1246 .read_tsc = native_read_tsc, 1263 .read_tsc = native_read_tsc,
@@ -1741,6 +1758,7 @@ asmlinkage __visible void __init xen_start_kernel(void)
1741#ifdef CONFIG_X86_32 1758#ifdef CONFIG_X86_32
1742 i386_start_kernel(); 1759 i386_start_kernel();
1743#else 1760#else
1761 cr4_init_shadow(); /* 32b kernel does this in i386_start_kernel() */
1744 x86_64_start_reservations((char *)__pa_symbol(&boot_params)); 1762 x86_64_start_reservations((char *)__pa_symbol(&boot_params));
1745#endif 1763#endif
1746} 1764}
diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c
index b64bccbb78c9..ceb32dd52a6c 100644
--- a/drivers/block/nvme-core.c
+++ b/drivers/block/nvme-core.c
@@ -482,6 +482,7 @@ static int nvme_error_status(u16 status)
482 } 482 }
483} 483}
484 484
485#ifdef CONFIG_BLK_DEV_INTEGRITY
485static void nvme_dif_prep(u32 p, u32 v, struct t10_pi_tuple *pi) 486static void nvme_dif_prep(u32 p, u32 v, struct t10_pi_tuple *pi)
486{ 487{
487 if (be32_to_cpu(pi->ref_tag) == v) 488 if (be32_to_cpu(pi->ref_tag) == v)
@@ -538,6 +539,58 @@ static void nvme_dif_remap(struct request *req,
538 kunmap_atomic(pmap); 539 kunmap_atomic(pmap);
539} 540}
540 541
542static int nvme_noop_verify(struct blk_integrity_iter *iter)
543{
544 return 0;
545}
546
547static int nvme_noop_generate(struct blk_integrity_iter *iter)
548{
549 return 0;
550}
551
552struct blk_integrity nvme_meta_noop = {
553 .name = "NVME_META_NOOP",
554 .generate_fn = nvme_noop_generate,
555 .verify_fn = nvme_noop_verify,
556};
557
558static void nvme_init_integrity(struct nvme_ns *ns)
559{
560 struct blk_integrity integrity;
561
562 switch (ns->pi_type) {
563 case NVME_NS_DPS_PI_TYPE3:
564 integrity = t10_pi_type3_crc;
565 break;
566 case NVME_NS_DPS_PI_TYPE1:
567 case NVME_NS_DPS_PI_TYPE2:
568 integrity = t10_pi_type1_crc;
569 break;
570 default:
571 integrity = nvme_meta_noop;
572 break;
573 }
574 integrity.tuple_size = ns->ms;
575 blk_integrity_register(ns->disk, &integrity);
576 blk_queue_max_integrity_segments(ns->queue, 1);
577}
578#else /* CONFIG_BLK_DEV_INTEGRITY */
579static void nvme_dif_remap(struct request *req,
580 void (*dif_swap)(u32 p, u32 v, struct t10_pi_tuple *pi))
581{
582}
583static void nvme_dif_prep(u32 p, u32 v, struct t10_pi_tuple *pi)
584{
585}
586static void nvme_dif_complete(u32 p, u32 v, struct t10_pi_tuple *pi)
587{
588}
589static void nvme_init_integrity(struct nvme_ns *ns)
590{
591}
592#endif
593
541static void req_completion(struct nvme_queue *nvmeq, void *ctx, 594static void req_completion(struct nvme_queue *nvmeq, void *ctx,
542 struct nvme_completion *cqe) 595 struct nvme_completion *cqe)
543{ 596{
@@ -1959,43 +2012,6 @@ static void nvme_config_discard(struct nvme_ns *ns)
1959 queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, ns->queue); 2012 queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, ns->queue);
1960} 2013}
1961 2014
1962static int nvme_noop_verify(struct blk_integrity_iter *iter)
1963{
1964 return 0;
1965}
1966
1967static int nvme_noop_generate(struct blk_integrity_iter *iter)
1968{
1969 return 0;
1970}
1971
1972struct blk_integrity nvme_meta_noop = {
1973 .name = "NVME_META_NOOP",
1974 .generate_fn = nvme_noop_generate,
1975 .verify_fn = nvme_noop_verify,
1976};
1977
1978static void nvme_init_integrity(struct nvme_ns *ns)
1979{
1980 struct blk_integrity integrity;
1981
1982 switch (ns->pi_type) {
1983 case NVME_NS_DPS_PI_TYPE3:
1984 integrity = t10_pi_type3_crc;
1985 break;
1986 case NVME_NS_DPS_PI_TYPE1:
1987 case NVME_NS_DPS_PI_TYPE2:
1988 integrity = t10_pi_type1_crc;
1989 break;
1990 default:
1991 integrity = nvme_meta_noop;
1992 break;
1993 }
1994 integrity.tuple_size = ns->ms;
1995 blk_integrity_register(ns->disk, &integrity);
1996 blk_queue_max_integrity_segments(ns->queue, 1);
1997}
1998
1999static int nvme_revalidate_disk(struct gendisk *disk) 2015static int nvme_revalidate_disk(struct gendisk *disk)
2000{ 2016{
2001 struct nvme_ns *ns = disk->private_data; 2017 struct nvme_ns *ns = disk->private_data;
@@ -2036,7 +2052,8 @@ static int nvme_revalidate_disk(struct gendisk *disk)
2036 pi_type = ns->ms == sizeof(struct t10_pi_tuple) ? 2052 pi_type = ns->ms == sizeof(struct t10_pi_tuple) ?
2037 id->dps & NVME_NS_DPS_PI_MASK : 0; 2053 id->dps & NVME_NS_DPS_PI_MASK : 0;
2038 2054
2039 if (disk->integrity && (ns->pi_type != pi_type || ns->ms != old_ms || 2055 if (blk_get_integrity(disk) && (ns->pi_type != pi_type ||
2056 ns->ms != old_ms ||
2040 bs != queue_logical_block_size(disk->queue) || 2057 bs != queue_logical_block_size(disk->queue) ||
2041 (ns->ms && id->flbas & NVME_NS_FLBAS_META_EXT))) 2058 (ns->ms && id->flbas & NVME_NS_FLBAS_META_EXT)))
2042 blk_integrity_unregister(disk); 2059 blk_integrity_unregister(disk);
@@ -2044,11 +2061,11 @@ static int nvme_revalidate_disk(struct gendisk *disk)
2044 ns->pi_type = pi_type; 2061 ns->pi_type = pi_type;
2045 blk_queue_logical_block_size(ns->queue, bs); 2062 blk_queue_logical_block_size(ns->queue, bs);
2046 2063
2047 if (ns->ms && !disk->integrity && (disk->flags & GENHD_FL_UP) && 2064 if (ns->ms && !blk_get_integrity(disk) && (disk->flags & GENHD_FL_UP) &&
2048 !(id->flbas & NVME_NS_FLBAS_META_EXT)) 2065 !(id->flbas & NVME_NS_FLBAS_META_EXT))
2049 nvme_init_integrity(ns); 2066 nvme_init_integrity(ns);
2050 2067
2051 if (id->ncap == 0 || (ns->ms && !disk->integrity)) 2068 if (id->ncap == 0 || (ns->ms && !blk_get_integrity(disk)))
2052 set_capacity(disk, 0); 2069 set_capacity(disk, 0);
2053 else 2070 else
2054 set_capacity(disk, le64_to_cpup(&id->nsze) << (ns->lba_shift - 9)); 2071 set_capacity(disk, le64_to_cpup(&id->nsze) << (ns->lba_shift - 9));
@@ -2652,7 +2669,7 @@ static void nvme_dev_remove(struct nvme_dev *dev)
2652 2669
2653 list_for_each_entry(ns, &dev->namespaces, list) { 2670 list_for_each_entry(ns, &dev->namespaces, list) {
2654 if (ns->disk->flags & GENHD_FL_UP) { 2671 if (ns->disk->flags & GENHD_FL_UP) {
2655 if (ns->disk->integrity) 2672 if (blk_get_integrity(ns->disk))
2656 blk_integrity_unregister(ns->disk); 2673 blk_integrity_unregister(ns->disk);
2657 del_gendisk(ns->disk); 2674 del_gendisk(ns->disk);
2658 } 2675 }
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 8e233edd7a09..871bd3550cb0 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -528,7 +528,7 @@ out_cleanup:
528static inline void update_used_max(struct zram *zram, 528static inline void update_used_max(struct zram *zram,
529 const unsigned long pages) 529 const unsigned long pages)
530{ 530{
531 int old_max, cur_max; 531 unsigned long old_max, cur_max;
532 532
533 old_max = atomic_long_read(&zram->stats.max_used_pages); 533 old_max = atomic_long_read(&zram->stats.max_used_pages);
534 534
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 1c2506f68122..68161f7a07d6 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -63,6 +63,11 @@ config VT8500_TIMER
63config CADENCE_TTC_TIMER 63config CADENCE_TTC_TIMER
64 bool 64 bool
65 65
66config ASM9260_TIMER
67 bool
68 select CLKSRC_MMIO
69 select CLKSRC_OF
70
66config CLKSRC_NOMADIK_MTU 71config CLKSRC_NOMADIK_MTU
67 bool 72 bool
68 depends on (ARCH_NOMADIK || ARCH_U8500) 73 depends on (ARCH_NOMADIK || ARCH_U8500)
@@ -245,15 +250,4 @@ config CLKSRC_PXA
245 help 250 help
246 This enables OST0 support available on PXA and SA-11x0 251 This enables OST0 support available on PXA and SA-11x0
247 platforms. 252 platforms.
248
249config ASM9260_TIMER
250 bool "Alphascale ASM9260 timer driver"
251 depends on GENERIC_CLOCKEVENTS
252 select CLKSRC_MMIO
253 select CLKSRC_OF
254 default y if MACH_ASM9260
255 help
256 This enables build of a clocksource and clockevent driver for
257 the 32-bit System Timer hardware available on a Alphascale ASM9260.
258
259endmenu 253endmenu
diff --git a/drivers/clocksource/mtk_timer.c b/drivers/clocksource/mtk_timer.c
index 32a3d25795d3..68ab42356d0e 100644
--- a/drivers/clocksource/mtk_timer.c
+++ b/drivers/clocksource/mtk_timer.c
@@ -224,6 +224,8 @@ static void __init mtk_timer_init(struct device_node *node)
224 } 224 }
225 rate = clk_get_rate(clk); 225 rate = clk_get_rate(clk);
226 226
227 mtk_timer_global_reset(evt);
228
227 if (request_irq(evt->dev.irq, mtk_timer_interrupt, 229 if (request_irq(evt->dev.irq, mtk_timer_interrupt,
228 IRQF_TIMER | IRQF_IRQPOLL, "mtk_timer", evt)) { 230 IRQF_TIMER | IRQF_IRQPOLL, "mtk_timer", evt)) {
229 pr_warn("failed to setup irq %d\n", evt->dev.irq); 231 pr_warn("failed to setup irq %d\n", evt->dev.irq);
@@ -232,8 +234,6 @@ static void __init mtk_timer_init(struct device_node *node)
232 234
233 evt->ticks_per_jiffy = DIV_ROUND_UP(rate, HZ); 235 evt->ticks_per_jiffy = DIV_ROUND_UP(rate, HZ);
234 236
235 mtk_timer_global_reset(evt);
236
237 /* Configure clock source */ 237 /* Configure clock source */
238 mtk_timer_setup(evt, GPT_CLK_SRC, TIMER_CTRL_OP_FREERUN); 238 mtk_timer_setup(evt, GPT_CLK_SRC, TIMER_CTRL_OP_FREERUN);
239 clocksource_mmio_init(evt->gpt_base + TIMER_CNT_REG(GPT_CLK_SRC), 239 clocksource_mmio_init(evt->gpt_base + TIMER_CNT_REG(GPT_CLK_SRC),
@@ -241,10 +241,11 @@ static void __init mtk_timer_init(struct device_node *node)
241 241
242 /* Configure clock event */ 242 /* Configure clock event */
243 mtk_timer_setup(evt, GPT_CLK_EVT, TIMER_CTRL_OP_REPEAT); 243 mtk_timer_setup(evt, GPT_CLK_EVT, TIMER_CTRL_OP_REPEAT);
244 mtk_timer_enable_irq(evt, GPT_CLK_EVT);
245
246 clockevents_config_and_register(&evt->dev, rate, 0x3, 244 clockevents_config_and_register(&evt->dev, rate, 0x3,
247 0xffffffff); 245 0xffffffff);
246
247 mtk_timer_enable_irq(evt, GPT_CLK_EVT);
248
248 return; 249 return;
249 250
250err_clk_disable: 251err_clk_disable:
diff --git a/drivers/clocksource/pxa_timer.c b/drivers/clocksource/pxa_timer.c
index 941f3f344e08..d9438af2bbd6 100644
--- a/drivers/clocksource/pxa_timer.c
+++ b/drivers/clocksource/pxa_timer.c
@@ -163,7 +163,7 @@ static struct irqaction pxa_ost0_irq = {
163 .dev_id = &ckevt_pxa_osmr0, 163 .dev_id = &ckevt_pxa_osmr0,
164}; 164};
165 165
166static void pxa_timer_common_init(int irq, unsigned long clock_tick_rate) 166static void __init pxa_timer_common_init(int irq, unsigned long clock_tick_rate)
167{ 167{
168 timer_writel(0, OIER); 168 timer_writel(0, OIER);
169 timer_writel(OSSR_M0 | OSSR_M1 | OSSR_M2 | OSSR_M3, OSSR); 169 timer_writel(OSSR_M0 | OSSR_M1 | OSSR_M2 | OSSR_M3, OSSR);
diff --git a/drivers/gpio/gpio-tps65912.c b/drivers/gpio/gpio-tps65912.c
index 472fb5b8779f..9cdbc0c9cb2d 100644
--- a/drivers/gpio/gpio-tps65912.c
+++ b/drivers/gpio/gpio-tps65912.c
@@ -26,9 +26,12 @@ struct tps65912_gpio_data {
26 struct gpio_chip gpio_chip; 26 struct gpio_chip gpio_chip;
27}; 27};
28 28
29#define to_tgd(gc) container_of(gc, struct tps65912_gpio_data, gpio_chip)
30
29static int tps65912_gpio_get(struct gpio_chip *gc, unsigned offset) 31static int tps65912_gpio_get(struct gpio_chip *gc, unsigned offset)
30{ 32{
31 struct tps65912 *tps65912 = container_of(gc, struct tps65912, gpio); 33 struct tps65912_gpio_data *tps65912_gpio = to_tgd(gc);
34 struct tps65912 *tps65912 = tps65912_gpio->tps65912;
32 int val; 35 int val;
33 36
34 val = tps65912_reg_read(tps65912, TPS65912_GPIO1 + offset); 37 val = tps65912_reg_read(tps65912, TPS65912_GPIO1 + offset);
@@ -42,7 +45,8 @@ static int tps65912_gpio_get(struct gpio_chip *gc, unsigned offset)
42static void tps65912_gpio_set(struct gpio_chip *gc, unsigned offset, 45static void tps65912_gpio_set(struct gpio_chip *gc, unsigned offset,
43 int value) 46 int value)
44{ 47{
45 struct tps65912 *tps65912 = container_of(gc, struct tps65912, gpio); 48 struct tps65912_gpio_data *tps65912_gpio = to_tgd(gc);
49 struct tps65912 *tps65912 = tps65912_gpio->tps65912;
46 50
47 if (value) 51 if (value)
48 tps65912_set_bits(tps65912, TPS65912_GPIO1 + offset, 52 tps65912_set_bits(tps65912, TPS65912_GPIO1 + offset,
@@ -55,7 +59,8 @@ static void tps65912_gpio_set(struct gpio_chip *gc, unsigned offset,
55static int tps65912_gpio_output(struct gpio_chip *gc, unsigned offset, 59static int tps65912_gpio_output(struct gpio_chip *gc, unsigned offset,
56 int value) 60 int value)
57{ 61{
58 struct tps65912 *tps65912 = container_of(gc, struct tps65912, gpio); 62 struct tps65912_gpio_data *tps65912_gpio = to_tgd(gc);
63 struct tps65912 *tps65912 = tps65912_gpio->tps65912;
59 64
60 /* Set the initial value */ 65 /* Set the initial value */
61 tps65912_gpio_set(gc, offset, value); 66 tps65912_gpio_set(gc, offset, value);
@@ -66,7 +71,8 @@ static int tps65912_gpio_output(struct gpio_chip *gc, unsigned offset,
66 71
67static int tps65912_gpio_input(struct gpio_chip *gc, unsigned offset) 72static int tps65912_gpio_input(struct gpio_chip *gc, unsigned offset)
68{ 73{
69 struct tps65912 *tps65912 = container_of(gc, struct tps65912, gpio); 74 struct tps65912_gpio_data *tps65912_gpio = to_tgd(gc);
75 struct tps65912 *tps65912 = tps65912_gpio->tps65912;
70 76
71 return tps65912_clear_bits(tps65912, TPS65912_GPIO1 + offset, 77 return tps65912_clear_bits(tps65912, TPS65912_GPIO1 + offset,
72 GPIO_CFG_MASK); 78 GPIO_CFG_MASK);
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index 8cad8e400b44..4650bf830d6b 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -46,12 +46,13 @@ static int of_gpiochip_find_and_xlate(struct gpio_chip *gc, void *data)
46 46
47 ret = gc->of_xlate(gc, &gg_data->gpiospec, gg_data->flags); 47 ret = gc->of_xlate(gc, &gg_data->gpiospec, gg_data->flags);
48 if (ret < 0) { 48 if (ret < 0) {
49 /* We've found the gpio chip, but the translation failed. 49 /* We've found a gpio chip, but the translation failed.
50 * Return true to stop looking and return the translation 50 * Store translation error in out_gpio.
51 * error via out_gpio 51 * Return false to keep looking, as more than one gpio chip
52 * could be registered per of-node.
52 */ 53 */
53 gg_data->out_gpio = ERR_PTR(ret); 54 gg_data->out_gpio = ERR_PTR(ret);
54 return true; 55 return false;
55 } 56 }
56 57
57 gg_data->out_gpio = gpiochip_get_desc(gc, ret); 58 gg_data->out_gpio = gpiochip_get_desc(gc, ret);
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
index b3589d0e39b9..910ff8ab9c9c 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -62,12 +62,18 @@ enum KFD_MQD_TYPE get_mqd_type_from_queue_type(enum kfd_queue_type type)
62 return KFD_MQD_TYPE_CP; 62 return KFD_MQD_TYPE_CP;
63} 63}
64 64
65static inline unsigned int get_first_pipe(struct device_queue_manager *dqm) 65unsigned int get_first_pipe(struct device_queue_manager *dqm)
66{ 66{
67 BUG_ON(!dqm); 67 BUG_ON(!dqm || !dqm->dev);
68 return dqm->dev->shared_resources.first_compute_pipe; 68 return dqm->dev->shared_resources.first_compute_pipe;
69} 69}
70 70
71unsigned int get_pipes_num(struct device_queue_manager *dqm)
72{
73 BUG_ON(!dqm || !dqm->dev);
74 return dqm->dev->shared_resources.compute_pipe_count;
75}
76
71static inline unsigned int get_pipes_num_cpsch(void) 77static inline unsigned int get_pipes_num_cpsch(void)
72{ 78{
73 return PIPE_PER_ME_CP_SCHEDULING; 79 return PIPE_PER_ME_CP_SCHEDULING;
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h
index d64f86cda34f..488f51d19427 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h
@@ -163,6 +163,8 @@ void program_sh_mem_settings(struct device_queue_manager *dqm,
163 struct qcm_process_device *qpd); 163 struct qcm_process_device *qpd);
164int init_pipelines(struct device_queue_manager *dqm, 164int init_pipelines(struct device_queue_manager *dqm,
165 unsigned int pipes_num, unsigned int first_pipe); 165 unsigned int pipes_num, unsigned int first_pipe);
166unsigned int get_first_pipe(struct device_queue_manager *dqm);
167unsigned int get_pipes_num(struct device_queue_manager *dqm);
166 168
167extern inline unsigned int get_sh_mem_bases_32(struct kfd_process_device *pdd) 169extern inline unsigned int get_sh_mem_bases_32(struct kfd_process_device *pdd)
168{ 170{
@@ -175,10 +177,4 @@ get_sh_mem_bases_nybble_64(struct kfd_process_device *pdd)
175 return (pdd->lds_base >> 60) & 0x0E; 177 return (pdd->lds_base >> 60) & 0x0E;
176} 178}
177 179
178extern inline unsigned int get_pipes_num(struct device_queue_manager *dqm)
179{
180 BUG_ON(!dqm || !dqm->dev);
181 return dqm->dev->shared_resources.compute_pipe_count;
182}
183
184#endif /* KFD_DEVICE_QUEUE_MANAGER_H_ */ 180#endif /* KFD_DEVICE_QUEUE_MANAGER_H_ */
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_cik.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_cik.c
index 6b072466e2a6..5469efe0523e 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_cik.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_cik.c
@@ -131,5 +131,5 @@ static int register_process_cik(struct device_queue_manager *dqm,
131 131
132static int initialize_cpsch_cik(struct device_queue_manager *dqm) 132static int initialize_cpsch_cik(struct device_queue_manager *dqm)
133{ 133{
134 return init_pipelines(dqm, get_pipes_num(dqm), 0); 134 return init_pipelines(dqm, get_pipes_num(dqm), get_first_pipe(dqm));
135} 135}
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
index 0409b907de5d..b3e3068c6ec0 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
@@ -153,7 +153,7 @@ static int atmel_hlcdc_crtc_mode_set(struct drm_crtc *c,
153 (adj->crtc_hdisplay - 1) | 153 (adj->crtc_hdisplay - 1) |
154 ((adj->crtc_vdisplay - 1) << 16)); 154 ((adj->crtc_vdisplay - 1) << 16));
155 155
156 cfg = ATMEL_HLCDC_CLKPOL; 156 cfg = 0;
157 157
158 prate = clk_get_rate(crtc->dc->hlcdc->sys_clk); 158 prate = clk_get_rate(crtc->dc->hlcdc->sys_clk);
159 mode_rate = mode->crtc_clock * 1000; 159 mode_rate = mode->crtc_clock * 1000;
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
index 7320a6c6613f..c1cb17493e0d 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
@@ -311,8 +311,6 @@ static int atmel_hlcdc_dc_load(struct drm_device *dev)
311 311
312 pm_runtime_enable(dev->dev); 312 pm_runtime_enable(dev->dev);
313 313
314 pm_runtime_put_sync(dev->dev);
315
316 ret = atmel_hlcdc_dc_modeset_init(dev); 314 ret = atmel_hlcdc_dc_modeset_init(dev);
317 if (ret < 0) { 315 if (ret < 0) {
318 dev_err(dev->dev, "failed to initialize mode setting\n"); 316 dev_err(dev->dev, "failed to initialize mode setting\n");
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_layer.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_layer.c
index 063d2a7b941f..e79bd9ba474b 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_layer.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_layer.c
@@ -311,7 +311,8 @@ int atmel_hlcdc_layer_disable(struct atmel_hlcdc_layer *layer)
311 311
312 /* Disable the layer */ 312 /* Disable the layer */
313 regmap_write(regmap, desc->regs_offset + ATMEL_HLCDC_LAYER_CHDR, 313 regmap_write(regmap, desc->regs_offset + ATMEL_HLCDC_LAYER_CHDR,
314 ATMEL_HLCDC_LAYER_RST); 314 ATMEL_HLCDC_LAYER_RST | ATMEL_HLCDC_LAYER_A2Q |
315 ATMEL_HLCDC_LAYER_UPDATE);
315 316
316 /* Clear all pending interrupts */ 317 /* Clear all pending interrupts */
317 regmap_read(regmap, desc->regs_offset + ATMEL_HLCDC_LAYER_ISR, &isr); 318 regmap_read(regmap, desc->regs_offset + ATMEL_HLCDC_LAYER_ISR, &isr);
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 6b00173d1be4..6b6b07ff720b 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -2127,7 +2127,6 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
2127 DRM_DEBUG_KMS("[CONNECTOR:%d:?]\n", out_resp->connector_id); 2127 DRM_DEBUG_KMS("[CONNECTOR:%d:?]\n", out_resp->connector_id);
2128 2128
2129 mutex_lock(&dev->mode_config.mutex); 2129 mutex_lock(&dev->mode_config.mutex);
2130 drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
2131 2130
2132 connector = drm_connector_find(dev, out_resp->connector_id); 2131 connector = drm_connector_find(dev, out_resp->connector_id);
2133 if (!connector) { 2132 if (!connector) {
@@ -2157,6 +2156,8 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,
2157 out_resp->mm_height = connector->display_info.height_mm; 2156 out_resp->mm_height = connector->display_info.height_mm;
2158 out_resp->subpixel = connector->display_info.subpixel_order; 2157 out_resp->subpixel = connector->display_info.subpixel_order;
2159 out_resp->connection = connector->status; 2158 out_resp->connection = connector->status;
2159
2160 drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
2160 encoder = drm_connector_get_encoder(connector); 2161 encoder = drm_connector_get_encoder(connector);
2161 if (encoder) 2162 if (encoder)
2162 out_resp->encoder_id = encoder->base.id; 2163 out_resp->encoder_id = encoder->base.id;
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index f2a825e39646..8727086cf48c 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2114,6 +2114,9 @@ void i915_gem_track_fb(struct drm_i915_gem_object *old,
2114 * number comparisons on buffer last_read|write_seqno. It also allows an 2114 * number comparisons on buffer last_read|write_seqno. It also allows an
2115 * emission time to be associated with the request for tracking how far ahead 2115 * emission time to be associated with the request for tracking how far ahead
2116 * of the GPU the submission is. 2116 * of the GPU the submission is.
2117 *
2118 * The requests are reference counted, so upon creation they should have an
2119 * initial reference taken using kref_init
2117 */ 2120 */
2118struct drm_i915_gem_request { 2121struct drm_i915_gem_request {
2119 struct kref ref; 2122 struct kref ref;
@@ -2137,7 +2140,16 @@ struct drm_i915_gem_request {
2137 /** Position in the ringbuffer of the end of the whole request */ 2140 /** Position in the ringbuffer of the end of the whole request */
2138 u32 tail; 2141 u32 tail;
2139 2142
2140 /** Context related to this request */ 2143 /**
2144 * Context related to this request
2145 * Contexts are refcounted, so when this request is associated with a
2146 * context, we must increment the context's refcount, to guarantee that
2147 * it persists while any request is linked to it. Requests themselves
2148 * are also refcounted, so the request will only be freed when the last
2149 * reference to it is dismissed, and the code in
2150 * i915_gem_request_free() will then decrement the refcount on the
2151 * context.
2152 */
2141 struct intel_context *ctx; 2153 struct intel_context *ctx;
2142 2154
2143 /** Batch buffer related to this request if any */ 2155 /** Batch buffer related to this request if any */
@@ -2374,6 +2386,7 @@ struct drm_i915_cmd_table {
2374 (INTEL_DEVID(dev) & 0xFF00) == 0x0C00) 2386 (INTEL_DEVID(dev) & 0xFF00) == 0x0C00)
2375#define IS_BDW_ULT(dev) (IS_BROADWELL(dev) && \ 2387#define IS_BDW_ULT(dev) (IS_BROADWELL(dev) && \
2376 ((INTEL_DEVID(dev) & 0xf) == 0x6 || \ 2388 ((INTEL_DEVID(dev) & 0xf) == 0x6 || \
2389 (INTEL_DEVID(dev) & 0xf) == 0xb || \
2377 (INTEL_DEVID(dev) & 0xf) == 0xe)) 2390 (INTEL_DEVID(dev) & 0xf) == 0xe))
2378#define IS_BDW_GT3(dev) (IS_BROADWELL(dev) && \ 2391#define IS_BDW_GT3(dev) (IS_BROADWELL(dev) && \
2379 (INTEL_DEVID(dev) & 0x00F0) == 0x0020) 2392 (INTEL_DEVID(dev) & 0x00F0) == 0x0020)
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index c26d36cc4b31..e5daad5f75fb 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2659,8 +2659,7 @@ static void i915_gem_reset_ring_cleanup(struct drm_i915_private *dev_priv,
2659 if (submit_req->ctx != ring->default_context) 2659 if (submit_req->ctx != ring->default_context)
2660 intel_lr_context_unpin(ring, submit_req->ctx); 2660 intel_lr_context_unpin(ring, submit_req->ctx);
2661 2661
2662 i915_gem_context_unreference(submit_req->ctx); 2662 i915_gem_request_unreference(submit_req);
2663 kfree(submit_req);
2664 } 2663 }
2665 2664
2666 /* 2665 /*
diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c
index a2045848bd1a..9c6f93ec886b 100644
--- a/drivers/gpu/drm/i915/i915_gem_stolen.c
+++ b/drivers/gpu/drm/i915/i915_gem_stolen.c
@@ -485,10 +485,8 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,
485 stolen_offset, gtt_offset, size); 485 stolen_offset, gtt_offset, size);
486 486
487 /* KISS and expect everything to be page-aligned */ 487 /* KISS and expect everything to be page-aligned */
488 BUG_ON(stolen_offset & 4095); 488 if (WARN_ON(size == 0) || WARN_ON(size & 4095) ||
489 BUG_ON(size & 4095); 489 WARN_ON(stolen_offset & 4095))
490
491 if (WARN_ON(size == 0))
492 return NULL; 490 return NULL;
493 491
494 stolen = kzalloc(sizeof(*stolen), GFP_KERNEL); 492 stolen = kzalloc(sizeof(*stolen), GFP_KERNEL);
diff --git a/drivers/gpu/drm/i915/i915_gem_tiling.c b/drivers/gpu/drm/i915/i915_gem_tiling.c
index 7a24bd1a51f6..6377b22269ad 100644
--- a/drivers/gpu/drm/i915/i915_gem_tiling.c
+++ b/drivers/gpu/drm/i915/i915_gem_tiling.c
@@ -335,9 +335,10 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,
335 return -EINVAL; 335 return -EINVAL;
336 } 336 }
337 337
338 mutex_lock(&dev->struct_mutex);
338 if (i915_gem_obj_is_pinned(obj) || obj->framebuffer_references) { 339 if (i915_gem_obj_is_pinned(obj) || obj->framebuffer_references) {
339 drm_gem_object_unreference_unlocked(&obj->base); 340 ret = -EBUSY;
340 return -EBUSY; 341 goto err;
341 } 342 }
342 343
343 if (args->tiling_mode == I915_TILING_NONE) { 344 if (args->tiling_mode == I915_TILING_NONE) {
@@ -369,7 +370,6 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,
369 } 370 }
370 } 371 }
371 372
372 mutex_lock(&dev->struct_mutex);
373 if (args->tiling_mode != obj->tiling_mode || 373 if (args->tiling_mode != obj->tiling_mode ||
374 args->stride != obj->stride) { 374 args->stride != obj->stride) {
375 /* We need to rebind the object if its current allocation 375 /* We need to rebind the object if its current allocation
@@ -424,6 +424,7 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,
424 obj->bit_17 = NULL; 424 obj->bit_17 = NULL;
425 } 425 }
426 426
427err:
427 drm_gem_object_unreference(&obj->base); 428 drm_gem_object_unreference(&obj->base);
428 mutex_unlock(&dev->struct_mutex); 429 mutex_unlock(&dev->struct_mutex);
429 430
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 4145d95902f5..ede5bbbd8a08 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1892,6 +1892,9 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
1892 u32 iir, gt_iir, pm_iir; 1892 u32 iir, gt_iir, pm_iir;
1893 irqreturn_t ret = IRQ_NONE; 1893 irqreturn_t ret = IRQ_NONE;
1894 1894
1895 if (!intel_irqs_enabled(dev_priv))
1896 return IRQ_NONE;
1897
1895 while (true) { 1898 while (true) {
1896 /* Find, clear, then process each source of interrupt */ 1899 /* Find, clear, then process each source of interrupt */
1897 1900
@@ -1936,6 +1939,9 @@ static irqreturn_t cherryview_irq_handler(int irq, void *arg)
1936 u32 master_ctl, iir; 1939 u32 master_ctl, iir;
1937 irqreturn_t ret = IRQ_NONE; 1940 irqreturn_t ret = IRQ_NONE;
1938 1941
1942 if (!intel_irqs_enabled(dev_priv))
1943 return IRQ_NONE;
1944
1939 for (;;) { 1945 for (;;) {
1940 master_ctl = I915_READ(GEN8_MASTER_IRQ) & ~GEN8_MASTER_IRQ_CONTROL; 1946 master_ctl = I915_READ(GEN8_MASTER_IRQ) & ~GEN8_MASTER_IRQ_CONTROL;
1941 iir = I915_READ(VLV_IIR); 1947 iir = I915_READ(VLV_IIR);
@@ -2208,6 +2214,9 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
2208 u32 de_iir, gt_iir, de_ier, sde_ier = 0; 2214 u32 de_iir, gt_iir, de_ier, sde_ier = 0;
2209 irqreturn_t ret = IRQ_NONE; 2215 irqreturn_t ret = IRQ_NONE;
2210 2216
2217 if (!intel_irqs_enabled(dev_priv))
2218 return IRQ_NONE;
2219
2211 /* We get interrupts on unclaimed registers, so check for this before we 2220 /* We get interrupts on unclaimed registers, so check for this before we
2212 * do any I915_{READ,WRITE}. */ 2221 * do any I915_{READ,WRITE}. */
2213 intel_uncore_check_errors(dev); 2222 intel_uncore_check_errors(dev);
@@ -2279,6 +2288,9 @@ static irqreturn_t gen8_irq_handler(int irq, void *arg)
2279 enum pipe pipe; 2288 enum pipe pipe;
2280 u32 aux_mask = GEN8_AUX_CHANNEL_A; 2289 u32 aux_mask = GEN8_AUX_CHANNEL_A;
2281 2290
2291 if (!intel_irqs_enabled(dev_priv))
2292 return IRQ_NONE;
2293
2282 if (IS_GEN9(dev)) 2294 if (IS_GEN9(dev))
2283 aux_mask |= GEN9_AUX_CHANNEL_B | GEN9_AUX_CHANNEL_C | 2295 aux_mask |= GEN9_AUX_CHANNEL_B | GEN9_AUX_CHANNEL_C |
2284 GEN9_AUX_CHANNEL_D; 2296 GEN9_AUX_CHANNEL_D;
@@ -3771,6 +3783,9 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
3771 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT | 3783 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
3772 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT; 3784 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
3773 3785
3786 if (!intel_irqs_enabled(dev_priv))
3787 return IRQ_NONE;
3788
3774 iir = I915_READ16(IIR); 3789 iir = I915_READ16(IIR);
3775 if (iir == 0) 3790 if (iir == 0)
3776 return IRQ_NONE; 3791 return IRQ_NONE;
@@ -3951,6 +3966,9 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
3951 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT; 3966 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
3952 int pipe, ret = IRQ_NONE; 3967 int pipe, ret = IRQ_NONE;
3953 3968
3969 if (!intel_irqs_enabled(dev_priv))
3970 return IRQ_NONE;
3971
3954 iir = I915_READ(IIR); 3972 iir = I915_READ(IIR);
3955 do { 3973 do {
3956 bool irq_received = (iir & ~flip_mask) != 0; 3974 bool irq_received = (iir & ~flip_mask) != 0;
@@ -4171,6 +4189,9 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
4171 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT | 4189 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
4172 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT; 4190 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
4173 4191
4192 if (!intel_irqs_enabled(dev_priv))
4193 return IRQ_NONE;
4194
4174 iir = I915_READ(IIR); 4195 iir = I915_READ(IIR);
4175 4196
4176 for (;;) { 4197 for (;;) {
@@ -4520,6 +4541,7 @@ void intel_runtime_pm_disable_interrupts(struct drm_i915_private *dev_priv)
4520{ 4541{
4521 dev_priv->dev->driver->irq_uninstall(dev_priv->dev); 4542 dev_priv->dev->driver->irq_uninstall(dev_priv->dev);
4522 dev_priv->pm.irqs_enabled = false; 4543 dev_priv->pm.irqs_enabled = false;
4544 synchronize_irq(dev_priv->dev->irq);
4523} 4545}
4524 4546
4525/** 4547/**
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 3d220a67f865..e730789b53b7 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2371,13 +2371,19 @@ intel_alloc_plane_obj(struct intel_crtc *crtc,
2371 struct drm_device *dev = crtc->base.dev; 2371 struct drm_device *dev = crtc->base.dev;
2372 struct drm_i915_gem_object *obj = NULL; 2372 struct drm_i915_gem_object *obj = NULL;
2373 struct drm_mode_fb_cmd2 mode_cmd = { 0 }; 2373 struct drm_mode_fb_cmd2 mode_cmd = { 0 };
2374 u32 base = plane_config->base; 2374 u32 base_aligned = round_down(plane_config->base, PAGE_SIZE);
2375 u32 size_aligned = round_up(plane_config->base + plane_config->size,
2376 PAGE_SIZE);
2377
2378 size_aligned -= base_aligned;
2375 2379
2376 if (plane_config->size == 0) 2380 if (plane_config->size == 0)
2377 return false; 2381 return false;
2378 2382
2379 obj = i915_gem_object_create_stolen_for_preallocated(dev, base, base, 2383 obj = i915_gem_object_create_stolen_for_preallocated(dev,
2380 plane_config->size); 2384 base_aligned,
2385 base_aligned,
2386 size_aligned);
2381 if (!obj) 2387 if (!obj)
2382 return false; 2388 return false;
2383 2389
@@ -2725,10 +2731,19 @@ static void skylake_update_primary_plane(struct drm_crtc *crtc,
2725 case DRM_FORMAT_XRGB8888: 2731 case DRM_FORMAT_XRGB8888:
2726 plane_ctl |= PLANE_CTL_FORMAT_XRGB_8888; 2732 plane_ctl |= PLANE_CTL_FORMAT_XRGB_8888;
2727 break; 2733 break;
2734 case DRM_FORMAT_ARGB8888:
2735 plane_ctl |= PLANE_CTL_FORMAT_XRGB_8888;
2736 plane_ctl |= PLANE_CTL_ALPHA_SW_PREMULTIPLY;
2737 break;
2728 case DRM_FORMAT_XBGR8888: 2738 case DRM_FORMAT_XBGR8888:
2729 plane_ctl |= PLANE_CTL_ORDER_RGBX; 2739 plane_ctl |= PLANE_CTL_ORDER_RGBX;
2730 plane_ctl |= PLANE_CTL_FORMAT_XRGB_8888; 2740 plane_ctl |= PLANE_CTL_FORMAT_XRGB_8888;
2731 break; 2741 break;
2742 case DRM_FORMAT_ABGR8888:
2743 plane_ctl |= PLANE_CTL_ORDER_RGBX;
2744 plane_ctl |= PLANE_CTL_FORMAT_XRGB_8888;
2745 plane_ctl |= PLANE_CTL_ALPHA_SW_PREMULTIPLY;
2746 break;
2732 case DRM_FORMAT_XRGB2101010: 2747 case DRM_FORMAT_XRGB2101010:
2733 plane_ctl |= PLANE_CTL_FORMAT_XRGB_2101010; 2748 plane_ctl |= PLANE_CTL_FORMAT_XRGB_2101010;
2734 break; 2749 break;
@@ -6627,7 +6642,7 @@ i9xx_get_initial_plane_config(struct intel_crtc *crtc,
6627 aligned_height = intel_fb_align_height(dev, fb->height, 6642 aligned_height = intel_fb_align_height(dev, fb->height,
6628 plane_config->tiling); 6643 plane_config->tiling);
6629 6644
6630 plane_config->size = PAGE_ALIGN(fb->pitches[0] * aligned_height); 6645 plane_config->size = fb->pitches[0] * aligned_height;
6631 6646
6632 DRM_DEBUG_KMS("pipe/plane %c/%d with fb: size=%dx%d@%d, offset=%x, pitch %d, size 0x%x\n", 6647 DRM_DEBUG_KMS("pipe/plane %c/%d with fb: size=%dx%d@%d, offset=%x, pitch %d, size 0x%x\n",
6633 pipe_name(pipe), plane, fb->width, fb->height, 6648 pipe_name(pipe), plane, fb->width, fb->height,
@@ -7664,7 +7679,7 @@ skylake_get_initial_plane_config(struct intel_crtc *crtc,
7664 aligned_height = intel_fb_align_height(dev, fb->height, 7679 aligned_height = intel_fb_align_height(dev, fb->height,
7665 plane_config->tiling); 7680 plane_config->tiling);
7666 7681
7667 plane_config->size = ALIGN(fb->pitches[0] * aligned_height, PAGE_SIZE); 7682 plane_config->size = fb->pitches[0] * aligned_height;
7668 7683
7669 DRM_DEBUG_KMS("pipe %c with fb: size=%dx%d@%d, offset=%x, pitch %d, size 0x%x\n", 7684 DRM_DEBUG_KMS("pipe %c with fb: size=%dx%d@%d, offset=%x, pitch %d, size 0x%x\n",
7670 pipe_name(pipe), fb->width, fb->height, 7685 pipe_name(pipe), fb->width, fb->height,
@@ -7755,7 +7770,7 @@ ironlake_get_initial_plane_config(struct intel_crtc *crtc,
7755 aligned_height = intel_fb_align_height(dev, fb->height, 7770 aligned_height = intel_fb_align_height(dev, fb->height,
7756 plane_config->tiling); 7771 plane_config->tiling);
7757 7772
7758 plane_config->size = PAGE_ALIGN(fb->pitches[0] * aligned_height); 7773 plane_config->size = fb->pitches[0] * aligned_height;
7759 7774
7760 DRM_DEBUG_KMS("pipe %c with fb: size=%dx%d@%d, offset=%x, pitch %d, size 0x%x\n", 7775 DRM_DEBUG_KMS("pipe %c with fb: size=%dx%d@%d, offset=%x, pitch %d, size 0x%x\n",
7761 pipe_name(pipe), fb->width, fb->height, 7776 pipe_name(pipe), fb->width, fb->height,
@@ -8698,6 +8713,7 @@ retry:
8698 old->release_fb->funcs->destroy(old->release_fb); 8713 old->release_fb->funcs->destroy(old->release_fb);
8699 goto fail; 8714 goto fail;
8700 } 8715 }
8716 crtc->primary->crtc = crtc;
8701 8717
8702 /* let the connector get through one full cycle before testing */ 8718 /* let the connector get through one full cycle before testing */
8703 intel_wait_for_vblank(dev, intel_crtc->pipe); 8719 intel_wait_for_vblank(dev, intel_crtc->pipe);
@@ -12182,9 +12198,6 @@ intel_check_cursor_plane(struct drm_plane *plane,
12182 return -ENOMEM; 12198 return -ENOMEM;
12183 } 12199 }
12184 12200
12185 if (fb == crtc->cursor->fb)
12186 return 0;
12187
12188 /* we only need to pin inside GTT if cursor is non-phy */ 12201 /* we only need to pin inside GTT if cursor is non-phy */
12189 mutex_lock(&dev->struct_mutex); 12202 mutex_lock(&dev->struct_mutex);
12190 if (!INTEL_INFO(dev)->cursor_needs_physical && obj->tiling_mode) { 12203 if (!INTEL_INFO(dev)->cursor_needs_physical && obj->tiling_mode) {
@@ -13096,6 +13109,9 @@ static struct intel_quirk intel_quirks[] = {
13096 13109
13097 /* HP Chromebook 14 (Celeron 2955U) */ 13110 /* HP Chromebook 14 (Celeron 2955U) */
13098 { 0x0a06, 0x103c, 0x21ed, quirk_backlight_present }, 13111 { 0x0a06, 0x103c, 0x21ed, quirk_backlight_present },
13112
13113 /* Dell Chromebook 11 */
13114 { 0x0a06, 0x1028, 0x0a35, quirk_backlight_present },
13099}; 13115};
13100 13116
13101static void intel_init_quirks(struct drm_device *dev) 13117static void intel_init_quirks(struct drm_device *dev)
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 0f358c5999ec..e8d3da9f3373 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -503,18 +503,19 @@ static int execlists_context_queue(struct intel_engine_cs *ring,
503 * If there isn't a request associated with this submission, 503 * If there isn't a request associated with this submission,
504 * create one as a temporary holder. 504 * create one as a temporary holder.
505 */ 505 */
506 WARN(1, "execlist context submission without request");
507 request = kzalloc(sizeof(*request), GFP_KERNEL); 506 request = kzalloc(sizeof(*request), GFP_KERNEL);
508 if (request == NULL) 507 if (request == NULL)
509 return -ENOMEM; 508 return -ENOMEM;
510 request->ring = ring; 509 request->ring = ring;
511 request->ctx = to; 510 request->ctx = to;
511 kref_init(&request->ref);
512 request->uniq = dev_priv->request_uniq++;
513 i915_gem_context_reference(request->ctx);
512 } else { 514 } else {
515 i915_gem_request_reference(request);
513 WARN_ON(to != request->ctx); 516 WARN_ON(to != request->ctx);
514 } 517 }
515 request->tail = tail; 518 request->tail = tail;
516 i915_gem_request_reference(request);
517 i915_gem_context_reference(request->ctx);
518 519
519 intel_runtime_pm_get(dev_priv); 520 intel_runtime_pm_get(dev_priv);
520 521
@@ -731,7 +732,6 @@ void intel_execlists_retire_requests(struct intel_engine_cs *ring)
731 if (ctx_obj && (ctx != ring->default_context)) 732 if (ctx_obj && (ctx != ring->default_context))
732 intel_lr_context_unpin(ring, ctx); 733 intel_lr_context_unpin(ring, ctx);
733 intel_runtime_pm_put(dev_priv); 734 intel_runtime_pm_put(dev_priv);
734 i915_gem_context_unreference(ctx);
735 list_del(&req->execlist_link); 735 list_del(&req->execlist_link);
736 i915_gem_request_unreference(req); 736 i915_gem_request_unreference(req);
737 } 737 }
diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c
index 5bf825dfaa09..8d74de82456e 100644
--- a/drivers/gpu/drm/radeon/atombios_dp.c
+++ b/drivers/gpu/drm/radeon/atombios_dp.c
@@ -178,6 +178,13 @@ radeon_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg)
178 switch (msg->request & ~DP_AUX_I2C_MOT) { 178 switch (msg->request & ~DP_AUX_I2C_MOT) {
179 case DP_AUX_NATIVE_WRITE: 179 case DP_AUX_NATIVE_WRITE:
180 case DP_AUX_I2C_WRITE: 180 case DP_AUX_I2C_WRITE:
181 /* The atom implementation only supports writes with a max payload of
182 * 12 bytes since it uses 4 bits for the total count (header + payload)
183 * in the parameter space. The atom interface supports 16 byte
184 * payloads for reads. The hw itself supports up to 16 bytes of payload.
185 */
186 if (WARN_ON_ONCE(msg->size > 12))
187 return -E2BIG;
181 /* tx_size needs to be 4 even for bare address packets since the atom 188 /* tx_size needs to be 4 even for bare address packets since the atom
182 * table needs the info in tx_buf[3]. 189 * table needs the info in tx_buf[3].
183 */ 190 */
diff --git a/drivers/gpu/drm/radeon/atombios_encoders.c b/drivers/gpu/drm/radeon/atombios_encoders.c
index 7c9df1eac065..7fe7b749e182 100644
--- a/drivers/gpu/drm/radeon/atombios_encoders.c
+++ b/drivers/gpu/drm/radeon/atombios_encoders.c
@@ -731,7 +731,9 @@ atombios_get_encoder_mode(struct drm_encoder *encoder)
731 dig_connector = radeon_connector->con_priv; 731 dig_connector = radeon_connector->con_priv;
732 if ((dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) || 732 if ((dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) ||
733 (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP)) { 733 (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_eDP)) {
734 if (radeon_audio != 0 && ASIC_IS_DCE4(rdev) && !ASIC_IS_DCE5(rdev)) 734 if (radeon_audio != 0 &&
735 drm_detect_monitor_audio(radeon_connector_edid(connector)) &&
736 ASIC_IS_DCE4(rdev) && !ASIC_IS_DCE5(rdev))
735 return ATOM_ENCODER_MODE_DP_AUDIO; 737 return ATOM_ENCODER_MODE_DP_AUDIO;
736 return ATOM_ENCODER_MODE_DP; 738 return ATOM_ENCODER_MODE_DP;
737 } else if (radeon_audio != 0) { 739 } else if (radeon_audio != 0) {
@@ -747,7 +749,9 @@ atombios_get_encoder_mode(struct drm_encoder *encoder)
747 } 749 }
748 break; 750 break;
749 case DRM_MODE_CONNECTOR_eDP: 751 case DRM_MODE_CONNECTOR_eDP:
750 if (radeon_audio != 0 && ASIC_IS_DCE4(rdev) && !ASIC_IS_DCE5(rdev)) 752 if (radeon_audio != 0 &&
753 drm_detect_monitor_audio(radeon_connector_edid(connector)) &&
754 ASIC_IS_DCE4(rdev) && !ASIC_IS_DCE5(rdev))
751 return ATOM_ENCODER_MODE_DP_AUDIO; 755 return ATOM_ENCODER_MODE_DP_AUDIO;
752 return ATOM_ENCODER_MODE_DP; 756 return ATOM_ENCODER_MODE_DP;
753 case DRM_MODE_CONNECTOR_DVIA: 757 case DRM_MODE_CONNECTOR_DVIA:
@@ -1720,8 +1724,10 @@ radeon_atom_encoder_dpms_dig(struct drm_encoder *encoder, int mode)
1720 } 1724 }
1721 1725
1722 encoder_mode = atombios_get_encoder_mode(encoder); 1726 encoder_mode = atombios_get_encoder_mode(encoder);
1723 if (radeon_audio != 0 && 1727 if (connector && (radeon_audio != 0) &&
1724 (encoder_mode == ATOM_ENCODER_MODE_HDMI || ENCODER_MODE_IS_DP(encoder_mode))) 1728 ((encoder_mode == ATOM_ENCODER_MODE_HDMI) ||
1729 (ENCODER_MODE_IS_DP(encoder_mode) &&
1730 drm_detect_monitor_audio(radeon_connector_edid(connector)))))
1725 radeon_audio_dpms(encoder, mode); 1731 radeon_audio_dpms(encoder, mode);
1726} 1732}
1727 1733
@@ -2136,6 +2142,7 @@ radeon_atom_encoder_mode_set(struct drm_encoder *encoder,
2136 struct drm_device *dev = encoder->dev; 2142 struct drm_device *dev = encoder->dev;
2137 struct radeon_device *rdev = dev->dev_private; 2143 struct radeon_device *rdev = dev->dev_private;
2138 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 2144 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
2145 struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
2139 int encoder_mode; 2146 int encoder_mode;
2140 2147
2141 radeon_encoder->pixel_clock = adjusted_mode->clock; 2148 radeon_encoder->pixel_clock = adjusted_mode->clock;
@@ -2164,8 +2171,10 @@ radeon_atom_encoder_mode_set(struct drm_encoder *encoder,
2164 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA: 2171 case ENCODER_OBJECT_ID_INTERNAL_KLDSCP_LVTMA:
2165 /* handled in dpms */ 2172 /* handled in dpms */
2166 encoder_mode = atombios_get_encoder_mode(encoder); 2173 encoder_mode = atombios_get_encoder_mode(encoder);
2167 if (radeon_audio != 0 && 2174 if (connector && (radeon_audio != 0) &&
2168 (encoder_mode == ATOM_ENCODER_MODE_HDMI || ENCODER_MODE_IS_DP(encoder_mode))) 2175 ((encoder_mode == ATOM_ENCODER_MODE_HDMI) ||
2176 (ENCODER_MODE_IS_DP(encoder_mode) &&
2177 drm_detect_monitor_audio(radeon_connector_edid(connector)))))
2169 radeon_audio_mode_set(encoder, adjusted_mode); 2178 radeon_audio_mode_set(encoder, adjusted_mode);
2170 break; 2179 break;
2171 case ENCODER_OBJECT_ID_INTERNAL_DDI: 2180 case ENCODER_OBJECT_ID_INTERNAL_DDI:
diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c
index e6a4ba236c70..0c993da9c8fb 100644
--- a/drivers/gpu/drm/radeon/cik.c
+++ b/drivers/gpu/drm/radeon/cik.c
@@ -3613,6 +3613,8 @@ static void cik_gpu_init(struct radeon_device *rdev)
3613 } 3613 }
3614 3614
3615 WREG32(GRBM_CNTL, GRBM_READ_TIMEOUT(0xff)); 3615 WREG32(GRBM_CNTL, GRBM_READ_TIMEOUT(0xff));
3616 WREG32(SRBM_INT_CNTL, 0x1);
3617 WREG32(SRBM_INT_ACK, 0x1);
3616 3618
3617 WREG32(BIF_FB_EN, FB_READ_EN | FB_WRITE_EN); 3619 WREG32(BIF_FB_EN, FB_READ_EN | FB_WRITE_EN);
3618 3620
@@ -7230,6 +7232,8 @@ static void cik_disable_interrupt_state(struct radeon_device *rdev)
7230 WREG32(CP_ME2_PIPE3_INT_CNTL, 0); 7232 WREG32(CP_ME2_PIPE3_INT_CNTL, 0);
7231 /* grbm */ 7233 /* grbm */
7232 WREG32(GRBM_INT_CNTL, 0); 7234 WREG32(GRBM_INT_CNTL, 0);
7235 /* SRBM */
7236 WREG32(SRBM_INT_CNTL, 0);
7233 /* vline/vblank, etc. */ 7237 /* vline/vblank, etc. */
7234 WREG32(LB_INTERRUPT_MASK + EVERGREEN_CRTC0_REGISTER_OFFSET, 0); 7238 WREG32(LB_INTERRUPT_MASK + EVERGREEN_CRTC0_REGISTER_OFFSET, 0);
7235 WREG32(LB_INTERRUPT_MASK + EVERGREEN_CRTC1_REGISTER_OFFSET, 0); 7239 WREG32(LB_INTERRUPT_MASK + EVERGREEN_CRTC1_REGISTER_OFFSET, 0);
@@ -8046,6 +8050,10 @@ restart_ih:
8046 break; 8050 break;
8047 } 8051 }
8048 break; 8052 break;
8053 case 96:
8054 DRM_ERROR("SRBM_READ_ERROR: 0x%x\n", RREG32(SRBM_READ_ERROR));
8055 WREG32(SRBM_INT_ACK, 0x1);
8056 break;
8049 case 124: /* UVD */ 8057 case 124: /* UVD */
8050 DRM_DEBUG("IH: UVD int: 0x%08x\n", src_data); 8058 DRM_DEBUG("IH: UVD int: 0x%08x\n", src_data);
8051 radeon_fence_process(rdev, R600_RING_TYPE_UVD_INDEX); 8059 radeon_fence_process(rdev, R600_RING_TYPE_UVD_INDEX);
diff --git a/drivers/gpu/drm/radeon/cikd.h b/drivers/gpu/drm/radeon/cikd.h
index 03003f8a6de6..c648e1996dab 100644
--- a/drivers/gpu/drm/radeon/cikd.h
+++ b/drivers/gpu/drm/radeon/cikd.h
@@ -482,6 +482,10 @@
482#define SOFT_RESET_ORB (1 << 23) 482#define SOFT_RESET_ORB (1 << 23)
483#define SOFT_RESET_VCE (1 << 24) 483#define SOFT_RESET_VCE (1 << 24)
484 484
485#define SRBM_READ_ERROR 0xE98
486#define SRBM_INT_CNTL 0xEA0
487#define SRBM_INT_ACK 0xEA8
488
485#define VM_L2_CNTL 0x1400 489#define VM_L2_CNTL 0x1400
486#define ENABLE_L2_CACHE (1 << 0) 490#define ENABLE_L2_CACHE (1 << 0)
487#define ENABLE_L2_FRAGMENT_PROCESSING (1 << 1) 491#define ENABLE_L2_FRAGMENT_PROCESSING (1 << 1)
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index 78600f534c80..4c0e24b3bb90 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -3253,6 +3253,8 @@ static void evergreen_gpu_init(struct radeon_device *rdev)
3253 } 3253 }
3254 3254
3255 WREG32(GRBM_CNTL, GRBM_READ_TIMEOUT(0xff)); 3255 WREG32(GRBM_CNTL, GRBM_READ_TIMEOUT(0xff));
3256 WREG32(SRBM_INT_CNTL, 0x1);
3257 WREG32(SRBM_INT_ACK, 0x1);
3256 3258
3257 evergreen_fix_pci_max_read_req_size(rdev); 3259 evergreen_fix_pci_max_read_req_size(rdev);
3258 3260
@@ -4324,6 +4326,7 @@ void evergreen_disable_interrupt_state(struct radeon_device *rdev)
4324 tmp = RREG32(DMA_CNTL) & ~TRAP_ENABLE; 4326 tmp = RREG32(DMA_CNTL) & ~TRAP_ENABLE;
4325 WREG32(DMA_CNTL, tmp); 4327 WREG32(DMA_CNTL, tmp);
4326 WREG32(GRBM_INT_CNTL, 0); 4328 WREG32(GRBM_INT_CNTL, 0);
4329 WREG32(SRBM_INT_CNTL, 0);
4327 WREG32(INT_MASK + EVERGREEN_CRTC0_REGISTER_OFFSET, 0); 4330 WREG32(INT_MASK + EVERGREEN_CRTC0_REGISTER_OFFSET, 0);
4328 WREG32(INT_MASK + EVERGREEN_CRTC1_REGISTER_OFFSET, 0); 4331 WREG32(INT_MASK + EVERGREEN_CRTC1_REGISTER_OFFSET, 0);
4329 if (rdev->num_crtc >= 4) { 4332 if (rdev->num_crtc >= 4) {
@@ -5066,6 +5069,10 @@ restart_ih:
5066 DRM_ERROR("Unhandled interrupt: %d %d\n", src_id, src_data); 5069 DRM_ERROR("Unhandled interrupt: %d %d\n", src_id, src_data);
5067 break; 5070 break;
5068 } 5071 }
5072 case 96:
5073 DRM_ERROR("SRBM_READ_ERROR: 0x%x\n", RREG32(SRBM_READ_ERROR));
5074 WREG32(SRBM_INT_ACK, 0x1);
5075 break;
5069 case 124: /* UVD */ 5076 case 124: /* UVD */
5070 DRM_DEBUG("IH: UVD int: 0x%08x\n", src_data); 5077 DRM_DEBUG("IH: UVD int: 0x%08x\n", src_data);
5071 radeon_fence_process(rdev, R600_RING_TYPE_UVD_INDEX); 5078 radeon_fence_process(rdev, R600_RING_TYPE_UVD_INDEX);
diff --git a/drivers/gpu/drm/radeon/evergreend.h b/drivers/gpu/drm/radeon/evergreend.h
index ee83d2a88750..a8d1d5240fcb 100644
--- a/drivers/gpu/drm/radeon/evergreend.h
+++ b/drivers/gpu/drm/radeon/evergreend.h
@@ -1191,6 +1191,10 @@
1191#define SOFT_RESET_REGBB (1 << 22) 1191#define SOFT_RESET_REGBB (1 << 22)
1192#define SOFT_RESET_ORB (1 << 23) 1192#define SOFT_RESET_ORB (1 << 23)
1193 1193
1194#define SRBM_READ_ERROR 0xE98
1195#define SRBM_INT_CNTL 0xEA0
1196#define SRBM_INT_ACK 0xEA8
1197
1194/* display watermarks */ 1198/* display watermarks */
1195#define DC_LB_MEMORY_SPLIT 0x6b0c 1199#define DC_LB_MEMORY_SPLIT 0x6b0c
1196#define PRIORITY_A_CNT 0x6b18 1200#define PRIORITY_A_CNT 0x6b18
diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
index 24242a7f0ac3..dab00812abaa 100644
--- a/drivers/gpu/drm/radeon/ni.c
+++ b/drivers/gpu/drm/radeon/ni.c
@@ -962,6 +962,8 @@ static void cayman_gpu_init(struct radeon_device *rdev)
962 } 962 }
963 963
964 WREG32(GRBM_CNTL, GRBM_READ_TIMEOUT(0xff)); 964 WREG32(GRBM_CNTL, GRBM_READ_TIMEOUT(0xff));
965 WREG32(SRBM_INT_CNTL, 0x1);
966 WREG32(SRBM_INT_ACK, 0x1);
965 967
966 evergreen_fix_pci_max_read_req_size(rdev); 968 evergreen_fix_pci_max_read_req_size(rdev);
967 969
@@ -1086,12 +1088,12 @@ static void cayman_gpu_init(struct radeon_device *rdev)
1086 1088
1087 if ((rdev->config.cayman.max_backends_per_se == 1) && 1089 if ((rdev->config.cayman.max_backends_per_se == 1) &&
1088 (rdev->flags & RADEON_IS_IGP)) { 1090 (rdev->flags & RADEON_IS_IGP)) {
1089 if ((disabled_rb_mask & 3) == 1) { 1091 if ((disabled_rb_mask & 3) == 2) {
1090 /* RB0 disabled, RB1 enabled */
1091 tmp = 0x11111111;
1092 } else {
1093 /* RB1 disabled, RB0 enabled */ 1092 /* RB1 disabled, RB0 enabled */
1094 tmp = 0x00000000; 1093 tmp = 0x00000000;
1094 } else {
1095 /* RB0 disabled, RB1 enabled */
1096 tmp = 0x11111111;
1095 } 1097 }
1096 } else { 1098 } else {
1097 tmp = gb_addr_config & NUM_PIPES_MASK; 1099 tmp = gb_addr_config & NUM_PIPES_MASK;
diff --git a/drivers/gpu/drm/radeon/nid.h b/drivers/gpu/drm/radeon/nid.h
index ad7125486894..6b44580440d0 100644
--- a/drivers/gpu/drm/radeon/nid.h
+++ b/drivers/gpu/drm/radeon/nid.h
@@ -82,6 +82,10 @@
82#define SOFT_RESET_REGBB (1 << 22) 82#define SOFT_RESET_REGBB (1 << 22)
83#define SOFT_RESET_ORB (1 << 23) 83#define SOFT_RESET_ORB (1 << 23)
84 84
85#define SRBM_READ_ERROR 0xE98
86#define SRBM_INT_CNTL 0xEA0
87#define SRBM_INT_ACK 0xEA8
88
85#define SRBM_STATUS2 0x0EC4 89#define SRBM_STATUS2 0x0EC4
86#define DMA_BUSY (1 << 5) 90#define DMA_BUSY (1 << 5)
87#define DMA1_BUSY (1 << 6) 91#define DMA1_BUSY (1 << 6)
diff --git a/drivers/gpu/drm/radeon/r600_dpm.c b/drivers/gpu/drm/radeon/r600_dpm.c
index 843b65f46ece..fa2154493cf1 100644
--- a/drivers/gpu/drm/radeon/r600_dpm.c
+++ b/drivers/gpu/drm/radeon/r600_dpm.c
@@ -188,7 +188,7 @@ u32 r600_dpm_get_vrefresh(struct radeon_device *rdev)
188 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { 188 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
189 radeon_crtc = to_radeon_crtc(crtc); 189 radeon_crtc = to_radeon_crtc(crtc);
190 if (crtc->enabled && radeon_crtc->enabled && radeon_crtc->hw_mode.clock) { 190 if (crtc->enabled && radeon_crtc->enabled && radeon_crtc->hw_mode.clock) {
191 vrefresh = radeon_crtc->hw_mode.vrefresh; 191 vrefresh = drm_mode_vrefresh(&radeon_crtc->hw_mode);
192 break; 192 break;
193 } 193 }
194 } 194 }
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c
index c830863bc98a..a579ed379f20 100644
--- a/drivers/gpu/drm/radeon/radeon_cs.c
+++ b/drivers/gpu/drm/radeon/radeon_cs.c
@@ -715,6 +715,7 @@ int radeon_cs_packet_parse(struct radeon_cs_parser *p,
715 struct radeon_cs_chunk *ib_chunk = p->chunk_ib; 715 struct radeon_cs_chunk *ib_chunk = p->chunk_ib;
716 struct radeon_device *rdev = p->rdev; 716 struct radeon_device *rdev = p->rdev;
717 uint32_t header; 717 uint32_t header;
718 int ret = 0, i;
718 719
719 if (idx >= ib_chunk->length_dw) { 720 if (idx >= ib_chunk->length_dw) {
720 DRM_ERROR("Can not parse packet at %d after CS end %d !\n", 721 DRM_ERROR("Can not parse packet at %d after CS end %d !\n",
@@ -743,14 +744,25 @@ int radeon_cs_packet_parse(struct radeon_cs_parser *p,
743 break; 744 break;
744 default: 745 default:
745 DRM_ERROR("Unknown packet type %d at %d !\n", pkt->type, idx); 746 DRM_ERROR("Unknown packet type %d at %d !\n", pkt->type, idx);
746 return -EINVAL; 747 ret = -EINVAL;
748 goto dump_ib;
747 } 749 }
748 if ((pkt->count + 1 + pkt->idx) >= ib_chunk->length_dw) { 750 if ((pkt->count + 1 + pkt->idx) >= ib_chunk->length_dw) {
749 DRM_ERROR("Packet (%d:%d:%d) end after CS buffer (%d) !\n", 751 DRM_ERROR("Packet (%d:%d:%d) end after CS buffer (%d) !\n",
750 pkt->idx, pkt->type, pkt->count, ib_chunk->length_dw); 752 pkt->idx, pkt->type, pkt->count, ib_chunk->length_dw);
751 return -EINVAL; 753 ret = -EINVAL;
754 goto dump_ib;
752 } 755 }
753 return 0; 756 return 0;
757
758dump_ib:
759 for (i = 0; i < ib_chunk->length_dw; i++) {
760 if (i == idx)
761 printk("\t0x%08x <---\n", radeon_get_ib_value(p, i));
762 else
763 printk("\t0x%08x\n", radeon_get_ib_value(p, i));
764 }
765 return ret;
754} 766}
755 767
756/** 768/**
diff --git a/drivers/gpu/drm/radeon/radeon_encoders.c b/drivers/gpu/drm/radeon/radeon_encoders.c
index 6b670b0bc47b..3a297037cc17 100644
--- a/drivers/gpu/drm/radeon/radeon_encoders.c
+++ b/drivers/gpu/drm/radeon/radeon_encoders.c
@@ -179,9 +179,12 @@ static void radeon_encoder_add_backlight(struct radeon_encoder *radeon_encoder,
179 (rdev->pdev->subsystem_vendor == 0x1734) && 179 (rdev->pdev->subsystem_vendor == 0x1734) &&
180 (rdev->pdev->subsystem_device == 0x1107)) 180 (rdev->pdev->subsystem_device == 0x1107))
181 use_bl = false; 181 use_bl = false;
182/* Older PPC macs use on-GPU backlight controller */
183#ifndef CONFIG_PPC_PMAC
182 /* disable native backlight control on older asics */ 184 /* disable native backlight control on older asics */
183 else if (rdev->family < CHIP_R600) 185 else if (rdev->family < CHIP_R600)
184 use_bl = false; 186 use_bl = false;
187#endif
185 else 188 else
186 use_bl = true; 189 use_bl = true;
187 } 190 }
diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c
index 9f758d39420d..33cf4108386d 100644
--- a/drivers/gpu/drm/radeon/radeon_pm.c
+++ b/drivers/gpu/drm/radeon/radeon_pm.c
@@ -852,6 +852,12 @@ static struct radeon_ps *radeon_dpm_pick_power_state(struct radeon_device *rdev,
852 single_display = false; 852 single_display = false;
853 } 853 }
854 854
855 /* 120hz tends to be problematic even if they are under the
856 * vblank limit.
857 */
858 if (single_display && (r600_dpm_get_vrefresh(rdev) >= 120))
859 single_display = false;
860
855 /* certain older asics have a separare 3D performance state, 861 /* certain older asics have a separare 3D performance state,
856 * so try that first if the user selected performance 862 * so try that first if the user selected performance
857 */ 863 */
diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
index 73107fe9e46f..bcf516a8a2f1 100644
--- a/drivers/gpu/drm/radeon/si.c
+++ b/drivers/gpu/drm/radeon/si.c
@@ -3162,6 +3162,8 @@ static void si_gpu_init(struct radeon_device *rdev)
3162 } 3162 }
3163 3163
3164 WREG32(GRBM_CNTL, GRBM_READ_TIMEOUT(0xff)); 3164 WREG32(GRBM_CNTL, GRBM_READ_TIMEOUT(0xff));
3165 WREG32(SRBM_INT_CNTL, 1);
3166 WREG32(SRBM_INT_ACK, 1);
3165 3167
3166 evergreen_fix_pci_max_read_req_size(rdev); 3168 evergreen_fix_pci_max_read_req_size(rdev);
3167 3169
@@ -4699,12 +4701,6 @@ int si_ib_parse(struct radeon_device *rdev, struct radeon_ib *ib)
4699 switch (pkt.type) { 4701 switch (pkt.type) {
4700 case RADEON_PACKET_TYPE0: 4702 case RADEON_PACKET_TYPE0:
4701 dev_err(rdev->dev, "Packet0 not allowed!\n"); 4703 dev_err(rdev->dev, "Packet0 not allowed!\n");
4702 for (i = 0; i < ib->length_dw; i++) {
4703 if (i == idx)
4704 printk("\t0x%08x <---\n", ib->ptr[i]);
4705 else
4706 printk("\t0x%08x\n", ib->ptr[i]);
4707 }
4708 ret = -EINVAL; 4704 ret = -EINVAL;
4709 break; 4705 break;
4710 case RADEON_PACKET_TYPE2: 4706 case RADEON_PACKET_TYPE2:
@@ -4736,8 +4732,15 @@ int si_ib_parse(struct radeon_device *rdev, struct radeon_ib *ib)
4736 ret = -EINVAL; 4732 ret = -EINVAL;
4737 break; 4733 break;
4738 } 4734 }
4739 if (ret) 4735 if (ret) {
4736 for (i = 0; i < ib->length_dw; i++) {
4737 if (i == idx)
4738 printk("\t0x%08x <---\n", ib->ptr[i]);
4739 else
4740 printk("\t0x%08x\n", ib->ptr[i]);
4741 }
4740 break; 4742 break;
4743 }
4741 } while (idx < ib->length_dw); 4744 } while (idx < ib->length_dw);
4742 4745
4743 return ret; 4746 return ret;
@@ -5910,6 +5913,7 @@ static void si_disable_interrupt_state(struct radeon_device *rdev)
5910 tmp = RREG32(DMA_CNTL + DMA1_REGISTER_OFFSET) & ~TRAP_ENABLE; 5913 tmp = RREG32(DMA_CNTL + DMA1_REGISTER_OFFSET) & ~TRAP_ENABLE;
5911 WREG32(DMA_CNTL + DMA1_REGISTER_OFFSET, tmp); 5914 WREG32(DMA_CNTL + DMA1_REGISTER_OFFSET, tmp);
5912 WREG32(GRBM_INT_CNTL, 0); 5915 WREG32(GRBM_INT_CNTL, 0);
5916 WREG32(SRBM_INT_CNTL, 0);
5913 if (rdev->num_crtc >= 2) { 5917 if (rdev->num_crtc >= 2) {
5914 WREG32(INT_MASK + EVERGREEN_CRTC0_REGISTER_OFFSET, 0); 5918 WREG32(INT_MASK + EVERGREEN_CRTC0_REGISTER_OFFSET, 0);
5915 WREG32(INT_MASK + EVERGREEN_CRTC1_REGISTER_OFFSET, 0); 5919 WREG32(INT_MASK + EVERGREEN_CRTC1_REGISTER_OFFSET, 0);
@@ -6609,6 +6613,10 @@ restart_ih:
6609 break; 6613 break;
6610 } 6614 }
6611 break; 6615 break;
6616 case 96:
6617 DRM_ERROR("SRBM_READ_ERROR: 0x%x\n", RREG32(SRBM_READ_ERROR));
6618 WREG32(SRBM_INT_ACK, 0x1);
6619 break;
6612 case 124: /* UVD */ 6620 case 124: /* UVD */
6613 DRM_DEBUG("IH: UVD int: 0x%08x\n", src_data); 6621 DRM_DEBUG("IH: UVD int: 0x%08x\n", src_data);
6614 radeon_fence_process(rdev, R600_RING_TYPE_UVD_INDEX); 6622 radeon_fence_process(rdev, R600_RING_TYPE_UVD_INDEX);
diff --git a/drivers/gpu/drm/radeon/sid.h b/drivers/gpu/drm/radeon/sid.h
index cbd91d226f3c..c27118cab16a 100644
--- a/drivers/gpu/drm/radeon/sid.h
+++ b/drivers/gpu/drm/radeon/sid.h
@@ -358,6 +358,10 @@
358#define CC_SYS_RB_BACKEND_DISABLE 0xe80 358#define CC_SYS_RB_BACKEND_DISABLE 0xe80
359#define GC_USER_SYS_RB_BACKEND_DISABLE 0xe84 359#define GC_USER_SYS_RB_BACKEND_DISABLE 0xe84
360 360
361#define SRBM_READ_ERROR 0xE98
362#define SRBM_INT_CNTL 0xEA0
363#define SRBM_INT_ACK 0xEA8
364
361#define SRBM_STATUS2 0x0EC4 365#define SRBM_STATUS2 0x0EC4
362#define DMA_BUSY (1 << 5) 366#define DMA_BUSY (1 << 5)
363#define DMA1_BUSY (1 << 6) 367#define DMA1_BUSY (1 << 6)
diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index 3aaa84ae2681..1a52522f5da7 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -997,8 +997,10 @@ static void tegra_crtc_reset(struct drm_crtc *crtc)
997 crtc->state = NULL; 997 crtc->state = NULL;
998 998
999 state = kzalloc(sizeof(*state), GFP_KERNEL); 999 state = kzalloc(sizeof(*state), GFP_KERNEL);
1000 if (state) 1000 if (state) {
1001 crtc->state = &state->base; 1001 crtc->state = &state->base;
1002 crtc->state->crtc = crtc;
1003 }
1002} 1004}
1003 1005
1004static struct drm_crtc_state * 1006static struct drm_crtc_state *
@@ -1012,6 +1014,7 @@ tegra_crtc_atomic_duplicate_state(struct drm_crtc *crtc)
1012 return NULL; 1014 return NULL;
1013 1015
1014 copy->base.mode_changed = false; 1016 copy->base.mode_changed = false;
1017 copy->base.active_changed = false;
1015 copy->base.planes_changed = false; 1018 copy->base.planes_changed = false;
1016 copy->base.event = NULL; 1019 copy->base.event = NULL;
1017 1020
@@ -1227,9 +1230,6 @@ static void tegra_crtc_mode_set_nofb(struct drm_crtc *crtc)
1227 /* program display mode */ 1230 /* program display mode */
1228 tegra_dc_set_timings(dc, mode); 1231 tegra_dc_set_timings(dc, mode);
1229 1232
1230 if (dc->soc->supports_border_color)
1231 tegra_dc_writel(dc, 0, DC_DISP_BORDER_COLOR);
1232
1233 /* interlacing isn't supported yet, so disable it */ 1233 /* interlacing isn't supported yet, so disable it */
1234 if (dc->soc->supports_interlacing) { 1234 if (dc->soc->supports_interlacing) {
1235 value = tegra_dc_readl(dc, DC_DISP_INTERLACE_CONTROL); 1235 value = tegra_dc_readl(dc, DC_DISP_INTERLACE_CONTROL);
@@ -1252,42 +1252,7 @@ static void tegra_crtc_mode_set_nofb(struct drm_crtc *crtc)
1252 1252
1253static void tegra_crtc_prepare(struct drm_crtc *crtc) 1253static void tegra_crtc_prepare(struct drm_crtc *crtc)
1254{ 1254{
1255 struct tegra_dc *dc = to_tegra_dc(crtc);
1256 unsigned int syncpt;
1257 unsigned long value;
1258
1259 drm_crtc_vblank_off(crtc); 1255 drm_crtc_vblank_off(crtc);
1260
1261 if (dc->pipe)
1262 syncpt = SYNCPT_VBLANK1;
1263 else
1264 syncpt = SYNCPT_VBLANK0;
1265
1266 /* initialize display controller */
1267 tegra_dc_writel(dc, 0x00000100, DC_CMD_GENERAL_INCR_SYNCPT_CNTRL);
1268 tegra_dc_writel(dc, 0x100 | syncpt, DC_CMD_CONT_SYNCPT_VSYNC);
1269
1270 value = WIN_A_UF_INT | WIN_B_UF_INT | WIN_C_UF_INT | WIN_A_OF_INT;
1271 tegra_dc_writel(dc, value, DC_CMD_INT_TYPE);
1272
1273 value = WIN_A_UF_INT | WIN_B_UF_INT | WIN_C_UF_INT |
1274 WIN_A_OF_INT | WIN_B_OF_INT | WIN_C_OF_INT;
1275 tegra_dc_writel(dc, value, DC_CMD_INT_POLARITY);
1276
1277 /* initialize timer */
1278 value = CURSOR_THRESHOLD(0) | WINDOW_A_THRESHOLD(0x20) |
1279 WINDOW_B_THRESHOLD(0x20) | WINDOW_C_THRESHOLD(0x20);
1280 tegra_dc_writel(dc, value, DC_DISP_DISP_MEM_HIGH_PRIORITY);
1281
1282 value = CURSOR_THRESHOLD(0) | WINDOW_A_THRESHOLD(1) |
1283 WINDOW_B_THRESHOLD(1) | WINDOW_C_THRESHOLD(1);
1284 tegra_dc_writel(dc, value, DC_DISP_DISP_MEM_HIGH_PRIORITY_TIMER);
1285
1286 value = VBLANK_INT | WIN_A_UF_INT | WIN_B_UF_INT | WIN_C_UF_INT;
1287 tegra_dc_writel(dc, value, DC_CMD_INT_ENABLE);
1288
1289 value = WIN_A_UF_INT | WIN_B_UF_INT | WIN_C_UF_INT;
1290 tegra_dc_writel(dc, value, DC_CMD_INT_MASK);
1291} 1256}
1292 1257
1293static void tegra_crtc_commit(struct drm_crtc *crtc) 1258static void tegra_crtc_commit(struct drm_crtc *crtc)
@@ -1664,6 +1629,8 @@ static int tegra_dc_init(struct host1x_client *client)
1664 struct tegra_drm *tegra = drm->dev_private; 1629 struct tegra_drm *tegra = drm->dev_private;
1665 struct drm_plane *primary = NULL; 1630 struct drm_plane *primary = NULL;
1666 struct drm_plane *cursor = NULL; 1631 struct drm_plane *cursor = NULL;
1632 unsigned int syncpt;
1633 u32 value;
1667 int err; 1634 int err;
1668 1635
1669 if (tegra->domain) { 1636 if (tegra->domain) {
@@ -1730,6 +1697,40 @@ static int tegra_dc_init(struct host1x_client *client)
1730 goto cleanup; 1697 goto cleanup;
1731 } 1698 }
1732 1699
1700 /* initialize display controller */
1701 if (dc->pipe)
1702 syncpt = SYNCPT_VBLANK1;
1703 else
1704 syncpt = SYNCPT_VBLANK0;
1705
1706 tegra_dc_writel(dc, 0x00000100, DC_CMD_GENERAL_INCR_SYNCPT_CNTRL);
1707 tegra_dc_writel(dc, 0x100 | syncpt, DC_CMD_CONT_SYNCPT_VSYNC);
1708
1709 value = WIN_A_UF_INT | WIN_B_UF_INT | WIN_C_UF_INT | WIN_A_OF_INT;
1710 tegra_dc_writel(dc, value, DC_CMD_INT_TYPE);
1711
1712 value = WIN_A_UF_INT | WIN_B_UF_INT | WIN_C_UF_INT |
1713 WIN_A_OF_INT | WIN_B_OF_INT | WIN_C_OF_INT;
1714 tegra_dc_writel(dc, value, DC_CMD_INT_POLARITY);
1715
1716 /* initialize timer */
1717 value = CURSOR_THRESHOLD(0) | WINDOW_A_THRESHOLD(0x20) |
1718 WINDOW_B_THRESHOLD(0x20) | WINDOW_C_THRESHOLD(0x20);
1719 tegra_dc_writel(dc, value, DC_DISP_DISP_MEM_HIGH_PRIORITY);
1720
1721 value = CURSOR_THRESHOLD(0) | WINDOW_A_THRESHOLD(1) |
1722 WINDOW_B_THRESHOLD(1) | WINDOW_C_THRESHOLD(1);
1723 tegra_dc_writel(dc, value, DC_DISP_DISP_MEM_HIGH_PRIORITY_TIMER);
1724
1725 value = VBLANK_INT | WIN_A_UF_INT | WIN_B_UF_INT | WIN_C_UF_INT;
1726 tegra_dc_writel(dc, value, DC_CMD_INT_ENABLE);
1727
1728 value = WIN_A_UF_INT | WIN_B_UF_INT | WIN_C_UF_INT;
1729 tegra_dc_writel(dc, value, DC_CMD_INT_MASK);
1730
1731 if (dc->soc->supports_border_color)
1732 tegra_dc_writel(dc, 0, DC_DISP_BORDER_COLOR);
1733
1733 return 0; 1734 return 0;
1734 1735
1735cleanup: 1736cleanup:
diff --git a/drivers/gpu/drm/tegra/hdmi.c b/drivers/gpu/drm/tegra/hdmi.c
index 7e06657ae58b..7eaaee74a039 100644
--- a/drivers/gpu/drm/tegra/hdmi.c
+++ b/drivers/gpu/drm/tegra/hdmi.c
@@ -851,6 +851,14 @@ static void tegra_hdmi_encoder_mode_set(struct drm_encoder *encoder,
851 h_back_porch = mode->htotal - mode->hsync_end; 851 h_back_porch = mode->htotal - mode->hsync_end;
852 h_front_porch = mode->hsync_start - mode->hdisplay; 852 h_front_porch = mode->hsync_start - mode->hdisplay;
853 853
854 err = clk_set_rate(hdmi->clk, pclk);
855 if (err < 0) {
856 dev_err(hdmi->dev, "failed to set HDMI clock frequency: %d\n",
857 err);
858 }
859
860 DRM_DEBUG_KMS("HDMI clock rate: %lu Hz\n", clk_get_rate(hdmi->clk));
861
854 /* power up sequence */ 862 /* power up sequence */
855 value = tegra_hdmi_readl(hdmi, HDMI_NV_PDISP_SOR_PLL0); 863 value = tegra_hdmi_readl(hdmi, HDMI_NV_PDISP_SOR_PLL0);
856 value &= ~SOR_PLL_PDBG; 864 value &= ~SOR_PLL_PDBG;
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index db4fb6e1cc5b..7c669c328c4c 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1872,6 +1872,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
1872 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV) }, 1872 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV) },
1873 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K) }, 1873 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K) },
1874 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K_JP) }, 1874 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K_JP) },
1875 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE7K) },
1875 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_LK6K) }, 1876 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_LK6K) },
1876 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_USB) }, 1877 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_USB) },
1877 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_DIGITAL_MEDIA_3K) }, 1878 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_DIGITAL_MEDIA_3K) },
@@ -1926,6 +1927,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
1926#endif 1927#endif
1927#if IS_ENABLED(CONFIG_HID_SAITEK) 1928#if IS_ENABLED(CONFIG_HID_SAITEK)
1928 { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_PS1000) }, 1929 { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_PS1000) },
1930 { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RAT7_OLD) },
1929 { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RAT7) }, 1931 { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RAT7) },
1930 { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_MMO7) }, 1932 { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_MMO7) },
1931 { HID_USB_DEVICE(USB_VENDOR_ID_MADCATZ, USB_DEVICE_ID_MADCATZ_RAT9) }, 1933 { HID_USB_DEVICE(USB_VENDOR_ID_MADCATZ, USB_DEVICE_ID_MADCATZ_RAT9) },
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 46edb4d3ed28..204312bfab2c 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -654,6 +654,7 @@
654#define USB_DEVICE_ID_MS_LK6K 0x00f9 654#define USB_DEVICE_ID_MS_LK6K 0x00f9
655#define USB_DEVICE_ID_MS_PRESENTER_8K_BT 0x0701 655#define USB_DEVICE_ID_MS_PRESENTER_8K_BT 0x0701
656#define USB_DEVICE_ID_MS_PRESENTER_8K_USB 0x0713 656#define USB_DEVICE_ID_MS_PRESENTER_8K_USB 0x0713
657#define USB_DEVICE_ID_MS_NE7K 0x071d
657#define USB_DEVICE_ID_MS_DIGITAL_MEDIA_3K 0x0730 658#define USB_DEVICE_ID_MS_DIGITAL_MEDIA_3K 0x0730
658#define USB_DEVICE_ID_MS_COMFORT_MOUSE_4500 0x076c 659#define USB_DEVICE_ID_MS_COMFORT_MOUSE_4500 0x076c
659#define USB_DEVICE_ID_MS_SURFACE_PRO_2 0x0799 660#define USB_DEVICE_ID_MS_SURFACE_PRO_2 0x0799
@@ -802,6 +803,7 @@
802#define USB_VENDOR_ID_SAITEK 0x06a3 803#define USB_VENDOR_ID_SAITEK 0x06a3
803#define USB_DEVICE_ID_SAITEK_RUMBLEPAD 0xff17 804#define USB_DEVICE_ID_SAITEK_RUMBLEPAD 0xff17
804#define USB_DEVICE_ID_SAITEK_PS1000 0x0621 805#define USB_DEVICE_ID_SAITEK_PS1000 0x0621
806#define USB_DEVICE_ID_SAITEK_RAT7_OLD 0x0ccb
805#define USB_DEVICE_ID_SAITEK_RAT7 0x0cd7 807#define USB_DEVICE_ID_SAITEK_RAT7 0x0cd7
806#define USB_DEVICE_ID_SAITEK_MMO7 0x0cd0 808#define USB_DEVICE_ID_SAITEK_MMO7 0x0cd0
807 809
diff --git a/drivers/hid/hid-microsoft.c b/drivers/hid/hid-microsoft.c
index fbaea6eb882e..af935eb198c9 100644
--- a/drivers/hid/hid-microsoft.c
+++ b/drivers/hid/hid-microsoft.c
@@ -264,6 +264,8 @@ static const struct hid_device_id ms_devices[] = {
264 .driver_data = MS_ERGONOMY }, 264 .driver_data = MS_ERGONOMY },
265 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K_JP), 265 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K_JP),
266 .driver_data = MS_ERGONOMY }, 266 .driver_data = MS_ERGONOMY },
267 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE7K),
268 .driver_data = MS_ERGONOMY },
267 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_LK6K), 269 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_LK6K),
268 .driver_data = MS_ERGONOMY | MS_RDESC }, 270 .driver_data = MS_ERGONOMY | MS_RDESC },
269 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_USB), 271 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_USB),
diff --git a/drivers/hid/hid-saitek.c b/drivers/hid/hid-saitek.c
index 5632c54eadf0..a014f21275d8 100644
--- a/drivers/hid/hid-saitek.c
+++ b/drivers/hid/hid-saitek.c
@@ -177,6 +177,8 @@ static int saitek_event(struct hid_device *hdev, struct hid_field *field,
177static const struct hid_device_id saitek_devices[] = { 177static const struct hid_device_id saitek_devices[] = {
178 { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_PS1000), 178 { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_PS1000),
179 .driver_data = SAITEK_FIX_PS1000 }, 179 .driver_data = SAITEK_FIX_PS1000 },
180 { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RAT7_OLD),
181 .driver_data = SAITEK_RELEASE_MODE_RAT7 },
180 { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RAT7), 182 { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RAT7),
181 .driver_data = SAITEK_RELEASE_MODE_RAT7 }, 183 .driver_data = SAITEK_RELEASE_MODE_RAT7 },
182 { HID_USB_DEVICE(USB_VENDOR_ID_MADCATZ, USB_DEVICE_ID_MADCATZ_RAT9), 184 { HID_USB_DEVICE(USB_VENDOR_ID_MADCATZ, USB_DEVICE_ID_MADCATZ_RAT9),
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 6a58b6c723aa..e54ce1097e2c 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -135,8 +135,9 @@ static struct hid_sensor_hub_callbacks *sensor_hub_get_callback(
135{ 135{
136 struct hid_sensor_hub_callbacks_list *callback; 136 struct hid_sensor_hub_callbacks_list *callback;
137 struct sensor_hub_data *pdata = hid_get_drvdata(hdev); 137 struct sensor_hub_data *pdata = hid_get_drvdata(hdev);
138 unsigned long flags;
138 139
139 spin_lock(&pdata->dyn_callback_lock); 140 spin_lock_irqsave(&pdata->dyn_callback_lock, flags);
140 list_for_each_entry(callback, &pdata->dyn_callback_list, list) 141 list_for_each_entry(callback, &pdata->dyn_callback_list, list)
141 if (callback->usage_id == usage_id && 142 if (callback->usage_id == usage_id &&
142 (collection_index >= 143 (collection_index >=
@@ -145,10 +146,11 @@ static struct hid_sensor_hub_callbacks *sensor_hub_get_callback(
145 callback->hsdev->end_collection_index)) { 146 callback->hsdev->end_collection_index)) {
146 *priv = callback->priv; 147 *priv = callback->priv;
147 *hsdev = callback->hsdev; 148 *hsdev = callback->hsdev;
148 spin_unlock(&pdata->dyn_callback_lock); 149 spin_unlock_irqrestore(&pdata->dyn_callback_lock,
150 flags);
149 return callback->usage_callback; 151 return callback->usage_callback;
150 } 152 }
151 spin_unlock(&pdata->dyn_callback_lock); 153 spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags);
152 154
153 return NULL; 155 return NULL;
154} 156}
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
index 31e9d2561106..1896c019e302 100644
--- a/drivers/hid/hid-sony.c
+++ b/drivers/hid/hid-sony.c
@@ -804,7 +804,7 @@ union sixaxis_output_report_01 {
804#define DS4_REPORT_0x81_SIZE 7 804#define DS4_REPORT_0x81_SIZE 7
805#define SIXAXIS_REPORT_0xF2_SIZE 18 805#define SIXAXIS_REPORT_0xF2_SIZE 18
806 806
807static spinlock_t sony_dev_list_lock; 807static DEFINE_SPINLOCK(sony_dev_list_lock);
808static LIST_HEAD(sony_device_list); 808static LIST_HEAD(sony_device_list);
809static DEFINE_IDA(sony_device_id_allocator); 809static DEFINE_IDA(sony_device_id_allocator);
810 810
@@ -1944,6 +1944,8 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
1944 return -ENOMEM; 1944 return -ENOMEM;
1945 } 1945 }
1946 1946
1947 spin_lock_init(&sc->lock);
1948
1947 sc->quirks = quirks; 1949 sc->quirks = quirks;
1948 hid_set_drvdata(hdev, sc); 1950 hid_set_drvdata(hdev, sc);
1949 sc->hdev = hdev; 1951 sc->hdev = hdev;
@@ -2147,8 +2149,8 @@ static void __exit sony_exit(void)
2147{ 2149{
2148 dbg_hid("Sony:%s\n", __func__); 2150 dbg_hid("Sony:%s\n", __func__);
2149 2151
2150 ida_destroy(&sony_device_id_allocator);
2151 hid_unregister_driver(&sony_driver); 2152 hid_unregister_driver(&sony_driver);
2153 ida_destroy(&sony_device_id_allocator);
2152} 2154}
2153module_init(sony_init); 2155module_init(sony_init);
2154module_exit(sony_exit); 2156module_exit(sony_exit);
diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
index d43e967e7533..36053f33d6d9 100644
--- a/drivers/hid/i2c-hid/i2c-hid.c
+++ b/drivers/hid/i2c-hid/i2c-hid.c
@@ -370,7 +370,10 @@ static int i2c_hid_hwreset(struct i2c_client *client)
370static void i2c_hid_get_input(struct i2c_hid *ihid) 370static void i2c_hid_get_input(struct i2c_hid *ihid)
371{ 371{
372 int ret, ret_size; 372 int ret, ret_size;
373 int size = ihid->bufsize; 373 int size = le16_to_cpu(ihid->hdesc.wMaxInputLength);
374
375 if (size > ihid->bufsize)
376 size = ihid->bufsize;
374 377
375 ret = i2c_master_recv(ihid->client, ihid->inbuf, size); 378 ret = i2c_master_recv(ihid->client, ihid->inbuf, size);
376 if (ret != size) { 379 if (ret != size) {
@@ -785,7 +788,7 @@ static int i2c_hid_init_irq(struct i2c_client *client)
785 dev_dbg(&client->dev, "Requesting IRQ: %d\n", client->irq); 788 dev_dbg(&client->dev, "Requesting IRQ: %d\n", client->irq);
786 789
787 ret = request_threaded_irq(client->irq, NULL, i2c_hid_irq, 790 ret = request_threaded_irq(client->irq, NULL, i2c_hid_irq,
788 IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 791 IRQF_TRIGGER_LOW | IRQF_ONESHOT,
789 client->name, ihid); 792 client->name, ihid);
790 if (ret < 0) { 793 if (ret < 0) {
791 dev_warn(&client->dev, 794 dev_warn(&client->dev,
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index 1a6507999a65..046351cf17f3 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -778,6 +778,11 @@ static int wacom_intuos_irq(struct wacom_wac *wacom)
778 input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[4])); 778 input_report_abs(input, ABS_X, be16_to_cpup((__be16 *)&data[4]));
779 input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[6])); 779 input_report_abs(input, ABS_Y, be16_to_cpup((__be16 *)&data[6]));
780 input_report_abs(input, ABS_Z, be16_to_cpup((__be16 *)&data[8])); 780 input_report_abs(input, ABS_Z, be16_to_cpup((__be16 *)&data[8]));
781 if ((data[2] & 0x07) | data[4] | data[5] | data[6] | data[7] | data[8] | data[9]) {
782 input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
783 } else {
784 input_report_abs(input, ABS_MISC, 0);
785 }
781 } else if (features->type == CINTIQ_HYBRID) { 786 } else if (features->type == CINTIQ_HYBRID) {
782 /* 787 /*
783 * Do not send hardware buttons under Android. They 788 * Do not send hardware buttons under Android. They
@@ -2725,9 +2730,9 @@ static const struct wacom_features wacom_features_0xF6 =
2725 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf8, .touch_max = 10, 2730 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf8, .touch_max = 10,
2726 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE }; 2731 .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
2727static const struct wacom_features wacom_features_0x32A = 2732static const struct wacom_features wacom_features_0x32A =
2728 { "Wacom Cintiq 27QHD", 119740, 67520, 2047, 2733 { "Wacom Cintiq 27QHD", 119740, 67520, 2047, 63,
2729 63, WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 2734 WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
2730 WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 2735 WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
2731static const struct wacom_features wacom_features_0x32B = 2736static const struct wacom_features wacom_features_0x32B =
2732 { "Wacom Cintiq 27QHD touch", 119740, 67520, 2047, 63, 2737 { "Wacom Cintiq 27QHD touch", 119740, 67520, 2047, 63,
2733 WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 2738 WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
diff --git a/drivers/hwmon/ads7828.c b/drivers/hwmon/ads7828.c
index bce4e9ff21bf..6c99ee7bafa3 100644
--- a/drivers/hwmon/ads7828.c
+++ b/drivers/hwmon/ads7828.c
@@ -147,6 +147,9 @@ static int ads7828_probe(struct i2c_client *client,
147 &ads2830_regmap_config); 147 &ads2830_regmap_config);
148 } 148 }
149 149
150 if (IS_ERR(data->regmap))
151 return PTR_ERR(data->regmap);
152
150 data->cmd_byte = ext_vref ? ADS7828_CMD_PD1 : ADS7828_CMD_PD3; 153 data->cmd_byte = ext_vref ? ADS7828_CMD_PD1 : ADS7828_CMD_PD3;
151 if (!diff_input) 154 if (!diff_input)
152 data->cmd_byte |= ADS7828_CMD_SD_SE; 155 data->cmd_byte |= ADS7828_CMD_SD_SE;
diff --git a/drivers/md/md.c b/drivers/md/md.c
index c8d2bac4e28b..cadf9cc02b25 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2555,7 +2555,7 @@ state_store(struct md_rdev *rdev, const char *buf, size_t len)
2555 return err ? err : len; 2555 return err ? err : len;
2556} 2556}
2557static struct rdev_sysfs_entry rdev_state = 2557static struct rdev_sysfs_entry rdev_state =
2558__ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store); 2558__ATTR_PREALLOC(state, S_IRUGO|S_IWUSR, state_show, state_store);
2559 2559
2560static ssize_t 2560static ssize_t
2561errors_show(struct md_rdev *rdev, char *page) 2561errors_show(struct md_rdev *rdev, char *page)
@@ -3638,7 +3638,8 @@ resync_start_store(struct mddev *mddev, const char *buf, size_t len)
3638 return err ?: len; 3638 return err ?: len;
3639} 3639}
3640static struct md_sysfs_entry md_resync_start = 3640static struct md_sysfs_entry md_resync_start =
3641__ATTR(resync_start, S_IRUGO|S_IWUSR, resync_start_show, resync_start_store); 3641__ATTR_PREALLOC(resync_start, S_IRUGO|S_IWUSR,
3642 resync_start_show, resync_start_store);
3642 3643
3643/* 3644/*
3644 * The array state can be: 3645 * The array state can be:
@@ -3851,7 +3852,7 @@ array_state_store(struct mddev *mddev, const char *buf, size_t len)
3851 return err ?: len; 3852 return err ?: len;
3852} 3853}
3853static struct md_sysfs_entry md_array_state = 3854static struct md_sysfs_entry md_array_state =
3854__ATTR(array_state, S_IRUGO|S_IWUSR, array_state_show, array_state_store); 3855__ATTR_PREALLOC(array_state, S_IRUGO|S_IWUSR, array_state_show, array_state_store);
3855 3856
3856static ssize_t 3857static ssize_t
3857max_corrected_read_errors_show(struct mddev *mddev, char *page) { 3858max_corrected_read_errors_show(struct mddev *mddev, char *page) {
@@ -4101,7 +4102,7 @@ out_unlock:
4101} 4102}
4102 4103
4103static struct md_sysfs_entry md_metadata = 4104static struct md_sysfs_entry md_metadata =
4104__ATTR(metadata_version, S_IRUGO|S_IWUSR, metadata_show, metadata_store); 4105__ATTR_PREALLOC(metadata_version, S_IRUGO|S_IWUSR, metadata_show, metadata_store);
4105 4106
4106static ssize_t 4107static ssize_t
4107action_show(struct mddev *mddev, char *page) 4108action_show(struct mddev *mddev, char *page)
@@ -4189,7 +4190,7 @@ action_store(struct mddev *mddev, const char *page, size_t len)
4189} 4190}
4190 4191
4191static struct md_sysfs_entry md_scan_mode = 4192static struct md_sysfs_entry md_scan_mode =
4192__ATTR(sync_action, S_IRUGO|S_IWUSR, action_show, action_store); 4193__ATTR_PREALLOC(sync_action, S_IRUGO|S_IWUSR, action_show, action_store);
4193 4194
4194static ssize_t 4195static ssize_t
4195last_sync_action_show(struct mddev *mddev, char *page) 4196last_sync_action_show(struct mddev *mddev, char *page)
@@ -4335,7 +4336,8 @@ sync_completed_show(struct mddev *mddev, char *page)
4335 return sprintf(page, "%llu / %llu\n", resync, max_sectors); 4336 return sprintf(page, "%llu / %llu\n", resync, max_sectors);
4336} 4337}
4337 4338
4338static struct md_sysfs_entry md_sync_completed = __ATTR_RO(sync_completed); 4339static struct md_sysfs_entry md_sync_completed =
4340 __ATTR_PREALLOC(sync_completed, S_IRUGO, sync_completed_show, NULL);
4339 4341
4340static ssize_t 4342static ssize_t
4341min_sync_show(struct mddev *mddev, char *page) 4343min_sync_show(struct mddev *mddev, char *page)
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 4153da5d4011..d34e238afa54 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -560,7 +560,7 @@ static int read_balance(struct r1conf *conf, struct r1bio *r1_bio, int *max_sect
560 if (test_bit(WriteMostly, &rdev->flags)) { 560 if (test_bit(WriteMostly, &rdev->flags)) {
561 /* Don't balance among write-mostly, just 561 /* Don't balance among write-mostly, just
562 * use the first as a last resort */ 562 * use the first as a last resort */
563 if (best_disk < 0) { 563 if (best_dist_disk < 0) {
564 if (is_badblock(rdev, this_sector, sectors, 564 if (is_badblock(rdev, this_sector, sectors,
565 &first_bad, &bad_sectors)) { 565 &first_bad, &bad_sectors)) {
566 if (first_bad < this_sector) 566 if (first_bad < this_sector)
@@ -569,7 +569,8 @@ static int read_balance(struct r1conf *conf, struct r1bio *r1_bio, int *max_sect
569 best_good_sectors = first_bad - this_sector; 569 best_good_sectors = first_bad - this_sector;
570 } else 570 } else
571 best_good_sectors = sectors; 571 best_good_sectors = sectors;
572 best_disk = disk; 572 best_dist_disk = disk;
573 best_pending_disk = disk;
573 } 574 }
574 continue; 575 continue;
575 } 576 }
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index e75d48c0421a..cd2f96b2c572 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -5121,12 +5121,17 @@ static inline sector_t sync_request(struct mddev *mddev, sector_t sector_nr, int
5121 schedule_timeout_uninterruptible(1); 5121 schedule_timeout_uninterruptible(1);
5122 } 5122 }
5123 /* Need to check if array will still be degraded after recovery/resync 5123 /* Need to check if array will still be degraded after recovery/resync
5124 * We don't need to check the 'failed' flag as when that gets set, 5124 * Note in case of > 1 drive failures it's possible we're rebuilding
5125 * recovery aborts. 5125 * one drive while leaving another faulty drive in array.
5126 */ 5126 */
5127 for (i = 0; i < conf->raid_disks; i++) 5127 rcu_read_lock();
5128 if (conf->disks[i].rdev == NULL) 5128 for (i = 0; i < conf->raid_disks; i++) {
5129 struct md_rdev *rdev = ACCESS_ONCE(conf->disks[i].rdev);
5130
5131 if (rdev == NULL || test_bit(Faulty, &rdev->flags))
5129 still_degraded = 1; 5132 still_degraded = 1;
5133 }
5134 rcu_read_unlock();
5130 5135
5131 bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, still_degraded); 5136 bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, still_degraded);
5132 5137
diff --git a/drivers/rtc/rtc-ds1685.c b/drivers/rtc/rtc-ds1685.c
index 8c3bfcb115b7..803869c7d7c2 100644
--- a/drivers/rtc/rtc-ds1685.c
+++ b/drivers/rtc/rtc-ds1685.c
@@ -399,21 +399,21 @@ ds1685_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
399 * of this RTC chip. We check for it anyways in case support is 399 * of this RTC chip. We check for it anyways in case support is
400 * added in the future. 400 * added in the future.
401 */ 401 */
402 if (unlikely((seconds >= 0xc0) && (seconds <= 0xff))) 402 if (unlikely(seconds >= 0xc0))
403 alrm->time.tm_sec = -1; 403 alrm->time.tm_sec = -1;
404 else 404 else
405 alrm->time.tm_sec = ds1685_rtc_bcd2bin(rtc, seconds, 405 alrm->time.tm_sec = ds1685_rtc_bcd2bin(rtc, seconds,
406 RTC_SECS_BCD_MASK, 406 RTC_SECS_BCD_MASK,
407 RTC_SECS_BIN_MASK); 407 RTC_SECS_BIN_MASK);
408 408
409 if (unlikely((minutes >= 0xc0) && (minutes <= 0xff))) 409 if (unlikely(minutes >= 0xc0))
410 alrm->time.tm_min = -1; 410 alrm->time.tm_min = -1;
411 else 411 else
412 alrm->time.tm_min = ds1685_rtc_bcd2bin(rtc, minutes, 412 alrm->time.tm_min = ds1685_rtc_bcd2bin(rtc, minutes,
413 RTC_MINS_BCD_MASK, 413 RTC_MINS_BCD_MASK,
414 RTC_MINS_BIN_MASK); 414 RTC_MINS_BIN_MASK);
415 415
416 if (unlikely((hours >= 0xc0) && (hours <= 0xff))) 416 if (unlikely(hours >= 0xc0))
417 alrm->time.tm_hour = -1; 417 alrm->time.tm_hour = -1;
418 else 418 else
419 alrm->time.tm_hour = ds1685_rtc_bcd2bin(rtc, hours, 419 alrm->time.tm_hour = ds1685_rtc_bcd2bin(rtc, hours,
@@ -472,13 +472,13 @@ ds1685_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
472 * field, and we only support four fields. We put the support 472 * field, and we only support four fields. We put the support
473 * here anyways for the future. 473 * here anyways for the future.
474 */ 474 */
475 if (unlikely((seconds >= 0xc0) && (seconds <= 0xff))) 475 if (unlikely(seconds >= 0xc0))
476 seconds = 0xff; 476 seconds = 0xff;
477 477
478 if (unlikely((minutes >= 0xc0) && (minutes <= 0xff))) 478 if (unlikely(minutes >= 0xc0))
479 minutes = 0xff; 479 minutes = 0xff;
480 480
481 if (unlikely((hours >= 0xc0) && (hours <= 0xff))) 481 if (unlikely(hours >= 0xc0))
482 hours = 0xff; 482 hours = 0xff;
483 483
484 alrm->time.tm_mon = -1; 484 alrm->time.tm_mon = -1;
@@ -528,7 +528,6 @@ ds1685_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
528/* ----------------------------------------------------------------------- */ 528/* ----------------------------------------------------------------------- */
529/* /dev/rtcX Interface functions */ 529/* /dev/rtcX Interface functions */
530 530
531#ifdef CONFIG_RTC_INTF_DEV
532/** 531/**
533 * ds1685_rtc_alarm_irq_enable - replaces ioctl() RTC_AIE on/off. 532 * ds1685_rtc_alarm_irq_enable - replaces ioctl() RTC_AIE on/off.
534 * @dev: pointer to device structure. 533 * @dev: pointer to device structure.
@@ -557,7 +556,6 @@ ds1685_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
557 556
558 return 0; 557 return 0;
559} 558}
560#endif
561/* ----------------------------------------------------------------------- */ 559/* ----------------------------------------------------------------------- */
562 560
563 561
@@ -1612,7 +1610,7 @@ ds1685_rtc_sysfs_time_regs_show(struct device *dev,
1612 ds1685_rtc_sysfs_time_regs_lookup(attr->attr.name, false); 1610 ds1685_rtc_sysfs_time_regs_lookup(attr->attr.name, false);
1613 1611
1614 /* Make sure we actually matched something. */ 1612 /* Make sure we actually matched something. */
1615 if (!bcd_reg_info && !bin_reg_info) 1613 if (!bcd_reg_info || !bin_reg_info)
1616 return -EINVAL; 1614 return -EINVAL;
1617 1615
1618 /* bcd_reg_info->reg == bin_reg_info->reg. */ 1616 /* bcd_reg_info->reg == bin_reg_info->reg. */
@@ -1650,7 +1648,7 @@ ds1685_rtc_sysfs_time_regs_store(struct device *dev,
1650 return -EINVAL; 1648 return -EINVAL;
1651 1649
1652 /* Make sure we actually matched something. */ 1650 /* Make sure we actually matched something. */
1653 if (!bcd_reg_info && !bin_reg_info) 1651 if (!bcd_reg_info || !bin_reg_info)
1654 return -EINVAL; 1652 return -EINVAL;
1655 1653
1656 /* Check for a valid range. */ 1654 /* Check for a valid range. */
diff --git a/drivers/sh/pm_runtime.c b/drivers/sh/pm_runtime.c
index f3ee439d6f0e..cd4c293f0dd0 100644
--- a/drivers/sh/pm_runtime.c
+++ b/drivers/sh/pm_runtime.c
@@ -81,7 +81,9 @@ static int __init sh_pm_runtime_init(void)
81 if (!of_machine_is_compatible("renesas,emev2") && 81 if (!of_machine_is_compatible("renesas,emev2") &&
82 !of_machine_is_compatible("renesas,r7s72100") && 82 !of_machine_is_compatible("renesas,r7s72100") &&
83 !of_machine_is_compatible("renesas,r8a73a4") && 83 !of_machine_is_compatible("renesas,r8a73a4") &&
84#ifndef CONFIG_PM_GENERIC_DOMAINS_OF
84 !of_machine_is_compatible("renesas,r8a7740") && 85 !of_machine_is_compatible("renesas,r8a7740") &&
86#endif
85 !of_machine_is_compatible("renesas,r8a7778") && 87 !of_machine_is_compatible("renesas,r8a7778") &&
86 !of_machine_is_compatible("renesas,r8a7779") && 88 !of_machine_is_compatible("renesas,r8a7779") &&
87 !of_machine_is_compatible("renesas,r8a7790") && 89 !of_machine_is_compatible("renesas,r8a7790") &&
diff --git a/drivers/thermal/int340x_thermal/int3400_thermal.c b/drivers/thermal/int340x_thermal/int3400_thermal.c
index 25d244cbbe8f..031018e7a65b 100644
--- a/drivers/thermal/int340x_thermal/int3400_thermal.c
+++ b/drivers/thermal/int340x_thermal/int3400_thermal.c
@@ -262,13 +262,12 @@ static int int3400_thermal_probe(struct platform_device *pdev)
262 result = acpi_parse_art(priv->adev->handle, &priv->art_count, 262 result = acpi_parse_art(priv->adev->handle, &priv->art_count,
263 &priv->arts, true); 263 &priv->arts, true);
264 if (result) 264 if (result)
265 goto free_priv; 265 dev_dbg(&pdev->dev, "_ART table parsing error\n");
266
267 266
268 result = acpi_parse_trt(priv->adev->handle, &priv->trt_count, 267 result = acpi_parse_trt(priv->adev->handle, &priv->trt_count,
269 &priv->trts, true); 268 &priv->trts, true);
270 if (result) 269 if (result)
271 goto free_art; 270 dev_dbg(&pdev->dev, "_TRT table parsing error\n");
272 271
273 platform_set_drvdata(pdev, priv); 272 platform_set_drvdata(pdev, priv);
274 273
@@ -281,7 +280,7 @@ static int int3400_thermal_probe(struct platform_device *pdev)
281 &int3400_thermal_params, 0, 0); 280 &int3400_thermal_params, 0, 0);
282 if (IS_ERR(priv->thermal)) { 281 if (IS_ERR(priv->thermal)) {
283 result = PTR_ERR(priv->thermal); 282 result = PTR_ERR(priv->thermal);
284 goto free_trt; 283 goto free_art_trt;
285 } 284 }
286 285
287 priv->rel_misc_dev_res = acpi_thermal_rel_misc_device_add( 286 priv->rel_misc_dev_res = acpi_thermal_rel_misc_device_add(
@@ -295,9 +294,8 @@ static int int3400_thermal_probe(struct platform_device *pdev)
295 294
296free_zone: 295free_zone:
297 thermal_zone_device_unregister(priv->thermal); 296 thermal_zone_device_unregister(priv->thermal);
298free_trt: 297free_art_trt:
299 kfree(priv->trts); 298 kfree(priv->trts);
300free_art:
301 kfree(priv->arts); 299 kfree(priv->arts);
302free_priv: 300free_priv:
303 kfree(priv); 301 kfree(priv);
diff --git a/drivers/thermal/intel_powerclamp.c b/drivers/thermal/intel_powerclamp.c
index 6ceebd659dd4..12623bc02f46 100644
--- a/drivers/thermal/intel_powerclamp.c
+++ b/drivers/thermal/intel_powerclamp.c
@@ -688,6 +688,7 @@ static const struct x86_cpu_id intel_powerclamp_ids[] = {
688 { X86_VENDOR_INTEL, 6, 0x45}, 688 { X86_VENDOR_INTEL, 6, 0x45},
689 { X86_VENDOR_INTEL, 6, 0x46}, 689 { X86_VENDOR_INTEL, 6, 0x46},
690 { X86_VENDOR_INTEL, 6, 0x4c}, 690 { X86_VENDOR_INTEL, 6, 0x4c},
691 { X86_VENDOR_INTEL, 6, 0x4d},
691 { X86_VENDOR_INTEL, 6, 0x56}, 692 { X86_VENDOR_INTEL, 6, 0x56},
692 {} 693 {}
693}; 694};
diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index 2580a4872f90..fe4e767018c4 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -387,21 +387,9 @@ static int rcar_thermal_probe(struct platform_device *pdev)
387 387
388 irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 388 irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
389 if (irq) { 389 if (irq) {
390 int ret;
391
392 /* 390 /*
393 * platform has IRQ support. 391 * platform has IRQ support.
394 * Then, driver uses common registers 392 * Then, driver uses common registers
395 */
396
397 ret = devm_request_irq(dev, irq->start, rcar_thermal_irq, 0,
398 dev_name(dev), common);
399 if (ret) {
400 dev_err(dev, "irq request failed\n ");
401 return ret;
402 }
403
404 /*
405 * rcar_has_irq_support() will be enabled 393 * rcar_has_irq_support() will be enabled
406 */ 394 */
407 res = platform_get_resource(pdev, IORESOURCE_MEM, mres++); 395 res = platform_get_resource(pdev, IORESOURCE_MEM, mres++);
@@ -456,8 +444,16 @@ static int rcar_thermal_probe(struct platform_device *pdev)
456 } 444 }
457 445
458 /* enable temperature comparation */ 446 /* enable temperature comparation */
459 if (irq) 447 if (irq) {
448 ret = devm_request_irq(dev, irq->start, rcar_thermal_irq, 0,
449 dev_name(dev), common);
450 if (ret) {
451 dev_err(dev, "irq request failed\n ");
452 goto error_unregister;
453 }
454
460 rcar_thermal_common_write(common, ENR, enr_bits); 455 rcar_thermal_common_write(common, ENR, enr_bits);
456 }
461 457
462 platform_set_drvdata(pdev, common); 458 platform_set_drvdata(pdev, common);
463 459
@@ -467,9 +463,9 @@ static int rcar_thermal_probe(struct platform_device *pdev)
467 463
468error_unregister: 464error_unregister:
469 rcar_thermal_for_each_priv(priv, common) { 465 rcar_thermal_for_each_priv(priv, common) {
470 thermal_zone_device_unregister(priv->zone);
471 if (rcar_has_irq_support(priv)) 466 if (rcar_has_irq_support(priv))
472 rcar_thermal_irq_disable(priv); 467 rcar_thermal_irq_disable(priv);
468 thermal_zone_device_unregister(priv->zone);
473 } 469 }
474 470
475 pm_runtime_put(dev); 471 pm_runtime_put(dev);
@@ -485,9 +481,9 @@ static int rcar_thermal_remove(struct platform_device *pdev)
485 struct rcar_thermal_priv *priv; 481 struct rcar_thermal_priv *priv;
486 482
487 rcar_thermal_for_each_priv(priv, common) { 483 rcar_thermal_for_each_priv(priv, common) {
488 thermal_zone_device_unregister(priv->zone);
489 if (rcar_has_irq_support(priv)) 484 if (rcar_has_irq_support(priv))
490 rcar_thermal_irq_disable(priv); 485 rcar_thermal_irq_disable(priv);
486 thermal_zone_device_unregister(priv->zone);
491 } 487 }
492 488
493 pm_runtime_put(dev); 489 pm_runtime_put(dev);
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
index 933cd80a6bc5..1fc54ab911d2 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -918,34 +918,16 @@ static irqreturn_t exynos_tmu_irq(int irq, void *id)
918} 918}
919 919
920static const struct of_device_id exynos_tmu_match[] = { 920static const struct of_device_id exynos_tmu_match[] = {
921 { 921 { .compatible = "samsung,exynos3250-tmu", },
922 .compatible = "samsung,exynos3250-tmu", 922 { .compatible = "samsung,exynos4210-tmu", },
923 }, 923 { .compatible = "samsung,exynos4412-tmu", },
924 { 924 { .compatible = "samsung,exynos5250-tmu", },
925 .compatible = "samsung,exynos4210-tmu", 925 { .compatible = "samsung,exynos5260-tmu", },
926 }, 926 { .compatible = "samsung,exynos5420-tmu", },
927 { 927 { .compatible = "samsung,exynos5420-tmu-ext-triminfo", },
928 .compatible = "samsung,exynos4412-tmu", 928 { .compatible = "samsung,exynos5440-tmu", },
929 }, 929 { .compatible = "samsung,exynos7-tmu", },
930 { 930 { /* sentinel */ },
931 .compatible = "samsung,exynos5250-tmu",
932 },
933 {
934 .compatible = "samsung,exynos5260-tmu",
935 },
936 {
937 .compatible = "samsung,exynos5420-tmu",
938 },
939 {
940 .compatible = "samsung,exynos5420-tmu-ext-triminfo",
941 },
942 {
943 .compatible = "samsung,exynos5440-tmu",
944 },
945 {
946 .compatible = "samsung,exynos7-tmu",
947 },
948 {},
949}; 931};
950MODULE_DEVICE_TABLE(of, exynos_tmu_match); 932MODULE_DEVICE_TABLE(of, exynos_tmu_match);
951 933
diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.c b/drivers/thermal/ti-soc-thermal/ti-bandgap.c
index 634b6ce0e63a..62a5d449c388 100644
--- a/drivers/thermal/ti-soc-thermal/ti-bandgap.c
+++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.c
@@ -1402,7 +1402,7 @@ int ti_bandgap_remove(struct platform_device *pdev)
1402 return 0; 1402 return 0;
1403} 1403}
1404 1404
1405#ifdef CONFIG_PM 1405#ifdef CONFIG_PM_SLEEP
1406static int ti_bandgap_save_ctxt(struct ti_bandgap *bgp) 1406static int ti_bandgap_save_ctxt(struct ti_bandgap *bgp)
1407{ 1407{
1408 int i; 1408 int i;
diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
index 3fb054a10f6a..a38c1756442a 100644
--- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
+++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c
@@ -429,7 +429,7 @@ int ti_thermal_unregister_cpu_cooling(struct ti_bandgap *bgp, int id)
429 429
430 data = ti_bandgap_get_sensor_data(bgp, id); 430 data = ti_bandgap_get_sensor_data(bgp, id);
431 431
432 if (data && data->cool_dev) 432 if (data)
433 cpufreq_cooling_unregister(data->cool_dev); 433 cpufreq_cooling_unregister(data->cool_dev);
434 434
435 return 0; 435 return 0;
diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
index 2140398a2a8c..2ccd3592d41f 100644
--- a/drivers/xen/Makefile
+++ b/drivers/xen/Makefile
@@ -2,7 +2,7 @@ ifeq ($(filter y, $(CONFIG_ARM) $(CONFIG_ARM64)),)
2obj-$(CONFIG_HOTPLUG_CPU) += cpu_hotplug.o 2obj-$(CONFIG_HOTPLUG_CPU) += cpu_hotplug.o
3endif 3endif
4obj-$(CONFIG_X86) += fallback.o 4obj-$(CONFIG_X86) += fallback.o
5obj-y += grant-table.o features.o balloon.o manage.o 5obj-y += grant-table.o features.o balloon.o manage.o preempt.o
6obj-y += events/ 6obj-y += events/
7obj-y += xenbus/ 7obj-y += xenbus/
8 8
diff --git a/drivers/xen/preempt.c b/drivers/xen/preempt.c
new file mode 100644
index 000000000000..a1800c150839
--- /dev/null
+++ b/drivers/xen/preempt.c
@@ -0,0 +1,44 @@
1/*
2 * Preemptible hypercalls
3 *
4 * Copyright (C) 2014 Citrix Systems R&D ltd.
5 *
6 * This source code is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
10 */
11
12#include <linux/sched.h>
13#include <xen/xen-ops.h>
14
15#ifndef CONFIG_PREEMPT
16
17/*
18 * Some hypercalls issued by the toolstack can take many 10s of
19 * seconds. Allow tasks running hypercalls via the privcmd driver to
20 * be voluntarily preempted even if full kernel preemption is
21 * disabled.
22 *
23 * Such preemptible hypercalls are bracketed by
24 * xen_preemptible_hcall_begin() and xen_preemptible_hcall_end()
25 * calls.
26 */
27
28DEFINE_PER_CPU(bool, xen_in_preemptible_hcall);
29EXPORT_SYMBOL_GPL(xen_in_preemptible_hcall);
30
31asmlinkage __visible void xen_maybe_preempt_hcall(void)
32{
33 if (unlikely(__this_cpu_read(xen_in_preemptible_hcall)
34 && should_resched())) {
35 /*
36 * Clear flag as we may be rescheduled on a different
37 * cpu.
38 */
39 __this_cpu_write(xen_in_preemptible_hcall, false);
40 _cond_resched();
41 __this_cpu_write(xen_in_preemptible_hcall, true);
42 }
43}
44#endif /* CONFIG_PREEMPT */
diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c
index 569a13b9e856..59ac71c4a043 100644
--- a/drivers/xen/privcmd.c
+++ b/drivers/xen/privcmd.c
@@ -56,10 +56,12 @@ static long privcmd_ioctl_hypercall(void __user *udata)
56 if (copy_from_user(&hypercall, udata, sizeof(hypercall))) 56 if (copy_from_user(&hypercall, udata, sizeof(hypercall)))
57 return -EFAULT; 57 return -EFAULT;
58 58
59 xen_preemptible_hcall_begin();
59 ret = privcmd_call(hypercall.op, 60 ret = privcmd_call(hypercall.op,
60 hypercall.arg[0], hypercall.arg[1], 61 hypercall.arg[0], hypercall.arg[1],
61 hypercall.arg[2], hypercall.arg[3], 62 hypercall.arg[2], hypercall.arg[3],
62 hypercall.arg[4]); 63 hypercall.arg[4]);
64 xen_preemptible_hcall_end();
63 65
64 return ret; 66 return ret;
65} 67}
diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c
index 61653a03a8f5..9faca6a60bb0 100644
--- a/drivers/xen/xen-scsiback.c
+++ b/drivers/xen/xen-scsiback.c
@@ -709,12 +709,11 @@ static int prepare_pending_reqs(struct vscsibk_info *info,
709static int scsiback_do_cmd_fn(struct vscsibk_info *info) 709static int scsiback_do_cmd_fn(struct vscsibk_info *info)
710{ 710{
711 struct vscsiif_back_ring *ring = &info->ring; 711 struct vscsiif_back_ring *ring = &info->ring;
712 struct vscsiif_request *ring_req; 712 struct vscsiif_request ring_req;
713 struct vscsibk_pend *pending_req; 713 struct vscsibk_pend *pending_req;
714 RING_IDX rc, rp; 714 RING_IDX rc, rp;
715 int err, more_to_do; 715 int err, more_to_do;
716 uint32_t result; 716 uint32_t result;
717 uint8_t act;
718 717
719 rc = ring->req_cons; 718 rc = ring->req_cons;
720 rp = ring->sring->req_prod; 719 rp = ring->sring->req_prod;
@@ -735,11 +734,10 @@ static int scsiback_do_cmd_fn(struct vscsibk_info *info)
735 if (!pending_req) 734 if (!pending_req)
736 return 1; 735 return 1;
737 736
738 ring_req = RING_GET_REQUEST(ring, rc); 737 ring_req = *RING_GET_REQUEST(ring, rc);
739 ring->req_cons = ++rc; 738 ring->req_cons = ++rc;
740 739
741 act = ring_req->act; 740 err = prepare_pending_reqs(info, &ring_req, pending_req);
742 err = prepare_pending_reqs(info, ring_req, pending_req);
743 if (err) { 741 if (err) {
744 switch (err) { 742 switch (err) {
745 case -ENODEV: 743 case -ENODEV:
@@ -755,9 +753,9 @@ static int scsiback_do_cmd_fn(struct vscsibk_info *info)
755 return 1; 753 return 1;
756 } 754 }
757 755
758 switch (act) { 756 switch (ring_req.act) {
759 case VSCSIIF_ACT_SCSI_CDB: 757 case VSCSIIF_ACT_SCSI_CDB:
760 if (scsiback_gnttab_data_map(ring_req, pending_req)) { 758 if (scsiback_gnttab_data_map(&ring_req, pending_req)) {
761 scsiback_fast_flush_area(pending_req); 759 scsiback_fast_flush_area(pending_req);
762 scsiback_do_resp_with_sense(NULL, 760 scsiback_do_resp_with_sense(NULL,
763 DRIVER_ERROR << 24, 0, pending_req); 761 DRIVER_ERROR << 24, 0, pending_req);
@@ -768,7 +766,7 @@ static int scsiback_do_cmd_fn(struct vscsibk_info *info)
768 break; 766 break;
769 case VSCSIIF_ACT_SCSI_ABORT: 767 case VSCSIIF_ACT_SCSI_ABORT:
770 scsiback_device_action(pending_req, TMR_ABORT_TASK, 768 scsiback_device_action(pending_req, TMR_ABORT_TASK,
771 ring_req->ref_rqid); 769 ring_req.ref_rqid);
772 break; 770 break;
773 case VSCSIIF_ACT_SCSI_RESET: 771 case VSCSIIF_ACT_SCSI_RESET:
774 scsiback_device_action(pending_req, TMR_LUN_RESET, 0); 772 scsiback_device_action(pending_req, TMR_LUN_RESET, 0);
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index cd4d1315aaa9..8222f6f74147 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -4903,10 +4903,17 @@ static void sort_parity_stripes(struct btrfs_bio *bbio, int num_stripes)
4903static struct btrfs_bio *alloc_btrfs_bio(int total_stripes, int real_stripes) 4903static struct btrfs_bio *alloc_btrfs_bio(int total_stripes, int real_stripes)
4904{ 4904{
4905 struct btrfs_bio *bbio = kzalloc( 4905 struct btrfs_bio *bbio = kzalloc(
4906 /* the size of the btrfs_bio */
4906 sizeof(struct btrfs_bio) + 4907 sizeof(struct btrfs_bio) +
4908 /* plus the variable array for the stripes */
4907 sizeof(struct btrfs_bio_stripe) * (total_stripes) + 4909 sizeof(struct btrfs_bio_stripe) * (total_stripes) +
4910 /* plus the variable array for the tgt dev */
4908 sizeof(int) * (real_stripes) + 4911 sizeof(int) * (real_stripes) +
4909 sizeof(u64) * (real_stripes), 4912 /*
4913 * plus the raid_map, which includes both the tgt dev
4914 * and the stripes
4915 */
4916 sizeof(u64) * (total_stripes),
4910 GFP_NOFS); 4917 GFP_NOFS);
4911 if (!bbio) 4918 if (!bbio)
4912 return NULL; 4919 return NULL;
diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c
index b2e3ff347620..ecdbae19a766 100644
--- a/fs/nilfs2/btree.c
+++ b/fs/nilfs2/btree.c
@@ -31,6 +31,8 @@
31#include "alloc.h" 31#include "alloc.h"
32#include "dat.h" 32#include "dat.h"
33 33
34static void __nilfs_btree_init(struct nilfs_bmap *bmap);
35
34static struct nilfs_btree_path *nilfs_btree_alloc_path(void) 36static struct nilfs_btree_path *nilfs_btree_alloc_path(void)
35{ 37{
36 struct nilfs_btree_path *path; 38 struct nilfs_btree_path *path;
@@ -368,6 +370,34 @@ static int nilfs_btree_node_broken(const struct nilfs_btree_node *node,
368 return ret; 370 return ret;
369} 371}
370 372
373/**
374 * nilfs_btree_root_broken - verify consistency of btree root node
375 * @node: btree root node to be examined
376 * @ino: inode number
377 *
378 * Return Value: If node is broken, 1 is returned. Otherwise, 0 is returned.
379 */
380static int nilfs_btree_root_broken(const struct nilfs_btree_node *node,
381 unsigned long ino)
382{
383 int level, flags, nchildren;
384 int ret = 0;
385
386 level = nilfs_btree_node_get_level(node);
387 flags = nilfs_btree_node_get_flags(node);
388 nchildren = nilfs_btree_node_get_nchildren(node);
389
390 if (unlikely(level < NILFS_BTREE_LEVEL_NODE_MIN ||
391 level > NILFS_BTREE_LEVEL_MAX ||
392 nchildren < 0 ||
393 nchildren > NILFS_BTREE_ROOT_NCHILDREN_MAX)) {
394 pr_crit("NILFS: bad btree root (inode number=%lu): level = %d, flags = 0x%x, nchildren = %d\n",
395 ino, level, flags, nchildren);
396 ret = 1;
397 }
398 return ret;
399}
400
371int nilfs_btree_broken_node_block(struct buffer_head *bh) 401int nilfs_btree_broken_node_block(struct buffer_head *bh)
372{ 402{
373 int ret; 403 int ret;
@@ -1713,7 +1743,7 @@ nilfs_btree_commit_convert_and_insert(struct nilfs_bmap *btree,
1713 1743
1714 /* convert and insert */ 1744 /* convert and insert */
1715 dat = NILFS_BMAP_USE_VBN(btree) ? nilfs_bmap_get_dat(btree) : NULL; 1745 dat = NILFS_BMAP_USE_VBN(btree) ? nilfs_bmap_get_dat(btree) : NULL;
1716 nilfs_btree_init(btree); 1746 __nilfs_btree_init(btree);
1717 if (nreq != NULL) { 1747 if (nreq != NULL) {
1718 nilfs_bmap_commit_alloc_ptr(btree, dreq, dat); 1748 nilfs_bmap_commit_alloc_ptr(btree, dreq, dat);
1719 nilfs_bmap_commit_alloc_ptr(btree, nreq, dat); 1749 nilfs_bmap_commit_alloc_ptr(btree, nreq, dat);
@@ -2294,12 +2324,23 @@ static const struct nilfs_bmap_operations nilfs_btree_ops_gc = {
2294 .bop_gather_data = NULL, 2324 .bop_gather_data = NULL,
2295}; 2325};
2296 2326
2297int nilfs_btree_init(struct nilfs_bmap *bmap) 2327static void __nilfs_btree_init(struct nilfs_bmap *bmap)
2298{ 2328{
2299 bmap->b_ops = &nilfs_btree_ops; 2329 bmap->b_ops = &nilfs_btree_ops;
2300 bmap->b_nchildren_per_block = 2330 bmap->b_nchildren_per_block =
2301 NILFS_BTREE_NODE_NCHILDREN_MAX(nilfs_btree_node_size(bmap)); 2331 NILFS_BTREE_NODE_NCHILDREN_MAX(nilfs_btree_node_size(bmap));
2302 return 0; 2332}
2333
2334int nilfs_btree_init(struct nilfs_bmap *bmap)
2335{
2336 int ret = 0;
2337
2338 __nilfs_btree_init(bmap);
2339
2340 if (nilfs_btree_root_broken(nilfs_btree_get_root(bmap),
2341 bmap->b_inode->i_ino))
2342 ret = -EIO;
2343 return ret;
2303} 2344}
2304 2345
2305void nilfs_btree_init_gc(struct nilfs_bmap *bmap) 2346void nilfs_btree_init_gc(struct nilfs_bmap *bmap)
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index ce615d12fb44..a2e1cb8a568b 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -397,7 +397,8 @@ STATIC int /* error (positive) */
397xfs_zero_last_block( 397xfs_zero_last_block(
398 struct xfs_inode *ip, 398 struct xfs_inode *ip,
399 xfs_fsize_t offset, 399 xfs_fsize_t offset,
400 xfs_fsize_t isize) 400 xfs_fsize_t isize,
401 bool *did_zeroing)
401{ 402{
402 struct xfs_mount *mp = ip->i_mount; 403 struct xfs_mount *mp = ip->i_mount;
403 xfs_fileoff_t last_fsb = XFS_B_TO_FSBT(mp, isize); 404 xfs_fileoff_t last_fsb = XFS_B_TO_FSBT(mp, isize);
@@ -425,6 +426,7 @@ xfs_zero_last_block(
425 zero_len = mp->m_sb.sb_blocksize - zero_offset; 426 zero_len = mp->m_sb.sb_blocksize - zero_offset;
426 if (isize + zero_len > offset) 427 if (isize + zero_len > offset)
427 zero_len = offset - isize; 428 zero_len = offset - isize;
429 *did_zeroing = true;
428 return xfs_iozero(ip, isize, zero_len); 430 return xfs_iozero(ip, isize, zero_len);
429} 431}
430 432
@@ -443,7 +445,8 @@ int /* error (positive) */
443xfs_zero_eof( 445xfs_zero_eof(
444 struct xfs_inode *ip, 446 struct xfs_inode *ip,
445 xfs_off_t offset, /* starting I/O offset */ 447 xfs_off_t offset, /* starting I/O offset */
446 xfs_fsize_t isize) /* current inode size */ 448 xfs_fsize_t isize, /* current inode size */
449 bool *did_zeroing)
447{ 450{
448 struct xfs_mount *mp = ip->i_mount; 451 struct xfs_mount *mp = ip->i_mount;
449 xfs_fileoff_t start_zero_fsb; 452 xfs_fileoff_t start_zero_fsb;
@@ -465,7 +468,7 @@ xfs_zero_eof(
465 * We only zero a part of that block so it is handled specially. 468 * We only zero a part of that block so it is handled specially.
466 */ 469 */
467 if (XFS_B_FSB_OFFSET(mp, isize) != 0) { 470 if (XFS_B_FSB_OFFSET(mp, isize) != 0) {
468 error = xfs_zero_last_block(ip, offset, isize); 471 error = xfs_zero_last_block(ip, offset, isize, did_zeroing);
469 if (error) 472 if (error)
470 return error; 473 return error;
471 } 474 }
@@ -525,6 +528,7 @@ xfs_zero_eof(
525 if (error) 528 if (error)
526 return error; 529 return error;
527 530
531 *did_zeroing = true;
528 start_zero_fsb = imap.br_startoff + imap.br_blockcount; 532 start_zero_fsb = imap.br_startoff + imap.br_blockcount;
529 ASSERT(start_zero_fsb <= (end_zero_fsb + 1)); 533 ASSERT(start_zero_fsb <= (end_zero_fsb + 1));
530 } 534 }
@@ -567,13 +571,15 @@ restart:
567 * having to redo all checks before. 571 * having to redo all checks before.
568 */ 572 */
569 if (*pos > i_size_read(inode)) { 573 if (*pos > i_size_read(inode)) {
574 bool zero = false;
575
570 if (*iolock == XFS_IOLOCK_SHARED) { 576 if (*iolock == XFS_IOLOCK_SHARED) {
571 xfs_rw_iunlock(ip, *iolock); 577 xfs_rw_iunlock(ip, *iolock);
572 *iolock = XFS_IOLOCK_EXCL; 578 *iolock = XFS_IOLOCK_EXCL;
573 xfs_rw_ilock(ip, *iolock); 579 xfs_rw_ilock(ip, *iolock);
574 goto restart; 580 goto restart;
575 } 581 }
576 error = xfs_zero_eof(ip, *pos, i_size_read(inode)); 582 error = xfs_zero_eof(ip, *pos, i_size_read(inode), &zero);
577 if (error) 583 if (error)
578 return error; 584 return error;
579 } 585 }
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index daafa1f6d260..6163767aa856 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -2867,6 +2867,10 @@ xfs_rename(
2867 * Handle RENAME_EXCHANGE flags 2867 * Handle RENAME_EXCHANGE flags
2868 */ 2868 */
2869 if (flags & RENAME_EXCHANGE) { 2869 if (flags & RENAME_EXCHANGE) {
2870 if (target_ip == NULL) {
2871 error = -EINVAL;
2872 goto error_return;
2873 }
2870 error = xfs_cross_rename(tp, src_dp, src_name, src_ip, 2874 error = xfs_cross_rename(tp, src_dp, src_name, src_ip,
2871 target_dp, target_name, target_ip, 2875 target_dp, target_name, target_ip,
2872 &free_list, &first_block, spaceres); 2876 &free_list, &first_block, spaceres);
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 86cd6b39bed7..a1cd55f3f351 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -384,10 +384,11 @@ enum xfs_prealloc_flags {
384 XFS_PREALLOC_INVISIBLE = (1 << 4), 384 XFS_PREALLOC_INVISIBLE = (1 << 4),
385}; 385};
386 386
387int xfs_update_prealloc_flags(struct xfs_inode *, 387int xfs_update_prealloc_flags(struct xfs_inode *ip,
388 enum xfs_prealloc_flags); 388 enum xfs_prealloc_flags flags);
389int xfs_zero_eof(struct xfs_inode *, xfs_off_t, xfs_fsize_t); 389int xfs_zero_eof(struct xfs_inode *ip, xfs_off_t offset,
390int xfs_iozero(struct xfs_inode *, loff_t, size_t); 390 xfs_fsize_t isize, bool *did_zeroing);
391int xfs_iozero(struct xfs_inode *ip, loff_t pos, size_t count);
391 392
392 393
393#define IHOLD(ip) \ 394#define IHOLD(ip) \
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index d919ad7b16bf..e53a90331422 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -751,6 +751,7 @@ xfs_setattr_size(
751 int error; 751 int error;
752 uint lock_flags = 0; 752 uint lock_flags = 0;
753 uint commit_flags = 0; 753 uint commit_flags = 0;
754 bool did_zeroing = false;
754 755
755 trace_xfs_setattr(ip); 756 trace_xfs_setattr(ip);
756 757
@@ -794,20 +795,16 @@ xfs_setattr_size(
794 return error; 795 return error;
795 796
796 /* 797 /*
797 * Now we can make the changes. Before we join the inode to the 798 * File data changes must be complete before we start the transaction to
798 * transaction, take care of the part of the truncation that must be 799 * modify the inode. This needs to be done before joining the inode to
799 * done without the inode lock. This needs to be done before joining 800 * the transaction because the inode cannot be unlocked once it is a
800 * the inode to the transaction, because the inode cannot be unlocked 801 * part of the transaction.
801 * once it is a part of the transaction. 802 *
803 * Start with zeroing any data block beyond EOF that we may expose on
804 * file extension.
802 */ 805 */
803 if (newsize > oldsize) { 806 if (newsize > oldsize) {
804 /* 807 error = xfs_zero_eof(ip, newsize, oldsize, &did_zeroing);
805 * Do the first part of growing a file: zero any data in the
806 * last block that is beyond the old EOF. We need to do this
807 * before the inode is joined to the transaction to modify
808 * i_size.
809 */
810 error = xfs_zero_eof(ip, newsize, oldsize);
811 if (error) 808 if (error)
812 return error; 809 return error;
813 } 810 }
@@ -817,23 +814,18 @@ xfs_setattr_size(
817 * any previous writes that are beyond the on disk EOF and the new 814 * any previous writes that are beyond the on disk EOF and the new
818 * EOF that have not been written out need to be written here. If we 815 * EOF that have not been written out need to be written here. If we
819 * do not write the data out, we expose ourselves to the null files 816 * do not write the data out, we expose ourselves to the null files
820 * problem. 817 * problem. Note that this includes any block zeroing we did above;
821 * 818 * otherwise those blocks may not be zeroed after a crash.
822 * Only flush from the on disk size to the smaller of the in memory
823 * file size or the new size as that's the range we really care about
824 * here and prevents waiting for other data not within the range we
825 * care about here.
826 */ 819 */
827 if (oldsize != ip->i_d.di_size && newsize > ip->i_d.di_size) { 820 if (newsize > ip->i_d.di_size &&
821 (oldsize != ip->i_d.di_size || did_zeroing)) {
828 error = filemap_write_and_wait_range(VFS_I(ip)->i_mapping, 822 error = filemap_write_and_wait_range(VFS_I(ip)->i_mapping,
829 ip->i_d.di_size, newsize); 823 ip->i_d.di_size, newsize);
830 if (error) 824 if (error)
831 return error; 825 return error;
832 } 826 }
833 827
834 /* 828 /* Now wait for all direct I/O to complete. */
835 * Wait for all direct I/O to complete.
836 */
837 inode_dio_wait(inode); 829 inode_dio_wait(inode);
838 830
839 /* 831 /*
diff --git a/fs/xfs/xfs_pnfs.c b/fs/xfs/xfs_pnfs.c
index 4b33ef112400..365dd57ea760 100644
--- a/fs/xfs/xfs_pnfs.c
+++ b/fs/xfs/xfs_pnfs.c
@@ -300,8 +300,10 @@ xfs_fs_commit_blocks(
300 300
301 tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE); 301 tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
302 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 0, 0); 302 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 0, 0);
303 if (error) 303 if (error) {
304 xfs_trans_cancel(tp, 0);
304 goto out_drop_iolock; 305 goto out_drop_iolock;
306 }
305 307
306 xfs_ilock(ip, XFS_ILOCK_EXCL); 308 xfs_ilock(ip, XFS_ILOCK_EXCL);
307 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); 309 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index 53cc2aaf8d2b..fbbb9e62e274 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -836,6 +836,11 @@ xfs_qm_reset_dqcounts(
836 */ 836 */
837 xfs_dqcheck(mp, ddq, id+j, type, XFS_QMOPT_DQREPAIR, 837 xfs_dqcheck(mp, ddq, id+j, type, XFS_QMOPT_DQREPAIR,
838 "xfs_quotacheck"); 838 "xfs_quotacheck");
839 /*
840 * Reset type in case we are reusing group quota file for
841 * project quotas or vice versa
842 */
843 ddq->d_flags = type;
839 ddq->d_bcount = 0; 844 ddq->d_bcount = 0;
840 ddq->d_icount = 0; 845 ddq->d_icount = 0;
841 ddq->d_rtbcount = 0; 846 ddq->d_rtbcount = 0;
diff --git a/include/drm/i915_pciids.h b/include/drm/i915_pciids.h
index 180ad0e6de21..d016dc57f007 100644
--- a/include/drm/i915_pciids.h
+++ b/include/drm/i915_pciids.h
@@ -214,9 +214,9 @@
214 INTEL_VGA_DEVICE((((gt) - 1) << 4) | (id), info) 214 INTEL_VGA_DEVICE((((gt) - 1) << 4) | (id), info)
215 215
216#define _INTEL_BDW_M_IDS(gt, info) \ 216#define _INTEL_BDW_M_IDS(gt, info) \
217 _INTEL_BDW_M(gt, 0x1602, info), /* ULT */ \ 217 _INTEL_BDW_M(gt, 0x1602, info), /* Halo */ \
218 _INTEL_BDW_M(gt, 0x1606, info), /* ULT */ \ 218 _INTEL_BDW_M(gt, 0x1606, info), /* ULT */ \
219 _INTEL_BDW_M(gt, 0x160B, info), /* Iris */ \ 219 _INTEL_BDW_M(gt, 0x160B, info), /* ULT */ \
220 _INTEL_BDW_M(gt, 0x160E, info) /* ULX */ 220 _INTEL_BDW_M(gt, 0x160E, info) /* ULX */
221 221
222#define _INTEL_BDW_D_IDS(gt, info) \ 222#define _INTEL_BDW_D_IDS(gt, info) \
diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h
index 51f7ccadf923..4173a8fdad9e 100644
--- a/include/linux/hid-sensor-hub.h
+++ b/include/linux/hid-sensor-hub.h
@@ -33,6 +33,8 @@
33 * @units: Measurment unit for this attribute. 33 * @units: Measurment unit for this attribute.
34 * @unit_expo: Exponent used in the data. 34 * @unit_expo: Exponent used in the data.
35 * @size: Size in bytes for data size. 35 * @size: Size in bytes for data size.
36 * @logical_minimum: Logical minimum value for this attribute.
37 * @logical_maximum: Logical maximum value for this attribute.
36 */ 38 */
37struct hid_sensor_hub_attribute_info { 39struct hid_sensor_hub_attribute_info {
38 u32 usage_id; 40 u32 usage_id;
@@ -146,6 +148,7 @@ int sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev,
146 148
147/** 149/**
148* sensor_hub_input_attr_get_raw_value() - Synchronous read request 150* sensor_hub_input_attr_get_raw_value() - Synchronous read request
151* @hsdev: Hub device instance.
149* @usage_id: Attribute usage id of parent physical device as per spec 152* @usage_id: Attribute usage id of parent physical device as per spec
150* @attr_usage_id: Attribute usage id as per spec 153* @attr_usage_id: Attribute usage id as per spec
151* @report_id: Report id to look for 154* @report_id: Report id to look for
@@ -160,6 +163,7 @@ int sensor_hub_input_attr_get_raw_value(struct hid_sensor_hub_device *hsdev,
160 u32 attr_usage_id, u32 report_id); 163 u32 attr_usage_id, u32 report_id);
161/** 164/**
162* sensor_hub_set_feature() - Feature set request 165* sensor_hub_set_feature() - Feature set request
166* @hsdev: Hub device instance.
163* @report_id: Report id to look for 167* @report_id: Report id to look for
164* @field_index: Field index inside a report 168* @field_index: Field index inside a report
165* @value: Value to set 169* @value: Value to set
@@ -172,6 +176,7 @@ int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
172 176
173/** 177/**
174* sensor_hub_get_feature() - Feature get request 178* sensor_hub_get_feature() - Feature get request
179* @hsdev: Hub device instance.
175* @report_id: Report id to look for 180* @report_id: Report id to look for
176* @field_index: Field index inside a report 181* @field_index: Field index inside a report
177* @value: Place holder for return value 182* @value: Place holder for return value
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index fc52e307efab..5eac316490ea 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -314,6 +314,8 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
314} 314}
315 315
316#endif 316#endif
317
318#if IS_ENABLED(CONFIG_THERMAL)
317struct thermal_zone_device *thermal_zone_device_register(const char *, int, int, 319struct thermal_zone_device *thermal_zone_device_register(const char *, int, int,
318 void *, struct thermal_zone_device_ops *, 320 void *, struct thermal_zone_device_ops *,
319 const struct thermal_zone_params *, int, int); 321 const struct thermal_zone_params *, int, int);
@@ -340,8 +342,58 @@ struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
340 struct thermal_cooling_device *, int); 342 struct thermal_cooling_device *, int);
341void thermal_cdev_update(struct thermal_cooling_device *); 343void thermal_cdev_update(struct thermal_cooling_device *);
342void thermal_notify_framework(struct thermal_zone_device *, int); 344void thermal_notify_framework(struct thermal_zone_device *, int);
343 345#else
344#ifdef CONFIG_NET 346static inline struct thermal_zone_device *thermal_zone_device_register(
347 const char *type, int trips, int mask, void *devdata,
348 struct thermal_zone_device_ops *ops,
349 const struct thermal_zone_params *tzp,
350 int passive_delay, int polling_delay)
351{ return ERR_PTR(-ENODEV); }
352static inline void thermal_zone_device_unregister(
353 struct thermal_zone_device *tz)
354{ }
355static inline int thermal_zone_bind_cooling_device(
356 struct thermal_zone_device *tz, int trip,
357 struct thermal_cooling_device *cdev,
358 unsigned long upper, unsigned long lower)
359{ return -ENODEV; }
360static inline int thermal_zone_unbind_cooling_device(
361 struct thermal_zone_device *tz, int trip,
362 struct thermal_cooling_device *cdev)
363{ return -ENODEV; }
364static inline void thermal_zone_device_update(struct thermal_zone_device *tz)
365{ }
366static inline struct thermal_cooling_device *
367thermal_cooling_device_register(char *type, void *devdata,
368 const struct thermal_cooling_device_ops *ops)
369{ return ERR_PTR(-ENODEV); }
370static inline struct thermal_cooling_device *
371thermal_of_cooling_device_register(struct device_node *np,
372 char *type, void *devdata, const struct thermal_cooling_device_ops *ops)
373{ return ERR_PTR(-ENODEV); }
374static inline void thermal_cooling_device_unregister(
375 struct thermal_cooling_device *cdev)
376{ }
377static inline struct thermal_zone_device *thermal_zone_get_zone_by_name(
378 const char *name)
379{ return ERR_PTR(-ENODEV); }
380static inline int thermal_zone_get_temp(
381 struct thermal_zone_device *tz, unsigned long *temp)
382{ return -ENODEV; }
383static inline int get_tz_trend(struct thermal_zone_device *tz, int trip)
384{ return -ENODEV; }
385static inline struct thermal_instance *
386get_thermal_instance(struct thermal_zone_device *tz,
387 struct thermal_cooling_device *cdev, int trip)
388{ return ERR_PTR(-ENODEV); }
389static inline void thermal_cdev_update(struct thermal_cooling_device *cdev)
390{ }
391static inline void thermal_notify_framework(struct thermal_zone_device *tz,
392 int trip)
393{ }
394#endif /* CONFIG_THERMAL */
395
396#if defined(CONFIG_NET) && IS_ENABLED(CONFIG_THERMAL)
345extern int thermal_generate_netlink_event(struct thermal_zone_device *tz, 397extern int thermal_generate_netlink_event(struct thermal_zone_device *tz,
346 enum events event); 398 enum events event);
347#else 399#else
diff --git a/include/sound/pcm_params.h b/include/sound/pcm_params.h
index 3c45f3924ba7..c704357775fc 100644
--- a/include/sound/pcm_params.h
+++ b/include/sound/pcm_params.h
@@ -366,4 +366,11 @@ static inline int params_physical_width(const struct snd_pcm_hw_params *p)
366 return snd_pcm_format_physical_width(params_format(p)); 366 return snd_pcm_format_physical_width(params_format(p));
367} 367}
368 368
369static inline void
370params_set_format(struct snd_pcm_hw_params *p, snd_pcm_format_t fmt)
371{
372 snd_mask_set(hw_param_mask(p, SNDRV_PCM_HW_PARAM_FORMAT),
373 (__force int)fmt);
374}
375
369#endif /* __SOUND_PCM_PARAMS_H */ 376#endif /* __SOUND_PCM_PARAMS_H */
diff --git a/include/sound/soc.h b/include/sound/soc.h
index cf0bb156d6da..b371aef9819f 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -450,8 +450,10 @@ int soc_dai_hw_params(struct snd_pcm_substream *substream,
450 struct snd_soc_dai *dai); 450 struct snd_soc_dai *dai);
451 451
452/* Jack reporting */ 452/* Jack reporting */
453int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type, 453int snd_soc_card_jack_new(struct snd_soc_card *card, const char *id, int type,
454 struct snd_soc_jack *jack); 454 struct snd_soc_jack *jack, struct snd_soc_jack_pin *pins,
455 unsigned int num_pins);
456
455void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask); 457void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask);
456int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count, 458int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count,
457 struct snd_soc_jack_pin *pins); 459 struct snd_soc_jack_pin *pins);
@@ -659,7 +661,7 @@ struct snd_soc_jack_gpio {
659struct snd_soc_jack { 661struct snd_soc_jack {
660 struct mutex mutex; 662 struct mutex mutex;
661 struct snd_jack *jack; 663 struct snd_jack *jack;
662 struct snd_soc_codec *codec; 664 struct snd_soc_card *card;
663 struct list_head pins; 665 struct list_head pins;
664 int status; 666 int status;
665 struct blocking_notifier_head notifier; 667 struct blocking_notifier_head notifier;
@@ -954,6 +956,9 @@ struct snd_soc_dai_link {
954 unsigned int symmetric_channels:1; 956 unsigned int symmetric_channels:1;
955 unsigned int symmetric_samplebits:1; 957 unsigned int symmetric_samplebits:1;
956 958
959 /* Mark this pcm with non atomic ops */
960 bool nonatomic;
961
957 /* Do not create a PCM for this DAI link (Backend link) */ 962 /* Do not create a PCM for this DAI link (Backend link) */
958 unsigned int no_pcm:1; 963 unsigned int no_pcm:1;
959 964
@@ -1071,11 +1076,16 @@ struct snd_soc_card {
1071 1076
1072 /* 1077 /*
1073 * Card-specific routes and widgets. 1078 * Card-specific routes and widgets.
1079 * Note: of_dapm_xxx for Device Tree; Otherwise for driver build-in.
1074 */ 1080 */
1075 const struct snd_soc_dapm_widget *dapm_widgets; 1081 const struct snd_soc_dapm_widget *dapm_widgets;
1076 int num_dapm_widgets; 1082 int num_dapm_widgets;
1077 const struct snd_soc_dapm_route *dapm_routes; 1083 const struct snd_soc_dapm_route *dapm_routes;
1078 int num_dapm_routes; 1084 int num_dapm_routes;
1085 const struct snd_soc_dapm_widget *of_dapm_widgets;
1086 int num_of_dapm_widgets;
1087 const struct snd_soc_dapm_route *of_dapm_routes;
1088 int num_of_dapm_routes;
1079 bool fully_routed; 1089 bool fully_routed;
1080 1090
1081 struct work_struct deferred_resume_work; 1091 struct work_struct deferred_resume_work;
diff --git a/include/xen/xen-ops.h b/include/xen/xen-ops.h
index 7491ee5d8164..83338210ee04 100644
--- a/include/xen/xen-ops.h
+++ b/include/xen/xen-ops.h
@@ -46,4 +46,30 @@ static inline efi_system_table_t __init *xen_efi_probe(void)
46} 46}
47#endif 47#endif
48 48
49#ifdef CONFIG_PREEMPT
50
51static inline void xen_preemptible_hcall_begin(void)
52{
53}
54
55static inline void xen_preemptible_hcall_end(void)
56{
57}
58
59#else
60
61DECLARE_PER_CPU(bool, xen_in_preemptible_hcall);
62
63static inline void xen_preemptible_hcall_begin(void)
64{
65 __this_cpu_write(xen_in_preemptible_hcall, true);
66}
67
68static inline void xen_preemptible_hcall_end(void)
69{
70 __this_cpu_write(xen_in_preemptible_hcall, false);
71}
72
73#endif /* CONFIG_PREEMPT */
74
49#endif /* INCLUDE_XEN_OPS_H */ 75#endif /* INCLUDE_XEN_OPS_H */
diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
index ff7f47d026ac..782172f073c5 100644
--- a/kernel/livepatch/core.c
+++ b/kernel/livepatch/core.c
@@ -314,12 +314,12 @@ static void notrace klp_ftrace_handler(unsigned long ip,
314 rcu_read_lock(); 314 rcu_read_lock();
315 func = list_first_or_null_rcu(&ops->func_stack, struct klp_func, 315 func = list_first_or_null_rcu(&ops->func_stack, struct klp_func,
316 stack_node); 316 stack_node);
317 rcu_read_unlock();
318
319 if (WARN_ON_ONCE(!func)) 317 if (WARN_ON_ONCE(!func))
320 return; 318 goto unlock;
321 319
322 klp_arch_set_pc(regs, (unsigned long)func->new_func); 320 klp_arch_set_pc(regs, (unsigned long)func->new_func);
321unlock:
322 rcu_read_unlock();
323} 323}
324 324
325static int klp_disable_func(struct klp_func *func) 325static int klp_disable_func(struct klp_func *func)
@@ -731,7 +731,7 @@ static int klp_init_func(struct klp_object *obj, struct klp_func *func)
731 func->state = KLP_DISABLED; 731 func->state = KLP_DISABLED;
732 732
733 return kobject_init_and_add(&func->kobj, &klp_ktype_func, 733 return kobject_init_and_add(&func->kobj, &klp_ktype_func,
734 obj->kobj, func->old_name); 734 obj->kobj, "%s", func->old_name);
735} 735}
736 736
737/* parts of the initialization that is done only when the object is loaded */ 737/* parts of the initialization that is done only when the object is loaded */
@@ -807,7 +807,7 @@ static int klp_init_patch(struct klp_patch *patch)
807 patch->state = KLP_DISABLED; 807 patch->state = KLP_DISABLED;
808 808
809 ret = kobject_init_and_add(&patch->kobj, &klp_ktype_patch, 809 ret = kobject_init_and_add(&patch->kobj, &klp_ktype_patch,
810 klp_root_kobj, patch->mod->name); 810 klp_root_kobj, "%s", patch->mod->name);
811 if (ret) 811 if (ret)
812 goto unlock; 812 goto unlock;
813 813
diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
index e16e5542bf13..6357265a31ad 100644
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -1193,6 +1193,7 @@ rt_mutex_slowlock(struct rt_mutex *lock, int state,
1193 ret = __rt_mutex_slowlock(lock, state, timeout, &waiter); 1193 ret = __rt_mutex_slowlock(lock, state, timeout, &waiter);
1194 1194
1195 if (unlikely(ret)) { 1195 if (unlikely(ret)) {
1196 __set_current_state(TASK_RUNNING);
1196 if (rt_mutex_has_waiters(lock)) 1197 if (rt_mutex_has_waiters(lock))
1197 remove_waiter(lock, &waiter); 1198 remove_waiter(lock, &waiter);
1198 rt_mutex_handle_deadlock(ret, chwalk, &waiter); 1199 rt_mutex_handle_deadlock(ret, chwalk, &waiter);
diff --git a/kernel/sys.c b/kernel/sys.c
index 667b2e62fad2..a03d9cd23ed7 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1108,6 +1108,7 @@ DECLARE_RWSEM(uts_sem);
1108/* 1108/*
1109 * Work around broken programs that cannot handle "Linux 3.0". 1109 * Work around broken programs that cannot handle "Linux 3.0".
1110 * Instead we map 3.x to 2.6.40+x, so e.g. 3.0 would be 2.6.40 1110 * Instead we map 3.x to 2.6.40+x, so e.g. 3.0 would be 2.6.40
1111 * And we map 4.x to 2.6.60+x, so 4.0 would be 2.6.60.
1111 */ 1112 */
1112static int override_release(char __user *release, size_t len) 1113static int override_release(char __user *release, size_t len)
1113{ 1114{
@@ -1127,7 +1128,7 @@ static int override_release(char __user *release, size_t len)
1127 break; 1128 break;
1128 rest++; 1129 rest++;
1129 } 1130 }
1130 v = ((LINUX_VERSION_CODE >> 8) & 0xff) + 40; 1131 v = ((LINUX_VERSION_CODE >> 8) & 0xff) + 60;
1131 copy = clamp_t(size_t, len, 1, sizeof(buf)); 1132 copy = clamp_t(size_t, len, 1, sizeof(buf));
1132 copy = scnprintf(buf, copy, "2.6.%u%s", v, rest); 1133 copy = scnprintf(buf, copy, "2.6.%u%s", v, rest);
1133 ret = copy_to_user(release, buf, copy + 1); 1134 ret = copy_to_user(release, buf, copy + 1);
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index d18d3a6e7337..9fe07692eaad 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5247,7 +5247,7 @@ static int memory_low_show(struct seq_file *m, void *v)
5247 unsigned long low = ACCESS_ONCE(memcg->low); 5247 unsigned long low = ACCESS_ONCE(memcg->low);
5248 5248
5249 if (low == PAGE_COUNTER_MAX) 5249 if (low == PAGE_COUNTER_MAX)
5250 seq_puts(m, "infinity\n"); 5250 seq_puts(m, "max\n");
5251 else 5251 else
5252 seq_printf(m, "%llu\n", (u64)low * PAGE_SIZE); 5252 seq_printf(m, "%llu\n", (u64)low * PAGE_SIZE);
5253 5253
@@ -5262,7 +5262,7 @@ static ssize_t memory_low_write(struct kernfs_open_file *of,
5262 int err; 5262 int err;
5263 5263
5264 buf = strstrip(buf); 5264 buf = strstrip(buf);
5265 err = page_counter_memparse(buf, "infinity", &low); 5265 err = page_counter_memparse(buf, "max", &low);
5266 if (err) 5266 if (err)
5267 return err; 5267 return err;
5268 5268
@@ -5277,7 +5277,7 @@ static int memory_high_show(struct seq_file *m, void *v)
5277 unsigned long high = ACCESS_ONCE(memcg->high); 5277 unsigned long high = ACCESS_ONCE(memcg->high);
5278 5278
5279 if (high == PAGE_COUNTER_MAX) 5279 if (high == PAGE_COUNTER_MAX)
5280 seq_puts(m, "infinity\n"); 5280 seq_puts(m, "max\n");
5281 else 5281 else
5282 seq_printf(m, "%llu\n", (u64)high * PAGE_SIZE); 5282 seq_printf(m, "%llu\n", (u64)high * PAGE_SIZE);
5283 5283
@@ -5292,7 +5292,7 @@ static ssize_t memory_high_write(struct kernfs_open_file *of,
5292 int err; 5292 int err;
5293 5293
5294 buf = strstrip(buf); 5294 buf = strstrip(buf);
5295 err = page_counter_memparse(buf, "infinity", &high); 5295 err = page_counter_memparse(buf, "max", &high);
5296 if (err) 5296 if (err)
5297 return err; 5297 return err;
5298 5298
@@ -5307,7 +5307,7 @@ static int memory_max_show(struct seq_file *m, void *v)
5307 unsigned long max = ACCESS_ONCE(memcg->memory.limit); 5307 unsigned long max = ACCESS_ONCE(memcg->memory.limit);
5308 5308
5309 if (max == PAGE_COUNTER_MAX) 5309 if (max == PAGE_COUNTER_MAX)
5310 seq_puts(m, "infinity\n"); 5310 seq_puts(m, "max\n");
5311 else 5311 else
5312 seq_printf(m, "%llu\n", (u64)max * PAGE_SIZE); 5312 seq_printf(m, "%llu\n", (u64)max * PAGE_SIZE);
5313 5313
@@ -5322,7 +5322,7 @@ static ssize_t memory_max_write(struct kernfs_open_file *of,
5322 int err; 5322 int err;
5323 5323
5324 buf = strstrip(buf); 5324 buf = strstrip(buf);
5325 err = page_counter_memparse(buf, "infinity", &max); 5325 err = page_counter_memparse(buf, "max", &max);
5326 if (err) 5326 if (err)
5327 return err; 5327 return err;
5328 5328
@@ -5426,7 +5426,7 @@ bool mem_cgroup_low(struct mem_cgroup *root, struct mem_cgroup *memcg)
5426 if (memcg == root_mem_cgroup) 5426 if (memcg == root_mem_cgroup)
5427 return false; 5427 return false;
5428 5428
5429 if (page_counter_read(&memcg->memory) > memcg->low) 5429 if (page_counter_read(&memcg->memory) >= memcg->low)
5430 return false; 5430 return false;
5431 5431
5432 while (memcg != root) { 5432 while (memcg != root) {
@@ -5435,7 +5435,7 @@ bool mem_cgroup_low(struct mem_cgroup *root, struct mem_cgroup *memcg)
5435 if (memcg == root_mem_cgroup) 5435 if (memcg == root_mem_cgroup)
5436 break; 5436 break;
5437 5437
5438 if (page_counter_read(&memcg->memory) > memcg->low) 5438 if (page_counter_read(&memcg->memory) >= memcg->low)
5439 return false; 5439 return false;
5440 } 5440 }
5441 return true; 5441 return true;
diff --git a/mm/nommu.c b/mm/nommu.c
index 7296360fc057..3e67e7538ecf 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -1213,11 +1213,9 @@ static int do_mmap_private(struct vm_area_struct *vma,
1213 if (sysctl_nr_trim_pages && total - point >= sysctl_nr_trim_pages) { 1213 if (sysctl_nr_trim_pages && total - point >= sysctl_nr_trim_pages) {
1214 total = point; 1214 total = point;
1215 kdebug("try to alloc exact %lu pages", total); 1215 kdebug("try to alloc exact %lu pages", total);
1216 base = alloc_pages_exact(len, GFP_KERNEL);
1217 } else {
1218 base = (void *)__get_free_pages(GFP_KERNEL, order);
1219 } 1216 }
1220 1217
1218 base = alloc_pages_exact(total << PAGE_SHIFT, GFP_KERNEL);
1221 if (!base) 1219 if (!base)
1222 goto enomem; 1220 goto enomem;
1223 1221
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index a47f0b229a1a..7abfa70cdc1a 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2353,8 +2353,15 @@ __alloc_pages_may_oom(gfp_t gfp_mask, unsigned int order,
2353 if (ac->high_zoneidx < ZONE_NORMAL) 2353 if (ac->high_zoneidx < ZONE_NORMAL)
2354 goto out; 2354 goto out;
2355 /* The OOM killer does not compensate for light reclaim */ 2355 /* The OOM killer does not compensate for light reclaim */
2356 if (!(gfp_mask & __GFP_FS)) 2356 if (!(gfp_mask & __GFP_FS)) {
2357 /*
2358 * XXX: Page reclaim didn't yield anything,
2359 * and the OOM killer can't be invoked, but
2360 * keep looping as per should_alloc_retry().
2361 */
2362 *did_some_progress = 1;
2357 goto out; 2363 goto out;
2364 }
2358 /* 2365 /*
2359 * GFP_THISNODE contains __GFP_NORETRY and we never hit this. 2366 * GFP_THISNODE contains __GFP_NORETRY and we never hit this.
2360 * Sanity check for bare calls of __GFP_THISNODE, not real OOM. 2367 * Sanity check for bare calls of __GFP_THISNODE, not real OOM.
diff --git a/mm/shmem.c b/mm/shmem.c
index 2f17cb5f00a4..cf2d0ca010bc 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1455,6 +1455,9 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode
1455 1455
1456bool shmem_mapping(struct address_space *mapping) 1456bool shmem_mapping(struct address_space *mapping)
1457{ 1457{
1458 if (!mapping->host)
1459 return false;
1460
1458 return mapping->host->i_sb->s_op == &shmem_ops; 1461 return mapping->host->i_sb->s_op == &shmem_ops;
1459} 1462}
1460 1463
diff --git a/scripts/gdb/linux/__init__.py b/scripts/gdb/linux/__init__.py
new file mode 100644
index 000000000000..4680fb176337
--- /dev/null
+++ b/scripts/gdb/linux/__init__.py
@@ -0,0 +1 @@
# nothing to do for the initialization of this package
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 9c2c6f801fed..abe1e811e660 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -1585,6 +1585,8 @@ static int snd_pcm_do_drain_init(struct snd_pcm_substream *substream, int state)
1585 if (! snd_pcm_playback_empty(substream)) { 1585 if (! snd_pcm_playback_empty(substream)) {
1586 snd_pcm_do_start(substream, SNDRV_PCM_STATE_DRAINING); 1586 snd_pcm_do_start(substream, SNDRV_PCM_STATE_DRAINING);
1587 snd_pcm_post_start(substream, SNDRV_PCM_STATE_DRAINING); 1587 snd_pcm_post_start(substream, SNDRV_PCM_STATE_DRAINING);
1588 } else {
1589 runtime->status->state = SNDRV_PCM_STATE_SETUP;
1588 } 1590 }
1589 break; 1591 break;
1590 case SNDRV_PCM_STATE_RUNNING: 1592 case SNDRV_PCM_STATE_RUNNING:
diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c
index ebb7a644bd86..f63d2cb55a82 100644
--- a/sound/pci/hda/hda_controller.c
+++ b/sound/pci/hda/hda_controller.c
@@ -978,7 +978,6 @@ static int azx_alloc_cmd_io(struct azx *chip)
978 dev_err(chip->card->dev, "cannot allocate CORB/RIRB\n"); 978 dev_err(chip->card->dev, "cannot allocate CORB/RIRB\n");
979 return err; 979 return err;
980} 980}
981EXPORT_SYMBOL_GPL(azx_alloc_cmd_io);
982 981
983static void azx_init_cmd_io(struct azx *chip) 982static void azx_init_cmd_io(struct azx *chip)
984{ 983{
@@ -1043,7 +1042,6 @@ static void azx_init_cmd_io(struct azx *chip)
1043 azx_writeb(chip, RIRBCTL, AZX_RBCTL_DMA_EN | AZX_RBCTL_IRQ_EN); 1042 azx_writeb(chip, RIRBCTL, AZX_RBCTL_DMA_EN | AZX_RBCTL_IRQ_EN);
1044 spin_unlock_irq(&chip->reg_lock); 1043 spin_unlock_irq(&chip->reg_lock);
1045} 1044}
1046EXPORT_SYMBOL_GPL(azx_init_cmd_io);
1047 1045
1048static void azx_free_cmd_io(struct azx *chip) 1046static void azx_free_cmd_io(struct azx *chip)
1049{ 1047{
@@ -1053,7 +1051,6 @@ static void azx_free_cmd_io(struct azx *chip)
1053 azx_writeb(chip, CORBCTL, 0); 1051 azx_writeb(chip, CORBCTL, 0);
1054 spin_unlock_irq(&chip->reg_lock); 1052 spin_unlock_irq(&chip->reg_lock);
1055} 1053}
1056EXPORT_SYMBOL_GPL(azx_free_cmd_io);
1057 1054
1058static unsigned int azx_command_addr(u32 cmd) 1055static unsigned int azx_command_addr(u32 cmd)
1059{ 1056{
@@ -1333,7 +1330,6 @@ static int azx_send_cmd(struct hda_bus *bus, unsigned int val)
1333 else 1330 else
1334 return azx_corb_send_cmd(bus, val); 1331 return azx_corb_send_cmd(bus, val);
1335} 1332}
1336EXPORT_SYMBOL_GPL(azx_send_cmd);
1337 1333
1338/* get a response */ 1334/* get a response */
1339static unsigned int azx_get_response(struct hda_bus *bus, 1335static unsigned int azx_get_response(struct hda_bus *bus,
@@ -1347,7 +1343,6 @@ static unsigned int azx_get_response(struct hda_bus *bus,
1347 else 1343 else
1348 return azx_rirb_get_response(bus, addr); 1344 return azx_rirb_get_response(bus, addr);
1349} 1345}
1350EXPORT_SYMBOL_GPL(azx_get_response);
1351 1346
1352#ifdef CONFIG_SND_HDA_DSP_LOADER 1347#ifdef CONFIG_SND_HDA_DSP_LOADER
1353/* 1348/*
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 5e00cc4a722f..4614cb1f9582 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -1965,7 +1965,7 @@ static const struct pci_device_id azx_ids[] = {
1965 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH_NOPM }, 1965 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH_NOPM },
1966 /* Panther Point */ 1966 /* Panther Point */
1967 { PCI_DEVICE(0x8086, 0x1e20), 1967 { PCI_DEVICE(0x8086, 0x1e20),
1968 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH }, 1968 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH_NOPM },
1969 /* Lynx Point */ 1969 /* Lynx Point */
1970 { PCI_DEVICE(0x8086, 0x8c20), 1970 { PCI_DEVICE(0x8086, 0x8c20),
1971 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH }, 1971 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH },
diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c
index fb0b7e8b08ff..841d05946b88 100644
--- a/sound/soc/atmel/atmel_ssc_dai.c
+++ b/sound/soc/atmel/atmel_ssc_dai.c
@@ -187,6 +187,94 @@ static irqreturn_t atmel_ssc_interrupt(int irq, void *dev_id)
187 return IRQ_HANDLED; 187 return IRQ_HANDLED;
188} 188}
189 189
190/*
191 * When the bit clock is input, limit the maximum rate according to the
192 * Serial Clock Ratio Considerations section from the SSC documentation:
193 *
194 * The Transmitter and the Receiver can be programmed to operate
195 * with the clock signals provided on either the TK or RK pins.
196 * This allows the SSC to support many slave-mode data transfers.
197 * In this case, the maximum clock speed allowed on the RK pin is:
198 * - Peripheral clock divided by 2 if Receiver Frame Synchro is input
199 * - Peripheral clock divided by 3 if Receiver Frame Synchro is output
200 * In addition, the maximum clock speed allowed on the TK pin is:
201 * - Peripheral clock divided by 6 if Transmit Frame Synchro is input
202 * - Peripheral clock divided by 2 if Transmit Frame Synchro is output
203 *
204 * When the bit clock is output, limit the rate according to the
205 * SSC divider restrictions.
206 */
207static int atmel_ssc_hw_rule_rate(struct snd_pcm_hw_params *params,
208 struct snd_pcm_hw_rule *rule)
209{
210 struct atmel_ssc_info *ssc_p = rule->private;
211 struct ssc_device *ssc = ssc_p->ssc;
212 struct snd_interval *i = hw_param_interval(params, rule->var);
213 struct snd_interval t;
214 struct snd_ratnum r = {
215 .den_min = 1,
216 .den_max = 4095,
217 .den_step = 1,
218 };
219 unsigned int num = 0, den = 0;
220 int frame_size;
221 int mck_div = 2;
222 int ret;
223
224 frame_size = snd_soc_params_to_frame_size(params);
225 if (frame_size < 0)
226 return frame_size;
227
228 switch (ssc_p->daifmt & SND_SOC_DAIFMT_MASTER_MASK) {
229 case SND_SOC_DAIFMT_CBM_CFS:
230 if ((ssc_p->dir_mask & SSC_DIR_MASK_CAPTURE)
231 && ssc->clk_from_rk_pin)
232 /* Receiver Frame Synchro (i.e. capture)
233 * is output (format is _CFS) and the RK pin
234 * is used for input (format is _CBM_).
235 */
236 mck_div = 3;
237 break;
238
239 case SND_SOC_DAIFMT_CBM_CFM:
240 if ((ssc_p->dir_mask & SSC_DIR_MASK_PLAYBACK)
241 && !ssc->clk_from_rk_pin)
242 /* Transmit Frame Synchro (i.e. playback)
243 * is input (format is _CFM) and the TK pin
244 * is used for input (format _CBM_ but not
245 * using the RK pin).
246 */
247 mck_div = 6;
248 break;
249 }
250
251 switch (ssc_p->daifmt & SND_SOC_DAIFMT_MASTER_MASK) {
252 case SND_SOC_DAIFMT_CBS_CFS:
253 r.num = ssc_p->mck_rate / mck_div / frame_size;
254
255 ret = snd_interval_ratnum(i, 1, &r, &num, &den);
256 if (ret >= 0 && den && rule->var == SNDRV_PCM_HW_PARAM_RATE) {
257 params->rate_num = num;
258 params->rate_den = den;
259 }
260 break;
261
262 case SND_SOC_DAIFMT_CBM_CFS:
263 case SND_SOC_DAIFMT_CBM_CFM:
264 t.min = 8000;
265 t.max = ssc_p->mck_rate / mck_div / frame_size;
266 t.openmin = t.openmax = 0;
267 t.integer = 0;
268 ret = snd_interval_refine(i, &t);
269 break;
270
271 default:
272 ret = -EINVAL;
273 break;
274 }
275
276 return ret;
277}
190 278
191/*-------------------------------------------------------------------------*\ 279/*-------------------------------------------------------------------------*\
192 * DAI functions 280 * DAI functions
@@ -200,6 +288,7 @@ static int atmel_ssc_startup(struct snd_pcm_substream *substream,
200 struct atmel_ssc_info *ssc_p = &ssc_info[dai->id]; 288 struct atmel_ssc_info *ssc_p = &ssc_info[dai->id];
201 struct atmel_pcm_dma_params *dma_params; 289 struct atmel_pcm_dma_params *dma_params;
202 int dir, dir_mask; 290 int dir, dir_mask;
291 int ret;
203 292
204 pr_debug("atmel_ssc_startup: SSC_SR=0x%u\n", 293 pr_debug("atmel_ssc_startup: SSC_SR=0x%u\n",
205 ssc_readl(ssc_p->ssc->regs, SR)); 294 ssc_readl(ssc_p->ssc->regs, SR));
@@ -207,6 +296,7 @@ static int atmel_ssc_startup(struct snd_pcm_substream *substream,
207 /* Enable PMC peripheral clock for this SSC */ 296 /* Enable PMC peripheral clock for this SSC */
208 pr_debug("atmel_ssc_dai: Starting clock\n"); 297 pr_debug("atmel_ssc_dai: Starting clock\n");
209 clk_enable(ssc_p->ssc->clk); 298 clk_enable(ssc_p->ssc->clk);
299 ssc_p->mck_rate = clk_get_rate(ssc_p->ssc->clk);
210 300
211 /* Reset the SSC to keep it at a clean status */ 301 /* Reset the SSC to keep it at a clean status */
212 ssc_writel(ssc_p->ssc->regs, CR, SSC_BIT(CR_SWRST)); 302 ssc_writel(ssc_p->ssc->regs, CR, SSC_BIT(CR_SWRST));
@@ -219,6 +309,17 @@ static int atmel_ssc_startup(struct snd_pcm_substream *substream,
219 dir_mask = SSC_DIR_MASK_CAPTURE; 309 dir_mask = SSC_DIR_MASK_CAPTURE;
220 } 310 }
221 311
312 ret = snd_pcm_hw_rule_add(substream->runtime, 0,
313 SNDRV_PCM_HW_PARAM_RATE,
314 atmel_ssc_hw_rule_rate,
315 ssc_p,
316 SNDRV_PCM_HW_PARAM_FRAME_BITS,
317 SNDRV_PCM_HW_PARAM_CHANNELS, -1);
318 if (ret < 0) {
319 dev_err(dai->dev, "Failed to specify rate rule: %d\n", ret);
320 return ret;
321 }
322
222 dma_params = &ssc_dma_params[dai->id][dir]; 323 dma_params = &ssc_dma_params[dai->id][dir];
223 dma_params->ssc = ssc_p->ssc; 324 dma_params->ssc = ssc_p->ssc;
224 dma_params->substream = substream; 325 dma_params->substream = substream;
@@ -783,8 +884,6 @@ static int atmel_ssc_resume(struct snd_soc_dai *cpu_dai)
783# define atmel_ssc_resume NULL 884# define atmel_ssc_resume NULL
784#endif /* CONFIG_PM */ 885#endif /* CONFIG_PM */
785 886
786#define ATMEL_SSC_RATES (SNDRV_PCM_RATE_8000_96000)
787
788#define ATMEL_SSC_FORMATS (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE |\ 887#define ATMEL_SSC_FORMATS (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE |\
789 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) 888 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
790 889
@@ -804,12 +903,16 @@ static struct snd_soc_dai_driver atmel_ssc_dai = {
804 .playback = { 903 .playback = {
805 .channels_min = 1, 904 .channels_min = 1,
806 .channels_max = 2, 905 .channels_max = 2,
807 .rates = ATMEL_SSC_RATES, 906 .rates = SNDRV_PCM_RATE_CONTINUOUS,
907 .rate_min = 8000,
908 .rate_max = 384000,
808 .formats = ATMEL_SSC_FORMATS,}, 909 .formats = ATMEL_SSC_FORMATS,},
809 .capture = { 910 .capture = {
810 .channels_min = 1, 911 .channels_min = 1,
811 .channels_max = 2, 912 .channels_max = 2,
812 .rates = ATMEL_SSC_RATES, 913 .rates = SNDRV_PCM_RATE_CONTINUOUS,
914 .rate_min = 8000,
915 .rate_max = 384000,
813 .formats = ATMEL_SSC_FORMATS,}, 916 .formats = ATMEL_SSC_FORMATS,},
814 .ops = &atmel_ssc_dai_ops, 917 .ops = &atmel_ssc_dai_ops,
815}; 918};
diff --git a/sound/soc/atmel/atmel_ssc_dai.h b/sound/soc/atmel/atmel_ssc_dai.h
index b1f08d511495..80b153857a88 100644
--- a/sound/soc/atmel/atmel_ssc_dai.h
+++ b/sound/soc/atmel/atmel_ssc_dai.h
@@ -115,6 +115,7 @@ struct atmel_ssc_info {
115 unsigned short rcmr_period; 115 unsigned short rcmr_period;
116 struct atmel_pcm_dma_params *dma_params[2]; 116 struct atmel_pcm_dma_params *dma_params[2];
117 struct atmel_ssc_state ssc_state; 117 struct atmel_ssc_state ssc_state;
118 unsigned long mck_rate;
118}; 119};
119 120
120int atmel_ssc_set_audio(int ssc_id); 121int atmel_ssc_set_audio(int ssc_id);
diff --git a/sound/soc/atmel/sam9g20_wm8731.c b/sound/soc/atmel/sam9g20_wm8731.c
index f5ad214663f9..8de836165cf2 100644
--- a/sound/soc/atmel/sam9g20_wm8731.c
+++ b/sound/soc/atmel/sam9g20_wm8731.c
@@ -46,8 +46,6 @@
46#include <sound/pcm_params.h> 46#include <sound/pcm_params.h>
47#include <sound/soc.h> 47#include <sound/soc.h>
48 48
49#include <asm/mach-types.h>
50
51#include "../codecs/wm8731.h" 49#include "../codecs/wm8731.h"
52#include "atmel-pcm.h" 50#include "atmel-pcm.h"
53#include "atmel_ssc_dai.h" 51#include "atmel_ssc_dai.h"
@@ -171,9 +169,7 @@ static int at91sam9g20ek_audio_probe(struct platform_device *pdev)
171 int ret; 169 int ret;
172 170
173 if (!np) { 171 if (!np) {
174 if (!(machine_is_at91sam9g20ek() || 172 return -ENODEV;
175 machine_is_at91sam9g20ek_2mmc()))
176 return -ENODEV;
177 } 173 }
178 174
179 ret = atmel_ssc_set_audio(0); 175 ret = atmel_ssc_set_audio(0);
@@ -210,39 +206,37 @@ static int at91sam9g20ek_audio_probe(struct platform_device *pdev)
210 card->dev = &pdev->dev; 206 card->dev = &pdev->dev;
211 207
212 /* Parse device node info */ 208 /* Parse device node info */
213 if (np) { 209 ret = snd_soc_of_parse_card_name(card, "atmel,model");
214 ret = snd_soc_of_parse_card_name(card, "atmel,model"); 210 if (ret)
215 if (ret) 211 goto err;
216 goto err; 212
217 213 ret = snd_soc_of_parse_audio_routing(card,
218 ret = snd_soc_of_parse_audio_routing(card, 214 "atmel,audio-routing");
219 "atmel,audio-routing"); 215 if (ret)
220 if (ret) 216 goto err;
221 goto err; 217
222 218 /* Parse codec info */
223 /* Parse codec info */ 219 at91sam9g20ek_dai.codec_name = NULL;
224 at91sam9g20ek_dai.codec_name = NULL; 220 codec_np = of_parse_phandle(np, "atmel,audio-codec", 0);
225 codec_np = of_parse_phandle(np, "atmel,audio-codec", 0); 221 if (!codec_np) {
226 if (!codec_np) { 222 dev_err(&pdev->dev, "codec info missing\n");
227 dev_err(&pdev->dev, "codec info missing\n"); 223 return -EINVAL;
228 return -EINVAL; 224 }
229 } 225 at91sam9g20ek_dai.codec_of_node = codec_np;
230 at91sam9g20ek_dai.codec_of_node = codec_np; 226
231 227 /* Parse dai and platform info */
232 /* Parse dai and platform info */ 228 at91sam9g20ek_dai.cpu_dai_name = NULL;
233 at91sam9g20ek_dai.cpu_dai_name = NULL; 229 at91sam9g20ek_dai.platform_name = NULL;
234 at91sam9g20ek_dai.platform_name = NULL; 230 cpu_np = of_parse_phandle(np, "atmel,ssc-controller", 0);
235 cpu_np = of_parse_phandle(np, "atmel,ssc-controller", 0); 231 if (!cpu_np) {
236 if (!cpu_np) { 232 dev_err(&pdev->dev, "dai and pcm info missing\n");
237 dev_err(&pdev->dev, "dai and pcm info missing\n"); 233 return -EINVAL;
238 return -EINVAL;
239 }
240 at91sam9g20ek_dai.cpu_of_node = cpu_np;
241 at91sam9g20ek_dai.platform_of_node = cpu_np;
242
243 of_node_put(codec_np);
244 of_node_put(cpu_np);
245 } 234 }
235 at91sam9g20ek_dai.cpu_of_node = cpu_np;
236 at91sam9g20ek_dai.platform_of_node = cpu_np;
237
238 of_node_put(codec_np);
239 of_node_put(cpu_np);
246 240
247 ret = snd_soc_register_card(card); 241 ret = snd_soc_register_card(card);
248 if (ret) { 242 if (ret) {
diff --git a/sound/soc/cirrus/Kconfig b/sound/soc/cirrus/Kconfig
index 7b7fbcd49e5e..c7cd60f009e9 100644
--- a/sound/soc/cirrus/Kconfig
+++ b/sound/soc/cirrus/Kconfig
@@ -16,7 +16,7 @@ config SND_EP93XX_SOC_AC97
16 16
17config SND_EP93XX_SOC_SNAPPERCL15 17config SND_EP93XX_SOC_SNAPPERCL15
18 tristate "SoC Audio support for Bluewater Systems Snapper CL15 module" 18 tristate "SoC Audio support for Bluewater Systems Snapper CL15 module"
19 depends on SND_EP93XX_SOC && MACH_SNAPPER_CL15 19 depends on SND_EP93XX_SOC && MACH_SNAPPER_CL15 && I2C
20 select SND_EP93XX_SOC_I2S 20 select SND_EP93XX_SOC_I2S
21 select SND_SOC_TLV320AIC23_I2C 21 select SND_SOC_TLV320AIC23_I2C
22 help 22 help
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 064e6c18e109..0bddd929837f 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -69,7 +69,7 @@ config SND_SOC_ALL_CODECS
69 select SND_SOC_MAX98088 if I2C 69 select SND_SOC_MAX98088 if I2C
70 select SND_SOC_MAX98090 if I2C 70 select SND_SOC_MAX98090 if I2C
71 select SND_SOC_MAX98095 if I2C 71 select SND_SOC_MAX98095 if I2C
72 select SND_SOC_MAX98357A 72 select SND_SOC_MAX98357A if GPIOLIB
73 select SND_SOC_MAX9850 if I2C 73 select SND_SOC_MAX9850 if I2C
74 select SND_SOC_MAX9768 if I2C 74 select SND_SOC_MAX9768 if I2C
75 select SND_SOC_MAX9877 if I2C 75 select SND_SOC_MAX9877 if I2C
@@ -141,7 +141,8 @@ config SND_SOC_ALL_CODECS
141 select SND_SOC_WM8770 if SPI_MASTER 141 select SND_SOC_WM8770 if SPI_MASTER
142 select SND_SOC_WM8776 if SND_SOC_I2C_AND_SPI 142 select SND_SOC_WM8776 if SND_SOC_I2C_AND_SPI
143 select SND_SOC_WM8782 143 select SND_SOC_WM8782
144 select SND_SOC_WM8804 if SND_SOC_I2C_AND_SPI 144 select SND_SOC_WM8804_I2C if I2C
145 select SND_SOC_WM8804_SPI if SPI_MASTER
145 select SND_SOC_WM8900 if I2C 146 select SND_SOC_WM8900 if I2C
146 select SND_SOC_WM8903 if I2C 147 select SND_SOC_WM8903 if I2C
147 select SND_SOC_WM8904 if I2C 148 select SND_SOC_WM8904 if I2C
@@ -744,8 +745,19 @@ config SND_SOC_WM8782
744 tristate 745 tristate
745 746
746config SND_SOC_WM8804 747config SND_SOC_WM8804
747 tristate "Wolfson Microelectronics WM8804 S/PDIF transceiver" 748 tristate
748 depends on SND_SOC_I2C_AND_SPI 749
750config SND_SOC_WM8804_I2C
751 tristate "Wolfson Microelectronics WM8804 S/PDIF transceiver I2C"
752 depends on I2C
753 select SND_SOC_WM8804
754 select REGMAP_I2C
755
756config SND_SOC_WM8804_SPI
757 tristate "Wolfson Microelectronics WM8804 S/PDIF transceiver SPI"
758 depends on SPI_MASTER
759 select SND_SOC_WM8804
760 select REGMAP_SPI
749 761
750config SND_SOC_WM8900 762config SND_SOC_WM8900
751 tristate 763 tristate
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index 69b8666d187a..7acb6c174cb4 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -145,6 +145,8 @@ snd-soc-wm8770-objs := wm8770.o
145snd-soc-wm8776-objs := wm8776.o 145snd-soc-wm8776-objs := wm8776.o
146snd-soc-wm8782-objs := wm8782.o 146snd-soc-wm8782-objs := wm8782.o
147snd-soc-wm8804-objs := wm8804.o 147snd-soc-wm8804-objs := wm8804.o
148snd-soc-wm8804-i2c-objs := wm8804-i2c.o
149snd-soc-wm8804-spi-objs := wm8804-spi.o
148snd-soc-wm8900-objs := wm8900.o 150snd-soc-wm8900-objs := wm8900.o
149snd-soc-wm8903-objs := wm8903.o 151snd-soc-wm8903-objs := wm8903.o
150snd-soc-wm8904-objs := wm8904.o 152snd-soc-wm8904-objs := wm8904.o
@@ -323,6 +325,8 @@ obj-$(CONFIG_SND_SOC_WM8770) += snd-soc-wm8770.o
323obj-$(CONFIG_SND_SOC_WM8776) += snd-soc-wm8776.o 325obj-$(CONFIG_SND_SOC_WM8776) += snd-soc-wm8776.o
324obj-$(CONFIG_SND_SOC_WM8782) += snd-soc-wm8782.o 326obj-$(CONFIG_SND_SOC_WM8782) += snd-soc-wm8782.o
325obj-$(CONFIG_SND_SOC_WM8804) += snd-soc-wm8804.o 327obj-$(CONFIG_SND_SOC_WM8804) += snd-soc-wm8804.o
328obj-$(CONFIG_SND_SOC_WM8804_I2C) += snd-soc-wm8804-i2c.o
329obj-$(CONFIG_SND_SOC_WM8804_SPI) += snd-soc-wm8804-spi.o
326obj-$(CONFIG_SND_SOC_WM8900) += snd-soc-wm8900.o 330obj-$(CONFIG_SND_SOC_WM8900) += snd-soc-wm8900.o
327obj-$(CONFIG_SND_SOC_WM8903) += snd-soc-wm8903.o 331obj-$(CONFIG_SND_SOC_WM8903) += snd-soc-wm8903.o
328obj-$(CONFIG_SND_SOC_WM8904) += snd-soc-wm8904.o 332obj-$(CONFIG_SND_SOC_WM8904) += snd-soc-wm8904.o
diff --git a/sound/soc/codecs/adau1977.c b/sound/soc/codecs/adau1977.c
index 70ab35744aba..7ad8e156e2df 100644
--- a/sound/soc/codecs/adau1977.c
+++ b/sound/soc/codecs/adau1977.c
@@ -938,22 +938,15 @@ int adau1977_probe(struct device *dev, struct regmap *regmap,
938 adau1977->dvdd_reg = NULL; 938 adau1977->dvdd_reg = NULL;
939 } 939 }
940 940
941 adau1977->reset_gpio = devm_gpiod_get(dev, "reset"); 941 adau1977->reset_gpio = devm_gpiod_get_optional(dev, "reset",
942 if (IS_ERR(adau1977->reset_gpio)) { 942 GPIOD_OUT_LOW);
943 ret = PTR_ERR(adau1977->reset_gpio); 943 if (IS_ERR(adau1977->reset_gpio))
944 if (ret != -ENOENT && ret != -ENOSYS) 944 return PTR_ERR(adau1977->reset_gpio);
945 return PTR_ERR(adau1977->reset_gpio);
946 adau1977->reset_gpio = NULL;
947 }
948 945
949 dev_set_drvdata(dev, adau1977); 946 dev_set_drvdata(dev, adau1977);
950 947
951 if (adau1977->reset_gpio) { 948 if (adau1977->reset_gpio)
952 ret = gpiod_direction_output(adau1977->reset_gpio, 0);
953 if (ret)
954 return ret;
955 ndelay(100); 949 ndelay(100);
956 }
957 950
958 ret = adau1977_power_enable(adau1977); 951 ret = adau1977_power_enable(adau1977);
959 if (ret) 952 if (ret)
diff --git a/sound/soc/codecs/cs35l32.c b/sound/soc/codecs/cs35l32.c
index f2b8aad21274..60598b230341 100644
--- a/sound/soc/codecs/cs35l32.c
+++ b/sound/soc/codecs/cs35l32.c
@@ -437,20 +437,13 @@ static int cs35l32_i2c_probe(struct i2c_client *i2c_client,
437 } 437 }
438 438
439 /* Reset the Device */ 439 /* Reset the Device */
440 cs35l32->reset_gpio = devm_gpiod_get(&i2c_client->dev, 440 cs35l32->reset_gpio = devm_gpiod_get_optional(&i2c_client->dev,
441 "reset-gpios"); 441 "reset", GPIOD_OUT_LOW);
442 if (IS_ERR(cs35l32->reset_gpio)) { 442 if (IS_ERR(cs35l32->reset_gpio))
443 ret = PTR_ERR(cs35l32->reset_gpio); 443 return PTR_ERR(cs35l32->reset_gpio);
444 if (ret != -ENOENT && ret != -ENOSYS) 444
445 return ret; 445 if (cs35l32->reset_gpio)
446
447 cs35l32->reset_gpio = NULL;
448 } else {
449 ret = gpiod_direction_output(cs35l32->reset_gpio, 0);
450 if (ret)
451 return ret;
452 gpiod_set_value_cansleep(cs35l32->reset_gpio, 1); 446 gpiod_set_value_cansleep(cs35l32->reset_gpio, 1);
453 }
454 447
455 /* initialize codec */ 448 /* initialize codec */
456 ret = regmap_read(cs35l32->regmap, CS35L32_DEVID_AB, &reg); 449 ret = regmap_read(cs35l32->regmap, CS35L32_DEVID_AB, &reg);
diff --git a/sound/soc/codecs/cs4265.c b/sound/soc/codecs/cs4265.c
index ce6086835ebd..cac48ddf3ba6 100644
--- a/sound/soc/codecs/cs4265.c
+++ b/sound/soc/codecs/cs4265.c
@@ -605,21 +605,14 @@ static int cs4265_i2c_probe(struct i2c_client *i2c_client,
605 return ret; 605 return ret;
606 } 606 }
607 607
608 cs4265->reset_gpio = devm_gpiod_get(&i2c_client->dev, 608 cs4265->reset_gpio = devm_gpiod_get_optional(&i2c_client->dev,
609 "reset-gpios"); 609 "reset", GPIOD_OUT_LOW);
610 if (IS_ERR(cs4265->reset_gpio)) { 610 if (IS_ERR(cs4265->reset_gpio))
611 ret = PTR_ERR(cs4265->reset_gpio); 611 return PTR_ERR(cs4265->reset_gpio);
612 if (ret != -ENOENT && ret != -ENOSYS) 612
613 return ret; 613 if (cs4265->reset_gpio) {
614
615 cs4265->reset_gpio = NULL;
616 } else {
617 ret = gpiod_direction_output(cs4265->reset_gpio, 0);
618 if (ret)
619 return ret;
620 mdelay(1); 614 mdelay(1);
621 gpiod_set_value_cansleep(cs4265->reset_gpio, 1); 615 gpiod_set_value_cansleep(cs4265->reset_gpio, 1);
622
623 } 616 }
624 617
625 i2c_set_clientdata(i2c_client, cs4265); 618 i2c_set_clientdata(i2c_client, cs4265);
diff --git a/sound/soc/codecs/max98357a.c b/sound/soc/codecs/max98357a.c
index 1806333ea29e..bf3e933ee895 100644
--- a/sound/soc/codecs/max98357a.c
+++ b/sound/soc/codecs/max98357a.c
@@ -12,11 +12,19 @@
12 * max98357a.c -- MAX98357A ALSA SoC Codec driver 12 * max98357a.c -- MAX98357A ALSA SoC Codec driver
13 */ 13 */
14 14
15#include <linux/module.h> 15#include <linux/device.h>
16#include <linux/err.h>
16#include <linux/gpio.h> 17#include <linux/gpio.h>
18#include <linux/gpio/consumer.h>
19#include <linux/kernel.h>
20#include <linux/mod_devicetable.h>
21#include <linux/module.h>
22#include <linux/of.h>
23#include <linux/platform_device.h>
24#include <sound/pcm.h>
17#include <sound/soc.h> 25#include <sound/soc.h>
18 26#include <sound/soc-dai.h>
19#define DRV_NAME "max98357a" 27#include <sound/soc-dapm.h>
20 28
21static int max98357a_daiops_trigger(struct snd_pcm_substream *substream, 29static int max98357a_daiops_trigger(struct snd_pcm_substream *substream,
22 int cmd, struct snd_soc_dai *dai) 30 int cmd, struct snd_soc_dai *dai)
@@ -77,9 +85,9 @@ static struct snd_soc_dai_ops max98357a_dai_ops = {
77}; 85};
78 86
79static struct snd_soc_dai_driver max98357a_dai_driver = { 87static struct snd_soc_dai_driver max98357a_dai_driver = {
80 .name = DRV_NAME, 88 .name = "HiFi",
81 .playback = { 89 .playback = {
82 .stream_name = DRV_NAME "-playback", 90 .stream_name = "HiFi Playback",
83 .formats = SNDRV_PCM_FMTBIT_S16 | 91 .formats = SNDRV_PCM_FMTBIT_S16 |
84 SNDRV_PCM_FMTBIT_S24 | 92 SNDRV_PCM_FMTBIT_S24 |
85 SNDRV_PCM_FMTBIT_S32, 93 SNDRV_PCM_FMTBIT_S32,
@@ -117,7 +125,7 @@ static int max98357a_platform_remove(struct platform_device *pdev)
117 125
118#ifdef CONFIG_OF 126#ifdef CONFIG_OF
119static const struct of_device_id max98357a_device_id[] = { 127static const struct of_device_id max98357a_device_id[] = {
120 { .compatible = "maxim," DRV_NAME, }, 128 { .compatible = "maxim,max98357a" },
121 {} 129 {}
122}; 130};
123MODULE_DEVICE_TABLE(of, max98357a_device_id); 131MODULE_DEVICE_TABLE(of, max98357a_device_id);
@@ -125,7 +133,7 @@ MODULE_DEVICE_TABLE(of, max98357a_device_id);
125 133
126static struct platform_driver max98357a_platform_driver = { 134static struct platform_driver max98357a_platform_driver = {
127 .driver = { 135 .driver = {
128 .name = DRV_NAME, 136 .name = "max98357a",
129 .of_match_table = of_match_ptr(max98357a_device_id), 137 .of_match_table = of_match_ptr(max98357a_device_id),
130 }, 138 },
131 .probe = max98357a_platform_probe, 139 .probe = max98357a_platform_probe,
@@ -135,4 +143,3 @@ module_platform_driver(max98357a_platform_driver);
135 143
136MODULE_DESCRIPTION("Maxim MAX98357A Codec Driver"); 144MODULE_DESCRIPTION("Maxim MAX98357A Codec Driver");
137MODULE_LICENSE("GPL v2"); 145MODULE_LICENSE("GPL v2");
138MODULE_ALIAS("platform:" DRV_NAME);
diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c
index 9974f201a08f..4b5f1fe9be97 100644
--- a/sound/soc/codecs/pcm512x.c
+++ b/sound/soc/codecs/pcm512x.c
@@ -54,6 +54,9 @@ struct pcm512x_priv {
54 int pll_d; 54 int pll_d;
55 int pll_p; 55 int pll_p;
56 unsigned long real_pll; 56 unsigned long real_pll;
57 unsigned long overclock_pll;
58 unsigned long overclock_dac;
59 unsigned long overclock_dsp;
57}; 60};
58 61
59/* 62/*
@@ -224,6 +227,90 @@ static bool pcm512x_volatile(struct device *dev, unsigned int reg)
224 } 227 }
225} 228}
226 229
230static int pcm512x_overclock_pll_get(struct snd_kcontrol *kcontrol,
231 struct snd_ctl_elem_value *ucontrol)
232{
233 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
234 struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec);
235
236 ucontrol->value.integer.value[0] = pcm512x->overclock_pll;
237 return 0;
238}
239
240static int pcm512x_overclock_pll_put(struct snd_kcontrol *kcontrol,
241 struct snd_ctl_elem_value *ucontrol)
242{
243 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
244 struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec);
245
246 switch (codec->dapm.bias_level) {
247 case SND_SOC_BIAS_OFF:
248 case SND_SOC_BIAS_STANDBY:
249 break;
250 default:
251 return -EBUSY;
252 }
253
254 pcm512x->overclock_pll = ucontrol->value.integer.value[0];
255 return 0;
256}
257
258static int pcm512x_overclock_dsp_get(struct snd_kcontrol *kcontrol,
259 struct snd_ctl_elem_value *ucontrol)
260{
261 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
262 struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec);
263
264 ucontrol->value.integer.value[0] = pcm512x->overclock_dsp;
265 return 0;
266}
267
268static int pcm512x_overclock_dsp_put(struct snd_kcontrol *kcontrol,
269 struct snd_ctl_elem_value *ucontrol)
270{
271 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
272 struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec);
273
274 switch (codec->dapm.bias_level) {
275 case SND_SOC_BIAS_OFF:
276 case SND_SOC_BIAS_STANDBY:
277 break;
278 default:
279 return -EBUSY;
280 }
281
282 pcm512x->overclock_dsp = ucontrol->value.integer.value[0];
283 return 0;
284}
285
286static int pcm512x_overclock_dac_get(struct snd_kcontrol *kcontrol,
287 struct snd_ctl_elem_value *ucontrol)
288{
289 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
290 struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec);
291
292 ucontrol->value.integer.value[0] = pcm512x->overclock_dac;
293 return 0;
294}
295
296static int pcm512x_overclock_dac_put(struct snd_kcontrol *kcontrol,
297 struct snd_ctl_elem_value *ucontrol)
298{
299 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
300 struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec);
301
302 switch (codec->dapm.bias_level) {
303 case SND_SOC_BIAS_OFF:
304 case SND_SOC_BIAS_STANDBY:
305 break;
306 default:
307 return -EBUSY;
308 }
309
310 pcm512x->overclock_dac = ucontrol->value.integer.value[0];
311 return 0;
312}
313
227static const DECLARE_TLV_DB_SCALE(digital_tlv, -10350, 50, 1); 314static const DECLARE_TLV_DB_SCALE(digital_tlv, -10350, 50, 1);
228static const DECLARE_TLV_DB_SCALE(analog_tlv, -600, 600, 0); 315static const DECLARE_TLV_DB_SCALE(analog_tlv, -600, 600, 0);
229static const DECLARE_TLV_DB_SCALE(boost_tlv, 0, 80, 0); 316static const DECLARE_TLV_DB_SCALE(boost_tlv, 0, 80, 0);
@@ -328,6 +415,13 @@ SOC_ENUM("Volume Ramp Up Rate", pcm512x_vnuf),
328SOC_ENUM("Volume Ramp Up Step", pcm512x_vnus), 415SOC_ENUM("Volume Ramp Up Step", pcm512x_vnus),
329SOC_ENUM("Volume Ramp Down Emergency Rate", pcm512x_vedf), 416SOC_ENUM("Volume Ramp Down Emergency Rate", pcm512x_vedf),
330SOC_ENUM("Volume Ramp Down Emergency Step", pcm512x_veds), 417SOC_ENUM("Volume Ramp Down Emergency Step", pcm512x_veds),
418
419SOC_SINGLE_EXT("Max Overclock PLL", SND_SOC_NOPM, 0, 20, 0,
420 pcm512x_overclock_pll_get, pcm512x_overclock_pll_put),
421SOC_SINGLE_EXT("Max Overclock DSP", SND_SOC_NOPM, 0, 40, 0,
422 pcm512x_overclock_dsp_get, pcm512x_overclock_dsp_put),
423SOC_SINGLE_EXT("Max Overclock DAC", SND_SOC_NOPM, 0, 40, 0,
424 pcm512x_overclock_dac_get, pcm512x_overclock_dac_put),
331}; 425};
332 426
333static const struct snd_soc_dapm_widget pcm512x_dapm_widgets[] = { 427static const struct snd_soc_dapm_widget pcm512x_dapm_widgets[] = {
@@ -346,6 +440,45 @@ static const struct snd_soc_dapm_route pcm512x_dapm_routes[] = {
346 { "OUTR", NULL, "DACR" }, 440 { "OUTR", NULL, "DACR" },
347}; 441};
348 442
443static unsigned long pcm512x_pll_max(struct pcm512x_priv *pcm512x)
444{
445 return 25000000 + 25000000 * pcm512x->overclock_pll / 100;
446}
447
448static unsigned long pcm512x_dsp_max(struct pcm512x_priv *pcm512x)
449{
450 return 50000000 + 50000000 * pcm512x->overclock_dsp / 100;
451}
452
453static unsigned long pcm512x_dac_max(struct pcm512x_priv *pcm512x,
454 unsigned long rate)
455{
456 return rate + rate * pcm512x->overclock_dac / 100;
457}
458
459static unsigned long pcm512x_sck_max(struct pcm512x_priv *pcm512x)
460{
461 if (!pcm512x->pll_out)
462 return 25000000;
463 return pcm512x_pll_max(pcm512x);
464}
465
466static unsigned long pcm512x_ncp_target(struct pcm512x_priv *pcm512x,
467 unsigned long dac_rate)
468{
469 /*
470 * If the DAC is not actually overclocked, use the good old
471 * NCP target rate...
472 */
473 if (dac_rate <= 6144000)
474 return 1536000;
475 /*
476 * ...but if the DAC is in fact overclocked, bump the NCP target
477 * rate to get the recommended dividers even when overclocking.
478 */
479 return pcm512x_dac_max(pcm512x, 1536000);
480}
481
349static const u32 pcm512x_dai_rates[] = { 482static const u32 pcm512x_dai_rates[] = {
350 8000, 11025, 16000, 22050, 32000, 44100, 48000, 64000, 483 8000, 11025, 16000, 22050, 32000, 44100, 48000, 64000,
351 88200, 96000, 176400, 192000, 384000, 484 88200, 96000, 176400, 192000, 384000,
@@ -359,6 +492,7 @@ static const struct snd_pcm_hw_constraint_list constraints_slave = {
359static int pcm512x_hw_rule_rate(struct snd_pcm_hw_params *params, 492static int pcm512x_hw_rule_rate(struct snd_pcm_hw_params *params,
360 struct snd_pcm_hw_rule *rule) 493 struct snd_pcm_hw_rule *rule)
361{ 494{
495 struct pcm512x_priv *pcm512x = rule->private;
362 struct snd_interval ranges[2]; 496 struct snd_interval ranges[2];
363 int frame_size; 497 int frame_size;
364 498
@@ -377,7 +511,7 @@ static int pcm512x_hw_rule_rate(struct snd_pcm_hw_params *params,
377 */ 511 */
378 memset(ranges, 0, sizeof(ranges)); 512 memset(ranges, 0, sizeof(ranges));
379 ranges[0].min = 8000; 513 ranges[0].min = 8000;
380 ranges[0].max = 25000000 / frame_size / 2; 514 ranges[0].max = pcm512x_sck_max(pcm512x) / frame_size / 2;
381 ranges[1].min = DIV_ROUND_UP(16000000, frame_size); 515 ranges[1].min = DIV_ROUND_UP(16000000, frame_size);
382 ranges[1].max = 384000; 516 ranges[1].max = 384000;
383 break; 517 break;
@@ -408,7 +542,7 @@ static int pcm512x_dai_startup_master(struct snd_pcm_substream *substream,
408 return snd_pcm_hw_rule_add(substream->runtime, 0, 542 return snd_pcm_hw_rule_add(substream->runtime, 0,
409 SNDRV_PCM_HW_PARAM_RATE, 543 SNDRV_PCM_HW_PARAM_RATE,
410 pcm512x_hw_rule_rate, 544 pcm512x_hw_rule_rate,
411 NULL, 545 pcm512x,
412 SNDRV_PCM_HW_PARAM_FRAME_BITS, 546 SNDRV_PCM_HW_PARAM_FRAME_BITS,
413 SNDRV_PCM_HW_PARAM_CHANNELS, -1); 547 SNDRV_PCM_HW_PARAM_CHANNELS, -1);
414 548
@@ -517,6 +651,8 @@ static unsigned long pcm512x_find_sck(struct snd_soc_dai *dai,
517 unsigned long bclk_rate) 651 unsigned long bclk_rate)
518{ 652{
519 struct device *dev = dai->dev; 653 struct device *dev = dai->dev;
654 struct snd_soc_codec *codec = dai->codec;
655 struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec);
520 unsigned long sck_rate; 656 unsigned long sck_rate;
521 int pow2; 657 int pow2;
522 658
@@ -527,9 +663,10 @@ static unsigned long pcm512x_find_sck(struct snd_soc_dai *dai,
527 * as many factors of 2 as possible, as that makes it easier 663 * as many factors of 2 as possible, as that makes it easier
528 * to find a fast DAC rate 664 * to find a fast DAC rate
529 */ 665 */
530 pow2 = 1 << fls((25000000 - 16000000) / bclk_rate); 666 pow2 = 1 << fls((pcm512x_pll_max(pcm512x) - 16000000) / bclk_rate);
531 for (; pow2; pow2 >>= 1) { 667 for (; pow2; pow2 >>= 1) {
532 sck_rate = rounddown(25000000, bclk_rate * pow2); 668 sck_rate = rounddown(pcm512x_pll_max(pcm512x),
669 bclk_rate * pow2);
533 if (sck_rate >= 16000000) 670 if (sck_rate >= 16000000)
534 break; 671 break;
535 } 672 }
@@ -678,7 +815,7 @@ static unsigned long pcm512x_pllin_dac_rate(struct snd_soc_dai *dai,
678 return 0; /* futile, quit early */ 815 return 0; /* futile, quit early */
679 816
680 /* run DAC no faster than 6144000 Hz */ 817 /* run DAC no faster than 6144000 Hz */
681 for (dac_rate = rounddown(6144000, osr_rate); 818 for (dac_rate = rounddown(pcm512x_dac_max(pcm512x, 6144000), osr_rate);
682 dac_rate; 819 dac_rate;
683 dac_rate -= osr_rate) { 820 dac_rate -= osr_rate) {
684 821
@@ -805,7 +942,7 @@ static int pcm512x_set_dividers(struct snd_soc_dai *dai,
805 osr_rate = 16 * sample_rate; 942 osr_rate = 16 * sample_rate;
806 943
807 /* run DSP no faster than 50 MHz */ 944 /* run DSP no faster than 50 MHz */
808 dsp_div = mck_rate > 50000000 ? 2 : 1; 945 dsp_div = mck_rate > pcm512x_dsp_max(pcm512x) ? 2 : 1;
809 946
810 dac_rate = pcm512x_pllin_dac_rate(dai, osr_rate, pllin_rate); 947 dac_rate = pcm512x_pllin_dac_rate(dai, osr_rate, pllin_rate);
811 if (dac_rate) { 948 if (dac_rate) {
@@ -836,7 +973,8 @@ static int pcm512x_set_dividers(struct snd_soc_dai *dai,
836 dacsrc_rate = pllin_rate; 973 dacsrc_rate = pllin_rate;
837 } else { 974 } else {
838 /* run DAC no faster than 6144000 Hz */ 975 /* run DAC no faster than 6144000 Hz */
839 unsigned long dac_mul = 6144000 / osr_rate; 976 unsigned long dac_mul = pcm512x_dac_max(pcm512x, 6144000)
977 / osr_rate;
840 unsigned long sck_mul = sck_rate / osr_rate; 978 unsigned long sck_mul = sck_rate / osr_rate;
841 979
842 for (; dac_mul; dac_mul--) { 980 for (; dac_mul; dac_mul--) {
@@ -863,28 +1001,30 @@ static int pcm512x_set_dividers(struct snd_soc_dai *dai,
863 dacsrc_rate = sck_rate; 1001 dacsrc_rate = sck_rate;
864 } 1002 }
865 1003
1004 osr_div = DIV_ROUND_CLOSEST(dac_rate, osr_rate);
1005 if (osr_div > 128) {
1006 dev_err(dev, "Failed to find OSR divider\n");
1007 return -EINVAL;
1008 }
1009
866 dac_div = DIV_ROUND_CLOSEST(dacsrc_rate, dac_rate); 1010 dac_div = DIV_ROUND_CLOSEST(dacsrc_rate, dac_rate);
867 if (dac_div > 128) { 1011 if (dac_div > 128) {
868 dev_err(dev, "Failed to find DAC divider\n"); 1012 dev_err(dev, "Failed to find DAC divider\n");
869 return -EINVAL; 1013 return -EINVAL;
870 } 1014 }
1015 dac_rate = dacsrc_rate / dac_div;
871 1016
872 ncp_div = DIV_ROUND_CLOSEST(dacsrc_rate / dac_div, 1536000); 1017 ncp_div = DIV_ROUND_CLOSEST(dac_rate,
873 if (ncp_div > 128 || dacsrc_rate / dac_div / ncp_div > 2048000) { 1018 pcm512x_ncp_target(pcm512x, dac_rate));
1019 if (ncp_div > 128 || dac_rate / ncp_div > 2048000) {
874 /* run NCP no faster than 2048000 Hz, but why? */ 1020 /* run NCP no faster than 2048000 Hz, but why? */
875 ncp_div = DIV_ROUND_UP(dacsrc_rate / dac_div, 2048000); 1021 ncp_div = DIV_ROUND_UP(dac_rate, 2048000);
876 if (ncp_div > 128) { 1022 if (ncp_div > 128) {
877 dev_err(dev, "Failed to find NCP divider\n"); 1023 dev_err(dev, "Failed to find NCP divider\n");
878 return -EINVAL; 1024 return -EINVAL;
879 } 1025 }
880 } 1026 }
881 1027
882 osr_div = DIV_ROUND_CLOSEST(dac_rate, osr_rate);
883 if (osr_div > 128) {
884 dev_err(dev, "Failed to find OSR divider\n");
885 return -EINVAL;
886 }
887
888 idac = mck_rate / (dsp_div * sample_rate); 1028 idac = mck_rate / (dsp_div * sample_rate);
889 1029
890 ret = regmap_write(pcm512x->regmap, PCM512x_DSP_CLKDIV, dsp_div - 1); 1030 ret = regmap_write(pcm512x->regmap, PCM512x_DSP_CLKDIV, dsp_div - 1);
@@ -937,11 +1077,11 @@ static int pcm512x_set_dividers(struct snd_soc_dai *dai,
937 return ret; 1077 return ret;
938 } 1078 }
939 1079
940 if (sample_rate <= 48000) 1080 if (sample_rate <= pcm512x_dac_max(pcm512x, 48000))
941 fssp = PCM512x_FSSP_48KHZ; 1081 fssp = PCM512x_FSSP_48KHZ;
942 else if (sample_rate <= 96000) 1082 else if (sample_rate <= pcm512x_dac_max(pcm512x, 96000))
943 fssp = PCM512x_FSSP_96KHZ; 1083 fssp = PCM512x_FSSP_96KHZ;
944 else if (sample_rate <= 192000) 1084 else if (sample_rate <= pcm512x_dac_max(pcm512x, 192000))
945 fssp = PCM512x_FSSP_192KHZ; 1085 fssp = PCM512x_FSSP_192KHZ;
946 else 1086 else
947 fssp = PCM512x_FSSP_384KHZ; 1087 fssp = PCM512x_FSSP_384KHZ;
diff --git a/sound/soc/codecs/rt286.c b/sound/soc/codecs/rt286.c
index f374840a5a7c..16723b167fbf 100644
--- a/sound/soc/codecs/rt286.c
+++ b/sound/soc/codecs/rt286.c
@@ -395,9 +395,20 @@ int rt286_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack)
395 395
396 rt286->jack = jack; 396 rt286->jack = jack;
397 397
398 /* Send an initial empty report */ 398 if (jack) {
399 snd_soc_jack_report(rt286->jack, 0, 399 /* enable IRQ */
400 SND_JACK_MICROPHONE | SND_JACK_HEADPHONE); 400 if (rt286->jack->status | SND_JACK_HEADPHONE)
401 snd_soc_dapm_force_enable_pin(&codec->dapm, "LDO1");
402 regmap_update_bits(rt286->regmap, RT286_IRQ_CTRL, 0x2, 0x2);
403 /* Send an initial empty report */
404 snd_soc_jack_report(rt286->jack, rt286->jack->status,
405 SND_JACK_MICROPHONE | SND_JACK_HEADPHONE);
406 } else {
407 /* disable IRQ */
408 regmap_update_bits(rt286->regmap, RT286_IRQ_CTRL, 0x2, 0x0);
409 snd_soc_dapm_disable_pin(&codec->dapm, "LDO1");
410 }
411 snd_soc_dapm_sync(&codec->dapm);
401 412
402 return 0; 413 return 0;
403} 414}
diff --git a/sound/soc/codecs/rt5670.c b/sound/soc/codecs/rt5670.c
index e1a4a45c57e2..fd102613d20d 100644
--- a/sound/soc/codecs/rt5670.c
+++ b/sound/soc/codecs/rt5670.c
@@ -225,7 +225,6 @@ static bool rt5670_volatile_register(struct device *dev, unsigned int reg)
225 case RT5670_ADC_EQ_CTRL1: 225 case RT5670_ADC_EQ_CTRL1:
226 case RT5670_EQ_CTRL1: 226 case RT5670_EQ_CTRL1:
227 case RT5670_ALC_CTRL_1: 227 case RT5670_ALC_CTRL_1:
228 case RT5670_IRQ_CTRL1:
229 case RT5670_IRQ_CTRL2: 228 case RT5670_IRQ_CTRL2:
230 case RT5670_INT_IRQ_ST: 229 case RT5670_INT_IRQ_ST:
231 case RT5670_IL_CMD: 230 case RT5670_IL_CMD:
@@ -2703,6 +2702,12 @@ static int rt5670_i2c_probe(struct i2c_client *i2c,
2703 2702
2704 regmap_write(rt5670->regmap, RT5670_RESET, 0); 2703 regmap_write(rt5670->regmap, RT5670_RESET, 0);
2705 2704
2705 regmap_read(rt5670->regmap, RT5670_VENDOR_ID, &val);
2706 if (val >= 4)
2707 regmap_write(rt5670->regmap, RT5670_GPIO_CTRL3, 0x0980);
2708 else
2709 regmap_write(rt5670->regmap, RT5670_GPIO_CTRL3, 0x0d00);
2710
2706 ret = regmap_register_patch(rt5670->regmap, init_list, 2711 ret = regmap_register_patch(rt5670->regmap, init_list,
2707 ARRAY_SIZE(init_list)); 2712 ARRAY_SIZE(init_list));
2708 if (ret != 0) 2713 if (ret != 0)
diff --git a/sound/soc/codecs/rt5670.h b/sound/soc/codecs/rt5670.h
index 21f8e18c13c4..0a67adbcfbc3 100644
--- a/sound/soc/codecs/rt5670.h
+++ b/sound/soc/codecs/rt5670.h
@@ -1950,17 +1950,20 @@ enum {
1950}; 1950};
1951 1951
1952enum { 1952enum {
1953 RT5670_DMIC1_DISABLED,
1953 RT5670_DMIC_DATA_GPIO6, 1954 RT5670_DMIC_DATA_GPIO6,
1954 RT5670_DMIC_DATA_IN2P, 1955 RT5670_DMIC_DATA_IN2P,
1955 RT5670_DMIC_DATA_GPIO7, 1956 RT5670_DMIC_DATA_GPIO7,
1956}; 1957};
1957 1958
1958enum { 1959enum {
1960 RT5670_DMIC2_DISABLED,
1959 RT5670_DMIC_DATA_GPIO8, 1961 RT5670_DMIC_DATA_GPIO8,
1960 RT5670_DMIC_DATA_IN3N, 1962 RT5670_DMIC_DATA_IN3N,
1961}; 1963};
1962 1964
1963enum { 1965enum {
1966 RT5670_DMIC3_DISABLED,
1964 RT5670_DMIC_DATA_GPIO9, 1967 RT5670_DMIC_DATA_GPIO9,
1965 RT5670_DMIC_DATA_GPIO10, 1968 RT5670_DMIC_DATA_GPIO10,
1966 RT5670_DMIC_DATA_GPIO5, 1969 RT5670_DMIC_DATA_GPIO5,
diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c
index 5d0bb8748dd1..c2a6e4091357 100644
--- a/sound/soc/codecs/rt5677.c
+++ b/sound/soc/codecs/rt5677.c
@@ -718,11 +718,24 @@ static int rt5677_set_dsp_vad(struct snd_soc_codec *codec, bool on)
718 RT5677_LDO1_SEL_MASK, 0x0); 718 RT5677_LDO1_SEL_MASK, 0x0);
719 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2, 719 regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2,
720 RT5677_PWR_LDO1, RT5677_PWR_LDO1); 720 RT5677_PWR_LDO1, RT5677_PWR_LDO1);
721 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1, 721 switch (rt5677->type) {
722 RT5677_MCLK_SRC_MASK, RT5677_MCLK2_SRC); 722 case RT5677:
723 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK2, 723 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1,
724 RT5677_PLL2_PR_SRC_MASK | RT5677_DSP_CLK_SRC_MASK, 724 RT5677_MCLK_SRC_MASK, RT5677_MCLK2_SRC);
725 RT5677_PLL2_PR_SRC_MCLK2 | RT5677_DSP_CLK_SRC_BYPASS); 725 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK2,
726 RT5677_PLL2_PR_SRC_MASK |
727 RT5677_DSP_CLK_SRC_MASK,
728 RT5677_PLL2_PR_SRC_MCLK2 |
729 RT5677_DSP_CLK_SRC_BYPASS);
730 break;
731 case RT5676:
732 regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK2,
733 RT5677_DSP_CLK_SRC_MASK,
734 RT5677_DSP_CLK_SRC_BYPASS);
735 break;
736 default:
737 break;
738 }
726 regmap_write(rt5677->regmap, RT5677_PWR_DSP2, 0x07ff); 739 regmap_write(rt5677->regmap, RT5677_PWR_DSP2, 0x07ff);
727 regmap_write(rt5677->regmap, RT5677_PWR_DSP1, 0x07fd); 740 regmap_write(rt5677->regmap, RT5677_PWR_DSP1, 0x07fd);
728 rt5677_set_dsp_mode(codec, true); 741 rt5677_set_dsp_mode(codec, true);
@@ -3284,8 +3297,8 @@ static const struct snd_soc_dapm_route rt5677_dapm_routes[] = {
3284 { "IB45 Bypass Mux", "Bypass", "IB45 Mux" }, 3297 { "IB45 Bypass Mux", "Bypass", "IB45 Mux" },
3285 { "IB45 Bypass Mux", "Pass SRC", "IB45 Mux" }, 3298 { "IB45 Bypass Mux", "Pass SRC", "IB45 Mux" },
3286 3299
3287 { "IB6 Mux", "IF1 DAC 6", "IF1 DAC6" }, 3300 { "IB6 Mux", "IF1 DAC 6", "IF1 DAC6 Mux" },
3288 { "IB6 Mux", "IF2 DAC 6", "IF2 DAC6" }, 3301 { "IB6 Mux", "IF2 DAC 6", "IF2 DAC6 Mux" },
3289 { "IB6 Mux", "SLB DAC 6", "SLB DAC6" }, 3302 { "IB6 Mux", "SLB DAC 6", "SLB DAC6" },
3290 { "IB6 Mux", "STO4 ADC MIX L", "Stereo4 ADC MIXL" }, 3303 { "IB6 Mux", "STO4 ADC MIX L", "Stereo4 ADC MIXL" },
3291 { "IB6 Mux", "IF4 DAC L", "IF4 DAC L" }, 3304 { "IB6 Mux", "IF4 DAC L", "IF4 DAC L" },
@@ -3293,8 +3306,8 @@ static const struct snd_soc_dapm_route rt5677_dapm_routes[] = {
3293 { "IB6 Mux", "STO2 ADC MIX L", "Stereo2 ADC MIXL" }, 3306 { "IB6 Mux", "STO2 ADC MIX L", "Stereo2 ADC MIXL" },
3294 { "IB6 Mux", "STO3 ADC MIX L", "Stereo3 ADC MIXL" }, 3307 { "IB6 Mux", "STO3 ADC MIX L", "Stereo3 ADC MIXL" },
3295 3308
3296 { "IB7 Mux", "IF1 DAC 7", "IF1 DAC7" }, 3309 { "IB7 Mux", "IF1 DAC 7", "IF1 DAC7 Mux" },
3297 { "IB7 Mux", "IF2 DAC 7", "IF2 DAC7" }, 3310 { "IB7 Mux", "IF2 DAC 7", "IF2 DAC7 Mux" },
3298 { "IB7 Mux", "SLB DAC 7", "SLB DAC7" }, 3311 { "IB7 Mux", "SLB DAC 7", "SLB DAC7" },
3299 { "IB7 Mux", "STO4 ADC MIX R", "Stereo4 ADC MIXR" }, 3312 { "IB7 Mux", "STO4 ADC MIX R", "Stereo4 ADC MIXR" },
3300 { "IB7 Mux", "IF4 DAC R", "IF4 DAC R" }, 3313 { "IB7 Mux", "IF4 DAC R", "IF4 DAC R" },
@@ -3635,15 +3648,15 @@ static const struct snd_soc_dapm_route rt5677_dapm_routes[] = {
3635 { "DAC1 FS", NULL, "DAC1 MIXL" }, 3648 { "DAC1 FS", NULL, "DAC1 MIXL" },
3636 { "DAC1 FS", NULL, "DAC1 MIXR" }, 3649 { "DAC1 FS", NULL, "DAC1 MIXR" },
3637 3650
3638 { "DAC2 L Mux", "IF1 DAC 2", "IF1 DAC2" }, 3651 { "DAC2 L Mux", "IF1 DAC 2", "IF1 DAC2 Mux" },
3639 { "DAC2 L Mux", "IF2 DAC 2", "IF2 DAC2" }, 3652 { "DAC2 L Mux", "IF2 DAC 2", "IF2 DAC2 Mux" },
3640 { "DAC2 L Mux", "IF3 DAC L", "IF3 DAC L" }, 3653 { "DAC2 L Mux", "IF3 DAC L", "IF3 DAC L" },
3641 { "DAC2 L Mux", "IF4 DAC L", "IF4 DAC L" }, 3654 { "DAC2 L Mux", "IF4 DAC L", "IF4 DAC L" },
3642 { "DAC2 L Mux", "SLB DAC 2", "SLB DAC2" }, 3655 { "DAC2 L Mux", "SLB DAC 2", "SLB DAC2" },
3643 { "DAC2 L Mux", "OB 2", "OutBound2" }, 3656 { "DAC2 L Mux", "OB 2", "OutBound2" },
3644 3657
3645 { "DAC2 R Mux", "IF1 DAC 3", "IF1 DAC3" }, 3658 { "DAC2 R Mux", "IF1 DAC 3", "IF1 DAC3 Mux" },
3646 { "DAC2 R Mux", "IF2 DAC 3", "IF2 DAC3" }, 3659 { "DAC2 R Mux", "IF2 DAC 3", "IF2 DAC3 Mux" },
3647 { "DAC2 R Mux", "IF3 DAC R", "IF3 DAC R" }, 3660 { "DAC2 R Mux", "IF3 DAC R", "IF3 DAC R" },
3648 { "DAC2 R Mux", "IF4 DAC R", "IF4 DAC R" }, 3661 { "DAC2 R Mux", "IF4 DAC R", "IF4 DAC R" },
3649 { "DAC2 R Mux", "SLB DAC 3", "SLB DAC3" }, 3662 { "DAC2 R Mux", "SLB DAC 3", "SLB DAC3" },
@@ -3651,29 +3664,29 @@ static const struct snd_soc_dapm_route rt5677_dapm_routes[] = {
3651 { "DAC2 R Mux", "Haptic Generator", "Haptic Generator" }, 3664 { "DAC2 R Mux", "Haptic Generator", "Haptic Generator" },
3652 { "DAC2 R Mux", "VAD ADC", "VAD ADC Mux" }, 3665 { "DAC2 R Mux", "VAD ADC", "VAD ADC Mux" },
3653 3666
3654 { "DAC3 L Mux", "IF1 DAC 4", "IF1 DAC4" }, 3667 { "DAC3 L Mux", "IF1 DAC 4", "IF1 DAC4 Mux" },
3655 { "DAC3 L Mux", "IF2 DAC 4", "IF2 DAC4" }, 3668 { "DAC3 L Mux", "IF2 DAC 4", "IF2 DAC4 Mux" },
3656 { "DAC3 L Mux", "IF3 DAC L", "IF3 DAC L" }, 3669 { "DAC3 L Mux", "IF3 DAC L", "IF3 DAC L" },
3657 { "DAC3 L Mux", "IF4 DAC L", "IF4 DAC L" }, 3670 { "DAC3 L Mux", "IF4 DAC L", "IF4 DAC L" },
3658 { "DAC3 L Mux", "SLB DAC 4", "SLB DAC4" }, 3671 { "DAC3 L Mux", "SLB DAC 4", "SLB DAC4" },
3659 { "DAC3 L Mux", "OB 4", "OutBound4" }, 3672 { "DAC3 L Mux", "OB 4", "OutBound4" },
3660 3673
3661 { "DAC3 R Mux", "IF1 DAC 5", "IF1 DAC4" }, 3674 { "DAC3 R Mux", "IF1 DAC 5", "IF1 DAC5 Mux" },
3662 { "DAC3 R Mux", "IF2 DAC 5", "IF2 DAC4" }, 3675 { "DAC3 R Mux", "IF2 DAC 5", "IF2 DAC5 Mux" },
3663 { "DAC3 R Mux", "IF3 DAC R", "IF3 DAC R" }, 3676 { "DAC3 R Mux", "IF3 DAC R", "IF3 DAC R" },
3664 { "DAC3 R Mux", "IF4 DAC R", "IF4 DAC R" }, 3677 { "DAC3 R Mux", "IF4 DAC R", "IF4 DAC R" },
3665 { "DAC3 R Mux", "SLB DAC 5", "SLB DAC5" }, 3678 { "DAC3 R Mux", "SLB DAC 5", "SLB DAC5" },
3666 { "DAC3 R Mux", "OB 5", "OutBound5" }, 3679 { "DAC3 R Mux", "OB 5", "OutBound5" },
3667 3680
3668 { "DAC4 L Mux", "IF1 DAC 6", "IF1 DAC6" }, 3681 { "DAC4 L Mux", "IF1 DAC 6", "IF1 DAC6 Mux" },
3669 { "DAC4 L Mux", "IF2 DAC 6", "IF2 DAC6" }, 3682 { "DAC4 L Mux", "IF2 DAC 6", "IF2 DAC6 Mux" },
3670 { "DAC4 L Mux", "IF3 DAC L", "IF3 DAC L" }, 3683 { "DAC4 L Mux", "IF3 DAC L", "IF3 DAC L" },
3671 { "DAC4 L Mux", "IF4 DAC L", "IF4 DAC L" }, 3684 { "DAC4 L Mux", "IF4 DAC L", "IF4 DAC L" },
3672 { "DAC4 L Mux", "SLB DAC 6", "SLB DAC6" }, 3685 { "DAC4 L Mux", "SLB DAC 6", "SLB DAC6" },
3673 { "DAC4 L Mux", "OB 6", "OutBound6" }, 3686 { "DAC4 L Mux", "OB 6", "OutBound6" },
3674 3687
3675 { "DAC4 R Mux", "IF1 DAC 7", "IF1 DAC7" }, 3688 { "DAC4 R Mux", "IF1 DAC 7", "IF1 DAC7 Mux" },
3676 { "DAC4 R Mux", "IF2 DAC 7", "IF2 DAC7" }, 3689 { "DAC4 R Mux", "IF2 DAC 7", "IF2 DAC7 Mux" },
3677 { "DAC4 R Mux", "IF3 DAC R", "IF3 DAC R" }, 3690 { "DAC4 R Mux", "IF3 DAC R", "IF3 DAC R" },
3678 { "DAC4 R Mux", "IF4 DAC R", "IF4 DAC R" }, 3691 { "DAC4 R Mux", "IF4 DAC R", "IF4 DAC R" },
3679 { "DAC4 R Mux", "SLB DAC 7", "SLB DAC7" }, 3692 { "DAC4 R Mux", "SLB DAC 7", "SLB DAC7" },
@@ -4500,10 +4513,10 @@ static int rt5677_suspend(struct snd_soc_codec *codec)
4500 if (!rt5677->dsp_vad_en) { 4513 if (!rt5677->dsp_vad_en) {
4501 regcache_cache_only(rt5677->regmap, true); 4514 regcache_cache_only(rt5677->regmap, true);
4502 regcache_mark_dirty(rt5677->regmap); 4515 regcache_mark_dirty(rt5677->regmap);
4503 }
4504 4516
4505 if (gpio_is_valid(rt5677->pow_ldo2)) 4517 if (gpio_is_valid(rt5677->pow_ldo2))
4506 gpio_set_value_cansleep(rt5677->pow_ldo2, 0); 4518 gpio_set_value_cansleep(rt5677->pow_ldo2, 0);
4519 }
4507 4520
4508 return 0; 4521 return 0;
4509} 4522}
@@ -4512,12 +4525,12 @@ static int rt5677_resume(struct snd_soc_codec *codec)
4512{ 4525{
4513 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); 4526 struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec);
4514 4527
4515 if (gpio_is_valid(rt5677->pow_ldo2)) {
4516 gpio_set_value_cansleep(rt5677->pow_ldo2, 1);
4517 msleep(10);
4518 }
4519
4520 if (!rt5677->dsp_vad_en) { 4528 if (!rt5677->dsp_vad_en) {
4529 if (gpio_is_valid(rt5677->pow_ldo2)) {
4530 gpio_set_value_cansleep(rt5677->pow_ldo2, 1);
4531 msleep(10);
4532 }
4533
4521 regcache_cache_only(rt5677->regmap, false); 4534 regcache_cache_only(rt5677->regmap, false);
4522 regcache_sync(rt5677->regmap); 4535 regcache_sync(rt5677->regmap);
4523 } 4536 }
@@ -4733,7 +4746,8 @@ static const struct regmap_config rt5677_regmap = {
4733}; 4746};
4734 4747
4735static const struct i2c_device_id rt5677_i2c_id[] = { 4748static const struct i2c_device_id rt5677_i2c_id[] = {
4736 { "rt5677", 0 }, 4749 { "rt5677", RT5677 },
4750 { "rt5676", RT5676 },
4737 { } 4751 { }
4738}; 4752};
4739MODULE_DEVICE_TABLE(i2c, rt5677_i2c_id); 4753MODULE_DEVICE_TABLE(i2c, rt5677_i2c_id);
@@ -4850,6 +4864,8 @@ static int rt5677_i2c_probe(struct i2c_client *i2c,
4850 4864
4851 i2c_set_clientdata(i2c, rt5677); 4865 i2c_set_clientdata(i2c, rt5677);
4852 4866
4867 rt5677->type = id->driver_data;
4868
4853 if (pdata) 4869 if (pdata)
4854 rt5677->pdata = *pdata; 4870 rt5677->pdata = *pdata;
4855 4871
diff --git a/sound/soc/codecs/rt5677.h b/sound/soc/codecs/rt5677.h
index c0a625f290cc..07df96b43f59 100644
--- a/sound/soc/codecs/rt5677.h
+++ b/sound/soc/codecs/rt5677.h
@@ -1665,6 +1665,11 @@ enum {
1665 RT5677_IRQ_JD3, 1665 RT5677_IRQ_JD3,
1666}; 1666};
1667 1667
1668enum rt5677_type {
1669 RT5677,
1670 RT5676,
1671};
1672
1668struct rt5677_priv { 1673struct rt5677_priv {
1669 struct snd_soc_codec *codec; 1674 struct snd_soc_codec *codec;
1670 struct rt5677_platform_data pdata; 1675 struct rt5677_platform_data pdata;
@@ -1681,6 +1686,7 @@ struct rt5677_priv {
1681 int pll_in; 1686 int pll_in;
1682 int pll_out; 1687 int pll_out;
1683 int pow_ldo2; /* POW_LDO2 pin */ 1688 int pow_ldo2; /* POW_LDO2 pin */
1689 enum rt5677_type type;
1684#ifdef CONFIG_GPIOLIB 1690#ifdef CONFIG_GPIOLIB
1685 struct gpio_chip gpio_chip; 1691 struct gpio_chip gpio_chip;
1686#endif 1692#endif
diff --git a/sound/soc/codecs/sn95031.c b/sound/soc/codecs/sn95031.c
index 47b257e41809..1e5d2643c286 100644
--- a/sound/soc/codecs/sn95031.c
+++ b/sound/soc/codecs/sn95031.c
@@ -783,19 +783,21 @@ static inline void sn95031_enable_jack_btn(struct snd_soc_codec *codec)
783 snd_soc_write(codec, SN95031_BTNCTRL2, 0x01); 783 snd_soc_write(codec, SN95031_BTNCTRL2, 0x01);
784} 784}
785 785
786static int sn95031_get_headset_state(struct snd_soc_jack *mfld_jack) 786static int sn95031_get_headset_state(struct snd_soc_codec *codec,
787 struct snd_soc_jack *mfld_jack)
787{ 788{
788 int micbias = sn95031_get_mic_bias(mfld_jack->codec); 789 int micbias = sn95031_get_mic_bias(codec);
789 790
790 int jack_type = snd_soc_jack_get_type(mfld_jack, micbias); 791 int jack_type = snd_soc_jack_get_type(mfld_jack, micbias);
791 792
792 pr_debug("jack type detected = %d\n", jack_type); 793 pr_debug("jack type detected = %d\n", jack_type);
793 if (jack_type == SND_JACK_HEADSET) 794 if (jack_type == SND_JACK_HEADSET)
794 sn95031_enable_jack_btn(mfld_jack->codec); 795 sn95031_enable_jack_btn(codec);
795 return jack_type; 796 return jack_type;
796} 797}
797 798
798void sn95031_jack_detection(struct mfld_jack_data *jack_data) 799void sn95031_jack_detection(struct snd_soc_codec *codec,
800 struct mfld_jack_data *jack_data)
799{ 801{
800 unsigned int status; 802 unsigned int status;
801 unsigned int mask = SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_HEADSET; 803 unsigned int mask = SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_HEADSET;
@@ -809,11 +811,11 @@ void sn95031_jack_detection(struct mfld_jack_data *jack_data)
809 status = SND_JACK_HEADSET | SND_JACK_BTN_1; 811 status = SND_JACK_HEADSET | SND_JACK_BTN_1;
810 } else if (jack_data->intr_id & 0x4) { 812 } else if (jack_data->intr_id & 0x4) {
811 pr_debug("headset or headphones inserted\n"); 813 pr_debug("headset or headphones inserted\n");
812 status = sn95031_get_headset_state(jack_data->mfld_jack); 814 status = sn95031_get_headset_state(codec, jack_data->mfld_jack);
813 } else if (jack_data->intr_id & 0x8) { 815 } else if (jack_data->intr_id & 0x8) {
814 pr_debug("headset or headphones removed\n"); 816 pr_debug("headset or headphones removed\n");
815 status = 0; 817 status = 0;
816 sn95031_disable_jack_btn(jack_data->mfld_jack->codec); 818 sn95031_disable_jack_btn(codec);
817 } else { 819 } else {
818 pr_err("unidentified interrupt\n"); 820 pr_err("unidentified interrupt\n");
819 return; 821 return;
diff --git a/sound/soc/codecs/sn95031.h b/sound/soc/codecs/sn95031.h
index 20376d234fb8..7651fe4e6a45 100644
--- a/sound/soc/codecs/sn95031.h
+++ b/sound/soc/codecs/sn95031.h
@@ -127,6 +127,7 @@ struct mfld_jack_data {
127 struct snd_soc_jack *mfld_jack; 127 struct snd_soc_jack *mfld_jack;
128}; 128};
129 129
130extern void sn95031_jack_detection(struct mfld_jack_data *jack_data); 130extern void sn95031_jack_detection(struct snd_soc_codec *codec,
131 struct mfld_jack_data *jack_data);
131 132
132#endif 133#endif
diff --git a/sound/soc/codecs/sta32x.c b/sound/soc/codecs/sta32x.c
index 3a1343fa109b..007a0e3bc273 100644
--- a/sound/soc/codecs/sta32x.c
+++ b/sound/soc/codecs/sta32x.c
@@ -106,13 +106,11 @@ static const struct reg_default sta32x_regs[] = {
106}; 106};
107 107
108static const struct regmap_range sta32x_write_regs_range[] = { 108static const struct regmap_range sta32x_write_regs_range[] = {
109 regmap_reg_range(STA32X_CONFA, STA32X_AUTO2), 109 regmap_reg_range(STA32X_CONFA, STA32X_FDRC2),
110 regmap_reg_range(STA32X_C1CFG, STA32X_FDRC2),
111}; 110};
112 111
113static const struct regmap_range sta32x_read_regs_range[] = { 112static const struct regmap_range sta32x_read_regs_range[] = {
114 regmap_reg_range(STA32X_CONFA, STA32X_AUTO2), 113 regmap_reg_range(STA32X_CONFA, STA32X_FDRC2),
115 regmap_reg_range(STA32X_C1CFG, STA32X_FDRC2),
116}; 114};
117 115
118static const struct regmap_range sta32x_volatile_regs_range[] = { 116static const struct regmap_range sta32x_volatile_regs_range[] = {
diff --git a/sound/soc/codecs/sta350.c b/sound/soc/codecs/sta350.c
index bda2ee18769e..669e3228241e 100644
--- a/sound/soc/codecs/sta350.c
+++ b/sound/soc/codecs/sta350.c
@@ -1213,27 +1213,15 @@ static int sta350_i2c_probe(struct i2c_client *i2c,
1213#endif 1213#endif
1214 1214
1215 /* GPIOs */ 1215 /* GPIOs */
1216 sta350->gpiod_nreset = devm_gpiod_get(dev, "reset"); 1216 sta350->gpiod_nreset = devm_gpiod_get_optional(dev, "reset",
1217 if (IS_ERR(sta350->gpiod_nreset)) { 1217 GPIOD_OUT_LOW);
1218 ret = PTR_ERR(sta350->gpiod_nreset); 1218 if (IS_ERR(sta350->gpiod_nreset))
1219 if (ret != -ENOENT && ret != -ENOSYS) 1219 return PTR_ERR(sta350->gpiod_nreset);
1220 return ret; 1220
1221 1221 sta350->gpiod_power_down = devm_gpiod_get(dev, "power-down",
1222 sta350->gpiod_nreset = NULL; 1222 GPIOD_OUT_LOW);
1223 } else { 1223 if (IS_ERR(sta350->gpiod_power_down))
1224 gpiod_direction_output(sta350->gpiod_nreset, 0); 1224 return PTR_ERR(sta350->gpiod_power_down);
1225 }
1226
1227 sta350->gpiod_power_down = devm_gpiod_get(dev, "power-down");
1228 if (IS_ERR(sta350->gpiod_power_down)) {
1229 ret = PTR_ERR(sta350->gpiod_power_down);
1230 if (ret != -ENOENT && ret != -ENOSYS)
1231 return ret;
1232
1233 sta350->gpiod_power_down = NULL;
1234 } else {
1235 gpiod_direction_output(sta350->gpiod_power_down, 0);
1236 }
1237 1225
1238 /* regulators */ 1226 /* regulators */
1239 for (i = 0; i < ARRAY_SIZE(sta350->supplies); i++) 1227 for (i = 0; i < ARRAY_SIZE(sta350->supplies); i++)
diff --git a/sound/soc/codecs/tas2552.c b/sound/soc/codecs/tas2552.c
index ae23acdd2708..dfb4ff5cc9ea 100644
--- a/sound/soc/codecs/tas2552.c
+++ b/sound/soc/codecs/tas2552.c
@@ -485,16 +485,9 @@ static int tas2552_probe(struct i2c_client *client,
485 if (data == NULL) 485 if (data == NULL)
486 return -ENOMEM; 486 return -ENOMEM;
487 487
488 data->enable_gpio = devm_gpiod_get(dev, "enable"); 488 data->enable_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW);
489 if (IS_ERR(data->enable_gpio)) { 489 if (IS_ERR(data->enable_gpio))
490 ret = PTR_ERR(data->enable_gpio); 490 return PTR_ERR(data->enable_gpio);
491 if (ret != -ENOENT && ret != -ENOSYS)
492 return ret;
493
494 data->enable_gpio = NULL;
495 } else {
496 gpiod_direction_output(data->enable_gpio, 0);
497 }
498 491
499 data->tas2552_client = client; 492 data->tas2552_client = client;
500 data->regmap = devm_regmap_init_i2c(client, &tas2552_regmap_config); 493 data->regmap = devm_regmap_init_i2c(client, &tas2552_regmap_config);
diff --git a/sound/soc/codecs/wm8804-i2c.c b/sound/soc/codecs/wm8804-i2c.c
new file mode 100644
index 000000000000..5bd4af2b4059
--- /dev/null
+++ b/sound/soc/codecs/wm8804-i2c.c
@@ -0,0 +1,64 @@
1/*
2 * wm8804-i2c.c -- WM8804 S/PDIF transceiver driver - I2C
3 *
4 * Copyright 2015 Cirrus Logic Inc
5 *
6 * Author: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/init.h>
14#include <linux/module.h>
15#include <linux/i2c.h>
16
17#include "wm8804.h"
18
19static int wm8804_i2c_probe(struct i2c_client *i2c,
20 const struct i2c_device_id *id)
21{
22 struct regmap *regmap;
23
24 regmap = devm_regmap_init_i2c(i2c, &wm8804_regmap_config);
25 if (IS_ERR(regmap))
26 return PTR_ERR(regmap);
27
28 return wm8804_probe(&i2c->dev, regmap);
29}
30
31static int wm8804_i2c_remove(struct i2c_client *i2c)
32{
33 wm8804_remove(&i2c->dev);
34 return 0;
35}
36
37static const struct i2c_device_id wm8804_i2c_id[] = {
38 { "wm8804", 0 },
39 { }
40};
41MODULE_DEVICE_TABLE(i2c, wm8804_i2c_id);
42
43static const struct of_device_id wm8804_of_match[] = {
44 { .compatible = "wlf,wm8804", },
45 { }
46};
47MODULE_DEVICE_TABLE(of, wm8804_of_match);
48
49static struct i2c_driver wm8804_i2c_driver = {
50 .driver = {
51 .name = "wm8804",
52 .owner = THIS_MODULE,
53 .of_match_table = wm8804_of_match,
54 },
55 .probe = wm8804_i2c_probe,
56 .remove = wm8804_i2c_remove,
57 .id_table = wm8804_i2c_id
58};
59
60module_i2c_driver(wm8804_i2c_driver);
61
62MODULE_DESCRIPTION("ASoC WM8804 driver - I2C");
63MODULE_AUTHOR("Charles Keepax <ckeepax@opensource.wolfsonmicro.com>");
64MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/wm8804-spi.c b/sound/soc/codecs/wm8804-spi.c
new file mode 100644
index 000000000000..287e11e90794
--- /dev/null
+++ b/sound/soc/codecs/wm8804-spi.c
@@ -0,0 +1,56 @@
1/*
2 * wm8804-spi.c -- WM8804 S/PDIF transceiver driver - SPI
3 *
4 * Copyright 2015 Cirrus Logic Inc
5 *
6 * Author: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/init.h>
14#include <linux/module.h>
15#include <linux/spi/spi.h>
16
17#include "wm8804.h"
18
19static int wm8804_spi_probe(struct spi_device *spi)
20{
21 struct regmap *regmap;
22
23 regmap = devm_regmap_init_spi(spi, &wm8804_regmap_config);
24 if (IS_ERR(regmap))
25 return PTR_ERR(regmap);
26
27 return wm8804_probe(&spi->dev, regmap);
28}
29
30static int wm8804_spi_remove(struct spi_device *spi)
31{
32 wm8804_remove(&spi->dev);
33 return 0;
34}
35
36static const struct of_device_id wm8804_of_match[] = {
37 { .compatible = "wlf,wm8804", },
38 { }
39};
40MODULE_DEVICE_TABLE(of, wm8804_of_match);
41
42static struct spi_driver wm8804_spi_driver = {
43 .driver = {
44 .name = "wm8804",
45 .owner = THIS_MODULE,
46 .of_match_table = wm8804_of_match,
47 },
48 .probe = wm8804_spi_probe,
49 .remove = wm8804_spi_remove
50};
51
52module_spi_driver(wm8804_spi_driver);
53
54MODULE_DESCRIPTION("ASoC WM8804 driver - SPI");
55MODULE_AUTHOR("Charles Keepax <ckeepax@opensource.wolfsonmicro.com>");
56MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/wm8804.c b/sound/soc/codecs/wm8804.c
index b2b0e68f707e..1bd4ace29594 100644
--- a/sound/soc/codecs/wm8804.c
+++ b/sound/soc/codecs/wm8804.c
@@ -15,10 +15,7 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/pm.h> 17#include <linux/pm.h>
18#include <linux/i2c.h>
19#include <linux/of_device.h> 18#include <linux/of_device.h>
20#include <linux/spi/spi.h>
21#include <linux/regmap.h>
22#include <linux/regulator/consumer.h> 19#include <linux/regulator/consumer.h>
23#include <linux/slab.h> 20#include <linux/slab.h>
24#include <sound/core.h> 21#include <sound/core.h>
@@ -185,9 +182,9 @@ static bool wm8804_volatile(struct device *dev, unsigned int reg)
185 } 182 }
186} 183}
187 184
188static int wm8804_reset(struct snd_soc_codec *codec) 185static int wm8804_reset(struct wm8804_priv *wm8804)
189{ 186{
190 return snd_soc_write(codec, WM8804_RST_DEVID1, 0x0); 187 return regmap_write(wm8804->regmap, WM8804_RST_DEVID1, 0x0);
191} 188}
192 189
193static int wm8804_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) 190static int wm8804_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
@@ -518,100 +515,6 @@ static int wm8804_set_bias_level(struct snd_soc_codec *codec,
518 return 0; 515 return 0;
519} 516}
520 517
521static int wm8804_remove(struct snd_soc_codec *codec)
522{
523 struct wm8804_priv *wm8804;
524 int i;
525
526 wm8804 = snd_soc_codec_get_drvdata(codec);
527
528 for (i = 0; i < ARRAY_SIZE(wm8804->supplies); ++i)
529 regulator_unregister_notifier(wm8804->supplies[i].consumer,
530 &wm8804->disable_nb[i]);
531 return 0;
532}
533
534static int wm8804_probe(struct snd_soc_codec *codec)
535{
536 struct wm8804_priv *wm8804;
537 int i, id1, id2, ret;
538
539 wm8804 = snd_soc_codec_get_drvdata(codec);
540
541 for (i = 0; i < ARRAY_SIZE(wm8804->supplies); i++)
542 wm8804->supplies[i].supply = wm8804_supply_names[i];
543
544 ret = devm_regulator_bulk_get(codec->dev, ARRAY_SIZE(wm8804->supplies),
545 wm8804->supplies);
546 if (ret) {
547 dev_err(codec->dev, "Failed to request supplies: %d\n", ret);
548 return ret;
549 }
550
551 wm8804->disable_nb[0].notifier_call = wm8804_regulator_event_0;
552 wm8804->disable_nb[1].notifier_call = wm8804_regulator_event_1;
553
554 /* This should really be moved into the regulator core */
555 for (i = 0; i < ARRAY_SIZE(wm8804->supplies); i++) {
556 ret = regulator_register_notifier(wm8804->supplies[i].consumer,
557 &wm8804->disable_nb[i]);
558 if (ret != 0) {
559 dev_err(codec->dev,
560 "Failed to register regulator notifier: %d\n",
561 ret);
562 }
563 }
564
565 ret = regulator_bulk_enable(ARRAY_SIZE(wm8804->supplies),
566 wm8804->supplies);
567 if (ret) {
568 dev_err(codec->dev, "Failed to enable supplies: %d\n", ret);
569 return ret;
570 }
571
572 id1 = snd_soc_read(codec, WM8804_RST_DEVID1);
573 if (id1 < 0) {
574 dev_err(codec->dev, "Failed to read device ID: %d\n", id1);
575 ret = id1;
576 goto err_reg_enable;
577 }
578
579 id2 = snd_soc_read(codec, WM8804_DEVID2);
580 if (id2 < 0) {
581 dev_err(codec->dev, "Failed to read device ID: %d\n", id2);
582 ret = id2;
583 goto err_reg_enable;
584 }
585
586 id2 = (id2 << 8) | id1;
587
588 if (id2 != 0x8805) {
589 dev_err(codec->dev, "Invalid device ID: %#x\n", id2);
590 ret = -EINVAL;
591 goto err_reg_enable;
592 }
593
594 ret = snd_soc_read(codec, WM8804_DEVREV);
595 if (ret < 0) {
596 dev_err(codec->dev, "Failed to read device revision: %d\n",
597 ret);
598 goto err_reg_enable;
599 }
600 dev_info(codec->dev, "revision %c\n", ret + 'A');
601
602 ret = wm8804_reset(codec);
603 if (ret < 0) {
604 dev_err(codec->dev, "Failed to issue reset: %d\n", ret);
605 goto err_reg_enable;
606 }
607
608 return 0;
609
610err_reg_enable:
611 regulator_bulk_disable(ARRAY_SIZE(wm8804->supplies), wm8804->supplies);
612 return ret;
613}
614
615static const struct snd_soc_dai_ops wm8804_dai_ops = { 518static const struct snd_soc_dai_ops wm8804_dai_ops = {
616 .hw_params = wm8804_hw_params, 519 .hw_params = wm8804_hw_params,
617 .set_fmt = wm8804_set_fmt, 520 .set_fmt = wm8804_set_fmt,
@@ -649,8 +552,6 @@ static struct snd_soc_dai_driver wm8804_dai = {
649}; 552};
650 553
651static const struct snd_soc_codec_driver soc_codec_dev_wm8804 = { 554static const struct snd_soc_codec_driver soc_codec_dev_wm8804 = {
652 .probe = wm8804_probe,
653 .remove = wm8804_remove,
654 .set_bias_level = wm8804_set_bias_level, 555 .set_bias_level = wm8804_set_bias_level,
655 .idle_bias_off = true, 556 .idle_bias_off = true,
656 557
@@ -658,13 +559,7 @@ static const struct snd_soc_codec_driver soc_codec_dev_wm8804 = {
658 .num_controls = ARRAY_SIZE(wm8804_snd_controls), 559 .num_controls = ARRAY_SIZE(wm8804_snd_controls),
659}; 560};
660 561
661static const struct of_device_id wm8804_of_match[] = { 562const struct regmap_config wm8804_regmap_config = {
662 { .compatible = "wlf,wm8804", },
663 { }
664};
665MODULE_DEVICE_TABLE(of, wm8804_of_match);
666
667static const struct regmap_config wm8804_regmap_config = {
668 .reg_bits = 8, 563 .reg_bits = 8,
669 .val_bits = 8, 564 .val_bits = 8,
670 565
@@ -675,128 +570,110 @@ static const struct regmap_config wm8804_regmap_config = {
675 .reg_defaults = wm8804_reg_defaults, 570 .reg_defaults = wm8804_reg_defaults,
676 .num_reg_defaults = ARRAY_SIZE(wm8804_reg_defaults), 571 .num_reg_defaults = ARRAY_SIZE(wm8804_reg_defaults),
677}; 572};
573EXPORT_SYMBOL_GPL(wm8804_regmap_config);
678 574
679#if defined(CONFIG_SPI_MASTER) 575int wm8804_probe(struct device *dev, struct regmap *regmap)
680static int wm8804_spi_probe(struct spi_device *spi)
681{ 576{
682 struct wm8804_priv *wm8804; 577 struct wm8804_priv *wm8804;
683 int ret; 578 unsigned int id1, id2;
579 int i, ret;
684 580
685 wm8804 = devm_kzalloc(&spi->dev, sizeof *wm8804, GFP_KERNEL); 581 wm8804 = devm_kzalloc(dev, sizeof(*wm8804), GFP_KERNEL);
686 if (!wm8804) 582 if (!wm8804)
687 return -ENOMEM; 583 return -ENOMEM;
688 584
689 wm8804->regmap = devm_regmap_init_spi(spi, &wm8804_regmap_config); 585 dev_set_drvdata(dev, wm8804);
690 if (IS_ERR(wm8804->regmap)) { 586
691 ret = PTR_ERR(wm8804->regmap); 587 wm8804->regmap = regmap;
588
589 for (i = 0; i < ARRAY_SIZE(wm8804->supplies); i++)
590 wm8804->supplies[i].supply = wm8804_supply_names[i];
591
592 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(wm8804->supplies),
593 wm8804->supplies);
594 if (ret) {
595 dev_err(dev, "Failed to request supplies: %d\n", ret);
692 return ret; 596 return ret;
693 } 597 }
694 598
695 spi_set_drvdata(spi, wm8804); 599 wm8804->disable_nb[0].notifier_call = wm8804_regulator_event_0;
600 wm8804->disable_nb[1].notifier_call = wm8804_regulator_event_1;
696 601
697 ret = snd_soc_register_codec(&spi->dev, 602 /* This should really be moved into the regulator core */
698 &soc_codec_dev_wm8804, &wm8804_dai, 1); 603 for (i = 0; i < ARRAY_SIZE(wm8804->supplies); i++) {
604 ret = regulator_register_notifier(wm8804->supplies[i].consumer,
605 &wm8804->disable_nb[i]);
606 if (ret != 0) {
607 dev_err(dev,
608 "Failed to register regulator notifier: %d\n",
609 ret);
610 }
611 }
699 612
700 return ret; 613 ret = regulator_bulk_enable(ARRAY_SIZE(wm8804->supplies),
701} 614 wm8804->supplies);
615 if (ret) {
616 dev_err(dev, "Failed to enable supplies: %d\n", ret);
617 goto err_reg_enable;
618 }
702 619
703static int wm8804_spi_remove(struct spi_device *spi) 620 ret = regmap_read(regmap, WM8804_RST_DEVID1, &id1);
704{ 621 if (ret < 0) {
705 snd_soc_unregister_codec(&spi->dev); 622 dev_err(dev, "Failed to read device ID: %d\n", ret);
706 return 0; 623 goto err_reg_enable;
707} 624 }
708 625
709static struct spi_driver wm8804_spi_driver = { 626 ret = regmap_read(regmap, WM8804_DEVID2, &id2);
710 .driver = { 627 if (ret < 0) {
711 .name = "wm8804", 628 dev_err(dev, "Failed to read device ID: %d\n", ret);
712 .owner = THIS_MODULE, 629 goto err_reg_enable;
713 .of_match_table = wm8804_of_match, 630 }
714 },
715 .probe = wm8804_spi_probe,
716 .remove = wm8804_spi_remove
717};
718#endif
719 631
720#if IS_ENABLED(CONFIG_I2C) 632 id2 = (id2 << 8) | id1;
721static int wm8804_i2c_probe(struct i2c_client *i2c,
722 const struct i2c_device_id *id)
723{
724 struct wm8804_priv *wm8804;
725 int ret;
726 633
727 wm8804 = devm_kzalloc(&i2c->dev, sizeof *wm8804, GFP_KERNEL); 634 if (id2 != 0x8805) {
728 if (!wm8804) 635 dev_err(dev, "Invalid device ID: %#x\n", id2);
729 return -ENOMEM; 636 ret = -EINVAL;
637 goto err_reg_enable;
638 }
730 639
731 wm8804->regmap = devm_regmap_init_i2c(i2c, &wm8804_regmap_config); 640 ret = regmap_read(regmap, WM8804_DEVREV, &id1);
732 if (IS_ERR(wm8804->regmap)) { 641 if (ret < 0) {
733 ret = PTR_ERR(wm8804->regmap); 642 dev_err(dev, "Failed to read device revision: %d\n",
734 return ret; 643 ret);
644 goto err_reg_enable;
735 } 645 }
646 dev_info(dev, "revision %c\n", id1 + 'A');
736 647
737 i2c_set_clientdata(i2c, wm8804); 648 ret = wm8804_reset(wm8804);
649 if (ret < 0) {
650 dev_err(dev, "Failed to issue reset: %d\n", ret);
651 goto err_reg_enable;
652 }
738 653
739 ret = snd_soc_register_codec(&i2c->dev, 654 return snd_soc_register_codec(dev, &soc_codec_dev_wm8804,
740 &soc_codec_dev_wm8804, &wm8804_dai, 1); 655 &wm8804_dai, 1);
656
657err_reg_enable:
658 regulator_bulk_disable(ARRAY_SIZE(wm8804->supplies), wm8804->supplies);
741 return ret; 659 return ret;
742} 660}
661EXPORT_SYMBOL_GPL(wm8804_probe);
743 662
744static int wm8804_i2c_remove(struct i2c_client *i2c) 663void wm8804_remove(struct device *dev)
745{ 664{
746 snd_soc_unregister_codec(&i2c->dev); 665 struct wm8804_priv *wm8804;
747 return 0; 666 int i;
748}
749
750static const struct i2c_device_id wm8804_i2c_id[] = {
751 { "wm8804", 0 },
752 { }
753};
754MODULE_DEVICE_TABLE(i2c, wm8804_i2c_id);
755
756static struct i2c_driver wm8804_i2c_driver = {
757 .driver = {
758 .name = "wm8804",
759 .owner = THIS_MODULE,
760 .of_match_table = wm8804_of_match,
761 },
762 .probe = wm8804_i2c_probe,
763 .remove = wm8804_i2c_remove,
764 .id_table = wm8804_i2c_id
765};
766#endif
767 667
768static int __init wm8804_modinit(void) 668 wm8804 = dev_get_drvdata(dev);
769{
770 int ret = 0;
771 669
772#if IS_ENABLED(CONFIG_I2C) 670 for (i = 0; i < ARRAY_SIZE(wm8804->supplies); ++i)
773 ret = i2c_add_driver(&wm8804_i2c_driver); 671 regulator_unregister_notifier(wm8804->supplies[i].consumer,
774 if (ret) { 672 &wm8804->disable_nb[i]);
775 printk(KERN_ERR "Failed to register wm8804 I2C driver: %d\n",
776 ret);
777 }
778#endif
779#if defined(CONFIG_SPI_MASTER)
780 ret = spi_register_driver(&wm8804_spi_driver);
781 if (ret != 0) {
782 printk(KERN_ERR "Failed to register wm8804 SPI driver: %d\n",
783 ret);
784 }
785#endif
786 return ret;
787}
788module_init(wm8804_modinit);
789 673
790static void __exit wm8804_exit(void) 674 snd_soc_unregister_codec(dev);
791{
792#if IS_ENABLED(CONFIG_I2C)
793 i2c_del_driver(&wm8804_i2c_driver);
794#endif
795#if defined(CONFIG_SPI_MASTER)
796 spi_unregister_driver(&wm8804_spi_driver);
797#endif
798} 675}
799module_exit(wm8804_exit); 676EXPORT_SYMBOL_GPL(wm8804_remove);
800 677
801MODULE_DESCRIPTION("ASoC WM8804 driver"); 678MODULE_DESCRIPTION("ASoC WM8804 driver");
802MODULE_AUTHOR("Dimitris Papastamos <dp@opensource.wolfsonmicro.com>"); 679MODULE_AUTHOR("Dimitris Papastamos <dp@opensource.wolfsonmicro.com>");
diff --git a/sound/soc/codecs/wm8804.h b/sound/soc/codecs/wm8804.h
index e72d4f4ba6b1..a39a2563dc67 100644
--- a/sound/soc/codecs/wm8804.h
+++ b/sound/soc/codecs/wm8804.h
@@ -13,6 +13,8 @@
13#ifndef _WM8804_H 13#ifndef _WM8804_H
14#define _WM8804_H 14#define _WM8804_H
15 15
16#include <linux/regmap.h>
17
16/* 18/*
17 * Register values. 19 * Register values.
18 */ 20 */
@@ -62,4 +64,9 @@
62#define WM8804_MCLKDIV_256FS 0 64#define WM8804_MCLKDIV_256FS 0
63#define WM8804_MCLKDIV_128FS 1 65#define WM8804_MCLKDIV_128FS 1
64 66
67extern const struct regmap_config wm8804_regmap_config;
68
69int wm8804_probe(struct device *dev, struct regmap *regmap);
70void wm8804_remove(struct device *dev);
71
65#endif /* _WM8804_H */ 72#endif /* _WM8804_H */
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index ff67b334065b..d01c2095452f 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -420,10 +420,9 @@ static int wm_coeff_put(struct snd_kcontrol *kcontrol,
420 420
421 memcpy(ctl->cache, p, ctl->len); 421 memcpy(ctl->cache, p, ctl->len);
422 422
423 if (!ctl->enabled) { 423 ctl->set = 1;
424 ctl->set = 1; 424 if (!ctl->enabled)
425 return 0; 425 return 0;
426 }
427 426
428 return wm_coeff_write_control(kcontrol, p, ctl->len); 427 return wm_coeff_write_control(kcontrol, p, ctl->len);
429} 428}
@@ -1185,7 +1184,6 @@ static int wm_adsp_load_coeff(struct wm_adsp *dsp)
1185 int ret, pos, blocks, type, offset, reg; 1184 int ret, pos, blocks, type, offset, reg;
1186 char *file; 1185 char *file;
1187 struct wm_adsp_buf *buf; 1186 struct wm_adsp_buf *buf;
1188 int tmp;
1189 1187
1190 file = kzalloc(PAGE_SIZE, GFP_KERNEL); 1188 file = kzalloc(PAGE_SIZE, GFP_KERNEL);
1191 if (file == NULL) 1189 if (file == NULL)
@@ -1335,12 +1333,7 @@ static int wm_adsp_load_coeff(struct wm_adsp *dsp)
1335 } 1333 }
1336 } 1334 }
1337 1335
1338 tmp = le32_to_cpu(blk->len) % 4; 1336 pos += (le32_to_cpu(blk->len) + sizeof(*blk) + 3) & ~0x03;
1339 if (tmp)
1340 pos += le32_to_cpu(blk->len) + (4 - tmp) + sizeof(*blk);
1341 else
1342 pos += le32_to_cpu(blk->len) + sizeof(*blk);
1343
1344 blocks++; 1337 blocks++;
1345 } 1338 }
1346 1339
diff --git a/sound/soc/davinci/Kconfig b/sound/soc/davinci/Kconfig
index 2b81ca418d2a..3736d9aabc56 100644
--- a/sound/soc/davinci/Kconfig
+++ b/sound/soc/davinci/Kconfig
@@ -1,14 +1,16 @@
1config SND_DAVINCI_SOC 1config SND_DAVINCI_SOC
2 tristate "SoC Audio for TI DAVINCI" 2 tristate
3 depends on ARCH_DAVINCI 3 depends on ARCH_DAVINCI
4 select SND_EDMA_SOC
4 5
5config SND_EDMA_SOC 6config SND_EDMA_SOC
6 tristate "SoC Audio for Texas Instruments chips using eDMA (AM33XX/43XX)" 7 tristate "SoC Audio for Texas Instruments chips using eDMA"
7 depends on SOC_AM33XX || SOC_AM43XX 8 depends on SOC_AM33XX || SOC_AM43XX || ARCH_DAVINCI
8 select SND_SOC_GENERIC_DMAENGINE_PCM 9 select SND_SOC_GENERIC_DMAENGINE_PCM
9 help 10 help
10 Say Y or M here if you want audio support for TI SoC which uses eDMA. 11 Say Y or M here if you want audio support for TI SoC which uses eDMA.
11 The following line of SoCs are supported by this platform driver: 12 The following line of SoCs are supported by this platform driver:
13 - daVinci devices
12 - AM335x 14 - AM335x
13 - AM437x/AM438x 15 - AM437x/AM438x
14 16
@@ -17,7 +19,7 @@ config SND_DAVINCI_SOC_I2S
17 19
18config SND_DAVINCI_SOC_MCASP 20config SND_DAVINCI_SOC_MCASP
19 tristate "Multichannel Audio Serial Port (McASP) support" 21 tristate "Multichannel Audio Serial Port (McASP) support"
20 depends on SND_DAVINCI_SOC || SND_OMAP_SOC || SND_EDMA_SOC 22 depends on SND_OMAP_SOC || SND_EDMA_SOC
21 help 23 help
22 Say Y or M here if you want to have support for McASP IP found in 24 Say Y or M here if you want to have support for McASP IP found in
23 various Texas Instruments SoCs like: 25 various Texas Instruments SoCs like:
@@ -45,7 +47,7 @@ config SND_AM33XX_SOC_EVM
45 47
46config SND_DAVINCI_SOC_EVM 48config SND_DAVINCI_SOC_EVM
47 tristate "SoC Audio support for DaVinci DM6446, DM355 or DM365 EVM" 49 tristate "SoC Audio support for DaVinci DM6446, DM355 or DM365 EVM"
48 depends on SND_DAVINCI_SOC && I2C 50 depends on SND_EDMA_SOC && I2C
49 depends on MACH_DAVINCI_EVM || MACH_DAVINCI_DM355_EVM || MACH_DAVINCI_DM365_EVM 51 depends on MACH_DAVINCI_EVM || MACH_DAVINCI_DM355_EVM || MACH_DAVINCI_DM365_EVM
50 select SND_DAVINCI_SOC_GENERIC_EVM 52 select SND_DAVINCI_SOC_GENERIC_EVM
51 help 53 help
@@ -73,7 +75,7 @@ endchoice
73 75
74config SND_DM6467_SOC_EVM 76config SND_DM6467_SOC_EVM
75 tristate "SoC Audio support for DaVinci DM6467 EVM" 77 tristate "SoC Audio support for DaVinci DM6467 EVM"
76 depends on SND_DAVINCI_SOC && MACH_DAVINCI_DM6467_EVM && I2C 78 depends on SND_EDMA_SOC && MACH_DAVINCI_DM6467_EVM && I2C
77 select SND_DAVINCI_SOC_GENERIC_EVM 79 select SND_DAVINCI_SOC_GENERIC_EVM
78 select SND_SOC_SPDIF 80 select SND_SOC_SPDIF
79 81
@@ -82,7 +84,7 @@ config SND_DM6467_SOC_EVM
82 84
83config SND_DA830_SOC_EVM 85config SND_DA830_SOC_EVM
84 tristate "SoC Audio support for DA830/OMAP-L137 EVM" 86 tristate "SoC Audio support for DA830/OMAP-L137 EVM"
85 depends on SND_DAVINCI_SOC && MACH_DAVINCI_DA830_EVM && I2C 87 depends on SND_EDMA_SOC && MACH_DAVINCI_DA830_EVM && I2C
86 select SND_DAVINCI_SOC_GENERIC_EVM 88 select SND_DAVINCI_SOC_GENERIC_EVM
87 89
88 help 90 help
@@ -91,7 +93,7 @@ config SND_DA830_SOC_EVM
91 93
92config SND_DA850_SOC_EVM 94config SND_DA850_SOC_EVM
93 tristate "SoC Audio support for DA850/OMAP-L138 EVM" 95 tristate "SoC Audio support for DA850/OMAP-L138 EVM"
94 depends on SND_DAVINCI_SOC && MACH_DAVINCI_DA850_EVM && I2C 96 depends on SND_EDMA_SOC && MACH_DAVINCI_DA850_EVM && I2C
95 select SND_DAVINCI_SOC_GENERIC_EVM 97 select SND_DAVINCI_SOC_GENERIC_EVM
96 help 98 help
97 Say Y if you want to add support for SoC audio on TI 99 Say Y if you want to add support for SoC audio on TI
diff --git a/sound/soc/davinci/Makefile b/sound/soc/davinci/Makefile
index 09bf2ba92d38..f883933c1a19 100644
--- a/sound/soc/davinci/Makefile
+++ b/sound/soc/davinci/Makefile
@@ -1,11 +1,9 @@
1# DAVINCI Platform Support 1# DAVINCI Platform Support
2snd-soc-davinci-objs := davinci-pcm.o
3snd-soc-edma-objs := edma-pcm.o 2snd-soc-edma-objs := edma-pcm.o
4snd-soc-davinci-i2s-objs := davinci-i2s.o 3snd-soc-davinci-i2s-objs := davinci-i2s.o
5snd-soc-davinci-mcasp-objs:= davinci-mcasp.o 4snd-soc-davinci-mcasp-objs:= davinci-mcasp.o
6snd-soc-davinci-vcif-objs:= davinci-vcif.o 5snd-soc-davinci-vcif-objs:= davinci-vcif.o
7 6
8obj-$(CONFIG_SND_DAVINCI_SOC) += snd-soc-davinci.o
9obj-$(CONFIG_SND_EDMA_SOC) += snd-soc-edma.o 7obj-$(CONFIG_SND_EDMA_SOC) += snd-soc-edma.o
10obj-$(CONFIG_SND_DAVINCI_SOC_I2S) += snd-soc-davinci-i2s.o 8obj-$(CONFIG_SND_DAVINCI_SOC_I2S) += snd-soc-davinci-i2s.o
11obj-$(CONFIG_SND_DAVINCI_SOC_MCASP) += snd-soc-davinci-mcasp.o 9obj-$(CONFIG_SND_DAVINCI_SOC_MCASP) += snd-soc-davinci-mcasp.o
diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c
index 15fb28fc8e1b..56cb4d95637d 100644
--- a/sound/soc/davinci/davinci-i2s.c
+++ b/sound/soc/davinci/davinci-i2s.c
@@ -23,8 +23,9 @@
23#include <sound/pcm_params.h> 23#include <sound/pcm_params.h>
24#include <sound/initval.h> 24#include <sound/initval.h>
25#include <sound/soc.h> 25#include <sound/soc.h>
26#include <sound/dmaengine_pcm.h>
26 27
27#include "davinci-pcm.h" 28#include "edma-pcm.h"
28#include "davinci-i2s.h" 29#include "davinci-i2s.h"
29 30
30 31
@@ -122,7 +123,8 @@ static const unsigned char double_fmt[SNDRV_PCM_FORMAT_S32_LE + 1] = {
122 123
123struct davinci_mcbsp_dev { 124struct davinci_mcbsp_dev {
124 struct device *dev; 125 struct device *dev;
125 struct davinci_pcm_dma_params dma_params[2]; 126 struct snd_dmaengine_dai_dma_data dma_data[2];
127 int dma_request[2];
126 void __iomem *base; 128 void __iomem *base;
127#define MOD_DSP_A 0 129#define MOD_DSP_A 0
128#define MOD_DSP_B 1 130#define MOD_DSP_B 1
@@ -419,8 +421,6 @@ static int davinci_i2s_hw_params(struct snd_pcm_substream *substream,
419 struct snd_soc_dai *dai) 421 struct snd_soc_dai *dai)
420{ 422{
421 struct davinci_mcbsp_dev *dev = snd_soc_dai_get_drvdata(dai); 423 struct davinci_mcbsp_dev *dev = snd_soc_dai_get_drvdata(dai);
422 struct davinci_pcm_dma_params *dma_params =
423 &dev->dma_params[substream->stream];
424 struct snd_interval *i = NULL; 424 struct snd_interval *i = NULL;
425 int mcbsp_word_length, master; 425 int mcbsp_word_length, master;
426 unsigned int rcr, xcr, srgr, clk_div, freq, framesize; 426 unsigned int rcr, xcr, srgr, clk_div, freq, framesize;
@@ -532,8 +532,6 @@ static int davinci_i2s_hw_params(struct snd_pcm_substream *substream,
532 return -EINVAL; 532 return -EINVAL;
533 } 533 }
534 } 534 }
535 dma_params->acnt = dma_params->data_type = data_type[fmt];
536 dma_params->fifo_level = 0;
537 mcbsp_word_length = asp_word_length[fmt]; 535 mcbsp_word_length = asp_word_length[fmt];
538 536
539 switch (master) { 537 switch (master) {
@@ -600,15 +598,6 @@ static int davinci_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
600 return ret; 598 return ret;
601} 599}
602 600
603static int davinci_i2s_startup(struct snd_pcm_substream *substream,
604 struct snd_soc_dai *dai)
605{
606 struct davinci_mcbsp_dev *dev = snd_soc_dai_get_drvdata(dai);
607
608 snd_soc_dai_set_dma_data(dai, substream, dev->dma_params);
609 return 0;
610}
611
612static void davinci_i2s_shutdown(struct snd_pcm_substream *substream, 601static void davinci_i2s_shutdown(struct snd_pcm_substream *substream,
613 struct snd_soc_dai *dai) 602 struct snd_soc_dai *dai)
614{ 603{
@@ -620,7 +609,6 @@ static void davinci_i2s_shutdown(struct snd_pcm_substream *substream,
620#define DAVINCI_I2S_RATES SNDRV_PCM_RATE_8000_96000 609#define DAVINCI_I2S_RATES SNDRV_PCM_RATE_8000_96000
621 610
622static const struct snd_soc_dai_ops davinci_i2s_dai_ops = { 611static const struct snd_soc_dai_ops davinci_i2s_dai_ops = {
623 .startup = davinci_i2s_startup,
624 .shutdown = davinci_i2s_shutdown, 612 .shutdown = davinci_i2s_shutdown,
625 .prepare = davinci_i2s_prepare, 613 .prepare = davinci_i2s_prepare,
626 .trigger = davinci_i2s_trigger, 614 .trigger = davinci_i2s_trigger,
@@ -630,7 +618,18 @@ static const struct snd_soc_dai_ops davinci_i2s_dai_ops = {
630 618
631}; 619};
632 620
621static int davinci_i2s_dai_probe(struct snd_soc_dai *dai)
622{
623 struct davinci_mcbsp_dev *dev = snd_soc_dai_get_drvdata(dai);
624
625 dai->playback_dma_data = &dev->dma_data[SNDRV_PCM_STREAM_PLAYBACK];
626 dai->capture_dma_data = &dev->dma_data[SNDRV_PCM_STREAM_CAPTURE];
627
628 return 0;
629}
630
633static struct snd_soc_dai_driver davinci_i2s_dai = { 631static struct snd_soc_dai_driver davinci_i2s_dai = {
632 .probe = davinci_i2s_dai_probe,
634 .playback = { 633 .playback = {
635 .channels_min = 2, 634 .channels_min = 2,
636 .channels_max = 2, 635 .channels_max = 2,
@@ -651,11 +650,9 @@ static const struct snd_soc_component_driver davinci_i2s_component = {
651 650
652static int davinci_i2s_probe(struct platform_device *pdev) 651static int davinci_i2s_probe(struct platform_device *pdev)
653{ 652{
654 struct snd_platform_data *pdata = pdev->dev.platform_data;
655 struct davinci_mcbsp_dev *dev; 653 struct davinci_mcbsp_dev *dev;
656 struct resource *mem, *ioarea, *res; 654 struct resource *mem, *ioarea, *res;
657 enum dma_event_q asp_chan_q = EVENTQ_0; 655 int *dma;
658 enum dma_event_q ram_chan_q = EVENTQ_1;
659 int ret; 656 int ret;
660 657
661 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 658 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -676,22 +673,6 @@ static int davinci_i2s_probe(struct platform_device *pdev)
676 GFP_KERNEL); 673 GFP_KERNEL);
677 if (!dev) 674 if (!dev)
678 return -ENOMEM; 675 return -ENOMEM;
679 if (pdata) {
680 dev->enable_channel_combine = pdata->enable_channel_combine;
681 dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK].sram_size =
682 pdata->sram_size_playback;
683 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE].sram_size =
684 pdata->sram_size_capture;
685 dev->clk_input_pin = pdata->clk_input_pin;
686 dev->i2s_accurate_sck = pdata->i2s_accurate_sck;
687 asp_chan_q = pdata->asp_chan_q;
688 ram_chan_q = pdata->ram_chan_q;
689 }
690
691 dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK].asp_chan_q = asp_chan_q;
692 dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK].ram_chan_q = ram_chan_q;
693 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE].asp_chan_q = asp_chan_q;
694 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE].ram_chan_q = ram_chan_q;
695 676
696 dev->clk = clk_get(&pdev->dev, NULL); 677 dev->clk = clk_get(&pdev->dev, NULL);
697 if (IS_ERR(dev->clk)) 678 if (IS_ERR(dev->clk))
@@ -705,10 +686,10 @@ static int davinci_i2s_probe(struct platform_device *pdev)
705 goto err_release_clk; 686 goto err_release_clk;
706 } 687 }
707 688
708 dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK].dma_addr = 689 dev->dma_data[SNDRV_PCM_STREAM_PLAYBACK].addr =
709 (dma_addr_t)(mem->start + DAVINCI_MCBSP_DXR_REG); 690 (dma_addr_t)(mem->start + DAVINCI_MCBSP_DXR_REG);
710 691
711 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE].dma_addr = 692 dev->dma_data[SNDRV_PCM_STREAM_CAPTURE].addr =
712 (dma_addr_t)(mem->start + DAVINCI_MCBSP_DRR_REG); 693 (dma_addr_t)(mem->start + DAVINCI_MCBSP_DRR_REG);
713 694
714 /* first TX, then RX */ 695 /* first TX, then RX */
@@ -718,7 +699,9 @@ static int davinci_i2s_probe(struct platform_device *pdev)
718 ret = -ENXIO; 699 ret = -ENXIO;
719 goto err_release_clk; 700 goto err_release_clk;
720 } 701 }
721 dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK].channel = res->start; 702 dma = &dev->dma_request[SNDRV_PCM_STREAM_PLAYBACK];
703 *dma = res->start;
704 dev->dma_data[SNDRV_PCM_STREAM_PLAYBACK].filter_data = dma;
722 705
723 res = platform_get_resource(pdev, IORESOURCE_DMA, 1); 706 res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
724 if (!res) { 707 if (!res) {
@@ -726,9 +709,11 @@ static int davinci_i2s_probe(struct platform_device *pdev)
726 ret = -ENXIO; 709 ret = -ENXIO;
727 goto err_release_clk; 710 goto err_release_clk;
728 } 711 }
729 dev->dma_params[SNDRV_PCM_STREAM_CAPTURE].channel = res->start; 712 dma = &dev->dma_request[SNDRV_PCM_STREAM_CAPTURE];
730 dev->dev = &pdev->dev; 713 *dma = res->start;
714 dev->dma_data[SNDRV_PCM_STREAM_CAPTURE].filter_data = dma;
731 715
716 dev->dev = &pdev->dev;
732 dev_set_drvdata(&pdev->dev, dev); 717 dev_set_drvdata(&pdev->dev, dev);
733 718
734 ret = snd_soc_register_component(&pdev->dev, &davinci_i2s_component, 719 ret = snd_soc_register_component(&pdev->dev, &davinci_i2s_component,
@@ -736,7 +721,7 @@ static int davinci_i2s_probe(struct platform_device *pdev)
736 if (ret != 0) 721 if (ret != 0)
737 goto err_release_clk; 722 goto err_release_clk;
738 723
739 ret = davinci_soc_platform_register(&pdev->dev); 724 ret = edma_pcm_platform_register(&pdev->dev);
740 if (ret) { 725 if (ret) {
741 dev_err(&pdev->dev, "register PCM failed: %d\n", ret); 726 dev_err(&pdev->dev, "register PCM failed: %d\n", ret);
742 goto err_unregister_component; 727 goto err_unregister_component;
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
index de3b155a5011..0c882995a357 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -26,6 +26,7 @@
26#include <linux/of.h> 26#include <linux/of.h>
27#include <linux/of_platform.h> 27#include <linux/of_platform.h>
28#include <linux/of_device.h> 28#include <linux/of_device.h>
29#include <linux/platform_data/davinci_asp.h>
29 30
30#include <sound/asoundef.h> 31#include <sound/asoundef.h>
31#include <sound/core.h> 32#include <sound/core.h>
@@ -36,7 +37,6 @@
36#include <sound/dmaengine_pcm.h> 37#include <sound/dmaengine_pcm.h>
37#include <sound/omap-pcm.h> 38#include <sound/omap-pcm.h>
38 39
39#include "davinci-pcm.h"
40#include "edma-pcm.h" 40#include "edma-pcm.h"
41#include "davinci-mcasp.h" 41#include "davinci-mcasp.h"
42 42
@@ -65,7 +65,6 @@ struct davinci_mcasp_context {
65}; 65};
66 66
67struct davinci_mcasp { 67struct davinci_mcasp {
68 struct davinci_pcm_dma_params dma_params[2];
69 struct snd_dmaengine_dai_dma_data dma_data[2]; 68 struct snd_dmaengine_dai_dma_data dma_data[2];
70 void __iomem *base; 69 void __iomem *base;
71 u32 fifo_base; 70 u32 fifo_base;
@@ -82,6 +81,7 @@ struct davinci_mcasp {
82 u16 bclk_lrclk_ratio; 81 u16 bclk_lrclk_ratio;
83 int streams; 82 int streams;
84 u32 irq_request[2]; 83 u32 irq_request[2];
84 int dma_request[2];
85 85
86 int sysclk_freq; 86 int sysclk_freq;
87 bool bclk_master; 87 bool bclk_master;
@@ -441,6 +441,18 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
441 mcasp_set_bits(mcasp, DAVINCI_MCASP_PDIR_REG, AFSX | AFSR); 441 mcasp_set_bits(mcasp, DAVINCI_MCASP_PDIR_REG, AFSX | AFSR);
442 mcasp->bclk_master = 1; 442 mcasp->bclk_master = 1;
443 break; 443 break;
444 case SND_SOC_DAIFMT_CBS_CFM:
445 /* codec is clock slave and frame master */
446 mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXE);
447 mcasp_clr_bits(mcasp, DAVINCI_MCASP_TXFMCTL_REG, AFSXE);
448
449 mcasp_set_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, ACLKRE);
450 mcasp_clr_bits(mcasp, DAVINCI_MCASP_RXFMCTL_REG, AFSRE);
451
452 mcasp_set_bits(mcasp, DAVINCI_MCASP_PDIR_REG, ACLKX | ACLKR);
453 mcasp_clr_bits(mcasp, DAVINCI_MCASP_PDIR_REG, AFSX | AFSR);
454 mcasp->bclk_master = 1;
455 break;
444 case SND_SOC_DAIFMT_CBM_CFS: 456 case SND_SOC_DAIFMT_CBM_CFS:
445 /* codec is clock master and frame slave */ 457 /* codec is clock master and frame slave */
446 mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXE); 458 mcasp_clr_bits(mcasp, DAVINCI_MCASP_ACLKXCTL_REG, ACLKXE);
@@ -631,7 +643,6 @@ static int davinci_config_channel_size(struct davinci_mcasp *mcasp,
631static int mcasp_common_hw_param(struct davinci_mcasp *mcasp, int stream, 643static int mcasp_common_hw_param(struct davinci_mcasp *mcasp, int stream,
632 int period_words, int channels) 644 int period_words, int channels)
633{ 645{
634 struct davinci_pcm_dma_params *dma_params = &mcasp->dma_params[stream];
635 struct snd_dmaengine_dai_dma_data *dma_data = &mcasp->dma_data[stream]; 646 struct snd_dmaengine_dai_dma_data *dma_data = &mcasp->dma_data[stream];
636 int i; 647 int i;
637 u8 tx_ser = 0; 648 u8 tx_ser = 0;
@@ -699,10 +710,8 @@ static int mcasp_common_hw_param(struct davinci_mcasp *mcasp, int stream,
699 * For example if three serializers are enabled the DMA 710 * For example if three serializers are enabled the DMA
700 * need to transfer three words per DMA request. 711 * need to transfer three words per DMA request.
701 */ 712 */
702 dma_params->fifo_level = active_serializers;
703 dma_data->maxburst = active_serializers; 713 dma_data->maxburst = active_serializers;
704 } else { 714 } else {
705 dma_params->fifo_level = 0;
706 dma_data->maxburst = 0; 715 dma_data->maxburst = 0;
707 } 716 }
708 return 0; 717 return 0;
@@ -734,7 +743,6 @@ static int mcasp_common_hw_param(struct davinci_mcasp *mcasp, int stream,
734 /* Configure the burst size for platform drivers */ 743 /* Configure the burst size for platform drivers */
735 if (numevt == 1) 744 if (numevt == 1)
736 numevt = 0; 745 numevt = 0;
737 dma_params->fifo_level = numevt;
738 dma_data->maxburst = numevt; 746 dma_data->maxburst = numevt;
739 747
740 return 0; 748 return 0;
@@ -860,8 +868,6 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream,
860 struct snd_soc_dai *cpu_dai) 868 struct snd_soc_dai *cpu_dai)
861{ 869{
862 struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(cpu_dai); 870 struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(cpu_dai);
863 struct davinci_pcm_dma_params *dma_params =
864 &mcasp->dma_params[substream->stream];
865 int word_length; 871 int word_length;
866 int channels = params_channels(params); 872 int channels = params_channels(params);
867 int period_size = params_period_size(params); 873 int period_size = params_period_size(params);
@@ -902,31 +908,26 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream,
902 switch (params_format(params)) { 908 switch (params_format(params)) {
903 case SNDRV_PCM_FORMAT_U8: 909 case SNDRV_PCM_FORMAT_U8:
904 case SNDRV_PCM_FORMAT_S8: 910 case SNDRV_PCM_FORMAT_S8:
905 dma_params->data_type = 1;
906 word_length = 8; 911 word_length = 8;
907 break; 912 break;
908 913
909 case SNDRV_PCM_FORMAT_U16_LE: 914 case SNDRV_PCM_FORMAT_U16_LE:
910 case SNDRV_PCM_FORMAT_S16_LE: 915 case SNDRV_PCM_FORMAT_S16_LE:
911 dma_params->data_type = 2;
912 word_length = 16; 916 word_length = 16;
913 break; 917 break;
914 918
915 case SNDRV_PCM_FORMAT_U24_3LE: 919 case SNDRV_PCM_FORMAT_U24_3LE:
916 case SNDRV_PCM_FORMAT_S24_3LE: 920 case SNDRV_PCM_FORMAT_S24_3LE:
917 dma_params->data_type = 3;
918 word_length = 24; 921 word_length = 24;
919 break; 922 break;
920 923
921 case SNDRV_PCM_FORMAT_U24_LE: 924 case SNDRV_PCM_FORMAT_U24_LE:
922 case SNDRV_PCM_FORMAT_S24_LE: 925 case SNDRV_PCM_FORMAT_S24_LE:
923 dma_params->data_type = 4;
924 word_length = 24; 926 word_length = 24;
925 break; 927 break;
926 928
927 case SNDRV_PCM_FORMAT_U32_LE: 929 case SNDRV_PCM_FORMAT_U32_LE:
928 case SNDRV_PCM_FORMAT_S32_LE: 930 case SNDRV_PCM_FORMAT_S32_LE:
929 dma_params->data_type = 4;
930 word_length = 32; 931 word_length = 32;
931 break; 932 break;
932 933
@@ -935,11 +936,6 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream,
935 return -EINVAL; 936 return -EINVAL;
936 } 937 }
937 938
938 if (mcasp->version == MCASP_VERSION_2 && !dma_params->fifo_level)
939 dma_params->acnt = 4;
940 else
941 dma_params->acnt = dma_params->data_type;
942
943 davinci_config_channel_size(mcasp, word_length); 939 davinci_config_channel_size(mcasp, word_length);
944 940
945 if (mcasp->op_mode == DAVINCI_MCASP_IIS_MODE) 941 if (mcasp->op_mode == DAVINCI_MCASP_IIS_MODE)
@@ -1043,17 +1039,8 @@ static int davinci_mcasp_dai_probe(struct snd_soc_dai *dai)
1043{ 1039{
1044 struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(dai); 1040 struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(dai);
1045 1041
1046 if (mcasp->version >= MCASP_VERSION_3) { 1042 dai->playback_dma_data = &mcasp->dma_data[SNDRV_PCM_STREAM_PLAYBACK];
1047 /* Using dmaengine PCM */ 1043 dai->capture_dma_data = &mcasp->dma_data[SNDRV_PCM_STREAM_CAPTURE];
1048 dai->playback_dma_data =
1049 &mcasp->dma_data[SNDRV_PCM_STREAM_PLAYBACK];
1050 dai->capture_dma_data =
1051 &mcasp->dma_data[SNDRV_PCM_STREAM_CAPTURE];
1052 } else {
1053 /* Using davinci-pcm */
1054 dai->playback_dma_data = mcasp->dma_params;
1055 dai->capture_dma_data = mcasp->dma_params;
1056 }
1057 1044
1058 return 0; 1045 return 0;
1059} 1046}
@@ -1172,28 +1159,24 @@ static const struct snd_soc_component_driver davinci_mcasp_component = {
1172static struct davinci_mcasp_pdata dm646x_mcasp_pdata = { 1159static struct davinci_mcasp_pdata dm646x_mcasp_pdata = {
1173 .tx_dma_offset = 0x400, 1160 .tx_dma_offset = 0x400,
1174 .rx_dma_offset = 0x400, 1161 .rx_dma_offset = 0x400,
1175 .asp_chan_q = EVENTQ_0,
1176 .version = MCASP_VERSION_1, 1162 .version = MCASP_VERSION_1,
1177}; 1163};
1178 1164
1179static struct davinci_mcasp_pdata da830_mcasp_pdata = { 1165static struct davinci_mcasp_pdata da830_mcasp_pdata = {
1180 .tx_dma_offset = 0x2000, 1166 .tx_dma_offset = 0x2000,
1181 .rx_dma_offset = 0x2000, 1167 .rx_dma_offset = 0x2000,
1182 .asp_chan_q = EVENTQ_0,
1183 .version = MCASP_VERSION_2, 1168 .version = MCASP_VERSION_2,
1184}; 1169};
1185 1170
1186static struct davinci_mcasp_pdata am33xx_mcasp_pdata = { 1171static struct davinci_mcasp_pdata am33xx_mcasp_pdata = {
1187 .tx_dma_offset = 0, 1172 .tx_dma_offset = 0,
1188 .rx_dma_offset = 0, 1173 .rx_dma_offset = 0,
1189 .asp_chan_q = EVENTQ_0,
1190 .version = MCASP_VERSION_3, 1174 .version = MCASP_VERSION_3,
1191}; 1175};
1192 1176
1193static struct davinci_mcasp_pdata dra7_mcasp_pdata = { 1177static struct davinci_mcasp_pdata dra7_mcasp_pdata = {
1194 .tx_dma_offset = 0x200, 1178 .tx_dma_offset = 0x200,
1195 .rx_dma_offset = 0x284, 1179 .rx_dma_offset = 0x284,
1196 .asp_chan_q = EVENTQ_0,
1197 .version = MCASP_VERSION_4, 1180 .version = MCASP_VERSION_4,
1198}; 1181};
1199 1182
@@ -1370,12 +1353,12 @@ nodata:
1370 1353
1371static int davinci_mcasp_probe(struct platform_device *pdev) 1354static int davinci_mcasp_probe(struct platform_device *pdev)
1372{ 1355{
1373 struct davinci_pcm_dma_params *dma_params;
1374 struct snd_dmaengine_dai_dma_data *dma_data; 1356 struct snd_dmaengine_dai_dma_data *dma_data;
1375 struct resource *mem, *ioarea, *res, *dat; 1357 struct resource *mem, *ioarea, *res, *dat;
1376 struct davinci_mcasp_pdata *pdata; 1358 struct davinci_mcasp_pdata *pdata;
1377 struct davinci_mcasp *mcasp; 1359 struct davinci_mcasp *mcasp;
1378 char *irq_name; 1360 char *irq_name;
1361 int *dma;
1379 int irq; 1362 int irq;
1380 int ret; 1363 int ret;
1381 1364
@@ -1509,59 +1492,45 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
1509 if (dat) 1492 if (dat)
1510 mcasp->dat_port = true; 1493 mcasp->dat_port = true;
1511 1494
1512 dma_params = &mcasp->dma_params[SNDRV_PCM_STREAM_PLAYBACK];
1513 dma_data = &mcasp->dma_data[SNDRV_PCM_STREAM_PLAYBACK]; 1495 dma_data = &mcasp->dma_data[SNDRV_PCM_STREAM_PLAYBACK];
1514 dma_params->asp_chan_q = pdata->asp_chan_q;
1515 dma_params->ram_chan_q = pdata->ram_chan_q;
1516 dma_params->sram_pool = pdata->sram_pool;
1517 dma_params->sram_size = pdata->sram_size_playback;
1518 if (dat) 1496 if (dat)
1519 dma_params->dma_addr = dat->start; 1497 dma_data->addr = dat->start;
1520 else 1498 else
1521 dma_params->dma_addr = mem->start + pdata->tx_dma_offset; 1499 dma_data->addr = mem->start + pdata->tx_dma_offset;
1522
1523 /* Unconditional dmaengine stuff */
1524 dma_data->addr = dma_params->dma_addr;
1525 1500
1501 dma = &mcasp->dma_request[SNDRV_PCM_STREAM_PLAYBACK];
1526 res = platform_get_resource(pdev, IORESOURCE_DMA, 0); 1502 res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
1527 if (res) 1503 if (res)
1528 dma_params->channel = res->start; 1504 *dma = res->start;
1529 else 1505 else
1530 dma_params->channel = pdata->tx_dma_channel; 1506 *dma = pdata->tx_dma_channel;
1531 1507
1532 /* dmaengine filter data for DT and non-DT boot */ 1508 /* dmaengine filter data for DT and non-DT boot */
1533 if (pdev->dev.of_node) 1509 if (pdev->dev.of_node)
1534 dma_data->filter_data = "tx"; 1510 dma_data->filter_data = "tx";
1535 else 1511 else
1536 dma_data->filter_data = &dma_params->channel; 1512 dma_data->filter_data = dma;
1537 1513
1538 /* RX is not valid in DIT mode */ 1514 /* RX is not valid in DIT mode */
1539 if (mcasp->op_mode != DAVINCI_MCASP_DIT_MODE) { 1515 if (mcasp->op_mode != DAVINCI_MCASP_DIT_MODE) {
1540 dma_params = &mcasp->dma_params[SNDRV_PCM_STREAM_CAPTURE];
1541 dma_data = &mcasp->dma_data[SNDRV_PCM_STREAM_CAPTURE]; 1516 dma_data = &mcasp->dma_data[SNDRV_PCM_STREAM_CAPTURE];
1542 dma_params->asp_chan_q = pdata->asp_chan_q;
1543 dma_params->ram_chan_q = pdata->ram_chan_q;
1544 dma_params->sram_pool = pdata->sram_pool;
1545 dma_params->sram_size = pdata->sram_size_capture;
1546 if (dat) 1517 if (dat)
1547 dma_params->dma_addr = dat->start; 1518 dma_data->addr = dat->start;
1548 else 1519 else
1549 dma_params->dma_addr = mem->start + pdata->rx_dma_offset; 1520 dma_data->addr = mem->start + pdata->rx_dma_offset;
1550
1551 /* Unconditional dmaengine stuff */
1552 dma_data->addr = dma_params->dma_addr;
1553 1521
1522 dma = &mcasp->dma_request[SNDRV_PCM_STREAM_CAPTURE];
1554 res = platform_get_resource(pdev, IORESOURCE_DMA, 1); 1523 res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
1555 if (res) 1524 if (res)
1556 dma_params->channel = res->start; 1525 *dma = res->start;
1557 else 1526 else
1558 dma_params->channel = pdata->rx_dma_channel; 1527 *dma = pdata->rx_dma_channel;
1559 1528
1560 /* dmaengine filter data for DT and non-DT boot */ 1529 /* dmaengine filter data for DT and non-DT boot */
1561 if (pdev->dev.of_node) 1530 if (pdev->dev.of_node)
1562 dma_data->filter_data = "rx"; 1531 dma_data->filter_data = "rx";
1563 else 1532 else
1564 dma_data->filter_data = &dma_params->channel; 1533 dma_data->filter_data = dma;
1565 } 1534 }
1566 1535
1567 if (mcasp->version < MCASP_VERSION_3) { 1536 if (mcasp->version < MCASP_VERSION_3) {
@@ -1584,17 +1553,11 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
1584 goto err; 1553 goto err;
1585 1554
1586 switch (mcasp->version) { 1555 switch (mcasp->version) {
1587#if IS_BUILTIN(CONFIG_SND_DAVINCI_SOC) || \
1588 (IS_MODULE(CONFIG_SND_DAVINCI_SOC_MCASP) && \
1589 IS_MODULE(CONFIG_SND_DAVINCI_SOC))
1590 case MCASP_VERSION_1:
1591 case MCASP_VERSION_2:
1592 ret = davinci_soc_platform_register(&pdev->dev);
1593 break;
1594#endif
1595#if IS_BUILTIN(CONFIG_SND_EDMA_SOC) || \ 1556#if IS_BUILTIN(CONFIG_SND_EDMA_SOC) || \
1596 (IS_MODULE(CONFIG_SND_DAVINCI_SOC_MCASP) && \ 1557 (IS_MODULE(CONFIG_SND_DAVINCI_SOC_MCASP) && \
1597 IS_MODULE(CONFIG_SND_EDMA_SOC)) 1558 IS_MODULE(CONFIG_SND_EDMA_SOC))
1559 case MCASP_VERSION_1:
1560 case MCASP_VERSION_2:
1598 case MCASP_VERSION_3: 1561 case MCASP_VERSION_3:
1599 ret = edma_pcm_platform_register(&pdev->dev); 1562 ret = edma_pcm_platform_register(&pdev->dev);
1600 break; 1563 break;
diff --git a/sound/soc/davinci/davinci-pcm.c b/sound/soc/davinci/davinci-pcm.c
deleted file mode 100644
index 7809e9d935fc..000000000000
--- a/sound/soc/davinci/davinci-pcm.c
+++ /dev/null
@@ -1,861 +0,0 @@
1/*
2 * ALSA PCM interface for the TI DAVINCI processor
3 *
4 * Author: Vladimir Barinov, <vbarinov@embeddedalley.com>
5 * Copyright: (C) 2007 MontaVista Software, Inc., <source@mvista.com>
6 * added SRAM ping/pong (C) 2008 Troy Kisky <troy.kisky@boundarydevices.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/module.h>
14#include <linux/init.h>
15#include <linux/platform_device.h>
16#include <linux/slab.h>
17#include <linux/dma-mapping.h>
18#include <linux/kernel.h>
19#include <linux/genalloc.h>
20#include <linux/platform_data/edma.h>
21
22#include <sound/core.h>
23#include <sound/pcm.h>
24#include <sound/pcm_params.h>
25#include <sound/soc.h>
26
27#include <asm/dma.h>
28
29#include "davinci-pcm.h"
30
31#ifdef DEBUG
32static void print_buf_info(int slot, char *name)
33{
34 struct edmacc_param p;
35 if (slot < 0)
36 return;
37 edma_read_slot(slot, &p);
38 printk(KERN_DEBUG "%s: 0x%x, opt=%x, src=%x, a_b_cnt=%x dst=%x\n",
39 name, slot, p.opt, p.src, p.a_b_cnt, p.dst);
40 printk(KERN_DEBUG " src_dst_bidx=%x link_bcntrld=%x src_dst_cidx=%x ccnt=%x\n",
41 p.src_dst_bidx, p.link_bcntrld, p.src_dst_cidx, p.ccnt);
42}
43#else
44static void print_buf_info(int slot, char *name)
45{
46}
47#endif
48
49static struct snd_pcm_hardware pcm_hardware_playback = {
50 .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
51 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
52 SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME|
53 SNDRV_PCM_INFO_BATCH),
54 .buffer_bytes_max = 128 * 1024,
55 .period_bytes_min = 32,
56 .period_bytes_max = 8 * 1024,
57 .periods_min = 16,
58 .periods_max = 255,
59 .fifo_size = 0,
60};
61
62static struct snd_pcm_hardware pcm_hardware_capture = {
63 .info = (SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER |
64 SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID |
65 SNDRV_PCM_INFO_PAUSE |
66 SNDRV_PCM_INFO_BATCH),
67 .buffer_bytes_max = 128 * 1024,
68 .period_bytes_min = 32,
69 .period_bytes_max = 8 * 1024,
70 .periods_min = 16,
71 .periods_max = 255,
72 .fifo_size = 0,
73};
74
75/*
76 * How ping/pong works....
77 *
78 * Playback:
79 * ram_params - copys 2*ping_size from start of SDRAM to iram,
80 * links to ram_link2
81 * ram_link2 - copys rest of SDRAM to iram in ping_size units,
82 * links to ram_link
83 * ram_link - copys entire SDRAM to iram in ping_size uints,
84 * links to self
85 *
86 * asp_params - same as asp_link[0]
87 * asp_link[0] - copys from lower half of iram to asp port
88 * links to asp_link[1], triggers iram copy event on completion
89 * asp_link[1] - copys from upper half of iram to asp port
90 * links to asp_link[0], triggers iram copy event on completion
91 * triggers interrupt only needed to let upper SOC levels update position
92 * in stream on completion
93 *
94 * When playback is started:
95 * ram_params started
96 * asp_params started
97 *
98 * Capture:
99 * ram_params - same as ram_link,
100 * links to ram_link
101 * ram_link - same as playback
102 * links to self
103 *
104 * asp_params - same as playback
105 * asp_link[0] - same as playback
106 * asp_link[1] - same as playback
107 *
108 * When capture is started:
109 * asp_params started
110 */
111struct davinci_runtime_data {
112 spinlock_t lock;
113 int period; /* current DMA period */
114 int asp_channel; /* Master DMA channel */
115 int asp_link[2]; /* asp parameter link channel, ping/pong */
116 struct davinci_pcm_dma_params *params; /* DMA params */
117 int ram_channel;
118 int ram_link;
119 int ram_link2;
120 struct edmacc_param asp_params;
121 struct edmacc_param ram_params;
122};
123
124static void davinci_pcm_period_elapsed(struct snd_pcm_substream *substream)
125{
126 struct davinci_runtime_data *prtd = substream->runtime->private_data;
127 struct snd_pcm_runtime *runtime = substream->runtime;
128
129 prtd->period++;
130 if (unlikely(prtd->period >= runtime->periods))
131 prtd->period = 0;
132}
133
134static void davinci_pcm_period_reset(struct snd_pcm_substream *substream)
135{
136 struct davinci_runtime_data *prtd = substream->runtime->private_data;
137
138 prtd->period = 0;
139}
140/*
141 * Not used with ping/pong
142 */
143static void davinci_pcm_enqueue_dma(struct snd_pcm_substream *substream)
144{
145 struct davinci_runtime_data *prtd = substream->runtime->private_data;
146 struct snd_pcm_runtime *runtime = substream->runtime;
147 unsigned int period_size;
148 unsigned int dma_offset;
149 dma_addr_t dma_pos;
150 dma_addr_t src, dst;
151 unsigned short src_bidx, dst_bidx;
152 unsigned short src_cidx, dst_cidx;
153 unsigned int data_type;
154 unsigned short acnt;
155 unsigned int count;
156 unsigned int fifo_level;
157
158 period_size = snd_pcm_lib_period_bytes(substream);
159 dma_offset = prtd->period * period_size;
160 dma_pos = runtime->dma_addr + dma_offset;
161 fifo_level = prtd->params->fifo_level;
162
163 pr_debug("davinci_pcm: audio_set_dma_params_play channel = %d "
164 "dma_ptr = %x period_size=%x\n", prtd->asp_link[0], dma_pos,
165 period_size);
166
167 data_type = prtd->params->data_type;
168 count = period_size / data_type;
169 if (fifo_level)
170 count /= fifo_level;
171
172 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
173 src = dma_pos;
174 dst = prtd->params->dma_addr;
175 src_bidx = data_type;
176 dst_bidx = 4;
177 src_cidx = data_type * fifo_level;
178 dst_cidx = 0;
179 } else {
180 src = prtd->params->dma_addr;
181 dst = dma_pos;
182 src_bidx = 0;
183 dst_bidx = data_type;
184 src_cidx = 0;
185 dst_cidx = data_type * fifo_level;
186 }
187
188 acnt = prtd->params->acnt;
189 edma_set_src(prtd->asp_link[0], src, INCR, W8BIT);
190 edma_set_dest(prtd->asp_link[0], dst, INCR, W8BIT);
191
192 edma_set_src_index(prtd->asp_link[0], src_bidx, src_cidx);
193 edma_set_dest_index(prtd->asp_link[0], dst_bidx, dst_cidx);
194
195 if (!fifo_level)
196 edma_set_transfer_params(prtd->asp_link[0], acnt, count, 1, 0,
197 ASYNC);
198 else
199 edma_set_transfer_params(prtd->asp_link[0], acnt,
200 fifo_level,
201 count, fifo_level,
202 ABSYNC);
203}
204
205static void davinci_pcm_dma_irq(unsigned link, u16 ch_status, void *data)
206{
207 struct snd_pcm_substream *substream = data;
208 struct davinci_runtime_data *prtd = substream->runtime->private_data;
209
210 print_buf_info(prtd->ram_channel, "i ram_channel");
211 pr_debug("davinci_pcm: link=%d, status=0x%x\n", link, ch_status);
212
213 if (unlikely(ch_status != EDMA_DMA_COMPLETE))
214 return;
215
216 if (snd_pcm_running(substream)) {
217 spin_lock(&prtd->lock);
218 if (prtd->ram_channel < 0) {
219 /* No ping/pong must fix up link dma data*/
220 davinci_pcm_enqueue_dma(substream);
221 }
222 davinci_pcm_period_elapsed(substream);
223 spin_unlock(&prtd->lock);
224 snd_pcm_period_elapsed(substream);
225 }
226}
227
228#ifdef CONFIG_GENERIC_ALLOCATOR
229static int allocate_sram(struct snd_pcm_substream *substream,
230 struct gen_pool *sram_pool, unsigned size,
231 struct snd_pcm_hardware *ppcm)
232{
233 struct snd_dma_buffer *buf = &substream->dma_buffer;
234 struct snd_dma_buffer *iram_dma = NULL;
235 dma_addr_t iram_phys = 0;
236 void *iram_virt = NULL;
237
238 if (buf->private_data || !size)
239 return 0;
240
241 ppcm->period_bytes_max = size;
242 iram_virt = gen_pool_dma_alloc(sram_pool, size, &iram_phys);
243 if (!iram_virt)
244 goto exit1;
245 iram_dma = kzalloc(sizeof(*iram_dma), GFP_KERNEL);
246 if (!iram_dma)
247 goto exit2;
248 iram_dma->area = iram_virt;
249 iram_dma->addr = iram_phys;
250 memset(iram_dma->area, 0, size);
251 iram_dma->bytes = size;
252 buf->private_data = iram_dma;
253 return 0;
254exit2:
255 if (iram_virt)
256 gen_pool_free(sram_pool, (unsigned)iram_virt, size);
257exit1:
258 return -ENOMEM;
259}
260
261static void davinci_free_sram(struct snd_pcm_substream *substream,
262 struct snd_dma_buffer *iram_dma)
263{
264 struct davinci_runtime_data *prtd = substream->runtime->private_data;
265 struct gen_pool *sram_pool = prtd->params->sram_pool;
266
267 gen_pool_free(sram_pool, (unsigned) iram_dma->area, iram_dma->bytes);
268}
269#else
270static int allocate_sram(struct snd_pcm_substream *substream,
271 struct gen_pool *sram_pool, unsigned size,
272 struct snd_pcm_hardware *ppcm)
273{
274 return 0;
275}
276
277static void davinci_free_sram(struct snd_pcm_substream *substream,
278 struct snd_dma_buffer *iram_dma)
279{
280}
281#endif
282
283/*
284 * Only used with ping/pong.
285 * This is called after runtime->dma_addr, period_bytes and data_type are valid
286 */
287static int ping_pong_dma_setup(struct snd_pcm_substream *substream)
288{
289 unsigned short ram_src_cidx, ram_dst_cidx;
290 struct snd_pcm_runtime *runtime = substream->runtime;
291 struct davinci_runtime_data *prtd = runtime->private_data;
292 struct snd_dma_buffer *iram_dma =
293 (struct snd_dma_buffer *)substream->dma_buffer.private_data;
294 struct davinci_pcm_dma_params *params = prtd->params;
295 unsigned int data_type = params->data_type;
296 unsigned int acnt = params->acnt;
297 /* divide by 2 for ping/pong */
298 unsigned int ping_size = snd_pcm_lib_period_bytes(substream) >> 1;
299 unsigned int fifo_level = prtd->params->fifo_level;
300 unsigned int count;
301 if ((data_type == 0) || (data_type > 4)) {
302 printk(KERN_ERR "%s: data_type=%i\n", __func__, data_type);
303 return -EINVAL;
304 }
305 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
306 dma_addr_t asp_src_pong = iram_dma->addr + ping_size;
307 ram_src_cidx = ping_size;
308 ram_dst_cidx = -ping_size;
309 edma_set_src(prtd->asp_link[1], asp_src_pong, INCR, W8BIT);
310
311 edma_set_src_index(prtd->asp_link[0], data_type,
312 data_type * fifo_level);
313 edma_set_src_index(prtd->asp_link[1], data_type,
314 data_type * fifo_level);
315
316 edma_set_src(prtd->ram_link, runtime->dma_addr, INCR, W32BIT);
317 } else {
318 dma_addr_t asp_dst_pong = iram_dma->addr + ping_size;
319 ram_src_cidx = -ping_size;
320 ram_dst_cidx = ping_size;
321 edma_set_dest(prtd->asp_link[1], asp_dst_pong, INCR, W8BIT);
322
323 edma_set_dest_index(prtd->asp_link[0], data_type,
324 data_type * fifo_level);
325 edma_set_dest_index(prtd->asp_link[1], data_type,
326 data_type * fifo_level);
327
328 edma_set_dest(prtd->ram_link, runtime->dma_addr, INCR, W32BIT);
329 }
330
331 if (!fifo_level) {
332 count = ping_size / data_type;
333 edma_set_transfer_params(prtd->asp_link[0], acnt, count,
334 1, 0, ASYNC);
335 edma_set_transfer_params(prtd->asp_link[1], acnt, count,
336 1, 0, ASYNC);
337 } else {
338 count = ping_size / (data_type * fifo_level);
339 edma_set_transfer_params(prtd->asp_link[0], acnt, fifo_level,
340 count, fifo_level, ABSYNC);
341 edma_set_transfer_params(prtd->asp_link[1], acnt, fifo_level,
342 count, fifo_level, ABSYNC);
343 }
344
345 edma_set_src_index(prtd->ram_link, ping_size, ram_src_cidx);
346 edma_set_dest_index(prtd->ram_link, ping_size, ram_dst_cidx);
347 edma_set_transfer_params(prtd->ram_link, ping_size, 2,
348 runtime->periods, 2, ASYNC);
349
350 /* init master params */
351 edma_read_slot(prtd->asp_link[0], &prtd->asp_params);
352 edma_read_slot(prtd->ram_link, &prtd->ram_params);
353 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
354 struct edmacc_param p_ram;
355 /* Copy entire iram buffer before playback started */
356 prtd->ram_params.a_b_cnt = (1 << 16) | (ping_size << 1);
357 /* 0 dst_bidx */
358 prtd->ram_params.src_dst_bidx = (ping_size << 1);
359 /* 0 dst_cidx */
360 prtd->ram_params.src_dst_cidx = (ping_size << 1);
361 prtd->ram_params.ccnt = 1;
362
363 /* Skip 1st period */
364 edma_read_slot(prtd->ram_link, &p_ram);
365 p_ram.src += (ping_size << 1);
366 p_ram.ccnt -= 1;
367 edma_write_slot(prtd->ram_link2, &p_ram);
368 /*
369 * When 1st started, ram -> iram dma channel will fill the
370 * entire iram. Then, whenever a ping/pong asp buffer finishes,
371 * 1/2 iram will be filled.
372 */
373 prtd->ram_params.link_bcntrld =
374 EDMA_CHAN_SLOT(prtd->ram_link2) << 5;
375 }
376 return 0;
377}
378
379/* 1 asp tx or rx channel using 2 parameter channels
380 * 1 ram to/from iram channel using 1 parameter channel
381 *
382 * Playback
383 * ram copy channel kicks off first,
384 * 1st ram copy of entire iram buffer completion kicks off asp channel
385 * asp tcc always kicks off ram copy of 1/2 iram buffer
386 *
387 * Record
388 * asp channel starts, tcc kicks off ram copy
389 */
390static int request_ping_pong(struct snd_pcm_substream *substream,
391 struct davinci_runtime_data *prtd,
392 struct snd_dma_buffer *iram_dma)
393{
394 dma_addr_t asp_src_ping;
395 dma_addr_t asp_dst_ping;
396 int ret;
397 struct davinci_pcm_dma_params *params = prtd->params;
398
399 /* Request ram master channel */
400 ret = prtd->ram_channel = edma_alloc_channel(EDMA_CHANNEL_ANY,
401 davinci_pcm_dma_irq, substream,
402 prtd->params->ram_chan_q);
403 if (ret < 0)
404 goto exit1;
405
406 /* Request ram link channel */
407 ret = prtd->ram_link = edma_alloc_slot(
408 EDMA_CTLR(prtd->ram_channel), EDMA_SLOT_ANY);
409 if (ret < 0)
410 goto exit2;
411
412 ret = prtd->asp_link[1] = edma_alloc_slot(
413 EDMA_CTLR(prtd->asp_channel), EDMA_SLOT_ANY);
414 if (ret < 0)
415 goto exit3;
416
417 prtd->ram_link2 = -1;
418 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
419 ret = prtd->ram_link2 = edma_alloc_slot(
420 EDMA_CTLR(prtd->ram_channel), EDMA_SLOT_ANY);
421 if (ret < 0)
422 goto exit4;
423 }
424 /* circle ping-pong buffers */
425 edma_link(prtd->asp_link[0], prtd->asp_link[1]);
426 edma_link(prtd->asp_link[1], prtd->asp_link[0]);
427 /* circle ram buffers */
428 edma_link(prtd->ram_link, prtd->ram_link);
429
430 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
431 asp_src_ping = iram_dma->addr;
432 asp_dst_ping = params->dma_addr; /* fifo */
433 } else {
434 asp_src_ping = params->dma_addr; /* fifo */
435 asp_dst_ping = iram_dma->addr;
436 }
437 /* ping */
438 edma_set_src(prtd->asp_link[0], asp_src_ping, INCR, W16BIT);
439 edma_set_dest(prtd->asp_link[0], asp_dst_ping, INCR, W16BIT);
440 edma_set_src_index(prtd->asp_link[0], 0, 0);
441 edma_set_dest_index(prtd->asp_link[0], 0, 0);
442
443 edma_read_slot(prtd->asp_link[0], &prtd->asp_params);
444 prtd->asp_params.opt &= ~(TCCMODE | EDMA_TCC(0x3f) | TCINTEN);
445 prtd->asp_params.opt |= TCCHEN |
446 EDMA_TCC(prtd->ram_channel & 0x3f);
447 edma_write_slot(prtd->asp_link[0], &prtd->asp_params);
448
449 /* pong */
450 edma_set_src(prtd->asp_link[1], asp_src_ping, INCR, W16BIT);
451 edma_set_dest(prtd->asp_link[1], asp_dst_ping, INCR, W16BIT);
452 edma_set_src_index(prtd->asp_link[1], 0, 0);
453 edma_set_dest_index(prtd->asp_link[1], 0, 0);
454
455 edma_read_slot(prtd->asp_link[1], &prtd->asp_params);
456 prtd->asp_params.opt &= ~(TCCMODE | EDMA_TCC(0x3f));
457 /* interrupt after every pong completion */
458 prtd->asp_params.opt |= TCINTEN | TCCHEN |
459 EDMA_TCC(prtd->ram_channel & 0x3f);
460 edma_write_slot(prtd->asp_link[1], &prtd->asp_params);
461
462 /* ram */
463 edma_set_src(prtd->ram_link, iram_dma->addr, INCR, W32BIT);
464 edma_set_dest(prtd->ram_link, iram_dma->addr, INCR, W32BIT);
465 pr_debug("%s: audio dma channels/slots in use for ram:%u %u %u,"
466 "for asp:%u %u %u\n", __func__,
467 prtd->ram_channel, prtd->ram_link, prtd->ram_link2,
468 prtd->asp_channel, prtd->asp_link[0],
469 prtd->asp_link[1]);
470 return 0;
471exit4:
472 edma_free_channel(prtd->asp_link[1]);
473 prtd->asp_link[1] = -1;
474exit3:
475 edma_free_channel(prtd->ram_link);
476 prtd->ram_link = -1;
477exit2:
478 edma_free_channel(prtd->ram_channel);
479 prtd->ram_channel = -1;
480exit1:
481 return ret;
482}
483
484static int davinci_pcm_dma_request(struct snd_pcm_substream *substream)
485{
486 struct snd_dma_buffer *iram_dma;
487 struct davinci_runtime_data *prtd = substream->runtime->private_data;
488 struct davinci_pcm_dma_params *params = prtd->params;
489 int ret;
490
491 if (!params)
492 return -ENODEV;
493
494 /* Request asp master DMA channel */
495 ret = prtd->asp_channel = edma_alloc_channel(params->channel,
496 davinci_pcm_dma_irq, substream,
497 prtd->params->asp_chan_q);
498 if (ret < 0)
499 goto exit1;
500
501 /* Request asp link channels */
502 ret = prtd->asp_link[0] = edma_alloc_slot(
503 EDMA_CTLR(prtd->asp_channel), EDMA_SLOT_ANY);
504 if (ret < 0)
505 goto exit2;
506
507 iram_dma = (struct snd_dma_buffer *)substream->dma_buffer.private_data;
508 if (iram_dma) {
509 if (request_ping_pong(substream, prtd, iram_dma) == 0)
510 return 0;
511 printk(KERN_WARNING "%s: dma channel allocation failed,"
512 "not using sram\n", __func__);
513 }
514
515 /* Issue transfer completion IRQ when the channel completes a
516 * transfer, then always reload from the same slot (by a kind
517 * of loopback link). The completion IRQ handler will update
518 * the reload slot with a new buffer.
519 *
520 * REVISIT save p_ram here after setting up everything except
521 * the buffer and its length (ccnt) ... use it as a template
522 * so davinci_pcm_enqueue_dma() takes less time in IRQ.
523 */
524 edma_read_slot(prtd->asp_link[0], &prtd->asp_params);
525 prtd->asp_params.opt |= TCINTEN |
526 EDMA_TCC(EDMA_CHAN_SLOT(prtd->asp_channel));
527 prtd->asp_params.link_bcntrld = EDMA_CHAN_SLOT(prtd->asp_link[0]) << 5;
528 edma_write_slot(prtd->asp_link[0], &prtd->asp_params);
529 return 0;
530exit2:
531 edma_free_channel(prtd->asp_channel);
532 prtd->asp_channel = -1;
533exit1:
534 return ret;
535}
536
537static int davinci_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
538{
539 struct davinci_runtime_data *prtd = substream->runtime->private_data;
540 int ret = 0;
541
542 spin_lock(&prtd->lock);
543
544 switch (cmd) {
545 case SNDRV_PCM_TRIGGER_START:
546 edma_start(prtd->asp_channel);
547 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
548 prtd->ram_channel >= 0) {
549 /* copy 1st iram buffer */
550 edma_start(prtd->ram_channel);
551 }
552 break;
553 case SNDRV_PCM_TRIGGER_RESUME:
554 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
555 edma_resume(prtd->asp_channel);
556 break;
557 case SNDRV_PCM_TRIGGER_STOP:
558 case SNDRV_PCM_TRIGGER_SUSPEND:
559 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
560 edma_pause(prtd->asp_channel);
561 break;
562 default:
563 ret = -EINVAL;
564 break;
565 }
566
567 spin_unlock(&prtd->lock);
568
569 return ret;
570}
571
572static int davinci_pcm_prepare(struct snd_pcm_substream *substream)
573{
574 struct davinci_runtime_data *prtd = substream->runtime->private_data;
575
576 davinci_pcm_period_reset(substream);
577 if (prtd->ram_channel >= 0) {
578 int ret = ping_pong_dma_setup(substream);
579 if (ret < 0)
580 return ret;
581
582 edma_write_slot(prtd->ram_channel, &prtd->ram_params);
583 edma_write_slot(prtd->asp_channel, &prtd->asp_params);
584
585 print_buf_info(prtd->ram_channel, "ram_channel");
586 print_buf_info(prtd->ram_link, "ram_link");
587 print_buf_info(prtd->ram_link2, "ram_link2");
588 print_buf_info(prtd->asp_channel, "asp_channel");
589 print_buf_info(prtd->asp_link[0], "asp_link[0]");
590 print_buf_info(prtd->asp_link[1], "asp_link[1]");
591
592 /*
593 * There is a phase offset of 2 periods between the position
594 * used by dma setup and the position reported in the pointer
595 * function.
596 *
597 * The phase offset, when not using ping-pong buffers, is due to
598 * the two consecutive calls to davinci_pcm_enqueue_dma() below.
599 *
600 * Whereas here, with ping-pong buffers, the phase is due to
601 * there being an entire buffer transfer complete before the
602 * first dma completion event triggers davinci_pcm_dma_irq().
603 */
604 davinci_pcm_period_elapsed(substream);
605 davinci_pcm_period_elapsed(substream);
606
607 return 0;
608 }
609 davinci_pcm_enqueue_dma(substream);
610 davinci_pcm_period_elapsed(substream);
611
612 /* Copy self-linked parameter RAM entry into master channel */
613 edma_read_slot(prtd->asp_link[0], &prtd->asp_params);
614 edma_write_slot(prtd->asp_channel, &prtd->asp_params);
615 davinci_pcm_enqueue_dma(substream);
616 davinci_pcm_period_elapsed(substream);
617
618 return 0;
619}
620
621static snd_pcm_uframes_t
622davinci_pcm_pointer(struct snd_pcm_substream *substream)
623{
624 struct snd_pcm_runtime *runtime = substream->runtime;
625 struct davinci_runtime_data *prtd = runtime->private_data;
626 unsigned int offset;
627 int asp_count;
628 unsigned int period_size = snd_pcm_lib_period_bytes(substream);
629
630 /*
631 * There is a phase offset of 2 periods between the position used by dma
632 * setup and the position reported in the pointer function. Either +2 in
633 * the dma setup or -2 here in the pointer function (with wrapping,
634 * both) accounts for this offset -- choose the latter since it makes
635 * the first-time setup clearer.
636 */
637 spin_lock(&prtd->lock);
638 asp_count = prtd->period - 2;
639 spin_unlock(&prtd->lock);
640
641 if (asp_count < 0)
642 asp_count += runtime->periods;
643 asp_count *= period_size;
644
645 offset = bytes_to_frames(runtime, asp_count);
646 if (offset >= runtime->buffer_size)
647 offset = 0;
648
649 return offset;
650}
651
652static int davinci_pcm_open(struct snd_pcm_substream *substream)
653{
654 struct snd_pcm_runtime *runtime = substream->runtime;
655 struct davinci_runtime_data *prtd;
656 struct snd_pcm_hardware *ppcm;
657 int ret = 0;
658 struct snd_soc_pcm_runtime *rtd = substream->private_data;
659 struct davinci_pcm_dma_params *pa;
660 struct davinci_pcm_dma_params *params;
661
662 pa = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
663 if (!pa)
664 return -ENODEV;
665 params = &pa[substream->stream];
666
667 ppcm = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
668 &pcm_hardware_playback : &pcm_hardware_capture;
669 allocate_sram(substream, params->sram_pool, params->sram_size, ppcm);
670 snd_soc_set_runtime_hwparams(substream, ppcm);
671 /* ensure that buffer size is a multiple of period size */
672 ret = snd_pcm_hw_constraint_integer(runtime,
673 SNDRV_PCM_HW_PARAM_PERIODS);
674 if (ret < 0)
675 return ret;
676
677 prtd = kzalloc(sizeof(struct davinci_runtime_data), GFP_KERNEL);
678 if (prtd == NULL)
679 return -ENOMEM;
680
681 spin_lock_init(&prtd->lock);
682 prtd->params = params;
683 prtd->asp_channel = -1;
684 prtd->asp_link[0] = prtd->asp_link[1] = -1;
685 prtd->ram_channel = -1;
686 prtd->ram_link = -1;
687 prtd->ram_link2 = -1;
688
689 runtime->private_data = prtd;
690
691 ret = davinci_pcm_dma_request(substream);
692 if (ret) {
693 printk(KERN_ERR "davinci_pcm: Failed to get dma channels\n");
694 kfree(prtd);
695 }
696
697 return ret;
698}
699
700static int davinci_pcm_close(struct snd_pcm_substream *substream)
701{
702 struct snd_pcm_runtime *runtime = substream->runtime;
703 struct davinci_runtime_data *prtd = runtime->private_data;
704
705 if (prtd->ram_channel >= 0)
706 edma_stop(prtd->ram_channel);
707 if (prtd->asp_channel >= 0)
708 edma_stop(prtd->asp_channel);
709 if (prtd->asp_link[0] >= 0)
710 edma_unlink(prtd->asp_link[0]);
711 if (prtd->asp_link[1] >= 0)
712 edma_unlink(prtd->asp_link[1]);
713 if (prtd->ram_link >= 0)
714 edma_unlink(prtd->ram_link);
715
716 if (prtd->asp_link[0] >= 0)
717 edma_free_slot(prtd->asp_link[0]);
718 if (prtd->asp_link[1] >= 0)
719 edma_free_slot(prtd->asp_link[1]);
720 if (prtd->asp_channel >= 0)
721 edma_free_channel(prtd->asp_channel);
722 if (prtd->ram_link >= 0)
723 edma_free_slot(prtd->ram_link);
724 if (prtd->ram_link2 >= 0)
725 edma_free_slot(prtd->ram_link2);
726 if (prtd->ram_channel >= 0)
727 edma_free_channel(prtd->ram_channel);
728
729 kfree(prtd);
730
731 return 0;
732}
733
734static int davinci_pcm_hw_params(struct snd_pcm_substream *substream,
735 struct snd_pcm_hw_params *hw_params)
736{
737 return snd_pcm_lib_malloc_pages(substream,
738 params_buffer_bytes(hw_params));
739}
740
741static int davinci_pcm_hw_free(struct snd_pcm_substream *substream)
742{
743 return snd_pcm_lib_free_pages(substream);
744}
745
746static int davinci_pcm_mmap(struct snd_pcm_substream *substream,
747 struct vm_area_struct *vma)
748{
749 struct snd_pcm_runtime *runtime = substream->runtime;
750
751 return dma_mmap_writecombine(substream->pcm->card->dev, vma,
752 runtime->dma_area,
753 runtime->dma_addr,
754 runtime->dma_bytes);
755}
756
757static struct snd_pcm_ops davinci_pcm_ops = {
758 .open = davinci_pcm_open,
759 .close = davinci_pcm_close,
760 .ioctl = snd_pcm_lib_ioctl,
761 .hw_params = davinci_pcm_hw_params,
762 .hw_free = davinci_pcm_hw_free,
763 .prepare = davinci_pcm_prepare,
764 .trigger = davinci_pcm_trigger,
765 .pointer = davinci_pcm_pointer,
766 .mmap = davinci_pcm_mmap,
767};
768
769static int davinci_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream,
770 size_t size)
771{
772 struct snd_pcm_substream *substream = pcm->streams[stream].substream;
773 struct snd_dma_buffer *buf = &substream->dma_buffer;
774
775 buf->dev.type = SNDRV_DMA_TYPE_DEV;
776 buf->dev.dev = pcm->card->dev;
777 buf->private_data = NULL;
778 buf->area = dma_alloc_writecombine(pcm->card->dev, size,
779 &buf->addr, GFP_KERNEL);
780
781 pr_debug("davinci_pcm: preallocate_dma_buffer: area=%p, addr=%p, "
782 "size=%d\n", (void *) buf->area, (void *) buf->addr, size);
783
784 if (!buf->area)
785 return -ENOMEM;
786
787 buf->bytes = size;
788 return 0;
789}
790
791static void davinci_pcm_free(struct snd_pcm *pcm)
792{
793 struct snd_pcm_substream *substream;
794 struct snd_dma_buffer *buf;
795 int stream;
796
797 for (stream = 0; stream < 2; stream++) {
798 struct snd_dma_buffer *iram_dma;
799 substream = pcm->streams[stream].substream;
800 if (!substream)
801 continue;
802
803 buf = &substream->dma_buffer;
804 if (!buf->area)
805 continue;
806
807 dma_free_writecombine(pcm->card->dev, buf->bytes,
808 buf->area, buf->addr);
809 buf->area = NULL;
810 iram_dma = buf->private_data;
811 if (iram_dma) {
812 davinci_free_sram(substream, iram_dma);
813 kfree(iram_dma);
814 }
815 }
816}
817
818static int davinci_pcm_new(struct snd_soc_pcm_runtime *rtd)
819{
820 struct snd_card *card = rtd->card->snd_card;
821 struct snd_pcm *pcm = rtd->pcm;
822 int ret;
823
824 ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
825 if (ret)
826 return ret;
827
828 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
829 ret = davinci_pcm_preallocate_dma_buffer(pcm,
830 SNDRV_PCM_STREAM_PLAYBACK,
831 pcm_hardware_playback.buffer_bytes_max);
832 if (ret)
833 return ret;
834 }
835
836 if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) {
837 ret = davinci_pcm_preallocate_dma_buffer(pcm,
838 SNDRV_PCM_STREAM_CAPTURE,
839 pcm_hardware_capture.buffer_bytes_max);
840 if (ret)
841 return ret;
842 }
843
844 return 0;
845}
846
847static struct snd_soc_platform_driver davinci_soc_platform = {
848 .ops = &davinci_pcm_ops,
849 .pcm_new = davinci_pcm_new,
850 .pcm_free = davinci_pcm_free,
851};
852
853int davinci_soc_platform_register(struct device *dev)
854{
855 return devm_snd_soc_register_platform(dev, &davinci_soc_platform);
856}
857EXPORT_SYMBOL_GPL(davinci_soc_platform_register);
858
859MODULE_AUTHOR("Vladimir Barinov");
860MODULE_DESCRIPTION("TI DAVINCI PCM DMA module");
861MODULE_LICENSE("GPL");
diff --git a/sound/soc/davinci/davinci-pcm.h b/sound/soc/davinci/davinci-pcm.h
deleted file mode 100644
index 0fe2346a9aa2..000000000000
--- a/sound/soc/davinci/davinci-pcm.h
+++ /dev/null
@@ -1,41 +0,0 @@
1/*
2 * ALSA PCM interface for the TI DAVINCI processor
3 *
4 * Author: Vladimir Barinov, <vbarinov@embeddedalley.com>
5 * Copyright: (C) 2007 MontaVista Software, Inc., <source@mvista.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#ifndef _DAVINCI_PCM_H
13#define _DAVINCI_PCM_H
14
15#include <linux/genalloc.h>
16#include <linux/platform_data/davinci_asp.h>
17#include <linux/platform_data/edma.h>
18
19struct davinci_pcm_dma_params {
20 int channel; /* sync dma channel ID */
21 unsigned short acnt;
22 dma_addr_t dma_addr; /* device physical address for DMA */
23 unsigned sram_size;
24 struct gen_pool *sram_pool; /* SRAM gen_pool for ping pong */
25 enum dma_event_q asp_chan_q; /* event queue number for ASP channel */
26 enum dma_event_q ram_chan_q; /* event queue number for RAM channel */
27 unsigned char data_type; /* xfer data type */
28 unsigned char convert_mono_stereo;
29 unsigned int fifo_level;
30};
31
32#if IS_ENABLED(CONFIG_SND_DAVINCI_SOC)
33int davinci_soc_platform_register(struct device *dev);
34#else
35static inline int davinci_soc_platform_register(struct device *dev)
36{
37 return 0;
38}
39#endif /* CONFIG_SND_DAVINCI_SOC */
40
41#endif
diff --git a/sound/soc/davinci/davinci-vcif.c b/sound/soc/davinci/davinci-vcif.c
index 5bee04279ebe..fabd05f24aeb 100644
--- a/sound/soc/davinci/davinci-vcif.c
+++ b/sound/soc/davinci/davinci-vcif.c
@@ -33,8 +33,9 @@
33#include <sound/pcm_params.h> 33#include <sound/pcm_params.h>
34#include <sound/initval.h> 34#include <sound/initval.h>
35#include <sound/soc.h> 35#include <sound/soc.h>
36#include <sound/dmaengine_pcm.h>
36 37
37#include "davinci-pcm.h" 38#include "edma-pcm.h"
38#include "davinci-i2s.h" 39#include "davinci-i2s.h"
39 40
40#define MOD_REG_BIT(val, mask, set) do { \ 41#define MOD_REG_BIT(val, mask, set) do { \
@@ -47,7 +48,8 @@
47 48
48struct davinci_vcif_dev { 49struct davinci_vcif_dev {
49 struct davinci_vc *davinci_vc; 50 struct davinci_vc *davinci_vc;
50 struct davinci_pcm_dma_params dma_params[2]; 51 struct snd_dmaengine_dai_dma_data dma_data[2];
52 int dma_request[2];
51}; 53};
52 54
53static void davinci_vcif_start(struct snd_pcm_substream *substream) 55static void davinci_vcif_start(struct snd_pcm_substream *substream)
@@ -93,8 +95,6 @@ static int davinci_vcif_hw_params(struct snd_pcm_substream *substream,
93{ 95{
94 struct davinci_vcif_dev *davinci_vcif_dev = snd_soc_dai_get_drvdata(dai); 96 struct davinci_vcif_dev *davinci_vcif_dev = snd_soc_dai_get_drvdata(dai);
95 struct davinci_vc *davinci_vc = davinci_vcif_dev->davinci_vc; 97 struct davinci_vc *davinci_vc = davinci_vcif_dev->davinci_vc;
96 struct davinci_pcm_dma_params *dma_params =
97 &davinci_vcif_dev->dma_params[substream->stream];
98 u32 w; 98 u32 w;
99 99
100 /* Restart the codec before setup */ 100 /* Restart the codec before setup */
@@ -113,16 +113,12 @@ static int davinci_vcif_hw_params(struct snd_pcm_substream *substream,
113 /* Determine xfer data type */ 113 /* Determine xfer data type */
114 switch (params_format(params)) { 114 switch (params_format(params)) {
115 case SNDRV_PCM_FORMAT_U8: 115 case SNDRV_PCM_FORMAT_U8:
116 dma_params->data_type = 0;
117
118 MOD_REG_BIT(w, DAVINCI_VC_CTRL_RD_BITS_8 | 116 MOD_REG_BIT(w, DAVINCI_VC_CTRL_RD_BITS_8 |
119 DAVINCI_VC_CTRL_RD_UNSIGNED | 117 DAVINCI_VC_CTRL_RD_UNSIGNED |
120 DAVINCI_VC_CTRL_WD_BITS_8 | 118 DAVINCI_VC_CTRL_WD_BITS_8 |
121 DAVINCI_VC_CTRL_WD_UNSIGNED, 1); 119 DAVINCI_VC_CTRL_WD_UNSIGNED, 1);
122 break; 120 break;
123 case SNDRV_PCM_FORMAT_S8: 121 case SNDRV_PCM_FORMAT_S8:
124 dma_params->data_type = 1;
125
126 MOD_REG_BIT(w, DAVINCI_VC_CTRL_RD_BITS_8 | 122 MOD_REG_BIT(w, DAVINCI_VC_CTRL_RD_BITS_8 |
127 DAVINCI_VC_CTRL_WD_BITS_8, 1); 123 DAVINCI_VC_CTRL_WD_BITS_8, 1);
128 124
@@ -130,8 +126,6 @@ static int davinci_vcif_hw_params(struct snd_pcm_substream *substream,
130 DAVINCI_VC_CTRL_WD_UNSIGNED, 0); 126 DAVINCI_VC_CTRL_WD_UNSIGNED, 0);
131 break; 127 break;
132 case SNDRV_PCM_FORMAT_S16_LE: 128 case SNDRV_PCM_FORMAT_S16_LE:
133 dma_params->data_type = 2;
134
135 MOD_REG_BIT(w, DAVINCI_VC_CTRL_RD_BITS_8 | 129 MOD_REG_BIT(w, DAVINCI_VC_CTRL_RD_BITS_8 |
136 DAVINCI_VC_CTRL_RD_UNSIGNED | 130 DAVINCI_VC_CTRL_RD_UNSIGNED |
137 DAVINCI_VC_CTRL_WD_BITS_8 | 131 DAVINCI_VC_CTRL_WD_BITS_8 |
@@ -142,8 +136,6 @@ static int davinci_vcif_hw_params(struct snd_pcm_substream *substream,
142 return -EINVAL; 136 return -EINVAL;
143 } 137 }
144 138
145 dma_params->acnt = dma_params->data_type;
146
147 writel(w, davinci_vc->base + DAVINCI_VC_CTRL); 139 writel(w, davinci_vc->base + DAVINCI_VC_CTRL);
148 140
149 return 0; 141 return 0;
@@ -172,24 +164,25 @@ static int davinci_vcif_trigger(struct snd_pcm_substream *substream, int cmd,
172 return ret; 164 return ret;
173} 165}
174 166
175static int davinci_vcif_startup(struct snd_pcm_substream *substream,
176 struct snd_soc_dai *dai)
177{
178 struct davinci_vcif_dev *dev = snd_soc_dai_get_drvdata(dai);
179
180 snd_soc_dai_set_dma_data(dai, substream, dev->dma_params);
181 return 0;
182}
183
184#define DAVINCI_VCIF_RATES SNDRV_PCM_RATE_8000_48000 167#define DAVINCI_VCIF_RATES SNDRV_PCM_RATE_8000_48000
185 168
186static const struct snd_soc_dai_ops davinci_vcif_dai_ops = { 169static const struct snd_soc_dai_ops davinci_vcif_dai_ops = {
187 .startup = davinci_vcif_startup,
188 .trigger = davinci_vcif_trigger, 170 .trigger = davinci_vcif_trigger,
189 .hw_params = davinci_vcif_hw_params, 171 .hw_params = davinci_vcif_hw_params,
190}; 172};
191 173
174static int davinci_vcif_dai_probe(struct snd_soc_dai *dai)
175{
176 struct davinci_vcif_dev *dev = snd_soc_dai_get_drvdata(dai);
177
178 dai->playback_dma_data = &dev->dma_data[SNDRV_PCM_STREAM_PLAYBACK];
179 dai->capture_dma_data = &dev->dma_data[SNDRV_PCM_STREAM_CAPTURE];
180
181 return 0;
182}
183
192static struct snd_soc_dai_driver davinci_vcif_dai = { 184static struct snd_soc_dai_driver davinci_vcif_dai = {
185 .probe = davinci_vcif_dai_probe,
193 .playback = { 186 .playback = {
194 .channels_min = 1, 187 .channels_min = 1,
195 .channels_max = 2, 188 .channels_max = 2,
@@ -225,16 +218,16 @@ static int davinci_vcif_probe(struct platform_device *pdev)
225 218
226 /* DMA tx params */ 219 /* DMA tx params */
227 davinci_vcif_dev->davinci_vc = davinci_vc; 220 davinci_vcif_dev->davinci_vc = davinci_vc;
228 davinci_vcif_dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK].channel = 221 davinci_vcif_dev->dma_data[SNDRV_PCM_STREAM_PLAYBACK].filter_data =
229 davinci_vc->davinci_vcif.dma_tx_channel; 222 &davinci_vc->davinci_vcif.dma_tx_channel;
230 davinci_vcif_dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK].dma_addr = 223 davinci_vcif_dev->dma_data[SNDRV_PCM_STREAM_PLAYBACK].addr =
231 davinci_vc->davinci_vcif.dma_tx_addr; 224 davinci_vc->davinci_vcif.dma_tx_addr;
232 225
233 /* DMA rx params */ 226 /* DMA rx params */
234 davinci_vcif_dev->dma_params[SNDRV_PCM_STREAM_CAPTURE].channel = 227 davinci_vcif_dev->dma_data[SNDRV_PCM_STREAM_CAPTURE].filter_data =
235 davinci_vc->davinci_vcif.dma_rx_channel; 228 &davinci_vc->davinci_vcif.dma_rx_channel;
236 davinci_vcif_dev->dma_params[SNDRV_PCM_STREAM_CAPTURE].dma_addr = 229 davinci_vcif_dev->dma_data[SNDRV_PCM_STREAM_CAPTURE].addr =
237 davinci_vc->davinci_vcif.dma_rx_addr; 230 davinci_vc->davinci_vcif.dma_rx_addr;
238 231
239 dev_set_drvdata(&pdev->dev, davinci_vcif_dev); 232 dev_set_drvdata(&pdev->dev, davinci_vcif_dev);
240 233
@@ -245,7 +238,7 @@ static int davinci_vcif_probe(struct platform_device *pdev)
245 return ret; 238 return ret;
246 } 239 }
247 240
248 ret = davinci_soc_platform_register(&pdev->dev); 241 ret = edma_pcm_platform_register(&pdev->dev);
249 if (ret) { 242 if (ret) {
250 dev_err(&pdev->dev, "register PCM failed: %d\n", ret); 243 dev_err(&pdev->dev, "register PCM failed: %d\n", ret);
251 snd_soc_unregister_component(&pdev->dev); 244 snd_soc_unregister_component(&pdev->dev);
diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c
index 3f6959c8e2f7..de438871040b 100644
--- a/sound/soc/fsl/fsl-asoc-card.c
+++ b/sound/soc/fsl/fsl-asoc-card.c
@@ -512,6 +512,12 @@ static int fsl_asoc_card_probe(struct platform_device *pdev)
512 memcpy(priv->dai_link, fsl_asoc_card_dai, 512 memcpy(priv->dai_link, fsl_asoc_card_dai,
513 sizeof(struct snd_soc_dai_link) * ARRAY_SIZE(priv->dai_link)); 513 sizeof(struct snd_soc_dai_link) * ARRAY_SIZE(priv->dai_link));
514 514
515 ret = snd_soc_of_parse_audio_routing(&priv->card, "audio-routing");
516 if (ret) {
517 dev_err(&pdev->dev, "failed to parse audio-routing: %d\n", ret);
518 goto asrc_fail;
519 }
520
515 /* Normal DAI Link */ 521 /* Normal DAI Link */
516 priv->dai_link[0].cpu_of_node = cpu_np; 522 priv->dai_link[0].cpu_of_node = cpu_np;
517 priv->dai_link[0].codec_of_node = codec_np; 523 priv->dai_link[0].codec_of_node = codec_np;
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 2595611e8a6d..b9fabbf69db6 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -603,10 +603,6 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream,
603 factor = (div2 + 1) * (7 * psr + 1) * 2; 603 factor = (div2 + 1) * (7 * psr + 1) * 2;
604 604
605 for (i = 0; i < 255; i++) { 605 for (i = 0; i < 255; i++) {
606 /* The bclk rate must be smaller than 1/5 sysclk rate */
607 if (factor * (i + 1) < 5)
608 continue;
609
610 tmprate = freq * factor * (i + 2); 606 tmprate = freq * factor * (i + 2);
611 607
612 if (baudclk_is_used) 608 if (baudclk_is_used)
@@ -614,6 +610,13 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream,
614 else 610 else
615 clkrate = clk_round_rate(ssi_private->baudclk, tmprate); 611 clkrate = clk_round_rate(ssi_private->baudclk, tmprate);
616 612
613 /*
614 * Hardware limitation: The bclk rate must be
615 * never greater than 1/5 IPG clock rate
616 */
617 if (clkrate * 5 > clk_get_rate(ssi_private->clk))
618 continue;
619
617 clkrate /= factor; 620 clkrate /= factor;
618 afreq = clkrate / (i + 1); 621 afreq = clkrate / (i + 1);
619 622
diff --git a/sound/soc/fsl/imx-es8328.c b/sound/soc/fsl/imx-es8328.c
index f8cf10e16ce9..20e7400e2611 100644
--- a/sound/soc/fsl/imx-es8328.c
+++ b/sound/soc/fsl/imx-es8328.c
@@ -53,9 +53,9 @@ static int imx_es8328_dai_init(struct snd_soc_pcm_runtime *rtd)
53 53
54 /* Headphone jack detection */ 54 /* Headphone jack detection */
55 if (gpio_is_valid(data->jack_gpio)) { 55 if (gpio_is_valid(data->jack_gpio)) {
56 ret = snd_soc_jack_new(rtd->codec, "Headphone", 56 ret = snd_soc_card_jack_new(rtd->card, "Headphone",
57 SND_JACK_HEADPHONE | SND_JACK_BTN_0, 57 SND_JACK_HEADPHONE | SND_JACK_BTN_0,
58 &headset_jack); 58 &headset_jack, NULL, 0);
59 if (ret) 59 if (ret)
60 return ret; 60 return ret;
61 61
diff --git a/sound/soc/fsl/wm1133-ev1.c b/sound/soc/fsl/wm1133-ev1.c
index a958937ab405..0653aa83c927 100644
--- a/sound/soc/fsl/wm1133-ev1.c
+++ b/sound/soc/fsl/wm1133-ev1.c
@@ -205,16 +205,14 @@ static int wm1133_ev1_init(struct snd_soc_pcm_runtime *rtd)
205 struct snd_soc_dapm_context *dapm = &codec->dapm; 205 struct snd_soc_dapm_context *dapm = &codec->dapm;
206 206
207 /* Headphone jack detection */ 207 /* Headphone jack detection */
208 snd_soc_jack_new(codec, "Headphone", SND_JACK_HEADPHONE, &hp_jack); 208 snd_soc_card_jack_new(rtd->card, "Headphone", SND_JACK_HEADPHONE,
209 snd_soc_jack_add_pins(&hp_jack, ARRAY_SIZE(hp_jack_pins), 209 &hp_jack, hp_jack_pins, ARRAY_SIZE(hp_jack_pins));
210 hp_jack_pins);
211 wm8350_hp_jack_detect(codec, WM8350_JDR, &hp_jack, SND_JACK_HEADPHONE); 210 wm8350_hp_jack_detect(codec, WM8350_JDR, &hp_jack, SND_JACK_HEADPHONE);
212 211
213 /* Microphone jack detection */ 212 /* Microphone jack detection */
214 snd_soc_jack_new(codec, "Microphone", 213 snd_soc_card_jack_new(rtd->card, "Microphone",
215 SND_JACK_MICROPHONE | SND_JACK_BTN_0, &mic_jack); 214 SND_JACK_MICROPHONE | SND_JACK_BTN_0, &mic_jack,
216 snd_soc_jack_add_pins(&mic_jack, ARRAY_SIZE(mic_jack_pins), 215 mic_jack_pins, ARRAY_SIZE(mic_jack_pins));
217 mic_jack_pins);
218 wm8350_mic_jack_detect(codec, &mic_jack, SND_JACK_MICROPHONE, 216 wm8350_mic_jack_detect(codec, &mic_jack, SND_JACK_MICROPHONE,
219 SND_JACK_BTN_0); 217 SND_JACK_BTN_0);
220 218
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index f7c6734bd5da..c49a408fc7a6 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -176,11 +176,11 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
176 return ret; 176 return ret;
177 177
178 if (gpio_is_valid(priv->gpio_hp_det)) { 178 if (gpio_is_valid(priv->gpio_hp_det)) {
179 snd_soc_jack_new(codec->codec, "Headphones", SND_JACK_HEADPHONE, 179 snd_soc_card_jack_new(rtd->card, "Headphones",
180 &simple_card_hp_jack); 180 SND_JACK_HEADPHONE,
181 snd_soc_jack_add_pins(&simple_card_hp_jack, 181 &simple_card_hp_jack,
182 ARRAY_SIZE(simple_card_hp_jack_pins), 182 simple_card_hp_jack_pins,
183 simple_card_hp_jack_pins); 183 ARRAY_SIZE(simple_card_hp_jack_pins));
184 184
185 simple_card_hp_jack_gpio.gpio = priv->gpio_hp_det; 185 simple_card_hp_jack_gpio.gpio = priv->gpio_hp_det;
186 simple_card_hp_jack_gpio.invert = priv->gpio_hp_det_invert; 186 simple_card_hp_jack_gpio.invert = priv->gpio_hp_det_invert;
@@ -189,11 +189,11 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd)
189 } 189 }
190 190
191 if (gpio_is_valid(priv->gpio_mic_det)) { 191 if (gpio_is_valid(priv->gpio_mic_det)) {
192 snd_soc_jack_new(codec->codec, "Mic Jack", SND_JACK_MICROPHONE, 192 snd_soc_card_jack_new(rtd->card, "Mic Jack",
193 &simple_card_mic_jack); 193 SND_JACK_MICROPHONE,
194 snd_soc_jack_add_pins(&simple_card_mic_jack, 194 &simple_card_mic_jack,
195 ARRAY_SIZE(simple_card_mic_jack_pins), 195 simple_card_mic_jack_pins,
196 simple_card_mic_jack_pins); 196 ARRAY_SIZE(simple_card_mic_jack_pins));
197 simple_card_mic_jack_gpio.gpio = priv->gpio_mic_det; 197 simple_card_mic_jack_gpio.gpio = priv->gpio_mic_det;
198 simple_card_mic_jack_gpio.invert = priv->gpio_mic_det_invert; 198 simple_card_mic_jack_gpio.invert = priv->gpio_mic_det_invert;
199 snd_soc_jack_add_gpios(&simple_card_mic_jack, 1, 199 snd_soc_jack_add_gpios(&simple_card_mic_jack, 1,
@@ -372,6 +372,11 @@ static int asoc_simple_card_dai_link_of(struct device_node *node,
372 strlen(dai_link->cpu_dai_name) + 372 strlen(dai_link->cpu_dai_name) +
373 strlen(dai_link->codec_dai_name) + 2, 373 strlen(dai_link->codec_dai_name) + 2,
374 GFP_KERNEL); 374 GFP_KERNEL);
375 if (!name) {
376 ret = -ENOMEM;
377 goto dai_link_of_err;
378 }
379
375 sprintf(name, "%s-%s", dai_link->cpu_dai_name, 380 sprintf(name, "%s-%s", dai_link->cpu_dai_name,
376 dai_link->codec_dai_name); 381 dai_link->codec_dai_name);
377 dai_link->name = dai_link->stream_name = name; 382 dai_link->name = dai_link->stream_name = name;
diff --git a/sound/soc/intel/broadwell.c b/sound/soc/intel/broadwell.c
index 9cf7d01479ad..fc5542034b9b 100644
--- a/sound/soc/intel/broadwell.c
+++ b/sound/soc/intel/broadwell.c
@@ -80,15 +80,9 @@ static int broadwell_rt286_codec_init(struct snd_soc_pcm_runtime *rtd)
80{ 80{
81 struct snd_soc_codec *codec = rtd->codec; 81 struct snd_soc_codec *codec = rtd->codec;
82 int ret = 0; 82 int ret = 0;
83 ret = snd_soc_jack_new(codec, "Headset", 83 ret = snd_soc_card_jack_new(rtd->card, "Headset",
84 SND_JACK_HEADSET | SND_JACK_BTN_0, &broadwell_headset); 84 SND_JACK_HEADSET | SND_JACK_BTN_0, &broadwell_headset,
85 85 broadwell_headset_pins, ARRAY_SIZE(broadwell_headset_pins));
86 if (ret)
87 return ret;
88
89 ret = snd_soc_jack_add_pins(&broadwell_headset,
90 ARRAY_SIZE(broadwell_headset_pins),
91 broadwell_headset_pins);
92 if (ret) 86 if (ret)
93 return ret; 87 return ret;
94 88
@@ -110,9 +104,7 @@ static int broadwell_ssp0_fixup(struct snd_soc_pcm_runtime *rtd,
110 channels->min = channels->max = 2; 104 channels->min = channels->max = 2;
111 105
112 /* set SSP0 to 16 bit */ 106 /* set SSP0 to 16 bit */
113 snd_mask_set(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT - 107 params_set_format(params, SNDRV_PCM_FORMAT_S16_LE);
114 SNDRV_PCM_HW_PARAM_FIRST_MASK],
115 SNDRV_PCM_FORMAT_S16_LE);
116 return 0; 108 return 0;
117} 109}
118 110
diff --git a/sound/soc/intel/byt-max98090.c b/sound/soc/intel/byt-max98090.c
index 9832afe7d22c..d8b1f038da1c 100644
--- a/sound/soc/intel/byt-max98090.c
+++ b/sound/soc/intel/byt-max98090.c
@@ -84,7 +84,6 @@ static struct snd_soc_jack_gpio hs_jack_gpios[] = {
84static int byt_max98090_init(struct snd_soc_pcm_runtime *runtime) 84static int byt_max98090_init(struct snd_soc_pcm_runtime *runtime)
85{ 85{
86 int ret; 86 int ret;
87 struct snd_soc_codec *codec = runtime->codec;
88 struct snd_soc_card *card = runtime->card; 87 struct snd_soc_card *card = runtime->card;
89 struct byt_max98090_private *drv = snd_soc_card_get_drvdata(card); 88 struct byt_max98090_private *drv = snd_soc_card_get_drvdata(card);
90 struct snd_soc_jack *jack = &drv->jack; 89 struct snd_soc_jack *jack = &drv->jack;
@@ -100,13 +99,9 @@ static int byt_max98090_init(struct snd_soc_pcm_runtime *runtime)
100 } 99 }
101 100
102 /* Enable jack detection */ 101 /* Enable jack detection */
103 ret = snd_soc_jack_new(codec, "Headset", 102 ret = snd_soc_card_jack_new(runtime->card, "Headset",
104 SND_JACK_LINEOUT | SND_JACK_HEADSET, jack); 103 SND_JACK_LINEOUT | SND_JACK_HEADSET, jack,
105 if (ret) 104 hs_jack_pins, ARRAY_SIZE(hs_jack_pins));
106 return ret;
107
108 ret = snd_soc_jack_add_pins(jack, ARRAY_SIZE(hs_jack_pins),
109 hs_jack_pins);
110 if (ret) 105 if (ret)
111 return ret; 106 return ret;
112 107
diff --git a/sound/soc/intel/bytcr_dpcm_rt5640.c b/sound/soc/intel/bytcr_dpcm_rt5640.c
index 59308629043e..3b262d01c1b3 100644
--- a/sound/soc/intel/bytcr_dpcm_rt5640.c
+++ b/sound/soc/intel/bytcr_dpcm_rt5640.c
@@ -113,9 +113,7 @@ static int byt_codec_fixup(struct snd_soc_pcm_runtime *rtd,
113 channels->min = channels->max = 2; 113 channels->min = channels->max = 2;
114 114
115 /* set SSP2 to 24-bit */ 115 /* set SSP2 to 24-bit */
116 snd_mask_set(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT - 116 params_set_format(params, SNDRV_PCM_FORMAT_S24_LE);
117 SNDRV_PCM_HW_PARAM_FIRST_MASK],
118 SNDRV_PCM_FORMAT_S24_LE);
119 return 0; 117 return 0;
120} 118}
121 119
diff --git a/sound/soc/intel/cht_bsw_rt5645.c b/sound/soc/intel/cht_bsw_rt5645.c
index bd29617a9ab9..012227997ed9 100644
--- a/sound/soc/intel/cht_bsw_rt5645.c
+++ b/sound/soc/intel/cht_bsw_rt5645.c
@@ -169,17 +169,17 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime)
169 return ret; 169 return ret;
170 } 170 }
171 171
172 ret = snd_soc_jack_new(codec, "Headphone Jack", 172 ret = snd_soc_card_jack_new(runtime->card, "Headphone Jack",
173 SND_JACK_HEADPHONE, 173 SND_JACK_HEADPHONE, &ctx->hp_jack,
174 &ctx->hp_jack); 174 NULL, 0);
175 if (ret) { 175 if (ret) {
176 dev_err(runtime->dev, "HP jack creation failed %d\n", ret); 176 dev_err(runtime->dev, "HP jack creation failed %d\n", ret);
177 return ret; 177 return ret;
178 } 178 }
179 179
180 ret = snd_soc_jack_new(codec, "Mic Jack", 180 ret = snd_soc_card_jack_new(runtime->card, "Mic Jack",
181 SND_JACK_MICROPHONE, 181 SND_JACK_MICROPHONE, &ctx->mic_jack,
182 &ctx->mic_jack); 182 NULL, 0);
183 if (ret) { 183 if (ret) {
184 dev_err(runtime->dev, "Mic jack creation failed %d\n", ret); 184 dev_err(runtime->dev, "Mic jack creation failed %d\n", ret);
185 return ret; 185 return ret;
@@ -203,9 +203,7 @@ static int cht_codec_fixup(struct snd_soc_pcm_runtime *rtd,
203 channels->min = channels->max = 2; 203 channels->min = channels->max = 2;
204 204
205 /* set SSP2 to 24-bit */ 205 /* set SSP2 to 24-bit */
206 snd_mask_set(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT - 206 params_set_format(params, SNDRV_PCM_FORMAT_S24_LE);
207 SNDRV_PCM_HW_PARAM_FIRST_MASK],
208 SNDRV_PCM_FORMAT_S24_LE);
209 return 0; 207 return 0;
210} 208}
211 209
diff --git a/sound/soc/intel/cht_bsw_rt5672.c b/sound/soc/intel/cht_bsw_rt5672.c
index ff016621583a..bc8dcacd5e6a 100644
--- a/sound/soc/intel/cht_bsw_rt5672.c
+++ b/sound/soc/intel/cht_bsw_rt5672.c
@@ -178,9 +178,7 @@ static int cht_codec_fixup(struct snd_soc_pcm_runtime *rtd,
178 channels->min = channels->max = 2; 178 channels->min = channels->max = 2;
179 179
180 /* set SSP2 to 24-bit */ 180 /* set SSP2 to 24-bit */
181 snd_mask_set(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT - 181 params_set_format(params, SNDRV_PCM_FORMAT_S24_LE);
182 SNDRV_PCM_HW_PARAM_FIRST_MASK],
183 SNDRV_PCM_FORMAT_S24_LE);
184 return 0; 182 return 0;
185} 183}
186 184
@@ -217,7 +215,7 @@ static struct snd_soc_dai_link cht_dailink[] = {
217 .codec_dai_name = "snd-soc-dummy-dai", 215 .codec_dai_name = "snd-soc-dummy-dai",
218 .codec_name = "snd-soc-dummy", 216 .codec_name = "snd-soc-dummy",
219 .platform_name = "sst-mfld-platform", 217 .platform_name = "sst-mfld-platform",
220 .ignore_suspend = 1, 218 .nonatomic = true,
221 .dynamic = 1, 219 .dynamic = 1,
222 .dpcm_playback = 1, 220 .dpcm_playback = 1,
223 .dpcm_capture = 1, 221 .dpcm_capture = 1,
@@ -240,13 +238,13 @@ static struct snd_soc_dai_link cht_dailink[] = {
240 .cpu_dai_name = "ssp2-port", 238 .cpu_dai_name = "ssp2-port",
241 .platform_name = "sst-mfld-platform", 239 .platform_name = "sst-mfld-platform",
242 .no_pcm = 1, 240 .no_pcm = 1,
241 .nonatomic = true,
243 .codec_dai_name = "rt5670-aif1", 242 .codec_dai_name = "rt5670-aif1",
244 .codec_name = "i2c-10EC5670:00", 243 .codec_name = "i2c-10EC5670:00",
245 .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_IB_NF 244 .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_IB_NF
246 | SND_SOC_DAIFMT_CBS_CFS, 245 | SND_SOC_DAIFMT_CBS_CFS,
247 .init = cht_codec_init, 246 .init = cht_codec_init,
248 .be_hw_params_fixup = cht_codec_fixup, 247 .be_hw_params_fixup = cht_codec_fixup,
249 .ignore_suspend = 1,
250 .dpcm_playback = 1, 248 .dpcm_playback = 1,
251 .dpcm_capture = 1, 249 .dpcm_capture = 1,
252 .ops = &cht_be_ssp2_ops, 250 .ops = &cht_be_ssp2_ops,
@@ -285,7 +283,6 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
285static struct platform_driver snd_cht_mc_driver = { 283static struct platform_driver snd_cht_mc_driver = {
286 .driver = { 284 .driver = {
287 .name = "cht-bsw-rt5672", 285 .name = "cht-bsw-rt5672",
288 .pm = &snd_soc_pm_ops,
289 }, 286 },
290 .probe = snd_cht_mc_probe, 287 .probe = snd_cht_mc_probe,
291}; 288};
diff --git a/sound/soc/intel/haswell.c b/sound/soc/intel/haswell.c
index 35edf51a52aa..00fddd3f5dfb 100644
--- a/sound/soc/intel/haswell.c
+++ b/sound/soc/intel/haswell.c
@@ -56,9 +56,7 @@ static int haswell_ssp0_fixup(struct snd_soc_pcm_runtime *rtd,
56 channels->min = channels->max = 2; 56 channels->min = channels->max = 2;
57 57
58 /* set SSP0 to 16 bit */ 58 /* set SSP0 to 16 bit */
59 snd_mask_set(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT - 59 params_set_format(params, SNDRV_PCM_FORMAT_S16_LE);
60 SNDRV_PCM_HW_PARAM_FIRST_MASK],
61 SNDRV_PCM_FORMAT_S16_LE);
62 return 0; 60 return 0;
63} 61}
64 62
diff --git a/sound/soc/intel/mfld_machine.c b/sound/soc/intel/mfld_machine.c
index 90b7a57713a0..49c09a0add79 100644
--- a/sound/soc/intel/mfld_machine.c
+++ b/sound/soc/intel/mfld_machine.c
@@ -228,10 +228,13 @@ static void mfld_jack_check(unsigned int intr_status)
228{ 228{
229 struct mfld_jack_data jack_data; 229 struct mfld_jack_data jack_data;
230 230
231 if (!mfld_codec)
232 return;
233
231 jack_data.mfld_jack = &mfld_jack; 234 jack_data.mfld_jack = &mfld_jack;
232 jack_data.intr_id = intr_status; 235 jack_data.intr_id = intr_status;
233 236
234 sn95031_jack_detection(&jack_data); 237 sn95031_jack_detection(mfld_codec, &jack_data);
235 /* TODO: add american headset detection post gpiolib support */ 238 /* TODO: add american headset detection post gpiolib support */
236} 239}
237 240
@@ -240,8 +243,6 @@ static int mfld_init(struct snd_soc_pcm_runtime *runtime)
240 struct snd_soc_dapm_context *dapm = &runtime->card->dapm; 243 struct snd_soc_dapm_context *dapm = &runtime->card->dapm;
241 int ret_val; 244 int ret_val;
242 245
243 mfld_codec = runtime->codec;
244
245 /* default is earpiece pin, userspace sets it explcitly */ 246 /* default is earpiece pin, userspace sets it explcitly */
246 snd_soc_dapm_disable_pin(dapm, "Headphones"); 247 snd_soc_dapm_disable_pin(dapm, "Headphones");
247 /* default is lineout NC, userspace sets it explcitly */ 248 /* default is lineout NC, userspace sets it explcitly */
@@ -254,20 +255,15 @@ static int mfld_init(struct snd_soc_pcm_runtime *runtime)
254 snd_soc_dapm_disable_pin(dapm, "LINEINR"); 255 snd_soc_dapm_disable_pin(dapm, "LINEINR");
255 256
256 /* Headset and button jack detection */ 257 /* Headset and button jack detection */
257 ret_val = snd_soc_jack_new(mfld_codec, "Intel(R) MID Audio Jack", 258 ret_val = snd_soc_card_jack_new(runtime->card,
258 SND_JACK_HEADSET | SND_JACK_BTN_0 | 259 "Intel(R) MID Audio Jack", SND_JACK_HEADSET |
259 SND_JACK_BTN_1, &mfld_jack); 260 SND_JACK_BTN_0 | SND_JACK_BTN_1, &mfld_jack,
261 mfld_jack_pins, ARRAY_SIZE(mfld_jack_pins));
260 if (ret_val) { 262 if (ret_val) {
261 pr_err("jack creation failed\n"); 263 pr_err("jack creation failed\n");
262 return ret_val; 264 return ret_val;
263 } 265 }
264 266
265 ret_val = snd_soc_jack_add_pins(&mfld_jack,
266 ARRAY_SIZE(mfld_jack_pins), mfld_jack_pins);
267 if (ret_val) {
268 pr_err("adding jack pins failed\n");
269 return ret_val;
270 }
271 ret_val = snd_soc_jack_add_zones(&mfld_jack, 267 ret_val = snd_soc_jack_add_zones(&mfld_jack,
272 ARRAY_SIZE(mfld_zones), mfld_zones); 268 ARRAY_SIZE(mfld_zones), mfld_zones);
273 if (ret_val) { 269 if (ret_val) {
@@ -275,6 +271,8 @@ static int mfld_init(struct snd_soc_pcm_runtime *runtime)
275 return ret_val; 271 return ret_val;
276 } 272 }
277 273
274 mfld_codec = runtime->codec;
275
278 /* we want to check if anything is inserted at boot, 276 /* we want to check if anything is inserted at boot,
279 * so send a fake event to codec and it will read adc 277 * so send a fake event to codec and it will read adc
280 * to find if anything is there or not */ 278 * to find if anything is there or not */
@@ -359,8 +357,6 @@ static irqreturn_t snd_mfld_jack_detection(int irq, void *data)
359{ 357{
360 struct mfld_mc_private *mc_drv_ctx = (struct mfld_mc_private *) data; 358 struct mfld_mc_private *mc_drv_ctx = (struct mfld_mc_private *) data;
361 359
362 if (mfld_jack.codec == NULL)
363 return IRQ_HANDLED;
364 mfld_jack_check(mc_drv_ctx->interrupt_status); 360 mfld_jack_check(mc_drv_ctx->interrupt_status);
365 361
366 return IRQ_HANDLED; 362 return IRQ_HANDLED;
diff --git a/sound/soc/intel/sst-atom-controls.h b/sound/soc/intel/sst-atom-controls.h
index dfebfdd5eb2a..daecc58f28af 100644
--- a/sound/soc/intel/sst-atom-controls.h
+++ b/sound/soc/intel/sst-atom-controls.h
@@ -150,7 +150,7 @@ enum sst_cmd_type {
150 150
151enum sst_task { 151enum sst_task {
152 SST_TASK_SBA = 1, 152 SST_TASK_SBA = 1,
153 SST_TASK_MMX, 153 SST_TASK_MMX = 3,
154}; 154};
155 155
156enum sst_type { 156enum sst_type {
diff --git a/sound/soc/intel/sst-mfld-platform-pcm.c b/sound/soc/intel/sst-mfld-platform-pcm.c
index 7523cbef8780..2fbaf2c75d17 100644
--- a/sound/soc/intel/sst-mfld-platform-pcm.c
+++ b/sound/soc/intel/sst-mfld-platform-pcm.c
@@ -594,11 +594,13 @@ static int sst_platform_pcm_trigger(struct snd_pcm_substream *substream,
594 ret_val = stream->ops->stream_drop(sst->dev, str_id); 594 ret_val = stream->ops->stream_drop(sst->dev, str_id);
595 break; 595 break;
596 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 596 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
597 case SNDRV_PCM_TRIGGER_SUSPEND:
597 dev_dbg(rtd->dev, "sst: in pause\n"); 598 dev_dbg(rtd->dev, "sst: in pause\n");
598 status = SST_PLATFORM_PAUSED; 599 status = SST_PLATFORM_PAUSED;
599 ret_val = stream->ops->stream_pause(sst->dev, str_id); 600 ret_val = stream->ops->stream_pause(sst->dev, str_id);
600 break; 601 break;
601 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 602 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
603 case SNDRV_PCM_TRIGGER_RESUME:
602 dev_dbg(rtd->dev, "sst: in pause release\n"); 604 dev_dbg(rtd->dev, "sst: in pause release\n");
603 status = SST_PLATFORM_RUNNING; 605 status = SST_PLATFORM_RUNNING;
604 ret_val = stream->ops->stream_pause_release(sst->dev, str_id); 606 ret_val = stream->ops->stream_pause_release(sst->dev, str_id);
@@ -665,6 +667,9 @@ static int sst_pcm_new(struct snd_soc_pcm_runtime *rtd)
665 667
666static int sst_soc_probe(struct snd_soc_platform *platform) 668static int sst_soc_probe(struct snd_soc_platform *platform)
667{ 669{
670 struct sst_data *drv = dev_get_drvdata(platform->dev);
671
672 drv->soc_card = platform->component.card;
668 return sst_dsp_init_v2_dpcm(platform); 673 return sst_dsp_init_v2_dpcm(platform);
669} 674}
670 675
@@ -727,9 +732,64 @@ static int sst_platform_remove(struct platform_device *pdev)
727 return 0; 732 return 0;
728} 733}
729 734
735#ifdef CONFIG_PM_SLEEP
736
737static int sst_soc_prepare(struct device *dev)
738{
739 struct sst_data *drv = dev_get_drvdata(dev);
740 int i;
741
742 /* suspend all pcms first */
743 snd_soc_suspend(drv->soc_card->dev);
744 snd_soc_poweroff(drv->soc_card->dev);
745
746 /* set the SSPs to idle */
747 for (i = 0; i < drv->soc_card->num_rtd; i++) {
748 struct snd_soc_dai *dai = drv->soc_card->rtd[i].cpu_dai;
749
750 if (dai->active) {
751 send_ssp_cmd(dai, dai->name, 0);
752 sst_handle_vb_timer(dai, false);
753 }
754 }
755
756 return 0;
757}
758
759static void sst_soc_complete(struct device *dev)
760{
761 struct sst_data *drv = dev_get_drvdata(dev);
762 int i;
763
764 /* restart SSPs */
765 for (i = 0; i < drv->soc_card->num_rtd; i++) {
766 struct snd_soc_dai *dai = drv->soc_card->rtd[i].cpu_dai;
767
768 if (dai->active) {
769 sst_handle_vb_timer(dai, true);
770 send_ssp_cmd(dai, dai->name, 1);
771 }
772 }
773 snd_soc_resume(drv->soc_card->dev);
774}
775
776#else
777
778#define sst_soc_prepare NULL
779#define sst_soc_complete NULL
780
781#endif
782
783
784static const struct dev_pm_ops sst_platform_pm = {
785 .prepare = sst_soc_prepare,
786 .complete = sst_soc_complete,
787};
788
730static struct platform_driver sst_platform_driver = { 789static struct platform_driver sst_platform_driver = {
731 .driver = { 790 .driver = {
732 .name = "sst-mfld-platform", 791 .name = "sst-mfld-platform",
792 .pm = &sst_platform_pm,
733 }, 793 },
734 .probe = sst_platform_probe, 794 .probe = sst_platform_probe,
735 .remove = sst_platform_remove, 795 .remove = sst_platform_remove,
diff --git a/sound/soc/intel/sst-mfld-platform.h b/sound/soc/intel/sst-mfld-platform.h
index 79c8d1246a8f..9094314be2b0 100644
--- a/sound/soc/intel/sst-mfld-platform.h
+++ b/sound/soc/intel/sst-mfld-platform.h
@@ -174,6 +174,7 @@ struct sst_data {
174 struct sst_platform_data *pdata; 174 struct sst_platform_data *pdata;
175 struct snd_sst_bytes_v2 *byte_stream; 175 struct snd_sst_bytes_v2 *byte_stream;
176 struct mutex lock; 176 struct mutex lock;
177 struct snd_soc_card *soc_card;
177}; 178};
178int sst_register_dsp(struct sst_device *sst); 179int sst_register_dsp(struct sst_device *sst);
179int sst_unregister_dsp(struct sst_device *sst); 180int sst_unregister_dsp(struct sst_device *sst);
diff --git a/sound/soc/intel/sst/sst.c b/sound/soc/intel/sst/sst.c
index 8a8d56a146e7..1a7eeec444b1 100644
--- a/sound/soc/intel/sst/sst.c
+++ b/sound/soc/intel/sst/sst.c
@@ -350,7 +350,9 @@ static inline void sst_save_shim64(struct intel_sst_drv *ctx,
350 350
351 spin_lock_irqsave(&ctx->ipc_spin_lock, irq_flags); 351 spin_lock_irqsave(&ctx->ipc_spin_lock, irq_flags);
352 352
353 shim_regs->imrx = sst_shim_read64(shim, SST_IMRX), 353 shim_regs->imrx = sst_shim_read64(shim, SST_IMRX);
354 shim_regs->csr = sst_shim_read64(shim, SST_CSR);
355
354 356
355 spin_unlock_irqrestore(&ctx->ipc_spin_lock, irq_flags); 357 spin_unlock_irqrestore(&ctx->ipc_spin_lock, irq_flags);
356} 358}
@@ -367,6 +369,7 @@ static inline void sst_restore_shim64(struct intel_sst_drv *ctx,
367 */ 369 */
368 spin_lock_irqsave(&ctx->ipc_spin_lock, irq_flags); 370 spin_lock_irqsave(&ctx->ipc_spin_lock, irq_flags);
369 sst_shim_write64(shim, SST_IMRX, shim_regs->imrx), 371 sst_shim_write64(shim, SST_IMRX, shim_regs->imrx),
372 sst_shim_write64(shim, SST_CSR, shim_regs->csr),
370 spin_unlock_irqrestore(&ctx->ipc_spin_lock, irq_flags); 373 spin_unlock_irqrestore(&ctx->ipc_spin_lock, irq_flags);
371} 374}
372 375
@@ -379,6 +382,10 @@ void sst_configure_runtime_pm(struct intel_sst_drv *ctx)
379 * initially active. So change the state to active before 382 * initially active. So change the state to active before
380 * enabling the pm 383 * enabling the pm
381 */ 384 */
385
386 if (!acpi_disabled)
387 pm_runtime_set_active(ctx->dev);
388
382 pm_runtime_enable(ctx->dev); 389 pm_runtime_enable(ctx->dev);
383 390
384 if (acpi_disabled) 391 if (acpi_disabled)
@@ -409,29 +416,142 @@ static int intel_sst_runtime_suspend(struct device *dev)
409 synchronize_irq(ctx->irq_num); 416 synchronize_irq(ctx->irq_num);
410 flush_workqueue(ctx->post_msg_wq); 417 flush_workqueue(ctx->post_msg_wq);
411 418
419 ctx->ops->reset(ctx);
412 /* save the shim registers because PMC doesn't save state */ 420 /* save the shim registers because PMC doesn't save state */
413 sst_save_shim64(ctx, ctx->shim, ctx->shim_regs64); 421 sst_save_shim64(ctx, ctx->shim, ctx->shim_regs64);
414 422
415 return ret; 423 return ret;
416} 424}
417 425
418static int intel_sst_runtime_resume(struct device *dev) 426static int intel_sst_suspend(struct device *dev)
419{ 427{
420 int ret = 0;
421 struct intel_sst_drv *ctx = dev_get_drvdata(dev); 428 struct intel_sst_drv *ctx = dev_get_drvdata(dev);
429 struct sst_fw_save *fw_save;
430 int i, ret = 0;
422 431
423 if (ctx->sst_state == SST_RESET) { 432 /* check first if we are already in SW reset */
424 ret = sst_load_fw(ctx); 433 if (ctx->sst_state == SST_RESET)
425 if (ret) { 434 return 0;
426 dev_err(dev, "FW download fail %d\n", ret); 435
427 sst_set_fw_state_locked(ctx, SST_RESET); 436 /*
437 * check if any stream is active and running
438 * they should already by suspend by soc_suspend
439 */
440 for (i = 1; i <= ctx->info.max_streams; i++) {
441 struct stream_info *stream = &ctx->streams[i];
442
443 if (stream->status == STREAM_RUNNING) {
444 dev_err(dev, "stream %d is running, cant susupend, abort\n", i);
445 return -EBUSY;
428 } 446 }
429 } 447 }
448 synchronize_irq(ctx->irq_num);
449 flush_workqueue(ctx->post_msg_wq);
450
451 /* Move the SST state to Reset */
452 sst_set_fw_state_locked(ctx, SST_RESET);
453
454 /* tell DSP we are suspending */
455 if (ctx->ops->save_dsp_context(ctx))
456 return -EBUSY;
457
458 /* save the memories */
459 fw_save = kzalloc(sizeof(*fw_save), GFP_KERNEL);
460 if (!fw_save)
461 return -ENOMEM;
462 fw_save->iram = kzalloc(ctx->iram_end - ctx->iram_base, GFP_KERNEL);
463 if (!fw_save->iram) {
464 ret = -ENOMEM;
465 goto iram;
466 }
467 fw_save->dram = kzalloc(ctx->dram_end - ctx->dram_base, GFP_KERNEL);
468 if (!fw_save->dram) {
469 ret = -ENOMEM;
470 goto dram;
471 }
472 fw_save->sram = kzalloc(SST_MAILBOX_SIZE, GFP_KERNEL);
473 if (!fw_save->sram) {
474 ret = -ENOMEM;
475 goto sram;
476 }
477
478 fw_save->ddr = kzalloc(ctx->ddr_end - ctx->ddr_base, GFP_KERNEL);
479 if (!fw_save->ddr) {
480 ret = -ENOMEM;
481 goto ddr;
482 }
483
484 memcpy32_fromio(fw_save->iram, ctx->iram, ctx->iram_end - ctx->iram_base);
485 memcpy32_fromio(fw_save->dram, ctx->dram, ctx->dram_end - ctx->dram_base);
486 memcpy32_fromio(fw_save->sram, ctx->mailbox, SST_MAILBOX_SIZE);
487 memcpy32_fromio(fw_save->ddr, ctx->ddr, ctx->ddr_end - ctx->ddr_base);
488
489 ctx->fw_save = fw_save;
490 ctx->ops->reset(ctx);
491 return 0;
492ddr:
493 kfree(fw_save->sram);
494sram:
495 kfree(fw_save->dram);
496dram:
497 kfree(fw_save->iram);
498iram:
499 kfree(fw_save);
500 return ret;
501}
502
503static int intel_sst_resume(struct device *dev)
504{
505 struct intel_sst_drv *ctx = dev_get_drvdata(dev);
506 struct sst_fw_save *fw_save = ctx->fw_save;
507 int ret = 0;
508 struct sst_block *block;
509
510 if (!fw_save)
511 return 0;
512
513 sst_set_fw_state_locked(ctx, SST_FW_LOADING);
514
515 /* we have to restore the memory saved */
516 ctx->ops->reset(ctx);
517
518 ctx->fw_save = NULL;
519
520 memcpy32_toio(ctx->iram, fw_save->iram, ctx->iram_end - ctx->iram_base);
521 memcpy32_toio(ctx->dram, fw_save->dram, ctx->dram_end - ctx->dram_base);
522 memcpy32_toio(ctx->mailbox, fw_save->sram, SST_MAILBOX_SIZE);
523 memcpy32_toio(ctx->ddr, fw_save->ddr, ctx->ddr_end - ctx->ddr_base);
524
525 kfree(fw_save->sram);
526 kfree(fw_save->dram);
527 kfree(fw_save->iram);
528 kfree(fw_save->ddr);
529 kfree(fw_save);
530
531 block = sst_create_block(ctx, 0, FW_DWNL_ID);
532 if (block == NULL)
533 return -ENOMEM;
534
535
536 /* start and wait for ack */
537 ctx->ops->start(ctx);
538 ret = sst_wait_timeout(ctx, block);
539 if (ret) {
540 dev_err(ctx->dev, "fw download failed %d\n", ret);
541 /* FW download failed due to timeout */
542 ret = -EBUSY;
543
544 } else {
545 sst_set_fw_state_locked(ctx, SST_FW_RUNNING);
546 }
547
548 sst_free_block(ctx, block);
430 return ret; 549 return ret;
431} 550}
432 551
433const struct dev_pm_ops intel_sst_pm = { 552const struct dev_pm_ops intel_sst_pm = {
553 .suspend = intel_sst_suspend,
554 .resume = intel_sst_resume,
434 .runtime_suspend = intel_sst_runtime_suspend, 555 .runtime_suspend = intel_sst_runtime_suspend,
435 .runtime_resume = intel_sst_runtime_resume,
436}; 556};
437EXPORT_SYMBOL_GPL(intel_sst_pm); 557EXPORT_SYMBOL_GPL(intel_sst_pm);
diff --git a/sound/soc/intel/sst/sst.h b/sound/soc/intel/sst/sst.h
index 562bc483d6b7..3f493862e98d 100644
--- a/sound/soc/intel/sst/sst.h
+++ b/sound/soc/intel/sst/sst.h
@@ -337,6 +337,13 @@ struct sst_shim_regs64 {
337 u64 csr2; 337 u64 csr2;
338}; 338};
339 339
340struct sst_fw_save {
341 void *iram;
342 void *dram;
343 void *sram;
344 void *ddr;
345};
346
340/** 347/**
341 * struct intel_sst_drv - driver ops 348 * struct intel_sst_drv - driver ops
342 * 349 *
@@ -428,6 +435,8 @@ struct intel_sst_drv {
428 * persistent till worker thread gets called 435 * persistent till worker thread gets called
429 */ 436 */
430 char firmware_name[FW_NAME_SIZE]; 437 char firmware_name[FW_NAME_SIZE];
438
439 struct sst_fw_save *fw_save;
431}; 440};
432 441
433/* misc definitions */ 442/* misc definitions */
@@ -544,4 +553,7 @@ int sst_alloc_drv_context(struct intel_sst_drv **ctx,
544int sst_context_init(struct intel_sst_drv *ctx); 553int sst_context_init(struct intel_sst_drv *ctx);
545void sst_context_cleanup(struct intel_sst_drv *ctx); 554void sst_context_cleanup(struct intel_sst_drv *ctx);
546void sst_configure_runtime_pm(struct intel_sst_drv *ctx); 555void sst_configure_runtime_pm(struct intel_sst_drv *ctx);
556void memcpy32_toio(void __iomem *dst, const void *src, int count);
557void memcpy32_fromio(void *dst, const void __iomem *src, int count);
558
547#endif 559#endif
diff --git a/sound/soc/intel/sst/sst_drv_interface.c b/sound/soc/intel/sst/sst_drv_interface.c
index 5f75ef3cdd22..f0e4b99b3aeb 100644
--- a/sound/soc/intel/sst/sst_drv_interface.c
+++ b/sound/soc/intel/sst/sst_drv_interface.c
@@ -138,12 +138,36 @@ int sst_get_stream(struct intel_sst_drv *ctx,
138static int sst_power_control(struct device *dev, bool state) 138static int sst_power_control(struct device *dev, bool state)
139{ 139{
140 struct intel_sst_drv *ctx = dev_get_drvdata(dev); 140 struct intel_sst_drv *ctx = dev_get_drvdata(dev);
141 141 int ret = 0;
142 dev_dbg(ctx->dev, "state:%d", state); 142 int usage_count = 0;
143 if (state == true) 143
144 return pm_runtime_get_sync(dev); 144#ifdef CONFIG_PM
145 else 145 usage_count = atomic_read(&dev->power.usage_count);
146#else
147 usage_count = 1;
148#endif
149
150 if (state == true) {
151 ret = pm_runtime_get_sync(dev);
152
153 dev_dbg(ctx->dev, "Enable: pm usage count: %d\n", usage_count);
154 if (ret < 0) {
155 dev_err(ctx->dev, "Runtime get failed with err: %d\n", ret);
156 return ret;
157 }
158 if ((ctx->sst_state == SST_RESET) && (usage_count == 1)) {
159 ret = sst_load_fw(ctx);
160 if (ret) {
161 dev_err(dev, "FW download fail %d\n", ret);
162 sst_set_fw_state_locked(ctx, SST_RESET);
163 ret = sst_pm_runtime_put(ctx);
164 }
165 }
166 } else {
167 dev_dbg(ctx->dev, "Disable: pm usage count: %d\n", usage_count);
146 return sst_pm_runtime_put(ctx); 168 return sst_pm_runtime_put(ctx);
169 }
170 return ret;
147} 171}
148 172
149/* 173/*
@@ -572,6 +596,35 @@ static int sst_stream_drop(struct device *dev, int str_id)
572 return sst_drop_stream(ctx, str_id); 596 return sst_drop_stream(ctx, str_id);
573} 597}
574 598
599static int sst_stream_pause(struct device *dev, int str_id)
600{
601 struct stream_info *str_info;
602 struct intel_sst_drv *ctx = dev_get_drvdata(dev);
603
604 if (ctx->sst_state != SST_FW_RUNNING)
605 return 0;
606
607 str_info = get_stream_info(ctx, str_id);
608 if (!str_info)
609 return -EINVAL;
610
611 return sst_pause_stream(ctx, str_id);
612}
613
614static int sst_stream_resume(struct device *dev, int str_id)
615{
616 struct stream_info *str_info;
617 struct intel_sst_drv *ctx = dev_get_drvdata(dev);
618
619 if (ctx->sst_state != SST_FW_RUNNING)
620 return 0;
621
622 str_info = get_stream_info(ctx, str_id);
623 if (!str_info)
624 return -EINVAL;
625 return sst_resume_stream(ctx, str_id);
626}
627
575static int sst_stream_init(struct device *dev, struct pcm_stream_info *str_info) 628static int sst_stream_init(struct device *dev, struct pcm_stream_info *str_info)
576{ 629{
577 int str_id = 0; 630 int str_id = 0;
@@ -633,6 +686,8 @@ static struct sst_ops pcm_ops = {
633 .stream_init = sst_stream_init, 686 .stream_init = sst_stream_init,
634 .stream_start = sst_stream_start, 687 .stream_start = sst_stream_start,
635 .stream_drop = sst_stream_drop, 688 .stream_drop = sst_stream_drop,
689 .stream_pause = sst_stream_pause,
690 .stream_pause_release = sst_stream_resume,
636 .stream_read_tstamp = sst_read_timestamp, 691 .stream_read_tstamp = sst_read_timestamp,
637 .send_byte_stream = sst_send_byte_stream, 692 .send_byte_stream = sst_send_byte_stream,
638 .close = sst_close_pcm_stream, 693 .close = sst_close_pcm_stream,
diff --git a/sound/soc/intel/sst/sst_loader.c b/sound/soc/intel/sst/sst_loader.c
index 7888cd707853..e88907ae8b15 100644
--- a/sound/soc/intel/sst/sst_loader.c
+++ b/sound/soc/intel/sst/sst_loader.c
@@ -39,7 +39,15 @@
39#include "sst.h" 39#include "sst.h"
40#include "../sst-dsp.h" 40#include "../sst-dsp.h"
41 41
42static inline void memcpy32_toio(void __iomem *dst, const void *src, int count) 42void memcpy32_toio(void __iomem *dst, const void *src, int count)
43{
44 /* __iowrite32_copy uses 32-bit count values so divide by 4 for
45 * right count in words
46 */
47 __iowrite32_copy(dst, src, count/4);
48}
49
50void memcpy32_fromio(void *dst, const void __iomem *src, int count)
43{ 51{
44 /* __iowrite32_copy uses 32-bit count values so divide by 4 for 52 /* __iowrite32_copy uses 32-bit count values so divide by 4 for
45 * right count in words 53 * right count in words
diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig
index a2cd3486ac55..e7c78b0406b5 100644
--- a/sound/soc/omap/Kconfig
+++ b/sound/soc/omap/Kconfig
@@ -100,17 +100,19 @@ config SND_OMAP_SOC_OMAP_TWL4030
100 100
101config SND_OMAP_SOC_OMAP_ABE_TWL6040 101config SND_OMAP_SOC_OMAP_ABE_TWL6040
102 tristate "SoC Audio support for OMAP boards using ABE and twl6040 codec" 102 tristate "SoC Audio support for OMAP boards using ABE and twl6040 codec"
103 depends on TWL6040_CORE && SND_OMAP_SOC && (ARCH_OMAP4 || COMPILE_TEST) 103 depends on TWL6040_CORE && SND_OMAP_SOC && (ARCH_OMAP4 || SOC_OMAP5 || COMPILE_TEST)
104 select SND_OMAP_SOC_DMIC 104 select SND_OMAP_SOC_DMIC
105 select SND_OMAP_SOC_MCPDM 105 select SND_OMAP_SOC_MCPDM
106 select SND_SOC_TWL6040 106 select SND_SOC_TWL6040
107 select SND_SOC_DMIC 107 select SND_SOC_DMIC
108 select COMMON_CLK_PALMAS if SOC_OMAP5
108 help 109 help
109 Say Y if you want to add support for SoC audio on OMAP boards using 110 Say Y if you want to add support for SoC audio on OMAP boards using
110 ABE and twl6040 codec. This driver currently supports: 111 ABE and twl6040 codec. This driver currently supports:
111 - SDP4430/Blaze boards 112 - SDP4430/Blaze boards
112 - PandaBoard (4430) 113 - PandaBoard (4430)
113 - PandaBoardES (4460) 114 - PandaBoardES (4460)
115 - omap5-uevm (5432)
114 116
115config SND_OMAP_SOC_OMAP3_PANDORA 117config SND_OMAP_SOC_OMAP3_PANDORA
116 tristate "SoC Audio support for OMAP3 Pandora" 118 tristate "SoC Audio support for OMAP3 Pandora"
diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c
index 706613077c15..16cc95fa4573 100644
--- a/sound/soc/omap/ams-delta.c
+++ b/sound/soc/omap/ams-delta.c
@@ -479,8 +479,8 @@ static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd)
479 479
480 /* Add hook switch - can be used to control the codec from userspace 480 /* Add hook switch - can be used to control the codec from userspace
481 * even if line discipline fails */ 481 * even if line discipline fails */
482 ret = snd_soc_jack_new(rtd->codec, "hook_switch", 482 ret = snd_soc_card_jack_new(card, "hook_switch", SND_JACK_HEADSET,
483 SND_JACK_HEADSET, &ams_delta_hook_switch); 483 &ams_delta_hook_switch, NULL, 0);
484 if (ret) 484 if (ret)
485 dev_warn(card->dev, 485 dev_warn(card->dev,
486 "Failed to allocate resources for hook switch, " 486 "Failed to allocate resources for hook switch, "
diff --git a/sound/soc/omap/omap-abe-twl6040.c b/sound/soc/omap/omap-abe-twl6040.c
index b9c65f1ad5a8..0843a68f277c 100644
--- a/sound/soc/omap/omap-abe-twl6040.c
+++ b/sound/soc/omap/omap-abe-twl6040.c
@@ -182,17 +182,17 @@ static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd)
182 182
183 /* Headset jack detection only if it is supported */ 183 /* Headset jack detection only if it is supported */
184 if (priv->jack_detection) { 184 if (priv->jack_detection) {
185 ret = snd_soc_jack_new(codec, "Headset Jack", 185 ret = snd_soc_card_jack_new(rtd->card, "Headset Jack",
186 SND_JACK_HEADSET, &hs_jack); 186 SND_JACK_HEADSET, &hs_jack,
187 hs_jack_pins,
188 ARRAY_SIZE(hs_jack_pins));
187 if (ret) 189 if (ret)
188 return ret; 190 return ret;
189 191
190 ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins),
191 hs_jack_pins);
192 twl6040_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADSET); 192 twl6040_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADSET);
193 } 193 }
194 194
195 return ret; 195 return 0;
196} 196}
197 197
198static const struct snd_soc_dapm_route dmic_audio_map[] = { 198static const struct snd_soc_dapm_route dmic_audio_map[] = {
diff --git a/sound/soc/omap/omap-hdmi-audio.c b/sound/soc/omap/omap-hdmi-audio.c
index ccfb41c22e53..f7eb42aa3f38 100644
--- a/sound/soc/omap/omap-hdmi-audio.c
+++ b/sound/soc/omap/omap-hdmi-audio.c
@@ -352,6 +352,9 @@ static int omap_hdmi_audio_probe(struct platform_device *pdev)
352 return ret; 352 return ret;
353 353
354 card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL); 354 card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
355 if (!card)
356 return -ENOMEM;
357
355 card->name = devm_kasprintf(dev, GFP_KERNEL, 358 card->name = devm_kasprintf(dev, GFP_KERNEL,
356 "HDMI %s", dev_name(ad->dssdev)); 359 "HDMI %s", dev_name(ad->dssdev));
357 card->owner = THIS_MODULE; 360 card->owner = THIS_MODULE;
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
index c7eb9dd67f60..fd99d89de6a8 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -530,8 +530,19 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
530 530
531 case OMAP_MCBSP_SYSCLK_CLKX_EXT: 531 case OMAP_MCBSP_SYSCLK_CLKX_EXT:
532 regs->srgr2 |= CLKSM; 532 regs->srgr2 |= CLKSM;
533 regs->pcr0 |= SCLKME;
534 /*
535 * If McBSP is master but yet the CLKX/CLKR pin drives the SRG,
536 * disable output on those pins. This enables to inject the
537 * reference clock through CLKX/CLKR. For this to work
538 * set_dai_sysclk() _needs_ to be called after set_dai_fmt().
539 */
540 regs->pcr0 &= ~CLKXM;
541 break;
533 case OMAP_MCBSP_SYSCLK_CLKR_EXT: 542 case OMAP_MCBSP_SYSCLK_CLKR_EXT:
534 regs->pcr0 |= SCLKME; 543 regs->pcr0 |= SCLKME;
544 /* Disable ouput on CLKR pin in master mode */
545 regs->pcr0 &= ~CLKRM;
535 break; 546 break;
536 default: 547 default:
537 err = -ENODEV; 548 err = -ENODEV;
diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c
index f4b05bc23e4b..6bb623a2a4df 100644
--- a/sound/soc/omap/omap-pcm.c
+++ b/sound/soc/omap/omap-pcm.c
@@ -39,7 +39,7 @@
39#define pcm_omap1510() 0 39#define pcm_omap1510() 0
40#endif 40#endif
41 41
42static const struct snd_pcm_hardware omap_pcm_hardware = { 42static struct snd_pcm_hardware omap_pcm_hardware = {
43 .info = SNDRV_PCM_INFO_MMAP | 43 .info = SNDRV_PCM_INFO_MMAP |
44 SNDRV_PCM_INFO_MMAP_VALID | 44 SNDRV_PCM_INFO_MMAP_VALID |
45 SNDRV_PCM_INFO_INTERLEAVED | 45 SNDRV_PCM_INFO_INTERLEAVED |
@@ -53,6 +53,24 @@ static const struct snd_pcm_hardware omap_pcm_hardware = {
53 .buffer_bytes_max = 128 * 1024, 53 .buffer_bytes_max = 128 * 1024,
54}; 54};
55 55
56/* sDMA supports only 1, 2, and 4 byte transfer elements. */
57static void omap_pcm_limit_supported_formats(void)
58{
59 int i;
60
61 for (i = 0; i < SNDRV_PCM_FORMAT_LAST; i++) {
62 switch (snd_pcm_format_physical_width(i)) {
63 case 8:
64 case 16:
65 case 32:
66 omap_pcm_hardware.formats |= (1LL << i);
67 break;
68 default:
69 break;
70 }
71 }
72}
73
56/* this may get called several times by oss emulation */ 74/* this may get called several times by oss emulation */
57static int omap_pcm_hw_params(struct snd_pcm_substream *substream, 75static int omap_pcm_hw_params(struct snd_pcm_substream *substream,
58 struct snd_pcm_hw_params *params) 76 struct snd_pcm_hw_params *params)
@@ -201,7 +219,7 @@ static int omap_pcm_new(struct snd_soc_pcm_runtime *rtd)
201 struct snd_pcm *pcm = rtd->pcm; 219 struct snd_pcm *pcm = rtd->pcm;
202 int ret; 220 int ret;
203 221
204 ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(64)); 222 ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
205 if (ret) 223 if (ret)
206 return ret; 224 return ret;
207 225
@@ -235,6 +253,7 @@ static struct snd_soc_platform_driver omap_soc_platform = {
235 253
236int omap_pcm_platform_register(struct device *dev) 254int omap_pcm_platform_register(struct device *dev)
237{ 255{
256 omap_pcm_limit_supported_formats();
238 return devm_snd_soc_register_platform(dev, &omap_soc_platform); 257 return devm_snd_soc_register_platform(dev, &omap_soc_platform);
239} 258}
240EXPORT_SYMBOL_GPL(omap_pcm_platform_register); 259EXPORT_SYMBOL_GPL(omap_pcm_platform_register);
diff --git a/sound/soc/omap/omap-twl4030.c b/sound/soc/omap/omap-twl4030.c
index fb1f6bb87cd4..3673ada43bfb 100644
--- a/sound/soc/omap/omap-twl4030.c
+++ b/sound/soc/omap/omap-twl4030.c
@@ -170,14 +170,10 @@ static int omap_twl4030_init(struct snd_soc_pcm_runtime *rtd)
170 if (priv->jack_detect > 0) { 170 if (priv->jack_detect > 0) {
171 hs_jack_gpios[0].gpio = priv->jack_detect; 171 hs_jack_gpios[0].gpio = priv->jack_detect;
172 172
173 ret = snd_soc_jack_new(codec, "Headset Jack", SND_JACK_HEADSET, 173 ret = snd_soc_card_jack_new(rtd->card, "Headset Jack",
174 &priv->hs_jack); 174 SND_JACK_HEADSET, &priv->hs_jack,
175 if (ret) 175 hs_jack_pins,
176 return ret; 176 ARRAY_SIZE(hs_jack_pins));
177
178 ret = snd_soc_jack_add_pins(&priv->hs_jack,
179 ARRAY_SIZE(hs_jack_pins),
180 hs_jack_pins);
181 if (ret) 177 if (ret)
182 return ret; 178 return ret;
183 179
diff --git a/sound/soc/omap/rx51.c b/sound/soc/omap/rx51.c
index 7f299357c2d2..c2ddf0fbfa28 100644
--- a/sound/soc/omap/rx51.c
+++ b/sound/soc/omap/rx51.c
@@ -311,9 +311,9 @@ static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd)
311 } 311 }
312 312
313 /* AV jack detection */ 313 /* AV jack detection */
314 err = snd_soc_jack_new(codec, "AV Jack", 314 err = snd_soc_card_jack_new(rtd->card, "AV Jack",
315 SND_JACK_HEADSET | SND_JACK_VIDEOOUT, 315 SND_JACK_HEADSET | SND_JACK_VIDEOOUT,
316 &rx51_av_jack); 316 &rx51_av_jack, NULL, 0);
317 if (err) { 317 if (err) {
318 dev_err(card->dev, "Failed to add AV Jack\n"); 318 dev_err(card->dev, "Failed to add AV Jack\n");
319 return err; 319 return err;
diff --git a/sound/soc/pxa/hx4700.c b/sound/soc/pxa/hx4700.c
index 73eb5ddf9753..9f8be7cd567e 100644
--- a/sound/soc/pxa/hx4700.c
+++ b/sound/soc/pxa/hx4700.c
@@ -126,17 +126,12 @@ static const struct snd_soc_dapm_route hx4700_audio_map[] = {
126 */ 126 */
127static int hx4700_ak4641_init(struct snd_soc_pcm_runtime *rtd) 127static int hx4700_ak4641_init(struct snd_soc_pcm_runtime *rtd)
128{ 128{
129 struct snd_soc_codec *codec = rtd->codec;
130 int err; 129 int err;
131 130
132 /* Jack detection API stuff */ 131 /* Jack detection API stuff */
133 err = snd_soc_jack_new(codec, "Headphone Jack", 132 err = snd_soc_card_jack_new(rtd->card, "Headphone Jack",
134 SND_JACK_HEADPHONE, &hs_jack); 133 SND_JACK_HEADPHONE, &hs_jack, hs_jack_pin,
135 if (err) 134 ARRAY_SIZE(hs_jack_pin));
136 return err;
137
138 err = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pin),
139 hs_jack_pin);
140 if (err) 135 if (err)
141 return err; 136 return err;
142 137
diff --git a/sound/soc/pxa/palm27x.c b/sound/soc/pxa/palm27x.c
index 910336c5ebeb..c20bbc042425 100644
--- a/sound/soc/pxa/palm27x.c
+++ b/sound/soc/pxa/palm27x.c
@@ -75,17 +75,12 @@ static struct snd_soc_card palm27x_asoc;
75 75
76static int palm27x_ac97_init(struct snd_soc_pcm_runtime *rtd) 76static int palm27x_ac97_init(struct snd_soc_pcm_runtime *rtd)
77{ 77{
78 struct snd_soc_codec *codec = rtd->codec;
79 int err; 78 int err;
80 79
81 /* Jack detection API stuff */ 80 /* Jack detection API stuff */
82 err = snd_soc_jack_new(codec, "Headphone Jack", 81 err = snd_soc_card_jack_new(rtd->card, "Headphone Jack",
83 SND_JACK_HEADPHONE, &hs_jack); 82 SND_JACK_HEADPHONE, &hs_jack, hs_jack_pins,
84 if (err) 83 ARRAY_SIZE(hs_jack_pins));
85 return err;
86
87 err = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins),
88 hs_jack_pins);
89 if (err) 84 if (err)
90 return err; 85 return err;
91 86
diff --git a/sound/soc/pxa/ttc-dkb.c b/sound/soc/pxa/ttc-dkb.c
index 5001dbb9b257..1753c7d9e760 100644
--- a/sound/soc/pxa/ttc-dkb.c
+++ b/sound/soc/pxa/ttc-dkb.c
@@ -78,15 +78,12 @@ static int ttc_pm860x_init(struct snd_soc_pcm_runtime *rtd)
78 struct snd_soc_codec *codec = rtd->codec; 78 struct snd_soc_codec *codec = rtd->codec;
79 79
80 /* Headset jack detection */ 80 /* Headset jack detection */
81 snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE 81 snd_soc_card_jack_new(rtd->card, "Headphone Jack", SND_JACK_HEADPHONE |
82 | SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2, 82 SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2,
83 &hs_jack); 83 &hs_jack, hs_jack_pins, ARRAY_SIZE(hs_jack_pins));
84 snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins), 84 snd_soc_card_jack_new(rtd->card, "Microphone Jack", SND_JACK_MICROPHONE,
85 hs_jack_pins); 85 &mic_jack, mic_jack_pins,
86 snd_soc_jack_new(codec, "Microphone Jack", SND_JACK_MICROPHONE, 86 ARRAY_SIZE(mic_jack_pins));
87 &mic_jack);
88 snd_soc_jack_add_pins(&mic_jack, ARRAY_SIZE(mic_jack_pins),
89 mic_jack_pins);
90 87
91 /* headphone, microphone detection & headset short detection */ 88 /* headphone, microphone detection & headset short detection */
92 pm860x_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADPHONE, 89 pm860x_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADPHONE,
diff --git a/sound/soc/pxa/z2.c b/sound/soc/pxa/z2.c
index 76ccb172d0a7..bcbfbe8303f7 100644
--- a/sound/soc/pxa/z2.c
+++ b/sound/soc/pxa/z2.c
@@ -143,13 +143,9 @@ static int z2_wm8750_init(struct snd_soc_pcm_runtime *rtd)
143 snd_soc_dapm_disable_pin(dapm, "MONO1"); 143 snd_soc_dapm_disable_pin(dapm, "MONO1");
144 144
145 /* Jack detection API stuff */ 145 /* Jack detection API stuff */
146 ret = snd_soc_jack_new(codec, "Headset Jack", SND_JACK_HEADSET, 146 ret = snd_soc_card_jack_new(rtd->card, "Headset Jack", SND_JACK_HEADSET,
147 &hs_jack); 147 &hs_jack, hs_jack_pins,
148 if (ret) 148 ARRAY_SIZE(hs_jack_pins));
149 goto err;
150
151 ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins),
152 hs_jack_pins);
153 if (ret) 149 if (ret)
154 goto err; 150 goto err;
155 151
diff --git a/sound/soc/samsung/Kconfig b/sound/soc/samsung/Kconfig
index 3cebf6ca03df..0632a36852c8 100644
--- a/sound/soc/samsung/Kconfig
+++ b/sound/soc/samsung/Kconfig
@@ -174,7 +174,7 @@ config SND_SOC_SMDK_WM8994_PCM
174 174
175config SND_SOC_SPEYSIDE 175config SND_SOC_SPEYSIDE
176 tristate "Audio support for Wolfson Speyside" 176 tristate "Audio support for Wolfson Speyside"
177 depends on SND_SOC_SAMSUNG && MACH_WLF_CRAGG_6410 177 depends on SND_SOC_SAMSUNG && MACH_WLF_CRAGG_6410 && I2C && SPI_MASTER
178 select SND_SAMSUNG_I2S 178 select SND_SAMSUNG_I2S
179 select SND_SOC_WM8996 179 select SND_SOC_WM8996
180 select SND_SOC_WM9081 180 select SND_SOC_WM9081
@@ -189,7 +189,7 @@ config SND_SOC_TOBERMORY
189 189
190config SND_SOC_BELLS 190config SND_SOC_BELLS
191 tristate "Audio support for Wolfson Bells" 191 tristate "Audio support for Wolfson Bells"
192 depends on SND_SOC_SAMSUNG && MACH_WLF_CRAGG_6410 && MFD_ARIZONA 192 depends on SND_SOC_SAMSUNG && MACH_WLF_CRAGG_6410 && MFD_ARIZONA && I2C && SPI_MASTER
193 select SND_SAMSUNG_I2S 193 select SND_SAMSUNG_I2S
194 select SND_SOC_WM5102 194 select SND_SOC_WM5102
195 select SND_SOC_WM5110 195 select SND_SOC_WM5110
@@ -206,7 +206,7 @@ config SND_SOC_LOWLAND
206 206
207config SND_SOC_LITTLEMILL 207config SND_SOC_LITTLEMILL
208 tristate "Audio support for Wolfson Littlemill" 208 tristate "Audio support for Wolfson Littlemill"
209 depends on SND_SOC_SAMSUNG && MACH_WLF_CRAGG_6410 209 depends on SND_SOC_SAMSUNG && MACH_WLF_CRAGG_6410 && I2C
210 select SND_SAMSUNG_I2S 210 select SND_SAMSUNG_I2S
211 select MFD_WM8994 211 select MFD_WM8994
212 select SND_SOC_WM8994 212 select SND_SOC_WM8994
@@ -223,7 +223,7 @@ config SND_SOC_SNOW
223 223
224config SND_SOC_ODROIDX2 224config SND_SOC_ODROIDX2
225 tristate "Audio support for Odroid-X2 and Odroid-U3" 225 tristate "Audio support for Odroid-X2 and Odroid-U3"
226 depends on SND_SOC_SAMSUNG 226 depends on SND_SOC_SAMSUNG && I2C
227 select SND_SOC_MAX98090 227 select SND_SOC_MAX98090
228 select SND_SAMSUNG_I2S 228 select SND_SAMSUNG_I2S
229 help 229 help
@@ -231,6 +231,6 @@ config SND_SOC_ODROIDX2
231 231
232config SND_SOC_ARNDALE_RT5631_ALC5631 232config SND_SOC_ARNDALE_RT5631_ALC5631
233 tristate "Audio support for RT5631(ALC5631) on Arndale Board" 233 tristate "Audio support for RT5631(ALC5631) on Arndale Board"
234 depends on SND_SOC_SAMSUNG 234 depends on SND_SOC_SAMSUNG && I2C
235 select SND_SAMSUNG_I2S 235 select SND_SAMSUNG_I2S
236 select SND_SOC_RT5631 236 select SND_SOC_RT5631
diff --git a/sound/soc/samsung/h1940_uda1380.c b/sound/soc/samsung/h1940_uda1380.c
index 59b044255b78..c72e9fb26658 100644
--- a/sound/soc/samsung/h1940_uda1380.c
+++ b/sound/soc/samsung/h1940_uda1380.c
@@ -162,13 +162,8 @@ static struct platform_device *s3c24xx_snd_device;
162 162
163static int h1940_uda1380_init(struct snd_soc_pcm_runtime *rtd) 163static int h1940_uda1380_init(struct snd_soc_pcm_runtime *rtd)
164{ 164{
165 struct snd_soc_codec *codec = rtd->codec; 165 snd_soc_card_jack_new(rtd->card, "Headphone Jack", SND_JACK_HEADPHONE,
166 166 &hp_jack, hp_jack_pins, ARRAY_SIZE(hp_jack_pins));
167 snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE,
168 &hp_jack);
169
170 snd_soc_jack_add_pins(&hp_jack, ARRAY_SIZE(hp_jack_pins),
171 hp_jack_pins);
172 167
173 snd_soc_jack_add_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios), 168 snd_soc_jack_add_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios),
174 hp_jack_gpios); 169 hp_jack_gpios);
diff --git a/sound/soc/samsung/littlemill.c b/sound/soc/samsung/littlemill.c
index 141519c21e21..31a820eb0ac3 100644
--- a/sound/soc/samsung/littlemill.c
+++ b/sound/soc/samsung/littlemill.c
@@ -260,12 +260,12 @@ static int littlemill_late_probe(struct snd_soc_card *card)
260 if (ret < 0) 260 if (ret < 0)
261 return ret; 261 return ret;
262 262
263 ret = snd_soc_jack_new(codec, "Headset", 263 ret = snd_soc_card_jack_new(card, "Headset",
264 SND_JACK_HEADSET | SND_JACK_MECHANICAL | 264 SND_JACK_HEADSET | SND_JACK_MECHANICAL |
265 SND_JACK_BTN_0 | SND_JACK_BTN_1 | 265 SND_JACK_BTN_0 | SND_JACK_BTN_1 |
266 SND_JACK_BTN_2 | SND_JACK_BTN_3 | 266 SND_JACK_BTN_2 | SND_JACK_BTN_3 |
267 SND_JACK_BTN_4 | SND_JACK_BTN_5, 267 SND_JACK_BTN_4 | SND_JACK_BTN_5,
268 &littlemill_headset); 268 &littlemill_headset, NULL, 0);
269 if (ret) 269 if (ret)
270 return ret; 270 return ret;
271 271
diff --git a/sound/soc/samsung/lowland.c b/sound/soc/samsung/lowland.c
index 243dea7ba38f..5f156093101e 100644
--- a/sound/soc/samsung/lowland.c
+++ b/sound/soc/samsung/lowland.c
@@ -56,16 +56,10 @@ static int lowland_wm5100_init(struct snd_soc_pcm_runtime *rtd)
56 return ret; 56 return ret;
57 } 57 }
58 58
59 ret = snd_soc_jack_new(codec, "Headset", 59 ret = snd_soc_card_jack_new(rtd->card, "Headset", SND_JACK_LINEOUT |
60 SND_JACK_LINEOUT | SND_JACK_HEADSET | 60 SND_JACK_HEADSET | SND_JACK_BTN_0,
61 SND_JACK_BTN_0, 61 &lowland_headset, lowland_headset_pins,
62 &lowland_headset); 62 ARRAY_SIZE(lowland_headset_pins));
63 if (ret)
64 return ret;
65
66 ret = snd_soc_jack_add_pins(&lowland_headset,
67 ARRAY_SIZE(lowland_headset_pins),
68 lowland_headset_pins);
69 if (ret) 63 if (ret)
70 return ret; 64 return ret;
71 65
diff --git a/sound/soc/samsung/rx1950_uda1380.c b/sound/soc/samsung/rx1950_uda1380.c
index 873f2cb4bebe..35e37c457f1f 100644
--- a/sound/soc/samsung/rx1950_uda1380.c
+++ b/sound/soc/samsung/rx1950_uda1380.c
@@ -211,13 +211,8 @@ static int rx1950_hw_params(struct snd_pcm_substream *substream,
211 211
212static int rx1950_uda1380_init(struct snd_soc_pcm_runtime *rtd) 212static int rx1950_uda1380_init(struct snd_soc_pcm_runtime *rtd)
213{ 213{
214 struct snd_soc_codec *codec = rtd->codec; 214 snd_soc_card_jack_new(rtd->card, "Headphone Jack", SND_JACK_HEADPHONE,
215 215 &hp_jack, hp_jack_pins, ARRAY_SIZE(hp_jack_pins));
216 snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE,
217 &hp_jack);
218
219 snd_soc_jack_add_pins(&hp_jack, ARRAY_SIZE(hp_jack_pins),
220 hp_jack_pins);
221 216
222 snd_soc_jack_add_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios), 217 snd_soc_jack_add_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios),
223 hp_jack_gpios); 218 hp_jack_gpios);
diff --git a/sound/soc/samsung/smartq_wm8987.c b/sound/soc/samsung/smartq_wm8987.c
index 8291d2a5f152..dfbe2db1c407 100644
--- a/sound/soc/samsung/smartq_wm8987.c
+++ b/sound/soc/samsung/smartq_wm8987.c
@@ -151,13 +151,10 @@ static int smartq_wm8987_init(struct snd_soc_pcm_runtime *rtd)
151 snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); 151 snd_soc_dapm_disable_pin(dapm, "Headphone Jack");
152 152
153 /* Headphone jack detection */ 153 /* Headphone jack detection */
154 err = snd_soc_jack_new(codec, "Headphone Jack", 154 err = snd_soc_card_jack_new(rtd->card, "Headphone Jack",
155 SND_JACK_HEADPHONE, &smartq_jack); 155 SND_JACK_HEADPHONE, &smartq_jack,
156 if (err) 156 smartq_jack_pins,
157 return err; 157 ARRAY_SIZE(smartq_jack_pins));
158
159 err = snd_soc_jack_add_pins(&smartq_jack, ARRAY_SIZE(smartq_jack_pins),
160 smartq_jack_pins);
161 if (err) 158 if (err)
162 return err; 159 return err;
163 160
diff --git a/sound/soc/samsung/speyside.c b/sound/soc/samsung/speyside.c
index 5ec7c52282f2..2dcb988bdff2 100644
--- a/sound/soc/samsung/speyside.c
+++ b/sound/soc/samsung/speyside.c
@@ -153,16 +153,10 @@ static int speyside_wm8996_init(struct snd_soc_pcm_runtime *rtd)
153 pr_err("Failed to request HP_SEL GPIO: %d\n", ret); 153 pr_err("Failed to request HP_SEL GPIO: %d\n", ret);
154 gpio_direction_output(WM8996_HPSEL_GPIO, speyside_jack_polarity); 154 gpio_direction_output(WM8996_HPSEL_GPIO, speyside_jack_polarity);
155 155
156 ret = snd_soc_jack_new(codec, "Headset", 156 ret = snd_soc_card_jack_new(rtd->card, "Headset", SND_JACK_LINEOUT |
157 SND_JACK_LINEOUT | SND_JACK_HEADSET | 157 SND_JACK_HEADSET | SND_JACK_BTN_0,
158 SND_JACK_BTN_0, 158 &speyside_headset, speyside_headset_pins,
159 &speyside_headset); 159 ARRAY_SIZE(speyside_headset_pins));
160 if (ret)
161 return ret;
162
163 ret = snd_soc_jack_add_pins(&speyside_headset,
164 ARRAY_SIZE(speyside_headset_pins),
165 speyside_headset_pins);
166 if (ret) 160 if (ret)
167 return ret; 161 return ret;
168 162
diff --git a/sound/soc/samsung/tobermory.c b/sound/soc/samsung/tobermory.c
index 9c80506527c4..85ccfb7188cb 100644
--- a/sound/soc/samsung/tobermory.c
+++ b/sound/soc/samsung/tobermory.c
@@ -179,15 +179,10 @@ static int tobermory_late_probe(struct snd_soc_card *card)
179 if (ret < 0) 179 if (ret < 0)
180 return ret; 180 return ret;
181 181
182 ret = snd_soc_jack_new(codec, "Headset", 182 ret = snd_soc_card_jack_new(card, "Headset", SND_JACK_HEADSET |
183 SND_JACK_HEADSET | SND_JACK_BTN_0, 183 SND_JACK_BTN_0, &tobermory_headset,
184 &tobermory_headset); 184 tobermory_headset_pins,
185 if (ret) 185 ARRAY_SIZE(tobermory_headset_pins));
186 return ret;
187
188 ret = snd_soc_jack_add_pins(&tobermory_headset,
189 ARRAY_SIZE(tobermory_headset_pins),
190 tobermory_headset_pins);
191 if (ret) 186 if (ret)
192 return ret; 187 return ret;
193 188
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
index 1b53605f7154..110577c52317 100644
--- a/sound/soc/sh/rcar/core.c
+++ b/sound/soc/sh/rcar/core.c
@@ -1252,6 +1252,8 @@ static int rsnd_probe(struct platform_device *pdev)
1252 goto exit_snd_probe; 1252 goto exit_snd_probe;
1253 } 1253 }
1254 1254
1255 dev_set_drvdata(dev, priv);
1256
1255 /* 1257 /*
1256 * asoc register 1258 * asoc register
1257 */ 1259 */
@@ -1268,8 +1270,6 @@ static int rsnd_probe(struct platform_device *pdev)
1268 goto exit_snd_soc; 1270 goto exit_snd_soc;
1269 } 1271 }
1270 1272
1271 dev_set_drvdata(dev, priv);
1272
1273 pm_runtime_enable(dev); 1273 pm_runtime_enable(dev);
1274 1274
1275 dev_info(dev, "probed\n"); 1275 dev_info(dev, "probed\n");
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 30579ca5bacb..5c0658d49609 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1561,6 +1561,10 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
1561 snd_soc_dapm_new_controls(&card->dapm, card->dapm_widgets, 1561 snd_soc_dapm_new_controls(&card->dapm, card->dapm_widgets,
1562 card->num_dapm_widgets); 1562 card->num_dapm_widgets);
1563 1563
1564 if (card->of_dapm_widgets)
1565 snd_soc_dapm_new_controls(&card->dapm, card->of_dapm_widgets,
1566 card->num_of_dapm_widgets);
1567
1564 /* initialise the sound card only once */ 1568 /* initialise the sound card only once */
1565 if (card->probe) { 1569 if (card->probe) {
1566 ret = card->probe(card); 1570 ret = card->probe(card);
@@ -1616,6 +1620,10 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
1616 snd_soc_dapm_add_routes(&card->dapm, card->dapm_routes, 1620 snd_soc_dapm_add_routes(&card->dapm, card->dapm_routes,
1617 card->num_dapm_routes); 1621 card->num_dapm_routes);
1618 1622
1623 if (card->of_dapm_routes)
1624 snd_soc_dapm_add_routes(&card->dapm, card->of_dapm_routes,
1625 card->num_of_dapm_routes);
1626
1619 for (i = 0; i < card->num_links; i++) { 1627 for (i = 0; i < card->num_links; i++) {
1620 if (card->dai_link[i].dai_fmt) 1628 if (card->dai_link[i].dai_fmt)
1621 snd_soc_runtime_set_dai_fmt(&card->rtd[i], 1629 snd_soc_runtime_set_dai_fmt(&card->rtd[i],
@@ -3223,8 +3231,8 @@ int snd_soc_of_parse_audio_simple_widgets(struct snd_soc_card *card,
3223 widgets[i].name = wname; 3231 widgets[i].name = wname;
3224 } 3232 }
3225 3233
3226 card->dapm_widgets = widgets; 3234 card->of_dapm_widgets = widgets;
3227 card->num_dapm_widgets = num_widgets; 3235 card->num_of_dapm_widgets = num_widgets;
3228 3236
3229 return 0; 3237 return 0;
3230} 3238}
@@ -3308,8 +3316,8 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
3308 } 3316 }
3309 } 3317 }
3310 3318
3311 card->num_dapm_routes = num_routes; 3319 card->num_of_dapm_routes = num_routes;
3312 card->dapm_routes = routes; 3320 card->of_dapm_routes = routes;
3313 3321
3314 return 0; 3322 return 0;
3315} 3323}
diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c
index 4380dcc064a5..9f60c25c4568 100644
--- a/sound/soc/soc-jack.c
+++ b/sound/soc/soc-jack.c
@@ -22,30 +22,42 @@
22#include <trace/events/asoc.h> 22#include <trace/events/asoc.h>
23 23
24/** 24/**
25 * snd_soc_jack_new - Create a new jack 25 * snd_soc_card_jack_new - Create a new jack
26 * @codec: ASoC codec 26 * @card: ASoC card
27 * @id: an identifying string for this jack 27 * @id: an identifying string for this jack
28 * @type: a bitmask of enum snd_jack_type values that can be detected by 28 * @type: a bitmask of enum snd_jack_type values that can be detected by
29 * this jack 29 * this jack
30 * @jack: structure to use for the jack 30 * @jack: structure to use for the jack
31 * @pins: Array of jack pins to be added to the jack or NULL
32 * @num_pins: Number of elements in the @pins array
31 * 33 *
32 * Creates a new jack object. 34 * Creates a new jack object.
33 * 35 *
34 * Returns zero if successful, or a negative error code on failure. 36 * Returns zero if successful, or a negative error code on failure.
35 * On success jack will be initialised. 37 * On success jack will be initialised.
36 */ 38 */
37int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type, 39int snd_soc_card_jack_new(struct snd_soc_card *card, const char *id, int type,
38 struct snd_soc_jack *jack) 40 struct snd_soc_jack *jack, struct snd_soc_jack_pin *pins,
41 unsigned int num_pins)
39{ 42{
43 int ret;
44
40 mutex_init(&jack->mutex); 45 mutex_init(&jack->mutex);
41 jack->codec = codec; 46 jack->card = card;
42 INIT_LIST_HEAD(&jack->pins); 47 INIT_LIST_HEAD(&jack->pins);
43 INIT_LIST_HEAD(&jack->jack_zones); 48 INIT_LIST_HEAD(&jack->jack_zones);
44 BLOCKING_INIT_NOTIFIER_HEAD(&jack->notifier); 49 BLOCKING_INIT_NOTIFIER_HEAD(&jack->notifier);
45 50
46 return snd_jack_new(codec->component.card->snd_card, id, type, &jack->jack); 51 ret = snd_jack_new(card->snd_card, id, type, &jack->jack);
52 if (ret)
53 return ret;
54
55 if (num_pins)
56 return snd_soc_jack_add_pins(jack, num_pins, pins);
57
58 return 0;
47} 59}
48EXPORT_SYMBOL_GPL(snd_soc_jack_new); 60EXPORT_SYMBOL_GPL(snd_soc_card_jack_new);
49 61
50/** 62/**
51 * snd_soc_jack_report - Report the current status for a jack 63 * snd_soc_jack_report - Report the current status for a jack
@@ -63,7 +75,6 @@ EXPORT_SYMBOL_GPL(snd_soc_jack_new);
63 */ 75 */
64void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask) 76void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask)
65{ 77{
66 struct snd_soc_codec *codec;
67 struct snd_soc_dapm_context *dapm; 78 struct snd_soc_dapm_context *dapm;
68 struct snd_soc_jack_pin *pin; 79 struct snd_soc_jack_pin *pin;
69 unsigned int sync = 0; 80 unsigned int sync = 0;
@@ -74,8 +85,7 @@ void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask)
74 if (!jack) 85 if (!jack)
75 return; 86 return;
76 87
77 codec = jack->codec; 88 dapm = &jack->card->dapm;
78 dapm = &codec->dapm;
79 89
80 mutex_lock(&jack->mutex); 90 mutex_lock(&jack->mutex);
81 91
@@ -175,12 +185,12 @@ int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count,
175 185
176 for (i = 0; i < count; i++) { 186 for (i = 0; i < count; i++) {
177 if (!pins[i].pin) { 187 if (!pins[i].pin) {
178 dev_err(jack->codec->dev, "ASoC: No name for pin %d\n", 188 dev_err(jack->card->dev, "ASoC: No name for pin %d\n",
179 i); 189 i);
180 return -EINVAL; 190 return -EINVAL;
181 } 191 }
182 if (!pins[i].mask) { 192 if (!pins[i].mask) {
183 dev_err(jack->codec->dev, "ASoC: No mask for pin %d" 193 dev_err(jack->card->dev, "ASoC: No mask for pin %d"
184 " (%s)\n", i, pins[i].pin); 194 " (%s)\n", i, pins[i].pin);
185 return -EINVAL; 195 return -EINVAL;
186 } 196 }
@@ -260,7 +270,7 @@ static void snd_soc_jack_gpio_detect(struct snd_soc_jack_gpio *gpio)
260static irqreturn_t gpio_handler(int irq, void *data) 270static irqreturn_t gpio_handler(int irq, void *data)
261{ 271{
262 struct snd_soc_jack_gpio *gpio = data; 272 struct snd_soc_jack_gpio *gpio = data;
263 struct device *dev = gpio->jack->codec->component.card->dev; 273 struct device *dev = gpio->jack->card->dev;
264 274
265 trace_snd_soc_jack_irq(gpio->name); 275 trace_snd_soc_jack_irq(gpio->name);
266 276
@@ -299,7 +309,7 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
299 309
300 for (i = 0; i < count; i++) { 310 for (i = 0; i < count; i++) {
301 if (!gpios[i].name) { 311 if (!gpios[i].name) {
302 dev_err(jack->codec->dev, 312 dev_err(jack->card->dev,
303 "ASoC: No name for gpio at index %d\n", i); 313 "ASoC: No name for gpio at index %d\n", i);
304 ret = -EINVAL; 314 ret = -EINVAL;
305 goto undo; 315 goto undo;
@@ -320,7 +330,7 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
320 } else { 330 } else {
321 /* legacy GPIO number */ 331 /* legacy GPIO number */
322 if (!gpio_is_valid(gpios[i].gpio)) { 332 if (!gpio_is_valid(gpios[i].gpio)) {
323 dev_err(jack->codec->dev, 333 dev_err(jack->card->dev,
324 "ASoC: Invalid gpio %d\n", 334 "ASoC: Invalid gpio %d\n",
325 gpios[i].gpio); 335 gpios[i].gpio);
326 ret = -EINVAL; 336 ret = -EINVAL;
@@ -350,7 +360,7 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
350 if (gpios[i].wake) { 360 if (gpios[i].wake) {
351 ret = irq_set_irq_wake(gpiod_to_irq(gpios[i].desc), 1); 361 ret = irq_set_irq_wake(gpiod_to_irq(gpios[i].desc), 1);
352 if (ret != 0) 362 if (ret != 0)
353 dev_err(jack->codec->dev, 363 dev_err(jack->card->dev,
354 "ASoC: Failed to mark GPIO at index %d as wake source: %d\n", 364 "ASoC: Failed to mark GPIO at index %d as wake source: %d\n",
355 i, ret); 365 i, ret);
356 } 366 }
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index 6b0136e7cb88..6e3781e88f9a 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -2511,6 +2511,7 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
2511 /* DAPM dai link stream work */ 2511 /* DAPM dai link stream work */
2512 INIT_DELAYED_WORK(&rtd->delayed_work, close_delayed_work); 2512 INIT_DELAYED_WORK(&rtd->delayed_work, close_delayed_work);
2513 2513
2514 pcm->nonatomic = rtd->dai_link->nonatomic;
2514 rtd->pcm = pcm; 2515 rtd->pcm = pcm;
2515 pcm->private_data = rtd; 2516 pcm->private_data = rtd;
2516 2517
diff --git a/sound/soc/tegra/tegra_alc5632.c b/sound/soc/tegra/tegra_alc5632.c
index 769aca2fc5f5..6dcd06a966c7 100644
--- a/sound/soc/tegra/tegra_alc5632.c
+++ b/sound/soc/tegra/tegra_alc5632.c
@@ -106,11 +106,10 @@ static int tegra_alc5632_asoc_init(struct snd_soc_pcm_runtime *rtd)
106 struct snd_soc_dapm_context *dapm = &codec->dapm; 106 struct snd_soc_dapm_context *dapm = &codec->dapm;
107 struct tegra_alc5632 *machine = snd_soc_card_get_drvdata(rtd->card); 107 struct tegra_alc5632 *machine = snd_soc_card_get_drvdata(rtd->card);
108 108
109 snd_soc_jack_new(codec, "Headset Jack", SND_JACK_HEADSET, 109 snd_soc_card_jack_new(rtd->card, "Headset Jack", SND_JACK_HEADSET,
110 &tegra_alc5632_hs_jack); 110 &tegra_alc5632_hs_jack,
111 snd_soc_jack_add_pins(&tegra_alc5632_hs_jack, 111 tegra_alc5632_hs_jack_pins,
112 ARRAY_SIZE(tegra_alc5632_hs_jack_pins), 112 ARRAY_SIZE(tegra_alc5632_hs_jack_pins));
113 tegra_alc5632_hs_jack_pins);
114 113
115 if (gpio_is_valid(machine->gpio_hp_det)) { 114 if (gpio_is_valid(machine->gpio_hp_det)) {
116 tegra_alc5632_hp_jack_gpio.gpio = machine->gpio_hp_det; 115 tegra_alc5632_hp_jack_gpio.gpio = machine->gpio_hp_det;
diff --git a/sound/soc/tegra/tegra_max98090.c b/sound/soc/tegra/tegra_max98090.c
index af3fb997b752..902da36581d1 100644
--- a/sound/soc/tegra/tegra_max98090.c
+++ b/sound/soc/tegra/tegra_max98090.c
@@ -133,24 +133,26 @@ static const struct snd_soc_dapm_widget tegra_max98090_dapm_widgets[] = {
133 SND_SOC_DAPM_HP("Headphones", NULL), 133 SND_SOC_DAPM_HP("Headphones", NULL),
134 SND_SOC_DAPM_SPK("Speakers", NULL), 134 SND_SOC_DAPM_SPK("Speakers", NULL),
135 SND_SOC_DAPM_MIC("Mic Jack", NULL), 135 SND_SOC_DAPM_MIC("Mic Jack", NULL),
136 SND_SOC_DAPM_MIC("Int Mic", NULL),
136}; 137};
137 138
138static const struct snd_kcontrol_new tegra_max98090_controls[] = { 139static const struct snd_kcontrol_new tegra_max98090_controls[] = {
140 SOC_DAPM_PIN_SWITCH("Headphones"),
139 SOC_DAPM_PIN_SWITCH("Speakers"), 141 SOC_DAPM_PIN_SWITCH("Speakers"),
142 SOC_DAPM_PIN_SWITCH("Mic Jack"),
143 SOC_DAPM_PIN_SWITCH("Int Mic"),
140}; 144};
141 145
142static int tegra_max98090_asoc_init(struct snd_soc_pcm_runtime *rtd) 146static int tegra_max98090_asoc_init(struct snd_soc_pcm_runtime *rtd)
143{ 147{
144 struct snd_soc_dai *codec_dai = rtd->codec_dai;
145 struct snd_soc_codec *codec = codec_dai->codec;
146 struct tegra_max98090 *machine = snd_soc_card_get_drvdata(rtd->card); 148 struct tegra_max98090 *machine = snd_soc_card_get_drvdata(rtd->card);
147 149
148 if (gpio_is_valid(machine->gpio_hp_det)) { 150 if (gpio_is_valid(machine->gpio_hp_det)) {
149 snd_soc_jack_new(codec, "Headphones", SND_JACK_HEADPHONE, 151 snd_soc_card_jack_new(rtd->card, "Headphones",
150 &tegra_max98090_hp_jack); 152 SND_JACK_HEADPHONE,
151 snd_soc_jack_add_pins(&tegra_max98090_hp_jack, 153 &tegra_max98090_hp_jack,
152 ARRAY_SIZE(tegra_max98090_hp_jack_pins), 154 tegra_max98090_hp_jack_pins,
153 tegra_max98090_hp_jack_pins); 155 ARRAY_SIZE(tegra_max98090_hp_jack_pins));
154 156
155 tegra_max98090_hp_jack_gpio.gpio = machine->gpio_hp_det; 157 tegra_max98090_hp_jack_gpio.gpio = machine->gpio_hp_det;
156 snd_soc_jack_add_gpios(&tegra_max98090_hp_jack, 158 snd_soc_jack_add_gpios(&tegra_max98090_hp_jack,
@@ -159,11 +161,11 @@ static int tegra_max98090_asoc_init(struct snd_soc_pcm_runtime *rtd)
159 } 161 }
160 162
161 if (gpio_is_valid(machine->gpio_mic_det)) { 163 if (gpio_is_valid(machine->gpio_mic_det)) {
162 snd_soc_jack_new(codec, "Mic Jack", SND_JACK_MICROPHONE, 164 snd_soc_card_jack_new(rtd->card, "Mic Jack",
163 &tegra_max98090_mic_jack); 165 SND_JACK_MICROPHONE,
164 snd_soc_jack_add_pins(&tegra_max98090_mic_jack, 166 &tegra_max98090_mic_jack,
165 ARRAY_SIZE(tegra_max98090_mic_jack_pins), 167 tegra_max98090_mic_jack_pins,
166 tegra_max98090_mic_jack_pins); 168 ARRAY_SIZE(tegra_max98090_mic_jack_pins));
167 169
168 tegra_max98090_mic_jack_gpio.gpio = machine->gpio_mic_det; 170 tegra_max98090_mic_jack_gpio.gpio = machine->gpio_mic_det;
169 snd_soc_jack_add_gpios(&tegra_max98090_mic_jack, 171 snd_soc_jack_add_gpios(&tegra_max98090_mic_jack,
diff --git a/sound/soc/tegra/tegra_rt5640.c b/sound/soc/tegra/tegra_rt5640.c
index ed759a3076b8..773daecaa5e8 100644
--- a/sound/soc/tegra/tegra_rt5640.c
+++ b/sound/soc/tegra/tegra_rt5640.c
@@ -108,15 +108,11 @@ static const struct snd_kcontrol_new tegra_rt5640_controls[] = {
108 108
109static int tegra_rt5640_asoc_init(struct snd_soc_pcm_runtime *rtd) 109static int tegra_rt5640_asoc_init(struct snd_soc_pcm_runtime *rtd)
110{ 110{
111 struct snd_soc_dai *codec_dai = rtd->codec_dai;
112 struct snd_soc_codec *codec = codec_dai->codec;
113 struct tegra_rt5640 *machine = snd_soc_card_get_drvdata(rtd->card); 111 struct tegra_rt5640 *machine = snd_soc_card_get_drvdata(rtd->card);
114 112
115 snd_soc_jack_new(codec, "Headphones", SND_JACK_HEADPHONE, 113 snd_soc_card_jack_new(rtd->card, "Headphones", SND_JACK_HEADPHONE,
116 &tegra_rt5640_hp_jack); 114 &tegra_rt5640_hp_jack, tegra_rt5640_hp_jack_pins,
117 snd_soc_jack_add_pins(&tegra_rt5640_hp_jack, 115 ARRAY_SIZE(tegra_rt5640_hp_jack_pins));
118 ARRAY_SIZE(tegra_rt5640_hp_jack_pins),
119 tegra_rt5640_hp_jack_pins);
120 116
121 if (gpio_is_valid(machine->gpio_hp_det)) { 117 if (gpio_is_valid(machine->gpio_hp_det)) {
122 tegra_rt5640_hp_jack_gpio.gpio = machine->gpio_hp_det; 118 tegra_rt5640_hp_jack_gpio.gpio = machine->gpio_hp_det;
diff --git a/sound/soc/tegra/tegra_rt5677.c b/sound/soc/tegra/tegra_rt5677.c
index e4cf978a6e3a..68d8b67e79c1 100644
--- a/sound/soc/tegra/tegra_rt5677.c
+++ b/sound/soc/tegra/tegra_rt5677.c
@@ -146,10 +146,9 @@ static int tegra_rt5677_asoc_init(struct snd_soc_pcm_runtime *rtd)
146 struct snd_soc_dapm_context *dapm = &codec->dapm; 146 struct snd_soc_dapm_context *dapm = &codec->dapm;
147 struct tegra_rt5677 *machine = snd_soc_card_get_drvdata(rtd->card); 147 struct tegra_rt5677 *machine = snd_soc_card_get_drvdata(rtd->card);
148 148
149 snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE, 149 snd_soc_card_jack_new(rtd->card, "Headphone Jack", SND_JACK_HEADPHONE,
150 &tegra_rt5677_hp_jack); 150 &tegra_rt5677_hp_jack,
151 snd_soc_jack_add_pins(&tegra_rt5677_hp_jack, 1, 151 &tegra_rt5677_hp_jack_pins, 1);
152 &tegra_rt5677_hp_jack_pins);
153 152
154 if (gpio_is_valid(machine->gpio_hp_det)) { 153 if (gpio_is_valid(machine->gpio_hp_det)) {
155 tegra_rt5677_hp_jack_gpio.gpio = machine->gpio_hp_det; 154 tegra_rt5677_hp_jack_gpio.gpio = machine->gpio_hp_det;
@@ -158,10 +157,9 @@ static int tegra_rt5677_asoc_init(struct snd_soc_pcm_runtime *rtd)
158 } 157 }
159 158
160 159
161 snd_soc_jack_new(codec, "Mic Jack", SND_JACK_MICROPHONE, 160 snd_soc_card_jack_new(rtd->card, "Mic Jack", SND_JACK_MICROPHONE,
162 &tegra_rt5677_mic_jack); 161 &tegra_rt5677_mic_jack,
163 snd_soc_jack_add_pins(&tegra_rt5677_mic_jack, 1, 162 &tegra_rt5677_mic_jack_pins, 1);
164 &tegra_rt5677_mic_jack_pins);
165 163
166 if (gpio_is_valid(machine->gpio_mic_present)) { 164 if (gpio_is_valid(machine->gpio_mic_present)) {
167 tegra_rt5677_mic_jack_gpio.gpio = machine->gpio_mic_present; 165 tegra_rt5677_mic_jack_gpio.gpio = machine->gpio_mic_present;
diff --git a/sound/soc/tegra/tegra_wm8903.c b/sound/soc/tegra/tegra_wm8903.c
index e52420dae2b4..4a95b70f0cf0 100644
--- a/sound/soc/tegra/tegra_wm8903.c
+++ b/sound/soc/tegra/tegra_wm8903.c
@@ -177,21 +177,19 @@ static int tegra_wm8903_init(struct snd_soc_pcm_runtime *rtd)
177 177
178 if (gpio_is_valid(machine->gpio_hp_det)) { 178 if (gpio_is_valid(machine->gpio_hp_det)) {
179 tegra_wm8903_hp_jack_gpio.gpio = machine->gpio_hp_det; 179 tegra_wm8903_hp_jack_gpio.gpio = machine->gpio_hp_det;
180 snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE, 180 snd_soc_card_jack_new(rtd->card, "Headphone Jack",
181 &tegra_wm8903_hp_jack); 181 SND_JACK_HEADPHONE, &tegra_wm8903_hp_jack,
182 snd_soc_jack_add_pins(&tegra_wm8903_hp_jack, 182 tegra_wm8903_hp_jack_pins,
183 ARRAY_SIZE(tegra_wm8903_hp_jack_pins), 183 ARRAY_SIZE(tegra_wm8903_hp_jack_pins));
184 tegra_wm8903_hp_jack_pins);
185 snd_soc_jack_add_gpios(&tegra_wm8903_hp_jack, 184 snd_soc_jack_add_gpios(&tegra_wm8903_hp_jack,
186 1, 185 1,
187 &tegra_wm8903_hp_jack_gpio); 186 &tegra_wm8903_hp_jack_gpio);
188 } 187 }
189 188
190 snd_soc_jack_new(codec, "Mic Jack", SND_JACK_MICROPHONE, 189 snd_soc_card_jack_new(rtd->card, "Mic Jack", SND_JACK_MICROPHONE,
191 &tegra_wm8903_mic_jack); 190 &tegra_wm8903_mic_jack,
192 snd_soc_jack_add_pins(&tegra_wm8903_mic_jack, 191 tegra_wm8903_mic_jack_pins,
193 ARRAY_SIZE(tegra_wm8903_mic_jack_pins), 192 ARRAY_SIZE(tegra_wm8903_mic_jack_pins));
194 tegra_wm8903_mic_jack_pins);
195 wm8903_mic_detect(codec, &tegra_wm8903_mic_jack, SND_JACK_MICROPHONE, 193 wm8903_mic_detect(codec, &tegra_wm8903_mic_jack, SND_JACK_MICROPHONE,
196 0); 194 0);
197 195
diff --git a/tools/perf/bench/mem-memcpy.c b/tools/perf/bench/mem-memcpy.c
index 6c14afe8c1b1..db1d3a29d97f 100644
--- a/tools/perf/bench/mem-memcpy.c
+++ b/tools/perf/bench/mem-memcpy.c
@@ -289,7 +289,7 @@ static u64 do_memcpy_cycle(const struct routine *r, size_t len, bool prefault)
289 memcpy_t fn = r->fn.memcpy; 289 memcpy_t fn = r->fn.memcpy;
290 int i; 290 int i;
291 291
292 memcpy_alloc_mem(&src, &dst, len); 292 memcpy_alloc_mem(&dst, &src, len);
293 293
294 if (prefault) 294 if (prefault)
295 fn(dst, src, len); 295 fn(dst, src, len);
@@ -312,7 +312,7 @@ static double do_memcpy_gettimeofday(const struct routine *r, size_t len,
312 void *src = NULL, *dst = NULL; 312 void *src = NULL, *dst = NULL;
313 int i; 313 int i;
314 314
315 memcpy_alloc_mem(&src, &dst, len); 315 memcpy_alloc_mem(&dst, &src, len);
316 316
317 if (prefault) 317 if (prefault)
318 fn(dst, src, len); 318 fn(dst, src, len);
diff --git a/tools/perf/config/Makefile.arch b/tools/perf/config/Makefile.arch
index ff95a68741d1..ac8721ffa6c8 100644
--- a/tools/perf/config/Makefile.arch
+++ b/tools/perf/config/Makefile.arch
@@ -21,6 +21,10 @@ ifeq ($(RAW_ARCH),x86_64)
21 endif 21 endif
22endif 22endif
23 23
24ifeq ($(RAW_ARCH),sparc64)
25 ARCH ?= sparc
26endif
27
24ARCH ?= $(RAW_ARCH) 28ARCH ?= $(RAW_ARCH)
25 29
26LP64 := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1) 30LP64 := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1)
diff --git a/tools/perf/config/feature-checks/Makefile b/tools/perf/config/feature-checks/Makefile
index 42ac05aaf8ac..b32ff3372514 100644
--- a/tools/perf/config/feature-checks/Makefile
+++ b/tools/perf/config/feature-checks/Makefile
@@ -49,7 +49,7 @@ test-hello.bin:
49 $(BUILD) 49 $(BUILD)
50 50
51test-pthread-attr-setaffinity-np.bin: 51test-pthread-attr-setaffinity-np.bin:
52 $(BUILD) -Werror -lpthread 52 $(BUILD) -D_GNU_SOURCE -Werror -lpthread
53 53
54test-stackprotector-all.bin: 54test-stackprotector-all.bin:
55 $(BUILD) -Werror -fstack-protector-all 55 $(BUILD) -Werror -fstack-protector-all
diff --git a/tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c b/tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c
index 0a0d3ecb4e8a..2b81b72eca23 100644
--- a/tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c
+++ b/tools/perf/config/feature-checks/test-pthread-attr-setaffinity-np.c
@@ -5,10 +5,11 @@ int main(void)
5{ 5{
6 int ret = 0; 6 int ret = 0;
7 pthread_attr_t thread_attr; 7 pthread_attr_t thread_attr;
8 cpu_set_t cs;
8 9
9 pthread_attr_init(&thread_attr); 10 pthread_attr_init(&thread_attr);
10 /* don't care abt exact args, just the API itself in libpthread */ 11 /* don't care abt exact args, just the API itself in libpthread */
11 ret = pthread_attr_setaffinity_np(&thread_attr, 0, NULL); 12 ret = pthread_attr_setaffinity_np(&thread_attr, sizeof(cs), &cs);
12 13
13 return ret; 14 return ret;
14} 15}
diff --git a/tools/perf/util/cloexec.c b/tools/perf/util/cloexec.c
index 47b78b3f0325..6da965bdbc2c 100644
--- a/tools/perf/util/cloexec.c
+++ b/tools/perf/util/cloexec.c
@@ -25,6 +25,10 @@ static int perf_flag_probe(void)
25 if (cpu < 0) 25 if (cpu < 0)
26 cpu = 0; 26 cpu = 0;
27 27
28 /*
29 * Using -1 for the pid is a workaround to avoid gratuitous jump label
30 * changes.
31 */
28 while (1) { 32 while (1) {
29 /* check cloexec flag */ 33 /* check cloexec flag */
30 fd = sys_perf_event_open(&attr, pid, cpu, -1, 34 fd = sys_perf_event_open(&attr, pid, cpu, -1,
@@ -47,16 +51,24 @@ static int perf_flag_probe(void)
47 err, strerror_r(err, sbuf, sizeof(sbuf))); 51 err, strerror_r(err, sbuf, sizeof(sbuf)));
48 52
49 /* not supported, confirm error related to PERF_FLAG_FD_CLOEXEC */ 53 /* not supported, confirm error related to PERF_FLAG_FD_CLOEXEC */
50 fd = sys_perf_event_open(&attr, pid, cpu, -1, 0); 54 while (1) {
55 fd = sys_perf_event_open(&attr, pid, cpu, -1, 0);
56 if (fd < 0 && pid == -1 && errno == EACCES) {
57 pid = 0;
58 continue;
59 }
60 break;
61 }
51 err = errno; 62 err = errno;
52 63
64 if (fd >= 0)
65 close(fd);
66
53 if (WARN_ONCE(fd < 0 && err != EBUSY, 67 if (WARN_ONCE(fd < 0 && err != EBUSY,
54 "perf_event_open(..., 0) failed unexpectedly with error %d (%s)\n", 68 "perf_event_open(..., 0) failed unexpectedly with error %d (%s)\n",
55 err, strerror_r(err, sbuf, sizeof(sbuf)))) 69 err, strerror_r(err, sbuf, sizeof(sbuf))))
56 return -1; 70 return -1;
57 71
58 close(fd);
59
60 return 0; 72 return 0;
61} 73}
62 74
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index c94a9e03ecf1..e99a67632831 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -28,7 +28,7 @@ struct perf_mmap {
28 int mask; 28 int mask;
29 int refcnt; 29 int refcnt;
30 unsigned int prev; 30 unsigned int prev;
31 char event_copy[PERF_SAMPLE_MAX_SIZE]; 31 char event_copy[PERF_SAMPLE_MAX_SIZE] __attribute__((aligned(8)));
32}; 32};
33 33
34struct perf_evlist { 34struct perf_evlist {
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index b24f9d8727a8..33b7a2aef713 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -11,6 +11,11 @@
11#include <symbol/kallsyms.h> 11#include <symbol/kallsyms.h>
12#include "debug.h" 12#include "debug.h"
13 13
14#ifndef EM_AARCH64
15#define EM_AARCH64 183 /* ARM 64 bit */
16#endif
17
18
14#ifdef HAVE_CPLUS_DEMANGLE_SUPPORT 19#ifdef HAVE_CPLUS_DEMANGLE_SUPPORT
15extern char *cplus_demangle(const char *, int); 20extern char *cplus_demangle(const char *, int);
16 21
diff --git a/tools/thermal/tmon/.gitignore b/tools/thermal/tmon/.gitignore
new file mode 100644
index 000000000000..06e96be65276
--- /dev/null
+++ b/tools/thermal/tmon/.gitignore
@@ -0,0 +1 @@
/tmon
diff --git a/tools/thermal/tmon/Makefile b/tools/thermal/tmon/Makefile
index e775adcbd29f..0788621c8d76 100644
--- a/tools/thermal/tmon/Makefile
+++ b/tools/thermal/tmon/Makefile
@@ -2,8 +2,8 @@ VERSION = 1.0
2 2
3BINDIR=usr/bin 3BINDIR=usr/bin
4WARNFLAGS=-Wall -Wshadow -W -Wformat -Wimplicit-function-declaration -Wimplicit-int 4WARNFLAGS=-Wall -Wshadow -W -Wformat -Wimplicit-function-declaration -Wimplicit-int
5CFLAGS= -O1 ${WARNFLAGS} -fstack-protector 5CFLAGS+= -O1 ${WARNFLAGS} -fstack-protector
6CC=gcc 6CC=$(CROSS_COMPILE)gcc
7 7
8CFLAGS+=-D VERSION=\"$(VERSION)\" 8CFLAGS+=-D VERSION=\"$(VERSION)\"
9LDFLAGS+= 9LDFLAGS+=
@@ -16,12 +16,21 @@ INSTALL_CONFIGFILE=install -m 644 -p
16CONFIG_FILE= 16CONFIG_FILE=
17CONFIG_PATH= 17CONFIG_PATH=
18 18
19# Static builds might require -ltinfo, for instance
20ifneq ($(findstring -static, $(LDFLAGS)),)
21STATIC := --static
22endif
23
24TMON_LIBS=-lm -lpthread
25TMON_LIBS += $(shell pkg-config --libs $(STATIC) panelw ncursesw 2> /dev/null || \
26 pkg-config --libs $(STATIC) panel ncurses 2> /dev/null || \
27 echo -lpanel -lncurses)
19 28
20OBJS = tmon.o tui.o sysfs.o pid.o 29OBJS = tmon.o tui.o sysfs.o pid.o
21OBJS += 30OBJS +=
22 31
23tmon: $(OBJS) Makefile tmon.h 32tmon: $(OBJS) Makefile tmon.h
24 $(CC) ${CFLAGS} $(LDFLAGS) $(OBJS) -o $(TARGET) -lm -lpanel -lncursesw -ltinfo -lpthread 33 $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $(TARGET) $(TMON_LIBS)
25 34
26valgrind: tmon 35valgrind: tmon
27 sudo valgrind -v --track-origins=yes --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes ./$(TARGET) 1> /dev/null 36 sudo valgrind -v --track-origins=yes --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes ./$(TARGET) 1> /dev/null
diff --git a/tools/thermal/tmon/tmon.8 b/tools/thermal/tmon/tmon.8
index 0be727cb9892..02d5179803aa 100644
--- a/tools/thermal/tmon/tmon.8
+++ b/tools/thermal/tmon/tmon.8
@@ -55,6 +55,8 @@ The \fB-l --log\fP option write data to /var/tmp/tmon.log
55.PP 55.PP
56The \fB-t --time-interval\fP option sets the polling interval in seconds 56The \fB-t --time-interval\fP option sets the polling interval in seconds
57.PP 57.PP
58The \fB-T --target-temp\fP option sets the initial target temperature
59.PP
58The \fB-v --version\fP option shows the version of \fBtmon \fP 60The \fB-v --version\fP option shows the version of \fBtmon \fP
59.PP 61.PP
60The \fB-z --zone\fP option sets the target therma zone instance to be controlled 62The \fB-z --zone\fP option sets the target therma zone instance to be controlled
diff --git a/tools/thermal/tmon/tmon.c b/tools/thermal/tmon/tmon.c
index 09b7c3218334..9aa19652e8e8 100644
--- a/tools/thermal/tmon/tmon.c
+++ b/tools/thermal/tmon/tmon.c
@@ -64,6 +64,7 @@ void usage()
64 printf(" -h, --help show this help message\n"); 64 printf(" -h, --help show this help message\n");
65 printf(" -l, --log log data to /var/tmp/tmon.log\n"); 65 printf(" -l, --log log data to /var/tmp/tmon.log\n");
66 printf(" -t, --time-interval sampling time interval, > 1 sec.\n"); 66 printf(" -t, --time-interval sampling time interval, > 1 sec.\n");
67 printf(" -T, --target-temp initial target temperature\n");
67 printf(" -v, --version show version\n"); 68 printf(" -v, --version show version\n");
68 printf(" -z, --zone target thermal zone id\n"); 69 printf(" -z, --zone target thermal zone id\n");
69 70
@@ -219,6 +220,7 @@ static struct option opts[] = {
219 { "control", 1, NULL, 'c' }, 220 { "control", 1, NULL, 'c' },
220 { "daemon", 0, NULL, 'd' }, 221 { "daemon", 0, NULL, 'd' },
221 { "time-interval", 1, NULL, 't' }, 222 { "time-interval", 1, NULL, 't' },
223 { "target-temp", 1, NULL, 'T' },
222 { "log", 0, NULL, 'l' }, 224 { "log", 0, NULL, 'l' },
223 { "help", 0, NULL, 'h' }, 225 { "help", 0, NULL, 'h' },
224 { "version", 0, NULL, 'v' }, 226 { "version", 0, NULL, 'v' },
@@ -231,7 +233,7 @@ int main(int argc, char **argv)
231{ 233{
232 int err = 0; 234 int err = 0;
233 int id2 = 0, c; 235 int id2 = 0, c;
234 double yk = 0.0; /* controller output */ 236 double yk = 0.0, temp; /* controller output */
235 int target_tz_index; 237 int target_tz_index;
236 238
237 if (geteuid() != 0) { 239 if (geteuid() != 0) {
@@ -239,7 +241,7 @@ int main(int argc, char **argv)
239 exit(EXIT_FAILURE); 241 exit(EXIT_FAILURE);
240 } 242 }
241 243
242 while ((c = getopt_long(argc, argv, "c:dlht:vgz:", opts, &id2)) != -1) { 244 while ((c = getopt_long(argc, argv, "c:dlht:T:vgz:", opts, &id2)) != -1) {
243 switch (c) { 245 switch (c) {
244 case 'c': 246 case 'c':
245 no_control = 0; 247 no_control = 0;
@@ -254,6 +256,14 @@ int main(int argc, char **argv)
254 if (ticktime < 1) 256 if (ticktime < 1)
255 ticktime = 1; 257 ticktime = 1;
256 break; 258 break;
259 case 'T':
260 temp = strtod(optarg, NULL);
261 if (temp < 0) {
262 fprintf(stderr, "error: temperature must be positive\n");
263 return 1;
264 }
265 target_temp_user = temp;
266 break;
257 case 'l': 267 case 'l':
258 printf("Logging data to /var/tmp/tmon.log\n"); 268 printf("Logging data to /var/tmp/tmon.log\n");
259 logging = 1; 269 logging = 1;
diff --git a/tools/thermal/tmon/tui.c b/tools/thermal/tmon/tui.c
index 89f8ef0e15c8..b5d1c6b22dd3 100644
--- a/tools/thermal/tmon/tui.c
+++ b/tools/thermal/tmon/tui.c
@@ -30,6 +30,18 @@
30 30
31#include "tmon.h" 31#include "tmon.h"
32 32
33#define min(x, y) ({ \
34 typeof(x) _min1 = (x); \
35 typeof(y) _min2 = (y); \
36 (void) (&_min1 == &_min2); \
37 _min1 < _min2 ? _min1 : _min2; })
38
39#define max(x, y) ({ \
40 typeof(x) _max1 = (x); \
41 typeof(y) _max2 = (y); \
42 (void) (&_max1 == &_max2); \
43 _max1 > _max2 ? _max1 : _max2; })
44
33static PANEL *data_panel; 45static PANEL *data_panel;
34static PANEL *dialogue_panel; 46static PANEL *dialogue_panel;
35static PANEL *top; 47static PANEL *top;
@@ -98,6 +110,18 @@ void write_status_bar(int x, char *line)
98 wrefresh(status_bar_window); 110 wrefresh(status_bar_window);
99} 111}
100 112
113/* wrap at 5 */
114#define DIAG_DEV_ROWS 5
115/*
116 * list cooling devices + "set temp" entry; wraps after 5 rows, if they fit
117 */
118static int diag_dev_rows(void)
119{
120 int entries = ptdata.nr_cooling_dev + 1;
121 int rows = max(DIAG_DEV_ROWS, (entries + 1) / 2);
122 return min(rows, entries);
123}
124
101void setup_windows(void) 125void setup_windows(void)
102{ 126{
103 int y_begin = 1; 127 int y_begin = 1;
@@ -122,7 +146,7 @@ void setup_windows(void)
122 * dialogue window is a pop-up, when needed it lays on top of cdev win 146 * dialogue window is a pop-up, when needed it lays on top of cdev win
123 */ 147 */
124 148
125 dialogue_window = subwin(stdscr, ptdata.nr_cooling_dev+5, maxx-50, 149 dialogue_window = subwin(stdscr, diag_dev_rows() + 5, maxx-50,
126 DIAG_Y, DIAG_X); 150 DIAG_Y, DIAG_X);
127 151
128 thermal_data_window = subwin(stdscr, ptdata.nr_tz_sensor * 152 thermal_data_window = subwin(stdscr, ptdata.nr_tz_sensor *
@@ -258,21 +282,26 @@ void show_cooling_device(void)
258} 282}
259 283
260const char DIAG_TITLE[] = "[ TUNABLES ]"; 284const char DIAG_TITLE[] = "[ TUNABLES ]";
261#define DIAG_DEV_ROWS 5
262void show_dialogue(void) 285void show_dialogue(void)
263{ 286{
264 int j, x = 0, y = 0; 287 int j, x = 0, y = 0;
288 int rows, cols;
265 WINDOW *w = dialogue_window; 289 WINDOW *w = dialogue_window;
266 290
267 if (tui_disabled || !w) 291 if (tui_disabled || !w)
268 return; 292 return;
269 293
294 getmaxyx(w, rows, cols);
295
296 /* Silence compiler 'unused' warnings */
297 (void)cols;
298
270 werase(w); 299 werase(w);
271 box(w, 0, 0); 300 box(w, 0, 0);
272 mvwprintw(w, 0, maxx/4, DIAG_TITLE); 301 mvwprintw(w, 0, maxx/4, DIAG_TITLE);
273 /* list all the available tunables */ 302 /* list all the available tunables */
274 for (j = 0; j <= ptdata.nr_cooling_dev; j++) { 303 for (j = 0; j <= ptdata.nr_cooling_dev; j++) {
275 y = j % DIAG_DEV_ROWS; 304 y = j % diag_dev_rows();
276 if (y == 0 && j != 0) 305 if (y == 0 && j != 0)
277 x += 20; 306 x += 20;
278 if (j == ptdata.nr_cooling_dev) 307 if (j == ptdata.nr_cooling_dev)
@@ -283,12 +312,10 @@ void show_dialogue(void)
283 ptdata.cdi[j].type, ptdata.cdi[j].instance); 312 ptdata.cdi[j].type, ptdata.cdi[j].instance);
284 } 313 }
285 wattron(w, A_BOLD); 314 wattron(w, A_BOLD);
286 mvwprintw(w, DIAG_DEV_ROWS+1, 1, "Enter Choice [A-Z]?"); 315 mvwprintw(w, diag_dev_rows()+1, 1, "Enter Choice [A-Z]?");
287 wattroff(w, A_BOLD); 316 wattroff(w, A_BOLD);
288 /* y size of dialogue win is nr cdev + 5, so print legend 317 /* print legend at the bottom line */
289 * at the bottom line 318 mvwprintw(w, rows - 2, 1,
290 */
291 mvwprintw(w, ptdata.nr_cooling_dev+3, 1,
292 "Legend: A=Active, P=Passive, C=Critical"); 319 "Legend: A=Active, P=Passive, C=Critical");
293 320
294 wrefresh(dialogue_window); 321 wrefresh(dialogue_window);
@@ -437,7 +464,7 @@ static void handle_input_choice(int ch)
437 snprintf(buf, sizeof(buf), "New Value for %.10s-%2d: ", 464 snprintf(buf, sizeof(buf), "New Value for %.10s-%2d: ",
438 ptdata.cdi[cdev_id].type, 465 ptdata.cdi[cdev_id].type,
439 ptdata.cdi[cdev_id].instance); 466 ptdata.cdi[cdev_id].instance);
440 write_dialogue_win(buf, DIAG_DEV_ROWS+2, 2); 467 write_dialogue_win(buf, diag_dev_rows() + 2, 2);
441 handle_input_val(cdev_id); 468 handle_input_val(cdev_id);
442 } else { 469 } else {
443 snprintf(buf, sizeof(buf), "Invalid selection %d", ch); 470 snprintf(buf, sizeof(buf), "Invalid selection %d", ch);