aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CREDITS5
-rw-r--r--Documentation/cgroups/memory.txt4
-rw-r--r--Documentation/devicetree/bindings/misc/atmel-ssc.txt15
-rw-r--r--Documentation/devicetree/bindings/net/mdio-gpio.txt9
-rw-r--r--Documentation/devicetree/bindings/sound/ak4104.txt22
-rw-r--r--Documentation/devicetree/bindings/sound/atmel-at91sam9g20ek-wm8731-audio.txt26
-rw-r--r--Documentation/devicetree/bindings/sound/cs4271.txt2
-rw-r--r--Documentation/devicetree/bindings/sound/omap-abe-twl6040.txt4
-rw-r--r--Documentation/filesystems/proc.txt16
-rw-r--r--Documentation/networking/netdev-features.txt2
-rw-r--r--Documentation/networking/vxlan.txt4
-rw-r--r--MAINTAINERS96
-rw-r--r--Makefile2
-rw-r--r--arch/alpha/kernel/osf_sys.c6
-rw-r--r--arch/arm/boot/Makefile10
-rw-r--r--arch/arm/boot/dts/at91sam9260.dtsi8
-rw-r--r--arch/arm/boot/dts/at91sam9263.dtsi16
-rw-r--r--arch/arm/boot/dts/at91sam9g20ek_common.dtsi32
-rw-r--r--arch/arm/boot/dts/at91sam9g45.dtsi16
-rw-r--r--arch/arm/boot/dts/at91sam9x5.dtsi8
-rw-r--r--arch/arm/boot/dts/tegra30.dtsi4
-rw-r--r--arch/arm/mach-at91/at91rm9200.c9
-rw-r--r--arch/arm/mach-at91/at91rm9200_devices.c8
-rw-r--r--arch/arm/mach-at91/at91sam9260.c3
-rw-r--r--arch/arm/mach-at91/at91sam9260_devices.c4
-rw-r--r--arch/arm/mach-at91/at91sam9261.c9
-rw-r--r--arch/arm/mach-at91/at91sam9261_devices.c8
-rw-r--r--arch/arm/mach-at91/at91sam9263.c6
-rw-r--r--arch/arm/mach-at91/at91sam9263_devices.c6
-rw-r--r--arch/arm/mach-at91/at91sam9g45.c6
-rw-r--r--arch/arm/mach-at91/at91sam9g45_devices.c16
-rw-r--r--arch/arm/mach-at91/at91sam9rl.c6
-rw-r--r--arch/arm/mach-at91/at91sam9rl_devices.c4
-rw-r--r--arch/arm/mach-at91/at91sam9x5.c1
-rw-r--r--arch/arm/mach-at91/board-sam9g20ek.c11
-rw-r--r--arch/arm/mach-davinci/board-da850-evm.c24
-rw-r--r--arch/arm/mach-davinci/dm644x.c3
-rw-r--r--arch/arm/mach-exynos/dma.c3
-rw-r--r--arch/arm/mach-exynos/include/mach/map.h1
-rw-r--r--arch/arm/mach-exynos/mach-armlex4210.c1
-rw-r--r--arch/arm/mach-exynos/mach-smdkv310.c1
-rw-r--r--arch/arm/mach-highbank/system.c3
-rw-r--r--arch/arm/mach-imx/clk-gate2.c2
-rw-r--r--arch/arm/mach-imx/ehci-imx25.c2
-rw-r--r--arch/arm/mach-imx/ehci-imx35.c2
-rw-r--r--arch/arm/mach-omap2/board-igep0020.c5
-rw-r--r--arch/arm/mach-omap2/clockdomains44xx_data.c2
-rw-r--r--arch/arm/mach-omap2/common-board-devices.c34
-rw-r--r--arch/arm/mach-omap2/devices.c79
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.c63
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_44xx_data.c36
-rw-r--r--arch/arm/mach-omap2/twl-common.c3
-rw-r--r--arch/arm/mach-omap2/vc.c2
-rw-r--r--arch/arm/mach-pxa/hx4700.c8
-rw-r--r--arch/arm/mach-pxa/spitz_pm.c8
-rw-r--r--arch/arm/mach-s3c24xx/mach-gta02.c1
-rw-r--r--arch/arm/mach-s3c24xx/mach-h1940.c1
-rw-r--r--arch/arm/mach-s3c24xx/mach-mini2440.c1
-rw-r--r--arch/arm/mach-s3c24xx/mach-rx1950.c1
-rw-r--r--arch/arm/mach-s3c64xx/mach-crag6410.c1
-rw-r--r--arch/arm/mach-s3c64xx/mach-smdk6410.c1
-rw-r--r--arch/arm/mach-s5p64x0/mach-smdk6440.c1
-rw-r--r--arch/arm/mach-s5p64x0/mach-smdk6450.c1
-rw-r--r--arch/arm/mach-s5pc100/mach-smdkc100.c1
-rw-r--r--arch/arm/mach-s5pv210/mach-smdkc110.c1
-rw-r--r--arch/arm/mach-s5pv210/mach-smdkv210.c1
-rw-r--r--arch/arm/plat-omap/i2c.c21
-rw-r--r--arch/arm/plat-omap/include/plat/omap_hwmod.h6
-rw-r--r--arch/arm/plat-samsung/devs.c9
-rw-r--r--arch/arm/plat-samsung/include/plat/devs.h1
-rw-r--r--arch/arm/tools/Makefile2
-rw-r--r--arch/arm64/include/asm/io.h2
-rw-r--r--arch/arm64/include/asm/pgtable-hwdef.h6
-rw-r--r--arch/arm64/include/asm/pgtable.h40
-rw-r--r--arch/ia64/mm/init.c1
-rw-r--r--arch/m68k/include/asm/signal.h6
-rw-r--r--arch/mips/cavium-octeon/executive/cvmx-l2c.c1
-rw-r--r--arch/mips/fw/arc/misc.c1
-rw-r--r--arch/mips/include/asm/bitops.h128
-rw-r--r--arch/mips/include/asm/compat.h2
-rw-r--r--arch/mips/include/asm/io.h1
-rw-r--r--arch/mips/include/asm/irqflags.h207
-rw-r--r--arch/mips/include/asm/thread_info.h6
-rw-r--r--arch/mips/kernel/setup.c26
-rw-r--r--arch/mips/lib/Makefile5
-rw-r--r--arch/mips/lib/bitops.c179
-rw-r--r--arch/mips/lib/mips-atomic.c176
-rw-r--r--arch/mips/mti-malta/malta-platform.c3
-rw-r--r--arch/parisc/kernel/signal32.c6
-rw-r--r--arch/parisc/kernel/sys_parisc.c2
-rw-r--r--arch/powerpc/boot/dts/mpc5200b.dtsi6
-rw-r--r--arch/powerpc/boot/dts/o2d.dtsi6
-rw-r--r--arch/powerpc/boot/dts/pcm030.dts7
-rw-r--r--arch/powerpc/platforms/52xx/mpc52xx_pic.c9
-rw-r--r--arch/powerpc/platforms/pseries/eeh_pe.c2
-rw-r--r--arch/powerpc/platforms/pseries/msi.c3
-rw-r--r--arch/s390/Kconfig1
-rw-r--r--arch/s390/include/asm/compat.h2
-rw-r--r--arch/s390/include/asm/topology.h3
-rw-r--r--arch/s390/include/uapi/asm/ptrace.h4
-rw-r--r--arch/s390/kernel/compat_signal.c14
-rw-r--r--arch/s390/kernel/signal.c14
-rw-r--r--arch/s390/kernel/topology.c6
-rw-r--r--arch/s390/mm/gup.c5
-rw-r--r--arch/sparc/include/asm/prom.h5
-rw-r--r--arch/sparc/kernel/signal_64.c4
-rw-r--r--arch/unicore32/Kconfig7
-rw-r--r--arch/unicore32/include/asm/Kbuild1
-rw-r--r--arch/unicore32/include/asm/bug.h5
-rw-r--r--arch/unicore32/include/asm/cmpxchg.h2
-rw-r--r--arch/unicore32/include/asm/kvm_para.h1
-rw-r--r--arch/unicore32/include/asm/processor.h5
-rw-r--r--arch/unicore32/include/asm/ptrace.h76
-rw-r--r--arch/unicore32/include/uapi/asm/Kbuild7
-rw-r--r--arch/unicore32/include/uapi/asm/byteorder.h (renamed from arch/unicore32/include/asm/byteorder.h)0
-rw-r--r--arch/unicore32/include/uapi/asm/ptrace.h90
-rw-r--r--arch/unicore32/include/uapi/asm/sigcontext.h (renamed from arch/unicore32/include/asm/sigcontext.h)0
-rw-r--r--arch/unicore32/include/uapi/asm/unistd.h (renamed from arch/unicore32/include/asm/unistd.h)1
-rw-r--r--arch/unicore32/kernel/entry.S20
-rw-r--r--arch/unicore32/kernel/process.c58
-rw-r--r--arch/unicore32/kernel/setup.h6
-rw-r--r--arch/unicore32/kernel/sys.c63
-rw-r--r--arch/unicore32/mm/fault.c37
-rw-r--r--arch/x86/boot/compressed/eboot.c2
-rw-r--r--arch/x86/boot/header.S3
-rw-r--r--arch/x86/include/asm/ptrace.h15
-rw-r--r--arch/x86/kernel/cpu/amd.c14
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce_amd.c2
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce_intel.c31
-rw-r--r--arch/x86/kernel/entry_64.S14
-rw-r--r--arch/x86/kernel/microcode_amd.c8
-rw-r--r--arch/x86/kernel/ptrace.c30
-rw-r--r--arch/x86/kvm/cpuid.h3
-rw-r--r--arch/x86/kvm/vmx.c11
-rw-r--r--arch/x86/kvm/x86.c3
-rw-r--r--arch/x86/mm/tlb.c2
-rw-r--r--arch/x86/pci/ce4100.c13
-rw-r--r--arch/x86/platform/ce4100/ce4100.c24
-rw-r--r--block/blk-exec.c8
-rw-r--r--drivers/ata/ahci_platform.c2
-rw-r--r--drivers/ata/libata-acpi.c11
-rw-r--r--drivers/ata/libata-core.c4
-rw-r--r--drivers/ata/libata-scsi.c2
-rw-r--r--drivers/ata/pata_arasan_cf.c8
-rw-r--r--drivers/ata/sata_highbank.c4
-rw-r--r--drivers/ata/sata_svw.c35
-rw-r--r--drivers/base/power/qos.c2
-rw-r--r--drivers/base/regmap/internal.h2
-rw-r--r--drivers/base/regmap/regmap-debugfs.c50
-rw-r--r--drivers/base/regmap/regmap.c154
-rw-r--r--drivers/block/aoe/aoecmd.c2
-rw-r--r--drivers/block/floppy.c5
-rw-r--r--drivers/block/mtip32xx/mtip32xx.c18
-rw-r--r--drivers/block/mtip32xx/mtip32xx.h6
-rw-r--r--drivers/bluetooth/ath3k.c1
-rw-r--r--drivers/bluetooth/btusb.c1
-rw-r--r--drivers/bus/omap-ocp2scp.c68
-rw-r--r--drivers/clk/ux500/u8500_clk.c50
-rw-r--r--drivers/edac/amd64_edac.h2
-rw-r--r--drivers/edac/edac_stub.c2
-rw-r--r--drivers/edac/mce_amd_inj.c4
-rw-r--r--drivers/firewire/sbp2.c2
-rw-r--r--drivers/gpio/Kconfig2
-rw-r--r--drivers/gpio/gpio-mcp23s08.c6
-rw-r--r--drivers/gpio/gpio-mvebu.c23
-rw-r--r--drivers/gpu/drm/i915/intel_crt.c2
-rw-r--r--drivers/gpu/drm/i915/intel_display.c11
-rw-r--r--drivers/gpu/drm/i915/intel_sdvo.c22
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/disp/nv50.c19
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/ctxnv40.c12
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/nv40.c4
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/nv40.h2
-rw-r--r--drivers/gpu/drm/nouveau/core/include/core/object.h14
-rw-r--r--drivers/gpu/drm/nouveau/core/include/subdev/clock.h3
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c2
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/clock/nva3.c19
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/clock/nvc0.c1
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_abi16.c4
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drm.c3
-rw-r--r--drivers/gpu/drm/radeon/atombios_encoders.c2
-rw-r--r--drivers/gpu/drm/radeon/evergreen.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_agp.c5
-rw-r--r--drivers/gpu/drm/ttm/ttm_page_alloc.c5
-rw-r--r--drivers/gpu/drm/ttm/ttm_tt.c4
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c2
-rw-r--r--drivers/hid/hid-microsoft.c6
-rw-r--r--drivers/i2c/busses/i2c-at91.c7
-rw-r--r--drivers/i2c/busses/i2c-mxs.c2
-rw-r--r--drivers/i2c/busses/i2c-omap.c36
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c1
-rw-r--r--drivers/i2c/muxes/i2c-mux-pinctrl.c2
-rw-r--r--drivers/input/input-mt.c4
-rw-r--r--drivers/input/misc/Kconfig10
-rw-r--r--drivers/input/misc/Makefile1
-rw-r--r--drivers/input/misc/arizona-haptics.c255
-rw-r--r--drivers/input/mousedev.c4
-rw-r--r--drivers/input/touchscreen/ads7846.c6
-rw-r--r--drivers/iommu/intel-iommu.c4
-rw-r--r--drivers/iommu/tegra-smmu.c1
-rw-r--r--drivers/irqchip/irq-bcm2835.c3
-rw-r--r--drivers/leds/ledtrig-cpu.c21
-rw-r--r--drivers/md/dm.c8
-rw-r--r--drivers/md/md.c27
-rw-r--r--drivers/md/raid10.c131
-rw-r--r--drivers/md/raid5.c79
-rw-r--r--drivers/mfd/arizona-core.c2
-rw-r--r--drivers/misc/atmel-ssc.c135
-rw-r--r--drivers/mtd/devices/slram.c2
-rw-r--r--drivers/mtd/nand/nand_base.c10
-rw-r--r--drivers/mtd/ofpart.c2
-rw-r--r--drivers/mtd/onenand/onenand_base.c2
-rw-r--r--drivers/net/bonding/bond_main.c7
-rw-r--r--drivers/net/ethernet/8390/ne.c1
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c11
-rw-r--r--drivers/net/ethernet/jme.c28
-rw-r--r--drivers/net/ethernet/micrel/ksz884x.c16
-rw-r--r--drivers/net/ethernet/realtek/8139cp.c22
-rw-r--r--drivers/net/ethernet/sis/sis900.c2
-rw-r--r--drivers/net/ethernet/smsc/smsc911x.c17
-rw-r--r--drivers/net/ethernet/tile/tilegx.c2
-rw-r--r--drivers/net/ethernet/xilinx/xilinx_axienet_main.c14
-rw-r--r--drivers/net/ethernet/xscale/ixp4xx_eth.c8
-rw-r--r--drivers/net/irda/sir_dev.c2
-rw-r--r--drivers/net/phy/mdio-bitbang.c1
-rw-r--r--drivers/net/phy/mdio-gpio.c11
-rw-r--r--drivers/net/team/team_mode_broadcast.c6
-rw-r--r--drivers/net/usb/cdc_ncm.c22
-rw-r--r--drivers/net/usb/smsc95xx.c4
-rw-r--r--drivers/net/vxlan.c10
-rw-r--r--drivers/net/wan/ixp4xx_hss.c8
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c2
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c2
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/mac80211.c16
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/main.c2
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/rx.c23
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/tx.c8
-rw-r--r--drivers/net/wireless/mwifiex/cmdevt.c11
-rw-r--r--drivers/net/wireless/mwifiex/sdio.c11
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/sw.c1
-rw-r--r--drivers/net/xen-netfront.c98
-rw-r--r--drivers/nfc/pn533.c25
-rw-r--r--drivers/pinctrl/Kconfig2
-rw-r--r--drivers/rapidio/rio.c2
-rw-r--r--drivers/regulator/core.c33
-rw-r--r--drivers/s390/char/con3215.c12
-rw-r--r--drivers/s390/net/qeth_core_main.c24
-rw-r--r--drivers/s390/net/qeth_l2_main.c13
-rw-r--r--drivers/scsi/isci/request.c2
-rw-r--r--drivers/scsi/scsi.c45
-rw-r--r--drivers/scsi/scsi_lib.c22
-rw-r--r--drivers/scsi/sd.c202
-rw-r--r--drivers/scsi/sd.h7
-rw-r--r--drivers/staging/android/android_alarm.h4
-rw-r--r--drivers/tty/hvc/hvc_console.c7
-rw-r--r--drivers/tty/serial/max310x.c1
-rw-r--r--drivers/usb/core/hcd.c16
-rw-r--r--drivers/usb/early/ehci-dbgp.c15
-rw-r--r--drivers/usb/host/ehci-ls1x.c2
-rw-r--r--drivers/usb/host/ohci-xls.c2
-rw-r--r--drivers/usb/musb/musb_gadget.c30
-rw-r--r--drivers/usb/musb/ux500.c2
-rw-r--r--drivers/usb/otg/Kconfig4
-rw-r--r--drivers/usb/serial/keyspan.c3
-rw-r--r--drivers/usb/serial/option.c9
-rw-r--r--drivers/usb/serial/usb_wwan.c10
-rw-r--r--drivers/usb/storage/scsiglue.c6
-rw-r--r--drivers/video/omap2/dss/dsi.c13
-rw-r--r--drivers/video/omap2/dss/dss.c18
-rw-r--r--drivers/video/omap2/dss/hdmi.c4
-rw-r--r--drivers/video/omap2/omapfb/omapfb-ioctl.c2
-rw-r--r--drivers/xen/privcmd.c18
-rw-r--r--fs/ext3/balloc.c5
-rw-r--r--fs/file.c1
-rw-r--r--fs/jffs2/file.c39
-rw-r--r--fs/notify/fanotify/fanotify_user.c3
-rw-r--r--fs/proc/base.c109
-rw-r--r--fs/pstore/platform.c3
-rw-r--r--fs/reiserfs/inode.c10
-rw-r--r--fs/reiserfs/stree.c4
-rw-r--r--fs/reiserfs/super.c60
-rw-r--r--fs/ubifs/find.c12
-rw-r--r--fs/ubifs/lprops.c6
-rw-r--r--fs/ubifs/ubifs.h3
-rw-r--r--fs/xfs/xfs_aops.c54
-rw-r--r--fs/xfs/xfs_attr_leaf.c20
-rw-r--r--fs/xfs/xfs_buf.c14
-rw-r--r--include/drm/drm_pciids.h1
-rw-r--r--include/linux/atmel-ssc.h6
-rw-r--r--include/linux/clk-provider.h4
-rw-r--r--include/linux/i2c-omap.h1
-rw-r--r--include/linux/mfd/arizona/core.h4
-rw-r--r--include/linux/mfd/arizona/pdata.h6
-rw-r--r--include/linux/mm.h4
-rw-r--r--include/linux/mmzone.h2
-rw-r--r--include/linux/of_address.h2
-rw-r--r--include/linux/platform_data/asoc-s3c.h6
-rw-r--r--include/linux/platform_data/davinci_asp.h4
-rw-r--r--include/linux/platform_data/omap-twl4030.h26
-rw-r--r--include/linux/platform_data/omap_ocp2scp.h31
-rw-r--r--include/linux/regmap.h6
-rw-r--r--include/linux/rio.h2
-rw-r--r--include/linux/spi/ads7846.h5
-rw-r--r--include/net/xfrm.h2
-rw-r--r--include/scsi/scsi_device.h4
-rw-r--r--include/sound/cs4271.h1
-rw-r--r--include/sound/sh_fsi.h6
-rw-r--r--include/sound/tlv320aic32x4.h1
-rw-r--r--include/uapi/linux/oom.h9
-rw-r--r--kernel/futex.c41
-rw-r--r--lib/mpi/longlong.h19
-rw-r--r--mm/bootmem.c10
-rw-r--r--mm/highmem.c2
-rw-r--r--mm/memcontrol.c67
-rw-r--r--mm/memory.c10
-rw-r--r--mm/memory_hotplug.c7
-rw-r--r--mm/mmap.c2
-rw-r--r--mm/mmzone.c6
-rw-r--r--mm/nobootmem.c3
-rw-r--r--mm/page_alloc.c38
-rw-r--r--mm/shmem.c18
-rw-r--r--mm/swapfile.c4
-rw-r--r--mm/vmscan.c25
-rw-r--r--net/batman-adv/soft-interface.c12
-rw-r--r--net/batman-adv/translation-table.c15
-rw-r--r--net/bluetooth/hci_core.c4
-rw-r--r--net/bluetooth/mgmt.c12
-rw-r--r--net/bluetooth/smp.c2
-rw-r--r--net/core/dev.c4
-rw-r--r--net/core/dev_addr_lists.c3
-rw-r--r--net/core/net-sysfs.c20
-rw-r--r--net/ipv4/ip_sockglue.c35
-rw-r--r--net/ipv4/ip_vti.c5
-rw-r--r--net/ipv4/route.c9
-rw-r--r--net/ipv4/tcp.c4
-rw-r--r--net/ipv4/tcp_input.c15
-rw-r--r--net/ipv4/tcp_metrics.c12
-rw-r--r--net/ipv4/tcp_output.c4
-rw-r--r--net/ipv4/xfrm4_policy.c13
-rw-r--r--net/ipv6/inet6_connection_sock.c3
-rw-r--r--net/ipv6/ipv6_sockglue.c1
-rw-r--r--net/mac80211/cfg.c3
-rw-r--r--net/mac80211/ibss.c8
-rw-r--r--net/mac80211/ieee80211_i.h2
-rw-r--r--net/mac80211/main.c6
-rw-r--r--net/mac80211/scan.c2
-rw-r--r--net/mac80211/sta_info.c11
-rw-r--r--net/mac80211/status.c9
-rw-r--r--net/mac80211/tx.c9
-rw-r--r--net/mac80211/util.c2
-rw-r--r--net/netfilter/ipset/ip_set_hash_ip.c4
-rw-r--r--net/netfilter/ipset/ip_set_hash_ipport.c7
-rw-r--r--net/netfilter/ipset/ip_set_hash_ipportip.c7
-rw-r--r--net/netfilter/ipset/ip_set_hash_ipportnet.c7
-rw-r--r--net/netfilter/nfnetlink_cttimeout.c3
-rw-r--r--net/nfc/llcp/llcp.c2
-rw-r--r--net/sctp/proc.c8
-rw-r--r--net/wireless/reg.c5
-rw-r--r--scripts/kconfig/expr.h5
-rw-r--r--scripts/kconfig/list.h91
-rw-r--r--scripts/kconfig/lkc_proto.h4
-rw-r--r--scripts/kconfig/mconf.c6
-rw-r--r--scripts/kconfig/menu.c14
-rwxr-xr-xscripts/sign-file6
-rw-r--r--security/device_cgroup.c18
-rw-r--r--security/selinux/netnode.c3
-rw-r--r--sound/pci/es1968.c11
-rw-r--r--sound/pci/fm801.c11
-rw-r--r--sound/pci/hda/hda_codec.c13
-rw-r--r--sound/pci/hda/hda_codec.h1
-rw-r--r--sound/pci/hda/hda_intel.c39
-rw-r--r--sound/pci/hda/patch_cirrus.c1
-rw-r--r--sound/pci/hda/patch_realtek.c2
-rw-r--r--sound/soc/atmel/Kconfig13
-rw-r--r--sound/soc/atmel/Makefile4
-rw-r--r--sound/soc/atmel/atmel-pcm-dma.c240
-rw-r--r--sound/soc/atmel/atmel-pcm-pdc.c401
-rw-r--r--sound/soc/atmel/atmel-pcm.c401
-rw-r--r--sound/soc/atmel/atmel-pcm.h34
-rw-r--r--sound/soc/atmel/atmel_ssc_dai.c168
-rw-r--r--sound/soc/atmel/atmel_ssc_dai.h3
-rw-r--r--sound/soc/atmel/sam9g20_wm8731.c116
-rw-r--r--sound/soc/codecs/Kconfig16
-rw-r--r--sound/soc/codecs/Makefile6
-rw-r--r--sound/soc/codecs/ab8500-codec.c2
-rw-r--r--sound/soc/codecs/ak4104.c65
-rw-r--r--sound/soc/codecs/ak4535.c7
-rw-r--r--sound/soc/codecs/ak4642.c23
-rw-r--r--sound/soc/codecs/arizona.c57
-rw-r--r--sound/soc/codecs/arizona.h71
-rw-r--r--sound/soc/codecs/cs4271.c32
-rw-r--r--sound/soc/codecs/cs42l52.c3
-rw-r--r--sound/soc/codecs/da7210.c24
-rw-r--r--sound/soc/codecs/da9055.c43
-rw-r--r--sound/soc/codecs/jz4740.c142
-rw-r--r--sound/soc/codecs/lm49453.c10
-rw-r--r--sound/soc/codecs/max9768.c7
-rw-r--r--sound/soc/codecs/max98088.c14
-rw-r--r--sound/soc/codecs/max98090.c577
-rw-r--r--sound/soc/codecs/rt5631.c2
-rw-r--r--sound/soc/codecs/si476x.c255
-rw-r--r--sound/soc/codecs/tlv320aic32x4.c24
-rw-r--r--sound/soc/codecs/tlv320aic32x4.h3
-rw-r--r--sound/soc/codecs/wm0010.c419
-rw-r--r--sound/soc/codecs/wm2000.c2
-rw-r--r--sound/soc/codecs/wm2200.c269
-rw-r--r--sound/soc/codecs/wm5100.c2
-rw-r--r--sound/soc/codecs/wm5102.c690
-rw-r--r--sound/soc/codecs/wm5110.c69
-rw-r--r--sound/soc/codecs/wm8350.c4
-rw-r--r--sound/soc/codecs/wm8400.c14
-rw-r--r--sound/soc/codecs/wm8510.c3
-rw-r--r--sound/soc/codecs/wm8741.c4
-rw-r--r--sound/soc/codecs/wm8750.c86
-rw-r--r--sound/soc/codecs/wm8753.c33
-rw-r--r--sound/soc/codecs/wm8770.c217
-rw-r--r--sound/soc/codecs/wm8804.c17
-rw-r--r--sound/soc/codecs/wm8955.c11
-rw-r--r--sound/soc/codecs/wm8960.c2
-rw-r--r--sound/soc/codecs/wm8962.c24
-rw-r--r--sound/soc/codecs/wm8971.c80
-rw-r--r--sound/soc/codecs/wm8978.c2
-rw-r--r--sound/soc/codecs/wm_adsp.c699
-rw-r--r--sound/soc/codecs/wm_adsp.h59
-rw-r--r--sound/soc/codecs/wmfw.h128
-rw-r--r--sound/soc/davinci/davinci-evm.c5
-rw-r--r--sound/soc/davinci/davinci-mcasp.c152
-rw-r--r--sound/soc/davinci/davinci-mcasp.h15
-rw-r--r--sound/soc/davinci/davinci-pcm.c53
-rw-r--r--sound/soc/davinci/davinci-pcm.h2
-rw-r--r--sound/soc/fsl/Kconfig20
-rw-r--r--sound/soc/fsl/Makefile14
-rw-r--r--sound/soc/fsl/imx-pcm.c4
-rw-r--r--sound/soc/fsl/imx-sgtl5000.c1
-rw-r--r--sound/soc/fsl/p1022_rdk.c392
-rw-r--r--sound/soc/fsl/pcm030-audio-fabric.c4
-rw-r--r--sound/soc/kirkwood/kirkwood-dma.c19
-rw-r--r--sound/soc/kirkwood/kirkwood-i2s.c291
-rw-r--r--sound/soc/kirkwood/kirkwood.h11
-rw-r--r--sound/soc/mxs/mxs-saif.c19
-rw-r--r--sound/soc/omap/mcbsp.c4
-rw-r--r--sound/soc/omap/mcbsp.h6
-rw-r--r--sound/soc/omap/omap-abe-twl6040.c4
-rw-r--r--sound/soc/omap/omap-mcbsp.c5
-rw-r--r--sound/soc/omap/zoom2.c7
-rw-r--r--sound/soc/samsung/Kconfig2
-rw-r--r--sound/soc/samsung/ac97.c16
-rw-r--r--sound/soc/samsung/bells.c224
-rw-r--r--sound/soc/samsung/dma.c24
-rw-r--r--sound/soc/samsung/dma.h3
-rw-r--r--sound/soc/samsung/goni_wm8994.c2
-rw-r--r--sound/soc/samsung/h1940_uda1380.c2
-rw-r--r--sound/soc/samsung/i2s.c24
-rw-r--r--sound/soc/samsung/jive_wm8750.c2
-rw-r--r--sound/soc/samsung/littlemill.c2
-rw-r--r--sound/soc/samsung/ln2440sbc_alc650.c2
-rw-r--r--sound/soc/samsung/lowland.c2
-rw-r--r--sound/soc/samsung/neo1973_wm8753.c2
-rw-r--r--sound/soc/samsung/pcm.c21
-rw-r--r--sound/soc/samsung/rx1950_uda1380.c2
-rw-r--r--sound/soc/samsung/s3c2412-i2s.c20
-rw-r--r--sound/soc/samsung/s3c24xx-i2s.c20
-rw-r--r--sound/soc/samsung/s3c24xx_simtec_hermes.c2
-rw-r--r--sound/soc/samsung/s3c24xx_simtec_tlv320aic23.c2
-rw-r--r--sound/soc/samsung/s3c24xx_uda134x.c2
-rw-r--r--sound/soc/samsung/smartq_wm8987.c2
-rw-r--r--sound/soc/samsung/smdk2443_wm9710.c2
-rw-r--r--sound/soc/samsung/smdk_spdif.c2
-rw-r--r--sound/soc/samsung/smdk_wm8580.c6
-rw-r--r--sound/soc/samsung/smdk_wm8580pcm.c2
-rw-r--r--sound/soc/samsung/smdk_wm8994.c4
-rw-r--r--sound/soc/samsung/smdk_wm8994pcm.c2
-rw-r--r--sound/soc/samsung/smdk_wm9713.c2
-rw-r--r--sound/soc/samsung/spdif.c22
-rw-r--r--sound/soc/samsung/speyside.c2
-rw-r--r--sound/soc/samsung/tobermory.c2
-rw-r--r--sound/soc/sh/fsi.c550
-rw-r--r--sound/soc/soc-cache.c10
-rw-r--r--sound/soc/soc-core.c248
-rw-r--r--sound/soc/soc-dapm.c136
-rw-r--r--sound/soc/soc-dmaengine-pcm.c2
-rw-r--r--sound/soc/soc-jack.c16
-rw-r--r--sound/soc/soc-pcm.c195
-rw-r--r--sound/soc/tegra/tegra20_das.c2
-rw-r--r--sound/soc/tegra/tegra20_i2s.c4
-rw-r--r--sound/soc/tegra/tegra20_spdif.c2
-rw-r--r--sound/soc/tegra/tegra30_ahub.c6
-rw-r--r--sound/soc/tegra/tegra30_i2s.c4
-rw-r--r--sound/soc/tegra/tegra_alc5632.c2
-rw-r--r--sound/soc/tegra/tegra_wm8753.c2
-rw-r--r--sound/soc/tegra/tegra_wm8903.c2
-rw-r--r--sound/soc/tegra/trimslice.c2
-rw-r--r--sound/soc/ux500/mop500.c4
-rw-r--r--sound/soc/ux500/ux500_msp_dai.c55
-rw-r--r--sound/soc/ux500/ux500_msp_dai.h1
-rw-r--r--sound/soc/ux500/ux500_pcm.c19
-rw-r--r--sound/soc/ux500/ux500_pcm.h3
-rw-r--r--sound/usb/card.c6
-rw-r--r--sound/usb/midi.c8
-rw-r--r--sound/usb/pcm.c2
-rw-r--r--tools/power/x86/turbostat/turbostat.c28
500 files changed, 10392 insertions, 3660 deletions
diff --git a/CREDITS b/CREDITS
index d8fe12a9421f..2346b09ca8bb 100644
--- a/CREDITS
+++ b/CREDITS
@@ -1823,6 +1823,11 @@ S: Kattreinstr 38
1823S: D-64295 1823S: D-64295
1824S: Germany 1824S: Germany
1825 1825
1826N: Avi Kivity
1827E: avi.kivity@gmail.com
1828D: Kernel-based Virtual Machine (KVM)
1829S: Ra'annana, Israel
1830
1826N: Andi Kleen 1831N: Andi Kleen
1827E: andi@firstfloor.org 1832E: andi@firstfloor.org
1828U: http://www.halobates.de 1833U: http://www.halobates.de
diff --git a/Documentation/cgroups/memory.txt b/Documentation/cgroups/memory.txt
index c07f7b4fb88d..71c4da413444 100644
--- a/Documentation/cgroups/memory.txt
+++ b/Documentation/cgroups/memory.txt
@@ -466,6 +466,10 @@ Note:
4665.3 swappiness 4665.3 swappiness
467 467
468Similar to /proc/sys/vm/swappiness, but affecting a hierarchy of groups only. 468Similar to /proc/sys/vm/swappiness, but affecting a hierarchy of groups only.
469Please note that unlike the global swappiness, memcg knob set to 0
470really prevents from any swapping even if there is a swap storage
471available. This might lead to memcg OOM killer if there are no file
472pages to reclaim.
469 473
470Following cgroups' swappiness can't be changed. 474Following cgroups' swappiness can't be changed.
471- root cgroup (uses /proc/sys/vm/swappiness). 475- root cgroup (uses /proc/sys/vm/swappiness).
diff --git a/Documentation/devicetree/bindings/misc/atmel-ssc.txt b/Documentation/devicetree/bindings/misc/atmel-ssc.txt
new file mode 100644
index 000000000000..38e51ad2e07e
--- /dev/null
+++ b/Documentation/devicetree/bindings/misc/atmel-ssc.txt
@@ -0,0 +1,15 @@
1* Atmel SSC driver.
2
3Required properties:
4- compatible: "atmel,at91rm9200-ssc" or "atmel,at91sam9g45-ssc"
5 - atmel,at91rm9200-ssc: support pdc transfer
6 - atmel,at91sam9g45-ssc: support dma transfer
7- reg: Should contain SSC registers location and length
8- interrupts: Should contain SSC interrupt
9
10Example:
11ssc0: ssc@fffbc000 {
12 compatible = "atmel,at91rm9200-ssc";
13 reg = <0xfffbc000 0x4000>;
14 interrupts = <14 4 5>;
15};
diff --git a/Documentation/devicetree/bindings/net/mdio-gpio.txt b/Documentation/devicetree/bindings/net/mdio-gpio.txt
index bc9549529014..c79bab025369 100644
--- a/Documentation/devicetree/bindings/net/mdio-gpio.txt
+++ b/Documentation/devicetree/bindings/net/mdio-gpio.txt
@@ -8,9 +8,16 @@ gpios property as described in section VIII.1 in the following order:
8 8
9MDC, MDIO. 9MDC, MDIO.
10 10
11Note: Each gpio-mdio bus should have an alias correctly numbered in "aliases"
12node.
13
11Example: 14Example:
12 15
13mdio { 16aliases {
17 mdio-gpio0 = <&mdio0>;
18};
19
20mdio0: mdio {
14 compatible = "virtual,mdio-gpio"; 21 compatible = "virtual,mdio-gpio";
15 #address-cells = <1>; 22 #address-cells = <1>;
16 #size-cells = <0>; 23 #size-cells = <0>;
diff --git a/Documentation/devicetree/bindings/sound/ak4104.txt b/Documentation/devicetree/bindings/sound/ak4104.txt
new file mode 100644
index 000000000000..b902ee39cf89
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/ak4104.txt
@@ -0,0 +1,22 @@
1AK4104 S/PDIF transmitter
2
3This device supports SPI mode only.
4
5Required properties:
6
7 - compatible : "asahi-kasei,ak4104"
8
9 - reg : The chip select number on the SPI bus
10
11Optional properties:
12
13 - reset-gpio : a GPIO spec for the reset pin. If specified, it will be
14 deasserted before communication to the device starts.
15
16Example:
17
18spdif: ak4104@0 {
19 compatible = "asahi-kasei,ak4104";
20 reg = <0>;
21 spi-max-frequency = <5000000>;
22};
diff --git a/Documentation/devicetree/bindings/sound/atmel-at91sam9g20ek-wm8731-audio.txt b/Documentation/devicetree/bindings/sound/atmel-at91sam9g20ek-wm8731-audio.txt
new file mode 100644
index 000000000000..9c5a9947b64d
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/atmel-at91sam9g20ek-wm8731-audio.txt
@@ -0,0 +1,26 @@
1* Atmel at91sam9g20ek wm8731 audio complex
2
3Required properties:
4 - compatible: "atmel,at91sam9g20ek-wm8731-audio"
5 - atmel,model: The user-visible name of this sound complex.
6 - atmel,audio-routing: A list of the connections between audio components.
7 - atmel,ssc-controller: The phandle of the SSC controller
8 - atmel,audio-codec: The phandle of the WM8731 audio codec
9Optional properties:
10 - pinctrl-names, pinctrl-0: Please refer to pinctrl-bindings.txt
11
12Example:
13sound {
14 compatible = "atmel,at91sam9g20ek-wm8731-audio";
15 pinctrl-names = "default";
16 pinctrl-0 = <&pinctrl_pck0_as_mck>;
17
18 atmel,model = "wm8731 @ AT91SAMG20EK";
19
20 atmel,audio-routing =
21 "Ext Spk", "LHPOUT",
22 "Int MIC", "MICIN";
23
24 atmel,ssc-controller = <&ssc0>;
25 atmel,audio-codec = <&wm8731>;
26};
diff --git a/Documentation/devicetree/bindings/sound/cs4271.txt b/Documentation/devicetree/bindings/sound/cs4271.txt
index c81b5fd5a5bc..a850fb9c88ea 100644
--- a/Documentation/devicetree/bindings/sound/cs4271.txt
+++ b/Documentation/devicetree/bindings/sound/cs4271.txt
@@ -18,6 +18,8 @@ Optional properties:
18 18
19 - reset-gpio: a GPIO spec to define which pin is connected to the chip's 19 - reset-gpio: a GPIO spec to define which pin is connected to the chip's
20 !RESET pin 20 !RESET pin
21 - cirrus,amuteb-eq-bmutec: When given, the Codec's AMUTEB=BMUTEC flag
22 is enabled.
21 23
22Examples: 24Examples:
23 25
diff --git a/Documentation/devicetree/bindings/sound/omap-abe-twl6040.txt b/Documentation/devicetree/bindings/sound/omap-abe-twl6040.txt
index 65dec876cb2d..fd40c852d7c7 100644
--- a/Documentation/devicetree/bindings/sound/omap-abe-twl6040.txt
+++ b/Documentation/devicetree/bindings/sound/omap-abe-twl6040.txt
@@ -12,7 +12,7 @@ Required properties:
12 12
13Optional properties: 13Optional properties:
14- ti,dmic: phandle for the OMAP dmic node if the machine have it connected 14- ti,dmic: phandle for the OMAP dmic node if the machine have it connected
15- ti,jack_detection: Need to be set to <1> if the board capable to detect jack 15- ti,jack_detection: Need to be present if the board capable to detect jack
16 insertion, removal. 16 insertion, removal.
17 17
18Available audio endpoints for the audio-routing table: 18Available audio endpoints for the audio-routing table:
@@ -59,7 +59,7 @@ sound {
59 compatible = "ti,abe-twl6040"; 59 compatible = "ti,abe-twl6040";
60 ti,model = "SDP4430"; 60 ti,model = "SDP4430";
61 61
62 ti,jack-detection = <1>; 62 ti,jack-detection;
63 ti,mclk-freq = <38400000>; 63 ti,mclk-freq = <38400000>;
64 64
65 ti,mcpdm = <&mcpdm>; 65 ti,mcpdm = <&mcpdm>;
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
index a1793d670cd0..3844d21d6ca3 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -33,7 +33,7 @@ Table of Contents
33 2 Modifying System Parameters 33 2 Modifying System Parameters
34 34
35 3 Per-Process Parameters 35 3 Per-Process Parameters
36 3.1 /proc/<pid>/oom_score_adj - Adjust the oom-killer 36 3.1 /proc/<pid>/oom_adj & /proc/<pid>/oom_score_adj - Adjust the oom-killer
37 score 37 score
38 3.2 /proc/<pid>/oom_score - Display current oom-killer score 38 3.2 /proc/<pid>/oom_score - Display current oom-killer score
39 3.3 /proc/<pid>/io - Display the IO accounting fields 39 3.3 /proc/<pid>/io - Display the IO accounting fields
@@ -1320,10 +1320,10 @@ of the kernel.
1320CHAPTER 3: PER-PROCESS PARAMETERS 1320CHAPTER 3: PER-PROCESS PARAMETERS
1321------------------------------------------------------------------------------ 1321------------------------------------------------------------------------------
1322 1322
13233.1 /proc/<pid>/oom_score_adj- Adjust the oom-killer score 13233.1 /proc/<pid>/oom_adj & /proc/<pid>/oom_score_adj- Adjust the oom-killer score
1324-------------------------------------------------------------------------------- 1324--------------------------------------------------------------------------------
1325 1325
1326This file can be used to adjust the badness heuristic used to select which 1326These file can be used to adjust the badness heuristic used to select which
1327process gets killed in out of memory conditions. 1327process gets killed in out of memory conditions.
1328 1328
1329The badness heuristic assigns a value to each candidate task ranging from 0 1329The badness heuristic assigns a value to each candidate task ranging from 0
@@ -1361,6 +1361,12 @@ same system, cpuset, mempolicy, or memory controller resources to use at least
1361equivalent to discounting 50% of the task's allowed memory from being considered 1361equivalent to discounting 50% of the task's allowed memory from being considered
1362as scoring against the task. 1362as scoring against the task.
1363 1363
1364For backwards compatibility with previous kernels, /proc/<pid>/oom_adj may also
1365be used to tune the badness score. Its acceptable values range from -16
1366(OOM_ADJUST_MIN) to +15 (OOM_ADJUST_MAX) and a special value of -17
1367(OOM_DISABLE) to disable oom killing entirely for that task. Its value is
1368scaled linearly with /proc/<pid>/oom_score_adj.
1369
1364The value of /proc/<pid>/oom_score_adj may be reduced no lower than the last 1370The value of /proc/<pid>/oom_score_adj may be reduced no lower than the last
1365value set by a CAP_SYS_RESOURCE process. To reduce the value any lower 1371value set by a CAP_SYS_RESOURCE process. To reduce the value any lower
1366requires CAP_SYS_RESOURCE. 1372requires CAP_SYS_RESOURCE.
@@ -1375,7 +1381,9 @@ minimal amount of work.
1375------------------------------------------------------------- 1381-------------------------------------------------------------
1376 1382
1377This file can be used to check the current score used by the oom-killer is for 1383This file can be used to check the current score used by the oom-killer is for
1378any given <pid>. 1384any given <pid>. Use it together with /proc/<pid>/oom_score_adj to tune which
1385process should be killed in an out-of-memory situation.
1386
1379 1387
13803.3 /proc/<pid>/io - Display the IO accounting fields 13883.3 /proc/<pid>/io - Display the IO accounting fields
1381------------------------------------------------------- 1389-------------------------------------------------------
diff --git a/Documentation/networking/netdev-features.txt b/Documentation/networking/netdev-features.txt
index 4164f5c02e4b..f310edec8a77 100644
--- a/Documentation/networking/netdev-features.txt
+++ b/Documentation/networking/netdev-features.txt
@@ -164,4 +164,4 @@ read the CRC recorded by the NIC on receipt of the packet.
164This requests that the NIC receive all possible frames, including errored 164This requests that the NIC receive all possible frames, including errored
165frames (such as bad FCS, etc). This can be helpful when sniffing a link with 165frames (such as bad FCS, etc). This can be helpful when sniffing a link with
166bad packets on it. Some NICs may receive more packets if also put into normal 166bad packets on it. Some NICs may receive more packets if also put into normal
167PROMISC mdoe. 167PROMISC mode.
diff --git a/Documentation/networking/vxlan.txt b/Documentation/networking/vxlan.txt
index 5b34b762d7d5..6d993510f091 100644
--- a/Documentation/networking/vxlan.txt
+++ b/Documentation/networking/vxlan.txt
@@ -32,7 +32,7 @@ no entry is in the forwarding table.
32 # ip link delete vxlan0 32 # ip link delete vxlan0
33 33
343. Show vxlan info 343. Show vxlan info
35 # ip -d show vxlan0 35 # ip -d link show vxlan0
36 36
37It is possible to create, destroy and display the vxlan 37It is possible to create, destroy and display the vxlan
38forwarding table using the new bridge command. 38forwarding table using the new bridge command.
@@ -41,7 +41,7 @@ forwarding table using the new bridge command.
41 # bridge fdb add to 00:17:42:8a:b4:05 dst 192.19.0.2 dev vxlan0 41 # bridge fdb add to 00:17:42:8a:b4:05 dst 192.19.0.2 dev vxlan0
42 42
432. Delete forwarding table entry 432. Delete forwarding table entry
44 # bridge fdb delete 00:17:42:8a:b4:05 44 # bridge fdb delete 00:17:42:8a:b4:05 dev vxlan0
45 45
463. Show forwarding table 463. Show forwarding table
47 # bridge fdb show dev vxlan0 47 # bridge fdb show dev vxlan0
diff --git a/MAINTAINERS b/MAINTAINERS
index 59203e77ce9e..9386a63ea8f6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -526,17 +526,17 @@ F: drivers/video/geode/
526F: arch/x86/include/asm/geode.h 526F: arch/x86/include/asm/geode.h
527 527
528AMD IOMMU (AMD-VI) 528AMD IOMMU (AMD-VI)
529M: Joerg Roedel <joerg.roedel@amd.com> 529M: Joerg Roedel <joro@8bytes.org>
530L: iommu@lists.linux-foundation.org 530L: iommu@lists.linux-foundation.org
531T: git git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git 531T: git git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git
532S: Supported 532S: Maintained
533F: drivers/iommu/amd_iommu*.[ch] 533F: drivers/iommu/amd_iommu*.[ch]
534F: include/linux/amd-iommu.h 534F: include/linux/amd-iommu.h
535 535
536AMD MICROCODE UPDATE SUPPORT 536AMD MICROCODE UPDATE SUPPORT
537M: Andreas Herrmann <andreas.herrmann3@amd.com> 537M: Andreas Herrmann <herrmann.der.user@googlemail.com>
538L: amd64-microcode@amd64.org 538L: amd64-microcode@amd64.org
539S: Supported 539S: Maintained
540F: arch/x86/kernel/microcode_amd.c 540F: arch/x86/kernel/microcode_amd.c
541 541
542AMS (Apple Motion Sensor) DRIVER 542AMS (Apple Motion Sensor) DRIVER
@@ -841,6 +841,14 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/kristoffer/linux-hpc.git
841F: arch/arm/mach-sa1100/jornada720.c 841F: arch/arm/mach-sa1100/jornada720.c
842F: arch/arm/mach-sa1100/include/mach/jornada720.h 842F: arch/arm/mach-sa1100/include/mach/jornada720.h
843 843
844ARM/IGEP MACHINE SUPPORT
845M: Enric Balletbo i Serra <eballetbo@gmail.com>
846M: Javier Martinez Canillas <javier@dowhile0.org>
847L: linux-omap@vger.kernel.org
848L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
849S: Maintained
850F: arch/arm/mach-omap2/board-igep0020.c
851
844ARM/INCOME PXA270 SUPPORT 852ARM/INCOME PXA270 SUPPORT
845M: Marek Vasut <marek.vasut@gmail.com> 853M: Marek Vasut <marek.vasut@gmail.com>
846L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 854L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
@@ -2708,10 +2716,10 @@ F: include/linux/edac.h
2708 2716
2709EDAC-AMD64 2717EDAC-AMD64
2710M: Doug Thompson <dougthompson@xmission.com> 2718M: Doug Thompson <dougthompson@xmission.com>
2711M: Borislav Petkov <borislav.petkov@amd.com> 2719M: Borislav Petkov <bp@alien8.de>
2712L: linux-edac@vger.kernel.org 2720L: linux-edac@vger.kernel.org
2713W: bluesmoke.sourceforge.net 2721W: bluesmoke.sourceforge.net
2714S: Supported 2722S: Maintained
2715F: drivers/edac/amd64_edac* 2723F: drivers/edac/amd64_edac*
2716 2724
2717EDAC-E752X 2725EDAC-E752X
@@ -3598,6 +3606,49 @@ F: drivers/hid/hid-hyperv.c
3598F: drivers/net/hyperv/ 3606F: drivers/net/hyperv/
3599F: drivers/staging/hv/ 3607F: drivers/staging/hv/
3600 3608
3609I2C OVER PARALLEL PORT
3610M: Jean Delvare <khali@linux-fr.org>
3611L: linux-i2c@vger.kernel.org
3612S: Maintained
3613F: Documentation/i2c/busses/i2c-parport
3614F: Documentation/i2c/busses/i2c-parport-light
3615F: drivers/i2c/busses/i2c-parport.c
3616F: drivers/i2c/busses/i2c-parport-light.c
3617
3618I2C/SMBUS CONTROLLER DRIVERS FOR PC
3619M: Jean Delvare <khali@linux-fr.org>
3620L: linux-i2c@vger.kernel.org
3621S: Maintained
3622F: Documentation/i2c/busses/i2c-ali1535
3623F: Documentation/i2c/busses/i2c-ali1563
3624F: Documentation/i2c/busses/i2c-ali15x3
3625F: Documentation/i2c/busses/i2c-amd756
3626F: Documentation/i2c/busses/i2c-amd8111
3627F: Documentation/i2c/busses/i2c-i801
3628F: Documentation/i2c/busses/i2c-nforce2
3629F: Documentation/i2c/busses/i2c-piix4
3630F: Documentation/i2c/busses/i2c-sis5595
3631F: Documentation/i2c/busses/i2c-sis630
3632F: Documentation/i2c/busses/i2c-sis96x
3633F: Documentation/i2c/busses/i2c-via
3634F: Documentation/i2c/busses/i2c-viapro
3635F: drivers/i2c/busses/i2c-ali1535.c
3636F: drivers/i2c/busses/i2c-ali1563.c
3637F: drivers/i2c/busses/i2c-ali15x3.c
3638F: drivers/i2c/busses/i2c-amd756.c
3639F: drivers/i2c/busses/i2c-amd756-s4882.c
3640F: drivers/i2c/busses/i2c-amd8111.c
3641F: drivers/i2c/busses/i2c-i801.c
3642F: drivers/i2c/busses/i2c-isch.c
3643F: drivers/i2c/busses/i2c-nforce2.c
3644F: drivers/i2c/busses/i2c-nforce2-s4985.c
3645F: drivers/i2c/busses/i2c-piix4.c
3646F: drivers/i2c/busses/i2c-sis5595.c
3647F: drivers/i2c/busses/i2c-sis630.c
3648F: drivers/i2c/busses/i2c-sis96x.c
3649F: drivers/i2c/busses/i2c-via.c
3650F: drivers/i2c/busses/i2c-viapro.c
3651
3601I2C/SMBUS STUB DRIVER 3652I2C/SMBUS STUB DRIVER
3602M: "Mark M. Hoffman" <mhoffman@lightlink.com> 3653M: "Mark M. Hoffman" <mhoffman@lightlink.com>
3603L: linux-i2c@vger.kernel.org 3654L: linux-i2c@vger.kernel.org
@@ -3605,9 +3656,8 @@ S: Maintained
3605F: drivers/i2c/busses/i2c-stub.c 3656F: drivers/i2c/busses/i2c-stub.c
3606 3657
3607I2C SUBSYSTEM 3658I2C SUBSYSTEM
3608M: "Jean Delvare (PC drivers, core)" <khali@linux-fr.org> 3659M: Wolfram Sang <w.sang@pengutronix.de>
3609M: "Ben Dooks (embedded platforms)" <ben-linux@fluff.org> 3660M: "Ben Dooks (embedded platforms)" <ben-linux@fluff.org>
3610M: "Wolfram Sang (embedded platforms)" <w.sang@pengutronix.de>
3611L: linux-i2c@vger.kernel.org 3661L: linux-i2c@vger.kernel.org
3612W: http://i2c.wiki.kernel.org/ 3662W: http://i2c.wiki.kernel.org/
3613T: quilt kernel.org/pub/linux/kernel/people/jdelvare/linux-2.6/jdelvare-i2c/ 3663T: quilt kernel.org/pub/linux/kernel/people/jdelvare/linux-2.6/jdelvare-i2c/
@@ -3618,6 +3668,13 @@ F: drivers/i2c/
3618F: include/linux/i2c.h 3668F: include/linux/i2c.h
3619F: include/linux/i2c-*.h 3669F: include/linux/i2c-*.h
3620 3670
3671I2C-TAOS-EVM DRIVER
3672M: Jean Delvare <khali@linux-fr.org>
3673L: linux-i2c@vger.kernel.org
3674S: Maintained
3675F: Documentation/i2c/busses/i2c-taos-evm
3676F: drivers/i2c/busses/i2c-taos-evm.c
3677
3621I2C-TINY-USB DRIVER 3678I2C-TINY-USB DRIVER
3622M: Till Harbaum <till@harbaum.org> 3679M: Till Harbaum <till@harbaum.org>
3623L: linux-i2c@vger.kernel.org 3680L: linux-i2c@vger.kernel.org
@@ -3704,7 +3761,7 @@ S: Maintained
3704F: drivers/platform/x86/ideapad-laptop.c 3761F: drivers/platform/x86/ideapad-laptop.c
3705 3762
3706IDE/ATAPI DRIVERS 3763IDE/ATAPI DRIVERS
3707M: Borislav Petkov <petkovbb@gmail.com> 3764M: Borislav Petkov <bp@alien8.de>
3708L: linux-ide@vger.kernel.org 3765L: linux-ide@vger.kernel.org
3709S: Maintained 3766S: Maintained
3710F: Documentation/cdrom/ide-cd 3767F: Documentation/cdrom/ide-cd
@@ -4231,8 +4288,8 @@ F: include/linux/lockd/
4231F: include/linux/sunrpc/ 4288F: include/linux/sunrpc/
4232 4289
4233KERNEL VIRTUAL MACHINE (KVM) 4290KERNEL VIRTUAL MACHINE (KVM)
4234M: Avi Kivity <avi@redhat.com>
4235M: Marcelo Tosatti <mtosatti@redhat.com> 4291M: Marcelo Tosatti <mtosatti@redhat.com>
4292M: Gleb Natapov <gleb@redhat.com>
4236L: kvm@vger.kernel.org 4293L: kvm@vger.kernel.org
4237W: http://kvm.qumranet.com 4294W: http://kvm.qumranet.com
4238S: Supported 4295S: Supported
@@ -5364,7 +5421,7 @@ S: Maintained
5364F: sound/drivers/opl4/ 5421F: sound/drivers/opl4/
5365 5422
5366OPROFILE 5423OPROFILE
5367M: Robert Richter <robert.richter@amd.com> 5424M: Robert Richter <rric@kernel.org>
5368L: oprofile-list@lists.sf.net 5425L: oprofile-list@lists.sf.net
5369S: Maintained 5426S: Maintained
5370F: arch/*/include/asm/oprofile*.h 5427F: arch/*/include/asm/oprofile*.h
@@ -7210,6 +7267,14 @@ L: linux-xtensa@linux-xtensa.org
7210S: Maintained 7267S: Maintained
7211F: arch/xtensa/ 7268F: arch/xtensa/
7212 7269
7270THERMAL
7271M: Zhang Rui <rui.zhang@intel.com>
7272L: linux-pm@vger.kernel.org
7273T: git git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git
7274S: Supported
7275F: drivers/thermal/
7276F: include/linux/thermal.h
7277
7213THINKPAD ACPI EXTRAS DRIVER 7278THINKPAD ACPI EXTRAS DRIVER
7214M: Henrique de Moraes Holschuh <ibm-acpi@hmh.eng.br> 7279M: Henrique de Moraes Holschuh <ibm-acpi@hmh.eng.br>
7215L: ibm-acpi-devel@lists.sourceforge.net 7280L: ibm-acpi-devel@lists.sourceforge.net
@@ -7887,13 +7952,6 @@ M: Roger Luethi <rl@hellgate.ch>
7887S: Maintained 7952S: Maintained
7888F: drivers/net/ethernet/via/via-rhine.c 7953F: drivers/net/ethernet/via/via-rhine.c
7889 7954
7890VIAPRO SMBUS DRIVER
7891M: Jean Delvare <khali@linux-fr.org>
7892L: linux-i2c@vger.kernel.org
7893S: Maintained
7894F: Documentation/i2c/busses/i2c-viapro
7895F: drivers/i2c/busses/i2c-viapro.c
7896
7897VIA SD/MMC CARD CONTROLLER DRIVER 7955VIA SD/MMC CARD CONTROLLER DRIVER
7898M: Bruce Chang <brucechang@via.com.tw> 7956M: Bruce Chang <brucechang@via.com.tw>
7899M: Harald Welte <HaraldWelte@viatech.com> 7957M: Harald Welte <HaraldWelte@viatech.com>
@@ -8148,7 +8206,7 @@ F: drivers/platform/x86
8148 8206
8149X86 MCE INFRASTRUCTURE 8207X86 MCE INFRASTRUCTURE
8150M: Tony Luck <tony.luck@intel.com> 8208M: Tony Luck <tony.luck@intel.com>
8151M: Borislav Petkov <bp@amd64.org> 8209M: Borislav Petkov <bp@alien8.de>
8152L: linux-edac@vger.kernel.org 8210L: linux-edac@vger.kernel.org
8153S: Maintained 8211S: Maintained
8154F: arch/x86/kernel/cpu/mcheck/* 8212F: arch/x86/kernel/cpu/mcheck/*
diff --git a/Makefile b/Makefile
index 6edac73ee1ba..3d2fc460b22f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 3 1VERSION = 3
2PATCHLEVEL = 7 2PATCHLEVEL = 7
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc5 4EXTRAVERSION = -rc7
5NAME = Terrified Chipmunk 5NAME = Terrified Chipmunk
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
index 1e6956a90608..14db93e4c8a8 100644
--- a/arch/alpha/kernel/osf_sys.c
+++ b/arch/alpha/kernel/osf_sys.c
@@ -445,7 +445,7 @@ struct procfs_args {
445 * unhappy with OSF UFS. [CHECKME] 445 * unhappy with OSF UFS. [CHECKME]
446 */ 446 */
447static int 447static int
448osf_ufs_mount(char *dirname, struct ufs_args __user *args, int flags) 448osf_ufs_mount(const char *dirname, struct ufs_args __user *args, int flags)
449{ 449{
450 int retval; 450 int retval;
451 struct cdfs_args tmp; 451 struct cdfs_args tmp;
@@ -465,7 +465,7 @@ osf_ufs_mount(char *dirname, struct ufs_args __user *args, int flags)
465} 465}
466 466
467static int 467static int
468osf_cdfs_mount(char *dirname, struct cdfs_args __user *args, int flags) 468osf_cdfs_mount(const char *dirname, struct cdfs_args __user *args, int flags)
469{ 469{
470 int retval; 470 int retval;
471 struct cdfs_args tmp; 471 struct cdfs_args tmp;
@@ -485,7 +485,7 @@ osf_cdfs_mount(char *dirname, struct cdfs_args __user *args, int flags)
485} 485}
486 486
487static int 487static int
488osf_procfs_mount(char *dirname, struct procfs_args __user *args, int flags) 488osf_procfs_mount(const char *dirname, struct procfs_args __user *args, int flags)
489{ 489{
490 struct procfs_args tmp; 490 struct procfs_args tmp;
491 491
diff --git a/arch/arm/boot/Makefile b/arch/arm/boot/Makefile
index f2aa09eb658e..9137df539b61 100644
--- a/arch/arm/boot/Makefile
+++ b/arch/arm/boot/Makefile
@@ -33,7 +33,7 @@ ifeq ($(CONFIG_XIP_KERNEL),y)
33 33
34$(obj)/xipImage: vmlinux FORCE 34$(obj)/xipImage: vmlinux FORCE
35 $(call if_changed,objcopy) 35 $(call if_changed,objcopy)
36 $(kecho) ' Kernel: $@ is ready (physical address: $(CONFIG_XIP_PHYS_ADDR))' 36 @$(kecho) ' Kernel: $@ is ready (physical address: $(CONFIG_XIP_PHYS_ADDR))'
37 37
38$(obj)/Image $(obj)/zImage: FORCE 38$(obj)/Image $(obj)/zImage: FORCE
39 @echo 'Kernel configured for XIP (CONFIG_XIP_KERNEL=y)' 39 @echo 'Kernel configured for XIP (CONFIG_XIP_KERNEL=y)'
@@ -48,14 +48,14 @@ $(obj)/xipImage: FORCE
48 48
49$(obj)/Image: vmlinux FORCE 49$(obj)/Image: vmlinux FORCE
50 $(call if_changed,objcopy) 50 $(call if_changed,objcopy)
51 $(kecho) ' Kernel: $@ is ready' 51 @$(kecho) ' Kernel: $@ is ready'
52 52
53$(obj)/compressed/vmlinux: $(obj)/Image FORCE 53$(obj)/compressed/vmlinux: $(obj)/Image FORCE
54 $(Q)$(MAKE) $(build)=$(obj)/compressed $@ 54 $(Q)$(MAKE) $(build)=$(obj)/compressed $@
55 55
56$(obj)/zImage: $(obj)/compressed/vmlinux FORCE 56$(obj)/zImage: $(obj)/compressed/vmlinux FORCE
57 $(call if_changed,objcopy) 57 $(call if_changed,objcopy)
58 $(kecho) ' Kernel: $@ is ready' 58 @$(kecho) ' Kernel: $@ is ready'
59 59
60endif 60endif
61 61
@@ -90,7 +90,7 @@ fi
90$(obj)/uImage: $(obj)/zImage FORCE 90$(obj)/uImage: $(obj)/zImage FORCE
91 @$(check_for_multiple_loadaddr) 91 @$(check_for_multiple_loadaddr)
92 $(call if_changed,uimage) 92 $(call if_changed,uimage)
93 $(kecho) ' Image $@ is ready' 93 @$(kecho) ' Image $@ is ready'
94 94
95$(obj)/bootp/bootp: $(obj)/zImage initrd FORCE 95$(obj)/bootp/bootp: $(obj)/zImage initrd FORCE
96 $(Q)$(MAKE) $(build)=$(obj)/bootp $@ 96 $(Q)$(MAKE) $(build)=$(obj)/bootp $@
@@ -98,7 +98,7 @@ $(obj)/bootp/bootp: $(obj)/zImage initrd FORCE
98 98
99$(obj)/bootpImage: $(obj)/bootp/bootp FORCE 99$(obj)/bootpImage: $(obj)/bootp/bootp FORCE
100 $(call if_changed,objcopy) 100 $(call if_changed,objcopy)
101 $(kecho) ' Kernel: $@ is ready' 101 @$(kecho) ' Kernel: $@ is ready'
102 102
103PHONY += initrd FORCE 103PHONY += initrd FORCE
104initrd: 104initrd:
diff --git a/arch/arm/boot/dts/at91sam9260.dtsi b/arch/arm/boot/dts/at91sam9260.dtsi
index d410581a5a85..aaa42d8d4f88 100644
--- a/arch/arm/boot/dts/at91sam9260.dtsi
+++ b/arch/arm/boot/dts/at91sam9260.dtsi
@@ -29,6 +29,7 @@
29 tcb0 = &tcb0; 29 tcb0 = &tcb0;
30 tcb1 = &tcb1; 30 tcb1 = &tcb1;
31 i2c0 = &i2c0; 31 i2c0 = &i2c0;
32 ssc0 = &ssc0;
32 }; 33 };
33 cpus { 34 cpus {
34 cpu@0 { 35 cpu@0 {
@@ -212,6 +213,13 @@
212 status = "disabled"; 213 status = "disabled";
213 }; 214 };
214 215
216 ssc0: ssc@fffbc000 {
217 compatible = "atmel,at91rm9200-ssc";
218 reg = <0xfffbc000 0x4000>;
219 interrupts = <14 4 5>;
220 status = "disable";
221 };
222
215 adc0: adc@fffe0000 { 223 adc0: adc@fffe0000 {
216 compatible = "atmel,at91sam9260-adc"; 224 compatible = "atmel,at91sam9260-adc";
217 reg = <0xfffe0000 0x100>; 225 reg = <0xfffe0000 0x100>;
diff --git a/arch/arm/boot/dts/at91sam9263.dtsi b/arch/arm/boot/dts/at91sam9263.dtsi
index 3e6e5c1abbf3..3b721ee59b10 100644
--- a/arch/arm/boot/dts/at91sam9263.dtsi
+++ b/arch/arm/boot/dts/at91sam9263.dtsi
@@ -25,6 +25,8 @@
25 gpio4 = &pioE; 25 gpio4 = &pioE;
26 tcb0 = &tcb0; 26 tcb0 = &tcb0;
27 i2c0 = &i2c0; 27 i2c0 = &i2c0;
28 ssc0 = &ssc0;
29 ssc1 = &ssc1;
28 }; 30 };
29 cpus { 31 cpus {
30 cpu@0 { 32 cpu@0 {
@@ -173,6 +175,20 @@
173 status = "disabled"; 175 status = "disabled";
174 }; 176 };
175 177
178 ssc0: ssc@fff98000 {
179 compatible = "atmel,at91rm9200-ssc";
180 reg = <0xfff98000 0x4000>;
181 interrupts = <16 4 5>;
182 status = "disable";
183 };
184
185 ssc1: ssc@fff9c000 {
186 compatible = "atmel,at91rm9200-ssc";
187 reg = <0xfff9c000 0x4000>;
188 interrupts = <17 4 5>;
189 status = "disable";
190 };
191
176 macb0: ethernet@fffbc000 { 192 macb0: ethernet@fffbc000 {
177 compatible = "cdns,at32ap7000-macb", "cdns,macb"; 193 compatible = "cdns,at32ap7000-macb", "cdns,macb";
178 reg = <0xfffbc000 0x100>; 194 reg = <0xfffbc000 0x100>;
diff --git a/arch/arm/boot/dts/at91sam9g20ek_common.dtsi b/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
index e6391a4e6649..2dcec8de759f 100644
--- a/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
+++ b/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
@@ -30,6 +30,16 @@
30 30
31 ahb { 31 ahb {
32 apb { 32 apb {
33 pinctrl@fffff400 {
34 board {
35 pinctrl_pck0_as_mck: pck0_as_mck {
36 atmel,pins =
37 <2 1 0x2 0x0>; /* PC1 periph B */
38 };
39
40 };
41 };
42
33 dbgu: serial@fffff200 { 43 dbgu: serial@fffff200 {
34 status = "okay"; 44 status = "okay";
35 }; 45 };
@@ -51,6 +61,11 @@
51 atmel,vbus-gpio = <&pioC 5 0>; 61 atmel,vbus-gpio = <&pioC 5 0>;
52 status = "okay"; 62 status = "okay";
53 }; 63 };
64
65 ssc0: ssc@fffbc000 {
66 status = "okay";
67 pinctrl-0 = <&pinctrl_ssc0_tx>;
68 };
54 }; 69 };
55 70
56 nand0: nand@40000000 { 71 nand0: nand@40000000 {
@@ -114,7 +129,7 @@
114 reg = <0x50>; 129 reg = <0x50>;
115 }; 130 };
116 131
117 wm8731@1b { 132 wm8731: wm8731@1b {
118 compatible = "wm8731"; 133 compatible = "wm8731";
119 reg = <0x1b>; 134 reg = <0x1b>;
120 }; 135 };
@@ -139,4 +154,19 @@
139 gpio-key,wakeup; 154 gpio-key,wakeup;
140 }; 155 };
141 }; 156 };
157
158 sound {
159 compatible = "atmel,at91sam9g20ek-wm8731-audio";
160 pinctrl-names = "default";
161 pinctrl-0 = <&pinctrl_pck0_as_mck>;
162
163 atmel,model = "wm8731 @ AT91SAMG20EK";
164
165 atmel,audio-routing =
166 "Ext Spk", "LHPOUT",
167 "Int Mic", "MICIN";
168
169 atmel,ssc-controller = <&ssc0>;
170 atmel,audio-codec = <&wm8731>;
171 };
142}; 172};
diff --git a/arch/arm/boot/dts/at91sam9g45.dtsi b/arch/arm/boot/dts/at91sam9g45.dtsi
index 3add030d61f8..acfa207162ff 100644
--- a/arch/arm/boot/dts/at91sam9g45.dtsi
+++ b/arch/arm/boot/dts/at91sam9g45.dtsi
@@ -31,6 +31,8 @@
31 tcb1 = &tcb1; 31 tcb1 = &tcb1;
32 i2c0 = &i2c0; 32 i2c0 = &i2c0;
33 i2c1 = &i2c1; 33 i2c1 = &i2c1;
34 ssc0 = &ssc0;
35 ssc1 = &ssc1;
34 }; 36 };
35 cpus { 37 cpus {
36 cpu@0 { 38 cpu@0 {
@@ -226,6 +228,20 @@
226 status = "disabled"; 228 status = "disabled";
227 }; 229 };
228 230
231 ssc0: ssc@fff9c000 {
232 compatible = "atmel,at91sam9g45-ssc";
233 reg = <0xfff9c000 0x4000>;
234 interrupts = <16 4 5>;
235 status = "disable";
236 };
237
238 ssc1: ssc@fffa0000 {
239 compatible = "atmel,at91sam9g45-ssc";
240 reg = <0xfffa0000 0x4000>;
241 interrupts = <17 4 5>;
242 status = "disable";
243 };
244
229 adc0: adc@fffb0000 { 245 adc0: adc@fffb0000 {
230 compatible = "atmel,at91sam9260-adc"; 246 compatible = "atmel,at91sam9260-adc";
231 reg = <0xfffb0000 0x100>; 247 reg = <0xfffb0000 0x100>;
diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi
index 03fc136421c5..69667d0ac347 100644
--- a/arch/arm/boot/dts/at91sam9x5.dtsi
+++ b/arch/arm/boot/dts/at91sam9x5.dtsi
@@ -30,6 +30,7 @@
30 i2c0 = &i2c0; 30 i2c0 = &i2c0;
31 i2c1 = &i2c1; 31 i2c1 = &i2c1;
32 i2c2 = &i2c2; 32 i2c2 = &i2c2;
33 ssc0 = &ssc0;
33 }; 34 };
34 cpus { 35 cpus {
35 cpu@0 { 36 cpu@0 {
@@ -87,6 +88,13 @@
87 interrupts = <1 4 7>; 88 interrupts = <1 4 7>;
88 }; 89 };
89 90
91 ssc0: ssc@f0010000 {
92 compatible = "atmel,at91sam9g45-ssc";
93 reg = <0xf0010000 0x4000>;
94 interrupts = <28 4 5>;
95 status = "disable";
96 };
97
90 tcb0: timer@f8008000 { 98 tcb0: timer@f8008000 {
91 compatible = "atmel,at91sam9x5-tcb"; 99 compatible = "atmel,at91sam9x5-tcb";
92 reg = <0xf8008000 0x100>; 100 reg = <0xf8008000 0x100>;
diff --git a/arch/arm/boot/dts/tegra30.dtsi b/arch/arm/boot/dts/tegra30.dtsi
index b1497c7d7d68..df7f2270fc91 100644
--- a/arch/arm/boot/dts/tegra30.dtsi
+++ b/arch/arm/boot/dts/tegra30.dtsi
@@ -73,8 +73,8 @@
73 73
74 pinmux: pinmux { 74 pinmux: pinmux {
75 compatible = "nvidia,tegra30-pinmux"; 75 compatible = "nvidia,tegra30-pinmux";
76 reg = <0x70000868 0xd0 /* Pad control registers */ 76 reg = <0x70000868 0xd4 /* Pad control registers */
77 0x70003000 0x3e0>; /* Mux registers */ 77 0x70003000 0x3e4>; /* Mux registers */
78 }; 78 };
79 79
80 serial@70006000 { 80 serial@70006000 {
diff --git a/arch/arm/mach-at91/at91rm9200.c b/arch/arm/mach-at91/at91rm9200.c
index 5269825194a8..af47c75db513 100644
--- a/arch/arm/mach-at91/at91rm9200.c
+++ b/arch/arm/mach-at91/at91rm9200.c
@@ -184,9 +184,12 @@ static struct clk_lookup periph_clocks_lookups[] = {
184 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.1", &tc3_clk), 184 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.1", &tc3_clk),
185 CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.1", &tc4_clk), 185 CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.1", &tc4_clk),
186 CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.1", &tc5_clk), 186 CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.1", &tc5_clk),
187 CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk), 187 CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.0", &ssc0_clk),
188 CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk), 188 CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.1", &ssc1_clk),
189 CLKDEV_CON_DEV_ID("pclk", "ssc.2", &ssc2_clk), 189 CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.2", &ssc2_clk),
190 CLKDEV_CON_DEV_ID("pclk", "fffd0000.ssc", &ssc0_clk),
191 CLKDEV_CON_DEV_ID("pclk", "fffd4000.ssc", &ssc1_clk),
192 CLKDEV_CON_DEV_ID("pclk", "fffd8000.ssc", &ssc2_clk),
190 CLKDEV_CON_DEV_ID(NULL, "i2c-at91rm9200.0", &twi_clk), 193 CLKDEV_CON_DEV_ID(NULL, "i2c-at91rm9200.0", &twi_clk),
191 /* fake hclk clock */ 194 /* fake hclk clock */
192 CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &ohci_clk), 195 CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &ohci_clk),
diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c
index 1e122bcd7845..9e76427aaec2 100644
--- a/arch/arm/mach-at91/at91rm9200_devices.c
+++ b/arch/arm/mach-at91/at91rm9200_devices.c
@@ -68,7 +68,7 @@ void __init at91_add_device_usbh(struct at91_usbh_data *data)
68 68
69 /* Enable overcurrent notification */ 69 /* Enable overcurrent notification */
70 for (i = 0; i < data->ports; i++) { 70 for (i = 0; i < data->ports; i++) {
71 if (data->overcurrent_pin[i]) 71 if (gpio_is_valid(data->overcurrent_pin[i]))
72 at91_set_gpio_input(data->overcurrent_pin[i], 1); 72 at91_set_gpio_input(data->overcurrent_pin[i], 1);
73 } 73 }
74 74
@@ -752,7 +752,7 @@ static struct resource ssc0_resources[] = {
752}; 752};
753 753
754static struct platform_device at91rm9200_ssc0_device = { 754static struct platform_device at91rm9200_ssc0_device = {
755 .name = "ssc", 755 .name = "at91rm9200_ssc",
756 .id = 0, 756 .id = 0,
757 .dev = { 757 .dev = {
758 .dma_mask = &ssc0_dmamask, 758 .dma_mask = &ssc0_dmamask,
@@ -794,7 +794,7 @@ static struct resource ssc1_resources[] = {
794}; 794};
795 795
796static struct platform_device at91rm9200_ssc1_device = { 796static struct platform_device at91rm9200_ssc1_device = {
797 .name = "ssc", 797 .name = "at91rm9200_ssc",
798 .id = 1, 798 .id = 1,
799 .dev = { 799 .dev = {
800 .dma_mask = &ssc1_dmamask, 800 .dma_mask = &ssc1_dmamask,
@@ -836,7 +836,7 @@ static struct resource ssc2_resources[] = {
836}; 836};
837 837
838static struct platform_device at91rm9200_ssc2_device = { 838static struct platform_device at91rm9200_ssc2_device = {
839 .name = "ssc", 839 .name = "at91rm9200_ssc",
840 .id = 2, 840 .id = 2,
841 .dev = { 841 .dev = {
842 .dma_mask = &ssc2_dmamask, 842 .dma_mask = &ssc2_dmamask,
diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c
index f8202615f4a8..a41eb3d23f68 100644
--- a/arch/arm/mach-at91/at91sam9260.c
+++ b/arch/arm/mach-at91/at91sam9260.c
@@ -210,7 +210,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
210 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.1", &tc3_clk), 210 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.1", &tc3_clk),
211 CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.1", &tc4_clk), 211 CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.1", &tc4_clk),
212 CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.1", &tc5_clk), 212 CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.1", &tc5_clk),
213 CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc_clk), 213 CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.0", &ssc_clk),
214 CLKDEV_CON_DEV_ID("pclk", "fffbc000.ssc", &ssc_clk),
214 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9260.0", &twi_clk), 215 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9260.0", &twi_clk),
215 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g20.0", &twi_clk), 216 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g20.0", &twi_clk),
216 /* more usart lookup table for DT entries */ 217 /* more usart lookup table for DT entries */
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
index aa1e58729885..e67cfa2acbe0 100644
--- a/arch/arm/mach-at91/at91sam9260_devices.c
+++ b/arch/arm/mach-at91/at91sam9260_devices.c
@@ -72,7 +72,7 @@ void __init at91_add_device_usbh(struct at91_usbh_data *data)
72 72
73 /* Enable overcurrent notification */ 73 /* Enable overcurrent notification */
74 for (i = 0; i < data->ports; i++) { 74 for (i = 0; i < data->ports; i++) {
75 if (data->overcurrent_pin[i]) 75 if (gpio_is_valid(data->overcurrent_pin[i]))
76 at91_set_gpio_input(data->overcurrent_pin[i], 1); 76 at91_set_gpio_input(data->overcurrent_pin[i], 1);
77 } 77 }
78 78
@@ -742,7 +742,7 @@ static struct resource ssc_resources[] = {
742}; 742};
743 743
744static struct platform_device at91sam9260_ssc_device = { 744static struct platform_device at91sam9260_ssc_device = {
745 .name = "ssc", 745 .name = "at91rm9200_ssc",
746 .id = 0, 746 .id = 0,
747 .dev = { 747 .dev = {
748 .dma_mask = &ssc_dmamask, 748 .dma_mask = &ssc_dmamask,
diff --git a/arch/arm/mach-at91/at91sam9261.c b/arch/arm/mach-at91/at91sam9261.c
index 04295c04b3e0..7fcbe0583342 100644
--- a/arch/arm/mach-at91/at91sam9261.c
+++ b/arch/arm/mach-at91/at91sam9261.c
@@ -174,9 +174,12 @@ static struct clk_lookup periph_clocks_lookups[] = {
174 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tc0_clk), 174 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tc0_clk),
175 CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.0", &tc1_clk), 175 CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.0", &tc1_clk),
176 CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.0", &tc2_clk), 176 CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.0", &tc2_clk),
177 CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk), 177 CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.0", &ssc0_clk),
178 CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk), 178 CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.1", &ssc1_clk),
179 CLKDEV_CON_DEV_ID("pclk", "ssc.2", &ssc2_clk), 179 CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.2", &ssc2_clk),
180 CLKDEV_CON_DEV_ID("pclk", "fffbc000.ssc", &ssc0_clk),
181 CLKDEV_CON_DEV_ID("pclk", "fffc0000.ssc", &ssc1_clk),
182 CLKDEV_CON_DEV_ID("pclk", "fffc4000.ssc", &ssc2_clk),
180 CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &hck0), 183 CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &hck0),
181 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9261.0", &twi_clk), 184 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9261.0", &twi_clk),
182 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g10.0", &twi_clk), 185 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g10.0", &twi_clk),
diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c
index b9487696b7be..a27d9dd0faa4 100644
--- a/arch/arm/mach-at91/at91sam9261_devices.c
+++ b/arch/arm/mach-at91/at91sam9261_devices.c
@@ -72,7 +72,7 @@ void __init at91_add_device_usbh(struct at91_usbh_data *data)
72 72
73 /* Enable overcurrent notification */ 73 /* Enable overcurrent notification */
74 for (i = 0; i < data->ports; i++) { 74 for (i = 0; i < data->ports; i++) {
75 if (data->overcurrent_pin[i]) 75 if (gpio_is_valid(data->overcurrent_pin[i]))
76 at91_set_gpio_input(data->overcurrent_pin[i], 1); 76 at91_set_gpio_input(data->overcurrent_pin[i], 1);
77 } 77 }
78 78
@@ -706,7 +706,7 @@ static struct resource ssc0_resources[] = {
706}; 706};
707 707
708static struct platform_device at91sam9261_ssc0_device = { 708static struct platform_device at91sam9261_ssc0_device = {
709 .name = "ssc", 709 .name = "at91rm9200_ssc",
710 .id = 0, 710 .id = 0,
711 .dev = { 711 .dev = {
712 .dma_mask = &ssc0_dmamask, 712 .dma_mask = &ssc0_dmamask,
@@ -748,7 +748,7 @@ static struct resource ssc1_resources[] = {
748}; 748};
749 749
750static struct platform_device at91sam9261_ssc1_device = { 750static struct platform_device at91sam9261_ssc1_device = {
751 .name = "ssc", 751 .name = "at91rm9200_ssc",
752 .id = 1, 752 .id = 1,
753 .dev = { 753 .dev = {
754 .dma_mask = &ssc1_dmamask, 754 .dma_mask = &ssc1_dmamask,
@@ -790,7 +790,7 @@ static struct resource ssc2_resources[] = {
790}; 790};
791 791
792static struct platform_device at91sam9261_ssc2_device = { 792static struct platform_device at91sam9261_ssc2_device = {
793 .name = "ssc", 793 .name = "at91rm9200_ssc",
794 .id = 2, 794 .id = 2,
795 .dev = { 795 .dev = {
796 .dma_mask = &ssc2_dmamask, 796 .dma_mask = &ssc2_dmamask,
diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c
index d6f9c23927c4..c0f4c8c1f4ed 100644
--- a/arch/arm/mach-at91/at91sam9263.c
+++ b/arch/arm/mach-at91/at91sam9263.c
@@ -186,8 +186,10 @@ static struct clk *periph_clocks[] __initdata = {
186static struct clk_lookup periph_clocks_lookups[] = { 186static struct clk_lookup periph_clocks_lookups[] = {
187 /* One additional fake clock for macb_hclk */ 187 /* One additional fake clock for macb_hclk */
188 CLKDEV_CON_ID("hclk", &macb_clk), 188 CLKDEV_CON_ID("hclk", &macb_clk),
189 CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk), 189 CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.0", &ssc0_clk),
190 CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk), 190 CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.1", &ssc1_clk),
191 CLKDEV_CON_DEV_ID("pclk", "fff98000.ssc", &ssc0_clk),
192 CLKDEV_CON_DEV_ID("pclk", "fff9c000.ssc", &ssc1_clk),
191 CLKDEV_CON_DEV_ID("mci_clk", "atmel_mci.0", &mmc0_clk), 193 CLKDEV_CON_DEV_ID("mci_clk", "atmel_mci.0", &mmc0_clk),
192 CLKDEV_CON_DEV_ID("mci_clk", "atmel_mci.1", &mmc1_clk), 194 CLKDEV_CON_DEV_ID("mci_clk", "atmel_mci.1", &mmc1_clk),
193 CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.0", &spi0_clk), 195 CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.0", &spi0_clk),
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
index cb85da2eccea..8215839f2d54 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -78,7 +78,7 @@ void __init at91_add_device_usbh(struct at91_usbh_data *data)
78 78
79 /* Enable overcurrent notification */ 79 /* Enable overcurrent notification */
80 for (i = 0; i < data->ports; i++) { 80 for (i = 0; i < data->ports; i++) {
81 if (data->overcurrent_pin[i]) 81 if (gpio_is_valid(data->overcurrent_pin[i]))
82 at91_set_gpio_input(data->overcurrent_pin[i], 1); 82 at91_set_gpio_input(data->overcurrent_pin[i], 1);
83 } 83 }
84 84
@@ -1199,7 +1199,7 @@ static struct resource ssc0_resources[] = {
1199}; 1199};
1200 1200
1201static struct platform_device at91sam9263_ssc0_device = { 1201static struct platform_device at91sam9263_ssc0_device = {
1202 .name = "ssc", 1202 .name = "at91rm9200_ssc",
1203 .id = 0, 1203 .id = 0,
1204 .dev = { 1204 .dev = {
1205 .dma_mask = &ssc0_dmamask, 1205 .dma_mask = &ssc0_dmamask,
@@ -1241,7 +1241,7 @@ static struct resource ssc1_resources[] = {
1241}; 1241};
1242 1242
1243static struct platform_device at91sam9263_ssc1_device = { 1243static struct platform_device at91sam9263_ssc1_device = {
1244 .name = "ssc", 1244 .name = "at91rm9200_ssc",
1245 .id = 1, 1245 .id = 1,
1246 .dev = { 1246 .dev = {
1247 .dma_mask = &ssc1_dmamask, 1247 .dma_mask = &ssc1_dmamask,
diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c
index 84af1b506d92..a4282d3742bf 100644
--- a/arch/arm/mach-at91/at91sam9g45.c
+++ b/arch/arm/mach-at91/at91sam9g45.c
@@ -239,8 +239,10 @@ static struct clk_lookup periph_clocks_lookups[] = {
239 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.1", &tcb0_clk), 239 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.1", &tcb0_clk),
240 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g10.0", &twi0_clk), 240 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g10.0", &twi0_clk),
241 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g10.1", &twi1_clk), 241 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g10.1", &twi1_clk),
242 CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk), 242 CLKDEV_CON_DEV_ID("pclk", "at91sam9g45_ssc.0", &ssc0_clk),
243 CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk), 243 CLKDEV_CON_DEV_ID("pclk", "at91sam9g45_ssc.1", &ssc1_clk),
244 CLKDEV_CON_DEV_ID("pclk", "fff9c000.ssc", &ssc0_clk),
245 CLKDEV_CON_DEV_ID("pclk", "fffa0000.ssc", &ssc1_clk),
244 CLKDEV_CON_DEV_ID(NULL, "atmel-trng", &trng_clk), 246 CLKDEV_CON_DEV_ID(NULL, "atmel-trng", &trng_clk),
245 CLKDEV_CON_DEV_ID(NULL, "atmel_sha", &aestdessha_clk), 247 CLKDEV_CON_DEV_ID(NULL, "atmel_sha", &aestdessha_clk),
246 CLKDEV_CON_DEV_ID(NULL, "atmel_tdes", &aestdessha_clk), 248 CLKDEV_CON_DEV_ID(NULL, "atmel_tdes", &aestdessha_clk),
diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c
index b1596072dcc2..d26474a97fec 100644
--- a/arch/arm/mach-at91/at91sam9g45_devices.c
+++ b/arch/arm/mach-at91/at91sam9g45_devices.c
@@ -1459,7 +1459,7 @@ static struct resource ssc0_resources[] = {
1459}; 1459};
1460 1460
1461static struct platform_device at91sam9g45_ssc0_device = { 1461static struct platform_device at91sam9g45_ssc0_device = {
1462 .name = "ssc", 1462 .name = "at91sam9g45_ssc",
1463 .id = 0, 1463 .id = 0,
1464 .dev = { 1464 .dev = {
1465 .dma_mask = &ssc0_dmamask, 1465 .dma_mask = &ssc0_dmamask,
@@ -1501,7 +1501,7 @@ static struct resource ssc1_resources[] = {
1501}; 1501};
1502 1502
1503static struct platform_device at91sam9g45_ssc1_device = { 1503static struct platform_device at91sam9g45_ssc1_device = {
1504 .name = "ssc", 1504 .name = "at91sam9g45_ssc",
1505 .id = 1, 1505 .id = 1,
1506 .dev = { 1506 .dev = {
1507 .dma_mask = &ssc1_dmamask, 1507 .dma_mask = &ssc1_dmamask,
@@ -1841,8 +1841,8 @@ static struct resource sha_resources[] = {
1841 .flags = IORESOURCE_MEM, 1841 .flags = IORESOURCE_MEM,
1842 }, 1842 },
1843 [1] = { 1843 [1] = {
1844 .start = AT91SAM9G45_ID_AESTDESSHA, 1844 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_AESTDESSHA,
1845 .end = AT91SAM9G45_ID_AESTDESSHA, 1845 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_AESTDESSHA,
1846 .flags = IORESOURCE_IRQ, 1846 .flags = IORESOURCE_IRQ,
1847 }, 1847 },
1848}; 1848};
@@ -1874,8 +1874,8 @@ static struct resource tdes_resources[] = {
1874 .flags = IORESOURCE_MEM, 1874 .flags = IORESOURCE_MEM,
1875 }, 1875 },
1876 [1] = { 1876 [1] = {
1877 .start = AT91SAM9G45_ID_AESTDESSHA, 1877 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_AESTDESSHA,
1878 .end = AT91SAM9G45_ID_AESTDESSHA, 1878 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_AESTDESSHA,
1879 .flags = IORESOURCE_IRQ, 1879 .flags = IORESOURCE_IRQ,
1880 }, 1880 },
1881}; 1881};
@@ -1910,8 +1910,8 @@ static struct resource aes_resources[] = {
1910 .flags = IORESOURCE_MEM, 1910 .flags = IORESOURCE_MEM,
1911 }, 1911 },
1912 [1] = { 1912 [1] = {
1913 .start = AT91SAM9G45_ID_AESTDESSHA, 1913 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_AESTDESSHA,
1914 .end = AT91SAM9G45_ID_AESTDESSHA, 1914 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_AESTDESSHA,
1915 .flags = IORESOURCE_IRQ, 1915 .flags = IORESOURCE_IRQ,
1916 }, 1916 },
1917}; 1917};
diff --git a/arch/arm/mach-at91/at91sam9rl.c b/arch/arm/mach-at91/at91sam9rl.c
index 72e908412222..b683fdc699f1 100644
--- a/arch/arm/mach-at91/at91sam9rl.c
+++ b/arch/arm/mach-at91/at91sam9rl.c
@@ -184,8 +184,10 @@ static struct clk_lookup periph_clocks_lookups[] = {
184 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tc0_clk), 184 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tc0_clk),
185 CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.0", &tc1_clk), 185 CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.0", &tc1_clk),
186 CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.0", &tc2_clk), 186 CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.0", &tc2_clk),
187 CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk), 187 CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.0", &ssc0_clk),
188 CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk), 188 CLKDEV_CON_DEV_ID("pclk", "at91rm9200_ssc.1", &ssc1_clk),
189 CLKDEV_CON_DEV_ID("pclk", "fffc0000.ssc", &ssc0_clk),
190 CLKDEV_CON_DEV_ID("pclk", "fffc4000.ssc", &ssc1_clk),
189 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g20.0", &twi0_clk), 191 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g20.0", &twi0_clk),
190 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g20.1", &twi1_clk), 192 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g20.1", &twi1_clk),
191 CLKDEV_CON_ID("pioA", &pioA_clk), 193 CLKDEV_CON_ID("pioA", &pioA_clk),
diff --git a/arch/arm/mach-at91/at91sam9rl_devices.c b/arch/arm/mach-at91/at91sam9rl_devices.c
index 5047bdc92adf..b656110e8afe 100644
--- a/arch/arm/mach-at91/at91sam9rl_devices.c
+++ b/arch/arm/mach-at91/at91sam9rl_devices.c
@@ -832,7 +832,7 @@ static struct resource ssc0_resources[] = {
832}; 832};
833 833
834static struct platform_device at91sam9rl_ssc0_device = { 834static struct platform_device at91sam9rl_ssc0_device = {
835 .name = "ssc", 835 .name = "at91rm9200_ssc",
836 .id = 0, 836 .id = 0,
837 .dev = { 837 .dev = {
838 .dma_mask = &ssc0_dmamask, 838 .dma_mask = &ssc0_dmamask,
@@ -874,7 +874,7 @@ static struct resource ssc1_resources[] = {
874}; 874};
875 875
876static struct platform_device at91sam9rl_ssc1_device = { 876static struct platform_device at91sam9rl_ssc1_device = {
877 .name = "ssc", 877 .name = "at91rm9200_ssc",
878 .id = 1, 878 .id = 1,
879 .dev = { 879 .dev = {
880 .dma_mask = &ssc1_dmamask, 880 .dma_mask = &ssc1_dmamask,
diff --git a/arch/arm/mach-at91/at91sam9x5.c b/arch/arm/mach-at91/at91sam9x5.c
index e5035380dcbc..18fbbb27f97f 100644
--- a/arch/arm/mach-at91/at91sam9x5.c
+++ b/arch/arm/mach-at91/at91sam9x5.c
@@ -231,6 +231,7 @@ static struct clk_lookup periph_clocks_lookups[] = {
231 CLKDEV_CON_DEV_ID("t0_clk", "f800c000.timer", &tcb0_clk), 231 CLKDEV_CON_DEV_ID("t0_clk", "f800c000.timer", &tcb0_clk),
232 CLKDEV_CON_DEV_ID("dma_clk", "ffffec00.dma-controller", &dma0_clk), 232 CLKDEV_CON_DEV_ID("dma_clk", "ffffec00.dma-controller", &dma0_clk),
233 CLKDEV_CON_DEV_ID("dma_clk", "ffffee00.dma-controller", &dma1_clk), 233 CLKDEV_CON_DEV_ID("dma_clk", "ffffee00.dma-controller", &dma1_clk),
234 CLKDEV_CON_DEV_ID("pclk", "f0010000.ssc", &ssc_clk),
234 CLKDEV_CON_DEV_ID(NULL, "f8010000.i2c", &twi0_clk), 235 CLKDEV_CON_DEV_ID(NULL, "f8010000.i2c", &twi0_clk),
235 CLKDEV_CON_DEV_ID(NULL, "f8014000.i2c", &twi1_clk), 236 CLKDEV_CON_DEV_ID(NULL, "f8014000.i2c", &twi1_clk),
236 CLKDEV_CON_DEV_ID(NULL, "f8018000.i2c", &twi2_clk), 237 CLKDEV_CON_DEV_ID(NULL, "f8018000.i2c", &twi2_clk),
diff --git a/arch/arm/mach-at91/board-sam9g20ek.c b/arch/arm/mach-at91/board-sam9g20ek.c
index 3ab2b86a3762..ebdbf42c02c1 100644
--- a/arch/arm/mach-at91/board-sam9g20ek.c
+++ b/arch/arm/mach-at91/board-sam9g20ek.c
@@ -353,6 +353,16 @@ static struct i2c_board_info __initdata ek_i2c_devices[] = {
353 }, 353 },
354}; 354};
355 355
356static struct platform_device sam9g20ek_audio_device = {
357 .name = "at91sam9g20ek-audio",
358 .id = -1,
359};
360
361static void __init ek_add_device_audio(void)
362{
363 platform_device_register(&sam9g20ek_audio_device);
364}
365
356 366
357static void __init ek_board_init(void) 367static void __init ek_board_init(void)
358{ 368{
@@ -394,6 +404,7 @@ static void __init ek_board_init(void)
394 at91_set_B_periph(AT91_PIN_PC1, 0); 404 at91_set_B_periph(AT91_PIN_PC1, 0);
395 /* SSC (for WM8731) */ 405 /* SSC (for WM8731) */
396 at91_add_device_ssc(AT91SAM9260_ID_SSC, ATMEL_SSC_TX); 406 at91_add_device_ssc(AT91SAM9260_ID_SSC, ATMEL_SSC_TX);
407 ek_add_device_audio();
397} 408}
398 409
399MACHINE_START(AT91SAM9G20EK, "Atmel AT91SAM9G20-EK") 410MACHINE_START(AT91SAM9G20EK, "Atmel AT91SAM9G20-EK")
diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
index 32ee3f895967..d9bc3fa7bb22 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -762,16 +762,19 @@ static u8 da850_iis_serializer_direction[] = {
762}; 762};
763 763
764static struct snd_platform_data da850_evm_snd_data = { 764static struct snd_platform_data da850_evm_snd_data = {
765 .tx_dma_offset = 0x2000, 765 .tx_dma_offset = 0x2000,
766 .rx_dma_offset = 0x2000, 766 .rx_dma_offset = 0x2000,
767 .op_mode = DAVINCI_MCASP_IIS_MODE, 767 .op_mode = DAVINCI_MCASP_IIS_MODE,
768 .num_serializer = ARRAY_SIZE(da850_iis_serializer_direction), 768 .num_serializer = ARRAY_SIZE(da850_iis_serializer_direction),
769 .tdm_slots = 2, 769 .tdm_slots = 2,
770 .serial_dir = da850_iis_serializer_direction, 770 .serial_dir = da850_iis_serializer_direction,
771 .asp_chan_q = EVENTQ_0, 771 .asp_chan_q = EVENTQ_0,
772 .version = MCASP_VERSION_2, 772 .ram_chan_q = EVENTQ_1,
773 .txnumevt = 1, 773 .version = MCASP_VERSION_2,
774 .rxnumevt = 1, 774 .txnumevt = 1,
775 .rxnumevt = 1,
776 .sram_size_playback = SZ_8K,
777 .sram_size_capture = SZ_8K,
775}; 778};
776 779
777static const short da850_evm_mcasp_pins[] __initconst = { 780static const short da850_evm_mcasp_pins[] __initconst = {
@@ -1509,6 +1512,7 @@ static __init void da850_evm_init(void)
1509 pr_warning("da850_evm_init: mcasp mux setup failed: %d\n", 1512 pr_warning("da850_evm_init: mcasp mux setup failed: %d\n",
1510 ret); 1513 ret);
1511 1514
1515 da850_evm_snd_data.sram_pool = sram_get_gen_pool();
1512 da8xx_register_mcasp(0, &da850_evm_snd_data); 1516 da8xx_register_mcasp(0, &da850_evm_snd_data);
1513 1517
1514 ret = davinci_cfg_reg_list(da850_lcdcntl_pins); 1518 ret = davinci_cfg_reg_list(da850_lcdcntl_pins);
diff --git a/arch/arm/mach-davinci/dm644x.c b/arch/arm/mach-davinci/dm644x.c
index cd0c8b1e1ecf..14e9947bad6e 100644
--- a/arch/arm/mach-davinci/dm644x.c
+++ b/arch/arm/mach-davinci/dm644x.c
@@ -713,8 +713,7 @@ static int dm644x_venc_setup_clock(enum vpbe_enc_timings_type type,
713 break; 713 break;
714 case VPBE_ENC_CUSTOM_TIMINGS: 714 case VPBE_ENC_CUSTOM_TIMINGS:
715 if (pclock <= 27000000) { 715 if (pclock <= 27000000) {
716 v |= DM644X_VPSS_MUXSEL_PLL2_MODE | 716 v |= DM644X_VPSS_DACCLKEN;
717 DM644X_VPSS_DACCLKEN;
718 writel(v, DAVINCI_SYSMOD_VIRT(SYSMOD_VPSS_CLKCTL)); 717 writel(v, DAVINCI_SYSMOD_VIRT(SYSMOD_VPSS_CLKCTL));
719 } else { 718 } else {
720 /* 719 /*
diff --git a/arch/arm/mach-exynos/dma.c b/arch/arm/mach-exynos/dma.c
index 21d568b3b149..87e07d6fc615 100644
--- a/arch/arm/mach-exynos/dma.c
+++ b/arch/arm/mach-exynos/dma.c
@@ -275,6 +275,9 @@ static int __init exynos_dma_init(void)
275 exynos_pdma1_pdata.nr_valid_peri = 275 exynos_pdma1_pdata.nr_valid_peri =
276 ARRAY_SIZE(exynos4210_pdma1_peri); 276 ARRAY_SIZE(exynos4210_pdma1_peri);
277 exynos_pdma1_pdata.peri_id = exynos4210_pdma1_peri; 277 exynos_pdma1_pdata.peri_id = exynos4210_pdma1_peri;
278
279 if (samsung_rev() == EXYNOS4210_REV_0)
280 exynos_mdma1_device.res.start = EXYNOS4_PA_S_MDMA1;
278 } else if (soc_is_exynos4212() || soc_is_exynos4412()) { 281 } else if (soc_is_exynos4212() || soc_is_exynos4412()) {
279 exynos_pdma0_pdata.nr_valid_peri = 282 exynos_pdma0_pdata.nr_valid_peri =
280 ARRAY_SIZE(exynos4212_pdma0_peri); 283 ARRAY_SIZE(exynos4212_pdma0_peri);
diff --git a/arch/arm/mach-exynos/include/mach/map.h b/arch/arm/mach-exynos/include/mach/map.h
index 8480849affb9..ed4da4544cd2 100644
--- a/arch/arm/mach-exynos/include/mach/map.h
+++ b/arch/arm/mach-exynos/include/mach/map.h
@@ -90,6 +90,7 @@
90 90
91#define EXYNOS4_PA_MDMA0 0x10810000 91#define EXYNOS4_PA_MDMA0 0x10810000
92#define EXYNOS4_PA_MDMA1 0x12850000 92#define EXYNOS4_PA_MDMA1 0x12850000
93#define EXYNOS4_PA_S_MDMA1 0x12840000
93#define EXYNOS4_PA_PDMA0 0x12680000 94#define EXYNOS4_PA_PDMA0 0x12680000
94#define EXYNOS4_PA_PDMA1 0x12690000 95#define EXYNOS4_PA_PDMA1 0x12690000
95#define EXYNOS5_PA_MDMA0 0x10800000 96#define EXYNOS5_PA_MDMA0 0x10800000
diff --git a/arch/arm/mach-exynos/mach-armlex4210.c b/arch/arm/mach-exynos/mach-armlex4210.c
index 3f37a5e8a1f4..b938f9fc1dd1 100644
--- a/arch/arm/mach-exynos/mach-armlex4210.c
+++ b/arch/arm/mach-exynos/mach-armlex4210.c
@@ -147,7 +147,6 @@ static struct platform_device *armlex4210_devices[] __initdata = {
147 &s3c_device_hsmmc3, 147 &s3c_device_hsmmc3,
148 &s3c_device_rtc, 148 &s3c_device_rtc,
149 &s3c_device_wdt, 149 &s3c_device_wdt,
150 &samsung_asoc_dma,
151 &armlex4210_smsc911x, 150 &armlex4210_smsc911x,
152 &exynos4_device_ahci, 151 &exynos4_device_ahci,
153}; 152};
diff --git a/arch/arm/mach-exynos/mach-smdkv310.c b/arch/arm/mach-exynos/mach-smdkv310.c
index ee4fb1a9cb72..5de9ee28a508 100644
--- a/arch/arm/mach-exynos/mach-smdkv310.c
+++ b/arch/arm/mach-exynos/mach-smdkv310.c
@@ -311,7 +311,6 @@ static struct platform_device *smdkv310_devices[] __initdata = {
311 &s5p_device_mfc_l, 311 &s5p_device_mfc_l,
312 &s5p_device_mfc_r, 312 &s5p_device_mfc_r,
313 &exynos4_device_spdif, 313 &exynos4_device_spdif,
314 &samsung_asoc_dma,
315 &samsung_asoc_idma, 314 &samsung_asoc_idma,
316 &s5p_device_fimd0, 315 &s5p_device_fimd0,
317 &smdkv310_device_audio, 316 &smdkv310_device_audio,
diff --git a/arch/arm/mach-highbank/system.c b/arch/arm/mach-highbank/system.c
index 82c27230d4a9..86e37cd9376c 100644
--- a/arch/arm/mach-highbank/system.c
+++ b/arch/arm/mach-highbank/system.c
@@ -28,6 +28,7 @@ void highbank_restart(char mode, const char *cmd)
28 hignbank_set_pwr_soft_reset(); 28 hignbank_set_pwr_soft_reset();
29 29
30 scu_power_mode(scu_base_addr, SCU_PM_POWEROFF); 30 scu_power_mode(scu_base_addr, SCU_PM_POWEROFF);
31 cpu_do_idle(); 31 while (1)
32 cpu_do_idle();
32} 33}
33 34
diff --git a/arch/arm/mach-imx/clk-gate2.c b/arch/arm/mach-imx/clk-gate2.c
index 3c1b8ff9a0a6..cc49c7ae186e 100644
--- a/arch/arm/mach-imx/clk-gate2.c
+++ b/arch/arm/mach-imx/clk-gate2.c
@@ -112,7 +112,7 @@ struct clk *clk_register_gate2(struct device *dev, const char *name,
112 112
113 clk = clk_register(dev, &gate->hw); 113 clk = clk_register(dev, &gate->hw);
114 if (IS_ERR(clk)) 114 if (IS_ERR(clk))
115 kfree(clk); 115 kfree(gate);
116 116
117 return clk; 117 return clk;
118} 118}
diff --git a/arch/arm/mach-imx/ehci-imx25.c b/arch/arm/mach-imx/ehci-imx25.c
index 412c583a24b0..576af7446952 100644
--- a/arch/arm/mach-imx/ehci-imx25.c
+++ b/arch/arm/mach-imx/ehci-imx25.c
@@ -30,7 +30,7 @@
30#define MX25_H1_SIC_SHIFT 21 30#define MX25_H1_SIC_SHIFT 21
31#define MX25_H1_SIC_MASK (0x3 << MX25_H1_SIC_SHIFT) 31#define MX25_H1_SIC_MASK (0x3 << MX25_H1_SIC_SHIFT)
32#define MX25_H1_PP_BIT (1 << 18) 32#define MX25_H1_PP_BIT (1 << 18)
33#define MX25_H1_PM_BIT (1 << 8) 33#define MX25_H1_PM_BIT (1 << 16)
34#define MX25_H1_IPPUE_UP_BIT (1 << 7) 34#define MX25_H1_IPPUE_UP_BIT (1 << 7)
35#define MX25_H1_IPPUE_DOWN_BIT (1 << 6) 35#define MX25_H1_IPPUE_DOWN_BIT (1 << 6)
36#define MX25_H1_TLL_BIT (1 << 5) 36#define MX25_H1_TLL_BIT (1 << 5)
diff --git a/arch/arm/mach-imx/ehci-imx35.c b/arch/arm/mach-imx/ehci-imx35.c
index 779e16eb65cb..293397852e4e 100644
--- a/arch/arm/mach-imx/ehci-imx35.c
+++ b/arch/arm/mach-imx/ehci-imx35.c
@@ -30,7 +30,7 @@
30#define MX35_H1_SIC_SHIFT 21 30#define MX35_H1_SIC_SHIFT 21
31#define MX35_H1_SIC_MASK (0x3 << MX35_H1_SIC_SHIFT) 31#define MX35_H1_SIC_MASK (0x3 << MX35_H1_SIC_SHIFT)
32#define MX35_H1_PP_BIT (1 << 18) 32#define MX35_H1_PP_BIT (1 << 18)
33#define MX35_H1_PM_BIT (1 << 8) 33#define MX35_H1_PM_BIT (1 << 16)
34#define MX35_H1_IPPUE_UP_BIT (1 << 7) 34#define MX35_H1_IPPUE_UP_BIT (1 << 7)
35#define MX35_H1_IPPUE_DOWN_BIT (1 << 6) 35#define MX35_H1_IPPUE_DOWN_BIT (1 << 6)
36#define MX35_H1_TLL_BIT (1 << 5) 36#define MX35_H1_TLL_BIT (1 << 5)
diff --git a/arch/arm/mach-omap2/board-igep0020.c b/arch/arm/mach-omap2/board-igep0020.c
index 48d5e41dfbfa..378590694447 100644
--- a/arch/arm/mach-omap2/board-igep0020.c
+++ b/arch/arm/mach-omap2/board-igep0020.c
@@ -580,6 +580,11 @@ static void __init igep_wlan_bt_init(void)
580 } else 580 } else
581 return; 581 return;
582 582
583 /* Make sure that the GPIO pins are muxed correctly */
584 omap_mux_init_gpio(igep_wlan_bt_gpios[0].gpio, OMAP_PIN_OUTPUT);
585 omap_mux_init_gpio(igep_wlan_bt_gpios[1].gpio, OMAP_PIN_OUTPUT);
586 omap_mux_init_gpio(igep_wlan_bt_gpios[2].gpio, OMAP_PIN_OUTPUT);
587
583 err = gpio_request_array(igep_wlan_bt_gpios, 588 err = gpio_request_array(igep_wlan_bt_gpios,
584 ARRAY_SIZE(igep_wlan_bt_gpios)); 589 ARRAY_SIZE(igep_wlan_bt_gpios));
585 if (err) { 590 if (err) {
diff --git a/arch/arm/mach-omap2/clockdomains44xx_data.c b/arch/arm/mach-omap2/clockdomains44xx_data.c
index b56d06b48782..95192a062d5d 100644
--- a/arch/arm/mach-omap2/clockdomains44xx_data.c
+++ b/arch/arm/mach-omap2/clockdomains44xx_data.c
@@ -359,7 +359,7 @@ static struct clockdomain iss_44xx_clkdm = {
359 .clkdm_offs = OMAP4430_CM2_CAM_CAM_CDOFFS, 359 .clkdm_offs = OMAP4430_CM2_CAM_CAM_CDOFFS,
360 .wkdep_srcs = iss_wkup_sleep_deps, 360 .wkdep_srcs = iss_wkup_sleep_deps,
361 .sleepdep_srcs = iss_wkup_sleep_deps, 361 .sleepdep_srcs = iss_wkup_sleep_deps,
362 .flags = CLKDM_CAN_HWSUP_SWSUP, 362 .flags = CLKDM_CAN_SWSUP,
363}; 363};
364 364
365static struct clockdomain l3_dss_44xx_clkdm = { 365static struct clockdomain l3_dss_44xx_clkdm = {
diff --git a/arch/arm/mach-omap2/common-board-devices.c b/arch/arm/mach-omap2/common-board-devices.c
index 48daac2581b4..84551f205e46 100644
--- a/arch/arm/mach-omap2/common-board-devices.c
+++ b/arch/arm/mach-omap2/common-board-devices.c
@@ -64,30 +64,36 @@ void __init omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,
64 struct spi_board_info *spi_bi = &ads7846_spi_board_info; 64 struct spi_board_info *spi_bi = &ads7846_spi_board_info;
65 int err; 65 int err;
66 66
67 err = gpio_request_one(gpio_pendown, GPIOF_IN, "TSPenDown"); 67 /*
68 if (err) { 68 * If a board defines get_pendown_state() function, request the pendown
69 pr_err("Couldn't obtain gpio for TSPenDown: %d\n", err); 69 * GPIO and set the GPIO debounce time.
70 return; 70 * If a board does not define the get_pendown_state() function, then
71 } 71 * the ads7846 driver will setup the pendown GPIO itself.
72 */
73 if (board_pdata && board_pdata->get_pendown_state) {
74 err = gpio_request_one(gpio_pendown, GPIOF_IN, "TSPenDown");
75 if (err) {
76 pr_err("Couldn't obtain gpio for TSPenDown: %d\n", err);
77 return;
78 }
72 79
73 if (gpio_debounce) 80 if (gpio_debounce)
74 gpio_set_debounce(gpio_pendown, gpio_debounce); 81 gpio_set_debounce(gpio_pendown, gpio_debounce);
82
83 gpio_export(gpio_pendown, 0);
84 }
75 85
76 spi_bi->bus_num = bus_num; 86 spi_bi->bus_num = bus_num;
77 spi_bi->irq = gpio_to_irq(gpio_pendown); 87 spi_bi->irq = gpio_to_irq(gpio_pendown);
78 88
89 ads7846_config.gpio_pendown = gpio_pendown;
90
79 if (board_pdata) { 91 if (board_pdata) {
80 board_pdata->gpio_pendown = gpio_pendown; 92 board_pdata->gpio_pendown = gpio_pendown;
93 board_pdata->gpio_pendown_debounce = gpio_debounce;
81 spi_bi->platform_data = board_pdata; 94 spi_bi->platform_data = board_pdata;
82 if (board_pdata->get_pendown_state)
83 gpio_export(gpio_pendown, 0);
84 } else {
85 ads7846_config.gpio_pendown = gpio_pendown;
86 } 95 }
87 96
88 if (!board_pdata || (board_pdata && !board_pdata->get_pendown_state))
89 gpio_free(gpio_pendown);
90
91 spi_register_board_info(&ads7846_spi_board_info, 1); 97 spi_register_board_info(&ads7846_spi_board_info, 1);
92} 98}
93#else 99#else
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index cba60e05e32e..c72b5a727720 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -19,6 +19,7 @@
19#include <linux/of.h> 19#include <linux/of.h>
20#include <linux/pinctrl/machine.h> 20#include <linux/pinctrl/machine.h>
21#include <linux/platform_data/omap4-keypad.h> 21#include <linux/platform_data/omap4-keypad.h>
22#include <linux/platform_data/omap_ocp2scp.h>
22 23
23#include <asm/mach-types.h> 24#include <asm/mach-types.h>
24#include <asm/mach/map.h> 25#include <asm/mach/map.h>
@@ -613,6 +614,83 @@ static void omap_init_vout(void)
613static inline void omap_init_vout(void) {} 614static inline void omap_init_vout(void) {}
614#endif 615#endif
615 616
617#if defined(CONFIG_OMAP_OCP2SCP) || defined(CONFIG_OMAP_OCP2SCP_MODULE)
618static int count_ocp2scp_devices(struct omap_ocp2scp_dev *ocp2scp_dev)
619{
620 int cnt = 0;
621
622 while (ocp2scp_dev->drv_name != NULL) {
623 cnt++;
624 ocp2scp_dev++;
625 }
626
627 return cnt;
628}
629
630static void omap_init_ocp2scp(void)
631{
632 struct omap_hwmod *oh;
633 struct platform_device *pdev;
634 int bus_id = -1, dev_cnt = 0, i;
635 struct omap_ocp2scp_dev *ocp2scp_dev;
636 const char *oh_name, *name;
637 struct omap_ocp2scp_platform_data *pdata;
638
639 if (!cpu_is_omap44xx())
640 return;
641
642 oh_name = "ocp2scp_usb_phy";
643 name = "omap-ocp2scp";
644
645 oh = omap_hwmod_lookup(oh_name);
646 if (!oh) {
647 pr_err("%s: could not find omap_hwmod for %s\n", __func__,
648 oh_name);
649 return;
650 }
651
652 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
653 if (!pdata) {
654 pr_err("%s: No memory for ocp2scp pdata\n", __func__);
655 return;
656 }
657
658 ocp2scp_dev = oh->dev_attr;
659 dev_cnt = count_ocp2scp_devices(ocp2scp_dev);
660
661 if (!dev_cnt) {
662 pr_err("%s: No devices connected to ocp2scp\n", __func__);
663 kfree(pdata);
664 return;
665 }
666
667 pdata->devices = kzalloc(sizeof(struct omap_ocp2scp_dev *)
668 * dev_cnt, GFP_KERNEL);
669 if (!pdata->devices) {
670 pr_err("%s: No memory for ocp2scp pdata devices\n", __func__);
671 kfree(pdata);
672 return;
673 }
674
675 for (i = 0; i < dev_cnt; i++, ocp2scp_dev++)
676 pdata->devices[i] = ocp2scp_dev;
677
678 pdata->dev_cnt = dev_cnt;
679
680 pdev = omap_device_build(name, bus_id, oh, pdata, sizeof(*pdata), NULL,
681 0, false);
682 if (IS_ERR(pdev)) {
683 pr_err("Could not build omap_device for %s %s\n",
684 name, oh_name);
685 kfree(pdata->devices);
686 kfree(pdata);
687 return;
688 }
689}
690#else
691static inline void omap_init_ocp2scp(void) { }
692#endif
693
616/*-------------------------------------------------------------------------*/ 694/*-------------------------------------------------------------------------*/
617 695
618static int __init omap2_init_devices(void) 696static int __init omap2_init_devices(void)
@@ -640,6 +718,7 @@ static int __init omap2_init_devices(void)
640 omap_init_sham(); 718 omap_init_sham();
641 omap_init_aes(); 719 omap_init_aes();
642 omap_init_vout(); 720 omap_init_vout();
721 omap_init_ocp2scp();
643 722
644 return 0; 723 return 0;
645} 724}
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index b969ab1d258b..87cc6d058de2 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -422,6 +422,38 @@ static int _set_softreset(struct omap_hwmod *oh, u32 *v)
422} 422}
423 423
424/** 424/**
425 * _wait_softreset_complete - wait for an OCP softreset to complete
426 * @oh: struct omap_hwmod * to wait on
427 *
428 * Wait until the IP block represented by @oh reports that its OCP
429 * softreset is complete. This can be triggered by software (see
430 * _ocp_softreset()) or by hardware upon returning from off-mode (one
431 * example is HSMMC). Waits for up to MAX_MODULE_SOFTRESET_WAIT
432 * microseconds. Returns the number of microseconds waited.
433 */
434static int _wait_softreset_complete(struct omap_hwmod *oh)
435{
436 struct omap_hwmod_class_sysconfig *sysc;
437 u32 softrst_mask;
438 int c = 0;
439
440 sysc = oh->class->sysc;
441
442 if (sysc->sysc_flags & SYSS_HAS_RESET_STATUS)
443 omap_test_timeout((omap_hwmod_read(oh, sysc->syss_offs)
444 & SYSS_RESETDONE_MASK),
445 MAX_MODULE_SOFTRESET_WAIT, c);
446 else if (sysc->sysc_flags & SYSC_HAS_RESET_STATUS) {
447 softrst_mask = (0x1 << sysc->sysc_fields->srst_shift);
448 omap_test_timeout(!(omap_hwmod_read(oh, sysc->sysc_offs)
449 & softrst_mask),
450 MAX_MODULE_SOFTRESET_WAIT, c);
451 }
452
453 return c;
454}
455
456/**
425 * _set_dmadisable: set OCP_SYSCONFIG.DMADISABLE bit in @v 457 * _set_dmadisable: set OCP_SYSCONFIG.DMADISABLE bit in @v
426 * @oh: struct omap_hwmod * 458 * @oh: struct omap_hwmod *
427 * 459 *
@@ -1282,6 +1314,18 @@ static void _enable_sysc(struct omap_hwmod *oh)
1282 if (!oh->class->sysc) 1314 if (!oh->class->sysc)
1283 return; 1315 return;
1284 1316
1317 /*
1318 * Wait until reset has completed, this is needed as the IP
1319 * block is reset automatically by hardware in some cases
1320 * (off-mode for example), and the drivers require the
1321 * IP to be ready when they access it
1322 */
1323 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET)
1324 _enable_optional_clocks(oh);
1325 _wait_softreset_complete(oh);
1326 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET)
1327 _disable_optional_clocks(oh);
1328
1285 v = oh->_sysc_cache; 1329 v = oh->_sysc_cache;
1286 sf = oh->class->sysc->sysc_flags; 1330 sf = oh->class->sysc->sysc_flags;
1287 1331
@@ -1804,7 +1848,7 @@ static int _am33xx_disable_module(struct omap_hwmod *oh)
1804 */ 1848 */
1805static int _ocp_softreset(struct omap_hwmod *oh) 1849static int _ocp_softreset(struct omap_hwmod *oh)
1806{ 1850{
1807 u32 v, softrst_mask; 1851 u32 v;
1808 int c = 0; 1852 int c = 0;
1809 int ret = 0; 1853 int ret = 0;
1810 1854
@@ -1834,19 +1878,7 @@ static int _ocp_softreset(struct omap_hwmod *oh)
1834 if (oh->class->sysc->srst_udelay) 1878 if (oh->class->sysc->srst_udelay)
1835 udelay(oh->class->sysc->srst_udelay); 1879 udelay(oh->class->sysc->srst_udelay);
1836 1880
1837 if (oh->class->sysc->sysc_flags & SYSS_HAS_RESET_STATUS) 1881 c = _wait_softreset_complete(oh);
1838 omap_test_timeout((omap_hwmod_read(oh,
1839 oh->class->sysc->syss_offs)
1840 & SYSS_RESETDONE_MASK),
1841 MAX_MODULE_SOFTRESET_WAIT, c);
1842 else if (oh->class->sysc->sysc_flags & SYSC_HAS_RESET_STATUS) {
1843 softrst_mask = (0x1 << oh->class->sysc->sysc_fields->srst_shift);
1844 omap_test_timeout(!(omap_hwmod_read(oh,
1845 oh->class->sysc->sysc_offs)
1846 & softrst_mask),
1847 MAX_MODULE_SOFTRESET_WAIT, c);
1848 }
1849
1850 if (c == MAX_MODULE_SOFTRESET_WAIT) 1882 if (c == MAX_MODULE_SOFTRESET_WAIT)
1851 pr_warning("omap_hwmod: %s: softreset failed (waited %d usec)\n", 1883 pr_warning("omap_hwmod: %s: softreset failed (waited %d usec)\n",
1852 oh->name, MAX_MODULE_SOFTRESET_WAIT); 1884 oh->name, MAX_MODULE_SOFTRESET_WAIT);
@@ -2352,6 +2384,9 @@ static int __init _setup_reset(struct omap_hwmod *oh)
2352 if (oh->_state != _HWMOD_STATE_INITIALIZED) 2384 if (oh->_state != _HWMOD_STATE_INITIALIZED)
2353 return -EINVAL; 2385 return -EINVAL;
2354 2386
2387 if (oh->flags & HWMOD_EXT_OPT_MAIN_CLK)
2388 return -EPERM;
2389
2355 if (oh->rst_lines_cnt == 0) { 2390 if (oh->rst_lines_cnt == 0) {
2356 r = _enable(oh); 2391 r = _enable(oh);
2357 if (r) { 2392 if (r) {
diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
index 652d0285bd6d..0b1249e00398 100644
--- a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
@@ -21,6 +21,7 @@
21#include <linux/io.h> 21#include <linux/io.h>
22#include <linux/platform_data/gpio-omap.h> 22#include <linux/platform_data/gpio-omap.h>
23#include <linux/power/smartreflex.h> 23#include <linux/power/smartreflex.h>
24#include <linux/platform_data/omap_ocp2scp.h>
24 25
25#include <plat/omap_hwmod.h> 26#include <plat/omap_hwmod.h>
26#include <plat/i2c.h> 27#include <plat/i2c.h>
@@ -2125,6 +2126,14 @@ static struct omap_hwmod omap44xx_mcpdm_hwmod = {
2125 .name = "mcpdm", 2126 .name = "mcpdm",
2126 .class = &omap44xx_mcpdm_hwmod_class, 2127 .class = &omap44xx_mcpdm_hwmod_class,
2127 .clkdm_name = "abe_clkdm", 2128 .clkdm_name = "abe_clkdm",
2129 /*
2130 * It's suspected that the McPDM requires an off-chip main
2131 * functional clock, controlled via I2C. This IP block is
2132 * currently reset very early during boot, before I2C is
2133 * available, so it doesn't seem that we have any choice in
2134 * the kernel other than to avoid resetting it.
2135 */
2136 .flags = HWMOD_EXT_OPT_MAIN_CLK,
2128 .mpu_irqs = omap44xx_mcpdm_irqs, 2137 .mpu_irqs = omap44xx_mcpdm_irqs,
2129 .sdma_reqs = omap44xx_mcpdm_sdma_reqs, 2138 .sdma_reqs = omap44xx_mcpdm_sdma_reqs,
2130 .main_clk = "mcpdm_fck", 2139 .main_clk = "mcpdm_fck",
@@ -2681,6 +2690,32 @@ static struct omap_hwmod_class omap44xx_ocp2scp_hwmod_class = {
2681 .sysc = &omap44xx_ocp2scp_sysc, 2690 .sysc = &omap44xx_ocp2scp_sysc,
2682}; 2691};
2683 2692
2693/* ocp2scp dev_attr */
2694static struct resource omap44xx_usb_phy_and_pll_addrs[] = {
2695 {
2696 .name = "usb_phy",
2697 .start = 0x4a0ad080,
2698 .end = 0x4a0ae000,
2699 .flags = IORESOURCE_MEM,
2700 },
2701 {
2702 /* XXX: Remove this once control module driver is in place */
2703 .name = "ctrl_dev",
2704 .start = 0x4a002300,
2705 .end = 0x4a002303,
2706 .flags = IORESOURCE_MEM,
2707 },
2708 { }
2709};
2710
2711static struct omap_ocp2scp_dev ocp2scp_dev_attr[] = {
2712 {
2713 .drv_name = "omap-usb2",
2714 .res = omap44xx_usb_phy_and_pll_addrs,
2715 },
2716 { }
2717};
2718
2684/* ocp2scp_usb_phy */ 2719/* ocp2scp_usb_phy */
2685static struct omap_hwmod omap44xx_ocp2scp_usb_phy_hwmod = { 2720static struct omap_hwmod omap44xx_ocp2scp_usb_phy_hwmod = {
2686 .name = "ocp2scp_usb_phy", 2721 .name = "ocp2scp_usb_phy",
@@ -2694,6 +2729,7 @@ static struct omap_hwmod omap44xx_ocp2scp_usb_phy_hwmod = {
2694 .modulemode = MODULEMODE_HWCTRL, 2729 .modulemode = MODULEMODE_HWCTRL,
2695 }, 2730 },
2696 }, 2731 },
2732 .dev_attr = ocp2scp_dev_attr,
2697}; 2733};
2698 2734
2699/* 2735/*
diff --git a/arch/arm/mach-omap2/twl-common.c b/arch/arm/mach-omap2/twl-common.c
index 635e109f5ad3..a256135d8e48 100644
--- a/arch/arm/mach-omap2/twl-common.c
+++ b/arch/arm/mach-omap2/twl-common.c
@@ -73,6 +73,7 @@ void __init omap4_pmic_init(const char *pmic_type,
73{ 73{
74 /* PMIC part*/ 74 /* PMIC part*/
75 omap_mux_init_signal("sys_nirq1", OMAP_PIN_INPUT_PULLUP | OMAP_PIN_OFF_WAKEUPENABLE); 75 omap_mux_init_signal("sys_nirq1", OMAP_PIN_INPUT_PULLUP | OMAP_PIN_OFF_WAKEUPENABLE);
76 omap_mux_init_signal("fref_clk0_out.sys_drm_msecure", OMAP_PIN_OUTPUT);
76 omap_pmic_init(1, 400, pmic_type, 7 + OMAP44XX_IRQ_GIC_START, pmic_data); 77 omap_pmic_init(1, 400, pmic_type, 7 + OMAP44XX_IRQ_GIC_START, pmic_data);
77 78
78 /* Register additional devices on i2c1 bus if needed */ 79 /* Register additional devices on i2c1 bus if needed */
@@ -366,7 +367,7 @@ static struct regulator_init_data omap4_clk32kg_idata = {
366}; 367};
367 368
368static struct regulator_consumer_supply omap4_vdd1_supply[] = { 369static struct regulator_consumer_supply omap4_vdd1_supply[] = {
369 REGULATOR_SUPPLY("vcc", "mpu.0"), 370 REGULATOR_SUPPLY("vcc", "cpu0"),
370}; 371};
371 372
372static struct regulator_consumer_supply omap4_vdd2_supply[] = { 373static struct regulator_consumer_supply omap4_vdd2_supply[] = {
diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c
index 880249b17012..75878c37959b 100644
--- a/arch/arm/mach-omap2/vc.c
+++ b/arch/arm/mach-omap2/vc.c
@@ -264,7 +264,7 @@ static void __init omap_vc_i2c_init(struct voltagedomain *voltdm)
264 264
265 if (initialized) { 265 if (initialized) {
266 if (voltdm->pmic->i2c_high_speed != i2c_high_speed) 266 if (voltdm->pmic->i2c_high_speed != i2c_high_speed)
267 pr_warn("%s: I2C config for vdd_%s does not match other channels (%u).", 267 pr_warn("%s: I2C config for vdd_%s does not match other channels (%u).\n",
268 __func__, voltdm->name, i2c_high_speed); 268 __func__, voltdm->name, i2c_high_speed);
269 return; 269 return;
270 } 270 }
diff --git a/arch/arm/mach-pxa/hx4700.c b/arch/arm/mach-pxa/hx4700.c
index 5ecbd17b5641..e2c6391863fe 100644
--- a/arch/arm/mach-pxa/hx4700.c
+++ b/arch/arm/mach-pxa/hx4700.c
@@ -28,6 +28,7 @@
28#include <linux/mfd/asic3.h> 28#include <linux/mfd/asic3.h>
29#include <linux/mtd/physmap.h> 29#include <linux/mtd/physmap.h>
30#include <linux/pda_power.h> 30#include <linux/pda_power.h>
31#include <linux/pwm.h>
31#include <linux/pwm_backlight.h> 32#include <linux/pwm_backlight.h>
32#include <linux/regulator/driver.h> 33#include <linux/regulator/driver.h>
33#include <linux/regulator/gpio-regulator.h> 34#include <linux/regulator/gpio-regulator.h>
@@ -556,7 +557,7 @@ static struct platform_device hx4700_lcd = {
556 */ 557 */
557 558
558static struct platform_pwm_backlight_data backlight_data = { 559static struct platform_pwm_backlight_data backlight_data = {
559 .pwm_id = 1, 560 .pwm_id = -1, /* Superseded by pwm_lookup */
560 .max_brightness = 200, 561 .max_brightness = 200,
561 .dft_brightness = 100, 562 .dft_brightness = 100,
562 .pwm_period_ns = 30923, 563 .pwm_period_ns = 30923,
@@ -571,6 +572,10 @@ static struct platform_device backlight = {
571 }, 572 },
572}; 573};
573 574
575static struct pwm_lookup hx4700_pwm_lookup[] = {
576 PWM_LOOKUP("pxa27x-pwm.1", 0, "pwm-backlight", NULL),
577};
578
574/* 579/*
575 * USB "Transceiver" 580 * USB "Transceiver"
576 */ 581 */
@@ -872,6 +877,7 @@ static void __init hx4700_init(void)
872 pxa_set_stuart_info(NULL); 877 pxa_set_stuart_info(NULL);
873 878
874 platform_add_devices(devices, ARRAY_SIZE(devices)); 879 platform_add_devices(devices, ARRAY_SIZE(devices));
880 pwm_add_table(hx4700_pwm_lookup, ARRAY_SIZE(hx4700_pwm_lookup));
875 881
876 pxa_set_ficp_info(&ficp_info); 882 pxa_set_ficp_info(&ficp_info);
877 pxa27x_set_i2c_power_info(NULL); 883 pxa27x_set_i2c_power_info(NULL);
diff --git a/arch/arm/mach-pxa/spitz_pm.c b/arch/arm/mach-pxa/spitz_pm.c
index 438f02fe122a..842596d4d31e 100644
--- a/arch/arm/mach-pxa/spitz_pm.c
+++ b/arch/arm/mach-pxa/spitz_pm.c
@@ -86,10 +86,7 @@ static void spitz_discharge1(int on)
86 gpio_set_value(SPITZ_GPIO_LED_GREEN, on); 86 gpio_set_value(SPITZ_GPIO_LED_GREEN, on);
87} 87}
88 88
89static unsigned long gpio18_config[] = { 89static unsigned long gpio18_config = GPIO18_GPIO;
90 GPIO18_RDY,
91 GPIO18_GPIO,
92};
93 90
94static void spitz_presuspend(void) 91static void spitz_presuspend(void)
95{ 92{
@@ -112,7 +109,7 @@ static void spitz_presuspend(void)
112 PGSR3 &= ~SPITZ_GPIO_G3_STROBE_BIT; 109 PGSR3 &= ~SPITZ_GPIO_G3_STROBE_BIT;
113 PGSR2 |= GPIO_bit(SPITZ_GPIO_KEY_STROBE0); 110 PGSR2 |= GPIO_bit(SPITZ_GPIO_KEY_STROBE0);
114 111
115 pxa2xx_mfp_config(&gpio18_config[0], 1); 112 pxa2xx_mfp_config(&gpio18_config, 1);
116 gpio_request_one(18, GPIOF_OUT_INIT_HIGH, "Unknown"); 113 gpio_request_one(18, GPIOF_OUT_INIT_HIGH, "Unknown");
117 gpio_free(18); 114 gpio_free(18);
118 115
@@ -131,7 +128,6 @@ static void spitz_presuspend(void)
131 128
132static void spitz_postsuspend(void) 129static void spitz_postsuspend(void)
133{ 130{
134 pxa2xx_mfp_config(&gpio18_config[1], 1);
135} 131}
136 132
137static int spitz_should_wakeup(unsigned int resume_on_alarm) 133static int spitz_should_wakeup(unsigned int resume_on_alarm)
diff --git a/arch/arm/mach-s3c24xx/mach-gta02.c b/arch/arm/mach-s3c24xx/mach-gta02.c
index 4a963467b7ee..973b87ca87f4 100644
--- a/arch/arm/mach-s3c24xx/mach-gta02.c
+++ b/arch/arm/mach-s3c24xx/mach-gta02.c
@@ -521,7 +521,6 @@ static struct platform_device *gta02_devices[] __initdata = {
521 &gta02_nor_flash, 521 &gta02_nor_flash,
522 &s3c24xx_pwm_device, 522 &s3c24xx_pwm_device,
523 &s3c_device_iis, 523 &s3c_device_iis,
524 &samsung_asoc_dma,
525 &s3c_device_i2c0, 524 &s3c_device_i2c0,
526 &gta02_dfbmcs320_device, 525 &gta02_dfbmcs320_device,
527 &gta02_buttons_device, 526 &gta02_buttons_device,
diff --git a/arch/arm/mach-s3c24xx/mach-h1940.c b/arch/arm/mach-s3c24xx/mach-h1940.c
index 63aaf076f611..b23dd1b106e8 100644
--- a/arch/arm/mach-s3c24xx/mach-h1940.c
+++ b/arch/arm/mach-s3c24xx/mach-h1940.c
@@ -632,7 +632,6 @@ static struct platform_device *h1940_devices[] __initdata = {
632 &s3c_device_wdt, 632 &s3c_device_wdt,
633 &s3c_device_i2c0, 633 &s3c_device_i2c0,
634 &s3c_device_iis, 634 &s3c_device_iis,
635 &samsung_asoc_dma,
636 &s3c_device_usbgadget, 635 &s3c_device_usbgadget,
637 &h1940_device_leds, 636 &h1940_device_leds,
638 &h1940_device_bluetooth, 637 &h1940_device_bluetooth,
diff --git a/arch/arm/mach-s3c24xx/mach-mini2440.c b/arch/arm/mach-s3c24xx/mach-mini2440.c
index 393c0f1ac11a..a31d5b83e5f7 100644
--- a/arch/arm/mach-s3c24xx/mach-mini2440.c
+++ b/arch/arm/mach-s3c24xx/mach-mini2440.c
@@ -519,7 +519,6 @@ static struct platform_device *mini2440_devices[] __initdata = {
519 &s3c_device_iis, 519 &s3c_device_iis,
520 &uda1340_codec, 520 &uda1340_codec,
521 &mini2440_audio, 521 &mini2440_audio,
522 &samsung_asoc_dma,
523}; 522};
524 523
525static void __init mini2440_map_io(void) 524static void __init mini2440_map_io(void)
diff --git a/arch/arm/mach-s3c24xx/mach-rx1950.c b/arch/arm/mach-s3c24xx/mach-rx1950.c
index 379fde521d37..0606f2faaa5c 100644
--- a/arch/arm/mach-s3c24xx/mach-rx1950.c
+++ b/arch/arm/mach-s3c24xx/mach-rx1950.c
@@ -712,7 +712,6 @@ static struct platform_device *rx1950_devices[] __initdata = {
712 &s3c_device_wdt, 712 &s3c_device_wdt,
713 &s3c_device_i2c0, 713 &s3c_device_i2c0,
714 &s3c_device_iis, 714 &s3c_device_iis,
715 &samsung_asoc_dma,
716 &s3c_device_usbgadget, 715 &s3c_device_usbgadget,
717 &s3c_device_rtc, 716 &s3c_device_rtc,
718 &s3c_device_nand, 717 &s3c_device_nand,
diff --git a/arch/arm/mach-s3c64xx/mach-crag6410.c b/arch/arm/mach-s3c64xx/mach-crag6410.c
index 13b7eaa45fd0..ef2117d7391b 100644
--- a/arch/arm/mach-s3c64xx/mach-crag6410.c
+++ b/arch/arm/mach-s3c64xx/mach-crag6410.c
@@ -357,7 +357,6 @@ static struct platform_device *crag6410_devices[] __initdata = {
357 &s3c_device_timer[0], 357 &s3c_device_timer[0],
358 &s3c64xx_device_iis0, 358 &s3c64xx_device_iis0,
359 &s3c64xx_device_iis1, 359 &s3c64xx_device_iis1,
360 &samsung_asoc_dma,
361 &samsung_device_keypad, 360 &samsung_device_keypad,
362 &crag6410_gpio_keydev, 361 &crag6410_gpio_keydev,
363 &crag6410_dm9k_device, 362 &crag6410_dm9k_device,
diff --git a/arch/arm/mach-s3c64xx/mach-smdk6410.c b/arch/arm/mach-s3c64xx/mach-smdk6410.c
index da1a771a29e9..574a9eef588d 100644
--- a/arch/arm/mach-s3c64xx/mach-smdk6410.c
+++ b/arch/arm/mach-s3c64xx/mach-smdk6410.c
@@ -275,7 +275,6 @@ static struct platform_device *smdk6410_devices[] __initdata = {
275 &s3c_device_fb, 275 &s3c_device_fb,
276 &s3c_device_ohci, 276 &s3c_device_ohci,
277 &s3c_device_usb_hsotg, 277 &s3c_device_usb_hsotg,
278 &samsung_asoc_dma,
279 &s3c64xx_device_iisv4, 278 &s3c64xx_device_iisv4,
280 &samsung_device_keypad, 279 &samsung_device_keypad,
281 280
diff --git a/arch/arm/mach-s5p64x0/mach-smdk6440.c b/arch/arm/mach-s5p64x0/mach-smdk6440.c
index 96ea1fe0ec94..1af823558c60 100644
--- a/arch/arm/mach-s5p64x0/mach-smdk6440.c
+++ b/arch/arm/mach-s5p64x0/mach-smdk6440.c
@@ -165,7 +165,6 @@ static struct platform_device *smdk6440_devices[] __initdata = {
165 &s3c_device_i2c1, 165 &s3c_device_i2c1,
166 &s3c_device_ts, 166 &s3c_device_ts,
167 &s3c_device_wdt, 167 &s3c_device_wdt,
168 &samsung_asoc_dma,
169 &s5p6440_device_iis, 168 &s5p6440_device_iis,
170 &s3c_device_fb, 169 &s3c_device_fb,
171 &smdk6440_lcd_lte480wv, 170 &smdk6440_lcd_lte480wv,
diff --git a/arch/arm/mach-s5p64x0/mach-smdk6450.c b/arch/arm/mach-s5p64x0/mach-smdk6450.c
index 12748b6eaa7b..62526ccf6b70 100644
--- a/arch/arm/mach-s5p64x0/mach-smdk6450.c
+++ b/arch/arm/mach-s5p64x0/mach-smdk6450.c
@@ -183,7 +183,6 @@ static struct platform_device *smdk6450_devices[] __initdata = {
183 &s3c_device_i2c1, 183 &s3c_device_i2c1,
184 &s3c_device_ts, 184 &s3c_device_ts,
185 &s3c_device_wdt, 185 &s3c_device_wdt,
186 &samsung_asoc_dma,
187 &s5p6450_device_iis0, 186 &s5p6450_device_iis0,
188 &s3c_device_fb, 187 &s3c_device_fb,
189 &smdk6450_lcd_lte480wv, 188 &smdk6450_lcd_lte480wv,
diff --git a/arch/arm/mach-s5pc100/mach-smdkc100.c b/arch/arm/mach-s5pc100/mach-smdkc100.c
index dba7384a87bd..9abe95e806ab 100644
--- a/arch/arm/mach-s5pc100/mach-smdkc100.c
+++ b/arch/arm/mach-s5pc100/mach-smdkc100.c
@@ -197,7 +197,6 @@ static struct platform_device *smdkc100_devices[] __initdata = {
197 &s3c_device_ts, 197 &s3c_device_ts,
198 &s3c_device_wdt, 198 &s3c_device_wdt,
199 &smdkc100_lcd_powerdev, 199 &smdkc100_lcd_powerdev,
200 &samsung_asoc_dma,
201 &s5pc100_device_iis0, 200 &s5pc100_device_iis0,
202 &samsung_device_keypad, 201 &samsung_device_keypad,
203 &s5pc100_device_ac97, 202 &s5pc100_device_ac97,
diff --git a/arch/arm/mach-s5pv210/mach-smdkc110.c b/arch/arm/mach-s5pv210/mach-smdkc110.c
index d9c99fcc1aa7..f1f3bd37ecda 100644
--- a/arch/arm/mach-s5pv210/mach-smdkc110.c
+++ b/arch/arm/mach-s5pv210/mach-smdkc110.c
@@ -85,7 +85,6 @@ static struct s3c_ide_platdata smdkc110_ide_pdata __initdata = {
85}; 85};
86 86
87static struct platform_device *smdkc110_devices[] __initdata = { 87static struct platform_device *smdkc110_devices[] __initdata = {
88 &samsung_asoc_dma,
89 &s5pv210_device_iis0, 88 &s5pv210_device_iis0,
90 &s5pv210_device_ac97, 89 &s5pv210_device_ac97,
91 &s5pv210_device_spdif, 90 &s5pv210_device_spdif,
diff --git a/arch/arm/mach-s5pv210/mach-smdkv210.c b/arch/arm/mach-s5pv210/mach-smdkv210.c
index 4cdb5bb7bbcf..6bc8404bf678 100644
--- a/arch/arm/mach-s5pv210/mach-smdkv210.c
+++ b/arch/arm/mach-s5pv210/mach-smdkv210.c
@@ -234,7 +234,6 @@ static struct platform_device *smdkv210_devices[] __initdata = {
234 &s5pv210_device_ac97, 234 &s5pv210_device_ac97,
235 &s5pv210_device_iis0, 235 &s5pv210_device_iis0,
236 &s5pv210_device_spdif, 236 &s5pv210_device_spdif,
237 &samsung_asoc_dma,
238 &samsung_asoc_idma, 237 &samsung_asoc_idma,
239 &samsung_device_keypad, 238 &samsung_device_keypad,
240 &smdkv210_dm9000, 239 &smdkv210_dm9000,
diff --git a/arch/arm/plat-omap/i2c.c b/arch/arm/plat-omap/i2c.c
index a5683a84c6ee..6013831a043e 100644
--- a/arch/arm/plat-omap/i2c.c
+++ b/arch/arm/plat-omap/i2c.c
@@ -26,12 +26,14 @@
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/platform_device.h> 27#include <linux/platform_device.h>
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <linux/i2c-omap.h>
29#include <linux/slab.h> 30#include <linux/slab.h>
30#include <linux/err.h> 31#include <linux/err.h>
31#include <linux/clk.h> 32#include <linux/clk.h>
32 33
33#include <mach/irqs.h> 34#include <mach/irqs.h>
34#include <plat/i2c.h> 35#include <plat/i2c.h>
36#include <plat/omap-pm.h>
35#include <plat/omap_device.h> 37#include <plat/omap_device.h>
36 38
37#define OMAP_I2C_SIZE 0x3f 39#define OMAP_I2C_SIZE 0x3f
@@ -127,6 +129,16 @@ static inline int omap1_i2c_add_bus(int bus_id)
127 129
128 130
129#ifdef CONFIG_ARCH_OMAP2PLUS 131#ifdef CONFIG_ARCH_OMAP2PLUS
132/*
133 * XXX This function is a temporary compatibility wrapper - only
134 * needed until the I2C driver can be converted to call
135 * omap_pm_set_max_dev_wakeup_lat() and handle a return code.
136 */
137static void omap_pm_set_max_mpu_wakeup_lat_compat(struct device *dev, long t)
138{
139 omap_pm_set_max_mpu_wakeup_lat(dev, t);
140}
141
130static inline int omap2_i2c_add_bus(int bus_id) 142static inline int omap2_i2c_add_bus(int bus_id)
131{ 143{
132 int l; 144 int l;
@@ -158,6 +170,15 @@ static inline int omap2_i2c_add_bus(int bus_id)
158 dev_attr = (struct omap_i2c_dev_attr *)oh->dev_attr; 170 dev_attr = (struct omap_i2c_dev_attr *)oh->dev_attr;
159 pdata->flags = dev_attr->flags; 171 pdata->flags = dev_attr->flags;
160 172
173 /*
174 * When waiting for completion of a i2c transfer, we need to
175 * set a wake up latency constraint for the MPU. This is to
176 * ensure quick enough wakeup from idle, when transfer
177 * completes.
178 * Only omap3 has support for constraints
179 */
180 if (cpu_is_omap34xx())
181 pdata->set_mpu_wkup_lat = omap_pm_set_max_mpu_wakeup_lat_compat;
161 pdev = omap_device_build(name, bus_id, oh, pdata, 182 pdev = omap_device_build(name, bus_id, oh, pdata,
162 sizeof(struct omap_i2c_bus_platform_data), 183 sizeof(struct omap_i2c_bus_platform_data),
163 NULL, 0, 0); 184 NULL, 0, 0);
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h
index b3349f7b1a2c..1db029438022 100644
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -443,6 +443,11 @@ struct omap_hwmod_omap4_prcm {
443 * in order to complete the reset. Optional clocks will be disabled 443 * in order to complete the reset. Optional clocks will be disabled
444 * again after the reset. 444 * again after the reset.
445 * HWMOD_16BIT_REG: Module has 16bit registers 445 * HWMOD_16BIT_REG: Module has 16bit registers
446 * HWMOD_EXT_OPT_MAIN_CLK: The only main functional clock source for
447 * this IP block comes from an off-chip source and is not always
448 * enabled. This prevents the hwmod code from being able to
449 * enable and reset the IP block early. XXX Eventually it should
450 * be possible to query the clock framework for this information.
446 */ 451 */
447#define HWMOD_SWSUP_SIDLE (1 << 0) 452#define HWMOD_SWSUP_SIDLE (1 << 0)
448#define HWMOD_SWSUP_MSTANDBY (1 << 1) 453#define HWMOD_SWSUP_MSTANDBY (1 << 1)
@@ -453,6 +458,7 @@ struct omap_hwmod_omap4_prcm {
453#define HWMOD_NO_IDLEST (1 << 6) 458#define HWMOD_NO_IDLEST (1 << 6)
454#define HWMOD_CONTROL_OPT_CLKS_IN_RESET (1 << 7) 459#define HWMOD_CONTROL_OPT_CLKS_IN_RESET (1 << 7)
455#define HWMOD_16BIT_REG (1 << 8) 460#define HWMOD_16BIT_REG (1 << 8)
461#define HWMOD_EXT_OPT_MAIN_CLK (1 << 9)
456 462
457/* 463/*
458 * omap_hwmod._int_flags definitions 464 * omap_hwmod._int_flags definitions
diff --git a/arch/arm/plat-samsung/devs.c b/arch/arm/plat-samsung/devs.c
index 03f654d55eff..7d27a241f984 100644
--- a/arch/arm/plat-samsung/devs.c
+++ b/arch/arm/plat-samsung/devs.c
@@ -146,15 +146,6 @@ struct platform_device s3c_device_camif = {
146 146
147/* ASOC DMA */ 147/* ASOC DMA */
148 148
149struct platform_device samsung_asoc_dma = {
150 .name = "samsung-audio",
151 .id = -1,
152 .dev = {
153 .dma_mask = &samsung_device_dma_mask,
154 .coherent_dma_mask = DMA_BIT_MASK(32),
155 }
156};
157
158struct platform_device samsung_asoc_idma = { 149struct platform_device samsung_asoc_idma = {
159 .name = "samsung-idma", 150 .name = "samsung-idma",
160 .id = -1, 151 .id = -1,
diff --git a/arch/arm/plat-samsung/include/plat/devs.h b/arch/arm/plat-samsung/include/plat/devs.h
index 5da4b4f38f40..c45f70cbbfb7 100644
--- a/arch/arm/plat-samsung/include/plat/devs.h
+++ b/arch/arm/plat-samsung/include/plat/devs.h
@@ -135,7 +135,6 @@ extern struct platform_device exynos4_device_spdif;
135 135
136extern struct platform_device exynos_device_drm; 136extern struct platform_device exynos_device_drm;
137 137
138extern struct platform_device samsung_asoc_dma;
139extern struct platform_device samsung_asoc_idma; 138extern struct platform_device samsung_asoc_idma;
140extern struct platform_device samsung_device_keypad; 139extern struct platform_device samsung_device_keypad;
141 140
diff --git a/arch/arm/tools/Makefile b/arch/arm/tools/Makefile
index cd60a81163e9..32d05c8219dc 100644
--- a/arch/arm/tools/Makefile
+++ b/arch/arm/tools/Makefile
@@ -5,6 +5,6 @@
5# 5#
6 6
7include/generated/mach-types.h: $(src)/gen-mach-types $(src)/mach-types 7include/generated/mach-types.h: $(src)/gen-mach-types $(src)/mach-types
8 $(kecho) ' Generating $@' 8 @$(kecho) ' Generating $@'
9 @mkdir -p $(dir $@) 9 @mkdir -p $(dir $@)
10 $(Q)$(AWK) -f $^ > $@ || { rm -f $@; /bin/false; } 10 $(Q)$(AWK) -f $^ > $@ || { rm -f $@; /bin/false; }
diff --git a/arch/arm64/include/asm/io.h b/arch/arm64/include/asm/io.h
index 54f6116697f7..d2f05a608274 100644
--- a/arch/arm64/include/asm/io.h
+++ b/arch/arm64/include/asm/io.h
@@ -222,7 +222,7 @@ extern void __iomem *__ioremap(phys_addr_t phys_addr, size_t size, pgprot_t prot
222extern void __iounmap(volatile void __iomem *addr); 222extern void __iounmap(volatile void __iomem *addr);
223 223
224#define PROT_DEFAULT (PTE_TYPE_PAGE | PTE_AF | PTE_DIRTY) 224#define PROT_DEFAULT (PTE_TYPE_PAGE | PTE_AF | PTE_DIRTY)
225#define PROT_DEVICE_nGnRE (PROT_DEFAULT | PTE_XN | PTE_ATTRINDX(MT_DEVICE_nGnRE)) 225#define PROT_DEVICE_nGnRE (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_ATTRINDX(MT_DEVICE_nGnRE))
226#define PROT_NORMAL_NC (PROT_DEFAULT | PTE_ATTRINDX(MT_NORMAL_NC)) 226#define PROT_NORMAL_NC (PROT_DEFAULT | PTE_ATTRINDX(MT_NORMAL_NC))
227 227
228#define ioremap(addr, size) __ioremap((addr), (size), __pgprot(PROT_DEVICE_nGnRE)) 228#define ioremap(addr, size) __ioremap((addr), (size), __pgprot(PROT_DEVICE_nGnRE))
diff --git a/arch/arm64/include/asm/pgtable-hwdef.h b/arch/arm64/include/asm/pgtable-hwdef.h
index 0f3b4581d925..75fd13d289b9 100644
--- a/arch/arm64/include/asm/pgtable-hwdef.h
+++ b/arch/arm64/include/asm/pgtable-hwdef.h
@@ -38,7 +38,8 @@
38#define PMD_SECT_S (_AT(pmdval_t, 3) << 8) 38#define PMD_SECT_S (_AT(pmdval_t, 3) << 8)
39#define PMD_SECT_AF (_AT(pmdval_t, 1) << 10) 39#define PMD_SECT_AF (_AT(pmdval_t, 1) << 10)
40#define PMD_SECT_NG (_AT(pmdval_t, 1) << 11) 40#define PMD_SECT_NG (_AT(pmdval_t, 1) << 11)
41#define PMD_SECT_XN (_AT(pmdval_t, 1) << 54) 41#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 53)
42#define PMD_SECT_UXN (_AT(pmdval_t, 1) << 54)
42 43
43/* 44/*
44 * AttrIndx[2:0] encoding (mapping attributes defined in the MAIR* registers). 45 * AttrIndx[2:0] encoding (mapping attributes defined in the MAIR* registers).
@@ -57,7 +58,8 @@
57#define PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */ 58#define PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
58#define PTE_AF (_AT(pteval_t, 1) << 10) /* Access Flag */ 59#define PTE_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
59#define PTE_NG (_AT(pteval_t, 1) << 11) /* nG */ 60#define PTE_NG (_AT(pteval_t, 1) << 11) /* nG */
60#define PTE_XN (_AT(pteval_t, 1) << 54) /* XN */ 61#define PTE_PXN (_AT(pteval_t, 1) << 53) /* Privileged XN */
62#define PTE_UXN (_AT(pteval_t, 1) << 54) /* User XN */
61 63
62/* 64/*
63 * AttrIndx[2:0] encoding (mapping attributes defined in the MAIR* registers). 65 * AttrIndx[2:0] encoding (mapping attributes defined in the MAIR* registers).
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index 8960239be722..14aba2db6776 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -62,23 +62,23 @@ extern pgprot_t pgprot_default;
62 62
63#define _MOD_PROT(p, b) __pgprot(pgprot_val(p) | (b)) 63#define _MOD_PROT(p, b) __pgprot(pgprot_val(p) | (b))
64 64
65#define PAGE_NONE _MOD_PROT(pgprot_default, PTE_NG | PTE_XN | PTE_RDONLY) 65#define PAGE_NONE _MOD_PROT(pgprot_default, PTE_NG | PTE_PXN | PTE_UXN | PTE_RDONLY)
66#define PAGE_SHARED _MOD_PROT(pgprot_default, PTE_USER | PTE_NG | PTE_XN) 66#define PAGE_SHARED _MOD_PROT(pgprot_default, PTE_USER | PTE_NG | PTE_PXN | PTE_UXN)
67#define PAGE_SHARED_EXEC _MOD_PROT(pgprot_default, PTE_USER | PTE_NG) 67#define PAGE_SHARED_EXEC _MOD_PROT(pgprot_default, PTE_USER | PTE_NG | PTE_PXN)
68#define PAGE_COPY _MOD_PROT(pgprot_default, PTE_USER | PTE_NG | PTE_XN | PTE_RDONLY) 68#define PAGE_COPY _MOD_PROT(pgprot_default, PTE_USER | PTE_NG | PTE_PXN | PTE_UXN | PTE_RDONLY)
69#define PAGE_COPY_EXEC _MOD_PROT(pgprot_default, PTE_USER | PTE_NG | PTE_RDONLY) 69#define PAGE_COPY_EXEC _MOD_PROT(pgprot_default, PTE_USER | PTE_NG | PTE_PXN | PTE_RDONLY)
70#define PAGE_READONLY _MOD_PROT(pgprot_default, PTE_USER | PTE_NG | PTE_XN | PTE_RDONLY) 70#define PAGE_READONLY _MOD_PROT(pgprot_default, PTE_USER | PTE_NG | PTE_PXN | PTE_UXN | PTE_RDONLY)
71#define PAGE_READONLY_EXEC _MOD_PROT(pgprot_default, PTE_USER | PTE_NG | PTE_RDONLY) 71#define PAGE_READONLY_EXEC _MOD_PROT(pgprot_default, PTE_USER | PTE_NG | PTE_PXN | PTE_RDONLY)
72#define PAGE_KERNEL _MOD_PROT(pgprot_default, PTE_XN | PTE_DIRTY) 72#define PAGE_KERNEL _MOD_PROT(pgprot_default, PTE_PXN | PTE_UXN | PTE_DIRTY)
73#define PAGE_KERNEL_EXEC _MOD_PROT(pgprot_default, PTE_DIRTY) 73#define PAGE_KERNEL_EXEC _MOD_PROT(pgprot_default, PTE_UXN | PTE_DIRTY)
74 74
75#define __PAGE_NONE __pgprot(_PAGE_DEFAULT | PTE_NG | PTE_XN | PTE_RDONLY) 75#define __PAGE_NONE __pgprot(_PAGE_DEFAULT | PTE_NG | PTE_PXN | PTE_UXN | PTE_RDONLY)
76#define __PAGE_SHARED __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_NG | PTE_XN) 76#define __PAGE_SHARED __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_NG | PTE_PXN | PTE_UXN)
77#define __PAGE_SHARED_EXEC __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_NG) 77#define __PAGE_SHARED_EXEC __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_NG | PTE_PXN)
78#define __PAGE_COPY __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_NG | PTE_XN | PTE_RDONLY) 78#define __PAGE_COPY __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_NG | PTE_PXN | PTE_UXN | PTE_RDONLY)
79#define __PAGE_COPY_EXEC __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_NG | PTE_RDONLY) 79#define __PAGE_COPY_EXEC __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_NG | PTE_PXN | PTE_RDONLY)
80#define __PAGE_READONLY __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_NG | PTE_XN | PTE_RDONLY) 80#define __PAGE_READONLY __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_NG | PTE_PXN | PTE_UXN | PTE_RDONLY)
81#define __PAGE_READONLY_EXEC __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_NG | PTE_RDONLY) 81#define __PAGE_READONLY_EXEC __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_NG | PTE_PXN | PTE_RDONLY)
82 82
83#endif /* __ASSEMBLY__ */ 83#endif /* __ASSEMBLY__ */
84 84
@@ -130,10 +130,10 @@ extern struct page *empty_zero_page;
130#define pte_young(pte) (pte_val(pte) & PTE_AF) 130#define pte_young(pte) (pte_val(pte) & PTE_AF)
131#define pte_special(pte) (pte_val(pte) & PTE_SPECIAL) 131#define pte_special(pte) (pte_val(pte) & PTE_SPECIAL)
132#define pte_write(pte) (!(pte_val(pte) & PTE_RDONLY)) 132#define pte_write(pte) (!(pte_val(pte) & PTE_RDONLY))
133#define pte_exec(pte) (!(pte_val(pte) & PTE_XN)) 133#define pte_exec(pte) (!(pte_val(pte) & PTE_UXN))
134 134
135#define pte_present_exec_user(pte) \ 135#define pte_present_exec_user(pte) \
136 ((pte_val(pte) & (PTE_VALID | PTE_USER | PTE_XN)) == \ 136 ((pte_val(pte) & (PTE_VALID | PTE_USER | PTE_UXN)) == \
137 (PTE_VALID | PTE_USER)) 137 (PTE_VALID | PTE_USER))
138 138
139#define PTE_BIT_FUNC(fn,op) \ 139#define PTE_BIT_FUNC(fn,op) \
@@ -262,7 +262,7 @@ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long addr)
262 262
263static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) 263static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
264{ 264{
265 const pteval_t mask = PTE_USER | PTE_XN | PTE_RDONLY; 265 const pteval_t mask = PTE_USER | PTE_PXN | PTE_UXN | PTE_RDONLY;
266 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask); 266 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
267 return pte; 267 return pte;
268} 268}
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index acd5b68e8871..082e383c1b6f 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -637,7 +637,6 @@ mem_init (void)
637 637
638 high_memory = __va(max_low_pfn * PAGE_SIZE); 638 high_memory = __va(max_low_pfn * PAGE_SIZE);
639 639
640 reset_zone_present_pages();
641 for_each_online_pgdat(pgdat) 640 for_each_online_pgdat(pgdat)
642 if (pgdat->bdata->node_bootmem_map) 641 if (pgdat->bdata->node_bootmem_map)
643 totalram_pages += free_all_bootmem_node(pgdat); 642 totalram_pages += free_all_bootmem_node(pgdat);
diff --git a/arch/m68k/include/asm/signal.h b/arch/m68k/include/asm/signal.h
index 67e489d8d1bd..2df26b57c26a 100644
--- a/arch/m68k/include/asm/signal.h
+++ b/arch/m68k/include/asm/signal.h
@@ -41,7 +41,7 @@ struct k_sigaction {
41static inline void sigaddset(sigset_t *set, int _sig) 41static inline void sigaddset(sigset_t *set, int _sig)
42{ 42{
43 asm ("bfset %0{%1,#1}" 43 asm ("bfset %0{%1,#1}"
44 : "+od" (*set) 44 : "+o" (*set)
45 : "id" ((_sig - 1) ^ 31) 45 : "id" ((_sig - 1) ^ 31)
46 : "cc"); 46 : "cc");
47} 47}
@@ -49,7 +49,7 @@ static inline void sigaddset(sigset_t *set, int _sig)
49static inline void sigdelset(sigset_t *set, int _sig) 49static inline void sigdelset(sigset_t *set, int _sig)
50{ 50{
51 asm ("bfclr %0{%1,#1}" 51 asm ("bfclr %0{%1,#1}"
52 : "+od" (*set) 52 : "+o" (*set)
53 : "id" ((_sig - 1) ^ 31) 53 : "id" ((_sig - 1) ^ 31)
54 : "cc"); 54 : "cc");
55} 55}
@@ -65,7 +65,7 @@ static inline int __gen_sigismember(sigset_t *set, int _sig)
65 int ret; 65 int ret;
66 asm ("bfextu %1{%2,#1},%0" 66 asm ("bfextu %1{%2,#1},%0"
67 : "=d" (ret) 67 : "=d" (ret)
68 : "od" (*set), "id" ((_sig-1) ^ 31) 68 : "o" (*set), "id" ((_sig-1) ^ 31)
69 : "cc"); 69 : "cc");
70 return ret; 70 return ret;
71} 71}
diff --git a/arch/mips/cavium-octeon/executive/cvmx-l2c.c b/arch/mips/cavium-octeon/executive/cvmx-l2c.c
index d38246e33ddb..9f883bf76953 100644
--- a/arch/mips/cavium-octeon/executive/cvmx-l2c.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-l2c.c
@@ -30,6 +30,7 @@
30 * measurement, and debugging facilities. 30 * measurement, and debugging facilities.
31 */ 31 */
32 32
33#include <linux/irqflags.h>
33#include <asm/octeon/cvmx.h> 34#include <asm/octeon/cvmx.h>
34#include <asm/octeon/cvmx-l2c.h> 35#include <asm/octeon/cvmx-l2c.h>
35#include <asm/octeon/cvmx-spinlock.h> 36#include <asm/octeon/cvmx-spinlock.h>
diff --git a/arch/mips/fw/arc/misc.c b/arch/mips/fw/arc/misc.c
index 7cf80ca2c1d2..f9f5307434c2 100644
--- a/arch/mips/fw/arc/misc.c
+++ b/arch/mips/fw/arc/misc.c
@@ -11,6 +11,7 @@
11 */ 11 */
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/irqflags.h>
14 15
15#include <asm/bcache.h> 16#include <asm/bcache.h>
16 17
diff --git a/arch/mips/include/asm/bitops.h b/arch/mips/include/asm/bitops.h
index 82ad35ce2b45..46ac73abd5ee 100644
--- a/arch/mips/include/asm/bitops.h
+++ b/arch/mips/include/asm/bitops.h
@@ -14,7 +14,6 @@
14#endif 14#endif
15 15
16#include <linux/compiler.h> 16#include <linux/compiler.h>
17#include <linux/irqflags.h>
18#include <linux/types.h> 17#include <linux/types.h>
19#include <asm/barrier.h> 18#include <asm/barrier.h>
20#include <asm/byteorder.h> /* sigh ... */ 19#include <asm/byteorder.h> /* sigh ... */
@@ -44,6 +43,24 @@
44#define smp_mb__before_clear_bit() smp_mb__before_llsc() 43#define smp_mb__before_clear_bit() smp_mb__before_llsc()
45#define smp_mb__after_clear_bit() smp_llsc_mb() 44#define smp_mb__after_clear_bit() smp_llsc_mb()
46 45
46
47/*
48 * These are the "slower" versions of the functions and are in bitops.c.
49 * These functions call raw_local_irq_{save,restore}().
50 */
51void __mips_set_bit(unsigned long nr, volatile unsigned long *addr);
52void __mips_clear_bit(unsigned long nr, volatile unsigned long *addr);
53void __mips_change_bit(unsigned long nr, volatile unsigned long *addr);
54int __mips_test_and_set_bit(unsigned long nr,
55 volatile unsigned long *addr);
56int __mips_test_and_set_bit_lock(unsigned long nr,
57 volatile unsigned long *addr);
58int __mips_test_and_clear_bit(unsigned long nr,
59 volatile unsigned long *addr);
60int __mips_test_and_change_bit(unsigned long nr,
61 volatile unsigned long *addr);
62
63
47/* 64/*
48 * set_bit - Atomically set a bit in memory 65 * set_bit - Atomically set a bit in memory
49 * @nr: the bit to set 66 * @nr: the bit to set
@@ -57,7 +74,7 @@
57static inline void set_bit(unsigned long nr, volatile unsigned long *addr) 74static inline void set_bit(unsigned long nr, volatile unsigned long *addr)
58{ 75{
59 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG); 76 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
60 unsigned short bit = nr & SZLONG_MASK; 77 int bit = nr & SZLONG_MASK;
61 unsigned long temp; 78 unsigned long temp;
62 79
63 if (kernel_uses_llsc && R10000_LLSC_WAR) { 80 if (kernel_uses_llsc && R10000_LLSC_WAR) {
@@ -92,17 +109,8 @@ static inline void set_bit(unsigned long nr, volatile unsigned long *addr)
92 : "=&r" (temp), "+m" (*m) 109 : "=&r" (temp), "+m" (*m)
93 : "ir" (1UL << bit)); 110 : "ir" (1UL << bit));
94 } while (unlikely(!temp)); 111 } while (unlikely(!temp));
95 } else { 112 } else
96 volatile unsigned long *a = addr; 113 __mips_set_bit(nr, addr);
97 unsigned long mask;
98 unsigned long flags;
99
100 a += nr >> SZLONG_LOG;
101 mask = 1UL << bit;
102 raw_local_irq_save(flags);
103 *a |= mask;
104 raw_local_irq_restore(flags);
105 }
106} 114}
107 115
108/* 116/*
@@ -118,7 +126,7 @@ static inline void set_bit(unsigned long nr, volatile unsigned long *addr)
118static inline void clear_bit(unsigned long nr, volatile unsigned long *addr) 126static inline void clear_bit(unsigned long nr, volatile unsigned long *addr)
119{ 127{
120 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG); 128 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
121 unsigned short bit = nr & SZLONG_MASK; 129 int bit = nr & SZLONG_MASK;
122 unsigned long temp; 130 unsigned long temp;
123 131
124 if (kernel_uses_llsc && R10000_LLSC_WAR) { 132 if (kernel_uses_llsc && R10000_LLSC_WAR) {
@@ -153,17 +161,8 @@ static inline void clear_bit(unsigned long nr, volatile unsigned long *addr)
153 : "=&r" (temp), "+m" (*m) 161 : "=&r" (temp), "+m" (*m)
154 : "ir" (~(1UL << bit))); 162 : "ir" (~(1UL << bit)));
155 } while (unlikely(!temp)); 163 } while (unlikely(!temp));
156 } else { 164 } else
157 volatile unsigned long *a = addr; 165 __mips_clear_bit(nr, addr);
158 unsigned long mask;
159 unsigned long flags;
160
161 a += nr >> SZLONG_LOG;
162 mask = 1UL << bit;
163 raw_local_irq_save(flags);
164 *a &= ~mask;
165 raw_local_irq_restore(flags);
166 }
167} 166}
168 167
169/* 168/*
@@ -191,7 +190,7 @@ static inline void clear_bit_unlock(unsigned long nr, volatile unsigned long *ad
191 */ 190 */
192static inline void change_bit(unsigned long nr, volatile unsigned long *addr) 191static inline void change_bit(unsigned long nr, volatile unsigned long *addr)
193{ 192{
194 unsigned short bit = nr & SZLONG_MASK; 193 int bit = nr & SZLONG_MASK;
195 194
196 if (kernel_uses_llsc && R10000_LLSC_WAR) { 195 if (kernel_uses_llsc && R10000_LLSC_WAR) {
197 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG); 196 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
@@ -220,17 +219,8 @@ static inline void change_bit(unsigned long nr, volatile unsigned long *addr)
220 : "=&r" (temp), "+m" (*m) 219 : "=&r" (temp), "+m" (*m)
221 : "ir" (1UL << bit)); 220 : "ir" (1UL << bit));
222 } while (unlikely(!temp)); 221 } while (unlikely(!temp));
223 } else { 222 } else
224 volatile unsigned long *a = addr; 223 __mips_change_bit(nr, addr);
225 unsigned long mask;
226 unsigned long flags;
227
228 a += nr >> SZLONG_LOG;
229 mask = 1UL << bit;
230 raw_local_irq_save(flags);
231 *a ^= mask;
232 raw_local_irq_restore(flags);
233 }
234} 224}
235 225
236/* 226/*
@@ -244,7 +234,7 @@ static inline void change_bit(unsigned long nr, volatile unsigned long *addr)
244static inline int test_and_set_bit(unsigned long nr, 234static inline int test_and_set_bit(unsigned long nr,
245 volatile unsigned long *addr) 235 volatile unsigned long *addr)
246{ 236{
247 unsigned short bit = nr & SZLONG_MASK; 237 int bit = nr & SZLONG_MASK;
248 unsigned long res; 238 unsigned long res;
249 239
250 smp_mb__before_llsc(); 240 smp_mb__before_llsc();
@@ -281,18 +271,8 @@ static inline int test_and_set_bit(unsigned long nr,
281 } while (unlikely(!res)); 271 } while (unlikely(!res));
282 272
283 res = temp & (1UL << bit); 273 res = temp & (1UL << bit);
284 } else { 274 } else
285 volatile unsigned long *a = addr; 275 res = __mips_test_and_set_bit(nr, addr);
286 unsigned long mask;
287 unsigned long flags;
288
289 a += nr >> SZLONG_LOG;
290 mask = 1UL << bit;
291 raw_local_irq_save(flags);
292 res = (mask & *a);
293 *a |= mask;
294 raw_local_irq_restore(flags);
295 }
296 276
297 smp_llsc_mb(); 277 smp_llsc_mb();
298 278
@@ -310,7 +290,7 @@ static inline int test_and_set_bit(unsigned long nr,
310static inline int test_and_set_bit_lock(unsigned long nr, 290static inline int test_and_set_bit_lock(unsigned long nr,
311 volatile unsigned long *addr) 291 volatile unsigned long *addr)
312{ 292{
313 unsigned short bit = nr & SZLONG_MASK; 293 int bit = nr & SZLONG_MASK;
314 unsigned long res; 294 unsigned long res;
315 295
316 if (kernel_uses_llsc && R10000_LLSC_WAR) { 296 if (kernel_uses_llsc && R10000_LLSC_WAR) {
@@ -345,18 +325,8 @@ static inline int test_and_set_bit_lock(unsigned long nr,
345 } while (unlikely(!res)); 325 } while (unlikely(!res));
346 326
347 res = temp & (1UL << bit); 327 res = temp & (1UL << bit);
348 } else { 328 } else
349 volatile unsigned long *a = addr; 329 res = __mips_test_and_set_bit_lock(nr, addr);
350 unsigned long mask;
351 unsigned long flags;
352
353 a += nr >> SZLONG_LOG;
354 mask = 1UL << bit;
355 raw_local_irq_save(flags);
356 res = (mask & *a);
357 *a |= mask;
358 raw_local_irq_restore(flags);
359 }
360 330
361 smp_llsc_mb(); 331 smp_llsc_mb();
362 332
@@ -373,7 +343,7 @@ static inline int test_and_set_bit_lock(unsigned long nr,
373static inline int test_and_clear_bit(unsigned long nr, 343static inline int test_and_clear_bit(unsigned long nr,
374 volatile unsigned long *addr) 344 volatile unsigned long *addr)
375{ 345{
376 unsigned short bit = nr & SZLONG_MASK; 346 int bit = nr & SZLONG_MASK;
377 unsigned long res; 347 unsigned long res;
378 348
379 smp_mb__before_llsc(); 349 smp_mb__before_llsc();
@@ -428,18 +398,8 @@ static inline int test_and_clear_bit(unsigned long nr,
428 } while (unlikely(!res)); 398 } while (unlikely(!res));
429 399
430 res = temp & (1UL << bit); 400 res = temp & (1UL << bit);
431 } else { 401 } else
432 volatile unsigned long *a = addr; 402 res = __mips_test_and_clear_bit(nr, addr);
433 unsigned long mask;
434 unsigned long flags;
435
436 a += nr >> SZLONG_LOG;
437 mask = 1UL << bit;
438 raw_local_irq_save(flags);
439 res = (mask & *a);
440 *a &= ~mask;
441 raw_local_irq_restore(flags);
442 }
443 403
444 smp_llsc_mb(); 404 smp_llsc_mb();
445 405
@@ -457,7 +417,7 @@ static inline int test_and_clear_bit(unsigned long nr,
457static inline int test_and_change_bit(unsigned long nr, 417static inline int test_and_change_bit(unsigned long nr,
458 volatile unsigned long *addr) 418 volatile unsigned long *addr)
459{ 419{
460 unsigned short bit = nr & SZLONG_MASK; 420 int bit = nr & SZLONG_MASK;
461 unsigned long res; 421 unsigned long res;
462 422
463 smp_mb__before_llsc(); 423 smp_mb__before_llsc();
@@ -494,18 +454,8 @@ static inline int test_and_change_bit(unsigned long nr,
494 } while (unlikely(!res)); 454 } while (unlikely(!res));
495 455
496 res = temp & (1UL << bit); 456 res = temp & (1UL << bit);
497 } else { 457 } else
498 volatile unsigned long *a = addr; 458 res = __mips_test_and_change_bit(nr, addr);
499 unsigned long mask;
500 unsigned long flags;
501
502 a += nr >> SZLONG_LOG;
503 mask = 1UL << bit;
504 raw_local_irq_save(flags);
505 res = (mask & *a);
506 *a ^= mask;
507 raw_local_irq_restore(flags);
508 }
509 459
510 smp_llsc_mb(); 460 smp_llsc_mb();
511 461
diff --git a/arch/mips/include/asm/compat.h b/arch/mips/include/asm/compat.h
index 58277e0e9cd4..3c5d1464b7bd 100644
--- a/arch/mips/include/asm/compat.h
+++ b/arch/mips/include/asm/compat.h
@@ -290,7 +290,7 @@ struct compat_shmid64_ds {
290 290
291static inline int is_compat_task(void) 291static inline int is_compat_task(void)
292{ 292{
293 return test_thread_flag(TIF_32BIT); 293 return test_thread_flag(TIF_32BIT_ADDR);
294} 294}
295 295
296#endif /* _ASM_COMPAT_H */ 296#endif /* _ASM_COMPAT_H */
diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h
index 29d9c23c20c7..ff2e0345e013 100644
--- a/arch/mips/include/asm/io.h
+++ b/arch/mips/include/asm/io.h
@@ -15,6 +15,7 @@
15#include <linux/compiler.h> 15#include <linux/compiler.h>
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/types.h> 17#include <linux/types.h>
18#include <linux/irqflags.h>
18 19
19#include <asm/addrspace.h> 20#include <asm/addrspace.h>
20#include <asm/bug.h> 21#include <asm/bug.h>
diff --git a/arch/mips/include/asm/irqflags.h b/arch/mips/include/asm/irqflags.h
index 309cbcd6909c..9f3384c789d7 100644
--- a/arch/mips/include/asm/irqflags.h
+++ b/arch/mips/include/asm/irqflags.h
@@ -16,83 +16,13 @@
16#include <linux/compiler.h> 16#include <linux/compiler.h>
17#include <asm/hazards.h> 17#include <asm/hazards.h>
18 18
19__asm__( 19#if defined(CONFIG_CPU_MIPSR2) && !defined(CONFIG_MIPS_MT_SMTC)
20 " .macro arch_local_irq_enable \n"
21 " .set push \n"
22 " .set reorder \n"
23 " .set noat \n"
24#ifdef CONFIG_MIPS_MT_SMTC
25 " mfc0 $1, $2, 1 # SMTC - clear TCStatus.IXMT \n"
26 " ori $1, 0x400 \n"
27 " xori $1, 0x400 \n"
28 " mtc0 $1, $2, 1 \n"
29#elif defined(CONFIG_CPU_MIPSR2)
30 " ei \n"
31#else
32 " mfc0 $1,$12 \n"
33 " ori $1,0x1f \n"
34 " xori $1,0x1e \n"
35 " mtc0 $1,$12 \n"
36#endif
37 " irq_enable_hazard \n"
38 " .set pop \n"
39 " .endm");
40 20
41extern void smtc_ipi_replay(void);
42
43static inline void arch_local_irq_enable(void)
44{
45#ifdef CONFIG_MIPS_MT_SMTC
46 /*
47 * SMTC kernel needs to do a software replay of queued
48 * IPIs, at the cost of call overhead on each local_irq_enable()
49 */
50 smtc_ipi_replay();
51#endif
52 __asm__ __volatile__(
53 "arch_local_irq_enable"
54 : /* no outputs */
55 : /* no inputs */
56 : "memory");
57}
58
59
60/*
61 * For cli() we have to insert nops to make sure that the new value
62 * has actually arrived in the status register before the end of this
63 * macro.
64 * R4000/R4400 need three nops, the R4600 two nops and the R10000 needs
65 * no nops at all.
66 */
67/*
68 * For TX49, operating only IE bit is not enough.
69 *
70 * If mfc0 $12 follows store and the mfc0 is last instruction of a
71 * page and fetching the next instruction causes TLB miss, the result
72 * of the mfc0 might wrongly contain EXL bit.
73 *
74 * ERT-TX49H2-027, ERT-TX49H3-012, ERT-TX49HL3-006, ERT-TX49H4-008
75 *
76 * Workaround: mask EXL bit of the result or place a nop before mfc0.
77 */
78__asm__( 21__asm__(
79 " .macro arch_local_irq_disable\n" 22 " .macro arch_local_irq_disable\n"
80 " .set push \n" 23 " .set push \n"
81 " .set noat \n" 24 " .set noat \n"
82#ifdef CONFIG_MIPS_MT_SMTC
83 " mfc0 $1, $2, 1 \n"
84 " ori $1, 0x400 \n"
85 " .set noreorder \n"
86 " mtc0 $1, $2, 1 \n"
87#elif defined(CONFIG_CPU_MIPSR2)
88 " di \n" 25 " di \n"
89#else
90 " mfc0 $1,$12 \n"
91 " ori $1,0x1f \n"
92 " xori $1,0x1f \n"
93 " .set noreorder \n"
94 " mtc0 $1,$12 \n"
95#endif
96 " irq_disable_hazard \n" 26 " irq_disable_hazard \n"
97 " .set pop \n" 27 " .set pop \n"
98 " .endm \n"); 28 " .endm \n");
@@ -106,46 +36,14 @@ static inline void arch_local_irq_disable(void)
106 : "memory"); 36 : "memory");
107} 37}
108 38
109__asm__(
110 " .macro arch_local_save_flags flags \n"
111 " .set push \n"
112 " .set reorder \n"
113#ifdef CONFIG_MIPS_MT_SMTC
114 " mfc0 \\flags, $2, 1 \n"
115#else
116 " mfc0 \\flags, $12 \n"
117#endif
118 " .set pop \n"
119 " .endm \n");
120
121static inline unsigned long arch_local_save_flags(void)
122{
123 unsigned long flags;
124 asm volatile("arch_local_save_flags %0" : "=r" (flags));
125 return flags;
126}
127 39
128__asm__( 40__asm__(
129 " .macro arch_local_irq_save result \n" 41 " .macro arch_local_irq_save result \n"
130 " .set push \n" 42 " .set push \n"
131 " .set reorder \n" 43 " .set reorder \n"
132 " .set noat \n" 44 " .set noat \n"
133#ifdef CONFIG_MIPS_MT_SMTC
134 " mfc0 \\result, $2, 1 \n"
135 " ori $1, \\result, 0x400 \n"
136 " .set noreorder \n"
137 " mtc0 $1, $2, 1 \n"
138 " andi \\result, \\result, 0x400 \n"
139#elif defined(CONFIG_CPU_MIPSR2)
140 " di \\result \n" 45 " di \\result \n"
141 " andi \\result, 1 \n" 46 " andi \\result, 1 \n"
142#else
143 " mfc0 \\result, $12 \n"
144 " ori $1, \\result, 0x1f \n"
145 " xori $1, 0x1f \n"
146 " .set noreorder \n"
147 " mtc0 $1, $12 \n"
148#endif
149 " irq_disable_hazard \n" 47 " irq_disable_hazard \n"
150 " .set pop \n" 48 " .set pop \n"
151 " .endm \n"); 49 " .endm \n");
@@ -160,61 +58,37 @@ static inline unsigned long arch_local_irq_save(void)
160 return flags; 58 return flags;
161} 59}
162 60
61
163__asm__( 62__asm__(
164 " .macro arch_local_irq_restore flags \n" 63 " .macro arch_local_irq_restore flags \n"
165 " .set push \n" 64 " .set push \n"
166 " .set noreorder \n" 65 " .set noreorder \n"
167 " .set noat \n" 66 " .set noat \n"
168#ifdef CONFIG_MIPS_MT_SMTC 67#if defined(CONFIG_IRQ_CPU)
169 "mfc0 $1, $2, 1 \n"
170 "andi \\flags, 0x400 \n"
171 "ori $1, 0x400 \n"
172 "xori $1, 0x400 \n"
173 "or \\flags, $1 \n"
174 "mtc0 \\flags, $2, 1 \n"
175#elif defined(CONFIG_CPU_MIPSR2) && defined(CONFIG_IRQ_CPU)
176 /* 68 /*
177 * Slow, but doesn't suffer from a relatively unlikely race 69 * Slow, but doesn't suffer from a relatively unlikely race
178 * condition we're having since days 1. 70 * condition we're having since days 1.
179 */ 71 */
180 " beqz \\flags, 1f \n" 72 " beqz \\flags, 1f \n"
181 " di \n" 73 " di \n"
182 " ei \n" 74 " ei \n"
183 "1: \n" 75 "1: \n"
184#elif defined(CONFIG_CPU_MIPSR2) 76#else
185 /* 77 /*
186 * Fast, dangerous. Life is fun, life is good. 78 * Fast, dangerous. Life is fun, life is good.
187 */ 79 */
188 " mfc0 $1, $12 \n" 80 " mfc0 $1, $12 \n"
189 " ins $1, \\flags, 0, 1 \n" 81 " ins $1, \\flags, 0, 1 \n"
190 " mtc0 $1, $12 \n" 82 " mtc0 $1, $12 \n"
191#else
192 " mfc0 $1, $12 \n"
193 " andi \\flags, 1 \n"
194 " ori $1, 0x1f \n"
195 " xori $1, 0x1f \n"
196 " or \\flags, $1 \n"
197 " mtc0 \\flags, $12 \n"
198#endif 83#endif
199 " irq_disable_hazard \n" 84 " irq_disable_hazard \n"
200 " .set pop \n" 85 " .set pop \n"
201 " .endm \n"); 86 " .endm \n");
202 87
203
204static inline void arch_local_irq_restore(unsigned long flags) 88static inline void arch_local_irq_restore(unsigned long flags)
205{ 89{
206 unsigned long __tmp1; 90 unsigned long __tmp1;
207 91
208#ifdef CONFIG_MIPS_MT_SMTC
209 /*
210 * SMTC kernel needs to do a software replay of queued
211 * IPIs, at the cost of branch and call overhead on each
212 * local_irq_restore()
213 */
214 if (unlikely(!(flags & 0x0400)))
215 smtc_ipi_replay();
216#endif
217
218 __asm__ __volatile__( 92 __asm__ __volatile__(
219 "arch_local_irq_restore\t%0" 93 "arch_local_irq_restore\t%0"
220 : "=r" (__tmp1) 94 : "=r" (__tmp1)
@@ -232,6 +106,75 @@ static inline void __arch_local_irq_restore(unsigned long flags)
232 : "0" (flags) 106 : "0" (flags)
233 : "memory"); 107 : "memory");
234} 108}
109#else
110/* Functions that require preempt_{dis,en}able() are in mips-atomic.c */
111void arch_local_irq_disable(void);
112unsigned long arch_local_irq_save(void);
113void arch_local_irq_restore(unsigned long flags);
114void __arch_local_irq_restore(unsigned long flags);
115#endif /* if defined(CONFIG_CPU_MIPSR2) && !defined(CONFIG_MIPS_MT_SMTC) */
116
117
118__asm__(
119 " .macro arch_local_irq_enable \n"
120 " .set push \n"
121 " .set reorder \n"
122 " .set noat \n"
123#ifdef CONFIG_MIPS_MT_SMTC
124 " mfc0 $1, $2, 1 # SMTC - clear TCStatus.IXMT \n"
125 " ori $1, 0x400 \n"
126 " xori $1, 0x400 \n"
127 " mtc0 $1, $2, 1 \n"
128#elif defined(CONFIG_CPU_MIPSR2)
129 " ei \n"
130#else
131 " mfc0 $1,$12 \n"
132 " ori $1,0x1f \n"
133 " xori $1,0x1e \n"
134 " mtc0 $1,$12 \n"
135#endif
136 " irq_enable_hazard \n"
137 " .set pop \n"
138 " .endm");
139
140extern void smtc_ipi_replay(void);
141
142static inline void arch_local_irq_enable(void)
143{
144#ifdef CONFIG_MIPS_MT_SMTC
145 /*
146 * SMTC kernel needs to do a software replay of queued
147 * IPIs, at the cost of call overhead on each local_irq_enable()
148 */
149 smtc_ipi_replay();
150#endif
151 __asm__ __volatile__(
152 "arch_local_irq_enable"
153 : /* no outputs */
154 : /* no inputs */
155 : "memory");
156}
157
158
159__asm__(
160 " .macro arch_local_save_flags flags \n"
161 " .set push \n"
162 " .set reorder \n"
163#ifdef CONFIG_MIPS_MT_SMTC
164 " mfc0 \\flags, $2, 1 \n"
165#else
166 " mfc0 \\flags, $12 \n"
167#endif
168 " .set pop \n"
169 " .endm \n");
170
171static inline unsigned long arch_local_save_flags(void)
172{
173 unsigned long flags;
174 asm volatile("arch_local_save_flags %0" : "=r" (flags));
175 return flags;
176}
177
235 178
236static inline int arch_irqs_disabled_flags(unsigned long flags) 179static inline int arch_irqs_disabled_flags(unsigned long flags)
237{ 180{
@@ -245,7 +188,7 @@ static inline int arch_irqs_disabled_flags(unsigned long flags)
245#endif 188#endif
246} 189}
247 190
248#endif 191#endif /* #ifndef __ASSEMBLY__ */
249 192
250/* 193/*
251 * Do the CPU's IRQ-state tracing from assembly code. 194 * Do the CPU's IRQ-state tracing from assembly code.
diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
index 8debe9e91754..18806a52061c 100644
--- a/arch/mips/include/asm/thread_info.h
+++ b/arch/mips/include/asm/thread_info.h
@@ -112,12 +112,6 @@ register struct thread_info *__current_thread_info __asm__("$28");
112#define TIF_LOAD_WATCH 25 /* If set, load watch registers */ 112#define TIF_LOAD_WATCH 25 /* If set, load watch registers */
113#define TIF_SYSCALL_TRACE 31 /* syscall trace active */ 113#define TIF_SYSCALL_TRACE 31 /* syscall trace active */
114 114
115#ifdef CONFIG_MIPS32_O32
116#define TIF_32BIT TIF_32BIT_REGS
117#elif defined(CONFIG_MIPS32_N32)
118#define TIF_32BIT _TIF_32BIT_ADDR
119#endif /* CONFIG_MIPS32_O32 */
120
121#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 115#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
122#define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 116#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
123#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 117#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index a53f8ec37aac..290dc6a1d7a3 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -79,7 +79,7 @@ static struct resource data_resource = { .name = "Kernel data", };
79void __init add_memory_region(phys_t start, phys_t size, long type) 79void __init add_memory_region(phys_t start, phys_t size, long type)
80{ 80{
81 int x = boot_mem_map.nr_map; 81 int x = boot_mem_map.nr_map;
82 struct boot_mem_map_entry *prev = boot_mem_map.map + x - 1; 82 int i;
83 83
84 /* Sanity check */ 84 /* Sanity check */
85 if (start + size < start) { 85 if (start + size < start) {
@@ -88,15 +88,29 @@ void __init add_memory_region(phys_t start, phys_t size, long type)
88 } 88 }
89 89
90 /* 90 /*
91 * Try to merge with previous entry if any. This is far less than 91 * Try to merge with existing entry, if any.
92 * perfect but is sufficient for most real world cases.
93 */ 92 */
94 if (x && prev->addr + prev->size == start && prev->type == type) { 93 for (i = 0; i < boot_mem_map.nr_map; i++) {
95 prev->size += size; 94 struct boot_mem_map_entry *entry = boot_mem_map.map + i;
95 unsigned long top;
96
97 if (entry->type != type)
98 continue;
99
100 if (start + size < entry->addr)
101 continue; /* no overlap */
102
103 if (entry->addr + entry->size < start)
104 continue; /* no overlap */
105
106 top = max(entry->addr + entry->size, start + size);
107 entry->addr = min(entry->addr, start);
108 entry->size = top - entry->addr;
109
96 return; 110 return;
97 } 111 }
98 112
99 if (x == BOOT_MEM_MAP_MAX) { 113 if (boot_mem_map.nr_map == BOOT_MEM_MAP_MAX) {
100 pr_err("Ooops! Too many entries in the memory map!\n"); 114 pr_err("Ooops! Too many entries in the memory map!\n");
101 return; 115 return;
102 } 116 }
diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile
index c4a82e841c73..eeddc58802e1 100644
--- a/arch/mips/lib/Makefile
+++ b/arch/mips/lib/Makefile
@@ -2,8 +2,9 @@
2# Makefile for MIPS-specific library files.. 2# Makefile for MIPS-specific library files..
3# 3#
4 4
5lib-y += csum_partial.o delay.o memcpy.o memset.o \ 5lib-y += bitops.o csum_partial.o delay.o memcpy.o memset.o \
6 strlen_user.o strncpy_user.o strnlen_user.o uncached.o 6 mips-atomic.o strlen_user.o strncpy_user.o \
7 strnlen_user.o uncached.o
7 8
8obj-y += iomap.o 9obj-y += iomap.o
9obj-$(CONFIG_PCI) += iomap-pci.o 10obj-$(CONFIG_PCI) += iomap-pci.o
diff --git a/arch/mips/lib/bitops.c b/arch/mips/lib/bitops.c
new file mode 100644
index 000000000000..239a9c957b02
--- /dev/null
+++ b/arch/mips/lib/bitops.c
@@ -0,0 +1,179 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (c) 1994-1997, 99, 2000, 06, 07 Ralf Baechle (ralf@linux-mips.org)
7 * Copyright (c) 1999, 2000 Silicon Graphics, Inc.
8 */
9#include <linux/bitops.h>
10#include <linux/irqflags.h>
11#include <linux/export.h>
12
13
14/**
15 * __mips_set_bit - Atomically set a bit in memory. This is called by
16 * set_bit() if it cannot find a faster solution.
17 * @nr: the bit to set
18 * @addr: the address to start counting from
19 */
20void __mips_set_bit(unsigned long nr, volatile unsigned long *addr)
21{
22 volatile unsigned long *a = addr;
23 unsigned bit = nr & SZLONG_MASK;
24 unsigned long mask;
25 unsigned long flags;
26
27 a += nr >> SZLONG_LOG;
28 mask = 1UL << bit;
29 raw_local_irq_save(flags);
30 *a |= mask;
31 raw_local_irq_restore(flags);
32}
33EXPORT_SYMBOL(__mips_set_bit);
34
35
36/**
37 * __mips_clear_bit - Clears a bit in memory. This is called by clear_bit() if
38 * it cannot find a faster solution.
39 * @nr: Bit to clear
40 * @addr: Address to start counting from
41 */
42void __mips_clear_bit(unsigned long nr, volatile unsigned long *addr)
43{
44 volatile unsigned long *a = addr;
45 unsigned bit = nr & SZLONG_MASK;
46 unsigned long mask;
47 unsigned long flags;
48
49 a += nr >> SZLONG_LOG;
50 mask = 1UL << bit;
51 raw_local_irq_save(flags);
52 *a &= ~mask;
53 raw_local_irq_restore(flags);
54}
55EXPORT_SYMBOL(__mips_clear_bit);
56
57
58/**
59 * __mips_change_bit - Toggle a bit in memory. This is called by change_bit()
60 * if it cannot find a faster solution.
61 * @nr: Bit to change
62 * @addr: Address to start counting from
63 */
64void __mips_change_bit(unsigned long nr, volatile unsigned long *addr)
65{
66 volatile unsigned long *a = addr;
67 unsigned bit = nr & SZLONG_MASK;
68 unsigned long mask;
69 unsigned long flags;
70
71 a += nr >> SZLONG_LOG;
72 mask = 1UL << bit;
73 raw_local_irq_save(flags);
74 *a ^= mask;
75 raw_local_irq_restore(flags);
76}
77EXPORT_SYMBOL(__mips_change_bit);
78
79
80/**
81 * __mips_test_and_set_bit - Set a bit and return its old value. This is
82 * called by test_and_set_bit() if it cannot find a faster solution.
83 * @nr: Bit to set
84 * @addr: Address to count from
85 */
86int __mips_test_and_set_bit(unsigned long nr,
87 volatile unsigned long *addr)
88{
89 volatile unsigned long *a = addr;
90 unsigned bit = nr & SZLONG_MASK;
91 unsigned long mask;
92 unsigned long flags;
93 unsigned long res;
94
95 a += nr >> SZLONG_LOG;
96 mask = 1UL << bit;
97 raw_local_irq_save(flags);
98 res = (mask & *a);
99 *a |= mask;
100 raw_local_irq_restore(flags);
101 return res;
102}
103EXPORT_SYMBOL(__mips_test_and_set_bit);
104
105
106/**
107 * __mips_test_and_set_bit_lock - Set a bit and return its old value. This is
108 * called by test_and_set_bit_lock() if it cannot find a faster solution.
109 * @nr: Bit to set
110 * @addr: Address to count from
111 */
112int __mips_test_and_set_bit_lock(unsigned long nr,
113 volatile unsigned long *addr)
114{
115 volatile unsigned long *a = addr;
116 unsigned bit = nr & SZLONG_MASK;
117 unsigned long mask;
118 unsigned long flags;
119 unsigned long res;
120
121 a += nr >> SZLONG_LOG;
122 mask = 1UL << bit;
123 raw_local_irq_save(flags);
124 res = (mask & *a);
125 *a |= mask;
126 raw_local_irq_restore(flags);
127 return res;
128}
129EXPORT_SYMBOL(__mips_test_and_set_bit_lock);
130
131
132/**
133 * __mips_test_and_clear_bit - Clear a bit and return its old value. This is
134 * called by test_and_clear_bit() if it cannot find a faster solution.
135 * @nr: Bit to clear
136 * @addr: Address to count from
137 */
138int __mips_test_and_clear_bit(unsigned long nr, volatile unsigned long *addr)
139{
140 volatile unsigned long *a = addr;
141 unsigned bit = nr & SZLONG_MASK;
142 unsigned long mask;
143 unsigned long flags;
144 unsigned long res;
145
146 a += nr >> SZLONG_LOG;
147 mask = 1UL << bit;
148 raw_local_irq_save(flags);
149 res = (mask & *a);
150 *a &= ~mask;
151 raw_local_irq_restore(flags);
152 return res;
153}
154EXPORT_SYMBOL(__mips_test_and_clear_bit);
155
156
157/**
158 * __mips_test_and_change_bit - Change a bit and return its old value. This is
159 * called by test_and_change_bit() if it cannot find a faster solution.
160 * @nr: Bit to change
161 * @addr: Address to count from
162 */
163int __mips_test_and_change_bit(unsigned long nr, volatile unsigned long *addr)
164{
165 volatile unsigned long *a = addr;
166 unsigned bit = nr & SZLONG_MASK;
167 unsigned long mask;
168 unsigned long flags;
169 unsigned long res;
170
171 a += nr >> SZLONG_LOG;
172 mask = 1UL << bit;
173 raw_local_irq_save(flags);
174 res = (mask & *a);
175 *a ^= mask;
176 raw_local_irq_restore(flags);
177 return res;
178}
179EXPORT_SYMBOL(__mips_test_and_change_bit);
diff --git a/arch/mips/lib/mips-atomic.c b/arch/mips/lib/mips-atomic.c
new file mode 100644
index 000000000000..cd160be3ce4d
--- /dev/null
+++ b/arch/mips/lib/mips-atomic.c
@@ -0,0 +1,176 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994, 95, 96, 97, 98, 99, 2003 by Ralf Baechle
7 * Copyright (C) 1996 by Paul M. Antoine
8 * Copyright (C) 1999 Silicon Graphics
9 * Copyright (C) 2000 MIPS Technologies, Inc.
10 */
11#include <asm/irqflags.h>
12#include <asm/hazards.h>
13#include <linux/compiler.h>
14#include <linux/preempt.h>
15#include <linux/export.h>
16
17#if !defined(CONFIG_CPU_MIPSR2) || defined(CONFIG_MIPS_MT_SMTC)
18
19/*
20 * For cli() we have to insert nops to make sure that the new value
21 * has actually arrived in the status register before the end of this
22 * macro.
23 * R4000/R4400 need three nops, the R4600 two nops and the R10000 needs
24 * no nops at all.
25 */
26/*
27 * For TX49, operating only IE bit is not enough.
28 *
29 * If mfc0 $12 follows store and the mfc0 is last instruction of a
30 * page and fetching the next instruction causes TLB miss, the result
31 * of the mfc0 might wrongly contain EXL bit.
32 *
33 * ERT-TX49H2-027, ERT-TX49H3-012, ERT-TX49HL3-006, ERT-TX49H4-008
34 *
35 * Workaround: mask EXL bit of the result or place a nop before mfc0.
36 */
37__asm__(
38 " .macro arch_local_irq_disable\n"
39 " .set push \n"
40 " .set noat \n"
41#ifdef CONFIG_MIPS_MT_SMTC
42 " mfc0 $1, $2, 1 \n"
43 " ori $1, 0x400 \n"
44 " .set noreorder \n"
45 " mtc0 $1, $2, 1 \n"
46#elif defined(CONFIG_CPU_MIPSR2)
47 /* see irqflags.h for inline function */
48#else
49 " mfc0 $1,$12 \n"
50 " ori $1,0x1f \n"
51 " xori $1,0x1f \n"
52 " .set noreorder \n"
53 " mtc0 $1,$12 \n"
54#endif
55 " irq_disable_hazard \n"
56 " .set pop \n"
57 " .endm \n");
58
59notrace void arch_local_irq_disable(void)
60{
61 preempt_disable();
62 __asm__ __volatile__(
63 "arch_local_irq_disable"
64 : /* no outputs */
65 : /* no inputs */
66 : "memory");
67 preempt_enable();
68}
69EXPORT_SYMBOL(arch_local_irq_disable);
70
71
72__asm__(
73 " .macro arch_local_irq_save result \n"
74 " .set push \n"
75 " .set reorder \n"
76 " .set noat \n"
77#ifdef CONFIG_MIPS_MT_SMTC
78 " mfc0 \\result, $2, 1 \n"
79 " ori $1, \\result, 0x400 \n"
80 " .set noreorder \n"
81 " mtc0 $1, $2, 1 \n"
82 " andi \\result, \\result, 0x400 \n"
83#elif defined(CONFIG_CPU_MIPSR2)
84 /* see irqflags.h for inline function */
85#else
86 " mfc0 \\result, $12 \n"
87 " ori $1, \\result, 0x1f \n"
88 " xori $1, 0x1f \n"
89 " .set noreorder \n"
90 " mtc0 $1, $12 \n"
91#endif
92 " irq_disable_hazard \n"
93 " .set pop \n"
94 " .endm \n");
95
96notrace unsigned long arch_local_irq_save(void)
97{
98 unsigned long flags;
99 preempt_disable();
100 asm volatile("arch_local_irq_save\t%0"
101 : "=r" (flags)
102 : /* no inputs */
103 : "memory");
104 preempt_enable();
105 return flags;
106}
107EXPORT_SYMBOL(arch_local_irq_save);
108
109
110__asm__(
111 " .macro arch_local_irq_restore flags \n"
112 " .set push \n"
113 " .set noreorder \n"
114 " .set noat \n"
115#ifdef CONFIG_MIPS_MT_SMTC
116 "mfc0 $1, $2, 1 \n"
117 "andi \\flags, 0x400 \n"
118 "ori $1, 0x400 \n"
119 "xori $1, 0x400 \n"
120 "or \\flags, $1 \n"
121 "mtc0 \\flags, $2, 1 \n"
122#elif defined(CONFIG_CPU_MIPSR2) && defined(CONFIG_IRQ_CPU)
123 /* see irqflags.h for inline function */
124#elif defined(CONFIG_CPU_MIPSR2)
125 /* see irqflags.h for inline function */
126#else
127 " mfc0 $1, $12 \n"
128 " andi \\flags, 1 \n"
129 " ori $1, 0x1f \n"
130 " xori $1, 0x1f \n"
131 " or \\flags, $1 \n"
132 " mtc0 \\flags, $12 \n"
133#endif
134 " irq_disable_hazard \n"
135 " .set pop \n"
136 " .endm \n");
137
138notrace void arch_local_irq_restore(unsigned long flags)
139{
140 unsigned long __tmp1;
141
142#ifdef CONFIG_MIPS_MT_SMTC
143 /*
144 * SMTC kernel needs to do a software replay of queued
145 * IPIs, at the cost of branch and call overhead on each
146 * local_irq_restore()
147 */
148 if (unlikely(!(flags & 0x0400)))
149 smtc_ipi_replay();
150#endif
151 preempt_disable();
152 __asm__ __volatile__(
153 "arch_local_irq_restore\t%0"
154 : "=r" (__tmp1)
155 : "0" (flags)
156 : "memory");
157 preempt_enable();
158}
159EXPORT_SYMBOL(arch_local_irq_restore);
160
161
162notrace void __arch_local_irq_restore(unsigned long flags)
163{
164 unsigned long __tmp1;
165
166 preempt_disable();
167 __asm__ __volatile__(
168 "arch_local_irq_restore\t%0"
169 : "=r" (__tmp1)
170 : "0" (flags)
171 : "memory");
172 preempt_enable();
173}
174EXPORT_SYMBOL(__arch_local_irq_restore);
175
176#endif /* !defined(CONFIG_CPU_MIPSR2) || defined(CONFIG_MIPS_MT_SMTC) */
diff --git a/arch/mips/mti-malta/malta-platform.c b/arch/mips/mti-malta/malta-platform.c
index 80562b81f0f2..74732177851c 100644
--- a/arch/mips/mti-malta/malta-platform.c
+++ b/arch/mips/mti-malta/malta-platform.c
@@ -29,6 +29,7 @@
29#include <linux/mtd/partitions.h> 29#include <linux/mtd/partitions.h>
30#include <linux/mtd/physmap.h> 30#include <linux/mtd/physmap.h>
31#include <linux/platform_device.h> 31#include <linux/platform_device.h>
32#include <asm/mips-boards/maltaint.h>
32#include <mtd/mtd-abi.h> 33#include <mtd/mtd-abi.h>
33 34
34#define SMC_PORT(base, int) \ 35#define SMC_PORT(base, int) \
@@ -48,7 +49,7 @@ static struct plat_serial8250_port uart8250_data[] = {
48 SMC_PORT(0x2F8, 3), 49 SMC_PORT(0x2F8, 3),
49 { 50 {
50 .mapbase = 0x1f000900, /* The CBUS UART */ 51 .mapbase = 0x1f000900, /* The CBUS UART */
51 .irq = MIPS_CPU_IRQ_BASE + 2, 52 .irq = MIPS_CPU_IRQ_BASE + MIPSCPU_INT_MB2,
52 .uartclk = 3686400, /* Twice the usual clk! */ 53 .uartclk = 3686400, /* Twice the usual clk! */
53 .iotype = UPIO_MEM32, 54 .iotype = UPIO_MEM32,
54 .flags = CBUS_UART_FLAGS, 55 .flags = CBUS_UART_FLAGS,
diff --git a/arch/parisc/kernel/signal32.c b/arch/parisc/kernel/signal32.c
index fd49aeda9eb8..5dede04f2f3e 100644
--- a/arch/parisc/kernel/signal32.c
+++ b/arch/parisc/kernel/signal32.c
@@ -65,7 +65,8 @@ put_sigset32(compat_sigset_t __user *up, sigset_t *set, size_t sz)
65{ 65{
66 compat_sigset_t s; 66 compat_sigset_t s;
67 67
68 if (sz != sizeof *set) panic("put_sigset32()"); 68 if (sz != sizeof *set)
69 return -EINVAL;
69 sigset_64to32(&s, set); 70 sigset_64to32(&s, set);
70 71
71 return copy_to_user(up, &s, sizeof s); 72 return copy_to_user(up, &s, sizeof s);
@@ -77,7 +78,8 @@ get_sigset32(compat_sigset_t __user *up, sigset_t *set, size_t sz)
77 compat_sigset_t s; 78 compat_sigset_t s;
78 int r; 79 int r;
79 80
80 if (sz != sizeof *set) panic("put_sigset32()"); 81 if (sz != sizeof *set)
82 return -EINVAL;
81 83
82 if ((r = copy_from_user(&s, up, sz)) == 0) { 84 if ((r = copy_from_user(&s, up, sz)) == 0) {
83 sigset_32to64(set, &s); 85 sigset_32to64(set, &s);
diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
index 7426e40699bd..f76c10863c62 100644
--- a/arch/parisc/kernel/sys_parisc.c
+++ b/arch/parisc/kernel/sys_parisc.c
@@ -73,6 +73,8 @@ static unsigned long get_shared_area(struct address_space *mapping,
73 struct vm_area_struct *vma; 73 struct vm_area_struct *vma;
74 int offset = mapping ? get_offset(mapping) : 0; 74 int offset = mapping ? get_offset(mapping) : 0;
75 75
76 offset = (offset + (pgoff << PAGE_SHIFT)) & 0x3FF000;
77
76 addr = DCACHE_ALIGN(addr - offset) + offset; 78 addr = DCACHE_ALIGN(addr - offset) + offset;
77 79
78 for (vma = find_vma(current->mm, addr); ; vma = vma->vm_next) { 80 for (vma = find_vma(current->mm, addr); ; vma = vma->vm_next) {
diff --git a/arch/powerpc/boot/dts/mpc5200b.dtsi b/arch/powerpc/boot/dts/mpc5200b.dtsi
index 7ab286ab5300..39ed65a44c5f 100644
--- a/arch/powerpc/boot/dts/mpc5200b.dtsi
+++ b/arch/powerpc/boot/dts/mpc5200b.dtsi
@@ -231,6 +231,12 @@
231 interrupts = <2 7 0>; 231 interrupts = <2 7 0>;
232 }; 232 };
233 233
234 sclpc@3c00 {
235 compatible = "fsl,mpc5200-lpbfifo";
236 reg = <0x3c00 0x60>;
237 interrupts = <2 23 0>;
238 };
239
234 i2c@3d00 { 240 i2c@3d00 {
235 #address-cells = <1>; 241 #address-cells = <1>;
236 #size-cells = <0>; 242 #size-cells = <0>;
diff --git a/arch/powerpc/boot/dts/o2d.dtsi b/arch/powerpc/boot/dts/o2d.dtsi
index 3444eb8f0ade..24f668039295 100644
--- a/arch/powerpc/boot/dts/o2d.dtsi
+++ b/arch/powerpc/boot/dts/o2d.dtsi
@@ -86,12 +86,6 @@
86 reg = <0>; 86 reg = <0>;
87 }; 87 };
88 }; 88 };
89
90 sclpc@3c00 {
91 compatible = "fsl,mpc5200-lpbfifo";
92 reg = <0x3c00 0x60>;
93 interrupts = <3 23 0>;
94 };
95 }; 89 };
96 90
97 localbus { 91 localbus {
diff --git a/arch/powerpc/boot/dts/pcm030.dts b/arch/powerpc/boot/dts/pcm030.dts
index 9e354997eb7e..96512c058033 100644
--- a/arch/powerpc/boot/dts/pcm030.dts
+++ b/arch/powerpc/boot/dts/pcm030.dts
@@ -59,7 +59,7 @@
59 #gpio-cells = <2>; 59 #gpio-cells = <2>;
60 }; 60 };
61 61
62 psc@2000 { /* PSC1 in ac97 mode */ 62 audioplatform: psc@2000 { /* PSC1 in ac97 mode */
63 compatible = "mpc5200b-psc-ac97","fsl,mpc5200b-psc-ac97"; 63 compatible = "mpc5200b-psc-ac97","fsl,mpc5200b-psc-ac97";
64 cell-index = <0>; 64 cell-index = <0>;
65 }; 65 };
@@ -134,4 +134,9 @@
134 localbus { 134 localbus {
135 status = "disabled"; 135 status = "disabled";
136 }; 136 };
137
138 sound {
139 compatible = "phytec,pcm030-audio-fabric";
140 asoc-platform = <&audioplatform>;
141 };
137}; 142};
diff --git a/arch/powerpc/platforms/52xx/mpc52xx_pic.c b/arch/powerpc/platforms/52xx/mpc52xx_pic.c
index 8520b58a5e9a..b89ef65392dc 100644
--- a/arch/powerpc/platforms/52xx/mpc52xx_pic.c
+++ b/arch/powerpc/platforms/52xx/mpc52xx_pic.c
@@ -372,10 +372,11 @@ static int mpc52xx_irqhost_map(struct irq_domain *h, unsigned int virq,
372 case MPC52xx_IRQ_L1_MAIN: irqchip = &mpc52xx_main_irqchip; break; 372 case MPC52xx_IRQ_L1_MAIN: irqchip = &mpc52xx_main_irqchip; break;
373 case MPC52xx_IRQ_L1_PERP: irqchip = &mpc52xx_periph_irqchip; break; 373 case MPC52xx_IRQ_L1_PERP: irqchip = &mpc52xx_periph_irqchip; break;
374 case MPC52xx_IRQ_L1_SDMA: irqchip = &mpc52xx_sdma_irqchip; break; 374 case MPC52xx_IRQ_L1_SDMA: irqchip = &mpc52xx_sdma_irqchip; break;
375 default: 375 case MPC52xx_IRQ_L1_CRIT:
376 pr_err("%s: invalid irq: virq=%i, l1=%i, l2=%i\n", 376 pr_warn("%s: Critical IRQ #%d is unsupported! Nopping it.\n",
377 __func__, virq, l1irq, l2irq); 377 __func__, l2irq);
378 return -EINVAL; 378 irq_set_chip(virq, &no_irq_chip);
379 return 0;
379 } 380 }
380 381
381 irq_set_chip_and_handler(virq, irqchip, handle_level_irq); 382 irq_set_chip_and_handler(virq, irqchip, handle_level_irq);
diff --git a/arch/powerpc/platforms/pseries/eeh_pe.c b/arch/powerpc/platforms/pseries/eeh_pe.c
index 797cd181dc3f..d16c8ded1084 100644
--- a/arch/powerpc/platforms/pseries/eeh_pe.c
+++ b/arch/powerpc/platforms/pseries/eeh_pe.c
@@ -449,7 +449,7 @@ int eeh_rmv_from_parent_pe(struct eeh_dev *edev, int purge_pe)
449 if (list_empty(&pe->edevs)) { 449 if (list_empty(&pe->edevs)) {
450 cnt = 0; 450 cnt = 0;
451 list_for_each_entry(child, &pe->child_list, child) { 451 list_for_each_entry(child, &pe->child_list, child) {
452 if (!(pe->type & EEH_PE_INVALID)) { 452 if (!(child->type & EEH_PE_INVALID)) {
453 cnt++; 453 cnt++;
454 break; 454 break;
455 } 455 }
diff --git a/arch/powerpc/platforms/pseries/msi.c b/arch/powerpc/platforms/pseries/msi.c
index d19f4977c834..e5b084723131 100644
--- a/arch/powerpc/platforms/pseries/msi.c
+++ b/arch/powerpc/platforms/pseries/msi.c
@@ -220,7 +220,8 @@ static struct device_node *find_pe_dn(struct pci_dev *dev, int *total)
220 220
221 /* Get the top level device in the PE */ 221 /* Get the top level device in the PE */
222 edev = of_node_to_eeh_dev(dn); 222 edev = of_node_to_eeh_dev(dn);
223 edev = list_first_entry(&edev->pe->edevs, struct eeh_dev, list); 223 if (edev->pe)
224 edev = list_first_entry(&edev->pe->edevs, struct eeh_dev, list);
224 dn = eeh_dev_to_of_node(edev); 225 dn = eeh_dev_to_of_node(edev);
225 if (!dn) 226 if (!dn)
226 return NULL; 227 return NULL;
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 5dba755a43e6..d385f396dfee 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -96,6 +96,7 @@ config S390
96 select HAVE_MEMBLOCK_NODE_MAP 96 select HAVE_MEMBLOCK_NODE_MAP
97 select HAVE_CMPXCHG_LOCAL 97 select HAVE_CMPXCHG_LOCAL
98 select HAVE_CMPXCHG_DOUBLE 98 select HAVE_CMPXCHG_DOUBLE
99 select HAVE_ALIGNED_STRUCT_PAGE if SLUB
99 select HAVE_VIRT_CPU_ACCOUNTING 100 select HAVE_VIRT_CPU_ACCOUNTING
100 select VIRT_CPU_ACCOUNTING 101 select VIRT_CPU_ACCOUNTING
101 select ARCH_DISCARD_MEMBLOCK 102 select ARCH_DISCARD_MEMBLOCK
diff --git a/arch/s390/include/asm/compat.h b/arch/s390/include/asm/compat.h
index a34a9d612fc0..18cd6b592650 100644
--- a/arch/s390/include/asm/compat.h
+++ b/arch/s390/include/asm/compat.h
@@ -20,7 +20,7 @@
20#define PSW32_MASK_CC 0x00003000UL 20#define PSW32_MASK_CC 0x00003000UL
21#define PSW32_MASK_PM 0x00000f00UL 21#define PSW32_MASK_PM 0x00000f00UL
22 22
23#define PSW32_MASK_USER 0x00003F00UL 23#define PSW32_MASK_USER 0x0000FF00UL
24 24
25#define PSW32_ADDR_AMODE 0x80000000UL 25#define PSW32_ADDR_AMODE 0x80000000UL
26#define PSW32_ADDR_INSN 0x7FFFFFFFUL 26#define PSW32_ADDR_INSN 0x7FFFFFFFUL
diff --git a/arch/s390/include/asm/topology.h b/arch/s390/include/asm/topology.h
index 9ca305383760..9935cbd6a46f 100644
--- a/arch/s390/include/asm/topology.h
+++ b/arch/s390/include/asm/topology.h
@@ -8,6 +8,9 @@ struct cpu;
8 8
9#ifdef CONFIG_SCHED_BOOK 9#ifdef CONFIG_SCHED_BOOK
10 10
11extern unsigned char cpu_socket_id[NR_CPUS];
12#define topology_physical_package_id(cpu) (cpu_socket_id[cpu])
13
11extern unsigned char cpu_core_id[NR_CPUS]; 14extern unsigned char cpu_core_id[NR_CPUS];
12extern cpumask_t cpu_core_map[NR_CPUS]; 15extern cpumask_t cpu_core_map[NR_CPUS];
13 16
diff --git a/arch/s390/include/uapi/asm/ptrace.h b/arch/s390/include/uapi/asm/ptrace.h
index 705588a16d70..a5ca214b34fd 100644
--- a/arch/s390/include/uapi/asm/ptrace.h
+++ b/arch/s390/include/uapi/asm/ptrace.h
@@ -239,7 +239,7 @@ typedef struct
239#define PSW_MASK_EA 0x00000000UL 239#define PSW_MASK_EA 0x00000000UL
240#define PSW_MASK_BA 0x00000000UL 240#define PSW_MASK_BA 0x00000000UL
241 241
242#define PSW_MASK_USER 0x00003F00UL 242#define PSW_MASK_USER 0x0000FF00UL
243 243
244#define PSW_ADDR_AMODE 0x80000000UL 244#define PSW_ADDR_AMODE 0x80000000UL
245#define PSW_ADDR_INSN 0x7FFFFFFFUL 245#define PSW_ADDR_INSN 0x7FFFFFFFUL
@@ -269,7 +269,7 @@ typedef struct
269#define PSW_MASK_EA 0x0000000100000000UL 269#define PSW_MASK_EA 0x0000000100000000UL
270#define PSW_MASK_BA 0x0000000080000000UL 270#define PSW_MASK_BA 0x0000000080000000UL
271 271
272#define PSW_MASK_USER 0x00003F8180000000UL 272#define PSW_MASK_USER 0x0000FF8180000000UL
273 273
274#define PSW_ADDR_AMODE 0x0000000000000000UL 274#define PSW_ADDR_AMODE 0x0000000000000000UL
275#define PSW_ADDR_INSN 0xFFFFFFFFFFFFFFFFUL 275#define PSW_ADDR_INSN 0xFFFFFFFFFFFFFFFFUL
diff --git a/arch/s390/kernel/compat_signal.c b/arch/s390/kernel/compat_signal.c
index a1e8a8694bb7..593fcc9253fc 100644
--- a/arch/s390/kernel/compat_signal.c
+++ b/arch/s390/kernel/compat_signal.c
@@ -309,6 +309,10 @@ static int restore_sigregs32(struct pt_regs *regs,_sigregs32 __user *sregs)
309 regs->psw.mask = (regs->psw.mask & ~PSW_MASK_USER) | 309 regs->psw.mask = (regs->psw.mask & ~PSW_MASK_USER) |
310 (__u64)(regs32.psw.mask & PSW32_MASK_USER) << 32 | 310 (__u64)(regs32.psw.mask & PSW32_MASK_USER) << 32 |
311 (__u64)(regs32.psw.addr & PSW32_ADDR_AMODE); 311 (__u64)(regs32.psw.addr & PSW32_ADDR_AMODE);
312 /* Check for invalid user address space control. */
313 if ((regs->psw.mask & PSW_MASK_ASC) >= (psw_kernel_bits & PSW_MASK_ASC))
314 regs->psw.mask = (psw_user_bits & PSW_MASK_ASC) |
315 (regs->psw.mask & ~PSW_MASK_ASC);
312 regs->psw.addr = (__u64)(regs32.psw.addr & PSW32_ADDR_INSN); 316 regs->psw.addr = (__u64)(regs32.psw.addr & PSW32_ADDR_INSN);
313 for (i = 0; i < NUM_GPRS; i++) 317 for (i = 0; i < NUM_GPRS; i++)
314 regs->gprs[i] = (__u64) regs32.gprs[i]; 318 regs->gprs[i] = (__u64) regs32.gprs[i];
@@ -481,7 +485,10 @@ static int setup_frame32(int sig, struct k_sigaction *ka,
481 485
482 /* Set up registers for signal handler */ 486 /* Set up registers for signal handler */
483 regs->gprs[15] = (__force __u64) frame; 487 regs->gprs[15] = (__force __u64) frame;
484 regs->psw.mask |= PSW_MASK_BA; /* force amode 31 */ 488 /* Force 31 bit amode and default user address space control. */
489 regs->psw.mask = PSW_MASK_BA |
490 (psw_user_bits & PSW_MASK_ASC) |
491 (regs->psw.mask & ~PSW_MASK_ASC);
485 regs->psw.addr = (__force __u64) ka->sa.sa_handler; 492 regs->psw.addr = (__force __u64) ka->sa.sa_handler;
486 493
487 regs->gprs[2] = map_signal(sig); 494 regs->gprs[2] = map_signal(sig);
@@ -549,7 +556,10 @@ static int setup_rt_frame32(int sig, struct k_sigaction *ka, siginfo_t *info,
549 556
550 /* Set up registers for signal handler */ 557 /* Set up registers for signal handler */
551 regs->gprs[15] = (__force __u64) frame; 558 regs->gprs[15] = (__force __u64) frame;
552 regs->psw.mask |= PSW_MASK_BA; /* force amode 31 */ 559 /* Force 31 bit amode and default user address space control. */
560 regs->psw.mask = PSW_MASK_BA |
561 (psw_user_bits & PSW_MASK_ASC) |
562 (regs->psw.mask & ~PSW_MASK_ASC);
553 regs->psw.addr = (__u64) ka->sa.sa_handler; 563 regs->psw.addr = (__u64) ka->sa.sa_handler;
554 564
555 regs->gprs[2] = map_signal(sig); 565 regs->gprs[2] = map_signal(sig);
diff --git a/arch/s390/kernel/signal.c b/arch/s390/kernel/signal.c
index c13a2a37ef00..d1259d875074 100644
--- a/arch/s390/kernel/signal.c
+++ b/arch/s390/kernel/signal.c
@@ -136,6 +136,10 @@ static int restore_sigregs(struct pt_regs *regs, _sigregs __user *sregs)
136 /* Use regs->psw.mask instead of psw_user_bits to preserve PER bit. */ 136 /* Use regs->psw.mask instead of psw_user_bits to preserve PER bit. */
137 regs->psw.mask = (regs->psw.mask & ~PSW_MASK_USER) | 137 regs->psw.mask = (regs->psw.mask & ~PSW_MASK_USER) |
138 (user_sregs.regs.psw.mask & PSW_MASK_USER); 138 (user_sregs.regs.psw.mask & PSW_MASK_USER);
139 /* Check for invalid user address space control. */
140 if ((regs->psw.mask & PSW_MASK_ASC) >= (psw_kernel_bits & PSW_MASK_ASC))
141 regs->psw.mask = (psw_user_bits & PSW_MASK_ASC) |
142 (regs->psw.mask & ~PSW_MASK_ASC);
139 /* Check for invalid amode */ 143 /* Check for invalid amode */
140 if (regs->psw.mask & PSW_MASK_EA) 144 if (regs->psw.mask & PSW_MASK_EA)
141 regs->psw.mask |= PSW_MASK_BA; 145 regs->psw.mask |= PSW_MASK_BA;
@@ -273,7 +277,10 @@ static int setup_frame(int sig, struct k_sigaction *ka,
273 277
274 /* Set up registers for signal handler */ 278 /* Set up registers for signal handler */
275 regs->gprs[15] = (unsigned long) frame; 279 regs->gprs[15] = (unsigned long) frame;
276 regs->psw.mask |= PSW_MASK_EA | PSW_MASK_BA; /* 64 bit amode */ 280 /* Force default amode and default user address space control. */
281 regs->psw.mask = PSW_MASK_EA | PSW_MASK_BA |
282 (psw_user_bits & PSW_MASK_ASC) |
283 (regs->psw.mask & ~PSW_MASK_ASC);
277 regs->psw.addr = (unsigned long) ka->sa.sa_handler | PSW_ADDR_AMODE; 284 regs->psw.addr = (unsigned long) ka->sa.sa_handler | PSW_ADDR_AMODE;
278 285
279 regs->gprs[2] = map_signal(sig); 286 regs->gprs[2] = map_signal(sig);
@@ -346,7 +353,10 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
346 353
347 /* Set up registers for signal handler */ 354 /* Set up registers for signal handler */
348 regs->gprs[15] = (unsigned long) frame; 355 regs->gprs[15] = (unsigned long) frame;
349 regs->psw.mask |= PSW_MASK_EA | PSW_MASK_BA; /* 64 bit amode */ 356 /* Force default amode and default user address space control. */
357 regs->psw.mask = PSW_MASK_EA | PSW_MASK_BA |
358 (psw_user_bits & PSW_MASK_ASC) |
359 (regs->psw.mask & ~PSW_MASK_ASC);
350 regs->psw.addr = (unsigned long) ka->sa.sa_handler | PSW_ADDR_AMODE; 360 regs->psw.addr = (unsigned long) ka->sa.sa_handler | PSW_ADDR_AMODE;
351 361
352 regs->gprs[2] = map_signal(sig); 362 regs->gprs[2] = map_signal(sig);
diff --git a/arch/s390/kernel/topology.c b/arch/s390/kernel/topology.c
index 54d93f4b6818..dd55f7c20104 100644
--- a/arch/s390/kernel/topology.c
+++ b/arch/s390/kernel/topology.c
@@ -40,6 +40,7 @@ static DEFINE_SPINLOCK(topology_lock);
40static struct mask_info core_info; 40static struct mask_info core_info;
41cpumask_t cpu_core_map[NR_CPUS]; 41cpumask_t cpu_core_map[NR_CPUS];
42unsigned char cpu_core_id[NR_CPUS]; 42unsigned char cpu_core_id[NR_CPUS];
43unsigned char cpu_socket_id[NR_CPUS];
43 44
44static struct mask_info book_info; 45static struct mask_info book_info;
45cpumask_t cpu_book_map[NR_CPUS]; 46cpumask_t cpu_book_map[NR_CPUS];
@@ -83,11 +84,12 @@ static struct mask_info *add_cpus_to_mask(struct topology_cpu *tl_cpu,
83 cpumask_set_cpu(lcpu, &book->mask); 84 cpumask_set_cpu(lcpu, &book->mask);
84 cpu_book_id[lcpu] = book->id; 85 cpu_book_id[lcpu] = book->id;
85 cpumask_set_cpu(lcpu, &core->mask); 86 cpumask_set_cpu(lcpu, &core->mask);
87 cpu_core_id[lcpu] = rcpu;
86 if (one_core_per_cpu) { 88 if (one_core_per_cpu) {
87 cpu_core_id[lcpu] = rcpu; 89 cpu_socket_id[lcpu] = rcpu;
88 core = core->next; 90 core = core->next;
89 } else { 91 } else {
90 cpu_core_id[lcpu] = core->id; 92 cpu_socket_id[lcpu] = core->id;
91 } 93 }
92 smp_cpu_set_polarization(lcpu, tl_cpu->pp); 94 smp_cpu_set_polarization(lcpu, tl_cpu->pp);
93 } 95 }
diff --git a/arch/s390/mm/gup.c b/arch/s390/mm/gup.c
index 8b8285310b5a..1f5315d1215c 100644
--- a/arch/s390/mm/gup.c
+++ b/arch/s390/mm/gup.c
@@ -180,8 +180,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
180 addr = start; 180 addr = start;
181 len = (unsigned long) nr_pages << PAGE_SHIFT; 181 len = (unsigned long) nr_pages << PAGE_SHIFT;
182 end = start + len; 182 end = start + len;
183 if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ, 183 if ((end < start) || (end > TASK_SIZE))
184 (void __user *)start, len)))
185 return 0; 184 return 0;
186 185
187 local_irq_save(flags); 186 local_irq_save(flags);
@@ -229,7 +228,7 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
229 addr = start; 228 addr = start;
230 len = (unsigned long) nr_pages << PAGE_SHIFT; 229 len = (unsigned long) nr_pages << PAGE_SHIFT;
231 end = start + len; 230 end = start + len;
232 if (end < start) 231 if ((end < start) || (end > TASK_SIZE))
233 goto slow_irqon; 232 goto slow_irqon;
234 233
235 /* 234 /*
diff --git a/arch/sparc/include/asm/prom.h b/arch/sparc/include/asm/prom.h
index f93003123bce..67c62578d170 100644
--- a/arch/sparc/include/asm/prom.h
+++ b/arch/sparc/include/asm/prom.h
@@ -63,10 +63,13 @@ extern char *of_console_options;
63extern void irq_trans_init(struct device_node *dp); 63extern void irq_trans_init(struct device_node *dp);
64extern char *build_path_component(struct device_node *dp); 64extern char *build_path_component(struct device_node *dp);
65 65
66/* SPARC has a local implementation */ 66/* SPARC has local implementations */
67extern int of_address_to_resource(struct device_node *dev, int index, 67extern int of_address_to_resource(struct device_node *dev, int index,
68 struct resource *r); 68 struct resource *r);
69#define of_address_to_resource of_address_to_resource 69#define of_address_to_resource of_address_to_resource
70 70
71void __iomem *of_iomap(struct device_node *node, int index);
72#define of_iomap of_iomap
73
71#endif /* __KERNEL__ */ 74#endif /* __KERNEL__ */
72#endif /* _SPARC_PROM_H */ 75#endif /* _SPARC_PROM_H */
diff --git a/arch/sparc/kernel/signal_64.c b/arch/sparc/kernel/signal_64.c
index 867de2f8189c..689e1ba62809 100644
--- a/arch/sparc/kernel/signal_64.c
+++ b/arch/sparc/kernel/signal_64.c
@@ -295,9 +295,7 @@ void do_rt_sigreturn(struct pt_regs *regs)
295 err |= restore_fpu_state(regs, fpu_save); 295 err |= restore_fpu_state(regs, fpu_save);
296 296
297 err |= __copy_from_user(&set, &sf->mask, sizeof(sigset_t)); 297 err |= __copy_from_user(&set, &sf->mask, sizeof(sigset_t));
298 err |= do_sigaltstack(&sf->stack, NULL, (unsigned long)sf); 298 if (err || do_sigaltstack(&sf->stack, NULL, (unsigned long)sf) == -EFAULT)
299
300 if (err)
301 goto segv; 299 goto segv;
302 300
303 err |= __get_user(rwin_save, &sf->rwin_save); 301 err |= __get_user(rwin_save, &sf->rwin_save);
diff --git a/arch/unicore32/Kconfig b/arch/unicore32/Kconfig
index e5c5473e69ce..c4fbb21e802b 100644
--- a/arch/unicore32/Kconfig
+++ b/arch/unicore32/Kconfig
@@ -16,6 +16,8 @@ config UNICORE32
16 select ARCH_WANT_FRAME_POINTERS 16 select ARCH_WANT_FRAME_POINTERS
17 select GENERIC_IOMAP 17 select GENERIC_IOMAP
18 select MODULES_USE_ELF_REL 18 select MODULES_USE_ELF_REL
19 select GENERIC_KERNEL_THREAD
20 select GENERIC_KERNEL_EXECVE
19 help 21 help
20 UniCore-32 is 32-bit Instruction Set Architecture, 22 UniCore-32 is 32-bit Instruction Set Architecture,
21 including a series of low-power-consumption RISC chip 23 including a series of low-power-consumption RISC chip
@@ -64,6 +66,9 @@ config GENERIC_CALIBRATE_DELAY
64config ARCH_MAY_HAVE_PC_FDC 66config ARCH_MAY_HAVE_PC_FDC
65 bool 67 bool
66 68
69config ZONE_DMA
70 def_bool y
71
67config NEED_DMA_MAP_STATE 72config NEED_DMA_MAP_STATE
68 def_bool y 73 def_bool y
69 74
@@ -216,7 +221,7 @@ config PUV3_GPIO
216 bool 221 bool
217 depends on !ARCH_FPGA 222 depends on !ARCH_FPGA
218 select GENERIC_GPIO 223 select GENERIC_GPIO
219 select GPIO_SYSFS if EXPERIMENTAL 224 select GPIO_SYSFS
220 default y 225 default y
221 226
222if PUV3_NB0916 227if PUV3_NB0916
diff --git a/arch/unicore32/include/asm/Kbuild b/arch/unicore32/include/asm/Kbuild
index c910c9857e11..601e92f18af6 100644
--- a/arch/unicore32/include/asm/Kbuild
+++ b/arch/unicore32/include/asm/Kbuild
@@ -1,4 +1,3 @@
1include include/asm-generic/Kbuild.asm
2 1
3generic-y += atomic.h 2generic-y += atomic.h
4generic-y += auxvec.h 3generic-y += auxvec.h
diff --git a/arch/unicore32/include/asm/bug.h b/arch/unicore32/include/asm/bug.h
index b1ff8cadb086..93a56f3e2344 100644
--- a/arch/unicore32/include/asm/bug.h
+++ b/arch/unicore32/include/asm/bug.h
@@ -19,9 +19,4 @@ extern void die(const char *msg, struct pt_regs *regs, int err);
19extern void uc32_notify_die(const char *str, struct pt_regs *regs, 19extern void uc32_notify_die(const char *str, struct pt_regs *regs,
20 struct siginfo *info, unsigned long err, unsigned long trap); 20 struct siginfo *info, unsigned long err, unsigned long trap);
21 21
22extern asmlinkage void __backtrace(void);
23extern asmlinkage void c_backtrace(unsigned long fp, int pmode);
24
25extern void __show_regs(struct pt_regs *);
26
27#endif /* __UNICORE_BUG_H__ */ 22#endif /* __UNICORE_BUG_H__ */
diff --git a/arch/unicore32/include/asm/cmpxchg.h b/arch/unicore32/include/asm/cmpxchg.h
index df4d5acfd19f..8e797ad4fa24 100644
--- a/arch/unicore32/include/asm/cmpxchg.h
+++ b/arch/unicore32/include/asm/cmpxchg.h
@@ -35,7 +35,7 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr,
35 : "memory", "cc"); 35 : "memory", "cc");
36 break; 36 break;
37 default: 37 default:
38 ret = __xchg_bad_pointer(); 38 __xchg_bad_pointer();
39 } 39 }
40 40
41 return ret; 41 return ret;
diff --git a/arch/unicore32/include/asm/kvm_para.h b/arch/unicore32/include/asm/kvm_para.h
deleted file mode 100644
index 14fab8f0b957..000000000000
--- a/arch/unicore32/include/asm/kvm_para.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/kvm_para.h>
diff --git a/arch/unicore32/include/asm/processor.h b/arch/unicore32/include/asm/processor.h
index 14382cb09657..4eaa42167667 100644
--- a/arch/unicore32/include/asm/processor.h
+++ b/arch/unicore32/include/asm/processor.h
@@ -72,11 +72,6 @@ unsigned long get_wchan(struct task_struct *p);
72 72
73#define cpu_relax() barrier() 73#define cpu_relax() barrier()
74 74
75/*
76 * Create a new kernel thread
77 */
78extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
79
80#define task_pt_regs(p) \ 75#define task_pt_regs(p) \
81 ((struct pt_regs *)(THREAD_START_SP + task_stack_page(p)) - 1) 76 ((struct pt_regs *)(THREAD_START_SP + task_stack_page(p)) - 1)
82 77
diff --git a/arch/unicore32/include/asm/ptrace.h b/arch/unicore32/include/asm/ptrace.h
index b9caf9b0997b..726749dab52f 100644
--- a/arch/unicore32/include/asm/ptrace.h
+++ b/arch/unicore32/include/asm/ptrace.h
@@ -12,80 +12,10 @@
12#ifndef __UNICORE_PTRACE_H__ 12#ifndef __UNICORE_PTRACE_H__
13#define __UNICORE_PTRACE_H__ 13#define __UNICORE_PTRACE_H__
14 14
15#define PTRACE_GET_THREAD_AREA 22 15#include <uapi/asm/ptrace.h>
16
17/*
18 * PSR bits
19 */
20#define USER_MODE 0x00000010
21#define REAL_MODE 0x00000011
22#define INTR_MODE 0x00000012
23#define PRIV_MODE 0x00000013
24#define ABRT_MODE 0x00000017
25#define EXTN_MODE 0x0000001b
26#define SUSR_MODE 0x0000001f
27#define MODE_MASK 0x0000001f
28#define PSR_R_BIT 0x00000040
29#define PSR_I_BIT 0x00000080
30#define PSR_V_BIT 0x10000000
31#define PSR_C_BIT 0x20000000
32#define PSR_Z_BIT 0x40000000
33#define PSR_S_BIT 0x80000000
34
35/*
36 * Groups of PSR bits
37 */
38#define PSR_f 0xff000000 /* Flags */
39#define PSR_c 0x000000ff /* Control */
40 16
41#ifndef __ASSEMBLY__ 17#ifndef __ASSEMBLY__
42 18
43/*
44 * This struct defines the way the registers are stored on the
45 * stack during a system call. Note that sizeof(struct pt_regs)
46 * has to be a multiple of 8.
47 */
48struct pt_regs {
49 unsigned long uregs[34];
50};
51
52#define UCreg_asr uregs[32]
53#define UCreg_pc uregs[31]
54#define UCreg_lr uregs[30]
55#define UCreg_sp uregs[29]
56#define UCreg_ip uregs[28]
57#define UCreg_fp uregs[27]
58#define UCreg_26 uregs[26]
59#define UCreg_25 uregs[25]
60#define UCreg_24 uregs[24]
61#define UCreg_23 uregs[23]
62#define UCreg_22 uregs[22]
63#define UCreg_21 uregs[21]
64#define UCreg_20 uregs[20]
65#define UCreg_19 uregs[19]
66#define UCreg_18 uregs[18]
67#define UCreg_17 uregs[17]
68#define UCreg_16 uregs[16]
69#define UCreg_15 uregs[15]
70#define UCreg_14 uregs[14]
71#define UCreg_13 uregs[13]
72#define UCreg_12 uregs[12]
73#define UCreg_11 uregs[11]
74#define UCreg_10 uregs[10]
75#define UCreg_09 uregs[9]
76#define UCreg_08 uregs[8]
77#define UCreg_07 uregs[7]
78#define UCreg_06 uregs[6]
79#define UCreg_05 uregs[5]
80#define UCreg_04 uregs[4]
81#define UCreg_03 uregs[3]
82#define UCreg_02 uregs[2]
83#define UCreg_01 uregs[1]
84#define UCreg_00 uregs[0]
85#define UCreg_ORIG_00 uregs[33]
86
87#ifdef __KERNEL__
88
89#define user_mode(regs) \ 19#define user_mode(regs) \
90 (processor_mode(regs) == USER_MODE) 20 (processor_mode(regs) == USER_MODE)
91 21
@@ -125,9 +55,5 @@ static inline int valid_user_regs(struct pt_regs *regs)
125 55
126#define instruction_pointer(regs) ((regs)->UCreg_pc) 56#define instruction_pointer(regs) ((regs)->UCreg_pc)
127 57
128#endif /* __KERNEL__ */
129
130#endif /* __ASSEMBLY__ */ 58#endif /* __ASSEMBLY__ */
131
132#endif 59#endif
133
diff --git a/arch/unicore32/include/uapi/asm/Kbuild b/arch/unicore32/include/uapi/asm/Kbuild
index baebb3da1d44..0514d7ad6855 100644
--- a/arch/unicore32/include/uapi/asm/Kbuild
+++ b/arch/unicore32/include/uapi/asm/Kbuild
@@ -1,3 +1,10 @@
1# UAPI Header export list 1# UAPI Header export list
2include include/uapi/asm-generic/Kbuild.asm 2include include/uapi/asm-generic/Kbuild.asm
3 3
4header-y += byteorder.h
5header-y += kvm_para.h
6header-y += ptrace.h
7header-y += sigcontext.h
8header-y += unistd.h
9
10generic-y += kvm_para.h
diff --git a/arch/unicore32/include/asm/byteorder.h b/arch/unicore32/include/uapi/asm/byteorder.h
index ebe1b3fef3e3..ebe1b3fef3e3 100644
--- a/arch/unicore32/include/asm/byteorder.h
+++ b/arch/unicore32/include/uapi/asm/byteorder.h
diff --git a/arch/unicore32/include/uapi/asm/ptrace.h b/arch/unicore32/include/uapi/asm/ptrace.h
new file mode 100644
index 000000000000..187aa2e98a53
--- /dev/null
+++ b/arch/unicore32/include/uapi/asm/ptrace.h
@@ -0,0 +1,90 @@
1/*
2 * linux/arch/unicore32/include/asm/ptrace.h
3 *
4 * Code specific to PKUnity SoC and UniCore ISA
5 *
6 * Copyright (C) 2001-2010 GUAN Xue-tao
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#ifndef _UAPI__UNICORE_PTRACE_H__
13#define _UAPI__UNICORE_PTRACE_H__
14
15#define PTRACE_GET_THREAD_AREA 22
16
17/*
18 * PSR bits
19 */
20#define USER_MODE 0x00000010
21#define REAL_MODE 0x00000011
22#define INTR_MODE 0x00000012
23#define PRIV_MODE 0x00000013
24#define ABRT_MODE 0x00000017
25#define EXTN_MODE 0x0000001b
26#define SUSR_MODE 0x0000001f
27#define MODE_MASK 0x0000001f
28#define PSR_R_BIT 0x00000040
29#define PSR_I_BIT 0x00000080
30#define PSR_V_BIT 0x10000000
31#define PSR_C_BIT 0x20000000
32#define PSR_Z_BIT 0x40000000
33#define PSR_S_BIT 0x80000000
34
35/*
36 * Groups of PSR bits
37 */
38#define PSR_f 0xff000000 /* Flags */
39#define PSR_c 0x000000ff /* Control */
40
41#ifndef __ASSEMBLY__
42
43/*
44 * This struct defines the way the registers are stored on the
45 * stack during a system call. Note that sizeof(struct pt_regs)
46 * has to be a multiple of 8.
47 */
48struct pt_regs {
49 unsigned long uregs[34];
50};
51
52#define UCreg_asr uregs[32]
53#define UCreg_pc uregs[31]
54#define UCreg_lr uregs[30]
55#define UCreg_sp uregs[29]
56#define UCreg_ip uregs[28]
57#define UCreg_fp uregs[27]
58#define UCreg_26 uregs[26]
59#define UCreg_25 uregs[25]
60#define UCreg_24 uregs[24]
61#define UCreg_23 uregs[23]
62#define UCreg_22 uregs[22]
63#define UCreg_21 uregs[21]
64#define UCreg_20 uregs[20]
65#define UCreg_19 uregs[19]
66#define UCreg_18 uregs[18]
67#define UCreg_17 uregs[17]
68#define UCreg_16 uregs[16]
69#define UCreg_15 uregs[15]
70#define UCreg_14 uregs[14]
71#define UCreg_13 uregs[13]
72#define UCreg_12 uregs[12]
73#define UCreg_11 uregs[11]
74#define UCreg_10 uregs[10]
75#define UCreg_09 uregs[9]
76#define UCreg_08 uregs[8]
77#define UCreg_07 uregs[7]
78#define UCreg_06 uregs[6]
79#define UCreg_05 uregs[5]
80#define UCreg_04 uregs[4]
81#define UCreg_03 uregs[3]
82#define UCreg_02 uregs[2]
83#define UCreg_01 uregs[1]
84#define UCreg_00 uregs[0]
85#define UCreg_ORIG_00 uregs[33]
86
87
88#endif /* __ASSEMBLY__ */
89
90#endif /* _UAPI__UNICORE_PTRACE_H__ */
diff --git a/arch/unicore32/include/asm/sigcontext.h b/arch/unicore32/include/uapi/asm/sigcontext.h
index 6a2d7671c052..6a2d7671c052 100644
--- a/arch/unicore32/include/asm/sigcontext.h
+++ b/arch/unicore32/include/uapi/asm/sigcontext.h
diff --git a/arch/unicore32/include/asm/unistd.h b/arch/unicore32/include/uapi/asm/unistd.h
index 2abcf61c615d..d18a3be89b38 100644
--- a/arch/unicore32/include/asm/unistd.h
+++ b/arch/unicore32/include/uapi/asm/unistd.h
@@ -12,3 +12,4 @@
12 12
13/* Use the standard ABI for syscalls. */ 13/* Use the standard ABI for syscalls. */
14#include <asm-generic/unistd.h> 14#include <asm-generic/unistd.h>
15#define __ARCH_WANT_SYS_EXECVE
diff --git a/arch/unicore32/kernel/entry.S b/arch/unicore32/kernel/entry.S
index dcb87ab19ddd..7049350c790f 100644
--- a/arch/unicore32/kernel/entry.S
+++ b/arch/unicore32/kernel/entry.S
@@ -573,17 +573,16 @@ ENDPROC(ret_to_user)
573 */ 573 */
574ENTRY(ret_from_fork) 574ENTRY(ret_from_fork)
575 b.l schedule_tail 575 b.l schedule_tail
576 get_thread_info tsk
577 ldw r1, [tsk+], #TI_FLAGS @ check for syscall tracing
578 mov why, #1
579 cand.a r1, #_TIF_SYSCALL_TRACE @ are we tracing syscalls?
580 beq ret_slow_syscall
581 mov r1, sp
582 mov r0, #1 @ trace exit [IP = 1]
583 b.l syscall_trace
584 b ret_slow_syscall 576 b ret_slow_syscall
585ENDPROC(ret_from_fork) 577ENDPROC(ret_from_fork)
586 578
579ENTRY(ret_from_kernel_thread)
580 b.l schedule_tail
581 mov r0, r5
582 adr lr, ret_slow_syscall
583 mov pc, r4
584ENDPROC(ret_from_kernel_thread)
585
587/*============================================================================= 586/*=============================================================================
588 * SWI handler 587 * SWI handler
589 *----------------------------------------------------------------------------- 588 *-----------------------------------------------------------------------------
@@ -669,11 +668,6 @@ __cr_alignment:
669#endif 668#endif
670 .ltorg 669 .ltorg
671 670
672ENTRY(sys_execve)
673 add r3, sp, #S_OFF
674 b __sys_execve
675ENDPROC(sys_execve)
676
677ENTRY(sys_clone) 671ENTRY(sys_clone)
678 add ip, sp, #S_OFF 672 add ip, sp, #S_OFF
679 stw ip, [sp+], #4 673 stw ip, [sp+], #4
diff --git a/arch/unicore32/kernel/process.c b/arch/unicore32/kernel/process.c
index b008586dad75..a8fe265ce2c0 100644
--- a/arch/unicore32/kernel/process.c
+++ b/arch/unicore32/kernel/process.c
@@ -258,6 +258,7 @@ void release_thread(struct task_struct *dead_task)
258} 258}
259 259
260asmlinkage void ret_from_fork(void) __asm__("ret_from_fork"); 260asmlinkage void ret_from_fork(void) __asm__("ret_from_fork");
261asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
261 262
262int 263int
263copy_thread(unsigned long clone_flags, unsigned long stack_start, 264copy_thread(unsigned long clone_flags, unsigned long stack_start,
@@ -266,17 +267,22 @@ copy_thread(unsigned long clone_flags, unsigned long stack_start,
266 struct thread_info *thread = task_thread_info(p); 267 struct thread_info *thread = task_thread_info(p);
267 struct pt_regs *childregs = task_pt_regs(p); 268 struct pt_regs *childregs = task_pt_regs(p);
268 269
269 *childregs = *regs;
270 childregs->UCreg_00 = 0;
271 childregs->UCreg_sp = stack_start;
272
273 memset(&thread->cpu_context, 0, sizeof(struct cpu_context_save)); 270 memset(&thread->cpu_context, 0, sizeof(struct cpu_context_save));
274 thread->cpu_context.sp = (unsigned long)childregs; 271 thread->cpu_context.sp = (unsigned long)childregs;
275 thread->cpu_context.pc = (unsigned long)ret_from_fork; 272 if (unlikely(!regs)) {
276 273 thread->cpu_context.pc = (unsigned long)ret_from_kernel_thread;
277 if (clone_flags & CLONE_SETTLS) 274 thread->cpu_context.r4 = stack_start;
278 childregs->UCreg_16 = regs->UCreg_03; 275 thread->cpu_context.r5 = stk_sz;
276 memset(childregs, 0, sizeof(struct pt_regs));
277 } else {
278 thread->cpu_context.pc = (unsigned long)ret_from_fork;
279 *childregs = *regs;
280 childregs->UCreg_00 = 0;
281 childregs->UCreg_sp = stack_start;
279 282
283 if (clone_flags & CLONE_SETTLS)
284 childregs->UCreg_16 = regs->UCreg_03;
285 }
280 return 0; 286 return 0;
281} 287}
282 288
@@ -305,42 +311,6 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fp)
305} 311}
306EXPORT_SYMBOL(dump_fpu); 312EXPORT_SYMBOL(dump_fpu);
307 313
308/*
309 * Shuffle the argument into the correct register before calling the
310 * thread function. r1 is the thread argument, r2 is the pointer to
311 * the thread function, and r3 points to the exit function.
312 */
313asm(".pushsection .text\n"
314" .align\n"
315" .type kernel_thread_helper, #function\n"
316"kernel_thread_helper:\n"
317" mov.a asr, r7\n"
318" mov r0, r4\n"
319" mov lr, r6\n"
320" mov pc, r5\n"
321" .size kernel_thread_helper, . - kernel_thread_helper\n"
322" .popsection");
323
324/*
325 * Create a kernel thread.
326 */
327pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
328{
329 struct pt_regs regs;
330
331 memset(&regs, 0, sizeof(regs));
332
333 regs.UCreg_04 = (unsigned long)arg;
334 regs.UCreg_05 = (unsigned long)fn;
335 regs.UCreg_06 = (unsigned long)do_exit;
336 regs.UCreg_07 = PRIV_MODE;
337 regs.UCreg_pc = (unsigned long)kernel_thread_helper;
338 regs.UCreg_asr = regs.UCreg_07 | PSR_I_BIT;
339
340 return do_fork(flags|CLONE_VM|CLONE_UNTRACED, 0, &regs, 0, NULL, NULL);
341}
342EXPORT_SYMBOL(kernel_thread);
343
344unsigned long get_wchan(struct task_struct *p) 314unsigned long get_wchan(struct task_struct *p)
345{ 315{
346 struct stackframe frame; 316 struct stackframe frame;
diff --git a/arch/unicore32/kernel/setup.h b/arch/unicore32/kernel/setup.h
index f23955028a18..30f749da8f73 100644
--- a/arch/unicore32/kernel/setup.h
+++ b/arch/unicore32/kernel/setup.h
@@ -30,4 +30,10 @@ extern char __vectors_start[], __vectors_end[];
30extern void kernel_thread_helper(void); 30extern void kernel_thread_helper(void);
31 31
32extern void __init early_signal_init(void); 32extern void __init early_signal_init(void);
33
34extern asmlinkage void __backtrace(void);
35extern asmlinkage void c_backtrace(unsigned long fp, int pmode);
36
37extern void __show_regs(struct pt_regs *);
38
33#endif 39#endif
diff --git a/arch/unicore32/kernel/sys.c b/arch/unicore32/kernel/sys.c
index fabdee96110b..9680134b31f0 100644
--- a/arch/unicore32/kernel/sys.c
+++ b/arch/unicore32/kernel/sys.c
@@ -42,69 +42,6 @@ asmlinkage long __sys_clone(unsigned long clone_flags, unsigned long newsp,
42 parent_tid, child_tid); 42 parent_tid, child_tid);
43} 43}
44 44
45/* sys_execve() executes a new program.
46 * This is called indirectly via a small wrapper
47 */
48asmlinkage long __sys_execve(const char __user *filename,
49 const char __user *const __user *argv,
50 const char __user *const __user *envp,
51 struct pt_regs *regs)
52{
53 int error;
54 struct filename *fn;
55
56 fn = getname(filename);
57 error = PTR_ERR(fn);
58 if (IS_ERR(fn))
59 goto out;
60 error = do_execve(fn->name, argv, envp, regs);
61 putname(fn);
62out:
63 return error;
64}
65
66int kernel_execve(const char *filename,
67 const char *const argv[],
68 const char *const envp[])
69{
70 struct pt_regs regs;
71 int ret;
72
73 memset(&regs, 0, sizeof(struct pt_regs));
74 ret = do_execve(filename,
75 (const char __user *const __user *)argv,
76 (const char __user *const __user *)envp, &regs);
77 if (ret < 0)
78 goto out;
79
80 /*
81 * Save argc to the register structure for userspace.
82 */
83 regs.UCreg_00 = ret;
84
85 /*
86 * We were successful. We won't be returning to our caller, but
87 * instead to user space by manipulating the kernel stack.
88 */
89 asm("add r0, %0, %1\n\t"
90 "mov r1, %2\n\t"
91 "mov r2, %3\n\t"
92 "mov r22, #0\n\t" /* not a syscall */
93 "mov r23, %0\n\t" /* thread structure */
94 "b.l memmove\n\t" /* copy regs to top of stack */
95 "mov sp, r0\n\t" /* reposition stack pointer */
96 "b ret_to_user"
97 :
98 : "r" (current_thread_info()),
99 "Ir" (THREAD_START_SP - sizeof(regs)),
100 "r" (&regs),
101 "Ir" (sizeof(regs))
102 : "r0", "r1", "r2", "r3", "ip", "lr", "memory");
103
104 out:
105 return ret;
106}
107
108/* Note: used by the compat code even in 64-bit Linux. */ 45/* Note: used by the compat code even in 64-bit Linux. */
109SYSCALL_DEFINE6(mmap2, unsigned long, addr, unsigned long, len, 46SYSCALL_DEFINE6(mmap2, unsigned long, addr, unsigned long, len,
110 unsigned long, prot, unsigned long, flags, 47 unsigned long, prot, unsigned long, flags,
diff --git a/arch/unicore32/mm/fault.c b/arch/unicore32/mm/fault.c
index 2eeb9c04cab0..f9b5c10bccee 100644
--- a/arch/unicore32/mm/fault.c
+++ b/arch/unicore32/mm/fault.c
@@ -168,7 +168,7 @@ static inline bool access_error(unsigned int fsr, struct vm_area_struct *vma)
168} 168}
169 169
170static int __do_pf(struct mm_struct *mm, unsigned long addr, unsigned int fsr, 170static int __do_pf(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
171 struct task_struct *tsk) 171 unsigned int flags, struct task_struct *tsk)
172{ 172{
173 struct vm_area_struct *vma; 173 struct vm_area_struct *vma;
174 int fault; 174 int fault;
@@ -194,14 +194,7 @@ good_area:
194 * If for any reason at all we couldn't handle the fault, make 194 * If for any reason at all we couldn't handle the fault, make
195 * sure we exit gracefully rather than endlessly redo the fault. 195 * sure we exit gracefully rather than endlessly redo the fault.
196 */ 196 */
197 fault = handle_mm_fault(mm, vma, addr & PAGE_MASK, 197 fault = handle_mm_fault(mm, vma, addr & PAGE_MASK, flags);
198 (!(fsr ^ 0x12)) ? FAULT_FLAG_WRITE : 0);
199 if (unlikely(fault & VM_FAULT_ERROR))
200 return fault;
201 if (fault & VM_FAULT_MAJOR)
202 tsk->maj_flt++;
203 else
204 tsk->min_flt++;
205 return fault; 198 return fault;
206 199
207check_stack: 200check_stack:
@@ -216,6 +209,8 @@ static int do_pf(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
216 struct task_struct *tsk; 209 struct task_struct *tsk;
217 struct mm_struct *mm; 210 struct mm_struct *mm;
218 int fault, sig, code; 211 int fault, sig, code;
212 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
213 ((!(fsr ^ 0x12)) ? FAULT_FLAG_WRITE : 0);
219 214
220 tsk = current; 215 tsk = current;
221 mm = tsk->mm; 216 mm = tsk->mm;
@@ -236,6 +231,7 @@ static int do_pf(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
236 if (!user_mode(regs) 231 if (!user_mode(regs)
237 && !search_exception_tables(regs->UCreg_pc)) 232 && !search_exception_tables(regs->UCreg_pc))
238 goto no_context; 233 goto no_context;
234retry:
239 down_read(&mm->mmap_sem); 235 down_read(&mm->mmap_sem);
240 } else { 236 } else {
241 /* 237 /*
@@ -251,7 +247,28 @@ static int do_pf(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
251#endif 247#endif
252 } 248 }
253 249
254 fault = __do_pf(mm, addr, fsr, tsk); 250 fault = __do_pf(mm, addr, fsr, flags, tsk);
251
252 /* If we need to retry but a fatal signal is pending, handle the
253 * signal first. We do not need to release the mmap_sem because
254 * it would already be released in __lock_page_or_retry in
255 * mm/filemap.c. */
256 if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current))
257 return 0;
258
259 if (!(fault & VM_FAULT_ERROR) && (flags & FAULT_FLAG_ALLOW_RETRY)) {
260 if (fault & VM_FAULT_MAJOR)
261 tsk->maj_flt++;
262 else
263 tsk->min_flt++;
264 if (fault & VM_FAULT_RETRY) {
265 /* Clear FAULT_FLAG_ALLOW_RETRY to avoid any risk
266 * of starvation. */
267 flags &= ~FAULT_FLAG_ALLOW_RETRY;
268 goto retry;
269 }
270 }
271
255 up_read(&mm->mmap_sem); 272 up_read(&mm->mmap_sem);
256 273
257 /* 274 /*
diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
index c760e073963e..e87b0cac14b5 100644
--- a/arch/x86/boot/compressed/eboot.c
+++ b/arch/x86/boot/compressed/eboot.c
@@ -12,6 +12,8 @@
12#include <asm/setup.h> 12#include <asm/setup.h>
13#include <asm/desc.h> 13#include <asm/desc.h>
14 14
15#undef memcpy /* Use memcpy from misc.c */
16
15#include "eboot.h" 17#include "eboot.h"
16 18
17static efi_system_table_t *sys_table; 19static efi_system_table_t *sys_table;
diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
index 2a017441b8b2..8c132a625b94 100644
--- a/arch/x86/boot/header.S
+++ b/arch/x86/boot/header.S
@@ -476,6 +476,3 @@ die:
476setup_corrupt: 476setup_corrupt:
477 .byte 7 477 .byte 7
478 .string "No setup signature found...\n" 478 .string "No setup signature found...\n"
479
480 .data
481dummy: .long 0
diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
index dcfde52979c3..19f16ebaf4fa 100644
--- a/arch/x86/include/asm/ptrace.h
+++ b/arch/x86/include/asm/ptrace.h
@@ -205,21 +205,14 @@ static inline bool user_64bit_mode(struct pt_regs *regs)
205} 205}
206#endif 206#endif
207 207
208/*
209 * X86_32 CPUs don't save ss and esp if the CPU is already in kernel mode
210 * when it traps. The previous stack will be directly underneath the saved
211 * registers, and 'sp/ss' won't even have been saved. Thus the '&regs->sp'.
212 *
213 * This is valid only for kernel mode traps.
214 */
215static inline unsigned long kernel_stack_pointer(struct pt_regs *regs)
216{
217#ifdef CONFIG_X86_32 208#ifdef CONFIG_X86_32
218 return (unsigned long)(&regs->sp); 209extern unsigned long kernel_stack_pointer(struct pt_regs *regs);
219#else 210#else
211static inline unsigned long kernel_stack_pointer(struct pt_regs *regs)
212{
220 return regs->sp; 213 return regs->sp;
221#endif
222} 214}
215#endif
223 216
224#define GET_IP(regs) ((regs)->ip) 217#define GET_IP(regs) ((regs)->ip)
225#define GET_FP(regs) ((regs)->bp) 218#define GET_FP(regs) ((regs)->bp)
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index f7e98a2c0d12..1b7d1656a042 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -631,6 +631,20 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
631 } 631 }
632 } 632 }
633 633
634 /*
635 * The way access filter has a performance penalty on some workloads.
636 * Disable it on the affected CPUs.
637 */
638 if ((c->x86 == 0x15) &&
639 (c->x86_model >= 0x02) && (c->x86_model < 0x20)) {
640 u64 val;
641
642 if (!rdmsrl_safe(0xc0011021, &val) && !(val & 0x1E)) {
643 val |= 0x1E;
644 wrmsrl_safe(0xc0011021, val);
645 }
646 }
647
634 cpu_detect_cache_sizes(c); 648 cpu_detect_cache_sizes(c);
635 649
636 /* Multi core CPU? */ 650 /* Multi core CPU? */
diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c
index 698b6ec12e0f..1ac581f38dfa 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_amd.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c
@@ -6,7 +6,7 @@
6 * 6 *
7 * Written by Jacob Shin - AMD, Inc. 7 * Written by Jacob Shin - AMD, Inc.
8 * 8 *
9 * Support: borislav.petkov@amd.com 9 * Maintained by: Borislav Petkov <bp@alien8.de>
10 * 10 *
11 * April 2006 11 * April 2006
12 * - added support for AMD Family 0x10 processors 12 * - added support for AMD Family 0x10 processors
diff --git a/arch/x86/kernel/cpu/mcheck/mce_intel.c b/arch/x86/kernel/cpu/mcheck/mce_intel.c
index 5f88abf07e9c..4f9a3cbfc4a3 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_intel.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_intel.c
@@ -285,34 +285,39 @@ void cmci_clear(void)
285 raw_spin_unlock_irqrestore(&cmci_discover_lock, flags); 285 raw_spin_unlock_irqrestore(&cmci_discover_lock, flags);
286} 286}
287 287
288static long cmci_rediscover_work_func(void *arg)
289{
290 int banks;
291
292 /* Recheck banks in case CPUs don't all have the same */
293 if (cmci_supported(&banks))
294 cmci_discover(banks);
295
296 return 0;
297}
298
288/* 299/*
289 * After a CPU went down cycle through all the others and rediscover 300 * After a CPU went down cycle through all the others and rediscover
290 * Must run in process context. 301 * Must run in process context.
291 */ 302 */
292void cmci_rediscover(int dying) 303void cmci_rediscover(int dying)
293{ 304{
294 int banks; 305 int cpu, banks;
295 int cpu;
296 cpumask_var_t old;
297 306
298 if (!cmci_supported(&banks)) 307 if (!cmci_supported(&banks))
299 return; 308 return;
300 if (!alloc_cpumask_var(&old, GFP_KERNEL))
301 return;
302 cpumask_copy(old, &current->cpus_allowed);
303 309
304 for_each_online_cpu(cpu) { 310 for_each_online_cpu(cpu) {
305 if (cpu == dying) 311 if (cpu == dying)
306 continue; 312 continue;
307 if (set_cpus_allowed_ptr(current, cpumask_of(cpu))) 313
314 if (cpu == smp_processor_id()) {
315 cmci_rediscover_work_func(NULL);
308 continue; 316 continue;
309 /* Recheck banks in case CPUs don't all have the same */ 317 }
310 if (cmci_supported(&banks))
311 cmci_discover(banks);
312 }
313 318
314 set_cpus_allowed_ptr(current, old); 319 work_on_cpu(cpu, cmci_rediscover_work_func, NULL);
315 free_cpumask_var(old); 320 }
316} 321}
317 322
318/* 323/*
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index b51b2c7ee51f..1328fe49a3f1 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -995,8 +995,8 @@ END(interrupt)
995 */ 995 */
996 .p2align CONFIG_X86_L1_CACHE_SHIFT 996 .p2align CONFIG_X86_L1_CACHE_SHIFT
997common_interrupt: 997common_interrupt:
998 ASM_CLAC
999 XCPT_FRAME 998 XCPT_FRAME
999 ASM_CLAC
1000 addq $-0x80,(%rsp) /* Adjust vector to [-256,-1] range */ 1000 addq $-0x80,(%rsp) /* Adjust vector to [-256,-1] range */
1001 interrupt do_IRQ 1001 interrupt do_IRQ
1002 /* 0(%rsp): old_rsp-ARGOFFSET */ 1002 /* 0(%rsp): old_rsp-ARGOFFSET */
@@ -1135,8 +1135,8 @@ END(common_interrupt)
1135 */ 1135 */
1136.macro apicinterrupt num sym do_sym 1136.macro apicinterrupt num sym do_sym
1137ENTRY(\sym) 1137ENTRY(\sym)
1138 ASM_CLAC
1139 INTR_FRAME 1138 INTR_FRAME
1139 ASM_CLAC
1140 pushq_cfi $~(\num) 1140 pushq_cfi $~(\num)
1141.Lcommon_\sym: 1141.Lcommon_\sym:
1142 interrupt \do_sym 1142 interrupt \do_sym
@@ -1190,8 +1190,8 @@ apicinterrupt IRQ_WORK_VECTOR \
1190 */ 1190 */
1191.macro zeroentry sym do_sym 1191.macro zeroentry sym do_sym
1192ENTRY(\sym) 1192ENTRY(\sym)
1193 ASM_CLAC
1194 INTR_FRAME 1193 INTR_FRAME
1194 ASM_CLAC
1195 PARAVIRT_ADJUST_EXCEPTION_FRAME 1195 PARAVIRT_ADJUST_EXCEPTION_FRAME
1196 pushq_cfi $-1 /* ORIG_RAX: no syscall to restart */ 1196 pushq_cfi $-1 /* ORIG_RAX: no syscall to restart */
1197 subq $ORIG_RAX-R15, %rsp 1197 subq $ORIG_RAX-R15, %rsp
@@ -1208,8 +1208,8 @@ END(\sym)
1208 1208
1209.macro paranoidzeroentry sym do_sym 1209.macro paranoidzeroentry sym do_sym
1210ENTRY(\sym) 1210ENTRY(\sym)
1211 ASM_CLAC
1212 INTR_FRAME 1211 INTR_FRAME
1212 ASM_CLAC
1213 PARAVIRT_ADJUST_EXCEPTION_FRAME 1213 PARAVIRT_ADJUST_EXCEPTION_FRAME
1214 pushq_cfi $-1 /* ORIG_RAX: no syscall to restart */ 1214 pushq_cfi $-1 /* ORIG_RAX: no syscall to restart */
1215 subq $ORIG_RAX-R15, %rsp 1215 subq $ORIG_RAX-R15, %rsp
@@ -1227,8 +1227,8 @@ END(\sym)
1227#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8) 1227#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
1228.macro paranoidzeroentry_ist sym do_sym ist 1228.macro paranoidzeroentry_ist sym do_sym ist
1229ENTRY(\sym) 1229ENTRY(\sym)
1230 ASM_CLAC
1231 INTR_FRAME 1230 INTR_FRAME
1231 ASM_CLAC
1232 PARAVIRT_ADJUST_EXCEPTION_FRAME 1232 PARAVIRT_ADJUST_EXCEPTION_FRAME
1233 pushq_cfi $-1 /* ORIG_RAX: no syscall to restart */ 1233 pushq_cfi $-1 /* ORIG_RAX: no syscall to restart */
1234 subq $ORIG_RAX-R15, %rsp 1234 subq $ORIG_RAX-R15, %rsp
@@ -1247,8 +1247,8 @@ END(\sym)
1247 1247
1248.macro errorentry sym do_sym 1248.macro errorentry sym do_sym
1249ENTRY(\sym) 1249ENTRY(\sym)
1250 ASM_CLAC
1251 XCPT_FRAME 1250 XCPT_FRAME
1251 ASM_CLAC
1252 PARAVIRT_ADJUST_EXCEPTION_FRAME 1252 PARAVIRT_ADJUST_EXCEPTION_FRAME
1253 subq $ORIG_RAX-R15, %rsp 1253 subq $ORIG_RAX-R15, %rsp
1254 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15 1254 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
@@ -1266,8 +1266,8 @@ END(\sym)
1266 /* error code is on the stack already */ 1266 /* error code is on the stack already */
1267.macro paranoiderrorentry sym do_sym 1267.macro paranoiderrorentry sym do_sym
1268ENTRY(\sym) 1268ENTRY(\sym)
1269 ASM_CLAC
1270 XCPT_FRAME 1269 XCPT_FRAME
1270 ASM_CLAC
1271 PARAVIRT_ADJUST_EXCEPTION_FRAME 1271 PARAVIRT_ADJUST_EXCEPTION_FRAME
1272 subq $ORIG_RAX-R15, %rsp 1272 subq $ORIG_RAX-R15, %rsp
1273 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15 1273 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
diff --git a/arch/x86/kernel/microcode_amd.c b/arch/x86/kernel/microcode_amd.c
index 7720ff5a9ee2..efdec7cd8e01 100644
--- a/arch/x86/kernel/microcode_amd.c
+++ b/arch/x86/kernel/microcode_amd.c
@@ -8,8 +8,8 @@
8 * Tigran Aivazian <tigran@aivazian.fsnet.co.uk> 8 * Tigran Aivazian <tigran@aivazian.fsnet.co.uk>
9 * 9 *
10 * Maintainers: 10 * Maintainers:
11 * Andreas Herrmann <andreas.herrmann3@amd.com> 11 * Andreas Herrmann <herrmann.der.user@googlemail.com>
12 * Borislav Petkov <borislav.petkov@amd.com> 12 * Borislav Petkov <bp@alien8.de>
13 * 13 *
14 * This driver allows to upgrade microcode on F10h AMD 14 * This driver allows to upgrade microcode on F10h AMD
15 * CPUs and later. 15 * CPUs and later.
@@ -190,6 +190,7 @@ static unsigned int verify_patch_size(int cpu, u32 patch_size,
190#define F1XH_MPB_MAX_SIZE 2048 190#define F1XH_MPB_MAX_SIZE 2048
191#define F14H_MPB_MAX_SIZE 1824 191#define F14H_MPB_MAX_SIZE 1824
192#define F15H_MPB_MAX_SIZE 4096 192#define F15H_MPB_MAX_SIZE 4096
193#define F16H_MPB_MAX_SIZE 3458
193 194
194 switch (c->x86) { 195 switch (c->x86) {
195 case 0x14: 196 case 0x14:
@@ -198,6 +199,9 @@ static unsigned int verify_patch_size(int cpu, u32 patch_size,
198 case 0x15: 199 case 0x15:
199 max_size = F15H_MPB_MAX_SIZE; 200 max_size = F15H_MPB_MAX_SIZE;
200 break; 201 break;
202 case 0x16:
203 max_size = F16H_MPB_MAX_SIZE;
204 break;
201 default: 205 default:
202 max_size = F1XH_MPB_MAX_SIZE; 206 max_size = F1XH_MPB_MAX_SIZE;
203 break; 207 break;
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index b00b33a18390..5e0596b0632e 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -22,6 +22,7 @@
22#include <linux/perf_event.h> 22#include <linux/perf_event.h>
23#include <linux/hw_breakpoint.h> 23#include <linux/hw_breakpoint.h>
24#include <linux/rcupdate.h> 24#include <linux/rcupdate.h>
25#include <linux/module.h>
25 26
26#include <asm/uaccess.h> 27#include <asm/uaccess.h>
27#include <asm/pgtable.h> 28#include <asm/pgtable.h>
@@ -166,6 +167,35 @@ static inline bool invalid_selector(u16 value)
166 167
167#define FLAG_MASK FLAG_MASK_32 168#define FLAG_MASK FLAG_MASK_32
168 169
170/*
171 * X86_32 CPUs don't save ss and esp if the CPU is already in kernel mode
172 * when it traps. The previous stack will be directly underneath the saved
173 * registers, and 'sp/ss' won't even have been saved. Thus the '&regs->sp'.
174 *
175 * Now, if the stack is empty, '&regs->sp' is out of range. In this
176 * case we try to take the previous stack. To always return a non-null
177 * stack pointer we fall back to regs as stack if no previous stack
178 * exists.
179 *
180 * This is valid only for kernel mode traps.
181 */
182unsigned long kernel_stack_pointer(struct pt_regs *regs)
183{
184 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
185 unsigned long sp = (unsigned long)&regs->sp;
186 struct thread_info *tinfo;
187
188 if (context == (sp & ~(THREAD_SIZE - 1)))
189 return sp;
190
191 tinfo = (struct thread_info *)context;
192 if (tinfo->previous_esp)
193 return tinfo->previous_esp;
194
195 return (unsigned long)regs;
196}
197EXPORT_SYMBOL_GPL(kernel_stack_pointer);
198
169static unsigned long *pt_regs_access(struct pt_regs *regs, unsigned long regno) 199static unsigned long *pt_regs_access(struct pt_regs *regs, unsigned long regno)
170{ 200{
171 BUILD_BUG_ON(offsetof(struct pt_regs, bx) != 0); 201 BUILD_BUG_ON(offsetof(struct pt_regs, bx) != 0);
diff --git a/arch/x86/kvm/cpuid.h b/arch/x86/kvm/cpuid.h
index a10e46016851..58fc51488828 100644
--- a/arch/x86/kvm/cpuid.h
+++ b/arch/x86/kvm/cpuid.h
@@ -24,6 +24,9 @@ static inline bool guest_cpuid_has_xsave(struct kvm_vcpu *vcpu)
24{ 24{
25 struct kvm_cpuid_entry2 *best; 25 struct kvm_cpuid_entry2 *best;
26 26
27 if (!static_cpu_has(X86_FEATURE_XSAVE))
28 return 0;
29
27 best = kvm_find_cpuid_entry(vcpu, 1, 0); 30 best = kvm_find_cpuid_entry(vcpu, 1, 0);
28 return best && (best->ecx & bit(X86_FEATURE_XSAVE)); 31 return best && (best->ecx & bit(X86_FEATURE_XSAVE));
29} 32}
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index ad6b1dd06f8b..f85815945fc6 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -6549,19 +6549,22 @@ static void vmx_cpuid_update(struct kvm_vcpu *vcpu)
6549 } 6549 }
6550 } 6550 }
6551 6551
6552 exec_control = vmcs_read32(SECONDARY_VM_EXEC_CONTROL);
6553 /* Exposing INVPCID only when PCID is exposed */ 6552 /* Exposing INVPCID only when PCID is exposed */
6554 best = kvm_find_cpuid_entry(vcpu, 0x7, 0); 6553 best = kvm_find_cpuid_entry(vcpu, 0x7, 0);
6555 if (vmx_invpcid_supported() && 6554 if (vmx_invpcid_supported() &&
6556 best && (best->ebx & bit(X86_FEATURE_INVPCID)) && 6555 best && (best->ebx & bit(X86_FEATURE_INVPCID)) &&
6557 guest_cpuid_has_pcid(vcpu)) { 6556 guest_cpuid_has_pcid(vcpu)) {
6557 exec_control = vmcs_read32(SECONDARY_VM_EXEC_CONTROL);
6558 exec_control |= SECONDARY_EXEC_ENABLE_INVPCID; 6558 exec_control |= SECONDARY_EXEC_ENABLE_INVPCID;
6559 vmcs_write32(SECONDARY_VM_EXEC_CONTROL, 6559 vmcs_write32(SECONDARY_VM_EXEC_CONTROL,
6560 exec_control); 6560 exec_control);
6561 } else { 6561 } else {
6562 exec_control &= ~SECONDARY_EXEC_ENABLE_INVPCID; 6562 if (cpu_has_secondary_exec_ctrls()) {
6563 vmcs_write32(SECONDARY_VM_EXEC_CONTROL, 6563 exec_control = vmcs_read32(SECONDARY_VM_EXEC_CONTROL);
6564 exec_control); 6564 exec_control &= ~SECONDARY_EXEC_ENABLE_INVPCID;
6565 vmcs_write32(SECONDARY_VM_EXEC_CONTROL,
6566 exec_control);
6567 }
6565 if (best) 6568 if (best)
6566 best->ebx &= ~bit(X86_FEATURE_INVPCID); 6569 best->ebx &= ~bit(X86_FEATURE_INVPCID);
6567 } 6570 }
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 224a7e78cb6c..4f7641756be2 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -5781,6 +5781,9 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
5781 int pending_vec, max_bits, idx; 5781 int pending_vec, max_bits, idx;
5782 struct desc_ptr dt; 5782 struct desc_ptr dt;
5783 5783
5784 if (!guest_cpuid_has_xsave(vcpu) && (sregs->cr4 & X86_CR4_OSXSAVE))
5785 return -EINVAL;
5786
5784 dt.size = sregs->idt.limit; 5787 dt.size = sregs->idt.limit;
5785 dt.address = sregs->idt.base; 5788 dt.address = sregs->idt.base;
5786 kvm_x86_ops->set_idt(vcpu, &dt); 5789 kvm_x86_ops->set_idt(vcpu, &dt);
diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
index 0777f042e400..60f926cd8b0e 100644
--- a/arch/x86/mm/tlb.c
+++ b/arch/x86/mm/tlb.c
@@ -197,7 +197,7 @@ void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start,
197 } 197 }
198 198
199 if (end == TLB_FLUSH_ALL || tlb_flushall_shift == -1 199 if (end == TLB_FLUSH_ALL || tlb_flushall_shift == -1
200 || vmflag == VM_HUGETLB) { 200 || vmflag & VM_HUGETLB) {
201 local_flush_tlb(); 201 local_flush_tlb();
202 goto flush_all; 202 goto flush_all;
203 } 203 }
diff --git a/arch/x86/pci/ce4100.c b/arch/x86/pci/ce4100.c
index 41bd2a2d2c50..b914e20b5a00 100644
--- a/arch/x86/pci/ce4100.c
+++ b/arch/x86/pci/ce4100.c
@@ -115,6 +115,16 @@ static void sata_revid_read(struct sim_dev_reg *reg, u32 *value)
115 reg_read(reg, value); 115 reg_read(reg, value);
116} 116}
117 117
118static void reg_noirq_read(struct sim_dev_reg *reg, u32 *value)
119{
120 unsigned long flags;
121
122 raw_spin_lock_irqsave(&pci_config_lock, flags);
123 /* force interrupt pin value to 0 */
124 *value = reg->sim_reg.value & 0xfff00ff;
125 raw_spin_unlock_irqrestore(&pci_config_lock, flags);
126}
127
118static struct sim_dev_reg bus1_fixups[] = { 128static struct sim_dev_reg bus1_fixups[] = {
119 DEFINE_REG(2, 0, 0x10, (16*MB), reg_init, reg_read, reg_write) 129 DEFINE_REG(2, 0, 0x10, (16*MB), reg_init, reg_read, reg_write)
120 DEFINE_REG(2, 0, 0x14, (256), reg_init, reg_read, reg_write) 130 DEFINE_REG(2, 0, 0x14, (256), reg_init, reg_read, reg_write)
@@ -144,6 +154,7 @@ static struct sim_dev_reg bus1_fixups[] = {
144 DEFINE_REG(11, 5, 0x10, (64*KB), reg_init, reg_read, reg_write) 154 DEFINE_REG(11, 5, 0x10, (64*KB), reg_init, reg_read, reg_write)
145 DEFINE_REG(11, 6, 0x10, (256), reg_init, reg_read, reg_write) 155 DEFINE_REG(11, 6, 0x10, (256), reg_init, reg_read, reg_write)
146 DEFINE_REG(11, 7, 0x10, (64*KB), reg_init, reg_read, reg_write) 156 DEFINE_REG(11, 7, 0x10, (64*KB), reg_init, reg_read, reg_write)
157 DEFINE_REG(11, 7, 0x3c, 256, reg_init, reg_noirq_read, reg_write)
147 DEFINE_REG(12, 0, 0x10, (128*KB), reg_init, reg_read, reg_write) 158 DEFINE_REG(12, 0, 0x10, (128*KB), reg_init, reg_read, reg_write)
148 DEFINE_REG(12, 0, 0x14, (256), reg_init, reg_read, reg_write) 159 DEFINE_REG(12, 0, 0x14, (256), reg_init, reg_read, reg_write)
149 DEFINE_REG(12, 1, 0x10, (1024), reg_init, reg_read, reg_write) 160 DEFINE_REG(12, 1, 0x10, (1024), reg_init, reg_read, reg_write)
@@ -161,8 +172,10 @@ static struct sim_dev_reg bus1_fixups[] = {
161 DEFINE_REG(16, 0, 0x10, (64*KB), reg_init, reg_read, reg_write) 172 DEFINE_REG(16, 0, 0x10, (64*KB), reg_init, reg_read, reg_write)
162 DEFINE_REG(16, 0, 0x14, (64*MB), reg_init, reg_read, reg_write) 173 DEFINE_REG(16, 0, 0x14, (64*MB), reg_init, reg_read, reg_write)
163 DEFINE_REG(16, 0, 0x18, (64*MB), reg_init, reg_read, reg_write) 174 DEFINE_REG(16, 0, 0x18, (64*MB), reg_init, reg_read, reg_write)
175 DEFINE_REG(16, 0, 0x3c, 256, reg_init, reg_noirq_read, reg_write)
164 DEFINE_REG(17, 0, 0x10, (128*KB), reg_init, reg_read, reg_write) 176 DEFINE_REG(17, 0, 0x10, (128*KB), reg_init, reg_read, reg_write)
165 DEFINE_REG(18, 0, 0x10, (1*KB), reg_init, reg_read, reg_write) 177 DEFINE_REG(18, 0, 0x10, (1*KB), reg_init, reg_read, reg_write)
178 DEFINE_REG(18, 0, 0x3c, 256, reg_init, reg_noirq_read, reg_write)
166}; 179};
167 180
168static void __init init_sim_regs(void) 181static void __init init_sim_regs(void)
diff --git a/arch/x86/platform/ce4100/ce4100.c b/arch/x86/platform/ce4100/ce4100.c
index 4c61b52191eb..92525cb8e54c 100644
--- a/arch/x86/platform/ce4100/ce4100.c
+++ b/arch/x86/platform/ce4100/ce4100.c
@@ -21,12 +21,25 @@
21#include <asm/i8259.h> 21#include <asm/i8259.h>
22#include <asm/io.h> 22#include <asm/io.h>
23#include <asm/io_apic.h> 23#include <asm/io_apic.h>
24#include <asm/emergency-restart.h>
24 25
25static int ce4100_i8042_detect(void) 26static int ce4100_i8042_detect(void)
26{ 27{
27 return 0; 28 return 0;
28} 29}
29 30
31/*
32 * The CE4100 platform has an internal 8051 Microcontroller which is
33 * responsible for signaling to the external Power Management Unit the
34 * intention to reset, reboot or power off the system. This 8051 device has
35 * its command register mapped at I/O port 0xcf9 and the value 0x4 is used
36 * to power off the system.
37 */
38static void ce4100_power_off(void)
39{
40 outb(0x4, 0xcf9);
41}
42
30#ifdef CONFIG_SERIAL_8250 43#ifdef CONFIG_SERIAL_8250
31 44
32static unsigned int mem_serial_in(struct uart_port *p, int offset) 45static unsigned int mem_serial_in(struct uart_port *p, int offset)
@@ -139,8 +152,19 @@ void __init x86_ce4100_early_setup(void)
139 x86_init.mpparse.find_smp_config = x86_init_noop; 152 x86_init.mpparse.find_smp_config = x86_init_noop;
140 x86_init.pci.init = ce4100_pci_init; 153 x86_init.pci.init = ce4100_pci_init;
141 154
155 /*
156 * By default, the reboot method is ACPI which is supported by the
157 * CE4100 bootloader CEFDK using FADT.ResetReg Address and ResetValue
158 * the bootloader will however issue a system power off instead of
159 * reboot. By using BOOT_KBD we ensure proper system reboot as
160 * expected.
161 */
162 reboot_type = BOOT_KBD;
163
142#ifdef CONFIG_X86_IO_APIC 164#ifdef CONFIG_X86_IO_APIC
143 x86_init.pci.init_irq = sdv_pci_init; 165 x86_init.pci.init_irq = sdv_pci_init;
144 x86_init.mpparse.setup_ioapic_ids = setup_ioapic_ids_from_mpc_nocheck; 166 x86_init.mpparse.setup_ioapic_ids = setup_ioapic_ids_from_mpc_nocheck;
145#endif 167#endif
168
169 pm_power_off = ce4100_power_off;
146} 170}
diff --git a/block/blk-exec.c b/block/blk-exec.c
index 8b6dc5bd4dd0..f71eac35c1b9 100644
--- a/block/blk-exec.c
+++ b/block/blk-exec.c
@@ -52,11 +52,17 @@ void blk_execute_rq_nowait(struct request_queue *q, struct gendisk *bd_disk,
52 rq_end_io_fn *done) 52 rq_end_io_fn *done)
53{ 53{
54 int where = at_head ? ELEVATOR_INSERT_FRONT : ELEVATOR_INSERT_BACK; 54 int where = at_head ? ELEVATOR_INSERT_FRONT : ELEVATOR_INSERT_BACK;
55 bool is_pm_resume;
55 56
56 WARN_ON(irqs_disabled()); 57 WARN_ON(irqs_disabled());
57 58
58 rq->rq_disk = bd_disk; 59 rq->rq_disk = bd_disk;
59 rq->end_io = done; 60 rq->end_io = done;
61 /*
62 * need to check this before __blk_run_queue(), because rq can
63 * be freed before that returns.
64 */
65 is_pm_resume = rq->cmd_type == REQ_TYPE_PM_RESUME;
60 66
61 spin_lock_irq(q->queue_lock); 67 spin_lock_irq(q->queue_lock);
62 68
@@ -71,7 +77,7 @@ void blk_execute_rq_nowait(struct request_queue *q, struct gendisk *bd_disk,
71 __elv_add_request(q, rq, where); 77 __elv_add_request(q, rq, where);
72 __blk_run_queue(q); 78 __blk_run_queue(q);
73 /* the queue is stopped so it won't be run */ 79 /* the queue is stopped so it won't be run */
74 if (rq->cmd_type == REQ_TYPE_PM_RESUME) 80 if (is_pm_resume)
75 q->request_fn(q); 81 q->request_fn(q);
76 spin_unlock_irq(q->queue_lock); 82 spin_unlock_irq(q->queue_lock);
77} 83}
diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c
index b1ae48054dc5..b7078afddb74 100644
--- a/drivers/ata/ahci_platform.c
+++ b/drivers/ata/ahci_platform.c
@@ -238,7 +238,7 @@ static int __devexit ahci_remove(struct platform_device *pdev)
238 return 0; 238 return 0;
239} 239}
240 240
241#ifdef CONFIG_PM 241#ifdef CONFIG_PM_SLEEP
242static int ahci_suspend(struct device *dev) 242static int ahci_suspend(struct device *dev)
243{ 243{
244 struct ahci_platform_data *pdata = dev_get_platdata(dev); 244 struct ahci_platform_data *pdata = dev_get_platdata(dev);
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index fd9ecf74e631..5b0ba3f20edc 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -1105,10 +1105,15 @@ static int ata_acpi_bind_device(struct ata_port *ap, struct scsi_device *sdev,
1105 struct acpi_device *acpi_dev; 1105 struct acpi_device *acpi_dev;
1106 struct acpi_device_power_state *states; 1106 struct acpi_device_power_state *states;
1107 1107
1108 if (ap->flags & ATA_FLAG_ACPI_SATA) 1108 if (ap->flags & ATA_FLAG_ACPI_SATA) {
1109 ata_dev = &ap->link.device[sdev->channel]; 1109 if (!sata_pmp_attached(ap))
1110 else 1110 ata_dev = &ap->link.device[sdev->id];
1111 else
1112 ata_dev = &ap->pmp_link[sdev->channel].device[sdev->id];
1113 }
1114 else {
1111 ata_dev = &ap->link.device[sdev->id]; 1115 ata_dev = &ap->link.device[sdev->id];
1116 }
1112 1117
1113 *handle = ata_dev_acpi_handle(ata_dev); 1118 *handle = ata_dev_acpi_handle(ata_dev);
1114 1119
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 3cc7096cfda7..f46fbd3bd3fb 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -2942,6 +2942,10 @@ const struct ata_timing *ata_timing_find_mode(u8 xfer_mode)
2942 2942
2943 if (xfer_mode == t->mode) 2943 if (xfer_mode == t->mode)
2944 return t; 2944 return t;
2945
2946 WARN_ONCE(true, "%s: unable to find timing for xfer_mode 0x%x\n",
2947 __func__, xfer_mode);
2948
2945 return NULL; 2949 return NULL;
2946} 2950}
2947 2951
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index e3bda074fa12..a6df6a351d6e 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -1052,6 +1052,8 @@ static void ata_scsi_sdev_config(struct scsi_device *sdev)
1052{ 1052{
1053 sdev->use_10_for_rw = 1; 1053 sdev->use_10_for_rw = 1;
1054 sdev->use_10_for_ms = 1; 1054 sdev->use_10_for_ms = 1;
1055 sdev->no_report_opcodes = 1;
1056 sdev->no_write_same = 1;
1055 1057
1056 /* Schedule policy is determined by ->qc_defer() callback and 1058 /* Schedule policy is determined by ->qc_defer() callback and
1057 * it needs to see every deferred qc. Set dev_blocked to 1 to 1059 * it needs to see every deferred qc. Set dev_blocked to 1 to
diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
index 26201ebef3ca..371fd2c698b7 100644
--- a/drivers/ata/pata_arasan_cf.c
+++ b/drivers/ata/pata_arasan_cf.c
@@ -317,6 +317,12 @@ static int cf_init(struct arasan_cf_dev *acdev)
317 return ret; 317 return ret;
318 } 318 }
319 319
320 ret = clk_set_rate(acdev->clk, 166000000);
321 if (ret) {
322 dev_warn(acdev->host->dev, "clock set rate failed");
323 return ret;
324 }
325
320 spin_lock_irqsave(&acdev->host->lock, flags); 326 spin_lock_irqsave(&acdev->host->lock, flags);
321 /* configure CF interface clock */ 327 /* configure CF interface clock */
322 writel((pdata->cf_if_clk <= CF_IF_CLK_200M) ? pdata->cf_if_clk : 328 writel((pdata->cf_if_clk <= CF_IF_CLK_200M) ? pdata->cf_if_clk :
@@ -908,7 +914,7 @@ static int __devexit arasan_cf_remove(struct platform_device *pdev)
908 return 0; 914 return 0;
909} 915}
910 916
911#ifdef CONFIG_PM 917#ifdef CONFIG_PM_SLEEP
912static int arasan_cf_suspend(struct device *dev) 918static int arasan_cf_suspend(struct device *dev)
913{ 919{
914 struct ata_host *host = dev_get_drvdata(dev); 920 struct ata_host *host = dev_get_drvdata(dev);
diff --git a/drivers/ata/sata_highbank.c b/drivers/ata/sata_highbank.c
index 0d7c4c2cd26f..400bf1c3e982 100644
--- a/drivers/ata/sata_highbank.c
+++ b/drivers/ata/sata_highbank.c
@@ -260,7 +260,7 @@ static const struct of_device_id ahci_of_match[] = {
260}; 260};
261MODULE_DEVICE_TABLE(of, ahci_of_match); 261MODULE_DEVICE_TABLE(of, ahci_of_match);
262 262
263static int __init ahci_highbank_probe(struct platform_device *pdev) 263static int __devinit ahci_highbank_probe(struct platform_device *pdev)
264{ 264{
265 struct device *dev = &pdev->dev; 265 struct device *dev = &pdev->dev;
266 struct ahci_host_priv *hpriv; 266 struct ahci_host_priv *hpriv;
@@ -378,7 +378,7 @@ static int __devexit ahci_highbank_remove(struct platform_device *pdev)
378 return 0; 378 return 0;
379} 379}
380 380
381#ifdef CONFIG_PM 381#ifdef CONFIG_PM_SLEEP
382static int ahci_highbank_suspend(struct device *dev) 382static int ahci_highbank_suspend(struct device *dev)
383{ 383{
384 struct ata_host *host = dev_get_drvdata(dev); 384 struct ata_host *host = dev_get_drvdata(dev);
diff --git a/drivers/ata/sata_svw.c b/drivers/ata/sata_svw.c
index 44a4256533e1..08608de87e4e 100644
--- a/drivers/ata/sata_svw.c
+++ b/drivers/ata/sata_svw.c
@@ -142,6 +142,39 @@ static int k2_sata_scr_write(struct ata_link *link,
142 return 0; 142 return 0;
143} 143}
144 144
145static int k2_sata_softreset(struct ata_link *link,
146 unsigned int *class, unsigned long deadline)
147{
148 u8 dmactl;
149 void __iomem *mmio = link->ap->ioaddr.bmdma_addr;
150
151 dmactl = readb(mmio + ATA_DMA_CMD);
152
153 /* Clear the start bit */
154 if (dmactl & ATA_DMA_START) {
155 dmactl &= ~ATA_DMA_START;
156 writeb(dmactl, mmio + ATA_DMA_CMD);
157 }
158
159 return ata_sff_softreset(link, class, deadline);
160}
161
162static int k2_sata_hardreset(struct ata_link *link,
163 unsigned int *class, unsigned long deadline)
164{
165 u8 dmactl;
166 void __iomem *mmio = link->ap->ioaddr.bmdma_addr;
167
168 dmactl = readb(mmio + ATA_DMA_CMD);
169
170 /* Clear the start bit */
171 if (dmactl & ATA_DMA_START) {
172 dmactl &= ~ATA_DMA_START;
173 writeb(dmactl, mmio + ATA_DMA_CMD);
174 }
175
176 return sata_sff_hardreset(link, class, deadline);
177}
145 178
146static void k2_sata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf) 179static void k2_sata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
147{ 180{
@@ -346,6 +379,8 @@ static struct scsi_host_template k2_sata_sht = {
346 379
347static struct ata_port_operations k2_sata_ops = { 380static struct ata_port_operations k2_sata_ops = {
348 .inherits = &ata_bmdma_port_ops, 381 .inherits = &ata_bmdma_port_ops,
382 .softreset = k2_sata_softreset,
383 .hardreset = k2_sata_hardreset,
349 .sff_tf_load = k2_sata_tf_load, 384 .sff_tf_load = k2_sata_tf_load,
350 .sff_tf_read = k2_sata_tf_read, 385 .sff_tf_read = k2_sata_tf_read,
351 .sff_check_status = k2_stat_check_status, 386 .sff_check_status = k2_stat_check_status,
diff --git a/drivers/base/power/qos.c b/drivers/base/power/qos.c
index 74a67e0019a2..fbbd4ed2edf2 100644
--- a/drivers/base/power/qos.c
+++ b/drivers/base/power/qos.c
@@ -451,7 +451,7 @@ int dev_pm_qos_add_ancestor_request(struct device *dev,
451 if (ancestor) 451 if (ancestor)
452 error = dev_pm_qos_add_request(ancestor, req, value); 452 error = dev_pm_qos_add_request(ancestor, req, value);
453 453
454 if (error) 454 if (error < 0)
455 req->dev = NULL; 455 req->dev = NULL;
456 456
457 return error; 457 return error;
diff --git a/drivers/base/regmap/internal.h b/drivers/base/regmap/internal.h
index 80f9ab9c3aa4..ac869d28d5ba 100644
--- a/drivers/base/regmap/internal.h
+++ b/drivers/base/regmap/internal.h
@@ -120,6 +120,8 @@ int _regmap_write(struct regmap *map, unsigned int reg,
120 120
121struct regmap_range_node { 121struct regmap_range_node {
122 struct rb_node node; 122 struct rb_node node;
123 const char *name;
124 struct regmap *map;
123 125
124 unsigned int range_min; 126 unsigned int range_min;
125 unsigned int range_max; 127 unsigned int range_max;
diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
index bb1ff175b962..f4b9dd01c981 100644
--- a/drivers/base/regmap/regmap-debugfs.c
+++ b/drivers/base/regmap/regmap-debugfs.c
@@ -56,15 +56,15 @@ static const struct file_operations regmap_name_fops = {
56 .llseek = default_llseek, 56 .llseek = default_llseek,
57}; 57};
58 58
59static ssize_t regmap_map_read_file(struct file *file, char __user *user_buf, 59static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from,
60 size_t count, loff_t *ppos) 60 unsigned int to, char __user *user_buf,
61 size_t count, loff_t *ppos)
61{ 62{
62 int reg_len, val_len, tot_len; 63 int reg_len, val_len, tot_len;
63 size_t buf_pos = 0; 64 size_t buf_pos = 0;
64 loff_t p = 0; 65 loff_t p = 0;
65 ssize_t ret; 66 ssize_t ret;
66 int i; 67 int i;
67 struct regmap *map = file->private_data;
68 char *buf; 68 char *buf;
69 unsigned int val; 69 unsigned int val;
70 70
@@ -80,7 +80,7 @@ static ssize_t regmap_map_read_file(struct file *file, char __user *user_buf,
80 val_len = 2 * map->format.val_bytes; 80 val_len = 2 * map->format.val_bytes;
81 tot_len = reg_len + val_len + 3; /* : \n */ 81 tot_len = reg_len + val_len + 3; /* : \n */
82 82
83 for (i = 0; i <= map->max_register; i += map->reg_stride) { 83 for (i = from; i <= to; i += map->reg_stride) {
84 if (!regmap_readable(map, i)) 84 if (!regmap_readable(map, i))
85 continue; 85 continue;
86 86
@@ -95,7 +95,7 @@ static ssize_t regmap_map_read_file(struct file *file, char __user *user_buf,
95 95
96 /* Format the register */ 96 /* Format the register */
97 snprintf(buf + buf_pos, count - buf_pos, "%.*x: ", 97 snprintf(buf + buf_pos, count - buf_pos, "%.*x: ",
98 reg_len, i); 98 reg_len, i - from);
99 buf_pos += reg_len + 2; 99 buf_pos += reg_len + 2;
100 100
101 /* Format the value, write all X if we can't read */ 101 /* Format the value, write all X if we can't read */
@@ -126,6 +126,15 @@ out:
126 return ret; 126 return ret;
127} 127}
128 128
129static ssize_t regmap_map_read_file(struct file *file, char __user *user_buf,
130 size_t count, loff_t *ppos)
131{
132 struct regmap *map = file->private_data;
133
134 return regmap_read_debugfs(map, 0, map->max_register, user_buf,
135 count, ppos);
136}
137
129#undef REGMAP_ALLOW_WRITE_DEBUGFS 138#undef REGMAP_ALLOW_WRITE_DEBUGFS
130#ifdef REGMAP_ALLOW_WRITE_DEBUGFS 139#ifdef REGMAP_ALLOW_WRITE_DEBUGFS
131/* 140/*
@@ -174,6 +183,22 @@ static const struct file_operations regmap_map_fops = {
174 .llseek = default_llseek, 183 .llseek = default_llseek,
175}; 184};
176 185
186static ssize_t regmap_range_read_file(struct file *file, char __user *user_buf,
187 size_t count, loff_t *ppos)
188{
189 struct regmap_range_node *range = file->private_data;
190 struct regmap *map = range->map;
191
192 return regmap_read_debugfs(map, range->range_min, range->range_max,
193 user_buf, count, ppos);
194}
195
196static const struct file_operations regmap_range_fops = {
197 .open = simple_open,
198 .read = regmap_range_read_file,
199 .llseek = default_llseek,
200};
201
177static ssize_t regmap_access_read_file(struct file *file, 202static ssize_t regmap_access_read_file(struct file *file,
178 char __user *user_buf, size_t count, 203 char __user *user_buf, size_t count,
179 loff_t *ppos) 204 loff_t *ppos)
@@ -244,6 +269,9 @@ static const struct file_operations regmap_access_fops = {
244 269
245void regmap_debugfs_init(struct regmap *map, const char *name) 270void regmap_debugfs_init(struct regmap *map, const char *name)
246{ 271{
272 struct rb_node *next;
273 struct regmap_range_node *range_node;
274
247 if (name) { 275 if (name) {
248 map->debugfs_name = kasprintf(GFP_KERNEL, "%s-%s", 276 map->debugfs_name = kasprintf(GFP_KERNEL, "%s-%s",
249 dev_name(map->dev), name); 277 dev_name(map->dev), name);
@@ -276,6 +304,18 @@ void regmap_debugfs_init(struct regmap *map, const char *name)
276 debugfs_create_bool("cache_bypass", 0400, map->debugfs, 304 debugfs_create_bool("cache_bypass", 0400, map->debugfs,
277 &map->cache_bypass); 305 &map->cache_bypass);
278 } 306 }
307
308 next = rb_first(&map->range_tree);
309 while (next) {
310 range_node = rb_entry(next, struct regmap_range_node, node);
311
312 if (range_node->name)
313 debugfs_create_file(range_node->name, 0400,
314 map->debugfs, range_node,
315 &regmap_range_fops);
316
317 next = rb_next(&range_node->node);
318 }
279} 319}
280 320
281void regmap_debugfs_exit(struct regmap *map) 321void regmap_debugfs_exit(struct regmap *map)
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 52069d29ff12..96253cd949e9 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -519,20 +519,38 @@ struct regmap *regmap_init(struct device *dev,
519 } 519 }
520 520
521 map->range_tree = RB_ROOT; 521 map->range_tree = RB_ROOT;
522 for (i = 0; i < config->n_ranges; i++) { 522 for (i = 0; i < config->num_ranges; i++) {
523 const struct regmap_range_cfg *range_cfg = &config->ranges[i]; 523 const struct regmap_range_cfg *range_cfg = &config->ranges[i];
524 struct regmap_range_node *new; 524 struct regmap_range_node *new;
525 525
526 /* Sanity check */ 526 /* Sanity check */
527 if (range_cfg->range_max < range_cfg->range_min || 527 if (range_cfg->range_max < range_cfg->range_min) {
528 range_cfg->range_max > map->max_register || 528 dev_err(map->dev, "Invalid range %d: %d < %d\n", i,
529 range_cfg->selector_reg > map->max_register || 529 range_cfg->range_max, range_cfg->range_min);
530 range_cfg->window_len == 0)
531 goto err_range; 530 goto err_range;
531 }
532
533 if (range_cfg->range_max > map->max_register) {
534 dev_err(map->dev, "Invalid range %d: %d > %d\n", i,
535 range_cfg->range_max, map->max_register);
536 goto err_range;
537 }
538
539 if (range_cfg->selector_reg > map->max_register) {
540 dev_err(map->dev,
541 "Invalid range %d: selector out of map\n", i);
542 goto err_range;
543 }
544
545 if (range_cfg->window_len == 0) {
546 dev_err(map->dev, "Invalid range %d: window_len 0\n",
547 i);
548 goto err_range;
549 }
532 550
533 /* Make sure, that this register range has no selector 551 /* Make sure, that this register range has no selector
534 or data window within its boundary */ 552 or data window within its boundary */
535 for (j = 0; j < config->n_ranges; j++) { 553 for (j = 0; j < config->num_ranges; j++) {
536 unsigned sel_reg = config->ranges[j].selector_reg; 554 unsigned sel_reg = config->ranges[j].selector_reg;
537 unsigned win_min = config->ranges[j].window_start; 555 unsigned win_min = config->ranges[j].window_start;
538 unsigned win_max = win_min + 556 unsigned win_max = win_min +
@@ -540,11 +558,17 @@ struct regmap *regmap_init(struct device *dev,
540 558
541 if (range_cfg->range_min <= sel_reg && 559 if (range_cfg->range_min <= sel_reg &&
542 sel_reg <= range_cfg->range_max) { 560 sel_reg <= range_cfg->range_max) {
561 dev_err(map->dev,
562 "Range %d: selector for %d in window\n",
563 i, j);
543 goto err_range; 564 goto err_range;
544 } 565 }
545 566
546 if (!(win_max < range_cfg->range_min || 567 if (!(win_max < range_cfg->range_min ||
547 win_min > range_cfg->range_max)) { 568 win_min > range_cfg->range_max)) {
569 dev_err(map->dev,
570 "Range %d: window for %d in window\n",
571 i, j);
548 goto err_range; 572 goto err_range;
549 } 573 }
550 } 574 }
@@ -555,6 +579,8 @@ struct regmap *regmap_init(struct device *dev,
555 goto err_range; 579 goto err_range;
556 } 580 }
557 581
582 new->map = map;
583 new->name = range_cfg->name;
558 new->range_min = range_cfg->range_min; 584 new->range_min = range_cfg->range_min;
559 new->range_max = range_cfg->range_max; 585 new->range_max = range_cfg->range_max;
560 new->selector_reg = range_cfg->selector_reg; 586 new->selector_reg = range_cfg->selector_reg;
@@ -564,6 +590,7 @@ struct regmap *regmap_init(struct device *dev,
564 new->window_len = range_cfg->window_len; 590 new->window_len = range_cfg->window_len;
565 591
566 if (_regmap_range_add(map, new) == false) { 592 if (_regmap_range_add(map, new) == false) {
593 dev_err(map->dev, "Failed to add range %d\n", i);
567 kfree(new); 594 kfree(new);
568 goto err_range; 595 goto err_range;
569 } 596 }
@@ -579,7 +606,7 @@ struct regmap *regmap_init(struct device *dev,
579 } 606 }
580 607
581 ret = regcache_init(map, config); 608 ret = regcache_init(map, config);
582 if (ret < 0) 609 if (ret != 0)
583 goto err_range; 610 goto err_range;
584 611
585 regmap_debugfs_init(map, config->name); 612 regmap_debugfs_init(map, config->name);
@@ -738,59 +765,57 @@ struct regmap *dev_get_regmap(struct device *dev, const char *name)
738EXPORT_SYMBOL_GPL(dev_get_regmap); 765EXPORT_SYMBOL_GPL(dev_get_regmap);
739 766
740static int _regmap_select_page(struct regmap *map, unsigned int *reg, 767static int _regmap_select_page(struct regmap *map, unsigned int *reg,
768 struct regmap_range_node *range,
741 unsigned int val_num) 769 unsigned int val_num)
742{ 770{
743 struct regmap_range_node *range;
744 void *orig_work_buf; 771 void *orig_work_buf;
745 unsigned int win_offset; 772 unsigned int win_offset;
746 unsigned int win_page; 773 unsigned int win_page;
747 bool page_chg; 774 bool page_chg;
748 int ret; 775 int ret;
749 776
750 range = _regmap_range_lookup(map, *reg); 777 win_offset = (*reg - range->range_min) % range->window_len;
751 if (range) { 778 win_page = (*reg - range->range_min) / range->window_len;
752 win_offset = (*reg - range->range_min) % range->window_len;
753 win_page = (*reg - range->range_min) / range->window_len;
754
755 if (val_num > 1) {
756 /* Bulk write shouldn't cross range boundary */
757 if (*reg + val_num - 1 > range->range_max)
758 return -EINVAL;
759 779
760 /* ... or single page boundary */ 780 if (val_num > 1) {
761 if (val_num > range->window_len - win_offset) 781 /* Bulk write shouldn't cross range boundary */
762 return -EINVAL; 782 if (*reg + val_num - 1 > range->range_max)
763 } 783 return -EINVAL;
764 784
765 /* It is possible to have selector register inside data window. 785 /* ... or single page boundary */
766 In that case, selector register is located on every page and 786 if (val_num > range->window_len - win_offset)
767 it needs no page switching, when accessed alone. */ 787 return -EINVAL;
768 if (val_num > 1 || 788 }
769 range->window_start + win_offset != range->selector_reg) {
770 /* Use separate work_buf during page switching */
771 orig_work_buf = map->work_buf;
772 map->work_buf = map->selector_work_buf;
773 789
774 ret = _regmap_update_bits(map, range->selector_reg, 790 /* It is possible to have selector register inside data window.
775 range->selector_mask, 791 In that case, selector register is located on every page and
776 win_page << range->selector_shift, 792 it needs no page switching, when accessed alone. */
777 &page_chg); 793 if (val_num > 1 ||
794 range->window_start + win_offset != range->selector_reg) {
795 /* Use separate work_buf during page switching */
796 orig_work_buf = map->work_buf;
797 map->work_buf = map->selector_work_buf;
778 798
779 map->work_buf = orig_work_buf; 799 ret = _regmap_update_bits(map, range->selector_reg,
800 range->selector_mask,
801 win_page << range->selector_shift,
802 &page_chg);
780 803
781 if (ret < 0) 804 map->work_buf = orig_work_buf;
782 return ret;
783 }
784 805
785 *reg = range->window_start + win_offset; 806 if (ret != 0)
807 return ret;
786 } 808 }
787 809
810 *reg = range->window_start + win_offset;
811
788 return 0; 812 return 0;
789} 813}
790 814
791static int _regmap_raw_write(struct regmap *map, unsigned int reg, 815static int _regmap_raw_write(struct regmap *map, unsigned int reg,
792 const void *val, size_t val_len) 816 const void *val, size_t val_len)
793{ 817{
818 struct regmap_range_node *range;
794 u8 *u8 = map->work_buf; 819 u8 *u8 = map->work_buf;
795 void *buf; 820 void *buf;
796 int ret = -ENOTSUPP; 821 int ret = -ENOTSUPP;
@@ -825,9 +850,35 @@ static int _regmap_raw_write(struct regmap *map, unsigned int reg,
825 } 850 }
826 } 851 }
827 852
828 ret = _regmap_select_page(map, &reg, val_len / map->format.val_bytes); 853 range = _regmap_range_lookup(map, reg);
829 if (ret < 0) 854 if (range) {
830 return ret; 855 int val_num = val_len / map->format.val_bytes;
856 int win_offset = (reg - range->range_min) % range->window_len;
857 int win_residue = range->window_len - win_offset;
858
859 /* If the write goes beyond the end of the window split it */
860 while (val_num > win_residue) {
861 dev_dbg(map->dev, "Writing window %d/%d\n",
862 win_residue, val_len / map->format.val_bytes);
863 ret = _regmap_raw_write(map, reg, val, win_residue *
864 map->format.val_bytes);
865 if (ret != 0)
866 return ret;
867
868 reg += win_residue;
869 val_num -= win_residue;
870 val += win_residue * map->format.val_bytes;
871 val_len -= win_residue * map->format.val_bytes;
872
873 win_offset = (reg - range->range_min) %
874 range->window_len;
875 win_residue = range->window_len - win_offset;
876 }
877
878 ret = _regmap_select_page(map, &reg, range, val_num);
879 if (ret != 0)
880 return ret;
881 }
831 882
832 map->format.format_reg(map->work_buf, reg, map->reg_shift); 883 map->format.format_reg(map->work_buf, reg, map->reg_shift);
833 884
@@ -876,6 +927,7 @@ static int _regmap_raw_write(struct regmap *map, unsigned int reg,
876int _regmap_write(struct regmap *map, unsigned int reg, 927int _regmap_write(struct regmap *map, unsigned int reg,
877 unsigned int val) 928 unsigned int val)
878{ 929{
930 struct regmap_range_node *range;
879 int ret; 931 int ret;
880 BUG_ON(!map->format.format_write && !map->format.format_val); 932 BUG_ON(!map->format.format_write && !map->format.format_val);
881 933
@@ -897,9 +949,12 @@ int _regmap_write(struct regmap *map, unsigned int reg,
897 trace_regmap_reg_write(map->dev, reg, val); 949 trace_regmap_reg_write(map->dev, reg, val);
898 950
899 if (map->format.format_write) { 951 if (map->format.format_write) {
900 ret = _regmap_select_page(map, &reg, 1); 952 range = _regmap_range_lookup(map, reg);
901 if (ret < 0) 953 if (range) {
902 return ret; 954 ret = _regmap_select_page(map, &reg, range, 1);
955 if (ret != 0)
956 return ret;
957 }
903 958
904 map->format.format_write(map, reg, val); 959 map->format.format_write(map, reg, val);
905 960
@@ -1055,12 +1110,17 @@ EXPORT_SYMBOL_GPL(regmap_bulk_write);
1055static int _regmap_raw_read(struct regmap *map, unsigned int reg, void *val, 1110static int _regmap_raw_read(struct regmap *map, unsigned int reg, void *val,
1056 unsigned int val_len) 1111 unsigned int val_len)
1057{ 1112{
1113 struct regmap_range_node *range;
1058 u8 *u8 = map->work_buf; 1114 u8 *u8 = map->work_buf;
1059 int ret; 1115 int ret;
1060 1116
1061 ret = _regmap_select_page(map, &reg, val_len / map->format.val_bytes); 1117 range = _regmap_range_lookup(map, reg);
1062 if (ret < 0) 1118 if (range) {
1063 return ret; 1119 ret = _regmap_select_page(map, &reg, range,
1120 val_len / map->format.val_bytes);
1121 if (ret != 0)
1122 return ret;
1123 }
1064 1124
1065 map->format.format_reg(map->work_buf, reg, map->reg_shift); 1125 map->format.format_reg(map->work_buf, reg, map->reg_shift);
1066 1126
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index 3804a0af3ef1..9fe4f1865558 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -935,7 +935,7 @@ aoe_end_request(struct aoedev *d, struct request *rq, int fastfail)
935 935
936 /* cf. http://lkml.org/lkml/2006/10/31/28 */ 936 /* cf. http://lkml.org/lkml/2006/10/31/28 */
937 if (!fastfail) 937 if (!fastfail)
938 q->request_fn(q); 938 __blk_run_queue(q);
939} 939}
940 940
941static void 941static void
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 1c49d7173966..2ddd64a9ffde 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -4330,6 +4330,7 @@ out_unreg_region:
4330out_unreg_blkdev: 4330out_unreg_blkdev:
4331 unregister_blkdev(FLOPPY_MAJOR, "fd"); 4331 unregister_blkdev(FLOPPY_MAJOR, "fd");
4332out_put_disk: 4332out_put_disk:
4333 destroy_workqueue(floppy_wq);
4333 for (drive = 0; drive < N_DRIVE; drive++) { 4334 for (drive = 0; drive < N_DRIVE; drive++) {
4334 if (!disks[drive]) 4335 if (!disks[drive])
4335 break; 4336 break;
@@ -4340,7 +4341,6 @@ out_put_disk:
4340 } 4341 }
4341 put_disk(disks[drive]); 4342 put_disk(disks[drive]);
4342 } 4343 }
4343 destroy_workqueue(floppy_wq);
4344 return err; 4344 return err;
4345} 4345}
4346 4346
@@ -4555,6 +4555,8 @@ static void __exit floppy_module_exit(void)
4555 unregister_blkdev(FLOPPY_MAJOR, "fd"); 4555 unregister_blkdev(FLOPPY_MAJOR, "fd");
4556 platform_driver_unregister(&floppy_driver); 4556 platform_driver_unregister(&floppy_driver);
4557 4557
4558 destroy_workqueue(floppy_wq);
4559
4558 for (drive = 0; drive < N_DRIVE; drive++) { 4560 for (drive = 0; drive < N_DRIVE; drive++) {
4559 del_timer_sync(&motor_off_timer[drive]); 4561 del_timer_sync(&motor_off_timer[drive]);
4560 4562
@@ -4578,7 +4580,6 @@ static void __exit floppy_module_exit(void)
4578 4580
4579 cancel_delayed_work_sync(&fd_timeout); 4581 cancel_delayed_work_sync(&fd_timeout);
4580 cancel_delayed_work_sync(&fd_timer); 4582 cancel_delayed_work_sync(&fd_timer);
4581 destroy_workqueue(floppy_wq);
4582 4583
4583 if (atomic_read(&usage_count)) 4584 if (atomic_read(&usage_count))
4584 floppy_release_irq_and_dma(); 4585 floppy_release_irq_and_dma();
diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index adc6f36564cf..9694dd99bbbc 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -559,7 +559,7 @@ static void mtip_timeout_function(unsigned long int data)
559 struct mtip_cmd *command; 559 struct mtip_cmd *command;
560 int tag, cmdto_cnt = 0; 560 int tag, cmdto_cnt = 0;
561 unsigned int bit, group; 561 unsigned int bit, group;
562 unsigned int num_command_slots = port->dd->slot_groups * 32; 562 unsigned int num_command_slots;
563 unsigned long to, tagaccum[SLOTBITS_IN_LONGS]; 563 unsigned long to, tagaccum[SLOTBITS_IN_LONGS];
564 564
565 if (unlikely(!port)) 565 if (unlikely(!port))
@@ -572,6 +572,7 @@ static void mtip_timeout_function(unsigned long int data)
572 } 572 }
573 /* clear the tag accumulator */ 573 /* clear the tag accumulator */
574 memset(tagaccum, 0, SLOTBITS_IN_LONGS * sizeof(long)); 574 memset(tagaccum, 0, SLOTBITS_IN_LONGS * sizeof(long));
575 num_command_slots = port->dd->slot_groups * 32;
575 576
576 for (tag = 0; tag < num_command_slots; tag++) { 577 for (tag = 0; tag < num_command_slots; tag++) {
577 /* 578 /*
@@ -2218,8 +2219,8 @@ static int exec_drive_taskfile(struct driver_data *dd,
2218 fis.device); 2219 fis.device);
2219 2220
2220 /* check for erase mode support during secure erase.*/ 2221 /* check for erase mode support during secure erase.*/
2221 if ((fis.command == ATA_CMD_SEC_ERASE_UNIT) 2222 if ((fis.command == ATA_CMD_SEC_ERASE_UNIT) && outbuf &&
2222 && (outbuf[0] & MTIP_SEC_ERASE_MODE)) { 2223 (outbuf[0] & MTIP_SEC_ERASE_MODE)) {
2223 erasemode = 1; 2224 erasemode = 1;
2224 } 2225 }
2225 2226
@@ -2439,7 +2440,7 @@ static int mtip_hw_ioctl(struct driver_data *dd, unsigned int cmd,
2439 * return value 2440 * return value
2440 * None 2441 * None
2441 */ 2442 */
2442static void mtip_hw_submit_io(struct driver_data *dd, sector_t start, 2443static void mtip_hw_submit_io(struct driver_data *dd, sector_t sector,
2443 int nsect, int nents, int tag, void *callback, 2444 int nsect, int nents, int tag, void *callback,
2444 void *data, int dir) 2445 void *data, int dir)
2445{ 2446{
@@ -2447,6 +2448,7 @@ static void mtip_hw_submit_io(struct driver_data *dd, sector_t start,
2447 struct mtip_port *port = dd->port; 2448 struct mtip_port *port = dd->port;
2448 struct mtip_cmd *command = &port->commands[tag]; 2449 struct mtip_cmd *command = &port->commands[tag];
2449 int dma_dir = (dir == READ) ? DMA_FROM_DEVICE : DMA_TO_DEVICE; 2450 int dma_dir = (dir == READ) ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
2451 u64 start = sector;
2450 2452
2451 /* Map the scatter list for DMA access */ 2453 /* Map the scatter list for DMA access */
2452 nents = dma_map_sg(&dd->pdev->dev, command->sg, nents, dma_dir); 2454 nents = dma_map_sg(&dd->pdev->dev, command->sg, nents, dma_dir);
@@ -2465,8 +2467,12 @@ static void mtip_hw_submit_io(struct driver_data *dd, sector_t start,
2465 fis->opts = 1 << 7; 2467 fis->opts = 1 << 7;
2466 fis->command = 2468 fis->command =
2467 (dir == READ ? ATA_CMD_FPDMA_READ : ATA_CMD_FPDMA_WRITE); 2469 (dir == READ ? ATA_CMD_FPDMA_READ : ATA_CMD_FPDMA_WRITE);
2468 *((unsigned int *) &fis->lba_low) = (start & 0xFFFFFF); 2470 fis->lba_low = start & 0xFF;
2469 *((unsigned int *) &fis->lba_low_ex) = ((start >> 24) & 0xFFFFFF); 2471 fis->lba_mid = (start >> 8) & 0xFF;
2472 fis->lba_hi = (start >> 16) & 0xFF;
2473 fis->lba_low_ex = (start >> 24) & 0xFF;
2474 fis->lba_mid_ex = (start >> 32) & 0xFF;
2475 fis->lba_hi_ex = (start >> 40) & 0xFF;
2470 fis->device = 1 << 6; 2476 fis->device = 1 << 6;
2471 fis->features = nsect & 0xFF; 2477 fis->features = nsect & 0xFF;
2472 fis->features_ex = (nsect >> 8) & 0xFF; 2478 fis->features_ex = (nsect >> 8) & 0xFF;
diff --git a/drivers/block/mtip32xx/mtip32xx.h b/drivers/block/mtip32xx/mtip32xx.h
index 5f4a917bd8bb..b1742640556a 100644
--- a/drivers/block/mtip32xx/mtip32xx.h
+++ b/drivers/block/mtip32xx/mtip32xx.h
@@ -34,7 +34,7 @@
34#define PCIE_CONFIG_EXT_DEVICE_CONTROL_OFFSET 0x48 34#define PCIE_CONFIG_EXT_DEVICE_CONTROL_OFFSET 0x48
35 35
36/* check for erase mode support during secure erase */ 36/* check for erase mode support during secure erase */
37#define MTIP_SEC_ERASE_MODE 0x3 37#define MTIP_SEC_ERASE_MODE 0x2
38 38
39/* # of times to retry timed out/failed IOs */ 39/* # of times to retry timed out/failed IOs */
40#define MTIP_MAX_RETRIES 2 40#define MTIP_MAX_RETRIES 2
@@ -155,14 +155,14 @@ enum {
155 MTIP_DDF_REBUILD_FAILED_BIT = 8, 155 MTIP_DDF_REBUILD_FAILED_BIT = 8,
156}; 156};
157 157
158__packed struct smart_attr{ 158struct smart_attr {
159 u8 attr_id; 159 u8 attr_id;
160 u16 flags; 160 u16 flags;
161 u8 cur; 161 u8 cur;
162 u8 worst; 162 u8 worst;
163 u32 data; 163 u32 data;
164 u8 res[3]; 164 u8 res[3];
165}; 165} __packed;
166 166
167/* Register Frame Information Structure (FIS), host to device. */ 167/* Register Frame Information Structure (FIS), host to device. */
168struct host_to_dev_fis { 168struct host_to_dev_fis {
diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
index fc2de5528dcc..b00000e8aef6 100644
--- a/drivers/bluetooth/ath3k.c
+++ b/drivers/bluetooth/ath3k.c
@@ -67,6 +67,7 @@ static struct usb_device_id ath3k_table[] = {
67 { USB_DEVICE(0x13d3, 0x3304) }, 67 { USB_DEVICE(0x13d3, 0x3304) },
68 { USB_DEVICE(0x0930, 0x0215) }, 68 { USB_DEVICE(0x0930, 0x0215) },
69 { USB_DEVICE(0x0489, 0xE03D) }, 69 { USB_DEVICE(0x0489, 0xE03D) },
70 { USB_DEVICE(0x0489, 0xE027) },
70 71
71 /* Atheros AR9285 Malbec with sflash firmware */ 72 /* Atheros AR9285 Malbec with sflash firmware */
72 { USB_DEVICE(0x03F0, 0x311D) }, 73 { USB_DEVICE(0x03F0, 0x311D) },
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index debda27df9b0..ee82f2fb65f0 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -124,6 +124,7 @@ static struct usb_device_id blacklist_table[] = {
124 { USB_DEVICE(0x13d3, 0x3304), .driver_info = BTUSB_IGNORE }, 124 { USB_DEVICE(0x13d3, 0x3304), .driver_info = BTUSB_IGNORE },
125 { USB_DEVICE(0x0930, 0x0215), .driver_info = BTUSB_IGNORE }, 125 { USB_DEVICE(0x0930, 0x0215), .driver_info = BTUSB_IGNORE },
126 { USB_DEVICE(0x0489, 0xe03d), .driver_info = BTUSB_IGNORE }, 126 { USB_DEVICE(0x0489, 0xe03d), .driver_info = BTUSB_IGNORE },
127 { USB_DEVICE(0x0489, 0xe027), .driver_info = BTUSB_IGNORE },
127 128
128 /* Atheros AR9285 Malbec with sflash firmware */ 129 /* Atheros AR9285 Malbec with sflash firmware */
129 { USB_DEVICE(0x03f0, 0x311d), .driver_info = BTUSB_IGNORE }, 130 { USB_DEVICE(0x03f0, 0x311d), .driver_info = BTUSB_IGNORE },
diff --git a/drivers/bus/omap-ocp2scp.c b/drivers/bus/omap-ocp2scp.c
index ff63560b8467..0c48b0e05ed6 100644
--- a/drivers/bus/omap-ocp2scp.c
+++ b/drivers/bus/omap-ocp2scp.c
@@ -22,6 +22,26 @@
22#include <linux/pm_runtime.h> 22#include <linux/pm_runtime.h>
23#include <linux/of.h> 23#include <linux/of.h>
24#include <linux/of_platform.h> 24#include <linux/of_platform.h>
25#include <linux/platform_data/omap_ocp2scp.h>
26
27/**
28 * _count_resources - count for the number of resources
29 * @res: struct resource *
30 *
31 * Count and return the number of resources populated for the device that is
32 * connected to ocp2scp.
33 */
34static unsigned _count_resources(struct resource *res)
35{
36 int cnt = 0;
37
38 while (res->start != res->end) {
39 cnt++;
40 res++;
41 }
42
43 return cnt;
44}
25 45
26static int ocp2scp_remove_devices(struct device *dev, void *c) 46static int ocp2scp_remove_devices(struct device *dev, void *c)
27{ 47{
@@ -34,20 +54,62 @@ static int ocp2scp_remove_devices(struct device *dev, void *c)
34 54
35static int __devinit omap_ocp2scp_probe(struct platform_device *pdev) 55static int __devinit omap_ocp2scp_probe(struct platform_device *pdev)
36{ 56{
37 int ret; 57 int ret;
38 struct device_node *np = pdev->dev.of_node; 58 unsigned res_cnt, i;
59 struct device_node *np = pdev->dev.of_node;
60 struct platform_device *pdev_child;
61 struct omap_ocp2scp_platform_data *pdata = pdev->dev.platform_data;
62 struct omap_ocp2scp_dev *dev;
39 63
40 if (np) { 64 if (np) {
41 ret = of_platform_populate(np, NULL, NULL, &pdev->dev); 65 ret = of_platform_populate(np, NULL, NULL, &pdev->dev);
42 if (ret) { 66 if (ret) {
43 dev_err(&pdev->dev, "failed to add resources for ocp2scp child\n"); 67 dev_err(&pdev->dev,
68 "failed to add resources for ocp2scp child\n");
44 goto err0; 69 goto err0;
45 } 70 }
71 } else if (pdata) {
72 for (i = 0, dev = *pdata->devices; i < pdata->dev_cnt; i++,
73 dev++) {
74 res_cnt = _count_resources(dev->res);
75
76 pdev_child = platform_device_alloc(dev->drv_name,
77 PLATFORM_DEVID_AUTO);
78 if (!pdev_child) {
79 dev_err(&pdev->dev,
80 "failed to allocate mem for ocp2scp child\n");
81 goto err0;
82 }
83
84 ret = platform_device_add_resources(pdev_child,
85 dev->res, res_cnt);
86 if (ret) {
87 dev_err(&pdev->dev,
88 "failed to add resources for ocp2scp child\n");
89 goto err1;
90 }
91
92 pdev_child->dev.parent = &pdev->dev;
93
94 ret = platform_device_add(pdev_child);
95 if (ret) {
96 dev_err(&pdev->dev,
97 "failed to register ocp2scp child device\n");
98 goto err1;
99 }
100 }
101 } else {
102 dev_err(&pdev->dev, "OCP2SCP initialized without plat data\n");
103 return -EINVAL;
46 } 104 }
105
47 pm_runtime_enable(&pdev->dev); 106 pm_runtime_enable(&pdev->dev);
48 107
49 return 0; 108 return 0;
50 109
110err1:
111 platform_device_put(pdev_child);
112
51err0: 113err0:
52 device_for_each_child(&pdev->dev, NULL, ocp2scp_remove_devices); 114 device_for_each_child(&pdev->dev, NULL, ocp2scp_remove_devices);
53 115
diff --git a/drivers/clk/ux500/u8500_clk.c b/drivers/clk/ux500/u8500_clk.c
index ca4a25ed844c..e2c17d187d98 100644
--- a/drivers/clk/ux500/u8500_clk.c
+++ b/drivers/clk/ux500/u8500_clk.c
@@ -40,7 +40,7 @@ void u8500_clk_init(void)
40 CLK_IS_ROOT|CLK_IGNORE_UNUSED, 40 CLK_IS_ROOT|CLK_IGNORE_UNUSED,
41 32768); 41 32768);
42 clk_register_clkdev(clk, "clk32k", NULL); 42 clk_register_clkdev(clk, "clk32k", NULL);
43 clk_register_clkdev(clk, NULL, "rtc-pl031"); 43 clk_register_clkdev(clk, "apb_pclk", "rtc-pl031");
44 44
45 /* PRCMU clocks */ 45 /* PRCMU clocks */
46 fw_version = prcmu_get_fw_version(); 46 fw_version = prcmu_get_fw_version();
@@ -228,10 +228,17 @@ void u8500_clk_init(void)
228 228
229 clk = clk_reg_prcc_pclk("p1_pclk2", "per1clk", U8500_CLKRST1_BASE, 229 clk = clk_reg_prcc_pclk("p1_pclk2", "per1clk", U8500_CLKRST1_BASE,
230 BIT(2), 0); 230 BIT(2), 0);
231 clk_register_clkdev(clk, "apb_pclk", "nmk-i2c.1");
232
231 clk = clk_reg_prcc_pclk("p1_pclk3", "per1clk", U8500_CLKRST1_BASE, 233 clk = clk_reg_prcc_pclk("p1_pclk3", "per1clk", U8500_CLKRST1_BASE,
232 BIT(3), 0); 234 BIT(3), 0);
235 clk_register_clkdev(clk, "apb_pclk", "msp0");
236 clk_register_clkdev(clk, "apb_pclk", "ux500-msp-i2s.0");
237
233 clk = clk_reg_prcc_pclk("p1_pclk4", "per1clk", U8500_CLKRST1_BASE, 238 clk = clk_reg_prcc_pclk("p1_pclk4", "per1clk", U8500_CLKRST1_BASE,
234 BIT(4), 0); 239 BIT(4), 0);
240 clk_register_clkdev(clk, "apb_pclk", "msp1");
241 clk_register_clkdev(clk, "apb_pclk", "ux500-msp-i2s.1");
235 242
236 clk = clk_reg_prcc_pclk("p1_pclk5", "per1clk", U8500_CLKRST1_BASE, 243 clk = clk_reg_prcc_pclk("p1_pclk5", "per1clk", U8500_CLKRST1_BASE,
237 BIT(5), 0); 244 BIT(5), 0);
@@ -239,6 +246,7 @@ void u8500_clk_init(void)
239 246
240 clk = clk_reg_prcc_pclk("p1_pclk6", "per1clk", U8500_CLKRST1_BASE, 247 clk = clk_reg_prcc_pclk("p1_pclk6", "per1clk", U8500_CLKRST1_BASE,
241 BIT(6), 0); 248 BIT(6), 0);
249 clk_register_clkdev(clk, "apb_pclk", "nmk-i2c.2");
242 250
243 clk = clk_reg_prcc_pclk("p1_pclk7", "per1clk", U8500_CLKRST1_BASE, 251 clk = clk_reg_prcc_pclk("p1_pclk7", "per1clk", U8500_CLKRST1_BASE,
244 BIT(7), 0); 252 BIT(7), 0);
@@ -246,6 +254,7 @@ void u8500_clk_init(void)
246 254
247 clk = clk_reg_prcc_pclk("p1_pclk8", "per1clk", U8500_CLKRST1_BASE, 255 clk = clk_reg_prcc_pclk("p1_pclk8", "per1clk", U8500_CLKRST1_BASE,
248 BIT(8), 0); 256 BIT(8), 0);
257 clk_register_clkdev(clk, "apb_pclk", "slimbus0");
249 258
250 clk = clk_reg_prcc_pclk("p1_pclk9", "per1clk", U8500_CLKRST1_BASE, 259 clk = clk_reg_prcc_pclk("p1_pclk9", "per1clk", U8500_CLKRST1_BASE,
251 BIT(9), 0); 260 BIT(9), 0);
@@ -255,11 +264,16 @@ void u8500_clk_init(void)
255 264
256 clk = clk_reg_prcc_pclk("p1_pclk10", "per1clk", U8500_CLKRST1_BASE, 265 clk = clk_reg_prcc_pclk("p1_pclk10", "per1clk", U8500_CLKRST1_BASE,
257 BIT(10), 0); 266 BIT(10), 0);
267 clk_register_clkdev(clk, "apb_pclk", "nmk-i2c.4");
268
258 clk = clk_reg_prcc_pclk("p1_pclk11", "per1clk", U8500_CLKRST1_BASE, 269 clk = clk_reg_prcc_pclk("p1_pclk11", "per1clk", U8500_CLKRST1_BASE,
259 BIT(11), 0); 270 BIT(11), 0);
271 clk_register_clkdev(clk, "apb_pclk", "msp3");
272 clk_register_clkdev(clk, "apb_pclk", "ux500-msp-i2s.3");
260 273
261 clk = clk_reg_prcc_pclk("p2_pclk0", "per2clk", U8500_CLKRST2_BASE, 274 clk = clk_reg_prcc_pclk("p2_pclk0", "per2clk", U8500_CLKRST2_BASE,
262 BIT(0), 0); 275 BIT(0), 0);
276 clk_register_clkdev(clk, "apb_pclk", "nmk-i2c.3");
263 277
264 clk = clk_reg_prcc_pclk("p2_pclk1", "per2clk", U8500_CLKRST2_BASE, 278 clk = clk_reg_prcc_pclk("p2_pclk1", "per2clk", U8500_CLKRST2_BASE,
265 BIT(1), 0); 279 BIT(1), 0);
@@ -279,12 +293,13 @@ void u8500_clk_init(void)
279 293
280 clk = clk_reg_prcc_pclk("p2_pclk5", "per2clk", U8500_CLKRST2_BASE, 294 clk = clk_reg_prcc_pclk("p2_pclk5", "per2clk", U8500_CLKRST2_BASE,
281 BIT(5), 0); 295 BIT(5), 0);
296 clk_register_clkdev(clk, "apb_pclk", "msp2");
297 clk_register_clkdev(clk, "apb_pclk", "ux500-msp-i2s.2");
282 298
283 clk = clk_reg_prcc_pclk("p2_pclk6", "per2clk", U8500_CLKRST2_BASE, 299 clk = clk_reg_prcc_pclk("p2_pclk6", "per2clk", U8500_CLKRST2_BASE,
284 BIT(6), 0); 300 BIT(6), 0);
285 clk_register_clkdev(clk, "apb_pclk", "sdi1"); 301 clk_register_clkdev(clk, "apb_pclk", "sdi1");
286 302
287
288 clk = clk_reg_prcc_pclk("p2_pclk7", "per2clk", U8500_CLKRST2_BASE, 303 clk = clk_reg_prcc_pclk("p2_pclk7", "per2clk", U8500_CLKRST2_BASE,
289 BIT(7), 0); 304 BIT(7), 0);
290 clk_register_clkdev(clk, "apb_pclk", "sdi3"); 305 clk_register_clkdev(clk, "apb_pclk", "sdi3");
@@ -316,10 +331,15 @@ void u8500_clk_init(void)
316 331
317 clk = clk_reg_prcc_pclk("p3_pclk1", "per3clk", U8500_CLKRST3_BASE, 332 clk = clk_reg_prcc_pclk("p3_pclk1", "per3clk", U8500_CLKRST3_BASE,
318 BIT(1), 0); 333 BIT(1), 0);
334 clk_register_clkdev(clk, "apb_pclk", "ssp0");
335
319 clk = clk_reg_prcc_pclk("p3_pclk2", "per3clk", U8500_CLKRST3_BASE, 336 clk = clk_reg_prcc_pclk("p3_pclk2", "per3clk", U8500_CLKRST3_BASE,
320 BIT(2), 0); 337 BIT(2), 0);
338 clk_register_clkdev(clk, "apb_pclk", "ssp1");
339
321 clk = clk_reg_prcc_pclk("p3_pclk3", "per3clk", U8500_CLKRST3_BASE, 340 clk = clk_reg_prcc_pclk("p3_pclk3", "per3clk", U8500_CLKRST3_BASE,
322 BIT(3), 0); 341 BIT(3), 0);
342 clk_register_clkdev(clk, "apb_pclk", "nmk-i2c.0");
323 343
324 clk = clk_reg_prcc_pclk("p3_pclk4", "per3clk", U8500_CLKRST3_BASE, 344 clk = clk_reg_prcc_pclk("p3_pclk4", "per3clk", U8500_CLKRST3_BASE,
325 BIT(4), 0); 345 BIT(4), 0);
@@ -401,10 +421,17 @@ void u8500_clk_init(void)
401 421
402 clk = clk_reg_prcc_kclk("p1_i2c1_kclk", "i2cclk", 422 clk = clk_reg_prcc_kclk("p1_i2c1_kclk", "i2cclk",
403 U8500_CLKRST1_BASE, BIT(2), CLK_SET_RATE_GATE); 423 U8500_CLKRST1_BASE, BIT(2), CLK_SET_RATE_GATE);
424 clk_register_clkdev(clk, NULL, "nmk-i2c.1");
425
404 clk = clk_reg_prcc_kclk("p1_msp0_kclk", "msp02clk", 426 clk = clk_reg_prcc_kclk("p1_msp0_kclk", "msp02clk",
405 U8500_CLKRST1_BASE, BIT(3), CLK_SET_RATE_GATE); 427 U8500_CLKRST1_BASE, BIT(3), CLK_SET_RATE_GATE);
428 clk_register_clkdev(clk, NULL, "msp0");
429 clk_register_clkdev(clk, NULL, "ux500-msp-i2s.0");
430
406 clk = clk_reg_prcc_kclk("p1_msp1_kclk", "msp1clk", 431 clk = clk_reg_prcc_kclk("p1_msp1_kclk", "msp1clk",
407 U8500_CLKRST1_BASE, BIT(4), CLK_SET_RATE_GATE); 432 U8500_CLKRST1_BASE, BIT(4), CLK_SET_RATE_GATE);
433 clk_register_clkdev(clk, NULL, "msp1");
434 clk_register_clkdev(clk, NULL, "ux500-msp-i2s.1");
408 435
409 clk = clk_reg_prcc_kclk("p1_sdi0_kclk", "sdmmcclk", 436 clk = clk_reg_prcc_kclk("p1_sdi0_kclk", "sdmmcclk",
410 U8500_CLKRST1_BASE, BIT(5), CLK_SET_RATE_GATE); 437 U8500_CLKRST1_BASE, BIT(5), CLK_SET_RATE_GATE);
@@ -412,17 +439,25 @@ void u8500_clk_init(void)
412 439
413 clk = clk_reg_prcc_kclk("p1_i2c2_kclk", "i2cclk", 440 clk = clk_reg_prcc_kclk("p1_i2c2_kclk", "i2cclk",
414 U8500_CLKRST1_BASE, BIT(6), CLK_SET_RATE_GATE); 441 U8500_CLKRST1_BASE, BIT(6), CLK_SET_RATE_GATE);
442 clk_register_clkdev(clk, NULL, "nmk-i2c.2");
443
415 clk = clk_reg_prcc_kclk("p1_slimbus0_kclk", "slimclk", 444 clk = clk_reg_prcc_kclk("p1_slimbus0_kclk", "slimclk",
416 U8500_CLKRST1_BASE, BIT(3), CLK_SET_RATE_GATE); 445 U8500_CLKRST1_BASE, BIT(8), CLK_SET_RATE_GATE);
417 /* FIXME: Redefinition of BIT(3). */ 446 clk_register_clkdev(clk, NULL, "slimbus0");
447
418 clk = clk_reg_prcc_kclk("p1_i2c4_kclk", "i2cclk", 448 clk = clk_reg_prcc_kclk("p1_i2c4_kclk", "i2cclk",
419 U8500_CLKRST1_BASE, BIT(9), CLK_SET_RATE_GATE); 449 U8500_CLKRST1_BASE, BIT(9), CLK_SET_RATE_GATE);
450 clk_register_clkdev(clk, NULL, "nmk-i2c.4");
451
420 clk = clk_reg_prcc_kclk("p1_msp3_kclk", "msp1clk", 452 clk = clk_reg_prcc_kclk("p1_msp3_kclk", "msp1clk",
421 U8500_CLKRST1_BASE, BIT(10), CLK_SET_RATE_GATE); 453 U8500_CLKRST1_BASE, BIT(10), CLK_SET_RATE_GATE);
454 clk_register_clkdev(clk, NULL, "msp3");
455 clk_register_clkdev(clk, NULL, "ux500-msp-i2s.3");
422 456
423 /* Periph2 */ 457 /* Periph2 */
424 clk = clk_reg_prcc_kclk("p2_i2c3_kclk", "i2cclk", 458 clk = clk_reg_prcc_kclk("p2_i2c3_kclk", "i2cclk",
425 U8500_CLKRST2_BASE, BIT(0), CLK_SET_RATE_GATE); 459 U8500_CLKRST2_BASE, BIT(0), CLK_SET_RATE_GATE);
460 clk_register_clkdev(clk, NULL, "nmk-i2c.3");
426 461
427 clk = clk_reg_prcc_kclk("p2_sdi4_kclk", "sdmmcclk", 462 clk = clk_reg_prcc_kclk("p2_sdi4_kclk", "sdmmcclk",
428 U8500_CLKRST2_BASE, BIT(2), CLK_SET_RATE_GATE); 463 U8500_CLKRST2_BASE, BIT(2), CLK_SET_RATE_GATE);
@@ -430,6 +465,8 @@ void u8500_clk_init(void)
430 465
431 clk = clk_reg_prcc_kclk("p2_msp2_kclk", "msp02clk", 466 clk = clk_reg_prcc_kclk("p2_msp2_kclk", "msp02clk",
432 U8500_CLKRST2_BASE, BIT(3), CLK_SET_RATE_GATE); 467 U8500_CLKRST2_BASE, BIT(3), CLK_SET_RATE_GATE);
468 clk_register_clkdev(clk, NULL, "msp2");
469 clk_register_clkdev(clk, NULL, "ux500-msp-i2s.2");
433 470
434 clk = clk_reg_prcc_kclk("p2_sdi1_kclk", "sdmmcclk", 471 clk = clk_reg_prcc_kclk("p2_sdi1_kclk", "sdmmcclk",
435 U8500_CLKRST2_BASE, BIT(4), CLK_SET_RATE_GATE); 472 U8500_CLKRST2_BASE, BIT(4), CLK_SET_RATE_GATE);
@@ -450,10 +487,15 @@ void u8500_clk_init(void)
450 /* Periph3 */ 487 /* Periph3 */
451 clk = clk_reg_prcc_kclk("p3_ssp0_kclk", "sspclk", 488 clk = clk_reg_prcc_kclk("p3_ssp0_kclk", "sspclk",
452 U8500_CLKRST3_BASE, BIT(1), CLK_SET_RATE_GATE); 489 U8500_CLKRST3_BASE, BIT(1), CLK_SET_RATE_GATE);
490 clk_register_clkdev(clk, NULL, "ssp0");
491
453 clk = clk_reg_prcc_kclk("p3_ssp1_kclk", "sspclk", 492 clk = clk_reg_prcc_kclk("p3_ssp1_kclk", "sspclk",
454 U8500_CLKRST3_BASE, BIT(2), CLK_SET_RATE_GATE); 493 U8500_CLKRST3_BASE, BIT(2), CLK_SET_RATE_GATE);
494 clk_register_clkdev(clk, NULL, "ssp1");
495
455 clk = clk_reg_prcc_kclk("p3_i2c0_kclk", "i2cclk", 496 clk = clk_reg_prcc_kclk("p3_i2c0_kclk", "i2cclk",
456 U8500_CLKRST3_BASE, BIT(3), CLK_SET_RATE_GATE); 497 U8500_CLKRST3_BASE, BIT(3), CLK_SET_RATE_GATE);
498 clk_register_clkdev(clk, NULL, "nmk-i2c.0");
457 499
458 clk = clk_reg_prcc_kclk("p3_sdi2_kclk", "sdmmcclk", 500 clk = clk_reg_prcc_kclk("p3_sdi2_kclk", "sdmmcclk",
459 U8500_CLKRST3_BASE, BIT(4), CLK_SET_RATE_GATE); 501 U8500_CLKRST3_BASE, BIT(4), CLK_SET_RATE_GATE);
diff --git a/drivers/edac/amd64_edac.h b/drivers/edac/amd64_edac.h
index 8d4804732bac..8c4139647efc 100644
--- a/drivers/edac/amd64_edac.h
+++ b/drivers/edac/amd64_edac.h
@@ -33,7 +33,7 @@
33 * detection. The mods to Rev F required more family 33 * detection. The mods to Rev F required more family
34 * information detection. 34 * information detection.
35 * 35 *
36 * Changes/Fixes by Borislav Petkov <borislav.petkov@amd.com>: 36 * Changes/Fixes by Borislav Petkov <bp@alien8.de>:
37 * - misc fixes and code cleanups 37 * - misc fixes and code cleanups
38 * 38 *
39 * This module is based on the following documents 39 * This module is based on the following documents
diff --git a/drivers/edac/edac_stub.c b/drivers/edac/edac_stub.c
index 6c86f6e54558..351945fa2ecd 100644
--- a/drivers/edac/edac_stub.c
+++ b/drivers/edac/edac_stub.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * 2007 (c) MontaVista Software, Inc. 6 * 2007 (c) MontaVista Software, Inc.
7 * 2010 (c) Advanced Micro Devices Inc. 7 * 2010 (c) Advanced Micro Devices Inc.
8 * Borislav Petkov <borislav.petkov@amd.com> 8 * Borislav Petkov <bp@alien8.de>
9 * 9 *
10 * This file is licensed under the terms of the GNU General Public 10 * This file is licensed under the terms of the GNU General Public
11 * License version 2. This program is licensed "as is" without any 11 * License version 2. This program is licensed "as is" without any
diff --git a/drivers/edac/mce_amd_inj.c b/drivers/edac/mce_amd_inj.c
index 66b5151c1080..2ae78f20cc28 100644
--- a/drivers/edac/mce_amd_inj.c
+++ b/drivers/edac/mce_amd_inj.c
@@ -6,7 +6,7 @@
6 * This file may be distributed under the terms of the GNU General Public 6 * This file may be distributed under the terms of the GNU General Public
7 * License version 2. 7 * License version 2.
8 * 8 *
9 * Copyright (c) 2010: Borislav Petkov <borislav.petkov@amd.com> 9 * Copyright (c) 2010: Borislav Petkov <bp@alien8.de>
10 * Advanced Micro Devices Inc. 10 * Advanced Micro Devices Inc.
11 */ 11 */
12 12
@@ -168,6 +168,6 @@ module_init(edac_init_mce_inject);
168module_exit(edac_exit_mce_inject); 168module_exit(edac_exit_mce_inject);
169 169
170MODULE_LICENSE("GPL"); 170MODULE_LICENSE("GPL");
171MODULE_AUTHOR("Borislav Petkov <borislav.petkov@amd.com>"); 171MODULE_AUTHOR("Borislav Petkov <bp@alien8.de>");
172MODULE_AUTHOR("AMD Inc."); 172MODULE_AUTHOR("AMD Inc.");
173MODULE_DESCRIPTION("MCE injection facility for testing MCE decoding"); 173MODULE_DESCRIPTION("MCE injection facility for testing MCE decoding");
diff --git a/drivers/firewire/sbp2.c b/drivers/firewire/sbp2.c
index 1162d6b3bf85..bb1b392f5cda 100644
--- a/drivers/firewire/sbp2.c
+++ b/drivers/firewire/sbp2.c
@@ -1546,6 +1546,8 @@ static int sbp2_scsi_slave_configure(struct scsi_device *sdev)
1546 struct sbp2_logical_unit *lu = sdev->hostdata; 1546 struct sbp2_logical_unit *lu = sdev->hostdata;
1547 1547
1548 sdev->use_10_for_rw = 1; 1548 sdev->use_10_for_rw = 1;
1549 sdev->no_report_opcodes = 1;
1550 sdev->no_write_same = 1;
1549 1551
1550 if (sbp2_param_exclusive_login) 1552 if (sbp2_param_exclusive_login)
1551 sdev->manage_start_stop = 1; 1553 sdev->manage_start_stop = 1;
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index f11d8e3b4041..47150f5ded04 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -466,7 +466,7 @@ config GPIO_ADP5588_IRQ
466 466
467config GPIO_ADNP 467config GPIO_ADNP
468 tristate "Avionic Design N-bit GPIO expander" 468 tristate "Avionic Design N-bit GPIO expander"
469 depends on I2C && OF 469 depends on I2C && OF_GPIO
470 help 470 help
471 This option enables support for N GPIOs found on Avionic Design 471 This option enables support for N GPIOs found on Avionic Design
472 I2C GPIO expanders. The register space will be extended by powers 472 I2C GPIO expanders. The register space will be extended by powers
diff --git a/drivers/gpio/gpio-mcp23s08.c b/drivers/gpio/gpio-mcp23s08.c
index 0f425189de11..ce1c84760076 100644
--- a/drivers/gpio/gpio-mcp23s08.c
+++ b/drivers/gpio/gpio-mcp23s08.c
@@ -77,7 +77,7 @@ struct mcp23s08_driver_data {
77 77
78/*----------------------------------------------------------------------*/ 78/*----------------------------------------------------------------------*/
79 79
80#ifdef CONFIG_I2C 80#if IS_ENABLED(CONFIG_I2C)
81 81
82static int mcp23008_read(struct mcp23s08 *mcp, unsigned reg) 82static int mcp23008_read(struct mcp23s08 *mcp, unsigned reg)
83{ 83{
@@ -399,7 +399,7 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev,
399 break; 399 break;
400#endif /* CONFIG_SPI_MASTER */ 400#endif /* CONFIG_SPI_MASTER */
401 401
402#ifdef CONFIG_I2C 402#if IS_ENABLED(CONFIG_I2C)
403 case MCP_TYPE_008: 403 case MCP_TYPE_008:
404 mcp->ops = &mcp23008_ops; 404 mcp->ops = &mcp23008_ops;
405 mcp->chip.ngpio = 8; 405 mcp->chip.ngpio = 8;
@@ -473,7 +473,7 @@ fail:
473 473
474/*----------------------------------------------------------------------*/ 474/*----------------------------------------------------------------------*/
475 475
476#ifdef CONFIG_I2C 476#if IS_ENABLED(CONFIG_I2C)
477 477
478static int __devinit mcp230xx_probe(struct i2c_client *client, 478static int __devinit mcp230xx_probe(struct i2c_client *client,
479 const struct i2c_device_id *id) 479 const struct i2c_device_id *id)
diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
index cf7afb9eb61a..be65c0451ad5 100644
--- a/drivers/gpio/gpio-mvebu.c
+++ b/drivers/gpio/gpio-mvebu.c
@@ -92,6 +92,11 @@ static inline void __iomem *mvebu_gpioreg_out(struct mvebu_gpio_chip *mvchip)
92 return mvchip->membase + GPIO_OUT_OFF; 92 return mvchip->membase + GPIO_OUT_OFF;
93} 93}
94 94
95static inline void __iomem *mvebu_gpioreg_blink(struct mvebu_gpio_chip *mvchip)
96{
97 return mvchip->membase + GPIO_BLINK_EN_OFF;
98}
99
95static inline void __iomem *mvebu_gpioreg_io_conf(struct mvebu_gpio_chip *mvchip) 100static inline void __iomem *mvebu_gpioreg_io_conf(struct mvebu_gpio_chip *mvchip)
96{ 101{
97 return mvchip->membase + GPIO_IO_CONF_OFF; 102 return mvchip->membase + GPIO_IO_CONF_OFF;
@@ -206,6 +211,23 @@ static int mvebu_gpio_get(struct gpio_chip *chip, unsigned pin)
206 return (u >> pin) & 1; 211 return (u >> pin) & 1;
207} 212}
208 213
214static void mvebu_gpio_blink(struct gpio_chip *chip, unsigned pin, int value)
215{
216 struct mvebu_gpio_chip *mvchip =
217 container_of(chip, struct mvebu_gpio_chip, chip);
218 unsigned long flags;
219 u32 u;
220
221 spin_lock_irqsave(&mvchip->lock, flags);
222 u = readl_relaxed(mvebu_gpioreg_blink(mvchip));
223 if (value)
224 u |= 1 << pin;
225 else
226 u &= ~(1 << pin);
227 writel_relaxed(u, mvebu_gpioreg_blink(mvchip));
228 spin_unlock_irqrestore(&mvchip->lock, flags);
229}
230
209static int mvebu_gpio_direction_input(struct gpio_chip *chip, unsigned pin) 231static int mvebu_gpio_direction_input(struct gpio_chip *chip, unsigned pin)
210{ 232{
211 struct mvebu_gpio_chip *mvchip = 233 struct mvebu_gpio_chip *mvchip =
@@ -244,6 +266,7 @@ static int mvebu_gpio_direction_output(struct gpio_chip *chip, unsigned pin,
244 if (ret) 266 if (ret)
245 return ret; 267 return ret;
246 268
269 mvebu_gpio_blink(chip, pin, 0);
247 mvebu_gpio_set(chip, pin, value); 270 mvebu_gpio_set(chip, pin, value);
248 271
249 spin_lock_irqsave(&mvchip->lock, flags); 272 spin_lock_irqsave(&mvchip->lock, flags);
diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c
index b726b478a4f5..6345878ae1e7 100644
--- a/drivers/gpu/drm/i915/intel_crt.c
+++ b/drivers/gpu/drm/i915/intel_crt.c
@@ -143,7 +143,7 @@ static void intel_crt_dpms(struct drm_connector *connector, int mode)
143 int old_dpms; 143 int old_dpms;
144 144
145 /* PCH platforms and VLV only support on/off. */ 145 /* PCH platforms and VLV only support on/off. */
146 if (INTEL_INFO(dev)->gen < 5 && mode != DRM_MODE_DPMS_ON) 146 if (INTEL_INFO(dev)->gen >= 5 && mode != DRM_MODE_DPMS_ON)
147 mode = DRM_MODE_DPMS_OFF; 147 mode = DRM_MODE_DPMS_OFF;
148 148
149 if (mode == connector->dpms) 149 if (mode == connector->dpms)
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 461a637f1ef7..4154bcd7a070 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -3841,6 +3841,17 @@ static bool intel_choose_pipe_bpp_dither(struct drm_crtc *crtc,
3841 } 3841 }
3842 } 3842 }
3843 3843
3844 if (intel_encoder->type == INTEL_OUTPUT_EDP) {
3845 /* Use VBT settings if we have an eDP panel */
3846 unsigned int edp_bpc = dev_priv->edp.bpp / 3;
3847
3848 if (edp_bpc < display_bpc) {
3849 DRM_DEBUG_KMS("clamping display bpc (was %d) to eDP (%d)\n", display_bpc, edp_bpc);
3850 display_bpc = edp_bpc;
3851 }
3852 continue;
3853 }
3854
3844 /* 3855 /*
3845 * HDMI is either 12 or 8, so if the display lets 10bpc sneak 3856 * HDMI is either 12 or 8, so if the display lets 10bpc sneak
3846 * through, clamp it down. (Note: >12bpc will be caught below.) 3857 * through, clamp it down. (Note: >12bpc will be caught below.)
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index 79d308da29ff..c600fb06e25e 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -2382,6 +2382,18 @@ intel_sdvo_output_setup(struct intel_sdvo *intel_sdvo, uint16_t flags)
2382 return true; 2382 return true;
2383} 2383}
2384 2384
2385static void intel_sdvo_output_cleanup(struct intel_sdvo *intel_sdvo)
2386{
2387 struct drm_device *dev = intel_sdvo->base.base.dev;
2388 struct drm_connector *connector, *tmp;
2389
2390 list_for_each_entry_safe(connector, tmp,
2391 &dev->mode_config.connector_list, head) {
2392 if (intel_attached_encoder(connector) == &intel_sdvo->base)
2393 intel_sdvo_destroy(connector);
2394 }
2395}
2396
2385static bool intel_sdvo_tv_create_property(struct intel_sdvo *intel_sdvo, 2397static bool intel_sdvo_tv_create_property(struct intel_sdvo *intel_sdvo,
2386 struct intel_sdvo_connector *intel_sdvo_connector, 2398 struct intel_sdvo_connector *intel_sdvo_connector,
2387 int type) 2399 int type)
@@ -2705,7 +2717,8 @@ bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob)
2705 intel_sdvo->caps.output_flags) != true) { 2717 intel_sdvo->caps.output_flags) != true) {
2706 DRM_DEBUG_KMS("SDVO output failed to setup on %s\n", 2718 DRM_DEBUG_KMS("SDVO output failed to setup on %s\n",
2707 SDVO_NAME(intel_sdvo)); 2719 SDVO_NAME(intel_sdvo));
2708 goto err; 2720 /* Output_setup can leave behind connectors! */
2721 goto err_output;
2709 } 2722 }
2710 2723
2711 /* Only enable the hotplug irq if we need it, to work around noisy 2724 /* Only enable the hotplug irq if we need it, to work around noisy
@@ -2718,12 +2731,12 @@ bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob)
2718 2731
2719 /* Set the input timing to the screen. Assume always input 0. */ 2732 /* Set the input timing to the screen. Assume always input 0. */
2720 if (!intel_sdvo_set_target_input(intel_sdvo)) 2733 if (!intel_sdvo_set_target_input(intel_sdvo))
2721 goto err; 2734 goto err_output;
2722 2735
2723 if (!intel_sdvo_get_input_pixel_clock_range(intel_sdvo, 2736 if (!intel_sdvo_get_input_pixel_clock_range(intel_sdvo,
2724 &intel_sdvo->pixel_clock_min, 2737 &intel_sdvo->pixel_clock_min,
2725 &intel_sdvo->pixel_clock_max)) 2738 &intel_sdvo->pixel_clock_max))
2726 goto err; 2739 goto err_output;
2727 2740
2728 DRM_DEBUG_KMS("%s device VID/DID: %02X:%02X.%02X, " 2741 DRM_DEBUG_KMS("%s device VID/DID: %02X:%02X.%02X, "
2729 "clock range %dMHz - %dMHz, " 2742 "clock range %dMHz - %dMHz, "
@@ -2743,6 +2756,9 @@ bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob)
2743 (SDVO_OUTPUT_TMDS1 | SDVO_OUTPUT_RGB1) ? 'Y' : 'N'); 2756 (SDVO_OUTPUT_TMDS1 | SDVO_OUTPUT_RGB1) ? 'Y' : 'N');
2744 return true; 2757 return true;
2745 2758
2759err_output:
2760 intel_sdvo_output_cleanup(intel_sdvo);
2761
2746err: 2762err:
2747 drm_encoder_cleanup(&intel_encoder->base); 2763 drm_encoder_cleanup(&intel_encoder->base);
2748 i2c_del_adapter(&intel_sdvo->ddc); 2764 i2c_del_adapter(&intel_sdvo->ddc);
diff --git a/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c b/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c
index 05a909a17cee..15b182c84ce8 100644
--- a/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c
+++ b/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c
@@ -49,13 +49,7 @@ nv50_disp_intr_vblank(struct nv50_disp_priv *priv, int crtc)
49 if (chan->vblank.crtc != crtc) 49 if (chan->vblank.crtc != crtc)
50 continue; 50 continue;
51 51
52 if (nv_device(priv)->chipset == 0x50) { 52 if (nv_device(priv)->chipset >= 0xc0) {
53 nv_wr32(priv, 0x001704, chan->vblank.channel);
54 nv_wr32(priv, 0x001710, 0x80000000 | chan->vblank.ctxdma);
55 bar->flush(bar);
56 nv_wr32(priv, 0x001570, chan->vblank.offset);
57 nv_wr32(priv, 0x001574, chan->vblank.value);
58 } else {
59 nv_wr32(priv, 0x001718, 0x80000000 | chan->vblank.channel); 53 nv_wr32(priv, 0x001718, 0x80000000 | chan->vblank.channel);
60 bar->flush(bar); 54 bar->flush(bar);
61 nv_wr32(priv, 0x06000c, 55 nv_wr32(priv, 0x06000c,
@@ -63,6 +57,17 @@ nv50_disp_intr_vblank(struct nv50_disp_priv *priv, int crtc)
63 nv_wr32(priv, 0x060010, 57 nv_wr32(priv, 0x060010,
64 lower_32_bits(chan->vblank.offset)); 58 lower_32_bits(chan->vblank.offset));
65 nv_wr32(priv, 0x060014, chan->vblank.value); 59 nv_wr32(priv, 0x060014, chan->vblank.value);
60 } else {
61 nv_wr32(priv, 0x001704, chan->vblank.channel);
62 nv_wr32(priv, 0x001710, 0x80000000 | chan->vblank.ctxdma);
63 bar->flush(bar);
64 if (nv_device(priv)->chipset == 0x50) {
65 nv_wr32(priv, 0x001570, chan->vblank.offset);
66 nv_wr32(priv, 0x001574, chan->vblank.value);
67 } else {
68 nv_wr32(priv, 0x060010, chan->vblank.offset);
69 nv_wr32(priv, 0x060014, chan->vblank.value);
70 }
66 } 71 }
67 72
68 list_del(&chan->vblank.head); 73 list_del(&chan->vblank.head);
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnv40.c b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnv40.c
index e45035efb8ca..7bbb1e1b7a8d 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnv40.c
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnv40.c
@@ -669,21 +669,27 @@ nv40_grctx_fill(struct nouveau_device *device, struct nouveau_gpuobj *mem)
669 }); 669 });
670} 670}
671 671
672void 672int
673nv40_grctx_init(struct nouveau_device *device, u32 *size) 673nv40_grctx_init(struct nouveau_device *device, u32 *size)
674{ 674{
675 u32 ctxprog[256], i; 675 u32 *ctxprog = kmalloc(256 * 4, GFP_KERNEL), i;
676 struct nouveau_grctx ctx = { 676 struct nouveau_grctx ctx = {
677 .device = device, 677 .device = device,
678 .mode = NOUVEAU_GRCTX_PROG, 678 .mode = NOUVEAU_GRCTX_PROG,
679 .data = ctxprog, 679 .data = ctxprog,
680 .ctxprog_max = ARRAY_SIZE(ctxprog) 680 .ctxprog_max = 256,
681 }; 681 };
682 682
683 if (!ctxprog)
684 return -ENOMEM;
685
683 nv40_grctx_generate(&ctx); 686 nv40_grctx_generate(&ctx);
684 687
685 nv_wr32(device, 0x400324, 0); 688 nv_wr32(device, 0x400324, 0);
686 for (i = 0; i < ctx.ctxprog_len; i++) 689 for (i = 0; i < ctx.ctxprog_len; i++)
687 nv_wr32(device, 0x400328, ctxprog[i]); 690 nv_wr32(device, 0x400328, ctxprog[i]);
688 *size = ctx.ctxvals_pos * 4; 691 *size = ctx.ctxvals_pos * 4;
692
693 kfree(ctxprog);
694 return 0;
689} 695}
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/nv40.c b/drivers/gpu/drm/nouveau/core/engine/graph/nv40.c
index 425001204a89..cc6574eeb80e 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/nv40.c
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/nv40.c
@@ -346,7 +346,9 @@ nv40_graph_init(struct nouveau_object *object)
346 return ret; 346 return ret;
347 347
348 /* generate and upload context program */ 348 /* generate and upload context program */
349 nv40_grctx_init(nv_device(priv), &priv->size); 349 ret = nv40_grctx_init(nv_device(priv), &priv->size);
350 if (ret)
351 return ret;
350 352
351 /* No context present currently */ 353 /* No context present currently */
352 nv_wr32(priv, NV40_PGRAPH_CTXCTL_CUR, 0x00000000); 354 nv_wr32(priv, NV40_PGRAPH_CTXCTL_CUR, 0x00000000);
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/nv40.h b/drivers/gpu/drm/nouveau/core/engine/graph/nv40.h
index d2ac975afc2e..7da35a4e7970 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/nv40.h
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/nv40.h
@@ -15,7 +15,7 @@ nv44_graph_class(void *priv)
15 return !(0x0baf & (1 << (device->chipset & 0x0f))); 15 return !(0x0baf & (1 << (device->chipset & 0x0f)));
16} 16}
17 17
18void nv40_grctx_init(struct nouveau_device *, u32 *size); 18int nv40_grctx_init(struct nouveau_device *, u32 *size);
19void nv40_grctx_fill(struct nouveau_device *, struct nouveau_gpuobj *); 19void nv40_grctx_fill(struct nouveau_device *, struct nouveau_gpuobj *);
20 20
21#endif 21#endif
diff --git a/drivers/gpu/drm/nouveau/core/include/core/object.h b/drivers/gpu/drm/nouveau/core/include/core/object.h
index 818feabbf4a0..486f1a9217fd 100644
--- a/drivers/gpu/drm/nouveau/core/include/core/object.h
+++ b/drivers/gpu/drm/nouveau/core/include/core/object.h
@@ -175,14 +175,18 @@ nv_mo32(void *obj, u32 addr, u32 mask, u32 data)
175 return temp; 175 return temp;
176} 176}
177 177
178static inline bool 178static inline int
179nv_strncmp(void *obj, u32 addr, u32 len, const char *str) 179nv_memcmp(void *obj, u32 addr, const char *str, u32 len)
180{ 180{
181 unsigned char c1, c2;
182
181 while (len--) { 183 while (len--) {
182 if (nv_ro08(obj, addr++) != *(str++)) 184 c1 = nv_ro08(obj, addr++);
183 return false; 185 c2 = *(str++);
186 if (c1 != c2)
187 return c1 - c2;
184 } 188 }
185 return true; 189 return 0;
186} 190}
187 191
188#endif 192#endif
diff --git a/drivers/gpu/drm/nouveau/core/include/subdev/clock.h b/drivers/gpu/drm/nouveau/core/include/subdev/clock.h
index 39e73b91d360..41b7a6a76f19 100644
--- a/drivers/gpu/drm/nouveau/core/include/subdev/clock.h
+++ b/drivers/gpu/drm/nouveau/core/include/subdev/clock.h
@@ -54,6 +54,7 @@ int nv04_clock_pll_calc(struct nouveau_clock *, struct nvbios_pll *,
54 int clk, struct nouveau_pll_vals *); 54 int clk, struct nouveau_pll_vals *);
55int nv04_clock_pll_prog(struct nouveau_clock *, u32 reg1, 55int nv04_clock_pll_prog(struct nouveau_clock *, u32 reg1,
56 struct nouveau_pll_vals *); 56 struct nouveau_pll_vals *);
57 57int nva3_clock_pll_calc(struct nouveau_clock *, struct nvbios_pll *,
58 int clk, struct nouveau_pll_vals *);
58 59
59#endif 60#endif
diff --git a/drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c b/drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c
index 7d750382a833..c51197157749 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c
@@ -64,7 +64,7 @@ dcb_table(struct nouveau_bios *bios, u8 *ver, u8 *hdr, u8 *cnt, u8 *len)
64 } 64 }
65 } else 65 } else
66 if (*ver >= 0x15) { 66 if (*ver >= 0x15) {
67 if (!nv_strncmp(bios, dcb - 7, 7, "DEV_REC")) { 67 if (!nv_memcmp(bios, dcb - 7, "DEV_REC", 7)) {
68 u16 i2c = nv_ro16(bios, dcb + 2); 68 u16 i2c = nv_ro16(bios, dcb + 2);
69 *hdr = 4; 69 *hdr = 4;
70 *cnt = (i2c - dcb) / 10; 70 *cnt = (i2c - dcb) / 10;
diff --git a/drivers/gpu/drm/nouveau/core/subdev/clock/nva3.c b/drivers/gpu/drm/nouveau/core/subdev/clock/nva3.c
index cc8d7d162d7c..9068c98b96f6 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/clock/nva3.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/clock/nva3.c
@@ -66,6 +66,24 @@ nva3_clock_pll_set(struct nouveau_clock *clk, u32 type, u32 freq)
66 return ret; 66 return ret;
67} 67}
68 68
69int
70nva3_clock_pll_calc(struct nouveau_clock *clock, struct nvbios_pll *info,
71 int clk, struct nouveau_pll_vals *pv)
72{
73 int ret, N, M, P;
74
75 ret = nva3_pll_calc(clock, info, clk, &N, NULL, &M, &P);
76
77 if (ret > 0) {
78 pv->refclk = info->refclk;
79 pv->N1 = N;
80 pv->M1 = M;
81 pv->log2P = P;
82 }
83 return ret;
84}
85
86
69static int 87static int
70nva3_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine, 88nva3_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
71 struct nouveau_oclass *oclass, void *data, u32 size, 89 struct nouveau_oclass *oclass, void *data, u32 size,
@@ -80,6 +98,7 @@ nva3_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
80 return ret; 98 return ret;
81 99
82 priv->base.pll_set = nva3_clock_pll_set; 100 priv->base.pll_set = nva3_clock_pll_set;
101 priv->base.pll_calc = nva3_clock_pll_calc;
83 return 0; 102 return 0;
84} 103}
85 104
diff --git a/drivers/gpu/drm/nouveau/core/subdev/clock/nvc0.c b/drivers/gpu/drm/nouveau/core/subdev/clock/nvc0.c
index 5ccce0b17bf3..f6962c9b6c36 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/clock/nvc0.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/clock/nvc0.c
@@ -79,6 +79,7 @@ nvc0_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
79 return ret; 79 return ret;
80 80
81 priv->base.pll_set = nvc0_clock_pll_set; 81 priv->base.pll_set = nvc0_clock_pll_set;
82 priv->base.pll_calc = nva3_clock_pll_calc;
82 return 0; 83 return 0;
83} 84}
84 85
diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouveau/nouveau_abi16.c
index cc79c796afee..cbf1fc60a386 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.c
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c
@@ -241,6 +241,10 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
241 241
242 if (unlikely(!abi16)) 242 if (unlikely(!abi16))
243 return -ENOMEM; 243 return -ENOMEM;
244
245 if (!drm->channel)
246 return nouveau_abi16_put(abi16, -ENODEV);
247
244 client = nv_client(abi16->client); 248 client = nv_client(abi16->client);
245 249
246 if (init->fb_ctxdma_handle == ~0 || init->tt_ctxdma_handle == ~0) 250 if (init->fb_ctxdma_handle == ~0 || init->tt_ctxdma_handle == ~0)
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 0910125cbbc3..8503b2ea570a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -129,7 +129,8 @@ nouveau_accel_init(struct nouveau_drm *drm)
129 129
130 /* initialise synchronisation routines */ 130 /* initialise synchronisation routines */
131 if (device->card_type < NV_10) ret = nv04_fence_create(drm); 131 if (device->card_type < NV_10) ret = nv04_fence_create(drm);
132 else if (device->chipset < 0x84) ret = nv10_fence_create(drm); 132 else if (device->card_type < NV_50) ret = nv10_fence_create(drm);
133 else if (device->chipset < 0x84) ret = nv50_fence_create(drm);
133 else if (device->card_type < NV_C0) ret = nv84_fence_create(drm); 134 else if (device->card_type < NV_C0) ret = nv84_fence_create(drm);
134 else ret = nvc0_fence_create(drm); 135 else ret = nvc0_fence_create(drm);
135 if (ret) { 136 if (ret) {
diff --git a/drivers/gpu/drm/radeon/atombios_encoders.c b/drivers/gpu/drm/radeon/atombios_encoders.c
index ba498f8e47a2..010bae19554a 100644
--- a/drivers/gpu/drm/radeon/atombios_encoders.c
+++ b/drivers/gpu/drm/radeon/atombios_encoders.c
@@ -1625,7 +1625,7 @@ radeon_atom_encoder_dpms_dig(struct drm_encoder *encoder, int mode)
1625 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_SETUP, 0, 0); 1625 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_SETUP, 0, 0);
1626 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE, 0, 0); 1626 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE, 0, 0);
1627 /* some early dce3.2 boards have a bug in their transmitter control table */ 1627 /* some early dce3.2 boards have a bug in their transmitter control table */
1628 if ((rdev->family != CHIP_RV710) || (rdev->family != CHIP_RV730)) 1628 if ((rdev->family != CHIP_RV710) && (rdev->family != CHIP_RV730))
1629 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE_OUTPUT, 0, 0); 1629 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE_OUTPUT, 0, 0);
1630 } 1630 }
1631 if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(encoder)) && connector) { 1631 if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(encoder)) && connector) {
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index af31f829f4a8..219942c660d7 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -1330,6 +1330,8 @@ void evergreen_mc_stop(struct radeon_device *rdev, struct evergreen_mc_save *sav
1330 break; 1330 break;
1331 udelay(1); 1331 udelay(1);
1332 } 1332 }
1333 } else {
1334 save->crtc_enabled[i] = false;
1333 } 1335 }
1334 } 1336 }
1335 1337
diff --git a/drivers/gpu/drm/radeon/radeon_agp.c b/drivers/gpu/drm/radeon/radeon_agp.c
index 10ea17a6b2a6..42433344cb1b 100644
--- a/drivers/gpu/drm/radeon/radeon_agp.c
+++ b/drivers/gpu/drm/radeon/radeon_agp.c
@@ -69,9 +69,12 @@ static struct radeon_agpmode_quirk radeon_agpmode_quirk_list[] = {
69 /* Intel 82830 830 Chipset Host Bridge / Mobility M6 LY Needs AGPMode 2 (fdo #17360)*/ 69 /* Intel 82830 830 Chipset Host Bridge / Mobility M6 LY Needs AGPMode 2 (fdo #17360)*/
70 { PCI_VENDOR_ID_INTEL, 0x3575, PCI_VENDOR_ID_ATI, 0x4c59, 70 { PCI_VENDOR_ID_INTEL, 0x3575, PCI_VENDOR_ID_ATI, 0x4c59,
71 PCI_VENDOR_ID_DELL, 0x00e3, 2}, 71 PCI_VENDOR_ID_DELL, 0x00e3, 2},
72 /* Intel 82852/82855 host bridge / Mobility FireGL 9000 R250 Needs AGPMode 1 (lp #296617) */ 72 /* Intel 82852/82855 host bridge / Mobility FireGL 9000 RV250 Needs AGPMode 1 (lp #296617) */
73 { PCI_VENDOR_ID_INTEL, 0x3580, PCI_VENDOR_ID_ATI, 0x4c66, 73 { PCI_VENDOR_ID_INTEL, 0x3580, PCI_VENDOR_ID_ATI, 0x4c66,
74 PCI_VENDOR_ID_DELL, 0x0149, 1}, 74 PCI_VENDOR_ID_DELL, 0x0149, 1},
75 /* Intel 82855PM host bridge / Mobility FireGL 9000 RV250 Needs AGPMode 1 for suspend/resume */
76 { PCI_VENDOR_ID_INTEL, 0x3340, PCI_VENDOR_ID_ATI, 0x4c66,
77 PCI_VENDOR_ID_IBM, 0x0531, 1},
75 /* Intel 82852/82855 host bridge / Mobility 9600 M10 RV350 Needs AGPMode 1 (deb #467460) */ 78 /* Intel 82852/82855 host bridge / Mobility 9600 M10 RV350 Needs AGPMode 1 (deb #467460) */
76 { PCI_VENDOR_ID_INTEL, 0x3580, PCI_VENDOR_ID_ATI, 0x4e50, 79 { PCI_VENDOR_ID_INTEL, 0x3580, PCI_VENDOR_ID_ATI, 0x4e50,
77 0x1025, 0x0061, 1}, 80 0x1025, 0x0061, 1},
diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
index 860dc4813e99..bd2a3b40cd12 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
@@ -749,7 +749,10 @@ static int ttm_get_pages(struct page **pages, unsigned npages, int flags,
749 /* clear the pages coming from the pool if requested */ 749 /* clear the pages coming from the pool if requested */
750 if (flags & TTM_PAGE_FLAG_ZERO_ALLOC) { 750 if (flags & TTM_PAGE_FLAG_ZERO_ALLOC) {
751 list_for_each_entry(p, &plist, lru) { 751 list_for_each_entry(p, &plist, lru) {
752 clear_page(page_address(p)); 752 if (PageHighMem(p))
753 clear_highpage(p);
754 else
755 clear_page(page_address(p));
753 } 756 }
754 } 757 }
755 758
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index bf8260133ea9..7d759a430294 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -308,9 +308,7 @@ int ttm_tt_swapin(struct ttm_tt *ttm)
308 if (unlikely(to_page == NULL)) 308 if (unlikely(to_page == NULL))
309 goto out_err; 309 goto out_err;
310 310
311 preempt_disable();
312 copy_highpage(to_page, from_page); 311 copy_highpage(to_page, from_page);
313 preempt_enable();
314 page_cache_release(from_page); 312 page_cache_release(from_page);
315 } 313 }
316 314
@@ -358,9 +356,7 @@ int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistent_swap_storage)
358 ret = PTR_ERR(to_page); 356 ret = PTR_ERR(to_page);
359 goto out_err; 357 goto out_err;
360 } 358 }
361 preempt_disable();
362 copy_highpage(to_page, from_page); 359 copy_highpage(to_page, from_page);
363 preempt_enable();
364 set_page_dirty(to_page); 360 set_page_dirty(to_page);
365 mark_page_accessed(to_page); 361 mark_page_accessed(to_page);
366 page_cache_release(to_page); 362 page_cache_release(to_page);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
index b07ca2e4d04b..7290811f89be 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
@@ -110,6 +110,8 @@ int vmw_get_cap_3d_ioctl(struct drm_device *dev, void *data,
110 memcpy_fromio(bounce, &fifo_mem[SVGA_FIFO_3D_CAPS], size); 110 memcpy_fromio(bounce, &fifo_mem[SVGA_FIFO_3D_CAPS], size);
111 111
112 ret = copy_to_user(buffer, bounce, size); 112 ret = copy_to_user(buffer, bounce, size);
113 if (ret)
114 ret = -EFAULT;
113 vfree(bounce); 115 vfree(bounce);
114 116
115 if (unlikely(ret != 0)) 117 if (unlikely(ret != 0))
diff --git a/drivers/hid/hid-microsoft.c b/drivers/hid/hid-microsoft.c
index f676c01bb471..6fcd466d0825 100644
--- a/drivers/hid/hid-microsoft.c
+++ b/drivers/hid/hid-microsoft.c
@@ -46,9 +46,9 @@ static __u8 *ms_report_fixup(struct hid_device *hdev, __u8 *rdesc,
46 rdesc[559] = 0x45; 46 rdesc[559] = 0x45;
47 } 47 }
48 /* the same as above (s/usage/physical/) */ 48 /* the same as above (s/usage/physical/) */
49 if ((quirks & MS_RDESC_3K) && *rsize == 106 && 49 if ((quirks & MS_RDESC_3K) && *rsize == 106 && rdesc[94] == 0x19 &&
50 !memcmp((char []){ 0x19, 0x00, 0x29, 0xff }, 50 rdesc[95] == 0x00 && rdesc[96] == 0x29 &&
51 &rdesc[94], 4)) { 51 rdesc[97] == 0xff) {
52 rdesc[94] = 0x35; 52 rdesc[94] = 0x35;
53 rdesc[96] = 0x45; 53 rdesc[96] = 0x45;
54 } 54 }
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index aa59a254be2c..c02bf208084f 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -39,6 +39,7 @@
39#define AT91_TWI_STOP 0x0002 /* Send a Stop Condition */ 39#define AT91_TWI_STOP 0x0002 /* Send a Stop Condition */
40#define AT91_TWI_MSEN 0x0004 /* Master Transfer Enable */ 40#define AT91_TWI_MSEN 0x0004 /* Master Transfer Enable */
41#define AT91_TWI_SVDIS 0x0020 /* Slave Transfer Disable */ 41#define AT91_TWI_SVDIS 0x0020 /* Slave Transfer Disable */
42#define AT91_TWI_QUICK 0x0040 /* SMBus quick command */
42#define AT91_TWI_SWRST 0x0080 /* Software Reset */ 43#define AT91_TWI_SWRST 0x0080 /* Software Reset */
43 44
44#define AT91_TWI_MMR 0x0004 /* Master Mode Register */ 45#define AT91_TWI_MMR 0x0004 /* Master Mode Register */
@@ -212,7 +213,11 @@ static int at91_do_twi_transfer(struct at91_twi_dev *dev)
212 213
213 INIT_COMPLETION(dev->cmd_complete); 214 INIT_COMPLETION(dev->cmd_complete);
214 dev->transfer_status = 0; 215 dev->transfer_status = 0;
215 if (dev->msg->flags & I2C_M_RD) { 216
217 if (!dev->buf_len) {
218 at91_twi_write(dev, AT91_TWI_CR, AT91_TWI_QUICK);
219 at91_twi_write(dev, AT91_TWI_IER, AT91_TWI_TXCOMP);
220 } else if (dev->msg->flags & I2C_M_RD) {
216 unsigned start_flags = AT91_TWI_START; 221 unsigned start_flags = AT91_TWI_START;
217 222
218 if (at91_twi_read(dev, AT91_TWI_SR) & AT91_TWI_RXRDY) { 223 if (at91_twi_read(dev, AT91_TWI_SR) & AT91_TWI_RXRDY) {
diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index 286ca1917820..0670da79ee5e 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -287,12 +287,14 @@ read_init_dma_fail:
287select_init_dma_fail: 287select_init_dma_fail:
288 dma_unmap_sg(i2c->dev, &i2c->sg_io[0], 1, DMA_TO_DEVICE); 288 dma_unmap_sg(i2c->dev, &i2c->sg_io[0], 1, DMA_TO_DEVICE);
289select_init_pio_fail: 289select_init_pio_fail:
290 dmaengine_terminate_all(i2c->dmach);
290 return -EINVAL; 291 return -EINVAL;
291 292
292/* Write failpath. */ 293/* Write failpath. */
293write_init_dma_fail: 294write_init_dma_fail:
294 dma_unmap_sg(i2c->dev, i2c->sg_io, 2, DMA_TO_DEVICE); 295 dma_unmap_sg(i2c->dev, i2c->sg_io, 2, DMA_TO_DEVICE);
295write_init_pio_fail: 296write_init_pio_fail:
297 dmaengine_terminate_all(i2c->dmach);
296 return -EINVAL; 298 return -EINVAL;
297} 299}
298 300
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index db31eaed6ea5..3525c9e62cb0 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -43,7 +43,6 @@
43#include <linux/slab.h> 43#include <linux/slab.h>
44#include <linux/i2c-omap.h> 44#include <linux/i2c-omap.h>
45#include <linux/pm_runtime.h> 45#include <linux/pm_runtime.h>
46#include <linux/pm_qos.h>
47 46
48/* I2C controller revisions */ 47/* I2C controller revisions */
49#define OMAP_I2C_OMAP1_REV_2 0x20 48#define OMAP_I2C_OMAP1_REV_2 0x20
@@ -187,8 +186,9 @@ struct omap_i2c_dev {
187 int reg_shift; /* bit shift for I2C register addresses */ 186 int reg_shift; /* bit shift for I2C register addresses */
188 struct completion cmd_complete; 187 struct completion cmd_complete;
189 struct resource *ioarea; 188 struct resource *ioarea;
190 u32 latency; /* maximum MPU wkup latency */ 189 u32 latency; /* maximum mpu wkup latency */
191 struct pm_qos_request pm_qos_request; 190 void (*set_mpu_wkup_lat)(struct device *dev,
191 long latency);
192 u32 speed; /* Speed of bus in kHz */ 192 u32 speed; /* Speed of bus in kHz */
193 u32 dtrev; /* extra revision from DT */ 193 u32 dtrev; /* extra revision from DT */
194 u32 flags; 194 u32 flags;
@@ -494,7 +494,9 @@ static void omap_i2c_resize_fifo(struct omap_i2c_dev *dev, u8 size, bool is_rx)
494 dev->b_hw = 1; /* Enable hardware fixes */ 494 dev->b_hw = 1; /* Enable hardware fixes */
495 495
496 /* calculate wakeup latency constraint for MPU */ 496 /* calculate wakeup latency constraint for MPU */
497 dev->latency = (1000000 * dev->threshold) / (1000 * dev->speed / 8); 497 if (dev->set_mpu_wkup_lat != NULL)
498 dev->latency = (1000000 * dev->threshold) /
499 (1000 * dev->speed / 8);
498} 500}
499 501
500/* 502/*
@@ -522,6 +524,9 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
522 dev->buf = msg->buf; 524 dev->buf = msg->buf;
523 dev->buf_len = msg->len; 525 dev->buf_len = msg->len;
524 526
527 /* make sure writes to dev->buf_len are ordered */
528 barrier();
529
525 omap_i2c_write_reg(dev, OMAP_I2C_CNT_REG, dev->buf_len); 530 omap_i2c_write_reg(dev, OMAP_I2C_CNT_REG, dev->buf_len);
526 531
527 /* Clear the FIFO Buffers */ 532 /* Clear the FIFO Buffers */
@@ -579,7 +584,6 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
579 */ 584 */
580 timeout = wait_for_completion_timeout(&dev->cmd_complete, 585 timeout = wait_for_completion_timeout(&dev->cmd_complete,
581 OMAP_I2C_TIMEOUT); 586 OMAP_I2C_TIMEOUT);
582 dev->buf_len = 0;
583 if (timeout == 0) { 587 if (timeout == 0) {
584 dev_err(dev->dev, "controller timed out\n"); 588 dev_err(dev->dev, "controller timed out\n");
585 omap_i2c_init(dev); 589 omap_i2c_init(dev);
@@ -629,16 +633,8 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
629 if (r < 0) 633 if (r < 0)
630 goto out; 634 goto out;
631 635
632 /* 636 if (dev->set_mpu_wkup_lat != NULL)
633 * When waiting for completion of a i2c transfer, we need to 637 dev->set_mpu_wkup_lat(dev->dev, dev->latency);
634 * set a wake up latency constraint for the MPU. This is to
635 * ensure quick enough wakeup from idle, when transfer
636 * completes.
637 */
638 if (dev->latency)
639 pm_qos_add_request(&dev->pm_qos_request,
640 PM_QOS_CPU_DMA_LATENCY,
641 dev->latency);
642 638
643 for (i = 0; i < num; i++) { 639 for (i = 0; i < num; i++) {
644 r = omap_i2c_xfer_msg(adap, &msgs[i], (i == (num - 1))); 640 r = omap_i2c_xfer_msg(adap, &msgs[i], (i == (num - 1)));
@@ -646,8 +642,8 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
646 break; 642 break;
647 } 643 }
648 644
649 if (dev->latency) 645 if (dev->set_mpu_wkup_lat != NULL)
650 pm_qos_remove_request(&dev->pm_qos_request); 646 dev->set_mpu_wkup_lat(dev->dev, -1);
651 647
652 if (r == 0) 648 if (r == 0)
653 r = num; 649 r = num;
@@ -1104,6 +1100,7 @@ omap_i2c_probe(struct platform_device *pdev)
1104 } else if (pdata != NULL) { 1100 } else if (pdata != NULL) {
1105 dev->speed = pdata->clkrate; 1101 dev->speed = pdata->clkrate;
1106 dev->flags = pdata->flags; 1102 dev->flags = pdata->flags;
1103 dev->set_mpu_wkup_lat = pdata->set_mpu_wkup_lat;
1107 dev->dtrev = pdata->rev; 1104 dev->dtrev = pdata->rev;
1108 } 1105 }
1109 1106
@@ -1159,8 +1156,9 @@ omap_i2c_probe(struct platform_device *pdev)
1159 dev->b_hw = 1; /* Enable hardware fixes */ 1156 dev->b_hw = 1; /* Enable hardware fixes */
1160 1157
1161 /* calculate wakeup latency constraint for MPU */ 1158 /* calculate wakeup latency constraint for MPU */
1162 dev->latency = (1000000 * dev->fifo_size) / 1159 if (dev->set_mpu_wkup_lat != NULL)
1163 (1000 * dev->speed / 8); 1160 dev->latency = (1000000 * dev->fifo_size) /
1161 (1000 * dev->speed / 8);
1164 } 1162 }
1165 1163
1166 /* reset ASAP, clearing any IRQs */ 1164 /* reset ASAP, clearing any IRQs */
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 3e0335f1fc60..9d902725bac9 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -806,6 +806,7 @@ static int s3c24xx_i2c_parse_dt_gpio(struct s3c24xx_i2c *i2c)
806 dev_err(i2c->dev, "invalid gpio[%d]: %d\n", idx, gpio); 806 dev_err(i2c->dev, "invalid gpio[%d]: %d\n", idx, gpio);
807 goto free_gpio; 807 goto free_gpio;
808 } 808 }
809 i2c->gpios[idx] = gpio;
809 810
810 ret = gpio_request(gpio, "i2c-bus"); 811 ret = gpio_request(gpio, "i2c-bus");
811 if (ret) { 812 if (ret) {
diff --git a/drivers/i2c/muxes/i2c-mux-pinctrl.c b/drivers/i2c/muxes/i2c-mux-pinctrl.c
index 5f097f309b9f..7fa5b24b16db 100644
--- a/drivers/i2c/muxes/i2c-mux-pinctrl.c
+++ b/drivers/i2c/muxes/i2c-mux-pinctrl.c
@@ -169,7 +169,7 @@ static int __devinit i2c_mux_pinctrl_probe(struct platform_device *pdev)
169 mux->busses = devm_kzalloc(&pdev->dev, 169 mux->busses = devm_kzalloc(&pdev->dev,
170 sizeof(mux->busses) * mux->pdata->bus_count, 170 sizeof(mux->busses) * mux->pdata->bus_count,
171 GFP_KERNEL); 171 GFP_KERNEL);
172 if (!mux->states) { 172 if (!mux->busses) {
173 dev_err(&pdev->dev, "Cannot allocate busses\n"); 173 dev_err(&pdev->dev, "Cannot allocate busses\n");
174 ret = -ENOMEM; 174 ret = -ENOMEM;
175 goto err; 175 goto err;
diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c
index c0ec7d42c3be..1abbc170d8b7 100644
--- a/drivers/input/input-mt.c
+++ b/drivers/input/input-mt.c
@@ -26,10 +26,14 @@ static void copy_abs(struct input_dev *dev, unsigned int dst, unsigned int src)
26 * input_mt_init_slots() - initialize MT input slots 26 * input_mt_init_slots() - initialize MT input slots
27 * @dev: input device supporting MT events and finger tracking 27 * @dev: input device supporting MT events and finger tracking
28 * @num_slots: number of slots used by the device 28 * @num_slots: number of slots used by the device
29 * @flags: mt tasks to handle in core
29 * 30 *
30 * This function allocates all necessary memory for MT slot handling 31 * This function allocates all necessary memory for MT slot handling
31 * in the input device, prepares the ABS_MT_SLOT and 32 * in the input device, prepares the ABS_MT_SLOT and
32 * ABS_MT_TRACKING_ID events for use and sets up appropriate buffers. 33 * ABS_MT_TRACKING_ID events for use and sets up appropriate buffers.
34 * Depending on the flags set, it also performs pointer emulation and
35 * frame synchronization.
36 *
33 * May be called repeatedly. Returns -EINVAL if attempting to 37 * May be called repeatedly. Returns -EINVAL if attempting to
34 * reinitialize with a different number of slots. 38 * reinitialize with a different number of slots.
35 */ 39 */
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 7c0f1ecfdd7a..104a7c3153c0 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -72,6 +72,16 @@ config INPUT_AD714X_SPI
72 To compile this driver as a module, choose M here: the 72 To compile this driver as a module, choose M here: the
73 module will be called ad714x-spi. 73 module will be called ad714x-spi.
74 74
75config INPUT_ARIZONA_HAPTICS
76 tristate "Arizona haptics support"
77 depends on MFD_ARIZONA && SND_SOC
78 select INPUT_FF_MEMLESS
79 help
80 Say Y to enable support for the haptics module in Arizona CODECs.
81
82 To compile this driver as a module, choose M here: the
83 module will be called arizona-haptics.
84
75config INPUT_BMA150 85config INPUT_BMA150
76 tristate "BMA150/SMB380 acceleration sensor support" 86 tristate "BMA150/SMB380 acceleration sensor support"
77 depends on I2C 87 depends on I2C
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 83fe6f5b77d1..5ea769eda999 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_INPUT_ADXL34X) += adxl34x.o
14obj-$(CONFIG_INPUT_ADXL34X_I2C) += adxl34x-i2c.o 14obj-$(CONFIG_INPUT_ADXL34X_I2C) += adxl34x-i2c.o
15obj-$(CONFIG_INPUT_ADXL34X_SPI) += adxl34x-spi.o 15obj-$(CONFIG_INPUT_ADXL34X_SPI) += adxl34x-spi.o
16obj-$(CONFIG_INPUT_APANEL) += apanel.o 16obj-$(CONFIG_INPUT_APANEL) += apanel.o
17obj-$(CONFIG_INPUT_ARIZONA_HAPTICS) += arizona-haptics.o
17obj-$(CONFIG_INPUT_ATI_REMOTE2) += ati_remote2.o 18obj-$(CONFIG_INPUT_ATI_REMOTE2) += ati_remote2.o
18obj-$(CONFIG_INPUT_ATLAS_BTNS) += atlas_btns.o 19obj-$(CONFIG_INPUT_ATLAS_BTNS) += atlas_btns.o
19obj-$(CONFIG_INPUT_BFIN_ROTARY) += bfin_rotary.o 20obj-$(CONFIG_INPUT_BFIN_ROTARY) += bfin_rotary.o
diff --git a/drivers/input/misc/arizona-haptics.c b/drivers/input/misc/arizona-haptics.c
new file mode 100644
index 000000000000..7a04f54ef961
--- /dev/null
+++ b/drivers/input/misc/arizona-haptics.c
@@ -0,0 +1,255 @@
1/*
2 * Arizona haptics driver
3 *
4 * Copyright 2012 Wolfson Microelectronics plc
5 *
6 * Author: Mark Brown <broonie@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/module.h>
14#include <linux/platform_device.h>
15#include <linux/input.h>
16#include <linux/slab.h>
17
18#include <sound/soc.h>
19#include <sound/soc-dapm.h>
20
21#include <linux/mfd/arizona/core.h>
22#include <linux/mfd/arizona/pdata.h>
23#include <linux/mfd/arizona/registers.h>
24
25struct arizona_haptics {
26 struct arizona *arizona;
27 struct input_dev *input_dev;
28 struct work_struct work;
29
30 struct mutex mutex;
31 u8 intensity;
32};
33
34static void arizona_haptics_work(struct work_struct *work)
35{
36 struct arizona_haptics *haptics = container_of(work,
37 struct arizona_haptics,
38 work);
39 struct arizona *arizona = haptics->arizona;
40 struct mutex *dapm_mutex = &arizona->dapm->card->dapm_mutex;
41 int ret;
42
43 if (!haptics->arizona->dapm) {
44 dev_err(arizona->dev, "No DAPM context\n");
45 return;
46 }
47
48 if (haptics->intensity) {
49 ret = regmap_update_bits(arizona->regmap,
50 ARIZONA_HAPTICS_PHASE_2_INTENSITY,
51 ARIZONA_PHASE2_INTENSITY_MASK,
52 haptics->intensity);
53 if (ret != 0) {
54 dev_err(arizona->dev, "Failed to set intensity: %d\n",
55 ret);
56 return;
57 }
58
59 /* This enable sequence will be a noop if already enabled */
60 ret = regmap_update_bits(arizona->regmap,
61 ARIZONA_HAPTICS_CONTROL_1,
62 ARIZONA_HAP_CTRL_MASK,
63 1 << ARIZONA_HAP_CTRL_SHIFT);
64 if (ret != 0) {
65 dev_err(arizona->dev, "Failed to start haptics: %d\n",
66 ret);
67 return;
68 }
69
70 mutex_lock_nested(dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
71
72 ret = snd_soc_dapm_enable_pin(arizona->dapm, "HAPTICS");
73 if (ret != 0) {
74 dev_err(arizona->dev, "Failed to start HAPTICS: %d\n",
75 ret);
76 mutex_unlock(dapm_mutex);
77 return;
78 }
79
80 ret = snd_soc_dapm_sync(arizona->dapm);
81 if (ret != 0) {
82 dev_err(arizona->dev, "Failed to sync DAPM: %d\n",
83 ret);
84 mutex_unlock(dapm_mutex);
85 return;
86 }
87
88 mutex_unlock(dapm_mutex);
89
90 } else {
91 /* This disable sequence will be a noop if already enabled */
92 mutex_lock_nested(dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
93
94 ret = snd_soc_dapm_disable_pin(arizona->dapm, "HAPTICS");
95 if (ret != 0) {
96 dev_err(arizona->dev, "Failed to disable HAPTICS: %d\n",
97 ret);
98 mutex_unlock(dapm_mutex);
99 return;
100 }
101
102 ret = snd_soc_dapm_sync(arizona->dapm);
103 if (ret != 0) {
104 dev_err(arizona->dev, "Failed to sync DAPM: %d\n",
105 ret);
106 mutex_unlock(dapm_mutex);
107 return;
108 }
109
110 mutex_unlock(dapm_mutex);
111
112 ret = regmap_update_bits(arizona->regmap,
113 ARIZONA_HAPTICS_CONTROL_1,
114 ARIZONA_HAP_CTRL_MASK,
115 1 << ARIZONA_HAP_CTRL_SHIFT);
116 if (ret != 0) {
117 dev_err(arizona->dev, "Failed to stop haptics: %d\n",
118 ret);
119 return;
120 }
121 }
122}
123
124static int arizona_haptics_play(struct input_dev *input, void *data,
125 struct ff_effect *effect)
126{
127 struct arizona_haptics *haptics = input_get_drvdata(input);
128 struct arizona *arizona = haptics->arizona;
129
130 if (!arizona->dapm) {
131 dev_err(arizona->dev, "No DAPM context\n");
132 return -EBUSY;
133 }
134
135 if (effect->u.rumble.strong_magnitude) {
136 /* Scale the magnitude into the range the device supports */
137 if (arizona->pdata.hap_act) {
138 haptics->intensity =
139 effect->u.rumble.strong_magnitude >> 9;
140 if (effect->direction < 0x8000)
141 haptics->intensity += 0x7f;
142 } else {
143 haptics->intensity =
144 effect->u.rumble.strong_magnitude >> 8;
145 }
146 } else {
147 haptics->intensity = 0;
148 }
149
150 schedule_work(&haptics->work);
151
152 return 0;
153}
154
155static void arizona_haptics_close(struct input_dev *input)
156{
157 struct arizona_haptics *haptics = input_get_drvdata(input);
158 struct mutex *dapm_mutex = &haptics->arizona->dapm->card->dapm_mutex;
159
160 cancel_work_sync(&haptics->work);
161
162 mutex_lock_nested(dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
163
164 if (haptics->arizona->dapm)
165 snd_soc_dapm_disable_pin(haptics->arizona->dapm, "HAPTICS");
166
167 mutex_unlock(dapm_mutex);
168}
169
170static int arizona_haptics_probe(struct platform_device *pdev)
171{
172 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
173 struct arizona_haptics *haptics;
174 int ret;
175
176 haptics = devm_kzalloc(&pdev->dev, sizeof(*haptics), GFP_KERNEL);
177 if (!haptics)
178 return -ENOMEM;
179
180 haptics->arizona = arizona;
181
182 ret = regmap_update_bits(arizona->regmap, ARIZONA_HAPTICS_CONTROL_1,
183 ARIZONA_HAP_ACT, arizona->pdata.hap_act);
184 if (ret != 0) {
185 dev_err(arizona->dev, "Failed to set haptics actuator: %d\n",
186 ret);
187 return ret;
188 }
189
190 INIT_WORK(&haptics->work, arizona_haptics_work);
191
192 haptics->input_dev = input_allocate_device();
193 if (haptics->input_dev == NULL) {
194 dev_err(arizona->dev, "Failed to allocate input device\n");
195 return -ENOMEM;
196 }
197
198 input_set_drvdata(haptics->input_dev, haptics);
199
200 haptics->input_dev->name = "arizona:haptics";
201 haptics->input_dev->dev.parent = pdev->dev.parent;
202 haptics->input_dev->close = arizona_haptics_close;
203 __set_bit(FF_RUMBLE, haptics->input_dev->ffbit);
204
205 ret = input_ff_create_memless(haptics->input_dev, NULL,
206 arizona_haptics_play);
207 if (ret < 0) {
208 dev_err(arizona->dev, "input_ff_create_memless() failed: %d\n",
209 ret);
210 goto err_ialloc;
211 }
212
213 ret = input_register_device(haptics->input_dev);
214 if (ret < 0) {
215 dev_err(arizona->dev, "couldn't register input device: %d\n",
216 ret);
217 goto err_iff;
218 }
219
220 platform_set_drvdata(pdev, haptics);
221
222 return 0;
223
224err_iff:
225 if (haptics->input_dev)
226 input_ff_destroy(haptics->input_dev);
227err_ialloc:
228 input_free_device(haptics->input_dev);
229
230 return ret;
231}
232
233static int arizona_haptics_remove(struct platform_device *pdev)
234{
235 struct arizona_haptics *haptics = platform_get_drvdata(pdev);
236
237 input_unregister_device(haptics->input_dev);
238
239 return 0;
240}
241
242static struct platform_driver arizona_haptics_driver = {
243 .probe = arizona_haptics_probe,
244 .remove = arizona_haptics_remove,
245 .driver = {
246 .name = "arizona-haptics",
247 .owner = THIS_MODULE,
248 },
249};
250module_platform_driver(arizona_haptics_driver);
251
252MODULE_ALIAS("platform:arizona-haptics");
253MODULE_DESCRIPTION("Arizona haptics driver");
254MODULE_LICENSE("GPL");
255MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
index 8f02e3d0e712..4c842c320c2e 100644
--- a/drivers/input/mousedev.c
+++ b/drivers/input/mousedev.c
@@ -12,8 +12,8 @@
12#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 12#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13 13
14#define MOUSEDEV_MINOR_BASE 32 14#define MOUSEDEV_MINOR_BASE 32
15#define MOUSEDEV_MINORS 32 15#define MOUSEDEV_MINORS 31
16#define MOUSEDEV_MIX 31 16#define MOUSEDEV_MIX 63
17 17
18#include <linux/sched.h> 18#include <linux/sched.h>
19#include <linux/slab.h> 19#include <linux/slab.h>
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index f02028ec3db6..78e5d9ab0ba7 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -955,7 +955,8 @@ static int ads7846_resume(struct device *dev)
955 955
956static SIMPLE_DEV_PM_OPS(ads7846_pm, ads7846_suspend, ads7846_resume); 956static SIMPLE_DEV_PM_OPS(ads7846_pm, ads7846_suspend, ads7846_resume);
957 957
958static int __devinit ads7846_setup_pendown(struct spi_device *spi, struct ads7846 *ts) 958static int __devinit ads7846_setup_pendown(struct spi_device *spi,
959 struct ads7846 *ts)
959{ 960{
960 struct ads7846_platform_data *pdata = spi->dev.platform_data; 961 struct ads7846_platform_data *pdata = spi->dev.platform_data;
961 int err; 962 int err;
@@ -981,6 +982,9 @@ static int __devinit ads7846_setup_pendown(struct spi_device *spi, struct ads784
981 982
982 ts->gpio_pendown = pdata->gpio_pendown; 983 ts->gpio_pendown = pdata->gpio_pendown;
983 984
985 if (pdata->gpio_pendown_debounce)
986 gpio_set_debounce(pdata->gpio_pendown,
987 pdata->gpio_pendown_debounce);
984 } else { 988 } else {
985 dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n"); 989 dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n");
986 return -EINVAL; 990 return -EINVAL;
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index d4a4cd445cab..0badfa48b32b 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -4108,7 +4108,7 @@ static void swap_pci_ref(struct pci_dev **from, struct pci_dev *to)
4108static int intel_iommu_add_device(struct device *dev) 4108static int intel_iommu_add_device(struct device *dev)
4109{ 4109{
4110 struct pci_dev *pdev = to_pci_dev(dev); 4110 struct pci_dev *pdev = to_pci_dev(dev);
4111 struct pci_dev *bridge, *dma_pdev; 4111 struct pci_dev *bridge, *dma_pdev = NULL;
4112 struct iommu_group *group; 4112 struct iommu_group *group;
4113 int ret; 4113 int ret;
4114 4114
@@ -4122,7 +4122,7 @@ static int intel_iommu_add_device(struct device *dev)
4122 dma_pdev = pci_get_domain_bus_and_slot( 4122 dma_pdev = pci_get_domain_bus_and_slot(
4123 pci_domain_nr(pdev->bus), 4123 pci_domain_nr(pdev->bus),
4124 bridge->subordinate->number, 0); 4124 bridge->subordinate->number, 0);
4125 else 4125 if (!dma_pdev)
4126 dma_pdev = pci_dev_get(bridge); 4126 dma_pdev = pci_dev_get(bridge);
4127 } else 4127 } else
4128 dma_pdev = pci_dev_get(pdev); 4128 dma_pdev = pci_dev_get(pdev);
diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
index a649f146d17b..c0f7a4266263 100644
--- a/drivers/iommu/tegra-smmu.c
+++ b/drivers/iommu/tegra-smmu.c
@@ -1054,6 +1054,7 @@ static int smmu_debugfs_stats_show(struct seq_file *s, void *v)
1054 stats[i], val, offs); 1054 stats[i], val, offs);
1055 } 1055 }
1056 seq_printf(s, "\n"); 1056 seq_printf(s, "\n");
1057 dput(dent);
1057 1058
1058 return 0; 1059 return 0;
1059} 1060}
diff --git a/drivers/irqchip/irq-bcm2835.c b/drivers/irqchip/irq-bcm2835.c
index dc670ccc6978..16c78f1c5ef2 100644
--- a/drivers/irqchip/irq-bcm2835.c
+++ b/drivers/irqchip/irq-bcm2835.c
@@ -168,7 +168,8 @@ static int __init armctrl_of_init(struct device_node *node,
168} 168}
169 169
170static struct of_device_id irq_of_match[] __initconst = { 170static struct of_device_id irq_of_match[] __initconst = {
171 { .compatible = "brcm,bcm2835-armctrl-ic", .data = armctrl_of_init } 171 { .compatible = "brcm,bcm2835-armctrl-ic", .data = armctrl_of_init },
172 { }
172}; 173};
173 174
174void __init bcm2835_init_irq(void) 175void __init bcm2835_init_irq(void)
diff --git a/drivers/leds/ledtrig-cpu.c b/drivers/leds/ledtrig-cpu.c
index b312056da14d..4239b3955ff0 100644
--- a/drivers/leds/ledtrig-cpu.c
+++ b/drivers/leds/ledtrig-cpu.c
@@ -33,8 +33,6 @@
33struct led_trigger_cpu { 33struct led_trigger_cpu {
34 char name[MAX_NAME_LEN]; 34 char name[MAX_NAME_LEN];
35 struct led_trigger *_trig; 35 struct led_trigger *_trig;
36 struct mutex lock;
37 int lock_is_inited;
38}; 36};
39 37
40static DEFINE_PER_CPU(struct led_trigger_cpu, cpu_trig); 38static DEFINE_PER_CPU(struct led_trigger_cpu, cpu_trig);
@@ -50,12 +48,6 @@ void ledtrig_cpu(enum cpu_led_event ledevt)
50{ 48{
51 struct led_trigger_cpu *trig = &__get_cpu_var(cpu_trig); 49 struct led_trigger_cpu *trig = &__get_cpu_var(cpu_trig);
52 50
53 /* mutex lock should be initialized before calling mutex_call() */
54 if (!trig->lock_is_inited)
55 return;
56
57 mutex_lock(&trig->lock);
58
59 /* Locate the correct CPU LED */ 51 /* Locate the correct CPU LED */
60 switch (ledevt) { 52 switch (ledevt) {
61 case CPU_LED_IDLE_END: 53 case CPU_LED_IDLE_END:
@@ -75,8 +67,6 @@ void ledtrig_cpu(enum cpu_led_event ledevt)
75 /* Will leave the LED as it is */ 67 /* Will leave the LED as it is */
76 break; 68 break;
77 } 69 }
78
79 mutex_unlock(&trig->lock);
80} 70}
81EXPORT_SYMBOL(ledtrig_cpu); 71EXPORT_SYMBOL(ledtrig_cpu);
82 72
@@ -117,14 +107,9 @@ static int __init ledtrig_cpu_init(void)
117 for_each_possible_cpu(cpu) { 107 for_each_possible_cpu(cpu) {
118 struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu); 108 struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu);
119 109
120 mutex_init(&trig->lock);
121
122 snprintf(trig->name, MAX_NAME_LEN, "cpu%d", cpu); 110 snprintf(trig->name, MAX_NAME_LEN, "cpu%d", cpu);
123 111
124 mutex_lock(&trig->lock);
125 led_trigger_register_simple(trig->name, &trig->_trig); 112 led_trigger_register_simple(trig->name, &trig->_trig);
126 trig->lock_is_inited = 1;
127 mutex_unlock(&trig->lock);
128 } 113 }
129 114
130 register_syscore_ops(&ledtrig_cpu_syscore_ops); 115 register_syscore_ops(&ledtrig_cpu_syscore_ops);
@@ -142,15 +127,9 @@ static void __exit ledtrig_cpu_exit(void)
142 for_each_possible_cpu(cpu) { 127 for_each_possible_cpu(cpu) {
143 struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu); 128 struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu);
144 129
145 mutex_lock(&trig->lock);
146
147 led_trigger_unregister_simple(trig->_trig); 130 led_trigger_unregister_simple(trig->_trig);
148 trig->_trig = NULL; 131 trig->_trig = NULL;
149 memset(trig->name, 0, MAX_NAME_LEN); 132 memset(trig->name, 0, MAX_NAME_LEN);
150 trig->lock_is_inited = 0;
151
152 mutex_unlock(&trig->lock);
153 mutex_destroy(&trig->lock);
154 } 133 }
155 134
156 unregister_syscore_ops(&ledtrig_cpu_syscore_ops); 135 unregister_syscore_ops(&ledtrig_cpu_syscore_ops);
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 02db9183ca01..77e6eff41cae 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -740,8 +740,14 @@ static void rq_completed(struct mapped_device *md, int rw, int run_queue)
740 if (!md_in_flight(md)) 740 if (!md_in_flight(md))
741 wake_up(&md->wait); 741 wake_up(&md->wait);
742 742
743 /*
744 * Run this off this callpath, as drivers could invoke end_io while
745 * inside their request_fn (and holding the queue lock). Calling
746 * back into ->request_fn() could deadlock attempting to grab the
747 * queue lock again.
748 */
743 if (run_queue) 749 if (run_queue)
744 blk_run_queue(md->queue); 750 blk_run_queue_async(md->queue);
745 751
746 /* 752 /*
747 * dm_put() must be at the end of this function. See the comment above 753 * dm_put() must be at the end of this function. See the comment above
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 9ab768acfb62..61200717687b 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1817,10 +1817,10 @@ retry:
1817 memset(bbp, 0xff, PAGE_SIZE); 1817 memset(bbp, 0xff, PAGE_SIZE);
1818 1818
1819 for (i = 0 ; i < bb->count ; i++) { 1819 for (i = 0 ; i < bb->count ; i++) {
1820 u64 internal_bb = *p++; 1820 u64 internal_bb = p[i];
1821 u64 store_bb = ((BB_OFFSET(internal_bb) << 10) 1821 u64 store_bb = ((BB_OFFSET(internal_bb) << 10)
1822 | BB_LEN(internal_bb)); 1822 | BB_LEN(internal_bb));
1823 *bbp++ = cpu_to_le64(store_bb); 1823 bbp[i] = cpu_to_le64(store_bb);
1824 } 1824 }
1825 bb->changed = 0; 1825 bb->changed = 0;
1826 if (read_seqretry(&bb->lock, seq)) 1826 if (read_seqretry(&bb->lock, seq))
@@ -5294,7 +5294,7 @@ void md_stop_writes(struct mddev *mddev)
5294} 5294}
5295EXPORT_SYMBOL_GPL(md_stop_writes); 5295EXPORT_SYMBOL_GPL(md_stop_writes);
5296 5296
5297void md_stop(struct mddev *mddev) 5297static void __md_stop(struct mddev *mddev)
5298{ 5298{
5299 mddev->ready = 0; 5299 mddev->ready = 0;
5300 mddev->pers->stop(mddev); 5300 mddev->pers->stop(mddev);
@@ -5304,6 +5304,18 @@ void md_stop(struct mddev *mddev)
5304 mddev->pers = NULL; 5304 mddev->pers = NULL;
5305 clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery); 5305 clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery);
5306} 5306}
5307
5308void md_stop(struct mddev *mddev)
5309{
5310 /* stop the array and free an attached data structures.
5311 * This is called from dm-raid
5312 */
5313 __md_stop(mddev);
5314 bitmap_destroy(mddev);
5315 if (mddev->bio_set)
5316 bioset_free(mddev->bio_set);
5317}
5318
5307EXPORT_SYMBOL_GPL(md_stop); 5319EXPORT_SYMBOL_GPL(md_stop);
5308 5320
5309static int md_set_readonly(struct mddev *mddev, struct block_device *bdev) 5321static int md_set_readonly(struct mddev *mddev, struct block_device *bdev)
@@ -5364,7 +5376,7 @@ static int do_md_stop(struct mddev * mddev, int mode,
5364 set_disk_ro(disk, 0); 5376 set_disk_ro(disk, 0);
5365 5377
5366 __md_stop_writes(mddev); 5378 __md_stop_writes(mddev);
5367 md_stop(mddev); 5379 __md_stop(mddev);
5368 mddev->queue->merge_bvec_fn = NULL; 5380 mddev->queue->merge_bvec_fn = NULL;
5369 mddev->queue->backing_dev_info.congested_fn = NULL; 5381 mddev->queue->backing_dev_info.congested_fn = NULL;
5370 5382
@@ -7936,9 +7948,9 @@ int md_is_badblock(struct badblocks *bb, sector_t s, int sectors,
7936 sector_t *first_bad, int *bad_sectors) 7948 sector_t *first_bad, int *bad_sectors)
7937{ 7949{
7938 int hi; 7950 int hi;
7939 int lo = 0; 7951 int lo;
7940 u64 *p = bb->page; 7952 u64 *p = bb->page;
7941 int rv = 0; 7953 int rv;
7942 sector_t target = s + sectors; 7954 sector_t target = s + sectors;
7943 unsigned seq; 7955 unsigned seq;
7944 7956
@@ -7953,7 +7965,8 @@ int md_is_badblock(struct badblocks *bb, sector_t s, int sectors,
7953 7965
7954retry: 7966retry:
7955 seq = read_seqbegin(&bb->lock); 7967 seq = read_seqbegin(&bb->lock);
7956 7968 lo = 0;
7969 rv = 0;
7957 hi = bb->count; 7970 hi = bb->count;
7958 7971
7959 /* Binary search between lo and hi for 'target' 7972 /* Binary search between lo and hi for 'target'
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index d1295aff4173..0d5d0ff2c0f7 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -499,7 +499,7 @@ static void raid10_end_write_request(struct bio *bio, int error)
499 */ 499 */
500 one_write_done(r10_bio); 500 one_write_done(r10_bio);
501 if (dec_rdev) 501 if (dec_rdev)
502 rdev_dec_pending(conf->mirrors[dev].rdev, conf->mddev); 502 rdev_dec_pending(rdev, conf->mddev);
503} 503}
504 504
505/* 505/*
@@ -1334,18 +1334,21 @@ retry_write:
1334 blocked_rdev = rrdev; 1334 blocked_rdev = rrdev;
1335 break; 1335 break;
1336 } 1336 }
1337 if (rdev && (test_bit(Faulty, &rdev->flags)
1338 || test_bit(Unmerged, &rdev->flags)))
1339 rdev = NULL;
1337 if (rrdev && (test_bit(Faulty, &rrdev->flags) 1340 if (rrdev && (test_bit(Faulty, &rrdev->flags)
1338 || test_bit(Unmerged, &rrdev->flags))) 1341 || test_bit(Unmerged, &rrdev->flags)))
1339 rrdev = NULL; 1342 rrdev = NULL;
1340 1343
1341 r10_bio->devs[i].bio = NULL; 1344 r10_bio->devs[i].bio = NULL;
1342 r10_bio->devs[i].repl_bio = NULL; 1345 r10_bio->devs[i].repl_bio = NULL;
1343 if (!rdev || test_bit(Faulty, &rdev->flags) || 1346
1344 test_bit(Unmerged, &rdev->flags)) { 1347 if (!rdev && !rrdev) {
1345 set_bit(R10BIO_Degraded, &r10_bio->state); 1348 set_bit(R10BIO_Degraded, &r10_bio->state);
1346 continue; 1349 continue;
1347 } 1350 }
1348 if (test_bit(WriteErrorSeen, &rdev->flags)) { 1351 if (rdev && test_bit(WriteErrorSeen, &rdev->flags)) {
1349 sector_t first_bad; 1352 sector_t first_bad;
1350 sector_t dev_sector = r10_bio->devs[i].addr; 1353 sector_t dev_sector = r10_bio->devs[i].addr;
1351 int bad_sectors; 1354 int bad_sectors;
@@ -1387,8 +1390,10 @@ retry_write:
1387 max_sectors = good_sectors; 1390 max_sectors = good_sectors;
1388 } 1391 }
1389 } 1392 }
1390 r10_bio->devs[i].bio = bio; 1393 if (rdev) {
1391 atomic_inc(&rdev->nr_pending); 1394 r10_bio->devs[i].bio = bio;
1395 atomic_inc(&rdev->nr_pending);
1396 }
1392 if (rrdev) { 1397 if (rrdev) {
1393 r10_bio->devs[i].repl_bio = bio; 1398 r10_bio->devs[i].repl_bio = bio;
1394 atomic_inc(&rrdev->nr_pending); 1399 atomic_inc(&rrdev->nr_pending);
@@ -1444,69 +1449,71 @@ retry_write:
1444 for (i = 0; i < conf->copies; i++) { 1449 for (i = 0; i < conf->copies; i++) {
1445 struct bio *mbio; 1450 struct bio *mbio;
1446 int d = r10_bio->devs[i].devnum; 1451 int d = r10_bio->devs[i].devnum;
1447 if (!r10_bio->devs[i].bio) 1452 if (r10_bio->devs[i].bio) {
1448 continue; 1453 struct md_rdev *rdev = conf->mirrors[d].rdev;
1454 mbio = bio_clone_mddev(bio, GFP_NOIO, mddev);
1455 md_trim_bio(mbio, r10_bio->sector - bio->bi_sector,
1456 max_sectors);
1457 r10_bio->devs[i].bio = mbio;
1458
1459 mbio->bi_sector = (r10_bio->devs[i].addr+
1460 choose_data_offset(r10_bio,
1461 rdev));
1462 mbio->bi_bdev = rdev->bdev;
1463 mbio->bi_end_io = raid10_end_write_request;
1464 mbio->bi_rw = WRITE | do_sync | do_fua | do_discard;
1465 mbio->bi_private = r10_bio;
1449 1466
1450 mbio = bio_clone_mddev(bio, GFP_NOIO, mddev); 1467 atomic_inc(&r10_bio->remaining);
1451 md_trim_bio(mbio, r10_bio->sector - bio->bi_sector,
1452 max_sectors);
1453 r10_bio->devs[i].bio = mbio;
1454 1468
1455 mbio->bi_sector = (r10_bio->devs[i].addr+ 1469 cb = blk_check_plugged(raid10_unplug, mddev,
1456 choose_data_offset(r10_bio, 1470 sizeof(*plug));
1457 conf->mirrors[d].rdev)); 1471 if (cb)
1458 mbio->bi_bdev = conf->mirrors[d].rdev->bdev; 1472 plug = container_of(cb, struct raid10_plug_cb,
1459 mbio->bi_end_io = raid10_end_write_request; 1473 cb);
1460 mbio->bi_rw = WRITE | do_sync | do_fua | do_discard; 1474 else
1461 mbio->bi_private = r10_bio; 1475 plug = NULL;
1476 spin_lock_irqsave(&conf->device_lock, flags);
1477 if (plug) {
1478 bio_list_add(&plug->pending, mbio);
1479 plug->pending_cnt++;
1480 } else {
1481 bio_list_add(&conf->pending_bio_list, mbio);
1482 conf->pending_count++;
1483 }
1484 spin_unlock_irqrestore(&conf->device_lock, flags);
1485 if (!plug)
1486 md_wakeup_thread(mddev->thread);
1487 }
1462 1488
1463 atomic_inc(&r10_bio->remaining); 1489 if (r10_bio->devs[i].repl_bio) {
1490 struct md_rdev *rdev = conf->mirrors[d].replacement;
1491 if (rdev == NULL) {
1492 /* Replacement just got moved to main 'rdev' */
1493 smp_mb();
1494 rdev = conf->mirrors[d].rdev;
1495 }
1496 mbio = bio_clone_mddev(bio, GFP_NOIO, mddev);
1497 md_trim_bio(mbio, r10_bio->sector - bio->bi_sector,
1498 max_sectors);
1499 r10_bio->devs[i].repl_bio = mbio;
1500
1501 mbio->bi_sector = (r10_bio->devs[i].addr +
1502 choose_data_offset(
1503 r10_bio, rdev));
1504 mbio->bi_bdev = rdev->bdev;
1505 mbio->bi_end_io = raid10_end_write_request;
1506 mbio->bi_rw = WRITE | do_sync | do_fua | do_discard;
1507 mbio->bi_private = r10_bio;
1464 1508
1465 cb = blk_check_plugged(raid10_unplug, mddev, sizeof(*plug)); 1509 atomic_inc(&r10_bio->remaining);
1466 if (cb) 1510 spin_lock_irqsave(&conf->device_lock, flags);
1467 plug = container_of(cb, struct raid10_plug_cb, cb);
1468 else
1469 plug = NULL;
1470 spin_lock_irqsave(&conf->device_lock, flags);
1471 if (plug) {
1472 bio_list_add(&plug->pending, mbio);
1473 plug->pending_cnt++;
1474 } else {
1475 bio_list_add(&conf->pending_bio_list, mbio); 1511 bio_list_add(&conf->pending_bio_list, mbio);
1476 conf->pending_count++; 1512 conf->pending_count++;
1513 spin_unlock_irqrestore(&conf->device_lock, flags);
1514 if (!mddev_check_plugged(mddev))
1515 md_wakeup_thread(mddev->thread);
1477 } 1516 }
1478 spin_unlock_irqrestore(&conf->device_lock, flags);
1479 if (!plug)
1480 md_wakeup_thread(mddev->thread);
1481
1482 if (!r10_bio->devs[i].repl_bio)
1483 continue;
1484
1485 mbio = bio_clone_mddev(bio, GFP_NOIO, mddev);
1486 md_trim_bio(mbio, r10_bio->sector - bio->bi_sector,
1487 max_sectors);
1488 r10_bio->devs[i].repl_bio = mbio;
1489
1490 /* We are actively writing to the original device
1491 * so it cannot disappear, so the replacement cannot
1492 * become NULL here
1493 */
1494 mbio->bi_sector = (r10_bio->devs[i].addr +
1495 choose_data_offset(
1496 r10_bio,
1497 conf->mirrors[d].replacement));
1498 mbio->bi_bdev = conf->mirrors[d].replacement->bdev;
1499 mbio->bi_end_io = raid10_end_write_request;
1500 mbio->bi_rw = WRITE | do_sync | do_fua | do_discard;
1501 mbio->bi_private = r10_bio;
1502
1503 atomic_inc(&r10_bio->remaining);
1504 spin_lock_irqsave(&conf->device_lock, flags);
1505 bio_list_add(&conf->pending_bio_list, mbio);
1506 conf->pending_count++;
1507 spin_unlock_irqrestore(&conf->device_lock, flags);
1508 if (!mddev_check_plugged(mddev))
1509 md_wakeup_thread(mddev->thread);
1510 } 1517 }
1511 1518
1512 /* Don't remove the bias on 'remaining' (one_write_done) until 1519 /* Don't remove the bias on 'remaining' (one_write_done) until
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index c5439dce0295..a4502686e7a8 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -2774,10 +2774,12 @@ static void handle_stripe_clean_event(struct r5conf *conf,
2774 dev = &sh->dev[i]; 2774 dev = &sh->dev[i];
2775 if (!test_bit(R5_LOCKED, &dev->flags) && 2775 if (!test_bit(R5_LOCKED, &dev->flags) &&
2776 (test_bit(R5_UPTODATE, &dev->flags) || 2776 (test_bit(R5_UPTODATE, &dev->flags) ||
2777 test_and_clear_bit(R5_Discard, &dev->flags))) { 2777 test_bit(R5_Discard, &dev->flags))) {
2778 /* We can return any write requests */ 2778 /* We can return any write requests */
2779 struct bio *wbi, *wbi2; 2779 struct bio *wbi, *wbi2;
2780 pr_debug("Return write for disc %d\n", i); 2780 pr_debug("Return write for disc %d\n", i);
2781 if (test_and_clear_bit(R5_Discard, &dev->flags))
2782 clear_bit(R5_UPTODATE, &dev->flags);
2781 wbi = dev->written; 2783 wbi = dev->written;
2782 dev->written = NULL; 2784 dev->written = NULL;
2783 while (wbi && wbi->bi_sector < 2785 while (wbi && wbi->bi_sector <
@@ -2795,7 +2797,8 @@ static void handle_stripe_clean_event(struct r5conf *conf,
2795 !test_bit(STRIPE_DEGRADED, &sh->state), 2797 !test_bit(STRIPE_DEGRADED, &sh->state),
2796 0); 2798 0);
2797 } 2799 }
2798 } 2800 } else if (test_bit(R5_Discard, &sh->dev[i].flags))
2801 clear_bit(R5_Discard, &sh->dev[i].flags);
2799 2802
2800 if (test_and_clear_bit(STRIPE_FULL_WRITE, &sh->state)) 2803 if (test_and_clear_bit(STRIPE_FULL_WRITE, &sh->state))
2801 if (atomic_dec_and_test(&conf->pending_full_writes)) 2804 if (atomic_dec_and_test(&conf->pending_full_writes))
@@ -3490,40 +3493,6 @@ static void handle_stripe(struct stripe_head *sh)
3490 handle_failed_sync(conf, sh, &s); 3493 handle_failed_sync(conf, sh, &s);
3491 } 3494 }
3492 3495
3493 /*
3494 * might be able to return some write requests if the parity blocks
3495 * are safe, or on a failed drive
3496 */
3497 pdev = &sh->dev[sh->pd_idx];
3498 s.p_failed = (s.failed >= 1 && s.failed_num[0] == sh->pd_idx)
3499 || (s.failed >= 2 && s.failed_num[1] == sh->pd_idx);
3500 qdev = &sh->dev[sh->qd_idx];
3501 s.q_failed = (s.failed >= 1 && s.failed_num[0] == sh->qd_idx)
3502 || (s.failed >= 2 && s.failed_num[1] == sh->qd_idx)
3503 || conf->level < 6;
3504
3505 if (s.written &&
3506 (s.p_failed || ((test_bit(R5_Insync, &pdev->flags)
3507 && !test_bit(R5_LOCKED, &pdev->flags)
3508 && (test_bit(R5_UPTODATE, &pdev->flags) ||
3509 test_bit(R5_Discard, &pdev->flags))))) &&
3510 (s.q_failed || ((test_bit(R5_Insync, &qdev->flags)
3511 && !test_bit(R5_LOCKED, &qdev->flags)
3512 && (test_bit(R5_UPTODATE, &qdev->flags) ||
3513 test_bit(R5_Discard, &qdev->flags))))))
3514 handle_stripe_clean_event(conf, sh, disks, &s.return_bi);
3515
3516 /* Now we might consider reading some blocks, either to check/generate
3517 * parity, or to satisfy requests
3518 * or to load a block that is being partially written.
3519 */
3520 if (s.to_read || s.non_overwrite
3521 || (conf->level == 6 && s.to_write && s.failed)
3522 || (s.syncing && (s.uptodate + s.compute < disks))
3523 || s.replacing
3524 || s.expanding)
3525 handle_stripe_fill(sh, &s, disks);
3526
3527 /* Now we check to see if any write operations have recently 3496 /* Now we check to see if any write operations have recently
3528 * completed 3497 * completed
3529 */ 3498 */
@@ -3561,6 +3530,40 @@ static void handle_stripe(struct stripe_head *sh)
3561 s.dec_preread_active = 1; 3530 s.dec_preread_active = 1;
3562 } 3531 }
3563 3532
3533 /*
3534 * might be able to return some write requests if the parity blocks
3535 * are safe, or on a failed drive
3536 */
3537 pdev = &sh->dev[sh->pd_idx];
3538 s.p_failed = (s.failed >= 1 && s.failed_num[0] == sh->pd_idx)
3539 || (s.failed >= 2 && s.failed_num[1] == sh->pd_idx);
3540 qdev = &sh->dev[sh->qd_idx];
3541 s.q_failed = (s.failed >= 1 && s.failed_num[0] == sh->qd_idx)
3542 || (s.failed >= 2 && s.failed_num[1] == sh->qd_idx)
3543 || conf->level < 6;
3544
3545 if (s.written &&
3546 (s.p_failed || ((test_bit(R5_Insync, &pdev->flags)
3547 && !test_bit(R5_LOCKED, &pdev->flags)
3548 && (test_bit(R5_UPTODATE, &pdev->flags) ||
3549 test_bit(R5_Discard, &pdev->flags))))) &&
3550 (s.q_failed || ((test_bit(R5_Insync, &qdev->flags)
3551 && !test_bit(R5_LOCKED, &qdev->flags)
3552 && (test_bit(R5_UPTODATE, &qdev->flags) ||
3553 test_bit(R5_Discard, &qdev->flags))))))
3554 handle_stripe_clean_event(conf, sh, disks, &s.return_bi);
3555
3556 /* Now we might consider reading some blocks, either to check/generate
3557 * parity, or to satisfy requests
3558 * or to load a block that is being partially written.
3559 */
3560 if (s.to_read || s.non_overwrite
3561 || (conf->level == 6 && s.to_write && s.failed)
3562 || (s.syncing && (s.uptodate + s.compute < disks))
3563 || s.replacing
3564 || s.expanding)
3565 handle_stripe_fill(sh, &s, disks);
3566
3564 /* Now to consider new write requests and what else, if anything 3567 /* Now to consider new write requests and what else, if anything
3565 * should be read. We do not handle new writes when: 3568 * should be read. We do not handle new writes when:
3566 * 1/ A 'write' operation (copy+xor) is already in flight. 3569 * 1/ A 'write' operation (copy+xor) is already in flight.
@@ -5529,6 +5532,10 @@ static int run(struct mddev *mddev)
5529 * discard data disk but write parity disk 5532 * discard data disk but write parity disk
5530 */ 5533 */
5531 stripe = stripe * PAGE_SIZE; 5534 stripe = stripe * PAGE_SIZE;
5535 /* Round up to power of 2, as discard handling
5536 * currently assumes that */
5537 while ((stripe-1) & stripe)
5538 stripe = (stripe | (stripe-1)) + 1;
5532 mddev->queue->limits.discard_alignment = stripe; 5539 mddev->queue->limits.discard_alignment = stripe;
5533 mddev->queue->limits.discard_granularity = stripe; 5540 mddev->queue->limits.discard_granularity = stripe;
5534 /* 5541 /*
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index 1b48f2094806..75619711a9e7 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -272,6 +272,7 @@ static struct mfd_cell early_devs[] = {
272static struct mfd_cell wm5102_devs[] = { 272static struct mfd_cell wm5102_devs[] = {
273 { .name = "arizona-extcon" }, 273 { .name = "arizona-extcon" },
274 { .name = "arizona-gpio" }, 274 { .name = "arizona-gpio" },
275 { .name = "arizona-haptics" },
275 { .name = "arizona-micsupp" }, 276 { .name = "arizona-micsupp" },
276 { .name = "arizona-pwm" }, 277 { .name = "arizona-pwm" },
277 { .name = "wm5102-codec" }, 278 { .name = "wm5102-codec" },
@@ -280,6 +281,7 @@ static struct mfd_cell wm5102_devs[] = {
280static struct mfd_cell wm5110_devs[] = { 281static struct mfd_cell wm5110_devs[] = {
281 { .name = "arizona-extcon" }, 282 { .name = "arizona-extcon" },
282 { .name = "arizona-gpio" }, 283 { .name = "arizona-gpio" },
284 { .name = "arizona-haptics" },
283 { .name = "arizona-micsupp" }, 285 { .name = "arizona-micsupp" },
284 { .name = "arizona-pwm" }, 286 { .name = "arizona-pwm" },
285 { .name = "wm5110-codec" }, 287 { .name = "wm5110-codec" },
diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c
index 5bb187781074..d07a9eda7fff 100644
--- a/drivers/misc/atmel-ssc.c
+++ b/drivers/misc/atmel-ssc.c
@@ -18,6 +18,8 @@
18#include <linux/slab.h> 18#include <linux/slab.h>
19#include <linux/module.h> 19#include <linux/module.h>
20 20
21#include <linux/of.h>
22
21/* Serialize access to ssc_list and user count */ 23/* Serialize access to ssc_list and user count */
22static DEFINE_SPINLOCK(user_lock); 24static DEFINE_SPINLOCK(user_lock);
23static LIST_HEAD(ssc_list); 25static LIST_HEAD(ssc_list);
@@ -29,7 +31,13 @@ struct ssc_device *ssc_request(unsigned int ssc_num)
29 31
30 spin_lock(&user_lock); 32 spin_lock(&user_lock);
31 list_for_each_entry(ssc, &ssc_list, list) { 33 list_for_each_entry(ssc, &ssc_list, list) {
32 if (ssc->pdev->id == ssc_num) { 34 if (ssc->pdev->dev.of_node) {
35 if (of_alias_get_id(ssc->pdev->dev.of_node, "ssc")
36 == ssc_num) {
37 ssc_valid = 1;
38 break;
39 }
40 } else if (ssc->pdev->id == ssc_num) {
33 ssc_valid = 1; 41 ssc_valid = 1;
34 break; 42 break;
35 } 43 }
@@ -68,39 +76,93 @@ void ssc_free(struct ssc_device *ssc)
68} 76}
69EXPORT_SYMBOL(ssc_free); 77EXPORT_SYMBOL(ssc_free);
70 78
71static int __init ssc_probe(struct platform_device *pdev) 79static struct atmel_ssc_platform_data at91rm9200_config = {
80 .use_dma = 0,
81};
82
83static struct atmel_ssc_platform_data at91sam9g45_config = {
84 .use_dma = 1,
85};
86
87static const struct platform_device_id atmel_ssc_devtypes[] = {
88 {
89 .name = "at91rm9200_ssc",
90 .driver_data = (unsigned long) &at91rm9200_config,
91 }, {
92 .name = "at91sam9g45_ssc",
93 .driver_data = (unsigned long) &at91sam9g45_config,
94 }, {
95 /* sentinel */
96 }
97};
98
99#ifdef CONFIG_OF
100static const struct of_device_id atmel_ssc_dt_ids[] = {
101 {
102 .compatible = "atmel,at91rm9200-ssc",
103 .data = &at91rm9200_config,
104 }, {
105 .compatible = "atmel,at91sam9g45-ssc",
106 .data = &at91sam9g45_config,
107 }, {
108 /* sentinel */
109 }
110};
111MODULE_DEVICE_TABLE(of, atmel_ssc_dt_ids);
112#endif
113
114static inline const struct atmel_ssc_platform_data * __init
115 atmel_ssc_get_driver_data(struct platform_device *pdev)
116{
117 if (pdev->dev.of_node) {
118 const struct of_device_id *match;
119 match = of_match_node(atmel_ssc_dt_ids, pdev->dev.of_node);
120 if (match == NULL)
121 return NULL;
122 return match->data;
123 }
124
125 return (struct atmel_ssc_platform_data *)
126 platform_get_device_id(pdev)->driver_data;
127}
128
129static int ssc_probe(struct platform_device *pdev)
72{ 130{
73 int retval = 0;
74 struct resource *regs; 131 struct resource *regs;
75 struct ssc_device *ssc; 132 struct ssc_device *ssc;
133 const struct atmel_ssc_platform_data *plat_dat;
76 134
77 ssc = kzalloc(sizeof(struct ssc_device), GFP_KERNEL); 135 ssc = devm_kzalloc(&pdev->dev, sizeof(struct ssc_device), GFP_KERNEL);
78 if (!ssc) { 136 if (!ssc) {
79 dev_dbg(&pdev->dev, "out of memory\n"); 137 dev_dbg(&pdev->dev, "out of memory\n");
80 retval = -ENOMEM; 138 return -ENOMEM;
81 goto out;
82 } 139 }
83 140
141 ssc->pdev = pdev;
142
143 plat_dat = atmel_ssc_get_driver_data(pdev);
144 if (!plat_dat)
145 return -ENODEV;
146 ssc->pdata = (struct atmel_ssc_platform_data *)plat_dat;
147
84 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); 148 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
85 if (!regs) { 149 if (!regs) {
86 dev_dbg(&pdev->dev, "no mmio resource defined\n"); 150 dev_dbg(&pdev->dev, "no mmio resource defined\n");
87 retval = -ENXIO; 151 return -ENXIO;
88 goto out_free;
89 } 152 }
90 153
91 ssc->clk = clk_get(&pdev->dev, "pclk"); 154 ssc->regs = devm_request_and_ioremap(&pdev->dev, regs);
92 if (IS_ERR(ssc->clk)) {
93 dev_dbg(&pdev->dev, "no pclk clock defined\n");
94 retval = -ENXIO;
95 goto out_free;
96 }
97
98 ssc->pdev = pdev;
99 ssc->regs = ioremap(regs->start, resource_size(regs));
100 if (!ssc->regs) { 155 if (!ssc->regs) {
101 dev_dbg(&pdev->dev, "ioremap failed\n"); 156 dev_dbg(&pdev->dev, "ioremap failed\n");
102 retval = -EINVAL; 157 return -EINVAL;
103 goto out_clk; 158 }
159
160 ssc->phybase = regs->start;
161
162 ssc->clk = devm_clk_get(&pdev->dev, "pclk");
163 if (IS_ERR(ssc->clk)) {
164 dev_dbg(&pdev->dev, "no pclk clock defined\n");
165 return -ENXIO;
104 } 166 }
105 167
106 /* disable all interrupts */ 168 /* disable all interrupts */
@@ -112,8 +174,7 @@ static int __init ssc_probe(struct platform_device *pdev)
112 ssc->irq = platform_get_irq(pdev, 0); 174 ssc->irq = platform_get_irq(pdev, 0);
113 if (!ssc->irq) { 175 if (!ssc->irq) {
114 dev_dbg(&pdev->dev, "could not get irq\n"); 176 dev_dbg(&pdev->dev, "could not get irq\n");
115 retval = -ENXIO; 177 return -ENXIO;
116 goto out_unmap;
117 } 178 }
118 179
119 spin_lock(&user_lock); 180 spin_lock(&user_lock);
@@ -125,16 +186,7 @@ static int __init ssc_probe(struct platform_device *pdev)
125 dev_info(&pdev->dev, "Atmel SSC device at 0x%p (irq %d)\n", 186 dev_info(&pdev->dev, "Atmel SSC device at 0x%p (irq %d)\n",
126 ssc->regs, ssc->irq); 187 ssc->regs, ssc->irq);
127 188
128 goto out; 189 return 0;
129
130out_unmap:
131 iounmap(ssc->regs);
132out_clk:
133 clk_put(ssc->clk);
134out_free:
135 kfree(ssc);
136out:
137 return retval;
138} 190}
139 191
140static int __devexit ssc_remove(struct platform_device *pdev) 192static int __devexit ssc_remove(struct platform_device *pdev)
@@ -142,34 +194,23 @@ static int __devexit ssc_remove(struct platform_device *pdev)
142 struct ssc_device *ssc = platform_get_drvdata(pdev); 194 struct ssc_device *ssc = platform_get_drvdata(pdev);
143 195
144 spin_lock(&user_lock); 196 spin_lock(&user_lock);
145 iounmap(ssc->regs);
146 clk_put(ssc->clk);
147 list_del(&ssc->list); 197 list_del(&ssc->list);
148 kfree(ssc);
149 spin_unlock(&user_lock); 198 spin_unlock(&user_lock);
150 199
151 return 0; 200 return 0;
152} 201}
153 202
154static struct platform_driver ssc_driver = { 203static struct platform_driver ssc_driver = {
155 .remove = __devexit_p(ssc_remove),
156 .driver = { 204 .driver = {
157 .name = "ssc", 205 .name = "ssc",
158 .owner = THIS_MODULE, 206 .owner = THIS_MODULE,
207 .of_match_table = of_match_ptr(atmel_ssc_dt_ids),
159 }, 208 },
209 .id_table = atmel_ssc_devtypes,
210 .probe = ssc_probe,
211 .remove = __devexit_p(ssc_remove),
160}; 212};
161 213module_platform_driver(ssc_driver);
162static int __init ssc_init(void)
163{
164 return platform_driver_probe(&ssc_driver, ssc_probe);
165}
166module_init(ssc_init);
167
168static void __exit ssc_exit(void)
169{
170 platform_driver_unregister(&ssc_driver);
171}
172module_exit(ssc_exit);
173 214
174MODULE_AUTHOR("Hans-Christian Egtvedt <hcegtvedt@atmel.com>"); 215MODULE_AUTHOR("Hans-Christian Egtvedt <hcegtvedt@atmel.com>");
175MODULE_DESCRIPTION("SSC driver for Atmel AVR32 and AT91"); 216MODULE_DESCRIPTION("SSC driver for Atmel AVR32 and AT91");
diff --git a/drivers/mtd/devices/slram.c b/drivers/mtd/devices/slram.c
index 8f52fc858e48..5a5cd2ace4a6 100644
--- a/drivers/mtd/devices/slram.c
+++ b/drivers/mtd/devices/slram.c
@@ -240,7 +240,7 @@ static int parse_cmdline(char *devname, char *szstart, char *szlength)
240 240
241 if (*(szlength) != '+') { 241 if (*(szlength) != '+') {
242 devlength = simple_strtoul(szlength, &buffer, 0); 242 devlength = simple_strtoul(szlength, &buffer, 0);
243 devlength = handle_unit(devlength, buffer) - devstart; 243 devlength = handle_unit(devlength, buffer);
244 if (devlength < devstart) 244 if (devlength < devstart)
245 goto err_out; 245 goto err_out;
246 246
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index ec6841d8e956..1a03b7f673ce 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2983,13 +2983,15 @@ static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip,
2983 /* 2983 /*
2984 * Field definitions are in the following datasheets: 2984 * Field definitions are in the following datasheets:
2985 * Old style (4,5 byte ID): Samsung K9GAG08U0M (p.32) 2985 * Old style (4,5 byte ID): Samsung K9GAG08U0M (p.32)
2986 * New style (6 byte ID): Samsung K9GAG08U0F (p.44) 2986 * New Samsung (6 byte ID): Samsung K9GAG08U0F (p.44)
2987 * Hynix MLC (6 byte ID): Hynix H27UBG8T2B (p.22) 2987 * Hynix MLC (6 byte ID): Hynix H27UBG8T2B (p.22)
2988 * 2988 *
2989 * Check for ID length, cell type, and Hynix/Samsung ID to decide what 2989 * Check for ID length, non-zero 6th byte, cell type, and Hynix/Samsung
2990 * to do. 2990 * ID to decide what to do.
2991 */ 2991 */
2992 if (id_len == 6 && id_data[0] == NAND_MFR_SAMSUNG) { 2992 if (id_len == 6 && id_data[0] == NAND_MFR_SAMSUNG &&
2993 (chip->cellinfo & NAND_CI_CELLTYPE_MSK) &&
2994 id_data[5] != 0x00) {
2993 /* Calc pagesize */ 2995 /* Calc pagesize */
2994 mtd->writesize = 2048 << (extid & 0x03); 2996 mtd->writesize = 2048 << (extid & 0x03);
2995 extid >>= 2; 2997 extid >>= 2;
diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c
index 64be8f0848b0..d9127e2ed808 100644
--- a/drivers/mtd/ofpart.c
+++ b/drivers/mtd/ofpart.c
@@ -121,7 +121,7 @@ static int parse_ofoldpart_partitions(struct mtd_info *master,
121 nr_parts = plen / sizeof(part[0]); 121 nr_parts = plen / sizeof(part[0]);
122 122
123 *pparts = kzalloc(nr_parts * sizeof(*(*pparts)), GFP_KERNEL); 123 *pparts = kzalloc(nr_parts * sizeof(*(*pparts)), GFP_KERNEL);
124 if (!pparts) 124 if (!*pparts)
125 return -ENOMEM; 125 return -ENOMEM;
126 126
127 names = of_get_property(dp, "partition-names", &plen); 127 names = of_get_property(dp, "partition-names", &plen);
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
index 7153e0d27101..b3f41f200622 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -3694,7 +3694,7 @@ static int flexonenand_check_blocks_erased(struct mtd_info *mtd, int start, int
3694 * flexonenand_set_boundary - Writes the SLC boundary 3694 * flexonenand_set_boundary - Writes the SLC boundary
3695 * @param mtd - mtd info structure 3695 * @param mtd - mtd info structure
3696 */ 3696 */
3697int flexonenand_set_boundary(struct mtd_info *mtd, int die, 3697static int flexonenand_set_boundary(struct mtd_info *mtd, int die,
3698 int boundary, int lock) 3698 int boundary, int lock)
3699{ 3699{
3700 struct onenand_chip *this = mtd->priv; 3700 struct onenand_chip *this = mtd->priv;
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index b2530b002125..5f5b69f37d2e 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1379,6 +1379,8 @@ static void bond_compute_features(struct bonding *bond)
1379 struct net_device *bond_dev = bond->dev; 1379 struct net_device *bond_dev = bond->dev;
1380 netdev_features_t vlan_features = BOND_VLAN_FEATURES; 1380 netdev_features_t vlan_features = BOND_VLAN_FEATURES;
1381 unsigned short max_hard_header_len = ETH_HLEN; 1381 unsigned short max_hard_header_len = ETH_HLEN;
1382 unsigned int gso_max_size = GSO_MAX_SIZE;
1383 u16 gso_max_segs = GSO_MAX_SEGS;
1382 int i; 1384 int i;
1383 unsigned int flags, dst_release_flag = IFF_XMIT_DST_RELEASE; 1385 unsigned int flags, dst_release_flag = IFF_XMIT_DST_RELEASE;
1384 1386
@@ -1394,11 +1396,16 @@ static void bond_compute_features(struct bonding *bond)
1394 dst_release_flag &= slave->dev->priv_flags; 1396 dst_release_flag &= slave->dev->priv_flags;
1395 if (slave->dev->hard_header_len > max_hard_header_len) 1397 if (slave->dev->hard_header_len > max_hard_header_len)
1396 max_hard_header_len = slave->dev->hard_header_len; 1398 max_hard_header_len = slave->dev->hard_header_len;
1399
1400 gso_max_size = min(gso_max_size, slave->dev->gso_max_size);
1401 gso_max_segs = min(gso_max_segs, slave->dev->gso_max_segs);
1397 } 1402 }
1398 1403
1399done: 1404done:
1400 bond_dev->vlan_features = vlan_features; 1405 bond_dev->vlan_features = vlan_features;
1401 bond_dev->hard_header_len = max_hard_header_len; 1406 bond_dev->hard_header_len = max_hard_header_len;
1407 bond_dev->gso_max_segs = gso_max_segs;
1408 netif_set_gso_max_size(bond_dev, gso_max_size);
1402 1409
1403 flags = bond_dev->priv_flags & ~IFF_XMIT_DST_RELEASE; 1410 flags = bond_dev->priv_flags & ~IFF_XMIT_DST_RELEASE;
1404 bond_dev->priv_flags = flags | dst_release_flag; 1411 bond_dev->priv_flags = flags | dst_release_flag;
diff --git a/drivers/net/ethernet/8390/ne.c b/drivers/net/ethernet/8390/ne.c
index d04911d33b64..47618e505355 100644
--- a/drivers/net/ethernet/8390/ne.c
+++ b/drivers/net/ethernet/8390/ne.c
@@ -813,6 +813,7 @@ static int __init ne_drv_probe(struct platform_device *pdev)
813 dev->irq = irq[this_dev]; 813 dev->irq = irq[this_dev];
814 dev->mem_end = bad[this_dev]; 814 dev->mem_end = bad[this_dev];
815 } 815 }
816 SET_NETDEV_DEV(dev, &pdev->dev);
816 err = do_ne_probe(dev); 817 err = do_ne_probe(dev);
817 if (err) { 818 if (err) {
818 free_netdev(dev); 819 free_netdev(dev);
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index bd1fd3d87c24..01611b33a93d 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -9545,10 +9545,13 @@ static int __devinit bnx2x_prev_unload_common(struct bnx2x *bp)
9545 */ 9545 */
9546static void __devinit bnx2x_prev_interrupted_dmae(struct bnx2x *bp) 9546static void __devinit bnx2x_prev_interrupted_dmae(struct bnx2x *bp)
9547{ 9547{
9548 u32 val = REG_RD(bp, PGLUE_B_REG_PGLUE_B_INT_STS); 9548 if (!CHIP_IS_E1x(bp)) {
9549 if (val & PGLUE_B_PGLUE_B_INT_STS_REG_WAS_ERROR_ATTN) { 9549 u32 val = REG_RD(bp, PGLUE_B_REG_PGLUE_B_INT_STS);
9550 BNX2X_ERR("was error bit was found to be set in pglueb upon startup. Clearing"); 9550 if (val & PGLUE_B_PGLUE_B_INT_STS_REG_WAS_ERROR_ATTN) {
9551 REG_WR(bp, PGLUE_B_REG_WAS_ERROR_PF_7_0_CLR, 1 << BP_FUNC(bp)); 9551 BNX2X_ERR("was error bit was found to be set in pglueb upon startup. Clearing");
9552 REG_WR(bp, PGLUE_B_REG_WAS_ERROR_PF_7_0_CLR,
9553 1 << BP_FUNC(bp));
9554 }
9552 } 9555 }
9553} 9556}
9554 9557
diff --git a/drivers/net/ethernet/jme.c b/drivers/net/ethernet/jme.c
index 92317e9c0f73..60ac46f4ac08 100644
--- a/drivers/net/ethernet/jme.c
+++ b/drivers/net/ethernet/jme.c
@@ -1860,10 +1860,14 @@ jme_open(struct net_device *netdev)
1860 jme_clear_pm(jme); 1860 jme_clear_pm(jme);
1861 JME_NAPI_ENABLE(jme); 1861 JME_NAPI_ENABLE(jme);
1862 1862
1863 tasklet_enable(&jme->linkch_task); 1863 tasklet_init(&jme->linkch_task, jme_link_change_tasklet,
1864 tasklet_enable(&jme->txclean_task); 1864 (unsigned long) jme);
1865 tasklet_hi_enable(&jme->rxclean_task); 1865 tasklet_init(&jme->txclean_task, jme_tx_clean_tasklet,
1866 tasklet_hi_enable(&jme->rxempty_task); 1866 (unsigned long) jme);
1867 tasklet_init(&jme->rxclean_task, jme_rx_clean_tasklet,
1868 (unsigned long) jme);
1869 tasklet_init(&jme->rxempty_task, jme_rx_empty_tasklet,
1870 (unsigned long) jme);
1867 1871
1868 rc = jme_request_irq(jme); 1872 rc = jme_request_irq(jme);
1869 if (rc) 1873 if (rc)
@@ -3079,22 +3083,6 @@ jme_init_one(struct pci_dev *pdev,
3079 tasklet_init(&jme->pcc_task, 3083 tasklet_init(&jme->pcc_task,
3080 jme_pcc_tasklet, 3084 jme_pcc_tasklet,
3081 (unsigned long) jme); 3085 (unsigned long) jme);
3082 tasklet_init(&jme->linkch_task,
3083 jme_link_change_tasklet,
3084 (unsigned long) jme);
3085 tasklet_init(&jme->txclean_task,
3086 jme_tx_clean_tasklet,
3087 (unsigned long) jme);
3088 tasklet_init(&jme->rxclean_task,
3089 jme_rx_clean_tasklet,
3090 (unsigned long) jme);
3091 tasklet_init(&jme->rxempty_task,
3092 jme_rx_empty_tasklet,
3093 (unsigned long) jme);
3094 tasklet_disable_nosync(&jme->linkch_task);
3095 tasklet_disable_nosync(&jme->txclean_task);
3096 tasklet_disable_nosync(&jme->rxclean_task);
3097 tasklet_disable_nosync(&jme->rxempty_task);
3098 jme->dpi.cur = PCC_P1; 3086 jme->dpi.cur = PCC_P1;
3099 3087
3100 jme->reg_ghc = 0; 3088 jme->reg_ghc = 0;
diff --git a/drivers/net/ethernet/micrel/ksz884x.c b/drivers/net/ethernet/micrel/ksz884x.c
index e558edd1cb6c..69e01977a1dd 100644
--- a/drivers/net/ethernet/micrel/ksz884x.c
+++ b/drivers/net/ethernet/micrel/ksz884x.c
@@ -5459,8 +5459,10 @@ static int prepare_hardware(struct net_device *dev)
5459 rc = request_irq(dev->irq, netdev_intr, IRQF_SHARED, dev->name, dev); 5459 rc = request_irq(dev->irq, netdev_intr, IRQF_SHARED, dev->name, dev);
5460 if (rc) 5460 if (rc)
5461 return rc; 5461 return rc;
5462 tasklet_enable(&hw_priv->rx_tasklet); 5462 tasklet_init(&hw_priv->rx_tasklet, rx_proc_task,
5463 tasklet_enable(&hw_priv->tx_tasklet); 5463 (unsigned long) hw_priv);
5464 tasklet_init(&hw_priv->tx_tasklet, tx_proc_task,
5465 (unsigned long) hw_priv);
5464 5466
5465 hw->promiscuous = 0; 5467 hw->promiscuous = 0;
5466 hw->all_multi = 0; 5468 hw->all_multi = 0;
@@ -7033,16 +7035,6 @@ static int __devinit pcidev_init(struct pci_dev *pdev,
7033 spin_lock_init(&hw_priv->hwlock); 7035 spin_lock_init(&hw_priv->hwlock);
7034 mutex_init(&hw_priv->lock); 7036 mutex_init(&hw_priv->lock);
7035 7037
7036 /* tasklet is enabled. */
7037 tasklet_init(&hw_priv->rx_tasklet, rx_proc_task,
7038 (unsigned long) hw_priv);
7039 tasklet_init(&hw_priv->tx_tasklet, tx_proc_task,
7040 (unsigned long) hw_priv);
7041
7042 /* tasklet_enable will decrement the atomic counter. */
7043 tasklet_disable(&hw_priv->rx_tasklet);
7044 tasklet_disable(&hw_priv->tx_tasklet);
7045
7046 for (i = 0; i < TOTAL_PORT_NUM; i++) 7038 for (i = 0; i < TOTAL_PORT_NUM; i++)
7047 init_waitqueue_head(&hw_priv->counter[i].counter); 7039 init_waitqueue_head(&hw_priv->counter[i].counter);
7048 7040
diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c
index 1c818254b7be..b01f83a044c4 100644
--- a/drivers/net/ethernet/realtek/8139cp.c
+++ b/drivers/net/ethernet/realtek/8139cp.c
@@ -979,17 +979,6 @@ static void cp_init_hw (struct cp_private *cp)
979 cpw32_f (MAC0 + 0, le32_to_cpu (*(__le32 *) (dev->dev_addr + 0))); 979 cpw32_f (MAC0 + 0, le32_to_cpu (*(__le32 *) (dev->dev_addr + 0)));
980 cpw32_f (MAC0 + 4, le32_to_cpu (*(__le32 *) (dev->dev_addr + 4))); 980 cpw32_f (MAC0 + 4, le32_to_cpu (*(__le32 *) (dev->dev_addr + 4)));
981 981
982 cpw32_f(HiTxRingAddr, 0);
983 cpw32_f(HiTxRingAddr + 4, 0);
984
985 ring_dma = cp->ring_dma;
986 cpw32_f(RxRingAddr, ring_dma & 0xffffffff);
987 cpw32_f(RxRingAddr + 4, (ring_dma >> 16) >> 16);
988
989 ring_dma += sizeof(struct cp_desc) * CP_RX_RING_SIZE;
990 cpw32_f(TxRingAddr, ring_dma & 0xffffffff);
991 cpw32_f(TxRingAddr + 4, (ring_dma >> 16) >> 16);
992
993 cp_start_hw(cp); 982 cp_start_hw(cp);
994 cpw8(TxThresh, 0x06); /* XXX convert magic num to a constant */ 983 cpw8(TxThresh, 0x06); /* XXX convert magic num to a constant */
995 984
@@ -1003,6 +992,17 @@ static void cp_init_hw (struct cp_private *cp)
1003 992
1004 cpw8(Config5, cpr8(Config5) & PMEStatus); 993 cpw8(Config5, cpr8(Config5) & PMEStatus);
1005 994
995 cpw32_f(HiTxRingAddr, 0);
996 cpw32_f(HiTxRingAddr + 4, 0);
997
998 ring_dma = cp->ring_dma;
999 cpw32_f(RxRingAddr, ring_dma & 0xffffffff);
1000 cpw32_f(RxRingAddr + 4, (ring_dma >> 16) >> 16);
1001
1002 ring_dma += sizeof(struct cp_desc) * CP_RX_RING_SIZE;
1003 cpw32_f(TxRingAddr, ring_dma & 0xffffffff);
1004 cpw32_f(TxRingAddr + 4, (ring_dma >> 16) >> 16);
1005
1006 cpw16(MultiIntr, 0); 1006 cpw16(MultiIntr, 0);
1007 1007
1008 cpw8_f(Cfg9346, Cfg9346_Lock); 1008 cpw8_f(Cfg9346, Cfg9346_Lock);
diff --git a/drivers/net/ethernet/sis/sis900.c b/drivers/net/ethernet/sis/sis900.c
index fb9f6b38511f..edf5edb13140 100644
--- a/drivers/net/ethernet/sis/sis900.c
+++ b/drivers/net/ethernet/sis/sis900.c
@@ -2479,7 +2479,7 @@ static int sis900_resume(struct pci_dev *pci_dev)
2479 netif_start_queue(net_dev); 2479 netif_start_queue(net_dev);
2480 2480
2481 /* Workaround for EDB */ 2481 /* Workaround for EDB */
2482 sis900_set_mode(ioaddr, HW_SPEED_10_MBPS, FDX_CAPABLE_HALF_SELECTED); 2482 sis900_set_mode(sis_priv, HW_SPEED_10_MBPS, FDX_CAPABLE_HALF_SELECTED);
2483 2483
2484 /* Enable all known interrupts by setting the interrupt mask. */ 2484 /* Enable all known interrupts by setting the interrupt mask. */
2485 sw32(imr, RxSOVR | RxORN | RxERR | RxOK | TxURN | TxERR | TxIDLE); 2485 sw32(imr, RxSOVR | RxORN | RxERR | RxOK | TxURN | TxERR | TxIDLE);
diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c
index 62d1baf111ea..c53c0f4e2ce3 100644
--- a/drivers/net/ethernet/smsc/smsc911x.c
+++ b/drivers/net/ethernet/smsc/smsc911x.c
@@ -2110,7 +2110,7 @@ static void __devinit smsc911x_read_mac_address(struct net_device *dev)
2110static int __devinit smsc911x_init(struct net_device *dev) 2110static int __devinit smsc911x_init(struct net_device *dev)
2111{ 2111{
2112 struct smsc911x_data *pdata = netdev_priv(dev); 2112 struct smsc911x_data *pdata = netdev_priv(dev);
2113 unsigned int byte_test; 2113 unsigned int byte_test, mask;
2114 unsigned int to = 100; 2114 unsigned int to = 100;
2115 2115
2116 SMSC_TRACE(pdata, probe, "Driver Parameters:"); 2116 SMSC_TRACE(pdata, probe, "Driver Parameters:");
@@ -2130,9 +2130,22 @@ static int __devinit smsc911x_init(struct net_device *dev)
2130 /* 2130 /*
2131 * poll the READY bit in PMT_CTRL. Any other access to the device is 2131 * poll the READY bit in PMT_CTRL. Any other access to the device is
2132 * forbidden while this bit isn't set. Try for 100ms 2132 * forbidden while this bit isn't set. Try for 100ms
2133 *
2134 * Note that this test is done before the WORD_SWAP register is
2135 * programmed. So in some configurations the READY bit is at 16 before
2136 * WORD_SWAP is written to. This issue is worked around by waiting
2137 * until either bit 0 or bit 16 gets set in PMT_CTRL.
2138 *
2139 * SMSC has confirmed that checking bit 16 (marked as reserved in
2140 * the datasheet) is fine since these bits "will either never be set
2141 * or can only go high after READY does (so also indicate the device
2142 * is ready)".
2133 */ 2143 */
2134 while (!(smsc911x_reg_read(pdata, PMT_CTRL) & PMT_CTRL_READY_) && --to) 2144
2145 mask = PMT_CTRL_READY_ | swahw32(PMT_CTRL_READY_);
2146 while (!(smsc911x_reg_read(pdata, PMT_CTRL) & mask) && --to)
2135 udelay(1000); 2147 udelay(1000);
2148
2136 if (to == 0) { 2149 if (to == 0) {
2137 pr_err("Device not READY in 100ms aborting\n"); 2150 pr_err("Device not READY in 100ms aborting\n");
2138 return -ENODEV; 2151 return -ENODEV;
diff --git a/drivers/net/ethernet/tile/tilegx.c b/drivers/net/ethernet/tile/tilegx.c
index 4e9810013850..66e025ad5df1 100644
--- a/drivers/net/ethernet/tile/tilegx.c
+++ b/drivers/net/ethernet/tile/tilegx.c
@@ -917,7 +917,7 @@ static int tile_net_setup_interrupts(struct net_device *dev)
917 ingress_irq = rc; 917 ingress_irq = rc;
918 tile_irq_activate(ingress_irq, TILE_IRQ_PERCPU); 918 tile_irq_activate(ingress_irq, TILE_IRQ_PERCPU);
919 rc = request_irq(ingress_irq, tile_net_handle_ingress_irq, 919 rc = request_irq(ingress_irq, tile_net_handle_ingress_irq,
920 0, NULL, NULL); 920 0, "tile_net", NULL);
921 if (rc != 0) { 921 if (rc != 0) {
922 netdev_err(dev, "request_irq failed: %d\n", rc); 922 netdev_err(dev, "request_irq failed: %d\n", rc);
923 destroy_irq(ingress_irq); 923 destroy_irq(ingress_irq);
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index 1d04754a6637..a788501e978e 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -894,6 +894,8 @@ out:
894 return IRQ_HANDLED; 894 return IRQ_HANDLED;
895} 895}
896 896
897static void axienet_dma_err_handler(unsigned long data);
898
897/** 899/**
898 * axienet_open - Driver open routine. 900 * axienet_open - Driver open routine.
899 * @ndev: Pointer to net_device structure 901 * @ndev: Pointer to net_device structure
@@ -942,6 +944,10 @@ static int axienet_open(struct net_device *ndev)
942 phy_start(lp->phy_dev); 944 phy_start(lp->phy_dev);
943 } 945 }
944 946
947 /* Enable tasklets for Axi DMA error handling */
948 tasklet_init(&lp->dma_err_tasklet, axienet_dma_err_handler,
949 (unsigned long) lp);
950
945 /* Enable interrupts for Axi DMA Tx */ 951 /* Enable interrupts for Axi DMA Tx */
946 ret = request_irq(lp->tx_irq, axienet_tx_irq, 0, ndev->name, ndev); 952 ret = request_irq(lp->tx_irq, axienet_tx_irq, 0, ndev->name, ndev);
947 if (ret) 953 if (ret)
@@ -950,8 +956,7 @@ static int axienet_open(struct net_device *ndev)
950 ret = request_irq(lp->rx_irq, axienet_rx_irq, 0, ndev->name, ndev); 956 ret = request_irq(lp->rx_irq, axienet_rx_irq, 0, ndev->name, ndev);
951 if (ret) 957 if (ret)
952 goto err_rx_irq; 958 goto err_rx_irq;
953 /* Enable tasklets for Axi DMA error handling */ 959
954 tasklet_enable(&lp->dma_err_tasklet);
955 return 0; 960 return 0;
956 961
957err_rx_irq: 962err_rx_irq:
@@ -960,6 +965,7 @@ err_tx_irq:
960 if (lp->phy_dev) 965 if (lp->phy_dev)
961 phy_disconnect(lp->phy_dev); 966 phy_disconnect(lp->phy_dev);
962 lp->phy_dev = NULL; 967 lp->phy_dev = NULL;
968 tasklet_kill(&lp->dma_err_tasklet);
963 dev_err(lp->dev, "request_irq() failed\n"); 969 dev_err(lp->dev, "request_irq() failed\n");
964 return ret; 970 return ret;
965} 971}
@@ -1613,10 +1619,6 @@ static int __devinit axienet_of_probe(struct platform_device *op)
1613 goto err_iounmap_2; 1619 goto err_iounmap_2;
1614 } 1620 }
1615 1621
1616 tasklet_init(&lp->dma_err_tasklet, axienet_dma_err_handler,
1617 (unsigned long) lp);
1618 tasklet_disable(&lp->dma_err_tasklet);
1619
1620 return 0; 1622 return 0;
1621 1623
1622err_iounmap_2: 1624err_iounmap_2:
diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
index 98934bdf6acf..477d6729b17f 100644
--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
@@ -1102,10 +1102,12 @@ static int init_queues(struct port *port)
1102{ 1102{
1103 int i; 1103 int i;
1104 1104
1105 if (!ports_open) 1105 if (!ports_open) {
1106 if (!(dma_pool = dma_pool_create(DRV_NAME, NULL, 1106 dma_pool = dma_pool_create(DRV_NAME, &port->netdev->dev,
1107 POOL_ALLOC_SIZE, 32, 0))) 1107 POOL_ALLOC_SIZE, 32, 0);
1108 if (!dma_pool)
1108 return -ENOMEM; 1109 return -ENOMEM;
1110 }
1109 1111
1110 if (!(port->desc_tab = dma_pool_alloc(dma_pool, GFP_KERNEL, 1112 if (!(port->desc_tab = dma_pool_alloc(dma_pool, GFP_KERNEL,
1111 &port->desc_tab_phys))) 1113 &port->desc_tab_phys)))
diff --git a/drivers/net/irda/sir_dev.c b/drivers/net/irda/sir_dev.c
index 5039f08f5a5b..43e9ab4f4d7e 100644
--- a/drivers/net/irda/sir_dev.c
+++ b/drivers/net/irda/sir_dev.c
@@ -222,7 +222,7 @@ static void sirdev_config_fsm(struct work_struct *work)
222 break; 222 break;
223 223
224 case SIRDEV_STATE_DONGLE_SPEED: 224 case SIRDEV_STATE_DONGLE_SPEED:
225 if (dev->dongle_drv->reset) { 225 if (dev->dongle_drv->set_speed) {
226 ret = dev->dongle_drv->set_speed(dev, fsm->param); 226 ret = dev->dongle_drv->set_speed(dev, fsm->param);
227 if (ret < 0) { 227 if (ret < 0) {
228 fsm->result = ret; 228 fsm->result = ret;
diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
index 6428fcbbdd4b..daec9b05d168 100644
--- a/drivers/net/phy/mdio-bitbang.c
+++ b/drivers/net/phy/mdio-bitbang.c
@@ -234,7 +234,6 @@ void free_mdio_bitbang(struct mii_bus *bus)
234 struct mdiobb_ctrl *ctrl = bus->priv; 234 struct mdiobb_ctrl *ctrl = bus->priv;
235 235
236 module_put(ctrl->ops->owner); 236 module_put(ctrl->ops->owner);
237 mdiobus_unregister(bus);
238 mdiobus_free(bus); 237 mdiobus_free(bus);
239} 238}
240EXPORT_SYMBOL(free_mdio_bitbang); 239EXPORT_SYMBOL(free_mdio_bitbang);
diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c
index 899274f2f9b1..2ed1140df3e9 100644
--- a/drivers/net/phy/mdio-gpio.c
+++ b/drivers/net/phy/mdio-gpio.c
@@ -185,17 +185,20 @@ static int __devinit mdio_gpio_probe(struct platform_device *pdev)
185{ 185{
186 struct mdio_gpio_platform_data *pdata; 186 struct mdio_gpio_platform_data *pdata;
187 struct mii_bus *new_bus; 187 struct mii_bus *new_bus;
188 int ret; 188 int ret, bus_id;
189 189
190 if (pdev->dev.of_node) 190 if (pdev->dev.of_node) {
191 pdata = mdio_gpio_of_get_data(pdev); 191 pdata = mdio_gpio_of_get_data(pdev);
192 else 192 bus_id = of_alias_get_id(pdev->dev.of_node, "mdio-gpio");
193 } else {
193 pdata = pdev->dev.platform_data; 194 pdata = pdev->dev.platform_data;
195 bus_id = pdev->id;
196 }
194 197
195 if (!pdata) 198 if (!pdata)
196 return -ENODEV; 199 return -ENODEV;
197 200
198 new_bus = mdio_gpio_bus_init(&pdev->dev, pdata, pdev->id); 201 new_bus = mdio_gpio_bus_init(&pdev->dev, pdata, bus_id);
199 if (!new_bus) 202 if (!new_bus)
200 return -ENODEV; 203 return -ENODEV;
201 204
diff --git a/drivers/net/team/team_mode_broadcast.c b/drivers/net/team/team_mode_broadcast.c
index 9db0171e9366..c5db428e73fa 100644
--- a/drivers/net/team/team_mode_broadcast.c
+++ b/drivers/net/team/team_mode_broadcast.c
@@ -29,8 +29,8 @@ static bool bc_transmit(struct team *team, struct sk_buff *skb)
29 if (last) { 29 if (last) {
30 skb2 = skb_clone(skb, GFP_ATOMIC); 30 skb2 = skb_clone(skb, GFP_ATOMIC);
31 if (skb2) { 31 if (skb2) {
32 ret = team_dev_queue_xmit(team, last, 32 ret = !team_dev_queue_xmit(team, last,
33 skb2); 33 skb2);
34 if (!sum_ret) 34 if (!sum_ret)
35 sum_ret = ret; 35 sum_ret = ret;
36 } 36 }
@@ -39,7 +39,7 @@ static bool bc_transmit(struct team *team, struct sk_buff *skb)
39 } 39 }
40 } 40 }
41 if (last) { 41 if (last) {
42 ret = team_dev_queue_xmit(team, last, skb); 42 ret = !team_dev_queue_xmit(team, last, skb);
43 if (!sum_ret) 43 if (!sum_ret)
44 sum_ret = ret; 44 sum_ret = ret;
45 } 45 }
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 4cd582a4f625..74fab1a40156 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -540,10 +540,12 @@ advance:
540 (ctx->ether_desc == NULL) || (ctx->control != intf)) 540 (ctx->ether_desc == NULL) || (ctx->control != intf))
541 goto error; 541 goto error;
542 542
543 /* claim interfaces, if any */ 543 /* claim data interface, if different from control */
544 temp = usb_driver_claim_interface(driver, ctx->data, dev); 544 if (ctx->data != ctx->control) {
545 if (temp) 545 temp = usb_driver_claim_interface(driver, ctx->data, dev);
546 goto error; 546 if (temp)
547 goto error;
548 }
547 549
548 iface_no = ctx->data->cur_altsetting->desc.bInterfaceNumber; 550 iface_no = ctx->data->cur_altsetting->desc.bInterfaceNumber;
549 551
@@ -623,6 +625,10 @@ static void cdc_ncm_unbind(struct usbnet *dev, struct usb_interface *intf)
623 625
624 tasklet_kill(&ctx->bh); 626 tasklet_kill(&ctx->bh);
625 627
628 /* handle devices with combined control and data interface */
629 if (ctx->control == ctx->data)
630 ctx->data = NULL;
631
626 /* disconnect master --> disconnect slave */ 632 /* disconnect master --> disconnect slave */
627 if (intf == ctx->control && ctx->data) { 633 if (intf == ctx->control && ctx->data) {
628 usb_set_intfdata(ctx->data, NULL); 634 usb_set_intfdata(ctx->data, NULL);
@@ -1245,6 +1251,14 @@ static const struct usb_device_id cdc_devs[] = {
1245 .driver_info = (unsigned long) &wwan_info, 1251 .driver_info = (unsigned long) &wwan_info,
1246 }, 1252 },
1247 1253
1254 /* Huawei NCM devices disguised as vendor specific */
1255 { USB_VENDOR_AND_INTERFACE_INFO(0x12d1, 0xff, 0x02, 0x16),
1256 .driver_info = (unsigned long)&wwan_info,
1257 },
1258 { USB_VENDOR_AND_INTERFACE_INFO(0x12d1, 0xff, 0x02, 0x46),
1259 .driver_info = (unsigned long)&wwan_info,
1260 },
1261
1248 /* Generic CDC-NCM devices */ 1262 /* Generic CDC-NCM devices */
1249 { USB_INTERFACE_INFO(USB_CLASS_COMM, 1263 { USB_INTERFACE_INFO(USB_CLASS_COMM,
1250 USB_CDC_SUBCLASS_NCM, USB_CDC_PROTO_NONE), 1264 USB_CDC_SUBCLASS_NCM, USB_CDC_PROTO_NONE),
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 3286166415b4..362cb8cfeb92 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -184,7 +184,7 @@ static int smsc95xx_mdio_read(struct net_device *netdev, int phy_id, int idx)
184 /* set the address, index & direction (read from PHY) */ 184 /* set the address, index & direction (read from PHY) */
185 phy_id &= dev->mii.phy_id_mask; 185 phy_id &= dev->mii.phy_id_mask;
186 idx &= dev->mii.reg_num_mask; 186 idx &= dev->mii.reg_num_mask;
187 addr = (phy_id << 11) | (idx << 6) | MII_READ_; 187 addr = (phy_id << 11) | (idx << 6) | MII_READ_ | MII_BUSY_;
188 ret = smsc95xx_write_reg(dev, MII_ADDR, addr); 188 ret = smsc95xx_write_reg(dev, MII_ADDR, addr);
189 check_warn_goto_done(ret, "Error writing MII_ADDR"); 189 check_warn_goto_done(ret, "Error writing MII_ADDR");
190 190
@@ -221,7 +221,7 @@ static void smsc95xx_mdio_write(struct net_device *netdev, int phy_id, int idx,
221 /* set the address, index & direction (write to PHY) */ 221 /* set the address, index & direction (write to PHY) */
222 phy_id &= dev->mii.phy_id_mask; 222 phy_id &= dev->mii.phy_id_mask;
223 idx &= dev->mii.reg_num_mask; 223 idx &= dev->mii.reg_num_mask;
224 addr = (phy_id << 11) | (idx << 6) | MII_WRITE_; 224 addr = (phy_id << 11) | (idx << 6) | MII_WRITE_ | MII_BUSY_;
225 ret = smsc95xx_write_reg(dev, MII_ADDR, addr); 225 ret = smsc95xx_write_reg(dev, MII_ADDR, addr);
226 check_warn_goto_done(ret, "Error writing MII_ADDR"); 226 check_warn_goto_done(ret, "Error writing MII_ADDR");
227 227
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 7b4adde93c01..8b5c61917076 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * VXLAN: Virtual eXtensiable Local Area Network 2 * VXLAN: Virtual eXtensible Local Area Network
3 * 3 *
4 * Copyright (c) 2012 Vyatta Inc. 4 * Copyright (c) 2012 Vyatta Inc.
5 * 5 *
@@ -50,8 +50,8 @@
50 50
51#define VXLAN_N_VID (1u << 24) 51#define VXLAN_N_VID (1u << 24)
52#define VXLAN_VID_MASK (VXLAN_N_VID - 1) 52#define VXLAN_VID_MASK (VXLAN_N_VID - 1)
53/* VLAN + IP header + UDP + VXLAN */ 53/* IP header + UDP + VXLAN + Ethernet header */
54#define VXLAN_HEADROOM (4 + 20 + 8 + 8) 54#define VXLAN_HEADROOM (20 + 8 + 8 + 14)
55 55
56#define VXLAN_FLAGS 0x08000000 /* struct vxlanhdr.vx_flags required value. */ 56#define VXLAN_FLAGS 0x08000000 /* struct vxlanhdr.vx_flags required value. */
57 57
@@ -1102,6 +1102,10 @@ static int vxlan_newlink(struct net *net, struct net_device *dev,
1102 1102
1103 if (!tb[IFLA_MTU]) 1103 if (!tb[IFLA_MTU])
1104 dev->mtu = lowerdev->mtu - VXLAN_HEADROOM; 1104 dev->mtu = lowerdev->mtu - VXLAN_HEADROOM;
1105
1106 /* update header length based on lower device */
1107 dev->hard_header_len = lowerdev->hard_header_len +
1108 VXLAN_HEADROOM;
1105 } 1109 }
1106 1110
1107 if (data[IFLA_VXLAN_TOS]) 1111 if (data[IFLA_VXLAN_TOS])
diff --git a/drivers/net/wan/ixp4xx_hss.c b/drivers/net/wan/ixp4xx_hss.c
index 3f575afd8cfc..e9a3da588e95 100644
--- a/drivers/net/wan/ixp4xx_hss.c
+++ b/drivers/net/wan/ixp4xx_hss.c
@@ -969,10 +969,12 @@ static int init_hdlc_queues(struct port *port)
969{ 969{
970 int i; 970 int i;
971 971
972 if (!ports_open) 972 if (!ports_open) {
973 if (!(dma_pool = dma_pool_create(DRV_NAME, NULL, 973 dma_pool = dma_pool_create(DRV_NAME, &port->netdev->dev,
974 POOL_ALLOC_SIZE, 32, 0))) 974 POOL_ALLOC_SIZE, 32, 0);
975 if (!dma_pool)
975 return -ENOMEM; 976 return -ENOMEM;
977 }
976 978
977 if (!(port->desc_tab = dma_pool_alloc(dma_pool, GFP_KERNEL, 979 if (!(port->desc_tab = dma_pool_alloc(dma_pool, GFP_KERNEL,
978 &port->desc_tab_phys))) 980 &port->desc_tab_phys)))
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 8e1559aba495..1829b445d0b0 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -1456,7 +1456,7 @@ static bool ath9k_hw_set_reset_reg(struct ath_hw *ah, u32 type)
1456 switch (type) { 1456 switch (type) {
1457 case ATH9K_RESET_POWER_ON: 1457 case ATH9K_RESET_POWER_ON:
1458 ret = ath9k_hw_set_reset_power_on(ah); 1458 ret = ath9k_hw_set_reset_power_on(ah);
1459 if (!ret) 1459 if (ret)
1460 ah->reset_power_on = true; 1460 ah->reset_power_on = true;
1461 break; 1461 break;
1462 case ATH9K_RESET_WARM: 1462 case ATH9K_RESET_WARM:
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
index a6f1e8166008..481345c23ded 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
@@ -4401,7 +4401,7 @@ static s32 brcmf_mode_to_nl80211_iftype(s32 mode)
4401 4401
4402static void brcmf_wiphy_pno_params(struct wiphy *wiphy) 4402static void brcmf_wiphy_pno_params(struct wiphy *wiphy)
4403{ 4403{
4404#ifndef CONFIG_BRCMFISCAN 4404#ifndef CONFIG_BRCMISCAN
4405 /* scheduled scan settings */ 4405 /* scheduled scan settings */
4406 wiphy->max_sched_scan_ssids = BRCMF_PNO_MAX_PFN_COUNT; 4406 wiphy->max_sched_scan_ssids = BRCMF_PNO_MAX_PFN_COUNT;
4407 wiphy->max_match_sets = BRCMF_PNO_MAX_PFN_COUNT; 4407 wiphy->max_match_sets = BRCMF_PNO_MAX_PFN_COUNT;
diff --git a/drivers/net/wireless/iwlwifi/dvm/mac80211.c b/drivers/net/wireless/iwlwifi/dvm/mac80211.c
index ff8162d4c454..2d9eee93c743 100644
--- a/drivers/net/wireless/iwlwifi/dvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/dvm/mac80211.c
@@ -521,7 +521,7 @@ static void iwlagn_mac_tx(struct ieee80211_hw *hw,
521 ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); 521 ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate);
522 522
523 if (iwlagn_tx_skb(priv, control->sta, skb)) 523 if (iwlagn_tx_skb(priv, control->sta, skb))
524 dev_kfree_skb_any(skb); 524 ieee80211_free_txskb(hw, skb);
525} 525}
526 526
527static void iwlagn_mac_update_tkip_key(struct ieee80211_hw *hw, 527static void iwlagn_mac_update_tkip_key(struct ieee80211_hw *hw,
@@ -1354,6 +1354,20 @@ static int iwlagn_mac_add_interface(struct ieee80211_hw *hw,
1354 vif_priv->ctx = ctx; 1354 vif_priv->ctx = ctx;
1355 ctx->vif = vif; 1355 ctx->vif = vif;
1356 1356
1357 /*
1358 * In SNIFFER device type, the firmware reports the FCS to
1359 * the host, rather than snipping it off. Unfortunately,
1360 * mac80211 doesn't (yet) provide a per-packet flag for
1361 * this, so that we have to set the hardware flag based
1362 * on the interfaces added. As the monitor interface can
1363 * only be present by itself, and will be removed before
1364 * other interfaces are added, this is safe.
1365 */
1366 if (vif->type == NL80211_IFTYPE_MONITOR)
1367 priv->hw->flags |= IEEE80211_HW_RX_INCLUDES_FCS;
1368 else
1369 priv->hw->flags &= ~IEEE80211_HW_RX_INCLUDES_FCS;
1370
1357 err = iwl_setup_interface(priv, ctx); 1371 err = iwl_setup_interface(priv, ctx);
1358 if (!err || reset) 1372 if (!err || reset)
1359 goto out; 1373 goto out;
diff --git a/drivers/net/wireless/iwlwifi/dvm/main.c b/drivers/net/wireless/iwlwifi/dvm/main.c
index 7ff3f1430678..408132cf83c1 100644
--- a/drivers/net/wireless/iwlwifi/dvm/main.c
+++ b/drivers/net/wireless/iwlwifi/dvm/main.c
@@ -2114,7 +2114,7 @@ static void iwl_free_skb(struct iwl_op_mode *op_mode, struct sk_buff *skb)
2114 2114
2115 info = IEEE80211_SKB_CB(skb); 2115 info = IEEE80211_SKB_CB(skb);
2116 iwl_trans_free_tx_cmd(priv->trans, info->driver_data[1]); 2116 iwl_trans_free_tx_cmd(priv->trans, info->driver_data[1]);
2117 dev_kfree_skb_any(skb); 2117 ieee80211_free_txskb(priv->hw, skb);
2118} 2118}
2119 2119
2120static void iwl_set_hw_rfkill_state(struct iwl_op_mode *op_mode, bool state) 2120static void iwl_set_hw_rfkill_state(struct iwl_op_mode *op_mode, bool state)
diff --git a/drivers/net/wireless/iwlwifi/pcie/rx.c b/drivers/net/wireless/iwlwifi/pcie/rx.c
index 17c8e5d82681..bb69f8f90b3b 100644
--- a/drivers/net/wireless/iwlwifi/pcie/rx.c
+++ b/drivers/net/wireless/iwlwifi/pcie/rx.c
@@ -321,6 +321,14 @@ static void iwl_rx_allocate(struct iwl_trans *trans, gfp_t priority)
321 dma_map_page(trans->dev, page, 0, 321 dma_map_page(trans->dev, page, 0,
322 PAGE_SIZE << trans_pcie->rx_page_order, 322 PAGE_SIZE << trans_pcie->rx_page_order,
323 DMA_FROM_DEVICE); 323 DMA_FROM_DEVICE);
324 if (dma_mapping_error(trans->dev, rxb->page_dma)) {
325 rxb->page = NULL;
326 spin_lock_irqsave(&rxq->lock, flags);
327 list_add(&rxb->list, &rxq->rx_used);
328 spin_unlock_irqrestore(&rxq->lock, flags);
329 __free_pages(page, trans_pcie->rx_page_order);
330 return;
331 }
324 /* dma address must be no more than 36 bits */ 332 /* dma address must be no more than 36 bits */
325 BUG_ON(rxb->page_dma & ~DMA_BIT_MASK(36)); 333 BUG_ON(rxb->page_dma & ~DMA_BIT_MASK(36));
326 /* and also 256 byte aligned! */ 334 /* and also 256 byte aligned! */
@@ -488,8 +496,19 @@ static void iwl_rx_handle_rxbuf(struct iwl_trans *trans,
488 dma_map_page(trans->dev, rxb->page, 0, 496 dma_map_page(trans->dev, rxb->page, 0,
489 PAGE_SIZE << trans_pcie->rx_page_order, 497 PAGE_SIZE << trans_pcie->rx_page_order,
490 DMA_FROM_DEVICE); 498 DMA_FROM_DEVICE);
491 list_add_tail(&rxb->list, &rxq->rx_free); 499 if (dma_mapping_error(trans->dev, rxb->page_dma)) {
492 rxq->free_count++; 500 /*
501 * free the page(s) as well to not break
502 * the invariant that the items on the used
503 * list have no page(s)
504 */
505 __free_pages(rxb->page, trans_pcie->rx_page_order);
506 rxb->page = NULL;
507 list_add_tail(&rxb->list, &rxq->rx_used);
508 } else {
509 list_add_tail(&rxb->list, &rxq->rx_free);
510 rxq->free_count++;
511 }
493 } else 512 } else
494 list_add_tail(&rxb->list, &rxq->rx_used); 513 list_add_tail(&rxb->list, &rxq->rx_used);
495 spin_unlock_irqrestore(&rxq->lock, flags); 514 spin_unlock_irqrestore(&rxq->lock, flags);
diff --git a/drivers/net/wireless/iwlwifi/pcie/tx.c b/drivers/net/wireless/iwlwifi/pcie/tx.c
index 105e3af3c621..79a4ddc002d3 100644
--- a/drivers/net/wireless/iwlwifi/pcie/tx.c
+++ b/drivers/net/wireless/iwlwifi/pcie/tx.c
@@ -480,20 +480,12 @@ void iwl_trans_pcie_txq_enable(struct iwl_trans *trans, int txq_id, int fifo,
480void iwl_trans_pcie_txq_disable(struct iwl_trans *trans, int txq_id) 480void iwl_trans_pcie_txq_disable(struct iwl_trans *trans, int txq_id)
481{ 481{
482 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 482 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
483 u16 rd_ptr, wr_ptr;
484 int n_bd = trans_pcie->txq[txq_id].q.n_bd;
485 483
486 if (!test_and_clear_bit(txq_id, trans_pcie->queue_used)) { 484 if (!test_and_clear_bit(txq_id, trans_pcie->queue_used)) {
487 WARN_ONCE(1, "queue %d not used", txq_id); 485 WARN_ONCE(1, "queue %d not used", txq_id);
488 return; 486 return;
489 } 487 }
490 488
491 rd_ptr = iwl_read_prph(trans, SCD_QUEUE_RDPTR(txq_id)) & (n_bd - 1);
492 wr_ptr = iwl_read_prph(trans, SCD_QUEUE_WRPTR(txq_id));
493
494 WARN_ONCE(rd_ptr != wr_ptr, "queue %d isn't empty: [%d,%d]",
495 txq_id, rd_ptr, wr_ptr);
496
497 iwl_txq_set_inactive(trans, txq_id); 489 iwl_txq_set_inactive(trans, txq_id);
498 IWL_DEBUG_TX_QUEUES(trans, "Deactivate queue %d\n", txq_id); 490 IWL_DEBUG_TX_QUEUES(trans, "Deactivate queue %d\n", txq_id);
499} 491}
diff --git a/drivers/net/wireless/mwifiex/cmdevt.c b/drivers/net/wireless/mwifiex/cmdevt.c
index 8d465107f52b..ae9010ed58de 100644
--- a/drivers/net/wireless/mwifiex/cmdevt.c
+++ b/drivers/net/wireless/mwifiex/cmdevt.c
@@ -890,9 +890,6 @@ mwifiex_cmd_timeout_func(unsigned long function_context)
890 return; 890 return;
891 } 891 }
892 cmd_node = adapter->curr_cmd; 892 cmd_node = adapter->curr_cmd;
893 if (cmd_node->wait_q_enabled)
894 adapter->cmd_wait_q.status = -ETIMEDOUT;
895
896 if (cmd_node) { 893 if (cmd_node) {
897 adapter->dbg.timeout_cmd_id = 894 adapter->dbg.timeout_cmd_id =
898 adapter->dbg.last_cmd_id[adapter->dbg.last_cmd_index]; 895 adapter->dbg.last_cmd_id[adapter->dbg.last_cmd_index];
@@ -938,6 +935,14 @@ mwifiex_cmd_timeout_func(unsigned long function_context)
938 935
939 dev_err(adapter->dev, "ps_mode=%d ps_state=%d\n", 936 dev_err(adapter->dev, "ps_mode=%d ps_state=%d\n",
940 adapter->ps_mode, adapter->ps_state); 937 adapter->ps_mode, adapter->ps_state);
938
939 if (cmd_node->wait_q_enabled) {
940 adapter->cmd_wait_q.status = -ETIMEDOUT;
941 wake_up_interruptible(&adapter->cmd_wait_q.wait);
942 mwifiex_cancel_pending_ioctl(adapter);
943 /* reset cmd_sent flag to unblock new commands */
944 adapter->cmd_sent = false;
945 }
941 } 946 }
942 if (adapter->hw_status == MWIFIEX_HW_STATUS_INITIALIZING) 947 if (adapter->hw_status == MWIFIEX_HW_STATUS_INITIALIZING)
943 mwifiex_init_fw_complete(adapter); 948 mwifiex_init_fw_complete(adapter);
diff --git a/drivers/net/wireless/mwifiex/sdio.c b/drivers/net/wireless/mwifiex/sdio.c
index fc8a9bfa1248..82cf0fa2d9f6 100644
--- a/drivers/net/wireless/mwifiex/sdio.c
+++ b/drivers/net/wireless/mwifiex/sdio.c
@@ -161,7 +161,6 @@ static int mwifiex_sdio_suspend(struct device *dev)
161 struct sdio_mmc_card *card; 161 struct sdio_mmc_card *card;
162 struct mwifiex_adapter *adapter; 162 struct mwifiex_adapter *adapter;
163 mmc_pm_flag_t pm_flag = 0; 163 mmc_pm_flag_t pm_flag = 0;
164 int hs_actived = 0;
165 int i; 164 int i;
166 int ret = 0; 165 int ret = 0;
167 166
@@ -188,12 +187,14 @@ static int mwifiex_sdio_suspend(struct device *dev)
188 adapter = card->adapter; 187 adapter = card->adapter;
189 188
190 /* Enable the Host Sleep */ 189 /* Enable the Host Sleep */
191 hs_actived = mwifiex_enable_hs(adapter); 190 if (!mwifiex_enable_hs(adapter)) {
192 if (hs_actived) { 191 dev_err(adapter->dev, "cmd: failed to suspend\n");
193 pr_debug("cmd: suspend with MMC_PM_KEEP_POWER\n"); 192 return -EFAULT;
194 ret = sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER);
195 } 193 }
196 194
195 dev_dbg(adapter->dev, "cmd: suspend with MMC_PM_KEEP_POWER\n");
196 ret = sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER);
197
197 /* Indicate device suspended */ 198 /* Indicate device suspended */
198 adapter->is_suspended = true; 199 adapter->is_suspended = true;
199 200
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
index 9970c2b1b199..b7e6607e6b6d 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
@@ -297,6 +297,7 @@ static struct usb_device_id rtl8192c_usb_ids[] = {
297 /*=== Customer ID ===*/ 297 /*=== Customer ID ===*/
298 /****** 8188CU ********/ 298 /****** 8188CU ********/
299 {RTL_USB_DEVICE(0x050d, 0x1102, rtl92cu_hal_cfg)}, /*Belkin - Edimax*/ 299 {RTL_USB_DEVICE(0x050d, 0x1102, rtl92cu_hal_cfg)}, /*Belkin - Edimax*/
300 {RTL_USB_DEVICE(0x050d, 0x11f2, rtl92cu_hal_cfg)}, /*Belkin - ISY*/
300 {RTL_USB_DEVICE(0x06f8, 0xe033, rtl92cu_hal_cfg)}, /*Hercules - Edimax*/ 301 {RTL_USB_DEVICE(0x06f8, 0xe033, rtl92cu_hal_cfg)}, /*Hercules - Edimax*/
301 {RTL_USB_DEVICE(0x07b8, 0x8188, rtl92cu_hal_cfg)}, /*Abocom - Abocom*/ 302 {RTL_USB_DEVICE(0x07b8, 0x8188, rtl92cu_hal_cfg)}, /*Abocom - Abocom*/
302 {RTL_USB_DEVICE(0x07b8, 0x8189, rtl92cu_hal_cfg)}, /*Funai - Abocom*/ 303 {RTL_USB_DEVICE(0x07b8, 0x8189, rtl92cu_hal_cfg)}, /*Funai - Abocom*/
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index caa011008cd0..fc24eb9b3948 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -452,29 +452,85 @@ static void xennet_make_frags(struct sk_buff *skb, struct net_device *dev,
452 /* Grant backend access to each skb fragment page. */ 452 /* Grant backend access to each skb fragment page. */
453 for (i = 0; i < frags; i++) { 453 for (i = 0; i < frags; i++) {
454 skb_frag_t *frag = skb_shinfo(skb)->frags + i; 454 skb_frag_t *frag = skb_shinfo(skb)->frags + i;
455 struct page *page = skb_frag_page(frag);
455 456
456 tx->flags |= XEN_NETTXF_more_data; 457 len = skb_frag_size(frag);
458 offset = frag->page_offset;
457 459
458 id = get_id_from_freelist(&np->tx_skb_freelist, np->tx_skbs); 460 /* Data must not cross a page boundary. */
459 np->tx_skbs[id].skb = skb_get(skb); 461 BUG_ON(len + offset > PAGE_SIZE<<compound_order(page));
460 tx = RING_GET_REQUEST(&np->tx, prod++);
461 tx->id = id;
462 ref = gnttab_claim_grant_reference(&np->gref_tx_head);
463 BUG_ON((signed short)ref < 0);
464 462
465 mfn = pfn_to_mfn(page_to_pfn(skb_frag_page(frag))); 463 /* Skip unused frames from start of page */
466 gnttab_grant_foreign_access_ref(ref, np->xbdev->otherend_id, 464 page += offset >> PAGE_SHIFT;
467 mfn, GNTMAP_readonly); 465 offset &= ~PAGE_MASK;
468 466
469 tx->gref = np->grant_tx_ref[id] = ref; 467 while (len > 0) {
470 tx->offset = frag->page_offset; 468 unsigned long bytes;
471 tx->size = skb_frag_size(frag); 469
472 tx->flags = 0; 470 BUG_ON(offset >= PAGE_SIZE);
471
472 bytes = PAGE_SIZE - offset;
473 if (bytes > len)
474 bytes = len;
475
476 tx->flags |= XEN_NETTXF_more_data;
477
478 id = get_id_from_freelist(&np->tx_skb_freelist,
479 np->tx_skbs);
480 np->tx_skbs[id].skb = skb_get(skb);
481 tx = RING_GET_REQUEST(&np->tx, prod++);
482 tx->id = id;
483 ref = gnttab_claim_grant_reference(&np->gref_tx_head);
484 BUG_ON((signed short)ref < 0);
485
486 mfn = pfn_to_mfn(page_to_pfn(page));
487 gnttab_grant_foreign_access_ref(ref,
488 np->xbdev->otherend_id,
489 mfn, GNTMAP_readonly);
490
491 tx->gref = np->grant_tx_ref[id] = ref;
492 tx->offset = offset;
493 tx->size = bytes;
494 tx->flags = 0;
495
496 offset += bytes;
497 len -= bytes;
498
499 /* Next frame */
500 if (offset == PAGE_SIZE && len) {
501 BUG_ON(!PageCompound(page));
502 page++;
503 offset = 0;
504 }
505 }
473 } 506 }
474 507
475 np->tx.req_prod_pvt = prod; 508 np->tx.req_prod_pvt = prod;
476} 509}
477 510
511/*
512 * Count how many ring slots are required to send the frags of this
513 * skb. Each frag might be a compound page.
514 */
515static int xennet_count_skb_frag_slots(struct sk_buff *skb)
516{
517 int i, frags = skb_shinfo(skb)->nr_frags;
518 int pages = 0;
519
520 for (i = 0; i < frags; i++) {
521 skb_frag_t *frag = skb_shinfo(skb)->frags + i;
522 unsigned long size = skb_frag_size(frag);
523 unsigned long offset = frag->page_offset;
524
525 /* Skip unused frames from start of page */
526 offset &= ~PAGE_MASK;
527
528 pages += PFN_UP(offset + size);
529 }
530
531 return pages;
532}
533
478static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev) 534static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev)
479{ 535{
480 unsigned short id; 536 unsigned short id;
@@ -487,23 +543,23 @@ static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev)
487 grant_ref_t ref; 543 grant_ref_t ref;
488 unsigned long mfn; 544 unsigned long mfn;
489 int notify; 545 int notify;
490 int frags = skb_shinfo(skb)->nr_frags; 546 int slots;
491 unsigned int offset = offset_in_page(data); 547 unsigned int offset = offset_in_page(data);
492 unsigned int len = skb_headlen(skb); 548 unsigned int len = skb_headlen(skb);
493 unsigned long flags; 549 unsigned long flags;
494 550
495 frags += DIV_ROUND_UP(offset + len, PAGE_SIZE); 551 slots = DIV_ROUND_UP(offset + len, PAGE_SIZE) +
496 if (unlikely(frags > MAX_SKB_FRAGS + 1)) { 552 xennet_count_skb_frag_slots(skb);
497 printk(KERN_ALERT "xennet: skb rides the rocket: %d frags\n", 553 if (unlikely(slots > MAX_SKB_FRAGS + 1)) {
498 frags); 554 net_alert_ratelimited(
499 dump_stack(); 555 "xennet: skb rides the rocket: %d slots\n", slots);
500 goto drop; 556 goto drop;
501 } 557 }
502 558
503 spin_lock_irqsave(&np->tx_lock, flags); 559 spin_lock_irqsave(&np->tx_lock, flags);
504 560
505 if (unlikely(!netif_carrier_ok(dev) || 561 if (unlikely(!netif_carrier_ok(dev) ||
506 (frags > 1 && !xennet_can_sg(dev)) || 562 (slots > 1 && !xennet_can_sg(dev)) ||
507 netif_needs_gso(skb, netif_skb_features(skb)))) { 563 netif_needs_gso(skb, netif_skb_features(skb)))) {
508 spin_unlock_irqrestore(&np->tx_lock, flags); 564 spin_unlock_irqrestore(&np->tx_lock, flags);
509 goto drop; 565 goto drop;
diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c
index 97c440a8cd61..30ae18a03a9c 100644
--- a/drivers/nfc/pn533.c
+++ b/drivers/nfc/pn533.c
@@ -698,13 +698,14 @@ static void pn533_wq_cmd(struct work_struct *work)
698 698
699 cmd = list_first_entry(&dev->cmd_queue, struct pn533_cmd, queue); 699 cmd = list_first_entry(&dev->cmd_queue, struct pn533_cmd, queue);
700 700
701 list_del(&cmd->queue);
702
701 mutex_unlock(&dev->cmd_lock); 703 mutex_unlock(&dev->cmd_lock);
702 704
703 __pn533_send_cmd_frame_async(dev, cmd->out_frame, cmd->in_frame, 705 __pn533_send_cmd_frame_async(dev, cmd->out_frame, cmd->in_frame,
704 cmd->in_frame_len, cmd->cmd_complete, 706 cmd->in_frame_len, cmd->cmd_complete,
705 cmd->arg, cmd->flags); 707 cmd->arg, cmd->flags);
706 708
707 list_del(&cmd->queue);
708 kfree(cmd); 709 kfree(cmd);
709} 710}
710 711
@@ -1678,11 +1679,14 @@ static void pn533_deactivate_target(struct nfc_dev *nfc_dev,
1678static int pn533_in_dep_link_up_complete(struct pn533 *dev, void *arg, 1679static int pn533_in_dep_link_up_complete(struct pn533 *dev, void *arg,
1679 u8 *params, int params_len) 1680 u8 *params, int params_len)
1680{ 1681{
1681 struct pn533_cmd_jump_dep *cmd;
1682 struct pn533_cmd_jump_dep_response *resp; 1682 struct pn533_cmd_jump_dep_response *resp;
1683 struct nfc_target nfc_target; 1683 struct nfc_target nfc_target;
1684 u8 target_gt_len; 1684 u8 target_gt_len;
1685 int rc; 1685 int rc;
1686 struct pn533_cmd_jump_dep *cmd = (struct pn533_cmd_jump_dep *)arg;
1687 u8 active = cmd->active;
1688
1689 kfree(arg);
1686 1690
1687 if (params_len == -ENOENT) { 1691 if (params_len == -ENOENT) {
1688 nfc_dev_dbg(&dev->interface->dev, ""); 1692 nfc_dev_dbg(&dev->interface->dev, "");
@@ -1704,7 +1708,6 @@ static int pn533_in_dep_link_up_complete(struct pn533 *dev, void *arg,
1704 } 1708 }
1705 1709
1706 resp = (struct pn533_cmd_jump_dep_response *) params; 1710 resp = (struct pn533_cmd_jump_dep_response *) params;
1707 cmd = (struct pn533_cmd_jump_dep *) arg;
1708 rc = resp->status & PN533_CMD_RET_MASK; 1711 rc = resp->status & PN533_CMD_RET_MASK;
1709 if (rc != PN533_CMD_RET_SUCCESS) { 1712 if (rc != PN533_CMD_RET_SUCCESS) {
1710 nfc_dev_err(&dev->interface->dev, 1713 nfc_dev_err(&dev->interface->dev,
@@ -1734,7 +1737,7 @@ static int pn533_in_dep_link_up_complete(struct pn533 *dev, void *arg,
1734 if (rc == 0) 1737 if (rc == 0)
1735 rc = nfc_dep_link_is_up(dev->nfc_dev, 1738 rc = nfc_dep_link_is_up(dev->nfc_dev,
1736 dev->nfc_dev->targets[0].idx, 1739 dev->nfc_dev->targets[0].idx,
1737 !cmd->active, NFC_RF_INITIATOR); 1740 !active, NFC_RF_INITIATOR);
1738 1741
1739 return 0; 1742 return 0;
1740} 1743}
@@ -1819,12 +1822,8 @@ static int pn533_dep_link_up(struct nfc_dev *nfc_dev, struct nfc_target *target,
1819 rc = pn533_send_cmd_frame_async(dev, dev->out_frame, dev->in_frame, 1822 rc = pn533_send_cmd_frame_async(dev, dev->out_frame, dev->in_frame,
1820 dev->in_maxlen, pn533_in_dep_link_up_complete, 1823 dev->in_maxlen, pn533_in_dep_link_up_complete,
1821 cmd, GFP_KERNEL); 1824 cmd, GFP_KERNEL);
1822 if (rc) 1825 if (rc < 0)
1823 goto out; 1826 kfree(cmd);
1824
1825
1826out:
1827 kfree(cmd);
1828 1827
1829 return rc; 1828 return rc;
1830} 1829}
@@ -2078,8 +2077,12 @@ error:
2078static int pn533_tm_send_complete(struct pn533 *dev, void *arg, 2077static int pn533_tm_send_complete(struct pn533 *dev, void *arg,
2079 u8 *params, int params_len) 2078 u8 *params, int params_len)
2080{ 2079{
2080 struct sk_buff *skb_out = arg;
2081
2081 nfc_dev_dbg(&dev->interface->dev, "%s", __func__); 2082 nfc_dev_dbg(&dev->interface->dev, "%s", __func__);
2082 2083
2084 dev_kfree_skb(skb_out);
2085
2083 if (params_len < 0) { 2086 if (params_len < 0) {
2084 nfc_dev_err(&dev->interface->dev, 2087 nfc_dev_err(&dev->interface->dev,
2085 "Error %d when sending data", 2088 "Error %d when sending data",
@@ -2117,7 +2120,7 @@ static int pn533_tm_send(struct nfc_dev *nfc_dev, struct sk_buff *skb)
2117 2120
2118 rc = pn533_send_cmd_frame_async(dev, out_frame, dev->in_frame, 2121 rc = pn533_send_cmd_frame_async(dev, out_frame, dev->in_frame,
2119 dev->in_maxlen, pn533_tm_send_complete, 2122 dev->in_maxlen, pn533_tm_send_complete,
2120 NULL, GFP_KERNEL); 2123 skb, GFP_KERNEL);
2121 if (rc) { 2124 if (rc) {
2122 nfc_dev_err(&dev->interface->dev, 2125 nfc_dev_err(&dev->interface->dev,
2123 "Error %d when trying to send data", rc); 2126 "Error %d when trying to send data", rc);
diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index d96caefd914a..aeecf0f72cad 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -178,7 +178,7 @@ config PINCTRL_COH901
178 ports of 8 GPIO pins each. 178 ports of 8 GPIO pins each.
179 179
180config PINCTRL_SAMSUNG 180config PINCTRL_SAMSUNG
181 bool "Samsung pinctrl driver" 181 bool
182 depends on OF && GPIOLIB 182 depends on OF && GPIOLIB
183 select PINMUX 183 select PINMUX
184 select PINCONF 184 select PINCONF
diff --git a/drivers/rapidio/rio.c b/drivers/rapidio/rio.c
index c17ae22567e0..0c6fcb461faf 100644
--- a/drivers/rapidio/rio.c
+++ b/drivers/rapidio/rio.c
@@ -401,7 +401,7 @@ EXPORT_SYMBOL_GPL(rio_release_inb_pwrite);
401/** 401/**
402 * rio_map_inb_region -- Map inbound memory region. 402 * rio_map_inb_region -- Map inbound memory region.
403 * @mport: Master port. 403 * @mport: Master port.
404 * @lstart: physical address of memory region to be mapped 404 * @local: physical address of memory region to be mapped
405 * @rbase: RIO base address assigned to this window 405 * @rbase: RIO base address assigned to this window
406 * @size: Size of the memory region 406 * @size: Size of the memory region
407 * @rflags: Flags for mapping. 407 * @rflags: Flags for mapping.
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 5c4829cba6a6..e872c8be080e 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1381,22 +1381,14 @@ struct regulator *regulator_get_exclusive(struct device *dev, const char *id)
1381} 1381}
1382EXPORT_SYMBOL_GPL(regulator_get_exclusive); 1382EXPORT_SYMBOL_GPL(regulator_get_exclusive);
1383 1383
1384/** 1384/* Locks held by regulator_put() */
1385 * regulator_put - "free" the regulator source 1385static void _regulator_put(struct regulator *regulator)
1386 * @regulator: regulator source
1387 *
1388 * Note: drivers must ensure that all regulator_enable calls made on this
1389 * regulator source are balanced by regulator_disable calls prior to calling
1390 * this function.
1391 */
1392void regulator_put(struct regulator *regulator)
1393{ 1386{
1394 struct regulator_dev *rdev; 1387 struct regulator_dev *rdev;
1395 1388
1396 if (regulator == NULL || IS_ERR(regulator)) 1389 if (regulator == NULL || IS_ERR(regulator))
1397 return; 1390 return;
1398 1391
1399 mutex_lock(&regulator_list_mutex);
1400 rdev = regulator->rdev; 1392 rdev = regulator->rdev;
1401 1393
1402 debugfs_remove_recursive(regulator->debugfs); 1394 debugfs_remove_recursive(regulator->debugfs);
@@ -1412,6 +1404,20 @@ void regulator_put(struct regulator *regulator)
1412 rdev->exclusive = 0; 1404 rdev->exclusive = 0;
1413 1405
1414 module_put(rdev->owner); 1406 module_put(rdev->owner);
1407}
1408
1409/**
1410 * regulator_put - "free" the regulator source
1411 * @regulator: regulator source
1412 *
1413 * Note: drivers must ensure that all regulator_enable calls made on this
1414 * regulator source are balanced by regulator_disable calls prior to calling
1415 * this function.
1416 */
1417void regulator_put(struct regulator *regulator)
1418{
1419 mutex_lock(&regulator_list_mutex);
1420 _regulator_put(regulator);
1415 mutex_unlock(&regulator_list_mutex); 1421 mutex_unlock(&regulator_list_mutex);
1416} 1422}
1417EXPORT_SYMBOL_GPL(regulator_put); 1423EXPORT_SYMBOL_GPL(regulator_put);
@@ -1974,7 +1980,7 @@ int regulator_is_supported_voltage(struct regulator *regulator,
1974 if (!(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE)) { 1980 if (!(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE)) {
1975 ret = regulator_get_voltage(regulator); 1981 ret = regulator_get_voltage(regulator);
1976 if (ret >= 0) 1982 if (ret >= 0)
1977 return (min_uV >= ret && ret <= max_uV); 1983 return (min_uV <= ret && ret <= max_uV);
1978 else 1984 else
1979 return ret; 1985 return ret;
1980 } 1986 }
@@ -3365,7 +3371,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
3365 if (ret != 0) { 3371 if (ret != 0) {
3366 rdev_err(rdev, "Failed to request enable GPIO%d: %d\n", 3372 rdev_err(rdev, "Failed to request enable GPIO%d: %d\n",
3367 config->ena_gpio, ret); 3373 config->ena_gpio, ret);
3368 goto clean; 3374 goto wash;
3369 } 3375 }
3370 3376
3371 rdev->ena_gpio = config->ena_gpio; 3377 rdev->ena_gpio = config->ena_gpio;
@@ -3445,10 +3451,11 @@ unset_supplies:
3445 3451
3446scrub: 3452scrub:
3447 if (rdev->supply) 3453 if (rdev->supply)
3448 regulator_put(rdev->supply); 3454 _regulator_put(rdev->supply);
3449 if (rdev->ena_gpio) 3455 if (rdev->ena_gpio)
3450 gpio_free(rdev->ena_gpio); 3456 gpio_free(rdev->ena_gpio);
3451 kfree(rdev->constraints); 3457 kfree(rdev->constraints);
3458wash:
3452 device_unregister(&rdev->dev); 3459 device_unregister(&rdev->dev);
3453 /* device core frees rdev */ 3460 /* device core frees rdev */
3454 rdev = ERR_PTR(ret); 3461 rdev = ERR_PTR(ret);
diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c
index 9ffb6d5f17aa..4ed343e4eb41 100644
--- a/drivers/s390/char/con3215.c
+++ b/drivers/s390/char/con3215.c
@@ -44,7 +44,6 @@
44#define RAW3215_NR_CCWS 3 44#define RAW3215_NR_CCWS 3
45#define RAW3215_TIMEOUT HZ/10 /* time for delayed output */ 45#define RAW3215_TIMEOUT HZ/10 /* time for delayed output */
46 46
47#define RAW3215_FIXED 1 /* 3215 console device is not be freed */
48#define RAW3215_WORKING 4 /* set if a request is being worked on */ 47#define RAW3215_WORKING 4 /* set if a request is being worked on */
49#define RAW3215_THROTTLED 8 /* set if reading is disabled */ 48#define RAW3215_THROTTLED 8 /* set if reading is disabled */
50#define RAW3215_STOPPED 16 /* set if writing is disabled */ 49#define RAW3215_STOPPED 16 /* set if writing is disabled */
@@ -339,8 +338,10 @@ static void raw3215_wakeup(unsigned long data)
339 struct tty_struct *tty; 338 struct tty_struct *tty;
340 339
341 tty = tty_port_tty_get(&raw->port); 340 tty = tty_port_tty_get(&raw->port);
342 tty_wakeup(tty); 341 if (tty) {
343 tty_kref_put(tty); 342 tty_wakeup(tty);
343 tty_kref_put(tty);
344 }
344} 345}
345 346
346/* 347/*
@@ -629,8 +630,7 @@ static void raw3215_shutdown(struct raw3215_info *raw)
629 DECLARE_WAITQUEUE(wait, current); 630 DECLARE_WAITQUEUE(wait, current);
630 unsigned long flags; 631 unsigned long flags;
631 632
632 if (!(raw->port.flags & ASYNC_INITIALIZED) || 633 if (!(raw->port.flags & ASYNC_INITIALIZED))
633 (raw->flags & RAW3215_FIXED))
634 return; 634 return;
635 /* Wait for outstanding requests, then free irq */ 635 /* Wait for outstanding requests, then free irq */
636 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); 636 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags);
@@ -926,8 +926,6 @@ static int __init con3215_init(void)
926 dev_set_drvdata(&cdev->dev, raw); 926 dev_set_drvdata(&cdev->dev, raw);
927 cdev->handler = raw3215_irq; 927 cdev->handler = raw3215_irq;
928 928
929 raw->flags |= RAW3215_FIXED;
930
931 /* Request the console irq */ 929 /* Request the console irq */
932 if (raw3215_startup(raw) != 0) { 930 if (raw3215_startup(raw) != 0) {
933 raw3215_free_info(raw); 931 raw3215_free_info(raw);
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
index 3e25d3150456..4d6ba00d0047 100644
--- a/drivers/s390/net/qeth_core_main.c
+++ b/drivers/s390/net/qeth_core_main.c
@@ -2942,13 +2942,33 @@ static int qeth_query_ipassists_cb(struct qeth_card *card,
2942 QETH_DBF_TEXT(SETUP, 2, "qipasscb"); 2942 QETH_DBF_TEXT(SETUP, 2, "qipasscb");
2943 2943
2944 cmd = (struct qeth_ipa_cmd *) data; 2944 cmd = (struct qeth_ipa_cmd *) data;
2945
2946 switch (cmd->hdr.return_code) {
2947 case IPA_RC_NOTSUPP:
2948 case IPA_RC_L2_UNSUPPORTED_CMD:
2949 QETH_DBF_TEXT(SETUP, 2, "ipaunsup");
2950 card->options.ipa4.supported_funcs |= IPA_SETADAPTERPARMS;
2951 card->options.ipa6.supported_funcs |= IPA_SETADAPTERPARMS;
2952 return -0;
2953 default:
2954 if (cmd->hdr.return_code) {
2955 QETH_DBF_MESSAGE(1, "%s IPA_CMD_QIPASSIST: Unhandled "
2956 "rc=%d\n",
2957 dev_name(&card->gdev->dev),
2958 cmd->hdr.return_code);
2959 return 0;
2960 }
2961 }
2962
2945 if (cmd->hdr.prot_version == QETH_PROT_IPV4) { 2963 if (cmd->hdr.prot_version == QETH_PROT_IPV4) {
2946 card->options.ipa4.supported_funcs = cmd->hdr.ipa_supported; 2964 card->options.ipa4.supported_funcs = cmd->hdr.ipa_supported;
2947 card->options.ipa4.enabled_funcs = cmd->hdr.ipa_enabled; 2965 card->options.ipa4.enabled_funcs = cmd->hdr.ipa_enabled;
2948 } else { 2966 } else if (cmd->hdr.prot_version == QETH_PROT_IPV6) {
2949 card->options.ipa6.supported_funcs = cmd->hdr.ipa_supported; 2967 card->options.ipa6.supported_funcs = cmd->hdr.ipa_supported;
2950 card->options.ipa6.enabled_funcs = cmd->hdr.ipa_enabled; 2968 card->options.ipa6.enabled_funcs = cmd->hdr.ipa_enabled;
2951 } 2969 } else
2970 QETH_DBF_MESSAGE(1, "%s IPA_CMD_QIPASSIST: Flawed LIC detected"
2971 "\n", dev_name(&card->gdev->dev));
2952 QETH_DBF_TEXT(SETUP, 2, "suppenbl"); 2972 QETH_DBF_TEXT(SETUP, 2, "suppenbl");
2953 QETH_DBF_TEXT_(SETUP, 2, "%08x", (__u32)cmd->hdr.ipa_supported); 2973 QETH_DBF_TEXT_(SETUP, 2, "%08x", (__u32)cmd->hdr.ipa_supported);
2954 QETH_DBF_TEXT_(SETUP, 2, "%08x", (__u32)cmd->hdr.ipa_enabled); 2974 QETH_DBF_TEXT_(SETUP, 2, "%08x", (__u32)cmd->hdr.ipa_enabled);
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
index e67e0258aec5..fddb62654b6a 100644
--- a/drivers/s390/net/qeth_l2_main.c
+++ b/drivers/s390/net/qeth_l2_main.c
@@ -626,10 +626,13 @@ static int qeth_l2_request_initial_mac(struct qeth_card *card)
626 QETH_DBF_TEXT(SETUP, 2, "doL2init"); 626 QETH_DBF_TEXT(SETUP, 2, "doL2init");
627 QETH_DBF_TEXT_(SETUP, 2, "doL2%s", CARD_BUS_ID(card)); 627 QETH_DBF_TEXT_(SETUP, 2, "doL2%s", CARD_BUS_ID(card));
628 628
629 rc = qeth_query_setadapterparms(card); 629 if (qeth_is_supported(card, IPA_SETADAPTERPARMS)) {
630 if (rc) { 630 rc = qeth_query_setadapterparms(card);
631 QETH_DBF_MESSAGE(2, "could not query adapter parameters on " 631 if (rc) {
632 "device %s: x%x\n", CARD_BUS_ID(card), rc); 632 QETH_DBF_MESSAGE(2, "could not query adapter "
633 "parameters on device %s: x%x\n",
634 CARD_BUS_ID(card), rc);
635 }
633 } 636 }
634 637
635 if (card->info.type == QETH_CARD_TYPE_IQD || 638 if (card->info.type == QETH_CARD_TYPE_IQD ||
@@ -676,7 +679,7 @@ static int qeth_l2_set_mac_address(struct net_device *dev, void *p)
676 return -ERESTARTSYS; 679 return -ERESTARTSYS;
677 } 680 }
678 rc = qeth_l2_send_delmac(card, &card->dev->dev_addr[0]); 681 rc = qeth_l2_send_delmac(card, &card->dev->dev_addr[0]);
679 if (!rc) 682 if (!rc || (rc == IPA_RC_L2_MAC_NOT_FOUND))
680 rc = qeth_l2_send_setmac(card, addr->sa_data); 683 rc = qeth_l2_send_setmac(card, addr->sa_data);
681 return rc ? -EINVAL : 0; 684 return rc ? -EINVAL : 0;
682} 685}
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c
index c1bafc3f3fb1..9594ab62702b 100644
--- a/drivers/scsi/isci/request.c
+++ b/drivers/scsi/isci/request.c
@@ -1972,7 +1972,7 @@ sci_io_request_frame_handler(struct isci_request *ireq,
1972 frame_index, 1972 frame_index,
1973 (void **)&frame_buffer); 1973 (void **)&frame_buffer);
1974 1974
1975 sci_controller_copy_sata_response(&ireq->stp.req, 1975 sci_controller_copy_sata_response(&ireq->stp.rsp,
1976 frame_header, 1976 frame_header,
1977 frame_buffer); 1977 frame_buffer);
1978 1978
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 2936b447cae9..2c0d0ec8150b 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -55,6 +55,7 @@
55#include <linux/cpu.h> 55#include <linux/cpu.h>
56#include <linux/mutex.h> 56#include <linux/mutex.h>
57#include <linux/async.h> 57#include <linux/async.h>
58#include <asm/unaligned.h>
58 59
59#include <scsi/scsi.h> 60#include <scsi/scsi.h>
60#include <scsi/scsi_cmnd.h> 61#include <scsi/scsi_cmnd.h>
@@ -1062,6 +1063,50 @@ int scsi_get_vpd_page(struct scsi_device *sdev, u8 page, unsigned char *buf,
1062EXPORT_SYMBOL_GPL(scsi_get_vpd_page); 1063EXPORT_SYMBOL_GPL(scsi_get_vpd_page);
1063 1064
1064/** 1065/**
1066 * scsi_report_opcode - Find out if a given command opcode is supported
1067 * @sdev: scsi device to query
1068 * @buffer: scratch buffer (must be at least 20 bytes long)
1069 * @len: length of buffer
1070 * @opcode: opcode for command to look up
1071 *
1072 * Uses the REPORT SUPPORTED OPERATION CODES to look up the given
1073 * opcode. Returns 0 if RSOC fails or if the command opcode is
1074 * unsupported. Returns 1 if the device claims to support the command.
1075 */
1076int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer,
1077 unsigned int len, unsigned char opcode)
1078{
1079 unsigned char cmd[16];
1080 struct scsi_sense_hdr sshdr;
1081 int result;
1082
1083 if (sdev->no_report_opcodes || sdev->scsi_level < SCSI_SPC_3)
1084 return 0;
1085
1086 memset(cmd, 0, 16);
1087 cmd[0] = MAINTENANCE_IN;
1088 cmd[1] = MI_REPORT_SUPPORTED_OPERATION_CODES;
1089 cmd[2] = 1; /* One command format */
1090 cmd[3] = opcode;
1091 put_unaligned_be32(len, &cmd[6]);
1092 memset(buffer, 0, len);
1093
1094 result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, len,
1095 &sshdr, 30 * HZ, 3, NULL);
1096
1097 if (result && scsi_sense_valid(&sshdr) &&
1098 sshdr.sense_key == ILLEGAL_REQUEST &&
1099 (sshdr.asc == 0x20 || sshdr.asc == 0x24) && sshdr.ascq == 0x00)
1100 return 0;
1101
1102 if ((buffer[1] & 3) == 3) /* Command supported */
1103 return 1;
1104
1105 return 0;
1106}
1107EXPORT_SYMBOL(scsi_report_opcode);
1108
1109/**
1065 * scsi_device_get - get an additional reference to a scsi_device 1110 * scsi_device_get - get an additional reference to a scsi_device
1066 * @sdev: device to get a reference to 1111 * @sdev: device to get a reference to
1067 * 1112 *
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index da36a3a81a9e..9032e910bca3 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -900,11 +900,23 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
900 action = ACTION_FAIL; 900 action = ACTION_FAIL;
901 error = -EILSEQ; 901 error = -EILSEQ;
902 /* INVALID COMMAND OPCODE or INVALID FIELD IN CDB */ 902 /* INVALID COMMAND OPCODE or INVALID FIELD IN CDB */
903 } else if ((sshdr.asc == 0x20 || sshdr.asc == 0x24) && 903 } else if (sshdr.asc == 0x20 || sshdr.asc == 0x24) {
904 (cmd->cmnd[0] == UNMAP || 904 switch (cmd->cmnd[0]) {
905 cmd->cmnd[0] == WRITE_SAME_16 || 905 case UNMAP:
906 cmd->cmnd[0] == WRITE_SAME)) { 906 description = "Discard failure";
907 description = "Discard failure"; 907 break;
908 case WRITE_SAME:
909 case WRITE_SAME_16:
910 if (cmd->cmnd[1] & 0x8)
911 description = "Discard failure";
912 else
913 description =
914 "Write same failure";
915 break;
916 default:
917 description = "Invalid command failure";
918 break;
919 }
908 action = ACTION_FAIL; 920 action = ACTION_FAIL;
909 error = -EREMOTEIO; 921 error = -EREMOTEIO;
910 } else 922 } else
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 12f6fdfc1147..352bc77b7c88 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -99,6 +99,7 @@ MODULE_ALIAS_SCSI_DEVICE(TYPE_RBC);
99#endif 99#endif
100 100
101static void sd_config_discard(struct scsi_disk *, unsigned int); 101static void sd_config_discard(struct scsi_disk *, unsigned int);
102static void sd_config_write_same(struct scsi_disk *);
102static int sd_revalidate_disk(struct gendisk *); 103static int sd_revalidate_disk(struct gendisk *);
103static void sd_unlock_native_capacity(struct gendisk *disk); 104static void sd_unlock_native_capacity(struct gendisk *disk);
104static int sd_probe(struct device *); 105static int sd_probe(struct device *);
@@ -395,6 +396,45 @@ sd_store_max_medium_access_timeouts(struct device *dev,
395 return err ? err : count; 396 return err ? err : count;
396} 397}
397 398
399static ssize_t
400sd_show_write_same_blocks(struct device *dev, struct device_attribute *attr,
401 char *buf)
402{
403 struct scsi_disk *sdkp = to_scsi_disk(dev);
404
405 return snprintf(buf, 20, "%u\n", sdkp->max_ws_blocks);
406}
407
408static ssize_t
409sd_store_write_same_blocks(struct device *dev, struct device_attribute *attr,
410 const char *buf, size_t count)
411{
412 struct scsi_disk *sdkp = to_scsi_disk(dev);
413 struct scsi_device *sdp = sdkp->device;
414 unsigned long max;
415 int err;
416
417 if (!capable(CAP_SYS_ADMIN))
418 return -EACCES;
419
420 if (sdp->type != TYPE_DISK)
421 return -EINVAL;
422
423 err = kstrtoul(buf, 10, &max);
424
425 if (err)
426 return err;
427
428 if (max == 0)
429 sdp->no_write_same = 1;
430 else if (max <= SD_MAX_WS16_BLOCKS)
431 sdkp->max_ws_blocks = max;
432
433 sd_config_write_same(sdkp);
434
435 return count;
436}
437
398static struct device_attribute sd_disk_attrs[] = { 438static struct device_attribute sd_disk_attrs[] = {
399 __ATTR(cache_type, S_IRUGO|S_IWUSR, sd_show_cache_type, 439 __ATTR(cache_type, S_IRUGO|S_IWUSR, sd_show_cache_type,
400 sd_store_cache_type), 440 sd_store_cache_type),
@@ -410,6 +450,8 @@ static struct device_attribute sd_disk_attrs[] = {
410 __ATTR(thin_provisioning, S_IRUGO, sd_show_thin_provisioning, NULL), 450 __ATTR(thin_provisioning, S_IRUGO, sd_show_thin_provisioning, NULL),
411 __ATTR(provisioning_mode, S_IRUGO|S_IWUSR, sd_show_provisioning_mode, 451 __ATTR(provisioning_mode, S_IRUGO|S_IWUSR, sd_show_provisioning_mode,
412 sd_store_provisioning_mode), 452 sd_store_provisioning_mode),
453 __ATTR(max_write_same_blocks, S_IRUGO|S_IWUSR,
454 sd_show_write_same_blocks, sd_store_write_same_blocks),
413 __ATTR(max_medium_access_timeouts, S_IRUGO|S_IWUSR, 455 __ATTR(max_medium_access_timeouts, S_IRUGO|S_IWUSR,
414 sd_show_max_medium_access_timeouts, 456 sd_show_max_medium_access_timeouts,
415 sd_store_max_medium_access_timeouts), 457 sd_store_max_medium_access_timeouts),
@@ -561,19 +603,23 @@ static void sd_config_discard(struct scsi_disk *sdkp, unsigned int mode)
561 return; 603 return;
562 604
563 case SD_LBP_UNMAP: 605 case SD_LBP_UNMAP:
564 max_blocks = min_not_zero(sdkp->max_unmap_blocks, 0xffffffff); 606 max_blocks = min_not_zero(sdkp->max_unmap_blocks,
607 (u32)SD_MAX_WS16_BLOCKS);
565 break; 608 break;
566 609
567 case SD_LBP_WS16: 610 case SD_LBP_WS16:
568 max_blocks = min_not_zero(sdkp->max_ws_blocks, 0xffffffff); 611 max_blocks = min_not_zero(sdkp->max_ws_blocks,
612 (u32)SD_MAX_WS16_BLOCKS);
569 break; 613 break;
570 614
571 case SD_LBP_WS10: 615 case SD_LBP_WS10:
572 max_blocks = min_not_zero(sdkp->max_ws_blocks, (u32)0xffff); 616 max_blocks = min_not_zero(sdkp->max_ws_blocks,
617 (u32)SD_MAX_WS10_BLOCKS);
573 break; 618 break;
574 619
575 case SD_LBP_ZERO: 620 case SD_LBP_ZERO:
576 max_blocks = min_not_zero(sdkp->max_ws_blocks, (u32)0xffff); 621 max_blocks = min_not_zero(sdkp->max_ws_blocks,
622 (u32)SD_MAX_WS10_BLOCKS);
577 q->limits.discard_zeroes_data = 1; 623 q->limits.discard_zeroes_data = 1;
578 break; 624 break;
579 } 625 }
@@ -583,29 +629,26 @@ static void sd_config_discard(struct scsi_disk *sdkp, unsigned int mode)
583} 629}
584 630
585/** 631/**
586 * scsi_setup_discard_cmnd - unmap blocks on thinly provisioned device 632 * sd_setup_discard_cmnd - unmap blocks on thinly provisioned device
587 * @sdp: scsi device to operate one 633 * @sdp: scsi device to operate one
588 * @rq: Request to prepare 634 * @rq: Request to prepare
589 * 635 *
590 * Will issue either UNMAP or WRITE SAME(16) depending on preference 636 * Will issue either UNMAP or WRITE SAME(16) depending on preference
591 * indicated by target device. 637 * indicated by target device.
592 **/ 638 **/
593static int scsi_setup_discard_cmnd(struct scsi_device *sdp, struct request *rq) 639static int sd_setup_discard_cmnd(struct scsi_device *sdp, struct request *rq)
594{ 640{
595 struct scsi_disk *sdkp = scsi_disk(rq->rq_disk); 641 struct scsi_disk *sdkp = scsi_disk(rq->rq_disk);
596 struct bio *bio = rq->bio; 642 sector_t sector = blk_rq_pos(rq);
597 sector_t sector = bio->bi_sector; 643 unsigned int nr_sectors = blk_rq_sectors(rq);
598 unsigned int nr_sectors = bio_sectors(bio); 644 unsigned int nr_bytes = blk_rq_bytes(rq);
599 unsigned int len; 645 unsigned int len;
600 int ret; 646 int ret;
601 char *buf; 647 char *buf;
602 struct page *page; 648 struct page *page;
603 649
604 if (sdkp->device->sector_size == 4096) { 650 sector >>= ilog2(sdp->sector_size) - 9;
605 sector >>= 3; 651 nr_sectors >>= ilog2(sdp->sector_size) - 9;
606 nr_sectors >>= 3;
607 }
608
609 rq->timeout = SD_TIMEOUT; 652 rq->timeout = SD_TIMEOUT;
610 653
611 memset(rq->cmd, 0, rq->cmd_len); 654 memset(rq->cmd, 0, rq->cmd_len);
@@ -660,6 +703,7 @@ static int scsi_setup_discard_cmnd(struct scsi_device *sdp, struct request *rq)
660 blk_add_request_payload(rq, page, len); 703 blk_add_request_payload(rq, page, len);
661 ret = scsi_setup_blk_pc_cmnd(sdp, rq); 704 ret = scsi_setup_blk_pc_cmnd(sdp, rq);
662 rq->buffer = page_address(page); 705 rq->buffer = page_address(page);
706 rq->__data_len = nr_bytes;
663 707
664out: 708out:
665 if (ret != BLKPREP_OK) { 709 if (ret != BLKPREP_OK) {
@@ -669,6 +713,83 @@ out:
669 return ret; 713 return ret;
670} 714}
671 715
716static void sd_config_write_same(struct scsi_disk *sdkp)
717{
718 struct request_queue *q = sdkp->disk->queue;
719 unsigned int logical_block_size = sdkp->device->sector_size;
720 unsigned int blocks = 0;
721
722 if (sdkp->device->no_write_same) {
723 sdkp->max_ws_blocks = 0;
724 goto out;
725 }
726
727 /* Some devices can not handle block counts above 0xffff despite
728 * supporting WRITE SAME(16). Consequently we default to 64k
729 * blocks per I/O unless the device explicitly advertises a
730 * bigger limit.
731 */
732 if (sdkp->max_ws_blocks == 0)
733 sdkp->max_ws_blocks = SD_MAX_WS10_BLOCKS;
734
735 if (sdkp->ws16 || sdkp->max_ws_blocks > SD_MAX_WS10_BLOCKS)
736 blocks = min_not_zero(sdkp->max_ws_blocks,
737 (u32)SD_MAX_WS16_BLOCKS);
738 else
739 blocks = min_not_zero(sdkp->max_ws_blocks,
740 (u32)SD_MAX_WS10_BLOCKS);
741
742out:
743 blk_queue_max_write_same_sectors(q, blocks * (logical_block_size >> 9));
744}
745
746/**
747 * sd_setup_write_same_cmnd - write the same data to multiple blocks
748 * @sdp: scsi device to operate one
749 * @rq: Request to prepare
750 *
751 * Will issue either WRITE SAME(10) or WRITE SAME(16) depending on
752 * preference indicated by target device.
753 **/
754static int sd_setup_write_same_cmnd(struct scsi_device *sdp, struct request *rq)
755{
756 struct scsi_disk *sdkp = scsi_disk(rq->rq_disk);
757 struct bio *bio = rq->bio;
758 sector_t sector = blk_rq_pos(rq);
759 unsigned int nr_sectors = blk_rq_sectors(rq);
760 unsigned int nr_bytes = blk_rq_bytes(rq);
761 int ret;
762
763 if (sdkp->device->no_write_same)
764 return BLKPREP_KILL;
765
766 BUG_ON(bio_offset(bio) || bio_iovec(bio)->bv_len != sdp->sector_size);
767
768 sector >>= ilog2(sdp->sector_size) - 9;
769 nr_sectors >>= ilog2(sdp->sector_size) - 9;
770
771 rq->__data_len = sdp->sector_size;
772 rq->timeout = SD_WRITE_SAME_TIMEOUT;
773 memset(rq->cmd, 0, rq->cmd_len);
774
775 if (sdkp->ws16 || sector > 0xffffffff || nr_sectors > 0xffff) {
776 rq->cmd_len = 16;
777 rq->cmd[0] = WRITE_SAME_16;
778 put_unaligned_be64(sector, &rq->cmd[2]);
779 put_unaligned_be32(nr_sectors, &rq->cmd[10]);
780 } else {
781 rq->cmd_len = 10;
782 rq->cmd[0] = WRITE_SAME;
783 put_unaligned_be32(sector, &rq->cmd[2]);
784 put_unaligned_be16(nr_sectors, &rq->cmd[7]);
785 }
786
787 ret = scsi_setup_blk_pc_cmnd(sdp, rq);
788 rq->__data_len = nr_bytes;
789
790 return ret;
791}
792
672static int scsi_setup_flush_cmnd(struct scsi_device *sdp, struct request *rq) 793static int scsi_setup_flush_cmnd(struct scsi_device *sdp, struct request *rq)
673{ 794{
674 rq->timeout = SD_FLUSH_TIMEOUT; 795 rq->timeout = SD_FLUSH_TIMEOUT;
@@ -712,7 +833,10 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
712 * block PC requests to make life easier. 833 * block PC requests to make life easier.
713 */ 834 */
714 if (rq->cmd_flags & REQ_DISCARD) { 835 if (rq->cmd_flags & REQ_DISCARD) {
715 ret = scsi_setup_discard_cmnd(sdp, rq); 836 ret = sd_setup_discard_cmnd(sdp, rq);
837 goto out;
838 } else if (rq->cmd_flags & REQ_WRITE_SAME) {
839 ret = sd_setup_write_same_cmnd(sdp, rq);
716 goto out; 840 goto out;
717 } else if (rq->cmd_flags & REQ_FLUSH) { 841 } else if (rq->cmd_flags & REQ_FLUSH) {
718 ret = scsi_setup_flush_cmnd(sdp, rq); 842 ret = scsi_setup_flush_cmnd(sdp, rq);
@@ -1482,12 +1606,21 @@ static int sd_done(struct scsi_cmnd *SCpnt)
1482 unsigned int good_bytes = result ? 0 : scsi_bufflen(SCpnt); 1606 unsigned int good_bytes = result ? 0 : scsi_bufflen(SCpnt);
1483 struct scsi_sense_hdr sshdr; 1607 struct scsi_sense_hdr sshdr;
1484 struct scsi_disk *sdkp = scsi_disk(SCpnt->request->rq_disk); 1608 struct scsi_disk *sdkp = scsi_disk(SCpnt->request->rq_disk);
1609 struct request *req = SCpnt->request;
1485 int sense_valid = 0; 1610 int sense_valid = 0;
1486 int sense_deferred = 0; 1611 int sense_deferred = 0;
1487 unsigned char op = SCpnt->cmnd[0]; 1612 unsigned char op = SCpnt->cmnd[0];
1613 unsigned char unmap = SCpnt->cmnd[1] & 8;
1488 1614
1489 if ((SCpnt->request->cmd_flags & REQ_DISCARD) && !result) 1615 if (req->cmd_flags & REQ_DISCARD || req->cmd_flags & REQ_WRITE_SAME) {
1490 scsi_set_resid(SCpnt, 0); 1616 if (!result) {
1617 good_bytes = blk_rq_bytes(req);
1618 scsi_set_resid(SCpnt, 0);
1619 } else {
1620 good_bytes = 0;
1621 scsi_set_resid(SCpnt, blk_rq_bytes(req));
1622 }
1623 }
1491 1624
1492 if (result) { 1625 if (result) {
1493 sense_valid = scsi_command_normalize_sense(SCpnt, &sshdr); 1626 sense_valid = scsi_command_normalize_sense(SCpnt, &sshdr);
@@ -1536,9 +1669,25 @@ static int sd_done(struct scsi_cmnd *SCpnt)
1536 if (sshdr.asc == 0x10) /* DIX: Host detected corruption */ 1669 if (sshdr.asc == 0x10) /* DIX: Host detected corruption */
1537 good_bytes = sd_completed_bytes(SCpnt); 1670 good_bytes = sd_completed_bytes(SCpnt);
1538 /* INVALID COMMAND OPCODE or INVALID FIELD IN CDB */ 1671 /* INVALID COMMAND OPCODE or INVALID FIELD IN CDB */
1539 if ((sshdr.asc == 0x20 || sshdr.asc == 0x24) && 1672 if (sshdr.asc == 0x20 || sshdr.asc == 0x24) {
1540 (op == UNMAP || op == WRITE_SAME_16 || op == WRITE_SAME)) 1673 switch (op) {
1541 sd_config_discard(sdkp, SD_LBP_DISABLE); 1674 case UNMAP:
1675 sd_config_discard(sdkp, SD_LBP_DISABLE);
1676 break;
1677 case WRITE_SAME_16:
1678 case WRITE_SAME:
1679 if (unmap)
1680 sd_config_discard(sdkp, SD_LBP_DISABLE);
1681 else {
1682 sdkp->device->no_write_same = 1;
1683 sd_config_write_same(sdkp);
1684
1685 good_bytes = 0;
1686 req->__data_len = blk_rq_bytes(req);
1687 req->cmd_flags |= REQ_QUIET;
1688 }
1689 }
1690 }
1542 break; 1691 break;
1543 default: 1692 default:
1544 break; 1693 break;
@@ -2374,9 +2523,7 @@ static void sd_read_block_limits(struct scsi_disk *sdkp)
2374 if (buffer[3] == 0x3c) { 2523 if (buffer[3] == 0x3c) {
2375 unsigned int lba_count, desc_count; 2524 unsigned int lba_count, desc_count;
2376 2525
2377 sdkp->max_ws_blocks = 2526 sdkp->max_ws_blocks = (u32)get_unaligned_be64(&buffer[36]);
2378 (u32) min_not_zero(get_unaligned_be64(&buffer[36]),
2379 (u64)0xffffffff);
2380 2527
2381 if (!sdkp->lbpme) 2528 if (!sdkp->lbpme)
2382 goto out; 2529 goto out;
@@ -2469,6 +2616,13 @@ static void sd_read_block_provisioning(struct scsi_disk *sdkp)
2469 kfree(buffer); 2616 kfree(buffer);
2470} 2617}
2471 2618
2619static void sd_read_write_same(struct scsi_disk *sdkp, unsigned char *buffer)
2620{
2621 if (scsi_report_opcode(sdkp->device, buffer, SD_BUF_SIZE,
2622 WRITE_SAME_16))
2623 sdkp->ws16 = 1;
2624}
2625
2472static int sd_try_extended_inquiry(struct scsi_device *sdp) 2626static int sd_try_extended_inquiry(struct scsi_device *sdp)
2473{ 2627{
2474 /* 2628 /*
@@ -2528,6 +2682,7 @@ static int sd_revalidate_disk(struct gendisk *disk)
2528 sd_read_write_protect_flag(sdkp, buffer); 2682 sd_read_write_protect_flag(sdkp, buffer);
2529 sd_read_cache_type(sdkp, buffer); 2683 sd_read_cache_type(sdkp, buffer);
2530 sd_read_app_tag_own(sdkp, buffer); 2684 sd_read_app_tag_own(sdkp, buffer);
2685 sd_read_write_same(sdkp, buffer);
2531 } 2686 }
2532 2687
2533 sdkp->first_scan = 0; 2688 sdkp->first_scan = 0;
@@ -2545,6 +2700,7 @@ static int sd_revalidate_disk(struct gendisk *disk)
2545 blk_queue_flush(sdkp->disk->queue, flush); 2700 blk_queue_flush(sdkp->disk->queue, flush);
2546 2701
2547 set_capacity(disk, sdkp->capacity); 2702 set_capacity(disk, sdkp->capacity);
2703 sd_config_write_same(sdkp);
2548 kfree(buffer); 2704 kfree(buffer);
2549 2705
2550 out: 2706 out:
diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h
index 47c52a6d733c..74a1e4ca5401 100644
--- a/drivers/scsi/sd.h
+++ b/drivers/scsi/sd.h
@@ -14,6 +14,7 @@
14#define SD_TIMEOUT (30 * HZ) 14#define SD_TIMEOUT (30 * HZ)
15#define SD_MOD_TIMEOUT (75 * HZ) 15#define SD_MOD_TIMEOUT (75 * HZ)
16#define SD_FLUSH_TIMEOUT (60 * HZ) 16#define SD_FLUSH_TIMEOUT (60 * HZ)
17#define SD_WRITE_SAME_TIMEOUT (120 * HZ)
17 18
18/* 19/*
19 * Number of allowed retries 20 * Number of allowed retries
@@ -39,6 +40,11 @@ enum {
39}; 40};
40 41
41enum { 42enum {
43 SD_MAX_WS10_BLOCKS = 0xffff,
44 SD_MAX_WS16_BLOCKS = 0x7fffff,
45};
46
47enum {
42 SD_LBP_FULL = 0, /* Full logical block provisioning */ 48 SD_LBP_FULL = 0, /* Full logical block provisioning */
43 SD_LBP_UNMAP, /* Use UNMAP command */ 49 SD_LBP_UNMAP, /* Use UNMAP command */
44 SD_LBP_WS16, /* Use WRITE SAME(16) with UNMAP bit */ 50 SD_LBP_WS16, /* Use WRITE SAME(16) with UNMAP bit */
@@ -77,6 +83,7 @@ struct scsi_disk {
77 unsigned lbpws : 1; 83 unsigned lbpws : 1;
78 unsigned lbpws10 : 1; 84 unsigned lbpws10 : 1;
79 unsigned lbpvpd : 1; 85 unsigned lbpvpd : 1;
86 unsigned ws16 : 1;
80}; 87};
81#define to_scsi_disk(obj) container_of(obj,struct scsi_disk,dev) 88#define to_scsi_disk(obj) container_of(obj,struct scsi_disk,dev)
82 89
diff --git a/drivers/staging/android/android_alarm.h b/drivers/staging/android/android_alarm.h
index f2ffd963f1c3..d0cafd637199 100644
--- a/drivers/staging/android/android_alarm.h
+++ b/drivers/staging/android/android_alarm.h
@@ -51,12 +51,10 @@ enum android_alarm_return_flags {
51#define ANDROID_ALARM_WAIT _IO('a', 1) 51#define ANDROID_ALARM_WAIT _IO('a', 1)
52 52
53#define ALARM_IOW(c, type, size) _IOW('a', (c) | ((type) << 4), size) 53#define ALARM_IOW(c, type, size) _IOW('a', (c) | ((type) << 4), size)
54#define ALARM_IOR(c, type, size) _IOR('a', (c) | ((type) << 4), size)
55
56/* Set alarm */ 54/* Set alarm */
57#define ANDROID_ALARM_SET(type) ALARM_IOW(2, type, struct timespec) 55#define ANDROID_ALARM_SET(type) ALARM_IOW(2, type, struct timespec)
58#define ANDROID_ALARM_SET_AND_WAIT(type) ALARM_IOW(3, type, struct timespec) 56#define ANDROID_ALARM_SET_AND_WAIT(type) ALARM_IOW(3, type, struct timespec)
59#define ANDROID_ALARM_GET_TIME(type) ALARM_IOR(4, type, struct timespec) 57#define ANDROID_ALARM_GET_TIME(type) ALARM_IOW(4, type, struct timespec)
60#define ANDROID_ALARM_SET_RTC _IOW('a', 5, struct timespec) 58#define ANDROID_ALARM_SET_RTC _IOW('a', 5, struct timespec)
61#define ANDROID_ALARM_BASE_CMD(cmd) (cmd & ~(_IOC(0, 0, 0xf0, 0))) 59#define ANDROID_ALARM_BASE_CMD(cmd) (cmd & ~(_IOC(0, 0, 0xf0, 0)))
62#define ANDROID_ALARM_IOCTL_TO_TYPE(cmd) (_IOC_NR(cmd) >> 4) 60#define ANDROID_ALARM_IOCTL_TO_TYPE(cmd) (_IOC_NR(cmd) >> 4)
diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
index a5dec1ca1b82..13ee53bd0bf6 100644
--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -424,7 +424,6 @@ static void hvc_hangup(struct tty_struct *tty)
424{ 424{
425 struct hvc_struct *hp = tty->driver_data; 425 struct hvc_struct *hp = tty->driver_data;
426 unsigned long flags; 426 unsigned long flags;
427 int temp_open_count;
428 427
429 if (!hp) 428 if (!hp)
430 return; 429 return;
@@ -444,7 +443,6 @@ static void hvc_hangup(struct tty_struct *tty)
444 return; 443 return;
445 } 444 }
446 445
447 temp_open_count = hp->port.count;
448 hp->port.count = 0; 446 hp->port.count = 0;
449 spin_unlock_irqrestore(&hp->port.lock, flags); 447 spin_unlock_irqrestore(&hp->port.lock, flags);
450 tty_port_tty_set(&hp->port, NULL); 448 tty_port_tty_set(&hp->port, NULL);
@@ -453,11 +451,6 @@ static void hvc_hangup(struct tty_struct *tty)
453 451
454 if (hp->ops->notifier_hangup) 452 if (hp->ops->notifier_hangup)
455 hp->ops->notifier_hangup(hp, hp->data); 453 hp->ops->notifier_hangup(hp, hp->data);
456
457 while(temp_open_count) {
458 --temp_open_count;
459 tty_port_put(&hp->port);
460 }
461} 454}
462 455
463/* 456/*
diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
index 2bc28a59d385..1ab1d2c66de4 100644
--- a/drivers/tty/serial/max310x.c
+++ b/drivers/tty/serial/max310x.c
@@ -1239,6 +1239,7 @@ static int __devexit max310x_remove(struct spi_device *spi)
1239static const struct spi_device_id max310x_id_table[] = { 1239static const struct spi_device_id max310x_id_table[] = {
1240 { "max3107", MAX310X_TYPE_MAX3107 }, 1240 { "max3107", MAX310X_TYPE_MAX3107 },
1241 { "max3108", MAX310X_TYPE_MAX3108 }, 1241 { "max3108", MAX310X_TYPE_MAX3108 },
1242 { }
1242}; 1243};
1243MODULE_DEVICE_TABLE(spi, max310x_id_table); 1244MODULE_DEVICE_TABLE(spi, max310x_id_table);
1244 1245
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 1e741bca0265..f034716190ff 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2151,8 +2151,15 @@ EXPORT_SYMBOL_GPL(usb_bus_start_enum);
2151irqreturn_t usb_hcd_irq (int irq, void *__hcd) 2151irqreturn_t usb_hcd_irq (int irq, void *__hcd)
2152{ 2152{
2153 struct usb_hcd *hcd = __hcd; 2153 struct usb_hcd *hcd = __hcd;
2154 unsigned long flags;
2154 irqreturn_t rc; 2155 irqreturn_t rc;
2155 2156
2157 /* IRQF_DISABLED doesn't work correctly with shared IRQs
2158 * when the first handler doesn't use it. So let's just
2159 * assume it's never used.
2160 */
2161 local_irq_save(flags);
2162
2156 if (unlikely(HCD_DEAD(hcd) || !HCD_HW_ACCESSIBLE(hcd))) 2163 if (unlikely(HCD_DEAD(hcd) || !HCD_HW_ACCESSIBLE(hcd)))
2157 rc = IRQ_NONE; 2164 rc = IRQ_NONE;
2158 else if (hcd->driver->irq(hcd) == IRQ_NONE) 2165 else if (hcd->driver->irq(hcd) == IRQ_NONE)
@@ -2160,6 +2167,7 @@ irqreturn_t usb_hcd_irq (int irq, void *__hcd)
2160 else 2167 else
2161 rc = IRQ_HANDLED; 2168 rc = IRQ_HANDLED;
2162 2169
2170 local_irq_restore(flags);
2163 return rc; 2171 return rc;
2164} 2172}
2165EXPORT_SYMBOL_GPL(usb_hcd_irq); 2173EXPORT_SYMBOL_GPL(usb_hcd_irq);
@@ -2347,6 +2355,14 @@ static int usb_hcd_request_irqs(struct usb_hcd *hcd,
2347 int retval; 2355 int retval;
2348 2356
2349 if (hcd->driver->irq) { 2357 if (hcd->driver->irq) {
2358
2359 /* IRQF_DISABLED doesn't work as advertised when used together
2360 * with IRQF_SHARED. As usb_hcd_irq() will always disable
2361 * interrupts we can remove it here.
2362 */
2363 if (irqflags & IRQF_SHARED)
2364 irqflags &= ~IRQF_DISABLED;
2365
2350 snprintf(hcd->irq_descr, sizeof(hcd->irq_descr), "%s:usb%d", 2366 snprintf(hcd->irq_descr, sizeof(hcd->irq_descr), "%s:usb%d",
2351 hcd->driver->description, hcd->self.busnum); 2367 hcd->driver->description, hcd->self.busnum);
2352 retval = request_irq(irqnum, &usb_hcd_irq, irqflags, 2368 retval = request_irq(irqnum, &usb_hcd_irq, irqflags,
diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
index e426ad626d74..4bfa78af379c 100644
--- a/drivers/usb/early/ehci-dbgp.c
+++ b/drivers/usb/early/ehci-dbgp.c
@@ -20,6 +20,7 @@
20#include <linux/usb/ehci_def.h> 20#include <linux/usb/ehci_def.h>
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/serial_core.h> 22#include <linux/serial_core.h>
23#include <linux/kconfig.h>
23#include <linux/kgdb.h> 24#include <linux/kgdb.h>
24#include <linux/kthread.h> 25#include <linux/kthread.h>
25#include <asm/io.h> 26#include <asm/io.h>
@@ -614,12 +615,6 @@ err:
614 return -ENODEV; 615 return -ENODEV;
615} 616}
616 617
617int dbgp_external_startup(struct usb_hcd *hcd)
618{
619 return xen_dbgp_external_startup(hcd) ?: _dbgp_external_startup();
620}
621EXPORT_SYMBOL_GPL(dbgp_external_startup);
622
623static int ehci_reset_port(int port) 618static int ehci_reset_port(int port)
624{ 619{
625 u32 portsc; 620 u32 portsc;
@@ -979,6 +974,7 @@ struct console early_dbgp_console = {
979 .index = -1, 974 .index = -1,
980}; 975};
981 976
977#if IS_ENABLED(CONFIG_USB_EHCI_HCD)
982int dbgp_reset_prep(struct usb_hcd *hcd) 978int dbgp_reset_prep(struct usb_hcd *hcd)
983{ 979{
984 int ret = xen_dbgp_reset_prep(hcd); 980 int ret = xen_dbgp_reset_prep(hcd);
@@ -1007,6 +1003,13 @@ int dbgp_reset_prep(struct usb_hcd *hcd)
1007} 1003}
1008EXPORT_SYMBOL_GPL(dbgp_reset_prep); 1004EXPORT_SYMBOL_GPL(dbgp_reset_prep);
1009 1005
1006int dbgp_external_startup(struct usb_hcd *hcd)
1007{
1008 return xen_dbgp_external_startup(hcd) ?: _dbgp_external_startup();
1009}
1010EXPORT_SYMBOL_GPL(dbgp_external_startup);
1011#endif /* USB_EHCI_HCD */
1012
1010#ifdef CONFIG_KGDB 1013#ifdef CONFIG_KGDB
1011 1014
1012static char kgdbdbgp_buf[DBGP_MAX_PACKET]; 1015static char kgdbdbgp_buf[DBGP_MAX_PACKET];
diff --git a/drivers/usb/host/ehci-ls1x.c b/drivers/usb/host/ehci-ls1x.c
index ca759652626b..aa0f328922df 100644
--- a/drivers/usb/host/ehci-ls1x.c
+++ b/drivers/usb/host/ehci-ls1x.c
@@ -113,7 +113,7 @@ static int ehci_hcd_ls1x_probe(struct platform_device *pdev)
113 goto err_put_hcd; 113 goto err_put_hcd;
114 } 114 }
115 115
116 ret = usb_add_hcd(hcd, irq, IRQF_SHARED); 116 ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED);
117 if (ret) 117 if (ret)
118 goto err_put_hcd; 118 goto err_put_hcd;
119 119
diff --git a/drivers/usb/host/ohci-xls.c b/drivers/usb/host/ohci-xls.c
index 84201cd1a472..41e378f17c66 100644
--- a/drivers/usb/host/ohci-xls.c
+++ b/drivers/usb/host/ohci-xls.c
@@ -56,7 +56,7 @@ static int ohci_xls_probe_internal(const struct hc_driver *driver,
56 goto err3; 56 goto err3;
57 } 57 }
58 58
59 retval = usb_add_hcd(hcd, irq, IRQF_SHARED); 59 retval = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED);
60 if (retval != 0) 60 if (retval != 0)
61 goto err4; 61 goto err4;
62 return retval; 62 return retval;
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index d0b87e7b4abf..b6b84dacc791 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -707,11 +707,12 @@ static void rxstate(struct musb *musb, struct musb_request *req)
707 fifo_count = musb_readw(epio, MUSB_RXCOUNT); 707 fifo_count = musb_readw(epio, MUSB_RXCOUNT);
708 708
709 /* 709 /*
710 * use mode 1 only if we expect data of at least ep packet_sz 710 * Enable Mode 1 on RX transfers only when short_not_ok flag
711 * and have not yet received a short packet 711 * is set. Currently short_not_ok flag is set only from
712 * file_storage and f_mass_storage drivers
712 */ 713 */
713 if ((request->length - request->actual >= musb_ep->packet_sz) && 714
714 (fifo_count >= musb_ep->packet_sz)) 715 if (request->short_not_ok && fifo_count == musb_ep->packet_sz)
715 use_mode_1 = 1; 716 use_mode_1 = 1;
716 else 717 else
717 use_mode_1 = 0; 718 use_mode_1 = 0;
@@ -727,6 +728,27 @@ static void rxstate(struct musb *musb, struct musb_request *req)
727 c = musb->dma_controller; 728 c = musb->dma_controller;
728 channel = musb_ep->dma; 729 channel = musb_ep->dma;
729 730
731 /* We use DMA Req mode 0 in rx_csr, and DMA controller operates in
732 * mode 0 only. So we do not get endpoint interrupts due to DMA
733 * completion. We only get interrupts from DMA controller.
734 *
735 * We could operate in DMA mode 1 if we knew the size of the tranfer
736 * in advance. For mass storage class, request->length = what the host
737 * sends, so that'd work. But for pretty much everything else,
738 * request->length is routinely more than what the host sends. For
739 * most these gadgets, end of is signified either by a short packet,
740 * or filling the last byte of the buffer. (Sending extra data in
741 * that last pckate should trigger an overflow fault.) But in mode 1,
742 * we don't get DMA completion interrupt for short packets.
743 *
744 * Theoretically, we could enable DMAReq irq (MUSB_RXCSR_DMAMODE = 1),
745 * to get endpoint interrupt on every DMA req, but that didn't seem
746 * to work reliably.
747 *
748 * REVISIT an updated g_file_storage can set req->short_not_ok, which
749 * then becomes usable as a runtime "use mode 1" hint...
750 */
751
730 /* Experimental: Mode1 works with mass storage use cases */ 752 /* Experimental: Mode1 works with mass storage use cases */
731 if (use_mode_1) { 753 if (use_mode_1) {
732 csr |= MUSB_RXCSR_AUTOCLEAR; 754 csr |= MUSB_RXCSR_AUTOCLEAR;
diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c
index d62a91fedc22..0e62f504410e 100644
--- a/drivers/usb/musb/ux500.c
+++ b/drivers/usb/musb/ux500.c
@@ -65,7 +65,7 @@ static int __devinit ux500_probe(struct platform_device *pdev)
65 struct platform_device *musb; 65 struct platform_device *musb;
66 struct ux500_glue *glue; 66 struct ux500_glue *glue;
67 struct clk *clk; 67 struct clk *clk;
68 68 int musbid;
69 int ret = -ENOMEM; 69 int ret = -ENOMEM;
70 70
71 glue = kzalloc(sizeof(*glue), GFP_KERNEL); 71 glue = kzalloc(sizeof(*glue), GFP_KERNEL);
diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig
index d8c8a42bff3e..6223062d5d1b 100644
--- a/drivers/usb/otg/Kconfig
+++ b/drivers/usb/otg/Kconfig
@@ -58,7 +58,7 @@ config USB_ULPI_VIEWPORT
58 58
59config TWL4030_USB 59config TWL4030_USB
60 tristate "TWL4030 USB Transceiver Driver" 60 tristate "TWL4030 USB Transceiver Driver"
61 depends on TWL4030_CORE && REGULATOR_TWL4030 61 depends on TWL4030_CORE && REGULATOR_TWL4030 && USB_MUSB_OMAP2PLUS
62 select USB_OTG_UTILS 62 select USB_OTG_UTILS
63 help 63 help
64 Enable this to support the USB OTG transceiver on TWL4030 64 Enable this to support the USB OTG transceiver on TWL4030
@@ -68,7 +68,7 @@ config TWL4030_USB
68 68
69config TWL6030_USB 69config TWL6030_USB
70 tristate "TWL6030 USB Transceiver Driver" 70 tristate "TWL6030 USB Transceiver Driver"
71 depends on TWL4030_CORE && OMAP_USB2 71 depends on TWL4030_CORE && OMAP_USB2 && USB_MUSB_OMAP2PLUS
72 select USB_OTG_UTILS 72 select USB_OTG_UTILS
73 help 73 help
74 Enable this to support the USB OTG transceiver on TWL6030 74 Enable this to support the USB OTG transceiver on TWL6030
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index 7179b0c5f814..cff8dd5b462d 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -2430,7 +2430,7 @@ static void keyspan_release(struct usb_serial *serial)
2430static int keyspan_port_probe(struct usb_serial_port *port) 2430static int keyspan_port_probe(struct usb_serial_port *port)
2431{ 2431{
2432 struct usb_serial *serial = port->serial; 2432 struct usb_serial *serial = port->serial;
2433 struct keyspan_port_private *s_priv; 2433 struct keyspan_serial_private *s_priv;
2434 struct keyspan_port_private *p_priv; 2434 struct keyspan_port_private *p_priv;
2435 const struct keyspan_device_details *d_details; 2435 const struct keyspan_device_details *d_details;
2436 struct callbacks *cback; 2436 struct callbacks *cback;
@@ -2445,7 +2445,6 @@ static int keyspan_port_probe(struct usb_serial_port *port)
2445 if (!p_priv) 2445 if (!p_priv)
2446 return -ENOMEM; 2446 return -ENOMEM;
2447 2447
2448 s_priv = usb_get_serial_data(port->serial);
2449 p_priv->device_details = d_details; 2448 p_priv->device_details = d_details;
2450 2449
2451 /* Setup values for the various callback routines */ 2450 /* Setup values for the various callback routines */
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 5dee7d61241e..edc64bb6f457 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -158,6 +158,7 @@ static void option_instat_callback(struct urb *urb);
158#define NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_HIGHSPEED 0x8001 158#define NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_HIGHSPEED 0x8001
159#define NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_FULLSPEED 0x9000 159#define NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_FULLSPEED 0x9000
160#define NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_HIGHSPEED 0x9001 160#define NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_HIGHSPEED 0x9001
161#define NOVATELWIRELESS_PRODUCT_E362 0x9010
161#define NOVATELWIRELESS_PRODUCT_G1 0xA001 162#define NOVATELWIRELESS_PRODUCT_G1 0xA001
162#define NOVATELWIRELESS_PRODUCT_G1_M 0xA002 163#define NOVATELWIRELESS_PRODUCT_G1_M 0xA002
163#define NOVATELWIRELESS_PRODUCT_G2 0xA010 164#define NOVATELWIRELESS_PRODUCT_G2 0xA010
@@ -193,6 +194,9 @@ static void option_instat_callback(struct urb *urb);
193#define DELL_PRODUCT_5730_MINICARD_TELUS 0x8181 194#define DELL_PRODUCT_5730_MINICARD_TELUS 0x8181
194#define DELL_PRODUCT_5730_MINICARD_VZW 0x8182 195#define DELL_PRODUCT_5730_MINICARD_VZW 0x8182
195 196
197#define DELL_PRODUCT_5800_MINICARD_VZW 0x8195 /* Novatel E362 */
198#define DELL_PRODUCT_5800_V2_MINICARD_VZW 0x8196 /* Novatel E362 */
199
196#define KYOCERA_VENDOR_ID 0x0c88 200#define KYOCERA_VENDOR_ID 0x0c88
197#define KYOCERA_PRODUCT_KPC650 0x17da 201#define KYOCERA_PRODUCT_KPC650 0x17da
198#define KYOCERA_PRODUCT_KPC680 0x180a 202#define KYOCERA_PRODUCT_KPC680 0x180a
@@ -283,6 +287,7 @@ static void option_instat_callback(struct urb *urb);
283/* ALCATEL PRODUCTS */ 287/* ALCATEL PRODUCTS */
284#define ALCATEL_VENDOR_ID 0x1bbb 288#define ALCATEL_VENDOR_ID 0x1bbb
285#define ALCATEL_PRODUCT_X060S_X200 0x0000 289#define ALCATEL_PRODUCT_X060S_X200 0x0000
290#define ALCATEL_PRODUCT_X220_X500D 0x0017
286 291
287#define PIRELLI_VENDOR_ID 0x1266 292#define PIRELLI_VENDOR_ID 0x1266
288#define PIRELLI_PRODUCT_C100_1 0x1002 293#define PIRELLI_PRODUCT_C100_1 0x1002
@@ -706,6 +711,7 @@ static const struct usb_device_id option_ids[] = {
706 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_G2) }, 711 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_G2) },
707 /* Novatel Ovation MC551 a.k.a. Verizon USB551L */ 712 /* Novatel Ovation MC551 a.k.a. Verizon USB551L */
708 { USB_DEVICE_AND_INTERFACE_INFO(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC551, 0xff, 0xff, 0xff) }, 713 { USB_DEVICE_AND_INTERFACE_INFO(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC551, 0xff, 0xff, 0xff) },
714 { USB_DEVICE_AND_INTERFACE_INFO(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_E362, 0xff, 0xff, 0xff) },
709 715
710 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01) }, 716 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01) },
711 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01A) }, 717 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01A) },
@@ -728,6 +734,8 @@ static const struct usb_device_id option_ids[] = {
728 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_SPRINT) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */ 734 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_SPRINT) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */
729 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_TELUS) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */ 735 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_TELUS) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */
730 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_VZW) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */ 736 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_VZW) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */
737 { USB_DEVICE_AND_INTERFACE_INFO(DELL_VENDOR_ID, DELL_PRODUCT_5800_MINICARD_VZW, 0xff, 0xff, 0xff) },
738 { USB_DEVICE_AND_INTERFACE_INFO(DELL_VENDOR_ID, DELL_PRODUCT_5800_V2_MINICARD_VZW, 0xff, 0xff, 0xff) },
731 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, /* ADU-E100, ADU-310 */ 739 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, /* ADU-E100, ADU-310 */
732 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) }, 740 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) },
733 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_620UW) }, 741 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_620UW) },
@@ -1157,6 +1165,7 @@ static const struct usb_device_id option_ids[] = {
1157 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X060S_X200), 1165 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X060S_X200),
1158 .driver_info = (kernel_ulong_t)&alcatel_x200_blacklist 1166 .driver_info = (kernel_ulong_t)&alcatel_x200_blacklist
1159 }, 1167 },
1168 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X220_X500D) },
1160 { USB_DEVICE(AIRPLUS_VENDOR_ID, AIRPLUS_PRODUCT_MCD650) }, 1169 { USB_DEVICE(AIRPLUS_VENDOR_ID, AIRPLUS_PRODUCT_MCD650) },
1161 { USB_DEVICE(TLAYTECH_VENDOR_ID, TLAYTECH_PRODUCT_TEU800) }, 1170 { USB_DEVICE(TLAYTECH_VENDOR_ID, TLAYTECH_PRODUCT_TEU800) },
1162 { USB_DEVICE(LONGCHEER_VENDOR_ID, FOUR_G_SYSTEMS_PRODUCT_W14), 1171 { USB_DEVICE(LONGCHEER_VENDOR_ID, FOUR_G_SYSTEMS_PRODUCT_W14),
diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c
index 61a73ad1a187..a3e9c095f0d8 100644
--- a/drivers/usb/serial/usb_wwan.c
+++ b/drivers/usb/serial/usb_wwan.c
@@ -455,9 +455,6 @@ static struct urb *usb_wwan_setup_urb(struct usb_serial_port *port,
455 struct usb_serial *serial = port->serial; 455 struct usb_serial *serial = port->serial;
456 struct urb *urb; 456 struct urb *urb;
457 457
458 if (endpoint == -1)
459 return NULL; /* endpoint not needed */
460
461 urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */ 458 urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */
462 if (urb == NULL) { 459 if (urb == NULL) {
463 dev_dbg(&serial->interface->dev, 460 dev_dbg(&serial->interface->dev,
@@ -489,6 +486,9 @@ int usb_wwan_port_probe(struct usb_serial_port *port)
489 init_usb_anchor(&portdata->delayed); 486 init_usb_anchor(&portdata->delayed);
490 487
491 for (i = 0; i < N_IN_URB; i++) { 488 for (i = 0; i < N_IN_URB; i++) {
489 if (!port->bulk_in_size)
490 break;
491
492 buffer = (u8 *)__get_free_page(GFP_KERNEL); 492 buffer = (u8 *)__get_free_page(GFP_KERNEL);
493 if (!buffer) 493 if (!buffer)
494 goto bail_out_error; 494 goto bail_out_error;
@@ -502,8 +502,8 @@ int usb_wwan_port_probe(struct usb_serial_port *port)
502 } 502 }
503 503
504 for (i = 0; i < N_OUT_URB; i++) { 504 for (i = 0; i < N_OUT_URB; i++) {
505 if (port->bulk_out_endpointAddress == -1) 505 if (!port->bulk_out_size)
506 continue; 506 break;
507 507
508 buffer = kmalloc(OUT_BUFLEN, GFP_KERNEL); 508 buffer = kmalloc(OUT_BUFLEN, GFP_KERNEL);
509 if (!buffer) 509 if (!buffer)
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index a3d54366afcc..92f35abee92d 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -186,6 +186,12 @@ static int slave_configure(struct scsi_device *sdev)
186 /* Some devices don't handle VPD pages correctly */ 186 /* Some devices don't handle VPD pages correctly */
187 sdev->skip_vpd_pages = 1; 187 sdev->skip_vpd_pages = 1;
188 188
189 /* Do not attempt to use REPORT SUPPORTED OPERATION CODES */
190 sdev->no_report_opcodes = 1;
191
192 /* Do not attempt to use WRITE SAME */
193 sdev->no_write_same = 1;
194
189 /* Some disks return the total number of blocks in response 195 /* Some disks return the total number of blocks in response
190 * to READ CAPACITY rather than the highest block number. 196 * to READ CAPACITY rather than the highest block number.
191 * If this device makes that mistake, tell the sd driver. */ 197 * If this device makes that mistake, tell the sd driver. */
diff --git a/drivers/video/omap2/dss/dsi.c b/drivers/video/omap2/dss/dsi.c
index d64ac3842884..bee92846cfab 100644
--- a/drivers/video/omap2/dss/dsi.c
+++ b/drivers/video/omap2/dss/dsi.c
@@ -365,11 +365,20 @@ struct platform_device *dsi_get_dsidev_from_id(int module)
365 struct omap_dss_output *out; 365 struct omap_dss_output *out;
366 enum omap_dss_output_id id; 366 enum omap_dss_output_id id;
367 367
368 id = module == 0 ? OMAP_DSS_OUTPUT_DSI1 : OMAP_DSS_OUTPUT_DSI2; 368 switch (module) {
369 case 0:
370 id = OMAP_DSS_OUTPUT_DSI1;
371 break;
372 case 1:
373 id = OMAP_DSS_OUTPUT_DSI2;
374 break;
375 default:
376 return NULL;
377 }
369 378
370 out = omap_dss_get_output(id); 379 out = omap_dss_get_output(id);
371 380
372 return out->pdev; 381 return out ? out->pdev : NULL;
373} 382}
374 383
375static inline void dsi_write_reg(struct platform_device *dsidev, 384static inline void dsi_write_reg(struct platform_device *dsidev,
diff --git a/drivers/video/omap2/dss/dss.c b/drivers/video/omap2/dss/dss.c
index 2ab1c3e96553..5f6eea801b06 100644
--- a/drivers/video/omap2/dss/dss.c
+++ b/drivers/video/omap2/dss/dss.c
@@ -697,11 +697,15 @@ static int dss_get_clocks(void)
697 697
698 dss.dss_clk = clk; 698 dss.dss_clk = clk;
699 699
700 clk = clk_get(NULL, dss.feat->clk_name); 700 if (dss.feat->clk_name) {
701 if (IS_ERR(clk)) { 701 clk = clk_get(NULL, dss.feat->clk_name);
702 DSSERR("Failed to get %s\n", dss.feat->clk_name); 702 if (IS_ERR(clk)) {
703 r = PTR_ERR(clk); 703 DSSERR("Failed to get %s\n", dss.feat->clk_name);
704 goto err; 704 r = PTR_ERR(clk);
705 goto err;
706 }
707 } else {
708 clk = NULL;
705 } 709 }
706 710
707 dss.dpll4_m4_ck = clk; 711 dss.dpll4_m4_ck = clk;
@@ -805,10 +809,10 @@ static int __init dss_init_features(struct device *dev)
805 809
806 if (cpu_is_omap24xx()) 810 if (cpu_is_omap24xx())
807 src = &omap24xx_dss_feats; 811 src = &omap24xx_dss_feats;
808 else if (cpu_is_omap34xx())
809 src = &omap34xx_dss_feats;
810 else if (cpu_is_omap3630()) 812 else if (cpu_is_omap3630())
811 src = &omap3630_dss_feats; 813 src = &omap3630_dss_feats;
814 else if (cpu_is_omap34xx())
815 src = &omap34xx_dss_feats;
812 else if (cpu_is_omap44xx()) 816 else if (cpu_is_omap44xx())
813 src = &omap44xx_dss_feats; 817 src = &omap44xx_dss_feats;
814 else if (soc_is_omap54xx()) 818 else if (soc_is_omap54xx())
diff --git a/drivers/video/omap2/dss/hdmi.c b/drivers/video/omap2/dss/hdmi.c
index a48a7dd75b33..8c9b8b3b7f77 100644
--- a/drivers/video/omap2/dss/hdmi.c
+++ b/drivers/video/omap2/dss/hdmi.c
@@ -644,8 +644,10 @@ static void hdmi_dump_regs(struct seq_file *s)
644{ 644{
645 mutex_lock(&hdmi.lock); 645 mutex_lock(&hdmi.lock);
646 646
647 if (hdmi_runtime_get()) 647 if (hdmi_runtime_get()) {
648 mutex_unlock(&hdmi.lock);
648 return; 649 return;
650 }
649 651
650 hdmi.ip_data.ops->dump_wrapper(&hdmi.ip_data, s); 652 hdmi.ip_data.ops->dump_wrapper(&hdmi.ip_data, s);
651 hdmi.ip_data.ops->dump_pll(&hdmi.ip_data, s); 653 hdmi.ip_data.ops->dump_pll(&hdmi.ip_data, s);
diff --git a/drivers/video/omap2/omapfb/omapfb-ioctl.c b/drivers/video/omap2/omapfb/omapfb-ioctl.c
index 606b89f12351..d630b26a005c 100644
--- a/drivers/video/omap2/omapfb/omapfb-ioctl.c
+++ b/drivers/video/omap2/omapfb/omapfb-ioctl.c
@@ -787,7 +787,7 @@ int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg)
787 787
788 case OMAPFB_WAITFORVSYNC: 788 case OMAPFB_WAITFORVSYNC:
789 DBG("ioctl WAITFORVSYNC\n"); 789 DBG("ioctl WAITFORVSYNC\n");
790 if (!display && !display->output && !display->output->manager) { 790 if (!display || !display->output || !display->output->manager) {
791 r = -EINVAL; 791 r = -EINVAL;
792 break; 792 break;
793 } 793 }
diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c
index 8adb9cc267f9..71f5c459b088 100644
--- a/drivers/xen/privcmd.c
+++ b/drivers/xen/privcmd.c
@@ -361,13 +361,13 @@ static long privcmd_ioctl_mmap_batch(void __user *udata, int version)
361 down_write(&mm->mmap_sem); 361 down_write(&mm->mmap_sem);
362 362
363 vma = find_vma(mm, m.addr); 363 vma = find_vma(mm, m.addr);
364 ret = -EINVAL;
365 if (!vma || 364 if (!vma ||
366 vma->vm_ops != &privcmd_vm_ops || 365 vma->vm_ops != &privcmd_vm_ops ||
367 (m.addr != vma->vm_start) || 366 (m.addr != vma->vm_start) ||
368 ((m.addr + (nr_pages << PAGE_SHIFT)) != vma->vm_end) || 367 ((m.addr + (nr_pages << PAGE_SHIFT)) != vma->vm_end) ||
369 !privcmd_enforce_singleshot_mapping(vma)) { 368 !privcmd_enforce_singleshot_mapping(vma)) {
370 up_write(&mm->mmap_sem); 369 up_write(&mm->mmap_sem);
370 ret = -EINVAL;
371 goto out; 371 goto out;
372 } 372 }
373 373
@@ -383,12 +383,16 @@ static long privcmd_ioctl_mmap_batch(void __user *udata, int version)
383 383
384 up_write(&mm->mmap_sem); 384 up_write(&mm->mmap_sem);
385 385
386 if (state.global_error && (version == 1)) { 386 if (version == 1) {
387 /* Write back errors in second pass. */ 387 if (state.global_error) {
388 state.user_mfn = (xen_pfn_t *)m.arr; 388 /* Write back errors in second pass. */
389 state.err = err_array; 389 state.user_mfn = (xen_pfn_t *)m.arr;
390 ret = traverse_pages(m.num, sizeof(xen_pfn_t), 390 state.err = err_array;
391 &pagelist, mmap_return_errors_v1, &state); 391 ret = traverse_pages(m.num, sizeof(xen_pfn_t),
392 &pagelist, mmap_return_errors_v1, &state);
393 } else
394 ret = 0;
395
392 } else if (version == 2) { 396 } else if (version == 2) {
393 ret = __copy_to_user(m.err, err_array, m.num * sizeof(int)); 397 ret = __copy_to_user(m.err, err_array, m.num * sizeof(int));
394 if (ret) 398 if (ret)
diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
index 7320a66e958f..22548f56197b 100644
--- a/fs/ext3/balloc.c
+++ b/fs/ext3/balloc.c
@@ -2101,8 +2101,9 @@ int ext3_trim_fs(struct super_block *sb, struct fstrim_range *range)
2101 end = start + (range->len >> sb->s_blocksize_bits) - 1; 2101 end = start + (range->len >> sb->s_blocksize_bits) - 1;
2102 minlen = range->minlen >> sb->s_blocksize_bits; 2102 minlen = range->minlen >> sb->s_blocksize_bits;
2103 2103
2104 if (unlikely(minlen > EXT3_BLOCKS_PER_GROUP(sb)) || 2104 if (minlen > EXT3_BLOCKS_PER_GROUP(sb) ||
2105 unlikely(start >= max_blks)) 2105 start >= max_blks ||
2106 range->len < sb->s_blocksize)
2106 return -EINVAL; 2107 return -EINVAL;
2107 if (end >= max_blks) 2108 if (end >= max_blks)
2108 end = max_blks - 1; 2109 end = max_blks - 1;
diff --git a/fs/file.c b/fs/file.c
index 708d997a7748..7cb71b992603 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -685,7 +685,6 @@ void do_close_on_exec(struct files_struct *files)
685 struct fdtable *fdt; 685 struct fdtable *fdt;
686 686
687 /* exec unshares first */ 687 /* exec unshares first */
688 BUG_ON(atomic_read(&files->count) != 1);
689 spin_lock(&files->file_lock); 688 spin_lock(&files->file_lock);
690 for (i = 0; ; i++) { 689 for (i = 0; ; i++) {
691 unsigned long set; 690 unsigned long set;
diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c
index 60ef3fb707ff..1506673c087e 100644
--- a/fs/jffs2/file.c
+++ b/fs/jffs2/file.c
@@ -138,33 +138,39 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
138 struct page *pg; 138 struct page *pg;
139 struct inode *inode = mapping->host; 139 struct inode *inode = mapping->host;
140 struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); 140 struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
141 struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
142 struct jffs2_raw_inode ri;
143 uint32_t alloc_len = 0;
141 pgoff_t index = pos >> PAGE_CACHE_SHIFT; 144 pgoff_t index = pos >> PAGE_CACHE_SHIFT;
142 uint32_t pageofs = index << PAGE_CACHE_SHIFT; 145 uint32_t pageofs = index << PAGE_CACHE_SHIFT;
143 int ret = 0; 146 int ret = 0;
144 147
148 jffs2_dbg(1, "%s()\n", __func__);
149
150 if (pageofs > inode->i_size) {
151 ret = jffs2_reserve_space(c, sizeof(ri), &alloc_len,
152 ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
153 if (ret)
154 return ret;
155 }
156
157 mutex_lock(&f->sem);
145 pg = grab_cache_page_write_begin(mapping, index, flags); 158 pg = grab_cache_page_write_begin(mapping, index, flags);
146 if (!pg) 159 if (!pg) {
160 if (alloc_len)
161 jffs2_complete_reservation(c);
162 mutex_unlock(&f->sem);
147 return -ENOMEM; 163 return -ENOMEM;
164 }
148 *pagep = pg; 165 *pagep = pg;
149 166
150 jffs2_dbg(1, "%s()\n", __func__); 167 if (alloc_len) {
151
152 if (pageofs > inode->i_size) {
153 /* Make new hole frag from old EOF to new page */ 168 /* Make new hole frag from old EOF to new page */
154 struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
155 struct jffs2_raw_inode ri;
156 struct jffs2_full_dnode *fn; 169 struct jffs2_full_dnode *fn;
157 uint32_t alloc_len;
158 170
159 jffs2_dbg(1, "Writing new hole frag 0x%x-0x%x between current EOF and new page\n", 171 jffs2_dbg(1, "Writing new hole frag 0x%x-0x%x between current EOF and new page\n",
160 (unsigned int)inode->i_size, pageofs); 172 (unsigned int)inode->i_size, pageofs);
161 173
162 ret = jffs2_reserve_space(c, sizeof(ri), &alloc_len,
163 ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
164 if (ret)
165 goto out_page;
166
167 mutex_lock(&f->sem);
168 memset(&ri, 0, sizeof(ri)); 174 memset(&ri, 0, sizeof(ri));
169 175
170 ri.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); 176 ri.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
@@ -191,7 +197,6 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
191 if (IS_ERR(fn)) { 197 if (IS_ERR(fn)) {
192 ret = PTR_ERR(fn); 198 ret = PTR_ERR(fn);
193 jffs2_complete_reservation(c); 199 jffs2_complete_reservation(c);
194 mutex_unlock(&f->sem);
195 goto out_page; 200 goto out_page;
196 } 201 }
197 ret = jffs2_add_full_dnode_to_inode(c, f, fn); 202 ret = jffs2_add_full_dnode_to_inode(c, f, fn);
@@ -206,12 +211,10 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
206 jffs2_mark_node_obsolete(c, fn->raw); 211 jffs2_mark_node_obsolete(c, fn->raw);
207 jffs2_free_full_dnode(fn); 212 jffs2_free_full_dnode(fn);
208 jffs2_complete_reservation(c); 213 jffs2_complete_reservation(c);
209 mutex_unlock(&f->sem);
210 goto out_page; 214 goto out_page;
211 } 215 }
212 jffs2_complete_reservation(c); 216 jffs2_complete_reservation(c);
213 inode->i_size = pageofs; 217 inode->i_size = pageofs;
214 mutex_unlock(&f->sem);
215 } 218 }
216 219
217 /* 220 /*
@@ -220,18 +223,18 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
220 * case of a short-copy. 223 * case of a short-copy.
221 */ 224 */
222 if (!PageUptodate(pg)) { 225 if (!PageUptodate(pg)) {
223 mutex_lock(&f->sem);
224 ret = jffs2_do_readpage_nolock(inode, pg); 226 ret = jffs2_do_readpage_nolock(inode, pg);
225 mutex_unlock(&f->sem);
226 if (ret) 227 if (ret)
227 goto out_page; 228 goto out_page;
228 } 229 }
230 mutex_unlock(&f->sem);
229 jffs2_dbg(1, "end write_begin(). pg->flags %lx\n", pg->flags); 231 jffs2_dbg(1, "end write_begin(). pg->flags %lx\n", pg->flags);
230 return ret; 232 return ret;
231 233
232out_page: 234out_page:
233 unlock_page(pg); 235 unlock_page(pg);
234 page_cache_release(pg); 236 page_cache_release(pg);
237 mutex_unlock(&f->sem);
235 return ret; 238 return ret;
236} 239}
237 240
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index 721d692fa8d4..6fcaeb8c902e 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -258,7 +258,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
258 if (ret) 258 if (ret)
259 goto out_close_fd; 259 goto out_close_fd;
260 260
261 fd_install(fd, f); 261 if (fd != FAN_NOFD)
262 fd_install(fd, f);
262 return fanotify_event_metadata.event_len; 263 return fanotify_event_metadata.event_len;
263 264
264out_close_fd: 265out_close_fd:
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 144a96732dd7..3c231adf8450 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -873,6 +873,113 @@ static const struct file_operations proc_environ_operations = {
873 .release = mem_release, 873 .release = mem_release,
874}; 874};
875 875
876static ssize_t oom_adj_read(struct file *file, char __user *buf, size_t count,
877 loff_t *ppos)
878{
879 struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode);
880 char buffer[PROC_NUMBUF];
881 int oom_adj = OOM_ADJUST_MIN;
882 size_t len;
883 unsigned long flags;
884
885 if (!task)
886 return -ESRCH;
887 if (lock_task_sighand(task, &flags)) {
888 if (task->signal->oom_score_adj == OOM_SCORE_ADJ_MAX)
889 oom_adj = OOM_ADJUST_MAX;
890 else
891 oom_adj = (task->signal->oom_score_adj * -OOM_DISABLE) /
892 OOM_SCORE_ADJ_MAX;
893 unlock_task_sighand(task, &flags);
894 }
895 put_task_struct(task);
896 len = snprintf(buffer, sizeof(buffer), "%d\n", oom_adj);
897 return simple_read_from_buffer(buf, count, ppos, buffer, len);
898}
899
900static ssize_t oom_adj_write(struct file *file, const char __user *buf,
901 size_t count, loff_t *ppos)
902{
903 struct task_struct *task;
904 char buffer[PROC_NUMBUF];
905 int oom_adj;
906 unsigned long flags;
907 int err;
908
909 memset(buffer, 0, sizeof(buffer));
910 if (count > sizeof(buffer) - 1)
911 count = sizeof(buffer) - 1;
912 if (copy_from_user(buffer, buf, count)) {
913 err = -EFAULT;
914 goto out;
915 }
916
917 err = kstrtoint(strstrip(buffer), 0, &oom_adj);
918 if (err)
919 goto out;
920 if ((oom_adj < OOM_ADJUST_MIN || oom_adj > OOM_ADJUST_MAX) &&
921 oom_adj != OOM_DISABLE) {
922 err = -EINVAL;
923 goto out;
924 }
925
926 task = get_proc_task(file->f_path.dentry->d_inode);
927 if (!task) {
928 err = -ESRCH;
929 goto out;
930 }
931
932 task_lock(task);
933 if (!task->mm) {
934 err = -EINVAL;
935 goto err_task_lock;
936 }
937
938 if (!lock_task_sighand(task, &flags)) {
939 err = -ESRCH;
940 goto err_task_lock;
941 }
942
943 /*
944 * Scale /proc/pid/oom_score_adj appropriately ensuring that a maximum
945 * value is always attainable.
946 */
947 if (oom_adj == OOM_ADJUST_MAX)
948 oom_adj = OOM_SCORE_ADJ_MAX;
949 else
950 oom_adj = (oom_adj * OOM_SCORE_ADJ_MAX) / -OOM_DISABLE;
951
952 if (oom_adj < task->signal->oom_score_adj &&
953 !capable(CAP_SYS_RESOURCE)) {
954 err = -EACCES;
955 goto err_sighand;
956 }
957
958 /*
959 * /proc/pid/oom_adj is provided for legacy purposes, ask users to use
960 * /proc/pid/oom_score_adj instead.
961 */
962 printk_once(KERN_WARNING "%s (%d): /proc/%d/oom_adj is deprecated, please use /proc/%d/oom_score_adj instead.\n",
963 current->comm, task_pid_nr(current), task_pid_nr(task),
964 task_pid_nr(task));
965
966 task->signal->oom_score_adj = oom_adj;
967 trace_oom_score_adj_update(task);
968err_sighand:
969 unlock_task_sighand(task, &flags);
970err_task_lock:
971 task_unlock(task);
972 put_task_struct(task);
973out:
974 return err < 0 ? err : count;
975}
976
977static const struct file_operations proc_oom_adj_operations = {
978 .read = oom_adj_read,
979 .write = oom_adj_write,
980 .llseek = generic_file_llseek,
981};
982
876static ssize_t oom_score_adj_read(struct file *file, char __user *buf, 983static ssize_t oom_score_adj_read(struct file *file, char __user *buf,
877 size_t count, loff_t *ppos) 984 size_t count, loff_t *ppos)
878{ 985{
@@ -2598,6 +2705,7 @@ static const struct pid_entry tgid_base_stuff[] = {
2598 REG("cgroup", S_IRUGO, proc_cgroup_operations), 2705 REG("cgroup", S_IRUGO, proc_cgroup_operations),
2599#endif 2706#endif
2600 INF("oom_score", S_IRUGO, proc_oom_score), 2707 INF("oom_score", S_IRUGO, proc_oom_score),
2708 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adj_operations),
2601 REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations), 2709 REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations),
2602#ifdef CONFIG_AUDITSYSCALL 2710#ifdef CONFIG_AUDITSYSCALL
2603 REG("loginuid", S_IWUSR|S_IRUGO, proc_loginuid_operations), 2711 REG("loginuid", S_IWUSR|S_IRUGO, proc_loginuid_operations),
@@ -2964,6 +3072,7 @@ static const struct pid_entry tid_base_stuff[] = {
2964 REG("cgroup", S_IRUGO, proc_cgroup_operations), 3072 REG("cgroup", S_IRUGO, proc_cgroup_operations),
2965#endif 3073#endif
2966 INF("oom_score", S_IRUGO, proc_oom_score), 3074 INF("oom_score", S_IRUGO, proc_oom_score),
3075 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adj_operations),
2967 REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations), 3076 REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations),
2968#ifdef CONFIG_AUDITSYSCALL 3077#ifdef CONFIG_AUDITSYSCALL
2969 REG("loginuid", S_IWUSR|S_IRUGO, proc_loginuid_operations), 3078 REG("loginuid", S_IWUSR|S_IRUGO, proc_loginuid_operations),
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index a40da07e93d6..947fbe06c3b1 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -161,6 +161,7 @@ static void pstore_console_write(struct console *con, const char *s, unsigned c)
161 161
162 while (s < e) { 162 while (s < e) {
163 unsigned long flags; 163 unsigned long flags;
164 u64 id;
164 165
165 if (c > psinfo->bufsize) 166 if (c > psinfo->bufsize)
166 c = psinfo->bufsize; 167 c = psinfo->bufsize;
@@ -172,7 +173,7 @@ static void pstore_console_write(struct console *con, const char *s, unsigned c)
172 spin_lock_irqsave(&psinfo->buf_lock, flags); 173 spin_lock_irqsave(&psinfo->buf_lock, flags);
173 } 174 }
174 memcpy(psinfo->buf, s, c); 175 memcpy(psinfo->buf, s, c);
175 psinfo->write(PSTORE_TYPE_CONSOLE, 0, NULL, 0, c, psinfo); 176 psinfo->write(PSTORE_TYPE_CONSOLE, 0, &id, 0, c, psinfo);
176 spin_unlock_irqrestore(&psinfo->buf_lock, flags); 177 spin_unlock_irqrestore(&psinfo->buf_lock, flags);
177 s += c; 178 s += c;
178 c = e - s; 179 c = e - s;
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index f27f01a98aa2..d83736fbc26c 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -1782,8 +1782,9 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
1782 1782
1783 BUG_ON(!th->t_trans_id); 1783 BUG_ON(!th->t_trans_id);
1784 1784
1785 dquot_initialize(inode); 1785 reiserfs_write_unlock(inode->i_sb);
1786 err = dquot_alloc_inode(inode); 1786 err = dquot_alloc_inode(inode);
1787 reiserfs_write_lock(inode->i_sb);
1787 if (err) 1788 if (err)
1788 goto out_end_trans; 1789 goto out_end_trans;
1789 if (!dir->i_nlink) { 1790 if (!dir->i_nlink) {
@@ -1979,8 +1980,10 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
1979 1980
1980 out_end_trans: 1981 out_end_trans:
1981 journal_end(th, th->t_super, th->t_blocks_allocated); 1982 journal_end(th, th->t_super, th->t_blocks_allocated);
1983 reiserfs_write_unlock(inode->i_sb);
1982 /* Drop can be outside and it needs more credits so it's better to have it outside */ 1984 /* Drop can be outside and it needs more credits so it's better to have it outside */
1983 dquot_drop(inode); 1985 dquot_drop(inode);
1986 reiserfs_write_lock(inode->i_sb);
1984 inode->i_flags |= S_NOQUOTA; 1987 inode->i_flags |= S_NOQUOTA;
1985 make_bad_inode(inode); 1988 make_bad_inode(inode);
1986 1989
@@ -3103,10 +3106,9 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
3103 /* must be turned off for recursive notify_change calls */ 3106 /* must be turned off for recursive notify_change calls */
3104 ia_valid = attr->ia_valid &= ~(ATTR_KILL_SUID|ATTR_KILL_SGID); 3107 ia_valid = attr->ia_valid &= ~(ATTR_KILL_SUID|ATTR_KILL_SGID);
3105 3108
3106 depth = reiserfs_write_lock_once(inode->i_sb);
3107 if (is_quota_modification(inode, attr)) 3109 if (is_quota_modification(inode, attr))
3108 dquot_initialize(inode); 3110 dquot_initialize(inode);
3109 3111 depth = reiserfs_write_lock_once(inode->i_sb);
3110 if (attr->ia_valid & ATTR_SIZE) { 3112 if (attr->ia_valid & ATTR_SIZE) {
3111 /* version 2 items will be caught by the s_maxbytes check 3113 /* version 2 items will be caught by the s_maxbytes check
3112 ** done for us in vmtruncate 3114 ** done for us in vmtruncate
@@ -3170,7 +3172,9 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
3170 error = journal_begin(&th, inode->i_sb, jbegin_count); 3172 error = journal_begin(&th, inode->i_sb, jbegin_count);
3171 if (error) 3173 if (error)
3172 goto out; 3174 goto out;
3175 reiserfs_write_unlock_once(inode->i_sb, depth);
3173 error = dquot_transfer(inode, attr); 3176 error = dquot_transfer(inode, attr);
3177 depth = reiserfs_write_lock_once(inode->i_sb);
3174 if (error) { 3178 if (error) {
3175 journal_end(&th, inode->i_sb, jbegin_count); 3179 journal_end(&th, inode->i_sb, jbegin_count);
3176 goto out; 3180 goto out;
diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c
index f8afa4b162b8..2f40a4c70a4d 100644
--- a/fs/reiserfs/stree.c
+++ b/fs/reiserfs/stree.c
@@ -1968,7 +1968,9 @@ int reiserfs_paste_into_item(struct reiserfs_transaction_handle *th, struct tree
1968 key2type(&(key->on_disk_key))); 1968 key2type(&(key->on_disk_key)));
1969#endif 1969#endif
1970 1970
1971 reiserfs_write_unlock(inode->i_sb);
1971 retval = dquot_alloc_space_nodirty(inode, pasted_size); 1972 retval = dquot_alloc_space_nodirty(inode, pasted_size);
1973 reiserfs_write_lock(inode->i_sb);
1972 if (retval) { 1974 if (retval) {
1973 pathrelse(search_path); 1975 pathrelse(search_path);
1974 return retval; 1976 return retval;
@@ -2061,9 +2063,11 @@ int reiserfs_insert_item(struct reiserfs_transaction_handle *th,
2061 "reiserquota insert_item(): allocating %u id=%u type=%c", 2063 "reiserquota insert_item(): allocating %u id=%u type=%c",
2062 quota_bytes, inode->i_uid, head2type(ih)); 2064 quota_bytes, inode->i_uid, head2type(ih));
2063#endif 2065#endif
2066 reiserfs_write_unlock(inode->i_sb);
2064 /* We can't dirty inode here. It would be immediately written but 2067 /* We can't dirty inode here. It would be immediately written but
2065 * appropriate stat item isn't inserted yet... */ 2068 * appropriate stat item isn't inserted yet... */
2066 retval = dquot_alloc_space_nodirty(inode, quota_bytes); 2069 retval = dquot_alloc_space_nodirty(inode, quota_bytes);
2070 reiserfs_write_lock(inode->i_sb);
2067 if (retval) { 2071 if (retval) {
2068 pathrelse(path); 2072 pathrelse(path);
2069 return retval; 2073 return retval;
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index 1078ae179993..418bdc3a57da 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -298,7 +298,9 @@ static int finish_unfinished(struct super_block *s)
298 retval = remove_save_link_only(s, &save_link_key, 0); 298 retval = remove_save_link_only(s, &save_link_key, 0);
299 continue; 299 continue;
300 } 300 }
301 reiserfs_write_unlock(s);
301 dquot_initialize(inode); 302 dquot_initialize(inode);
303 reiserfs_write_lock(s);
302 304
303 if (truncate && S_ISDIR(inode->i_mode)) { 305 if (truncate && S_ISDIR(inode->i_mode)) {
304 /* We got a truncate request for a dir which is impossible. 306 /* We got a truncate request for a dir which is impossible.
@@ -1335,7 +1337,7 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
1335 kfree(qf_names[i]); 1337 kfree(qf_names[i]);
1336#endif 1338#endif
1337 err = -EINVAL; 1339 err = -EINVAL;
1338 goto out_err; 1340 goto out_unlock;
1339 } 1341 }
1340#ifdef CONFIG_QUOTA 1342#ifdef CONFIG_QUOTA
1341 handle_quota_files(s, qf_names, &qfmt); 1343 handle_quota_files(s, qf_names, &qfmt);
@@ -1379,7 +1381,7 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
1379 if (blocks) { 1381 if (blocks) {
1380 err = reiserfs_resize(s, blocks); 1382 err = reiserfs_resize(s, blocks);
1381 if (err != 0) 1383 if (err != 0)
1382 goto out_err; 1384 goto out_unlock;
1383 } 1385 }
1384 1386
1385 if (*mount_flags & MS_RDONLY) { 1387 if (*mount_flags & MS_RDONLY) {
@@ -1389,9 +1391,15 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
1389 /* it is read-only already */ 1391 /* it is read-only already */
1390 goto out_ok; 1392 goto out_ok;
1391 1393
1394 /*
1395 * Drop write lock. Quota will retake it when needed and lock
1396 * ordering requires calling dquot_suspend() without it.
1397 */
1398 reiserfs_write_unlock(s);
1392 err = dquot_suspend(s, -1); 1399 err = dquot_suspend(s, -1);
1393 if (err < 0) 1400 if (err < 0)
1394 goto out_err; 1401 goto out_err;
1402 reiserfs_write_lock(s);
1395 1403
1396 /* try to remount file system with read-only permissions */ 1404 /* try to remount file system with read-only permissions */
1397 if (sb_umount_state(rs) == REISERFS_VALID_FS 1405 if (sb_umount_state(rs) == REISERFS_VALID_FS
@@ -1401,7 +1409,7 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
1401 1409
1402 err = journal_begin(&th, s, 10); 1410 err = journal_begin(&th, s, 10);
1403 if (err) 1411 if (err)
1404 goto out_err; 1412 goto out_unlock;
1405 1413
1406 /* Mounting a rw partition read-only. */ 1414 /* Mounting a rw partition read-only. */
1407 reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1); 1415 reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1);
@@ -1416,7 +1424,7 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
1416 1424
1417 if (reiserfs_is_journal_aborted(journal)) { 1425 if (reiserfs_is_journal_aborted(journal)) {
1418 err = journal->j_errno; 1426 err = journal->j_errno;
1419 goto out_err; 1427 goto out_unlock;
1420 } 1428 }
1421 1429
1422 handle_data_mode(s, mount_options); 1430 handle_data_mode(s, mount_options);
@@ -1425,7 +1433,7 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
1425 s->s_flags &= ~MS_RDONLY; /* now it is safe to call journal_begin */ 1433 s->s_flags &= ~MS_RDONLY; /* now it is safe to call journal_begin */
1426 err = journal_begin(&th, s, 10); 1434 err = journal_begin(&th, s, 10);
1427 if (err) 1435 if (err)
1428 goto out_err; 1436 goto out_unlock;
1429 1437
1430 /* Mount a partition which is read-only, read-write */ 1438 /* Mount a partition which is read-only, read-write */
1431 reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1); 1439 reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1);
@@ -1442,10 +1450,16 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
1442 SB_JOURNAL(s)->j_must_wait = 1; 1450 SB_JOURNAL(s)->j_must_wait = 1;
1443 err = journal_end(&th, s, 10); 1451 err = journal_end(&th, s, 10);
1444 if (err) 1452 if (err)
1445 goto out_err; 1453 goto out_unlock;
1446 1454
1447 if (!(*mount_flags & MS_RDONLY)) { 1455 if (!(*mount_flags & MS_RDONLY)) {
1456 /*
1457 * Drop write lock. Quota will retake it when needed and lock
1458 * ordering requires calling dquot_resume() without it.
1459 */
1460 reiserfs_write_unlock(s);
1448 dquot_resume(s, -1); 1461 dquot_resume(s, -1);
1462 reiserfs_write_lock(s);
1449 finish_unfinished(s); 1463 finish_unfinished(s);
1450 reiserfs_xattr_init(s, *mount_flags); 1464 reiserfs_xattr_init(s, *mount_flags);
1451 } 1465 }
@@ -1455,9 +1469,10 @@ out_ok:
1455 reiserfs_write_unlock(s); 1469 reiserfs_write_unlock(s);
1456 return 0; 1470 return 0;
1457 1471
1472out_unlock:
1473 reiserfs_write_unlock(s);
1458out_err: 1474out_err:
1459 kfree(new_opts); 1475 kfree(new_opts);
1460 reiserfs_write_unlock(s);
1461 return err; 1476 return err;
1462} 1477}
1463 1478
@@ -2095,13 +2110,15 @@ static int reiserfs_write_dquot(struct dquot *dquot)
2095 REISERFS_QUOTA_TRANS_BLOCKS(dquot->dq_sb)); 2110 REISERFS_QUOTA_TRANS_BLOCKS(dquot->dq_sb));
2096 if (ret) 2111 if (ret)
2097 goto out; 2112 goto out;
2113 reiserfs_write_unlock(dquot->dq_sb);
2098 ret = dquot_commit(dquot); 2114 ret = dquot_commit(dquot);
2115 reiserfs_write_lock(dquot->dq_sb);
2099 err = 2116 err =
2100 journal_end(&th, dquot->dq_sb, 2117 journal_end(&th, dquot->dq_sb,
2101 REISERFS_QUOTA_TRANS_BLOCKS(dquot->dq_sb)); 2118 REISERFS_QUOTA_TRANS_BLOCKS(dquot->dq_sb));
2102 if (!ret && err) 2119 if (!ret && err)
2103 ret = err; 2120 ret = err;
2104 out: 2121out:
2105 reiserfs_write_unlock(dquot->dq_sb); 2122 reiserfs_write_unlock(dquot->dq_sb);
2106 return ret; 2123 return ret;
2107} 2124}
@@ -2117,13 +2134,15 @@ static int reiserfs_acquire_dquot(struct dquot *dquot)
2117 REISERFS_QUOTA_INIT_BLOCKS(dquot->dq_sb)); 2134 REISERFS_QUOTA_INIT_BLOCKS(dquot->dq_sb));
2118 if (ret) 2135 if (ret)
2119 goto out; 2136 goto out;
2137 reiserfs_write_unlock(dquot->dq_sb);
2120 ret = dquot_acquire(dquot); 2138 ret = dquot_acquire(dquot);
2139 reiserfs_write_lock(dquot->dq_sb);
2121 err = 2140 err =
2122 journal_end(&th, dquot->dq_sb, 2141 journal_end(&th, dquot->dq_sb,
2123 REISERFS_QUOTA_INIT_BLOCKS(dquot->dq_sb)); 2142 REISERFS_QUOTA_INIT_BLOCKS(dquot->dq_sb));
2124 if (!ret && err) 2143 if (!ret && err)
2125 ret = err; 2144 ret = err;
2126 out: 2145out:
2127 reiserfs_write_unlock(dquot->dq_sb); 2146 reiserfs_write_unlock(dquot->dq_sb);
2128 return ret; 2147 return ret;
2129} 2148}
@@ -2137,19 +2156,21 @@ static int reiserfs_release_dquot(struct dquot *dquot)
2137 ret = 2156 ret =
2138 journal_begin(&th, dquot->dq_sb, 2157 journal_begin(&th, dquot->dq_sb,
2139 REISERFS_QUOTA_DEL_BLOCKS(dquot->dq_sb)); 2158 REISERFS_QUOTA_DEL_BLOCKS(dquot->dq_sb));
2159 reiserfs_write_unlock(dquot->dq_sb);
2140 if (ret) { 2160 if (ret) {
2141 /* Release dquot anyway to avoid endless cycle in dqput() */ 2161 /* Release dquot anyway to avoid endless cycle in dqput() */
2142 dquot_release(dquot); 2162 dquot_release(dquot);
2143 goto out; 2163 goto out;
2144 } 2164 }
2145 ret = dquot_release(dquot); 2165 ret = dquot_release(dquot);
2166 reiserfs_write_lock(dquot->dq_sb);
2146 err = 2167 err =
2147 journal_end(&th, dquot->dq_sb, 2168 journal_end(&th, dquot->dq_sb,
2148 REISERFS_QUOTA_DEL_BLOCKS(dquot->dq_sb)); 2169 REISERFS_QUOTA_DEL_BLOCKS(dquot->dq_sb));
2149 if (!ret && err) 2170 if (!ret && err)
2150 ret = err; 2171 ret = err;
2151 out:
2152 reiserfs_write_unlock(dquot->dq_sb); 2172 reiserfs_write_unlock(dquot->dq_sb);
2173out:
2153 return ret; 2174 return ret;
2154} 2175}
2155 2176
@@ -2174,11 +2195,13 @@ static int reiserfs_write_info(struct super_block *sb, int type)
2174 ret = journal_begin(&th, sb, 2); 2195 ret = journal_begin(&th, sb, 2);
2175 if (ret) 2196 if (ret)
2176 goto out; 2197 goto out;
2198 reiserfs_write_unlock(sb);
2177 ret = dquot_commit_info(sb, type); 2199 ret = dquot_commit_info(sb, type);
2200 reiserfs_write_lock(sb);
2178 err = journal_end(&th, sb, 2); 2201 err = journal_end(&th, sb, 2);
2179 if (!ret && err) 2202 if (!ret && err)
2180 ret = err; 2203 ret = err;
2181 out: 2204out:
2182 reiserfs_write_unlock(sb); 2205 reiserfs_write_unlock(sb);
2183 return ret; 2206 return ret;
2184} 2207}
@@ -2203,8 +2226,11 @@ static int reiserfs_quota_on(struct super_block *sb, int type, int format_id,
2203 struct reiserfs_transaction_handle th; 2226 struct reiserfs_transaction_handle th;
2204 int opt = type == USRQUOTA ? REISERFS_USRQUOTA : REISERFS_GRPQUOTA; 2227 int opt = type == USRQUOTA ? REISERFS_USRQUOTA : REISERFS_GRPQUOTA;
2205 2228
2206 if (!(REISERFS_SB(sb)->s_mount_opt & (1 << opt))) 2229 reiserfs_write_lock(sb);
2207 return -EINVAL; 2230 if (!(REISERFS_SB(sb)->s_mount_opt & (1 << opt))) {
2231 err = -EINVAL;
2232 goto out;
2233 }
2208 2234
2209 /* Quotafile not on the same filesystem? */ 2235 /* Quotafile not on the same filesystem? */
2210 if (path->dentry->d_sb != sb) { 2236 if (path->dentry->d_sb != sb) {
@@ -2246,8 +2272,10 @@ static int reiserfs_quota_on(struct super_block *sb, int type, int format_id,
2246 if (err) 2272 if (err)
2247 goto out; 2273 goto out;
2248 } 2274 }
2249 err = dquot_quota_on(sb, type, format_id, path); 2275 reiserfs_write_unlock(sb);
2276 return dquot_quota_on(sb, type, format_id, path);
2250out: 2277out:
2278 reiserfs_write_unlock(sb);
2251 return err; 2279 return err;
2252} 2280}
2253 2281
@@ -2320,7 +2348,9 @@ static ssize_t reiserfs_quota_write(struct super_block *sb, int type,
2320 tocopy = sb->s_blocksize - offset < towrite ? 2348 tocopy = sb->s_blocksize - offset < towrite ?
2321 sb->s_blocksize - offset : towrite; 2349 sb->s_blocksize - offset : towrite;
2322 tmp_bh.b_state = 0; 2350 tmp_bh.b_state = 0;
2351 reiserfs_write_lock(sb);
2323 err = reiserfs_get_block(inode, blk, &tmp_bh, GET_BLOCK_CREATE); 2352 err = reiserfs_get_block(inode, blk, &tmp_bh, GET_BLOCK_CREATE);
2353 reiserfs_write_unlock(sb);
2324 if (err) 2354 if (err)
2325 goto out; 2355 goto out;
2326 if (offset || tocopy != sb->s_blocksize) 2356 if (offset || tocopy != sb->s_blocksize)
@@ -2336,10 +2366,12 @@ static ssize_t reiserfs_quota_write(struct super_block *sb, int type,
2336 flush_dcache_page(bh->b_page); 2366 flush_dcache_page(bh->b_page);
2337 set_buffer_uptodate(bh); 2367 set_buffer_uptodate(bh);
2338 unlock_buffer(bh); 2368 unlock_buffer(bh);
2369 reiserfs_write_lock(sb);
2339 reiserfs_prepare_for_journal(sb, bh, 1); 2370 reiserfs_prepare_for_journal(sb, bh, 1);
2340 journal_mark_dirty(current->journal_info, sb, bh); 2371 journal_mark_dirty(current->journal_info, sb, bh);
2341 if (!journal_quota) 2372 if (!journal_quota)
2342 reiserfs_add_ordered_list(inode, bh); 2373 reiserfs_add_ordered_list(inode, bh);
2374 reiserfs_write_unlock(sb);
2343 brelse(bh); 2375 brelse(bh);
2344 offset = 0; 2376 offset = 0;
2345 towrite -= tocopy; 2377 towrite -= tocopy;
diff --git a/fs/ubifs/find.c b/fs/ubifs/find.c
index 28ec13af28d9..2dcf3d473fec 100644
--- a/fs/ubifs/find.c
+++ b/fs/ubifs/find.c
@@ -681,8 +681,16 @@ int ubifs_find_free_leb_for_idx(struct ubifs_info *c)
681 if (!lprops) { 681 if (!lprops) {
682 lprops = ubifs_fast_find_freeable(c); 682 lprops = ubifs_fast_find_freeable(c);
683 if (!lprops) { 683 if (!lprops) {
684 ubifs_assert(c->freeable_cnt == 0); 684 /*
685 if (c->lst.empty_lebs - c->lst.taken_empty_lebs > 0) { 685 * The first condition means the following: go scan the
686 * LPT if there are uncategorized lprops, which means
687 * there may be freeable LEBs there (UBIFS does not
688 * store the information about freeable LEBs in the
689 * master node).
690 */
691 if (c->in_a_category_cnt != c->main_lebs ||
692 c->lst.empty_lebs - c->lst.taken_empty_lebs > 0) {
693 ubifs_assert(c->freeable_cnt == 0);
686 lprops = scan_for_leb_for_idx(c); 694 lprops = scan_for_leb_for_idx(c);
687 if (IS_ERR(lprops)) { 695 if (IS_ERR(lprops)) {
688 err = PTR_ERR(lprops); 696 err = PTR_ERR(lprops);
diff --git a/fs/ubifs/lprops.c b/fs/ubifs/lprops.c
index e5a2a35a46dc..46190a7c42a6 100644
--- a/fs/ubifs/lprops.c
+++ b/fs/ubifs/lprops.c
@@ -300,8 +300,11 @@ void ubifs_add_to_cat(struct ubifs_info *c, struct ubifs_lprops *lprops,
300 default: 300 default:
301 ubifs_assert(0); 301 ubifs_assert(0);
302 } 302 }
303
303 lprops->flags &= ~LPROPS_CAT_MASK; 304 lprops->flags &= ~LPROPS_CAT_MASK;
304 lprops->flags |= cat; 305 lprops->flags |= cat;
306 c->in_a_category_cnt += 1;
307 ubifs_assert(c->in_a_category_cnt <= c->main_lebs);
305} 308}
306 309
307/** 310/**
@@ -334,6 +337,9 @@ static void ubifs_remove_from_cat(struct ubifs_info *c,
334 default: 337 default:
335 ubifs_assert(0); 338 ubifs_assert(0);
336 } 339 }
340
341 c->in_a_category_cnt -= 1;
342 ubifs_assert(c->in_a_category_cnt >= 0);
337} 343}
338 344
339/** 345/**
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index 5486346d0a3f..d133c276fe05 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -1183,6 +1183,8 @@ struct ubifs_debug_info;
1183 * @freeable_list: list of freeable non-index LEBs (free + dirty == @leb_size) 1183 * @freeable_list: list of freeable non-index LEBs (free + dirty == @leb_size)
1184 * @frdi_idx_list: list of freeable index LEBs (free + dirty == @leb_size) 1184 * @frdi_idx_list: list of freeable index LEBs (free + dirty == @leb_size)
1185 * @freeable_cnt: number of freeable LEBs in @freeable_list 1185 * @freeable_cnt: number of freeable LEBs in @freeable_list
1186 * @in_a_category_cnt: count of lprops which are in a certain category, which
1187 * basically meants that they were loaded from the flash
1186 * 1188 *
1187 * @ltab_lnum: LEB number of LPT's own lprops table 1189 * @ltab_lnum: LEB number of LPT's own lprops table
1188 * @ltab_offs: offset of LPT's own lprops table 1190 * @ltab_offs: offset of LPT's own lprops table
@@ -1412,6 +1414,7 @@ struct ubifs_info {
1412 struct list_head freeable_list; 1414 struct list_head freeable_list;
1413 struct list_head frdi_idx_list; 1415 struct list_head frdi_idx_list;
1414 int freeable_cnt; 1416 int freeable_cnt;
1417 int in_a_category_cnt;
1415 1418
1416 int ltab_lnum; 1419 int ltab_lnum;
1417 int ltab_offs; 1420 int ltab_offs;
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index e562dd43f41f..e57e2daa357c 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -481,11 +481,17 @@ static inline int bio_add_buffer(struct bio *bio, struct buffer_head *bh)
481 * 481 *
482 * The fix is two passes across the ioend list - one to start writeback on the 482 * The fix is two passes across the ioend list - one to start writeback on the
483 * buffer_heads, and then submit them for I/O on the second pass. 483 * buffer_heads, and then submit them for I/O on the second pass.
484 *
485 * If @fail is non-zero, it means that we have a situation where some part of
486 * the submission process has failed after we have marked paged for writeback
487 * and unlocked them. In this situation, we need to fail the ioend chain rather
488 * than submit it to IO. This typically only happens on a filesystem shutdown.
484 */ 489 */
485STATIC void 490STATIC void
486xfs_submit_ioend( 491xfs_submit_ioend(
487 struct writeback_control *wbc, 492 struct writeback_control *wbc,
488 xfs_ioend_t *ioend) 493 xfs_ioend_t *ioend,
494 int fail)
489{ 495{
490 xfs_ioend_t *head = ioend; 496 xfs_ioend_t *head = ioend;
491 xfs_ioend_t *next; 497 xfs_ioend_t *next;
@@ -506,6 +512,18 @@ xfs_submit_ioend(
506 next = ioend->io_list; 512 next = ioend->io_list;
507 bio = NULL; 513 bio = NULL;
508 514
515 /*
516 * If we are failing the IO now, just mark the ioend with an
517 * error and finish it. This will run IO completion immediately
518 * as there is only one reference to the ioend at this point in
519 * time.
520 */
521 if (fail) {
522 ioend->io_error = -fail;
523 xfs_finish_ioend(ioend);
524 continue;
525 }
526
509 for (bh = ioend->io_buffer_head; bh; bh = bh->b_private) { 527 for (bh = ioend->io_buffer_head; bh; bh = bh->b_private) {
510 528
511 if (!bio) { 529 if (!bio) {
@@ -1060,7 +1078,18 @@ xfs_vm_writepage(
1060 1078
1061 xfs_start_page_writeback(page, 1, count); 1079 xfs_start_page_writeback(page, 1, count);
1062 1080
1063 if (ioend && imap_valid) { 1081 /* if there is no IO to be submitted for this page, we are done */
1082 if (!ioend)
1083 return 0;
1084
1085 ASSERT(iohead);
1086
1087 /*
1088 * Any errors from this point onwards need tobe reported through the IO
1089 * completion path as we have marked the initial page as under writeback
1090 * and unlocked it.
1091 */
1092 if (imap_valid) {
1064 xfs_off_t end_index; 1093 xfs_off_t end_index;
1065 1094
1066 end_index = imap.br_startoff + imap.br_blockcount; 1095 end_index = imap.br_startoff + imap.br_blockcount;
@@ -1079,20 +1108,15 @@ xfs_vm_writepage(
1079 wbc, end_index); 1108 wbc, end_index);
1080 } 1109 }
1081 1110
1082 if (iohead) {
1083 /*
1084 * Reserve log space if we might write beyond the on-disk
1085 * inode size.
1086 */
1087 if (ioend->io_type != XFS_IO_UNWRITTEN &&
1088 xfs_ioend_is_append(ioend)) {
1089 err = xfs_setfilesize_trans_alloc(ioend);
1090 if (err)
1091 goto error;
1092 }
1093 1111
1094 xfs_submit_ioend(wbc, iohead); 1112 /*
1095 } 1113 * Reserve log space if we might write beyond the on-disk inode size.
1114 */
1115 err = 0;
1116 if (ioend->io_type != XFS_IO_UNWRITTEN && xfs_ioend_is_append(ioend))
1117 err = xfs_setfilesize_trans_alloc(ioend);
1118
1119 xfs_submit_ioend(wbc, iohead, err);
1096 1120
1097 return 0; 1121 return 0;
1098 1122
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c
index d330111ca738..70eec1829776 100644
--- a/fs/xfs/xfs_attr_leaf.c
+++ b/fs/xfs/xfs_attr_leaf.c
@@ -1291,6 +1291,7 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
1291 leaf2 = blk2->bp->b_addr; 1291 leaf2 = blk2->bp->b_addr;
1292 ASSERT(leaf1->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1292 ASSERT(leaf1->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
1293 ASSERT(leaf2->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1293 ASSERT(leaf2->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
1294 ASSERT(leaf2->hdr.count == 0);
1294 args = state->args; 1295 args = state->args;
1295 1296
1296 trace_xfs_attr_leaf_rebalance(args); 1297 trace_xfs_attr_leaf_rebalance(args);
@@ -1361,6 +1362,7 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
1361 * I assert that since all callers pass in an empty 1362 * I assert that since all callers pass in an empty
1362 * second buffer, this code should never execute. 1363 * second buffer, this code should never execute.
1363 */ 1364 */
1365 ASSERT(0);
1364 1366
1365 /* 1367 /*
1366 * Figure the total bytes to be added to the destination leaf. 1368 * Figure the total bytes to be added to the destination leaf.
@@ -1422,10 +1424,24 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
1422 args->index2 = 0; 1424 args->index2 = 0;
1423 args->blkno2 = blk2->blkno; 1425 args->blkno2 = blk2->blkno;
1424 } else { 1426 } else {
1427 /*
1428 * On a double leaf split, the original attr location
1429 * is already stored in blkno2/index2, so don't
1430 * overwrite it overwise we corrupt the tree.
1431 */
1425 blk2->index = blk1->index 1432 blk2->index = blk1->index
1426 - be16_to_cpu(leaf1->hdr.count); 1433 - be16_to_cpu(leaf1->hdr.count);
1427 args->index = args->index2 = blk2->index; 1434 args->index = blk2->index;
1428 args->blkno = args->blkno2 = blk2->blkno; 1435 args->blkno = blk2->blkno;
1436 if (!state->extravalid) {
1437 /*
1438 * set the new attr location to match the old
1439 * one and let the higher level split code
1440 * decide where in the leaf to place it.
1441 */
1442 args->index2 = blk2->index;
1443 args->blkno2 = blk2->blkno;
1444 }
1429 } 1445 }
1430 } else { 1446 } else {
1431 ASSERT(state->inleaf == 1); 1447 ASSERT(state->inleaf == 1);
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 933b7930b863..4b0b8dd1b7b0 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -1197,9 +1197,14 @@ xfs_buf_bio_end_io(
1197{ 1197{
1198 xfs_buf_t *bp = (xfs_buf_t *)bio->bi_private; 1198 xfs_buf_t *bp = (xfs_buf_t *)bio->bi_private;
1199 1199
1200 xfs_buf_ioerror(bp, -error); 1200 /*
1201 * don't overwrite existing errors - otherwise we can lose errors on
1202 * buffers that require multiple bios to complete.
1203 */
1204 if (!bp->b_error)
1205 xfs_buf_ioerror(bp, -error);
1201 1206
1202 if (!error && xfs_buf_is_vmapped(bp) && (bp->b_flags & XBF_READ)) 1207 if (!bp->b_error && xfs_buf_is_vmapped(bp) && (bp->b_flags & XBF_READ))
1203 invalidate_kernel_vmap_range(bp->b_addr, xfs_buf_vmap_len(bp)); 1208 invalidate_kernel_vmap_range(bp->b_addr, xfs_buf_vmap_len(bp));
1204 1209
1205 _xfs_buf_ioend(bp, 1); 1210 _xfs_buf_ioend(bp, 1);
@@ -1279,6 +1284,11 @@ next_chunk:
1279 if (size) 1284 if (size)
1280 goto next_chunk; 1285 goto next_chunk;
1281 } else { 1286 } else {
1287 /*
1288 * This is guaranteed not to be the last io reference count
1289 * because the caller (xfs_buf_iorequest) holds a count itself.
1290 */
1291 atomic_dec(&bp->b_io_remaining);
1282 xfs_buf_ioerror(bp, EIO); 1292 xfs_buf_ioerror(bp, EIO);
1283 bio_put(bio); 1293 bio_put(bio);
1284 } 1294 }
diff --git a/include/drm/drm_pciids.h b/include/drm/drm_pciids.h
index af1cbaf535ed..c5c35e629426 100644
--- a/include/drm/drm_pciids.h
+++ b/include/drm/drm_pciids.h
@@ -210,6 +210,7 @@
210 {0x1002, 0x6798, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \ 210 {0x1002, 0x6798, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \
211 {0x1002, 0x6799, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \ 211 {0x1002, 0x6799, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \
212 {0x1002, 0x679A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \ 212 {0x1002, 0x679A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \
213 {0x1002, 0x679B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \
213 {0x1002, 0x679E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \ 214 {0x1002, 0x679E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \
214 {0x1002, 0x679F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \ 215 {0x1002, 0x679F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \
215 {0x1002, 0x6800, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ 216 {0x1002, 0x6800, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
diff --git a/include/linux/atmel-ssc.h b/include/linux/atmel-ssc.h
index 4eb31752e2b7..deb0ae58b99b 100644
--- a/include/linux/atmel-ssc.h
+++ b/include/linux/atmel-ssc.h
@@ -5,10 +5,16 @@
5#include <linux/list.h> 5#include <linux/list.h>
6#include <linux/io.h> 6#include <linux/io.h>
7 7
8struct atmel_ssc_platform_data {
9 int use_dma;
10};
11
8struct ssc_device { 12struct ssc_device {
9 struct list_head list; 13 struct list_head list;
14 resource_size_t phybase;
10 void __iomem *regs; 15 void __iomem *regs;
11 struct platform_device *pdev; 16 struct platform_device *pdev;
17 struct atmel_ssc_platform_data *pdata;
12 struct clk *clk; 18 struct clk *clk;
13 int user; 19 int user;
14 int irq; 20 int irq;
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index c12731582920..f9f5e9eeb9dd 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -335,8 +335,8 @@ const char *__clk_get_name(struct clk *clk);
335struct clk_hw *__clk_get_hw(struct clk *clk); 335struct clk_hw *__clk_get_hw(struct clk *clk);
336u8 __clk_get_num_parents(struct clk *clk); 336u8 __clk_get_num_parents(struct clk *clk);
337struct clk *__clk_get_parent(struct clk *clk); 337struct clk *__clk_get_parent(struct clk *clk);
338inline int __clk_get_enable_count(struct clk *clk); 338int __clk_get_enable_count(struct clk *clk);
339inline int __clk_get_prepare_count(struct clk *clk); 339int __clk_get_prepare_count(struct clk *clk);
340unsigned long __clk_get_rate(struct clk *clk); 340unsigned long __clk_get_rate(struct clk *clk);
341unsigned long __clk_get_flags(struct clk *clk); 341unsigned long __clk_get_flags(struct clk *clk);
342int __clk_is_enabled(struct clk *clk); 342int __clk_is_enabled(struct clk *clk);
diff --git a/include/linux/i2c-omap.h b/include/linux/i2c-omap.h
index df804ba73e0b..92a0dc75bc74 100644
--- a/include/linux/i2c-omap.h
+++ b/include/linux/i2c-omap.h
@@ -34,6 +34,7 @@ struct omap_i2c_bus_platform_data {
34 u32 clkrate; 34 u32 clkrate;
35 u32 rev; 35 u32 rev;
36 u32 flags; 36 u32 flags;
37 void (*set_mpu_wkup_lat)(struct device *dev, long set);
37}; 38};
38 39
39#endif 40#endif
diff --git a/include/linux/mfd/arizona/core.h b/include/linux/mfd/arizona/core.h
index dd231ac0bb1f..a580363a7d29 100644
--- a/include/linux/mfd/arizona/core.h
+++ b/include/linux/mfd/arizona/core.h
@@ -78,6 +78,8 @@ enum arizona_type {
78 78
79#define ARIZONA_NUM_IRQ 50 79#define ARIZONA_NUM_IRQ 50
80 80
81struct snd_soc_dapm_context;
82
81struct arizona { 83struct arizona {
82 struct regmap *regmap; 84 struct regmap *regmap;
83 struct device *dev; 85 struct device *dev;
@@ -98,6 +100,8 @@ struct arizona {
98 100
99 struct mutex clk_lock; 101 struct mutex clk_lock;
100 int clk32k_ref; 102 int clk32k_ref;
103
104 struct snd_soc_dapm_context *dapm;
101}; 105};
102 106
103int arizona_clk32k_enable(struct arizona *arizona); 107int arizona_clk32k_enable(struct arizona *arizona);
diff --git a/include/linux/mfd/arizona/pdata.h b/include/linux/mfd/arizona/pdata.h
index 7ab442905a57..8b1d1daaae16 100644
--- a/include/linux/mfd/arizona/pdata.h
+++ b/include/linux/mfd/arizona/pdata.h
@@ -62,6 +62,9 @@
62 62
63#define ARIZONA_MAX_OUTPUT 6 63#define ARIZONA_MAX_OUTPUT 6
64 64
65#define ARIZONA_HAP_ACT_ERM 0
66#define ARIZONA_HAP_ACT_LRA 2
67
65#define ARIZONA_MAX_PDM_SPK 2 68#define ARIZONA_MAX_PDM_SPK 2
66 69
67struct regulator_init_data; 70struct regulator_init_data;
@@ -114,6 +117,9 @@ struct arizona_pdata {
114 117
115 /** PDM speaker format */ 118 /** PDM speaker format */
116 unsigned int spk_fmt[ARIZONA_MAX_PDM_SPK]; 119 unsigned int spk_fmt[ARIZONA_MAX_PDM_SPK];
120
121 /** Haptic actuator type */
122 unsigned int hap_act;
117}; 123};
118 124
119#endif 125#endif
diff --git a/include/linux/mm.h b/include/linux/mm.h
index fa0680402738..bcaab4e6fe91 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1684,9 +1684,5 @@ static inline unsigned int debug_guardpage_minorder(void) { return 0; }
1684static inline bool page_is_guard(struct page *page) { return false; } 1684static inline bool page_is_guard(struct page *page) { return false; }
1685#endif /* CONFIG_DEBUG_PAGEALLOC */ 1685#endif /* CONFIG_DEBUG_PAGEALLOC */
1686 1686
1687extern void reset_zone_present_pages(void);
1688extern void fixup_zone_present_pages(int nid, unsigned long start_pfn,
1689 unsigned long end_pfn);
1690
1691#endif /* __KERNEL__ */ 1687#endif /* __KERNEL__ */
1692#endif /* _LINUX_MM_H */ 1688#endif /* _LINUX_MM_H */
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 50aaca81f63d..a23923ba8263 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -752,7 +752,7 @@ extern int init_currently_empty_zone(struct zone *zone, unsigned long start_pfn,
752 unsigned long size, 752 unsigned long size,
753 enum memmap_context context); 753 enum memmap_context context);
754 754
755extern void lruvec_init(struct lruvec *lruvec, struct zone *zone); 755extern void lruvec_init(struct lruvec *lruvec);
756 756
757static inline struct zone *lruvec_zone(struct lruvec *lruvec) 757static inline struct zone *lruvec_zone(struct lruvec *lruvec)
758{ 758{
diff --git a/include/linux/of_address.h b/include/linux/of_address.h
index e20e3af68fb6..0506eb53519b 100644
--- a/include/linux/of_address.h
+++ b/include/linux/of_address.h
@@ -42,10 +42,12 @@ static inline struct device_node *of_find_matching_node_by_address(
42{ 42{
43 return NULL; 43 return NULL;
44} 44}
45#ifndef of_iomap
45static inline void __iomem *of_iomap(struct device_node *device, int index) 46static inline void __iomem *of_iomap(struct device_node *device, int index)
46{ 47{
47 return NULL; 48 return NULL;
48} 49}
50#endif
49static inline const __be32 *of_get_address(struct device_node *dev, int index, 51static inline const __be32 *of_get_address(struct device_node *dev, int index,
50 u64 *size, unsigned int *flags) 52 u64 *size, unsigned int *flags)
51{ 53{
diff --git a/include/linux/platform_data/asoc-s3c.h b/include/linux/platform_data/asoc-s3c.h
index aa9875f77c40..88272591a895 100644
--- a/include/linux/platform_data/asoc-s3c.h
+++ b/include/linux/platform_data/asoc-s3c.h
@@ -38,12 +38,6 @@ struct samsung_i2s {
38#define QUIRK_NEED_RSTCLR (1 << 3) 38#define QUIRK_NEED_RSTCLR (1 << 3)
39 /* Quirks of the I2S controller */ 39 /* Quirks of the I2S controller */
40 u32 quirks; 40 u32 quirks;
41
42 /*
43 * Array of clock names that can be used to generate I2S signals.
44 * Also corresponds to clocks of I2SMOD[10]
45 */
46 const char **src_clk;
47 dma_addr_t idma_addr; 41 dma_addr_t idma_addr;
48}; 42};
49 43
diff --git a/include/linux/platform_data/davinci_asp.h b/include/linux/platform_data/davinci_asp.h
index d0c5825876f8..8db5ae03b6e3 100644
--- a/include/linux/platform_data/davinci_asp.h
+++ b/include/linux/platform_data/davinci_asp.h
@@ -16,12 +16,13 @@
16#ifndef __DAVINCI_ASP_H 16#ifndef __DAVINCI_ASP_H
17#define __DAVINCI_ASP_H 17#define __DAVINCI_ASP_H
18 18
19#include <linux/genalloc.h>
20
19struct snd_platform_data { 21struct snd_platform_data {
20 u32 tx_dma_offset; 22 u32 tx_dma_offset;
21 u32 rx_dma_offset; 23 u32 rx_dma_offset;
22 int asp_chan_q; /* event queue number for ASP channel */ 24 int asp_chan_q; /* event queue number for ASP channel */
23 int ram_chan_q; /* event queue number for RAM channel */ 25 int ram_chan_q; /* event queue number for RAM channel */
24 unsigned int codec_fmt;
25 /* 26 /*
26 * Allowing this is more efficient and eliminates left and right swaps 27 * Allowing this is more efficient and eliminates left and right swaps
27 * caused by underruns, but will swap the left and right channels 28 * caused by underruns, but will swap the left and right channels
@@ -30,6 +31,7 @@ struct snd_platform_data {
30 unsigned enable_channel_combine:1; 31 unsigned enable_channel_combine:1;
31 unsigned sram_size_playback; 32 unsigned sram_size_playback;
32 unsigned sram_size_capture; 33 unsigned sram_size_capture;
34 struct gen_pool *sram_pool;
33 35
34 /* 36 /*
35 * If McBSP peripheral gets the clock from an external pin, 37 * If McBSP peripheral gets the clock from an external pin,
diff --git a/include/linux/platform_data/omap-twl4030.h b/include/linux/platform_data/omap-twl4030.h
index c7bef788daab..ee60ef79d792 100644
--- a/include/linux/platform_data/omap-twl4030.h
+++ b/include/linux/platform_data/omap-twl4030.h
@@ -25,8 +25,34 @@
25#ifndef _OMAP_TWL4030_H_ 25#ifndef _OMAP_TWL4030_H_
26#define _OMAP_TWL4030_H_ 26#define _OMAP_TWL4030_H_
27 27
28/* To select if only one channel is connected in a stereo port */
29#define OMAP_TWL4030_LEFT (1 << 0)
30#define OMAP_TWL4030_RIGHT (1 << 1)
31
28struct omap_tw4030_pdata { 32struct omap_tw4030_pdata {
29 const char *card_name; 33 const char *card_name;
34 /* Voice port is connected to McBSP3 */
35 bool voice_connected;
36
37 /* The driver will parse the connection flags if this flag is set */
38 bool custom_routing;
39 /* Flags to indicate connected audio ports. */
40 u8 has_hs;
41 u8 has_hf;
42 u8 has_predriv;
43 u8 has_carkit;
44 bool has_ear;
45
46 bool has_mainmic;
47 bool has_submic;
48 bool has_hsmic;
49 bool has_carkitmic;
50 bool has_digimic0;
51 bool has_digimic1;
52 u8 has_linein;
53
54 /* Jack detect GPIO or <= 0 if it is not implemented */
55 int jack_detect;
30}; 56};
31 57
32#endif /* _OMAP_TWL4030_H_ */ 58#endif /* _OMAP_TWL4030_H_ */
diff --git a/include/linux/platform_data/omap_ocp2scp.h b/include/linux/platform_data/omap_ocp2scp.h
new file mode 100644
index 000000000000..5c6c3939355f
--- /dev/null
+++ b/include/linux/platform_data/omap_ocp2scp.h
@@ -0,0 +1,31 @@
1/*
2 * omap_ocp2scp.h -- ocp2scp header file
3 *
4 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * Author: Kishon Vijay Abraham I <kishon@ti.com>
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 */
18
19#ifndef __DRIVERS_OMAP_OCP2SCP_H
20#define __DRIVERS_OMAP_OCP2SCP_H
21
22struct omap_ocp2scp_dev {
23 const char *drv_name;
24 struct resource *res;
25};
26
27struct omap_ocp2scp_platform_data {
28 int dev_cnt;
29 struct omap_ocp2scp_dev **devices;
30};
31#endif /* __DRIVERS_OMAP_OCP2SCP_H */
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index e3bcc3f4dcb8..9f228d7f7ac4 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -133,7 +133,7 @@ struct regmap_config {
133 enum regmap_endian val_format_endian; 133 enum regmap_endian val_format_endian;
134 134
135 const struct regmap_range_cfg *ranges; 135 const struct regmap_range_cfg *ranges;
136 unsigned int n_ranges; 136 unsigned int num_ranges;
137}; 137};
138 138
139/** 139/**
@@ -142,6 +142,8 @@ struct regmap_config {
142 * 1. page selector register update; 142 * 1. page selector register update;
143 * 2. access through data window registers. 143 * 2. access through data window registers.
144 * 144 *
145 * @name: Descriptive name for diagnostics
146 *
145 * @range_min: Address of the lowest register address in virtual range. 147 * @range_min: Address of the lowest register address in virtual range.
146 * @range_max: Address of the highest register in virtual range. 148 * @range_max: Address of the highest register in virtual range.
147 * 149 *
@@ -153,6 +155,8 @@ struct regmap_config {
153 * @window_len: Number of registers in data window. 155 * @window_len: Number of registers in data window.
154 */ 156 */
155struct regmap_range_cfg { 157struct regmap_range_cfg {
158 const char *name;
159
156 /* Registers of virtual address range */ 160 /* Registers of virtual address range */
157 unsigned int range_min; 161 unsigned int range_min;
158 unsigned int range_max; 162 unsigned int range_max;
diff --git a/include/linux/rio.h b/include/linux/rio.h
index 4187da511006..a3e784278667 100644
--- a/include/linux/rio.h
+++ b/include/linux/rio.h
@@ -275,9 +275,11 @@ struct rio_id_table {
275 * struct rio_net - RIO network info 275 * struct rio_net - RIO network info
276 * @node: Node in global list of RIO networks 276 * @node: Node in global list of RIO networks
277 * @devices: List of devices in this network 277 * @devices: List of devices in this network
278 * @switches: List of switches in this netowrk
278 * @mports: List of master ports accessing this network 279 * @mports: List of master ports accessing this network
279 * @hport: Default port for accessing this network 280 * @hport: Default port for accessing this network
280 * @id: RIO network ID 281 * @id: RIO network ID
282 * @destid_table: destID allocation table
281 */ 283 */
282struct rio_net { 284struct rio_net {
283 struct list_head node; /* node in list of networks */ 285 struct list_head node; /* node in list of networks */
diff --git a/include/linux/spi/ads7846.h b/include/linux/spi/ads7846.h
index c64de9dd7631..2f694f3846a9 100644
--- a/include/linux/spi/ads7846.h
+++ b/include/linux/spi/ads7846.h
@@ -46,8 +46,9 @@ struct ads7846_platform_data {
46 u16 debounce_rep; /* additional consecutive good readings 46 u16 debounce_rep; /* additional consecutive good readings
47 * required after the first two */ 47 * required after the first two */
48 int gpio_pendown; /* the GPIO used to decide the pendown 48 int gpio_pendown; /* the GPIO used to decide the pendown
49 * state if get_pendown_state == NULL 49 * state if get_pendown_state == NULL */
50 */ 50 int gpio_pendown_debounce; /* platform specific debounce time for
51 * the gpio_pendown */
51 int (*get_pendown_state)(void); 52 int (*get_pendown_state)(void);
52 int (*filter_init) (const struct ads7846_platform_data *pdata, 53 int (*filter_init) (const struct ads7846_platform_data *pdata,
53 void **filter_data); 54 void **filter_data);
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 6f0ba01afe73..63445ede48bb 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -1351,7 +1351,7 @@ struct xfrm6_tunnel {
1351}; 1351};
1352 1352
1353extern void xfrm_init(void); 1353extern void xfrm_init(void);
1354extern void xfrm4_init(int rt_hash_size); 1354extern void xfrm4_init(void);
1355extern int xfrm_state_init(struct net *net); 1355extern int xfrm_state_init(struct net *net);
1356extern void xfrm_state_fini(struct net *net); 1356extern void xfrm_state_fini(struct net *net);
1357extern void xfrm4_state_init(void); 1357extern void xfrm4_state_init(void);
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 88fae8d20154..55367b04dc94 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -135,6 +135,8 @@ struct scsi_device {
135 * because we did a bus reset. */ 135 * because we did a bus reset. */
136 unsigned use_10_for_rw:1; /* first try 10-byte read / write */ 136 unsigned use_10_for_rw:1; /* first try 10-byte read / write */
137 unsigned use_10_for_ms:1; /* first try 10-byte mode sense/select */ 137 unsigned use_10_for_ms:1; /* first try 10-byte mode sense/select */
138 unsigned no_report_opcodes:1; /* no REPORT SUPPORTED OPERATION CODES */
139 unsigned no_write_same:1; /* no WRITE SAME command */
138 unsigned skip_ms_page_8:1; /* do not use MODE SENSE page 0x08 */ 140 unsigned skip_ms_page_8:1; /* do not use MODE SENSE page 0x08 */
139 unsigned skip_ms_page_3f:1; /* do not use MODE SENSE page 0x3f */ 141 unsigned skip_ms_page_3f:1; /* do not use MODE SENSE page 0x3f */
140 unsigned skip_vpd_pages:1; /* do not read VPD pages */ 142 unsigned skip_vpd_pages:1; /* do not read VPD pages */
@@ -362,6 +364,8 @@ extern int scsi_test_unit_ready(struct scsi_device *sdev, int timeout,
362 int retries, struct scsi_sense_hdr *sshdr); 364 int retries, struct scsi_sense_hdr *sshdr);
363extern int scsi_get_vpd_page(struct scsi_device *, u8 page, unsigned char *buf, 365extern int scsi_get_vpd_page(struct scsi_device *, u8 page, unsigned char *buf,
364 int buf_len); 366 int buf_len);
367extern int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer,
368 unsigned int len, unsigned char opcode);
365extern int scsi_device_set_state(struct scsi_device *sdev, 369extern int scsi_device_set_state(struct scsi_device *sdev,
366 enum scsi_device_state state); 370 enum scsi_device_state state);
367extern struct scsi_event *sdev_evt_alloc(enum scsi_device_event evt_type, 371extern struct scsi_event *sdev_evt_alloc(enum scsi_device_event evt_type,
diff --git a/include/sound/cs4271.h b/include/sound/cs4271.h
index 50a059e7d116..6d9e15ed1dcf 100644
--- a/include/sound/cs4271.h
+++ b/include/sound/cs4271.h
@@ -19,6 +19,7 @@
19 19
20struct cs4271_platform_data { 20struct cs4271_platform_data {
21 int gpio_nreset; /* GPIO driving Reset pin, if any */ 21 int gpio_nreset; /* GPIO driving Reset pin, if any */
22 int amutec_eq_bmutec:1; /* flag to enable AMUTEC=BMUTEC */
22}; 23};
23 24
24#endif /* __CS4271_H */ 25#endif /* __CS4271_H */
diff --git a/include/sound/sh_fsi.h b/include/sound/sh_fsi.h
index 906010344dd7..cc1c919c6436 100644
--- a/include/sound/sh_fsi.h
+++ b/include/sound/sh_fsi.h
@@ -26,6 +26,7 @@
26 * A: inversion 26 * A: inversion
27 * B: format mode 27 * B: format mode
28 * C: chip specific 28 * C: chip specific
29 * D: clock selecter if master mode
29 */ 30 */
30 31
31/* A: clock inversion */ 32/* A: clock inversion */
@@ -44,6 +45,11 @@
44#define SH_FSI_OPTION_MASK 0x00000F00 45#define SH_FSI_OPTION_MASK 0x00000F00
45#define SH_FSI_ENABLE_STREAM_MODE (1 << 8) /* for 16bit data */ 46#define SH_FSI_ENABLE_STREAM_MODE (1 << 8) /* for 16bit data */
46 47
48/* D: clock selecter if master mode */
49#define SH_FSI_CLK_MASK 0x0000F000
50#define SH_FSI_CLK_EXTERNAL (0 << 12)
51#define SH_FSI_CLK_CPG (1 << 12) /* FSIxCK + FSI-DIV */
52
47/* 53/*
48 * set_rate return value 54 * set_rate return value
49 * 55 *
diff --git a/include/sound/tlv320aic32x4.h b/include/sound/tlv320aic32x4.h
index c009f70b4029..24e5d991f148 100644
--- a/include/sound/tlv320aic32x4.h
+++ b/include/sound/tlv320aic32x4.h
@@ -26,6 +26,7 @@ struct aic32x4_pdata {
26 u32 power_cfg; 26 u32 power_cfg;
27 u32 micpga_routing; 27 u32 micpga_routing;
28 bool swapdacs; 28 bool swapdacs;
29 int rstn_gpio;
29}; 30};
30 31
31#endif 32#endif
diff --git a/include/uapi/linux/oom.h b/include/uapi/linux/oom.h
index a49c4afc7060..b29272d621ce 100644
--- a/include/uapi/linux/oom.h
+++ b/include/uapi/linux/oom.h
@@ -8,4 +8,13 @@
8#define OOM_SCORE_ADJ_MIN (-1000) 8#define OOM_SCORE_ADJ_MIN (-1000)
9#define OOM_SCORE_ADJ_MAX 1000 9#define OOM_SCORE_ADJ_MAX 1000
10 10
11/*
12 * /proc/<pid>/oom_adj set to -17 protects from the oom killer for legacy
13 * purposes.
14 */
15#define OOM_DISABLE (-17)
16/* inclusive */
17#define OOM_ADJUST_MIN (-16)
18#define OOM_ADJUST_MAX 15
19
11#endif /* _UAPI__INCLUDE_LINUX_OOM_H */ 20#endif /* _UAPI__INCLUDE_LINUX_OOM_H */
diff --git a/kernel/futex.c b/kernel/futex.c
index 3717e7b306e0..20ef219bbe9b 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -716,7 +716,7 @@ static int futex_lock_pi_atomic(u32 __user *uaddr, struct futex_hash_bucket *hb,
716 struct futex_pi_state **ps, 716 struct futex_pi_state **ps,
717 struct task_struct *task, int set_waiters) 717 struct task_struct *task, int set_waiters)
718{ 718{
719 int lock_taken, ret, ownerdied = 0; 719 int lock_taken, ret, force_take = 0;
720 u32 uval, newval, curval, vpid = task_pid_vnr(task); 720 u32 uval, newval, curval, vpid = task_pid_vnr(task);
721 721
722retry: 722retry:
@@ -755,17 +755,15 @@ retry:
755 newval = curval | FUTEX_WAITERS; 755 newval = curval | FUTEX_WAITERS;
756 756
757 /* 757 /*
758 * There are two cases, where a futex might have no owner (the 758 * Should we force take the futex? See below.
759 * owner TID is 0): OWNER_DIED. We take over the futex in this
760 * case. We also do an unconditional take over, when the owner
761 * of the futex died.
762 *
763 * This is safe as we are protected by the hash bucket lock !
764 */ 759 */
765 if (unlikely(ownerdied || !(curval & FUTEX_TID_MASK))) { 760 if (unlikely(force_take)) {
766 /* Keep the OWNER_DIED bit */ 761 /*
762 * Keep the OWNER_DIED and the WAITERS bit and set the
763 * new TID value.
764 */
767 newval = (curval & ~FUTEX_TID_MASK) | vpid; 765 newval = (curval & ~FUTEX_TID_MASK) | vpid;
768 ownerdied = 0; 766 force_take = 0;
769 lock_taken = 1; 767 lock_taken = 1;
770 } 768 }
771 769
@@ -775,7 +773,7 @@ retry:
775 goto retry; 773 goto retry;
776 774
777 /* 775 /*
778 * We took the lock due to owner died take over. 776 * We took the lock due to forced take over.
779 */ 777 */
780 if (unlikely(lock_taken)) 778 if (unlikely(lock_taken))
781 return 1; 779 return 1;
@@ -790,20 +788,25 @@ retry:
790 switch (ret) { 788 switch (ret) {
791 case -ESRCH: 789 case -ESRCH:
792 /* 790 /*
793 * No owner found for this futex. Check if the 791 * We failed to find an owner for this
794 * OWNER_DIED bit is set to figure out whether 792 * futex. So we have no pi_state to block
795 * this is a robust futex or not. 793 * on. This can happen in two cases:
794 *
795 * 1) The owner died
796 * 2) A stale FUTEX_WAITERS bit
797 *
798 * Re-read the futex value.
796 */ 799 */
797 if (get_futex_value_locked(&curval, uaddr)) 800 if (get_futex_value_locked(&curval, uaddr))
798 return -EFAULT; 801 return -EFAULT;
799 802
800 /* 803 /*
801 * We simply start over in case of a robust 804 * If the owner died or we have a stale
802 * futex. The code above will take the futex 805 * WAITERS bit the owner TID in the user space
803 * and return happy. 806 * futex is 0.
804 */ 807 */
805 if (curval & FUTEX_OWNER_DIED) { 808 if (!(curval & FUTEX_TID_MASK)) {
806 ownerdied = 1; 809 force_take = 1;
807 goto retry; 810 goto retry;
808 } 811 }
809 default: 812 default:
diff --git a/lib/mpi/longlong.h b/lib/mpi/longlong.h
index 678ce4f1e124..095ab157a521 100644
--- a/lib/mpi/longlong.h
+++ b/lib/mpi/longlong.h
@@ -641,7 +641,14 @@ do { \
641 ************** MIPS ***************** 641 ************** MIPS *****************
642 ***************************************/ 642 ***************************************/
643#if defined(__mips__) && W_TYPE_SIZE == 32 643#if defined(__mips__) && W_TYPE_SIZE == 32
644#if __GNUC__ > 2 || __GNUC_MINOR__ >= 7 644#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 4
645#define umul_ppmm(w1, w0, u, v) \
646do { \
647 UDItype __ll = (UDItype)(u) * (v); \
648 w1 = __ll >> 32; \
649 w0 = __ll; \
650} while (0)
651#elif __GNUC__ > 2 || __GNUC_MINOR__ >= 7
645#define umul_ppmm(w1, w0, u, v) \ 652#define umul_ppmm(w1, w0, u, v) \
646 __asm__ ("multu %2,%3" \ 653 __asm__ ("multu %2,%3" \
647 : "=l" ((USItype)(w0)), \ 654 : "=l" ((USItype)(w0)), \
@@ -666,7 +673,15 @@ do { \
666 ************** MIPS/64 ************** 673 ************** MIPS/64 **************
667 ***************************************/ 674 ***************************************/
668#if (defined(__mips) && __mips >= 3) && W_TYPE_SIZE == 64 675#if (defined(__mips) && __mips >= 3) && W_TYPE_SIZE == 64
669#if __GNUC__ > 2 || __GNUC_MINOR__ >= 7 676#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 4
677#define umul_ppmm(w1, w0, u, v) \
678do { \
679 typedef unsigned int __ll_UTItype __attribute__((mode(TI))); \
680 __ll_UTItype __ll = (__ll_UTItype)(u) * (v); \
681 w1 = __ll >> 64; \
682 w0 = __ll; \
683} while (0)
684#elif __GNUC__ > 2 || __GNUC_MINOR__ >= 7
670#define umul_ppmm(w1, w0, u, v) \ 685#define umul_ppmm(w1, w0, u, v) \
671 __asm__ ("dmultu %2,%3" \ 686 __asm__ ("dmultu %2,%3" \
672 : "=l" ((UDItype)(w0)), \ 687 : "=l" ((UDItype)(w0)), \
diff --git a/mm/bootmem.c b/mm/bootmem.c
index 434be4ae7a04..f468185b3b28 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -198,8 +198,6 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
198 int order = ilog2(BITS_PER_LONG); 198 int order = ilog2(BITS_PER_LONG);
199 199
200 __free_pages_bootmem(pfn_to_page(start), order); 200 __free_pages_bootmem(pfn_to_page(start), order);
201 fixup_zone_present_pages(page_to_nid(pfn_to_page(start)),
202 start, start + BITS_PER_LONG);
203 count += BITS_PER_LONG; 201 count += BITS_PER_LONG;
204 start += BITS_PER_LONG; 202 start += BITS_PER_LONG;
205 } else { 203 } else {
@@ -210,9 +208,6 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
210 if (vec & 1) { 208 if (vec & 1) {
211 page = pfn_to_page(start + off); 209 page = pfn_to_page(start + off);
212 __free_pages_bootmem(page, 0); 210 __free_pages_bootmem(page, 0);
213 fixup_zone_present_pages(
214 page_to_nid(page),
215 start + off, start + off + 1);
216 count++; 211 count++;
217 } 212 }
218 vec >>= 1; 213 vec >>= 1;
@@ -226,11 +221,8 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
226 pages = bdata->node_low_pfn - bdata->node_min_pfn; 221 pages = bdata->node_low_pfn - bdata->node_min_pfn;
227 pages = bootmem_bootmap_pages(pages); 222 pages = bootmem_bootmap_pages(pages);
228 count += pages; 223 count += pages;
229 while (pages--) { 224 while (pages--)
230 fixup_zone_present_pages(page_to_nid(page),
231 page_to_pfn(page), page_to_pfn(page) + 1);
232 __free_pages_bootmem(page++, 0); 225 __free_pages_bootmem(page++, 0);
233 }
234 226
235 bdebug("nid=%td released=%lx\n", bdata - bootmem_node_data, count); 227 bdebug("nid=%td released=%lx\n", bdata - bootmem_node_data, count);
236 228
diff --git a/mm/highmem.c b/mm/highmem.c
index d517cd16a6eb..2da13a5c50e2 100644
--- a/mm/highmem.c
+++ b/mm/highmem.c
@@ -98,7 +98,7 @@ struct page *kmap_to_page(void *vaddr)
98{ 98{
99 unsigned long addr = (unsigned long)vaddr; 99 unsigned long addr = (unsigned long)vaddr;
100 100
101 if (addr >= PKMAP_ADDR(0) && addr <= PKMAP_ADDR(LAST_PKMAP)) { 101 if (addr >= PKMAP_ADDR(0) && addr < PKMAP_ADDR(LAST_PKMAP)) {
102 int i = (addr - PKMAP_ADDR(0)) >> PAGE_SHIFT; 102 int i = (addr - PKMAP_ADDR(0)) >> PAGE_SHIFT;
103 return pte_page(pkmap_page_table[i]); 103 return pte_page(pkmap_page_table[i]);
104 } 104 }
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 7acf43bf04a2..dd39ba000b31 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1055,12 +1055,24 @@ struct lruvec *mem_cgroup_zone_lruvec(struct zone *zone,
1055 struct mem_cgroup *memcg) 1055 struct mem_cgroup *memcg)
1056{ 1056{
1057 struct mem_cgroup_per_zone *mz; 1057 struct mem_cgroup_per_zone *mz;
1058 struct lruvec *lruvec;
1058 1059
1059 if (mem_cgroup_disabled()) 1060 if (mem_cgroup_disabled()) {
1060 return &zone->lruvec; 1061 lruvec = &zone->lruvec;
1062 goto out;
1063 }
1061 1064
1062 mz = mem_cgroup_zoneinfo(memcg, zone_to_nid(zone), zone_idx(zone)); 1065 mz = mem_cgroup_zoneinfo(memcg, zone_to_nid(zone), zone_idx(zone));
1063 return &mz->lruvec; 1066 lruvec = &mz->lruvec;
1067out:
1068 /*
1069 * Since a node can be onlined after the mem_cgroup was created,
1070 * we have to be prepared to initialize lruvec->zone here;
1071 * and if offlined then reonlined, we need to reinitialize it.
1072 */
1073 if (unlikely(lruvec->zone != zone))
1074 lruvec->zone = zone;
1075 return lruvec;
1064} 1076}
1065 1077
1066/* 1078/*
@@ -1087,9 +1099,12 @@ struct lruvec *mem_cgroup_page_lruvec(struct page *page, struct zone *zone)
1087 struct mem_cgroup_per_zone *mz; 1099 struct mem_cgroup_per_zone *mz;
1088 struct mem_cgroup *memcg; 1100 struct mem_cgroup *memcg;
1089 struct page_cgroup *pc; 1101 struct page_cgroup *pc;
1102 struct lruvec *lruvec;
1090 1103
1091 if (mem_cgroup_disabled()) 1104 if (mem_cgroup_disabled()) {
1092 return &zone->lruvec; 1105 lruvec = &zone->lruvec;
1106 goto out;
1107 }
1093 1108
1094 pc = lookup_page_cgroup(page); 1109 pc = lookup_page_cgroup(page);
1095 memcg = pc->mem_cgroup; 1110 memcg = pc->mem_cgroup;
@@ -1107,7 +1122,16 @@ struct lruvec *mem_cgroup_page_lruvec(struct page *page, struct zone *zone)
1107 pc->mem_cgroup = memcg = root_mem_cgroup; 1122 pc->mem_cgroup = memcg = root_mem_cgroup;
1108 1123
1109 mz = page_cgroup_zoneinfo(memcg, page); 1124 mz = page_cgroup_zoneinfo(memcg, page);
1110 return &mz->lruvec; 1125 lruvec = &mz->lruvec;
1126out:
1127 /*
1128 * Since a node can be onlined after the mem_cgroup was created,
1129 * we have to be prepared to initialize lruvec->zone here;
1130 * and if offlined then reonlined, we need to reinitialize it.
1131 */
1132 if (unlikely(lruvec->zone != zone))
1133 lruvec->zone = zone;
1134 return lruvec;
1111} 1135}
1112 1136
1113/** 1137/**
@@ -1452,17 +1476,26 @@ static int mem_cgroup_count_children(struct mem_cgroup *memcg)
1452static u64 mem_cgroup_get_limit(struct mem_cgroup *memcg) 1476static u64 mem_cgroup_get_limit(struct mem_cgroup *memcg)
1453{ 1477{
1454 u64 limit; 1478 u64 limit;
1455 u64 memsw;
1456 1479
1457 limit = res_counter_read_u64(&memcg->res, RES_LIMIT); 1480 limit = res_counter_read_u64(&memcg->res, RES_LIMIT);
1458 limit += total_swap_pages << PAGE_SHIFT;
1459 1481
1460 memsw = res_counter_read_u64(&memcg->memsw, RES_LIMIT);
1461 /* 1482 /*
1462 * If memsw is finite and limits the amount of swap space available 1483 * Do not consider swap space if we cannot swap due to swappiness
1463 * to this memcg, return that limit.
1464 */ 1484 */
1465 return min(limit, memsw); 1485 if (mem_cgroup_swappiness(memcg)) {
1486 u64 memsw;
1487
1488 limit += total_swap_pages << PAGE_SHIFT;
1489 memsw = res_counter_read_u64(&memcg->memsw, RES_LIMIT);
1490
1491 /*
1492 * If memsw is finite and limits the amount of swap space
1493 * available to this memcg, return that limit.
1494 */
1495 limit = min(limit, memsw);
1496 }
1497
1498 return limit;
1466} 1499}
1467 1500
1468void mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask, 1501void mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask,
@@ -3688,17 +3721,17 @@ unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order,
3688static bool mem_cgroup_force_empty_list(struct mem_cgroup *memcg, 3721static bool mem_cgroup_force_empty_list(struct mem_cgroup *memcg,
3689 int node, int zid, enum lru_list lru) 3722 int node, int zid, enum lru_list lru)
3690{ 3723{
3691 struct mem_cgroup_per_zone *mz; 3724 struct lruvec *lruvec;
3692 unsigned long flags, loop; 3725 unsigned long flags, loop;
3693 struct list_head *list; 3726 struct list_head *list;
3694 struct page *busy; 3727 struct page *busy;
3695 struct zone *zone; 3728 struct zone *zone;
3696 3729
3697 zone = &NODE_DATA(node)->node_zones[zid]; 3730 zone = &NODE_DATA(node)->node_zones[zid];
3698 mz = mem_cgroup_zoneinfo(memcg, node, zid); 3731 lruvec = mem_cgroup_zone_lruvec(zone, memcg);
3699 list = &mz->lruvec.lists[lru]; 3732 list = &lruvec->lists[lru];
3700 3733
3701 loop = mz->lru_size[lru]; 3734 loop = mem_cgroup_get_lru_size(lruvec, lru);
3702 /* give some margin against EBUSY etc...*/ 3735 /* give some margin against EBUSY etc...*/
3703 loop += 256; 3736 loop += 256;
3704 busy = NULL; 3737 busy = NULL;
@@ -4736,7 +4769,7 @@ static int alloc_mem_cgroup_per_zone_info(struct mem_cgroup *memcg, int node)
4736 4769
4737 for (zone = 0; zone < MAX_NR_ZONES; zone++) { 4770 for (zone = 0; zone < MAX_NR_ZONES; zone++) {
4738 mz = &pn->zoneinfo[zone]; 4771 mz = &pn->zoneinfo[zone];
4739 lruvec_init(&mz->lruvec, &NODE_DATA(node)->node_zones[zone]); 4772 lruvec_init(&mz->lruvec);
4740 mz->usage_in_excess = 0; 4773 mz->usage_in_excess = 0;
4741 mz->on_tree = false; 4774 mz->on_tree = false;
4742 mz->memcg = memcg; 4775 mz->memcg = memcg;
diff --git a/mm/memory.c b/mm/memory.c
index fb135ba4aba9..221fc9ffcab1 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -2527,9 +2527,8 @@ static int do_wp_page(struct mm_struct *mm, struct vm_area_struct *vma,
2527 int ret = 0; 2527 int ret = 0;
2528 int page_mkwrite = 0; 2528 int page_mkwrite = 0;
2529 struct page *dirty_page = NULL; 2529 struct page *dirty_page = NULL;
2530 unsigned long mmun_start; /* For mmu_notifiers */ 2530 unsigned long mmun_start = 0; /* For mmu_notifiers */
2531 unsigned long mmun_end; /* For mmu_notifiers */ 2531 unsigned long mmun_end = 0; /* For mmu_notifiers */
2532 bool mmun_called = false; /* For mmu_notifiers */
2533 2532
2534 old_page = vm_normal_page(vma, address, orig_pte); 2533 old_page = vm_normal_page(vma, address, orig_pte);
2535 if (!old_page) { 2534 if (!old_page) {
@@ -2708,8 +2707,7 @@ gotten:
2708 goto oom_free_new; 2707 goto oom_free_new;
2709 2708
2710 mmun_start = address & PAGE_MASK; 2709 mmun_start = address & PAGE_MASK;
2711 mmun_end = (address & PAGE_MASK) + PAGE_SIZE; 2710 mmun_end = mmun_start + PAGE_SIZE;
2712 mmun_called = true;
2713 mmu_notifier_invalidate_range_start(mm, mmun_start, mmun_end); 2711 mmu_notifier_invalidate_range_start(mm, mmun_start, mmun_end);
2714 2712
2715 /* 2713 /*
@@ -2778,7 +2776,7 @@ gotten:
2778 page_cache_release(new_page); 2776 page_cache_release(new_page);
2779unlock: 2777unlock:
2780 pte_unmap_unlock(page_table, ptl); 2778 pte_unmap_unlock(page_table, ptl);
2781 if (mmun_called) 2779 if (mmun_end > mmun_start)
2782 mmu_notifier_invalidate_range_end(mm, mmun_start, mmun_end); 2780 mmu_notifier_invalidate_range_end(mm, mmun_start, mmun_end);
2783 if (old_page) { 2781 if (old_page) {
2784 /* 2782 /*
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 56b758ae57d2..e4eeacae2b91 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -106,7 +106,6 @@ static void get_page_bootmem(unsigned long info, struct page *page,
106void __ref put_page_bootmem(struct page *page) 106void __ref put_page_bootmem(struct page *page)
107{ 107{
108 unsigned long type; 108 unsigned long type;
109 struct zone *zone;
110 109
111 type = (unsigned long) page->lru.next; 110 type = (unsigned long) page->lru.next;
112 BUG_ON(type < MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE || 111 BUG_ON(type < MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE ||
@@ -117,12 +116,6 @@ void __ref put_page_bootmem(struct page *page)
117 set_page_private(page, 0); 116 set_page_private(page, 0);
118 INIT_LIST_HEAD(&page->lru); 117 INIT_LIST_HEAD(&page->lru);
119 __free_pages_bootmem(page, 0); 118 __free_pages_bootmem(page, 0);
120
121 zone = page_zone(page);
122 zone_span_writelock(zone);
123 zone->present_pages++;
124 zone_span_writeunlock(zone);
125 totalram_pages++;
126 } 119 }
127 120
128} 121}
diff --git a/mm/mmap.c b/mm/mmap.c
index 2d942353d681..9a796c41e7d9 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -334,8 +334,10 @@ void validate_mm(struct mm_struct *mm)
334 struct vm_area_struct *vma = mm->mmap; 334 struct vm_area_struct *vma = mm->mmap;
335 while (vma) { 335 while (vma) {
336 struct anon_vma_chain *avc; 336 struct anon_vma_chain *avc;
337 vma_lock_anon_vma(vma);
337 list_for_each_entry(avc, &vma->anon_vma_chain, same_vma) 338 list_for_each_entry(avc, &vma->anon_vma_chain, same_vma)
338 anon_vma_interval_tree_verify(avc); 339 anon_vma_interval_tree_verify(avc);
340 vma_unlock_anon_vma(vma);
339 vma = vma->vm_next; 341 vma = vma->vm_next;
340 i++; 342 i++;
341 } 343 }
diff --git a/mm/mmzone.c b/mm/mmzone.c
index 3cef80f6ac79..4596d81b89b1 100644
--- a/mm/mmzone.c
+++ b/mm/mmzone.c
@@ -87,7 +87,7 @@ int memmap_valid_within(unsigned long pfn,
87} 87}
88#endif /* CONFIG_ARCH_HAS_HOLES_MEMORYMODEL */ 88#endif /* CONFIG_ARCH_HAS_HOLES_MEMORYMODEL */
89 89
90void lruvec_init(struct lruvec *lruvec, struct zone *zone) 90void lruvec_init(struct lruvec *lruvec)
91{ 91{
92 enum lru_list lru; 92 enum lru_list lru;
93 93
@@ -95,8 +95,4 @@ void lruvec_init(struct lruvec *lruvec, struct zone *zone)
95 95
96 for_each_lru(lru) 96 for_each_lru(lru)
97 INIT_LIST_HEAD(&lruvec->lists[lru]); 97 INIT_LIST_HEAD(&lruvec->lists[lru]);
98
99#ifdef CONFIG_MEMCG
100 lruvec->zone = zone;
101#endif
102} 98}
diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index 714d5d650470..bd82f6b31411 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -116,8 +116,6 @@ static unsigned long __init __free_memory_core(phys_addr_t start,
116 return 0; 116 return 0;
117 117
118 __free_pages_memory(start_pfn, end_pfn); 118 __free_pages_memory(start_pfn, end_pfn);
119 fixup_zone_present_pages(pfn_to_nid(start >> PAGE_SHIFT),
120 start_pfn, end_pfn);
121 119
122 return end_pfn - start_pfn; 120 return end_pfn - start_pfn;
123} 121}
@@ -128,7 +126,6 @@ unsigned long __init free_low_memory_core_early(int nodeid)
128 phys_addr_t start, end, size; 126 phys_addr_t start, end, size;
129 u64 i; 127 u64 i;
130 128
131 reset_zone_present_pages();
132 for_each_free_mem_range(i, MAX_NUMNODES, &start, &end, NULL) 129 for_each_free_mem_range(i, MAX_NUMNODES, &start, &end, NULL)
133 count += __free_memory_core(start, end); 130 count += __free_memory_core(start, end);
134 131
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 5b74de6702e0..bcb72c6e2b2d 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1405,7 +1405,7 @@ int capture_free_page(struct page *page, int alloc_order, int migratetype)
1405 1405
1406 mt = get_pageblock_migratetype(page); 1406 mt = get_pageblock_migratetype(page);
1407 if (unlikely(mt != MIGRATE_ISOLATE)) 1407 if (unlikely(mt != MIGRATE_ISOLATE))
1408 __mod_zone_freepage_state(zone, -(1UL << order), mt); 1408 __mod_zone_freepage_state(zone, -(1UL << alloc_order), mt);
1409 1409
1410 if (alloc_order != order) 1410 if (alloc_order != order)
1411 expand(zone, page, alloc_order, order, 1411 expand(zone, page, alloc_order, order,
@@ -4505,7 +4505,7 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat,
4505 zone->zone_pgdat = pgdat; 4505 zone->zone_pgdat = pgdat;
4506 4506
4507 zone_pcp_init(zone); 4507 zone_pcp_init(zone);
4508 lruvec_init(&zone->lruvec, zone); 4508 lruvec_init(&zone->lruvec);
4509 if (!size) 4509 if (!size)
4510 continue; 4510 continue;
4511 4511
@@ -6098,37 +6098,3 @@ void dump_page(struct page *page)
6098 dump_page_flags(page->flags); 6098 dump_page_flags(page->flags);
6099 mem_cgroup_print_bad_page(page); 6099 mem_cgroup_print_bad_page(page);
6100} 6100}
6101
6102/* reset zone->present_pages */
6103void reset_zone_present_pages(void)
6104{
6105 struct zone *z;
6106 int i, nid;
6107
6108 for_each_node_state(nid, N_HIGH_MEMORY) {
6109 for (i = 0; i < MAX_NR_ZONES; i++) {
6110 z = NODE_DATA(nid)->node_zones + i;
6111 z->present_pages = 0;
6112 }
6113 }
6114}
6115
6116/* calculate zone's present pages in buddy system */
6117void fixup_zone_present_pages(int nid, unsigned long start_pfn,
6118 unsigned long end_pfn)
6119{
6120 struct zone *z;
6121 unsigned long zone_start_pfn, zone_end_pfn;
6122 int i;
6123
6124 for (i = 0; i < MAX_NR_ZONES; i++) {
6125 z = NODE_DATA(nid)->node_zones + i;
6126 zone_start_pfn = z->zone_start_pfn;
6127 zone_end_pfn = zone_start_pfn + z->spanned_pages;
6128
6129 /* if the two regions intersect */
6130 if (!(zone_start_pfn >= end_pfn || zone_end_pfn <= start_pfn))
6131 z->present_pages += min(end_pfn, zone_end_pfn) -
6132 max(start_pfn, zone_start_pfn);
6133 }
6134}
diff --git a/mm/shmem.c b/mm/shmem.c
index 67afba5117f2..89341b658bd0 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -643,7 +643,7 @@ static void shmem_evict_inode(struct inode *inode)
643 kfree(info->symlink); 643 kfree(info->symlink);
644 644
645 simple_xattrs_free(&info->xattrs); 645 simple_xattrs_free(&info->xattrs);
646 BUG_ON(inode->i_blocks); 646 WARN_ON(inode->i_blocks);
647 shmem_free_inode(inode->i_sb); 647 shmem_free_inode(inode->i_sb);
648 clear_inode(inode); 648 clear_inode(inode);
649} 649}
@@ -1145,8 +1145,20 @@ repeat:
1145 if (!error) { 1145 if (!error) {
1146 error = shmem_add_to_page_cache(page, mapping, index, 1146 error = shmem_add_to_page_cache(page, mapping, index,
1147 gfp, swp_to_radix_entry(swap)); 1147 gfp, swp_to_radix_entry(swap));
1148 /* We already confirmed swap, and make no allocation */ 1148 /*
1149 VM_BUG_ON(error); 1149 * We already confirmed swap under page lock, and make
1150 * no memory allocation here, so usually no possibility
1151 * of error; but free_swap_and_cache() only trylocks a
1152 * page, so it is just possible that the entry has been
1153 * truncated or holepunched since swap was confirmed.
1154 * shmem_undo_range() will have done some of the
1155 * unaccounting, now delete_from_swap_cache() will do
1156 * the rest (including mem_cgroup_uncharge_swapcache).
1157 * Reset swap.val? No, leave it so "failed" goes back to
1158 * "repeat": reading a hole and writing should succeed.
1159 */
1160 if (error)
1161 delete_from_swap_cache(page);
1150 } 1162 }
1151 if (error) 1163 if (error)
1152 goto failed; 1164 goto failed;
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 71cd288b2001..f91a25547ffe 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1494,9 +1494,8 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
1494 BUG_ON(!current->mm); 1494 BUG_ON(!current->mm);
1495 1495
1496 pathname = getname(specialfile); 1496 pathname = getname(specialfile);
1497 err = PTR_ERR(pathname);
1498 if (IS_ERR(pathname)) 1497 if (IS_ERR(pathname))
1499 goto out; 1498 return PTR_ERR(pathname);
1500 1499
1501 victim = file_open_name(pathname, O_RDWR|O_LARGEFILE, 0); 1500 victim = file_open_name(pathname, O_RDWR|O_LARGEFILE, 0);
1502 err = PTR_ERR(victim); 1501 err = PTR_ERR(victim);
@@ -1608,6 +1607,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
1608out_dput: 1607out_dput:
1609 filp_close(victim, NULL); 1608 filp_close(victim, NULL);
1610out: 1609out:
1610 putname(pathname);
1611 return err; 1611 return err;
1612} 1612}
1613 1613
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 8b055e9379bc..48550c66f1f2 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1760,28 +1760,6 @@ static bool in_reclaim_compaction(struct scan_control *sc)
1760 return false; 1760 return false;
1761} 1761}
1762 1762
1763#ifdef CONFIG_COMPACTION
1764/*
1765 * If compaction is deferred for sc->order then scale the number of pages
1766 * reclaimed based on the number of consecutive allocation failures
1767 */
1768static unsigned long scale_for_compaction(unsigned long pages_for_compaction,
1769 struct lruvec *lruvec, struct scan_control *sc)
1770{
1771 struct zone *zone = lruvec_zone(lruvec);
1772
1773 if (zone->compact_order_failed <= sc->order)
1774 pages_for_compaction <<= zone->compact_defer_shift;
1775 return pages_for_compaction;
1776}
1777#else
1778static unsigned long scale_for_compaction(unsigned long pages_for_compaction,
1779 struct lruvec *lruvec, struct scan_control *sc)
1780{
1781 return pages_for_compaction;
1782}
1783#endif
1784
1785/* 1763/*
1786 * Reclaim/compaction is used for high-order allocation requests. It reclaims 1764 * Reclaim/compaction is used for high-order allocation requests. It reclaims
1787 * order-0 pages before compacting the zone. should_continue_reclaim() returns 1765 * order-0 pages before compacting the zone. should_continue_reclaim() returns
@@ -1829,9 +1807,6 @@ static inline bool should_continue_reclaim(struct lruvec *lruvec,
1829 * inactive lists are large enough, continue reclaiming 1807 * inactive lists are large enough, continue reclaiming
1830 */ 1808 */
1831 pages_for_compaction = (2UL << sc->order); 1809 pages_for_compaction = (2UL << sc->order);
1832
1833 pages_for_compaction = scale_for_compaction(pages_for_compaction,
1834 lruvec, sc);
1835 inactive_lru_pages = get_lru_size(lruvec, LRU_INACTIVE_FILE); 1810 inactive_lru_pages = get_lru_size(lruvec, LRU_INACTIVE_FILE);
1836 if (nr_swap_pages > 0) 1811 if (nr_swap_pages > 0)
1837 inactive_lru_pages += get_lru_size(lruvec, LRU_INACTIVE_ANON); 1812 inactive_lru_pages += get_lru_size(lruvec, LRU_INACTIVE_ANON);
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index b9a28d2dd3e8..ce0684a1fc83 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -325,6 +325,12 @@ void batadv_interface_rx(struct net_device *soft_iface,
325 325
326 soft_iface->last_rx = jiffies; 326 soft_iface->last_rx = jiffies;
327 327
328 /* Let the bridge loop avoidance check the packet. If will
329 * not handle it, we can safely push it up.
330 */
331 if (batadv_bla_rx(bat_priv, skb, vid, is_bcast))
332 goto out;
333
328 if (orig_node) 334 if (orig_node)
329 batadv_tt_add_temporary_global_entry(bat_priv, orig_node, 335 batadv_tt_add_temporary_global_entry(bat_priv, orig_node,
330 ethhdr->h_source); 336 ethhdr->h_source);
@@ -332,12 +338,6 @@ void batadv_interface_rx(struct net_device *soft_iface,
332 if (batadv_is_ap_isolated(bat_priv, ethhdr->h_source, ethhdr->h_dest)) 338 if (batadv_is_ap_isolated(bat_priv, ethhdr->h_source, ethhdr->h_dest))
333 goto dropped; 339 goto dropped;
334 340
335 /* Let the bridge loop avoidance check the packet. If will
336 * not handle it, we can safely push it up.
337 */
338 if (batadv_bla_rx(bat_priv, skb, vid, is_bcast))
339 goto out;
340
341 netif_rx(skb); 341 netif_rx(skb);
342 goto out; 342 goto out;
343 343
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 112edd371b2f..baae71585804 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -769,6 +769,12 @@ int batadv_tt_global_add(struct batadv_priv *bat_priv,
769 */ 769 */
770 tt_global_entry->common.flags &= ~BATADV_TT_CLIENT_TEMP; 770 tt_global_entry->common.flags &= ~BATADV_TT_CLIENT_TEMP;
771 771
772 /* the change can carry possible "attribute" flags like the
773 * TT_CLIENT_WIFI, therefore they have to be copied in the
774 * client entry
775 */
776 tt_global_entry->common.flags |= flags;
777
772 /* If there is the BATADV_TT_CLIENT_ROAM flag set, there is only 778 /* If there is the BATADV_TT_CLIENT_ROAM flag set, there is only
773 * one originator left in the list and we previously received a 779 * one originator left in the list and we previously received a
774 * delete + roaming change for this originator. 780 * delete + roaming change for this originator.
@@ -1496,7 +1502,7 @@ batadv_tt_response_fill_table(uint16_t tt_len, uint8_t ttvn,
1496 1502
1497 memcpy(tt_change->addr, tt_common_entry->addr, 1503 memcpy(tt_change->addr, tt_common_entry->addr,
1498 ETH_ALEN); 1504 ETH_ALEN);
1499 tt_change->flags = BATADV_NO_FLAGS; 1505 tt_change->flags = tt_common_entry->flags;
1500 1506
1501 tt_count++; 1507 tt_count++;
1502 tt_change++; 1508 tt_change++;
@@ -2450,6 +2456,13 @@ bool batadv_tt_add_temporary_global_entry(struct batadv_priv *bat_priv,
2450{ 2456{
2451 bool ret = false; 2457 bool ret = false;
2452 2458
2459 /* if the originator is a backbone node (meaning it belongs to the same
2460 * LAN of this node) the temporary client must not be added because to
2461 * reach such destination the node must use the LAN instead of the mesh
2462 */
2463 if (batadv_bla_is_backbone_gw_orig(bat_priv, orig_node->orig))
2464 goto out;
2465
2453 if (!batadv_tt_global_add(bat_priv, orig_node, addr, 2466 if (!batadv_tt_global_add(bat_priv, orig_node, addr,
2454 BATADV_TT_CLIENT_TEMP, 2467 BATADV_TT_CLIENT_TEMP,
2455 atomic_read(&orig_node->last_ttvn))) 2468 atomic_read(&orig_node->last_ttvn)))
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 8a0ce706aebd..a0a2f97b9c62 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1754,11 +1754,11 @@ int hci_register_dev(struct hci_dev *hdev)
1754 if (hdev->dev_type != HCI_AMP) 1754 if (hdev->dev_type != HCI_AMP)
1755 set_bit(HCI_AUTO_OFF, &hdev->dev_flags); 1755 set_bit(HCI_AUTO_OFF, &hdev->dev_flags);
1756 1756
1757 schedule_work(&hdev->power_on);
1758
1759 hci_notify(hdev, HCI_DEV_REG); 1757 hci_notify(hdev, HCI_DEV_REG);
1760 hci_dev_hold(hdev); 1758 hci_dev_hold(hdev);
1761 1759
1760 schedule_work(&hdev->power_on);
1761
1762 return id; 1762 return id;
1763 1763
1764err_wqueue: 1764err_wqueue:
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index aa2ea0a8142c..91de4239da66 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -326,7 +326,7 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data,
326 struct hci_dev *d; 326 struct hci_dev *d;
327 size_t rp_len; 327 size_t rp_len;
328 u16 count; 328 u16 count;
329 int i, err; 329 int err;
330 330
331 BT_DBG("sock %p", sk); 331 BT_DBG("sock %p", sk);
332 332
@@ -347,9 +347,7 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data,
347 return -ENOMEM; 347 return -ENOMEM;
348 } 348 }
349 349
350 rp->num_controllers = cpu_to_le16(count); 350 count = 0;
351
352 i = 0;
353 list_for_each_entry(d, &hci_dev_list, list) { 351 list_for_each_entry(d, &hci_dev_list, list) {
354 if (test_bit(HCI_SETUP, &d->dev_flags)) 352 if (test_bit(HCI_SETUP, &d->dev_flags))
355 continue; 353 continue;
@@ -357,10 +355,13 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data,
357 if (!mgmt_valid_hdev(d)) 355 if (!mgmt_valid_hdev(d))
358 continue; 356 continue;
359 357
360 rp->index[i++] = cpu_to_le16(d->id); 358 rp->index[count++] = cpu_to_le16(d->id);
361 BT_DBG("Added hci%u", d->id); 359 BT_DBG("Added hci%u", d->id);
362 } 360 }
363 361
362 rp->num_controllers = cpu_to_le16(count);
363 rp_len = sizeof(*rp) + (2 * count);
364
364 read_unlock(&hci_dev_list_lock); 365 read_unlock(&hci_dev_list_lock);
365 366
366 err = cmd_complete(sk, MGMT_INDEX_NONE, MGMT_OP_READ_INDEX_LIST, 0, rp, 367 err = cmd_complete(sk, MGMT_INDEX_NONE, MGMT_OP_READ_INDEX_LIST, 0, rp,
@@ -1366,6 +1367,7 @@ static int remove_uuid(struct sock *sk, struct hci_dev *hdev, void *data,
1366 continue; 1367 continue;
1367 1368
1368 list_del(&match->list); 1369 list_del(&match->list);
1370 kfree(match);
1369 found++; 1371 found++;
1370 } 1372 }
1371 1373
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index 2ac8d50861e0..a5923378bdf0 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -267,7 +267,7 @@ static void smp_failure(struct l2cap_conn *conn, u8 reason, u8 send)
267 267
268 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->hcon->flags); 268 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->hcon->flags);
269 mgmt_auth_failed(conn->hcon->hdev, conn->dst, hcon->type, 269 mgmt_auth_failed(conn->hcon->hdev, conn->dst, hcon->type,
270 hcon->dst_type, reason); 270 hcon->dst_type, HCI_ERROR_AUTH_FAILURE);
271 271
272 cancel_delayed_work_sync(&conn->security_timer); 272 cancel_delayed_work_sync(&conn->security_timer);
273 273
diff --git a/net/core/dev.c b/net/core/dev.c
index bda6d004f9f0..c0946cb2b354 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2818,8 +2818,10 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,
2818 if (unlikely(tcpu != next_cpu) && 2818 if (unlikely(tcpu != next_cpu) &&
2819 (tcpu == RPS_NO_CPU || !cpu_online(tcpu) || 2819 (tcpu == RPS_NO_CPU || !cpu_online(tcpu) ||
2820 ((int)(per_cpu(softnet_data, tcpu).input_queue_head - 2820 ((int)(per_cpu(softnet_data, tcpu).input_queue_head -
2821 rflow->last_qtail)) >= 0)) 2821 rflow->last_qtail)) >= 0)) {
2822 tcpu = next_cpu;
2822 rflow = set_rps_cpu(dev, skb, rflow, next_cpu); 2823 rflow = set_rps_cpu(dev, skb, rflow, next_cpu);
2824 }
2823 2825
2824 if (tcpu != RPS_NO_CPU && cpu_online(tcpu)) { 2826 if (tcpu != RPS_NO_CPU && cpu_online(tcpu)) {
2825 *rflowp = rflow; 2827 *rflowp = rflow;
diff --git a/net/core/dev_addr_lists.c b/net/core/dev_addr_lists.c
index 87cc17db2d56..b079c7bbc157 100644
--- a/net/core/dev_addr_lists.c
+++ b/net/core/dev_addr_lists.c
@@ -319,7 +319,8 @@ int dev_addr_del(struct net_device *dev, const unsigned char *addr,
319 */ 319 */
320 ha = list_first_entry(&dev->dev_addrs.list, 320 ha = list_first_entry(&dev->dev_addrs.list,
321 struct netdev_hw_addr, list); 321 struct netdev_hw_addr, list);
322 if (ha->addr == dev->dev_addr && ha->refcount == 1) 322 if (!memcmp(ha->addr, addr, dev->addr_len) &&
323 ha->type == addr_type && ha->refcount == 1)
323 return -ENOENT; 324 return -ENOENT;
324 325
325 err = __hw_addr_del(&dev->dev_addrs, addr, dev->addr_len, 326 err = __hw_addr_del(&dev->dev_addrs, addr, dev->addr_len,
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index bcf02f608cbf..017a8bacfb27 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -429,6 +429,17 @@ static struct attribute_group netstat_group = {
429 .name = "statistics", 429 .name = "statistics",
430 .attrs = netstat_attrs, 430 .attrs = netstat_attrs,
431}; 431};
432
433#if IS_ENABLED(CONFIG_WIRELESS_EXT) || IS_ENABLED(CONFIG_CFG80211)
434static struct attribute *wireless_attrs[] = {
435 NULL
436};
437
438static struct attribute_group wireless_group = {
439 .name = "wireless",
440 .attrs = wireless_attrs,
441};
442#endif
432#endif /* CONFIG_SYSFS */ 443#endif /* CONFIG_SYSFS */
433 444
434#ifdef CONFIG_RPS 445#ifdef CONFIG_RPS
@@ -1409,6 +1420,15 @@ int netdev_register_kobject(struct net_device *net)
1409 groups++; 1420 groups++;
1410 1421
1411 *groups++ = &netstat_group; 1422 *groups++ = &netstat_group;
1423
1424#if IS_ENABLED(CONFIG_WIRELESS_EXT) || IS_ENABLED(CONFIG_CFG80211)
1425 if (net->ieee80211_ptr)
1426 *groups++ = &wireless_group;
1427#if IS_ENABLED(CONFIG_WIRELESS_EXT)
1428 else if (net->wireless_handlers)
1429 *groups++ = &wireless_group;
1430#endif
1431#endif
1412#endif /* CONFIG_SYSFS */ 1432#endif /* CONFIG_SYSFS */
1413 1433
1414 error = device_add(dev); 1434 error = device_add(dev);
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index 5eea4a811042..14bbfcf717ac 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -457,19 +457,28 @@ static int do_ip_setsockopt(struct sock *sk, int level,
457 struct inet_sock *inet = inet_sk(sk); 457 struct inet_sock *inet = inet_sk(sk);
458 int val = 0, err; 458 int val = 0, err;
459 459
460 if (((1<<optname) & ((1<<IP_PKTINFO) | (1<<IP_RECVTTL) | 460 switch (optname) {
461 (1<<IP_RECVOPTS) | (1<<IP_RECVTOS) | 461 case IP_PKTINFO:
462 (1<<IP_RETOPTS) | (1<<IP_TOS) | 462 case IP_RECVTTL:
463 (1<<IP_TTL) | (1<<IP_HDRINCL) | 463 case IP_RECVOPTS:
464 (1<<IP_MTU_DISCOVER) | (1<<IP_RECVERR) | 464 case IP_RECVTOS:
465 (1<<IP_ROUTER_ALERT) | (1<<IP_FREEBIND) | 465 case IP_RETOPTS:
466 (1<<IP_PASSSEC) | (1<<IP_TRANSPARENT) | 466 case IP_TOS:
467 (1<<IP_MINTTL) | (1<<IP_NODEFRAG))) || 467 case IP_TTL:
468 optname == IP_UNICAST_IF || 468 case IP_HDRINCL:
469 optname == IP_MULTICAST_TTL || 469 case IP_MTU_DISCOVER:
470 optname == IP_MULTICAST_ALL || 470 case IP_RECVERR:
471 optname == IP_MULTICAST_LOOP || 471 case IP_ROUTER_ALERT:
472 optname == IP_RECVORIGDSTADDR) { 472 case IP_FREEBIND:
473 case IP_PASSSEC:
474 case IP_TRANSPARENT:
475 case IP_MINTTL:
476 case IP_NODEFRAG:
477 case IP_UNICAST_IF:
478 case IP_MULTICAST_TTL:
479 case IP_MULTICAST_ALL:
480 case IP_MULTICAST_LOOP:
481 case IP_RECVORIGDSTADDR:
473 if (optlen >= sizeof(int)) { 482 if (optlen >= sizeof(int)) {
474 if (get_user(val, (int __user *) optval)) 483 if (get_user(val, (int __user *) optval))
475 return -EFAULT; 484 return -EFAULT;
diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
index 1831092f999f..858fddf6482a 100644
--- a/net/ipv4/ip_vti.c
+++ b/net/ipv4/ip_vti.c
@@ -338,12 +338,17 @@ static int vti_rcv(struct sk_buff *skb)
338 if (tunnel != NULL) { 338 if (tunnel != NULL) {
339 struct pcpu_tstats *tstats; 339 struct pcpu_tstats *tstats;
340 340
341 if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb))
342 return -1;
343
341 tstats = this_cpu_ptr(tunnel->dev->tstats); 344 tstats = this_cpu_ptr(tunnel->dev->tstats);
342 u64_stats_update_begin(&tstats->syncp); 345 u64_stats_update_begin(&tstats->syncp);
343 tstats->rx_packets++; 346 tstats->rx_packets++;
344 tstats->rx_bytes += skb->len; 347 tstats->rx_bytes += skb->len;
345 u64_stats_update_end(&tstats->syncp); 348 u64_stats_update_end(&tstats->syncp);
346 349
350 skb->mark = 0;
351 secpath_reset(skb);
347 skb->dev = tunnel->dev; 352 skb->dev = tunnel->dev;
348 return 1; 353 return 1;
349 } 354 }
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index a8c651216fa6..df251424d816 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1785,6 +1785,7 @@ static struct rtable *__mkroute_output(const struct fib_result *res,
1785 if (dev_out->flags & IFF_LOOPBACK) 1785 if (dev_out->flags & IFF_LOOPBACK)
1786 flags |= RTCF_LOCAL; 1786 flags |= RTCF_LOCAL;
1787 1787
1788 do_cache = true;
1788 if (type == RTN_BROADCAST) { 1789 if (type == RTN_BROADCAST) {
1789 flags |= RTCF_BROADCAST | RTCF_LOCAL; 1790 flags |= RTCF_BROADCAST | RTCF_LOCAL;
1790 fi = NULL; 1791 fi = NULL;
@@ -1793,6 +1794,8 @@ static struct rtable *__mkroute_output(const struct fib_result *res,
1793 if (!ip_check_mc_rcu(in_dev, fl4->daddr, fl4->saddr, 1794 if (!ip_check_mc_rcu(in_dev, fl4->daddr, fl4->saddr,
1794 fl4->flowi4_proto)) 1795 fl4->flowi4_proto))
1795 flags &= ~RTCF_LOCAL; 1796 flags &= ~RTCF_LOCAL;
1797 else
1798 do_cache = false;
1796 /* If multicast route do not exist use 1799 /* If multicast route do not exist use
1797 * default one, but do not gateway in this case. 1800 * default one, but do not gateway in this case.
1798 * Yes, it is hack. 1801 * Yes, it is hack.
@@ -1802,8 +1805,8 @@ static struct rtable *__mkroute_output(const struct fib_result *res,
1802 } 1805 }
1803 1806
1804 fnhe = NULL; 1807 fnhe = NULL;
1805 do_cache = fi != NULL; 1808 do_cache &= fi != NULL;
1806 if (fi) { 1809 if (do_cache) {
1807 struct rtable __rcu **prth; 1810 struct rtable __rcu **prth;
1808 struct fib_nh *nh = &FIB_RES_NH(*res); 1811 struct fib_nh *nh = &FIB_RES_NH(*res);
1809 1812
@@ -2597,7 +2600,7 @@ int __init ip_rt_init(void)
2597 pr_err("Unable to create route proc files\n"); 2600 pr_err("Unable to create route proc files\n");
2598#ifdef CONFIG_XFRM 2601#ifdef CONFIG_XFRM
2599 xfrm_init(); 2602 xfrm_init();
2600 xfrm4_init(ip_rt_max_size); 2603 xfrm4_init();
2601#endif 2604#endif
2602 rtnl_register(PF_INET, RTM_GETROUTE, inet_rtm_getroute, NULL, NULL); 2605 rtnl_register(PF_INET, RTM_GETROUTE, inet_rtm_getroute, NULL, NULL);
2603 2606
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 197c0008503c..083092e3aed6 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1212,7 +1212,7 @@ new_segment:
1212wait_for_sndbuf: 1212wait_for_sndbuf:
1213 set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); 1213 set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
1214wait_for_memory: 1214wait_for_memory:
1215 if (copied && likely(!tp->repair)) 1215 if (copied)
1216 tcp_push(sk, flags & ~MSG_MORE, mss_now, TCP_NAGLE_PUSH); 1216 tcp_push(sk, flags & ~MSG_MORE, mss_now, TCP_NAGLE_PUSH);
1217 1217
1218 if ((err = sk_stream_wait_memory(sk, &timeo)) != 0) 1218 if ((err = sk_stream_wait_memory(sk, &timeo)) != 0)
@@ -1223,7 +1223,7 @@ wait_for_memory:
1223 } 1223 }
1224 1224
1225out: 1225out:
1226 if (copied && likely(!tp->repair)) 1226 if (copied)
1227 tcp_push(sk, flags, mss_now, tp->nonagle); 1227 tcp_push(sk, flags, mss_now, tp->nonagle);
1228 release_sock(sk); 1228 release_sock(sk);
1229 return copied + copied_syn; 1229 return copied + copied_syn;
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 2c2b13a999ea..609ff98aeb47 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -5313,11 +5313,6 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb,
5313 goto discard; 5313 goto discard;
5314 } 5314 }
5315 5315
5316 /* ts_recent update must be made after we are sure that the packet
5317 * is in window.
5318 */
5319 tcp_replace_ts_recent(tp, TCP_SKB_CB(skb)->seq);
5320
5321 /* step 3: check security and precedence [ignored] */ 5316 /* step 3: check security and precedence [ignored] */
5322 5317
5323 /* step 4: Check for a SYN 5318 /* step 4: Check for a SYN
@@ -5552,6 +5547,11 @@ step5:
5552 if (th->ack && tcp_ack(sk, skb, FLAG_SLOWPATH) < 0) 5547 if (th->ack && tcp_ack(sk, skb, FLAG_SLOWPATH) < 0)
5553 goto discard; 5548 goto discard;
5554 5549
5550 /* ts_recent update must be made after we are sure that the packet
5551 * is in window.
5552 */
5553 tcp_replace_ts_recent(tp, TCP_SKB_CB(skb)->seq);
5554
5555 tcp_rcv_rtt_measure_ts(sk, skb); 5555 tcp_rcv_rtt_measure_ts(sk, skb);
5556 5556
5557 /* Process urgent data. */ 5557 /* Process urgent data. */
@@ -6130,6 +6130,11 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
6130 } else 6130 } else
6131 goto discard; 6131 goto discard;
6132 6132
6133 /* ts_recent update must be made after we are sure that the packet
6134 * is in window.
6135 */
6136 tcp_replace_ts_recent(tp, TCP_SKB_CB(skb)->seq);
6137
6133 /* step 6: check the URG bit */ 6138 /* step 6: check the URG bit */
6134 tcp_urg(sk, skb, th); 6139 tcp_urg(sk, skb, th);
6135 6140
diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c
index 53bc5847bfa8..f696d7c2e9fa 100644
--- a/net/ipv4/tcp_metrics.c
+++ b/net/ipv4/tcp_metrics.c
@@ -1,7 +1,6 @@
1#include <linux/rcupdate.h> 1#include <linux/rcupdate.h>
2#include <linux/spinlock.h> 2#include <linux/spinlock.h>
3#include <linux/jiffies.h> 3#include <linux/jiffies.h>
4#include <linux/bootmem.h>
5#include <linux/module.h> 4#include <linux/module.h>
6#include <linux/cache.h> 5#include <linux/cache.h>
7#include <linux/slab.h> 6#include <linux/slab.h>
@@ -9,6 +8,7 @@
9#include <linux/tcp.h> 8#include <linux/tcp.h>
10#include <linux/hash.h> 9#include <linux/hash.h>
11#include <linux/tcp_metrics.h> 10#include <linux/tcp_metrics.h>
11#include <linux/vmalloc.h>
12 12
13#include <net/inet_connection_sock.h> 13#include <net/inet_connection_sock.h>
14#include <net/net_namespace.h> 14#include <net/net_namespace.h>
@@ -1034,7 +1034,10 @@ static int __net_init tcp_net_metrics_init(struct net *net)
1034 net->ipv4.tcp_metrics_hash_log = order_base_2(slots); 1034 net->ipv4.tcp_metrics_hash_log = order_base_2(slots);
1035 size = sizeof(struct tcpm_hash_bucket) << net->ipv4.tcp_metrics_hash_log; 1035 size = sizeof(struct tcpm_hash_bucket) << net->ipv4.tcp_metrics_hash_log;
1036 1036
1037 net->ipv4.tcp_metrics_hash = kzalloc(size, GFP_KERNEL); 1037 net->ipv4.tcp_metrics_hash = kzalloc(size, GFP_KERNEL | __GFP_NOWARN);
1038 if (!net->ipv4.tcp_metrics_hash)
1039 net->ipv4.tcp_metrics_hash = vzalloc(size);
1040
1038 if (!net->ipv4.tcp_metrics_hash) 1041 if (!net->ipv4.tcp_metrics_hash)
1039 return -ENOMEM; 1042 return -ENOMEM;
1040 1043
@@ -1055,7 +1058,10 @@ static void __net_exit tcp_net_metrics_exit(struct net *net)
1055 tm = next; 1058 tm = next;
1056 } 1059 }
1057 } 1060 }
1058 kfree(net->ipv4.tcp_metrics_hash); 1061 if (is_vmalloc_addr(net->ipv4.tcp_metrics_hash))
1062 vfree(net->ipv4.tcp_metrics_hash);
1063 else
1064 kfree(net->ipv4.tcp_metrics_hash);
1059} 1065}
1060 1066
1061static __net_initdata struct pernet_operations tcp_net_metrics_ops = { 1067static __net_initdata struct pernet_operations tcp_net_metrics_ops = {
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index cfe6ffe1c177..2798706cb063 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -1986,6 +1986,9 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,
1986 tso_segs = tcp_init_tso_segs(sk, skb, mss_now); 1986 tso_segs = tcp_init_tso_segs(sk, skb, mss_now);
1987 BUG_ON(!tso_segs); 1987 BUG_ON(!tso_segs);
1988 1988
1989 if (unlikely(tp->repair) && tp->repair_queue == TCP_SEND_QUEUE)
1990 goto repair; /* Skip network transmission */
1991
1989 cwnd_quota = tcp_cwnd_test(tp, skb); 1992 cwnd_quota = tcp_cwnd_test(tp, skb);
1990 if (!cwnd_quota) 1993 if (!cwnd_quota)
1991 break; 1994 break;
@@ -2026,6 +2029,7 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,
2026 if (unlikely(tcp_transmit_skb(sk, skb, 1, gfp))) 2029 if (unlikely(tcp_transmit_skb(sk, skb, 1, gfp)))
2027 break; 2030 break;
2028 2031
2032repair:
2029 /* Advance the send_head. This one is sent out. 2033 /* Advance the send_head. This one is sent out.
2030 * This call will increment packets_out. 2034 * This call will increment packets_out.
2031 */ 2035 */
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
index 05c5ab8d983c..3be0ac2c1920 100644
--- a/net/ipv4/xfrm4_policy.c
+++ b/net/ipv4/xfrm4_policy.c
@@ -279,19 +279,8 @@ static void __exit xfrm4_policy_fini(void)
279 xfrm_policy_unregister_afinfo(&xfrm4_policy_afinfo); 279 xfrm_policy_unregister_afinfo(&xfrm4_policy_afinfo);
280} 280}
281 281
282void __init xfrm4_init(int rt_max_size) 282void __init xfrm4_init(void)
283{ 283{
284 /*
285 * Select a default value for the gc_thresh based on the main route
286 * table hash size. It seems to me the worst case scenario is when
287 * we have ipsec operating in transport mode, in which we create a
288 * dst_entry per socket. The xfrm gc algorithm starts trying to remove
289 * entries at gc_thresh, and prevents new allocations as 2*gc_thresh
290 * so lets set an initial xfrm gc_thresh value at the rt_max_size/2.
291 * That will let us store an ipsec connection per route table entry,
292 * and start cleaning when were 1/2 full
293 */
294 xfrm4_dst_ops.gc_thresh = rt_max_size/2;
295 dst_entries_init(&xfrm4_dst_ops); 284 dst_entries_init(&xfrm4_dst_ops);
296 285
297 xfrm4_state_init(); 286 xfrm4_state_init();
diff --git a/net/ipv6/inet6_connection_sock.c b/net/ipv6/inet6_connection_sock.c
index c4f934176cab..30647857a375 100644
--- a/net/ipv6/inet6_connection_sock.c
+++ b/net/ipv6/inet6_connection_sock.c
@@ -252,6 +252,7 @@ struct dst_entry *inet6_csk_update_pmtu(struct sock *sk, u32 mtu)
252 return NULL; 252 return NULL;
253 dst->ops->update_pmtu(dst, sk, NULL, mtu); 253 dst->ops->update_pmtu(dst, sk, NULL, mtu);
254 254
255 return inet6_csk_route_socket(sk, &fl6); 255 dst = inet6_csk_route_socket(sk, &fl6);
256 return IS_ERR(dst) ? NULL : dst;
256} 257}
257EXPORT_SYMBOL_GPL(inet6_csk_update_pmtu); 258EXPORT_SYMBOL_GPL(inet6_csk_update_pmtu);
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index ba6d13d1f1e1..e02faed6d17e 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -827,6 +827,7 @@ pref_skip_coa:
827 if (val < 0 || val > 255) 827 if (val < 0 || val > 255)
828 goto e_inval; 828 goto e_inval;
829 np->min_hopcount = val; 829 np->min_hopcount = val;
830 retv = 0;
830 break; 831 break;
831 case IPV6_DONTFRAG: 832 case IPV6_DONTFRAG:
832 np->dontfrag = valbool; 833 np->dontfrag = valbool;
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 05f3a313db88..7371f676cf41 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -2594,6 +2594,9 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
2594 else 2594 else
2595 local->probe_req_reg--; 2595 local->probe_req_reg--;
2596 2596
2597 if (!local->open_count)
2598 break;
2599
2597 ieee80211_queue_work(&local->hw, &local->reconfig_filter); 2600 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
2598 break; 2601 break;
2599 default: 2602 default:
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index bf87c70ac6c5..c21e33d1abd0 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -1151,10 +1151,6 @@ int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata)
1151 1151
1152 mutex_lock(&sdata->u.ibss.mtx); 1152 mutex_lock(&sdata->u.ibss.mtx);
1153 1153
1154 sdata->u.ibss.state = IEEE80211_IBSS_MLME_SEARCH;
1155 memset(sdata->u.ibss.bssid, 0, ETH_ALEN);
1156 sdata->u.ibss.ssid_len = 0;
1157
1158 active_ibss = ieee80211_sta_active_ibss(sdata); 1154 active_ibss = ieee80211_sta_active_ibss(sdata);
1159 1155
1160 if (!active_ibss && !is_zero_ether_addr(ifibss->bssid)) { 1156 if (!active_ibss && !is_zero_ether_addr(ifibss->bssid)) {
@@ -1175,6 +1171,10 @@ int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata)
1175 } 1171 }
1176 } 1172 }
1177 1173
1174 ifibss->state = IEEE80211_IBSS_MLME_SEARCH;
1175 memset(ifibss->bssid, 0, ETH_ALEN);
1176 ifibss->ssid_len = 0;
1177
1178 sta_info_flush(sdata->local, sdata); 1178 sta_info_flush(sdata->local, sdata);
1179 1179
1180 spin_lock_bh(&ifibss->incomplete_lock); 1180 spin_lock_bh(&ifibss->incomplete_lock);
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 8c804550465b..156e5835e37f 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1314,6 +1314,8 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,
1314 struct net_device *dev); 1314 struct net_device *dev);
1315netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, 1315netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1316 struct net_device *dev); 1316 struct net_device *dev);
1317void ieee80211_purge_tx_queue(struct ieee80211_hw *hw,
1318 struct sk_buff_head *skbs);
1317 1319
1318/* HT */ 1320/* HT */
1319void ieee80211_apply_htcap_overrides(struct ieee80211_sub_if_data *sdata, 1321void ieee80211_apply_htcap_overrides(struct ieee80211_sub_if_data *sdata,
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index c80c4490351c..f57f597972f8 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -871,8 +871,10 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
871 local->hw.wiphy->cipher_suites, 871 local->hw.wiphy->cipher_suites,
872 sizeof(u32) * local->hw.wiphy->n_cipher_suites, 872 sizeof(u32) * local->hw.wiphy->n_cipher_suites,
873 GFP_KERNEL); 873 GFP_KERNEL);
874 if (!suites) 874 if (!suites) {
875 return -ENOMEM; 875 result = -ENOMEM;
876 goto fail_wiphy_register;
877 }
876 for (r = 0; r < local->hw.wiphy->n_cipher_suites; r++) { 878 for (r = 0; r < local->hw.wiphy->n_cipher_suites; r++) {
877 u32 suite = local->hw.wiphy->cipher_suites[r]; 879 u32 suite = local->hw.wiphy->cipher_suites[r];
878 if (suite == WLAN_CIPHER_SUITE_WEP40 || 880 if (suite == WLAN_CIPHER_SUITE_WEP40 ||
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index c4cdbde24fd3..43e60b5a7546 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -917,7 +917,7 @@ int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
917 struct cfg80211_sched_scan_request *req) 917 struct cfg80211_sched_scan_request *req)
918{ 918{
919 struct ieee80211_local *local = sdata->local; 919 struct ieee80211_local *local = sdata->local;
920 struct ieee80211_sched_scan_ies sched_scan_ies; 920 struct ieee80211_sched_scan_ies sched_scan_ies = {};
921 int ret, i; 921 int ret, i;
922 922
923 mutex_lock(&local->mtx); 923 mutex_lock(&local->mtx);
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index 0a4e4c04db89..d2eb64e12353 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -117,8 +117,8 @@ static void free_sta_work(struct work_struct *wk)
117 117
118 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { 118 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
119 local->total_ps_buffered -= skb_queue_len(&sta->ps_tx_buf[ac]); 119 local->total_ps_buffered -= skb_queue_len(&sta->ps_tx_buf[ac]);
120 __skb_queue_purge(&sta->ps_tx_buf[ac]); 120 ieee80211_purge_tx_queue(&local->hw, &sta->ps_tx_buf[ac]);
121 __skb_queue_purge(&sta->tx_filtered[ac]); 121 ieee80211_purge_tx_queue(&local->hw, &sta->tx_filtered[ac]);
122 } 122 }
123 123
124#ifdef CONFIG_MAC80211_MESH 124#ifdef CONFIG_MAC80211_MESH
@@ -141,7 +141,7 @@ static void free_sta_work(struct work_struct *wk)
141 tid_tx = rcu_dereference_raw(sta->ampdu_mlme.tid_tx[i]); 141 tid_tx = rcu_dereference_raw(sta->ampdu_mlme.tid_tx[i]);
142 if (!tid_tx) 142 if (!tid_tx)
143 continue; 143 continue;
144 __skb_queue_purge(&tid_tx->pending); 144 ieee80211_purge_tx_queue(&local->hw, &tid_tx->pending);
145 kfree(tid_tx); 145 kfree(tid_tx);
146 } 146 }
147 147
@@ -961,6 +961,7 @@ void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta)
961 struct ieee80211_local *local = sdata->local; 961 struct ieee80211_local *local = sdata->local;
962 struct sk_buff_head pending; 962 struct sk_buff_head pending;
963 int filtered = 0, buffered = 0, ac; 963 int filtered = 0, buffered = 0, ac;
964 unsigned long flags;
964 965
965 clear_sta_flag(sta, WLAN_STA_SP); 966 clear_sta_flag(sta, WLAN_STA_SP);
966 967
@@ -976,12 +977,16 @@ void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta)
976 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { 977 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
977 int count = skb_queue_len(&pending), tmp; 978 int count = skb_queue_len(&pending), tmp;
978 979
980 spin_lock_irqsave(&sta->tx_filtered[ac].lock, flags);
979 skb_queue_splice_tail_init(&sta->tx_filtered[ac], &pending); 981 skb_queue_splice_tail_init(&sta->tx_filtered[ac], &pending);
982 spin_unlock_irqrestore(&sta->tx_filtered[ac].lock, flags);
980 tmp = skb_queue_len(&pending); 983 tmp = skb_queue_len(&pending);
981 filtered += tmp - count; 984 filtered += tmp - count;
982 count = tmp; 985 count = tmp;
983 986
987 spin_lock_irqsave(&sta->ps_tx_buf[ac].lock, flags);
984 skb_queue_splice_tail_init(&sta->ps_tx_buf[ac], &pending); 988 skb_queue_splice_tail_init(&sta->ps_tx_buf[ac], &pending);
989 spin_unlock_irqrestore(&sta->ps_tx_buf[ac].lock, flags);
985 tmp = skb_queue_len(&pending); 990 tmp = skb_queue_len(&pending);
986 buffered += tmp - count; 991 buffered += tmp - count;
987 } 992 }
diff --git a/net/mac80211/status.c b/net/mac80211/status.c
index 3af0cc4130f1..101eb88a2b78 100644
--- a/net/mac80211/status.c
+++ b/net/mac80211/status.c
@@ -668,3 +668,12 @@ void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb)
668 dev_kfree_skb_any(skb); 668 dev_kfree_skb_any(skb);
669} 669}
670EXPORT_SYMBOL(ieee80211_free_txskb); 670EXPORT_SYMBOL(ieee80211_free_txskb);
671
672void ieee80211_purge_tx_queue(struct ieee80211_hw *hw,
673 struct sk_buff_head *skbs)
674{
675 struct sk_buff *skb;
676
677 while ((skb = __skb_dequeue(skbs)))
678 ieee80211_free_txskb(hw, skb);
679}
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index c9bf83f36657..b858ebe41fda 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -1358,7 +1358,7 @@ static int invoke_tx_handlers(struct ieee80211_tx_data *tx)
1358 if (tx->skb) 1358 if (tx->skb)
1359 ieee80211_free_txskb(&tx->local->hw, tx->skb); 1359 ieee80211_free_txskb(&tx->local->hw, tx->skb);
1360 else 1360 else
1361 __skb_queue_purge(&tx->skbs); 1361 ieee80211_purge_tx_queue(&tx->local->hw, &tx->skbs);
1362 return -1; 1362 return -1;
1363 } else if (unlikely(res == TX_QUEUED)) { 1363 } else if (unlikely(res == TX_QUEUED)) {
1364 I802_DEBUG_INC(tx->local->tx_handlers_queued); 1364 I802_DEBUG_INC(tx->local->tx_handlers_queued);
@@ -2120,10 +2120,13 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
2120 */ 2120 */
2121void ieee80211_clear_tx_pending(struct ieee80211_local *local) 2121void ieee80211_clear_tx_pending(struct ieee80211_local *local)
2122{ 2122{
2123 struct sk_buff *skb;
2123 int i; 2124 int i;
2124 2125
2125 for (i = 0; i < local->hw.queues; i++) 2126 for (i = 0; i < local->hw.queues; i++) {
2126 skb_queue_purge(&local->pending[i]); 2127 while ((skb = skb_dequeue(&local->pending[i])) != NULL)
2128 ieee80211_free_txskb(&local->hw, skb);
2129 }
2127} 2130}
2128 2131
2129/* 2132/*
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 239391807ca9..0151ae33c4cd 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -1491,6 +1491,8 @@ int ieee80211_reconfig(struct ieee80211_local *local)
1491 list_for_each_entry(sdata, &local->interfaces, list) { 1491 list_for_each_entry(sdata, &local->interfaces, list) {
1492 if (sdata->vif.type != NL80211_IFTYPE_STATION) 1492 if (sdata->vif.type != NL80211_IFTYPE_STATION)
1493 continue; 1493 continue;
1494 if (!sdata->u.mgd.associated)
1495 continue;
1494 1496
1495 ieee80211_send_nullfunc(local, sdata, 0); 1497 ieee80211_send_nullfunc(local, sdata, 0);
1496 } 1498 }
diff --git a/net/netfilter/ipset/ip_set_hash_ip.c b/net/netfilter/ipset/ip_set_hash_ip.c
index ec3dba5dcd62..5c0b78528e55 100644
--- a/net/netfilter/ipset/ip_set_hash_ip.c
+++ b/net/netfilter/ipset/ip_set_hash_ip.c
@@ -173,6 +173,7 @@ hash_ip4_uadt(struct ip_set *set, struct nlattr *tb[],
173 return adtfn(set, &nip, timeout, flags); 173 return adtfn(set, &nip, timeout, flags);
174 } 174 }
175 175
176 ip_to = ip;
176 if (tb[IPSET_ATTR_IP_TO]) { 177 if (tb[IPSET_ATTR_IP_TO]) {
177 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP_TO], &ip_to); 178 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP_TO], &ip_to);
178 if (ret) 179 if (ret)
@@ -185,8 +186,7 @@ hash_ip4_uadt(struct ip_set *set, struct nlattr *tb[],
185 if (!cidr || cidr > 32) 186 if (!cidr || cidr > 32)
186 return -IPSET_ERR_INVALID_CIDR; 187 return -IPSET_ERR_INVALID_CIDR;
187 ip_set_mask_from_to(ip, ip_to, cidr); 188 ip_set_mask_from_to(ip, ip_to, cidr);
188 } else 189 }
189 ip_to = ip;
190 190
191 hosts = h->netmask == 32 ? 1 : 2 << (32 - h->netmask - 1); 191 hosts = h->netmask == 32 ? 1 : 2 << (32 - h->netmask - 1);
192 192
diff --git a/net/netfilter/ipset/ip_set_hash_ipport.c b/net/netfilter/ipset/ip_set_hash_ipport.c
index 0171f7502fa5..6283351f4eeb 100644
--- a/net/netfilter/ipset/ip_set_hash_ipport.c
+++ b/net/netfilter/ipset/ip_set_hash_ipport.c
@@ -162,7 +162,7 @@ hash_ipport4_uadt(struct ip_set *set, struct nlattr *tb[],
162 const struct ip_set_hash *h = set->data; 162 const struct ip_set_hash *h = set->data;
163 ipset_adtfn adtfn = set->variant->adt[adt]; 163 ipset_adtfn adtfn = set->variant->adt[adt];
164 struct hash_ipport4_elem data = { }; 164 struct hash_ipport4_elem data = { };
165 u32 ip, ip_to = 0, p = 0, port, port_to; 165 u32 ip, ip_to, p = 0, port, port_to;
166 u32 timeout = h->timeout; 166 u32 timeout = h->timeout;
167 bool with_ports = false; 167 bool with_ports = false;
168 int ret; 168 int ret;
@@ -210,7 +210,7 @@ hash_ipport4_uadt(struct ip_set *set, struct nlattr *tb[],
210 return ip_set_eexist(ret, flags) ? 0 : ret; 210 return ip_set_eexist(ret, flags) ? 0 : ret;
211 } 211 }
212 212
213 ip = ntohl(data.ip); 213 ip_to = ip = ntohl(data.ip);
214 if (tb[IPSET_ATTR_IP_TO]) { 214 if (tb[IPSET_ATTR_IP_TO]) {
215 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP_TO], &ip_to); 215 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP_TO], &ip_to);
216 if (ret) 216 if (ret)
@@ -223,8 +223,7 @@ hash_ipport4_uadt(struct ip_set *set, struct nlattr *tb[],
223 if (!cidr || cidr > 32) 223 if (!cidr || cidr > 32)
224 return -IPSET_ERR_INVALID_CIDR; 224 return -IPSET_ERR_INVALID_CIDR;
225 ip_set_mask_from_to(ip, ip_to, cidr); 225 ip_set_mask_from_to(ip, ip_to, cidr);
226 } else 226 }
227 ip_to = ip;
228 227
229 port_to = port = ntohs(data.port); 228 port_to = port = ntohs(data.port);
230 if (with_ports && tb[IPSET_ATTR_PORT_TO]) { 229 if (with_ports && tb[IPSET_ATTR_PORT_TO]) {
diff --git a/net/netfilter/ipset/ip_set_hash_ipportip.c b/net/netfilter/ipset/ip_set_hash_ipportip.c
index 6344ef551ec8..6a21271c8d5a 100644
--- a/net/netfilter/ipset/ip_set_hash_ipportip.c
+++ b/net/netfilter/ipset/ip_set_hash_ipportip.c
@@ -166,7 +166,7 @@ hash_ipportip4_uadt(struct ip_set *set, struct nlattr *tb[],
166 const struct ip_set_hash *h = set->data; 166 const struct ip_set_hash *h = set->data;
167 ipset_adtfn adtfn = set->variant->adt[adt]; 167 ipset_adtfn adtfn = set->variant->adt[adt];
168 struct hash_ipportip4_elem data = { }; 168 struct hash_ipportip4_elem data = { };
169 u32 ip, ip_to = 0, p = 0, port, port_to; 169 u32 ip, ip_to, p = 0, port, port_to;
170 u32 timeout = h->timeout; 170 u32 timeout = h->timeout;
171 bool with_ports = false; 171 bool with_ports = false;
172 int ret; 172 int ret;
@@ -218,7 +218,7 @@ hash_ipportip4_uadt(struct ip_set *set, struct nlattr *tb[],
218 return ip_set_eexist(ret, flags) ? 0 : ret; 218 return ip_set_eexist(ret, flags) ? 0 : ret;
219 } 219 }
220 220
221 ip = ntohl(data.ip); 221 ip_to = ip = ntohl(data.ip);
222 if (tb[IPSET_ATTR_IP_TO]) { 222 if (tb[IPSET_ATTR_IP_TO]) {
223 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP_TO], &ip_to); 223 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP_TO], &ip_to);
224 if (ret) 224 if (ret)
@@ -231,8 +231,7 @@ hash_ipportip4_uadt(struct ip_set *set, struct nlattr *tb[],
231 if (!cidr || cidr > 32) 231 if (!cidr || cidr > 32)
232 return -IPSET_ERR_INVALID_CIDR; 232 return -IPSET_ERR_INVALID_CIDR;
233 ip_set_mask_from_to(ip, ip_to, cidr); 233 ip_set_mask_from_to(ip, ip_to, cidr);
234 } else 234 }
235 ip_to = ip;
236 235
237 port_to = port = ntohs(data.port); 236 port_to = port = ntohs(data.port);
238 if (with_ports && tb[IPSET_ATTR_PORT_TO]) { 237 if (with_ports && tb[IPSET_ATTR_PORT_TO]) {
diff --git a/net/netfilter/ipset/ip_set_hash_ipportnet.c b/net/netfilter/ipset/ip_set_hash_ipportnet.c
index cb71f9a774e7..2d5cd4ee30eb 100644
--- a/net/netfilter/ipset/ip_set_hash_ipportnet.c
+++ b/net/netfilter/ipset/ip_set_hash_ipportnet.c
@@ -215,8 +215,8 @@ hash_ipportnet4_uadt(struct ip_set *set, struct nlattr *tb[],
215 const struct ip_set_hash *h = set->data; 215 const struct ip_set_hash *h = set->data;
216 ipset_adtfn adtfn = set->variant->adt[adt]; 216 ipset_adtfn adtfn = set->variant->adt[adt];
217 struct hash_ipportnet4_elem data = { .cidr = HOST_MASK - 1 }; 217 struct hash_ipportnet4_elem data = { .cidr = HOST_MASK - 1 };
218 u32 ip, ip_to = 0, p = 0, port, port_to; 218 u32 ip, ip_to, p = 0, port, port_to;
219 u32 ip2_from = 0, ip2_to, ip2_last, ip2; 219 u32 ip2_from, ip2_to, ip2_last, ip2;
220 u32 timeout = h->timeout; 220 u32 timeout = h->timeout;
221 bool with_ports = false; 221 bool with_ports = false;
222 u8 cidr; 222 u8 cidr;
@@ -286,6 +286,7 @@ hash_ipportnet4_uadt(struct ip_set *set, struct nlattr *tb[],
286 return ip_set_eexist(ret, flags) ? 0 : ret; 286 return ip_set_eexist(ret, flags) ? 0 : ret;
287 } 287 }
288 288
289 ip_to = ip;
289 if (tb[IPSET_ATTR_IP_TO]) { 290 if (tb[IPSET_ATTR_IP_TO]) {
290 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP_TO], &ip_to); 291 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP_TO], &ip_to);
291 if (ret) 292 if (ret)
@@ -306,6 +307,8 @@ hash_ipportnet4_uadt(struct ip_set *set, struct nlattr *tb[],
306 if (port > port_to) 307 if (port > port_to)
307 swap(port, port_to); 308 swap(port, port_to);
308 } 309 }
310
311 ip2_to = ip2_from;
309 if (tb[IPSET_ATTR_IP2_TO]) { 312 if (tb[IPSET_ATTR_IP2_TO]) {
310 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP2_TO], &ip2_to); 313 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP2_TO], &ip2_to);
311 if (ret) 314 if (ret)
diff --git a/net/netfilter/nfnetlink_cttimeout.c b/net/netfilter/nfnetlink_cttimeout.c
index 8847b4d8be06..701c88a20fea 100644
--- a/net/netfilter/nfnetlink_cttimeout.c
+++ b/net/netfilter/nfnetlink_cttimeout.c
@@ -41,7 +41,8 @@ MODULE_DESCRIPTION("cttimeout: Extended Netfilter Connection Tracking timeout tu
41static LIST_HEAD(cttimeout_list); 41static LIST_HEAD(cttimeout_list);
42 42
43static const struct nla_policy cttimeout_nla_policy[CTA_TIMEOUT_MAX+1] = { 43static const struct nla_policy cttimeout_nla_policy[CTA_TIMEOUT_MAX+1] = {
44 [CTA_TIMEOUT_NAME] = { .type = NLA_NUL_STRING }, 44 [CTA_TIMEOUT_NAME] = { .type = NLA_NUL_STRING,
45 .len = CTNL_TIMEOUT_NAME_MAX - 1},
45 [CTA_TIMEOUT_L3PROTO] = { .type = NLA_U16 }, 46 [CTA_TIMEOUT_L3PROTO] = { .type = NLA_U16 },
46 [CTA_TIMEOUT_L4PROTO] = { .type = NLA_U8 }, 47 [CTA_TIMEOUT_L4PROTO] = { .type = NLA_U8 },
47 [CTA_TIMEOUT_DATA] = { .type = NLA_NESTED }, 48 [CTA_TIMEOUT_DATA] = { .type = NLA_NESTED },
diff --git a/net/nfc/llcp/llcp.c b/net/nfc/llcp/llcp.c
index cc10d073c338..9e8f4b2801f6 100644
--- a/net/nfc/llcp/llcp.c
+++ b/net/nfc/llcp/llcp.c
@@ -1210,7 +1210,7 @@ int nfc_llcp_register_device(struct nfc_dev *ndev)
1210 local->remote_miu = LLCP_DEFAULT_MIU; 1210 local->remote_miu = LLCP_DEFAULT_MIU;
1211 local->remote_lto = LLCP_DEFAULT_LTO; 1211 local->remote_lto = LLCP_DEFAULT_LTO;
1212 1212
1213 list_add(&llcp_devices, &local->list); 1213 list_add(&local->list, &llcp_devices);
1214 1214
1215 return 0; 1215 return 0;
1216} 1216}
diff --git a/net/sctp/proc.c b/net/sctp/proc.c
index c3bea269faf4..9966e7b16451 100644
--- a/net/sctp/proc.c
+++ b/net/sctp/proc.c
@@ -102,7 +102,7 @@ static const struct file_operations sctp_snmp_seq_fops = {
102 .open = sctp_snmp_seq_open, 102 .open = sctp_snmp_seq_open,
103 .read = seq_read, 103 .read = seq_read,
104 .llseek = seq_lseek, 104 .llseek = seq_lseek,
105 .release = single_release, 105 .release = single_release_net,
106}; 106};
107 107
108/* Set up the proc fs entry for 'snmp' object. */ 108/* Set up the proc fs entry for 'snmp' object. */
@@ -251,7 +251,7 @@ static const struct file_operations sctp_eps_seq_fops = {
251 .open = sctp_eps_seq_open, 251 .open = sctp_eps_seq_open,
252 .read = seq_read, 252 .read = seq_read,
253 .llseek = seq_lseek, 253 .llseek = seq_lseek,
254 .release = seq_release, 254 .release = seq_release_net,
255}; 255};
256 256
257/* Set up the proc fs entry for 'eps' object. */ 257/* Set up the proc fs entry for 'eps' object. */
@@ -372,7 +372,7 @@ static const struct file_operations sctp_assocs_seq_fops = {
372 .open = sctp_assocs_seq_open, 372 .open = sctp_assocs_seq_open,
373 .read = seq_read, 373 .read = seq_read,
374 .llseek = seq_lseek, 374 .llseek = seq_lseek,
375 .release = seq_release, 375 .release = seq_release_net,
376}; 376};
377 377
378/* Set up the proc fs entry for 'assocs' object. */ 378/* Set up the proc fs entry for 'assocs' object. */
@@ -517,7 +517,7 @@ static const struct file_operations sctp_remaddr_seq_fops = {
517 .open = sctp_remaddr_seq_open, 517 .open = sctp_remaddr_seq_open,
518 .read = seq_read, 518 .read = seq_read,
519 .llseek = seq_lseek, 519 .llseek = seq_lseek,
520 .release = seq_release, 520 .release = seq_release_net,
521}; 521};
522 522
523int __net_init sctp_remaddr_proc_init(struct net *net) 523int __net_init sctp_remaddr_proc_init(struct net *net)
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index bcc7d7ee5a51..b75756b05af7 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -141,9 +141,8 @@ static const struct ieee80211_regdomain world_regdom = {
141 .reg_rules = { 141 .reg_rules = {
142 /* IEEE 802.11b/g, channels 1..11 */ 142 /* IEEE 802.11b/g, channels 1..11 */
143 REG_RULE(2412-10, 2462+10, 40, 6, 20, 0), 143 REG_RULE(2412-10, 2462+10, 40, 6, 20, 0),
144 /* IEEE 802.11b/g, channels 12..13. No HT40 144 /* IEEE 802.11b/g, channels 12..13. */
145 * channel fits here. */ 145 REG_RULE(2467-10, 2472+10, 40, 6, 20,
146 REG_RULE(2467-10, 2472+10, 20, 6, 20,
147 NL80211_RRF_PASSIVE_SCAN | 146 NL80211_RRF_PASSIVE_SCAN |
148 NL80211_RRF_NO_IBSS), 147 NL80211_RRF_NO_IBSS),
149 /* IEEE 802.11 channel 14 - Only JP enables 148 /* IEEE 802.11 channel 14 - Only JP enables
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index bd2e09895553..cdd48600e02a 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -12,7 +12,7 @@ extern "C" {
12 12
13#include <assert.h> 13#include <assert.h>
14#include <stdio.h> 14#include <stdio.h>
15#include <sys/queue.h> 15#include "list.h"
16#ifndef __cplusplus 16#ifndef __cplusplus
17#include <stdbool.h> 17#include <stdbool.h>
18#endif 18#endif
@@ -175,12 +175,11 @@ struct menu {
175#define MENU_ROOT 0x0002 175#define MENU_ROOT 0x0002
176 176
177struct jump_key { 177struct jump_key {
178 CIRCLEQ_ENTRY(jump_key) entries; 178 struct list_head entries;
179 size_t offset; 179 size_t offset;
180 struct menu *target; 180 struct menu *target;
181 int index; 181 int index;
182}; 182};
183CIRCLEQ_HEAD(jk_head, jump_key);
184 183
185#define JUMP_NB 9 184#define JUMP_NB 9
186 185
diff --git a/scripts/kconfig/list.h b/scripts/kconfig/list.h
new file mode 100644
index 000000000000..0ae730be5f49
--- /dev/null
+++ b/scripts/kconfig/list.h
@@ -0,0 +1,91 @@
1#ifndef LIST_H
2#define LIST_H
3
4/*
5 * Copied from include/linux/...
6 */
7
8#undef offsetof
9#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
10
11/**
12 * container_of - cast a member of a structure out to the containing structure
13 * @ptr: the pointer to the member.
14 * @type: the type of the container struct this is embedded in.
15 * @member: the name of the member within the struct.
16 *
17 */
18#define container_of(ptr, type, member) ({ \
19 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
20 (type *)( (char *)__mptr - offsetof(type,member) );})
21
22
23struct list_head {
24 struct list_head *next, *prev;
25};
26
27
28#define LIST_HEAD_INIT(name) { &(name), &(name) }
29
30#define LIST_HEAD(name) \
31 struct list_head name = LIST_HEAD_INIT(name)
32
33/**
34 * list_entry - get the struct for this entry
35 * @ptr: the &struct list_head pointer.
36 * @type: the type of the struct this is embedded in.
37 * @member: the name of the list_struct within the struct.
38 */
39#define list_entry(ptr, type, member) \
40 container_of(ptr, type, member)
41
42/**
43 * list_for_each_entry - iterate over list of given type
44 * @pos: the type * to use as a loop cursor.
45 * @head: the head for your list.
46 * @member: the name of the list_struct within the struct.
47 */
48#define list_for_each_entry(pos, head, member) \
49 for (pos = list_entry((head)->next, typeof(*pos), member); \
50 &pos->member != (head); \
51 pos = list_entry(pos->member.next, typeof(*pos), member))
52
53/**
54 * list_empty - tests whether a list is empty
55 * @head: the list to test.
56 */
57static inline int list_empty(const struct list_head *head)
58{
59 return head->next == head;
60}
61
62/*
63 * Insert a new entry between two known consecutive entries.
64 *
65 * This is only for internal list manipulation where we know
66 * the prev/next entries already!
67 */
68static inline void __list_add(struct list_head *_new,
69 struct list_head *prev,
70 struct list_head *next)
71{
72 next->prev = _new;
73 _new->next = next;
74 _new->prev = prev;
75 prev->next = _new;
76}
77
78/**
79 * list_add_tail - add a new entry
80 * @new: new entry to be added
81 * @head: list head to add it before
82 *
83 * Insert a new entry before the specified head.
84 * This is useful for implementing queues.
85 */
86static inline void list_add_tail(struct list_head *_new, struct list_head *head)
87{
88 __list_add(_new, head->prev, head);
89}
90
91#endif
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h
index 1d1c08537f1e..ef1a7381f956 100644
--- a/scripts/kconfig/lkc_proto.h
+++ b/scripts/kconfig/lkc_proto.h
@@ -21,9 +21,9 @@ P(menu_get_root_menu,struct menu *,(struct menu *menu));
21P(menu_get_parent_menu,struct menu *,(struct menu *menu)); 21P(menu_get_parent_menu,struct menu *,(struct menu *menu));
22P(menu_has_help,bool,(struct menu *menu)); 22P(menu_has_help,bool,(struct menu *menu));
23P(menu_get_help,const char *,(struct menu *menu)); 23P(menu_get_help,const char *,(struct menu *menu));
24P(get_symbol_str, void, (struct gstr *r, struct symbol *sym, struct jk_head 24P(get_symbol_str, void, (struct gstr *r, struct symbol *sym, struct list_head
25 *head)); 25 *head));
26P(get_relations_str, struct gstr, (struct symbol **sym_arr, struct jk_head 26P(get_relations_str, struct gstr, (struct symbol **sym_arr, struct list_head
27 *head)); 27 *head));
28P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help)); 28P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help));
29 29
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index 48f67448af7b..53975cf87608 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -312,7 +312,7 @@ static void set_config_filename(const char *config_filename)
312 312
313 313
314struct search_data { 314struct search_data {
315 struct jk_head *head; 315 struct list_head *head;
316 struct menu **targets; 316 struct menu **targets;
317 int *keys; 317 int *keys;
318}; 318};
@@ -323,7 +323,7 @@ static void update_text(char *buf, size_t start, size_t end, void *_data)
323 struct jump_key *pos; 323 struct jump_key *pos;
324 int k = 0; 324 int k = 0;
325 325
326 CIRCLEQ_FOREACH(pos, data->head, entries) { 326 list_for_each_entry(pos, data->head, entries) {
327 if (pos->offset >= start && pos->offset < end) { 327 if (pos->offset >= start && pos->offset < end) {
328 char header[4]; 328 char header[4];
329 329
@@ -375,7 +375,7 @@ again:
375 375
376 sym_arr = sym_re_search(dialog_input); 376 sym_arr = sym_re_search(dialog_input);
377 do { 377 do {
378 struct jk_head head = CIRCLEQ_HEAD_INITIALIZER(head); 378 LIST_HEAD(head);
379 struct menu *targets[JUMP_NB]; 379 struct menu *targets[JUMP_NB];
380 int keys[JUMP_NB + 1], i; 380 int keys[JUMP_NB + 1], i;
381 struct search_data data = { 381 struct search_data data = {
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index a3cade659f89..e98a05c8e508 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -508,7 +508,7 @@ const char *menu_get_help(struct menu *menu)
508} 508}
509 509
510static void get_prompt_str(struct gstr *r, struct property *prop, 510static void get_prompt_str(struct gstr *r, struct property *prop,
511 struct jk_head *head) 511 struct list_head *head)
512{ 512{
513 int i, j; 513 int i, j;
514 struct menu *submenu[8], *menu, *location = NULL; 514 struct menu *submenu[8], *menu, *location = NULL;
@@ -544,12 +544,13 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
544 } else 544 } else
545 jump->target = location; 545 jump->target = location;
546 546
547 if (CIRCLEQ_EMPTY(head)) 547 if (list_empty(head))
548 jump->index = 0; 548 jump->index = 0;
549 else 549 else
550 jump->index = CIRCLEQ_LAST(head)->index + 1; 550 jump->index = list_entry(head->prev, struct jump_key,
551 entries)->index + 1;
551 552
552 CIRCLEQ_INSERT_TAIL(head, jump, entries); 553 list_add_tail(&jump->entries, head);
553 } 554 }
554 555
555 if (i > 0) { 556 if (i > 0) {
@@ -573,7 +574,8 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
573/* 574/*
574 * head is optional and may be NULL 575 * head is optional and may be NULL
575 */ 576 */
576void get_symbol_str(struct gstr *r, struct symbol *sym, struct jk_head *head) 577void get_symbol_str(struct gstr *r, struct symbol *sym,
578 struct list_head *head)
577{ 579{
578 bool hit; 580 bool hit;
579 struct property *prop; 581 struct property *prop;
@@ -612,7 +614,7 @@ void get_symbol_str(struct gstr *r, struct symbol *sym, struct jk_head *head)
612 str_append(r, "\n\n"); 614 str_append(r, "\n\n");
613} 615}
614 616
615struct gstr get_relations_str(struct symbol **sym_arr, struct jk_head *head) 617struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head)
616{ 618{
617 struct symbol *sym; 619 struct symbol *sym;
618 struct gstr res = str_new(); 620 struct gstr res = str_new();
diff --git a/scripts/sign-file b/scripts/sign-file
index 87ca59d36e7e..974a20b661b7 100755
--- a/scripts/sign-file
+++ b/scripts/sign-file
@@ -156,12 +156,12 @@ sub asn1_extract($$@)
156 156
157 if ($l == 0x1) { 157 if ($l == 0x1) {
158 $len = unpack("C", substr(${$cursor->[2]}, $cursor->[0], 1)); 158 $len = unpack("C", substr(${$cursor->[2]}, $cursor->[0], 1));
159 } elsif ($l = 0x2) { 159 } elsif ($l == 0x2) {
160 $len = unpack("n", substr(${$cursor->[2]}, $cursor->[0], 2)); 160 $len = unpack("n", substr(${$cursor->[2]}, $cursor->[0], 2));
161 } elsif ($l = 0x3) { 161 } elsif ($l == 0x3) {
162 $len = unpack("C", substr(${$cursor->[2]}, $cursor->[0], 1)) << 16; 162 $len = unpack("C", substr(${$cursor->[2]}, $cursor->[0], 1)) << 16;
163 $len = unpack("n", substr(${$cursor->[2]}, $cursor->[0] + 1, 2)); 163 $len = unpack("n", substr(${$cursor->[2]}, $cursor->[0] + 1, 2));
164 } elsif ($l = 0x4) { 164 } elsif ($l == 0x4) {
165 $len = unpack("N", substr(${$cursor->[2]}, $cursor->[0], 4)); 165 $len = unpack("N", substr(${$cursor->[2]}, $cursor->[0], 4));
166 } else { 166 } else {
167 die $x509, ": ", $cursor->[0], ": ASN.1 element too long (", $l, ")\n"; 167 die $x509, ": ", $cursor->[0], ": ASN.1 element too long (", $l, ")\n";
diff --git a/security/device_cgroup.c b/security/device_cgroup.c
index 842c254396db..b08d20c66c2e 100644
--- a/security/device_cgroup.c
+++ b/security/device_cgroup.c
@@ -164,8 +164,8 @@ static void dev_exception_clean(struct dev_cgroup *dev_cgroup)
164 struct dev_exception_item *ex, *tmp; 164 struct dev_exception_item *ex, *tmp;
165 165
166 list_for_each_entry_safe(ex, tmp, &dev_cgroup->exceptions, list) { 166 list_for_each_entry_safe(ex, tmp, &dev_cgroup->exceptions, list) {
167 list_del(&ex->list); 167 list_del_rcu(&ex->list);
168 kfree(ex); 168 kfree_rcu(ex, rcu);
169 } 169 }
170} 170}
171 171
@@ -298,7 +298,7 @@ static int may_access(struct dev_cgroup *dev_cgroup,
298 struct dev_exception_item *ex; 298 struct dev_exception_item *ex;
299 bool match = false; 299 bool match = false;
300 300
301 list_for_each_entry(ex, &dev_cgroup->exceptions, list) { 301 list_for_each_entry_rcu(ex, &dev_cgroup->exceptions, list) {
302 if ((refex->type & DEV_BLOCK) && !(ex->type & DEV_BLOCK)) 302 if ((refex->type & DEV_BLOCK) && !(ex->type & DEV_BLOCK))
303 continue; 303 continue;
304 if ((refex->type & DEV_CHAR) && !(ex->type & DEV_CHAR)) 304 if ((refex->type & DEV_CHAR) && !(ex->type & DEV_CHAR))
@@ -352,6 +352,8 @@ static int parent_has_perm(struct dev_cgroup *childcg,
352 */ 352 */
353static inline int may_allow_all(struct dev_cgroup *parent) 353static inline int may_allow_all(struct dev_cgroup *parent)
354{ 354{
355 if (!parent)
356 return 1;
355 return parent->behavior == DEVCG_DEFAULT_ALLOW; 357 return parent->behavior == DEVCG_DEFAULT_ALLOW;
356} 358}
357 359
@@ -376,11 +378,14 @@ static int devcgroup_update_access(struct dev_cgroup *devcgroup,
376 int count, rc; 378 int count, rc;
377 struct dev_exception_item ex; 379 struct dev_exception_item ex;
378 struct cgroup *p = devcgroup->css.cgroup; 380 struct cgroup *p = devcgroup->css.cgroup;
379 struct dev_cgroup *parent = cgroup_to_devcgroup(p->parent); 381 struct dev_cgroup *parent = NULL;
380 382
381 if (!capable(CAP_SYS_ADMIN)) 383 if (!capable(CAP_SYS_ADMIN))
382 return -EPERM; 384 return -EPERM;
383 385
386 if (p->parent)
387 parent = cgroup_to_devcgroup(p->parent);
388
384 memset(&ex, 0, sizeof(ex)); 389 memset(&ex, 0, sizeof(ex));
385 b = buffer; 390 b = buffer;
386 391
@@ -391,11 +396,14 @@ static int devcgroup_update_access(struct dev_cgroup *devcgroup,
391 if (!may_allow_all(parent)) 396 if (!may_allow_all(parent))
392 return -EPERM; 397 return -EPERM;
393 dev_exception_clean(devcgroup); 398 dev_exception_clean(devcgroup);
399 devcgroup->behavior = DEVCG_DEFAULT_ALLOW;
400 if (!parent)
401 break;
402
394 rc = dev_exceptions_copy(&devcgroup->exceptions, 403 rc = dev_exceptions_copy(&devcgroup->exceptions,
395 &parent->exceptions); 404 &parent->exceptions);
396 if (rc) 405 if (rc)
397 return rc; 406 return rc;
398 devcgroup->behavior = DEVCG_DEFAULT_ALLOW;
399 break; 407 break;
400 case DEVCG_DENY: 408 case DEVCG_DENY:
401 dev_exception_clean(devcgroup); 409 dev_exception_clean(devcgroup);
diff --git a/security/selinux/netnode.c b/security/selinux/netnode.c
index 28f911cdd7c7..c5454c0477c3 100644
--- a/security/selinux/netnode.c
+++ b/security/selinux/netnode.c
@@ -174,7 +174,8 @@ static void sel_netnode_insert(struct sel_netnode *node)
174 if (sel_netnode_hash[idx].size == SEL_NETNODE_HASH_BKT_LIMIT) { 174 if (sel_netnode_hash[idx].size == SEL_NETNODE_HASH_BKT_LIMIT) {
175 struct sel_netnode *tail; 175 struct sel_netnode *tail;
176 tail = list_entry( 176 tail = list_entry(
177 rcu_dereference(sel_netnode_hash[idx].list.prev), 177 rcu_dereference_protected(sel_netnode_hash[idx].list.prev,
178 lockdep_is_held(&sel_netnode_lock)),
178 struct sel_netnode, list); 179 struct sel_netnode, list);
179 list_del_rcu(&tail->list); 180 list_del_rcu(&tail->list);
180 kfree_rcu(tail, rcu); 181 kfree_rcu(tail, rcu);
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index 50169bcfd903..7266020c16cb 100644
--- a/sound/pci/es1968.c
+++ b/sound/pci/es1968.c
@@ -2581,9 +2581,14 @@ static u8 snd_es1968_tea575x_get_pins(struct snd_tea575x *tea)
2581 struct es1968 *chip = tea->private_data; 2581 struct es1968 *chip = tea->private_data;
2582 unsigned long io = chip->io_port + GPIO_DATA; 2582 unsigned long io = chip->io_port + GPIO_DATA;
2583 u16 val = inw(io); 2583 u16 val = inw(io);
2584 2584 u8 ret;
2585 return (val & STR_DATA) ? TEA575X_DATA : 0 | 2585
2586 (val & STR_MOST) ? TEA575X_MOST : 0; 2586 ret = 0;
2587 if (val & STR_DATA)
2588 ret |= TEA575X_DATA;
2589 if (val & STR_MOST)
2590 ret |= TEA575X_MOST;
2591 return ret;
2587} 2592}
2588 2593
2589static void snd_es1968_tea575x_set_direction(struct snd_tea575x *tea, bool output) 2594static void snd_es1968_tea575x_set_direction(struct snd_tea575x *tea, bool output)
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
index cc2e91d15538..c5806f89be1e 100644
--- a/sound/pci/fm801.c
+++ b/sound/pci/fm801.c
@@ -767,9 +767,14 @@ static u8 snd_fm801_tea575x_get_pins(struct snd_tea575x *tea)
767 struct fm801 *chip = tea->private_data; 767 struct fm801 *chip = tea->private_data;
768 unsigned short reg = inw(FM801_REG(chip, GPIO_CTRL)); 768 unsigned short reg = inw(FM801_REG(chip, GPIO_CTRL));
769 struct snd_fm801_tea575x_gpio gpio = *get_tea575x_gpio(chip); 769 struct snd_fm801_tea575x_gpio gpio = *get_tea575x_gpio(chip);
770 770 u8 ret;
771 return (reg & FM801_GPIO_GP(gpio.data)) ? TEA575X_DATA : 0 | 771
772 (reg & FM801_GPIO_GP(gpio.most)) ? TEA575X_MOST : 0; 772 ret = 0;
773 if (reg & FM801_GPIO_GP(gpio.data))
774 ret |= TEA575X_DATA;
775 if (reg & FM801_GPIO_GP(gpio.most))
776 ret |= TEA575X_MOST;
777 return ret;
773} 778}
774 779
775static void snd_fm801_tea575x_set_direction(struct snd_tea575x *tea, bool output) 780static void snd_fm801_tea575x_set_direction(struct snd_tea575x *tea, bool output)
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 70d4848b5cd0..d010de12335e 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -95,6 +95,7 @@ int snd_hda_delete_codec_preset(struct hda_codec_preset_list *preset)
95EXPORT_SYMBOL_HDA(snd_hda_delete_codec_preset); 95EXPORT_SYMBOL_HDA(snd_hda_delete_codec_preset);
96 96
97#ifdef CONFIG_PM 97#ifdef CONFIG_PM
98#define codec_in_pm(codec) ((codec)->in_pm)
98static void hda_power_work(struct work_struct *work); 99static void hda_power_work(struct work_struct *work);
99static void hda_keep_power_on(struct hda_codec *codec); 100static void hda_keep_power_on(struct hda_codec *codec);
100#define hda_codec_is_power_on(codec) ((codec)->power_on) 101#define hda_codec_is_power_on(codec) ((codec)->power_on)
@@ -104,6 +105,7 @@ static inline void hda_call_pm_notify(struct hda_bus *bus, bool power_up)
104 bus->ops.pm_notify(bus, power_up); 105 bus->ops.pm_notify(bus, power_up);
105} 106}
106#else 107#else
108#define codec_in_pm(codec) 0
107static inline void hda_keep_power_on(struct hda_codec *codec) {} 109static inline void hda_keep_power_on(struct hda_codec *codec) {}
108#define hda_codec_is_power_on(codec) 1 110#define hda_codec_is_power_on(codec) 1
109#define hda_call_pm_notify(bus, state) {} 111#define hda_call_pm_notify(bus, state) {}
@@ -228,7 +230,7 @@ static int codec_exec_verb(struct hda_codec *codec, unsigned int cmd,
228 } 230 }
229 mutex_unlock(&bus->cmd_mutex); 231 mutex_unlock(&bus->cmd_mutex);
230 snd_hda_power_down(codec); 232 snd_hda_power_down(codec);
231 if (res && *res == -1 && bus->rirb_error) { 233 if (!codec_in_pm(codec) && res && *res == -1 && bus->rirb_error) {
232 if (bus->response_reset) { 234 if (bus->response_reset) {
233 snd_printd("hda_codec: resetting BUS due to " 235 snd_printd("hda_codec: resetting BUS due to "
234 "fatal communication error\n"); 236 "fatal communication error\n");
@@ -238,7 +240,7 @@ static int codec_exec_verb(struct hda_codec *codec, unsigned int cmd,
238 goto again; 240 goto again;
239 } 241 }
240 /* clear reset-flag when the communication gets recovered */ 242 /* clear reset-flag when the communication gets recovered */
241 if (!err) 243 if (!err || codec_in_pm(codec))
242 bus->response_reset = 0; 244 bus->response_reset = 0;
243 return err; 245 return err;
244} 246}
@@ -3616,6 +3618,8 @@ static unsigned int hda_call_codec_suspend(struct hda_codec *codec, bool in_wq)
3616{ 3618{
3617 unsigned int state; 3619 unsigned int state;
3618 3620
3621 codec->in_pm = 1;
3622
3619 if (codec->patch_ops.suspend) 3623 if (codec->patch_ops.suspend)
3620 codec->patch_ops.suspend(codec); 3624 codec->patch_ops.suspend(codec);
3621 hda_cleanup_all_streams(codec); 3625 hda_cleanup_all_streams(codec);
@@ -3630,6 +3634,7 @@ static unsigned int hda_call_codec_suspend(struct hda_codec *codec, bool in_wq)
3630 codec->power_transition = 0; 3634 codec->power_transition = 0;
3631 codec->power_jiffies = jiffies; 3635 codec->power_jiffies = jiffies;
3632 spin_unlock(&codec->power_lock); 3636 spin_unlock(&codec->power_lock);
3637 codec->in_pm = 0;
3633 return state; 3638 return state;
3634} 3639}
3635 3640
@@ -3638,6 +3643,8 @@ static unsigned int hda_call_codec_suspend(struct hda_codec *codec, bool in_wq)
3638 */ 3643 */
3639static void hda_call_codec_resume(struct hda_codec *codec) 3644static void hda_call_codec_resume(struct hda_codec *codec)
3640{ 3645{
3646 codec->in_pm = 1;
3647
3641 /* set as if powered on for avoiding re-entering the resume 3648 /* set as if powered on for avoiding re-entering the resume
3642 * in the resume / power-save sequence 3649 * in the resume / power-save sequence
3643 */ 3650 */
@@ -3656,6 +3663,8 @@ static void hda_call_codec_resume(struct hda_codec *codec)
3656 snd_hda_codec_resume_cache(codec); 3663 snd_hda_codec_resume_cache(codec);
3657 } 3664 }
3658 snd_hda_jack_report_sync(codec); 3665 snd_hda_jack_report_sync(codec);
3666
3667 codec->in_pm = 0;
3659 snd_hda_power_down(codec); /* flag down before returning */ 3668 snd_hda_power_down(codec); /* flag down before returning */
3660} 3669}
3661#endif /* CONFIG_PM */ 3670#endif /* CONFIG_PM */
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 507fe8a917b6..4f4e545c0f4b 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -869,6 +869,7 @@ struct hda_codec {
869 unsigned int power_on :1; /* current (global) power-state */ 869 unsigned int power_on :1; /* current (global) power-state */
870 unsigned int d3_stop_clk:1; /* support D3 operation without BCLK */ 870 unsigned int d3_stop_clk:1; /* support D3 operation without BCLK */
871 unsigned int pm_down_notified:1; /* PM notified to controller */ 871 unsigned int pm_down_notified:1; /* PM notified to controller */
872 unsigned int in_pm:1; /* suspend/resume being performed */
872 int power_transition; /* power-state in transition */ 873 int power_transition; /* power-state in transition */
873 int power_count; /* current (global) power refcount */ 874 int power_count; /* current (global) power refcount */
874 struct delayed_work power_work; /* delayed task for powerdown */ 875 struct delayed_work power_work; /* delayed task for powerdown */
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index cd2dbaf1be78..f9d870e554d9 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -556,6 +556,12 @@ enum {
556#define AZX_DCAPS_ALIGN_BUFSIZE (1 << 22) /* buffer size alignment */ 556#define AZX_DCAPS_ALIGN_BUFSIZE (1 << 22) /* buffer size alignment */
557#define AZX_DCAPS_4K_BDLE_BOUNDARY (1 << 23) /* BDLE in 4k boundary */ 557#define AZX_DCAPS_4K_BDLE_BOUNDARY (1 << 23) /* BDLE in 4k boundary */
558#define AZX_DCAPS_COUNT_LPIB_DELAY (1 << 25) /* Take LPIB as delay */ 558#define AZX_DCAPS_COUNT_LPIB_DELAY (1 << 25) /* Take LPIB as delay */
559#define AZX_DCAPS_PM_RUNTIME (1 << 26) /* runtime PM support */
560
561/* quirks for Intel PCH */
562#define AZX_DCAPS_INTEL_PCH \
563 (AZX_DCAPS_SCH_SNOOP | AZX_DCAPS_BUFSIZE | \
564 AZX_DCAPS_COUNT_LPIB_DELAY | AZX_DCAPS_PM_RUNTIME)
559 565
560/* quirks for ATI SB / AMD Hudson */ 566/* quirks for ATI SB / AMD Hudson */
561#define AZX_DCAPS_PRESET_ATI_SB \ 567#define AZX_DCAPS_PRESET_ATI_SB \
@@ -2433,6 +2439,9 @@ static void azx_power_notify(struct hda_bus *bus, bool power_up)
2433{ 2439{
2434 struct azx *chip = bus->private_data; 2440 struct azx *chip = bus->private_data;
2435 2441
2442 if (!(chip->driver_caps & AZX_DCAPS_PM_RUNTIME))
2443 return;
2444
2436 if (power_up) 2445 if (power_up)
2437 pm_runtime_get_sync(&chip->pci->dev); 2446 pm_runtime_get_sync(&chip->pci->dev);
2438 else 2447 else
@@ -2548,7 +2557,8 @@ static int azx_runtime_suspend(struct device *dev)
2548 struct snd_card *card = dev_get_drvdata(dev); 2557 struct snd_card *card = dev_get_drvdata(dev);
2549 struct azx *chip = card->private_data; 2558 struct azx *chip = card->private_data;
2550 2559
2551 if (!power_save_controller) 2560 if (!power_save_controller ||
2561 !(chip->driver_caps & AZX_DCAPS_PM_RUNTIME))
2552 return -EAGAIN; 2562 return -EAGAIN;
2553 2563
2554 azx_stop_chip(chip); 2564 azx_stop_chip(chip);
@@ -3429,39 +3439,30 @@ static void __devexit azx_remove(struct pci_dev *pci)
3429static DEFINE_PCI_DEVICE_TABLE(azx_ids) = { 3439static DEFINE_PCI_DEVICE_TABLE(azx_ids) = {
3430 /* CPT */ 3440 /* CPT */
3431 { PCI_DEVICE(0x8086, 0x1c20), 3441 { PCI_DEVICE(0x8086, 0x1c20),
3432 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_SCH_SNOOP | 3442 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH },
3433 AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY },
3434 /* PBG */ 3443 /* PBG */
3435 { PCI_DEVICE(0x8086, 0x1d20), 3444 { PCI_DEVICE(0x8086, 0x1d20),
3436 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_SCH_SNOOP | 3445 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH },
3437 AZX_DCAPS_BUFSIZE},
3438 /* Panther Point */ 3446 /* Panther Point */
3439 { PCI_DEVICE(0x8086, 0x1e20), 3447 { PCI_DEVICE(0x8086, 0x1e20),
3440 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_SCH_SNOOP | 3448 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH },
3441 AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY },
3442 /* Lynx Point */ 3449 /* Lynx Point */
3443 { PCI_DEVICE(0x8086, 0x8c20), 3450 { PCI_DEVICE(0x8086, 0x8c20),
3444 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_SCH_SNOOP | 3451 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH },
3445 AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY },
3446 /* Lynx Point-LP */ 3452 /* Lynx Point-LP */
3447 { PCI_DEVICE(0x8086, 0x9c20), 3453 { PCI_DEVICE(0x8086, 0x9c20),
3448 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_SCH_SNOOP | 3454 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH },
3449 AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY },
3450 /* Lynx Point-LP */ 3455 /* Lynx Point-LP */
3451 { PCI_DEVICE(0x8086, 0x9c21), 3456 { PCI_DEVICE(0x8086, 0x9c21),
3452 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_SCH_SNOOP | 3457 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH },
3453 AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY },
3454 /* Haswell */ 3458 /* Haswell */
3455 { PCI_DEVICE(0x8086, 0x0c0c), 3459 { PCI_DEVICE(0x8086, 0x0c0c),
3456 .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_SCH_SNOOP | 3460 .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH },
3457 AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY },
3458 { PCI_DEVICE(0x8086, 0x0d0c), 3461 { PCI_DEVICE(0x8086, 0x0d0c),
3459 .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_SCH_SNOOP | 3462 .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH },
3460 AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY },
3461 /* 5 Series/3400 */ 3463 /* 5 Series/3400 */
3462 { PCI_DEVICE(0x8086, 0x3b56), 3464 { PCI_DEVICE(0x8086, 0x3b56),
3463 .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_SCH_SNOOP | 3465 .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH },
3464 AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY },
3465 /* SCH */ 3466 /* SCH */
3466 { PCI_DEVICE(0x8086, 0x811b), 3467 { PCI_DEVICE(0x8086, 0x811b),
3467 .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_SCH_SNOOP | 3468 .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_SCH_SNOOP |
diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c
index d5f3a26d608d..3bcb67172358 100644
--- a/sound/pci/hda/patch_cirrus.c
+++ b/sound/pci/hda/patch_cirrus.c
@@ -466,6 +466,7 @@ static int parse_output(struct hda_codec *codec)
466 memcpy(cfg->speaker_pins, cfg->line_out_pins, 466 memcpy(cfg->speaker_pins, cfg->line_out_pins,
467 sizeof(cfg->speaker_pins)); 467 sizeof(cfg->speaker_pins));
468 cfg->line_outs = 0; 468 cfg->line_outs = 0;
469 memset(cfg->line_out_pins, 0, sizeof(cfg->line_out_pins));
469 } 470 }
470 471
471 return 0; 472 return 0;
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index c0ce3b1f04b4..ad68d223f8af 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -5407,6 +5407,7 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = {
5407 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF), 5407 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF),
5408 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF), 5408 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF),
5409 SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 5,1", ALC885_FIXUP_MACPRO_GPIO), 5409 SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 5,1", ALC885_FIXUP_MACPRO_GPIO),
5410 SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF),
5410 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF), 5411 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF),
5411 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF), 5412 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF),
5412 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF), 5413 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF),
@@ -7064,6 +7065,7 @@ static const struct hda_codec_preset snd_hda_preset_realtek[] = {
7064 { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 }, 7065 { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 },
7065 { .id = 0x10ec0283, .name = "ALC283", .patch = patch_alc269 }, 7066 { .id = 0x10ec0283, .name = "ALC283", .patch = patch_alc269 },
7066 { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 }, 7067 { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 },
7068 { .id = 0x10ec0292, .name = "ALC292", .patch = patch_alc269 },
7067 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", 7069 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
7068 .patch = patch_alc861 }, 7070 .patch = patch_alc861 },
7069 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, 7071 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
diff --git a/sound/soc/atmel/Kconfig b/sound/soc/atmel/Kconfig
index 72b09cfd3dc3..d1b691bf8e2d 100644
--- a/sound/soc/atmel/Kconfig
+++ b/sound/soc/atmel/Kconfig
@@ -6,6 +6,14 @@ config SND_ATMEL_SOC
6 the ATMEL SSC interface. You will also need 6 the ATMEL SSC interface. You will also need
7 to select the audio interfaces to support below. 7 to select the audio interfaces to support below.
8 8
9config SND_ATMEL_SOC_PDC
10 tristate
11 depends on SND_ATMEL_SOC
12
13config SND_ATMEL_SOC_DMA
14 tristate
15 depends on SND_ATMEL_SOC
16
9config SND_ATMEL_SOC_SSC 17config SND_ATMEL_SOC_SSC
10 tristate 18 tristate
11 depends on SND_ATMEL_SOC 19 depends on SND_ATMEL_SOC
@@ -16,8 +24,8 @@ config SND_ATMEL_SOC_SSC
16 24
17config SND_AT91_SOC_SAM9G20_WM8731 25config SND_AT91_SOC_SAM9G20_WM8731
18 tristate "SoC Audio support for WM8731-based At91sam9g20 evaluation board" 26 tristate "SoC Audio support for WM8731-based At91sam9g20 evaluation board"
19 depends on ATMEL_SSC && ARCH_AT91SAM9G20 && SND_ATMEL_SOC && \ 27 depends on ATMEL_SSC && SND_ATMEL_SOC && AT91_PROGRAMMABLE_CLOCKS
20 AT91_PROGRAMMABLE_CLOCKS 28 select SND_ATMEL_SOC_PDC
21 select SND_ATMEL_SOC_SSC 29 select SND_ATMEL_SOC_SSC
22 select SND_SOC_WM8731 30 select SND_SOC_WM8731
23 help 31 help
@@ -27,6 +35,7 @@ config SND_AT91_SOC_SAM9G20_WM8731
27config SND_AT91_SOC_AFEB9260 35config SND_AT91_SOC_AFEB9260
28 tristate "SoC Audio support for AFEB9260 board" 36 tristate "SoC Audio support for AFEB9260 board"
29 depends on ATMEL_SSC && ARCH_AT91 && MACH_AFEB9260 && SND_ATMEL_SOC 37 depends on ATMEL_SSC && ARCH_AT91 && MACH_AFEB9260 && SND_ATMEL_SOC
38 select SND_ATMEL_SOC_PDC
30 select SND_ATMEL_SOC_SSC 39 select SND_ATMEL_SOC_SSC
31 select SND_SOC_TLV320AIC23 40 select SND_SOC_TLV320AIC23
32 help 41 help
diff --git a/sound/soc/atmel/Makefile b/sound/soc/atmel/Makefile
index a5c0bf19da78..41967ccb6f41 100644
--- a/sound/soc/atmel/Makefile
+++ b/sound/soc/atmel/Makefile
@@ -1,8 +1,12 @@
1# AT91 Platform Support 1# AT91 Platform Support
2snd-soc-atmel-pcm-objs := atmel-pcm.o 2snd-soc-atmel-pcm-objs := atmel-pcm.o
3snd-soc-atmel-pcm-pdc-objs := atmel-pcm-pdc.o
4snd-soc-atmel-pcm-dma-objs := atmel-pcm-dma.o
3snd-soc-atmel_ssc_dai-objs := atmel_ssc_dai.o 5snd-soc-atmel_ssc_dai-objs := atmel_ssc_dai.o
4 6
5obj-$(CONFIG_SND_ATMEL_SOC) += snd-soc-atmel-pcm.o 7obj-$(CONFIG_SND_ATMEL_SOC) += snd-soc-atmel-pcm.o
8obj-$(CONFIG_SND_ATMEL_SOC_PDC) += snd-soc-atmel-pcm-pdc.o
9obj-$(CONFIG_SND_ATMEL_SOC_DMA) += snd-soc-atmel-pcm-dma.o
6obj-$(CONFIG_SND_ATMEL_SOC_SSC) += snd-soc-atmel_ssc_dai.o 10obj-$(CONFIG_SND_ATMEL_SOC_SSC) += snd-soc-atmel_ssc_dai.o
7 11
8# AT91 Machine Support 12# AT91 Machine Support
diff --git a/sound/soc/atmel/atmel-pcm-dma.c b/sound/soc/atmel/atmel-pcm-dma.c
new file mode 100644
index 000000000000..30184a4a147a
--- /dev/null
+++ b/sound/soc/atmel/atmel-pcm-dma.c
@@ -0,0 +1,240 @@
1/*
2 * atmel-pcm-dma.c -- ALSA PCM DMA support for the Atmel SoC.
3 *
4 * Copyright (C) 2012 Atmel
5 *
6 * Author: Bo Shen <voice.shen@atmel.com>
7 *
8 * Based on atmel-pcm by:
9 * Sedji Gaouaou <sedji.gaouaou@atmel.com>
10 * Copyright 2008 Atmel
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */
26
27#include <linux/module.h>
28#include <linux/init.h>
29#include <linux/platform_device.h>
30#include <linux/slab.h>
31#include <linux/dma-mapping.h>
32#include <linux/dmaengine.h>
33#include <linux/atmel-ssc.h>
34#include <linux/platform_data/dma-atmel.h>
35
36#include <sound/core.h>
37#include <sound/pcm.h>
38#include <sound/pcm_params.h>
39#include <sound/soc.h>
40#include <sound/dmaengine_pcm.h>
41
42#include "atmel-pcm.h"
43
44/*--------------------------------------------------------------------------*\
45 * Hardware definition
46\*--------------------------------------------------------------------------*/
47static const struct snd_pcm_hardware atmel_pcm_dma_hardware = {
48 .info = SNDRV_PCM_INFO_MMAP |
49 SNDRV_PCM_INFO_MMAP_VALID |
50 SNDRV_PCM_INFO_INTERLEAVED |
51 SNDRV_PCM_INFO_RESUME |
52 SNDRV_PCM_INFO_PAUSE,
53 .formats = SNDRV_PCM_FMTBIT_S16_LE,
54 .period_bytes_min = 256, /* lighting DMA overhead */
55 .period_bytes_max = 2 * 0xffff, /* if 2 bytes format */
56 .periods_min = 8,
57 .periods_max = 1024, /* no limit */
58 .buffer_bytes_max = ATMEL_SSC_DMABUF_SIZE,
59};
60
61/**
62 * atmel_pcm_dma_irq: SSC interrupt handler for DMAENGINE enabled SSC
63 *
64 * We use DMAENGINE to send/receive data to/from SSC so this ISR is only to
65 * check if any overrun occured.
66 */
67static void atmel_pcm_dma_irq(u32 ssc_sr,
68 struct snd_pcm_substream *substream)
69{
70 struct atmel_pcm_dma_params *prtd;
71
72 prtd = snd_dmaengine_pcm_get_data(substream);
73
74 if (ssc_sr & prtd->mask->ssc_error) {
75 if (snd_pcm_running(substream))
76 pr_warn("atmel-pcm: buffer %s on %s (SSC_SR=%#x)\n",
77 substream->stream == SNDRV_PCM_STREAM_PLAYBACK
78 ? "underrun" : "overrun", prtd->name,
79 ssc_sr);
80
81 /* stop RX and capture: will be enabled again at restart */
82 ssc_writex(prtd->ssc->regs, SSC_CR, prtd->mask->ssc_disable);
83 snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN);
84
85 /* now drain RHR and read status to remove xrun condition */
86 ssc_readx(prtd->ssc->regs, SSC_RHR);
87 ssc_readx(prtd->ssc->regs, SSC_SR);
88 }
89}
90
91/*--------------------------------------------------------------------------*\
92 * DMAENGINE operations
93\*--------------------------------------------------------------------------*/
94static bool filter(struct dma_chan *chan, void *slave)
95{
96 struct at_dma_slave *sl = slave;
97
98 if (sl->dma_dev == chan->device->dev) {
99 chan->private = sl;
100 return true;
101 } else {
102 return false;
103 }
104}
105
106static int atmel_pcm_configure_dma(struct snd_pcm_substream *substream,
107 struct snd_pcm_hw_params *params)
108{
109 struct atmel_pcm_dma_params *prtd;
110 struct ssc_device *ssc;
111 struct dma_chan *dma_chan;
112 struct dma_slave_config slave_config;
113 int ret;
114
115 prtd = snd_dmaengine_pcm_get_data(substream);
116 ssc = prtd->ssc;
117
118 ret = snd_hwparams_to_dma_slave_config(substream, params,
119 &slave_config);
120 if (ret) {
121 pr_err("atmel-pcm: hwparams to dma slave configure failed\n");
122 return ret;
123 }
124
125 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
126 slave_config.dst_addr = (dma_addr_t)ssc->phybase + SSC_THR;
127 slave_config.dst_maxburst = 1;
128 } else {
129 slave_config.src_addr = (dma_addr_t)ssc->phybase + SSC_RHR;
130 slave_config.src_maxburst = 1;
131 }
132
133 slave_config.device_fc = false;
134
135 dma_chan = snd_dmaengine_pcm_get_chan(substream);
136 if (dmaengine_slave_config(dma_chan, &slave_config)) {
137 pr_err("atmel-pcm: failed to configure dma channel\n");
138 ret = -EBUSY;
139 return ret;
140 }
141
142 return 0;
143}
144
145static int atmel_pcm_hw_params(struct snd_pcm_substream *substream,
146 struct snd_pcm_hw_params *params)
147{
148 struct snd_soc_pcm_runtime *rtd = substream->private_data;
149 struct atmel_pcm_dma_params *prtd;
150 struct ssc_device *ssc;
151 struct at_dma_slave *sdata = NULL;
152 int ret;
153
154 snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
155
156 prtd = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
157 ssc = prtd->ssc;
158 if (ssc->pdev)
159 sdata = ssc->pdev->dev.platform_data;
160
161 ret = snd_dmaengine_pcm_open(substream, filter, sdata);
162 if (ret) {
163 pr_err("atmel-pcm: dmaengine pcm open failed\n");
164 return -EINVAL;
165 }
166
167 snd_dmaengine_pcm_set_data(substream, prtd);
168
169 ret = atmel_pcm_configure_dma(substream, params);
170 if (ret) {
171 pr_err("atmel-pcm: failed to configure dmai\n");
172 goto err;
173 }
174
175 prtd->dma_intr_handler = atmel_pcm_dma_irq;
176
177 return 0;
178err:
179 snd_dmaengine_pcm_close(substream);
180 return ret;
181}
182
183static int atmel_pcm_dma_prepare(struct snd_pcm_substream *substream)
184{
185 struct atmel_pcm_dma_params *prtd;
186
187 prtd = snd_dmaengine_pcm_get_data(substream);
188
189 ssc_writex(prtd->ssc->regs, SSC_IER, prtd->mask->ssc_error);
190 ssc_writex(prtd->ssc->regs, SSC_CR, prtd->mask->ssc_enable);
191
192 return 0;
193}
194
195static int atmel_pcm_open(struct snd_pcm_substream *substream)
196{
197 snd_soc_set_runtime_hwparams(substream, &atmel_pcm_dma_hardware);
198
199 return 0;
200}
201
202static int atmel_pcm_close(struct snd_pcm_substream *substream)
203{
204 snd_dmaengine_pcm_close(substream);
205
206 return 0;
207}
208
209static struct snd_pcm_ops atmel_pcm_ops = {
210 .open = atmel_pcm_open,
211 .close = atmel_pcm_close,
212 .ioctl = snd_pcm_lib_ioctl,
213 .hw_params = atmel_pcm_hw_params,
214 .prepare = atmel_pcm_dma_prepare,
215 .trigger = snd_dmaengine_pcm_trigger,
216 .pointer = snd_dmaengine_pcm_pointer_no_residue,
217 .mmap = atmel_pcm_mmap,
218};
219
220static struct snd_soc_platform_driver atmel_soc_platform = {
221 .ops = &atmel_pcm_ops,
222 .pcm_new = atmel_pcm_new,
223 .pcm_free = atmel_pcm_free,
224};
225
226int atmel_pcm_dma_platform_register(struct device *dev)
227{
228 return snd_soc_register_platform(dev, &atmel_soc_platform);
229}
230EXPORT_SYMBOL(atmel_pcm_dma_platform_register);
231
232void atmel_pcm_dma_platform_unregister(struct device *dev)
233{
234 snd_soc_unregister_platform(dev);
235}
236EXPORT_SYMBOL(atmel_pcm_dma_platform_unregister);
237
238MODULE_AUTHOR("Bo Shen <voice.shen@atmel.com>");
239MODULE_DESCRIPTION("Atmel DMA based PCM module");
240MODULE_LICENSE("GPL");
diff --git a/sound/soc/atmel/atmel-pcm-pdc.c b/sound/soc/atmel/atmel-pcm-pdc.c
new file mode 100644
index 000000000000..6a293c713a38
--- /dev/null
+++ b/sound/soc/atmel/atmel-pcm-pdc.c
@@ -0,0 +1,401 @@
1/*
2 * atmel-pcm.c -- ALSA PCM interface for the Atmel atmel SoC.
3 *
4 * Copyright (C) 2005 SAN People
5 * Copyright (C) 2008 Atmel
6 *
7 * Authors: Sedji Gaouaou <sedji.gaouaou@atmel.com>
8 *
9 * Based on at91-pcm. by:
10 * Frank Mandarino <fmandarino@endrelia.com>
11 * Copyright 2006 Endrelia Technologies Inc.
12 *
13 * Based on pxa2xx-pcm.c by:
14 *
15 * Author: Nicolas Pitre
16 * Created: Nov 30, 2004
17 * Copyright: (C) 2004 MontaVista Software, Inc.
18 *
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
28 *
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 */
33
34#include <linux/module.h>
35#include <linux/init.h>
36#include <linux/platform_device.h>
37#include <linux/slab.h>
38#include <linux/dma-mapping.h>
39#include <linux/atmel_pdc.h>
40#include <linux/atmel-ssc.h>
41
42#include <sound/core.h>
43#include <sound/pcm.h>
44#include <sound/pcm_params.h>
45#include <sound/soc.h>
46
47#include "atmel-pcm.h"
48
49
50/*--------------------------------------------------------------------------*\
51 * Hardware definition
52\*--------------------------------------------------------------------------*/
53/* TODO: These values were taken from the AT91 platform driver, check
54 * them against real values for AT32
55 */
56static const struct snd_pcm_hardware atmel_pcm_hardware = {
57 .info = SNDRV_PCM_INFO_MMAP |
58 SNDRV_PCM_INFO_MMAP_VALID |
59 SNDRV_PCM_INFO_INTERLEAVED |
60 SNDRV_PCM_INFO_PAUSE,
61 .formats = SNDRV_PCM_FMTBIT_S16_LE,
62 .period_bytes_min = 32,
63 .period_bytes_max = 8192,
64 .periods_min = 2,
65 .periods_max = 1024,
66 .buffer_bytes_max = ATMEL_SSC_DMABUF_SIZE,
67};
68
69
70/*--------------------------------------------------------------------------*\
71 * Data types
72\*--------------------------------------------------------------------------*/
73struct atmel_runtime_data {
74 struct atmel_pcm_dma_params *params;
75 dma_addr_t dma_buffer; /* physical address of dma buffer */
76 dma_addr_t dma_buffer_end; /* first address beyond DMA buffer */
77 size_t period_size;
78
79 dma_addr_t period_ptr; /* physical address of next period */
80
81 /* PDC register save */
82 u32 pdc_xpr_save;
83 u32 pdc_xcr_save;
84 u32 pdc_xnpr_save;
85 u32 pdc_xncr_save;
86};
87
88/*--------------------------------------------------------------------------*\
89 * ISR
90\*--------------------------------------------------------------------------*/
91static void atmel_pcm_dma_irq(u32 ssc_sr,
92 struct snd_pcm_substream *substream)
93{
94 struct atmel_runtime_data *prtd = substream->runtime->private_data;
95 struct atmel_pcm_dma_params *params = prtd->params;
96 static int count;
97
98 count++;
99
100 if (ssc_sr & params->mask->ssc_endbuf) {
101 pr_warn("atmel-pcm: buffer %s on %s (SSC_SR=%#x, count=%d)\n",
102 substream->stream == SNDRV_PCM_STREAM_PLAYBACK
103 ? "underrun" : "overrun",
104 params->name, ssc_sr, count);
105
106 /* re-start the PDC */
107 ssc_writex(params->ssc->regs, ATMEL_PDC_PTCR,
108 params->mask->pdc_disable);
109 prtd->period_ptr += prtd->period_size;
110 if (prtd->period_ptr >= prtd->dma_buffer_end)
111 prtd->period_ptr = prtd->dma_buffer;
112
113 ssc_writex(params->ssc->regs, params->pdc->xpr,
114 prtd->period_ptr);
115 ssc_writex(params->ssc->regs, params->pdc->xcr,
116 prtd->period_size / params->pdc_xfer_size);
117 ssc_writex(params->ssc->regs, ATMEL_PDC_PTCR,
118 params->mask->pdc_enable);
119 }
120
121 if (ssc_sr & params->mask->ssc_endx) {
122 /* Load the PDC next pointer and counter registers */
123 prtd->period_ptr += prtd->period_size;
124 if (prtd->period_ptr >= prtd->dma_buffer_end)
125 prtd->period_ptr = prtd->dma_buffer;
126
127 ssc_writex(params->ssc->regs, params->pdc->xnpr,
128 prtd->period_ptr);
129 ssc_writex(params->ssc->regs, params->pdc->xncr,
130 prtd->period_size / params->pdc_xfer_size);
131 }
132
133 snd_pcm_period_elapsed(substream);
134}
135
136
137/*--------------------------------------------------------------------------*\
138 * PCM operations
139\*--------------------------------------------------------------------------*/
140static int atmel_pcm_hw_params(struct snd_pcm_substream *substream,
141 struct snd_pcm_hw_params *params)
142{
143 struct snd_pcm_runtime *runtime = substream->runtime;
144 struct atmel_runtime_data *prtd = runtime->private_data;
145 struct snd_soc_pcm_runtime *rtd = substream->private_data;
146
147 /* this may get called several times by oss emulation
148 * with different params */
149
150 snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
151 runtime->dma_bytes = params_buffer_bytes(params);
152
153 prtd->params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
154 prtd->params->dma_intr_handler = atmel_pcm_dma_irq;
155
156 prtd->dma_buffer = runtime->dma_addr;
157 prtd->dma_buffer_end = runtime->dma_addr + runtime->dma_bytes;
158 prtd->period_size = params_period_bytes(params);
159
160 pr_debug("atmel-pcm: "
161 "hw_params: DMA for %s initialized "
162 "(dma_bytes=%u, period_size=%u)\n",
163 prtd->params->name,
164 runtime->dma_bytes,
165 prtd->period_size);
166 return 0;
167}
168
169static int atmel_pcm_hw_free(struct snd_pcm_substream *substream)
170{
171 struct atmel_runtime_data *prtd = substream->runtime->private_data;
172 struct atmel_pcm_dma_params *params = prtd->params;
173
174 if (params != NULL) {
175 ssc_writex(params->ssc->regs, SSC_PDC_PTCR,
176 params->mask->pdc_disable);
177 prtd->params->dma_intr_handler = NULL;
178 }
179
180 return 0;
181}
182
183static int atmel_pcm_prepare(struct snd_pcm_substream *substream)
184{
185 struct atmel_runtime_data *prtd = substream->runtime->private_data;
186 struct atmel_pcm_dma_params *params = prtd->params;
187
188 ssc_writex(params->ssc->regs, SSC_IDR,
189 params->mask->ssc_endx | params->mask->ssc_endbuf);
190 ssc_writex(params->ssc->regs, ATMEL_PDC_PTCR,
191 params->mask->pdc_disable);
192 return 0;
193}
194
195static int atmel_pcm_trigger(struct snd_pcm_substream *substream,
196 int cmd)
197{
198 struct snd_pcm_runtime *rtd = substream->runtime;
199 struct atmel_runtime_data *prtd = rtd->private_data;
200 struct atmel_pcm_dma_params *params = prtd->params;
201 int ret = 0;
202
203 pr_debug("atmel-pcm:buffer_size = %ld,"
204 "dma_area = %p, dma_bytes = %u\n",
205 rtd->buffer_size, rtd->dma_area, rtd->dma_bytes);
206
207 switch (cmd) {
208 case SNDRV_PCM_TRIGGER_START:
209 prtd->period_ptr = prtd->dma_buffer;
210
211 ssc_writex(params->ssc->regs, params->pdc->xpr,
212 prtd->period_ptr);
213 ssc_writex(params->ssc->regs, params->pdc->xcr,
214 prtd->period_size / params->pdc_xfer_size);
215
216 prtd->period_ptr += prtd->period_size;
217 ssc_writex(params->ssc->regs, params->pdc->xnpr,
218 prtd->period_ptr);
219 ssc_writex(params->ssc->regs, params->pdc->xncr,
220 prtd->period_size / params->pdc_xfer_size);
221
222 pr_debug("atmel-pcm: trigger: "
223 "period_ptr=%lx, xpr=%u, "
224 "xcr=%u, xnpr=%u, xncr=%u\n",
225 (unsigned long)prtd->period_ptr,
226 ssc_readx(params->ssc->regs, params->pdc->xpr),
227 ssc_readx(params->ssc->regs, params->pdc->xcr),
228 ssc_readx(params->ssc->regs, params->pdc->xnpr),
229 ssc_readx(params->ssc->regs, params->pdc->xncr));
230
231 ssc_writex(params->ssc->regs, SSC_IER,
232 params->mask->ssc_endx | params->mask->ssc_endbuf);
233 ssc_writex(params->ssc->regs, SSC_PDC_PTCR,
234 params->mask->pdc_enable);
235
236 pr_debug("sr=%u imr=%u\n",
237 ssc_readx(params->ssc->regs, SSC_SR),
238 ssc_readx(params->ssc->regs, SSC_IER));
239 break; /* SNDRV_PCM_TRIGGER_START */
240
241 case SNDRV_PCM_TRIGGER_STOP:
242 case SNDRV_PCM_TRIGGER_SUSPEND:
243 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
244 ssc_writex(params->ssc->regs, ATMEL_PDC_PTCR,
245 params->mask->pdc_disable);
246 break;
247
248 case SNDRV_PCM_TRIGGER_RESUME:
249 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
250 ssc_writex(params->ssc->regs, ATMEL_PDC_PTCR,
251 params->mask->pdc_enable);
252 break;
253
254 default:
255 ret = -EINVAL;
256 }
257
258 return ret;
259}
260
261static snd_pcm_uframes_t atmel_pcm_pointer(
262 struct snd_pcm_substream *substream)
263{
264 struct snd_pcm_runtime *runtime = substream->runtime;
265 struct atmel_runtime_data *prtd = runtime->private_data;
266 struct atmel_pcm_dma_params *params = prtd->params;
267 dma_addr_t ptr;
268 snd_pcm_uframes_t x;
269
270 ptr = (dma_addr_t) ssc_readx(params->ssc->regs, params->pdc->xpr);
271 x = bytes_to_frames(runtime, ptr - prtd->dma_buffer);
272
273 if (x == runtime->buffer_size)
274 x = 0;
275
276 return x;
277}
278
279static int atmel_pcm_open(struct snd_pcm_substream *substream)
280{
281 struct snd_pcm_runtime *runtime = substream->runtime;
282 struct atmel_runtime_data *prtd;
283 int ret = 0;
284
285 snd_soc_set_runtime_hwparams(substream, &atmel_pcm_hardware);
286
287 /* ensure that buffer size is a multiple of period size */
288 ret = snd_pcm_hw_constraint_integer(runtime,
289 SNDRV_PCM_HW_PARAM_PERIODS);
290 if (ret < 0)
291 goto out;
292
293 prtd = kzalloc(sizeof(struct atmel_runtime_data), GFP_KERNEL);
294 if (prtd == NULL) {
295 ret = -ENOMEM;
296 goto out;
297 }
298 runtime->private_data = prtd;
299
300 out:
301 return ret;
302}
303
304static int atmel_pcm_close(struct snd_pcm_substream *substream)
305{
306 struct atmel_runtime_data *prtd = substream->runtime->private_data;
307
308 kfree(prtd);
309 return 0;
310}
311
312static struct snd_pcm_ops atmel_pcm_ops = {
313 .open = atmel_pcm_open,
314 .close = atmel_pcm_close,
315 .ioctl = snd_pcm_lib_ioctl,
316 .hw_params = atmel_pcm_hw_params,
317 .hw_free = atmel_pcm_hw_free,
318 .prepare = atmel_pcm_prepare,
319 .trigger = atmel_pcm_trigger,
320 .pointer = atmel_pcm_pointer,
321 .mmap = atmel_pcm_mmap,
322};
323
324
325/*--------------------------------------------------------------------------*\
326 * ASoC platform driver
327\*--------------------------------------------------------------------------*/
328#ifdef CONFIG_PM
329static int atmel_pcm_suspend(struct snd_soc_dai *dai)
330{
331 struct snd_pcm_runtime *runtime = dai->runtime;
332 struct atmel_runtime_data *prtd;
333 struct atmel_pcm_dma_params *params;
334
335 if (!runtime)
336 return 0;
337
338 prtd = runtime->private_data;
339 params = prtd->params;
340
341 /* disable the PDC and save the PDC registers */
342
343 ssc_writel(params->ssc->regs, PDC_PTCR, params->mask->pdc_disable);
344
345 prtd->pdc_xpr_save = ssc_readx(params->ssc->regs, params->pdc->xpr);
346 prtd->pdc_xcr_save = ssc_readx(params->ssc->regs, params->pdc->xcr);
347 prtd->pdc_xnpr_save = ssc_readx(params->ssc->regs, params->pdc->xnpr);
348 prtd->pdc_xncr_save = ssc_readx(params->ssc->regs, params->pdc->xncr);
349
350 return 0;
351}
352
353static int atmel_pcm_resume(struct snd_soc_dai *dai)
354{
355 struct snd_pcm_runtime *runtime = dai->runtime;
356 struct atmel_runtime_data *prtd;
357 struct atmel_pcm_dma_params *params;
358
359 if (!runtime)
360 return 0;
361
362 prtd = runtime->private_data;
363 params = prtd->params;
364
365 /* restore the PDC registers and enable the PDC */
366 ssc_writex(params->ssc->regs, params->pdc->xpr, prtd->pdc_xpr_save);
367 ssc_writex(params->ssc->regs, params->pdc->xcr, prtd->pdc_xcr_save);
368 ssc_writex(params->ssc->regs, params->pdc->xnpr, prtd->pdc_xnpr_save);
369 ssc_writex(params->ssc->regs, params->pdc->xncr, prtd->pdc_xncr_save);
370
371 ssc_writel(params->ssc->regs, PDC_PTCR, params->mask->pdc_enable);
372 return 0;
373}
374#else
375#define atmel_pcm_suspend NULL
376#define atmel_pcm_resume NULL
377#endif
378
379static struct snd_soc_platform_driver atmel_soc_platform = {
380 .ops = &atmel_pcm_ops,
381 .pcm_new = atmel_pcm_new,
382 .pcm_free = atmel_pcm_free,
383 .suspend = atmel_pcm_suspend,
384 .resume = atmel_pcm_resume,
385};
386
387int atmel_pcm_pdc_platform_register(struct device *dev)
388{
389 return snd_soc_register_platform(dev, &atmel_soc_platform);
390}
391EXPORT_SYMBOL(atmel_pcm_pdc_platform_register);
392
393void atmel_pcm_pdc_platform_unregister(struct device *dev)
394{
395 snd_soc_unregister_platform(dev);
396}
397EXPORT_SYMBOL(atmel_pcm_pdc_platform_unregister);
398
399MODULE_AUTHOR("Sedji Gaouaou <sedji.gaouaou@atmel.com>");
400MODULE_DESCRIPTION("Atmel PCM module");
401MODULE_LICENSE("GPL");
diff --git a/sound/soc/atmel/atmel-pcm.c b/sound/soc/atmel/atmel-pcm.c
index 9b84f985770e..e99f1811300a 100644
--- a/sound/soc/atmel/atmel-pcm.c
+++ b/sound/soc/atmel/atmel-pcm.c
@@ -32,80 +32,25 @@
32 */ 32 */
33 33
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/init.h>
36#include <linux/platform_device.h>
37#include <linux/slab.h>
38#include <linux/dma-mapping.h> 35#include <linux/dma-mapping.h>
39#include <linux/atmel_pdc.h>
40#include <linux/atmel-ssc.h>
41
42#include <sound/core.h>
43#include <sound/pcm.h> 36#include <sound/pcm.h>
44#include <sound/pcm_params.h>
45#include <sound/soc.h> 37#include <sound/soc.h>
46
47#include "atmel-pcm.h" 38#include "atmel-pcm.h"
48 39
49
50/*--------------------------------------------------------------------------*\
51 * Hardware definition
52\*--------------------------------------------------------------------------*/
53/* TODO: These values were taken from the AT91 platform driver, check
54 * them against real values for AT32
55 */
56static const struct snd_pcm_hardware atmel_pcm_hardware = {
57 .info = SNDRV_PCM_INFO_MMAP |
58 SNDRV_PCM_INFO_MMAP_VALID |
59 SNDRV_PCM_INFO_INTERLEAVED |
60 SNDRV_PCM_INFO_PAUSE,
61 .formats = SNDRV_PCM_FMTBIT_S16_LE,
62 .period_bytes_min = 32,
63 .period_bytes_max = 8192,
64 .periods_min = 2,
65 .periods_max = 1024,
66 .buffer_bytes_max = 32 * 1024,
67};
68
69
70/*--------------------------------------------------------------------------*\
71 * Data types
72\*--------------------------------------------------------------------------*/
73struct atmel_runtime_data {
74 struct atmel_pcm_dma_params *params;
75 dma_addr_t dma_buffer; /* physical address of dma buffer */
76 dma_addr_t dma_buffer_end; /* first address beyond DMA buffer */
77 size_t period_size;
78
79 dma_addr_t period_ptr; /* physical address of next period */
80
81 /* PDC register save */
82 u32 pdc_xpr_save;
83 u32 pdc_xcr_save;
84 u32 pdc_xnpr_save;
85 u32 pdc_xncr_save;
86};
87
88
89/*--------------------------------------------------------------------------*\
90 * Helper functions
91\*--------------------------------------------------------------------------*/
92static int atmel_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, 40static int atmel_pcm_preallocate_dma_buffer(struct snd_pcm *pcm,
93 int stream) 41 int stream)
94{ 42{
95 struct snd_pcm_substream *substream = pcm->streams[stream].substream; 43 struct snd_pcm_substream *substream = pcm->streams[stream].substream;
96 struct snd_dma_buffer *buf = &substream->dma_buffer; 44 struct snd_dma_buffer *buf = &substream->dma_buffer;
97 size_t size = atmel_pcm_hardware.buffer_bytes_max; 45 size_t size = ATMEL_SSC_DMABUF_SIZE;
98 46
99 buf->dev.type = SNDRV_DMA_TYPE_DEV; 47 buf->dev.type = SNDRV_DMA_TYPE_DEV;
100 buf->dev.dev = pcm->card->dev; 48 buf->dev.dev = pcm->card->dev;
101 buf->private_data = NULL; 49 buf->private_data = NULL;
102 buf->area = dma_alloc_coherent(pcm->card->dev, size, 50 buf->area = dma_alloc_coherent(pcm->card->dev, size,
103 &buf->addr, GFP_KERNEL); 51 &buf->addr, GFP_KERNEL);
104 pr_debug("atmel-pcm:" 52 pr_debug("atmel-pcm: alloc dma buffer: area=%p, addr=%p, size=%d\n",
105 "preallocate_dma_buffer: area=%p, addr=%p, size=%d\n", 53 (void *)buf->area, (void *)buf->addr, size);
106 (void *) buf->area,
107 (void *) buf->addr,
108 size);
109 54
110 if (!buf->area) 55 if (!buf->area)
111 return -ENOMEM; 56 return -ENOMEM;
@@ -113,258 +58,19 @@ static int atmel_pcm_preallocate_dma_buffer(struct snd_pcm *pcm,
113 buf->bytes = size; 58 buf->bytes = size;
114 return 0; 59 return 0;
115} 60}
116/*--------------------------------------------------------------------------*\
117 * ISR
118\*--------------------------------------------------------------------------*/
119static void atmel_pcm_dma_irq(u32 ssc_sr,
120 struct snd_pcm_substream *substream)
121{
122 struct atmel_runtime_data *prtd = substream->runtime->private_data;
123 struct atmel_pcm_dma_params *params = prtd->params;
124 static int count;
125
126 count++;
127
128 if (ssc_sr & params->mask->ssc_endbuf) {
129 pr_warning("atmel-pcm: buffer %s on %s"
130 " (SSC_SR=%#x, count=%d)\n",
131 substream->stream == SNDRV_PCM_STREAM_PLAYBACK
132 ? "underrun" : "overrun",
133 params->name, ssc_sr, count);
134
135 /* re-start the PDC */
136 ssc_writex(params->ssc->regs, ATMEL_PDC_PTCR,
137 params->mask->pdc_disable);
138 prtd->period_ptr += prtd->period_size;
139 if (prtd->period_ptr >= prtd->dma_buffer_end)
140 prtd->period_ptr = prtd->dma_buffer;
141
142 ssc_writex(params->ssc->regs, params->pdc->xpr,
143 prtd->period_ptr);
144 ssc_writex(params->ssc->regs, params->pdc->xcr,
145 prtd->period_size / params->pdc_xfer_size);
146 ssc_writex(params->ssc->regs, ATMEL_PDC_PTCR,
147 params->mask->pdc_enable);
148 }
149
150 if (ssc_sr & params->mask->ssc_endx) {
151 /* Load the PDC next pointer and counter registers */
152 prtd->period_ptr += prtd->period_size;
153 if (prtd->period_ptr >= prtd->dma_buffer_end)
154 prtd->period_ptr = prtd->dma_buffer;
155
156 ssc_writex(params->ssc->regs, params->pdc->xnpr,
157 prtd->period_ptr);
158 ssc_writex(params->ssc->regs, params->pdc->xncr,
159 prtd->period_size / params->pdc_xfer_size);
160 }
161
162 snd_pcm_period_elapsed(substream);
163}
164
165
166/*--------------------------------------------------------------------------*\
167 * PCM operations
168\*--------------------------------------------------------------------------*/
169static int atmel_pcm_hw_params(struct snd_pcm_substream *substream,
170 struct snd_pcm_hw_params *params)
171{
172 struct snd_pcm_runtime *runtime = substream->runtime;
173 struct atmel_runtime_data *prtd = runtime->private_data;
174 struct snd_soc_pcm_runtime *rtd = substream->private_data;
175
176 /* this may get called several times by oss emulation
177 * with different params */
178
179 snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
180 runtime->dma_bytes = params_buffer_bytes(params);
181
182 prtd->params = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
183 prtd->params->dma_intr_handler = atmel_pcm_dma_irq;
184
185 prtd->dma_buffer = runtime->dma_addr;
186 prtd->dma_buffer_end = runtime->dma_addr + runtime->dma_bytes;
187 prtd->period_size = params_period_bytes(params);
188
189 pr_debug("atmel-pcm: "
190 "hw_params: DMA for %s initialized "
191 "(dma_bytes=%u, period_size=%u)\n",
192 prtd->params->name,
193 runtime->dma_bytes,
194 prtd->period_size);
195 return 0;
196}
197
198static int atmel_pcm_hw_free(struct snd_pcm_substream *substream)
199{
200 struct atmel_runtime_data *prtd = substream->runtime->private_data;
201 struct atmel_pcm_dma_params *params = prtd->params;
202
203 if (params != NULL) {
204 ssc_writex(params->ssc->regs, SSC_PDC_PTCR,
205 params->mask->pdc_disable);
206 prtd->params->dma_intr_handler = NULL;
207 }
208
209 return 0;
210}
211
212static int atmel_pcm_prepare(struct snd_pcm_substream *substream)
213{
214 struct atmel_runtime_data *prtd = substream->runtime->private_data;
215 struct atmel_pcm_dma_params *params = prtd->params;
216
217 ssc_writex(params->ssc->regs, SSC_IDR,
218 params->mask->ssc_endx | params->mask->ssc_endbuf);
219 ssc_writex(params->ssc->regs, ATMEL_PDC_PTCR,
220 params->mask->pdc_disable);
221 return 0;
222}
223
224static int atmel_pcm_trigger(struct snd_pcm_substream *substream,
225 int cmd)
226{
227 struct snd_pcm_runtime *rtd = substream->runtime;
228 struct atmel_runtime_data *prtd = rtd->private_data;
229 struct atmel_pcm_dma_params *params = prtd->params;
230 int ret = 0;
231
232 pr_debug("atmel-pcm:buffer_size = %ld,"
233 "dma_area = %p, dma_bytes = %u\n",
234 rtd->buffer_size, rtd->dma_area, rtd->dma_bytes);
235
236 switch (cmd) {
237 case SNDRV_PCM_TRIGGER_START:
238 prtd->period_ptr = prtd->dma_buffer;
239
240 ssc_writex(params->ssc->regs, params->pdc->xpr,
241 prtd->period_ptr);
242 ssc_writex(params->ssc->regs, params->pdc->xcr,
243 prtd->period_size / params->pdc_xfer_size);
244
245 prtd->period_ptr += prtd->period_size;
246 ssc_writex(params->ssc->regs, params->pdc->xnpr,
247 prtd->period_ptr);
248 ssc_writex(params->ssc->regs, params->pdc->xncr,
249 prtd->period_size / params->pdc_xfer_size);
250
251 pr_debug("atmel-pcm: trigger: "
252 "period_ptr=%lx, xpr=%u, "
253 "xcr=%u, xnpr=%u, xncr=%u\n",
254 (unsigned long)prtd->period_ptr,
255 ssc_readx(params->ssc->regs, params->pdc->xpr),
256 ssc_readx(params->ssc->regs, params->pdc->xcr),
257 ssc_readx(params->ssc->regs, params->pdc->xnpr),
258 ssc_readx(params->ssc->regs, params->pdc->xncr));
259
260 ssc_writex(params->ssc->regs, SSC_IER,
261 params->mask->ssc_endx | params->mask->ssc_endbuf);
262 ssc_writex(params->ssc->regs, SSC_PDC_PTCR,
263 params->mask->pdc_enable);
264
265 pr_debug("sr=%u imr=%u\n",
266 ssc_readx(params->ssc->regs, SSC_SR),
267 ssc_readx(params->ssc->regs, SSC_IER));
268 break; /* SNDRV_PCM_TRIGGER_START */
269
270 case SNDRV_PCM_TRIGGER_STOP:
271 case SNDRV_PCM_TRIGGER_SUSPEND:
272 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
273 ssc_writex(params->ssc->regs, ATMEL_PDC_PTCR,
274 params->mask->pdc_disable);
275 break;
276
277 case SNDRV_PCM_TRIGGER_RESUME:
278 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
279 ssc_writex(params->ssc->regs, ATMEL_PDC_PTCR,
280 params->mask->pdc_enable);
281 break;
282
283 default:
284 ret = -EINVAL;
285 }
286 61
287 return ret; 62int atmel_pcm_mmap(struct snd_pcm_substream *substream,
288}
289
290static snd_pcm_uframes_t atmel_pcm_pointer(
291 struct snd_pcm_substream *substream)
292{
293 struct snd_pcm_runtime *runtime = substream->runtime;
294 struct atmel_runtime_data *prtd = runtime->private_data;
295 struct atmel_pcm_dma_params *params = prtd->params;
296 dma_addr_t ptr;
297 snd_pcm_uframes_t x;
298
299 ptr = (dma_addr_t) ssc_readx(params->ssc->regs, params->pdc->xpr);
300 x = bytes_to_frames(runtime, ptr - prtd->dma_buffer);
301
302 if (x == runtime->buffer_size)
303 x = 0;
304
305 return x;
306}
307
308static int atmel_pcm_open(struct snd_pcm_substream *substream)
309{
310 struct snd_pcm_runtime *runtime = substream->runtime;
311 struct atmel_runtime_data *prtd;
312 int ret = 0;
313
314 snd_soc_set_runtime_hwparams(substream, &atmel_pcm_hardware);
315
316 /* ensure that buffer size is a multiple of period size */
317 ret = snd_pcm_hw_constraint_integer(runtime,
318 SNDRV_PCM_HW_PARAM_PERIODS);
319 if (ret < 0)
320 goto out;
321
322 prtd = kzalloc(sizeof(struct atmel_runtime_data), GFP_KERNEL);
323 if (prtd == NULL) {
324 ret = -ENOMEM;
325 goto out;
326 }
327 runtime->private_data = prtd;
328
329 out:
330 return ret;
331}
332
333static int atmel_pcm_close(struct snd_pcm_substream *substream)
334{
335 struct atmel_runtime_data *prtd = substream->runtime->private_data;
336
337 kfree(prtd);
338 return 0;
339}
340
341static int atmel_pcm_mmap(struct snd_pcm_substream *substream,
342 struct vm_area_struct *vma) 63 struct vm_area_struct *vma)
343{ 64{
344 return remap_pfn_range(vma, vma->vm_start, 65 return remap_pfn_range(vma, vma->vm_start,
345 substream->dma_buffer.addr >> PAGE_SHIFT, 66 substream->dma_buffer.addr >> PAGE_SHIFT,
346 vma->vm_end - vma->vm_start, vma->vm_page_prot); 67 vma->vm_end - vma->vm_start, vma->vm_page_prot);
347} 68}
69EXPORT_SYMBOL_GPL(atmel_pcm_mmap);
348 70
349static struct snd_pcm_ops atmel_pcm_ops = {
350 .open = atmel_pcm_open,
351 .close = atmel_pcm_close,
352 .ioctl = snd_pcm_lib_ioctl,
353 .hw_params = atmel_pcm_hw_params,
354 .hw_free = atmel_pcm_hw_free,
355 .prepare = atmel_pcm_prepare,
356 .trigger = atmel_pcm_trigger,
357 .pointer = atmel_pcm_pointer,
358 .mmap = atmel_pcm_mmap,
359};
360
361
362/*--------------------------------------------------------------------------*\
363 * ASoC platform driver
364\*--------------------------------------------------------------------------*/
365static u64 atmel_pcm_dmamask = DMA_BIT_MASK(32); 71static u64 atmel_pcm_dmamask = DMA_BIT_MASK(32);
366 72
367static int atmel_pcm_new(struct snd_soc_pcm_runtime *rtd) 73int atmel_pcm_new(struct snd_soc_pcm_runtime *rtd)
368{ 74{
369 struct snd_card *card = rtd->card->snd_card; 75 struct snd_card *card = rtd->card->snd_card;
370 struct snd_pcm *pcm = rtd->pcm; 76 struct snd_pcm *pcm = rtd->pcm;
@@ -376,6 +82,7 @@ static int atmel_pcm_new(struct snd_soc_pcm_runtime *rtd)
376 card->dev->coherent_dma_mask = DMA_BIT_MASK(32); 82 card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
377 83
378 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { 84 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
85 pr_debug("atmel-pcm: allocating PCM playback DMA buffer\n");
379 ret = atmel_pcm_preallocate_dma_buffer(pcm, 86 ret = atmel_pcm_preallocate_dma_buffer(pcm,
380 SNDRV_PCM_STREAM_PLAYBACK); 87 SNDRV_PCM_STREAM_PLAYBACK);
381 if (ret) 88 if (ret)
@@ -383,8 +90,7 @@ static int atmel_pcm_new(struct snd_soc_pcm_runtime *rtd)
383 } 90 }
384 91
385 if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { 92 if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) {
386 pr_debug("atmel-pcm:" 93 pr_debug("atmel-pcm: allocating PCM capture DMA buffer\n");
387 "Allocating PCM capture DMA buffer\n");
388 ret = atmel_pcm_preallocate_dma_buffer(pcm, 94 ret = atmel_pcm_preallocate_dma_buffer(pcm,
389 SNDRV_PCM_STREAM_CAPTURE); 95 SNDRV_PCM_STREAM_CAPTURE);
390 if (ret) 96 if (ret)
@@ -393,8 +99,9 @@ static int atmel_pcm_new(struct snd_soc_pcm_runtime *rtd)
393 out: 99 out:
394 return ret; 100 return ret;
395} 101}
102EXPORT_SYMBOL_GPL(atmel_pcm_new);
396 103
397static void atmel_pcm_free_dma_buffers(struct snd_pcm *pcm) 104void atmel_pcm_free(struct snd_pcm *pcm)
398{ 105{
399 struct snd_pcm_substream *substream; 106 struct snd_pcm_substream *substream;
400 struct snd_dma_buffer *buf; 107 struct snd_dma_buffer *buf;
@@ -413,89 +120,5 @@ static void atmel_pcm_free_dma_buffers(struct snd_pcm *pcm)
413 buf->area = NULL; 120 buf->area = NULL;
414 } 121 }
415} 122}
123EXPORT_SYMBOL_GPL(atmel_pcm_free);
416 124
417#ifdef CONFIG_PM
418static int atmel_pcm_suspend(struct snd_soc_dai *dai)
419{
420 struct snd_pcm_runtime *runtime = dai->runtime;
421 struct atmel_runtime_data *prtd;
422 struct atmel_pcm_dma_params *params;
423
424 if (!runtime)
425 return 0;
426
427 prtd = runtime->private_data;
428 params = prtd->params;
429
430 /* disable the PDC and save the PDC registers */
431
432 ssc_writel(params->ssc->regs, PDC_PTCR, params->mask->pdc_disable);
433
434 prtd->pdc_xpr_save = ssc_readx(params->ssc->regs, params->pdc->xpr);
435 prtd->pdc_xcr_save = ssc_readx(params->ssc->regs, params->pdc->xcr);
436 prtd->pdc_xnpr_save = ssc_readx(params->ssc->regs, params->pdc->xnpr);
437 prtd->pdc_xncr_save = ssc_readx(params->ssc->regs, params->pdc->xncr);
438
439 return 0;
440}
441
442static int atmel_pcm_resume(struct snd_soc_dai *dai)
443{
444 struct snd_pcm_runtime *runtime = dai->runtime;
445 struct atmel_runtime_data *prtd;
446 struct atmel_pcm_dma_params *params;
447
448 if (!runtime)
449 return 0;
450
451 prtd = runtime->private_data;
452 params = prtd->params;
453
454 /* restore the PDC registers and enable the PDC */
455 ssc_writex(params->ssc->regs, params->pdc->xpr, prtd->pdc_xpr_save);
456 ssc_writex(params->ssc->regs, params->pdc->xcr, prtd->pdc_xcr_save);
457 ssc_writex(params->ssc->regs, params->pdc->xnpr, prtd->pdc_xnpr_save);
458 ssc_writex(params->ssc->regs, params->pdc->xncr, prtd->pdc_xncr_save);
459
460 ssc_writel(params->ssc->regs, PDC_PTCR, params->mask->pdc_enable);
461 return 0;
462}
463#else
464#define atmel_pcm_suspend NULL
465#define atmel_pcm_resume NULL
466#endif
467
468static struct snd_soc_platform_driver atmel_soc_platform = {
469 .ops = &atmel_pcm_ops,
470 .pcm_new = atmel_pcm_new,
471 .pcm_free = atmel_pcm_free_dma_buffers,
472 .suspend = atmel_pcm_suspend,
473 .resume = atmel_pcm_resume,
474};
475
476static int __devinit atmel_soc_platform_probe(struct platform_device *pdev)
477{
478 return snd_soc_register_platform(&pdev->dev, &atmel_soc_platform);
479}
480
481static int __devexit atmel_soc_platform_remove(struct platform_device *pdev)
482{
483 snd_soc_unregister_platform(&pdev->dev);
484 return 0;
485}
486
487static struct platform_driver atmel_pcm_driver = {
488 .driver = {
489 .name = "atmel-pcm-audio",
490 .owner = THIS_MODULE,
491 },
492
493 .probe = atmel_soc_platform_probe,
494 .remove = __devexit_p(atmel_soc_platform_remove),
495};
496
497module_platform_driver(atmel_pcm_driver);
498
499MODULE_AUTHOR("Sedji Gaouaou <sedji.gaouaou@atmel.com>");
500MODULE_DESCRIPTION("Atmel PCM module");
501MODULE_LICENSE("GPL");
diff --git a/sound/soc/atmel/atmel-pcm.h b/sound/soc/atmel/atmel-pcm.h
index 5e0a95e64329..bb45d20e7250 100644
--- a/sound/soc/atmel/atmel-pcm.h
+++ b/sound/soc/atmel/atmel-pcm.h
@@ -36,6 +36,8 @@
36 36
37#include <linux/atmel-ssc.h> 37#include <linux/atmel-ssc.h>
38 38
39#define ATMEL_SSC_DMABUF_SIZE (64 * 1024)
40
39/* 41/*
40 * Registers and status bits that are required by the PCM driver. 42 * Registers and status bits that are required by the PCM driver.
41 */ 43 */
@@ -50,6 +52,7 @@ struct atmel_pdc_regs {
50struct atmel_ssc_mask { 52struct atmel_ssc_mask {
51 u32 ssc_enable; /* SSC recv/trans enable */ 53 u32 ssc_enable; /* SSC recv/trans enable */
52 u32 ssc_disable; /* SSC recv/trans disable */ 54 u32 ssc_disable; /* SSC recv/trans disable */
55 u32 ssc_error; /* SSC error conditions */
53 u32 ssc_endx; /* SSC ENDTX or ENDRX */ 56 u32 ssc_endx; /* SSC ENDTX or ENDRX */
54 u32 ssc_endbuf; /* SSC TXBUFE or RXBUFF */ 57 u32 ssc_endbuf; /* SSC TXBUFE or RXBUFF */
55 u32 pdc_enable; /* PDC recv/trans enable */ 58 u32 pdc_enable; /* PDC recv/trans enable */
@@ -80,4 +83,35 @@ struct atmel_pcm_dma_params {
80#define ssc_readx(base, reg) (__raw_readl((base) + (reg))) 83#define ssc_readx(base, reg) (__raw_readl((base) + (reg)))
81#define ssc_writex(base, reg, value) __raw_writel((value), (base) + (reg)) 84#define ssc_writex(base, reg, value) __raw_writel((value), (base) + (reg))
82 85
86int atmel_pcm_new(struct snd_soc_pcm_runtime *rtd);
87void atmel_pcm_free(struct snd_pcm *pcm);
88int atmel_pcm_mmap(struct snd_pcm_substream *substream,
89 struct vm_area_struct *vma);
90
91#ifdef CONFIG_SND_ATMEL_SOC_PDC
92int atmel_pcm_pdc_platform_register(struct device *dev);
93void atmel_pcm_pdc_platform_unregister(struct device *dev);
94#else
95static inline int atmel_pcm_pdc_platform_register(struct device *dev)
96{
97 return 0;
98}
99static inline void atmel_pcm_pdc_platform_unregister(struct device *dev)
100{
101}
102#endif
103
104#ifdef CONFIG_SND_ATMEL_SOC_DMA
105int atmel_pcm_dma_platform_register(struct device *dev);
106void atmel_pcm_dma_platform_unregister(struct device *dev);
107#else
108static inline int atmel_pcm_dma_platform_register(struct device *dev)
109{
110 return 0;
111}
112static inline void atmel_pcm_dma_platform_unregister(struct device *dev)
113{
114}
115#endif
116
83#endif /* _ATMEL_PCM_H */ 117#endif /* _ATMEL_PCM_H */
diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c
index 354341ec0f42..1c7663422054 100644
--- a/sound/soc/atmel/atmel_ssc_dai.c
+++ b/sound/soc/atmel/atmel_ssc_dai.c
@@ -48,11 +48,7 @@
48#include "atmel_ssc_dai.h" 48#include "atmel_ssc_dai.h"
49 49
50 50
51#if defined(CONFIG_ARCH_AT91SAM9260) || defined(CONFIG_ARCH_AT91SAM9G20)
52#define NUM_SSC_DEVICES 1
53#else
54#define NUM_SSC_DEVICES 3 51#define NUM_SSC_DEVICES 3
55#endif
56 52
57/* 53/*
58 * SSC PDC registers required by the PCM DMA engine. 54 * SSC PDC registers required by the PCM DMA engine.
@@ -107,7 +103,6 @@ static struct atmel_pcm_dma_params ssc_dma_params[NUM_SSC_DEVICES][2] = {
107 .pdc = &pdc_rx_reg, 103 .pdc = &pdc_rx_reg,
108 .mask = &ssc_rx_mask, 104 .mask = &ssc_rx_mask,
109 } }, 105 } },
110#if NUM_SSC_DEVICES == 3
111 {{ 106 {{
112 .name = "SSC1 PCM out", 107 .name = "SSC1 PCM out",
113 .pdc = &pdc_tx_reg, 108 .pdc = &pdc_tx_reg,
@@ -128,7 +123,6 @@ static struct atmel_pcm_dma_params ssc_dma_params[NUM_SSC_DEVICES][2] = {
128 .pdc = &pdc_rx_reg, 123 .pdc = &pdc_rx_reg,
129 .mask = &ssc_rx_mask, 124 .mask = &ssc_rx_mask,
130 } }, 125 } },
131#endif
132}; 126};
133 127
134 128
@@ -139,7 +133,6 @@ static struct atmel_ssc_info ssc_info[NUM_SSC_DEVICES] = {
139 .dir_mask = SSC_DIR_MASK_UNUSED, 133 .dir_mask = SSC_DIR_MASK_UNUSED,
140 .initialized = 0, 134 .initialized = 0,
141 }, 135 },
142#if NUM_SSC_DEVICES == 3
143 { 136 {
144 .name = "ssc1", 137 .name = "ssc1",
145 .lock = __SPIN_LOCK_UNLOCKED(ssc_info[1].lock), 138 .lock = __SPIN_LOCK_UNLOCKED(ssc_info[1].lock),
@@ -152,7 +145,6 @@ static struct atmel_ssc_info ssc_info[NUM_SSC_DEVICES] = {
152 .dir_mask = SSC_DIR_MASK_UNUSED, 145 .dir_mask = SSC_DIR_MASK_UNUSED,
153 .initialized = 0, 146 .initialized = 0,
154 }, 147 },
155#endif
156}; 148};
157 149
158 150
@@ -690,27 +682,9 @@ static int atmel_ssc_resume(struct snd_soc_dai *cpu_dai)
690static int atmel_ssc_probe(struct snd_soc_dai *dai) 682static int atmel_ssc_probe(struct snd_soc_dai *dai)
691{ 683{
692 struct atmel_ssc_info *ssc_p = &ssc_info[dai->id]; 684 struct atmel_ssc_info *ssc_p = &ssc_info[dai->id];
693 int ret = 0;
694 685
695 snd_soc_dai_set_drvdata(dai, ssc_p); 686 snd_soc_dai_set_drvdata(dai, ssc_p);
696 687
697 /*
698 * Request SSC device
699 */
700 ssc_p->ssc = ssc_request(dai->id);
701 if (IS_ERR(ssc_p->ssc)) {
702 printk(KERN_ERR "ASoC: Failed to request SSC %d\n", dai->id);
703 ret = PTR_ERR(ssc_p->ssc);
704 }
705
706 return ret;
707}
708
709static int atmel_ssc_remove(struct snd_soc_dai *dai)
710{
711 struct atmel_ssc_info *ssc_p = snd_soc_dai_get_drvdata(dai);
712
713 ssc_free(ssc_p->ssc);
714 return 0; 688 return 0;
715} 689}
716 690
@@ -728,30 +702,8 @@ static const struct snd_soc_dai_ops atmel_ssc_dai_ops = {
728 .set_clkdiv = atmel_ssc_set_dai_clkdiv, 702 .set_clkdiv = atmel_ssc_set_dai_clkdiv,
729}; 703};
730 704
731static struct snd_soc_dai_driver atmel_ssc_dai[NUM_SSC_DEVICES] = { 705static struct snd_soc_dai_driver atmel_ssc_dai = {
732 {
733 .name = "atmel-ssc-dai.0",
734 .probe = atmel_ssc_probe,
735 .remove = atmel_ssc_remove,
736 .suspend = atmel_ssc_suspend,
737 .resume = atmel_ssc_resume,
738 .playback = {
739 .channels_min = 1,
740 .channels_max = 2,
741 .rates = ATMEL_SSC_RATES,
742 .formats = ATMEL_SSC_FORMATS,},
743 .capture = {
744 .channels_min = 1,
745 .channels_max = 2,
746 .rates = ATMEL_SSC_RATES,
747 .formats = ATMEL_SSC_FORMATS,},
748 .ops = &atmel_ssc_dai_ops,
749 },
750#if NUM_SSC_DEVICES == 3
751 {
752 .name = "atmel-ssc-dai.1",
753 .probe = atmel_ssc_probe, 706 .probe = atmel_ssc_probe,
754 .remove = atmel_ssc_remove,
755 .suspend = atmel_ssc_suspend, 707 .suspend = atmel_ssc_suspend,
756 .resume = atmel_ssc_resume, 708 .resume = atmel_ssc_resume,
757 .playback = { 709 .playback = {
@@ -765,50 +717,50 @@ static struct snd_soc_dai_driver atmel_ssc_dai[NUM_SSC_DEVICES] = {
765 .rates = ATMEL_SSC_RATES, 717 .rates = ATMEL_SSC_RATES,
766 .formats = ATMEL_SSC_FORMATS,}, 718 .formats = ATMEL_SSC_FORMATS,},
767 .ops = &atmel_ssc_dai_ops, 719 .ops = &atmel_ssc_dai_ops,
768 },
769 {
770 .name = "atmel-ssc-dai.2",
771 .probe = atmel_ssc_probe,
772 .remove = atmel_ssc_remove,
773 .suspend = atmel_ssc_suspend,
774 .resume = atmel_ssc_resume,
775 .playback = {
776 .channels_min = 1,
777 .channels_max = 2,
778 .rates = ATMEL_SSC_RATES,
779 .formats = ATMEL_SSC_FORMATS,},
780 .capture = {
781 .channels_min = 1,
782 .channels_max = 2,
783 .rates = ATMEL_SSC_RATES,
784 .formats = ATMEL_SSC_FORMATS,},
785 .ops = &atmel_ssc_dai_ops,
786 },
787#endif
788}; 720};
789 721
790static __devinit int asoc_ssc_probe(struct platform_device *pdev) 722static int asoc_ssc_init(struct device *dev)
791{ 723{
792 BUG_ON(pdev->id < 0); 724 struct platform_device *pdev = to_platform_device(dev);
793 BUG_ON(pdev->id >= ARRAY_SIZE(atmel_ssc_dai)); 725 struct ssc_device *ssc = platform_get_drvdata(pdev);
794 return snd_soc_register_dai(&pdev->dev, &atmel_ssc_dai[pdev->id]); 726 int ret;
795} 727
728 ret = snd_soc_register_dai(dev, &atmel_ssc_dai);
729 if (ret) {
730 dev_err(dev, "Could not register DAI: %d\n", ret);
731 goto err;
732 }
733
734 if (ssc->pdata->use_dma)
735 ret = atmel_pcm_dma_platform_register(dev);
736 else
737 ret = atmel_pcm_pdc_platform_register(dev);
738
739 if (ret) {
740 dev_err(dev, "Could not register PCM: %d\n", ret);
741 goto err_unregister_dai;
742 };
796 743
797static int __devexit asoc_ssc_remove(struct platform_device *pdev)
798{
799 snd_soc_unregister_dai(&pdev->dev);
800 return 0; 744 return 0;
745
746err_unregister_dai:
747 snd_soc_unregister_dai(dev);
748err:
749 return ret;
801} 750}
802 751
803static struct platform_driver asoc_ssc_driver = { 752static void asoc_ssc_exit(struct device *dev)
804 .driver = { 753{
805 .name = "atmel-ssc-dai", 754 struct platform_device *pdev = to_platform_device(dev);
806 .owner = THIS_MODULE, 755 struct ssc_device *ssc = platform_get_drvdata(pdev);
807 },
808 756
809 .probe = asoc_ssc_probe, 757 if (ssc->pdata->use_dma)
810 .remove = __devexit_p(asoc_ssc_remove), 758 atmel_pcm_dma_platform_unregister(dev);
811}; 759 else
760 atmel_pcm_pdc_platform_unregister(dev);
761
762 snd_soc_unregister_dai(dev);
763}
812 764
813/** 765/**
814 * atmel_ssc_set_audio - Allocate the specified SSC for audio use. 766 * atmel_ssc_set_audio - Allocate the specified SSC for audio use.
@@ -816,50 +768,32 @@ static struct platform_driver asoc_ssc_driver = {
816int atmel_ssc_set_audio(int ssc_id) 768int atmel_ssc_set_audio(int ssc_id)
817{ 769{
818 struct ssc_device *ssc; 770 struct ssc_device *ssc;
819 static struct platform_device *dma_pdev;
820 struct platform_device *ssc_pdev;
821 int ret; 771 int ret;
822 772
823 if (ssc_id < 0 || ssc_id >= ARRAY_SIZE(atmel_ssc_dai))
824 return -EINVAL;
825
826 /* Allocate a dummy device for DMA if we don't have one already */
827 if (!dma_pdev) {
828 dma_pdev = platform_device_alloc("atmel-pcm-audio", -1);
829 if (!dma_pdev)
830 return -ENOMEM;
831
832 ret = platform_device_add(dma_pdev);
833 if (ret < 0) {
834 platform_device_put(dma_pdev);
835 dma_pdev = NULL;
836 return ret;
837 }
838 }
839
840 ssc_pdev = platform_device_alloc("atmel-ssc-dai", ssc_id);
841 if (!ssc_pdev)
842 return -ENOMEM;
843
844 /* If we can grab the SSC briefly to parent the DAI device off it */ 773 /* If we can grab the SSC briefly to parent the DAI device off it */
845 ssc = ssc_request(ssc_id); 774 ssc = ssc_request(ssc_id);
846 if (IS_ERR(ssc)) 775 if (IS_ERR(ssc)) {
847 pr_warn("Unable to parent ASoC SSC DAI on SSC: %ld\n", 776 pr_err("Unable to parent ASoC SSC DAI on SSC: %ld\n",
848 PTR_ERR(ssc)); 777 PTR_ERR(ssc));
849 else { 778 return PTR_ERR(ssc);
850 ssc_pdev->dev.parent = &(ssc->pdev->dev); 779 } else {
851 ssc_free(ssc); 780 ssc_info[ssc_id].ssc = ssc;
852 } 781 }
853 782
854 ret = platform_device_add(ssc_pdev); 783 ret = asoc_ssc_init(&ssc->pdev->dev);
855 if (ret < 0)
856 platform_device_put(ssc_pdev);
857 784
858 return ret; 785 return ret;
859} 786}
860EXPORT_SYMBOL_GPL(atmel_ssc_set_audio); 787EXPORT_SYMBOL_GPL(atmel_ssc_set_audio);
861 788
862module_platform_driver(asoc_ssc_driver); 789void atmel_ssc_put_audio(int ssc_id)
790{
791 struct ssc_device *ssc = ssc_info[ssc_id].ssc;
792
793 ssc_free(ssc);
794 asoc_ssc_exit(&ssc->pdev->dev);
795}
796EXPORT_SYMBOL_GPL(atmel_ssc_put_audio);
863 797
864/* Module information */ 798/* Module information */
865MODULE_AUTHOR("Sedji Gaouaou, sedji.gaouaou@atmel.com, www.atmel.com"); 799MODULE_AUTHOR("Sedji Gaouaou, sedji.gaouaou@atmel.com, www.atmel.com");
diff --git a/sound/soc/atmel/atmel_ssc_dai.h b/sound/soc/atmel/atmel_ssc_dai.h
index 5d4f0f9b4d9a..b1f08d511495 100644
--- a/sound/soc/atmel/atmel_ssc_dai.h
+++ b/sound/soc/atmel/atmel_ssc_dai.h
@@ -117,6 +117,7 @@ struct atmel_ssc_info {
117 struct atmel_ssc_state ssc_state; 117 struct atmel_ssc_state ssc_state;
118}; 118};
119 119
120int atmel_ssc_set_audio(int ssc); 120int atmel_ssc_set_audio(int ssc_id);
121void atmel_ssc_put_audio(int ssc_id);
121 122
122#endif /* _AT91_SSC_DAI_H */ 123#endif /* _AT91_SSC_DAI_H */
diff --git a/sound/soc/atmel/sam9g20_wm8731.c b/sound/soc/atmel/sam9g20_wm8731.c
index c88351488f45..0744610e53dd 100644
--- a/sound/soc/atmel/sam9g20_wm8731.c
+++ b/sound/soc/atmel/sam9g20_wm8731.c
@@ -38,6 +38,8 @@
38#include <linux/platform_device.h> 38#include <linux/platform_device.h>
39#include <linux/i2c.h> 39#include <linux/i2c.h>
40 40
41#include <linux/pinctrl/consumer.h>
42
41#include <linux/atmel-ssc.h> 43#include <linux/atmel-ssc.h>
42 44
43#include <sound/core.h> 45#include <sound/core.h>
@@ -179,10 +181,10 @@ static int at91sam9g20ek_wm8731_init(struct snd_soc_pcm_runtime *rtd)
179static struct snd_soc_dai_link at91sam9g20ek_dai = { 181static struct snd_soc_dai_link at91sam9g20ek_dai = {
180 .name = "WM8731", 182 .name = "WM8731",
181 .stream_name = "WM8731 PCM", 183 .stream_name = "WM8731 PCM",
182 .cpu_dai_name = "atmel-ssc-dai.0", 184 .cpu_dai_name = "at91rm9200_ssc.0",
183 .codec_dai_name = "wm8731-hifi", 185 .codec_dai_name = "wm8731-hifi",
184 .init = at91sam9g20ek_wm8731_init, 186 .init = at91sam9g20ek_wm8731_init,
185 .platform_name = "atmel-pcm-audio", 187 .platform_name = "at91rm9200_ssc.0",
186 .codec_name = "wm8731.0-001b", 188 .codec_name = "wm8731.0-001b",
187 .ops = &at91sam9g20ek_ops, 189 .ops = &at91sam9g20ek_ops,
188}; 190};
@@ -195,20 +197,31 @@ static struct snd_soc_card snd_soc_at91sam9g20ek = {
195 .set_bias_level = at91sam9g20ek_set_bias_level, 197 .set_bias_level = at91sam9g20ek_set_bias_level,
196}; 198};
197 199
198static struct platform_device *at91sam9g20ek_snd_device; 200static int __devinit at91sam9g20ek_audio_probe(struct platform_device *pdev)
199
200static int __init at91sam9g20ek_init(void)
201{ 201{
202 struct device_node *np = pdev->dev.of_node;
203 struct device_node *codec_np, *cpu_np;
202 struct clk *pllb; 204 struct clk *pllb;
205 struct snd_soc_card *card = &snd_soc_at91sam9g20ek;
206 struct pinctrl *pinctrl;
203 int ret; 207 int ret;
204 208
205 if (!(machine_is_at91sam9g20ek() || machine_is_at91sam9g20ek_2mmc())) 209 pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
206 return -ENODEV; 210 if (IS_ERR(pinctrl)) {
211 dev_err(&pdev->dev, "Failed to request pinctrl for mck\n");
212 return PTR_ERR(pinctrl);
213 }
214
215 if (!np) {
216 if (!(machine_is_at91sam9g20ek() ||
217 machine_is_at91sam9g20ek_2mmc()))
218 return -ENODEV;
219 }
207 220
208 ret = atmel_ssc_set_audio(0); 221 ret = atmel_ssc_set_audio(0);
209 if (ret != 0) { 222 if (ret) {
210 pr_err("Failed to set SSC 0 for audio: %d\n", ret); 223 dev_err(&pdev->dev, "ssc channel is not valid\n");
211 return ret; 224 return -EINVAL;
212 } 225 }
213 226
214 /* 227 /*
@@ -236,45 +249,92 @@ static int __init at91sam9g20ek_init(void)
236 249
237 clk_set_rate(mclk, MCLK_RATE); 250 clk_set_rate(mclk, MCLK_RATE);
238 251
239 at91sam9g20ek_snd_device = platform_device_alloc("soc-audio", -1); 252 card->dev = &pdev->dev;
240 if (!at91sam9g20ek_snd_device) { 253
241 printk(KERN_ERR "ASoC: Platform device allocation failed\n"); 254 /* Parse device node info */
242 ret = -ENOMEM; 255 if (np) {
243 goto err_mclk; 256 ret = snd_soc_of_parse_card_name(card, "atmel,model");
257 if (ret)
258 goto err;
259
260 ret = snd_soc_of_parse_audio_routing(card,
261 "atmel,audio-routing");
262 if (ret)
263 goto err;
264
265 /* Parse codec info */
266 at91sam9g20ek_dai.codec_name = NULL;
267 codec_np = of_parse_phandle(np, "atmel,audio-codec", 0);
268 if (!codec_np) {
269 dev_err(&pdev->dev, "codec info missing\n");
270 return -EINVAL;
271 }
272 at91sam9g20ek_dai.codec_of_node = codec_np;
273
274 /* Parse dai and platform info */
275 at91sam9g20ek_dai.cpu_dai_name = NULL;
276 at91sam9g20ek_dai.platform_name = NULL;
277 cpu_np = of_parse_phandle(np, "atmel,ssc-controller", 0);
278 if (!cpu_np) {
279 dev_err(&pdev->dev, "dai and pcm info missing\n");
280 return -EINVAL;
281 }
282 at91sam9g20ek_dai.cpu_of_node = cpu_np;
283 at91sam9g20ek_dai.platform_of_node = cpu_np;
284
285 of_node_put(codec_np);
286 of_node_put(cpu_np);
244 } 287 }
245 288
246 platform_set_drvdata(at91sam9g20ek_snd_device, 289 ret = snd_soc_register_card(card);
247 &snd_soc_at91sam9g20ek);
248
249 ret = platform_device_add(at91sam9g20ek_snd_device);
250 if (ret) { 290 if (ret) {
251 printk(KERN_ERR "ASoC: Platform device allocation failed\n"); 291 printk(KERN_ERR "ASoC: snd_soc_register_card() failed\n");
252 goto err_device_add;
253 } 292 }
254 293
255 return ret; 294 return ret;
256 295
257err_device_add:
258 platform_device_put(at91sam9g20ek_snd_device);
259err_mclk: 296err_mclk:
260 clk_put(mclk); 297 clk_put(mclk);
261 mclk = NULL; 298 mclk = NULL;
262err: 299err:
300 atmel_ssc_put_audio(0);
263 return ret; 301 return ret;
264} 302}
265 303
266static void __exit at91sam9g20ek_exit(void) 304static int __devexit at91sam9g20ek_audio_remove(struct platform_device *pdev)
267{ 305{
268 platform_device_unregister(at91sam9g20ek_snd_device); 306 struct snd_soc_card *card = platform_get_drvdata(pdev);
269 at91sam9g20ek_snd_device = NULL; 307
308 atmel_ssc_put_audio(0);
309 snd_soc_unregister_card(card);
270 clk_put(mclk); 310 clk_put(mclk);
271 mclk = NULL; 311 mclk = NULL;
312
313 return 0;
272} 314}
273 315
274module_init(at91sam9g20ek_init); 316#ifdef CONFIG_OF
275module_exit(at91sam9g20ek_exit); 317static const struct of_device_id at91sam9g20ek_wm8731_dt_ids[] = {
318 { .compatible = "atmel,at91sam9g20ek-wm8731-audio", },
319 { }
320};
321MODULE_DEVICE_TABLE(of, at91sam9g20ek_wm8731_dt_ids);
322#endif
323
324static struct platform_driver at91sam9g20ek_audio_driver = {
325 .driver = {
326 .name = "at91sam9g20ek-audio",
327 .owner = THIS_MODULE,
328 .of_match_table = of_match_ptr(at91sam9g20ek_wm8731_dt_ids),
329 },
330 .probe = at91sam9g20ek_audio_probe,
331 .remove = __devexit_p(at91sam9g20ek_audio_remove),
332};
333
334module_platform_driver(at91sam9g20ek_audio_driver);
276 335
277/* Module information */ 336/* Module information */
278MODULE_AUTHOR("Sedji Gaouaou <sedji.gaouaou@atmel.com>"); 337MODULE_AUTHOR("Sedji Gaouaou <sedji.gaouaou@atmel.com>");
279MODULE_DESCRIPTION("ALSA SoC AT91SAM9G20EK_WM8731"); 338MODULE_DESCRIPTION("ALSA SoC AT91SAM9G20EK_WM8731");
339MODULE_ALIAS("platform:at91sam9g20ek-audio");
280MODULE_LICENSE("GPL"); 340MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index b92759a39361..3a847828932a 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -44,6 +44,7 @@ config SND_SOC_ALL_CODECS
44 select SND_SOC_LM4857 if I2C 44 select SND_SOC_LM4857 if I2C
45 select SND_SOC_LM49453 if I2C 45 select SND_SOC_LM49453 if I2C
46 select SND_SOC_MAX98088 if I2C 46 select SND_SOC_MAX98088 if I2C
47 select SND_SOC_MAX98090 if I2C
47 select SND_SOC_MAX98095 if I2C 48 select SND_SOC_MAX98095 if I2C
48 select SND_SOC_MAX9850 if I2C 49 select SND_SOC_MAX9850 if I2C
49 select SND_SOC_MAX9768 if I2C 50 select SND_SOC_MAX9768 if I2C
@@ -54,6 +55,7 @@ config SND_SOC_ALL_CODECS
54 select SND_SOC_PCM3008 55 select SND_SOC_PCM3008
55 select SND_SOC_RT5631 if I2C 56 select SND_SOC_RT5631 if I2C
56 select SND_SOC_SGTL5000 if I2C 57 select SND_SOC_SGTL5000 if I2C
58 select SND_SOC_SI476X if MFD_SI476X_CORE
57 select SND_SOC_SN95031 if INTEL_SCU_IPC 59 select SND_SOC_SN95031 if INTEL_SCU_IPC
58 select SND_SOC_SPDIF 60 select SND_SOC_SPDIF
59 select SND_SOC_SSM2602 if SND_SOC_I2C_AND_SPI 61 select SND_SOC_SSM2602 if SND_SOC_I2C_AND_SPI
@@ -146,6 +148,13 @@ config SND_SOC_WM_HUBS
146 default y if SND_SOC_WM8993=y || SND_SOC_WM8994=y 148 default y if SND_SOC_WM8993=y || SND_SOC_WM8994=y
147 default m if SND_SOC_WM8993=m || SND_SOC_WM8994=m 149 default m if SND_SOC_WM8993=m || SND_SOC_WM8994=m
148 150
151config SND_SOC_WM_ADSP
152 tristate
153 default y if SND_SOC_WM5102=y
154 default y if SND_SOC_WM2200=y
155 default m if SND_SOC_WM5102=m
156 default m if SND_SOC_WM2200=m
157
149config SND_SOC_AB8500_CODEC 158config SND_SOC_AB8500_CODEC
150 tristate 159 tristate
151 160
@@ -229,6 +238,7 @@ config SND_SOC_CX20442
229 tristate 238 tristate
230 239
231config SND_SOC_JZ4740_CODEC 240config SND_SOC_JZ4740_CODEC
241 select REGMAP_MMIO
232 tristate 242 tristate
233 243
234config SND_SOC_L3 244config SND_SOC_L3
@@ -258,6 +268,9 @@ config SND_SOC_LM49453
258config SND_SOC_MAX98088 268config SND_SOC_MAX98088
259 tristate 269 tristate
260 270
271config SND_SOC_MAX98090
272 tristate
273
261config SND_SOC_MAX98095 274config SND_SOC_MAX98095
262 tristate 275 tristate
263 276
@@ -277,6 +290,9 @@ config SND_SOC_RT5631
277config SND_SOC_SGTL5000 290config SND_SOC_SGTL5000
278 tristate 291 tristate
279 292
293config SND_SOC_SI476X
294 tristate
295
280config SND_SOC_SIGMADSP 296config SND_SOC_SIGMADSP
281 tristate 297 tristate
282 select CRC32 298 select CRC32
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index 9bd4d95aab4f..f6e8e36cceb7 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -34,6 +34,7 @@ snd-soc-lm4857-objs := lm4857.o
34snd-soc-lm49453-objs := lm49453.o 34snd-soc-lm49453-objs := lm49453.o
35snd-soc-max9768-objs := max9768.o 35snd-soc-max9768-objs := max9768.o
36snd-soc-max98088-objs := max98088.o 36snd-soc-max98088-objs := max98088.o
37snd-soc-max98090-objs := max98090.o
37snd-soc-max98095-objs := max98095.o 38snd-soc-max98095-objs := max98095.o
38snd-soc-max9850-objs := max9850.o 39snd-soc-max9850-objs := max9850.o
39snd-soc-mc13783-objs := mc13783.o 40snd-soc-mc13783-objs := mc13783.o
@@ -45,6 +46,7 @@ snd-soc-sgtl5000-objs := sgtl5000.o
45snd-soc-alc5623-objs := alc5623.o 46snd-soc-alc5623-objs := alc5623.o
46snd-soc-alc5632-objs := alc5632.o 47snd-soc-alc5632-objs := alc5632.o
47snd-soc-sigmadsp-objs := sigmadsp.o 48snd-soc-sigmadsp-objs := sigmadsp.o
49snd-soc-si476x-objs := si476x.o
48snd-soc-sn95031-objs := sn95031.o 50snd-soc-sn95031-objs := sn95031.o
49snd-soc-spdif-tx-objs := spdif_transciever.o 51snd-soc-spdif-tx-objs := spdif_transciever.o
50snd-soc-spdif-rx-objs := spdif_receiver.o 52snd-soc-spdif-rx-objs := spdif_receiver.o
@@ -62,6 +64,7 @@ snd-soc-twl6040-objs := twl6040.o
62snd-soc-uda134x-objs := uda134x.o 64snd-soc-uda134x-objs := uda134x.o
63snd-soc-uda1380-objs := uda1380.o 65snd-soc-uda1380-objs := uda1380.o
64snd-soc-wl1273-objs := wl1273.o 66snd-soc-wl1273-objs := wl1273.o
67snd-soc-wm-adsp-objs := wm_adsp.o
65snd-soc-wm0010-objs := wm0010.o 68snd-soc-wm0010-objs := wm0010.o
66snd-soc-wm1250-ev1-objs := wm1250-ev1.o 69snd-soc-wm1250-ev1-objs := wm1250-ev1.o
67snd-soc-wm2000-objs := wm2000.o 70snd-soc-wm2000-objs := wm2000.o
@@ -155,6 +158,7 @@ obj-$(CONFIG_SND_SOC_LM4857) += snd-soc-lm4857.o
155obj-$(CONFIG_SND_SOC_LM49453) += snd-soc-lm49453.o 158obj-$(CONFIG_SND_SOC_LM49453) += snd-soc-lm49453.o
156obj-$(CONFIG_SND_SOC_MAX9768) += snd-soc-max9768.o 159obj-$(CONFIG_SND_SOC_MAX9768) += snd-soc-max9768.o
157obj-$(CONFIG_SND_SOC_MAX98088) += snd-soc-max98088.o 160obj-$(CONFIG_SND_SOC_MAX98088) += snd-soc-max98088.o
161obj-$(CONFIG_SND_SOC_MAX98090) += snd-soc-max98090.o
158obj-$(CONFIG_SND_SOC_MAX98095) += snd-soc-max98095.o 162obj-$(CONFIG_SND_SOC_MAX98095) += snd-soc-max98095.o
159obj-$(CONFIG_SND_SOC_MAX9850) += snd-soc-max9850.o 163obj-$(CONFIG_SND_SOC_MAX9850) += snd-soc-max9850.o
160obj-$(CONFIG_SND_SOC_MC13783) += snd-soc-mc13783.o 164obj-$(CONFIG_SND_SOC_MC13783) += snd-soc-mc13783.o
@@ -164,6 +168,7 @@ obj-$(CONFIG_SND_SOC_PCM3008) += snd-soc-pcm3008.o
164obj-$(CONFIG_SND_SOC_RT5631) += snd-soc-rt5631.o 168obj-$(CONFIG_SND_SOC_RT5631) += snd-soc-rt5631.o
165obj-$(CONFIG_SND_SOC_SGTL5000) += snd-soc-sgtl5000.o 169obj-$(CONFIG_SND_SOC_SGTL5000) += snd-soc-sgtl5000.o
166obj-$(CONFIG_SND_SOC_SIGMADSP) += snd-soc-sigmadsp.o 170obj-$(CONFIG_SND_SOC_SIGMADSP) += snd-soc-sigmadsp.o
171obj-$(CONFIG_SND_SOC_SI476X) += snd-soc-si476x.o
167obj-$(CONFIG_SND_SOC_SN95031) +=snd-soc-sn95031.o 172obj-$(CONFIG_SND_SOC_SN95031) +=snd-soc-sn95031.o
168obj-$(CONFIG_SND_SOC_SPDIF) += snd-soc-spdif-rx.o snd-soc-spdif-tx.o 173obj-$(CONFIG_SND_SOC_SPDIF) += snd-soc-spdif-rx.o snd-soc-spdif-tx.o
169obj-$(CONFIG_SND_SOC_SSM2602) += snd-soc-ssm2602.o 174obj-$(CONFIG_SND_SOC_SSM2602) += snd-soc-ssm2602.o
@@ -229,6 +234,7 @@ obj-$(CONFIG_SND_SOC_WM9090) += snd-soc-wm9090.o
229obj-$(CONFIG_SND_SOC_WM9705) += snd-soc-wm9705.o 234obj-$(CONFIG_SND_SOC_WM9705) += snd-soc-wm9705.o
230obj-$(CONFIG_SND_SOC_WM9712) += snd-soc-wm9712.o 235obj-$(CONFIG_SND_SOC_WM9712) += snd-soc-wm9712.o
231obj-$(CONFIG_SND_SOC_WM9713) += snd-soc-wm9713.o 236obj-$(CONFIG_SND_SOC_WM9713) += snd-soc-wm9713.o
237obj-$(CONFIG_SND_SOC_WM_ADSP) += snd-soc-wm-adsp.o
232obj-$(CONFIG_SND_SOC_WM_HUBS) += snd-soc-wm-hubs.o 238obj-$(CONFIG_SND_SOC_WM_HUBS) += snd-soc-wm-hubs.o
233 239
234# Amp 240# Amp
diff --git a/sound/soc/codecs/ab8500-codec.c b/sound/soc/codecs/ab8500-codec.c
index af547490b4f7..4d96090db662 100644
--- a/sound/soc/codecs/ab8500-codec.c
+++ b/sound/soc/codecs/ab8500-codec.c
@@ -2356,7 +2356,7 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai,
2356 return 0; 2356 return 0;
2357} 2357}
2358 2358
2359struct snd_soc_dai_driver ab8500_codec_dai[] = { 2359static struct snd_soc_dai_driver ab8500_codec_dai[] = {
2360 { 2360 {
2361 .name = "ab8500-codec-dai.0", 2361 .name = "ab8500-codec-dai.0",
2362 .id = 0, 2362 .id = 0,
diff --git a/sound/soc/codecs/ak4104.c b/sound/soc/codecs/ak4104.c
index 31d4483245d0..4b11b82b2273 100644
--- a/sound/soc/codecs/ak4104.c
+++ b/sound/soc/codecs/ak4104.c
@@ -15,6 +15,8 @@
15#include <sound/soc.h> 15#include <sound/soc.h>
16#include <sound/initval.h> 16#include <sound/initval.h>
17#include <linux/spi/spi.h> 17#include <linux/spi/spi.h>
18#include <linux/of_device.h>
19#include <linux/of_gpio.h>
18#include <sound/asoundef.h> 20#include <sound/asoundef.h>
19 21
20/* AK4104 registers addresses */ 22/* AK4104 registers addresses */
@@ -98,14 +100,32 @@ static int ak4104_hw_params(struct snd_pcm_substream *substream,
98 val = 0; 100 val = 0;
99 101
100 switch (params_rate(params)) { 102 switch (params_rate(params)) {
103 case 22050:
104 val |= IEC958_AES3_CON_FS_22050;
105 break;
106 case 24000:
107 val |= IEC958_AES3_CON_FS_24000;
108 break;
109 case 32000:
110 val |= IEC958_AES3_CON_FS_32000;
111 break;
101 case 44100: 112 case 44100:
102 val |= IEC958_AES3_CON_FS_44100; 113 val |= IEC958_AES3_CON_FS_44100;
103 break; 114 break;
104 case 48000: 115 case 48000:
105 val |= IEC958_AES3_CON_FS_48000; 116 val |= IEC958_AES3_CON_FS_48000;
106 break; 117 break;
107 case 32000: 118 case 88200:
108 val |= IEC958_AES3_CON_FS_32000; 119 val |= IEC958_AES3_CON_FS_88200;
120 break;
121 case 96000:
122 val |= IEC958_AES3_CON_FS_96000;
123 break;
124 case 176400:
125 val |= IEC958_AES3_CON_FS_176400;
126 break;
127 case 192000:
128 val |= IEC958_AES3_CON_FS_192000;
109 break; 129 break;
110 default: 130 default:
111 dev_err(codec->dev, "unsupported sampling rate\n"); 131 dev_err(codec->dev, "unsupported sampling rate\n");
@@ -186,6 +206,7 @@ static const struct regmap_config ak4104_regmap = {
186 206
187static int ak4104_spi_probe(struct spi_device *spi) 207static int ak4104_spi_probe(struct spi_device *spi)
188{ 208{
209 struct device_node *np = spi->dev.of_node;
189 struct ak4104_private *ak4104; 210 struct ak4104_private *ak4104;
190 unsigned int val; 211 unsigned int val;
191 int ret; 212 int ret;
@@ -201,49 +222,59 @@ static int ak4104_spi_probe(struct spi_device *spi)
201 if (ak4104 == NULL) 222 if (ak4104 == NULL)
202 return -ENOMEM; 223 return -ENOMEM;
203 224
204 ak4104->regmap = regmap_init_spi(spi, &ak4104_regmap); 225 ak4104->regmap = devm_regmap_init_spi(spi, &ak4104_regmap);
205 if (IS_ERR(ak4104->regmap)) { 226 if (IS_ERR(ak4104->regmap)) {
206 ret = PTR_ERR(ak4104->regmap); 227 ret = PTR_ERR(ak4104->regmap);
207 return ret; 228 return ret;
208 } 229 }
209 230
231 if (np) {
232 enum of_gpio_flags flags;
233 int gpio = of_get_named_gpio_flags(np, "reset-gpio", 0, &flags);
234
235 if (gpio_is_valid(gpio)) {
236 ret = devm_gpio_request_one(&spi->dev, gpio,
237 flags & OF_GPIO_ACTIVE_LOW ?
238 GPIOF_OUT_INIT_LOW : GPIOF_OUT_INIT_HIGH,
239 "ak4104 reset");
240 if (ret < 0)
241 return ret;
242 }
243 }
244
210 /* read the 'reserved' register - according to the datasheet, it 245 /* read the 'reserved' register - according to the datasheet, it
211 * should contain 0x5b. Not a good way to verify the presence of 246 * should contain 0x5b. Not a good way to verify the presence of
212 * the device, but there is no hardware ID register. */ 247 * the device, but there is no hardware ID register. */
213 ret = regmap_read(ak4104->regmap, AK4104_REG_RESERVED, &val); 248 ret = regmap_read(ak4104->regmap, AK4104_REG_RESERVED, &val);
214 if (ret != 0) 249 if (ret != 0)
215 goto err; 250 return ret;
216 if (val != AK4104_RESERVED_VAL) { 251 if (val != AK4104_RESERVED_VAL)
217 ret = -ENODEV; 252 return -ENODEV;
218 goto err;
219 }
220 253
221 spi_set_drvdata(spi, ak4104); 254 spi_set_drvdata(spi, ak4104);
222 255
223 ret = snd_soc_register_codec(&spi->dev, 256 ret = snd_soc_register_codec(&spi->dev,
224 &soc_codec_device_ak4104, &ak4104_dai, 1); 257 &soc_codec_device_ak4104, &ak4104_dai, 1);
225 if (ret != 0)
226 goto err;
227
228 return 0;
229
230err:
231 regmap_exit(ak4104->regmap);
232 return ret; 258 return ret;
233} 259}
234 260
235static int __devexit ak4104_spi_remove(struct spi_device *spi) 261static int __devexit ak4104_spi_remove(struct spi_device *spi)
236{ 262{
237 struct ak4104_private *ak4101 = spi_get_drvdata(spi);
238 regmap_exit(ak4101->regmap);
239 snd_soc_unregister_codec(&spi->dev); 263 snd_soc_unregister_codec(&spi->dev);
240 return 0; 264 return 0;
241} 265}
242 266
267static const struct of_device_id ak4104_of_match[] = {
268 { .compatible = "asahi-kasei,ak4104", },
269 { }
270};
271MODULE_DEVICE_TABLE(of, ak4104_of_match);
272
243static struct spi_driver ak4104_spi_driver = { 273static struct spi_driver ak4104_spi_driver = {
244 .driver = { 274 .driver = {
245 .name = DRV_NAME, 275 .name = DRV_NAME,
246 .owner = THIS_MODULE, 276 .owner = THIS_MODULE,
277 .of_match_table = ak4104_of_match,
247 }, 278 },
248 .probe = ak4104_spi_probe, 279 .probe = ak4104_spi_probe,
249 .remove = __devexit_p(ak4104_spi_remove), 280 .remove = __devexit_p(ak4104_spi_remove),
diff --git a/sound/soc/codecs/ak4535.c b/sound/soc/codecs/ak4535.c
index 618fdc30f73e..fc5581063b2d 100644
--- a/sound/soc/codecs/ak4535.c
+++ b/sound/soc/codecs/ak4535.c
@@ -447,7 +447,7 @@ static __devinit int ak4535_i2c_probe(struct i2c_client *i2c,
447 if (ak4535 == NULL) 447 if (ak4535 == NULL)
448 return -ENOMEM; 448 return -ENOMEM;
449 449
450 ak4535->regmap = regmap_init_i2c(i2c, &ak4535_regmap); 450 ak4535->regmap = devm_regmap_init_i2c(i2c, &ak4535_regmap);
451 if (IS_ERR(ak4535->regmap)) { 451 if (IS_ERR(ak4535->regmap)) {
452 ret = PTR_ERR(ak4535->regmap); 452 ret = PTR_ERR(ak4535->regmap);
453 dev_err(&i2c->dev, "Failed to init regmap: %d\n", ret); 453 dev_err(&i2c->dev, "Failed to init regmap: %d\n", ret);
@@ -458,18 +458,13 @@ static __devinit int ak4535_i2c_probe(struct i2c_client *i2c,
458 458
459 ret = snd_soc_register_codec(&i2c->dev, 459 ret = snd_soc_register_codec(&i2c->dev,
460 &soc_codec_dev_ak4535, &ak4535_dai, 1); 460 &soc_codec_dev_ak4535, &ak4535_dai, 1);
461 if (ret != 0)
462 regmap_exit(ak4535->regmap);
463 461
464 return ret; 462 return ret;
465} 463}
466 464
467static __devexit int ak4535_i2c_remove(struct i2c_client *client) 465static __devexit int ak4535_i2c_remove(struct i2c_client *client)
468{ 466{
469 struct ak4535_priv *ak4535 = i2c_get_clientdata(client);
470
471 snd_soc_unregister_codec(&client->dev); 467 snd_soc_unregister_codec(&client->dev);
472 regmap_exit(ak4535->regmap);
473 return 0; 468 return 0;
474} 469}
475 470
diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c
index b3e24f289421..546466abb77f 100644
--- a/sound/soc/codecs/ak4642.c
+++ b/sound/soc/codecs/ak4642.c
@@ -194,12 +194,6 @@ static const struct snd_soc_dapm_route ak4642_intercon[] = {
194 {"LINEOUT Mixer", "DACL", "DAC"}, 194 {"LINEOUT Mixer", "DACL", "DAC"},
195}; 195};
196 196
197/* codec private data */
198struct ak4642_priv {
199 unsigned int sysclk;
200 enum snd_soc_control_type control_type;
201};
202
203/* 197/*
204 * ak4642 register cache 198 * ak4642 register cache
205 */ 199 */
@@ -468,10 +462,9 @@ static int ak4642_resume(struct snd_soc_codec *codec)
468 462
469static int ak4642_probe(struct snd_soc_codec *codec) 463static int ak4642_probe(struct snd_soc_codec *codec)
470{ 464{
471 struct ak4642_priv *ak4642 = snd_soc_codec_get_drvdata(codec);
472 int ret; 465 int ret;
473 466
474 ret = snd_soc_codec_set_cache_io(codec, 8, 8, ak4642->control_type); 467 ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C);
475 if (ret < 0) { 468 if (ret < 0) {
476 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); 469 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
477 return ret; 470 return ret;
@@ -523,21 +516,9 @@ static struct snd_soc_codec_driver soc_codec_dev_ak4648 = {
523static __devinit int ak4642_i2c_probe(struct i2c_client *i2c, 516static __devinit int ak4642_i2c_probe(struct i2c_client *i2c,
524 const struct i2c_device_id *id) 517 const struct i2c_device_id *id)
525{ 518{
526 struct ak4642_priv *ak4642; 519 return snd_soc_register_codec(&i2c->dev,
527 int ret;
528
529 ak4642 = devm_kzalloc(&i2c->dev, sizeof(struct ak4642_priv),
530 GFP_KERNEL);
531 if (!ak4642)
532 return -ENOMEM;
533
534 i2c_set_clientdata(i2c, ak4642);
535 ak4642->control_type = SND_SOC_I2C;
536
537 ret = snd_soc_register_codec(&i2c->dev,
538 (struct snd_soc_codec_driver *)id->driver_data, 520 (struct snd_soc_codec_driver *)id->driver_data,
539 &ak4642_dai, 1); 521 &ak4642_dai, 1);
540 return ret;
541} 522}
542 523
543static __devexit int ak4642_i2c_remove(struct i2c_client *client) 524static __devexit int ak4642_i2c_remove(struct i2c_client *client)
diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c
index c03b65af3059..adf397b9d0e6 100644
--- a/sound/soc/codecs/arizona.c
+++ b/sound/soc/codecs/arizona.c
@@ -226,6 +226,31 @@ EXPORT_SYMBOL_GPL(arizona_mixer_values);
226const DECLARE_TLV_DB_SCALE(arizona_mixer_tlv, -3200, 100, 0); 226const DECLARE_TLV_DB_SCALE(arizona_mixer_tlv, -3200, 100, 0);
227EXPORT_SYMBOL_GPL(arizona_mixer_tlv); 227EXPORT_SYMBOL_GPL(arizona_mixer_tlv);
228 228
229static const char *arizona_vol_ramp_text[] = {
230 "0ms/6dB", "0.5ms/6dB", "1ms/6dB", "2ms/6dB", "4ms/6dB", "8ms/6dB",
231 "15ms/6dB", "30ms/6dB",
232};
233
234const struct soc_enum arizona_in_vd_ramp =
235 SOC_ENUM_SINGLE(ARIZONA_INPUT_VOLUME_RAMP,
236 ARIZONA_IN_VD_RAMP_SHIFT, 7, arizona_vol_ramp_text);
237EXPORT_SYMBOL_GPL(arizona_in_vd_ramp);
238
239const struct soc_enum arizona_in_vi_ramp =
240 SOC_ENUM_SINGLE(ARIZONA_INPUT_VOLUME_RAMP,
241 ARIZONA_IN_VI_RAMP_SHIFT, 7, arizona_vol_ramp_text);
242EXPORT_SYMBOL_GPL(arizona_in_vi_ramp);
243
244const struct soc_enum arizona_out_vd_ramp =
245 SOC_ENUM_SINGLE(ARIZONA_OUTPUT_VOLUME_RAMP,
246 ARIZONA_OUT_VD_RAMP_SHIFT, 7, arizona_vol_ramp_text);
247EXPORT_SYMBOL_GPL(arizona_out_vd_ramp);
248
249const struct soc_enum arizona_out_vi_ramp =
250 SOC_ENUM_SINGLE(ARIZONA_OUTPUT_VOLUME_RAMP,
251 ARIZONA_OUT_VI_RAMP_SHIFT, 7, arizona_vol_ramp_text);
252EXPORT_SYMBOL_GPL(arizona_out_vi_ramp);
253
229static const char *arizona_lhpf_mode_text[] = { 254static const char *arizona_lhpf_mode_text[] = {
230 "Low-pass", "High-pass" 255 "Low-pass", "High-pass"
231}; 256};
@@ -268,7 +293,7 @@ EXPORT_SYMBOL_GPL(arizona_out_ev);
268static unsigned int arizona_sysclk_48k_rates[] = { 293static unsigned int arizona_sysclk_48k_rates[] = {
269 6144000, 294 6144000,
270 12288000, 295 12288000,
271 22579200, 296 24576000,
272 49152000, 297 49152000,
273 73728000, 298 73728000,
274 98304000, 299 98304000,
@@ -278,7 +303,7 @@ static unsigned int arizona_sysclk_48k_rates[] = {
278static unsigned int arizona_sysclk_44k1_rates[] = { 303static unsigned int arizona_sysclk_44k1_rates[] = {
279 5644800, 304 5644800,
280 11289600, 305 11289600,
281 24576000, 306 22579200,
282 45158400, 307 45158400,
283 67737600, 308 67737600,
284 90316800, 309 90316800,
@@ -380,6 +405,18 @@ int arizona_set_sysclk(struct snd_soc_codec *codec, int clk_id,
380 case 49152000: 405 case 49152000:
381 val |= 3 << ARIZONA_SYSCLK_FREQ_SHIFT; 406 val |= 3 << ARIZONA_SYSCLK_FREQ_SHIFT;
382 break; 407 break;
408 case 67737600:
409 case 73728000:
410 val |= 4 << ARIZONA_SYSCLK_FREQ_SHIFT;
411 break;
412 case 90316800:
413 case 98304000:
414 val |= 5 << ARIZONA_SYSCLK_FREQ_SHIFT;
415 break;
416 case 135475200:
417 case 147456000:
418 val |= 6 << ARIZONA_SYSCLK_FREQ_SHIFT;
419 break;
383 default: 420 default:
384 return -EINVAL; 421 return -EINVAL;
385 } 422 }
@@ -737,6 +774,9 @@ static int arizona_dai_set_sysclk(struct snd_soc_dai *dai,
737 return -EBUSY; 774 return -EBUSY;
738 } 775 }
739 776
777 dev_dbg(codec->dev, "Setting AIF%d to %s\n", dai->id + 1,
778 arizona_dai_clk_str(clk_id));
779
740 memset(&routes, 0, sizeof(routes)); 780 memset(&routes, 0, sizeof(routes));
741 routes[0].sink = dai->driver->capture.stream_name; 781 routes[0].sink = dai->driver->capture.stream_name;
742 routes[1].sink = dai->driver->playback.stream_name; 782 routes[1].sink = dai->driver->playback.stream_name;
@@ -749,6 +789,8 @@ static int arizona_dai_set_sysclk(struct snd_soc_dai *dai,
749 routes[1].source = arizona_dai_clk_str(clk_id); 789 routes[1].source = arizona_dai_clk_str(clk_id);
750 snd_soc_dapm_add_routes(&codec->dapm, routes, ARRAY_SIZE(routes)); 790 snd_soc_dapm_add_routes(&codec->dapm, routes, ARRAY_SIZE(routes));
751 791
792 dai_priv->clk = clk_id;
793
752 return snd_soc_dapm_sync(&codec->dapm); 794 return snd_soc_dapm_sync(&codec->dapm);
753} 795}
754 796
@@ -925,6 +967,9 @@ int arizona_set_fll(struct arizona_fll *fll, int source,
925 bool ena; 967 bool ena;
926 int ret; 968 int ret;
927 969
970 if (fll->fref == Fref && fll->fout == Fout)
971 return 0;
972
928 ret = regmap_read(arizona->regmap, fll->base + 1, &reg); 973 ret = regmap_read(arizona->regmap, fll->base + 1, &reg);
929 if (ret != 0) { 974 if (ret != 0) {
930 arizona_fll_err(fll, "Failed to read current state: %d\n", 975 arizona_fll_err(fll, "Failed to read current state: %d\n",
@@ -970,6 +1015,9 @@ int arizona_set_fll(struct arizona_fll *fll, int source,
970 if (ena) 1015 if (ena)
971 pm_runtime_put_autosuspend(arizona->dev); 1016 pm_runtime_put_autosuspend(arizona->dev);
972 1017
1018 fll->fref = Fref;
1019 fll->fout = Fout;
1020
973 return 0; 1021 return 0;
974 } 1022 }
975 1023
@@ -998,10 +1046,13 @@ int arizona_set_fll(struct arizona_fll *fll, int source,
998 ARIZONA_FLL1_SYNC_ENA); 1046 ARIZONA_FLL1_SYNC_ENA);
999 1047
1000 ret = wait_for_completion_timeout(&fll->ok, 1048 ret = wait_for_completion_timeout(&fll->ok,
1001 msecs_to_jiffies(25)); 1049 msecs_to_jiffies(250));
1002 if (ret == 0) 1050 if (ret == 0)
1003 arizona_fll_warn(fll, "Timed out waiting for lock\n"); 1051 arizona_fll_warn(fll, "Timed out waiting for lock\n");
1004 1052
1053 fll->fref = Fref;
1054 fll->fout = Fout;
1055
1005 return 0; 1056 return 0;
1006} 1057}
1007EXPORT_SYMBOL_GPL(arizona_set_fll); 1058EXPORT_SYMBOL_GPL(arizona_set_fll);
diff --git a/sound/soc/codecs/arizona.h b/sound/soc/codecs/arizona.h
index 36ec64946120..41dae1ed3b71 100644
--- a/sound/soc/codecs/arizona.h
+++ b/sound/soc/codecs/arizona.h
@@ -17,6 +17,8 @@
17 17
18#include <sound/soc.h> 18#include <sound/soc.h>
19 19
20#include "wm_adsp.h"
21
20#define ARIZONA_CLK_SYSCLK 1 22#define ARIZONA_CLK_SYSCLK 1
21#define ARIZONA_CLK_ASYNCCLK 2 23#define ARIZONA_CLK_ASYNCCLK 2
22#define ARIZONA_CLK_OPCLK 3 24#define ARIZONA_CLK_OPCLK 3
@@ -46,15 +48,18 @@
46#define ARIZONA_MIXER_VOL_SHIFT 1 48#define ARIZONA_MIXER_VOL_SHIFT 1
47#define ARIZONA_MIXER_VOL_WIDTH 7 49#define ARIZONA_MIXER_VOL_WIDTH 7
48 50
49#define ARIZONA_MAX_DAI 3 51#define ARIZONA_MAX_DAI 4
52#define ARIZONA_MAX_ADSP 4
50 53
51struct arizona; 54struct arizona;
55struct wm_adsp;
52 56
53struct arizona_dai_priv { 57struct arizona_dai_priv {
54 int clk; 58 int clk;
55}; 59};
56 60
57struct arizona_priv { 61struct arizona_priv {
62 struct wm_adsp adsp[ARIZONA_MAX_ADSP];
58 struct arizona *arizona; 63 struct arizona *arizona;
59 int sysclk; 64 int sysclk;
60 int asyncclk; 65 int asyncclk;
@@ -89,19 +94,30 @@ extern int arizona_mixer_values[ARIZONA_NUM_MIXER_INPUTS];
89 const struct snd_kcontrol_new name##_mux = \ 94 const struct snd_kcontrol_new name##_mux = \
90 SOC_DAPM_VALUE_ENUM("Route", name##_enum) 95 SOC_DAPM_VALUE_ENUM("Route", name##_enum)
91 96
97#define ARIZONA_MUX_ENUMS(name, base_reg) \
98 static ARIZONA_MUX_ENUM_DECL(name##_enum, base_reg); \
99 static ARIZONA_MUX_CTL_DECL(name)
100
92#define ARIZONA_MIXER_ENUMS(name, base_reg) \ 101#define ARIZONA_MIXER_ENUMS(name, base_reg) \
93 static ARIZONA_MUX_ENUM_DECL(name##_in1_enum, base_reg); \ 102 ARIZONA_MUX_ENUMS(name##_in1, base_reg); \
94 static ARIZONA_MUX_ENUM_DECL(name##_in2_enum, base_reg + 2); \ 103 ARIZONA_MUX_ENUMS(name##_in2, base_reg + 2); \
95 static ARIZONA_MUX_ENUM_DECL(name##_in3_enum, base_reg + 4); \ 104 ARIZONA_MUX_ENUMS(name##_in3, base_reg + 4); \
96 static ARIZONA_MUX_ENUM_DECL(name##_in4_enum, base_reg + 6); \ 105 ARIZONA_MUX_ENUMS(name##_in4, base_reg + 6)
97 static ARIZONA_MUX_CTL_DECL(name##_in1); \ 106
98 static ARIZONA_MUX_CTL_DECL(name##_in2); \ 107#define ARIZONA_DSP_AUX_ENUMS(name, base_reg) \
99 static ARIZONA_MUX_CTL_DECL(name##_in3); \ 108 ARIZONA_MUX_ENUMS(name##_aux1, base_reg); \
100 static ARIZONA_MUX_CTL_DECL(name##_in4) 109 ARIZONA_MUX_ENUMS(name##_aux2, base_reg + 8); \
110 ARIZONA_MUX_ENUMS(name##_aux3, base_reg + 16); \
111 ARIZONA_MUX_ENUMS(name##_aux4, base_reg + 24); \
112 ARIZONA_MUX_ENUMS(name##_aux5, base_reg + 32); \
113 ARIZONA_MUX_ENUMS(name##_aux6, base_reg + 40)
101 114
102#define ARIZONA_MUX(name, ctrl) \ 115#define ARIZONA_MUX(name, ctrl) \
103 SND_SOC_DAPM_VALUE_MUX(name, SND_SOC_NOPM, 0, 0, ctrl) 116 SND_SOC_DAPM_VALUE_MUX(name, SND_SOC_NOPM, 0, 0, ctrl)
104 117
118#define ARIZONA_MUX_WIDGETS(name, name_str) \
119 ARIZONA_MUX(name_str " Input", &name##_mux)
120
105#define ARIZONA_MIXER_WIDGETS(name, name_str) \ 121#define ARIZONA_MIXER_WIDGETS(name, name_str) \
106 ARIZONA_MUX(name_str " Input 1", &name##_in1_mux), \ 122 ARIZONA_MUX(name_str " Input 1", &name##_in1_mux), \
107 ARIZONA_MUX(name_str " Input 2", &name##_in2_mux), \ 123 ARIZONA_MUX(name_str " Input 2", &name##_in2_mux), \
@@ -109,6 +125,19 @@ extern int arizona_mixer_values[ARIZONA_NUM_MIXER_INPUTS];
109 ARIZONA_MUX(name_str " Input 4", &name##_in4_mux), \ 125 ARIZONA_MUX(name_str " Input 4", &name##_in4_mux), \
110 SND_SOC_DAPM_MIXER(name_str " Mixer", SND_SOC_NOPM, 0, 0, NULL, 0) 126 SND_SOC_DAPM_MIXER(name_str " Mixer", SND_SOC_NOPM, 0, 0, NULL, 0)
111 127
128#define ARIZONA_DSP_WIDGETS(name, name_str) \
129 ARIZONA_MIXER_WIDGETS(name##L, name_str "L"), \
130 ARIZONA_MIXER_WIDGETS(name##R, name_str "R"), \
131 ARIZONA_MUX(name_str " Aux 1", &name##_aux1_mux), \
132 ARIZONA_MUX(name_str " Aux 2", &name##_aux2_mux), \
133 ARIZONA_MUX(name_str " Aux 3", &name##_aux3_mux), \
134 ARIZONA_MUX(name_str " Aux 4", &name##_aux4_mux), \
135 ARIZONA_MUX(name_str " Aux 5", &name##_aux5_mux), \
136 ARIZONA_MUX(name_str " Aux 6", &name##_aux6_mux)
137
138#define ARIZONA_MUX_ROUTES(name) \
139 ARIZONA_MIXER_INPUT_ROUTES(name " Input")
140
112#define ARIZONA_MIXER_ROUTES(widget, name) \ 141#define ARIZONA_MIXER_ROUTES(widget, name) \
113 { widget, NULL, name " Mixer" }, \ 142 { widget, NULL, name " Mixer" }, \
114 { name " Mixer", NULL, name " Input 1" }, \ 143 { name " Mixer", NULL, name " Input 1" }, \
@@ -120,6 +149,28 @@ extern int arizona_mixer_values[ARIZONA_NUM_MIXER_INPUTS];
120 ARIZONA_MIXER_INPUT_ROUTES(name " Input 3"), \ 149 ARIZONA_MIXER_INPUT_ROUTES(name " Input 3"), \
121 ARIZONA_MIXER_INPUT_ROUTES(name " Input 4") 150 ARIZONA_MIXER_INPUT_ROUTES(name " Input 4")
122 151
152#define ARIZONA_DSP_ROUTES(name) \
153 { name, NULL, name " Aux 1" }, \
154 { name, NULL, name " Aux 2" }, \
155 { name, NULL, name " Aux 3" }, \
156 { name, NULL, name " Aux 4" }, \
157 { name, NULL, name " Aux 5" }, \
158 { name, NULL, name " Aux 6" }, \
159 ARIZONA_MIXER_INPUT_ROUTES(name " Aux 1"), \
160 ARIZONA_MIXER_INPUT_ROUTES(name " Aux 2"), \
161 ARIZONA_MIXER_INPUT_ROUTES(name " Aux 3"), \
162 ARIZONA_MIXER_INPUT_ROUTES(name " Aux 4"), \
163 ARIZONA_MIXER_INPUT_ROUTES(name " Aux 5"), \
164 ARIZONA_MIXER_INPUT_ROUTES(name " Aux 6"), \
165 ARIZONA_MIXER_ROUTES(name, name "L"), \
166 ARIZONA_MIXER_ROUTES(name, name "R")
167
168extern const struct soc_enum arizona_in_vi_ramp;
169extern const struct soc_enum arizona_in_vd_ramp;
170
171extern const struct soc_enum arizona_out_vi_ramp;
172extern const struct soc_enum arizona_out_vd_ramp;
173
123extern const struct soc_enum arizona_lhpf1_mode; 174extern const struct soc_enum arizona_lhpf1_mode;
124extern const struct soc_enum arizona_lhpf2_mode; 175extern const struct soc_enum arizona_lhpf2_mode;
125extern const struct soc_enum arizona_lhpf3_mode; 176extern const struct soc_enum arizona_lhpf3_mode;
@@ -146,6 +197,8 @@ struct arizona_fll {
146 unsigned int vco_mult; 197 unsigned int vco_mult;
147 struct completion lock; 198 struct completion lock;
148 struct completion ok; 199 struct completion ok;
200 unsigned int fref;
201 unsigned int fout;
149 202
150 char lock_name[ARIZONA_FLL_NAME_LEN]; 203 char lock_name[ARIZONA_FLL_NAME_LEN];
151 char clock_ok_name[ARIZONA_FLL_NAME_LEN]; 204 char clock_ok_name[ARIZONA_FLL_NAME_LEN];
diff --git a/sound/soc/codecs/cs4271.c b/sound/soc/codecs/cs4271.c
index f994af34f552..6ad3878db8fc 100644
--- a/sound/soc/codecs/cs4271.c
+++ b/sound/soc/codecs/cs4271.c
@@ -474,18 +474,28 @@ static int cs4271_probe(struct snd_soc_codec *codec)
474 struct cs4271_platform_data *cs4271plat = codec->dev->platform_data; 474 struct cs4271_platform_data *cs4271plat = codec->dev->platform_data;
475 int ret; 475 int ret;
476 int gpio_nreset = -EINVAL; 476 int gpio_nreset = -EINVAL;
477 int amutec_eq_bmutec = 0;
477 478
478#ifdef CONFIG_OF 479#ifdef CONFIG_OF
479 if (of_match_device(cs4271_dt_ids, codec->dev)) 480 if (of_match_device(cs4271_dt_ids, codec->dev)) {
480 gpio_nreset = of_get_named_gpio(codec->dev->of_node, 481 gpio_nreset = of_get_named_gpio(codec->dev->of_node,
481 "reset-gpio", 0); 482 "reset-gpio", 0);
483
484 if (!of_get_property(codec->dev->of_node,
485 "cirrus,amutec-eq-bmutec", NULL))
486 amutec_eq_bmutec = 1;
487 }
482#endif 488#endif
483 489
484 if (cs4271plat && gpio_is_valid(cs4271plat->gpio_nreset)) 490 if (cs4271plat) {
485 gpio_nreset = cs4271plat->gpio_nreset; 491 if (gpio_is_valid(cs4271plat->gpio_nreset))
492 gpio_nreset = cs4271plat->gpio_nreset;
493
494 amutec_eq_bmutec = cs4271plat->amutec_eq_bmutec;
495 }
486 496
487 if (gpio_nreset >= 0) 497 if (gpio_nreset >= 0)
488 if (gpio_request(gpio_nreset, "CS4271 Reset")) 498 if (devm_gpio_request(codec->dev, gpio_nreset, "CS4271 Reset"))
489 gpio_nreset = -EINVAL; 499 gpio_nreset = -EINVAL;
490 if (gpio_nreset >= 0) { 500 if (gpio_nreset >= 0) {
491 /* Reset codec */ 501 /* Reset codec */
@@ -528,6 +538,11 @@ static int cs4271_probe(struct snd_soc_codec *codec)
528 /* Power-up sequence requires 85 uS */ 538 /* Power-up sequence requires 85 uS */
529 udelay(85); 539 udelay(85);
530 540
541 if (amutec_eq_bmutec)
542 snd_soc_update_bits(codec, CS4271_MODE2,
543 CS4271_MODE2_MUTECAEQUB,
544 CS4271_MODE2_MUTECAEQUB);
545
531 return snd_soc_add_codec_controls(codec, cs4271_snd_controls, 546 return snd_soc_add_codec_controls(codec, cs4271_snd_controls,
532 ARRAY_SIZE(cs4271_snd_controls)); 547 ARRAY_SIZE(cs4271_snd_controls));
533} 548}
@@ -535,15 +550,10 @@ static int cs4271_probe(struct snd_soc_codec *codec)
535static int cs4271_remove(struct snd_soc_codec *codec) 550static int cs4271_remove(struct snd_soc_codec *codec)
536{ 551{
537 struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); 552 struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec);
538 int gpio_nreset;
539
540 gpio_nreset = cs4271->gpio_nreset;
541 553
542 if (gpio_is_valid(gpio_nreset)) { 554 if (gpio_is_valid(cs4271->gpio_nreset))
543 /* Set codec to the reset state */ 555 /* Set codec to the reset state */
544 gpio_set_value(gpio_nreset, 0); 556 gpio_set_value(cs4271->gpio_nreset, 0);
545 gpio_free(gpio_nreset);
546 }
547 557
548 return 0; 558 return 0;
549}; 559};
diff --git a/sound/soc/codecs/cs42l52.c b/sound/soc/codecs/cs42l52.c
index 4d8db3685e96..97a81051e88d 100644
--- a/sound/soc/codecs/cs42l52.c
+++ b/sound/soc/codecs/cs42l52.c
@@ -773,7 +773,6 @@ static int cs42l52_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
773{ 773{
774 struct snd_soc_codec *codec = codec_dai->codec; 774 struct snd_soc_codec *codec = codec_dai->codec;
775 struct cs42l52_private *cs42l52 = snd_soc_codec_get_drvdata(codec); 775 struct cs42l52_private *cs42l52 = snd_soc_codec_get_drvdata(codec);
776 int ret = 0;
777 u8 iface = 0; 776 u8 iface = 0;
778 777
779 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { 778 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
@@ -822,7 +821,7 @@ static int cs42l52_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
822 case SND_SOC_DAIFMT_NB_IF: 821 case SND_SOC_DAIFMT_NB_IF:
823 break; 822 break;
824 default: 823 default:
825 ret = -EINVAL; 824 return -EINVAL;
826 } 825 }
827 cs42l52->config.format = iface; 826 cs42l52->config.format = iface;
828 snd_soc_write(codec, CS42L52_IFACE_CTL1, cs42l52->config.format); 827 snd_soc_write(codec, CS42L52_IFACE_CTL1, cs42l52->config.format);
diff --git a/sound/soc/codecs/da7210.c b/sound/soc/codecs/da7210.c
index af5db7080519..843c1eb72faf 100644
--- a/sound/soc/codecs/da7210.c
+++ b/sound/soc/codecs/da7210.c
@@ -1231,7 +1231,7 @@ static int __devinit da7210_i2c_probe(struct i2c_client *i2c,
1231 1231
1232 i2c_set_clientdata(i2c, da7210); 1232 i2c_set_clientdata(i2c, da7210);
1233 1233
1234 da7210->regmap = regmap_init_i2c(i2c, &da7210_regmap_config_i2c); 1234 da7210->regmap = devm_regmap_init_i2c(i2c, &da7210_regmap_config_i2c);
1235 if (IS_ERR(da7210->regmap)) { 1235 if (IS_ERR(da7210->regmap)) {
1236 ret = PTR_ERR(da7210->regmap); 1236 ret = PTR_ERR(da7210->regmap);
1237 dev_err(&i2c->dev, "regmap_init() failed: %d\n", ret); 1237 dev_err(&i2c->dev, "regmap_init() failed: %d\n", ret);
@@ -1245,24 +1245,15 @@ static int __devinit da7210_i2c_probe(struct i2c_client *i2c,
1245 1245
1246 ret = snd_soc_register_codec(&i2c->dev, 1246 ret = snd_soc_register_codec(&i2c->dev,
1247 &soc_codec_dev_da7210, &da7210_dai, 1); 1247 &soc_codec_dev_da7210, &da7210_dai, 1);
1248 if (ret < 0) { 1248 if (ret < 0)
1249 dev_err(&i2c->dev, "Failed to register codec: %d\n", ret); 1249 dev_err(&i2c->dev, "Failed to register codec: %d\n", ret);
1250 goto err_regmap;
1251 }
1252 return ret;
1253
1254err_regmap:
1255 regmap_exit(da7210->regmap);
1256 1250
1257 return ret; 1251 return ret;
1258} 1252}
1259 1253
1260static int __devexit da7210_i2c_remove(struct i2c_client *client) 1254static int __devexit da7210_i2c_remove(struct i2c_client *client)
1261{ 1255{
1262 struct da7210_priv *da7210 = i2c_get_clientdata(client);
1263
1264 snd_soc_unregister_codec(&client->dev); 1256 snd_soc_unregister_codec(&client->dev);
1265 regmap_exit(da7210->regmap);
1266 return 0; 1257 return 0;
1267} 1258}
1268 1259
@@ -1346,24 +1337,15 @@ static int __devinit da7210_spi_probe(struct spi_device *spi)
1346 if (ret != 0) 1337 if (ret != 0)
1347 dev_warn(&spi->dev, "Failed to apply regmap patch: %d\n", ret); 1338 dev_warn(&spi->dev, "Failed to apply regmap patch: %d\n", ret);
1348 1339
1349 ret = snd_soc_register_codec(&spi->dev, 1340 ret = snd_soc_register_codec(&spi->dev,
1350 &soc_codec_dev_da7210, &da7210_dai, 1); 1341 &soc_codec_dev_da7210, &da7210_dai, 1);
1351 if (ret < 0)
1352 goto err_regmap;
1353
1354 return ret;
1355
1356err_regmap:
1357 regmap_exit(da7210->regmap);
1358 1342
1359 return ret; 1343 return ret;
1360} 1344}
1361 1345
1362static int __devexit da7210_spi_remove(struct spi_device *spi) 1346static int __devexit da7210_spi_remove(struct spi_device *spi)
1363{ 1347{
1364 struct da7210_priv *da7210 = spi_get_drvdata(spi);
1365 snd_soc_unregister_codec(&spi->dev); 1348 snd_soc_unregister_codec(&spi->dev);
1366 regmap_exit(da7210->regmap);
1367 return 0; 1349 return 0;
1368} 1350}
1369 1351
diff --git a/sound/soc/codecs/da9055.c b/sound/soc/codecs/da9055.c
index f379b085c392..d3a6de2e757b 100644
--- a/sound/soc/codecs/da9055.c
+++ b/sound/soc/codecs/da9055.c
@@ -173,6 +173,7 @@
173#define DA9055_AIF_FORMAT_I2S_MODE (0 << 0) 173#define DA9055_AIF_FORMAT_I2S_MODE (0 << 0)
174#define DA9055_AIF_FORMAT_LEFT_J (1 << 0) 174#define DA9055_AIF_FORMAT_LEFT_J (1 << 0)
175#define DA9055_AIF_FORMAT_RIGHT_J (2 << 0) 175#define DA9055_AIF_FORMAT_RIGHT_J (2 << 0)
176#define DA9055_AIF_FORMAT_DSP (3 << 0)
176#define DA9055_AIF_WORD_S16_LE (0 << 2) 177#define DA9055_AIF_WORD_S16_LE (0 << 2)
177#define DA9055_AIF_WORD_S20_3LE (1 << 2) 178#define DA9055_AIF_WORD_S20_3LE (1 << 2)
178#define DA9055_AIF_WORD_S24_LE (2 << 2) 179#define DA9055_AIF_WORD_S24_LE (2 << 2)
@@ -752,6 +753,17 @@ static const struct snd_kcontrol_new da9055_dapm_mixoutr_controls[] = {
752 6, 1, 0), 753 6, 1, 0),
753}; 754};
754 755
756/* Headphone Output Enable */
757static const struct snd_kcontrol_new da9055_dapm_hp_l_control =
758SOC_DAPM_SINGLE("Switch", DA9055_HP_L_CTRL, 3, 1, 0);
759
760static const struct snd_kcontrol_new da9055_dapm_hp_r_control =
761SOC_DAPM_SINGLE("Switch", DA9055_HP_R_CTRL, 3, 1, 0);
762
763/* Lineout Output Enable */
764static const struct snd_kcontrol_new da9055_dapm_lineout_control =
765SOC_DAPM_SINGLE("Switch", DA9055_LINE_CTRL, 3, 1, 0);
766
755/* DAPM widgets */ 767/* DAPM widgets */
756static const struct snd_soc_dapm_widget da9055_dapm_widgets[] = { 768static const struct snd_soc_dapm_widget da9055_dapm_widgets[] = {
757 /* Input Side */ 769 /* Input Side */
@@ -816,6 +828,14 @@ static const struct snd_soc_dapm_widget da9055_dapm_widgets[] = {
816 &da9055_dapm_mixoutr_controls[0], 828 &da9055_dapm_mixoutr_controls[0],
817 ARRAY_SIZE(da9055_dapm_mixoutr_controls)), 829 ARRAY_SIZE(da9055_dapm_mixoutr_controls)),
818 830
831 /* Output Enable Switches */
832 SND_SOC_DAPM_SWITCH("Headphone Left Enable", SND_SOC_NOPM, 0, 0,
833 &da9055_dapm_hp_l_control),
834 SND_SOC_DAPM_SWITCH("Headphone Right Enable", SND_SOC_NOPM, 0, 0,
835 &da9055_dapm_hp_r_control),
836 SND_SOC_DAPM_SWITCH("Lineout Enable", SND_SOC_NOPM, 0, 0,
837 &da9055_dapm_lineout_control),
838
819 /* Output PGAs */ 839 /* Output PGAs */
820 SND_SOC_DAPM_PGA("MIXOUT Left", DA9055_MIXOUT_L_CTRL, 7, 0, NULL, 0), 840 SND_SOC_DAPM_PGA("MIXOUT Left", DA9055_MIXOUT_L_CTRL, 7, 0, NULL, 0),
821 SND_SOC_DAPM_PGA("MIXOUT Right", DA9055_MIXOUT_R_CTRL, 7, 0, NULL, 0), 841 SND_SOC_DAPM_PGA("MIXOUT Right", DA9055_MIXOUT_R_CTRL, 7, 0, NULL, 0),
@@ -901,17 +921,20 @@ static const struct snd_soc_dapm_route da9055_audio_map[] = {
901 {"Out Mixer Right", "DAC Right Switch", "DAC Right"}, 921 {"Out Mixer Right", "DAC Right Switch", "DAC Right"},
902 922
903 {"MIXOUT Left", NULL, "Out Mixer Left"}, 923 {"MIXOUT Left", NULL, "Out Mixer Left"},
904 {"Headphone Left", NULL, "MIXOUT Left"}, 924 {"Headphone Left Enable", "Switch", "MIXOUT Left"},
925 {"Headphone Left", NULL, "Headphone Left Enable"},
905 {"Headphone Left", NULL, "Charge Pump"}, 926 {"Headphone Left", NULL, "Charge Pump"},
906 {"HPL", NULL, "Headphone Left"}, 927 {"HPL", NULL, "Headphone Left"},
907 928
908 {"MIXOUT Right", NULL, "Out Mixer Right"}, 929 {"MIXOUT Right", NULL, "Out Mixer Right"},
909 {"Headphone Right", NULL, "MIXOUT Right"}, 930 {"Headphone Right Enable", "Switch", "MIXOUT Right"},
931 {"Headphone Right", NULL, "Headphone Right Enable"},
910 {"Headphone Right", NULL, "Charge Pump"}, 932 {"Headphone Right", NULL, "Charge Pump"},
911 {"HPR", NULL, "Headphone Right"}, 933 {"HPR", NULL, "Headphone Right"},
912 934
913 {"MIXOUT Right", NULL, "Out Mixer Right"}, 935 {"MIXOUT Right", NULL, "Out Mixer Right"},
914 {"Lineout", NULL, "MIXOUT Right"}, 936 {"Lineout Enable", "Switch", "MIXOUT Right"},
937 {"Lineout", NULL, "Lineout Enable"},
915 {"LINE", NULL, "Lineout"}, 938 {"LINE", NULL, "Lineout"},
916}; 939};
917 940
@@ -1175,6 +1198,9 @@ static int da9055_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
1175 case SND_SOC_DAIFMT_RIGHT_J: 1198 case SND_SOC_DAIFMT_RIGHT_J:
1176 aif_ctrl = DA9055_AIF_FORMAT_RIGHT_J; 1199 aif_ctrl = DA9055_AIF_FORMAT_RIGHT_J;
1177 break; 1200 break;
1201 case SND_SOC_DAIFMT_DSP_A:
1202 aif_ctrl = DA9055_AIF_FORMAT_DSP;
1203 break;
1178 default: 1204 default:
1179 return -EINVAL; 1205 return -EINVAL;
1180 } 1206 }
@@ -1390,8 +1416,7 @@ static int da9055_probe(struct snd_soc_codec *codec)
1390 DA9055_GAIN_RAMPING_EN, DA9055_GAIN_RAMPING_EN); 1416 DA9055_GAIN_RAMPING_EN, DA9055_GAIN_RAMPING_EN);
1391 1417
1392 /* 1418 /*
1393 * There are two separate control bits for input and output mixers as 1419 * There are two separate control bits for input and output mixers.
1394 * well as headphone and line outs.
1395 * One to enable corresponding amplifier and other to enable its 1420 * One to enable corresponding amplifier and other to enable its
1396 * output. As amplifier bits are related to power control, they are 1421 * output. As amplifier bits are related to power control, they are
1397 * being managed by DAPM while other (non power related) bits are 1422 * being managed by DAPM while other (non power related) bits are
@@ -1407,14 +1432,6 @@ static int da9055_probe(struct snd_soc_codec *codec)
1407 snd_soc_update_bits(codec, DA9055_MIXOUT_R_CTRL, 1432 snd_soc_update_bits(codec, DA9055_MIXOUT_R_CTRL,
1408 DA9055_MIXOUT_R_MIX_EN, DA9055_MIXOUT_R_MIX_EN); 1433 DA9055_MIXOUT_R_MIX_EN, DA9055_MIXOUT_R_MIX_EN);
1409 1434
1410 snd_soc_update_bits(codec, DA9055_HP_L_CTRL,
1411 DA9055_HP_L_AMP_OE, DA9055_HP_L_AMP_OE);
1412 snd_soc_update_bits(codec, DA9055_HP_R_CTRL,
1413 DA9055_HP_R_AMP_OE, DA9055_HP_R_AMP_OE);
1414
1415 snd_soc_update_bits(codec, DA9055_LINE_CTRL,
1416 DA9055_LINE_AMP_OE, DA9055_LINE_AMP_OE);
1417
1418 /* Set this as per your system configuration */ 1435 /* Set this as per your system configuration */
1419 snd_soc_write(codec, DA9055_PLL_CTRL, DA9055_PLL_INDIV_10_20_MHZ); 1436 snd_soc_write(codec, DA9055_PLL_CTRL, DA9055_PLL_INDIV_10_20_MHZ);
1420 1437
diff --git a/sound/soc/codecs/jz4740.c b/sound/soc/codecs/jz4740.c
index 85d9cabe6d55..9ad1da36887e 100644
--- a/sound/soc/codecs/jz4740.c
+++ b/sound/soc/codecs/jz4740.c
@@ -16,6 +16,7 @@
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <linux/io.h> 18#include <linux/io.h>
19#include <linux/regmap.h>
19 20
20#include <linux/delay.h> 21#include <linux/delay.h>
21 22
@@ -24,9 +25,10 @@
24#include <sound/pcm_params.h> 25#include <sound/pcm_params.h>
25#include <sound/initval.h> 26#include <sound/initval.h>
26#include <sound/soc.h> 27#include <sound/soc.h>
28#include <sound/tlv.h>
27 29
28#define JZ4740_REG_CODEC_1 0x0 30#define JZ4740_REG_CODEC_1 0x0
29#define JZ4740_REG_CODEC_2 0x1 31#define JZ4740_REG_CODEC_2 0x4
30 32
31#define JZ4740_CODEC_1_LINE_ENABLE BIT(29) 33#define JZ4740_CODEC_1_LINE_ENABLE BIT(29)
32#define JZ4740_CODEC_1_MIC_ENABLE BIT(28) 34#define JZ4740_CODEC_1_MIC_ENABLE BIT(28)
@@ -67,43 +69,36 @@
67#define JZ4740_CODEC_2_MIC_BOOST_GAIN_OFFSET 4 69#define JZ4740_CODEC_2_MIC_BOOST_GAIN_OFFSET 4
68#define JZ4740_CODEC_2_HEADPHONE_VOLUME_OFFSET 0 70#define JZ4740_CODEC_2_HEADPHONE_VOLUME_OFFSET 0
69 71
70static const uint32_t jz4740_codec_regs[] = { 72static const struct reg_default jz4740_codec_reg_defaults[] = {
71 0x021b2302, 0x00170803, 73 { JZ4740_REG_CODEC_1, 0x021b2302 },
74 { JZ4740_REG_CODEC_2, 0x00170803 },
72}; 75};
73 76
74struct jz4740_codec { 77struct jz4740_codec {
75 void __iomem *base; 78 struct regmap *regmap;
76 struct resource *mem;
77}; 79};
78 80
79static unsigned int jz4740_codec_read(struct snd_soc_codec *codec, 81static const unsigned int jz4740_mic_tlv[] = {
80 unsigned int reg) 82 TLV_DB_RANGE_HEAD(2),
81{ 83 0, 2, TLV_DB_SCALE_ITEM(0, 600, 0),
82 struct jz4740_codec *jz4740_codec = snd_soc_codec_get_drvdata(codec); 84 3, 3, TLV_DB_SCALE_ITEM(2000, 0, 0),
83 return readl(jz4740_codec->base + (reg << 2)); 85};
84}
85
86static int jz4740_codec_write(struct snd_soc_codec *codec, unsigned int reg,
87 unsigned int val)
88{
89 struct jz4740_codec *jz4740_codec = snd_soc_codec_get_drvdata(codec);
90 u32 *cache = codec->reg_cache;
91
92 cache[reg] = val;
93 writel(val, jz4740_codec->base + (reg << 2));
94 86
95 return 0; 87static const DECLARE_TLV_DB_SCALE(jz4740_out_tlv, 0, 200, 0);
96} 88static const DECLARE_TLV_DB_SCALE(jz4740_in_tlv, -3450, 150, 0);
97 89
98static const struct snd_kcontrol_new jz4740_codec_controls[] = { 90static const struct snd_kcontrol_new jz4740_codec_controls[] = {
99 SOC_SINGLE("Master Playback Volume", JZ4740_REG_CODEC_2, 91 SOC_SINGLE_TLV("Master Playback Volume", JZ4740_REG_CODEC_2,
100 JZ4740_CODEC_2_HEADPHONE_VOLUME_OFFSET, 3, 0), 92 JZ4740_CODEC_2_HEADPHONE_VOLUME_OFFSET, 3, 0,
101 SOC_SINGLE("Master Capture Volume", JZ4740_REG_CODEC_2, 93 jz4740_out_tlv),
102 JZ4740_CODEC_2_INPUT_VOLUME_OFFSET, 31, 0), 94 SOC_SINGLE_TLV("Master Capture Volume", JZ4740_REG_CODEC_2,
95 JZ4740_CODEC_2_INPUT_VOLUME_OFFSET, 31, 0,
96 jz4740_in_tlv),
103 SOC_SINGLE("Master Playback Switch", JZ4740_REG_CODEC_1, 97 SOC_SINGLE("Master Playback Switch", JZ4740_REG_CODEC_1,
104 JZ4740_CODEC_1_HEADPHONE_DISABLE_OFFSET, 1, 1), 98 JZ4740_CODEC_1_HEADPHONE_DISABLE_OFFSET, 1, 1),
105 SOC_SINGLE("Mic Capture Volume", JZ4740_REG_CODEC_2, 99 SOC_SINGLE_TLV("Mic Capture Volume", JZ4740_REG_CODEC_2,
106 JZ4740_CODEC_2_MIC_BOOST_GAIN_OFFSET, 3, 0), 100 JZ4740_CODEC_2_MIC_BOOST_GAIN_OFFSET, 3, 0,
101 jz4740_mic_tlv),
107}; 102};
108 103
109static const struct snd_kcontrol_new jz4740_codec_output_controls[] = { 104static const struct snd_kcontrol_new jz4740_codec_output_controls[] = {
@@ -163,8 +158,8 @@ static const struct snd_soc_dapm_route jz4740_codec_dapm_routes[] = {
163static int jz4740_codec_hw_params(struct snd_pcm_substream *substream, 158static int jz4740_codec_hw_params(struct snd_pcm_substream *substream,
164 struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) 159 struct snd_pcm_hw_params *params, struct snd_soc_dai *dai)
165{ 160{
161 struct jz4740_codec *jz4740_codec = snd_soc_codec_get_drvdata(dai->codec);
166 uint32_t val; 162 uint32_t val;
167 struct snd_soc_codec *codec = dai->codec;
168 163
169 switch (params_rate(params)) { 164 switch (params_rate(params)) {
170 case 8000: 165 case 8000:
@@ -200,7 +195,7 @@ static int jz4740_codec_hw_params(struct snd_pcm_substream *substream,
200 195
201 val <<= JZ4740_CODEC_2_SAMPLE_RATE_OFFSET; 196 val <<= JZ4740_CODEC_2_SAMPLE_RATE_OFFSET;
202 197
203 snd_soc_update_bits(codec, JZ4740_REG_CODEC_2, 198 regmap_update_bits(jz4740_codec->regmap, JZ4740_REG_CODEC_2,
204 JZ4740_CODEC_2_SAMPLE_RATE_MASK, val); 199 JZ4740_CODEC_2_SAMPLE_RATE_MASK, val);
205 200
206 return 0; 201 return 0;
@@ -230,25 +225,23 @@ static struct snd_soc_dai_driver jz4740_codec_dai = {
230 .symmetric_rates = 1, 225 .symmetric_rates = 1,
231}; 226};
232 227
233static void jz4740_codec_wakeup(struct snd_soc_codec *codec) 228static void jz4740_codec_wakeup(struct regmap *regmap)
234{ 229{
235 int i; 230 regmap_update_bits(regmap, JZ4740_REG_CODEC_1,
236 uint32_t *cache = codec->reg_cache;
237
238 snd_soc_update_bits(codec, JZ4740_REG_CODEC_1,
239 JZ4740_CODEC_1_RESET, JZ4740_CODEC_1_RESET); 231 JZ4740_CODEC_1_RESET, JZ4740_CODEC_1_RESET);
240 udelay(2); 232 udelay(2);
241 233
242 snd_soc_update_bits(codec, JZ4740_REG_CODEC_1, 234 regmap_update_bits(regmap, JZ4740_REG_CODEC_1,
243 JZ4740_CODEC_1_SUSPEND | JZ4740_CODEC_1_RESET, 0); 235 JZ4740_CODEC_1_SUSPEND | JZ4740_CODEC_1_RESET, 0);
244 236
245 for (i = 0; i < ARRAY_SIZE(jz4740_codec_regs); ++i) 237 regcache_sync(regmap);
246 jz4740_codec_write(codec, i, cache[i]);
247} 238}
248 239
249static int jz4740_codec_set_bias_level(struct snd_soc_codec *codec, 240static int jz4740_codec_set_bias_level(struct snd_soc_codec *codec,
250 enum snd_soc_bias_level level) 241 enum snd_soc_bias_level level)
251{ 242{
243 struct jz4740_codec *jz4740_codec = snd_soc_codec_get_drvdata(codec);
244 struct regmap *regmap = jz4740_codec->regmap;
252 unsigned int mask; 245 unsigned int mask;
253 unsigned int value; 246 unsigned int value;
254 247
@@ -261,12 +254,12 @@ static int jz4740_codec_set_bias_level(struct snd_soc_codec *codec,
261 JZ4740_CODEC_1_HEADPHONE_POWERDOWN_M; 254 JZ4740_CODEC_1_HEADPHONE_POWERDOWN_M;
262 value = 0; 255 value = 0;
263 256
264 snd_soc_update_bits(codec, JZ4740_REG_CODEC_1, mask, value); 257 regmap_update_bits(regmap, JZ4740_REG_CODEC_1, mask, value);
265 break; 258 break;
266 case SND_SOC_BIAS_STANDBY: 259 case SND_SOC_BIAS_STANDBY:
267 /* The only way to clear the suspend flag is to reset the codec */ 260 /* The only way to clear the suspend flag is to reset the codec */
268 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) 261 if (codec->dapm.bias_level == SND_SOC_BIAS_OFF)
269 jz4740_codec_wakeup(codec); 262 jz4740_codec_wakeup(regmap);
270 263
271 mask = JZ4740_CODEC_1_VREF_DISABLE | 264 mask = JZ4740_CODEC_1_VREF_DISABLE |
272 JZ4740_CODEC_1_VREF_AMP_DISABLE | 265 JZ4740_CODEC_1_VREF_AMP_DISABLE |
@@ -275,13 +268,14 @@ static int jz4740_codec_set_bias_level(struct snd_soc_codec *codec,
275 JZ4740_CODEC_1_VREF_AMP_DISABLE | 268 JZ4740_CODEC_1_VREF_AMP_DISABLE |
276 JZ4740_CODEC_1_HEADPHONE_POWERDOWN_M; 269 JZ4740_CODEC_1_HEADPHONE_POWERDOWN_M;
277 270
278 snd_soc_update_bits(codec, JZ4740_REG_CODEC_1, mask, value); 271 regmap_update_bits(regmap, JZ4740_REG_CODEC_1, mask, value);
279 break; 272 break;
280 case SND_SOC_BIAS_OFF: 273 case SND_SOC_BIAS_OFF:
281 mask = JZ4740_CODEC_1_SUSPEND; 274 mask = JZ4740_CODEC_1_SUSPEND;
282 value = JZ4740_CODEC_1_SUSPEND; 275 value = JZ4740_CODEC_1_SUSPEND;
283 276
284 snd_soc_update_bits(codec, JZ4740_REG_CODEC_1, mask, value); 277 regmap_update_bits(regmap, JZ4740_REG_CODEC_1, mask, value);
278 regcache_mark_dirty(regmap);
285 break; 279 break;
286 default: 280 default:
287 break; 281 break;
@@ -294,7 +288,9 @@ static int jz4740_codec_set_bias_level(struct snd_soc_codec *codec,
294 288
295static int jz4740_codec_dev_probe(struct snd_soc_codec *codec) 289static int jz4740_codec_dev_probe(struct snd_soc_codec *codec)
296{ 290{
297 snd_soc_update_bits(codec, JZ4740_REG_CODEC_1, 291 struct jz4740_codec *jz4740_codec = snd_soc_codec_get_drvdata(codec);
292
293 regmap_update_bits(jz4740_codec->regmap, JZ4740_REG_CODEC_1,
298 JZ4740_CODEC_1_SW2_ENABLE, JZ4740_CODEC_1_SW2_ENABLE); 294 JZ4740_CODEC_1_SW2_ENABLE, JZ4740_CODEC_1_SW2_ENABLE);
299 295
300 jz4740_codec_set_bias_level(codec, SND_SOC_BIAS_STANDBY); 296 jz4740_codec_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
@@ -331,12 +327,7 @@ static struct snd_soc_codec_driver soc_codec_dev_jz4740_codec = {
331 .remove = jz4740_codec_dev_remove, 327 .remove = jz4740_codec_dev_remove,
332 .suspend = jz4740_codec_suspend, 328 .suspend = jz4740_codec_suspend,
333 .resume = jz4740_codec_resume, 329 .resume = jz4740_codec_resume,
334 .read = jz4740_codec_read,
335 .write = jz4740_codec_write,
336 .set_bias_level = jz4740_codec_set_bias_level, 330 .set_bias_level = jz4740_codec_set_bias_level,
337 .reg_cache_default = jz4740_codec_regs,
338 .reg_word_size = sizeof(u32),
339 .reg_cache_size = 2,
340 331
341 .controls = jz4740_codec_controls, 332 .controls = jz4740_codec_controls,
342 .num_controls = ARRAY_SIZE(jz4740_codec_controls), 333 .num_controls = ARRAY_SIZE(jz4740_codec_controls),
@@ -346,11 +337,23 @@ static struct snd_soc_codec_driver soc_codec_dev_jz4740_codec = {
346 .num_dapm_routes = ARRAY_SIZE(jz4740_codec_dapm_routes), 337 .num_dapm_routes = ARRAY_SIZE(jz4740_codec_dapm_routes),
347}; 338};
348 339
340static const struct regmap_config jz4740_codec_regmap_config = {
341 .reg_bits = 32,
342 .reg_stride = 4,
343 .val_bits = 32,
344 .max_register = JZ4740_REG_CODEC_2,
345
346 .reg_defaults = jz4740_codec_reg_defaults,
347 .num_reg_defaults = ARRAY_SIZE(jz4740_codec_reg_defaults),
348 .cache_type = REGCACHE_RBTREE,
349};
350
349static int __devinit jz4740_codec_probe(struct platform_device *pdev) 351static int __devinit jz4740_codec_probe(struct platform_device *pdev)
350{ 352{
351 int ret; 353 int ret;
352 struct jz4740_codec *jz4740_codec; 354 struct jz4740_codec *jz4740_codec;
353 struct resource *mem; 355 struct resource *mem;
356 void __iomem *base;
354 357
355 jz4740_codec = devm_kzalloc(&pdev->dev, sizeof(*jz4740_codec), 358 jz4740_codec = devm_kzalloc(&pdev->dev, sizeof(*jz4740_codec),
356 GFP_KERNEL); 359 GFP_KERNEL);
@@ -358,56 +361,29 @@ static int __devinit jz4740_codec_probe(struct platform_device *pdev)
358 return -ENOMEM; 361 return -ENOMEM;
359 362
360 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 363 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
361 if (!mem) { 364 base = devm_request_and_ioremap(&pdev->dev, mem);
362 dev_err(&pdev->dev, "Failed to get mmio memory resource\n"); 365 if (!base)
363 ret = -ENOENT; 366 return -EBUSY;
364 goto err_out;
365 }
366
367 mem = request_mem_region(mem->start, resource_size(mem), pdev->name);
368 if (!mem) {
369 dev_err(&pdev->dev, "Failed to request mmio memory region\n");
370 ret = -EBUSY;
371 goto err_out;
372 }
373 367
374 jz4740_codec->base = ioremap(mem->start, resource_size(mem)); 368 jz4740_codec->regmap = devm_regmap_init_mmio(&pdev->dev, base,
375 if (!jz4740_codec->base) { 369 &jz4740_codec_regmap_config);
376 dev_err(&pdev->dev, "Failed to ioremap mmio memory\n"); 370 if (IS_ERR(jz4740_codec->regmap))
377 ret = -EBUSY; 371 return PTR_ERR(jz4740_codec->regmap);
378 goto err_release_mem_region;
379 }
380 jz4740_codec->mem = mem;
381 372
382 platform_set_drvdata(pdev, jz4740_codec); 373 platform_set_drvdata(pdev, jz4740_codec);
383 374
384 ret = snd_soc_register_codec(&pdev->dev, 375 ret = snd_soc_register_codec(&pdev->dev,
385 &soc_codec_dev_jz4740_codec, &jz4740_codec_dai, 1); 376 &soc_codec_dev_jz4740_codec, &jz4740_codec_dai, 1);
386 if (ret) { 377 if (ret)
387 dev_err(&pdev->dev, "Failed to register codec\n"); 378 dev_err(&pdev->dev, "Failed to register codec\n");
388 goto err_iounmap;
389 }
390 379
391 return 0;
392
393err_iounmap:
394 iounmap(jz4740_codec->base);
395err_release_mem_region:
396 release_mem_region(mem->start, resource_size(mem));
397err_out:
398 return ret; 380 return ret;
399} 381}
400 382
401static int __devexit jz4740_codec_remove(struct platform_device *pdev) 383static int __devexit jz4740_codec_remove(struct platform_device *pdev)
402{ 384{
403 struct jz4740_codec *jz4740_codec = platform_get_drvdata(pdev);
404 struct resource *mem = jz4740_codec->mem;
405
406 snd_soc_unregister_codec(&pdev->dev); 385 snd_soc_unregister_codec(&pdev->dev);
407 386
408 iounmap(jz4740_codec->base);
409 release_mem_region(mem->start, resource_size(mem));
410
411 platform_set_drvdata(pdev, NULL); 387 platform_set_drvdata(pdev, NULL);
412 388
413 return 0; 389 return 0;
diff --git a/sound/soc/codecs/lm49453.c b/sound/soc/codecs/lm49453.c
index 99b0a9dcff34..096b6aa87f0f 100644
--- a/sound/soc/codecs/lm49453.c
+++ b/sound/soc/codecs/lm49453.c
@@ -1497,7 +1497,7 @@ static __devinit int lm49453_i2c_probe(struct i2c_client *i2c,
1497 1497
1498 i2c_set_clientdata(i2c, lm49453); 1498 i2c_set_clientdata(i2c, lm49453);
1499 1499
1500 lm49453->regmap = regmap_init_i2c(i2c, &lm49453_regmap_config); 1500 lm49453->regmap = devm_regmap_init_i2c(i2c, &lm49453_regmap_config);
1501 if (IS_ERR(lm49453->regmap)) { 1501 if (IS_ERR(lm49453->regmap)) {
1502 ret = PTR_ERR(lm49453->regmap); 1502 ret = PTR_ERR(lm49453->regmap);
1503 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", 1503 dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
@@ -1508,21 +1508,15 @@ static __devinit int lm49453_i2c_probe(struct i2c_client *i2c,
1508 ret = snd_soc_register_codec(&i2c->dev, 1508 ret = snd_soc_register_codec(&i2c->dev,
1509 &soc_codec_dev_lm49453, 1509 &soc_codec_dev_lm49453,
1510 lm49453_dai, ARRAY_SIZE(lm49453_dai)); 1510 lm49453_dai, ARRAY_SIZE(lm49453_dai));
1511 if (ret < 0) { 1511 if (ret < 0)
1512 dev_err(&i2c->dev, "Failed to register codec: %d\n", ret); 1512 dev_err(&i2c->dev, "Failed to register codec: %d\n", ret);
1513 regmap_exit(lm49453->regmap);
1514 return ret;
1515 }
1516 1513
1517 return ret; 1514 return ret;
1518} 1515}
1519 1516
1520static int __devexit lm49453_i2c_remove(struct i2c_client *client) 1517static int __devexit lm49453_i2c_remove(struct i2c_client *client)
1521{ 1518{
1522 struct lm49453_priv *lm49453 = i2c_get_clientdata(client);
1523
1524 snd_soc_unregister_codec(&client->dev); 1519 snd_soc_unregister_codec(&client->dev);
1525 regmap_exit(lm49453->regmap);
1526 return 0; 1520 return 0;
1527} 1521}
1528 1522
diff --git a/sound/soc/codecs/max9768.c b/sound/soc/codecs/max9768.c
index 17b3ec2d05cb..a777de6a1b23 100644
--- a/sound/soc/codecs/max9768.c
+++ b/sound/soc/codecs/max9768.c
@@ -187,7 +187,7 @@ static int __devinit max9768_i2c_probe(struct i2c_client *client,
187 187
188 i2c_set_clientdata(client, max9768); 188 i2c_set_clientdata(client, max9768);
189 189
190 max9768->regmap = regmap_init_i2c(client, &max9768_i2c_regmap_config); 190 max9768->regmap = devm_regmap_init_i2c(client, &max9768_i2c_regmap_config);
191 if (IS_ERR(max9768->regmap)) { 191 if (IS_ERR(max9768->regmap)) {
192 err = PTR_ERR(max9768->regmap); 192 err = PTR_ERR(max9768->regmap);
193 goto err_gpio_free; 193 goto err_gpio_free;
@@ -195,12 +195,10 @@ static int __devinit max9768_i2c_probe(struct i2c_client *client,
195 195
196 err = snd_soc_register_codec(&client->dev, &max9768_codec_driver, NULL, 0); 196 err = snd_soc_register_codec(&client->dev, &max9768_codec_driver, NULL, 0);
197 if (err) 197 if (err)
198 goto err_regmap_free; 198 goto err_gpio_free;
199 199
200 return 0; 200 return 0;
201 201
202 err_regmap_free:
203 regmap_exit(max9768->regmap);
204 err_gpio_free: 202 err_gpio_free:
205 if (gpio_is_valid(max9768->shdn_gpio)) 203 if (gpio_is_valid(max9768->shdn_gpio))
206 gpio_free(max9768->shdn_gpio); 204 gpio_free(max9768->shdn_gpio);
@@ -215,7 +213,6 @@ static int __devexit max9768_i2c_remove(struct i2c_client *client)
215 struct max9768 *max9768 = i2c_get_clientdata(client); 213 struct max9768 *max9768 = i2c_get_clientdata(client);
216 214
217 snd_soc_unregister_codec(&client->dev); 215 snd_soc_unregister_codec(&client->dev);
218 regmap_exit(max9768->regmap);
219 216
220 if (gpio_is_valid(max9768->shdn_gpio)) 217 if (gpio_is_valid(max9768->shdn_gpio))
221 gpio_free(max9768->shdn_gpio); 218 gpio_free(max9768->shdn_gpio);
diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c
index 3264a5169306..b858264235c4 100644
--- a/sound/soc/codecs/max98088.c
+++ b/sound/soc/codecs/max98088.c
@@ -2098,13 +2098,13 @@ static const struct i2c_device_id max98088_i2c_id[] = {
2098MODULE_DEVICE_TABLE(i2c, max98088_i2c_id); 2098MODULE_DEVICE_TABLE(i2c, max98088_i2c_id);
2099 2099
2100static struct i2c_driver max98088_i2c_driver = { 2100static struct i2c_driver max98088_i2c_driver = {
2101 .driver = { 2101 .driver = {
2102 .name = "max98088", 2102 .name = "max98088",
2103 .owner = THIS_MODULE, 2103 .owner = THIS_MODULE,
2104 }, 2104 },
2105 .probe = max98088_i2c_probe, 2105 .probe = max98088_i2c_probe,
2106 .remove = __devexit_p(max98088_i2c_remove), 2106 .remove = max98088_i2c_remove,
2107 .id_table = max98088_i2c_id, 2107 .id_table = max98088_i2c_id,
2108}; 2108};
2109 2109
2110module_i2c_driver(max98088_i2c_driver); 2110module_i2c_driver(max98088_i2c_driver);
diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c
new file mode 100644
index 000000000000..c9772ca3da4f
--- /dev/null
+++ b/sound/soc/codecs/max98090.c
@@ -0,0 +1,577 @@
1/*
2 * max98090.c -- MAX98090 ALSA SoC Audio driver
3 * based on Rev0p8 datasheet
4 *
5 * Copyright (C) 2012 Renesas Solutions Corp.
6 * Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
7 *
8 * Based on
9 *
10 * max98095.c
11 * Copyright 2011 Maxim Integrated Products
12 *
13 * https://github.com/hardkernel/linux/commit/\
14 * 3417d7166b17113b3b33b0a337c74d1c7cc313df#sound/soc/codecs/max98090.c
15 * Copyright 2011 Maxim Integrated Products
16 *
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License version 2 as
19 * published by the Free Software Foundation.
20 */
21
22#include <linux/i2c.h>
23#include <linux/module.h>
24#include <linux/regmap.h>
25#include <sound/soc.h>
26#include <sound/tlv.h>
27
28/*
29 *
30 * MAX98090 Registers Definition
31 *
32 */
33
34/* RESET / STATUS / INTERRUPT REGISTERS */
35#define MAX98090_0x00_SW_RESET 0x00
36#define MAX98090_0x01_INT_STS 0x01
37#define MAX98090_0x02_JACK_STS 0x02
38#define MAX98090_0x03_INT_MASK 0x03
39
40/* QUICK SETUP REGISTERS */
41#define MAX98090_0x04_SYS_CLK 0x04
42#define MAX98090_0x05_SAMPLE_RATE 0x05
43#define MAX98090_0x06_DAI_IF 0x06
44#define MAX98090_0x07_DAC_PATH 0x07
45#define MAX98090_0x08_MIC_TO_ADC 0x08
46#define MAX98090_0x09_LINE_TO_ADC 0x09
47#define MAX98090_0x0A_ANALOG_MIC_LOOP 0x0A
48#define MAX98090_0x0B_ANALOG_LINE_LOOP 0x0B
49
50/* ANALOG INPUT CONFIGURATION REGISTERS */
51#define MAX98090_0x0D_INPUT_CONFIG 0x0D
52#define MAX98090_0x0E_LINE_IN_LVL 0x0E
53#define MAX98090_0x0F_LINI_IN_CFG 0x0F
54#define MAX98090_0x10_MIC1_IN_LVL 0x10
55#define MAX98090_0x11_MIC2_IN_LVL 0x11
56
57/* MICROPHONE CONFIGURATION REGISTERS */
58#define MAX98090_0x12_MIC_BIAS_VOL 0x12
59#define MAX98090_0x13_DIGITAL_MIC_CFG 0x13
60#define MAX98090_0x14_DIGITAL_MIC_MODE 0x14
61
62/* ADC PATH AND CONFIGURATION REGISTERS */
63#define MAX98090_0x15_L_ADC_MIX 0x15
64#define MAX98090_0x16_R_ADC_MIX 0x16
65#define MAX98090_0x17_L_ADC_LVL 0x17
66#define MAX98090_0x18_R_ADC_LVL 0x18
67#define MAX98090_0x19_ADC_BIQUAD_LVL 0x19
68#define MAX98090_0x1A_ADC_SIDETONE 0x1A
69
70/* CLOCK CONFIGURATION REGISTERS */
71#define MAX98090_0x1B_SYS_CLK 0x1B
72#define MAX98090_0x1C_CLK_MODE 0x1C
73#define MAX98090_0x1D_ANY_CLK1 0x1D
74#define MAX98090_0x1E_ANY_CLK2 0x1E
75#define MAX98090_0x1F_ANY_CLK3 0x1F
76#define MAX98090_0x20_ANY_CLK4 0x20
77#define MAX98090_0x21_MASTER_MODE 0x21
78
79/* INTERFACE CONTROL REGISTERS */
80#define MAX98090_0x22_DAI_IF_FMT 0x22
81#define MAX98090_0x23_DAI_TDM_FMT1 0x23
82#define MAX98090_0x24_DAI_TDM_FMT2 0x24
83#define MAX98090_0x25_DAI_IO_CFG 0x25
84#define MAX98090_0x26_FILTER_CFG 0x26
85#define MAX98090_0x27_DAI_PLAYBACK_LVL 0x27
86#define MAX98090_0x28_EQ_PLAYBACK_LVL 0x28
87
88/* HEADPHONE CONTROL REGISTERS */
89#define MAX98090_0x29_L_HP_MIX 0x29
90#define MAX98090_0x2A_R_HP_MIX 0x2A
91#define MAX98090_0x2B_HP_CTR 0x2B
92#define MAX98090_0x2C_L_HP_VOL 0x2C
93#define MAX98090_0x2D_R_HP_VOL 0x2D
94
95/* SPEAKER CONFIGURATION REGISTERS */
96#define MAX98090_0x2E_L_SPK_MIX 0x2E
97#define MAX98090_0x2F_R_SPK_MIX 0x2F
98#define MAX98090_0x30_SPK_CTR 0x30
99#define MAX98090_0x31_L_SPK_VOL 0x31
100#define MAX98090_0x32_R_SPK_VOL 0x32
101
102/* ALC CONFIGURATION REGISTERS */
103#define MAX98090_0x33_ALC_TIMING 0x33
104#define MAX98090_0x34_ALC_COMPRESSOR 0x34
105#define MAX98090_0x35_ALC_EXPANDER 0x35
106#define MAX98090_0x36_ALC_GAIN 0x36
107
108/* RECEIVER AND LINE_OUTPUT REGISTERS */
109#define MAX98090_0x37_RCV_LOUT_L_MIX 0x37
110#define MAX98090_0x38_RCV_LOUT_L_CNTL 0x38
111#define MAX98090_0x39_RCV_LOUT_L_VOL 0x39
112#define MAX98090_0x3A_LOUT_R_MIX 0x3A
113#define MAX98090_0x3B_LOUT_R_CNTL 0x3B
114#define MAX98090_0x3C_LOUT_R_VOL 0x3C
115
116/* JACK DETECT AND ENABLE REGISTERS */
117#define MAX98090_0x3D_JACK_DETECT 0x3D
118#define MAX98090_0x3E_IN_ENABLE 0x3E
119#define MAX98090_0x3F_OUT_ENABLE 0x3F
120#define MAX98090_0x40_LVL_CTR 0x40
121#define MAX98090_0x41_DSP_FILTER_ENABLE 0x41
122
123/* BIAS AND POWER MODE CONFIGURATION REGISTERS */
124#define MAX98090_0x42_BIAS_CTR 0x42
125#define MAX98090_0x43_DAC_CTR 0x43
126#define MAX98090_0x44_ADC_CTR 0x44
127#define MAX98090_0x45_DEV_SHUTDOWN 0x45
128
129/* REVISION ID REGISTER */
130#define MAX98090_0xFF_REV_ID 0xFF
131
132#define MAX98090_REG_MAX_CACHED 0x45
133#define MAX98090_REG_END 0xFF
134
135/*
136 *
137 * MAX98090 Registers Bit Fields
138 *
139 */
140
141/* MAX98090_0x06_DAI_IF */
142#define MAX98090_DAI_IF_MASK 0x3F
143#define MAX98090_RJ_M (1 << 5)
144#define MAX98090_RJ_S (1 << 4)
145#define MAX98090_LJ_M (1 << 3)
146#define MAX98090_LJ_S (1 << 2)
147#define MAX98090_I2S_M (1 << 1)
148#define MAX98090_I2S_S (1 << 0)
149
150/* MAX98090_0x45_DEV_SHUTDOWN */
151#define MAX98090_SHDNRUN (1 << 7)
152
153/* codec private data */
154struct max98090_priv {
155 struct regmap *regmap;
156};
157
158static const struct reg_default max98090_reg_defaults[] = {
159 /* RESET / STATUS / INTERRUPT REGISTERS */
160 {MAX98090_0x00_SW_RESET, 0x00},
161 {MAX98090_0x01_INT_STS, 0x00},
162 {MAX98090_0x02_JACK_STS, 0x00},
163 {MAX98090_0x03_INT_MASK, 0x04},
164
165 /* QUICK SETUP REGISTERS */
166 {MAX98090_0x04_SYS_CLK, 0x00},
167 {MAX98090_0x05_SAMPLE_RATE, 0x00},
168 {MAX98090_0x06_DAI_IF, 0x00},
169 {MAX98090_0x07_DAC_PATH, 0x00},
170 {MAX98090_0x08_MIC_TO_ADC, 0x00},
171 {MAX98090_0x09_LINE_TO_ADC, 0x00},
172 {MAX98090_0x0A_ANALOG_MIC_LOOP, 0x00},
173 {MAX98090_0x0B_ANALOG_LINE_LOOP, 0x00},
174
175 /* ANALOG INPUT CONFIGURATION REGISTERS */
176 {MAX98090_0x0D_INPUT_CONFIG, 0x00},
177 {MAX98090_0x0E_LINE_IN_LVL, 0x1B},
178 {MAX98090_0x0F_LINI_IN_CFG, 0x00},
179 {MAX98090_0x10_MIC1_IN_LVL, 0x11},
180 {MAX98090_0x11_MIC2_IN_LVL, 0x11},
181
182 /* MICROPHONE CONFIGURATION REGISTERS */
183 {MAX98090_0x12_MIC_BIAS_VOL, 0x00},
184 {MAX98090_0x13_DIGITAL_MIC_CFG, 0x00},
185 {MAX98090_0x14_DIGITAL_MIC_MODE, 0x00},
186
187 /* ADC PATH AND CONFIGURATION REGISTERS */
188 {MAX98090_0x15_L_ADC_MIX, 0x00},
189 {MAX98090_0x16_R_ADC_MIX, 0x00},
190 {MAX98090_0x17_L_ADC_LVL, 0x03},
191 {MAX98090_0x18_R_ADC_LVL, 0x03},
192 {MAX98090_0x19_ADC_BIQUAD_LVL, 0x00},
193 {MAX98090_0x1A_ADC_SIDETONE, 0x00},
194
195 /* CLOCK CONFIGURATION REGISTERS */
196 {MAX98090_0x1B_SYS_CLK, 0x00},
197 {MAX98090_0x1C_CLK_MODE, 0x00},
198 {MAX98090_0x1D_ANY_CLK1, 0x00},
199 {MAX98090_0x1E_ANY_CLK2, 0x00},
200 {MAX98090_0x1F_ANY_CLK3, 0x00},
201 {MAX98090_0x20_ANY_CLK4, 0x00},
202 {MAX98090_0x21_MASTER_MODE, 0x00},
203
204 /* INTERFACE CONTROL REGISTERS */
205 {MAX98090_0x22_DAI_IF_FMT, 0x00},
206 {MAX98090_0x23_DAI_TDM_FMT1, 0x00},
207 {MAX98090_0x24_DAI_TDM_FMT2, 0x00},
208 {MAX98090_0x25_DAI_IO_CFG, 0x00},
209 {MAX98090_0x26_FILTER_CFG, 0x80},
210 {MAX98090_0x27_DAI_PLAYBACK_LVL, 0x00},
211 {MAX98090_0x28_EQ_PLAYBACK_LVL, 0x00},
212
213 /* HEADPHONE CONTROL REGISTERS */
214 {MAX98090_0x29_L_HP_MIX, 0x00},
215 {MAX98090_0x2A_R_HP_MIX, 0x00},
216 {MAX98090_0x2B_HP_CTR, 0x00},
217 {MAX98090_0x2C_L_HP_VOL, 0x1A},
218 {MAX98090_0x2D_R_HP_VOL, 0x1A},
219
220 /* SPEAKER CONFIGURATION REGISTERS */
221 {MAX98090_0x2E_L_SPK_MIX, 0x00},
222 {MAX98090_0x2F_R_SPK_MIX, 0x00},
223 {MAX98090_0x30_SPK_CTR, 0x00},
224 {MAX98090_0x31_L_SPK_VOL, 0x2C},
225 {MAX98090_0x32_R_SPK_VOL, 0x2C},
226
227 /* ALC CONFIGURATION REGISTERS */
228 {MAX98090_0x33_ALC_TIMING, 0x00},
229 {MAX98090_0x34_ALC_COMPRESSOR, 0x00},
230 {MAX98090_0x35_ALC_EXPANDER, 0x00},
231 {MAX98090_0x36_ALC_GAIN, 0x00},
232
233 /* RECEIVER AND LINE_OUTPUT REGISTERS */
234 {MAX98090_0x37_RCV_LOUT_L_MIX, 0x00},
235 {MAX98090_0x38_RCV_LOUT_L_CNTL, 0x00},
236 {MAX98090_0x39_RCV_LOUT_L_VOL, 0x15},
237 {MAX98090_0x3A_LOUT_R_MIX, 0x00},
238 {MAX98090_0x3B_LOUT_R_CNTL, 0x00},
239 {MAX98090_0x3C_LOUT_R_VOL, 0x15},
240
241 /* JACK DETECT AND ENABLE REGISTERS */
242 {MAX98090_0x3D_JACK_DETECT, 0x00},
243 {MAX98090_0x3E_IN_ENABLE, 0x00},
244 {MAX98090_0x3F_OUT_ENABLE, 0x00},
245 {MAX98090_0x40_LVL_CTR, 0x00},
246 {MAX98090_0x41_DSP_FILTER_ENABLE, 0x00},
247
248 /* BIAS AND POWER MODE CONFIGURATION REGISTERS */
249 {MAX98090_0x42_BIAS_CTR, 0x00},
250 {MAX98090_0x43_DAC_CTR, 0x00},
251 {MAX98090_0x44_ADC_CTR, 0x06},
252 {MAX98090_0x45_DEV_SHUTDOWN, 0x00},
253};
254
255static const unsigned int max98090_hp_tlv[] = {
256 TLV_DB_RANGE_HEAD(5),
257 0x0, 0x6, TLV_DB_SCALE_ITEM(-6700, 400, 0),
258 0x7, 0xE, TLV_DB_SCALE_ITEM(-4000, 300, 0),
259 0xF, 0x15, TLV_DB_SCALE_ITEM(-1700, 200, 0),
260 0x16, 0x1B, TLV_DB_SCALE_ITEM(-400, 100, 0),
261 0x1C, 0x1F, TLV_DB_SCALE_ITEM(150, 50, 0),
262};
263
264static struct snd_kcontrol_new max98090_snd_controls[] = {
265 SOC_DOUBLE_R_TLV("Headphone Volume", MAX98090_0x2C_L_HP_VOL,
266 MAX98090_0x2D_R_HP_VOL, 0, 31, 0, max98090_hp_tlv),
267};
268
269/* Left HeadPhone Mixer Switch */
270static struct snd_kcontrol_new max98090_left_hp_mixer_controls[] = {
271 SOC_DAPM_SINGLE("DACR Switch", MAX98090_0x29_L_HP_MIX, 1, 1, 0),
272 SOC_DAPM_SINGLE("DACL Switch", MAX98090_0x29_L_HP_MIX, 0, 1, 0),
273};
274
275/* Right HeadPhone Mixer Switch */
276static struct snd_kcontrol_new max98090_right_hp_mixer_controls[] = {
277 SOC_DAPM_SINGLE("DACR Switch", MAX98090_0x2A_R_HP_MIX, 1, 1, 0),
278 SOC_DAPM_SINGLE("DACL Switch", MAX98090_0x2A_R_HP_MIX, 0, 1, 0),
279};
280
281static struct snd_soc_dapm_widget max98090_dapm_widgets[] = {
282 /* Output */
283 SND_SOC_DAPM_OUTPUT("HPL"),
284 SND_SOC_DAPM_OUTPUT("HPR"),
285
286 /* PGA */
287 SND_SOC_DAPM_PGA("HPL Out", MAX98090_0x3F_OUT_ENABLE, 7, 0, NULL, 0),
288 SND_SOC_DAPM_PGA("HPR Out", MAX98090_0x3F_OUT_ENABLE, 6, 0, NULL, 0),
289
290 /* Mixer */
291 SND_SOC_DAPM_MIXER("HPL Mixer", SND_SOC_NOPM, 0, 0,
292 max98090_left_hp_mixer_controls,
293 ARRAY_SIZE(max98090_left_hp_mixer_controls)),
294
295 SND_SOC_DAPM_MIXER("HPR Mixer", SND_SOC_NOPM, 0, 0,
296 max98090_right_hp_mixer_controls,
297 ARRAY_SIZE(max98090_right_hp_mixer_controls)),
298
299 /* DAC */
300 SND_SOC_DAPM_DAC("DACL", "Hifi Playback", MAX98090_0x3F_OUT_ENABLE, 0, 0),
301 SND_SOC_DAPM_DAC("DACR", "Hifi Playback", MAX98090_0x3F_OUT_ENABLE, 1, 0),
302};
303
304static struct snd_soc_dapm_route max98090_audio_map[] = {
305 /* Output */
306 {"HPL", NULL, "HPL Out"},
307 {"HPR", NULL, "HPR Out"},
308
309 /* PGA */
310 {"HPL Out", NULL, "HPL Mixer"},
311 {"HPR Out", NULL, "HPR Mixer"},
312
313 /* Mixer*/
314 {"HPL Mixer", "DACR Switch", "DACR"},
315 {"HPL Mixer", "DACL Switch", "DACL"},
316
317 {"HPR Mixer", "DACR Switch", "DACR"},
318 {"HPR Mixer", "DACL Switch", "DACL"},
319};
320
321static bool max98090_volatile(struct device *dev, unsigned int reg)
322{
323 if ((reg == MAX98090_0x01_INT_STS) ||
324 (reg == MAX98090_0x02_JACK_STS) ||
325 (reg > MAX98090_REG_MAX_CACHED))
326 return true;
327
328 return false;
329}
330
331static int max98090_dai_hw_params(struct snd_pcm_substream *substream,
332 struct snd_pcm_hw_params *params,
333 struct snd_soc_dai *dai)
334{
335 struct snd_soc_codec *codec = dai->codec;
336 unsigned int val;
337
338 switch (params_rate(params)) {
339 case 96000:
340 val = 1 << 5;
341 break;
342 case 32000:
343 val = 1 << 4;
344 break;
345 case 48000:
346 val = 1 << 3;
347 break;
348 case 44100:
349 val = 1 << 2;
350 break;
351 case 16000:
352 val = 1 << 1;
353 break;
354 case 8000:
355 val = 1 << 0;
356 break;
357 default:
358 dev_err(codec->dev, "unsupported rate\n");
359 return -EINVAL;
360 }
361 snd_soc_update_bits(codec, MAX98090_0x05_SAMPLE_RATE, 0x03F, val);
362
363 return 0;
364}
365
366static int max98090_dai_set_sysclk(struct snd_soc_dai *dai,
367 int clk_id, unsigned int freq, int dir)
368{
369 struct snd_soc_codec *codec = dai->codec;
370 unsigned int val;
371
372 snd_soc_update_bits(codec, MAX98090_0x45_DEV_SHUTDOWN,
373 MAX98090_SHDNRUN, 0);
374
375 switch (freq) {
376 case 26000000:
377 val = 1 << 7;
378 break;
379 case 19200000:
380 val = 1 << 6;
381 break;
382 case 13000000:
383 val = 1 << 5;
384 break;
385 case 12288000:
386 val = 1 << 4;
387 break;
388 case 12000000:
389 val = 1 << 3;
390 break;
391 case 11289600:
392 val = 1 << 2;
393 break;
394 default:
395 dev_err(codec->dev, "Invalid master clock frequency\n");
396 return -EINVAL;
397 }
398 snd_soc_update_bits(codec, MAX98090_0x04_SYS_CLK, 0xFD, val);
399
400 snd_soc_update_bits(codec, MAX98090_0x45_DEV_SHUTDOWN,
401 MAX98090_SHDNRUN, MAX98090_SHDNRUN);
402
403 dev_dbg(dai->dev, "sysclk is %uHz\n", freq);
404
405 return 0;
406}
407
408static int max98090_dai_set_fmt(struct snd_soc_dai *dai,
409 unsigned int fmt)
410{
411 struct snd_soc_codec *codec = dai->codec;
412 int is_master;
413 u8 val;
414
415 /* master/slave mode */
416 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
417 case SND_SOC_DAIFMT_CBM_CFM:
418 is_master = 1;
419 break;
420 case SND_SOC_DAIFMT_CBS_CFS:
421 is_master = 0;
422 break;
423 default:
424 dev_err(codec->dev, "unsupported clock\n");
425 return -EINVAL;
426 }
427
428 /* format */
429 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
430 case SND_SOC_DAIFMT_I2S:
431 val = (is_master) ? MAX98090_I2S_M : MAX98090_I2S_S;
432 break;
433 case SND_SOC_DAIFMT_RIGHT_J:
434 val = (is_master) ? MAX98090_RJ_M : MAX98090_RJ_S;
435 break;
436 case SND_SOC_DAIFMT_LEFT_J:
437 val = (is_master) ? MAX98090_LJ_M : MAX98090_LJ_S;
438 break;
439 default:
440 dev_err(codec->dev, "unsupported format\n");
441 return -EINVAL;
442 }
443 snd_soc_update_bits(codec, MAX98090_0x06_DAI_IF,
444 MAX98090_DAI_IF_MASK, val);
445
446 return 0;
447}
448
449#define MAX98090_RATES SNDRV_PCM_RATE_8000_96000
450#define MAX98090_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE)
451
452static struct snd_soc_dai_ops max98090_dai_ops = {
453 .set_sysclk = max98090_dai_set_sysclk,
454 .set_fmt = max98090_dai_set_fmt,
455 .hw_params = max98090_dai_hw_params,
456};
457
458static struct snd_soc_dai_driver max98090_dai = {
459 .name = "max98090-Hifi",
460 .playback = {
461 .stream_name = "Playback",
462 .channels_min = 1,
463 .channels_max = 2,
464 .rates = MAX98090_RATES,
465 .formats = MAX98090_FORMATS,
466 },
467 .ops = &max98090_dai_ops,
468};
469
470static int max98090_probe(struct snd_soc_codec *codec)
471{
472 struct max98090_priv *priv = snd_soc_codec_get_drvdata(codec);
473 struct device *dev = codec->dev;
474 int ret;
475
476 codec->control_data = priv->regmap;
477 ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_REGMAP);
478 if (ret < 0) {
479 dev_err(dev, "Failed to set cache I/O: %d\n", ret);
480 return ret;
481 }
482
483 /* Device active */
484 snd_soc_update_bits(codec, MAX98090_0x45_DEV_SHUTDOWN,
485 MAX98090_SHDNRUN, MAX98090_SHDNRUN);
486
487 return 0;
488}
489
490static int max98090_remove(struct snd_soc_codec *codec)
491{
492 return 0;
493}
494
495static struct snd_soc_codec_driver soc_codec_dev_max98090 = {
496 .probe = max98090_probe,
497 .remove = max98090_remove,
498 .controls = max98090_snd_controls,
499 .num_controls = ARRAY_SIZE(max98090_snd_controls),
500 .dapm_widgets = max98090_dapm_widgets,
501 .num_dapm_widgets = ARRAY_SIZE(max98090_dapm_widgets),
502 .dapm_routes = max98090_audio_map,
503 .num_dapm_routes = ARRAY_SIZE(max98090_audio_map),
504};
505
506static const struct regmap_config max98090_regmap = {
507 .reg_bits = 8,
508 .val_bits = 8,
509 .max_register = MAX98090_REG_END,
510 .volatile_reg = max98090_volatile,
511 .cache_type = REGCACHE_RBTREE,
512 .reg_defaults = max98090_reg_defaults,
513 .num_reg_defaults = ARRAY_SIZE(max98090_reg_defaults),
514};
515
516static int max98090_i2c_probe(struct i2c_client *i2c,
517 const struct i2c_device_id *id)
518{
519 struct max98090_priv *priv;
520 struct device *dev = &i2c->dev;
521 unsigned int val;
522 int ret;
523
524 priv = devm_kzalloc(dev, sizeof(struct max98090_priv),
525 GFP_KERNEL);
526 if (!priv)
527 return -ENOMEM;
528
529 priv->regmap = devm_regmap_init_i2c(i2c, &max98090_regmap);
530 if (IS_ERR(priv->regmap)) {
531 ret = PTR_ERR(priv->regmap);
532 dev_err(dev, "Failed to init regmap: %d\n", ret);
533 return ret;
534 }
535
536 i2c_set_clientdata(i2c, priv);
537
538 ret = regmap_read(priv->regmap, MAX98090_0xFF_REV_ID, &val);
539 if (ret < 0) {
540 dev_err(dev, "Failed to read device revision: %d\n", ret);
541 return ret;
542 }
543 dev_info(dev, "revision 0x%02x\n", val);
544
545 ret = snd_soc_register_codec(dev,
546 &soc_codec_dev_max98090,
547 &max98090_dai, 1);
548
549 return ret;
550}
551
552static int max98090_i2c_remove(struct i2c_client *client)
553{
554 snd_soc_unregister_codec(&client->dev);
555 return 0;
556}
557
558static const struct i2c_device_id max98090_i2c_id[] = {
559 { "max98090", 0 },
560 { }
561};
562MODULE_DEVICE_TABLE(i2c, max98090_i2c_id);
563
564static struct i2c_driver max98090_i2c_driver = {
565 .driver = {
566 .name = "max98090",
567 .owner = THIS_MODULE,
568 },
569 .probe = max98090_i2c_probe,
570 .remove = max98090_i2c_remove,
571 .id_table = max98090_i2c_id,
572};
573module_i2c_driver(max98090_i2c_driver);
574
575MODULE_DESCRIPTION("ALSA SoC MAX98090 driver");
576MODULE_AUTHOR("Peter Hsiang, Kuninori Morimoto");
577MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/rt5631.c b/sound/soc/codecs/rt5631.c
index 960d0e93cce9..d6ca615489ee 100644
--- a/sound/soc/codecs/rt5631.c
+++ b/sound/soc/codecs/rt5631.c
@@ -1382,7 +1382,7 @@ static int rt5631_hifi_pcm_params(struct snd_pcm_substream *substream,
1382 timesofbclk); 1382 timesofbclk);
1383 if (coeff < 0) { 1383 if (coeff < 0) {
1384 dev_err(codec->dev, "Fail to get coeff\n"); 1384 dev_err(codec->dev, "Fail to get coeff\n");
1385 return -EINVAL; 1385 return coeff;
1386 } 1386 }
1387 1387
1388 switch (params_format(params)) { 1388 switch (params_format(params)) {
diff --git a/sound/soc/codecs/si476x.c b/sound/soc/codecs/si476x.c
new file mode 100644
index 000000000000..38145ba74db8
--- /dev/null
+++ b/sound/soc/codecs/si476x.c
@@ -0,0 +1,255 @@
1#include <linux/module.h>
2#include <linux/slab.h>
3#include <sound/pcm.h>
4#include <sound/pcm_params.h>
5#include <sound/soc.h>
6#include <sound/initval.h>
7
8#include <linux/i2c.h>
9
10#include <linux/mfd/si476x-core.h>
11
12enum si476x_audio_registers {
13 SI476X_DIGITAL_IO_OUTPUT_FORMAT = 0x0203,
14 SI476X_DIGITAL_IO_OUTPUT_SAMPLE_RATE = 0x0202,
15};
16
17enum si476x_digital_io_output_format {
18 SI476X_DIGITAL_IO_SLOT_SIZE_SHIFT = 11,
19 SI476X_DIGITAL_IO_SAMPLE_SIZE_SHIFT = 8,
20};
21
22#define SI476X_DIGITAL_IO_OUTPUT_WIDTH_MASK ((0b111 << SI476X_DIGITAL_IO_SLOT_SIZE_SHIFT) | \
23 (0b111 << SI476X_DIGITAL_IO_SAMPLE_SIZE_SHIFT))
24#define SI476X_DIGITAL_IO_OUTPUT_FORMAT_MASK (0b1111110)
25
26enum si476x_daudio_formats {
27 SI476X_DAUDIO_MODE_I2S = (0x0 << 1),
28 SI476X_DAUDIO_MODE_DSP_A = (0x6 << 1),
29 SI476X_DAUDIO_MODE_DSP_B = (0x7 << 1),
30 SI476X_DAUDIO_MODE_LEFT_J = (0x8 << 1),
31 SI476X_DAUDIO_MODE_RIGHT_J = (0x9 << 1),
32
33 SI476X_DAUDIO_MODE_IB = (1 << 5),
34 SI476X_DAUDIO_MODE_IF = (1 << 6),
35};
36
37enum si476x_pcm_format {
38 SI476X_PCM_FORMAT_S8 = 2,
39 SI476X_PCM_FORMAT_S16_LE = 4,
40 SI476X_PCM_FORMAT_S20_3LE = 5,
41 SI476X_PCM_FORMAT_S24_LE = 6,
42};
43
44static unsigned int si476x_codec_read(struct snd_soc_codec *codec,
45 unsigned int reg)
46{
47 int err;
48 struct si476x_core *core = codec->control_data;
49
50 si476x_core_lock(core);
51 err = si476x_core_cmd_get_property(core, reg);
52 si476x_core_unlock(core);
53
54 return err;
55}
56
57static int si476x_codec_write(struct snd_soc_codec *codec,
58 unsigned int reg, unsigned int val)
59{
60 int err;
61 struct si476x_core *core = codec->control_data;
62
63 si476x_core_lock(core);
64 err = si476x_core_cmd_set_property(core, reg, val);
65 si476x_core_unlock(core);
66
67 return err;
68}
69
70static int si476x_codec_set_dai_fmt(struct snd_soc_dai *codec_dai,
71 unsigned int fmt)
72{
73 int err;
74 u16 format = 0;
75
76 if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) != SND_SOC_DAIFMT_CBS_CFS)
77 return -EINVAL;
78
79 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
80 case SND_SOC_DAIFMT_DSP_A:
81 format |= SI476X_DAUDIO_MODE_DSP_A;
82 break;
83 case SND_SOC_DAIFMT_DSP_B:
84 format |= SI476X_DAUDIO_MODE_DSP_B;
85 break;
86 case SND_SOC_DAIFMT_I2S:
87 format |= SI476X_DAUDIO_MODE_I2S;
88 break;
89 case SND_SOC_DAIFMT_RIGHT_J:
90 format |= SI476X_DAUDIO_MODE_RIGHT_J;
91 break;
92 case SND_SOC_DAIFMT_LEFT_J:
93 format |= SI476X_DAUDIO_MODE_LEFT_J;
94 break;
95 default:
96 return -EINVAL;
97 }
98
99 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
100 case SND_SOC_DAIFMT_DSP_A:
101 case SND_SOC_DAIFMT_DSP_B:
102 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
103 case SND_SOC_DAIFMT_NB_NF:
104 break;
105 case SND_SOC_DAIFMT_IB_NF:
106 format |= SI476X_DAUDIO_MODE_IB;
107 break;
108 default:
109 return -EINVAL;
110 }
111 break;
112 case SND_SOC_DAIFMT_I2S:
113 case SND_SOC_DAIFMT_RIGHT_J:
114 case SND_SOC_DAIFMT_LEFT_J:
115 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
116 case SND_SOC_DAIFMT_NB_NF:
117 break;
118 case SND_SOC_DAIFMT_IB_IF:
119 format |= SI476X_DAUDIO_MODE_IB |
120 SI476X_DAUDIO_MODE_IF;
121 break;
122 case SND_SOC_DAIFMT_IB_NF:
123 format |= SI476X_DAUDIO_MODE_IB;
124 break;
125 case SND_SOC_DAIFMT_NB_IF:
126 format |= SI476X_DAUDIO_MODE_IF;
127 break;
128 default:
129 return -EINVAL;
130 }
131 break;
132 default:
133 return -EINVAL;
134 }
135
136 err = snd_soc_update_bits(codec_dai->codec, SI476X_DIGITAL_IO_OUTPUT_FORMAT,
137 SI476X_DIGITAL_IO_OUTPUT_FORMAT_MASK,
138 format);
139 if (err < 0) {
140 dev_err(codec_dai->codec->dev, "Failed to set output format\n");
141 return err;
142 }
143
144 return 0;
145}
146
147static int si476x_codec_hw_params(struct snd_pcm_substream *substream,
148 struct snd_pcm_hw_params *params,
149 struct snd_soc_dai *dai)
150{
151 int rate, width, err;
152
153 rate = params_rate(params);
154 if (rate < 32000 || rate > 48000) {
155 dev_err(dai->codec->dev, "Rate: %d is not supported\n", rate);
156 return -EINVAL;
157 }
158
159 switch (params_format(params)) {
160 case SNDRV_PCM_FORMAT_S8:
161 width = SI476X_PCM_FORMAT_S8;
162 case SNDRV_PCM_FORMAT_S16_LE:
163 width = SI476X_PCM_FORMAT_S16_LE;
164 break;
165 case SNDRV_PCM_FORMAT_S20_3LE:
166 width = SI476X_PCM_FORMAT_S20_3LE;
167 break;
168 case SNDRV_PCM_FORMAT_S24_LE:
169 width = SI476X_PCM_FORMAT_S24_LE;
170 break;
171 default:
172 return -EINVAL;
173 }
174
175 err = snd_soc_write(dai->codec, SI476X_DIGITAL_IO_OUTPUT_SAMPLE_RATE,
176 rate);
177 if (err < 0) {
178 dev_err(dai->codec->dev, "Failed to set sample rate\n");
179 return err;
180 }
181
182 err = snd_soc_update_bits(dai->codec, SI476X_DIGITAL_IO_OUTPUT_FORMAT,
183 SI476X_DIGITAL_IO_OUTPUT_WIDTH_MASK,
184 (width << SI476X_DIGITAL_IO_SLOT_SIZE_SHIFT) |
185 (width << SI476X_DIGITAL_IO_SAMPLE_SIZE_SHIFT));
186 if (err < 0) {
187 dev_err(dai->codec->dev, "Failed to set output width\n");
188 return err;
189 }
190
191 return 0;
192}
193
194static int si476x_codec_probe(struct snd_soc_codec *codec)
195{
196 codec->control_data = i2c_mfd_cell_to_core(codec->dev);
197 return 0;
198}
199
200static struct snd_soc_dai_ops si476x_dai_ops = {
201 .hw_params = si476x_codec_hw_params,
202 .set_fmt = si476x_codec_set_dai_fmt,
203};
204
205static struct snd_soc_dai_driver si476x_dai = {
206 .name = "si476x-codec",
207 .capture = {
208 .stream_name = "Capture",
209 .channels_min = 2,
210 .channels_max = 2,
211
212 .rates = SNDRV_PCM_RATE_32000 |
213 SNDRV_PCM_RATE_44100 |
214 SNDRV_PCM_RATE_48000,
215 .formats = SNDRV_PCM_FMTBIT_S8 |
216 SNDRV_PCM_FMTBIT_S16_LE |
217 SNDRV_PCM_FMTBIT_S20_3LE |
218 SNDRV_PCM_FMTBIT_S24_LE
219 },
220 .ops = &si476x_dai_ops,
221};
222
223static struct snd_soc_codec_driver soc_codec_dev_si476x = {
224 .probe = si476x_codec_probe,
225 .read = si476x_codec_read,
226 .write = si476x_codec_write,
227};
228
229static int __devinit si476x_platform_probe(struct platform_device *pdev)
230{
231 return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_si476x,
232 &si476x_dai, 1);
233}
234
235static int __devexit si476x_platform_remove(struct platform_device *pdev)
236{
237 snd_soc_unregister_codec(&pdev->dev);
238 return 0;
239}
240
241MODULE_ALIAS("platform:si476x-codec");
242
243static struct platform_driver si476x_platform_driver = {
244 .driver = {
245 .name = "si476x-codec",
246 .owner = THIS_MODULE,
247 },
248 .probe = si476x_platform_probe,
249 .remove = __devexit_p(si476x_platform_remove),
250};
251module_platform_driver(si476x_platform_driver);
252
253MODULE_AUTHOR("Andrey Smirnov <andrey.smirnov@convergeddevices.net>");
254MODULE_DESCRIPTION("ASoC Si4761/64 codec driver");
255MODULE_LICENSE("GPL");
diff --git a/sound/soc/codecs/tlv320aic32x4.c b/sound/soc/codecs/tlv320aic32x4.c
index f230292ba96b..e39e08d5d8e4 100644
--- a/sound/soc/codecs/tlv320aic32x4.c
+++ b/sound/soc/codecs/tlv320aic32x4.c
@@ -28,6 +28,7 @@
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/pm.h> 30#include <linux/pm.h>
31#include <linux/gpio.h>
31#include <linux/i2c.h> 32#include <linux/i2c.h>
32#include <linux/cdev.h> 33#include <linux/cdev.h>
33#include <linux/slab.h> 34#include <linux/slab.h>
@@ -65,6 +66,7 @@ struct aic32x4_priv {
65 u32 power_cfg; 66 u32 power_cfg;
66 u32 micpga_routing; 67 u32 micpga_routing;
67 bool swapdacs; 68 bool swapdacs;
69 int rstn_gpio;
68}; 70};
69 71
70/* 0dB min, 1dB steps */ 72/* 0dB min, 1dB steps */
@@ -627,10 +629,20 @@ static int aic32x4_probe(struct snd_soc_codec *codec)
627{ 629{
628 struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec); 630 struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec);
629 u32 tmp_reg; 631 u32 tmp_reg;
632 int ret;
630 633
631 codec->hw_write = (hw_write_t) i2c_master_send; 634 codec->hw_write = (hw_write_t) i2c_master_send;
632 codec->control_data = aic32x4->control_data; 635 codec->control_data = aic32x4->control_data;
633 636
637 if (aic32x4->rstn_gpio >= 0) {
638 ret = devm_gpio_request_one(codec->dev, aic32x4->rstn_gpio,
639 GPIOF_OUT_INIT_LOW, "tlv320aic32x4 rstn");
640 if (ret != 0)
641 return ret;
642 ndelay(10);
643 gpio_set_value(aic32x4->rstn_gpio, 1);
644 }
645
634 snd_soc_write(codec, AIC32X4_RESET, 0x01); 646 snd_soc_write(codec, AIC32X4_RESET, 0x01);
635 647
636 /* Power platform configuration */ 648 /* Power platform configuration */
@@ -675,6 +687,16 @@ static int aic32x4_probe(struct snd_soc_codec *codec)
675 ARRAY_SIZE(aic32x4_snd_controls)); 687 ARRAY_SIZE(aic32x4_snd_controls));
676 aic32x4_add_widgets(codec); 688 aic32x4_add_widgets(codec);
677 689
690 /*
691 * Workaround: for an unknown reason, the ADC needs to be powered up
692 * and down for the first capture to work properly. It seems related to
693 * a HW BUG or some kind of behavior not documented in the datasheet.
694 */
695 tmp_reg = snd_soc_read(codec, AIC32X4_ADCSETUP);
696 snd_soc_write(codec, AIC32X4_ADCSETUP, tmp_reg |
697 AIC32X4_LADC_EN | AIC32X4_RADC_EN);
698 snd_soc_write(codec, AIC32X4_ADCSETUP, tmp_reg);
699
678 return 0; 700 return 0;
679} 701}
680 702
@@ -713,10 +735,12 @@ static __devinit int aic32x4_i2c_probe(struct i2c_client *i2c,
713 aic32x4->power_cfg = pdata->power_cfg; 735 aic32x4->power_cfg = pdata->power_cfg;
714 aic32x4->swapdacs = pdata->swapdacs; 736 aic32x4->swapdacs = pdata->swapdacs;
715 aic32x4->micpga_routing = pdata->micpga_routing; 737 aic32x4->micpga_routing = pdata->micpga_routing;
738 aic32x4->rstn_gpio = pdata->rstn_gpio;
716 } else { 739 } else {
717 aic32x4->power_cfg = 0; 740 aic32x4->power_cfg = 0;
718 aic32x4->swapdacs = false; 741 aic32x4->swapdacs = false;
719 aic32x4->micpga_routing = 0; 742 aic32x4->micpga_routing = 0;
743 aic32x4->rstn_gpio = -1;
720 } 744 }
721 745
722 ret = snd_soc_register_codec(&i2c->dev, 746 ret = snd_soc_register_codec(&i2c->dev,
diff --git a/sound/soc/codecs/tlv320aic32x4.h b/sound/soc/codecs/tlv320aic32x4.h
index aae2b2440398..35774223fd91 100644
--- a/sound/soc/codecs/tlv320aic32x4.h
+++ b/sound/soc/codecs/tlv320aic32x4.h
@@ -94,6 +94,9 @@
94#define AIC32X4_WORD_LEN_24BITS 0x02 94#define AIC32X4_WORD_LEN_24BITS 0x02
95#define AIC32X4_WORD_LEN_32BITS 0x03 95#define AIC32X4_WORD_LEN_32BITS 0x03
96 96
97#define AIC32X4_LADC_EN (1 << 7)
98#define AIC32X4_RADC_EN (1 << 6)
99
97#define AIC32X4_I2S_MODE 0x00 100#define AIC32X4_I2S_MODE 0x00
98#define AIC32X4_DSP_MODE 0x01 101#define AIC32X4_DSP_MODE 0x01
99#define AIC32X4_RIGHT_JUSTIFIED_MODE 0x02 102#define AIC32X4_RIGHT_JUSTIFIED_MODE 0x02
diff --git a/sound/soc/codecs/wm0010.c b/sound/soc/codecs/wm0010.c
index 99afc003a084..40256b526259 100644
--- a/sound/soc/codecs/wm0010.c
+++ b/sound/soc/codecs/wm0010.c
@@ -31,6 +31,9 @@
31 31
32#define DEVICE_ID_WM0010 10 32#define DEVICE_ID_WM0010 10
33 33
34/* We only support v1 of the .dfw INFO record */
35#define INFO_VERSION 1
36
34enum dfw_cmd { 37enum dfw_cmd {
35 DFW_CMD_FUSE = 0x01, 38 DFW_CMD_FUSE = 0x01,
36 DFW_CMD_CODE_HDR, 39 DFW_CMD_CODE_HDR,
@@ -46,6 +49,13 @@ struct dfw_binrec {
46 uint8_t data[0]; 49 uint8_t data[0];
47} __packed; 50} __packed;
48 51
52struct dfw_inforec {
53 u8 info_version;
54 u8 tool_major_version;
55 u8 tool_minor_version;
56 u8 dsp_target;
57};
58
49struct dfw_pllrec { 59struct dfw_pllrec {
50 u8 command; 60 u8 command;
51 u32 length:24; 61 u32 length:24;
@@ -97,7 +107,6 @@ struct wm0010_priv {
97 107
98 enum wm0010_state state; 108 enum wm0010_state state;
99 bool boot_failed; 109 bool boot_failed;
100 int boot_done;
101 bool ready; 110 bool ready;
102 bool pll_running; 111 bool pll_running;
103 int max_spi_freq; 112 int max_spi_freq;
@@ -234,7 +243,7 @@ static void wm0010_boot_xfer_complete(void *data)
234 break; 243 break;
235 244
236 case 0x55555555: 245 case 0x55555555:
237 if (wm0010->boot_done == 0) 246 if (wm0010->state < WM0010_STAGE2)
238 break; 247 break;
239 dev_err(codec->dev, 248 dev_err(codec->dev,
240 "%d: ROM bootloader running in stage 2\n", i); 249 "%d: ROM bootloader running in stage 2\n", i);
@@ -321,7 +330,6 @@ static void wm0010_boot_xfer_complete(void *data)
321 break; 330 break;
322 } 331 }
323 332
324 wm0010->boot_done++;
325 if (xfer->done) 333 if (xfer->done)
326 complete(xfer->done); 334 complete(xfer->done);
327} 335}
@@ -334,94 +342,198 @@ static void byte_swap_64(u64 *data_in, u64 *data_out, u32 len)
334 data_out[i] = cpu_to_be64(le64_to_cpu(data_in[i])); 342 data_out[i] = cpu_to_be64(le64_to_cpu(data_in[i]));
335} 343}
336 344
337static int wm0010_boot(struct snd_soc_codec *codec) 345static int wm0010_firmware_load(char *name, struct snd_soc_codec *codec)
338{ 346{
339 struct spi_device *spi = to_spi_device(codec->dev); 347 struct spi_device *spi = to_spi_device(codec->dev);
340 struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); 348 struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec);
341 unsigned long flags;
342 struct list_head xfer_list; 349 struct list_head xfer_list;
343 struct wm0010_boot_xfer *xfer; 350 struct wm0010_boot_xfer *xfer;
344 int ret; 351 int ret;
345 struct completion done; 352 struct completion done;
346 const struct firmware *fw; 353 const struct firmware *fw;
347 const struct dfw_binrec *rec; 354 const struct dfw_binrec *rec;
348 struct spi_message m; 355 const struct dfw_inforec *inforec;
349 struct spi_transfer t; 356 u64 *img;
350 struct dfw_pllrec pll_rec; 357 u8 *out, dsp;
351 u32 *img, *p;
352 u64 *img_swap;
353 u8 *out;
354 u32 len, offset; 358 u32 len, offset;
355 int i;
356 359
357 spin_lock_irqsave(&wm0010->irq_lock, flags); 360 INIT_LIST_HEAD(&xfer_list);
358 if (wm0010->state != WM0010_POWER_OFF)
359 dev_warn(wm0010->dev, "DSP already powered up!\n");
360 spin_unlock_irqrestore(&wm0010->irq_lock, flags);
361 361
362 if (wm0010->sysclk > 26000000) { 362 ret = request_firmware(&fw, name, codec->dev);
363 dev_err(codec->dev, "Max DSP clock frequency is 26MHz\n"); 363 if (ret != 0) {
364 ret = -ECANCELED; 364 dev_err(codec->dev, "Failed to request application: %d\n",
365 goto err; 365 ret);
366 return ret;
366 } 367 }
367 368
368 INIT_LIST_HEAD(&xfer_list); 369 rec = (const struct dfw_binrec *)fw->data;
370 inforec = (const struct dfw_inforec *)rec->data;
371 offset = 0;
372 dsp = inforec->dsp_target;
373 wm0010->boot_failed = false;
374 BUG_ON(!list_empty(&xfer_list));
375 init_completion(&done);
369 376
370 mutex_lock(&wm0010->lock); 377 /* First record should be INFO */
371 wm0010->pll_running = false; 378 if (rec->command != DFW_CMD_INFO) {
379 dev_err(codec->dev, "First record not INFO\r\n");
380 ret = -EINVAL;
381 goto abort;
382 }
372 383
373 dev_dbg(codec->dev, "max_spi_freq: %d\n", wm0010->max_spi_freq); 384 if (inforec->info_version != INFO_VERSION) {
385 dev_err(codec->dev,
386 "Unsupported version (%02d) of INFO record\r\n",
387 inforec->info_version);
388 ret = -EINVAL;
389 goto abort;
390 }
374 391
375 ret = regulator_bulk_enable(ARRAY_SIZE(wm0010->core_supplies), 392 dev_dbg(codec->dev, "Version v%02d INFO record found\r\n",
376 wm0010->core_supplies); 393 inforec->info_version);
377 if (ret != 0) { 394
378 dev_err(&spi->dev, "Failed to enable core supplies: %d\n", 395 /* Check it's a DSP file */
379 ret); 396 if (dsp != DEVICE_ID_WM0010) {
380 mutex_unlock(&wm0010->lock); 397 dev_err(codec->dev, "Not a WM0010 firmware file.\r\n");
381 goto err; 398 ret = -EINVAL;
399 goto abort;
382 } 400 }
383 401
384 ret = regulator_enable(wm0010->dbvdd); 402 /* Skip the info record as we don't need to send it */
385 if (ret != 0) { 403 offset += ((rec->length) + 8);
386 dev_err(&spi->dev, "Failed to enable DBVDD: %d\n", ret); 404 rec = (void *)&rec->data[rec->length];
387 goto err_core; 405
406 while (offset < fw->size) {
407 dev_dbg(codec->dev,
408 "Packet: command %d, data length = 0x%x\r\n",
409 rec->command, rec->length);
410 len = rec->length + 8;
411
412 out = kzalloc(len, GFP_KERNEL);
413 if (!out) {
414 dev_err(codec->dev,
415 "Failed to allocate RX buffer\n");
416 ret = -ENOMEM;
417 goto abort1;
418 }
419
420 img = kzalloc(len, GFP_KERNEL);
421 if (!img) {
422 dev_err(codec->dev,
423 "Failed to allocate image buffer\n");
424 ret = -ENOMEM;
425 goto abort1;
426 }
427
428 byte_swap_64((u64 *)&rec->command, img, len);
429
430 xfer = kzalloc(sizeof(*xfer), GFP_KERNEL);
431 if (!xfer) {
432 dev_err(codec->dev, "Failed to allocate xfer\n");
433 ret = -ENOMEM;
434 goto abort1;
435 }
436
437 xfer->codec = codec;
438 list_add_tail(&xfer->list, &xfer_list);
439
440 spi_message_init(&xfer->m);
441 xfer->m.complete = wm0010_boot_xfer_complete;
442 xfer->m.context = xfer;
443 xfer->t.tx_buf = img;
444 xfer->t.rx_buf = out;
445 xfer->t.len = len;
446 xfer->t.bits_per_word = 8;
447
448 if (!wm0010->pll_running) {
449 xfer->t.speed_hz = wm0010->sysclk / 6;
450 } else {
451 xfer->t.speed_hz = wm0010->max_spi_freq;
452
453 if (wm0010->board_max_spi_speed &&
454 (wm0010->board_max_spi_speed < wm0010->max_spi_freq))
455 xfer->t.speed_hz = wm0010->board_max_spi_speed;
456 }
457
458 /* Store max usable spi frequency for later use */
459 wm0010->max_spi_freq = xfer->t.speed_hz;
460
461 spi_message_add_tail(&xfer->t, &xfer->m);
462
463 offset += ((rec->length) + 8);
464 rec = (void *)&rec->data[rec->length];
465
466 if (offset >= fw->size) {
467 dev_dbg(codec->dev, "All transfers scheduled\n");
468 xfer->done = &done;
469 }
470
471 ret = spi_async(spi, &xfer->m);
472 if (ret != 0) {
473 dev_err(codec->dev, "Write failed: %d\n", ret);
474 goto abort1;
475 }
476
477 if (wm0010->boot_failed) {
478 dev_dbg(codec->dev, "Boot fail!\n");
479 ret = -EINVAL;
480 goto abort1;
481 }
388 } 482 }
389 483
390 /* Release reset */ 484 wait_for_completion(&done);
391 gpio_set_value_cansleep(wm0010->gpio_reset, !wm0010->gpio_reset_value); 485
392 spin_lock_irqsave(&wm0010->irq_lock, flags); 486 ret = 0;
393 wm0010->state = WM0010_OUT_OF_RESET; 487
394 spin_unlock_irqrestore(&wm0010->irq_lock, flags); 488abort1:
489 while (!list_empty(&xfer_list)) {
490 xfer = list_first_entry(&xfer_list, struct wm0010_boot_xfer,
491 list);
492 kfree(xfer->t.rx_buf);
493 kfree(xfer->t.tx_buf);
494 list_del(&xfer->list);
495 kfree(xfer);
496 }
497
498abort:
499 release_firmware(fw);
500 return ret;
501}
502
503static int wm0010_stage2_load(struct snd_soc_codec *codec)
504{
505 struct spi_device *spi = to_spi_device(codec->dev);
506 struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec);
507 const struct firmware *fw;
508 struct spi_message m;
509 struct spi_transfer t;
510 u32 *img;
511 u8 *out;
512 int i;
513 int ret = 0;
395 514
396 /* First the bootloader */
397 ret = request_firmware(&fw, "wm0010_stage2.bin", codec->dev); 515 ret = request_firmware(&fw, "wm0010_stage2.bin", codec->dev);
398 if (ret != 0) { 516 if (ret != 0) {
399 dev_err(codec->dev, "Failed to request stage2 loader: %d\n", 517 dev_err(codec->dev, "Failed to request stage2 loader: %d\n",
400 ret); 518 ret);
401 goto abort; 519 return ret;
402 } 520 }
403 521
404 if (!wait_for_completion_timeout(&wm0010->boot_completion,
405 msecs_to_jiffies(10)))
406 dev_err(codec->dev, "Failed to get interrupt from DSP\n");
407
408 spin_lock_irqsave(&wm0010->irq_lock, flags);
409 wm0010->state = WM0010_BOOTROM;
410 spin_unlock_irqrestore(&wm0010->irq_lock, flags);
411
412 dev_dbg(codec->dev, "Downloading %zu byte stage 2 loader\n", fw->size); 522 dev_dbg(codec->dev, "Downloading %zu byte stage 2 loader\n", fw->size);
413 523
414 /* Copy to local buffer first as vmalloc causes problems for dma */ 524 /* Copy to local buffer first as vmalloc causes problems for dma */
415 img = kzalloc(fw->size, GFP_KERNEL); 525 img = kzalloc(fw->size, GFP_KERNEL);
416 if (!img) { 526 if (!img) {
417 dev_err(codec->dev, "Failed to allocate image buffer\n"); 527 dev_err(codec->dev, "Failed to allocate image buffer\n");
418 goto abort; 528 ret = -ENOMEM;
529 goto abort2;
419 } 530 }
420 531
421 out = kzalloc(fw->size, GFP_KERNEL); 532 out = kzalloc(fw->size, GFP_KERNEL);
422 if (!out) { 533 if (!out) {
423 dev_err(codec->dev, "Failed to allocate output buffer\n"); 534 dev_err(codec->dev, "Failed to allocate output buffer\n");
424 goto abort; 535 ret = -ENOMEM;
536 goto abort1;
425 } 537 }
426 538
427 memcpy(img, &fw->data[0], fw->size); 539 memcpy(img, &fw->data[0], fw->size);
@@ -447,20 +559,97 @@ static int wm0010_boot(struct snd_soc_codec *codec)
447 /* Look for errors from the boot ROM */ 559 /* Look for errors from the boot ROM */
448 for (i = 0; i < fw->size; i++) { 560 for (i = 0; i < fw->size; i++) {
449 if (out[i] != 0x55) { 561 if (out[i] != 0x55) {
450 ret = -EBUSY;
451 dev_err(codec->dev, "Boot ROM error: %x in %d\n", 562 dev_err(codec->dev, "Boot ROM error: %x in %d\n",
452 out[i], i); 563 out[i], i);
453 wm0010_mark_boot_failure(wm0010); 564 wm0010_mark_boot_failure(wm0010);
565 ret = -EBUSY;
454 goto abort; 566 goto abort;
455 } 567 }
456 } 568 }
457 569abort:
458 release_firmware(fw);
459 kfree(img);
460 kfree(out); 570 kfree(out);
571abort1:
572 kfree(img);
573abort2:
574 release_firmware(fw);
575
576 return ret;
577}
578
579static int wm0010_boot(struct snd_soc_codec *codec)
580{
581 struct spi_device *spi = to_spi_device(codec->dev);
582 struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec);
583 unsigned long flags;
584 int ret;
585 const struct firmware *fw;
586 struct spi_message m;
587 struct spi_transfer t;
588 struct dfw_pllrec pll_rec;
589 u32 *p, len;
590 u64 *img_swap;
591 u8 *out;
592 int i;
593
594 spin_lock_irqsave(&wm0010->irq_lock, flags);
595 if (wm0010->state != WM0010_POWER_OFF)
596 dev_warn(wm0010->dev, "DSP already powered up!\n");
597 spin_unlock_irqrestore(&wm0010->irq_lock, flags);
598
599 if (wm0010->sysclk > 26000000) {
600 dev_err(codec->dev, "Max DSP clock frequency is 26MHz\n");
601 ret = -ECANCELED;
602 goto err;
603 }
604
605 mutex_lock(&wm0010->lock);
606 wm0010->pll_running = false;
607
608 dev_dbg(codec->dev, "max_spi_freq: %d\n", wm0010->max_spi_freq);
609
610 ret = regulator_bulk_enable(ARRAY_SIZE(wm0010->core_supplies),
611 wm0010->core_supplies);
612 if (ret != 0) {
613 dev_err(&spi->dev, "Failed to enable core supplies: %d\n",
614 ret);
615 mutex_unlock(&wm0010->lock);
616 goto err;
617 }
618
619 ret = regulator_enable(wm0010->dbvdd);
620 if (ret != 0) {
621 dev_err(&spi->dev, "Failed to enable DBVDD: %d\n", ret);
622 goto err_core;
623 }
624
625 /* Release reset */
626 gpio_set_value_cansleep(wm0010->gpio_reset, !wm0010->gpio_reset_value);
627 spin_lock_irqsave(&wm0010->irq_lock, flags);
628 wm0010->state = WM0010_OUT_OF_RESET;
629 spin_unlock_irqrestore(&wm0010->irq_lock, flags);
630
631 /* First the bootloader */
632 ret = request_firmware(&fw, "wm0010_stage2.bin", codec->dev);
633 if (ret != 0) {
634 dev_err(codec->dev, "Failed to request stage2 loader: %d\n",
635 ret);
636 goto abort;
637 }
638
639 if (!wait_for_completion_timeout(&wm0010->boot_completion,
640 msecs_to_jiffies(20)))
641 dev_err(codec->dev, "Failed to get interrupt from DSP\n");
642
643 spin_lock_irqsave(&wm0010->irq_lock, flags);
644 wm0010->state = WM0010_BOOTROM;
645 spin_unlock_irqrestore(&wm0010->irq_lock, flags);
646
647 ret = wm0010_stage2_load(codec);
648 if (ret)
649 goto abort;
461 650
462 if (!wait_for_completion_timeout(&wm0010->boot_completion, 651 if (!wait_for_completion_timeout(&wm0010->boot_completion,
463 msecs_to_jiffies(10))) 652 msecs_to_jiffies(20)))
464 dev_err(codec->dev, "Failed to get interrupt from DSP loader.\n"); 653 dev_err(codec->dev, "Failed to get interrupt from DSP loader.\n");
465 654
466 spin_lock_irqsave(&wm0010->irq_lock, flags); 655 spin_lock_irqsave(&wm0010->irq_lock, flags);
@@ -535,110 +724,10 @@ static int wm0010_boot(struct snd_soc_codec *codec)
535 } else 724 } else
536 dev_dbg(codec->dev, "Not enabling DSP PLL."); 725 dev_dbg(codec->dev, "Not enabling DSP PLL.");
537 726
538 ret = request_firmware(&fw, "wm0010.dfw", codec->dev); 727 ret = wm0010_firmware_load("wm0010.dfw", codec);
539 if (ret != 0) {
540 dev_err(codec->dev, "Failed to request application: %d\n",
541 ret);
542 goto abort;
543 }
544
545 rec = (const struct dfw_binrec *)fw->data;
546 offset = 0;
547 wm0010->boot_done = 0;
548 wm0010->boot_failed = false;
549 BUG_ON(!list_empty(&xfer_list));
550 init_completion(&done);
551 728
552 /* First record should be INFO */ 729 if (ret != 0)
553 if (rec->command != DFW_CMD_INFO) {
554 dev_err(codec->dev, "First record not INFO\r\n");
555 goto abort;
556 }
557
558 /* Check it's a 0010 file */
559 if (rec->data[0] != DEVICE_ID_WM0010) {
560 dev_err(codec->dev, "Not a WM0010 firmware file.\r\n");
561 goto abort; 730 goto abort;
562 }
563
564 /* Skip the info record as we don't need to send it */
565 offset += ((rec->length) + 8);
566 rec = (void *)&rec->data[rec->length];
567
568 while (offset < fw->size) {
569 dev_dbg(codec->dev,
570 "Packet: command %d, data length = 0x%x\r\n",
571 rec->command, rec->length);
572 len = rec->length + 8;
573
574 out = kzalloc(len, GFP_KERNEL);
575 if (!out) {
576 dev_err(codec->dev,
577 "Failed to allocate RX buffer\n");
578 goto abort;
579 }
580
581 img_swap = kzalloc(len, GFP_KERNEL);
582 if (!img_swap) {
583 dev_err(codec->dev,
584 "Failed to allocate image buffer\n");
585 goto abort;
586 }
587
588 /* We need to re-order for 0010 */
589 byte_swap_64((u64 *)&rec->command, img_swap, len);
590
591 xfer = kzalloc(sizeof(*xfer), GFP_KERNEL);
592 if (!xfer) {
593 dev_err(codec->dev, "Failed to allocate xfer\n");
594 goto abort;
595 }
596
597 xfer->codec = codec;
598 list_add_tail(&xfer->list, &xfer_list);
599
600 spi_message_init(&xfer->m);
601 xfer->m.complete = wm0010_boot_xfer_complete;
602 xfer->m.context = xfer;
603 xfer->t.tx_buf = img_swap;
604 xfer->t.rx_buf = out;
605 xfer->t.len = len;
606 xfer->t.bits_per_word = 8;
607
608 if (!wm0010->pll_running) {
609 xfer->t.speed_hz = wm0010->sysclk / 6;
610 } else {
611 xfer->t.speed_hz = wm0010->max_spi_freq;
612
613 if (wm0010->board_max_spi_speed &&
614 (wm0010->board_max_spi_speed < wm0010->max_spi_freq))
615 xfer->t.speed_hz = wm0010->board_max_spi_speed;
616 }
617
618 /* Store max usable spi frequency for later use */
619 wm0010->max_spi_freq = xfer->t.speed_hz;
620
621 spi_message_add_tail(&xfer->t, &xfer->m);
622
623 offset += ((rec->length) + 8);
624 rec = (void *)&rec->data[rec->length];
625
626 if (offset >= fw->size) {
627 dev_dbg(codec->dev, "All transfers scheduled\n");
628 xfer->done = &done;
629 }
630
631 ret = spi_async(spi, &xfer->m);
632 if (ret != 0) {
633 dev_err(codec->dev, "Write failed: %d\n", ret);
634 goto abort;
635 }
636
637 if (wm0010->boot_failed)
638 goto abort;
639 }
640
641 wait_for_completion(&done);
642 731
643 spin_lock_irqsave(&wm0010->irq_lock, flags); 732 spin_lock_irqsave(&wm0010->irq_lock, flags);
644 wm0010->state = WM0010_FIRMWARE; 733 wm0010->state = WM0010_FIRMWARE;
@@ -646,17 +735,6 @@ static int wm0010_boot(struct snd_soc_codec *codec)
646 735
647 mutex_unlock(&wm0010->lock); 736 mutex_unlock(&wm0010->lock);
648 737
649 release_firmware(fw);
650
651 while (!list_empty(&xfer_list)) {
652 xfer = list_first_entry(&xfer_list, struct wm0010_boot_xfer,
653 list);
654 kfree(xfer->t.rx_buf);
655 kfree(xfer->t.tx_buf);
656 list_del(&xfer->list);
657 kfree(xfer);
658 }
659
660 return 0; 738 return 0;
661 739
662abort: 740abort:
@@ -784,7 +862,6 @@ static irqreturn_t wm0010_irq(int irq, void *data)
784 struct wm0010_priv *wm0010 = data; 862 struct wm0010_priv *wm0010 = data;
785 863
786 switch (wm0010->state) { 864 switch (wm0010->state) {
787 case WM0010_POWER_OFF:
788 case WM0010_OUT_OF_RESET: 865 case WM0010_OUT_OF_RESET:
789 case WM0010_BOOTROM: 866 case WM0010_BOOTROM:
790 case WM0010_STAGE2: 867 case WM0010_STAGE2:
diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c
index 683dc43b1d87..02750ab020de 100644
--- a/sound/soc/codecs/wm2000.c
+++ b/sound/soc/codecs/wm2000.c
@@ -646,7 +646,7 @@ static const struct snd_kcontrol_new wm2000_controls[] = {
646static int wm2000_anc_power_event(struct snd_soc_dapm_widget *w, 646static int wm2000_anc_power_event(struct snd_soc_dapm_widget *w,
647 struct snd_kcontrol *kcontrol, int event) 647 struct snd_kcontrol *kcontrol, int event)
648{ 648{
649 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 649 struct snd_soc_codec *codec = w->codec;
650 struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); 650 struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev);
651 651
652 if (SND_SOC_DAPM_EVENT_ON(event)) 652 if (SND_SOC_DAPM_EVENT_ON(event))
diff --git a/sound/soc/codecs/wm2200.c b/sound/soc/codecs/wm2200.c
index eab64a193989..ff45b02a9dff 100644
--- a/sound/soc/codecs/wm2200.c
+++ b/sound/soc/codecs/wm2200.c
@@ -15,6 +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/firmware.h>
18#include <linux/gcd.h> 19#include <linux/gcd.h>
19#include <linux/gpio.h> 20#include <linux/gpio.h>
20#include <linux/i2c.h> 21#include <linux/i2c.h>
@@ -32,6 +33,40 @@
32#include <sound/wm2200.h> 33#include <sound/wm2200.h>
33 34
34#include "wm2200.h" 35#include "wm2200.h"
36#include "wmfw.h"
37#include "wm_adsp.h"
38
39#define WM2200_DSP_CONTROL_1 0x00
40#define WM2200_DSP_CONTROL_2 0x02
41#define WM2200_DSP_CONTROL_3 0x03
42#define WM2200_DSP_CONTROL_4 0x04
43#define WM2200_DSP_CONTROL_5 0x06
44#define WM2200_DSP_CONTROL_6 0x07
45#define WM2200_DSP_CONTROL_7 0x08
46#define WM2200_DSP_CONTROL_8 0x09
47#define WM2200_DSP_CONTROL_9 0x0A
48#define WM2200_DSP_CONTROL_10 0x0B
49#define WM2200_DSP_CONTROL_11 0x0C
50#define WM2200_DSP_CONTROL_12 0x0D
51#define WM2200_DSP_CONTROL_13 0x0F
52#define WM2200_DSP_CONTROL_14 0x10
53#define WM2200_DSP_CONTROL_15 0x11
54#define WM2200_DSP_CONTROL_16 0x12
55#define WM2200_DSP_CONTROL_17 0x13
56#define WM2200_DSP_CONTROL_18 0x14
57#define WM2200_DSP_CONTROL_19 0x16
58#define WM2200_DSP_CONTROL_20 0x17
59#define WM2200_DSP_CONTROL_21 0x18
60#define WM2200_DSP_CONTROL_22 0x1A
61#define WM2200_DSP_CONTROL_23 0x1B
62#define WM2200_DSP_CONTROL_24 0x1C
63#define WM2200_DSP_CONTROL_25 0x1E
64#define WM2200_DSP_CONTROL_26 0x20
65#define WM2200_DSP_CONTROL_27 0x21
66#define WM2200_DSP_CONTROL_28 0x22
67#define WM2200_DSP_CONTROL_29 0x23
68#define WM2200_DSP_CONTROL_30 0x24
69#define WM2200_DSP_CONTROL_31 0x26
35 70
36/* The code assumes DCVDD is generated internally */ 71/* The code assumes DCVDD is generated internally */
37#define WM2200_NUM_CORE_SUPPLIES 2 72#define WM2200_NUM_CORE_SUPPLIES 2
@@ -49,6 +84,7 @@ struct wm2200_fll {
49 84
50/* codec private data */ 85/* codec private data */
51struct wm2200_priv { 86struct wm2200_priv {
87 struct wm_adsp dsp[2];
52 struct regmap *regmap; 88 struct regmap *regmap;
53 struct device *dev; 89 struct device *dev;
54 struct snd_soc_codec *codec; 90 struct snd_soc_codec *codec;
@@ -64,6 +100,72 @@ struct wm2200_priv {
64 int sysclk; 100 int sysclk;
65}; 101};
66 102
103#define WM2200_DSP_RANGE_BASE (WM2200_MAX_REGISTER + 1)
104#define WM2200_DSP_SPACING 12288
105
106#define WM2200_DSP1_DM_BASE (WM2200_DSP_RANGE_BASE + (0 * WM2200_DSP_SPACING))
107#define WM2200_DSP1_PM_BASE (WM2200_DSP_RANGE_BASE + (1 * WM2200_DSP_SPACING))
108#define WM2200_DSP1_ZM_BASE (WM2200_DSP_RANGE_BASE + (2 * WM2200_DSP_SPACING))
109#define WM2200_DSP2_DM_BASE (WM2200_DSP_RANGE_BASE + (3 * WM2200_DSP_SPACING))
110#define WM2200_DSP2_PM_BASE (WM2200_DSP_RANGE_BASE + (4 * WM2200_DSP_SPACING))
111#define WM2200_DSP2_ZM_BASE (WM2200_DSP_RANGE_BASE + (5 * WM2200_DSP_SPACING))
112
113static const struct regmap_range_cfg wm2200_ranges[] = {
114 { .name = "DSP1DM", .range_min = WM2200_DSP1_DM_BASE,
115 .range_max = WM2200_DSP1_DM_BASE + 12287,
116 .selector_reg = WM2200_DSP1_CONTROL_3,
117 .selector_mask = WM2200_DSP1_PAGE_BASE_DM_0_MASK,
118 .selector_shift = WM2200_DSP1_PAGE_BASE_DM_0_SHIFT,
119 .window_start = WM2200_DSP1_DM_0, .window_len = 2048, },
120
121 { .name = "DSP1PM", .range_min = WM2200_DSP1_PM_BASE,
122 .range_max = WM2200_DSP1_PM_BASE + 12287,
123 .selector_reg = WM2200_DSP1_CONTROL_2,
124 .selector_mask = WM2200_DSP1_PAGE_BASE_PM_0_MASK,
125 .selector_shift = WM2200_DSP1_PAGE_BASE_PM_0_SHIFT,
126 .window_start = WM2200_DSP1_PM_0, .window_len = 768, },
127
128 { .name = "DSP1ZM", .range_min = WM2200_DSP1_ZM_BASE,
129 .range_max = WM2200_DSP1_ZM_BASE + 2047,
130 .selector_reg = WM2200_DSP1_CONTROL_4,
131 .selector_mask = WM2200_DSP1_PAGE_BASE_ZM_0_MASK,
132 .selector_shift = WM2200_DSP1_PAGE_BASE_ZM_0_SHIFT,
133 .window_start = WM2200_DSP1_ZM_0, .window_len = 1024, },
134
135 { .name = "DSP2DM", .range_min = WM2200_DSP2_DM_BASE,
136 .range_max = WM2200_DSP2_DM_BASE + 4095,
137 .selector_reg = WM2200_DSP2_CONTROL_3,
138 .selector_mask = WM2200_DSP2_PAGE_BASE_DM_0_MASK,
139 .selector_shift = WM2200_DSP2_PAGE_BASE_DM_0_SHIFT,
140 .window_start = WM2200_DSP2_DM_0, .window_len = 2048, },
141
142 { .name = "DSP2PM", .range_min = WM2200_DSP2_PM_BASE,
143 .range_max = WM2200_DSP2_PM_BASE + 11287,
144 .selector_reg = WM2200_DSP2_CONTROL_2,
145 .selector_mask = WM2200_DSP2_PAGE_BASE_PM_0_MASK,
146 .selector_shift = WM2200_DSP2_PAGE_BASE_PM_0_SHIFT,
147 .window_start = WM2200_DSP2_PM_0, .window_len = 768, },
148
149 { .name = "DSP2ZM", .range_min = WM2200_DSP2_ZM_BASE,
150 .range_max = WM2200_DSP2_ZM_BASE + 2047,
151 .selector_reg = WM2200_DSP2_CONTROL_4,
152 .selector_mask = WM2200_DSP2_PAGE_BASE_ZM_0_MASK,
153 .selector_shift = WM2200_DSP2_PAGE_BASE_ZM_0_SHIFT,
154 .window_start = WM2200_DSP2_ZM_0, .window_len = 1024, },
155};
156
157static const struct wm_adsp_region wm2200_dsp1_regions[] = {
158 { .type = WMFW_ADSP1_PM, .base = WM2200_DSP1_PM_BASE },
159 { .type = WMFW_ADSP1_DM, .base = WM2200_DSP1_DM_BASE },
160 { .type = WMFW_ADSP1_ZM, .base = WM2200_DSP1_ZM_BASE },
161};
162
163static const struct wm_adsp_region wm2200_dsp2_regions[] = {
164 { .type = WMFW_ADSP1_PM, .base = WM2200_DSP2_PM_BASE },
165 { .type = WMFW_ADSP1_DM, .base = WM2200_DSP2_DM_BASE },
166 { .type = WMFW_ADSP1_ZM, .base = WM2200_DSP2_ZM_BASE },
167};
168
67static struct reg_default wm2200_reg_defaults[] = { 169static struct reg_default wm2200_reg_defaults[] = {
68 { 0x000B, 0x0000 }, /* R11 - Tone Generator 1 */ 170 { 0x000B, 0x0000 }, /* R11 - Tone Generator 1 */
69 { 0x0102, 0x0000 }, /* R258 - Clocking 3 */ 171 { 0x0102, 0x0000 }, /* R258 - Clocking 3 */
@@ -407,6 +509,16 @@ static struct reg_default wm2200_reg_defaults[] = {
407 509
408static bool wm2200_volatile_register(struct device *dev, unsigned int reg) 510static bool wm2200_volatile_register(struct device *dev, unsigned int reg)
409{ 511{
512 int i;
513
514 for (i = 0; i < ARRAY_SIZE(wm2200_ranges); i++)
515 if ((reg >= wm2200_ranges[i].window_start &&
516 reg <= wm2200_ranges[i].window_start +
517 wm2200_ranges[i].window_len) ||
518 (reg >= wm2200_ranges[i].range_min &&
519 reg <= wm2200_ranges[i].range_max))
520 return true;
521
410 switch (reg) { 522 switch (reg) {
411 case WM2200_SOFTWARE_RESET: 523 case WM2200_SOFTWARE_RESET:
412 case WM2200_DEVICE_REVISION: 524 case WM2200_DEVICE_REVISION:
@@ -423,6 +535,16 @@ static bool wm2200_volatile_register(struct device *dev, unsigned int reg)
423 535
424static bool wm2200_readable_register(struct device *dev, unsigned int reg) 536static bool wm2200_readable_register(struct device *dev, unsigned int reg)
425{ 537{
538 int i;
539
540 for (i = 0; i < ARRAY_SIZE(wm2200_ranges); i++)
541 if ((reg >= wm2200_ranges[i].window_start &&
542 reg <= wm2200_ranges[i].window_start +
543 wm2200_ranges[i].window_len) ||
544 (reg >= wm2200_ranges[i].range_min &&
545 reg <= wm2200_ranges[i].range_max))
546 return true;
547
426 switch (reg) { 548 switch (reg) {
427 case WM2200_SOFTWARE_RESET: 549 case WM2200_SOFTWARE_RESET:
428 case WM2200_DEVICE_REVISION: 550 case WM2200_DEVICE_REVISION:
@@ -880,7 +1002,7 @@ static DECLARE_TLV_DB_SCALE(out_tlv, -6400, 100, 0);
880static const char *wm2200_mixer_texts[] = { 1002static const char *wm2200_mixer_texts[] = {
881 "None", 1003 "None",
882 "Tone Generator", 1004 "Tone Generator",
883 "AEC loopback", 1005 "AEC Loopback",
884 "IN1L", 1006 "IN1L",
885 "IN1R", 1007 "IN1R",
886 "IN2L", 1008 "IN2L",
@@ -976,6 +1098,20 @@ static int wm2200_mixer_values[] = {
976 static WM2200_MUX_CTL_DECL(name##_in3); \ 1098 static WM2200_MUX_CTL_DECL(name##_in3); \
977 static WM2200_MUX_CTL_DECL(name##_in4) 1099 static WM2200_MUX_CTL_DECL(name##_in4)
978 1100
1101#define WM2200_DSP_ENUMS(name, base_reg) \
1102 static WM2200_MUX_ENUM_DECL(name##_aux1_enum, base_reg); \
1103 static WM2200_MUX_ENUM_DECL(name##_aux2_enum, base_reg + 1); \
1104 static WM2200_MUX_ENUM_DECL(name##_aux3_enum, base_reg + 2); \
1105 static WM2200_MUX_ENUM_DECL(name##_aux4_enum, base_reg + 3); \
1106 static WM2200_MUX_ENUM_DECL(name##_aux5_enum, base_reg + 4); \
1107 static WM2200_MUX_ENUM_DECL(name##_aux6_enum, base_reg + 5); \
1108 static WM2200_MUX_CTL_DECL(name##_aux1); \
1109 static WM2200_MUX_CTL_DECL(name##_aux2); \
1110 static WM2200_MUX_CTL_DECL(name##_aux3); \
1111 static WM2200_MUX_CTL_DECL(name##_aux4); \
1112 static WM2200_MUX_CTL_DECL(name##_aux5); \
1113 static WM2200_MUX_CTL_DECL(name##_aux6);
1114
979static const struct snd_kcontrol_new wm2200_snd_controls[] = { 1115static const struct snd_kcontrol_new wm2200_snd_controls[] = {
980SOC_SINGLE("IN1 High Performance Switch", WM2200_IN1L_CONTROL, 1116SOC_SINGLE("IN1 High Performance Switch", WM2200_IN1L_CONTROL,
981 WM2200_IN1_OSR_SHIFT, 1, 0), 1117 WM2200_IN1_OSR_SHIFT, 1, 0),
@@ -1051,6 +1187,9 @@ WM2200_MIXER_ENUMS(DSP1R, WM2200_DSP1RMIX_INPUT_1_SOURCE);
1051WM2200_MIXER_ENUMS(DSP2L, WM2200_DSP2LMIX_INPUT_1_SOURCE); 1187WM2200_MIXER_ENUMS(DSP2L, WM2200_DSP2LMIX_INPUT_1_SOURCE);
1052WM2200_MIXER_ENUMS(DSP2R, WM2200_DSP2RMIX_INPUT_1_SOURCE); 1188WM2200_MIXER_ENUMS(DSP2R, WM2200_DSP2RMIX_INPUT_1_SOURCE);
1053 1189
1190WM2200_DSP_ENUMS(DSP1, WM2200_DSP1AUX1MIX_INPUT_1_SOURCE);
1191WM2200_DSP_ENUMS(DSP2, WM2200_DSP2AUX1MIX_INPUT_1_SOURCE);
1192
1054WM2200_MIXER_ENUMS(LHPF1, WM2200_LHPF1MIX_INPUT_1_SOURCE); 1193WM2200_MIXER_ENUMS(LHPF1, WM2200_LHPF1MIX_INPUT_1_SOURCE);
1055WM2200_MIXER_ENUMS(LHPF2, WM2200_LHPF2MIX_INPUT_1_SOURCE); 1194WM2200_MIXER_ENUMS(LHPF2, WM2200_LHPF2MIX_INPUT_1_SOURCE);
1056 1195
@@ -1064,8 +1203,19 @@ WM2200_MIXER_ENUMS(LHPF2, WM2200_LHPF2MIX_INPUT_1_SOURCE);
1064 WM2200_MUX(name_str " Input 4", &name##_in4_mux), \ 1203 WM2200_MUX(name_str " Input 4", &name##_in4_mux), \
1065 SND_SOC_DAPM_MIXER(name_str " Mixer", SND_SOC_NOPM, 0, 0, NULL, 0) 1204 SND_SOC_DAPM_MIXER(name_str " Mixer", SND_SOC_NOPM, 0, 0, NULL, 0)
1066 1205
1206#define WM2200_DSP_WIDGETS(name, name_str) \
1207 WM2200_MIXER_WIDGETS(name##L, name_str "L"), \
1208 WM2200_MIXER_WIDGETS(name##R, name_str "R"), \
1209 WM2200_MUX(name_str " Aux 1", &name##_aux1_mux), \
1210 WM2200_MUX(name_str " Aux 2", &name##_aux2_mux), \
1211 WM2200_MUX(name_str " Aux 3", &name##_aux3_mux), \
1212 WM2200_MUX(name_str " Aux 4", &name##_aux4_mux), \
1213 WM2200_MUX(name_str " Aux 5", &name##_aux5_mux), \
1214 WM2200_MUX(name_str " Aux 6", &name##_aux6_mux)
1215
1067#define WM2200_MIXER_INPUT_ROUTES(name) \ 1216#define WM2200_MIXER_INPUT_ROUTES(name) \
1068 { name, "Tone Generator", "Tone Generator" }, \ 1217 { name, "Tone Generator", "Tone Generator" }, \
1218 { name, "AEC Loopback", "AEC Loopback" }, \
1069 { name, "IN1L", "IN1L PGA" }, \ 1219 { name, "IN1L", "IN1L PGA" }, \
1070 { name, "IN1R", "IN1R PGA" }, \ 1220 { name, "IN1R", "IN1R PGA" }, \
1071 { name, "IN2L", "IN2L PGA" }, \ 1221 { name, "IN2L", "IN2L PGA" }, \
@@ -1106,6 +1256,33 @@ WM2200_MIXER_ENUMS(LHPF2, WM2200_LHPF2MIX_INPUT_1_SOURCE);
1106 WM2200_MIXER_INPUT_ROUTES(name " Input 3"), \ 1256 WM2200_MIXER_INPUT_ROUTES(name " Input 3"), \
1107 WM2200_MIXER_INPUT_ROUTES(name " Input 4") 1257 WM2200_MIXER_INPUT_ROUTES(name " Input 4")
1108 1258
1259#define WM2200_DSP_AUX_ROUTES(name) \
1260 { name, NULL, name " Aux 1" }, \
1261 { name, NULL, name " Aux 2" }, \
1262 { name, NULL, name " Aux 3" }, \
1263 { name, NULL, name " Aux 4" }, \
1264 { name, NULL, name " Aux 5" }, \
1265 { name, NULL, name " Aux 6" }, \
1266 WM2200_MIXER_INPUT_ROUTES(name " Aux 1"), \
1267 WM2200_MIXER_INPUT_ROUTES(name " Aux 2"), \
1268 WM2200_MIXER_INPUT_ROUTES(name " Aux 3"), \
1269 WM2200_MIXER_INPUT_ROUTES(name " Aux 4"), \
1270 WM2200_MIXER_INPUT_ROUTES(name " Aux 5"), \
1271 WM2200_MIXER_INPUT_ROUTES(name " Aux 6")
1272
1273static const char *wm2200_aec_loopback_texts[] = {
1274 "OUT1L", "OUT1R", "OUT2L", "OUT2R",
1275};
1276
1277static const struct soc_enum wm2200_aec_loopback =
1278 SOC_ENUM_SINGLE(WM2200_DAC_AEC_CONTROL_1,
1279 WM2200_AEC_LOOPBACK_SRC_SHIFT,
1280 ARRAY_SIZE(wm2200_aec_loopback_texts),
1281 wm2200_aec_loopback_texts);
1282
1283static const struct snd_kcontrol_new wm2200_aec_loopback_mux =
1284 SOC_DAPM_ENUM("AEC Loopback", wm2200_aec_loopback);
1285
1109static const struct snd_soc_dapm_widget wm2200_dapm_widgets[] = { 1286static const struct snd_soc_dapm_widget wm2200_dapm_widgets[] = {
1110SND_SOC_DAPM_SUPPLY("SYSCLK", WM2200_CLOCKING_3, WM2200_SYSCLK_ENA_SHIFT, 0, 1287SND_SOC_DAPM_SUPPLY("SYSCLK", WM2200_CLOCKING_3, WM2200_SYSCLK_ENA_SHIFT, 0,
1111 NULL, 0), 1288 NULL, 0),
@@ -1165,8 +1342,8 @@ SND_SOC_DAPM_PGA("LHPF1", WM2200_HPLPF1_1, WM2200_LHPF1_ENA_SHIFT, 0,
1165SND_SOC_DAPM_PGA("LHPF2", WM2200_HPLPF2_1, WM2200_LHPF2_ENA_SHIFT, 0, 1342SND_SOC_DAPM_PGA("LHPF2", WM2200_HPLPF2_1, WM2200_LHPF2_ENA_SHIFT, 0,
1166 NULL, 0), 1343 NULL, 0),
1167 1344
1168SND_SOC_DAPM_PGA_E("DSP1", SND_SOC_NOPM, 0, 0, NULL, 0, NULL, 0), 1345WM_ADSP1("DSP1", 0),
1169SND_SOC_DAPM_PGA_E("DSP2", SND_SOC_NOPM, 1, 0, NULL, 0, NULL, 0), 1346WM_ADSP1("DSP2", 1),
1170 1347
1171SND_SOC_DAPM_AIF_OUT("AIF1TX1", "Capture", 0, 1348SND_SOC_DAPM_AIF_OUT("AIF1TX1", "Capture", 0,
1172 WM2200_AUDIO_IF_1_22, WM2200_AIF1TX1_ENA_SHIFT, 0), 1349 WM2200_AUDIO_IF_1_22, WM2200_AIF1TX1_ENA_SHIFT, 0),
@@ -1181,6 +1358,9 @@ SND_SOC_DAPM_AIF_OUT("AIF1TX5", "Capture", 4,
1181SND_SOC_DAPM_AIF_OUT("AIF1TX6", "Capture", 5, 1358SND_SOC_DAPM_AIF_OUT("AIF1TX6", "Capture", 5,
1182 WM2200_AUDIO_IF_1_22, WM2200_AIF1TX6_ENA_SHIFT, 0), 1359 WM2200_AUDIO_IF_1_22, WM2200_AIF1TX6_ENA_SHIFT, 0),
1183 1360
1361SND_SOC_DAPM_MUX("AEC Loopback", WM2200_DAC_AEC_CONTROL_1,
1362 WM2200_AEC_LOOPBACK_ENA_SHIFT, 0, &wm2200_aec_loopback_mux),
1363
1184SND_SOC_DAPM_PGA_S("OUT1L", 0, WM2200_OUTPUT_ENABLES, 1364SND_SOC_DAPM_PGA_S("OUT1L", 0, WM2200_OUTPUT_ENABLES,
1185 WM2200_OUT1L_ENA_SHIFT, 0, NULL, 0), 1365 WM2200_OUT1L_ENA_SHIFT, 0, NULL, 0),
1186SND_SOC_DAPM_PGA_S("OUT1R", 0, WM2200_OUTPUT_ENABLES, 1366SND_SOC_DAPM_PGA_S("OUT1R", 0, WM2200_OUTPUT_ENABLES,
@@ -1231,10 +1411,8 @@ WM2200_MIXER_WIDGETS(EQR, "EQR"),
1231WM2200_MIXER_WIDGETS(LHPF1, "LHPF1"), 1411WM2200_MIXER_WIDGETS(LHPF1, "LHPF1"),
1232WM2200_MIXER_WIDGETS(LHPF2, "LHPF2"), 1412WM2200_MIXER_WIDGETS(LHPF2, "LHPF2"),
1233 1413
1234WM2200_MIXER_WIDGETS(DSP1L, "DSP1L"), 1414WM2200_DSP_WIDGETS(DSP1, "DSP1"),
1235WM2200_MIXER_WIDGETS(DSP1R, "DSP1R"), 1415WM2200_DSP_WIDGETS(DSP2, "DSP2"),
1236WM2200_MIXER_WIDGETS(DSP2L, "DSP2L"),
1237WM2200_MIXER_WIDGETS(DSP2R, "DSP2R"),
1238 1416
1239WM2200_MIXER_WIDGETS(AIF1TX1, "AIF1TX1"), 1417WM2200_MIXER_WIDGETS(AIF1TX1, "AIF1TX1"),
1240WM2200_MIXER_WIDGETS(AIF1TX2, "AIF1TX2"), 1418WM2200_MIXER_WIDGETS(AIF1TX2, "AIF1TX2"),
@@ -1326,11 +1504,19 @@ static const struct snd_soc_dapm_route wm2200_dapm_routes[] = {
1326 { "SPK", NULL, "OUT2L" }, 1504 { "SPK", NULL, "OUT2L" },
1327 { "SPK", NULL, "OUT2R" }, 1505 { "SPK", NULL, "OUT2R" },
1328 1506
1507 { "AEC Loopback", "OUT1L", "OUT1L" },
1508 { "AEC Loopback", "OUT1R", "OUT1R" },
1509 { "AEC Loopback", "OUT2L", "OUT2L" },
1510 { "AEC Loopback", "OUT2R", "OUT2R" },
1511
1329 WM2200_MIXER_ROUTES("DSP1", "DSP1L"), 1512 WM2200_MIXER_ROUTES("DSP1", "DSP1L"),
1330 WM2200_MIXER_ROUTES("DSP1", "DSP1R"), 1513 WM2200_MIXER_ROUTES("DSP1", "DSP1R"),
1331 WM2200_MIXER_ROUTES("DSP2", "DSP2L"), 1514 WM2200_MIXER_ROUTES("DSP2", "DSP2L"),
1332 WM2200_MIXER_ROUTES("DSP2", "DSP2R"), 1515 WM2200_MIXER_ROUTES("DSP2", "DSP2R"),
1333 1516
1517 WM2200_DSP_AUX_ROUTES("DSP1"),
1518 WM2200_DSP_AUX_ROUTES("DSP2"),
1519
1334 WM2200_MIXER_ROUTES("OUT1L", "OUT1L"), 1520 WM2200_MIXER_ROUTES("OUT1L", "OUT1L"),
1335 WM2200_MIXER_ROUTES("OUT1R", "OUT1R"), 1521 WM2200_MIXER_ROUTES("OUT1R", "OUT1R"),
1336 WM2200_MIXER_ROUTES("OUT2L", "OUT2L"), 1522 WM2200_MIXER_ROUTES("OUT2L", "OUT2L"),
@@ -1968,12 +2154,15 @@ static const struct regmap_config wm2200_regmap = {
1968 .reg_bits = 16, 2154 .reg_bits = 16,
1969 .val_bits = 16, 2155 .val_bits = 16,
1970 2156
1971 .max_register = WM2200_MAX_REGISTER, 2157 .max_register = WM2200_MAX_REGISTER + (ARRAY_SIZE(wm2200_ranges) *
2158 WM2200_DSP_SPACING),
1972 .reg_defaults = wm2200_reg_defaults, 2159 .reg_defaults = wm2200_reg_defaults,
1973 .num_reg_defaults = ARRAY_SIZE(wm2200_reg_defaults), 2160 .num_reg_defaults = ARRAY_SIZE(wm2200_reg_defaults),
1974 .volatile_reg = wm2200_volatile_register, 2161 .volatile_reg = wm2200_volatile_register,
1975 .readable_reg = wm2200_readable_register, 2162 .readable_reg = wm2200_readable_register,
1976 .cache_type = REGCACHE_RBTREE, 2163 .cache_type = REGCACHE_RBTREE,
2164 .ranges = wm2200_ranges,
2165 .num_ranges = ARRAY_SIZE(wm2200_ranges),
1977}; 2166};
1978 2167
1979static const unsigned int wm2200_dig_vu[] = { 2168static const unsigned int wm2200_dig_vu[] = {
@@ -2011,14 +2200,30 @@ static __devinit int wm2200_i2c_probe(struct i2c_client *i2c,
2011 wm2200->dev = &i2c->dev; 2200 wm2200->dev = &i2c->dev;
2012 init_completion(&wm2200->fll_lock); 2201 init_completion(&wm2200->fll_lock);
2013 2202
2014 wm2200->regmap = regmap_init_i2c(i2c, &wm2200_regmap); 2203 wm2200->regmap = devm_regmap_init_i2c(i2c, &wm2200_regmap);
2015 if (IS_ERR(wm2200->regmap)) { 2204 if (IS_ERR(wm2200->regmap)) {
2016 ret = PTR_ERR(wm2200->regmap); 2205 ret = PTR_ERR(wm2200->regmap);
2017 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", 2206 dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
2018 ret); 2207 ret);
2019 goto err; 2208 return ret;
2209 }
2210
2211 for (i = 0; i < 2; i++) {
2212 wm2200->dsp[i].type = WMFW_ADSP1;
2213 wm2200->dsp[i].part = "wm2200";
2214 wm2200->dsp[i].num = i + 1;
2215 wm2200->dsp[i].dev = &i2c->dev;
2216 wm2200->dsp[i].regmap = wm2200->regmap;
2020 } 2217 }
2021 2218
2219 wm2200->dsp[0].base = WM2200_DSP1_CONTROL_1;
2220 wm2200->dsp[0].mem = wm2200_dsp1_regions;
2221 wm2200->dsp[0].num_mems = ARRAY_SIZE(wm2200_dsp1_regions);
2222
2223 wm2200->dsp[1].base = WM2200_DSP2_CONTROL_1;
2224 wm2200->dsp[1].mem = wm2200_dsp2_regions;
2225 wm2200->dsp[1].num_mems = ARRAY_SIZE(wm2200_dsp2_regions);
2226
2022 if (pdata) 2227 if (pdata)
2023 wm2200->pdata = *pdata; 2228 wm2200->pdata = *pdata;
2024 2229
@@ -2027,12 +2232,13 @@ static __devinit int wm2200_i2c_probe(struct i2c_client *i2c,
2027 for (i = 0; i < ARRAY_SIZE(wm2200->core_supplies); i++) 2232 for (i = 0; i < ARRAY_SIZE(wm2200->core_supplies); i++)
2028 wm2200->core_supplies[i].supply = wm2200_core_supply_names[i]; 2233 wm2200->core_supplies[i].supply = wm2200_core_supply_names[i];
2029 2234
2030 ret = regulator_bulk_get(&i2c->dev, ARRAY_SIZE(wm2200->core_supplies), 2235 ret = devm_regulator_bulk_get(&i2c->dev,
2031 wm2200->core_supplies); 2236 ARRAY_SIZE(wm2200->core_supplies),
2237 wm2200->core_supplies);
2032 if (ret != 0) { 2238 if (ret != 0) {
2033 dev_err(&i2c->dev, "Failed to request core supplies: %d\n", 2239 dev_err(&i2c->dev, "Failed to request core supplies: %d\n",
2034 ret); 2240 ret);
2035 goto err_regmap; 2241 return ret;
2036 } 2242 }
2037 2243
2038 ret = regulator_bulk_enable(ARRAY_SIZE(wm2200->core_supplies), 2244 ret = regulator_bulk_enable(ARRAY_SIZE(wm2200->core_supplies),
@@ -2040,12 +2246,13 @@ static __devinit int wm2200_i2c_probe(struct i2c_client *i2c,
2040 if (ret != 0) { 2246 if (ret != 0) {
2041 dev_err(&i2c->dev, "Failed to enable core supplies: %d\n", 2247 dev_err(&i2c->dev, "Failed to enable core supplies: %d\n",
2042 ret); 2248 ret);
2043 goto err_core; 2249 return ret;
2044 } 2250 }
2045 2251
2046 if (wm2200->pdata.ldo_ena) { 2252 if (wm2200->pdata.ldo_ena) {
2047 ret = gpio_request_one(wm2200->pdata.ldo_ena, 2253 ret = devm_gpio_request_one(&i2c->dev, wm2200->pdata.ldo_ena,
2048 GPIOF_OUT_INIT_HIGH, "WM2200 LDOENA"); 2254 GPIOF_OUT_INIT_HIGH,
2255 "WM2200 LDOENA");
2049 if (ret < 0) { 2256 if (ret < 0) {
2050 dev_err(&i2c->dev, "Failed to request LDOENA %d: %d\n", 2257 dev_err(&i2c->dev, "Failed to request LDOENA %d: %d\n",
2051 wm2200->pdata.ldo_ena, ret); 2258 wm2200->pdata.ldo_ena, ret);
@@ -2055,8 +2262,9 @@ static __devinit int wm2200_i2c_probe(struct i2c_client *i2c,
2055 } 2262 }
2056 2263
2057 if (wm2200->pdata.reset) { 2264 if (wm2200->pdata.reset) {
2058 ret = gpio_request_one(wm2200->pdata.reset, 2265 ret = devm_gpio_request_one(&i2c->dev, wm2200->pdata.reset,
2059 GPIOF_OUT_INIT_HIGH, "WM2200 /RESET"); 2266 GPIOF_OUT_INIT_HIGH,
2267 "WM2200 /RESET");
2060 if (ret < 0) { 2268 if (ret < 0) {
2061 dev_err(&i2c->dev, "Failed to request /RESET %d: %d\n", 2269 dev_err(&i2c->dev, "Failed to request /RESET %d: %d\n",
2062 wm2200->pdata.reset, ret); 2270 wm2200->pdata.reset, ret);
@@ -2166,24 +2374,14 @@ static __devinit int wm2200_i2c_probe(struct i2c_client *i2c,
2166err_pm_runtime: 2374err_pm_runtime:
2167 pm_runtime_disable(&i2c->dev); 2375 pm_runtime_disable(&i2c->dev);
2168err_reset: 2376err_reset:
2169 if (wm2200->pdata.reset) { 2377 if (wm2200->pdata.reset)
2170 gpio_set_value_cansleep(wm2200->pdata.reset, 0); 2378 gpio_set_value_cansleep(wm2200->pdata.reset, 0);
2171 gpio_free(wm2200->pdata.reset);
2172 }
2173err_ldo: 2379err_ldo:
2174 if (wm2200->pdata.ldo_ena) { 2380 if (wm2200->pdata.ldo_ena)
2175 gpio_set_value_cansleep(wm2200->pdata.ldo_ena, 0); 2381 gpio_set_value_cansleep(wm2200->pdata.ldo_ena, 0);
2176 gpio_free(wm2200->pdata.ldo_ena);
2177 }
2178err_enable: 2382err_enable:
2179 regulator_bulk_disable(ARRAY_SIZE(wm2200->core_supplies), 2383 regulator_bulk_disable(ARRAY_SIZE(wm2200->core_supplies),
2180 wm2200->core_supplies); 2384 wm2200->core_supplies);
2181err_core:
2182 regulator_bulk_free(ARRAY_SIZE(wm2200->core_supplies),
2183 wm2200->core_supplies);
2184err_regmap:
2185 regmap_exit(wm2200->regmap);
2186err:
2187 return ret; 2385 return ret;
2188} 2386}
2189 2387
@@ -2194,17 +2392,10 @@ static __devexit int wm2200_i2c_remove(struct i2c_client *i2c)
2194 snd_soc_unregister_codec(&i2c->dev); 2392 snd_soc_unregister_codec(&i2c->dev);
2195 if (i2c->irq) 2393 if (i2c->irq)
2196 free_irq(i2c->irq, wm2200); 2394 free_irq(i2c->irq, wm2200);
2197 if (wm2200->pdata.reset) { 2395 if (wm2200->pdata.reset)
2198 gpio_set_value_cansleep(wm2200->pdata.reset, 0); 2396 gpio_set_value_cansleep(wm2200->pdata.reset, 0);
2199 gpio_free(wm2200->pdata.reset); 2397 if (wm2200->pdata.ldo_ena)
2200 }
2201 if (wm2200->pdata.ldo_ena) {
2202 gpio_set_value_cansleep(wm2200->pdata.ldo_ena, 0); 2398 gpio_set_value_cansleep(wm2200->pdata.ldo_ena, 0);
2203 gpio_free(wm2200->pdata.ldo_ena);
2204 }
2205 regulator_bulk_free(ARRAY_SIZE(wm2200->core_supplies),
2206 wm2200->core_supplies);
2207 regmap_exit(wm2200->regmap);
2208 2399
2209 return 0; 2400 return 0;
2210} 2401}
diff --git a/sound/soc/codecs/wm5100.c b/sound/soc/codecs/wm5100.c
index 7f567585832e..9f57996ff272 100644
--- a/sound/soc/codecs/wm5100.c
+++ b/sound/soc/codecs/wm5100.c
@@ -1233,7 +1233,7 @@ static const struct snd_soc_dapm_route wm5100_dapm_routes[] = {
1233 { "PWM2", NULL, "PWM2 Driver" }, 1233 { "PWM2", NULL, "PWM2 Driver" },
1234}; 1234};
1235 1235
1236static const __devinitconst struct reg_default wm5100_reva_patches[] = { 1236static const struct reg_default wm5100_reva_patches[] = {
1237 { WM5100_AUDIO_IF_1_10, 0 }, 1237 { WM5100_AUDIO_IF_1_10, 0 },
1238 { WM5100_AUDIO_IF_1_11, 1 }, 1238 { WM5100_AUDIO_IF_1_11, 1 },
1239 { WM5100_AUDIO_IF_1_12, 2 }, 1239 { WM5100_AUDIO_IF_1_12, 2 },
diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c
index 1722b586bdba..27f7e38e7eca 100644
--- a/sound/soc/codecs/wm5102.c
+++ b/sound/soc/codecs/wm5102.c
@@ -31,6 +31,7 @@
31 31
32#include "arizona.h" 32#include "arizona.h"
33#include "wm5102.h" 33#include "wm5102.h"
34#include "wm_adsp.h"
34 35
35struct wm5102_priv { 36struct wm5102_priv {
36 struct arizona_priv core; 37 struct arizona_priv core;
@@ -42,6 +43,563 @@ static DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
42static DECLARE_TLV_DB_SCALE(digital_tlv, -6400, 50, 0); 43static DECLARE_TLV_DB_SCALE(digital_tlv, -6400, 50, 0);
43static DECLARE_TLV_DB_SCALE(noise_tlv, 0, 600, 0); 44static DECLARE_TLV_DB_SCALE(noise_tlv, 0, 600, 0);
44 45
46static const struct wm_adsp_region wm5102_dsp1_regions[] = {
47 { .type = WMFW_ADSP2_PM, .base = 0x100000 },
48 { .type = WMFW_ADSP2_ZM, .base = 0x180000 },
49 { .type = WMFW_ADSP2_XM, .base = 0x190000 },
50 { .type = WMFW_ADSP2_YM, .base = 0x1a8000 },
51};
52
53static const struct reg_default wm5102_sysclk_reva_patch[] = {
54 { 0x3000, 0x2225 },
55 { 0x3001, 0x3a03 },
56 { 0x3002, 0x0225 },
57 { 0x3003, 0x0801 },
58 { 0x3004, 0x6249 },
59 { 0x3005, 0x0c04 },
60 { 0x3006, 0x0225 },
61 { 0x3007, 0x5901 },
62 { 0x3008, 0xe249 },
63 { 0x3009, 0x030d },
64 { 0x300a, 0x0249 },
65 { 0x300b, 0x2c01 },
66 { 0x300c, 0xe249 },
67 { 0x300d, 0x4342 },
68 { 0x300e, 0xe249 },
69 { 0x300f, 0x73c0 },
70 { 0x3010, 0x4249 },
71 { 0x3011, 0x0c00 },
72 { 0x3012, 0x0225 },
73 { 0x3013, 0x1f01 },
74 { 0x3014, 0x0225 },
75 { 0x3015, 0x1e01 },
76 { 0x3016, 0x0225 },
77 { 0x3017, 0xfa00 },
78 { 0x3018, 0x0000 },
79 { 0x3019, 0xf000 },
80 { 0x301a, 0x0000 },
81 { 0x301b, 0xf000 },
82 { 0x301c, 0x0000 },
83 { 0x301d, 0xf000 },
84 { 0x301e, 0x0000 },
85 { 0x301f, 0xf000 },
86 { 0x3020, 0x0000 },
87 { 0x3021, 0xf000 },
88 { 0x3022, 0x0000 },
89 { 0x3023, 0xf000 },
90 { 0x3024, 0x0000 },
91 { 0x3025, 0xf000 },
92 { 0x3026, 0x0000 },
93 { 0x3027, 0xf000 },
94 { 0x3028, 0x0000 },
95 { 0x3029, 0xf000 },
96 { 0x302a, 0x0000 },
97 { 0x302b, 0xf000 },
98 { 0x302c, 0x0000 },
99 { 0x302d, 0xf000 },
100 { 0x302e, 0x0000 },
101 { 0x302f, 0xf000 },
102 { 0x3030, 0x0225 },
103 { 0x3031, 0x1a01 },
104 { 0x3032, 0x0225 },
105 { 0x3033, 0x1e00 },
106 { 0x3034, 0x0225 },
107 { 0x3035, 0x1f00 },
108 { 0x3036, 0x6225 },
109 { 0x3037, 0xf800 },
110 { 0x3038, 0x0000 },
111 { 0x3039, 0xf000 },
112 { 0x303a, 0x0000 },
113 { 0x303b, 0xf000 },
114 { 0x303c, 0x0000 },
115 { 0x303d, 0xf000 },
116 { 0x303e, 0x0000 },
117 { 0x303f, 0xf000 },
118 { 0x3040, 0x2226 },
119 { 0x3041, 0x3a03 },
120 { 0x3042, 0x0226 },
121 { 0x3043, 0x0801 },
122 { 0x3044, 0x6249 },
123 { 0x3045, 0x0c06 },
124 { 0x3046, 0x0226 },
125 { 0x3047, 0x5901 },
126 { 0x3048, 0xe249 },
127 { 0x3049, 0x030d },
128 { 0x304a, 0x0249 },
129 { 0x304b, 0x2c01 },
130 { 0x304c, 0xe249 },
131 { 0x304d, 0x4342 },
132 { 0x304e, 0xe249 },
133 { 0x304f, 0x73c0 },
134 { 0x3050, 0x4249 },
135 { 0x3051, 0x0c00 },
136 { 0x3052, 0x0226 },
137 { 0x3053, 0x1f01 },
138 { 0x3054, 0x0226 },
139 { 0x3055, 0x1e01 },
140 { 0x3056, 0x0226 },
141 { 0x3057, 0xfa00 },
142 { 0x3058, 0x0000 },
143 { 0x3059, 0xf000 },
144 { 0x305a, 0x0000 },
145 { 0x305b, 0xf000 },
146 { 0x305c, 0x0000 },
147 { 0x305d, 0xf000 },
148 { 0x305e, 0x0000 },
149 { 0x305f, 0xf000 },
150 { 0x3060, 0x0000 },
151 { 0x3061, 0xf000 },
152 { 0x3062, 0x0000 },
153 { 0x3063, 0xf000 },
154 { 0x3064, 0x0000 },
155 { 0x3065, 0xf000 },
156 { 0x3066, 0x0000 },
157 { 0x3067, 0xf000 },
158 { 0x3068, 0x0000 },
159 { 0x3069, 0xf000 },
160 { 0x306a, 0x0000 },
161 { 0x306b, 0xf000 },
162 { 0x306c, 0x0000 },
163 { 0x306d, 0xf000 },
164 { 0x306e, 0x0000 },
165 { 0x306f, 0xf000 },
166 { 0x3070, 0x0226 },
167 { 0x3071, 0x1a01 },
168 { 0x3072, 0x0226 },
169 { 0x3073, 0x1e00 },
170 { 0x3074, 0x0226 },
171 { 0x3075, 0x1f00 },
172 { 0x3076, 0x6226 },
173 { 0x3077, 0xf800 },
174 { 0x3078, 0x0000 },
175 { 0x3079, 0xf000 },
176 { 0x307a, 0x0000 },
177 { 0x307b, 0xf000 },
178 { 0x307c, 0x0000 },
179 { 0x307d, 0xf000 },
180 { 0x307e, 0x0000 },
181 { 0x307f, 0xf000 },
182 { 0x3080, 0x2227 },
183 { 0x3081, 0x3a03 },
184 { 0x3082, 0x0227 },
185 { 0x3083, 0x0801 },
186 { 0x3084, 0x6255 },
187 { 0x3085, 0x0c04 },
188 { 0x3086, 0x0227 },
189 { 0x3087, 0x5901 },
190 { 0x3088, 0xe255 },
191 { 0x3089, 0x030d },
192 { 0x308a, 0x0255 },
193 { 0x308b, 0x2c01 },
194 { 0x308c, 0xe255 },
195 { 0x308d, 0x4342 },
196 { 0x308e, 0xe255 },
197 { 0x308f, 0x73c0 },
198 { 0x3090, 0x4255 },
199 { 0x3091, 0x0c00 },
200 { 0x3092, 0x0227 },
201 { 0x3093, 0x1f01 },
202 { 0x3094, 0x0227 },
203 { 0x3095, 0x1e01 },
204 { 0x3096, 0x0227 },
205 { 0x3097, 0xfa00 },
206 { 0x3098, 0x0000 },
207 { 0x3099, 0xf000 },
208 { 0x309a, 0x0000 },
209 { 0x309b, 0xf000 },
210 { 0x309c, 0x0000 },
211 { 0x309d, 0xf000 },
212 { 0x309e, 0x0000 },
213 { 0x309f, 0xf000 },
214 { 0x30a0, 0x0000 },
215 { 0x30a1, 0xf000 },
216 { 0x30a2, 0x0000 },
217 { 0x30a3, 0xf000 },
218 { 0x30a4, 0x0000 },
219 { 0x30a5, 0xf000 },
220 { 0x30a6, 0x0000 },
221 { 0x30a7, 0xf000 },
222 { 0x30a8, 0x0000 },
223 { 0x30a9, 0xf000 },
224 { 0x30aa, 0x0000 },
225 { 0x30ab, 0xf000 },
226 { 0x30ac, 0x0000 },
227 { 0x30ad, 0xf000 },
228 { 0x30ae, 0x0000 },
229 { 0x30af, 0xf000 },
230 { 0x30b0, 0x0227 },
231 { 0x30b1, 0x1a01 },
232 { 0x30b2, 0x0227 },
233 { 0x30b3, 0x1e00 },
234 { 0x30b4, 0x0227 },
235 { 0x30b5, 0x1f00 },
236 { 0x30b6, 0x6227 },
237 { 0x30b7, 0xf800 },
238 { 0x30b8, 0x0000 },
239 { 0x30b9, 0xf000 },
240 { 0x30ba, 0x0000 },
241 { 0x30bb, 0xf000 },
242 { 0x30bc, 0x0000 },
243 { 0x30bd, 0xf000 },
244 { 0x30be, 0x0000 },
245 { 0x30bf, 0xf000 },
246 { 0x30c0, 0x2228 },
247 { 0x30c1, 0x3a03 },
248 { 0x30c2, 0x0228 },
249 { 0x30c3, 0x0801 },
250 { 0x30c4, 0x6255 },
251 { 0x30c5, 0x0c06 },
252 { 0x30c6, 0x0228 },
253 { 0x30c7, 0x5901 },
254 { 0x30c8, 0xe255 },
255 { 0x30c9, 0x030d },
256 { 0x30ca, 0x0255 },
257 { 0x30cb, 0x2c01 },
258 { 0x30cc, 0xe255 },
259 { 0x30cd, 0x4342 },
260 { 0x30ce, 0xe255 },
261 { 0x30cf, 0x73c0 },
262 { 0x30d0, 0x4255 },
263 { 0x30d1, 0x0c00 },
264 { 0x30d2, 0x0228 },
265 { 0x30d3, 0x1f01 },
266 { 0x30d4, 0x0228 },
267 { 0x30d5, 0x1e01 },
268 { 0x30d6, 0x0228 },
269 { 0x30d7, 0xfa00 },
270 { 0x30d8, 0x0000 },
271 { 0x30d9, 0xf000 },
272 { 0x30da, 0x0000 },
273 { 0x30db, 0xf000 },
274 { 0x30dc, 0x0000 },
275 { 0x30dd, 0xf000 },
276 { 0x30de, 0x0000 },
277 { 0x30df, 0xf000 },
278 { 0x30e0, 0x0000 },
279 { 0x30e1, 0xf000 },
280 { 0x30e2, 0x0000 },
281 { 0x30e3, 0xf000 },
282 { 0x30e4, 0x0000 },
283 { 0x30e5, 0xf000 },
284 { 0x30e6, 0x0000 },
285 { 0x30e7, 0xf000 },
286 { 0x30e8, 0x0000 },
287 { 0x30e9, 0xf000 },
288 { 0x30ea, 0x0000 },
289 { 0x30eb, 0xf000 },
290 { 0x30ec, 0x0000 },
291 { 0x30ed, 0xf000 },
292 { 0x30ee, 0x0000 },
293 { 0x30ef, 0xf000 },
294 { 0x30f0, 0x0228 },
295 { 0x30f1, 0x1a01 },
296 { 0x30f2, 0x0228 },
297 { 0x30f3, 0x1e00 },
298 { 0x30f4, 0x0228 },
299 { 0x30f5, 0x1f00 },
300 { 0x30f6, 0x6228 },
301 { 0x30f7, 0xf800 },
302 { 0x30f8, 0x0000 },
303 { 0x30f9, 0xf000 },
304 { 0x30fa, 0x0000 },
305 { 0x30fb, 0xf000 },
306 { 0x30fc, 0x0000 },
307 { 0x30fd, 0xf000 },
308 { 0x30fe, 0x0000 },
309 { 0x30ff, 0xf000 },
310 { 0x3100, 0x222b },
311 { 0x3101, 0x3a03 },
312 { 0x3102, 0x222b },
313 { 0x3103, 0x5803 },
314 { 0x3104, 0xe26f },
315 { 0x3105, 0x030d },
316 { 0x3106, 0x626f },
317 { 0x3107, 0x2c01 },
318 { 0x3108, 0xe26f },
319 { 0x3109, 0x4342 },
320 { 0x310a, 0xe26f },
321 { 0x310b, 0x73c0 },
322 { 0x310c, 0x026f },
323 { 0x310d, 0x0c00 },
324 { 0x310e, 0x022b },
325 { 0x310f, 0x1f01 },
326 { 0x3110, 0x022b },
327 { 0x3111, 0x1e01 },
328 { 0x3112, 0x022b },
329 { 0x3113, 0xfa00 },
330 { 0x3114, 0x0000 },
331 { 0x3115, 0xf000 },
332 { 0x3116, 0x0000 },
333 { 0x3117, 0xf000 },
334 { 0x3118, 0x0000 },
335 { 0x3119, 0xf000 },
336 { 0x311a, 0x0000 },
337 { 0x311b, 0xf000 },
338 { 0x311c, 0x0000 },
339 { 0x311d, 0xf000 },
340 { 0x311e, 0x0000 },
341 { 0x311f, 0xf000 },
342 { 0x3120, 0x022b },
343 { 0x3121, 0x0a01 },
344 { 0x3122, 0x022b },
345 { 0x3123, 0x1e00 },
346 { 0x3124, 0x022b },
347 { 0x3125, 0x1f00 },
348 { 0x3126, 0x622b },
349 { 0x3127, 0xf800 },
350 { 0x3128, 0x0000 },
351 { 0x3129, 0xf000 },
352 { 0x312a, 0x0000 },
353 { 0x312b, 0xf000 },
354 { 0x312c, 0x0000 },
355 { 0x312d, 0xf000 },
356 { 0x312e, 0x0000 },
357 { 0x312f, 0xf000 },
358 { 0x3130, 0x0000 },
359 { 0x3131, 0xf000 },
360 { 0x3132, 0x0000 },
361 { 0x3133, 0xf000 },
362 { 0x3134, 0x0000 },
363 { 0x3135, 0xf000 },
364 { 0x3136, 0x0000 },
365 { 0x3137, 0xf000 },
366 { 0x3138, 0x0000 },
367 { 0x3139, 0xf000 },
368 { 0x313a, 0x0000 },
369 { 0x313b, 0xf000 },
370 { 0x313c, 0x0000 },
371 { 0x313d, 0xf000 },
372 { 0x313e, 0x0000 },
373 { 0x313f, 0xf000 },
374 { 0x3140, 0x0000 },
375 { 0x3141, 0xf000 },
376 { 0x3142, 0x0000 },
377 { 0x3143, 0xf000 },
378 { 0x3144, 0x0000 },
379 { 0x3145, 0xf000 },
380 { 0x3146, 0x0000 },
381 { 0x3147, 0xf000 },
382 { 0x3148, 0x0000 },
383 { 0x3149, 0xf000 },
384 { 0x314a, 0x0000 },
385 { 0x314b, 0xf000 },
386 { 0x314c, 0x0000 },
387 { 0x314d, 0xf000 },
388 { 0x314e, 0x0000 },
389 { 0x314f, 0xf000 },
390 { 0x3150, 0x0000 },
391 { 0x3151, 0xf000 },
392 { 0x3152, 0x0000 },
393 { 0x3153, 0xf000 },
394 { 0x3154, 0x0000 },
395 { 0x3155, 0xf000 },
396 { 0x3156, 0x0000 },
397 { 0x3157, 0xf000 },
398 { 0x3158, 0x0000 },
399 { 0x3159, 0xf000 },
400 { 0x315a, 0x0000 },
401 { 0x315b, 0xf000 },
402 { 0x315c, 0x0000 },
403 { 0x315d, 0xf000 },
404 { 0x315e, 0x0000 },
405 { 0x315f, 0xf000 },
406 { 0x3160, 0x0000 },
407 { 0x3161, 0xf000 },
408 { 0x3162, 0x0000 },
409 { 0x3163, 0xf000 },
410 { 0x3164, 0x0000 },
411 { 0x3165, 0xf000 },
412 { 0x3166, 0x0000 },
413 { 0x3167, 0xf000 },
414 { 0x3168, 0x0000 },
415 { 0x3169, 0xf000 },
416 { 0x316a, 0x0000 },
417 { 0x316b, 0xf000 },
418 { 0x316c, 0x0000 },
419 { 0x316d, 0xf000 },
420 { 0x316e, 0x0000 },
421 { 0x316f, 0xf000 },
422 { 0x3170, 0x0000 },
423 { 0x3171, 0xf000 },
424 { 0x3172, 0x0000 },
425 { 0x3173, 0xf000 },
426 { 0x3174, 0x0000 },
427 { 0x3175, 0xf000 },
428 { 0x3176, 0x0000 },
429 { 0x3177, 0xf000 },
430 { 0x3178, 0x0000 },
431 { 0x3179, 0xf000 },
432 { 0x317a, 0x0000 },
433 { 0x317b, 0xf000 },
434 { 0x317c, 0x0000 },
435 { 0x317d, 0xf000 },
436 { 0x317e, 0x0000 },
437 { 0x317f, 0xf000 },
438 { 0x3180, 0x2001 },
439 { 0x3181, 0xf101 },
440 { 0x3182, 0x0000 },
441 { 0x3183, 0xf000 },
442 { 0x3184, 0x0000 },
443 { 0x3185, 0xf000 },
444 { 0x3186, 0x0000 },
445 { 0x3187, 0xf000 },
446 { 0x3188, 0x0000 },
447 { 0x3189, 0xf000 },
448 { 0x318a, 0x0000 },
449 { 0x318b, 0xf000 },
450 { 0x318c, 0x0000 },
451 { 0x318d, 0xf000 },
452 { 0x318e, 0x0000 },
453 { 0x318f, 0xf000 },
454 { 0x3190, 0x0000 },
455 { 0x3191, 0xf000 },
456 { 0x3192, 0x0000 },
457 { 0x3193, 0xf000 },
458 { 0x3194, 0x0000 },
459 { 0x3195, 0xf000 },
460 { 0x3196, 0x0000 },
461 { 0x3197, 0xf000 },
462 { 0x3198, 0x0000 },
463 { 0x3199, 0xf000 },
464 { 0x319a, 0x0000 },
465 { 0x319b, 0xf000 },
466 { 0x319c, 0x0000 },
467 { 0x319d, 0xf000 },
468 { 0x319e, 0x0000 },
469 { 0x319f, 0xf000 },
470 { 0x31a0, 0x0000 },
471 { 0x31a1, 0xf000 },
472 { 0x31a2, 0x0000 },
473 { 0x31a3, 0xf000 },
474 { 0x31a4, 0x0000 },
475 { 0x31a5, 0xf000 },
476 { 0x31a6, 0x0000 },
477 { 0x31a7, 0xf000 },
478 { 0x31a8, 0x0000 },
479 { 0x31a9, 0xf000 },
480 { 0x31aa, 0x0000 },
481 { 0x31ab, 0xf000 },
482 { 0x31ac, 0x0000 },
483 { 0x31ad, 0xf000 },
484 { 0x31ae, 0x0000 },
485 { 0x31af, 0xf000 },
486 { 0x31b0, 0x0000 },
487 { 0x31b1, 0xf000 },
488 { 0x31b2, 0x0000 },
489 { 0x31b3, 0xf000 },
490 { 0x31b4, 0x0000 },
491 { 0x31b5, 0xf000 },
492 { 0x31b6, 0x0000 },
493 { 0x31b7, 0xf000 },
494 { 0x31b8, 0x0000 },
495 { 0x31b9, 0xf000 },
496 { 0x31ba, 0x0000 },
497 { 0x31bb, 0xf000 },
498 { 0x31bc, 0x0000 },
499 { 0x31bd, 0xf000 },
500 { 0x31be, 0x0000 },
501 { 0x31bf, 0xf000 },
502 { 0x31c0, 0x0000 },
503 { 0x31c1, 0xf000 },
504 { 0x31c2, 0x0000 },
505 { 0x31c3, 0xf000 },
506 { 0x31c4, 0x0000 },
507 { 0x31c5, 0xf000 },
508 { 0x31c6, 0x0000 },
509 { 0x31c7, 0xf000 },
510 { 0x31c8, 0x0000 },
511 { 0x31c9, 0xf000 },
512 { 0x31ca, 0x0000 },
513 { 0x31cb, 0xf000 },
514 { 0x31cc, 0x0000 },
515 { 0x31cd, 0xf000 },
516 { 0x31ce, 0x0000 },
517 { 0x31cf, 0xf000 },
518 { 0x31d0, 0x0000 },
519 { 0x31d1, 0xf000 },
520 { 0x31d2, 0x0000 },
521 { 0x31d3, 0xf000 },
522 { 0x31d4, 0x0000 },
523 { 0x31d5, 0xf000 },
524 { 0x31d6, 0x0000 },
525 { 0x31d7, 0xf000 },
526 { 0x31d8, 0x0000 },
527 { 0x31d9, 0xf000 },
528 { 0x31da, 0x0000 },
529 { 0x31db, 0xf000 },
530 { 0x31dc, 0x0000 },
531 { 0x31dd, 0xf000 },
532 { 0x31de, 0x0000 },
533 { 0x31df, 0xf000 },
534 { 0x31e0, 0x0000 },
535 { 0x31e1, 0xf000 },
536 { 0x31e2, 0x0000 },
537 { 0x31e3, 0xf000 },
538 { 0x31e4, 0x0000 },
539 { 0x31e5, 0xf000 },
540 { 0x31e6, 0x0000 },
541 { 0x31e7, 0xf000 },
542 { 0x31e8, 0x0000 },
543 { 0x31e9, 0xf000 },
544 { 0x31ea, 0x0000 },
545 { 0x31eb, 0xf000 },
546 { 0x31ec, 0x0000 },
547 { 0x31ed, 0xf000 },
548 { 0x31ee, 0x0000 },
549 { 0x31ef, 0xf000 },
550 { 0x31f0, 0x0000 },
551 { 0x31f1, 0xf000 },
552 { 0x31f2, 0x0000 },
553 { 0x31f3, 0xf000 },
554 { 0x31f4, 0x0000 },
555 { 0x31f5, 0xf000 },
556 { 0x31f6, 0x0000 },
557 { 0x31f7, 0xf000 },
558 { 0x31f8, 0x0000 },
559 { 0x31f9, 0xf000 },
560 { 0x31fa, 0x0000 },
561 { 0x31fb, 0xf000 },
562 { 0x31fc, 0x0000 },
563 { 0x31fd, 0xf000 },
564 { 0x31fe, 0x0000 },
565 { 0x31ff, 0xf000 },
566 { 0x024d, 0xff50 },
567 { 0x0252, 0xff50 },
568 { 0x0259, 0x0112 },
569 { 0x025e, 0x0112 },
570};
571
572static int wm5102_sysclk_ev(struct snd_soc_dapm_widget *w,
573 struct snd_kcontrol *kcontrol, int event)
574{
575 struct snd_soc_codec *codec = w->codec;
576 struct arizona *arizona = dev_get_drvdata(codec->dev);
577 struct regmap *regmap = codec->control_data;
578 const struct reg_default *patch = NULL;
579 int i, patch_size;
580
581 switch (arizona->rev) {
582 case 0:
583 patch = wm5102_sysclk_reva_patch;
584 patch_size = ARRAY_SIZE(wm5102_sysclk_reva_patch);
585 break;
586 }
587
588 switch (event) {
589 case SND_SOC_DAPM_POST_PMU:
590 if (patch)
591 for (i = 0; i < patch_size; i++)
592 regmap_write(regmap, patch[i].reg,
593 patch[i].def);
594 break;
595
596 default:
597 break;
598 }
599
600 return 0;
601}
602
45static const struct snd_kcontrol_new wm5102_snd_controls[] = { 603static const struct snd_kcontrol_new wm5102_snd_controls[] = {
46SOC_SINGLE("IN1 High Performance Switch", ARIZONA_IN1L_CONTROL, 604SOC_SINGLE("IN1 High Performance Switch", ARIZONA_IN1L_CONTROL,
47 ARIZONA_IN1_OSR_SHIFT, 1, 0), 605 ARIZONA_IN1_OSR_SHIFT, 1, 0),
@@ -77,11 +635,23 @@ SOC_DOUBLE_R_TLV("IN3 Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_3L,
77 ARIZONA_ADC_DIGITAL_VOLUME_3R, ARIZONA_IN3L_DIG_VOL_SHIFT, 635 ARIZONA_ADC_DIGITAL_VOLUME_3R, ARIZONA_IN3L_DIG_VOL_SHIFT,
78 0xbf, 0, digital_tlv), 636 0xbf, 0, digital_tlv),
79 637
638SOC_ENUM("Input Ramp Up", arizona_in_vi_ramp),
639SOC_ENUM("Input Ramp Down", arizona_in_vd_ramp),
640
80ARIZONA_MIXER_CONTROLS("EQ1", ARIZONA_EQ1MIX_INPUT_1_SOURCE), 641ARIZONA_MIXER_CONTROLS("EQ1", ARIZONA_EQ1MIX_INPUT_1_SOURCE),
81ARIZONA_MIXER_CONTROLS("EQ2", ARIZONA_EQ2MIX_INPUT_1_SOURCE), 642ARIZONA_MIXER_CONTROLS("EQ2", ARIZONA_EQ2MIX_INPUT_1_SOURCE),
82ARIZONA_MIXER_CONTROLS("EQ3", ARIZONA_EQ3MIX_INPUT_1_SOURCE), 643ARIZONA_MIXER_CONTROLS("EQ3", ARIZONA_EQ3MIX_INPUT_1_SOURCE),
83ARIZONA_MIXER_CONTROLS("EQ4", ARIZONA_EQ4MIX_INPUT_1_SOURCE), 644ARIZONA_MIXER_CONTROLS("EQ4", ARIZONA_EQ4MIX_INPUT_1_SOURCE),
84 645
646SND_SOC_BYTES_MASK("EQ1 Coefficeints", ARIZONA_EQ1_1, 21,
647 ARIZONA_EQ1_ENA_MASK),
648SND_SOC_BYTES_MASK("EQ2 Coefficeints", ARIZONA_EQ2_1, 21,
649 ARIZONA_EQ2_ENA_MASK),
650SND_SOC_BYTES_MASK("EQ3 Coefficeints", ARIZONA_EQ3_1, 21,
651 ARIZONA_EQ3_ENA_MASK),
652SND_SOC_BYTES_MASK("EQ4 Coefficeints", ARIZONA_EQ4_1, 21,
653 ARIZONA_EQ4_ENA_MASK),
654
85SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT, 655SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT,
86 24, 0, eq_tlv), 656 24, 0, eq_tlv),
87SOC_SINGLE_TLV("EQ1 B2 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B2_GAIN_SHIFT, 657SOC_SINGLE_TLV("EQ1 B2 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B2_GAIN_SHIFT,
@@ -137,6 +707,14 @@ ARIZONA_MIXER_CONTROLS("LHPF2", ARIZONA_HPLP2MIX_INPUT_1_SOURCE),
137ARIZONA_MIXER_CONTROLS("LHPF3", ARIZONA_HPLP3MIX_INPUT_1_SOURCE), 707ARIZONA_MIXER_CONTROLS("LHPF3", ARIZONA_HPLP3MIX_INPUT_1_SOURCE),
138ARIZONA_MIXER_CONTROLS("LHPF4", ARIZONA_HPLP4MIX_INPUT_1_SOURCE), 708ARIZONA_MIXER_CONTROLS("LHPF4", ARIZONA_HPLP4MIX_INPUT_1_SOURCE),
139 709
710SND_SOC_BYTES("LHPF1 Coefficients", ARIZONA_HPLPF1_2, 1),
711SND_SOC_BYTES("LHPF2 Coefficients", ARIZONA_HPLPF2_2, 1),
712SND_SOC_BYTES("LHPF3 Coefficients", ARIZONA_HPLPF3_2, 1),
713SND_SOC_BYTES("LHPF4 Coefficients", ARIZONA_HPLPF4_2, 1),
714
715ARIZONA_MIXER_CONTROLS("DSP1L", ARIZONA_DSP1LMIX_INPUT_1_SOURCE),
716ARIZONA_MIXER_CONTROLS("DSP1R", ARIZONA_DSP1RMIX_INPUT_1_SOURCE),
717
140SOC_ENUM("LHPF1 Mode", arizona_lhpf1_mode), 718SOC_ENUM("LHPF1 Mode", arizona_lhpf1_mode),
141SOC_ENUM("LHPF2 Mode", arizona_lhpf2_mode), 719SOC_ENUM("LHPF2 Mode", arizona_lhpf2_mode),
142SOC_ENUM("LHPF3 Mode", arizona_lhpf3_mode), 720SOC_ENUM("LHPF3 Mode", arizona_lhpf3_mode),
@@ -158,14 +736,6 @@ ARIZONA_MIXER_CONTROLS("SPKOUTR", ARIZONA_OUT4RMIX_INPUT_1_SOURCE),
158ARIZONA_MIXER_CONTROLS("SPKDAT1L", ARIZONA_OUT5LMIX_INPUT_1_SOURCE), 736ARIZONA_MIXER_CONTROLS("SPKDAT1L", ARIZONA_OUT5LMIX_INPUT_1_SOURCE),
159ARIZONA_MIXER_CONTROLS("SPKDAT1R", ARIZONA_OUT5RMIX_INPUT_1_SOURCE), 737ARIZONA_MIXER_CONTROLS("SPKDAT1R", ARIZONA_OUT5RMIX_INPUT_1_SOURCE),
160 738
161SOC_SINGLE("HPOUT1 High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_1L,
162 ARIZONA_OUT1_OSR_SHIFT, 1, 0),
163SOC_SINGLE("OUT2 High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_2L,
164 ARIZONA_OUT2_OSR_SHIFT, 1, 0),
165SOC_SINGLE("EPOUT High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_3L,
166 ARIZONA_OUT3_OSR_SHIFT, 1, 0),
167SOC_SINGLE("Speaker High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_4L,
168 ARIZONA_OUT4_OSR_SHIFT, 1, 0),
169SOC_SINGLE("SPKDAT1 High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_5L, 739SOC_SINGLE("SPKDAT1 High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_5L,
170 ARIZONA_OUT5_OSR_SHIFT, 1, 0), 740 ARIZONA_OUT5_OSR_SHIFT, 1, 0),
171 741
@@ -195,16 +765,8 @@ SOC_DOUBLE_R_TLV("SPKDAT1 Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_5L,
195 ARIZONA_DAC_DIGITAL_VOLUME_5R, ARIZONA_OUT5L_VOL_SHIFT, 765 ARIZONA_DAC_DIGITAL_VOLUME_5R, ARIZONA_OUT5L_VOL_SHIFT,
196 0xbf, 0, digital_tlv), 766 0xbf, 0, digital_tlv),
197 767
198SOC_DOUBLE_R_RANGE_TLV("HPOUT1 Volume", ARIZONA_OUTPUT_PATH_CONFIG_1L, 768SOC_ENUM("Output Ramp Up", arizona_out_vi_ramp),
199 ARIZONA_OUTPUT_PATH_CONFIG_1R, 769SOC_ENUM("Output Ramp Down", arizona_out_vd_ramp),
200 ARIZONA_OUT1L_PGA_VOL_SHIFT,
201 0x34, 0x40, 0, ana_tlv),
202SOC_DOUBLE_R_RANGE_TLV("OUT2 Volume", ARIZONA_OUTPUT_PATH_CONFIG_2L,
203 ARIZONA_OUTPUT_PATH_CONFIG_2R,
204 ARIZONA_OUT2L_PGA_VOL_SHIFT,
205 0x34, 0x40, 0, ana_tlv),
206SOC_SINGLE_RANGE_TLV("EPOUT Volume", ARIZONA_OUTPUT_PATH_CONFIG_3L,
207 ARIZONA_OUT3L_PGA_VOL_SHIFT, 0x34, 0x40, 0, ana_tlv),
208 770
209SOC_DOUBLE("SPKDAT1 Switch", ARIZONA_PDM_SPK1_CTRL_1, ARIZONA_SPK1L_MUTE_SHIFT, 771SOC_DOUBLE("SPKDAT1 Switch", ARIZONA_PDM_SPK1_CTRL_1, ARIZONA_SPK1L_MUTE_SHIFT,
210 ARIZONA_SPK1R_MUTE_SHIFT, 1, 1), 772 ARIZONA_SPK1R_MUTE_SHIFT, 1, 1),
@@ -269,11 +831,15 @@ ARIZONA_MIXER_ENUMS(AIF2TX2, ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE);
269ARIZONA_MIXER_ENUMS(AIF3TX1, ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE); 831ARIZONA_MIXER_ENUMS(AIF3TX1, ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE);
270ARIZONA_MIXER_ENUMS(AIF3TX2, ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE); 832ARIZONA_MIXER_ENUMS(AIF3TX2, ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE);
271 833
272ARIZONA_MIXER_ENUMS(ASRC1L, ARIZONA_ASRC1LMIX_INPUT_1_SOURCE); 834ARIZONA_MUX_ENUMS(ASRC1L, ARIZONA_ASRC1LMIX_INPUT_1_SOURCE);
273ARIZONA_MIXER_ENUMS(ASRC1R, ARIZONA_ASRC1RMIX_INPUT_1_SOURCE); 835ARIZONA_MUX_ENUMS(ASRC1R, ARIZONA_ASRC1RMIX_INPUT_1_SOURCE);
274ARIZONA_MIXER_ENUMS(ASRC2L, ARIZONA_ASRC2LMIX_INPUT_1_SOURCE); 836ARIZONA_MUX_ENUMS(ASRC2L, ARIZONA_ASRC2LMIX_INPUT_1_SOURCE);
275ARIZONA_MIXER_ENUMS(ASRC2R, ARIZONA_ASRC2RMIX_INPUT_1_SOURCE); 837ARIZONA_MUX_ENUMS(ASRC2R, ARIZONA_ASRC2RMIX_INPUT_1_SOURCE);
838
839ARIZONA_MIXER_ENUMS(DSP1L, ARIZONA_DSP1LMIX_INPUT_1_SOURCE);
840ARIZONA_MIXER_ENUMS(DSP1R, ARIZONA_DSP1RMIX_INPUT_1_SOURCE);
276 841
842ARIZONA_DSP_AUX_ENUMS(DSP1, ARIZONA_DSP1AUX1MIX_INPUT_1_SOURCE);
277 843
278static const char *wm5102_aec_loopback_texts[] = { 844static const char *wm5102_aec_loopback_texts[] = {
279 "HPOUT1L", "HPOUT1R", "HPOUT2L", "HPOUT2R", "EPOUT", 845 "HPOUT1L", "HPOUT1R", "HPOUT2L", "HPOUT2R", "EPOUT",
@@ -297,7 +863,7 @@ static const struct snd_kcontrol_new wm5102_aec_loopback_mux =
297 863
298static const struct snd_soc_dapm_widget wm5102_dapm_widgets[] = { 864static const struct snd_soc_dapm_widget wm5102_dapm_widgets[] = {
299SND_SOC_DAPM_SUPPLY("SYSCLK", ARIZONA_SYSTEM_CLOCK_1, ARIZONA_SYSCLK_ENA_SHIFT, 865SND_SOC_DAPM_SUPPLY("SYSCLK", ARIZONA_SYSTEM_CLOCK_1, ARIZONA_SYSCLK_ENA_SHIFT,
300 0, NULL, 0), 866 0, wm5102_sysclk_ev, SND_SOC_DAPM_POST_PMU),
301SND_SOC_DAPM_SUPPLY("ASYNCCLK", ARIZONA_ASYNC_CLOCK_1, 867SND_SOC_DAPM_SUPPLY("ASYNCCLK", ARIZONA_ASYNC_CLOCK_1,
302 ARIZONA_ASYNC_CLK_ENA_SHIFT, 0, NULL, 0), 868 ARIZONA_ASYNC_CLK_ENA_SHIFT, 0, NULL, 0),
303SND_SOC_DAPM_SUPPLY("OPCLK", ARIZONA_OUTPUT_SYSTEM_CLOCK, 869SND_SOC_DAPM_SUPPLY("OPCLK", ARIZONA_OUTPUT_SYSTEM_CLOCK,
@@ -314,6 +880,7 @@ SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDDR", 0, 0),
314 880
315SND_SOC_DAPM_SIGGEN("TONE"), 881SND_SOC_DAPM_SIGGEN("TONE"),
316SND_SOC_DAPM_SIGGEN("NOISE"), 882SND_SOC_DAPM_SIGGEN("NOISE"),
883SND_SOC_DAPM_SIGGEN("HAPTICS"),
317 884
318SND_SOC_DAPM_INPUT("IN1L"), 885SND_SOC_DAPM_INPUT("IN1L"),
319SND_SOC_DAPM_INPUT("IN1R"), 886SND_SOC_DAPM_INPUT("IN1R"),
@@ -344,9 +911,9 @@ SND_SOC_DAPM_PGA_E("IN3R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN3R_ENA_SHIFT,
344SND_SOC_DAPM_SUPPLY("MICBIAS1", ARIZONA_MIC_BIAS_CTRL_1, 911SND_SOC_DAPM_SUPPLY("MICBIAS1", ARIZONA_MIC_BIAS_CTRL_1,
345 ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0), 912 ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0),
346SND_SOC_DAPM_SUPPLY("MICBIAS2", ARIZONA_MIC_BIAS_CTRL_2, 913SND_SOC_DAPM_SUPPLY("MICBIAS2", ARIZONA_MIC_BIAS_CTRL_2,
347 ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0), 914 ARIZONA_MICB2_ENA_SHIFT, 0, NULL, 0),
348SND_SOC_DAPM_SUPPLY("MICBIAS3", ARIZONA_MIC_BIAS_CTRL_3, 915SND_SOC_DAPM_SUPPLY("MICBIAS3", ARIZONA_MIC_BIAS_CTRL_3,
349 ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0), 916 ARIZONA_MICB3_ENA_SHIFT, 0, NULL, 0),
350 917
351SND_SOC_DAPM_PGA("Noise Generator", ARIZONA_COMFORT_NOISE_GENERATOR, 918SND_SOC_DAPM_PGA("Noise Generator", ARIZONA_COMFORT_NOISE_GENERATOR,
352 ARIZONA_NOISE_GEN_ENA_SHIFT, 0, NULL, 0), 919 ARIZONA_NOISE_GEN_ENA_SHIFT, 0, NULL, 0),
@@ -446,6 +1013,8 @@ SND_SOC_DAPM_AIF_IN("AIF3RX1", NULL, 0,
446SND_SOC_DAPM_AIF_IN("AIF3RX2", NULL, 0, 1013SND_SOC_DAPM_AIF_IN("AIF3RX2", NULL, 0,
447 ARIZONA_AIF3_RX_ENABLES, ARIZONA_AIF3RX2_ENA_SHIFT, 0), 1014 ARIZONA_AIF3_RX_ENABLES, ARIZONA_AIF3RX2_ENA_SHIFT, 0),
448 1015
1016ARIZONA_DSP_WIDGETS(DSP1, "DSP1"),
1017
449SND_SOC_DAPM_VALUE_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1, 1018SND_SOC_DAPM_VALUE_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1,
450 ARIZONA_AEC_LOOPBACK_ENA, 0, &wm5102_aec_loopback_mux), 1019 ARIZONA_AEC_LOOPBACK_ENA, 0, &wm5102_aec_loopback_mux),
451 1020
@@ -521,10 +1090,12 @@ ARIZONA_MIXER_WIDGETS(AIF2TX2, "AIF2TX2"),
521ARIZONA_MIXER_WIDGETS(AIF3TX1, "AIF3TX1"), 1090ARIZONA_MIXER_WIDGETS(AIF3TX1, "AIF3TX1"),
522ARIZONA_MIXER_WIDGETS(AIF3TX2, "AIF3TX2"), 1091ARIZONA_MIXER_WIDGETS(AIF3TX2, "AIF3TX2"),
523 1092
524ARIZONA_MIXER_WIDGETS(ASRC1L, "ASRC1L"), 1093ARIZONA_MUX_WIDGETS(ASRC1L, "ASRC1L"),
525ARIZONA_MIXER_WIDGETS(ASRC1R, "ASRC1R"), 1094ARIZONA_MUX_WIDGETS(ASRC1R, "ASRC1R"),
526ARIZONA_MIXER_WIDGETS(ASRC2L, "ASRC2L"), 1095ARIZONA_MUX_WIDGETS(ASRC2L, "ASRC2L"),
527ARIZONA_MIXER_WIDGETS(ASRC2R, "ASRC2R"), 1096ARIZONA_MUX_WIDGETS(ASRC2R, "ASRC2R"),
1097
1098WM_ADSP2("DSP1", 0),
528 1099
529SND_SOC_DAPM_OUTPUT("HPOUT1L"), 1100SND_SOC_DAPM_OUTPUT("HPOUT1L"),
530SND_SOC_DAPM_OUTPUT("HPOUT1R"), 1101SND_SOC_DAPM_OUTPUT("HPOUT1R"),
@@ -544,6 +1115,7 @@ SND_SOC_DAPM_OUTPUT("SPKDAT1R"),
544 { name, "Noise Generator", "Noise Generator" }, \ 1115 { name, "Noise Generator", "Noise Generator" }, \
545 { name, "Tone Generator 1", "Tone Generator 1" }, \ 1116 { name, "Tone Generator 1", "Tone Generator 1" }, \
546 { name, "Tone Generator 2", "Tone Generator 2" }, \ 1117 { name, "Tone Generator 2", "Tone Generator 2" }, \
1118 { name, "Haptics", "HAPTICS" }, \
547 { name, "AEC", "AEC Loopback" }, \ 1119 { name, "AEC", "AEC Loopback" }, \
548 { name, "IN1L", "IN1L PGA" }, \ 1120 { name, "IN1L", "IN1L PGA" }, \
549 { name, "IN1R", "IN1R PGA" }, \ 1121 { name, "IN1R", "IN1R PGA" }, \
@@ -577,7 +1149,13 @@ SND_SOC_DAPM_OUTPUT("SPKDAT1R"),
577 { name, "ASRC1L", "ASRC1L" }, \ 1149 { name, "ASRC1L", "ASRC1L" }, \
578 { name, "ASRC1R", "ASRC1R" }, \ 1150 { name, "ASRC1R", "ASRC1R" }, \
579 { name, "ASRC2L", "ASRC2L" }, \ 1151 { name, "ASRC2L", "ASRC2L" }, \
580 { name, "ASRC2R", "ASRC2R" } 1152 { name, "ASRC2R", "ASRC2R" }, \
1153 { name, "DSP1.1", "DSP1" }, \
1154 { name, "DSP1.2", "DSP1" }, \
1155 { name, "DSP1.3", "DSP1" }, \
1156 { name, "DSP1.4", "DSP1" }, \
1157 { name, "DSP1.5", "DSP1" }, \
1158 { name, "DSP1.6", "DSP1" }
581 1159
582static const struct snd_soc_dapm_route wm5102_dapm_routes[] = { 1160static const struct snd_soc_dapm_route wm5102_dapm_routes[] = {
583 { "AIF2 Capture", NULL, "DBVDD2" }, 1161 { "AIF2 Capture", NULL, "DBVDD2" },
@@ -663,6 +1241,11 @@ static const struct snd_soc_dapm_route wm5102_dapm_routes[] = {
663 { "IN3L PGA", NULL, "IN3L" }, 1241 { "IN3L PGA", NULL, "IN3L" },
664 { "IN3R PGA", NULL, "IN3R" }, 1242 { "IN3R PGA", NULL, "IN3R" },
665 1243
1244 { "ASRC1L", NULL, "ASRC1L Input" },
1245 { "ASRC1R", NULL, "ASRC1R Input" },
1246 { "ASRC2L", NULL, "ASRC2L Input" },
1247 { "ASRC2R", NULL, "ASRC2R Input" },
1248
666 ARIZONA_MIXER_ROUTES("OUT1L", "HPOUT1L"), 1249 ARIZONA_MIXER_ROUTES("OUT1L", "HPOUT1L"),
667 ARIZONA_MIXER_ROUTES("OUT1R", "HPOUT1R"), 1250 ARIZONA_MIXER_ROUTES("OUT1R", "HPOUT1R"),
668 ARIZONA_MIXER_ROUTES("OUT2L", "HPOUT2L"), 1251 ARIZONA_MIXER_ROUTES("OUT2L", "HPOUT2L"),
@@ -705,10 +1288,12 @@ static const struct snd_soc_dapm_route wm5102_dapm_routes[] = {
705 ARIZONA_MIXER_ROUTES("LHPF3", "LHPF3"), 1288 ARIZONA_MIXER_ROUTES("LHPF3", "LHPF3"),
706 ARIZONA_MIXER_ROUTES("LHPF4", "LHPF4"), 1289 ARIZONA_MIXER_ROUTES("LHPF4", "LHPF4"),
707 1290
708 ARIZONA_MIXER_ROUTES("ASRC1L", "ASRC1L"), 1291 ARIZONA_MUX_ROUTES("ASRC1L"),
709 ARIZONA_MIXER_ROUTES("ASRC1R", "ASRC1R"), 1292 ARIZONA_MUX_ROUTES("ASRC1R"),
710 ARIZONA_MIXER_ROUTES("ASRC2L", "ASRC2L"), 1293 ARIZONA_MUX_ROUTES("ASRC2L"),
711 ARIZONA_MIXER_ROUTES("ASRC2R", "ASRC2R"), 1294 ARIZONA_MUX_ROUTES("ASRC2R"),
1295
1296 ARIZONA_DSP_ROUTES("DSP1"),
712 1297
713 { "AEC Loopback", "HPOUT1L", "OUT1L" }, 1298 { "AEC Loopback", "HPOUT1L", "OUT1L" },
714 { "AEC Loopback", "HPOUT1R", "OUT1R" }, 1299 { "AEC Loopback", "HPOUT1R", "OUT1R" },
@@ -827,9 +1412,28 @@ static struct snd_soc_dai_driver wm5102_dai[] = {
827static int wm5102_codec_probe(struct snd_soc_codec *codec) 1412static int wm5102_codec_probe(struct snd_soc_codec *codec)
828{ 1413{
829 struct wm5102_priv *priv = snd_soc_codec_get_drvdata(codec); 1414 struct wm5102_priv *priv = snd_soc_codec_get_drvdata(codec);
1415 int ret;
830 1416
831 codec->control_data = priv->core.arizona->regmap; 1417 codec->control_data = priv->core.arizona->regmap;
832 return snd_soc_codec_set_cache_io(codec, 32, 16, SND_SOC_REGMAP); 1418
1419 ret = snd_soc_codec_set_cache_io(codec, 32, 16, SND_SOC_REGMAP);
1420 if (ret != 0)
1421 return ret;
1422
1423 snd_soc_dapm_disable_pin(&codec->dapm, "HAPTICS");
1424
1425 priv->core.arizona->dapm = &codec->dapm;
1426
1427 return 0;
1428}
1429
1430static int wm5102_codec_remove(struct snd_soc_codec *codec)
1431{
1432 struct wm5102_priv *priv = snd_soc_codec_get_drvdata(codec);
1433
1434 priv->core.arizona->dapm = NULL;
1435
1436 return 0;
833} 1437}
834 1438
835#define WM5102_DIG_VU 0x0200 1439#define WM5102_DIG_VU 0x0200
@@ -856,6 +1460,7 @@ static unsigned int wm5102_digital_vu[] = {
856 1460
857static struct snd_soc_codec_driver soc_codec_dev_wm5102 = { 1461static struct snd_soc_codec_driver soc_codec_dev_wm5102 = {
858 .probe = wm5102_codec_probe, 1462 .probe = wm5102_codec_probe,
1463 .remove = wm5102_codec_remove,
859 1464
860 .idle_bias_off = true, 1465 .idle_bias_off = true,
861 1466
@@ -874,7 +1479,7 @@ static int __devinit wm5102_probe(struct platform_device *pdev)
874{ 1479{
875 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); 1480 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
876 struct wm5102_priv *wm5102; 1481 struct wm5102_priv *wm5102;
877 int i; 1482 int i, ret;
878 1483
879 wm5102 = devm_kzalloc(&pdev->dev, sizeof(struct wm5102_priv), 1484 wm5102 = devm_kzalloc(&pdev->dev, sizeof(struct wm5102_priv),
880 GFP_KERNEL); 1485 GFP_KERNEL);
@@ -884,6 +1489,19 @@ static int __devinit wm5102_probe(struct platform_device *pdev)
884 1489
885 wm5102->core.arizona = arizona; 1490 wm5102->core.arizona = arizona;
886 1491
1492 wm5102->core.adsp[0].part = "wm5102";
1493 wm5102->core.adsp[0].num = 1;
1494 wm5102->core.adsp[0].type = WMFW_ADSP2;
1495 wm5102->core.adsp[0].base = ARIZONA_DSP1_CONTROL_1;
1496 wm5102->core.adsp[0].dev = arizona->dev;
1497 wm5102->core.adsp[0].regmap = arizona->regmap;
1498 wm5102->core.adsp[0].mem = wm5102_dsp1_regions;
1499 wm5102->core.adsp[0].num_mems = ARRAY_SIZE(wm5102_dsp1_regions);
1500
1501 ret = wm_adsp2_init(&wm5102->core.adsp[0], true);
1502 if (ret != 0)
1503 return ret;
1504
887 for (i = 0; i < ARRAY_SIZE(wm5102->fll); i++) 1505 for (i = 0; i < ARRAY_SIZE(wm5102->fll); i++)
888 wm5102->fll[i].vco_mult = 1; 1506 wm5102->fll[i].vco_mult = 1;
889 1507
diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c
index 9211e4192f71..c57dc7468300 100644
--- a/sound/soc/codecs/wm5110.c
+++ b/sound/soc/codecs/wm5110.c
@@ -84,11 +84,23 @@ SOC_DOUBLE_R_TLV("IN4 Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_4L,
84 ARIZONA_ADC_DIGITAL_VOLUME_4R, ARIZONA_IN4L_DIG_VOL_SHIFT, 84 ARIZONA_ADC_DIGITAL_VOLUME_4R, ARIZONA_IN4L_DIG_VOL_SHIFT,
85 0xbf, 0, digital_tlv), 85 0xbf, 0, digital_tlv),
86 86
87SOC_ENUM("Input Ramp Up", arizona_in_vi_ramp),
88SOC_ENUM("Input Ramp Down", arizona_in_vd_ramp),
89
87ARIZONA_MIXER_CONTROLS("EQ1", ARIZONA_EQ1MIX_INPUT_1_SOURCE), 90ARIZONA_MIXER_CONTROLS("EQ1", ARIZONA_EQ1MIX_INPUT_1_SOURCE),
88ARIZONA_MIXER_CONTROLS("EQ2", ARIZONA_EQ2MIX_INPUT_1_SOURCE), 91ARIZONA_MIXER_CONTROLS("EQ2", ARIZONA_EQ2MIX_INPUT_1_SOURCE),
89ARIZONA_MIXER_CONTROLS("EQ3", ARIZONA_EQ3MIX_INPUT_1_SOURCE), 92ARIZONA_MIXER_CONTROLS("EQ3", ARIZONA_EQ3MIX_INPUT_1_SOURCE),
90ARIZONA_MIXER_CONTROLS("EQ4", ARIZONA_EQ4MIX_INPUT_1_SOURCE), 93ARIZONA_MIXER_CONTROLS("EQ4", ARIZONA_EQ4MIX_INPUT_1_SOURCE),
91 94
95SND_SOC_BYTES_MASK("EQ1 Coefficeints", ARIZONA_EQ1_1, 21,
96 ARIZONA_EQ1_ENA_MASK),
97SND_SOC_BYTES_MASK("EQ2 Coefficeints", ARIZONA_EQ2_1, 21,
98 ARIZONA_EQ2_ENA_MASK),
99SND_SOC_BYTES_MASK("EQ3 Coefficeints", ARIZONA_EQ3_1, 21,
100 ARIZONA_EQ3_ENA_MASK),
101SND_SOC_BYTES_MASK("EQ4 Coefficeints", ARIZONA_EQ4_1, 21,
102 ARIZONA_EQ4_ENA_MASK),
103
92SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT, 104SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT,
93 24, 0, eq_tlv), 105 24, 0, eq_tlv),
94SOC_SINGLE_TLV("EQ1 B2 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B2_GAIN_SHIFT, 106SOC_SINGLE_TLV("EQ1 B2 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B2_GAIN_SHIFT,
@@ -148,6 +160,11 @@ ARIZONA_MIXER_CONTROLS("LHPF2", ARIZONA_HPLP2MIX_INPUT_1_SOURCE),
148ARIZONA_MIXER_CONTROLS("LHPF3", ARIZONA_HPLP3MIX_INPUT_1_SOURCE), 160ARIZONA_MIXER_CONTROLS("LHPF3", ARIZONA_HPLP3MIX_INPUT_1_SOURCE),
149ARIZONA_MIXER_CONTROLS("LHPF4", ARIZONA_HPLP4MIX_INPUT_1_SOURCE), 161ARIZONA_MIXER_CONTROLS("LHPF4", ARIZONA_HPLP4MIX_INPUT_1_SOURCE),
150 162
163SND_SOC_BYTES("LHPF1 Coefficients", ARIZONA_HPLPF1_2, 1),
164SND_SOC_BYTES("LHPF2 Coefficients", ARIZONA_HPLPF2_2, 1),
165SND_SOC_BYTES("LHPF3 Coefficients", ARIZONA_HPLPF3_2, 1),
166SND_SOC_BYTES("LHPF4 Coefficients", ARIZONA_HPLPF4_2, 1),
167
151SOC_ENUM("LHPF1 Mode", arizona_lhpf1_mode), 168SOC_ENUM("LHPF1 Mode", arizona_lhpf1_mode),
152SOC_ENUM("LHPF2 Mode", arizona_lhpf2_mode), 169SOC_ENUM("LHPF2 Mode", arizona_lhpf2_mode),
153SOC_ENUM("LHPF3 Mode", arizona_lhpf3_mode), 170SOC_ENUM("LHPF3 Mode", arizona_lhpf3_mode),
@@ -243,6 +260,9 @@ SOC_DOUBLE("SPKDAT1 Switch", ARIZONA_PDM_SPK1_CTRL_1, ARIZONA_SPK1L_MUTE_SHIFT,
243SOC_DOUBLE("SPKDAT2 Switch", ARIZONA_PDM_SPK2_CTRL_1, ARIZONA_SPK2L_MUTE_SHIFT, 260SOC_DOUBLE("SPKDAT2 Switch", ARIZONA_PDM_SPK2_CTRL_1, ARIZONA_SPK2L_MUTE_SHIFT,
244 ARIZONA_SPK2R_MUTE_SHIFT, 1, 1), 261 ARIZONA_SPK2R_MUTE_SHIFT, 1, 1),
245 262
263SOC_ENUM("Output Ramp Up", arizona_out_vi_ramp),
264SOC_ENUM("Output Ramp Down", arizona_out_vd_ramp),
265
246ARIZONA_MIXER_CONTROLS("AIF1TX1", ARIZONA_AIF1TX1MIX_INPUT_1_SOURCE), 266ARIZONA_MIXER_CONTROLS("AIF1TX1", ARIZONA_AIF1TX1MIX_INPUT_1_SOURCE),
247ARIZONA_MIXER_CONTROLS("AIF1TX2", ARIZONA_AIF1TX2MIX_INPUT_1_SOURCE), 267ARIZONA_MIXER_CONTROLS("AIF1TX2", ARIZONA_AIF1TX2MIX_INPUT_1_SOURCE),
248ARIZONA_MIXER_CONTROLS("AIF1TX3", ARIZONA_AIF1TX3MIX_INPUT_1_SOURCE), 268ARIZONA_MIXER_CONTROLS("AIF1TX3", ARIZONA_AIF1TX3MIX_INPUT_1_SOURCE),
@@ -308,10 +328,10 @@ ARIZONA_MIXER_ENUMS(AIF2TX2, ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE);
308ARIZONA_MIXER_ENUMS(AIF3TX1, ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE); 328ARIZONA_MIXER_ENUMS(AIF3TX1, ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE);
309ARIZONA_MIXER_ENUMS(AIF3TX2, ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE); 329ARIZONA_MIXER_ENUMS(AIF3TX2, ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE);
310 330
311ARIZONA_MIXER_ENUMS(ASRC1L, ARIZONA_ASRC1LMIX_INPUT_1_SOURCE); 331ARIZONA_MUX_ENUMS(ASRC1L, ARIZONA_ASRC1LMIX_INPUT_1_SOURCE);
312ARIZONA_MIXER_ENUMS(ASRC1R, ARIZONA_ASRC1RMIX_INPUT_1_SOURCE); 332ARIZONA_MUX_ENUMS(ASRC1R, ARIZONA_ASRC1RMIX_INPUT_1_SOURCE);
313ARIZONA_MIXER_ENUMS(ASRC2L, ARIZONA_ASRC2LMIX_INPUT_1_SOURCE); 333ARIZONA_MUX_ENUMS(ASRC2L, ARIZONA_ASRC2LMIX_INPUT_1_SOURCE);
314ARIZONA_MIXER_ENUMS(ASRC2R, ARIZONA_ASRC2RMIX_INPUT_1_SOURCE); 334ARIZONA_MUX_ENUMS(ASRC2R, ARIZONA_ASRC2RMIX_INPUT_1_SOURCE);
315 335
316static const char *wm5110_aec_loopback_texts[] = { 336static const char *wm5110_aec_loopback_texts[] = {
317 "HPOUT1L", "HPOUT1R", "HPOUT2L", "HPOUT2R", "HPOUT3L", "HPOUT3R", 337 "HPOUT1L", "HPOUT1R", "HPOUT2L", "HPOUT2R", "HPOUT3L", "HPOUT3R",
@@ -352,6 +372,7 @@ SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDDR", 0, 0),
352 372
353SND_SOC_DAPM_SIGGEN("TONE"), 373SND_SOC_DAPM_SIGGEN("TONE"),
354SND_SOC_DAPM_SIGGEN("NOISE"), 374SND_SOC_DAPM_SIGGEN("NOISE"),
375SND_SOC_DAPM_SIGGEN("HAPTICS"),
355 376
356SND_SOC_DAPM_INPUT("IN1L"), 377SND_SOC_DAPM_INPUT("IN1L"),
357SND_SOC_DAPM_INPUT("IN1R"), 378SND_SOC_DAPM_INPUT("IN1R"),
@@ -585,10 +606,10 @@ ARIZONA_MIXER_WIDGETS(AIF2TX2, "AIF2TX2"),
585ARIZONA_MIXER_WIDGETS(AIF3TX1, "AIF3TX1"), 606ARIZONA_MIXER_WIDGETS(AIF3TX1, "AIF3TX1"),
586ARIZONA_MIXER_WIDGETS(AIF3TX2, "AIF3TX2"), 607ARIZONA_MIXER_WIDGETS(AIF3TX2, "AIF3TX2"),
587 608
588ARIZONA_MIXER_WIDGETS(ASRC1L, "ASRC1L"), 609ARIZONA_MUX_WIDGETS(ASRC1L, "ASRC1L"),
589ARIZONA_MIXER_WIDGETS(ASRC1R, "ASRC1R"), 610ARIZONA_MUX_WIDGETS(ASRC1R, "ASRC1R"),
590ARIZONA_MIXER_WIDGETS(ASRC2L, "ASRC2L"), 611ARIZONA_MUX_WIDGETS(ASRC2L, "ASRC2L"),
591ARIZONA_MIXER_WIDGETS(ASRC2R, "ASRC2R"), 612ARIZONA_MUX_WIDGETS(ASRC2R, "ASRC2R"),
592 613
593SND_SOC_DAPM_OUTPUT("HPOUT1L"), 614SND_SOC_DAPM_OUTPUT("HPOUT1L"),
594SND_SOC_DAPM_OUTPUT("HPOUT1R"), 615SND_SOC_DAPM_OUTPUT("HPOUT1R"),
@@ -610,6 +631,7 @@ SND_SOC_DAPM_OUTPUT("SPKDAT2R"),
610 { name, "Noise Generator", "Noise Generator" }, \ 631 { name, "Noise Generator", "Noise Generator" }, \
611 { name, "Tone Generator 1", "Tone Generator 1" }, \ 632 { name, "Tone Generator 1", "Tone Generator 1" }, \
612 { name, "Tone Generator 2", "Tone Generator 2" }, \ 633 { name, "Tone Generator 2", "Tone Generator 2" }, \
634 { name, "Haptics", "HAPTICS" }, \
613 { name, "AEC", "AEC Loopback" }, \ 635 { name, "AEC", "AEC Loopback" }, \
614 { name, "IN1L", "IN1L PGA" }, \ 636 { name, "IN1L", "IN1L PGA" }, \
615 { name, "IN1R", "IN1R PGA" }, \ 637 { name, "IN1R", "IN1R PGA" }, \
@@ -786,10 +808,10 @@ static const struct snd_soc_dapm_route wm5110_dapm_routes[] = {
786 ARIZONA_MIXER_ROUTES("LHPF3", "LHPF3"), 808 ARIZONA_MIXER_ROUTES("LHPF3", "LHPF3"),
787 ARIZONA_MIXER_ROUTES("LHPF4", "LHPF4"), 809 ARIZONA_MIXER_ROUTES("LHPF4", "LHPF4"),
788 810
789 ARIZONA_MIXER_ROUTES("ASRC1L", "ASRC1L"), 811 ARIZONA_MUX_ROUTES("ASRC1L"),
790 ARIZONA_MIXER_ROUTES("ASRC1R", "ASRC1R"), 812 ARIZONA_MUX_ROUTES("ASRC1R"),
791 ARIZONA_MIXER_ROUTES("ASRC2L", "ASRC2L"), 813 ARIZONA_MUX_ROUTES("ASRC2L"),
792 ARIZONA_MIXER_ROUTES("ASRC2R", "ASRC2R"), 814 ARIZONA_MUX_ROUTES("ASRC2R"),
793 815
794 { "HPOUT1L", NULL, "OUT1L" }, 816 { "HPOUT1L", NULL, "OUT1L" },
795 { "HPOUT1R", NULL, "OUT1R" }, 817 { "HPOUT1R", NULL, "OUT1R" },
@@ -902,9 +924,29 @@ static struct snd_soc_dai_driver wm5110_dai[] = {
902static int wm5110_codec_probe(struct snd_soc_codec *codec) 924static int wm5110_codec_probe(struct snd_soc_codec *codec)
903{ 925{
904 struct wm5110_priv *priv = snd_soc_codec_get_drvdata(codec); 926 struct wm5110_priv *priv = snd_soc_codec_get_drvdata(codec);
927 int ret;
905 928
906 codec->control_data = priv->core.arizona->regmap; 929 codec->control_data = priv->core.arizona->regmap;
907 return snd_soc_codec_set_cache_io(codec, 32, 16, SND_SOC_REGMAP); 930 priv->core.arizona->dapm = &codec->dapm;
931
932 ret = snd_soc_codec_set_cache_io(codec, 32, 16, SND_SOC_REGMAP);
933 if (ret != 0)
934 return ret;
935
936 snd_soc_dapm_disable_pin(&codec->dapm, "HAPTICS");
937
938 priv->core.arizona->dapm = &codec->dapm;
939
940 return 0;
941}
942
943static int wm5110_codec_remove(struct snd_soc_codec *codec)
944{
945 struct wm5110_priv *priv = snd_soc_codec_get_drvdata(codec);
946
947 priv->core.arizona->dapm = NULL;
948
949 return 0;
908} 950}
909 951
910#define WM5110_DIG_VU 0x0200 952#define WM5110_DIG_VU 0x0200
@@ -935,6 +977,7 @@ static unsigned int wm5110_digital_vu[] = {
935 977
936static struct snd_soc_codec_driver soc_codec_dev_wm5110 = { 978static struct snd_soc_codec_driver soc_codec_dev_wm5110 = {
937 .probe = wm5110_codec_probe, 979 .probe = wm5110_codec_probe,
980 .remove = wm5110_codec_remove,
938 981
939 .idle_bias_off = true, 982 .idle_bias_off = true,
940 983
diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c
index a4cae060bf26..32b8f0852f6e 100644
--- a/sound/soc/codecs/wm8350.c
+++ b/sound/soc/codecs/wm8350.c
@@ -1500,7 +1500,7 @@ static int wm8350_codec_probe(struct snd_soc_codec *codec)
1500 for (i = 0; i < ARRAY_SIZE(supply_names); i++) 1500 for (i = 0; i < ARRAY_SIZE(supply_names); i++)
1501 priv->supplies[i].supply = supply_names[i]; 1501 priv->supplies[i].supply = supply_names[i];
1502 1502
1503 ret = regulator_bulk_get(wm8350->dev, ARRAY_SIZE(priv->supplies), 1503 ret = devm_regulator_bulk_get(wm8350->dev, ARRAY_SIZE(priv->supplies),
1504 priv->supplies); 1504 priv->supplies);
1505 if (ret != 0) 1505 if (ret != 0)
1506 return ret; 1506 return ret;
@@ -1607,8 +1607,6 @@ static int wm8350_codec_remove(struct snd_soc_codec *codec)
1607 1607
1608 wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_5, WM8350_CODEC_ENA); 1608 wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_5, WM8350_CODEC_ENA);
1609 1609
1610 regulator_bulk_free(ARRAY_SIZE(priv->supplies), priv->supplies);
1611
1612 return 0; 1610 return 0;
1613} 1611}
1614 1612
diff --git a/sound/soc/codecs/wm8400.c b/sound/soc/codecs/wm8400.c
index 5d277a915f81..262c44082eb0 100644
--- a/sound/soc/codecs/wm8400.c
+++ b/sound/soc/codecs/wm8400.c
@@ -1373,7 +1373,7 @@ static int wm8400_codec_probe(struct snd_soc_codec *codec)
1373 codec->control_data = priv->wm8400 = wm8400; 1373 codec->control_data = priv->wm8400 = wm8400;
1374 priv->codec = codec; 1374 priv->codec = codec;
1375 1375
1376 ret = regulator_bulk_get(wm8400->dev, 1376 ret = devm_regulator_bulk_get(wm8400->dev,
1377 ARRAY_SIZE(power), &power[0]); 1377 ARRAY_SIZE(power), &power[0]);
1378 if (ret != 0) { 1378 if (ret != 0) {
1379 dev_err(codec->dev, "Failed to get regulators: %d\n", ret); 1379 dev_err(codec->dev, "Failed to get regulators: %d\n", ret);
@@ -1398,15 +1398,9 @@ static int wm8400_codec_probe(struct snd_soc_codec *codec)
1398 snd_soc_write(codec, WM8400_LEFT_OUTPUT_VOLUME, 0x50 | (1<<8)); 1398 snd_soc_write(codec, WM8400_LEFT_OUTPUT_VOLUME, 0x50 | (1<<8));
1399 snd_soc_write(codec, WM8400_RIGHT_OUTPUT_VOLUME, 0x50 | (1<<8)); 1399 snd_soc_write(codec, WM8400_RIGHT_OUTPUT_VOLUME, 0x50 | (1<<8));
1400 1400
1401 if (!schedule_work(&priv->work)) { 1401 if (!schedule_work(&priv->work))
1402 ret = -EINVAL; 1402 return -EINVAL;
1403 goto err_regulator;
1404 }
1405 return 0; 1403 return 0;
1406
1407err_regulator:
1408 regulator_bulk_free(ARRAY_SIZE(power), power);
1409 return ret;
1410} 1404}
1411 1405
1412static int wm8400_codec_remove(struct snd_soc_codec *codec) 1406static int wm8400_codec_remove(struct snd_soc_codec *codec)
@@ -1417,8 +1411,6 @@ static int wm8400_codec_remove(struct snd_soc_codec *codec)
1417 snd_soc_write(codec, WM8400_POWER_MANAGEMENT_1, 1411 snd_soc_write(codec, WM8400_POWER_MANAGEMENT_1,
1418 reg & (~WM8400_CODEC_ENA)); 1412 reg & (~WM8400_CODEC_ENA));
1419 1413
1420 regulator_bulk_free(ARRAY_SIZE(power), power);
1421
1422 return 0; 1414 return 0;
1423} 1415}
1424 1416
diff --git a/sound/soc/codecs/wm8510.c b/sound/soc/codecs/wm8510.c
index c12a54e72e89..923e7e1f6704 100644
--- a/sound/soc/codecs/wm8510.c
+++ b/sound/soc/codecs/wm8510.c
@@ -608,10 +608,7 @@ static int wm8510_probe(struct snd_soc_codec *codec)
608/* power down chip */ 608/* power down chip */
609static int wm8510_remove(struct snd_soc_codec *codec) 609static int wm8510_remove(struct snd_soc_codec *codec)
610{ 610{
611 struct wm8510_priv *wm8510 = snd_soc_codec_get_drvdata(codec);
612
613 wm8510_set_bias_level(codec, SND_SOC_BIAS_OFF); 611 wm8510_set_bias_level(codec, SND_SOC_BIAS_OFF);
614 kfree(wm8510);
615 return 0; 612 return 0;
616} 613}
617 614
diff --git a/sound/soc/codecs/wm8741.c b/sound/soc/codecs/wm8741.c
index 4281a0802138..99b8ebe93424 100644
--- a/sound/soc/codecs/wm8741.c
+++ b/sound/soc/codecs/wm8741.c
@@ -522,7 +522,7 @@ static int wm8741_i2c_probe(struct i2c_client *i2c,
522 return ret; 522 return ret;
523 } 523 }
524 524
525 wm8741->regmap = regmap_init_i2c(i2c, &wm8741_regmap); 525 wm8741->regmap = devm_regmap_init_i2c(i2c, &wm8741_regmap);
526 if (IS_ERR(wm8741->regmap)) { 526 if (IS_ERR(wm8741->regmap)) {
527 ret = PTR_ERR(wm8741->regmap); 527 ret = PTR_ERR(wm8741->regmap);
528 dev_err(&i2c->dev, "Failed to init regmap: %d\n", ret); 528 dev_err(&i2c->dev, "Failed to init regmap: %d\n", ret);
@@ -582,7 +582,7 @@ static int __devinit wm8741_spi_probe(struct spi_device *spi)
582 return ret; 582 return ret;
583 } 583 }
584 584
585 wm8741->regmap = regmap_init_spi(spi, &wm8741_regmap); 585 wm8741->regmap = devm_regmap_init_spi(spi, &wm8741_regmap);
586 if (IS_ERR(wm8741->regmap)) { 586 if (IS_ERR(wm8741->regmap)) {
587 ret = PTR_ERR(wm8741->regmap); 587 ret = PTR_ERR(wm8741->regmap);
588 dev_err(&spi->dev, "Failed to init regmap: %d\n", ret); 588 dev_err(&spi->dev, "Failed to init regmap: %d\n", ret);
diff --git a/sound/soc/codecs/wm8750.c b/sound/soc/codecs/wm8750.c
index 89151ca5e776..7665d68c4558 100644
--- a/sound/soc/codecs/wm8750.c
+++ b/sound/soc/codecs/wm8750.c
@@ -18,6 +18,7 @@
18#include <linux/delay.h> 18#include <linux/delay.h>
19#include <linux/pm.h> 19#include <linux/pm.h>
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <linux/regmap.h>
21#include <linux/spi/spi.h> 22#include <linux/spi/spi.h>
22#include <linux/slab.h> 23#include <linux/slab.h>
23#include <linux/of_device.h> 24#include <linux/of_device.h>
@@ -34,24 +35,55 @@
34 * We can't read the WM8750 register space when we 35 * We can't read the WM8750 register space when we
35 * are using 2 wire for device control, so we cache them instead. 36 * are using 2 wire for device control, so we cache them instead.
36 */ 37 */
37static const u16 wm8750_reg[] = { 38static const struct reg_default wm8750_reg_defaults[] = {
38 0x0097, 0x0097, 0x0079, 0x0079, /* 0 */ 39 { 0, 0x0097 },
39 0x0000, 0x0008, 0x0000, 0x000a, /* 4 */ 40 { 1, 0x0097 },
40 0x0000, 0x0000, 0x00ff, 0x00ff, /* 8 */ 41 { 2, 0x0079 },
41 0x000f, 0x000f, 0x0000, 0x0000, /* 12 */ 42 { 3, 0x0079 },
42 0x0000, 0x007b, 0x0000, 0x0032, /* 16 */ 43 { 4, 0x0000 },
43 0x0000, 0x00c3, 0x00c3, 0x00c0, /* 20 */ 44 { 5, 0x0008 },
44 0x0000, 0x0000, 0x0000, 0x0000, /* 24 */ 45 { 6, 0x0000 },
45 0x0000, 0x0000, 0x0000, 0x0000, /* 28 */ 46 { 7, 0x000a },
46 0x0000, 0x0000, 0x0050, 0x0050, /* 32 */ 47 { 8, 0x0000 },
47 0x0050, 0x0050, 0x0050, 0x0050, /* 36 */ 48 { 9, 0x0000 },
48 0x0079, 0x0079, 0x0079, /* 40 */ 49 { 10, 0x00ff },
50 { 11, 0x00ff },
51 { 12, 0x000f },
52 { 13, 0x000f },
53 { 14, 0x0000 },
54 { 15, 0x0000 },
55 { 16, 0x0000 },
56 { 17, 0x007b },
57 { 18, 0x0000 },
58 { 19, 0x0032 },
59 { 20, 0x0000 },
60 { 21, 0x00c3 },
61 { 22, 0x00c3 },
62 { 23, 0x00c0 },
63 { 24, 0x0000 },
64 { 25, 0x0000 },
65 { 26, 0x0000 },
66 { 27, 0x0000 },
67 { 28, 0x0000 },
68 { 29, 0x0000 },
69 { 30, 0x0000 },
70 { 31, 0x0000 },
71 { 32, 0x0000 },
72 { 33, 0x0000 },
73 { 34, 0x0050 },
74 { 35, 0x0050 },
75 { 36, 0x0050 },
76 { 37, 0x0050 },
77 { 38, 0x0050 },
78 { 39, 0x0050 },
79 { 40, 0x0079 },
80 { 41, 0x0079 },
81 { 42, 0x0079 },
49}; 82};
50 83
51/* codec private data */ 84/* codec private data */
52struct wm8750_priv { 85struct wm8750_priv {
53 unsigned int sysclk; 86 unsigned int sysclk;
54 enum snd_soc_control_type control_type;
55}; 87};
56 88
57#define wm8750_reset(c) snd_soc_write(c, WM8750_RESET, 0) 89#define wm8750_reset(c) snd_soc_write(c, WM8750_RESET, 0)
@@ -668,10 +700,9 @@ static int wm8750_resume(struct snd_soc_codec *codec)
668 700
669static int wm8750_probe(struct snd_soc_codec *codec) 701static int wm8750_probe(struct snd_soc_codec *codec)
670{ 702{
671 struct wm8750_priv *wm8750 = snd_soc_codec_get_drvdata(codec);
672 int ret; 703 int ret;
673 704
674 ret = snd_soc_codec_set_cache_io(codec, 7, 9, wm8750->control_type); 705 ret = snd_soc_codec_set_cache_io(codec, 7, 9, SND_SOC_REGMAP);
675 if (ret < 0) { 706 if (ret < 0) {
676 printk(KERN_ERR "wm8750: failed to set cache I/O: %d\n", ret); 707 printk(KERN_ERR "wm8750: failed to set cache I/O: %d\n", ret);
677 return ret; 708 return ret;
@@ -711,9 +742,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8750 = {
711 .suspend = wm8750_suspend, 742 .suspend = wm8750_suspend,
712 .resume = wm8750_resume, 743 .resume = wm8750_resume,
713 .set_bias_level = wm8750_set_bias_level, 744 .set_bias_level = wm8750_set_bias_level,
714 .reg_cache_size = ARRAY_SIZE(wm8750_reg),
715 .reg_word_size = sizeof(u16),
716 .reg_cache_default = wm8750_reg,
717 745
718 .controls = wm8750_snd_controls, 746 .controls = wm8750_snd_controls,
719 .num_controls = ARRAY_SIZE(wm8750_snd_controls), 747 .num_controls = ARRAY_SIZE(wm8750_snd_controls),
@@ -730,10 +758,21 @@ static const struct of_device_id wm8750_of_match[] = {
730}; 758};
731MODULE_DEVICE_TABLE(of, wm8750_of_match); 759MODULE_DEVICE_TABLE(of, wm8750_of_match);
732 760
761static const struct regmap_config wm8750_regmap = {
762 .reg_bits = 7,
763 .val_bits = 9,
764 .max_register = WM8750_MOUTV,
765
766 .reg_defaults = wm8750_reg_defaults,
767 .num_reg_defaults = ARRAY_SIZE(wm8750_reg_defaults),
768 .cache_type = REGCACHE_RBTREE,
769};
770
733#if defined(CONFIG_SPI_MASTER) 771#if defined(CONFIG_SPI_MASTER)
734static int __devinit wm8750_spi_probe(struct spi_device *spi) 772static int __devinit wm8750_spi_probe(struct spi_device *spi)
735{ 773{
736 struct wm8750_priv *wm8750; 774 struct wm8750_priv *wm8750;
775 struct regmap *regmap;
737 int ret; 776 int ret;
738 777
739 wm8750 = devm_kzalloc(&spi->dev, sizeof(struct wm8750_priv), 778 wm8750 = devm_kzalloc(&spi->dev, sizeof(struct wm8750_priv),
@@ -741,7 +780,10 @@ static int __devinit wm8750_spi_probe(struct spi_device *spi)
741 if (wm8750 == NULL) 780 if (wm8750 == NULL)
742 return -ENOMEM; 781 return -ENOMEM;
743 782
744 wm8750->control_type = SND_SOC_SPI; 783 regmap = devm_regmap_init_spi(spi, &wm8750_regmap);
784 if (IS_ERR(regmap))
785 return PTR_ERR(regmap);
786
745 spi_set_drvdata(spi, wm8750); 787 spi_set_drvdata(spi, wm8750);
746 788
747 ret = snd_soc_register_codec(&spi->dev, 789 ret = snd_soc_register_codec(&spi->dev,
@@ -779,6 +821,7 @@ static __devinit int wm8750_i2c_probe(struct i2c_client *i2c,
779 const struct i2c_device_id *id) 821 const struct i2c_device_id *id)
780{ 822{
781 struct wm8750_priv *wm8750; 823 struct wm8750_priv *wm8750;
824 struct regmap *regmap;
782 int ret; 825 int ret;
783 826
784 wm8750 = devm_kzalloc(&i2c->dev, sizeof(struct wm8750_priv), 827 wm8750 = devm_kzalloc(&i2c->dev, sizeof(struct wm8750_priv),
@@ -787,7 +830,10 @@ static __devinit int wm8750_i2c_probe(struct i2c_client *i2c,
787 return -ENOMEM; 830 return -ENOMEM;
788 831
789 i2c_set_clientdata(i2c, wm8750); 832 i2c_set_clientdata(i2c, wm8750);
790 wm8750->control_type = SND_SOC_I2C; 833
834 regmap = devm_regmap_init_i2c(i2c, &wm8750_regmap);
835 if (IS_ERR(regmap))
836 return PTR_ERR(regmap);
791 837
792 ret = snd_soc_register_codec(&i2c->dev, 838 ret = snd_soc_register_codec(&i2c->dev,
793 &soc_codec_dev_wm8750, &wm8750_dai, 1); 839 &soc_codec_dev_wm8750, &wm8750_dai, 1);
diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c
index 2e4a775ae560..50a5dc7974e1 100644
--- a/sound/soc/codecs/wm8753.c
+++ b/sound/soc/codecs/wm8753.c
@@ -1562,36 +1562,25 @@ static int __devinit wm8753_spi_probe(struct spi_device *spi)
1562 1562
1563 spi_set_drvdata(spi, wm8753); 1563 spi_set_drvdata(spi, wm8753);
1564 1564
1565 wm8753->regmap = regmap_init_spi(spi, &wm8753_regmap); 1565 wm8753->regmap = devm_regmap_init_spi(spi, &wm8753_regmap);
1566 if (IS_ERR(wm8753->regmap)) { 1566 if (IS_ERR(wm8753->regmap)) {
1567 ret = PTR_ERR(wm8753->regmap); 1567 ret = PTR_ERR(wm8753->regmap);
1568 dev_err(&spi->dev, "Failed to allocate register map: %d\n", 1568 dev_err(&spi->dev, "Failed to allocate register map: %d\n",
1569 ret); 1569 ret);
1570 goto err; 1570 return ret;
1571 } 1571 }
1572 1572
1573 ret = snd_soc_register_codec(&spi->dev, &soc_codec_dev_wm8753, 1573 ret = snd_soc_register_codec(&spi->dev, &soc_codec_dev_wm8753,
1574 wm8753_dai, ARRAY_SIZE(wm8753_dai)); 1574 wm8753_dai, ARRAY_SIZE(wm8753_dai));
1575 if (ret != 0) { 1575 if (ret != 0)
1576 dev_err(&spi->dev, "Failed to register CODEC: %d\n", ret); 1576 dev_err(&spi->dev, "Failed to register CODEC: %d\n", ret);
1577 goto err_regmap;
1578 }
1579 1577
1580 return 0;
1581
1582err_regmap:
1583 regmap_exit(wm8753->regmap);
1584err:
1585 return ret; 1578 return ret;
1586} 1579}
1587 1580
1588static int __devexit wm8753_spi_remove(struct spi_device *spi) 1581static int __devexit wm8753_spi_remove(struct spi_device *spi)
1589{ 1582{
1590 struct wm8753_priv *wm8753 = spi_get_drvdata(spi);
1591
1592 snd_soc_unregister_codec(&spi->dev); 1583 snd_soc_unregister_codec(&spi->dev);
1593 regmap_exit(wm8753->regmap);
1594 kfree(wm8753);
1595 return 0; 1584 return 0;
1596} 1585}
1597 1586
@@ -1620,35 +1609,25 @@ static __devinit int wm8753_i2c_probe(struct i2c_client *i2c,
1620 1609
1621 i2c_set_clientdata(i2c, wm8753); 1610 i2c_set_clientdata(i2c, wm8753);
1622 1611
1623 wm8753->regmap = regmap_init_i2c(i2c, &wm8753_regmap); 1612 wm8753->regmap = devm_regmap_init_i2c(i2c, &wm8753_regmap);
1624 if (IS_ERR(wm8753->regmap)) { 1613 if (IS_ERR(wm8753->regmap)) {
1625 ret = PTR_ERR(wm8753->regmap); 1614 ret = PTR_ERR(wm8753->regmap);
1626 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", 1615 dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
1627 ret); 1616 ret);
1628 goto err; 1617 return ret;
1629 } 1618 }
1630 1619
1631 ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_wm8753, 1620 ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_wm8753,
1632 wm8753_dai, ARRAY_SIZE(wm8753_dai)); 1621 wm8753_dai, ARRAY_SIZE(wm8753_dai));
1633 if (ret != 0) { 1622 if (ret != 0)
1634 dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); 1623 dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret);
1635 goto err_regmap;
1636 }
1637 1624
1638 return 0;
1639
1640err_regmap:
1641 regmap_exit(wm8753->regmap);
1642err:
1643 return ret; 1625 return ret;
1644} 1626}
1645 1627
1646static __devexit int wm8753_i2c_remove(struct i2c_client *client) 1628static __devexit int wm8753_i2c_remove(struct i2c_client *client)
1647{ 1629{
1648 struct wm8753_priv *wm8753 = i2c_get_clientdata(client);
1649
1650 snd_soc_unregister_codec(&client->dev); 1630 snd_soc_unregister_codec(&client->dev);
1651 regmap_exit(wm8753->regmap);
1652 return 0; 1631 return 0;
1653} 1632}
1654 1633
diff --git a/sound/soc/codecs/wm8770.c b/sound/soc/codecs/wm8770.c
index c7c0034d3966..0b690ba875f8 100644
--- a/sound/soc/codecs/wm8770.c
+++ b/sound/soc/codecs/wm8770.c
@@ -17,6 +17,7 @@
17#include <linux/of_device.h> 17#include <linux/of_device.h>
18#include <linux/pm.h> 18#include <linux/pm.h>
19#include <linux/spi/spi.h> 19#include <linux/spi/spi.h>
20#include <linux/regmap.h>
20#include <linux/regulator/consumer.h> 21#include <linux/regulator/consumer.h>
21#include <linux/slab.h> 22#include <linux/slab.h>
22#include <sound/core.h> 23#include <sound/core.h>
@@ -35,19 +36,52 @@ static const char *wm8770_supply_names[WM8770_NUM_SUPPLIES] = {
35 "DVDD" 36 "DVDD"
36}; 37};
37 38
38static const u16 wm8770_reg_defs[WM8770_CACHEREGNUM] = { 39static const struct reg_default wm8770_reg_defaults[] = {
39 0x7f, 0x7f, 0x7f, 0x7f, 40 { 0, 0x7f },
40 0x7f, 0x7f, 0x7f, 0x7f, 41 { 1, 0x7f },
41 0x7f, 0xff, 0xff, 0xff, 42 { 2, 0x7f },
42 0xff, 0xff, 0xff, 0xff, 43 { 3, 0x7f },
43 0xff, 0xff, 0, 0x90, 0, 44 { 4, 0x7f },
44 0, 0x22, 0x22, 0x3e, 45 { 5, 0x7f },
45 0xc, 0xc, 0x100, 0x189, 46 { 6, 0x7f },
46 0x189, 0x8770 47 { 7, 0x7f },
48 { 8, 0x7f },
49 { 9, 0xff },
50 { 10, 0xff },
51 { 11, 0xff },
52 { 12, 0xff },
53 { 13, 0xff },
54 { 14, 0xff },
55 { 15, 0xff },
56 { 16, 0xff },
57 { 17, 0xff },
58 { 18, 0 },
59 { 19, 0x90 },
60 { 20, 0 },
61 { 21, 0 },
62 { 22, 0x22 },
63 { 23, 0x22 },
64 { 24, 0x3e },
65 { 25, 0xc },
66 { 26, 0xc },
67 { 27, 0x100 },
68 { 28, 0x189 },
69 { 29, 0x189 },
70 { 30, 0x8770 },
47}; 71};
48 72
73static bool wm8770_volatile_reg(struct device *dev, unsigned int reg)
74{
75 switch (reg) {
76 case WM8770_RESET:
77 return true;
78 default:
79 return false;
80 }
81}
82
49struct wm8770_priv { 83struct wm8770_priv {
50 enum snd_soc_control_type control_type; 84 struct regmap *regmap;
51 struct regulator_bulk_data supplies[WM8770_NUM_SUPPLIES]; 85 struct regulator_bulk_data supplies[WM8770_NUM_SUPPLIES];
52 struct notifier_block disable_nb[WM8770_NUM_SUPPLIES]; 86 struct notifier_block disable_nb[WM8770_NUM_SUPPLIES];
53 struct snd_soc_codec *codec; 87 struct snd_soc_codec *codec;
@@ -71,7 +105,7 @@ static int wm8770_regulator_event_##n(struct notifier_block *nb, \
71 struct wm8770_priv *wm8770 = container_of(nb, struct wm8770_priv, \ 105 struct wm8770_priv *wm8770 = container_of(nb, struct wm8770_priv, \
72 disable_nb[n]); \ 106 disable_nb[n]); \
73 if (event & REGULATOR_EVENT_DISABLE) { \ 107 if (event & REGULATOR_EVENT_DISABLE) { \
74 wm8770->codec->cache_sync = 1; \ 108 regcache_mark_dirty(wm8770->regmap); \
75 } \ 109 } \
76 return 0; \ 110 return 0; \
77} 111}
@@ -466,24 +500,6 @@ static int wm8770_set_sysclk(struct snd_soc_dai *dai,
466 return 0; 500 return 0;
467} 501}
468 502
469static void wm8770_sync_cache(struct snd_soc_codec *codec)
470{
471 int i;
472 u16 *cache;
473
474 if (!codec->cache_sync)
475 return;
476
477 codec->cache_only = 0;
478 cache = codec->reg_cache;
479 for (i = 0; i < codec->driver->reg_cache_size; i++) {
480 if (i == WM8770_RESET || cache[i] == wm8770_reg_defs[i])
481 continue;
482 snd_soc_write(codec, i, cache[i]);
483 }
484 codec->cache_sync = 0;
485}
486
487static int wm8770_set_bias_level(struct snd_soc_codec *codec, 503static int wm8770_set_bias_level(struct snd_soc_codec *codec,
488 enum snd_soc_bias_level level) 504 enum snd_soc_bias_level level)
489{ 505{
@@ -507,7 +523,9 @@ static int wm8770_set_bias_level(struct snd_soc_codec *codec,
507 ret); 523 ret);
508 return ret; 524 return ret;
509 } 525 }
510 wm8770_sync_cache(codec); 526
527 regcache_sync(wm8770->regmap);
528
511 /* global powerup */ 529 /* global powerup */
512 snd_soc_write(codec, WM8770_PWDNCTRL, 0); 530 snd_soc_write(codec, WM8770_PWDNCTRL, 0);
513 } 531 }
@@ -554,68 +572,25 @@ static struct snd_soc_dai_driver wm8770_dai = {
554 .symmetric_rates = 1 572 .symmetric_rates = 1
555}; 573};
556 574
557#ifdef CONFIG_PM
558static int wm8770_suspend(struct snd_soc_codec *codec)
559{
560 wm8770_set_bias_level(codec, SND_SOC_BIAS_OFF);
561 return 0;
562}
563
564static int wm8770_resume(struct snd_soc_codec *codec)
565{
566 wm8770_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
567 return 0;
568}
569#else
570#define wm8770_suspend NULL
571#define wm8770_resume NULL
572#endif
573
574static int wm8770_probe(struct snd_soc_codec *codec) 575static int wm8770_probe(struct snd_soc_codec *codec)
575{ 576{
576 struct wm8770_priv *wm8770; 577 struct wm8770_priv *wm8770;
577 int ret; 578 int ret;
578 int i;
579 579
580 wm8770 = snd_soc_codec_get_drvdata(codec); 580 wm8770 = snd_soc_codec_get_drvdata(codec);
581 wm8770->codec = codec; 581 wm8770->codec = codec;
582 582
583 ret = snd_soc_codec_set_cache_io(codec, 7, 9, wm8770->control_type); 583 ret = snd_soc_codec_set_cache_io(codec, 7, 9, SND_SOC_REGMAP);
584 if (ret < 0) { 584 if (ret < 0) {
585 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); 585 dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret);
586 return ret; 586 return ret;
587 } 587 }
588 588
589 for (i = 0; i < ARRAY_SIZE(wm8770->supplies); i++)
590 wm8770->supplies[i].supply = wm8770_supply_names[i];
591
592 ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(wm8770->supplies),
593 wm8770->supplies);
594 if (ret) {
595 dev_err(codec->dev, "Failed to request supplies: %d\n", ret);
596 return ret;
597 }
598
599 wm8770->disable_nb[0].notifier_call = wm8770_regulator_event_0;
600 wm8770->disable_nb[1].notifier_call = wm8770_regulator_event_1;
601 wm8770->disable_nb[2].notifier_call = wm8770_regulator_event_2;
602
603 /* This should really be moved into the regulator core */
604 for (i = 0; i < ARRAY_SIZE(wm8770->supplies); i++) {
605 ret = regulator_register_notifier(wm8770->supplies[i].consumer,
606 &wm8770->disable_nb[i]);
607 if (ret) {
608 dev_err(codec->dev,
609 "Failed to register regulator notifier: %d\n",
610 ret);
611 }
612 }
613
614 ret = regulator_bulk_enable(ARRAY_SIZE(wm8770->supplies), 589 ret = regulator_bulk_enable(ARRAY_SIZE(wm8770->supplies),
615 wm8770->supplies); 590 wm8770->supplies);
616 if (ret) { 591 if (ret) {
617 dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); 592 dev_err(codec->dev, "Failed to enable supplies: %d\n", ret);
618 goto err_reg_get; 593 return ret;
619 } 594 }
620 595
621 ret = wm8770_reset(codec); 596 ret = wm8770_reset(codec);
@@ -624,8 +599,6 @@ static int wm8770_probe(struct snd_soc_codec *codec)
624 goto err_reg_enable; 599 goto err_reg_enable;
625 } 600 }
626 601
627 wm8770_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
628
629 /* latch the volume update bits */ 602 /* latch the volume update bits */
630 snd_soc_update_bits(codec, WM8770_MSDIGVOL, 0x100, 0x100); 603 snd_soc_update_bits(codec, WM8770_MSDIGVOL, 0x100, 0x100);
631 snd_soc_update_bits(codec, WM8770_MSALGVOL, 0x100, 0x100); 604 snd_soc_update_bits(codec, WM8770_MSALGVOL, 0x100, 0x100);
@@ -641,46 +614,22 @@ static int wm8770_probe(struct snd_soc_codec *codec)
641 /* mute all DACs */ 614 /* mute all DACs */
642 snd_soc_update_bits(codec, WM8770_DACMUTE, 0x10, 0x10); 615 snd_soc_update_bits(codec, WM8770_DACMUTE, 0x10, 0x10);
643 616
644 snd_soc_add_codec_controls(codec, wm8770_snd_controls,
645 ARRAY_SIZE(wm8770_snd_controls));
646 snd_soc_dapm_new_controls(&codec->dapm, wm8770_dapm_widgets,
647 ARRAY_SIZE(wm8770_dapm_widgets));
648 snd_soc_dapm_add_routes(&codec->dapm, wm8770_intercon,
649 ARRAY_SIZE(wm8770_intercon));
650 return 0;
651
652err_reg_enable: 617err_reg_enable:
653 regulator_bulk_disable(ARRAY_SIZE(wm8770->supplies), wm8770->supplies); 618 regulator_bulk_disable(ARRAY_SIZE(wm8770->supplies), wm8770->supplies);
654err_reg_get:
655 regulator_bulk_free(ARRAY_SIZE(wm8770->supplies), wm8770->supplies);
656 return ret; 619 return ret;
657} 620}
658 621
659static int wm8770_remove(struct snd_soc_codec *codec)
660{
661 struct wm8770_priv *wm8770;
662 int i;
663
664 wm8770 = snd_soc_codec_get_drvdata(codec);
665 wm8770_set_bias_level(codec, SND_SOC_BIAS_OFF);
666
667 for (i = 0; i < ARRAY_SIZE(wm8770->supplies); ++i)
668 regulator_unregister_notifier(wm8770->supplies[i].consumer,
669 &wm8770->disable_nb[i]);
670 regulator_bulk_free(ARRAY_SIZE(wm8770->supplies), wm8770->supplies);
671 return 0;
672}
673
674static struct snd_soc_codec_driver soc_codec_dev_wm8770 = { 622static struct snd_soc_codec_driver soc_codec_dev_wm8770 = {
675 .probe = wm8770_probe, 623 .probe = wm8770_probe,
676 .remove = wm8770_remove,
677 .suspend = wm8770_suspend,
678 .resume = wm8770_resume,
679 .set_bias_level = wm8770_set_bias_level, 624 .set_bias_level = wm8770_set_bias_level,
680 .idle_bias_off = true, 625 .idle_bias_off = true,
681 .reg_cache_size = ARRAY_SIZE(wm8770_reg_defs), 626
682 .reg_word_size = sizeof (u16), 627 .controls = wm8770_snd_controls,
683 .reg_cache_default = wm8770_reg_defs 628 .num_controls = ARRAY_SIZE(wm8770_snd_controls),
629 .dapm_widgets = wm8770_dapm_widgets,
630 .num_dapm_widgets = ARRAY_SIZE(wm8770_dapm_widgets),
631 .dapm_routes = wm8770_intercon,
632 .num_dapm_routes = ARRAY_SIZE(wm8770_intercon),
684}; 633};
685 634
686static const struct of_device_id wm8770_of_match[] = { 635static const struct of_device_id wm8770_of_match[] = {
@@ -689,17 +638,57 @@ static const struct of_device_id wm8770_of_match[] = {
689}; 638};
690MODULE_DEVICE_TABLE(of, wm8770_of_match); 639MODULE_DEVICE_TABLE(of, wm8770_of_match);
691 640
641static const struct regmap_config wm8770_regmap = {
642 .reg_bits = 7,
643 .val_bits = 9,
644 .max_register = WM8770_RESET,
645
646 .reg_defaults = wm8770_reg_defaults,
647 .num_reg_defaults = ARRAY_SIZE(wm8770_reg_defaults),
648 .cache_type = REGCACHE_RBTREE,
649
650 .volatile_reg = wm8770_volatile_reg,
651};
652
692static int __devinit wm8770_spi_probe(struct spi_device *spi) 653static int __devinit wm8770_spi_probe(struct spi_device *spi)
693{ 654{
694 struct wm8770_priv *wm8770; 655 struct wm8770_priv *wm8770;
695 int ret; 656 int ret, i;
696 657
697 wm8770 = devm_kzalloc(&spi->dev, sizeof(struct wm8770_priv), 658 wm8770 = devm_kzalloc(&spi->dev, sizeof(struct wm8770_priv),
698 GFP_KERNEL); 659 GFP_KERNEL);
699 if (!wm8770) 660 if (!wm8770)
700 return -ENOMEM; 661 return -ENOMEM;
701 662
702 wm8770->control_type = SND_SOC_SPI; 663 for (i = 0; i < ARRAY_SIZE(wm8770->supplies); i++)
664 wm8770->supplies[i].supply = wm8770_supply_names[i];
665
666 ret = devm_regulator_bulk_get(&spi->dev, ARRAY_SIZE(wm8770->supplies),
667 wm8770->supplies);
668 if (ret) {
669 dev_err(&spi->dev, "Failed to request supplies: %d\n", ret);
670 return ret;
671 }
672
673 wm8770->disable_nb[0].notifier_call = wm8770_regulator_event_0;
674 wm8770->disable_nb[1].notifier_call = wm8770_regulator_event_1;
675 wm8770->disable_nb[2].notifier_call = wm8770_regulator_event_2;
676
677 /* This should really be moved into the regulator core */
678 for (i = 0; i < ARRAY_SIZE(wm8770->supplies); i++) {
679 ret = regulator_register_notifier(wm8770->supplies[i].consumer,
680 &wm8770->disable_nb[i]);
681 if (ret) {
682 dev_err(&spi->dev,
683 "Failed to register regulator notifier: %d\n",
684 ret);
685 }
686 }
687
688 wm8770->regmap = devm_regmap_init_spi(spi, &wm8770_regmap);
689 if (IS_ERR(wm8770->regmap))
690 return PTR_ERR(wm8770->regmap);
691
703 spi_set_drvdata(spi, wm8770); 692 spi_set_drvdata(spi, wm8770);
704 693
705 ret = snd_soc_register_codec(&spi->dev, 694 ret = snd_soc_register_codec(&spi->dev,
@@ -710,7 +699,15 @@ static int __devinit wm8770_spi_probe(struct spi_device *spi)
710 699
711static int __devexit wm8770_spi_remove(struct spi_device *spi) 700static int __devexit wm8770_spi_remove(struct spi_device *spi)
712{ 701{
702 struct wm8770_priv *wm8770 = spi_get_drvdata(spi);
703 int i;
704
705 for (i = 0; i < ARRAY_SIZE(wm8770->supplies); ++i)
706 regulator_unregister_notifier(wm8770->supplies[i].consumer,
707 &wm8770->disable_nb[i]);
708
713 snd_soc_unregister_codec(&spi->dev); 709 snd_soc_unregister_codec(&spi->dev);
710
714 return 0; 711 return 0;
715} 712}
716 713
diff --git a/sound/soc/codecs/wm8804.c b/sound/soc/codecs/wm8804.c
index c088020172ab..837bfb51cebf 100644
--- a/sound/soc/codecs/wm8804.c
+++ b/sound/soc/codecs/wm8804.c
@@ -711,7 +711,7 @@ static int __devinit wm8804_spi_probe(struct spi_device *spi)
711 if (!wm8804) 711 if (!wm8804)
712 return -ENOMEM; 712 return -ENOMEM;
713 713
714 wm8804->regmap = regmap_init_spi(spi, &wm8804_regmap_config); 714 wm8804->regmap = devm_regmap_init_spi(spi, &wm8804_regmap_config);
715 if (IS_ERR(wm8804->regmap)) { 715 if (IS_ERR(wm8804->regmap)) {
716 ret = PTR_ERR(wm8804->regmap); 716 ret = PTR_ERR(wm8804->regmap);
717 return ret; 717 return ret;
@@ -727,9 +727,7 @@ static int __devinit wm8804_spi_probe(struct spi_device *spi)
727 727
728static int __devexit wm8804_spi_remove(struct spi_device *spi) 728static int __devexit wm8804_spi_remove(struct spi_device *spi)
729{ 729{
730 struct wm8804_priv *wm8804 = spi_get_drvdata(spi);
731 snd_soc_unregister_codec(&spi->dev); 730 snd_soc_unregister_codec(&spi->dev);
732 regmap_exit(wm8804->regmap);
733 return 0; 731 return 0;
734} 732}
735 733
@@ -755,7 +753,7 @@ static __devinit int wm8804_i2c_probe(struct i2c_client *i2c,
755 if (!wm8804) 753 if (!wm8804)
756 return -ENOMEM; 754 return -ENOMEM;
757 755
758 wm8804->regmap = regmap_init_i2c(i2c, &wm8804_regmap_config); 756 wm8804->regmap = devm_regmap_init_i2c(i2c, &wm8804_regmap_config);
759 if (IS_ERR(wm8804->regmap)) { 757 if (IS_ERR(wm8804->regmap)) {
760 ret = PTR_ERR(wm8804->regmap); 758 ret = PTR_ERR(wm8804->regmap);
761 return ret; 759 return ret;
@@ -765,23 +763,12 @@ static __devinit int wm8804_i2c_probe(struct i2c_client *i2c,
765 763
766 ret = snd_soc_register_codec(&i2c->dev, 764 ret = snd_soc_register_codec(&i2c->dev,
767 &soc_codec_dev_wm8804, &wm8804_dai, 1); 765 &soc_codec_dev_wm8804, &wm8804_dai, 1);
768 if (ret != 0)
769 goto err;
770
771 return 0;
772
773err:
774 regmap_exit(wm8804->regmap);
775 return ret; 766 return ret;
776} 767}
777 768
778static __devexit int wm8804_i2c_remove(struct i2c_client *i2c) 769static __devexit int wm8804_i2c_remove(struct i2c_client *i2c)
779{ 770{
780 struct wm8804_priv *wm8804 = i2c_get_clientdata(i2c);
781
782 snd_soc_unregister_codec(&i2c->dev); 771 snd_soc_unregister_codec(&i2c->dev);
783 regmap_exit(wm8804->regmap);
784
785 return 0; 772 return 0;
786} 773}
787 774
diff --git a/sound/soc/codecs/wm8955.c b/sound/soc/codecs/wm8955.c
index 2f1c075755b1..7a82b7d28dcd 100644
--- a/sound/soc/codecs/wm8955.c
+++ b/sound/soc/codecs/wm8955.c
@@ -1023,7 +1023,7 @@ static __devinit int wm8955_i2c_probe(struct i2c_client *i2c,
1023 if (wm8955 == NULL) 1023 if (wm8955 == NULL)
1024 return -ENOMEM; 1024 return -ENOMEM;
1025 1025
1026 wm8955->regmap = regmap_init_i2c(i2c, &wm8955_regmap); 1026 wm8955->regmap = devm_regmap_init_i2c(i2c, &wm8955_regmap);
1027 if (IS_ERR(wm8955->regmap)) { 1027 if (IS_ERR(wm8955->regmap)) {
1028 ret = PTR_ERR(wm8955->regmap); 1028 ret = PTR_ERR(wm8955->regmap);
1029 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", 1029 dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
@@ -1035,22 +1035,13 @@ static __devinit int wm8955_i2c_probe(struct i2c_client *i2c,
1035 1035
1036 ret = snd_soc_register_codec(&i2c->dev, 1036 ret = snd_soc_register_codec(&i2c->dev,
1037 &soc_codec_dev_wm8955, &wm8955_dai, 1); 1037 &soc_codec_dev_wm8955, &wm8955_dai, 1);
1038 if (ret != 0)
1039 goto err;
1040 1038
1041 return ret; 1039 return ret;
1042
1043err:
1044 regmap_exit(wm8955->regmap);
1045 return ret;
1046} 1040}
1047 1041
1048static __devexit int wm8955_i2c_remove(struct i2c_client *client) 1042static __devexit int wm8955_i2c_remove(struct i2c_client *client)
1049{ 1043{
1050 struct wm8955_priv *wm8955 = i2c_get_clientdata(client);
1051
1052 snd_soc_unregister_codec(&client->dev); 1044 snd_soc_unregister_codec(&client->dev);
1053 regmap_exit(wm8955->regmap);
1054 1045
1055 return 0; 1046 return 0;
1056} 1047}
diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c
index f0f6f6601785..cf09cb625a7b 100644
--- a/sound/soc/codecs/wm8960.c
+++ b/sound/soc/codecs/wm8960.c
@@ -1040,7 +1040,7 @@ static __devinit int wm8960_i2c_probe(struct i2c_client *i2c,
1040 if (wm8960 == NULL) 1040 if (wm8960 == NULL)
1041 return -ENOMEM; 1041 return -ENOMEM;
1042 1042
1043 wm8960->regmap = regmap_init_i2c(i2c, &wm8960_regmap); 1043 wm8960->regmap = devm_regmap_init_i2c(i2c, &wm8960_regmap);
1044 if (IS_ERR(wm8960->regmap)) 1044 if (IS_ERR(wm8960->regmap))
1045 return PTR_ERR(wm8960->regmap); 1045 return PTR_ERR(wm8960->regmap);
1046 1046
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index ce6720073798..8fd38cb4ba48 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -3610,7 +3610,7 @@ static __devinit int wm8962_i2c_probe(struct i2c_client *i2c,
3610 for (i = 0; i < ARRAY_SIZE(wm8962->supplies); i++) 3610 for (i = 0; i < ARRAY_SIZE(wm8962->supplies); i++)
3611 wm8962->supplies[i].supply = wm8962_supply_names[i]; 3611 wm8962->supplies[i].supply = wm8962_supply_names[i];
3612 3612
3613 ret = regulator_bulk_get(&i2c->dev, ARRAY_SIZE(wm8962->supplies), 3613 ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(wm8962->supplies),
3614 wm8962->supplies); 3614 wm8962->supplies);
3615 if (ret != 0) { 3615 if (ret != 0) {
3616 dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret); 3616 dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret);
@@ -3621,10 +3621,10 @@ static __devinit int wm8962_i2c_probe(struct i2c_client *i2c,
3621 wm8962->supplies); 3621 wm8962->supplies);
3622 if (ret != 0) { 3622 if (ret != 0) {
3623 dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret); 3623 dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret);
3624 goto err_get; 3624 return ret;
3625 } 3625 }
3626 3626
3627 wm8962->regmap = regmap_init_i2c(i2c, &wm8962_regmap); 3627 wm8962->regmap = devm_regmap_init_i2c(i2c, &wm8962_regmap);
3628 if (IS_ERR(wm8962->regmap)) { 3628 if (IS_ERR(wm8962->regmap)) {
3629 ret = PTR_ERR(wm8962->regmap); 3629 ret = PTR_ERR(wm8962->regmap);
3630 dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret); 3630 dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret);
@@ -3641,20 +3641,20 @@ static __devinit int wm8962_i2c_probe(struct i2c_client *i2c,
3641 ret = regmap_read(wm8962->regmap, WM8962_SOFTWARE_RESET, &reg); 3641 ret = regmap_read(wm8962->regmap, WM8962_SOFTWARE_RESET, &reg);
3642 if (ret < 0) { 3642 if (ret < 0) {
3643 dev_err(&i2c->dev, "Failed to read ID register\n"); 3643 dev_err(&i2c->dev, "Failed to read ID register\n");
3644 goto err_regmap; 3644 goto err_enable;
3645 } 3645 }
3646 if (reg != 0x6243) { 3646 if (reg != 0x6243) {
3647 dev_err(&i2c->dev, 3647 dev_err(&i2c->dev,
3648 "Device is not a WM8962, ID %x != 0x6243\n", reg); 3648 "Device is not a WM8962, ID %x != 0x6243\n", reg);
3649 ret = -EINVAL; 3649 ret = -EINVAL;
3650 goto err_regmap; 3650 goto err_enable;
3651 } 3651 }
3652 3652
3653 ret = regmap_read(wm8962->regmap, WM8962_RIGHT_INPUT_VOLUME, &reg); 3653 ret = regmap_read(wm8962->regmap, WM8962_RIGHT_INPUT_VOLUME, &reg);
3654 if (ret < 0) { 3654 if (ret < 0) {
3655 dev_err(&i2c->dev, "Failed to read device revision: %d\n", 3655 dev_err(&i2c->dev, "Failed to read device revision: %d\n",
3656 ret); 3656 ret);
3657 goto err_regmap; 3657 goto err_enable;
3658 } 3658 }
3659 3659
3660 dev_info(&i2c->dev, "customer id %x revision %c\n", 3660 dev_info(&i2c->dev, "customer id %x revision %c\n",
@@ -3667,7 +3667,7 @@ static __devinit int wm8962_i2c_probe(struct i2c_client *i2c,
3667 ret = wm8962_reset(wm8962); 3667 ret = wm8962_reset(wm8962);
3668 if (ret < 0) { 3668 if (ret < 0) {
3669 dev_err(&i2c->dev, "Failed to issue reset\n"); 3669 dev_err(&i2c->dev, "Failed to issue reset\n");
3670 goto err_regmap; 3670 goto err_enable;
3671 } 3671 }
3672 3672
3673 if (pdata && pdata->in4_dc_measure) { 3673 if (pdata && pdata->in4_dc_measure) {
@@ -3686,30 +3686,22 @@ static __devinit int wm8962_i2c_probe(struct i2c_client *i2c,
3686 ret = snd_soc_register_codec(&i2c->dev, 3686 ret = snd_soc_register_codec(&i2c->dev,
3687 &soc_codec_dev_wm8962, &wm8962_dai, 1); 3687 &soc_codec_dev_wm8962, &wm8962_dai, 1);
3688 if (ret < 0) 3688 if (ret < 0)
3689 goto err_regmap; 3689 goto err_enable;
3690 3690
3691 /* The drivers should power up as needed */ 3691 /* The drivers should power up as needed */
3692 regulator_bulk_disable(ARRAY_SIZE(wm8962->supplies), wm8962->supplies); 3692 regulator_bulk_disable(ARRAY_SIZE(wm8962->supplies), wm8962->supplies);
3693 3693
3694 return 0; 3694 return 0;
3695 3695
3696err_regmap:
3697 regmap_exit(wm8962->regmap);
3698err_enable: 3696err_enable:
3699 regulator_bulk_disable(ARRAY_SIZE(wm8962->supplies), wm8962->supplies); 3697 regulator_bulk_disable(ARRAY_SIZE(wm8962->supplies), wm8962->supplies);
3700err_get:
3701 regulator_bulk_free(ARRAY_SIZE(wm8962->supplies), wm8962->supplies);
3702err: 3698err:
3703 return ret; 3699 return ret;
3704} 3700}
3705 3701
3706static __devexit int wm8962_i2c_remove(struct i2c_client *client) 3702static __devexit int wm8962_i2c_remove(struct i2c_client *client)
3707{ 3703{
3708 struct wm8962_priv *wm8962 = dev_get_drvdata(&client->dev);
3709
3710 snd_soc_unregister_codec(&client->dev); 3704 snd_soc_unregister_codec(&client->dev);
3711 regmap_exit(wm8962->regmap);
3712 regulator_bulk_free(ARRAY_SIZE(wm8962->supplies), wm8962->supplies);
3713 return 0; 3705 return 0;
3714} 3706}
3715 3707
diff --git a/sound/soc/codecs/wm8971.c b/sound/soc/codecs/wm8971.c
index 5ce647758443..70dd27e94514 100644
--- a/sound/soc/codecs/wm8971.c
+++ b/sound/soc/codecs/wm8971.c
@@ -19,6 +19,7 @@
19#include <linux/delay.h> 19#include <linux/delay.h>
20#include <linux/pm.h> 20#include <linux/pm.h>
21#include <linux/i2c.h> 21#include <linux/i2c.h>
22#include <linux/regmap.h>
22#include <linux/slab.h> 23#include <linux/slab.h>
23#include <sound/core.h> 24#include <sound/core.h>
24#include <sound/pcm.h> 25#include <sound/pcm.h>
@@ -34,7 +35,6 @@ static struct workqueue_struct *wm8971_workq = NULL;
34 35
35/* codec private data */ 36/* codec private data */
36struct wm8971_priv { 37struct wm8971_priv {
37 enum snd_soc_control_type control_type;
38 unsigned int sysclk; 38 unsigned int sysclk;
39}; 39};
40 40
@@ -43,18 +43,50 @@ struct wm8971_priv {
43 * We can't read the WM8971 register space when we 43 * We can't read the WM8971 register space when we
44 * are using 2 wire for device control, so we cache them instead. 44 * are using 2 wire for device control, so we cache them instead.
45 */ 45 */
46static const u16 wm8971_reg[] = { 46static const struct reg_default wm8971_reg_defaults[] = {
47 0x0097, 0x0097, 0x0079, 0x0079, /* 0 */ 47 { 0, 0x0097 },
48 0x0000, 0x0008, 0x0000, 0x000a, /* 4 */ 48 { 1, 0x0097 },
49 0x0000, 0x0000, 0x00ff, 0x00ff, /* 8 */ 49 { 2, 0x0079 },
50 0x000f, 0x000f, 0x0000, 0x0000, /* 12 */ 50 { 3, 0x0079 },
51 0x0000, 0x007b, 0x0000, 0x0032, /* 16 */ 51 { 4, 0x0000 },
52 0x0000, 0x00c3, 0x00c3, 0x00c0, /* 20 */ 52 { 5, 0x0008 },
53 0x0000, 0x0000, 0x0000, 0x0000, /* 24 */ 53 { 6, 0x0000 },
54 0x0000, 0x0000, 0x0000, 0x0000, /* 28 */ 54 { 7, 0x000a },
55 0x0000, 0x0000, 0x0050, 0x0050, /* 32 */ 55 { 8, 0x0000 },
56 0x0050, 0x0050, 0x0050, 0x0050, /* 36 */ 56 { 9, 0x0000 },
57 0x0079, 0x0079, 0x0079, /* 40 */ 57 { 10, 0x00ff },
58 { 11, 0x00ff },
59 { 12, 0x000f },
60 { 13, 0x000f },
61 { 14, 0x0000 },
62 { 15, 0x0000 },
63 { 16, 0x0000 },
64 { 17, 0x007b },
65 { 18, 0x0000 },
66 { 19, 0x0032 },
67 { 20, 0x0000 },
68 { 21, 0x00c3 },
69 { 22, 0x00c3 },
70 { 23, 0x00c0 },
71 { 24, 0x0000 },
72 { 25, 0x0000 },
73 { 26, 0x0000 },
74 { 27, 0x0000 },
75 { 28, 0x0000 },
76 { 29, 0x0000 },
77 { 30, 0x0000 },
78 { 31, 0x0000 },
79 { 32, 0x0000 },
80 { 33, 0x0000 },
81 { 34, 0x0050 },
82 { 35, 0x0050 },
83 { 36, 0x0050 },
84 { 37, 0x0050 },
85 { 38, 0x0050 },
86 { 39, 0x0050 },
87 { 40, 0x0079 },
88 { 41, 0x0079 },
89 { 42, 0x0079 },
58}; 90};
59 91
60#define wm8971_reset(c) snd_soc_write(c, WM8971_RESET, 0) 92#define wm8971_reset(c) snd_soc_write(c, WM8971_RESET, 0)
@@ -613,11 +645,10 @@ static int wm8971_resume(struct snd_soc_codec *codec)
613 645
614static int wm8971_probe(struct snd_soc_codec *codec) 646static int wm8971_probe(struct snd_soc_codec *codec)
615{ 647{
616 struct wm8971_priv *wm8971 = snd_soc_codec_get_drvdata(codec);
617 int ret = 0; 648 int ret = 0;
618 u16 reg; 649 u16 reg;
619 650
620 ret = snd_soc_codec_set_cache_io(codec, 7, 9, wm8971->control_type); 651 ret = snd_soc_codec_set_cache_io(codec, 7, 9, SND_SOC_REGMAP);
621 if (ret < 0) { 652 if (ret < 0) {
622 printk(KERN_ERR "wm8971: failed to set cache I/O: %d\n", ret); 653 printk(KERN_ERR "wm8971: failed to set cache I/O: %d\n", ret);
623 return ret; 654 return ret;
@@ -667,9 +698,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8971 = {
667 .suspend = wm8971_suspend, 698 .suspend = wm8971_suspend,
668 .resume = wm8971_resume, 699 .resume = wm8971_resume,
669 .set_bias_level = wm8971_set_bias_level, 700 .set_bias_level = wm8971_set_bias_level,
670 .reg_cache_size = ARRAY_SIZE(wm8971_reg),
671 .reg_word_size = sizeof(u16),
672 .reg_cache_default = wm8971_reg,
673 701
674 .controls = wm8971_snd_controls, 702 .controls = wm8971_snd_controls,
675 .num_controls = ARRAY_SIZE(wm8971_snd_controls), 703 .num_controls = ARRAY_SIZE(wm8971_snd_controls),
@@ -679,10 +707,21 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8971 = {
679 .num_dapm_routes = ARRAY_SIZE(wm8971_dapm_routes), 707 .num_dapm_routes = ARRAY_SIZE(wm8971_dapm_routes),
680}; 708};
681 709
710static const struct regmap_config wm8971_regmap = {
711 .reg_bits = 7,
712 .val_bits = 9,
713 .max_register = WM8971_MOUTV,
714
715 .reg_defaults = wm8971_reg_defaults,
716 .num_reg_defaults = ARRAY_SIZE(wm8971_reg_defaults),
717 .cache_type = REGCACHE_RBTREE,
718};
719
682static __devinit int wm8971_i2c_probe(struct i2c_client *i2c, 720static __devinit int wm8971_i2c_probe(struct i2c_client *i2c,
683 const struct i2c_device_id *id) 721 const struct i2c_device_id *id)
684{ 722{
685 struct wm8971_priv *wm8971; 723 struct wm8971_priv *wm8971;
724 struct regmap *regmap;
686 int ret; 725 int ret;
687 726
688 wm8971 = devm_kzalloc(&i2c->dev, sizeof(struct wm8971_priv), 727 wm8971 = devm_kzalloc(&i2c->dev, sizeof(struct wm8971_priv),
@@ -690,7 +729,10 @@ static __devinit int wm8971_i2c_probe(struct i2c_client *i2c,
690 if (wm8971 == NULL) 729 if (wm8971 == NULL)
691 return -ENOMEM; 730 return -ENOMEM;
692 731
693 wm8971->control_type = SND_SOC_I2C; 732 regmap = devm_regmap_init_i2c(i2c, &wm8971_regmap);
733 if (IS_ERR(regmap))
734 return PTR_ERR(regmap);
735
694 i2c_set_clientdata(i2c, wm8971); 736 i2c_set_clientdata(i2c, wm8971);
695 737
696 ret = snd_soc_register_codec(&i2c->dev, 738 ret = snd_soc_register_codec(&i2c->dev,
diff --git a/sound/soc/codecs/wm8978.c b/sound/soc/codecs/wm8978.c
index b54c9e532758..ef467001c3d5 100644
--- a/sound/soc/codecs/wm8978.c
+++ b/sound/soc/codecs/wm8978.c
@@ -779,7 +779,7 @@ static int wm8978_hw_params(struct snd_pcm_substream *substream,
779 wm8978->mclk_idx = -1; 779 wm8978->mclk_idx = -1;
780 f_sel = wm8978->f_mclk; 780 f_sel = wm8978->f_mclk;
781 } else { 781 } else {
782 if (!wm8978->f_pllout) { 782 if (!wm8978->f_opclk) {
783 /* We only enter here, if OPCLK is not used */ 783 /* We only enter here, if OPCLK is not used */
784 int ret = wm8978_configure_pll(codec); 784 int ret = wm8978_configure_pll(codec);
785 if (ret < 0) 785 if (ret < 0)
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
new file mode 100644
index 000000000000..ffc89fab96fb
--- /dev/null
+++ b/sound/soc/codecs/wm_adsp.c
@@ -0,0 +1,699 @@
1/*
2 * wm_adsp.c -- Wolfson ADSP support
3 *
4 * Copyright 2012 Wolfson Microelectronics plc
5 *
6 * Author: Mark Brown <broonie@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/module.h>
14#include <linux/moduleparam.h>
15#include <linux/init.h>
16#include <linux/delay.h>
17#include <linux/firmware.h>
18#include <linux/pm.h>
19#include <linux/pm_runtime.h>
20#include <linux/regmap.h>
21#include <linux/regulator/consumer.h>
22#include <linux/slab.h>
23#include <sound/core.h>
24#include <sound/pcm.h>
25#include <sound/pcm_params.h>
26#include <sound/soc.h>
27#include <sound/jack.h>
28#include <sound/initval.h>
29#include <sound/tlv.h>
30
31#include <linux/mfd/arizona/registers.h>
32
33#include "wm_adsp.h"
34
35#define adsp_crit(_dsp, fmt, ...) \
36 dev_crit(_dsp->dev, "DSP%d: " fmt, _dsp->num, ##__VA_ARGS__)
37#define adsp_err(_dsp, fmt, ...) \
38 dev_err(_dsp->dev, "DSP%d: " fmt, _dsp->num, ##__VA_ARGS__)
39#define adsp_warn(_dsp, fmt, ...) \
40 dev_warn(_dsp->dev, "DSP%d: " fmt, _dsp->num, ##__VA_ARGS__)
41#define adsp_info(_dsp, fmt, ...) \
42 dev_info(_dsp->dev, "DSP%d: " fmt, _dsp->num, ##__VA_ARGS__)
43#define adsp_dbg(_dsp, fmt, ...) \
44 dev_dbg(_dsp->dev, "DSP%d: " fmt, _dsp->num, ##__VA_ARGS__)
45
46#define ADSP1_CONTROL_1 0x00
47#define ADSP1_CONTROL_2 0x02
48#define ADSP1_CONTROL_3 0x03
49#define ADSP1_CONTROL_4 0x04
50#define ADSP1_CONTROL_5 0x06
51#define ADSP1_CONTROL_6 0x07
52#define ADSP1_CONTROL_7 0x08
53#define ADSP1_CONTROL_8 0x09
54#define ADSP1_CONTROL_9 0x0A
55#define ADSP1_CONTROL_10 0x0B
56#define ADSP1_CONTROL_11 0x0C
57#define ADSP1_CONTROL_12 0x0D
58#define ADSP1_CONTROL_13 0x0F
59#define ADSP1_CONTROL_14 0x10
60#define ADSP1_CONTROL_15 0x11
61#define ADSP1_CONTROL_16 0x12
62#define ADSP1_CONTROL_17 0x13
63#define ADSP1_CONTROL_18 0x14
64#define ADSP1_CONTROL_19 0x16
65#define ADSP1_CONTROL_20 0x17
66#define ADSP1_CONTROL_21 0x18
67#define ADSP1_CONTROL_22 0x1A
68#define ADSP1_CONTROL_23 0x1B
69#define ADSP1_CONTROL_24 0x1C
70#define ADSP1_CONTROL_25 0x1E
71#define ADSP1_CONTROL_26 0x20
72#define ADSP1_CONTROL_27 0x21
73#define ADSP1_CONTROL_28 0x22
74#define ADSP1_CONTROL_29 0x23
75#define ADSP1_CONTROL_30 0x24
76#define ADSP1_CONTROL_31 0x26
77
78/*
79 * ADSP1 Control 19
80 */
81#define ADSP1_WDMA_BUFFER_LENGTH_MASK 0x00FF /* DSP1_WDMA_BUFFER_LENGTH - [7:0] */
82#define ADSP1_WDMA_BUFFER_LENGTH_SHIFT 0 /* DSP1_WDMA_BUFFER_LENGTH - [7:0] */
83#define ADSP1_WDMA_BUFFER_LENGTH_WIDTH 8 /* DSP1_WDMA_BUFFER_LENGTH - [7:0] */
84
85
86/*
87 * ADSP1 Control 30
88 */
89#define ADSP1_DBG_CLK_ENA 0x0008 /* DSP1_DBG_CLK_ENA */
90#define ADSP1_DBG_CLK_ENA_MASK 0x0008 /* DSP1_DBG_CLK_ENA */
91#define ADSP1_DBG_CLK_ENA_SHIFT 3 /* DSP1_DBG_CLK_ENA */
92#define ADSP1_DBG_CLK_ENA_WIDTH 1 /* DSP1_DBG_CLK_ENA */
93#define ADSP1_SYS_ENA 0x0004 /* DSP1_SYS_ENA */
94#define ADSP1_SYS_ENA_MASK 0x0004 /* DSP1_SYS_ENA */
95#define ADSP1_SYS_ENA_SHIFT 2 /* DSP1_SYS_ENA */
96#define ADSP1_SYS_ENA_WIDTH 1 /* DSP1_SYS_ENA */
97#define ADSP1_CORE_ENA 0x0002 /* DSP1_CORE_ENA */
98#define ADSP1_CORE_ENA_MASK 0x0002 /* DSP1_CORE_ENA */
99#define ADSP1_CORE_ENA_SHIFT 1 /* DSP1_CORE_ENA */
100#define ADSP1_CORE_ENA_WIDTH 1 /* DSP1_CORE_ENA */
101#define ADSP1_START 0x0001 /* DSP1_START */
102#define ADSP1_START_MASK 0x0001 /* DSP1_START */
103#define ADSP1_START_SHIFT 0 /* DSP1_START */
104#define ADSP1_START_WIDTH 1 /* DSP1_START */
105
106#define ADSP2_CONTROL 0
107#define ADSP2_CLOCKING 1
108#define ADSP2_STATUS1 4
109
110/*
111 * ADSP2 Control
112 */
113
114#define ADSP2_MEM_ENA 0x0010 /* DSP1_MEM_ENA */
115#define ADSP2_MEM_ENA_MASK 0x0010 /* DSP1_MEM_ENA */
116#define ADSP2_MEM_ENA_SHIFT 4 /* DSP1_MEM_ENA */
117#define ADSP2_MEM_ENA_WIDTH 1 /* DSP1_MEM_ENA */
118#define ADSP2_SYS_ENA 0x0004 /* DSP1_SYS_ENA */
119#define ADSP2_SYS_ENA_MASK 0x0004 /* DSP1_SYS_ENA */
120#define ADSP2_SYS_ENA_SHIFT 2 /* DSP1_SYS_ENA */
121#define ADSP2_SYS_ENA_WIDTH 1 /* DSP1_SYS_ENA */
122#define ADSP2_CORE_ENA 0x0002 /* DSP1_CORE_ENA */
123#define ADSP2_CORE_ENA_MASK 0x0002 /* DSP1_CORE_ENA */
124#define ADSP2_CORE_ENA_SHIFT 1 /* DSP1_CORE_ENA */
125#define ADSP2_CORE_ENA_WIDTH 1 /* DSP1_CORE_ENA */
126#define ADSP2_START 0x0001 /* DSP1_START */
127#define ADSP2_START_MASK 0x0001 /* DSP1_START */
128#define ADSP2_START_SHIFT 0 /* DSP1_START */
129#define ADSP2_START_WIDTH 1 /* DSP1_START */
130
131/*
132 * ADSP2 clocking
133 */
134#define ADSP2_CLK_SEL_MASK 0x0007 /* CLK_SEL_ENA */
135#define ADSP2_CLK_SEL_SHIFT 0 /* CLK_SEL_ENA */
136#define ADSP2_CLK_SEL_WIDTH 3 /* CLK_SEL_ENA */
137
138/*
139 * ADSP2 Status 1
140 */
141#define ADSP2_RAM_RDY 0x0001
142#define ADSP2_RAM_RDY_MASK 0x0001
143#define ADSP2_RAM_RDY_SHIFT 0
144#define ADSP2_RAM_RDY_WIDTH 1
145
146
147static struct wm_adsp_region const *wm_adsp_find_region(struct wm_adsp *dsp,
148 int type)
149{
150 int i;
151
152 for (i = 0; i < dsp->num_mems; i++)
153 if (dsp->mem[i].type == type)
154 return &dsp->mem[i];
155
156 return NULL;
157}
158
159static int wm_adsp_load(struct wm_adsp *dsp)
160{
161 const struct firmware *firmware;
162 struct regmap *regmap = dsp->regmap;
163 unsigned int pos = 0;
164 const struct wmfw_header *header;
165 const struct wmfw_adsp1_sizes *adsp1_sizes;
166 const struct wmfw_adsp2_sizes *adsp2_sizes;
167 const struct wmfw_footer *footer;
168 const struct wmfw_region *region;
169 const struct wm_adsp_region *mem;
170 const char *region_name;
171 char *file, *text;
172 unsigned int reg;
173 int regions = 0;
174 int ret, offset, type, sizes;
175
176 file = kzalloc(PAGE_SIZE, GFP_KERNEL);
177 if (file == NULL)
178 return -ENOMEM;
179
180 snprintf(file, PAGE_SIZE, "%s-dsp%d.wmfw", dsp->part, dsp->num);
181 file[PAGE_SIZE - 1] = '\0';
182
183 ret = request_firmware(&firmware, file, dsp->dev);
184 if (ret != 0) {
185 adsp_err(dsp, "Failed to request '%s'\n", file);
186 goto out;
187 }
188 ret = -EINVAL;
189
190 pos = sizeof(*header) + sizeof(*adsp1_sizes) + sizeof(*footer);
191 if (pos >= firmware->size) {
192 adsp_err(dsp, "%s: file too short, %zu bytes\n",
193 file, firmware->size);
194 goto out_fw;
195 }
196
197 header = (void*)&firmware->data[0];
198
199 if (memcmp(&header->magic[0], "WMFW", 4) != 0) {
200 adsp_err(dsp, "%s: invalid magic\n", file);
201 goto out_fw;
202 }
203
204 if (header->ver != 0) {
205 adsp_err(dsp, "%s: unknown file format %d\n",
206 file, header->ver);
207 goto out_fw;
208 }
209
210 if (header->core != dsp->type) {
211 adsp_err(dsp, "%s: invalid core %d != %d\n",
212 file, header->core, dsp->type);
213 goto out_fw;
214 }
215
216 switch (dsp->type) {
217 case WMFW_ADSP1:
218 pos = sizeof(*header) + sizeof(*adsp1_sizes) + sizeof(*footer);
219 adsp1_sizes = (void *)&(header[1]);
220 footer = (void *)&(adsp1_sizes[1]);
221 sizes = sizeof(*adsp1_sizes);
222
223 adsp_dbg(dsp, "%s: %d DM, %d PM, %d ZM\n",
224 file, le32_to_cpu(adsp1_sizes->dm),
225 le32_to_cpu(adsp1_sizes->pm),
226 le32_to_cpu(adsp1_sizes->zm));
227 break;
228
229 case WMFW_ADSP2:
230 pos = sizeof(*header) + sizeof(*adsp2_sizes) + sizeof(*footer);
231 adsp2_sizes = (void *)&(header[1]);
232 footer = (void *)&(adsp2_sizes[1]);
233 sizes = sizeof(*adsp2_sizes);
234
235 adsp_dbg(dsp, "%s: %d XM, %d YM %d PM, %d ZM\n",
236 file, le32_to_cpu(adsp2_sizes->xm),
237 le32_to_cpu(adsp2_sizes->ym),
238 le32_to_cpu(adsp2_sizes->pm),
239 le32_to_cpu(adsp2_sizes->zm));
240 break;
241
242 default:
243 BUG_ON(NULL == "Unknown DSP type");
244 goto out_fw;
245 }
246
247 if (le32_to_cpu(header->len) != sizeof(*header) +
248 sizes + sizeof(*footer)) {
249 adsp_err(dsp, "%s: unexpected header length %d\n",
250 file, le32_to_cpu(header->len));
251 goto out_fw;
252 }
253
254 adsp_dbg(dsp, "%s: timestamp %llu\n", file,
255 le64_to_cpu(footer->timestamp));
256
257 while (pos < firmware->size &&
258 pos - firmware->size > sizeof(*region)) {
259 region = (void *)&(firmware->data[pos]);
260 region_name = "Unknown";
261 reg = 0;
262 text = NULL;
263 offset = le32_to_cpu(region->offset) & 0xffffff;
264 type = be32_to_cpu(region->type) & 0xff;
265 mem = wm_adsp_find_region(dsp, type);
266
267 switch (type) {
268 case WMFW_NAME_TEXT:
269 region_name = "Firmware name";
270 text = kzalloc(le32_to_cpu(region->len) + 1,
271 GFP_KERNEL);
272 break;
273 case WMFW_INFO_TEXT:
274 region_name = "Information";
275 text = kzalloc(le32_to_cpu(region->len) + 1,
276 GFP_KERNEL);
277 break;
278 case WMFW_ABSOLUTE:
279 region_name = "Absolute";
280 reg = offset;
281 break;
282 case WMFW_ADSP1_PM:
283 BUG_ON(!mem);
284 region_name = "PM";
285 reg = mem->base + (offset * 3);
286 break;
287 case WMFW_ADSP1_DM:
288 BUG_ON(!mem);
289 region_name = "DM";
290 reg = mem->base + (offset * 2);
291 break;
292 case WMFW_ADSP2_XM:
293 BUG_ON(!mem);
294 region_name = "XM";
295 reg = mem->base + (offset * 2);
296 break;
297 case WMFW_ADSP2_YM:
298 BUG_ON(!mem);
299 region_name = "YM";
300 reg = mem->base + (offset * 2);
301 break;
302 case WMFW_ADSP1_ZM:
303 BUG_ON(!mem);
304 region_name = "ZM";
305 reg = mem->base + (offset * 2);
306 break;
307 default:
308 adsp_warn(dsp,
309 "%s.%d: Unknown region type %x at %d(%x)\n",
310 file, regions, type, pos, pos);
311 break;
312 }
313
314 adsp_dbg(dsp, "%s.%d: %d bytes at %d in %s\n", file,
315 regions, le32_to_cpu(region->len), offset,
316 region_name);
317
318 if (text) {
319 memcpy(text, region->data, le32_to_cpu(region->len));
320 adsp_info(dsp, "%s: %s\n", file, text);
321 kfree(text);
322 }
323
324 if (reg) {
325 ret = regmap_raw_write(regmap, reg, region->data,
326 le32_to_cpu(region->len));
327 if (ret != 0) {
328 adsp_err(dsp,
329 "%s.%d: Failed to write %d bytes at %d in %s: %d\n",
330 file, regions,
331 le32_to_cpu(region->len), offset,
332 region_name, ret);
333 goto out_fw;
334 }
335 }
336
337 pos += le32_to_cpu(region->len) + sizeof(*region);
338 regions++;
339 }
340
341 if (pos > firmware->size)
342 adsp_warn(dsp, "%s.%d: %zu bytes at end of file\n",
343 file, regions, pos - firmware->size);
344
345out_fw:
346 release_firmware(firmware);
347out:
348 kfree(file);
349
350 return ret;
351}
352
353static int wm_adsp_load_coeff(struct wm_adsp *dsp)
354{
355 struct regmap *regmap = dsp->regmap;
356 struct wmfw_coeff_hdr *hdr;
357 struct wmfw_coeff_item *blk;
358 const struct firmware *firmware;
359 const char *region_name;
360 int ret, pos, blocks, type, offset, reg;
361 char *file;
362
363 file = kzalloc(PAGE_SIZE, GFP_KERNEL);
364 if (file == NULL)
365 return -ENOMEM;
366
367 snprintf(file, PAGE_SIZE, "%s-dsp%d.bin", dsp->part, dsp->num);
368 file[PAGE_SIZE - 1] = '\0';
369
370 ret = request_firmware(&firmware, file, dsp->dev);
371 if (ret != 0) {
372 adsp_warn(dsp, "Failed to request '%s'\n", file);
373 ret = 0;
374 goto out;
375 }
376 ret = -EINVAL;
377
378 if (sizeof(*hdr) >= firmware->size) {
379 adsp_err(dsp, "%s: file too short, %zu bytes\n",
380 file, firmware->size);
381 goto out_fw;
382 }
383
384 hdr = (void*)&firmware->data[0];
385 if (memcmp(hdr->magic, "WMDR", 4) != 0) {
386 adsp_err(dsp, "%s: invalid magic\n", file);
387 return -EINVAL;
388 }
389
390 adsp_dbg(dsp, "%s: v%d.%d.%d\n", file,
391 (le32_to_cpu(hdr->ver) >> 16) & 0xff,
392 (le32_to_cpu(hdr->ver) >> 8) & 0xff,
393 le32_to_cpu(hdr->ver) & 0xff);
394
395 pos = le32_to_cpu(hdr->len);
396
397 blocks = 0;
398 while (pos < firmware->size &&
399 pos - firmware->size > sizeof(*blk)) {
400 blk = (void*)(&firmware->data[pos]);
401
402 type = be32_to_cpu(blk->type) & 0xff;
403 offset = le32_to_cpu(blk->offset) & 0xffffff;
404
405 adsp_dbg(dsp, "%s.%d: %x v%d.%d.%d\n",
406 file, blocks, le32_to_cpu(blk->id),
407 (le32_to_cpu(blk->ver) >> 16) & 0xff,
408 (le32_to_cpu(blk->ver) >> 8) & 0xff,
409 le32_to_cpu(blk->ver) & 0xff);
410 adsp_dbg(dsp, "%s.%d: %d bytes at 0x%x in %x\n",
411 file, blocks, le32_to_cpu(blk->len), offset, type);
412
413 reg = 0;
414 region_name = "Unknown";
415 switch (type) {
416 case WMFW_NAME_TEXT:
417 case WMFW_INFO_TEXT:
418 break;
419 case WMFW_ABSOLUTE:
420 region_name = "register";
421 reg = offset;
422 break;
423 default:
424 adsp_err(dsp, "Unknown region type %x\n", type);
425 break;
426 }
427
428 if (reg) {
429 ret = regmap_raw_write(regmap, reg, blk->data,
430 le32_to_cpu(blk->len));
431 if (ret != 0) {
432 adsp_err(dsp,
433 "%s.%d: Failed to write to %x in %s\n",
434 file, blocks, reg, region_name);
435 }
436 }
437
438 pos += le32_to_cpu(blk->len) + sizeof(*blk);
439 blocks++;
440 }
441
442 if (pos > firmware->size)
443 adsp_warn(dsp, "%s.%d: %zu bytes at end of file\n",
444 file, blocks, pos - firmware->size);
445
446out_fw:
447 release_firmware(firmware);
448out:
449 kfree(file);
450 return 0;
451}
452
453int wm_adsp1_event(struct snd_soc_dapm_widget *w,
454 struct snd_kcontrol *kcontrol,
455 int event)
456{
457 struct snd_soc_codec *codec = w->codec;
458 struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec);
459 struct wm_adsp *dsp = &dsps[w->shift];
460 int ret;
461
462 switch (event) {
463 case SND_SOC_DAPM_POST_PMU:
464 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30,
465 ADSP1_SYS_ENA, ADSP1_SYS_ENA);
466
467 ret = wm_adsp_load(dsp);
468 if (ret != 0)
469 goto err;
470
471 ret = wm_adsp_load_coeff(dsp);
472 if (ret != 0)
473 goto err;
474
475 /* Start the core running */
476 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30,
477 ADSP1_CORE_ENA | ADSP1_START,
478 ADSP1_CORE_ENA | ADSP1_START);
479 break;
480
481 case SND_SOC_DAPM_PRE_PMD:
482 /* Halt the core */
483 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30,
484 ADSP1_CORE_ENA | ADSP1_START, 0);
485
486 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_19,
487 ADSP1_WDMA_BUFFER_LENGTH_MASK, 0);
488
489 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30,
490 ADSP1_SYS_ENA, 0);
491 break;
492
493 default:
494 break;
495 }
496
497 return 0;
498
499err:
500 regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30,
501 ADSP1_SYS_ENA, 0);
502 return ret;
503}
504EXPORT_SYMBOL_GPL(wm_adsp1_event);
505
506static int wm_adsp2_ena(struct wm_adsp *dsp)
507{
508 unsigned int val;
509 int ret, count;
510
511 ret = regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL,
512 ADSP2_SYS_ENA, ADSP2_SYS_ENA);
513 if (ret != 0)
514 return ret;
515
516 /* Wait for the RAM to start, should be near instantaneous */
517 count = 0;
518 do {
519 ret = regmap_read(dsp->regmap, dsp->base + ADSP2_STATUS1,
520 &val);
521 if (ret != 0)
522 return ret;
523 } while (!(val & ADSP2_RAM_RDY) && ++count < 10);
524
525 if (!(val & ADSP2_RAM_RDY)) {
526 adsp_err(dsp, "Failed to start DSP RAM\n");
527 return -EBUSY;
528 }
529
530 adsp_dbg(dsp, "RAM ready after %d polls\n", count);
531 adsp_info(dsp, "RAM ready after %d polls\n", count);
532
533 return 0;
534}
535
536int wm_adsp2_event(struct snd_soc_dapm_widget *w,
537 struct snd_kcontrol *kcontrol, int event)
538{
539 struct snd_soc_codec *codec = w->codec;
540 struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec);
541 struct wm_adsp *dsp = &dsps[w->shift];
542 unsigned int val;
543 int ret;
544
545 switch (event) {
546 case SND_SOC_DAPM_POST_PMU:
547 /*
548 * For simplicity set the DSP clock rate to be the
549 * SYSCLK rate rather than making it configurable.
550 */
551 ret = regmap_read(dsp->regmap, ARIZONA_SYSTEM_CLOCK_1, &val);
552 if (ret != 0) {
553 adsp_err(dsp, "Failed to read SYSCLK state: %d\n",
554 ret);
555 return ret;
556 }
557 val = (val & ARIZONA_SYSCLK_FREQ_MASK)
558 >> ARIZONA_SYSCLK_FREQ_SHIFT;
559
560 ret = regmap_update_bits(dsp->regmap,
561 dsp->base + ADSP2_CLOCKING,
562 ADSP2_CLK_SEL_MASK, val);
563 if (ret != 0) {
564 adsp_err(dsp, "Failed to set clock rate: %d\n",
565 ret);
566 return ret;
567 }
568
569 if (dsp->dvfs) {
570 ret = regmap_read(dsp->regmap,
571 dsp->base + ADSP2_CLOCKING, &val);
572 if (ret != 0) {
573 dev_err(dsp->dev,
574 "Failed to read clocking: %d\n", ret);
575 return ret;
576 }
577
578 if ((val & ADSP2_CLK_SEL_MASK) >= 3) {
579 ret = regulator_enable(dsp->dvfs);
580 if (ret != 0) {
581 dev_err(dsp->dev,
582 "Failed to enable supply: %d\n",
583 ret);
584 return ret;
585 }
586
587 ret = regulator_set_voltage(dsp->dvfs,
588 1800000,
589 1800000);
590 if (ret != 0) {
591 dev_err(dsp->dev,
592 "Failed to raise supply: %d\n",
593 ret);
594 return ret;
595 }
596 }
597 }
598
599 ret = wm_adsp2_ena(dsp);
600 if (ret != 0)
601 return ret;
602
603 ret = wm_adsp_load(dsp);
604 if (ret != 0)
605 goto err;
606
607 ret = wm_adsp_load_coeff(dsp);
608 if (ret != 0)
609 goto err;
610
611 ret = regmap_update_bits(dsp->regmap,
612 dsp->base + ADSP2_CONTROL,
613 ADSP2_CORE_ENA | ADSP2_START,
614 ADSP2_CORE_ENA | ADSP2_START);
615 if (ret != 0)
616 goto err;
617 break;
618
619 case SND_SOC_DAPM_PRE_PMD:
620 regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL,
621 ADSP2_SYS_ENA | ADSP2_CORE_ENA |
622 ADSP2_START, 0);
623
624 if (dsp->dvfs) {
625 ret = regulator_set_voltage(dsp->dvfs, 1200000,
626 1800000);
627 if (ret != 0)
628 dev_warn(dsp->dev,
629 "Failed to lower supply: %d\n",
630 ret);
631
632 ret = regulator_disable(dsp->dvfs);
633 if (ret != 0)
634 dev_err(dsp->dev,
635 "Failed to enable supply: %d\n",
636 ret);
637 }
638 break;
639
640 default:
641 break;
642 }
643
644 return 0;
645err:
646 regmap_update_bits(dsp->regmap, dsp->base + ADSP2_CONTROL,
647 ADSP2_SYS_ENA | ADSP2_CORE_ENA | ADSP2_START, 0);
648 return ret;
649}
650EXPORT_SYMBOL_GPL(wm_adsp2_event);
651
652int wm_adsp2_init(struct wm_adsp *adsp, bool dvfs)
653{
654 int ret;
655
656 /*
657 * Disable the DSP memory by default when in reset for a small
658 * power saving.
659 */
660 ret = regmap_update_bits(adsp->regmap, adsp->base + ADSP2_CONTROL,
661 ADSP2_MEM_ENA, 0);
662 if (ret != 0) {
663 adsp_err(adsp, "Failed to clear memory retention: %d\n", ret);
664 return ret;
665 }
666
667 if (dvfs) {
668 adsp->dvfs = devm_regulator_get(adsp->dev, "DCVDD");
669 if (IS_ERR(adsp->dvfs)) {
670 ret = PTR_ERR(adsp->dvfs);
671 dev_err(adsp->dev, "Failed to get DCVDD: %d\n", ret);
672 return ret;
673 }
674
675 ret = regulator_enable(adsp->dvfs);
676 if (ret != 0) {
677 dev_err(adsp->dev, "Failed to enable DCVDD: %d\n",
678 ret);
679 return ret;
680 }
681
682 ret = regulator_set_voltage(adsp->dvfs, 1200000, 1800000);
683 if (ret != 0) {
684 dev_err(adsp->dev, "Failed to initialise DVFS: %d\n",
685 ret);
686 return ret;
687 }
688
689 ret = regulator_disable(adsp->dvfs);
690 if (ret != 0) {
691 dev_err(adsp->dev, "Failed to disable DCVDD: %d\n",
692 ret);
693 return ret;
694 }
695 }
696
697 return 0;
698}
699EXPORT_SYMBOL_GPL(wm_adsp2_init);
diff --git a/sound/soc/codecs/wm_adsp.h b/sound/soc/codecs/wm_adsp.h
new file mode 100644
index 000000000000..ffd29a4609e2
--- /dev/null
+++ b/sound/soc/codecs/wm_adsp.h
@@ -0,0 +1,59 @@
1/*
2 * wm_adsp.h -- Wolfson ADSP support
3 *
4 * Copyright 2012 Wolfson Microelectronics plc
5 *
6 * Author: Mark Brown <broonie@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#ifndef __WM_ADSP_H
14#define __WM_ADSP_H
15
16#include <sound/soc.h>
17#include <sound/soc-dapm.h>
18
19#include "wmfw.h"
20
21struct regulator;
22
23struct wm_adsp_region {
24 int type;
25 unsigned int base;
26};
27
28struct wm_adsp {
29 const char *part;
30 int num;
31 int type;
32 struct device *dev;
33 struct regmap *regmap;
34
35 int base;
36
37 const struct wm_adsp_region *mem;
38 int num_mems;
39
40 struct regulator *dvfs;
41};
42
43#define WM_ADSP1(wname, num) \
44 { .id = snd_soc_dapm_pga, .name = wname, .reg = SND_SOC_NOPM, \
45 .shift = num, .event = wm_adsp1_event, \
46 .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD }
47
48#define WM_ADSP2(wname, num) \
49{ .id = snd_soc_dapm_pga, .name = wname, .reg = SND_SOC_NOPM, \
50 .shift = num, .event = wm_adsp2_event, \
51 .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD }
52
53int wm_adsp2_init(struct wm_adsp *adsp, bool dvfs);
54int wm_adsp1_event(struct snd_soc_dapm_widget *w,
55 struct snd_kcontrol *kcontrol, int event);
56int wm_adsp2_event(struct snd_soc_dapm_widget *w,
57 struct snd_kcontrol *kcontrol, int event);
58
59#endif
diff --git a/sound/soc/codecs/wmfw.h b/sound/soc/codecs/wmfw.h
new file mode 100644
index 000000000000..5632ded67fdd
--- /dev/null
+++ b/sound/soc/codecs/wmfw.h
@@ -0,0 +1,128 @@
1/*
2 * wmfw.h - Wolfson firmware format information
3 *
4 * Copyright 2012 Wolfson Microelectronics plc
5 *
6 * Author: Mark Brown <broonie@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#ifndef __WMFW_H
14#define __WMFW_H
15
16#include <linux/types.h>
17
18struct wmfw_header {
19 char magic[4];
20 __le32 len;
21 __le16 rev;
22 u8 core;
23 u8 ver;
24} __packed;
25
26struct wmfw_footer {
27 __le64 timestamp;
28 __le32 checksum;
29} __packed;
30
31struct wmfw_adsp1_sizes {
32 __le32 dm;
33 __le32 pm;
34 __le32 zm;
35} __packed;
36
37struct wmfw_adsp2_sizes {
38 __le32 xm;
39 __le32 ym;
40 __le32 pm;
41 __le32 zm;
42} __packed;
43
44struct wmfw_region {
45 union {
46 __be32 type;
47 __le32 offset;
48 };
49 __le32 len;
50 u8 data[];
51} __packed;
52
53struct wmfw_id_hdr {
54 __be32 core_id;
55 __be32 core_rev;
56 __be32 id;
57 __be32 ver;
58} __packed;
59
60struct wmfw_adsp1_id_hdr {
61 struct wmfw_id_hdr fw;
62 __be32 zm;
63 __be32 dm;
64 __be32 algs;
65} __packed;
66
67struct wmfw_adsp2_id_hdr {
68 struct wmfw_id_hdr fw;
69 __be32 zm;
70 __be32 xm;
71 __be32 ym;
72 __be32 algs;
73} __packed;
74
75struct wmfw_alg_hdr {
76 __be32 id;
77 __be32 ver;
78} __packed;
79
80struct wmfw_adsp1_alg_hdr {
81 struct wmfw_alg_hdr alg;
82 __be32 zm;
83 __be32 dm;
84} __packed;
85
86struct wmfw_adsp2_alg_hdr {
87 struct wmfw_alg_hdr alg;
88 __be32 zm;
89 __be32 xm;
90 __be32 ym;
91} __packed;
92
93struct wmfw_coeff_hdr {
94 u8 magic[4];
95 __le32 len;
96 __le32 ver;
97 u8 data[];
98} __packed;
99
100struct wmfw_coeff_item {
101 union {
102 __be32 type;
103 __le32 offset;
104 };
105 __le32 id;
106 __le32 ver;
107 __le32 sr;
108 __le32 len;
109 u8 data[];
110} __packed;
111
112#define WMFW_ADSP1 1
113#define WMFW_ADSP2 2
114
115#define WMFW_ABSOLUTE 0xf0
116#define WMFW_NAME_TEXT 0xfe
117#define WMFW_INFO_TEXT 0xff
118
119#define WMFW_ADSP1_PM 2
120#define WMFW_ADSP1_DM 3
121#define WMFW_ADSP1_ZM 4
122
123#define WMFW_ADSP2_PM 2
124#define WMFW_ADSP2_ZM 4
125#define WMFW_ADSP2_XM 5
126#define WMFW_ADSP2_YM 6
127
128#endif
diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c
index 6fac5af13298..d55e6477bff0 100644
--- a/sound/soc/davinci/davinci-evm.c
+++ b/sound/soc/davinci/davinci-evm.c
@@ -71,6 +71,11 @@ static int evm_hw_params(struct snd_pcm_substream *substream,
71 if (ret < 0) 71 if (ret < 0)
72 return ret; 72 return ret;
73 73
74 /* set the CPU system clock */
75 ret = snd_soc_dai_set_sysclk(cpu_dai, 0, sysclk, SND_SOC_CLOCK_OUT);
76 if (ret < 0)
77 return ret;
78
74 return 0; 79 return 0;
75} 80}
76 81
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c
index 714e51e5be5b..55e2bf652bef 100644
--- a/sound/soc/davinci/davinci-mcasp.c
+++ b/sound/soc/davinci/davinci-mcasp.c
@@ -199,6 +199,7 @@
199#define ACLKXE BIT(5) 199#define ACLKXE BIT(5)
200#define TX_ASYNC BIT(6) 200#define TX_ASYNC BIT(6)
201#define ACLKXPOL BIT(7) 201#define ACLKXPOL BIT(7)
202#define ACLKXDIV_MASK 0x1f
202 203
203/* 204/*
204 * DAVINCI_MCASP_ACLKRCTL_REG Receive Clock Control Register Bits 205 * DAVINCI_MCASP_ACLKRCTL_REG Receive Clock Control Register Bits
@@ -207,6 +208,7 @@
207#define ACLKRE BIT(5) 208#define ACLKRE BIT(5)
208#define RX_ASYNC BIT(6) 209#define RX_ASYNC BIT(6)
209#define ACLKRPOL BIT(7) 210#define ACLKRPOL BIT(7)
211#define ACLKRDIV_MASK 0x1f
210 212
211/* 213/*
212 * DAVINCI_MCASP_AHCLKXCTL_REG - High Frequency Transmit Clock Control 214 * DAVINCI_MCASP_AHCLKXCTL_REG - High Frequency Transmit Clock Control
@@ -215,6 +217,7 @@
215#define AHCLKXDIV(val) (val) 217#define AHCLKXDIV(val) (val)
216#define AHCLKXPOL BIT(14) 218#define AHCLKXPOL BIT(14)
217#define AHCLKXE BIT(15) 219#define AHCLKXE BIT(15)
220#define AHCLKXDIV_MASK 0xfff
218 221
219/* 222/*
220 * DAVINCI_MCASP_AHCLKRCTL_REG - High Frequency Receive Clock Control 223 * DAVINCI_MCASP_AHCLKRCTL_REG - High Frequency Receive Clock Control
@@ -223,6 +226,7 @@
223#define AHCLKRDIV(val) (val) 226#define AHCLKRDIV(val) (val)
224#define AHCLKRPOL BIT(14) 227#define AHCLKRPOL BIT(14)
225#define AHCLKRE BIT(15) 228#define AHCLKRE BIT(15)
229#define AHCLKRDIV_MASK 0xfff
226 230
227/* 231/*
228 * DAVINCI_MCASP_XRSRCTL_BASE_REG - Serializer Control Register Bits 232 * DAVINCI_MCASP_XRSRCTL_BASE_REG - Serializer Control Register Bits
@@ -473,6 +477,23 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
473 struct davinci_audio_dev *dev = snd_soc_dai_get_drvdata(cpu_dai); 477 struct davinci_audio_dev *dev = snd_soc_dai_get_drvdata(cpu_dai);
474 void __iomem *base = dev->base; 478 void __iomem *base = dev->base;
475 479
480 switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
481 case SND_SOC_DAIFMT_DSP_B:
482 case SND_SOC_DAIFMT_AC97:
483 mcasp_clr_bits(dev->base + DAVINCI_MCASP_TXFMCTL_REG, FSXDUR);
484 mcasp_clr_bits(dev->base + DAVINCI_MCASP_RXFMCTL_REG, FSRDUR);
485 break;
486 default:
487 /* configure a full-word SYNC pulse (LRCLK) */
488 mcasp_set_bits(dev->base + DAVINCI_MCASP_TXFMCTL_REG, FSXDUR);
489 mcasp_set_bits(dev->base + DAVINCI_MCASP_RXFMCTL_REG, FSRDUR);
490
491 /* make 1st data bit occur one ACLK cycle after the frame sync */
492 mcasp_set_bits(dev->base + DAVINCI_MCASP_TXFMT_REG, FSXDLY(1));
493 mcasp_set_bits(dev->base + DAVINCI_MCASP_RXFMT_REG, FSRDLY(1));
494 break;
495 }
496
476 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { 497 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
477 case SND_SOC_DAIFMT_CBS_CFS: 498 case SND_SOC_DAIFMT_CBS_CFS:
478 /* codec is clock and frame slave */ 499 /* codec is clock and frame slave */
@@ -482,8 +503,7 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
482 mcasp_set_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRE); 503 mcasp_set_bits(base + DAVINCI_MCASP_ACLKRCTL_REG, ACLKRE);
483 mcasp_set_bits(base + DAVINCI_MCASP_RXFMCTL_REG, AFSRE); 504 mcasp_set_bits(base + DAVINCI_MCASP_RXFMCTL_REG, AFSRE);
484 505
485 mcasp_set_bits(base + DAVINCI_MCASP_PDIR_REG, 506 mcasp_set_bits(base + DAVINCI_MCASP_PDIR_REG, ACLKX | AFSX);
486 ACLKX | AHCLKX | AFSX);
487 break; 507 break;
488 case SND_SOC_DAIFMT_CBM_CFS: 508 case SND_SOC_DAIFMT_CBM_CFS:
489 /* codec is clock master and frame slave */ 509 /* codec is clock master and frame slave */
@@ -554,59 +574,75 @@ static int davinci_mcasp_set_dai_fmt(struct snd_soc_dai *cpu_dai,
554 return 0; 574 return 0;
555} 575}
556 576
557static int davinci_config_channel_size(struct davinci_audio_dev *dev, 577static int davinci_mcasp_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div)
558 int channel_size)
559{ 578{
560 u32 fmt = 0; 579 struct davinci_audio_dev *dev = snd_soc_dai_get_drvdata(dai);
561 u32 mask, rotate;
562
563 switch (channel_size) {
564 case DAVINCI_AUDIO_WORD_8:
565 fmt = 0x03;
566 rotate = 6;
567 mask = 0x000000ff;
568 break;
569 580
570 case DAVINCI_AUDIO_WORD_12: 581 switch (div_id) {
571 fmt = 0x05; 582 case 0: /* MCLK divider */
572 rotate = 5; 583 mcasp_mod_bits(dev->base + DAVINCI_MCASP_AHCLKXCTL_REG,
573 mask = 0x00000fff; 584 AHCLKXDIV(div - 1), AHCLKXDIV_MASK);
585 mcasp_mod_bits(dev->base + DAVINCI_MCASP_AHCLKRCTL_REG,
586 AHCLKRDIV(div - 1), AHCLKRDIV_MASK);
574 break; 587 break;
575 588
576 case DAVINCI_AUDIO_WORD_16: 589 case 1: /* BCLK divider */
577 fmt = 0x07; 590 mcasp_mod_bits(dev->base + DAVINCI_MCASP_ACLKXCTL_REG,
578 rotate = 4; 591 ACLKXDIV(div - 1), ACLKXDIV_MASK);
579 mask = 0x0000ffff; 592 mcasp_mod_bits(dev->base + DAVINCI_MCASP_ACLKRCTL_REG,
593 ACLKRDIV(div - 1), ACLKRDIV_MASK);
580 break; 594 break;
581 595
582 case DAVINCI_AUDIO_WORD_20: 596 case 2: /* BCLK/LRCLK ratio */
583 fmt = 0x09; 597 dev->bclk_lrclk_ratio = div;
584 rotate = 3;
585 mask = 0x000fffff;
586 break; 598 break;
587 599
588 case DAVINCI_AUDIO_WORD_24: 600 default:
589 fmt = 0x0B; 601 return -EINVAL;
590 rotate = 2; 602 }
591 mask = 0x00ffffff;
592 break;
593 603
594 case DAVINCI_AUDIO_WORD_28: 604 return 0;
595 fmt = 0x0D; 605}
596 rotate = 1;
597 mask = 0x0fffffff;
598 break;
599 606
600 case DAVINCI_AUDIO_WORD_32: 607static int davinci_mcasp_set_sysclk(struct snd_soc_dai *dai, int clk_id,
601 fmt = 0x0F; 608 unsigned int freq, int dir)
602 rotate = 0; 609{
603 mask = 0xffffffff; 610 struct davinci_audio_dev *dev = snd_soc_dai_get_drvdata(dai);
604 break;
605 611
606 default: 612 if (dir == SND_SOC_CLOCK_OUT) {
607 return -EINVAL; 613 mcasp_set_bits(dev->base + DAVINCI_MCASP_AHCLKXCTL_REG, AHCLKXE);
614 mcasp_set_bits(dev->base + DAVINCI_MCASP_AHCLKRCTL_REG, AHCLKRE);
615 mcasp_set_bits(dev->base + DAVINCI_MCASP_PDIR_REG, AHCLKX);
616 } else {
617 mcasp_clr_bits(dev->base + DAVINCI_MCASP_AHCLKXCTL_REG, AHCLKXE);
618 mcasp_clr_bits(dev->base + DAVINCI_MCASP_AHCLKRCTL_REG, AHCLKRE);
619 mcasp_clr_bits(dev->base + DAVINCI_MCASP_PDIR_REG, AHCLKX);
608 } 620 }
609 621
622 return 0;
623}
624
625static int davinci_config_channel_size(struct davinci_audio_dev *dev,
626 int word_length)
627{
628 u32 fmt;
629 u32 rotate = (32 - word_length) / 4;
630 u32 mask = (1ULL << word_length) - 1;
631
632 /*
633 * if s BCLK-to-LRCLK ratio has been configured via the set_clkdiv()
634 * callback, take it into account here. That allows us to for example
635 * send 32 bits per channel to the codec, while only 16 of them carry
636 * audio payload.
637 * The clock ratio is given for a full period of data (both left and
638 * right channels), so it has to be divided by 2.
639 */
640 if (dev->bclk_lrclk_ratio)
641 word_length = dev->bclk_lrclk_ratio / 2;
642
643 /* mapping of the XSSZ bit-field as described in the datasheet */
644 fmt = (word_length >> 1) - 1;
645
610 mcasp_mod_bits(dev->base + DAVINCI_MCASP_RXFMT_REG, 646 mcasp_mod_bits(dev->base + DAVINCI_MCASP_RXFMT_REG,
611 RXSSZ(fmt), RXSSZ(0x0F)); 647 RXSSZ(fmt), RXSSZ(0x0F));
612 mcasp_mod_bits(dev->base + DAVINCI_MCASP_TXFMT_REG, 648 mcasp_mod_bits(dev->base + DAVINCI_MCASP_TXFMT_REG,
@@ -709,8 +745,6 @@ static void davinci_hw_param(struct davinci_audio_dev *dev, int stream)
709 if (stream == SNDRV_PCM_STREAM_PLAYBACK) { 745 if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
710 /* bit stream is MSB first with no delay */ 746 /* bit stream is MSB first with no delay */
711 /* DSP_B mode */ 747 /* DSP_B mode */
712 mcasp_set_bits(dev->base + DAVINCI_MCASP_AHCLKXCTL_REG,
713 AHCLKXE);
714 mcasp_set_reg(dev->base + DAVINCI_MCASP_TXTDM_REG, mask); 748 mcasp_set_reg(dev->base + DAVINCI_MCASP_TXTDM_REG, mask);
715 mcasp_set_bits(dev->base + DAVINCI_MCASP_TXFMT_REG, TXORD); 749 mcasp_set_bits(dev->base + DAVINCI_MCASP_TXFMT_REG, TXORD);
716 750
@@ -720,14 +754,10 @@ static void davinci_hw_param(struct davinci_audio_dev *dev, int stream)
720 else 754 else
721 printk(KERN_ERR "playback tdm slot %d not supported\n", 755 printk(KERN_ERR "playback tdm slot %d not supported\n",
722 dev->tdm_slots); 756 dev->tdm_slots);
723
724 mcasp_clr_bits(dev->base + DAVINCI_MCASP_TXFMCTL_REG, FSXDUR);
725 } else { 757 } else {
726 /* bit stream is MSB first with no delay */ 758 /* bit stream is MSB first with no delay */
727 /* DSP_B mode */ 759 /* DSP_B mode */
728 mcasp_set_bits(dev->base + DAVINCI_MCASP_RXFMT_REG, RXORD); 760 mcasp_set_bits(dev->base + DAVINCI_MCASP_RXFMT_REG, RXORD);
729 mcasp_set_bits(dev->base + DAVINCI_MCASP_AHCLKRCTL_REG,
730 AHCLKRE);
731 mcasp_set_reg(dev->base + DAVINCI_MCASP_RXTDM_REG, mask); 761 mcasp_set_reg(dev->base + DAVINCI_MCASP_RXTDM_REG, mask);
732 762
733 if ((dev->tdm_slots >= 2) && (dev->tdm_slots <= 32)) 763 if ((dev->tdm_slots >= 2) && (dev->tdm_slots <= 32))
@@ -736,8 +766,6 @@ static void davinci_hw_param(struct davinci_audio_dev *dev, int stream)
736 else 766 else
737 printk(KERN_ERR "capture tdm slot %d not supported\n", 767 printk(KERN_ERR "capture tdm slot %d not supported\n",
738 dev->tdm_slots); 768 dev->tdm_slots);
739
740 mcasp_clr_bits(dev->base + DAVINCI_MCASP_RXFMCTL_REG, FSRDUR);
741 } 769 }
742} 770}
743 771
@@ -800,19 +828,27 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream,
800 case SNDRV_PCM_FORMAT_U8: 828 case SNDRV_PCM_FORMAT_U8:
801 case SNDRV_PCM_FORMAT_S8: 829 case SNDRV_PCM_FORMAT_S8:
802 dma_params->data_type = 1; 830 dma_params->data_type = 1;
803 word_length = DAVINCI_AUDIO_WORD_8; 831 word_length = 8;
804 break; 832 break;
805 833
806 case SNDRV_PCM_FORMAT_U16_LE: 834 case SNDRV_PCM_FORMAT_U16_LE:
807 case SNDRV_PCM_FORMAT_S16_LE: 835 case SNDRV_PCM_FORMAT_S16_LE:
808 dma_params->data_type = 2; 836 dma_params->data_type = 2;
809 word_length = DAVINCI_AUDIO_WORD_16; 837 word_length = 16;
838 break;
839
840 case SNDRV_PCM_FORMAT_U24_3LE:
841 case SNDRV_PCM_FORMAT_S24_3LE:
842 dma_params->data_type = 3;
843 word_length = 24;
810 break; 844 break;
811 845
846 case SNDRV_PCM_FORMAT_U24_LE:
847 case SNDRV_PCM_FORMAT_S24_LE:
812 case SNDRV_PCM_FORMAT_U32_LE: 848 case SNDRV_PCM_FORMAT_U32_LE:
813 case SNDRV_PCM_FORMAT_S32_LE: 849 case SNDRV_PCM_FORMAT_S32_LE:
814 dma_params->data_type = 4; 850 dma_params->data_type = 4;
815 word_length = DAVINCI_AUDIO_WORD_32; 851 word_length = 32;
816 break; 852 break;
817 853
818 default: 854 default:
@@ -880,13 +916,18 @@ static const struct snd_soc_dai_ops davinci_mcasp_dai_ops = {
880 .trigger = davinci_mcasp_trigger, 916 .trigger = davinci_mcasp_trigger,
881 .hw_params = davinci_mcasp_hw_params, 917 .hw_params = davinci_mcasp_hw_params,
882 .set_fmt = davinci_mcasp_set_dai_fmt, 918 .set_fmt = davinci_mcasp_set_dai_fmt,
883 919 .set_clkdiv = davinci_mcasp_set_clkdiv,
920 .set_sysclk = davinci_mcasp_set_sysclk,
884}; 921};
885 922
886#define DAVINCI_MCASP_PCM_FMTS (SNDRV_PCM_FMTBIT_S8 | \ 923#define DAVINCI_MCASP_PCM_FMTS (SNDRV_PCM_FMTBIT_S8 | \
887 SNDRV_PCM_FMTBIT_U8 | \ 924 SNDRV_PCM_FMTBIT_U8 | \
888 SNDRV_PCM_FMTBIT_S16_LE | \ 925 SNDRV_PCM_FMTBIT_S16_LE | \
889 SNDRV_PCM_FMTBIT_U16_LE | \ 926 SNDRV_PCM_FMTBIT_U16_LE | \
927 SNDRV_PCM_FMTBIT_S24_LE | \
928 SNDRV_PCM_FMTBIT_U24_LE | \
929 SNDRV_PCM_FMTBIT_S24_3LE | \
930 SNDRV_PCM_FMTBIT_U24_3LE | \
890 SNDRV_PCM_FMTBIT_S32_LE | \ 931 SNDRV_PCM_FMTBIT_S32_LE | \
891 SNDRV_PCM_FMTBIT_U32_LE) 932 SNDRV_PCM_FMTBIT_U32_LE)
892 933
@@ -1089,7 +1130,6 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
1089 dev->tdm_slots = pdata->tdm_slots; 1130 dev->tdm_slots = pdata->tdm_slots;
1090 dev->num_serializer = pdata->num_serializer; 1131 dev->num_serializer = pdata->num_serializer;
1091 dev->serial_dir = pdata->serial_dir; 1132 dev->serial_dir = pdata->serial_dir;
1092 dev->codec_fmt = pdata->codec_fmt;
1093 dev->version = pdata->version; 1133 dev->version = pdata->version;
1094 dev->txnumevt = pdata->txnumevt; 1134 dev->txnumevt = pdata->txnumevt;
1095 dev->rxnumevt = pdata->rxnumevt; 1135 dev->rxnumevt = pdata->rxnumevt;
@@ -1098,6 +1138,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
1098 dma_data = &dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK]; 1138 dma_data = &dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK];
1099 dma_data->asp_chan_q = pdata->asp_chan_q; 1139 dma_data->asp_chan_q = pdata->asp_chan_q;
1100 dma_data->ram_chan_q = pdata->ram_chan_q; 1140 dma_data->ram_chan_q = pdata->ram_chan_q;
1141 dma_data->sram_pool = pdata->sram_pool;
1101 dma_data->sram_size = pdata->sram_size_playback; 1142 dma_data->sram_size = pdata->sram_size_playback;
1102 dma_data->dma_addr = (dma_addr_t) (pdata->tx_dma_offset + 1143 dma_data->dma_addr = (dma_addr_t) (pdata->tx_dma_offset +
1103 mem->start); 1144 mem->start);
@@ -1115,6 +1156,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
1115 dma_data = &dev->dma_params[SNDRV_PCM_STREAM_CAPTURE]; 1156 dma_data = &dev->dma_params[SNDRV_PCM_STREAM_CAPTURE];
1116 dma_data->asp_chan_q = pdata->asp_chan_q; 1157 dma_data->asp_chan_q = pdata->asp_chan_q;
1117 dma_data->ram_chan_q = pdata->ram_chan_q; 1158 dma_data->ram_chan_q = pdata->ram_chan_q;
1159 dma_data->sram_pool = pdata->sram_pool;
1118 dma_data->sram_size = pdata->sram_size_capture; 1160 dma_data->sram_size = pdata->sram_size_capture;
1119 dma_data->dma_addr = (dma_addr_t)(pdata->rx_dma_offset + 1161 dma_data->dma_addr = (dma_addr_t)(pdata->rx_dma_offset +
1120 mem->start); 1162 mem->start);
diff --git a/sound/soc/davinci/davinci-mcasp.h b/sound/soc/davinci/davinci-mcasp.h
index 0de9ed6ce038..0edd3b5a37fd 100644
--- a/sound/soc/davinci/davinci-mcasp.h
+++ b/sound/soc/davinci/davinci-mcasp.h
@@ -23,26 +23,14 @@
23 23
24#include "davinci-pcm.h" 24#include "davinci-pcm.h"
25 25
26#define DAVINCI_MCASP_RATES SNDRV_PCM_RATE_8000_96000 26#define DAVINCI_MCASP_RATES SNDRV_PCM_RATE_8000_192000
27#define DAVINCI_MCASP_I2S_DAI 0 27#define DAVINCI_MCASP_I2S_DAI 0
28#define DAVINCI_MCASP_DIT_DAI 1 28#define DAVINCI_MCASP_DIT_DAI 1
29 29
30enum {
31 DAVINCI_AUDIO_WORD_8 = 0,
32 DAVINCI_AUDIO_WORD_12,
33 DAVINCI_AUDIO_WORD_16,
34 DAVINCI_AUDIO_WORD_20,
35 DAVINCI_AUDIO_WORD_24,
36 DAVINCI_AUDIO_WORD_32,
37 DAVINCI_AUDIO_WORD_28, /* This is only valid for McASP */
38};
39
40struct davinci_audio_dev { 30struct davinci_audio_dev {
41 struct davinci_pcm_dma_params dma_params[2]; 31 struct davinci_pcm_dma_params dma_params[2];
42 void __iomem *base; 32 void __iomem *base;
43 int sample_rate;
44 struct device *dev; 33 struct device *dev;
45 unsigned int codec_fmt;
46 34
47 /* McASP specific data */ 35 /* McASP specific data */
48 int tdm_slots; 36 int tdm_slots;
@@ -50,6 +38,7 @@ struct davinci_audio_dev {
50 u8 num_serializer; 38 u8 num_serializer;
51 u8 *serial_dir; 39 u8 *serial_dir;
52 u8 version; 40 u8 version;
41 u8 bclk_lrclk_ratio;
53 42
54 /* McASP FIFO related */ 43 /* McASP FIFO related */
55 u8 txnumevt; 44 u8 txnumevt;
diff --git a/sound/soc/davinci/davinci-pcm.c b/sound/soc/davinci/davinci-pcm.c
index 93ea3bf567e1..afab81f844ae 100644
--- a/sound/soc/davinci/davinci-pcm.c
+++ b/sound/soc/davinci/davinci-pcm.c
@@ -16,6 +16,7 @@
16#include <linux/slab.h> 16#include <linux/slab.h>
17#include <linux/dma-mapping.h> 17#include <linux/dma-mapping.h>
18#include <linux/kernel.h> 18#include <linux/kernel.h>
19#include <linux/genalloc.h>
19 20
20#include <sound/core.h> 21#include <sound/core.h>
21#include <sound/pcm.h> 22#include <sound/pcm.h>
@@ -23,7 +24,6 @@
23#include <sound/soc.h> 24#include <sound/soc.h>
24 25
25#include <asm/dma.h> 26#include <asm/dma.h>
26#include <mach/sram.h>
27 27
28#include "davinci-pcm.h" 28#include "davinci-pcm.h"
29 29
@@ -67,13 +67,9 @@ static struct snd_pcm_hardware pcm_hardware_playback = {
67 SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME| 67 SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME|
68 SNDRV_PCM_INFO_BATCH), 68 SNDRV_PCM_INFO_BATCH),
69 .formats = DAVINCI_PCM_FMTBITS, 69 .formats = DAVINCI_PCM_FMTBITS,
70 .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 | 70 .rates = SNDRV_PCM_RATE_8000_192000 | SNDRV_PCM_RATE_KNOT,
71 SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 |
72 SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
73 SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 |
74 SNDRV_PCM_RATE_KNOT),
75 .rate_min = 8000, 71 .rate_min = 8000,
76 .rate_max = 96000, 72 .rate_max = 192000,
77 .channels_min = 2, 73 .channels_min = 2,
78 .channels_max = 384, 74 .channels_max = 384,
79 .buffer_bytes_max = 128 * 1024, 75 .buffer_bytes_max = 128 * 1024,
@@ -90,13 +86,9 @@ static struct snd_pcm_hardware pcm_hardware_capture = {
90 SNDRV_PCM_INFO_PAUSE | 86 SNDRV_PCM_INFO_PAUSE |
91 SNDRV_PCM_INFO_BATCH), 87 SNDRV_PCM_INFO_BATCH),
92 .formats = DAVINCI_PCM_FMTBITS, 88 .formats = DAVINCI_PCM_FMTBITS,
93 .rates = (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 | 89 .rates = SNDRV_PCM_RATE_8000_192000 | SNDRV_PCM_RATE_KNOT,
94 SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_32000 |
95 SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |
96 SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 |
97 SNDRV_PCM_RATE_KNOT),
98 .rate_min = 8000, 90 .rate_min = 8000,
99 .rate_max = 96000, 91 .rate_max = 192000,
100 .channels_min = 2, 92 .channels_min = 2,
101 .channels_max = 384, 93 .channels_max = 384,
102 .buffer_bytes_max = 128 * 1024, 94 .buffer_bytes_max = 128 * 1024,
@@ -259,7 +251,9 @@ static void davinci_pcm_dma_irq(unsigned link, u16 ch_status, void *data)
259 } 251 }
260} 252}
261 253
262static int allocate_sram(struct snd_pcm_substream *substream, unsigned size, 254#ifdef CONFIG_GENERIC_ALLOCATOR
255static int allocate_sram(struct snd_pcm_substream *substream,
256 struct gen_pool *sram_pool, unsigned size,
263 struct snd_pcm_hardware *ppcm) 257 struct snd_pcm_hardware *ppcm)
264{ 258{
265 struct snd_dma_buffer *buf = &substream->dma_buffer; 259 struct snd_dma_buffer *buf = &substream->dma_buffer;
@@ -271,9 +265,10 @@ static int allocate_sram(struct snd_pcm_substream *substream, unsigned size,
271 return 0; 265 return 0;
272 266
273 ppcm->period_bytes_max = size; 267 ppcm->period_bytes_max = size;
274 iram_virt = sram_alloc(size, &iram_phys); 268 iram_virt = (void *)gen_pool_alloc(sram_pool, size);
275 if (!iram_virt) 269 if (!iram_virt)
276 goto exit1; 270 goto exit1;
271 iram_phys = gen_pool_virt_to_phys(sram_pool, (unsigned)iram_virt);
277 iram_dma = kzalloc(sizeof(*iram_dma), GFP_KERNEL); 272 iram_dma = kzalloc(sizeof(*iram_dma), GFP_KERNEL);
278 if (!iram_dma) 273 if (!iram_dma)
279 goto exit2; 274 goto exit2;
@@ -285,11 +280,33 @@ static int allocate_sram(struct snd_pcm_substream *substream, unsigned size,
285 return 0; 280 return 0;
286exit2: 281exit2:
287 if (iram_virt) 282 if (iram_virt)
288 sram_free(iram_virt, size); 283 gen_pool_free(sram_pool, (unsigned)iram_virt, size);
289exit1: 284exit1:
290 return -ENOMEM; 285 return -ENOMEM;
291} 286}
292 287
288static void davinci_free_sram(struct snd_pcm_substream *substream,
289 struct snd_dma_buffer *iram_dma)
290{
291 struct davinci_runtime_data *prtd = substream->runtime->private_data;
292 struct gen_pool *sram_pool = prtd->params->sram_pool;
293
294 gen_pool_free(sram_pool, (unsigned) iram_dma->area, iram_dma->bytes);
295}
296#else
297static int allocate_sram(struct snd_pcm_substream *substream,
298 struct gen_pool *sram_pool, unsigned size,
299 struct snd_pcm_hardware *ppcm)
300{
301 return 0;
302}
303
304static void davinci_free_sram(struct snd_pcm_substream *substream,
305 struct snd_dma_buffer *iram_dma)
306{
307}
308#endif
309
293/* 310/*
294 * Only used with ping/pong. 311 * Only used with ping/pong.
295 * This is called after runtime->dma_addr, period_bytes and data_type are valid 312 * This is called after runtime->dma_addr, period_bytes and data_type are valid
@@ -676,7 +693,7 @@ static int davinci_pcm_open(struct snd_pcm_substream *substream)
676 693
677 ppcm = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? 694 ppcm = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ?
678 &pcm_hardware_playback : &pcm_hardware_capture; 695 &pcm_hardware_playback : &pcm_hardware_capture;
679 allocate_sram(substream, params->sram_size, ppcm); 696 allocate_sram(substream, params->sram_pool, params->sram_size, ppcm);
680 snd_soc_set_runtime_hwparams(substream, ppcm); 697 snd_soc_set_runtime_hwparams(substream, ppcm);
681 /* ensure that buffer size is a multiple of period size */ 698 /* ensure that buffer size is a multiple of period size */
682 ret = snd_pcm_hw_constraint_integer(runtime, 699 ret = snd_pcm_hw_constraint_integer(runtime,
@@ -819,7 +836,7 @@ static void davinci_pcm_free(struct snd_pcm *pcm)
819 buf->area = NULL; 836 buf->area = NULL;
820 iram_dma = buf->private_data; 837 iram_dma = buf->private_data;
821 if (iram_dma) { 838 if (iram_dma) {
822 sram_free(iram_dma->area, iram_dma->bytes); 839 davinci_free_sram(substream, iram_dma);
823 kfree(iram_dma); 840 kfree(iram_dma);
824 } 841 }
825 } 842 }
diff --git a/sound/soc/davinci/davinci-pcm.h b/sound/soc/davinci/davinci-pcm.h
index fc4d01cdd8c9..b6ef7039dd09 100644
--- a/sound/soc/davinci/davinci-pcm.h
+++ b/sound/soc/davinci/davinci-pcm.h
@@ -12,6 +12,7 @@
12#ifndef _DAVINCI_PCM_H 12#ifndef _DAVINCI_PCM_H
13#define _DAVINCI_PCM_H 13#define _DAVINCI_PCM_H
14 14
15#include <linux/genalloc.h>
15#include <linux/platform_data/davinci_asp.h> 16#include <linux/platform_data/davinci_asp.h>
16#include <mach/edma.h> 17#include <mach/edma.h>
17 18
@@ -20,6 +21,7 @@ struct davinci_pcm_dma_params {
20 unsigned short acnt; 21 unsigned short acnt;
21 dma_addr_t dma_addr; /* device physical address for DMA */ 22 dma_addr_t dma_addr; /* device physical address for DMA */
22 unsigned sram_size; 23 unsigned sram_size;
24 struct gen_pool *sram_pool; /* SRAM gen_pool for ping pong */
23 enum dma_event_q asp_chan_q; /* event queue number for ASP channel */ 25 enum dma_event_q asp_chan_q; /* event queue number for ASP channel */
24 enum dma_event_q ram_chan_q; /* event queue number for RAM channel */ 26 enum dma_event_q ram_chan_q; /* event queue number for RAM channel */
25 unsigned char data_type; /* xfer data type */ 27 unsigned char data_type; /* xfer data type */
diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig
index 4563b28bd625..3b98159d9645 100644
--- a/sound/soc/fsl/Kconfig
+++ b/sound/soc/fsl/Kconfig
@@ -46,6 +46,20 @@ config SND_SOC_P1022_DS
46 This will also include the Wolfson Microelectronics WM8776 codec 46 This will also include the Wolfson Microelectronics WM8776 codec
47 driver. 47 driver.
48 48
49config SND_SOC_P1022_RDK
50 tristate "ALSA SoC support for the Freescale / iVeia P1022 RDK board"
51 # I2C is necessary for the WM8960 driver
52 depends on P1022_RDK && I2C
53 select SND_SOC_FSL_SSI
54 select SND_SOC_FSL_UTILS
55 select SND_SOC_POWERPC_DMA
56 select SND_SOC_WM8960
57 default y if P1022_RDK
58 help
59 Say Y if you want to enable audio on the Freescale / iVeia
60 P1022 RDK board. This will also include the Wolfson
61 Microelectronics WM8960 codec driver.
62
49config SND_SOC_MPC5200_I2S 63config SND_SOC_MPC5200_I2S
50 tristate "Freescale MPC5200 PSC in I2S mode driver" 64 tristate "Freescale MPC5200 PSC in I2S mode driver"
51 depends on PPC_MPC52xx && PPC_BESTCOMM 65 depends on PPC_MPC52xx && PPC_BESTCOMM
@@ -98,12 +112,12 @@ config SND_SOC_IMX_PCM
98 tristate 112 tristate
99 113
100config SND_SOC_IMX_PCM_FIQ 114config SND_SOC_IMX_PCM_FIQ
101 tristate 115 bool
102 select FIQ 116 select FIQ
103 select SND_SOC_IMX_PCM 117 select SND_SOC_IMX_PCM
104 118
105config SND_SOC_IMX_PCM_DMA 119config SND_SOC_IMX_PCM_DMA
106 tristate 120 bool
107 select SND_SOC_DMAENGINE_PCM 121 select SND_SOC_DMAENGINE_PCM
108 select SND_SOC_IMX_PCM 122 select SND_SOC_IMX_PCM
109 123
@@ -112,7 +126,7 @@ config SND_SOC_IMX_AUDMUX
112 126
113config SND_MXC_SOC_WM1133_EV1 127config SND_MXC_SOC_WM1133_EV1
114 tristate "Audio on the i.MX31ADS with WM1133-EV1 fitted" 128 tristate "Audio on the i.MX31ADS with WM1133-EV1 fitted"
115 depends on MACH_MX31ADS_WM1133_EV1 && EXPERIMENTAL 129 depends on MACH_MX31ADS_WM1133_EV1
116 select SND_SOC_WM8350 130 select SND_SOC_WM8350
117 select SND_SOC_IMX_PCM_FIQ 131 select SND_SOC_IMX_PCM_FIQ
118 select SND_SOC_IMX_AUDMUX 132 select SND_SOC_IMX_AUDMUX
diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile
index 5f3cf3f52ea0..afd34794db53 100644
--- a/sound/soc/fsl/Makefile
+++ b/sound/soc/fsl/Makefile
@@ -6,6 +6,10 @@ obj-$(CONFIG_SND_SOC_MPC8610_HPCD) += snd-soc-mpc8610-hpcd.o
6snd-soc-p1022-ds-objs := p1022_ds.o 6snd-soc-p1022-ds-objs := p1022_ds.o
7obj-$(CONFIG_SND_SOC_P1022_DS) += snd-soc-p1022-ds.o 7obj-$(CONFIG_SND_SOC_P1022_DS) += snd-soc-p1022-ds.o
8 8
9# P1022 RDK Machine Support
10snd-soc-p1022-rdk-objs := p1022_rdk.o
11obj-$(CONFIG_SND_SOC_P1022_RDK) += snd-soc-p1022-rdk.o
12
9# Freescale PowerPC SSI/DMA Platform Support 13# Freescale PowerPC SSI/DMA Platform Support
10snd-soc-fsl-ssi-objs := fsl_ssi.o 14snd-soc-fsl-ssi-objs := fsl_ssi.o
11snd-soc-fsl-utils-objs := fsl_utils.o 15snd-soc-fsl-utils-objs := fsl_utils.o
@@ -26,14 +30,18 @@ obj-$(CONFIG_SND_MPC52xx_SOC_EFIKA) += efika-audio-fabric.o
26# i.MX Platform Support 30# i.MX Platform Support
27snd-soc-imx-ssi-objs := imx-ssi.o 31snd-soc-imx-ssi-objs := imx-ssi.o
28snd-soc-imx-audmux-objs := imx-audmux.o 32snd-soc-imx-audmux-objs := imx-audmux.o
33snd-soc-imx-pcm-objs := imx-pcm.o
34ifneq ($(CONFIG_SND_SOC_IMX_PCM_FIQ),)
35 snd-soc-imx-pcm-objs += imx-pcm-fiq.o
36endif
37ifneq ($(CONFIG_SND_SOC_IMX_PCM_DMA),)
38 snd-soc-imx-pcm-objs += imx-pcm-dma.o
39endif
29 40
30obj-$(CONFIG_SND_SOC_IMX_SSI) += snd-soc-imx-ssi.o 41obj-$(CONFIG_SND_SOC_IMX_SSI) += snd-soc-imx-ssi.o
31obj-$(CONFIG_SND_SOC_IMX_AUDMUX) += snd-soc-imx-audmux.o 42obj-$(CONFIG_SND_SOC_IMX_AUDMUX) += snd-soc-imx-audmux.o
32 43
33obj-$(CONFIG_SND_SOC_IMX_PCM) += snd-soc-imx-pcm.o 44obj-$(CONFIG_SND_SOC_IMX_PCM) += snd-soc-imx-pcm.o
34snd-soc-imx-pcm-y := imx-pcm.o
35snd-soc-imx-pcm-$(CONFIG_SND_SOC_IMX_PCM_FIQ) += imx-pcm-fiq.o
36snd-soc-imx-pcm-$(CONFIG_SND_SOC_IMX_PCM_DMA) += imx-pcm-dma.o
37 45
38# i.MX Machine Support 46# i.MX Machine Support
39snd-soc-eukrea-tlv320-objs := eukrea-tlv320.o 47snd-soc-eukrea-tlv320-objs := eukrea-tlv320.o
diff --git a/sound/soc/fsl/imx-pcm.c b/sound/soc/fsl/imx-pcm.c
index 93dc360b1777..d5cd9eff3b48 100644
--- a/sound/soc/fsl/imx-pcm.c
+++ b/sound/soc/fsl/imx-pcm.c
@@ -103,3 +103,7 @@ void imx_pcm_free(struct snd_pcm *pcm)
103 } 103 }
104} 104}
105EXPORT_SYMBOL_GPL(imx_pcm_free); 105EXPORT_SYMBOL_GPL(imx_pcm_free);
106
107MODULE_DESCRIPTION("Freescale i.MX PCM driver");
108MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
109MODULE_LICENSE("GPL");
diff --git a/sound/soc/fsl/imx-sgtl5000.c b/sound/soc/fsl/imx-sgtl5000.c
index 199408ec4261..3d9b1c427ce9 100644
--- a/sound/soc/fsl/imx-sgtl5000.c
+++ b/sound/soc/fsl/imx-sgtl5000.c
@@ -162,6 +162,7 @@ static int __devinit imx_sgtl5000_probe(struct platform_device *pdev)
162 if (ret) 162 if (ret)
163 goto clk_fail; 163 goto clk_fail;
164 data->card.num_links = 1; 164 data->card.num_links = 1;
165 data->card.owner = THIS_MODULE;
165 data->card.dai_link = &data->dai; 166 data->card.dai_link = &data->dai;
166 data->card.dapm_widgets = imx_sgtl5000_dapm_widgets; 167 data->card.dapm_widgets = imx_sgtl5000_dapm_widgets;
167 data->card.num_dapm_widgets = ARRAY_SIZE(imx_sgtl5000_dapm_widgets); 168 data->card.num_dapm_widgets = ARRAY_SIZE(imx_sgtl5000_dapm_widgets);
diff --git a/sound/soc/fsl/p1022_rdk.c b/sound/soc/fsl/p1022_rdk.c
new file mode 100644
index 000000000000..897e32ffdc42
--- /dev/null
+++ b/sound/soc/fsl/p1022_rdk.c
@@ -0,0 +1,392 @@
1/**
2 * Freescale P1022RDK ALSA SoC Machine driver
3 *
4 * Author: Timur Tabi <timur@freescale.com>
5 *
6 * Copyright 2012 Freescale Semiconductor, Inc.
7 *
8 * This file is licensed under the terms of the GNU General Public License
9 * version 2. This program is licensed "as is" without any warranty of any
10 * kind, whether express or implied.
11 *
12 * Note: in order for audio to work correctly, the output controls need
13 * to be enabled, because they control the clock. So for playback, for
14 * example:
15 *
16 * amixer sset 'Left Output Mixer PCM' on
17 * amixer sset 'Right Output Mixer PCM' on
18 */
19
20#include <linux/module.h>
21#include <linux/interrupt.h>
22#include <linux/of_device.h>
23#include <linux/slab.h>
24#include <sound/soc.h>
25#include <asm/fsl_guts.h>
26
27#include "fsl_dma.h"
28#include "fsl_ssi.h"
29#include "fsl_utils.h"
30
31/* P1022-specific PMUXCR and DMUXCR bit definitions */
32
33#define CCSR_GUTS_PMUXCR_UART0_I2C1_MASK 0x0001c000
34#define CCSR_GUTS_PMUXCR_UART0_I2C1_UART0_SSI 0x00010000
35#define CCSR_GUTS_PMUXCR_UART0_I2C1_SSI 0x00018000
36
37#define CCSR_GUTS_PMUXCR_SSI_DMA_TDM_MASK 0x00000c00
38#define CCSR_GUTS_PMUXCR_SSI_DMA_TDM_SSI 0x00000000
39
40#define CCSR_GUTS_DMUXCR_PAD 1 /* DMA controller/channel set to pad */
41#define CCSR_GUTS_DMUXCR_SSI 2 /* DMA controller/channel set to SSI */
42
43/*
44 * Set the DMACR register in the GUTS
45 *
46 * The DMACR register determines the source of initiated transfers for each
47 * channel on each DMA controller. Rather than have a bunch of repetitive
48 * macros for the bit patterns, we just have a function that calculates
49 * them.
50 *
51 * guts: Pointer to GUTS structure
52 * co: The DMA controller (0 or 1)
53 * ch: The channel on the DMA controller (0, 1, 2, or 3)
54 * device: The device to set as the target (CCSR_GUTS_DMUXCR_xxx)
55 */
56static inline void guts_set_dmuxcr(struct ccsr_guts __iomem *guts,
57 unsigned int co, unsigned int ch, unsigned int device)
58{
59 unsigned int shift = 16 + (8 * (1 - co) + 2 * (3 - ch));
60
61 clrsetbits_be32(&guts->dmuxcr, 3 << shift, device << shift);
62}
63
64/* There's only one global utilities register */
65static phys_addr_t guts_phys;
66
67/**
68 * machine_data: machine-specific ASoC device data
69 *
70 * This structure contains data for a single sound platform device on an
71 * P1022 RDK. Some of the data is taken from the device tree.
72 */
73struct machine_data {
74 struct snd_soc_dai_link dai[2];
75 struct snd_soc_card card;
76 unsigned int dai_format;
77 unsigned int codec_clk_direction;
78 unsigned int cpu_clk_direction;
79 unsigned int clk_frequency;
80 unsigned int dma_id[2]; /* 0 = DMA1, 1 = DMA2, etc */
81 unsigned int dma_channel_id[2]; /* 0 = ch 0, 1 = ch 1, etc*/
82 char platform_name[2][DAI_NAME_SIZE]; /* One for each DMA channel */
83};
84
85/**
86 * p1022_rdk_machine_probe: initialize the board
87 *
88 * This function is used to initialize the board-specific hardware.
89 *
90 * Here we program the DMACR and PMUXCR registers.
91 */
92static int p1022_rdk_machine_probe(struct snd_soc_card *card)
93{
94 struct machine_data *mdata =
95 container_of(card, struct machine_data, card);
96 struct ccsr_guts __iomem *guts;
97
98 guts = ioremap(guts_phys, sizeof(struct ccsr_guts));
99 if (!guts) {
100 dev_err(card->dev, "could not map global utilities\n");
101 return -ENOMEM;
102 }
103
104 /* Enable SSI Tx signal */
105 clrsetbits_be32(&guts->pmuxcr, CCSR_GUTS_PMUXCR_UART0_I2C1_MASK,
106 CCSR_GUTS_PMUXCR_UART0_I2C1_UART0_SSI);
107
108 /* Enable SSI Rx signal */
109 clrsetbits_be32(&guts->pmuxcr, CCSR_GUTS_PMUXCR_SSI_DMA_TDM_MASK,
110 CCSR_GUTS_PMUXCR_SSI_DMA_TDM_SSI);
111
112 /* Enable DMA Channel for SSI */
113 guts_set_dmuxcr(guts, mdata->dma_id[0], mdata->dma_channel_id[0],
114 CCSR_GUTS_DMUXCR_SSI);
115
116 guts_set_dmuxcr(guts, mdata->dma_id[1], mdata->dma_channel_id[1],
117 CCSR_GUTS_DMUXCR_SSI);
118
119 iounmap(guts);
120
121 return 0;
122}
123
124/**
125 * p1022_rdk_startup: program the board with various hardware parameters
126 *
127 * This function takes board-specific information, like clock frequencies
128 * and serial data formats, and passes that information to the codec and
129 * transport drivers.
130 */
131static int p1022_rdk_startup(struct snd_pcm_substream *substream)
132{
133 struct snd_soc_pcm_runtime *rtd = substream->private_data;
134 struct machine_data *mdata =
135 container_of(rtd->card, struct machine_data, card);
136 struct device *dev = rtd->card->dev;
137 int ret = 0;
138
139 /* Tell the codec driver what the serial protocol is. */
140 ret = snd_soc_dai_set_fmt(rtd->codec_dai, mdata->dai_format);
141 if (ret < 0) {
142 dev_err(dev, "could not set codec driver audio format (ret=%i)\n",
143 ret);
144 return ret;
145 }
146
147 ret = snd_soc_dai_set_pll(rtd->codec_dai, 0, 0, mdata->clk_frequency,
148 mdata->clk_frequency);
149 if (ret < 0) {
150 dev_err(dev, "could not set codec PLL frequency (ret=%i)\n",
151 ret);
152 return ret;
153 }
154
155 return 0;
156}
157
158/**
159 * p1022_rdk_machine_remove: Remove the sound device
160 *
161 * This function is called to remove the sound device for one SSI. We
162 * de-program the DMACR and PMUXCR register.
163 */
164static int p1022_rdk_machine_remove(struct snd_soc_card *card)
165{
166 struct machine_data *mdata =
167 container_of(card, struct machine_data, card);
168 struct ccsr_guts __iomem *guts;
169
170 guts = ioremap(guts_phys, sizeof(struct ccsr_guts));
171 if (!guts) {
172 dev_err(card->dev, "could not map global utilities\n");
173 return -ENOMEM;
174 }
175
176 /* Restore the signal routing */
177 clrbits32(&guts->pmuxcr, CCSR_GUTS_PMUXCR_UART0_I2C1_MASK);
178 clrbits32(&guts->pmuxcr, CCSR_GUTS_PMUXCR_SSI_DMA_TDM_MASK);
179 guts_set_dmuxcr(guts, mdata->dma_id[0], mdata->dma_channel_id[0], 0);
180 guts_set_dmuxcr(guts, mdata->dma_id[1], mdata->dma_channel_id[1], 0);
181
182 iounmap(guts);
183
184 return 0;
185}
186
187/**
188 * p1022_rdk_ops: ASoC machine driver operations
189 */
190static struct snd_soc_ops p1022_rdk_ops = {
191 .startup = p1022_rdk_startup,
192};
193
194/**
195 * p1022_rdk_probe: platform probe function for the machine driver
196 *
197 * Although this is a machine driver, the SSI node is the "master" node with
198 * respect to audio hardware connections. Therefore, we create a new ASoC
199 * device for each new SSI node that has a codec attached.
200 */
201static int p1022_rdk_probe(struct platform_device *pdev)
202{
203 struct device *dev = pdev->dev.parent;
204 /* ssi_pdev is the platform device for the SSI node that probed us */
205 struct platform_device *ssi_pdev =
206 container_of(dev, struct platform_device, dev);
207 struct device_node *np = ssi_pdev->dev.of_node;
208 struct device_node *codec_np = NULL;
209 struct machine_data *mdata;
210 const u32 *iprop;
211 int ret;
212
213 /* Find the codec node for this SSI. */
214 codec_np = of_parse_phandle(np, "codec-handle", 0);
215 if (!codec_np) {
216 dev_err(dev, "could not find codec node\n");
217 return -EINVAL;
218 }
219
220 mdata = kzalloc(sizeof(struct machine_data), GFP_KERNEL);
221 if (!mdata) {
222 ret = -ENOMEM;
223 goto error_put;
224 }
225
226 mdata->dai[0].cpu_dai_name = dev_name(&ssi_pdev->dev);
227 mdata->dai[0].ops = &p1022_rdk_ops;
228
229 /* ASoC core can match codec with device node */
230 mdata->dai[0].codec_of_node = codec_np;
231
232 /*
233 * We register two DAIs per SSI, one for playback and the other for
234 * capture. We support codecs that have separate DAIs for both playback
235 * and capture.
236 */
237 memcpy(&mdata->dai[1], &mdata->dai[0], sizeof(struct snd_soc_dai_link));
238
239 /* The DAI names from the codec (snd_soc_dai_driver.name) */
240 mdata->dai[0].codec_dai_name = "wm8960-hifi";
241 mdata->dai[1].codec_dai_name = mdata->dai[0].codec_dai_name;
242
243 /*
244 * Configure the SSI for I2S slave mode. Older device trees have
245 * an fsl,mode property, but we ignore that since there's really
246 * only one way to configure the SSI.
247 */
248 mdata->dai_format = SND_SOC_DAIFMT_NB_NF |
249 SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBM_CFM;
250 mdata->codec_clk_direction = SND_SOC_CLOCK_OUT;
251 mdata->cpu_clk_direction = SND_SOC_CLOCK_IN;
252
253 /*
254 * In i2s-slave mode, the codec has its own clock source, so we
255 * need to get the frequency from the device tree and pass it to
256 * the codec driver.
257 */
258 iprop = of_get_property(codec_np, "clock-frequency", NULL);
259 if (!iprop || !*iprop) {
260 dev_err(&pdev->dev, "codec bus-frequency property is missing or invalid\n");
261 ret = -EINVAL;
262 goto error;
263 }
264 mdata->clk_frequency = be32_to_cpup(iprop);
265
266 if (!mdata->clk_frequency) {
267 dev_err(&pdev->dev, "unknown clock frequency\n");
268 ret = -EINVAL;
269 goto error;
270 }
271
272 /* Find the playback DMA channel to use. */
273 mdata->dai[0].platform_name = mdata->platform_name[0];
274 ret = fsl_asoc_get_dma_channel(np, "fsl,playback-dma", &mdata->dai[0],
275 &mdata->dma_channel_id[0],
276 &mdata->dma_id[0]);
277 if (ret) {
278 dev_err(&pdev->dev, "missing/invalid playback DMA phandle (ret=%i)\n",
279 ret);
280 goto error;
281 }
282
283 /* Find the capture DMA channel to use. */
284 mdata->dai[1].platform_name = mdata->platform_name[1];
285 ret = fsl_asoc_get_dma_channel(np, "fsl,capture-dma", &mdata->dai[1],
286 &mdata->dma_channel_id[1],
287 &mdata->dma_id[1]);
288 if (ret) {
289 dev_err(&pdev->dev, "missing/invalid capture DMA phandle (ret=%i)\n",
290 ret);
291 goto error;
292 }
293
294 /* Initialize our DAI data structure. */
295 mdata->dai[0].stream_name = "playback";
296 mdata->dai[1].stream_name = "capture";
297 mdata->dai[0].name = mdata->dai[0].stream_name;
298 mdata->dai[1].name = mdata->dai[1].stream_name;
299
300 mdata->card.probe = p1022_rdk_machine_probe;
301 mdata->card.remove = p1022_rdk_machine_remove;
302 mdata->card.name = pdev->name; /* The platform driver name */
303 mdata->card.owner = THIS_MODULE;
304 mdata->card.dev = &pdev->dev;
305 mdata->card.num_links = 2;
306 mdata->card.dai_link = mdata->dai;
307
308 /* Register with ASoC */
309 ret = snd_soc_register_card(&mdata->card);
310 if (ret) {
311 dev_err(&pdev->dev, "could not register card (ret=%i)\n", ret);
312 goto error;
313 }
314
315 return 0;
316
317error:
318 kfree(mdata);
319error_put:
320 of_node_put(codec_np);
321 return ret;
322}
323
324/**
325 * p1022_rdk_remove: remove the platform device
326 *
327 * This function is called when the platform device is removed.
328 */
329static int __devexit p1022_rdk_remove(struct platform_device *pdev)
330{
331 struct snd_soc_card *card = platform_get_drvdata(pdev);
332 struct machine_data *mdata =
333 container_of(card, struct machine_data, card);
334
335 snd_soc_unregister_card(card);
336 kfree(mdata);
337
338 return 0;
339}
340
341static struct platform_driver p1022_rdk_driver = {
342 .probe = p1022_rdk_probe,
343 .remove = __devexit_p(p1022_rdk_remove),
344 .driver = {
345 /*
346 * The name must match 'compatible' property in the device tree,
347 * in lowercase letters.
348 */
349 .name = "snd-soc-p1022rdk",
350 .owner = THIS_MODULE,
351 },
352};
353
354/**
355 * p1022_rdk_init: machine driver initialization.
356 *
357 * This function is called when this module is loaded.
358 */
359static int __init p1022_rdk_init(void)
360{
361 struct device_node *guts_np;
362 struct resource res;
363
364 /* Get the physical address of the global utilities registers */
365 guts_np = of_find_compatible_node(NULL, NULL, "fsl,p1022-guts");
366 if (of_address_to_resource(guts_np, 0, &res)) {
367 pr_err("snd-soc-p1022rdk: missing/invalid global utils node\n");
368 of_node_put(guts_np);
369 return -EINVAL;
370 }
371 guts_phys = res.start;
372 of_node_put(guts_np);
373
374 return platform_driver_register(&p1022_rdk_driver);
375}
376
377/**
378 * p1022_rdk_exit: machine driver exit
379 *
380 * This function is called when this driver is unloaded.
381 */
382static void __exit p1022_rdk_exit(void)
383{
384 platform_driver_unregister(&p1022_rdk_driver);
385}
386
387late_initcall(p1022_rdk_init);
388module_exit(p1022_rdk_exit);
389
390MODULE_AUTHOR("Timur Tabi <timur@freescale.com>");
391MODULE_DESCRIPTION("Freescale / iVeia P1022 RDK ALSA SoC machine driver");
392MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/fsl/pcm030-audio-fabric.c b/sound/soc/fsl/pcm030-audio-fabric.c
index 4b63ec8eb372..4d261927662f 100644
--- a/sound/soc/fsl/pcm030-audio-fabric.c
+++ b/sound/soc/fsl/pcm030-audio-fabric.c
@@ -29,14 +29,14 @@ struct pcm030_audio_data {
29 29
30static struct snd_soc_dai_link pcm030_fabric_dai[] = { 30static struct snd_soc_dai_link pcm030_fabric_dai[] = {
31{ 31{
32 .name = "AC97", 32 .name = "AC97.0",
33 .stream_name = "AC97 Analog", 33 .stream_name = "AC97 Analog",
34 .codec_dai_name = "wm9712-hifi", 34 .codec_dai_name = "wm9712-hifi",
35 .cpu_dai_name = "mpc5200-psc-ac97.0", 35 .cpu_dai_name = "mpc5200-psc-ac97.0",
36 .codec_name = "wm9712-codec", 36 .codec_name = "wm9712-codec",
37}, 37},
38{ 38{
39 .name = "AC97", 39 .name = "AC97.1",
40 .stream_name = "AC97 IEC958", 40 .stream_name = "AC97 IEC958",
41 .codec_dai_name = "wm9712-aux", 41 .codec_dai_name = "wm9712-aux",
42 .cpu_dai_name = "mpc5200-psc-ac97.1", 42 .cpu_dai_name = "mpc5200-psc-ac97.1",
diff --git a/sound/soc/kirkwood/kirkwood-dma.c b/sound/soc/kirkwood/kirkwood-dma.c
index b9f16598324c..58d5a96b366f 100644
--- a/sound/soc/kirkwood/kirkwood-dma.c
+++ b/sound/soc/kirkwood/kirkwood-dma.c
@@ -22,12 +22,16 @@
22#include "kirkwood.h" 22#include "kirkwood.h"
23 23
24#define KIRKWOOD_RATES \ 24#define KIRKWOOD_RATES \
25 (SNDRV_PCM_RATE_44100 | \ 25 (SNDRV_PCM_RATE_8000_192000 | \
26 SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000) 26 SNDRV_PCM_RATE_CONTINUOUS | \
27 SNDRV_PCM_RATE_KNOT)
28
27#define KIRKWOOD_FORMATS \ 29#define KIRKWOOD_FORMATS \
28 (SNDRV_PCM_FMTBIT_S16_LE | \ 30 (SNDRV_PCM_FMTBIT_S16_LE | \
29 SNDRV_PCM_FMTBIT_S24_LE | \ 31 SNDRV_PCM_FMTBIT_S24_LE | \
30 SNDRV_PCM_FMTBIT_S32_LE) 32 SNDRV_PCM_FMTBIT_S32_LE | \
33 SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE | \
34 SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE)
31 35
32struct kirkwood_dma_priv { 36struct kirkwood_dma_priv {
33 struct snd_pcm_substream *play_stream; 37 struct snd_pcm_substream *play_stream;
@@ -43,10 +47,10 @@ static struct snd_pcm_hardware kirkwood_dma_snd_hw = {
43 SNDRV_PCM_INFO_PAUSE), 47 SNDRV_PCM_INFO_PAUSE),
44 .formats = KIRKWOOD_FORMATS, 48 .formats = KIRKWOOD_FORMATS,
45 .rates = KIRKWOOD_RATES, 49 .rates = KIRKWOOD_RATES,
46 .rate_min = 44100, 50 .rate_min = 8000,
47 .rate_max = 96000, 51 .rate_max = 384000,
48 .channels_min = 1, 52 .channels_min = 1,
49 .channels_max = 2, 53 .channels_max = 8,
50 .buffer_bytes_max = KIRKWOOD_SND_MAX_PERIOD_BYTES * KIRKWOOD_SND_MAX_PERIODS, 54 .buffer_bytes_max = KIRKWOOD_SND_MAX_PERIOD_BYTES * KIRKWOOD_SND_MAX_PERIODS,
51 .period_bytes_min = KIRKWOOD_SND_MIN_PERIOD_BYTES, 55 .period_bytes_min = KIRKWOOD_SND_MIN_PERIOD_BYTES,
52 .period_bytes_max = KIRKWOOD_SND_MAX_PERIOD_BYTES, 56 .period_bytes_max = KIRKWOOD_SND_MAX_PERIOD_BYTES,
@@ -71,7 +75,6 @@ static irqreturn_t kirkwood_dma_irq(int irq, void *dev_id)
71 printk(KERN_WARNING "%s: got err interrupt 0x%lx\n", 75 printk(KERN_WARNING "%s: got err interrupt 0x%lx\n",
72 __func__, cause); 76 __func__, cause);
73 writel(cause, priv->io + KIRKWOOD_ERR_CAUSE); 77 writel(cause, priv->io + KIRKWOOD_ERR_CAUSE);
74 return IRQ_HANDLED;
75 } 78 }
76 79
77 /* we've enabled only bytes interrupts ... */ 80 /* we've enabled only bytes interrupts ... */
@@ -178,7 +181,7 @@ static int kirkwood_dma_open(struct snd_pcm_substream *substream)
178 } 181 }
179 182
180 dram = mv_mbus_dram_info(); 183 dram = mv_mbus_dram_info();
181 addr = virt_to_phys(substream->dma_buffer.area); 184 addr = substream->dma_buffer.addr;
182 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 185 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
183 prdata->play_stream = substream; 186 prdata->play_stream = substream;
184 kirkwood_dma_conf_mbus_windows(priv->io, 187 kirkwood_dma_conf_mbus_windows(priv->io,
diff --git a/sound/soc/kirkwood/kirkwood-i2s.c b/sound/soc/kirkwood/kirkwood-i2s.c
index 542538d10ab7..d3629d5927e9 100644
--- a/sound/soc/kirkwood/kirkwood-i2s.c
+++ b/sound/soc/kirkwood/kirkwood-i2s.c
@@ -95,10 +95,33 @@ static inline void kirkwood_set_dco(void __iomem *io, unsigned long rate)
95 do { 95 do {
96 cpu_relax(); 96 cpu_relax();
97 value = readl(io + KIRKWOOD_DCO_SPCR_STATUS); 97 value = readl(io + KIRKWOOD_DCO_SPCR_STATUS);
98 value &= KIRKWOOD_DCO_SPCR_STATUS; 98 value &= KIRKWOOD_DCO_SPCR_STATUS_DCO_LOCK;
99 } while (value == 0); 99 } while (value == 0);
100} 100}
101 101
102static void kirkwood_set_rate(struct snd_soc_dai *dai,
103 struct kirkwood_dma_data *priv, unsigned long rate)
104{
105 uint32_t clks_ctrl;
106
107 if (rate == 44100 || rate == 48000 || rate == 96000) {
108 /* use internal dco for supported rates */
109 dev_dbg(dai->dev, "%s: dco set rate = %lu\n",
110 __func__, rate);
111 kirkwood_set_dco(priv->io, rate);
112
113 clks_ctrl = KIRKWOOD_MCLK_SOURCE_DCO;
114 } else if (!IS_ERR(priv->extclk)) {
115 /* use optional external clk for other rates */
116 dev_dbg(dai->dev, "%s: extclk set rate = %lu -> %lu\n",
117 __func__, rate, 256 * rate);
118 clk_set_rate(priv->extclk, 256 * rate);
119
120 clks_ctrl = KIRKWOOD_MCLK_SOURCE_EXTCLK;
121 }
122 writel(clks_ctrl, priv->io + KIRKWOOD_CLOCKS_CTRL);
123}
124
102static int kirkwood_i2s_startup(struct snd_pcm_substream *substream, 125static int kirkwood_i2s_startup(struct snd_pcm_substream *substream,
103 struct snd_soc_dai *dai) 126 struct snd_soc_dai *dai)
104{ 127{
@@ -113,26 +136,21 @@ static int kirkwood_i2s_hw_params(struct snd_pcm_substream *substream,
113 struct snd_soc_dai *dai) 136 struct snd_soc_dai *dai)
114{ 137{
115 struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(dai); 138 struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(dai);
116 unsigned int i2s_reg, reg; 139 uint32_t ctl_play, ctl_rec;
117 unsigned long i2s_value, value; 140 unsigned int i2s_reg;
141 unsigned long i2s_value;
118 142
119 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 143 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
120 i2s_reg = KIRKWOOD_I2S_PLAYCTL; 144 i2s_reg = KIRKWOOD_I2S_PLAYCTL;
121 reg = KIRKWOOD_PLAYCTL;
122 } else { 145 } else {
123 i2s_reg = KIRKWOOD_I2S_RECCTL; 146 i2s_reg = KIRKWOOD_I2S_RECCTL;
124 reg = KIRKWOOD_RECCTL;
125 } 147 }
126 148
127 /* set dco conf */ 149 kirkwood_set_rate(dai, priv, params_rate(params));
128 kirkwood_set_dco(priv->io, params_rate(params));
129 150
130 i2s_value = readl(priv->io+i2s_reg); 151 i2s_value = readl(priv->io+i2s_reg);
131 i2s_value &= ~KIRKWOOD_I2S_CTL_SIZE_MASK; 152 i2s_value &= ~KIRKWOOD_I2S_CTL_SIZE_MASK;
132 153
133 value = readl(priv->io+reg);
134 value &= ~KIRKWOOD_PLAYCTL_SIZE_MASK;
135
136 /* 154 /*
137 * Size settings in play/rec i2s control regs and play/rec control 155 * Size settings in play/rec i2s control regs and play/rec control
138 * regs must be the same. 156 * regs must be the same.
@@ -140,38 +158,57 @@ static int kirkwood_i2s_hw_params(struct snd_pcm_substream *substream,
140 switch (params_format(params)) { 158 switch (params_format(params)) {
141 case SNDRV_PCM_FORMAT_S16_LE: 159 case SNDRV_PCM_FORMAT_S16_LE:
142 i2s_value |= KIRKWOOD_I2S_CTL_SIZE_16; 160 i2s_value |= KIRKWOOD_I2S_CTL_SIZE_16;
143 value |= KIRKWOOD_PLAYCTL_SIZE_16_C; 161 ctl_play = KIRKWOOD_PLAYCTL_SIZE_16_C |
162 KIRKWOOD_PLAYCTL_I2S_EN;
163 ctl_rec = KIRKWOOD_RECCTL_SIZE_16_C |
164 KIRKWOOD_RECCTL_I2S_EN;
144 break; 165 break;
145 /* 166 /*
146 * doesn't work... S20_3LE != kirkwood 20bit format ? 167 * doesn't work... S20_3LE != kirkwood 20bit format ?
147 * 168 *
148 case SNDRV_PCM_FORMAT_S20_3LE: 169 case SNDRV_PCM_FORMAT_S20_3LE:
149 i2s_value |= KIRKWOOD_I2S_CTL_SIZE_20; 170 i2s_value |= KIRKWOOD_I2S_CTL_SIZE_20;
150 value |= KIRKWOOD_PLAYCTL_SIZE_20; 171 ctl_play = KIRKWOOD_PLAYCTL_SIZE_20 |
172 KIRKWOOD_PLAYCTL_I2S_EN;
173 ctl_rec = KIRKWOOD_RECCTL_SIZE_20 |
174 KIRKWOOD_RECCTL_I2S_EN;
151 break; 175 break;
152 */ 176 */
153 case SNDRV_PCM_FORMAT_S24_LE: 177 case SNDRV_PCM_FORMAT_S24_LE:
154 i2s_value |= KIRKWOOD_I2S_CTL_SIZE_24; 178 i2s_value |= KIRKWOOD_I2S_CTL_SIZE_24;
155 value |= KIRKWOOD_PLAYCTL_SIZE_24; 179 ctl_play = KIRKWOOD_PLAYCTL_SIZE_24 |
180 KIRKWOOD_PLAYCTL_I2S_EN;
181 ctl_rec = KIRKWOOD_RECCTL_SIZE_24 |
182 KIRKWOOD_RECCTL_I2S_EN;
156 break; 183 break;
157 case SNDRV_PCM_FORMAT_S32_LE: 184 case SNDRV_PCM_FORMAT_S32_LE:
158 i2s_value |= KIRKWOOD_I2S_CTL_SIZE_32; 185 i2s_value |= KIRKWOOD_I2S_CTL_SIZE_32;
159 value |= KIRKWOOD_PLAYCTL_SIZE_32; 186 ctl_play = KIRKWOOD_PLAYCTL_SIZE_32 |
187 KIRKWOOD_PLAYCTL_I2S_EN;
188 ctl_rec = KIRKWOOD_RECCTL_SIZE_32 |
189 KIRKWOOD_RECCTL_I2S_EN;
160 break; 190 break;
161 default: 191 default:
162 return -EINVAL; 192 return -EINVAL;
163 } 193 }
164 194
165 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 195 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
166 value &= ~KIRKWOOD_PLAYCTL_MONO_MASK;
167 if (params_channels(params) == 1) 196 if (params_channels(params) == 1)
168 value |= KIRKWOOD_PLAYCTL_MONO_BOTH; 197 ctl_play |= KIRKWOOD_PLAYCTL_MONO_BOTH;
169 else 198 else
170 value |= KIRKWOOD_PLAYCTL_MONO_OFF; 199 ctl_play |= KIRKWOOD_PLAYCTL_MONO_OFF;
200
201 priv->ctl_play &= ~(KIRKWOOD_PLAYCTL_MONO_MASK |
202 KIRKWOOD_PLAYCTL_I2S_EN |
203 KIRKWOOD_PLAYCTL_SPDIF_EN |
204 KIRKWOOD_PLAYCTL_SIZE_MASK);
205 priv->ctl_play |= ctl_play;
206 } else {
207 priv->ctl_rec &= ~KIRKWOOD_RECCTL_SIZE_MASK;
208 priv->ctl_rec |= ctl_rec;
171 } 209 }
172 210
173 writel(i2s_value, priv->io+i2s_reg); 211 writel(i2s_value, priv->io+i2s_reg);
174 writel(value, priv->io+reg);
175 212
176 return 0; 213 return 0;
177} 214}
@@ -180,67 +217,70 @@ static int kirkwood_i2s_play_trigger(struct snd_pcm_substream *substream,
180 int cmd, struct snd_soc_dai *dai) 217 int cmd, struct snd_soc_dai *dai)
181{ 218{
182 struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(dai); 219 struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(dai);
183 unsigned long value; 220 uint32_t ctl, value;
184 221
185 /* 222 ctl = readl(priv->io + KIRKWOOD_PLAYCTL);
186 * specs says KIRKWOOD_PLAYCTL must be read 2 times before 223 if (ctl & KIRKWOOD_PLAYCTL_PAUSE) {
187 * changing it. So read 1 time here and 1 later. 224 unsigned timeout = 5000;
188 */ 225 /*
189 value = readl(priv->io + KIRKWOOD_PLAYCTL); 226 * The Armada510 spec says that if we enter pause mode, the
227 * busy bit must be read back as clear _twice_. Make sure
228 * we respect that otherwise we get DMA underruns.
229 */
230 do {
231 value = ctl;
232 ctl = readl(priv->io + KIRKWOOD_PLAYCTL);
233 if (!((ctl | value) & KIRKWOOD_PLAYCTL_PLAY_BUSY))
234 break;
235 udelay(1);
236 } while (timeout--);
237
238 if ((ctl | value) & KIRKWOOD_PLAYCTL_PLAY_BUSY)
239 dev_notice(dai->dev, "timed out waiting for busy to deassert: %08x\n",
240 ctl);
241 }
190 242
191 switch (cmd) { 243 switch (cmd) {
192 case SNDRV_PCM_TRIGGER_START: 244 case SNDRV_PCM_TRIGGER_START:
193 /* stop audio, enable interrupts */ 245 /* configure */
194 value = readl(priv->io + KIRKWOOD_PLAYCTL); 246 ctl = priv->ctl_play;
195 value |= KIRKWOOD_PLAYCTL_PAUSE; 247 value = ctl & ~(KIRKWOOD_PLAYCTL_I2S_EN |
248 KIRKWOOD_PLAYCTL_SPDIF_EN);
196 writel(value, priv->io + KIRKWOOD_PLAYCTL); 249 writel(value, priv->io + KIRKWOOD_PLAYCTL);
197 250
251 /* enable interrupts */
198 value = readl(priv->io + KIRKWOOD_INT_MASK); 252 value = readl(priv->io + KIRKWOOD_INT_MASK);
199 value |= KIRKWOOD_INT_CAUSE_PLAY_BYTES; 253 value |= KIRKWOOD_INT_CAUSE_PLAY_BYTES;
200 writel(value, priv->io + KIRKWOOD_INT_MASK); 254 writel(value, priv->io + KIRKWOOD_INT_MASK);
201 255
202 /* configure audio & enable i2s playback */ 256 /* enable playback */
203 value = readl(priv->io + KIRKWOOD_PLAYCTL); 257 writel(ctl, priv->io + KIRKWOOD_PLAYCTL);
204 value &= ~KIRKWOOD_PLAYCTL_BURST_MASK;
205 value &= ~(KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE
206 | KIRKWOOD_PLAYCTL_SPDIF_EN);
207
208 if (priv->burst == 32)
209 value |= KIRKWOOD_PLAYCTL_BURST_32;
210 else
211 value |= KIRKWOOD_PLAYCTL_BURST_128;
212 value |= KIRKWOOD_PLAYCTL_I2S_EN;
213 writel(value, priv->io + KIRKWOOD_PLAYCTL);
214 break; 258 break;
215 259
216 case SNDRV_PCM_TRIGGER_STOP: 260 case SNDRV_PCM_TRIGGER_STOP:
217 /* stop audio, disable interrupts */ 261 /* stop audio, disable interrupts */
218 value = readl(priv->io + KIRKWOOD_PLAYCTL); 262 ctl |= KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE;
219 value |= KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE; 263 writel(ctl, priv->io + KIRKWOOD_PLAYCTL);
220 writel(value, priv->io + KIRKWOOD_PLAYCTL);
221 264
222 value = readl(priv->io + KIRKWOOD_INT_MASK); 265 value = readl(priv->io + KIRKWOOD_INT_MASK);
223 value &= ~KIRKWOOD_INT_CAUSE_PLAY_BYTES; 266 value &= ~KIRKWOOD_INT_CAUSE_PLAY_BYTES;
224 writel(value, priv->io + KIRKWOOD_INT_MASK); 267 writel(value, priv->io + KIRKWOOD_INT_MASK);
225 268
226 /* disable all playbacks */ 269 /* disable all playbacks */
227 value = readl(priv->io + KIRKWOOD_PLAYCTL); 270 ctl &= ~(KIRKWOOD_PLAYCTL_I2S_EN | KIRKWOOD_PLAYCTL_SPDIF_EN);
228 value &= ~(KIRKWOOD_PLAYCTL_I2S_EN | KIRKWOOD_PLAYCTL_SPDIF_EN); 271 writel(ctl, priv->io + KIRKWOOD_PLAYCTL);
229 writel(value, priv->io + KIRKWOOD_PLAYCTL);
230 break; 272 break;
231 273
232 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 274 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
233 case SNDRV_PCM_TRIGGER_SUSPEND: 275 case SNDRV_PCM_TRIGGER_SUSPEND:
234 value = readl(priv->io + KIRKWOOD_PLAYCTL); 276 ctl |= KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE;
235 value |= KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE; 277 writel(ctl, priv->io + KIRKWOOD_PLAYCTL);
236 writel(value, priv->io + KIRKWOOD_PLAYCTL);
237 break; 278 break;
238 279
239 case SNDRV_PCM_TRIGGER_RESUME: 280 case SNDRV_PCM_TRIGGER_RESUME:
240 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 281 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
241 value = readl(priv->io + KIRKWOOD_PLAYCTL); 282 ctl &= ~(KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE);
242 value &= ~(KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE); 283 writel(ctl, priv->io + KIRKWOOD_PLAYCTL);
243 writel(value, priv->io + KIRKWOOD_PLAYCTL);
244 break; 284 break;
245 285
246 default: 286 default:
@@ -254,35 +294,24 @@ static int kirkwood_i2s_rec_trigger(struct snd_pcm_substream *substream,
254 int cmd, struct snd_soc_dai *dai) 294 int cmd, struct snd_soc_dai *dai)
255{ 295{
256 struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(dai); 296 struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(dai);
257 unsigned long value; 297 uint32_t ctl, value;
258 298
259 value = readl(priv->io + KIRKWOOD_RECCTL); 299 value = readl(priv->io + KIRKWOOD_RECCTL);
260 300
261 switch (cmd) { 301 switch (cmd) {
262 case SNDRV_PCM_TRIGGER_START: 302 case SNDRV_PCM_TRIGGER_START:
263 /* stop audio, enable interrupts */ 303 /* configure */
264 value = readl(priv->io + KIRKWOOD_RECCTL); 304 ctl = priv->ctl_rec;
265 value |= KIRKWOOD_RECCTL_PAUSE; 305 value = ctl & ~KIRKWOOD_RECCTL_I2S_EN;
266 writel(value, priv->io + KIRKWOOD_RECCTL); 306 writel(value, priv->io + KIRKWOOD_RECCTL);
267 307
308 /* enable interrupts */
268 value = readl(priv->io + KIRKWOOD_INT_MASK); 309 value = readl(priv->io + KIRKWOOD_INT_MASK);
269 value |= KIRKWOOD_INT_CAUSE_REC_BYTES; 310 value |= KIRKWOOD_INT_CAUSE_REC_BYTES;
270 writel(value, priv->io + KIRKWOOD_INT_MASK); 311 writel(value, priv->io + KIRKWOOD_INT_MASK);
271 312
272 /* configure audio & enable i2s record */ 313 /* enable record */
273 value = readl(priv->io + KIRKWOOD_RECCTL); 314 writel(ctl, priv->io + KIRKWOOD_RECCTL);
274 value &= ~KIRKWOOD_RECCTL_BURST_MASK;
275 value &= ~KIRKWOOD_RECCTL_MONO;
276 value &= ~(KIRKWOOD_RECCTL_PAUSE | KIRKWOOD_RECCTL_MUTE
277 | KIRKWOOD_RECCTL_SPDIF_EN);
278
279 if (priv->burst == 32)
280 value |= KIRKWOOD_RECCTL_BURST_32;
281 else
282 value |= KIRKWOOD_RECCTL_BURST_128;
283 value |= KIRKWOOD_RECCTL_I2S_EN;
284
285 writel(value, priv->io + KIRKWOOD_RECCTL);
286 break; 315 break;
287 316
288 case SNDRV_PCM_TRIGGER_STOP: 317 case SNDRV_PCM_TRIGGER_STOP:
@@ -389,90 +418,125 @@ static struct snd_soc_dai_driver kirkwood_i2s_dai = {
389 .channels_min = 1, 418 .channels_min = 1,
390 .channels_max = 2, 419 .channels_max = 2,
391 .rates = KIRKWOOD_I2S_RATES, 420 .rates = KIRKWOOD_I2S_RATES,
392 .formats = KIRKWOOD_I2S_FORMATS,}, 421 .formats = KIRKWOOD_I2S_FORMATS,
422 },
393 .capture = { 423 .capture = {
394 .channels_min = 1, 424 .channels_min = 1,
395 .channels_max = 2, 425 .channels_max = 2,
396 .rates = KIRKWOOD_I2S_RATES, 426 .rates = KIRKWOOD_I2S_RATES,
397 .formats = KIRKWOOD_I2S_FORMATS,}, 427 .formats = KIRKWOOD_I2S_FORMATS,
428 },
429 .ops = &kirkwood_i2s_dai_ops,
430};
431
432static struct snd_soc_dai_driver kirkwood_i2s_dai_extclk = {
433 .probe = kirkwood_i2s_probe,
434 .remove = kirkwood_i2s_remove,
435 .playback = {
436 .channels_min = 1,
437 .channels_max = 2,
438 .rates = SNDRV_PCM_RATE_8000_192000 |
439 SNDRV_PCM_RATE_CONTINUOUS |
440 SNDRV_PCM_RATE_KNOT,
441 .formats = KIRKWOOD_I2S_FORMATS,
442 },
443 .capture = {
444 .channels_min = 1,
445 .channels_max = 2,
446 .rates = SNDRV_PCM_RATE_8000_192000 |
447 SNDRV_PCM_RATE_CONTINUOUS |
448 SNDRV_PCM_RATE_KNOT,
449 .formats = KIRKWOOD_I2S_FORMATS,
450 },
398 .ops = &kirkwood_i2s_dai_ops, 451 .ops = &kirkwood_i2s_dai_ops,
399}; 452};
400 453
401static __devinit int kirkwood_i2s_dev_probe(struct platform_device *pdev) 454static __devinit int kirkwood_i2s_dev_probe(struct platform_device *pdev)
402{ 455{
403 struct resource *mem; 456 struct kirkwood_asoc_platform_data *data = pdev->dev.platform_data;
404 struct kirkwood_asoc_platform_data *data = 457 struct snd_soc_dai_driver *soc_dai = &kirkwood_i2s_dai;
405 pdev->dev.platform_data;
406 struct kirkwood_dma_data *priv; 458 struct kirkwood_dma_data *priv;
459 struct resource *mem;
407 int err; 460 int err;
408 461
409 priv = kzalloc(sizeof(struct kirkwood_dma_data), GFP_KERNEL); 462 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
410 if (!priv) { 463 if (!priv) {
411 dev_err(&pdev->dev, "allocation failed\n"); 464 dev_err(&pdev->dev, "allocation failed\n");
412 err = -ENOMEM; 465 return -ENOMEM;
413 goto error;
414 } 466 }
415 dev_set_drvdata(&pdev->dev, priv); 467 dev_set_drvdata(&pdev->dev, priv);
416 468
417 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 469 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
418 if (!mem) { 470 if (!mem) {
419 dev_err(&pdev->dev, "platform_get_resource failed\n"); 471 dev_err(&pdev->dev, "platform_get_resource failed\n");
420 err = -ENXIO; 472 return -ENXIO;
421 goto err_alloc;
422 }
423
424 priv->mem = request_mem_region(mem->start, SZ_16K, DRV_NAME);
425 if (!priv->mem) {
426 dev_err(&pdev->dev, "request_mem_region failed\n");
427 err = -EBUSY;
428 goto err_alloc;
429 } 473 }
430 474
431 priv->io = ioremap(priv->mem->start, SZ_16K); 475 priv->io = devm_request_and_ioremap(&pdev->dev, mem);
432 if (!priv->io) { 476 if (!priv->io) {
433 dev_err(&pdev->dev, "ioremap failed\n"); 477 dev_err(&pdev->dev, "devm_request_and_ioremap failed\n");
434 err = -ENOMEM; 478 return -ENOMEM;
435 goto err_iomem;
436 } 479 }
437 480
438 priv->irq = platform_get_irq(pdev, 0); 481 priv->irq = platform_get_irq(pdev, 0);
439 if (priv->irq <= 0) { 482 if (priv->irq <= 0) {
440 dev_err(&pdev->dev, "platform_get_irq failed\n"); 483 dev_err(&pdev->dev, "platform_get_irq failed\n");
441 err = -ENXIO; 484 return -ENXIO;
442 goto err_ioremap;
443 } 485 }
444 486
445 if (!data) { 487 if (!data) {
446 dev_err(&pdev->dev, "no platform data ?!\n"); 488 dev_err(&pdev->dev, "no platform data ?!\n");
447 err = -EINVAL; 489 return -EINVAL;
448 goto err_ioremap;
449 } 490 }
450 491
451 priv->burst = data->burst; 492 priv->burst = data->burst;
452 493
453 priv->clk = clk_get(&pdev->dev, NULL); 494 priv->clk = devm_clk_get(&pdev->dev, NULL);
454 if (IS_ERR(priv->clk)) { 495 if (IS_ERR(priv->clk)) {
455 dev_err(&pdev->dev, "no clock\n"); 496 dev_err(&pdev->dev, "no clock\n");
456 err = PTR_ERR(priv->clk); 497 return PTR_ERR(priv->clk);
457 goto err_ioremap; 498 }
499
500 err = clk_prepare_enable(priv->clk);
501 if (err < 0)
502 return err;
503
504 priv->extclk = clk_get(&pdev->dev, "extclk");
505 if (!IS_ERR(priv->extclk)) {
506 if (priv->extclk == priv->clk) {
507 clk_put(priv->extclk);
508 priv->extclk = ERR_PTR(-EINVAL);
509 } else {
510 dev_info(&pdev->dev, "found external clock\n");
511 clk_prepare_enable(priv->extclk);
512 soc_dai = &kirkwood_i2s_dai_extclk;
513 }
514 }
515
516 /* Some sensible defaults - this reflects the powerup values */
517 priv->ctl_play = KIRKWOOD_PLAYCTL_SIZE_24;
518 priv->ctl_rec = KIRKWOOD_RECCTL_SIZE_24;
519
520 /* Select the burst size */
521 if (data->burst == 32) {
522 priv->ctl_play |= KIRKWOOD_PLAYCTL_BURST_32;
523 priv->ctl_rec |= KIRKWOOD_RECCTL_BURST_32;
524 } else {
525 priv->ctl_play |= KIRKWOOD_PLAYCTL_BURST_128;
526 priv->ctl_rec |= KIRKWOOD_RECCTL_BURST_128;
458 } 527 }
459 clk_prepare_enable(priv->clk);
460 528
461 err = snd_soc_register_dai(&pdev->dev, &kirkwood_i2s_dai); 529 err = snd_soc_register_dai(&pdev->dev, soc_dai);
462 if (!err) 530 if (!err)
463 return 0; 531 return 0;
464 dev_err(&pdev->dev, "snd_soc_register_dai failed\n"); 532 dev_err(&pdev->dev, "snd_soc_register_dai failed\n");
465 533
534 if (!IS_ERR(priv->extclk)) {
535 clk_disable_unprepare(priv->extclk);
536 clk_put(priv->extclk);
537 }
466 clk_disable_unprepare(priv->clk); 538 clk_disable_unprepare(priv->clk);
467 clk_put(priv->clk); 539
468
469err_ioremap:
470 iounmap(priv->io);
471err_iomem:
472 release_mem_region(priv->mem->start, SZ_16K);
473err_alloc:
474 kfree(priv);
475error:
476 return err; 540 return err;
477} 541}
478 542
@@ -482,12 +546,11 @@ static __devexit int kirkwood_i2s_dev_remove(struct platform_device *pdev)
482 546
483 snd_soc_unregister_dai(&pdev->dev); 547 snd_soc_unregister_dai(&pdev->dev);
484 548
549 if (!IS_ERR(priv->extclk)) {
550 clk_disable_unprepare(priv->extclk);
551 clk_put(priv->extclk);
552 }
485 clk_disable_unprepare(priv->clk); 553 clk_disable_unprepare(priv->clk);
486 clk_put(priv->clk);
487
488 iounmap(priv->io);
489 release_mem_region(priv->mem->start, SZ_16K);
490 kfree(priv);
491 554
492 return 0; 555 return 0;
493} 556}
diff --git a/sound/soc/kirkwood/kirkwood.h b/sound/soc/kirkwood/kirkwood.h
index f9084d83e6bd..4d92637ddb3f 100644
--- a/sound/soc/kirkwood/kirkwood.h
+++ b/sound/soc/kirkwood/kirkwood.h
@@ -77,6 +77,11 @@
77#define KIRKWOOD_DCO_SPCR_STATUS 0x120c 77#define KIRKWOOD_DCO_SPCR_STATUS 0x120c
78#define KIRKWOOD_DCO_SPCR_STATUS_DCO_LOCK (1<<16) 78#define KIRKWOOD_DCO_SPCR_STATUS_DCO_LOCK (1<<16)
79 79
80#define KIRKWOOD_CLOCKS_CTRL 0x1230
81#define KIRKWOOD_MCLK_SOURCE_MASK (3<<0)
82#define KIRKWOOD_MCLK_SOURCE_DCO (0<<0)
83#define KIRKWOOD_MCLK_SOURCE_EXTCLK (3<<0)
84
80#define KIRKWOOD_ERR_CAUSE 0x1300 85#define KIRKWOOD_ERR_CAUSE 0x1300
81#define KIRKWOOD_ERR_MASK 0x1304 86#define KIRKWOOD_ERR_MASK 0x1304
82 87
@@ -119,11 +124,13 @@
119#define KIRKWOOD_SND_MAX_PERIOD_BYTES 0x4000 124#define KIRKWOOD_SND_MAX_PERIOD_BYTES 0x4000
120 125
121struct kirkwood_dma_data { 126struct kirkwood_dma_data {
122 struct resource *mem;
123 void __iomem *io; 127 void __iomem *io;
128 struct clk *clk;
129 struct clk *extclk;
130 uint32_t ctl_play;
131 uint32_t ctl_rec;
124 int irq; 132 int irq;
125 int burst; 133 int burst;
126 struct clk *clk;
127}; 134};
128 135
129#endif 136#endif
diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c
index aa037b292f3d..b304e375568a 100644
--- a/sound/soc/mxs/mxs-saif.c
+++ b/sound/soc/mxs/mxs-saif.c
@@ -229,6 +229,7 @@ int mxs_saif_put_mclk(unsigned int saif_id)
229 saif->mclk_in_use = 0; 229 saif->mclk_in_use = 0;
230 return 0; 230 return 0;
231} 231}
232EXPORT_SYMBOL_GPL(mxs_saif_put_mclk);
232 233
233/* 234/*
234 * Get MCLK and set clock rate, then enable it 235 * Get MCLK and set clock rate, then enable it
@@ -282,6 +283,7 @@ int mxs_saif_get_mclk(unsigned int saif_id, unsigned int mclk,
282 283
283 return 0; 284 return 0;
284} 285}
286EXPORT_SYMBOL_GPL(mxs_saif_get_mclk);
285 287
286/* 288/*
287 * SAIF DAI format configuration. 289 * SAIF DAI format configuration.
@@ -523,16 +525,24 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd,
523 525
524 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 526 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
525 /* 527 /*
526 * write a data to saif data register to trigger 528 * write data to saif data register to trigger
527 * the transfer 529 * the transfer.
530 * For 24-bit format the 32-bit FIFO register stores
531 * only one channel, so we need to write twice.
532 * This is also safe for the other non 24-bit formats.
528 */ 533 */
529 __raw_writel(0, saif->base + SAIF_DATA); 534 __raw_writel(0, saif->base + SAIF_DATA);
535 __raw_writel(0, saif->base + SAIF_DATA);
530 } else { 536 } else {
531 /* 537 /*
532 * read a data from saif data register to trigger 538 * read data from saif data register to trigger
533 * the receive 539 * the receive.
540 * For 24-bit format the 32-bit FIFO register stores
541 * only one channel, so we need to read twice.
542 * This is also safe for the other non 24-bit formats.
534 */ 543 */
535 __raw_readl(saif->base + SAIF_DATA); 544 __raw_readl(saif->base + SAIF_DATA);
545 __raw_readl(saif->base + SAIF_DATA);
536 } 546 }
537 547
538 master_saif->ongoing = 1; 548 master_saif->ongoing = 1;
@@ -812,3 +822,4 @@ module_platform_driver(mxs_saif_driver);
812MODULE_AUTHOR("Freescale Semiconductor, Inc."); 822MODULE_AUTHOR("Freescale Semiconductor, Inc.");
813MODULE_DESCRIPTION("MXS ASoC SAIF driver"); 823MODULE_DESCRIPTION("MXS ASoC SAIF driver");
814MODULE_LICENSE("GPL"); 824MODULE_LICENSE("GPL");
825MODULE_ALIAS("platform:mxs-saif");
diff --git a/sound/soc/omap/mcbsp.c b/sound/soc/omap/mcbsp.c
index afb8d4f1bedf..a9a243860428 100644
--- a/sound/soc/omap/mcbsp.c
+++ b/sound/soc/omap/mcbsp.c
@@ -28,8 +28,6 @@
28 28
29#include <linux/platform_data/asoc-ti-mcbsp.h> 29#include <linux/platform_data/asoc-ti-mcbsp.h>
30 30
31#include <plat/cpu.h>
32
33#include "mcbsp.h" 31#include "mcbsp.h"
34 32
35static void omap_mcbsp_write(struct omap_mcbsp *mcbsp, u16 reg, u32 val) 33static void omap_mcbsp_write(struct omap_mcbsp *mcbsp, u16 reg, u32 val)
@@ -612,7 +610,7 @@ void omap_mcbsp_free(struct omap_mcbsp *mcbsp)
612 * system will refuse to enter idle if the CLKS pin source is not reset 610 * system will refuse to enter idle if the CLKS pin source is not reset
613 * back to internal source. 611 * back to internal source.
614 */ 612 */
615 if (!cpu_class_is_omap1()) 613 if (!mcbsp_omap1())
616 omap2_mcbsp_set_clks_src(mcbsp, MCBSP_CLKS_PRCM_SRC); 614 omap2_mcbsp_set_clks_src(mcbsp, MCBSP_CLKS_PRCM_SRC);
617 615
618 spin_lock(&mcbsp->lock); 616 spin_lock(&mcbsp->lock);
diff --git a/sound/soc/omap/mcbsp.h b/sound/soc/omap/mcbsp.h
index 49a67259ce5a..a89791c239a5 100644
--- a/sound/soc/omap/mcbsp.h
+++ b/sound/soc/omap/mcbsp.h
@@ -26,6 +26,12 @@
26 26
27#include "omap-pcm.h" 27#include "omap-pcm.h"
28 28
29#ifdef CONFIG_ARCH_OMAP1
30#define mcbsp_omap1() 1
31#else
32#define mcbsp_omap1() 0
33#endif
34
29/* McBSP register numbers. Register address offset = num * reg_step */ 35/* McBSP register numbers. Register address offset = num * reg_step */
30enum { 36enum {
31 /* Common registers */ 37 /* Common registers */
diff --git a/sound/soc/omap/omap-abe-twl6040.c b/sound/soc/omap/omap-abe-twl6040.c
index a57a4e68dcc6..1d6ea8609d28 100644
--- a/sound/soc/omap/omap-abe-twl6040.c
+++ b/sound/soc/omap/omap-abe-twl6040.c
@@ -331,8 +331,8 @@ static __devinit int omap_abe_probe(struct platform_device *pdev)
331 num_links = 1; 331 num_links = 1;
332 } 332 }
333 333
334 of_property_read_u32(node, "ti,jack-detection", 334 priv->jack_detection = of_property_read_bool(node,
335 &priv->jack_detection); 335 "ti,jack-detection");
336 of_property_read_u32(node, "ti,mclk-freq", 336 of_property_read_u32(node, "ti,mclk-freq",
337 &priv->mclk_freq); 337 &priv->mclk_freq);
338 if (!priv->mclk_freq) { 338 if (!priv->mclk_freq) {
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c
index a6ee15747859..09167609c93e 100644
--- a/sound/soc/omap/omap-mcbsp.c
+++ b/sound/soc/omap/omap-mcbsp.c
@@ -34,7 +34,6 @@
34#include <sound/initval.h> 34#include <sound/initval.h>
35#include <sound/soc.h> 35#include <sound/soc.h>
36 36
37#include <plat/cpu.h>
38#include <linux/platform_data/asoc-ti-mcbsp.h> 37#include <linux/platform_data/asoc-ti-mcbsp.h>
39#include "mcbsp.h" 38#include "mcbsp.h"
40#include "omap-mcbsp.h" 39#include "omap-mcbsp.h"
@@ -512,7 +511,7 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
512 regs->srgr2 |= CLKSM; 511 regs->srgr2 |= CLKSM;
513 break; 512 break;
514 case OMAP_MCBSP_SYSCLK_CLKS_FCLK: 513 case OMAP_MCBSP_SYSCLK_CLKS_FCLK:
515 if (cpu_class_is_omap1()) { 514 if (mcbsp_omap1()) {
516 err = -EINVAL; 515 err = -EINVAL;
517 break; 516 break;
518 } 517 }
@@ -520,7 +519,7 @@ static int omap_mcbsp_dai_set_dai_sysclk(struct snd_soc_dai *cpu_dai,
520 MCBSP_CLKS_PRCM_SRC); 519 MCBSP_CLKS_PRCM_SRC);
521 break; 520 break;
522 case OMAP_MCBSP_SYSCLK_CLKS_EXT: 521 case OMAP_MCBSP_SYSCLK_CLKS_EXT:
523 if (cpu_class_is_omap1()) { 522 if (mcbsp_omap1()) {
524 err = 0; 523 err = 0;
525 break; 524 break;
526 } 525 }
diff --git a/sound/soc/omap/zoom2.c b/sound/soc/omap/zoom2.c
index 1ff6bb9ade5c..771bff27ac3e 100644
--- a/sound/soc/omap/zoom2.c
+++ b/sound/soc/omap/zoom2.c
@@ -37,8 +37,6 @@
37#include "omap-mcbsp.h" 37#include "omap-mcbsp.h"
38#include "omap-pcm.h" 38#include "omap-pcm.h"
39 39
40#define ZOOM2_HEADSET_MUX_GPIO (OMAP_MAX_GPIO_LINES + 15)
41
42static int zoom2_hw_params(struct snd_pcm_substream *substream, 40static int zoom2_hw_params(struct snd_pcm_substream *substream,
43 struct snd_pcm_hw_params *params) 41 struct snd_pcm_hw_params *params)
44{ 42{
@@ -187,9 +185,6 @@ static int __init zoom2_soc_init(void)
187 if (ret) 185 if (ret)
188 goto err1; 186 goto err1;
189 187
190 BUG_ON(gpio_request(ZOOM2_HEADSET_MUX_GPIO, "hs_mux") < 0);
191 gpio_direction_output(ZOOM2_HEADSET_MUX_GPIO, 0);
192
193 return 0; 188 return 0;
194 189
195err1: 190err1:
@@ -202,8 +197,6 @@ module_init(zoom2_soc_init);
202 197
203static void __exit zoom2_soc_exit(void) 198static void __exit zoom2_soc_exit(void)
204{ 199{
205 gpio_free(ZOOM2_HEADSET_MUX_GPIO);
206
207 platform_device_unregister(zoom2_snd_device); 200 platform_device_unregister(zoom2_snd_device);
208} 201}
209module_exit(zoom2_soc_exit); 202module_exit(zoom2_soc_exit);
diff --git a/sound/soc/samsung/Kconfig b/sound/soc/samsung/Kconfig
index e7b83179aca2..3c7c3a59ed39 100644
--- a/sound/soc/samsung/Kconfig
+++ b/sound/soc/samsung/Kconfig
@@ -207,6 +207,8 @@ config SND_SOC_BELLS
207 select SND_SOC_WM5102 207 select SND_SOC_WM5102
208 select SND_SOC_WM5110 208 select SND_SOC_WM5110
209 select SND_SOC_WM9081 209 select SND_SOC_WM9081
210 select SND_SOC_WM0010
211 select SND_SOC_WM1250_EV1
210 212
211config SND_SOC_LOWLAND 213config SND_SOC_LOWLAND
212 tristate "Audio support for Wolfson Lowland" 214 tristate "Audio support for Wolfson Lowland"
diff --git a/sound/soc/samsung/ac97.c b/sound/soc/samsung/ac97.c
index 14fbcd30cae5..cd6c7073c50d 100644
--- a/sound/soc/samsung/ac97.c
+++ b/sound/soc/samsung/ac97.c
@@ -442,7 +442,7 @@ static __devinit int s3c_ac97_probe(struct platform_device *pdev)
442 ret = -ENODEV; 442 ret = -ENODEV;
443 goto err2; 443 goto err2;
444 } 444 }
445 clk_enable(s3c_ac97.ac97_clk); 445 clk_prepare_enable(s3c_ac97.ac97_clk);
446 446
447 if (ac97_pdata->cfg_gpio(pdev)) { 447 if (ac97_pdata->cfg_gpio(pdev)) {
448 dev_err(&pdev->dev, "Unable to configure gpio\n"); 448 dev_err(&pdev->dev, "Unable to configure gpio\n");
@@ -462,13 +462,20 @@ static __devinit int s3c_ac97_probe(struct platform_device *pdev)
462 if (ret) 462 if (ret)
463 goto err5; 463 goto err5;
464 464
465 return 0; 465 ret = asoc_dma_platform_register(&pdev->dev);
466 if (ret) {
467 dev_err(&pdev->dev, "failed to get register DMA: %d\n", ret);
468 goto err6;
469 }
466 470
471 return 0;
472err6:
473 snd_soc_unregister_dais(&pdev->dev, ARRAY_SIZE(s3c_ac97_dai));
467err5: 474err5:
468 free_irq(irq_res->start, NULL); 475 free_irq(irq_res->start, NULL);
469err4: 476err4:
470err3: 477err3:
471 clk_disable(s3c_ac97.ac97_clk); 478 clk_disable_unprepare(s3c_ac97.ac97_clk);
472 clk_put(s3c_ac97.ac97_clk); 479 clk_put(s3c_ac97.ac97_clk);
473err2: 480err2:
474 iounmap(s3c_ac97.regs); 481 iounmap(s3c_ac97.regs);
@@ -482,13 +489,14 @@ static __devexit int s3c_ac97_remove(struct platform_device *pdev)
482{ 489{
483 struct resource *mem_res, *irq_res; 490 struct resource *mem_res, *irq_res;
484 491
492 asoc_dma_platform_unregister(&pdev->dev);
485 snd_soc_unregister_dais(&pdev->dev, ARRAY_SIZE(s3c_ac97_dai)); 493 snd_soc_unregister_dais(&pdev->dev, ARRAY_SIZE(s3c_ac97_dai));
486 494
487 irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 495 irq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
488 if (irq_res) 496 if (irq_res)
489 free_irq(irq_res->start, NULL); 497 free_irq(irq_res->start, NULL);
490 498
491 clk_disable(s3c_ac97.ac97_clk); 499 clk_disable_unprepare(s3c_ac97.ac97_clk);
492 clk_put(s3c_ac97.ac97_clk); 500 clk_put(s3c_ac97.ac97_clk);
493 501
494 iounmap(s3c_ac97.regs); 502 iounmap(s3c_ac97.regs);
diff --git a/sound/soc/samsung/bells.c b/sound/soc/samsung/bells.c
index b0d46d63d55e..01c1c5a2d321 100644
--- a/sound/soc/samsung/bells.c
+++ b/sound/soc/samsung/bells.c
@@ -18,15 +18,6 @@
18#include "../codecs/wm5102.h" 18#include "../codecs/wm5102.h"
19#include "../codecs/wm9081.h" 19#include "../codecs/wm9081.h"
20 20
21/*
22 * 44.1kHz based clocks for the SYSCLK domain, use a very high clock
23 * to allow all the DSP functionality to be enabled if desired.
24 */
25#define SYSCLK_RATE (44100 * 1024)
26
27/* 48kHz based clocks for the ASYNC domain */
28#define ASYNCCLK_RATE (48000 * 512)
29
30/* BCLK2 is fixed at this currently */ 21/* BCLK2 is fixed at this currently */
31#define BCLK2_RATE (64 * 8000) 22#define BCLK2_RATE (64 * 8000)
32 23
@@ -36,15 +27,40 @@
36 */ 27 */
37#define MCLK_RATE 24576000 28#define MCLK_RATE 24576000
38 29
39#define WM9081_AUDIO_RATE 44100 30#define SYS_AUDIO_RATE 44100
40#define WM9081_MCLK_RATE (WM9081_AUDIO_RATE * 256) 31#define SYS_MCLK_RATE (SYS_AUDIO_RATE * 512)
32
33#define DAI_AP_DSP 0
34#define DAI_DSP_CODEC 1
35#define DAI_CODEC_CP 2
36#define DAI_CODEC_SUB 3
37
38struct bells_drvdata {
39 int sysclk_rate;
40 int asyncclk_rate;
41};
42
43static struct bells_drvdata wm2200_drvdata = {
44 .sysclk_rate = 22579200,
45};
46
47static struct bells_drvdata wm5102_drvdata = {
48 .sysclk_rate = 45158400,
49 .asyncclk_rate = 49152000,
50};
51
52static struct bells_drvdata wm5110_drvdata = {
53 .sysclk_rate = 135475200,
54 .asyncclk_rate = 147456000,
55};
41 56
42static int bells_set_bias_level(struct snd_soc_card *card, 57static int bells_set_bias_level(struct snd_soc_card *card,
43 struct snd_soc_dapm_context *dapm, 58 struct snd_soc_dapm_context *dapm,
44 enum snd_soc_bias_level level) 59 enum snd_soc_bias_level level)
45{ 60{
46 struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai; 61 struct snd_soc_dai *codec_dai = card->rtd[DAI_DSP_CODEC].codec_dai;
47 struct snd_soc_codec *codec = codec_dai->codec; 62 struct snd_soc_codec *codec = codec_dai->codec;
63 struct bells_drvdata *bells = card->drvdata;
48 int ret; 64 int ret;
49 65
50 if (dapm->dev != codec_dai->dev) 66 if (dapm->dev != codec_dai->dev)
@@ -52,18 +68,21 @@ static int bells_set_bias_level(struct snd_soc_card *card,
52 68
53 switch (level) { 69 switch (level) {
54 case SND_SOC_BIAS_PREPARE: 70 case SND_SOC_BIAS_PREPARE:
55 if (dapm->bias_level == SND_SOC_BIAS_STANDBY) { 71 if (dapm->bias_level != SND_SOC_BIAS_STANDBY)
56 ret = snd_soc_codec_set_pll(codec, WM5102_FLL1, 72 break;
57 ARIZONA_FLL_SRC_MCLK1,
58 MCLK_RATE,
59 SYSCLK_RATE);
60 if (ret < 0)
61 pr_err("Failed to start FLL: %d\n", ret);
62 73
74 ret = snd_soc_codec_set_pll(codec, WM5102_FLL1,
75 ARIZONA_FLL_SRC_MCLK1,
76 MCLK_RATE,
77 bells->sysclk_rate);
78 if (ret < 0)
79 pr_err("Failed to start FLL: %d\n", ret);
80
81 if (bells->asyncclk_rate) {
63 ret = snd_soc_codec_set_pll(codec, WM5102_FLL2, 82 ret = snd_soc_codec_set_pll(codec, WM5102_FLL2,
64 ARIZONA_FLL_SRC_AIF2BCLK, 83 ARIZONA_FLL_SRC_AIF2BCLK,
65 BCLK2_RATE, 84 BCLK2_RATE,
66 ASYNCCLK_RATE); 85 bells->asyncclk_rate);
67 if (ret < 0) 86 if (ret < 0)
68 pr_err("Failed to start FLL: %d\n", ret); 87 pr_err("Failed to start FLL: %d\n", ret);
69 } 88 }
@@ -80,8 +99,9 @@ static int bells_set_bias_level_post(struct snd_soc_card *card,
80 struct snd_soc_dapm_context *dapm, 99 struct snd_soc_dapm_context *dapm,
81 enum snd_soc_bias_level level) 100 enum snd_soc_bias_level level)
82{ 101{
83 struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai; 102 struct snd_soc_dai *codec_dai = card->rtd[DAI_DSP_CODEC].codec_dai;
84 struct snd_soc_codec *codec = codec_dai->codec; 103 struct snd_soc_codec *codec = codec_dai->codec;
104 struct bells_drvdata *bells = card->drvdata;
85 int ret; 105 int ret;
86 106
87 if (dapm->dev != codec_dai->dev) 107 if (dapm->dev != codec_dai->dev)
@@ -95,10 +115,13 @@ static int bells_set_bias_level_post(struct snd_soc_card *card,
95 return ret; 115 return ret;
96 } 116 }
97 117
98 ret = snd_soc_codec_set_pll(codec, WM5102_FLL2, 0, 0, 0); 118 if (bells->asyncclk_rate) {
99 if (ret < 0) { 119 ret = snd_soc_codec_set_pll(codec, WM5102_FLL2,
100 pr_err("Failed to stop FLL: %d\n", ret); 120 0, 0, 0);
101 return ret; 121 if (ret < 0) {
122 pr_err("Failed to stop FLL: %d\n", ret);
123 return ret;
124 }
102 } 125 }
103 break; 126 break;
104 127
@@ -113,56 +136,73 @@ static int bells_set_bias_level_post(struct snd_soc_card *card,
113 136
114static int bells_late_probe(struct snd_soc_card *card) 137static int bells_late_probe(struct snd_soc_card *card)
115{ 138{
116 struct snd_soc_codec *codec = card->rtd[0].codec; 139 struct bells_drvdata *bells = card->drvdata;
117 struct snd_soc_dai *aif1_dai = card->rtd[0].codec_dai; 140 struct snd_soc_codec *wm0010 = card->rtd[DAI_AP_DSP].codec;
118 struct snd_soc_dai *aif2_dai = card->rtd[1].cpu_dai; 141 struct snd_soc_codec *codec = card->rtd[DAI_DSP_CODEC].codec;
119 struct snd_soc_dai *aif3_dai = card->rtd[2].cpu_dai; 142 struct snd_soc_dai *aif1_dai = card->rtd[DAI_DSP_CODEC].codec_dai;
120 struct snd_soc_dai *wm9081_dai = card->rtd[2].codec_dai; 143 struct snd_soc_dai *aif2_dai;
144 struct snd_soc_dai *aif3_dai;
145 struct snd_soc_dai *wm9081_dai;
121 int ret; 146 int ret;
122 147
123 ret = snd_soc_dai_set_sysclk(aif1_dai, ARIZONA_CLK_SYSCLK, 0, 0); 148 ret = snd_soc_codec_set_sysclk(codec, ARIZONA_CLK_SYSCLK,
149 ARIZONA_CLK_SRC_FLL1,
150 bells->sysclk_rate,
151 SND_SOC_CLOCK_IN);
124 if (ret != 0) { 152 if (ret != 0) {
125 dev_err(aif1_dai->dev, "Failed to set AIF1 clock: %d\n", ret); 153 dev_err(codec->dev, "Failed to set SYSCLK: %d\n", ret);
126 return ret; 154 return ret;
127 } 155 }
128 156
129 ret = snd_soc_dai_set_sysclk(aif2_dai, ARIZONA_CLK_ASYNCCLK, 0, 0); 157 ret = snd_soc_codec_set_sysclk(wm0010, 0, 0, SYS_MCLK_RATE, 0);
130 if (ret != 0) { 158 if (ret != 0) {
131 dev_err(aif2_dai->dev, "Failed to set AIF2 clock: %d\n", ret); 159 dev_err(wm0010->dev, "Failed to set WM0010 clock: %d\n", ret);
132 return ret; 160 return ret;
133 } 161 }
134 162
135 ret = snd_soc_dai_set_sysclk(aif3_dai, ARIZONA_CLK_SYSCLK, 0, 0); 163 ret = snd_soc_dai_set_sysclk(aif1_dai, ARIZONA_CLK_SYSCLK, 0, 0);
136 if (ret != 0) { 164 if (ret != 0)
137 dev_err(aif1_dai->dev, "Failed to set AIF1 clock: %d\n", ret); 165 dev_err(aif1_dai->dev, "Failed to set AIF1 clock: %d\n", ret);
138 return ret;
139 }
140 166
141 ret = snd_soc_codec_set_sysclk(codec, ARIZONA_CLK_SYSCLK, 167 ret = snd_soc_codec_set_sysclk(codec, ARIZONA_CLK_OPCLK, 0,
142 ARIZONA_CLK_SRC_FLL1, SYSCLK_RATE, 168 SYS_MCLK_RATE, SND_SOC_CLOCK_OUT);
169 if (ret != 0)
170 dev_err(codec->dev, "Failed to set OPCLK: %d\n", ret);
171
172 if (card->num_rtd == DAI_CODEC_CP)
173 return 0;
174
175 ret = snd_soc_codec_set_sysclk(codec, ARIZONA_CLK_ASYNCCLK,
176 ARIZONA_CLK_SRC_FLL2,
177 bells->asyncclk_rate,
143 SND_SOC_CLOCK_IN); 178 SND_SOC_CLOCK_IN);
144 if (ret != 0) { 179 if (ret != 0) {
145 dev_err(codec->dev, "Failed to set SYSCLK: %d\n", ret); 180 dev_err(codec->dev, "Failed to set ASYNCCLK: %d\n", ret);
146 return ret; 181 return ret;
147 } 182 }
148 183
149 ret = snd_soc_codec_set_sysclk(codec, ARIZONA_CLK_OPCLK, 0, 184 aif2_dai = card->rtd[DAI_CODEC_CP].cpu_dai;
150 WM9081_MCLK_RATE, SND_SOC_CLOCK_OUT); 185
186 ret = snd_soc_dai_set_sysclk(aif2_dai, ARIZONA_CLK_ASYNCCLK, 0, 0);
151 if (ret != 0) { 187 if (ret != 0) {
152 dev_err(codec->dev, "Failed to set OPCLK: %d\n", ret); 188 dev_err(aif2_dai->dev, "Failed to set AIF2 clock: %d\n", ret);
153 return ret; 189 return ret;
154 } 190 }
155 191
156 ret = snd_soc_codec_set_sysclk(codec, ARIZONA_CLK_ASYNCCLK, 192 if (card->num_rtd == DAI_CODEC_SUB)
157 ARIZONA_CLK_SRC_FLL2, ASYNCCLK_RATE, 193 return 0;
158 SND_SOC_CLOCK_IN); 194
195 aif3_dai = card->rtd[DAI_CODEC_SUB].cpu_dai;
196 wm9081_dai = card->rtd[DAI_CODEC_SUB].codec_dai;
197
198 ret = snd_soc_dai_set_sysclk(aif3_dai, ARIZONA_CLK_SYSCLK, 0, 0);
159 if (ret != 0) { 199 if (ret != 0) {
160 dev_err(codec->dev, "Failed to set SYSCLK: %d\n", ret); 200 dev_err(aif1_dai->dev, "Failed to set AIF1 clock: %d\n", ret);
161 return ret; 201 return ret;
162 } 202 }
163 203
164 ret = snd_soc_codec_set_sysclk(wm9081_dai->codec, WM9081_SYSCLK_MCLK, 204 ret = snd_soc_codec_set_sysclk(wm9081_dai->codec, WM9081_SYSCLK_MCLK,
165 0, WM9081_MCLK_RATE, 0); 205 0, SYS_MCLK_RATE, 0);
166 if (ret != 0) { 206 if (ret != 0) {
167 dev_err(wm9081_dai->dev, "Failed to set MCLK: %d\n", ret); 207 dev_err(wm9081_dai->dev, "Failed to set MCLK: %d\n", ret);
168 return ret; 208 return ret;
@@ -181,22 +221,57 @@ static const struct snd_soc_pcm_stream baseband_params = {
181 221
182static const struct snd_soc_pcm_stream sub_params = { 222static const struct snd_soc_pcm_stream sub_params = {
183 .formats = SNDRV_PCM_FMTBIT_S32_LE, 223 .formats = SNDRV_PCM_FMTBIT_S32_LE,
184 .rate_min = WM9081_AUDIO_RATE, 224 .rate_min = SYS_AUDIO_RATE,
185 .rate_max = WM9081_AUDIO_RATE, 225 .rate_max = SYS_AUDIO_RATE,
186 .channels_min = 2, 226 .channels_min = 2,
187 .channels_max = 2, 227 .channels_max = 2,
188}; 228};
189 229
230static struct snd_soc_dai_link bells_dai_wm2200[] = {
231 {
232 .name = "CPU-DSP",
233 .stream_name = "CPU-DSP",
234 .cpu_dai_name = "samsung-i2s.0",
235 .codec_dai_name = "wm0010-sdi1",
236 .platform_name = "samsung-i2s.0",
237 .codec_name = "spi0.0",
238 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
239 | SND_SOC_DAIFMT_CBM_CFM,
240 },
241 {
242 .name = "DSP-CODEC",
243 .stream_name = "DSP-CODEC",
244 .cpu_dai_name = "wm0010-sdi2",
245 .codec_dai_name = "wm2200",
246 .codec_name = "wm2200.1-003a",
247 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
248 | SND_SOC_DAIFMT_CBM_CFM,
249 .params = &sub_params,
250 .ignore_suspend = 1,
251 },
252};
253
190static struct snd_soc_dai_link bells_dai_wm5102[] = { 254static struct snd_soc_dai_link bells_dai_wm5102[] = {
191 { 255 {
192 .name = "CPU", 256 .name = "CPU-DSP",
193 .stream_name = "CPU", 257 .stream_name = "CPU-DSP",
194 .cpu_dai_name = "samsung-i2s.0", 258 .cpu_dai_name = "samsung-i2s.0",
259 .codec_dai_name = "wm0010-sdi1",
260 .platform_name = "samsung-i2s.0",
261 .codec_name = "spi0.0",
262 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
263 | SND_SOC_DAIFMT_CBM_CFM,
264 },
265 {
266 .name = "DSP-CODEC",
267 .stream_name = "DSP-CODEC",
268 .cpu_dai_name = "wm0010-sdi2",
195 .codec_dai_name = "wm5102-aif1", 269 .codec_dai_name = "wm5102-aif1",
196 .platform_name = "samsung-audio",
197 .codec_name = "wm5102-codec", 270 .codec_name = "wm5102-codec",
198 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF 271 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
199 | SND_SOC_DAIFMT_CBM_CFM, 272 | SND_SOC_DAIFMT_CBM_CFM,
273 .params = &sub_params,
274 .ignore_suspend = 1,
200 }, 275 },
201 { 276 {
202 .name = "Baseband", 277 .name = "Baseband",
@@ -212,7 +287,7 @@ static struct snd_soc_dai_link bells_dai_wm5102[] = {
212 { 287 {
213 .name = "Sub", 288 .name = "Sub",
214 .stream_name = "Sub", 289 .stream_name = "Sub",
215 .cpu_dai_name = "wm5110-aif3", 290 .cpu_dai_name = "wm5102-aif3",
216 .codec_dai_name = "wm9081-hifi", 291 .codec_dai_name = "wm9081-hifi",
217 .codec_name = "wm9081.1-006c", 292 .codec_name = "wm9081.1-006c",
218 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF 293 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
@@ -224,14 +299,25 @@ static struct snd_soc_dai_link bells_dai_wm5102[] = {
224 299
225static struct snd_soc_dai_link bells_dai_wm5110[] = { 300static struct snd_soc_dai_link bells_dai_wm5110[] = {
226 { 301 {
227 .name = "CPU", 302 .name = "CPU-DSP",
228 .stream_name = "CPU", 303 .stream_name = "CPU-DSP",
229 .cpu_dai_name = "samsung-i2s.0", 304 .cpu_dai_name = "samsung-i2s.0",
305 .codec_dai_name = "wm0010-sdi1",
306 .platform_name = "samsung-i2s.0",
307 .codec_name = "spi0.0",
308 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
309 | SND_SOC_DAIFMT_CBM_CFM,
310 },
311 {
312 .name = "DSP-CODEC",
313 .stream_name = "DSP-CODEC",
314 .cpu_dai_name = "wm0010-sdi2",
230 .codec_dai_name = "wm5110-aif1", 315 .codec_dai_name = "wm5110-aif1",
231 .platform_name = "samsung-audio",
232 .codec_name = "wm5110-codec", 316 .codec_name = "wm5110-codec",
233 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF 317 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
234 | SND_SOC_DAIFMT_CBM_CFM, 318 | SND_SOC_DAIFMT_CBM_CFM,
319 .params = &sub_params,
320 .ignore_suspend = 1,
235 }, 321 },
236 { 322 {
237 .name = "Baseband", 323 .name = "Baseband",
@@ -270,6 +356,24 @@ static struct snd_soc_dapm_route bells_routes[] = {
270 356
271static struct snd_soc_card bells_cards[] = { 357static struct snd_soc_card bells_cards[] = {
272 { 358 {
359 .name = "Bells WM2200",
360 .owner = THIS_MODULE,
361 .dai_link = bells_dai_wm2200,
362 .num_links = ARRAY_SIZE(bells_dai_wm2200),
363 .codec_conf = bells_codec_conf,
364 .num_configs = ARRAY_SIZE(bells_codec_conf),
365
366 .late_probe = bells_late_probe,
367
368 .dapm_routes = bells_routes,
369 .num_dapm_routes = ARRAY_SIZE(bells_routes),
370
371 .set_bias_level = bells_set_bias_level,
372 .set_bias_level_post = bells_set_bias_level_post,
373
374 .drvdata = &wm2200_drvdata,
375 },
376 {
273 .name = "Bells WM5102", 377 .name = "Bells WM5102",
274 .owner = THIS_MODULE, 378 .owner = THIS_MODULE,
275 .dai_link = bells_dai_wm5102, 379 .dai_link = bells_dai_wm5102,
@@ -284,6 +388,8 @@ static struct snd_soc_card bells_cards[] = {
284 388
285 .set_bias_level = bells_set_bias_level, 389 .set_bias_level = bells_set_bias_level,
286 .set_bias_level_post = bells_set_bias_level_post, 390 .set_bias_level_post = bells_set_bias_level_post,
391
392 .drvdata = &wm5102_drvdata,
287 }, 393 },
288 { 394 {
289 .name = "Bells WM5110", 395 .name = "Bells WM5110",
@@ -300,6 +406,8 @@ static struct snd_soc_card bells_cards[] = {
300 406
301 .set_bias_level = bells_set_bias_level, 407 .set_bias_level = bells_set_bias_level,
302 .set_bias_level_post = bells_set_bias_level_post, 408 .set_bias_level_post = bells_set_bias_level_post,
409
410 .drvdata = &wm5110_drvdata,
303 }, 411 },
304}; 412};
305 413
diff --git a/sound/soc/samsung/dma.c b/sound/soc/samsung/dma.c
index b70964ea448c..64529904a95f 100644
--- a/sound/soc/samsung/dma.c
+++ b/sound/soc/samsung/dma.c
@@ -432,30 +432,18 @@ static struct snd_soc_platform_driver samsung_asoc_platform = {
432 .pcm_free = dma_free_dma_buffers, 432 .pcm_free = dma_free_dma_buffers,
433}; 433};
434 434
435static int __devinit samsung_asoc_platform_probe(struct platform_device *pdev) 435int __devinit asoc_dma_platform_register(struct device *dev)
436{ 436{
437 return snd_soc_register_platform(&pdev->dev, &samsung_asoc_platform); 437 return snd_soc_register_platform(dev, &samsung_asoc_platform);
438} 438}
439EXPORT_SYMBOL_GPL(asoc_dma_platform_register);
439 440
440static int __devexit samsung_asoc_platform_remove(struct platform_device *pdev) 441void __devexit asoc_dma_platform_unregister(struct device *dev)
441{ 442{
442 snd_soc_unregister_platform(&pdev->dev); 443 snd_soc_unregister_platform(dev);
443 return 0;
444} 444}
445 445EXPORT_SYMBOL_GPL(asoc_dma_platform_unregister);
446static struct platform_driver asoc_dma_driver = {
447 .driver = {
448 .name = "samsung-audio",
449 .owner = THIS_MODULE,
450 },
451
452 .probe = samsung_asoc_platform_probe,
453 .remove = __devexit_p(samsung_asoc_platform_remove),
454};
455
456module_platform_driver(asoc_dma_driver);
457 446
458MODULE_AUTHOR("Ben Dooks, <ben@simtec.co.uk>"); 447MODULE_AUTHOR("Ben Dooks, <ben@simtec.co.uk>");
459MODULE_DESCRIPTION("Samsung ASoC DMA Driver"); 448MODULE_DESCRIPTION("Samsung ASoC DMA Driver");
460MODULE_LICENSE("GPL"); 449MODULE_LICENSE("GPL");
461MODULE_ALIAS("platform:samsung-audio");
diff --git a/sound/soc/samsung/dma.h b/sound/soc/samsung/dma.h
index 7d1ead77ef21..73d8c7c8a1e8 100644
--- a/sound/soc/samsung/dma.h
+++ b/sound/soc/samsung/dma.h
@@ -21,4 +21,7 @@ struct s3c_dma_params {
21 struct samsung_dma_ops *ops; 21 struct samsung_dma_ops *ops;
22}; 22};
23 23
24int asoc_dma_platform_register(struct device *dev);
25void asoc_dma_platform_unregister(struct device *dev);
26
24#endif 27#endif
diff --git a/sound/soc/samsung/goni_wm8994.c b/sound/soc/samsung/goni_wm8994.c
index c23c2ae91f58..d37ede58e0a8 100644
--- a/sound/soc/samsung/goni_wm8994.c
+++ b/sound/soc/samsung/goni_wm8994.c
@@ -228,7 +228,7 @@ static struct snd_soc_dai_link goni_dai[] = {
228 .stream_name = "WM8994 HiFi", 228 .stream_name = "WM8994 HiFi",
229 .cpu_dai_name = "samsung-i2s.0", 229 .cpu_dai_name = "samsung-i2s.0",
230 .codec_dai_name = "wm8994-aif1", 230 .codec_dai_name = "wm8994-aif1",
231 .platform_name = "samsung-audio", 231 .platform_name = "samsung-i2s.0",
232 .codec_name = "wm8994-codec.0-001a", 232 .codec_name = "wm8994-codec.0-001a",
233 .init = goni_wm8994_init, 233 .init = goni_wm8994_init,
234 .ops = &goni_hifi_ops, 234 .ops = &goni_hifi_ops,
diff --git a/sound/soc/samsung/h1940_uda1380.c b/sound/soc/samsung/h1940_uda1380.c
index 6e3257717c54..3870e9678b5d 100644
--- a/sound/soc/samsung/h1940_uda1380.c
+++ b/sound/soc/samsung/h1940_uda1380.c
@@ -207,7 +207,7 @@ static struct snd_soc_dai_link h1940_uda1380_dai[] = {
207 .cpu_dai_name = "s3c24xx-iis", 207 .cpu_dai_name = "s3c24xx-iis",
208 .codec_dai_name = "uda1380-hifi", 208 .codec_dai_name = "uda1380-hifi",
209 .init = h1940_uda1380_init, 209 .init = h1940_uda1380_init,
210 .platform_name = "samsung-audio", 210 .platform_name = "s3c24xx-iis",
211 .codec_name = "uda1380-codec.0-001a", 211 .codec_name = "uda1380-codec.0-001a",
212 .ops = &h1940_ops, 212 .ops = &h1940_ops,
213 }, 213 },
diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c
index 40b00a13dcd1..0aa0451823ce 100644
--- a/sound/soc/samsung/i2s.c
+++ b/sound/soc/samsung/i2s.c
@@ -49,8 +49,6 @@ struct i2s_dai {
49 struct clk *clk; 49 struct clk *clk;
50 /* Clock for generating I2S signals */ 50 /* Clock for generating I2S signals */
51 struct clk *op_clk; 51 struct clk *op_clk;
52 /* Array of clock names for op_clk */
53 const char **src_clk;
54 /* Pointer to the Primary_Fifo if this is Sec_Fifo, NULL otherwise */ 52 /* Pointer to the Primary_Fifo if this is Sec_Fifo, NULL otherwise */
55 struct i2s_dai *pri_dai; 53 struct i2s_dai *pri_dai;
56 /* Pointer to the Secondary_Fifo if it has one, NULL otherwise */ 54 /* Pointer to the Secondary_Fifo if it has one, NULL otherwise */
@@ -423,7 +421,7 @@ static int i2s_set_sysclk(struct snd_soc_dai *dai,
423 if (i2s->op_clk) { 421 if (i2s->op_clk) {
424 if ((clk_id && !(mod & MOD_IMS_SYSMUX)) || 422 if ((clk_id && !(mod & MOD_IMS_SYSMUX)) ||
425 (!clk_id && (mod & MOD_IMS_SYSMUX))) { 423 (!clk_id && (mod & MOD_IMS_SYSMUX))) {
426 clk_disable(i2s->op_clk); 424 clk_disable_unprepare(i2s->op_clk);
427 clk_put(i2s->op_clk); 425 clk_put(i2s->op_clk);
428 } else { 426 } else {
429 i2s->rclk_srcrate = 427 i2s->rclk_srcrate =
@@ -432,9 +430,13 @@ static int i2s_set_sysclk(struct snd_soc_dai *dai,
432 } 430 }
433 } 431 }
434 432
435 i2s->op_clk = clk_get(&i2s->pdev->dev, 433 if (clk_id)
436 i2s->src_clk[clk_id]); 434 i2s->op_clk = clk_get(&i2s->pdev->dev,
437 clk_enable(i2s->op_clk); 435 "i2s_opclk1");
436 else
437 i2s->op_clk = clk_get(&i2s->pdev->dev,
438 "i2s_opclk0");
439 clk_prepare_enable(i2s->op_clk);
438 i2s->rclk_srcrate = clk_get_rate(i2s->op_clk); 440 i2s->rclk_srcrate = clk_get_rate(i2s->op_clk);
439 441
440 /* Over-ride the other's */ 442 /* Over-ride the other's */
@@ -880,7 +882,7 @@ static int samsung_i2s_dai_probe(struct snd_soc_dai *dai)
880 iounmap(i2s->addr); 882 iounmap(i2s->addr);
881 return -ENOENT; 883 return -ENOENT;
882 } 884 }
883 clk_enable(i2s->clk); 885 clk_prepare_enable(i2s->clk);
884 886
885 if (other) { 887 if (other) {
886 other->addr = i2s->addr; 888 other->addr = i2s->addr;
@@ -922,7 +924,7 @@ static int samsung_i2s_dai_remove(struct snd_soc_dai *dai)
922 if (i2s->quirks & QUIRK_NEED_RSTCLR) 924 if (i2s->quirks & QUIRK_NEED_RSTCLR)
923 writel(0, i2s->addr + I2SCON); 925 writel(0, i2s->addr + I2SCON);
924 926
925 clk_disable(i2s->clk); 927 clk_disable_unprepare(i2s->clk);
926 clk_put(i2s->clk); 928 clk_put(i2s->clk);
927 929
928 iounmap(i2s->addr); 930 iounmap(i2s->addr);
@@ -1007,6 +1009,7 @@ static __devinit int samsung_i2s_probe(struct platform_device *pdev)
1007 sec_dai = dev_get_drvdata(&pdev->dev); 1009 sec_dai = dev_get_drvdata(&pdev->dev);
1008 snd_soc_register_dai(&sec_dai->pdev->dev, 1010 snd_soc_register_dai(&sec_dai->pdev->dev,
1009 &sec_dai->i2s_dai_drv); 1011 &sec_dai->i2s_dai_drv);
1012 asoc_dma_platform_register(&pdev->dev);
1010 return 0; 1013 return 0;
1011 } 1014 }
1012 1015
@@ -1067,7 +1070,6 @@ static __devinit int samsung_i2s_probe(struct platform_device *pdev)
1067 (struct s3c2410_dma_client *)&pri_dai->dma_capture; 1070 (struct s3c2410_dma_client *)&pri_dai->dma_capture;
1068 pri_dai->dma_playback.channel = dma_pl_chan; 1071 pri_dai->dma_playback.channel = dma_pl_chan;
1069 pri_dai->dma_capture.channel = dma_cp_chan; 1072 pri_dai->dma_capture.channel = dma_cp_chan;
1070 pri_dai->src_clk = i2s_cfg->src_clk;
1071 pri_dai->dma_playback.dma_size = 4; 1073 pri_dai->dma_playback.dma_size = 4;
1072 pri_dai->dma_capture.dma_size = 4; 1074 pri_dai->dma_capture.dma_size = 4;
1073 pri_dai->base = regs_base; 1075 pri_dai->base = regs_base;
@@ -1088,7 +1090,6 @@ static __devinit int samsung_i2s_probe(struct platform_device *pdev)
1088 (struct s3c2410_dma_client *)&sec_dai->dma_playback; 1090 (struct s3c2410_dma_client *)&sec_dai->dma_playback;
1089 /* Use iDMA always if SysDMA not provided */ 1091 /* Use iDMA always if SysDMA not provided */
1090 sec_dai->dma_playback.channel = dma_pl_sec_chan ? : -1; 1092 sec_dai->dma_playback.channel = dma_pl_sec_chan ? : -1;
1091 sec_dai->src_clk = i2s_cfg->src_clk;
1092 sec_dai->dma_playback.dma_size = 4; 1093 sec_dai->dma_playback.dma_size = 4;
1093 sec_dai->base = regs_base; 1094 sec_dai->base = regs_base;
1094 sec_dai->quirks = quirks; 1095 sec_dai->quirks = quirks;
@@ -1107,6 +1108,8 @@ static __devinit int samsung_i2s_probe(struct platform_device *pdev)
1107 1108
1108 pm_runtime_enable(&pdev->dev); 1109 pm_runtime_enable(&pdev->dev);
1109 1110
1111 asoc_dma_platform_register(&pdev->dev);
1112
1110 return 0; 1113 return 0;
1111err: 1114err:
1112 release_mem_region(regs_base, resource_size(res)); 1115 release_mem_region(regs_base, resource_size(res));
@@ -1135,6 +1138,7 @@ static __devexit int samsung_i2s_remove(struct platform_device *pdev)
1135 i2s->pri_dai = NULL; 1138 i2s->pri_dai = NULL;
1136 i2s->sec_dai = NULL; 1139 i2s->sec_dai = NULL;
1137 1140
1141 asoc_dma_platform_unregister(&pdev->dev);
1138 snd_soc_unregister_dai(&pdev->dev); 1142 snd_soc_unregister_dai(&pdev->dev);
1139 1143
1140 return 0; 1144 return 0;
diff --git a/sound/soc/samsung/jive_wm8750.c b/sound/soc/samsung/jive_wm8750.c
index 1578663a1faa..b5f6abd9d221 100644
--- a/sound/soc/samsung/jive_wm8750.c
+++ b/sound/soc/samsung/jive_wm8750.c
@@ -118,7 +118,7 @@ static struct snd_soc_dai_link jive_dai = {
118 .stream_name = "WM8750", 118 .stream_name = "WM8750",
119 .cpu_dai_name = "s3c2412-i2s", 119 .cpu_dai_name = "s3c2412-i2s",
120 .codec_dai_name = "wm8750-hifi", 120 .codec_dai_name = "wm8750-hifi",
121 .platform_name = "samsung-audio", 121 .platform_name = "s3c2412-i2s",
122 .codec_name = "wm8750.0-001a", 122 .codec_name = "wm8750.0-001a",
123 .init = jive_wm8750_init, 123 .init = jive_wm8750_init,
124 .ops = &jive_ops, 124 .ops = &jive_ops,
diff --git a/sound/soc/samsung/littlemill.c b/sound/soc/samsung/littlemill.c
index ee52c8a00779..0908bb05a5e7 100644
--- a/sound/soc/samsung/littlemill.c
+++ b/sound/soc/samsung/littlemill.c
@@ -145,7 +145,7 @@ static struct snd_soc_dai_link littlemill_dai[] = {
145 .stream_name = "CPU", 145 .stream_name = "CPU",
146 .cpu_dai_name = "samsung-i2s.0", 146 .cpu_dai_name = "samsung-i2s.0",
147 .codec_dai_name = "wm8994-aif1", 147 .codec_dai_name = "wm8994-aif1",
148 .platform_name = "samsung-audio", 148 .platform_name = "samsung-i2s.0",
149 .codec_name = "wm8994-codec", 149 .codec_name = "wm8994-codec",
150 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF 150 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
151 | SND_SOC_DAIFMT_CBM_CFM, 151 | SND_SOC_DAIFMT_CBM_CFM,
diff --git a/sound/soc/samsung/ln2440sbc_alc650.c b/sound/soc/samsung/ln2440sbc_alc650.c
index 69c4a5934a4d..9342fc270c2b 100644
--- a/sound/soc/samsung/ln2440sbc_alc650.c
+++ b/sound/soc/samsung/ln2440sbc_alc650.c
@@ -28,7 +28,7 @@ static struct snd_soc_dai_link ln2440sbc_dai[] = {
28 .cpu_dai_name = "samsung-ac97", 28 .cpu_dai_name = "samsung-ac97",
29 .codec_dai_name = "ac97-hifi", 29 .codec_dai_name = "ac97-hifi",
30 .codec_name = "ac97-codec", 30 .codec_name = "ac97-codec",
31 .platform_name = "samsung-audio", 31 .platform_name = "samsung-ac97",
32}, 32},
33}; 33};
34 34
diff --git a/sound/soc/samsung/lowland.c b/sound/soc/samsung/lowland.c
index 6abf341c4a2a..a71c31af4e0e 100644
--- a/sound/soc/samsung/lowland.c
+++ b/sound/soc/samsung/lowland.c
@@ -99,7 +99,7 @@ static struct snd_soc_dai_link lowland_dai[] = {
99 .stream_name = "CPU", 99 .stream_name = "CPU",
100 .cpu_dai_name = "samsung-i2s.0", 100 .cpu_dai_name = "samsung-i2s.0",
101 .codec_dai_name = "wm5100-aif1", 101 .codec_dai_name = "wm5100-aif1",
102 .platform_name = "samsung-audio", 102 .platform_name = "samsung-i2s.0",
103 .codec_name = "wm5100.1-001a", 103 .codec_name = "wm5100.1-001a",
104 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | 104 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
105 SND_SOC_DAIFMT_CBM_CFM, 105 SND_SOC_DAIFMT_CBM_CFM,
diff --git a/sound/soc/samsung/neo1973_wm8753.c b/sound/soc/samsung/neo1973_wm8753.c
index 321d51134e47..c7e965f80d2e 100644
--- a/sound/soc/samsung/neo1973_wm8753.c
+++ b/sound/soc/samsung/neo1973_wm8753.c
@@ -364,7 +364,7 @@ static struct snd_soc_dai_link neo1973_dai[] = {
364{ /* Hifi Playback - for similatious use with voice below */ 364{ /* Hifi Playback - for similatious use with voice below */
365 .name = "WM8753", 365 .name = "WM8753",
366 .stream_name = "WM8753 HiFi", 366 .stream_name = "WM8753 HiFi",
367 .platform_name = "samsung-audio", 367 .platform_name = "s3c24xx-iis",
368 .cpu_dai_name = "s3c24xx-iis", 368 .cpu_dai_name = "s3c24xx-iis",
369 .codec_dai_name = "wm8753-hifi", 369 .codec_dai_name = "wm8753-hifi",
370 .codec_name = "wm8753.0-001a", 370 .codec_name = "wm8753.0-001a",
diff --git a/sound/soc/samsung/pcm.c b/sound/soc/samsung/pcm.c
index c86081992dfd..ecd509048771 100644
--- a/sound/soc/samsung/pcm.c
+++ b/sound/soc/samsung/pcm.c
@@ -543,7 +543,7 @@ static __devinit int s3c_pcm_dev_probe(struct platform_device *pdev)
543 ret = PTR_ERR(pcm->cclk); 543 ret = PTR_ERR(pcm->cclk);
544 goto err1; 544 goto err1;
545 } 545 }
546 clk_enable(pcm->cclk); 546 clk_prepare_enable(pcm->cclk);
547 547
548 /* record our pcm structure for later use in the callbacks */ 548 /* record our pcm structure for later use in the callbacks */
549 dev_set_drvdata(&pdev->dev, pcm); 549 dev_set_drvdata(&pdev->dev, pcm);
@@ -568,7 +568,7 @@ static __devinit int s3c_pcm_dev_probe(struct platform_device *pdev)
568 ret = -ENOENT; 568 ret = -ENOENT;
569 goto err4; 569 goto err4;
570 } 570 }
571 clk_enable(pcm->pclk); 571 clk_prepare_enable(pcm->pclk);
572 572
573 s3c_pcm_stereo_in[pdev->id].dma_addr = mem_res->start 573 s3c_pcm_stereo_in[pdev->id].dma_addr = mem_res->start
574 + S3C_PCM_RXFIFO; 574 + S3C_PCM_RXFIFO;
@@ -589,17 +589,25 @@ static __devinit int s3c_pcm_dev_probe(struct platform_device *pdev)
589 goto err5; 589 goto err5;
590 } 590 }
591 591
592 ret = asoc_dma_platform_register(&pdev->dev);
593 if (ret) {
594 dev_err(&pdev->dev, "failed to get register DMA: %d\n", ret);
595 goto err6;
596 }
597
592 return 0; 598 return 0;
593 599
600err6:
601 snd_soc_unregister_dai(&pdev->dev);
594err5: 602err5:
595 clk_disable(pcm->pclk); 603 clk_disable_unprepare(pcm->pclk);
596 clk_put(pcm->pclk); 604 clk_put(pcm->pclk);
597err4: 605err4:
598 iounmap(pcm->regs); 606 iounmap(pcm->regs);
599err3: 607err3:
600 release_mem_region(mem_res->start, resource_size(mem_res)); 608 release_mem_region(mem_res->start, resource_size(mem_res));
601err2: 609err2:
602 clk_disable(pcm->cclk); 610 clk_disable_unprepare(pcm->cclk);
603 clk_put(pcm->cclk); 611 clk_put(pcm->cclk);
604err1: 612err1:
605 return ret; 613 return ret;
@@ -610,6 +618,7 @@ static __devexit int s3c_pcm_dev_remove(struct platform_device *pdev)
610 struct s3c_pcm_info *pcm = &s3c_pcm[pdev->id]; 618 struct s3c_pcm_info *pcm = &s3c_pcm[pdev->id];
611 struct resource *mem_res; 619 struct resource *mem_res;
612 620
621 asoc_dma_platform_unregister(&pdev->dev);
613 snd_soc_unregister_dai(&pdev->dev); 622 snd_soc_unregister_dai(&pdev->dev);
614 623
615 pm_runtime_disable(&pdev->dev); 624 pm_runtime_disable(&pdev->dev);
@@ -619,8 +628,8 @@ static __devexit int s3c_pcm_dev_remove(struct platform_device *pdev)
619 mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 628 mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
620 release_mem_region(mem_res->start, resource_size(mem_res)); 629 release_mem_region(mem_res->start, resource_size(mem_res));
621 630
622 clk_disable(pcm->cclk); 631 clk_disable_unprepare(pcm->cclk);
623 clk_disable(pcm->pclk); 632 clk_disable_unprepare(pcm->pclk);
624 clk_put(pcm->pclk); 633 clk_put(pcm->pclk);
625 clk_put(pcm->cclk); 634 clk_put(pcm->cclk);
626 635
diff --git a/sound/soc/samsung/rx1950_uda1380.c b/sound/soc/samsung/rx1950_uda1380.c
index 21e12361a9cd..a5826ea9cad6 100644
--- a/sound/soc/samsung/rx1950_uda1380.c
+++ b/sound/soc/samsung/rx1950_uda1380.c
@@ -85,7 +85,7 @@ static struct snd_soc_dai_link rx1950_uda1380_dai[] = {
85 .cpu_dai_name = "s3c24xx-iis", 85 .cpu_dai_name = "s3c24xx-iis",
86 .codec_dai_name = "uda1380-hifi", 86 .codec_dai_name = "uda1380-hifi",
87 .init = rx1950_uda1380_init, 87 .init = rx1950_uda1380_init,
88 .platform_name = "samsung-audio", 88 .platform_name = "s3c24xx-iis",
89 .codec_name = "uda1380-codec.0-001a", 89 .codec_name = "uda1380-codec.0-001a",
90 .ops = &rx1950_ops, 90 .ops = &rx1950_ops,
91 }, 91 },
diff --git a/sound/soc/samsung/s3c2412-i2s.c b/sound/soc/samsung/s3c2412-i2s.c
index ac7701b3c5dc..edf5f527c5a2 100644
--- a/sound/soc/samsung/s3c2412-i2s.c
+++ b/sound/soc/samsung/s3c2412-i2s.c
@@ -162,11 +162,29 @@ static struct snd_soc_dai_driver s3c2412_i2s_dai = {
162 162
163static __devinit int s3c2412_iis_dev_probe(struct platform_device *pdev) 163static __devinit int s3c2412_iis_dev_probe(struct platform_device *pdev)
164{ 164{
165 return s3c_i2sv2_register_dai(&pdev->dev, -1, &s3c2412_i2s_dai); 165 int ret = 0;
166
167 ret = s3c_i2sv2_register_dai(&pdev->dev, -1, &s3c2412_i2s_dai);
168 if (ret) {
169 pr_err("failed to register the dai\n");
170 return ret;
171 }
172
173 ret = asoc_dma_platform_register(&pdev->dev);
174 if (ret) {
175 pr_err("failed to register the DMA: %d\n", ret);
176 goto err;
177 }
178
179 return 0;
180err:
181 snd_soc_unregister_dai(&pdev->dev);
182 return ret;
166} 183}
167 184
168static __devexit int s3c2412_iis_dev_remove(struct platform_device *pdev) 185static __devexit int s3c2412_iis_dev_remove(struct platform_device *pdev)
169{ 186{
187 asoc_dma_platform_unregister(&pdev->dev);
170 snd_soc_unregister_dai(&pdev->dev); 188 snd_soc_unregister_dai(&pdev->dev);
171 return 0; 189 return 0;
172} 190}
diff --git a/sound/soc/samsung/s3c24xx-i2s.c b/sound/soc/samsung/s3c24xx-i2s.c
index 0aae3a3883dc..0022d51fd160 100644
--- a/sound/soc/samsung/s3c24xx-i2s.c
+++ b/sound/soc/samsung/s3c24xx-i2s.c
@@ -467,11 +467,29 @@ static struct snd_soc_dai_driver s3c24xx_i2s_dai = {
467 467
468static __devinit int s3c24xx_iis_dev_probe(struct platform_device *pdev) 468static __devinit int s3c24xx_iis_dev_probe(struct platform_device *pdev)
469{ 469{
470 return snd_soc_register_dai(&pdev->dev, &s3c24xx_i2s_dai); 470 int ret = 0;
471
472 ret = s3c_i2sv2_register_dai(&pdev->dev, -1, &s3c2412_i2s_dai);
473 if (ret) {
474 pr_err("failed to register the dai\n");
475 return ret;
476 }
477
478 ret = asoc_dma_platform_register(&pdev->dev);
479 if (ret) {
480 pr_err("failed to register the dma: %d\n", ret);
481 goto err;
482 }
483
484 return 0;
485err:
486 snd_soc_unregister_dai(&pdev->dev);
487 return ret;
471} 488}
472 489
473static __devexit int s3c24xx_iis_dev_remove(struct platform_device *pdev) 490static __devexit int s3c24xx_iis_dev_remove(struct platform_device *pdev)
474{ 491{
492 asoc_dma_platform_unregister(&pdev->dev);
475 snd_soc_unregister_dai(&pdev->dev); 493 snd_soc_unregister_dai(&pdev->dev);
476 return 0; 494 return 0;
477} 495}
diff --git a/sound/soc/samsung/s3c24xx_simtec_hermes.c b/sound/soc/samsung/s3c24xx_simtec_hermes.c
index 7ace6a87f41b..befabe8979f7 100644
--- a/sound/soc/samsung/s3c24xx_simtec_hermes.c
+++ b/sound/soc/samsung/s3c24xx_simtec_hermes.c
@@ -82,7 +82,7 @@ static struct snd_soc_dai_link simtec_dai_aic33 = {
82 .codec_name = "tlv320aic3x-codec.0-001a", 82 .codec_name = "tlv320aic3x-codec.0-001a",
83 .cpu_dai_name = "s3c24xx-iis", 83 .cpu_dai_name = "s3c24xx-iis",
84 .codec_dai_name = "tlv320aic3x-hifi", 84 .codec_dai_name = "tlv320aic3x-hifi",
85 .platform_name = "samsung-audio", 85 .platform_name = "s3c24xx-iis",
86 .init = simtec_hermes_init, 86 .init = simtec_hermes_init,
87}; 87};
88 88
diff --git a/sound/soc/samsung/s3c24xx_simtec_tlv320aic23.c b/sound/soc/samsung/s3c24xx_simtec_tlv320aic23.c
index c42d5f00b0e1..5552f82c92a7 100644
--- a/sound/soc/samsung/s3c24xx_simtec_tlv320aic23.c
+++ b/sound/soc/samsung/s3c24xx_simtec_tlv320aic23.c
@@ -71,7 +71,7 @@ static struct snd_soc_dai_link simtec_dai_aic23 = {
71 .codec_name = "tlv320aic3x-codec.0-001a", 71 .codec_name = "tlv320aic3x-codec.0-001a",
72 .cpu_dai_name = "s3c24xx-iis", 72 .cpu_dai_name = "s3c24xx-iis",
73 .codec_dai_name = "tlv320aic3x-hifi", 73 .codec_dai_name = "tlv320aic3x-hifi",
74 .platform_name = "samsung-audio", 74 .platform_name = "s3c24xx-iis",
75 .init = simtec_tlv320aic23_init, 75 .init = simtec_tlv320aic23_init,
76}; 76};
77 77
diff --git a/sound/soc/samsung/s3c24xx_uda134x.c b/sound/soc/samsung/s3c24xx_uda134x.c
index d731042e51b0..333e1b7f06c7 100644
--- a/sound/soc/samsung/s3c24xx_uda134x.c
+++ b/sound/soc/samsung/s3c24xx_uda134x.c
@@ -224,7 +224,7 @@ static struct snd_soc_dai_link s3c24xx_uda134x_dai_link = {
224 .codec_dai_name = "uda134x-hifi", 224 .codec_dai_name = "uda134x-hifi",
225 .cpu_dai_name = "s3c24xx-iis", 225 .cpu_dai_name = "s3c24xx-iis",
226 .ops = &s3c24xx_uda134x_ops, 226 .ops = &s3c24xx_uda134x_ops,
227 .platform_name = "samsung-audio", 227 .platform_name = "s3c24xx-iis",
228}; 228};
229 229
230static struct snd_soc_card snd_soc_s3c24xx_uda134x = { 230static struct snd_soc_card snd_soc_s3c24xx_uda134x = {
diff --git a/sound/soc/samsung/smartq_wm8987.c b/sound/soc/samsung/smartq_wm8987.c
index f2dcb424ea25..58ae3237ef69 100644
--- a/sound/soc/samsung/smartq_wm8987.c
+++ b/sound/soc/samsung/smartq_wm8987.c
@@ -189,7 +189,7 @@ static struct snd_soc_dai_link smartq_dai[] = {
189 .stream_name = "SmartQ Hi-Fi", 189 .stream_name = "SmartQ Hi-Fi",
190 .cpu_dai_name = "samsung-i2s.0", 190 .cpu_dai_name = "samsung-i2s.0",
191 .codec_dai_name = "wm8750-hifi", 191 .codec_dai_name = "wm8750-hifi",
192 .platform_name = "samsung-audio", 192 .platform_name = "samsung-i2s.0",
193 .codec_name = "wm8750.0-0x1a", 193 .codec_name = "wm8750.0-0x1a",
194 .init = smartq_wm8987_init, 194 .init = smartq_wm8987_init,
195 .ops = &smartq_hifi_ops, 195 .ops = &smartq_hifi_ops,
diff --git a/sound/soc/samsung/smdk2443_wm9710.c b/sound/soc/samsung/smdk2443_wm9710.c
index 720ba29bb7e4..c390aad68cfb 100644
--- a/sound/soc/samsung/smdk2443_wm9710.c
+++ b/sound/soc/samsung/smdk2443_wm9710.c
@@ -24,7 +24,7 @@ static struct snd_soc_dai_link smdk2443_dai[] = {
24 .cpu_dai_name = "samsung-ac97", 24 .cpu_dai_name = "samsung-ac97",
25 .codec_dai_name = "ac97-hifi", 25 .codec_dai_name = "ac97-hifi",
26 .codec_name = "ac97-codec", 26 .codec_name = "ac97-codec",
27 .platform_name = "samsung-audio", 27 .platform_name = "samsung-ac97",
28}, 28},
29}; 29};
30 30
diff --git a/sound/soc/samsung/smdk_spdif.c b/sound/soc/samsung/smdk_spdif.c
index beaa9c15d697..a2f2363fe1c2 100644
--- a/sound/soc/samsung/smdk_spdif.c
+++ b/sound/soc/samsung/smdk_spdif.c
@@ -151,7 +151,7 @@ static struct snd_soc_ops smdk_spdif_ops = {
151static struct snd_soc_dai_link smdk_dai = { 151static struct snd_soc_dai_link smdk_dai = {
152 .name = "S/PDIF", 152 .name = "S/PDIF",
153 .stream_name = "S/PDIF PCM Playback", 153 .stream_name = "S/PDIF PCM Playback",
154 .platform_name = "samsung-audio", 154 .platform_name = "samsung-spdif",
155 .cpu_dai_name = "samsung-spdif", 155 .cpu_dai_name = "samsung-spdif",
156 .codec_dai_name = "dit-hifi", 156 .codec_dai_name = "dit-hifi",
157 .codec_name = "spdif-dit", 157 .codec_name = "spdif-dit",
diff --git a/sound/soc/samsung/smdk_wm8580.c b/sound/soc/samsung/smdk_wm8580.c
index ade2809cf393..7e2b710763be 100644
--- a/sound/soc/samsung/smdk_wm8580.c
+++ b/sound/soc/samsung/smdk_wm8580.c
@@ -176,7 +176,7 @@ static struct snd_soc_dai_link smdk_dai[] = {
176 .stream_name = "Playback", 176 .stream_name = "Playback",
177 .cpu_dai_name = "samsung-i2s.0", 177 .cpu_dai_name = "samsung-i2s.0",
178 .codec_dai_name = "wm8580-hifi-playback", 178 .codec_dai_name = "wm8580-hifi-playback",
179 .platform_name = "samsung-audio", 179 .platform_name = "samsung-i2s.0",
180 .codec_name = "wm8580.0-001b", 180 .codec_name = "wm8580.0-001b",
181 .ops = &smdk_ops, 181 .ops = &smdk_ops,
182 }, 182 },
@@ -185,7 +185,7 @@ static struct snd_soc_dai_link smdk_dai[] = {
185 .stream_name = "Capture", 185 .stream_name = "Capture",
186 .cpu_dai_name = "samsung-i2s.0", 186 .cpu_dai_name = "samsung-i2s.0",
187 .codec_dai_name = "wm8580-hifi-capture", 187 .codec_dai_name = "wm8580-hifi-capture",
188 .platform_name = "samsung-audio", 188 .platform_name = "samsung-i2s.0",
189 .codec_name = "wm8580.0-001b", 189 .codec_name = "wm8580.0-001b",
190 .init = smdk_wm8580_init_paiftx, 190 .init = smdk_wm8580_init_paiftx,
191 .ops = &smdk_ops, 191 .ops = &smdk_ops,
@@ -195,7 +195,7 @@ static struct snd_soc_dai_link smdk_dai[] = {
195 .stream_name = "Playback", 195 .stream_name = "Playback",
196 .cpu_dai_name = "samsung-i2s.x", 196 .cpu_dai_name = "samsung-i2s.x",
197 .codec_dai_name = "wm8580-hifi-playback", 197 .codec_dai_name = "wm8580-hifi-playback",
198 .platform_name = "samsung-audio", 198 .platform_name = "samsung-i2s.x",
199 .codec_name = "wm8580.0-001b", 199 .codec_name = "wm8580.0-001b",
200 .ops = &smdk_ops, 200 .ops = &smdk_ops,
201 }, 201 },
diff --git a/sound/soc/samsung/smdk_wm8580pcm.c b/sound/soc/samsung/smdk_wm8580pcm.c
index fab5322e9f05..34239fe9afde 100644
--- a/sound/soc/samsung/smdk_wm8580pcm.c
+++ b/sound/soc/samsung/smdk_wm8580pcm.c
@@ -135,7 +135,7 @@ static struct snd_soc_dai_link smdk_dai[] = {
135 .stream_name = "Capture", 135 .stream_name = "Capture",
136 .cpu_dai_name = "samsung-pcm.0", 136 .cpu_dai_name = "samsung-pcm.0",
137 .codec_dai_name = "wm8580-hifi-capture", 137 .codec_dai_name = "wm8580-hifi-capture",
138 .platform_name = "samsung-audio", 138 .platform_name = "samsung-pcm.0",
139 .codec_name = "wm8580.0-001b", 139 .codec_name = "wm8580.0-001b",
140 .ops = &smdk_wm8580_pcm_ops, 140 .ops = &smdk_wm8580_pcm_ops,
141 }, 141 },
diff --git a/sound/soc/samsung/smdk_wm8994.c b/sound/soc/samsung/smdk_wm8994.c
index 48dd4dd9ee08..dd0aa8cb1a9e 100644
--- a/sound/soc/samsung/smdk_wm8994.c
+++ b/sound/soc/samsung/smdk_wm8994.c
@@ -127,7 +127,7 @@ static struct snd_soc_dai_link smdk_dai[] = {
127 .stream_name = "Pri_Dai", 127 .stream_name = "Pri_Dai",
128 .cpu_dai_name = "samsung-i2s.0", 128 .cpu_dai_name = "samsung-i2s.0",
129 .codec_dai_name = "wm8994-aif1", 129 .codec_dai_name = "wm8994-aif1",
130 .platform_name = "samsung-audio", 130 .platform_name = "samsung-i2s.0",
131 .codec_name = "wm8994-codec", 131 .codec_name = "wm8994-codec",
132 .init = smdk_wm8994_init_paiftx, 132 .init = smdk_wm8994_init_paiftx,
133 .ops = &smdk_ops, 133 .ops = &smdk_ops,
@@ -136,7 +136,7 @@ static struct snd_soc_dai_link smdk_dai[] = {
136 .stream_name = "Sec_Dai", 136 .stream_name = "Sec_Dai",
137 .cpu_dai_name = "samsung-i2s.4", 137 .cpu_dai_name = "samsung-i2s.4",
138 .codec_dai_name = "wm8994-aif1", 138 .codec_dai_name = "wm8994-aif1",
139 .platform_name = "samsung-audio", 139 .platform_name = "samsung-i2s.4",
140 .codec_name = "wm8994-codec", 140 .codec_name = "wm8994-codec",
141 .ops = &smdk_ops, 141 .ops = &smdk_ops,
142 }, 142 },
diff --git a/sound/soc/samsung/smdk_wm8994pcm.c b/sound/soc/samsung/smdk_wm8994pcm.c
index 77ecba935119..15f6b44e9de3 100644
--- a/sound/soc/samsung/smdk_wm8994pcm.c
+++ b/sound/soc/samsung/smdk_wm8994pcm.c
@@ -116,7 +116,7 @@ static struct snd_soc_dai_link smdk_dai[] = {
116 .stream_name = "Primary PCM", 116 .stream_name = "Primary PCM",
117 .cpu_dai_name = "samsung-pcm.0", 117 .cpu_dai_name = "samsung-pcm.0",
118 .codec_dai_name = "wm8994-aif1", 118 .codec_dai_name = "wm8994-aif1",
119 .platform_name = "samsung-audio", 119 .platform_name = "samsung-pcm.0",
120 .codec_name = "wm8994-codec", 120 .codec_name = "wm8994-codec",
121 .ops = &smdk_wm8994_pcm_ops, 121 .ops = &smdk_wm8994_pcm_ops,
122 }, 122 },
diff --git a/sound/soc/samsung/smdk_wm9713.c b/sound/soc/samsung/smdk_wm9713.c
index 55b2ca7f3290..0d20e4ed27aa 100644
--- a/sound/soc/samsung/smdk_wm9713.c
+++ b/sound/soc/samsung/smdk_wm9713.c
@@ -42,7 +42,7 @@ static struct snd_soc_card smdk;
42static struct snd_soc_dai_link smdk_dai = { 42static struct snd_soc_dai_link smdk_dai = {
43 .name = "AC97", 43 .name = "AC97",
44 .stream_name = "AC97 PCM", 44 .stream_name = "AC97 PCM",
45 .platform_name = "samsung-audio", 45 .platform_name = "samsung-ac97",
46 .cpu_dai_name = "samsung-ac97", 46 .cpu_dai_name = "samsung-ac97",
47 .codec_dai_name = "wm9713-hifi", 47 .codec_dai_name = "wm9713-hifi",
48 .codec_name = "wm9713-codec", 48 .codec_name = "wm9713-codec",
diff --git a/sound/soc/samsung/spdif.c b/sound/soc/samsung/spdif.c
index bc24c7af02b2..8606fc6cb37d 100644
--- a/sound/soc/samsung/spdif.c
+++ b/sound/soc/samsung/spdif.c
@@ -397,7 +397,7 @@ static __devinit int spdif_probe(struct platform_device *pdev)
397 ret = -ENOENT; 397 ret = -ENOENT;
398 goto err0; 398 goto err0;
399 } 399 }
400 clk_enable(spdif->pclk); 400 clk_prepare_enable(spdif->pclk);
401 401
402 spdif->sclk = clk_get(&pdev->dev, "sclk_spdif"); 402 spdif->sclk = clk_get(&pdev->dev, "sclk_spdif");
403 if (IS_ERR(spdif->sclk)) { 403 if (IS_ERR(spdif->sclk)) {
@@ -405,7 +405,7 @@ static __devinit int spdif_probe(struct platform_device *pdev)
405 ret = -ENOENT; 405 ret = -ENOENT;
406 goto err1; 406 goto err1;
407 } 407 }
408 clk_enable(spdif->sclk); 408 clk_prepare_enable(spdif->sclk);
409 409
410 /* Request S/PDIF Register's memory region */ 410 /* Request S/PDIF Register's memory region */
411 if (!request_mem_region(mem_res->start, 411 if (!request_mem_region(mem_res->start,
@@ -437,17 +437,24 @@ static __devinit int spdif_probe(struct platform_device *pdev)
437 437
438 spdif->dma_playback = &spdif_stereo_out; 438 spdif->dma_playback = &spdif_stereo_out;
439 439
440 return 0; 440 ret = asoc_dma_platform_register(&pdev->dev);
441 if (ret) {
442 dev_err(&pdev->dev, "failed to register DMA: %d\n", ret);
443 goto err5;
444 }
441 445
446 return 0;
447err5:
448 snd_soc_unregister_dai(&pdev->dev);
442err4: 449err4:
443 iounmap(spdif->regs); 450 iounmap(spdif->regs);
444err3: 451err3:
445 release_mem_region(mem_res->start, resource_size(mem_res)); 452 release_mem_region(mem_res->start, resource_size(mem_res));
446err2: 453err2:
447 clk_disable(spdif->sclk); 454 clk_disable_unprepare(spdif->sclk);
448 clk_put(spdif->sclk); 455 clk_put(spdif->sclk);
449err1: 456err1:
450 clk_disable(spdif->pclk); 457 clk_disable_unprepare(spdif->pclk);
451 clk_put(spdif->pclk); 458 clk_put(spdif->pclk);
452err0: 459err0:
453 return ret; 460 return ret;
@@ -458,6 +465,7 @@ static __devexit int spdif_remove(struct platform_device *pdev)
458 struct samsung_spdif_info *spdif = &spdif_info; 465 struct samsung_spdif_info *spdif = &spdif_info;
459 struct resource *mem_res; 466 struct resource *mem_res;
460 467
468 asoc_dma_platform_unregister(&pdev->dev);
461 snd_soc_unregister_dai(&pdev->dev); 469 snd_soc_unregister_dai(&pdev->dev);
462 470
463 iounmap(spdif->regs); 471 iounmap(spdif->regs);
@@ -466,9 +474,9 @@ static __devexit int spdif_remove(struct platform_device *pdev)
466 if (mem_res) 474 if (mem_res)
467 release_mem_region(mem_res->start, resource_size(mem_res)); 475 release_mem_region(mem_res->start, resource_size(mem_res));
468 476
469 clk_disable(spdif->sclk); 477 clk_disable_unprepare(spdif->sclk);
470 clk_put(spdif->sclk); 478 clk_put(spdif->sclk);
471 clk_disable(spdif->pclk); 479 clk_disable_unprepare(spdif->pclk);
472 clk_put(spdif->pclk); 480 clk_put(spdif->pclk);
473 481
474 return 0; 482 return 0;
diff --git a/sound/soc/samsung/speyside.c b/sound/soc/samsung/speyside.c
index c7e1c28528a4..d7906a144195 100644
--- a/sound/soc/samsung/speyside.c
+++ b/sound/soc/samsung/speyside.c
@@ -198,7 +198,7 @@ static struct snd_soc_dai_link speyside_dai[] = {
198 .stream_name = "CPU-DSP", 198 .stream_name = "CPU-DSP",
199 .cpu_dai_name = "samsung-i2s.0", 199 .cpu_dai_name = "samsung-i2s.0",
200 .codec_dai_name = "wm0010-sdi1", 200 .codec_dai_name = "wm0010-sdi1",
201 .platform_name = "samsung-audio", 201 .platform_name = "samsung-i2s.0",
202 .codec_name = "spi0.0", 202 .codec_name = "spi0.0",
203 .init = speyside_wm0010_init, 203 .init = speyside_wm0010_init,
204 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF 204 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
diff --git a/sound/soc/samsung/tobermory.c b/sound/soc/samsung/tobermory.c
index 9199649bf786..42e4c8e6b03e 100644
--- a/sound/soc/samsung/tobermory.c
+++ b/sound/soc/samsung/tobermory.c
@@ -110,7 +110,7 @@ static struct snd_soc_dai_link tobermory_dai[] = {
110 .stream_name = "CPU", 110 .stream_name = "CPU",
111 .cpu_dai_name = "samsung-i2s.0", 111 .cpu_dai_name = "samsung-i2s.0",
112 .codec_dai_name = "wm8962", 112 .codec_dai_name = "wm8962",
113 .platform_name = "samsung-audio", 113 .platform_name = "samsung-i2s.0",
114 .codec_name = "wm8962.1-001a", 114 .codec_name = "wm8962.1-001a",
115 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF 115 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
116 | SND_SOC_DAIFMT_CBM_CFM, 116 | SND_SOC_DAIFMT_CBM_CFM,
diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c
index 9d7f30774a44..a606d0f93d1c 100644
--- a/sound/soc/sh/fsi.c
+++ b/sound/soc/sh/fsi.c
@@ -22,6 +22,7 @@
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/workqueue.h> 23#include <linux/workqueue.h>
24#include <sound/soc.h> 24#include <sound/soc.h>
25#include <sound/pcm_params.h>
25#include <sound/sh_fsi.h> 26#include <sound/sh_fsi.h>
26 27
27/* PortA/PortB register */ 28/* PortA/PortB register */
@@ -189,6 +190,14 @@ typedef int (*set_rate_func)(struct device *dev, int rate, int enable);
189 */ 190 */
190 191
191/* 192/*
193 * FSI clock
194 *
195 * FSIxCLK [CPG] (ick) -------> |
196 * |-> FSI_DIV (div)-> FSI2
197 * FSIxCK [external] (xck) ---> |
198 */
199
200/*
192 * struct 201 * struct
193 */ 202 */
194 203
@@ -228,6 +237,20 @@ struct fsi_stream {
228 dma_addr_t dma; 237 dma_addr_t dma;
229}; 238};
230 239
240struct fsi_clk {
241 /* see [FSI clock] */
242 struct clk *own;
243 struct clk *xck;
244 struct clk *ick;
245 struct clk *div;
246 int (*set_rate)(struct device *dev,
247 struct fsi_priv *fsi,
248 unsigned long rate);
249
250 unsigned long rate;
251 unsigned int count;
252};
253
231struct fsi_priv { 254struct fsi_priv {
232 void __iomem *base; 255 void __iomem *base;
233 struct fsi_master *master; 256 struct fsi_master *master;
@@ -236,11 +259,17 @@ struct fsi_priv {
236 struct fsi_stream playback; 259 struct fsi_stream playback;
237 struct fsi_stream capture; 260 struct fsi_stream capture;
238 261
262 struct fsi_clk clock;
263
239 u32 fmt; 264 u32 fmt;
240 265
241 int chan_num:16; 266 int chan_num:16;
242 int clk_master:1; 267 int clk_master:1;
268 int clk_cpg:1;
243 int spdif:1; 269 int spdif:1;
270 int enable_stream:1;
271 int bit_clk_inv:1;
272 int lr_clk_inv:1;
244 273
245 long rate; 274 long rate;
246}; 275};
@@ -370,6 +399,11 @@ static int fsi_is_spdif(struct fsi_priv *fsi)
370 return fsi->spdif; 399 return fsi->spdif;
371} 400}
372 401
402static int fsi_is_enable_stream(struct fsi_priv *fsi)
403{
404 return fsi->enable_stream;
405}
406
373static int fsi_is_play(struct snd_pcm_substream *substream) 407static int fsi_is_play(struct snd_pcm_substream *substream)
374{ 408{
375 return substream->stream == SNDRV_PCM_STREAM_PLAYBACK; 409 return substream->stream == SNDRV_PCM_STREAM_PLAYBACK;
@@ -717,14 +751,335 @@ static void fsi_spdif_clk_ctrl(struct fsi_priv *fsi, int enable)
717/* 751/*
718 * clock function 752 * clock function
719 */ 753 */
754static int fsi_clk_init(struct device *dev,
755 struct fsi_priv *fsi,
756 int xck,
757 int ick,
758 int div,
759 int (*set_rate)(struct device *dev,
760 struct fsi_priv *fsi,
761 unsigned long rate))
762{
763 struct fsi_clk *clock = &fsi->clock;
764 int is_porta = fsi_is_port_a(fsi);
765
766 clock->xck = NULL;
767 clock->ick = NULL;
768 clock->div = NULL;
769 clock->rate = 0;
770 clock->count = 0;
771 clock->set_rate = set_rate;
772
773 clock->own = devm_clk_get(dev, NULL);
774 if (IS_ERR(clock->own))
775 return -EINVAL;
776
777 /* external clock */
778 if (xck) {
779 clock->xck = devm_clk_get(dev, is_porta ? "xcka" : "xckb");
780 if (IS_ERR(clock->xck)) {
781 dev_err(dev, "can't get xck clock\n");
782 return -EINVAL;
783 }
784 if (clock->xck == clock->own) {
785 dev_err(dev, "cpu doesn't support xck clock\n");
786 return -EINVAL;
787 }
788 }
789
790 /* FSIACLK/FSIBCLK */
791 if (ick) {
792 clock->ick = devm_clk_get(dev, is_porta ? "icka" : "ickb");
793 if (IS_ERR(clock->ick)) {
794 dev_err(dev, "can't get ick clock\n");
795 return -EINVAL;
796 }
797 if (clock->ick == clock->own) {
798 dev_err(dev, "cpu doesn't support ick clock\n");
799 return -EINVAL;
800 }
801 }
802
803 /* FSI-DIV */
804 if (div) {
805 clock->div = devm_clk_get(dev, is_porta ? "diva" : "divb");
806 if (IS_ERR(clock->div)) {
807 dev_err(dev, "can't get div clock\n");
808 return -EINVAL;
809 }
810 if (clock->div == clock->own) {
811 dev_err(dev, "cpu doens't support div clock\n");
812 return -EINVAL;
813 }
814 }
815
816 return 0;
817}
818
819#define fsi_clk_invalid(fsi) fsi_clk_valid(fsi, 0)
820static void fsi_clk_valid(struct fsi_priv *fsi, unsigned long rate)
821{
822 fsi->clock.rate = rate;
823}
824
825static int fsi_clk_is_valid(struct fsi_priv *fsi)
826{
827 return fsi->clock.set_rate &&
828 fsi->clock.rate;
829}
830
831static int fsi_clk_enable(struct device *dev,
832 struct fsi_priv *fsi,
833 unsigned long rate)
834{
835 struct fsi_clk *clock = &fsi->clock;
836 int ret = -EINVAL;
837
838 if (!fsi_clk_is_valid(fsi))
839 return ret;
840
841 if (0 == clock->count) {
842 ret = clock->set_rate(dev, fsi, rate);
843 if (ret < 0) {
844 fsi_clk_invalid(fsi);
845 return ret;
846 }
847
848 if (clock->xck)
849 clk_enable(clock->xck);
850 if (clock->ick)
851 clk_enable(clock->ick);
852 if (clock->div)
853 clk_enable(clock->div);
854
855 clock->count++;
856 }
857
858 return ret;
859}
860
861static int fsi_clk_disable(struct device *dev,
862 struct fsi_priv *fsi)
863{
864 struct fsi_clk *clock = &fsi->clock;
865
866 if (!fsi_clk_is_valid(fsi))
867 return -EINVAL;
868
869 if (1 == clock->count--) {
870 if (clock->xck)
871 clk_disable(clock->xck);
872 if (clock->ick)
873 clk_disable(clock->ick);
874 if (clock->div)
875 clk_disable(clock->div);
876 }
877
878 return 0;
879}
880
881static int fsi_clk_set_ackbpf(struct device *dev,
882 struct fsi_priv *fsi,
883 int ackmd, int bpfmd)
884{
885 u32 data = 0;
886
887 /* check ackmd/bpfmd relationship */
888 if (bpfmd > ackmd) {
889 dev_err(dev, "unsupported rate (%d/%d)\n", ackmd, bpfmd);
890 return -EINVAL;
891 }
892
893 /* ACKMD */
894 switch (ackmd) {
895 case 512:
896 data |= (0x0 << 12);
897 break;
898 case 256:
899 data |= (0x1 << 12);
900 break;
901 case 128:
902 data |= (0x2 << 12);
903 break;
904 case 64:
905 data |= (0x3 << 12);
906 break;
907 case 32:
908 data |= (0x4 << 12);
909 break;
910 default:
911 dev_err(dev, "unsupported ackmd (%d)\n", ackmd);
912 return -EINVAL;
913 }
914
915 /* BPFMD */
916 switch (bpfmd) {
917 case 32:
918 data |= (0x0 << 8);
919 break;
920 case 64:
921 data |= (0x1 << 8);
922 break;
923 case 128:
924 data |= (0x2 << 8);
925 break;
926 case 256:
927 data |= (0x3 << 8);
928 break;
929 case 512:
930 data |= (0x4 << 8);
931 break;
932 case 16:
933 data |= (0x7 << 8);
934 break;
935 default:
936 dev_err(dev, "unsupported bpfmd (%d)\n", bpfmd);
937 return -EINVAL;
938 }
939
940 dev_dbg(dev, "ACKMD/BPFMD = %d/%d\n", ackmd, bpfmd);
941
942 fsi_reg_mask_set(fsi, CKG1, (ACKMD_MASK | BPFMD_MASK) , data);
943 udelay(10);
944
945 return 0;
946}
947
948static int fsi_clk_set_rate_external(struct device *dev,
949 struct fsi_priv *fsi,
950 unsigned long rate)
951{
952 struct clk *xck = fsi->clock.xck;
953 struct clk *ick = fsi->clock.ick;
954 unsigned long xrate;
955 int ackmd, bpfmd;
956 int ret = 0;
957
958 /* check clock rate */
959 xrate = clk_get_rate(xck);
960 if (xrate % rate) {
961 dev_err(dev, "unsupported clock rate\n");
962 return -EINVAL;
963 }
964
965 clk_set_parent(ick, xck);
966 clk_set_rate(ick, xrate);
967
968 bpfmd = fsi->chan_num * 32;
969 ackmd = xrate / rate;
970
971 dev_dbg(dev, "external/rate = %ld/%ld\n", xrate, rate);
972
973 ret = fsi_clk_set_ackbpf(dev, fsi, ackmd, bpfmd);
974 if (ret < 0)
975 dev_err(dev, "%s failed", __func__);
976
977 return ret;
978}
979
980static int fsi_clk_set_rate_cpg(struct device *dev,
981 struct fsi_priv *fsi,
982 unsigned long rate)
983{
984 struct clk *ick = fsi->clock.ick;
985 struct clk *div = fsi->clock.div;
986 unsigned long target = 0; /* 12288000 or 11289600 */
987 unsigned long actual, cout;
988 unsigned long diff, min;
989 unsigned long best_cout, best_act;
990 int adj;
991 int ackmd, bpfmd;
992 int ret = -EINVAL;
993
994 if (!(12288000 % rate))
995 target = 12288000;
996 if (!(11289600 % rate))
997 target = 11289600;
998 if (!target) {
999 dev_err(dev, "unsupported rate\n");
1000 return ret;
1001 }
1002
1003 bpfmd = fsi->chan_num * 32;
1004 ackmd = target / rate;
1005 ret = fsi_clk_set_ackbpf(dev, fsi, ackmd, bpfmd);
1006 if (ret < 0) {
1007 dev_err(dev, "%s failed", __func__);
1008 return ret;
1009 }
1010
1011 /*
1012 * The clock flow is
1013 *
1014 * [CPG] = cout => [FSI_DIV] = audio => [FSI] => [codec]
1015 *
1016 * But, it needs to find best match of CPG and FSI_DIV
1017 * combination, since it is difficult to generate correct
1018 * frequency of audio clock from ick clock only.
1019 * Because ick is created from its parent clock.
1020 *
1021 * target = rate x [512/256/128/64]fs
1022 * cout = round(target x adjustment)
1023 * actual = cout / adjustment (by FSI-DIV) ~= target
1024 * audio = actual
1025 */
1026 min = ~0;
1027 best_cout = 0;
1028 best_act = 0;
1029 for (adj = 1; adj < 0xffff; adj++) {
1030
1031 cout = target * adj;
1032 if (cout > 100000000) /* max clock = 100MHz */
1033 break;
1034
1035 /* cout/actual audio clock */
1036 cout = clk_round_rate(ick, cout);
1037 actual = cout / adj;
1038
1039 /* find best frequency */
1040 diff = abs(actual - target);
1041 if (diff < min) {
1042 min = diff;
1043 best_cout = cout;
1044 best_act = actual;
1045 }
1046 }
1047
1048 ret = clk_set_rate(ick, best_cout);
1049 if (ret < 0) {
1050 dev_err(dev, "ick clock failed\n");
1051 return -EIO;
1052 }
1053
1054 ret = clk_set_rate(div, clk_round_rate(div, best_act));
1055 if (ret < 0) {
1056 dev_err(dev, "div clock failed\n");
1057 return -EIO;
1058 }
1059
1060 dev_dbg(dev, "ick/div = %ld/%ld\n",
1061 clk_get_rate(ick), clk_get_rate(div));
1062
1063 return ret;
1064}
1065
720static int fsi_set_master_clk(struct device *dev, struct fsi_priv *fsi, 1066static int fsi_set_master_clk(struct device *dev, struct fsi_priv *fsi,
721 long rate, int enable) 1067 long rate, int enable)
722{ 1068{
723 set_rate_func set_rate = fsi_get_info_set_rate(fsi); 1069 set_rate_func set_rate = fsi_get_info_set_rate(fsi);
724 int ret; 1070 int ret;
725 1071
726 if (!set_rate) 1072 /*
727 return 0; 1073 * CAUTION
1074 *
1075 * set_rate will be deleted
1076 */
1077 if (!set_rate) {
1078 if (enable)
1079 return fsi_clk_enable(dev, fsi, rate);
1080 else
1081 return fsi_clk_disable(dev, fsi);
1082 }
728 1083
729 ret = set_rate(dev, rate, enable); 1084 ret = set_rate(dev, rate, enable);
730 if (ret < 0) /* error */ 1085 if (ret < 0) /* error */
@@ -792,10 +1147,9 @@ static int fsi_set_master_clk(struct device *dev, struct fsi_priv *fsi,
792 */ 1147 */
793static void fsi_pio_push16(struct fsi_priv *fsi, u8 *_buf, int samples) 1148static void fsi_pio_push16(struct fsi_priv *fsi, u8 *_buf, int samples)
794{ 1149{
795 u32 enable_stream = fsi_get_info_flags(fsi) & SH_FSI_ENABLE_STREAM_MODE;
796 int i; 1150 int i;
797 1151
798 if (enable_stream) { 1152 if (fsi_is_enable_stream(fsi)) {
799 /* 1153 /*
800 * stream mode 1154 * stream mode
801 * see 1155 * see
@@ -953,8 +1307,6 @@ static void fsi_pio_start_stop(struct fsi_priv *fsi, struct fsi_stream *io,
953 1307
954static int fsi_pio_push_init(struct fsi_priv *fsi, struct fsi_stream *io) 1308static int fsi_pio_push_init(struct fsi_priv *fsi, struct fsi_stream *io)
955{ 1309{
956 u32 enable_stream = fsi_get_info_flags(fsi) & SH_FSI_ENABLE_STREAM_MODE;
957
958 /* 1310 /*
959 * we can use 16bit stream mode 1311 * we can use 16bit stream mode
960 * when "playback" and "16bit data" 1312 * when "playback" and "16bit data"
@@ -962,7 +1314,7 @@ static int fsi_pio_push_init(struct fsi_priv *fsi, struct fsi_stream *io)
962 * see 1314 * see
963 * fsi_pio_push16() 1315 * fsi_pio_push16()
964 */ 1316 */
965 if (enable_stream) 1317 if (fsi_is_enable_stream(fsi))
966 io->bus_option = BUSOP_SET(24, PACKAGE_24BITBUS_BACK) | 1318 io->bus_option = BUSOP_SET(24, PACKAGE_24BITBUS_BACK) |
967 BUSOP_SET(16, PACKAGE_16BITBUS_STREAM); 1319 BUSOP_SET(16, PACKAGE_16BITBUS_STREAM);
968 else 1320 else
@@ -1296,6 +1648,16 @@ static int fsi_hw_startup(struct fsi_priv *fsi,
1296 1648
1297 /* clock inversion (CKG2) */ 1649 /* clock inversion (CKG2) */
1298 data = 0; 1650 data = 0;
1651 if (fsi->bit_clk_inv)
1652 data |= (1 << 0);
1653 if (fsi->lr_clk_inv)
1654 data |= (1 << 4);
1655 if (fsi_is_clk_master(fsi))
1656 data <<= 8;
1657 /* FIXME
1658 *
1659 * SH_FSI_xxx_INV style will be removed
1660 */
1299 if (SH_FSI_LRM_INV & flags) 1661 if (SH_FSI_LRM_INV & flags)
1300 data |= 1 << 12; 1662 data |= 1 << 12;
1301 if (SH_FSI_BRM_INV & flags) 1663 if (SH_FSI_BRM_INV & flags)
@@ -1334,14 +1696,21 @@ static int fsi_hw_startup(struct fsi_priv *fsi,
1334 /* fifo init */ 1696 /* fifo init */
1335 fsi_fifo_init(fsi, io, dev); 1697 fsi_fifo_init(fsi, io, dev);
1336 1698
1699 /* start master clock */
1700 if (fsi_is_clk_master(fsi))
1701 return fsi_set_master_clk(dev, fsi, fsi->rate, 1);
1702
1337 return 0; 1703 return 0;
1338} 1704}
1339 1705
1340static void fsi_hw_shutdown(struct fsi_priv *fsi, 1706static int fsi_hw_shutdown(struct fsi_priv *fsi,
1341 struct device *dev) 1707 struct device *dev)
1342{ 1708{
1709 /* stop master clock */
1343 if (fsi_is_clk_master(fsi)) 1710 if (fsi_is_clk_master(fsi))
1344 fsi_set_master_clk(dev, fsi, fsi->rate, 0); 1711 return fsi_set_master_clk(dev, fsi, fsi->rate, 0);
1712
1713 return 0;
1345} 1714}
1346 1715
1347static int fsi_dai_startup(struct snd_pcm_substream *substream, 1716static int fsi_dai_startup(struct snd_pcm_substream *substream,
@@ -1349,6 +1718,7 @@ static int fsi_dai_startup(struct snd_pcm_substream *substream,
1349{ 1718{
1350 struct fsi_priv *fsi = fsi_get_priv(substream); 1719 struct fsi_priv *fsi = fsi_get_priv(substream);
1351 1720
1721 fsi_clk_invalid(fsi);
1352 fsi->rate = 0; 1722 fsi->rate = 0;
1353 1723
1354 return 0; 1724 return 0;
@@ -1359,6 +1729,7 @@ static void fsi_dai_shutdown(struct snd_pcm_substream *substream,
1359{ 1729{
1360 struct fsi_priv *fsi = fsi_get_priv(substream); 1730 struct fsi_priv *fsi = fsi_get_priv(substream);
1361 1731
1732 fsi_clk_invalid(fsi);
1362 fsi->rate = 0; 1733 fsi->rate = 0;
1363} 1734}
1364 1735
@@ -1372,13 +1743,16 @@ static int fsi_dai_trigger(struct snd_pcm_substream *substream, int cmd,
1372 switch (cmd) { 1743 switch (cmd) {
1373 case SNDRV_PCM_TRIGGER_START: 1744 case SNDRV_PCM_TRIGGER_START:
1374 fsi_stream_init(fsi, io, substream); 1745 fsi_stream_init(fsi, io, substream);
1375 fsi_hw_startup(fsi, io, dai->dev); 1746 if (!ret)
1376 ret = fsi_stream_transfer(io); 1747 ret = fsi_hw_startup(fsi, io, dai->dev);
1377 if (0 == ret) 1748 if (!ret)
1749 ret = fsi_stream_transfer(io);
1750 if (!ret)
1378 fsi_stream_start(fsi, io); 1751 fsi_stream_start(fsi, io);
1379 break; 1752 break;
1380 case SNDRV_PCM_TRIGGER_STOP: 1753 case SNDRV_PCM_TRIGGER_STOP:
1381 fsi_hw_shutdown(fsi, dai->dev); 1754 if (!ret)
1755 ret = fsi_hw_shutdown(fsi, dai->dev);
1382 fsi_stream_stop(fsi, io); 1756 fsi_stream_stop(fsi, io);
1383 fsi_stream_quit(fsi, io); 1757 fsi_stream_quit(fsi, io);
1384 break; 1758 break;
@@ -1414,7 +1788,6 @@ static int fsi_set_fmt_spdif(struct fsi_priv *fsi)
1414 1788
1415 fsi->fmt = CR_DTMD_SPDIF_PCM | CR_PCM; 1789 fsi->fmt = CR_DTMD_SPDIF_PCM | CR_PCM;
1416 fsi->chan_num = 2; 1790 fsi->chan_num = 2;
1417 fsi->spdif = 1;
1418 1791
1419 return 0; 1792 return 0;
1420} 1793}
@@ -1423,7 +1796,6 @@ static int fsi_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
1423{ 1796{
1424 struct fsi_priv *fsi = fsi_get_priv_frm_dai(dai); 1797 struct fsi_priv *fsi = fsi_get_priv_frm_dai(dai);
1425 set_rate_func set_rate = fsi_get_info_set_rate(fsi); 1798 set_rate_func set_rate = fsi_get_info_set_rate(fsi);
1426 u32 flags = fsi_get_info_flags(fsi);
1427 int ret; 1799 int ret;
1428 1800
1429 /* set master/slave audio interface */ 1801 /* set master/slave audio interface */
@@ -1437,23 +1809,50 @@ static int fsi_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
1437 return -EINVAL; 1809 return -EINVAL;
1438 } 1810 }
1439 1811
1440 if (fsi_is_clk_master(fsi) && !set_rate) { 1812 /* set clock inversion */
1441 dev_err(dai->dev, "platform doesn't have set_rate\n"); 1813 switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
1442 return -EINVAL; 1814 case SND_SOC_DAIFMT_NB_IF:
1443 } 1815 fsi->bit_clk_inv = 0;
1444 1816 fsi->lr_clk_inv = 1;
1445 /* set format */
1446 switch (flags & SH_FSI_FMT_MASK) {
1447 case SH_FSI_FMT_DAI:
1448 ret = fsi_set_fmt_dai(fsi, fmt & SND_SOC_DAIFMT_FORMAT_MASK);
1449 break; 1817 break;
1450 case SH_FSI_FMT_SPDIF: 1818 case SND_SOC_DAIFMT_IB_NF:
1451 ret = fsi_set_fmt_spdif(fsi); 1819 fsi->bit_clk_inv = 1;
1820 fsi->lr_clk_inv = 0;
1452 break; 1821 break;
1822 case SND_SOC_DAIFMT_IB_IF:
1823 fsi->bit_clk_inv = 1;
1824 fsi->lr_clk_inv = 1;
1825 break;
1826 case SND_SOC_DAIFMT_NB_NF:
1453 default: 1827 default:
1454 ret = -EINVAL; 1828 fsi->bit_clk_inv = 0;
1829 fsi->lr_clk_inv = 0;
1830 break;
1831 }
1832
1833 if (fsi_is_clk_master(fsi)) {
1834 /*
1835 * CAUTION
1836 *
1837 * set_rate will be deleted
1838 */
1839 if (set_rate)
1840 dev_warn(dai->dev, "set_rate will be removed soon\n");
1841
1842 if (fsi->clk_cpg)
1843 fsi_clk_init(dai->dev, fsi, 0, 1, 1,
1844 fsi_clk_set_rate_cpg);
1845 else
1846 fsi_clk_init(dai->dev, fsi, 1, 1, 0,
1847 fsi_clk_set_rate_external);
1455 } 1848 }
1456 1849
1850 /* set format */
1851 if (fsi_is_spdif(fsi))
1852 ret = fsi_set_fmt_spdif(fsi);
1853 else
1854 ret = fsi_set_fmt_dai(fsi, fmt & SND_SOC_DAIFMT_FORMAT_MASK);
1855
1457 return ret; 1856 return ret;
1458} 1857}
1459 1858
@@ -1462,19 +1861,13 @@ static int fsi_dai_hw_params(struct snd_pcm_substream *substream,
1462 struct snd_soc_dai *dai) 1861 struct snd_soc_dai *dai)
1463{ 1862{
1464 struct fsi_priv *fsi = fsi_get_priv(substream); 1863 struct fsi_priv *fsi = fsi_get_priv(substream);
1465 long rate = params_rate(params);
1466 int ret;
1467 1864
1468 if (!fsi_is_clk_master(fsi)) 1865 if (fsi_is_clk_master(fsi)) {
1469 return 0; 1866 fsi->rate = params_rate(params);
1470 1867 fsi_clk_valid(fsi, fsi->rate);
1471 ret = fsi_set_master_clk(dai->dev, fsi, rate, 1); 1868 }
1472 if (ret < 0)
1473 return ret;
1474
1475 fsi->rate = rate;
1476 1869
1477 return ret; 1870 return 0;
1478} 1871}
1479 1872
1480static const struct snd_soc_dai_ops fsi_dai_ops = { 1873static const struct snd_soc_dai_ops fsi_dai_ops = {
@@ -1498,7 +1891,7 @@ static struct snd_pcm_hardware fsi_pcm_hardware = {
1498 .rates = FSI_RATES, 1891 .rates = FSI_RATES,
1499 .rate_min = 8000, 1892 .rate_min = 8000,
1500 .rate_max = 192000, 1893 .rate_max = 192000,
1501 .channels_min = 1, 1894 .channels_min = 2,
1502 .channels_max = 2, 1895 .channels_max = 2,
1503 .buffer_bytes_max = 64 * 1024, 1896 .buffer_bytes_max = 64 * 1024,
1504 .period_bytes_min = 32, 1897 .period_bytes_min = 32,
@@ -1586,14 +1979,14 @@ static struct snd_soc_dai_driver fsi_soc_dai[] = {
1586 .playback = { 1979 .playback = {
1587 .rates = FSI_RATES, 1980 .rates = FSI_RATES,
1588 .formats = FSI_FMTS, 1981 .formats = FSI_FMTS,
1589 .channels_min = 1, 1982 .channels_min = 2,
1590 .channels_max = 8, 1983 .channels_max = 2,
1591 }, 1984 },
1592 .capture = { 1985 .capture = {
1593 .rates = FSI_RATES, 1986 .rates = FSI_RATES,
1594 .formats = FSI_FMTS, 1987 .formats = FSI_FMTS,
1595 .channels_min = 1, 1988 .channels_min = 2,
1596 .channels_max = 8, 1989 .channels_max = 2,
1597 }, 1990 },
1598 .ops = &fsi_dai_ops, 1991 .ops = &fsi_dai_ops,
1599 }, 1992 },
@@ -1602,14 +1995,14 @@ static struct snd_soc_dai_driver fsi_soc_dai[] = {
1602 .playback = { 1995 .playback = {
1603 .rates = FSI_RATES, 1996 .rates = FSI_RATES,
1604 .formats = FSI_FMTS, 1997 .formats = FSI_FMTS,
1605 .channels_min = 1, 1998 .channels_min = 2,
1606 .channels_max = 8, 1999 .channels_max = 2,
1607 }, 2000 },
1608 .capture = { 2001 .capture = {
1609 .rates = FSI_RATES, 2002 .rates = FSI_RATES,
1610 .formats = FSI_FMTS, 2003 .formats = FSI_FMTS,
1611 .channels_min = 1, 2004 .channels_min = 2,
1612 .channels_max = 8, 2005 .channels_max = 2,
1613 }, 2006 },
1614 .ops = &fsi_dai_ops, 2007 .ops = &fsi_dai_ops,
1615 }, 2008 },
@@ -1624,15 +2017,29 @@ static struct snd_soc_platform_driver fsi_soc_platform = {
1624/* 2017/*
1625 * platform function 2018 * platform function
1626 */ 2019 */
1627static void fsi_handler_init(struct fsi_priv *fsi) 2020static void fsi_port_info_init(struct fsi_priv *fsi,
2021 struct sh_fsi_port_info *info)
2022{
2023 if (info->flags & SH_FSI_FMT_SPDIF)
2024 fsi->spdif = 1;
2025
2026 if (info->flags & SH_FSI_CLK_CPG)
2027 fsi->clk_cpg = 1;
2028
2029 if (info->flags & SH_FSI_ENABLE_STREAM_MODE)
2030 fsi->enable_stream = 1;
2031}
2032
2033static void fsi_handler_init(struct fsi_priv *fsi,
2034 struct sh_fsi_port_info *info)
1628{ 2035{
1629 fsi->playback.handler = &fsi_pio_push_handler; /* default PIO */ 2036 fsi->playback.handler = &fsi_pio_push_handler; /* default PIO */
1630 fsi->playback.priv = fsi; 2037 fsi->playback.priv = fsi;
1631 fsi->capture.handler = &fsi_pio_pop_handler; /* default PIO */ 2038 fsi->capture.handler = &fsi_pio_pop_handler; /* default PIO */
1632 fsi->capture.priv = fsi; 2039 fsi->capture.priv = fsi;
1633 2040
1634 if (fsi->info->tx_id) { 2041 if (info->tx_id) {
1635 fsi->playback.slave.shdma_slave.slave_id = fsi->info->tx_id; 2042 fsi->playback.slave.shdma_slave.slave_id = info->tx_id;
1636 fsi->playback.handler = &fsi_dma_push_handler; 2043 fsi->playback.handler = &fsi_dma_push_handler;
1637 } 2044 }
1638} 2045}
@@ -1642,10 +2049,16 @@ static int fsi_probe(struct platform_device *pdev)
1642 struct fsi_master *master; 2049 struct fsi_master *master;
1643 const struct platform_device_id *id_entry; 2050 const struct platform_device_id *id_entry;
1644 struct sh_fsi_platform_info *info = pdev->dev.platform_data; 2051 struct sh_fsi_platform_info *info = pdev->dev.platform_data;
2052 struct sh_fsi_port_info nul_info, *pinfo;
2053 struct fsi_priv *fsi;
1645 struct resource *res; 2054 struct resource *res;
1646 unsigned int irq; 2055 unsigned int irq;
1647 int ret; 2056 int ret;
1648 2057
2058 nul_info.flags = 0;
2059 nul_info.tx_id = 0;
2060 nul_info.rx_id = 0;
2061
1649 id_entry = pdev->id_entry; 2062 id_entry = pdev->id_entry;
1650 if (!id_entry) { 2063 if (!id_entry) {
1651 dev_err(&pdev->dev, "unknown fsi device\n"); 2064 dev_err(&pdev->dev, "unknown fsi device\n");
@@ -1678,22 +2091,28 @@ static int fsi_probe(struct platform_device *pdev)
1678 spin_lock_init(&master->lock); 2091 spin_lock_init(&master->lock);
1679 2092
1680 /* FSI A setting */ 2093 /* FSI A setting */
1681 master->fsia.base = master->base; 2094 pinfo = (info) ? &info->port_a : &nul_info;
1682 master->fsia.master = master; 2095 fsi = &master->fsia;
1683 master->fsia.info = &info->port_a; 2096 fsi->base = master->base;
1684 fsi_handler_init(&master->fsia); 2097 fsi->master = master;
1685 ret = fsi_stream_probe(&master->fsia, &pdev->dev); 2098 fsi->info = pinfo;
2099 fsi_port_info_init(fsi, pinfo);
2100 fsi_handler_init(fsi, pinfo);
2101 ret = fsi_stream_probe(fsi, &pdev->dev);
1686 if (ret < 0) { 2102 if (ret < 0) {
1687 dev_err(&pdev->dev, "FSIA stream probe failed\n"); 2103 dev_err(&pdev->dev, "FSIA stream probe failed\n");
1688 return ret; 2104 return ret;
1689 } 2105 }
1690 2106
1691 /* FSI B setting */ 2107 /* FSI B setting */
1692 master->fsib.base = master->base + 0x40; 2108 pinfo = (info) ? &info->port_b : &nul_info;
1693 master->fsib.master = master; 2109 fsi = &master->fsib;
1694 master->fsib.info = &info->port_b; 2110 fsi->base = master->base + 0x40;
1695 fsi_handler_init(&master->fsib); 2111 fsi->master = master;
1696 ret = fsi_stream_probe(&master->fsib, &pdev->dev); 2112 fsi->info = pinfo;
2113 fsi_port_info_init(fsi, pinfo);
2114 fsi_handler_init(fsi, pinfo);
2115 ret = fsi_stream_probe(fsi, &pdev->dev);
1697 if (ret < 0) { 2116 if (ret < 0) {
1698 dev_err(&pdev->dev, "FSIB stream probe failed\n"); 2117 dev_err(&pdev->dev, "FSIB stream probe failed\n");
1699 goto exit_fsia; 2118 goto exit_fsia;
@@ -1702,7 +2121,7 @@ static int fsi_probe(struct platform_device *pdev)
1702 pm_runtime_enable(&pdev->dev); 2121 pm_runtime_enable(&pdev->dev);
1703 dev_set_drvdata(&pdev->dev, master); 2122 dev_set_drvdata(&pdev->dev, master);
1704 2123
1705 ret = request_irq(irq, &fsi_interrupt, 0, 2124 ret = devm_request_irq(&pdev->dev, irq, &fsi_interrupt, 0,
1706 id_entry->name, master); 2125 id_entry->name, master);
1707 if (ret) { 2126 if (ret) {
1708 dev_err(&pdev->dev, "irq request err\n"); 2127 dev_err(&pdev->dev, "irq request err\n");
@@ -1712,7 +2131,7 @@ static int fsi_probe(struct platform_device *pdev)
1712 ret = snd_soc_register_platform(&pdev->dev, &fsi_soc_platform); 2131 ret = snd_soc_register_platform(&pdev->dev, &fsi_soc_platform);
1713 if (ret < 0) { 2132 if (ret < 0) {
1714 dev_err(&pdev->dev, "cannot snd soc register\n"); 2133 dev_err(&pdev->dev, "cannot snd soc register\n");
1715 goto exit_free_irq; 2134 goto exit_fsib;
1716 } 2135 }
1717 2136
1718 ret = snd_soc_register_dais(&pdev->dev, fsi_soc_dai, 2137 ret = snd_soc_register_dais(&pdev->dev, fsi_soc_dai,
@@ -1726,8 +2145,6 @@ static int fsi_probe(struct platform_device *pdev)
1726 2145
1727exit_snd_soc: 2146exit_snd_soc:
1728 snd_soc_unregister_platform(&pdev->dev); 2147 snd_soc_unregister_platform(&pdev->dev);
1729exit_free_irq:
1730 free_irq(irq, master);
1731exit_fsib: 2148exit_fsib:
1732 pm_runtime_disable(&pdev->dev); 2149 pm_runtime_disable(&pdev->dev);
1733 fsi_stream_remove(&master->fsib); 2150 fsi_stream_remove(&master->fsib);
@@ -1743,7 +2160,6 @@ static int fsi_remove(struct platform_device *pdev)
1743 2160
1744 master = dev_get_drvdata(&pdev->dev); 2161 master = dev_get_drvdata(&pdev->dev);
1745 2162
1746 free_irq(master->irq, master);
1747 pm_runtime_disable(&pdev->dev); 2163 pm_runtime_disable(&pdev->dev);
1748 2164
1749 snd_soc_unregister_dais(&pdev->dev, ARRAY_SIZE(fsi_soc_dai)); 2165 snd_soc_unregister_dais(&pdev->dev, ARRAY_SIZE(fsi_soc_dai));
@@ -1774,10 +2190,6 @@ static void __fsi_resume(struct fsi_priv *fsi,
1774 return; 2190 return;
1775 2191
1776 fsi_hw_startup(fsi, io, dev); 2192 fsi_hw_startup(fsi, io, dev);
1777
1778 if (fsi_is_clk_master(fsi) && fsi->rate)
1779 fsi_set_master_clk(dev, fsi, fsi->rate, 1);
1780
1781 fsi_stream_start(fsi, io); 2193 fsi_stream_start(fsi, io);
1782} 2194}
1783 2195
diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c
index 9d56f0218f41..e72f55428f0b 100644
--- a/sound/soc/soc-cache.c
+++ b/sound/soc/soc-cache.c
@@ -88,7 +88,7 @@ static int snd_soc_flat_cache_sync(struct snd_soc_codec *codec)
88 ret = snd_soc_write(codec, i, val); 88 ret = snd_soc_write(codec, i, val);
89 if (ret) 89 if (ret)
90 return ret; 90 return ret;
91 dev_dbg(codec->dev, "Synced register %#x, value = %#x\n", 91 dev_dbg(codec->dev, "ASoC: Synced register %#x, value = %#x\n",
92 i, val); 92 i, val);
93 } 93 }
94 return 0; 94 return 0;
@@ -156,7 +156,7 @@ int snd_soc_cache_init(struct snd_soc_codec *codec)
156 156
157 /* Fall back to flat compression */ 157 /* Fall back to flat compression */
158 if (i == ARRAY_SIZE(cache_types)) { 158 if (i == ARRAY_SIZE(cache_types)) {
159 dev_warn(codec->dev, "Could not match compress type: %d\n", 159 dev_warn(codec->dev, "ASoC: Could not match compress type: %d\n",
160 codec->compress_type); 160 codec->compress_type);
161 i = 0; 161 i = 0;
162 } 162 }
@@ -166,7 +166,7 @@ int snd_soc_cache_init(struct snd_soc_codec *codec)
166 166
167 if (codec->cache_ops->init) { 167 if (codec->cache_ops->init) {
168 if (codec->cache_ops->name) 168 if (codec->cache_ops->name)
169 dev_dbg(codec->dev, "Initializing %s cache for %s codec\n", 169 dev_dbg(codec->dev, "ASoC: Initializing %s cache for %s codec\n",
170 codec->cache_ops->name, codec->name); 170 codec->cache_ops->name, codec->name);
171 return codec->cache_ops->init(codec); 171 return codec->cache_ops->init(codec);
172 } 172 }
@@ -181,7 +181,7 @@ int snd_soc_cache_exit(struct snd_soc_codec *codec)
181{ 181{
182 if (codec->cache_ops && codec->cache_ops->exit) { 182 if (codec->cache_ops && codec->cache_ops->exit) {
183 if (codec->cache_ops->name) 183 if (codec->cache_ops->name)
184 dev_dbg(codec->dev, "Destroying %s cache for %s codec\n", 184 dev_dbg(codec->dev, "ASoC: Destroying %s cache for %s codec\n",
185 codec->cache_ops->name, codec->name); 185 codec->cache_ops->name, codec->name);
186 return codec->cache_ops->exit(codec); 186 return codec->cache_ops->exit(codec);
187 } 187 }
@@ -265,7 +265,7 @@ int snd_soc_cache_sync(struct snd_soc_codec *codec)
265 name = "unknown"; 265 name = "unknown";
266 266
267 if (codec->cache_ops->name) 267 if (codec->cache_ops->name)
268 dev_dbg(codec->dev, "Syncing %s cache for %s codec\n", 268 dev_dbg(codec->dev, "ASoC: Syncing %s cache for %s codec\n",
269 codec->cache_ops->name, codec->name); 269 codec->cache_ops->name, codec->name);
270 trace_snd_soc_cache_sync(codec, name, "start"); 270 trace_snd_soc_cache_sync(codec, name, "start");
271 ret = codec->cache_ops->sync(codec); 271 ret = codec->cache_ops->sync(codec);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index d1198627fc40..9c768bcb98a6 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -271,7 +271,8 @@ static void soc_init_codec_debugfs(struct snd_soc_codec *codec)
271 codec->debugfs_codec_root = debugfs_create_dir(codec->name, 271 codec->debugfs_codec_root = debugfs_create_dir(codec->name,
272 debugfs_card_root); 272 debugfs_card_root);
273 if (!codec->debugfs_codec_root) { 273 if (!codec->debugfs_codec_root) {
274 dev_warn(codec->dev, "Failed to create codec debugfs directory\n"); 274 dev_warn(codec->dev, "ASoC: Failed to create codec debugfs"
275 " directory\n");
275 return; 276 return;
276 } 277 }
277 278
@@ -284,7 +285,8 @@ static void soc_init_codec_debugfs(struct snd_soc_codec *codec)
284 codec->debugfs_codec_root, 285 codec->debugfs_codec_root,
285 codec, &codec_reg_fops); 286 codec, &codec_reg_fops);
286 if (!codec->debugfs_reg) 287 if (!codec->debugfs_reg)
287 dev_warn(codec->dev, "Failed to create codec register debugfs file\n"); 288 dev_warn(codec->dev, "ASoC: Failed to create codec register"
289 " debugfs file\n");
288 290
289 snd_soc_dapm_debugfs_init(&codec->dapm, codec->debugfs_codec_root); 291 snd_soc_dapm_debugfs_init(&codec->dapm, codec->debugfs_codec_root);
290} 292}
@@ -302,7 +304,7 @@ static void soc_init_platform_debugfs(struct snd_soc_platform *platform)
302 debugfs_card_root); 304 debugfs_card_root);
303 if (!platform->debugfs_platform_root) { 305 if (!platform->debugfs_platform_root) {
304 dev_warn(platform->dev, 306 dev_warn(platform->dev,
305 "Failed to create platform debugfs directory\n"); 307 "ASoC: Failed to create platform debugfs directory\n");
306 return; 308 return;
307 } 309 }
308 310
@@ -430,7 +432,7 @@ static void soc_init_card_debugfs(struct snd_soc_card *card)
430 &card->pop_time); 432 &card->pop_time);
431 if (!card->debugfs_pop_time) 433 if (!card->debugfs_pop_time)
432 dev_warn(card->dev, 434 dev_warn(card->dev,
433 "Failed to create pop time debugfs file\n"); 435 "ASoC: Failed to create pop time debugfs file\n");
434} 436}
435 437
436static void soc_cleanup_card_debugfs(struct snd_soc_card *card) 438static void soc_cleanup_card_debugfs(struct snd_soc_card *card)
@@ -475,7 +477,7 @@ struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card,
475 !strcmp(card->rtd[i].dai_link->name, dai_link)) 477 !strcmp(card->rtd[i].dai_link->name, dai_link))
476 return card->rtd[i].pcm->streams[stream].substream; 478 return card->rtd[i].pcm->streams[stream].substream;
477 } 479 }
478 dev_dbg(card->dev, "failed to find dai link %s\n", dai_link); 480 dev_dbg(card->dev, "ASoC: failed to find dai link %s\n", dai_link);
479 return NULL; 481 return NULL;
480} 482}
481EXPORT_SYMBOL_GPL(snd_soc_get_dai_substream); 483EXPORT_SYMBOL_GPL(snd_soc_get_dai_substream);
@@ -489,7 +491,7 @@ struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card,
489 if (!strcmp(card->rtd[i].dai_link->name, dai_link)) 491 if (!strcmp(card->rtd[i].dai_link->name, dai_link))
490 return &card->rtd[i]; 492 return &card->rtd[i];
491 } 493 }
492 dev_dbg(card->dev, "failed to find rtd %s\n", dai_link); 494 dev_dbg(card->dev, "ASoC: failed to find rtd %s\n", dai_link);
493 return NULL; 495 return NULL;
494} 496}
495EXPORT_SYMBOL_GPL(snd_soc_get_pcm_runtime); 497EXPORT_SYMBOL_GPL(snd_soc_get_pcm_runtime);
@@ -519,7 +521,7 @@ static int soc_ac97_dev_register(struct snd_soc_codec *codec)
519 codec->card->snd_card->number, 0, codec->name); 521 codec->card->snd_card->number, 0, codec->name);
520 err = device_register(&codec->ac97->dev); 522 err = device_register(&codec->ac97->dev);
521 if (err < 0) { 523 if (err < 0) {
522 snd_printk(KERN_ERR "Can't register ac97 bus\n"); 524 dev_err(codec->dev, "ASoC: Can't register ac97 bus\n");
523 codec->ac97->dev.bus = NULL; 525 codec->ac97->dev.bus = NULL;
524 return err; 526 return err;
525 } 527 }
@@ -628,7 +630,8 @@ int snd_soc_suspend(struct device *dev)
628 */ 630 */
629 if (codec->dapm.idle_bias_off) { 631 if (codec->dapm.idle_bias_off) {
630 dev_dbg(codec->dev, 632 dev_dbg(codec->dev,
631 "idle_bias_off CODEC on over suspend\n"); 633 "ASoC: idle_bias_off CODEC on"
634 " over suspend\n");
632 break; 635 break;
633 } 636 }
634 case SND_SOC_BIAS_OFF: 637 case SND_SOC_BIAS_OFF:
@@ -639,7 +642,8 @@ int snd_soc_suspend(struct device *dev)
639 regcache_mark_dirty(codec->control_data); 642 regcache_mark_dirty(codec->control_data);
640 break; 643 break;
641 default: 644 default:
642 dev_dbg(codec->dev, "CODEC is on over suspend\n"); 645 dev_dbg(codec->dev, "ASoC: CODEC is on"
646 " over suspend\n");
643 break; 647 break;
644 } 648 }
645 } 649 }
@@ -676,7 +680,7 @@ static void soc_resume_deferred(struct work_struct *work)
676 * so userspace apps are blocked from touching us 680 * so userspace apps are blocked from touching us
677 */ 681 */
678 682
679 dev_dbg(card->dev, "starting resume work\n"); 683 dev_dbg(card->dev, "ASoC: starting resume work\n");
680 684
681 /* Bring us up into D2 so that DAPM starts enabling things */ 685 /* Bring us up into D2 so that DAPM starts enabling things */
682 snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D2); 686 snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D2);
@@ -708,7 +712,8 @@ static void soc_resume_deferred(struct work_struct *work)
708 codec->suspended = 0; 712 codec->suspended = 0;
709 break; 713 break;
710 default: 714 default:
711 dev_dbg(codec->dev, "CODEC was on over suspend\n"); 715 dev_dbg(codec->dev, "ASoC: CODEC was on over"
716 " suspend\n");
712 break; 717 break;
713 } 718 }
714 } 719 }
@@ -758,7 +763,7 @@ static void soc_resume_deferred(struct work_struct *work)
758 if (card->resume_post) 763 if (card->resume_post)
759 card->resume_post(card); 764 card->resume_post(card);
760 765
761 dev_dbg(card->dev, "resume work completed\n"); 766 dev_dbg(card->dev, "ASoC: resume work completed\n");
762 767
763 /* userspace can access us now we are back as we were before */ 768 /* userspace can access us now we are back as we were before */
764 snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D0); 769 snd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D0);
@@ -790,12 +795,12 @@ int snd_soc_resume(struct device *dev)
790 ac97_control |= cpu_dai->driver->ac97_control; 795 ac97_control |= cpu_dai->driver->ac97_control;
791 } 796 }
792 if (ac97_control) { 797 if (ac97_control) {
793 dev_dbg(dev, "Resuming AC97 immediately\n"); 798 dev_dbg(dev, "ASoC: Resuming AC97 immediately\n");
794 soc_resume_deferred(&card->deferred_resume_work); 799 soc_resume_deferred(&card->deferred_resume_work);
795 } else { 800 } else {
796 dev_dbg(dev, "Scheduling resume work\n"); 801 dev_dbg(dev, "ASoC: Scheduling resume work\n");
797 if (!schedule_work(&card->deferred_resume_work)) 802 if (!schedule_work(&card->deferred_resume_work))
798 dev_err(dev, "resume work item may be lost\n"); 803 dev_err(dev, "ASoC: resume work item may be lost\n");
799 } 804 }
800 805
801 return 0; 806 return 0;
@@ -818,7 +823,7 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num)
818 struct snd_soc_dai *codec_dai, *cpu_dai; 823 struct snd_soc_dai *codec_dai, *cpu_dai;
819 const char *platform_name; 824 const char *platform_name;
820 825
821 dev_dbg(card->dev, "binding %s at idx %d\n", dai_link->name, num); 826 dev_dbg(card->dev, "ASoC: binding %s at idx %d\n", dai_link->name, num);
822 827
823 /* Find CPU DAI from registered DAIs*/ 828 /* Find CPU DAI from registered DAIs*/
824 list_for_each_entry(cpu_dai, &dai_list, list) { 829 list_for_each_entry(cpu_dai, &dai_list, list) {
@@ -836,7 +841,7 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num)
836 } 841 }
837 842
838 if (!rtd->cpu_dai) { 843 if (!rtd->cpu_dai) {
839 dev_err(card->dev, "CPU DAI %s not registered\n", 844 dev_err(card->dev, "ASoC: CPU DAI %s not registered\n",
840 dai_link->cpu_dai_name); 845 dai_link->cpu_dai_name);
841 return -EPROBE_DEFER; 846 return -EPROBE_DEFER;
842 } 847 }
@@ -867,14 +872,14 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num)
867 } 872 }
868 873
869 if (!rtd->codec_dai) { 874 if (!rtd->codec_dai) {
870 dev_err(card->dev, "CODEC DAI %s not registered\n", 875 dev_err(card->dev, "ASoC: CODEC DAI %s not registered\n",
871 dai_link->codec_dai_name); 876 dai_link->codec_dai_name);
872 return -EPROBE_DEFER; 877 return -EPROBE_DEFER;
873 } 878 }
874 } 879 }
875 880
876 if (!rtd->codec) { 881 if (!rtd->codec) {
877 dev_err(card->dev, "CODEC %s not registered\n", 882 dev_err(card->dev, "ASoC: CODEC %s not registered\n",
878 dai_link->codec_name); 883 dai_link->codec_name);
879 return -EPROBE_DEFER; 884 return -EPROBE_DEFER;
880 } 885 }
@@ -898,7 +903,7 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num)
898 rtd->platform = platform; 903 rtd->platform = platform;
899 } 904 }
900 if (!rtd->platform) { 905 if (!rtd->platform) {
901 dev_err(card->dev, "platform %s not registered\n", 906 dev_err(card->dev, "ASoC: platform %s not registered\n",
902 dai_link->platform_name); 907 dai_link->platform_name);
903 return -EPROBE_DEFER; 908 return -EPROBE_DEFER;
904 } 909 }
@@ -915,8 +920,8 @@ static int soc_remove_platform(struct snd_soc_platform *platform)
915 if (platform->driver->remove) { 920 if (platform->driver->remove) {
916 ret = platform->driver->remove(platform); 921 ret = platform->driver->remove(platform);
917 if (ret < 0) 922 if (ret < 0)
918 pr_err("asoc: failed to remove %s: %d\n", 923 dev_err(platform->dev, "ASoC: failed to remove %d\n",
919 platform->name, ret); 924 ret);
920 } 925 }
921 926
922 /* Make sure all DAPM widgets are freed */ 927 /* Make sure all DAPM widgets are freed */
@@ -937,9 +942,7 @@ static void soc_remove_codec(struct snd_soc_codec *codec)
937 if (codec->driver->remove) { 942 if (codec->driver->remove) {
938 err = codec->driver->remove(codec); 943 err = codec->driver->remove(codec);
939 if (err < 0) 944 if (err < 0)
940 dev_err(codec->dev, 945 dev_err(codec->dev, "ASoC: failed to remove %d\n", err);
941 "asoc: failed to remove %s: %d\n",
942 codec->name, err);
943 } 946 }
944 947
945 /* Make sure all DAPM widgets are freed */ 948 /* Make sure all DAPM widgets are freed */
@@ -971,8 +974,9 @@ static void soc_remove_link_dais(struct snd_soc_card *card, int num, int order)
971 if (codec_dai->driver->remove) { 974 if (codec_dai->driver->remove) {
972 err = codec_dai->driver->remove(codec_dai); 975 err = codec_dai->driver->remove(codec_dai);
973 if (err < 0) 976 if (err < 0)
974 pr_err("asoc: failed to remove %s: %d\n", 977 dev_err(codec_dai->dev,
975 codec_dai->name, err); 978 "ASoC: failed to remove %s: %d\n",
979 codec_dai->name, err);
976 } 980 }
977 codec_dai->probed = 0; 981 codec_dai->probed = 0;
978 list_del(&codec_dai->card_list); 982 list_del(&codec_dai->card_list);
@@ -984,8 +988,9 @@ static void soc_remove_link_dais(struct snd_soc_card *card, int num, int order)
984 if (cpu_dai->driver->remove) { 988 if (cpu_dai->driver->remove) {
985 err = cpu_dai->driver->remove(cpu_dai); 989 err = cpu_dai->driver->remove(cpu_dai);
986 if (err < 0) 990 if (err < 0)
987 pr_err("asoc: failed to remove %s: %d\n", 991 dev_err(cpu_dai->dev,
988 cpu_dai->name, err); 992 "ASoC: failed to remove %s: %d\n",
993 cpu_dai->name, err);
989 } 994 }
990 cpu_dai->probed = 0; 995 cpu_dai->probed = 0;
991 list_del(&cpu_dai->card_list); 996 list_del(&cpu_dai->card_list);
@@ -1099,8 +1104,7 @@ static int soc_probe_codec(struct snd_soc_card *card,
1099 ret = driver->probe(codec); 1104 ret = driver->probe(codec);
1100 if (ret < 0) { 1105 if (ret < 0) {
1101 dev_err(codec->dev, 1106 dev_err(codec->dev,
1102 "asoc: failed to probe CODEC %s: %d\n", 1107 "ASoC: failed to probe CODEC %d\n", ret);
1103 codec->name, ret);
1104 goto err_probe; 1108 goto err_probe;
1105 } 1109 }
1106 } 1110 }
@@ -1163,8 +1167,7 @@ static int soc_probe_platform(struct snd_soc_card *card,
1163 ret = driver->probe(platform); 1167 ret = driver->probe(platform);
1164 if (ret < 0) { 1168 if (ret < 0) {
1165 dev_err(platform->dev, 1169 dev_err(platform->dev,
1166 "asoc: failed to probe platform %s: %d\n", 1170 "ASoC: failed to probe platform %d\n", ret);
1167 platform->name, ret);
1168 goto err_probe; 1171 goto err_probe;
1169 } 1172 }
1170 } 1173 }
@@ -1229,7 +1232,7 @@ static int soc_post_component_init(struct snd_soc_card *card,
1229 else if (dailess && aux_dev->init) 1232 else if (dailess && aux_dev->init)
1230 ret = aux_dev->init(&codec->dapm); 1233 ret = aux_dev->init(&codec->dapm);
1231 if (ret < 0) { 1234 if (ret < 0) {
1232 dev_err(card->dev, "asoc: failed to init %s: %d\n", name, ret); 1235 dev_err(card->dev, "ASoC: failed to init %s: %d\n", name, ret);
1233 return ret; 1236 return ret;
1234 } 1237 }
1235 codec->name_prefix = temp; 1238 codec->name_prefix = temp;
@@ -1253,7 +1256,7 @@ static int soc_post_component_init(struct snd_soc_card *card,
1253 ret = device_add(rtd->dev); 1256 ret = device_add(rtd->dev);
1254 if (ret < 0) { 1257 if (ret < 0) {
1255 dev_err(card->dev, 1258 dev_err(card->dev,
1256 "asoc: failed to register runtime device: %d\n", ret); 1259 "ASoC: failed to register runtime device: %d\n", ret);
1257 return ret; 1260 return ret;
1258 } 1261 }
1259 rtd->dev_registered = 1; 1262 rtd->dev_registered = 1;
@@ -1262,14 +1265,13 @@ static int soc_post_component_init(struct snd_soc_card *card,
1262 ret = snd_soc_dapm_sys_add(rtd->dev); 1265 ret = snd_soc_dapm_sys_add(rtd->dev);
1263 if (ret < 0) 1266 if (ret < 0)
1264 dev_err(codec->dev, 1267 dev_err(codec->dev,
1265 "asoc: failed to add codec dapm sysfs entries: %d\n", 1268 "ASoC: failed to add codec dapm sysfs entries: %d\n", ret);
1266 ret);
1267 1269
1268 /* add codec sysfs entries */ 1270 /* add codec sysfs entries */
1269 ret = device_create_file(rtd->dev, &dev_attr_codec_reg); 1271 ret = device_create_file(rtd->dev, &dev_attr_codec_reg);
1270 if (ret < 0) 1272 if (ret < 0)
1271 dev_err(codec->dev, 1273 dev_err(codec->dev,
1272 "asoc: failed to add codec sysfs files: %d\n", ret); 1274 "ASoC: failed to add codec sysfs files: %d\n", ret);
1273 1275
1274#ifdef CONFIG_DEBUG_FS 1276#ifdef CONFIG_DEBUG_FS
1275 /* add DPCM sysfs entries */ 1277 /* add DPCM sysfs entries */
@@ -1278,7 +1280,7 @@ static int soc_post_component_init(struct snd_soc_card *card,
1278 1280
1279 ret = soc_dpcm_debugfs_add(rtd); 1281 ret = soc_dpcm_debugfs_add(rtd);
1280 if (ret < 0) 1282 if (ret < 0)
1281 dev_err(rtd->dev, "asoc: failed to add dpcm sysfs entries: %d\n", ret); 1283 dev_err(rtd->dev, "ASoC: failed to add dpcm sysfs entries: %d\n", ret);
1282 1284
1283out: 1285out:
1284#endif 1286#endif
@@ -1333,7 +1335,7 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order)
1333 struct snd_soc_dapm_widget *play_w, *capture_w; 1335 struct snd_soc_dapm_widget *play_w, *capture_w;
1334 int ret; 1336 int ret;
1335 1337
1336 dev_dbg(card->dev, "probe %s dai link %d late %d\n", 1338 dev_dbg(card->dev, "ASoC: probe %s dai link %d late %d\n",
1337 card->name, num, order); 1339 card->name, num, order);
1338 1340
1339 /* config components */ 1341 /* config components */
@@ -1359,8 +1361,9 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order)
1359 if (cpu_dai->driver->probe) { 1361 if (cpu_dai->driver->probe) {
1360 ret = cpu_dai->driver->probe(cpu_dai); 1362 ret = cpu_dai->driver->probe(cpu_dai);
1361 if (ret < 0) { 1363 if (ret < 0) {
1362 pr_err("asoc: failed to probe CPU DAI %s: %d\n", 1364 dev_err(cpu_dai->dev,
1363 cpu_dai->name, ret); 1365 "ASoC: failed to probe CPU DAI %s: %d\n",
1366 cpu_dai->name, ret);
1364 module_put(cpu_dai->dev->driver->owner); 1367 module_put(cpu_dai->dev->driver->owner);
1365 return ret; 1368 return ret;
1366 } 1369 }
@@ -1375,8 +1378,9 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order)
1375 if (codec_dai->driver->probe) { 1378 if (codec_dai->driver->probe) {
1376 ret = codec_dai->driver->probe(codec_dai); 1379 ret = codec_dai->driver->probe(codec_dai);
1377 if (ret < 0) { 1380 if (ret < 0) {
1378 pr_err("asoc: failed to probe CODEC DAI %s: %d\n", 1381 dev_err(codec_dai->dev,
1379 codec_dai->name, ret); 1382 "ASoC: failed to probe CODEC DAI %s: %d\n",
1383 codec_dai->name, ret);
1380 return ret; 1384 return ret;
1381 } 1385 }
1382 } 1386 }
@@ -1396,13 +1400,14 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order)
1396 1400
1397 ret = device_create_file(rtd->dev, &dev_attr_pmdown_time); 1401 ret = device_create_file(rtd->dev, &dev_attr_pmdown_time);
1398 if (ret < 0) 1402 if (ret < 0)
1399 pr_warn("asoc: failed to add pmdown_time sysfs:%d\n", ret); 1403 dev_warn(rtd->dev, "ASoC: failed to add pmdown_time sysfs: %d\n",
1404 ret);
1400 1405
1401 if (cpu_dai->driver->compress_dai) { 1406 if (cpu_dai->driver->compress_dai) {
1402 /*create compress_device"*/ 1407 /*create compress_device"*/
1403 ret = soc_new_compress(rtd, num); 1408 ret = soc_new_compress(rtd, num);
1404 if (ret < 0) { 1409 if (ret < 0) {
1405 pr_err("asoc: can't create compress %s\n", 1410 dev_err(card->dev, "ASoC: can't create compress %s\n",
1406 dai_link->stream_name); 1411 dai_link->stream_name);
1407 return ret; 1412 return ret;
1408 } 1413 }
@@ -1412,7 +1417,7 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order)
1412 /* create the pcm */ 1417 /* create the pcm */
1413 ret = soc_new_pcm(rtd, num); 1418 ret = soc_new_pcm(rtd, num);
1414 if (ret < 0) { 1419 if (ret < 0) {
1415 pr_err("asoc: can't create pcm %s :%d\n", 1420 dev_err(card->dev, "ASoC: can't create pcm %s :%d\n",
1416 dai_link->stream_name, ret); 1421 dai_link->stream_name, ret);
1417 return ret; 1422 return ret;
1418 } 1423 }
@@ -1424,7 +1429,7 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order)
1424 ret = snd_soc_dapm_new_pcm(card, dai_link->params, 1429 ret = snd_soc_dapm_new_pcm(card, dai_link->params,
1425 capture_w, play_w); 1430 capture_w, play_w);
1426 if (ret != 0) { 1431 if (ret != 0) {
1427 dev_err(card->dev, "Can't link %s to %s: %d\n", 1432 dev_err(card->dev, "ASoC: Can't link %s to %s: %d\n",
1428 play_w->name, capture_w->name, ret); 1433 play_w->name, capture_w->name, ret);
1429 return ret; 1434 return ret;
1430 } 1435 }
@@ -1436,7 +1441,7 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order)
1436 ret = snd_soc_dapm_new_pcm(card, dai_link->params, 1441 ret = snd_soc_dapm_new_pcm(card, dai_link->params,
1437 capture_w, play_w); 1442 capture_w, play_w);
1438 if (ret != 0) { 1443 if (ret != 0) {
1439 dev_err(card->dev, "Can't link %s to %s: %d\n", 1444 dev_err(card->dev, "ASoC: Can't link %s to %s: %d\n",
1440 play_w->name, capture_w->name, ret); 1445 play_w->name, capture_w->name, ret);
1441 return ret; 1446 return ret;
1442 } 1447 }
@@ -1473,7 +1478,8 @@ static int soc_register_ac97_dai_link(struct snd_soc_pcm_runtime *rtd)
1473 1478
1474 ret = soc_ac97_dev_register(rtd->codec); 1479 ret = soc_ac97_dev_register(rtd->codec);
1475 if (ret < 0) { 1480 if (ret < 0) {
1476 pr_err("asoc: AC97 device register failed:%d\n", ret); 1481 dev_err(rtd->codec->dev,
1482 "ASoC: AC97 device register failed: %d\n", ret);
1477 return ret; 1483 return ret;
1478 } 1484 }
1479 1485
@@ -1502,7 +1508,7 @@ static int soc_check_aux_dev(struct snd_soc_card *card, int num)
1502 return 0; 1508 return 0;
1503 } 1509 }
1504 1510
1505 dev_err(card->dev, "%s not registered\n", aux_dev->codec_name); 1511 dev_err(card->dev, "ASoC: %s not registered\n", aux_dev->codec_name);
1506 1512
1507 return -EPROBE_DEFER; 1513 return -EPROBE_DEFER;
1508} 1514}
@@ -1518,7 +1524,7 @@ static int soc_probe_aux_dev(struct snd_soc_card *card, int num)
1518 if (!strcmp(codec->name, aux_dev->codec_name)) { 1524 if (!strcmp(codec->name, aux_dev->codec_name)) {
1519 if (codec->probed) { 1525 if (codec->probed) {
1520 dev_err(codec->dev, 1526 dev_err(codec->dev,
1521 "asoc: codec already probed"); 1527 "ASoC: codec already probed");
1522 ret = -EBUSY; 1528 ret = -EBUSY;
1523 goto out; 1529 goto out;
1524 } 1530 }
@@ -1526,7 +1532,7 @@ static int soc_probe_aux_dev(struct snd_soc_card *card, int num)
1526 } 1532 }
1527 } 1533 }
1528 /* codec not found */ 1534 /* codec not found */
1529 dev_err(card->dev, "asoc: codec %s not found", aux_dev->codec_name); 1535 dev_err(card->dev, "ASoC: codec %s not found", aux_dev->codec_name);
1530 return -EPROBE_DEFER; 1536 return -EPROBE_DEFER;
1531 1537
1532found: 1538found:
@@ -1569,8 +1575,8 @@ static int snd_soc_init_codec_cache(struct snd_soc_codec *codec,
1569 codec->compress_type = compress_type; 1575 codec->compress_type = compress_type;
1570 ret = snd_soc_cache_init(codec); 1576 ret = snd_soc_cache_init(codec);
1571 if (ret < 0) { 1577 if (ret < 0) {
1572 dev_err(codec->dev, "Failed to set cache compression type: %d\n", 1578 dev_err(codec->dev, "ASoC: Failed to set cache compression"
1573 ret); 1579 " type: %d\n", ret);
1574 return ret; 1580 return ret;
1575 } 1581 }
1576 codec->cache_init = 1; 1582 codec->cache_init = 1;
@@ -1626,8 +1632,8 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
1626 ret = snd_card_create(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1, 1632 ret = snd_card_create(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
1627 card->owner, 0, &card->snd_card); 1633 card->owner, 0, &card->snd_card);
1628 if (ret < 0) { 1634 if (ret < 0) {
1629 pr_err("asoc: can't create sound card for card %s: %d\n", 1635 dev_err(card->dev, "ASoC: can't create sound card for"
1630 card->name, ret); 1636 " card %s: %d\n", card->name, ret);
1631 goto base_error; 1637 goto base_error;
1632 } 1638 }
1633 card->snd_card->dev = card->dev; 1639 card->snd_card->dev = card->dev;
@@ -1663,8 +1669,9 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
1663 for (i = 0; i < card->num_links; i++) { 1669 for (i = 0; i < card->num_links; i++) {
1664 ret = soc_probe_link_components(card, i, order); 1670 ret = soc_probe_link_components(card, i, order);
1665 if (ret < 0) { 1671 if (ret < 0) {
1666 pr_err("asoc: failed to instantiate card %s: %d\n", 1672 dev_err(card->dev,
1667 card->name, ret); 1673 "ASoC: failed to instantiate card %d\n",
1674 ret);
1668 goto probe_dai_err; 1675 goto probe_dai_err;
1669 } 1676 }
1670 } 1677 }
@@ -1676,8 +1683,9 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
1676 for (i = 0; i < card->num_links; i++) { 1683 for (i = 0; i < card->num_links; i++) {
1677 ret = soc_probe_link_dais(card, i, order); 1684 ret = soc_probe_link_dais(card, i, order);
1678 if (ret < 0) { 1685 if (ret < 0) {
1679 pr_err("asoc: failed to instantiate card %s: %d\n", 1686 dev_err(card->dev,
1680 card->name, ret); 1687 "ASoC: failed to instantiate card %d\n",
1688 ret);
1681 goto probe_dai_err; 1689 goto probe_dai_err;
1682 } 1690 }
1683 } 1691 }
@@ -1686,8 +1694,9 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
1686 for (i = 0; i < card->num_aux_devs; i++) { 1694 for (i = 0; i < card->num_aux_devs; i++) {
1687 ret = soc_probe_aux_dev(card, i); 1695 ret = soc_probe_aux_dev(card, i);
1688 if (ret < 0) { 1696 if (ret < 0) {
1689 pr_err("asoc: failed to add auxiliary devices %s: %d\n", 1697 dev_err(card->dev,
1690 card->name, ret); 1698 "ASoC: failed to add auxiliary devices %d\n",
1699 ret);
1691 goto probe_aux_dev_err; 1700 goto probe_aux_dev_err;
1692 } 1701 }
1693 } 1702 }
@@ -1712,7 +1721,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
1712 dai_fmt); 1721 dai_fmt);
1713 if (ret != 0 && ret != -ENOTSUPP) 1722 if (ret != 0 && ret != -ENOTSUPP)
1714 dev_warn(card->rtd[i].codec_dai->dev, 1723 dev_warn(card->rtd[i].codec_dai->dev,
1715 "Failed to set DAI format: %d\n", 1724 "ASoC: Failed to set DAI format: %d\n",
1716 ret); 1725 ret);
1717 } 1726 }
1718 1727
@@ -1723,7 +1732,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
1723 dai_fmt); 1732 dai_fmt);
1724 if (ret != 0 && ret != -ENOTSUPP) 1733 if (ret != 0 && ret != -ENOTSUPP)
1725 dev_warn(card->rtd[i].cpu_dai->dev, 1734 dev_warn(card->rtd[i].cpu_dai->dev,
1726 "Failed to set DAI format: %d\n", 1735 "ASoC: Failed to set DAI format: %d\n",
1727 ret); 1736 ret);
1728 } else if (dai_fmt) { 1737 } else if (dai_fmt) {
1729 /* Flip the polarity for the "CPU" end */ 1738 /* Flip the polarity for the "CPU" end */
@@ -1748,7 +1757,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
1748 dai_fmt); 1757 dai_fmt);
1749 if (ret != 0 && ret != -ENOTSUPP) 1758 if (ret != 0 && ret != -ENOTSUPP)
1750 dev_warn(card->rtd[i].cpu_dai->dev, 1759 dev_warn(card->rtd[i].cpu_dai->dev,
1751 "Failed to set DAI format: %d\n", 1760 "ASoC: Failed to set DAI format: %d\n",
1752 ret); 1761 ret);
1753 } 1762 }
1754 } 1763 }
@@ -1775,7 +1784,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
1775 if (card->late_probe) { 1784 if (card->late_probe) {
1776 ret = card->late_probe(card); 1785 ret = card->late_probe(card);
1777 if (ret < 0) { 1786 if (ret < 0) {
1778 dev_err(card->dev, "%s late_probe() failed: %d\n", 1787 dev_err(card->dev, "ASoC: %s late_probe() failed: %d\n",
1779 card->name, ret); 1788 card->name, ret);
1780 goto probe_aux_dev_err; 1789 goto probe_aux_dev_err;
1781 } 1790 }
@@ -1789,8 +1798,8 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
1789 1798
1790 ret = snd_card_register(card->snd_card); 1799 ret = snd_card_register(card->snd_card);
1791 if (ret < 0) { 1800 if (ret < 0) {
1792 pr_err("asoc: failed to register soundcard for %s: %d\n", 1801 dev_err(card->dev, "ASoC: failed to register soundcard %d\n",
1793 card->name, ret); 1802 ret);
1794 goto probe_aux_dev_err; 1803 goto probe_aux_dev_err;
1795 } 1804 }
1796 1805
@@ -1799,8 +1808,8 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
1799 for (i = 0; i < card->num_rtd; i++) { 1808 for (i = 0; i < card->num_rtd; i++) {
1800 ret = soc_register_ac97_dai_link(&card->rtd[i]); 1809 ret = soc_register_ac97_dai_link(&card->rtd[i]);
1801 if (ret < 0) { 1810 if (ret < 0) {
1802 pr_err("asoc: failed to register AC97 %s: %d\n", 1811 dev_err(card->dev, "ASoC: failed to register AC97:"
1803 card->name, ret); 1812 " %d\n", ret);
1804 while (--i >= 0) 1813 while (--i >= 0)
1805 soc_unregister_ac97_dai_link(card->rtd[i].codec); 1814 soc_unregister_ac97_dai_link(card->rtd[i].codec);
1806 goto probe_aux_dev_err; 1815 goto probe_aux_dev_err;
@@ -1846,7 +1855,7 @@ static int soc_probe(struct platform_device *pdev)
1846 return -EINVAL; 1855 return -EINVAL;
1847 1856
1848 dev_warn(&pdev->dev, 1857 dev_warn(&pdev->dev,
1849 "ASoC machine %s should use snd_soc_register_card()\n", 1858 "ASoC: machine %s should use snd_soc_register_card()\n",
1850 card->name); 1859 card->name);
1851 1860
1852 /* Bodge while we unpick instantiation */ 1861 /* Bodge while we unpick instantiation */
@@ -1996,7 +2005,7 @@ int snd_soc_platform_read(struct snd_soc_platform *platform,
1996 unsigned int ret; 2005 unsigned int ret;
1997 2006
1998 if (!platform->driver->read) { 2007 if (!platform->driver->read) {
1999 dev_err(platform->dev, "platform has no read back\n"); 2008 dev_err(platform->dev, "ASoC: platform has no read back\n");
2000 return -1; 2009 return -1;
2001 } 2010 }
2002 2011
@@ -2012,7 +2021,7 @@ int snd_soc_platform_write(struct snd_soc_platform *platform,
2012 unsigned int reg, unsigned int val) 2021 unsigned int reg, unsigned int val)
2013{ 2022{
2014 if (!platform->driver->write) { 2023 if (!platform->driver->write) {
2015 dev_err(platform->dev, "platform has no write back\n"); 2024 dev_err(platform->dev, "ASoC: platform has no write back\n");
2016 return -1; 2025 return -1;
2017 } 2026 }
2018 2027
@@ -2283,7 +2292,8 @@ static int snd_soc_add_controls(struct snd_card *card, struct device *dev,
2283 err = snd_ctl_add(card, snd_soc_cnew(control, data, 2292 err = snd_ctl_add(card, snd_soc_cnew(control, data,
2284 control->name, prefix)); 2293 control->name, prefix));
2285 if (err < 0) { 2294 if (err < 0) {
2286 dev_err(dev, "Failed to add %s: %d\n", control->name, err); 2295 dev_err(dev, "ASoC: Failed to add %s: %d\n",
2296 control->name, err);
2287 return err; 2297 return err;
2288 } 2298 }
2289 } 2299 }
@@ -2786,8 +2796,9 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
2786 val = (ucontrol->value.integer.value[0] + min) & mask; 2796 val = (ucontrol->value.integer.value[0] + min) & mask;
2787 val = val << shift; 2797 val = val << shift;
2788 2798
2789 if (snd_soc_update_bits_locked(codec, reg, val_mask, val)) 2799 err = snd_soc_update_bits_locked(codec, reg, val_mask, val);
2790 return err; 2800 if (err < 0)
2801 return err;
2791 2802
2792 if (snd_soc_volsw_is_stereo(mc)) { 2803 if (snd_soc_volsw_is_stereo(mc)) {
2793 val_mask = mask << rshift; 2804 val_mask = mask << rshift;
@@ -3533,15 +3544,14 @@ int snd_soc_register_card(struct snd_soc_card *card)
3533 * not both or neither. 3544 * not both or neither.
3534 */ 3545 */
3535 if (!!link->codec_name == !!link->codec_of_node) { 3546 if (!!link->codec_name == !!link->codec_of_node) {
3536 dev_err(card->dev, 3547 dev_err(card->dev, "ASoC: Neither/both codec"
3537 "Neither/both codec name/of_node are set for %s\n", 3548 " name/of_node are set for %s\n", link->name);
3538 link->name);
3539 return -EINVAL; 3549 return -EINVAL;
3540 } 3550 }
3541 /* Codec DAI name must be specified */ 3551 /* Codec DAI name must be specified */
3542 if (!link->codec_dai_name) { 3552 if (!link->codec_dai_name) {
3543 dev_err(card->dev, "codec_dai_name not set for %s\n", 3553 dev_err(card->dev, "ASoC: codec_dai_name not"
3544 link->name); 3554 " set for %s\n", link->name);
3545 return -EINVAL; 3555 return -EINVAL;
3546 } 3556 }
3547 3557
@@ -3550,8 +3560,8 @@ int snd_soc_register_card(struct snd_soc_card *card)
3550 * can be left unspecified, and a dummy platform will be used. 3560 * can be left unspecified, and a dummy platform will be used.
3551 */ 3561 */
3552 if (link->platform_name && link->platform_of_node) { 3562 if (link->platform_name && link->platform_of_node) {
3553 dev_err(card->dev, 3563 dev_err(card->dev, "ASoC: Both platform name/of_node"
3554 "Both platform name/of_node are set for %s\n", link->name); 3564 " are set for %s\n", link->name);
3555 return -EINVAL; 3565 return -EINVAL;
3556 } 3566 }
3557 3567
@@ -3561,9 +3571,8 @@ int snd_soc_register_card(struct snd_soc_card *card)
3561 * name alone.. 3571 * name alone..
3562 */ 3572 */
3563 if (link->cpu_name && link->cpu_of_node) { 3573 if (link->cpu_name && link->cpu_of_node) {
3564 dev_err(card->dev, 3574 dev_err(card->dev, "ASoC: Neither/both "
3565 "Neither/both cpu name/of_node are set for %s\n", 3575 "cpu name/of_node are set for %s\n",link->name);
3566 link->name);
3567 return -EINVAL; 3576 return -EINVAL;
3568 } 3577 }
3569 /* 3578 /*
@@ -3572,9 +3581,8 @@ int snd_soc_register_card(struct snd_soc_card *card)
3572 */ 3581 */
3573 if (!link->cpu_dai_name && 3582 if (!link->cpu_dai_name &&
3574 !(link->cpu_name || link->cpu_of_node)) { 3583 !(link->cpu_name || link->cpu_of_node)) {
3575 dev_err(card->dev, 3584 dev_err(card->dev, "ASoC: Neither cpu_dai_name nor "
3576 "Neither cpu_dai_name nor cpu_name/of_node are set for %s\n", 3585 "cpu_name/of_node are set for %s\n", link->name);
3577 link->name);
3578 return -EINVAL; 3586 return -EINVAL;
3579 } 3587 }
3580 } 3588 }
@@ -3621,7 +3629,7 @@ int snd_soc_unregister_card(struct snd_soc_card *card)
3621{ 3629{
3622 if (card->instantiated) 3630 if (card->instantiated)
3623 soc_cleanup_card_resources(card); 3631 soc_cleanup_card_resources(card);
3624 dev_dbg(card->dev, "Unregistered card '%s'\n", card->name); 3632 dev_dbg(card->dev, "ASoC: Unregistered card '%s'\n", card->name);
3625 3633
3626 return 0; 3634 return 0;
3627} 3635}
@@ -3678,8 +3686,8 @@ static inline char *fmt_multiple_name(struct device *dev,
3678 struct snd_soc_dai_driver *dai_drv) 3686 struct snd_soc_dai_driver *dai_drv)
3679{ 3687{
3680 if (dai_drv->name == NULL) { 3688 if (dai_drv->name == NULL) {
3681 pr_err("asoc: error - multiple DAI %s registered with no name\n", 3689 dev_err(dev, "ASoC: error - multiple DAI %s registered with"
3682 dev_name(dev)); 3690 " no name\n", dev_name(dev));
3683 return NULL; 3691 return NULL;
3684 } 3692 }
3685 3693
@@ -3697,7 +3705,7 @@ int snd_soc_register_dai(struct device *dev,
3697 struct snd_soc_codec *codec; 3705 struct snd_soc_codec *codec;
3698 struct snd_soc_dai *dai; 3706 struct snd_soc_dai *dai;
3699 3707
3700 dev_dbg(dev, "dai register %s\n", dev_name(dev)); 3708 dev_dbg(dev, "ASoC: dai register %s\n", dev_name(dev));
3701 3709
3702 dai = kzalloc(sizeof(struct snd_soc_dai), GFP_KERNEL); 3710 dai = kzalloc(sizeof(struct snd_soc_dai), GFP_KERNEL);
3703 if (dai == NULL) 3711 if (dai == NULL)
@@ -3720,7 +3728,7 @@ int snd_soc_register_dai(struct device *dev,
3720 3728
3721 list_for_each_entry(codec, &codec_list, list) { 3729 list_for_each_entry(codec, &codec_list, list) {
3722 if (codec->dev == dev) { 3730 if (codec->dev == dev) {
3723 dev_dbg(dev, "Mapped DAI %s to CODEC %s\n", 3731 dev_dbg(dev, "ASoC: Mapped DAI %s to CODEC %s\n",
3724 dai->name, codec->name); 3732 dai->name, codec->name);
3725 dai->codec = codec; 3733 dai->codec = codec;
3726 break; 3734 break;
@@ -3734,7 +3742,7 @@ int snd_soc_register_dai(struct device *dev,
3734 3742
3735 mutex_unlock(&client_mutex); 3743 mutex_unlock(&client_mutex);
3736 3744
3737 pr_debug("Registered DAI '%s'\n", dai->name); 3745 dev_dbg(dev, "ASoC: Registered DAI '%s'\n", dai->name);
3738 3746
3739 return 0; 3747 return 0;
3740} 3748}
@@ -3760,7 +3768,7 @@ found:
3760 list_del(&dai->list); 3768 list_del(&dai->list);
3761 mutex_unlock(&client_mutex); 3769 mutex_unlock(&client_mutex);
3762 3770
3763 pr_debug("Unregistered DAI '%s'\n", dai->name); 3771 dev_dbg(dev, "ASoC: Unregistered DAI '%s'\n", dai->name);
3764 kfree(dai->name); 3772 kfree(dai->name);
3765 kfree(dai); 3773 kfree(dai);
3766} 3774}
@@ -3779,7 +3787,7 @@ int snd_soc_register_dais(struct device *dev,
3779 struct snd_soc_dai *dai; 3787 struct snd_soc_dai *dai;
3780 int i, ret = 0; 3788 int i, ret = 0;
3781 3789
3782 dev_dbg(dev, "dai register %s #%Zu\n", dev_name(dev), count); 3790 dev_dbg(dev, "ASoC: dai register %s #%Zu\n", dev_name(dev), count);
3783 3791
3784 for (i = 0; i < count; i++) { 3792 for (i = 0; i < count; i++) {
3785 3793
@@ -3811,8 +3819,8 @@ int snd_soc_register_dais(struct device *dev,
3811 3819
3812 list_for_each_entry(codec, &codec_list, list) { 3820 list_for_each_entry(codec, &codec_list, list) {
3813 if (codec->dev == dev) { 3821 if (codec->dev == dev) {
3814 dev_dbg(dev, "Mapped DAI %s to CODEC %s\n", 3822 dev_dbg(dev, "ASoC: Mapped DAI %s to "
3815 dai->name, codec->name); 3823 "CODEC %s\n", dai->name, codec->name);
3816 dai->codec = codec; 3824 dai->codec = codec;
3817 break; 3825 break;
3818 } 3826 }
@@ -3825,7 +3833,7 @@ int snd_soc_register_dais(struct device *dev,
3825 3833
3826 mutex_unlock(&client_mutex); 3834 mutex_unlock(&client_mutex);
3827 3835
3828 pr_debug("Registered DAI '%s'\n", dai->name); 3836 dev_dbg(dai->dev, "ASoC: Registered DAI '%s'\n", dai->name);
3829 } 3837 }
3830 3838
3831 return 0; 3839 return 0;
@@ -3863,7 +3871,7 @@ int snd_soc_register_platform(struct device *dev,
3863{ 3871{
3864 struct snd_soc_platform *platform; 3872 struct snd_soc_platform *platform;
3865 3873
3866 dev_dbg(dev, "platform register %s\n", dev_name(dev)); 3874 dev_dbg(dev, "ASoC: platform register %s\n", dev_name(dev));
3867 3875
3868 platform = kzalloc(sizeof(struct snd_soc_platform), GFP_KERNEL); 3876 platform = kzalloc(sizeof(struct snd_soc_platform), GFP_KERNEL);
3869 if (platform == NULL) 3877 if (platform == NULL)
@@ -3887,7 +3895,7 @@ int snd_soc_register_platform(struct device *dev,
3887 list_add(&platform->list, &platform_list); 3895 list_add(&platform->list, &platform_list);
3888 mutex_unlock(&client_mutex); 3896 mutex_unlock(&client_mutex);
3889 3897
3890 pr_debug("Registered platform '%s'\n", platform->name); 3898 dev_dbg(dev, "ASoC: Registered platform '%s'\n", platform->name);
3891 3899
3892 return 0; 3900 return 0;
3893} 3901}
@@ -3913,7 +3921,7 @@ found:
3913 list_del(&platform->list); 3921 list_del(&platform->list);
3914 mutex_unlock(&client_mutex); 3922 mutex_unlock(&client_mutex);
3915 3923
3916 pr_debug("Unregistered platform '%s'\n", platform->name); 3924 dev_dbg(dev, "ASoC: Unregistered platform '%s'\n", platform->name);
3917 kfree(platform->name); 3925 kfree(platform->name);
3918 kfree(platform); 3926 kfree(platform);
3919} 3927}
@@ -4006,7 +4014,7 @@ int snd_soc_register_codec(struct device *dev,
4006 codec->reg_size = reg_size; 4014 codec->reg_size = reg_size;
4007 /* it is necessary to make a copy of the default register cache 4015 /* it is necessary to make a copy of the default register cache
4008 * because in the case of using a compression type that requires 4016 * because in the case of using a compression type that requires
4009 * the default register cache to be marked as __devinitconst the 4017 * the default register cache to be marked as the
4010 * kernel might have freed the array by the time we initialize 4018 * kernel might have freed the array by the time we initialize
4011 * the cache. 4019 * the cache.
4012 */ 4020 */
@@ -4042,11 +4050,11 @@ int snd_soc_register_codec(struct device *dev,
4042 if (num_dai) { 4050 if (num_dai) {
4043 ret = snd_soc_register_dais(dev, dai_drv, num_dai); 4051 ret = snd_soc_register_dais(dev, dai_drv, num_dai);
4044 if (ret < 0) 4052 if (ret < 0)
4045 dev_err(codec->dev, "Failed to regster DAIs: %d\n", 4053 dev_err(codec->dev, "ASoC: Failed to regster"
4046 ret); 4054 " DAIs: %d\n", ret);
4047 } 4055 }
4048 4056
4049 pr_debug("Registered codec '%s'\n", codec->name); 4057 dev_dbg(codec->dev, "ASoC: Registered codec '%s'\n", codec->name);
4050 return 0; 4058 return 0;
4051 4059
4052fail: 4060fail:
@@ -4081,7 +4089,7 @@ found:
4081 list_del(&codec->list); 4089 list_del(&codec->list);
4082 mutex_unlock(&client_mutex); 4090 mutex_unlock(&client_mutex);
4083 4091
4084 pr_debug("Unregistered codec '%s'\n", codec->name); 4092 dev_dbg(codec->dev, "ASoC: Unregistered codec '%s'\n", codec->name);
4085 4093
4086 snd_soc_cache_exit(codec); 4094 snd_soc_cache_exit(codec);
4087 kfree(codec->reg_def_copy); 4095 kfree(codec->reg_def_copy);
@@ -4105,7 +4113,7 @@ int snd_soc_of_parse_card_name(struct snd_soc_card *card,
4105 */ 4113 */
4106 if (ret < 0 && ret != -EINVAL) { 4114 if (ret < 0 && ret != -EINVAL) {
4107 dev_err(card->dev, 4115 dev_err(card->dev,
4108 "Property '%s' could not be read: %d\n", 4116 "ASoC: Property '%s' could not be read: %d\n",
4109 propname, ret); 4117 propname, ret);
4110 return ret; 4118 return ret;
4111 } 4119 }
@@ -4124,15 +4132,13 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
4124 4132
4125 num_routes = of_property_count_strings(np, propname); 4133 num_routes = of_property_count_strings(np, propname);
4126 if (num_routes < 0 || num_routes & 1) { 4134 if (num_routes < 0 || num_routes & 1) {
4127 dev_err(card->dev, 4135 dev_err(card->dev, "ASoC: Property '%s' does not exist or its"
4128 "Property '%s' does not exist or its length is not even\n", 4136 " length is not even\n", propname);
4129 propname);
4130 return -EINVAL; 4137 return -EINVAL;
4131 } 4138 }
4132 num_routes /= 2; 4139 num_routes /= 2;
4133 if (!num_routes) { 4140 if (!num_routes) {
4134 dev_err(card->dev, 4141 dev_err(card->dev, "ASoC: Property '%s's length is zero\n",
4135 "Property '%s's length is zero\n",
4136 propname); 4142 propname);
4137 return -EINVAL; 4143 return -EINVAL;
4138 } 4144 }
@@ -4141,7 +4147,7 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
4141 GFP_KERNEL); 4147 GFP_KERNEL);
4142 if (!routes) { 4148 if (!routes) {
4143 dev_err(card->dev, 4149 dev_err(card->dev,
4144 "Could not allocate DAPM route table\n"); 4150 "ASoC: Could not allocate DAPM route table\n");
4145 return -EINVAL; 4151 return -EINVAL;
4146 } 4152 }
4147 4153
@@ -4149,9 +4155,9 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
4149 ret = of_property_read_string_index(np, propname, 4155 ret = of_property_read_string_index(np, propname,
4150 2 * i, &routes[i].sink); 4156 2 * i, &routes[i].sink);
4151 if (ret) { 4157 if (ret) {
4152 dev_err(card->dev, 4158 dev_err(card->dev, "ASoC: Property '%s' index %d"
4153 "Property '%s' index %d could not be read: %d\n", 4159 " could not be read: %d\n", propname, 2 * i,
4154 propname, 2 * i, ret); 4160 ret);
4155 kfree(routes); 4161 kfree(routes);
4156 return -EINVAL; 4162 return -EINVAL;
4157 } 4163 }
@@ -4159,8 +4165,8 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
4159 (2 * i) + 1, &routes[i].source); 4165 (2 * i) + 1, &routes[i].source);
4160 if (ret) { 4166 if (ret) {
4161 dev_err(card->dev, 4167 dev_err(card->dev,
4162 "Property '%s' index %d could not be read: %d\n", 4168 "ASoC: Property '%s' index %d could not be"
4163 propname, (2 * i) + 1, ret); 4169 " read: %d\n", propname, (2 * i) + 1, ret);
4164 kfree(routes); 4170 kfree(routes);
4165 return -EINVAL; 4171 return -EINVAL;
4166 } 4172 }
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index d0a4be38dc0f..1e36bc81e5af 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -220,7 +220,7 @@ static int soc_widget_read(struct snd_soc_dapm_widget *w, int reg)
220 else if (w->platform) 220 else if (w->platform)
221 return snd_soc_platform_read(w->platform, reg); 221 return snd_soc_platform_read(w->platform, reg);
222 222
223 dev_err(w->dapm->dev, "no valid widget read method\n"); 223 dev_err(w->dapm->dev, "ASoC: no valid widget read method\n");
224 return -1; 224 return -1;
225} 225}
226 226
@@ -231,7 +231,7 @@ static int soc_widget_write(struct snd_soc_dapm_widget *w, int reg, int val)
231 else if (w->platform) 231 else if (w->platform)
232 return snd_soc_platform_write(w->platform, reg, val); 232 return snd_soc_platform_write(w->platform, reg, val);
233 233
234 dev_err(w->dapm->dev, "no valid widget write method\n"); 234 dev_err(w->dapm->dev, "ASoC: no valid widget write method\n");
235 return -1; 235 return -1;
236} 236}
237 237
@@ -546,7 +546,7 @@ static int dapm_new_mixer(struct snd_soc_dapm_widget *w)
546 wlist = kzalloc(wlistsize, GFP_KERNEL); 546 wlist = kzalloc(wlistsize, GFP_KERNEL);
547 if (wlist == NULL) { 547 if (wlist == NULL) {
548 dev_err(dapm->dev, 548 dev_err(dapm->dev,
549 "asoc: can't allocate widget list for %s\n", 549 "ASoC: can't allocate widget list for %s\n",
550 w->name); 550 w->name);
551 return -ENOMEM; 551 return -ENOMEM;
552 } 552 }
@@ -595,9 +595,9 @@ static int dapm_new_mixer(struct snd_soc_dapm_widget *w)
595 prefix); 595 prefix);
596 ret = snd_ctl_add(card, path->kcontrol); 596 ret = snd_ctl_add(card, path->kcontrol);
597 if (ret < 0) { 597 if (ret < 0) {
598 dev_err(dapm->dev, 598 dev_err(dapm->dev, "ASoC: failed to add widget"
599 "asoc: failed to add dapm kcontrol %s: %d\n", 599 " %s dapm kcontrol %s: %d\n",
600 path->long_name, ret); 600 w->name, path->long_name, ret);
601 kfree(wlist); 601 kfree(wlist);
602 kfree(path->long_name); 602 kfree(path->long_name);
603 path->long_name = NULL; 603 path->long_name = NULL;
@@ -626,7 +626,7 @@ static int dapm_new_mux(struct snd_soc_dapm_widget *w)
626 626
627 if (w->num_kcontrols != 1) { 627 if (w->num_kcontrols != 1) {
628 dev_err(dapm->dev, 628 dev_err(dapm->dev,
629 "asoc: mux %s has incorrect number of controls\n", 629 "ASoC: mux %s has incorrect number of controls\n",
630 w->name); 630 w->name);
631 return -EINVAL; 631 return -EINVAL;
632 } 632 }
@@ -645,7 +645,7 @@ static int dapm_new_mux(struct snd_soc_dapm_widget *w)
645 wlist = krealloc(wlist, wlistsize, GFP_KERNEL); 645 wlist = krealloc(wlist, wlistsize, GFP_KERNEL);
646 if (wlist == NULL) { 646 if (wlist == NULL) {
647 dev_err(dapm->dev, 647 dev_err(dapm->dev,
648 "asoc: can't allocate widget list for %s\n", w->name); 648 "ASoC: can't allocate widget list for %s\n", w->name);
649 return -ENOMEM; 649 return -ENOMEM;
650 } 650 }
651 wlist->num_widgets = wlistentries; 651 wlist->num_widgets = wlistentries;
@@ -677,7 +677,7 @@ static int dapm_new_mux(struct snd_soc_dapm_widget *w)
677 name + prefix_len, prefix); 677 name + prefix_len, prefix);
678 ret = snd_ctl_add(card, kcontrol); 678 ret = snd_ctl_add(card, kcontrol);
679 if (ret < 0) { 679 if (ret < 0) {
680 dev_err(dapm->dev, "failed to add kcontrol %s: %d\n", 680 dev_err(dapm->dev, "ASoC: failed to add kcontrol %s: %d\n",
681 w->name, ret); 681 w->name, ret);
682 kfree(wlist); 682 kfree(wlist);
683 return ret; 683 return ret;
@@ -699,7 +699,7 @@ static int dapm_new_pga(struct snd_soc_dapm_widget *w)
699{ 699{
700 if (w->num_kcontrols) 700 if (w->num_kcontrols)
701 dev_err(w->dapm->dev, 701 dev_err(w->dapm->dev,
702 "asoc: PGA controls not supported: '%s'\n", w->name); 702 "ASoC: PGA controls not supported: '%s'\n", w->name);
703 703
704 return 0; 704 return 0;
705} 705}
@@ -725,7 +725,7 @@ static int snd_soc_dapm_suspend_check(struct snd_soc_dapm_widget *widget)
725 case SNDRV_CTL_POWER_D3hot: 725 case SNDRV_CTL_POWER_D3hot:
726 case SNDRV_CTL_POWER_D3cold: 726 case SNDRV_CTL_POWER_D3cold:
727 if (widget->ignore_suspend) 727 if (widget->ignore_suspend)
728 dev_dbg(widget->dapm->dev, "%s ignoring suspend\n", 728 dev_dbg(widget->dapm->dev, "ASoC: %s ignoring suspend\n",
729 widget->name); 729 widget->name);
730 return widget->ignore_suspend; 730 return widget->ignore_suspend;
731 default: 731 default:
@@ -757,14 +757,14 @@ static int dapm_list_add_widget(struct snd_soc_dapm_widget_list **list,
757 wlistentries * sizeof(struct snd_soc_dapm_widget *); 757 wlistentries * sizeof(struct snd_soc_dapm_widget *);
758 *list = krealloc(wlist, wlistsize, GFP_KERNEL); 758 *list = krealloc(wlist, wlistsize, GFP_KERNEL);
759 if (*list == NULL) { 759 if (*list == NULL) {
760 dev_err(w->dapm->dev, "can't allocate widget list for %s\n", 760 dev_err(w->dapm->dev, "ASoC: can't allocate widget list for %s\n",
761 w->name); 761 w->name);
762 return -ENOMEM; 762 return -ENOMEM;
763 } 763 }
764 wlist = *list; 764 wlist = *list;
765 765
766 /* insert the widget */ 766 /* insert the widget */
767 dev_dbg(w->dapm->dev, "added %s in widget list pos %d\n", 767 dev_dbg(w->dapm->dev, "ASoC: added %s in widget list pos %d\n",
768 w->name, wlist->num_widgets); 768 w->name, wlist->num_widgets);
769 769
770 wlist->widgets[wlist->num_widgets] = w; 770 wlist->widgets[wlist->num_widgets] = w;
@@ -844,7 +844,8 @@ static int is_connected_output_ep(struct snd_soc_dapm_widget *widget,
844 int err; 844 int err;
845 err = dapm_list_add_widget(list, path->sink); 845 err = dapm_list_add_widget(list, path->sink);
846 if (err < 0) { 846 if (err < 0) {
847 dev_err(widget->dapm->dev, "could not add widget %s\n", 847 dev_err(widget->dapm->dev,
848 "ASoC: could not add widget %s\n",
848 widget->name); 849 widget->name);
849 return con; 850 return con;
850 } 851 }
@@ -943,7 +944,8 @@ static int is_connected_input_ep(struct snd_soc_dapm_widget *widget,
943 int err; 944 int err;
944 err = dapm_list_add_widget(list, path->source); 945 err = dapm_list_add_widget(list, path->source);
945 if (err < 0) { 946 if (err < 0) {
946 dev_err(widget->dapm->dev, "could not add widget %s\n", 947 dev_err(widget->dapm->dev,
948 "ASoC: could not add widget %s\n",
947 widget->name); 949 widget->name);
948 return con; 950 return con;
949 } 951 }
@@ -1024,7 +1026,7 @@ int dapm_regulator_event(struct snd_soc_dapm_widget *w,
1024 ret = regulator_allow_bypass(w->regulator, true); 1026 ret = regulator_allow_bypass(w->regulator, true);
1025 if (ret != 0) 1027 if (ret != 0)
1026 dev_warn(w->dapm->dev, 1028 dev_warn(w->dapm->dev,
1027 "Failed to bypass %s: %d\n", 1029 "ASoC: Failed to bypass %s: %d\n",
1028 w->name, ret); 1030 w->name, ret);
1029 } 1031 }
1030 1032
@@ -1034,7 +1036,7 @@ int dapm_regulator_event(struct snd_soc_dapm_widget *w,
1034 ret = regulator_allow_bypass(w->regulator, false); 1036 ret = regulator_allow_bypass(w->regulator, false);
1035 if (ret != 0) 1037 if (ret != 0)
1036 dev_warn(w->dapm->dev, 1038 dev_warn(w->dapm->dev,
1037 "Failed to unbypass %s: %d\n", 1039 "ASoC: Failed to unbypass %s: %d\n",
1038 w->name, ret); 1040 w->name, ret);
1039 } 1041 }
1040 1042
@@ -1253,7 +1255,7 @@ static void dapm_seq_check_event(struct snd_soc_dapm_context *dapm,
1253 ret = w->event(w, NULL, event); 1255 ret = w->event(w, NULL, event);
1254 trace_snd_soc_dapm_widget_event_done(w, event); 1256 trace_snd_soc_dapm_widget_event_done(w, event);
1255 if (ret < 0) 1257 if (ret < 0)
1256 pr_err("%s: %s event failed: %d\n", 1258 dev_err(dapm->dev, "ASoC: %s: %s event failed: %d\n",
1257 ev_name, w->name, ret); 1259 ev_name, w->name, ret);
1258 } 1260 }
1259} 1261}
@@ -1402,7 +1404,7 @@ static void dapm_seq_run(struct snd_soc_dapm_context *dapm,
1402 1404
1403 if (ret < 0) 1405 if (ret < 0)
1404 dev_err(w->dapm->dev, 1406 dev_err(w->dapm->dev,
1405 "Failed to apply widget power: %d\n", ret); 1407 "ASoC: Failed to apply widget power: %d\n", ret);
1406 } 1408 }
1407 1409
1408 if (!list_empty(&pending)) 1410 if (!list_empty(&pending))
@@ -1431,20 +1433,21 @@ static void dapm_widget_update(struct snd_soc_dapm_context *dapm)
1431 (w->event_flags & SND_SOC_DAPM_PRE_REG)) { 1433 (w->event_flags & SND_SOC_DAPM_PRE_REG)) {
1432 ret = w->event(w, update->kcontrol, SND_SOC_DAPM_PRE_REG); 1434 ret = w->event(w, update->kcontrol, SND_SOC_DAPM_PRE_REG);
1433 if (ret != 0) 1435 if (ret != 0)
1434 pr_err("%s DAPM pre-event failed: %d\n", 1436 dev_err(dapm->dev, "ASoC: %s DAPM pre-event failed: %d\n",
1435 w->name, ret); 1437 w->name, ret);
1436 } 1438 }
1437 1439
1438 ret = soc_widget_update_bits_locked(w, update->reg, update->mask, 1440 ret = soc_widget_update_bits_locked(w, update->reg, update->mask,
1439 update->val); 1441 update->val);
1440 if (ret < 0) 1442 if (ret < 0)
1441 pr_err("%s DAPM update failed: %d\n", w->name, ret); 1443 dev_err(dapm->dev, "ASoC: %s DAPM update failed: %d\n",
1444 w->name, ret);
1442 1445
1443 if (w->event && 1446 if (w->event &&
1444 (w->event_flags & SND_SOC_DAPM_POST_REG)) { 1447 (w->event_flags & SND_SOC_DAPM_POST_REG)) {
1445 ret = w->event(w, update->kcontrol, SND_SOC_DAPM_POST_REG); 1448 ret = w->event(w, update->kcontrol, SND_SOC_DAPM_POST_REG);
1446 if (ret != 0) 1449 if (ret != 0)
1447 pr_err("%s DAPM post-event failed: %d\n", 1450 dev_err(dapm->dev, "ASoC: %s DAPM post-event failed: %d\n",
1448 w->name, ret); 1451 w->name, ret);
1449 } 1452 }
1450} 1453}
@@ -1466,7 +1469,7 @@ static void dapm_pre_sequence_async(void *data, async_cookie_t cookie)
1466 ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_STANDBY); 1469 ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_STANDBY);
1467 if (ret != 0) 1470 if (ret != 0)
1468 dev_err(d->dev, 1471 dev_err(d->dev,
1469 "Failed to turn on bias: %d\n", ret); 1472 "ASoC: Failed to turn on bias: %d\n", ret);
1470 } 1473 }
1471 1474
1472 /* Prepare for a STADDBY->ON or ON->STANDBY transition */ 1475 /* Prepare for a STADDBY->ON or ON->STANDBY transition */
@@ -1474,7 +1477,7 @@ static void dapm_pre_sequence_async(void *data, async_cookie_t cookie)
1474 ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_PREPARE); 1477 ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_PREPARE);
1475 if (ret != 0) 1478 if (ret != 0)
1476 dev_err(d->dev, 1479 dev_err(d->dev,
1477 "Failed to prepare bias: %d\n", ret); 1480 "ASoC: Failed to prepare bias: %d\n", ret);
1478 } 1481 }
1479} 1482}
1480 1483
@@ -1492,7 +1495,7 @@ static void dapm_post_sequence_async(void *data, async_cookie_t cookie)
1492 d->target_bias_level == SND_SOC_BIAS_OFF)) { 1495 d->target_bias_level == SND_SOC_BIAS_OFF)) {
1493 ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_STANDBY); 1496 ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_STANDBY);
1494 if (ret != 0) 1497 if (ret != 0)
1495 dev_err(d->dev, "Failed to apply standby bias: %d\n", 1498 dev_err(d->dev, "ASoC: Failed to apply standby bias: %d\n",
1496 ret); 1499 ret);
1497 } 1500 }
1498 1501
@@ -1501,7 +1504,8 @@ static void dapm_post_sequence_async(void *data, async_cookie_t cookie)
1501 d->target_bias_level == SND_SOC_BIAS_OFF) { 1504 d->target_bias_level == SND_SOC_BIAS_OFF) {
1502 ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_OFF); 1505 ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_OFF);
1503 if (ret != 0) 1506 if (ret != 0)
1504 dev_err(d->dev, "Failed to turn off bias: %d\n", ret); 1507 dev_err(d->dev, "ASoC: Failed to turn off bias: %d\n",
1508 ret);
1505 1509
1506 if (d->dev) 1510 if (d->dev)
1507 pm_runtime_put(d->dev); 1511 pm_runtime_put(d->dev);
@@ -1512,7 +1516,7 @@ static void dapm_post_sequence_async(void *data, async_cookie_t cookie)
1512 d->target_bias_level == SND_SOC_BIAS_ON) { 1516 d->target_bias_level == SND_SOC_BIAS_ON) {
1513 ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_ON); 1517 ret = snd_soc_dapm_set_bias_level(d, SND_SOC_BIAS_ON);
1514 if (ret != 0) 1518 if (ret != 0)
1515 dev_err(d->dev, "Failed to apply active bias: %d\n", 1519 dev_err(d->dev, "ASoC: Failed to apply active bias: %d\n",
1516 ret); 1520 ret);
1517 } 1521 }
1518} 1522}
@@ -1838,7 +1842,7 @@ void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm,
1838 1842
1839 if (!dapm->debugfs_dapm) { 1843 if (!dapm->debugfs_dapm) {
1840 dev_warn(dapm->dev, 1844 dev_warn(dapm->dev,
1841 "Failed to create DAPM debugfs directory\n"); 1845 "ASoC: Failed to create DAPM debugfs directory\n");
1842 return; 1846 return;
1843 } 1847 }
1844 1848
@@ -2123,7 +2127,7 @@ static int snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm,
2123 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); 2127 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true);
2124 2128
2125 if (!w) { 2129 if (!w) {
2126 dev_err(dapm->dev, "dapm: unknown pin %s\n", pin); 2130 dev_err(dapm->dev, "ASoC: DAPM unknown pin %s\n", pin);
2127 return -EINVAL; 2131 return -EINVAL;
2128 } 2132 }
2129 2133
@@ -2212,8 +2216,16 @@ static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm,
2212 if (!wsource) 2216 if (!wsource)
2213 wsource = wtsource; 2217 wsource = wtsource;
2214 2218
2215 if (wsource == NULL || wsink == NULL) 2219 if (wsource == NULL) {
2220 dev_err(dapm->dev, "ASoC: no source widget found for %s\n",
2221 route->source);
2216 return -ENODEV; 2222 return -ENODEV;
2223 }
2224 if (wsink == NULL) {
2225 dev_err(dapm->dev, "ASoC: no sink widget found for %s\n",
2226 route->sink);
2227 return -ENODEV;
2228 }
2217 2229
2218 path = kzalloc(sizeof(struct snd_soc_dapm_path), GFP_KERNEL); 2230 path = kzalloc(sizeof(struct snd_soc_dapm_path), GFP_KERNEL);
2219 if (!path) 2231 if (!path)
@@ -2308,7 +2320,7 @@ static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm,
2308 return 0; 2320 return 0;
2309 2321
2310err: 2322err:
2311 dev_warn(dapm->dev, "asoc: no dapm match for %s --> %s --> %s\n", 2323 dev_warn(dapm->dev, "ASoC: no dapm match for %s --> %s --> %s\n",
2312 source, control, sink); 2324 source, control, sink);
2313 kfree(path); 2325 kfree(path);
2314 return ret; 2326 return ret;
@@ -2325,7 +2337,7 @@ static int snd_soc_dapm_del_route(struct snd_soc_dapm_context *dapm,
2325 2337
2326 if (route->control) { 2338 if (route->control) {
2327 dev_err(dapm->dev, 2339 dev_err(dapm->dev,
2328 "Removal of routes with controls not supported\n"); 2340 "ASoC: Removal of routes with controls not supported\n");
2329 return -EINVAL; 2341 return -EINVAL;
2330 } 2342 }
2331 2343
@@ -2360,7 +2372,7 @@ static int snd_soc_dapm_del_route(struct snd_soc_dapm_context *dapm,
2360 list_del(&path->list_source); 2372 list_del(&path->list_source);
2361 kfree(path); 2373 kfree(path);
2362 } else { 2374 } else {
2363 dev_warn(dapm->dev, "Route %s->%s does not exist\n", 2375 dev_warn(dapm->dev, "ASoC: Route %s->%s does not exist\n",
2364 source, sink); 2376 source, sink);
2365 } 2377 }
2366 2378
@@ -2389,8 +2401,10 @@ int snd_soc_dapm_add_routes(struct snd_soc_dapm_context *dapm,
2389 for (i = 0; i < num; i++) { 2401 for (i = 0; i < num; i++) {
2390 r = snd_soc_dapm_add_route(dapm, route); 2402 r = snd_soc_dapm_add_route(dapm, route);
2391 if (r < 0) { 2403 if (r < 0) {
2392 dev_err(dapm->dev, "Failed to add route %s->%s\n", 2404 dev_err(dapm->dev, "ASoC: Failed to add route %s -> %s -> %s\n",
2393 route->source, route->sink); 2405 route->source,
2406 route->control ? route->control : "direct",
2407 route->sink);
2394 ret = r; 2408 ret = r;
2395 } 2409 }
2396 route++; 2410 route++;
@@ -2438,19 +2452,19 @@ static int snd_soc_dapm_weak_route(struct snd_soc_dapm_context *dapm,
2438 int count = 0; 2452 int count = 0;
2439 2453
2440 if (!source) { 2454 if (!source) {
2441 dev_err(dapm->dev, "Unable to find source %s for weak route\n", 2455 dev_err(dapm->dev, "ASoC: Unable to find source %s for weak route\n",
2442 route->source); 2456 route->source);
2443 return -ENODEV; 2457 return -ENODEV;
2444 } 2458 }
2445 2459
2446 if (!sink) { 2460 if (!sink) {
2447 dev_err(dapm->dev, "Unable to find sink %s for weak route\n", 2461 dev_err(dapm->dev, "ASoC: Unable to find sink %s for weak route\n",
2448 route->sink); 2462 route->sink);
2449 return -ENODEV; 2463 return -ENODEV;
2450 } 2464 }
2451 2465
2452 if (route->control || route->connected) 2466 if (route->control || route->connected)
2453 dev_warn(dapm->dev, "Ignoring control for weak route %s->%s\n", 2467 dev_warn(dapm->dev, "ASoC: Ignoring control for weak route %s->%s\n",
2454 route->source, route->sink); 2468 route->source, route->sink);
2455 2469
2456 list_for_each_entry(path, &source->sinks, list_source) { 2470 list_for_each_entry(path, &source->sinks, list_source) {
@@ -2461,10 +2475,10 @@ static int snd_soc_dapm_weak_route(struct snd_soc_dapm_context *dapm,
2461 } 2475 }
2462 2476
2463 if (count == 0) 2477 if (count == 0)
2464 dev_err(dapm->dev, "No path found for weak route %s->%s\n", 2478 dev_err(dapm->dev, "ASoC: No path found for weak route %s->%s\n",
2465 route->source, route->sink); 2479 route->source, route->sink);
2466 if (count > 1) 2480 if (count > 1)
2467 dev_warn(dapm->dev, "%d paths found for weak route %s->%s\n", 2481 dev_warn(dapm->dev, "ASoC: %d paths found for weak route %s->%s\n",
2468 count, route->source, route->sink); 2482 count, route->source, route->sink);
2469 2483
2470 return 0; 2484 return 0;
@@ -2601,7 +2615,7 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol,
2601 2615
2602 if (snd_soc_volsw_is_stereo(mc)) 2616 if (snd_soc_volsw_is_stereo(mc))
2603 dev_warn(widget->dapm->dev, 2617 dev_warn(widget->dapm->dev,
2604 "Control '%s' is stereo, which is not supported\n", 2618 "ASoC: Control '%s' is stereo, which is not supported\n",
2605 kcontrol->id.name); 2619 kcontrol->id.name);
2606 2620
2607 ucontrol->value.integer.value[0] = 2621 ucontrol->value.integer.value[0] =
@@ -2644,7 +2658,7 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol,
2644 2658
2645 if (snd_soc_volsw_is_stereo(mc)) 2659 if (snd_soc_volsw_is_stereo(mc))
2646 dev_warn(widget->dapm->dev, 2660 dev_warn(widget->dapm->dev,
2647 "Control '%s' is stereo, which is not supported\n", 2661 "ASoC: Control '%s' is stereo, which is not supported\n",
2648 kcontrol->id.name); 2662 kcontrol->id.name);
2649 2663
2650 val = (ucontrol->value.integer.value[0] & mask); 2664 val = (ucontrol->value.integer.value[0] & mask);
@@ -3021,7 +3035,7 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
3021 w->regulator = devm_regulator_get(dapm->dev, w->name); 3035 w->regulator = devm_regulator_get(dapm->dev, w->name);
3022 if (IS_ERR(w->regulator)) { 3036 if (IS_ERR(w->regulator)) {
3023 ret = PTR_ERR(w->regulator); 3037 ret = PTR_ERR(w->regulator);
3024 dev_err(dapm->dev, "Failed to request %s: %d\n", 3038 dev_err(dapm->dev, "ASoC: Failed to request %s: %d\n",
3025 w->name, ret); 3039 w->name, ret);
3026 return NULL; 3040 return NULL;
3027 } 3041 }
@@ -3031,7 +3045,7 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
3031 w->clk = devm_clk_get(dapm->dev, w->name); 3045 w->clk = devm_clk_get(dapm->dev, w->name);
3032 if (IS_ERR(w->clk)) { 3046 if (IS_ERR(w->clk)) {
3033 ret = PTR_ERR(w->clk); 3047 ret = PTR_ERR(w->clk);
3034 dev_err(dapm->dev, "Failed to request %s: %d\n", 3048 dev_err(dapm->dev, "ASoC: Failed to request %s: %d\n",
3035 w->name, ret); 3049 w->name, ret);
3036 return NULL; 3050 return NULL;
3037 } 3051 }
@@ -3182,7 +3196,7 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w,
3182 if (config->formats) { 3196 if (config->formats) {
3183 fmt = ffs(config->formats) - 1; 3197 fmt = ffs(config->formats) - 1;
3184 } else { 3198 } else {
3185 dev_warn(w->dapm->dev, "Invalid format %llx specified\n", 3199 dev_warn(w->dapm->dev, "ASoC: Invalid format %llx specified\n",
3186 config->formats); 3200 config->formats);
3187 fmt = 0; 3201 fmt = 0;
3188 } 3202 }
@@ -3215,7 +3229,7 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w,
3215 params, source); 3229 params, source);
3216 if (ret != 0) { 3230 if (ret != 0) {
3217 dev_err(source->dev, 3231 dev_err(source->dev,
3218 "hw_params() failed: %d\n", ret); 3232 "ASoC: hw_params() failed: %d\n", ret);
3219 goto out; 3233 goto out;
3220 } 3234 }
3221 } 3235 }
@@ -3226,7 +3240,7 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w,
3226 sink); 3240 sink);
3227 if (ret != 0) { 3241 if (ret != 0) {
3228 dev_err(sink->dev, 3242 dev_err(sink->dev,
3229 "hw_params() failed: %d\n", ret); 3243 "ASoC: hw_params() failed: %d\n", ret);
3230 goto out; 3244 goto out;
3231 } 3245 }
3232 } 3246 }
@@ -3235,14 +3249,14 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w,
3235 case SND_SOC_DAPM_POST_PMU: 3249 case SND_SOC_DAPM_POST_PMU:
3236 ret = snd_soc_dai_digital_mute(sink, 0); 3250 ret = snd_soc_dai_digital_mute(sink, 0);
3237 if (ret != 0 && ret != -ENOTSUPP) 3251 if (ret != 0 && ret != -ENOTSUPP)
3238 dev_warn(sink->dev, "Failed to unmute: %d\n", ret); 3252 dev_warn(sink->dev, "ASoC: Failed to unmute: %d\n", ret);
3239 ret = 0; 3253 ret = 0;
3240 break; 3254 break;
3241 3255
3242 case SND_SOC_DAPM_PRE_PMD: 3256 case SND_SOC_DAPM_PRE_PMD:
3243 ret = snd_soc_dai_digital_mute(sink, 1); 3257 ret = snd_soc_dai_digital_mute(sink, 1);
3244 if (ret != 0 && ret != -ENOTSUPP) 3258 if (ret != 0 && ret != -ENOTSUPP)
3245 dev_warn(sink->dev, "Failed to mute: %d\n", ret); 3259 dev_warn(sink->dev, "ASoC: Failed to mute: %d\n", ret);
3246 ret = 0; 3260 ret = 0;
3247 break; 3261 break;
3248 3262
@@ -3281,11 +3295,11 @@ int snd_soc_dapm_new_pcm(struct snd_soc_card *card,
3281 template.event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | 3295 template.event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
3282 SND_SOC_DAPM_PRE_PMD; 3296 SND_SOC_DAPM_PRE_PMD;
3283 3297
3284 dev_dbg(card->dev, "adding %s widget\n", link_name); 3298 dev_dbg(card->dev, "ASoC: adding %s widget\n", link_name);
3285 3299
3286 w = snd_soc_dapm_new_control(&card->dapm, &template); 3300 w = snd_soc_dapm_new_control(&card->dapm, &template);
3287 if (!w) { 3301 if (!w) {
3288 dev_err(card->dev, "Failed to create %s widget\n", 3302 dev_err(card->dev, "ASoC: Failed to create %s widget\n",
3289 link_name); 3303 link_name);
3290 return -ENOMEM; 3304 return -ENOMEM;
3291 } 3305 }
@@ -3319,12 +3333,12 @@ int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm,
3319 template.name = dai->driver->playback.stream_name; 3333 template.name = dai->driver->playback.stream_name;
3320 template.sname = dai->driver->playback.stream_name; 3334 template.sname = dai->driver->playback.stream_name;
3321 3335
3322 dev_dbg(dai->dev, "adding %s widget\n", 3336 dev_dbg(dai->dev, "ASoC: adding %s widget\n",
3323 template.name); 3337 template.name);
3324 3338
3325 w = snd_soc_dapm_new_control(dapm, &template); 3339 w = snd_soc_dapm_new_control(dapm, &template);
3326 if (!w) { 3340 if (!w) {
3327 dev_err(dapm->dev, "Failed to create %s widget\n", 3341 dev_err(dapm->dev, "ASoC: Failed to create %s widget\n",
3328 dai->driver->playback.stream_name); 3342 dai->driver->playback.stream_name);
3329 } 3343 }
3330 3344
@@ -3337,12 +3351,12 @@ int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm,
3337 template.name = dai->driver->capture.stream_name; 3351 template.name = dai->driver->capture.stream_name;
3338 template.sname = dai->driver->capture.stream_name; 3352 template.sname = dai->driver->capture.stream_name;
3339 3353
3340 dev_dbg(dai->dev, "adding %s widget\n", 3354 dev_dbg(dai->dev, "ASoC: adding %s widget\n",
3341 template.name); 3355 template.name);
3342 3356
3343 w = snd_soc_dapm_new_control(dapm, &template); 3357 w = snd_soc_dapm_new_control(dapm, &template);
3344 if (!w) { 3358 if (!w) {
3345 dev_err(dapm->dev, "Failed to create %s widget\n", 3359 dev_err(dapm->dev, "ASoC: Failed to create %s widget\n",
3346 dai->driver->capture.stream_name); 3360 dai->driver->capture.stream_name);
3347 } 3361 }
3348 3362
@@ -3518,11 +3532,11 @@ int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm,
3518 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true); 3532 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true);
3519 3533
3520 if (!w) { 3534 if (!w) {
3521 dev_err(dapm->dev, "dapm: unknown pin %s\n", pin); 3535 dev_err(dapm->dev, "ASoC: unknown pin %s\n", pin);
3522 return -EINVAL; 3536 return -EINVAL;
3523 } 3537 }
3524 3538
3525 dev_dbg(w->dapm->dev, "dapm: force enable pin %s\n", pin); 3539 dev_dbg(w->dapm->dev, "ASoC: force enable pin %s\n", pin);
3526 w->connected = 1; 3540 w->connected = 1;
3527 w->force = 1; 3541 w->force = 1;
3528 dapm_mark_dirty(w, "force enable"); 3542 dapm_mark_dirty(w, "force enable");
@@ -3605,7 +3619,7 @@ int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm,
3605 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, false); 3619 struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, false);
3606 3620
3607 if (!w) { 3621 if (!w) {
3608 dev_err(dapm->dev, "dapm: unknown pin %s\n", pin); 3622 dev_err(dapm->dev, "ASoC: unknown pin %s\n", pin);
3609 return -EINVAL; 3623 return -EINVAL;
3610 } 3624 }
3611 3625
@@ -3664,7 +3678,7 @@ void snd_soc_dapm_auto_nc_codec_pins(struct snd_soc_codec *codec)
3664 struct snd_soc_dapm_context *dapm = &codec->dapm; 3678 struct snd_soc_dapm_context *dapm = &codec->dapm;
3665 struct snd_soc_dapm_widget *w; 3679 struct snd_soc_dapm_widget *w;
3666 3680
3667 dev_dbg(codec->dev, "Auto NC: DAPMs: card:%p codec:%p\n", 3681 dev_dbg(codec->dev, "ASoC: Auto NC: DAPMs: card:%p codec:%p\n",
3668 &card->dapm, &codec->dapm); 3682 &card->dapm, &codec->dapm);
3669 3683
3670 list_for_each_entry(w, &card->widgets, list) { 3684 list_for_each_entry(w, &card->widgets, list) {
@@ -3674,7 +3688,7 @@ void snd_soc_dapm_auto_nc_codec_pins(struct snd_soc_codec *codec)
3674 case snd_soc_dapm_input: 3688 case snd_soc_dapm_input:
3675 case snd_soc_dapm_output: 3689 case snd_soc_dapm_output:
3676 case snd_soc_dapm_micbias: 3690 case snd_soc_dapm_micbias:
3677 dev_dbg(codec->dev, "Auto NC: Checking widget %s\n", 3691 dev_dbg(codec->dev, "ASoC: Auto NC: Checking widget %s\n",
3678 w->name); 3692 w->name);
3679 if (!snd_soc_dapm_widget_in_card_paths(card, w)) { 3693 if (!snd_soc_dapm_widget_in_card_paths(card, w)) {
3680 dev_dbg(codec->dev, 3694 dev_dbg(codec->dev,
@@ -3745,7 +3759,7 @@ void snd_soc_dapm_shutdown(struct snd_soc_card *card)
3745{ 3759{
3746 struct snd_soc_codec *codec; 3760 struct snd_soc_codec *codec;
3747 3761
3748 list_for_each_entry(codec, &card->codec_dev_list, list) { 3762 list_for_each_entry(codec, &card->codec_dev_list, card_list) {
3749 soc_dapm_shutdown_codec(&codec->dapm); 3763 soc_dapm_shutdown_codec(&codec->dapm);
3750 if (codec->dapm.bias_level == SND_SOC_BIAS_STANDBY) 3764 if (codec->dapm.bias_level == SND_SOC_BIAS_STANDBY)
3751 snd_soc_dapm_set_bias_level(&codec->dapm, 3765 snd_soc_dapm_set_bias_level(&codec->dapm,
diff --git a/sound/soc/soc-dmaengine-pcm.c b/sound/soc/soc-dmaengine-pcm.c
index bbc125748a38..111b7d921e89 100644
--- a/sound/soc/soc-dmaengine-pcm.c
+++ b/sound/soc/soc-dmaengine-pcm.c
@@ -317,3 +317,5 @@ int snd_dmaengine_pcm_close(struct snd_pcm_substream *substream)
317 return 0; 317 return 0;
318} 318}
319EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_close); 319EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_close);
320
321MODULE_LICENSE("GPL");
diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c
index 1ab5fe04bfcc..0bb5cccd7766 100644
--- a/sound/soc/soc-jack.c
+++ b/sound/soc/soc-jack.c
@@ -66,7 +66,6 @@ void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask)
66 struct snd_soc_dapm_context *dapm; 66 struct snd_soc_dapm_context *dapm;
67 struct snd_soc_jack_pin *pin; 67 struct snd_soc_jack_pin *pin;
68 int enable; 68 int enable;
69 int oldstatus;
70 69
71 trace_snd_soc_jack_report(jack, mask, status); 70 trace_snd_soc_jack_report(jack, mask, status);
72 71
@@ -78,8 +77,6 @@ void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask)
78 77
79 mutex_lock(&jack->mutex); 78 mutex_lock(&jack->mutex);
80 79
81 oldstatus = jack->status;
82
83 jack->status &= ~mask; 80 jack->status &= ~mask;
84 jack->status |= status & mask; 81 jack->status |= status & mask;
85 82
@@ -172,12 +169,13 @@ int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count,
172 169
173 for (i = 0; i < count; i++) { 170 for (i = 0; i < count; i++) {
174 if (!pins[i].pin) { 171 if (!pins[i].pin) {
175 printk(KERN_ERR "No name for pin %d\n", i); 172 dev_err(jack->codec->dev, "ASoC: No name for pin %d\n",
173 i);
176 return -EINVAL; 174 return -EINVAL;
177 } 175 }
178 if (!pins[i].mask) { 176 if (!pins[i].mask) {
179 printk(KERN_ERR "No mask for pin %d (%s)\n", i, 177 dev_err(jack->codec->dev, "ASoC: No mask for pin %d"
180 pins[i].pin); 178 " (%s)\n", i, pins[i].pin);
181 return -EINVAL; 179 return -EINVAL;
182 } 180 }
183 181
@@ -297,13 +295,13 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
297 295
298 for (i = 0; i < count; i++) { 296 for (i = 0; i < count; i++) {
299 if (!gpio_is_valid(gpios[i].gpio)) { 297 if (!gpio_is_valid(gpios[i].gpio)) {
300 printk(KERN_ERR "Invalid gpio %d\n", 298 dev_err(jack->codec->dev, "ASoC: Invalid gpio %d\n",
301 gpios[i].gpio); 299 gpios[i].gpio);
302 ret = -EINVAL; 300 ret = -EINVAL;
303 goto undo; 301 goto undo;
304 } 302 }
305 if (!gpios[i].name) { 303 if (!gpios[i].name) {
306 printk(KERN_ERR "No name for gpio %d\n", 304 dev_err(jack->codec->dev, "ASoC: No name for gpio %d\n",
307 gpios[i].gpio); 305 gpios[i].gpio);
308 ret = -EINVAL; 306 ret = -EINVAL;
309 goto undo; 307 goto undo;
@@ -332,7 +330,7 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
332 if (gpios[i].wake) { 330 if (gpios[i].wake) {
333 ret = irq_set_irq_wake(gpio_to_irq(gpios[i].gpio), 1); 331 ret = irq_set_irq_wake(gpio_to_irq(gpios[i].gpio), 1);
334 if (ret != 0) 332 if (ret != 0)
335 printk(KERN_ERR 333 dev_err(jack->codec->dev, "ASoC: "
336 "Failed to mark GPIO %d as wake source: %d\n", 334 "Failed to mark GPIO %d as wake source: %d\n",
337 gpios[i].gpio, ret); 335 gpios[i].gpio, ret);
338 } 336 }
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
index ef22d0bd9e9e..5c3ca2a34661 100644
--- a/sound/soc/soc-pcm.c
+++ b/sound/soc/soc-pcm.c
@@ -43,7 +43,7 @@ static int dpcm_dapm_stream_event(struct snd_soc_pcm_runtime *fe, int dir,
43 43
44 struct snd_soc_pcm_runtime *be = dpcm->be; 44 struct snd_soc_pcm_runtime *be = dpcm->be;
45 45
46 dev_dbg(be->dev, "pm: BE %s event %d dir %d\n", 46 dev_dbg(be->dev, "ASoC: BE %s event %d dir %d\n",
47 be->dai_link->name, event, dir); 47 be->dai_link->name, event, dir);
48 48
49 snd_soc_dapm_stream_event(be, dir, event); 49 snd_soc_dapm_stream_event(be, dir, event);
@@ -70,18 +70,19 @@ static int soc_pcm_apply_symmetry(struct snd_pcm_substream *substream,
70 */ 70 */
71 if (!soc_dai->rate) { 71 if (!soc_dai->rate) {
72 dev_warn(soc_dai->dev, 72 dev_warn(soc_dai->dev,
73 "Not enforcing symmetric_rates due to race\n"); 73 "ASoC: Not enforcing symmetric_rates due to race\n");
74 return 0; 74 return 0;
75 } 75 }
76 76
77 dev_dbg(soc_dai->dev, "Symmetry forces %dHz rate\n", soc_dai->rate); 77 dev_dbg(soc_dai->dev, "ASoC: Symmetry forces %dHz rate\n", soc_dai->rate);
78 78
79 ret = snd_pcm_hw_constraint_minmax(substream->runtime, 79 ret = snd_pcm_hw_constraint_minmax(substream->runtime,
80 SNDRV_PCM_HW_PARAM_RATE, 80 SNDRV_PCM_HW_PARAM_RATE,
81 soc_dai->rate, soc_dai->rate); 81 soc_dai->rate, soc_dai->rate);
82 if (ret < 0) { 82 if (ret < 0) {
83 dev_err(soc_dai->dev, 83 dev_err(soc_dai->dev,
84 "Unable to apply rate symmetry constraint: %d\n", ret); 84 "ASoC: Unable to apply rate symmetry constraint: %d\n",
85 ret);
85 return ret; 86 return ret;
86 } 87 }
87 88
@@ -118,7 +119,7 @@ static void soc_pcm_apply_msb(struct snd_pcm_substream *substream,
118 sample_sizes[i], bits); 119 sample_sizes[i], bits);
119 if (ret != 0) 120 if (ret != 0)
120 dev_warn(dai->dev, 121 dev_warn(dai->dev,
121 "Failed to set MSB %d/%d: %d\n", 122 "ASoC: Failed to set MSB %d/%d: %d\n",
122 bits, sample_sizes[i], ret); 123 bits, sample_sizes[i], ret);
123 } 124 }
124} 125}
@@ -149,8 +150,8 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
149 if (cpu_dai->driver->ops->startup) { 150 if (cpu_dai->driver->ops->startup) {
150 ret = cpu_dai->driver->ops->startup(substream, cpu_dai); 151 ret = cpu_dai->driver->ops->startup(substream, cpu_dai);
151 if (ret < 0) { 152 if (ret < 0) {
152 dev_err(cpu_dai->dev, "can't open interface %s: %d\n", 153 dev_err(cpu_dai->dev, "ASoC: can't open interface"
153 cpu_dai->name, ret); 154 " %s: %d\n", cpu_dai->name, ret);
154 goto out; 155 goto out;
155 } 156 }
156 } 157 }
@@ -158,8 +159,8 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
158 if (platform->driver->ops && platform->driver->ops->open) { 159 if (platform->driver->ops && platform->driver->ops->open) {
159 ret = platform->driver->ops->open(substream); 160 ret = platform->driver->ops->open(substream);
160 if (ret < 0) { 161 if (ret < 0) {
161 dev_err(platform->dev, "can't open platform %s: %d\n", 162 dev_err(platform->dev, "ASoC: can't open platform"
162 platform->name, ret); 163 " %s: %d\n", platform->name, ret);
163 goto platform_err; 164 goto platform_err;
164 } 165 }
165 } 166 }
@@ -167,8 +168,8 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
167 if (codec_dai->driver->ops->startup) { 168 if (codec_dai->driver->ops->startup) {
168 ret = codec_dai->driver->ops->startup(substream, codec_dai); 169 ret = codec_dai->driver->ops->startup(substream, codec_dai);
169 if (ret < 0) { 170 if (ret < 0) {
170 dev_err(codec_dai->dev, "can't open codec %s: %d\n", 171 dev_err(codec_dai->dev, "ASoC: can't open codec"
171 codec_dai->name, ret); 172 " %s: %d\n", codec_dai->name, ret);
172 goto codec_dai_err; 173 goto codec_dai_err;
173 } 174 }
174 } 175 }
@@ -176,7 +177,7 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
176 if (rtd->dai_link->ops && rtd->dai_link->ops->startup) { 177 if (rtd->dai_link->ops && rtd->dai_link->ops->startup) {
177 ret = rtd->dai_link->ops->startup(substream); 178 ret = rtd->dai_link->ops->startup(substream);
178 if (ret < 0) { 179 if (ret < 0) {
179 pr_err("asoc: %s startup failed: %d\n", 180 pr_err("ASoC: %s startup failed: %d\n",
180 rtd->dai_link->name, ret); 181 rtd->dai_link->name, ret);
181 goto machine_err; 182 goto machine_err;
182 } 183 }
@@ -238,18 +239,18 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
238 ret = -EINVAL; 239 ret = -EINVAL;
239 snd_pcm_limit_hw_rates(runtime); 240 snd_pcm_limit_hw_rates(runtime);
240 if (!runtime->hw.rates) { 241 if (!runtime->hw.rates) {
241 printk(KERN_ERR "asoc: %s <-> %s No matching rates\n", 242 printk(KERN_ERR "ASoC: %s <-> %s No matching rates\n",
242 codec_dai->name, cpu_dai->name); 243 codec_dai->name, cpu_dai->name);
243 goto config_err; 244 goto config_err;
244 } 245 }
245 if (!runtime->hw.formats) { 246 if (!runtime->hw.formats) {
246 printk(KERN_ERR "asoc: %s <-> %s No matching formats\n", 247 printk(KERN_ERR "ASoC: %s <-> %s No matching formats\n",
247 codec_dai->name, cpu_dai->name); 248 codec_dai->name, cpu_dai->name);
248 goto config_err; 249 goto config_err;
249 } 250 }
250 if (!runtime->hw.channels_min || !runtime->hw.channels_max || 251 if (!runtime->hw.channels_min || !runtime->hw.channels_max ||
251 runtime->hw.channels_min > runtime->hw.channels_max) { 252 runtime->hw.channels_min > runtime->hw.channels_max) {
252 printk(KERN_ERR "asoc: %s <-> %s No matching channels\n", 253 printk(KERN_ERR "ASoC: %s <-> %s No matching channels\n",
253 codec_dai->name, cpu_dai->name); 254 codec_dai->name, cpu_dai->name);
254 goto config_err; 255 goto config_err;
255 } 256 }
@@ -270,12 +271,12 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
270 goto config_err; 271 goto config_err;
271 } 272 }
272 273
273 pr_debug("asoc: %s <-> %s info:\n", 274 pr_debug("ASoC: %s <-> %s info:\n",
274 codec_dai->name, cpu_dai->name); 275 codec_dai->name, cpu_dai->name);
275 pr_debug("asoc: rate mask 0x%x\n", runtime->hw.rates); 276 pr_debug("ASoC: rate mask 0x%x\n", runtime->hw.rates);
276 pr_debug("asoc: min ch %d max ch %d\n", runtime->hw.channels_min, 277 pr_debug("ASoC: min ch %d max ch %d\n", runtime->hw.channels_min,
277 runtime->hw.channels_max); 278 runtime->hw.channels_max);
278 pr_debug("asoc: min rate %d max rate %d\n", runtime->hw.rate_min, 279 pr_debug("ASoC: min rate %d max rate %d\n", runtime->hw.rate_min,
279 runtime->hw.rate_max); 280 runtime->hw.rate_max);
280 281
281dynamic: 282dynamic:
@@ -330,7 +331,7 @@ static void close_delayed_work(struct work_struct *work)
330 331
331 mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); 332 mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
332 333
333 pr_debug("pop wq checking: %s status: %s waiting: %s\n", 334 dev_dbg(rtd->dev, "ASoC: pop wq checking: %s status: %s waiting: %s\n",
334 codec_dai->driver->playback.stream_name, 335 codec_dai->driver->playback.stream_name,
335 codec_dai->playback_active ? "active" : "inactive", 336 codec_dai->playback_active ? "active" : "inactive",
336 codec_dai->pop_wait ? "yes" : "no"); 337 codec_dai->pop_wait ? "yes" : "no");
@@ -444,7 +445,8 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
444 if (rtd->dai_link->ops && rtd->dai_link->ops->prepare) { 445 if (rtd->dai_link->ops && rtd->dai_link->ops->prepare) {
445 ret = rtd->dai_link->ops->prepare(substream); 446 ret = rtd->dai_link->ops->prepare(substream);
446 if (ret < 0) { 447 if (ret < 0) {
447 pr_err("asoc: machine prepare error: %d\n", ret); 448 dev_err(rtd->card->dev, "ASoC: machine prepare error:"
449 " %d\n", ret);
448 goto out; 450 goto out;
449 } 451 }
450 } 452 }
@@ -452,8 +454,8 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
452 if (platform->driver->ops && platform->driver->ops->prepare) { 454 if (platform->driver->ops && platform->driver->ops->prepare) {
453 ret = platform->driver->ops->prepare(substream); 455 ret = platform->driver->ops->prepare(substream);
454 if (ret < 0) { 456 if (ret < 0) {
455 dev_err(platform->dev, "platform prepare error: %d\n", 457 dev_err(platform->dev, "ASoC: platform prepare error:"
456 ret); 458 " %d\n", ret);
457 goto out; 459 goto out;
458 } 460 }
459 } 461 }
@@ -461,7 +463,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
461 if (codec_dai->driver->ops->prepare) { 463 if (codec_dai->driver->ops->prepare) {
462 ret = codec_dai->driver->ops->prepare(substream, codec_dai); 464 ret = codec_dai->driver->ops->prepare(substream, codec_dai);
463 if (ret < 0) { 465 if (ret < 0) {
464 dev_err(codec_dai->dev, "DAI prepare error: %d\n", 466 dev_err(codec_dai->dev, "ASoC: DAI prepare error: %d\n",
465 ret); 467 ret);
466 goto out; 468 goto out;
467 } 469 }
@@ -470,7 +472,7 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream)
470 if (cpu_dai->driver->ops->prepare) { 472 if (cpu_dai->driver->ops->prepare) {
471 ret = cpu_dai->driver->ops->prepare(substream, cpu_dai); 473 ret = cpu_dai->driver->ops->prepare(substream, cpu_dai);
472 if (ret < 0) { 474 if (ret < 0) {
473 dev_err(cpu_dai->dev, "DAI prepare error: %d\n", 475 dev_err(cpu_dai->dev, "ASoC: DAI prepare error: %d\n",
474 ret); 476 ret);
475 goto out; 477 goto out;
476 } 478 }
@@ -512,7 +514,8 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
512 if (rtd->dai_link->ops && rtd->dai_link->ops->hw_params) { 514 if (rtd->dai_link->ops && rtd->dai_link->ops->hw_params) {
513 ret = rtd->dai_link->ops->hw_params(substream, params); 515 ret = rtd->dai_link->ops->hw_params(substream, params);
514 if (ret < 0) { 516 if (ret < 0) {
515 pr_err("asoc: machine hw_params failed: %d\n", ret); 517 dev_err(rtd->card->dev, "ASoC: machine hw_params"
518 " failed: %d\n", ret);
516 goto out; 519 goto out;
517 } 520 }
518 } 521 }
@@ -520,8 +523,8 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
520 if (codec_dai->driver->ops->hw_params) { 523 if (codec_dai->driver->ops->hw_params) {
521 ret = codec_dai->driver->ops->hw_params(substream, params, codec_dai); 524 ret = codec_dai->driver->ops->hw_params(substream, params, codec_dai);
522 if (ret < 0) { 525 if (ret < 0) {
523 dev_err(codec_dai->dev, "can't set %s hw params: %d\n", 526 dev_err(codec_dai->dev, "ASoC: can't set %s hw params:"
524 codec_dai->name, ret); 527 " %d\n", codec_dai->name, ret);
525 goto codec_err; 528 goto codec_err;
526 } 529 }
527 } 530 }
@@ -529,7 +532,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
529 if (cpu_dai->driver->ops->hw_params) { 532 if (cpu_dai->driver->ops->hw_params) {
530 ret = cpu_dai->driver->ops->hw_params(substream, params, cpu_dai); 533 ret = cpu_dai->driver->ops->hw_params(substream, params, cpu_dai);
531 if (ret < 0) { 534 if (ret < 0) {
532 dev_err(cpu_dai->dev, "%s hw params failed: %d\n", 535 dev_err(cpu_dai->dev, "ASoC: %s hw params failed: %d\n",
533 cpu_dai->name, ret); 536 cpu_dai->name, ret);
534 goto interface_err; 537 goto interface_err;
535 } 538 }
@@ -538,7 +541,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
538 if (platform->driver->ops && platform->driver->ops->hw_params) { 541 if (platform->driver->ops && platform->driver->ops->hw_params) {
539 ret = platform->driver->ops->hw_params(substream, params); 542 ret = platform->driver->ops->hw_params(substream, params);
540 if (ret < 0) { 543 if (ret < 0) {
541 dev_err(platform->dev, "%s hw params failed: %d\n", 544 dev_err(platform->dev, "ASoC: %s hw params failed: %d\n",
542 platform->name, ret); 545 platform->name, ret);
543 goto platform_err; 546 goto platform_err;
544 } 547 }
@@ -760,7 +763,7 @@ static void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream)
760 struct snd_soc_dpcm *dpcm, *d; 763 struct snd_soc_dpcm *dpcm, *d;
761 764
762 list_for_each_entry_safe(dpcm, d, &fe->dpcm[stream].be_clients, list_be) { 765 list_for_each_entry_safe(dpcm, d, &fe->dpcm[stream].be_clients, list_be) {
763 dev_dbg(fe->dev, "BE %s disconnect check for %s\n", 766 dev_dbg(fe->dev, "ASoC: BE %s disconnect check for %s\n",
764 stream ? "capture" : "playback", 767 stream ? "capture" : "playback",
765 dpcm->be->dai_link->name); 768 dpcm->be->dai_link->name);
766 769
@@ -815,7 +818,7 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card,
815 } 818 }
816 } 819 }
817 820
818 dev_err(card->dev, "can't get %s BE for %s\n", 821 dev_err(card->dev, "ASoC: can't get %s BE for %s\n",
819 stream ? "capture" : "playback", widget->name); 822 stream ? "capture" : "playback", widget->name);
820 return NULL; 823 return NULL;
821} 824}
@@ -866,7 +869,7 @@ static int dpcm_path_get(struct snd_soc_pcm_runtime *fe,
866 /* get number of valid DAI paths and their widgets */ 869 /* get number of valid DAI paths and their widgets */
867 paths = snd_soc_dapm_dai_get_connected_widgets(cpu_dai, stream, &list); 870 paths = snd_soc_dapm_dai_get_connected_widgets(cpu_dai, stream, &list);
868 871
869 dev_dbg(fe->dev, "found %d audio %s paths\n", paths, 872 dev_dbg(fe->dev, "ASoC: found %d audio %s paths\n", paths,
870 stream ? "capture" : "playback"); 873 stream ? "capture" : "playback");
871 874
872 *list_ = list; 875 *list_ = list;
@@ -903,7 +906,7 @@ static int dpcm_prune_paths(struct snd_soc_pcm_runtime *fe, int stream,
903 if (widget && widget_in_list(list, widget)) 906 if (widget && widget_in_list(list, widget))
904 continue; 907 continue;
905 908
906 dev_dbg(fe->dev, "pruning %s BE %s for %s\n", 909 dev_dbg(fe->dev, "ASoC: pruning %s BE %s for %s\n",
907 stream ? "capture" : "playback", 910 stream ? "capture" : "playback",
908 dpcm->be->dai_link->name, fe->dai_link->name); 911 dpcm->be->dai_link->name, fe->dai_link->name);
909 dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE; 912 dpcm->state = SND_SOC_DPCM_LINK_STATE_FREE;
@@ -911,7 +914,7 @@ static int dpcm_prune_paths(struct snd_soc_pcm_runtime *fe, int stream,
911 prune++; 914 prune++;
912 } 915 }
913 916
914 dev_dbg(fe->dev, "found %d old BE paths for pruning\n", prune); 917 dev_dbg(fe->dev, "ASoC: found %d old BE paths for pruning\n", prune);
915 return prune; 918 return prune;
916} 919}
917 920
@@ -932,7 +935,7 @@ static int dpcm_add_paths(struct snd_soc_pcm_runtime *fe, int stream,
932 /* is there a valid BE rtd for this widget */ 935 /* is there a valid BE rtd for this widget */
933 be = dpcm_get_be(card, list->widgets[i], stream); 936 be = dpcm_get_be(card, list->widgets[i], stream);
934 if (!be) { 937 if (!be) {
935 dev_err(fe->dev, "no BE found for %s\n", 938 dev_err(fe->dev, "ASoC: no BE found for %s\n",
936 list->widgets[i]->name); 939 list->widgets[i]->name);
937 continue; 940 continue;
938 } 941 }
@@ -948,7 +951,7 @@ static int dpcm_add_paths(struct snd_soc_pcm_runtime *fe, int stream,
948 /* newly connected FE and BE */ 951 /* newly connected FE and BE */
949 err = dpcm_be_connect(fe, be, stream); 952 err = dpcm_be_connect(fe, be, stream);
950 if (err < 0) { 953 if (err < 0) {
951 dev_err(fe->dev, "can't connect %s\n", 954 dev_err(fe->dev, "ASoC: can't connect %s\n",
952 list->widgets[i]->name); 955 list->widgets[i]->name);
953 break; 956 break;
954 } else if (err == 0) /* already connected */ 957 } else if (err == 0) /* already connected */
@@ -959,7 +962,7 @@ static int dpcm_add_paths(struct snd_soc_pcm_runtime *fe, int stream,
959 new++; 962 new++;
960 } 963 }
961 964
962 dev_dbg(fe->dev, "found %d new BE paths\n", new); 965 dev_dbg(fe->dev, "ASoC: found %d new BE paths\n", new);
963 return new; 966 return new;
964} 967}
965 968
@@ -998,7 +1001,7 @@ static void dpcm_be_dai_startup_unwind(struct snd_soc_pcm_runtime *fe,
998 snd_soc_dpcm_get_substream(be, stream); 1001 snd_soc_dpcm_get_substream(be, stream);
999 1002
1000 if (be->dpcm[stream].users == 0) 1003 if (be->dpcm[stream].users == 0)
1001 dev_err(be->dev, "no users %s at close - state %d\n", 1004 dev_err(be->dev, "ASoC: no users %s at close - state %d\n",
1002 stream ? "capture" : "playback", 1005 stream ? "capture" : "playback",
1003 be->dpcm[stream].state); 1006 be->dpcm[stream].state);
1004 1007
@@ -1032,7 +1035,7 @@ static int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream)
1032 1035
1033 /* first time the dpcm is open ? */ 1036 /* first time the dpcm is open ? */
1034 if (be->dpcm[stream].users == DPCM_MAX_BE_USERS) 1037 if (be->dpcm[stream].users == DPCM_MAX_BE_USERS)
1035 dev_err(be->dev, "too many users %s at open %d\n", 1038 dev_err(be->dev, "ASoC: too many users %s at open %d\n",
1036 stream ? "capture" : "playback", 1039 stream ? "capture" : "playback",
1037 be->dpcm[stream].state); 1040 be->dpcm[stream].state);
1038 1041
@@ -1043,15 +1046,15 @@ static int dpcm_be_dai_startup(struct snd_soc_pcm_runtime *fe, int stream)
1043 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_CLOSE)) 1046 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_CLOSE))
1044 continue; 1047 continue;
1045 1048
1046 dev_dbg(be->dev, "dpcm: open BE %s\n", be->dai_link->name); 1049 dev_dbg(be->dev, "ASoC: open BE %s\n", be->dai_link->name);
1047 1050
1048 be_substream->runtime = be->dpcm[stream].runtime; 1051 be_substream->runtime = be->dpcm[stream].runtime;
1049 err = soc_pcm_open(be_substream); 1052 err = soc_pcm_open(be_substream);
1050 if (err < 0) { 1053 if (err < 0) {
1051 dev_err(be->dev, "BE open failed %d\n", err); 1054 dev_err(be->dev, "ASoC: BE open failed %d\n", err);
1052 be->dpcm[stream].users--; 1055 be->dpcm[stream].users--;
1053 if (be->dpcm[stream].users < 0) 1056 if (be->dpcm[stream].users < 0)
1054 dev_err(be->dev, "no users %s at unwind %d\n", 1057 dev_err(be->dev, "ASoC: no users %s at unwind %d\n",
1055 stream ? "capture" : "playback", 1058 stream ? "capture" : "playback",
1056 be->dpcm[stream].state); 1059 be->dpcm[stream].state);
1057 1060
@@ -1076,7 +1079,7 @@ unwind:
1076 continue; 1079 continue;
1077 1080
1078 if (be->dpcm[stream].users == 0) 1081 if (be->dpcm[stream].users == 0)
1079 dev_err(be->dev, "no users %s at close %d\n", 1082 dev_err(be->dev, "ASoC: no users %s at close %d\n",
1080 stream ? "capture" : "playback", 1083 stream ? "capture" : "playback",
1081 be->dpcm[stream].state); 1084 be->dpcm[stream].state);
1082 1085
@@ -1128,16 +1131,16 @@ static int dpcm_fe_dai_startup(struct snd_pcm_substream *fe_substream)
1128 1131
1129 ret = dpcm_be_dai_startup(fe, fe_substream->stream); 1132 ret = dpcm_be_dai_startup(fe, fe_substream->stream);
1130 if (ret < 0) { 1133 if (ret < 0) {
1131 dev_err(fe->dev,"dpcm: failed to start some BEs %d\n", ret); 1134 dev_err(fe->dev,"ASoC: failed to start some BEs %d\n", ret);
1132 goto be_err; 1135 goto be_err;
1133 } 1136 }
1134 1137
1135 dev_dbg(fe->dev, "dpcm: open FE %s\n", fe->dai_link->name); 1138 dev_dbg(fe->dev, "ASoC: open FE %s\n", fe->dai_link->name);
1136 1139
1137 /* start the DAI frontend */ 1140 /* start the DAI frontend */
1138 ret = soc_pcm_open(fe_substream); 1141 ret = soc_pcm_open(fe_substream);
1139 if (ret < 0) { 1142 if (ret < 0) {
1140 dev_err(fe->dev,"dpcm: failed to start FE %d\n", ret); 1143 dev_err(fe->dev,"ASoC: failed to start FE %d\n", ret);
1141 goto unwind; 1144 goto unwind;
1142 } 1145 }
1143 1146
@@ -1172,7 +1175,7 @@ static int dpcm_be_dai_shutdown(struct snd_soc_pcm_runtime *fe, int stream)
1172 continue; 1175 continue;
1173 1176
1174 if (be->dpcm[stream].users == 0) 1177 if (be->dpcm[stream].users == 0)
1175 dev_err(be->dev, "no users %s at close - state %d\n", 1178 dev_err(be->dev, "ASoC: no users %s at close - state %d\n",
1176 stream ? "capture" : "playback", 1179 stream ? "capture" : "playback",
1177 be->dpcm[stream].state); 1180 be->dpcm[stream].state);
1178 1181
@@ -1183,7 +1186,7 @@ static int dpcm_be_dai_shutdown(struct snd_soc_pcm_runtime *fe, int stream)
1183 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_OPEN)) 1186 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_OPEN))
1184 continue; 1187 continue;
1185 1188
1186 dev_dbg(be->dev, "dpcm: close BE %s\n", 1189 dev_dbg(be->dev, "ASoC: close BE %s\n",
1187 dpcm->fe->dai_link->name); 1190 dpcm->fe->dai_link->name);
1188 1191
1189 soc_pcm_close(be_substream); 1192 soc_pcm_close(be_substream);
@@ -1204,7 +1207,7 @@ static int dpcm_fe_dai_shutdown(struct snd_pcm_substream *substream)
1204 /* shutdown the BEs */ 1207 /* shutdown the BEs */
1205 dpcm_be_dai_shutdown(fe, substream->stream); 1208 dpcm_be_dai_shutdown(fe, substream->stream);
1206 1209
1207 dev_dbg(fe->dev, "dpcm: close FE %s\n", fe->dai_link->name); 1210 dev_dbg(fe->dev, "ASoC: close FE %s\n", fe->dai_link->name);
1208 1211
1209 /* now shutdown the frontend */ 1212 /* now shutdown the frontend */
1210 soc_pcm_close(substream); 1213 soc_pcm_close(substream);
@@ -1243,7 +1246,7 @@ static int dpcm_be_dai_hw_free(struct snd_soc_pcm_runtime *fe, int stream)
1243 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP)) 1246 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP))
1244 continue; 1247 continue;
1245 1248
1246 dev_dbg(be->dev, "dpcm: hw_free BE %s\n", 1249 dev_dbg(be->dev, "ASoC: hw_free BE %s\n",
1247 dpcm->fe->dai_link->name); 1250 dpcm->fe->dai_link->name);
1248 1251
1249 soc_pcm_hw_free(be_substream); 1252 soc_pcm_hw_free(be_substream);
@@ -1262,12 +1265,12 @@ static int dpcm_fe_dai_hw_free(struct snd_pcm_substream *substream)
1262 mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); 1265 mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
1263 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; 1266 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE;
1264 1267
1265 dev_dbg(fe->dev, "dpcm: hw_free FE %s\n", fe->dai_link->name); 1268 dev_dbg(fe->dev, "ASoC: hw_free FE %s\n", fe->dai_link->name);
1266 1269
1267 /* call hw_free on the frontend */ 1270 /* call hw_free on the frontend */
1268 err = soc_pcm_hw_free(substream); 1271 err = soc_pcm_hw_free(substream);
1269 if (err < 0) 1272 if (err < 0)
1270 dev_err(fe->dev,"dpcm: hw_free FE %s failed\n", 1273 dev_err(fe->dev,"ASoC: hw_free FE %s failed\n",
1271 fe->dai_link->name); 1274 fe->dai_link->name);
1272 1275
1273 /* only hw_params backends that are either sinks or sources 1276 /* only hw_params backends that are either sinks or sources
@@ -1305,7 +1308,7 @@ static int dpcm_be_dai_hw_params(struct snd_soc_pcm_runtime *fe, int stream)
1305 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE)) 1308 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE))
1306 continue; 1309 continue;
1307 1310
1308 dev_dbg(be->dev, "dpcm: hw_params BE %s\n", 1311 dev_dbg(be->dev, "ASoC: hw_params BE %s\n",
1309 dpcm->fe->dai_link->name); 1312 dpcm->fe->dai_link->name);
1310 1313
1311 /* copy params for each dpcm */ 1314 /* copy params for each dpcm */
@@ -1318,7 +1321,7 @@ static int dpcm_be_dai_hw_params(struct snd_soc_pcm_runtime *fe, int stream)
1318 &dpcm->hw_params); 1321 &dpcm->hw_params);
1319 if (ret < 0) { 1322 if (ret < 0) {
1320 dev_err(be->dev, 1323 dev_err(be->dev,
1321 "dpcm: hw_params BE fixup failed %d\n", 1324 "ASoC: hw_params BE fixup failed %d\n",
1322 ret); 1325 ret);
1323 goto unwind; 1326 goto unwind;
1324 } 1327 }
@@ -1327,7 +1330,7 @@ static int dpcm_be_dai_hw_params(struct snd_soc_pcm_runtime *fe, int stream)
1327 ret = soc_pcm_hw_params(be_substream, &dpcm->hw_params); 1330 ret = soc_pcm_hw_params(be_substream, &dpcm->hw_params);
1328 if (ret < 0) { 1331 if (ret < 0) {
1329 dev_err(dpcm->be->dev, 1332 dev_err(dpcm->be->dev,
1330 "dpcm: hw_params BE failed %d\n", ret); 1333 "ASoC: hw_params BE failed %d\n", ret);
1331 goto unwind; 1334 goto unwind;
1332 } 1335 }
1333 1336
@@ -1374,18 +1377,18 @@ static int dpcm_fe_dai_hw_params(struct snd_pcm_substream *substream,
1374 sizeof(struct snd_pcm_hw_params)); 1377 sizeof(struct snd_pcm_hw_params));
1375 ret = dpcm_be_dai_hw_params(fe, substream->stream); 1378 ret = dpcm_be_dai_hw_params(fe, substream->stream);
1376 if (ret < 0) { 1379 if (ret < 0) {
1377 dev_err(fe->dev,"dpcm: hw_params BE failed %d\n", ret); 1380 dev_err(fe->dev,"ASoC: hw_params BE failed %d\n", ret);
1378 goto out; 1381 goto out;
1379 } 1382 }
1380 1383
1381 dev_dbg(fe->dev, "dpcm: hw_params FE %s rate %d chan %x fmt %d\n", 1384 dev_dbg(fe->dev, "ASoC: hw_params FE %s rate %d chan %x fmt %d\n",
1382 fe->dai_link->name, params_rate(params), 1385 fe->dai_link->name, params_rate(params),
1383 params_channels(params), params_format(params)); 1386 params_channels(params), params_format(params));
1384 1387
1385 /* call hw_params on the frontend */ 1388 /* call hw_params on the frontend */
1386 ret = soc_pcm_hw_params(substream, params); 1389 ret = soc_pcm_hw_params(substream, params);
1387 if (ret < 0) { 1390 if (ret < 0) {
1388 dev_err(fe->dev,"dpcm: hw_params FE failed %d\n", ret); 1391 dev_err(fe->dev,"ASoC: hw_params FE failed %d\n", ret);
1389 dpcm_be_dai_hw_free(fe, stream); 1392 dpcm_be_dai_hw_free(fe, stream);
1390 } else 1393 } else
1391 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_PARAMS; 1394 fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_PARAMS;
@@ -1401,12 +1404,12 @@ static int dpcm_do_trigger(struct snd_soc_dpcm *dpcm,
1401{ 1404{
1402 int ret; 1405 int ret;
1403 1406
1404 dev_dbg(dpcm->be->dev, "dpcm: trigger BE %s cmd %d\n", 1407 dev_dbg(dpcm->be->dev, "ASoC: trigger BE %s cmd %d\n",
1405 dpcm->fe->dai_link->name, cmd); 1408 dpcm->fe->dai_link->name, cmd);
1406 1409
1407 ret = soc_pcm_trigger(substream, cmd); 1410 ret = soc_pcm_trigger(substream, cmd);
1408 if (ret < 0) 1411 if (ret < 0)
1409 dev_err(dpcm->be->dev,"dpcm: trigger BE failed %d\n", ret); 1412 dev_err(dpcm->be->dev,"ASoC: trigger BE failed %d\n", ret);
1410 1413
1411 return ret; 1414 return ret;
1412} 1415}
@@ -1517,12 +1520,12 @@ static int dpcm_fe_dai_trigger(struct snd_pcm_substream *substream, int cmd)
1517 case SND_SOC_DPCM_TRIGGER_PRE: 1520 case SND_SOC_DPCM_TRIGGER_PRE:
1518 /* call trigger on the frontend before the backend. */ 1521 /* call trigger on the frontend before the backend. */
1519 1522
1520 dev_dbg(fe->dev, "dpcm: pre trigger FE %s cmd %d\n", 1523 dev_dbg(fe->dev, "ASoC: pre trigger FE %s cmd %d\n",
1521 fe->dai_link->name, cmd); 1524 fe->dai_link->name, cmd);
1522 1525
1523 ret = soc_pcm_trigger(substream, cmd); 1526 ret = soc_pcm_trigger(substream, cmd);
1524 if (ret < 0) { 1527 if (ret < 0) {
1525 dev_err(fe->dev,"dpcm: trigger FE failed %d\n", ret); 1528 dev_err(fe->dev,"ASoC: trigger FE failed %d\n", ret);
1526 goto out; 1529 goto out;
1527 } 1530 }
1528 1531
@@ -1533,11 +1536,11 @@ static int dpcm_fe_dai_trigger(struct snd_pcm_substream *substream, int cmd)
1533 1536
1534 ret = dpcm_be_dai_trigger(fe, substream->stream, cmd); 1537 ret = dpcm_be_dai_trigger(fe, substream->stream, cmd);
1535 if (ret < 0) { 1538 if (ret < 0) {
1536 dev_err(fe->dev,"dpcm: trigger FE failed %d\n", ret); 1539 dev_err(fe->dev,"ASoC: trigger FE failed %d\n", ret);
1537 goto out; 1540 goto out;
1538 } 1541 }
1539 1542
1540 dev_dbg(fe->dev, "dpcm: post trigger FE %s cmd %d\n", 1543 dev_dbg(fe->dev, "ASoC: post trigger FE %s cmd %d\n",
1541 fe->dai_link->name, cmd); 1544 fe->dai_link->name, cmd);
1542 1545
1543 ret = soc_pcm_trigger(substream, cmd); 1546 ret = soc_pcm_trigger(substream, cmd);
@@ -1545,17 +1548,17 @@ static int dpcm_fe_dai_trigger(struct snd_pcm_substream *substream, int cmd)
1545 case SND_SOC_DPCM_TRIGGER_BESPOKE: 1548 case SND_SOC_DPCM_TRIGGER_BESPOKE:
1546 /* bespoke trigger() - handles both FE and BEs */ 1549 /* bespoke trigger() - handles both FE and BEs */
1547 1550
1548 dev_dbg(fe->dev, "dpcm: bespoke trigger FE %s cmd %d\n", 1551 dev_dbg(fe->dev, "ASoC: bespoke trigger FE %s cmd %d\n",
1549 fe->dai_link->name, cmd); 1552 fe->dai_link->name, cmd);
1550 1553
1551 ret = soc_pcm_bespoke_trigger(substream, cmd); 1554 ret = soc_pcm_bespoke_trigger(substream, cmd);
1552 if (ret < 0) { 1555 if (ret < 0) {
1553 dev_err(fe->dev,"dpcm: trigger FE failed %d\n", ret); 1556 dev_err(fe->dev,"ASoC: trigger FE failed %d\n", ret);
1554 goto out; 1557 goto out;
1555 } 1558 }
1556 break; 1559 break;
1557 default: 1560 default:
1558 dev_err(fe->dev, "dpcm: invalid trigger cmd %d for %s\n", cmd, 1561 dev_err(fe->dev, "ASoC: invalid trigger cmd %d for %s\n", cmd,
1559 fe->dai_link->name); 1562 fe->dai_link->name);
1560 ret = -EINVAL; 1563 ret = -EINVAL;
1561 goto out; 1564 goto out;
@@ -1598,12 +1601,12 @@ static int dpcm_be_dai_prepare(struct snd_soc_pcm_runtime *fe, int stream)
1598 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP)) 1601 (be->dpcm[stream].state != SND_SOC_DPCM_STATE_STOP))
1599 continue; 1602 continue;
1600 1603
1601 dev_dbg(be->dev, "dpcm: prepare BE %s\n", 1604 dev_dbg(be->dev, "ASoC: prepare BE %s\n",
1602 dpcm->fe->dai_link->name); 1605 dpcm->fe->dai_link->name);
1603 1606
1604 ret = soc_pcm_prepare(be_substream); 1607 ret = soc_pcm_prepare(be_substream);
1605 if (ret < 0) { 1608 if (ret < 0) {
1606 dev_err(be->dev, "dpcm: backend prepare failed %d\n", 1609 dev_err(be->dev, "ASoC: backend prepare failed %d\n",
1607 ret); 1610 ret);
1608 break; 1611 break;
1609 } 1612 }
@@ -1620,13 +1623,13 @@ static int dpcm_fe_dai_prepare(struct snd_pcm_substream *substream)
1620 1623
1621 mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME); 1624 mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
1622 1625
1623 dev_dbg(fe->dev, "dpcm: prepare FE %s\n", fe->dai_link->name); 1626 dev_dbg(fe->dev, "ASoC: prepare FE %s\n", fe->dai_link->name);
1624 1627
1625 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE; 1628 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_FE;
1626 1629
1627 /* there is no point preparing this FE if there are no BEs */ 1630 /* there is no point preparing this FE if there are no BEs */
1628 if (list_empty(&fe->dpcm[stream].be_clients)) { 1631 if (list_empty(&fe->dpcm[stream].be_clients)) {
1629 dev_err(fe->dev, "dpcm: no backend DAIs enabled for %s\n", 1632 dev_err(fe->dev, "ASoC: no backend DAIs enabled for %s\n",
1630 fe->dai_link->name); 1633 fe->dai_link->name);
1631 ret = -EINVAL; 1634 ret = -EINVAL;
1632 goto out; 1635 goto out;
@@ -1639,7 +1642,7 @@ static int dpcm_fe_dai_prepare(struct snd_pcm_substream *substream)
1639 /* call prepare on the frontend */ 1642 /* call prepare on the frontend */
1640 ret = soc_pcm_prepare(substream); 1643 ret = soc_pcm_prepare(substream);
1641 if (ret < 0) { 1644 if (ret < 0) {
1642 dev_err(fe->dev,"dpcm: prepare FE %s failed\n", 1645 dev_err(fe->dev,"ASoC: prepare FE %s failed\n",
1643 fe->dai_link->name); 1646 fe->dai_link->name);
1644 goto out; 1647 goto out;
1645 } 1648 }
@@ -1673,33 +1676,33 @@ static int dpcm_run_update_shutdown(struct snd_soc_pcm_runtime *fe, int stream)
1673 enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream]; 1676 enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream];
1674 int err; 1677 int err;
1675 1678
1676 dev_dbg(fe->dev, "runtime %s close on FE %s\n", 1679 dev_dbg(fe->dev, "ASoC: runtime %s close on FE %s\n",
1677 stream ? "capture" : "playback", fe->dai_link->name); 1680 stream ? "capture" : "playback", fe->dai_link->name);
1678 1681
1679 if (trigger == SND_SOC_DPCM_TRIGGER_BESPOKE) { 1682 if (trigger == SND_SOC_DPCM_TRIGGER_BESPOKE) {
1680 /* call bespoke trigger - FE takes care of all BE triggers */ 1683 /* call bespoke trigger - FE takes care of all BE triggers */
1681 dev_dbg(fe->dev, "dpcm: bespoke trigger FE %s cmd stop\n", 1684 dev_dbg(fe->dev, "ASoC: bespoke trigger FE %s cmd stop\n",
1682 fe->dai_link->name); 1685 fe->dai_link->name);
1683 1686
1684 err = soc_pcm_bespoke_trigger(substream, SNDRV_PCM_TRIGGER_STOP); 1687 err = soc_pcm_bespoke_trigger(substream, SNDRV_PCM_TRIGGER_STOP);
1685 if (err < 0) 1688 if (err < 0)
1686 dev_err(fe->dev,"dpcm: trigger FE failed %d\n", err); 1689 dev_err(fe->dev,"ASoC: trigger FE failed %d\n", err);
1687 } else { 1690 } else {
1688 dev_dbg(fe->dev, "dpcm: trigger FE %s cmd stop\n", 1691 dev_dbg(fe->dev, "ASoC: trigger FE %s cmd stop\n",
1689 fe->dai_link->name); 1692 fe->dai_link->name);
1690 1693
1691 err = dpcm_be_dai_trigger(fe, stream, SNDRV_PCM_TRIGGER_STOP); 1694 err = dpcm_be_dai_trigger(fe, stream, SNDRV_PCM_TRIGGER_STOP);
1692 if (err < 0) 1695 if (err < 0)
1693 dev_err(fe->dev,"dpcm: trigger FE failed %d\n", err); 1696 dev_err(fe->dev,"ASoC: trigger FE failed %d\n", err);
1694 } 1697 }
1695 1698
1696 err = dpcm_be_dai_hw_free(fe, stream); 1699 err = dpcm_be_dai_hw_free(fe, stream);
1697 if (err < 0) 1700 if (err < 0)
1698 dev_err(fe->dev,"dpcm: hw_free FE failed %d\n", err); 1701 dev_err(fe->dev,"ASoC: hw_free FE failed %d\n", err);
1699 1702
1700 err = dpcm_be_dai_shutdown(fe, stream); 1703 err = dpcm_be_dai_shutdown(fe, stream);
1701 if (err < 0) 1704 if (err < 0)
1702 dev_err(fe->dev,"dpcm: shutdown FE failed %d\n", err); 1705 dev_err(fe->dev,"ASoC: shutdown FE failed %d\n", err);
1703 1706
1704 /* run the stream event for each BE */ 1707 /* run the stream event for each BE */
1705 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_NOP); 1708 dpcm_dapm_stream_event(fe, stream, SND_SOC_DAPM_STREAM_NOP);
@@ -1715,7 +1718,7 @@ static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream)
1715 enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream]; 1718 enum snd_soc_dpcm_trigger trigger = fe->dai_link->trigger[stream];
1716 int ret; 1719 int ret;
1717 1720
1718 dev_dbg(fe->dev, "runtime %s open on FE %s\n", 1721 dev_dbg(fe->dev, "ASoC: runtime %s open on FE %s\n",
1719 stream ? "capture" : "playback", fe->dai_link->name); 1722 stream ? "capture" : "playback", fe->dai_link->name);
1720 1723
1721 /* Only start the BE if the FE is ready */ 1724 /* Only start the BE if the FE is ready */
@@ -1761,22 +1764,22 @@ static int dpcm_run_update_startup(struct snd_soc_pcm_runtime *fe, int stream)
1761 1764
1762 if (trigger == SND_SOC_DPCM_TRIGGER_BESPOKE) { 1765 if (trigger == SND_SOC_DPCM_TRIGGER_BESPOKE) {
1763 /* call trigger on the frontend - FE takes care of all BE triggers */ 1766 /* call trigger on the frontend - FE takes care of all BE triggers */
1764 dev_dbg(fe->dev, "dpcm: bespoke trigger FE %s cmd start\n", 1767 dev_dbg(fe->dev, "ASoC: bespoke trigger FE %s cmd start\n",
1765 fe->dai_link->name); 1768 fe->dai_link->name);
1766 1769
1767 ret = soc_pcm_bespoke_trigger(substream, SNDRV_PCM_TRIGGER_START); 1770 ret = soc_pcm_bespoke_trigger(substream, SNDRV_PCM_TRIGGER_START);
1768 if (ret < 0) { 1771 if (ret < 0) {
1769 dev_err(fe->dev,"dpcm: bespoke trigger FE failed %d\n", ret); 1772 dev_err(fe->dev,"ASoC: bespoke trigger FE failed %d\n", ret);
1770 goto hw_free; 1773 goto hw_free;
1771 } 1774 }
1772 } else { 1775 } else {
1773 dev_dbg(fe->dev, "dpcm: trigger FE %s cmd start\n", 1776 dev_dbg(fe->dev, "ASoC: trigger FE %s cmd start\n",
1774 fe->dai_link->name); 1777 fe->dai_link->name);
1775 1778
1776 ret = dpcm_be_dai_trigger(fe, stream, 1779 ret = dpcm_be_dai_trigger(fe, stream,
1777 SNDRV_PCM_TRIGGER_START); 1780 SNDRV_PCM_TRIGGER_START);
1778 if (ret < 0) { 1781 if (ret < 0) {
1779 dev_err(fe->dev,"dpcm: trigger FE failed %d\n", ret); 1782 dev_err(fe->dev,"ASoC: trigger FE failed %d\n", ret);
1780 goto hw_free; 1783 goto hw_free;
1781 } 1784 }
1782 } 1785 }
@@ -1805,7 +1808,7 @@ static int dpcm_run_new_update(struct snd_soc_pcm_runtime *fe, int stream)
1805 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_BE; 1808 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_BE;
1806 ret = dpcm_run_update_startup(fe, stream); 1809 ret = dpcm_run_update_startup(fe, stream);
1807 if (ret < 0) 1810 if (ret < 0)
1808 dev_err(fe->dev, "failed to startup some BEs\n"); 1811 dev_err(fe->dev, "ASoC: failed to startup some BEs\n");
1809 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; 1812 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO;
1810 1813
1811 return ret; 1814 return ret;
@@ -1818,7 +1821,7 @@ static int dpcm_run_old_update(struct snd_soc_pcm_runtime *fe, int stream)
1818 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_BE; 1821 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_BE;
1819 ret = dpcm_run_update_shutdown(fe, stream); 1822 ret = dpcm_run_update_shutdown(fe, stream);
1820 if (ret < 0) 1823 if (ret < 0)
1821 dev_err(fe->dev, "failed to shutdown some BEs\n"); 1824 dev_err(fe->dev, "ASoC: failed to shutdown some BEs\n");
1822 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO; 1825 fe->dpcm[stream].runtime_update = SND_SOC_DPCM_UPDATE_NO;
1823 1826
1824 return ret; 1827 return ret;
@@ -1853,7 +1856,7 @@ int soc_dpcm_runtime_update(struct snd_soc_dapm_widget *widget)
1853 continue; 1856 continue;
1854 1857
1855 /* DAPM sync will call this to update DSP paths */ 1858 /* DAPM sync will call this to update DSP paths */
1856 dev_dbg(fe->dev, "DPCM runtime update for FE %s\n", 1859 dev_dbg(fe->dev, "ASoC: DPCM runtime update for FE %s\n",
1857 fe->dai_link->name); 1860 fe->dai_link->name);
1858 1861
1859 /* skip if FE doesn't have playback capability */ 1862 /* skip if FE doesn't have playback capability */
@@ -1862,7 +1865,7 @@ int soc_dpcm_runtime_update(struct snd_soc_dapm_widget *widget)
1862 1865
1863 paths = dpcm_path_get(fe, SNDRV_PCM_STREAM_PLAYBACK, &list); 1866 paths = dpcm_path_get(fe, SNDRV_PCM_STREAM_PLAYBACK, &list);
1864 if (paths < 0) { 1867 if (paths < 0) {
1865 dev_warn(fe->dev, "%s no valid %s path\n", 1868 dev_warn(fe->dev, "ASoC: %s no valid %s path\n",
1866 fe->dai_link->name, "playback"); 1869 fe->dai_link->name, "playback");
1867 mutex_unlock(&card->mutex); 1870 mutex_unlock(&card->mutex);
1868 return paths; 1871 return paths;
@@ -1891,7 +1894,7 @@ capture:
1891 1894
1892 paths = dpcm_path_get(fe, SNDRV_PCM_STREAM_CAPTURE, &list); 1895 paths = dpcm_path_get(fe, SNDRV_PCM_STREAM_CAPTURE, &list);
1893 if (paths < 0) { 1896 if (paths < 0) {
1894 dev_warn(fe->dev, "%s no valid %s path\n", 1897 dev_warn(fe->dev, "ASoC: %s no valid %s path\n",
1895 fe->dai_link->name, "capture"); 1898 fe->dai_link->name, "capture");
1896 mutex_unlock(&card->mutex); 1899 mutex_unlock(&card->mutex);
1897 return paths; 1900 return paths;
@@ -1934,7 +1937,7 @@ int soc_dpcm_be_digital_mute(struct snd_soc_pcm_runtime *fe, int mute)
1934 if (be->dai_link->ignore_suspend) 1937 if (be->dai_link->ignore_suspend)
1935 continue; 1938 continue;
1936 1939
1937 dev_dbg(be->dev, "BE digital mute %s\n", be->dai_link->name); 1940 dev_dbg(be->dev, "ASoC: BE digital mute %s\n", be->dai_link->name);
1938 1941
1939 if (drv->ops->digital_mute && dai->playback_active) 1942 if (drv->ops->digital_mute && dai->playback_active)
1940 drv->ops->digital_mute(dai, mute); 1943 drv->ops->digital_mute(dai, mute);
@@ -1955,7 +1958,7 @@ static int dpcm_fe_dai_open(struct snd_pcm_substream *fe_substream)
1955 fe->dpcm[stream].runtime = fe_substream->runtime; 1958 fe->dpcm[stream].runtime = fe_substream->runtime;
1956 1959
1957 if (dpcm_path_get(fe, stream, &list) <= 0) { 1960 if (dpcm_path_get(fe, stream, &list) <= 0) {
1958 dev_dbg(fe->dev, "asoc: %s no valid %s route\n", 1961 dev_dbg(fe->dev, "ASoC: %s no valid %s route\n",
1959 fe->dai_link->name, stream ? "capture" : "playback"); 1962 fe->dai_link->name, stream ? "capture" : "playback");
1960 } 1963 }
1961 1964
@@ -2039,11 +2042,11 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
2039 capture, &pcm); 2042 capture, &pcm);
2040 } 2043 }
2041 if (ret < 0) { 2044 if (ret < 0) {
2042 dev_err(rtd->card->dev, "can't create pcm for %s\n", 2045 dev_err(rtd->card->dev, "ASoC: can't create pcm for %s\n",
2043 rtd->dai_link->name); 2046 rtd->dai_link->name);
2044 return ret; 2047 return ret;
2045 } 2048 }
2046 dev_dbg(rtd->card->dev, "registered pcm #%d %s\n",num, new_name); 2049 dev_dbg(rtd->card->dev, "ASoC: registered pcm #%d %s\n",num, new_name);
2047 2050
2048 /* DAPM dai link stream work */ 2051 /* DAPM dai link stream work */
2049 INIT_DELAYED_WORK(&rtd->delayed_work, close_delayed_work); 2052 INIT_DELAYED_WORK(&rtd->delayed_work, close_delayed_work);
@@ -2097,7 +2100,9 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
2097 if (platform->driver->pcm_new) { 2100 if (platform->driver->pcm_new) {
2098 ret = platform->driver->pcm_new(rtd); 2101 ret = platform->driver->pcm_new(rtd);
2099 if (ret < 0) { 2102 if (ret < 0) {
2100 dev_err(platform->dev, "pcm constructor failed\n"); 2103 dev_err(platform->dev,
2104 "ASoC: pcm constructor failed: %d\n",
2105 ret);
2101 return ret; 2106 return ret;
2102 } 2107 }
2103 } 2108 }
diff --git a/sound/soc/tegra/tegra20_das.c b/sound/soc/tegra/tegra20_das.c
index bf99296bce95..49653375970b 100644
--- a/sound/soc/tegra/tegra20_das.c
+++ b/sound/soc/tegra/tegra20_das.c
@@ -210,7 +210,7 @@ static int __devexit tegra20_das_remove(struct platform_device *pdev)
210 return 0; 210 return 0;
211} 211}
212 212
213static const struct of_device_id tegra20_das_of_match[] __devinitconst = { 213static const struct of_device_id tegra20_das_of_match[] = {
214 { .compatible = "nvidia,tegra20-das", }, 214 { .compatible = "nvidia,tegra20-das", },
215 {}, 215 {},
216}; 216};
diff --git a/sound/soc/tegra/tegra20_i2s.c b/sound/soc/tegra/tegra20_i2s.c
index 0832e8afd73c..2ae8af86edbd 100644
--- a/sound/soc/tegra/tegra20_i2s.c
+++ b/sound/soc/tegra/tegra20_i2s.c
@@ -463,12 +463,12 @@ static int __devexit tegra20_i2s_platform_remove(struct platform_device *pdev)
463 return 0; 463 return 0;
464} 464}
465 465
466static const struct of_device_id tegra20_i2s_of_match[] __devinitconst = { 466static const struct of_device_id tegra20_i2s_of_match[] = {
467 { .compatible = "nvidia,tegra20-i2s", }, 467 { .compatible = "nvidia,tegra20-i2s", },
468 {}, 468 {},
469}; 469};
470 470
471static const struct dev_pm_ops tegra20_i2s_pm_ops __devinitconst = { 471static const struct dev_pm_ops tegra20_i2s_pm_ops = {
472 SET_RUNTIME_PM_OPS(tegra20_i2s_runtime_suspend, 472 SET_RUNTIME_PM_OPS(tegra20_i2s_runtime_suspend,
473 tegra20_i2s_runtime_resume, NULL) 473 tegra20_i2s_runtime_resume, NULL)
474}; 474};
diff --git a/sound/soc/tegra/tegra20_spdif.c b/sound/soc/tegra/tegra20_spdif.c
index 3ebc8670ba00..d9641ef7b1ee 100644
--- a/sound/soc/tegra/tegra20_spdif.c
+++ b/sound/soc/tegra/tegra20_spdif.c
@@ -373,7 +373,7 @@ static int __devexit tegra20_spdif_platform_remove(struct platform_device *pdev)
373 return 0; 373 return 0;
374} 374}
375 375
376static const struct dev_pm_ops tegra20_spdif_pm_ops __devinitconst = { 376static const struct dev_pm_ops tegra20_spdif_pm_ops = {
377 SET_RUNTIME_PM_OPS(tegra20_spdif_runtime_suspend, 377 SET_RUNTIME_PM_OPS(tegra20_spdif_runtime_suspend,
378 tegra20_spdif_runtime_resume, NULL) 378 tegra20_spdif_runtime_resume, NULL)
379}; 379};
diff --git a/sound/soc/tegra/tegra30_ahub.c b/sound/soc/tegra/tegra30_ahub.c
index bf5610122c76..2269170b0df4 100644
--- a/sound/soc/tegra/tegra30_ahub.c
+++ b/sound/soc/tegra/tegra30_ahub.c
@@ -288,7 +288,7 @@ int tegra30_ahub_unset_rx_cif_source(enum tegra30_ahub_rxcif rxcif)
288} 288}
289EXPORT_SYMBOL_GPL(tegra30_ahub_unset_rx_cif_source); 289EXPORT_SYMBOL_GPL(tegra30_ahub_unset_rx_cif_source);
290 290
291static const char * const configlink_clocks[] __devinitconst = { 291static const char * const configlink_clocks[] = {
292 "i2s0", 292 "i2s0",
293 "i2s1", 293 "i2s1",
294 "i2s2", 294 "i2s2",
@@ -603,12 +603,12 @@ static int __devexit tegra30_ahub_remove(struct platform_device *pdev)
603 return 0; 603 return 0;
604} 604}
605 605
606static const struct of_device_id tegra30_ahub_of_match[] __devinitconst = { 606static const struct of_device_id tegra30_ahub_of_match[] = {
607 { .compatible = "nvidia,tegra30-ahub", }, 607 { .compatible = "nvidia,tegra30-ahub", },
608 {}, 608 {},
609}; 609};
610 610
611static const struct dev_pm_ops tegra30_ahub_pm_ops __devinitconst = { 611static const struct dev_pm_ops tegra30_ahub_pm_ops = {
612 SET_RUNTIME_PM_OPS(tegra30_ahub_runtime_suspend, 612 SET_RUNTIME_PM_OPS(tegra30_ahub_runtime_suspend,
613 tegra30_ahub_runtime_resume, NULL) 613 tegra30_ahub_runtime_resume, NULL)
614}; 614};
diff --git a/sound/soc/tegra/tegra30_i2s.c b/sound/soc/tegra/tegra30_i2s.c
index 44184228d1f0..bf0e089e7997 100644
--- a/sound/soc/tegra/tegra30_i2s.c
+++ b/sound/soc/tegra/tegra30_i2s.c
@@ -508,12 +508,12 @@ static int __devexit tegra30_i2s_platform_remove(struct platform_device *pdev)
508 return 0; 508 return 0;
509} 509}
510 510
511static const struct of_device_id tegra30_i2s_of_match[] __devinitconst = { 511static const struct of_device_id tegra30_i2s_of_match[] = {
512 { .compatible = "nvidia,tegra30-i2s", }, 512 { .compatible = "nvidia,tegra30-i2s", },
513 {}, 513 {},
514}; 514};
515 515
516static const struct dev_pm_ops tegra30_i2s_pm_ops __devinitconst = { 516static const struct dev_pm_ops tegra30_i2s_pm_ops = {
517 SET_RUNTIME_PM_OPS(tegra30_i2s_runtime_suspend, 517 SET_RUNTIME_PM_OPS(tegra30_i2s_runtime_suspend,
518 tegra30_i2s_runtime_resume, NULL) 518 tegra30_i2s_runtime_resume, NULL)
519}; 519};
diff --git a/sound/soc/tegra/tegra_alc5632.c b/sound/soc/tegra/tegra_alc5632.c
index 76cb1b363b71..523795a6e83e 100644
--- a/sound/soc/tegra/tegra_alc5632.c
+++ b/sound/soc/tegra/tegra_alc5632.c
@@ -242,7 +242,7 @@ static int __devexit tegra_alc5632_remove(struct platform_device *pdev)
242 return 0; 242 return 0;
243} 243}
244 244
245static const struct of_device_id tegra_alc5632_of_match[] __devinitconst = { 245static const struct of_device_id tegra_alc5632_of_match[] = {
246 { .compatible = "nvidia,tegra-audio-alc5632", }, 246 { .compatible = "nvidia,tegra-audio-alc5632", },
247 {}, 247 {},
248}; 248};
diff --git a/sound/soc/tegra/tegra_wm8753.c b/sound/soc/tegra/tegra_wm8753.c
index ea9166d5c4eb..effe5b41b5f9 100644
--- a/sound/soc/tegra/tegra_wm8753.c
+++ b/sound/soc/tegra/tegra_wm8753.c
@@ -200,7 +200,7 @@ static int __devexit tegra_wm8753_driver_remove(struct platform_device *pdev)
200 return 0; 200 return 0;
201} 201}
202 202
203static const struct of_device_id tegra_wm8753_of_match[] __devinitconst = { 203static const struct of_device_id tegra_wm8753_of_match[] = {
204 { .compatible = "nvidia,tegra-audio-wm8753", }, 204 { .compatible = "nvidia,tegra-audio-wm8753", },
205 {}, 205 {},
206}; 206};
diff --git a/sound/soc/tegra/tegra_wm8903.c b/sound/soc/tegra/tegra_wm8903.c
index cee13b7bfb94..0f794126fbe4 100644
--- a/sound/soc/tegra/tegra_wm8903.c
+++ b/sound/soc/tegra/tegra_wm8903.c
@@ -417,7 +417,7 @@ static int __devexit tegra_wm8903_driver_remove(struct platform_device *pdev)
417 return 0; 417 return 0;
418} 418}
419 419
420static const struct of_device_id tegra_wm8903_of_match[] __devinitconst = { 420static const struct of_device_id tegra_wm8903_of_match[] = {
421 { .compatible = "nvidia,tegra-audio-wm8903", }, 421 { .compatible = "nvidia,tegra-audio-wm8903", },
422 {}, 422 {},
423}; 423};
diff --git a/sound/soc/tegra/trimslice.c b/sound/soc/tegra/trimslice.c
index e69a4f7000d6..4a255a4d0c47 100644
--- a/sound/soc/tegra/trimslice.c
+++ b/sound/soc/tegra/trimslice.c
@@ -195,7 +195,7 @@ static int __devexit tegra_snd_trimslice_remove(struct platform_device *pdev)
195 return 0; 195 return 0;
196} 196}
197 197
198static const struct of_device_id trimslice_of_match[] __devinitconst = { 198static const struct of_device_id trimslice_of_match[] = {
199 { .compatible = "nvidia,tegra-audio-trimslice", }, 199 { .compatible = "nvidia,tegra-audio-trimslice", },
200 {}, 200 {},
201}; 201};
diff --git a/sound/soc/ux500/mop500.c b/sound/soc/ux500/mop500.c
index 54f7e25b6f7d..651a52a95fd7 100644
--- a/sound/soc/ux500/mop500.c
+++ b/sound/soc/ux500/mop500.c
@@ -33,7 +33,7 @@ struct snd_soc_dai_link mop500_dai_links[] = {
33 .stream_name = "ab8500_0", 33 .stream_name = "ab8500_0",
34 .cpu_dai_name = "ux500-msp-i2s.1", 34 .cpu_dai_name = "ux500-msp-i2s.1",
35 .codec_dai_name = "ab8500-codec-dai.0", 35 .codec_dai_name = "ab8500-codec-dai.0",
36 .platform_name = "ux500-pcm.0", 36 .platform_name = "ux500-msp-i2s.1",
37 .codec_name = "ab8500-codec.0", 37 .codec_name = "ab8500-codec.0",
38 .init = mop500_ab8500_machine_init, 38 .init = mop500_ab8500_machine_init,
39 .ops = mop500_ab8500_ops, 39 .ops = mop500_ab8500_ops,
@@ -43,7 +43,7 @@ struct snd_soc_dai_link mop500_dai_links[] = {
43 .stream_name = "ab8500_1", 43 .stream_name = "ab8500_1",
44 .cpu_dai_name = "ux500-msp-i2s.3", 44 .cpu_dai_name = "ux500-msp-i2s.3",
45 .codec_dai_name = "ab8500-codec-dai.1", 45 .codec_dai_name = "ab8500-codec-dai.1",
46 .platform_name = "ux500-pcm.0", 46 .platform_name = "ux500-msp-i2s.3",
47 .codec_name = "ab8500-codec.0", 47 .codec_name = "ab8500-codec.0",
48 .init = NULL, 48 .init = NULL,
49 .ops = mop500_ab8500_ops, 49 .ops = mop500_ab8500_ops,
diff --git a/sound/soc/ux500/ux500_msp_dai.c b/sound/soc/ux500/ux500_msp_dai.c
index be94bf9bf94f..478b4b60e0cc 100644
--- a/sound/soc/ux500/ux500_msp_dai.c
+++ b/sound/soc/ux500/ux500_msp_dai.c
@@ -28,6 +28,7 @@
28 28
29#include "ux500_msp_i2s.h" 29#include "ux500_msp_i2s.h"
30#include "ux500_msp_dai.h" 30#include "ux500_msp_dai.h"
31#include "ux500_pcm.h"
31 32
32static int setup_pcm_multichan(struct snd_soc_dai *dai, 33static int setup_pcm_multichan(struct snd_soc_dai *dai,
33 struct ux500_msp_config *msp_config) 34 struct ux500_msp_config *msp_config)
@@ -398,11 +399,28 @@ static int ux500_msp_dai_startup(struct snd_pcm_substream *substream,
398 return ret; 399 return ret;
399 } 400 }
400 401
401 /* Enable clock */ 402 /* Prepare and enable clocks */
402 dev_dbg(dai->dev, "%s: Enabling MSP-clock.\n", __func__); 403 dev_dbg(dai->dev, "%s: Enabling MSP-clocks.\n", __func__);
403 clk_enable(drvdata->clk); 404 ret = clk_prepare_enable(drvdata->pclk);
405 if (ret) {
406 dev_err(drvdata->msp->dev,
407 "%s: Failed to prepare/enable pclk!\n", __func__);
408 goto err_pclk;
409 }
404 410
405 return 0; 411 ret = clk_prepare_enable(drvdata->clk);
412 if (ret) {
413 dev_err(drvdata->msp->dev,
414 "%s: Failed to prepare/enable clk!\n", __func__);
415 goto err_clk;
416 }
417
418 return ret;
419err_clk:
420 clk_disable_unprepare(drvdata->pclk);
421err_pclk:
422 regulator_disable(drvdata->reg_vape);
423 return ret;
406} 424}
407 425
408static void ux500_msp_dai_shutdown(struct snd_pcm_substream *substream, 426static void ux500_msp_dai_shutdown(struct snd_pcm_substream *substream,
@@ -428,8 +446,9 @@ static void ux500_msp_dai_shutdown(struct snd_pcm_substream *substream,
428 __func__, dai->id, snd_pcm_stream_str(substream)); 446 __func__, dai->id, snd_pcm_stream_str(substream));
429 } 447 }
430 448
431 /* Disable clock */ 449 /* Disable and unprepare clocks */
432 clk_disable(drvdata->clk); 450 clk_disable_unprepare(drvdata->clk);
451 clk_disable_unprepare(drvdata->pclk);
433 452
434 /* Disable regulator */ 453 /* Disable regulator */
435 ret = regulator_disable(drvdata->reg_vape); 454 ret = regulator_disable(drvdata->reg_vape);
@@ -780,6 +799,14 @@ static int __devinit ux500_msp_drv_probe(struct platform_device *pdev)
780 } 799 }
781 prcmu_qos_add_requirement(PRCMU_QOS_APE_OPP, (char *)pdev->name, 50); 800 prcmu_qos_add_requirement(PRCMU_QOS_APE_OPP, (char *)pdev->name, 50);
782 801
802 drvdata->pclk = clk_get(&pdev->dev, "apb_pclk");
803 if (IS_ERR(drvdata->pclk)) {
804 ret = (int)PTR_ERR(drvdata->pclk);
805 dev_err(&pdev->dev, "%s: ERROR: clk_get of pclk failed (%d)!\n",
806 __func__, ret);
807 goto err_pclk;
808 }
809
783 drvdata->clk = clk_get(&pdev->dev, NULL); 810 drvdata->clk = clk_get(&pdev->dev, NULL);
784 if (IS_ERR(drvdata->clk)) { 811 if (IS_ERR(drvdata->clk)) {
785 ret = (int)PTR_ERR(drvdata->clk); 812 ret = (int)PTR_ERR(drvdata->clk);
@@ -806,12 +833,23 @@ static int __devinit ux500_msp_drv_probe(struct platform_device *pdev)
806 goto err_init_msp; 833 goto err_init_msp;
807 } 834 }
808 835
836 ret = ux500_pcm_register_platform(pdev);
837 if (ret < 0) {
838 dev_err(&pdev->dev,
839 "Error: %s: Failed to register PCM platform device!\n",
840 __func__);
841 goto err_reg_plat;
842 }
843
809 return 0; 844 return 0;
810 845
846err_reg_plat:
847 snd_soc_unregister_dais(&pdev->dev, ARRAY_SIZE(ux500_msp_dai_drv));
811err_init_msp: 848err_init_msp:
812 clk_put(drvdata->clk); 849 clk_put(drvdata->clk);
813
814err_clk: 850err_clk:
851 clk_put(drvdata->pclk);
852err_pclk:
815 devm_regulator_put(drvdata->reg_vape); 853 devm_regulator_put(drvdata->reg_vape);
816 854
817 return ret; 855 return ret;
@@ -821,12 +859,15 @@ static int __devexit ux500_msp_drv_remove(struct platform_device *pdev)
821{ 859{
822 struct ux500_msp_i2s_drvdata *drvdata = dev_get_drvdata(&pdev->dev); 860 struct ux500_msp_i2s_drvdata *drvdata = dev_get_drvdata(&pdev->dev);
823 861
862 ux500_pcm_unregister_platform(pdev);
863
824 snd_soc_unregister_dais(&pdev->dev, ARRAY_SIZE(ux500_msp_dai_drv)); 864 snd_soc_unregister_dais(&pdev->dev, ARRAY_SIZE(ux500_msp_dai_drv));
825 865
826 devm_regulator_put(drvdata->reg_vape); 866 devm_regulator_put(drvdata->reg_vape);
827 prcmu_qos_remove_requirement(PRCMU_QOS_APE_OPP, "ux500_msp_i2s"); 867 prcmu_qos_remove_requirement(PRCMU_QOS_APE_OPP, "ux500_msp_i2s");
828 868
829 clk_put(drvdata->clk); 869 clk_put(drvdata->clk);
870 clk_put(drvdata->pclk);
830 871
831 ux500_msp_i2s_cleanup_msp(pdev, drvdata->msp); 872 ux500_msp_i2s_cleanup_msp(pdev, drvdata->msp);
832 873
diff --git a/sound/soc/ux500/ux500_msp_dai.h b/sound/soc/ux500/ux500_msp_dai.h
index 98202a34a5dd..9c778d9c3838 100644
--- a/sound/soc/ux500/ux500_msp_dai.h
+++ b/sound/soc/ux500/ux500_msp_dai.h
@@ -69,6 +69,7 @@ struct ux500_msp_i2s_drvdata {
69 /* Clocks */ 69 /* Clocks */
70 unsigned int master_clk; 70 unsigned int master_clk;
71 struct clk *clk; 71 struct clk *clk;
72 struct clk *pclk;
72 73
73 /* Regulators */ 74 /* Regulators */
74 int vape_opp_constraint; 75 int vape_opp_constraint;
diff --git a/sound/soc/ux500/ux500_pcm.c b/sound/soc/ux500/ux500_pcm.c
index 1a04e248453c..894c9f4bb9f6 100644
--- a/sound/soc/ux500/ux500_pcm.c
+++ b/sound/soc/ux500/ux500_pcm.c
@@ -282,7 +282,7 @@ static struct snd_soc_platform_driver ux500_pcm_soc_drv = {
282 .pcm_new = ux500_pcm_new, 282 .pcm_new = ux500_pcm_new,
283}; 283};
284 284
285static int __devexit ux500_pcm_drv_probe(struct platform_device *pdev) 285int __devinit ux500_pcm_register_platform(struct platform_device *pdev)
286{ 286{
287 int ret; 287 int ret;
288 288
@@ -296,23 +296,12 @@ static int __devexit ux500_pcm_drv_probe(struct platform_device *pdev)
296 296
297 return 0; 297 return 0;
298} 298}
299EXPORT_SYMBOL_GPL(ux500_pcm_register_platform);
299 300
300static int __devinit ux500_pcm_drv_remove(struct platform_device *pdev) 301int __devexit ux500_pcm_unregister_platform(struct platform_device *pdev)
301{ 302{
302 snd_soc_unregister_platform(&pdev->dev); 303 snd_soc_unregister_platform(&pdev->dev);
303 304
304 return 0; 305 return 0;
305} 306}
306 307EXPORT_SYMBOL_GPL(ux500_pcm_unregister_platform);
307static struct platform_driver ux500_pcm_driver = {
308 .driver = {
309 .name = "ux500-pcm",
310 .owner = THIS_MODULE,
311 },
312
313 .probe = ux500_pcm_drv_probe,
314 .remove = __devexit_p(ux500_pcm_drv_remove),
315};
316module_platform_driver(ux500_pcm_driver);
317
318MODULE_LICENSE("GPL v2");
diff --git a/sound/soc/ux500/ux500_pcm.h b/sound/soc/ux500/ux500_pcm.h
index 77ed44d371e9..76d344476afc 100644
--- a/sound/soc/ux500/ux500_pcm.h
+++ b/sound/soc/ux500/ux500_pcm.h
@@ -32,4 +32,7 @@
32#define UX500_PLATFORM_PERIODS_MAX 48 32#define UX500_PLATFORM_PERIODS_MAX 48
33#define UX500_PLATFORM_BUFFER_BYTES_MAX (2048 * PAGE_SIZE) 33#define UX500_PLATFORM_BUFFER_BYTES_MAX (2048 * PAGE_SIZE)
34 34
35int ux500_pcm_register_platform(struct platform_device *pdev);
36int ux500_pcm_unregister_platform(struct platform_device *pdev);
37
35#endif 38#endif
diff --git a/sound/usb/card.c b/sound/usb/card.c
index 282f0fc9fed1..dbf7999d18b4 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -559,9 +559,11 @@ static void snd_usb_audio_disconnect(struct usb_device *dev,
559 return; 559 return;
560 560
561 card = chip->card; 561 card = chip->card;
562 mutex_lock(&register_mutex);
563 down_write(&chip->shutdown_rwsem); 562 down_write(&chip->shutdown_rwsem);
564 chip->shutdown = 1; 563 chip->shutdown = 1;
564 up_write(&chip->shutdown_rwsem);
565
566 mutex_lock(&register_mutex);
565 chip->num_interfaces--; 567 chip->num_interfaces--;
566 if (chip->num_interfaces <= 0) { 568 if (chip->num_interfaces <= 0) {
567 snd_card_disconnect(card); 569 snd_card_disconnect(card);
@@ -582,11 +584,9 @@ static void snd_usb_audio_disconnect(struct usb_device *dev,
582 snd_usb_mixer_disconnect(p); 584 snd_usb_mixer_disconnect(p);
583 } 585 }
584 usb_chip[chip->index] = NULL; 586 usb_chip[chip->index] = NULL;
585 up_write(&chip->shutdown_rwsem);
586 mutex_unlock(&register_mutex); 587 mutex_unlock(&register_mutex);
587 snd_card_free_when_closed(card); 588 snd_card_free_when_closed(card);
588 } else { 589 } else {
589 up_write(&chip->shutdown_rwsem);
590 mutex_unlock(&register_mutex); 590 mutex_unlock(&register_mutex);
591 } 591 }
592} 592}
diff --git a/sound/usb/midi.c b/sound/usb/midi.c
index c83f6143c0eb..eeefbce3873c 100644
--- a/sound/usb/midi.c
+++ b/sound/usb/midi.c
@@ -148,6 +148,7 @@ struct snd_usb_midi_out_endpoint {
148 struct snd_usb_midi_out_endpoint* ep; 148 struct snd_usb_midi_out_endpoint* ep;
149 struct snd_rawmidi_substream *substream; 149 struct snd_rawmidi_substream *substream;
150 int active; 150 int active;
151 bool autopm_reference;
151 uint8_t cable; /* cable number << 4 */ 152 uint8_t cable; /* cable number << 4 */
152 uint8_t state; 153 uint8_t state;
153#define STATE_UNKNOWN 0 154#define STATE_UNKNOWN 0
@@ -1076,7 +1077,8 @@ static int snd_usbmidi_output_open(struct snd_rawmidi_substream *substream)
1076 return -ENXIO; 1077 return -ENXIO;
1077 } 1078 }
1078 err = usb_autopm_get_interface(umidi->iface); 1079 err = usb_autopm_get_interface(umidi->iface);
1079 if (err < 0) 1080 port->autopm_reference = err >= 0;
1081 if (err < 0 && err != -EACCES)
1080 return -EIO; 1082 return -EIO;
1081 substream->runtime->private_data = port; 1083 substream->runtime->private_data = port;
1082 port->state = STATE_UNKNOWN; 1084 port->state = STATE_UNKNOWN;
@@ -1087,9 +1089,11 @@ static int snd_usbmidi_output_open(struct snd_rawmidi_substream *substream)
1087static int snd_usbmidi_output_close(struct snd_rawmidi_substream *substream) 1089static int snd_usbmidi_output_close(struct snd_rawmidi_substream *substream)
1088{ 1090{
1089 struct snd_usb_midi* umidi = substream->rmidi->private_data; 1091 struct snd_usb_midi* umidi = substream->rmidi->private_data;
1092 struct usbmidi_out_port *port = substream->runtime->private_data;
1090 1093
1091 substream_open(substream, 0); 1094 substream_open(substream, 0);
1092 usb_autopm_put_interface(umidi->iface); 1095 if (port->autopm_reference)
1096 usb_autopm_put_interface(umidi->iface);
1093 return 0; 1097 return 0;
1094} 1098}
1095 1099
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index 5c12a3fe8c3e..ef6fa24fc473 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -459,7 +459,7 @@ static int configure_endpoint(struct snd_usb_substream *subs)
459 return ret; 459 return ret;
460 460
461 if (subs->sync_endpoint) 461 if (subs->sync_endpoint)
462 ret = snd_usb_endpoint_set_params(subs->data_endpoint, 462 ret = snd_usb_endpoint_set_params(subs->sync_endpoint,
463 subs->pcm_format, 463 subs->pcm_format,
464 subs->channels, 464 subs->channels,
465 subs->period_bytes, 465 subs->period_bytes,
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 2655ae9a3ad8..ea095abbe97e 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -206,8 +206,10 @@ int get_msr(int cpu, off_t offset, unsigned long long *msr)
206 retval = pread(fd, msr, sizeof *msr, offset); 206 retval = pread(fd, msr, sizeof *msr, offset);
207 close(fd); 207 close(fd);
208 208
209 if (retval != sizeof *msr) 209 if (retval != sizeof *msr) {
210 fprintf(stderr, "%s offset 0x%zx read failed\n", pathname, offset);
210 return -1; 211 return -1;
212 }
211 213
212 return 0; 214 return 0;
213} 215}
@@ -1101,7 +1103,9 @@ void turbostat_loop()
1101 1103
1102restart: 1104restart:
1103 retval = for_all_cpus(get_counters, EVEN_COUNTERS); 1105 retval = for_all_cpus(get_counters, EVEN_COUNTERS);
1104 if (retval) { 1106 if (retval < -1) {
1107 exit(retval);
1108 } else if (retval == -1) {
1105 re_initialize(); 1109 re_initialize();
1106 goto restart; 1110 goto restart;
1107 } 1111 }
@@ -1114,7 +1118,9 @@ restart:
1114 } 1118 }
1115 sleep(interval_sec); 1119 sleep(interval_sec);
1116 retval = for_all_cpus(get_counters, ODD_COUNTERS); 1120 retval = for_all_cpus(get_counters, ODD_COUNTERS);
1117 if (retval) { 1121 if (retval < -1) {
1122 exit(retval);
1123 } else if (retval == -1) {
1118 re_initialize(); 1124 re_initialize();
1119 goto restart; 1125 goto restart;
1120 } 1126 }
@@ -1126,7 +1132,9 @@ restart:
1126 flush_stdout(); 1132 flush_stdout();
1127 sleep(interval_sec); 1133 sleep(interval_sec);
1128 retval = for_all_cpus(get_counters, EVEN_COUNTERS); 1134 retval = for_all_cpus(get_counters, EVEN_COUNTERS);
1129 if (retval) { 1135 if (retval < -1) {
1136 exit(retval);
1137 } else if (retval == -1) {
1130 re_initialize(); 1138 re_initialize();
1131 goto restart; 1139 goto restart;
1132 } 1140 }
@@ -1545,8 +1553,11 @@ void turbostat_init()
1545int fork_it(char **argv) 1553int fork_it(char **argv)
1546{ 1554{
1547 pid_t child_pid; 1555 pid_t child_pid;
1556 int status;
1548 1557
1549 for_all_cpus(get_counters, EVEN_COUNTERS); 1558 status = for_all_cpus(get_counters, EVEN_COUNTERS);
1559 if (status)
1560 exit(status);
1550 /* clear affinity side-effect of get_counters() */ 1561 /* clear affinity side-effect of get_counters() */
1551 sched_setaffinity(0, cpu_present_setsize, cpu_present_set); 1562 sched_setaffinity(0, cpu_present_setsize, cpu_present_set);
1552 gettimeofday(&tv_even, (struct timezone *)NULL); 1563 gettimeofday(&tv_even, (struct timezone *)NULL);
@@ -1556,7 +1567,6 @@ int fork_it(char **argv)
1556 /* child */ 1567 /* child */
1557 execvp(argv[0], argv); 1568 execvp(argv[0], argv);
1558 } else { 1569 } else {
1559 int status;
1560 1570
1561 /* parent */ 1571 /* parent */
1562 if (child_pid == -1) { 1572 if (child_pid == -1) {
@@ -1568,7 +1578,7 @@ int fork_it(char **argv)
1568 signal(SIGQUIT, SIG_IGN); 1578 signal(SIGQUIT, SIG_IGN);
1569 if (waitpid(child_pid, &status, 0) == -1) { 1579 if (waitpid(child_pid, &status, 0) == -1) {
1570 perror("wait"); 1580 perror("wait");
1571 exit(1); 1581 exit(status);
1572 } 1582 }
1573 } 1583 }
1574 /* 1584 /*
@@ -1585,7 +1595,7 @@ int fork_it(char **argv)
1585 1595
1586 fprintf(stderr, "%.6f sec\n", tv_delta.tv_sec + tv_delta.tv_usec/1000000.0); 1596 fprintf(stderr, "%.6f sec\n", tv_delta.tv_sec + tv_delta.tv_usec/1000000.0);
1587 1597
1588 return 0; 1598 return status;
1589} 1599}
1590 1600
1591void cmdline(int argc, char **argv) 1601void cmdline(int argc, char **argv)
@@ -1594,7 +1604,7 @@ void cmdline(int argc, char **argv)
1594 1604
1595 progname = argv[0]; 1605 progname = argv[0];
1596 1606
1597 while ((opt = getopt(argc, argv, "+pPSvisc:sC:m:M:")) != -1) { 1607 while ((opt = getopt(argc, argv, "+pPSvi:sc:sC:m:M:")) != -1) {
1598 switch (opt) { 1608 switch (opt) {
1599 case 'p': 1609 case 'p':
1600 show_core_only++; 1610 show_core_only++;